diff --git a/build.bat b/build.bat index 9a2859d5..c01926b5 100644 --- a/build.bat +++ b/build.bat @@ -1,7 +1,7 @@ @echo off rem See 'readme' file -if "%PROCESSOR_ARCHITECTURE%"=="x86" set BDS=%ProgramFiles%\Embarcadero\RAD Studio\9.0 -if "%PROCESSOR_ARCHITECTURE%"=="AMD64" set BDS=%ProgramFiles(x86)%\Embarcadero\RAD Studio\9.0 +if "%PROCESSOR_ARCHITECTURE%"=="x86" set BDS=%ProgramFiles%\Embarcadero\Studio\14.0 +if "%PROCESSOR_ARCHITECTURE%"=="AMD64" set BDS=%ProgramFiles(x86)%\Embarcadero\Studio\14.0 set WITH_DRAGEXT64=0 set WITH_DOTNET=1 rem set DRAGEXT64CL= diff --git a/deployment/license.setup-chrome.txt b/deployment/license.setup-chrome.txt deleted file mode 100644 index b92b2983..00000000 --- a/deployment/license.setup-chrome.txt +++ /dev/null @@ -1,294 +0,0 @@ -You can also review this license and further details online at: -http://winscp.net/eng/docs/license - - - A. GNU General Public License - B. License of WinSCP Icon Set - C. Privacy Policy - D. Licenses and Distribution Terms of WinSCP Installation Package - - - A. GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - -Copyright (C) 2007 Free Software Foundation, Inc. -Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - - Preamble - -The GNU General Public License is a free, copyleft license for software and other kinds of works. - -The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. 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 them 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 prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. - -For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. 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. - -Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. - -For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. - -Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. - -Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. - -The precise terms and conditions for copying, distribution and modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - -"This License" refers to version 3 of the GNU General Public License. - -"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. - -"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. - -To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. - -A "covered work" means either the unmodified Program or a work based on the Program. - -To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. - -To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. - -An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. - - 1. Source Code. - -The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. - -A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. - -The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. - -The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. - -The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. - -The Corresponding Source for a work in source code form is that same work. - - 2. Basic Permissions. - -All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. - -You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. - -Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - -No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. - -When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. - - 4. Conveying Verbatim Copies. - -You may convey 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; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. - -You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - -You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: - -a) The work must carry prominent notices stating that you modified it, and giving a relevant date. - -b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". - -c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. - -d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. - -A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. - - 6. Conveying Non-Source Forms. - -You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: - -a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. - -b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. - -c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. - -d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. - -e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. - -A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. - -A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. - -"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. - -If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). - -The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. - -Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. - - 7. Additional Terms. - -"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. - -When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. - -Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: - -a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or - -b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or - -c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or - -d) Limiting the use for publicity purposes of names of licensors or authors of the material; or - -e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or - -f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. - -All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. - -If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. - -Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. - - 8. Termination. - -You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). - -However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. - -Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. - -Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. - - 9. Acceptance Not Required for Having Copies. - -You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - -Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. - -An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. - -You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. - - 11. Patents. - -A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". - -A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. - -Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. - -In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. - -If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. - -If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. - -A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. - -Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - -If 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 convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - -Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. - - 14. Revised Versions of this License. - -The Free Software Foundation may publish revised and/or new versions of the GNU 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 that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Softwar Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. - -If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. - -Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. - - 15. Disclaimer of Warranty. - -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. - - 16. Limitation of Liability. - -IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 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. - - 17. Interpretation of Sections 15 and 16. - -If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - -If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. - -To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - -If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - - Copyright (C) - This program 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, your program's commands might be different; for a GUI interface, you would use an "about box". - -You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . - -The GNU 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 Lesser General Public License instead of this License. But first, please read . - - - B. License of WinSCP Icon Set - -Note that all images distributed in or with WinSCP application are NOT published under the GNU General Public License. It means that it is not allowed to redistribute or reuse these images or parts of them or modifications of them without WinSCP separately or in or with another software. - -You agree that all ownership and copyright of the licensed stock icons remain the property of York Technologies Limited. WinSCP was granted a license to display this graphical media royalty-free in WinSCP software applications, web design, presentations, and multimedia projects that WinSCP creates and/or distributes. - - - C. WinSCP Privacy Policy - -Please take time to read WinSCP Privacy policy at http://winscp.net/eng/docs/privacy - -WinSCP includes functionality to collect and send non-personal WinSCP Usage statistics and to automatically check for application updates. The only potentially personal information sent to WinSCP is IP addresses. Users can opt-out from using this functionality in the installer or anytime later in WinSCP Preferences. WinSCP Usage statistics help improve future versions of WinSCP. Once sent, usage statistics are stored for analysis (except IP addresses) and made available to the core WinSCP team only. - -Before disabling WinSCP Usage statistics, be so kind and consider that it plays very important role in the WinSCP development. We work very hard to make WinSCP reliable and useful. We also love improving WinSCP with every release. And last but not least, we provide WinSCP application to you for free and we want this to stay so! However our resources and time are unfortunately very limited. We want to focus our effort on improving the right features for you. That is why we need to learn more about how you use WinSCP. - -If you still want to disable WinSCP Usage statistics already during installation, you may do so using Custom installation. - -Thank you! - - - D. Licenses and Distribution Terms of WinSCP Installation Package - -Note that GNU General Public License applies solely to WinSCP application. During WinSCP installation you might be offered to install also other application having own license agreement. While nothing will be installed without your consent be sure to read and understand the respective license conditions. - -In case you intent to distribute WinSCP Installation Package you are not allowed to bundles anything in or with the WinSCP Installation Package; and you are obliged to comply with all applicable export and re-export control laws and regulations: (a) the Export Administration Regulations maintained by the U.S. Department of Commerce; (b) trade and economic sanctions maintained by the U.S. Treasury Department's Office of Foreign Assets Control; and (c) the International Traffic in Arms Regulations maintained by the U.S. Department of State. Unless Distributor obtains prior authorisation required by applicable Export Laws, Distributor shall not export any Product to Cuba, Iran, North Korea, Sudan or Syria. - diff --git a/deployment/winscp.isl b/deployment/winscp.isl index e263e58c..84ed89e8 100644 --- a/deployment/winscp.isl +++ b/deployment/winscp.isl @@ -21,22 +21,10 @@ RegisteringAsUrlHandlers=Registering to handle URL addresses... AddingSearchPath=Adding installation directory to search path (%PATH%) RemovingObsoleteTranslations=Removing obsolete translations -RSAKeyTools=Key tools SendToHookNew=WinSCP (for upload) Launch=Launch &WinSCP OpenGettingStarted=Open &Getting started page -; used only to delete file from older version -; (not to be translated for new languages) -SupportForum=Support forum -WebSite=WinSCP Web Site -PuTTYgenManual=PuTTYgen Manual -PageantManual=Pageant Manual -KeysManual=Using public keys for SSH authentication -PuttyWebSite=PuTTY Web Site -DocumentationPage=Documentation -SendToHook=WinSCP3 (upload using SFTP or SCP) - HelpButton=&Help ProgramComment=SFTP, FTP and SCP client @@ -76,3 +64,4 @@ AboutDonations=About donations Donate=Donate %s Currency=USD ImportSites=Looking for sites to import... +ApplicationsFoundDragExt=The following applications have loaded WinSCP Drag & drop shell extension that needs to be updated by Setup. It is recommended that you allow Setup to automatically close these applications. After the installation has completed, Setup will attempt to restart the applications. You can restart your computer later instead, if you do not need to use the extension. diff --git a/deployment/winscpsetup.iss b/deployment/winscpsetup.iss index c75083cd..572ebc37 100644 --- a/deployment/winscpsetup.iss +++ b/deployment/winscpsetup.iss @@ -45,6 +45,7 @@ #define ShellExt64FileSource BinariesDir+"\"+ShellExt64FileName #define ConsoleFileSource BinariesDir+"\WinSCP.com" #define IconFileSource SourceDir+"\resource\Icon256.ico" +#define MapFileSource BinariesDir+"\WinSCP.map" #ifdef Donations #define PayPalCardImage "paypalcard.bmp" @@ -61,10 +62,6 @@ #define WebArguments "ver=" +VersionOnly + "&lang={language}&utm_source=winscp&utm_medium=setup&utm_campaign=" + VersionOnly #define WebGettingStarted WebRoot + "eng/installed.php?" + WebArguments + "&prevver=" -#ifdef OpenCandy -#include "opencandy\OCSetupHlp.iss" -#endif - ; Some features of ISCC requires path relative to script, ; some path relative to CWD #define MessagesPathRel(L) TranslationDirRel + "\" + "WinSCP." + L + ".isl" @@ -72,17 +69,6 @@ #define ExplorerFile "explorer.bmp" #define CommanderFile "commander.bmp" -#ifdef Chrome -#define ChromeLogoFile "chromelogo.bmp" -#define ChromeAdFile "chromead.bmp" -#define ChromeGcApiDllFile "gcapi_dll.dll" -#define ChromeCheckerFile "chromech.exe" -#define ChromeInstallerFile "WinSCP_Chrome.exe" -#define ChromeBrandCode1 "WSCA" -#define ChromeBrandCode2 "WSCB" -#include "chrome\texts.iss" -#endif - [Setup] AppId={#AppId} AppName=WinSCP @@ -99,11 +85,7 @@ VersionInfoCopyright=(c) 2000-{#Year} Martin Prikryl DefaultDirName={pf}\WinSCP DefaultGroupName=WinSCP AllowNoIcons=yes -#ifdef Chrome -LicenseFile=license.setup-chrome.txt -#else LicenseFile=license.setup.txt -#endif UninstallDisplayIcon={app}\WinSCP.exe OutputDir={#OutputDir} DisableStartupPrompt=yes @@ -122,9 +104,6 @@ SetupIconFile=winscpsetup.ico #ifdef Sign SignTool=sign $f "WinSCP Installer" http://winscp.net/eng/docs/installation #endif -#ifdef Chrome -RestartIfNeededByRun=no -#endif [Languages] Name: {#DefaultLang}; MessagesFile: {#MessagesPathRel(DefaultLang)} @@ -242,29 +221,9 @@ Name: "{sendto}\{cm:SendToHookNew}"; Filename: "{app}\WinSCP.exe"; \ Parameters: "/upload"; Tasks: sendtohook [InstallDelete] +; Remove pre-524 licence file (without .txt extension) Type: files; Name: "{app}\license" -Type: files; Name: "{group}\{cm:WebSite}.url" -Type: files; Name: "{group}\{cm:SupportForum}.url" -Type: files; Name: "{group}\{cm:DocumentationPage}.url" -Type: files; Name: "{group}\{cm:RSAKeyTools}\{cm:PuTTYgenManual}.lnk" -Type: files; Name: "{group}\{cm:RSAKeyTools}\{cm:PageantManual}.lnk" -Type: files; Name: "{group}\{cm:RSAKeyTools}\{cm:PuttyWebSite}.url" -; Legacy sendto hook (SCP-only), only english link is removed -Type: files; Name: "{sendto}\WinSCP3 (upload using SCP).lnk" -Type: files; Name: "{group}\{cm:RSAKeyTools}\{cm:KeysManual}.lnk" -Type: files; Name: "{app}\{cm:SupportForum}.url" -Type: files; Name: "{app}\{cm:DocumentationPage}.url" -Type: files; Name: "{app}\WinSCP.url" -Type: files; Name: "{app}\PuTTY\PuTTY.url" -; Remove links to winscp3 -Type: files; Name: "{app}\WinSCP3.exe" -Type: files; Name: "{app}\WinSCP3.com" -Type: files; Name: "{group}\WinSCP3.lnk" -Type: files; Name: "{userdesktop}\WinSCP3.lnk" -Type: files; Name: "{commondesktop}\WinSCP3.lnk" -Type: files; Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\WinSCP3.lnk" -Type: files; Name: "{sendto}\{cm:SendToHook}.lnk" -; Remove +; Remove pre-520 start menu folders Type: filesandordirs; Name: "{commonprograms}\WinSCP" Type: filesandordirs; Name: "{userprograms}\WinSCP" @@ -279,34 +238,19 @@ Filename: "{app}\WinSCP.exe"; Parameters: "/Usage=TypicalInstallation:1"; \ Check: IsTypicalInstallation Filename: "{app}\WinSCP.exe"; Parameters: "/Usage=TypicalInstallation:0"; \ Check: not IsTypicalInstallation -#ifdef Chrome -Filename: "{tmp}\{#ChromeInstallerFile}"; \ - Parameters: "/r1:{#ChromeBrandCode1} /r2:{#ChromeBrandCode2} /b:1"; \ - StatusMsg: {cm:ChromeInstalling}; \ - Check: IsChromeSelected and IsChromeDefaultSelected -Filename: "{tmp}\{#ChromeInstallerFile}"; \ - Parameters: "/r1:{#ChromeBrandCode1} /r2:{#ChromeBrandCode2} /b:0"; \ - StatusMsg: {cm:ChromeInstalling}; \ - Check: IsChromeSelected and (not IsChromeDefaultSelected) -#endif [UninstallDelete] ; These additional files are created by application Type: files; Name: "{app}\WinSCP.ini" Type: files; Name: "{app}\WinSCP.cgl" -; WinSCP3 may remain from previous version, note that we do not delete it on -; upgrade, only duplicate into WinSCP.ini, see [Files] -Type: files; Name: "{app}\WinSCP3.ini" [Files] Source: "{#MainFileSource}"; DestDir: "{app}"; \ Components: main; Flags: ignoreversion -; If WinSCP3.ini already exists on target system, copy it into WinSCP.ini -; (if WinSCP.ini does not exist yet) -Source: "{app}\WinSCP3.ini"; DestName: "WinSCP.ini"; DestDir: "{app}"; \ - Components: main; Flags: ignoreversion external skipifsourcedoesntexist onlyifdoesntexist Source: "{#ConsoleFileSource}"; DestDir: "{app}"; \ Components: main; Flags: ignoreversion +Source: "{#MapFileSource}"; DestDir: "{app}"; \ + Components: main; Flags: ignoreversion Source: "license.txt"; DestDir: "{app}"; \ Components: main; Flags: ignoreversion Source: "{#ShellExtFileSource}"; DestDir: "{app}"; \ @@ -331,18 +275,6 @@ Source: "{#CommanderFile}"; Flags: dontcopy Source: "{#PayPalCardImage}"; \ Flags: dontcopy #endif -#ifdef OpenCandy -Source: "{#OC_OCSETUPHLP_FILE_PATH}"; \ - Flags: dontcopy ignoreversion deleteafterinstall -#endif -#ifdef Chrome -Source: "chrome\{#ChromeLogoFile}"; Flags: dontcopy -Source: "chrome\{#ChromeAdFile}"; Flags: dontcopy -Source: "chrome\{#ChromeGcApiDllFile}"; Flags: dontcopy -Source: "chrome\{#ChromeCheckerFile}"; Flags: dontcopy -Source: "chrome\{#ChromeInstallerFile}"; DestDir: "{tmp}"; \ - Flags: deleteafterinstall; Check: IsChromeSelected -#endif [Registry] Root: HKCU; Subkey: "{#ParentRegistryKey}"; Flags: uninsdeletekeyifempty @@ -421,9 +353,6 @@ Filename: "{app}\WinSCP.exe"; Parameters: "/UnregisterForProtocols"; \ const wpSetupType = 100; wpInterface = 101; -#ifdef Chrome - wpChrome = 102; -#endif NewLine = #13#10; var @@ -444,17 +373,6 @@ var #endif InstallationDone: Boolean; LicenseAccepted: Boolean; -#ifdef Chrome - ChromeLogoImage: TBitmapImage; - ChromeLogoImageOffset: Integer; - ChromeAdImage: TBitmapImage; - ChromeCheckbox: TCheckbox; - ChromeDefaultCheckbox: TCheckbox; - ChromeLastPolicyText: TLabel; - ChromeAllowed: Boolean; - ChromeLaunched: Boolean; - LaunchChromeCheckbox: TCheckbox; -#endif procedure ShowMessage(Text: string); begin @@ -707,11 +625,6 @@ begin LaunchCheckbox.Enabled := not WillRestart; OpenGettingStartedCheckbox.Enabled := LaunchCheckbox.Enabled -#ifdef Chrome - and - ((not LaunchChromeCheckbox.Visible) or (not LaunchChromeCheckbox.Checked)); - LaunchChromeCheckbox.Enabled := LaunchCheckbox.Enabled -#endif end; procedure LinkLabel(Control: TLabel); @@ -752,97 +665,6 @@ begin Image.AutoSize := True; end; -#ifdef Chrome - -procedure ChromeCheckboxClick(Sender: TObject); -begin - ChromeDefaultCheckbox.Enabled := ChromeCheckbox.Checked; -end; - -procedure AddChromePolicyText(S: string; OnLinkClick: TNotifyEvent); -var - Caption: TLabel; - I: Integer; -begin - S := ExpandConstant(S); - - if s <> '' then - begin - Caption := TLabel.Create(ChromeDefaultCheckbox.Parent); - if ChromeLastPolicyText <> nil then - begin - Caption.Top := ChromeLastPolicyText.Top; - Caption.Left := ChromeLastPolicyText.Left + ChromeLastPolicyText.Width; - end - else - begin - Caption.Top := - ChromeDefaultCheckbox.Top + ChromeDefaultCheckbox.Height + ScaleY(4); - end; - Caption.Caption := S; - Caption.Parent := ChromeDefaultCheckbox.Parent; - Caption.Font.Name := 'Arial'; - Caption.Font.Size := Caption.Font.Size - 1; - Caption.Tag := 1; - - if OnLinkClick <> nil then - begin - Caption.Font.Style := Caption.Font.Style + [fsUnderline]; - Caption.Font.Color := clBlue; - Caption.Cursor := crHand; - Caption.OnClick := OnLinkClick; - end; - - if Caption.Left + Caption.Width > Caption.Parent.Width then - begin - Caption.Left := 0; - Caption.Top := Caption.Top + Caption.Height; - ChromeAdImage.Top := ChromeAdImage.Top - 1; - ChromeCheckbox.Top := ChromeCheckbox.Top - 3; - ChromeDefaultCheckbox.Top := ChromeDefaultCheckbox.Top - 4; - - for I := 0 to Caption.Parent.ControlCount - 1 do - begin - if Caption.Parent.Controls[I].Tag = 1 then - Caption.Parent.Controls[I].Top := Caption.Parent.Controls[I].Top - 5; - end; - - if Copy(Caption.Caption, 1, 1) = ' ' then - Caption.Caption := Copy(Caption.Caption, 2, Length(Caption.Caption) - 1); - end; - - ChromeLastPolicyText := Caption; - end; -end; - -procedure OpenPolicy(S: string); -begin - S := FmtMessage(S, [ExpandConstant('{cm:LanguageISOCode}')]); - OpenBrowser(S); -end; - -procedure ChromeTermsOfUseClick(Sender: TObject); -begin - OpenPolicy('http://www.google.com/chrome/intl/%1/eula_text.html'); -end; - -procedure ChromePrivacyPolicyClick(Sender: TObject); -begin - OpenPolicy('http://www.google.com/chrome/intl/%1/privacy.html'); -end; - -function IsChromeSelected: Boolean; -begin - Result := ChromeAllowed and ChromeCheckbox.Checked; -end; - -function IsChromeDefaultSelected: Boolean; -begin - Result := ChromeAllowed and ChromeDefaultCheckbox.Checked; -end; - -#endif - // WORKAROUND // Checkboxes and Radio buttons created on runtime do // not scale their height automatically @@ -866,19 +688,9 @@ var #endif S: string; I: Integer; -#ifdef OpenCandy - OpenCandyNewPageID: Integer; -#endif -#ifdef Chrome - ChromePage: TWizardPage; - ResultCode: Integer; -#endif begin InstallationDone := False; LicenseAccepted := False; -#ifdef Chrome - ChromeLaunched := False; -#endif DefaultLang := (ActiveLanguage = '{#DefaultLang}'); @@ -899,19 +711,6 @@ begin // to accomodate one more task WizardForm.TasksList.Height := WizardForm.TasksList.Height + ScaleY(8); -#ifndef Chrome - // allow installation without requiring user to accept license - WizardForm.LicenseAcceptedRadio.Checked := True; - WizardForm.LicenseAcceptedRadio.Visible := False; - WizardForm.LicenseLabel1.Visible := False; - WizardForm.LicenseNotAcceptedRadio.Visible := False; - WizardForm.LicenseMemo.Top := WizardForm.LicenseLabel1.Top; - WizardForm.LicenseMemo.Height := - WizardForm.LicenseNotAcceptedRadio.Top + - WizardForm.LicenseNotAcceptedRadio.Height - - WizardForm.LicenseMemo.Top - 5; -#endif - // hide installation types combo WizardForm.TypesCombo.Visible := False; WizardForm.ComponentsList.Height := @@ -1135,16 +934,6 @@ begin OpenGettingStartedCheckbox.Width := WizardForm.YesRadio.Width; ScaleFixedHeightControl(OpenGettingStartedCheckbox); OpenGettingStartedCheckbox.Parent := WizardForm.FinishedPage; -#ifdef Chrome - LaunchChromeCheckbox := TCheckbox.Create(WizardForm.FinishedPage); - LaunchChromeCheckbox.Caption := ExpandConstant('{cm:ChromeLaunch}'); - LaunchChromeCheckbox.Checked := True; - LaunchChromeCheckbox.Left := WizardForm.YesRadio.Left; - LaunchChromeCheckbox.Width := WizardForm.YesRadio.Width; - ScaleFixedHeightControl(LaunchChromeCheckbox); - LaunchChromeCheckbox.Parent := WizardForm.FinishedPage; - LaunchChromeCheckbox.OnClick := @UpdatePostInstallRunCheckboxes; -#endif #ifdef Donations @@ -1202,93 +991,6 @@ begin begin WizardForm.NoIconsCheck.Checked := True; end; - -#ifdef OpenCandy - OpenCandyInit('{#OC_STR_MY_PRODUCT_NAME}', '{#OC_STR_KEY}', '{#OC_STR_SECRET}', - ExpandConstant('{cm:LanguageISOCode}'), {#OC_INIT_MODE_NORMAL}); - OpenCandyNewPageID := OpenCandyInsertLoadDLLPage(wpLicense); - OpenCandyInsertConnectPage(OpenCandyNewPageID); - OpenCandyNewPageID := OpenCandyInsertLoadingPage(wpSelectTasks, ' ', ' ', 'Loading...', 'Arial', 100); - OpenCandyInsertOfferPage(OpenCandyNewPageID); -#endif - -#ifdef Chrome - ExtractTemporaryFile('{#ChromeGcApiDllFile}'); - ExtractTemporaryFile('{#ChromeCheckerFile}'); - - ChromeAllowed := - (not WizardSilent) and - ExecAsOriginalUser(ExpandConstant('{tmp}\{#ChromeCheckerFile}'), 'checkstandard', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) and - (ResultCode = 0) and - Exec(ExpandConstant('{tmp}\{#ChromeCheckerFile}'), 'checkelevated', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) and - (ResultCode = 0); - - if ChromeAllowed then - begin - Log('Chrome allowed'); - - ChromePage := CreateCustomPage(wpInterface, - ExpandConstant('{cm:ChromeTitle}'), - ExpandConstant('{cm:ChromePrompt}')); - - Caption := TLabel.Create(ChromePage); - Caption.WordWrap := True; - Caption.Caption := - '- ' + ExpandConstant('{cm:ChromePoint1}') + #13#10 + - '- ' + ExpandConstant('{cm:ChromePoint2}') + #13#10 + - '- ' + ExpandConstant('{cm:ChromePoint3}'); - Caption.Width := ChromePage.SurfaceWidth; - Caption.Parent := ChromePage.Surface; - - ChromeAdImage := TBitmapImage.Create(ChromePage); - ChromeAdImage.Top := Caption.Top + Caption.Height + ScaleY(6); - ChromeAdImage.Parent := ChromePage.Surface; - LoadEmbededBitmap(ChromeAdImage, '{#ChromeAdFile}'); - - ChromeCheckbox := TCheckbox.Create(ChromePage); - ChromeCheckbox.Top := ChromeAdImage.Top + ChromeAdImage.Height + ScaleY(6); - ChromeCheckbox.Left := ScaleX(4); - ChromeCheckbox.Width := - ChromePage.SurfaceWidth - ChromeCheckbox.Left; - ChromeCheckbox.Caption := ExpandConstant('{cm:ChromeCheck}'); - ChromeCheckbox.Checked := True; - ScaleFixedHeightControl(ChromeCheckbox); - ChromeCheckbox.Parent := ChromePage.Surface; - ChromeCheckbox.OnClick := @ChromeCheckboxClick; - - ChromeDefaultCheckbox := TCheckbox.Create(ChromePage); - ChromeDefaultCheckbox.Top := - ChromeCheckbox.Top + ChromeCheckbox.Height + ScaleY(4); - ChromeDefaultCheckbox.Left := ScaleX(4); - ChromeDefaultCheckbox.Width := - ChromePage.SurfaceWidth - ChromeDefaultCheckbox.Left; - ChromeDefaultCheckbox.Height := ScaleY(ChromeDefaultCheckbox.Height); - ScaleFixedHeightControl(ChromeDefaultCheckbox); - ChromeDefaultCheckbox.Caption := ExpandConstant('{cm:ChromeDefaultCheck}'); - ChromeDefaultCheckbox.Checked := True; - ChromeDefaultCheckbox.Parent := ChromePage.Surface; - - ChromeLastPolicyText := nil; - AddChromePolicyText('{cm:ChromeDisclaimerPrefix}', nil); - AddChromePolicyText('{cm:ChromeDisclaimerTermsOfUse}', @ChromeTermsOfUseClick); - AddChromePolicyText('{cm:ChromeDisclaimerInfix}', nil); - AddChromePolicyText('{cm:ChromeDisclaimerPrivacyPolicy}', @ChromePrivacyPolicyClick); - AddChromePolicyText('{cm:ChromeDisclaimerPostfix}', nil); - - // override the windows scheme to make sure it matches chrome logo background - WizardForm.MainPanel.Color := clWhite; - - ChromeLogoImage := TBitmapImage.Create(WizardForm.MainPanel); - ChromeLogoImage.Top := WizardForm.PageNameLabel.Top; - ChromeLogoImage.Left := ScaleX(8); - ChromeLogoImage.Parent := WizardForm.MainPanel; - LoadEmbededBitmap(ChromeLogoImage, '{#ChromeLogoFile}'); - ChromeLogoImage.Visible := False; - ChromeLogoImageOffset := - (ChromeLogoImage.Left + ChromeLogoImage.Width + ScaleX(8)) - - WizardForm.PageNameLabel.Left; - end; -#endif end; procedure RegisterPreviousData(PreviousDataKey: Integer); @@ -1307,10 +1009,6 @@ var LineHeight: Integer; LaunchCheckboxTop: Integer; begin -#ifdef OpenCandy - OpenCandyCurPageChanged(CurPageID); -#endif - if CurPageID = wpFinished then begin LineHeight := (WizardForm.NoRadio.Top - WizardForm.YesRadio.Top); @@ -1333,19 +1031,10 @@ begin else begin LaunchCheckboxTop := WizardForm.RunList.Top; -#ifdef Donations -#ifdef Chrome - DonationPanel.Visible := not IsChromeSelected; -#endif -#endif end; LaunchCheckbox.Top := LaunchCheckboxTop; OpenGettingStartedCheckbox.Top := LaunchCheckbox.Top + LineHeight; -#ifdef Chrome - LaunchChromeCheckbox.Visible := IsChromeSelected; - LaunchChromeCheckbox.Top := OpenGettingStartedCheckbox.Top + LineHeight; -#endif UpdatePostInstallRunCheckboxes(nil); end; @@ -1356,44 +1045,20 @@ begin LicenseAccepted := True; end; -#ifdef Chrome - if ChromeAllowed then + if CurPageID = wpPreparing then begin - if CurPageID = wpChrome then - begin - WizardForm.PageNameLabel.Width := WizardForm.PageNameLabel.Width - ChromeLogoImageOffset; - WizardForm.PageNameLabel.Left := WizardForm.PageNameLabel.Left + ChromeLogoImageOffset; - WizardForm.PageDescriptionLabel.Width := WizardForm.PageDescriptionLabel.Width - ChromeLogoImageOffset; - WizardForm.PageDescriptionLabel.Left := WizardForm.PageDescriptionLabel.Left + ChromeLogoImageOffset; - ChromeLogoImage.Visible := True; - end - else - if ChromeLogoImage.Visible then + // Are we at the "Restart applications?" screen + if WizardForm.PreparingLabel.Visible then begin - ChromeLogoImage.Visible := False; - WizardForm.PageNameLabel.Left := WizardForm.PageNameLabel.Left - ChromeLogoImageOffset; - WizardForm.PageNameLabel.Width := WizardForm.PageNameLabel.Width + ChromeLogoImageOffset; - WizardForm.PageDescriptionLabel.Left := WizardForm.PageDescriptionLabel.Left - ChromeLogoImageOffset; - WizardForm.PageDescriptionLabel.Width := WizardForm.PageDescriptionLabel.Width + ChromeLogoImageOffset; + WizardForm.PreparingLabel.Caption := + ExpandConstant('{cm:ApplicationsFoundDragExt}'); + WizardForm.IncTopDecHeight(WizardForm.PreparingMemo, + WizardForm.AdjustLabelHeight(WizardForm.PreparingLabel)); end; end; -#endif -end; - -#ifdef OpenCandy -function BackButtonClick(CurPageID: Integer): Boolean; -begin - Result := True; - OpenCandyBackButtonClick(CurPageID); end; -function NextButtonClick(CurPageID: Integer): Boolean; -begin - Result := OpenCandyNextButtonClick(CurPageID); -end; -#endif - function AskedRestart: Boolean; begin Result := WizardForm.YesRadio.Visible; @@ -1405,10 +1070,6 @@ var ReportUrl: string; ReportData: string; begin -#ifdef OpenCandy - OpenCandyDeinitializeSetup(); -#endif - // cannot send report, unless user already accepted license // (with privacy policy) if LicenseAccepted then @@ -1421,11 +1082,6 @@ begin ExpandConstant('{#VersionOnly}'), ActiveLanguage, PrevVersion]); -#ifdef Chrome - ReportData := ReportData + - Format('chromeoffered=%d&chromeaccepted=%d&chromelaunched=%d&', [Integer(ChromeAllowed), Integer(IsChromeSelected), Integer(ChromeLaunched)]); -#endif - try ReportUrl := ExpandConstant('{#WebReport}?') + ReportData; @@ -1449,9 +1105,6 @@ var Path: string; WebGettingStarted: string; OpenGettingStarted: Boolean; -#ifdef Chrome - LaunchChrome: Boolean; -#endif begin if CurStep = ssPostInstall then begin @@ -1478,13 +1131,6 @@ begin OpenGettingStartedCheckbox.Enabled and OpenGettingStartedCheckbox.Checked; -#ifdef Chrome - LaunchChrome := - ChromeAllowed and IsChromeSelected and - LaunchChromeCheckbox.Visible and // sanity check - LaunchChromeCheckbox.Checked; -#endif - if OpenGettingStarted then begin WebGettingStarted := @@ -1495,11 +1141,7 @@ begin if LaunchCheckbox.Checked then begin - if OpenGettingStarted -#ifdef Chrome - or LaunchChrome -#endif - then + if OpenGettingStarted then begin Log('Will launch WinSCP minimized'); ShowCmd := SW_SHOWMINIMIZED @@ -1513,43 +1155,19 @@ begin Path := ExpandConstant('{app}\{#MainFileName}'); ExecAsOriginalUser(Path, '', '', ShowCmd, ewNoWait, ErrorCode) end; - -#ifdef Chrome - if LaunchChrome then - begin - Log('Launching Chrome'); - ChromeLaunched := - ExecAsOriginalUser(ExpandConstant('{tmp}\{#ChromeCheckerFile}'), 'launch', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode) and - (ErrorCode = 0); - - Log(Format('Launched Chrome [%d] [%d]', [Integer(ChromeLaunched), ErrorCode])); - - if not ChromeLaunched then - begin - MsgBox(ExpandConstant('{cm:ChromeInstallationFailed}'), mbError, MB_OK); - end; - end; -#endif end; end; - -#ifdef OpenCandy - OpenCandyCurStepChanged(CurStep); -#endif end; function ShouldSkipPage(PageID: Integer): Boolean; begin Result := -#ifdef OpenCandy - OpenCandyShouldSkipPage(PageID) or -#endif { Hide most pages during typical installation } - (IsTypicalInstallation and - ((PageID = wpSelectDir) or (PageID = wpSelectComponents) or - (PageID = wpSelectTasks) or - { Hide Interface page for upgrades only, show for fresh installs } - ((PageID = wpInterface) and Upgrade))); + IsTypicalInstallation and + ((PageID = wpSelectDir) or (PageID = wpSelectComponents) or + (PageID = wpSelectTasks) or + { Hide Interface page for upgrades only, show for fresh installs } + ((PageID = wpInterface) and Upgrade)); end; function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo, diff --git a/dotnet/FileTransferProgressEventArgs.cs b/dotnet/FileTransferProgressEventArgs.cs index f8715f08..f962e601 100644 --- a/dotnet/FileTransferProgressEventArgs.cs +++ b/dotnet/FileTransferProgressEventArgs.cs @@ -3,8 +3,8 @@ namespace WinSCP { - public enum ProgressOperation { Transfer }; - public enum ProgressSide { Local, Remote }; + public enum ProgressOperation { Transfer } + public enum ProgressSide { Local, Remote } [Guid("E421924E-87F0-433E-AF38-CE034DC8E8CB")] [ClassInterface(Constants.ClassInterface)] diff --git a/dotnet/GlobalSuppressions.cs b/dotnet/GlobalSuppressions.cs index c44e7d3d..94747ca9 100644 --- a/dotnet/GlobalSuppressions.cs +++ b/dotnet/GlobalSuppressions.cs @@ -145,3 +145,5 @@ [assembly: SuppressMessage("Microsoft.Interoperability", "CA1404:CallGetLastErrorImmediatelyAfterPInvoke", Scope = "member", Target = "WinSCP.ExeSessionProcess.#Dispose()")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "WinSCP.Job.#.ctor(WinSCP.Logger,System.String)")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "WinSCP.Logger.#LastWin32ErrorMessage()")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "WinSCP.Session.#GuardProcessWithJobInternal")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "WinSCP.Session.#TestHandlesClosedInternal")] diff --git a/dotnet/Session.cs b/dotnet/Session.cs index 839d4db5..6edaa7f1 100644 --- a/dotnet/Session.cs +++ b/dotnet/Session.cs @@ -18,7 +18,7 @@ public enum SynchronizationMode Local = 0, Remote = 1, Both = 2, - }; + } [Guid("3F770EC1-35F5-4A7B-A000-46A2F7A213D8")] [ComVisible(true)] @@ -29,7 +29,7 @@ public enum SynchronizationCriteria Time = 0x01, Size = 0x02, Either = Time | Size, - }; + } public delegate void OutputDataReceivedEventHandler(object sender, OutputDataReceivedEventArgs e); public delegate void FileTransferredEventHandler(object sender, TransferEventArgs e); @@ -52,7 +52,7 @@ public sealed class Session : IDisposable, IReflect public string SessionLogPath { get { return _sessionLogPath; } set { CheckNotOpened(); _sessionLogPath = value; } } public string XmlLogPath { get { return _xmlLogPath; } set { CheckNotOpened(); _xmlLogPath = value; } } #if DEBUG - public bool GuardProcessWithJob { get { return _guardProcessWithJob; } set { CheckNotOpened(); _guardProcessWithJob = value; } } + public bool GuardProcessWithJob { get { return GuardProcessWithJobInternal; } set { GuardProcessWithJobInternal = value; } } public bool TestHandlesClosed { get { return TestHandlesClosedInternal; } set { TestHandlesClosedInternal = value; } } #endif @@ -189,10 +189,15 @@ public void Open(SessionOptions sessionOptions) Logger.WriteCounters(); Logger.WriteProcesses(); _process.WriteStatus(); + string exitCode = string.Format(CultureInfo.CurrentCulture, "{0}", _process.ExitCode); + if (_process.ExitCode < 0) + { + exitCode = string.Format(CultureInfo.CurrentCulture, "{0} ({1:X})", exitCode, _process.ExitCode); + } throw new SessionLocalException(this, string.Format(CultureInfo.CurrentCulture, "WinSCP process terminated with exit code {0} and output \"{1}\", without responding {2}", - _process.ExitCode, string.Join(Environment.NewLine, output), logExplanation)); + exitCode, string.Join(Environment.NewLine, output), logExplanation)); } Thread.Sleep(50); @@ -206,8 +211,12 @@ public void Open(SessionOptions sessionOptions) _logReader = new SessionLogReader(this); - _reader = _logReader.WaitForNonEmptyElementAndCreateLogReader("session", LogReadFlags.ThrowFailures); + _logReader.WaitForNonEmptyElement("session", LogReadFlags.ThrowFailures); + + // special variant of ElementLogReader that throws when closing element () is encountered + _reader = new SessionElementLogReader(_logReader); + // Skip "open" command using (ElementLogReader groupReader = _reader.WaitForGroupAndCreateLogReader()) { ReadElement(groupReader, LogReadFlags.ThrowFailures); @@ -222,6 +231,16 @@ public void Open(SessionOptions sessionOptions) } } + public void Close() + { + using (Logger.CreateCallstackAndLock()) + { + CheckOpened(); + + Cleanup(); + } + } + public RemoteDirectoryInfo ListDirectory(string path) { using (Logger.CreateCallstackAndLock()) @@ -830,6 +849,14 @@ private string SessionOptionsToOpenArguments(SessionOptions sessionOptions) { using (Logger.CreateCallstack()) { + if (sessionOptions.WebdavSecure) + { + if (sessionOptions.Protocol != Protocol.Webdav) + { + throw new ArgumentException("SessionOptions.WebdavSecure is set, but SessionOptions.Protocol is not Protocol.Webdav."); + } + } + string url; switch (sessionOptions.Protocol) { @@ -845,6 +872,17 @@ private string SessionOptionsToOpenArguments(SessionOptions sessionOptions) url = "ftp://"; break; + case Protocol.Webdav: + if (!sessionOptions.WebdavSecure) + { + url = "http://"; + } + else + { + url = "https://"; + } + break; + default: throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "{0} is not supported", sessionOptions.Protocol)); } @@ -931,11 +969,20 @@ private string SessionOptionsToOpenSwitches(SessionOptions sessionOptions) { if (!sessionOptions.IsSsh) { - throw new ArgumentException("SessionOptions.SshPrivateKey is set, but SessionOptions.Protocol is not Protocol.Sftp nor Protocol.Scp."); + throw new ArgumentException("SessionOptions.SshPrivateKeyPath is set, but SessionOptions.Protocol is not Protocol.Sftp nor Protocol.Scp."); } switches.Add(FormatSwitch("privatekey", sessionOptions.SshPrivateKeyPath)); } + if (!string.IsNullOrEmpty(sessionOptions.SshPrivateKeyPassphrase)) + { + if (string.IsNullOrEmpty(sessionOptions.SshPrivateKeyPath)) + { + throw new ArgumentException("SessionOptions.SshPrivateKeyPassphrase is set, but sessionOptions.SshPrivateKeyPath is not."); + } + switches.Add(FormatSwitch("passphrase", sessionOptions.SshPrivateKeyPassphrase)); + } + if (sessionOptions.FtpSecure != FtpSecure.None) { if (sessionOptions.Protocol != Protocol.Ftp) @@ -1295,7 +1342,7 @@ FieldInfo IReflect.GetField(string name, BindingFlags bindingAttr) using (Logger.CreateCallstack()) { Logger.WriteLine("Name [{0}]", name); - FieldInfo result = typeof(Session).GetField(name, bindingAttr); + FieldInfo result = GetType().GetField(name, bindingAttr); Logger.WriteLine("Result [{0}]", result != null ? result.Name : "null"); return result; } @@ -1305,7 +1352,7 @@ FieldInfo[] IReflect.GetFields(BindingFlags bindingAttr) { using (Logger.CreateCallstack()) { - FieldInfo[] result = typeof(Session).GetFields(bindingAttr); + FieldInfo[] result = GetType().GetFields(bindingAttr); Logger.WriteLine("Fields [{0}]", result.Length); return result; } @@ -1316,7 +1363,7 @@ MemberInfo[] IReflect.GetMember(string name, BindingFlags bindingAttr) using (Logger.CreateCallstack()) { Logger.WriteLine("Name [{0}]", name); - MemberInfo[] result = typeof(Session).GetMember(name, bindingAttr); + MemberInfo[] result = GetType().GetMember(name, bindingAttr); Logger.WriteLine("Result [{0}]", result.Length); return result; } @@ -1326,7 +1373,7 @@ MemberInfo[] IReflect.GetMembers(BindingFlags bindingAttr) { using (Logger.CreateCallstack()) { - MemberInfo[] result = typeof(Session).GetMembers(bindingAttr); + MemberInfo[] result = GetType().GetMembers(bindingAttr); Logger.WriteLine("Result [{0}]", result.Length); return result; } @@ -1337,7 +1384,7 @@ MethodInfo IReflect.GetMethod(string name, BindingFlags bindingAttr) using (Logger.CreateCallstack()) { Logger.WriteLine("Name [{0}]", name); - MethodInfo result = typeof(Session).GetMethod(name, bindingAttr); + MethodInfo result = GetType().GetMethod(name, bindingAttr); Logger.WriteLine("Result [{0}]", result != null ? result.Name : "null"); return result; } @@ -1348,7 +1395,7 @@ MethodInfo IReflect.GetMethod(string name, BindingFlags bindingAttr, Binder bind using (Logger.CreateCallstack()) { Logger.WriteLine("Name [{0}]", name); - MethodInfo result = typeof(Session).GetMethod(name, bindingAttr, binder, types, modifiers); + MethodInfo result = GetType().GetMethod(name, bindingAttr, binder, types, modifiers); Logger.WriteLine("Result [{0}]", result != null ? result.Name : "null"); return result; } @@ -1358,7 +1405,7 @@ MethodInfo[] IReflect.GetMethods(BindingFlags bindingAttr) { using (Logger.CreateCallstack()) { - MethodInfo[] result = typeof(Session).GetMethods(bindingAttr); + MethodInfo[] result = GetType().GetMethods(bindingAttr); Logger.WriteLine("Result [{0}]", result.Length); return result; } @@ -1368,7 +1415,7 @@ PropertyInfo[] IReflect.GetProperties(BindingFlags bindingAttr) { using (Logger.CreateCallstack()) { - PropertyInfo[] result = typeof(Session).GetProperties(bindingAttr); + PropertyInfo[] result = GetType().GetProperties(bindingAttr); Logger.WriteLine("Result [{0}]", result.Length); return result; } @@ -1379,7 +1426,7 @@ PropertyInfo IReflect.GetProperty(string name, BindingFlags bindingAttr, Binder using (Logger.CreateCallstack()) { Logger.WriteLine("Name [{0}]", name); - PropertyInfo result = typeof(Session).GetProperty(name, bindingAttr, binder, returnType, types, modifiers); + PropertyInfo result = GetType().GetProperty(name, bindingAttr, binder, returnType, types, modifiers); Logger.WriteLine("Result [{0}]", result != null ? result.Name : "null"); return result; } @@ -1390,7 +1437,7 @@ PropertyInfo IReflect.GetProperty(string name, BindingFlags bindingAttr) using (Logger.CreateCallstack()) { Logger.WriteLine("Name [{0}]", name); - PropertyInfo result = typeof(Session).GetProperty(name, bindingAttr); + PropertyInfo result = GetType().GetProperty(name, bindingAttr); Logger.WriteLine("Result [{0}]", result != null ? result.Name : "null"); return result; } @@ -1400,30 +1447,109 @@ object IReflect.InvokeMember(string name, BindingFlags invokeAttr, Binder binder { using (Logger.CreateCallstack()) { - Logger.WriteLine("Name [{0}]", name); object result; + try { - Logger.WriteLine("Target [{0}]", target); - if (args != null) + if (Logger.Logging) { - Logger.WriteLine("Args [{0}] [{1}]", args.Length, modifiers != null ? modifiers.Length.ToString(CultureInfo.InvariantCulture) : "null"); - for (int i = 0; i < args.Length; ++i) + Logger.WriteLine("Name [{0}]", name); + Logger.WriteLine("BindingFlags [{0}]", invokeAttr); + Logger.WriteLine("Binder [{0}]", binder); + Logger.WriteLine("Target [{0}]", target); + if (args != null) + { + Logger.WriteLine("Args [{0}] [{1}]", args.Length, modifiers != null ? modifiers.Length.ToString(CultureInfo.InvariantCulture) : "null"); + for (int i = 0; i < args.Length; ++i) + { + Logger.WriteLine("Arg [{0}] [{1}] [{2}]", i, args[i], (modifiers != null ? modifiers[i].ToString() : "null")); + } + } + Logger.WriteLine("Culture [{0}]", culture); + if (namedParameters != null) { - Logger.WriteLine("Arg [{0}] [{1}] [{2}]", i, args[i], (modifiers != null ? modifiers[i].ToString() : "null")); + foreach (string namedParameter in namedParameters) + { + Logger.WriteLine("NamedParameter [{0}]", namedParameter); + } } } - Logger.WriteLine("Culture [{0}]", culture); - if (namedParameters != null) + + Type type = target.GetType(); + + // RuntimeType.InvokeMember below calls into Binder.BindToMethod (Binder is OleAutBinder) + // that fails to match method, if integer value is provided to enum argument + // (SynchronizeDirectories with its SynchronizationMode and SynchronizationCriteria). + // This does not happen if we do not implement IReflect, though no idea why. + // So as a workaround we check, if the method has no overloads (what is always true for Session), + // and call the only instance directly. + // Calling MethodInfo.Invoke with int values for enum arguments works. + // Only as a fallback, we call InvokeMember (what is currently actually used only when + // the method with given name does not exist at all) + + MethodInfo method = null; + + // would be way too difficult to implement the below involving named arguments + if (namedParameters == null) { - foreach (string namedParameter in namedParameters) + try + { + method = type.GetMethod(name, invokeAttr | BindingFlags.Instance | BindingFlags.Public); + + if (method != null) + { + // MethodInfo.Invoke does not fill-in optional arguments (contrary to RuntimeType.InvokeMember) + ParameterInfo[] parameters = method.GetParameters(); + if (args.Length < parameters.Length) + { + Logger.WriteLine("Provided less parameters [{0}] than defined [{1}]", args.Length, parameters.Length); + object[] args2 = new object[parameters.Length]; + + for (int i = 0; i < parameters.Length; i++) + { + if (i < args.Length) + { + args2[i] = args[i]; + } + else + { + if (!parameters[i].IsOptional) + { + Logger.WriteLine("Parameter [{0}] of [{1}] is not optional", i, method); + args2 = null; + break; + } + else + { + Logger.WriteLine("Adding default value [{0}] for optional parameter [{1}]", parameters[i].DefaultValue, i); + args2[i] = parameters[i].DefaultValue; + } + } + } + + if (args2 != null) + { + args = args2; + } + } + } + } + catch (AmbiguousMatchException) { - Logger.WriteLine("NamedParameter [{0}]", namedParameter); } } - Logger.WriteLine("Invoking"); - result = typeof(Session).InvokeMember(name, invokeAttr, binder, target, args, modifiers, culture, namedParameters); + if (method != null) + { + Logger.WriteLine("Invoking unambiguous method [{0}]", method); + result = method.Invoke(target, invokeAttr, binder, args, culture); + } + else + { + Logger.WriteLine("Invoking ambiguous method [{0}]", name); + result = type.InvokeMember(name, invokeAttr, binder, target, args, modifiers, culture, namedParameters); + } + Logger.WriteLine("Result [{0}]", result); } catch (Exception e) @@ -1437,7 +1563,7 @@ object IReflect.InvokeMember(string name, BindingFlags invokeAttr, Binder binder Type IReflect.UnderlyingSystemType { - get { return typeof(Session); } + get { return GetType(); } } internal const string Namespace = "http://winscp.net/schema/session/1.0"; diff --git a/dotnet/SessionOptions.cs b/dotnet/SessionOptions.cs index 4d0e89c0..42265b2f 100644 --- a/dotnet/SessionOptions.cs +++ b/dotnet/SessionOptions.cs @@ -13,6 +13,7 @@ public enum Protocol Sftp = 0, Scp = 1, Ftp = 2, + Webdav = 3, } [Guid("D924FAB9-FCE7-47B8-9F23-5717698384D3")] @@ -56,16 +57,18 @@ public SessionOptions() public string SshHostKeyFingerprint { get { return _sshHostKeyFingerprint; } set { SetSshHostKeyFingerprint(value); } } public bool GiveUpSecurityAndAcceptAnySshHostKey { get; set; } public string SshPrivateKeyPath { get; set; } + public string SshPrivateKeyPassphrase { get; set; } // FTP public FtpMode FtpMode { get; set; } public FtpSecure FtpSecure { get; set; } + + // WebDAV + public bool WebdavSecure { get; set; } + + // TLS public string TlsHostCertificateFingerprint { get { return _tlsHostCertificateFingerprint; } set { SetHostTlsCertificateFingerprint(value); } } - [Obsolete("Use TlsHostCertificateFingerprint")] - public string SslHostCertificateFingerprint { get { return TlsHostCertificateFingerprint; } set { TlsHostCertificateFingerprint = value; } } public bool GiveUpSecurityAndAcceptAnyTlsHostCertificate { get; set; } - [Obsolete("Use GiveUpSecurityAndAcceptAnyTlsHostCertificate")] - public bool GiveUpSecurityAndAcceptAnySslHostCertificate { get { return GiveUpSecurityAndAcceptAnyTlsHostCertificate; } set { GiveUpSecurityAndAcceptAnyTlsHostCertificate = value; } } public void AddRawSettings(string setting, string value) { diff --git a/dotnet/TransferOptions.cs b/dotnet/TransferOptions.cs index 4808de3e..79fa3da6 100644 --- a/dotnet/TransferOptions.cs +++ b/dotnet/TransferOptions.cs @@ -24,6 +24,7 @@ public sealed class TransferOptions public TransferMode TransferMode { get; set; } public string FileMask { get; set; } public TransferResumeSupport ResumeSupport { get; private set; } + public int SpeedLimit { get; set; } public TransferOptions() { @@ -74,6 +75,11 @@ internal string ToSwitches() switches.Add(Session.FormatSwitch("resumesupport", ResumeSupport.ToString())); } + if (SpeedLimit > 0) + { + switches.Add(Session.FormatSwitch("speed", SpeedLimit.ToString(CultureInfo.InvariantCulture))); + } + return string.Join(" ", switches.ToArray()); } } diff --git a/dotnet/TransferResumeSupport.cs b/dotnet/TransferResumeSupport.cs index 147a7690..243e28ea 100644 --- a/dotnet/TransferResumeSupport.cs +++ b/dotnet/TransferResumeSupport.cs @@ -25,7 +25,7 @@ public sealed class TransferResumeSupport internal TransferResumeSupport() { State = TransferResumeSupportState.Default; - _threshold = 100; // (100 KiB) + _threshold = 100; // (100 KB) } public override string ToString() diff --git a/dotnet/WinSCPnet.csproj b/dotnet/WinSCPnet.csproj index d84018ca..61600c5e 100644 --- a/dotnet/WinSCPnet.csproj +++ b/dotnet/WinSCPnet.csproj @@ -64,6 +64,7 @@ + diff --git a/dotnet/internal/ConsoleCommStruct.cs b/dotnet/internal/ConsoleCommStruct.cs index a1d7c712..c38beee6 100644 --- a/dotnet/internal/ConsoleCommStruct.cs +++ b/dotnet/internal/ConsoleCommStruct.cs @@ -12,7 +12,7 @@ internal class ConsoleInitEventStruct public uint InputType; public uint OutputType; public bool WantsProgress; - }; + } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal class ConsolePrintEventStruct @@ -21,7 +21,7 @@ internal class ConsolePrintEventStruct public string Message; // wide since version 4 [MarshalAs(UnmanagedType.I1)] public bool FromBeginning; - }; + } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal class ConsoleInputEventStruct @@ -33,7 +33,7 @@ internal class ConsoleInputEventStruct [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 10240)] public string Str; // wide since version 4 public uint Timer; // since version 2 - }; + } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal class ConsoleChoiceEventStruct diff --git a/dotnet/internal/ElementLogReader.cs b/dotnet/internal/ElementLogReader.cs index 40855f60..65be279d 100644 --- a/dotnet/internal/ElementLogReader.cs +++ b/dotnet/internal/ElementLogReader.cs @@ -80,6 +80,6 @@ internal override XmlReader Reader private readonly CustomLogReader _parentReader; private readonly string _localName; private readonly int _depth; - private bool _read; + protected bool _read; } } diff --git a/dotnet/internal/SessionElementLogReader.cs b/dotnet/internal/SessionElementLogReader.cs new file mode 100644 index 00000000..670392b6 --- /dev/null +++ b/dotnet/internal/SessionElementLogReader.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WinSCP +{ + internal class SessionElementLogReader : ElementLogReader + { + public SessionElementLogReader(CustomLogReader parentReader) : + base(parentReader) + { + } + + public override void Dispose() + { + // Now it's ok if we encounter . + _disposing = true; + + base.Dispose(); + } + + public override bool Read(LogReadFlags flags) + { + bool result = base.Read(flags); + + if (_read && !_disposing) + { + throw new SessionLocalException(Session, "Session has unexpectedly closed"); + } + + return result; + } + + private bool _disposing; + } +} diff --git a/dotnet/properties/AssemblyInfo.cs b/dotnet/properties/AssemblyInfo.cs index 9f9d878d..70ab1546 100644 --- a/dotnet/properties/AssemblyInfo.cs +++ b/dotnet/properties/AssemblyInfo.cs @@ -19,9 +19,9 @@ // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("a0b93468-d98a-4845-a234-8076229ad93f")] -[assembly: AssemblyVersion("1.1.6.0")] -[assembly: AssemblyFileVersion("1.1.6.0")] -[assembly: AssemblyInformationalVersionAttribute("5.5.4.0")] +[assembly: AssemblyVersion("1.2.0.0")] +[assembly: AssemblyFileVersion("1.2.0.0")] +[assembly: AssemblyInformationalVersionAttribute("5.6.0.0")] [assembly: CLSCompliant(true)] diff --git a/libs/apr/CHANGES b/libs/apr/CHANGES deleted file mode 100644 index f3213bfc..00000000 --- a/libs/apr/CHANGES +++ /dev/null @@ -1,190 +0,0 @@ - -*- coding: utf-8 -*- -Changes for APR 1.4.6 - - *) Flush write buffer before truncate call on a file. - [Mladen Turk] - - *) Security: oCERT-2011-003 - Randomise hashes by providing a seed. - [Bojan Smojver, Branko Čibej, Ruediger Pluem et al.] - - *) apr_random: Prevent segfault if pool used to initialize apr_random is - destroyed before forking. [Stefan Fritsch] - - *) testrand: Improve child randomness test case. [Rainer Jung] - - *) apr_proc_fork, apr_random_after_fork: disambiguate what happens to the - proc structure passed in, and ensure that the pid is set correctly in - a newly created child; note that merely mixing a PID into the random - seed of a new child doesn't markedly increase entropy. [Sander Temme] - - *) apr_file_open: Avoid fcntl() calls if support for O_CLOEXEC works. - PR 48557. [Mike Frysinger ] - - *) apr_dir_make_recursive: Fix race condition that could lead to EEXIST - being returned. PR 51254. [William Lee , - Wim Lewis ] - - *) configure: Fix APR_RESTORE_THE_ENVIRONMENT if the original variable was - a single space. PR 50334. [Nathan Phillip Brink ] - - *) apr_proc_create: Don't close any of the new stdin/stdout/stderr in the - child if it already has the correct FD. PR 51995. - [Dan Ports ] - - *) Fix flag character '#' in combination with format character 'x' in - apr snprintf implementations. [Rainer Jung] - - *) Improve platform detection by updating config.guess and config.sub. - [Rainer Jung] - - *) Add libtool2 files to extraclean make target. [Rainer Jung] - - *) Don't overwrite our config.guess and config.sub - when running buildconf. [Rainer Jung] - - *) Silence autoconf 2.68 warnings. [Rainer Jung] - -Changes for APR 1.4.5 - - *) Security: CVE-2011-1928 - apr_fnmatch(): Fix high CPU loop. [William Rowe] - - *) Fix top_builddir in installed apr_rules.mk. [Bojan Smojver] - -Changes for APR 1.4.4 - - *) Windows: Fix command-line builds. [William Rowe] - -Changes for APR 1.4.3 - - *) Security: CVE-2011-0419 - Reimplement apr_fnmatch() from scratch using a non-recursive - algorithm; now has improved compliance with the fnmatch() spec. - [William Rowe] - - *) Fix environment-related crash using some non-standard builds on - Windows 7/Server 2008. [Steve Hay ] - - *) poll, pollset, pollcb on Windows: Handle calls with no file/socket - descriptors. PR 49882. [Stefan Ruppert , Jeff Trawick] - - *) Fix APR_IPV6_V6ONLY issues on Windows related to run-time behavior - on Windows older than Vista and SDK/MinGW levels without IPV6_V6ONLY. - PR 45321. [Sob ] - - *) Fix address handling when accepting an AF_INET socket from a socket - bound as AF_INET6. PR 49678. [Joe Orton] - - *) Fix error return values from apr_sockaddr_info_get() on Windows for - IPv6 builds. [Ivan Zhakov ] - - *) Add new experimental configure option --enable-allocator-uses-mmap to - use mmap instead of malloc in apr_allocator_alloc(). This greatly reduces - memory fragmentation with malloc implementations (e.g. glibc) that - don't handle allocationss of a page-size-multiples in an efficient way. - It also makes apr_allocator_max_free_set() actually have some effect - on such platforms. [Stefan Fritsch] - - *) configure: Support 64 and 32 bit universal builds for Darwin/ - OS X 10.6+. [Jim Jagielski] - - *) apr_sockaddr_info_get() on AIX: Fix a problem which could set - the port field in the native socket address to 1 when 0 was - specified. PR 46964. [Jeff Trawick] - - *) configure: Make definition of apr_ino_t independent of - _FILE_OFFSET_BITS even on platforms where ino_t is 'unsigned int'. - [Stefan Fritsch] - - *) apr_ring: Workaround for aliasing problem that causes gcc 4.5 to - miscompile some brigade related code. PR 50190. [Stefan Fritsch] - - *) apr_file_flush_locked(): Handle short writes. [Stefan Fritsch] - - *) apr_pollset_create_ex(): Trap errors from pollset providers. - PR 49094. [Sami Tolvanen ] - - *) apr_pollset_create*(): Fix memory lifetime problem with the wakeup - pipe when the pollset was created with APR_POLLSET_NOCOPY. - [Neil Conway ] - - *) Fix detection of some Linux variants when configure is built with - recent GNU tools. [Eric Covener] - - *) Avoid a redundant fcntl() call in apr_file_open() where O_CLOEXEC - is supported. PR 46297. [Joe Orton] - - *) Improve platform detection by updating config.guess and config.sub. - [Rainer Jung] - -Changes for APR 1.4.2 - - *) Undo a crash-bug introduced in 1.4.1 affecting some applications of - the apr hash and table structures, reported to affect Subversion - by Bert Huijben . [Graham Leggett] - -Changes for APR 1.4.1 - - *) Win32: Properly handle the ERROR_DIRECTORY system error code. - [Brane Čibej] - -Changes for APR 1.4.0 - - *) Windows: Default build configurations assume NT or higher at run-time. - - *) Add apr_global_mutex_lockfile() for retrieving the file, if any, - associated with the mutex. Add apr_global_mutex_name() for retrieving - the name of the lock mechanism used by the underlying proc mutex. - [Jeff Trawick] - - *) Add apr_socket_atreadeof to determine whether the receive part of the - socket has been closed by the peer. - [Ruediger Pluem, Mladen Turk, Joe Orton] - - *) Make apr_pollset and apr_pollcb implementations using providers. - Added apr_pollset_create_ex and apr_pollcb_create_ex that allows - choosing non-default providers. - [Mladen Turk] - - *) Win32: Use WSAPoll as default pollset method if supported and found - inside winsock dll. [Mladen Turk] - - *) apr_temp_dir_get() now checks the TMPDIR environment variable first, - instead of third. [Jim Jagielski] - - *) Add apr_file_sync() and apr_file_datasync() calls. [Bojan Smojver] - - *) apr_pollset_wakeup() on Windows: Fix core caused by closing the - file_socket_pipe with standard file_close. - [Arsen Chaloyan, Mladen Turk] - - *) Introduce apr_hash_do() for iterating over a hash table. [Mladen Turk] - - *) Make sure WIN32 behaves the same as posix for file-backed shared memory - by removing the file on cleanup/remove. [Mladen Turk] - - *) Introduce apr_pollset_wakeup() for interrupting the blocking - apr_pollset_poll() call. [Mladen Turk] - - *) Add apr_file_link() function. PR 44841. [Mark Heily ] - -Changes for APR 1.3.x and later: - - *) http://svn.apache.org/viewvc/apr/apr/branches/1.3.x/CHANGES?view=markup - -Changes for APR 1.2.x and later: - - *) http://svn.apache.org/viewvc/apr/apr/branches/1.2.x/CHANGES?view=markup - -Changes for APR 1.1.x and later: - - *) http://svn.apache.org/viewvc/apr/apr/branches/1.1.x/CHANGES?view=markup - -Changes for APR 1.0.x and later: - - *) http://svn.apache.org/viewvc/apr/apr/branches/1.0.x/CHANGES?view=markup - -Changes for APR 0.9.x and later/earlier: - - *) http://svn.apache.org/viewvc/apr/apr/branches/0.9.x/CHANGES?view=markup diff --git a/libs/apr/LICENSE b/libs/apr/LICENSE deleted file mode 100644 index 02418e19..00000000 --- a/libs/apr/LICENSE +++ /dev/null @@ -1,341 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - -APACHE PORTABLE RUNTIME SUBCOMPONENTS: - -The Apache Portable Runtime includes a number of subcomponents with -separate copyright notices and license terms. Your use of the source -code for the these subcomponents is subject to the terms and -conditions of the following licenses. - -From strings/apr_fnmatch.c, include/apr_fnmatch.h, misc/unix/getopt.c, -file_io/unix/mktemp.c, strings/apr_strings.c: - -/* - * Copyright (c) 1987, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - -From network_io/unix/inet_ntop.c, network_io/unix/inet_pton.c: - -/* Copyright (c) 1996 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - -From dso/aix/dso.c: - - * Based on libdl (dlfcn.c/dlfcn.h) which is - * Copyright (c) 1992,1993,1995,1996,1997,1988 - * Jens-Uwe Mager, Helios Software GmbH, Hannover, Germany. - * - * Not derived from licensed software. - * - * Permission is granted to freely use, copy, modify, and redistribute - * this software, provided that the author is not construed to be liable - * for any results of using the software, alterations are clearly marked - * as such, and this notice is not modified. - -From strings/apr_strnatcmp.c, include/apr_strings.h: - - strnatcmp.c -- Perform 'natural order' comparisons of strings in C. - Copyright (C) 2000 by Martin Pool - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - -From strings/apr_snprintf.c: - - * - * cvt - IEEE floating point formatting routines. - * Derived from UNIX V7, Copyright(C) Caldera International Inc. - * - - Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - Redistributions of source code and documentation must retain the above - copyright notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - All advertising materials mentioning features or use of this software - must display the following acknowledgement: - - This product includes software developed or owned by Caldera - International, Inc. - - Neither the name of Caldera International, Inc. nor the names of other - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA - INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, - INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - - diff --git a/libs/apr/Makefile.bcb b/libs/apr/Makefile.bcb deleted file mode 100644 index b4e657f0..00000000 --- a/libs/apr/Makefile.bcb +++ /dev/null @@ -1,287 +0,0 @@ -# Set your compiler options -CC=bcc32 -CFLAG=-DWIN32;WINNT;_WINDOWS -DWIN32_LEAN_AND_MEAN -q -w-ccc -w-rch -w-pia -w-aus -w-par -w-inl -w-eff -w-sus -w-dup -w-spa -w-csu -w-rvl -c -tWC -tWM -D_stricmp=stricmp -D_strnicmp=strnicmp -O2 -ff -fp -DAPR_DECLARE_STATIC;APR_HAS_UNICODE_FS;APR_HAS_LARGE_FILES -LIB_CFLAG= - -# apr directory -SRC_D=. - -# The output directory for everything intersting -OUT_D=..\lib -# The output directory for all the temporary muck -TMP_D=tmp -INCO_D=openssl - -CP=copy -RM=del -MKDIR=mkdir -MKLIB=tlib /P64 /C -ASM=nasm -f obj -d__omf__ - -###################################################### -# You should not need to touch anything below this point -###################################################### - -# INCL_D - local library directory -# OBJ_D - temp object file directory -OBJ_D=$(TMP_D) -INCL_D=include -INCL=include;include\arch\win32;include\arch\unix; - -O_APR=$(OUT_D)\apr.lib - -###################################################### -# Don't touch anything below this point -###################################################### - -INC=-I$(INCL) -I. -LIB_CFLAGS=$(INC) $(CFLAG) $(LIB_CFLAG) -LIBS_DEP=$(O_APR) - -############################################# -HEADER=$(INCL_D)\apr.h - -APROBJS=\ - $(OBJ_D)\apr_atomic.obj \ - $(OBJ_D)\dso.obj \ - $(OBJ_D)\buffer.obj \ - $(OBJ_D)\copy.obj \ - $(OBJ_D)\dir.obj \ - $(OBJ_D)\fileacc.obj \ - $(OBJ_D)\filedup.obj \ - $(OBJ_D)\filepath.obj \ - $(OBJ_D)\filepath_util.obj \ - $(OBJ_D)\filestat.obj \ - $(OBJ_D)\filesys.obj \ - $(OBJ_D)\flock.obj \ - $(OBJ_D)\fullrw.obj \ - $(OBJ_D)\mktemp.obj \ - $(OBJ_D)\open.obj \ - $(OBJ_D)\pipe.obj \ - $(OBJ_D)\readwrite.obj \ - $(OBJ_D)\seek.obj \ - $(OBJ_D)\tempdir.obj \ - $(OBJ_D)\proc_mutex.obj \ - $(OBJ_D)\thread_cond.obj \ - $(OBJ_D)\thread_mutex.obj \ - $(OBJ_D)\thread_rwlock.obj \ - $(OBJ_D)\apr_pools.obj \ - $(OBJ_D)\apr_app.obj \ - $(OBJ_D)\charset.obj \ - $(OBJ_D)\env.obj \ - $(OBJ_D)\errorcodes.obj \ - $(OBJ_D)\getopt.obj \ - $(OBJ_D)\internal.obj \ - $(OBJ_D)\misc.obj \ - $(OBJ_D)\otherchild.obj \ - $(OBJ_D)\rand.obj \ - $(OBJ_D)\start.obj \ - $(OBJ_D)\utf8.obj \ - $(OBJ_D)\version.obj \ - $(OBJ_D)\common.obj \ - $(OBJ_D)\mmap.obj \ - $(OBJ_D)\inet_ntop.obj \ - $(OBJ_D)\inet_pton.obj \ - $(OBJ_D)\multicast.obj \ - $(OBJ_D)\sendrecv.obj \ - $(OBJ_D)\sockaddr.obj \ - $(OBJ_D)\sockets.obj \ - $(OBJ_D)\socket_util.obj \ - $(OBJ_D)\sockopt.obj \ - $(OBJ_D)\apr_getpass.obj \ - $(OBJ_D)\poll.obj \ - $(OBJ_D)\pollcb.obj \ - $(OBJ_D)\pollset.obj \ - $(OBJ_D)\select.obj \ - $(OBJ_D)\apr_random.obj \ - $(OBJ_D)\sha2.obj \ - $(OBJ_D)\sha2_glue.obj \ - $(OBJ_D)\shm.obj \ - $(OBJ_D)\apr_cpystrn.obj \ - $(OBJ_D)\apr_fnmatch.obj \ - $(OBJ_D)\apr_snprintf.obj \ - $(OBJ_D)\apr_strings.obj \ - $(OBJ_D)\apr_strnatcmp.obj \ - $(OBJ_D)\apr_strtok.obj \ - $(OBJ_D)\apr_hash.obj \ - $(OBJ_D)\apr_tables.obj \ - $(OBJ_D)\proc.obj \ - $(OBJ_D)\signals.obj \ - $(OBJ_D)\thread.obj \ - $(OBJ_D)\threadpriv.obj \ - $(OBJ_D)\time.obj \ - $(OBJ_D)\timestr.obj \ - $(OBJ_D)\groupinfo.obj \ - $(OBJ_D)\userinfo.obj - -$(OBJ_D)\apr_atomic.obj: $(SRC_D)/atomic/win32/apr_atomic.c - $(CC) -o$(OBJ_D)\apr_atomic.obj $(LIB_CFLAGS) -c $(SRC_D)/atomic/win32/apr_atomic.c -$(OBJ_D)\dso.obj: $(SRC_D)/dso/win32/dso.c - $(CC) -o$(OBJ_D)\dso.obj $(LIB_CFLAGS) -c $(SRC_D)/dso/win32/dso.c -$(OBJ_D)\buffer.obj: $(SRC_D)/file_io/win32/buffer.c - $(CC) -o$(OBJ_D)\buffer.obj $(LIB_CFLAGS) -c $(SRC_D)/file_io/win32/buffer.c -$(OBJ_D)\copy.obj: $(SRC_D)/file_io/unix/copy.c - $(CC) -o$(OBJ_D)\copy.obj $(LIB_CFLAGS) -c $(SRC_D)/file_io/unix/copy.c -$(OBJ_D)\dir.obj: $(SRC_D)/file_io/win32/dir.c - $(CC) -o$(OBJ_D)\dir.obj $(LIB_CFLAGS) -c $(SRC_D)/file_io/win32/dir.c -$(OBJ_D)\fileacc.obj: $(SRC_D)/file_io/unix/fileacc.c - $(CC) -o$(OBJ_D)\fileacc.obj $(LIB_CFLAGS) -c $(SRC_D)/file_io/unix/fileacc.c -$(OBJ_D)\filedup.obj: $(SRC_D)/file_io/win32/filedup.c - $(CC) -o$(OBJ_D)\filedup.obj $(LIB_CFLAGS) -c $(SRC_D)/file_io/win32/filedup.c -$(OBJ_D)\filepath.obj: $(SRC_D)/file_io/win32/filepath.c - $(CC) -o$(OBJ_D)\filepath.obj $(LIB_CFLAGS) -c $(SRC_D)/file_io/win32/filepath.c -$(OBJ_D)\filepath_util.obj: $(SRC_D)/file_io/unix/filepath_util.c - $(CC) -o$(OBJ_D)\filepath_util.obj $(LIB_CFLAGS) -c $(SRC_D)/file_io/unix/filepath_util.c -$(OBJ_D)\filestat.obj: $(SRC_D)/file_io/win32/filestat.c - $(CC) -o$(OBJ_D)\filestat.obj $(LIB_CFLAGS) -c $(SRC_D)/file_io/win32/filestat.c -$(OBJ_D)\filesys.obj: $(SRC_D)/file_io/win32/filesys.c - $(CC) -o$(OBJ_D)\filesys.obj $(LIB_CFLAGS) -c $(SRC_D)/file_io/win32/filesys.c -$(OBJ_D)\flock.obj: $(SRC_D)/file_io/win32/flock.c - $(CC) -o$(OBJ_D)\flock.obj $(LIB_CFLAGS) -c $(SRC_D)/file_io/win32/flock.c -$(OBJ_D)\fullrw.obj: $(SRC_D)/file_io/unix/fullrw.c - $(CC) -o$(OBJ_D)\fullrw.obj $(LIB_CFLAGS) -c $(SRC_D)/file_io/unix/fullrw.c -$(OBJ_D)\mktemp.obj: $(SRC_D)/file_io/unix/mktemp.c - $(CC) -o$(OBJ_D)\mktemp.obj $(LIB_CFLAGS) -c $(SRC_D)/file_io/unix/mktemp.c -$(OBJ_D)\open.obj: $(SRC_D)/file_io/win32/open.c - $(CC) -o$(OBJ_D)\open.obj $(LIB_CFLAGS) -c $(SRC_D)/file_io/win32/open.c -$(OBJ_D)\pipe.obj: $(SRC_D)/file_io/win32/pipe.c - $(CC) -o$(OBJ_D)\pipe.obj $(LIB_CFLAGS) -c $(SRC_D)/file_io/win32/pipe.c -$(OBJ_D)\readwrite.obj: $(SRC_D)/file_io/win32/readwrite.c - $(CC) -o$(OBJ_D)\readwrite.obj $(LIB_CFLAGS) -c $(SRC_D)/file_io/win32/readwrite.c -$(OBJ_D)\seek.obj: $(SRC_D)/file_io/win32/seek.c - $(CC) -o$(OBJ_D)\seek.obj $(LIB_CFLAGS) -c $(SRC_D)/file_io/win32/seek.c -$(OBJ_D)\tempdir.obj: $(SRC_D)/file_io/unix/tempdir.c - $(CC) -o$(OBJ_D)\tempdir.obj $(LIB_CFLAGS) -c $(SRC_D)/file_io/unix/tempdir.c -$(OBJ_D)\proc_mutex.obj: $(SRC_D)/locks/win32/proc_mutex.c - $(CC) -o$(OBJ_D)\proc_mutex.obj $(LIB_CFLAGS) -c $(SRC_D)/locks/win32/proc_mutex.c -$(OBJ_D)\thread_cond.obj: $(SRC_D)/locks/win32/thread_cond.c - $(CC) -o$(OBJ_D)\thread_cond.obj $(LIB_CFLAGS) -c $(SRC_D)/locks/win32/thread_cond.c -$(OBJ_D)\thread_mutex.obj: $(SRC_D)/locks/win32/thread_mutex.c - $(CC) -o$(OBJ_D)\thread_mutex.obj $(LIB_CFLAGS) -c $(SRC_D)/locks/win32/thread_mutex.c -$(OBJ_D)\thread_rwlock.obj: $(SRC_D)/locks/win32/thread_rwlock.c - $(CC) -o$(OBJ_D)\thread_rwlock.obj $(LIB_CFLAGS) -c $(SRC_D)/locks/win32/thread_rwlock.c -$(OBJ_D)\apr_pools.obj: $(SRC_D)/memory/unix/apr_pools.c - $(CC) -o$(OBJ_D)\apr_pools.obj $(LIB_CFLAGS) -c $(SRC_D)/memory/unix/apr_pools.c -$(OBJ_D)\apr_app.obj: $(SRC_D)/misc/win32/apr_app.c - $(CC) -o$(OBJ_D)\apr_app.obj $(LIB_CFLAGS) -c $(SRC_D)/misc/win32/apr_app.c -$(OBJ_D)\charset.obj: $(SRC_D)/misc/win32/charset.c - $(CC) -o$(OBJ_D)\charset.obj $(LIB_CFLAGS) -c $(SRC_D)/misc/win32/charset.c -$(OBJ_D)\env.obj: $(SRC_D)/misc/win32/env.c - $(CC) -o$(OBJ_D)\env.obj $(LIB_CFLAGS) -c $(SRC_D)/misc/win32/env.c -$(OBJ_D)\errorcodes.obj: $(SRC_D)/misc/unix/errorcodes.c - $(CC) -o$(OBJ_D)\errorcodes.obj $(LIB_CFLAGS) -c $(SRC_D)/misc/unix/errorcodes.c -$(OBJ_D)\getopt.obj: $(SRC_D)/misc/unix/getopt.c - $(CC) -o$(OBJ_D)\getopt.obj $(LIB_CFLAGS) -c $(SRC_D)/misc/unix/getopt.c -$(OBJ_D)\internal.obj: $(SRC_D)/misc/win32/internal.c - $(CC) -o$(OBJ_D)\internal.obj $(LIB_CFLAGS) -c $(SRC_D)/misc/win32/internal.c -$(OBJ_D)\misc.obj: $(SRC_D)/misc/win32/misc.c - $(CC) -o$(OBJ_D)\misc.obj $(LIB_CFLAGS) -c $(SRC_D)/misc/win32/misc.c -$(OBJ_D)\otherchild.obj: $(SRC_D)/misc/unix/otherchild.c - $(CC) -o$(OBJ_D)\otherchild.obj $(LIB_CFLAGS) -c $(SRC_D)/misc/unix/otherchild.c -$(OBJ_D)\rand.obj: $(SRC_D)/misc/win32/rand.c - $(CC) -o$(OBJ_D)\rand.obj $(LIB_CFLAGS) -c $(SRC_D)/misc/win32/rand.c -$(OBJ_D)\start.obj: $(SRC_D)/misc/win32/start.c - $(CC) -o$(OBJ_D)\start.obj $(LIB_CFLAGS) -c $(SRC_D)/misc/win32/start.c -$(OBJ_D)\utf8.obj: $(SRC_D)/misc/win32/utf8.c - $(CC) -o$(OBJ_D)\utf8.obj $(LIB_CFLAGS) -c $(SRC_D)/misc/win32/utf8.c -$(OBJ_D)\version.obj: $(SRC_D)/misc/unix/version.c - $(CC) -o$(OBJ_D)\version.obj $(LIB_CFLAGS) -c $(SRC_D)/misc/unix/version.c -$(OBJ_D)\common.obj: $(SRC_D)/mmap/unix/common.c - $(CC) -o$(OBJ_D)\common.obj $(LIB_CFLAGS) -c $(SRC_D)/mmap/unix/common.c -$(OBJ_D)\mmap.obj: $(SRC_D)/mmap/win32/mmap.c - $(CC) -o$(OBJ_D)\mmap.obj $(LIB_CFLAGS) -c $(SRC_D)/mmap/win32/mmap.c -$(OBJ_D)\inet_ntop.obj: $(SRC_D)/network_io/unix/inet_ntop.c - $(CC) -o$(OBJ_D)\inet_ntop.obj $(LIB_CFLAGS) -c $(SRC_D)/network_io/unix/inet_ntop.c -$(OBJ_D)\inet_pton.obj: $(SRC_D)/network_io/unix/inet_pton.c - $(CC) -o$(OBJ_D)\inet_pton.obj $(LIB_CFLAGS) -c $(SRC_D)/network_io/unix/inet_pton.c -$(OBJ_D)\multicast.obj: $(SRC_D)/network_io/unix/multicast.c - $(CC) -o$(OBJ_D)\multicast.obj $(LIB_CFLAGS) -c $(SRC_D)/network_io/unix/multicast.c -$(OBJ_D)\sendrecv.obj: $(SRC_D)/network_io/win32/sendrecv.c - $(CC) -o$(OBJ_D)\sendrecv.obj $(LIB_CFLAGS) -c $(SRC_D)/network_io/win32/sendrecv.c -$(OBJ_D)\sockaddr.obj: $(SRC_D)/network_io/unix/sockaddr.c - $(CC) -o$(OBJ_D)\sockaddr.obj $(LIB_CFLAGS) -c $(SRC_D)/network_io/unix/sockaddr.c -$(OBJ_D)\sockets.obj: $(SRC_D)/network_io/win32/sockets.c - $(CC) -o$(OBJ_D)\sockets.obj $(LIB_CFLAGS) -c $(SRC_D)/network_io/win32/sockets.c -$(OBJ_D)\socket_util.obj: $(SRC_D)/network_io/unix/socket_util.c - $(CC) -o$(OBJ_D)\socket_util.obj $(LIB_CFLAGS) -c $(SRC_D)/network_io/unix/socket_util.c -$(OBJ_D)\sockopt.obj: $(SRC_D)/network_io/win32/sockopt.c - $(CC) -o$(OBJ_D)\sockopt.obj $(LIB_CFLAGS) -c $(SRC_D)/network_io/win32/sockopt.c -$(OBJ_D)\apr_getpass.obj: $(SRC_D)/passwd/apr_getpass.c - $(CC) -o$(OBJ_D)\apr_getpass.obj $(LIB_CFLAGS) -c $(SRC_D)/passwd/apr_getpass.c -$(OBJ_D)\poll.obj: $(SRC_D)/poll/unix/poll.c - $(CC) -o$(OBJ_D)\poll.obj $(LIB_CFLAGS) -c $(SRC_D)/poll/unix/poll.c -$(OBJ_D)\pollcb.obj: $(SRC_D)/poll/unix/pollcb.c - $(CC) -o$(OBJ_D)\pollcb.obj $(LIB_CFLAGS) -c $(SRC_D)/poll/unix/pollcb.c -$(OBJ_D)\pollset.obj: $(SRC_D)/poll/unix/pollset.c - $(CC) -o$(OBJ_D)\pollset.obj $(LIB_CFLAGS) -c $(SRC_D)/poll/unix/pollset.c -$(OBJ_D)\select.obj: $(SRC_D)/poll/unix/select.c - $(CC) -o$(OBJ_D)\select.obj $(LIB_CFLAGS) -c $(SRC_D)/poll/unix/select.c -$(OBJ_D)\apr_random.obj: $(SRC_D)/random/unix/apr_random.c - $(CC) -o$(OBJ_D)\apr_random.obj $(LIB_CFLAGS) -c $(SRC_D)/random/unix/apr_random.c -$(OBJ_D)\sha2.obj: $(SRC_D)/random/unix/sha2.c - $(CC) -o$(OBJ_D)\sha2.obj $(LIB_CFLAGS) -c $(SRC_D)/random/unix/sha2.c -$(OBJ_D)\sha2_glue.obj: $(SRC_D)/random/unix/sha2_glue.c - $(CC) -o$(OBJ_D)\sha2_glue.obj $(LIB_CFLAGS) -c $(SRC_D)/random/unix/sha2_glue.c -$(OBJ_D)\shm.obj: $(SRC_D)/shmem/win32/shm.c - $(CC) -o$(OBJ_D)\shm.obj $(LIB_CFLAGS) -c $(SRC_D)/shmem/win32/shm.c -$(OBJ_D)\apr_cpystrn.obj: $(SRC_D)/strings/apr_cpystrn.c - $(CC) -o$(OBJ_D)\apr_cpystrn.obj $(LIB_CFLAGS) -c $(SRC_D)/strings/apr_cpystrn.c -$(OBJ_D)\apr_fnmatch.obj: $(SRC_D)/strings/apr_fnmatch.c - $(CC) -o$(OBJ_D)\apr_fnmatch.obj $(LIB_CFLAGS) -c $(SRC_D)/strings/apr_fnmatch.c -$(OBJ_D)\apr_snprintf.obj: $(SRC_D)/strings/apr_snprintf.c - $(CC) -o$(OBJ_D)\apr_snprintf.obj $(LIB_CFLAGS) -c $(SRC_D)/strings/apr_snprintf.c -$(OBJ_D)\apr_strings.obj: $(SRC_D)/strings/apr_strings.c - $(CC) -o$(OBJ_D)\apr_strings.obj $(LIB_CFLAGS) -c $(SRC_D)/strings/apr_strings.c -$(OBJ_D)\apr_strnatcmp.obj: $(SRC_D)/strings/apr_strnatcmp.c - $(CC) -o$(OBJ_D)\apr_strnatcmp.obj $(LIB_CFLAGS) -c $(SRC_D)/strings/apr_strnatcmp.c -$(OBJ_D)\apr_strtok.obj: $(SRC_D)/strings/apr_strtok.c - $(CC) -o$(OBJ_D)\apr_strtok.obj $(LIB_CFLAGS) -c $(SRC_D)/strings/apr_strtok.c -$(OBJ_D)\apr_hash.obj: $(SRC_D)/tables/apr_hash.c - $(CC) -o$(OBJ_D)\apr_hash.obj $(LIB_CFLAGS) -c $(SRC_D)/tables/apr_hash.c -$(OBJ_D)\apr_tables.obj: $(SRC_D)/tables/apr_tables.c - $(CC) -o$(OBJ_D)\apr_tables.obj $(LIB_CFLAGS) -c $(SRC_D)/tables/apr_tables.c -$(OBJ_D)\proc.obj: $(SRC_D)/threadproc/win32/proc.c - $(CC) -o$(OBJ_D)\proc.obj $(LIB_CFLAGS) -c $(SRC_D)/threadproc/win32/proc.c -$(OBJ_D)\signals.obj: $(SRC_D)/threadproc/win32/signals.c - $(CC) -o$(OBJ_D)\signals.obj $(LIB_CFLAGS) -c $(SRC_D)/threadproc/win32/signals.c -$(OBJ_D)\thread.obj: $(SRC_D)/threadproc/win32/thread.c - $(CC) -o$(OBJ_D)\thread.obj $(LIB_CFLAGS) -c $(SRC_D)/threadproc/win32/thread.c -$(OBJ_D)\threadpriv.obj: $(SRC_D)/threadproc/win32/threadpriv.c - $(CC) -o$(OBJ_D)\threadpriv.obj $(LIB_CFLAGS) -c $(SRC_D)/threadproc/win32/threadpriv.c -$(OBJ_D)\time.obj: $(SRC_D)/time/win32/time.c - $(CC) -o$(OBJ_D)\time.obj $(LIB_CFLAGS) -c $(SRC_D)/time/win32/time.c -$(OBJ_D)\timestr.obj: $(SRC_D)/time/win32/timestr.c - $(CC) -o$(OBJ_D)\timestr.obj $(LIB_CFLAGS) -c $(SRC_D)/time/win32/timestr.c -$(OBJ_D)\groupinfo.obj: $(SRC_D)/user/win32/groupinfo.c - $(CC) -o$(OBJ_D)\groupinfo.obj $(LIB_CFLAGS) -c $(SRC_D)/user/win32/groupinfo.c -$(OBJ_D)\userinfo.obj: $(SRC_D)/user/win32/userinfo.c - $(CC) -o$(OBJ_D)\userinfo.obj $(LIB_CFLAGS) -c $(SRC_D)/user/win32/userinfo.c - -$(O_APR): $(APROBJS) - if exist $(O_APR) $(RM) $(O_APR) - $(MKLIB) $(O_APR) @&&! -+$(**: = &^ -+) -! - -################################################################### -all: banner clean_lib $(TMP_D) $(OUT_D) headers lib - -banner: - @echo Building apr - @echo $(APROBJS) - -clean_lib: - if exist $(O_APR) $(RM) $(O_APR) - -$(TMP_D): - if not exist "$(TMP_D)" ( $(MKDIR) "$(TMP_D)" ) - -$(OUT_D): - if not exist "$(OUT_D)" ( $(MKDIR) "$(OUT_D)" ) - -headers: $(HEADER) - @ - -lib: $(LIBS_DEP) - diff --git a/libs/apr/Makefile.in b/libs/apr/Makefile.in deleted file mode 100644 index 6d3b9127..00000000 --- a/libs/apr/Makefile.in +++ /dev/null @@ -1,129 +0,0 @@ - -srcdir=@srcdir@ -VPATH=@srcdir@ -top_srcdir=@apr_srcdir@ -top_blddir=@apr_builddir@ - -# -# APR (Apache Portable Runtime) library Makefile. -# -CPP = @CPP@ - -# get substituted into some targets -APR_MAJOR_VERSION=@APR_MAJOR_VERSION@ - -# -# Macros for supporting directories -# -INCDIR=./include -OSDIR=$(top_srcdir)/include/arch/@OSDIR@ -DEFOSDIR=$(INCDIR)/arch/@DEFAULT_OSDIR@ -INCLUDES=-I$(INCDIR) -I$(OSDIR) -I$(DEFOSDIR) -I$(top_srcdir)/include/arch/@DEFAULT_OSDIR@ -I$(top_srcdir)/include - -# -# Macros for target determination -# -CLEAN_SUBDIRS= test -INSTALL_SUBDIRS=@INSTALL_SUBDIRS@ - -TARGET_LIB = lib@APR_LIBNAME@.la -APR_PCFILE = apr-$(APR_MAJOR_VERSION).pc -APR_CONFIG = apr-$(APR_MAJOR_VERSION)-config -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ - -# -# Rules for building specific targets, starting with 'all' for -# building the entire package. -# -TARGETS = $(TARGET_LIB) apr.exp apr-config.out build/apr_rules.out - -LT_VERSION = @LT_VERSION@ - -# bring in rules.mk for standard functionality -@INCLUDE_RULES@ -@INCLUDE_OUTPUTS@ - -CLEAN_TARGETS = apr-config.out apr.exp exports.c export_vars.c .make.dirs \ - build/apr_rules.out -DISTCLEAN_TARGETS = config.cache config.log config.status \ - include/apr.h include/arch/unix/apr_private.h \ - libtool $(APR_CONFIG) build/apr_rules.mk apr.pc \ - build/pkg/pkginfo -EXTRACLEAN_TARGETS = configure aclocal.m4 include/arch/unix/apr_private.h.in \ - build-outputs.mk build/ltcf-c.sh build/aclocal.m4 \ - build/ltconfig build/ltmain.sh \ - build/argz.m4 build/libtool.m4 build/ltoptions.m4 \ - build/ltsugar.m4 build/ltversion.m4 build/lt~obsolete.m4 - -prefix=@prefix@ -exec_prefix=@exec_prefix@ -bindir=@bindir@ -libdir=@libdir@ -includedir=@includedir@ -installbuilddir=@installbuilddir@ - -# Create apr-config script suitable for the install tree -apr-config.out: $(APR_CONFIG) - sed 's,^\(location=\).*$$,\1installed,' < $(APR_CONFIG) > $@ - -# Create apr_rules.mk suitable for the install tree -build/apr_rules.out: build/apr_rules.mk - sed -e 's,^\(apr_build.*=\).*$$,\1$(installbuilddir),' -e 's,^\(top_build.*=\).*$$,\1$(installbuilddir),' < build/apr_rules.mk > $@ - -install: $(TARGETS) - $(APR_MKDIR) $(DESTDIR)$(libdir) $(DESTDIR)$(bindir) $(DESTDIR)$(installbuilddir) \ - $(DESTDIR)$(libdir)/pkgconfig $(DESTDIR)$(includedir) - $(INSTALL_DATA) $(top_blddir)/include/apr.h $(DESTDIR)$(includedir) - for f in $(top_srcdir)/include/apr_*.h; do \ - $(INSTALL_DATA) $${f} $(DESTDIR)$(includedir); \ - done - $(LIBTOOL) --mode=install $(INSTALL) -m 755 $(TARGET_LIB) $(DESTDIR)$(libdir) - $(INSTALL_DATA) apr.exp $(DESTDIR)$(libdir)/apr.exp - $(INSTALL_DATA) apr.pc $(DESTDIR)$(libdir)/pkgconfig/$(APR_PCFILE) - for f in libtool shlibtool; do \ - if test -f $${f}; then $(INSTALL) -m 755 $${f} $(DESTDIR)$(installbuilddir); fi; \ - done - $(INSTALL) -m 755 $(top_srcdir)/build/mkdir.sh $(DESTDIR)$(installbuilddir) - for f in make_exports.awk make_var_export.awk; do \ - $(INSTALL_DATA) $(top_srcdir)/build/$${f} $(DESTDIR)$(installbuilddir); \ - done - $(INSTALL_DATA) build/apr_rules.out $(DESTDIR)$(installbuilddir)/apr_rules.mk - $(INSTALL) -m 755 apr-config.out $(DESTDIR)$(bindir)/$(APR_CONFIG) - @if [ $(INSTALL_SUBDIRS) != "none" ]; then \ - for i in $(INSTALL_SUBDIRS); do \ - ( cd $$i ; $(MAKE) DESTDIR=$(DESTDIR) install ); \ - done \ - fi - -$(TARGET_LIB): $(OBJECTS) - $(LINK) @lib_target@ $(ALL_LIBS) - -exports.c: $(HEADERS) - $(APR_MKEXPORT) $(HEADERS) > $@ - -export_vars.c: $(HEADERS) - $(APR_MKVAREXPORT) $(HEADERS) > $@ - -apr.exp: exports.c export_vars.c - @echo "#! lib@APR_LIBNAME@.so" > $@ - @echo "* This file was AUTOGENERATED at build time." >> $@ - @echo "* Please do not edit by hand." >> $@ - $(CPP) $(ALL_CPPFLAGS) $(ALL_INCLUDES) exports.c | grep "ap_hack_" | sed -e 's/^.*[)]\(.*\);$$/\1/' >> $@ - $(CPP) $(ALL_CPPFLAGS) $(ALL_INCLUDES) export_vars.c | sed -e 's/^\#[^!]*//' | sed -e '/^$$/d' >> $@ - -dox: - doxygen $(top_srcdir)/docs/doxygen.conf - -gcov: - @build/run-gcov.sh - -test: check -check: $(TARGET_LIB) - cd test && $(MAKE) all check - -etags: - etags `find . -name '*.[ch]'` - -# DO NOT REMOVE -docs: $(INCDIR)/*.h diff --git a/libs/apr/Makefile.win b/libs/apr/Makefile.win deleted file mode 100644 index d2090f3f..00000000 --- a/libs/apr/Makefile.win +++ /dev/null @@ -1,181 +0,0 @@ -# Makefile.win for Win32 APR alone -# -# Targets are: -# -# buildall - compile everything -# checkall - run APR regression tests -# install - compile everything -# clean - mop up everything -# -# You can override the build mechansim, choose only one; -# -# USEMAK=1 - compile from exported make files -# USEDSW=1 - compile from .dsw / .dsp VC6 projects -# USESLN=1 - compile from converted .sln / .vcproj VC7+ files -# -# Define ARCH to your desired preference (your PATH must point -# to the correct compiler tools!) Choose only one; -# -# ARCH="Win32 Release" -# ARCH="Win32 Debug" -# ARCH="Win32 Release9x" -# ARCH="Win32 Debug9x" -# ARCH="x64 Release" -# ARCH="x64 Debug" -# -# For example; -# -# nmake -f Makefile.win PREFIX=C:\APR buildall checkall installall clean -# - -!IF EXIST("apr.sln") && ([devenv /help > NUL 2>&1] == 0) \ - && !defined(USEMAK) && !defined(USEDSW) -USESLN=1 -USEMAK=0 -USEDSW=0 -!ELSEIF EXIST("apr.mak") && !defined(USEDSW) -USESLN=0 -USEMAK=1 -USEDSW=0 -!ELSE -USESLN=0 -USEMAK=0 -USEDSW=1 -!ENDIF - -PREFIX=..\apr-dist - -!IF [$(COMSPEC) /c cl /nologo /? \ - | $(SystemRoot)\System32\find.exe "x64" >NUL ] == 0 -ARCH=x64 Release -!ELSE -ARCH=Win32 Release -!ENDIF - -!MESSAGE ARCH = $(ARCH) -!MESSAGE PREFIX = $(PREFIX) (install path) - - -# Utility and Translation things, nothing here for the user -# -!IF "$(ARCH)" == "Win32 Release" -SLNARCH=Release|Win32 -ARCHOSPATH=Release -LIBSOSPATH=LibR -!ELSEIF "$(ARCH)" == "Win32 Debug" -SLNARCH=Debug|Win32 -ARCHOSPATH=Debug -LIBSOSPATH=LibD -!ELSEIF "$(ARCH)" == "Win32 Release9x" -SLNARCH=Release9x|Win32 -ARCHOSPATH=9x\Release -LIBSOSPATH=9x\LibR -!ELSEIF "$(ARCH)" == "Win32 Debug9x" -SLNARCH=Debug9x|Win32 -ARCHOSPATH=9x\Debug -LIBSOSPATH=9x\LibD -!ELSEIF "$(ARCH)" == "x64 Release" -SLNARCH=Release|x64 -ARCHOSPATH=x64\Release -LIBSOSPATH=x64\LibR -!ELSEIF "$(ARCH)" == "x64 Debug" -SLNARCH=Debug|x64 -ARCHOSPATH=x64\Debug -LIBSOSPATH=x64\LibD -!ENDIF - -!IFNDEF MAKEOPT -# Only default the behavior if MAKEOPT= is omitted -!IFDEF _NMAKE_VER -# Microsoft NMake options -MAKEOPT=-nologo -!ELSEIF "$(MAKE)" == "make" -# Borland make options? Not really supported (yet) -MAKEOPT=-s -N -!ENDIF -!ENDIF - - -all: buildall checkall - -!IF $(USEMAK) == 1 - -clean: - $(MAKE) $(MAKEOPT) -f Makefile.win ARCH="$(ARCH)" \ - CTARGET=CLEAN buildall - -buildall: - $(MAKE) $(MAKEOPT) -f apr.mak CFG="apr - $(ARCH)" RECURSE=0 $(CTARGET) - $(MAKE) $(MAKEOPT) -f libapr.mak CFG="libapr - $(ARCH)" RECURSE=0 $(CTARGET) - cd build - $(MAKE) $(MAKEOPT) -f aprapp.mak CFG="aprapp - $(ARCH)" RECURSE=0 $(CTARGET) - $(MAKE) $(MAKEOPT) -f libaprapp.mak CFG="libaprapp - $(ARCH)" RECURSE=0 $(CTARGET) - cd .. - -!ELSEIF $(USESLN) == 1 - -clean: - -devenv apr.sln /useenv /clean "$(SLNARCH)" /project libaprapp - -devenv apr.sln /useenv /clean "$(SLNARCH)" /project libapr - -devenv apr.sln /useenv /clean "$(SLNARCH)" /project aprapp - -devenv apr.sln /useenv /clean "$(SLNARCH)" /project apr - -buildall: - devenv apr.sln /useenv /build "$(SLNARCH)" /project apr - devenv apr.sln /useenv /build "$(SLNARCH)" /project aprapp - devenv apr.sln /useenv /build "$(SLNARCH)" /project libapr - devenv apr.sln /useenv /build "$(SLNARCH)" /project libaprapp - -!ELSE -# $(USEDSP) == 1 - -clean: - -msdev apr.dsw /USEENV /MAKE "libaprapp - $(ARCH)" /CLEAN - -msdev apr.dsw /USEENV /MAKE "libapr - $(ARCH)" /CLEAN - -msdev apr.dsw /USEENV /MAKE "aprapp - $(ARCH)" /CLEAN - -msdev apr.dsw /USEENV /MAKE "apr - $(ARCH)" /CLEAN - -buildall: - @msdev apr.dsw /USEENV /MAKE "apr - $(ARCH)" - @msdev apr.dsw /USEENV /MAKE "aprapp - $(ARCH)" - @msdev apr.dsw /USEENV /MAKE "libapr - $(ARCH)" - @msdev apr.dsw /USEENV /MAKE "libaprapp - $(ARCH)" - -!ENDIF - - -checkapr: - cd test - $(MAKE) $(MAKEOPT) -f Makefile.win MODEL=static \ - OUTDIR=$(LIBSOSPATH) check - $(MAKE) $(MAKEOPT) -f Makefile.win MODEL=dynamic \ - OUTDIR=$(ARCHOSPATH) check - cd .. - -checkall: checkapr - - -install: - echo Y >.y - echo A >.A - @if NOT EXIST "$(PREFIX)\." mkdir "$(PREFIX)" - @if NOT EXIST "$(PREFIX)\bin\." mkdir "$(PREFIX)\bin" - @if NOT EXIST "$(PREFIX)\include\." mkdir "$(PREFIX)\include" - @if NOT EXIST "$(PREFIX)\lib\." mkdir "$(PREFIX)\lib" - copy CHANGES "$(PREFIX)\APR-CHANGES.txt" <.y - copy LICENSE "$(PREFIX)\APR-LICENSE.txt" <.y - copy NOTICE "$(PREFIX)\APR-NOTICE.txt" <.y - xcopy include\*.h "$(PREFIX)\include\" /d < .a - copy $(LIBSOSPATH)\apr-1.lib "$(PREFIX)\lib\" <.y - copy $(LIBSOSPATH)\apr-1.pdb "$(PREFIX)\lib\" <.y - copy $(LIBSOSPATH)\aprapp-1.lib "$(PREFIX)\lib\" <.y - copy $(LIBSOSPATH)\aprapp-1.pdb "$(PREFIX)\lib\" <.y - copy $(ARCHOSPATH)\libaprapp-1.lib "$(PREFIX)\lib\" <.y - copy $(ARCHOSPATH)\libaprapp-1.pdb "$(PREFIX)\lib\" <.y - copy $(ARCHOSPATH)\libapr-1.lib "$(PREFIX)\lib\" <.y - copy $(ARCHOSPATH)\libapr-1.exp "$(PREFIX)\lib\" <.y - copy $(ARCHOSPATH)\libapr-1.dll "$(PREFIX)\bin\" <.y - copy $(ARCHOSPATH)\libapr-1.pdb "$(PREFIX)\bin\" <.y - del .y - del .a - diff --git a/libs/apr/NOTICE b/libs/apr/NOTICE deleted file mode 100644 index 6643ee6d..00000000 --- a/libs/apr/NOTICE +++ /dev/null @@ -1,15 +0,0 @@ -Apache Portable Runtime -Copyright (c) 2011 The Apache Software Foundation. - -This product includes software developed by -The Apache Software Foundation (http://www.apache.org/). - -Portions of this software were developed at the National Center -for Supercomputing Applications (NCSA) at the University of -Illinois at Urbana-Champaign. - -This software contains code derived from the RSA Data Security -Inc. MD5 Message-Digest Algorithm. - -This software contains code derived from UNIX V7, Copyright(C) -Caldera International Inc. diff --git a/libs/apr/NWGNUmakefile b/libs/apr/NWGNUmakefile deleted file mode 100644 index 3f789ebc..00000000 --- a/libs/apr/NWGNUmakefile +++ /dev/null @@ -1,430 +0,0 @@ -# -# Define our macros with defaults if we dont got them already. -# -ifndef APR_WORK -export APR_WORK = $(CURDIR) -endif -ifneq "$(wildcard $(APR_WORK)/include/apr_version.h)" "$(APR_WORK)/include/apr_version.h" -$(error APR_WORK does not point to a valid APR source tree) -endif -ifndef APU_WORK -export APU_WORK = $(CURDIR)/../apr-util -endif -ifneq "$(wildcard $(APU_WORK)/include/apu_version.h)" "$(APU_WORK)/include/apu_version.h" -$(error APU_WORK does not point to a valid APU source tree) -endif - -# -# Declare the sub-directories to be built here -# - -SUBDIRS = \ - build \ - $(APU_WORK) \ - $(EOLIST) - -ifeq "$(TEST)" "1" -SUBDIRS += \ - test \ - $(APU_WORK)/test \ - $(EOLIST) -endif - -# -# Get the 'head' of the build environment. This includes default targets and -# paths to tools -# - -include $(APR_WORK)/build/NWGNUhead.inc - -# -# build this level's files - -# -# Make sure all needed macro's are defined -# - -# -# These directories will be at the beginning of the include list, followed by -# INCDIRS -# -XINCDIRS += \ - $(APR)/include \ - $(APR)/include/arch/NetWare \ - $(APR)/include/arch/unix \ - $(APR)/memory/unix \ - $(APR)/random/unix \ - $(APU)/include \ - $(APU)/xml \ - $(LDAPSDK)/inc \ - $(EOLIST) - -# -# These flags will come after CFLAGS -# -XCFLAGS += \ - $(EOLIST) - -# -# These defines will come after DEFINES -# -XDEFINES += \ - $(EOLIST) - -# -# These flags will be added to the link.opt file -# -XLFLAGS += \ - $(EOLIST) - -# -# These values will be appended to the correct variables based on the value of -# RELEASE -# -ifeq "$(RELEASE)" "debug" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) -endif - -ifeq "$(RELEASE)" "noopt" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) -endif - -ifeq "$(RELEASE)" "release" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) -endif - -# -# These are used by the link target if an NLM is being generated -# This is used by the link 'name' directive to name the nlm. If left blank -# TARGET_nlm (see below) will be used. -# -NLM_NAME = aprlib - -# -# This is used by the link '-desc ' directive. -# If left blank, NLM_NAME will be used. -# -NLM_DESCRIPTION = Apache Portability Runtime Library $(VERSION_STR) $(VERSION_SKT) - -# -# This is used by the '-threadname' directive. If left blank, -# NLM_NAME Thread will be used. -# -NLM_THREAD_NAME = -# -# If this is specified, it will override VERSION value in -# $(APR_WORK)/build/NWGNUenvironment.inc -# -NLM_VERSION = - -# -# If this is specified, it will override the default of 64K -# -NLM_STACK_SIZE = - -# -# If this is specified it will be used by the link '-entry' directive -# -NLM_ENTRY_SYM = - -# -# If this is specified it will be used by the link '-exit' directive -# -NLM_EXIT_SYM = - -# -# If this is specified it will be used by the link '-check' directive -# -NLM_CHECK_SYM = - -# -# If this is specified it will be used by the link '-flags' directive -# -NLM_FLAGS = - -# -# If this is specified it will be linked in with the XDCData option in the def -# file instead of the default of $(APR)/misc/netware/apache.xdc. XDCData can -# be disabled by setting APACHE_UNIPROC in the environment -# -XDCDATA = - -# -# Declare all target files (you must add your files here) -# - -# -# If there is an NLM target, put it here -# -TARGET_nlm = \ - $(OBJDIR)/aprlib.nlm \ - $(EOLIST) - -# -# If there is an LIB target, put it here -# -TARGET_lib = \ - $(OBJDIR)/aprlib.lib \ - $(EOLIST) - -# -# These are the OBJ files needed to create the NLM target above. -# Paths must all use the '/' character -# -FILES_nlm_objs = \ - $(OBJDIR)/libprews.o \ - $(EOLIST) - -# -# These are the LIB files needed to create the NLM target above. -# These will be added as a library command in the link.opt file. -# -FILES_nlm_libs = \ - $(PRELUDE) \ - $(APRLIB) \ - $(APULIB) \ - $(APULDAPLIB) \ - $(APUXMLLIB) \ - $(EOLIST) - -# -# These are the modules that the above NLM target depends on to load. -# These will be added as a module command in the link.opt file. -# -FILES_nlm_modules = \ - Libc \ - $(EOLIST) - -# Include the Winsock libraries if Winsock is being used -ifndef USE_STDSOCKETS -FILES_nlm_modules += ws2_32 \ - $(EOLIST) -endif - -#If the LDAP support is defined then add the auto-load modules -ifneq "$(LDAPSDK)" "" -FILES_nlm_modules += \ - lldapsdk \ - lldapssl \ - $(EOLIST) -endif - -# -# If the nlm has a msg file, put it's path here -# -FILE_nlm_msg = - -# -# If the nlm has a hlp file put it's path here -# -FILE_nlm_hlp = - -# -# If this is specified, it will override $(NWOS)\copyright.txt. -# -FILE_nlm_copyright = - -# -# Any additional imports go here -# -FILES_nlm_Ximports = \ - @libc.imp \ - @netware.imp \ - $(EOLIST) - -# Include the Winsock imports if Winsock is being used -ifndef USE_STDSOCKETS -FILES_nlm_Ximports += \ - @ws2nlm.imp \ - WSAStartupRTags \ - WSACleanupRTag \ - $(EOLIST) -endif - -#If the LDAP support is defined then add the imports -ifneq "$(LDAPSDK)" "" -FILES_nlm_Ximports += \ - @lldapsdk.imp \ - @lldapssl.imp \ - $(EOLIST) -endif - -# -# Any symbols exported to here -# -FILES_nlm_exports = \ - @aprlib.imp \ - $(EOLIST) - -# -# These are the OBJ files needed to create the LIB target above. -# Paths must all use the '/' character -# -FILES_lib_objs = \ - $(OBJDIR)/apr_atomic.o \ - $(OBJDIR)/apr_cpystrn.o \ - $(OBJDIR)/apr_fnmatch.o \ - $(OBJDIR)/apr_getpass.o \ - $(OBJDIR)/apr_hash.o \ - $(OBJDIR)/apr_pools.o \ - $(OBJDIR)/apr_random.o \ - $(OBJDIR)/apr_snprintf.o \ - $(OBJDIR)/apr_strings.o \ - $(OBJDIR)/apr_strnatcmp.o \ - $(OBJDIR)/apr_strtok.o \ - $(OBJDIR)/apr_tables.o \ - $(OBJDIR)/buffer.o \ - $(OBJDIR)/charset.o \ - $(OBJDIR)/copy.o \ - $(OBJDIR)/common.o \ - $(OBJDIR)/dir.o \ - $(OBJDIR)/dso.o \ - $(OBJDIR)/errorcodes.o \ - $(OBJDIR)/env.o \ - $(OBJDIR)/fileacc.o \ - $(OBJDIR)/filedup.o \ - $(OBJDIR)/filepath.o \ - $(OBJDIR)/filepath_util.o \ - $(OBJDIR)/filestat.o \ - $(OBJDIR)/filesys.o \ - $(OBJDIR)/flock.o \ - $(OBJDIR)/fullrw.o \ - $(OBJDIR)/getopt.o \ - $(OBJDIR)/groupinfo.o \ - $(OBJDIR)/inet_pton.o \ - $(OBJDIR)/inet_ntop.o \ - $(OBJDIR)/mktemp.o \ - $(OBJDIR)/mmap.o \ - $(OBJDIR)/multicast.o \ - $(OBJDIR)/open.o \ - $(OBJDIR)/pipe.o \ - $(OBJDIR)/otherchild.o \ - $(OBJDIR)/proc.o \ - $(OBJDIR)/procsup.o \ - $(OBJDIR)/proc_mutex.o \ - $(OBJDIR)/rand.o \ - $(OBJDIR)/readwrite.o \ - $(OBJDIR)/seek.o \ - $(OBJDIR)/pollcb.o \ - $(OBJDIR)/pollset.o \ - $(OBJDIR)/select.o \ - $(OBJDIR)/sendrecv.o \ - $(OBJDIR)/sha2.o \ - $(OBJDIR)/sha2_glue.o \ - $(OBJDIR)/shm.o \ - $(OBJDIR)/signals.o \ - $(OBJDIR)/sockaddr.o \ - $(OBJDIR)/socket_util.o \ - $(OBJDIR)/sockets.o \ - $(OBJDIR)/sockopt.o \ - $(OBJDIR)/start.o \ - $(OBJDIR)/tempdir.o \ - $(OBJDIR)/thread.o \ - $(OBJDIR)/thread_cond.o \ - $(OBJDIR)/thread_mutex.o \ - $(OBJDIR)/thread_rwlock.o \ - $(OBJDIR)/threadpriv.o \ - $(OBJDIR)/time.o \ - $(OBJDIR)/timestr.o \ - $(OBJDIR)/userinfo.o \ - $(OBJDIR)/version.o \ - $(OBJDIR)/waitio.o \ - $(EOLIST) - - -# -# implement targets and dependancies (leave this section alone) -# - -libs :: $(OBJDIR) $(TARGET_lib) - -nlms :: libs $(TARGET_nlm) - -# -# Updated this target to create necessary directories and copy files to the -# correct place. (See $(APR_WORK)/build/NWGNUhead.inc for examples) -# -install :: nlms $(INSTDIRS) FORCE - $(call COPY,$(APR)/$(TARGET_nlm),$(INSTALLBASE)/) -ifndef DEST - -$(call COPY,$(APR)/LICENSE,$(INSTALLBASE)/) - -$(call COPY,$(APR)/STATUS,$(INSTALLBASE)/STATUS.apr) - -$(call COPY,$(APR)/CHANGES,$(INSTALLBASE)/CHANGES.apr) - -$(call COPY,$(APU)/STATUS,$(INSTALLBASE)/STATUS.apu) - -$(call COPY,$(APU)/CHANGES,$(INSTALLBASE)/CHANGES.apu) - -$(call COPYR,$(APR)/docs,$(INSTALLBASE)/docs/) -endif - -ifndef DEST -installdev :: $(INSTDEVDIRS) FORCE - $(call COPY,$(APR)/include/*.h,$(INSTALLBASE)/include/) - $(call COPY,$(APR)/*.imp,$(INSTALLBASE)/lib/) - $(call COPY,$(APR)/misc/netware/*.xdc,$(INSTALLBASE)/lib/) - $(call COPY,$(APR)/$(TARGET_nlm),$(INSTALLBASE)/bin/) - $(call COPY,$(APRLIB),$(INSTALLBASE)/lib/) - $(call COPY,$(APULIB),$(INSTALLBASE)/lib/) - $(call COPY,$(APULDAPLIB),$(INSTALLBASE)/lib/) - $(call COPY,$(APUXMLLIB),$(INSTALLBASE)/lib/) - -$(INSTDEVDIRS) :: - $(call MKDIR,$@) -endif - -# -# Any specialized rules here -# - -vpath %.c atomic/netware:strings:tables:passwd:lib:time/unix -vpath %.c file_io/unix:locks/netware:misc/netware:misc/unix:threadproc/netware -vpath %.c poll/unix:shmem/unix:support/unix:random/unix -vpath %.c dso/netware:memory/unix:mmap/unix:user/netware - -# Use the win32 network_io if Winsock is being used -ifndef USE_STDSOCKETS -vpath %.c network_io/win32 -endif -vpath %.c network_io/unix - -$(OBJDIR)/%.o: file_io/netware/%.c $(OBJDIR)/$(NLM_NAME)_cc.opt -# @echo Compiling $< - @echo $(DL)CC $<$(DL) - $(CC) $< -cwd source -o=$@ @$(OBJDIR)/$(NLM_NAME)_cc.opt - -# -# Include the 'tail' makefile that has targets that depend on variables defined -# in this makefile -# - -include $(APRBUILD)/NWGNUtail.inc - - diff --git a/libs/apr/README b/libs/apr/README deleted file mode 100644 index f3add18e..00000000 --- a/libs/apr/README +++ /dev/null @@ -1,167 +0,0 @@ -Apache Portable Runtime Library (APR) -------------------------------------- - - The Apache Portable Runtime Library provides a predictable and - consistent interface to underlying platform-specific - implementations, with an API to which software developers may code - and be assured of predictable if not identical behavior regardless - of the platform on which their software is built, relieving them of - the need to code special-case conditions to work around or take - advantage of platform-specific deficiencies or features. - - APR and its companion libraries are implemented entirely in C - and provide a common programming interface across a wide variety - of operating system platforms without sacrificing performance. - Currently supported platforms include: - - UNIX variants - Windows - Netware - Mac OS X - OS/2 - - To give a brief overview, the primary core - subsystems of APR 1.3 include the following: - - Atomic operations - Dynamic Shared Object loading - File I/O - Locks (mutexes, condition variables, etc) - Memory management (high performance allocators) - Memory-mapped files - Multicast Sockets - Network I/O - Shared memory - Thread and Process management - Various data structures (tables, hashes, priority queues, etc) - - For a more complete list, please refer to the following URLs: - - http://apr.apache.org/docs/apr/modules.html - - Users of APR 0.9 should be aware that migrating to the APR 1.x - programming interfaces may require some adjustments; APR 1.x is - neither source nor binary compatible with earlier APR 0.9 releases. - Users of APR 1.x can expect consistent interfaces and binary backwards - compatibility throughout the entire APR 1.x release cycle, as defined - in our versioning rules: - - http://apr.apache.org/versioning.html - - APR is already used extensively by the Apache HTTP Server - version 2 and the Subversion revision control system, to - name but a few. We list all known projects using APR at - http://apr.apache.org/projects.html -- so please let us know - if you find our libraries useful in your own projects! - - -Using a Subversion Checkout on Unix -=================================== - -If you are building APR from SVN, you need to perform a prerequisite -step. You must have autoconf, libtool and python installed for this -to work. The prerequisite is simply; - - ./buildconf - -If you are building APR from a distribution tarball, buildconf is -already run for you, and you do not need autoconf, libtool or python -installed or to run buildconf unless you have patched APR's buildconf -inputs (such as configure.in, build.conf, virtually any file within -the build/ tree, or you add or remove source files). - -Remember when updating from svn that you must rerun ./buildconf again -to effect any changes made to the build schema in your fresh update. - - -Configuring and Building APR on Unix -==================================== - -Simply; - - ./configure --prefix=/desired/path/of/apr - make - make test - make install - -Configure has additional options, ./configure --help will offer you -those choices. You may also add CC=compiler CFLAGS="compiler flags" -etc. prior to the ./configure statement (on the same line). Please -be warned, some flags must be passed as part of the CC command, -itself, in order for autoconf to make the right determinations. Eg.; - - CC="gcc -m64" ./configure --prefix=/desired/path/of/apr - -will inform APR that you are compiling to a 64 bit CPU, and autoconf -must consider that when setting up all of APR's internal and external -type declarations. - -For more verbose output from testall, you may wish to invoke testall -with the flag; - - cd test - ./testall -v - - -Building APR RPM files on Linux -=============================== - -Run the following to create SRPMs: - -rpmbuild -ts apr-.tar.bz2 -rpmbuild -ts apr-util-.tar.bz2 - -Run the following to create RPMs (or build from the SRPMs): - -rpmbuild -tb apr-.tar.bz2 -rpmbuild -tb apr-util-.tar.bz2 - -Resolve dependencies as appropriate. - - -Configuring and Building APR on Windows -======================================= - -Using Visual Studio, you can build and run the test validation of APR. -The Makefile.win make file has a bunch of documentation about it's -options, but a trivial build is simply; - - nmake -f Makefile.win - nmake -f Makefile.win PREFIX=c:\desired\path\of\apr install - -Note you must manually modify the include\apr.hw file before you -build to change default options, see the #define APR_HAS_... or the -#define APR_HAVE_... statements. Be careful, many of these aren't -appropriate to be modified. The most common change is - -#define APR_HAVE_IPV6 1 - -rather than 0 if this build of APR will be used strictly on machines -with the IPv6 adapter support installed. - -It's trivial to include the apr.dsp (for a static library) or the -libapr.dsp (for a dynamic library) in your own build project, or you -can load apr.dsw in Visual Studio 2002 (.NET) or later, which will -convert these for you into apr.sln and associated .vcproj files. - -When using APR as a dynamic library, nothing special is required, -simply link to libapr.lib. To use it as a static library, simply -define APR_DECLARE_STATIC before you include any apr header files -in your source, and link to apr.lib instead. - - -Generating Test Coverage information with gcc -============================================= - -If you want to generate test coverage data, use the following steps: - - ./buildconf - CFLAGS="-fprofile-arcs -ftest-coverage" ./configure - make - cd test - make - ./testall - cd .. - make gcov - - diff --git a/libs/apr/apr-config.in b/libs/apr/apr-config.in deleted file mode 100644 index 84b40735..00000000 --- a/libs/apr/apr-config.in +++ /dev/null @@ -1,251 +0,0 @@ -#!/bin/sh -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# APR script designed to allow easy command line access to APR configuration -# parameters. - -APR_MAJOR_VERSION="@APR_MAJOR_VERSION@" -APR_DOTTED_VERSION="@APR_DOTTED_VERSION@" - -prefix="@prefix@" -exec_prefix="@exec_prefix@" -bindir="@bindir@" -libdir="@libdir@" -datarootdir="@datadir@" -datadir="@datadir@" -installbuilddir="@installbuilddir@" -includedir="@includedir@" - -CC="@CC@" -CPP="@CPP@" -SHELL="@SHELL@" -CPPFLAGS="@EXTRA_CPPFLAGS@" -CFLAGS="@EXTRA_CFLAGS@" -LDFLAGS="@EXTRA_LDFLAGS@" -LIBS="@EXTRA_LIBS@" -EXTRA_INCLUDES="@EXTRA_INCLUDES@" -SHLIBPATH_VAR="@shlibpath_var@" -APR_SOURCE_DIR="@apr_srcdir@" -APR_BUILD_DIR="@apr_builddir@" -APR_SO_EXT="@so_ext@" -APR_LIB_TARGET="@export_lib_target@" -APR_LIBNAME="@APR_LIBNAME@" - -# NOTE: the following line is modified during 'make install': alter with care! -location=@APR_CONFIG_LOCATION@ - -show_usage() -{ - cat << EOF -Usage: apr-$APR_MAJOR_VERSION-config [OPTION] - -Known values for OPTION are: - --prefix[=DIR] change prefix to DIR - --bindir print location where binaries are installed - --includedir print location where headers are installed - --cc print C compiler name - --cpp print C preprocessor name and any required options - --cflags print C compiler flags - --cppflags print C preprocessor flags - --includes print include information - --ldflags print linker flags - --libs print additional libraries to link against - --srcdir print APR source directory - --installbuilddir print APR build helper directory - --link-ld print link switch(es) for linking to APR - --link-libtool print the libtool inputs for linking to APR - --shlib-path-var print the name of the shared library path env var - --apr-la-file print the path to the .la file, if available - --apr-so-ext print the extensions of shared objects on this platform - --apr-lib-target print the libtool target information - --apr-libtool print the path to APR's libtool - --version print the APR's version as a dotted triple - --help print this help - -When linking with libtool, an application should do something like: - APR_LIBS="\`apr-$APR_MAJOR_VERSION-config --link-libtool --libs\`" -or when linking directly: - APR_LIBS="\`apr-$APR_MAJOR_VERSION-config --link-ld --libs\`" - -An application should use the results of --cflags, --cppflags, --includes, -and --ldflags in their build process. -EOF -} - -if test $# -eq 0; then - show_usage - exit 1 -fi - -if test "$location" = "installed"; then - LA_FILE="$libdir/lib${APR_LIBNAME}.la" -else - LA_FILE="$APR_BUILD_DIR/lib${APR_LIBNAME}.la" -fi - -flags="" - -while test $# -gt 0; do - # Normalize the prefix. - case "$1" in - -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) optarg= ;; - esac - - case "$1" in - # It is possible for the user to override our prefix. - --prefix=*) - prefix=$optarg - ;; - --prefix) - echo $prefix - exit 0 - ;; - --bindir) - echo $bindir - exit 0 - ;; - --includedir) - if test "$location" = "installed"; then - flags="$includedir" - elif test "$location" = "source"; then - flags="$APR_SOURCE_DIR/include" - else - # this is for VPATH builds - flags="$APR_BUILD_DIR/include $APR_SOURCE_DIR/include" - fi - echo $flags - exit 0 - ;; - --cc) - echo $CC - exit 0 - ;; - --cpp) - echo $CPP - exit 0 - ;; - --cflags) - flags="$flags $CFLAGS" - ;; - --cppflags) - flags="$flags $CPPFLAGS" - ;; - --libs) - flags="$flags $LIBS" - ;; - --ldflags) - flags="$flags $LDFLAGS" - ;; - --includes) - if test "$location" = "installed"; then - flags="$flags -I$includedir $EXTRA_INCLUDES" - elif test "$location" = "source"; then - flags="$flags -I$APR_SOURCE_DIR/include $EXTRA_INCLUDES" - else - # this is for VPATH builds - flags="$flags -I$APR_BUILD_DIR/include -I$APR_SOURCE_DIR/include $EXTRA_INCLUDES" - fi - ;; - --srcdir) - echo $APR_SOURCE_DIR - exit 0 - ;; - --installbuilddir) - if test "$location" = "installed"; then - echo "${installbuilddir}" - elif test "$location" = "source"; then - echo "$APR_SOURCE_DIR/build" - else - # this is for VPATH builds - echo "$APR_BUILD_DIR/build" - fi - exit 0 - ;; - --version) - echo $APR_DOTTED_VERSION - exit 0 - ;; - --link-ld) - if test "$location" = "installed"; then - ### avoid using -L if libdir is a "standard" location like /usr/lib - flags="$flags -L$libdir -l${APR_LIBNAME}" - else - ### this surely can't work since the library is in .libs? - flags="$flags -L$APR_BUILD_DIR -l${APR_LIBNAME}" - fi - ;; - --link-libtool) - # If the LA_FILE exists where we think it should be, use it. If we're - # installed and the LA_FILE does not exist, assume to use -L/-l - # (the LA_FILE may not have been installed). If we're building ourselves, - # we'll assume that at some point the .la file be created. - if test -f "$LA_FILE"; then - flags="$flags $LA_FILE" - elif test "$location" = "installed"; then - ### avoid using -L if libdir is a "standard" location like /usr/lib - # Since the user is specifying they are linking with libtool, we - # *know* that -R will be recognized by libtool. - flags="$flags -L$libdir -R$libdir -l${APR_LIBNAME}" - else - flags="$flags $LA_FILE" - fi - ;; - --shlib-path-var) - echo "$SHLIBPATH_VAR" - exit 0 - ;; - --apr-la-file) - if test -f "$LA_FILE"; then - flags="$flags $LA_FILE" - fi - ;; - --apr-so-ext) - echo "$APR_SO_EXT" - exit 0 - ;; - --apr-lib-target) - echo "$APR_LIB_TARGET" - exit 0 - ;; - --apr-libtool) - if test "$location" = "installed"; then - echo "${installbuilddir}/libtool" - else - echo "$APR_BUILD_DIR/libtool" - fi - exit 0 - ;; - --help) - show_usage - exit 0 - ;; - *) - show_usage - exit 1 - ;; - esac - - # Next please. - shift -done - -if test -n "$flags"; then - echo "$flags" -fi - -exit 0 diff --git a/libs/apr/apr.dep b/libs/apr/apr.dep deleted file mode 100644 index 3abf37de..00000000 --- a/libs/apr/apr.dep +++ /dev/null @@ -1,558 +0,0 @@ -# Microsoft Developer Studio Generated Dependency File, included by apr.mak - -.\atomic\win32\apr_atomic.c : \ - ".\include\apr_atomic.h"\ - - -.\dso\win32\dso.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_dso.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\win32\buffer.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\unix\copy.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\win32\dir.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_atime.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\unix\fileacc.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\win32\filedup.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_inherit.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\win32\filepath.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\unix\filepath_util.c : \ - ".\include\apr_strings.h"\ - - -.\file_io\win32\filestat.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_atime.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\win32\filesys.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\win32\flock.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\unix\fullrw.c : \ - - -.\file_io\unix\mktemp.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_inherit.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\win32\open.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_inherit.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\win32\pipe.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\win32\readwrite.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_atime.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\win32\seek.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\unix\tempdir.c : \ - ".\include\apr_env.h"\ - ".\include\apr_strings.h"\ - - -.\locks\win32\proc_mutex.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_proc_mutex.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\locks\win32\thread_cond.c : \ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\apr_thread_cond.h"\ - ".\include\arch\win32\apr_arch_thread_cond.h"\ - ".\include\arch\win32\apr_arch_thread_mutex.h"\ - - -.\locks\win32\thread_mutex.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_thread_mutex.h"\ - - -.\locks\win32\thread_rwlock.c : \ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\apr_thread_rwlock.h"\ - ".\include\arch\win32\apr_arch_thread_rwlock.h"\ - - -.\memory\unix\apr_pools.c : \ - ".\include\apr_atomic.h"\ - ".\include\apr_env.h"\ - ".\include\apr_hash.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - - -.\misc\win32\charset.c : \ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - - -.\misc\win32\env.c : \ - ".\include\apr_env.h"\ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\misc\unix\errorcodes.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - - -.\misc\unix\getopt.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - - -.\misc\win32\internal.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\misc\win32\misc.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - ".\include\arch\win32\apr_dbg_win32_handles.h"\ - - -.\misc\unix\otherchild.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_threadproc.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\misc\win32\rand.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_portable.h"\ - - -.\misc\win32\start.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_signal.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_threadproc.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\misc\win32\utf8.c : \ - ".\include\apr_lib.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\misc\unix\version.c : \ - ".\include\apr_version.h"\ - - -.\mmap\unix\common.c : \ - ".\include\apr_mmap.h"\ - - -.\mmap\win32\mmap.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_mmap.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\network_io\unix\inet_ntop.c : \ - ".\include\apr_poll.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_networkio.h"\ - - -.\network_io\unix\inet_pton.c : \ - ".\include\apr_poll.h"\ - ".\include\arch\win32\apr_arch_networkio.h"\ - - -.\network_io\unix\multicast.c : \ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_support.h"\ - ".\include\arch\win32\apr_arch_inherit.h"\ - ".\include\arch\win32\apr_arch_networkio.h"\ - - -.\network_io\win32\sendrecv.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_networkio.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\network_io\unix\sockaddr.c : \ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_networkio.h"\ - - -.\network_io\unix\socket_util.c : \ - ".\include\apr_poll.h"\ - - -.\network_io\win32\sockets.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_inherit.h"\ - ".\include\arch\win32\apr_arch_networkio.h"\ - - -.\network_io\win32\sockopt.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_networkio.h"\ - - -.\passwd\apr_getpass.c : \ - ".\include\apr_lib.h"\ - ".\include\apr_strings.h"\ - - -.\poll\unix\poll.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\unix\apr_arch_poll_private.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_networkio.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\poll\unix\pollcb.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\unix\apr_arch_poll_private.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_networkio.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\poll\unix\pollset.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\unix\apr_arch_poll_private.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_inherit.h"\ - ".\include\arch\win32\apr_arch_networkio.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\poll\unix\select.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\unix\apr_arch_poll_private.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_networkio.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\random\unix\apr_random.c : \ - ".\include\apr_random.h"\ - - -.\random\unix\sha2.c : \ - ".\random\unix\sha2.h"\ - - -.\random\unix\sha2_glue.c : \ - ".\include\apr_random.h"\ - ".\random\unix\sha2.h"\ - - -.\shmem\win32\shm.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\strings\apr_cpystrn.c : \ - ".\include\apr_lib.h"\ - ".\include\apr_strings.h"\ - - -.\strings\apr_fnmatch.c : \ - ".\include\apr_fnmatch.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_strings.h"\ - - -.\strings\apr_snprintf.c : \ - ".\include\apr_lib.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - - -.\strings\apr_strings.c : \ - ".\include\apr_lib.h"\ - ".\include\apr_strings.h"\ - - -.\strings\apr_strnatcmp.c : \ - ".\include\apr_lib.h"\ - ".\include\apr_strings.h"\ - - -.\strings\apr_strtok.c : \ - ".\include\apr_strings.h"\ - - -.\tables\apr_hash.c : \ - ".\include\apr_hash.h"\ - - -.\tables\apr_tables.c : \ - ".\include\apr_lib.h"\ - ".\include\apr_strings.h"\ - - -.\threadproc\win32\proc.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_threadproc.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\threadproc\win32\signals.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_signal.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_threadproc.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\threadproc\win32\thread.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\win32\apr_arch_threadproc.h"\ - - -.\threadproc\win32\threadpriv.c : \ - ".\include\apr_lib.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\win32\apr_arch_threadproc.h"\ - - -.\time\win32\time.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\win32\apr_arch_atime.h"\ - - -.\time\win32\timestr.c : \ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_atime.h"\ - - -.\user\win32\groupinfo.c : \ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - - -.\user\win32\userinfo.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -!IF "$(CFG)" == "apr - Win32 Release" - -!ELSEIF "$(CFG)" == "apr - Win32 Debug" - -!ELSEIF "$(CFG)" == "apr - Win32 Release9x" - -!ELSEIF "$(CFG)" == "apr - Win32 Debug9x" - -!ELSEIF "$(CFG)" == "apr - x64 Release" - -!ELSEIF "$(CFG)" == "apr - x64 Debug" - -!ENDIF - diff --git a/libs/apr/apr.dsp b/libs/apr/apr.dsp deleted file mode 100644 index 82eda32c..00000000 --- a/libs/apr/apr.dsp +++ /dev/null @@ -1,817 +0,0 @@ -# Microsoft Developer Studio Project File - Name="apr" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=apr - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "apr.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "apr.mak" CFG="apr - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "apr - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "apr - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE "apr - Win32 Release9x" (based on "Win32 (x86) Static Library") -!MESSAGE "apr - Win32 Debug9x" (based on "Win32 (x86) Static Library") -!MESSAGE "apr - x64 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "apr - x64 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "apr - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "LibR" -# PROP BASE Intermediate_Dir "LibR" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "LibR" -# PROP Intermediate_Dir "LibR" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MD /W3 /Zi /O2 /Oy- /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "NDEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "WINNT" /D "_WINDOWS" /Fo"$(INTDIR)\" /Fd"$(OUTDIR)\apr-1" /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"LibR\apr-1.lib" - -!ELSEIF "$(CFG)" == "apr - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "LibD" -# PROP BASE Intermediate_Dir "LibD" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "LibD" -# PROP Intermediate_Dir "LibD" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MDd /W3 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /EHsc /c -# ADD CPP /nologo /MDd /W3 /Zi /Od /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "_DEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "WINNT" /D "_WINDOWS" /Fo"$(INTDIR)\" /Fd"$(OUTDIR)\apr-1" /FD /EHsc /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"LibD\apr-1.lib" - -!ELSEIF "$(CFG)" == "apr - Win32 Release9x" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "9x\LibR" -# PROP BASE Intermediate_Dir "9x\LibR" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "9x\LibR" -# PROP Intermediate_Dir "9x\LibR" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MD /W3 /Zi /O2 /Oy- /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "NDEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\" /Fd"$(OUTDIR)\apr-1" /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"9x\LibR\apr-1.lib" - -!ELSEIF "$(CFG)" == "apr - Win32 Debug9x" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "9x\LibD" -# PROP BASE Intermediate_Dir "9x\LibD" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "9x\LibD" -# PROP Intermediate_Dir "9x\LibD" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MDd /W3 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /EHsc /c -# ADD CPP /nologo /MDd /W3 /Zi /Od /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "_DEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\" /Fd"$(OUTDIR)\apr-1" /FD /EHsc /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"9x\LibD\apr-1.lib" - -!ELSEIF "$(CFG)" == "apr - x64 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "x64\LibR" -# PROP BASE Intermediate_Dir "x64\LibR" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "x64\LibR" -# PROP Intermediate_Dir "x64\LibR" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MD /W3 /Zi /O2 /Oy- /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "NDEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "WINNT" /D "_WINDOWS" /Fo"$(INTDIR)\" /Fd"$(OUTDIR)\apr-1" /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"x64\LibR\apr-1.lib" - -!ELSEIF "$(CFG)" == "apr - x64 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "x64\LibD" -# PROP BASE Intermediate_Dir "x64\LibD" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "x64\LibD" -# PROP Intermediate_Dir "x64\LibD" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MDd /W3 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /EHsc /c -# ADD CPP /nologo /MDd /W3 /Zi /Od /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "_DEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "WINNT" /D "_WINDOWS" /Fo"$(INTDIR)\" /Fd"$(OUTDIR)\apr-1" /FD /EHsc /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"x64\LibD\apr-1.lib" - -!ENDIF - -# Begin Target - -# Name "apr - Win32 Release" -# Name "apr - Win32 Debug" -# Name "apr - Win32 Release9x" -# Name "apr - Win32 Debug9x" -# Name "apr - x64 Release" -# Name "apr - x64 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter ".c" -# Begin Group "atomic" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\atomic\win32\apr_atomic.c -# End Source File -# End Group -# Begin Group "dso" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\dso\win32\dso.c -# End Source File -# End Group -# Begin Group "file_io" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\file_io\win32\buffer.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\unix\copy.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\win32\dir.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\unix\fileacc.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\win32\filedup.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\win32\filepath.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\unix\filepath_util.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\win32\filestat.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\win32\filesys.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\win32\flock.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\unix\fullrw.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\unix\mktemp.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\win32\open.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\win32\pipe.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\win32\readwrite.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\win32\seek.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\unix\tempdir.c -# End Source File -# End Group -# Begin Group "locks" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\locks\win32\proc_mutex.c -# End Source File -# Begin Source File - -SOURCE=.\locks\win32\thread_cond.c -# End Source File -# Begin Source File - -SOURCE=.\locks\win32\thread_mutex.c -# End Source File -# Begin Source File - -SOURCE=.\locks\win32\thread_rwlock.c -# End Source File -# End Group -# Begin Group "memory" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\memory\unix\apr_pools.c -# End Source File -# End Group -# Begin Group "misc" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\misc\win32\apr_app.c -# PROP Exclude_From_Build 1 -# End Source File -# Begin Source File - -SOURCE=.\misc\win32\charset.c -# End Source File -# Begin Source File - -SOURCE=.\misc\win32\env.c -# End Source File -# Begin Source File - -SOURCE=.\misc\unix\errorcodes.c -# End Source File -# Begin Source File - -SOURCE=.\misc\unix\getopt.c -# End Source File -# Begin Source File - -SOURCE=.\misc\win32\internal.c -# End Source File -# Begin Source File - -SOURCE=.\misc\win32\misc.c -# End Source File -# Begin Source File - -SOURCE=.\misc\unix\otherchild.c -# End Source File -# Begin Source File - -SOURCE=.\misc\win32\rand.c -# End Source File -# Begin Source File - -SOURCE=.\misc\win32\start.c -# End Source File -# Begin Source File - -SOURCE=.\misc\win32\utf8.c -# End Source File -# Begin Source File - -SOURCE=.\misc\unix\version.c -# End Source File -# End Group -# Begin Group "mmap" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\mmap\unix\common.c -# End Source File -# Begin Source File - -SOURCE=.\mmap\win32\mmap.c -# End Source File -# End Group -# Begin Group "network_io" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\network_io\unix\inet_ntop.c -# End Source File -# Begin Source File - -SOURCE=.\network_io\unix\inet_pton.c -# End Source File -# Begin Source File - -SOURCE=.\network_io\unix\multicast.c -# End Source File -# Begin Source File - -SOURCE=.\network_io\win32\sendrecv.c -# End Source File -# Begin Source File - -SOURCE=.\network_io\unix\sockaddr.c -# End Source File -# Begin Source File - -SOURCE=.\network_io\win32\sockets.c -# End Source File -# Begin Source File - -SOURCE=.\network_io\unix\socket_util.c -# End Source File -# Begin Source File - -SOURCE=.\network_io\win32\sockopt.c -# End Source File -# End Group -# Begin Group "passwd" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\passwd\apr_getpass.c -# End Source File -# End Group -# Begin Group "poll" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\poll\unix\poll.c -# End Source File -# Begin Source File - -SOURCE=.\poll\unix\pollcb.c -# End Source File -# Begin Source File - -SOURCE=.\poll\unix\pollset.c -# End Source File -# Begin Source File - -SOURCE=.\poll\unix\select.c -# End Source File -# End Group -# Begin Group "random" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\random\unix\apr_random.c -# End Source File -# Begin Source File - -SOURCE=.\random\unix\sha2.c -# End Source File -# Begin Source File - -SOURCE=.\random\unix\sha2_glue.c -# End Source File -# End Group -# Begin Group "shmem" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\shmem\win32\shm.c -# End Source File -# End Group -# Begin Group "strings" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\strings\apr_cpystrn.c -# End Source File -# Begin Source File - -SOURCE=.\strings\apr_fnmatch.c -# End Source File -# Begin Source File - -SOURCE=.\strings\apr_snprintf.c -# End Source File -# Begin Source File - -SOURCE=.\strings\apr_strings.c -# End Source File -# Begin Source File - -SOURCE=.\strings\apr_strnatcmp.c -# End Source File -# Begin Source File - -SOURCE=.\strings\apr_strtok.c -# End Source File -# End Group -# Begin Group "tables" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\tables\apr_hash.c -# End Source File -# Begin Source File - -SOURCE=.\tables\apr_tables.c -# End Source File -# End Group -# Begin Group "threadproc" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\threadproc\win32\proc.c -# End Source File -# Begin Source File - -SOURCE=.\threadproc\win32\signals.c -# End Source File -# Begin Source File - -SOURCE=.\threadproc\win32\thread.c -# End Source File -# Begin Source File - -SOURCE=.\threadproc\win32\threadpriv.c -# End Source File -# End Group -# Begin Group "time" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\time\win32\time.c -# End Source File -# Begin Source File - -SOURCE=.\time\win32\timestr.c -# End Source File -# End Group -# Begin Group "user" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\user\win32\groupinfo.c -# End Source File -# Begin Source File - -SOURCE=.\user\win32\userinfo.c -# End Source File -# End Group -# End Group -# Begin Group "Private Header Files" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\include\arch\win32\apr_arch_atime.h -# End Source File -# Begin Source File - -SOURCE=.\include\arch\win32\apr_arch_dso.h -# End Source File -# Begin Source File - -SOURCE=.\include\arch\win32\apr_arch_file_io.h -# End Source File -# Begin Source File - -SOURCE=.\include\arch\win32\apr_arch_inherit.h -# End Source File -# Begin Source File - -SOURCE=.\include\arch\win32\apr_arch_misc.h -# End Source File -# Begin Source File - -SOURCE=.\include\arch\win32\apr_arch_networkio.h -# End Source File -# Begin Source File - -SOURCE=.\include\arch\win32\apr_arch_thread_mutex.h -# End Source File -# Begin Source File - -SOURCE=.\include\arch\win32\apr_arch_thread_rwlock.h -# End Source File -# Begin Source File - -SOURCE=.\include\arch\win32\apr_arch_threadproc.h -# End Source File -# Begin Source File - -SOURCE=.\include\arch\win32\apr_arch_utf8.h -# End Source File -# Begin Source File - -SOURCE=.\include\arch\win32\apr_private.h -# End Source File -# Begin Source File - -SOURCE=.\include\arch\apr_private_common.h -# End Source File -# End Group -# Begin Group "Public Header Files" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\include\apr.h.in -# PROP Exclude_From_Build 1 -# End Source File -# Begin Source File - -SOURCE=.\include\apr.hnw -# PROP Exclude_From_Build 1 -# End Source File -# Begin Source File - -SOURCE=.\include\apr.hw - -!IF "$(CFG)" == "apr - Win32 Release" - -# Begin Custom Build - Creating apr.h from apr.hw -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apr.hw > .\include\apr.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "apr - Win32 Debug" - -# Begin Custom Build - Creating apr.h from apr.hw -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apr.hw > .\include\apr.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "apr - Win32 Release9x" - -# Begin Custom Build - Creating apr.h from apr.hw -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apr.hw > .\include\apr.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "apr - Win32 Debug9x" - -# Begin Custom Build - Creating apr.h from apr.hw -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apr.hw > .\include\apr.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "apr - x64 Release" - -# Begin Custom Build - Creating apr.h from apr.hw -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apr.hw > .\include\apr.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "apr - x64 Debug" - -# Begin Custom Build - Creating apr.h from apr.hw -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apr.hw > .\include\apr.h - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\include\apr_allocator.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_atomic.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_dso.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_env.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_errno.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_file_info.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_file_io.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_fnmatch.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_general.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_getopt.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_global_mutex.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_hash.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_inherit.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_lib.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_mmap.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_network_io.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_poll.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_pools.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_portable.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_proc_mutex.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_random.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_ring.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_shm.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_signal.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_strings.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_support.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_tables.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_thread_cond.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_thread_mutex.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_thread_proc.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_thread_rwlock.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_time.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_user.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_version.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_want.h -# End Source File -# End Group -# End Target -# End Project diff --git a/libs/apr/apr.dsw b/libs/apr/apr.dsw deleted file mode 100644 index 6d67f340..00000000 --- a/libs/apr/apr.dsw +++ /dev/null @@ -1,101 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "apr"=".\apr.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "aprapp"=".\build\aprapp.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name preaprapp - End Project Dependency -}}} - -############################################################################### - -Project: "libapr"=".\libapr.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "libaprapp"=".\build\libaprapp.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name prelibaprapp - End Project Dependency -}}} - -############################################################################### - -Project: "preaprapp"=".\build\preaprapp.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name apr - End Project Dependency -}}} - -############################################################################### - -Project: "prelibaprapp"=".\build\prelibaprapp.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name libapr - End Project Dependency -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/libs/apr/apr.mak b/libs/apr/apr.mak deleted file mode 100644 index 78bd56a9..00000000 --- a/libs/apr/apr.mak +++ /dev/null @@ -1,1779 +0,0 @@ -# Microsoft Developer Studio Generated NMAKE File, Based on apr.dsp -!IF "$(CFG)" == "" -CFG=apr - Win32 Release -!MESSAGE No configuration specified. Defaulting to apr - Win32 Release. -!ENDIF - -!IF "$(CFG)" != "apr - Win32 Release" && "$(CFG)" != "apr - Win32 Debug" && "$(CFG)" != "apr - Win32 Release9x" && "$(CFG)" != "apr - Win32 Debug9x" && "$(CFG)" != "apr - x64 Release" && "$(CFG)" != "apr - x64 Debug" -!MESSAGE Invalid configuration "$(CFG)" specified. -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "apr.mak" CFG="apr - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "apr - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "apr - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE "apr - Win32 Release9x" (based on "Win32 (x86) Static Library") -!MESSAGE "apr - Win32 Debug9x" (based on "Win32 (x86) Static Library") -!MESSAGE "apr - x64 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "apr - x64 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE -!ERROR An invalid configuration is specified. -!ENDIF - -!IF "$(OS)" == "Windows_NT" -NULL= -!ELSE -NULL=nul -!ENDIF - -!IF "$(CFG)" == "apr - Win32 Release" - -OUTDIR=.\LibR -INTDIR=.\LibR -# Begin Custom Macros -OutDir=.\LibR -# End Custom Macros - -ALL : "$(OUTDIR)\apr-1.lib" - - -CLEAN : - -@erase "$(INTDIR)\apr-1.idb" - -@erase "$(INTDIR)\apr-1.pdb" - -@erase "$(INTDIR)\apr_atomic.obj" - -@erase "$(INTDIR)\apr_cpystrn.obj" - -@erase "$(INTDIR)\apr_fnmatch.obj" - -@erase "$(INTDIR)\apr_getpass.obj" - -@erase "$(INTDIR)\apr_hash.obj" - -@erase "$(INTDIR)\apr_pools.obj" - -@erase "$(INTDIR)\apr_random.obj" - -@erase "$(INTDIR)\apr_snprintf.obj" - -@erase "$(INTDIR)\apr_strings.obj" - -@erase "$(INTDIR)\apr_strnatcmp.obj" - -@erase "$(INTDIR)\apr_strtok.obj" - -@erase "$(INTDIR)\apr_tables.obj" - -@erase "$(INTDIR)\buffer.obj" - -@erase "$(INTDIR)\charset.obj" - -@erase "$(INTDIR)\common.obj" - -@erase "$(INTDIR)\copy.obj" - -@erase "$(INTDIR)\dir.obj" - -@erase "$(INTDIR)\dso.obj" - -@erase "$(INTDIR)\env.obj" - -@erase "$(INTDIR)\errorcodes.obj" - -@erase "$(INTDIR)\fileacc.obj" - -@erase "$(INTDIR)\filedup.obj" - -@erase "$(INTDIR)\filepath.obj" - -@erase "$(INTDIR)\filepath_util.obj" - -@erase "$(INTDIR)\filestat.obj" - -@erase "$(INTDIR)\filesys.obj" - -@erase "$(INTDIR)\flock.obj" - -@erase "$(INTDIR)\fullrw.obj" - -@erase "$(INTDIR)\getopt.obj" - -@erase "$(INTDIR)\groupinfo.obj" - -@erase "$(INTDIR)\inet_ntop.obj" - -@erase "$(INTDIR)\inet_pton.obj" - -@erase "$(INTDIR)\internal.obj" - -@erase "$(INTDIR)\misc.obj" - -@erase "$(INTDIR)\mktemp.obj" - -@erase "$(INTDIR)\mmap.obj" - -@erase "$(INTDIR)\multicast.obj" - -@erase "$(INTDIR)\open.obj" - -@erase "$(INTDIR)\otherchild.obj" - -@erase "$(INTDIR)\pipe.obj" - -@erase "$(INTDIR)\poll.obj" - -@erase "$(INTDIR)\pollcb.obj" - -@erase "$(INTDIR)\pollset.obj" - -@erase "$(INTDIR)\proc.obj" - -@erase "$(INTDIR)\proc_mutex.obj" - -@erase "$(INTDIR)\rand.obj" - -@erase "$(INTDIR)\readwrite.obj" - -@erase "$(INTDIR)\seek.obj" - -@erase "$(INTDIR)\select.obj" - -@erase "$(INTDIR)\sendrecv.obj" - -@erase "$(INTDIR)\sha2.obj" - -@erase "$(INTDIR)\sha2_glue.obj" - -@erase "$(INTDIR)\shm.obj" - -@erase "$(INTDIR)\signals.obj" - -@erase "$(INTDIR)\sockaddr.obj" - -@erase "$(INTDIR)\socket_util.obj" - -@erase "$(INTDIR)\sockets.obj" - -@erase "$(INTDIR)\sockopt.obj" - -@erase "$(INTDIR)\start.obj" - -@erase "$(INTDIR)\tempdir.obj" - -@erase "$(INTDIR)\thread.obj" - -@erase "$(INTDIR)\thread_cond.obj" - -@erase "$(INTDIR)\thread_mutex.obj" - -@erase "$(INTDIR)\thread_rwlock.obj" - -@erase "$(INTDIR)\threadpriv.obj" - -@erase "$(INTDIR)\time.obj" - -@erase "$(INTDIR)\timestr.obj" - -@erase "$(INTDIR)\userinfo.obj" - -@erase "$(INTDIR)\utf8.obj" - -@erase "$(INTDIR)\version.obj" - -@erase "$(OUTDIR)\apr-1.lib" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "NDEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "WINNT" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(OUTDIR)\apr-1" /FD /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -RSC=rc.exe -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\apr.bsc" -BSC32_SBRS= \ - -LIB32=link.exe -lib -LIB32_FLAGS=/nologo /out:"$(OUTDIR)\apr-1.lib" -LIB32_OBJS= \ - "$(INTDIR)\apr_atomic.obj" \ - "$(INTDIR)\dso.obj" \ - "$(INTDIR)\buffer.obj" \ - "$(INTDIR)\copy.obj" \ - "$(INTDIR)\dir.obj" \ - "$(INTDIR)\fileacc.obj" \ - "$(INTDIR)\filedup.obj" \ - "$(INTDIR)\filepath.obj" \ - "$(INTDIR)\filepath_util.obj" \ - "$(INTDIR)\filestat.obj" \ - "$(INTDIR)\filesys.obj" \ - "$(INTDIR)\flock.obj" \ - "$(INTDIR)\fullrw.obj" \ - "$(INTDIR)\mktemp.obj" \ - "$(INTDIR)\open.obj" \ - "$(INTDIR)\pipe.obj" \ - "$(INTDIR)\readwrite.obj" \ - "$(INTDIR)\seek.obj" \ - "$(INTDIR)\tempdir.obj" \ - "$(INTDIR)\proc_mutex.obj" \ - "$(INTDIR)\thread_cond.obj" \ - "$(INTDIR)\thread_mutex.obj" \ - "$(INTDIR)\thread_rwlock.obj" \ - "$(INTDIR)\apr_pools.obj" \ - "$(INTDIR)\charset.obj" \ - "$(INTDIR)\env.obj" \ - "$(INTDIR)\errorcodes.obj" \ - "$(INTDIR)\getopt.obj" \ - "$(INTDIR)\internal.obj" \ - "$(INTDIR)\misc.obj" \ - "$(INTDIR)\otherchild.obj" \ - "$(INTDIR)\rand.obj" \ - "$(INTDIR)\start.obj" \ - "$(INTDIR)\utf8.obj" \ - "$(INTDIR)\version.obj" \ - "$(INTDIR)\common.obj" \ - "$(INTDIR)\mmap.obj" \ - "$(INTDIR)\inet_ntop.obj" \ - "$(INTDIR)\inet_pton.obj" \ - "$(INTDIR)\multicast.obj" \ - "$(INTDIR)\sendrecv.obj" \ - "$(INTDIR)\sockaddr.obj" \ - "$(INTDIR)\sockets.obj" \ - "$(INTDIR)\socket_util.obj" \ - "$(INTDIR)\sockopt.obj" \ - "$(INTDIR)\apr_getpass.obj" \ - "$(INTDIR)\poll.obj" \ - "$(INTDIR)\pollcb.obj" \ - "$(INTDIR)\pollset.obj" \ - "$(INTDIR)\select.obj" \ - "$(INTDIR)\apr_random.obj" \ - "$(INTDIR)\sha2.obj" \ - "$(INTDIR)\sha2_glue.obj" \ - "$(INTDIR)\shm.obj" \ - "$(INTDIR)\apr_cpystrn.obj" \ - "$(INTDIR)\apr_fnmatch.obj" \ - "$(INTDIR)\apr_snprintf.obj" \ - "$(INTDIR)\apr_strings.obj" \ - "$(INTDIR)\apr_strnatcmp.obj" \ - "$(INTDIR)\apr_strtok.obj" \ - "$(INTDIR)\apr_hash.obj" \ - "$(INTDIR)\apr_tables.obj" \ - "$(INTDIR)\proc.obj" \ - "$(INTDIR)\signals.obj" \ - "$(INTDIR)\thread.obj" \ - "$(INTDIR)\threadpriv.obj" \ - "$(INTDIR)\time.obj" \ - "$(INTDIR)\timestr.obj" \ - "$(INTDIR)\groupinfo.obj" \ - "$(INTDIR)\userinfo.obj" - -"$(OUTDIR)\apr-1.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) - $(LIB32) @<< - $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) -<< - -!ELSEIF "$(CFG)" == "apr - Win32 Debug" - -OUTDIR=.\LibD -INTDIR=.\LibD -# Begin Custom Macros -OutDir=.\LibD -# End Custom Macros - -ALL : ".\include\apr.h" "$(OUTDIR)\apr-1.lib" - - -CLEAN : - -@erase "$(INTDIR)\apr-1.idb" - -@erase "$(INTDIR)\apr-1.pdb" - -@erase "$(INTDIR)\apr_atomic.obj" - -@erase "$(INTDIR)\apr_cpystrn.obj" - -@erase "$(INTDIR)\apr_fnmatch.obj" - -@erase "$(INTDIR)\apr_getpass.obj" - -@erase "$(INTDIR)\apr_hash.obj" - -@erase "$(INTDIR)\apr_pools.obj" - -@erase "$(INTDIR)\apr_random.obj" - -@erase "$(INTDIR)\apr_snprintf.obj" - -@erase "$(INTDIR)\apr_strings.obj" - -@erase "$(INTDIR)\apr_strnatcmp.obj" - -@erase "$(INTDIR)\apr_strtok.obj" - -@erase "$(INTDIR)\apr_tables.obj" - -@erase "$(INTDIR)\buffer.obj" - -@erase "$(INTDIR)\charset.obj" - -@erase "$(INTDIR)\common.obj" - -@erase "$(INTDIR)\copy.obj" - -@erase "$(INTDIR)\dir.obj" - -@erase "$(INTDIR)\dso.obj" - -@erase "$(INTDIR)\env.obj" - -@erase "$(INTDIR)\errorcodes.obj" - -@erase "$(INTDIR)\fileacc.obj" - -@erase "$(INTDIR)\filedup.obj" - -@erase "$(INTDIR)\filepath.obj" - -@erase "$(INTDIR)\filepath_util.obj" - -@erase "$(INTDIR)\filestat.obj" - -@erase "$(INTDIR)\filesys.obj" - -@erase "$(INTDIR)\flock.obj" - -@erase "$(INTDIR)\fullrw.obj" - -@erase "$(INTDIR)\getopt.obj" - -@erase "$(INTDIR)\groupinfo.obj" - -@erase "$(INTDIR)\inet_ntop.obj" - -@erase "$(INTDIR)\inet_pton.obj" - -@erase "$(INTDIR)\internal.obj" - -@erase "$(INTDIR)\misc.obj" - -@erase "$(INTDIR)\mktemp.obj" - -@erase "$(INTDIR)\mmap.obj" - -@erase "$(INTDIR)\multicast.obj" - -@erase "$(INTDIR)\open.obj" - -@erase "$(INTDIR)\otherchild.obj" - -@erase "$(INTDIR)\pipe.obj" - -@erase "$(INTDIR)\poll.obj" - -@erase "$(INTDIR)\pollcb.obj" - -@erase "$(INTDIR)\pollset.obj" - -@erase "$(INTDIR)\proc.obj" - -@erase "$(INTDIR)\proc_mutex.obj" - -@erase "$(INTDIR)\rand.obj" - -@erase "$(INTDIR)\readwrite.obj" - -@erase "$(INTDIR)\seek.obj" - -@erase "$(INTDIR)\select.obj" - -@erase "$(INTDIR)\sendrecv.obj" - -@erase "$(INTDIR)\sha2.obj" - -@erase "$(INTDIR)\sha2_glue.obj" - -@erase "$(INTDIR)\shm.obj" - -@erase "$(INTDIR)\signals.obj" - -@erase "$(INTDIR)\sockaddr.obj" - -@erase "$(INTDIR)\socket_util.obj" - -@erase "$(INTDIR)\sockets.obj" - -@erase "$(INTDIR)\sockopt.obj" - -@erase "$(INTDIR)\start.obj" - -@erase "$(INTDIR)\tempdir.obj" - -@erase "$(INTDIR)\thread.obj" - -@erase "$(INTDIR)\thread_cond.obj" - -@erase "$(INTDIR)\thread_mutex.obj" - -@erase "$(INTDIR)\thread_rwlock.obj" - -@erase "$(INTDIR)\threadpriv.obj" - -@erase "$(INTDIR)\time.obj" - -@erase "$(INTDIR)\timestr.obj" - -@erase "$(INTDIR)\userinfo.obj" - -@erase "$(INTDIR)\utf8.obj" - -@erase "$(INTDIR)\version.obj" - -@erase "$(OUTDIR)\apr-1.lib" - -@erase ".\include\apr.h" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "_DEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "WINNT" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(OUTDIR)\apr-1" /FD /EHsc /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -RSC=rc.exe -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\apr.bsc" -BSC32_SBRS= \ - -LIB32=link.exe -lib -LIB32_FLAGS=/nologo /out:"$(OUTDIR)\apr-1.lib" -LIB32_OBJS= \ - "$(INTDIR)\apr_atomic.obj" \ - "$(INTDIR)\dso.obj" \ - "$(INTDIR)\buffer.obj" \ - "$(INTDIR)\copy.obj" \ - "$(INTDIR)\dir.obj" \ - "$(INTDIR)\fileacc.obj" \ - "$(INTDIR)\filedup.obj" \ - "$(INTDIR)\filepath.obj" \ - "$(INTDIR)\filepath_util.obj" \ - "$(INTDIR)\filestat.obj" \ - "$(INTDIR)\filesys.obj" \ - "$(INTDIR)\flock.obj" \ - "$(INTDIR)\fullrw.obj" \ - "$(INTDIR)\mktemp.obj" \ - "$(INTDIR)\open.obj" \ - "$(INTDIR)\pipe.obj" \ - "$(INTDIR)\readwrite.obj" \ - "$(INTDIR)\seek.obj" \ - "$(INTDIR)\tempdir.obj" \ - "$(INTDIR)\proc_mutex.obj" \ - "$(INTDIR)\thread_cond.obj" \ - "$(INTDIR)\thread_mutex.obj" \ - "$(INTDIR)\thread_rwlock.obj" \ - "$(INTDIR)\apr_pools.obj" \ - "$(INTDIR)\charset.obj" \ - "$(INTDIR)\env.obj" \ - "$(INTDIR)\errorcodes.obj" \ - "$(INTDIR)\getopt.obj" \ - "$(INTDIR)\internal.obj" \ - "$(INTDIR)\misc.obj" \ - "$(INTDIR)\otherchild.obj" \ - "$(INTDIR)\rand.obj" \ - "$(INTDIR)\start.obj" \ - "$(INTDIR)\utf8.obj" \ - "$(INTDIR)\version.obj" \ - "$(INTDIR)\common.obj" \ - "$(INTDIR)\mmap.obj" \ - "$(INTDIR)\inet_ntop.obj" \ - "$(INTDIR)\inet_pton.obj" \ - "$(INTDIR)\multicast.obj" \ - "$(INTDIR)\sendrecv.obj" \ - "$(INTDIR)\sockaddr.obj" \ - "$(INTDIR)\sockets.obj" \ - "$(INTDIR)\socket_util.obj" \ - "$(INTDIR)\sockopt.obj" \ - "$(INTDIR)\apr_getpass.obj" \ - "$(INTDIR)\poll.obj" \ - "$(INTDIR)\pollcb.obj" \ - "$(INTDIR)\pollset.obj" \ - "$(INTDIR)\select.obj" \ - "$(INTDIR)\apr_random.obj" \ - "$(INTDIR)\sha2.obj" \ - "$(INTDIR)\sha2_glue.obj" \ - "$(INTDIR)\shm.obj" \ - "$(INTDIR)\apr_cpystrn.obj" \ - "$(INTDIR)\apr_fnmatch.obj" \ - "$(INTDIR)\apr_snprintf.obj" \ - "$(INTDIR)\apr_strings.obj" \ - "$(INTDIR)\apr_strnatcmp.obj" \ - "$(INTDIR)\apr_strtok.obj" \ - "$(INTDIR)\apr_hash.obj" \ - "$(INTDIR)\apr_tables.obj" \ - "$(INTDIR)\proc.obj" \ - "$(INTDIR)\signals.obj" \ - "$(INTDIR)\thread.obj" \ - "$(INTDIR)\threadpriv.obj" \ - "$(INTDIR)\time.obj" \ - "$(INTDIR)\timestr.obj" \ - "$(INTDIR)\groupinfo.obj" \ - "$(INTDIR)\userinfo.obj" - -"$(OUTDIR)\apr-1.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) - $(LIB32) @<< - $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) -<< - -!ELSEIF "$(CFG)" == "apr - Win32 Release9x" - -OUTDIR=.\9x\LibR -INTDIR=.\9x\LibR -# Begin Custom Macros -OutDir=.\9x\LibR -# End Custom Macros - -ALL : ".\include\apr.h" "$(OUTDIR)\apr-1.lib" - - -CLEAN : - -@erase "$(INTDIR)\apr-1.idb" - -@erase "$(INTDIR)\apr-1.pdb" - -@erase "$(INTDIR)\apr_atomic.obj" - -@erase "$(INTDIR)\apr_cpystrn.obj" - -@erase "$(INTDIR)\apr_fnmatch.obj" - -@erase "$(INTDIR)\apr_getpass.obj" - -@erase "$(INTDIR)\apr_hash.obj" - -@erase "$(INTDIR)\apr_pools.obj" - -@erase "$(INTDIR)\apr_random.obj" - -@erase "$(INTDIR)\apr_snprintf.obj" - -@erase "$(INTDIR)\apr_strings.obj" - -@erase "$(INTDIR)\apr_strnatcmp.obj" - -@erase "$(INTDIR)\apr_strtok.obj" - -@erase "$(INTDIR)\apr_tables.obj" - -@erase "$(INTDIR)\buffer.obj" - -@erase "$(INTDIR)\charset.obj" - -@erase "$(INTDIR)\common.obj" - -@erase "$(INTDIR)\copy.obj" - -@erase "$(INTDIR)\dir.obj" - -@erase "$(INTDIR)\dso.obj" - -@erase "$(INTDIR)\env.obj" - -@erase "$(INTDIR)\errorcodes.obj" - -@erase "$(INTDIR)\fileacc.obj" - -@erase "$(INTDIR)\filedup.obj" - -@erase "$(INTDIR)\filepath.obj" - -@erase "$(INTDIR)\filepath_util.obj" - -@erase "$(INTDIR)\filestat.obj" - -@erase "$(INTDIR)\filesys.obj" - -@erase "$(INTDIR)\flock.obj" - -@erase "$(INTDIR)\fullrw.obj" - -@erase "$(INTDIR)\getopt.obj" - -@erase "$(INTDIR)\groupinfo.obj" - -@erase "$(INTDIR)\inet_ntop.obj" - -@erase "$(INTDIR)\inet_pton.obj" - -@erase "$(INTDIR)\internal.obj" - -@erase "$(INTDIR)\misc.obj" - -@erase "$(INTDIR)\mktemp.obj" - -@erase "$(INTDIR)\mmap.obj" - -@erase "$(INTDIR)\multicast.obj" - -@erase "$(INTDIR)\open.obj" - -@erase "$(INTDIR)\otherchild.obj" - -@erase "$(INTDIR)\pipe.obj" - -@erase "$(INTDIR)\poll.obj" - -@erase "$(INTDIR)\pollcb.obj" - -@erase "$(INTDIR)\pollset.obj" - -@erase "$(INTDIR)\proc.obj" - -@erase "$(INTDIR)\proc_mutex.obj" - -@erase "$(INTDIR)\rand.obj" - -@erase "$(INTDIR)\readwrite.obj" - -@erase "$(INTDIR)\seek.obj" - -@erase "$(INTDIR)\select.obj" - -@erase "$(INTDIR)\sendrecv.obj" - -@erase "$(INTDIR)\sha2.obj" - -@erase "$(INTDIR)\sha2_glue.obj" - -@erase "$(INTDIR)\shm.obj" - -@erase "$(INTDIR)\signals.obj" - -@erase "$(INTDIR)\sockaddr.obj" - -@erase "$(INTDIR)\socket_util.obj" - -@erase "$(INTDIR)\sockets.obj" - -@erase "$(INTDIR)\sockopt.obj" - -@erase "$(INTDIR)\start.obj" - -@erase "$(INTDIR)\tempdir.obj" - -@erase "$(INTDIR)\thread.obj" - -@erase "$(INTDIR)\thread_cond.obj" - -@erase "$(INTDIR)\thread_mutex.obj" - -@erase "$(INTDIR)\thread_rwlock.obj" - -@erase "$(INTDIR)\threadpriv.obj" - -@erase "$(INTDIR)\time.obj" - -@erase "$(INTDIR)\timestr.obj" - -@erase "$(INTDIR)\userinfo.obj" - -@erase "$(INTDIR)\utf8.obj" - -@erase "$(INTDIR)\version.obj" - -@erase "$(OUTDIR)\apr-1.lib" - -@erase ".\include\apr.h" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "NDEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(OUTDIR)\apr-1" /FD /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -RSC=rc.exe -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\apr.bsc" -BSC32_SBRS= \ - -LIB32=link.exe -lib -LIB32_FLAGS=/nologo /out:"$(OUTDIR)\apr-1.lib" -LIB32_OBJS= \ - "$(INTDIR)\apr_atomic.obj" \ - "$(INTDIR)\dso.obj" \ - "$(INTDIR)\buffer.obj" \ - "$(INTDIR)\copy.obj" \ - "$(INTDIR)\dir.obj" \ - "$(INTDIR)\fileacc.obj" \ - "$(INTDIR)\filedup.obj" \ - "$(INTDIR)\filepath.obj" \ - "$(INTDIR)\filepath_util.obj" \ - "$(INTDIR)\filestat.obj" \ - "$(INTDIR)\filesys.obj" \ - "$(INTDIR)\flock.obj" \ - "$(INTDIR)\fullrw.obj" \ - "$(INTDIR)\mktemp.obj" \ - "$(INTDIR)\open.obj" \ - "$(INTDIR)\pipe.obj" \ - "$(INTDIR)\readwrite.obj" \ - "$(INTDIR)\seek.obj" \ - "$(INTDIR)\tempdir.obj" \ - "$(INTDIR)\proc_mutex.obj" \ - "$(INTDIR)\thread_cond.obj" \ - "$(INTDIR)\thread_mutex.obj" \ - "$(INTDIR)\thread_rwlock.obj" \ - "$(INTDIR)\apr_pools.obj" \ - "$(INTDIR)\charset.obj" \ - "$(INTDIR)\env.obj" \ - "$(INTDIR)\errorcodes.obj" \ - "$(INTDIR)\getopt.obj" \ - "$(INTDIR)\internal.obj" \ - "$(INTDIR)\misc.obj" \ - "$(INTDIR)\otherchild.obj" \ - "$(INTDIR)\rand.obj" \ - "$(INTDIR)\start.obj" \ - "$(INTDIR)\utf8.obj" \ - "$(INTDIR)\version.obj" \ - "$(INTDIR)\common.obj" \ - "$(INTDIR)\mmap.obj" \ - "$(INTDIR)\inet_ntop.obj" \ - "$(INTDIR)\inet_pton.obj" \ - "$(INTDIR)\multicast.obj" \ - "$(INTDIR)\sendrecv.obj" \ - "$(INTDIR)\sockaddr.obj" \ - "$(INTDIR)\sockets.obj" \ - "$(INTDIR)\socket_util.obj" \ - "$(INTDIR)\sockopt.obj" \ - "$(INTDIR)\apr_getpass.obj" \ - "$(INTDIR)\poll.obj" \ - "$(INTDIR)\pollcb.obj" \ - "$(INTDIR)\pollset.obj" \ - "$(INTDIR)\select.obj" \ - "$(INTDIR)\apr_random.obj" \ - "$(INTDIR)\sha2.obj" \ - "$(INTDIR)\sha2_glue.obj" \ - "$(INTDIR)\shm.obj" \ - "$(INTDIR)\apr_cpystrn.obj" \ - "$(INTDIR)\apr_fnmatch.obj" \ - "$(INTDIR)\apr_snprintf.obj" \ - "$(INTDIR)\apr_strings.obj" \ - "$(INTDIR)\apr_strnatcmp.obj" \ - "$(INTDIR)\apr_strtok.obj" \ - "$(INTDIR)\apr_hash.obj" \ - "$(INTDIR)\apr_tables.obj" \ - "$(INTDIR)\proc.obj" \ - "$(INTDIR)\signals.obj" \ - "$(INTDIR)\thread.obj" \ - "$(INTDIR)\threadpriv.obj" \ - "$(INTDIR)\time.obj" \ - "$(INTDIR)\timestr.obj" \ - "$(INTDIR)\groupinfo.obj" \ - "$(INTDIR)\userinfo.obj" - -"$(OUTDIR)\apr-1.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) - $(LIB32) @<< - $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) -<< - -!ELSEIF "$(CFG)" == "apr - Win32 Debug9x" - -OUTDIR=.\9x\LibD -INTDIR=.\9x\LibD -# Begin Custom Macros -OutDir=.\9x\LibD -# End Custom Macros - -ALL : ".\include\apr.h" "$(OUTDIR)\apr-1.lib" - - -CLEAN : - -@erase "$(INTDIR)\apr-1.idb" - -@erase "$(INTDIR)\apr-1.pdb" - -@erase "$(INTDIR)\apr_atomic.obj" - -@erase "$(INTDIR)\apr_cpystrn.obj" - -@erase "$(INTDIR)\apr_fnmatch.obj" - -@erase "$(INTDIR)\apr_getpass.obj" - -@erase "$(INTDIR)\apr_hash.obj" - -@erase "$(INTDIR)\apr_pools.obj" - -@erase "$(INTDIR)\apr_random.obj" - -@erase "$(INTDIR)\apr_snprintf.obj" - -@erase "$(INTDIR)\apr_strings.obj" - -@erase "$(INTDIR)\apr_strnatcmp.obj" - -@erase "$(INTDIR)\apr_strtok.obj" - -@erase "$(INTDIR)\apr_tables.obj" - -@erase "$(INTDIR)\buffer.obj" - -@erase "$(INTDIR)\charset.obj" - -@erase "$(INTDIR)\common.obj" - -@erase "$(INTDIR)\copy.obj" - -@erase "$(INTDIR)\dir.obj" - -@erase "$(INTDIR)\dso.obj" - -@erase "$(INTDIR)\env.obj" - -@erase "$(INTDIR)\errorcodes.obj" - -@erase "$(INTDIR)\fileacc.obj" - -@erase "$(INTDIR)\filedup.obj" - -@erase "$(INTDIR)\filepath.obj" - -@erase "$(INTDIR)\filepath_util.obj" - -@erase "$(INTDIR)\filestat.obj" - -@erase "$(INTDIR)\filesys.obj" - -@erase "$(INTDIR)\flock.obj" - -@erase "$(INTDIR)\fullrw.obj" - -@erase "$(INTDIR)\getopt.obj" - -@erase "$(INTDIR)\groupinfo.obj" - -@erase "$(INTDIR)\inet_ntop.obj" - -@erase "$(INTDIR)\inet_pton.obj" - -@erase "$(INTDIR)\internal.obj" - -@erase "$(INTDIR)\misc.obj" - -@erase "$(INTDIR)\mktemp.obj" - -@erase "$(INTDIR)\mmap.obj" - -@erase "$(INTDIR)\multicast.obj" - -@erase "$(INTDIR)\open.obj" - -@erase "$(INTDIR)\otherchild.obj" - -@erase "$(INTDIR)\pipe.obj" - -@erase "$(INTDIR)\poll.obj" - -@erase "$(INTDIR)\pollcb.obj" - -@erase "$(INTDIR)\pollset.obj" - -@erase "$(INTDIR)\proc.obj" - -@erase "$(INTDIR)\proc_mutex.obj" - -@erase "$(INTDIR)\rand.obj" - -@erase "$(INTDIR)\readwrite.obj" - -@erase "$(INTDIR)\seek.obj" - -@erase "$(INTDIR)\select.obj" - -@erase "$(INTDIR)\sendrecv.obj" - -@erase "$(INTDIR)\sha2.obj" - -@erase "$(INTDIR)\sha2_glue.obj" - -@erase "$(INTDIR)\shm.obj" - -@erase "$(INTDIR)\signals.obj" - -@erase "$(INTDIR)\sockaddr.obj" - -@erase "$(INTDIR)\socket_util.obj" - -@erase "$(INTDIR)\sockets.obj" - -@erase "$(INTDIR)\sockopt.obj" - -@erase "$(INTDIR)\start.obj" - -@erase "$(INTDIR)\tempdir.obj" - -@erase "$(INTDIR)\thread.obj" - -@erase "$(INTDIR)\thread_cond.obj" - -@erase "$(INTDIR)\thread_mutex.obj" - -@erase "$(INTDIR)\thread_rwlock.obj" - -@erase "$(INTDIR)\threadpriv.obj" - -@erase "$(INTDIR)\time.obj" - -@erase "$(INTDIR)\timestr.obj" - -@erase "$(INTDIR)\userinfo.obj" - -@erase "$(INTDIR)\utf8.obj" - -@erase "$(INTDIR)\version.obj" - -@erase "$(OUTDIR)\apr-1.lib" - -@erase ".\include\apr.h" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "_DEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(OUTDIR)\apr-1" /FD /EHsc /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -RSC=rc.exe -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\apr.bsc" -BSC32_SBRS= \ - -LIB32=link.exe -lib -LIB32_FLAGS=/nologo /out:"$(OUTDIR)\apr-1.lib" -LIB32_OBJS= \ - "$(INTDIR)\apr_atomic.obj" \ - "$(INTDIR)\dso.obj" \ - "$(INTDIR)\buffer.obj" \ - "$(INTDIR)\copy.obj" \ - "$(INTDIR)\dir.obj" \ - "$(INTDIR)\fileacc.obj" \ - "$(INTDIR)\filedup.obj" \ - "$(INTDIR)\filepath.obj" \ - "$(INTDIR)\filepath_util.obj" \ - "$(INTDIR)\filestat.obj" \ - "$(INTDIR)\filesys.obj" \ - "$(INTDIR)\flock.obj" \ - "$(INTDIR)\fullrw.obj" \ - "$(INTDIR)\mktemp.obj" \ - "$(INTDIR)\open.obj" \ - "$(INTDIR)\pipe.obj" \ - "$(INTDIR)\readwrite.obj" \ - "$(INTDIR)\seek.obj" \ - "$(INTDIR)\tempdir.obj" \ - "$(INTDIR)\proc_mutex.obj" \ - "$(INTDIR)\thread_cond.obj" \ - "$(INTDIR)\thread_mutex.obj" \ - "$(INTDIR)\thread_rwlock.obj" \ - "$(INTDIR)\apr_pools.obj" \ - "$(INTDIR)\charset.obj" \ - "$(INTDIR)\env.obj" \ - "$(INTDIR)\errorcodes.obj" \ - "$(INTDIR)\getopt.obj" \ - "$(INTDIR)\internal.obj" \ - "$(INTDIR)\misc.obj" \ - "$(INTDIR)\otherchild.obj" \ - "$(INTDIR)\rand.obj" \ - "$(INTDIR)\start.obj" \ - "$(INTDIR)\utf8.obj" \ - "$(INTDIR)\version.obj" \ - "$(INTDIR)\common.obj" \ - "$(INTDIR)\mmap.obj" \ - "$(INTDIR)\inet_ntop.obj" \ - "$(INTDIR)\inet_pton.obj" \ - "$(INTDIR)\multicast.obj" \ - "$(INTDIR)\sendrecv.obj" \ - "$(INTDIR)\sockaddr.obj" \ - "$(INTDIR)\sockets.obj" \ - "$(INTDIR)\socket_util.obj" \ - "$(INTDIR)\sockopt.obj" \ - "$(INTDIR)\apr_getpass.obj" \ - "$(INTDIR)\poll.obj" \ - "$(INTDIR)\pollcb.obj" \ - "$(INTDIR)\pollset.obj" \ - "$(INTDIR)\select.obj" \ - "$(INTDIR)\apr_random.obj" \ - "$(INTDIR)\sha2.obj" \ - "$(INTDIR)\sha2_glue.obj" \ - "$(INTDIR)\shm.obj" \ - "$(INTDIR)\apr_cpystrn.obj" \ - "$(INTDIR)\apr_fnmatch.obj" \ - "$(INTDIR)\apr_snprintf.obj" \ - "$(INTDIR)\apr_strings.obj" \ - "$(INTDIR)\apr_strnatcmp.obj" \ - "$(INTDIR)\apr_strtok.obj" \ - "$(INTDIR)\apr_hash.obj" \ - "$(INTDIR)\apr_tables.obj" \ - "$(INTDIR)\proc.obj" \ - "$(INTDIR)\signals.obj" \ - "$(INTDIR)\thread.obj" \ - "$(INTDIR)\threadpriv.obj" \ - "$(INTDIR)\time.obj" \ - "$(INTDIR)\timestr.obj" \ - "$(INTDIR)\groupinfo.obj" \ - "$(INTDIR)\userinfo.obj" - -"$(OUTDIR)\apr-1.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) - $(LIB32) @<< - $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) -<< - -!ELSEIF "$(CFG)" == "apr - x64 Release" - -OUTDIR=.\x64\LibR -INTDIR=.\x64\LibR -# Begin Custom Macros -OutDir=.\x64\LibR -# End Custom Macros - -ALL : ".\include\apr.h" "$(OUTDIR)\apr-1.lib" - - -CLEAN : - -@erase "$(INTDIR)\apr-1.idb" - -@erase "$(INTDIR)\apr-1.pdb" - -@erase "$(INTDIR)\apr_atomic.obj" - -@erase "$(INTDIR)\apr_cpystrn.obj" - -@erase "$(INTDIR)\apr_fnmatch.obj" - -@erase "$(INTDIR)\apr_getpass.obj" - -@erase "$(INTDIR)\apr_hash.obj" - -@erase "$(INTDIR)\apr_pools.obj" - -@erase "$(INTDIR)\apr_random.obj" - -@erase "$(INTDIR)\apr_snprintf.obj" - -@erase "$(INTDIR)\apr_strings.obj" - -@erase "$(INTDIR)\apr_strnatcmp.obj" - -@erase "$(INTDIR)\apr_strtok.obj" - -@erase "$(INTDIR)\apr_tables.obj" - -@erase "$(INTDIR)\buffer.obj" - -@erase "$(INTDIR)\charset.obj" - -@erase "$(INTDIR)\common.obj" - -@erase "$(INTDIR)\copy.obj" - -@erase "$(INTDIR)\dir.obj" - -@erase "$(INTDIR)\dso.obj" - -@erase "$(INTDIR)\env.obj" - -@erase "$(INTDIR)\errorcodes.obj" - -@erase "$(INTDIR)\fileacc.obj" - -@erase "$(INTDIR)\filedup.obj" - -@erase "$(INTDIR)\filepath.obj" - -@erase "$(INTDIR)\filepath_util.obj" - -@erase "$(INTDIR)\filestat.obj" - -@erase "$(INTDIR)\filesys.obj" - -@erase "$(INTDIR)\flock.obj" - -@erase "$(INTDIR)\fullrw.obj" - -@erase "$(INTDIR)\getopt.obj" - -@erase "$(INTDIR)\groupinfo.obj" - -@erase "$(INTDIR)\inet_ntop.obj" - -@erase "$(INTDIR)\inet_pton.obj" - -@erase "$(INTDIR)\internal.obj" - -@erase "$(INTDIR)\misc.obj" - -@erase "$(INTDIR)\mktemp.obj" - -@erase "$(INTDIR)\mmap.obj" - -@erase "$(INTDIR)\multicast.obj" - -@erase "$(INTDIR)\open.obj" - -@erase "$(INTDIR)\otherchild.obj" - -@erase "$(INTDIR)\pipe.obj" - -@erase "$(INTDIR)\poll.obj" - -@erase "$(INTDIR)\pollcb.obj" - -@erase "$(INTDIR)\pollset.obj" - -@erase "$(INTDIR)\proc.obj" - -@erase "$(INTDIR)\proc_mutex.obj" - -@erase "$(INTDIR)\rand.obj" - -@erase "$(INTDIR)\readwrite.obj" - -@erase "$(INTDIR)\seek.obj" - -@erase "$(INTDIR)\select.obj" - -@erase "$(INTDIR)\sendrecv.obj" - -@erase "$(INTDIR)\sha2.obj" - -@erase "$(INTDIR)\sha2_glue.obj" - -@erase "$(INTDIR)\shm.obj" - -@erase "$(INTDIR)\signals.obj" - -@erase "$(INTDIR)\sockaddr.obj" - -@erase "$(INTDIR)\socket_util.obj" - -@erase "$(INTDIR)\sockets.obj" - -@erase "$(INTDIR)\sockopt.obj" - -@erase "$(INTDIR)\start.obj" - -@erase "$(INTDIR)\tempdir.obj" - -@erase "$(INTDIR)\thread.obj" - -@erase "$(INTDIR)\thread_cond.obj" - -@erase "$(INTDIR)\thread_mutex.obj" - -@erase "$(INTDIR)\thread_rwlock.obj" - -@erase "$(INTDIR)\threadpriv.obj" - -@erase "$(INTDIR)\time.obj" - -@erase "$(INTDIR)\timestr.obj" - -@erase "$(INTDIR)\userinfo.obj" - -@erase "$(INTDIR)\utf8.obj" - -@erase "$(INTDIR)\version.obj" - -@erase "$(OUTDIR)\apr-1.lib" - -@erase ".\include\apr.h" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "NDEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "WINNT" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(OUTDIR)\apr-1" /FD /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -RSC=rc.exe -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\apr.bsc" -BSC32_SBRS= \ - -LIB32=link.exe -lib -LIB32_FLAGS=/nologo /out:"$(OUTDIR)\apr-1.lib" -LIB32_OBJS= \ - "$(INTDIR)\apr_atomic.obj" \ - "$(INTDIR)\dso.obj" \ - "$(INTDIR)\buffer.obj" \ - "$(INTDIR)\copy.obj" \ - "$(INTDIR)\dir.obj" \ - "$(INTDIR)\fileacc.obj" \ - "$(INTDIR)\filedup.obj" \ - "$(INTDIR)\filepath.obj" \ - "$(INTDIR)\filepath_util.obj" \ - "$(INTDIR)\filestat.obj" \ - "$(INTDIR)\filesys.obj" \ - "$(INTDIR)\flock.obj" \ - "$(INTDIR)\fullrw.obj" \ - "$(INTDIR)\mktemp.obj" \ - "$(INTDIR)\open.obj" \ - "$(INTDIR)\pipe.obj" \ - "$(INTDIR)\readwrite.obj" \ - "$(INTDIR)\seek.obj" \ - "$(INTDIR)\tempdir.obj" \ - "$(INTDIR)\proc_mutex.obj" \ - "$(INTDIR)\thread_cond.obj" \ - "$(INTDIR)\thread_mutex.obj" \ - "$(INTDIR)\thread_rwlock.obj" \ - "$(INTDIR)\apr_pools.obj" \ - "$(INTDIR)\charset.obj" \ - "$(INTDIR)\env.obj" \ - "$(INTDIR)\errorcodes.obj" \ - "$(INTDIR)\getopt.obj" \ - "$(INTDIR)\internal.obj" \ - "$(INTDIR)\misc.obj" \ - "$(INTDIR)\otherchild.obj" \ - "$(INTDIR)\rand.obj" \ - "$(INTDIR)\start.obj" \ - "$(INTDIR)\utf8.obj" \ - "$(INTDIR)\version.obj" \ - "$(INTDIR)\common.obj" \ - "$(INTDIR)\mmap.obj" \ - "$(INTDIR)\inet_ntop.obj" \ - "$(INTDIR)\inet_pton.obj" \ - "$(INTDIR)\multicast.obj" \ - "$(INTDIR)\sendrecv.obj" \ - "$(INTDIR)\sockaddr.obj" \ - "$(INTDIR)\sockets.obj" \ - "$(INTDIR)\socket_util.obj" \ - "$(INTDIR)\sockopt.obj" \ - "$(INTDIR)\apr_getpass.obj" \ - "$(INTDIR)\poll.obj" \ - "$(INTDIR)\pollcb.obj" \ - "$(INTDIR)\pollset.obj" \ - "$(INTDIR)\select.obj" \ - "$(INTDIR)\apr_random.obj" \ - "$(INTDIR)\sha2.obj" \ - "$(INTDIR)\sha2_glue.obj" \ - "$(INTDIR)\shm.obj" \ - "$(INTDIR)\apr_cpystrn.obj" \ - "$(INTDIR)\apr_fnmatch.obj" \ - "$(INTDIR)\apr_snprintf.obj" \ - "$(INTDIR)\apr_strings.obj" \ - "$(INTDIR)\apr_strnatcmp.obj" \ - "$(INTDIR)\apr_strtok.obj" \ - "$(INTDIR)\apr_hash.obj" \ - "$(INTDIR)\apr_tables.obj" \ - "$(INTDIR)\proc.obj" \ - "$(INTDIR)\signals.obj" \ - "$(INTDIR)\thread.obj" \ - "$(INTDIR)\threadpriv.obj" \ - "$(INTDIR)\time.obj" \ - "$(INTDIR)\timestr.obj" \ - "$(INTDIR)\groupinfo.obj" \ - "$(INTDIR)\userinfo.obj" - -"$(OUTDIR)\apr-1.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) - $(LIB32) @<< - $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) -<< - -!ELSEIF "$(CFG)" == "apr - x64 Debug" - -OUTDIR=.\x64\LibD -INTDIR=.\x64\LibD -# Begin Custom Macros -OutDir=.\x64\LibD -# End Custom Macros - -ALL : ".\include\apr.h" "$(OUTDIR)\apr-1.lib" - - -CLEAN : - -@erase "$(INTDIR)\apr-1.idb" - -@erase "$(INTDIR)\apr-1.pdb" - -@erase "$(INTDIR)\apr_atomic.obj" - -@erase "$(INTDIR)\apr_cpystrn.obj" - -@erase "$(INTDIR)\apr_fnmatch.obj" - -@erase "$(INTDIR)\apr_getpass.obj" - -@erase "$(INTDIR)\apr_hash.obj" - -@erase "$(INTDIR)\apr_pools.obj" - -@erase "$(INTDIR)\apr_random.obj" - -@erase "$(INTDIR)\apr_snprintf.obj" - -@erase "$(INTDIR)\apr_strings.obj" - -@erase "$(INTDIR)\apr_strnatcmp.obj" - -@erase "$(INTDIR)\apr_strtok.obj" - -@erase "$(INTDIR)\apr_tables.obj" - -@erase "$(INTDIR)\buffer.obj" - -@erase "$(INTDIR)\charset.obj" - -@erase "$(INTDIR)\common.obj" - -@erase "$(INTDIR)\copy.obj" - -@erase "$(INTDIR)\dir.obj" - -@erase "$(INTDIR)\dso.obj" - -@erase "$(INTDIR)\env.obj" - -@erase "$(INTDIR)\errorcodes.obj" - -@erase "$(INTDIR)\fileacc.obj" - -@erase "$(INTDIR)\filedup.obj" - -@erase "$(INTDIR)\filepath.obj" - -@erase "$(INTDIR)\filepath_util.obj" - -@erase "$(INTDIR)\filestat.obj" - -@erase "$(INTDIR)\filesys.obj" - -@erase "$(INTDIR)\flock.obj" - -@erase "$(INTDIR)\fullrw.obj" - -@erase "$(INTDIR)\getopt.obj" - -@erase "$(INTDIR)\groupinfo.obj" - -@erase "$(INTDIR)\inet_ntop.obj" - -@erase "$(INTDIR)\inet_pton.obj" - -@erase "$(INTDIR)\internal.obj" - -@erase "$(INTDIR)\misc.obj" - -@erase "$(INTDIR)\mktemp.obj" - -@erase "$(INTDIR)\mmap.obj" - -@erase "$(INTDIR)\multicast.obj" - -@erase "$(INTDIR)\open.obj" - -@erase "$(INTDIR)\otherchild.obj" - -@erase "$(INTDIR)\pipe.obj" - -@erase "$(INTDIR)\poll.obj" - -@erase "$(INTDIR)\pollcb.obj" - -@erase "$(INTDIR)\pollset.obj" - -@erase "$(INTDIR)\proc.obj" - -@erase "$(INTDIR)\proc_mutex.obj" - -@erase "$(INTDIR)\rand.obj" - -@erase "$(INTDIR)\readwrite.obj" - -@erase "$(INTDIR)\seek.obj" - -@erase "$(INTDIR)\select.obj" - -@erase "$(INTDIR)\sendrecv.obj" - -@erase "$(INTDIR)\sha2.obj" - -@erase "$(INTDIR)\sha2_glue.obj" - -@erase "$(INTDIR)\shm.obj" - -@erase "$(INTDIR)\signals.obj" - -@erase "$(INTDIR)\sockaddr.obj" - -@erase "$(INTDIR)\socket_util.obj" - -@erase "$(INTDIR)\sockets.obj" - -@erase "$(INTDIR)\sockopt.obj" - -@erase "$(INTDIR)\start.obj" - -@erase "$(INTDIR)\tempdir.obj" - -@erase "$(INTDIR)\thread.obj" - -@erase "$(INTDIR)\thread_cond.obj" - -@erase "$(INTDIR)\thread_mutex.obj" - -@erase "$(INTDIR)\thread_rwlock.obj" - -@erase "$(INTDIR)\threadpriv.obj" - -@erase "$(INTDIR)\time.obj" - -@erase "$(INTDIR)\timestr.obj" - -@erase "$(INTDIR)\userinfo.obj" - -@erase "$(INTDIR)\utf8.obj" - -@erase "$(INTDIR)\version.obj" - -@erase "$(OUTDIR)\apr-1.lib" - -@erase ".\include\apr.h" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "_DEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "WINNT" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(OUTDIR)\apr-1" /FD /EHsc /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -RSC=rc.exe -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\apr.bsc" -BSC32_SBRS= \ - -LIB32=link.exe -lib -LIB32_FLAGS=/nologo /out:"$(OUTDIR)\apr-1.lib" -LIB32_OBJS= \ - "$(INTDIR)\apr_atomic.obj" \ - "$(INTDIR)\dso.obj" \ - "$(INTDIR)\buffer.obj" \ - "$(INTDIR)\copy.obj" \ - "$(INTDIR)\dir.obj" \ - "$(INTDIR)\fileacc.obj" \ - "$(INTDIR)\filedup.obj" \ - "$(INTDIR)\filepath.obj" \ - "$(INTDIR)\filepath_util.obj" \ - "$(INTDIR)\filestat.obj" \ - "$(INTDIR)\filesys.obj" \ - "$(INTDIR)\flock.obj" \ - "$(INTDIR)\fullrw.obj" \ - "$(INTDIR)\mktemp.obj" \ - "$(INTDIR)\open.obj" \ - "$(INTDIR)\pipe.obj" \ - "$(INTDIR)\readwrite.obj" \ - "$(INTDIR)\seek.obj" \ - "$(INTDIR)\tempdir.obj" \ - "$(INTDIR)\proc_mutex.obj" \ - "$(INTDIR)\thread_cond.obj" \ - "$(INTDIR)\thread_mutex.obj" \ - "$(INTDIR)\thread_rwlock.obj" \ - "$(INTDIR)\apr_pools.obj" \ - "$(INTDIR)\charset.obj" \ - "$(INTDIR)\env.obj" \ - "$(INTDIR)\errorcodes.obj" \ - "$(INTDIR)\getopt.obj" \ - "$(INTDIR)\internal.obj" \ - "$(INTDIR)\misc.obj" \ - "$(INTDIR)\otherchild.obj" \ - "$(INTDIR)\rand.obj" \ - "$(INTDIR)\start.obj" \ - "$(INTDIR)\utf8.obj" \ - "$(INTDIR)\version.obj" \ - "$(INTDIR)\common.obj" \ - "$(INTDIR)\mmap.obj" \ - "$(INTDIR)\inet_ntop.obj" \ - "$(INTDIR)\inet_pton.obj" \ - "$(INTDIR)\multicast.obj" \ - "$(INTDIR)\sendrecv.obj" \ - "$(INTDIR)\sockaddr.obj" \ - "$(INTDIR)\sockets.obj" \ - "$(INTDIR)\socket_util.obj" \ - "$(INTDIR)\sockopt.obj" \ - "$(INTDIR)\apr_getpass.obj" \ - "$(INTDIR)\poll.obj" \ - "$(INTDIR)\pollcb.obj" \ - "$(INTDIR)\pollset.obj" \ - "$(INTDIR)\select.obj" \ - "$(INTDIR)\apr_random.obj" \ - "$(INTDIR)\sha2.obj" \ - "$(INTDIR)\sha2_glue.obj" \ - "$(INTDIR)\shm.obj" \ - "$(INTDIR)\apr_cpystrn.obj" \ - "$(INTDIR)\apr_fnmatch.obj" \ - "$(INTDIR)\apr_snprintf.obj" \ - "$(INTDIR)\apr_strings.obj" \ - "$(INTDIR)\apr_strnatcmp.obj" \ - "$(INTDIR)\apr_strtok.obj" \ - "$(INTDIR)\apr_hash.obj" \ - "$(INTDIR)\apr_tables.obj" \ - "$(INTDIR)\proc.obj" \ - "$(INTDIR)\signals.obj" \ - "$(INTDIR)\thread.obj" \ - "$(INTDIR)\threadpriv.obj" \ - "$(INTDIR)\time.obj" \ - "$(INTDIR)\timestr.obj" \ - "$(INTDIR)\groupinfo.obj" \ - "$(INTDIR)\userinfo.obj" - -"$(OUTDIR)\apr-1.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) - $(LIB32) @<< - $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) -<< - -!ENDIF - - -!IF "$(NO_EXTERNAL_DEPS)" != "1" -!IF EXISTS("apr.dep") -!INCLUDE "apr.dep" -!ELSE -!MESSAGE Warning: cannot find "apr.dep" -!ENDIF -!ENDIF - - -!IF "$(CFG)" == "apr - Win32 Release" || "$(CFG)" == "apr - Win32 Debug" || "$(CFG)" == "apr - Win32 Release9x" || "$(CFG)" == "apr - Win32 Debug9x" || "$(CFG)" == "apr - x64 Release" || "$(CFG)" == "apr - x64 Debug" -SOURCE=.\atomic\win32\apr_atomic.c - -"$(INTDIR)\apr_atomic.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\dso\win32\dso.c - -"$(INTDIR)\dso.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\win32\buffer.c - -"$(INTDIR)\buffer.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\unix\copy.c - -"$(INTDIR)\copy.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\win32\dir.c - -"$(INTDIR)\dir.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\unix\fileacc.c - -"$(INTDIR)\fileacc.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\win32\filedup.c - -"$(INTDIR)\filedup.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\win32\filepath.c - -"$(INTDIR)\filepath.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\unix\filepath_util.c - -"$(INTDIR)\filepath_util.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\win32\filestat.c - -"$(INTDIR)\filestat.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\win32\filesys.c - -"$(INTDIR)\filesys.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\win32\flock.c - -"$(INTDIR)\flock.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\unix\fullrw.c - -"$(INTDIR)\fullrw.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\unix\mktemp.c - -"$(INTDIR)\mktemp.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\win32\open.c - -"$(INTDIR)\open.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\win32\pipe.c - -"$(INTDIR)\pipe.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\win32\readwrite.c - -"$(INTDIR)\readwrite.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\win32\seek.c - -"$(INTDIR)\seek.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\unix\tempdir.c - -"$(INTDIR)\tempdir.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\locks\win32\proc_mutex.c - -"$(INTDIR)\proc_mutex.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\locks\win32\thread_cond.c - -"$(INTDIR)\thread_cond.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\locks\win32\thread_mutex.c - -"$(INTDIR)\thread_mutex.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\locks\win32\thread_rwlock.c - -"$(INTDIR)\thread_rwlock.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\memory\unix\apr_pools.c - -"$(INTDIR)\apr_pools.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\misc\win32\apr_app.c -SOURCE=.\misc\win32\charset.c - -"$(INTDIR)\charset.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\misc\win32\env.c - -"$(INTDIR)\env.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\misc\unix\errorcodes.c - -"$(INTDIR)\errorcodes.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\misc\unix\getopt.c - -"$(INTDIR)\getopt.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\misc\win32\internal.c - -"$(INTDIR)\internal.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\misc\win32\misc.c - -"$(INTDIR)\misc.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\misc\unix\otherchild.c - -"$(INTDIR)\otherchild.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\misc\win32\rand.c - -"$(INTDIR)\rand.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\misc\win32\start.c - -"$(INTDIR)\start.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\misc\win32\utf8.c - -"$(INTDIR)\utf8.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\misc\unix\version.c - -"$(INTDIR)\version.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\mmap\unix\common.c - -"$(INTDIR)\common.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\mmap\win32\mmap.c - -"$(INTDIR)\mmap.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\network_io\unix\inet_ntop.c - -"$(INTDIR)\inet_ntop.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\network_io\unix\inet_pton.c - -"$(INTDIR)\inet_pton.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\network_io\unix\multicast.c - -"$(INTDIR)\multicast.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\network_io\win32\sendrecv.c - -"$(INTDIR)\sendrecv.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\network_io\unix\sockaddr.c - -"$(INTDIR)\sockaddr.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\network_io\unix\socket_util.c - -"$(INTDIR)\socket_util.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\network_io\win32\sockets.c - -"$(INTDIR)\sockets.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\network_io\win32\sockopt.c - -"$(INTDIR)\sockopt.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\passwd\apr_getpass.c - -"$(INTDIR)\apr_getpass.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\poll\unix\poll.c - -"$(INTDIR)\poll.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\poll\unix\pollcb.c - -"$(INTDIR)\pollcb.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\poll\unix\pollset.c - -"$(INTDIR)\pollset.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\poll\unix\select.c - -"$(INTDIR)\select.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\random\unix\apr_random.c - -"$(INTDIR)\apr_random.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\random\unix\sha2.c - -"$(INTDIR)\sha2.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\random\unix\sha2_glue.c - -"$(INTDIR)\sha2_glue.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\shmem\win32\shm.c - -"$(INTDIR)\shm.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\strings\apr_cpystrn.c - -"$(INTDIR)\apr_cpystrn.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\strings\apr_fnmatch.c - -"$(INTDIR)\apr_fnmatch.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\strings\apr_snprintf.c - -"$(INTDIR)\apr_snprintf.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\strings\apr_strings.c - -"$(INTDIR)\apr_strings.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\strings\apr_strnatcmp.c - -"$(INTDIR)\apr_strnatcmp.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\strings\apr_strtok.c - -"$(INTDIR)\apr_strtok.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\tables\apr_hash.c - -"$(INTDIR)\apr_hash.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\tables\apr_tables.c - -"$(INTDIR)\apr_tables.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\threadproc\win32\proc.c - -"$(INTDIR)\proc.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\threadproc\win32\signals.c - -"$(INTDIR)\signals.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\threadproc\win32\thread.c - -"$(INTDIR)\thread.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\threadproc\win32\threadpriv.c - -"$(INTDIR)\threadpriv.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\time\win32\time.c - -"$(INTDIR)\time.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\time\win32\timestr.c - -"$(INTDIR)\timestr.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\user\win32\groupinfo.c - -"$(INTDIR)\groupinfo.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\user\win32\userinfo.c - -"$(INTDIR)\userinfo.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\include\apr.hw - -!IF "$(CFG)" == "apr - Win32 Release" - -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - < .\include\apr.h -<< - - -!ELSEIF "$(CFG)" == "apr - Win32 Debug" - -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - < .\include\apr.h -<< - - -!ELSEIF "$(CFG)" == "apr - Win32 Release9x" - -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - < .\include\apr.h -<< - - -!ELSEIF "$(CFG)" == "apr - Win32 Debug9x" - -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - < .\include\apr.h -<< - - -!ELSEIF "$(CFG)" == "apr - x64 Release" - -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - < .\include\apr.h -<< - - -!ELSEIF "$(CFG)" == "apr - x64 Debug" - -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - < .\include\apr.h -<< - - -!ENDIF - - -!ENDIF - diff --git a/libs/apr/apr.pc.in b/libs/apr/apr.pc.in deleted file mode 100644 index 318a81e2..00000000 --- a/libs/apr/apr.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -APR_MAJOR_VERSION=@APR_MAJOR_VERSION@ -includedir=@includedir@ - -Name: APR -Description: The Apache Portable Runtime library -Version: @APR_DOTTED_VERSION@ -Libs: -L${libdir} -l@APR_LIBNAME@ @EXTRA_LIBS@ -Cflags: @EXTRA_CPPFLAGS@ @EXTRA_CFLAGS@ -I${includedir} diff --git a/libs/apr/apr.spec b/libs/apr/apr.spec deleted file mode 100644 index abecbdfd..00000000 --- a/libs/apr/apr.spec +++ /dev/null @@ -1,100 +0,0 @@ - -%define aprver 1 - -Summary: Apache Portable Runtime library -Name: apr -Version: 1.4.6 -Release: 1 -License: Apache Software License -Group: System Environment/Libraries -URL: http://apr.apache.org/ -Source0: http://www.apache.org/dist/apr/%{name}-%{version}.tar.bz2 -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot -BuildRequires: autoconf, libtool, doxygen, python - -%description -The mission of the Apache Portable Runtime (APR) is to provide a -free library of C data structures and routines, forming a system -portability layer to as many operating systems as possible, -including Unices, MS Win32, BeOS and OS/2. - -%package devel -Group: Development/Libraries -Summary: APR library development kit -Requires: apr = %{version} - -%description devel -This package provides the support files which can be used to -build applications using the APR library. The mission of the -Apache Portable Runtime (APR) is to provide a free library of -C data structures and routines. - -%prep -%setup -q - -%build -# regenerate configure script etc. -./buildconf -%configure \ - --prefix=/usr \ - --includedir=%{_includedir}/apr-%{aprver} \ - --with-installbuilddir=%{_libdir}/apr/build-%{aprver} \ - --with-devrandom=/dev/urandom \ - CC=gcc CXX=g++ -make %{?_smp_mflags} && make dox - -%check -# Run non-interactive tests -pushd test -make %{?_smp_mflags} all CFLAGS=-fno-strict-aliasing -make check || exit 1 -popd - -%install -rm -rf $RPM_BUILD_ROOT -make install DESTDIR=$RPM_BUILD_ROOT - -# Move docs to more convenient location -mv docs/dox/html html - -# Unpackaged files: -rm -f $RPM_BUILD_ROOT%{_libdir}/apr.exp - -%clean -rm -rf $RPM_BUILD_ROOT - -%post -p /sbin/ldconfig - -%postun -p /sbin/ldconfig - -%files -%defattr(-,root,root,-) -%doc CHANGES LICENSE NOTICE -%{_libdir}/libapr-%{aprver}.so.* - -%files devel -%defattr(-,root,root,-) -%doc docs/APRDesign.html docs/canonical_filenames.html -%doc docs/incomplete_types docs/non_apr_programs -%doc --parents html -%{_bindir}/apr*config -%{_libdir}/libapr-%{aprver}.*a -%{_libdir}/libapr-%{aprver}.so -%dir %{_libdir}/apr -%dir %{_libdir}/apr/build-%{aprver} -%{_libdir}/apr/build-%{aprver}/* -%{_libdir}/pkgconfig/apr-%{aprver}.pc -%dir %{_includedir}/apr-%{aprver} -%{_includedir}/apr-%{aprver}/*.h - -%changelog -* Sat Aug 30 2008 Graham Leggett 1.3.3 -- update to depend on the bzip2 binary -- build depends on python - -* Tue Jun 22 2004 Graham Leggett 1.0.0-1 -- update to support v1.0.0 of APR - -* Tue Jun 22 2004 Graham Leggett 1.0.0-1 -- derived from Fedora Core apr.spec - diff --git a/libs/apr/atomic/netware/apr_atomic.c b/libs/apr/atomic/netware/apr_atomic.c deleted file mode 100644 index b5d965b0..00000000 --- a/libs/apr/atomic/netware/apr_atomic.c +++ /dev/null @@ -1,75 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_atomic.h" - -#include - -APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *pool) -{ - return APR_SUCCESS; -} - -APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - return atomic_xchgadd((unsigned long *)mem,(unsigned long)val); -} - -APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - atomic_sub((unsigned long *)mem,(unsigned long)val); -} - -APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem) -{ - return atomic_xchgadd((unsigned long *)mem, 1); -} - -APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - *mem = val; -} - -APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem) -{ - return *mem; -} - -APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with,apr_uint32_t cmp) -{ - return atomic_cmpxchg((unsigned long *)mem,(unsigned long)cmp,(unsigned long)with); -} - -APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - return atomic_xchg((unsigned long *)mem,(unsigned long)val); -} - -APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem) -{ - return (atomic_xchgadd((unsigned long *)mem, 0xFFFFFFFF) - 1); -} - -APR_DECLARE(void *) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp) -{ - return (void*)atomic_cmpxchg((unsigned long *)mem,(unsigned long)cmp,(unsigned long)with); -} - -APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem, void *with) -{ - return (void*)atomic_xchg((unsigned long *)mem,(unsigned long)with); -} diff --git a/libs/apr/atomic/os390/atomic.c b/libs/apr/atomic/os390/atomic.c deleted file mode 100644 index 1d44ca3d..00000000 --- a/libs/apr/atomic/os390/atomic.c +++ /dev/null @@ -1,137 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include "apr.h" -#include "apr_atomic.h" - -#include - -apr_status_t apr_atomic_init(apr_pool_t *p) -{ - return APR_SUCCESS; -} - -apr_uint32_t apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - apr_uint32_t old, new_val; - - old = *mem; /* old is automatically updated on cs failure */ - do { - new_val = old + val; - } while (__cs(&old, (cs_t *)mem, new_val)); - return old; -} - -void apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - apr_uint32_t old, new_val; - - old = *mem; /* old is automatically updated on cs failure */ - do { - new_val = old - val; - } while (__cs(&old, (cs_t *)mem, new_val)); -} - -apr_uint32_t apr_atomic_inc32(volatile apr_uint32_t *mem) -{ - return apr_atomic_add32(mem, 1); -} - -int apr_atomic_dec32(volatile apr_uint32_t *mem) -{ - apr_uint32_t old, new_val; - - old = *mem; /* old is automatically updated on cs failure */ - do { - new_val = old - 1; - } while (__cs(&old, (cs_t *)mem, new_val)); - - return new_val != 0; -} - -apr_uint32_t apr_atomic_read32(volatile apr_uint32_t *mem) -{ - return *mem; -} - -void apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - *mem = val; -} - -apr_uint32_t apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t swap, - apr_uint32_t cmp) -{ - apr_uint32_t old = cmp; - - __cs(&old, (cs_t *)mem, swap); - return old; /* old is automatically updated from mem on cs failure */ -} - -#if APR_SIZEOF_VOIDP == 4 -void *apr_atomic_casptr(volatile void **mem_ptr, - void *swap_ptr, - const void *cmp_ptr) -{ - __cs1(&cmp_ptr, /* automatically updated from mem on __cs1 failure */ - mem_ptr, /* set from swap when __cs1 succeeds */ - &swap_ptr); - return (void *)cmp_ptr; -} -#elif APR_SIZEOF_VOIDP == 8 -void *apr_atomic_casptr(volatile void **mem_ptr, - void *swap_ptr, - const void *cmp_ptr) -{ - __csg(&cmp_ptr, /* automatically updated from mem on __csg failure */ - mem_ptr, /* set from swap when __csg succeeds */ - &swap_ptr); - return (void *)cmp_ptr; -} -#else -#error APR_SIZEOF_VOIDP value not supported -#endif /* APR_SIZEOF_VOIDP */ - -apr_uint32_t apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - apr_uint32_t old, new_val; - - old = *mem; /* old is automatically updated on cs failure */ - do { - new_val = val; - } while (__cs(&old, (cs_t *)mem, new_val)); - - return old; -} - -APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem_ptr, void *new_ptr) -{ - void *old_ptr; - - old_ptr = *(void **)mem_ptr; /* old is automatically updated on cs failure */ -#if APR_SIZEOF_VOIDP == 4 - do { - } while (__cs1(&old_ptr, mem_ptr, &new_ptr)); -#elif APR_SIZEOF_VOIDP == 8 - do { - } while (__csg(&old_ptr, mem_ptr, &new_ptr)); -#else -#error APR_SIZEOF_VOIDP value not supported -#endif /* APR_SIZEOF_VOIDP */ - - return old_ptr; -} diff --git a/libs/apr/atomic/unix/builtins.c b/libs/apr/atomic/unix/builtins.c deleted file mode 100644 index 745acf15..00000000 --- a/libs/apr/atomic/unix/builtins.c +++ /dev/null @@ -1,81 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_atomic.h" - -#ifdef USE_ATOMICS_BUILTINS - -APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p) -{ - return APR_SUCCESS; -} - -APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem) -{ - return *mem; -} - -APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - *mem = val; -} - -APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - return __sync_fetch_and_add(mem, val); -} - -APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - __sync_fetch_and_sub(mem, val); -} - -APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem) -{ - return __sync_fetch_and_add(mem, 1); -} - -APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem) -{ - return __sync_sub_and_fetch(mem, 1); -} - -APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with, - apr_uint32_t cmp) -{ - return __sync_val_compare_and_swap(mem, cmp, with); -} - -APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - __sync_synchronize(); - - return __sync_lock_test_and_set(mem, val); -} - -APR_DECLARE(void*) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp) -{ - return (void*) __sync_val_compare_and_swap(mem, cmp, with); -} - -APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem, void *with) -{ - __sync_synchronize(); - - return (void*) __sync_lock_test_and_set(mem, with); -} - -#endif /* USE_ATOMICS_BUILTINS */ diff --git a/libs/apr/atomic/unix/ia32.c b/libs/apr/atomic/unix/ia32.c deleted file mode 100644 index 3826f927..00000000 --- a/libs/apr/atomic/unix/ia32.c +++ /dev/null @@ -1,127 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_atomic.h" - -#ifdef USE_ATOMICS_IA32 - -APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p) -{ - return APR_SUCCESS; -} - -APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem) -{ - return *mem; -} - -APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - *mem = val; -} - -APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - asm volatile ("lock; xaddl %0,%1" - : "=r" (val), "=m" (*mem) - : "0" (val), "m" (*mem) - : "memory", "cc"); - return val; -} - -APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - asm volatile ("lock; subl %1, %0" - : /* no output */ - : "m" (*(mem)), "r" (val) - : "memory", "cc"); -} - -APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem) -{ - return apr_atomic_add32(mem, 1); -} - -APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem) -{ - unsigned char prev; - - asm volatile ("lock; decl %0; setnz %1" - : "=m" (*mem), "=qm" (prev) - : "m" (*mem) - : "memory"); - - return prev; -} - -APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with, - apr_uint32_t cmp) -{ - apr_uint32_t prev; - - asm volatile ("lock; cmpxchgl %1, %2" - : "=a" (prev) - : "r" (with), "m" (*(mem)), "0"(cmp) - : "memory", "cc"); - return prev; -} - -APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - apr_uint32_t prev = val; - - asm volatile ("xchgl %0, %1" - : "=r" (prev), "+m" (*mem) - : "0" (prev)); - return prev; -} - -APR_DECLARE(void*) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp) -{ - void *prev; -#if APR_SIZEOF_VOIDP == 4 - asm volatile ("lock; cmpxchgl %2, %1" - : "=a" (prev), "=m" (*mem) - : "r" (with), "m" (*mem), "0" (cmp)); -#elif APR_SIZEOF_VOIDP == 8 - asm volatile ("lock; cmpxchgq %q2, %1" - : "=a" (prev), "=m" (*mem) - : "r" ((unsigned long)with), "m" (*mem), - "0" ((unsigned long)cmp)); -#else -#error APR_SIZEOF_VOIDP value not supported -#endif - return prev; -} - -APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem, void *with) -{ - void *prev; -#if APR_SIZEOF_VOIDP == 4 - asm volatile ("xchgl %2, %1" - : "=a" (prev), "+m" (*mem) - : "0" (with)); -#elif APR_SIZEOF_VOIDP == 8 - asm volatile ("xchgq %q2, %1" - : "=a" (prev), "+m" (*mem) - : "r" ((unsigned long)with)); -#else -#error APR_SIZEOF_VOIDP value not supported -#endif - return prev; -} - -#endif /* USE_ATOMICS_IA32 */ diff --git a/libs/apr/atomic/unix/mutex.c b/libs/apr/atomic/unix/mutex.c deleted file mode 100644 index fba3be2b..00000000 --- a/libs/apr/atomic/unix/mutex.c +++ /dev/null @@ -1,205 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_atomic.h" - -#ifdef USE_ATOMICS_GENERIC - -#include - -#if APR_HAS_THREADS -# define DECLARE_MUTEX_LOCKED(name, mem) \ - apr_thread_mutex_t *name = mutex_hash(mem) -# define MUTEX_UNLOCK(name) \ - do { \ - if (apr_thread_mutex_unlock(name) != APR_SUCCESS) \ - abort(); \ - } while (0) -#else -# define DECLARE_MUTEX_LOCKED(name, mem) -# define MUTEX_UNLOCK(name) -# warning Be warned: using stubs for all atomic operations -#endif - -#if APR_HAS_THREADS - -static apr_thread_mutex_t **hash_mutex; - -#define NUM_ATOMIC_HASH 7 -/* shift by 2 to get rid of alignment issues */ -#define ATOMIC_HASH(x) (unsigned int)(((unsigned long)(x)>>2)%(unsigned int)NUM_ATOMIC_HASH) - -static apr_status_t atomic_cleanup(void *data) -{ - if (hash_mutex == data) - hash_mutex = NULL; - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p) -{ - int i; - apr_status_t rv; - - if (hash_mutex != NULL) - return APR_SUCCESS; - - hash_mutex = apr_palloc(p, sizeof(apr_thread_mutex_t*) * NUM_ATOMIC_HASH); - apr_pool_cleanup_register(p, hash_mutex, atomic_cleanup, - apr_pool_cleanup_null); - - for (i = 0; i < NUM_ATOMIC_HASH; i++) { - rv = apr_thread_mutex_create(&(hash_mutex[i]), - APR_THREAD_MUTEX_DEFAULT, p); - if (rv != APR_SUCCESS) { - return rv; - } - } - - return APR_SUCCESS; -} - -static APR_INLINE apr_thread_mutex_t *mutex_hash(volatile apr_uint32_t *mem) -{ - apr_thread_mutex_t *mutex = hash_mutex[ATOMIC_HASH(mem)]; - - if (apr_thread_mutex_lock(mutex) != APR_SUCCESS) { - abort(); - } - - return mutex; -} - -#else - -APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p) -{ - return APR_SUCCESS; -} - -#endif /* APR_HAS_THREADS */ - -APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem) -{ - return *mem; -} - -APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - DECLARE_MUTEX_LOCKED(mutex, mem); - - *mem = val; - - MUTEX_UNLOCK(mutex); -} - -APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - apr_uint32_t old_value; - DECLARE_MUTEX_LOCKED(mutex, mem); - - old_value = *mem; - *mem += val; - - MUTEX_UNLOCK(mutex); - - return old_value; -} - -APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - DECLARE_MUTEX_LOCKED(mutex, mem); - *mem -= val; - MUTEX_UNLOCK(mutex); -} - -APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem) -{ - return apr_atomic_add32(mem, 1); -} - -APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem) -{ - apr_uint32_t new; - DECLARE_MUTEX_LOCKED(mutex, mem); - - (*mem)--; - new = *mem; - - MUTEX_UNLOCK(mutex); - - return new; -} - -APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with, - apr_uint32_t cmp) -{ - apr_uint32_t prev; - DECLARE_MUTEX_LOCKED(mutex, mem); - - prev = *mem; - if (prev == cmp) { - *mem = with; - } - - MUTEX_UNLOCK(mutex); - - return prev; -} - -APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - apr_uint32_t prev; - DECLARE_MUTEX_LOCKED(mutex, mem); - - prev = *mem; - *mem = val; - - MUTEX_UNLOCK(mutex); - - return prev; -} - -APR_DECLARE(void*) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp) -{ - void *prev; - DECLARE_MUTEX_LOCKED(mutex, *mem); - - prev = *(void **)mem; - if (prev == cmp) { - *mem = with; - } - - MUTEX_UNLOCK(mutex); - - return prev; -} - -APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem, void *with) -{ - void *prev; - DECLARE_MUTEX_LOCKED(mutex, *mem); - - prev = *(void **)mem; - *mem = with; - - MUTEX_UNLOCK(mutex); - - return prev; -} - -#endif /* USE_ATOMICS_GENERIC */ diff --git a/libs/apr/atomic/unix/ppc.c b/libs/apr/atomic/unix/ppc.c deleted file mode 100644 index db9fca93..00000000 --- a/libs/apr/atomic/unix/ppc.c +++ /dev/null @@ -1,207 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_atomic.h" - -#ifdef USE_ATOMICS_PPC - -#ifdef PPC405_ERRATA -# define PPC405_ERR77_SYNC " sync\n" -#else -# define PPC405_ERR77_SYNC -#endif - -APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p) -{ - return APR_SUCCESS; -} - -APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem) -{ - return *mem; -} - -APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - *mem = val; -} - -APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - apr_uint32_t prev, temp; - - asm volatile ("loop_%=:\n" /* lost reservation */ - " lwarx %0,0,%3\n" /* load and reserve */ - " add %1,%0,%4\n" /* add val and prev */ - PPC405_ERR77_SYNC /* ppc405 Erratum 77 */ - " stwcx. %1,0,%3\n" /* store new value */ - " bne- loop_%=\n" /* loop if lost */ - : "=&r" (prev), "=&r" (temp), "=m" (*mem) - : "b" (mem), "r" (val) - : "cc", "memory"); - - return prev; -} - -APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - apr_uint32_t temp; - - asm volatile ("loop_%=:\n" /* lost reservation */ - " lwarx %0,0,%2\n" /* load and reserve */ - " subf %0,%3,%0\n" /* subtract val */ - PPC405_ERR77_SYNC /* ppc405 Erratum 77 */ - " stwcx. %0,0,%2\n" /* store new value */ - " bne- loop_%=\n" /* loop if lost */ - : "=&r" (temp), "=m" (*mem) - : "b" (mem), "r" (val) - : "cc", "memory"); -} - -APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem) -{ - apr_uint32_t prev; - - asm volatile ("loop_%=:\n" /* lost reservation */ - " lwarx %0,0,%2\n" /* load and reserve */ - " addi %0,%0,1\n" /* add immediate */ - PPC405_ERR77_SYNC /* ppc405 Erratum 77 */ - " stwcx. %0,0,%2\n" /* store new value */ - " bne- loop_%=\n" /* loop if lost */ - " subi %0,%0,1\n" /* return old value */ - : "=&b" (prev), "=m" (*mem) - : "b" (mem), "m" (*mem) - : "cc", "memory"); - - return prev; -} - -APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem) -{ - apr_uint32_t prev; - - asm volatile ("loop_%=:\n" /* lost reservation */ - " lwarx %0,0,%2\n" /* load and reserve */ - " subi %0,%0,1\n" /* subtract immediate */ - PPC405_ERR77_SYNC /* ppc405 Erratum 77 */ - " stwcx. %0,0,%2\n" /* store new value */ - " bne- loop_%=\n" /* loop if lost */ - : "=&b" (prev), "=m" (*mem) - : "b" (mem), "m" (*mem) - : "cc", "memory"); - - return prev; -} - -APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with, - apr_uint32_t cmp) -{ - apr_uint32_t prev; - - asm volatile ("loop_%=:\n" /* lost reservation */ - " lwarx %0,0,%1\n" /* load and reserve */ - " cmpw %0,%3\n" /* compare operands */ - " bne- exit_%=\n" /* skip if not equal */ - PPC405_ERR77_SYNC /* ppc405 Erratum 77 */ - " stwcx. %2,0,%1\n" /* store new value */ - " bne- loop_%=\n" /* loop if lost */ - "exit_%=:\n" /* not equal */ - : "=&r" (prev) - : "b" (mem), "r" (with), "r" (cmp) - : "cc", "memory"); - - return prev; -} - -APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - apr_uint32_t prev; - - asm volatile ("loop_%=:\n" /* lost reservation */ - " lwarx %0,0,%1\n" /* load and reserve */ - PPC405_ERR77_SYNC /* ppc405 Erratum 77 */ - " stwcx. %2,0,%1\n" /* store new value */ - " bne- loop_%=" /* loop if lost */ - : "=&r" (prev) - : "b" (mem), "r" (val) - : "cc", "memory"); - - return prev; -} - -APR_DECLARE(void*) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp) -{ - void *prev; -#if APR_SIZEOF_VOIDP == 4 - asm volatile ("loop_%=:\n" /* lost reservation */ - " lwarx %0,0,%1\n" /* load and reserve */ - " cmpw %0,%3\n" /* compare operands */ - " bne- exit_%=\n" /* skip if not equal */ - PPC405_ERR77_SYNC /* ppc405 Erratum 77 */ - " stwcx. %2,0,%1\n" /* store new value */ - " bne- loop_%=\n" /* loop if lost */ - "exit_%=:\n" /* not equal */ - : "=&r" (prev) - : "b" (mem), "r" (with), "r" (cmp) - : "cc", "memory"); -#elif APR_SIZEOF_VOIDP == 8 - asm volatile ("loop_%=:\n" /* lost reservation */ - " ldarx %0,0,%1\n" /* load and reserve */ - " cmpd %0,%3\n" /* compare operands */ - " bne- exit_%=\n" /* skip if not equal */ - PPC405_ERR77_SYNC /* ppc405 Erratum 77 */ - " stdcx. %2,0,%1\n" /* store new value */ - " bne- loop_%=\n" /* loop if lost */ - "exit_%=:\n" /* not equal */ - : "=&r" (prev) - : "b" (mem), "r" (with), "r" (cmp) - : "cc", "memory"); -#else -#error APR_SIZEOF_VOIDP value not supported -#endif - return prev; -} - -APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem, void *with) -{ - void *prev; -#if APR_SIZEOF_VOIDP == 4 - asm volatile ("loop_%=:\n" /* lost reservation */ - " lwarx %0,0,%1\n" /* load and reserve */ - PPC405_ERR77_SYNC /* ppc405 Erratum 77 */ - " stwcx. %2,0,%1\n" /* store new value */ - " bne- loop_%=\n" /* loop if lost */ - " isync\n" /* memory barrier */ - : "=&r" (prev) - : "b" (mem), "r" (with) - : "cc", "memory"); -#elif APR_SIZEOF_VOIDP == 8 - asm volatile ("loop_%=:\n" /* lost reservation */ - " ldarx %0,0,%1\n" /* load and reserve */ - PPC405_ERR77_SYNC /* ppc405 Erratum 77 */ - " stdcx. %2,0,%1\n" /* store new value */ - " bne- loop_%=\n" /* loop if lost */ - " isync\n" /* memory barrier */ - : "=&r" (prev) - : "b" (mem), "r" (with) - : "cc", "memory"); -#else -#error APR_SIZEOF_VOIDP value not supported -#endif - return prev; -} - -#endif /* USE_ATOMICS_PPC */ diff --git a/libs/apr/atomic/unix/s390.c b/libs/apr/atomic/unix/s390.c deleted file mode 100644 index 3e233207..00000000 --- a/libs/apr/atomic/unix/s390.c +++ /dev/null @@ -1,155 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_atomic.h" - -#ifdef USE_ATOMICS_S390 - -APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p) -{ - return APR_SUCCESS; -} - -APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem) -{ - return *mem; -} - -APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - *mem = val; -} - -static APR_INLINE apr_uint32_t atomic_add(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - apr_uint32_t prev = *mem, temp; - - asm volatile ("loop_%=:\n" - " lr %1,%0\n" - " alr %1,%3\n" - " cs %0,%1,%2\n" - " jl loop_%=\n" - : "+d" (prev), "+d" (temp), "=Q" (*mem) - : "d" (val), "m" (*mem) - : "cc", "memory"); - - return prev; -} - -APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - return atomic_add(mem, val); -} - -APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem) -{ - return atomic_add(mem, 1); -} - -static APR_INLINE apr_uint32_t atomic_sub(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - apr_uint32_t prev = *mem, temp; - - asm volatile ("loop_%=:\n" - " lr %1,%0\n" - " slr %1,%3\n" - " cs %0,%1,%2\n" - " jl loop_%=\n" - : "+d" (prev), "+d" (temp), "=Q" (*mem) - : "d" (val), "m" (*mem) - : "cc", "memory"); - - return temp; -} - -APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - atomic_sub(mem, val); -} - -APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem) -{ - return atomic_sub(mem, 1); -} - -APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with, - apr_uint32_t cmp) -{ - asm volatile (" cs %0,%2,%1\n" - : "+d" (cmp), "=Q" (*mem) - : "d" (with), "m" (*mem) - : "cc", "memory"); - - return cmp; -} - -APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - apr_uint32_t prev = *mem; - - asm volatile ("loop_%=:\n" - " cs %0,%2,%1\n" - " jl loop_%=\n" - : "+d" (prev), "=Q" (*mem) - : "d" (val), "m" (*mem) - : "cc", "memory"); - - return prev; -} - -APR_DECLARE(void*) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp) -{ - void *prev = (void *) cmp; -#if APR_SIZEOF_VOIDP == 4 - asm volatile (" cs %0,%2,%1\n" - : "+d" (prev), "=Q" (*mem) - : "d" (with), "m" (*mem) - : "cc", "memory"); -#elif APR_SIZEOF_VOIDP == 8 - asm volatile (" csg %0,%2,%1\n" - : "+d" (prev), "=Q" (*mem) - : "d" (with), "m" (*mem) - : "cc", "memory"); -#else -#error APR_SIZEOF_VOIDP value not supported -#endif - return prev; -} - -APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem, void *with) -{ - void *prev = (void *) *mem; -#if APR_SIZEOF_VOIDP == 4 - asm volatile ("loop_%=:\n" - " cs %0,%2,%1\n" - " jl loop_%=\n" - : "+d" (prev), "=Q" (*mem) - : "d" (with), "m" (*mem) - : "cc", "memory"); -#elif APR_SIZEOF_VOIDP == 8 - asm volatile ("loop_%=:\n" - " csg %0,%2,%1\n" - " jl loop_%=\n" - : "+d" (prev), "=Q" (*mem) - : "d" (with), "m" (*mem) - : "cc", "memory"); -#else -#error APR_SIZEOF_VOIDP value not supported -#endif - return prev; -} - -#endif /* USE_ATOMICS_S390 */ diff --git a/libs/apr/atomic/unix/solaris.c b/libs/apr/atomic/unix/solaris.c deleted file mode 100644 index 547499a5..00000000 --- a/libs/apr/atomic/unix/solaris.c +++ /dev/null @@ -1,79 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_atomic.h" - -#ifdef USE_ATOMICS_SOLARIS - -#include - -APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p) -{ - return APR_SUCCESS; -} - -APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem) -{ - return *mem; -} - -APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - *mem = val; -} - -APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - return atomic_add_32_nv(mem, val) - val; -} - -APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - atomic_add_32(mem, -val); -} - -APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem) -{ - return atomic_inc_32_nv(mem) - 1; -} - -APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem) -{ - return atomic_dec_32_nv(mem); -} - -APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with, - apr_uint32_t cmp) -{ - return atomic_cas_32(mem, cmp, with); -} - -APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ - return atomic_swap_32(mem, val); -} - -APR_DECLARE(void*) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp) -{ - return atomic_cas_ptr(mem, (void*) cmp, with); -} - -APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem, void *with) -{ - return atomic_swap_ptr(mem, with); -} - -#endif /* USE_ATOMICS_SOLARIS */ diff --git a/libs/apr/atomic/win32/apr_atomic.c b/libs/apr/atomic/win32/apr_atomic.c deleted file mode 100644 index 1ed7df89..00000000 --- a/libs/apr/atomic/win32/apr_atomic.c +++ /dev/null @@ -1,154 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_atomic.h" -#include "apr_thread_mutex.h" - -APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p) -{ - return APR_SUCCESS; -} - -/* - * Remapping function pointer type to accept apr_uint32_t's type-safely - * as the arguments for as our apr_atomic_foo32 Functions - */ -typedef WINBASEAPI apr_uint32_t (WINAPI * apr_atomic_win32_ptr_fn) - (apr_uint32_t volatile *); -typedef WINBASEAPI apr_uint32_t (WINAPI * apr_atomic_win32_ptr_val_fn) - (apr_uint32_t volatile *, - apr_uint32_t); -typedef WINBASEAPI apr_uint32_t (WINAPI * apr_atomic_win32_ptr_val_val_fn) - (apr_uint32_t volatile *, - apr_uint32_t, apr_uint32_t); -typedef WINBASEAPI void * (WINAPI * apr_atomic_win32_ptr_ptr_ptr_fn) - (volatile void **, - void *, const void *); -typedef WINBASEAPI void * (WINAPI * apr_atomic_win32_ptr_ptr_fn) - (volatile void **, - void *); - -APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ -#if (defined(_M_IA64) || defined(_M_AMD64)) - return InterlockedExchangeAdd(mem, val); -#elif defined(__MINGW32__) - return InterlockedExchangeAdd((long *)mem, val); -#else - return ((apr_atomic_win32_ptr_val_fn)InterlockedExchangeAdd)(mem, val); -#endif -} - -/* Of course we want the 2's compliment of the unsigned value, val */ -#ifdef _MSC_VER -#pragma warning(disable: 4146) -#endif - -APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ -#if (defined(_M_IA64) || defined(_M_AMD64)) - InterlockedExchangeAdd(mem, -val); -#elif defined(__MINGW32__) - InterlockedExchangeAdd((long *)mem, -val); -#else - ((apr_atomic_win32_ptr_val_fn)InterlockedExchangeAdd)(mem, -val); -#endif -} - -APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem) -{ - /* we return old value, win32 returns new value :( */ -#if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED) - return InterlockedIncrement(mem) - 1; -#elif defined(__MINGW32__) - return InterlockedIncrement((long *)mem) - 1; -#else - return ((apr_atomic_win32_ptr_fn)InterlockedIncrement)(mem) - 1; -#endif -} - -APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem) -{ -#if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED) - return InterlockedDecrement(mem); -#elif defined(__MINGW32__) - return InterlockedDecrement((long *)mem); -#else - return ((apr_atomic_win32_ptr_fn)InterlockedDecrement)(mem); -#endif -} - -APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ -#if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED) - InterlockedExchange(mem, val); -#elif defined(__MINGW32__) - InterlockedExchange((long*)mem, val); -#else - ((apr_atomic_win32_ptr_val_fn)InterlockedExchange)(mem, val); -#endif -} - -APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem) -{ - return *mem; -} - -APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with, - apr_uint32_t cmp) -{ -#if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED) - return InterlockedCompareExchange(mem, with, cmp); -#elif defined(__MINGW32__) - return InterlockedCompareExchange((long*)mem, with, cmp); -#else - return ((apr_atomic_win32_ptr_val_val_fn)InterlockedCompareExchange)(mem, with, cmp); -#endif -} - -APR_DECLARE(void *) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp) -{ -#if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED) - return InterlockedCompareExchangePointer((void* volatile*)mem, with, (void*)cmp); -#elif defined(__MINGW32__) - return InterlockedCompareExchangePointer((void**)mem, with, (void*)cmp); -#else - /* Too many VC6 users have stale win32 API files, stub this */ - return ((apr_atomic_win32_ptr_ptr_ptr_fn)InterlockedCompareExchange)(mem, with, cmp); -#endif -} - -APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val) -{ -#if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED) - return InterlockedExchange(mem, val); -#elif defined(__MINGW32__) - return InterlockedExchange((long *)mem, val); -#else - return ((apr_atomic_win32_ptr_val_fn)InterlockedExchange)(mem, val); -#endif -} - -APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem, void *with) -{ -#if (defined(_M_IA64) || defined(_M_AMD64) || defined(__MINGW32__)) && !defined(RC_INVOKED) - return InterlockedExchangePointer((void**)mem, with); -#else - /* Too many VC6 users have stale win32 API files, stub this */ - return ((apr_atomic_win32_ptr_ptr_fn)InterlockedExchange)(mem, with); -#endif -} diff --git a/libs/apr/build-outputs.mk b/libs/apr/build-outputs.mk deleted file mode 100644 index 9f4876e3..00000000 --- a/libs/apr/build-outputs.mk +++ /dev/null @@ -1,319 +0,0 @@ -# DO NOT EDIT. AUTOMATICALLY GENERATED. - -passwd/apr_getpass.lo: passwd/apr_getpass.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_lib.h include/apr_pools.h include/apr_strings.h include/apr_thread_mutex.h include/apr_want.h -strings/apr_cpystrn.lo: strings/apr_cpystrn.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_lib.h include/apr_pools.h include/apr_strings.h include/apr_thread_mutex.h include/apr_want.h -strings/apr_fnmatch.lo: strings/apr_fnmatch.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_fnmatch.h include/apr_general.h include/apr_lib.h include/apr_pools.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h -strings/apr_snprintf.lo: strings/apr_snprintf.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -strings/apr_strings.lo: strings/apr_strings.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_lib.h include/apr_pools.h include/apr_strings.h include/apr_thread_mutex.h include/apr_want.h -strings/apr_strnatcmp.lo: strings/apr_strnatcmp.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_lib.h include/apr_pools.h include/apr_strings.h include/apr_thread_mutex.h include/apr_want.h -strings/apr_strtok.lo: strings/apr_strtok.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_strings.h include/apr_thread_mutex.h include/apr_want.h -tables/apr_hash.lo: tables/apr_hash.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_hash.h include/apr_pools.h include/apr_thread_mutex.h include/apr_time.h include/apr_want.h -tables/apr_tables.lo: tables/apr_tables.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_lib.h include/apr_pools.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_want.h - -OBJECTS_all = passwd/apr_getpass.lo strings/apr_cpystrn.lo strings/apr_fnmatch.lo strings/apr_snprintf.lo strings/apr_strings.lo strings/apr_strnatcmp.lo strings/apr_strtok.lo tables/apr_hash.lo tables/apr_tables.lo - -dso/unix/dso.lo: dso/unix/dso.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_dso_unix = dso/unix/dso.lo - -file_io/unix/buffer.lo: file_io/unix/buffer.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_thread_mutex.h include/apr_want.h -file_io/unix/copy.lo: file_io/unix/copy.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_pools.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/unix/dir.lo: file_io/unix/dir.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/unix/fileacc.lo: file_io/unix/fileacc.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_strings.h include/apr_thread_mutex.h include/apr_want.h -file_io/unix/filedup.lo: file_io/unix/filedup.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/unix/filepath.lo: file_io/unix/filepath.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_pools.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/unix/filepath_util.lo: file_io/unix/filepath_util.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_want.h -file_io/unix/filestat.lo: file_io/unix/filestat.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_pools.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/unix/flock.lo: file_io/unix/flock.c .make.dirs -file_io/unix/fullrw.lo: file_io/unix/fullrw.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_pools.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/unix/mktemp.lo: file_io/unix/mktemp.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/unix/open.lo: file_io/unix/open.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_hash.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/unix/pipe.lo: file_io/unix/pipe.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/unix/readwrite.lo: file_io/unix/readwrite.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_strings.h include/apr_support.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/unix/seek.lo: file_io/unix/seek.c .make.dirs -file_io/unix/tempdir.lo: file_io/unix/tempdir.c .make.dirs include/apr_allocator.h include/apr_env.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_pools.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_file_io_unix = file_io/unix/buffer.lo file_io/unix/copy.lo file_io/unix/dir.lo file_io/unix/fileacc.lo file_io/unix/filedup.lo file_io/unix/filepath.lo file_io/unix/filepath_util.lo file_io/unix/filestat.lo file_io/unix/flock.lo file_io/unix/fullrw.lo file_io/unix/mktemp.lo file_io/unix/open.lo file_io/unix/pipe.lo file_io/unix/readwrite.lo file_io/unix/seek.lo file_io/unix/tempdir.lo - -locks/unix/global_mutex.lo: locks/unix/global_mutex.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -locks/unix/proc_mutex.lo: locks/unix/proc_mutex.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_hash.h include/apr_pools.h include/apr_strings.h include/apr_thread_mutex.h include/apr_want.h -locks/unix/thread_cond.lo: locks/unix/thread_cond.c .make.dirs -locks/unix/thread_mutex.lo: locks/unix/thread_mutex.c .make.dirs include/apr_want.h -locks/unix/thread_rwlock.lo: locks/unix/thread_rwlock.c .make.dirs - -OBJECTS_locks_unix = locks/unix/global_mutex.lo locks/unix/proc_mutex.lo locks/unix/thread_cond.lo locks/unix/thread_mutex.lo locks/unix/thread_rwlock.lo - -memory/unix/apr_pools.lo: memory/unix/apr_pools.c .make.dirs include/apr_allocator.h include/apr_atomic.h include/apr_dso.h include/apr_env.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_hash.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_memory_unix = memory/unix/apr_pools.lo - -misc/unix/charset.lo: misc/unix/charset.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -misc/unix/env.lo: misc/unix/env.c .make.dirs include/apr_allocator.h include/apr_env.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_strings.h include/apr_thread_mutex.h include/apr_want.h -misc/unix/errorcodes.lo: misc/unix/errorcodes.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_general.h include/apr_lib.h include/apr_pools.h include/apr_strings.h include/apr_thread_mutex.h include/apr_want.h -misc/unix/getopt.lo: misc/unix/getopt.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_lib.h include/apr_pools.h include/apr_strings.h include/apr_thread_mutex.h include/apr_want.h -misc/unix/otherchild.lo: misc/unix/otherchild.c .make.dirs -misc/unix/rand.lo: misc/unix/rand.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_thread_mutex.h include/apr_want.h -misc/unix/start.lo: misc/unix/start.c .make.dirs include/apr_allocator.h include/apr_atomic.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_signal.h include/apr_thread_mutex.h include/apr_want.h -misc/unix/version.lo: misc/unix/version.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_thread_mutex.h include/apr_version.h include/apr_want.h - -OBJECTS_misc_unix = misc/unix/charset.lo misc/unix/env.lo misc/unix/errorcodes.lo misc/unix/getopt.lo misc/unix/otherchild.lo misc/unix/rand.lo misc/unix/start.lo misc/unix/version.lo - -mmap/unix/common.lo: mmap/unix/common.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_mmap.h include/apr_pools.h include/apr_ring.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h -mmap/unix/mmap.lo: mmap/unix/mmap.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_mmap.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_ring.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_mmap_unix = mmap/unix/common.lo mmap/unix/mmap.lo - -network_io/unix/inet_ntop.lo: network_io/unix/inet_ntop.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_strings.h include/apr_thread_mutex.h include/apr_want.h -network_io/unix/inet_pton.lo: network_io/unix/inet_pton.c .make.dirs -network_io/unix/multicast.lo: network_io/unix/multicast.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_support.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -network_io/unix/sendrecv.lo: network_io/unix/sendrecv.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_support.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h -network_io/unix/sockaddr.lo: network_io/unix/sockaddr.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_lib.h include/apr_pools.h include/apr_strings.h include/apr_thread_mutex.h include/apr_want.h -network_io/unix/socket_util.lo: network_io/unix/socket_util.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_network_io.h include/apr_poll.h include/apr_pools.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h -network_io/unix/sockets.lo: network_io/unix/sockets.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_support.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -network_io/unix/sockopt.lo: network_io/unix/sockopt.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_strings.h include/apr_thread_mutex.h include/apr_want.h - -OBJECTS_network_io_unix = network_io/unix/inet_ntop.lo network_io/unix/inet_pton.lo network_io/unix/multicast.lo network_io/unix/sendrecv.lo network_io/unix/sockaddr.lo network_io/unix/socket_util.lo network_io/unix/sockets.lo network_io/unix/sockopt.lo - -poll/unix/epoll.lo: poll/unix/epoll.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_poll.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -poll/unix/kqueue.lo: poll/unix/kqueue.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_poll.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -poll/unix/poll.lo: poll/unix/poll.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_poll.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -poll/unix/pollcb.lo: poll/unix/pollcb.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_poll.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -poll/unix/pollset.lo: poll/unix/pollset.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_poll.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -poll/unix/port.lo: poll/unix/port.c .make.dirs include/apr_allocator.h include/apr_atomic.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_poll.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -poll/unix/select.lo: poll/unix/select.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_poll.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_poll_unix = poll/unix/epoll.lo poll/unix/kqueue.lo poll/unix/poll.lo poll/unix/pollcb.lo poll/unix/pollset.lo poll/unix/port.lo poll/unix/select.lo - -random/unix/apr_random.lo: random/unix/apr_random.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_pools.h include/apr_random.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -random/unix/sha2.lo: random/unix/sha2.c .make.dirs -random/unix/sha2_glue.lo: random/unix/sha2_glue.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_pools.h include/apr_random.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_random_unix = random/unix/apr_random.lo random/unix/sha2.lo random/unix/sha2_glue.lo - -shmem/unix/shm.lo: shmem/unix/shm.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_strings.h include/apr_thread_mutex.h include/apr_user.h include/apr_want.h - -OBJECTS_shmem_unix = shmem/unix/shm.lo - -support/unix/waitio.lo: support/unix/waitio.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_network_io.h include/apr_poll.h include/apr_pools.h include/apr_support.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_support_unix = support/unix/waitio.lo - -threadproc/unix/proc.lo: threadproc/unix/proc.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_random.h include/apr_shm.h include/apr_signal.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -threadproc/unix/procsup.lo: threadproc/unix/procsup.c .make.dirs -threadproc/unix/signals.lo: threadproc/unix/signals.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_signal.h include/apr_strings.h include/apr_thread_mutex.h include/apr_want.h -threadproc/unix/thread.lo: threadproc/unix/thread.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -threadproc/unix/threadpriv.lo: threadproc/unix/threadpriv.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_threadproc_unix = threadproc/unix/proc.lo threadproc/unix/procsup.lo threadproc/unix/signals.lo threadproc/unix/thread.lo threadproc/unix/threadpriv.lo - -time/unix/time.lo: time/unix/time.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -time/unix/timestr.lo: time/unix/timestr.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_time_unix = time/unix/time.lo time/unix/timestr.lo - -user/unix/groupinfo.lo: user/unix/groupinfo.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -user/unix/userinfo.lo: user/unix/userinfo.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_user_unix = user/unix/groupinfo.lo user/unix/userinfo.lo - -atomic/unix/builtins.lo: atomic/unix/builtins.c .make.dirs -atomic/unix/ia32.lo: atomic/unix/ia32.c .make.dirs -atomic/unix/mutex.lo: atomic/unix/mutex.c .make.dirs -atomic/unix/ppc.lo: atomic/unix/ppc.c .make.dirs -atomic/unix/s390.lo: atomic/unix/s390.c .make.dirs -atomic/unix/solaris.lo: atomic/unix/solaris.c .make.dirs - -OBJECTS_atomic_unix = atomic/unix/builtins.lo atomic/unix/ia32.lo atomic/unix/mutex.lo atomic/unix/ppc.lo atomic/unix/s390.lo atomic/unix/solaris.lo - -OBJECTS_unix = $(OBJECTS_all) $(OBJECTS_atomic_unix) $(OBJECTS_dso_unix) $(OBJECTS_file_io_unix) $(OBJECTS_locks_unix) $(OBJECTS_memory_unix) $(OBJECTS_misc_unix) $(OBJECTS_mmap_unix) $(OBJECTS_network_io_unix) $(OBJECTS_poll_unix) $(OBJECTS_random_unix) $(OBJECTS_shmem_unix) $(OBJECTS_support_unix) $(OBJECTS_threadproc_unix) $(OBJECTS_time_unix) $(OBJECTS_user_unix) - -dso/aix/dso.lo: dso/aix/dso.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_dso_aix = dso/aix/dso.lo - -OBJECTS_aix = $(OBJECTS_all) $(OBJECTS_atomic_unix) $(OBJECTS_dso_aix) $(OBJECTS_file_io_unix) $(OBJECTS_locks_unix) $(OBJECTS_memory_unix) $(OBJECTS_misc_unix) $(OBJECTS_mmap_unix) $(OBJECTS_network_io_unix) $(OBJECTS_poll_unix) $(OBJECTS_random_unix) $(OBJECTS_shmem_unix) $(OBJECTS_support_unix) $(OBJECTS_threadproc_unix) $(OBJECTS_time_unix) $(OBJECTS_user_unix) - -dso/beos/dso.lo: dso/beos/dso.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_dso_beos = dso/beos/dso.lo - -locks/beos/proc_mutex.lo: locks/beos/proc_mutex.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -locks/beos/thread_cond.lo: locks/beos/thread_cond.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -locks/beos/thread_mutex.lo: locks/beos/thread_mutex.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -locks/beos/thread_rwlock.lo: locks/beos/thread_rwlock.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_locks_beos = locks/beos/proc_mutex.lo locks/beos/thread_cond.lo locks/beos/thread_mutex.lo locks/beos/thread_rwlock.lo - -network_io/beos/sendrecv.lo: network_io/beos/sendrecv.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_thread_mutex.h include/apr_time.h include/apr_want.h -network_io/beos/socketcommon.lo: network_io/beos/socketcommon.c .make.dirs - -OBJECTS_network_io_beos = network_io/beos/sendrecv.lo network_io/beos/socketcommon.lo - -shmem/beos/shm.lo: shmem/beos/shm.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_shmem_beos = shmem/beos/shm.lo - -threadproc/beos/apr_proc_stub.lo: threadproc/beos/apr_proc_stub.c .make.dirs -threadproc/beos/proc.lo: threadproc/beos/proc.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_strings.h include/apr_thread_mutex.h include/apr_want.h -threadproc/beos/thread.lo: threadproc/beos/thread.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -threadproc/beos/threadpriv.lo: threadproc/beos/threadpriv.c .make.dirs -threadproc/beos/threadproc_common.lo: threadproc/beos/threadproc_common.c .make.dirs - -OBJECTS_threadproc_beos = threadproc/beos/apr_proc_stub.lo threadproc/beos/proc.lo threadproc/beos/thread.lo threadproc/beos/threadpriv.lo threadproc/beos/threadproc_common.lo - -OBJECTS_beos = $(OBJECTS_all) $(OBJECTS_atomic_unix) $(OBJECTS_dso_beos) $(OBJECTS_file_io_unix) $(OBJECTS_locks_beos) $(OBJECTS_memory_unix) $(OBJECTS_misc_unix) $(OBJECTS_mmap_unix) $(OBJECTS_network_io_beos) $(OBJECTS_poll_unix) $(OBJECTS_random_unix) $(OBJECTS_shmem_beos) $(OBJECTS_support_unix) $(OBJECTS_threadproc_beos) $(OBJECTS_time_unix) $(OBJECTS_user_unix) - -dso/os2/dso.lo: dso/os2/dso.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_dso_os2 = dso/os2/dso.lo - -file_io/os2/buffer.lo: file_io/os2/buffer.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_thread_mutex.h include/apr_want.h -file_io/os2/copy.lo: file_io/os2/copy.c .make.dirs -file_io/os2/dir.lo: file_io/os2/dir.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/os2/dir_make_recurse.lo: file_io/os2/dir_make_recurse.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_lib.h include/apr_pools.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/os2/fileacc.lo: file_io/os2/fileacc.c .make.dirs -file_io/os2/filedup.lo: file_io/os2/filedup.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_lib.h include/apr_pools.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/os2/filepath.lo: file_io/os2/filepath.c .make.dirs -file_io/os2/filepath_util.lo: file_io/os2/filepath_util.c .make.dirs -file_io/os2/filestat.lo: file_io/os2/filestat.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_lib.h include/apr_pools.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/os2/filesys.lo: file_io/os2/filesys.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_lib.h include/apr_pools.h include/apr_strings.h include/apr_thread_mutex.h include/apr_want.h -file_io/os2/flock.lo: file_io/os2/flock.c .make.dirs -file_io/os2/fullrw.lo: file_io/os2/fullrw.c .make.dirs -file_io/os2/maperrorcode.lo: file_io/os2/maperrorcode.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_pools.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/os2/mktemp.lo: file_io/os2/mktemp.c .make.dirs -file_io/os2/open.lo: file_io/os2/open.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/os2/pipe.lo: file_io/os2/pipe.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/os2/readwrite.lo: file_io/os2/readwrite.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_lib.h include/apr_pools.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/os2/seek.lo: file_io/os2/seek.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_lib.h include/apr_pools.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/os2/tempdir.lo: file_io/os2/tempdir.c .make.dirs - -OBJECTS_file_io_os2 = file_io/os2/buffer.lo file_io/os2/copy.lo file_io/os2/dir.lo file_io/os2/dir_make_recurse.lo file_io/os2/fileacc.lo file_io/os2/filedup.lo file_io/os2/filepath.lo file_io/os2/filepath_util.lo file_io/os2/filestat.lo file_io/os2/filesys.lo file_io/os2/flock.lo file_io/os2/fullrw.lo file_io/os2/maperrorcode.lo file_io/os2/mktemp.lo file_io/os2/open.lo file_io/os2/pipe.lo file_io/os2/readwrite.lo file_io/os2/seek.lo file_io/os2/tempdir.lo - -locks/os2/proc_mutex.lo: locks/os2/proc_mutex.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -locks/os2/thread_cond.lo: locks/os2/thread_cond.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -locks/os2/thread_mutex.lo: locks/os2/thread_mutex.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -locks/os2/thread_rwlock.lo: locks/os2/thread_rwlock.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_locks_os2 = locks/os2/proc_mutex.lo locks/os2/thread_cond.lo locks/os2/thread_mutex.lo locks/os2/thread_rwlock.lo - -network_io/os2/inet_ntop.lo: network_io/os2/inet_ntop.c .make.dirs -network_io/os2/inet_pton.lo: network_io/os2/inet_pton.c .make.dirs -network_io/os2/os2calls.lo: network_io/os2/os2calls.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -network_io/os2/sendrecv.lo: network_io/os2/sendrecv.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h -network_io/os2/sendrecv_udp.lo: network_io/os2/sendrecv_udp.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_support.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h -network_io/os2/sockaddr.lo: network_io/os2/sockaddr.c .make.dirs -network_io/os2/socket_util.lo: network_io/os2/socket_util.c .make.dirs -network_io/os2/sockets.lo: network_io/os2/sockets.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -network_io/os2/sockopt.lo: network_io/os2/sockopt.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_network_io_os2 = network_io/os2/inet_ntop.lo network_io/os2/inet_pton.lo network_io/os2/os2calls.lo network_io/os2/sendrecv.lo network_io/os2/sendrecv_udp.lo network_io/os2/sockaddr.lo network_io/os2/socket_util.lo network_io/os2/sockets.lo network_io/os2/sockopt.lo - -poll/os2/poll.lo: poll/os2/poll.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_network_io.h include/apr_poll.h include/apr_pools.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h -poll/os2/pollset.lo: poll/os2/pollset.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_network_io.h include/apr_poll.h include/apr_pools.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_poll_os2 = poll/os2/poll.lo poll/os2/pollset.lo - -shmem/os2/shm.lo: shmem/os2/shm.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_shmem_os2 = shmem/os2/shm.lo - -threadproc/os2/proc.lo: threadproc/os2/proc.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_signal.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -threadproc/os2/signals.lo: threadproc/os2/signals.c .make.dirs -threadproc/os2/thread.lo: threadproc/os2/thread.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -threadproc/os2/threadpriv.lo: threadproc/os2/threadpriv.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_threadproc_os2 = threadproc/os2/proc.lo threadproc/os2/signals.lo threadproc/os2/thread.lo threadproc/os2/threadpriv.lo - -OBJECTS_os2 = $(OBJECTS_all) $(OBJECTS_atomic_unix) $(OBJECTS_dso_os2) $(OBJECTS_file_io_os2) $(OBJECTS_locks_os2) $(OBJECTS_memory_unix) $(OBJECTS_misc_unix) $(OBJECTS_mmap_unix) $(OBJECTS_network_io_os2) $(OBJECTS_poll_os2) $(OBJECTS_random_unix) $(OBJECTS_shmem_os2) $(OBJECTS_support_unix) $(OBJECTS_threadproc_os2) $(OBJECTS_time_unix) $(OBJECTS_user_unix) - -dso/os390/dso.lo: dso/os390/dso.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_dso_os390 = dso/os390/dso.lo - -atomic/os390/atomic.lo: atomic/os390/atomic.c .make.dirs include/apr_allocator.h include/apr_atomic.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_thread_mutex.h include/apr_want.h - -OBJECTS_atomic_os390 = atomic/os390/atomic.lo - -OBJECTS_os390 = $(OBJECTS_all) $(OBJECTS_atomic_os390) $(OBJECTS_dso_os390) $(OBJECTS_file_io_unix) $(OBJECTS_locks_unix) $(OBJECTS_memory_unix) $(OBJECTS_misc_unix) $(OBJECTS_mmap_unix) $(OBJECTS_network_io_unix) $(OBJECTS_poll_unix) $(OBJECTS_random_unix) $(OBJECTS_shmem_unix) $(OBJECTS_support_unix) $(OBJECTS_threadproc_unix) $(OBJECTS_time_unix) $(OBJECTS_user_unix) - -dso/win32/dso.lo: dso/win32/dso.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_strings.h include/apr_thread_mutex.h include/apr_want.h - -OBJECTS_dso_win32 = dso/win32/dso.lo - -file_io/win32/buffer.lo: file_io/win32/buffer.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_thread_mutex.h include/apr_want.h -file_io/win32/dir.lo: file_io/win32/dir.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/win32/filedup.lo: file_io/win32/filedup.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_pools.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/win32/filepath.lo: file_io/win32/filepath.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_lib.h include/apr_pools.h include/apr_strings.h include/apr_thread_mutex.h include/apr_want.h -file_io/win32/filestat.lo: file_io/win32/filestat.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_pools.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/win32/filesys.lo: file_io/win32/filesys.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_strings.h include/apr_thread_mutex.h include/apr_want.h -file_io/win32/flock.lo: file_io/win32/flock.c .make.dirs -file_io/win32/open.lo: file_io/win32/open.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/win32/pipe.lo: file_io/win32/pipe.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_pools.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/win32/readwrite.lo: file_io/win32/readwrite.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_lib.h include/apr_pools.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h -file_io/win32/seek.lo: file_io/win32/seek.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_pools.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_file_io_win32 = file_io/unix/copy.lo file_io/unix/fileacc.lo file_io/unix/filepath_util.lo file_io/unix/fullrw.lo file_io/unix/mktemp.lo file_io/unix/tempdir.lo file_io/win32/buffer.lo file_io/win32/dir.lo file_io/win32/filedup.lo file_io/win32/filepath.lo file_io/win32/filestat.lo file_io/win32/filesys.lo file_io/win32/flock.lo file_io/win32/open.lo file_io/win32/pipe.lo file_io/win32/readwrite.lo file_io/win32/seek.lo - -locks/win32/proc_mutex.lo: locks/win32/proc_mutex.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -locks/win32/thread_cond.lo: locks/win32/thread_cond.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -locks/win32/thread_mutex.lo: locks/win32/thread_mutex.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -locks/win32/thread_rwlock.lo: locks/win32/thread_rwlock.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_locks_win32 = locks/win32/proc_mutex.lo locks/win32/thread_cond.lo locks/win32/thread_mutex.lo locks/win32/thread_rwlock.lo - -misc/win32/charset.lo: misc/win32/charset.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -misc/win32/env.lo: misc/win32/env.c .make.dirs include/apr_allocator.h include/apr_env.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_strings.h include/apr_thread_mutex.h include/apr_want.h -misc/win32/internal.lo: misc/win32/internal.c .make.dirs -misc/win32/misc.lo: misc/win32/misc.c .make.dirs include/apr_errno.h include/apr_lib.h -misc/win32/rand.lo: misc/win32/rand.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -misc/win32/start.lo: misc/win32/start.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_signal.h include/apr_thread_mutex.h include/apr_want.h -misc/win32/utf8.lo: misc/win32/utf8.c .make.dirs include/apr_errno.h - -OBJECTS_misc_win32 = misc/unix/errorcodes.lo misc/unix/getopt.lo misc/unix/otherchild.lo misc/unix/version.lo misc/win32/charset.lo misc/win32/env.lo misc/win32/internal.lo misc/win32/misc.lo misc/win32/rand.lo misc/win32/start.lo misc/win32/utf8.lo - -mmap/win32/mmap.lo: mmap/win32/mmap.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_mmap.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_ring.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_mmap_win32 = mmap/unix/common.lo mmap/win32/mmap.lo - -network_io/win32/sendrecv.lo: network_io/win32/sendrecv.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h -network_io/win32/sockets.lo: network_io/win32/sockets.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -network_io/win32/sockopt.lo: network_io/win32/sockopt.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_network_io_win32 = network_io/unix/inet_ntop.lo network_io/unix/inet_pton.lo network_io/unix/multicast.lo network_io/unix/sockaddr.lo network_io/unix/socket_util.lo network_io/win32/sendrecv.lo network_io/win32/sockets.lo network_io/win32/sockopt.lo - -shmem/win32/shm.lo: shmem/win32/shm.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_pools.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_shmem_win32 = shmem/win32/shm.lo - -threadproc/win32/proc.lo: threadproc/win32/proc.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -threadproc/win32/signals.lo: threadproc/win32/signals.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_pools.h include/apr_signal.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -threadproc/win32/thread.lo: threadproc/win32/thread.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -threadproc/win32/threadpriv.lo: threadproc/win32/threadpriv.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_threadproc_win32 = threadproc/win32/proc.lo threadproc/win32/signals.lo threadproc/win32/thread.lo threadproc/win32/threadpriv.lo - -time/win32/time.lo: time/win32/time.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_lib.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -time/win32/timestr.lo: time/win32/timestr.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_time_win32 = time/win32/time.lo time/win32/timestr.lo - -user/win32/groupinfo.lo: user/win32/groupinfo.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h -user/win32/userinfo.lo: user/win32/userinfo.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h - -OBJECTS_user_win32 = user/win32/groupinfo.lo user/win32/userinfo.lo - -atomic/win32/apr_atomic.lo: atomic/win32/apr_atomic.c .make.dirs include/apr_allocator.h include/apr_atomic.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_thread_mutex.h include/apr_want.h - -OBJECTS_atomic_win32 = atomic/win32/apr_atomic.lo - -OBJECTS_win32 = $(OBJECTS_all) $(OBJECTS_atomic_win32) $(OBJECTS_dso_win32) $(OBJECTS_file_io_win32) $(OBJECTS_locks_win32) $(OBJECTS_memory_unix) $(OBJECTS_misc_win32) $(OBJECTS_mmap_win32) $(OBJECTS_network_io_win32) $(OBJECTS_poll_unix) $(OBJECTS_random_unix) $(OBJECTS_shmem_win32) $(OBJECTS_support_unix) $(OBJECTS_threadproc_win32) $(OBJECTS_time_win32) $(OBJECTS_user_win32) - -HEADERS = $(top_srcdir)/include/apr_allocator.h $(top_srcdir)/include/apr_atomic.h $(top_srcdir)/include/apr_dso.h $(top_srcdir)/include/apr_env.h $(top_srcdir)/include/apr_errno.h $(top_srcdir)/include/apr_file_info.h $(top_srcdir)/include/apr_file_io.h $(top_srcdir)/include/apr_fnmatch.h $(top_srcdir)/include/apr_general.h $(top_srcdir)/include/apr_getopt.h $(top_srcdir)/include/apr_global_mutex.h $(top_srcdir)/include/apr_hash.h $(top_srcdir)/include/apr_inherit.h $(top_srcdir)/include/apr_lib.h $(top_srcdir)/include/apr_mmap.h $(top_srcdir)/include/apr_network_io.h $(top_srcdir)/include/apr_poll.h $(top_srcdir)/include/apr_pools.h $(top_srcdir)/include/apr_portable.h $(top_srcdir)/include/apr_proc_mutex.h $(top_srcdir)/include/apr_random.h $(top_srcdir)/include/apr_ring.h $(top_srcdir)/include/apr_shm.h $(top_srcdir)/include/apr_signal.h $(top_srcdir)/include/apr_strings.h $(top_srcdir)/include/apr_support.h $(top_srcdir)/include/apr_tables.h $(top_srcdir)/include/apr_thread_cond.h $(top_srcdir)/include/apr_thread_mutex.h $(top_srcdir)/include/apr_thread_proc.h $(top_srcdir)/include/apr_thread_rwlock.h $(top_srcdir)/include/apr_time.h $(top_srcdir)/include/apr_user.h $(top_srcdir)/include/apr_version.h $(top_srcdir)/include/apr_want.h - -SOURCE_DIRS = random/unix misc/win32 mmap/win32 dso/os2 time/unix network_io/win32 dso/win32 locks/unix user/unix time/win32 locks/beos tables support/unix file_io/unix mmap/unix atomic/unix threadproc/win32 poll/os2 atomic/win32 dso/os390 atomic/os390 dso/beos poll/unix passwd network_io/beos threadproc/os2 network_io/os2 shmem/win32 threadproc/beos shmem/unix network_io/unix file_io/os2 dso/aix file_io/win32 threadproc/unix misc/unix locks/win32 shmem/beos dso/unix locks/os2 user/win32 shmem/os2 memory/unix strings $(EXTRA_SOURCE_DIRS) - -BUILD_DIRS = atomic atomic/os390 atomic/unix atomic/win32 dso dso/aix dso/beos dso/os2 dso/os390 dso/unix dso/win32 file_io file_io/os2 file_io/unix file_io/win32 locks locks/beos locks/os2 locks/unix locks/win32 memory memory/unix misc misc/unix misc/win32 mmap mmap/unix mmap/win32 network_io network_io/beos network_io/os2 network_io/unix network_io/win32 passwd poll poll/os2 poll/unix random random/unix shmem shmem/beos shmem/os2 shmem/unix shmem/win32 strings support support/unix tables threadproc threadproc/beos threadproc/os2 threadproc/unix threadproc/win32 time time/unix time/win32 user user/unix user/win32 - -.make.dirs: $(srcdir)/build-outputs.mk - @for d in $(BUILD_DIRS); do test -d $$d || mkdir $$d; done - @echo timestamp > $@ diff --git a/libs/apr/build.conf b/libs/apr/build.conf deleted file mode 100644 index c302b98b..00000000 --- a/libs/apr/build.conf +++ /dev/null @@ -1,28 +0,0 @@ -# -# Configuration file for APR. Used by APR/build/gen-build.py -# - -[options] - -# paths to platform-independent .c files to build -paths = - passwd/*.c - strings/*.c - tables/*.c - -# directories that have platform-specific code in them. the resulting -# pattern will be: SUBDIR/PLATFORM/*.c -platform_dirs = - dso file_io locks memory misc mmap network_io poll random - shmem support threadproc time user atomic - -# all the public headers -headers = include/*.h - -# aplibtool is manually built by the configure process -# build/aplibtool.c - -# we have a recursive makefile for the test files (for now) -# test/*.c - -dsp = libapr.dsp diff --git a/libs/apr/build/MakeEtags b/libs/apr/build/MakeEtags deleted file mode 100644 index cf1a4868..00000000 --- a/libs/apr/build/MakeEtags +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh - -# This file illustrates how to generate a useful TAGS file via etags -# for emacs. This should be invoked from the top source directory i.e.: -# > build/MakeEtags -# and will create a TAGS file in the top source directory. - -# This script falls under the Apache License. -# See http://www.apache.org/docs/LICENSE - -# Once you have created ./TAGS in emacs you'll need to setup -# tag-table-alist with an entry to assure it finds the single ./TAGS -# file from the many source directories. Something along these lines: -# (setq tag-table-alist -# '(("/home/me/work/apr-x.y/" . "/home/me/work/apr-x.y/") -# ("/home/me/work/apr-util-x.y/" . "/home/me/work/apr-util-x.y/") -# ("/home/me/work/httpd-x.y/" . "/home/me/work/httpd-x.y/") -# )) - -# This requires a special version of etags, i.e. the -# one called "Exuberant ctags" available at: -# http://ctags.sourceforge.net/ -# Once that is setup you'll need to point to the -# executable here: - -etags=${ETAGS-etags} - -# Exuberant etags is necessary since it can ignore some defined symbols -# that obscure the function signatures. - -ignore=AP_DECLARE,AP_DECLARE_NONSTD,__declspec,APR_DECLARE,APR_DECLARE_NONSTD -ignore=$ignore,APU_DECLARE,APU_DECLARE_NONSTD - -# Create an etags file at the root of the source -# tree, then create symbol links to it from each -# directory in the source tree. By passing etags -# absolute pathnames we get a tag file that is -# NOT portable when we move the directory tree. - -find . -name '*.[ch]' -print | $etags -I "$ignore" -L - - diff --git a/libs/apr/build/NWGNUenvironment.inc b/libs/apr/build/NWGNUenvironment.inc deleted file mode 100644 index c15e003b..00000000 --- a/libs/apr/build/NWGNUenvironment.inc +++ /dev/null @@ -1,344 +0,0 @@ -# -# Setup needed Tools and Libraries -# - -ifeq "$(wildcard $(APR_WORK)/build/NWGNUcustom.inc)" "$(APR_WORK)/build/NWGNUcustom.inc" -include $(APR_WORK)/build/NWGNUcustom.inc -CUSTOM_INI = $(AP_WORK)/NWGNUcustom.ini -endif - -ifndef VERBOSE -.SILENT: -endif - -# -# Treat like an include -# -ifndef EnvironmentDefined - -# -# simple macros for parsing makefiles -# -EOLIST:= -EMPTY := -COMMA := , -SPACE := $(EMPTY) $(EMPTY) - -# -# Base environment -# - -# Try and handle case issues -ifndef NOVELLLIBC -ifdef NovellLibC -NOVELLLIBC = $(NovellLibC) -endif -endif - -ifndef NOVELLLIBC -NOVELLLIBC = C:/novell/ndk/libc -endif -ifneq "$(wildcard $(NOVELLLIBC)/include/ndkvers.h)" "$(NOVELLLIBC)/include/ndkvers.h" -$(error NOVELLLIBC does not point to a valid Novell LIBC SDK) -endif - -ifndef LDAPSDK -LDAPSDK = C:/novell/ndk/cldapsdk/NetWare/libc -endif -ifneq "$(wildcard $(LDAPSDK)/inc/ldap.h)" "$(LDAPSDK)/inc/ldap.h" -$(error LDAPSDK does not point to a valid Novell CLDAP SDK) -endif - -ifdef EXPATSDK -ifeq "$(wildcard $(EXPATSDK)/include/expat.h)" "$(EXPATSDK)/include/expat.h" -EXPAT_IMP = $(EXPATSDK)/imports/expatlbc.imp -EXPAT_INC = $(EXPATSDK)/include -EXPAT_LIB = $(EXPATSDK)/lib/expat.lib -EXPAT_NLM = EXPATLBC -else -$(error EXPATSDK does not point to a valid EXPAT SDK) -endif -endif -ifdef EXPATSRC -ifeq "$(wildcard $(EXPATSRC)/lib/xmlparse.c)" "$(EXPATSRC)/lib/xmlparse.c" -EXPAT_INC = $(EXPATSRC)/lib -EXPAT_LIB = $(EXPATSRC)/lib/$(OBJDIR)/expat.lib -else -$(error EXPATSRC does not point to a valid EXPAT source tree) -endif -endif -ifndef EXPAT_INC -EXPATSRC = $(APUXML)/expat -EXPAT_INC = $(EXPATSRC)/lib -EXPAT_LIB = $(EXPATSRC)/lib/$(OBJDIR)/expat.lib -endif - -ifndef METROWERKS -METROWERKS = $(ProgramFiles)\Metrowerks\CodeWarrior -endif - -# If LM_LICENSE_FILE isn't defined, define a variable that can be used to -# restart make with it defined -ifndef LM_LICENSE_FILE -NO_LICENSE_FILE = NO_LICENSE_FILE -endif - -# -# Set the Release type that you want to build, possible values are: -# -# debug - full debug switches are set -# noopt - normal switches are set -# release - optimization switches are set (default) - -ifdef reltype -RELEASE = $(reltype) -endif - -ifdef RELTYPE -RELEASE = $(RELTYPE) -endif - -ifdef debug -RELEASE = debug -endif - -ifdef DEBUG -RELEASE = debug -endif - -ifdef noopt -RELEASE = noopt -endif - -ifdef NOOPT -RELEASE = noopt -endif - -ifdef optimized -RELEASE = release -endif - -ifdef OPTIMIZED -RELEASE = release -endif - -ifndef RELEASE -RELEASE = release -endif - -ifeq "$(strip $(RELEASE))" "optimized" -RELEASE = release -endif - -OBJDIR = obj_$(RELEASE) - -# -# Setup compiler information -# - -# MetroWerks NLM tools -CC = mwccnlm -CPP = mwccnlm -LINK = mwldnlm -LIB = mwldnlm -type library -w nocmdline - -# Setup build tools -AWK = awk - -# -# Declare Command and tool macros here -# - -ifeq ($(findstring /sh,$(SHELL)),/sh) -DEL = rm -f $1 -RMDIR = rm -rf $1 -MKDIR = mkdir -p $1 -COPY = cp -av $1 $2 -COPYR = cp -ar $1 $2 -ECHONL = echo "" -DL = ' -CAT = cat -else -ifeq "$(OS)" "Windows_NT" -DEL = $(shell if exist $(subst /,\,$1) del /q /f 2>NUL $(subst /,\,$1)) -RMDIR = $(shell if exist $(subst /,\,$1)\NUL rd /q /s 2>NUL $(subst /,\,$1)) -else -DEL = $(shell if exist $(subst /,\,$1) del 2>NUL $(subst /,\,$1)) -RMDIR = $(shell if exist $(subst /,\,$1)\NUL deltree /y 2>NUL $(subst /,\,$1)) -endif -ECHONL = $(ComSpec) /c echo. -MKDIR = $(shell if not exist $(subst /,\,$1)\NUL md 2>NUL $(subst /,\,$1)) -COPY = copy /y 2>NUL $(subst /,\,$1) $(subst /,\,$2) -COPYR = xcopy /y /e 2>NUL $(subst /,\,$1) $(subst /,\,$2) -CAT = type -endif - -ifdef IPV6 -ifndef USE_STDSOCKETS -USE_STDSOCKETS=1 -endif -endif - -NOVI = $(NOVELLLIBC)/imports -PRELUDE = $(NOVI)/libcpre.o - -INCDIRS = $(NOVELLLIBC)/include; - -DEFINES = -DNETWARE -ifdef USE_STDSOCKETS -DEFINES += -DUSE_BSD_SOCKETS -else -DEFINES += -DUSE_WINSOCK -INCDIRS += $(NOVELLLIBC)/include/winsock; -endif -ifndef DEBUG -DEFINES += -DNDEBUG -endif - -ifdef USE_STDSOCKETS -VERSION_SKT = (BSDSOCK) -else -VERSION_SKT = (WINSOCK) -endif - -# MetroWerks static Libraries -CLIB3S = $(METROWERKS)/Novell Support/Metrowerks Support/Libraries/Runtime/mwcrtl.lib -MATH3S = -PLIB3S = $(METROWERKS)/Novell Support/Metrowerks Support/Libraries/MSL C++/MWCPP.lib - -# Base compile flags -# and prefix or precompiled header added here. - -# The default flags are as follows: -# -# -c compile only, no link -# -nosyspath treat #include <...> like #include "..." -# -Cpp_exceptions off disable C++ exceptions -# -RTTI off disable C++ run-time typing information -# -align 4 align on 4 byte bounderies -# -w nocmdline disable command-line driver/parser warnings -# -proc PII generate code base on Pentium II instruction set -# -inst mmx use MMX extensions (not used) - -CFLAGS = -c -nosyspath -Cpp_exceptions off -RTTI off -align 4 -w nocmdline -proc PII - -ifeq "$(REQUIRE_PROTOTYPES)" "1" -CFLAGS += -r -endif - -# -g generate debugging information -# -O0 level 0 optimizations -ifeq "$(RELEASE)" "debug" -CFLAGS += -g -O0 -endif - -# -O4,p level 4 optimizations, optimize for speed -ifeq "$(RELEASE)" "release" -CFLAGS += -O4,p -endif - -# -prefix apr_arch_pre_nw.h #include pre_nw.h for all files -CFLAGS += -prefix apr_arch_pre_nw.h - - -ifneq ($(findstring /sh,$(SHELL)),/sh) -PATH:=$(PATH);$(METROWERKS)\bin;$(METROWERKS)\Other Metrowerks Tools\Command Line Tools -endif - -# -# Declare major project deliverables output directories here -# - -ifdef DEST -INSTALL = $(DEST) -ifeq (\, $(findstring \,$(INSTALL))) -INSTDIRS = $(DEST) -endif -endif - -ifdef dest -INSTALL = $(dest) -ifeq (\, $(findstring \,$(INSTALL))) -INSTDIRS = $(dest) -endif -endif - -ifndef INSTALL -INSTALL = $(APR_WORK)/Dist -INSTDIRS = $(APR_WORK)/Dist -BASEDIR = Apr -endif - -# Add support for building IPV6 alongside -ifneq "$(IPV6)" "" -DEFINES += -DNW_BUILD_IPV6 -# INCDIRS := $(NOVELLLIBC)/include/winsock/IPV6;$(INCDIRS) - -ifneq "$(findstring IPV6,$(OBJDIR))" "IPV6" -OBJDIR := $(OBJDIR)_IPV6 -endif - -ifneq "$(findstring IPV6,$(INSTALL))" "IPV6" -INSTALL := $(INSTALL)_IPV6 -endif - -ifneq "$(findstring IPV6,$(INSTDIRS))" "IPV6" -INSTDIRS := $(INSTDIRS)_IPV6 -endif - -endif - -ifdef DEST - -ifndef BASEDIR -BASEDIR = Apache2 -endif - -endif - -INSTALLBASE := $(INSTALL)/$(BASEDIR) - -INSTDEVDIRS := \ - $(INSTDIRS) \ - $(INSTALLBASE) \ - $(INSTALLBASE)/include \ - $(INSTALLBASE)/lib \ - $(INSTALLBASE)/bin - -INSTDIRS += \ - $(INSTALLBASE) - -# -# Common directories -# - -APR = $(subst \,/,$(APR_WORK)) -APU = $(subst \,/,$(APU_WORK)) -APRBUILD = $(APR)/build -APULDAP = $(APU)/ldap -APUXML = $(APU)/xml -APRTEST = $(APR)/test -APUTEST = $(APU)/test - -# -# Internal Libraries -# - -APRLIB = $(APR)/$(OBJDIR)/aprlib.lib -APULIB = $(APU)/$(OBJDIR)/apulib.lib -APULDAPLIB = $(APULDAP)/$(OBJDIR)/apuldap.lib -APUXMLLIB = $(APUXML)/$(OBJDIR)/apuxml.lib - -# -# Additional general defines -# - -EnvironmentDefined = 1 -endif # ifndef EnvironmentDefined - -# This is always set so that it will show up in lower directories - -ifdef Path -Path = $(PATH) -endif - diff --git a/libs/apr/build/NWGNUhead.inc b/libs/apr/build/NWGNUhead.inc deleted file mode 100644 index 723137c4..00000000 --- a/libs/apr/build/NWGNUhead.inc +++ /dev/null @@ -1,94 +0,0 @@ -# -# Obtain the global build environment -# - -include $(APR_WORK)/build/NWGNUenvironment.inc - -# -# Define base targets and rules -# - -TARGETS = libs nlms install clobber_libs clobber_nlms clean installdev - -.PHONY : $(TARGETS) default all help $(NO_LICENSE_FILE) - -# Here is where we will use the NO_LICENSE_FILE variable to see if we need to -# restart the make with it defined - -ifdef NO_LICENSE_FILE - -default: NO_LICENSE_FILE - -all: NO_LICENSE_FILE - -install :: NO_LICENSE_FILE - -installdev :: NO_LICENSE_FILE - -NO_LICENSE_FILE : - $(MAKE) $(MAKECMDGOALS) -f NWGNUmakefile RELEASE=$(RELEASE) DEST="$(INSTALL)" LM_LICENSE_FILE="$(METROWERKS)/license.dat" - -else # LM_LICENSE_FILE must be defined so use the real targets - -default: $(SUBDIRS) libs nlms - -all: $(SUBDIRS) libs nlms install - -$(TARGETS) :: $(SUBDIRS) - -endif #NO_LICENSE_FILE check - -help : - @echo $(DL)targets for RELEASE=$(RELEASE):$(DL) - @echo $(DL)(default) . . . . libs nlms$(DL) - @echo $(DL)all . . . . . . . does everything (libs nlms install)$(DL) - @echo $(DL)libs. . . . . . . builds all libs$(DL) - @echo $(DL)nlms. . . . . . . builds all nlms$(DL) - @echo $(DL)install . . . . . builds libs and nlms and copies install files to$(DL) - @echo $(DL) "$(INSTALL)"$(DL) - @echo $(DL)installdev. . . . copies headers and files needed for development to$(DL) - @echo $(DL) "$(INSTALL)"$(DL) - @echo $(DL)clean . . . . . . deletes $(OBJDIR) dirs, *.err, and *.map$(DL) - @echo $(DL)clobber_all . . . deletes all possible output from the make$(DL) - @echo $(DL)clobber_install . deletes all files in $(INSTALL)$(DL) - @$(ECHONL) - @echo $(DL)Multiple targets can be used on a single make command line -$(DL) - @echo $(DL)(i.e. $(MAKE) clean all)$(DL) - @$(ECHONL) - @echo $(DL)You can also specify RELEASE=debug, RELEASE=noopt, or RELEASE=release$(DL) - @echo $(DL)The default is RELEASE=release$(DL) - -clobber_all :: clean clobber_install - -clobber_install :: - $(call RMDIR,$(INSTALL)) - -# -# build recursive targets -# - -$(SUBDIRS) : FORCE -ifneq "$(MAKECMDGOALS)" "clean" - @$(ECHONL) - @echo Building $(CURDIR)/$@ -endif - $(MAKE) -C $@ $(MAKECMDGOALS) -f NWGNUmakefile RELEASE=$(RELEASE) DEST="$(INSTALL)" LM_LICENSE_FILE="$(LM_LICENSE_FILE)" - @$(ECHONL) - -FORCE : ; - -# -# Standard targets -# - -clean :: $(SUBDIRS) $(APRTEST) - @echo Cleaning up $(CURDIR) - $(call RMDIR,$(OBJDIR)) - $(call DEL,*.err) - $(call DEL,*.map) - $(call DEL,*.tmp) -# $(call DEL,*.d) - -$(OBJDIR) :: - $(call MKDIR,$@) - diff --git a/libs/apr/build/NWGNUmakefile b/libs/apr/build/NWGNUmakefile deleted file mode 100644 index 68fff198..00000000 --- a/libs/apr/build/NWGNUmakefile +++ /dev/null @@ -1,83 +0,0 @@ -# -# Declare the sub-directories to be built here -# - -SUBDIRS = \ - $(EOLIST) - -# -# Get the 'head' of the build environment. This includes default targets and -# paths to tools -# - -include $(APR_WORK)/build/NWGNUhead.inc - -# -# build this level's files - -FILES_prebuild_headers = \ - $(APR)/include/apr.h \ - $(APU)/include/apu.h \ - $(APU)/include/apu_want.h \ - $(APU)/include/apr_ldap.h \ - $(APU)/include/private/apu_config.h \ - $(APU)/include/private/apu_select_dbm.h \ - $(APUXML)/expat/lib/expat_config.h \ - $(EOLIST) - -nlms :: $(APR)/aprlib.imp - -$(APR)/aprlib.imp : make_nw_export.awk nw_export.i - @echo $(DL)GEN $@$(DL) - $(AWK) -v EXPPREFIX=APR$(VERSION_MAJMIN) -f $^ >$@ - -nw_export.i : nw_export.inc $(APU)/build/nw_apu_export.inc $(FILES_prebuild_headers) cc.opt - @echo $(DL)GEN $@$(DL) - $(CC) $< @cc.opt - -cc.opt : NWGNUmakefile $(APR_WORK)/build/NWGNUenvironment.inc $(APR_WORK)/build/NWGNUhead.inc $(APRBUILD)/NWGNUtail.inc $(CUSTOM_INI) - @echo $(DL)-P$(DL)> $@ - @echo $(DL)-EP$(DL)>> $@ - @echo $(DL)-nosyspath$(DL)>> $@ - @echo $(DL)-w nocmdline$(DL)>> $@ - @echo $(DL)$(DEFINES) -DGENEXPORTS$(DL)>> $@ - @echo $(DL)-I$(APR)/include$(DL)>> $@ - @echo $(DL)-I$(APR)/include/arch/netware$(DL)>> $@ - @echo $(DL)-I$(APR)/include/arch/unix$(DL)>> $@ - @echo $(DL)-I$(APU)/include$(DL)>> $@ - @echo $(DL)-I$(APU)/include/private$(DL)>> $@ - @echo $(DL)-I$(APU)/build$(DL)>> $@ - @echo $(DL)-ir $(NOVELLLIBC)$(DL)>> $@ -ifneq "$(LDAPSDK)" "" - @echo $(DL)-ir $(LDAPSDK)$(DL)>> $@ -endif - - -%.h: %.hnw - @echo $(DL)Creating $@$(DL) - $(call COPY,$<,$@) - -%.h: %.hw - @echo $(DL)Creating $@$(DL) - $(call COPY,$<,$@) - -# -# You can use this target if all that is needed is to copy files to the -# installation area -# -install :: nlms FORCE - -clean :: - $(call DEL,nw_export.i) - $(call DEL,cc.opt) - $(call DEL,NWGNUversion.inc) - $(call DEL,$(APR)/aprlib.imp) - $(foreach file,$(FILES_prebuild_headers),$(call DEL,$(file))) - -# -# Include the 'tail' makefile that has targets that depend on variables defined -# in this makefile -# - -include $(APRBUILD)/NWGNUtail.inc - diff --git a/libs/apr/build/NWGNUtail.inc b/libs/apr/build/NWGNUtail.inc deleted file mode 100644 index ad911c93..00000000 --- a/libs/apr/build/NWGNUtail.inc +++ /dev/null @@ -1,371 +0,0 @@ -# -# This contains final targets and should be included at the end of any -# NWGNUmakefile file -# - -# -# If we are going to create an nlm, make sure we have assigned variables to -# use during the link. -# -ifndef NLM_NAME -NLM_NAME = $(TARGET_nlm) -endif - -ifndef NLM_DESCRIPTION -NLM_DESCRIPTION = $(NLM_NAME) -endif - -ifndef NLM_THREAD_NAME -NLM_THREAD_NAME = $(NLM_NAME) Thread -endif - -ifndef NLM_SCREEN_NAME -NLM_SCREEN_NAME = DEFAULT -endif - -ifndef NLM_COPYRIGHT -NLM_COPYRIGHT = Licensed under the Apache License, Version 2.0 -endif - -ifeq "$(NLM_FLAGS)" "" -NLM_FLAGS = AUTOUNLOAD, PSEUDOPREEMPTION -endif - -ifeq "$(NLM_STACK_SIZE)" "" -NLM_STACK_SIZE = 65536 -endif - -ifeq "$(NLM_ENTRY_SYM)" "" -NLM_ENTRY_SYM = _LibCPrelude -endif - -ifeq "$(NLM_EXIT_SYM)" "" -NLM_EXIT_SYM = _LibCPostlude -endif - -ifeq "$(NLM_VERSION)" "" -NLM_VERSION = $(VERSION) -endif - -# -# Create dependency lists based on the files available -# - - -CCOPT_DEPENDS = \ - $(APRBUILD)/NWGNUhead.inc \ - $(APRBUILD)/NWGNUenvironment.inc \ - $(APRBUILD)/NWGNUtail.inc \ - NWGNUmakefile \ - $(CUSTOM_INI) \ - $(EOLIST) - -CPPOPT_DEPENDS = \ - $(APRBUILD)/NWGNUhead.inc \ - $(APRBUILD)/NWGNUenvironment.inc \ - $(APRBUILD)/NWGNUtail.inc \ - NWGNUmakefile \ - $(CUSTOM_INI) \ - $(EOLIST) - -$(NLM_NAME)_LINKOPT_DEPENDS = \ - $(TARGET_lib) \ - $(APRBUILD)/NWGNUenvironment.inc \ - NWGNUmakefile \ - $(APRBUILD)/NWGNUtail.inc \ - $(CUSTOM_INI) \ - $(VERSION_INC) \ - $(EOLIST) - -ifeq "$(words $(strip $(TARGET_lib)))" "1" -LIB_NAME = $(basename $(notdir $(TARGET_lib))) -$(LIB_NAME)_LIBLST_DEPENDS = \ - $(FILES_lib_objs) \ - $(APRBUILD)/NWGNUenvironment.inc \ - NWGNUmakefile \ - $(APRBUILD)/NWGNUtail.inc \ - $(CUSTOM_INI) \ - $(EOLIST) -endif - -ifeq "$(wildcard NWGNU$(LIB_NAME))" "NWGNU$(LIB_NAME)" -$(LIB_NAME)_LIBLST_DEPENDS += NWGNU$(LIB_NAME) -endif - -ifeq "$(wildcard NWGNU$(NLM_NAME))" "NWGNU$(NLM_NAME)" -$(NLM_NAME)_LINKOPT_DEPENDS += NWGNU$(NLM_NAME) -CCOPT_DEPENDS += NWGNU$(NLM_NAME) -CPPOPT_DEPENDS += NWGNU$(NLM_NAME) -endif - -# -# Generic compiler rules -# - -ifneq ($(MAKECMDGOALS),clean) -$(APRBUILD)/NWGNUversion.inc : $(APRBUILD)/nw_ver.awk $(APR)/include/apr_version.h -# @echo Generating $@ - @echo GEN $@ - @$(AWK) -f $^ > $@ - --include $(APRBUILD)/NWGNUversion.inc - -ifneq "$(strip $(VERSION_STR))" "" -VERSION_INC = $(APRBUILD)/NWGNUversion.inc -else -VERSION = 1,4,0 -VERSION_STR = 1.4.0 -VERSION_MAJMIN = 14 -endif -endif - -ifeq "$(words $(strip $(TARGET_nlm)))" "1" -INCLUDE_BLDCMDS = 1 -CCOPT_NAME = $(NLM_NAME) -endif - -ifeq "$(words $(strip $(TARGET_lib)))" "1" -INCLUDE_BLDCMDS = 1 -CCOPT_NAME = $(LIB_NAME) -endif - -ifeq "$(INCLUDE_BLDCMDS)" "1" - -$(OBJDIR)/%.o: %.c $(OBJDIR)/$(CCOPT_NAME)_cc.opt -# @echo Compiling $< - @echo $(DL)CC $<$(DL) - $(CC) -o $@ $< @$(word 2, $^) - -$(OBJDIR)/$(CCOPT_NAME)_cc.opt: $(CCOPT_DEPENDS) - $(call DEL,$@) -ifdef VERBOSE - @echo $(DL)CCOPT_DEPENDS=$^$(DL) -endif -# @echo Generating $@ - @echo $(DL)GEN $@$(DL) -ifneq "$(strip $(CFLAGS))" "" - @echo $(DL)$(CFLAGS)$(DL)>> $@ -endif -ifneq "$(strip $(XCFLAGS))" "" - @echo $(DL)$(XCFLAGS)$(DL)>> $@ -endif -ifneq "$(strip $(XINCDIRS))" "" - @echo $(DL)$(foreach xincdir,$(strip $(subst ;,$(SPACE),$(XINCDIRS))),-I$(xincdir))$(DL)>> $@ -endif -ifneq "$(strip $(INCDIRS))" "" - @echo $(DL)$(foreach incdir,$(strip $(subst ;,$(SPACE),$(INCDIRS))),-I$(incdir))$(DL)>> $@ -endif -ifneq "$(strip $(DEFINES))" "" - @echo $(DL)$(DEFINES)$(DL)>> $@ -endif -ifneq "$(strip $(XDEFINES))" "" - @echo $(DL)$(XDEFINES)$(DL)>> $@ -endif - -$(OBJDIR)/%.o: %.cpp $(OBJDIR)/$(CCOPT_NAME)_cpp.opt -# @echo Compiling $< - @echo $(DL)CPP $<$(DL) - $(CCP) -o $@ $< @$(word 2, $^) - -$(OBJDIR)/$(CCOPT_NAME)_cpp.opt: $(CPPOPT_DEPENDS) - $(call DEL,$@) -ifdef VERBOSE - @echo $(DL)CPPOPT_DEPENDS=$^$(DL) -endif -# @echo Generating $@ - @echo $(DL)GEN $@$(DL) -ifneq "$(strip $(CFLAGS))" "" - @echo $(DL)$(CFLAGS)$(DL)>> $@ -endif -ifneq "$(strip $(XCFLAGS))" "" - @echo $(DL)$(XCFLAGS)$(DL)>> $@ -endif -ifneq "$(strip $(XINCDIRS))" "" - @echo $(DL)$(foreach xincdir,$(strip $(subst ;,$(SPACE),$(XINCDIRS))),-I$(xincdir))$(DL)>> $@ -endif -ifneq "$(strip $(INCDIRS))" "" - @echo $(DL)$(foreach incdir,$(strip $(subst ;,$(SPACE),$(INCDIRS))),-I$(incdir))$(DL)>> $@ -endif -ifneq "$(strip $(DEFINES))" "" - @echo $(DL)$(DEFINES)$(DL)>> $@ -endif -ifneq "$(strip $(XDEFINES))" "" - @echo $(DL)$(XDEFINES)$(DL)>> $@ -endif - -endif # one target nlm or lib - -# -# Rules to build libraries -# - -# If we only have one target library then build it - -ifeq "$(words $(strip $(TARGET_lib)))" "1" - -$(TARGET_lib) : $(OBJDIR)/$(LIB_NAME)_lib.lst - $(call DEL,$@) -# @echo Generating $@ - @echo $(DL)AR $@$(DL) - $(LIB) -o $@ @$< - -$(OBJDIR)/aprlib_lib.lst: $(aprlib_LIBLST_DEPENDS) - $(call DEL,$@) -ifneq "$(strip $(FILES_lib_objs))" "" -# @echo Generating $@ - @echo $(DL)GEN $@$(DL) -ifdef VERBOSE - @echo $(DL)FILES_lib_objs=$(words $(FILES_lib_objs))$(DL) -endif - @echo $(DL)$(wordlist 1, 20, $(FILES_lib_objs))$(DL)>> $@ - @echo $(DL)$(wordlist 21, 40, $(FILES_lib_objs))$(DL)>> $@ - @echo $(DL)$(wordlist 41, 60, $(FILES_lib_objs))$(DL)>> $@ - @echo $(DL)$(wordlist 61, 80, $(FILES_lib_objs))$(DL)>> $@ -endif - -$(OBJDIR)/%_lib.lst: $($(LIB_NAME)_LIBLST_DEPENDS) - $(call DEL,$@) -ifneq "$(strip $(FILES_lib_objs))" "" -# @echo Generating $@ - @echo $(DL)GEN $@$(DL) -ifdef VERBOSE - @echo FILES_lib_objs=$(words $(FILES_lib_objs)) -endif - @echo $(DL)$(FILES_lib_objs)$(DL)>> $@ -endif - -else # We must have more than one target library so load the individual makefiles - -$(OBJDIR)/%.lib: NWGNU% $(APRBUILD)/NWGNUhead.inc $(APRBUILD)/NWGNUtail.inc $(APRBUILD)/NWGNUenvironment.inc FORCE - @echo $(DL)Calling $<$(DL) - $(MAKE) -f $< $(MAKECMDGOALS) RELEASE=$(RELEASE) - -endif - -# -# Rules to build nlms. -# - -# If we only have one target NLM then build it -ifeq "$(words $(strip $(TARGET_nlm)))" "1" - -$(TARGET_nlm) : $(FILES_nlm_objs) $(FILES_nlm_libs) $(OBJDIR)/$(NLM_NAME)_link.opt -# @echo Linking $@ - @echo $(DL)LINK $@$(DL) - $(LINK) @$(OBJDIR)/$(NLM_NAME)_link.opt - -# This will force the link option file to be rebuilt if we change the -# corresponding makefile - -$(OBJDIR)/$(NLM_NAME)_link.opt : $($(NLM_NAME)_LINKOPT_DEPENDS) - $(call DEL,$@) - $(call DEL,$(@:.opt=.def)) -# @echo Generating $@ - @echo $(DL)GEN $@$(DL) - @echo $(DL)# Do not edit this file - it is created by make!$(DL) > $@ - @echo $(DL)# All your changes will be lost!!$(DL)>> $@ - @echo $(DL)-warnings off$(DL)>> $@ - @echo $(DL)-zerobss$(DL)>> $@ - @echo $(DL)-o $(TARGET_nlm)$(DL)>> $@ -ifneq "$(FILE_nlm_copyright)" "" - @-$(CAT) $(FILE_nlm_copyright) >> $@ -endif -ifeq "$(RELEASE)" "debug" - @echo $(DL)-g$(DL)>> $@ - @echo $(DL)-sym internal$(DL)>> $@ - @echo $(DL)-sym codeview4$(DL)>> $@ - @echo $(DL)-osym $(OBJDIR)/$(NLM_NAME).sym$(DL)>> $@ -else - @echo $(DL)-sym internal$(DL)>> $@ -endif - @echo $(DL)-l $(APR)/$(OBJDIR)$(DL)>> $@ - @echo $(DL)-l $(APU)/$(OBJDIR)$(DL)>> $@ - @echo $(DL)-l $(APULDAP)/$(OBJDIR)$(DL)>> $@ - @echo $(DL)-l $(APUXML)/$(OBJDIR)$(DL)>> $@ - @echo $(DL)-l $(APR)/misc/netware$(DL)>> $@ - @echo $(DL)-l $(APR)$(DL)>> $@ - @echo $(DL)-l "$(METROWERKS)/Novell Support/Metrowerks Support/Libraries/Runtime"$(DL)>> $@ - @echo $(DL)-l "$(METROWERKS)/Novell Support/Metrowerks Support/Libraries/MSL C++"$(DL)>> $@ -ifneq "$(IPV6)" "" - @echo $(DL)-l $(NOVELLLIBC)/include/winsock/IPV6$(DL)>> $@ -endif - @echo $(DL)-l $(NOVELLLIBC)/imports$(DL)>> $@ -ifneq "$(LDAPSDK)" "" - @echo $(DL)-l $(LDAPSDK)/imports$(DL)>> $@ -endif - @echo $(DL)-nodefaults$(DL)>> $@ - @echo $(DL)-map $(OBJDIR)/$(NLM_NAME).map$(DL)>> $@ -ifneq "$(strip $(XLFLAGS))" "" - @echo $(DL)$(XLFLAGS)$(DL)>> $@ -endif -ifneq "$(strip $(FILES_nlm_objs))" "" - @echo $(DL)$(foreach objfile,$(strip $(FILES_nlm_objs)),$(objfile))$(DL)>> $@ -endif -ifneq "$(FILES_nlm_libs)" "" - @echo $(DL)$(foreach libfile, $(notdir $(strip $(FILES_nlm_libs))),-l$(libfile))$(DL)>> $@ -endif - @echo $(DL)-commandfile $(@:.opt=.def)$(DL)>> $@ - @echo $(DL)# Do not edit this file - it is created by make!$(DL)> $(@:.opt=.def) - @echo $(DL)# All your changes will be lost!!$(DL)>> $(@:.opt=.def) -ifneq "$(FILE_nlm_msg)" "" - @echo $(DL)Messages $(FILE_nlm_msg)$(DL)>> $(@:.opt=.def) -endif -ifneq "$(FILE_nlm_hlp)" "" - @echo $(DL)Help $(FILE_nlm_hlp)$(DL)>> $(@:.opt=.def) -endif -ifeq "$(FILE_nlm_copyright)" "" - @echo $(DL)copyright "$(NLM_COPYRIGHT)"$(DL)>> $(@:.opt=.def) -endif - @echo $(DL)description "$(NLM_DESCRIPTION)"$(DL)>> $(@:.opt=.def) - @echo $(DL)threadname "$(NLM_THREAD_NAME)"$(DL)>> $(@:.opt=.def) - @echo $(DL)screenname "$(NLM_SCREEN_NAME)"$(DL)>> $(@:.opt=.def) - @echo $(DL)stacksize $(subst K,000,$(subst k,K,$(strip $(NLM_STACK_SIZE))))$(DL)>> $(@:.opt=.def) - @echo $(DL)version $(NLM_VERSION) $(DL)>> $(@:.opt=.def) - @echo $(DL)$(strip $(NLM_FLAGS))$(DL)>> $(@:.opt=.def) - @echo $(DL)start $(NLM_ENTRY_SYM)$(DL)>> $(@:.opt=.def) - @echo $(DL)exit $(NLM_EXIT_SYM)$(DL)>> $(@:.opt=.def) -ifneq "$(NLM_CHECK_SYM)" "" - @echo $(DL)check $(NLM_CHECK_SYM)$(DL)>> $(@:.opt=.def) -endif -ifneq "$(FILES_nlm_modules)" "" - @echo $(DL)module $(foreach module,$(subst $(SPACE),$(COMMA),$(strip $(FILES_nlm_modules))),$(module))$(DL)>> $(@:.opt=.def) -endif -ifneq "$(FILES_nlm_Ximports)" "" - @echo $(DL)import $(foreach import,$(subst $(SPACE),$(COMMA),$(strip $(FILES_nlm_Ximports))),$(import))$(DL)>> $(@:.opt=.def) -endif -ifneq "$(FILES_nlm_exports)" "" - @echo $(DL)export $(foreach export,$(subst $(SPACE),$(COMMA),$(strip $(FILES_nlm_exports))),$(export))$(DL)>> $(@:.opt=.def) -endif -# if APACHE_UNIPROC is defined, don't include XDCData -ifndef APACHE_UNIPROC -ifneq "$(string $(XDCDATA))" "" - @echo $(DL)xdcdata $(XDCDATA)$(DL)>> $(@:.opt=.def) -else - @echo $(DL)xdcdata apr.xdc$(DL)>> $(@:.opt=.def) -endif -endif - -else # more than one target so look for individual makefiles. - -# Only include these if NO_LICENSE_FILE isn't set to prevent excessive -# recursion - -ifndef NO_LICENSE_FILE - -$(OBJDIR)/%.nlm: NWGNU% $(APRBUILD)/NWGNUhead.inc $(APRBUILD)/NWGNUtail.inc $(APRBUILD)/NWGNUenvironment.inc $(CUSTOM_INI) $(VERSION_INC) FORCE - @echo $(DL)Calling $<$(DL) - $(MAKE) -f $< $(MAKECMDGOALS) RELEASE=$(RELEASE) - @$(ECHONL) - -else - -$(TARGET_nlm): - -endif # NO_LICENSE_FILE - -endif # multiple targets - -$(INSTDIRS) :: - $(call MKDIR,$@) - - diff --git a/libs/apr/build/PrintPath b/libs/apr/build/PrintPath deleted file mode 100644 index 2a2b48b6..00000000 --- a/libs/apr/build/PrintPath +++ /dev/null @@ -1,130 +0,0 @@ -#!/bin/sh -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# -# Look for program[s] somewhere in $PATH. -# -# Options: -# -s -# Do not print out full pathname. (silent) -# -pPATHNAME -# Look in PATHNAME instead of $PATH -# -# Usage: -# PrintPath [-s] [-pPATHNAME] program [program ...] -# -# Initially written by Jim Jagielski for the Apache configuration mechanism -# (with kudos to Kernighan/Pike) - -## -# Some "constants" -## -pathname=$PATH -echo="yes" - -## -# Find out what OS we are running for later on -## -os=`(uname) 2>/dev/null` - -## -# Parse command line -## -for args in $* -do - case $args in - -s ) echo="no" ;; - -p* ) pathname="`echo $args | sed 's/^..//'`" ;; - * ) programs="$programs $args" ;; - esac -done - -## -# Now we make the adjustments required for OS/2 and everyone -# else :) -# -# First of all, all OS/2 programs have the '.exe' extension. -# Next, we adjust PATH (or what was given to us as PATH) to -# be whitespace separated directories. -# Finally, we try to determine the best flag to use for -# test/[] to look for an executable file. OS/2 just has '-r' -# but with other OSs, we do some funny stuff to check to see -# if test/[] knows about -x, which is the prefered flag. -## - -if [ "x$os" = "xOS/2" ] -then - ext=".exe" - pathname=`echo -E $pathname | - sed 's/^;/.;/ - s/;;/;.;/g - s/;$/;./ - s/;/ /g - s/\\\\/\\//g' ` - test_exec_flag="-r" -else - ext="" # No default extensions - pathname=`echo $pathname | - sed 's/^:/.:/ - s/::/:.:/g - s/:$/:./ - s/:/ /g' ` - # Here is how we test to see if test/[] can handle -x - testfile="pp.t.$$" - - cat > $testfile </dev/null`; then - test_exec_flag="-x" - else - test_exec_flag="-r" - fi - rm -f $testfile -fi - -for program in $programs -do - for path in $pathname - do - if [ $test_exec_flag $path/${program}${ext} ] && \ - [ ! -d $path/${program}${ext} ]; then - if [ "x$echo" = "xyes" ]; then - echo $path/${program}${ext} - fi - exit 0 - fi - -# Next try without extension (if one was used above) - if [ "x$ext" != "x" ]; then - if [ $test_exec_flag $path/${program} ] && \ - [ ! -d $path/${program} ]; then - if [ "x$echo" = "xyes" ]; then - echo $path/${program} - fi - exit 0 - fi - fi - done -done -exit 1 - diff --git a/libs/apr/build/aplibtool.c b/libs/apr/build/aplibtool.c deleted file mode 100644 index b5c6c3fe..00000000 --- a/libs/apr/build/aplibtool.c +++ /dev/null @@ -1,750 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include - -typedef char bool; -#define false 0 -#define true (!false) - -bool silent = false; -bool shared = false; -bool export_all = false; -enum mode_t { mCompile, mLink, mInstall }; -enum output_type_t { otGeneral, otObject, otProgram, otStaticLibrary, otDynamicLibrary }; - -#ifdef __EMX__ -# define SHELL_CMD "sh" -# define CC "gcc" -# define GEN_EXPORTS "emxexp" -# define DEF2IMPLIB_CMD "emximp" -# define SHARE_SW "-Zdll -Zmtd" -# define USE_OMF true -# define TRUNCATE_DLL_NAME -# define DYNAMIC_LIB_EXT "dll" -# define EXE_EXT ".exe" - -# if USE_OMF - /* OMF is the native format under OS/2 */ -# define STATIC_LIB_EXT "lib" -# define OBJECT_EXT "obj" -# define LIBRARIAN "emxomfar" -# else - /* but the alternative, a.out, can fork() which is sometimes necessary */ -# define STATIC_LIB_EXT "a" -# define OBJECT_EXT "o" -# define LIBRARIAN "ar" -# endif -#endif - - -typedef struct { - char *arglist[1024]; - int num_args; - enum mode_t mode; - enum output_type_t output_type; - char *output_name; - char *stub_name; - char *tmp_dirs[1024]; - int num_tmp_dirs; - char *obj_files[1024]; - int num_obj_files; -} cmd_data_t; - -void parse_args(int argc, char *argv[], cmd_data_t *cmd_data); -bool parse_long_opt(char *arg, cmd_data_t *cmd_data); -int parse_short_opt(char *arg, cmd_data_t *cmd_data); -bool parse_input_file_name(char *arg, cmd_data_t *cmd_data); -bool parse_output_file_name(char *arg, cmd_data_t *cmd_data); -void post_parse_fixup(cmd_data_t *cmd_data); -bool explode_static_lib(char *lib, cmd_data_t *cmd_data); -int execute_command(cmd_data_t *cmd_data); -char *shell_esc(const char *str); -void cleanup_tmp_dirs(cmd_data_t *cmd_data); -void generate_def_file(cmd_data_t *cmd_data); -char *nameof(char *fullpath); -char *truncate_dll_name(char *path); - - -int main(int argc, char *argv[]) -{ - int rc; - cmd_data_t cmd_data; - - memset(&cmd_data, 0, sizeof(cmd_data)); - cmd_data.mode = mCompile; - cmd_data.output_type = otGeneral; - - parse_args(argc, argv, &cmd_data); - rc = execute_command(&cmd_data); - - if (rc == 0 && cmd_data.stub_name) { - fopen(cmd_data.stub_name, "w"); - } - - cleanup_tmp_dirs(&cmd_data); - return rc; -} - - - -void parse_args(int argc, char *argv[], cmd_data_t *cmd_data) -{ - int a; - char *arg; - bool argused; - - for (a=1; a < argc; a++) { - arg = argv[a]; - argused = false; - - if (arg[0] == '-') { - if (arg[1] == '-') { - argused = parse_long_opt(arg + 2, cmd_data); - } else if (arg[1] == 'o' && a+1 < argc) { - cmd_data->arglist[cmd_data->num_args++] = arg; - arg = argv[++a]; - argused = parse_output_file_name(arg, cmd_data); - } else { - int num_used = parse_short_opt(arg + 1, cmd_data); - argused = num_used > 0; - - if (num_used > 1) { - a += num_used - 1; - } - } - } else { - argused = parse_input_file_name(arg, cmd_data); - } - - if (!argused) { - cmd_data->arglist[cmd_data->num_args++] = arg; - } - } - - post_parse_fixup(cmd_data); -} - - - -bool parse_long_opt(char *arg, cmd_data_t *cmd_data) -{ - char *equal_pos = strchr(arg, '='); - char var[50]; - char value[500]; - - if (equal_pos) { - strncpy(var, arg, equal_pos - arg); - var[equal_pos - arg] = 0; - strcpy(value, equal_pos + 1); - } else { - strcpy(var, arg); - } - - if (strcmp(var, "silent") == 0) { - silent = true; - } else if (strcmp(var, "mode") == 0) { - if (strcmp(value, "compile") == 0) { - cmd_data->mode = mCompile; - cmd_data->output_type = otObject; - } - - if (strcmp(value, "link") == 0) { - cmd_data->mode = mLink; - } - - if (strcmp(value, "install") == 0) { - cmd_data->mode = mInstall; - } - } else if (strcmp(var, "shared") == 0) { - shared = true; - } else if (strcmp(var, "export-all") == 0) { - export_all = true; - } else { - return false; - } - - return true; -} - - - -int parse_short_opt(char *arg, cmd_data_t *cmd_data) -{ - if (strcmp(arg, "export-dynamic") == 0) { - return 1; - } - - if (strcmp(arg, "module") == 0) { - return 1; - } - - if (strcmp(arg, "Zexe") == 0) { - return 1; - } - - if (strcmp(arg, "avoid-version") == 0) { - return 1; - } - - if (strcmp(arg, "prefer-pic") == 0) { - return 1; - } - - if (strcmp(arg, "prefer-non-pic") == 0) { - return 1; - } - - if (strcmp(arg, "version-info") == 0 ) { - return 2; - } - - if (strcmp(arg, "no-install") == 0) { - return 1; - } - - return 0; -} - - - -bool parse_input_file_name(char *arg, cmd_data_t *cmd_data) -{ - char *ext = strrchr(arg, '.'); - char *name = strrchr(arg, '/'); - char *newarg; - - if (!ext) { - return false; - } - - ext++; - - if (name == NULL) { - name = strrchr(arg, '\\'); - - if (name == NULL) { - name = arg; - } else { - name++; - } - } else { - name++; - } - - if (strcmp(ext, "lo") == 0) { - newarg = (char *)malloc(strlen(arg) + 10); - strcpy(newarg, arg); - strcpy(newarg + (ext - arg), OBJECT_EXT); - cmd_data->arglist[cmd_data->num_args++] = newarg; - cmd_data->obj_files[cmd_data->num_obj_files++] = newarg; - return true; - } - - if (strcmp(ext, "la") == 0) { - newarg = (char *)malloc(strlen(arg) + 10); - strcpy(newarg, arg); - newarg[pathlen] = 0; - strcat(newarg, ".libs/"); - - if (strncmp(name, "lib", 3) == 0) { - name += 3; - } - - strcat(newarg, name); - ext = strrchr(newarg, '.') + 1; - - if (shared && cmd_data->mode == mInstall) { - strcpy(ext, DYNAMIC_LIB_EXT); - newarg = truncate_dll_name(newarg); - } else { - strcpy(ext, STATIC_LIB_EXT); - } - - cmd_data->arglist[cmd_data->num_args++] = newarg; - return true; - } - - if (strcmp(ext, "c") == 0) { - if (cmd_data->stub_name == NULL) { - cmd_data->stub_name = (char *)malloc(strlen(arg) + 4); - strcpy(cmd_data->stub_name, arg); - strcpy(strrchr(cmd_data->stub_name, '.') + 1, "lo"); - } - } - - if (strcmp(name, CC) == 0 || strcmp(name, CC EXE_EXT) == 0) { - if (cmd_data->output_type == otGeneral) { - cmd_data->output_type = otObject; - } - } - - return false; -} - - - -bool parse_output_file_name(char *arg, cmd_data_t *cmd_data) -{ - char *name = strrchr(arg, '/'); - char *ext = strrchr(arg, '.'); - char *newarg = NULL, *newext; - - if (name == NULL) { - name = strrchr(arg, '\\'); - - if (name == NULL) { - name = arg; - } else { - name++; - } - } else { - name++; - } - - if (!ext) { - cmd_data->stub_name = arg; - cmd_data->output_type = otProgram; - newarg = (char *)malloc(strlen(arg) + 5); - strcpy(newarg, arg); - strcat(newarg, EXE_EXT); - cmd_data->arglist[cmd_data->num_args++] = newarg; - cmd_data->output_name = newarg; - return true; - } - - ext++; - - if (strcmp(ext, "la") == 0) { - cmd_data->stub_name = arg; - cmd_data->output_type = shared ? otDynamicLibrary : otStaticLibrary; - newarg = (char *)malloc(strlen(arg) + 10); - mkdir(".libs", 0); - strcpy(newarg, ".libs/"); - - if (strncmp(arg, "lib", 3) == 0) { - arg += 3; - } - - strcat(newarg, arg); - newext = strrchr(newarg, '.') + 1; - strcpy(newext, shared ? DYNAMIC_LIB_EXT : STATIC_LIB_EXT); - -#ifdef TRUNCATE_DLL_NAME - if (shared) { - newarg = truncate_dll_name(newarg); - } -#endif - - cmd_data->arglist[cmd_data->num_args++] = newarg; - cmd_data->output_name = newarg; - return true; - } - - if (strcmp(ext, "lo") == 0) { - cmd_data->stub_name = arg; - cmd_data->output_type = otObject; - newarg = (char *)malloc(strlen(arg) + 2); - strcpy(newarg, arg); - ext = strrchr(newarg, '.') + 1; - strcpy(ext, OBJECT_EXT); - cmd_data->arglist[cmd_data->num_args++] = newarg; - cmd_data->output_name = newarg; - return true; - } - - return false; -} - - - -void post_parse_fixup(cmd_data_t *cmd_data) -{ - int a; - char *arg; - char *ext; - - if (cmd_data->output_type == otStaticLibrary && cmd_data->mode == mLink) { - /* We do a real hatchet job on the args when making a static library - * removing all compiler switches & any other cruft that ar won't like - * We also need to explode any libraries listed - */ - - for (a=0; a < cmd_data->num_args; a++) { - arg = cmd_data->arglist[a]; - - if (arg) { - ext = strrchr(arg, '.'); - - if (ext) { - ext++; - } - - if (arg[0] == '-') { - cmd_data->arglist[a] = NULL; - - if (strcmp(arg, "-rpath") == 0 && a+1 < cmd_data->num_args) { - cmd_data->arglist[a+1] = NULL; - } - - if (strcmp(arg, "-R") == 0 && a+1 < cmd_data->num_args) { - cmd_data->arglist[a+1] = NULL; - } - - if (strcmp(arg, "-version-info") == 0 && a+1 < cmd_data->num_args) { - cmd_data->arglist[a+1] = NULL; - } - - if (strcmp(arg, "-Zstack") == 0 && a+1 < cmd_data->num_args) { - cmd_data->arglist[a+1] = NULL; - } - - if (strcmp(arg, "-o") == 0) { - a++; - } - } - - if (strcmp(arg, CC) == 0 || strcmp(arg, CC EXE_EXT) == 0) { - cmd_data->arglist[a] = LIBRARIAN " cr"; - } - - if (ext) { - if (strcmp(ext, "h") == 0 || strcmp(ext, "c") == 0) { - /* ignore source files, they don't belong in a library */ - cmd_data->arglist[a] = NULL; - } - - if (strcmp(ext, STATIC_LIB_EXT) == 0) { - cmd_data->arglist[a] = NULL; - explode_static_lib(arg, cmd_data); - } - } - } - } - } - - if (cmd_data->output_type == otDynamicLibrary) { - for (a=0; a < cmd_data->num_args; a++) { - arg = cmd_data->arglist[a]; - - if (arg) { - if (strcmp(arg, "-rpath") == 0 && a+1 < cmd_data->num_args) { - cmd_data->arglist[a] = NULL; - cmd_data->arglist[a+1] = NULL; - } - } - } - - if (export_all) { - generate_def_file(cmd_data); - } - } - -#if USE_OMF - if (cmd_data->output_type == otObject || - cmd_data->output_type == otProgram || - cmd_data->output_type == otDynamicLibrary) { - cmd_data->arglist[cmd_data->num_args++] = "-Zomf"; - } -#endif - - if (shared && (cmd_data->output_type == otObject || cmd_data->output_type == otDynamicLibrary)) { - cmd_data->arglist[cmd_data->num_args++] = SHARE_SW; - } -} - - - -int execute_command(cmd_data_t *cmd_data) -{ - int target = 0; - char *command; - int a, total_len = 0; - char *args[4]; - - for (a=0; a < cmd_data->num_args; a++) { - if (cmd_data->arglist[a]) { - total_len += strlen(cmd_data->arglist[a]) + 1; - } - } - - command = (char *)malloc( total_len ); - command[0] = 0; - - for (a=0; a < cmd_data->num_args; a++) { - if (cmd_data->arglist[a]) { - strcat(command, cmd_data->arglist[a]); - strcat(command, " "); - } - } - - command[strlen(command)-1] = 0; - - if (!silent) { - puts(command); - } - - cmd_data->num_args = target; - cmd_data->arglist[cmd_data->num_args] = NULL; - command = shell_esc(command); - - args[0] = SHELL_CMD; - args[1] = "-c"; - args[2] = command; - args[3] = NULL; - return spawnvp(P_WAIT, args[0], args); -} - - - -char *shell_esc(const char *str) -{ - char *cmd; - unsigned char *d; - const unsigned char *s; - - cmd = (char *)malloc(2 * strlen(str) + 1); - d = (unsigned char *)cmd; - s = (const unsigned char *)str; - - for (; *s; ++s) { - if (*s == '"' || *s == '\\') { - *d++ = '\\'; - } - *d++ = *s; - } - - *d = '\0'; - return cmd; -} - - - -bool explode_static_lib(char *lib, cmd_data_t *cmd_data) -{ - char tmpdir[1024]; - char savewd[1024]; - char cmd[1024]; - char *name; - DIR *dir; - struct dirent *entry; - - strcpy(tmpdir, lib); - strcat(tmpdir, ".exploded"); - - mkdir(tmpdir, 0); - cmd_data->tmp_dirs[cmd_data->num_tmp_dirs++] = strdup(tmpdir); - getcwd(savewd, sizeof(savewd)); - - if (chdir(tmpdir) != 0) - return false; - - strcpy(cmd, LIBRARIAN " x "); - name = strrchr(lib, '/'); - - if (name) { - name++; - } else { - name = lib; - } - - strcat(cmd, "../"); - strcat(cmd, name); - system(cmd); - chdir(savewd); - dir = opendir(tmpdir); - - while ((entry = readdir(dir)) != NULL) { - if (entry->d_name[0] != '.') { - strcpy(cmd, tmpdir); - strcat(cmd, "/"); - strcat(cmd, entry->d_name); - cmd_data->arglist[cmd_data->num_args++] = strdup(cmd); - } - } - - closedir(dir); - return true; -} - - - -void cleanup_tmp_dir(char *dirname) -{ - DIR *dir; - struct dirent *entry; - char fullname[1024]; - - dir = opendir(dirname); - - if (dir == NULL) - return; - - while ((entry = readdir(dir)) != NULL) { - if (entry->d_name[0] != '.') { - strcpy(fullname, dirname); - strcat(fullname, "/"); - strcat(fullname, entry->d_name); - remove(fullname); - } - } - - rmdir(dirname); -} - - - -void cleanup_tmp_dirs(cmd_data_t *cmd_data) -{ - int d; - - for (d=0; d < cmd_data->num_tmp_dirs; d++) { - cleanup_tmp_dir(cmd_data->tmp_dirs[d]); - } -} - - - -void generate_def_file(cmd_data_t *cmd_data) -{ - char def_file[1024]; - char implib_file[1024]; - char *ext; - FILE *hDef; - char *export_args[1024]; - int num_export_args = 0; - char *cmd; - int cmd_size = 0; - int a; - - if (cmd_data->output_name) { - strcpy(def_file, cmd_data->output_name); - strcat(def_file, ".def"); - hDef = fopen(def_file, "w"); - - if (hDef != NULL) { - fprintf(hDef, "LIBRARY '%s' INITINSTANCE\n", nameof(cmd_data->output_name)); - fprintf(hDef, "DATA NONSHARED\n"); - fprintf(hDef, "EXPORTS\n"); - fclose(hDef); - - for (a=0; a < cmd_data->num_obj_files; a++) { - cmd_size += strlen(cmd_data->obj_files[a]) + 1; - } - - cmd_size += strlen(GEN_EXPORTS) + strlen(def_file) + 3; - cmd = (char *)malloc(cmd_size); - strcpy(cmd, GEN_EXPORTS); - - for (a=0; a < cmd_data->num_obj_files; a++) { - strcat(cmd, " "); - strcat(cmd, cmd_data->obj_files[a] ); - } - - strcat(cmd, ">>"); - strcat(cmd, def_file); - puts(cmd); - export_args[num_export_args++] = SHELL_CMD; - export_args[num_export_args++] = "-c"; - export_args[num_export_args++] = cmd; - export_args[num_export_args++] = NULL; - spawnvp(P_WAIT, export_args[0], export_args); - cmd_data->arglist[cmd_data->num_args++] = strdup(def_file); - - /* Now make an import library for the dll */ - num_export_args = 0; - export_args[num_export_args++] = DEF2IMPLIB_CMD; - export_args[num_export_args++] = "-o"; - - strcpy(implib_file, ".libs/"); - strcat(implib_file, cmd_data->stub_name); - ext = strrchr(implib_file, '.'); - - if (ext) - *ext = 0; - - strcat(implib_file, "."); - strcat(implib_file, STATIC_LIB_EXT); - - export_args[num_export_args++] = implib_file; - export_args[num_export_args++] = def_file; - export_args[num_export_args++] = NULL; - spawnvp(P_WAIT, export_args[0], export_args); - } - } -} - - - -/* returns just a file's name without path or extension */ -char *nameof(char *fullpath) -{ - char buffer[1024]; - char *ext; - char *name = strrchr(fullpath, '/'); - - if (name == NULL) { - name = strrchr(fullpath, '\\'); - } - - if (name == NULL) { - name = fullpath; - } else { - name++; - } - - strcpy(buffer, name); - ext = strrchr(buffer, '.'); - - if (ext) { - *ext = 0; - return strdup(buffer); - } - - return name; -} - - - -char *truncate_dll_name(char *path) -{ - /* Cut DLL name down to 8 characters after removing any mod_ prefix */ - char *tmppath = strdup(path); - char *newname = strrchr(tmppath, '/') + 1; - char *ext = strrchr(tmppath, '.'); - int len; - - if (ext == NULL) - return tmppath; - - len = ext - newname; - - if (strncmp(newname, "mod_", 4) == 0) { - strcpy(newname, newname + 4); - len -= 4; - } - - if (len > 8) { - strcpy(newname + 8, strchr(newname, '.')); - } - - return tmppath; -} diff --git a/libs/apr/build/apr_common.m4 b/libs/apr/build/apr_common.m4 deleted file mode 100644 index 50dbfacb..00000000 --- a/libs/apr/build/apr_common.m4 +++ /dev/null @@ -1,985 +0,0 @@ -dnl -------------------------------------------------------- -*- autoconf -*- -dnl Licensed to the Apache Software Foundation (ASF) under one or more -dnl contributor license agreements. See the NOTICE file distributed with -dnl this work for additional information regarding copyright ownership. -dnl The ASF licenses this file to You under the Apache License, Version 2.0 -dnl (the "License"); you may not use this file except in compliance with -dnl the License. You may obtain a copy of the License at -dnl -dnl http://www.apache.org/licenses/LICENSE-2.0 -dnl -dnl Unless required by applicable law or agreed to in writing, software -dnl distributed under the License is distributed on an "AS IS" BASIS, -dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -dnl See the License for the specific language governing permissions and -dnl limitations under the License. - -dnl -dnl apr_common.m4: APR's general-purpose autoconf macros -dnl - -dnl -dnl APR_CONFIG_NICE(filename) -dnl -dnl Saves a snapshot of the configure command-line for later reuse -dnl -AC_DEFUN([APR_CONFIG_NICE], [ - rm -f $1 - cat >$1<> $1 - fi - if test -n "$CFLAGS"; then - echo "CFLAGS=\"$CFLAGS\"; export CFLAGS" >> $1 - fi - if test -n "$CPPFLAGS"; then - echo "CPPFLAGS=\"$CPPFLAGS\"; export CPPFLAGS" >> $1 - fi - if test -n "$LDFLAGS"; then - echo "LDFLAGS=\"$LDFLAGS\"; export LDFLAGS" >> $1 - fi - if test -n "$LTFLAGS"; then - echo "LTFLAGS=\"$LTFLAGS\"; export LTFLAGS" >> $1 - fi - if test -n "$LIBS"; then - echo "LIBS=\"$LIBS\"; export LIBS" >> $1 - fi - if test -n "$INCLUDES"; then - echo "INCLUDES=\"$INCLUDES\"; export INCLUDES" >> $1 - fi - if test -n "$NOTEST_CFLAGS"; then - echo "NOTEST_CFLAGS=\"$NOTEST_CFLAGS\"; export NOTEST_CFLAGS" >> $1 - fi - if test -n "$NOTEST_CPPFLAGS"; then - echo "NOTEST_CPPFLAGS=\"$NOTEST_CPPFLAGS\"; export NOTEST_CPPFLAGS" >> $1 - fi - if test -n "$NOTEST_LDFLAGS"; then - echo "NOTEST_LDFLAGS=\"$NOTEST_LDFLAGS\"; export NOTEST_LDFLAGS" >> $1 - fi - if test -n "$NOTEST_LIBS"; then - echo "NOTEST_LIBS=\"$NOTEST_LIBS\"; export NOTEST_LIBS" >> $1 - fi - - # Retrieve command-line arguments. - eval "set x $[0] $ac_configure_args" - shift - - for arg - do - APR_EXPAND_VAR(arg, $arg) - echo "\"[$]arg\" \\" >> $1 - done - echo '"[$]@"' >> $1 - chmod +x $1 -])dnl - -dnl APR_MKDIR_P_CHECK(fallback-mkdir-p) -dnl checks whether mkdir -p works -AC_DEFUN([APR_MKDIR_P_CHECK], [ - AC_CACHE_CHECK(for working mkdir -p, ac_cv_mkdir_p,[ - test -d conftestdir && rm -rf conftestdir - mkdir -p conftestdir/somedir >/dev/null 2>&1 - if test -d conftestdir/somedir; then - ac_cv_mkdir_p=yes - else - ac_cv_mkdir_p=no - fi - rm -rf conftestdir - ]) - if test "$ac_cv_mkdir_p" = "yes"; then - mkdir_p="mkdir -p" - else - mkdir_p="$1" - fi -]) - -dnl -dnl APR_SUBDIR_CONFIG(dir [, sub-package-cmdline-args, args-to-drop]) -dnl -dnl dir: directory to find configure in -dnl sub-package-cmdline-args: arguments to add to the invocation (optional) -dnl args-to-drop: arguments to drop from the invocation (optional) -dnl -dnl Note: This macro relies on ac_configure_args being set properly. -dnl -dnl The args-to-drop argument is shoved into a case statement, so -dnl multiple arguments can be separated with a |. -dnl -dnl Note: Older versions of autoconf do not single-quote args, while 2.54+ -dnl places quotes around every argument. So, if you want to drop the -dnl argument called --enable-layout, you must pass the third argument as: -dnl [--enable-layout=*|\'--enable-layout=*] -dnl -dnl Trying to optimize this is left as an exercise to the reader who wants -dnl to put up with more autoconf craziness. I give up. -dnl -AC_DEFUN([APR_SUBDIR_CONFIG], [ - # save our work to this point; this allows the sub-package to use it - AC_CACHE_SAVE - - echo "configuring package in $1 now" - ac_popdir=`pwd` - apr_config_subdirs="$1" - test -d $1 || $mkdir_p $1 - ac_abs_srcdir=`(cd $srcdir/$1 && pwd)` - cd $1 - -changequote(, )dnl - # A "../" for each directory in /$config_subdirs. - ac_dots=`echo $apr_config_subdirs|sed -e 's%^\./%%' -e 's%[^/]$%&/%' -e 's%[^/]*/%../%g'` -changequote([, ])dnl - - # Make the cache file pathname absolute for the subdirs - # required to correctly handle subdirs that might actually - # be symlinks - case "$cache_file" in - /*) # already absolute - ac_sub_cache_file=$cache_file ;; - *) # Was relative path. - ac_sub_cache_file="$ac_popdir/$cache_file" ;; - esac - - ifelse($3, [], [apr_configure_args=$ac_configure_args],[ - apr_configure_args= - apr_sep= - for apr_configure_arg in $ac_configure_args - do - case "$apr_configure_arg" in - $3) - continue ;; - esac - apr_configure_args="$apr_configure_args$apr_sep'$apr_configure_arg'" - apr_sep=" " - done - ]) - - dnl autoconf doesn't add --silent to ac_configure_args; explicitly pass it - test "x$silent" = "xyes" && apr_configure_args="$apr_configure_args --silent" - - dnl AC_CONFIG_SUBDIRS silences option warnings, emulate this for 2.62 - apr_configure_args="--disable-option-checking $apr_configure_args" - - dnl The eval makes quoting arguments work - specifically the second argument - dnl where the quoting mechanisms used is "" rather than []. - dnl - dnl We need to execute another shell because some autoconf/shell combinations - dnl will choke after doing repeated APR_SUBDIR_CONFIG()s. (Namely Solaris - dnl and autoconf-2.54+) - if eval $SHELL $ac_abs_srcdir/configure $apr_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_abs_srcdir $2 - then : - echo "$1 configured properly" - else - echo "configure failed for $1" - exit 1 - fi - - cd $ac_popdir - - # grab any updates from the sub-package - AC_CACHE_LOAD -])dnl - -dnl -dnl APR_SAVE_THE_ENVIRONMENT(variable_name) -dnl -dnl Stores the variable (usually a Makefile macro) for later restoration -dnl -AC_DEFUN([APR_SAVE_THE_ENVIRONMENT], [ - apr_ste_save_$1="$$1" -])dnl - -dnl -dnl APR_RESTORE_THE_ENVIRONMENT(variable_name, prefix_) -dnl -dnl Uses the previously saved variable content to figure out what configure -dnl has added to the variable, moving the new bits to prefix_variable_name -dnl and restoring the original variable contents. This makes it possible -dnl for a user to override configure when it does something stupid. -dnl -AC_DEFUN([APR_RESTORE_THE_ENVIRONMENT], [ -dnl Check whether $apr_ste_save_$1 is empty or -dnl only whitespace. The verbatim "X" is token number 1, -dnl the following whitespace will be ignored. -set X $apr_ste_save_$1 -if test ${#} -eq 1; then - $2$1="$$1" - $1= -else - if test "x$apr_ste_save_$1" = "x$$1"; then - $2$1= - else - $2$1=`echo "$$1" | sed -e "s%${apr_ste_save_$1}%%"` - $1="$apr_ste_save_$1" - fi -fi -if test "x$silent" != "xyes"; then - echo " restoring $1 to \"$$1\"" - echo " setting $2$1 to \"$$2$1\"" -fi -AC_SUBST($2$1) -])dnl - -dnl -dnl APR_SETIFNULL(variable, value) -dnl -dnl Set variable iff it's currently null -dnl -AC_DEFUN([APR_SETIFNULL], [ - if test -z "$$1"; then - test "x$silent" != "xyes" && echo " setting $1 to \"$2\"" - $1="$2" - fi -])dnl - -dnl -dnl APR_SETVAR(variable, value) -dnl -dnl Set variable no matter what -dnl -AC_DEFUN([APR_SETVAR], [ - test "x$silent" != "xyes" && echo " forcing $1 to \"$2\"" - $1="$2" -])dnl - -dnl -dnl APR_ADDTO(variable, value) -dnl -dnl Add value to variable -dnl -AC_DEFUN([APR_ADDTO], [ - if test "x$$1" = "x"; then - test "x$silent" != "xyes" && echo " setting $1 to \"$2\"" - $1="$2" - else - apr_addto_bugger="$2" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $$1; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to $1" - $1="$$1 $i" - fi - done - fi -])dnl - -dnl -dnl APR_REMOVEFROM(variable, value) -dnl -dnl Remove a value from a variable -dnl -AC_DEFUN([APR_REMOVEFROM], [ - if test "x$$1" = "x$2"; then - test "x$silent" != "xyes" && echo " nulling $1" - $1="" - else - apr_new_bugger="" - apr_removed=0 - for i in $$1; do - if test "x$i" != "x$2"; then - apr_new_bugger="$apr_new_bugger $i" - else - apr_removed=1 - fi - done - if test $apr_removed = "1"; then - test "x$silent" != "xyes" && echo " removed \"$2\" from $1" - $1=$apr_new_bugger - fi - fi -]) dnl - -dnl -dnl APR_CHECK_DEFINE_FILES( symbol, header_file [header_file ...] ) -dnl -AC_DEFUN([APR_CHECK_DEFINE_FILES], [ - AC_CACHE_CHECK([for $1 in $2],ac_cv_define_$1,[ - ac_cv_define_$1=no - for curhdr in $2 - do - AC_EGREP_CPP(YES_IS_DEFINED, [ -#include <$curhdr> -#ifdef $1 -YES_IS_DEFINED -#endif - ], ac_cv_define_$1=yes) - done - ]) - if test "$ac_cv_define_$1" = "yes"; then - AC_DEFINE(HAVE_$1, 1, [Define if $1 is defined]) - fi -]) - - -dnl -dnl APR_CHECK_DEFINE(symbol, header_file) -dnl -AC_DEFUN([APR_CHECK_DEFINE], [ - AC_CACHE_CHECK([for $1 in $2],ac_cv_define_$1,[ - AC_EGREP_CPP(YES_IS_DEFINED, [ -#include <$2> -#ifdef $1 -YES_IS_DEFINED -#endif - ], ac_cv_define_$1=yes, ac_cv_define_$1=no) - ]) - if test "$ac_cv_define_$1" = "yes"; then - AC_DEFINE(HAVE_$1, 1, [Define if $1 is defined in $2]) - fi -]) - -dnl -dnl APR_CHECK_APR_DEFINE( symbol ) -dnl -AC_DEFUN([APR_CHECK_APR_DEFINE], [ -apr_old_cppflags=$CPPFLAGS -CPPFLAGS="$CPPFLAGS $INCLUDES" -AC_EGREP_CPP(YES_IS_DEFINED, [ -#include -#if $1 -YES_IS_DEFINED -#endif -], ac_cv_define_$1=yes, ac_cv_define_$1=no) -CPPFLAGS=$apr_old_cppflags -]) - -dnl APR_CHECK_FILE(filename); set ac_cv_file_filename to -dnl "yes" if 'filename' is readable, else "no". -dnl @deprecated! - use AC_CHECK_FILE instead -AC_DEFUN([APR_CHECK_FILE], [ -dnl Pick a safe variable name -define([apr_cvname], ac_cv_file_[]translit([$1], [./+-], [__p_])) -AC_CACHE_CHECK([for $1], [apr_cvname], -[if test -r $1; then - apr_cvname=yes - else - apr_cvname=no - fi]) -]) - -define(APR_IFALLYES,[dnl -ac_rc=yes -for ac_spec in $1; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - $2 -else - : - $3 -fi -]) - - -define(APR_BEGIN_DECISION,[dnl -ac_decision_item='$1' -ac_decision_msg='FAILED' -ac_decision='' -]) - - -AC_DEFUN([APR_DECIDE],[dnl -dnl Define the flag (or not) in apr_private.h via autoheader -AH_TEMPLATE($1, [Define if $2 will be used]) -ac_decision='$1' -ac_decision_msg='$2' -ac_decision_$1=yes -ac_decision_$1_msg='$2' -]) - - -define(APR_DECISION_OVERRIDE,[dnl - ac_decision='' - for ac_item in $1; do - eval "ac_decision_this=\$ac_decision_${ac_item}" - if test ".$ac_decision_this" = .yes; then - ac_decision=$ac_item - eval "ac_decision_msg=\$ac_decision_${ac_item}_msg" - fi - done -]) - - -define(APR_DECISION_FORCE,[dnl -ac_decision="$1" -eval "ac_decision_msg=\"\$ac_decision_${ac_decision}_msg\"" -]) - - -define(APR_END_DECISION,[dnl -if test ".$ac_decision" = .; then - echo "[$]0:Error: decision on $ac_decision_item failed" 1>&2 - exit 1 -else - if test ".$ac_decision_msg" = .; then - ac_decision_msg="$ac_decision" - fi - AC_DEFINE_UNQUOTED(${ac_decision_item}) - AC_MSG_RESULT([decision on $ac_decision_item... $ac_decision_msg]) -fi -]) - - -dnl -dnl APR_CHECK_SIZEOF_EXTENDED(INCLUDES, TYPE [, CROSS_SIZE]) -dnl -dnl A variant of AC_CHECK_SIZEOF which allows the checking of -dnl sizes of non-builtin types -dnl -AC_DEFUN([APR_CHECK_SIZEOF_EXTENDED], -[changequote(<<, >>)dnl -dnl The name to #define. -define(<>, translit(sizeof_$2, [a-z *], [A-Z_P]))dnl -dnl The cache variable name. -define(<>, translit(ac_cv_sizeof_$2, [ *], [_p]))dnl -changequote([, ])dnl -AC_MSG_CHECKING(size of $2) -AC_CACHE_VAL(AC_CV_NAME, -[AC_TRY_RUN([#include -$1 -main() -{ - FILE *f=fopen("conftestval", "w"); - if (!f) exit(1); - fprintf(f, "%d\n", sizeof($2)); - exit(0); -}], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$3],,, -AC_CV_NAME=$3))])dnl -AC_MSG_RESULT($AC_CV_NAME) -AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The size of ]$2) -undefine([AC_TYPE_NAME])dnl -undefine([AC_CV_NAME])dnl -]) - - -dnl -dnl APR_TRY_COMPILE_NO_WARNING(INCLUDES, FUNCTION-BODY, -dnl [ACTIONS-IF-NO-WARNINGS], [ACTIONS-IF-WARNINGS]) -dnl -dnl Tries a compile test with warnings activated so that the result -dnl is false if the code doesn't compile cleanly. For compilers -dnl where it is not known how to activate a "fail-on-error" mode, -dnl it is undefined which of the sets of actions will be run. -dnl -AC_DEFUN([APR_TRY_COMPILE_NO_WARNING], -[apr_save_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS $CFLAGS_WARN" - if test "$ac_cv_prog_gcc" = "yes"; then - CFLAGS="$CFLAGS -Werror" - fi - AC_COMPILE_IFELSE( - [AC_LANG_SOURCE( - [#include "confdefs.h" - ] - [[$1]] - [int main(int argc, const char *const *argv) {] - [[$2]] - [ return 0; }] - )], - [$3], [$4]) - CFLAGS=$apr_save_CFLAGS -]) - -dnl -dnl APR_CHECK_STRERROR_R_RC -dnl -dnl Decide which style of retcode is used by this system's -dnl strerror_r(). It either returns int (0 for success, -1 -dnl for failure), or it returns a pointer to the error -dnl string. -dnl -dnl -AC_DEFUN([APR_CHECK_STRERROR_R_RC], [ -AC_MSG_CHECKING(for type of return code from strerror_r) -AC_TRY_RUN([ -#include -#include -#include -main() -{ - char buf[1024]; - if (strerror_r(ERANGE, buf, sizeof buf) < 1) { - exit(0); - } - else { - exit(1); - } -}], [ - ac_cv_strerror_r_rc_int=yes ], [ - ac_cv_strerror_r_rc_int=no ], [ - ac_cv_strerror_r_rc_int=no ] ) -if test "x$ac_cv_strerror_r_rc_int" = xyes; then - AC_DEFINE(STRERROR_R_RC_INT, 1, [Define if strerror returns int]) - msg="int" -else - msg="pointer" -fi -AC_MSG_RESULT([$msg]) -] ) - -dnl -dnl APR_CHECK_DIRENT_INODE -dnl -dnl Decide if d_fileno or d_ino are available in the dirent -dnl structure on this platform. Single UNIX Spec says d_ino, -dnl BSD uses d_fileno. Undef to find the real beast. -dnl -AC_DEFUN([APR_CHECK_DIRENT_INODE], [ -AC_CACHE_CHECK([for inode member of struct dirent], apr_cv_dirent_inode, [ -apr_cv_dirent_inode=no -AC_TRY_COMPILE([ -#include -#include -],[ -#ifdef d_ino -#undef d_ino -#endif -struct dirent de; de.d_fileno; -], apr_cv_dirent_inode=d_fileno) -if test "$apr_cv_dirent_inode" = "no"; then -AC_TRY_COMPILE([ -#include -#include -],[ -#ifdef d_fileno -#undef d_fileno -#endif -struct dirent de; de.d_ino; -], apr_cv_dirent_inode=d_ino) -fi -]) -if test "$apr_cv_dirent_inode" != "no"; then - AC_DEFINE_UNQUOTED(DIRENT_INODE, $apr_cv_dirent_inode, - [Define if struct dirent has an inode member]) -fi -]) - -dnl -dnl APR_CHECK_DIRENT_TYPE -dnl -dnl Decide if d_type is available in the dirent structure -dnl on this platform. Not part of the Single UNIX Spec. -dnl Note that this is worthless without DT_xxx macros, so -dnl look for one while we are at it. -dnl -AC_DEFUN([APR_CHECK_DIRENT_TYPE], [ -AC_CACHE_CHECK([for file type member of struct dirent], apr_cv_dirent_type,[ -apr_cv_dirent_type=no -AC_TRY_COMPILE([ -#include -#include -],[ -struct dirent de; de.d_type = DT_REG; -], apr_cv_dirent_type=d_type) -]) -if test "$apr_cv_dirent_type" != "no"; then - AC_DEFINE_UNQUOTED(DIRENT_TYPE, $apr_cv_dirent_type, - [Define if struct dirent has a d_type member]) -fi -]) - -dnl the following is a newline, a space, a tab, and a backslash (the -dnl backslash is used by the shell to skip newlines, but m4 sees it; -dnl treat it like whitespace). -dnl WARNING: don't reindent these lines, or the space/tab will be lost! -define([apr_whitespace],[ - \]) - -dnl -dnl APR_COMMA_ARGS(ARG1 ...) -dnl convert the whitespace-separated arguments into comman-separated -dnl arguments. -dnl -dnl APR_FOREACH(CODE-BLOCK, ARG1, ARG2, ...) -dnl subsitute CODE-BLOCK for each ARG[i]. "eachval" will be set to ARG[i] -dnl within each iteration. -dnl -changequote({,}) -define({APR_COMMA_ARGS},{patsubst([$}{1],[[}apr_whitespace{]+],[,])}) -define({APR_FOREACH}, - {ifelse($}{2,,, - [define([eachval], - $}{2)$}{1[]APR_FOREACH([$}{1], - builtin([shift], - builtin([shift], $}{@)))])}) -changequote([,]) - -dnl APR_FLAG_HEADERS(HEADER-FILE ... [, FLAG-TO-SET ] [, "yes" ]) -dnl we set FLAG-TO-SET to 1 if we find HEADER-FILE, otherwise we set to 0 -dnl if FLAG-TO-SET is null, we automagically determine it's name -dnl by changing all "/" to "_" in the HEADER-FILE and dropping -dnl all "." and "-" chars. If the 3rd parameter is "yes" then instead of -dnl setting to 1 or 0, we set FLAG-TO-SET to yes or no. -dnl -AC_DEFUN([APR_FLAG_HEADERS], [ -AC_CHECK_HEADERS($1) -for aprt_i in $1 -do - ac_safe=`echo "$aprt_i" | sed 'y%./+-%__p_%'` - aprt_2=`echo "$aprt_i" | sed -e 's%/%_%g' -e 's/\.//g' -e 's/-//g'` - if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - eval "ifelse($2,,$aprt_2,$2)=ifelse($3,yes,yes,1)" - else - eval "ifelse($2,,$aprt_2,$2)=ifelse($3,yes,no,0)" - fi -done -]) - -dnl APR_FLAG_FUNCS(FUNC ... [, FLAG-TO-SET] [, "yes" ]) -dnl if FLAG-TO-SET is null, we automagically determine it's name -dnl prepending "have_" to the function name in FUNC, otherwise -dnl we use what's provided as FLAG-TO-SET. If the 3rd parameter -dnl is "yes" then instead of setting to 1 or 0, we set FLAG-TO-SET -dnl to yes or no. -dnl -AC_DEFUN([APR_FLAG_FUNCS], [ -AC_CHECK_FUNCS($1) -for aprt_j in $1 -do - aprt_3="have_$aprt_j" - if eval "test \"`echo '$ac_cv_func_'$aprt_j`\" = yes"; then - eval "ifelse($2,,$aprt_3,$2)=ifelse($3,yes,yes,1)" - else - eval "ifelse($2,,$aprt_3,$2)=ifelse($3,yes,no,0)" - fi -done -]) - -dnl Iteratively interpolate the contents of the second argument -dnl until interpolation offers no new result. Then assign the -dnl final result to $1. -dnl -dnl Example: -dnl -dnl foo=1 -dnl bar='${foo}/2' -dnl baz='${bar}/3' -dnl APR_EXPAND_VAR(fraz, $baz) -dnl $fraz is now "1/2/3" -dnl -AC_DEFUN([APR_EXPAND_VAR], [ -ap_last= -ap_cur="$2" -while test "x${ap_cur}" != "x${ap_last}"; -do - ap_last="${ap_cur}" - ap_cur=`eval "echo ${ap_cur}"` -done -$1="${ap_cur}" -]) - -dnl -dnl Removes the value of $3 from the string in $2, strips of any leading -dnl slashes, and returns the value in $1. -dnl -dnl Example: -dnl orig_path="${prefix}/bar" -dnl APR_PATH_RELATIVE(final_path, $orig_path, $prefix) -dnl $final_path now contains "bar" -AC_DEFUN([APR_PATH_RELATIVE], [ -ap_stripped=`echo $2 | sed -e "s#^$3##"` -# check if the stripping was successful -if test "x$2" != "x${ap_stripped}"; then - # it was, so strip of any leading slashes - $1="`echo ${ap_stripped} | sed -e 's#^/*##'`" -else - # it wasn't so return the original - $1="$2" -fi -]) - -dnl APR_HELP_STRING(LHS, RHS) -dnl Autoconf 2.50 can not handle substr correctly. It does have -dnl AC_HELP_STRING, so let's try to call it if we can. -dnl Note: this define must be on one line so that it can be properly returned -dnl as the help string. When using this macro with a multi-line RHS, ensure -dnl that you surround the macro invocation with []s -AC_DEFUN([APR_HELP_STRING], [ifelse(regexp(AC_ACVERSION, 2\.1), -1, AC_HELP_STRING([$1],[$2]),[ ][$1] substr([ ],len($1))[$2])]) - -dnl -dnl APR_LAYOUT(configlayout, layoutname [, extravars]) -dnl -AC_DEFUN([APR_LAYOUT], [ - if test ! -f $srcdir/config.layout; then - echo "** Error: Layout file $srcdir/config.layout not found" - echo "** Error: Cannot use undefined layout '$LAYOUT'" - exit 1 - fi - # Catch layout names including a slash which will otherwise - # confuse the heck out of the sed script. - case $2 in - */*) - echo "** Error: $2 is not a valid layout name" - exit 1 ;; - esac - pldconf=./config.pld - changequote({,}) - sed -e "1s/[ ]*<[lL]ayout[ ]*$2[ ]*>[ ]*//;1t" \ - -e "1,/[ ]*<[lL]ayout[ ]*$2[ ]*>[ ]*/d" \ - -e '/[ ]*<\/Layout>[ ]*/,$d' \ - -e "s/^[ ]*//g" \ - -e "s/:[ ]*/=\'/g" \ - -e "s/[ ]*$/'/g" \ - $1 > $pldconf - layout_name=$2 - if test ! -s $pldconf; then - echo "** Error: unable to find layout $layout_name" - exit 1 - fi - . $pldconf - rm $pldconf - for var in prefix exec_prefix bindir sbindir libexecdir mandir \ - sysconfdir datadir includedir localstatedir runtimedir \ - logfiledir libdir installbuilddir libsuffix $3; do - eval "val=\"\$$var\"" - case $val in - *+) - val=`echo $val | sed -e 's;\+$;;'` - eval "$var=\"\$val\"" - autosuffix=yes - ;; - *) - autosuffix=no - ;; - esac - val=`echo $val | sed -e 's:\(.\)/*$:\1:'` - val=`echo $val | sed -e 's:[\$]\([a-z_]*\):${\1}:g'` - if test "$autosuffix" = "yes"; then - if echo $val | grep apache >/dev/null; then - addtarget=no - else - addtarget=yes - fi - if test "$addtarget" = "yes"; then - val="$val/apache2" - fi - fi - eval "$var='$val'" - done - changequote([,]) -])dnl - -dnl -dnl APR_ENABLE_LAYOUT(default layout name [, extra vars]) -dnl -AC_DEFUN([APR_ENABLE_LAYOUT], [ -AC_ARG_ENABLE(layout, -[ --enable-layout=LAYOUT],[ - LAYOUT=$enableval -]) - -if test -z "$LAYOUT"; then - LAYOUT="$1" -fi -APR_LAYOUT($srcdir/config.layout, $LAYOUT, $2) - -AC_MSG_CHECKING(for chosen layout) -AC_MSG_RESULT($layout_name) -]) - - -dnl -dnl APR_PARSE_ARGUMENTS -dnl a reimplementation of autoconf's argument parser, -dnl used here to allow us to co-exist layouts and argument based -dnl set ups. -AC_DEFUN([APR_PARSE_ARGUMENTS], [ -ac_prev= -# Retrieve the command-line arguments. The eval is needed because -# the arguments are quoted to preserve accuracy. -eval "set x $ac_configure_args" -shift -for ac_option -do - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" - ac_prev= - continue - fi - - ac_optarg=`expr "x$ac_option" : 'x[[^=]]*=\(.*\)'` - - case $ac_option in - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir="$ac_optarg" ;; - - -datadir | --datadir | --datadi | --datad | --data | --dat | --da) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ - | --da=*) - datadir="$ac_optarg" ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix="$ac_optarg" ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir="$ac_optarg" ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir="$ac_optarg" ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir="$ac_optarg" ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir="$ac_optarg" ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst \ - | --locals | --local | --loca | --loc | --lo) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* \ - | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) - localstatedir="$ac_optarg" ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir="$ac_optarg" ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix="$ac_optarg" ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir="$ac_optarg" ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir="$ac_optarg" ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir="$ac_optarg" ;; - - esac -done - -# Be sure to have absolute paths. -for ac_var in exec_prefix prefix -do - eval ac_val=$`echo $ac_var` - case $ac_val in - [[\\/$]]* | ?:[[\\/]]* | NONE | '' ) ;; - *) AC_MSG_ERROR([expected an absolute path for --$ac_var: $ac_val]);; - esac -done - -])dnl - -dnl -dnl APR_CHECK_DEPEND -dnl -dnl Determine what program we can use to generate .deps-style dependencies -dnl -AC_DEFUN([APR_CHECK_DEPEND], [ -dnl Try to determine what depend program we can use -dnl All GCC-variants should have -MM. -dnl If not, then we can check on those, too. -if test "$GCC" = "yes"; then - MKDEP='$(CC) -MM' -else - rm -f conftest.c -dnl should be available everywhere! - cat > conftest.c < - int main() { return 0; } -EOF - MKDEP="true" - for i in "$CC -MM" "$CC -M" "$CPP -MM" "$CPP -M" "cpp -M"; do - AC_MSG_CHECKING([if $i can create proper make dependencies]) - if $i conftest.c 2>/dev/null | grep 'conftest.o: conftest.c' >/dev/null; then - MKDEP=$i - AC_MSG_RESULT(yes) - break; - fi - AC_MSG_RESULT(no) - done - rm -f conftest.c -fi - -AC_SUBST(MKDEP) -]) - -dnl -dnl APR_CHECK_TYPES_COMPATIBLE(TYPE-1, TYPE-2, [ACTION-IF-TRUE]) -dnl -dnl Try to determine whether two types are the same. Only works -dnl for gcc and icc. -dnl -AC_DEFUN([APR_CHECK_TYPES_COMPATIBLE], [ -define([apr_cvname], apr_cv_typematch_[]translit([$1], [ ], [_])_[]translit([$2], [ ], [_])) -AC_CACHE_CHECK([whether $1 and $2 are the same], apr_cvname, [ -AC_TRY_COMPILE(AC_INCLUDES_DEFAULT, [ - int foo[0 - !__builtin_types_compatible_p($1, $2)]; -], [apr_cvname=yes -$3], [apr_cvname=no])]) -]) diff --git a/libs/apr/build/apr_hints.m4 b/libs/apr/build/apr_hints.m4 deleted file mode 100644 index 9cde0fef..00000000 --- a/libs/apr/build/apr_hints.m4 +++ /dev/null @@ -1,528 +0,0 @@ -dnl -------------------------------------------------------- -*- autoconf -*- -dnl Licensed to the Apache Software Foundation (ASF) under one or more -dnl contributor license agreements. See the NOTICE file distributed with -dnl this work for additional information regarding copyright ownership. -dnl The ASF licenses this file to You under the Apache License, Version 2.0 -dnl (the "License"); you may not use this file except in compliance with -dnl the License. You may obtain a copy of the License at -dnl -dnl http://www.apache.org/licenses/LICENSE-2.0 -dnl -dnl Unless required by applicable law or agreed to in writing, software -dnl distributed under the License is distributed on an "AS IS" BASIS, -dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -dnl See the License for the specific language governing permissions and -dnl limitations under the License. - -dnl ----------------------------------------------------------------- -dnl apr_hints.m4: APR's autoconf macros for platform-specific hints -dnl -dnl We preload various configure settings depending -dnl on previously obtained platform knowledge. -dnl We allow all settings to be overridden from -dnl the command-line. -dnl -dnl We maintain the "format" that we've used -dnl under 1.3.x, so we don't exactly follow -dnl what is "recommended" by autoconf. - -dnl -dnl APR_PRELOAD -dnl -dnl Preload various ENV/makefile params such as CC, CFLAGS, etc -dnl based on outside knowledge -dnl -dnl Generally, we force the setting of CC, and add flags -dnl to CFLAGS, CPPFLAGS, LIBS and LDFLAGS. -dnl -AC_DEFUN(APR_PRELOAD, [ -if test "x$apr_preload_done" != "xyes" ; then - - apr_preload_done="yes" - - echo "Applying APR hints file rules for $host" - - case "$host" in - *mint) - APR_ADDTO(CPPFLAGS, [-DMINT]) - APR_ADDTO(LIBS, [-lportlib]) - ;; - *MPE/iX*) - APR_ADDTO(CPPFLAGS, [-DMPE -D_POSIX_SOURCE -D_SOCKET_SOURCE]) - APR_ADDTO(LIBS, [-lsvipc -lcurses]) - APR_ADDTO(LDFLAGS, [-Xlinker \"-WL,cap=ia,ba,ph;nmstack=1024000\"]) - ;; - *-apple-aux3*) - APR_ADDTO(CPPFLAGS, [-DAUX3 -D_POSIX_SOURCE]) - APR_ADDTO(LIBS, [-lposix -lbsd]) - APR_ADDTO(LDFLAGS, [-s]) - APR_SETVAR(SHELL, [/bin/ksh]) - ;; - *-ibm-aix*) - APR_ADDTO(CPPFLAGS, [-U__STR__ -D_THREAD_SAFE]) - dnl _USR_IRS gets us the hstrerror() proto in netdb.h - case $host in - *-ibm-aix4.3) - APR_ADDTO(CPPFLAGS, [-D_USE_IRS]) - ;; - *-ibm-aix5*) - APR_ADDTO(CPPFLAGS, [-D_USE_IRS]) - ;; - *-ibm-aix4.3.*) - APR_ADDTO(CPPFLAGS, [-D_USE_IRS]) - ;; - esac - dnl If using xlc, remember it, and give it the right options. - if $CC 2>&1 | grep 'xlc' > /dev/null; then - APR_SETIFNULL(AIX_XLC, [yes]) - APR_ADDTO(CFLAGS, [-qHALT=E]) - fi - APR_SETIFNULL(apr_sysvsem_is_global, [yes]) - APR_SETIFNULL(apr_lock_method, [USE_SYSVSEM_SERIALIZE]) - case $host in - *-ibm-aix3* | *-ibm-aix4.1.*) - ;; - *) - APR_ADDTO(LDFLAGS, [-Wl,-brtl]) - ;; - esac - ;; - *-apollo-*) - APR_ADDTO(CPPFLAGS, [-DAPOLLO]) - ;; - *-dg-dgux*) - APR_ADDTO(CPPFLAGS, [-DDGUX]) - ;; - *-os2*) - APR_SETVAR(SHELL, [sh]) - APR_SETIFNULL(apr_gethostbyname_is_thread_safe, [yes]) - APR_SETIFNULL(apr_gethostbyaddr_is_thread_safe, [yes]) - APR_SETIFNULL(apr_getservbyname_is_thread_safe, [yes]) - ;; - *-hi-hiux) - APR_ADDTO(CPPFLAGS, [-DHIUX]) - ;; - *-hp-hpux11.*) - APR_ADDTO(CPPFLAGS, [-DHPUX11 -D_REENTRANT -D_HPUX_SOURCE]) - ;; - *-hp-hpux10.*) - case $host in - *-hp-hpux10.01) -dnl # We know this is a problem in 10.01. -dnl # Not a problem in 10.20. Otherwise, who knows? - APR_ADDTO(CPPFLAGS, [-DSELECT_NEEDS_CAST]) - ;; - esac - APR_ADDTO(CPPFLAGS, [-D_REENTRANT]) - ;; - *-hp-hpux*) - APR_ADDTO(CPPFLAGS, [-DHPUX -D_REENTRANT]) - ;; - *-linux*) - case `uname -r` in - 2.* ) APR_ADDTO(CPPFLAGS, [-DLINUX=2]) - ;; - 1.* ) APR_ADDTO(CPPFLAGS, [-DLINUX=1]) - ;; - * ) - ;; - esac - APR_ADDTO(CPPFLAGS, [-D_REENTRANT -D_GNU_SOURCE]) - ;; - *-GNU*) - APR_ADDTO(CPPFLAGS, [-DHURD -D_GNU_SOURCE]) - ;; - *-lynx-lynxos) - APR_ADDTO(CPPFLAGS, [-D__NO_INCLUDE_WARN__ -DLYNXOS]) - APR_ADDTO(LIBS, [-lbsd]) - ;; - *486-*-bsdi*) - APR_ADDTO(CFLAGS, [-m486]) - ;; - *-*-bsdi*) - case $host in - *bsdi4.1) - APR_ADDTO(CFLAGS, [-D_REENTRANT]) - ;; - esac - ;; - *-openbsd*) - APR_ADDTO(CPPFLAGS, [-D_POSIX_THREADS]) - # binding to an ephemeral port fails on OpenBSD so override - # the test for O_NONBLOCK inheritance across accept(). - APR_SETIFNULL(ac_cv_o_nonblock_inherited, [yes]) - ;; - *-netbsd*) - APR_ADDTO(CPPFLAGS, [-DNETBSD]) - # fcntl() lies about O_NONBLOCK on an accept()ed socket (PR kern/26950) - APR_SETIFNULL(ac_cv_o_nonblock_inherited, [yes]) - ;; - *-freebsd*) - APR_SETIFNULL(apr_lock_method, [USE_FLOCK_SERIALIZE]) - if test -x /sbin/sysctl; then - os_version=`/sbin/sysctl -n kern.osreldate` - else - os_version=000000 - fi - # 502102 is when libc_r switched to libpthread (aka libkse). - if test $os_version -ge "502102"; then - apr_cv_pthreads_cflags="none" - apr_cv_pthreads_lib="-lpthread" - else - APR_ADDTO(CPPFLAGS, [-D_THREAD_SAFE -D_REENTRANT]) - APR_SETIFNULL(enable_threads, [no]) - fi - # prevent use of KQueue before FreeBSD 4.8 - if test $os_version -lt "480000"; then - APR_SETIFNULL(ac_cv_func_kqueue, no) - fi - ;; - *-k*bsd*-gnu) - APR_ADDTO(CPPFLAGS, [-D_REENTRANT -D_GNU_SOURCE]) - ;; - *-next-nextstep*) - APR_SETIFNULL(CFLAGS, [-O]) - APR_ADDTO(CPPFLAGS, [-DNEXT]) - ;; - *-next-openstep*) - APR_SETIFNULL(CFLAGS, [-O]) - APR_ADDTO(CPPFLAGS, [-DNEXT]) - ;; - *-apple-rhapsody*) - APR_ADDTO(CPPFLAGS, [-DRHAPSODY]) - ;; - *-apple-darwin*) - APR_ADDTO(CPPFLAGS, [-DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -no-cpp-precomp]) - APR_SETIFNULL(apr_posixsem_is_global, [yes]) - case $host in - *-apple-darwin[[1-9]].*) - # APR's use of kqueue has triggered kernel panics for some - # 10.5.x (Darwin 9.x) users when running the entire test suite. - # In 10.4.x, use of kqueue would cause the socket tests to hang. - # 10.6+ (Darwin 10.x is supposed to fix the KQueue issues - APR_SETIFNULL(ac_cv_func_kqueue, [no]) - APR_SETIFNULL(ac_cv_func_poll, [no]) # See issue 34332 - ;; - *-apple-darwin1[[01]].*) - APR_ADDTO(CPPFLAGS, [-DDARWIN_10]) - ;; - esac - ;; - *-dec-osf*) - APR_ADDTO(CPPFLAGS, [-DOSF1]) - # process-shared mutexes don't seem to work in Tru64 5.0 - APR_SETIFNULL(apr_cv_process_shared_works, [no]) - ;; - *-nto-qnx*) - ;; - *-qnx) - APR_ADDTO(CPPFLAGS, [-DQNX]) - APR_ADDTO(LIBS, [-N128k -lunix]) - ;; - *-qnx32) - APR_ADDTO(CPPFLAGS, [-DQNX]) - APR_ADDTO(CFLAGS, [-mf -3]) - APR_ADDTO(LIBS, [-N128k -lunix]) - ;; - *-isc4*) - APR_ADDTO(CPPFLAGS, [-posix -DISC]) - APR_ADDTO(LDFLAGS, [-posix]) - APR_ADDTO(LIBS, [-linet]) - ;; - *-sco3.2v[[234]]*) - APR_ADDTO(CPPFLAGS, [-DSCO -D_REENTRANT]) - if test "$GCC" = "no"; then - APR_ADDTO(CFLAGS, [-Oacgiltz]) - fi - APR_ADDTO(LIBS, [-lPW -lmalloc]) - ;; - *-sco3.2v5*) - APR_ADDTO(CPPFLAGS, [-DSCO5 -D_REENTRANT]) - ;; - *-sco_sv*|*-SCO_SV*) - APR_ADDTO(CPPFLAGS, [-DSCO -D_REENTRANT]) - APR_ADDTO(LIBS, [-lPW -lmalloc]) - ;; - *-solaris2*) - PLATOSVERS=`echo $host | sed 's/^.*solaris2.//'` - APR_ADDTO(CPPFLAGS, [-DSOLARIS2=$PLATOSVERS -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT]) - if test $PLATOSVERS -ge 10; then - APR_SETIFNULL(apr_lock_method, [USE_PROC_PTHREAD_SERIALIZE]) - else - APR_SETIFNULL(apr_lock_method, [USE_FCNTL_SERIALIZE]) - fi - # readdir64_r error handling seems broken on Solaris (at least - # up till 2.8) -- it will return -1 at end-of-directory. - APR_SETIFNULL(ac_cv_func_readdir64_r, [no]) - ;; - *-sunos4*) - APR_ADDTO(CPPFLAGS, [-DSUNOS4]) - ;; - *-unixware1) - APR_ADDTO(CPPFLAGS, [-DUW=100]) - ;; - *-unixware2) - APR_ADDTO(CPPFLAGS, [-DUW=200]) - APR_ADDTO(LIBS, [-lgen]) - ;; - *-unixware211) - APR_ADDTO(CPPFLAGS, [-DUW=211]) - APR_ADDTO(LIBS, [-lgen]) - ;; - *-unixware212) - APR_ADDTO(CPPFLAGS, [-DUW=212]) - APR_ADDTO(LIBS, [-lgen]) - ;; - *-unixware7) - APR_ADDTO(CPPFLAGS, [-DUW=700]) - APR_ADDTO(LIBS, [-lgen]) - ;; - maxion-*-sysv4*) - APR_ADDTO(CPPFLAGS, [-DSVR4]) - APR_ADDTO(LIBS, [-lc -lgen]) - ;; - *-*-powermax*) - APR_ADDTO(CPPFLAGS, [-DSVR4]) - APR_ADDTO(LIBS, [-lgen]) - ;; - TPF) - APR_ADDTO(CPPFLAGS, [-DTPF -D_POSIX_SOURCE]) - ;; - bs2000*-siemens-sysv*) - APR_SETIFNULL(CFLAGS, [-O]) - APR_ADDTO(CPPFLAGS, [-DSVR4 -D_XPG_IV -D_KMEMUSER]) - APR_ADDTO(LIBS, [-lsocket]) - APR_SETIFNULL(enable_threads, [no]) - ;; - *-siemens-sysv4*) - APR_ADDTO(CPPFLAGS, [-DSVR4 -D_XPG_IV -DHAS_DLFCN -DUSE_MMAP_FILES -DUSE_SYSVSEM_SERIALIZED_ACCEPT]) - APR_ADDTO(LIBS, [-lc]) - ;; - pyramid-pyramid-svr4) - APR_ADDTO(CPPFLAGS, [-DSVR4 -DNO_LONG_DOUBLE]) - APR_ADDTO(LIBS, [-lc]) - ;; - DS/90\ 7000-*-sysv4*) - APR_ADDTO(CPPFLAGS, [-DUXPDS]) - ;; - *-tandem-sysv4*) - APR_ADDTO(CPPFLAGS, [-DSVR4]) - ;; - *-ncr-sysv4) - APR_ADDTO(CPPFLAGS, [-DSVR4 -DMPRAS]) - APR_ADDTO(LIBS, [-lc -L/usr/ucblib -lucb]) - ;; - *-sysv4*) - APR_ADDTO(CPPFLAGS, [-DSVR4]) - APR_ADDTO(LIBS, [-lc]) - ;; - 88k-encore-sysv4) - APR_ADDTO(CPPFLAGS, [-DSVR4 -DENCORE]) - APR_ADDTO(LIBS, [-lPW]) - ;; - *-uts*) - PLATOSVERS=`echo $host | sed 's/^.*,//'` - case $PLATOSVERS in - 2*) APR_ADDTO(CPPFLAGS, [-DUTS21]) - APR_ADDTO(CFLAGS, [-Xa -eft]) - APR_ADDTO(LIBS, [-lbsd -la]) - ;; - *) APR_ADDTO(CPPFLAGS, [-DSVR4]) - APR_ADDTO(CFLAGS, [-Xa]) - ;; - esac - ;; - *-ultrix) - APR_ADDTO(CPPFLAGS, [-DULTRIX]) - APR_SETVAR(SHELL, [/bin/sh5]) - ;; - *powerpc-tenon-machten*) - APR_ADDTO(LDFLAGS, [-Xlstack=0x14000 -Xldelcsect]) - ;; - *-machten*) - APR_ADDTO(LDFLAGS, [-stack 0x14000]) - ;; - *convex-v11*) - APR_ADDTO(CPPFLAGS, [-DCONVEXOS11]) - APR_SETIFNULL(CFLAGS, [-O1]) - APR_ADDTO(CFLAGS, [-ext]) - ;; - i860-intel-osf1) - APR_ADDTO(CPPFLAGS, [-DPARAGON]) - ;; - *-sequent-ptx2.*.*) - APR_ADDTO(CPPFLAGS, [-DSEQUENT=20]) - APR_ADDTO(CFLAGS, [-Wc,-pw]) - APR_ADDTO(LIBS, [-linet -lc -lseq]) - ;; - *-sequent-ptx4.0.*) - APR_ADDTO(CPPFLAGS, [-DSEQUENT=40]) - APR_ADDTO(CFLAGS, [-Wc,-pw]) - APR_ADDTO(LIBS, [-linet -lc]) - ;; - *-sequent-ptx4.[[123]].*) - APR_ADDTO(CPPFLAGS, [-DSEQUENT=41]) - APR_ADDTO(CFLAGS, [-Wc,-pw]) - APR_ADDTO(LIBS, [-lc]) - ;; - *-sequent-ptx4.4.*) - APR_ADDTO(CPPFLAGS, [-DSEQUENT=44]) - APR_ADDTO(CFLAGS, [-Wc,-pw]) - APR_ADDTO(LIBS, [-lc]) - ;; - *-sequent-ptx4.5.*) - APR_ADDTO(CPPFLAGS, [-DSEQUENT=45]) - APR_ADDTO(CFLAGS, [-Wc,-pw]) - APR_ADDTO(LIBS, [-lc]) - ;; - *-sequent-ptx5.0.*) - APR_ADDTO(CPPFLAGS, [-DSEQUENT=50]) - APR_ADDTO(CFLAGS, [-Wc,-pw]) - APR_ADDTO(LIBS, [-lc]) - ;; - *NEWS-OS*) - APR_ADDTO(CPPFLAGS, [-DNEWSOS]) - ;; - *-riscix) - APR_ADDTO(CPPFLAGS, [-DRISCIX]) - APR_SETIFNULL(CFLAGS, [-O]) - ;; - *-irix*) - APR_ADDTO(CPPFLAGS, [-D_POSIX_THREAD_SAFE_FUNCTIONS]) - ;; - *beos*) - APR_ADDTO(CPPFLAGS, [-DBEOS]) - PLATOSVERS=`uname -r` - APR_SETIFNULL(apr_process_lock_is_global, [yes]) - case $PLATOSVERS in - 5.0.4) - APR_ADDTO(LDFLAGS, [-L/boot/beos/system/lib]) - APR_ADDTO(LIBS, [-lbind -lsocket]) - APR_ADDTO(CPPFLAGS,[-DBONE7]) - ;; - 5.1) - APR_ADDTO(LDFLAGS, [-L/boot/beos/system/lib]) - APR_ADDTO(LIBS, [-lbind -lsocket]) - ;; - esac - APR_ADDTO(CPPFLAGS, [-DSIGPROCMASK_SETS_THREAD_MASK]) - ;; - 4850-*.*) - APR_ADDTO(CPPFLAGS, [-DSVR4 -DMPRAS]) - APR_ADDTO(LIBS, [-lc -L/usr/ucblib -lucb]) - ;; - drs6000*) - APR_ADDTO(CPPFLAGS, [-DSVR4]) - APR_ADDTO(LIBS, [-lc -L/usr/ucblib -lucb]) - ;; - m88k-*-CX/SX|CYBER) - APR_ADDTO(CPPFLAGS, [-D_CX_SX]) - APR_ADDTO(CFLAGS, [-Xa]) - ;; - *-tandem-oss) - APR_ADDTO(CPPFLAGS, [-D_TANDEM_SOURCE -D_XOPEN_SOURCE_EXTENDED=1]) - ;; - *-ibm-os390) - APR_SETIFNULL(apr_lock_method, [USE_SYSVSEM_SERIALIZE]) - APR_SETIFNULL(apr_sysvsem_is_global, [yes]) - APR_SETIFNULL(apr_gethostbyname_is_thread_safe, [yes]) - APR_SETIFNULL(apr_gethostbyaddr_is_thread_safe, [yes]) - APR_SETIFNULL(apr_getservbyname_is_thread_safe, [yes]) - AC_DEFINE(HAVE_ZOS_PTHREADS, 1, [Define for z/OS pthread API nuances]) - APR_ADDTO(CPPFLAGS, [-U_NO_PROTO -DSIGPROCMASK_SETS_THREAD_MASK -DTCP_NODELAY=1]) - ;; - *-ibm-as400) - APR_SETIFNULL(apr_lock_method, [USE_SYSVSEM_SERIALIZE]) - APR_SETIFNULL(apr_process_lock_is_global, [yes]) - APR_SETIFNULL(apr_gethostbyname_is_thread_safe, [yes]) - APR_SETIFNULL(apr_gethostbyaddr_is_thread_safe, [yes]) - APR_SETIFNULL(apr_getservbyname_is_thread_safe, [yes]) - ;; - *cygwin*) - APR_ADDTO(CPPFLAGS, [-DCYGWIN]) - ;; - *mingw*) - APR_ADDTO(CPPFLAGS, [-DWIN32 -D__MSVCRT__]) - APR_ADDTO(LDFLAGS, [-Wl,--enable-auto-import,--subsystem,console]) - APR_SETIFNULL(have_unicode_fs, [1]) - APR_SETIFNULL(have_proc_invoked, [1]) - APR_SETIFNULL(apr_lock_method, [win32]) - APR_SETIFNULL(apr_process_lock_is_global, [yes]) - APR_SETIFNULL(apr_cv_use_lfs64, [yes]) - APR_SETIFNULL(apr_cv_osuuid, [yes]) - APR_SETIFNULL(apr_cv_tcp_nodelay_with_cork, [no]) - APR_SETIFNULL(apr_thread_func, [__stdcall]) - APR_SETIFNULL(ac_cv_o_nonblock_inherited, [yes]) - APR_SETIFNULL(ac_cv_tcp_nodelay_inherited, [yes]) - APR_SETIFNULL(ac_cv_file__dev_zero, [no]) - APR_SETIFNULL(ac_cv_func_setpgrp_void, [no]) - APR_SETIFNULL(ac_cv_func_mmap, [yes]) - APR_SETIFNULL(ac_cv_define_sockaddr_in6, [yes]) - APR_SETIFNULL(ac_cv_working_getaddrinfo, [yes]) - APR_SETIFNULL(ac_cv_working_getnameinfo, [yes]) - APR_SETIFNULL(ac_cv_func_gai_strerror, [yes]) - case $host in - *mingw32*) - APR_SETIFNULL(apr_has_xthread_files, [1]) - APR_SETIFNULL(apr_has_user, [1]) - APR_SETIFNULL(apr_procattr_user_set_requires_password, [1]) - dnl The real function is TransmitFile(), not sendfile(), but - dnl this bypasses the Linux/Solaris/AIX/etc. test and enables - dnl the TransmitFile() implementation. - APR_SETIFNULL(ac_cv_func_sendfile, [yes]) - ;; - *mingwce) - APR_SETIFNULL(apr_has_xthread_files, [0]) - APR_SETIFNULL(apr_has_user, [0]) - APR_SETIFNULL(apr_procattr_user_set_requires_password, [0]) - APR_SETIFNULL(ac_cv_func_sendfile, [no]) - ;; - esac - ;; - esac - -fi -]) - -dnl -dnl APR_CC_HINTS -dnl -dnl Allows us to provide a default choice of compiler which -dnl the user can override. -AC_DEFUN(APR_CC_HINTS, [ -case "$host" in - *-apple-aux3*) - APR_SETIFNULL(CC, [gcc]) - ;; - bs2000*-siemens-sysv*) - APR_SETIFNULL(CC, [c89 -XLLML -XLLMK -XL -Kno_integer_overflow]) - ;; - *convex-v11*) - APR_SETIFNULL(CC, [cc]) - ;; - *-ibm-os390) - APR_SETIFNULL(CC, [cc]) - ;; - *-ibm-as400) - APR_SETIFNULL(CC, [icc]) - ;; - *-isc4*) - APR_SETIFNULL(CC, [gcc]) - ;; - m88k-*-CX/SX|CYBER) - APR_SETIFNULL(CC, [cc]) - ;; - *-next-openstep*) - APR_SETIFNULL(CC, [cc]) - ;; - *-qnx32) - APR_SETIFNULL(CC, [cc -F]) - ;; - *-tandem-oss) - APR_SETIFNULL(CC, [c89]) - ;; - TPF) - APR_SETIFNULL(CC, [c89]) - ;; -esac -]) diff --git a/libs/apr/build/apr_network.m4 b/libs/apr/build/apr_network.m4 deleted file mode 100644 index 4d479a45..00000000 --- a/libs/apr/build/apr_network.m4 +++ /dev/null @@ -1,928 +0,0 @@ -dnl -------------------------------------------------------- -*- autoconf -*- -dnl Licensed to the Apache Software Foundation (ASF) under one or more -dnl contributor license agreements. See the NOTICE file distributed with -dnl this work for additional information regarding copyright ownership. -dnl The ASF licenses this file to You under the Apache License, Version 2.0 -dnl (the "License"); you may not use this file except in compliance with -dnl the License. You may obtain a copy of the License at -dnl -dnl http://www.apache.org/licenses/LICENSE-2.0 -dnl -dnl Unless required by applicable law or agreed to in writing, software -dnl distributed under the License is distributed on an "AS IS" BASIS, -dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -dnl See the License for the specific language governing permissions and -dnl limitations under the License. - -dnl ----------------------------------------------------------------- -dnl apr_network.m4: APR's autoconf macros for testing network support -dnl - -dnl -dnl check for type in_addr -dnl -AC_DEFUN(APR_TYPE_IN_ADDR,[ - AC_CACHE_CHECK(for type in_addr, ac_cv_type_in_addr,[ - AC_TRY_COMPILE([ -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_WINSOCK2_H -#include -#endif -],[ - struct in_addr arg; - arg.s_addr = htonl(INADDR_ANY); -], [ ac_cv_type_in_addr="yes"] , [ -ac_cv_type_in_addr="no"]) -]) -]) - -dnl -dnl check for working getaddrinfo() -dnl -dnl Note that if the system doesn't have gai_strerror(), we -dnl can't use getaddrinfo() because we can't get strings -dnl describing the error codes. -dnl -AC_DEFUN([APR_CHECK_WORKING_GETADDRINFO], [ - AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[ - AC_TRY_RUN( [ -#ifdef HAVE_NETDB_H -#include -#endif -#ifdef HAVE_STRING_H -#include -#endif -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_SOCKET_H -#include -#endif - -void main(void) { - struct addrinfo hints, *ai; - int error; - - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - error = getaddrinfo("127.0.0.1", NULL, &hints, &ai); - if (error) { - exit(1); - } - if (ai->ai_addr->sa_family != AF_INET) { - exit(1); - } - exit(0); -} -],[ - ac_cv_working_getaddrinfo="yes" -],[ - ac_cv_working_getaddrinfo="no" -],[ - ac_cv_working_getaddrinfo="yes" -])]) -if test "$ac_cv_working_getaddrinfo" = "yes"; then - if test "$ac_cv_func_gai_strerror" != "yes"; then - ac_cv_working_getaddrinfo="no" - else - AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works well enough for APR]) - fi -fi -]) - -dnl Check whether the AI_ADDRCONFIG flag can be used with getaddrinfo -AC_DEFUN([APR_CHECK_GETADDRINFO_ADDRCONFIG], [ - AC_CACHE_CHECK(for working AI_ADDRCONFIG, apr_cv_gai_addrconfig, [ - AC_TRY_RUN([ -#ifdef HAVE_NETDB_H -#include -#endif -#ifdef HAVE_STRING_H -#include -#endif -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_SOCKET_H -#include -#endif - -int main(int argc, char **argv) { - struct addrinfo hints, *ai; - - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_ADDRCONFIG; - return getaddrinfo("localhost", NULL, &hints, &ai) != 0; -}], [apr_cv_gai_addrconfig=yes], - [apr_cv_gai_addrconfig=no], - [apr_cv_gai_addrconfig=no])]) - -if test $apr_cv_gai_addrconfig = yes; then - AC_DEFINE(HAVE_GAI_ADDRCONFIG, 1, [Define if getaddrinfo accepts the AI_ADDRCONFIG flag]) -fi -]) - -dnl -dnl check for working getnameinfo() -dnl -AC_DEFUN([APR_CHECK_WORKING_GETNAMEINFO], [ - AC_CACHE_CHECK(for working getnameinfo, ac_cv_working_getnameinfo,[ - AC_TRY_RUN( [ -#ifdef HAVE_NETDB_H -#include -#endif -#ifdef HAVE_STRING_H -#include -#endif -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_SOCKET_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif - -void main(void) { - struct sockaddr_in sa; - char hbuf[256]; - int error; - - sa.sin_family = AF_INET; - sa.sin_port = 0; - sa.sin_addr.s_addr = inet_addr("127.0.0.1"); -#ifdef SIN6_LEN - sa.sin_len = sizeof(sa); -#endif - - error = getnameinfo((const struct sockaddr *)&sa, sizeof(sa), - hbuf, 256, NULL, 0, - NI_NUMERICHOST); - if (error) { - exit(1); - } else { - exit(0); - } -} -],[ - ac_cv_working_getnameinfo="yes" -],[ - ac_cv_working_getnameinfo="no" -],[ - ac_cv_working_getnameinfo="yes" -])]) -if test "$ac_cv_working_getnameinfo" = "yes"; then - AC_DEFINE(HAVE_GETNAMEINFO, 1, [Define if getnameinfo exists]) -fi -]) - -dnl -dnl check for negative error codes for getaddrinfo() -dnl -AC_DEFUN([APR_CHECK_NEGATIVE_EAI], [ - AC_CACHE_CHECK(for negative error codes for getaddrinfo, ac_cv_negative_eai,[ - AC_TRY_RUN( [ -#ifdef HAVE_NETDB_H -#include -#endif - -void main(void) { - if (EAI_ADDRFAMILY < 0) { - exit(0); - } - exit(1); -} -],[ - ac_cv_negative_eai="yes" -],[ - ac_cv_negative_eai="no" -],[ - ac_cv_negative_eai="no" -])]) -if test "$ac_cv_negative_eai" = "yes"; then - AC_DEFINE(NEGATIVE_EAI, 1, [Define if EAI_ error codes from getaddrinfo are negative]) -fi -]) - -dnl -dnl Checks the definition of gethostbyname_r and gethostbyaddr_r -dnl which are different for glibc, solaris and assorted other operating -dnl systems -dnl -dnl Note that this test is executed too early to see if we have all of -dnl the headers. -AC_DEFUN([APR_CHECK_GETHOSTBYNAME_R_STYLE], [ - -dnl Try and compile a glibc2 gethostbyname_r piece of code, and set the -dnl style of the routines to glibc2 on success -AC_CACHE_CHECK([style of gethostbyname_r routine], ac_cv_gethostbyname_r_style, -APR_TRY_COMPILE_NO_WARNING([ -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_ARPA_INET_H -#include -#endif -#ifdef HAVE_NETDB_H -#include -#endif -#ifdef HAVE_STDLIB_H -#include -#endif -],[ -int tmp = gethostbyname_r((const char *) 0, (struct hostent *) 0, - (char *) 0, 0, (struct hostent **) 0, &tmp); -/* use tmp to suppress the warning */ -tmp=0; -], ac_cv_gethostbyname_r_style=glibc2, ac_cv_gethostbyname_r_style=none)) - -if test "$ac_cv_gethostbyname_r_style" = "glibc2"; then - AC_DEFINE(GETHOSTBYNAME_R_GLIBC2, 1, [Define if gethostbyname_r has the glibc style]) -fi - -AC_CACHE_CHECK([3rd argument to the gethostbyname_r routines], ac_cv_gethostbyname_r_arg, -APR_TRY_COMPILE_NO_WARNING([ -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_ARPA_INET_H -#include -#endif -#ifdef HAVE_NETDB_H -#include -#endif -#ifdef HAVE_STDLIB_H -#include -#endif -],[ -int tmp = gethostbyname_r((const char *) 0, (struct hostent *) 0, - (struct hostent_data *) 0); -/* use tmp to suppress the warning */ -tmp=0; -], ac_cv_gethostbyname_r_arg=hostent_data, ac_cv_gethostbyname_r_arg=char)) - -if test "$ac_cv_gethostbyname_r_arg" = "hostent_data"; then - AC_DEFINE(GETHOSTBYNAME_R_HOSTENT_DATA, 1, [Define if gethostbyname_r has the hostent_data for the third argument]) -fi -]) - -dnl -dnl Checks the definition of getservbyname_r -dnl which are different for glibc, solaris and assorted other operating -dnl systems -dnl -dnl Note that this test is executed too early to see if we have all of -dnl the headers. -AC_DEFUN([APR_CHECK_GETSERVBYNAME_R_STYLE], [ - -dnl Try and compile a glibc2 getservbyname_r piece of code, and set the -dnl style of the routines to glibc2 on success -AC_CACHE_CHECK([style of getservbyname_r routine], ac_cv_getservbyname_r_style, [ -APR_TRY_COMPILE_NO_WARNING([ -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_ARPA_INET_H -#include -#endif -#ifdef HAVE_NETDB_H -#include -#endif -#ifdef HAVE_STDLIB_H -#include -#endif -],[ -int tmp = getservbyname_r((const char *) 0, (const char *) 0, - (struct servent *) 0, (char *) 0, 0, - (struct servent **) 0); -/* use tmp to suppress the warning */ -tmp=0; -], ac_cv_getservbyname_r_style=glibc2, ac_cv_getservbyname_r_style=none) - -if test "$ac_cv_getservbyname_r_style" = "none"; then - dnl Try and compile a Solaris getservbyname_r piece of code, and set the - dnl style of the routines to solaris on success - APR_TRY_COMPILE_NO_WARNING([ - #ifdef HAVE_SYS_TYPES_H - #include - #endif - #ifdef HAVE_NETINET_IN_H - #include - #endif - #ifdef HAVE_ARPA_INET_H - #include - #endif - #ifdef HAVE_NETDB_H - #include - #endif - #ifdef HAVE_STDLIB_H - #include - #endif - ],[ - struct servent *tmp = getservbyname_r((const char *) 0, (const char *) 0, - (struct servent *) 0, (char *) 0, 0); - /* use tmp to suppress the warning */ - tmp=NULL; - ], ac_cv_getservbyname_r_style=solaris, ac_cv_getservbyname_r_style=none) -fi - -if test "$ac_cv_getservbyname_r_style" = "none"; then - dnl Try and compile a OSF/1 getservbyname_r piece of code, and set the - dnl style of the routines to osf1 on success - APR_TRY_COMPILE_NO_WARNING([ - #ifdef HAVE_SYS_TYPES_H - #include - #endif - #ifdef HAVE_NETINET_IN_H - #include - #endif - #ifdef HAVE_ARPA_INET_H - #include - #endif - #ifdef HAVE_NETDB_H - #include - #endif - #ifdef HAVE_STDLIB_H - #include - #endif - ],[ - int tmp = getservbyname_r((const char *) 0, (const char *) 0, - (struct servent *) 0, (struct servent_data *) 0); - /* use tmp to suppress the warning */ - tmp=0; - ], ac_cv_getservbyname_r_style=osf1, ac_cv_getservbyname_r_style=none) -fi -]) - -if test "$ac_cv_getservbyname_r_style" = "glibc2"; then - AC_DEFINE(GETSERVBYNAME_R_GLIBC2, 1, [Define if getservbyname_r has the glibc style]) -elif test "$ac_cv_getservbyname_r_style" = "solaris"; then - AC_DEFINE(GETSERVBYNAME_R_SOLARIS, 1, [Define if getservbyname_r has the Solaris style]) -elif test "$ac_cv_getservbyname_r_style" = "osf1"; then - AC_DEFINE(GETSERVBYNAME_R_OSF1, 1, [Define if getservbyname_r has the OSF/1 style]) -fi -]) - -dnl -dnl see if TCP_NODELAY setting is inherited from listening sockets -dnl -AC_DEFUN([APR_CHECK_TCP_NODELAY_INHERITED], [ - AC_CACHE_CHECK(if TCP_NODELAY setting is inherited from listening sockets, ac_cv_tcp_nodelay_inherited,[ - AC_TRY_RUN( [ -#include -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_SOCKET_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_NETINET_TCP_H -#include -#endif -#ifndef HAVE_SOCKLEN_T -typedef int socklen_t; -#endif -int main(void) { - int listen_s, connected_s, client_s; - int listen_port, rc; - struct sockaddr_in sa; - socklen_t sa_len; - socklen_t option_len; - int option; - - listen_s = socket(AF_INET, SOCK_STREAM, 0); - if (listen_s < 0) { - perror("socket"); - exit(1); - } - option = 1; - rc = setsockopt(listen_s, IPPROTO_TCP, TCP_NODELAY, &option, sizeof option); - if (rc < 0) { - perror("setsockopt TCP_NODELAY"); - exit(1); - } - memset(&sa, 0, sizeof sa); - sa.sin_family = AF_INET; -#ifdef BEOS - sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); -#endif - /* leave port 0 to get ephemeral */ - rc = bind(listen_s, (struct sockaddr *)&sa, sizeof sa); - if (rc < 0) { - perror("bind for ephemeral port"); - exit(1); - } - /* find ephemeral port */ - sa_len = sizeof(sa); - rc = getsockname(listen_s, (struct sockaddr *)&sa, &sa_len); - if (rc < 0) { - perror("getsockname"); - exit(1); - } - listen_port = sa.sin_port; - rc = listen(listen_s, 5); - if (rc < 0) { - perror("listen"); - exit(1); - } - client_s = socket(AF_INET, SOCK_STREAM, 0); - if (client_s < 0) { - perror("socket"); - exit(1); - } - memset(&sa, 0, sizeof sa); - sa.sin_family = AF_INET; - sa.sin_port = listen_port; -#ifdef BEOS - sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); -#endif - /* leave sin_addr all zeros to use loopback */ - rc = connect(client_s, (struct sockaddr *)&sa, sizeof sa); - if (rc < 0) { - perror("connect"); - exit(1); - } - sa_len = sizeof sa; - connected_s = accept(listen_s, (struct sockaddr *)&sa, &sa_len); - if (connected_s < 0) { - perror("accept"); - exit(1); - } - option_len = sizeof option; - rc = getsockopt(connected_s, IPPROTO_TCP, TCP_NODELAY, &option, &option_len); - if (rc < 0) { - perror("getsockopt"); - exit(1); - } - if (!option) { - fprintf(stderr, "TCP_NODELAY is not set in the child.\n"); - exit(1); - } - return 0; -} -],[ - ac_cv_tcp_nodelay_inherited="yes" -],[ - ac_cv_tcp_nodelay_inherited="no" -],[ - ac_cv_tcp_nodelay_inherited="yes" -])]) -if test "$ac_cv_tcp_nodelay_inherited" = "yes"; then - tcp_nodelay_inherited=1 -else - tcp_nodelay_inherited=0 -fi -]) - -dnl -dnl Determine whether TCP_NODELAY and TCP_CORK can both be set -dnl on a TCP socket. -dnl -AC_DEFUN([APR_CHECK_TCP_NODELAY_WITH_CORK], [ -AC_CACHE_CHECK([whether TCP_NODELAY and TCP_CORK can both be enabled], -[apr_cv_tcp_nodelay_with_cork], -[AC_RUN_IFELSE([AC_LANG_PROGRAM([[ -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_SOCKET_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_NETINET_TCP_H -#include -#endif -#include -#include -]], [[ - int fd, flag, rc; - - fd = socket(AF_INET, SOCK_STREAM, 0); - if (fd < 0) { - exit(1); - } - - flag = 1; - rc = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof flag); - if (rc < 0) { - perror("setsockopt TCP_NODELAY"); - exit(2); - } - - flag = 1; - rc = setsockopt(fd, IPPROTO_TCP, TCP_CORK, &flag, sizeof flag); - if (rc < 0) { - perror("setsockopt TCP_CORK"); - exit(3); - } - - exit(0); -]])], [apr_cv_tcp_nodelay_with_cork=yes], [apr_cv_tcp_nodelay_with_cork=no])]) - -if test "$apr_cv_tcp_nodelay_with_cork" = "yes"; then - AC_DEFINE([HAVE_TCP_NODELAY_WITH_CORK], 1, - [Define if TCP_NODELAY and TCP_CORK can be enabled at the same time]) -fi -]) - - -dnl -dnl see if O_NONBLOCK setting is inherited from listening sockets -dnl -AC_DEFUN([APR_CHECK_O_NONBLOCK_INHERITED], [ - AC_CACHE_CHECK(if O_NONBLOCK setting is inherited from listening sockets, ac_cv_o_nonblock_inherited,[ - AC_TRY_RUN( [ -#include -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_SOCKET_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_NETINET_TCP_H -#include -#endif -#ifndef HAVE_SOCKLEN_T -typedef int socklen_t; -#endif -#ifdef HAVE_FCNTL_H -#include -#endif -int main(void) { - int listen_s, connected_s, client_s; - int listen_port, rc; - struct sockaddr_in sa; - socklen_t sa_len; - - listen_s = socket(AF_INET, SOCK_STREAM, 0); - if (listen_s < 0) { - perror("socket"); - exit(1); - } - memset(&sa, 0, sizeof sa); - sa.sin_family = AF_INET; -#ifdef BEOS - sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); -#endif - /* leave port 0 to get ephemeral */ - rc = bind(listen_s, (struct sockaddr *)&sa, sizeof sa); - if (rc < 0) { - perror("bind for ephemeral port"); - exit(1); - } - /* find ephemeral port */ - sa_len = sizeof(sa); - rc = getsockname(listen_s, (struct sockaddr *)&sa, &sa_len); - if (rc < 0) { - perror("getsockname"); - exit(1); - } - listen_port = sa.sin_port; - rc = listen(listen_s, 5); - if (rc < 0) { - perror("listen"); - exit(1); - } - rc = fcntl(listen_s, F_SETFL, O_NONBLOCK); - if (rc < 0) { - perror("fcntl(F_SETFL)"); - exit(1); - } - client_s = socket(AF_INET, SOCK_STREAM, 0); - if (client_s < 0) { - perror("socket"); - exit(1); - } - memset(&sa, 0, sizeof sa); - sa.sin_family = AF_INET; - sa.sin_port = listen_port; -#ifdef BEOS - sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); -#endif - /* leave sin_addr all zeros to use loopback */ - rc = connect(client_s, (struct sockaddr *)&sa, sizeof sa); - if (rc < 0) { - perror("connect"); - exit(1); - } - sa_len = sizeof sa; - connected_s = accept(listen_s, (struct sockaddr *)&sa, &sa_len); - if (connected_s < 0) { - perror("accept"); - exit(1); - } - rc = fcntl(connected_s, F_GETFL, 0); - if (rc < 0) { - perror("fcntl(F_GETFL)"); - exit(1); - } - if (!(rc & O_NONBLOCK)) { - fprintf(stderr, "O_NONBLOCK is not set in the child.\n"); - exit(1); - } - return 0; -} -],[ - ac_cv_o_nonblock_inherited="yes" -],[ - ac_cv_o_nonblock_inherited="no" -],[ - ac_cv_o_nonblock_inherited="yes" -])]) -if test "$ac_cv_o_nonblock_inherited" = "yes"; then - o_nonblock_inherited=1 -else - o_nonblock_inherited=0 -fi -]) - -dnl -dnl check for socklen_t, fall back to unsigned int -dnl -AC_DEFUN([APR_CHECK_SOCKLEN_T], [ -AC_CACHE_CHECK(for socklen_t, ac_cv_socklen_t,[ -AC_TRY_COMPILE([ -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_SOCKET_H -#include -#endif -],[ -socklen_t foo = (socklen_t) 0; -],[ - ac_cv_socklen_t=yes -],[ - ac_cv_socklen_t=no -]) -]) - -if test "$ac_cv_socklen_t" = "yes"; then - AC_DEFINE(HAVE_SOCKLEN_T, 1, [Whether you have socklen_t]) -fi -]) - - -AC_DEFUN([APR_CHECK_INET_ADDR], [ -AC_CACHE_CHECK(for inet_addr, ac_cv_func_inet_addr,[ -AC_TRY_COMPILE([ -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_ARPA_INET_H -#include -#endif -],[ -inet_addr("127.0.0.1"); -],[ - ac_cv_func_inet_addr=yes -],[ - ac_cv_func_inet_addr=no -]) -]) - -if test "$ac_cv_func_inet_addr" = "yes"; then - have_inet_addr=1 -else - have_inet_addr=0 -fi -]) - - -AC_DEFUN([APR_CHECK_INET_NETWORK], [ -AC_CACHE_CHECK(for inet_network, ac_cv_func_inet_network,[ -AC_TRY_COMPILE([ -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_ARPA_INET_H -#include -#endif -],[ -inet_network("127.0.0.1"); -],[ - ac_cv_func_inet_network=yes -],[ - ac_cv_func_inet_network=no -]) -]) - -if test "$ac_cv_func_inet_network" = "yes"; then - have_inet_network=1 -else - have_inet_network=0 -fi -]) - -dnl Check for presence of struct sockaddr_storage. -AC_DEFUN([APR_CHECK_SOCKADDR_STORAGE], [ -AC_CACHE_CHECK(for sockaddr_storage, apr_cv_define_sockaddr_storage,[ -AC_TRY_COMPILE([ -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif -],[struct sockaddr_storage sa;], -[apr_cv_define_sockaddr_storage=yes], -[apr_cv_define_sockaddr_storage=no])]) - -if test "$apr_cv_define_sockaddr_storage" = "yes"; then - have_sa_storage=1 -else - have_sa_storage=0 -fi -AC_SUBST(have_sa_storage) -]) - -dnl Check for presence of struct sockaddr_in6. -AC_DEFUN([APR_CHECK_SOCKADDR_IN6], [ -AC_CACHE_CHECK(for sockaddr_in6, ac_cv_define_sockaddr_in6,[ -AC_TRY_COMPILE([ -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif -],[ -struct sockaddr_in6 sa; -],[ - ac_cv_define_sockaddr_in6=yes -],[ - ac_cv_define_sockaddr_in6=no -]) -]) - -if test "$ac_cv_define_sockaddr_in6" = "yes"; then - have_sockaddr_in6=1 -else - have_sockaddr_in6=0 -fi -]) - -dnl -dnl APR_H_ERRNO_COMPILE_CHECK -dnl -AC_DEFUN([APR_H_ERRNO_COMPILE_CHECK], [ - if test x$1 != x; then - CPPFLAGS="-D$1 $CPPFLAGS" - fi - AC_TRY_COMPILE([ -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_NETDB_H -#include -#endif -],[ -int h_e = h_errno; -],[ - if test x$1 != x; then - ac_cv_h_errno_cppflags="$1" - else - ac_cv_h_errno_cppflags=yes - fi -],[ - ac_cv_h_errno_cppflags=no -])]) - - -dnl -dnl APR_CHECK_SCTP -dnl -dnl check for presence of SCTP protocol support -dnl -AC_DEFUN([APR_CHECK_SCTP], -[ - AC_CACHE_CHECK([whether SCTP is supported], [apr_cv_sctp], [ - AC_TRY_RUN([ -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_SOCKET_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_NETINET_SCTP_H -#include -#endif -#ifdef HAVE_NETINET_SCTP_UIO_H -#include -#endif -#include -int main(void) { - int s, opt = 1; - if ((s = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP)) < 0) - exit(1); - if (setsockopt(s, IPPROTO_SCTP, SCTP_NODELAY, &opt, sizeof(int)) < 0) - exit(2); - exit(0); -}], [apr_cv_sctp=yes], [apr_cv_sctp=no], [apr_cv_sctp=no])]) - -if test "$apr_cv_sctp" = "yes"; then - have_sctp=1 -else - have_sctp=0 -fi -]) - -dnl APR_CHECK_MCAST: check for multicast interfaces -AC_DEFUN([APR_CHECK_MCAST], [ -AC_CACHE_CHECK([for struct ip_mreq], [apr_cv_struct_ipmreq], [ -AC_TRY_COMPILE([ -#include -#include -], [ - struct ip_mreq mip; - mip.imr_interface.s_addr = INADDR_ANY; -], [apr_cv_struct_ipmreq=yes], [apr_cv_struct_ipmreq=no], [apr_cv_struct_ipmreq=yes])]) - -if test $apr_cv_struct_ipmreq = yes; then - AC_DEFINE([HAVE_STRUCT_IPMREQ], 1, [Define if struct impreq was found]) -fi -]) - -dnl -dnl APR_CHECK_H_ERRNO_FLAG -dnl -dnl checks which flags are necessary for to define h_errno -dnl -AC_DEFUN([APR_CHECK_H_ERRNO_FLAG], [ - AC_MSG_CHECKING([for h_errno in netdb.h]) - AC_CACHE_VAL(ac_cv_h_errno_cppflags,[ - APR_H_ERRNO_COMPILE_CHECK - if test "$ac_cv_h_errno_cppflags" = "no"; then - ac_save="$CPPFLAGS" - for flag in _XOPEN_SOURCE_EXTENDED; do - APR_H_ERRNO_COMPILE_CHECK($flag) - if test "$ac_cv_h_errno_cppflags" != "no"; then - break - fi - done - CPPFLAGS="$ac_save" - fi - ]) - if test "$ac_cv_h_errno_cppflags" != "no"; then - if test "$ac_cv_h_errno_cppflags" != "yes"; then - CPPFLAGS="-D$ac_cv_h_errno_cppflags $CPPFLAGS" - AC_MSG_RESULT([yes, with -D$ac_cv_h_errno_cppflags]) - else - AC_MSG_RESULT([$ac_cv_h_errno_cppflags]) - fi - else - AC_MSG_RESULT([$ac_cv_h_errno_cppflags]) - fi -]) - - -AC_DEFUN([APR_EBCDIC], [ - AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[ - AC_TRY_RUN( [ -int main(void) { - return (unsigned char)'A' != (unsigned char)0xC1; -} -],[ - ac_cv_ebcdic="yes" -],[ - ac_cv_ebcdic="no" -],[ - ac_cv_ebcdic="no" -])]) - if test "$ac_cv_ebcdic" = "yes"; then - apr_charset_ebcdic=1 - else - apr_charset_ebcdic=0 - fi - AC_SUBST(apr_charset_ebcdic) -]) - diff --git a/libs/apr/build/apr_rules.mk.in b/libs/apr/build/apr_rules.mk.in deleted file mode 100644 index 03e02aa8..00000000 --- a/libs/apr/build/apr_rules.mk.in +++ /dev/null @@ -1,208 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# - -# -# rules.mk: standard rules for APR -# - -@SET_MAKE@ - -# -# Configuration variables -# -apr_builddir=@apr_builddir@ -apr_builders=@apr_builders@ -top_builddir=@apr_builddir@ - -# Some layouts require knowing what version we are at. -APR_MAJOR_VERSION=@APR_MAJOR_VERSION@ -APR_DOTTED_VERSION=@APR_DOTTED_VERSION@ - -CC=@CC@ -RM=@RM@ -AWK=@AWK@ -SHELL=@SHELL@ -LIBTOOL=@LIBTOOL@ - -# compilation and linking flags that are supposed to be set only by the user. -# configure adds to them for tests, but we restore them at the end. -# -CFLAGS=@CFLAGS@ -CPPFLAGS=@CPPFLAGS@ -LDFLAGS=@LDFLAGS@ -LIBS=@LIBS@ -DEFS=@DEFS@ - -# anything added to the standard flags by configure is moved to EXTRA_* -# at the end of the process. -# -EXTRA_CFLAGS=@EXTRA_CFLAGS@ -EXTRA_CPPFLAGS=@EXTRA_CPPFLAGS@ -EXTRA_LDFLAGS=@EXTRA_LDFLAGS@ -EXTRA_LIBS=@EXTRA_LIBS@ -EXTRA_INCLUDES=@EXTRA_INCLUDES@ - -# NOTEST_* are flags and libraries that can be added by the user without -# causing them to be used in configure tests (necessary for things like -# -Werror and other strict warnings that maintainers like to use). -# -NOTEST_CFLAGS=@NOTEST_CFLAGS@ -NOTEST_CPPFLAGS=@NOTEST_CPPFLAGS@ -NOTEST_LDFLAGS=@NOTEST_LDFLAGS@ -NOTEST_LIBS=@NOTEST_LIBS@ - -# Finally, combine all of the flags together in the proper order so that -# the user-defined flags can always override the configure ones, if needed. -# Note that includes are listed after the flags because -I options have -# left-to-right precedence and CPPFLAGS may include user-defined overrides. -# -ALL_CFLAGS = $(EXTRA_CFLAGS) $(NOTEST_CFLAGS) $(CFLAGS) -ALL_CPPFLAGS = $(DEFS) $(EXTRA_CPPFLAGS) $(NOTEST_CPPFLAGS) $(CPPFLAGS) -ALL_LDFLAGS = $(EXTRA_LDFLAGS) $(NOTEST_LDFLAGS) $(LDFLAGS) -ALL_LIBS = $(LIBS) $(NOTEST_LIBS) $(EXTRA_LIBS) -ALL_INCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) - -LTFLAGS = @LTFLAGS@ -LT_LDFLAGS = @LT_LDFLAGS@ - -# The set of object files that will be linked into the target library. -# The build-outputs.mk specifies a different set for each platform. The -# configure script will select the appropriate set. -# -OBJECTS = @OBJECTS_PLATFORM@ - -# -# Basic macro setup -# -COMPILE = $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(ALL_INCLUDES) -LT_COMPILE = @lt_compile@ - -LINK = @link@ - -APR_MKDIR = $(apr_builders)/mkdir.sh -APR_MKEXPORT = $(AWK) -f $(apr_builders)/make_exports.awk -APR_MKVAREXPORT = $(AWK) -f $(apr_builders)/make_var_export.awk -MKDEP = @MKDEP@ - -# -# Standard build rules -# -all: all-recursive -depend: depend-recursive -clean: clean-recursive -distclean: distclean-recursive -extraclean: extraclean-recursive - -install: all-recursive - - -all-recursive depend-recursive: - @otarget=`echo $@ | sed s/-recursive//`; \ - list='$(SOURCE_DIRS)'; \ - for i in $$list; do \ - if test -f "$$i/Makefile"; then \ - target="$$otarget"; \ - echo "Making $$target in $$i"; \ - if test "$$i" = "."; then \ - made_local=yes; \ - target="local-$$target"; \ - fi; \ - (cd $$i && $(MAKE) $$target) || exit 1; \ - fi; \ - done; \ - if test "$$otarget" = "all" && test -z "$(TARGETS)"; then \ - made_local=yes; \ - fi; \ - if test "$$made_local" != "yes"; then \ - $(MAKE) "local-$$otarget" || exit 1; \ - fi - -clean-recursive distclean-recursive extraclean-recursive: - @otarget=`echo $@ | sed s/-recursive//`; \ - list='$(CLEAN_SUBDIRS)'; \ - for i in $$list; do \ - if test -f "$$i/Makefile"; then \ - target="$$otarget"; \ - echo "Making $$target in $$i"; \ - if test "$$i" = "."; then \ - made_local=yes; \ - target="local-$$target"; \ - fi; \ - (cd $$i && $(MAKE) $$target); \ - fi; \ - done; \ - if test "$$otarget" = "all" && test -z "$(TARGETS)"; then \ - made_local=yes; \ - fi; \ - if test "$$made_local" != "yes"; then \ - $(MAKE) "local-$$otarget"; \ - fi - -# autoconf 2.5x is creating a 'autom4te.cache' directory -# In case someone ran autoconf by hand, get rid of that directory -# as well. -local-clean: x-local-clean - @list='. $(SOURCE_DIRS)'; \ - for i in $$list; do \ - echo $(RM) -f $$i/*.o $$i/*.lo $$i/*.a $$i/*.la $$i/*.so $$i/*.obj; \ - $(RM) -f $$i/*.o $$i/*.lo $$i/*.a $$i/*.la $$i/*.so $$i/*.obj; \ - echo $(RM) -rf $$i/.libs; \ - $(RM) -rf $$i/.libs; \ - done - $(RM) -f $(CLEAN_TARGETS) $(PROGRAMS) - $(RM) -rf autom4te.cache - -local-distclean: local-clean x-local-distclean - $(RM) -f Makefile $(DISTCLEAN_TARGETS) - -local-extraclean: local-distclean x-local-extraclean - @if test -n "$(EXTRACLEAN_TARGETS)"; then \ - echo $(RM) -f $(EXTRACLEAN_TARGETS) ; \ - $(RM) -f $(EXTRACLEAN_TARGETS) ; \ - fi - -local-all: $(TARGETS) - -local-depend: x-local-depend - @if test -n "`ls $(srcdir)/*.c 2> /dev/null`"; then \ - $(RM) -f .deps; \ - list='$(srcdir)/*.c'; \ - for i in $$list; do \ - $(MKDEP) $(ALL_CPPFLAGS) $(ALL_INCLUDES) $$i | sed 's/\.o:/.lo:/' >> .deps; \ - done; \ - fi - -# to be filled in by the actual Makefile -x-local-depend x-local-clean x-local-distclean x-local-extraclean: - -# -# Implicit rules for creating outputs from input files -# -.SUFFIXES: -.SUFFIXES: .c .lo .o - -.c.o: - $(COMPILE) -c $< - -.c.lo: - $(LT_COMPILE) - -.PHONY: all all-recursive local-all install \ - depend depend-recursive local-depend x-local-depend \ - clean clean-recursive local-clean x-local-clean \ - distclean distclean-recursive local-distclean x-local-distclean \ - extraclean extraclean-recursive local-extraclean x-local-extraclean diff --git a/libs/apr/build/apr_threads.m4 b/libs/apr/build/apr_threads.m4 deleted file mode 100644 index cbc677b1..00000000 --- a/libs/apr/build/apr_threads.m4 +++ /dev/null @@ -1,283 +0,0 @@ -dnl -------------------------------------------------------- -*- autoconf -*- -dnl Licensed to the Apache Software Foundation (ASF) under one or more -dnl contributor license agreements. See the NOTICE file distributed with -dnl this work for additional information regarding copyright ownership. -dnl The ASF licenses this file to You under the Apache License, Version 2.0 -dnl (the "License"); you may not use this file except in compliance with -dnl the License. You may obtain a copy of the License at -dnl -dnl http://www.apache.org/licenses/LICENSE-2.0 -dnl -dnl Unless required by applicable law or agreed to in writing, software -dnl distributed under the License is distributed on an "AS IS" BASIS, -dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -dnl See the License for the specific language governing permissions and -dnl limitations under the License. - -dnl ----------------------------------------------------------------- -dnl apr_threads.m4: APR's autoconf macros for testing thread support -dnl - -dnl -dnl APR_CHECK_PTHREADS_H([ ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) -dnl -dnl gcc issues warnings when parsing AIX 4.3.3's pthread.h -dnl which causes autoconf to incorrectly conclude that -dnl pthreads is not available. -dnl Turn off warnings if we're using gcc. -dnl -AC_DEFUN(APR_CHECK_PTHREADS_H, [ - if test "$GCC" = "yes"; then - SAVE_FL="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS -w" - AC_CHECK_HEADERS(pthread.h, [ $1 ] , [ $2 ] ) - CPPFLAGS="$SAVE_FL" - else - AC_CHECK_HEADERS(pthread.h, [ $1 ] , [ $2 ] ) - fi -])dnl - - -dnl -dnl APR_CHECK_PTHREAD_GETSPECIFIC_TWO_ARGS -dnl -AC_DEFUN(APR_CHECK_PTHREAD_GETSPECIFIC_TWO_ARGS, [ -AC_CACHE_CHECK(whether pthread_getspecific takes two arguments, ac_cv_pthread_getspecific_two_args,[ -AC_TRY_COMPILE([ -#include -],[ -pthread_key_t key; -void *tmp; -pthread_getspecific(key,&tmp); -],[ - ac_cv_pthread_getspecific_two_args=yes -],[ - ac_cv_pthread_getspecific_two_args=no -]) -]) - -if test "$ac_cv_pthread_getspecific_two_args" = "yes"; then - AC_DEFINE(PTHREAD_GETSPECIFIC_TAKES_TWO_ARGS, 1, [Define if pthread_getspecific() has two args]) -fi -])dnl - - -dnl -dnl APR_CHECK_PTHREAD_ATTR_GETDETACHSTATE_ONE_ARG -dnl -AC_DEFUN(APR_CHECK_PTHREAD_ATTR_GETDETACHSTATE_ONE_ARG, [ -AC_CACHE_CHECK(whether pthread_attr_getdetachstate takes one argument, ac_cv_pthread_attr_getdetachstate_one_arg,[ -AC_TRY_COMPILE([ -#include -],[ -pthread_attr_t *attr; -pthread_attr_getdetachstate(attr); -],[ - ac_cv_pthread_attr_getdetachstate_one_arg=yes -],[ - ac_cv_pthread_attr_getdetachstate_one_arg=no -]) -]) - -if test "$ac_cv_pthread_attr_getdetachstate_one_arg" = "yes"; then - AC_DEFINE(PTHREAD_ATTR_GETDETACHSTATE_TAKES_ONE_ARG, 1, [Define if pthread_attr_getdetachstate() has one arg]) -fi -])dnl - - -dnl -dnl APR_PTHREADS_TRY_RUN(actions-if-success) -dnl -dnl Try running a program which uses pthreads, executing the -dnl actions-if-success commands on success. -dnl -AC_DEFUN(APR_PTHREADS_TRY_RUN, [ -AC_TRY_RUN( [ -#include -#include - -void *thread_routine(void *data) { - return data; -} - -int main() { - pthread_t thd; - pthread_mutexattr_t mattr; - pthread_once_t once_init = PTHREAD_ONCE_INIT; - int data = 1; - pthread_mutexattr_init(&mattr); - return pthread_create(&thd, NULL, thread_routine, &data); -} ], [apr_p_t_r=yes], [apr_p_t_r=no], [apr_p_t_r=no]) - -if test $apr_p_t_r = yes; then - $1 -fi - -])dnl - - -dnl -dnl APR_PTHREADS_CHECK() -dnl -dnl Try to find a way to enable POSIX threads. Sets the -dnl pthreads_working variable to "yes" on success. -dnl -AC_DEFUN([APR_PTHREADS_CHECK], [ - -AC_CACHE_CHECK([for CFLAGS needed for pthreads], [apr_cv_pthreads_cflags], -[apr_ptc_cflags=$CFLAGS - for flag in none -kthread -pthread -pthreads -mt -mthreads -Kthread -threads; do - CFLAGS=$apr_ptc_cflags - test "x$flag" != "xnone" && CFLAGS="$CFLAGS $flag" - APR_PTHREADS_TRY_RUN([ - apr_cv_pthreads_cflags="$flag" - break - ]) - done - CFLAGS=$apr_ptc_cflags -]) - -if test -n "$apr_cv_pthreads_cflags"; then - pthreads_working=yes - if test "x$apr_cv_pthreads_cflags" != "xnone"; then - APR_ADDTO(CFLAGS,[$apr_cv_pthreads_cflags]) - fi -fi - -# The CFLAGS may or may not be sufficient to ensure that libapr -# depends on the pthreads library: some versions of libtool -# drop -pthread when passed on the link line; some versions of -# gcc ignore -pthread when linking a shared object. So always -# try and add the relevant library to LIBS too. - -AC_CACHE_CHECK([for LIBS needed for pthreads], [apr_cv_pthreads_lib], [ - apr_ptc_libs=$LIBS - for lib in -lpthread -lpthreads -lc_r; do - LIBS="$apr_ptc_libs $lib" - APR_PTHREADS_TRY_RUN([ - apr_cv_pthreads_lib=$lib - break - ]) - done - LIBS=$apr_ptc_libs -]) - -if test -n "$apr_cv_pthreads_lib"; then - pthreads_working=yes - APR_ADDTO(LIBS,[$apr_cv_pthreads_lib]) -fi - -if test "$pthreads_working" = "yes"; then - threads_result="POSIX Threads found" -else - threads_result="POSIX Threads not found" -fi -])dnl - -dnl -dnl APR_PTHREADS_CHECK_SAVE -dnl APR_PTHREADS_CHECK_RESTORE -dnl -dnl Save the global environment variables that might be modified during -dnl the checks for threading support so that they can restored if the -dnl result is not what the caller wanted. -dnl -AC_DEFUN(APR_PTHREADS_CHECK_SAVE, [ - apr_pthsv_CFLAGS="$CFLAGS" - apr_pthsv_LIBS="$LIBS" -])dnl - -AC_DEFUN(APR_PTHREADS_CHECK_RESTORE, [ - CFLAGS="$apr_pthsv_CFLAGS" - LIBS="$apr_pthsv_LIBS" -])dnl - -dnl -dnl APR_CHECK_SIGWAIT_ONE_ARG -dnl -AC_DEFUN([APR_CHECK_SIGWAIT_ONE_ARG], [ - AC_CACHE_CHECK(whether sigwait takes one argument,ac_cv_sigwait_one_arg,[ - AC_TRY_COMPILE([ -#if defined(__NETBSD__) || defined(DARWIN) - /* When using the unproven-pthreads package, we need to pull in this - * header to get a prototype for sigwait(). Else things will fail later - * on. XXX Should probably be fixed in the unproven-pthreads package. - * Darwin is declaring sigwait() in the wrong place as well. - */ -#include -#endif -#include -],[ - sigset_t set; - - sigwait(&set); -],[ - ac_cv_sigwait_one_arg=yes -],[ - ac_cv_sigwait_one_arg=no -])]) - if test "$ac_cv_sigwait_one_arg" = "yes"; then - AC_DEFINE(SIGWAIT_TAKES_ONE_ARG,1,[ ]) - fi -]) - -dnl Check for recursive mutex support (per SUSv3). -AC_DEFUN([APR_CHECK_PTHREAD_RECURSIVE_MUTEX], [ - AC_CACHE_CHECK([for recursive mutex support], [apr_cv_mutex_recursive], -[AC_TRY_RUN([#include -#include -#include - -int main() { - pthread_mutexattr_t attr; - pthread_mutex_t m; - - exit (pthread_mutexattr_init(&attr) - || pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) - || pthread_mutex_init(&m, &attr)); -}], [apr_cv_mutex_recursive=yes], [apr_cv_mutex_recursive=no], -[apr_cv_mutex_recursive=no])]) - -if test "$apr_cv_mutex_recursive" = "yes"; then - AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], 1, - [Define if recursive pthread mutexes are available]) -fi -]) - -dnl Check for robust process-shared mutex support -AC_DEFUN([APR_CHECK_PTHREAD_ROBUST_SHARED_MUTEX], [ -AC_CACHE_CHECK([for robust cross-process mutex support], -[apr_cv_mutex_robust_shared], -[AC_TRY_RUN([ -#include -#include -#include - -int main(int argc, char **argv) -{ - pthread_mutex_t mutex; - pthread_mutexattr_t attr; - - if (pthread_mutexattr_init(&attr)) - exit(1); - if (pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED)) - exit(2); - if (pthread_mutexattr_setrobust_np(&attr, PTHREAD_MUTEX_ROBUST_NP)) - exit(3); - if (pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT)) - exit(4); - if (pthread_mutex_init(&mutex, &attr)) - exit(5); - if (pthread_mutexattr_destroy(&attr)) - exit(6); - if (pthread_mutex_destroy(&mutex)) - exit(7); - - exit(0); -}], [apr_cv_mutex_robust_shared=yes], [apr_cv_mutex_robust_shared=no])]) - -if test "$apr_cv_mutex_robust_shared" = "yes"; then - AC_DEFINE([HAVE_PTHREAD_MUTEX_ROBUST], 1, - [Define if cross-process robust mutexes are available]) -fi -]) diff --git a/libs/apr/build/apr_win32.m4 b/libs/apr/build/apr_win32.m4 deleted file mode 100644 index f9813742..00000000 --- a/libs/apr/build/apr_win32.m4 +++ /dev/null @@ -1,33 +0,0 @@ - -dnl if $2 contains '@dd', links against mingw symbols -dnl otherwise calls AC_CHECK_LIB -AC_DEFUN([APR_CHECK_DLL_FUNC],[ -m4_define($1_function_name,m4_substr($2,0,m4_index($2,[@]))) -m4_define($1_function_arglength,m4_substr($2,m4_incr(m4_index($2,[@])))) -m4_define($1_[function_name]_arglength,m4_substr($2,m4_incr(m4_index($2,[@])))) -dnl m4_define(apr_check_dll_id,$1_m4_defn($1_function_name)) - -AC_CACHE_CHECK([for $2 in $1],[ac_cv_lib_$1_]$1_function_name,[ - -ac_func_search_save_LIBS=$LIBS -LIBS="$LIBS -l$1" - -AC_TRY_LINK([ -#pragma pack(1) -struct x { -]m4_for([byte_id], 1, m4_defn([$1_function_name_arglength]), 1,[[ char c]]byte_id; -)[}; -__stdcall ]$1_function_name[(]struct x[);],[ -struct x s = {0}; -]$1_function_name[(s)], -[ac_cv_lib_$1_]$1_function_name[=yes],[ac_cv_lib_$1_]$1_function_name[=no]) -LIBS=$ac_func_search_save_LIBS -])dnl AC_CACHE_CHECK - -AS_IF([test $ac_cv_lib_$1_]$1_function_name[ = yes], - [m4_default([$3], [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1),,Enable if this library is available) - LIBS="-l$1 $LIBS" -])], - [$4])dnl -]) - diff --git a/libs/apr/build/aprapp.dep b/libs/apr/build/aprapp.dep deleted file mode 100644 index 0155a451..00000000 --- a/libs/apr/build/aprapp.dep +++ /dev/null @@ -1,10 +0,0 @@ -# Microsoft Developer Studio Generated Dependency File, included by aprapp.mak - -..\misc\win32\apr_app.c : \ - "..\include\apr_getopt.h"\ - "..\include\apr_lib.h"\ - "..\include\apr_poll.h"\ - "..\include\apr_portable.h"\ - "..\include\arch\win32\apr_arch_file_io.h"\ - "..\include\arch\win32\apr_arch_utf8.h"\ - diff --git a/libs/apr/build/aprapp.dsp b/libs/apr/build/aprapp.dsp deleted file mode 100644 index b8b08ebd..00000000 --- a/libs/apr/build/aprapp.dsp +++ /dev/null @@ -1,191 +0,0 @@ -# Microsoft Developer Studio Project File - Name="aprapp" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=aprapp - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "aprapp.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "aprapp.mak" CFG="aprapp - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "aprapp - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "aprapp - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE "aprapp - Win32 Release9x" (based on "Win32 (x86) Static Library") -!MESSAGE "aprapp - Win32 Debug9x" (based on "Win32 (x86) Static Library") -!MESSAGE "aprapp - x64 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "aprapp - x64 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "aprapp - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "..\LibR" -# PROP BASE Intermediate_Dir "LibR" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\LibR" -# PROP Intermediate_Dir "LibR" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "NDEBUG" /D "WINNT" /D "WIN32" /D "_WINDOWS" /D APR_APP /D "APR_DECLARE_STATIC" /Fo"$(INTDIR)\" /Fd"$(OUTDIR)\aprapp-1" /FD /c -# ADD BASE RSC /l 0x409 -# ADD RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"..\LibR\aprapp-1.lib" - -!ELSEIF "$(CFG)" == "aprapp - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "..\LibD" -# PROP BASE Intermediate_Dir "LibD" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\LibD" -# PROP Intermediate_Dir "LibD" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "_DEBUG" /D "WINNT" /D "WIN32" /D "_WINDOWS" /D APR_APP /D "APR_DECLARE_STATIC" /Fo"$(INTDIR)\" /Fd"$(OUTDIR)\aprapp-1" /FD /c -# ADD BASE RSC /l 0x409 -# ADD RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"..\LibD\aprapp-1.lib" - -!ELSEIF "$(CFG)" == "aprapp - Win32 Release9x" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "..\9x\LibR" -# PROP BASE Intermediate_Dir "9x\LibR" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\9x\LibR" -# PROP Intermediate_Dir "9x\LibR" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D APR_APP /D "APR_DECLARE_STATIC" /Fo"$(INTDIR)\" /Fd"$(OUTDIR)\aprapp-1" /FD /c -# ADD BASE RSC /l 0x409 -# ADD RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"..\9x\LibR\aprapp-1.lib" - -!ELSEIF "$(CFG)" == "aprapp - Win32 Debug9x" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "..\9x\LibD" -# PROP BASE Intermediate_Dir "9x\LibD" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\9x\LibD" -# PROP Intermediate_Dir "9x\LibD" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D APR_APP /D "APR_DECLARE_STATIC" /Fo"$(INTDIR)\" /Fd"$(OUTDIR)\aprapp-1" /FD /c -# ADD BASE RSC /l 0x409 -# ADD RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"..\9x\LibD\aprapp-1.lib" - -!ELSEIF "$(CFG)" == "aprapp - x64 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "..\x64\LibR" -# PROP BASE Intermediate_Dir "x64\LibR" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\x64\LibR" -# PROP Intermediate_Dir "x64\LibR" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "NDEBUG" /D "WINNT" /D "WIN32" /D "_WINDOWS" /D APR_APP /D "APR_DECLARE_STATIC" /Fo"$(INTDIR)\" /Fd"$(OUTDIR)\aprapp-1" /FD /c -# ADD BASE RSC /l 0x409 -# ADD RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"..\x64\LibR\aprapp-1.lib" - -!ELSEIF "$(CFG)" == "aprapp - x64 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "..\x64\LibD" -# PROP BASE Intermediate_Dir "x64\LibD" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\x64\LibD" -# PROP Intermediate_Dir "x64\LibD" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "_DEBUG" /D "WINNT" /D "WIN32" /D "_WINDOWS" /D APR_APP /D "APR_DECLARE_STATIC" /Fo"$(INTDIR)\" /Fd"$(OUTDIR)\aprapp-1" /FD /c -# ADD BASE RSC /l 0x409 -# ADD RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"..\x64\LibD\aprapp-1.lib" - -!ENDIF - -# Begin Target - -# Name "aprapp - Win32 Release" -# Name "aprapp - Win32 Debug" -# Name "aprapp - Win32 Release9x" -# Name "aprapp - Win32 Debug9x" -# Name "aprapp - x64 Release" -# Name "aprapp - x64 Debug" -# Begin Source File - -SOURCE=..\misc\win32\apr_app.c -# End Source File -# End Target -# End Project diff --git a/libs/apr/build/aprapp.mak b/libs/apr/build/aprapp.mak deleted file mode 100644 index f0b61ce8..00000000 --- a/libs/apr/build/aprapp.mak +++ /dev/null @@ -1,614 +0,0 @@ -# Microsoft Developer Studio Generated NMAKE File, Based on aprapp.dsp -!IF "$(CFG)" == "" -CFG=aprapp - Win32 Release -!MESSAGE No configuration specified. Defaulting to aprapp - Win32 Release. -!ENDIF - -!IF "$(CFG)" != "aprapp - Win32 Release" && "$(CFG)" != "aprapp - Win32 Debug" && "$(CFG)" != "aprapp - Win32 Release9x" && "$(CFG)" != "aprapp - Win32 Debug9x" && "$(CFG)" != "aprapp - x64 Release" && "$(CFG)" != "aprapp - x64 Debug" -!MESSAGE Invalid configuration "$(CFG)" specified. -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "aprapp.mak" CFG="aprapp - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "aprapp - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "aprapp - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE "aprapp - Win32 Release9x" (based on "Win32 (x86) Static Library") -!MESSAGE "aprapp - Win32 Debug9x" (based on "Win32 (x86) Static Library") -!MESSAGE "aprapp - x64 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "aprapp - x64 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE -!ERROR An invalid configuration is specified. -!ENDIF - -!IF "$(OS)" == "Windows_NT" -NULL= -!ELSE -NULL=nul -!ENDIF - -!IF "$(CFG)" == "aprapp - Win32 Release" - -OUTDIR=.\..\LibR -INTDIR=.\LibR -# Begin Custom Macros -OutDir=.\..\LibR -# End Custom Macros - -!IF "$(RECURSE)" == "0" - -ALL : "$(OUTDIR)\aprapp-1.lib" - -!ELSE - -ALL : "preaprapp - Win32 Release" "$(OUTDIR)\aprapp-1.lib" - -!ENDIF - -!IF "$(RECURSE)" == "1" -CLEAN :"preaprapp - Win32 ReleaseCLEAN" -!ELSE -CLEAN : -!ENDIF - -@erase "$(INTDIR)\apr_app.obj" - -@erase "$(OUTDIR)\aprapp-1.lib" - -@erase "..\LibR\aprapp-1.idb" - -@erase "..\LibR\aprapp-1.pdb" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -"$(INTDIR)" : - if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "NDEBUG" /D "WINNT" /D "WIN32" /D "_WINDOWS" /D "APR_APP" /D "APR_DECLARE_STATIC" /Fo"$(INTDIR)\\" /Fd"$(OUTDIR)\aprapp-1" /FD /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -RSC=rc.exe -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\aprapp.bsc" -BSC32_SBRS= \ - -LIB32=link.exe -lib -LIB32_FLAGS=/nologo /out:"$(OUTDIR)\aprapp-1.lib" -LIB32_OBJS= \ - "$(INTDIR)\apr_app.obj" - -"$(OUTDIR)\aprapp-1.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) - $(LIB32) @<< - $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) -<< - -!ELSEIF "$(CFG)" == "aprapp - Win32 Debug" - -OUTDIR=.\..\LibD -INTDIR=.\LibD -# Begin Custom Macros -OutDir=.\..\LibD -# End Custom Macros - -!IF "$(RECURSE)" == "0" - -ALL : "$(OUTDIR)\aprapp-1.lib" - -!ELSE - -ALL : "preaprapp - Win32 Debug" "$(OUTDIR)\aprapp-1.lib" - -!ENDIF - -!IF "$(RECURSE)" == "1" -CLEAN :"preaprapp - Win32 DebugCLEAN" -!ELSE -CLEAN : -!ENDIF - -@erase "$(INTDIR)\apr_app.obj" - -@erase "$(OUTDIR)\aprapp-1.lib" - -@erase "..\LibD\aprapp-1.idb" - -@erase "..\LibD\aprapp-1.pdb" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -"$(INTDIR)" : - if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "_DEBUG" /D "WINNT" /D "WIN32" /D "_WINDOWS" /D "APR_APP" /D "APR_DECLARE_STATIC" /Fo"$(INTDIR)\\" /Fd"$(OUTDIR)\aprapp-1" /FD /EHsc /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -RSC=rc.exe -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\aprapp.bsc" -BSC32_SBRS= \ - -LIB32=link.exe -lib -LIB32_FLAGS=/nologo /out:"$(OUTDIR)\aprapp-1.lib" -LIB32_OBJS= \ - "$(INTDIR)\apr_app.obj" - -"$(OUTDIR)\aprapp-1.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) - $(LIB32) @<< - $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) -<< - -!ELSEIF "$(CFG)" == "aprapp - Win32 Release9x" - -OUTDIR=.\..\9x\LibR -INTDIR=.\9x\LibR -# Begin Custom Macros -OutDir=.\..\9x\LibR -# End Custom Macros - -!IF "$(RECURSE)" == "0" - -ALL : "$(OUTDIR)\aprapp-1.lib" - -!ELSE - -ALL : "preaprapp - Win32 Release9x" "$(OUTDIR)\aprapp-1.lib" - -!ENDIF - -!IF "$(RECURSE)" == "1" -CLEAN :"preaprapp - Win32 Release9xCLEAN" -!ELSE -CLEAN : -!ENDIF - -@erase "$(INTDIR)\apr_app.obj" - -@erase "$(OUTDIR)\aprapp-1.lib" - -@erase "..\9x\LibR\aprapp-1.idb" - -@erase "..\9x\LibR\aprapp-1.pdb" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -"$(INTDIR)" : - if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "APR_APP" /D "APR_DECLARE_STATIC" /Fo"$(INTDIR)\\" /Fd"$(OUTDIR)\aprapp-1" /FD /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -RSC=rc.exe -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\aprapp.bsc" -BSC32_SBRS= \ - -LIB32=link.exe -lib -LIB32_FLAGS=/nologo /out:"$(OUTDIR)\aprapp-1.lib" -LIB32_OBJS= \ - "$(INTDIR)\apr_app.obj" - -"$(OUTDIR)\aprapp-1.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) - $(LIB32) @<< - $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) -<< - -!ELSEIF "$(CFG)" == "aprapp - Win32 Debug9x" - -OUTDIR=.\..\9x\LibD -INTDIR=.\9x\LibD -# Begin Custom Macros -OutDir=.\..\9x\LibD -# End Custom Macros - -!IF "$(RECURSE)" == "0" - -ALL : "$(OUTDIR)\aprapp-1.lib" - -!ELSE - -ALL : "preaprapp - Win32 Debug9x" "$(OUTDIR)\aprapp-1.lib" - -!ENDIF - -!IF "$(RECURSE)" == "1" -CLEAN :"preaprapp - Win32 Debug9xCLEAN" -!ELSE -CLEAN : -!ENDIF - -@erase "$(INTDIR)\apr_app.obj" - -@erase "$(OUTDIR)\aprapp-1.lib" - -@erase "..\9x\LibD\aprapp-1.idb" - -@erase "..\9x\LibD\aprapp-1.pdb" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -"$(INTDIR)" : - if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "APR_APP" /D "APR_DECLARE_STATIC" /Fo"$(INTDIR)\\" /Fd"$(OUTDIR)\aprapp-1" /FD /EHsc /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -RSC=rc.exe -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\aprapp.bsc" -BSC32_SBRS= \ - -LIB32=link.exe -lib -LIB32_FLAGS=/nologo /out:"$(OUTDIR)\aprapp-1.lib" -LIB32_OBJS= \ - "$(INTDIR)\apr_app.obj" - -"$(OUTDIR)\aprapp-1.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) - $(LIB32) @<< - $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) -<< - -!ELSEIF "$(CFG)" == "aprapp - x64 Release" - -OUTDIR=.\..\x64\LibR -INTDIR=.\x64\LibR -# Begin Custom Macros -OutDir=.\..\x64\LibR -# End Custom Macros - -!IF "$(RECURSE)" == "0" - -ALL : "$(OUTDIR)\aprapp-1.lib" - -!ELSE - -ALL : "preaprapp - x64 Release" "$(OUTDIR)\aprapp-1.lib" - -!ENDIF - -!IF "$(RECURSE)" == "1" -CLEAN :"preaprapp - x64 ReleaseCLEAN" -!ELSE -CLEAN : -!ENDIF - -@erase "$(INTDIR)\apr_app.obj" - -@erase "$(OUTDIR)\aprapp-1.lib" - -@erase "..\x64\LibR\aprapp-1.idb" - -@erase "..\x64\LibR\aprapp-1.pdb" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -"$(INTDIR)" : - if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "NDEBUG" /D "WINNT" /D "WIN32" /D "_WINDOWS" /D "APR_APP" /D "APR_DECLARE_STATIC" /Fo"$(INTDIR)\\" /Fd"$(OUTDIR)\aprapp-1" /FD /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -RSC=rc.exe -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\aprapp.bsc" -BSC32_SBRS= \ - -LIB32=link.exe -lib -LIB32_FLAGS=/nologo /out:"$(OUTDIR)\aprapp-1.lib" -LIB32_OBJS= \ - "$(INTDIR)\apr_app.obj" - -"$(OUTDIR)\aprapp-1.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) - $(LIB32) @<< - $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) -<< - -!ELSEIF "$(CFG)" == "aprapp - x64 Debug" - -OUTDIR=.\..\x64\LibD -INTDIR=.\x64\LibD -# Begin Custom Macros -OutDir=.\..\x64\LibD -# End Custom Macros - -!IF "$(RECURSE)" == "0" - -ALL : "$(OUTDIR)\aprapp-1.lib" - -!ELSE - -ALL : "preaprapp - x64 Debug" "$(OUTDIR)\aprapp-1.lib" - -!ENDIF - -!IF "$(RECURSE)" == "1" -CLEAN :"preaprapp - x64 DebugCLEAN" -!ELSE -CLEAN : -!ENDIF - -@erase "$(INTDIR)\apr_app.obj" - -@erase "$(OUTDIR)\aprapp-1.lib" - -@erase "..\x64\LibD\aprapp-1.idb" - -@erase "..\x64\LibD\aprapp-1.pdb" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -"$(INTDIR)" : - if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "_DEBUG" /D "WINNT" /D "WIN32" /D "_WINDOWS" /D "APR_APP" /D "APR_DECLARE_STATIC" /Fo"$(INTDIR)\\" /Fd"$(OUTDIR)\aprapp-1" /FD /EHsc /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -RSC=rc.exe -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\aprapp.bsc" -BSC32_SBRS= \ - -LIB32=link.exe -lib -LIB32_FLAGS=/nologo /out:"$(OUTDIR)\aprapp-1.lib" -LIB32_OBJS= \ - "$(INTDIR)\apr_app.obj" - -"$(OUTDIR)\aprapp-1.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) - $(LIB32) @<< - $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) -<< - -!ENDIF - - -!IF "$(NO_EXTERNAL_DEPS)" != "1" -!IF EXISTS("aprapp.dep") -!INCLUDE "aprapp.dep" -!ELSE -!MESSAGE Warning: cannot find "aprapp.dep" -!ENDIF -!ENDIF - - -!IF "$(CFG)" == "aprapp - Win32 Release" || "$(CFG)" == "aprapp - Win32 Debug" || "$(CFG)" == "aprapp - Win32 Release9x" || "$(CFG)" == "aprapp - Win32 Debug9x" || "$(CFG)" == "aprapp - x64 Release" || "$(CFG)" == "aprapp - x64 Debug" - -!IF "$(CFG)" == "aprapp - Win32 Release" - -"preaprapp - Win32 Release" : - cd "." - NMAKE /nologo /f NUL - cd "." - -"preaprapp - Win32 ReleaseCLEAN" : - cd "." - cd "." - -!ELSEIF "$(CFG)" == "aprapp - Win32 Debug" - -"preaprapp - Win32 Debug" : - cd "." - NMAKE /nologo /f NUL - cd "." - -"preaprapp - Win32 DebugCLEAN" : - cd "." - cd "." - -!ELSEIF "$(CFG)" == "aprapp - Win32 Release9x" - -"preaprapp - Win32 Release9x" : - cd "." - NMAKE /nologo /f NUL - cd "." - -"preaprapp - Win32 Release9xCLEAN" : - cd "." - cd "." - -!ELSEIF "$(CFG)" == "aprapp - Win32 Debug9x" - -"preaprapp - Win32 Debug9x" : - cd "." - NMAKE /nologo /f NUL - cd "." - -"preaprapp - Win32 Debug9xCLEAN" : - cd "." - cd "." - -!ELSEIF "$(CFG)" == "aprapp - x64 Release" - -"preaprapp - x64 Release" : - cd "." - NMAKE /nologo /f NUL - cd "." - -"preaprapp - x64 ReleaseCLEAN" : - cd "." - cd "." - -!ELSEIF "$(CFG)" == "aprapp - x64 Debug" - -"preaprapp - x64 Debug" : - cd "." - NMAKE /nologo /f NUL - cd "." - -"preaprapp - x64 DebugCLEAN" : - cd "." - cd "." - -!ENDIF - -SOURCE=..\misc\win32\apr_app.c - -"$(INTDIR)\apr_app.obj" : $(SOURCE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - - -!ENDIF - diff --git a/libs/apr/build/buildcheck.sh b/libs/apr/build/buildcheck.sh deleted file mode 100644 index 532602e9..00000000 --- a/libs/apr/build/buildcheck.sh +++ /dev/null @@ -1,66 +0,0 @@ -#! /bin/sh - -echo "buildconf: checking installation..." - -# any python -python=`build/PrintPath python` -if test -z "$python"; then -echo "buildconf: python not found." -echo " You need python installed" -echo " to build APR from SVN." -exit 1 -else -py_version=`python -c 'import sys; print sys.version' 2>&1|sed 's/ .*//;q'` -echo "buildconf: python version $py_version (ok)" -fi - -# autoconf 2.59 or newer -ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;q'` -if test -z "$ac_version"; then -echo "buildconf: autoconf not found." -echo " You need autoconf version 2.59 or newer installed" -echo " to build APR from SVN." -exit 1 -fi -IFS=.; set $ac_version; IFS=' ' -if test "$1" = "2" -a "$2" -lt "59" || test "$1" -lt "2"; then -echo "buildconf: autoconf version $ac_version found." -echo " You need autoconf version 2.59 or newer installed" -echo " to build APR from SVN." -exit 1 -else -echo "buildconf: autoconf version $ac_version (ok)" -fi - -# Sample libtool --version outputs: -# ltmain.sh (GNU libtool) 1.3.3 (1.385.2.181 1999/07/02 15:49:11) -# ltmain.sh (GNU libtool 1.1361 2004/01/02 23:10:52) 1.5a -# output is multiline from 1.5 onwards - -# Require libtool 1.4 or newer -libtool=`build/PrintPath glibtool1 glibtool libtool libtool15 libtool14` -lt_pversion=`$libtool --version 2>/dev/null|sed -e 's/([^)]*)//g;s/^[^0-9]*//;s/[- ].*//g;q'` -if test -z "$lt_pversion"; then -echo "buildconf: libtool not found." -echo " You need libtool version 1.4 or newer installed" -echo " to build APR from SVN." -exit 1 -fi -lt_version=`echo $lt_pversion|sed -e 's/\([a-z]*\)$/.\1/'` -IFS=.; set $lt_version; IFS=' ' -lt_status="good" -if test "$1" = "1"; then - if test "$2" -lt "4"; then - lt_status="bad" - fi -fi -if test $lt_status = "good"; then - echo "buildconf: libtool version $lt_pversion (ok)" - exit 0 -fi - -echo "buildconf: libtool version $lt_pversion found." -echo " You need libtool version 1.4 or newer installed" -echo " to build APR from SVN." - -exit 1 diff --git a/libs/apr/build/config.guess b/libs/apr/build/config.guess deleted file mode 100644 index 40eaed48..00000000 --- a/libs/apr/build/config.guess +++ /dev/null @@ -1,1517 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -# 2011 Free Software Foundation, Inc. - -timestamp='2011-05-11' - -# This file 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., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - - -# Originally written by Per Bothner. Please send patches (context -# diff format) to and include a ChangeLog -# entry. -# -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. -# -# You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free -Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - -trap 'exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. Note that the use of a -# compiler to aid in system detection is discouraged as it requires -# temporary files to be created and, as you can see below, it is a -# headache to deal with in a portable fashion. - -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -# Portable tmp directory creation inspired by the Autoconf team. - -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) - # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # - # Note: NetBSD doesn't particularly care about the vendor - # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in - armeb) machine=armeb-unknown ;; - arm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; - sh5el) machine=sh5le-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in - arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ELF__ - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # The OS release - # Debian GNU/NetBSD machines have a different userland, and - # thus, need a distinct triplet. However, they do not need - # kernel version information, so it can be replaced with a - # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in - Debian*) - release='-gnu' - ;; - *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - ;; - esac - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" - exit ;; - *:OpenBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} - exit ;; - *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} - exit ;; - *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} - exit ;; - macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} - exit ;; - *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} - exit ;; - alpha:OSF1:*:*) - case $UNAME_RELEASE in - *4.0) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - ;; - *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` - ;; - esac - # According to Compaq, /usr/sbin/psrinfo has been available on - # OSF/1 and Tru64 systems produced since 1995. I hope that - # covers most systems running today. This code pipes the CPU - # types through head -n 1, so we only detect the type of CPU 0. - ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in - "EV4 (21064)") - UNAME_MACHINE="alpha" ;; - "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; - "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; - "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; - "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; - "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; - "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; - "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; - "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; - "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; - "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; - "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; - "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; - esac - # A Pn.n version is a patched version. - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - # Reset EXIT trap before exiting to avoid spurious non-zero exit code. - exitcode=$? - trap '' 0 - exit $exitcode ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit ;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit ;; - *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit ;; - *:z/VM:*:*) - echo s390-ibm-zvmoe - exit ;; - *:OS400:*:*) - echo powerpc-ibm-os400 - exit ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit ;; - arm:riscos:*:*|arm:RISCOS:*:*) - echo arm-unknown-riscos - exit ;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit ;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit ;; - DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit ;; - DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) - case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7; exit ;; - esac ;; - s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} - exit ;; - i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build - SUN_ARCH="i386" - # If there is a compiler, see if it is configured for 64-bit objects. - # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. - # This test works for both compilers. - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - SUN_ARCH="x86_64" - fi - fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; - m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} - exit ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && - { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} - exit ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit ;; - Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` - then - echo "$SYSTEM_NAME" - else - echo rs6000-ibm-aix3.2.5 - fi - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit ;; - *:AIX:*:[4567]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac - fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` - test -z "$HP_ARCH" && HP_ARCH=hppa - fi ;; - esac - if [ ${HP_ARCH} = "hppa2.0w" ] - then - eval $set_cc_for_build - - # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating - # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler - # generating 64-bit code. GNU and HP use different nomenclature: - # - # $ CC_FOR_BUILD=cc ./config.guess - # => hppa2.0w-hp-hpux11.23 - # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess - # => hppa64-hp-hpux11.23 - - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | - grep -q __LP64__ - then - HP_ARCH="hppa2.0w" - else - HP_ARCH="hppa64" - fi - fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 - exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:FreeBSD:*:*) - case ${UNAME_MACHINE} in - pc98) - echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - esac - exit ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit ;; - *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 - exit ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit ;; - *:Interix*:*) - case ${UNAME_MACHINE} in - x86) - echo i586-pc-interix${UNAME_RELEASE} - exit ;; - authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix${UNAME_RELEASE} - exit ;; - IA64) - echo ia64-unknown-interix${UNAME_RELEASE} - exit ;; - esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit ;; - amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - *:GNU:*:*) - # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit ;; - *:GNU/*:*:*) - # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu - exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} - exit ;; - arm*:Linux:*:*) - eval $set_cc_for_build - if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_EABI__ - then - echo ${UNAME_MACHINE}-unknown-linux-gnu - else - if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_PCS_VFP - then - echo ${UNAME_MACHINE}-unknown-linux-gnueabi - else - echo ${UNAME_MACHINE}-unknown-linux-gnueabihf - fi - fi - exit ;; - avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - cris:Linux:*:*) - echo cris-axis-linux-gnu - exit ;; - crisv32:Linux:*:*) - echo crisv32-axis-linux-gnu - exit ;; - frv:Linux:*:*) - echo frv-unknown-linux-gnu - exit ;; - i*86:Linux:*:*) - LIBC=gnu - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` - echo "${UNAME_MACHINE}-pc-linux-${LIBC}" - exit ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } - ;; - or32:Linux:*:*) - echo or32-unknown-linux-gnu - exit ;; - padre:Linux:*:*) - echo sparc-unknown-linux-gnu - exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu - exit ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-gnu ;; - PA8*) echo hppa2.0-unknown-linux-gnu ;; - *) echo hppa-unknown-linux-gnu ;; - esac - exit ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu - exit ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu - exit ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux - exit ;; - sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - tile*:Linux:*:*) - echo ${UNAME_MACHINE}-tilera-linux-gnu - exit ;; - vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-gnu - exit ;; - x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu - exit ;; - xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 - exit ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit ;; - i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit ;; - i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` - (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i586. - # Note: whatever this is, it MUST be the same as what config.sub - # prints for the "djgpp" host, or else GDB configury will decide that - # this is a cross-build. - echo i586-pc-msdosdjgpp - exit ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit ;; - mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit ;; - M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit ;; - M68*:*:R3V[5678]*:*) - test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; - 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; - NCR*:*:4.2:* | MPRAS*:*:4.2:*) - OS_REL='.3' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit ;; - i*86:VOS:*:*) - # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos - exit ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit ;; - BePC:Haiku:*:*) # Haiku running on Intel PC compatible. - echo i586-pc-haiku - exit ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit ;; - SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit ;; - SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} - exit ;; - SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} - exit ;; - SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} - exit ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - case $UNAME_PROCESSOR in - i386) - eval $set_cc_for_build - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - UNAME_PROCESSOR="x86_64" - fi - fi ;; - unknown) UNAME_PROCESSOR=powerpc ;; - esac - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then - UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit ;; - NEO-?:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} - exit ;; - NSE-?:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} - exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. - if test "$cputype" = "386"; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex - exit ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit ;; - *:ITS:*:*) - echo pdp10-unknown-its - exit ;; - SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit ;; - *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; - *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; - esac ;; - *:XENIX:*:SysV) - echo i386-pc-xenix - exit ;; - i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' - exit ;; - i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos - exit ;; - i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros - exit ;; -esac - -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -eval $set_cc_for_build -cat >$dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix\n"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - c34*) - echo c34-convex-bsd - exit ;; - c38*) - echo c38-convex-bsd - exit ;; - c4*) - echo c4-convex-bsd - exit ;; - esac -fi - -cat >&2 < in order to provide the needed -information to handle your system. - -config.guess timestamp = $timestamp - -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/libs/apr/build/config.sub b/libs/apr/build/config.sub deleted file mode 100644 index 30fdca81..00000000 --- a/libs/apr/build/config.sub +++ /dev/null @@ -1,1760 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -# 2011 Free Software Foundation, Inc. - -timestamp='2011-03-23' - -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# This file 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., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - - -# Please send patches to . Submit a context -# diff and a properly formatted GNU ChangeLog entry. -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.sub ($timestamp) - -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free -Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit ;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | \ - kopensolaris*-gnu* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze) - os= - basic_machine=$1 - ;; - -bluegene*) - os=-cnk - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco6) - os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ - | bfin \ - | c4x | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | fido | fr30 | frv \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | mcore | mep | metag \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nios | nios2 \ - | ns16k | ns32k \ - | open8 \ - | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pyramid \ - | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e \ - | we32k \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown - ;; - c54x) - basic_machine=tic54x-unknown - ;; - c55x) - basic_machine=tic55x-unknown - ;; - c6x) - basic_machine=tic6x-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12 | picochip) - # Motorola 68HC11/12. - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - ms1) - basic_machine=mt-unknown - ;; - - strongarm | thumb | xscale) - basic_machine=arm-unknown - ;; - - xscaleeb) - basic_machine=armeb-unknown - ;; - - xscaleel) - basic_machine=armel-unknown - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pyramid-* \ - | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile-* | tilegx-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-* | z80-*) - ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; - blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - bluegene*) - basic_machine=powerpc-ibm - os=-cnk - ;; - c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; - m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - microblaze) - basic_machine=microblaze-xilinx - ;; - mingw32) - basic_machine=i386-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - parisc) - basic_machine=hppa-unknown - os=-linux - ;; - parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pc98) - basic_machine=i386-pc - ;; - pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc | ppcbe) basic_machine=powerpc-unknown - ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown - ;; - sde) - basic_machine=mipsisa32-sde - os=-elf - ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sh5el) - basic_machine=sh5le-unknown - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - strongarm-* | thumb-*) - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - # This must be matched before tile*. - tilegx*) - basic_machine=tilegx-unknown - os=-linux-gnu - ;; - tile*) - basic_machine=tile-unknown - os=-linux-gnu - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - xbox) - basic_machine=i686-pc - os=-mingw32 - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - xscale-* | xscalee[bl]-*) - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - romp) - basic_machine=romp-ibm - ;; - mmix) - basic_machine=mmix-knuth - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown - ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux - ;; - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -openbsd* | -solidbsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-android* \ - | -linux-newlib* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto-qnx*) - ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -os400*) - os=-os400 - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -atheos*) - os=-atheos - ;; - -syllable*) - os=-syllable - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -nova*) - os=-rtmk-nova - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -tpf*) - os=-tpf - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -aros*) - os=-aros - ;; - -kaos*) - os=-kaos - ;; - -zvmoe) - os=-zvmoe - ;; - -dicos*) - os=-dicos - ;; - -nacl*) - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - score-*) - os=-elf - ;; - spu-*) - os=-elf - ;; - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - c4x-* | tic4x-*) - os=-coff - ;; - tic54x-*) - os=-coff - ;; - tic55x-*) - os=-coff - ;; - tic6x-*) - os=-coff - ;; - # This must come before the *-dec entry. - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 - ;; - m68*-cisco) - os=-aout - ;; - mep-*) - os=-elf - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - or32-*) - os=-coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-be) - os=-beos - ;; - *-haiku) - os=-haiku - ;; - *-ibm) - os=-aix - ;; - *-knuth) - os=-mmixware - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -cnk*|-aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -os400*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -tpf*) - vendor=ibm - ;; - -vxsim* | -vxworks* | -windiss*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/libs/apr/build/cvtdsp.pl b/libs/apr/build/cvtdsp.pl deleted file mode 100644 index becb75bd..00000000 --- a/libs/apr/build/cvtdsp.pl +++ /dev/null @@ -1,605 +0,0 @@ -use IO::File; -use File::Find; - -if ($ARGV[0] eq '-6') { - find(\&tovc6, '.'); -} -elsif ($ARGV[0] eq '-5') { - find(\&tovc5, '.'); -} -elsif ($ARGV[0] eq '-2005') { - find(\&tovc2005, '.'); -} -elsif ($ARGV[0] eq '-w3') { - find(\&tow3, '.'); -} -elsif ($ARGV[0] eq '-w4') { - find(\&tow4, '.'); -} -elsif ($ARGV[0] eq '-ia64') { - find(\&tovc64, '.'); -} -elsif ($ARGV[0] eq '-d') { - find(\&todebugpools, '.'); -} -elsif ($ARGV[0] eq '-b') { - find(\&tobrowse, '.'); -} -elsif ($ARGV[0] eq '-mt') { - find(\&addmt, '.'); -} -elsif ($ARGV[0] eq '-m') { - ## 0 - conapp, 1 - dll lib, 2 - static lib - $dsptype = 2; - $name = "apr"; - onemake(); -} -else { - print "Specify -5 or -6 for Visual Studio 5 or 6 (98) .dsp format\n"; - print "Specify -w3 or -w4 for .dsp build with warning level 3 or 4 (strict)\n\n"; - print "Specify -ia64 for build targeted at Itanium (req's psdk tools)\n\n"; - print "Specify -p for extreme pool debugging\n\n"; - print "Specify -mt to add .manifest embedding\n\n"; - die "Missing argument"; -} - -sub addmt { - my $outpath, $outtype; - - if (m|\.dsp$|) { - $oname = $_; - $tname = '.#' . $_; - $verchg = 0; - $srcfl = new IO::File $oname, "r" || die; - $dstfl = new IO::File $tname, "w" || die; - while ($src = <$srcfl>) { - if ($src =~ m|^# TARGTYPE .+ Application|) { - $outtype = ".exe" - } - if ($src =~ m|^# TARGTYPE .+ Dynamic-Link|) { - $outtype = ".dll" - } - if ($src =~ m|^# PROP Output_Dir "(.+)"|) { - $outdir = $1; - $outpath = $oname; - $outpath =~ s|\.dsp||; - $outpath = ".\\" . $outdir . "\\" . $outpath . $outtype; - } - if ($src =~ m|^# ADD (BASE )?LINK32 .+ /out:"([^"]+)"|) { - $outpath = $2; - $outpath =~ s|/|\\|; - $outpath = ".\\" . $outpath if (!($outpath =~ m|^\.|)); - $src =~ s|/out:"([^"]+)"|/out:"$outpath"|; - } - if (defined($outpath) && ($src =~ m|^# Begin Special Build Tool|)) { - undef $outpath; - } - if (defined($outpath) && defined($outtype) && ($src =~ m|^\s*$|)) { - print $dstfl '# Begin Special Build Tool' . "\n"; - print $dstfl 'TargetPath=' . $outpath . "\n"; - print $dstfl 'SOURCE="$(InputPath)"' . "\n"; - print $dstfl 'PostBuild_Desc=Embed .manifest' . "\n"; - print $dstfl 'PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2' . "\n"; - print $dstfl '# End Special Build Tool' . "\n"; - $verchg = -1; - undef $outpath; - } - print $dstfl $src; - } - undef $outtype if (defined($outtype)); - undef $outpath if (defined($outpath)); - undef $srcfl; - undef $dstfl; - if ($verchg) { - unlink $oname || die; - rename $tname, $oname || die; - print "Added manifest to " . $oname . " in " . $File::Find::dir . "\n"; - } - else { - unlink $tname; - } - } -} -sub tovc5 { - - if (m|\.dsp$|) { - $oname = $_; - $tname = '.#' . $_; - $verchg = 0; - $srcfl = new IO::File $oname, "r" || die; - $dstfl = new IO::File $tname, "w" || die; - while ($src = <$srcfl>) { - if ($src =~ s|Format Version 6\.00|Format Version 5\.00|) { - $verchg = -1; - } - if ($src =~ s|^(# ADD CPP .*)/ZI (.*)|$1/Zi $2|) { - $verchg = -1; - } - if ($src =~ s|^(# ADD BASE CPP .*)/ZI (.*)|$1/Zi $2|) { - $verchg = -1; - } - if ($src =~ s|^(# ADD CPP .*)/EHsc (.*)|$1/GX $2|) { - $verchg = -1; - } - if ($src =~ s|^(# ADD BASE CPP .*)/EHsc (.*)|$1/GX $2|) { - $verchg = -1; - } - while ($src =~ s|^(# ADD RSC .*)/d "([^ ="]+)=([^"]+)"|$1/d $2="$3"|) { - $verchg = -1; - } - if ($src !~ m|^# PROP AllowPerConfigDependencies|) { - print $dstfl $src; } - else { - $verchg = -1; - } - } - undef $srcfl; - undef $dstfl; - if ($verchg) { - unlink $oname || die; - rename $tname, $oname || die; - print "Converted VC6 project " . $oname . " to VC5 in " . $File::Find::dir . "\n"; - } - else { - unlink $tname; - } - } -} - -sub tovc6 { - - if (m|\.dsp$|) { - $oname = $_; - $tname = '.#' . $_; - $verchg = 0; - $srcfl = new IO::File $_, "r" || die; - $dstfl = new IO::File $tname, "w" || die; - while ($src = <$srcfl>) { - if ($src =~ s|Format Version 5\.00|Format Version 6\.00|) { - $verchg = -1; - } - if ($src =~ s|^(!MESSAGE .*)\\\n|$1|) { - $cont = <$srcfl>; - $src = $src . $cont; - $verchg = -1; - } - if ($src =~ s|^(# ADD CPP .*)/GX (.*)|$1/EHsc $2|) { - $verchg = -1; - } - if ($src =~ s|^(# ADD BASE CPP .*)/GX (.*)|$1/EHsc $2|) { - $verchg = -1; - } - while ($src =~ s|^(# ADD RSC .*)/d "([^ ="]+)=([^"]+)"|$1/d $2="$3"|) { - $verchg = -1; - } - print $dstfl $src; - if ($verchg && $src =~ m|^# Begin Project|) { - print $dstfl "# PROP AllowPerConfigDependencies 0\n"; - } - } - undef $srcfl; - undef $dstfl; - if ($verchg) { - unlink $oname || die; - rename $tname, $oname || die; - print "Converted VC5 project " . $oname . " to VC6 in " . $File::Find::dir . "\n"; - } - else { - unlink $tname; - } - } -} - -sub tovc2005 { - - if (m|\.dsp$| || m|\.mak$|) { - $oname = $_; - $tname = '.#' . $_; - $verchg = 0; - $srcfl = new IO::File $_, "r" || die; - $dstfl = new IO::File $tname, "w" || die; - while ($src = <$srcfl>) { - if ($src =~ s|(\bCPP.*) /GX(.*)|$1 /EHsc$2|) { - $verchg = -1; - } - if ($src =~ s|(\bLINK32.*) /machine:I386(.*)|$1$2|) { - $verchg = -1; - } - while ($src =~ s|^(# ADD RSC .*)/d ([^ ="]+)="([^"]+)"|$1/d "$2=$3"|) { - $verchg = -1; - } - print $dstfl $src; - } - undef $srcfl; - undef $dstfl; - if ($verchg) { - unlink $oname || die; - rename $tname, $oname || die; - print "Converted project " . $oname . " to 2005 in " . $File::Find::dir . "\n"; - } - else { - unlink $tname; - } - } -} - -sub tow3 { - - if (m|\.dsp$| || m|\.mak$|) { - $oname = $_; - $tname = '.#' . $_; - $verchg = 0; - $srcfl = new IO::File $_, "r" || die; - $dstfl = new IO::File $tname, "w" || die; - while ($src = <$srcfl>) { - while ($src =~ m|\\\n$|) { - $src = $src . <$srcfl> - } - if ($src =~ s|(\bCPP.*) /W4(.*)|$1 /W3$2|) { - $verchg = -1; - } - print $dstfl $src; - } - undef $srcfl; - undef $dstfl; - if ($verchg) { - unlink $oname || die; - rename $tname, $oname || die; - print "Converted project " . $oname . " to warn:3 in " . $File::Find::dir . "\n"; - } - else { - unlink $tname; - } - } -} - -sub tow4 { - - if (m|\.dsp$| || m|\.mak$|) { - $oname = $_; - $tname = '.#' . $_; - $verchg = 0; - $srcfl = new IO::File $_, "r" || die; - $dstfl = new IO::File $tname, "w" || die; - while ($src = <$srcfl>) { - while ($src =~ m|\\\n$|) { - $src = $src . <$srcfl> - } - if ($src =~ s|(\bCPP.*) /W3(.*)|$1 /W4$2|) { - $verchg = -1; - } - print $dstfl $src; - } - undef $srcfl; - undef $dstfl; - if ($verchg) { - unlink $oname || die; - rename $tname, $oname || die; - print "Converted project " . $oname . " to warn:4 " . $File::Find::dir . "\n"; - } - else { - unlink $tname; - } - } -} - -sub tovc64 { - - if (m|\.dsp$| || m|\.mak$|) { - $oname = $_; - $tname = '.#' . $_; - $verchg = 0; - $srcfl = new IO::File $_, "r" || die; - $dstfl = new IO::File $tname, "w" || die; - while ($src = <$srcfl>) { - while ($src =~ m|\\\n$|) { - $src = $src . <$srcfl> - } - if ($src =~ s|Win32 \(x86\) (Release)|Win32 (IA64) $1|s) { - $verchg = -1; - } - if ($src =~ s|Win32 \(x86\) (Debug)|Win32 (IA64) $1|s) { - $verchg = -1; - } - if ($src =~ s| - Win32 (Release)| - Win32 (IA64) $1|s) { - $verchg = -1; - } - if ($src =~ s| - Win32 (Debug)| - Win32 (IA64) $1|s) { - $verchg = -1; - } - # Cross compilation exceptions - if (!(m|gen[^/]*$| || m|dftables[^/]*$|)) { - if ($src =~ s|(\bCPP.* /W3)(.*) /FD(.*)|$1 /As64 /Wp64$2$3|s) { - $verchg = -1; - } - if ($src =~ s|(\bLINK.*/machine):I386(.*)|$1:IA64$2|s) { - $verchg = -1; - } - } - else { - if ($src =~ s|(\bCPP.* /W3)(.*) /FD(.*)|$1 /As32 /Wp64$2$3|s) { - $verchg = -1; - } - } - print $dstfl $src; - } - undef $srcfl; - undef $dstfl; - if ($verchg) { - unlink $oname || die; - rename $tname, $oname || die; - print "Converted build file " . $oname . " to Win64 in " . $File::Find::dir . "\n"; - } - else { - unlink $tname; - } - } -} - -sub todebugpools { - - if (m|\.dsp$|) { - $oname = $_; - $tname = '.#' . $_; - $verchg = 0; - $srcfl = new IO::File $oname, "r" || die; - $dstfl = new IO::File $tname, "w" || die; - while ($src = <$srcfl>) { - if ($src =~ s|^(# ADD CPP .* /D "_DEBUG" )|$1/D "APR_POOL_DEBUG" |) { - $verchg = -1; - if ($oname =~ /apr\.dsp$/) { - $src =~ s|^(# ADD CPP .* /D "_DEBUG" )|$1/D "POOL_DEBUG" |; - } - } - print $dstfl $src; - } - undef $srcfl; - undef $dstfl; - if ($verchg) { - unlink $oname || die; - rename $tname, $oname || die; - print "Converted project " . $oname . " to debug pools in " . $File::Find::dir . "\n"; - } - else { - unlink $tname; - } - } -} - -sub tobrowsesources { - - if (m|\.dsp$|) { - $oname = $_; - $tname = '.#' . $_; - $verchg = 0; - $srcfl = new IO::File $oname, "r" || die; - $dstfl = new IO::File $tname, "w" || die; - while ($src = <$srcfl>) { - if ($src =~ s|^(# ADD CPP .*)( /Fd)|$1 /Fr "/httpd-2.0/srclib/apr"$2|) { - $verchg = -1; - } - print $dstfl $src; - } - undef $srcfl; - undef $dstfl; - if ($verchg) { - unlink $oname || die; - rename $tname, $oname || die; - print "Converted project " . $oname . " to browse sources in " . $File::Find::dir . "\n"; - } - else { - unlink $tname; - } - } -} - -sub frommakefiles { - - if (m|\.mak\.in$|) { - $oname = $_; - $dname = $_; - $_ =~ s/\.mak\.in/.dsp/; - $verchg = 0; - $srcfl = new IO::File $oname, "r" || die; - $dstfl = new IO::File $tname, "w" || die; - while ($src = <$srcfl>) { - if ($src =~ s|^(# ADD CPP .*)( /Fd)|$1 /Fr "/httpd-2.0/srclib/apr"$2|) { - $verchg = -1; - } - print $dstfl $src; - } - undef $srcfl; - undef $dstfl; - if ($verchg) { - unlink $oname || die; - rename $tname, $oname || die; - print "Converted project " . $oname . " to browse sources in " . $File::Find::dir . "\n"; - } - else { - unlink $tname; - } - } -} - - -sub onemake { - - if ($dsptype == 0) { - $cdefs = qq{/D "WIN32" /D "_CONSOLE"}; - $lmodel = qq{/subsystem:console}; - $targname = "Win32 (x86) Console Application"; - $targid = "0x0103"; - $debpath = "Debug"; $relpath = "Release"; - } elsif ($dsptype == 1) { - $cdefs = qq{/D "WIN32" /D "_WINDOWS"}; - $lmodel = qq{/subsystem:windows /dll}; - $targname = "Win32 (x86) Dynamic-Link Library"; - $targid = "0x0102"; - $debpath = "Debug"; $relpath = "Release"; - } elsif($dsptype == 2) { - $cdefs = qq{/D "WIN32" /D "_CONSOLE"}; - $lmodel = qq{/subsystem:console}; - $targname = "Win32 (x86) Static Library"; - $targid = "0x0104"; - $debpath = "LibD"; $relpath = "LibR"; - } - $file = dspheader(); - - - $second = ""; - - $model = "Release"; - $usedebuglib = "0"; - $debugdef = "NDEBUG"; - $cflags = "/MD /W3 /O2"; - $cincl = qq{/I "./include" /I "./os/win32" /I "./srclib/apr/include" /I "./srclib/apr-util/include"}; - $lflags = qq{/map}; - $file .= dsponemodel(); - - $second = "ELSE"; - $model = "Debug"; - $usedebuglib = "1"; - $debugdef = "_DEBUG"; - $cflags = "/MDd /W3 /GX /Zi /Od"; - $cincl = qq{/I "./include" /I "./os/win32" /I "./srclib/apr/include" /I "./srclib/apr-util/include"}; - $lflags = qq{/incremental:no /debug}; - $file .= dsponemodel(); - - $file .= qq{ -!ENDIF - -# Begin Target - -# Name "$name - Win32 Release" -# Name "$name - Win32 Debug" -}; - - $toroot = "."; - -#HERE IS OUR FOREACH! - $file .= qq{# Begin Source File - -SOURCE=./server/main.c -# End Source File -}; - - if ($dsptype == 0) { - #HERE IS OUR ICON! - $icon="$toroot/build/win32/apache.ico"; - $file .= qq{# Begin Source File - -SOURCE=$icon -# End Source File -}; - $icon = "icon=" . $icon . " "; - } - if ($dsptype == 0 || $dsptype == 1) { - $file .= qq{ -# Begin Source File - -SOURCE=./$name.rc -# End Source File -# Begin Source File - -SOURCE=$toroot/include/ap_release.h -# PROP Ignore_Default_Tool 1 -# Begin Custom Build - Creating Version Resource -InputPath=$toroot/include/ap_release.h $toroot/build/win32/win32ver.awk - -"./$name.rc" : \$(SOURCE) "\$(INTDIR)" "\$(OUTDIR)" - awk -f $toroot/build/win32/win32ver.awk $name "Apache HTTP Server" $toroot/include/ap_release.h $icon> ./Apache.rc - -# End Custom Build -# End Source File -}; - } - $file .= qq{ -# End Target -# End Project -}; - print $file; -} - -sub dspheader { - if ($dsptype == 1) { - $midl = "MTL=midl.exe\n"; - } else { - $midl = "" - } -qq{# Microsoft Developer Studio Project File - Name="$name" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "$targname" $targid - -CFG=$name - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "$name.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "$name.mak" CFG="$name - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "$name - Win32 Release" (based on "$targname") -!MESSAGE "$name - Win32 Debug" (based on "$targname") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -${midl}RSC=rc.exe -}; -} -sub dsponemodel { - if ($model eq "Release") { - $targpath = $relpath; - } else { - $targpath = $debpath; - } - if ($dsptype == 1) { - $midl = -qq{# ADD BASE MTL /nologo /D "$debugdef" /win32 -# ADD MTL /nologo /D "$debugdef" /mktyplib203 /win32 -}; } - if ($dsptype == 2) { - $linkop = qq{LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo -}; - } else { - $linkop = qq{LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib mswsock.lib /nologo $lmodel $lflags /machine:I386 -# ADD LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib mswsock.lib /nologo $lmodel $lflags /machine:I386 -}; - } - -qq{ -!${second}IF "\$(CFG)" == "$name - Win32 $model" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries $usedebuglib -# PROP BASE Output_Dir "$targpath" -# PROP BASE Intermediate_Dir "$targpath" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries $usedebuglib -# PROP Output_Dir "$targpath" -# PROP Intermediate_Dir "$targpath" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo $cflags $cincl /D "$debugdef" $cdefs /FD /c -# ADD CPP /nologo $cflags $cincl /D "$debugdef" $cdefs /Fd"$targpath/$name" /FD /c -${midl}# ADD BASE RSC /l 0x409 /d "$debugdef" -# ADD RSC /l 0x409 /d "$debugdef" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -$linkop}; -} \ No newline at end of file diff --git a/libs/apr/build/find_apr.m4 b/libs/apr/build/find_apr.m4 deleted file mode 100644 index 925e523f..00000000 --- a/libs/apr/build/find_apr.m4 +++ /dev/null @@ -1,202 +0,0 @@ -dnl -------------------------------------------------------- -*- autoconf -*- -dnl Licensed to the Apache Software Foundation (ASF) under one or more -dnl contributor license agreements. See the NOTICE file distributed with -dnl this work for additional information regarding copyright ownership. -dnl The ASF licenses this file to You under the Apache License, Version 2.0 -dnl (the "License"); you may not use this file except in compliance with -dnl the License. You may obtain a copy of the License at -dnl -dnl http://www.apache.org/licenses/LICENSE-2.0 -dnl -dnl Unless required by applicable law or agreed to in writing, software -dnl distributed under the License is distributed on an "AS IS" BASIS, -dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -dnl See the License for the specific language governing permissions and -dnl limitations under the License. - -dnl -dnl find_apr.m4 : locate the APR include files and libraries -dnl -dnl This macro file can be used by applications to find and use the APR -dnl library. It provides a standardized mechanism for using APR. It supports -dnl embedding APR into the application source, or locating an installed -dnl copy of APR. -dnl -dnl APR_FIND_APR(srcdir, builddir, implicit-install-check, acceptable-majors, -dnl detailed-check) -dnl -dnl where srcdir is the location of the bundled APR source directory, or -dnl empty if source is not bundled. -dnl -dnl where builddir is the location where the bundled APR will will be built, -dnl or empty if the build will occur in the srcdir. -dnl -dnl where implicit-install-check set to 1 indicates if there is no -dnl --with-apr option specified, we will look for installed copies. -dnl -dnl where acceptable-majors is a space separated list of acceptable major -dnl version numbers. Often only a single major version will be acceptable. -dnl If multiple versions are specified, and --with-apr=PREFIX or the -dnl implicit installed search are used, then the first (leftmost) version -dnl in the list that is found will be used. Currently defaults to [0 1]. -dnl -dnl where detailed-check is an M4 macro which sets the apr_acceptable to -dnl either "yes" or "no". The macro will be invoked for each installed -dnl copy of APR found, with the apr_config variable set appropriately. -dnl Only installed copies of APR which are considered acceptable by -dnl this macro will be considered found. If no installed copies are -dnl considered acceptable by this macro, apr_found will be set to either -dnl either "no" or "reconfig". -dnl -dnl Sets the following variables on exit: -dnl -dnl apr_found : "yes", "no", "reconfig" -dnl -dnl apr_config : If the apr-config tool exists, this refers to it. If -dnl apr_found is "reconfig", then the bundled directory -dnl should be reconfigured *before* using apr_config. -dnl -dnl Note: this macro file assumes that apr-config has been installed; it -dnl is normally considered a required part of an APR installation. -dnl -dnl If a bundled source directory is available and needs to be (re)configured, -dnl then apr_found is set to "reconfig". The caller should reconfigure the -dnl (passed-in) source directory, placing the result in the build directory, -dnl as appropriate. -dnl -dnl If apr_found is "yes" or "reconfig", then the caller should use the -dnl value of apr_config to fetch any necessary build/link information. -dnl - -AC_DEFUN([APR_FIND_APR], [ - apr_found="no" - - if test "$target_os" = "os2-emx"; then - # Scripts don't pass test -x on OS/2 - TEST_X="test -f" - else - TEST_X="test -x" - fi - - ifelse([$4], [], [ - ifdef(AC_WARNING,AC_WARNING([$0: missing argument 4 (acceptable-majors): Defaulting to APR 0.x then APR 1.x])) - acceptable_majors="0 1"], - [acceptable_majors="$4"]) - - apr_temp_acceptable_apr_config="" - for apr_temp_major in $acceptable_majors - do - case $apr_temp_major in - 0) - apr_temp_acceptable_apr_config="$apr_temp_acceptable_apr_config apr-config" - ;; - *) - apr_temp_acceptable_apr_config="$apr_temp_acceptable_apr_config apr-$apr_temp_major-config" - ;; - esac - done - - AC_MSG_CHECKING(for APR) - AC_ARG_WITH(apr, - [ --with-apr=PATH prefix for installed APR or the full path to - apr-config], - [ - if test "$withval" = "no" || test "$withval" = "yes"; then - AC_MSG_ERROR([--with-apr requires a directory or file to be provided]) - fi - - for apr_temp_apr_config_file in $apr_temp_acceptable_apr_config - do - for lookdir in "$withval/bin" "$withval" - do - if $TEST_X "$lookdir/$apr_temp_apr_config_file"; then - apr_config="$lookdir/$apr_temp_apr_config_file" - ifelse([$5], [], [], [ - apr_acceptable="yes" - $5 - if test "$apr_acceptable" != "yes"; then - AC_MSG_WARN([Found APR in $apr_config, but we think it is considered unacceptable]) - continue - fi]) - apr_found="yes" - break 2 - fi - done - done - - if test "$apr_found" != "yes" && $TEST_X "$withval" && $withval --help > /dev/null 2>&1 ; then - apr_config="$withval" - ifelse([$5], [], [apr_found="yes"], [ - apr_acceptable="yes" - $5 - if test "$apr_acceptable" = "yes"; then - apr_found="yes" - fi]) - fi - - dnl if --with-apr is used, it is a fatal error for its argument - dnl to be invalid - if test "$apr_found" != "yes"; then - AC_MSG_ERROR([the --with-apr parameter is incorrect. It must specify an install prefix, a build directory, or an apr-config file.]) - fi - ],[ - dnl If we allow installed copies, check those before using bundled copy. - if test -n "$3" && test "$3" = "1"; then - for apr_temp_apr_config_file in $apr_temp_acceptable_apr_config - do - if $apr_temp_apr_config_file --help > /dev/null 2>&1 ; then - apr_config="$apr_temp_apr_config_file" - ifelse([$5], [], [], [ - apr_acceptable="yes" - $5 - if test "$apr_acceptable" != "yes"; then - AC_MSG_WARN([skipped APR at $apr_config, version not acceptable]) - continue - fi]) - apr_found="yes" - break - else - dnl look in some standard places - for lookdir in /usr /usr/local /usr/local/apr /opt/apr; do - if $TEST_X "$lookdir/bin/$apr_temp_apr_config_file"; then - apr_config="$lookdir/bin/$apr_temp_apr_config_file" - ifelse([$5], [], [], [ - apr_acceptable="yes" - $5 - if test "$apr_acceptable" != "yes"; then - AC_MSG_WARN([skipped APR at $apr_config, version not acceptable]) - continue - fi]) - apr_found="yes" - break 2 - fi - done - fi - done - fi - dnl if we have not found anything yet and have bundled source, use that - if test "$apr_found" = "no" && test -d "$1"; then - apr_temp_abs_srcdir="`cd \"$1\" && pwd`" - apr_found="reconfig" - apr_bundled_major="`sed -n '/#define.*APR_MAJOR_VERSION/s/^[^0-9]*\([0-9]*\).*$/\1/p' \"$1/include/apr_version.h\"`" - case $apr_bundled_major in - "") - AC_MSG_ERROR([failed to find major version of bundled APR]) - ;; - 0) - apr_temp_apr_config_file="apr-config" - ;; - *) - apr_temp_apr_config_file="apr-$apr_bundled_major-config" - ;; - esac - if test -n "$2"; then - apr_config="$2/$apr_temp_apr_config_file" - else - apr_config="$1/$apr_temp_apr_config_file" - fi - fi - ]) - - AC_MSG_RESULT($apr_found) -]) diff --git a/libs/apr/build/fixwin32mak.pl b/libs/apr/build/fixwin32mak.pl deleted file mode 100644 index 49853b34..00000000 --- a/libs/apr/build/fixwin32mak.pl +++ /dev/null @@ -1,167 +0,0 @@ -# -# fixwin32mak.pl ::: Apache/Win32 maintanace program -# -# This program, launched from the build/ directory, replaces all nasty absoulute paths -# in the win32 .mak files with the appropriate relative root. -# -# Run this program prior to committing or packaging any newly exported make files. - -use Cwd; -use IO::File; -use File::Find; - -$root = cwd; -# ignore our own direcory (allowing us to move into any parallel tree) -$root =~ s|^.:(.*)?$|cd "$1|; -$root =~ s|/|\\\\|g; -$altroot = $root; -$altroot =~ s| ".:| "|; -print "Stripping " . $root . " and " . $altroot . "\n"; -find(\&fixcwd, '.'); - -# Given this pattern that disregarded the RECURSE flag... -# -# !IF "$(RECURSE)" == "0" -# -# ALL : "$(OUTDIR)\mod_charset_lite.so" -# -# !ELSE -# -# ALL : "libhttpd - Win32 Release" "libaprutil - Win32 Release" "libapr - Win32 Release" "$(OUTDIR)\mod_charset_lite.so" -# -# !ENDIF -#... -# DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep -#... -# ALL : $(DS_POSTBUILD_DEP) -# -# $(DS_POSTBUILD_DEP) : "libhttpd - Win32 Release" "libaprutil - Win32 Release" "libapr - Win32 Release" "$(OUTDIR)\mod_charset_lite.so" -# -# we will axe the final ALL : clause, -# strip all but the final element from $(DS_POSTBUILD_DEP) : clause -# move the DS_POSTBUILD_DEP assignment above the IF (for true ALL : targets) -# and in pass 2, append the $(DS_POSTBUILD_DEP) to the valid ALL : targets - - -sub fixcwd { - if (m|.mak$|) { - $thisroot = $File::Find::dir; - $thisroot =~ s|^./(.*)$|$1|; - $thisroot =~ s|/|\\\\|g; - $thisroot = $root . "\\\\" . $thisroot; - $thisaltroot = $altroot . "\\\\" . $thisroot; - $oname = $_; - $tname = '.#' . $_; - $verchg = 0; - $postdep = 0; - $srcfl = new IO::File $_, "r" || die; - $dstfl = new IO::File $tname, "w" || die; - while ($src = <$srcfl>) { - if ($src =~ m|^DS_POSTBUILD_DEP=.+$|) { - $postdepval = $src; - } - if ($src =~ s|^ALL : \$\(DS_POSTBUILD_DEP\)||) { - $postdep = -1; - $verchg = -1; - $src = <$srcfl>; - $src = <$srcfl> if ($src =~ m|^$|); - } - if ($postdep) { - $src =~ s|^(\$\(DS_POSTBUILD_DEP\)) :.+(\"[^\"]+\")$|"$1" : $2|; - } - if ($src =~ m|^\s*($root[^\"]*)\".*$|) { - $orig = $thisroot; - } elsif ($src =~ m|^\s*($altroot[^\"]*)\".*$|) { - $orig = $thisaltroot; - } - if (defined($orig)) { - $repl = "cd \"."; - while (!($src =~ s|$orig|$repl|)) { - if (!($orig =~ s|^(.*)\\\\[^\\]+$|$1|)) { - break; - } - $repl .= "\\.."; - } - print "Replaced " . $orig . " with " . $repl . "\n"; - $verchg = -1; - undef $orig; - } - # With modern LINK.EXE linkers, there is a different LINK for - # each platform, and it's determined by the file path. Best - # that here, after we compiled the code to the default CPU, - # that we also link here to the default CPU. Omitting the - # /machine spec from the .dsp was not enough, MSVC put it back. - # - if ($src =~ s#^(LINK32_FLAGS=.*) /machine:(x|IX|I3)86 #$1 #) { - $verchg = -1; - } - print $dstfl $src; - } - undef $srcfl; - undef $dstfl; - if ($verchg) { - if ($postdep) { - $srcfl = new IO::File $tname, "r" || die; - $dstfl = new IO::File $oname, "w" || die; - while ($src = <$srcfl>) { - if ($src =~ m|^INTDIR=|) { - print $dstfl $src; - $src = $postdepval; - } - $src =~ s|^(ALL : .+)$|$1 "\$\(DS_POSTBUILD_DEP\)"|; - print $dstfl $src; - } - undef $srcfl; - undef $dstfl; - unlink $tname || die; - print "Corrected post-dependency within " . $oname . " in " . $File::Find::dir . "\n"; - } - else { - unlink $oname || die; - rename $tname, $oname || die; - print "Corrected absolute paths within " . $oname . " in " . $File::Find::dir . "\n"; - } - } - else { - unlink $tname; - } - $dname = $oname; - $dname =~ s/.mak$/.dsp/; - @dstat = stat($dname); - @ostat = stat($oname); - if ($ostat[9] && $dstat[9] && ($ostat[9] != $dstat[9])) { - @onames = ($oname); - utime $dstat[9], $dstat[9], @onames; - print "Touched datestamp for " . $oname . " in " . $File::Find::dir . "\n"; - } - $oname =~ s/.mak$/.dep/; - $verchg = 0; - $srcfl = new IO::File $oname, "r" || die; - $dstfl = new IO::File $tname, "w" || die; - while ($src = <$srcfl>) { - if (($src =~ m/^\t"(\.\.\\)+(apr|apr-util|apr-iconv)\\.*"\\/) || - ($src =~ m/^\t{\$\(INCLUDE\)}".*"\\/)) { - $verchg = -1; - } - else { - print $dstfl $src; - } - } - undef $srcfl; - undef $dstfl; - if ($verchg) { - unlink $oname || die; - rename $tname, $oname || die; - print "Stripped external dependencies from " . $oname . " in " . $File::Find::dir . "\n"; - } - else { - unlink $tname || die; - } - @ostat = stat($oname); - if ($ostat[9] && $dstat[9] && ($ostat[9] != $dstat[9])) { - @onames = ($oname); - utime $dstat[9], $dstat[9], @onames; - print "Touched datestamp for " . $oname . " in " . $File::Find::dir . "\n"; - } - } -} diff --git a/libs/apr/build/gen-build.py b/libs/apr/build/gen-build.py deleted file mode 100644 index aa94c33f..00000000 --- a/libs/apr/build/gen-build.py +++ /dev/null @@ -1,230 +0,0 @@ -#!/usr/bin/env python -# -# USAGE: gen-build.py TYPE -# -# where TYPE is one of: make, dsp, vcproj -# -# It reads build.conf from the current directory, and produces its output -# into the current directory. -# - - -import os -import ConfigParser -import getopt -import string -import glob -import re - -#import ezt - -# -# legal platforms: aix, beos, netware, os2, os390, unix, win32 -# 'make' users: aix, beos, os2, os390, unix, win32 (mingw) -# -PLATFORMS = [ 'aix', 'beos', 'netware', 'os2', 'os390', 'unix', 'win32' ] -MAKE_PLATFORMS = [ - ('unix', None), - ('aix', 'unix'), - ('beos', 'unix'), - ('os2', 'unix'), - ('os390', 'unix'), - ('win32', 'unix'), - ] -# note: MAKE_PLATFORMS is an ordered set. we want to generate unix symbols -# first, so that the later platforms can reference them. - - -def main(): - parser = ConfigParser.ConfigParser() - parser.read('build.conf') - - if parser.has_option('options', 'dsp'): - dsp_file = parser.get('options', 'dsp') - else: - dsp_file = None - - headers = get_files(parser.get('options', 'headers')) - - # compute the relevant headers, along with the implied includes - legal_deps = { } - for fname in headers: - legal_deps[os.path.basename(fname)] = fname - - h_deps = { } - for fname in headers: - h_deps[os.path.basename(fname)] = extract_deps(fname, legal_deps) - resolve_deps(h_deps) - - f = open('build-outputs.mk', 'w') - f.write('# DO NOT EDIT. AUTOMATICALLY GENERATED.\n\n') - - # write out the platform-independent files - files = get_files(parser.get('options', 'paths')) - objects, dirs = write_objects(f, legal_deps, h_deps, files) - f.write('\nOBJECTS_all = %s\n\n' % string.join(objects)) - - # for each platform and each subdirectory holding platform-specific files, - # write out their compilation rules, and an OBJECT__ symbol. - for platform, parent in MAKE_PLATFORMS: - - # record the object symbols to build for each platform - group = [ '$(OBJECTS_all)' ] - - # If we're doing win32, we're going to look in the libapr.dsp file - # for those files that we have to manually add to our list. - inherit_parent = { } - if platform == 'win32' and dsp_file: - for line in open(dsp_file).readlines(): - if line[:7] != 'SOURCE=': - continue - if line[7:].find('unix') != -1: - # skip the leading .\ and split it out - inherit_files = line[9:].strip().split('\\') - # change the .c to .lo - assert inherit_files[-1][-2:] == '.c' - inherit_files[-1] = inherit_files[-1][:-2] + '.lo' - # replace the \\'s with /'s - inherit_line = '/'.join(inherit_files) - if not inherit_parent.has_key(inherit_files[0]): - inherit_parent[inherit_files[0]] = [] - inherit_parent[inherit_files[0]].append(inherit_line) - - for subdir in string.split(parser.get('options', 'platform_dirs')): - path = '%s/%s' % (subdir, platform) - if not os.path.exists(path): - # this subdir doesn't have a subdir for this platform, so we'll - # use the parent-platform's set of symbols - if parent: - group.append('$(OBJECTS_%s_%s)' % (subdir, parent)) - continue - - # remember that this directory has files/objects - dirs[path] = None - - # write out the compilation lines for this subdir - files = get_files(path + '/*.c') - objects, _unused = write_objects(f, legal_deps, h_deps, files) - - if inherit_parent.has_key(subdir): - objects = objects + inherit_parent[subdir] - - symname = 'OBJECTS_%s_%s' % (subdir, platform) - - objects.sort() - - # and write the symbol for the whole group - f.write('\n%s = %s\n\n' % (symname, string.join(objects))) - - # and include that symbol in the group - group.append('$(%s)' % symname) - - group.sort() - - # write out a symbol which contains the necessary files - f.write('OBJECTS_%s = %s\n\n' % (platform, string.join(group))) - - f.write('HEADERS = $(top_srcdir)/%s\n\n' % string.join(headers, ' $(top_srcdir)/')) - f.write('SOURCE_DIRS = %s $(EXTRA_SOURCE_DIRS)\n\n' % string.join(dirs.keys())) - - if parser.has_option('options', 'modules'): - modules = parser.get('options', 'modules') - - for mod in string.split(modules): - files = get_files(parser.get(mod, 'paths')) - objects, _unused = write_objects(f, legal_deps, h_deps, files) - flat_objects = string.join(objects) - f.write('OBJECTS_%s = %s\n' % (mod, flat_objects)) - - if parser.has_option(mod, 'target'): - target = parser.get(mod, 'target') - f.write('MODULE_%s = %s\n' % (mod, target)) - f.write('%s: %s\n' % (target, flat_objects)) - f.write('\t$(LINK_MODULE) -o $@ $(OBJECTS_%s) $(LDADD_%s)\n' % (mod, mod)) - - f.write('\n') - - # Build a list of all necessary directories in build tree - alldirs = { } - for dir in dirs.keys(): - d = dir - while d: - alldirs[d] = None - d = os.path.dirname(d) - - # Sort so 'foo' is before 'foo/bar' - keys = alldirs.keys() - keys.sort() - f.write('BUILD_DIRS = %s\n\n' % string.join(keys)) - - f.write('.make.dirs: $(srcdir)/build-outputs.mk\n' \ - '\t@for d in $(BUILD_DIRS); do test -d $$d || mkdir $$d; done\n' \ - '\t@echo timestamp > $@\n') - - -def write_objects(f, legal_deps, h_deps, files): - dirs = { } - objects = [ ] - - for file in files: - if file[-10:] == '/apr_app.c': - continue - assert file[-2:] == '.c' - obj = file[:-2] + '.lo' - objects.append(obj) - - dirs[os.path.dirname(file)] = None - - # what headers does this file include, along with the implied headers - deps = extract_deps(file, legal_deps) - for hdr in deps.keys(): - deps.update(h_deps.get(hdr, {})) - - vals = deps.values() - vals.sort() - f.write('%s: %s .make.dirs %s\n' % (obj, file, string.join(vals))) - - objects.sort() - - return objects, dirs - - -def extract_deps(fname, legal_deps): - "Extract the headers this file includes." - deps = { } - for line in open(fname).readlines(): - if line[:8] != '#include': - continue - inc = _re_include.match(line).group(1) - if inc in legal_deps.keys(): - deps[inc] = legal_deps[inc] - return deps -_re_include = re.compile('#include *["<](.*)[">]') - - -def resolve_deps(header_deps): - "Alter the provided dictionary to flatten includes-of-includes." - altered = 1 - while altered: - altered = 0 - for hdr, deps in header_deps.items(): - # print hdr, deps - start = len(deps) - for dep in deps.keys(): - deps.update(header_deps.get(dep, {})) - if len(deps) != start: - altered = 1 - -def clean_path(path): - return path.replace("\\", "/") - -def get_files(patterns): - files = [ ] - for pat in string.split(patterns): - files.extend(map(clean_path, glob.glob(pat))) - files.sort() - return files - - -if __name__ == '__main__': - main() diff --git a/libs/apr/build/get-version.sh b/libs/apr/build/get-version.sh deleted file mode 100644 index fd685b22..00000000 --- a/libs/apr/build/get-version.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -# -# extract version numbers from a header file -# -# USAGE: get-version.sh CMD VERSION_HEADER PREFIX -# where CMD is one of: all, major, libtool -# where PREFIX is the prefix to {MAJOR|MINOR|PATCH}_VERSION defines -# -# get-version.sh all returns a dotted version number -# get-version.sh major returns just the major version number -# get-version.sh libtool returns a version "libtool -version-info" format -# - -if test $# != 3; then - echo "USAGE: $0 CMD VERSION_HEADER PREFIX" - echo " where CMD is one of: all, major, libtool" - exit 1 -fi - -major_sed="/#define.*$3_MAJOR_VERSION/s/^[^0-9]*\([0-9]*\).*$/\1/p" -minor_sed="/#define.*$3_MINOR_VERSION/s/^[^0-9]*\([0-9]*\).*$/\1/p" -patch_sed="/#define.*$3_PATCH_VERSION/s/^[^0-9]*\([0-9]*\).*$/\1/p" -major="`sed -n $major_sed $2`" -minor="`sed -n $minor_sed $2`" -patch="`sed -n $patch_sed $2`" - -if test "$1" = "all"; then - echo ${major}.${minor}.${patch} -elif test "$1" = "major"; then - echo ${major} -elif test "$1" = "libtool"; then - # Yes, ${minor}:${patch}:${minor} is correct due to libtool idiocy. - echo ${minor}:${patch}:${minor} -else - echo "ERROR: unknown version CMD ($1)" - exit 1 -fi diff --git a/libs/apr/build/install.sh b/libs/apr/build/install.sh deleted file mode 100644 index 9a8821fa..00000000 --- a/libs/apr/build/install.sh +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/sh -## -## install.sh -- install a program, script or datafile -## -## Based on `install-sh' from the X Consortium's X11R5 distribution -## as of 89/12/18 which is freely available. -## Cleaned up for Apache's Autoconf-style Interface (APACI) -## by Ralf S. Engelschall -## -# -# This script falls under the Apache License. -# See http://www.apache.org/docs/LICENSE - - -# -# put in absolute paths if you don't have them in your path; -# or use env. vars. -# -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" - -# -# parse argument line -# -instcmd="$mvprog" -chmodcmd="" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -ext="" -src="" -dst="" -while [ "x$1" != "x" ]; do - case $1 in - -c) instcmd="$cpprog" - shift; continue - ;; - -m) chmodcmd="$chmodprog $2" - shift; shift; continue - ;; - -o) chowncmd="$chownprog $2" - shift; shift; continue - ;; - -g) chgrpcmd="$chgrpprog $2" - shift; shift; continue - ;; - -s) stripcmd="$stripprog" - shift; continue - ;; - -S) stripcmd="$stripprog $2" - shift; shift; continue - ;; - -e) ext="$2" - shift; shift; continue - ;; - *) if [ "x$src" = "x" ]; then - src=$1 - else - dst=$1 - fi - shift; continue - ;; - esac -done -if [ "x$src" = "x" ]; then - echo "install.sh: no input file specified" - exit 1 -fi -if [ "x$dst" = "x" ]; then - echo "install.sh: no destination specified" - exit 1 -fi - -# -# If destination is a directory, append the input filename; if -# your system does not like double slashes in filenames, you may -# need to add some logic -# -if [ -d $dst ]; then - dst="$dst/`basename $src`" -fi - -# Add a possible extension (such as ".exe") to src and dst -src="$src$ext" -dst="$dst$ext" - -# Make a temp file name in the proper directory. -dstdir=`dirname $dst` -dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name -$instcmd $src $dsttmp - -# And set any options; do chmod last to preserve setuid bits -if [ "x$chowncmd" != "x" ]; then $chowncmd $dsttmp; fi -if [ "x$chgrpcmd" != "x" ]; then $chgrpcmd $dsttmp; fi -if [ "x$stripcmd" != "x" ]; then $stripcmd $dsttmp; fi -if [ "x$chmodcmd" != "x" ]; then $chmodcmd $dsttmp; fi - -# Now rename the file to the real destination. -$rmcmd $dst -$mvcmd $dsttmp $dst - -exit 0 - diff --git a/libs/apr/build/jlibtool.c b/libs/apr/build/jlibtool.c deleted file mode 100644 index 2313c1fd..00000000 --- a/libs/apr/build/jlibtool.c +++ /dev/null @@ -1,2056 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#if !defined(__MINGW32__) -#include -#endif -#include -#include -#include -#include - -#ifdef __EMX__ -# define SHELL_CMD "sh" -# define GEN_EXPORTS "emxexp" -# define DEF2IMPLIB_CMD "emximp" -# define SHARE_SW "-Zdll -Zmtd" -# define USE_OMF 1 -# define TRUNCATE_DLL_NAME -# define DYNAMIC_LIB_EXT "dll" -# define EXE_EXT ".exe" - -# if USE_OMF - /* OMF is the native format under OS/2 */ -# define STATIC_LIB_EXT "lib" -# define OBJECT_EXT "obj" -# define LIBRARIAN "emxomfar" -# define LIBRARIAN_OPTS "cr" -# else - /* but the alternative, a.out, can fork() which is sometimes necessary */ -# define STATIC_LIB_EXT "a" -# define OBJECT_EXT "o" -# define LIBRARIAN "ar" -# define LIBRARIAN_OPTS "cr" -# endif -#endif - -#if defined(__APPLE__) -# define SHELL_CMD "/bin/sh" -# define DYNAMIC_LIB_EXT "dylib" -# define MODULE_LIB_EXT "bundle" -# define STATIC_LIB_EXT "a" -# define OBJECT_EXT "o" -# define LIBRARIAN "ar" -# define LIBRARIAN_OPTS "cr" -/* man libtool(1) documents ranlib option of -c. */ -# define RANLIB "ranlib" -# define PIC_FLAG "-fPIC -fno-common" -# define SHARED_OPTS "-dynamiclib" -# define MODULE_OPTS "-bundle -dynamic" -# define DYNAMIC_LINK_OPTS "-flat_namespace" -# define DYNAMIC_LINK_UNDEFINED "-undefined suppress" -# define dynamic_link_version_func darwin_dynamic_link_function -# define DYNAMIC_INSTALL_NAME "-install_name" -# define DYNAMIC_LINK_NO_INSTALL "-dylib_file" -# define HAS_REALPATH -/*-install_name /Users/jerenk/apache-2.0-cvs/lib/libapr.0.dylib -compatibility_version 1 -current_version 1.0 */ -# define LD_LIBRARY_PATH "DYLD_LIBRARY_PATH" -#endif - -#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) -# define SHELL_CMD "/bin/sh" -# define DYNAMIC_LIB_EXT "so" -# define MODULE_LIB_EXT "so" -# define STATIC_LIB_EXT "a" -# define OBJECT_EXT "o" -# define LIBRARIAN "ar" -# define LIBRARIAN_OPTS "cr" -# define RANLIB "ranlib" -# define PIC_FLAG "-fPIC" -# define RPATH "-rpath" -# define SHARED_OPTS "-shared" -# define MODULE_OPTS "-shared" -# define DYNAMIC_LINK_OPTS "-export-dynamic" -# define LINKER_FLAG_PREFIX "-Wl," -# define ADD_MINUS_L -# define LD_RUN_PATH "LD_RUN_PATH" -# define LD_LIBRARY_PATH "LD_LIBRARY_PATH" -#endif - -#if defined(sun) -# define SHELL_CMD "/bin/sh" -# define DYNAMIC_LIB_EXT "so" -# define MODULE_LIB_EXT "so" -# define STATIC_LIB_EXT "a" -# define OBJECT_EXT "o" -# define LIBRARIAN "ar" -# define LIBRARIAN_OPTS "cr" -# define RANLIB "ranlib" -# define PIC_FLAG "-KPIC" -# define RPATH "-R" -# define SHARED_OPTS "-G" -# define MODULE_OPTS "-G" -# define DYNAMIC_LINK_OPTS "" -# define LINKER_FLAG_NO_EQUALS -# define ADD_MINUS_L -# define HAS_REALPATH -# define LD_RUN_PATH "LD_RUN_PATH" -# define LD_LIBRARY_PATH "LD_LIBRARY_PATH" -#endif - -#if defined(_OSD_POSIX) -# define SHELL_CMD "/usr/bin/sh" -# define DYNAMIC_LIB_EXT "so" -# define MODULE_LIB_EXT "so" -# define STATIC_LIB_EXT "a" -# define OBJECT_EXT "o" -# define LIBRARIAN "ar" -# define LIBRARIAN_OPTS "cr" -# define SHARED_OPTS "-G" -# define MODULE_OPTS "-G" -# define LINKER_FLAG_PREFIX "-Wl," -# define NEED_SNPRINTF -#endif - -#if defined(sinix) && defined(mips) && defined(__SNI_TARG_UNIX) -# define SHELL_CMD "/usr/bin/sh" -# define DYNAMIC_LIB_EXT "so" -# define MODULE_LIB_EXT "so" -# define STATIC_LIB_EXT "a" -# define OBJECT_EXT "o" -# define LIBRARIAN "ar" -# define LIBRARIAN_OPTS "cr" -# define RPATH "-Brpath" -# define SHARED_OPTS "-G" -# define MODULE_OPTS "-G" -# define DYNAMIC_LINK_OPTS "-Wl,-Blargedynsym" -# define LINKER_FLAG_PREFIX "-Wl," -# define NEED_SNPRINTF -# define LD_RUN_PATH "LD_RUN_PATH" -# define LD_LIBRARY_PATH "LD_LIBRARY_PATH" -#endif - -#if defined(__MINGW32__) -# define SHELL_CMD "sh" -# define DYNAMIC_LIB_EXT "dll" -# define MODULE_LIB_EXT "dll" -# define STATIC_LIB_EXT "a" -# define OBJECT_EXT "o" -# define LIBRARIAN "ar" -# define LIBRARIAN_OPTS "cr" -# define RANLIB "ranlib" -# define LINKER_FLAG_PREFIX "-Wl," -# define SHARED_OPTS "-shared" -# define MODULE_OPTS "-shared" -# define MKDIR_NO_UMASK -# define EXE_EXT ".exe" -#endif - -#ifndef SHELL_CMD -#error Unsupported platform: Please add defines for SHELL_CMD etc. for your platform. -#endif - -#ifdef NEED_SNPRINTF -#include -#endif - -#ifdef __EMX__ -#include -#endif - -#ifndef PATH_MAX -#define PATH_MAX 1024 -#endif - - -/* We want to say we are libtool 1.4 for shlibtool compatibility. */ -#define VERSION "1.4" - -enum tool_mode_t { - mUnknown, - mCompile, - mLink, - mInstall, -}; - -enum output_t { - otGeneral, - otObject, - otProgram, - otLibrary, - otStaticLibraryOnly, - otDynamicLibraryOnly, - otModule, -}; - -enum pic_mode_e { - pic_UNKNOWN, - pic_PREFER, - pic_AVOID, -}; - -enum shared_mode_e { - share_UNSET, - share_STATIC, - share_SHARED, -}; - -enum lib_type { - type_UNKNOWN, - type_DYNAMIC_LIB, - type_STATIC_LIB, - type_MODULE_LIB, - type_OBJECT, -}; - -typedef struct { - const char **vals; - int num; -} count_chars; - -typedef struct { - const char *normal; - const char *install; -} library_name; - -typedef struct { - count_chars *normal; - count_chars *install; - count_chars *dependencies; -} library_opts; - -typedef struct { - int silent; - enum shared_mode_e shared; - int export_all; - int dry_run; - enum pic_mode_e pic_mode; - int export_dynamic; - int no_install; -} options_t; - -typedef struct { - enum tool_mode_t mode; - enum output_t output; - options_t options; - - char *output_name; - char *fake_output_name; - char *basename; - - const char *install_path; - const char *compiler; - const char *program; - count_chars *program_opts; - - count_chars *arglist; - count_chars *tmp_dirs; - count_chars *obj_files; - count_chars *dep_rpaths; - count_chars *rpaths; - - library_name static_name; - library_name shared_name; - library_name module_name; - - library_opts static_opts; - library_opts shared_opts; - - const char *version_info; - const char *undefined_flag; -} command_t; - -#ifdef RPATH -void add_rpath(count_chars *cc, const char *path); -#endif - -#if defined(NEED_SNPRINTF) -/* Write at most n characters to the buffer in str, return the - * number of chars written or -1 if the buffer would have been - * overflowed. - * - * This is portable to any POSIX-compliant system has /dev/null - */ -static FILE *f=NULL; -static int vsnprintf( char *str, size_t n, const char *fmt, va_list ap ) -{ - int res; - - if (f == NULL) - f = fopen("/dev/null","w"); - if (f == NULL) - return -1; - - setvbuf( f, str, _IOFBF, n ); - - res = vfprintf( f, fmt, ap ); - - if ( res > 0 && res < n ) { - res = vsprintf( str, fmt, ap ); - } - return res; -} -static int snprintf( char *str, size_t n, const char *fmt, ... ) -{ - va_list ap; - int res; - - va_start( ap, fmt ); - res = vsnprintf( str, n, fmt, ap ); - va_end( ap ); - return res; -} -#endif - -void init_count_chars(count_chars *cc) -{ - cc->vals = (const char**)malloc(PATH_MAX*sizeof(char*)); - cc->num = 0; -} - -void clear_count_chars(count_chars *cc) -{ - int i; - for (i = 0; i < cc->num; i++) { - cc->vals[i] = 0; - } - - cc->num = 0; -} - -void push_count_chars(count_chars *cc, const char *newval) -{ - cc->vals[cc->num++] = newval; -} - -void pop_count_chars(count_chars *cc) -{ - cc->num--; -} - -void insert_count_chars(count_chars *cc, const char *newval, int position) -{ - int i; - - for (i = cc->num; i > position; i--) { - cc->vals[i] = cc->vals[i-1]; - } - - cc->vals[position] = newval; - cc->num++; -} - -void append_count_chars(count_chars *cc, count_chars *cctoadd) -{ - int i; - for (i = 0; i < cctoadd->num; i++) { - if (cctoadd->vals[i]) { - push_count_chars(cc, cctoadd->vals[i]); - } - } -} - -const char *flatten_count_chars(count_chars *cc, int space) -{ - int i, size; - char *newval; - - size = 0; - for (i = 0; i < cc->num; i++) { - if (cc->vals[i]) { - size += strlen(cc->vals[i]) + 1; - if (space) { - size++; - } - } - } - - newval = (char*)malloc(size + 1); - newval[0] = 0; - - for (i = 0; i < cc->num; i++) { - if (cc->vals[i]) { - strcat(newval, cc->vals[i]); - if (space) { - strcat(newval, " "); - } - } - } - - return newval; -} - -char *shell_esc(const char *str) -{ - int in_quote = 0; - char *cmd; - unsigned char *d; - const unsigned char *s; - - cmd = (char *)malloc(2 * strlen(str) + 3); - d = (unsigned char *)cmd; - s = (const unsigned char *)str; - -#ifdef __MINGW32__ - *d++ = '\"'; -#endif - - for (; *s; ++s) { - if (*s == '"') { - *d++ = '\\'; - in_quote++; - } - else if (*s == '\\' || (*s == ' ' && (in_quote % 2))) { - *d++ = '\\'; - } - *d++ = *s; - } - -#ifdef __MINGW32__ - *d++ = '\"'; -#endif - - *d = '\0'; - return cmd; -} - -int external_spawn(command_t *cmd, const char *file, const char **argv) -{ - if (!cmd->options.silent) { - const char **argument = argv; - printf("Executing: "); - while (*argument) { - printf("%s ", *argument); - argument++; - } - puts(""); - } - - if (cmd->options.dry_run) { - return 0; - } -#if defined(__EMX__) || defined(__MINGW32__) - return spawnvp(P_WAIT, argv[0], argv); -#else - { - pid_t pid; - pid = fork(); - if (pid == 0) { - return execvp(argv[0], (char**)argv); - } - else { - int statuscode; - waitpid(pid, &statuscode, 0); - if (WIFEXITED(statuscode)) { - return WEXITSTATUS(statuscode); - } - return 0; - } - } -#endif -} - -int run_command(command_t *cmd_data, count_chars *cc) -{ - char *command; - const char *spawn_args[4]; - count_chars tmpcc; - - init_count_chars(&tmpcc); - - if (cmd_data->program) { - push_count_chars(&tmpcc, cmd_data->program); - } - - append_count_chars(&tmpcc, cmd_data->program_opts); - - append_count_chars(&tmpcc, cc); - - command = shell_esc(flatten_count_chars(&tmpcc, 1)); - - spawn_args[0] = SHELL_CMD; - spawn_args[1] = "-c"; - spawn_args[2] = command; - spawn_args[3] = NULL; - return external_spawn(cmd_data, spawn_args[0], (const char**)spawn_args); -} - -/* - * print configuration - * shlibpath_var is used in configure. - */ -void print_config() -{ -#ifdef LD_RUN_PATH - printf("runpath_var=%s\n", LD_RUN_PATH); -#endif -#ifdef LD_LIBRARY_PATH - printf("shlibpath_var=%s\n", LD_LIBRARY_PATH); -#endif -#ifdef SHELL_CMD - printf("SHELL=\"%s\"\n", SHELL_CMD); -#endif -} -/* - * Add a directory to the runtime library search path. - */ -void add_runtimedirlib(char *arg, command_t *cmd_data) -{ -#ifdef RPATH - add_rpath(cmd_data->shared_opts.dependencies, arg); -#else -#endif -} - -int parse_long_opt(char *arg, command_t *cmd_data) -{ - char *equal_pos = strchr(arg, '='); - char var[50]; - char value[500]; - - if (equal_pos) { - strncpy(var, arg, equal_pos - arg); - var[equal_pos - arg] = 0; - strcpy(value, equal_pos + 1); - } else { - strcpy(var, arg); - } - - if (strcmp(var, "silent") == 0) { - cmd_data->options.silent = 1; - } else if (strcmp(var, "mode") == 0) { - if (strcmp(value, "compile") == 0) { - cmd_data->mode = mCompile; - cmd_data->output = otObject; - } - - if (strcmp(value, "link") == 0) { - cmd_data->mode = mLink; - cmd_data->output = otLibrary; - } - - if (strcmp(value, "install") == 0) { - cmd_data->mode = mInstall; - } - } else if (strcmp(var, "shared") == 0) { - if (cmd_data->mode == mLink) { - cmd_data->output = otDynamicLibraryOnly; - } - cmd_data->options.shared = share_SHARED; - } else if (strcmp(var, "export-all") == 0) { - cmd_data->options.export_all = 1; - } else if (strcmp(var, "dry-run") == 0) { - printf("Dry-run mode on!\n"); - cmd_data->options.dry_run = 1; - } else if (strcmp(var, "version") == 0) { - printf("Version " VERSION "\n"); - } else if (strcmp(var, "help") == 0) { - printf("Sorry. No help available.\n"); - } else if (strcmp(var, "config") == 0) { - print_config(); - } else if (strcmp(var, "tag") == 0) { - if (strcmp(value, "CC") == 0) { - /* Do nothing. */ - } - if (strcmp(value, "CXX") == 0) { - /* Do nothing. */ - } - } else { - return 0; - } - - return 1; -} - -/* Return 1 if we eat it. */ -int parse_short_opt(char *arg, command_t *cmd_data) -{ - if (strcmp(arg, "export-dynamic") == 0) { - cmd_data->options.export_dynamic = 1; - return 1; - } - - if (strcmp(arg, "module") == 0) { - cmd_data->output = otModule; - return 1; - } - - if (strcmp(arg, "shared") == 0) { - if (cmd_data->mode == mLink) { - cmd_data->output = otDynamicLibraryOnly; - } - cmd_data->options.shared = share_SHARED; - return 1; - } - - if (strcmp(arg, "Zexe") == 0) { - return 1; - } - - if (strcmp(arg, "avoid-version") == 0) { - return 1; - } - - if (strcmp(arg, "prefer-pic") == 0) { - cmd_data->options.pic_mode = pic_PREFER; - return 1; - } - - if (strcmp(arg, "prefer-non-pic") == 0) { - cmd_data->options.pic_mode = pic_AVOID; - return 1; - } - - if (strcmp(arg, "static") == 0) { - cmd_data->options.shared = share_STATIC; - return 1; - } - - if (cmd_data->mode == mLink) { - if (strcmp(arg, "no-install") == 0) { - cmd_data->options.no_install = 1; - return 1; - } - if (arg[0] == 'L' || arg[0] == 'l') { - /* Hack... */ - arg--; - push_count_chars(cmd_data->shared_opts.dependencies, arg); - return 1; - } else if (arg[0] == 'R' && arg[1]) { - /* -Rdir Add dir to runtime library search path. */ - add_runtimedirlib(&arg[1], cmd_data); - return 1; - } - } - return 0; -} - -char *truncate_dll_name(char *path) -{ - /* Cut DLL name down to 8 characters after removing any mod_ prefix */ - char *tmppath = strdup(path); - char *newname = strrchr(tmppath, '/') + 1; - char *ext = strrchr(tmppath, '.'); - int len; - - if (ext == NULL) - return tmppath; - - len = ext - newname; - - if (strncmp(newname, "mod_", 4) == 0) { - strcpy(newname, newname + 4); - len -= 4; - } - - if (len > 8) { - strcpy(newname + 8, strchr(newname, '.')); - } - - return tmppath; -} - -long safe_strtol(const char *nptr, const char **endptr, int base) -{ - long rv; - - errno = 0; - - rv = strtol(nptr, (char**)endptr, 10); - - if (errno == ERANGE) { - return 0; - } - - return rv; -} - -void safe_mkdir(const char *path) -{ - mode_t old_umask; - - old_umask = umask(0); - umask(old_umask); - -#ifdef MKDIR_NO_UMASK - mkdir(path); -#else - mkdir(path, ~old_umask); -#endif -} - -/* returns just a file's name without the path */ -const char *jlibtool_basename(const char *fullpath) -{ - const char *name = strrchr(fullpath, '/'); - - if (name == NULL) { - name = strrchr(fullpath, '\\'); - } - - if (name == NULL) { - name = fullpath; - } else { - name++; - } - - return name; -} - -/* returns just a file's name without path or extension */ -const char *nameof(const char *fullpath) -{ - const char *name; - const char *ext; - - name = jlibtool_basename(fullpath); - ext = strrchr(name, '.'); - - if (ext) { - char *trimmed; - trimmed = malloc(ext - name + 1); - strncpy(trimmed, name, ext - name); - trimmed[ext-name] = 0; - return trimmed; - } - - return name; -} - -/* version_info is in the form of MAJOR:MINOR:PATCH */ -const char *darwin_dynamic_link_function(const char *version_info) -{ - char *newarg; - long major, minor, patch; - - major = 0; - minor = 0; - patch = 0; - - if (version_info) { - major = safe_strtol(version_info, &version_info, 10); - - if (version_info) { - if (version_info[0] == ':') { - version_info++; - } - - minor = safe_strtol(version_info, &version_info, 10); - - if (version_info) { - if (version_info[0] == ':') { - version_info++; - } - - patch = safe_strtol(version_info, &version_info, 10); - - } - } - } - - /* Avoid -dylib_compatibility_version must be greater than zero errors. */ - if (major == 0) { - major = 1; - } - newarg = (char*)malloc(100); - snprintf(newarg, 99, - "-compatibility_version %ld -current_version %ld.%ld", - major, major, minor); - - return newarg; -} - -/* genlib values - * 0 - static - * 1 - dynamic - * 2 - module - */ -char *gen_library_name(const char *name, int genlib) -{ - char *newarg, *newext; - - newarg = (char *)malloc(strlen(name) + 11); - strcpy(newarg, ".libs/"); - - if (genlib == 2 && strncmp(name, "lib", 3) == 0) { - name += 3; - } - - if (genlib == 2) { - strcat(newarg, jlibtool_basename(name)); - } - else { - strcat(newarg, name); - } - - newext = strrchr(newarg, '.') + 1; - - switch (genlib) { - case 0: - strcpy(newext, STATIC_LIB_EXT); - break; - case 1: - strcpy(newext, DYNAMIC_LIB_EXT); - break; - case 2: - strcpy(newext, MODULE_LIB_EXT); - break; - } - - return newarg; -} - -/* genlib values - * 0 - static - * 1 - dynamic - * 2 - module - */ -char *gen_install_name(const char *name, int genlib) -{ - struct stat sb; - char *newname; - int rv; - - newname = gen_library_name(name, genlib); - - /* Check if it exists. If not, return NULL. */ - rv = stat(newname, &sb); - - if (rv) { - return NULL; - } - - return newname; -} - -char *check_object_exists(command_t *cmd, const char *arg, int arglen) -{ - char *newarg, *ext; - int pass, rv; - - newarg = (char *)malloc(arglen + 10); - memcpy(newarg, arg, arglen); - newarg[arglen] = 0; - ext = newarg + arglen; - - pass = 0; - - do { - struct stat sb; - - switch (pass) { - case 0: - strcpy(ext, OBJECT_EXT); - break; -/* - case 1: - strcpy(ext, NO_PIC_EXT); - break; -*/ - default: - break; - } - - if (!cmd->options.silent) { - printf("Checking (obj): %s\n", newarg); - } - rv = stat(newarg, &sb); - } - while (rv != 0 && ++pass < 1); - - if (rv == 0) { - if (pass == 1) { - cmd->options.pic_mode = pic_AVOID; - } - return newarg; - } - - return NULL; -} - -/* libdircheck values: - * 0 - no .libs suffix - * 1 - .libs suffix - */ -char *check_library_exists(command_t *cmd, const char *arg, int pathlen, - int libdircheck, enum lib_type *libtype) -{ - char *newarg, *ext; - int pass, rv, newpathlen; - - newarg = (char *)malloc(strlen(arg) + 10); - strcpy(newarg, arg); - newarg[pathlen] = 0; - - newpathlen = pathlen; - if (libdircheck) { - strcat(newarg, ".libs/"); - newpathlen += sizeof(".libs/") - 1; - } - - strcpy(newarg+newpathlen, arg+pathlen); - ext = strrchr(newarg, '.') + 1; - - pass = 0; - - do { - struct stat sb; - - switch (pass) { - case 0: - if (cmd->options.pic_mode != pic_AVOID && - cmd->options.shared != share_STATIC) { - strcpy(ext, DYNAMIC_LIB_EXT); - *libtype = type_DYNAMIC_LIB; - break; - } - pass = 1; - /* Fall through */ - case 1: - strcpy(ext, STATIC_LIB_EXT); - *libtype = type_STATIC_LIB; - break; - case 2: - strcpy(ext, MODULE_LIB_EXT); - *libtype = type_MODULE_LIB; - break; - case 3: - strcpy(ext, OBJECT_EXT); - *libtype = type_OBJECT; - break; - default: - *libtype = type_UNKNOWN; - break; - } - - if (!cmd->options.silent) { - printf("Checking (lib): %s\n", newarg); - } - rv = stat(newarg, &sb); - } - while (rv != 0 && ++pass < 4); - - if (rv == 0) { - return newarg; - } - - return NULL; -} - -char * load_install_path(const char *arg) -{ - FILE *f; - char *path; - - path = malloc(PATH_MAX); - - f = fopen(arg,"r"); - if (f == NULL) { - return NULL; - } - fgets(path, PATH_MAX, f); - fclose(f); - if (path[strlen(path)-1] == '\n') { - path[strlen(path)-1] = '\0'; - } - /* Check that we have an absolute path. - * Otherwise the file could be a GNU libtool file. - */ - if (path[0] != '/') { - return NULL; - } - return path; -} - -char * load_noinstall_path(const char *arg, int pathlen) -{ - char *newarg, *expanded_path; - int newpathlen; - - newarg = (char *)malloc(strlen(arg) + 10); - strcpy(newarg, arg); - newarg[pathlen] = 0; - - newpathlen = pathlen; - strcat(newarg, ".libs"); - newpathlen += sizeof(".libs") - 1; - newarg[newpathlen] = 0; - -#ifdef HAS_REALPATH - expanded_path = malloc(PATH_MAX); - expanded_path = realpath(newarg, expanded_path); - /* Uh, oh. There was an error. Fall back on our first guess. */ - if (!expanded_path) { - expanded_path = newarg; - } -#else - /* We might get ../ or something goofy. Oh, well. */ - expanded_path = newarg; -#endif - - return expanded_path; -} - -void add_dynamic_link_opts(command_t *cmd_data, count_chars *args) -{ -#ifdef DYNAMIC_LINK_OPTS - if (cmd_data->options.pic_mode != pic_AVOID) { - if (!cmd_data->options.silent) { - printf("Adding: %s\n", DYNAMIC_LINK_OPTS); - } - push_count_chars(args, DYNAMIC_LINK_OPTS); - if (cmd_data->undefined_flag) { - push_count_chars(args, "-undefined"); -#if defined(__APPLE__) - /* -undefined dynamic_lookup is used by the bundled Python in - * 10.4, but if we don't set MACOSX_DEPLOYMENT_TARGET to 10.3+, - * we'll get a linker error if we pass this flag. - */ - if (strcasecmp(cmd_data->undefined_flag, - "dynamic_lookup") == 0) { - insert_count_chars(cmd_data->program_opts, - "MACOSX_DEPLOYMENT_TARGET=10.3", 0); - } -#endif - push_count_chars(args, cmd_data->undefined_flag); - } - else { -#ifdef DYNAMIC_LINK_UNDEFINED - if (!cmd_data->options.silent) { - printf("Adding: %s\n", DYNAMIC_LINK_UNDEFINED); - } - push_count_chars(args, DYNAMIC_LINK_UNDEFINED); -#endif - } - } -#endif -} - -/* Read the final install location and add it to runtime library search path. */ -#ifdef RPATH -void add_rpath(count_chars *cc, const char *path) -{ - int size = 0; - char *tmp; - -#ifdef LINKER_FLAG_PREFIX - size = strlen(LINKER_FLAG_PREFIX); -#endif - size = size + strlen(path) + strlen(RPATH) + 2; - tmp = malloc(size); - if (tmp == NULL) { - return; - } -#ifdef LINKER_FLAG_PREFIX - strcpy(tmp, LINKER_FLAG_PREFIX); - strcat(tmp, RPATH); -#else - strcpy(tmp, RPATH); -#endif -#ifndef LINKER_FLAG_NO_EQUALS - strcat(tmp, "="); -#endif - strcat(tmp, path); - - push_count_chars(cc, tmp); -} - -void add_rpath_file(count_chars *cc, const char *arg) -{ - const char *path; - - path = load_install_path(arg); - if (path) { - add_rpath(cc, path); - } -} - -void add_rpath_noinstall(count_chars *cc, const char *arg, int pathlen) -{ - const char *path; - - path = load_noinstall_path(arg, pathlen); - if (path) { - add_rpath(cc, path); - } -} -#endif - -#ifdef DYNAMIC_LINK_NO_INSTALL -void add_dylink_noinstall(count_chars *cc, const char *arg, int pathlen, - int extlen) -{ - const char *install_path, *current_path, *name; - char *exp_argument; - int i_p_len, c_p_len, name_len, dyext_len, cur_len; - - install_path = load_install_path(arg); - current_path = load_noinstall_path(arg, pathlen); - - if (!install_path || !current_path) { - return; - } - - push_count_chars(cc, DYNAMIC_LINK_NO_INSTALL); - - i_p_len = strlen(install_path); - c_p_len = strlen(current_path); - - name = arg+pathlen; - name_len = extlen-pathlen; - dyext_len = sizeof(DYNAMIC_LIB_EXT) - 1; - - /* No, we need to replace the extension. */ - exp_argument = (char *)malloc(i_p_len + c_p_len + (name_len*2) + - (dyext_len*2) + 2); - - cur_len = 0; - strcpy(exp_argument, install_path); - cur_len += i_p_len; - exp_argument[cur_len++] = '/'; - strncpy(exp_argument+cur_len, name, extlen-pathlen); - cur_len += name_len; - strcpy(exp_argument+cur_len, DYNAMIC_LIB_EXT); - cur_len += dyext_len; - exp_argument[cur_len++] = ':'; - strcpy(exp_argument+cur_len, current_path); - cur_len += c_p_len; - exp_argument[cur_len++] = '/'; - strncpy(exp_argument+cur_len, name, extlen-pathlen); - cur_len += name_len; - strcpy(exp_argument+cur_len, DYNAMIC_LIB_EXT); - cur_len += dyext_len; - - push_count_chars(cc, exp_argument); -} -#endif - -/* use -L -llibname to allow to use installed libraries */ -void add_minus_l(count_chars *cc, const char *arg) -{ - char *newarg; - char *name = strrchr(arg, '/'); - char *file = strrchr(arg, '.'); - char *lib = strstr(name, "lib"); - - if (name !=NULL && file != NULL && lib == name+1) { - *name = '\0'; - *file = '\0'; - file = name; - file = file+4; - push_count_chars(cc, "-L"); - push_count_chars(cc, arg); - /* we need one argument like -lapr-1 */ - newarg = malloc(strlen(file) + 3); - strcpy(newarg, "-l"); - strcat(newarg, file); - push_count_chars(cc, newarg); - } else { - push_count_chars(cc, arg); - } -} - -void add_linker_flag_prefix(count_chars *cc, const char *arg) -{ -#ifndef LINKER_FLAG_PREFIX - push_count_chars(cc, arg); -#else - char *newarg; - newarg = (char*)malloc(strlen(arg) + sizeof(LINKER_FLAG_PREFIX) + 1); - strcpy(newarg, LINKER_FLAG_PREFIX); - strcat(newarg, arg); - push_count_chars(cc, newarg); -#endif -} - -int explode_static_lib(command_t *cmd_data, const char *lib) -{ - count_chars tmpdir_cc, libname_cc; - const char *tmpdir, *libname; - char savewd[PATH_MAX]; - const char *name; - DIR *dir; - struct dirent *entry; - const char *lib_args[4]; - - /* Bah! */ - if (cmd_data->options.dry_run) { - return 0; - } - - name = jlibtool_basename(lib); - - init_count_chars(&tmpdir_cc); - push_count_chars(&tmpdir_cc, ".libs/"); - push_count_chars(&tmpdir_cc, name); - push_count_chars(&tmpdir_cc, ".exploded/"); - tmpdir = flatten_count_chars(&tmpdir_cc, 0); - - if (!cmd_data->options.silent) { - printf("Making: %s\n", tmpdir); - } - safe_mkdir(tmpdir); - - push_count_chars(cmd_data->tmp_dirs, tmpdir); - - getcwd(savewd, sizeof(savewd)); - - if (chdir(tmpdir) != 0) { - if (!cmd_data->options.silent) { - printf("Warning: could not explode %s\n", lib); - } - return 1; - } - - if (lib[0] == '/') { - libname = lib; - } - else { - init_count_chars(&libname_cc); - push_count_chars(&libname_cc, "../../"); - push_count_chars(&libname_cc, lib); - libname = flatten_count_chars(&libname_cc, 0); - } - - lib_args[0] = LIBRARIAN; - lib_args[1] = "x"; - lib_args[2] = libname; - lib_args[3] = NULL; - - external_spawn(cmd_data, LIBRARIAN, lib_args); - - chdir(savewd); - dir = opendir(tmpdir); - - while ((entry = readdir(dir)) != NULL) { -#if defined(__APPLE__) && defined(RANLIB) - /* Apple inserts __.SYMDEF which isn't needed. - * Leopard (10.5+) can also add '__.SYMDEF SORTED' which isn't - * much fun either. Just skip them. - */ - if (strstr(entry->d_name, "__.SYMDEF") != NULL) { - continue; - } -#endif - if (entry->d_name[0] != '.') { - push_count_chars(&tmpdir_cc, entry->d_name); - name = flatten_count_chars(&tmpdir_cc, 0); - if (!cmd_data->options.silent) { - printf("Adding: %s\n", name); - } - push_count_chars(cmd_data->obj_files, name); - pop_count_chars(&tmpdir_cc); - } - } - - closedir(dir); - return 0; -} - -int parse_input_file_name(char *arg, command_t *cmd_data) -{ - char *ext = strrchr(arg, '.'); - char *name = strrchr(arg, '/'); - int pathlen; - enum lib_type libtype; - char *newarg; - - if (!ext) { - return 0; - } - - ext++; - - if (name == NULL) { - name = strrchr(arg, '\\'); - - if (name == NULL) { - name = arg; - } else { - name++; - } - } else { - name++; - } - - pathlen = name - arg; - - if (strcmp(ext, "lo") == 0) { - newarg = check_object_exists(cmd_data, arg, ext - arg); - if (!newarg) { - printf("Can not find suitable object file for %s\n", arg); - exit(1); - } - if (cmd_data->mode != mLink) { - push_count_chars(cmd_data->arglist, newarg); - } - else { - push_count_chars(cmd_data->obj_files, newarg); - } - return 1; - } - - if (strcmp(ext, "la") == 0) { - switch (cmd_data->mode) { - case mLink: - /* Try the .libs dir first! */ - newarg = check_library_exists(cmd_data, arg, pathlen, 1, &libtype); - if (!newarg) { - /* Try the normal dir next. */ - newarg = check_library_exists(cmd_data, arg, pathlen, 0, &libtype); - if (!newarg) { - printf("Can not find suitable library for %s\n", arg); - exit(1); - } - } - - /* It is not ok to just add the file: a library may added with: - 1 - -L path library_name. (For *.so in Linux). - 2 - library_name. - */ -#ifdef ADD_MINUS_L - if (libtype == type_DYNAMIC_LIB) { - add_minus_l(cmd_data->shared_opts.dependencies, newarg); - } else if (cmd_data->output == otLibrary && - libtype == type_STATIC_LIB) { - explode_static_lib(cmd_data, newarg); - } else { - push_count_chars(cmd_data->shared_opts.dependencies, newarg); - } -#else - if (cmd_data->output == otLibrary && libtype == type_STATIC_LIB) { - explode_static_lib(cmd_data, newarg); - } - else { - push_count_chars(cmd_data->shared_opts.dependencies, newarg); - } -#endif - if (libtype == type_DYNAMIC_LIB) { - if (cmd_data->options.no_install) { -#ifdef RPATH - add_rpath_noinstall(cmd_data->shared_opts.dependencies, - arg, pathlen); -#endif -#ifdef DYNAMIC_LINK_NO_INSTALL - /* - * This doesn't work as Darwin's linker has no way to - * override at link-time the search paths for a - * non-installed library. - */ - /* - add_dylink_noinstall(cmd_data->shared_opts.dependencies, - arg, pathlen, ext - arg); - */ -#endif - } - else { -#ifdef RPATH - add_rpath_file(cmd_data->shared_opts.dependencies, arg); -#endif - } - } - break; - case mInstall: - /* If we've already recorded a library to install, we're most - * likely getting the .la file that we want to install as. - * The problem is that we need to add it as the directory, - * not the .la file itself. Otherwise, we'll do odd things. - */ - if (cmd_data->output == otLibrary) { - arg[pathlen] = '\0'; - push_count_chars(cmd_data->arglist, arg); - } - else { - cmd_data->output = otLibrary; - cmd_data->output_name = arg; - cmd_data->static_name.install = gen_install_name(arg, 0); - cmd_data->shared_name.install = gen_install_name(arg, 1); - cmd_data->module_name.install = gen_install_name(arg, 2); - } - break; - default: - break; - } - return 1; - } - - if (strcmp(ext, "c") == 0) { - /* If we don't already have an idea what our output name will be. */ - if (cmd_data->basename == NULL) { - cmd_data->basename = (char *)malloc(strlen(arg) + 4); - strcpy(cmd_data->basename, arg); - strcpy(strrchr(cmd_data->basename, '.') + 1, "lo"); - - cmd_data->fake_output_name = strrchr(cmd_data->basename, '/'); - if (cmd_data->fake_output_name) { - cmd_data->fake_output_name++; - } - else { - cmd_data->fake_output_name = cmd_data->basename; - } - } - } - - return 0; -} - -int parse_output_file_name(char *arg, command_t *cmd_data) -{ - char *name = strrchr(arg, '/'); - char *ext = strrchr(arg, '.'); - char *newarg = NULL; - int pathlen; - - cmd_data->fake_output_name = arg; - - if (name) { - name++; - } - else { - name = strrchr(arg, '\\'); - - if (name == NULL) { - name = arg; - } - else { - name++; - } - } - -#ifdef EXE_EXT - if (!ext || strcmp(ext, EXE_EXT) == 0) { -#else - if (!ext) { -#endif - cmd_data->basename = arg; - cmd_data->output = otProgram; -#if defined(_OSD_POSIX) - cmd_data->options.pic_mode = pic_AVOID; -#endif - newarg = (char *)malloc(strlen(arg) + 5); - strcpy(newarg, arg); -#ifdef EXE_EXT - if (!ext) { - strcat(newarg, EXE_EXT); - } -#endif - cmd_data->output_name = newarg; - return 1; - } - - ext++; - pathlen = name - arg; - - if (strcmp(ext, "la") == 0) { - assert(cmd_data->mode == mLink); - - cmd_data->basename = arg; - cmd_data->static_name.normal = gen_library_name(arg, 0); - cmd_data->shared_name.normal = gen_library_name(arg, 1); - cmd_data->module_name.normal = gen_library_name(arg, 2); - cmd_data->static_name.install = gen_install_name(arg, 0); - cmd_data->shared_name.install = gen_install_name(arg, 1); - cmd_data->module_name.install = gen_install_name(arg, 2); - -#ifdef TRUNCATE_DLL_NAME - if (shared) { - arg = truncate_dll_name(arg); - } -#endif - - cmd_data->output_name = arg; - return 1; - } - - if (strcmp(ext, "lo") == 0) { - cmd_data->basename = arg; - cmd_data->output = otObject; - newarg = (char *)malloc(strlen(arg) + 2); - strcpy(newarg, arg); - ext = strrchr(newarg, '.') + 1; - strcpy(ext, OBJECT_EXT); - cmd_data->output_name = newarg; - return 1; - } - - return 0; -} - -void parse_args(int argc, char *argv[], command_t *cmd_data) -{ - int a; - char *arg; - int argused; - - for (a = 1; a < argc; a++) { - arg = argv[a]; - argused = 1; - - if (arg[0] == '-') { - if (arg[1] == '-') { - argused = parse_long_opt(arg + 2, cmd_data); - } - else { - argused = parse_short_opt(arg + 1, cmd_data); - } - - /* We haven't done anything with it yet, try some of the - * more complicated short opts... */ - if (argused == 0 && a + 1 < argc) { - if (arg[1] == 'o' && !arg[2]) { - arg = argv[++a]; - argused = parse_output_file_name(arg, cmd_data); - } else if (strcmp(arg+1, "MT") == 0) { - if (!cmd_data->options.silent) { - printf("Adding: %s\n", arg); - } - push_count_chars(cmd_data->arglist, arg); - arg = argv[++a]; - if (!cmd_data->options.silent) { - printf(" %s\n", arg); - } - push_count_chars(cmd_data->arglist, arg); - argused = 1; - } else if (strcmp(arg+1, "rpath") == 0) { - /* Aha, we should try to link both! */ - cmd_data->install_path = argv[++a]; - argused = 1; - } else if (strcmp(arg+1, "release") == 0) { - /* Store for later deciphering */ - cmd_data->version_info = argv[++a]; - argused = 1; - } else if (strcmp(arg+1, "version-info") == 0) { - /* Store for later deciphering */ - cmd_data->version_info = argv[++a]; - argused = 1; - } else if (strcmp(arg+1, "export-symbols-regex") == 0) { - /* Skip the argument. */ - ++a; - argused = 1; - } else if (strcmp(arg+1, "release") == 0) { - /* Skip the argument. */ - ++a; - argused = 1; - } else if (strcmp(arg+1, "undefined") == 0) { - cmd_data->undefined_flag = argv[++a]; - argused = 1; - } else if (arg[1] == 'R' && !arg[2]) { - /* -R dir Add dir to runtime library search path. */ - add_runtimedirlib(argv[++a], cmd_data); - argused = 1; - } - } - } else { - argused = parse_input_file_name(arg, cmd_data); - } - - if (!argused) { - if (!cmd_data->options.silent) { - printf("Adding: %s\n", arg); - } - push_count_chars(cmd_data->arglist, arg); - } - } - -} - -#ifdef GEN_EXPORTS -void generate_def_file(command_t *cmd_data) -{ - char def_file[1024]; - char implib_file[1024]; - char *ext; - FILE *hDef; - char *export_args[1024]; - int num_export_args = 0; - char *cmd; - int cmd_size = 0; - int a; - - if (cmd_data->output_name) { - strcpy(def_file, cmd_data->output_name); - strcat(def_file, ".def"); - hDef = fopen(def_file, "w"); - - if (hDef != NULL) { - fprintf(hDef, "LIBRARY '%s' INITINSTANCE\n", nameof(cmd_data->output_name)); - fprintf(hDef, "DATA NONSHARED\n"); - fprintf(hDef, "EXPORTS\n"); - fclose(hDef); - - for (a = 0; a < cmd_data->num_obj_files; a++) { - cmd_size += strlen(cmd_data->obj_files[a]) + 1; - } - - cmd_size += strlen(GEN_EXPORTS) + strlen(def_file) + 3; - cmd = (char *)malloc(cmd_size); - strcpy(cmd, GEN_EXPORTS); - - for (a=0; a < cmd_data->num_obj_files; a++) { - strcat(cmd, " "); - strcat(cmd, cmd_data->obj_files[a] ); - } - - strcat(cmd, ">>"); - strcat(cmd, def_file); - puts(cmd); - export_args[num_export_args++] = SHELL_CMD; - export_args[num_export_args++] = "-c"; - export_args[num_export_args++] = cmd; - export_args[num_export_args++] = NULL; - external_spawn(cmd_data, export_args[0], (const char**)export_args); - cmd_data->arglist[cmd_data->num_args++] = strdup(def_file); - - /* Now make an import library for the dll */ - num_export_args = 0; - export_args[num_export_args++] = DEF2IMPLIB_CMD; - export_args[num_export_args++] = "-o"; - - strcpy(implib_file, ".libs/"); - strcat(implib_file, cmd_data->basename); - ext = strrchr(implib_file, '.'); - - if (ext) - *ext = 0; - - strcat(implib_file, "."); - strcat(implib_file, STATIC_LIB_EXT); - - export_args[num_export_args++] = implib_file; - export_args[num_export_args++] = def_file; - export_args[num_export_args++] = NULL; - external_spawn(cmd_data, export_args[0], (const char**)export_args); - - } - } -} -#endif - -const char* expand_path(const char *relpath) -{ - char foo[PATH_MAX], *newpath; - - getcwd(foo, PATH_MAX-1); - newpath = (char*)malloc(strlen(foo)+strlen(relpath)+2); - strcpy(newpath, foo); - strcat(newpath, "/"); - strcat(newpath, relpath); - return newpath; -} - -void link_fixup(command_t *c) -{ - /* If we were passed an -rpath directive, we need to build - * shared objects too. Otherwise, we should only create static - * libraries. - */ - if (!c->install_path && (c->output == otDynamicLibraryOnly || - c->output == otModule || c->output == otLibrary)) { - c->output = otStaticLibraryOnly; - } - - if (c->output == otDynamicLibraryOnly || - c->output == otModule || - c->output == otLibrary) { - - push_count_chars(c->shared_opts.normal, "-o"); - if (c->output == otModule) { - push_count_chars(c->shared_opts.normal, c->module_name.normal); - } - else { - char *tmp; - push_count_chars(c->shared_opts.normal, c->shared_name.normal); -#ifdef DYNAMIC_INSTALL_NAME - push_count_chars(c->shared_opts.normal, DYNAMIC_INSTALL_NAME); - - tmp = (char*)malloc(PATH_MAX); - strcpy(tmp, c->install_path); - strcat(tmp, strrchr(c->shared_name.normal, '/')); - push_count_chars(c->shared_opts.normal, tmp); -#endif - } - - append_count_chars(c->shared_opts.normal, c->obj_files); - append_count_chars(c->shared_opts.normal, c->shared_opts.dependencies); - - if (c->options.export_all) { -#ifdef GEN_EXPORTS - generate_def_file(c); -#endif - } - } - - if (c->output == otLibrary || c->output == otStaticLibraryOnly) { - push_count_chars(c->static_opts.normal, "-o"); - push_count_chars(c->static_opts.normal, c->output_name); - } - - if (c->output == otProgram) { - if (c->output_name) { - push_count_chars(c->arglist, "-o"); - push_count_chars(c->arglist, c->output_name); - append_count_chars(c->arglist, c->obj_files); - append_count_chars(c->arglist, c->shared_opts.dependencies); - add_dynamic_link_opts(c, c->arglist); - } - } -} - -void post_parse_fixup(command_t *cmd_data) -{ - switch (cmd_data->mode) - { - case mCompile: -#ifdef PIC_FLAG - if (cmd_data->options.pic_mode != pic_AVOID) { - push_count_chars(cmd_data->arglist, PIC_FLAG); - } -#endif - if (cmd_data->output_name) { - push_count_chars(cmd_data->arglist, "-o"); - push_count_chars(cmd_data->arglist, cmd_data->output_name); - } - break; - case mLink: - link_fixup(cmd_data); - break; - case mInstall: - if (cmd_data->output == otLibrary) { - link_fixup(cmd_data); - } - default: - break; - } - -#if USE_OMF - if (cmd_data->output == otObject || - cmd_data->output == otProgram || - cmd_data->output == otLibrary || - cmd_data->output == otDynamicLibraryOnly) { - push_count_chars(cmd_data->arglist, "-Zomf"); - } -#endif - - if (cmd_data->options.shared && - (cmd_data->output == otObject || - cmd_data->output == otLibrary || - cmd_data->output == otDynamicLibraryOnly)) { -#ifdef SHARE_SW - push_count_chars(cmd_data->arglist, SHARE_SW); -#endif - } -} - -int run_mode(command_t *cmd_data) -{ - int rv; - count_chars *cctemp; - - cctemp = (count_chars*)malloc(sizeof(count_chars)); - init_count_chars(cctemp); - - switch (cmd_data->mode) - { - case mCompile: - rv = run_command(cmd_data, cmd_data->arglist); - if (rv) { - return rv; - } - break; - case mInstall: - /* Well, we'll assume it's a file going to a directory... */ - /* For brain-dead install-sh based scripts, we have to repeat - * the command N-times. install-sh should die. - */ - if (!cmd_data->output_name) { - rv = run_command(cmd_data, cmd_data->arglist); - if (rv) { - return rv; - } - } - if (cmd_data->output_name) { - append_count_chars(cctemp, cmd_data->arglist); - insert_count_chars(cctemp, - cmd_data->output_name, - cctemp->num - 1); - rv = run_command(cmd_data, cctemp); - if (rv) { - return rv; - } - clear_count_chars(cctemp); - } - if (cmd_data->static_name.install) { - append_count_chars(cctemp, cmd_data->arglist); - insert_count_chars(cctemp, - cmd_data->static_name.install, - cctemp->num - 1); - rv = run_command(cmd_data, cctemp); - if (rv) { - return rv; - } -#if defined(__APPLE__) && defined(RANLIB) - /* From the Apple libtool(1) manpage on Tiger/10.4: - * ---- - * With the way libraries used to be created, errors were possible - * if the library was modified with ar(1) and the table of - * contents was not updated by rerunning ranlib(1). Thus the - * link editor, ld, warns when the modification date of a library - * is more recent than the creation date of its table of - * contents. Unfortunately, this means that you get the warning - * even if you only copy the library. - * ---- - * - * This means that when we install the static archive, we need to - * rerun ranlib afterwards. - */ - const char *lib_args[3], *static_lib_name; - char *tmp; - size_t len1, len2; - len1 = strlen(cmd_data->arglist->vals[cmd_data->arglist->num - 1]); - - static_lib_name = jlibtool_basename(cmd_data->static_name.install); - len2 = strlen(static_lib_name); - - tmp = malloc(len1 + len2 + 2); - - snprintf(tmp, len1 + len2 + 2, "%s/%s", - cmd_data->arglist->vals[cmd_data->arglist->num - 1], - static_lib_name); - - lib_args[0] = RANLIB; - lib_args[1] = tmp; - lib_args[2] = NULL; - external_spawn(cmd_data, RANLIB, lib_args); - free(tmp); -#endif - clear_count_chars(cctemp); - } - if (cmd_data->shared_name.install) { - append_count_chars(cctemp, cmd_data->arglist); - insert_count_chars(cctemp, - cmd_data->shared_name.install, - cctemp->num - 1); - rv = run_command(cmd_data, cctemp); - if (rv) { - return rv; - } - clear_count_chars(cctemp); - } - if (cmd_data->module_name.install) { - append_count_chars(cctemp, cmd_data->arglist); - insert_count_chars(cctemp, - cmd_data->module_name.install, - cctemp->num - 1); - rv = run_command(cmd_data, cctemp); - if (rv) { - return rv; - } - clear_count_chars(cctemp); - } - break; - case mLink: - if (!cmd_data->options.dry_run) { - /* Check first to see if the dir already exists! */ - safe_mkdir(".libs"); - } - - if (cmd_data->output == otStaticLibraryOnly || - cmd_data->output == otLibrary) { -#ifdef RANLIB - const char *lib_args[3]; -#endif - /* Removes compiler! */ - cmd_data->program = LIBRARIAN; - push_count_chars(cmd_data->program_opts, LIBRARIAN_OPTS); - push_count_chars(cmd_data->program_opts, - cmd_data->static_name.normal); - - rv = run_command(cmd_data, cmd_data->obj_files); - if (rv) { - return rv; - } - -#ifdef RANLIB - lib_args[0] = RANLIB; - lib_args[1] = cmd_data->static_name.normal; - lib_args[2] = NULL; - external_spawn(cmd_data, RANLIB, lib_args); -#endif - } - - if (cmd_data->output == otDynamicLibraryOnly || - cmd_data->output == otModule || - cmd_data->output == otLibrary) { - cmd_data->program = NULL; - clear_count_chars(cmd_data->program_opts); - - append_count_chars(cmd_data->program_opts, cmd_data->arglist); - if (cmd_data->output == otModule) { -#ifdef MODULE_OPTS - push_count_chars(cmd_data->program_opts, MODULE_OPTS); -#endif - } else { -#ifdef SHARED_OPTS - push_count_chars(cmd_data->program_opts, SHARED_OPTS); -#endif -#ifdef dynamic_link_version_func - push_count_chars(cmd_data->program_opts, - dynamic_link_version_func(cmd_data->version_info)); -#endif - } - add_dynamic_link_opts(cmd_data, cmd_data->program_opts); - - rv = run_command(cmd_data, cmd_data->shared_opts.normal); - if (rv) { - return rv; - } - } - if (cmd_data->output == otProgram) { - rv = run_command(cmd_data, cmd_data->arglist); - if (rv) { - return rv; - } - } - break; - default: - break; - } - - return 0; -} - -void cleanup_tmp_dir(const char *dirname) -{ - DIR *dir; - struct dirent *entry; - char fullname[1024]; - - dir = opendir(dirname); - - if (dir == NULL) - return; - - while ((entry = readdir(dir)) != NULL) { - if (entry->d_name[0] != '.') { - strcpy(fullname, dirname); - strcat(fullname, "/"); - strcat(fullname, entry->d_name); - remove(fullname); - } - } - - rmdir(dirname); -} - -void cleanup_tmp_dirs(command_t *cmd_data) -{ - int d; - - for (d = 0; d < cmd_data->tmp_dirs->num; d++) { - cleanup_tmp_dir(cmd_data->tmp_dirs->vals[d]); - } -} - -int ensure_fake_uptodate(command_t *cmd_data) -{ - /* FIXME: could do the stat/touch here, but nah... */ - const char *touch_args[3]; - - if (cmd_data->mode == mInstall) { - return 0; - } - if (!cmd_data->fake_output_name) { - return 0; - } - - touch_args[0] = "touch"; - touch_args[1] = cmd_data->fake_output_name; - touch_args[2] = NULL; - return external_spawn(cmd_data, "touch", touch_args); -} - -/* Store the install path in the *.la file */ -int add_for_runtime(command_t *cmd_data) -{ - if (cmd_data->mode == mInstall) { - return 0; - } - if (cmd_data->output == otDynamicLibraryOnly || - cmd_data->output == otLibrary) { - FILE *f=fopen(cmd_data->fake_output_name,"w"); - if (f == NULL) { - return -1; - } - fprintf(f,"%s\n", cmd_data->install_path); - fclose(f); - return(0); - } else { - return(ensure_fake_uptodate(cmd_data)); - } -} - -int main(int argc, char *argv[]) -{ - int rc; - command_t cmd_data; - - memset(&cmd_data, 0, sizeof(cmd_data)); - - cmd_data.options.pic_mode = pic_UNKNOWN; - - cmd_data.program_opts = (count_chars*)malloc(sizeof(count_chars)); - init_count_chars(cmd_data.program_opts); - cmd_data.arglist = (count_chars*)malloc(sizeof(count_chars)); - init_count_chars(cmd_data.arglist); - cmd_data.tmp_dirs = (count_chars*)malloc(sizeof(count_chars)); - init_count_chars(cmd_data.tmp_dirs); - cmd_data.obj_files = (count_chars*)malloc(sizeof(count_chars)); - init_count_chars(cmd_data.obj_files); - cmd_data.dep_rpaths = (count_chars*)malloc(sizeof(count_chars)); - init_count_chars(cmd_data.dep_rpaths); - cmd_data.rpaths = (count_chars*)malloc(sizeof(count_chars)); - init_count_chars(cmd_data.rpaths); - cmd_data.static_opts.normal = (count_chars*)malloc(sizeof(count_chars)); - init_count_chars(cmd_data.static_opts.normal); - cmd_data.shared_opts.normal = (count_chars*)malloc(sizeof(count_chars)); - init_count_chars(cmd_data.shared_opts.normal); - cmd_data.shared_opts.dependencies = (count_chars*)malloc(sizeof(count_chars)); - init_count_chars(cmd_data.shared_opts.dependencies); - - cmd_data.mode = mUnknown; - cmd_data.output = otGeneral; - - parse_args(argc, argv, &cmd_data); - post_parse_fixup(&cmd_data); - - if (cmd_data.mode == mUnknown) { - exit(0); - } - - rc = run_mode(&cmd_data); - - if (!rc) { - add_for_runtime(&cmd_data); - } - - cleanup_tmp_dirs(&cmd_data); - return rc; -} diff --git a/libs/apr/build/libapr.vcxproj b/libs/apr/build/libapr.vcxproj deleted file mode 100644 index dbf77476..00000000 --- a/libs/apr/build/libapr.vcxproj +++ /dev/null @@ -1,246 +0,0 @@ - - - - - UnityDebug - Win32 - - - UnityDebug - x64 - - - UnityRelease - Win32 - - - UnityRelease - x64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {74BFD665-A62B-4745-8A2A-EE1A2A63CD08} - Win32Proj - libapr - - - - StaticLibrary - true - Unicode - - - StaticLibrary - true - Unicode - - - StaticLibrary - false - true - Unicode - - - StaticLibrary - false - true - Unicode - - - - - - - - - - - - - - - - - - - ..\..\..\Temp\$(SolutionName)\$(Configuration)\x86\$(ProjectName)\ - - - ..\..\..\Temp\$(SolutionName)\$(Configuration)\x86\$(ProjectName)\ - AllRules.ruleset - - - ..\..\..\Temp\$(SolutionName)\$(Configuration)\x86\$(ProjectName)\ - - - ..\..\..\Temp\$(SolutionName)\$(Configuration)\x86\$(ProjectName)\ - - - ..\..\..\Temp\$(SolutionName)\$(Configuration)\x64\$(ProjectName)\ - - - ..\..\..\Temp\$(SolutionName)\$(Configuration)\x64\$(ProjectName)\ - - - ..\..\..\Temp\$(SolutionName)\$(Configuration)\x64\$(ProjectName)\ - - - ..\..\..\Temp\$(SolutionName)\$(Configuration)\x64\$(ProjectName)\ - - - - - - TurnOffAllWarnings - Disabled - true - WIN32;WINNT;_WINDOWS;_DEBUG;_LIB;APR_DECLARE_STATIC;%(PreprocessorDefinitions) - .\..\include;.\..\include\arch;.\..\include\arch\win32;.\..\include\arch\unix; - ProgramDatabase - false - MultiThreadedDebug - - - Windows - true - - - - - - - TurnOffAllWarnings - Disabled - true - WIN64;WIN32;WINNT;_WINDOWS;_DEBUG;_LIB;APR_DECLARE_STATIC;%(PreprocessorDefinitions) - .\..\include;.\..\include\arch;.\..\include\arch\win32;.\..\include\arch\unix; - ProgramDatabase - false - MultiThreadedDebug - - - Windows - true - - - - - TurnOffAllWarnings - - - Full - true - true - true - WIN32;NDEBUG;_LIB;APR_DECLARE_STATIC;%(PreprocessorDefinitions) - .\..\include;.\..\include\arch;.\..\include\arch\win32;.\..\include\arch\unix; - ProgramDatabase - false - MultiThreaded - - - Windows - true - true - true - - - - - TurnOffAllWarnings - - - Full - true - true - true - WIN64;WIN32;NDEBUG;_LIB;APR_DECLARE_STATIC;%(PreprocessorDefinitions) - .\..\include;.\..\include\arch;.\..\include\arch\win32;.\..\include\arch\unix; - ProgramDatabase - false - MultiThreaded - - - Windows - true - true - true - - - - - - \ No newline at end of file diff --git a/libs/apr/build/libaprapp.dep b/libs/apr/build/libaprapp.dep deleted file mode 100644 index eb02b820..00000000 --- a/libs/apr/build/libaprapp.dep +++ /dev/null @@ -1,19 +0,0 @@ -# Microsoft Developer Studio Generated Dependency File, included by libaprapp.mak - -..\misc\win32\apr_app.c : \ - "..\include\apr_getopt.h"\ - "..\include\apr_lib.h"\ - "..\include\apr_poll.h"\ - "..\include\apr_portable.h"\ - "..\include\arch\win32\apr_arch_file_io.h"\ - "..\include\arch\win32\apr_arch_utf8.h"\ - - -..\misc\win32\internal.c : \ - "..\include\apr_getopt.h"\ - "..\include\apr_lib.h"\ - "..\include\apr_poll.h"\ - "..\include\apr_portable.h"\ - "..\include\arch\win32\apr_arch_file_io.h"\ - "..\include\arch\win32\apr_arch_utf8.h"\ - diff --git a/libs/apr/build/libaprapp.dsp b/libs/apr/build/libaprapp.dsp deleted file mode 100644 index 2a9506dc..00000000 --- a/libs/apr/build/libaprapp.dsp +++ /dev/null @@ -1,195 +0,0 @@ -# Microsoft Developer Studio Project File - Name="libaprapp" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=libaprapp - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "libaprapp.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "libaprapp.mak" CFG="libaprapp - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "libaprapp - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "libaprapp - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE "libaprapp - Win32 Release9x" (based on "Win32 (x86) Static Library") -!MESSAGE "libaprapp - Win32 Debug9x" (based on "Win32 (x86) Static Library") -!MESSAGE "libaprapp - x64 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "libaprapp - x64 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "libaprapp - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "..\Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "NDEBUG" /D "WINNT" /D "WIN32" /D "_WINDOWS" /D "APR_APP" /Fo"$(INTDIR)\" /Fd"$(OUTDIR)\libaprapp-1" /FD /c -# ADD BASE RSC /l 0x409 -# ADD RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"..\Release\libaprapp-1.lib" - -!ELSEIF "$(CFG)" == "libaprapp - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "..\Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "_DEBUG" /D "WINNT" /D "WIN32" /D "_WINDOWS" /D "APR_APP" /Fo"$(INTDIR)\" /Fd"$(OUTDIR)\libaprapp-1" /FD /c -# ADD BASE RSC /l 0x409 -# ADD RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"..\Debug\libaprapp-1.lib" - -!ELSEIF "$(CFG)" == "libaprapp - Win32 Release9x" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "..\9x\Release" -# PROP BASE Intermediate_Dir "9x\Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\9x\Release" -# PROP Intermediate_Dir "9x\Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "APR_APP" /Fo"$(INTDIR)\" /Fd"$(OUTDIR)\libaprapp-1" /FD /c -# ADD BASE RSC /l 0x409 -# ADD RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"..\9x\Release\libaprapp-1.lib" - -!ELSEIF "$(CFG)" == "libaprapp - Win32 Debug9x" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "..\9x\Debug" -# PROP BASE Intermediate_Dir "9x\Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\9x\Debug" -# PROP Intermediate_Dir "9x\Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "APR_APP" /Fo"$(INTDIR)\" /Fd"$(OUTDIR)\libaprapp-1" /FD /c -# ADD BASE RSC /l 0x409 -# ADD RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"..\9x\Debug\libaprapp-1.lib" - -!ELSEIF "$(CFG)" == "libaprapp - x64 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "..\x64\Release" -# PROP BASE Intermediate_Dir "x64\Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\x64\Release" -# PROP Intermediate_Dir "x64\Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "NDEBUG" /D "WINNT" /D "WIN32" /D "_WINDOWS" /D "APR_APP" /Fo"$(INTDIR)\" /Fd"$(OUTDIR)\libaprapp-1" /FD /c -# ADD BASE RSC /l 0x409 -# ADD RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"..\x64\Release\libaprapp-1.lib" - -!ELSEIF "$(CFG)" == "libaprapp - x64 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "..\x64\Debug" -# PROP BASE Intermediate_Dir "x64\Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\x64\Debug" -# PROP Intermediate_Dir "x64\Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "_DEBUG" /D "WINNT" /D "WIN32" /D "_WINDOWS" /D "APR_APP" /Fo"$(INTDIR)\" /Fd"$(OUTDIR)\libaprapp-1" /FD /c -# ADD BASE RSC /l 0x409 -# ADD RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"..\x64\Debug\libaprapp-1.lib" - -!ENDIF - -# Begin Target - -# Name "libaprapp - Win32 Release" -# Name "libaprapp - Win32 Debug" -# Name "libaprapp - Win32 Release9x" -# Name "libaprapp - Win32 Debug9x" -# Name "libaprapp - x64 Release" -# Name "libaprapp - x64 Debug" -# Begin Source File - -SOURCE=..\misc\win32\apr_app.c -# End Source File -# Begin Source File - -SOURCE=..\misc\win32\internal.c -# End Source File -# End Target -# End Project diff --git a/libs/apr/build/libaprapp.mak b/libs/apr/build/libaprapp.mak deleted file mode 100644 index 450d41c3..00000000 --- a/libs/apr/build/libaprapp.mak +++ /dev/null @@ -1,632 +0,0 @@ -# Microsoft Developer Studio Generated NMAKE File, Based on libaprapp.dsp -!IF "$(CFG)" == "" -CFG=libaprapp - Win32 Release -!MESSAGE No configuration specified. Defaulting to libaprapp - Win32 Release. -!ENDIF - -!IF "$(CFG)" != "libaprapp - Win32 Release" && "$(CFG)" != "libaprapp - Win32 Debug" && "$(CFG)" != "libaprapp - Win32 Release9x" && "$(CFG)" != "libaprapp - Win32 Debug9x" && "$(CFG)" != "libaprapp - x64 Release" && "$(CFG)" != "libaprapp - x64 Debug" -!MESSAGE Invalid configuration "$(CFG)" specified. -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "libaprapp.mak" CFG="libaprapp - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "libaprapp - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "libaprapp - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE "libaprapp - Win32 Release9x" (based on "Win32 (x86) Static Library") -!MESSAGE "libaprapp - Win32 Debug9x" (based on "Win32 (x86) Static Library") -!MESSAGE "libaprapp - x64 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "libaprapp - x64 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE -!ERROR An invalid configuration is specified. -!ENDIF - -!IF "$(OS)" == "Windows_NT" -NULL= -!ELSE -NULL=nul -!ENDIF - -!IF "$(CFG)" == "libaprapp - Win32 Release" - -OUTDIR=.\..\Release -INTDIR=.\Release -# Begin Custom Macros -OutDir=.\..\Release -# End Custom Macros - -!IF "$(RECURSE)" == "0" - -ALL : "$(OUTDIR)\libaprapp-1.lib" - -!ELSE - -ALL : "prelibaprapp - Win32 Release" "$(OUTDIR)\libaprapp-1.lib" - -!ENDIF - -!IF "$(RECURSE)" == "1" -CLEAN :"prelibaprapp - Win32 ReleaseCLEAN" -!ELSE -CLEAN : -!ENDIF - -@erase "$(INTDIR)\apr_app.obj" - -@erase "$(INTDIR)\internal.obj" - -@erase "$(OUTDIR)\libaprapp-1.lib" - -@erase "..\Release\libaprapp-1.idb" - -@erase "..\Release\libaprapp-1.pdb" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -"$(INTDIR)" : - if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "NDEBUG" /D "WINNT" /D "WIN32" /D "_WINDOWS" /D "APR_APP" /Fo"$(INTDIR)\\" /Fd"$(OUTDIR)\libaprapp-1" /FD /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -RSC=rc.exe -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\libaprapp.bsc" -BSC32_SBRS= \ - -LIB32=link.exe -lib -LIB32_FLAGS=/nologo /out:"$(OUTDIR)\libaprapp-1.lib" -LIB32_OBJS= \ - "$(INTDIR)\apr_app.obj" \ - "$(INTDIR)\internal.obj" - -"$(OUTDIR)\libaprapp-1.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) - $(LIB32) @<< - $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) -<< - -!ELSEIF "$(CFG)" == "libaprapp - Win32 Debug" - -OUTDIR=.\..\Debug -INTDIR=.\Debug -# Begin Custom Macros -OutDir=.\..\Debug -# End Custom Macros - -!IF "$(RECURSE)" == "0" - -ALL : "$(OUTDIR)\libaprapp-1.lib" - -!ELSE - -ALL : "prelibaprapp - Win32 Debug" "$(OUTDIR)\libaprapp-1.lib" - -!ENDIF - -!IF "$(RECURSE)" == "1" -CLEAN :"prelibaprapp - Win32 DebugCLEAN" -!ELSE -CLEAN : -!ENDIF - -@erase "$(INTDIR)\apr_app.obj" - -@erase "$(INTDIR)\internal.obj" - -@erase "$(OUTDIR)\libaprapp-1.lib" - -@erase "..\Debug\libaprapp-1.idb" - -@erase "..\Debug\libaprapp-1.pdb" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -"$(INTDIR)" : - if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "_DEBUG" /D "WINNT" /D "WIN32" /D "_WINDOWS" /D "APR_APP" /Fo"$(INTDIR)\\" /Fd"$(OUTDIR)\libaprapp-1" /FD /EHsc /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -RSC=rc.exe -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\libaprapp.bsc" -BSC32_SBRS= \ - -LIB32=link.exe -lib -LIB32_FLAGS=/nologo /out:"$(OUTDIR)\libaprapp-1.lib" -LIB32_OBJS= \ - "$(INTDIR)\apr_app.obj" \ - "$(INTDIR)\internal.obj" - -"$(OUTDIR)\libaprapp-1.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) - $(LIB32) @<< - $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) -<< - -!ELSEIF "$(CFG)" == "libaprapp - Win32 Release9x" - -OUTDIR=.\..\9x\Release -INTDIR=.\9x\Release -# Begin Custom Macros -OutDir=.\..\9x\Release -# End Custom Macros - -!IF "$(RECURSE)" == "0" - -ALL : "$(OUTDIR)\libaprapp-1.lib" - -!ELSE - -ALL : "prelibaprapp - Win32 Release9x" "$(OUTDIR)\libaprapp-1.lib" - -!ENDIF - -!IF "$(RECURSE)" == "1" -CLEAN :"prelibaprapp - Win32 Release9xCLEAN" -!ELSE -CLEAN : -!ENDIF - -@erase "$(INTDIR)\apr_app.obj" - -@erase "$(INTDIR)\internal.obj" - -@erase "$(OUTDIR)\libaprapp-1.lib" - -@erase "..\9x\Release\libaprapp-1.idb" - -@erase "..\9x\Release\libaprapp-1.pdb" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -"$(INTDIR)" : - if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "APR_APP" /Fo"$(INTDIR)\\" /Fd"$(OUTDIR)\libaprapp-1" /FD /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -RSC=rc.exe -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\libaprapp.bsc" -BSC32_SBRS= \ - -LIB32=link.exe -lib -LIB32_FLAGS=/nologo /out:"$(OUTDIR)\libaprapp-1.lib" -LIB32_OBJS= \ - "$(INTDIR)\apr_app.obj" \ - "$(INTDIR)\internal.obj" - -"$(OUTDIR)\libaprapp-1.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) - $(LIB32) @<< - $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) -<< - -!ELSEIF "$(CFG)" == "libaprapp - Win32 Debug9x" - -OUTDIR=.\..\9x\Debug -INTDIR=.\9x\Debug -# Begin Custom Macros -OutDir=.\..\9x\Debug -# End Custom Macros - -!IF "$(RECURSE)" == "0" - -ALL : "$(OUTDIR)\libaprapp-1.lib" - -!ELSE - -ALL : "prelibaprapp - Win32 Debug9x" "$(OUTDIR)\libaprapp-1.lib" - -!ENDIF - -!IF "$(RECURSE)" == "1" -CLEAN :"prelibaprapp - Win32 Debug9xCLEAN" -!ELSE -CLEAN : -!ENDIF - -@erase "$(INTDIR)\apr_app.obj" - -@erase "$(INTDIR)\internal.obj" - -@erase "$(OUTDIR)\libaprapp-1.lib" - -@erase "..\9x\Debug\libaprapp-1.idb" - -@erase "..\9x\Debug\libaprapp-1.pdb" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -"$(INTDIR)" : - if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "APR_APP" /Fo"$(INTDIR)\\" /Fd"$(OUTDIR)\libaprapp-1" /FD /EHsc /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -RSC=rc.exe -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\libaprapp.bsc" -BSC32_SBRS= \ - -LIB32=link.exe -lib -LIB32_FLAGS=/nologo /out:"$(OUTDIR)\libaprapp-1.lib" -LIB32_OBJS= \ - "$(INTDIR)\apr_app.obj" \ - "$(INTDIR)\internal.obj" - -"$(OUTDIR)\libaprapp-1.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) - $(LIB32) @<< - $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) -<< - -!ELSEIF "$(CFG)" == "libaprapp - x64 Release" - -OUTDIR=.\..\x64\Release -INTDIR=.\x64\Release -# Begin Custom Macros -OutDir=.\..\x64\Release -# End Custom Macros - -!IF "$(RECURSE)" == "0" - -ALL : "$(OUTDIR)\libaprapp-1.lib" - -!ELSE - -ALL : "prelibaprapp - x64 Release" "$(OUTDIR)\libaprapp-1.lib" - -!ENDIF - -!IF "$(RECURSE)" == "1" -CLEAN :"prelibaprapp - x64 ReleaseCLEAN" -!ELSE -CLEAN : -!ENDIF - -@erase "$(INTDIR)\apr_app.obj" - -@erase "$(INTDIR)\internal.obj" - -@erase "$(OUTDIR)\libaprapp-1.lib" - -@erase "..\x64\Release\libaprapp-1.idb" - -@erase "..\x64\Release\libaprapp-1.pdb" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -"$(INTDIR)" : - if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "NDEBUG" /D "WINNT" /D "WIN32" /D "_WINDOWS" /D "APR_APP" /Fo"$(INTDIR)\\" /Fd"$(OUTDIR)\libaprapp-1" /FD /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -RSC=rc.exe -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\libaprapp.bsc" -BSC32_SBRS= \ - -LIB32=link.exe -lib -LIB32_FLAGS=/nologo /out:"$(OUTDIR)\libaprapp-1.lib" -LIB32_OBJS= \ - "$(INTDIR)\apr_app.obj" \ - "$(INTDIR)\internal.obj" - -"$(OUTDIR)\libaprapp-1.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) - $(LIB32) @<< - $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) -<< - -!ELSEIF "$(CFG)" == "libaprapp - x64 Debug" - -OUTDIR=.\..\x64\Debug -INTDIR=.\x64\Debug -# Begin Custom Macros -OutDir=.\..\x64\Debug -# End Custom Macros - -!IF "$(RECURSE)" == "0" - -ALL : "$(OUTDIR)\libaprapp-1.lib" - -!ELSE - -ALL : "prelibaprapp - x64 Debug" "$(OUTDIR)\libaprapp-1.lib" - -!ENDIF - -!IF "$(RECURSE)" == "1" -CLEAN :"prelibaprapp - x64 DebugCLEAN" -!ELSE -CLEAN : -!ENDIF - -@erase "$(INTDIR)\apr_app.obj" - -@erase "$(INTDIR)\internal.obj" - -@erase "$(OUTDIR)\libaprapp-1.lib" - -@erase "..\x64\Debug\libaprapp-1.idb" - -@erase "..\x64\Debug\libaprapp-1.pdb" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -"$(INTDIR)" : - if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "../include" /I "../include/arch" /I "../include/arch/win32" /I "../include/arch/unix" /D "_DEBUG" /D "WINNT" /D "WIN32" /D "_WINDOWS" /D "APR_APP" /Fo"$(INTDIR)\\" /Fd"$(OUTDIR)\libaprapp-1" /FD /EHsc /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -RSC=rc.exe -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\libaprapp.bsc" -BSC32_SBRS= \ - -LIB32=link.exe -lib -LIB32_FLAGS=/nologo /out:"$(OUTDIR)\libaprapp-1.lib" -LIB32_OBJS= \ - "$(INTDIR)\apr_app.obj" \ - "$(INTDIR)\internal.obj" - -"$(OUTDIR)\libaprapp-1.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) - $(LIB32) @<< - $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) -<< - -!ENDIF - - -!IF "$(NO_EXTERNAL_DEPS)" != "1" -!IF EXISTS("libaprapp.dep") -!INCLUDE "libaprapp.dep" -!ELSE -!MESSAGE Warning: cannot find "libaprapp.dep" -!ENDIF -!ENDIF - - -!IF "$(CFG)" == "libaprapp - Win32 Release" || "$(CFG)" == "libaprapp - Win32 Debug" || "$(CFG)" == "libaprapp - Win32 Release9x" || "$(CFG)" == "libaprapp - Win32 Debug9x" || "$(CFG)" == "libaprapp - x64 Release" || "$(CFG)" == "libaprapp - x64 Debug" - -!IF "$(CFG)" == "libaprapp - Win32 Release" - -"prelibaprapp - Win32 Release" : - cd "." - NMAKE /nologo /f NUL - cd "." - -"prelibaprapp - Win32 ReleaseCLEAN" : - cd "." - cd "." - -!ELSEIF "$(CFG)" == "libaprapp - Win32 Debug" - -"prelibaprapp - Win32 Debug" : - cd "." - NMAKE /nologo /f NUL - cd "." - -"prelibaprapp - Win32 DebugCLEAN" : - cd "." - cd "." - -!ELSEIF "$(CFG)" == "libaprapp - Win32 Release9x" - -"prelibaprapp - Win32 Release9x" : - cd "." - NMAKE /nologo /f NUL - cd "." - -"prelibaprapp - Win32 Release9xCLEAN" : - cd "." - cd "." - -!ELSEIF "$(CFG)" == "libaprapp - Win32 Debug9x" - -"prelibaprapp - Win32 Debug9x" : - cd "." - NMAKE /nologo /f NUL - cd "." - -"prelibaprapp - Win32 Debug9xCLEAN" : - cd "." - cd "." - -!ELSEIF "$(CFG)" == "libaprapp - x64 Release" - -"prelibaprapp - x64 Release" : - cd "." - NMAKE /nologo /f NUL - cd "." - -"prelibaprapp - x64 ReleaseCLEAN" : - cd "." - cd "." - -!ELSEIF "$(CFG)" == "libaprapp - x64 Debug" - -"prelibaprapp - x64 Debug" : - cd "." - NMAKE /nologo /f NUL - cd "." - -"prelibaprapp - x64 DebugCLEAN" : - cd "." - cd "." - -!ENDIF - -SOURCE=..\misc\win32\apr_app.c - -"$(INTDIR)\apr_app.obj" : $(SOURCE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=..\misc\win32\internal.c - -"$(INTDIR)\internal.obj" : $(SOURCE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - - -!ENDIF - diff --git a/libs/apr/build/libtool.m4 b/libs/apr/build/libtool.m4 deleted file mode 100644 index 422bd722..00000000 --- a/libs/apr/build/libtool.m4 +++ /dev/null @@ -1,7982 +0,0 @@ -# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010, 2011 Free Software -# Foundation, Inc. -# Written by Gordon Matzigkeit, 1996 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -m4_define([_LT_COPYING], [dnl -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010, 2011 Free Software -# Foundation, Inc. -# Written by Gordon Matzigkeit, 1996 -# -# This file is part of GNU Libtool. -# -# GNU Libtool 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. -# -# As a special exception to the GNU General Public License, -# if you distribute this file as part of a program or library that -# is built using GNU Libtool, you may include this file under the -# same distribution terms that you use for the rest of that program. -# -# GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy -# can be downloaded from http://www.gnu.org/licenses/gpl.html, or -# obtained by writing to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -]) - -# serial 57 LT_INIT - - -# LT_PREREQ(VERSION) -# ------------------ -# Complain and exit if this libtool version is less that VERSION. -m4_defun([LT_PREREQ], -[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, - [m4_default([$3], - [m4_fatal([Libtool version $1 or higher is required], - 63)])], - [$2])]) - - -# _LT_CHECK_BUILDDIR -# ------------------ -# Complain if the absolute build directory name contains unusual characters -m4_defun([_LT_CHECK_BUILDDIR], -[case `pwd` in - *\ * | *\ *) - AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; -esac -]) - - -# LT_INIT([OPTIONS]) -# ------------------ -AC_DEFUN([LT_INIT], -[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT -AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl -AC_BEFORE([$0], [LT_LANG])dnl -AC_BEFORE([$0], [LT_OUTPUT])dnl -AC_BEFORE([$0], [LTDL_INIT])dnl -m4_require([_LT_CHECK_BUILDDIR])dnl - -dnl Autoconf doesn't catch unexpanded LT_ macros by default: -m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl -m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl -dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 -dnl unless we require an AC_DEFUNed macro: -AC_REQUIRE([LTOPTIONS_VERSION])dnl -AC_REQUIRE([LTSUGAR_VERSION])dnl -AC_REQUIRE([LTVERSION_VERSION])dnl -AC_REQUIRE([LTOBSOLETE_VERSION])dnl -m4_require([_LT_PROG_LTMAIN])dnl - -_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) - -dnl Parse OPTIONS -_LT_SET_OPTIONS([$0], [$1]) - -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ltmain" - -# Always use our own libtool. -LIBTOOL='$(SHELL) $(apr_builddir)/libtool' -AC_SUBST(LIBTOOL)dnl - -_LT_SETUP - -# Only expand once: -m4_define([LT_INIT]) -])# LT_INIT - -# Old names: -AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) -AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_PROG_LIBTOOL], []) -dnl AC_DEFUN([AM_PROG_LIBTOOL], []) - - -# _LT_CC_BASENAME(CC) -# ------------------- -# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. -m4_defun([_LT_CC_BASENAME], -[for cc_temp in $1""; do - case $cc_temp in - compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; - distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` -]) - - -# _LT_FILEUTILS_DEFAULTS -# ---------------------- -# It is okay to use these file commands and assume they have been set -# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. -m4_defun([_LT_FILEUTILS_DEFAULTS], -[: ${CP="cp -f"} -: ${MV="mv -f"} -: ${RM="rm -f"} -])# _LT_FILEUTILS_DEFAULTS - - -# _LT_SETUP -# --------- -m4_defun([_LT_SETUP], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl -AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl - -_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl -dnl -_LT_DECL([], [host_alias], [0], [The host system])dnl -_LT_DECL([], [host], [0])dnl -_LT_DECL([], [host_os], [0])dnl -dnl -_LT_DECL([], [build_alias], [0], [The build system])dnl -_LT_DECL([], [build], [0])dnl -_LT_DECL([], [build_os], [0])dnl -dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([LT_PATH_LD])dnl -AC_REQUIRE([LT_PATH_NM])dnl -dnl -AC_REQUIRE([AC_PROG_LN_S])dnl -test -z "$LN_S" && LN_S="ln -s" -_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl -dnl -AC_REQUIRE([LT_CMD_MAX_LEN])dnl -_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl -_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl -dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_CHECK_SHELL_FEATURES])dnl -m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl -m4_require([_LT_CMD_RELOAD])dnl -m4_require([_LT_CHECK_MAGIC_METHOD])dnl -m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl -m4_require([_LT_CMD_OLD_ARCHIVE])dnl -m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl -m4_require([_LT_WITH_SYSROOT])dnl - -_LT_CONFIG_LIBTOOL_INIT([ -# See if we are running on zsh, and set the options which allow our -# commands through without removal of \ escapes INIT. -if test -n "\${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST -fi -]) -if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST -fi - -_LT_CHECK_OBJDIR - -m4_require([_LT_TAG_COMPILER])dnl - -case $host_os in -aix3*) - # AIX sometimes has problems with the GCC collect2 program. For some - # reason, if we set the COLLECT_NAMES environment variable, the problems - # vanish in a puff of smoke. - if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES - fi - ;; -esac - -# Global variables: -ofile=libtool -can_build_shared=yes - -# All known linkers require a `.a' archive for static linking (except MSVC, -# which needs '.lib'). -libext=a - -with_gnu_ld="$lt_cv_prog_gnu_ld" - -old_CC="$CC" -old_CFLAGS="$CFLAGS" - -# Set sane defaults for various variables -test -z "$CC" && CC=cc -test -z "$LTCC" && LTCC=$CC -test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS -test -z "$LD" && LD=ld -test -z "$ac_objext" && ac_objext=o - -_LT_CC_BASENAME([$compiler]) - -# Only perform the check for file, if the check method requires it -test -z "$MAGIC_CMD" && MAGIC_CMD=file -case $deplibs_check_method in -file_magic*) - if test "$file_magic_cmd" = '$MAGIC_CMD'; then - _LT_PATH_MAGIC - fi - ;; -esac - -# Use C for the default configuration in the libtool script -LT_SUPPORTED_TAG([CC]) -_LT_LANG_C_CONFIG -_LT_LANG_DEFAULT_CONFIG -_LT_CONFIG_COMMANDS -])# _LT_SETUP - - -# _LT_PREPARE_SED_QUOTE_VARS -# -------------------------- -# Define a few sed substitution that help us do robust quoting. -m4_defun([_LT_PREPARE_SED_QUOTE_VARS], -[# Backslashify metacharacters that are still active within -# double-quoted strings. -sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\([["`\\]]\)/\\\1/g' - -# Sed substitution to delay expansion of an escaped shell variable in a -# double_quote_subst'ed string. -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - -# Sed substitution to delay expansion of an escaped single quote. -delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' - -# Sed substitution to avoid accidental globbing in evaled expressions -no_glob_subst='s/\*/\\\*/g' -]) - -# _LT_PROG_LTMAIN -# --------------- -# Note that this code is called both from `configure', and `config.status' -# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, -# `config.status' has no value for ac_aux_dir unless we are using Automake, -# so we pass a copy along to make sure it has a sensible value anyway. -m4_defun([_LT_PROG_LTMAIN], -[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl -_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) -ltmain="$ac_aux_dir/ltmain.sh" -])# _LT_PROG_LTMAIN - - -## ------------------------------------- ## -## Accumulate code for creating libtool. ## -## ------------------------------------- ## - -# So that we can recreate a full libtool script including additional -# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS -# in macros and then make a single call at the end using the `libtool' -# label. - - -# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) -# ---------------------------------------- -# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. -m4_define([_LT_CONFIG_LIBTOOL_INIT], -[m4_ifval([$1], - [m4_append([_LT_OUTPUT_LIBTOOL_INIT], - [$1 -])])]) - -# Initialize. -m4_define([_LT_OUTPUT_LIBTOOL_INIT]) - - -# _LT_CONFIG_LIBTOOL([COMMANDS]) -# ------------------------------ -# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. -m4_define([_LT_CONFIG_LIBTOOL], -[m4_ifval([$1], - [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], - [$1 -])])]) - -# Initialize. -m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) - - -# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) -# ----------------------------------------------------- -m4_defun([_LT_CONFIG_SAVE_COMMANDS], -[_LT_CONFIG_LIBTOOL([$1]) -_LT_CONFIG_LIBTOOL_INIT([$2]) -]) - - -# _LT_FORMAT_COMMENT([COMMENT]) -# ----------------------------- -# Add leading comment marks to the start of each line, and a trailing -# full-stop to the whole comment if one is not present already. -m4_define([_LT_FORMAT_COMMENT], -[m4_ifval([$1], [ -m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], - [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) -)]) - - - -## ------------------------ ## -## FIXME: Eliminate VARNAME ## -## ------------------------ ## - - -# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) -# ------------------------------------------------------------------- -# CONFIGNAME is the name given to the value in the libtool script. -# VARNAME is the (base) name used in the configure script. -# VALUE may be 0, 1 or 2 for a computed quote escaped value based on -# VARNAME. Any other value will be used directly. -m4_define([_LT_DECL], -[lt_if_append_uniq([lt_decl_varnames], [$2], [, ], - [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], - [m4_ifval([$1], [$1], [$2])]) - lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) - m4_ifval([$4], - [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) - lt_dict_add_subkey([lt_decl_dict], [$2], - [tagged?], [m4_ifval([$5], [yes], [no])])]) -]) - - -# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) -# -------------------------------------------------------- -m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) - - -# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) -# ------------------------------------------------ -m4_define([lt_decl_tag_varnames], -[_lt_decl_filter([tagged?], [yes], $@)]) - - -# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) -# --------------------------------------------------------- -m4_define([_lt_decl_filter], -[m4_case([$#], - [0], [m4_fatal([$0: too few arguments: $#])], - [1], [m4_fatal([$0: too few arguments: $#: $1])], - [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], - [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], - [lt_dict_filter([lt_decl_dict], $@)])[]dnl -]) - - -# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) -# -------------------------------------------------- -m4_define([lt_decl_quote_varnames], -[_lt_decl_filter([value], [1], $@)]) - - -# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) -# --------------------------------------------------- -m4_define([lt_decl_dquote_varnames], -[_lt_decl_filter([value], [2], $@)]) - - -# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) -# --------------------------------------------------- -m4_define([lt_decl_varnames_tagged], -[m4_assert([$# <= 2])dnl -_$0(m4_quote(m4_default([$1], [[, ]])), - m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), - m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) -m4_define([_lt_decl_varnames_tagged], -[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) - - -# lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) -# ------------------------------------------------ -m4_define([lt_decl_all_varnames], -[_$0(m4_quote(m4_default([$1], [[, ]])), - m4_if([$2], [], - m4_quote(lt_decl_varnames), - m4_quote(m4_shift($@))))[]dnl -]) -m4_define([_lt_decl_all_varnames], -[lt_join($@, lt_decl_varnames_tagged([$1], - lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl -]) - - -# _LT_CONFIG_STATUS_DECLARE([VARNAME]) -# ------------------------------------ -# Quote a variable value, and forward it to `config.status' so that its -# declaration there will have the same value as in `configure'. VARNAME -# must have a single quote delimited value for this to work. -m4_define([_LT_CONFIG_STATUS_DECLARE], -[$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) - - -# _LT_CONFIG_STATUS_DECLARATIONS -# ------------------------------ -# We delimit libtool config variables with single quotes, so when -# we write them to config.status, we have to be sure to quote all -# embedded single quotes properly. In configure, this macro expands -# each variable declared with _LT_DECL (and _LT_TAGDECL) into: -# -# ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' -m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], -[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), - [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) - - -# _LT_LIBTOOL_TAGS -# ---------------- -# Output comment and list of tags supported by the script -m4_defun([_LT_LIBTOOL_TAGS], -[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl -available_tags="_LT_TAGS"dnl -]) - - -# _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) -# ----------------------------------- -# Extract the dictionary values for VARNAME (optionally with TAG) and -# expand to a commented shell variable setting: -# -# # Some comment about what VAR is for. -# visible_name=$lt_internal_name -m4_define([_LT_LIBTOOL_DECLARE], -[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], - [description])))[]dnl -m4_pushdef([_libtool_name], - m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl -m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), - [0], [_libtool_name=[$]$1], - [1], [_libtool_name=$lt_[]$1], - [2], [_libtool_name=$lt_[]$1], - [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl -m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl -]) - - -# _LT_LIBTOOL_CONFIG_VARS -# ----------------------- -# Produce commented declarations of non-tagged libtool config variables -# suitable for insertion in the LIBTOOL CONFIG section of the `libtool' -# script. Tagged libtool config variables (even for the LIBTOOL CONFIG -# section) are produced by _LT_LIBTOOL_TAG_VARS. -m4_defun([_LT_LIBTOOL_CONFIG_VARS], -[m4_foreach([_lt_var], - m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), - [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) - - -# _LT_LIBTOOL_TAG_VARS(TAG) -# ------------------------- -m4_define([_LT_LIBTOOL_TAG_VARS], -[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), - [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) - - -# _LT_TAGVAR(VARNAME, [TAGNAME]) -# ------------------------------ -m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) - - -# _LT_CONFIG_COMMANDS -# ------------------- -# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of -# variables for single and double quote escaping we saved from calls -# to _LT_DECL, we can put quote escaped variables declarations -# into `config.status', and then the shell code to quote escape them in -# for loops in `config.status'. Finally, any additional code accumulated -# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. -m4_defun([_LT_CONFIG_COMMANDS], -[AC_PROVIDE_IFELSE([LT_OUTPUT], - dnl If the libtool generation code has been placed in $CONFIG_LT, - dnl instead of duplicating it all over again into config.status, - dnl then we will have config.status run $CONFIG_LT later, so it - dnl needs to know what name is stored there: - [AC_CONFIG_COMMANDS([libtool], - [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], - dnl If the libtool generation code is destined for config.status, - dnl expand the accumulated commands and init code now: - [AC_CONFIG_COMMANDS([libtool], - [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) -])#_LT_CONFIG_COMMANDS - - -# Initialize. -m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], -[ - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -sed_quote_subst='$sed_quote_subst' -double_quote_subst='$double_quote_subst' -delay_variable_subst='$delay_variable_subst' -_LT_CONFIG_STATUS_DECLARATIONS -LTCC='$LTCC' -LTCFLAGS='$LTCFLAGS' -compiler='$compiler_DEFAULT' - -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -\$[]1 -_LTECHO_EOF' -} - -# Quote evaled strings. -for var in lt_decl_all_varnames([[ \ -]], lt_decl_quote_varnames); do - case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in - *[[\\\\\\\`\\"\\\$]]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -# Double-quote double-evaled strings. -for var in lt_decl_all_varnames([[ \ -]], lt_decl_dquote_varnames); do - case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in - *[[\\\\\\\`\\"\\\$]]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -_LT_OUTPUT_LIBTOOL_INIT -]) - -# _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) -# ------------------------------------ -# Generate a child script FILE with all initialization necessary to -# reuse the environment learned by the parent script, and make the -# file executable. If COMMENT is supplied, it is inserted after the -# `#!' sequence but before initialization text begins. After this -# macro, additional text can be appended to FILE to form the body of -# the child script. The macro ends with non-zero status if the -# file could not be fully written (such as if the disk is full). -m4_ifdef([AS_INIT_GENERATED], -[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], -[m4_defun([_LT_GENERATED_FILE_INIT], -[m4_require([AS_PREPARE])]dnl -[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl -[lt_write_fail=0 -cat >$1 <<_ASEOF || lt_write_fail=1 -#! $SHELL -# Generated by $as_me. -$2 -SHELL=\${CONFIG_SHELL-$SHELL} -export SHELL -_ASEOF -cat >>$1 <<\_ASEOF || lt_write_fail=1 -AS_SHELL_SANITIZE -_AS_PREPARE -exec AS_MESSAGE_FD>&1 -_ASEOF -test $lt_write_fail = 0 && chmod +x $1[]dnl -m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT - -# LT_OUTPUT -# --------- -# This macro allows early generation of the libtool script (before -# AC_OUTPUT is called), incase it is used in configure for compilation -# tests. -AC_DEFUN([LT_OUTPUT], -[: ${CONFIG_LT=./config.lt} -AC_MSG_NOTICE([creating $CONFIG_LT]) -_LT_GENERATED_FILE_INIT(["$CONFIG_LT"], -[# Run this file to recreate a libtool stub with the current configuration.]) - -cat >>"$CONFIG_LT" <<\_LTEOF -lt_cl_silent=false -exec AS_MESSAGE_LOG_FD>>config.log -{ - echo - AS_BOX([Running $as_me.]) -} >&AS_MESSAGE_LOG_FD - -lt_cl_help="\ -\`$as_me' creates a local libtool stub from the current configuration, -for use in further configure time tests before the real libtool is -generated. - -Usage: $[0] [[OPTIONS]] - - -h, --help print this help, then exit - -V, --version print version number, then exit - -q, --quiet do not print progress messages - -d, --debug don't remove temporary files - -Report bugs to ." - -lt_cl_version="\ -m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl -m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) -configured by $[0], generated by m4_PACKAGE_STRING. - -Copyright (C) 2011 Free Software Foundation, Inc. -This config.lt script is free software; the Free Software Foundation -gives unlimited permision to copy, distribute and modify it." - -while test $[#] != 0 -do - case $[1] in - --version | --v* | -V ) - echo "$lt_cl_version"; exit 0 ;; - --help | --h* | -h ) - echo "$lt_cl_help"; exit 0 ;; - --debug | --d* | -d ) - debug=: ;; - --quiet | --q* | --silent | --s* | -q ) - lt_cl_silent=: ;; - - -*) AC_MSG_ERROR([unrecognized option: $[1] -Try \`$[0] --help' for more information.]) ;; - - *) AC_MSG_ERROR([unrecognized argument: $[1] -Try \`$[0] --help' for more information.]) ;; - esac - shift -done - -if $lt_cl_silent; then - exec AS_MESSAGE_FD>/dev/null -fi -_LTEOF - -cat >>"$CONFIG_LT" <<_LTEOF -_LT_OUTPUT_LIBTOOL_COMMANDS_INIT -_LTEOF - -cat >>"$CONFIG_LT" <<\_LTEOF -AC_MSG_NOTICE([creating $ofile]) -_LT_OUTPUT_LIBTOOL_COMMANDS -AS_EXIT(0) -_LTEOF -chmod +x "$CONFIG_LT" - -# configure is writing to config.log, but config.lt does its own redirection, -# appending to config.log, which fails on DOS, as config.log is still kept -# open by configure. Here we exec the FD to /dev/null, effectively closing -# config.log, so it can be properly (re)opened and appended to by config.lt. -lt_cl_success=: -test "$silent" = yes && - lt_config_lt_args="$lt_config_lt_args --quiet" -exec AS_MESSAGE_LOG_FD>/dev/null -$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false -exec AS_MESSAGE_LOG_FD>>config.log -$lt_cl_success || AS_EXIT(1) -])# LT_OUTPUT - - -# _LT_CONFIG(TAG) -# --------------- -# If TAG is the built-in tag, create an initial libtool script with a -# default configuration from the untagged config vars. Otherwise add code -# to config.status for appending the configuration named by TAG from the -# matching tagged config vars. -m4_defun([_LT_CONFIG], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -_LT_CONFIG_SAVE_COMMANDS([ - m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl - m4_if(_LT_TAG, [C], [ - # See if we are running on zsh, and set the options which allow our - # commands through without removal of \ escapes. - if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST - fi - - cfgfile="${ofile}T" - trap "$RM \"$cfgfile\"; exit 1" 1 2 15 - $RM "$cfgfile" - - cat <<_LT_EOF >> "$cfgfile" -#! $SHELL - -# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. -# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# NOTE: Changes made to this file will be lost: look at ltmain.sh. -# -_LT_COPYING -_LT_LIBTOOL_TAGS - -# ### BEGIN LIBTOOL CONFIG -_LT_LIBTOOL_CONFIG_VARS -_LT_LIBTOOL_TAG_VARS -# ### END LIBTOOL CONFIG - -_LT_EOF - - case $host_os in - aix3*) - cat <<\_LT_EOF >> "$cfgfile" -# AIX sometimes has problems with the GCC collect2 program. For some -# reason, if we set the COLLECT_NAMES environment variable, the problems -# vanish in a puff of smoke. -if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES -fi -_LT_EOF - ;; - esac - - _LT_PROG_LTMAIN - - # We use sed instead of cat because bash on DJGPP gets confused if - # if finds mixed CR/LF and LF-only lines. Since sed operates in - # text mode, it properly converts lines to CR/LF. This bash problem - # is reportedly fixed, but why not run on old versions too? - sed '$q' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - _LT_PROG_REPLACE_SHELLFNS - - mv -f "$cfgfile" "$ofile" || - (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") - chmod +x "$ofile" -], -[cat <<_LT_EOF >> "$ofile" - -dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded -dnl in a comment (ie after a #). -# ### BEGIN LIBTOOL TAG CONFIG: $1 -_LT_LIBTOOL_TAG_VARS(_LT_TAG) -# ### END LIBTOOL TAG CONFIG: $1 -_LT_EOF -])dnl /m4_if -], -[m4_if([$1], [], [ - PACKAGE='$PACKAGE' - VERSION='$VERSION' - TIMESTAMP='$TIMESTAMP' - RM='$RM' - ofile='$ofile'], []) -])dnl /_LT_CONFIG_SAVE_COMMANDS -])# _LT_CONFIG - - -# LT_SUPPORTED_TAG(TAG) -# --------------------- -# Trace this macro to discover what tags are supported by the libtool -# --tag option, using: -# autoconf --trace 'LT_SUPPORTED_TAG:$1' -AC_DEFUN([LT_SUPPORTED_TAG], []) - - -# C support is built-in for now -m4_define([_LT_LANG_C_enabled], []) -m4_define([_LT_TAGS], []) - - -# LT_LANG(LANG) -# ------------- -# Enable libtool support for the given language if not already enabled. -AC_DEFUN([LT_LANG], -[AC_BEFORE([$0], [LT_OUTPUT])dnl -m4_case([$1], - [C], [_LT_LANG(C)], - [C++], [_LT_LANG(CXX)], - [Go], [_LT_LANG(GO)], - [Java], [_LT_LANG(GCJ)], - [Fortran 77], [_LT_LANG(F77)], - [Fortran], [_LT_LANG(FC)], - [Windows Resource], [_LT_LANG(RC)], - [m4_ifdef([_LT_LANG_]$1[_CONFIG], - [_LT_LANG($1)], - [m4_fatal([$0: unsupported language: "$1"])])])dnl -])# LT_LANG - - -# _LT_LANG(LANGNAME) -# ------------------ -m4_defun([_LT_LANG], -[m4_ifdef([_LT_LANG_]$1[_enabled], [], - [LT_SUPPORTED_TAG([$1])dnl - m4_append([_LT_TAGS], [$1 ])dnl - m4_define([_LT_LANG_]$1[_enabled], [])dnl - _LT_LANG_$1_CONFIG($1)])dnl -])# _LT_LANG - - -m4_ifndef([AC_PROG_GO], [ -############################################################ -# NOTE: This macro has been submitted for inclusion into # -# GNU Autoconf as AC_PROG_GO. When it is available in # -# a released version of Autoconf we should remove this # -# macro and use it instead. # -############################################################ -m4_defun([AC_PROG_GO], -[AC_LANG_PUSH(Go)dnl -AC_ARG_VAR([GOC], [Go compiler command])dnl -AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl -_AC_ARG_VAR_LDFLAGS()dnl -AC_CHECK_TOOL(GOC, gccgo) -if test -z "$GOC"; then - if test -n "$ac_tool_prefix"; then - AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) - fi -fi -if test -z "$GOC"; then - AC_CHECK_PROG(GOC, gccgo, gccgo, false) -fi -])#m4_defun -])#m4_ifndef - - -# _LT_LANG_DEFAULT_CONFIG -# ----------------------- -m4_defun([_LT_LANG_DEFAULT_CONFIG], -[AC_PROVIDE_IFELSE([AC_PROG_CXX], - [LT_LANG(CXX)], - [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) - -AC_PROVIDE_IFELSE([AC_PROG_F77], - [LT_LANG(F77)], - [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) - -AC_PROVIDE_IFELSE([AC_PROG_FC], - [LT_LANG(FC)], - [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) - -dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal -dnl pulling things in needlessly. -AC_PROVIDE_IFELSE([AC_PROG_GCJ], - [LT_LANG(GCJ)], - [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], - [LT_LANG(GCJ)], - [AC_PROVIDE_IFELSE([LT_PROG_GCJ], - [LT_LANG(GCJ)], - [m4_ifdef([AC_PROG_GCJ], - [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) - m4_ifdef([A][M_PROG_GCJ], - [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) - m4_ifdef([LT_PROG_GCJ], - [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) - -AC_PROVIDE_IFELSE([AC_PROG_GO], - [LT_LANG(GO)], - [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) - -AC_PROVIDE_IFELSE([LT_PROG_RC], - [LT_LANG(RC)], - [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) -])# _LT_LANG_DEFAULT_CONFIG - -# Obsolete macros: -AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) -AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) -AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) -AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) -AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_CXX], []) -dnl AC_DEFUN([AC_LIBTOOL_F77], []) -dnl AC_DEFUN([AC_LIBTOOL_FC], []) -dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) -dnl AC_DEFUN([AC_LIBTOOL_RC], []) - - -# _LT_TAG_COMPILER -# ---------------- -m4_defun([_LT_TAG_COMPILER], -[AC_REQUIRE([AC_PROG_CC])dnl - -_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl -_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl -_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl -_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC -])# _LT_TAG_COMPILER - - -# _LT_COMPILER_BOILERPLATE -# ------------------------ -# Check for compiler boilerplate output or warnings with -# the simple compiler test code. -m4_defun([_LT_COMPILER_BOILERPLATE], -[m4_require([_LT_DECL_SED])dnl -ac_outfile=conftest.$ac_objext -echo "$lt_simple_compile_test_code" >conftest.$ac_ext -eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_compiler_boilerplate=`cat conftest.err` -$RM conftest* -])# _LT_COMPILER_BOILERPLATE - - -# _LT_LINKER_BOILERPLATE -# ---------------------- -# Check for linker boilerplate output or warnings with -# the simple link test code. -m4_defun([_LT_LINKER_BOILERPLATE], -[m4_require([_LT_DECL_SED])dnl -ac_outfile=conftest.$ac_objext -echo "$lt_simple_link_test_code" >conftest.$ac_ext -eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_linker_boilerplate=`cat conftest.err` -$RM -r conftest* -])# _LT_LINKER_BOILERPLATE - -# _LT_REQUIRED_DARWIN_CHECKS -# ------------------------- -m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ - case $host_os in - rhapsody* | darwin*) - AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) - AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) - AC_CHECK_TOOL([LIPO], [lipo], [:]) - AC_CHECK_TOOL([OTOOL], [otool], [:]) - AC_CHECK_TOOL([OTOOL64], [otool64], [:]) - _LT_DECL([], [DSYMUTIL], [1], - [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) - _LT_DECL([], [NMEDIT], [1], - [Tool to change global to local symbols on Mac OS X]) - _LT_DECL([], [LIPO], [1], - [Tool to manipulate fat objects and archives on Mac OS X]) - _LT_DECL([], [OTOOL], [1], - [ldd/readelf like tool for Mach-O binaries on Mac OS X]) - _LT_DECL([], [OTOOL64], [1], - [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) - - AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], - [lt_cv_apple_cc_single_mod=no - if test -z "${LT_MULTI_MODULE}"; then - # By default we will add the -single_module flag. You can override - # by either setting the environment variable LT_MULTI_MODULE - # non-empty at configure time, or by adding -multi_module to the - # link flags. - rm -rf libconftest.dylib* - echo "int foo(void){return 1;}" > conftest.c - echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ --dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD - $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ - -dynamiclib -Wl,-single_module conftest.c 2>conftest.err - _lt_result=$? - # If there is a non-empty error log, and "single_module" - # appears in it, assume the flag caused a linker warning - if test -s conftest.err && $GREP single_module conftest.err; then - cat conftest.err >&AS_MESSAGE_LOG_FD - # Otherwise, if the output was created with a 0 exit code from - # the compiler, it worked. - elif test -f libconftest.dylib && test $_lt_result -eq 0; then - lt_cv_apple_cc_single_mod=yes - else - cat conftest.err >&AS_MESSAGE_LOG_FD - fi - rm -rf libconftest.dylib* - rm -f conftest.* - fi]) - - AC_CACHE_CHECK([for -exported_symbols_list linker flag], - [lt_cv_ld_exported_symbols_list], - [lt_cv_ld_exported_symbols_list=no - save_LDFLAGS=$LDFLAGS - echo "_main" > conftest.sym - LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" - AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], - [lt_cv_ld_exported_symbols_list=yes], - [lt_cv_ld_exported_symbols_list=no]) - LDFLAGS="$save_LDFLAGS" - ]) - - AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], - [lt_cv_ld_force_load=no - cat > conftest.c << _LT_EOF -int forced_loaded() { return 2;} -_LT_EOF - echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD - $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD - echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD - $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD - echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD - $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD - cat > conftest.c << _LT_EOF -int main() { return 0;} -_LT_EOF - echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD - $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err - _lt_result=$? - if test -s conftest.err && $GREP force_load conftest.err; then - cat conftest.err >&AS_MESSAGE_LOG_FD - elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then - lt_cv_ld_force_load=yes - else - cat conftest.err >&AS_MESSAGE_LOG_FD - fi - rm -f conftest.err libconftest.a conftest conftest.c - rm -rf conftest.dSYM - ]) - case $host_os in - rhapsody* | darwin1.[[012]]) - _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; - darwin1.*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - darwin*) # darwin 5.x on - # if running on 10.5 or later, the deployment target defaults - # to the OS version, if on x86, and 10.4, the deployment - # target defaults to 10.4. Don't you love it? - case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in - 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - 10.[[012]]*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - 10.*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - esac - ;; - esac - if test "$lt_cv_apple_cc_single_mod" = "yes"; then - _lt_dar_single_mod='$single_module' - fi - if test "$lt_cv_ld_exported_symbols_list" = "yes"; then - _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' - else - _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' - fi - if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then - _lt_dsymutil='~$DSYMUTIL $lib || :' - else - _lt_dsymutil= - fi - ;; - esac -]) - - -# _LT_DARWIN_LINKER_FEATURES([TAG]) -# --------------------------------- -# Checks for linker and compiler features on darwin -m4_defun([_LT_DARWIN_LINKER_FEATURES], -[ - m4_require([_LT_REQUIRED_DARWIN_CHECKS]) - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_automatic, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - if test "$lt_cv_ld_force_load" = "yes"; then - _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' - m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], - [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) - else - _LT_TAGVAR(whole_archive_flag_spec, $1)='' - fi - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" - case $cc_basename in - ifort*) _lt_dar_can_shared=yes ;; - *) _lt_dar_can_shared=$GCC ;; - esac - if test "$_lt_dar_can_shared" = "yes"; then - output_verbose_link_cmd=func_echo_all - _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" - _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" - _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" - _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" - m4_if([$1], [CXX], -[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then - _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" - _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" - fi -],[]) - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi -]) - -# _LT_SYS_MODULE_PATH_AIX([TAGNAME]) -# ---------------------------------- -# Links a minimal program and checks the executable -# for the system default hardcoded library path. In most cases, -# this is /usr/lib:/lib, but when the MPI compilers are used -# the location of the communication and MPI libs are included too. -# If we don't find anything, use the default library path according -# to the aix ld manual. -# Store the results from the different compilers for each TAGNAME. -# Allow to override them for all tags through lt_cv_aix_libpath. -m4_defun([_LT_SYS_MODULE_PATH_AIX], -[m4_require([_LT_DECL_SED])dnl -if test "${lt_cv_aix_libpath+set}" = set; then - aix_libpath=$lt_cv_aix_libpath -else - AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], - [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ - lt_aix_libpath_sed='[ - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\([^ ]*\) *$/\1/ - p - } - }]' - _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - # Check for a 64-bit object if we didn't find anything. - if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then - _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - fi],[]) - if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then - _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib" - fi - ]) - aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) -fi -])# _LT_SYS_MODULE_PATH_AIX - - -# _LT_SHELL_INIT(ARG) -# ------------------- -m4_define([_LT_SHELL_INIT], -[m4_divert_text([M4SH-INIT], [$1 -])])# _LT_SHELL_INIT - - - -# _LT_PROG_ECHO_BACKSLASH -# ----------------------- -# Find how we can fake an echo command that does not interpret backslash. -# In particular, with Autoconf 2.60 or later we add some code to the start -# of the generated configure script which will find a shell with a builtin -# printf (which we can use as an echo command). -m4_defun([_LT_PROG_ECHO_BACKSLASH], -[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO -ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO - -AC_MSG_CHECKING([how to print strings]) -# Test print first, because it will be a builtin if present. -if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ - test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then - ECHO='print -r --' -elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then - ECHO='printf %s\n' -else - # Use this function as a fallback that always works. - func_fallback_echo () - { - eval 'cat <<_LTECHO_EOF -$[]1 -_LTECHO_EOF' - } - ECHO='func_fallback_echo' -fi - -# func_echo_all arg... -# Invoke $ECHO with all args, space-separated. -func_echo_all () -{ - $ECHO "$*" -} - -case "$ECHO" in - printf*) AC_MSG_RESULT([printf]) ;; - print*) AC_MSG_RESULT([print -r]) ;; - *) AC_MSG_RESULT([cat]) ;; -esac - -m4_ifdef([_AS_DETECT_SUGGESTED], -[_AS_DETECT_SUGGESTED([ - test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( - ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' - ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO - ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO - PATH=/empty FPATH=/empty; export PATH FPATH - test "X`printf %s $ECHO`" = "X$ECHO" \ - || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) - -_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) -_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) -])# _LT_PROG_ECHO_BACKSLASH - - -# _LT_WITH_SYSROOT -# ---------------- -AC_DEFUN([_LT_WITH_SYSROOT], -[AC_MSG_CHECKING([for sysroot]) -AC_ARG_WITH([sysroot], -[ --with-sysroot[=DIR] Search for dependent libraries within DIR - (or the compiler's sysroot if not specified).], -[], [with_sysroot=no]) - -dnl lt_sysroot will always be passed unquoted. We quote it here -dnl in case the user passed a directory name. -lt_sysroot= -case ${with_sysroot} in #( - yes) - if test "$GCC" = yes; then - lt_sysroot=`$CC --print-sysroot 2>/dev/null` - fi - ;; #( - /*) - lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` - ;; #( - no|'') - ;; #( - *) - AC_MSG_RESULT([${with_sysroot}]) - AC_MSG_ERROR([The sysroot must be an absolute path.]) - ;; -esac - - AC_MSG_RESULT([${lt_sysroot:-no}]) -_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl -[dependent libraries, and in which our libraries should be installed.])]) - -# _LT_ENABLE_LOCK -# --------------- -m4_defun([_LT_ENABLE_LOCK], -[AC_ARG_ENABLE([libtool-lock], - [AS_HELP_STRING([--disable-libtool-lock], - [avoid locking (might break parallel builds)])]) -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes - -# Some flags need to be propagated to the compiler or linker for good -# libtool support. -case $host in -ia64-*-hpux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.$ac_objext` in - *ELF-32*) - HPUX_IA64_MODE="32" - ;; - *ELF-64*) - HPUX_IA64_MODE="64" - ;; - esac - fi - rm -rf conftest* - ;; -*-*-irix6*) - # Find out which ABI we are using. - echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - if test "$lt_cv_prog_gnu_ld" = yes; then - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -melf32bsmip" - ;; - *N32*) - LD="${LD-ld} -melf32bmipn32" - ;; - *64-bit*) - LD="${LD-ld} -melf64bmip" - ;; - esac - else - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -32" - ;; - *N32*) - LD="${LD-ld} -n32" - ;; - *64-bit*) - LD="${LD-ld} -64" - ;; - esac - fi - fi - rm -rf conftest* - ;; - -x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ -s390*-*linux*|s390*-*tpf*|sparc*-*linux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in - *32-bit*) - case $host in - x86_64-*kfreebsd*-gnu) - LD="${LD-ld} -m elf_i386_fbsd" - ;; - x86_64-*linux*) - LD="${LD-ld} -m elf_i386" - ;; - ppc64-*linux*|powerpc64-*linux*) - LD="${LD-ld} -m elf32ppclinux" - ;; - s390x-*linux*) - LD="${LD-ld} -m elf_s390" - ;; - sparc64-*linux*) - LD="${LD-ld} -m elf32_sparc" - ;; - esac - ;; - *64-bit*) - case $host in - x86_64-*kfreebsd*-gnu) - LD="${LD-ld} -m elf_x86_64_fbsd" - ;; - x86_64-*linux*) - LD="${LD-ld} -m elf_x86_64" - ;; - ppc*-*linux*|powerpc*-*linux*) - LD="${LD-ld} -m elf64ppc" - ;; - s390*-*linux*|s390*-*tpf*) - LD="${LD-ld} -m elf64_s390" - ;; - sparc*-*linux*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; - -*-*-sco3.2v5*) - # On SCO OpenServer 5, we need -belf to get full-featured binaries. - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -belf" - AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, - [AC_LANG_PUSH(C) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) - AC_LANG_POP]) - if test x"$lt_cv_cc_needs_belf" != x"yes"; then - # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf - CFLAGS="$SAVE_CFLAGS" - fi - ;; -*-*solaris*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in - *64-bit*) - case $lt_cv_prog_gnu_ld in - yes*) - case $host in - i?86-*-solaris*) - LD="${LD-ld} -m elf_x86_64" - ;; - sparc*-*-solaris*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - # GNU ld 2.21 introduced _sol2 emulations. Use them if available. - if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then - LD="${LD-ld}_sol2" - fi - ;; - *) - if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then - LD="${LD-ld} -64" - fi - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; -esac - -need_locks="$enable_libtool_lock" -])# _LT_ENABLE_LOCK - - -# _LT_PROG_AR -# ----------- -m4_defun([_LT_PROG_AR], -[AC_CHECK_TOOLS(AR, [ar], false) -: ${AR=ar} -: ${AR_FLAGS=cru} -_LT_DECL([], [AR], [1], [The archiver]) -_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) - -AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], - [lt_cv_ar_at_file=no - AC_COMPILE_IFELSE([AC_LANG_PROGRAM], - [echo conftest.$ac_objext > conftest.lst - lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' - AC_TRY_EVAL([lt_ar_try]) - if test "$ac_status" -eq 0; then - # Ensure the archiver fails upon bogus file names. - rm -f conftest.$ac_objext libconftest.a - AC_TRY_EVAL([lt_ar_try]) - if test "$ac_status" -ne 0; then - lt_cv_ar_at_file=@ - fi - fi - rm -f conftest.* libconftest.a - ]) - ]) - -if test "x$lt_cv_ar_at_file" = xno; then - archiver_list_spec= -else - archiver_list_spec=$lt_cv_ar_at_file -fi -_LT_DECL([], [archiver_list_spec], [1], - [How to feed a file listing to the archiver]) -])# _LT_PROG_AR - - -# _LT_CMD_OLD_ARCHIVE -# ------------------- -m4_defun([_LT_CMD_OLD_ARCHIVE], -[_LT_PROG_AR - -AC_CHECK_TOOL(STRIP, strip, :) -test -z "$STRIP" && STRIP=: -_LT_DECL([], [STRIP], [1], [A symbol stripping program]) - -AC_CHECK_TOOL(RANLIB, ranlib, :) -test -z "$RANLIB" && RANLIB=: -_LT_DECL([], [RANLIB], [1], - [Commands used to install an old-style archive]) - -# Determine commands to create old-style static archives. -old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= - -if test -n "$RANLIB"; then - case $host_os in - openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" - ;; - *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" - ;; - esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" -fi - -case $host_os in - darwin*) - lock_old_archive_extraction=yes ;; - *) - lock_old_archive_extraction=no ;; -esac -_LT_DECL([], [old_postinstall_cmds], [2]) -_LT_DECL([], [old_postuninstall_cmds], [2]) -_LT_TAGDECL([], [old_archive_cmds], [2], - [Commands used to build an old-style archive]) -_LT_DECL([], [lock_old_archive_extraction], [0], - [Whether to use a lock for old archive extraction]) -])# _LT_CMD_OLD_ARCHIVE - - -# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) -# ---------------------------------------------------------------- -# Check whether the given compiler option works -AC_DEFUN([_LT_COMPILER_OPTION], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_SED])dnl -AC_CACHE_CHECK([$1], [$2], - [$2=no - m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$3" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - $2=yes - fi - fi - $RM conftest* -]) - -if test x"[$]$2" = xyes; then - m4_if([$5], , :, [$5]) -else - m4_if([$6], , :, [$6]) -fi -])# _LT_COMPILER_OPTION - -# Old name: -AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) - - -# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [ACTION-SUCCESS], [ACTION-FAILURE]) -# ---------------------------------------------------- -# Check whether the given linker option works -AC_DEFUN([_LT_LINKER_OPTION], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_SED])dnl -AC_CACHE_CHECK([$1], [$2], - [$2=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $3" - echo "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The linker can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&AS_MESSAGE_LOG_FD - $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - $2=yes - fi - else - $2=yes - fi - fi - $RM -r conftest* - LDFLAGS="$save_LDFLAGS" -]) - -if test x"[$]$2" = xyes; then - m4_if([$4], , :, [$4]) -else - m4_if([$5], , :, [$5]) -fi -])# _LT_LINKER_OPTION - -# Old name: -AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) - - -# LT_CMD_MAX_LEN -#--------------- -AC_DEFUN([LT_CMD_MAX_LEN], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -# find the maximum length of command line arguments -AC_MSG_CHECKING([the maximum length of command line arguments]) -AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl - i=0 - teststring="ABCD" - - case $build_os in - msdosdjgpp*) - # On DJGPP, this test can blow up pretty badly due to problems in libc - # (any single argument exceeding 2000 bytes causes a buffer overrun - # during glob expansion). Even if it were fixed, the result of this - # check would be larger than it should be. - lt_cv_sys_max_cmd_len=12288; # 12K is about right - ;; - - gnu*) - # Under GNU Hurd, this test is not required because there is - # no limit to the length of command line arguments. - # Libtool will interpret -1 as no limit whatsoever - lt_cv_sys_max_cmd_len=-1; - ;; - - cygwin* | mingw* | cegcc*) - # On Win9x/ME, this test blows up -- it succeeds, but takes - # about 5 minutes as the teststring grows exponentially. - # Worse, since 9x/ME are not pre-emptively multitasking, - # you end up with a "frozen" computer, even though with patience - # the test eventually succeeds (with a max line length of 256k). - # Instead, let's just punt: use the minimum linelength reported by - # all of the supported platforms: 8192 (on NT/2K/XP). - lt_cv_sys_max_cmd_len=8192; - ;; - - mint*) - # On MiNT this can take a long time and run out of memory. - lt_cv_sys_max_cmd_len=8192; - ;; - - amigaos*) - # On AmigaOS with pdksh, this test takes hours, literally. - # So we just punt and use a minimum line length of 8192. - lt_cv_sys_max_cmd_len=8192; - ;; - - netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) - # This has been around since 386BSD, at least. Likely further. - if test -x /sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` - elif test -x /usr/sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` - else - lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs - fi - # And add a safety zone - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - ;; - - interix*) - # We know the value 262144 and hardcode it with a safety zone (like BSD) - lt_cv_sys_max_cmd_len=196608 - ;; - - os2*) - # The test takes a long time on OS/2. - lt_cv_sys_max_cmd_len=8192 - ;; - - osf*) - # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure - # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not - # nice to cause kernel panics so lets avoid the loop below. - # First set a reasonable default. - lt_cv_sys_max_cmd_len=16384 - # - if test -x /sbin/sysconfig; then - case `/sbin/sysconfig -q proc exec_disable_arg_limit` in - *1*) lt_cv_sys_max_cmd_len=-1 ;; - esac - fi - ;; - sco3.2v5*) - lt_cv_sys_max_cmd_len=102400 - ;; - sysv5* | sco5v6* | sysv4.2uw2*) - kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` - if test -n "$kargmax"; then - lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` - else - lt_cv_sys_max_cmd_len=32768 - fi - ;; - *) - lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` - if test -n "$lt_cv_sys_max_cmd_len"; then - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - else - # Make teststring a little bigger before we do anything with it. - # a 1K string should be a reasonable start. - for i in 1 2 3 4 5 6 7 8 ; do - teststring=$teststring$teststring - done - SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} - # If test is not a shell built-in, we'll probably end up computing a - # maximum length that is only half of the actual maximum length, but - # we can't tell. - while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ - = "X$teststring$teststring"; } >/dev/null 2>&1 && - test $i != 17 # 1/2 MB should be enough - do - i=`expr $i + 1` - teststring=$teststring$teststring - done - # Only check the string length outside the loop. - lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` - teststring= - # Add a significant safety factor because C++ compilers can tack on - # massive amounts of additional arguments before passing them to the - # linker. It appears as though 1/2 is a usable value. - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` - fi - ;; - esac -]) -if test -n $lt_cv_sys_max_cmd_len ; then - AC_MSG_RESULT($lt_cv_sys_max_cmd_len) -else - AC_MSG_RESULT(none) -fi -max_cmd_len=$lt_cv_sys_max_cmd_len -_LT_DECL([], [max_cmd_len], [0], - [What is the maximum length of a command?]) -])# LT_CMD_MAX_LEN - -# Old name: -AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) - - -# _LT_HEADER_DLFCN -# ---------------- -m4_defun([_LT_HEADER_DLFCN], -[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl -])# _LT_HEADER_DLFCN - - -# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, -# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) -# ---------------------------------------------------------------- -m4_defun([_LT_TRY_DLOPEN_SELF], -[m4_require([_LT_HEADER_DLFCN])dnl -if test "$cross_compiling" = yes; then : - [$4] -else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<_LT_EOF -[#line $LINENO "configure" -#include "confdefs.h" - -#if HAVE_DLFCN_H -#include -#endif - -#include - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -/* When -fvisbility=hidden is used, assume the code has been annotated - correspondingly for the symbols needed. */ -#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) -int fnord () __attribute__((visibility("default"))); -#endif - -int fnord () { return 42; } -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else - { - if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - else puts (dlerror ()); - } - /* dlclose (self); */ - } - else - puts (dlerror ()); - - return status; -}] -_LT_EOF - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) $1 ;; - x$lt_dlneed_uscore) $2 ;; - x$lt_dlunknown|x*) $3 ;; - esac - else : - # compilation failed - $3 - fi -fi -rm -fr conftest* -])# _LT_TRY_DLOPEN_SELF - - -# LT_SYS_DLOPEN_SELF -# ------------------ -AC_DEFUN([LT_SYS_DLOPEN_SELF], -[m4_require([_LT_HEADER_DLFCN])dnl -if test "x$enable_dlopen" != xyes; then - enable_dlopen=unknown - enable_dlopen_self=unknown - enable_dlopen_self_static=unknown -else - lt_cv_dlopen=no - lt_cv_dlopen_libs= - - case $host_os in - beos*) - lt_cv_dlopen="load_add_on" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ;; - - mingw* | pw32* | cegcc*) - lt_cv_dlopen="LoadLibrary" - lt_cv_dlopen_libs= - ;; - - cygwin*) - lt_cv_dlopen="dlopen" - lt_cv_dlopen_libs= - ;; - - darwin*) - # if libdl is installed we need to link against it - AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ - lt_cv_dlopen="dyld" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ]) - ;; - - *) - AC_CHECK_FUNC([shl_load], - [lt_cv_dlopen="shl_load"], - [AC_CHECK_LIB([dld], [shl_load], - [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], - [AC_CHECK_FUNC([dlopen], - [lt_cv_dlopen="dlopen"], - [AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], - [AC_CHECK_LIB([svld], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], - [AC_CHECK_LIB([dld], [dld_link], - [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) - ]) - ]) - ]) - ]) - ]) - ;; - esac - - if test "x$lt_cv_dlopen" != xno; then - enable_dlopen=yes - else - enable_dlopen=no - fi - - case $lt_cv_dlopen in - dlopen) - save_CPPFLAGS="$CPPFLAGS" - test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" - - save_LDFLAGS="$LDFLAGS" - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - - save_LIBS="$LIBS" - LIBS="$lt_cv_dlopen_libs $LIBS" - - AC_CACHE_CHECK([whether a program can dlopen itself], - lt_cv_dlopen_self, [dnl - _LT_TRY_DLOPEN_SELF( - lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, - lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) - ]) - - if test "x$lt_cv_dlopen_self" = xyes; then - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" - AC_CACHE_CHECK([whether a statically linked program can dlopen itself], - lt_cv_dlopen_self_static, [dnl - _LT_TRY_DLOPEN_SELF( - lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, - lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) - ]) - fi - - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - LIBS="$save_LIBS" - ;; - esac - - case $lt_cv_dlopen_self in - yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; - *) enable_dlopen_self=unknown ;; - esac - - case $lt_cv_dlopen_self_static in - yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; - *) enable_dlopen_self_static=unknown ;; - esac -fi -_LT_DECL([dlopen_support], [enable_dlopen], [0], - [Whether dlopen is supported]) -_LT_DECL([dlopen_self], [enable_dlopen_self], [0], - [Whether dlopen of programs is supported]) -_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], - [Whether dlopen of statically linked programs is supported]) -])# LT_SYS_DLOPEN_SELF - -# Old name: -AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) - - -# _LT_COMPILER_C_O([TAGNAME]) -# --------------------------- -# Check to see if options -c and -o are simultaneously supported by compiler. -# This macro does not hard code the compiler like AC_PROG_CC_C_O. -m4_defun([_LT_COMPILER_C_O], -[m4_require([_LT_DECL_SED])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_TAG_COMPILER])dnl -AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], - [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], - [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no - $RM -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes - fi - fi - chmod u+w . 2>&AS_MESSAGE_LOG_FD - $RM conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files - $RM out/* && rmdir out - cd .. - $RM -r conftest - $RM conftest* -]) -_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], - [Does compiler simultaneously support -c and -o options?]) -])# _LT_COMPILER_C_O - - -# _LT_COMPILER_FILE_LOCKS([TAGNAME]) -# ---------------------------------- -# Check to see if we can do hard links to lock some files if needed -m4_defun([_LT_COMPILER_FILE_LOCKS], -[m4_require([_LT_ENABLE_LOCK])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -_LT_COMPILER_C_O([$1]) - -hard_links="nottested" -if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - AC_MSG_CHECKING([if we can lock with hard links]) - hard_links=yes - $RM conftest* - ln conftest.a conftest.b 2>/dev/null && hard_links=no - touch conftest.a - ln conftest.a conftest.b 2>&5 || hard_links=no - ln conftest.a conftest.b 2>/dev/null && hard_links=no - AC_MSG_RESULT([$hard_links]) - if test "$hard_links" = no; then - AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) - need_locks=warn - fi -else - need_locks=no -fi -_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) -])# _LT_COMPILER_FILE_LOCKS - - -# _LT_CHECK_OBJDIR -# ---------------- -m4_defun([_LT_CHECK_OBJDIR], -[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], -[rm -f .libs 2>/dev/null -mkdir .libs 2>/dev/null -if test -d .libs; then - lt_cv_objdir=.libs -else - # MS-DOS does not allow filenames that begin with a dot. - lt_cv_objdir=_libs -fi -rmdir .libs 2>/dev/null]) -objdir=$lt_cv_objdir -_LT_DECL([], [objdir], [0], - [The name of the directory that contains temporary libtool files])dnl -m4_pattern_allow([LT_OBJDIR])dnl -AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", - [Define to the sub-directory in which libtool stores uninstalled libraries.]) -])# _LT_CHECK_OBJDIR - - -# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) -# -------------------------------------- -# Check hardcoding attributes. -m4_defun([_LT_LINKER_HARDCODE_LIBPATH], -[AC_MSG_CHECKING([how to hardcode library paths into programs]) -_LT_TAGVAR(hardcode_action, $1)= -if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || - test -n "$_LT_TAGVAR(runpath_var, $1)" || - test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then - - # We can hardcode non-existent directories. - if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && - test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then - # Linking always hardcodes the temporary library directory. - _LT_TAGVAR(hardcode_action, $1)=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - _LT_TAGVAR(hardcode_action, $1)=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - _LT_TAGVAR(hardcode_action, $1)=unsupported -fi -AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) - -if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || - test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then - # Fast installation is not supported - enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then - # Fast installation is not necessary - enable_fast_install=needless -fi -_LT_TAGDECL([], [hardcode_action], [0], - [How to hardcode a shared library path into an executable]) -])# _LT_LINKER_HARDCODE_LIBPATH - - -# _LT_CMD_STRIPLIB -# ---------------- -m4_defun([_LT_CMD_STRIPLIB], -[m4_require([_LT_DECL_EGREP]) -striplib= -old_striplib= -AC_MSG_CHECKING([whether stripping libraries is possible]) -if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" - test -z "$striplib" && striplib="$STRIP --strip-unneeded" - AC_MSG_RESULT([yes]) -else -# FIXME - insert some real tests, host_os isn't really good enough - case $host_os in - darwin*) - if test -n "$STRIP" ; then - striplib="$STRIP -x" - old_striplib="$STRIP -S" - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - fi - ;; - *) - AC_MSG_RESULT([no]) - ;; - esac -fi -_LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) -_LT_DECL([], [striplib], [1]) -])# _LT_CMD_STRIPLIB - - -# _LT_SYS_DYNAMIC_LINKER([TAG]) -# ----------------------------- -# PORTME Fill in your ld.so characteristics -m4_defun([_LT_SYS_DYNAMIC_LINKER], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_OBJDUMP])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_CHECK_SHELL_FEATURES])dnl -AC_MSG_CHECKING([dynamic linker characteristics]) -m4_if([$1], - [], [ -if test "$GCC" = yes; then - case $host_os in - darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; - *) lt_awk_arg="/^libraries:/" ;; - esac - case $host_os in - mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;; - *) lt_sed_strip_eq="s,=/,/,g" ;; - esac - lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` - case $lt_search_path_spec in - *\;*) - # if the path contains ";" then we assume it to be the separator - # otherwise default to the standard path separator (i.e. ":") - it is - # assumed that no part of a normal pathname contains ";" but that should - # okay in the real world where ";" in dirpaths is itself problematic. - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` - ;; - *) - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` - ;; - esac - # Ok, now we have the path, separated by spaces, we can step through it - # and add multilib dir if necessary. - lt_tmp_lt_search_path_spec= - lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` - for lt_sys_path in $lt_search_path_spec; do - if test -d "$lt_sys_path/$lt_multi_os_dir"; then - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" - else - test -d "$lt_sys_path" && \ - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" - fi - done - lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' -BEGIN {RS=" "; FS="/|\n";} { - lt_foo=""; - lt_count=0; - for (lt_i = NF; lt_i > 0; lt_i--) { - if ($lt_i != "" && $lt_i != ".") { - if ($lt_i == "..") { - lt_count++; - } else { - if (lt_count == 0) { - lt_foo="/" $lt_i lt_foo; - } else { - lt_count--; - } - } - } - } - if (lt_foo != "") { lt_freq[[lt_foo]]++; } - if (lt_freq[[lt_foo]] == 1) { print lt_foo; } -}'` - # AWK program above erroneously prepends '/' to C:/dos/paths - # for these hosts. - case $host_os in - mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ - $SED 's,/\([[A-Za-z]]:\),\1,g'` ;; - esac - sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` -else - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -fi]) -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext_cmds=".so" -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -shlibpath_overrides_runpath=unknown -version_type=none -dynamic_linker="$host_os ld.so" -sys_lib_dlsearch_path_spec="/lib /usr/lib" -need_lib_prefix=unknown -hardcode_into_libs=no - -# when you set need_version to no, make sure it does not cause -set_version -# flags to be left without arguments -need_version=unknown - -case $host_os in -aix3*) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}${shared_ext}$major' - ;; - -aix[[4-9]]*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - hardcode_into_libs=yes - if test "$host_cpu" = ia64; then - # AIX 5 supports IA64 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - else - # With GCC up to 2.95.x, collect2 would create an import file - # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in - # development snapshots of GCC prior to 3.0. - case $host_os in - aix4 | aix4.[[01]] | aix4.[[01]].*) - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then - : - else - can_build_shared=no - fi - ;; - esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct - # soname into executable. Probably we can add versioning support to - # collect2, so additional links can be useful in future. - if test "$aix_use_runtimelinking" = yes; then - # If using run time linking (on AIX 4.2 or later) use lib.so - # instead of lib.a to let people know that these are not - # typical AIX shared libraries. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - else - # We preserve .a as extension for shared libraries through AIX4.2 - # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}${shared_ext}$major' - fi - shlibpath_var=LIBPATH - fi - ;; - -amigaos*) - case $host_cpu in - powerpc) - # Since July 2007 AmigaOS4 officially supports .so libraries. - # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - ;; - m68k) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' - ;; - esac - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi[[45]]*) - version_type=linux # correct to gnu/linux during the next big refactor - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" - sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" - # the default ld.so.conf also contains /usr/contrib/lib and - # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow - # libtool to hard-code these into programs - ;; - -cygwin* | mingw* | pw32* | cegcc*) - version_type=windows - shrext_cmds=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$cc_basename in - yes,*) - # gcc - library_names_spec='$libname.dll.a' - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname~ - chmod a+x \$dldir/$dlname~ - if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then - eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; - fi' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - - case $host_os in - cygwin*) - # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' -m4_if([$1], [],[ - sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) - ;; - mingw* | cegcc*) - # MinGW DLLs use traditional 'lib' prefix - soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - ;; - pw32*) - # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - ;; - esac - dynamic_linker='Win32 ld.exe' - ;; - - *,cl*) - # Native MSVC - libname_spec='$name' - soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - library_names_spec='${libname}.dll.lib' - - case $build_os in - mingw*) - sys_lib_search_path_spec= - lt_save_ifs=$IFS - IFS=';' - for lt_path in $LIB - do - IFS=$lt_save_ifs - # Let DOS variable expansion print the short 8.3 style file name. - lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` - sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" - done - IFS=$lt_save_ifs - # Convert to MSYS style. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` - ;; - cygwin*) - # Convert to unix form, then to dos form, then back to unix form - # but this time dos style (no spaces!) so that the unix form looks - # like /cygdrive/c/PROGRA~1:/cygdr... - sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` - sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` - sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - ;; - *) - sys_lib_search_path_spec="$LIB" - if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then - # It is most probably a Windows format PATH. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - # FIXME: find the short name or the path components, as spaces are - # common. (e.g. "Program Files" -> "PROGRA~1") - ;; - esac - - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - dynamic_linker='Win32 link.exe' - ;; - - *) - # Assume MSVC wrapper - library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' - dynamic_linker='Win32 ld.exe' - ;; - esac - # FIXME: first we should search . and the directory the executable is in - shlibpath_var=PATH - ;; - -darwin* | rhapsody*) - dynamic_linker="$host_os dyld" - version_type=darwin - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' - soname_spec='${libname}${release}${major}$shared_ext' - shlibpath_overrides_runpath=yes - shlibpath_var=DYLD_LIBRARY_PATH - shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' -m4_if([$1], [],[ - sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) - sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' - ;; - -dgux*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -freebsd* | dragonfly*) - # DragonFly does not have aout. When/if they implement a new - # versioning mechanism, adjust this. - if test -x /usr/bin/objformat; then - objformat=`/usr/bin/objformat` - else - case $host_os in - freebsd[[23]].*) objformat=aout ;; - *) objformat=elf ;; - esac - fi - version_type=freebsd-$objformat - case $version_type in - freebsd-elf*) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - need_version=no - need_lib_prefix=no - ;; - freebsd-*) - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' - need_version=yes - ;; - esac - shlibpath_var=LD_LIBRARY_PATH - case $host_os in - freebsd2.*) - shlibpath_overrides_runpath=yes - ;; - freebsd3.[[01]]* | freebsdelf3.[[01]]*) - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ - freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - *) # from 4.6 on, and DragonFly - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - esac - ;; - -gnu*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -haiku*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - dynamic_linker="$host_os runtime_loader" - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LIBRARY_PATH - shlibpath_overrides_runpath=yes - sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' - hardcode_into_libs=yes - ;; - -hpux9* | hpux10* | hpux11*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - version_type=sunos - need_lib_prefix=no - need_version=no - case $host_cpu in - ia64*) - shrext_cmds='.so' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.so" - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - if test "X$HPUX_IA64_MODE" = X32; then - sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" - else - sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" - fi - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - hppa*64*) - shrext_cmds='.sl' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.sl" - shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - *) - shrext_cmds='.sl' - dynamic_linker="$host_os dld.sl" - shlibpath_var=SHLIB_PATH - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - ;; - esac - # HP-UX runs *really* slowly unless shared libraries are mode 555, ... - postinstall_cmds='chmod 555 $lib' - # or fails outright, so override atomically: - install_override_mode=555 - ;; - -interix[[3-9]]*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -irix5* | irix6* | nonstopux*) - case $host_os in - nonstopux*) version_type=nonstopux ;; - *) - if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux # correct to gnu/linux during the next big refactor - else - version_type=irix - fi ;; - esac - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' - case $host_os in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in # libtool.m4 will add one of these switches to LD - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") - libsuff= shlibsuff= libmagic=32-bit;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") - libsuff=32 shlibsuff=N32 libmagic=N32;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") - libsuff=64 shlibsuff=64 libmagic=64-bit;; - *) libsuff= shlibsuff= libmagic=never-match;; - esac - ;; - esac - shlibpath_var=LD_LIBRARY${shlibsuff}_PATH - shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" - hardcode_into_libs=yes - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux*oldld* | linux*aout* | linux*coff*) - dynamic_linker=no - ;; - -# This must be glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - - # Some binutils ld are patched to set DT_RUNPATH - AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], - [lt_cv_shlibpath_overrides_runpath=no - save_LDFLAGS=$LDFLAGS - save_libdir=$libdir - eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ - LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" - AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], - [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], - [lt_cv_shlibpath_overrides_runpath=yes])]) - LDFLAGS=$save_LDFLAGS - libdir=$save_libdir - ]) - shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath - - # This implies no fast_install, which is unacceptable. - # Some rework will be needed to allow for fast_install - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on - # powerpc, because MkLinux only supported shared libraries with the - # GNU dynamic linker. Since this was broken with cross compilers, - # most powerpc-linux boxes support dynamic linking these days and - # people can always --disable-shared, the test was removed, and we - # assume the GNU/Linux dynamic linker is in use. - dynamic_linker='GNU/Linux ld.so' - ;; - -netbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - dynamic_linker='NetBSD (a.out) ld.so' - else - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='NetBSD ld.elf_so' - fi - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - -newsos6) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -*nto* | *qnx*) - version_type=qnx - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='ldqnx.so' - ;; - -openbsd*) - version_type=sunos - sys_lib_dlsearch_path_spec="/usr/lib" - need_lib_prefix=no - # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. - case $host_os in - openbsd3.3 | openbsd3.3.*) need_version=yes ;; - *) need_version=no ;; - esac - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case $host_os in - openbsd2.[[89]] | openbsd2.[[89]].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi - ;; - -os2*) - libname_spec='$name' - shrext_cmds=".dll" - need_lib_prefix=no - library_names_spec='$libname${shared_ext} $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - -osf3* | osf4* | osf5*) - version_type=osf - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" - ;; - -rdos*) - dynamic_linker=no - ;; - -solaris*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - # ldd complains unless libraries are executable - postinstall_cmds='chmod +x $lib' - ;; - -sunos4*) - version_type=sunos - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - fi - need_version=yes - ;; - -sysv4 | sysv4.3*) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - case $host_vendor in - sni) - shlibpath_overrides_runpath=no - need_lib_prefix=no - runpath_var=LD_RUN_PATH - ;; - siemens) - need_lib_prefix=no - ;; - motorola) - need_lib_prefix=no - need_version=no - shlibpath_overrides_runpath=no - sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' - ;; - esac - ;; - -sysv4*MP*) - if test -d /usr/nec ;then - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' - soname_spec='$libname${shared_ext}.$major' - shlibpath_var=LD_LIBRARY_PATH - fi - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - version_type=freebsd-elf - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - if test "$with_gnu_ld" = yes; then - sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' - else - sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' - case $host_os in - sco3.2v5*) - sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" - ;; - esac - fi - sys_lib_dlsearch_path_spec='/usr/lib' - ;; - -tpf*) - # TPF is a cross-target only. Preferred cross-host = GNU/Linux. - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -uts4*) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -*) - dynamic_linker=no - ;; -esac -AC_MSG_RESULT([$dynamic_linker]) -test "$dynamic_linker" = no && can_build_shared=no - -variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then - variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -fi - -if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then - sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" -fi -if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then - sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" -fi - -_LT_DECL([], [variables_saved_for_relink], [1], - [Variables whose values should be saved in libtool wrapper scripts and - restored at link time]) -_LT_DECL([], [need_lib_prefix], [0], - [Do we need the "lib" prefix for modules?]) -_LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) -_LT_DECL([], [version_type], [0], [Library versioning type]) -_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) -_LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) -_LT_DECL([], [shlibpath_overrides_runpath], [0], - [Is shlibpath searched before the hard-coded library search path?]) -_LT_DECL([], [libname_spec], [1], [Format of library name prefix]) -_LT_DECL([], [library_names_spec], [1], - [[List of archive names. First name is the real one, the rest are links. - The last name is the one that the linker finds with -lNAME]]) -_LT_DECL([], [soname_spec], [1], - [[The coded name of the library, if different from the real name]]) -_LT_DECL([], [install_override_mode], [1], - [Permission mode override for installation of shared libraries]) -_LT_DECL([], [postinstall_cmds], [2], - [Command to use after installation of a shared archive]) -_LT_DECL([], [postuninstall_cmds], [2], - [Command to use after uninstallation of a shared archive]) -_LT_DECL([], [finish_cmds], [2], - [Commands used to finish a libtool library installation in a directory]) -_LT_DECL([], [finish_eval], [1], - [[As "finish_cmds", except a single script fragment to be evaled but - not shown]]) -_LT_DECL([], [hardcode_into_libs], [0], - [Whether we should hardcode library paths into libraries]) -_LT_DECL([], [sys_lib_search_path_spec], [2], - [Compile-time system search path for libraries]) -_LT_DECL([], [sys_lib_dlsearch_path_spec], [2], - [Run-time system search path for libraries]) -])# _LT_SYS_DYNAMIC_LINKER - - -# _LT_PATH_TOOL_PREFIX(TOOL) -# -------------------------- -# find a file program which can recognize shared library -AC_DEFUN([_LT_PATH_TOOL_PREFIX], -[m4_require([_LT_DECL_EGREP])dnl -AC_MSG_CHECKING([for $1]) -AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, -[case $MAGIC_CMD in -[[\\/*] | ?:[\\/]*]) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. - ;; -*) - lt_save_MAGIC_CMD="$MAGIC_CMD" - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR -dnl $ac_dummy forces splitting on constant user-supplied paths. -dnl POSIX.2 word splitting is done only on the output of word expansions, -dnl not every word. This closes a longstanding sh security hole. - ac_dummy="m4_if([$2], , $PATH, [$2])" - for ac_dir in $ac_dummy; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$1; then - lt_cv_path_MAGIC_CMD="$ac_dir/$1" - if test -n "$file_magic_test_file"; then - case $deplibs_check_method in - "file_magic "*) - file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" - if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - $EGREP "$file_magic_regex" > /dev/null; then - : - else - cat <<_LT_EOF 1>&2 - -*** Warning: the command libtool uses to detect shared libraries, -*** $file_magic_cmd, produces output that libtool cannot recognize. -*** The result is that libtool may fail to recognize shared libraries -*** as such. This will affect the creation of libtool libraries that -*** depend on shared libraries, but programs linked with such libtool -*** libraries will work regardless of this problem. Nevertheless, you -*** may want to report the problem to your system manager and/or to -*** bug-libtool@gnu.org - -_LT_EOF - fi ;; - esac - fi - break - fi - done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" - ;; -esac]) -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -if test -n "$MAGIC_CMD"; then - AC_MSG_RESULT($MAGIC_CMD) -else - AC_MSG_RESULT(no) -fi -_LT_DECL([], [MAGIC_CMD], [0], - [Used to examine libraries when file_magic_cmd begins with "file"])dnl -])# _LT_PATH_TOOL_PREFIX - -# Old name: -AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) - - -# _LT_PATH_MAGIC -# -------------- -# find a file program which can recognize a shared library -m4_defun([_LT_PATH_MAGIC], -[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) -if test -z "$lt_cv_path_MAGIC_CMD"; then - if test -n "$ac_tool_prefix"; then - _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) - else - MAGIC_CMD=: - fi -fi -])# _LT_PATH_MAGIC - - -# LT_PATH_LD -# ---------- -# find the pathname to the GNU or non-GNU linker -AC_DEFUN([LT_PATH_LD], -[AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_PROG_ECHO_BACKSLASH])dnl - -AC_ARG_WITH([gnu-ld], - [AS_HELP_STRING([--with-gnu-ld], - [assume the C compiler uses GNU ld @<:@default=no@:>@])], - [test "$withval" = no || with_gnu_ld=yes], - [with_gnu_ld=no])dnl - -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - AC_MSG_CHECKING([for ld used by $CC]) - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [[\\/]]* | ?:[[\\/]]*) - re_direlt='/[[^/]][[^/]]*/\.\./' - # Canonicalize the pathname of ld - ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` - while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do - ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - AC_MSG_CHECKING([for GNU ld]) -else - AC_MSG_CHECKING([for non-GNU ld]) -fi -AC_CACHE_VAL(lt_cv_path_LD, -[if test -z "$LD"; then - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then - lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' - lt_cv_file_magic_cmd='func_win32_libid' - else - # Keep this pattern in sync with the one in func_win32_libid. - lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' - lt_cv_file_magic_cmd='$OBJDUMP -f' - fi - ;; - -cegcc*) - # use the weaker test based on 'objdump'. See mingw*. - lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' - lt_cv_file_magic_cmd='$OBJDUMP -f' - ;; - -darwin* | rhapsody*) - lt_cv_deplibs_check_method=pass_all - ;; - -freebsd* | dragonfly*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then - case $host_cpu in - i*86 ) - # Not sure whether the presence of OpenBSD here was a mistake. - # Let's accept both of them until this is cleared up. - lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` - ;; - esac - else - lt_cv_deplibs_check_method=pass_all - fi - ;; - -gnu*) - lt_cv_deplibs_check_method=pass_all - ;; - -haiku*) - lt_cv_deplibs_check_method=pass_all - ;; - -hpux10.20* | hpux11*) - lt_cv_file_magic_cmd=/usr/bin/file - case $host_cpu in - ia64*) - lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' - lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so - ;; - hppa*64*) - [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] - lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl - ;; - *) - lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' - lt_cv_file_magic_test_file=/usr/lib/libc.sl - ;; - esac - ;; - -interix[[3-9]]*) - # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' - ;; - -irix5* | irix6* | nonstopux*) - case $LD in - *-32|*"-32 ") libmagic=32-bit;; - *-n32|*"-n32 ") libmagic=N32;; - *-64|*"-64 ") libmagic=64-bit;; - *) libmagic=never-match;; - esac - lt_cv_deplibs_check_method=pass_all - ;; - -# This must be glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu) - lt_cv_deplibs_check_method=pass_all - ;; - -netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' - fi - ;; - -newos6*) - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=/usr/lib/libnls.so - ;; - -*nto* | *qnx*) - lt_cv_deplibs_check_method=pass_all - ;; - -openbsd*) - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' - fi - ;; - -osf3* | osf4* | osf5*) - lt_cv_deplibs_check_method=pass_all - ;; - -rdos*) - lt_cv_deplibs_check_method=pass_all - ;; - -solaris*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv4 | sysv4.3*) - case $host_vendor in - motorola) - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` - ;; - ncr) - lt_cv_deplibs_check_method=pass_all - ;; - sequent) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' - ;; - sni) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" - lt_cv_file_magic_test_file=/lib/libc.so - ;; - siemens) - lt_cv_deplibs_check_method=pass_all - ;; - pc) - lt_cv_deplibs_check_method=pass_all - ;; - esac - ;; - -tpf*) - lt_cv_deplibs_check_method=pass_all - ;; -esac -]) - -file_magic_glob= -want_nocaseglob=no -if test "$build" = "$host"; then - case $host_os in - mingw* | pw32*) - if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then - want_nocaseglob=yes - else - file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` - fi - ;; - esac -fi - -file_magic_cmd=$lt_cv_file_magic_cmd -deplibs_check_method=$lt_cv_deplibs_check_method -test -z "$deplibs_check_method" && deplibs_check_method=unknown - -_LT_DECL([], [deplibs_check_method], [1], - [Method to check whether dependent libraries are shared objects]) -_LT_DECL([], [file_magic_cmd], [1], - [Command to use when deplibs_check_method = "file_magic"]) -_LT_DECL([], [file_magic_glob], [1], - [How to find potential files when deplibs_check_method = "file_magic"]) -_LT_DECL([], [want_nocaseglob], [1], - [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) -])# _LT_CHECK_MAGIC_METHOD - - -# LT_PATH_NM -# ---------- -# find the pathname to a BSD- or MS-compatible name lister -AC_DEFUN([LT_PATH_NM], -[AC_REQUIRE([AC_PROG_CC])dnl -AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, -[if test -n "$NM"; then - # Let the user override the test. - lt_cv_path_NM="$NM" -else - lt_nm_to_check="${ac_tool_prefix}nm" - if test -n "$ac_tool_prefix" && test "$build" = "$host"; then - lt_nm_to_check="$lt_nm_to_check nm" - fi - for lt_tmp_nm in $lt_nm_to_check; do - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - tmp_nm="$ac_dir/$lt_tmp_nm" - if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then - # Check to see if the nm accepts a BSD-compat flag. - # Adding the `sed 1q' prevents false positives on HP-UX, which says: - # nm: unknown option "B" ignored - # Tru64's nm complains that /dev/null is an invalid object file - case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in - */dev/null* | *'Invalid file or object type'*) - lt_cv_path_NM="$tmp_nm -B" - break - ;; - *) - case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in - */dev/null*) - lt_cv_path_NM="$tmp_nm -p" - break - ;; - *) - lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but - continue # so that we can try to find one that supports BSD flags - ;; - esac - ;; - esac - fi - done - IFS="$lt_save_ifs" - done - : ${lt_cv_path_NM=no} -fi]) -if test "$lt_cv_path_NM" != "no"; then - NM="$lt_cv_path_NM" -else - # Didn't find any BSD compatible name lister, look for dumpbin. - if test -n "$DUMPBIN"; then : - # Let the user override the test. - else - AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) - case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in - *COFF*) - DUMPBIN="$DUMPBIN -symbols" - ;; - *) - DUMPBIN=: - ;; - esac - fi - AC_SUBST([DUMPBIN]) - if test "$DUMPBIN" != ":"; then - NM="$DUMPBIN" - fi -fi -test -z "$NM" && NM=nm -AC_SUBST([NM]) -_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl - -AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], - [lt_cv_nm_interface="BSD nm" - echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$ac_compile" 2>conftest.err) - cat conftest.err >&AS_MESSAGE_LOG_FD - (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) - (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) - cat conftest.err >&AS_MESSAGE_LOG_FD - (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) - cat conftest.out >&AS_MESSAGE_LOG_FD - if $GREP 'External.*some_variable' conftest.out > /dev/null; then - lt_cv_nm_interface="MS dumpbin" - fi - rm -f conftest*]) -])# LT_PATH_NM - -# Old names: -AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) -AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AM_PROG_NM], []) -dnl AC_DEFUN([AC_PROG_NM], []) - -# _LT_CHECK_SHAREDLIB_FROM_LINKLIB -# -------------------------------- -# how to determine the name of the shared library -# associated with a specific link library. -# -- PORTME fill in with the dynamic library characteristics -m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], -[m4_require([_LT_DECL_EGREP]) -m4_require([_LT_DECL_OBJDUMP]) -m4_require([_LT_DECL_DLLTOOL]) -AC_CACHE_CHECK([how to associate runtime and link libraries], -lt_cv_sharedlib_from_linklib_cmd, -[lt_cv_sharedlib_from_linklib_cmd='unknown' - -case $host_os in -cygwin* | mingw* | pw32* | cegcc*) - # two different shell functions defined in ltmain.sh - # decide which to use based on capabilities of $DLLTOOL - case `$DLLTOOL --help 2>&1` in - *--identify-strict*) - lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib - ;; - *) - lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback - ;; - esac - ;; -*) - # fallback: assume linklib IS sharedlib - lt_cv_sharedlib_from_linklib_cmd="$ECHO" - ;; -esac -]) -sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd -test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO - -_LT_DECL([], [sharedlib_from_linklib_cmd], [1], - [Command to associate shared and link libraries]) -])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB - - -# _LT_PATH_MANIFEST_TOOL -# ---------------------- -# locate the manifest tool -m4_defun([_LT_PATH_MANIFEST_TOOL], -[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) -test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt -AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], - [lt_cv_path_mainfest_tool=no - echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD - $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out - cat conftest.err >&AS_MESSAGE_LOG_FD - if $GREP 'Manifest Tool' conftest.out > /dev/null; then - lt_cv_path_mainfest_tool=yes - fi - rm -f conftest*]) -if test "x$lt_cv_path_mainfest_tool" != xyes; then - MANIFEST_TOOL=: -fi -_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl -])# _LT_PATH_MANIFEST_TOOL - - -# LT_LIB_M -# -------- -# check for math library -AC_DEFUN([LT_LIB_M], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -LIBM= -case $host in -*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) - # These system don't have libm, or don't need it - ;; -*-ncr-sysv4.3*) - AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") - AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") - ;; -*) - AC_CHECK_LIB(m, cos, LIBM="-lm") - ;; -esac -AC_SUBST([LIBM]) -])# LT_LIB_M - -# Old name: -AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_CHECK_LIBM], []) - - -# _LT_COMPILER_NO_RTTI([TAGNAME]) -# ------------------------------- -m4_defun([_LT_COMPILER_NO_RTTI], -[m4_require([_LT_TAG_COMPILER])dnl - -_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= - -if test "$GCC" = yes; then - case $cc_basename in - nvcc*) - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; - *) - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; - esac - - _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], - lt_cv_prog_compiler_rtti_exceptions, - [-fno-rtti -fno-exceptions], [], - [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) -fi -_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], - [Compiler flag to turn off builtin functions]) -])# _LT_COMPILER_NO_RTTI - - -# _LT_CMD_GLOBAL_SYMBOLS -# ---------------------- -m4_defun([_LT_CMD_GLOBAL_SYMBOLS], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([AC_PROG_AWK])dnl -AC_REQUIRE([LT_PATH_NM])dnl -AC_REQUIRE([LT_PATH_LD])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_TAG_COMPILER])dnl - -# Check for command to grab the raw symbol name followed by C symbol from nm. -AC_MSG_CHECKING([command to parse $NM output from $compiler object]) -AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], -[ -# These are sane defaults that work on at least a few old systems. -# [They come from Ultrix. What could be older than Ultrix?!! ;)] - -# Character class describing NM global symbol codes. -symcode='[[BCDEGRST]]' - -# Regexp to match symbols that can be accessed directly from C. -sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' - -# Define system-specific variables. -case $host_os in -aix*) - symcode='[[BCDT]]' - ;; -cygwin* | mingw* | pw32* | cegcc*) - symcode='[[ABCDGISTW]]' - ;; -hpux*) - if test "$host_cpu" = ia64; then - symcode='[[ABCDEGRST]]' - fi - ;; -irix* | nonstopux*) - symcode='[[BCDEGRST]]' - ;; -osf*) - symcode='[[BCDEGQRST]]' - ;; -solaris*) - symcode='[[BDRT]]' - ;; -sco3.2v5*) - symcode='[[DT]]' - ;; -sysv4.2uw2*) - symcode='[[DT]]' - ;; -sysv5* | sco5v6* | unixware* | OpenUNIX*) - symcode='[[ABDT]]' - ;; -sysv4) - symcode='[[DFNSTU]]' - ;; -esac - -# If we're using GNU nm, then use its standard symbol codes. -case `$NM -V 2>&1` in -*GNU* | *'with BFD'*) - symcode='[[ABCDGIRSTW]]' ;; -esac - -# Transform an extracted symbol line into a proper C declaration. -# Some systems (esp. on ia64) link data and code symbols differently, -# so use this general approach. -lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" - -# Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" - -# Handle CRLF in mingw tool chain -opt_cr= -case $build_os in -mingw*) - opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp - ;; -esac - -# Try without a prefix underscore, then with it. -for ac_symprfx in "" "_"; do - - # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. - symxfrm="\\1 $ac_symprfx\\2 \\2" - - # Write the raw and C identifiers. - if test "$lt_cv_nm_interface" = "MS dumpbin"; then - # Fake it for dumpbin and say T for any non-static function - # and D for any global variable. - # Also find C++ and __fastcall symbols from MSVC++, - # which start with @ or ?. - lt_cv_sys_global_symbol_pipe="$AWK ['"\ -" {last_section=section; section=\$ 3};"\ -" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ -" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ -" \$ 0!~/External *\|/{next};"\ -" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ -" {if(hide[section]) next};"\ -" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ -" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ -" s[1]~/^[@?]/{print s[1], s[1]; next};"\ -" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ -" ' prfx=^$ac_symprfx]" - else - lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" - fi - lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" - - # Check to see that the pipe works correctly. - pipe_works=no - - rm -f conftest* - cat > conftest.$ac_ext <<_LT_EOF -#ifdef __cplusplus -extern "C" { -#endif -char nm_test_var; -void nm_test_func(void); -void nm_test_func(void){} -#ifdef __cplusplus -} -#endif -int main(){nm_test_var='a';nm_test_func();return(0);} -_LT_EOF - - if AC_TRY_EVAL(ac_compile); then - # Now try to grab the symbols. - nlist=conftest.nm - if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then - # Try sorting and uniquifying the output. - if sort "$nlist" | uniq > "$nlist"T; then - mv -f "$nlist"T "$nlist" - else - rm -f "$nlist"T - fi - - # Make sure that we snagged all the symbols we need. - if $GREP ' nm_test_var$' "$nlist" >/dev/null; then - if $GREP ' nm_test_func$' "$nlist" >/dev/null; then - cat <<_LT_EOF > conftest.$ac_ext -/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ -#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) -/* DATA imports from DLLs on WIN32 con't be const, because runtime - relocations are performed -- see ld's documentation on pseudo-relocs. */ -# define LT@&t@_DLSYM_CONST -#elif defined(__osf__) -/* This system does not cope well with relocations in const data. */ -# define LT@&t@_DLSYM_CONST -#else -# define LT@&t@_DLSYM_CONST const -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -_LT_EOF - # Now generate the symbol file. - eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' - - cat <<_LT_EOF >> conftest.$ac_ext - -/* The mapping between symbol names and symbols. */ -LT@&t@_DLSYM_CONST struct { - const char *name; - void *address; -} -lt__PROGRAM__LTX_preloaded_symbols[[]] = -{ - { "@PROGRAM@", (void *) 0 }, -_LT_EOF - $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext - cat <<\_LT_EOF >> conftest.$ac_ext - {0, (void *) 0} -}; - -/* This works around a problem in FreeBSD linker */ -#ifdef FREEBSD_WORKAROUND -static const void *lt_preloaded_setup() { - return lt__PROGRAM__LTX_preloaded_symbols; -} -#endif - -#ifdef __cplusplus -} -#endif -_LT_EOF - # Now try linking the two files. - mv conftest.$ac_objext conftstm.$ac_objext - lt_globsym_save_LIBS=$LIBS - lt_globsym_save_CFLAGS=$CFLAGS - LIBS="conftstm.$ac_objext" - CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then - pipe_works=yes - fi - LIBS=$lt_globsym_save_LIBS - CFLAGS=$lt_globsym_save_CFLAGS - else - echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD - fi - else - echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD - fi - else - echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD - fi - else - echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD - cat conftest.$ac_ext >&5 - fi - rm -rf conftest* conftst* - - # Do not use the global_symbol_pipe unless it works. - if test "$pipe_works" = yes; then - break - else - lt_cv_sys_global_symbol_pipe= - fi -done -]) -if test -z "$lt_cv_sys_global_symbol_pipe"; then - lt_cv_sys_global_symbol_to_cdecl= -fi -if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then - AC_MSG_RESULT(failed) -else - AC_MSG_RESULT(ok) -fi - -# Response file support. -if test "$lt_cv_nm_interface" = "MS dumpbin"; then - nm_file_list_spec='@' -elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then - nm_file_list_spec='@' -fi - -_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], - [Take the output of nm and produce a listing of raw symbols and C names]) -_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], - [Transform the output of nm in a proper C declaration]) -_LT_DECL([global_symbol_to_c_name_address], - [lt_cv_sys_global_symbol_to_c_name_address], [1], - [Transform the output of nm in a C name address pair]) -_LT_DECL([global_symbol_to_c_name_address_lib_prefix], - [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], - [Transform the output of nm in a C name address pair when lib prefix is needed]) -_LT_DECL([], [nm_file_list_spec], [1], - [Specify filename containing input files for $NM]) -]) # _LT_CMD_GLOBAL_SYMBOLS - - -# _LT_COMPILER_PIC([TAGNAME]) -# --------------------------- -m4_defun([_LT_COMPILER_PIC], -[m4_require([_LT_TAG_COMPILER])dnl -_LT_TAGVAR(lt_prog_compiler_wl, $1)= -_LT_TAGVAR(lt_prog_compiler_pic, $1)= -_LT_TAGVAR(lt_prog_compiler_static, $1)= - -m4_if([$1], [CXX], [ - # C++ specific cases for pic, static, wl, etc. - if test "$GXX" = yes; then - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - m68k) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' - ;; - esac - ;; - - beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - mingw* | cygwin* | os2* | pw32* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - # Although the cygwin gcc ignores -fPIC, still need this for old-style - # (--disable-auto-import) libraries - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - ;; - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' - ;; - *djgpp*) - # DJGPP does not support shared libraries at all - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - ;; - haiku*) - # PIC is the default for Haiku. - # The "-static" flag exists, but is broken. - _LT_TAGVAR(lt_prog_compiler_static, $1)= - ;; - interix[[3-9]]*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - sysv4*MP*) - if test -d /usr/nec; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic - fi - ;; - hpux*) - # PIC is the default for 64-bit PA HP-UX, but not for 32-bit - # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag - # sets the default TLS model and affects inlining. - case $host_cpu in - hppa*64*) - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - ;; - *qnx* | *nto*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - else - case $host_os in - aix[[4-9]]*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - else - _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' - fi - ;; - chorus*) - case $cc_basename in - cxch68*) - # Green Hills C++ Compiler - # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" - ;; - esac - ;; - mingw* | cygwin* | os2* | pw32* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - ;; - dgux*) - case $cc_basename in - ec++*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - ;; - ghcx*) - # Green Hills C++ Compiler - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - *) - ;; - esac - ;; - freebsd* | dragonfly*) - # FreeBSD uses GNU C++ - ;; - hpux9* | hpux10* | hpux11*) - case $cc_basename in - CC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - if test "$host_cpu" != ia64; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - fi - ;; - aCC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - ;; - esac - ;; - *) - ;; - esac - ;; - interix*) - # This is c89, which is MS Visual C++ (no shared libs) - # Anyone wants to do a port? - ;; - irix5* | irix6* | nonstopux*) - case $cc_basename in - CC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - # CC pic flag -KPIC is the default. - ;; - *) - ;; - esac - ;; - linux* | k*bsd*-gnu | kopensolaris*-gnu) - case $cc_basename in - KCC*) - # KAI C++ Compiler - _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - ecpc* ) - # old Intel C++ for x86_64 which still supported -KPIC. - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - icpc* ) - # Intel C++, used to be incompatible with GCC. - # ICC 10 doesn't accept -KPIC any more. - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - pgCC* | pgcpp*) - # Portland Group C++ compiler - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - cxx*) - # Compaq C++ - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) - # IBM XL 8.0, 9.0 on PPC and BlueGene - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - ;; - esac - ;; - esac - ;; - lynxos*) - ;; - m88k*) - ;; - mvs*) - case $cc_basename in - cxx*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' - ;; - *) - ;; - esac - ;; - netbsd*) - ;; - *qnx* | *nto*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - osf3* | osf4* | osf5*) - case $cc_basename in - KCC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' - ;; - RCC*) - # Rational C++ 2.4.1 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - cxx*) - # Digital/Compaq C++ - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - *) - ;; - esac - ;; - psos*) - ;; - solaris*) - case $cc_basename in - CC* | sunCC*) - # Sun C++ 4.2, 5.x and Centerline C++ - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - ;; - gcx*) - # Green Hills C++ Compiler - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - ;; - *) - ;; - esac - ;; - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - lcc*) - # Lucid - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - *) - ;; - esac - ;; - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - case $cc_basename in - CC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - esac - ;; - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - ;; - *) - ;; - esac - ;; - vxworks*) - ;; - *) - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - esac - fi -], -[ - if test "$GCC" = yes; then - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - m68k) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' - ;; - esac - ;; - - beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - - mingw* | cygwin* | pw32* | os2* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - # Although the cygwin gcc ignores -fPIC, still need this for old-style - # (--disable-auto-import) libraries - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - ;; - - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' - ;; - - haiku*) - # PIC is the default for Haiku. - # The "-static" flag exists, but is broken. - _LT_TAGVAR(lt_prog_compiler_static, $1)= - ;; - - hpux*) - # PIC is the default for 64-bit PA HP-UX, but not for 32-bit - # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag - # sets the default TLS model and affects inlining. - case $host_cpu in - hppa*64*) - # +Z the default - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - ;; - - interix[[3-9]]*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - - msdosdjgpp*) - # Just because we use GCC doesn't mean we suddenly get shared libraries - # on systems that don't support them. - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - enable_shared=no - ;; - - *nto* | *qnx*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic - fi - ;; - - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - - case $cc_basename in - nvcc*) # Cuda Compiler Driver 2.2 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' - if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" - fi - ;; - esac - else - # PORTME Check for flag to pass linker flags through the system compiler. - case $host_os in - aix*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - else - _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' - fi - ;; - - mingw* | cygwin* | pw32* | os2* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - ;; - - hpux9* | hpux10* | hpux11*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - ;; - esac - # Is there a better lt_prog_compiler_static that works with the bundled CC? - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - ;; - - irix5* | irix6* | nonstopux*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # PIC (with -KPIC) is the default. - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - linux* | k*bsd*-gnu | kopensolaris*-gnu) - case $cc_basename in - # old Intel for x86_64 which still supported -KPIC. - ecc*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - # icc used to be incompatible with GCC. - # ICC 10 doesn't accept -KPIC any more. - icc* | ifort*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - # Lahey Fortran 8.1. - lf95*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' - _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' - ;; - nagfor*) - # NAG Fortran compiler - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) - # Portland Group compilers (*not* the Pentium gcc compiler, - # which looks to be a dead project) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - ccc*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # All Alpha code is PIC. - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - xl* | bgxl* | bgf* | mpixl*) - # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) - # Sun Fortran 8.3 passes all unrecognized flags to the linker - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='' - ;; - *Sun\ F* | *Sun*Fortran*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - ;; - *Sun\ C*) - # Sun C 5.9 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - ;; - *Intel*\ [[CF]]*Compiler*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - *Portland\ Group*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - esac - ;; - esac - ;; - - newsos6) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - *nto* | *qnx*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - - osf3* | osf4* | osf5*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # All OSF/1 code is PIC. - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - rdos*) - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - solaris*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - case $cc_basename in - f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; - *) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; - esac - ;; - - sunos4*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - sysv4 | sysv4.2uw2* | sysv4.3*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - sysv4*MP*) - if test -d /usr/nec ;then - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - unicos*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - - uts4*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - *) - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - esac - fi -]) -case $host_os in - # For platforms which do not support PIC, -DPIC is meaningless: - *djgpp*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" - ;; -esac - -AC_CACHE_CHECK([for $compiler option to produce PIC], - [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], - [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) -_LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then - _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], - [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], - [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], - [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in - "" | " "*) ;; - *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; - esac], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) -fi -_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], - [Additional compiler flags for building library objects]) - -_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], - [How to pass a linker flag through the compiler]) -# -# Check to make sure the static flag actually works. -# -wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" -_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], - _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), - $lt_tmp_static_flag, - [], - [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) -_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], - [Compiler flag to prevent dynamic linking]) -])# _LT_COMPILER_PIC - - -# _LT_LINKER_SHLIBS([TAGNAME]) -# ---------------------------- -# See if the linker supports building shared libraries. -m4_defun([_LT_LINKER_SHLIBS], -[AC_REQUIRE([LT_PATH_LD])dnl -AC_REQUIRE([LT_PATH_NM])dnl -m4_require([_LT_PATH_MANIFEST_TOOL])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl -m4_require([_LT_TAG_COMPILER])dnl -AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) -m4_if([$1], [CXX], [ - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] - case $host_os in - aix[[4-9]]*) - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - # Also, AIX nm treats weak defined symbols like other global defined - # symbols, whereas GNU nm marks them as "W". - if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - else - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - fi - ;; - pw32*) - _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" - ;; - cygwin* | mingw* | cegcc*) - case $cc_basename in - cl*) - _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' - ;; - *) - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' - _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] - ;; - esac - ;; - *) - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - ;; - esac -], [ - runpath_var= - _LT_TAGVAR(allow_undefined_flag, $1)= - _LT_TAGVAR(always_export_symbols, $1)=no - _LT_TAGVAR(archive_cmds, $1)= - _LT_TAGVAR(archive_expsym_cmds, $1)= - _LT_TAGVAR(compiler_needs_object, $1)=no - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - _LT_TAGVAR(export_dynamic_flag_spec, $1)= - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - _LT_TAGVAR(hardcode_automatic, $1)=no - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_direct_absolute, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(hardcode_libdir_separator, $1)= - _LT_TAGVAR(hardcode_minus_L, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - _LT_TAGVAR(inherit_rpath, $1)=no - _LT_TAGVAR(link_all_deplibs, $1)=unknown - _LT_TAGVAR(module_cmds, $1)= - _LT_TAGVAR(module_expsym_cmds, $1)= - _LT_TAGVAR(old_archive_from_new_cmds, $1)= - _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= - _LT_TAGVAR(thread_safe_flag_spec, $1)= - _LT_TAGVAR(whole_archive_flag_spec, $1)= - # include_expsyms should be a list of space-separated symbols to be *always* - # included in the symbol list - _LT_TAGVAR(include_expsyms, $1)= - # exclude_expsyms can be an extended regexp of symbols to exclude - # it will be wrapped by ` (' and `)$', so one must not match beginning or - # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', - # as well as any symbol that contains `d'. - _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] - # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out - # platforms (ab)use it in PIC code, but their linkers get confused if - # the symbol is explicitly referenced. Since portable code cannot - # rely on this symbol name, it's probably fine to never include it in - # preloaded symbol tables. - # Exclude shared library initialization/finalization symbols. -dnl Note also adjust exclude_expsyms for C++ above. - extract_expsyms_cmds= - - case $host_os in - cygwin* | mingw* | pw32* | cegcc*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - if test "$GCC" != yes; then - with_gnu_ld=no - fi - ;; - interix*) - # we just hope/assume this is gcc and not c89 (= MSVC++) - with_gnu_ld=yes - ;; - openbsd*) - with_gnu_ld=no - ;; - esac - - _LT_TAGVAR(ld_shlibs, $1)=yes - - # On some targets, GNU ld is compatible enough with the native linker - # that we're better off using the native interface for both. - lt_use_gnu_ld_interface=no - if test "$with_gnu_ld" = yes; then - case $host_os in - aix*) - # The AIX port of GNU ld has always aspired to compatibility - # with the native linker. However, as the warning in the GNU ld - # block says, versions before 2.19.5* couldn't really create working - # shared libraries, regardless of the interface used. - case `$LD -v 2>&1` in - *\ \(GNU\ Binutils\)\ 2.19.5*) ;; - *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; - *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; - *) - lt_use_gnu_ld_interface=yes - ;; - esac - ;; - *) - lt_use_gnu_ld_interface=yes - ;; - esac - fi - - if test "$lt_use_gnu_ld_interface" = yes; then - # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' - - # Set some defaults for GNU ld with shared library support. These - # are reset later if shared libraries are not supported. Putting them - # here allows them to be overridden if necessary. - runpath_var=LD_RUN_PATH - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - # ancient GNU ld didn't support --whole-archive et. al. - if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - _LT_TAGVAR(whole_archive_flag_spec, $1)= - fi - supports_anon_versioning=no - case `$LD -v 2>&1` in - *GNU\ gold*) supports_anon_versioning=yes ;; - *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 - *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... - *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... - *\ 2.11.*) ;; # other 2.11 versions - *) supports_anon_versioning=yes ;; - esac - - # See if GNU ld supports shared libraries. - case $host_os in - aix[[3-9]]*) - # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then - _LT_TAGVAR(ld_shlibs, $1)=no - cat <<_LT_EOF 1>&2 - -*** Warning: the GNU linker, at least up to release 2.19, is reported -*** to be unable to reliably create shared libraries on AIX. -*** Therefore, libtool is disabling shared libraries support. If you -*** really care for shared libraries, you may want to install binutils -*** 2.20 or above, or modify your PATH so that a non-GNU linker is found. -*** You will then need to restart the configuration process. - -_LT_EOF - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='' - ;; - m68k) - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - ;; - - beos*) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, - # as there is no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=no - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' - _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] - - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - haiku*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - - interix[[3-9]]*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - - gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) - tmp_diet=no - if test "$host_os" = linux-dietlibc; then - case $cc_basename in - diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) - esac - fi - if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ - && test "$tmp_diet" = no - then - tmp_addflag=' $pic_flag' - tmp_sharedflag='-shared' - case $cc_basename,$host_cpu in - pgcc*) # Portland Group C compiler - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag' - ;; - pgf77* | pgf90* | pgf95* | pgfortran*) - # Portland Group f77 and f90 compilers - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag -Mnomain' ;; - ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 - tmp_addflag=' -i_dynamic' ;; - efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 - tmp_addflag=' -i_dynamic -nofor_main' ;; - ifc* | ifort*) # Intel Fortran compiler - tmp_addflag=' -nofor_main' ;; - lf95*) # Lahey Fortran 8.1 - _LT_TAGVAR(whole_archive_flag_spec, $1)= - tmp_sharedflag='--shared' ;; - xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) - tmp_sharedflag='-qmkshrobj' - tmp_addflag= ;; - nvcc*) # Cuda Compiler Driver 2.2 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - _LT_TAGVAR(compiler_needs_object, $1)=yes - ;; - esac - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) # Sun C 5.9 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - _LT_TAGVAR(compiler_needs_object, $1)=yes - tmp_sharedflag='-G' ;; - *Sun\ F*) # Sun Fortran 8.3 - tmp_sharedflag='-G' ;; - esac - _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - - if test "x$supports_anon_versioning" = xyes; then - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - fi - - case $cc_basename in - xlf* | bgf* | bgxlf* | mpixlf*) - # IBM XL Fortran 10.1 on PPC cannot create shared libs itself - _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' - fi - ;; - esac - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' - wlarc= - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - fi - ;; - - solaris*) - if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then - _LT_TAGVAR(ld_shlibs, $1)=no - cat <<_LT_EOF 1>&2 - -*** Warning: The releases 2.8.* of the GNU linker cannot reliably -*** create shared libraries on Solaris systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.9.1 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) - case `$LD -v 2>&1` in - *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) - _LT_TAGVAR(ld_shlibs, $1)=no - cat <<_LT_EOF 1>&2 - -*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not -*** reliably create shared libraries on SCO systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.16.91.0.3 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - ;; - *) - # For security reasons, it is highly recommended that you always - # use absolute paths for naming shared libraries, and exclude the - # DT_RUNPATH tag from executables and libraries. But doing so - # requires that you compile everything twice, which is a pain. - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - sunos4*) - _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' - wlarc= - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - - if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then - runpath_var= - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(export_dynamic_flag_spec, $1)= - _LT_TAGVAR(whole_archive_flag_spec, $1)= - fi - else - # PORTME fill in a description of your system's linker (not GNU ld) - case $host_os in - aix3*) - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=yes - _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - _LT_TAGVAR(hardcode_direct, $1)=unsupported - fi - ;; - - aix[[4-9]]*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - # Also, AIX nm treats weak defined symbols like other global - # defined symbols, whereas GNU nm marks them as "W". - if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - else - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - fi - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) - for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then - aix_use_runtimelinking=yes - break - fi - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - _LT_TAGVAR(archive_cmds, $1)='' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' - - if test "$GCC" = yes; then - case $host_os in aix4.[[012]]|aix4.[[012]].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && - strings "$collect2name" | $GREP resolve_lib_name >/dev/null - then - # We have reworked collect2 - : - else - # We have old collect2 - _LT_TAGVAR(hardcode_direct, $1)=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)= - fi - ;; - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to export. - _LT_TAGVAR(always_export_symbols, $1)=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(allow_undefined_flag, $1)='-berok' - # Determine the default libpath from the value encoded in an - # empty executable. - _LT_SYS_MODULE_PATH_AIX([$1]) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' - _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an - # empty executable. - _LT_SYS_MODULE_PATH_AIX([$1]) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' - if test "$with_gnu_ld" = yes; then - # We only use this code for GNU lds that support --whole-archive. - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - else - # Exported symbols can be pulled into shared objects from archives - _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - # This is similar to how AIX traditionally builds its shared libraries. - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='' - ;; - m68k) - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - ;; - - bsdi[[45]]*) - _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - case $cc_basename in - cl*) - # Native MSVC - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='@' - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; - else - sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; - fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ - linknames=' - # The linker will not automatically build a static lib if we build a DLL. - # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' - # Don't use ranlib - _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' - _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ - lt_tool_outputfile="@TOOL_OUTPUT@"~ - case $lt_outputfile in - *.exe|*.EXE) ;; - *) - lt_outputfile="$lt_outputfile.exe" - lt_tool_outputfile="$lt_tool_outputfile.exe" - ;; - esac~ - if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then - $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; - $RM "$lt_outputfile.manifest"; - fi' - ;; - *) - # Assume MSVC wrapper - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' - # FIXME: Should let the user specify the lib program. - _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - ;; - esac - ;; - - darwin* | rhapsody*) - _LT_DARWIN_LINKER_FEATURES($1) - ;; - - dgux*) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor - # support. Future versions do this automatically, but an explicit c++rt0.o - # does not break anything, and helps significantly (at the cost of a little - # extra space). - freebsd2.2*) - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2.*) - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | dragonfly*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - hpux9*) - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(hardcode_direct, $1)=yes - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - ;; - - hpux10*) - if test "$GCC" = yes && test "$with_gnu_ld" = no; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' - fi - if test "$with_gnu_ld" = no; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - fi - ;; - - hpux11*) - if test "$GCC" = yes && test "$with_gnu_ld" = no; then - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - else - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - m4_if($1, [], [ - # Older versions of the 11.00 compiler do not understand -b yet - # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) - _LT_LINKER_OPTION([if $CC understands -b], - _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], - [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], - [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], - [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) - ;; - esac - fi - if test "$with_gnu_ld" = no; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - case $host_cpu in - hppa*64*|ia64*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - *) - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - fi - ;; - - irix5* | irix6* | nonstopux*) - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - # Try to use the -exported_symbol ld option, if it does not - # work, assume that -exports_file does not work either and - # implicitly export all symbols. - # This should be the same for all languages, so no per-tag cache variable. - AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], - [lt_cv_irix_exported_symbol], - [save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" - AC_LINK_IFELSE( - [AC_LANG_SOURCE( - [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], - [C++], [[int foo (void) { return 0; }]], - [Fortran 77], [[ - subroutine foo - end]], - [Fortran], [[ - subroutine foo - end]])])], - [lt_cv_irix_exported_symbol=yes], - [lt_cv_irix_exported_symbol=no]) - LDFLAGS="$save_LDFLAGS"]) - if test "$lt_cv_irix_exported_symbol" = yes; then - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' - fi - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(inherit_rpath, $1)=yes - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out - else - _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - newsos6) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *nto* | *qnx*) - ;; - - openbsd*) - if test -f /usr/libexec/ld.so; then - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - else - case $host_os in - openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - ;; - esac - fi - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - os2*) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' - _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' - ;; - - osf3*) - if test "$GCC" = yes; then - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - - osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - else - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ - $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' - - # Both c and cxx compiler support -rpath directly - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - - solaris*) - _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' - if test "$GCC" = yes; then - wlarc='${wl}' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' - else - case `$CC -V 2>&1` in - *"Compilers 5.0"*) - wlarc='' - _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' - ;; - *) - wlarc='${wl}' - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' - ;; - esac - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - # The compiler driver will combine and reorder linker options, - # but understands `-z linker_flag'. GCC discards it without `$wl', - # but is careful enough not to reorder. - # Supported since Solaris 2.6 (maybe 2.5.1?) - if test "$GCC" = yes; then - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' - else - _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' - fi - ;; - esac - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - - sunos4*) - if test "x$host_vendor" = xsequent; then - # Use $CC to link under sequent, because it throws in some extra .o - # files that make .init and .fini sections work. - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - sysv4) - case $host_vendor in - sni) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? - ;; - siemens) - ## LD is ld it makes a PLAMLIB - ## CC just makes a GrossModule. - _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' - _LT_TAGVAR(hardcode_direct, $1)=no - ;; - motorola) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie - ;; - esac - runpath_var='LD_RUN_PATH' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - sysv4.3*) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - _LT_TAGVAR(ld_shlibs, $1)=yes - fi - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - uts4*) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *) - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - - if test x$host_vendor = xsni; then - case $host in - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' - ;; - esac - fi - fi -]) -AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) -test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no - -_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld - -_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl -_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl -_LT_DECL([], [extract_expsyms_cmds], [2], - [The commands to extract the exported symbol list from a shared archive]) - -# -# Do we need to explicitly link libc? -# -case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in -x|xyes) - # Assume -lc should be added - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - - if test "$enable_shared" = yes && test "$GCC" = yes; then - case $_LT_TAGVAR(archive_cmds, $1) in - *'~'*) - # FIXME: we may have to deal with multi-command sequences. - ;; - '$CC '*) - # Test whether the compiler implicitly links with -lc since on some - # systems, -lgcc has to come before -lc. If gcc already passes -lc - # to ld, don't add -lc before -lgcc. - AC_CACHE_CHECK([whether -lc should be explicitly linked in], - [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), - [$RM conftest* - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - if AC_TRY_EVAL(ac_compile) 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) - pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) - _LT_TAGVAR(allow_undefined_flag, $1)= - if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) - then - lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no - else - lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes - fi - _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $RM conftest* - ]) - _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) - ;; - esac - fi - ;; -esac - -_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], - [Whether or not to add -lc for building shared libraries]) -_LT_TAGDECL([allow_libtool_libs_with_static_runtimes], - [enable_shared_with_static_runtimes], [0], - [Whether or not to disallow shared libs when runtime libs are static]) -_LT_TAGDECL([], [export_dynamic_flag_spec], [1], - [Compiler flag to allow reflexive dlopens]) -_LT_TAGDECL([], [whole_archive_flag_spec], [1], - [Compiler flag to generate shared objects directly from archives]) -_LT_TAGDECL([], [compiler_needs_object], [1], - [Whether the compiler copes with passing no objects directly]) -_LT_TAGDECL([], [old_archive_from_new_cmds], [2], - [Create an old-style archive from a shared archive]) -_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], - [Create a temporary old-style archive to link instead of a shared archive]) -_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) -_LT_TAGDECL([], [archive_expsym_cmds], [2]) -_LT_TAGDECL([], [module_cmds], [2], - [Commands used to build a loadable module if different from building - a shared archive.]) -_LT_TAGDECL([], [module_expsym_cmds], [2]) -_LT_TAGDECL([], [with_gnu_ld], [1], - [Whether we are building with GNU ld or not]) -_LT_TAGDECL([], [allow_undefined_flag], [1], - [Flag that allows shared libraries with undefined symbols to be built]) -_LT_TAGDECL([], [no_undefined_flag], [1], - [Flag that enforces no undefined symbols]) -_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], - [Flag to hardcode $libdir into a binary during linking. - This must work even if $libdir does not exist]) -_LT_TAGDECL([], [hardcode_libdir_separator], [1], - [Whether we need a single "-rpath" flag with a separated argument]) -_LT_TAGDECL([], [hardcode_direct], [0], - [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes - DIR into the resulting binary]) -_LT_TAGDECL([], [hardcode_direct_absolute], [0], - [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes - DIR into the resulting binary and the resulting library dependency is - "absolute", i.e impossible to change by setting ${shlibpath_var} if the - library is relocated]) -_LT_TAGDECL([], [hardcode_minus_L], [0], - [Set to "yes" if using the -LDIR flag during linking hardcodes DIR - into the resulting binary]) -_LT_TAGDECL([], [hardcode_shlibpath_var], [0], - [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR - into the resulting binary]) -_LT_TAGDECL([], [hardcode_automatic], [0], - [Set to "yes" if building a shared library automatically hardcodes DIR - into the library and all subsequent libraries and executables linked - against it]) -_LT_TAGDECL([], [inherit_rpath], [0], - [Set to yes if linker adds runtime paths of dependent libraries - to runtime path list]) -_LT_TAGDECL([], [link_all_deplibs], [0], - [Whether libtool must link a program against all its dependency libraries]) -_LT_TAGDECL([], [always_export_symbols], [0], - [Set to "yes" if exported symbols are required]) -_LT_TAGDECL([], [export_symbols_cmds], [2], - [The commands to list exported symbols]) -_LT_TAGDECL([], [exclude_expsyms], [1], - [Symbols that should not be listed in the preloaded symbols]) -_LT_TAGDECL([], [include_expsyms], [1], - [Symbols that must always be exported]) -_LT_TAGDECL([], [prelink_cmds], [2], - [Commands necessary for linking programs (against libraries) with templates]) -_LT_TAGDECL([], [postlink_cmds], [2], - [Commands necessary for finishing linking programs]) -_LT_TAGDECL([], [file_list_spec], [1], - [Specify filename containing input files]) -dnl FIXME: Not yet implemented -dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], -dnl [Compiler flag to generate thread safe objects]) -])# _LT_LINKER_SHLIBS - - -# _LT_LANG_C_CONFIG([TAG]) -# ------------------------ -# Ensure that the configuration variables for a C compiler are suitably -# defined. These variables are subsequently used by _LT_CONFIG to write -# the compiler configuration to `libtool'. -m4_defun([_LT_LANG_C_CONFIG], -[m4_require([_LT_DECL_EGREP])dnl -lt_save_CC="$CC" -AC_LANG_PUSH(C) - -# Source file extension for C test sources. -ac_ext=c - -# Object file extension for compiled C test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="int some_variable = 0;" - -# Code to be used in simple link tests -lt_simple_link_test_code='int main(){return(0);}' - -_LT_TAG_COMPILER -# Save the default compiler, since it gets overwritten when the other -# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. -compiler_DEFAULT=$CC - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -## CAVEAT EMPTOR: -## There is no encapsulation within the following macros, do not change -## the running order or otherwise move them around unless you know exactly -## what you are doing... -if test -n "$compiler"; then - _LT_COMPILER_NO_RTTI($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - LT_SYS_DLOPEN_SELF - _LT_CMD_STRIPLIB - - # Report which library types will actually be built - AC_MSG_CHECKING([if libtool supports shared libraries]) - AC_MSG_RESULT([$can_build_shared]) - - AC_MSG_CHECKING([whether to build shared libraries]) - test "$can_build_shared" = "no" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - - aix[[4-9]]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - esac - AC_MSG_RESULT([$enable_shared]) - - AC_MSG_CHECKING([whether to build static libraries]) - # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes - AC_MSG_RESULT([$enable_static]) - - _LT_CONFIG($1) -fi -AC_LANG_POP -CC="$lt_save_CC" -])# _LT_LANG_C_CONFIG - - -# _LT_LANG_CXX_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for a C++ compiler are suitably -# defined. These variables are subsequently used by _LT_CONFIG to write -# the compiler configuration to `libtool'. -m4_defun([_LT_LANG_CXX_CONFIG], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_PATH_MANIFEST_TOOL])dnl -if test -n "$CXX" && ( test "X$CXX" != "Xno" && - ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || - (test "X$CXX" != "Xg++"))) ; then - AC_PROG_CXXCPP -else - _lt_caught_CXX_error=yes -fi - -AC_LANG_PUSH(C++) -_LT_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_TAGVAR(allow_undefined_flag, $1)= -_LT_TAGVAR(always_export_symbols, $1)=no -_LT_TAGVAR(archive_expsym_cmds, $1)= -_LT_TAGVAR(compiler_needs_object, $1)=no -_LT_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_TAGVAR(hardcode_direct, $1)=no -_LT_TAGVAR(hardcode_direct_absolute, $1)=no -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_separator, $1)= -_LT_TAGVAR(hardcode_minus_L, $1)=no -_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported -_LT_TAGVAR(hardcode_automatic, $1)=no -_LT_TAGVAR(inherit_rpath, $1)=no -_LT_TAGVAR(module_cmds, $1)= -_LT_TAGVAR(module_expsym_cmds, $1)= -_LT_TAGVAR(link_all_deplibs, $1)=unknown -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds -_LT_TAGVAR(no_undefined_flag, $1)= -_LT_TAGVAR(whole_archive_flag_spec, $1)= -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Source file extension for C++ test sources. -ac_ext=cpp - -# Object file extension for compiled C++ test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# No sense in running all these tests if we already determined that -# the CXX compiler isn't working. Some variables (like enable_shared) -# are currently assumed to apply to all compilers on this platform, -# and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_caught_CXX_error" != yes; then - # Code to be used in simple compile tests - lt_simple_compile_test_code="int some_variable = 0;" - - # Code to be used in simple link tests - lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' - - # ltmain only uses $CC for tagged configurations so make sure $CC is set. - _LT_TAG_COMPILER - - # save warnings/boilerplate of simple test code - _LT_COMPILER_BOILERPLATE - _LT_LINKER_BOILERPLATE - - # Allow CC to be a program name with arguments. - lt_save_CC=$CC - lt_save_CFLAGS=$CFLAGS - lt_save_LD=$LD - lt_save_GCC=$GCC - GCC=$GXX - lt_save_with_gnu_ld=$with_gnu_ld - lt_save_path_LD=$lt_cv_path_LD - if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then - lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx - else - $as_unset lt_cv_prog_gnu_ld - fi - if test -n "${lt_cv_path_LDCXX+set}"; then - lt_cv_path_LD=$lt_cv_path_LDCXX - else - $as_unset lt_cv_path_LD - fi - test -z "${LDCXX+set}" || LD=$LDCXX - CC=${CXX-"c++"} - CFLAGS=$CXXFLAGS - compiler=$CC - _LT_TAGVAR(compiler, $1)=$CC - _LT_CC_BASENAME([$compiler]) - - if test -n "$compiler"; then - # We don't want -fno-exception when compiling C++ code, so set the - # no_builtin_flag separately - if test "$GXX" = yes; then - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' - else - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= - fi - - if test "$GXX" = yes; then - # Set up default GNU C++ configuration - - LT_PATH_LD - - # Check if GNU C++ uses GNU ld as the underlying linker, since the - # archiving commands below assume that GNU ld is being used. - if test "$with_gnu_ld" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - - # If archive_cmds runs LD, not CC, wlarc should be empty - # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to - # investigate it a little bit more. (MM) - wlarc='${wl}' - - # ancient GNU ld didn't support --whole-archive et. al. - if eval "`$CC -print-prog-name=ld` --help 2>&1" | - $GREP 'no-whole-archive' > /dev/null; then - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - _LT_TAGVAR(whole_archive_flag_spec, $1)= - fi - else - with_gnu_ld=no - wlarc= - - # A generic and very simple default shared library creation - # command for GNU C++ for the case where it uses the native - # linker, instead of GNU ld. If possible, this setting should - # overridden to take advantage of the native linker features on - # the platform it is being used on. - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - fi - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' - - else - GXX=no - with_gnu_ld=no - wlarc= - fi - - # PORTME: fill in a description of your system's C++ link characteristics - AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) - _LT_TAGVAR(ld_shlibs, $1)=yes - case $host_os in - aix3*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - aix[[4-9]]*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) - for ld_flag in $LDFLAGS; do - case $ld_flag in - *-brtl*) - aix_use_runtimelinking=yes - break - ;; - esac - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - _LT_TAGVAR(archive_cmds, $1)='' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' - - if test "$GXX" = yes; then - case $host_os in aix4.[[012]]|aix4.[[012]].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && - strings "$collect2name" | $GREP resolve_lib_name >/dev/null - then - # We have reworked collect2 - : - else - # We have old collect2 - _LT_TAGVAR(hardcode_direct, $1)=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)= - fi - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to - # export. - _LT_TAGVAR(always_export_symbols, $1)=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(allow_undefined_flag, $1)='-berok' - # Determine the default libpath from the value encoded in an empty - # executable. - _LT_SYS_MODULE_PATH_AIX([$1]) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' - _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an - # empty executable. - _LT_SYS_MODULE_PATH_AIX([$1]) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' - if test "$with_gnu_ld" = yes; then - # We only use this code for GNU lds that support --whole-archive. - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - else - # Exported symbols can be pulled into shared objects from archives - _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - # This is similar to how AIX traditionally builds its shared - # libraries. - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - beos*) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - chorus*) - case $cc_basename in - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - cygwin* | mingw* | pw32* | cegcc*) - case $GXX,$cc_basename in - ,cl* | no,cl*) - # Native MSVC - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='@' - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; - else - $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; - fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ - linknames=' - # The linker will not automatically build a static lib if we build a DLL. - # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - # Don't use ranlib - _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' - _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ - lt_tool_outputfile="@TOOL_OUTPUT@"~ - case $lt_outputfile in - *.exe|*.EXE) ;; - *) - lt_outputfile="$lt_outputfile.exe" - lt_tool_outputfile="$lt_tool_outputfile.exe" - ;; - esac~ - func_to_tool_file "$lt_outputfile"~ - if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then - $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; - $RM "$lt_outputfile.manifest"; - fi' - ;; - *) - # g++ - # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, - # as there is no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=no - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - darwin* | rhapsody*) - _LT_DARWIN_LINKER_FEATURES($1) - ;; - - dgux*) - case $cc_basename in - ec++*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - ghcx*) - # Green Hills C++ Compiler - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - freebsd2.*) - # C++ shared libraries reported to be fairly broken before - # switch to ELF - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - freebsd-elf*) - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - ;; - - freebsd* | dragonfly*) - # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF - # conventions - _LT_TAGVAR(ld_shlibs, $1)=yes - ;; - - gnu*) - ;; - - haiku*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - - hpux9*) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, - # but as the default - # location of the library. - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - aCC*) - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' - ;; - *) - if test "$GXX" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - hpux10*|hpux11*) - if test $with_gnu_ld = no; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - case $host_cpu in - hppa*64*|ia64*) - ;; - *) - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - ;; - esac - fi - case $host_cpu in - hppa*64*|ia64*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - *) - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, - # but as the default - # location of the library. - ;; - esac - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - aCC*) - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' - ;; - *) - if test "$GXX" = yes; then - if test $with_gnu_ld = no; then - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - fi - else - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - interix[[3-9]]*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - irix5* | irix6*) - case $cc_basename in - CC*) - # SGI C++ - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - - # Archives containing C++ object files must be created using - # "CC -ar", where "CC" is the IRIX C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' - ;; - *) - if test "$GXX" = yes; then - if test "$with_gnu_ld" = no; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' - fi - fi - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - esac - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(inherit_rpath, $1)=yes - ;; - - linux* | k*bsd*-gnu | kopensolaris*-gnu) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - - # Archives containing C++ object files must be created using - # "CC -Bstatic", where "CC" is the KAI C++ compiler. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' - ;; - icpc* | ecpc* ) - # Intel C++ - with_gnu_ld=yes - # version 8.0 and above of icpc choke on multiply defined symbols - # if we add $predep_objects and $postdep_objects, however 7.1 and - # earlier do not add the objects themselves. - case `$CC -V 2>&1` in - *"Version 7."*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - ;; - *) # Version 8.0 or newer - tmp_idyn= - case $host_cpu in - ia64*) tmp_idyn=' -i_dynamic';; - esac - _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - ;; - esac - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - ;; - pgCC* | pgcpp*) - # Portland Group C++ compiler - case `$CC -V` in - *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) - _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ - compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' - _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ - $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ - $RANLIB $oldlib' - _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' - ;; - *) # Version 6 and above use weak symbols - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' - ;; - esac - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - ;; - cxx*) - # Compaq C++ - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' - - runpath_var=LD_RUN_PATH - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' - ;; - xl* | mpixl* | bgxl*) - # IBM XL 8.0 on PPC, with GNU ld - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - fi - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - _LT_TAGVAR(compiler_needs_object, $1)=yes - - # Not sure whether something based on - # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 - # would be better. - output_verbose_link_cmd='func_echo_all' - - # Archives containing C++ object files must be created using - # "CC -xar", where "CC" is the Sun C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' - ;; - esac - ;; - esac - ;; - - lynxos*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - m88k*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - mvs*) - case $cc_basename in - cxx*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' - wlarc= - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - fi - # Workaround some broken pre-1.5 toolchains - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' - ;; - - *nto* | *qnx*) - _LT_TAGVAR(ld_shlibs, $1)=yes - ;; - - openbsd2*) - # C++ shared libraries are fairly broken - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - openbsd*) - if test -f /usr/libexec/ld.so; then - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - fi - output_verbose_link_cmd=func_echo_all - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - osf3* | osf4* | osf5*) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Archives containing C++ object files must be created using - # the KAI C++ compiler. - case $host in - osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; - *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; - esac - ;; - RCC*) - # Rational C++ 2.4.1 - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - cxx*) - case $host in - osf3*) - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - ;; - *) - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ - echo "-hidden">> $lib.exp~ - $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~ - $RM $lib.exp' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - ;; - esac - - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' - ;; - *) - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - case $host in - osf3*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - ;; - esac - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' - - else - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - psos*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - lcc*) - # Lucid - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - solaris*) - case $cc_basename in - CC* | sunCC*) - # Sun C++ 4.2, 5.x and Centerline C++ - _LT_TAGVAR(archive_cmds_need_lc,$1)=yes - _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - # The compiler driver will combine and reorder linker options, - # but understands `-z linker_flag'. - # Supported since Solaris 2.6 (maybe 2.5.1?) - _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' - ;; - esac - _LT_TAGVAR(link_all_deplibs, $1)=yes - - output_verbose_link_cmd='func_echo_all' - - # Archives containing C++ object files must be created using - # "CC -xar", where "CC" is the Sun C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' - ;; - gcx*) - # Green Hills C++ Compiler - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - - # The C++ compiler must be used to create the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' - ;; - *) - # GNU C++ compiler with Solaris linker - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' - if $CC --version | $GREP -v '^2\.7' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' - else - # g++ 2.7 appears to require `-G' NOT `-shared' on this - # platform. - _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' - fi - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' - ;; - esac - fi - ;; - esac - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ - '"$_LT_TAGVAR(old_archive_cmds, $1)" - _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ - '"$_LT_TAGVAR(reload_cmds, $1)" - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - vxworks*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - - AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) - test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no - - _LT_TAGVAR(GCC, $1)="$GXX" - _LT_TAGVAR(LD, $1)="$LD" - - ## CAVEAT EMPTOR: - ## There is no encapsulation within the following macros, do not change - ## the running order or otherwise move them around unless you know exactly - ## what you are doing... - _LT_SYS_HIDDEN_LIBDEPS($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) - fi # test -n "$compiler" - - CC=$lt_save_CC - CFLAGS=$lt_save_CFLAGS - LDCXX=$LD - LD=$lt_save_LD - GCC=$lt_save_GCC - with_gnu_ld=$lt_save_with_gnu_ld - lt_cv_path_LDCXX=$lt_cv_path_LD - lt_cv_path_LD=$lt_save_path_LD - lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld - lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld -fi # test "$_lt_caught_CXX_error" != yes - -AC_LANG_POP -])# _LT_LANG_CXX_CONFIG - - -# _LT_FUNC_STRIPNAME_CNF -# ---------------------- -# func_stripname_cnf prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -# -# This function is identical to the (non-XSI) version of func_stripname, -# except this one can be used by m4 code that may be executed by configure, -# rather than the libtool script. -m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl -AC_REQUIRE([_LT_DECL_SED]) -AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) -func_stripname_cnf () -{ - case ${2} in - .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; - esac -} # func_stripname_cnf -])# _LT_FUNC_STRIPNAME_CNF - -# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) -# --------------------------------- -# Figure out "hidden" library dependencies from verbose -# compiler output when linking a shared library. -# Parse the compiler output and extract the necessary -# objects, libraries and library flags. -m4_defun([_LT_SYS_HIDDEN_LIBDEPS], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl -# Dependencies to place before and after the object being linked: -_LT_TAGVAR(predep_objects, $1)= -_LT_TAGVAR(postdep_objects, $1)= -_LT_TAGVAR(predeps, $1)= -_LT_TAGVAR(postdeps, $1)= -_LT_TAGVAR(compiler_lib_search_path, $1)= - -dnl we can't use the lt_simple_compile_test_code here, -dnl because it contains code intended for an executable, -dnl not a library. It's possible we should let each -dnl tag define a new lt_????_link_test_code variable, -dnl but it's only used here... -m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF -int a; -void foo (void) { a = 0; } -_LT_EOF -], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF -class Foo -{ -public: - Foo (void) { a = 0; } -private: - int a; -}; -_LT_EOF -], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF - subroutine foo - implicit none - integer*4 a - a=0 - return - end -_LT_EOF -], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF - subroutine foo - implicit none - integer a - a=0 - return - end -_LT_EOF -], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF -public class foo { - private int a; - public void bar (void) { - a = 0; - } -}; -_LT_EOF -], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF -package foo -func foo() { -} -_LT_EOF -]) - -_lt_libdeps_save_CFLAGS=$CFLAGS -case "$CC $CFLAGS " in #( -*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; -*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; -*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; -esac - -dnl Parse the compiler output and extract the necessary -dnl objects, libraries and library flags. -if AC_TRY_EVAL(ac_compile); then - # Parse the compiler output and extract the necessary - # objects, libraries and library flags. - - # Sentinel used to keep track of whether or not we are before - # the conftest object file. - pre_test_object_deps_done=no - - for p in `eval "$output_verbose_link_cmd"`; do - case ${prev}${p} in - - -L* | -R* | -l*) - # Some compilers place space between "-{L,R}" and the path. - # Remove the space. - if test $p = "-L" || - test $p = "-R"; then - prev=$p - continue - fi - - # Expand the sysroot to ease extracting the directories later. - if test -z "$prev"; then - case $p in - -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; - -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; - -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; - esac - fi - case $p in - =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; - esac - if test "$pre_test_object_deps_done" = no; then - case ${prev} in - -L | -R) - # Internal compiler library paths should come after those - # provided the user. The postdeps already come after the - # user supplied libs so there is no need to process them. - if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then - _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" - else - _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" - fi - ;; - # The "-l" case would never come before the object being - # linked, so don't bother handling this case. - esac - else - if test -z "$_LT_TAGVAR(postdeps, $1)"; then - _LT_TAGVAR(postdeps, $1)="${prev}${p}" - else - _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" - fi - fi - prev= - ;; - - *.lto.$objext) ;; # Ignore GCC LTO objects - *.$objext) - # This assumes that the test object file only shows up - # once in the compiler output. - if test "$p" = "conftest.$objext"; then - pre_test_object_deps_done=yes - continue - fi - - if test "$pre_test_object_deps_done" = no; then - if test -z "$_LT_TAGVAR(predep_objects, $1)"; then - _LT_TAGVAR(predep_objects, $1)="$p" - else - _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" - fi - else - if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then - _LT_TAGVAR(postdep_objects, $1)="$p" - else - _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" - fi - fi - ;; - - *) ;; # Ignore the rest. - - esac - done - - # Clean up. - rm -f a.out a.exe -else - echo "libtool.m4: error: problem compiling $1 test program" -fi - -$RM -f confest.$objext -CFLAGS=$_lt_libdeps_save_CFLAGS - -# PORTME: override above test on systems where it is broken -m4_if([$1], [CXX], -[case $host_os in -interix[[3-9]]*) - # Interix 3.5 installs completely hosed .la files for C++, so rather than - # hack all around it, let's just trust "g++" to DTRT. - _LT_TAGVAR(predep_objects,$1)= - _LT_TAGVAR(postdep_objects,$1)= - _LT_TAGVAR(postdeps,$1)= - ;; - -linux*) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - - # The more standards-conforming stlport4 library is - # incompatible with the Cstd library. Avoid specifying - # it if it's in CXXFLAGS. Ignore libCrun as - # -library=stlport4 depends on it. - case " $CXX $CXXFLAGS " in - *" -library=stlport4 "*) - solaris_use_stlport4=yes - ;; - esac - - if test "$solaris_use_stlport4" != yes; then - _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' - fi - ;; - esac - ;; - -solaris*) - case $cc_basename in - CC* | sunCC*) - # The more standards-conforming stlport4 library is - # incompatible with the Cstd library. Avoid specifying - # it if it's in CXXFLAGS. Ignore libCrun as - # -library=stlport4 depends on it. - case " $CXX $CXXFLAGS " in - *" -library=stlport4 "*) - solaris_use_stlport4=yes - ;; - esac - - # Adding this requires a known-good setup of shared libraries for - # Sun compiler versions before 5.6, else PIC objects from an old - # archive will be linked into the output, leading to subtle bugs. - if test "$solaris_use_stlport4" != yes; then - _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' - fi - ;; - esac - ;; -esac -]) - -case " $_LT_TAGVAR(postdeps, $1) " in -*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; -esac - _LT_TAGVAR(compiler_lib_search_dirs, $1)= -if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then - _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` -fi -_LT_TAGDECL([], [compiler_lib_search_dirs], [1], - [The directories searched by this compiler when creating a shared library]) -_LT_TAGDECL([], [predep_objects], [1], - [Dependencies to place before and after the objects being linked to - create a shared library]) -_LT_TAGDECL([], [postdep_objects], [1]) -_LT_TAGDECL([], [predeps], [1]) -_LT_TAGDECL([], [postdeps], [1]) -_LT_TAGDECL([], [compiler_lib_search_path], [1], - [The library search path used internally by the compiler when linking - a shared library]) -])# _LT_SYS_HIDDEN_LIBDEPS - - -# _LT_LANG_F77_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for a Fortran 77 compiler are -# suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_F77_CONFIG], -[AC_LANG_PUSH(Fortran 77) -if test -z "$F77" || test "X$F77" = "Xno"; then - _lt_disable_F77=yes -fi - -_LT_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_TAGVAR(allow_undefined_flag, $1)= -_LT_TAGVAR(always_export_symbols, $1)=no -_LT_TAGVAR(archive_expsym_cmds, $1)= -_LT_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_TAGVAR(hardcode_direct, $1)=no -_LT_TAGVAR(hardcode_direct_absolute, $1)=no -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_separator, $1)= -_LT_TAGVAR(hardcode_minus_L, $1)=no -_LT_TAGVAR(hardcode_automatic, $1)=no -_LT_TAGVAR(inherit_rpath, $1)=no -_LT_TAGVAR(module_cmds, $1)= -_LT_TAGVAR(module_expsym_cmds, $1)= -_LT_TAGVAR(link_all_deplibs, $1)=unknown -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds -_LT_TAGVAR(no_undefined_flag, $1)= -_LT_TAGVAR(whole_archive_flag_spec, $1)= -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Source file extension for f77 test sources. -ac_ext=f - -# Object file extension for compiled f77 test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# No sense in running all these tests if we already determined that -# the F77 compiler isn't working. Some variables (like enable_shared) -# are currently assumed to apply to all compilers on this platform, -# and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_disable_F77" != yes; then - # Code to be used in simple compile tests - lt_simple_compile_test_code="\ - subroutine t - return - end -" - - # Code to be used in simple link tests - lt_simple_link_test_code="\ - program t - end -" - - # ltmain only uses $CC for tagged configurations so make sure $CC is set. - _LT_TAG_COMPILER - - # save warnings/boilerplate of simple test code - _LT_COMPILER_BOILERPLATE - _LT_LINKER_BOILERPLATE - - # Allow CC to be a program name with arguments. - lt_save_CC="$CC" - lt_save_GCC=$GCC - lt_save_CFLAGS=$CFLAGS - CC=${F77-"f77"} - CFLAGS=$FFLAGS - compiler=$CC - _LT_TAGVAR(compiler, $1)=$CC - _LT_CC_BASENAME([$compiler]) - GCC=$G77 - if test -n "$compiler"; then - AC_MSG_CHECKING([if libtool supports shared libraries]) - AC_MSG_RESULT([$can_build_shared]) - - AC_MSG_CHECKING([whether to build shared libraries]) - test "$can_build_shared" = "no" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - aix[[4-9]]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - esac - AC_MSG_RESULT([$enable_shared]) - - AC_MSG_CHECKING([whether to build static libraries]) - # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes - AC_MSG_RESULT([$enable_static]) - - _LT_TAGVAR(GCC, $1)="$G77" - _LT_TAGVAR(LD, $1)="$LD" - - ## CAVEAT EMPTOR: - ## There is no encapsulation within the following macros, do not change - ## the running order or otherwise move them around unless you know exactly - ## what you are doing... - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) - fi # test -n "$compiler" - - GCC=$lt_save_GCC - CC="$lt_save_CC" - CFLAGS="$lt_save_CFLAGS" -fi # test "$_lt_disable_F77" != yes - -AC_LANG_POP -])# _LT_LANG_F77_CONFIG - - -# _LT_LANG_FC_CONFIG([TAG]) -# ------------------------- -# Ensure that the configuration variables for a Fortran compiler are -# suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_FC_CONFIG], -[AC_LANG_PUSH(Fortran) - -if test -z "$FC" || test "X$FC" = "Xno"; then - _lt_disable_FC=yes -fi - -_LT_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_TAGVAR(allow_undefined_flag, $1)= -_LT_TAGVAR(always_export_symbols, $1)=no -_LT_TAGVAR(archive_expsym_cmds, $1)= -_LT_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_TAGVAR(hardcode_direct, $1)=no -_LT_TAGVAR(hardcode_direct_absolute, $1)=no -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_separator, $1)= -_LT_TAGVAR(hardcode_minus_L, $1)=no -_LT_TAGVAR(hardcode_automatic, $1)=no -_LT_TAGVAR(inherit_rpath, $1)=no -_LT_TAGVAR(module_cmds, $1)= -_LT_TAGVAR(module_expsym_cmds, $1)= -_LT_TAGVAR(link_all_deplibs, $1)=unknown -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds -_LT_TAGVAR(no_undefined_flag, $1)= -_LT_TAGVAR(whole_archive_flag_spec, $1)= -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Source file extension for fc test sources. -ac_ext=${ac_fc_srcext-f} - -# Object file extension for compiled fc test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# No sense in running all these tests if we already determined that -# the FC compiler isn't working. Some variables (like enable_shared) -# are currently assumed to apply to all compilers on this platform, -# and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_disable_FC" != yes; then - # Code to be used in simple compile tests - lt_simple_compile_test_code="\ - subroutine t - return - end -" - - # Code to be used in simple link tests - lt_simple_link_test_code="\ - program t - end -" - - # ltmain only uses $CC for tagged configurations so make sure $CC is set. - _LT_TAG_COMPILER - - # save warnings/boilerplate of simple test code - _LT_COMPILER_BOILERPLATE - _LT_LINKER_BOILERPLATE - - # Allow CC to be a program name with arguments. - lt_save_CC="$CC" - lt_save_GCC=$GCC - lt_save_CFLAGS=$CFLAGS - CC=${FC-"f95"} - CFLAGS=$FCFLAGS - compiler=$CC - GCC=$ac_cv_fc_compiler_gnu - - _LT_TAGVAR(compiler, $1)=$CC - _LT_CC_BASENAME([$compiler]) - - if test -n "$compiler"; then - AC_MSG_CHECKING([if libtool supports shared libraries]) - AC_MSG_RESULT([$can_build_shared]) - - AC_MSG_CHECKING([whether to build shared libraries]) - test "$can_build_shared" = "no" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - aix[[4-9]]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - esac - AC_MSG_RESULT([$enable_shared]) - - AC_MSG_CHECKING([whether to build static libraries]) - # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes - AC_MSG_RESULT([$enable_static]) - - _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" - _LT_TAGVAR(LD, $1)="$LD" - - ## CAVEAT EMPTOR: - ## There is no encapsulation within the following macros, do not change - ## the running order or otherwise move them around unless you know exactly - ## what you are doing... - _LT_SYS_HIDDEN_LIBDEPS($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) - fi # test -n "$compiler" - - GCC=$lt_save_GCC - CC=$lt_save_CC - CFLAGS=$lt_save_CFLAGS -fi # test "$_lt_disable_FC" != yes - -AC_LANG_POP -])# _LT_LANG_FC_CONFIG - - -# _LT_LANG_GCJ_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for the GNU Java Compiler compiler -# are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_GCJ_CONFIG], -[AC_REQUIRE([LT_PROG_GCJ])dnl -AC_LANG_SAVE - -# Source file extension for Java test sources. -ac_ext=java - -# Object file extension for compiled Java test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="class foo {}" - -# Code to be used in simple link tests -lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. -_LT_TAG_COMPILER - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -# Allow CC to be a program name with arguments. -lt_save_CC=$CC -lt_save_CFLAGS=$CFLAGS -lt_save_GCC=$GCC -GCC=yes -CC=${GCJ-"gcj"} -CFLAGS=$GCJFLAGS -compiler=$CC -_LT_TAGVAR(compiler, $1)=$CC -_LT_TAGVAR(LD, $1)="$LD" -_LT_CC_BASENAME([$compiler]) - -# GCJ did not exist at the time GCC didn't implicitly link libc in. -_LT_TAGVAR(archive_cmds_need_lc, $1)=no - -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds - -## CAVEAT EMPTOR: -## There is no encapsulation within the following macros, do not change -## the running order or otherwise move them around unless you know exactly -## what you are doing... -if test -n "$compiler"; then - _LT_COMPILER_NO_RTTI($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) -fi - -AC_LANG_RESTORE - -GCC=$lt_save_GCC -CC=$lt_save_CC -CFLAGS=$lt_save_CFLAGS -])# _LT_LANG_GCJ_CONFIG - - -# _LT_LANG_GO_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for the GNU Go compiler -# are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_GO_CONFIG], -[AC_REQUIRE([LT_PROG_GO])dnl -AC_LANG_SAVE - -# Source file extension for Go test sources. -ac_ext=go - -# Object file extension for compiled Go test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="package main; func main() { }" - -# Code to be used in simple link tests -lt_simple_link_test_code='package main; func main() { }' - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. -_LT_TAG_COMPILER - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -# Allow CC to be a program name with arguments. -lt_save_CC=$CC -lt_save_CFLAGS=$CFLAGS -lt_save_GCC=$GCC -GCC=yes -CC=${GOC-"gccgo"} -CFLAGS=$GOFLAGS -compiler=$CC -_LT_TAGVAR(compiler, $1)=$CC -_LT_TAGVAR(LD, $1)="$LD" -_LT_CC_BASENAME([$compiler]) - -# Go did not exist at the time GCC didn't implicitly link libc in. -_LT_TAGVAR(archive_cmds_need_lc, $1)=no - -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds - -## CAVEAT EMPTOR: -## There is no encapsulation within the following macros, do not change -## the running order or otherwise move them around unless you know exactly -## what you are doing... -if test -n "$compiler"; then - _LT_COMPILER_NO_RTTI($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) -fi - -AC_LANG_RESTORE - -GCC=$lt_save_GCC -CC=$lt_save_CC -CFLAGS=$lt_save_CFLAGS -])# _LT_LANG_GO_CONFIG - - -# _LT_LANG_RC_CONFIG([TAG]) -# ------------------------- -# Ensure that the configuration variables for the Windows resource compiler -# are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_RC_CONFIG], -[AC_REQUIRE([LT_PROG_RC])dnl -AC_LANG_SAVE - -# Source file extension for RC test sources. -ac_ext=rc - -# Object file extension for compiled RC test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' - -# Code to be used in simple link tests -lt_simple_link_test_code="$lt_simple_compile_test_code" - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. -_LT_TAG_COMPILER - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -# Allow CC to be a program name with arguments. -lt_save_CC="$CC" -lt_save_CFLAGS=$CFLAGS -lt_save_GCC=$GCC -GCC= -CC=${RC-"windres"} -CFLAGS= -compiler=$CC -_LT_TAGVAR(compiler, $1)=$CC -_LT_CC_BASENAME([$compiler]) -_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes - -if test -n "$compiler"; then - : - _LT_CONFIG($1) -fi - -GCC=$lt_save_GCC -AC_LANG_RESTORE -CC=$lt_save_CC -CFLAGS=$lt_save_CFLAGS -])# _LT_LANG_RC_CONFIG - - -# LT_PROG_GCJ -# ----------- -AC_DEFUN([LT_PROG_GCJ], -[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], - [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], - [AC_CHECK_TOOL(GCJ, gcj,) - test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" - AC_SUBST(GCJFLAGS)])])[]dnl -]) - -# Old name: -AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([LT_AC_PROG_GCJ], []) - - -# LT_PROG_GO -# ---------- -AC_DEFUN([LT_PROG_GO], -[AC_CHECK_TOOL(GOC, gccgo,) -]) - - -# LT_PROG_RC -# ---------- -AC_DEFUN([LT_PROG_RC], -[AC_CHECK_TOOL(RC, windres,) -]) - -# Old name: -AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([LT_AC_PROG_RC], []) - - -# _LT_DECL_EGREP -# -------------- -# If we don't have a new enough Autoconf to choose the best grep -# available, choose the one first in the user's PATH. -m4_defun([_LT_DECL_EGREP], -[AC_REQUIRE([AC_PROG_EGREP])dnl -AC_REQUIRE([AC_PROG_FGREP])dnl -test -z "$GREP" && GREP=grep -_LT_DECL([], [GREP], [1], [A grep program that handles long lines]) -_LT_DECL([], [EGREP], [1], [An ERE matcher]) -_LT_DECL([], [FGREP], [1], [A literal string matcher]) -dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too -AC_SUBST([GREP]) -]) - - -# _LT_DECL_OBJDUMP -# -------------- -# If we don't have a new enough Autoconf to choose the best objdump -# available, choose the one first in the user's PATH. -m4_defun([_LT_DECL_OBJDUMP], -[AC_CHECK_TOOL(OBJDUMP, objdump, false) -test -z "$OBJDUMP" && OBJDUMP=objdump -_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) -AC_SUBST([OBJDUMP]) -]) - -# _LT_DECL_DLLTOOL -# ---------------- -# Ensure DLLTOOL variable is set. -m4_defun([_LT_DECL_DLLTOOL], -[AC_CHECK_TOOL(DLLTOOL, dlltool, false) -test -z "$DLLTOOL" && DLLTOOL=dlltool -_LT_DECL([], [DLLTOOL], [1], [DLL creation program]) -AC_SUBST([DLLTOOL]) -]) - -# _LT_DECL_SED -# ------------ -# Check for a fully-functional sed program, that truncates -# as few characters as possible. Prefer GNU sed if found. -m4_defun([_LT_DECL_SED], -[AC_PROG_SED -test -z "$SED" && SED=sed -Xsed="$SED -e 1s/^X//" -_LT_DECL([], [SED], [1], [A sed program that does not truncate output]) -_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], - [Sed that helps us avoid accidentally triggering echo(1) options like -n]) -])# _LT_DECL_SED - -m4_ifndef([AC_PROG_SED], [ -############################################################ -# NOTE: This macro has been submitted for inclusion into # -# GNU Autoconf as AC_PROG_SED. When it is available in # -# a released version of Autoconf we should remove this # -# macro and use it instead. # -############################################################ - -m4_defun([AC_PROG_SED], -[AC_MSG_CHECKING([for a sed that does not truncate output]) -AC_CACHE_VAL(lt_cv_path_SED, -[# Loop through the user's path and test for sed and gsed. -# Then use that list of sed's as ones to test for truncation. -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for lt_ac_prog in sed gsed; do - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then - lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" - fi - done - done -done -IFS=$as_save_IFS -lt_ac_max=0 -lt_ac_count=0 -# Add /usr/xpg4/bin/sed as it is typically found on Solaris -# along with /bin/sed that truncates output. -for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do - test ! -f $lt_ac_sed && continue - cat /dev/null > conftest.in - lt_ac_count=0 - echo $ECHO_N "0123456789$ECHO_C" >conftest.in - # Check for GNU sed and select it if it is found. - if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then - lt_cv_path_SED=$lt_ac_sed - break - fi - while true; do - cat conftest.in conftest.in >conftest.tmp - mv conftest.tmp conftest.in - cp conftest.in conftest.nl - echo >>conftest.nl - $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break - cmp -s conftest.out conftest.nl || break - # 10000 chars as input seems more than enough - test $lt_ac_count -gt 10 && break - lt_ac_count=`expr $lt_ac_count + 1` - if test $lt_ac_count -gt $lt_ac_max; then - lt_ac_max=$lt_ac_count - lt_cv_path_SED=$lt_ac_sed - fi - done -done -]) -SED=$lt_cv_path_SED -AC_SUBST([SED]) -AC_MSG_RESULT([$SED]) -])#AC_PROG_SED -])#m4_ifndef - -# Old name: -AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([LT_AC_PROG_SED], []) - - -# _LT_CHECK_SHELL_FEATURES -# ------------------------ -# Find out whether the shell is Bourne or XSI compatible, -# or has some other useful features. -m4_defun([_LT_CHECK_SHELL_FEATURES], -[AC_MSG_CHECKING([whether the shell understands some XSI constructs]) -# Try some XSI features -xsi_shell=no -( _lt_dummy="a/b/c" - test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ - = c,a/b,b/c, \ - && eval 'test $(( 1 + 1 )) -eq 2 \ - && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ - && xsi_shell=yes -AC_MSG_RESULT([$xsi_shell]) -_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) - -AC_MSG_CHECKING([whether the shell understands "+="]) -lt_shell_append=no -( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ - >/dev/null 2>&1 \ - && lt_shell_append=yes -AC_MSG_RESULT([$lt_shell_append]) -_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) - -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - lt_unset=unset -else - lt_unset=false -fi -_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl - -# test EBCDIC or ASCII -case `echo X|tr X '\101'` in - A) # ASCII based system - # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr - lt_SP2NL='tr \040 \012' - lt_NL2SP='tr \015\012 \040\040' - ;; - *) # EBCDIC based system - lt_SP2NL='tr \100 \n' - lt_NL2SP='tr \r\n \100\100' - ;; -esac -_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl -_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl -])# _LT_CHECK_SHELL_FEATURES - - -# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY) -# ------------------------------------------------------ -# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and -# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY. -m4_defun([_LT_PROG_FUNCTION_REPLACE], -[dnl { -sed -e '/^$1 ()$/,/^} # $1 /c\ -$1 ()\ -{\ -m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1]) -} # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: -]) - - -# _LT_PROG_REPLACE_SHELLFNS -# ------------------------- -# Replace existing portable implementations of several shell functions with -# equivalent extended shell implementations where those features are available.. -m4_defun([_LT_PROG_REPLACE_SHELLFNS], -[if test x"$xsi_shell" = xyes; then - _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac]) - - _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl - func_basename_result="${1##*/}"]) - - _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac - func_basename_result="${1##*/}"]) - - _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl - # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are - # positional parameters, so assign one to ordinary parameter first. - func_stripname_result=${3} - func_stripname_result=${func_stripname_result#"${1}"} - func_stripname_result=${func_stripname_result%"${2}"}]) - - _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl - func_split_long_opt_name=${1%%=*} - func_split_long_opt_arg=${1#*=}]) - - _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl - func_split_short_opt_arg=${1#??} - func_split_short_opt_name=${1%"$func_split_short_opt_arg"}]) - - _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl - case ${1} in - *.lo) func_lo2o_result=${1%.lo}.${objext} ;; - *) func_lo2o_result=${1} ;; - esac]) - - _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo]) - - _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))]) - - _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}]) -fi - -if test x"$lt_shell_append" = xyes; then - _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"]) - - _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl - func_quote_for_eval "${2}" -dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \ - eval "${1}+=\\\\ \\$func_quote_for_eval_result"]) - - # Save a `func_append' function call where possible by direct use of '+=' - sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") - test 0 -eq $? || _lt_function_replace_fail=: -else - # Save a `func_append' function call even when '+=' is not available - sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") - test 0 -eq $? || _lt_function_replace_fail=: -fi - -if test x"$_lt_function_replace_fail" = x":"; then - AC_MSG_WARN([Unable to substitute extended shell functions in $ofile]) -fi -]) - -# _LT_PATH_CONVERSION_FUNCTIONS -# ----------------------------- -# Determine which file name conversion functions should be used by -# func_to_host_file (and, implicitly, by func_to_host_path). These are needed -# for certain cross-compile configurations and native mingw. -m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -AC_MSG_CHECKING([how to convert $build file names to $host format]) -AC_CACHE_VAL(lt_cv_to_host_file_cmd, -[case $host in - *-*-mingw* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 - ;; - *-*-cygwin* ) - lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 - ;; - * ) # otherwise, assume *nix - lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 - ;; - esac - ;; - *-*-cygwin* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin - ;; - *-*-cygwin* ) - lt_cv_to_host_file_cmd=func_convert_file_noop - ;; - * ) # otherwise, assume *nix - lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin - ;; - esac - ;; - * ) # unhandled hosts (and "normal" native builds) - lt_cv_to_host_file_cmd=func_convert_file_noop - ;; -esac -]) -to_host_file_cmd=$lt_cv_to_host_file_cmd -AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) -_LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], - [0], [convert $build file names to $host format])dnl - -AC_MSG_CHECKING([how to convert $build file names to toolchain format]) -AC_CACHE_VAL(lt_cv_to_tool_file_cmd, -[#assume ordinary cross tools, or native build. -lt_cv_to_tool_file_cmd=func_convert_file_noop -case $host in - *-*-mingw* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 - ;; - esac - ;; -esac -]) -to_tool_file_cmd=$lt_cv_to_tool_file_cmd -AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) -_LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], - [0], [convert $build files to toolchain format])dnl -])# _LT_PATH_CONVERSION_FUNCTIONS diff --git a/libs/apr/build/lineends.pl b/libs/apr/build/lineends.pl deleted file mode 100644 index 3e3067f7..00000000 --- a/libs/apr/build/lineends.pl +++ /dev/null @@ -1,150 +0,0 @@ -#!/usr/local/bin/perl -# -# Heuristically converts line endings to the current OS's preferred format -# -# All existing line endings must be identical (e.g. lf's only, or even -# the accedental cr.cr.lf sequence.) If some lines end lf, and others as -# cr.lf, the file is presumed binary. If the cr character appears anywhere -# except prefixed to an lf, the file is presumed binary. If there is no -# change in the resulting file size, or the file is binary, the conversion -# is discarded. -# -# Todo: Handle NULL stdin characters gracefully. -# - -use IO::File; -use File::Find; - -# The ignore list is '-' seperated, with this leading hyphen and -# trailing hyphens in ever concatinated list below. -$ignore = "-"; - -# Image formats -$ignore .= "gif-jpg-jpeg-png-ico-bmp-"; - -# Archive formats -$ignore .= "tar-gz-z-zip-jar-war-bz2-tgz-"; - -# Many document formats -$ignore .= "eps-psd-pdf-chm-ai-"; - -# Some encodings -$ignore .= "ucs2-ucs4-"; - -# Some binary objects -$ignore .= "class-so-dll-exe-obj-lib-a-o-lo-slo-sl-dylib-"; - -# Some build env files -$ignore .= "mcp-xdc-ncb-opt-pdb-ilk-exp-res-pch-idb-sbr-"; - -$preservedate = 1; - -$forceending = 0; - -$givenpaths = 0; - -$notnative = 0; - -while (defined @ARGV[0]) { - if (@ARGV[0] eq '--touch') { - $preservedate = 0; - } - elsif (@ARGV[0] eq '--nocr') { - $notnative = -1; - } - elsif (@ARGV[0] eq '--cr') { - $notnative = 1; - } - elsif (@ARGV[0] eq '--force') { - $forceending = 1; - } - elsif (@ARGV[0] eq '--FORCE') { - $forceending = 2; - } - elsif (@ARGV[0] =~ m/^-/) { - die "What is " . @ARGV[0] . " supposed to mean?\n\n" - . "Syntax:\t$0 [option()s] [path(s)]\n\n" . <<'OUTCH' -Where: paths specifies the top level directory to convert (default of '.') - options are; - - --cr keep/add one ^M - --nocr remove ^M's - --touch the datestamp (default: keeps date/attribs) - --force mismatched corrections (unbalanced ^M's) - --FORCE all files regardless of file name! - -OUTCH - } - else { - find(\&totxt, @ARGV[0]); - print "scanned " . @ARGV[0] . "\n"; - $givenpaths = 1; - } - shift @ARGV; -} - -if (!$givenpaths) { - find(\&totxt, '.'); - print "did .\n"; -} - -sub totxt { - $oname = $_; - $tname = '.#' . $_; - if (!-f) { - return; - } - @exts = split /\./; - if ($forceending < 2) { - while ($#exts && ($ext = pop(@exts))) { - if ($ignore =~ m|-$ext-|i) { - return; - } - } - } - return if ($File::Find::dir =~ m|^(.+/)?.svn(/.+)?$|); - @ostat = stat($oname); - $srcfl = new IO::File $oname, "r" or die; - $dstfl = new IO::File $tname, "w" or die; - binmode $srcfl; - if ($notnative) { - binmode $dstfl; - } - undef $t; - while (<$srcfl>) { - if (s/(\r*)\n$/\n/) { - $n = length $1; - if (!defined $t) { - $t = $n; - } - if (!$forceending && (($n != $t) || m/\r/)) { - print "mismatch in " .$oname. ":" .$n. " expected " .$t. "\n"; - undef $t; - last; - } - elsif ($notnative > 0) { - s/\n$/\r\n/; - } - } - print $dstfl $_; - } - if (defined $t && (tell $srcfl == tell $dstfl)) { - undef $t; - } - undef $srcfl; - undef $dstfl; - if (defined $t) { - unlink $oname or die; - rename $tname, $oname or die; - @anames = ($oname); - if ($preservedate) { - utime $ostat[9], $ostat[9], @anames; - } - chmod $ostat[2] & 07777, @anames; - chown $ostat[5], $ostat[6], @anames; - print "Converted file " . $oname . " to text in " . $File::Find::dir . "\n"; - } - else { - unlink $tname or die; - } -} diff --git a/libs/apr/build/ltmain.sh b/libs/apr/build/ltmain.sh deleted file mode 100644 index 63ae69dc..00000000 --- a/libs/apr/build/ltmain.sh +++ /dev/null @@ -1,9655 +0,0 @@ - -# libtool (GNU libtool) 2.4.2 -# Written by Gordon Matzigkeit , 1996 - -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, -# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. -# This is free software; see the source for copying conditions. There is NO -# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -# GNU Libtool 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. -# -# As a special exception to the GNU General Public License, -# if you distribute this file as part of a program or library that -# is built using GNU Libtool, you may include this file under the -# same distribution terms that you use for the rest of that program. -# -# GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy -# can be downloaded from http://www.gnu.org/licenses/gpl.html, -# or obtained by writing to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -# Usage: $progname [OPTION]... [MODE-ARG]... -# -# Provide generalized library-building support services. -# -# --config show all configuration variables -# --debug enable verbose shell tracing -# -n, --dry-run display commands without modifying any files -# --features display basic configuration information and exit -# --mode=MODE use operation mode MODE -# --preserve-dup-deps don't remove duplicate dependency libraries -# --quiet, --silent don't print informational messages -# --no-quiet, --no-silent -# print informational messages (default) -# --no-warn don't display warning messages -# --tag=TAG use configuration variables from tag TAG -# -v, --verbose print more informational messages than default -# --no-verbose don't print the extra informational messages -# --version print version information -# -h, --help, --help-all print short, long, or detailed help message -# -# MODE must be one of the following: -# -# clean remove files from the build directory -# compile compile a source file into a libtool object -# execute automatically set library path, then run a program -# finish complete the installation of libtool libraries -# install install libraries or executables -# link create a library or an executable -# uninstall remove libraries from an installed directory -# -# MODE-ARGS vary depending on the MODE. When passed as first option, -# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. -# Try `$progname --help --mode=MODE' for a more detailed description of MODE. -# -# When reporting a bug, please describe a test case to reproduce it and -# include the following information: -# -# host-triplet: $host -# shell: $SHELL -# compiler: $LTCC -# compiler flags: $LTCFLAGS -# linker: $LD (gnu? $with_gnu_ld) -# $progname: (GNU libtool) 2.4.2 -# automake: $automake_version -# autoconf: $autoconf_version -# -# Report bugs to . -# GNU libtool home page: . -# General help using GNU software: . - -PROGRAM=libtool -PACKAGE=libtool -VERSION=2.4.2 -TIMESTAMP="" -package_revision=1.3337 - -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac -fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh - -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -$1 -_LTECHO_EOF' -} - -# NLS nuisances: We save the old values to restore during execute mode. -lt_user_locale= -lt_safe_locale= -for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES -do - eval "if test \"\${$lt_var+set}\" = set; then - save_$lt_var=\$$lt_var - $lt_var=C - export $lt_var - lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" - lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" - fi" -done -LC_ALL=C -LANGUAGE=C -export LANGUAGE LC_ALL - -$lt_unset CDPATH - - -# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh -# is ksh but when the shell is invoked as "sh" and the current value of -# the _XPG environment variable is not equal to 1 (one), the special -# positional parameter $0, within a function call, is the name of the -# function. -progpath="$0" - - - -: ${CP="cp -f"} -test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} -: ${MAKE="make"} -: ${MKDIR="mkdir"} -: ${MV="mv -f"} -: ${RM="rm -f"} -: ${SHELL="${CONFIG_SHELL-/bin/sh}"} -: ${Xsed="$SED -e 1s/^X//"} - -# Global variables: -EXIT_SUCCESS=0 -EXIT_FAILURE=1 -EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. -EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. - -exit_status=$EXIT_SUCCESS - -# Make sure IFS has a sensible default -lt_nl=' -' -IFS=" $lt_nl" - -dirname="s,/[^/]*$,," -basename="s,^.*/,," - -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" - fi -} # func_dirname may be replaced by extended shell implementation - - -# func_basename file -func_basename () -{ - func_basename_result=`$ECHO "${1}" | $SED "$basename"` -} # func_basename may be replaced by extended shell implementation - - -# func_dirname_and_basename file append nondir_replacement -# perform func_basename and func_dirname in a single function -# call: -# dirname: Compute the dirname of FILE. If nonempty, -# add APPEND to the result, otherwise set result -# to NONDIR_REPLACEMENT. -# value returned in "$func_dirname_result" -# basename: Compute filename of FILE. -# value retuned in "$func_basename_result" -# Implementation must be kept synchronized with func_dirname -# and func_basename. For efficiency, we do not delegate to -# those functions but instead duplicate the functionality here. -func_dirname_and_basename () -{ - # Extract subdirectory from the argument. - func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" - fi - func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` -} # func_dirname_and_basename may be replaced by extended shell implementation - - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -# func_strip_suffix prefix name -func_stripname () -{ - case ${2} in - .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; - esac -} # func_stripname may be replaced by extended shell implementation - - -# These SED scripts presuppose an absolute path with a trailing slash. -pathcar='s,^/\([^/]*\).*$,\1,' -pathcdr='s,^/[^/]*,,' -removedotparts=':dotsl - s@/\./@/@g - t dotsl - s,/\.$,/,' -collapseslashes='s@/\{1,\}@/@g' -finalslash='s,/*$,/,' - -# func_normal_abspath PATH -# Remove doubled-up and trailing slashes, "." path components, -# and cancel out any ".." path components in PATH after making -# it an absolute path. -# value returned in "$func_normal_abspath_result" -func_normal_abspath () -{ - # Start from root dir and reassemble the path. - func_normal_abspath_result= - func_normal_abspath_tpath=$1 - func_normal_abspath_altnamespace= - case $func_normal_abspath_tpath in - "") - # Empty path, that just means $cwd. - func_stripname '' '/' "`pwd`" - func_normal_abspath_result=$func_stripname_result - return - ;; - # The next three entries are used to spot a run of precisely - # two leading slashes without using negated character classes; - # we take advantage of case's first-match behaviour. - ///*) - # Unusual form of absolute path, do nothing. - ;; - //*) - # Not necessarily an ordinary path; POSIX reserves leading '//' - # and for example Cygwin uses it to access remote file shares - # over CIFS/SMB, so we conserve a leading double slash if found. - func_normal_abspath_altnamespace=/ - ;; - /*) - # Absolute path, do nothing. - ;; - *) - # Relative path, prepend $cwd. - func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath - ;; - esac - # Cancel out all the simple stuff to save iterations. We also want - # the path to end with a slash for ease of parsing, so make sure - # there is one (and only one) here. - func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` - while :; do - # Processed it all yet? - if test "$func_normal_abspath_tpath" = / ; then - # If we ascended to the root using ".." the result may be empty now. - if test -z "$func_normal_abspath_result" ; then - func_normal_abspath_result=/ - fi - break - fi - func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$pathcar"` - func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$pathcdr"` - # Figure out what to do with it - case $func_normal_abspath_tcomponent in - "") - # Trailing empty path component, ignore it. - ;; - ..) - # Parent dir; strip last assembled component from result. - func_dirname "$func_normal_abspath_result" - func_normal_abspath_result=$func_dirname_result - ;; - *) - # Actual path component, append it. - func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent - ;; - esac - done - # Restore leading double-slash if one was found on entry. - func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result -} - -# func_relative_path SRCDIR DSTDIR -# generates a relative path from SRCDIR to DSTDIR, with a trailing -# slash if non-empty, suitable for immediately appending a filename -# without needing to append a separator. -# value returned in "$func_relative_path_result" -func_relative_path () -{ - func_relative_path_result= - func_normal_abspath "$1" - func_relative_path_tlibdir=$func_normal_abspath_result - func_normal_abspath "$2" - func_relative_path_tbindir=$func_normal_abspath_result - - # Ascend the tree starting from libdir - while :; do - # check if we have found a prefix of bindir - case $func_relative_path_tbindir in - $func_relative_path_tlibdir) - # found an exact match - func_relative_path_tcancelled= - break - ;; - $func_relative_path_tlibdir*) - # found a matching prefix - func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" - func_relative_path_tcancelled=$func_stripname_result - if test -z "$func_relative_path_result"; then - func_relative_path_result=. - fi - break - ;; - *) - func_dirname $func_relative_path_tlibdir - func_relative_path_tlibdir=${func_dirname_result} - if test "x$func_relative_path_tlibdir" = x ; then - # Have to descend all the way to the root! - func_relative_path_result=../$func_relative_path_result - func_relative_path_tcancelled=$func_relative_path_tbindir - break - fi - func_relative_path_result=../$func_relative_path_result - ;; - esac - done - - # Now calculate path; take care to avoid doubling-up slashes. - func_stripname '' '/' "$func_relative_path_result" - func_relative_path_result=$func_stripname_result - func_stripname '/' '/' "$func_relative_path_tcancelled" - if test "x$func_stripname_result" != x ; then - func_relative_path_result=${func_relative_path_result}/${func_stripname_result} - fi - - # Normalisation. If bindir is libdir, return empty string, - # else relative path ending with a slash; either way, target - # file name can be directly appended. - if test ! -z "$func_relative_path_result"; then - func_stripname './' '' "$func_relative_path_result/" - func_relative_path_result=$func_stripname_result - fi -} - -# The name of this program: -func_dirname_and_basename "$progpath" -progname=$func_basename_result - -# Make sure we have an absolute path for reexecution: -case $progpath in - [\\/]*|[A-Za-z]:\\*) ;; - *[\\/]*) - progdir=$func_dirname_result - progdir=`cd "$progdir" && pwd` - progpath="$progdir/$progname" - ;; - *) - save_IFS="$IFS" - IFS=${PATH_SEPARATOR-:} - for progdir in $PATH; do - IFS="$save_IFS" - test -x "$progdir/$progname" && break - done - IFS="$save_IFS" - test -n "$progdir" || progdir=`pwd` - progpath="$progdir/$progname" - ;; -esac - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed="${SED}"' -e 1s/^X//' -sed_quote_subst='s/\([`"$\\]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\(["`\\]\)/\\\1/g' - -# Sed substitution that turns a string into a regex matching for the -# string literally. -sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' - -# Sed substitution that converts a w32 file name or path -# which contains forward slashes, into one that contains -# (escaped) backslashes. A very naive implementation. -lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' - -# Re-`\' parameter expansions in output of double_quote_subst that were -# `\'-ed in input to the same. If an odd number of `\' preceded a '$' -# in input to double_quote_subst, that '$' was protected from expansion. -# Since each input `\' is now two `\'s, look for any number of runs of -# four `\'s followed by two `\'s and then a '$'. `\' that '$'. -bs='\\' -bs2='\\\\' -bs4='\\\\\\\\' -dollar='\$' -sed_double_backslash="\ - s/$bs4/&\\ -/g - s/^$bs2$dollar/$bs&/ - s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g - s/\n//g" - -# Standard options: -opt_dry_run=false -opt_help=false -opt_quiet=false -opt_verbose=false -opt_warning=: - -# func_echo arg... -# Echo program name prefixed message, along with the current mode -# name if it has been set yet. -func_echo () -{ - $ECHO "$progname: ${opt_mode+$opt_mode: }$*" -} - -# func_verbose arg... -# Echo program name prefixed message in verbose mode only. -func_verbose () -{ - $opt_verbose && func_echo ${1+"$@"} - - # A bug in bash halts the script if the last line of a function - # fails when set -e is in force, so we need another command to - # work around that: - : -} - -# func_echo_all arg... -# Invoke $ECHO with all args, space-separated. -func_echo_all () -{ - $ECHO "$*" -} - -# func_error arg... -# Echo program name prefixed message to standard error. -func_error () -{ - $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 -} - -# func_warning arg... -# Echo program name prefixed warning message to standard error. -func_warning () -{ - $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 - - # bash bug again: - : -} - -# func_fatal_error arg... -# Echo program name prefixed message to standard error, and exit. -func_fatal_error () -{ - func_error ${1+"$@"} - exit $EXIT_FAILURE -} - -# func_fatal_help arg... -# Echo program name prefixed message to standard error, followed by -# a help hint, and exit. -func_fatal_help () -{ - func_error ${1+"$@"} - func_fatal_error "$help" -} -help="Try \`$progname --help' for more information." ## default - - -# func_grep expression filename -# Check whether EXPRESSION matches any line of FILENAME, without output. -func_grep () -{ - $GREP "$1" "$2" >/dev/null 2>&1 -} - - -# func_mkdir_p directory-path -# Make sure the entire path to DIRECTORY-PATH is available. -func_mkdir_p () -{ - my_directory_path="$1" - my_dir_list= - - if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then - - # Protect directory names starting with `-' - case $my_directory_path in - -*) my_directory_path="./$my_directory_path" ;; - esac - - # While some portion of DIR does not yet exist... - while test ! -d "$my_directory_path"; do - # ...make a list in topmost first order. Use a colon delimited - # list incase some portion of path contains whitespace. - my_dir_list="$my_directory_path:$my_dir_list" - - # If the last portion added has no slash in it, the list is done - case $my_directory_path in */*) ;; *) break ;; esac - - # ...otherwise throw away the child directory and loop - my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` - done - my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` - - save_mkdir_p_IFS="$IFS"; IFS=':' - for my_dir in $my_dir_list; do - IFS="$save_mkdir_p_IFS" - # mkdir can fail with a `File exist' error if two processes - # try to create one of the directories concurrently. Don't - # stop in that case! - $MKDIR "$my_dir" 2>/dev/null || : - done - IFS="$save_mkdir_p_IFS" - - # Bail out if we (or some other process) failed to create a directory. - test -d "$my_directory_path" || \ - func_fatal_error "Failed to create \`$1'" - fi -} - - -# func_mktempdir [string] -# Make a temporary directory that won't clash with other running -# libtool processes, and avoids race conditions if possible. If -# given, STRING is the basename for that directory. -func_mktempdir () -{ - my_template="${TMPDIR-/tmp}/${1-$progname}" - - if test "$opt_dry_run" = ":"; then - # Return a directory name, but don't create it in dry-run mode - my_tmpdir="${my_template}-$$" - else - - # If mktemp works, use that first and foremost - my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` - - if test ! -d "$my_tmpdir"; then - # Failing that, at least try and use $RANDOM to avoid a race - my_tmpdir="${my_template}-${RANDOM-0}$$" - - save_mktempdir_umask=`umask` - umask 0077 - $MKDIR "$my_tmpdir" - umask $save_mktempdir_umask - fi - - # If we're not in dry-run mode, bomb out on failure - test -d "$my_tmpdir" || \ - func_fatal_error "cannot create temporary directory \`$my_tmpdir'" - fi - - $ECHO "$my_tmpdir" -} - - -# func_quote_for_eval arg -# Aesthetically quote ARG to be evaled later. -# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT -# is double-quoted, suitable for a subsequent eval, whereas -# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters -# which are still active within double quotes backslashified. -func_quote_for_eval () -{ - case $1 in - *[\\\`\"\$]*) - func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; - *) - func_quote_for_eval_unquoted_result="$1" ;; - esac - - case $func_quote_for_eval_unquoted_result in - # Double-quote args containing shell metacharacters to delay - # word splitting, command substitution and and variable - # expansion for a subsequent eval. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" - ;; - *) - func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" - esac -} - - -# func_quote_for_expand arg -# Aesthetically quote ARG to be evaled later; same as above, -# but do not quote variable references. -func_quote_for_expand () -{ - case $1 in - *[\\\`\"]*) - my_arg=`$ECHO "$1" | $SED \ - -e "$double_quote_subst" -e "$sed_double_backslash"` ;; - *) - my_arg="$1" ;; - esac - - case $my_arg in - # Double-quote args containing shell metacharacters to delay - # word splitting and command substitution for a subsequent eval. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - my_arg="\"$my_arg\"" - ;; - esac - - func_quote_for_expand_result="$my_arg" -} - - -# func_show_eval cmd [fail_exp] -# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is -# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP -# is given, then evaluate it. -func_show_eval () -{ - my_cmd="$1" - my_fail_exp="${2-:}" - - ${opt_silent-false} || { - func_quote_for_expand "$my_cmd" - eval "func_echo $func_quote_for_expand_result" - } - - if ${opt_dry_run-false}; then :; else - eval "$my_cmd" - my_status=$? - if test "$my_status" -eq 0; then :; else - eval "(exit $my_status); $my_fail_exp" - fi - fi -} - - -# func_show_eval_locale cmd [fail_exp] -# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is -# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP -# is given, then evaluate it. Use the saved locale for evaluation. -func_show_eval_locale () -{ - my_cmd="$1" - my_fail_exp="${2-:}" - - ${opt_silent-false} || { - func_quote_for_expand "$my_cmd" - eval "func_echo $func_quote_for_expand_result" - } - - if ${opt_dry_run-false}; then :; else - eval "$lt_user_locale - $my_cmd" - my_status=$? - eval "$lt_safe_locale" - if test "$my_status" -eq 0; then :; else - eval "(exit $my_status); $my_fail_exp" - fi - fi -} - -# func_tr_sh -# Turn $1 into a string suitable for a shell variable name. -# Result is stored in $func_tr_sh_result. All characters -# not in the set a-zA-Z0-9_ are replaced with '_'. Further, -# if $1 begins with a digit, a '_' is prepended as well. -func_tr_sh () -{ - case $1 in - [0-9]* | *[!a-zA-Z0-9_]*) - func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` - ;; - * ) - func_tr_sh_result=$1 - ;; - esac -} - - -# func_version -# Echo version message to standard output and exit. -func_version () -{ - $opt_debug - - $SED -n '/(C)/!b go - :more - /\./!{ - N - s/\n# / / - b more - } - :go - /^# '$PROGRAM' (GNU /,/# warranty; / { - s/^# // - s/^# *$// - s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ - p - }' < "$progpath" - exit $? -} - -# func_usage -# Echo short help message to standard output and exit. -func_usage () -{ - $opt_debug - - $SED -n '/^# Usage:/,/^# *.*--help/ { - s/^# // - s/^# *$// - s/\$progname/'$progname'/ - p - }' < "$progpath" - echo - $ECHO "run \`$progname --help | more' for full usage" - exit $? -} - -# func_help [NOEXIT] -# Echo long help message to standard output and exit, -# unless 'noexit' is passed as argument. -func_help () -{ - $opt_debug - - $SED -n '/^# Usage:/,/# Report bugs to/ { - :print - s/^# // - s/^# *$// - s*\$progname*'$progname'* - s*\$host*'"$host"'* - s*\$SHELL*'"$SHELL"'* - s*\$LTCC*'"$LTCC"'* - s*\$LTCFLAGS*'"$LTCFLAGS"'* - s*\$LD*'"$LD"'* - s/\$with_gnu_ld/'"$with_gnu_ld"'/ - s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ - s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ - p - d - } - /^# .* home page:/b print - /^# General help using/b print - ' < "$progpath" - ret=$? - if test -z "$1"; then - exit $ret - fi -} - -# func_missing_arg argname -# Echo program name prefixed message to standard error and set global -# exit_cmd. -func_missing_arg () -{ - $opt_debug - - func_error "missing argument for $1." - exit_cmd=exit -} - - -# func_split_short_opt shortopt -# Set func_split_short_opt_name and func_split_short_opt_arg shell -# variables after splitting SHORTOPT after the 2nd character. -func_split_short_opt () -{ - my_sed_short_opt='1s/^\(..\).*$/\1/;q' - my_sed_short_rest='1s/^..\(.*\)$/\1/;q' - - func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` - func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` -} # func_split_short_opt may be replaced by extended shell implementation - - -# func_split_long_opt longopt -# Set func_split_long_opt_name and func_split_long_opt_arg shell -# variables after splitting LONGOPT at the `=' sign. -func_split_long_opt () -{ - my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' - my_sed_long_arg='1s/^--[^=]*=//' - - func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` - func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` -} # func_split_long_opt may be replaced by extended shell implementation - -exit_cmd=: - - - - - -magic="%%%MAGIC variable%%%" -magic_exe="%%%MAGIC EXE variable%%%" - -# Global variables. -nonopt= -preserve_args= -lo2o="s/\\.lo\$/.${objext}/" -o2lo="s/\\.${objext}\$/.lo/" -extracted_archives= -extracted_serial=0 - -# If this variable is set in any of the actions, the command in it -# will be execed at the end. This prevents here-documents from being -# left over by shells. -exec_cmd= - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "${1}=\$${1}\${2}" -} # func_append may be replaced by extended shell implementation - -# func_append_quoted var value -# Quote VALUE and append to the end of shell variable VAR, separated -# by a space. -func_append_quoted () -{ - func_quote_for_eval "${2}" - eval "${1}=\$${1}\\ \$func_quote_for_eval_result" -} # func_append_quoted may be replaced by extended shell implementation - - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=`expr "${@}"` -} # func_arith may be replaced by extended shell implementation - - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` -} # func_len may be replaced by extended shell implementation - - -# func_lo2o object -func_lo2o () -{ - func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` -} # func_lo2o may be replaced by extended shell implementation - - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` -} # func_xform may be replaced by extended shell implementation - - -# func_fatal_configuration arg... -# Echo program name prefixed message to standard error, followed by -# a configuration failure hint, and exit. -func_fatal_configuration () -{ - func_error ${1+"$@"} - func_error "See the $PACKAGE documentation for more information." - func_fatal_error "Fatal configuration error." -} - - -# func_config -# Display the configuration for all the tags in this script. -func_config () -{ - re_begincf='^# ### BEGIN LIBTOOL' - re_endcf='^# ### END LIBTOOL' - - # Default configuration. - $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" - - # Now print the configurations for the tags. - for tagname in $taglist; do - $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" - done - - exit $? -} - -# func_features -# Display the features supported by this script. -func_features () -{ - echo "host: $host" - if test "$build_libtool_libs" = yes; then - echo "enable shared libraries" - else - echo "disable shared libraries" - fi - if test "$build_old_libs" = yes; then - echo "enable static libraries" - else - echo "disable static libraries" - fi - - exit $? -} - -# func_enable_tag tagname -# Verify that TAGNAME is valid, and either flag an error and exit, or -# enable the TAGNAME tag. We also add TAGNAME to the global $taglist -# variable here. -func_enable_tag () -{ - # Global variable: - tagname="$1" - - re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" - re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" - sed_extractcf="/$re_begincf/,/$re_endcf/p" - - # Validate tagname. - case $tagname in - *[!-_A-Za-z0-9,/]*) - func_fatal_error "invalid tag name: $tagname" - ;; - esac - - # Don't test for the "default" C tag, as we know it's - # there but not specially marked. - case $tagname in - CC) ;; - *) - if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then - taglist="$taglist $tagname" - - # Evaluate the configuration. Be careful to quote the path - # and the sed script, to avoid splitting on whitespace, but - # also don't use non-portable quotes within backquotes within - # quotes we have to do it in 2 steps: - extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` - eval "$extractedcf" - else - func_error "ignoring unknown tag $tagname" - fi - ;; - esac -} - -# func_check_version_match -# Ensure that we are using m4 macros, and libtool script from the same -# release of libtool. -func_check_version_match () -{ - if test "$package_revision" != "$macro_revision"; then - if test "$VERSION" != "$macro_version"; then - if test -z "$macro_version"; then - cat >&2 <<_LT_EOF -$progname: Version mismatch error. This is $PACKAGE $VERSION, but the -$progname: definition of this LT_INIT comes from an older release. -$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION -$progname: and run autoconf again. -_LT_EOF - else - cat >&2 <<_LT_EOF -$progname: Version mismatch error. This is $PACKAGE $VERSION, but the -$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. -$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION -$progname: and run autoconf again. -_LT_EOF - fi - else - cat >&2 <<_LT_EOF -$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, -$progname: but the definition of this LT_INIT comes from revision $macro_revision. -$progname: You should recreate aclocal.m4 with macros from revision $package_revision -$progname: of $PACKAGE $VERSION and run autoconf again. -_LT_EOF - fi - - exit $EXIT_MISMATCH - fi -} - - -# Shorthand for --mode=foo, only valid as the first argument -case $1 in -clean|clea|cle|cl) - shift; set dummy --mode clean ${1+"$@"}; shift - ;; -compile|compil|compi|comp|com|co|c) - shift; set dummy --mode compile ${1+"$@"}; shift - ;; -execute|execut|execu|exec|exe|ex|e) - shift; set dummy --mode execute ${1+"$@"}; shift - ;; -finish|finis|fini|fin|fi|f) - shift; set dummy --mode finish ${1+"$@"}; shift - ;; -install|instal|insta|inst|ins|in|i) - shift; set dummy --mode install ${1+"$@"}; shift - ;; -link|lin|li|l) - shift; set dummy --mode link ${1+"$@"}; shift - ;; -uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) - shift; set dummy --mode uninstall ${1+"$@"}; shift - ;; -esac - - - -# Option defaults: -opt_debug=: -opt_dry_run=false -opt_config=false -opt_preserve_dup_deps=false -opt_features=false -opt_finish=false -opt_help=false -opt_help_all=false -opt_silent=: -opt_warning=: -opt_verbose=: -opt_silent=false -opt_verbose=false - - -# Parse options once, thoroughly. This comes as soon as possible in the -# script to make things like `--version' happen as quickly as we can. -{ - # this just eases exit handling - while test $# -gt 0; do - opt="$1" - shift - case $opt in - --debug|-x) opt_debug='set -x' - func_echo "enabling shell trace mode" - $opt_debug - ;; - --dry-run|--dryrun|-n) - opt_dry_run=: - ;; - --config) - opt_config=: -func_config - ;; - --dlopen|-dlopen) - optarg="$1" - opt_dlopen="${opt_dlopen+$opt_dlopen -}$optarg" - shift - ;; - --preserve-dup-deps) - opt_preserve_dup_deps=: - ;; - --features) - opt_features=: -func_features - ;; - --finish) - opt_finish=: -set dummy --mode finish ${1+"$@"}; shift - ;; - --help) - opt_help=: - ;; - --help-all) - opt_help_all=: -opt_help=': help-all' - ;; - --mode) - test $# = 0 && func_missing_arg $opt && break - optarg="$1" - opt_mode="$optarg" -case $optarg in - # Valid mode arguments: - clean|compile|execute|finish|install|link|relink|uninstall) ;; - - # Catch anything else as an error - *) func_error "invalid argument for $opt" - exit_cmd=exit - break - ;; -esac - shift - ;; - --no-silent|--no-quiet) - opt_silent=false -func_append preserve_args " $opt" - ;; - --no-warning|--no-warn) - opt_warning=false -func_append preserve_args " $opt" - ;; - --no-verbose) - opt_verbose=false -func_append preserve_args " $opt" - ;; - --silent|--quiet) - opt_silent=: -func_append preserve_args " $opt" - opt_verbose=false - ;; - --verbose|-v) - opt_verbose=: -func_append preserve_args " $opt" -opt_silent=false - ;; - --tag) - test $# = 0 && func_missing_arg $opt && break - optarg="$1" - opt_tag="$optarg" -func_append preserve_args " $opt $optarg" -func_enable_tag "$optarg" - shift - ;; - - -\?|-h) func_usage ;; - --help) func_help ;; - --version) func_version ;; - - # Separate optargs to long options: - --*=*) - func_split_long_opt "$opt" - set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} - shift - ;; - - # Separate non-argument short options: - -\?*|-h*|-n*|-v*) - func_split_short_opt "$opt" - set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} - shift - ;; - - --) break ;; - -*) func_fatal_help "unrecognized option \`$opt'" ;; - *) set dummy "$opt" ${1+"$@"}; shift; break ;; - esac - done - - # Validate options: - - # save first non-option argument - if test "$#" -gt 0; then - nonopt="$opt" - shift - fi - - # preserve --debug - test "$opt_debug" = : || func_append preserve_args " --debug" - - case $host in - *cygwin* | *mingw* | *pw32* | *cegcc*) - # don't eliminate duplications in $postdeps and $predeps - opt_duplicate_compiler_generated_deps=: - ;; - *) - opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps - ;; - esac - - $opt_help || { - # Sanity checks first: - func_check_version_match - - if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then - func_fatal_configuration "not configured to build any kind of library" - fi - - # Darwin sucks - eval std_shrext=\"$shrext_cmds\" - - # Only execute mode is allowed to have -dlopen flags. - if test -n "$opt_dlopen" && test "$opt_mode" != execute; then - func_error "unrecognized option \`-dlopen'" - $ECHO "$help" 1>&2 - exit $EXIT_FAILURE - fi - - # Change the help message to a mode-specific one. - generic_help="$help" - help="Try \`$progname --help --mode=$opt_mode' for more information." - } - - - # Bail if the options were screwed - $exit_cmd $EXIT_FAILURE -} - - - - -## ----------- ## -## Main. ## -## ----------- ## - -# func_lalib_p file -# True iff FILE is a libtool `.la' library or `.lo' object file. -# This function is only a basic sanity check; it will hardly flush out -# determined imposters. -func_lalib_p () -{ - test -f "$1" && - $SED -e 4q "$1" 2>/dev/null \ - | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 -} - -# func_lalib_unsafe_p file -# True iff FILE is a libtool `.la' library or `.lo' object file. -# This function implements the same check as func_lalib_p without -# resorting to external programs. To this end, it redirects stdin and -# closes it afterwards, without saving the original file descriptor. -# As a safety measure, use it only where a negative result would be -# fatal anyway. Works if `file' does not exist. -func_lalib_unsafe_p () -{ - lalib_p=no - if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then - for lalib_p_l in 1 2 3 4 - do - read lalib_p_line - case "$lalib_p_line" in - \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; - esac - done - exec 0<&5 5<&- - fi - test "$lalib_p" = yes -} - -# func_ltwrapper_script_p file -# True iff FILE is a libtool wrapper script -# This function is only a basic sanity check; it will hardly flush out -# determined imposters. -func_ltwrapper_script_p () -{ - func_lalib_p "$1" -} - -# func_ltwrapper_executable_p file -# True iff FILE is a libtool wrapper executable -# This function is only a basic sanity check; it will hardly flush out -# determined imposters. -func_ltwrapper_executable_p () -{ - func_ltwrapper_exec_suffix= - case $1 in - *.exe) ;; - *) func_ltwrapper_exec_suffix=.exe ;; - esac - $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 -} - -# func_ltwrapper_scriptname file -# Assumes file is an ltwrapper_executable -# uses $file to determine the appropriate filename for a -# temporary ltwrapper_script. -func_ltwrapper_scriptname () -{ - func_dirname_and_basename "$1" "" "." - func_stripname '' '.exe' "$func_basename_result" - func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" -} - -# func_ltwrapper_p file -# True iff FILE is a libtool wrapper script or wrapper executable -# This function is only a basic sanity check; it will hardly flush out -# determined imposters. -func_ltwrapper_p () -{ - func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" -} - - -# func_execute_cmds commands fail_cmd -# Execute tilde-delimited COMMANDS. -# If FAIL_CMD is given, eval that upon failure. -# FAIL_CMD may read-access the current command in variable CMD! -func_execute_cmds () -{ - $opt_debug - save_ifs=$IFS; IFS='~' - for cmd in $1; do - IFS=$save_ifs - eval cmd=\"$cmd\" - func_show_eval "$cmd" "${2-:}" - done - IFS=$save_ifs -} - - -# func_source file -# Source FILE, adding directory component if necessary. -# Note that it is not necessary on cygwin/mingw to append a dot to -# FILE even if both FILE and FILE.exe exist: automatic-append-.exe -# behavior happens only for exec(3), not for open(2)! Also, sourcing -# `FILE.' does not work on cygwin managed mounts. -func_source () -{ - $opt_debug - case $1 in - */* | *\\*) . "$1" ;; - *) . "./$1" ;; - esac -} - - -# func_resolve_sysroot PATH -# Replace a leading = in PATH with a sysroot. Store the result into -# func_resolve_sysroot_result -func_resolve_sysroot () -{ - func_resolve_sysroot_result=$1 - case $func_resolve_sysroot_result in - =*) - func_stripname '=' '' "$func_resolve_sysroot_result" - func_resolve_sysroot_result=$lt_sysroot$func_stripname_result - ;; - esac -} - -# func_replace_sysroot PATH -# If PATH begins with the sysroot, replace it with = and -# store the result into func_replace_sysroot_result. -func_replace_sysroot () -{ - case "$lt_sysroot:$1" in - ?*:"$lt_sysroot"*) - func_stripname "$lt_sysroot" '' "$1" - func_replace_sysroot_result="=$func_stripname_result" - ;; - *) - # Including no sysroot. - func_replace_sysroot_result=$1 - ;; - esac -} - -# func_infer_tag arg -# Infer tagged configuration to use if any are available and -# if one wasn't chosen via the "--tag" command line option. -# Only attempt this if the compiler in the base compile -# command doesn't match the default compiler. -# arg is usually of the form 'gcc ...' -func_infer_tag () -{ - $opt_debug - if test -n "$available_tags" && test -z "$tagname"; then - CC_quoted= - for arg in $CC; do - func_append_quoted CC_quoted "$arg" - done - CC_expanded=`func_echo_all $CC` - CC_quoted_expanded=`func_echo_all $CC_quoted` - case $@ in - # Blanks in the command may have been stripped by the calling shell, - # but not from the CC environment variable when configure was run. - " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ - " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; - # Blanks at the start of $base_compile will cause this to fail - # if we don't check for them as well. - *) - for z in $available_tags; do - if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then - # Evaluate the configuration. - eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" - CC_quoted= - for arg in $CC; do - # Double-quote args containing other shell metacharacters. - func_append_quoted CC_quoted "$arg" - done - CC_expanded=`func_echo_all $CC` - CC_quoted_expanded=`func_echo_all $CC_quoted` - case "$@ " in - " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ - " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) - # The compiler in the base compile command matches - # the one in the tagged configuration. - # Assume this is the tagged configuration we want. - tagname=$z - break - ;; - esac - fi - done - # If $tagname still isn't set, then no tagged configuration - # was found and let the user know that the "--tag" command - # line option must be used. - if test -z "$tagname"; then - func_echo "unable to infer tagged configuration" - func_fatal_error "specify a tag with \`--tag'" -# else -# func_verbose "using $tagname tagged configuration" - fi - ;; - esac - fi -} - - - -# func_write_libtool_object output_name pic_name nonpic_name -# Create a libtool object file (analogous to a ".la" file), -# but don't create it if we're doing a dry run. -func_write_libtool_object () -{ - write_libobj=${1} - if test "$build_libtool_libs" = yes; then - write_lobj=\'${2}\' - else - write_lobj=none - fi - - if test "$build_old_libs" = yes; then - write_oldobj=\'${3}\' - else - write_oldobj=none - fi - - $opt_dry_run || { - cat >${write_libobj}T </dev/null` - if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then - func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | - $SED -e "$lt_sed_naive_backslashify"` - else - func_convert_core_file_wine_to_w32_result= - fi - fi -} -# end: func_convert_core_file_wine_to_w32 - - -# func_convert_core_path_wine_to_w32 ARG -# Helper function used by path conversion functions when $build is *nix, and -# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly -# configured wine environment available, with the winepath program in $build's -# $PATH. Assumes ARG has no leading or trailing path separator characters. -# -# ARG is path to be converted from $build format to win32. -# Result is available in $func_convert_core_path_wine_to_w32_result. -# Unconvertible file (directory) names in ARG are skipped; if no directory names -# are convertible, then the result may be empty. -func_convert_core_path_wine_to_w32 () -{ - $opt_debug - # unfortunately, winepath doesn't convert paths, only file names - func_convert_core_path_wine_to_w32_result="" - if test -n "$1"; then - oldIFS=$IFS - IFS=: - for func_convert_core_path_wine_to_w32_f in $1; do - IFS=$oldIFS - func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" - if test -n "$func_convert_core_file_wine_to_w32_result" ; then - if test -z "$func_convert_core_path_wine_to_w32_result"; then - func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" - else - func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" - fi - fi - done - IFS=$oldIFS - fi -} -# end: func_convert_core_path_wine_to_w32 - - -# func_cygpath ARGS... -# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when -# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) -# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or -# (2), returns the Cygwin file name or path in func_cygpath_result (input -# file name or path is assumed to be in w32 format, as previously converted -# from $build's *nix or MSYS format). In case (3), returns the w32 file name -# or path in func_cygpath_result (input file name or path is assumed to be in -# Cygwin format). Returns an empty string on error. -# -# ARGS are passed to cygpath, with the last one being the file name or path to -# be converted. -# -# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH -# environment variable; do not put it in $PATH. -func_cygpath () -{ - $opt_debug - if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then - func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` - if test "$?" -ne 0; then - # on failure, ensure result is empty - func_cygpath_result= - fi - else - func_cygpath_result= - func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" - fi -} -#end: func_cygpath - - -# func_convert_core_msys_to_w32 ARG -# Convert file name or path ARG from MSYS format to w32 format. Return -# result in func_convert_core_msys_to_w32_result. -func_convert_core_msys_to_w32 () -{ - $opt_debug - # awkward: cmd appends spaces to result - func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | - $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` -} -#end: func_convert_core_msys_to_w32 - - -# func_convert_file_check ARG1 ARG2 -# Verify that ARG1 (a file name in $build format) was converted to $host -# format in ARG2. Otherwise, emit an error message, but continue (resetting -# func_to_host_file_result to ARG1). -func_convert_file_check () -{ - $opt_debug - if test -z "$2" && test -n "$1" ; then - func_error "Could not determine host file name corresponding to" - func_error " \`$1'" - func_error "Continuing, but uninstalled executables may not work." - # Fallback: - func_to_host_file_result="$1" - fi -} -# end func_convert_file_check - - -# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH -# Verify that FROM_PATH (a path in $build format) was converted to $host -# format in TO_PATH. Otherwise, emit an error message, but continue, resetting -# func_to_host_file_result to a simplistic fallback value (see below). -func_convert_path_check () -{ - $opt_debug - if test -z "$4" && test -n "$3"; then - func_error "Could not determine the host path corresponding to" - func_error " \`$3'" - func_error "Continuing, but uninstalled executables may not work." - # Fallback. This is a deliberately simplistic "conversion" and - # should not be "improved". See libtool.info. - if test "x$1" != "x$2"; then - lt_replace_pathsep_chars="s|$1|$2|g" - func_to_host_path_result=`echo "$3" | - $SED -e "$lt_replace_pathsep_chars"` - else - func_to_host_path_result="$3" - fi - fi -} -# end func_convert_path_check - - -# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG -# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT -# and appending REPL if ORIG matches BACKPAT. -func_convert_path_front_back_pathsep () -{ - $opt_debug - case $4 in - $1 ) func_to_host_path_result="$3$func_to_host_path_result" - ;; - esac - case $4 in - $2 ) func_append func_to_host_path_result "$3" - ;; - esac -} -# end func_convert_path_front_back_pathsep - - -################################################## -# $build to $host FILE NAME CONVERSION FUNCTIONS # -################################################## -# invoked via `$to_host_file_cmd ARG' -# -# In each case, ARG is the path to be converted from $build to $host format. -# Result will be available in $func_to_host_file_result. - - -# func_to_host_file ARG -# Converts the file name ARG from $build format to $host format. Return result -# in func_to_host_file_result. -func_to_host_file () -{ - $opt_debug - $to_host_file_cmd "$1" -} -# end func_to_host_file - - -# func_to_tool_file ARG LAZY -# converts the file name ARG from $build format to toolchain format. Return -# result in func_to_tool_file_result. If the conversion in use is listed -# in (the comma separated) LAZY, no conversion takes place. -func_to_tool_file () -{ - $opt_debug - case ,$2, in - *,"$to_tool_file_cmd",*) - func_to_tool_file_result=$1 - ;; - *) - $to_tool_file_cmd "$1" - func_to_tool_file_result=$func_to_host_file_result - ;; - esac -} -# end func_to_tool_file - - -# func_convert_file_noop ARG -# Copy ARG to func_to_host_file_result. -func_convert_file_noop () -{ - func_to_host_file_result="$1" -} -# end func_convert_file_noop - - -# func_convert_file_msys_to_w32 ARG -# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic -# conversion to w32 is not available inside the cwrapper. Returns result in -# func_to_host_file_result. -func_convert_file_msys_to_w32 () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - func_convert_core_msys_to_w32 "$1" - func_to_host_file_result="$func_convert_core_msys_to_w32_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_msys_to_w32 - - -# func_convert_file_cygwin_to_w32 ARG -# Convert file name ARG from Cygwin to w32 format. Returns result in -# func_to_host_file_result. -func_convert_file_cygwin_to_w32 () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - # because $build is cygwin, we call "the" cygpath in $PATH; no need to use - # LT_CYGPATH in this case. - func_to_host_file_result=`cygpath -m "$1"` - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_cygwin_to_w32 - - -# func_convert_file_nix_to_w32 ARG -# Convert file name ARG from *nix to w32 format. Requires a wine environment -# and a working winepath. Returns result in func_to_host_file_result. -func_convert_file_nix_to_w32 () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - func_convert_core_file_wine_to_w32 "$1" - func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_nix_to_w32 - - -# func_convert_file_msys_to_cygwin ARG -# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. -# Returns result in func_to_host_file_result. -func_convert_file_msys_to_cygwin () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - func_convert_core_msys_to_w32 "$1" - func_cygpath -u "$func_convert_core_msys_to_w32_result" - func_to_host_file_result="$func_cygpath_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_msys_to_cygwin - - -# func_convert_file_nix_to_cygwin ARG -# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed -# in a wine environment, working winepath, and LT_CYGPATH set. Returns result -# in func_to_host_file_result. -func_convert_file_nix_to_cygwin () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. - func_convert_core_file_wine_to_w32 "$1" - func_cygpath -u "$func_convert_core_file_wine_to_w32_result" - func_to_host_file_result="$func_cygpath_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_nix_to_cygwin - - -############################################# -# $build to $host PATH CONVERSION FUNCTIONS # -############################################# -# invoked via `$to_host_path_cmd ARG' -# -# In each case, ARG is the path to be converted from $build to $host format. -# The result will be available in $func_to_host_path_result. -# -# Path separators are also converted from $build format to $host format. If -# ARG begins or ends with a path separator character, it is preserved (but -# converted to $host format) on output. -# -# All path conversion functions are named using the following convention: -# file name conversion function : func_convert_file_X_to_Y () -# path conversion function : func_convert_path_X_to_Y () -# where, for any given $build/$host combination the 'X_to_Y' value is the -# same. If conversion functions are added for new $build/$host combinations, -# the two new functions must follow this pattern, or func_init_to_host_path_cmd -# will break. - - -# func_init_to_host_path_cmd -# Ensures that function "pointer" variable $to_host_path_cmd is set to the -# appropriate value, based on the value of $to_host_file_cmd. -to_host_path_cmd= -func_init_to_host_path_cmd () -{ - $opt_debug - if test -z "$to_host_path_cmd"; then - func_stripname 'func_convert_file_' '' "$to_host_file_cmd" - to_host_path_cmd="func_convert_path_${func_stripname_result}" - fi -} - - -# func_to_host_path ARG -# Converts the path ARG from $build format to $host format. Return result -# in func_to_host_path_result. -func_to_host_path () -{ - $opt_debug - func_init_to_host_path_cmd - $to_host_path_cmd "$1" -} -# end func_to_host_path - - -# func_convert_path_noop ARG -# Copy ARG to func_to_host_path_result. -func_convert_path_noop () -{ - func_to_host_path_result="$1" -} -# end func_convert_path_noop - - -# func_convert_path_msys_to_w32 ARG -# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic -# conversion to w32 is not available inside the cwrapper. Returns result in -# func_to_host_path_result. -func_convert_path_msys_to_w32 () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # Remove leading and trailing path separator characters from ARG. MSYS - # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; - # and winepath ignores them completely. - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" - func_to_host_path_result="$func_convert_core_msys_to_w32_result" - func_convert_path_check : ";" \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" - fi -} -# end func_convert_path_msys_to_w32 - - -# func_convert_path_cygwin_to_w32 ARG -# Convert path ARG from Cygwin to w32 format. Returns result in -# func_to_host_file_result. -func_convert_path_cygwin_to_w32 () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # See func_convert_path_msys_to_w32: - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` - func_convert_path_check : ";" \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" - fi -} -# end func_convert_path_cygwin_to_w32 - - -# func_convert_path_nix_to_w32 ARG -# Convert path ARG from *nix to w32 format. Requires a wine environment and -# a working winepath. Returns result in func_to_host_file_result. -func_convert_path_nix_to_w32 () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # See func_convert_path_msys_to_w32: - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" - func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" - func_convert_path_check : ";" \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" - fi -} -# end func_convert_path_nix_to_w32 - - -# func_convert_path_msys_to_cygwin ARG -# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. -# Returns result in func_to_host_file_result. -func_convert_path_msys_to_cygwin () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # See func_convert_path_msys_to_w32: - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" - func_cygpath -u -p "$func_convert_core_msys_to_w32_result" - func_to_host_path_result="$func_cygpath_result" - func_convert_path_check : : \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" : "$1" - fi -} -# end func_convert_path_msys_to_cygwin - - -# func_convert_path_nix_to_cygwin ARG -# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a -# a wine environment, working winepath, and LT_CYGPATH set. Returns result in -# func_to_host_file_result. -func_convert_path_nix_to_cygwin () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # Remove leading and trailing path separator characters from - # ARG. msys behavior is inconsistent here, cygpath turns them - # into '.;' and ';.', and winepath ignores them completely. - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" - func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" - func_to_host_path_result="$func_cygpath_result" - func_convert_path_check : : \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" : "$1" - fi -} -# end func_convert_path_nix_to_cygwin - - -# func_mode_compile arg... -func_mode_compile () -{ - $opt_debug - # Get the compilation command and the source file. - base_compile= - srcfile="$nonopt" # always keep a non-empty value in "srcfile" - suppress_opt=yes - suppress_output= - arg_mode=normal - libobj= - later= - pie_flag= - - for arg - do - case $arg_mode in - arg ) - # do not "continue". Instead, add this to base_compile - lastarg="$arg" - arg_mode=normal - ;; - - target ) - libobj="$arg" - arg_mode=normal - continue - ;; - - normal ) - # Accept any command-line options. - case $arg in - -o) - test -n "$libobj" && \ - func_fatal_error "you cannot specify \`-o' more than once" - arg_mode=target - continue - ;; - - -pie | -fpie | -fPIE) - func_append pie_flag " $arg" - continue - ;; - - -shared | -static | -prefer-pic | -prefer-non-pic) - func_append later " $arg" - continue - ;; - - -no-suppress) - suppress_opt=no - continue - ;; - - -Xcompiler) - arg_mode=arg # the next one goes into the "base_compile" arg list - continue # The current "srcfile" will either be retained or - ;; # replaced later. I would guess that would be a bug. - - -Wc,*) - func_stripname '-Wc,' '' "$arg" - args=$func_stripname_result - lastarg= - save_ifs="$IFS"; IFS=',' - for arg in $args; do - IFS="$save_ifs" - func_append_quoted lastarg "$arg" - done - IFS="$save_ifs" - func_stripname ' ' '' "$lastarg" - lastarg=$func_stripname_result - - # Add the arguments to base_compile. - func_append base_compile " $lastarg" - continue - ;; - - *) - # Accept the current argument as the source file. - # The previous "srcfile" becomes the current argument. - # - lastarg="$srcfile" - srcfile="$arg" - ;; - esac # case $arg - ;; - esac # case $arg_mode - - # Aesthetically quote the previous argument. - func_append_quoted base_compile "$lastarg" - done # for arg - - case $arg_mode in - arg) - func_fatal_error "you must specify an argument for -Xcompile" - ;; - target) - func_fatal_error "you must specify a target with \`-o'" - ;; - *) - # Get the name of the library object. - test -z "$libobj" && { - func_basename "$srcfile" - libobj="$func_basename_result" - } - ;; - esac - - # Recognize several different file suffixes. - # If the user specifies -o file.o, it is replaced with file.lo - case $libobj in - *.[cCFSifmso] | \ - *.ada | *.adb | *.ads | *.asm | \ - *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ - *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) - func_xform "$libobj" - libobj=$func_xform_result - ;; - esac - - case $libobj in - *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; - *) - func_fatal_error "cannot determine name of library object from \`$libobj'" - ;; - esac - - func_infer_tag $base_compile - - for arg in $later; do - case $arg in - -shared) - test "$build_libtool_libs" != yes && \ - func_fatal_configuration "can not build a shared library" - build_old_libs=no - continue - ;; - - -static) - build_libtool_libs=no - build_old_libs=yes - continue - ;; - - -prefer-pic) - pic_mode=yes - continue - ;; - - -prefer-non-pic) - pic_mode=no - continue - ;; - esac - done - - func_quote_for_eval "$libobj" - test "X$libobj" != "X$func_quote_for_eval_result" \ - && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ - && func_warning "libobj name \`$libobj' may not contain shell special characters." - func_dirname_and_basename "$obj" "/" "" - objname="$func_basename_result" - xdir="$func_dirname_result" - lobj=${xdir}$objdir/$objname - - test -z "$base_compile" && \ - func_fatal_help "you must specify a compilation command" - - # Delete any leftover library objects. - if test "$build_old_libs" = yes; then - removelist="$obj $lobj $libobj ${libobj}T" - else - removelist="$lobj $libobj ${libobj}T" - fi - - # On Cygwin there's no "real" PIC flag so we must build both object types - case $host_os in - cygwin* | mingw* | pw32* | os2* | cegcc*) - pic_mode=default - ;; - esac - if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then - # non-PIC code in shared libraries is not supported - pic_mode=default - fi - - # Calculate the filename of the output object if compiler does - # not support -o with -c - if test "$compiler_c_o" = no; then - output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} - lockfile="$output_obj.lock" - else - output_obj= - need_locks=no - lockfile= - fi - - # Lock this critical section if it is needed - # We use this script file to make the link, it avoids creating a new file - if test "$need_locks" = yes; then - until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do - func_echo "Waiting for $lockfile to be removed" - sleep 2 - done - elif test "$need_locks" = warn; then - if test -f "$lockfile"; then - $ECHO "\ -*** ERROR, $lockfile exists and contains: -`cat $lockfile 2>/dev/null` - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $opt_dry_run || $RM $removelist - exit $EXIT_FAILURE - fi - func_append removelist " $output_obj" - $ECHO "$srcfile" > "$lockfile" - fi - - $opt_dry_run || $RM $removelist - func_append removelist " $lockfile" - trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 - - func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 - srcfile=$func_to_tool_file_result - func_quote_for_eval "$srcfile" - qsrcfile=$func_quote_for_eval_result - - # Only build a PIC object if we are building libtool libraries. - if test "$build_libtool_libs" = yes; then - # Without this assignment, base_compile gets emptied. - fbsd_hideous_sh_bug=$base_compile - - if test "$pic_mode" != no; then - command="$base_compile $qsrcfile $pic_flag" - else - # Don't build PIC code - command="$base_compile $qsrcfile" - fi - - func_mkdir_p "$xdir$objdir" - - if test -z "$output_obj"; then - # Place PIC objects in $objdir - func_append command " -o $lobj" - fi - - func_show_eval_locale "$command" \ - 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' - - if test "$need_locks" = warn && - test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then - $ECHO "\ -*** ERROR, $lockfile contains: -`cat $lockfile 2>/dev/null` - -but it should contain: -$srcfile - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $opt_dry_run || $RM $removelist - exit $EXIT_FAILURE - fi - - # Just move the object if needed, then go on to compile the next one - if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then - func_show_eval '$MV "$output_obj" "$lobj"' \ - 'error=$?; $opt_dry_run || $RM $removelist; exit $error' - fi - - # Allow error messages only from the first compilation. - if test "$suppress_opt" = yes; then - suppress_output=' >/dev/null 2>&1' - fi - fi - - # Only build a position-dependent object if we build old libraries. - if test "$build_old_libs" = yes; then - if test "$pic_mode" != yes; then - # Don't build PIC code - command="$base_compile $qsrcfile$pie_flag" - else - command="$base_compile $qsrcfile $pic_flag" - fi - if test "$compiler_c_o" = yes; then - func_append command " -o $obj" - fi - - # Suppress compiler output if we already did a PIC compilation. - func_append command "$suppress_output" - func_show_eval_locale "$command" \ - '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' - - if test "$need_locks" = warn && - test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then - $ECHO "\ -*** ERROR, $lockfile contains: -`cat $lockfile 2>/dev/null` - -but it should contain: -$srcfile - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $opt_dry_run || $RM $removelist - exit $EXIT_FAILURE - fi - - # Just move the object if needed - if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then - func_show_eval '$MV "$output_obj" "$obj"' \ - 'error=$?; $opt_dry_run || $RM $removelist; exit $error' - fi - fi - - $opt_dry_run || { - func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" - - # Unlock the critical section if it was locked - if test "$need_locks" != no; then - removelist=$lockfile - $RM "$lockfile" - fi - } - - exit $EXIT_SUCCESS -} - -$opt_help || { - test "$opt_mode" = compile && func_mode_compile ${1+"$@"} -} - -func_mode_help () -{ - # We need to display help for each of the modes. - case $opt_mode in - "") - # Generic help is extracted from the usage comments - # at the start of this file. - func_help - ;; - - clean) - $ECHO \ -"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... - -Remove files from the build directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, object or program, all the files associated -with it are deleted. Otherwise, only FILE itself is deleted using RM." - ;; - - compile) - $ECHO \ -"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE - -Compile a source file into a libtool library object. - -This mode accepts the following additional options: - - -o OUTPUT-FILE set the output file name to OUTPUT-FILE - -no-suppress do not suppress compiler output for multiple passes - -prefer-pic try to build PIC objects only - -prefer-non-pic try to build non-PIC objects only - -shared do not build a \`.o' file suitable for static linking - -static only build a \`.o' file suitable for static linking - -Wc,FLAG pass FLAG directly to the compiler - -COMPILE-COMMAND is a command to be used in creating a \`standard' object file -from the given SOURCEFILE. - -The output file name is determined by removing the directory component from -SOURCEFILE, then substituting the C source code suffix \`.c' with the -library object suffix, \`.lo'." - ;; - - execute) - $ECHO \ -"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... - -Automatically set library path, then run a program. - -This mode accepts the following additional options: - - -dlopen FILE add the directory containing FILE to the library path - -This mode sets the library path environment variable according to \`-dlopen' -flags. - -If any of the ARGS are libtool executable wrappers, then they are translated -into their corresponding uninstalled binary, and any of their required library -directories are added to the library path. - -Then, COMMAND is executed, with ARGS as arguments." - ;; - - finish) - $ECHO \ -"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... - -Complete the installation of libtool libraries. - -Each LIBDIR is a directory that contains libtool libraries. - -The commands that this mode executes may require superuser privileges. Use -the \`--dry-run' option if you just want to see what would be executed." - ;; - - install) - $ECHO \ -"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... - -Install executables or libraries. - -INSTALL-COMMAND is the installation command. The first component should be -either the \`install' or \`cp' program. - -The following components of INSTALL-COMMAND are treated specially: - - -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation - -The rest of the components are interpreted as arguments to that command (only -BSD-compatible install options are recognized)." - ;; - - link) - $ECHO \ -"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... - -Link object files or libraries together to form another library, or to -create an executable program. - -LINK-COMMAND is a command using the C compiler that you would use to create -a program from several object files. - -The following components of LINK-COMMAND are treated specially: - - -all-static do not do any dynamic linking at all - -avoid-version do not add a version suffix if possible - -bindir BINDIR specify path to binaries directory (for systems where - libraries must be found in the PATH setting at runtime) - -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime - -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols - -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) - -export-symbols SYMFILE - try to export only the symbols listed in SYMFILE - -export-symbols-regex REGEX - try to export only the symbols matching REGEX - -LLIBDIR search LIBDIR for required installed libraries - -lNAME OUTPUT-FILE requires the installed library libNAME - -module build a library that can dlopened - -no-fast-install disable the fast-install mode - -no-install link a not-installable executable - -no-undefined declare that a library does not refer to external symbols - -o OUTPUT-FILE create OUTPUT-FILE from the specified objects - -objectlist FILE Use a list of object files found in FILE to specify objects - -precious-files-regex REGEX - don't remove output files matching REGEX - -release RELEASE specify package release information - -rpath LIBDIR the created library will eventually be installed in LIBDIR - -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries - -shared only do dynamic linking of libtool libraries - -shrext SUFFIX override the standard shared library file extension - -static do not do any dynamic linking of uninstalled libtool libraries - -static-libtool-libs - do not do any dynamic linking of libtool libraries - -version-info CURRENT[:REVISION[:AGE]] - specify library version info [each variable defaults to 0] - -weak LIBNAME declare that the target provides the LIBNAME interface - -Wc,FLAG - -Xcompiler FLAG pass linker-specific FLAG directly to the compiler - -Wl,FLAG - -Xlinker FLAG pass linker-specific FLAG directly to the linker - -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) - -All other options (arguments beginning with \`-') are ignored. - -Every other argument is treated as a filename. Files ending in \`.la' are -treated as uninstalled libtool libraries, other files are standard or library -object files. - -If the OUTPUT-FILE ends in \`.la', then a libtool library is created, -only library objects (\`.lo' files) may be specified, and \`-rpath' is -required, except when creating a convenience library. - -If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created -using \`ar' and \`ranlib', or on Windows using \`lib'. - -If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file -is created, otherwise an executable program is created." - ;; - - uninstall) - $ECHO \ -"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... - -Remove libraries from an installation directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, all the files associated with it are deleted. -Otherwise, only FILE itself is deleted using RM." - ;; - - *) - func_fatal_help "invalid operation mode \`$opt_mode'" - ;; - esac - - echo - $ECHO "Try \`$progname --help' for more information about other modes." -} - -# Now that we've collected a possible --mode arg, show help if necessary -if $opt_help; then - if test "$opt_help" = :; then - func_mode_help - else - { - func_help noexit - for opt_mode in compile link execute install finish uninstall clean; do - func_mode_help - done - } | sed -n '1p; 2,$s/^Usage:/ or: /p' - { - func_help noexit - for opt_mode in compile link execute install finish uninstall clean; do - echo - func_mode_help - done - } | - sed '1d - /^When reporting/,/^Report/{ - H - d - } - $x - /information about other modes/d - /more detailed .*MODE/d - s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' - fi - exit $? -fi - - -# func_mode_execute arg... -func_mode_execute () -{ - $opt_debug - # The first argument is the command name. - cmd="$nonopt" - test -z "$cmd" && \ - func_fatal_help "you must specify a COMMAND" - - # Handle -dlopen flags immediately. - for file in $opt_dlopen; do - test -f "$file" \ - || func_fatal_help "\`$file' is not a file" - - dir= - case $file in - *.la) - func_resolve_sysroot "$file" - file=$func_resolve_sysroot_result - - # Check to see that this really is a libtool archive. - func_lalib_unsafe_p "$file" \ - || func_fatal_help "\`$lib' is not a valid libtool archive" - - # Read the libtool library. - dlname= - library_names= - func_source "$file" - - # Skip this library if it cannot be dlopened. - if test -z "$dlname"; then - # Warn if it was a shared library. - test -n "$library_names" && \ - func_warning "\`$file' was not linked with \`-export-dynamic'" - continue - fi - - func_dirname "$file" "" "." - dir="$func_dirname_result" - - if test -f "$dir/$objdir/$dlname"; then - func_append dir "/$objdir" - else - if test ! -f "$dir/$dlname"; then - func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" - fi - fi - ;; - - *.lo) - # Just add the directory containing the .lo file. - func_dirname "$file" "" "." - dir="$func_dirname_result" - ;; - - *) - func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" - continue - ;; - esac - - # Get the absolute pathname. - absdir=`cd "$dir" && pwd` - test -n "$absdir" && dir="$absdir" - - # Now add the directory to shlibpath_var. - if eval "test -z \"\$$shlibpath_var\""; then - eval "$shlibpath_var=\"\$dir\"" - else - eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" - fi - done - - # This variable tells wrapper scripts just to set shlibpath_var - # rather than running their programs. - libtool_execute_magic="$magic" - - # Check if any of the arguments is a wrapper script. - args= - for file - do - case $file in - -* | *.la | *.lo ) ;; - *) - # Do a test to see if this is really a libtool program. - if func_ltwrapper_script_p "$file"; then - func_source "$file" - # Transform arg to wrapped name. - file="$progdir/$program" - elif func_ltwrapper_executable_p "$file"; then - func_ltwrapper_scriptname "$file" - func_source "$func_ltwrapper_scriptname_result" - # Transform arg to wrapped name. - file="$progdir/$program" - fi - ;; - esac - # Quote arguments (to preserve shell metacharacters). - func_append_quoted args "$file" - done - - if test "X$opt_dry_run" = Xfalse; then - if test -n "$shlibpath_var"; then - # Export the shlibpath_var. - eval "export $shlibpath_var" - fi - - # Restore saved environment variables - for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES - do - eval "if test \"\${save_$lt_var+set}\" = set; then - $lt_var=\$save_$lt_var; export $lt_var - else - $lt_unset $lt_var - fi" - done - - # Now prepare to actually exec the command. - exec_cmd="\$cmd$args" - else - # Display what would be done. - if test -n "$shlibpath_var"; then - eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" - echo "export $shlibpath_var" - fi - $ECHO "$cmd$args" - exit $EXIT_SUCCESS - fi -} - -test "$opt_mode" = execute && func_mode_execute ${1+"$@"} - - -# func_mode_finish arg... -func_mode_finish () -{ - $opt_debug - libs= - libdirs= - admincmds= - - for opt in "$nonopt" ${1+"$@"} - do - if test -d "$opt"; then - func_append libdirs " $opt" - - elif test -f "$opt"; then - if func_lalib_unsafe_p "$opt"; then - func_append libs " $opt" - else - func_warning "\`$opt' is not a valid libtool archive" - fi - - else - func_fatal_error "invalid argument \`$opt'" - fi - done - - if test -n "$libs"; then - if test -n "$lt_sysroot"; then - sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` - sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" - else - sysroot_cmd= - fi - - # Remove sysroot references - if $opt_dry_run; then - for lib in $libs; do - echo "removing references to $lt_sysroot and \`=' prefixes from $lib" - done - else - tmpdir=`func_mktempdir` - for lib in $libs; do - sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ - > $tmpdir/tmp-la - mv -f $tmpdir/tmp-la $lib - done - ${RM}r "$tmpdir" - fi - fi - - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - for libdir in $libdirs; do - if test -n "$finish_cmds"; then - # Do each command in the finish commands. - func_execute_cmds "$finish_cmds" 'admincmds="$admincmds -'"$cmd"'"' - fi - if test -n "$finish_eval"; then - # Do the single finish_eval. - eval cmds=\"$finish_eval\" - $opt_dry_run || eval "$cmds" || func_append admincmds " - $cmds" - fi - done - fi - - # Exit here if they wanted silent mode. - $opt_silent && exit $EXIT_SUCCESS - - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - echo "----------------------------------------------------------------------" - echo "Libraries have been installed in:" - for libdir in $libdirs; do - $ECHO " $libdir" - done - echo - echo "If you ever happen to want to link against installed libraries" - echo "in a given directory, LIBDIR, you must either use libtool, and" - echo "specify the full pathname of the library, or use the \`-LLIBDIR'" - echo "flag during linking and do at least one of the following:" - if test -n "$shlibpath_var"; then - echo " - add LIBDIR to the \`$shlibpath_var' environment variable" - echo " during execution" - fi - if test -n "$runpath_var"; then - echo " - add LIBDIR to the \`$runpath_var' environment variable" - echo " during linking" - fi - if test -n "$hardcode_libdir_flag_spec"; then - libdir=LIBDIR - eval flag=\"$hardcode_libdir_flag_spec\" - - $ECHO " - use the \`$flag' linker flag" - fi - if test -n "$admincmds"; then - $ECHO " - have your system administrator run these commands:$admincmds" - fi - if test -f /etc/ld.so.conf; then - echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" - fi - echo - - echo "See any operating system documentation about shared libraries for" - case $host in - solaris2.[6789]|solaris2.1[0-9]) - echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" - echo "pages." - ;; - *) - echo "more information, such as the ld(1) and ld.so(8) manual pages." - ;; - esac - echo "----------------------------------------------------------------------" - fi - exit $EXIT_SUCCESS -} - -test "$opt_mode" = finish && func_mode_finish ${1+"$@"} - - -# func_mode_install arg... -func_mode_install () -{ - $opt_debug - # There may be an optional sh(1) argument at the beginning of - # install_prog (especially on Windows NT). - if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || - # Allow the use of GNU shtool's install command. - case $nonopt in *shtool*) :;; *) false;; esac; then - # Aesthetically quote it. - func_quote_for_eval "$nonopt" - install_prog="$func_quote_for_eval_result " - arg=$1 - shift - else - install_prog= - arg=$nonopt - fi - - # The real first argument should be the name of the installation program. - # Aesthetically quote it. - func_quote_for_eval "$arg" - func_append install_prog "$func_quote_for_eval_result" - install_shared_prog=$install_prog - case " $install_prog " in - *[\\\ /]cp\ *) install_cp=: ;; - *) install_cp=false ;; - esac - - # We need to accept at least all the BSD install flags. - dest= - files= - opts= - prev= - install_type= - isdir=no - stripme= - no_mode=: - for arg - do - arg2= - if test -n "$dest"; then - func_append files " $dest" - dest=$arg - continue - fi - - case $arg in - -d) isdir=yes ;; - -f) - if $install_cp; then :; else - prev=$arg - fi - ;; - -g | -m | -o) - prev=$arg - ;; - -s) - stripme=" -s" - continue - ;; - -*) - ;; - *) - # If the previous option needed an argument, then skip it. - if test -n "$prev"; then - if test "x$prev" = x-m && test -n "$install_override_mode"; then - arg2=$install_override_mode - no_mode=false - fi - prev= - else - dest=$arg - continue - fi - ;; - esac - - # Aesthetically quote the argument. - func_quote_for_eval "$arg" - func_append install_prog " $func_quote_for_eval_result" - if test -n "$arg2"; then - func_quote_for_eval "$arg2" - fi - func_append install_shared_prog " $func_quote_for_eval_result" - done - - test -z "$install_prog" && \ - func_fatal_help "you must specify an install program" - - test -n "$prev" && \ - func_fatal_help "the \`$prev' option requires an argument" - - if test -n "$install_override_mode" && $no_mode; then - if $install_cp; then :; else - func_quote_for_eval "$install_override_mode" - func_append install_shared_prog " -m $func_quote_for_eval_result" - fi - fi - - if test -z "$files"; then - if test -z "$dest"; then - func_fatal_help "no file or destination specified" - else - func_fatal_help "you must specify a destination" - fi - fi - - # Strip any trailing slash from the destination. - func_stripname '' '/' "$dest" - dest=$func_stripname_result - - # Check to see that the destination is a directory. - test -d "$dest" && isdir=yes - if test "$isdir" = yes; then - destdir="$dest" - destname= - else - func_dirname_and_basename "$dest" "" "." - destdir="$func_dirname_result" - destname="$func_basename_result" - - # Not a directory, so check to see that there is only one file specified. - set dummy $files; shift - test "$#" -gt 1 && \ - func_fatal_help "\`$dest' is not a directory" - fi - case $destdir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - for file in $files; do - case $file in - *.lo) ;; - *) - func_fatal_help "\`$destdir' must be an absolute directory name" - ;; - esac - done - ;; - esac - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - staticlibs= - future_libdirs= - current_libdirs= - for file in $files; do - - # Do each installation. - case $file in - *.$libext) - # Do the static libraries later. - func_append staticlibs " $file" - ;; - - *.la) - func_resolve_sysroot "$file" - file=$func_resolve_sysroot_result - - # Check to see that this really is a libtool archive. - func_lalib_unsafe_p "$file" \ - || func_fatal_help "\`$file' is not a valid libtool archive" - - library_names= - old_library= - relink_command= - func_source "$file" - - # Add the libdir to current_libdirs if it is the destination. - if test "X$destdir" = "X$libdir"; then - case "$current_libdirs " in - *" $libdir "*) ;; - *) func_append current_libdirs " $libdir" ;; - esac - else - # Note the libdir as a future libdir. - case "$future_libdirs " in - *" $libdir "*) ;; - *) func_append future_libdirs " $libdir" ;; - esac - fi - - func_dirname "$file" "/" "" - dir="$func_dirname_result" - func_append dir "$objdir" - - if test -n "$relink_command"; then - # Determine the prefix the user has applied to our future dir. - inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` - - # Don't allow the user to place us outside of our expected - # location b/c this prevents finding dependent libraries that - # are installed to the same prefix. - # At present, this check doesn't affect windows .dll's that - # are installed into $libdir/../bin (currently, that works fine) - # but it's something to keep an eye on. - test "$inst_prefix_dir" = "$destdir" && \ - func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" - - if test -n "$inst_prefix_dir"; then - # Stick the inst_prefix_dir data into the link command. - relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` - else - relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` - fi - - func_warning "relinking \`$file'" - func_show_eval "$relink_command" \ - 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' - fi - - # See the names of the shared library. - set dummy $library_names; shift - if test -n "$1"; then - realname="$1" - shift - - srcname="$realname" - test -n "$relink_command" && srcname="$realname"T - - # Install the shared library and build the symlinks. - func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ - 'exit $?' - tstripme="$stripme" - case $host_os in - cygwin* | mingw* | pw32* | cegcc*) - case $realname in - *.dll.a) - tstripme="" - ;; - esac - ;; - esac - if test -n "$tstripme" && test -n "$striplib"; then - func_show_eval "$striplib $destdir/$realname" 'exit $?' - fi - - if test "$#" -gt 0; then - # Delete the old symlinks, and create new ones. - # Try `ln -sf' first, because the `ln' binary might depend on - # the symlink we replace! Solaris /bin/ln does not understand -f, - # so we also need to try rm && ln -s. - for linkname - do - test "$linkname" != "$realname" \ - && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" - done - fi - - # Do each command in the postinstall commands. - lib="$destdir/$realname" - func_execute_cmds "$postinstall_cmds" 'exit $?' - fi - - # Install the pseudo-library for information purposes. - func_basename "$file" - name="$func_basename_result" - instname="$dir/$name"i - func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' - - # Maybe install the static library, too. - test -n "$old_library" && func_append staticlibs " $dir/$old_library" - ;; - - *.lo) - # Install (i.e. copy) a libtool object. - - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - func_basename "$file" - destfile="$func_basename_result" - destfile="$destdir/$destfile" - fi - - # Deduce the name of the destination old-style object file. - case $destfile in - *.lo) - func_lo2o "$destfile" - staticdest=$func_lo2o_result - ;; - *.$objext) - staticdest="$destfile" - destfile= - ;; - *) - func_fatal_help "cannot copy a libtool object to \`$destfile'" - ;; - esac - - # Install the libtool object if requested. - test -n "$destfile" && \ - func_show_eval "$install_prog $file $destfile" 'exit $?' - - # Install the old object if enabled. - if test "$build_old_libs" = yes; then - # Deduce the name of the old-style object file. - func_lo2o "$file" - staticobj=$func_lo2o_result - func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' - fi - exit $EXIT_SUCCESS - ;; - - *) - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - func_basename "$file" - destfile="$func_basename_result" - destfile="$destdir/$destfile" - fi - - # If the file is missing, and there is a .exe on the end, strip it - # because it is most likely a libtool script we actually want to - # install - stripped_ext="" - case $file in - *.exe) - if test ! -f "$file"; then - func_stripname '' '.exe' "$file" - file=$func_stripname_result - stripped_ext=".exe" - fi - ;; - esac - - # Do a test to see if this is really a libtool program. - case $host in - *cygwin* | *mingw*) - if func_ltwrapper_executable_p "$file"; then - func_ltwrapper_scriptname "$file" - wrapper=$func_ltwrapper_scriptname_result - else - func_stripname '' '.exe' "$file" - wrapper=$func_stripname_result - fi - ;; - *) - wrapper=$file - ;; - esac - if func_ltwrapper_script_p "$wrapper"; then - notinst_deplibs= - relink_command= - - func_source "$wrapper" - - # Check the variables that should have been set. - test -z "$generated_by_libtool_version" && \ - func_fatal_error "invalid libtool wrapper script \`$wrapper'" - - finalize=yes - for lib in $notinst_deplibs; do - # Check to see that each library is installed. - libdir= - if test -f "$lib"; then - func_source "$lib" - fi - libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test - if test -n "$libdir" && test ! -f "$libfile"; then - func_warning "\`$lib' has not been installed in \`$libdir'" - finalize=no - fi - done - - relink_command= - func_source "$wrapper" - - outputname= - if test "$fast_install" = no && test -n "$relink_command"; then - $opt_dry_run || { - if test "$finalize" = yes; then - tmpdir=`func_mktempdir` - func_basename "$file$stripped_ext" - file="$func_basename_result" - outputname="$tmpdir/$file" - # Replace the output file specification. - relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` - - $opt_silent || { - func_quote_for_expand "$relink_command" - eval "func_echo $func_quote_for_expand_result" - } - if eval "$relink_command"; then : - else - func_error "error: relink \`$file' with the above command before installing it" - $opt_dry_run || ${RM}r "$tmpdir" - continue - fi - file="$outputname" - else - func_warning "cannot relink \`$file'" - fi - } - else - # Install the binary that we compiled earlier. - file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` - fi - fi - - # remove .exe since cygwin /usr/bin/install will append another - # one anyway - case $install_prog,$host in - */usr/bin/install*,*cygwin*) - case $file:$destfile in - *.exe:*.exe) - # this is ok - ;; - *.exe:*) - destfile=$destfile.exe - ;; - *:*.exe) - func_stripname '' '.exe' "$destfile" - destfile=$func_stripname_result - ;; - esac - ;; - esac - func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' - $opt_dry_run || if test -n "$outputname"; then - ${RM}r "$tmpdir" - fi - ;; - esac - done - - for file in $staticlibs; do - func_basename "$file" - name="$func_basename_result" - - # Set up the ranlib parameters. - oldlib="$destdir/$name" - func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 - tool_oldlib=$func_to_tool_file_result - - func_show_eval "$install_prog \$file \$oldlib" 'exit $?' - - if test -n "$stripme" && test -n "$old_striplib"; then - func_show_eval "$old_striplib $tool_oldlib" 'exit $?' - fi - - # Do each command in the postinstall commands. - func_execute_cmds "$old_postinstall_cmds" 'exit $?' - done - - test -n "$future_libdirs" && \ - func_warning "remember to run \`$progname --finish$future_libdirs'" - - if test -n "$current_libdirs"; then - # Maybe just do a dry run. - $opt_dry_run && current_libdirs=" -n$current_libdirs" - exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' - else - exit $EXIT_SUCCESS - fi -} - -test "$opt_mode" = install && func_mode_install ${1+"$@"} - - -# func_generate_dlsyms outputname originator pic_p -# Extract symbols from dlprefiles and create ${outputname}S.o with -# a dlpreopen symbol table. -func_generate_dlsyms () -{ - $opt_debug - my_outputname="$1" - my_originator="$2" - my_pic_p="${3-no}" - my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` - my_dlsyms= - - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - if test -n "$NM" && test -n "$global_symbol_pipe"; then - my_dlsyms="${my_outputname}S.c" - else - func_error "not configured to extract global symbols from dlpreopened files" - fi - fi - - if test -n "$my_dlsyms"; then - case $my_dlsyms in - "") ;; - *.c) - # Discover the nlist of each of the dlfiles. - nlist="$output_objdir/${my_outputname}.nm" - - func_show_eval "$RM $nlist ${nlist}S ${nlist}T" - - # Parse the name list into a source file. - func_verbose "creating $output_objdir/$my_dlsyms" - - $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ -/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ -/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ - -#ifdef __cplusplus -extern \"C\" { -#endif - -#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) -#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" -#endif - -/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ -#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) -/* DATA imports from DLLs on WIN32 con't be const, because runtime - relocations are performed -- see ld's documentation on pseudo-relocs. */ -# define LT_DLSYM_CONST -#elif defined(__osf__) -/* This system does not cope well with relocations in const data. */ -# define LT_DLSYM_CONST -#else -# define LT_DLSYM_CONST const -#endif - -/* External symbol declarations for the compiler. */\ -" - - if test "$dlself" = yes; then - func_verbose "generating symbol list for \`$output'" - - $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" - - # Add our own program objects to the symbol list. - progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` - for progfile in $progfiles; do - func_to_tool_file "$progfile" func_convert_file_msys_to_w32 - func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" - $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" - done - - if test -n "$exclude_expsyms"; then - $opt_dry_run || { - eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' - eval '$MV "$nlist"T "$nlist"' - } - fi - - if test -n "$export_symbols_regex"; then - $opt_dry_run || { - eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' - eval '$MV "$nlist"T "$nlist"' - } - fi - - # Prepare the list of exported symbols - if test -z "$export_symbols"; then - export_symbols="$output_objdir/$outputname.exp" - $opt_dry_run || { - $RM $export_symbols - eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' - case $host in - *cygwin* | *mingw* | *cegcc* ) - eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' - eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' - ;; - esac - } - else - $opt_dry_run || { - eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' - eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' - eval '$MV "$nlist"T "$nlist"' - case $host in - *cygwin* | *mingw* | *cegcc* ) - eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' - eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' - ;; - esac - } - fi - fi - - for dlprefile in $dlprefiles; do - func_verbose "extracting global C symbols from \`$dlprefile'" - func_basename "$dlprefile" - name="$func_basename_result" - case $host in - *cygwin* | *mingw* | *cegcc* ) - # if an import library, we need to obtain dlname - if func_win32_import_lib_p "$dlprefile"; then - func_tr_sh "$dlprefile" - eval "curr_lafile=\$libfile_$func_tr_sh_result" - dlprefile_dlbasename="" - if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then - # Use subshell, to avoid clobbering current variable values - dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` - if test -n "$dlprefile_dlname" ; then - func_basename "$dlprefile_dlname" - dlprefile_dlbasename="$func_basename_result" - else - # no lafile. user explicitly requested -dlpreopen . - $sharedlib_from_linklib_cmd "$dlprefile" - dlprefile_dlbasename=$sharedlib_from_linklib_result - fi - fi - $opt_dry_run || { - if test -n "$dlprefile_dlbasename" ; then - eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' - else - func_warning "Could not compute DLL name from $name" - eval '$ECHO ": $name " >> "$nlist"' - fi - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | - $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" - } - else # not an import lib - $opt_dry_run || { - eval '$ECHO ": $name " >> "$nlist"' - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" - } - fi - ;; - *) - $opt_dry_run || { - eval '$ECHO ": $name " >> "$nlist"' - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" - } - ;; - esac - done - - $opt_dry_run || { - # Make sure we have at least an empty file. - test -f "$nlist" || : > "$nlist" - - if test -n "$exclude_expsyms"; then - $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T - $MV "$nlist"T "$nlist" - fi - - # Try sorting and uniquifying the output. - if $GREP -v "^: " < "$nlist" | - if sort -k 3 /dev/null 2>&1; then - sort -k 3 - else - sort +2 - fi | - uniq > "$nlist"S; then - : - else - $GREP -v "^: " < "$nlist" > "$nlist"S - fi - - if test -f "$nlist"S; then - eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' - else - echo '/* NONE */' >> "$output_objdir/$my_dlsyms" - fi - - echo >> "$output_objdir/$my_dlsyms" "\ - -/* The mapping between symbol names and symbols. */ -typedef struct { - const char *name; - void *address; -} lt_dlsymlist; -extern LT_DLSYM_CONST lt_dlsymlist -lt_${my_prefix}_LTX_preloaded_symbols[]; -LT_DLSYM_CONST lt_dlsymlist -lt_${my_prefix}_LTX_preloaded_symbols[] = -{\ - { \"$my_originator\", (void *) 0 }," - - case $need_lib_prefix in - no) - eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" - ;; - *) - eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" - ;; - esac - echo >> "$output_objdir/$my_dlsyms" "\ - {0, (void *) 0} -}; - -/* This works around a problem in FreeBSD linker */ -#ifdef FREEBSD_WORKAROUND -static const void *lt_preloaded_setup() { - return lt_${my_prefix}_LTX_preloaded_symbols; -} -#endif - -#ifdef __cplusplus -} -#endif\ -" - } # !$opt_dry_run - - pic_flag_for_symtable= - case "$compile_command " in - *" -static "*) ;; - *) - case $host in - # compiling the symbol table file with pic_flag works around - # a FreeBSD bug that causes programs to crash when -lm is - # linked before any other PIC object. But we must not use - # pic_flag when linking with -static. The problem exists in - # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. - *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) - pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; - *-*-hpux*) - pic_flag_for_symtable=" $pic_flag" ;; - *) - if test "X$my_pic_p" != Xno; then - pic_flag_for_symtable=" $pic_flag" - fi - ;; - esac - ;; - esac - symtab_cflags= - for arg in $LTCFLAGS; do - case $arg in - -pie | -fpie | -fPIE) ;; - *) func_append symtab_cflags " $arg" ;; - esac - done - - # Now compile the dynamic symbol file. - func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' - - # Clean up the generated files. - func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' - - # Transform the symbol file into the correct name. - symfileobj="$output_objdir/${my_outputname}S.$objext" - case $host in - *cygwin* | *mingw* | *cegcc* ) - if test -f "$output_objdir/$my_outputname.def"; then - compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` - else - compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` - fi - ;; - *) - compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` - ;; - esac - ;; - *) - func_fatal_error "unknown suffix for \`$my_dlsyms'" - ;; - esac - else - # We keep going just in case the user didn't refer to - # lt_preloaded_symbols. The linker will fail if global_symbol_pipe - # really was required. - - # Nullify the symbol file. - compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` - fi -} - -# func_win32_libid arg -# return the library type of file 'arg' -# -# Need a lot of goo to handle *both* DLLs and import libs -# Has to be a shell function in order to 'eat' the argument -# that is supplied when $file_magic_command is called. -# Despite the name, also deal with 64 bit binaries. -func_win32_libid () -{ - $opt_debug - win32_libid_type="unknown" - win32_fileres=`file -L $1 2>/dev/null` - case $win32_fileres in - *ar\ archive\ import\ library*) # definitely import - win32_libid_type="x86 archive import" - ;; - *ar\ archive*) # could be an import, or static - # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. - if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | - $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then - func_to_tool_file "$1" func_convert_file_msys_to_w32 - win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | - $SED -n -e ' - 1,100{ - / I /{ - s,.*,import, - p - q - } - }'` - case $win32_nmres in - import*) win32_libid_type="x86 archive import";; - *) win32_libid_type="x86 archive static";; - esac - fi - ;; - *DLL*) - win32_libid_type="x86 DLL" - ;; - *executable*) # but shell scripts are "executable" too... - case $win32_fileres in - *MS\ Windows\ PE\ Intel*) - win32_libid_type="x86 DLL" - ;; - esac - ;; - esac - $ECHO "$win32_libid_type" -} - -# func_cygming_dll_for_implib ARG -# -# Platform-specific function to extract the -# name of the DLL associated with the specified -# import library ARG. -# Invoked by eval'ing the libtool variable -# $sharedlib_from_linklib_cmd -# Result is available in the variable -# $sharedlib_from_linklib_result -func_cygming_dll_for_implib () -{ - $opt_debug - sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` -} - -# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs -# -# The is the core of a fallback implementation of a -# platform-specific function to extract the name of the -# DLL associated with the specified import library LIBNAME. -# -# SECTION_NAME is either .idata$6 or .idata$7, depending -# on the platform and compiler that created the implib. -# -# Echos the name of the DLL associated with the -# specified import library. -func_cygming_dll_for_implib_fallback_core () -{ - $opt_debug - match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` - $OBJDUMP -s --section "$1" "$2" 2>/dev/null | - $SED '/^Contents of section '"$match_literal"':/{ - # Place marker at beginning of archive member dllname section - s/.*/====MARK====/ - p - d - } - # These lines can sometimes be longer than 43 characters, but - # are always uninteresting - /:[ ]*file format pe[i]\{,1\}-/d - /^In archive [^:]*:/d - # Ensure marker is printed - /^====MARK====/p - # Remove all lines with less than 43 characters - /^.\{43\}/!d - # From remaining lines, remove first 43 characters - s/^.\{43\}//' | - $SED -n ' - # Join marker and all lines until next marker into a single line - /^====MARK====/ b para - H - $ b para - b - :para - x - s/\n//g - # Remove the marker - s/^====MARK====// - # Remove trailing dots and whitespace - s/[\. \t]*$// - # Print - /./p' | - # we now have a list, one entry per line, of the stringified - # contents of the appropriate section of all members of the - # archive which possess that section. Heuristic: eliminate - # all those which have a first or second character that is - # a '.' (that is, objdump's representation of an unprintable - # character.) This should work for all archives with less than - # 0x302f exports -- but will fail for DLLs whose name actually - # begins with a literal '.' or a single character followed by - # a '.'. - # - # Of those that remain, print the first one. - $SED -e '/^\./d;/^.\./d;q' -} - -# func_cygming_gnu_implib_p ARG -# This predicate returns with zero status (TRUE) if -# ARG is a GNU/binutils-style import library. Returns -# with nonzero status (FALSE) otherwise. -func_cygming_gnu_implib_p () -{ - $opt_debug - func_to_tool_file "$1" func_convert_file_msys_to_w32 - func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` - test -n "$func_cygming_gnu_implib_tmp" -} - -# func_cygming_ms_implib_p ARG -# This predicate returns with zero status (TRUE) if -# ARG is an MS-style import library. Returns -# with nonzero status (FALSE) otherwise. -func_cygming_ms_implib_p () -{ - $opt_debug - func_to_tool_file "$1" func_convert_file_msys_to_w32 - func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` - test -n "$func_cygming_ms_implib_tmp" -} - -# func_cygming_dll_for_implib_fallback ARG -# Platform-specific function to extract the -# name of the DLL associated with the specified -# import library ARG. -# -# This fallback implementation is for use when $DLLTOOL -# does not support the --identify-strict option. -# Invoked by eval'ing the libtool variable -# $sharedlib_from_linklib_cmd -# Result is available in the variable -# $sharedlib_from_linklib_result -func_cygming_dll_for_implib_fallback () -{ - $opt_debug - if func_cygming_gnu_implib_p "$1" ; then - # binutils import library - sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` - elif func_cygming_ms_implib_p "$1" ; then - # ms-generated import library - sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` - else - # unknown - sharedlib_from_linklib_result="" - fi -} - - -# func_extract_an_archive dir oldlib -func_extract_an_archive () -{ - $opt_debug - f_ex_an_ar_dir="$1"; shift - f_ex_an_ar_oldlib="$1" - if test "$lock_old_archive_extraction" = yes; then - lockfile=$f_ex_an_ar_oldlib.lock - until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do - func_echo "Waiting for $lockfile to be removed" - sleep 2 - done - fi - func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ - 'stat=$?; rm -f "$lockfile"; exit $stat' - if test "$lock_old_archive_extraction" = yes; then - $opt_dry_run || rm -f "$lockfile" - fi - if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then - : - else - func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" - fi -} - - -# func_extract_archives gentop oldlib ... -func_extract_archives () -{ - $opt_debug - my_gentop="$1"; shift - my_oldlibs=${1+"$@"} - my_oldobjs="" - my_xlib="" - my_xabs="" - my_xdir="" - - for my_xlib in $my_oldlibs; do - # Extract the objects. - case $my_xlib in - [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; - *) my_xabs=`pwd`"/$my_xlib" ;; - esac - func_basename "$my_xlib" - my_xlib="$func_basename_result" - my_xlib_u=$my_xlib - while :; do - case " $extracted_archives " in - *" $my_xlib_u "*) - func_arith $extracted_serial + 1 - extracted_serial=$func_arith_result - my_xlib_u=lt$extracted_serial-$my_xlib ;; - *) break ;; - esac - done - extracted_archives="$extracted_archives $my_xlib_u" - my_xdir="$my_gentop/$my_xlib_u" - - func_mkdir_p "$my_xdir" - - case $host in - *-darwin*) - func_verbose "Extracting $my_xabs" - # Do not bother doing anything if just a dry run - $opt_dry_run || { - darwin_orig_dir=`pwd` - cd $my_xdir || exit $? - darwin_archive=$my_xabs - darwin_curdir=`pwd` - darwin_base_archive=`basename "$darwin_archive"` - darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` - if test -n "$darwin_arches"; then - darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` - darwin_arch= - func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" - for darwin_arch in $darwin_arches ; do - func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" - $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" - cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" - func_extract_an_archive "`pwd`" "${darwin_base_archive}" - cd "$darwin_curdir" - $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" - done # $darwin_arches - ## Okay now we've a bunch of thin objects, gotta fatten them up :) - darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` - darwin_file= - darwin_files= - for darwin_file in $darwin_filelist; do - darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` - $LIPO -create -output "$darwin_file" $darwin_files - done # $darwin_filelist - $RM -rf unfat-$$ - cd "$darwin_orig_dir" - else - cd $darwin_orig_dir - func_extract_an_archive "$my_xdir" "$my_xabs" - fi # $darwin_arches - } # !$opt_dry_run - ;; - *) - func_extract_an_archive "$my_xdir" "$my_xabs" - ;; - esac - my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` - done - - func_extract_archives_result="$my_oldobjs" -} - - -# func_emit_wrapper [arg=no] -# -# Emit a libtool wrapper script on stdout. -# Don't directly open a file because we may want to -# incorporate the script contents within a cygwin/mingw -# wrapper executable. Must ONLY be called from within -# func_mode_link because it depends on a number of variables -# set therein. -# -# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR -# variable will take. If 'yes', then the emitted script -# will assume that the directory in which it is stored is -# the $objdir directory. This is a cygwin/mingw-specific -# behavior. -func_emit_wrapper () -{ - func_emit_wrapper_arg1=${1-no} - - $ECHO "\ -#! $SHELL - -# $output - temporary wrapper script for $objdir/$outputname -# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION -# -# The $output program cannot be directly executed until all the libtool -# libraries that it depends on are installed. -# -# This wrapper script should never be moved out of the build directory. -# If it is, it will not operate correctly. - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -sed_quote_subst='$sed_quote_subst' - -# Be Bourne compatible -if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which - # is contrary to our usage. Disable this feature. - alias -g '\${1+\"\$@\"}'='\"\$@\"' - setopt NO_GLOB_SUBST -else - case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac -fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -relink_command=\"$relink_command\" - -# This environment variable determines our operation mode. -if test \"\$libtool_install_magic\" = \"$magic\"; then - # install mode needs the following variables: - generated_by_libtool_version='$macro_version' - notinst_deplibs='$notinst_deplibs' -else - # When we are sourced in execute mode, \$file and \$ECHO are already set. - if test \"\$libtool_execute_magic\" != \"$magic\"; then - file=\"\$0\"" - - qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` - $ECHO "\ - -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -\$1 -_LTECHO_EOF' -} - ECHO=\"$qECHO\" - fi - -# Very basic option parsing. These options are (a) specific to -# the libtool wrapper, (b) are identical between the wrapper -# /script/ and the wrapper /executable/ which is used only on -# windows platforms, and (c) all begin with the string "--lt-" -# (application programs are unlikely to have options which match -# this pattern). -# -# There are only two supported options: --lt-debug and -# --lt-dump-script. There is, deliberately, no --lt-help. -# -# The first argument to this parsing function should be the -# script's $0 value, followed by "$@". -lt_option_debug= -func_parse_lt_options () -{ - lt_script_arg0=\$0 - shift - for lt_opt - do - case \"\$lt_opt\" in - --lt-debug) lt_option_debug=1 ;; - --lt-dump-script) - lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` - test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. - lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` - cat \"\$lt_dump_D/\$lt_dump_F\" - exit 0 - ;; - --lt-*) - \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 - exit 1 - ;; - esac - done - - # Print the debug banner immediately: - if test -n \"\$lt_option_debug\"; then - echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 - fi -} - -# Used when --lt-debug. Prints its arguments to stdout -# (redirection is the responsibility of the caller) -func_lt_dump_args () -{ - lt_dump_args_N=1; - for lt_arg - do - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" - lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` - done -} - -# Core function for launching the target application -func_exec_program_core () -{ -" - case $host in - # Backslashes separate directories on plain windows - *-*-mingw | *-*-os2* | *-cegcc*) - $ECHO "\ - if test -n \"\$lt_option_debug\"; then - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 - func_lt_dump_args \${1+\"\$@\"} 1>&2 - fi - exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} -" - ;; - - *) - $ECHO "\ - if test -n \"\$lt_option_debug\"; then - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 - func_lt_dump_args \${1+\"\$@\"} 1>&2 - fi - exec \"\$progdir/\$program\" \${1+\"\$@\"} -" - ;; - esac - $ECHO "\ - \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 - exit 1 -} - -# A function to encapsulate launching the target application -# Strips options in the --lt-* namespace from \$@ and -# launches target application with the remaining arguments. -func_exec_program () -{ - case \" \$* \" in - *\\ --lt-*) - for lt_wr_arg - do - case \$lt_wr_arg in - --lt-*) ;; - *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; - esac - shift - done ;; - esac - func_exec_program_core \${1+\"\$@\"} -} - - # Parse options - func_parse_lt_options \"\$0\" \${1+\"\$@\"} - - # Find the directory that this script lives in. - thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` - test \"x\$thisdir\" = \"x\$file\" && thisdir=. - - # Follow symbolic links until we get to the real thisdir. - file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` - while test -n \"\$file\"; do - destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` - - # If there was a directory component, then change thisdir. - if test \"x\$destdir\" != \"x\$file\"; then - case \"\$destdir\" in - [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; - *) thisdir=\"\$thisdir/\$destdir\" ;; - esac - fi - - file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` - file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` - done - - # Usually 'no', except on cygwin/mingw when embedded into - # the cwrapper. - WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 - if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then - # special case for '.' - if test \"\$thisdir\" = \".\"; then - thisdir=\`pwd\` - fi - # remove .libs from thisdir - case \"\$thisdir\" in - *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; - $objdir ) thisdir=. ;; - esac - fi - - # Try to get the absolute directory name. - absdir=\`cd \"\$thisdir\" && pwd\` - test -n \"\$absdir\" && thisdir=\"\$absdir\" -" - - if test "$fast_install" = yes; then - $ECHO "\ - program=lt-'$outputname'$exeext - progdir=\"\$thisdir/$objdir\" - - if test ! -f \"\$progdir/\$program\" || - { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ - test \"X\$file\" != \"X\$progdir/\$program\"; }; then - - file=\"\$\$-\$program\" - - if test ! -d \"\$progdir\"; then - $MKDIR \"\$progdir\" - else - $RM \"\$progdir/\$file\" - fi" - - $ECHO "\ - - # relink executable if necessary - if test -n \"\$relink_command\"; then - if relink_command_output=\`eval \$relink_command 2>&1\`; then : - else - $ECHO \"\$relink_command_output\" >&2 - $RM \"\$progdir/\$file\" - exit 1 - fi - fi - - $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || - { $RM \"\$progdir/\$program\"; - $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } - $RM \"\$progdir/\$file\" - fi" - else - $ECHO "\ - program='$outputname' - progdir=\"\$thisdir/$objdir\" -" - fi - - $ECHO "\ - - if test -f \"\$progdir/\$program\"; then" - - # fixup the dll searchpath if we need to. - # - # Fix the DLL searchpath if we need to. Do this before prepending - # to shlibpath, because on Windows, both are PATH and uninstalled - # libraries must come first. - if test -n "$dllsearchpath"; then - $ECHO "\ - # Add the dll search path components to the executable PATH - PATH=$dllsearchpath:\$PATH -" - fi - - # Export our shlibpath_var if we have one. - if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then - $ECHO "\ - # Add our own library path to $shlibpath_var - $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" - - # Some systems cannot cope with colon-terminated $shlibpath_var - # The second colon is a workaround for a bug in BeOS R4 sed - $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` - - export $shlibpath_var -" - fi - - $ECHO "\ - if test \"\$libtool_execute_magic\" != \"$magic\"; then - # Run the actual program with our arguments. - func_exec_program \${1+\"\$@\"} - fi - else - # The program doesn't exist. - \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 - \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 - \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 - exit 1 - fi -fi\ -" -} - - -# func_emit_cwrapperexe_src -# emit the source code for a wrapper executable on stdout -# Must ONLY be called from within func_mode_link because -# it depends on a number of variable set therein. -func_emit_cwrapperexe_src () -{ - cat < -#include -#ifdef _MSC_VER -# include -# include -# include -#else -# include -# include -# ifdef __CYGWIN__ -# include -# endif -#endif -#include -#include -#include -#include -#include -#include -#include -#include - -/* declarations of non-ANSI functions */ -#if defined(__MINGW32__) -# ifdef __STRICT_ANSI__ -int _putenv (const char *); -# endif -#elif defined(__CYGWIN__) -# ifdef __STRICT_ANSI__ -char *realpath (const char *, char *); -int putenv (char *); -int setenv (const char *, const char *, int); -# endif -/* #elif defined (other platforms) ... */ -#endif - -/* portability defines, excluding path handling macros */ -#if defined(_MSC_VER) -# define setmode _setmode -# define stat _stat -# define chmod _chmod -# define getcwd _getcwd -# define putenv _putenv -# define S_IXUSR _S_IEXEC -# ifndef _INTPTR_T_DEFINED -# define _INTPTR_T_DEFINED -# define intptr_t int -# endif -#elif defined(__MINGW32__) -# define setmode _setmode -# define stat _stat -# define chmod _chmod -# define getcwd _getcwd -# define putenv _putenv -#elif defined(__CYGWIN__) -# define HAVE_SETENV -# define FOPEN_WB "wb" -/* #elif defined (other platforms) ... */ -#endif - -#if defined(PATH_MAX) -# define LT_PATHMAX PATH_MAX -#elif defined(MAXPATHLEN) -# define LT_PATHMAX MAXPATHLEN -#else -# define LT_PATHMAX 1024 -#endif - -#ifndef S_IXOTH -# define S_IXOTH 0 -#endif -#ifndef S_IXGRP -# define S_IXGRP 0 -#endif - -/* path handling portability macros */ -#ifndef DIR_SEPARATOR -# define DIR_SEPARATOR '/' -# define PATH_SEPARATOR ':' -#endif - -#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ - defined (__OS2__) -# define HAVE_DOS_BASED_FILE_SYSTEM -# define FOPEN_WB "wb" -# ifndef DIR_SEPARATOR_2 -# define DIR_SEPARATOR_2 '\\' -# endif -# ifndef PATH_SEPARATOR_2 -# define PATH_SEPARATOR_2 ';' -# endif -#endif - -#ifndef DIR_SEPARATOR_2 -# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) -#else /* DIR_SEPARATOR_2 */ -# define IS_DIR_SEPARATOR(ch) \ - (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) -#endif /* DIR_SEPARATOR_2 */ - -#ifndef PATH_SEPARATOR_2 -# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) -#else /* PATH_SEPARATOR_2 */ -# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) -#endif /* PATH_SEPARATOR_2 */ - -#ifndef FOPEN_WB -# define FOPEN_WB "w" -#endif -#ifndef _O_BINARY -# define _O_BINARY 0 -#endif - -#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) -#define XFREE(stale) do { \ - if (stale) { free ((void *) stale); stale = 0; } \ -} while (0) - -#if defined(LT_DEBUGWRAPPER) -static int lt_debug = 1; -#else -static int lt_debug = 0; -#endif - -const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ - -void *xmalloc (size_t num); -char *xstrdup (const char *string); -const char *base_name (const char *name); -char *find_executable (const char *wrapper); -char *chase_symlinks (const char *pathspec); -int make_executable (const char *path); -int check_executable (const char *path); -char *strendzap (char *str, const char *pat); -void lt_debugprintf (const char *file, int line, const char *fmt, ...); -void lt_fatal (const char *file, int line, const char *message, ...); -static const char *nonnull (const char *s); -static const char *nonempty (const char *s); -void lt_setenv (const char *name, const char *value); -char *lt_extend_str (const char *orig_value, const char *add, int to_end); -void lt_update_exe_path (const char *name, const char *value); -void lt_update_lib_path (const char *name, const char *value); -char **prepare_spawn (char **argv); -void lt_dump_script (FILE *f); -EOF - - cat <= 0) - && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) - return 1; - else - return 0; -} - -int -make_executable (const char *path) -{ - int rval = 0; - struct stat st; - - lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", - nonempty (path)); - if ((!path) || (!*path)) - return 0; - - if (stat (path, &st) >= 0) - { - rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); - } - return rval; -} - -/* Searches for the full path of the wrapper. Returns - newly allocated full path name if found, NULL otherwise - Does not chase symlinks, even on platforms that support them. -*/ -char * -find_executable (const char *wrapper) -{ - int has_slash = 0; - const char *p; - const char *p_next; - /* static buffer for getcwd */ - char tmp[LT_PATHMAX + 1]; - int tmp_len; - char *concat_name; - - lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", - nonempty (wrapper)); - - if ((wrapper == NULL) || (*wrapper == '\0')) - return NULL; - - /* Absolute path? */ -#if defined (HAVE_DOS_BASED_FILE_SYSTEM) - if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') - { - concat_name = xstrdup (wrapper); - if (check_executable (concat_name)) - return concat_name; - XFREE (concat_name); - } - else - { -#endif - if (IS_DIR_SEPARATOR (wrapper[0])) - { - concat_name = xstrdup (wrapper); - if (check_executable (concat_name)) - return concat_name; - XFREE (concat_name); - } -#if defined (HAVE_DOS_BASED_FILE_SYSTEM) - } -#endif - - for (p = wrapper; *p; p++) - if (*p == '/') - { - has_slash = 1; - break; - } - if (!has_slash) - { - /* no slashes; search PATH */ - const char *path = getenv ("PATH"); - if (path != NULL) - { - for (p = path; *p; p = p_next) - { - const char *q; - size_t p_len; - for (q = p; *q; q++) - if (IS_PATH_SEPARATOR (*q)) - break; - p_len = q - p; - p_next = (*q == '\0' ? q : q + 1); - if (p_len == 0) - { - /* empty path: current directory */ - if (getcwd (tmp, LT_PATHMAX) == NULL) - lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", - nonnull (strerror (errno))); - tmp_len = strlen (tmp); - concat_name = - XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); - memcpy (concat_name, tmp, tmp_len); - concat_name[tmp_len] = '/'; - strcpy (concat_name + tmp_len + 1, wrapper); - } - else - { - concat_name = - XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); - memcpy (concat_name, p, p_len); - concat_name[p_len] = '/'; - strcpy (concat_name + p_len + 1, wrapper); - } - if (check_executable (concat_name)) - return concat_name; - XFREE (concat_name); - } - } - /* not found in PATH; assume curdir */ - } - /* Relative path | not found in path: prepend cwd */ - if (getcwd (tmp, LT_PATHMAX) == NULL) - lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", - nonnull (strerror (errno))); - tmp_len = strlen (tmp); - concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); - memcpy (concat_name, tmp, tmp_len); - concat_name[tmp_len] = '/'; - strcpy (concat_name + tmp_len + 1, wrapper); - - if (check_executable (concat_name)) - return concat_name; - XFREE (concat_name); - return NULL; -} - -char * -chase_symlinks (const char *pathspec) -{ -#ifndef S_ISLNK - return xstrdup (pathspec); -#else - char buf[LT_PATHMAX]; - struct stat s; - char *tmp_pathspec = xstrdup (pathspec); - char *p; - int has_symlinks = 0; - while (strlen (tmp_pathspec) && !has_symlinks) - { - lt_debugprintf (__FILE__, __LINE__, - "checking path component for symlinks: %s\n", - tmp_pathspec); - if (lstat (tmp_pathspec, &s) == 0) - { - if (S_ISLNK (s.st_mode) != 0) - { - has_symlinks = 1; - break; - } - - /* search backwards for last DIR_SEPARATOR */ - p = tmp_pathspec + strlen (tmp_pathspec) - 1; - while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) - p--; - if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) - { - /* no more DIR_SEPARATORS left */ - break; - } - *p = '\0'; - } - else - { - lt_fatal (__FILE__, __LINE__, - "error accessing file \"%s\": %s", - tmp_pathspec, nonnull (strerror (errno))); - } - } - XFREE (tmp_pathspec); - - if (!has_symlinks) - { - return xstrdup (pathspec); - } - - tmp_pathspec = realpath (pathspec, buf); - if (tmp_pathspec == 0) - { - lt_fatal (__FILE__, __LINE__, - "could not follow symlinks for %s", pathspec); - } - return xstrdup (tmp_pathspec); -#endif -} - -char * -strendzap (char *str, const char *pat) -{ - size_t len, patlen; - - assert (str != NULL); - assert (pat != NULL); - - len = strlen (str); - patlen = strlen (pat); - - if (patlen <= len) - { - str += len - patlen; - if (strcmp (str, pat) == 0) - *str = '\0'; - } - return str; -} - -void -lt_debugprintf (const char *file, int line, const char *fmt, ...) -{ - va_list args; - if (lt_debug) - { - (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); - va_start (args, fmt); - (void) vfprintf (stderr, fmt, args); - va_end (args); - } -} - -static void -lt_error_core (int exit_status, const char *file, - int line, const char *mode, - const char *message, va_list ap) -{ - fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); - vfprintf (stderr, message, ap); - fprintf (stderr, ".\n"); - - if (exit_status >= 0) - exit (exit_status); -} - -void -lt_fatal (const char *file, int line, const char *message, ...) -{ - va_list ap; - va_start (ap, message); - lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); - va_end (ap); -} - -static const char * -nonnull (const char *s) -{ - return s ? s : "(null)"; -} - -static const char * -nonempty (const char *s) -{ - return (s && !*s) ? "(empty)" : nonnull (s); -} - -void -lt_setenv (const char *name, const char *value) -{ - lt_debugprintf (__FILE__, __LINE__, - "(lt_setenv) setting '%s' to '%s'\n", - nonnull (name), nonnull (value)); - { -#ifdef HAVE_SETENV - /* always make a copy, for consistency with !HAVE_SETENV */ - char *str = xstrdup (value); - setenv (name, str, 1); -#else - int len = strlen (name) + 1 + strlen (value) + 1; - char *str = XMALLOC (char, len); - sprintf (str, "%s=%s", name, value); - if (putenv (str) != EXIT_SUCCESS) - { - XFREE (str); - } -#endif - } -} - -char * -lt_extend_str (const char *orig_value, const char *add, int to_end) -{ - char *new_value; - if (orig_value && *orig_value) - { - int orig_value_len = strlen (orig_value); - int add_len = strlen (add); - new_value = XMALLOC (char, add_len + orig_value_len + 1); - if (to_end) - { - strcpy (new_value, orig_value); - strcpy (new_value + orig_value_len, add); - } - else - { - strcpy (new_value, add); - strcpy (new_value + add_len, orig_value); - } - } - else - { - new_value = xstrdup (add); - } - return new_value; -} - -void -lt_update_exe_path (const char *name, const char *value) -{ - lt_debugprintf (__FILE__, __LINE__, - "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", - nonnull (name), nonnull (value)); - - if (name && *name && value && *value) - { - char *new_value = lt_extend_str (getenv (name), value, 0); - /* some systems can't cope with a ':'-terminated path #' */ - int len = strlen (new_value); - while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) - { - new_value[len-1] = '\0'; - } - lt_setenv (name, new_value); - XFREE (new_value); - } -} - -void -lt_update_lib_path (const char *name, const char *value) -{ - lt_debugprintf (__FILE__, __LINE__, - "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", - nonnull (name), nonnull (value)); - - if (name && *name && value && *value) - { - char *new_value = lt_extend_str (getenv (name), value, 0); - lt_setenv (name, new_value); - XFREE (new_value); - } -} - -EOF - case $host_os in - mingw*) - cat <<"EOF" - -/* Prepares an argument vector before calling spawn(). - Note that spawn() does not by itself call the command interpreter - (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : - ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&v); - v.dwPlatformId == VER_PLATFORM_WIN32_NT; - }) ? "cmd.exe" : "command.com"). - Instead it simply concatenates the arguments, separated by ' ', and calls - CreateProcess(). We must quote the arguments since Win32 CreateProcess() - interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a - special way: - - Space and tab are interpreted as delimiters. They are not treated as - delimiters if they are surrounded by double quotes: "...". - - Unescaped double quotes are removed from the input. Their only effect is - that within double quotes, space and tab are treated like normal - characters. - - Backslashes not followed by double quotes are not special. - - But 2*n+1 backslashes followed by a double quote become - n backslashes followed by a double quote (n >= 0): - \" -> " - \\\" -> \" - \\\\\" -> \\" - */ -#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" -#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" -char ** -prepare_spawn (char **argv) -{ - size_t argc; - char **new_argv; - size_t i; - - /* Count number of arguments. */ - for (argc = 0; argv[argc] != NULL; argc++) - ; - - /* Allocate new argument vector. */ - new_argv = XMALLOC (char *, argc + 1); - - /* Put quoted arguments into the new argument vector. */ - for (i = 0; i < argc; i++) - { - const char *string = argv[i]; - - if (string[0] == '\0') - new_argv[i] = xstrdup ("\"\""); - else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) - { - int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); - size_t length; - unsigned int backslashes; - const char *s; - char *quoted_string; - char *p; - - length = 0; - backslashes = 0; - if (quote_around) - length++; - for (s = string; *s != '\0'; s++) - { - char c = *s; - if (c == '"') - length += backslashes + 1; - length++; - if (c == '\\') - backslashes++; - else - backslashes = 0; - } - if (quote_around) - length += backslashes + 1; - - quoted_string = XMALLOC (char, length + 1); - - p = quoted_string; - backslashes = 0; - if (quote_around) - *p++ = '"'; - for (s = string; *s != '\0'; s++) - { - char c = *s; - if (c == '"') - { - unsigned int j; - for (j = backslashes + 1; j > 0; j--) - *p++ = '\\'; - } - *p++ = c; - if (c == '\\') - backslashes++; - else - backslashes = 0; - } - if (quote_around) - { - unsigned int j; - for (j = backslashes; j > 0; j--) - *p++ = '\\'; - *p++ = '"'; - } - *p = '\0'; - - new_argv[i] = quoted_string; - } - else - new_argv[i] = (char *) string; - } - new_argv[argc] = NULL; - - return new_argv; -} -EOF - ;; - esac - - cat <<"EOF" -void lt_dump_script (FILE* f) -{ -EOF - func_emit_wrapper yes | - $SED -n -e ' -s/^\(.\{79\}\)\(..*\)/\1\ -\2/ -h -s/\([\\"]\)/\\\1/g -s/$/\\n/ -s/\([^\n]*\).*/ fputs ("\1", f);/p -g -D' - cat <<"EOF" -} -EOF -} -# end: func_emit_cwrapperexe_src - -# func_win32_import_lib_p ARG -# True if ARG is an import lib, as indicated by $file_magic_cmd -func_win32_import_lib_p () -{ - $opt_debug - case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in - *import*) : ;; - *) false ;; - esac -} - -# func_mode_link arg... -func_mode_link () -{ - $opt_debug - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) - # It is impossible to link a dll without this setting, and - # we shouldn't force the makefile maintainer to figure out - # which system we are compiling for in order to pass an extra - # flag for every libtool invocation. - # allow_undefined=no - - # FIXME: Unfortunately, there are problems with the above when trying - # to make a dll which has undefined symbols, in which case not - # even a static library is built. For now, we need to specify - # -no-undefined on the libtool link line when we can be certain - # that all symbols are satisfied, otherwise we get a static library. - allow_undefined=yes - ;; - *) - allow_undefined=yes - ;; - esac - libtool_args=$nonopt - base_compile="$nonopt $@" - compile_command=$nonopt - finalize_command=$nonopt - - compile_rpath= - finalize_rpath= - compile_shlibpath= - finalize_shlibpath= - convenience= - old_convenience= - deplibs= - old_deplibs= - compiler_flags= - linker_flags= - dllsearchpath= - lib_search_path=`pwd` - inst_prefix_dir= - new_inherited_linker_flags= - - avoid_version=no - bindir= - dlfiles= - dlprefiles= - dlself=no - export_dynamic=no - export_symbols= - export_symbols_regex= - generated= - libobjs= - ltlibs= - module=no - no_install=no - objs= - non_pic_objects= - precious_files_regex= - prefer_static_libs=no - preload=no - prev= - prevarg= - release= - rpath= - xrpath= - perm_rpath= - temp_rpath= - thread_safe=no - vinfo= - vinfo_number=no - weak_libs= - single_module="${wl}-single_module" - func_infer_tag $base_compile - - # We need to know -static, to get the right output filenames. - for arg - do - case $arg in - -shared) - test "$build_libtool_libs" != yes && \ - func_fatal_configuration "can not build a shared library" - build_old_libs=no - break - ;; - -all-static | -static | -static-libtool-libs) - case $arg in - -all-static) - if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then - func_warning "complete static linking is impossible in this configuration" - fi - if test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - prefer_static_libs=yes - ;; - -static) - if test -z "$pic_flag" && test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - prefer_static_libs=built - ;; - -static-libtool-libs) - if test -z "$pic_flag" && test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - prefer_static_libs=yes - ;; - esac - build_libtool_libs=no - build_old_libs=yes - break - ;; - esac - done - - # See if our shared archives depend on static archives. - test -n "$old_archive_from_new_cmds" && build_old_libs=yes - - # Go through the arguments, transforming them on the way. - while test "$#" -gt 0; do - arg="$1" - shift - func_quote_for_eval "$arg" - qarg=$func_quote_for_eval_unquoted_result - func_append libtool_args " $func_quote_for_eval_result" - - # If the previous option needs an argument, assign it. - if test -n "$prev"; then - case $prev in - output) - func_append compile_command " @OUTPUT@" - func_append finalize_command " @OUTPUT@" - ;; - esac - - case $prev in - bindir) - bindir="$arg" - prev= - continue - ;; - dlfiles|dlprefiles) - if test "$preload" = no; then - # Add the symbol object into the linking commands. - func_append compile_command " @SYMFILE@" - func_append finalize_command " @SYMFILE@" - preload=yes - fi - case $arg in - *.la | *.lo) ;; # We handle these cases below. - force) - if test "$dlself" = no; then - dlself=needless - export_dynamic=yes - fi - prev= - continue - ;; - self) - if test "$prev" = dlprefiles; then - dlself=yes - elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then - dlself=yes - else - dlself=needless - export_dynamic=yes - fi - prev= - continue - ;; - *) - if test "$prev" = dlfiles; then - func_append dlfiles " $arg" - else - func_append dlprefiles " $arg" - fi - prev= - continue - ;; - esac - ;; - expsyms) - export_symbols="$arg" - test -f "$arg" \ - || func_fatal_error "symbol file \`$arg' does not exist" - prev= - continue - ;; - expsyms_regex) - export_symbols_regex="$arg" - prev= - continue - ;; - framework) - case $host in - *-*-darwin*) - case "$deplibs " in - *" $qarg.ltframework "*) ;; - *) func_append deplibs " $qarg.ltframework" # this is fixed later - ;; - esac - ;; - esac - prev= - continue - ;; - inst_prefix) - inst_prefix_dir="$arg" - prev= - continue - ;; - objectlist) - if test -f "$arg"; then - save_arg=$arg - moreargs= - for fil in `cat "$save_arg"` - do -# func_append moreargs " $fil" - arg=$fil - # A libtool-controlled object. - - # Check to see that this really is a libtool object. - if func_lalib_unsafe_p "$arg"; then - pic_object= - non_pic_object= - - # Read the .lo file - func_source "$arg" - - if test -z "$pic_object" || - test -z "$non_pic_object" || - test "$pic_object" = none && - test "$non_pic_object" = none; then - func_fatal_error "cannot find name of object for \`$arg'" - fi - - # Extract subdirectory from the argument. - func_dirname "$arg" "/" "" - xdir="$func_dirname_result" - - if test "$pic_object" != none; then - # Prepend the subdirectory the object is found in. - pic_object="$xdir$pic_object" - - if test "$prev" = dlfiles; then - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then - func_append dlfiles " $pic_object" - prev= - continue - else - # If libtool objects are unsupported, then we need to preload. - prev=dlprefiles - fi - fi - - # CHECK ME: I think I busted this. -Ossama - if test "$prev" = dlprefiles; then - # Preload the old-style object. - func_append dlprefiles " $pic_object" - prev= - fi - - # A PIC object. - func_append libobjs " $pic_object" - arg="$pic_object" - fi - - # Non-PIC object. - if test "$non_pic_object" != none; then - # Prepend the subdirectory the object is found in. - non_pic_object="$xdir$non_pic_object" - - # A standard non-PIC object - func_append non_pic_objects " $non_pic_object" - if test -z "$pic_object" || test "$pic_object" = none ; then - arg="$non_pic_object" - fi - else - # If the PIC object exists, use it instead. - # $xdir was prepended to $pic_object above. - non_pic_object="$pic_object" - func_append non_pic_objects " $non_pic_object" - fi - else - # Only an error if not doing a dry-run. - if $opt_dry_run; then - # Extract subdirectory from the argument. - func_dirname "$arg" "/" "" - xdir="$func_dirname_result" - - func_lo2o "$arg" - pic_object=$xdir$objdir/$func_lo2o_result - non_pic_object=$xdir$func_lo2o_result - func_append libobjs " $pic_object" - func_append non_pic_objects " $non_pic_object" - else - func_fatal_error "\`$arg' is not a valid libtool object" - fi - fi - done - else - func_fatal_error "link input file \`$arg' does not exist" - fi - arg=$save_arg - prev= - continue - ;; - precious_regex) - precious_files_regex="$arg" - prev= - continue - ;; - release) - release="-$arg" - prev= - continue - ;; - rpath | xrpath) - # We need an absolute path. - case $arg in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - func_fatal_error "only absolute run-paths are allowed" - ;; - esac - if test "$prev" = rpath; then - case "$rpath " in - *" $arg "*) ;; - *) func_append rpath " $arg" ;; - esac - else - case "$xrpath " in - *" $arg "*) ;; - *) func_append xrpath " $arg" ;; - esac - fi - prev= - continue - ;; - shrext) - shrext_cmds="$arg" - prev= - continue - ;; - weak) - func_append weak_libs " $arg" - prev= - continue - ;; - xcclinker) - func_append linker_flags " $qarg" - func_append compiler_flags " $qarg" - prev= - func_append compile_command " $qarg" - func_append finalize_command " $qarg" - continue - ;; - xcompiler) - func_append compiler_flags " $qarg" - prev= - func_append compile_command " $qarg" - func_append finalize_command " $qarg" - continue - ;; - xlinker) - func_append linker_flags " $qarg" - func_append compiler_flags " $wl$qarg" - prev= - func_append compile_command " $wl$qarg" - func_append finalize_command " $wl$qarg" - continue - ;; - *) - eval "$prev=\"\$arg\"" - prev= - continue - ;; - esac - fi # test -n "$prev" - - prevarg="$arg" - - case $arg in - -all-static) - if test -n "$link_static_flag"; then - # See comment for -static flag below, for more details. - func_append compile_command " $link_static_flag" - func_append finalize_command " $link_static_flag" - fi - continue - ;; - - -allow-undefined) - # FIXME: remove this flag sometime in the future. - func_fatal_error "\`-allow-undefined' must not be used because it is the default" - ;; - - -avoid-version) - avoid_version=yes - continue - ;; - - -bindir) - prev=bindir - continue - ;; - - -dlopen) - prev=dlfiles - continue - ;; - - -dlpreopen) - prev=dlprefiles - continue - ;; - - -export-dynamic) - export_dynamic=yes - continue - ;; - - -export-symbols | -export-symbols-regex) - if test -n "$export_symbols" || test -n "$export_symbols_regex"; then - func_fatal_error "more than one -exported-symbols argument is not allowed" - fi - if test "X$arg" = "X-export-symbols"; then - prev=expsyms - else - prev=expsyms_regex - fi - continue - ;; - - -framework) - prev=framework - continue - ;; - - -inst-prefix-dir) - prev=inst_prefix - continue - ;; - - # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* - # so, if we see these flags be careful not to treat them like -L - -L[A-Z][A-Z]*:*) - case $with_gcc/$host in - no/*-*-irix* | /*-*-irix*) - func_append compile_command " $arg" - func_append finalize_command " $arg" - ;; - esac - continue - ;; - - -L*) - func_stripname "-L" '' "$arg" - if test -z "$func_stripname_result"; then - if test "$#" -gt 0; then - func_fatal_error "require no space between \`-L' and \`$1'" - else - func_fatal_error "need path for \`-L' option" - fi - fi - func_resolve_sysroot "$func_stripname_result" - dir=$func_resolve_sysroot_result - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - absdir=`cd "$dir" && pwd` - test -z "$absdir" && \ - func_fatal_error "cannot determine absolute directory name of \`$dir'" - dir="$absdir" - ;; - esac - case "$deplibs " in - *" -L$dir "* | *" $arg "*) - # Will only happen for absolute or sysroot arguments - ;; - *) - # Preserve sysroot, but never include relative directories - case $dir in - [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; - *) func_append deplibs " -L$dir" ;; - esac - func_append lib_search_path " $dir" - ;; - esac - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) - testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` - case :$dllsearchpath: in - *":$dir:"*) ;; - ::) dllsearchpath=$dir;; - *) func_append dllsearchpath ":$dir";; - esac - case :$dllsearchpath: in - *":$testbindir:"*) ;; - ::) dllsearchpath=$testbindir;; - *) func_append dllsearchpath ":$testbindir";; - esac - ;; - esac - continue - ;; - - -l*) - if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) - # These systems don't actually have a C or math library (as such) - continue - ;; - *-*-os2*) - # These systems don't actually have a C library (as such) - test "X$arg" = "X-lc" && continue - ;; - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) - # Do not include libc due to us having libc/libc_r. - test "X$arg" = "X-lc" && continue - ;; - *-*-rhapsody* | *-*-darwin1.[012]) - # Rhapsody C and math libraries are in the System framework - func_append deplibs " System.ltframework" - continue - ;; - *-*-sco3.2v5* | *-*-sco5v6*) - # Causes problems with __ctype - test "X$arg" = "X-lc" && continue - ;; - *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) - # Compiler inserts libc in the correct place for threads to work - test "X$arg" = "X-lc" && continue - ;; - esac - elif test "X$arg" = "X-lc_r"; then - case $host in - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) - # Do not include libc_r directly, use -pthread flag. - continue - ;; - esac - fi - func_append deplibs " $arg" - continue - ;; - - -module) - module=yes - continue - ;; - - # Tru64 UNIX uses -model [arg] to determine the layout of C++ - # classes, name mangling, and exception handling. - # Darwin uses the -arch flag to determine output architecture. - -model|-arch|-isysroot|--sysroot) - func_append compiler_flags " $arg" - func_append compile_command " $arg" - func_append finalize_command " $arg" - prev=xcompiler - continue - ;; - - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ - |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) - func_append compiler_flags " $arg" - func_append compile_command " $arg" - func_append finalize_command " $arg" - case "$new_inherited_linker_flags " in - *" $arg "*) ;; - * ) func_append new_inherited_linker_flags " $arg" ;; - esac - continue - ;; - - -multi_module) - single_module="${wl}-multi_module" - continue - ;; - - -no-fast-install) - fast_install=no - continue - ;; - - -no-install) - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) - # The PATH hackery in wrapper scripts is required on Windows - # and Darwin in order for the loader to find any dlls it needs. - func_warning "\`-no-install' is ignored for $host" - func_warning "assuming \`-no-fast-install' instead" - fast_install=no - ;; - *) no_install=yes ;; - esac - continue - ;; - - -no-undefined) - allow_undefined=no - continue - ;; - - -objectlist) - prev=objectlist - continue - ;; - - -o) prev=output ;; - - -precious-files-regex) - prev=precious_regex - continue - ;; - - -release) - prev=release - continue - ;; - - -rpath) - prev=rpath - continue - ;; - - -R) - prev=xrpath - continue - ;; - - -R*) - func_stripname '-R' '' "$arg" - dir=$func_stripname_result - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - =*) - func_stripname '=' '' "$dir" - dir=$lt_sysroot$func_stripname_result - ;; - *) - func_fatal_error "only absolute run-paths are allowed" - ;; - esac - case "$xrpath " in - *" $dir "*) ;; - *) func_append xrpath " $dir" ;; - esac - continue - ;; - - -shared) - # The effects of -shared are defined in a previous loop. - continue - ;; - - -shrext) - prev=shrext - continue - ;; - - -static | -static-libtool-libs) - # The effects of -static are defined in a previous loop. - # We used to do the same as -all-static on platforms that - # didn't have a PIC flag, but the assumption that the effects - # would be equivalent was wrong. It would break on at least - # Digital Unix and AIX. - continue - ;; - - -thread-safe) - thread_safe=yes - continue - ;; - - -version-info) - prev=vinfo - continue - ;; - - -version-number) - prev=vinfo - vinfo_number=yes - continue - ;; - - -weak) - prev=weak - continue - ;; - - -Wc,*) - func_stripname '-Wc,' '' "$arg" - args=$func_stripname_result - arg= - save_ifs="$IFS"; IFS=',' - for flag in $args; do - IFS="$save_ifs" - func_quote_for_eval "$flag" - func_append arg " $func_quote_for_eval_result" - func_append compiler_flags " $func_quote_for_eval_result" - done - IFS="$save_ifs" - func_stripname ' ' '' "$arg" - arg=$func_stripname_result - ;; - - -Wl,*) - func_stripname '-Wl,' '' "$arg" - args=$func_stripname_result - arg= - save_ifs="$IFS"; IFS=',' - for flag in $args; do - IFS="$save_ifs" - func_quote_for_eval "$flag" - func_append arg " $wl$func_quote_for_eval_result" - func_append compiler_flags " $wl$func_quote_for_eval_result" - func_append linker_flags " $func_quote_for_eval_result" - done - IFS="$save_ifs" - func_stripname ' ' '' "$arg" - arg=$func_stripname_result - ;; - - -Xcompiler) - prev=xcompiler - continue - ;; - - -Xlinker) - prev=xlinker - continue - ;; - - -XCClinker) - prev=xcclinker - continue - ;; - - # -msg_* for osf cc - -msg_*) - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - ;; - - # Flags to be passed through unchanged, with rationale: - # -64, -mips[0-9] enable 64-bit mode for the SGI compiler - # -r[0-9][0-9]* specify processor for the SGI compiler - # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler - # +DA*, +DD* enable 64-bit mode for the HP compiler - # -q* compiler args for the IBM compiler - # -m*, -t[45]*, -txscale* architecture-specific flags for GCC - # -F/path path to uninstalled frameworks, gcc on darwin - # -p, -pg, --coverage, -fprofile-* profiling flags for GCC - # @file GCC response files - # -tp=* Portland pgcc target processor selection - # --sysroot=* for sysroot support - # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization - -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ - -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ - -O*|-flto*|-fwhopr*|-fuse-linker-plugin) - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - func_append compile_command " $arg" - func_append finalize_command " $arg" - func_append compiler_flags " $arg" - continue - ;; - - # Some other compiler flag. - -* | +*) - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - ;; - - *.$objext) - # A standard object. - func_append objs " $arg" - ;; - - *.lo) - # A libtool-controlled object. - - # Check to see that this really is a libtool object. - if func_lalib_unsafe_p "$arg"; then - pic_object= - non_pic_object= - - # Read the .lo file - func_source "$arg" - - if test -z "$pic_object" || - test -z "$non_pic_object" || - test "$pic_object" = none && - test "$non_pic_object" = none; then - func_fatal_error "cannot find name of object for \`$arg'" - fi - - # Extract subdirectory from the argument. - func_dirname "$arg" "/" "" - xdir="$func_dirname_result" - - if test "$pic_object" != none; then - # Prepend the subdirectory the object is found in. - pic_object="$xdir$pic_object" - - if test "$prev" = dlfiles; then - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then - func_append dlfiles " $pic_object" - prev= - continue - else - # If libtool objects are unsupported, then we need to preload. - prev=dlprefiles - fi - fi - - # CHECK ME: I think I busted this. -Ossama - if test "$prev" = dlprefiles; then - # Preload the old-style object. - func_append dlprefiles " $pic_object" - prev= - fi - - # A PIC object. - func_append libobjs " $pic_object" - arg="$pic_object" - fi - - # Non-PIC object. - if test "$non_pic_object" != none; then - # Prepend the subdirectory the object is found in. - non_pic_object="$xdir$non_pic_object" - - # A standard non-PIC object - func_append non_pic_objects " $non_pic_object" - if test -z "$pic_object" || test "$pic_object" = none ; then - arg="$non_pic_object" - fi - else - # If the PIC object exists, use it instead. - # $xdir was prepended to $pic_object above. - non_pic_object="$pic_object" - func_append non_pic_objects " $non_pic_object" - fi - else - # Only an error if not doing a dry-run. - if $opt_dry_run; then - # Extract subdirectory from the argument. - func_dirname "$arg" "/" "" - xdir="$func_dirname_result" - - func_lo2o "$arg" - pic_object=$xdir$objdir/$func_lo2o_result - non_pic_object=$xdir$func_lo2o_result - func_append libobjs " $pic_object" - func_append non_pic_objects " $non_pic_object" - else - func_fatal_error "\`$arg' is not a valid libtool object" - fi - fi - ;; - - *.$libext) - # An archive. - func_append deplibs " $arg" - func_append old_deplibs " $arg" - continue - ;; - - *.la) - # A libtool-controlled library. - - func_resolve_sysroot "$arg" - if test "$prev" = dlfiles; then - # This library was specified with -dlopen. - func_append dlfiles " $func_resolve_sysroot_result" - prev= - elif test "$prev" = dlprefiles; then - # The library was specified with -dlpreopen. - func_append dlprefiles " $func_resolve_sysroot_result" - prev= - else - func_append deplibs " $func_resolve_sysroot_result" - fi - continue - ;; - - # Some other compiler argument. - *) - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - ;; - esac # arg - - # Now actually substitute the argument into the commands. - if test -n "$arg"; then - func_append compile_command " $arg" - func_append finalize_command " $arg" - fi - done # argument parsing loop - - test -n "$prev" && \ - func_fatal_help "the \`$prevarg' option requires an argument" - - if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then - eval arg=\"$export_dynamic_flag_spec\" - func_append compile_command " $arg" - func_append finalize_command " $arg" - fi - - oldlibs= - # calculate the name of the file, without its directory - func_basename "$output" - outputname="$func_basename_result" - libobjs_save="$libobjs" - - if test -n "$shlibpath_var"; then - # get the directories listed in $shlibpath_var - eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` - else - shlib_search_path= - fi - eval sys_lib_search_path=\"$sys_lib_search_path_spec\" - eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" - - func_dirname "$output" "/" "" - output_objdir="$func_dirname_result$objdir" - func_to_tool_file "$output_objdir/" - tool_output_objdir=$func_to_tool_file_result - # Create the object directory. - func_mkdir_p "$output_objdir" - - # Determine the type of output - case $output in - "") - func_fatal_help "you must specify an output file" - ;; - *.$libext) linkmode=oldlib ;; - *.lo | *.$objext) linkmode=obj ;; - *.la) linkmode=lib ;; - *) linkmode=prog ;; # Anything else should be a program. - esac - - specialdeplibs= - - libs= - # Find all interdependent deplibs by searching for libraries - # that are linked more than once (e.g. -la -lb -la) - for deplib in $deplibs; do - if $opt_preserve_dup_deps ; then - case "$libs " in - *" $deplib "*) func_append specialdeplibs " $deplib" ;; - esac - fi - func_append libs " $deplib" - done - - if test "$linkmode" = lib; then - libs="$predeps $libs $compiler_lib_search_path $postdeps" - - # Compute libraries that are listed more than once in $predeps - # $postdeps and mark them as special (i.e., whose duplicates are - # not to be eliminated). - pre_post_deps= - if $opt_duplicate_compiler_generated_deps; then - for pre_post_dep in $predeps $postdeps; do - case "$pre_post_deps " in - *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; - esac - func_append pre_post_deps " $pre_post_dep" - done - fi - pre_post_deps= - fi - - deplibs= - newdependency_libs= - newlib_search_path= - need_relink=no # whether we're linking any uninstalled libtool libraries - notinst_deplibs= # not-installed libtool libraries - notinst_path= # paths that contain not-installed libtool libraries - - case $linkmode in - lib) - passes="conv dlpreopen link" - for file in $dlfiles $dlprefiles; do - case $file in - *.la) ;; - *) - func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" - ;; - esac - done - ;; - prog) - compile_deplibs= - finalize_deplibs= - alldeplibs=no - newdlfiles= - newdlprefiles= - passes="conv scan dlopen dlpreopen link" - ;; - *) passes="conv" - ;; - esac - - for pass in $passes; do - # The preopen pass in lib mode reverses $deplibs; put it back here - # so that -L comes before libs that need it for instance... - if test "$linkmode,$pass" = "lib,link"; then - ## FIXME: Find the place where the list is rebuilt in the wrong - ## order, and fix it there properly - tmp_deplibs= - for deplib in $deplibs; do - tmp_deplibs="$deplib $tmp_deplibs" - done - deplibs="$tmp_deplibs" - fi - - if test "$linkmode,$pass" = "lib,link" || - test "$linkmode,$pass" = "prog,scan"; then - libs="$deplibs" - deplibs= - fi - if test "$linkmode" = prog; then - case $pass in - dlopen) libs="$dlfiles" ;; - dlpreopen) libs="$dlprefiles" ;; - link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; - esac - fi - if test "$linkmode,$pass" = "lib,dlpreopen"; then - # Collect and forward deplibs of preopened libtool libs - for lib in $dlprefiles; do - # Ignore non-libtool-libs - dependency_libs= - func_resolve_sysroot "$lib" - case $lib in - *.la) func_source "$func_resolve_sysroot_result" ;; - esac - - # Collect preopened libtool deplibs, except any this library - # has declared as weak libs - for deplib in $dependency_libs; do - func_basename "$deplib" - deplib_base=$func_basename_result - case " $weak_libs " in - *" $deplib_base "*) ;; - *) func_append deplibs " $deplib" ;; - esac - done - done - libs="$dlprefiles" - fi - if test "$pass" = dlopen; then - # Collect dlpreopened libraries - save_deplibs="$deplibs" - deplibs= - fi - - for deplib in $libs; do - lib= - found=no - case $deplib in - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ - |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - func_append compiler_flags " $deplib" - if test "$linkmode" = lib ; then - case "$new_inherited_linker_flags " in - *" $deplib "*) ;; - * ) func_append new_inherited_linker_flags " $deplib" ;; - esac - fi - fi - continue - ;; - -l*) - if test "$linkmode" != lib && test "$linkmode" != prog; then - func_warning "\`-l' is ignored for archives/objects" - continue - fi - func_stripname '-l' '' "$deplib" - name=$func_stripname_result - if test "$linkmode" = lib; then - searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" - else - searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" - fi - for searchdir in $searchdirs; do - for search_ext in .la $std_shrext .so .a; do - # Search the libtool library - lib="$searchdir/lib${name}${search_ext}" - if test -f "$lib"; then - if test "$search_ext" = ".la"; then - found=yes - else - found=no - fi - break 2 - fi - done - done - if test "$found" != yes; then - # deplib doesn't seem to be a libtool library - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" - fi - continue - else # deplib is a libtool library - # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, - # We need to do some special things here, and not later. - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - case " $predeps $postdeps " in - *" $deplib "*) - if func_lalib_p "$lib"; then - library_names= - old_library= - func_source "$lib" - for l in $old_library $library_names; do - ll="$l" - done - if test "X$ll" = "X$old_library" ; then # only static version available - found=no - func_dirname "$lib" "" "." - ladir="$func_dirname_result" - lib=$ladir/$old_library - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" - fi - continue - fi - fi - ;; - *) ;; - esac - fi - fi - ;; # -l - *.ltframework) - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - if test "$linkmode" = lib ; then - case "$new_inherited_linker_flags " in - *" $deplib "*) ;; - * ) func_append new_inherited_linker_flags " $deplib" ;; - esac - fi - fi - continue - ;; - -L*) - case $linkmode in - lib) - deplibs="$deplib $deplibs" - test "$pass" = conv && continue - newdependency_libs="$deplib $newdependency_libs" - func_stripname '-L' '' "$deplib" - func_resolve_sysroot "$func_stripname_result" - func_append newlib_search_path " $func_resolve_sysroot_result" - ;; - prog) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - continue - fi - if test "$pass" = scan; then - deplibs="$deplib $deplibs" - else - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - fi - func_stripname '-L' '' "$deplib" - func_resolve_sysroot "$func_stripname_result" - func_append newlib_search_path " $func_resolve_sysroot_result" - ;; - *) - func_warning "\`-L' is ignored for archives/objects" - ;; - esac # linkmode - continue - ;; # -L - -R*) - if test "$pass" = link; then - func_stripname '-R' '' "$deplib" - func_resolve_sysroot "$func_stripname_result" - dir=$func_resolve_sysroot_result - # Make sure the xrpath contains only unique directories. - case "$xrpath " in - *" $dir "*) ;; - *) func_append xrpath " $dir" ;; - esac - fi - deplibs="$deplib $deplibs" - continue - ;; - *.la) - func_resolve_sysroot "$deplib" - lib=$func_resolve_sysroot_result - ;; - *.$libext) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - continue - fi - case $linkmode in - lib) - # Linking convenience modules into shared libraries is allowed, - # but linking other static libraries is non-portable. - case " $dlpreconveniencelibs " in - *" $deplib "*) ;; - *) - valid_a_lib=no - case $deplibs_check_method in - match_pattern*) - set dummy $deplibs_check_method; shift - match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` - if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ - | $EGREP "$match_pattern_regex" > /dev/null; then - valid_a_lib=yes - fi - ;; - pass_all) - valid_a_lib=yes - ;; - esac - if test "$valid_a_lib" != yes; then - echo - $ECHO "*** Warning: Trying to link with static lib archive $deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because the file extensions .$libext of this argument makes me believe" - echo "*** that it is just a static archive that I should not use here." - else - echo - $ECHO "*** Warning: Linking the shared library $output against the" - $ECHO "*** static library $deplib is not portable!" - deplibs="$deplib $deplibs" - fi - ;; - esac - continue - ;; - prog) - if test "$pass" != link; then - deplibs="$deplib $deplibs" - else - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - fi - continue - ;; - esac # linkmode - ;; # *.$libext - *.lo | *.$objext) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - elif test "$linkmode" = prog; then - if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then - # If there is no dlopen support or we're linking statically, - # we need to preload. - func_append newdlprefiles " $deplib" - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - func_append newdlfiles " $deplib" - fi - fi - continue - ;; - %DEPLIBS%) - alldeplibs=yes - continue - ;; - esac # case $deplib - - if test "$found" = yes || test -f "$lib"; then : - else - func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" - fi - - # Check to see that this really is a libtool archive. - func_lalib_unsafe_p "$lib" \ - || func_fatal_error "\`$lib' is not a valid libtool archive" - - func_dirname "$lib" "" "." - ladir="$func_dirname_result" - - dlname= - dlopen= - dlpreopen= - libdir= - library_names= - old_library= - inherited_linker_flags= - # If the library was installed with an old release of libtool, - # it will not redefine variables installed, or shouldnotlink - installed=yes - shouldnotlink=no - avoidtemprpath= - - - # Read the .la file - func_source "$lib" - - # Convert "-framework foo" to "foo.ltframework" - if test -n "$inherited_linker_flags"; then - tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` - for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do - case " $new_inherited_linker_flags " in - *" $tmp_inherited_linker_flag "*) ;; - *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; - esac - done - fi - dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - if test "$linkmode,$pass" = "lib,link" || - test "$linkmode,$pass" = "prog,scan" || - { test "$linkmode" != prog && test "$linkmode" != lib; }; then - test -n "$dlopen" && func_append dlfiles " $dlopen" - test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" - fi - - if test "$pass" = conv; then - # Only check for convenience libraries - deplibs="$lib $deplibs" - if test -z "$libdir"; then - if test -z "$old_library"; then - func_fatal_error "cannot find name of link library for \`$lib'" - fi - # It is a libtool convenience library, so add in its objects. - func_append convenience " $ladir/$objdir/$old_library" - func_append old_convenience " $ladir/$objdir/$old_library" - elif test "$linkmode" != prog && test "$linkmode" != lib; then - func_fatal_error "\`$lib' is not a convenience library" - fi - tmp_libs= - for deplib in $dependency_libs; do - deplibs="$deplib $deplibs" - if $opt_preserve_dup_deps ; then - case "$tmp_libs " in - *" $deplib "*) func_append specialdeplibs " $deplib" ;; - esac - fi - func_append tmp_libs " $deplib" - done - continue - fi # $pass = conv - - - # Get the name of the library we link against. - linklib= - if test -n "$old_library" && - { test "$prefer_static_libs" = yes || - test "$prefer_static_libs,$installed" = "built,no"; }; then - linklib=$old_library - else - for l in $old_library $library_names; do - linklib="$l" - done - fi - if test -z "$linklib"; then - func_fatal_error "cannot find name of link library for \`$lib'" - fi - - # This library was specified with -dlopen. - if test "$pass" = dlopen; then - if test -z "$libdir"; then - func_fatal_error "cannot -dlopen a convenience library: \`$lib'" - fi - if test -z "$dlname" || - test "$dlopen_support" != yes || - test "$build_libtool_libs" = no; then - # If there is no dlname, no dlopen support or we're linking - # statically, we need to preload. We also need to preload any - # dependent libraries so libltdl's deplib preloader doesn't - # bomb out in the load deplibs phase. - func_append dlprefiles " $lib $dependency_libs" - else - func_append newdlfiles " $lib" - fi - continue - fi # $pass = dlopen - - # We need an absolute path. - case $ladir in - [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; - *) - abs_ladir=`cd "$ladir" && pwd` - if test -z "$abs_ladir"; then - func_warning "cannot determine absolute directory name of \`$ladir'" - func_warning "passing it literally to the linker, although it might fail" - abs_ladir="$ladir" - fi - ;; - esac - func_basename "$lib" - laname="$func_basename_result" - - # Find the relevant object directory and library name. - if test "X$installed" = Xyes; then - if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then - func_warning "library \`$lib' was moved." - dir="$ladir" - absdir="$abs_ladir" - libdir="$abs_ladir" - else - dir="$lt_sysroot$libdir" - absdir="$lt_sysroot$libdir" - fi - test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes - else - if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then - dir="$ladir" - absdir="$abs_ladir" - # Remove this search path later - func_append notinst_path " $abs_ladir" - else - dir="$ladir/$objdir" - absdir="$abs_ladir/$objdir" - # Remove this search path later - func_append notinst_path " $abs_ladir" - fi - fi # $installed = yes - func_stripname 'lib' '.la' "$laname" - name=$func_stripname_result - - # This library was specified with -dlpreopen. - if test "$pass" = dlpreopen; then - if test -z "$libdir" && test "$linkmode" = prog; then - func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" - fi - case "$host" in - # special handling for platforms with PE-DLLs. - *cygwin* | *mingw* | *cegcc* ) - # Linker will automatically link against shared library if both - # static and shared are present. Therefore, ensure we extract - # symbols from the import library if a shared library is present - # (otherwise, the dlopen module name will be incorrect). We do - # this by putting the import library name into $newdlprefiles. - # We recover the dlopen module name by 'saving' the la file - # name in a special purpose variable, and (later) extracting the - # dlname from the la file. - if test -n "$dlname"; then - func_tr_sh "$dir/$linklib" - eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" - func_append newdlprefiles " $dir/$linklib" - else - func_append newdlprefiles " $dir/$old_library" - # Keep a list of preopened convenience libraries to check - # that they are being used correctly in the link pass. - test -z "$libdir" && \ - func_append dlpreconveniencelibs " $dir/$old_library" - fi - ;; - * ) - # Prefer using a static library (so that no silly _DYNAMIC symbols - # are required to link). - if test -n "$old_library"; then - func_append newdlprefiles " $dir/$old_library" - # Keep a list of preopened convenience libraries to check - # that they are being used correctly in the link pass. - test -z "$libdir" && \ - func_append dlpreconveniencelibs " $dir/$old_library" - # Otherwise, use the dlname, so that lt_dlopen finds it. - elif test -n "$dlname"; then - func_append newdlprefiles " $dir/$dlname" - else - func_append newdlprefiles " $dir/$linklib" - fi - ;; - esac - fi # $pass = dlpreopen - - if test -z "$libdir"; then - # Link the convenience library - if test "$linkmode" = lib; then - deplibs="$dir/$old_library $deplibs" - elif test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$dir/$old_library $compile_deplibs" - finalize_deplibs="$dir/$old_library $finalize_deplibs" - else - deplibs="$lib $deplibs" # used for prog,scan pass - fi - continue - fi - - - if test "$linkmode" = prog && test "$pass" != link; then - func_append newlib_search_path " $ladir" - deplibs="$lib $deplibs" - - linkalldeplibs=no - if test "$link_all_deplibs" != no || test -z "$library_names" || - test "$build_libtool_libs" = no; then - linkalldeplibs=yes - fi - - tmp_libs= - for deplib in $dependency_libs; do - case $deplib in - -L*) func_stripname '-L' '' "$deplib" - func_resolve_sysroot "$func_stripname_result" - func_append newlib_search_path " $func_resolve_sysroot_result" - ;; - esac - # Need to link against all dependency_libs? - if test "$linkalldeplibs" = yes; then - deplibs="$deplib $deplibs" - else - # Need to hardcode shared library paths - # or/and link against static libraries - newdependency_libs="$deplib $newdependency_libs" - fi - if $opt_preserve_dup_deps ; then - case "$tmp_libs " in - *" $deplib "*) func_append specialdeplibs " $deplib" ;; - esac - fi - func_append tmp_libs " $deplib" - done # for deplib - continue - fi # $linkmode = prog... - - if test "$linkmode,$pass" = "prog,link"; then - if test -n "$library_names" && - { { test "$prefer_static_libs" = no || - test "$prefer_static_libs,$installed" = "built,yes"; } || - test -z "$old_library"; }; then - # We need to hardcode the library path - if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then - # Make sure the rpath contains only unique directories. - case "$temp_rpath:" in - *"$absdir:"*) ;; - *) func_append temp_rpath "$absdir:" ;; - esac - fi - - # Hardcode the library path. - # Skip directories that are in the system default run-time - # search path. - case " $sys_lib_dlsearch_path " in - *" $absdir "*) ;; - *) - case "$compile_rpath " in - *" $absdir "*) ;; - *) func_append compile_rpath " $absdir" ;; - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) func_append finalize_rpath " $libdir" ;; - esac - ;; - esac - fi # $linkmode,$pass = prog,link... - - if test "$alldeplibs" = yes && - { test "$deplibs_check_method" = pass_all || - { test "$build_libtool_libs" = yes && - test -n "$library_names"; }; }; then - # We only need to search for static libraries - continue - fi - fi - - link_static=no # Whether the deplib will be linked statically - use_static_libs=$prefer_static_libs - if test "$use_static_libs" = built && test "$installed" = yes; then - use_static_libs=no - fi - if test -n "$library_names" && - { test "$use_static_libs" = no || test -z "$old_library"; }; then - case $host in - *cygwin* | *mingw* | *cegcc*) - # No point in relinking DLLs because paths are not encoded - func_append notinst_deplibs " $lib" - need_relink=no - ;; - *) - if test "$installed" = no; then - func_append notinst_deplibs " $lib" - need_relink=yes - fi - ;; - esac - # This is a shared library - - # Warn about portability, can't link against -module's on some - # systems (darwin). Don't bleat about dlopened modules though! - dlopenmodule="" - for dlpremoduletest in $dlprefiles; do - if test "X$dlpremoduletest" = "X$lib"; then - dlopenmodule="$dlpremoduletest" - break - fi - done - if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then - echo - if test "$linkmode" = prog; then - $ECHO "*** Warning: Linking the executable $output against the loadable module" - else - $ECHO "*** Warning: Linking the shared library $output against the loadable module" - fi - $ECHO "*** $linklib is not portable!" - fi - if test "$linkmode" = lib && - test "$hardcode_into_libs" = yes; then - # Hardcode the library path. - # Skip directories that are in the system default run-time - # search path. - case " $sys_lib_dlsearch_path " in - *" $absdir "*) ;; - *) - case "$compile_rpath " in - *" $absdir "*) ;; - *) func_append compile_rpath " $absdir" ;; - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) func_append finalize_rpath " $libdir" ;; - esac - ;; - esac - fi - - if test -n "$old_archive_from_expsyms_cmds"; then - # figure out the soname - set dummy $library_names - shift - realname="$1" - shift - libname=`eval "\\$ECHO \"$libname_spec\""` - # use dlname if we got it. it's perfectly good, no? - if test -n "$dlname"; then - soname="$dlname" - elif test -n "$soname_spec"; then - # bleh windows - case $host in - *cygwin* | mingw* | *cegcc*) - func_arith $current - $age - major=$func_arith_result - versuffix="-$major" - ;; - esac - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - - # Make a new name for the extract_expsyms_cmds to use - soroot="$soname" - func_basename "$soroot" - soname="$func_basename_result" - func_stripname 'lib' '.dll' "$soname" - newlib=libimp-$func_stripname_result.a - - # If the library has no export list, then create one now - if test -f "$output_objdir/$soname-def"; then : - else - func_verbose "extracting exported symbol list from \`$soname'" - func_execute_cmds "$extract_expsyms_cmds" 'exit $?' - fi - - # Create $newlib - if test -f "$output_objdir/$newlib"; then :; else - func_verbose "generating import library for \`$soname'" - func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' - fi - # make sure the library variables are pointing to the new library - dir=$output_objdir - linklib=$newlib - fi # test -n "$old_archive_from_expsyms_cmds" - - if test "$linkmode" = prog || test "$opt_mode" != relink; then - add_shlibpath= - add_dir= - add= - lib_linked=yes - case $hardcode_action in - immediate | unsupported) - if test "$hardcode_direct" = no; then - add="$dir/$linklib" - case $host in - *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; - *-*-sysv4*uw2*) add_dir="-L$dir" ;; - *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ - *-*-unixware7*) add_dir="-L$dir" ;; - *-*-darwin* ) - # if the lib is a (non-dlopened) module then we can not - # link against it, someone is ignoring the earlier warnings - if /usr/bin/file -L $add 2> /dev/null | - $GREP ": [^:]* bundle" >/dev/null ; then - if test "X$dlopenmodule" != "X$lib"; then - $ECHO "*** Warning: lib $linklib is a module, not a shared library" - if test -z "$old_library" ; then - echo - echo "*** And there doesn't seem to be a static archive available" - echo "*** The link will probably fail, sorry" - else - add="$dir/$old_library" - fi - elif test -n "$old_library"; then - add="$dir/$old_library" - fi - fi - esac - elif test "$hardcode_minus_L" = no; then - case $host in - *-*-sunos*) add_shlibpath="$dir" ;; - esac - add_dir="-L$dir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = no; then - add_shlibpath="$dir" - add="-l$name" - else - lib_linked=no - fi - ;; - relink) - if test "$hardcode_direct" = yes && - test "$hardcode_direct_absolute" = no; then - add="$dir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$absdir" - # Try looking first in the location we're being installed to. - if test -n "$inst_prefix_dir"; then - case $libdir in - [\\/]*) - func_append add_dir " -L$inst_prefix_dir$libdir" - ;; - esac - fi - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - add_shlibpath="$dir" - add="-l$name" - else - lib_linked=no - fi - ;; - *) lib_linked=no ;; - esac - - if test "$lib_linked" != yes; then - func_fatal_configuration "unsupported hardcode properties" - fi - - if test -n "$add_shlibpath"; then - case :$compile_shlibpath: in - *":$add_shlibpath:"*) ;; - *) func_append compile_shlibpath "$add_shlibpath:" ;; - esac - fi - if test "$linkmode" = prog; then - test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" - test -n "$add" && compile_deplibs="$add $compile_deplibs" - else - test -n "$add_dir" && deplibs="$add_dir $deplibs" - test -n "$add" && deplibs="$add $deplibs" - if test "$hardcode_direct" != yes && - test "$hardcode_minus_L" != yes && - test "$hardcode_shlibpath_var" = yes; then - case :$finalize_shlibpath: in - *":$libdir:"*) ;; - *) func_append finalize_shlibpath "$libdir:" ;; - esac - fi - fi - fi - - if test "$linkmode" = prog || test "$opt_mode" = relink; then - add_shlibpath= - add_dir= - add= - # Finalize command for both is simple: just hardcode it. - if test "$hardcode_direct" = yes && - test "$hardcode_direct_absolute" = no; then - add="$libdir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$libdir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - case :$finalize_shlibpath: in - *":$libdir:"*) ;; - *) func_append finalize_shlibpath "$libdir:" ;; - esac - add="-l$name" - elif test "$hardcode_automatic" = yes; then - if test -n "$inst_prefix_dir" && - test -f "$inst_prefix_dir$libdir/$linklib" ; then - add="$inst_prefix_dir$libdir/$linklib" - else - add="$libdir/$linklib" - fi - else - # We cannot seem to hardcode it, guess we'll fake it. - add_dir="-L$libdir" - # Try looking first in the location we're being installed to. - if test -n "$inst_prefix_dir"; then - case $libdir in - [\\/]*) - func_append add_dir " -L$inst_prefix_dir$libdir" - ;; - esac - fi - add="-l$name" - fi - - if test "$linkmode" = prog; then - test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" - test -n "$add" && finalize_deplibs="$add $finalize_deplibs" - else - test -n "$add_dir" && deplibs="$add_dir $deplibs" - test -n "$add" && deplibs="$add $deplibs" - fi - fi - elif test "$linkmode" = prog; then - # Here we assume that one of hardcode_direct or hardcode_minus_L - # is not unsupported. This is valid on all known static and - # shared platforms. - if test "$hardcode_direct" != unsupported; then - test -n "$old_library" && linklib="$old_library" - compile_deplibs="$dir/$linklib $compile_deplibs" - finalize_deplibs="$dir/$linklib $finalize_deplibs" - else - compile_deplibs="-l$name -L$dir $compile_deplibs" - finalize_deplibs="-l$name -L$dir $finalize_deplibs" - fi - elif test "$build_libtool_libs" = yes; then - # Not a shared library - if test "$deplibs_check_method" != pass_all; then - # We're trying link a shared library against a static one - # but the system doesn't support it. - - # Just print a warning and add the library to dependency_libs so - # that the program can be linked against the static library. - echo - $ECHO "*** Warning: This system can not link to static lib archive $lib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have." - if test "$module" = yes; then - echo "*** But as you try to build a module library, libtool will still create " - echo "*** a static module, that should work as long as the dlopening application" - echo "*** is linked with the -dlopen flag to resolve symbols at runtime." - if test -z "$global_symbol_pipe"; then - echo - echo "*** However, this would only work if libtool was able to extract symbol" - echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - echo "*** not find such a program. So, this module is probably useless." - echo "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - fi - else - deplibs="$dir/$old_library $deplibs" - link_static=yes - fi - fi # link shared/static library? - - if test "$linkmode" = lib; then - if test -n "$dependency_libs" && - { test "$hardcode_into_libs" != yes || - test "$build_old_libs" = yes || - test "$link_static" = yes; }; then - # Extract -R from dependency_libs - temp_deplibs= - for libdir in $dependency_libs; do - case $libdir in - -R*) func_stripname '-R' '' "$libdir" - temp_xrpath=$func_stripname_result - case " $xrpath " in - *" $temp_xrpath "*) ;; - *) func_append xrpath " $temp_xrpath";; - esac;; - *) func_append temp_deplibs " $libdir";; - esac - done - dependency_libs="$temp_deplibs" - fi - - func_append newlib_search_path " $absdir" - # Link against this library - test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" - # ... and its dependency_libs - tmp_libs= - for deplib in $dependency_libs; do - newdependency_libs="$deplib $newdependency_libs" - case $deplib in - -L*) func_stripname '-L' '' "$deplib" - func_resolve_sysroot "$func_stripname_result";; - *) func_resolve_sysroot "$deplib" ;; - esac - if $opt_preserve_dup_deps ; then - case "$tmp_libs " in - *" $func_resolve_sysroot_result "*) - func_append specialdeplibs " $func_resolve_sysroot_result" ;; - esac - fi - func_append tmp_libs " $func_resolve_sysroot_result" - done - - if test "$link_all_deplibs" != no; then - # Add the search paths of all dependency libraries - for deplib in $dependency_libs; do - path= - case $deplib in - -L*) path="$deplib" ;; - *.la) - func_resolve_sysroot "$deplib" - deplib=$func_resolve_sysroot_result - func_dirname "$deplib" "" "." - dir=$func_dirname_result - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; - *) - absdir=`cd "$dir" && pwd` - if test -z "$absdir"; then - func_warning "cannot determine absolute directory name of \`$dir'" - absdir="$dir" - fi - ;; - esac - if $GREP "^installed=no" $deplib > /dev/null; then - case $host in - *-*-darwin*) - depdepl= - eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` - if test -n "$deplibrary_names" ; then - for tmp in $deplibrary_names ; do - depdepl=$tmp - done - if test -f "$absdir/$objdir/$depdepl" ; then - depdepl="$absdir/$objdir/$depdepl" - darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` - if test -z "$darwin_install_name"; then - darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` - fi - func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" - func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" - path= - fi - fi - ;; - *) - path="-L$absdir/$objdir" - ;; - esac - else - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` - test -z "$libdir" && \ - func_fatal_error "\`$deplib' is not a valid libtool archive" - test "$absdir" != "$libdir" && \ - func_warning "\`$deplib' seems to be moved" - - path="-L$absdir" - fi - ;; - esac - case " $deplibs " in - *" $path "*) ;; - *) deplibs="$path $deplibs" ;; - esac - done - fi # link_all_deplibs != no - fi # linkmode = lib - done # for deplib in $libs - if test "$pass" = link; then - if test "$linkmode" = "prog"; then - compile_deplibs="$new_inherited_linker_flags $compile_deplibs" - finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" - else - compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - fi - fi - dependency_libs="$newdependency_libs" - if test "$pass" = dlpreopen; then - # Link the dlpreopened libraries before other libraries - for deplib in $save_deplibs; do - deplibs="$deplib $deplibs" - done - fi - if test "$pass" != dlopen; then - if test "$pass" != conv; then - # Make sure lib_search_path contains only unique directories. - lib_search_path= - for dir in $newlib_search_path; do - case "$lib_search_path " in - *" $dir "*) ;; - *) func_append lib_search_path " $dir" ;; - esac - done - newlib_search_path= - fi - - if test "$linkmode,$pass" != "prog,link"; then - vars="deplibs" - else - vars="compile_deplibs finalize_deplibs" - fi - for var in $vars dependency_libs; do - # Add libraries to $var in reverse order - eval tmp_libs=\"\$$var\" - new_libs= - for deplib in $tmp_libs; do - # FIXME: Pedantically, this is the right thing to do, so - # that some nasty dependency loop isn't accidentally - # broken: - #new_libs="$deplib $new_libs" - # Pragmatically, this seems to cause very few problems in - # practice: - case $deplib in - -L*) new_libs="$deplib $new_libs" ;; - -R*) ;; - *) - # And here is the reason: when a library appears more - # than once as an explicit dependence of a library, or - # is implicitly linked in more than once by the - # compiler, it is considered special, and multiple - # occurrences thereof are not removed. Compare this - # with having the same library being listed as a - # dependency of multiple other libraries: in this case, - # we know (pedantically, we assume) the library does not - # need to be listed more than once, so we keep only the - # last copy. This is not always right, but it is rare - # enough that we require users that really mean to play - # such unportable linking tricks to link the library - # using -Wl,-lname, so that libtool does not consider it - # for duplicate removal. - case " $specialdeplibs " in - *" $deplib "*) new_libs="$deplib $new_libs" ;; - *) - case " $new_libs " in - *" $deplib "*) ;; - *) new_libs="$deplib $new_libs" ;; - esac - ;; - esac - ;; - esac - done - tmp_libs= - for deplib in $new_libs; do - case $deplib in - -L*) - case " $tmp_libs " in - *" $deplib "*) ;; - *) func_append tmp_libs " $deplib" ;; - esac - ;; - *) func_append tmp_libs " $deplib" ;; - esac - done - eval $var=\"$tmp_libs\" - done # for var - fi - # Last step: remove runtime libs from dependency_libs - # (they stay in deplibs) - tmp_libs= - for i in $dependency_libs ; do - case " $predeps $postdeps $compiler_lib_search_path " in - *" $i "*) - i="" - ;; - esac - if test -n "$i" ; then - func_append tmp_libs " $i" - fi - done - dependency_libs=$tmp_libs - done # for pass - if test "$linkmode" = prog; then - dlfiles="$newdlfiles" - fi - if test "$linkmode" = prog || test "$linkmode" = lib; then - dlprefiles="$newdlprefiles" - fi - - case $linkmode in - oldlib) - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - func_warning "\`-dlopen' is ignored for archives" - fi - - case " $deplibs" in - *\ -l* | *\ -L*) - func_warning "\`-l' and \`-L' are ignored for archives" ;; - esac - - test -n "$rpath" && \ - func_warning "\`-rpath' is ignored for archives" - - test -n "$xrpath" && \ - func_warning "\`-R' is ignored for archives" - - test -n "$vinfo" && \ - func_warning "\`-version-info/-version-number' is ignored for archives" - - test -n "$release" && \ - func_warning "\`-release' is ignored for archives" - - test -n "$export_symbols$export_symbols_regex" && \ - func_warning "\`-export-symbols' is ignored for archives" - - # Now set the variables for building old libraries. - build_libtool_libs=no - oldlibs="$output" - func_append objs "$old_deplibs" - ;; - - lib) - # Make sure we only generate libraries of the form `libNAME.la'. - case $outputname in - lib*) - func_stripname 'lib' '.la' "$outputname" - name=$func_stripname_result - eval shared_ext=\"$shrext_cmds\" - eval libname=\"$libname_spec\" - ;; - *) - test "$module" = no && \ - func_fatal_help "libtool library \`$output' must begin with \`lib'" - - if test "$need_lib_prefix" != no; then - # Add the "lib" prefix for modules if required - func_stripname '' '.la' "$outputname" - name=$func_stripname_result - eval shared_ext=\"$shrext_cmds\" - eval libname=\"$libname_spec\" - else - func_stripname '' '.la' "$outputname" - libname=$func_stripname_result - fi - ;; - esac - - if test -n "$objs"; then - if test "$deplibs_check_method" != pass_all; then - func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" - else - echo - $ECHO "*** Warning: Linking the shared library $output against the non-libtool" - $ECHO "*** objects $objs is not portable!" - func_append libobjs " $objs" - fi - fi - - test "$dlself" != no && \ - func_warning "\`-dlopen self' is ignored for libtool libraries" - - set dummy $rpath - shift - test "$#" -gt 1 && \ - func_warning "ignoring multiple \`-rpath's for a libtool library" - - install_libdir="$1" - - oldlibs= - if test -z "$rpath"; then - if test "$build_libtool_libs" = yes; then - # Building a libtool convenience library. - # Some compilers have problems with a `.al' extension so - # convenience libraries should have the same extension an - # archive normally would. - oldlibs="$output_objdir/$libname.$libext $oldlibs" - build_libtool_libs=convenience - build_old_libs=yes - fi - - test -n "$vinfo" && \ - func_warning "\`-version-info/-version-number' is ignored for convenience libraries" - - test -n "$release" && \ - func_warning "\`-release' is ignored for convenience libraries" - else - - # Parse the version information argument. - save_ifs="$IFS"; IFS=':' - set dummy $vinfo 0 0 0 - shift - IFS="$save_ifs" - - test -n "$7" && \ - func_fatal_help "too many parameters to \`-version-info'" - - # convert absolute version numbers to libtool ages - # this retains compatibility with .la files and attempts - # to make the code below a bit more comprehensible - - case $vinfo_number in - yes) - number_major="$1" - number_minor="$2" - number_revision="$3" - # - # There are really only two kinds -- those that - # use the current revision as the major version - # and those that subtract age and use age as - # a minor version. But, then there is irix - # which has an extra 1 added just for fun - # - case $version_type in - # correct linux to gnu/linux during the next big refactor - darwin|linux|osf|windows|none) - func_arith $number_major + $number_minor - current=$func_arith_result - age="$number_minor" - revision="$number_revision" - ;; - freebsd-aout|freebsd-elf|qnx|sunos) - current="$number_major" - revision="$number_minor" - age="0" - ;; - irix|nonstopux) - func_arith $number_major + $number_minor - current=$func_arith_result - age="$number_minor" - revision="$number_minor" - lt_irix_increment=no - ;; - esac - ;; - no) - current="$1" - revision="$2" - age="$3" - ;; - esac - - # Check that each of the things are valid numbers. - case $current in - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) - func_error "CURRENT \`$current' must be a nonnegative integer" - func_fatal_error "\`$vinfo' is not valid version information" - ;; - esac - - case $revision in - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) - func_error "REVISION \`$revision' must be a nonnegative integer" - func_fatal_error "\`$vinfo' is not valid version information" - ;; - esac - - case $age in - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) - func_error "AGE \`$age' must be a nonnegative integer" - func_fatal_error "\`$vinfo' is not valid version information" - ;; - esac - - if test "$age" -gt "$current"; then - func_error "AGE \`$age' is greater than the current interface number \`$current'" - func_fatal_error "\`$vinfo' is not valid version information" - fi - - # Calculate the version variables. - major= - versuffix= - verstring= - case $version_type in - none) ;; - - darwin) - # Like Linux, but with the current version available in - # verstring for coding it into the library header - func_arith $current - $age - major=.$func_arith_result - versuffix="$major.$age.$revision" - # Darwin ld doesn't like 0 for these options... - func_arith $current + 1 - minor_current=$func_arith_result - xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" - verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" - ;; - - freebsd-aout) - major=".$current" - versuffix=".$current.$revision"; - ;; - - freebsd-elf) - major=".$current" - versuffix=".$current" - ;; - - irix | nonstopux) - if test "X$lt_irix_increment" = "Xno"; then - func_arith $current - $age - else - func_arith $current - $age + 1 - fi - major=$func_arith_result - - case $version_type in - nonstopux) verstring_prefix=nonstopux ;; - *) verstring_prefix=sgi ;; - esac - verstring="$verstring_prefix$major.$revision" - - # Add in all the interfaces that we are compatible with. - loop=$revision - while test "$loop" -ne 0; do - func_arith $revision - $loop - iface=$func_arith_result - func_arith $loop - 1 - loop=$func_arith_result - verstring="$verstring_prefix$major.$iface:$verstring" - done - - # Before this point, $major must not contain `.'. - major=.$major - versuffix="$major.$revision" - ;; - - linux) # correct to gnu/linux during the next big refactor - func_arith $current - $age - major=.$func_arith_result - versuffix="$major.$age.$revision" - ;; - - osf) - func_arith $current - $age - major=.$func_arith_result - versuffix=".$current.$age.$revision" - verstring="$current.$age.$revision" - - # Add in all the interfaces that we are compatible with. - loop=$age - while test "$loop" -ne 0; do - func_arith $current - $loop - iface=$func_arith_result - func_arith $loop - 1 - loop=$func_arith_result - verstring="$verstring:${iface}.0" - done - - # Make executables depend on our current version. - func_append verstring ":${current}.0" - ;; - - qnx) - major=".$current" - versuffix=".$current" - ;; - - sunos) - major=".$current" - versuffix=".$current.$revision" - ;; - - windows) - # Use '-' rather than '.', since we only want one - # extension on DOS 8.3 filesystems. - func_arith $current - $age - major=$func_arith_result - versuffix="-$major" - ;; - - *) - func_fatal_configuration "unknown library version type \`$version_type'" - ;; - esac - - # Clear the version info if we defaulted, and they specified a release. - if test -z "$vinfo" && test -n "$release"; then - major= - case $version_type in - darwin) - # we can't check for "0.0" in archive_cmds due to quoting - # problems, so we reset it completely - verstring= - ;; - *) - verstring="0.0" - ;; - esac - if test "$need_version" = no; then - versuffix= - else - versuffix=".0.0" - fi - fi - - # Remove version info from name if versioning should be avoided - if test "$avoid_version" = yes && test "$need_version" = no; then - major= - versuffix= - verstring="" - fi - - # Check to see if the archive will have undefined symbols. - if test "$allow_undefined" = yes; then - if test "$allow_undefined_flag" = unsupported; then - func_warning "undefined symbols not allowed in $host shared libraries" - build_libtool_libs=no - build_old_libs=yes - fi - else - # Don't allow undefined symbols. - allow_undefined_flag="$no_undefined_flag" - fi - - fi - - func_generate_dlsyms "$libname" "$libname" "yes" - func_append libobjs " $symfileobj" - test "X$libobjs" = "X " && libobjs= - - if test "$opt_mode" != relink; then - # Remove our outputs, but don't remove object files since they - # may have been created when compiling PIC objects. - removelist= - tempremovelist=`$ECHO "$output_objdir/*"` - for p in $tempremovelist; do - case $p in - *.$objext | *.gcno) - ;; - $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) - if test "X$precious_files_regex" != "X"; then - if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 - then - continue - fi - fi - func_append removelist " $p" - ;; - *) ;; - esac - done - test -n "$removelist" && \ - func_show_eval "${RM}r \$removelist" - fi - - # Now set the variables for building old libraries. - if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then - func_append oldlibs " $output_objdir/$libname.$libext" - - # Transform .lo files to .o files. - oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` - fi - - # Eliminate all temporary directories. - #for path in $notinst_path; do - # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` - # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` - # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` - #done - - if test -n "$xrpath"; then - # If the user specified any rpath flags, then add them. - temp_xrpath= - for libdir in $xrpath; do - func_replace_sysroot "$libdir" - func_append temp_xrpath " -R$func_replace_sysroot_result" - case "$finalize_rpath " in - *" $libdir "*) ;; - *) func_append finalize_rpath " $libdir" ;; - esac - done - if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then - dependency_libs="$temp_xrpath $dependency_libs" - fi - fi - - # Make sure dlfiles contains only unique files that won't be dlpreopened - old_dlfiles="$dlfiles" - dlfiles= - for lib in $old_dlfiles; do - case " $dlprefiles $dlfiles " in - *" $lib "*) ;; - *) func_append dlfiles " $lib" ;; - esac - done - - # Make sure dlprefiles contains only unique files - old_dlprefiles="$dlprefiles" - dlprefiles= - for lib in $old_dlprefiles; do - case "$dlprefiles " in - *" $lib "*) ;; - *) func_append dlprefiles " $lib" ;; - esac - done - - if test "$build_libtool_libs" = yes; then - if test -n "$rpath"; then - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) - # these systems don't actually have a c library (as such)! - ;; - *-*-rhapsody* | *-*-darwin1.[012]) - # Rhapsody C library is in the System framework - func_append deplibs " System.ltframework" - ;; - *-*-netbsd*) - # Don't link with libc until the a.out ld.so is fixed. - ;; - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) - # Do not include libc due to us having libc/libc_r. - ;; - *-*-sco3.2v5* | *-*-sco5v6*) - # Causes problems with __ctype - ;; - *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) - # Compiler inserts libc in the correct place for threads to work - ;; - *) - # Add libc to deplibs on all other systems if necessary. - if test "$build_libtool_need_lc" = "yes"; then - func_append deplibs " -lc" - fi - ;; - esac - fi - - # Transform deplibs into only deplibs that can be linked in shared. - name_save=$name - libname_save=$libname - release_save=$release - versuffix_save=$versuffix - major_save=$major - # I'm not sure if I'm treating the release correctly. I think - # release should show up in the -l (ie -lgmp5) so we don't want to - # add it in twice. Is that correct? - release="" - versuffix="" - major="" - newdeplibs= - droppeddeps=no - case $deplibs_check_method in - pass_all) - # Don't check for shared/static. Everything works. - # This might be a little naive. We might want to check - # whether the library exists or not. But this is on - # osf3 & osf4 and I'm not really sure... Just - # implementing what was already the behavior. - newdeplibs=$deplibs - ;; - test_compile) - # This code stresses the "libraries are programs" paradigm to its - # limits. Maybe even breaks it. We compile a program, linking it - # against the deplibs as a proxy for the library. Then we can check - # whether they linked in statically or dynamically with ldd. - $opt_dry_run || $RM conftest.c - cat > conftest.c </dev/null` - $nocaseglob - else - potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` - fi - for potent_lib in $potential_libs; do - # Follow soft links. - if ls -lLd "$potent_lib" 2>/dev/null | - $GREP " -> " >/dev/null; then - continue - fi - # The statement above tries to avoid entering an - # endless loop below, in case of cyclic links. - # We might still enter an endless loop, since a link - # loop can be closed while we follow links, - # but so what? - potlib="$potent_lib" - while test -h "$potlib" 2>/dev/null; do - potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` - case $potliblink in - [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; - *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; - esac - done - if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | - $SED -e 10q | - $EGREP "$file_magic_regex" > /dev/null; then - func_append newdeplibs " $a_deplib" - a_deplib="" - break 2 - fi - done - done - fi - if test -n "$a_deplib" ; then - droppeddeps=yes - echo - $ECHO "*** Warning: linker path does not have real file for library $a_deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then - $ECHO "*** with $libname but no candidates were found. (...for file magic test)" - else - $ECHO "*** with $libname and none of the candidates passed a file format test" - $ECHO "*** using a file magic. Last file checked: $potlib" - fi - fi - ;; - *) - # Add a -L argument. - func_append newdeplibs " $a_deplib" - ;; - esac - done # Gone through all deplibs. - ;; - match_pattern*) - set dummy $deplibs_check_method; shift - match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` - for a_deplib in $deplibs; do - case $a_deplib in - -l*) - func_stripname -l '' "$a_deplib" - name=$func_stripname_result - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - case " $predeps $postdeps " in - *" $a_deplib "*) - func_append newdeplibs " $a_deplib" - a_deplib="" - ;; - esac - fi - if test -n "$a_deplib" ; then - libname=`eval "\\$ECHO \"$libname_spec\""` - for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do - potential_libs=`ls $i/$libname[.-]* 2>/dev/null` - for potent_lib in $potential_libs; do - potlib="$potent_lib" # see symlink-check above in file_magic test - if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ - $EGREP "$match_pattern_regex" > /dev/null; then - func_append newdeplibs " $a_deplib" - a_deplib="" - break 2 - fi - done - done - fi - if test -n "$a_deplib" ; then - droppeddeps=yes - echo - $ECHO "*** Warning: linker path does not have real file for library $a_deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then - $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" - else - $ECHO "*** with $libname and none of the candidates passed a file format test" - $ECHO "*** using a regex pattern. Last file checked: $potlib" - fi - fi - ;; - *) - # Add a -L argument. - func_append newdeplibs " $a_deplib" - ;; - esac - done # Gone through all deplibs. - ;; - none | unknown | *) - newdeplibs="" - tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - for i in $predeps $postdeps ; do - # can't use Xsed below, because $i might contain '/' - tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` - done - fi - case $tmp_deplibs in - *[!\ \ ]*) - echo - if test "X$deplibs_check_method" = "Xnone"; then - echo "*** Warning: inter-library dependencies are not supported in this platform." - else - echo "*** Warning: inter-library dependencies are not known to be supported." - fi - echo "*** All declared inter-library dependencies are being dropped." - droppeddeps=yes - ;; - esac - ;; - esac - versuffix=$versuffix_save - major=$major_save - release=$release_save - libname=$libname_save - name=$name_save - - case $host in - *-*-rhapsody* | *-*-darwin1.[012]) - # On Rhapsody replace the C library with the System framework - newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` - ;; - esac - - if test "$droppeddeps" = yes; then - if test "$module" = yes; then - echo - echo "*** Warning: libtool could not satisfy all declared inter-library" - $ECHO "*** dependencies of module $libname. Therefore, libtool will create" - echo "*** a static module, that should work as long as the dlopening" - echo "*** application is linked with the -dlopen flag." - if test -z "$global_symbol_pipe"; then - echo - echo "*** However, this would only work if libtool was able to extract symbol" - echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - echo "*** not find such a program. So, this module is probably useless." - echo "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - else - echo "*** The inter-library dependencies that have been dropped here will be" - echo "*** automatically added whenever a program is linked with this library" - echo "*** or is declared to -dlopen it." - - if test "$allow_undefined" = no; then - echo - echo "*** Since this library must not contain undefined symbols," - echo "*** because either the platform does not support them or" - echo "*** it was explicitly requested with -no-undefined," - echo "*** libtool will only create a static version of it." - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - fi - fi - fi - # Done checking deplibs! - deplibs=$newdeplibs - fi - # Time to change all our "foo.ltframework" stuff back to "-framework foo" - case $host in - *-*-darwin*) - newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - ;; - esac - - # move library search paths that coincide with paths to not yet - # installed libraries to the beginning of the library search list - new_libs= - for path in $notinst_path; do - case " $new_libs " in - *" -L$path/$objdir "*) ;; - *) - case " $deplibs " in - *" -L$path/$objdir "*) - func_append new_libs " -L$path/$objdir" ;; - esac - ;; - esac - done - for deplib in $deplibs; do - case $deplib in - -L*) - case " $new_libs " in - *" $deplib "*) ;; - *) func_append new_libs " $deplib" ;; - esac - ;; - *) func_append new_libs " $deplib" ;; - esac - done - deplibs="$new_libs" - - # All the library-specific variables (install_libdir is set above). - library_names= - old_library= - dlname= - - # Test again, we may have decided not to build it any more - if test "$build_libtool_libs" = yes; then - # Remove ${wl} instances when linking with ld. - # FIXME: should test the right _cmds variable. - case $archive_cmds in - *\$LD\ *) wl= ;; - esac - if test "$hardcode_into_libs" = yes; then - # Hardcode the library paths - hardcode_libdirs= - dep_rpath= - rpath="$finalize_rpath" - test "$opt_mode" != relink && rpath="$compile_rpath$rpath" - for libdir in $rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - func_replace_sysroot "$libdir" - libdir=$func_replace_sysroot_result - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - func_append dep_rpath " $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) func_append perm_rpath " $libdir" ;; - esac - fi - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" - fi - if test -n "$runpath_var" && test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - func_append rpath "$dir:" - done - eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" - fi - test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" - fi - - shlibpath="$finalize_shlibpath" - test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" - if test -n "$shlibpath"; then - eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" - fi - - # Get the real and link names of the library. - eval shared_ext=\"$shrext_cmds\" - eval library_names=\"$library_names_spec\" - set dummy $library_names - shift - realname="$1" - shift - - if test -n "$soname_spec"; then - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - if test -z "$dlname"; then - dlname=$soname - fi - - lib="$output_objdir/$realname" - linknames= - for link - do - func_append linknames " $link" - done - - # Use standard objects if they are pic - test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` - test "X$libobjs" = "X " && libobjs= - - delfiles= - if test -n "$export_symbols" && test -n "$include_expsyms"; then - $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" - export_symbols="$output_objdir/$libname.uexp" - func_append delfiles " $export_symbols" - fi - - orig_export_symbols= - case $host_os in - cygwin* | mingw* | cegcc*) - if test -n "$export_symbols" && test -z "$export_symbols_regex"; then - # exporting using user supplied symfile - if test "x`$SED 1q $export_symbols`" != xEXPORTS; then - # and it's NOT already a .def file. Must figure out - # which of the given symbols are data symbols and tag - # them as such. So, trigger use of export_symbols_cmds. - # export_symbols gets reassigned inside the "prepare - # the list of exported symbols" if statement, so the - # include_expsyms logic still works. - orig_export_symbols="$export_symbols" - export_symbols= - always_export_symbols=yes - fi - fi - ;; - esac - - # Prepare the list of exported symbols - if test -z "$export_symbols"; then - if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then - func_verbose "generating symbol list for \`$libname.la'" - export_symbols="$output_objdir/$libname.exp" - $opt_dry_run || $RM $export_symbols - cmds=$export_symbols_cmds - save_ifs="$IFS"; IFS='~' - for cmd1 in $cmds; do - IFS="$save_ifs" - # Take the normal branch if the nm_file_list_spec branch - # doesn't work or if tool conversion is not needed. - case $nm_file_list_spec~$to_tool_file_cmd in - *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) - try_normal_branch=yes - eval cmd=\"$cmd1\" - func_len " $cmd" - len=$func_len_result - ;; - *) - try_normal_branch=no - ;; - esac - if test "$try_normal_branch" = yes \ - && { test "$len" -lt "$max_cmd_len" \ - || test "$max_cmd_len" -le -1; } - then - func_show_eval "$cmd" 'exit $?' - skipped_export=false - elif test -n "$nm_file_list_spec"; then - func_basename "$output" - output_la=$func_basename_result - save_libobjs=$libobjs - save_output=$output - output=${output_objdir}/${output_la}.nm - func_to_tool_file "$output" - libobjs=$nm_file_list_spec$func_to_tool_file_result - func_append delfiles " $output" - func_verbose "creating $NM input file list: $output" - for obj in $save_libobjs; do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" - done > "$output" - eval cmd=\"$cmd1\" - func_show_eval "$cmd" 'exit $?' - output=$save_output - libobjs=$save_libobjs - skipped_export=false - else - # The command line is too long to execute in one step. - func_verbose "using reloadable object file for export list..." - skipped_export=: - # Break out early, otherwise skipped_export may be - # set to false by a later but shorter cmd. - break - fi - done - IFS="$save_ifs" - if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then - func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' - func_show_eval '$MV "${export_symbols}T" "$export_symbols"' - fi - fi - fi - - if test -n "$export_symbols" && test -n "$include_expsyms"; then - tmp_export_symbols="$export_symbols" - test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" - $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' - fi - - if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then - # The given exports_symbols file has to be filtered, so filter it. - func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" - # FIXME: $output_objdir/$libname.filter potentially contains lots of - # 's' commands which not all seds can handle. GNU sed should be fine - # though. Also, the filter scales superlinearly with the number of - # global variables. join(1) would be nice here, but unfortunately - # isn't a blessed tool. - $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter - func_append delfiles " $export_symbols $output_objdir/$libname.filter" - export_symbols=$output_objdir/$libname.def - $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols - fi - - tmp_deplibs= - for test_deplib in $deplibs; do - case " $convenience " in - *" $test_deplib "*) ;; - *) - func_append tmp_deplibs " $test_deplib" - ;; - esac - done - deplibs="$tmp_deplibs" - - if test -n "$convenience"; then - if test -n "$whole_archive_flag_spec" && - test "$compiler_needs_object" = yes && - test -z "$libobjs"; then - # extract the archives, so we have objects to list. - # TODO: could optimize this to just extract one archive. - whole_archive_flag_spec= - fi - if test -n "$whole_archive_flag_spec"; then - save_libobjs=$libobjs - eval libobjs=\"\$libobjs $whole_archive_flag_spec\" - test "X$libobjs" = "X " && libobjs= - else - gentop="$output_objdir/${outputname}x" - func_append generated " $gentop" - - func_extract_archives $gentop $convenience - func_append libobjs " $func_extract_archives_result" - test "X$libobjs" = "X " && libobjs= - fi - fi - - if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then - eval flag=\"$thread_safe_flag_spec\" - func_append linker_flags " $flag" - fi - - # Make a backup of the uninstalled library when relinking - if test "$opt_mode" = relink; then - $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? - fi - - # Do each of the archive commands. - if test "$module" = yes && test -n "$module_cmds" ; then - if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then - eval test_cmds=\"$module_expsym_cmds\" - cmds=$module_expsym_cmds - else - eval test_cmds=\"$module_cmds\" - cmds=$module_cmds - fi - else - if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then - eval test_cmds=\"$archive_expsym_cmds\" - cmds=$archive_expsym_cmds - else - eval test_cmds=\"$archive_cmds\" - cmds=$archive_cmds - fi - fi - - if test "X$skipped_export" != "X:" && - func_len " $test_cmds" && - len=$func_len_result && - test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then - : - else - # The command line is too long to link in one step, link piecewise - # or, if using GNU ld and skipped_export is not :, use a linker - # script. - - # Save the value of $output and $libobjs because we want to - # use them later. If we have whole_archive_flag_spec, we - # want to use save_libobjs as it was before - # whole_archive_flag_spec was expanded, because we can't - # assume the linker understands whole_archive_flag_spec. - # This may have to be revisited, in case too many - # convenience libraries get linked in and end up exceeding - # the spec. - if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then - save_libobjs=$libobjs - fi - save_output=$output - func_basename "$output" - output_la=$func_basename_result - - # Clear the reloadable object creation command queue and - # initialize k to one. - test_cmds= - concat_cmds= - objlist= - last_robj= - k=1 - - if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then - output=${output_objdir}/${output_la}.lnkscript - func_verbose "creating GNU ld script: $output" - echo 'INPUT (' > $output - for obj in $save_libobjs - do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" >> $output - done - echo ')' >> $output - func_append delfiles " $output" - func_to_tool_file "$output" - output=$func_to_tool_file_result - elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then - output=${output_objdir}/${output_la}.lnk - func_verbose "creating linker input file list: $output" - : > $output - set x $save_libobjs - shift - firstobj= - if test "$compiler_needs_object" = yes; then - firstobj="$1 " - shift - fi - for obj - do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" >> $output - done - func_append delfiles " $output" - func_to_tool_file "$output" - output=$firstobj\"$file_list_spec$func_to_tool_file_result\" - else - if test -n "$save_libobjs"; then - func_verbose "creating reloadable object files..." - output=$output_objdir/$output_la-${k}.$objext - eval test_cmds=\"$reload_cmds\" - func_len " $test_cmds" - len0=$func_len_result - len=$len0 - - # Loop over the list of objects to be linked. - for obj in $save_libobjs - do - func_len " $obj" - func_arith $len + $func_len_result - len=$func_arith_result - if test "X$objlist" = X || - test "$len" -lt "$max_cmd_len"; then - func_append objlist " $obj" - else - # The command $test_cmds is almost too long, add a - # command to the queue. - if test "$k" -eq 1 ; then - # The first file doesn't have a previous command to add. - reload_objs=$objlist - eval concat_cmds=\"$reload_cmds\" - else - # All subsequent reloadable object files will link in - # the last one created. - reload_objs="$objlist $last_robj" - eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" - fi - last_robj=$output_objdir/$output_la-${k}.$objext - func_arith $k + 1 - k=$func_arith_result - output=$output_objdir/$output_la-${k}.$objext - objlist=" $obj" - func_len " $last_robj" - func_arith $len0 + $func_len_result - len=$func_arith_result - fi - done - # Handle the remaining objects by creating one last - # reloadable object file. All subsequent reloadable object - # files will link in the last one created. - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - reload_objs="$objlist $last_robj" - eval concat_cmds=\"\${concat_cmds}$reload_cmds\" - if test -n "$last_robj"; then - eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" - fi - func_append delfiles " $output" - - else - output= - fi - - if ${skipped_export-false}; then - func_verbose "generating symbol list for \`$libname.la'" - export_symbols="$output_objdir/$libname.exp" - $opt_dry_run || $RM $export_symbols - libobjs=$output - # Append the command to create the export file. - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" - if test -n "$last_robj"; then - eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" - fi - fi - - test -n "$save_libobjs" && - func_verbose "creating a temporary reloadable object file: $output" - - # Loop through the commands generated above and execute them. - save_ifs="$IFS"; IFS='~' - for cmd in $concat_cmds; do - IFS="$save_ifs" - $opt_silent || { - func_quote_for_expand "$cmd" - eval "func_echo $func_quote_for_expand_result" - } - $opt_dry_run || eval "$cmd" || { - lt_exit=$? - - # Restore the uninstalled library and exit - if test "$opt_mode" = relink; then - ( cd "$output_objdir" && \ - $RM "${realname}T" && \ - $MV "${realname}U" "$realname" ) - fi - - exit $lt_exit - } - done - IFS="$save_ifs" - - if test -n "$export_symbols_regex" && ${skipped_export-false}; then - func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' - func_show_eval '$MV "${export_symbols}T" "$export_symbols"' - fi - fi - - if ${skipped_export-false}; then - if test -n "$export_symbols" && test -n "$include_expsyms"; then - tmp_export_symbols="$export_symbols" - test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" - $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' - fi - - if test -n "$orig_export_symbols"; then - # The given exports_symbols file has to be filtered, so filter it. - func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" - # FIXME: $output_objdir/$libname.filter potentially contains lots of - # 's' commands which not all seds can handle. GNU sed should be fine - # though. Also, the filter scales superlinearly with the number of - # global variables. join(1) would be nice here, but unfortunately - # isn't a blessed tool. - $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter - func_append delfiles " $export_symbols $output_objdir/$libname.filter" - export_symbols=$output_objdir/$libname.def - $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols - fi - fi - - libobjs=$output - # Restore the value of output. - output=$save_output - - if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then - eval libobjs=\"\$libobjs $whole_archive_flag_spec\" - test "X$libobjs" = "X " && libobjs= - fi - # Expand the library linking commands again to reset the - # value of $libobjs for piecewise linking. - - # Do each of the archive commands. - if test "$module" = yes && test -n "$module_cmds" ; then - if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then - cmds=$module_expsym_cmds - else - cmds=$module_cmds - fi - else - if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then - cmds=$archive_expsym_cmds - else - cmds=$archive_cmds - fi - fi - fi - - if test -n "$delfiles"; then - # Append the command to remove temporary files to $cmds. - eval cmds=\"\$cmds~\$RM $delfiles\" - fi - - # Add any objects from preloaded convenience libraries - if test -n "$dlprefiles"; then - gentop="$output_objdir/${outputname}x" - func_append generated " $gentop" - - func_extract_archives $gentop $dlprefiles - func_append libobjs " $func_extract_archives_result" - test "X$libobjs" = "X " && libobjs= - fi - - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $opt_silent || { - func_quote_for_expand "$cmd" - eval "func_echo $func_quote_for_expand_result" - } - $opt_dry_run || eval "$cmd" || { - lt_exit=$? - - # Restore the uninstalled library and exit - if test "$opt_mode" = relink; then - ( cd "$output_objdir" && \ - $RM "${realname}T" && \ - $MV "${realname}U" "$realname" ) - fi - - exit $lt_exit - } - done - IFS="$save_ifs" - - # Restore the uninstalled library and exit - if test "$opt_mode" = relink; then - $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? - - if test -n "$convenience"; then - if test -z "$whole_archive_flag_spec"; then - func_show_eval '${RM}r "$gentop"' - fi - fi - - exit $EXIT_SUCCESS - fi - - # Create links to the real library. - for linkname in $linknames; do - if test "$realname" != "$linkname"; then - func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' - fi - done - - # If -module or -export-dynamic was specified, set the dlname. - if test "$module" = yes || test "$export_dynamic" = yes; then - # On all known operating systems, these are identical. - dlname="$soname" - fi - fi - ;; - - obj) - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - func_warning "\`-dlopen' is ignored for objects" - fi - - case " $deplibs" in - *\ -l* | *\ -L*) - func_warning "\`-l' and \`-L' are ignored for objects" ;; - esac - - test -n "$rpath" && \ - func_warning "\`-rpath' is ignored for objects" - - test -n "$xrpath" && \ - func_warning "\`-R' is ignored for objects" - - test -n "$vinfo" && \ - func_warning "\`-version-info' is ignored for objects" - - test -n "$release" && \ - func_warning "\`-release' is ignored for objects" - - case $output in - *.lo) - test -n "$objs$old_deplibs" && \ - func_fatal_error "cannot build library object \`$output' from non-libtool objects" - - libobj=$output - func_lo2o "$libobj" - obj=$func_lo2o_result - ;; - *) - libobj= - obj="$output" - ;; - esac - - # Delete the old objects. - $opt_dry_run || $RM $obj $libobj - - # Objects from convenience libraries. This assumes - # single-version convenience libraries. Whenever we create - # different ones for PIC/non-PIC, this we'll have to duplicate - # the extraction. - reload_conv_objs= - gentop= - # reload_cmds runs $LD directly, so let us get rid of - # -Wl from whole_archive_flag_spec and hope we can get by with - # turning comma into space.. - wl= - - if test -n "$convenience"; then - if test -n "$whole_archive_flag_spec"; then - eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" - reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` - else - gentop="$output_objdir/${obj}x" - func_append generated " $gentop" - - func_extract_archives $gentop $convenience - reload_conv_objs="$reload_objs $func_extract_archives_result" - fi - fi - - # If we're not building shared, we need to use non_pic_objs - test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" - - # Create the old-style object. - reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test - - output="$obj" - func_execute_cmds "$reload_cmds" 'exit $?' - - # Exit if we aren't doing a library object file. - if test -z "$libobj"; then - if test -n "$gentop"; then - func_show_eval '${RM}r "$gentop"' - fi - - exit $EXIT_SUCCESS - fi - - if test "$build_libtool_libs" != yes; then - if test -n "$gentop"; then - func_show_eval '${RM}r "$gentop"' - fi - - # Create an invalid libtool object if no PIC, so that we don't - # accidentally link it into a program. - # $show "echo timestamp > $libobj" - # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? - exit $EXIT_SUCCESS - fi - - if test -n "$pic_flag" || test "$pic_mode" != default; then - # Only do commands if we really have different PIC objects. - reload_objs="$libobjs $reload_conv_objs" - output="$libobj" - func_execute_cmds "$reload_cmds" 'exit $?' - fi - - if test -n "$gentop"; then - func_show_eval '${RM}r "$gentop"' - fi - - exit $EXIT_SUCCESS - ;; - - prog) - case $host in - *cygwin*) func_stripname '' '.exe' "$output" - output=$func_stripname_result.exe;; - esac - test -n "$vinfo" && \ - func_warning "\`-version-info' is ignored for programs" - - test -n "$release" && \ - func_warning "\`-release' is ignored for programs" - - test "$preload" = yes \ - && test "$dlopen_support" = unknown \ - && test "$dlopen_self" = unknown \ - && test "$dlopen_self_static" = unknown && \ - func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." - - case $host in - *-*-rhapsody* | *-*-darwin1.[012]) - # On Rhapsody replace the C library is the System framework - compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` - finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` - ;; - esac - - case $host in - *-*-darwin*) - # Don't allow lazy linking, it breaks C++ global constructors - # But is supposedly fixed on 10.4 or later (yay!). - if test "$tagname" = CXX ; then - case ${MACOSX_DEPLOYMENT_TARGET-10.0} in - 10.[0123]) - func_append compile_command " ${wl}-bind_at_load" - func_append finalize_command " ${wl}-bind_at_load" - ;; - esac - fi - # Time to change all our "foo.ltframework" stuff back to "-framework foo" - compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - ;; - esac - - - # move library search paths that coincide with paths to not yet - # installed libraries to the beginning of the library search list - new_libs= - for path in $notinst_path; do - case " $new_libs " in - *" -L$path/$objdir "*) ;; - *) - case " $compile_deplibs " in - *" -L$path/$objdir "*) - func_append new_libs " -L$path/$objdir" ;; - esac - ;; - esac - done - for deplib in $compile_deplibs; do - case $deplib in - -L*) - case " $new_libs " in - *" $deplib "*) ;; - *) func_append new_libs " $deplib" ;; - esac - ;; - *) func_append new_libs " $deplib" ;; - esac - done - compile_deplibs="$new_libs" - - - func_append compile_command " $compile_deplibs" - func_append finalize_command " $finalize_deplibs" - - if test -n "$rpath$xrpath"; then - # If the user specified any rpath flags, then add them. - for libdir in $rpath $xrpath; do - # This is the magic to use -rpath. - case "$finalize_rpath " in - *" $libdir "*) ;; - *) func_append finalize_rpath " $libdir" ;; - esac - done - fi - - # Now hardcode the library paths - rpath= - hardcode_libdirs= - for libdir in $compile_rpath $finalize_rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - func_append rpath " $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) func_append perm_rpath " $libdir" ;; - esac - fi - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) - testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` - case :$dllsearchpath: in - *":$libdir:"*) ;; - ::) dllsearchpath=$libdir;; - *) func_append dllsearchpath ":$libdir";; - esac - case :$dllsearchpath: in - *":$testbindir:"*) ;; - ::) dllsearchpath=$testbindir;; - *) func_append dllsearchpath ":$testbindir";; - esac - ;; - esac - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval rpath=\" $hardcode_libdir_flag_spec\" - fi - compile_rpath="$rpath" - - rpath= - hardcode_libdirs= - for libdir in $finalize_rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - func_append rpath " $flag" - fi - elif test -n "$runpath_var"; then - case "$finalize_perm_rpath " in - *" $libdir "*) ;; - *) func_append finalize_perm_rpath " $libdir" ;; - esac - fi - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval rpath=\" $hardcode_libdir_flag_spec\" - fi - finalize_rpath="$rpath" - - if test -n "$libobjs" && test "$build_old_libs" = yes; then - # Transform all the library objects into standard objects. - compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` - finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` - fi - - func_generate_dlsyms "$outputname" "@PROGRAM@" "no" - - # template prelinking step - if test -n "$prelink_cmds"; then - func_execute_cmds "$prelink_cmds" 'exit $?' - fi - - wrappers_required=yes - case $host in - *cegcc* | *mingw32ce*) - # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. - wrappers_required=no - ;; - *cygwin* | *mingw* ) - if test "$build_libtool_libs" != yes; then - wrappers_required=no - fi - ;; - *) - if test "$need_relink" = no || test "$build_libtool_libs" != yes; then - wrappers_required=no - fi - ;; - esac - if test "$wrappers_required" = no; then - # Replace the output file specification. - compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` - link_command="$compile_command$compile_rpath" - - # We have no uninstalled library dependencies, so finalize right now. - exit_status=0 - func_show_eval "$link_command" 'exit_status=$?' - - if test -n "$postlink_cmds"; then - func_to_tool_file "$output" - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` - func_execute_cmds "$postlink_cmds" 'exit $?' - fi - - # Delete the generated files. - if test -f "$output_objdir/${outputname}S.${objext}"; then - func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' - fi - - exit $exit_status - fi - - if test -n "$compile_shlibpath$finalize_shlibpath"; then - compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" - fi - if test -n "$finalize_shlibpath"; then - finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" - fi - - compile_var= - finalize_var= - if test -n "$runpath_var"; then - if test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - func_append rpath "$dir:" - done - compile_var="$runpath_var=\"$rpath\$$runpath_var\" " - fi - if test -n "$finalize_perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $finalize_perm_rpath; do - func_append rpath "$dir:" - done - finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " - fi - fi - - if test "$no_install" = yes; then - # We don't need to create a wrapper script. - link_command="$compile_var$compile_command$compile_rpath" - # Replace the output file specification. - link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` - # Delete the old output file. - $opt_dry_run || $RM $output - # Link the executable and exit - func_show_eval "$link_command" 'exit $?' - - if test -n "$postlink_cmds"; then - func_to_tool_file "$output" - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` - func_execute_cmds "$postlink_cmds" 'exit $?' - fi - - exit $EXIT_SUCCESS - fi - - if test "$hardcode_action" = relink; then - # Fast installation is not supported - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" - - func_warning "this platform does not like uninstalled shared libraries" - func_warning "\`$output' will be relinked during installation" - else - if test "$fast_install" != no; then - link_command="$finalize_var$compile_command$finalize_rpath" - if test "$fast_install" = yes; then - relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` - else - # fast_install is set to needless - relink_command= - fi - else - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" - fi - fi - - # Replace the output file specification. - link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` - - # Delete the old output files. - $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname - - func_show_eval "$link_command" 'exit $?' - - if test -n "$postlink_cmds"; then - func_to_tool_file "$output_objdir/$outputname" - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` - func_execute_cmds "$postlink_cmds" 'exit $?' - fi - - # Now create the wrapper script. - func_verbose "creating $output" - - # Quote the relink command for shipping. - if test -n "$relink_command"; then - # Preserve any variables that may affect compiler behavior - for var in $variables_saved_for_relink; do - if eval test -z \"\${$var+set}\"; then - relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" - elif eval var_value=\$$var; test -z "$var_value"; then - relink_command="$var=; export $var; $relink_command" - else - func_quote_for_eval "$var_value" - relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" - fi - done - relink_command="(cd `pwd`; $relink_command)" - relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` - fi - - # Only actually do things if not in dry run mode. - $opt_dry_run || { - # win32 will think the script is a binary if it has - # a .exe suffix, so we strip it off here. - case $output in - *.exe) func_stripname '' '.exe' "$output" - output=$func_stripname_result ;; - esac - # test for cygwin because mv fails w/o .exe extensions - case $host in - *cygwin*) - exeext=.exe - func_stripname '' '.exe' "$outputname" - outputname=$func_stripname_result ;; - *) exeext= ;; - esac - case $host in - *cygwin* | *mingw* ) - func_dirname_and_basename "$output" "" "." - output_name=$func_basename_result - output_path=$func_dirname_result - cwrappersource="$output_path/$objdir/lt-$output_name.c" - cwrapper="$output_path/$output_name.exe" - $RM $cwrappersource $cwrapper - trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 - - func_emit_cwrapperexe_src > $cwrappersource - - # The wrapper executable is built using the $host compiler, - # because it contains $host paths and files. If cross- - # compiling, it, like the target executable, must be - # executed on the $host or under an emulation environment. - $opt_dry_run || { - $LTCC $LTCFLAGS -o $cwrapper $cwrappersource - $STRIP $cwrapper - } - - # Now, create the wrapper script for func_source use: - func_ltwrapper_scriptname $cwrapper - $RM $func_ltwrapper_scriptname_result - trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 - $opt_dry_run || { - # note: this script will not be executed, so do not chmod. - if test "x$build" = "x$host" ; then - $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result - else - func_emit_wrapper no > $func_ltwrapper_scriptname_result - fi - } - ;; - * ) - $RM $output - trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 - - func_emit_wrapper no > $output - chmod +x $output - ;; - esac - } - exit $EXIT_SUCCESS - ;; - esac - - # See if we need to build an old-fashioned archive. - for oldlib in $oldlibs; do - - if test "$build_libtool_libs" = convenience; then - oldobjs="$libobjs_save $symfileobj" - addlibs="$convenience" - build_libtool_libs=no - else - if test "$build_libtool_libs" = module; then - oldobjs="$libobjs_save" - build_libtool_libs=no - else - oldobjs="$old_deplibs $non_pic_objects" - if test "$preload" = yes && test -f "$symfileobj"; then - func_append oldobjs " $symfileobj" - fi - fi - addlibs="$old_convenience" - fi - - if test -n "$addlibs"; then - gentop="$output_objdir/${outputname}x" - func_append generated " $gentop" - - func_extract_archives $gentop $addlibs - func_append oldobjs " $func_extract_archives_result" - fi - - # Do each command in the archive commands. - if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then - cmds=$old_archive_from_new_cmds - else - - # Add any objects from preloaded convenience libraries - if test -n "$dlprefiles"; then - gentop="$output_objdir/${outputname}x" - func_append generated " $gentop" - - func_extract_archives $gentop $dlprefiles - func_append oldobjs " $func_extract_archives_result" - fi - - # POSIX demands no paths to be encoded in archives. We have - # to avoid creating archives with duplicate basenames if we - # might have to extract them afterwards, e.g., when creating a - # static archive out of a convenience library, or when linking - # the entirety of a libtool archive into another (currently - # not supported by libtool). - if (for obj in $oldobjs - do - func_basename "$obj" - $ECHO "$func_basename_result" - done | sort | sort -uc >/dev/null 2>&1); then - : - else - echo "copying selected object files to avoid basename conflicts..." - gentop="$output_objdir/${outputname}x" - func_append generated " $gentop" - func_mkdir_p "$gentop" - save_oldobjs=$oldobjs - oldobjs= - counter=1 - for obj in $save_oldobjs - do - func_basename "$obj" - objbase="$func_basename_result" - case " $oldobjs " in - " ") oldobjs=$obj ;; - *[\ /]"$objbase "*) - while :; do - # Make sure we don't pick an alternate name that also - # overlaps. - newobj=lt$counter-$objbase - func_arith $counter + 1 - counter=$func_arith_result - case " $oldobjs " in - *[\ /]"$newobj "*) ;; - *) if test ! -f "$gentop/$newobj"; then break; fi ;; - esac - done - func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" - func_append oldobjs " $gentop/$newobj" - ;; - *) func_append oldobjs " $obj" ;; - esac - done - fi - func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 - tool_oldlib=$func_to_tool_file_result - eval cmds=\"$old_archive_cmds\" - - func_len " $cmds" - len=$func_len_result - if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then - cmds=$old_archive_cmds - elif test -n "$archiver_list_spec"; then - func_verbose "using command file archive linking..." - for obj in $oldobjs - do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" - done > $output_objdir/$libname.libcmd - func_to_tool_file "$output_objdir/$libname.libcmd" - oldobjs=" $archiver_list_spec$func_to_tool_file_result" - cmds=$old_archive_cmds - else - # the command line is too long to link in one step, link in parts - func_verbose "using piecewise archive linking..." - save_RANLIB=$RANLIB - RANLIB=: - objlist= - concat_cmds= - save_oldobjs=$oldobjs - oldobjs= - # Is there a better way of finding the last object in the list? - for obj in $save_oldobjs - do - last_oldobj=$obj - done - eval test_cmds=\"$old_archive_cmds\" - func_len " $test_cmds" - len0=$func_len_result - len=$len0 - for obj in $save_oldobjs - do - func_len " $obj" - func_arith $len + $func_len_result - len=$func_arith_result - func_append objlist " $obj" - if test "$len" -lt "$max_cmd_len"; then - : - else - # the above command should be used before it gets too long - oldobjs=$objlist - if test "$obj" = "$last_oldobj" ; then - RANLIB=$save_RANLIB - fi - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" - objlist= - len=$len0 - fi - done - RANLIB=$save_RANLIB - oldobjs=$objlist - if test "X$oldobjs" = "X" ; then - eval cmds=\"\$concat_cmds\" - else - eval cmds=\"\$concat_cmds~\$old_archive_cmds\" - fi - fi - fi - func_execute_cmds "$cmds" 'exit $?' - done - - test -n "$generated" && \ - func_show_eval "${RM}r$generated" - - # Now create the libtool archive. - case $output in - *.la) - old_library= - test "$build_old_libs" = yes && old_library="$libname.$libext" - func_verbose "creating $output" - - # Preserve any variables that may affect compiler behavior - for var in $variables_saved_for_relink; do - if eval test -z \"\${$var+set}\"; then - relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" - elif eval var_value=\$$var; test -z "$var_value"; then - relink_command="$var=; export $var; $relink_command" - else - func_quote_for_eval "$var_value" - relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" - fi - done - # Quote the link command for shipping. - relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" - relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` - if test "$hardcode_automatic" = yes ; then - relink_command= - fi - - # Only create the output if not a dry run. - $opt_dry_run || { - for installed in no yes; do - if test "$installed" = yes; then - if test -z "$install_libdir"; then - break - fi - output="$output_objdir/$outputname"i - # Replace all uninstalled libtool libraries with the installed ones - newdependency_libs= - for deplib in $dependency_libs; do - case $deplib in - *.la) - func_basename "$deplib" - name="$func_basename_result" - func_resolve_sysroot "$deplib" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` - test -z "$libdir" && \ - func_fatal_error "\`$deplib' is not a valid libtool archive" - func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" - ;; - -L*) - func_stripname -L '' "$deplib" - func_replace_sysroot "$func_stripname_result" - func_append newdependency_libs " -L$func_replace_sysroot_result" - ;; - -R*) - func_stripname -R '' "$deplib" - func_replace_sysroot "$func_stripname_result" - func_append newdependency_libs " -R$func_replace_sysroot_result" - ;; - *) func_append newdependency_libs " $deplib" ;; - esac - done - dependency_libs="$newdependency_libs" - newdlfiles= - - for lib in $dlfiles; do - case $lib in - *.la) - func_basename "$lib" - name="$func_basename_result" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - test -z "$libdir" && \ - func_fatal_error "\`$lib' is not a valid libtool archive" - func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" - ;; - *) func_append newdlfiles " $lib" ;; - esac - done - dlfiles="$newdlfiles" - newdlprefiles= - for lib in $dlprefiles; do - case $lib in - *.la) - # Only pass preopened files to the pseudo-archive (for - # eventual linking with the app. that links it) if we - # didn't already link the preopened objects directly into - # the library: - func_basename "$lib" - name="$func_basename_result" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - test -z "$libdir" && \ - func_fatal_error "\`$lib' is not a valid libtool archive" - func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" - ;; - esac - done - dlprefiles="$newdlprefiles" - else - newdlfiles= - for lib in $dlfiles; do - case $lib in - [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; - *) abs=`pwd`"/$lib" ;; - esac - func_append newdlfiles " $abs" - done - dlfiles="$newdlfiles" - newdlprefiles= - for lib in $dlprefiles; do - case $lib in - [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; - *) abs=`pwd`"/$lib" ;; - esac - func_append newdlprefiles " $abs" - done - dlprefiles="$newdlprefiles" - fi - $RM $output - # place dlname in correct position for cygwin - # In fact, it would be nice if we could use this code for all target - # systems that can't hard-code library paths into their executables - # and that have no shared library path variable independent of PATH, - # but it turns out we can't easily determine that from inspecting - # libtool variables, so we have to hard-code the OSs to which it - # applies here; at the moment, that means platforms that use the PE - # object format with DLL files. See the long comment at the top of - # tests/bindir.at for full details. - tdlname=$dlname - case $host,$output,$installed,$module,$dlname in - *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) - # If a -bindir argument was supplied, place the dll there. - if test "x$bindir" != x ; - then - func_relative_path "$install_libdir" "$bindir" - tdlname=$func_relative_path_result$dlname - else - # Otherwise fall back on heuristic. - tdlname=../bin/$dlname - fi - ;; - esac - $ECHO > $output "\ -# $outputname - a libtool library file -# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION -# -# Please DO NOT delete this file! -# It is necessary for linking the library. - -# The name that we can dlopen(3). -dlname='$tdlname' - -# Names of this library. -library_names='$library_names' - -# The name of the static archive. -old_library='$old_library' - -# Linker flags that can not go in dependency_libs. -inherited_linker_flags='$new_inherited_linker_flags' - -# Libraries that this one depends upon. -dependency_libs='$dependency_libs' - -# Names of additional weak libraries provided by this library -weak_library_names='$weak_libs' - -# Version information for $libname. -current=$current -age=$age -revision=$revision - -# Is this an already installed library? -installed=$installed - -# Should we warn about portability when linking against -modules? -shouldnotlink=$module - -# Files to dlopen/dlpreopen -dlopen='$dlfiles' -dlpreopen='$dlprefiles' - -# Directory that this library needs to be installed in: -libdir='$install_libdir'" - if test "$installed" = no && test "$need_relink" = yes; then - $ECHO >> $output "\ -relink_command=\"$relink_command\"" - fi - done - } - - # Do a symbolic link so that the libtool archive can be found in - # LD_LIBRARY_PATH before the program is installed. - func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' - ;; - esac - exit $EXIT_SUCCESS -} - -{ test "$opt_mode" = link || test "$opt_mode" = relink; } && - func_mode_link ${1+"$@"} - - -# func_mode_uninstall arg... -func_mode_uninstall () -{ - $opt_debug - RM="$nonopt" - files= - rmforce= - exit_status=0 - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - for arg - do - case $arg in - -f) func_append RM " $arg"; rmforce=yes ;; - -*) func_append RM " $arg" ;; - *) func_append files " $arg" ;; - esac - done - - test -z "$RM" && \ - func_fatal_help "you must specify an RM program" - - rmdirs= - - for file in $files; do - func_dirname "$file" "" "." - dir="$func_dirname_result" - if test "X$dir" = X.; then - odir="$objdir" - else - odir="$dir/$objdir" - fi - func_basename "$file" - name="$func_basename_result" - test "$opt_mode" = uninstall && odir="$dir" - - # Remember odir for removal later, being careful to avoid duplicates - if test "$opt_mode" = clean; then - case " $rmdirs " in - *" $odir "*) ;; - *) func_append rmdirs " $odir" ;; - esac - fi - - # Don't error if the file doesn't exist and rm -f was used. - if { test -L "$file"; } >/dev/null 2>&1 || - { test -h "$file"; } >/dev/null 2>&1 || - test -f "$file"; then - : - elif test -d "$file"; then - exit_status=1 - continue - elif test "$rmforce" = yes; then - continue - fi - - rmfiles="$file" - - case $name in - *.la) - # Possibly a libtool archive, so verify it. - if func_lalib_p "$file"; then - func_source $dir/$name - - # Delete the libtool libraries and symlinks. - for n in $library_names; do - func_append rmfiles " $odir/$n" - done - test -n "$old_library" && func_append rmfiles " $odir/$old_library" - - case "$opt_mode" in - clean) - case " $library_names " in - *" $dlname "*) ;; - *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; - esac - test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" - ;; - uninstall) - if test -n "$library_names"; then - # Do each command in the postuninstall commands. - func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' - fi - - if test -n "$old_library"; then - # Do each command in the old_postuninstall commands. - func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' - fi - # FIXME: should reinstall the best remaining shared library. - ;; - esac - fi - ;; - - *.lo) - # Possibly a libtool object, so verify it. - if func_lalib_p "$file"; then - - # Read the .lo file - func_source $dir/$name - - # Add PIC object to the list of files to remove. - if test -n "$pic_object" && - test "$pic_object" != none; then - func_append rmfiles " $dir/$pic_object" - fi - - # Add non-PIC object to the list of files to remove. - if test -n "$non_pic_object" && - test "$non_pic_object" != none; then - func_append rmfiles " $dir/$non_pic_object" - fi - fi - ;; - - *) - if test "$opt_mode" = clean ; then - noexename=$name - case $file in - *.exe) - func_stripname '' '.exe' "$file" - file=$func_stripname_result - func_stripname '' '.exe' "$name" - noexename=$func_stripname_result - # $file with .exe has already been added to rmfiles, - # add $file without .exe - func_append rmfiles " $file" - ;; - esac - # Do a test to see if this is a libtool program. - if func_ltwrapper_p "$file"; then - if func_ltwrapper_executable_p "$file"; then - func_ltwrapper_scriptname "$file" - relink_command= - func_source $func_ltwrapper_scriptname_result - func_append rmfiles " $func_ltwrapper_scriptname_result" - else - relink_command= - func_source $dir/$noexename - fi - - # note $name still contains .exe if it was in $file originally - # as does the version of $file that was added into $rmfiles - func_append rmfiles " $odir/$name $odir/${name}S.${objext}" - if test "$fast_install" = yes && test -n "$relink_command"; then - func_append rmfiles " $odir/lt-$name" - fi - if test "X$noexename" != "X$name" ; then - func_append rmfiles " $odir/lt-${noexename}.c" - fi - fi - fi - ;; - esac - func_show_eval "$RM $rmfiles" 'exit_status=1' - done - - # Try to remove the ${objdir}s in the directories where we deleted files - for dir in $rmdirs; do - if test -d "$dir"; then - func_show_eval "rmdir $dir >/dev/null 2>&1" - fi - done - - exit $exit_status -} - -{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && - func_mode_uninstall ${1+"$@"} - -test -z "$opt_mode" && { - help="$generic_help" - func_fatal_help "you must specify a MODE" -} - -test -z "$exec_cmd" && \ - func_fatal_help "invalid operation mode \`$opt_mode'" - -if test -n "$exec_cmd"; then - eval exec "$exec_cmd" - exit $EXIT_FAILURE -fi - -exit $exit_status - - -# The TAGs below are defined such that we never get into a situation -# in which we disable both kinds of libraries. Given conflicting -# choices, we go for a static library, that is the most portable, -# since we can't tell whether shared libraries were disabled because -# the user asked for that or because the platform doesn't support -# them. This is particularly important on AIX, because we don't -# support having both static and shared libraries enabled at the same -# time on that platform, so we default to a shared-only configuration. -# If a disable-shared tag is given, we'll fallback to a static-only -# configuration. But we'll never go from static-only to shared-only. - -# ### BEGIN LIBTOOL TAG CONFIG: disable-shared -build_libtool_libs=no -build_old_libs=yes -# ### END LIBTOOL TAG CONFIG: disable-shared - -# ### BEGIN LIBTOOL TAG CONFIG: disable-static -build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` -# ### END LIBTOOL TAG CONFIG: disable-static - -# Local Variables: -# mode:shell-script -# sh-indentation:2 -# End: -# vi:sw=2 - diff --git a/libs/apr/build/make_exports.awk b/libs/apr/build/make_exports.awk deleted file mode 100644 index 1d12fc65..00000000 --- a/libs/apr/build/make_exports.awk +++ /dev/null @@ -1,150 +0,0 @@ - -BEGIN { - printf("/*\n") - printf(" * THIS FILE WAS AUTOGENERATED BY make_exports.awk\n") - printf(" *\n") - printf(" * This is an ugly hack that needs to be here, so\n") - printf(" * that libtool will link all of the APR functions\n") - printf(" * into server regardless of whether the base server\n") - printf(" * uses them.\n") - printf(" */\n") - printf("\n") - printf("#define CORE_PRIVATE\n") - printf("\n") - - for (i = 1; i < ARGC; i++) { - file = ARGV[i] - sub("([^/]*[/])*", "", file) - printf("#include \"%s\"\n", file) - } - - printf("\n") - printf("const void *ap_ugly_hack = NULL;\n") - printf("\n") - - TYPE_NORMAL = 0 - TYPE_HEADER = 1 - - stackptr = 0 -} - -function push(line) { - stack[stackptr] = line - stackptr++ -} - -function do_output() { - printf("/*\n") - printf(" * %s\n", FILENAME) - printf(" */\n") - - for (i = 0; i < stackptr; i++) { - printf("%s\n", stack[i]) - } - - stackptr = 0 - - printf("\n"); -} - -function enter_scope(type) { - scope++ - scope_type[scope] = type - scope_stack[scope] = stackptr - delete scope_used[scope] -} - -function leave_scope() { - used = scope_used[scope] - - if (!used) - stackptr = scope_stack[scope] - - scope-- - if (used) { - scope_used[scope] = 1 - - if (!scope) - do_output() - } -} - -function add_symbol(symbol) { - if (!index(symbol, "#")) { - push("const void *ap_hack_" symbol " = (const void *)" symbol ";") - scope_used[scope] = 1 - } -} - -/^[ \t]*AP[RUI]?_(CORE_)?DECLARE[^(]*[(][^)]*[)]([^ ]* )*[^(]+[(]/ { - sub("[ \t]*AP[RUI]?_(CORE_)?DECLARE[^(]*[(][^)]*[)][ \t]*", "") - sub("[(].*", "") - sub("([^ ]* (^([ \t]*[(])))+", "") - - add_symbol($0) - next -} - -/^[ \t]*AP_DECLARE_HOOK[^(]*[(][^)]*/ { - split($0, args, ",") - symbol = args[2] - sub("^[ \t]+", "", symbol) - sub("[ \t]+$", "", symbol) - - add_symbol("ap_hook_" symbol) - add_symbol("ap_hook_get_" symbol) - add_symbol("ap_run_" symbol) - next -} - -/^[ \t]*APR_POOL_DECLARE_ACCESSOR[^(]*[(][^)]*[)]/ { - sub("[ \t]*APR_POOL_DECLARE_ACCESSOR[^(]*[(]", "", $0) - sub("[)].*$", "", $0) - add_symbol("apr_" $0 "_pool_get") - next -} - -/^[ \t]*APR_DECLARE_INHERIT_SET[^(]*[(][^)]*[)]/ { - sub("[ \t]*APR_DECLARE_INHERIT_SET[^(]*[(]", "", $0) - sub("[)].*$", "", $0) - add_symbol("apr_" $0 "_inherit_set") - next -} - -/^[ \t]*APR_DECLARE_INHERIT_UNSET[^(]*[(][^)]*[)]/ { - sub("[ \t]*APR_DECLARE_INHERIT_UNSET[^(]*[(]", "", $0) - sub("[)].*$", "", $0) - add_symbol("apr_" $0 "_inherit_unset") - next -} - -/^#[ \t]*if(ndef| !defined[(])([^_]*_)*H/ { - enter_scope(TYPE_HEADER) - next -} - -/^#[ \t]*if([n]?def)? / { - enter_scope(TYPE_NORMAL) - push($0) - next -} - -/^#[ \t]*endif/ { - if (scope_type[scope] == TYPE_NORMAL) - push($0) - - leave_scope() - next -} - -/^#[ \t]*else/ { - push($0) - next -} - -/^#[ \t]*elif/ { - push($0) - next -} - - diff --git a/libs/apr/build/make_nw_export.awk b/libs/apr/build/make_nw_export.awk deleted file mode 100644 index b3e94834..00000000 --- a/libs/apr/build/make_nw_export.awk +++ /dev/null @@ -1,106 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Based on apr's make_export.awk, which is -# based on Ryan Bloom's make_export.pl -# - -BEGIN { - add_symbol("apr_wait_for_io_or_timeout") -} - -function add_symbol(sym_name) { - sub(" ", "", sym_name) - exports[++idx] = sym_name -} - -# List of functions that we don't support, yet?? -#/apr_##name##_set_inherit/{next} -#/apr_##name##_unset_inherit/{next} - -/^[ \t]*AP[RUI]?_DECLARE[^(]*[(][^)]*[)]([^ ]* )*[^(]+[(]/ { - sub("[ \t]*AP[RUI]?_DECLARE[^(]*[(][^)]*[)][ \t]*", "") - sub("[(].*", "") - sub("([^ ]* (^([ \t]*[(])))+", "") - add_symbol($0) - next -} - -/^[ \t]*AP_DECLARE_HOOK[^(]*[(][^)]*/ { - split($0, args, ",") - symbol = args[2] - sub("^[ \t]+", "", symbol) - sub("[ \t]+$", "", symbol) - add_symbol("ap_hook_" symbol) - add_symbol("ap_hook_get_" symbol) - add_symbol("ap_run_" symbol) - next -} - -/^[ \t]*APR_POOL_DECLARE_ACCESSOR[^(]*[(][^)]*[)]/ { - sub("[ \t]*APR_POOL_DECLARE_ACCESSOR[^(]*[(]", "", $0) - sub("[)].*$", "", $0) - add_symbol("apr_" $0 "_pool_get") - next -} - -/^[ \t]*APR_DECLARE_INHERIT_SET[^(]*[(][^)]*[)]/ { - sub("[ \t]*APR_DECLARE_INHERIT_SET[^(]*[(]", "", $0) - sub("[)].*$", "", $0) - add_symbol("apr_" $0 "_inherit_set") - next -} - -/^[ \t]*APR_DECLARE_INHERIT_UNSET[^(]*[(][^)]*[)]/ { - sub("[ \t]*APR_DECLARE_INHERIT_UNSET[^(]*[(]", "", $0) - sub("[)].*$", "", $0) - add_symbol("apr_" $0 "_inherit_unset") - next -} - -/^[ \t]*AP[RUI]?_DECLARE_DATA .*;/ { - gsub(/[*;\n\r]/, "", $NF) - gsub(/\[.*\]/, "", $NF) - add_symbol($NF) -} - - -END { - printf("Added %d symbols to export list.\n", idx) > "/dev/stderr" - # sort symbols with shell sort - increment = int(idx / 2) - while (increment > 0) { - for (i = increment+1; i <= idx; i++) { - j = i - temp = exports[i] - while ((j >= increment+1) && (exports[j-increment] > temp)) { - exports[j] = exports[j-increment] - j -= increment - } - exports[j] = temp - } - if (increment == 2) - increment = 1 - else - increment = int(increment*5/11) - } - # print the array - printf(" (%s)\n", EXPPREFIX) - while (x < idx - 1) { - printf(" %s,\n", exports[++x]) - } - printf(" %s\n", exports[++x]) -} - diff --git a/libs/apr/build/make_var_export.awk b/libs/apr/build/make_var_export.awk deleted file mode 100644 index 59922758..00000000 --- a/libs/apr/build/make_var_export.awk +++ /dev/null @@ -1,59 +0,0 @@ -# Based on apr's make_export.awk, which is -# based on Ryan Bloom's make_export.pl - -/^#[ \t]*if(def)? (AP[RUI]?_|!?defined).*/ { - if (old_filename != FILENAME) { - if (old_filename != "") printf("%s", line) - macro_no = 0 - found = 0 - count = 0 - old_filename = FILENAME - line = "" - } - macro_stack[macro_no++] = macro - macro = substr($0, length($1)+2) - count++ - line = line "#ifdef " macro "\n" - next -} - -/^#[ \t]*endif/ { - if (count > 0) { - count-- - line = line "#endif /* " macro " */\n" - macro = macro_stack[--macro_no] - } - if (count == 0) { - if (found != 0) { - printf("%s", line) - } - line = "" - } - next -} - -function add_symbol (sym_name) { - if (count) { - found++ - } - for (i = 0; i < count; i++) { - line = line "\t" - } - line = line sym_name "\n" - - if (count == 0) { - printf("%s", line) - line = "" - } -} - -/^[ \t]*(extern[ \t]+)?AP[RUI]?_DECLARE_DATA .*;$/ { - varname = $NF; - gsub( /[*;]/, "", varname); - gsub( /\[.*\]/, "", varname); - add_symbol(varname); -} - -END { - printf("%s", line) -} diff --git a/libs/apr/build/mkdir.sh b/libs/apr/build/mkdir.sh deleted file mode 100644 index b947c926..00000000 --- a/libs/apr/build/mkdir.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -## -## mkdir.sh -- make directory hierarchy -## -## Based on `mkinstalldirs' from Noah Friedman -## as of 1994-03-25, which was placed in the Public Domain. -## Cleaned up for Apache's Autoconf-style Interface (APACI) -## by Ralf S. Engelschall -## -# -# This script falls under the Apache License. -# See http://www.apache.org/docs/LICENSE - - -umask 022 -errstatus=0 -for file in ${1+"$@"} ; do - set fnord `echo ":$file" |\ - sed -e 's/^:\//%/' -e 's/^://' -e 's/\// /g' -e 's/^%/\//'` - shift - pathcomp= - for d in ${1+"$@"}; do - pathcomp="$pathcomp$d" - case "$pathcomp" in - -* ) pathcomp=./$pathcomp ;; - ?: ) pathcomp="$pathcomp/" - continue ;; - esac - if test ! -d "$pathcomp"; then - echo "mkdir $pathcomp" 1>&2 - mkdir "$pathcomp" || errstatus=$? - fi - pathcomp="$pathcomp/" - done -done -exit $errstatus - diff --git a/libs/apr/build/nw_export.inc b/libs/apr/build/nw_export.inc deleted file mode 100644 index 452b4018..00000000 --- a/libs/apr/build/nw_export.inc +++ /dev/null @@ -1,50 +0,0 @@ -/* Must include apr.h first so that we can undefine - the standard prototypes macros after it messes with - them. */ -#include "apr.h" - -#undef APR_DECLARE -#undef APR_DECLARE_NONSTD -#undef APR_DECLARE_HOOK -#undef APR_POOL_DECLARE_ACCESSOR -#undef APR_DECLARE_DATA - -/* Preprocess all of the standard APR headers. */ -#include "apr_allocator.h" -#include "apr_atomic.h" -#include "apr_dso.h" -#include "apr_env.h" -#include "apr_errno.h" -#include "apr_file_info.h" -#include "apr_file_io.h" -#include "apr_fnmatch.h" -#include "apr_general.h" -#include "apr_getopt.h" -#include "apr_global_mutex.h" -#include "apr_hash.h" -#include "apr_inherit.h" -#include "apr_lib.h" -#include "apr_mmap.h" -#include "apr_network_io.h" -#include "apr_poll.h" -#include "apr_pools.h" -#include "apr_portable.h" -#include "apr_proc_mutex.h" -#include "apr_ring.h" -#include "apr_random.h" -#include "apr_shm.h" -#include "apr_signal.h" -#include "apr_strings.h" -#include "apr_support.h" -#include "apr_tables.h" -#include "apr_thread_cond.h" -#include "apr_thread_mutex.h" -#include "apr_thread_proc.h" -#include "apr_thread_rwlock.h" -#include "apr_time.h" -#include "apr_user.h" -#include "apr_version.h" -#include "apr_want.h" - -#include "nw_apu_export.inc" - diff --git a/libs/apr/build/nw_ver.awk b/libs/apr/build/nw_ver.awk deleted file mode 100644 index e83ea968..00000000 --- a/libs/apr/build/nw_ver.awk +++ /dev/null @@ -1,56 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -BEGIN { - - # fetch APR version numbers from input file and write them to STDOUT - - while ((getline < ARGV[1]) > 0) { - if (match ($0, /^#define APR_MAJOR_VERSION/)) { - ver_major = $3; - } - else if (match ($0, /^#define APR_MINOR_VERSION/)) { - ver_minor = $3; - } - else if (match ($0, /^#define APR_PATCH_VERSION/)) { - ver_patch = $3; - } - else if (match ($0, /^#define APR_IS_DEV_VERSION/)) { - ver_devbuild = 1; - } - } - ver_str = ver_major "." ver_minor "." ver_patch (ver_devbuild ? "-dev" : ""); - if (WANTED) { - ver_num = ver_major * 1000000 + ver_minor * 1000 + ver_patch; - if (ver_num < WANTED) { - print "ERROR: APR version " ver_str " does NOT match!"; - exit 1; - } else if (ver_num > (WANTED + 1000)) { - print "WARNING: APR version " ver_str " higher than expected!"; - exit 0; - } else { - print "OK: APR version " ver_str ""; - exit 0; - } - } else { - ver_nlm = ver_major "," ver_minor "," ver_patch; - print "VERSION = " ver_nlm ""; - print "VERSION_STR = " ver_str ""; - print "VERSION_MAJMIN = " ver_major ver_minor ""; - } - -} - - diff --git a/libs/apr/build/pkg/README b/libs/apr/build/pkg/README deleted file mode 100644 index ce1c9b73..00000000 --- a/libs/apr/build/pkg/README +++ /dev/null @@ -1,20 +0,0 @@ -The script in this directory will attempt to build a Solaris package -out of a source tree for APR. - -To build a package, make sure you are in the root of the source tree, -and run: - -build/pkg/buildpkg.sh - -A Solaris package called apr---local.gz will be -created in the root of the source tree. - -By default, if you attempt to build packages for apr-util, it will -search for the sources for apr in: - -../apr - -You may override the location of apr like so: - -build/pkg/buildpkg.sh --with-apr=some/other/path - diff --git a/libs/apr/build/pkg/buildpkg.sh b/libs/apr/build/pkg/buildpkg.sh deleted file mode 100644 index 073e89d7..00000000 --- a/libs/apr/build/pkg/buildpkg.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/sh -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# - -# buildpkg.sh: This script builds a Solaris PKG from the source tree -# provided. - -PREFIX=/usr/local -TEMPDIR=/var/tmp/$USER/apr-root -rm -rf $TEMPDIR - -apr_src_dir=. - -while test $# -gt 0 -do - # Normalize - case "$1" in - -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) optarg= ;; - esac - - case "$1" in - --with-apr=*) - apr_src_dir=$optarg - ;; - esac - - shift -done - -if [ -f "$apr_src_dir/configure.in" ]; then - cd $apr_src_dir -else - echo "The apr source could not be found within $apr_src_dir" - echo "Usage: buildpkg [--with-apr=dir]" - exit 1 -fi - -./configure --prefix=$PREFIX -make -make install DESTDIR=$TEMPDIR -rm $TEMPDIR$PREFIX/lib/apr.exp -. build/pkg/pkginfo -cp build/pkg/pkginfo $TEMPDIR$PREFIX - -current=`pwd` -cd $TEMPDIR$PREFIX -echo "i pkginfo=./pkginfo" > prototype -find . -print | grep -v ./prototype | grep -v ./pkginfo | pkgproto | awk '{print $1" "$2" "$3" "$4" root bin"}' >> prototype -mkdir $TEMPDIR/pkg -pkgmk -r $TEMPDIR$PREFIX -d $TEMPDIR/pkg - -cd $current -pkgtrans -s $TEMPDIR/pkg $current/$NAME-$VERSION-$ARCH-local -gzip $current/$NAME-$VERSION-$ARCH-local - -rm -rf $TEMPDIR - diff --git a/libs/apr/build/pkg/pkginfo.in b/libs/apr/build/pkg/pkginfo.in deleted file mode 100644 index f389b269..00000000 --- a/libs/apr/build/pkg/pkginfo.in +++ /dev/null @@ -1,11 +0,0 @@ -PKG="ASFapr-1" -NAME="apr" -ARCH="@target_cpu@" -VERSION="@APR_DOTTED_VERSION@" -CATEGORY="application" -VENDOR="Apache Software Foundation" -EMAIL="dev@apr.apache.org" -PSTAMP="dev@apr.apache.org" -BASEDIR="@prefix@" -CLASSES="none" - diff --git a/libs/apr/build/preaprapp.dsp b/libs/apr/build/preaprapp.dsp deleted file mode 100644 index caa95dfa..00000000 --- a/libs/apr/build/preaprapp.dsp +++ /dev/null @@ -1,179 +0,0 @@ -# Microsoft Developer Studio Project File - Name="preaprapp" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) External Target" 0x0106 - -CFG=preaprapp - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "preaprapp.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "preaprapp.mak" CFG="preaprapp - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "preaprapp - Win32 Release" (based on "Win32 (x86) External Target") -!MESSAGE "preaprapp - Win32 Debug" (based on "Win32 (x86) External Target") -!MESSAGE "preaprapp - Win32 Release9x" (based on "Win32 (x86) External Target") -!MESSAGE "preaprapp - Win32 Debug9x" (based on "Win32 (x86) External Target") -!MESSAGE "preaprapp - x64 Release" (based on "Win32 (x86) External Target") -!MESSAGE "preaprapp - x64 Debug" (based on "Win32 (x86) External Target") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" - -!IF "$(CFG)" == "preaprapp - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "" -# PROP BASE Intermediate_Dir "" -# PROP BASE Cmd_Line "NMAKE /nologo /f NUL" -# PROP BASE Rebuild_Opt "/a" -# PROP BASE Target_File "preaprapp.exe" -# PROP BASE Bsc_Name "preaprapp.bsc" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "" -# PROP Intermediate_Dir "" -# PROP Cmd_Line "NMAKE /nologo /f NUL" -# PROP Rebuild_Opt "/a" -# PROP Bsc_Name "" -# PROP Target_Dir "" - -!ELSEIF "$(CFG)" == "preaprapp - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "" -# PROP BASE Intermediate_Dir "" -# PROP BASE Cmd_Line "NMAKE /nologo /f NUL" -# PROP BASE Rebuild_Opt "/a" -# PROP BASE Target_File "preaprapp.exe" -# PROP BASE Bsc_Name "preaprapp.bsc" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "" -# PROP Intermediate_Dir "" -# PROP Cmd_Line "NMAKE /nologo /f NUL" -# PROP Rebuild_Opt "/a" -# PROP Bsc_Name "" -# PROP Target_Dir "" - -!ELSEIF "$(CFG)" == "preaprapp - Win32 Release9x" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "" -# PROP BASE Intermediate_Dir "" -# PROP BASE Cmd_Line "NMAKE /nologo /f NUL" -# PROP BASE Rebuild_Opt "/a" -# PROP BASE Target_File "preaprapp.exe" -# PROP BASE Bsc_Name "preaprapp.bsc" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "" -# PROP Intermediate_Dir "" -# PROP Cmd_Line "NMAKE /nologo /f NUL" -# PROP Rebuild_Opt "/a" -# PROP Bsc_Name "" -# PROP Target_Dir "" - -!ELSEIF "$(CFG)" == "preaprapp - Win32 Debug9x" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "" -# PROP BASE Intermediate_Dir "" -# PROP BASE Cmd_Line "NMAKE /nologo /f NUL" -# PROP BASE Rebuild_Opt "/a" -# PROP BASE Target_File "preaprapp.exe" -# PROP BASE Bsc_Name "preaprapp.bsc" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "" -# PROP Intermediate_Dir "" -# PROP Cmd_Line "NMAKE /nologo /f NUL" -# PROP Rebuild_Opt "/a" -# PROP Bsc_Name "" -# PROP Target_Dir "" - -!ELSEIF "$(CFG)" == "preaprapp - x64 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "" -# PROP BASE Intermediate_Dir "" -# PROP BASE Cmd_Line "NMAKE /nologo /f NUL" -# PROP BASE Rebuild_Opt "/a" -# PROP BASE Target_File "preaprapp.exe" -# PROP BASE Bsc_Name "preaprapp.bsc" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "" -# PROP Intermediate_Dir "" -# PROP Cmd_Line "NMAKE /nologo /f NUL" -# PROP Rebuild_Opt "/a" -# PROP Bsc_Name "" -# PROP Target_Dir "" - -!ELSEIF "$(CFG)" == "preaprapp - x64 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "" -# PROP BASE Intermediate_Dir "" -# PROP BASE Cmd_Line "NMAKE /nologo /f NUL" -# PROP BASE Rebuild_Opt "/a" -# PROP BASE Target_File "preaprapp.exe" -# PROP BASE Bsc_Name "preaprapp.bsc" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "" -# PROP Intermediate_Dir "" -# PROP Cmd_Line "NMAKE /nologo /f NUL" -# PROP Rebuild_Opt "/a" -# PROP Bsc_Name "" -# PROP Target_Dir "" - -!ENDIF - -# Begin Target - -# Name "preaprapp - Win32 Release" -# Name "preaprapp - Win32 Debug" -# Name "preaprapp - Win32 Release9x" -# Name "preaprapp - Win32 Debug9x" -# Name "preaprapp - x64 Release" -# Name "preaprapp - x64 Debug" - -!IF "$(CFG)" == "preaprapp - Win32 Release" - -!ELSEIF "$(CFG)" == "preaprapp - Win32 Debug" - -!ELSEIF "$(CFG)" == "preaprapp - Win32 Release9x" - -!ELSEIF "$(CFG)" == "preaprapp - Win32 Debug9x" - -!ELSEIF "$(CFG)" == "preaprapp - x64 Release" - -!ELSEIF "$(CFG)" == "preaprapp - x64 Debug" - -!ENDIF - -# End Target -# End Project diff --git a/libs/apr/build/prelibaprapp.dsp b/libs/apr/build/prelibaprapp.dsp deleted file mode 100644 index 3654a7fb..00000000 --- a/libs/apr/build/prelibaprapp.dsp +++ /dev/null @@ -1,179 +0,0 @@ -# Microsoft Developer Studio Project File - Name="prelibaprapp" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) External Target" 0x0106 - -CFG=prelibaprapp - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "prelibaprapp.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "prelibaprapp.mak" CFG="prelibaprapp - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "prelibaprapp - Win32 Release" (based on "Win32 (x86) External Target") -!MESSAGE "prelibaprapp - Win32 Debug" (based on "Win32 (x86) External Target") -!MESSAGE "prelibaprapp - Win32 Release9x" (based on "Win32 (x86) External Target") -!MESSAGE "prelibaprapp - Win32 Debug9x" (based on "Win32 (x86) External Target") -!MESSAGE "prelibaprapp - x64 Release" (based on "Win32 (x86) External Target") -!MESSAGE "prelibaprapp - x64 Debug" (based on "Win32 (x86) External Target") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" - -!IF "$(CFG)" == "prelibaprapp - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "" -# PROP BASE Intermediate_Dir "" -# PROP BASE Cmd_Line "NMAKE /nologo /f NUL" -# PROP BASE Rebuild_Opt "/a" -# PROP BASE Target_File "prelibaprapp.exe" -# PROP BASE Bsc_Name "prelibaprapp.bsc" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "" -# PROP Intermediate_Dir "" -# PROP Cmd_Line "NMAKE /nologo /f NUL" -# PROP Rebuild_Opt "/a" -# PROP Bsc_Name "" -# PROP Target_Dir "" - -!ELSEIF "$(CFG)" == "prelibaprapp - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "" -# PROP BASE Intermediate_Dir "" -# PROP BASE Cmd_Line "NMAKE /nologo /f NUL" -# PROP BASE Rebuild_Opt "/a" -# PROP BASE Target_File "prelibaprapp.exe" -# PROP BASE Bsc_Name "prelibaprapp.bsc" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "" -# PROP Intermediate_Dir "" -# PROP Cmd_Line "NMAKE /nologo /f NUL" -# PROP Rebuild_Opt "/a" -# PROP Bsc_Name "" -# PROP Target_Dir "" - -!ELSEIF "$(CFG)" == "prelibaprapp - Win32 Release9x" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "" -# PROP BASE Intermediate_Dir "" -# PROP BASE Cmd_Line "NMAKE /nologo /f NUL" -# PROP BASE Rebuild_Opt "/a" -# PROP BASE Target_File "prelibaprapp.exe" -# PROP BASE Bsc_Name "prelibaprapp.bsc" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "" -# PROP Intermediate_Dir "" -# PROP Cmd_Line "NMAKE /nologo /f NUL" -# PROP Rebuild_Opt "/a" -# PROP Bsc_Name "" -# PROP Target_Dir "" - -!ELSEIF "$(CFG)" == "prelibaprapp - Win32 Debug9x" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "" -# PROP BASE Intermediate_Dir "" -# PROP BASE Cmd_Line "NMAKE /nologo /f NUL" -# PROP BASE Rebuild_Opt "/a" -# PROP BASE Target_File "prelibaprapp.exe" -# PROP BASE Bsc_Name "prelibaprapp.bsc" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "" -# PROP Intermediate_Dir "" -# PROP Cmd_Line "NMAKE /nologo /f NUL" -# PROP Rebuild_Opt "/a" -# PROP Bsc_Name "" -# PROP Target_Dir "" - -!ELSEIF "$(CFG)" == "prelibaprapp - x64 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "" -# PROP BASE Intermediate_Dir "" -# PROP BASE Cmd_Line "NMAKE /nologo /f NUL" -# PROP BASE Rebuild_Opt "/a" -# PROP BASE Target_File "prelibaprapp.exe" -# PROP BASE Bsc_Name "prelibaprapp.bsc" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "" -# PROP Intermediate_Dir "" -# PROP Cmd_Line "NMAKE /nologo /f NUL" -# PROP Rebuild_Opt "/a" -# PROP Bsc_Name "" -# PROP Target_Dir "" - -!ELSEIF "$(CFG)" == "prelibaprapp - x64 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "" -# PROP BASE Intermediate_Dir "" -# PROP BASE Cmd_Line "NMAKE /nologo /f NUL" -# PROP BASE Rebuild_Opt "/a" -# PROP BASE Target_File "prelibaprapp.exe" -# PROP BASE Bsc_Name "prelibaprapp.bsc" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "" -# PROP Intermediate_Dir "" -# PROP Cmd_Line "NMAKE /nologo /f NUL" -# PROP Rebuild_Opt "/a" -# PROP Bsc_Name "" -# PROP Target_Dir "" - -!ENDIF - -# Begin Target - -# Name "prelibaprapp - Win32 Release" -# Name "prelibaprapp - Win32 Debug" -# Name "prelibaprapp - Win32 Release9x" -# Name "prelibaprapp - Win32 Debug9x" -# Name "prelibaprapp - x64 Release" -# Name "prelibaprapp - x64 Debug" - -!IF "$(CFG)" == "prelibaprapp - Win32 Release" - -!ELSEIF "$(CFG)" == "prelibaprapp - Win32 Debug" - -!ELSEIF "$(CFG)" == "prelibaprapp - Win32 Release9x" - -!ELSEIF "$(CFG)" == "prelibaprapp - Win32 Debug9x" - -!ELSEIF "$(CFG)" == "prelibaprapp - x64 Release" - -!ELSEIF "$(CFG)" == "prelibaprapp - x64 Debug" - -!ENDIF - -# End Target -# End Project diff --git a/libs/apr/build/rpm/apr.spec.in b/libs/apr/build/rpm/apr.spec.in deleted file mode 100644 index e35e9a38..00000000 --- a/libs/apr/build/rpm/apr.spec.in +++ /dev/null @@ -1,100 +0,0 @@ - -%define aprver 1 - -Summary: Apache Portable Runtime library -Name: apr -Version: APR_VERSION -Release: APR_RELEASE -License: Apache Software License -Group: System Environment/Libraries -URL: http://apr.apache.org/ -Source0: http://www.apache.org/dist/apr/%{name}-%{version}.tar.bz2 -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot -BuildRequires: autoconf, libtool, doxygen, python - -%description -The mission of the Apache Portable Runtime (APR) is to provide a -free library of C data structures and routines, forming a system -portability layer to as many operating systems as possible, -including Unices, MS Win32, BeOS and OS/2. - -%package devel -Group: Development/Libraries -Summary: APR library development kit -Requires: apr = %{version} - -%description devel -This package provides the support files which can be used to -build applications using the APR library. The mission of the -Apache Portable Runtime (APR) is to provide a free library of -C data structures and routines. - -%prep -%setup -q - -%build -# regenerate configure script etc. -./buildconf -%configure \ - --prefix=/usr \ - --includedir=%{_includedir}/apr-%{aprver} \ - --with-installbuilddir=%{_libdir}/apr/build-%{aprver} \ - --with-devrandom=/dev/urandom \ - CC=gcc CXX=g++ -make %{?_smp_mflags} && make dox - -%check -# Run non-interactive tests -pushd test -make %{?_smp_mflags} all CFLAGS=-fno-strict-aliasing -make check || exit 1 -popd - -%install -rm -rf $RPM_BUILD_ROOT -make install DESTDIR=$RPM_BUILD_ROOT - -# Move docs to more convenient location -mv docs/dox/html html - -# Unpackaged files: -rm -f $RPM_BUILD_ROOT%{_libdir}/apr.exp - -%clean -rm -rf $RPM_BUILD_ROOT - -%post -p /sbin/ldconfig - -%postun -p /sbin/ldconfig - -%files -%defattr(-,root,root,-) -%doc CHANGES LICENSE NOTICE -%{_libdir}/libapr-%{aprver}.so.* - -%files devel -%defattr(-,root,root,-) -%doc docs/APRDesign.html docs/canonical_filenames.html -%doc docs/incomplete_types docs/non_apr_programs -%doc --parents html -%{_bindir}/apr*config -%{_libdir}/libapr-%{aprver}.*a -%{_libdir}/libapr-%{aprver}.so -%dir %{_libdir}/apr -%dir %{_libdir}/apr/build-%{aprver} -%{_libdir}/apr/build-%{aprver}/* -%{_libdir}/pkgconfig/apr-%{aprver}.pc -%dir %{_includedir}/apr-%{aprver} -%{_includedir}/apr-%{aprver}/*.h - -%changelog -* Sat Aug 30 2008 Graham Leggett 1.3.3 -- update to depend on the bzip2 binary -- build depends on python - -* Tue Jun 22 2004 Graham Leggett 1.0.0-1 -- update to support v1.0.0 of APR - -* Tue Jun 22 2004 Graham Leggett 1.0.0-1 -- derived from Fedora Core apr.spec - diff --git a/libs/apr/build/run-gcov.sh b/libs/apr/build/run-gcov.sh deleted file mode 100644 index 98f911fc..00000000 --- a/libs/apr/build/run-gcov.sh +++ /dev/null @@ -1,130 +0,0 @@ -#!/bin/sh - -if [ ! -d coverage ]; then - mkdir coverage -fi -cd coverage - -# It would be really nice to find a better way to do this than copying the -# HTML into this script. But, I am being lazy right now. -cat > index.html << EOF - - - - - - - Test Coverage - - -

The Apache Portable Runtime Project

- - - - - - - - -
- ApacheCon -

Get Involved

- -
  • CVS
  • -
  • Mailing Lists
  • -
  • Snapshots
  • -
  • Build on Win32
  • -
  • Build on Unix
  • -
    -

    Download!

    - -
  • from a mirror
  • -
    -

    Docs

    - -
  • APR
  • -
  • APR-util
  • -
  • APR-iconv
  • -
    -

    Guidelines

    - -
  • Project Guidelines
  • -
  • Contributing
  • -
  • Version Numbers
  • -
    -

    Miscellaneous

    - -
  • License
  • -
  • Projects using APR
  • -
    -
    - - - -
    - - APR Test Coverage - -
    -
    -

    This should give us some idea of how well our tests actually stress our -code. To generate this data, do the following:

    - -
  • ./buildconf
  • -
  • CFLAGS="-fprofile-arcs -ftest-coverage ./configure
  • -
  • make
  • -
  • cd test
  • -
  • make
  • -
  • ./testall
  • -
  • cd ..
  • -
  • make gcov
  • -
    -

    Note that this will only generate test coverage data for the testall script, -but all tests should be moving to the unified framework, so this is correct.

    -
    - - -EOF - -for i in `find .. -name "*.bb" -maxdepth 1 | sort`; do - percent=`gcov $i -o .. | grep "%" | awk -F'%' {'print $1'}` - name=`echo $i | awk -F'/' {'print $2'}` - basename=`echo $name | awk -F'.' {'print $1'}` - - if [ "x$percent" = "x" ]; then - echo "" >> index.html - echo "" >> index.html - echo "
    Error generating data for $basename
    " >> index.html - continue; - fi - intpercent=`echo "$percent/1" | bc` - if [ $intpercent -lt 33 ]; then - color="#ffaaaa" - else if [ $intpercent -lt 66 ]; then - color="#ffff77" - else - color="#aaffaa" - fi - fi - - echo "
    $basename
    " >> index.html - echo "
    $percent% tested" >> index.html -done - -echo "

    Last generated `date`

    " >> index.html - -cat >> index.html << EOF -
    - -

    - - Copyright © 1999-2004, The Apache Software Foundation - -
    - - - -EOF diff --git a/libs/apr/build/win32ver.awk b/libs/apr/build/win32ver.awk deleted file mode 100644 index 11be0807..00000000 --- a/libs/apr/build/win32ver.awk +++ /dev/null @@ -1,124 +0,0 @@ -BEGIN { - - # ff bits: 1(debug), 2(prerelease), 4(patched), 8(vendor) and 32(special) - # debug is summed based on the /Define _DEBUG - # prerelease is based on the -dev extension, - # patched is based on a non-standard "-ver" extension, - # special and vendor are toggled by their args. - # - ff = 0; - - file=ARGV[1]; - desc=ARGV[2]; - rel_h=ARGV[3]; - - filename = file; - if (match(file, /\./)) { - sub(/\.[^\.]*$/, "", file); - } - - i = 4; - while (length(ARGV[i])) { - if (match(ARGV[i], /icon=/)) { - icon = substr(ARGV[i], 6); - } - if (match(ARGV[i], /vendor=/)) { - vendor = substr(ARGV[i], 8); - ff = ff + 8; - } - if (match(ARGV[i], /special=/)) { - special = substr(ARGV[i], 9); - ff = ff + 32; - } - i = i + 1 - } - - i = i - 1; - while (i) { - delete ARGV[i]; - i = i - 1; - } - - while ((getline < rel_h) > 0) { - if (match ($0, /^#define AP._MAJOR_VERSION/)) { - ver_major = $3; - } - if (match ($0, /^#define AP._MINOR_VERSION/)) { - ver_minor = $3; - } - if (match ($0, /^#define AP._PATCH_VERSION/)) { - ver_patch = $3; - } - if (match ($0, /^#define AP._IS_DEV_VERSION/)) { - ver_suffix = "-dev"; - ver_build = "0"; - } - if (match ($0, /^#undef AP._IS_DEV_VERSION/)) { - ver_build = "100"; - } - if (match ($0, /^.*Copyright /)) { - copyright = substr($0, RLENGTH + 1); - } - } - ver = ver_major "." ver_minor "." ver_patch ver_suffix; - verc = ver_major "," ver_minor "," ver_patch "," ver_build; - - if (length(vendor)) { - ff = ff + 8; - } - - if (length(icon)) { - print "1 ICON DISCARDABLE \"" icon "\""; - } - print "1 VERSIONINFO"; - print " FILEVERSION " verc ""; - print " PRODUCTVERSION " verc ""; - print " FILEFLAGSMASK 0x3fL"; - print "#if defined(_DEBUG)" - print " FILEFLAGS 0x" sprintf("%02x", ff + 1) "L"; - print "#else" - print " FILEFLAGS 0x" sprintf("%02x", ff) "L"; - print "#endif" - print " FILEOS 0x40004L"; - print " FILETYPE 0x1L"; - print " FILESUBTYPE 0x0L"; - print "BEGIN"; - print " BLOCK \"StringFileInfo\""; - print " BEGIN"; - print " BLOCK \"040904b0\""; - print " BEGIN"; - print " VALUE \"Comments\", "\ - "\"Licensed to the Apache Software Foundation (ASF) under one or more " \ - "contributor license agreements. See the NOTICE file distributed with " \ - "this work for additional information regarding copyright ownership. " \ - "The ASF licenses this file to You under the Apache License, Version 2.0 " \ - "(the \"\"License\"\"); you may not use this file except in compliance " \ - "with the License. You may obtain a copy of the License at\\r\\n\\r\\n" \ - "http://www.apache.org/licenses/LICENSE-2.0\\r\\n\\r\\n" \ - "Unless required by applicable law or agreed to in writing, software " \ - "distributed under the License is distributed on an \"\"AS IS\"\" BASIS, " \ - "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. " \ - "See the License for the specific language governing permissions and " \ - "limitations under the License.\\0\""; - print " VALUE \"CompanyName\", \"Apache Software Foundation\\0\""; - print " VALUE \"FileDescription\", \"" desc "\\0\""; - print " VALUE \"FileVersion\", \"" ver "\\0\""; - print " VALUE \"InternalName\", \"" file "\\0\""; - print " VALUE \"LegalCopyright\", \"Copyright " copyright "\\0\""; - print " VALUE \"OriginalFilename\", \"" filename "\\0\""; - if (vendor) { - print " VALUE \"PrivateBuild\", \"" vendor "\\0\""; - } - if (special) { - print " VALUE \"SpecialBuild\", \"" vendor "\\0\""; - } - print " VALUE \"ProductName\", \"Apache Portable Runtime\\0\""; - print " VALUE \"ProductVersion\", \"" ver "\\0\""; - print " END"; - print " END"; - print " BLOCK \"VarFileInfo\""; - print " BEGIN"; - print " VALUE \"Translation\", 0x409, 1200"; - print " END"; - print "END"; -} diff --git a/libs/apr/buildconf b/libs/apr/buildconf deleted file mode 100644 index b70fa53e..00000000 --- a/libs/apr/buildconf +++ /dev/null @@ -1,134 +0,0 @@ -#!/bin/sh -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# - -# buildconf: Build the support scripts needed to compile from a -# checked-out version of the source code. - -if [ "$1" = "--verbose" -o "$1" = "-v" ]; then - verbose="--verbose" - shift -fi - -# Verify that the builder has the right config tools installed -# -build/buildcheck.sh $verbose || exit 1 - -libtoolize=`build/PrintPath glibtoolize1 glibtoolize libtoolize15 libtoolize14 libtoolize` -if [ "x$libtoolize" = "x" ]; then - echo "libtoolize not found in path" - exit 1 -fi - -# Create the libtool helper files -# -# Note: we copy (rather than link) them to simplify distribution. -# Note: APR supplies its own config.guess and config.sub -- we do not -# rely on libtool's versions -# -echo "buildconf: copying libtool helper files using $libtoolize" - -# Remove any libtool files so one can switch between libtool versions -# by simply rerunning the buildconf script. -rm -f aclocal.m4 libtool.m4 -(cd build ; rm -f ltconfig ltmain.sh argz.m4 libtool.m4 ltoptions.m4 ltsugar.m4 ltversion.m4 lt~obsolete.m4) - -# Determine libtool version, because --copy behaves differently -# w.r.t. copying libtool.m4 -lt_pversion=`$libtoolize --version 2>/dev/null|sed -e 's/([^)]*)//g;s/^[^0-9]*//;s/[- ].*//g;q'` -lt_version=`echo $lt_pversion|sed -e 's/\([a-z]*\)$/.\1/'` -IFS=.; set $lt_version; IFS=' ' - -# libtool 1 -if test "$1" = "1"; then - $libtoolize --copy --automake - # Unlikely, maybe for old versions the file exists - if [ -f libtool.m4 ]; then - ltfile=`pwd`/libtool.m4 - else - - # Extract all lines setting variables from libtoolize up until - # libtool_m4 gets set - ltfindcmd="`sed -n \"/=[^\\\`]/p;/libtool_m4=/{s/.*=/echo /p;q;}\" \ - < $libtoolize`" - - # Get path to libtool.m4 either from LIBTOOL_M4 env var or our libtoolize based script - ltfile=${LIBTOOL_M4-`eval "$ltfindcmd"`} - - # Expecting the code above to be very portable, but just in case... - if [ -z "$ltfile" -o ! -f "$ltfile" ]; then - ltpath=`dirname $libtoolize` - ltfile=`cd $ltpath/../share/aclocal ; pwd`/libtool.m4 - fi - fi - if [ ! -f $ltfile ]; then - echo "$ltfile not found" - exit 1 - fi - # Do we need this anymore? - echo "buildconf: Using libtool.m4 at ${ltfile}." - rm -f build/libtool.m4 - cp -p $ltfile build/libtool.m4 - -# libtool 2 -elif test "$1" = "2"; then - $libtoolize --copy --quiet $verbose -fi - -# Replace top_builddir by apr_builddir. -# Wouldn't it just be better to define top_builddir?? -# Not sure, would it interfere with httpd top_builddir when bundled? -mv build/libtool.m4 build/libtool.m4.$$ -sed -e 's/\(LIBTOOL=.*\)top_build/\1apr_build/' < build/libtool.m4.$$ > build/libtool.m4 -rm -f build/libtool.m4.$$ - -# Clean up any leftovers -rm -f aclocal.m4 libtool.m4 - -# -# Generate the autoconf header and ./configure -# -echo "buildconf: creating include/arch/unix/apr_private.h.in ..." -${AUTOHEADER:-autoheader} $verbose - -echo "buildconf: creating configure ..." -### do some work to toss config.cache? -${AUTOCONF:-autoconf} $verbose - -# Remove autoconf 2.5x's cache directory -rm -rf autom4te*.cache - -echo "buildconf: generating 'make' outputs ..." -build/gen-build.py $verbose make - -# Create RPM Spec file -if [ -f `which cut` ]; then - echo "buildconf: rebuilding rpm spec file" - ( REVISION=`build/get-version.sh all include/apr_version.h APR` - VERSION=`echo $REVISION | cut -d- -s -f1` - RELEASE=`echo $REVISION | cut -d- -s -f2` - if [ "x$VERSION" = "x" ]; then - VERSION=$REVISION - RELEASE=1 - fi - cat ./build/rpm/apr.spec.in | \ - sed -e "s/APR_VERSION/$VERSION/" \ - -e "s/APR_RELEASE/$RELEASE/" \ - > apr.spec ) -fi - -exit 0 diff --git a/libs/apr/config.layout b/libs/apr/config.layout deleted file mode 100644 index 0f42e84e..00000000 --- a/libs/apr/config.layout +++ /dev/null @@ -1,231 +0,0 @@ -## -## config.layout -- Pre-defined Installation Path Layouts -## -## Hints: -## - layouts can be loaded with configure's --enable-layout=ID option -## - when no --enable-layout option is given, the default layout is `apr' -## - a trailing plus character (`+') on paths is replaced with a -## `/' suffix where is currently hardcoded to 'apr'. -## (This may become a configurable parameter at some point.) -## - -# Classical APR path layout designed for parallel installs. - - prefix: /usr/local/apr - exec_prefix: ${prefix} - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/bin - libdir: ${exec_prefix}/lib - libexecdir: ${exec_prefix}/modules - mandir: ${prefix}/man - sysconfdir: ${prefix}/conf - datadir: ${prefix} - installbuilddir: ${datadir}/build-${APR_MAJOR_VERSION} - includedir: ${prefix}/include/apr-${APR_MAJOR_VERSION} - localstatedir: ${prefix} - libsuffix: -${APR_MAJOR_VERSION} - - -# Classical single-installation APR path layout. - - prefix: /usr/local/apr - exec_prefix: ${prefix} - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/bin - libdir: ${exec_prefix}/lib - libexecdir: ${exec_prefix}/modules - mandir: ${prefix}/man - sysconfdir: ${prefix}/conf - datadir: ${prefix} - installbuilddir: ${datadir}/build - includedir: ${prefix}/include - localstatedir: ${prefix} - - -# GNU standards conforming path layout. -# See FSF's GNU project `make-stds' document for details. - - prefix: /usr/local - exec_prefix: ${prefix} - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/sbin - libdir: ${exec_prefix}/lib - libexecdir: ${exec_prefix}/libexec - mandir: ${prefix}/man - sysconfdir: ${prefix}/etc+ - datadir: ${prefix}/share+ - installbuilddir: ${datadir}/build - includedir: ${prefix}/include+ - localstatedir: ${prefix}/var+ - runtimedir: ${localstatedir}/run - - -# Mac OS X Server (Rhapsody) - - prefix: /Local/Library/WebServer - exec_prefix: /usr - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/sbin - libdir: ${exec_prefix}/lib - libexecdir: /System/Library/apr/Modules - mandir: ${exec_prefix}/share/man - sysconfdir: ${prefix}/Configuration - datadir: ${prefix} - installbuilddir: /System/Library/apr/Build - includedir: /System/Library/Frameworks/apr.framework/Versions/2.0/Headers - localstatedir: /var - runtimedir: ${prefix}/Logs - - -# Darwin/Mac OS Layout - - prefix: /usr - exec_prefix: ${prefix} - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/sbin - libdir: ${exec_prefix}/lib - libexecdir: ${exec_prefix}/libexec+ - mandir: ${prefix}/share/man - datadir: /Library/WebServer - sysconfdir: /etc+ - installbuilddir: ${prefix}/share/httpd/build - includedir: ${prefix}/include+ - localstatedir: /var - runtimedir: ${localstatedir}/run - - -# Red Hat Linux 7.x layout - - prefix: /usr - exec_prefix: ${prefix} - bindir: ${prefix}/bin - sbindir: ${prefix}/sbin - libdir: ${prefix}/lib - libexecdir: ${prefix}/lib/apr - mandir: ${prefix}/man - sysconfdir: /etc/httpd/conf - datadir: /var/www - installbuilddir: ${datadir}/build - includedir: ${prefix}/include/apr - localstatedir: /var - runtimedir: ${localstatedir}/run - - -# According to the /opt filesystem conventions - - prefix: /opt/apr - exec_prefix: ${prefix} - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/sbin - libdir: ${exec_prefix}/lib - libexecdir: ${exec_prefix}/libexec - mandir: ${prefix}/man - sysconfdir: /etc${prefix} - datadir: ${prefix}/share - installbuilddir: ${datadir}/build - includedir: ${prefix}/include - localstatedir: /var${prefix} - runtimedir: ${localstatedir}/run - - -# BeOS layout... - - prefix: /boot/home/apr - exec_prefix: ${prefix} - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/bin - libdir: ${exec_prefix}/lib - libexecdir: ${exec_prefix}/libexec - mandir: ${prefix}/man - sysconfdir: ${prefix}/conf - datadir: ${prefix} - installbuilddir: ${datadir}/build - includedir: ${prefix}/include - localstatedir: ${prefix} - runtimedir: ${localstatedir}/logs - - -# SuSE 6.x layout - - prefix: /usr - exec_prefix: ${prefix} - bindir: ${prefix}/bin - sbindir: ${prefix}/sbin - libdir: ${prefix}/lib - libexecdir: ${prefix}/lib/apr - mandir: ${prefix}/share/man - sysconfdir: /etc/httpd - datadir: /usr/local/httpd - installbuilddir: ${datadir}/build - includedir: ${prefix}/include/apr - localstatedir: /var/lib/httpd - runtimedir: /var/run - - -# BSD/OS layout - - prefix: /var/www - exec_prefix: /usr/contrib - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/bin - libdir: ${exec_prefix}/lib - libexecdir: ${exec_prefix}/libexec/apr - mandir: ${exec_prefix}/man - sysconfdir: ${prefix}/conf - datadir: ${prefix} - installbuilddir: ${datadir}/build - includedir: ${exec_prefix}/include/apr - localstatedir: /var - runtimedir: ${localstatedir}/run - - -# Solaris 8 Layout - - prefix: /usr/apr - exec_prefix: ${prefix} - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/bin - libdir: ${exec_prefix}/lib - libexecdir: ${exec_prefix}/libexec - mandir: ${exec_prefix}/man - sysconfdir: /etc/apr - datadir: /var/apr - installbuilddir: ${datadir}/build - includedir: ${exec_prefix}/include - localstatedir: ${prefix} - runtimedir: /var/run - - -# OpenBSD Layout - - prefix: /var/www - exec_prefix: /usr - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/sbin - libdir: ${exec_prefix}/lib - libexecdir: ${exec_prefix}/lib/apr/modules - mandir: ${exec_prefix}/share/man - sysconfdir: ${prefix}/conf - datadir: ${prefix} - installbuilddir: ${prefix}/build - includedir: ${exec_prefix}/lib/apr/include - localstatedir: ${prefix} - runtimedir: ${prefix}/logs - - -# Debian layout - - prefix: - exec_prefix: ${prefix}/usr - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/sbin - libdir: ${exec_prefix}/lib - libexecdir: ${exec_prefix}/lib/apr/modules - mandir: ${exec_prefix}/share/man - datadir: ${exec_prefix}/share/apr - includedir: ${exec_prefix}/include/apr-${APR_MAJOR_VERSION} - localstatedir: ${prefix}/var/run - runtimedir: ${prefix}/var/run - infodir: ${exec_prefix}/share/info - libsuffix: -${APR_MAJOR_VERSION} - diff --git a/libs/apr/configure b/libs/apr/configure deleted file mode 100644 index cee0f0e6..00000000 --- a/libs/apr/configure +++ /dev/null @@ -1,30720 +0,0 @@ -#! /bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68. -# -# -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software -# Foundation, Inc. -# -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -as_myself= -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -if test "x$CONFIG_SHELL" = x; then - as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which - # is contrary to our usage. Disable this feature. - alias -g '\${1+\"\$@\"}'='\"\$@\"' - setopt NO_GLOB_SUBST -else - case \`(set -o) 2>/dev/null\` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi -" - as_required="as_fn_return () { (exit \$1); } -as_fn_success () { as_fn_return 0; } -as_fn_failure () { as_fn_return 1; } -as_fn_ret_success () { return 0; } -as_fn_ret_failure () { return 1; } - -exitcode=0 -as_fn_success || { exitcode=1; echo as_fn_success failed.; } -as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } -as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } -as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } -if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : - -else - exitcode=1; echo positional parameters were not saved. -fi -test x\$exitcode = x0 || exit 1" - as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO - as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO - eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && - test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 -test \$(( 1 + 1 )) = 2 || exit 1 - - test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( - ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' - ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO - ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO - PATH=/empty FPATH=/empty; export PATH FPATH - test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ - || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1" - if (eval "$as_required") 2>/dev/null; then : - as_have_required=yes -else - as_have_required=no -fi - if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : - -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -as_found=false -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - as_found=: - case $as_dir in #( - /*) - for as_base in sh bash ksh sh5; do - # Try only shells that exist, to save several forks. - as_shell=$as_dir/$as_base - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : - CONFIG_SHELL=$as_shell as_have_required=yes - if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : - break 2 -fi -fi - done;; - esac - as_found=false -done -$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : - CONFIG_SHELL=$SHELL as_have_required=yes -fi; } -IFS=$as_save_IFS - - - if test "x$CONFIG_SHELL" != x; then : - # We cannot yet assume a decent shell, so we have to provide a - # neutralization value for shells without unset; and this also - # works around shells that cannot unset nonexistent variables. - # Preserve -v and -x to the replacement shell. - BASH_ENV=/dev/null - ENV=/dev/null - (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV - export CONFIG_SHELL - case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; - esac - exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} -fi - - if test x$as_have_required = xno; then : - $as_echo "$0: This script requires a shell more modern than all" - $as_echo "$0: the shells that I found on your system." - if test x${ZSH_VERSION+set} = xset ; then - $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" - $as_echo "$0: be upgraded to zsh 4.3.4 or later." - else - $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, -$0: including any error possibly output before this -$0: message. Then install a modern shell, or manually run -$0: the script under such a shell if you do have one." - fi - exit 1 -fi -fi -fi -SHELL=${CONFIG_SHELL-/bin/sh} -export SHELL -# Unset more variables known to interfere with behavior of common tools. -CLICOLOR_FORCE= GREP_OPTIONS= -unset CLICOLOR_FORCE GREP_OPTIONS - -## --------------------- ## -## M4sh Shell Functions. ## -## --------------------- ## -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - - - as_lineno_1=$LINENO as_lineno_1a=$LINENO - as_lineno_2=$LINENO as_lineno_2a=$LINENO - eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && - test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { - # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -p' - fi -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - -SHELL=${CONFIG_SHELL-/bin/sh} - - -test -n "$DJDIR" || exec 7<&0 &1 - -# Name of the host. -# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, -# so uname gets run too. -ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` - -# -# Initializations. -# -ac_default_prefix=/usr/local -ac_clean_files= -ac_config_libobj_dir=. -LIBOBJS= -cross_compiling=no -subdirs= -MFLAGS= -MAKEFLAGS= - -# Identity of this package. -PACKAGE_NAME= -PACKAGE_TARNAME= -PACKAGE_VERSION= -PACKAGE_STRING= -PACKAGE_BUGREPORT= -PACKAGE_URL= - -ac_unique_file="build/apr_common.m4" -# Factoring default headers for most tests. -ac_includes_default="\ -#include -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_STAT_H -# include -#endif -#ifdef STDC_HEADERS -# include -# include -#else -# ifdef HAVE_STDLIB_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# if !defined STDC_HEADERS && defined HAVE_MEMORY_H -# include -# endif -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif -#ifdef HAVE_INTTYPES_H -# include -#endif -#ifdef HAVE_STDINT_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif" - -ac_subst_vars='LTLIBOBJS -LIBOBJS -INCLUDE_OUTPUTS -INCLUDE_RULES -LT_NO_INSTALL -LIBTOOL_LIBS -DEFAULT_OSDIR -OSDIR -INCLUDES -LDLIBS -NOTEST_INCLUDES -NOTEST_LIBS -NOTEST_LDFLAGS -NOTEST_CFLAGS -NOTEST_CPPFLAGS -EXTRA_INCLUDES -EXTRA_LIBS -EXTRA_LDFLAGS -EXTRA_CFLAGS -EXTRA_CPPFLAGS -apr_has_user -apr_thread_func -apr_procattr_user_set_requires_password -apr_has_xthread_files -have_unicode_fs -have_ipv6 -have_sa_storage -have_sctp -acceptfilter -have_corkable_tcp -apr_tcp_nopush_flag -file_as_socket -have_in_addr -osuuid -rand -proclockglobal -pthreadser -procpthreadser -fcntlser -posixser -sysvser -flockser -hasprocpthreadser -hasfcntlser -hasposixser -hassysvser -hasflockser -have_union_semun -struct_rlimit -have_proc_invoked -oc -aprdso -have_memchr -have_strstr -have_strdup -have_strcasecmp -have_stricmp -have_strncasecmp -have_strnicmp -ino_t_value -have_iovec -aprlfs -bigendian -stdint -uint64_literal -int64_literal -pid_t_fmt -off_t_fmt -size_t_fmt -ssize_t_fmt -uint64_t_hex_fmt -uint64_t_fmt -int64_t_fmt -socklen_t_value -ssize_t_value -size_t_value -off_t_value -int64_value -long_value -int_value -short_value -voidp_size -winsock2h -windowsh -semaphoreh -pthreadh -processh -sys_waith -signalh -unistdh -timeh -sys_unh -sys_uioh -sys_timeh -sys_typesh -sys_sockioh -sys_socketh -sys_signalh -sys_sendfileh -sys_ioctlh -stringsh -stringh -stdlibh -stdioh -stdargh -netinet_tcph -netinet_sctp_uioh -netinet_sctph -netinet_inh -sys_syslimitsh -netdbh -limitsh -ioh -fcntlh -direnth -errnoh -crypth -ctypeh -conioh -arpa_ineth -have_memmove -mmap -have_getrlimit -have_setrlimit -have_sigaction -have_inet_network -o_nonblock_inherited -tcp_nodelay_inherited -have_inet_addr -fork -apr_inaddr_none -sendfile -ALLOCA -sharedmem -havewin32shm -haveos2shm -havebeosarea -haveshmget -havemmapshm -havemmaptmp -usewin32shm -useos2shm -usebeosarea -useshmget -usemmapshm -usemmaptmp -havemmapanon -havemmapzero -haveshmgetanon -usemmapanon -usemmapzero -useshmgetanon -have_sigwait -have_sigsuspend -threads -INSTALL_SUBDIRS -eolstr -proc_mutex_is_global -OBJECTS_PLATFORM -MKDEP -LT_VERSION -LT_LDFLAGS -LTFLAGS -shlibpath_var -export_lib_target -lib_target -so_ext -link -lt_compile -installbuilddir -OTOOL64 -OTOOL -LIPO -NMEDIT -DSYMUTIL -MANIFEST_TOOL -STRIP -ac_ct_AR -NM -ac_ct_DUMPBIN -DUMPBIN -LD -FGREP -LIBTOOL -OBJDUMP -DLLTOOL -APR_LIBNAME -apr_charset_ebcdic -EGREP -GREP -AR -ASCPP -AS -RM -INSTALL_DATA -INSTALL_SCRIPT -INSTALL_PROGRAM -RANLIB -LN_S -AWK -CPP -SET_MAKE -SED -OBJEXT -EXEEXT -ac_ct_CC -CPPFLAGS -LDFLAGS -CFLAGS -CC -APR_MAJOR_VERSION -APR_DOTTED_VERSION -apr_builders -top_builddir -APR_CONFIG_LOCATION -apr_builddir -apr_srcdir -target_os -target_vendor -target_cpu -target -host_os -host_vendor -host_cpu -host -build_os -build_vendor -build_cpu -build -target_alias -host_alias -build_alias -LIBS -ECHO_T -ECHO_N -ECHO_C -DEFS -mandir -localedir -libdir -psdir -pdfdir -dvidir -htmldir -infodir -docdir -oldincludedir -includedir -localstatedir -sharedstatedir -sysconfdir -datadir -datarootdir -libexecdir -sbindir -bindir -program_transform_name -prefix -exec_prefix -PACKAGE_URL -PACKAGE_BUGREPORT -PACKAGE_STRING -PACKAGE_VERSION -PACKAGE_TARNAME -PACKAGE_NAME -PATH_SEPARATOR -SHELL' -ac_subst_files='' -ac_user_opts=' -enable_option_checking -enable_layout -enable_experimental_libtool -enable_shared -enable_static -with_pic -enable_fast_install -with_gnu_ld -with_sysroot -enable_libtool_lock -with_installbuilddir -with_libtool -enable_debug -enable_maintainer_mode -enable_profile -enable_pool_debug -enable_malloc_debug -enable_lfs -enable_nonportable_atomics -enable_threads -with_efence -with_sendfile -enable_allocator_uses_mmap -enable_dso -enable_other_child -with_egd -with_devrandom -enable_ipv6 -' - ac_precious_vars='build_alias -host_alias -target_alias -CC -CFLAGS -LDFLAGS -LIBS -CPPFLAGS -CPP' - - -# Initialize some variables set by options. -ac_init_help= -ac_init_version=false -ac_unrecognized_opts= -ac_unrecognized_sep= -# The variables have the same names as the options, with -# dashes changed to underlines. -cache_file=/dev/null -exec_prefix=NONE -no_create= -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -verbose= -x_includes=NONE -x_libraries=NONE - -# Installation directory options. -# These are left unexpanded so users can "make install exec_prefix=/foo" -# and all the variables that are supposed to be based on exec_prefix -# by default will actually change. -# Use braces instead of parens because sh, perl, etc. also accept them. -# (The list follows the same order as the GNU Coding Standards.) -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datarootdir='${prefix}/share' -datadir='${datarootdir}' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -includedir='${prefix}/include' -oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE}' -infodir='${datarootdir}/info' -htmldir='${docdir}' -dvidir='${docdir}' -pdfdir='${docdir}' -psdir='${docdir}' -libdir='${exec_prefix}/lib' -localedir='${datarootdir}/locale' -mandir='${datarootdir}/man' - -ac_prev= -ac_dashdash= -for ac_option -do - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval $ac_prev=\$ac_option - ac_prev= - continue - fi - - case $ac_option in - *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *=) ac_optarg= ;; - *) ac_optarg=yes ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case $ac_dashdash$ac_option in - --) - ac_dashdash=yes ;; - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir=$ac_optarg ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build_alias ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build_alias=$ac_optarg ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file=$ac_optarg ;; - - --config-cache | -C) - cache_file=config.cache ;; - - -datadir | --datadir | --datadi | --datad) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=*) - datadir=$ac_optarg ;; - - -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ - | --dataroo | --dataro | --datar) - ac_prev=datarootdir ;; - -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ - | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) - datarootdir=$ac_optarg ;; - - -disable-* | --disable-*) - ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=no ;; - - -docdir | --docdir | --docdi | --doc | --do) - ac_prev=docdir ;; - -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) - docdir=$ac_optarg ;; - - -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) - ac_prev=dvidir ;; - -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) - dvidir=$ac_optarg ;; - - -enable-* | --enable-*) - ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=\$ac_optarg ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix=$ac_optarg ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he | -h) - ac_init_help=long ;; - -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) - ac_init_help=recursive ;; - -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) - ac_init_help=short ;; - - -host | --host | --hos | --ho) - ac_prev=host_alias ;; - -host=* | --host=* | --hos=* | --ho=*) - host_alias=$ac_optarg ;; - - -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) - ac_prev=htmldir ;; - -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ - | --ht=*) - htmldir=$ac_optarg ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir=$ac_optarg ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir=$ac_optarg ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir=$ac_optarg ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir=$ac_optarg ;; - - -localedir | --localedir | --localedi | --localed | --locale) - ac_prev=localedir ;; - -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) - localedir=$ac_optarg ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst | --locals) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) - localstatedir=$ac_optarg ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir=$ac_optarg ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c | -n) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir=$ac_optarg ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=$ac_optarg ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix=$ac_optarg ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix=$ac_optarg ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name=$ac_optarg ;; - - -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) - ac_prev=pdfdir ;; - -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) - pdfdir=$ac_optarg ;; - - -psdir | --psdir | --psdi | --psd | --ps) - ac_prev=psdir ;; - -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) - psdir=$ac_optarg ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir=$ac_optarg ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir=$ac_optarg ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site=$ac_optarg ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir=$ac_optarg ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir=$ac_optarg ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target_alias ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target_alias=$ac_optarg ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers | -V) - ac_init_version=: ;; - - -with-* | --with-*) - ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=\$ac_optarg ;; - - -without-* | --without-*) - ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=no ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes=$ac_optarg ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries=$ac_optarg ;; - - -*) as_fn_error $? "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information" - ;; - - *=*) - ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` - # Reject names that are not valid shell variable names. - case $ac_envvar in #( - '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; - esac - eval $ac_envvar=\$ac_optarg - export $ac_envvar ;; - - *) - # FIXME: should be removed in autoconf 3.0. - $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 - expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" - ;; - - esac -done - -if test -n "$ac_prev"; then - ac_option=--`echo $ac_prev | sed 's/_/-/g'` - as_fn_error $? "missing argument to $ac_option" -fi - -if test -n "$ac_unrecognized_opts"; then - case $enable_option_checking in - no) ;; - fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; - *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; - esac -fi - -# Check all directory arguments for consistency. -for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ - datadir sysconfdir sharedstatedir localstatedir includedir \ - oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir -do - eval ac_val=\$$ac_var - # Remove trailing slashes. - case $ac_val in - */ ) - ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` - eval $ac_var=\$ac_val;; - esac - # Be sure to have absolute directory names. - case $ac_val in - [\\/$]* | ?:[\\/]* ) continue;; - NONE | '' ) case $ac_var in *prefix ) continue;; esac;; - esac - as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" -done - -# There might be people who depend on the old broken behavior: `$host' -# used to hold the argument of --host etc. -# FIXME: To remove some day. -build=$build_alias -host=$host_alias -target=$target_alias - -# FIXME: To remove some day. -if test "x$host_alias" != x; then - if test "x$build_alias" = x; then - cross_compiling=maybe - $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used" >&2 - elif test "x$build_alias" != "x$host_alias"; then - cross_compiling=yes - fi -fi - -ac_tool_prefix= -test -n "$host_alias" && ac_tool_prefix=$host_alias- - -test "$silent" = yes && exec 6>/dev/null - - -ac_pwd=`pwd` && test -n "$ac_pwd" && -ac_ls_di=`ls -di .` && -ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - as_fn_error $? "working directory cannot be determined" -test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - as_fn_error $? "pwd does not report name of working directory" - - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then the parent directory. - ac_confdir=`$as_dirname -- "$as_myself" || -$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_myself" : 'X\(//\)[^/]' \| \ - X"$as_myself" : 'X\(//\)$' \| \ - X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_myself" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - srcdir=$ac_confdir - if test ! -r "$srcdir/$ac_unique_file"; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r "$srcdir/$ac_unique_file"; then - test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" -fi -ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" -ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" - pwd)` -# When building in place, set srcdir=. -if test "$ac_abs_confdir" = "$ac_pwd"; then - srcdir=. -fi -# Remove unnecessary trailing slashes from srcdir. -# Double slashes in file names in object file debugging info -# mess up M-x gdb in Emacs. -case $srcdir in -*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; -esac -for ac_var in $ac_precious_vars; do - eval ac_env_${ac_var}_set=\${${ac_var}+set} - eval ac_env_${ac_var}_value=\$${ac_var} - eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} - eval ac_cv_env_${ac_var}_value=\$${ac_var} -done - -# -# Report the --help message. -# -if test "$ac_init_help" = "long"; then - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat <<_ACEOF -\`configure' configures this package to adapt to many kinds of systems. - -Usage: $0 [OPTION]... [VAR=VALUE]... - -To assign environment variables (e.g., CC, CFLAGS...), specify them as -VAR=VALUE. See below for descriptions of some of the useful variables. - -Defaults for the options are specified in brackets. - -Configuration: - -h, --help display this help and exit - --help=short display options specific to this package - --help=recursive display the short help of all the included packages - -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking ...' messages - --cache-file=FILE cache test results in FILE [disabled] - -C, --config-cache alias for \`--cache-file=config.cache' - -n, --no-create do not create output files - --srcdir=DIR find the sources in DIR [configure dir or \`..'] - -Installation directories: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] - -By default, \`make install' will install all the files in -\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify -an installation prefix other than \`$ac_default_prefix' using \`--prefix', -for instance \`--prefix=\$HOME'. - -For better control, use the options below. - -Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] - --datadir=DIR read-only architecture-independent data [DATAROOTDIR] - --infodir=DIR info documentation [DATAROOTDIR/info] - --localedir=DIR locale-dependent data [DATAROOTDIR/locale] - --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] - --htmldir=DIR html documentation [DOCDIR] - --dvidir=DIR dvi documentation [DOCDIR] - --pdfdir=DIR pdf documentation [DOCDIR] - --psdir=DIR ps documentation [DOCDIR] -_ACEOF - - cat <<\_ACEOF - -System types: - --build=BUILD configure for building on BUILD [guessed] - --host=HOST cross-compile to build programs to run on HOST [BUILD] - --target=TARGET configure for building compilers for TARGET [HOST] -_ACEOF -fi - -if test -n "$ac_init_help"; then - - cat <<\_ACEOF - -Optional Features: - --disable-option-checking ignore unrecognized --enable/--with options - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --enable-layout=LAYOUT - --enable-experimental-libtool Use experimental custom libtool - --enable-shared[=PKGS] build shared libraries [default=yes] - --enable-static[=PKGS] build static libraries [default=yes] - --enable-fast-install[=PKGS] - optimize for fast installation [default=yes] - --disable-libtool-lock avoid locking (might break parallel builds) - --enable-debug Turn on debugging and compile time warnings - --enable-maintainer-mode Turn on debugging and compile time warnings - --enable-profile Turn on profiling for the build (GCC) - --enable-pool-debug[=yes|no|verbose|verbose-alloc|lifetime|owner|all] Turn on pools debugging - --enable-malloc-debug Switch on malloc_debug for BeOS - --disable-lfs Disable large file support on 32-bit platforms - --enable-nonportable-atomics Use optimized atomic code which may produce nonportable binaries - --enable-threads Enable threading support in APR. - --enable-allocator-uses-mmap Use mmap in apr_allocator instead of malloc (experimental) - --disable-dso Disable DSO support - --enable-other-child Enable reliable child processes - --disable-ipv6 Disable IPv6 support in APR. - -Optional Packages: - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use - both] - --with-gnu-ld assume the C compiler uses GNU ld [default=no] - --with-sysroot=DIR Search for dependent libraries within DIR - (or the compiler's sysroot if not specified). - --with-installbuilddir=DIR location to store APR build files (defaults to '${datadir}/build') - --without-libtool avoid using libtool to link the library - --with-efence[=DIR] path to Electric Fence installation - --with-sendfile Override decision to use sendfile - --with-egd[=DIR] use EGD-compatible socket - --with-devrandom[=DEV] use /dev/random or compatible [searches by default] - -Some influential environment variables: - CC C compiler command - CFLAGS C compiler flags - LDFLAGS linker flags, e.g. -L if you have libraries in a - nonstandard directory - LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if - you have headers in a nonstandard directory - CPP C preprocessor - -Use these variables to override the choices made by `configure' or to help -it to find libraries and programs with nonstandard names/locations. - -Report bugs to the package provider. -_ACEOF -ac_status=$? -fi - -if test "$ac_init_help" = "recursive"; then - # If there are subdirs, report their specific --help. - for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d "$ac_dir" || - { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || - continue - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - cd "$ac_dir" || { ac_status=$?; continue; } - # Check for guested configure. - if test -f "$ac_srcdir/configure.gnu"; then - echo && - $SHELL "$ac_srcdir/configure.gnu" --help=recursive - elif test -f "$ac_srcdir/configure"; then - echo && - $SHELL "$ac_srcdir/configure" --help=recursive - else - $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi || ac_status=$? - cd "$ac_pwd" || { ac_status=$?; break; } - done -fi - -test -n "$ac_init_help" && exit $ac_status -if $ac_init_version; then - cat <<\_ACEOF -configure -generated by GNU Autoconf 2.68 - -Copyright (C) 2010 Free Software Foundation, Inc. -This configure script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it. -_ACEOF - exit -fi - -## ------------------------ ## -## Autoconf initialization. ## -## ------------------------ ## - -# ac_fn_c_try_compile LINENO -# -------------------------- -# Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext - if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_compile - -# ac_fn_c_try_cpp LINENO -# ---------------------- -# Try to preprocess conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_cpp () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_cpp - -# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists, giving a warning if it cannot be compiled using -# the include files in INCLUDES and setting the cache variable VAR -# accordingly. -ac_fn_c_check_header_mongrel () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if eval \${$3+:} false; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 -$as_echo_n "checking $2 usability... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_header_compiler=yes -else - ac_header_compiler=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 -$as_echo_n "checking $2 presence... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <$2> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - ac_header_preproc=yes -else - ac_header_preproc=no -fi -rm -f conftest.err conftest.i conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( - yes:no: ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} - ;; - no:yes:* ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} - ;; -esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=\$ac_header_compiler" -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_header_mongrel - -# ac_fn_c_try_run LINENO -# ---------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes -# that executables *can* be run. -ac_fn_c_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then : - ac_retval=0 -else - $as_echo "$as_me: program exited with status $ac_status" >&5 - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_run - -# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists and can be compiled using the include files in -# INCLUDES, setting the cache variable VAR accordingly. -ac_fn_c_check_header_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_header_compile - -# ac_fn_c_try_link LINENO -# ----------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_link () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest$ac_exeext - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information - # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would - # interfere with the next link command; also delete a directory that is - # left behind by Apple's compiler. We do this before executing the actions. - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_link - -# ac_fn_c_check_func LINENO FUNC VAR -# ---------------------------------- -# Tests whether FUNC exists, setting the cache variable VAR accordingly -ac_fn_c_check_func () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -/* Define $2 to an innocuous variant, in case declares $2. - For example, HP-UX 11i declares gettimeofday. */ -#define $2 innocuous_$2 - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $2 (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $2 - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $2 (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$2 || defined __stub___$2 -choke me -#endif - -int -main () -{ -return $2 (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_func - -# ac_fn_c_check_type LINENO TYPE VAR INCLUDES -# ------------------------------------------- -# Tests whether TYPE exists after having included INCLUDES, setting cache -# variable VAR accordingly. -ac_fn_c_check_type () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=no" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -if (sizeof ($2)) - return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -if (sizeof (($2))) - return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - eval "$3=yes" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_type - -# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES -# -------------------------------------------- -# Tries to find the compile-time value of EXPR in a program that includes -# INCLUDES, setting VAR accordingly. Returns whether the value could be -# computed -ac_fn_c_compute_int () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if test "$cross_compiling" = yes; then - # Depending upon the size, compute the lo and hi bounds. -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) >= 0)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_lo=0 ac_mid=0 - while :; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_hi=$ac_mid; break -else - as_fn_arith $ac_mid + 1 && ac_lo=$as_val - if test $ac_lo -le $ac_mid; then - ac_lo= ac_hi= - break - fi - as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) < 0)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_hi=-1 ac_mid=-1 - while :; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) >= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_lo=$ac_mid; break -else - as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val - if test $ac_mid -le $ac_hi; then - ac_lo= ac_hi= - break - fi - as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - ac_lo= ac_hi= -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -# Binary search between lo and hi bounds. -while test "x$ac_lo" != "x$ac_hi"; do - as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_hi=$ac_mid -else - as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -done -case $ac_lo in #(( -?*) eval "$3=\$ac_lo"; ac_retval=0 ;; -'') ac_retval=1 ;; -esac - else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -static long int longval () { return $2; } -static unsigned long int ulongval () { return $2; } -#include -#include -int -main () -{ - - FILE *f = fopen ("conftest.val", "w"); - if (! f) - return 1; - if (($2) < 0) - { - long int i = longval (); - if (i != ($2)) - return 1; - fprintf (f, "%ld", i); - } - else - { - unsigned long int i = ulongval (); - if (i != ($2)) - return 1; - fprintf (f, "%lu", i); - } - /* Do not output a trailing newline, as this causes \r\n confusion - on some platforms. */ - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - echo >>conftest.val; read $3 &5 -$as_echo_n "checking whether $as_decl_name is declared... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -#ifndef $as_decl_name -#ifdef __cplusplus - (void) $as_decl_use; -#else - (void) $as_decl_name; -#endif -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_decl - -# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES -# ---------------------------------------------------- -# Tries to find if the field MEMBER exists in type AGGR, after including -# INCLUDES, setting cache variable VAR accordingly. -ac_fn_c_check_member () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 -$as_echo_n "checking for $2.$3... " >&6; } -if eval \${$4+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$5 -int -main () -{ -static $2 ac_aggr; -if (ac_aggr.$3) -return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$4=yes" -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$5 -int -main () -{ -static $2 ac_aggr; -if (sizeof ac_aggr.$3) -return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$4=yes" -else - eval "$4=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$4 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_member -cat >config.log <<_ACEOF -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by $as_me, which was -generated by GNU Autoconf 2.68. Invocation command line was - - $ $0 $@ - -_ACEOF -exec 5>>config.log -{ -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` - -/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` -/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` -/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` - -_ASUNAME - -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - $as_echo "PATH: $as_dir" - done -IFS=$as_save_IFS - -} >&5 - -cat >&5 <<_ACEOF - - -## ----------- ## -## Core tests. ## -## ----------- ## - -_ACEOF - - -# Keep a trace of the command line. -# Strip out --no-create and --no-recursion so they do not pile up. -# Strip out --silent because we don't want to record it for future runs. -# Also quote any args containing shell meta-characters. -# Make two passes to allow for proper duplicate-argument suppression. -ac_configure_args= -ac_configure_args0= -ac_configure_args1= -ac_must_keep_next=false -for ac_pass in 1 2 -do - for ac_arg - do - case $ac_arg in - -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - continue ;; - *\'*) - ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - case $ac_pass in - 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; - 2) - as_fn_append ac_configure_args1 " '$ac_arg'" - if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. - else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac - fi - as_fn_append ac_configure_args " '$ac_arg'" - ;; - esac - done -done -{ ac_configure_args0=; unset ac_configure_args0;} -{ ac_configure_args1=; unset ac_configure_args1;} - -# When interrupted or exit'd, cleanup temporary files, and complete -# config.log. We remove comments because anyway the quotes in there -# would cause problems or look ugly. -# WARNING: Use '\'' to represent an apostrophe within the trap. -# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. -trap 'exit_status=$? - # Save into config.log some information that might help in debugging. - { - echo - - $as_echo "## ---------------- ## -## Cache variables. ## -## ---------------- ##" - echo - # The following way of writing the cache mishandles newlines in values, -( - for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - (set) 2>&1 | - case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - sed -n \ - "s/'\''/'\''\\\\'\'''\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" - ;; #( - *) - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) - echo - - $as_echo "## ----------------- ## -## Output variables. ## -## ----------------- ##" - echo - for ac_var in $ac_subst_vars - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - - if test -n "$ac_subst_files"; then - $as_echo "## ------------------- ## -## File substitutions. ## -## ------------------- ##" - echo - for ac_var in $ac_subst_files - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - fi - - if test -s confdefs.h; then - $as_echo "## ----------- ## -## confdefs.h. ## -## ----------- ##" - echo - cat confdefs.h - echo - fi - test "$ac_signal" != 0 && - $as_echo "$as_me: caught signal $ac_signal" - $as_echo "$as_me: exit $exit_status" - } >&5 - rm -f core *.core core.conftest.* && - rm -f -r conftest* confdefs* conf$$* $ac_clean_files && - exit $exit_status -' 0 -for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal -done -ac_signal=0 - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -f -r conftest* confdefs.h - -$as_echo "/* confdefs.h */" > confdefs.h - -# Predefined preprocessor variables. - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_NAME "$PACKAGE_NAME" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_TARNAME "$PACKAGE_TARNAME" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_VERSION "$PACKAGE_VERSION" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_STRING "$PACKAGE_STRING" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_URL "$PACKAGE_URL" -_ACEOF - - -# Let the site file select an alternate cache file if it wants to. -# Prefer an explicitly selected file to automatically selected ones. -ac_site_file1=NONE -ac_site_file2=NONE -if test -n "$CONFIG_SITE"; then - # We do not want a PATH search for config.site. - case $CONFIG_SITE in #(( - -*) ac_site_file1=./$CONFIG_SITE;; - */*) ac_site_file1=$CONFIG_SITE;; - *) ac_site_file1=./$CONFIG_SITE;; - esac -elif test "x$prefix" != xNONE; then - ac_site_file1=$prefix/share/config.site - ac_site_file2=$prefix/etc/config.site -else - ac_site_file1=$ac_default_prefix/share/config.site - ac_site_file2=$ac_default_prefix/etc/config.site -fi -for ac_site_file in "$ac_site_file1" "$ac_site_file2" -do - test "x$ac_site_file" = xNONE && continue - if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 -$as_echo "$as_me: loading site script $ac_site_file" >&6;} - sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" \ - || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "failed to load site script $ac_site_file -See \`config.log' for more details" "$LINENO" 5; } - fi -done - -if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special files - # actually), so we avoid doing that. DJGPP emulates it as a regular file. - if test /dev/null != "$cache_file" && test -f "$cache_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 -$as_echo "$as_me: loading cache $cache_file" >&6;} - case $cache_file in - [\\/]* | ?:[\\/]* ) . "$cache_file";; - *) . "./$cache_file";; - esac - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 -$as_echo "$as_me: creating cache $cache_file" >&6;} - >$cache_file -fi - -# Check that the precious variables saved in the cache have kept the same -# value. -ac_cache_corrupted=false -for ac_var in $ac_precious_vars; do - eval ac_old_set=\$ac_cv_env_${ac_var}_set - eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val=\$ac_cv_env_${ac_var}_value - eval ac_new_val=\$ac_env_${ac_var}_value - case $ac_old_set,$ac_new_set in - set,) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,set) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,);; - *) - if test "x$ac_old_val" != "x$ac_new_val"; then - # differences in whitespace do not lead to failure. - ac_old_val_w=`echo x $ac_old_val` - ac_new_val_w=`echo x $ac_new_val` - if test "$ac_old_val_w" != "$ac_new_val_w"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 -$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - ac_cache_corrupted=: - else - { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 -$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} - eval $ac_var=\$ac_old_val - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 -$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 -$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} - fi;; - esac - # Pass precious variables to config.status. - if test "$ac_new_set" = set; then - case $ac_new_val in - *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; - *) ac_arg=$ac_var=$ac_new_val ;; - esac - case " $ac_configure_args " in - *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) as_fn_append ac_configure_args " '$ac_arg'" ;; - esac - fi -done -if $ac_cache_corrupted; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 -$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 -fi -## -------------------- ## -## Main body of script. ## -## -------------------- ## - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -ac_config_headers="$ac_config_headers include/arch/unix/apr_private.h" - -ac_aux_dir= -for ac_dir in build "$srcdir"/build; do - if test -f "$ac_dir/install-sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f "$ac_dir/install.sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - elif test -f "$ac_dir/shtool"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/shtool install -c" - break - fi -done -if test -z "$ac_aux_dir"; then - as_fn_error $? "cannot find install-sh, install.sh, or shtool in build \"$srcdir\"/build" "$LINENO" 5 -fi - -# These three variables are undocumented and unsupported, -# and are intended to be withdrawn in a future Autoconf release. -# They can cause serious problems if a builder's source tree is in a directory -# whose full name contains unusual characters. -ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. -ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. -ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010, 2011 Free Software -# Foundation, Inc. -# Written by Gordon Matzigkeit, 1996 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - - - -# serial 57 LT_INIT - - -# LT_PREREQ(VERSION) -# ------------------ -# Complain and exit if this libtool version is less that VERSION. - - - -# _LT_CHECK_BUILDDIR -# ------------------ -# Complain if the absolute build directory name contains unusual characters - - - -# LT_INIT([OPTIONS]) -# ------------------ -# LT_INIT - -# Old names: -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - - - -# _LT_CC_BASENAME(CC) -# ------------------- -# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. - - - -# _LT_FILEUTILS_DEFAULTS -# ---------------------- -# It is okay to use these file commands and assume they have been set -# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. -# _LT_FILEUTILS_DEFAULTS - - -# _LT_SETUP -# --------- -# _LT_SETUP - - -# _LT_PREPARE_SED_QUOTE_VARS -# -------------------------- -# Define a few sed substitution that help us do robust quoting. - - -# _LT_PROG_LTMAIN -# --------------- -# Note that this code is called both from `configure', and `config.status' -# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, -# `config.status' has no value for ac_aux_dir unless we are using Automake, -# so we pass a copy along to make sure it has a sensible value anyway. -# _LT_PROG_LTMAIN - - -## ------------------------------------- ## -## Accumulate code for creating libtool. ## -## ------------------------------------- ## - -# So that we can recreate a full libtool script including additional -# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS -# in macros and then make a single call at the end using the `libtool' -# label. - - -# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) -# ---------------------------------------- -# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. - - -# Initialize. - - - -# _LT_CONFIG_LIBTOOL([COMMANDS]) -# ------------------------------ -# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. - - -# Initialize. - - - -# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) -# ----------------------------------------------------- - - - -# _LT_FORMAT_COMMENT([COMMENT]) -# ----------------------------- -# Add leading comment marks to the start of each line, and a trailing -# full-stop to the whole comment if one is not present already. - - - - -## ------------------------ ## -## FIXME: Eliminate VARNAME ## -## ------------------------ ## - - -# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) -# ------------------------------------------------------------------- -# CONFIGNAME is the name given to the value in the libtool script. -# VARNAME is the (base) name used in the configure script. -# VALUE may be 0, 1 or 2 for a computed quote escaped value based on -# VARNAME. Any other value will be used directly. - - - -# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) -# -------------------------------------------------------- - - - -# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) -# ------------------------------------------------ - - - -# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) -# --------------------------------------------------------- - - - -# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) -# -------------------------------------------------- - - - -# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) -# --------------------------------------------------- - - - -# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) -# --------------------------------------------------- - - - - -# lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) -# ------------------------------------------------ - - - - -# _LT_CONFIG_STATUS_DECLARE([VARNAME]) -# ------------------------------------ -# Quote a variable value, and forward it to `config.status' so that its -# declaration there will have the same value as in `configure'. VARNAME -# must have a single quote delimited value for this to work. - - - -# _LT_CONFIG_STATUS_DECLARATIONS -# ------------------------------ -# We delimit libtool config variables with single quotes, so when -# we write them to config.status, we have to be sure to quote all -# embedded single quotes properly. In configure, this macro expands -# each variable declared with _LT_DECL (and _LT_TAGDECL) into: -# -# ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' - - - -# _LT_LIBTOOL_TAGS -# ---------------- -# Output comment and list of tags supported by the script - - - -# _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) -# ----------------------------------- -# Extract the dictionary values for VARNAME (optionally with TAG) and -# expand to a commented shell variable setting: -# -# # Some comment about what VAR is for. -# visible_name=$lt_internal_name - - - -# _LT_LIBTOOL_CONFIG_VARS -# ----------------------- -# Produce commented declarations of non-tagged libtool config variables -# suitable for insertion in the LIBTOOL CONFIG section of the `libtool' -# script. Tagged libtool config variables (even for the LIBTOOL CONFIG -# section) are produced by _LT_LIBTOOL_TAG_VARS. - - - -# _LT_LIBTOOL_TAG_VARS(TAG) -# ------------------------- - - - -# _LT_TAGVAR(VARNAME, [TAGNAME]) -# ------------------------------ - - - -# _LT_CONFIG_COMMANDS -# ------------------- -# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of -# variables for single and double quote escaping we saved from calls -# to _LT_DECL, we can put quote escaped variables declarations -# into `config.status', and then the shell code to quote escape them in -# for loops in `config.status'. Finally, any additional code accumulated -# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. -#_LT_CONFIG_COMMANDS - - -# Initialize. - - -# _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) -# ------------------------------------ -# Generate a child script FILE with all initialization necessary to -# reuse the environment learned by the parent script, and make the -# file executable. If COMMENT is supplied, it is inserted after the -# `#!' sequence but before initialization text begins. After this -# macro, additional text can be appended to FILE to form the body of -# the child script. The macro ends with non-zero status if the -# file could not be fully written (such as if the disk is full). -# _LT_GENERATED_FILE_INIT - -# LT_OUTPUT -# --------- -# This macro allows early generation of the libtool script (before -# AC_OUTPUT is called), incase it is used in configure for compilation -# tests. -# LT_OUTPUT - - -# _LT_CONFIG(TAG) -# --------------- -# If TAG is the built-in tag, create an initial libtool script with a -# default configuration from the untagged config vars. Otherwise add code -# to config.status for appending the configuration named by TAG from the -# matching tagged config vars. -# _LT_CONFIG - - -# LT_SUPPORTED_TAG(TAG) -# --------------------- -# Trace this macro to discover what tags are supported by the libtool -# --tag option, using: -# autoconf --trace 'LT_SUPPORTED_TAG:$1' - - - -# C support is built-in for now - - - - -# LT_LANG(LANG) -# ------------- -# Enable libtool support for the given language if not already enabled. -# LT_LANG - - -# _LT_LANG(LANGNAME) -# ------------------ -# _LT_LANG - - - -############################################################ -# NOTE: This macro has been submitted for inclusion into # -# GNU Autoconf as AC_PROG_GO. When it is available in # -# a released version of Autoconf we should remove this # -# macro and use it instead. # -############################################################ -#m4_defun -#m4_ifndef - - -# _LT_LANG_DEFAULT_CONFIG -# ----------------------- -# _LT_LANG_DEFAULT_CONFIG - -# Obsolete macros: -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - - - -# _LT_TAG_COMPILER -# ---------------- -# _LT_TAG_COMPILER - - -# _LT_COMPILER_BOILERPLATE -# ------------------------ -# Check for compiler boilerplate output or warnings with -# the simple compiler test code. -# _LT_COMPILER_BOILERPLATE - - -# _LT_LINKER_BOILERPLATE -# ---------------------- -# Check for linker boilerplate output or warnings with -# the simple link test code. -# _LT_LINKER_BOILERPLATE - -# _LT_REQUIRED_DARWIN_CHECKS -# ------------------------- - - - -# _LT_DARWIN_LINKER_FEATURES([TAG]) -# --------------------------------- -# Checks for linker and compiler features on darwin - - -# _LT_SYS_MODULE_PATH_AIX([TAGNAME]) -# ---------------------------------- -# Links a minimal program and checks the executable -# for the system default hardcoded library path. In most cases, -# this is /usr/lib:/lib, but when the MPI compilers are used -# the location of the communication and MPI libs are included too. -# If we don't find anything, use the default library path according -# to the aix ld manual. -# Store the results from the different compilers for each TAGNAME. -# Allow to override them for all tags through lt_cv_aix_libpath. -# _LT_SYS_MODULE_PATH_AIX - - -# _LT_SHELL_INIT(ARG) -# ------------------- -# _LT_SHELL_INIT - - - -# _LT_PROG_ECHO_BACKSLASH -# ----------------------- -# Find how we can fake an echo command that does not interpret backslash. -# In particular, with Autoconf 2.60 or later we add some code to the start -# of the generated configure script which will find a shell with a builtin -# printf (which we can use as an echo command). -# _LT_PROG_ECHO_BACKSLASH - - -# _LT_WITH_SYSROOT -# ---------------- - - -# _LT_ENABLE_LOCK -# --------------- -# _LT_ENABLE_LOCK - - -# _LT_PROG_AR -# ----------- -# _LT_PROG_AR - - -# _LT_CMD_OLD_ARCHIVE -# ------------------- -# _LT_CMD_OLD_ARCHIVE - - -# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) -# ---------------------------------------------------------------- -# Check whether the given compiler option works -# _LT_COMPILER_OPTION - -# Old name: -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - - - -# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [ACTION-SUCCESS], [ACTION-FAILURE]) -# ---------------------------------------------------- -# Check whether the given linker option works -# _LT_LINKER_OPTION - -# Old name: -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - - - -# LT_CMD_MAX_LEN -#--------------- -# LT_CMD_MAX_LEN - -# Old name: -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - - - -# _LT_HEADER_DLFCN -# ---------------- -# _LT_HEADER_DLFCN - - -# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, -# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) -# ---------------------------------------------------------------- -# _LT_TRY_DLOPEN_SELF - - -# LT_SYS_DLOPEN_SELF -# ------------------ -# LT_SYS_DLOPEN_SELF - -# Old name: -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - - - -# _LT_COMPILER_C_O([TAGNAME]) -# --------------------------- -# Check to see if options -c and -o are simultaneously supported by compiler. -# This macro does not hard code the compiler like AC_PROG_CC_C_O. -# _LT_COMPILER_C_O - - -# _LT_COMPILER_FILE_LOCKS([TAGNAME]) -# ---------------------------------- -# Check to see if we can do hard links to lock some files if needed -# _LT_COMPILER_FILE_LOCKS - - -# _LT_CHECK_OBJDIR -# ---------------- -# _LT_CHECK_OBJDIR - - -# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) -# -------------------------------------- -# Check hardcoding attributes. -# _LT_LINKER_HARDCODE_LIBPATH - - -# _LT_CMD_STRIPLIB -# ---------------- -# _LT_CMD_STRIPLIB - - -# _LT_SYS_DYNAMIC_LINKER([TAG]) -# ----------------------------- -# PORTME Fill in your ld.so characteristics -# _LT_SYS_DYNAMIC_LINKER - - -# _LT_PATH_TOOL_PREFIX(TOOL) -# -------------------------- -# find a file program which can recognize shared library -# _LT_PATH_TOOL_PREFIX - -# Old name: -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - - - -# _LT_PATH_MAGIC -# -------------- -# find a file program which can recognize a shared library -# _LT_PATH_MAGIC - - -# LT_PATH_LD -# ---------- -# find the pathname to the GNU or non-GNU linker -# LT_PATH_LD - -# Old names: -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - - - -# _LT_PATH_LD_GNU -#- -------------- -# _LT_PATH_LD_GNU - - -# _LT_CMD_RELOAD -# -------------- -# find reload flag for linker -# -- PORTME Some linkers may need a different reload flag. -# _LT_CMD_RELOAD - - -# _LT_CHECK_MAGIC_METHOD -# ---------------------- -# how to check for library dependencies -# -- PORTME fill in with the dynamic library characteristics -# _LT_CHECK_MAGIC_METHOD - - -# LT_PATH_NM -# ---------- -# find the pathname to a BSD- or MS-compatible name lister -# LT_PATH_NM - -# Old names: -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - - -# _LT_CHECK_SHAREDLIB_FROM_LINKLIB -# -------------------------------- -# how to determine the name of the shared library -# associated with a specific link library. -# -- PORTME fill in with the dynamic library characteristics -# _LT_CHECK_SHAREDLIB_FROM_LINKLIB - - -# _LT_PATH_MANIFEST_TOOL -# ---------------------- -# locate the manifest tool -# _LT_PATH_MANIFEST_TOOL - - -# LT_LIB_M -# -------- -# check for math library -# LT_LIB_M - -# Old name: -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - - - -# _LT_COMPILER_NO_RTTI([TAGNAME]) -# ------------------------------- -# _LT_COMPILER_NO_RTTI - - -# _LT_CMD_GLOBAL_SYMBOLS -# ---------------------- - # _LT_CMD_GLOBAL_SYMBOLS - - -# _LT_COMPILER_PIC([TAGNAME]) -# --------------------------- -# _LT_COMPILER_PIC - - -# _LT_LINKER_SHLIBS([TAGNAME]) -# ---------------------------- -# See if the linker supports building shared libraries. -# _LT_LINKER_SHLIBS - - -# _LT_LANG_C_CONFIG([TAG]) -# ------------------------ -# Ensure that the configuration variables for a C compiler are suitably -# defined. These variables are subsequently used by _LT_CONFIG to write -# the compiler configuration to `libtool'. -# _LT_LANG_C_CONFIG - - -# _LT_LANG_CXX_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for a C++ compiler are suitably -# defined. These variables are subsequently used by _LT_CONFIG to write -# the compiler configuration to `libtool'. -# _LT_LANG_CXX_CONFIG - - -# _LT_FUNC_STRIPNAME_CNF -# ---------------------- -# func_stripname_cnf prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -# -# This function is identical to the (non-XSI) version of func_stripname, -# except this one can be used by m4 code that may be executed by configure, -# rather than the libtool script. -# _LT_FUNC_STRIPNAME_CNF - -# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) -# --------------------------------- -# Figure out "hidden" library dependencies from verbose -# compiler output when linking a shared library. -# Parse the compiler output and extract the necessary -# objects, libraries and library flags. -# _LT_SYS_HIDDEN_LIBDEPS - - -# _LT_LANG_F77_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for a Fortran 77 compiler are -# suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -# _LT_LANG_F77_CONFIG - - -# _LT_LANG_FC_CONFIG([TAG]) -# ------------------------- -# Ensure that the configuration variables for a Fortran compiler are -# suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -# _LT_LANG_FC_CONFIG - - -# _LT_LANG_GCJ_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for the GNU Java Compiler compiler -# are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -# _LT_LANG_GCJ_CONFIG - - -# _LT_LANG_GO_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for the GNU Go compiler -# are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -# _LT_LANG_GO_CONFIG - - -# _LT_LANG_RC_CONFIG([TAG]) -# ------------------------- -# Ensure that the configuration variables for the Windows resource compiler -# are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -# _LT_LANG_RC_CONFIG - - -# LT_PROG_GCJ -# ----------- - - -# Old name: -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - - - -# LT_PROG_GO -# ---------- - - - -# LT_PROG_RC -# ---------- - - -# Old name: -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - - - -# _LT_DECL_EGREP -# -------------- -# If we don't have a new enough Autoconf to choose the best grep -# available, choose the one first in the user's PATH. - - - -# _LT_DECL_OBJDUMP -# -------------- -# If we don't have a new enough Autoconf to choose the best objdump -# available, choose the one first in the user's PATH. - - -# _LT_DECL_DLLTOOL -# ---------------- -# Ensure DLLTOOL variable is set. - - -# _LT_DECL_SED -# ------------ -# Check for a fully-functional sed program, that truncates -# as few characters as possible. Prefer GNU sed if found. -# _LT_DECL_SED - -#m4_ifndef - -# Old name: -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - - - -# _LT_CHECK_SHELL_FEATURES -# ------------------------ -# Find out whether the shell is Bourne or XSI compatible, -# or has some other useful features. -# _LT_CHECK_SHELL_FEATURES - - -# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY) -# ------------------------------------------------------ -# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and -# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY. - - - -# _LT_PROG_REPLACE_SHELLFNS -# ------------------------- -# Replace existing portable implementations of several shell functions with -# equivalent extended shell implementations where those features are available.. - - -# _LT_PATH_CONVERSION_FUNCTIONS -# ----------------------------- -# Determine which file name conversion functions should be used by -# func_to_host_file (and, implicitly, by func_to_host_path). These are needed -# for certain cross-compile configurations and native mingw. -# _LT_PATH_CONVERSION_FUNCTIONS - -# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- -# -# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. -# Written by Gary V. Vaughan, 2004 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# serial 6 ltsugar.m4 - -# This is to help aclocal find these macros, as it can't see m4_define. - - - -# lt_join(SEP, ARG1, [ARG2...]) -# ----------------------------- -# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their -# associated separator. -# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier -# versions in m4sugar had bugs. - - - - -# lt_car(LIST) -# lt_cdr(LIST) -# ------------ -# Manipulate m4 lists. -# These macros are necessary as long as will still need to support -# Autoconf-2.59 which quotes differently. - - - - - -# lt_append(MACRO-NAME, STRING, [SEPARATOR]) -# ------------------------------------------ -# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. -# Note that neither SEPARATOR nor STRING are expanded; they are appended -# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). -# No SEPARATOR is output if MACRO-NAME was previously undefined (different -# than defined and empty). -# -# This macro is needed until we can rely on Autoconf 2.62, since earlier -# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. - - - - -# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) -# ---------------------------------------------------------- -# Produce a SEP delimited list of all paired combinations of elements of -# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list -# has the form PREFIXmINFIXSUFFIXn. -# Needed until we can rely on m4_combine added in Autoconf 2.62. - - - -# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) -# ----------------------------------------------------------------------- -# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited -# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. - - - -# lt_dict_add(DICT, KEY, VALUE) -# ----------------------------- - - - -# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) -# -------------------------------------------- - - - -# lt_dict_fetch(DICT, KEY, [SUBKEY]) -# ---------------------------------- - - - -# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) -# ----------------------------------------------------------------- - - - -# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) -# -------------------------------------------------------------- - - - -# Helper functions for option handling. -*- Autoconf -*- -# -# Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, -# Inc. -# Written by Gary V. Vaughan, 2004 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# serial 7 ltoptions.m4 - -# This is to help aclocal find these macros, as it can't see m4_define. - - - -# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) -# ------------------------------------------ - - - -# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) -# --------------------------------------- -# Set option OPTION-NAME for macro MACRO-NAME, and if there is a -# matching handler defined, dispatch to it. Other OPTION-NAMEs are -# saved as a flag. - - - -# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) -# ------------------------------------------------------------ -# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. - - - -# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) -# ------------------------------------------------------- -# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME -# are set. - - - -# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) -# ---------------------------------------- -# OPTION-LIST is a space-separated list of Libtool options associated -# with MACRO-NAME. If any OPTION has a matching handler declared with -# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about -# the unknown option and exit. -# _LT_SET_OPTIONS - - -## --------------------------------- ## -## Macros to handle LT_INIT options. ## -## --------------------------------- ## - -# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) -# ----------------------------------------- - - - -# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) -# ----------------------------------------------- -# LT_OPTION_DEFINE - - -# dlopen -# ------ - - -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - - - - -# win32-dll -# --------- -# Declare package support for building win32 dll's. -# win32-dll - -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - - - - -# _LT_ENABLE_SHARED([DEFAULT]) -# ---------------------------- -# implement the --enable-shared flag, and supports the `shared' and -# `disable-shared' LT_INIT options. -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -# _LT_ENABLE_SHARED - - - - -# Old names: - - - - -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - - - - - -# _LT_ENABLE_STATIC([DEFAULT]) -# ---------------------------- -# implement the --enable-static flag, and support the `static' and -# `disable-static' LT_INIT options. -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -# _LT_ENABLE_STATIC - - - - -# Old names: - - - - -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - - - - - -# _LT_ENABLE_FAST_INSTALL([DEFAULT]) -# ---------------------------------- -# implement the --enable-fast-install flag, and support the `fast-install' -# and `disable-fast-install' LT_INIT options. -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -# _LT_ENABLE_FAST_INSTALL - - - - -# Old names: -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - - -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - - - - -# _LT_WITH_PIC([MODE]) -# -------------------- -# implement the --with-pic flag, and support the `pic-only' and `no-pic' -# LT_INIT options. -# MODE is either `yes' or `no'. If omitted, it defaults to `both'. -# _LT_WITH_PIC - - - - -# Old name: -# This is what autoupdate's m4 run will expand. It fires -# the warning (with _au_warn_XXX), outputs it into the -# updated configure.ac (with AC_DIAGNOSE), and then outputs -# the replacement expansion. - - -# This is an auxiliary macro that is also run when -# autoupdate runs m4. It simply calls m4_warning, but -# we need a wrapper so that each warning is emitted only -# once. We break the quoting in m4_warning's argument in -# order to expand this macro's arguments, not AU_DEFUN's. - - -# Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. - - - -## ----------------- ## -## LTDL_INIT Options ## -## ----------------- ## - - - - - - - - - - -# ltversion.m4 -- version numbers -*- Autoconf -*- -# -# Copyright (C) 2004 Free Software Foundation, Inc. -# Written by Scott James Remnant, 2004 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# @configure_input@ - -# serial 3337 ltversion.m4 -# This file is part of GNU Libtool - - - - - - -# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- -# -# Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. -# Written by Scott James Remnant, 2004. -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# serial 5 lt~obsolete.m4 - -# These exist entirely to fool aclocal when bootstrapping libtool. -# -# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) -# which have later been changed to m4_define as they aren't part of the -# exported API, or moved to Autoconf or Automake where they belong. -# -# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN -# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us -# using a macro with the same name in our local m4/libtool.m4 it'll -# pull the old libtool.m4 in (it doesn't see our shiny new m4_define -# and doesn't know about Autoconf macros at all.) -# -# So we provide this file, which has a silly filename so it's always -# included after everything else. This provides aclocal with the -# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything -# because those macros already exist, or will be overwritten later. -# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. -# -# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. -# Yes, that means every name once taken will need to remain here until -# we give up compatibility with versions before 1.7, at which point -# we need to keep only those names which we still refer to. - -# This is to help aclocal find these macros, as it can't see m4_define. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - apr_ste_save_CPPFLAGS="$CPPFLAGS" - - - apr_ste_save_CFLAGS="$CFLAGS" - - - apr_ste_save_LDFLAGS="$LDFLAGS" - - - apr_ste_save_LIBS="$LIBS" - - - apr_ste_save_INCLUDES="$INCLUDES" - - - - rm -f config.nice - cat >config.nice<> config.nice - fi - if test -n "$CFLAGS"; then - echo "CFLAGS=\"$CFLAGS\"; export CFLAGS" >> config.nice - fi - if test -n "$CPPFLAGS"; then - echo "CPPFLAGS=\"$CPPFLAGS\"; export CPPFLAGS" >> config.nice - fi - if test -n "$LDFLAGS"; then - echo "LDFLAGS=\"$LDFLAGS\"; export LDFLAGS" >> config.nice - fi - if test -n "$LTFLAGS"; then - echo "LTFLAGS=\"$LTFLAGS\"; export LTFLAGS" >> config.nice - fi - if test -n "$LIBS"; then - echo "LIBS=\"$LIBS\"; export LIBS" >> config.nice - fi - if test -n "$INCLUDES"; then - echo "INCLUDES=\"$INCLUDES\"; export INCLUDES" >> config.nice - fi - if test -n "$NOTEST_CFLAGS"; then - echo "NOTEST_CFLAGS=\"$NOTEST_CFLAGS\"; export NOTEST_CFLAGS" >> config.nice - fi - if test -n "$NOTEST_CPPFLAGS"; then - echo "NOTEST_CPPFLAGS=\"$NOTEST_CPPFLAGS\"; export NOTEST_CPPFLAGS" >> config.nice - fi - if test -n "$NOTEST_LDFLAGS"; then - echo "NOTEST_LDFLAGS=\"$NOTEST_LDFLAGS\"; export NOTEST_LDFLAGS" >> config.nice - fi - if test -n "$NOTEST_LIBS"; then - echo "NOTEST_LIBS=\"$NOTEST_LIBS\"; export NOTEST_LIBS" >> config.nice - fi - - # Retrieve command-line arguments. - eval "set x $0 $ac_configure_args" - shift - - for arg - do - -ap_last= -ap_cur="$arg" -while test "x${ap_cur}" != "x${ap_last}"; -do - ap_last="${ap_cur}" - ap_cur=`eval "echo ${ap_cur}"` -done -arg="${ap_cur}" - - echo "\"$arg\" \\" >> config.nice - done - echo '"$@"' >> config.nice - chmod +x config.nice - - -# Make sure we can run config.sub. -$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 -$as_echo_n "checking build system type... " >&6; } -if ${ac_cv_build+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_build_alias=$build_alias -test "x$ac_build_alias" = x && - ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` -test "x$ac_build_alias" = x && - as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 -ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 -$as_echo "$ac_cv_build" >&6; } -case $ac_cv_build in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; -esac -build=$ac_cv_build -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_build -shift -build_cpu=$1 -build_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -build_os=$* -IFS=$ac_save_IFS -case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 -$as_echo_n "checking host system type... " >&6; } -if ${ac_cv_host+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "x$host_alias" = x; then - ac_cv_host=$ac_cv_build -else - ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 -$as_echo "$ac_cv_host" >&6; } -case $ac_cv_host in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; -esac -host=$ac_cv_host -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_host -shift -host_cpu=$1 -host_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -host_os=$* -IFS=$ac_save_IFS -case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 -$as_echo_n "checking target system type... " >&6; } -if ${ac_cv_target+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "x$target_alias" = x; then - ac_cv_target=$ac_cv_host -else - ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5 -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 -$as_echo "$ac_cv_target" >&6; } -case $ac_cv_target in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;; -esac -target=$ac_cv_target -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_target -shift -target_cpu=$1 -target_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -target_os=$* -IFS=$ac_save_IFS -case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac - - -# The aliases save the names the user supplied, while $host etc. -# will get canonicalized. -test -n "$target_alias" && - test "$program_prefix$program_suffix$program_transform_name" = \ - NONENONEs,x,x, && - program_prefix=${target_alias}- - -echo "Configuring APR library" -echo "Platform: $host" - - - -# Absolute source/build directory -apr_srcdir=`(cd $srcdir && pwd)` -apr_builddir=`pwd` - - - -if test "$apr_builddir" != "$apr_srcdir"; then - USE_VPATH=1 - APR_CONFIG_LOCATION=build -else - APR_CONFIG_LOCATION=source -fi - - - -# Libtool might need this symbol -- it must point to the location of -# the generated libtool script (not necessarily the "top" build dir). -# -top_builddir="$apr_builddir" - - -# Directory containing apr build macros, helpers, and make rules -# NOTE: make rules (apr_rules.mk) will be in the builddir for vpath -# -apr_buildout=$apr_builddir/build -apr_builders=$apr_srcdir/build - - -MKDIR=$apr_builders/mkdir.sh - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mkdir -p" >&5 -$as_echo_n "checking for working mkdir -p... " >&6; } -if ${ac_cv_mkdir_p+:} false; then : - $as_echo_n "(cached) " >&6 -else - - test -d conftestdir && rm -rf conftestdir - mkdir -p conftestdir/somedir >/dev/null 2>&1 - if test -d conftestdir/somedir; then - ac_cv_mkdir_p=yes - else - ac_cv_mkdir_p=no - fi - rm -rf conftestdir - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_mkdir_p" >&5 -$as_echo "$ac_cv_mkdir_p" >&6; } - if test "$ac_cv_mkdir_p" = "yes"; then - mkdir_p="mkdir -p" - else - mkdir_p="$apr_builders/mkdir.sh" - fi - - -# get our version information -get_version="$apr_builders/get-version.sh" -version_hdr="$apr_srcdir/include/apr_version.h" -APR_MAJOR_VERSION="`$get_version major $version_hdr APR`" -APR_DOTTED_VERSION="`$get_version all $version_hdr APR`" - - - - -echo "APR Version: ${APR_DOTTED_VERSION}" - - -# Check whether --enable-layout was given. -if test "${enable_layout+set}" = set; then : - enableval=$enable_layout; - LAYOUT=$enableval - -fi - - -if test -z "$LAYOUT"; then - LAYOUT="apr" -fi - - if test ! -f $srcdir/config.layout; then - echo "** Error: Layout file $srcdir/config.layout not found" - echo "** Error: Cannot use undefined layout '$LAYOUT'" - exit 1 - fi - # Catch layout names including a slash which will otherwise - # confuse the heck out of the sed script. - case $LAYOUT in - */*) - echo "** Error: $LAYOUT is not a valid layout name" - exit 1 ;; - esac - pldconf=./config.pld - - sed -e "1s/[ ]*<[lL]ayout[ ]*$LAYOUT[ ]*>[ ]*//;1t" \ - -e "1,/[ ]*<[lL]ayout[ ]*$LAYOUT[ ]*>[ ]*/d" \ - -e '/[ ]*<\/Layout>[ ]*/,$d' \ - -e "s/^[ ]*//g" \ - -e "s/:[ ]*/=\'/g" \ - -e "s/[ ]*$/'/g" \ - $srcdir/config.layout > $pldconf - layout_name=$LAYOUT - if test ! -s $pldconf; then - echo "** Error: unable to find layout $layout_name" - exit 1 - fi - . $pldconf - rm $pldconf - for var in prefix exec_prefix bindir sbindir libexecdir mandir \ - sysconfdir datadir includedir localstatedir runtimedir \ - logfiledir libdir installbuilddir libsuffix ; do - eval "val=\"\$$var\"" - case $val in - *+) - val=`echo $val | sed -e 's;\+$;;'` - eval "$var=\"\$val\"" - autosuffix=yes - ;; - *) - autosuffix=no - ;; - esac - val=`echo $val | sed -e 's:\(.\)/*$:\1:'` - val=`echo $val | sed -e 's:[\$]\([a-z_]*\):$\1:g'` - if test "$autosuffix" = "yes"; then - if echo $val | grep apache >/dev/null; then - addtarget=no - else - addtarget=yes - fi - if test "$addtarget" = "yes"; then - val="$val/apache2" - fi - fi - eval "$var='$val'" - done - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for chosen layout" >&5 -$as_echo_n "checking for chosen layout... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $layout_name" >&5 -$as_echo "$layout_name" >&6; } - - -ac_prev= -# Retrieve the command-line arguments. The eval is needed because -# the arguments are quoted to preserve accuracy. -eval "set x $ac_configure_args" -shift -for ac_option -do - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" - ac_prev= - continue - fi - - ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` - - case $ac_option in - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir="$ac_optarg" ;; - - -datadir | --datadir | --datadi | --datad | --data | --dat | --da) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ - | --da=*) - datadir="$ac_optarg" ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix="$ac_optarg" ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir="$ac_optarg" ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir="$ac_optarg" ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir="$ac_optarg" ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir="$ac_optarg" ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst \ - | --locals | --local | --loca | --loc | --lo) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* \ - | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) - localstatedir="$ac_optarg" ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir="$ac_optarg" ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix="$ac_optarg" ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir="$ac_optarg" ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir="$ac_optarg" ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir="$ac_optarg" ;; - - esac -done - -# Be sure to have absolute paths. -for ac_var in exec_prefix prefix -do - eval ac_val=$`echo $ac_var` - case $ac_val in - [\\/$]* | ?:[\\/]* | NONE | '' ) ;; - *) as_fn_error $? "expected an absolute path for --$ac_var: $ac_val" "$LINENO" 5;; - esac -done - - - - -case "$host" in - *-apple-aux3*) - - if test -z "$CC"; then - test "x$silent" != "xyes" && echo " setting CC to \"gcc\"" - CC="gcc" - fi - - ;; - bs2000*-siemens-sysv*) - - if test -z "$CC"; then - test "x$silent" != "xyes" && echo " setting CC to \"c89 -XLLML -XLLMK -XL -Kno_integer_overflow\"" - CC="c89 -XLLML -XLLMK -XL -Kno_integer_overflow" - fi - - ;; - *convex-v11*) - - if test -z "$CC"; then - test "x$silent" != "xyes" && echo " setting CC to \"cc\"" - CC="cc" - fi - - ;; - *-ibm-os390) - - if test -z "$CC"; then - test "x$silent" != "xyes" && echo " setting CC to \"cc\"" - CC="cc" - fi - - ;; - *-ibm-as400) - - if test -z "$CC"; then - test "x$silent" != "xyes" && echo " setting CC to \"icc\"" - CC="icc" - fi - - ;; - *-isc4*) - - if test -z "$CC"; then - test "x$silent" != "xyes" && echo " setting CC to \"gcc\"" - CC="gcc" - fi - - ;; - m88k-*-CX/SX|CYBER) - - if test -z "$CC"; then - test "x$silent" != "xyes" && echo " setting CC to \"cc\"" - CC="cc" - fi - - ;; - *-next-openstep*) - - if test -z "$CC"; then - test "x$silent" != "xyes" && echo " setting CC to \"cc\"" - CC="cc" - fi - - ;; - *-qnx32) - - if test -z "$CC"; then - test "x$silent" != "xyes" && echo " setting CC to \"cc -F\"" - CC="cc -F" - fi - - ;; - *-tandem-oss) - - if test -z "$CC"; then - test "x$silent" != "xyes" && echo " setting CC to \"c89\"" - CC="c89" - fi - - ;; - TPF) - - if test -z "$CC"; then - test "x$silent" != "xyes" && echo " setting CC to \"c89\"" - CC="c89" - fi - - ;; -esac - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CC" && break -done - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -fi - -fi - - -test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5; } - -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&6; } -ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` - -# The possible output files: -ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" - -ac_rmfiles= -for ac_file in $ac_files -do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - * ) ac_rmfiles="$ac_rmfiles $ac_file";; - esac -done -rm -f $ac_rmfiles - -if { { ac_try="$ac_link_default" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link_default") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. -# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' -# in a Makefile. We should not override ac_cv_exeext if it was cached, -# so that the user can short-circuit this test for compilers unknown to -# Autoconf. -for ac_file in $ac_files '' -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; - then :; else - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - fi - # We set ac_cv_exeext here because the later test for it is not - # safe: cross compilers may not add the suffix if given an `-o' - # argument, so we may need to know it at that point already. - # Even if this section looks crufty: it has the advantage of - # actually working. - break;; - * ) - break;; - esac -done -test "$ac_cv_exeext" = no && ac_cv_exeext= - -else - ac_file='' -fi -if test -z "$ac_file"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "C compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } -ac_exeext=$ac_cv_exeext - -rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 -$as_echo_n "checking for suffix of executables... " >&6; } -if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - break;; - * ) break;; - esac -done -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5; } -fi -rm -f conftest conftest$ac_cv_exeext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 -$as_echo "$ac_cv_exeext" >&6; } - -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -FILE *f = fopen ("conftest.out", "w"); - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -ac_clean_files="$ac_clean_files conftest.out" -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -if test "$cross_compiling" != yes; then - { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if { ac_try='./conftest$ac_cv_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5; } - fi - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 -$as_echo_n "checking for suffix of object files... " >&6; } -if ${ac_cv_objext+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.o conftest.obj -if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - for ac_file in conftest.o conftest.obj conftest.*; do - test -f "$ac_file" || continue; - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5; } -fi -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 -$as_echo "$ac_cv_objext" >&6; } -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if ${ac_cv_c_compiler_gnu+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC= -fi -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if ${ac_cv_prog_cc_g+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -else - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if ${ac_cv_prog_cc_c89+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC - -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : - -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 -$as_echo_n "checking for a sed that does not truncate output... " >&6; } -if ${ac_cv_path_SED+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ - for ac_i in 1 2 3 4 5 6 7; do - ac_script="$ac_script$as_nl$ac_script" - done - echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed - { ac_script=; unset ac_script;} - if test -z "$SED"; then - ac_path_SED_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in sed gsed; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue -# Check for GNU ac_path_SED and select it if it is found. - # Check for GNU $ac_path_SED -case `"$ac_path_SED" --version 2>&1` in -*GNU*) - ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo '' >> "conftest.nl" - "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_SED_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_SED="$ac_path_SED" - ac_path_SED_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_SED_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_SED"; then - as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 - fi -else - ac_cv_path_SED=$SED -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 -$as_echo "$ac_cv_path_SED" >&6; } - SED="$ac_cv_path_SED" - rm -f conftest.sed - - - -if test "x$apr_preload_done" != "xyes" ; then - - apr_preload_done="yes" - - echo "Applying APR hints file rules for $host" - - case "$host" in - *mint) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DMINT\"" - CPPFLAGS="-DMINT" - else - apr_addto_bugger="-DMINT" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lportlib\"" - LIBS="-lportlib" - else - apr_addto_bugger="-lportlib" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - *MPE/iX*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DMPE -D_POSIX_SOURCE -D_SOCKET_SOURCE\"" - CPPFLAGS="-DMPE -D_POSIX_SOURCE -D_SOCKET_SOURCE" - else - apr_addto_bugger="-DMPE -D_POSIX_SOURCE -D_SOCKET_SOURCE" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lsvipc -lcurses\"" - LIBS="-lsvipc -lcurses" - else - apr_addto_bugger="-lsvipc -lcurses" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - - if test "x$LDFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting LDFLAGS to \"-Xlinker \"-WL,cap=ia,ba,ph;nmstack=1024000\"\"" - LDFLAGS="-Xlinker \"-WL,cap=ia,ba,ph;nmstack=1024000\"" - else - apr_addto_bugger="-Xlinker \"-WL,cap=ia,ba,ph;nmstack=1024000\"" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LDFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LDFLAGS" - LDFLAGS="$LDFLAGS $i" - fi - done - fi - - ;; - *-apple-aux3*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DAUX3 -D_POSIX_SOURCE\"" - CPPFLAGS="-DAUX3 -D_POSIX_SOURCE" - else - apr_addto_bugger="-DAUX3 -D_POSIX_SOURCE" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lposix -lbsd\"" - LIBS="-lposix -lbsd" - else - apr_addto_bugger="-lposix -lbsd" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - - if test "x$LDFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting LDFLAGS to \"-s\"" - LDFLAGS="-s" - else - apr_addto_bugger="-s" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LDFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LDFLAGS" - LDFLAGS="$LDFLAGS $i" - fi - done - fi - - - test "x$silent" != "xyes" && echo " forcing SHELL to \"/bin/ksh\"" - SHELL="/bin/ksh" - - ;; - *-ibm-aix*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-U__STR__ -D_THREAD_SAFE\"" - CPPFLAGS="-U__STR__ -D_THREAD_SAFE" - else - apr_addto_bugger="-U__STR__ -D_THREAD_SAFE" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - case $host in - *-ibm-aix4.3) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-D_USE_IRS\"" - CPPFLAGS="-D_USE_IRS" - else - apr_addto_bugger="-D_USE_IRS" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *-ibm-aix5*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-D_USE_IRS\"" - CPPFLAGS="-D_USE_IRS" - else - apr_addto_bugger="-D_USE_IRS" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *-ibm-aix4.3.*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-D_USE_IRS\"" - CPPFLAGS="-D_USE_IRS" - else - apr_addto_bugger="-D_USE_IRS" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - esac - if $CC 2>&1 | grep 'xlc' > /dev/null; then - - if test -z "$AIX_XLC"; then - test "x$silent" != "xyes" && echo " setting AIX_XLC to \"yes\"" - AIX_XLC="yes" - fi - - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-qHALT=E\"" - CFLAGS="-qHALT=E" - else - apr_addto_bugger="-qHALT=E" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - fi - - if test -z "$apr_sysvsem_is_global"; then - test "x$silent" != "xyes" && echo " setting apr_sysvsem_is_global to \"yes\"" - apr_sysvsem_is_global="yes" - fi - - - if test -z "$apr_lock_method"; then - test "x$silent" != "xyes" && echo " setting apr_lock_method to \"USE_SYSVSEM_SERIALIZE\"" - apr_lock_method="USE_SYSVSEM_SERIALIZE" - fi - - case $host in - *-ibm-aix3* | *-ibm-aix4.1.*) - ;; - *) - - if test "x$LDFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting LDFLAGS to \"-Wl,-brtl\"" - LDFLAGS="-Wl,-brtl" - else - apr_addto_bugger="-Wl,-brtl" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LDFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LDFLAGS" - LDFLAGS="$LDFLAGS $i" - fi - done - fi - - ;; - esac - ;; - *-apollo-*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DAPOLLO\"" - CPPFLAGS="-DAPOLLO" - else - apr_addto_bugger="-DAPOLLO" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *-dg-dgux*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DDGUX\"" - CPPFLAGS="-DDGUX" - else - apr_addto_bugger="-DDGUX" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *-os2*) - - test "x$silent" != "xyes" && echo " forcing SHELL to \"sh\"" - SHELL="sh" - - - if test -z "$apr_gethostbyname_is_thread_safe"; then - test "x$silent" != "xyes" && echo " setting apr_gethostbyname_is_thread_safe to \"yes\"" - apr_gethostbyname_is_thread_safe="yes" - fi - - - if test -z "$apr_gethostbyaddr_is_thread_safe"; then - test "x$silent" != "xyes" && echo " setting apr_gethostbyaddr_is_thread_safe to \"yes\"" - apr_gethostbyaddr_is_thread_safe="yes" - fi - - - if test -z "$apr_getservbyname_is_thread_safe"; then - test "x$silent" != "xyes" && echo " setting apr_getservbyname_is_thread_safe to \"yes\"" - apr_getservbyname_is_thread_safe="yes" - fi - - ;; - *-hi-hiux) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DHIUX\"" - CPPFLAGS="-DHIUX" - else - apr_addto_bugger="-DHIUX" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *-hp-hpux11.*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DHPUX11 -D_REENTRANT -D_HPUX_SOURCE\"" - CPPFLAGS="-DHPUX11 -D_REENTRANT -D_HPUX_SOURCE" - else - apr_addto_bugger="-DHPUX11 -D_REENTRANT -D_HPUX_SOURCE" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *-hp-hpux10.*) - case $host in - *-hp-hpux10.01) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSELECT_NEEDS_CAST\"" - CPPFLAGS="-DSELECT_NEEDS_CAST" - else - apr_addto_bugger="-DSELECT_NEEDS_CAST" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - esac - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-D_REENTRANT\"" - CPPFLAGS="-D_REENTRANT" - else - apr_addto_bugger="-D_REENTRANT" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *-hp-hpux*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DHPUX -D_REENTRANT\"" - CPPFLAGS="-DHPUX -D_REENTRANT" - else - apr_addto_bugger="-DHPUX -D_REENTRANT" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *-linux*) - case `uname -r` in - 2.* ) - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DLINUX=2\"" - CPPFLAGS="-DLINUX=2" - else - apr_addto_bugger="-DLINUX=2" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - 1.* ) - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DLINUX=1\"" - CPPFLAGS="-DLINUX=1" - else - apr_addto_bugger="-DLINUX=1" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - * ) - ;; - esac - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-D_REENTRANT -D_GNU_SOURCE\"" - CPPFLAGS="-D_REENTRANT -D_GNU_SOURCE" - else - apr_addto_bugger="-D_REENTRANT -D_GNU_SOURCE" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *-GNU*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DHURD -D_GNU_SOURCE\"" - CPPFLAGS="-DHURD -D_GNU_SOURCE" - else - apr_addto_bugger="-DHURD -D_GNU_SOURCE" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *-lynx-lynxos) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-D__NO_INCLUDE_WARN__ -DLYNXOS\"" - CPPFLAGS="-D__NO_INCLUDE_WARN__ -DLYNXOS" - else - apr_addto_bugger="-D__NO_INCLUDE_WARN__ -DLYNXOS" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lbsd\"" - LIBS="-lbsd" - else - apr_addto_bugger="-lbsd" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - *486-*-bsdi*) - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-m486\"" - CFLAGS="-m486" - else - apr_addto_bugger="-m486" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - ;; - *-*-bsdi*) - case $host in - *bsdi4.1) - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-D_REENTRANT\"" - CFLAGS="-D_REENTRANT" - else - apr_addto_bugger="-D_REENTRANT" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - ;; - esac - ;; - *-openbsd*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-D_POSIX_THREADS\"" - CPPFLAGS="-D_POSIX_THREADS" - else - apr_addto_bugger="-D_POSIX_THREADS" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - # binding to an ephemeral port fails on OpenBSD so override - # the test for O_NONBLOCK inheritance across accept(). - - if test -z "$ac_cv_o_nonblock_inherited"; then - test "x$silent" != "xyes" && echo " setting ac_cv_o_nonblock_inherited to \"yes\"" - ac_cv_o_nonblock_inherited="yes" - fi - - ;; - *-netbsd*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DNETBSD\"" - CPPFLAGS="-DNETBSD" - else - apr_addto_bugger="-DNETBSD" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - # fcntl() lies about O_NONBLOCK on an accept()ed socket (PR kern/26950) - - if test -z "$ac_cv_o_nonblock_inherited"; then - test "x$silent" != "xyes" && echo " setting ac_cv_o_nonblock_inherited to \"yes\"" - ac_cv_o_nonblock_inherited="yes" - fi - - ;; - *-freebsd*) - - if test -z "$apr_lock_method"; then - test "x$silent" != "xyes" && echo " setting apr_lock_method to \"USE_FLOCK_SERIALIZE\"" - apr_lock_method="USE_FLOCK_SERIALIZE" - fi - - if test -x /sbin/sysctl; then - os_version=`/sbin/sysctl -n kern.osreldate` - else - os_version=000000 - fi - # 502102 is when libc_r switched to libpthread (aka libkse). - if test $os_version -ge "502102"; then - apr_cv_pthreads_cflags="none" - apr_cv_pthreads_lib="-lpthread" - else - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-D_THREAD_SAFE -D_REENTRANT\"" - CPPFLAGS="-D_THREAD_SAFE -D_REENTRANT" - else - apr_addto_bugger="-D_THREAD_SAFE -D_REENTRANT" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test -z "$enable_threads"; then - test "x$silent" != "xyes" && echo " setting enable_threads to \"no\"" - enable_threads="no" - fi - - fi - # prevent use of KQueue before FreeBSD 4.8 - if test $os_version -lt "480000"; then - - if test -z "$ac_cv_func_kqueue"; then - test "x$silent" != "xyes" && echo " setting ac_cv_func_kqueue to \"no\"" - ac_cv_func_kqueue="no" - fi - - fi - ;; - *-k*bsd*-gnu) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-D_REENTRANT -D_GNU_SOURCE\"" - CPPFLAGS="-D_REENTRANT -D_GNU_SOURCE" - else - apr_addto_bugger="-D_REENTRANT -D_GNU_SOURCE" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *-next-nextstep*) - - if test -z "$CFLAGS"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-O\"" - CFLAGS="-O" - fi - - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DNEXT\"" - CPPFLAGS="-DNEXT" - else - apr_addto_bugger="-DNEXT" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *-next-openstep*) - - if test -z "$CFLAGS"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-O\"" - CFLAGS="-O" - fi - - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DNEXT\"" - CPPFLAGS="-DNEXT" - else - apr_addto_bugger="-DNEXT" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *-apple-rhapsody*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DRHAPSODY\"" - CPPFLAGS="-DRHAPSODY" - else - apr_addto_bugger="-DRHAPSODY" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *-apple-darwin*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -no-cpp-precomp\"" - CPPFLAGS="-DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -no-cpp-precomp" - else - apr_addto_bugger="-DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -no-cpp-precomp" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test -z "$apr_posixsem_is_global"; then - test "x$silent" != "xyes" && echo " setting apr_posixsem_is_global to \"yes\"" - apr_posixsem_is_global="yes" - fi - - case $host in - *-apple-darwin[1-9].*) - # APR's use of kqueue has triggered kernel panics for some - # 10.5.x (Darwin 9.x) users when running the entire test suite. - # In 10.4.x, use of kqueue would cause the socket tests to hang. - # 10.6+ (Darwin 10.x is supposed to fix the KQueue issues - - if test -z "$ac_cv_func_kqueue"; then - test "x$silent" != "xyes" && echo " setting ac_cv_func_kqueue to \"no\"" - ac_cv_func_kqueue="no" - fi - - - if test -z "$ac_cv_func_poll"; then - test "x$silent" != "xyes" && echo " setting ac_cv_func_poll to \"no\"" - ac_cv_func_poll="no" - fi - # See issue 34332 - ;; - *-apple-darwin1[01].*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DDARWIN_10\"" - CPPFLAGS="-DDARWIN_10" - else - apr_addto_bugger="-DDARWIN_10" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - esac - ;; - *-dec-osf*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DOSF1\"" - CPPFLAGS="-DOSF1" - else - apr_addto_bugger="-DOSF1" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - # process-shared mutexes don't seem to work in Tru64 5.0 - - if test -z "$apr_cv_process_shared_works"; then - test "x$silent" != "xyes" && echo " setting apr_cv_process_shared_works to \"no\"" - apr_cv_process_shared_works="no" - fi - - ;; - *-nto-qnx*) - ;; - *-qnx) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DQNX\"" - CPPFLAGS="-DQNX" - else - apr_addto_bugger="-DQNX" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-N128k -lunix\"" - LIBS="-N128k -lunix" - else - apr_addto_bugger="-N128k -lunix" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - *-qnx32) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DQNX\"" - CPPFLAGS="-DQNX" - else - apr_addto_bugger="-DQNX" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-mf -3\"" - CFLAGS="-mf -3" - else - apr_addto_bugger="-mf -3" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-N128k -lunix\"" - LIBS="-N128k -lunix" - else - apr_addto_bugger="-N128k -lunix" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - *-isc4*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-posix -DISC\"" - CPPFLAGS="-posix -DISC" - else - apr_addto_bugger="-posix -DISC" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$LDFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting LDFLAGS to \"-posix\"" - LDFLAGS="-posix" - else - apr_addto_bugger="-posix" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LDFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LDFLAGS" - LDFLAGS="$LDFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-linet\"" - LIBS="-linet" - else - apr_addto_bugger="-linet" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - *-sco3.2v[234]*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSCO -D_REENTRANT\"" - CPPFLAGS="-DSCO -D_REENTRANT" - else - apr_addto_bugger="-DSCO -D_REENTRANT" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - if test "$GCC" = "no"; then - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-Oacgiltz\"" - CFLAGS="-Oacgiltz" - else - apr_addto_bugger="-Oacgiltz" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - fi - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lPW -lmalloc\"" - LIBS="-lPW -lmalloc" - else - apr_addto_bugger="-lPW -lmalloc" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - *-sco3.2v5*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSCO5 -D_REENTRANT\"" - CPPFLAGS="-DSCO5 -D_REENTRANT" - else - apr_addto_bugger="-DSCO5 -D_REENTRANT" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *-sco_sv*|*-SCO_SV*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSCO -D_REENTRANT\"" - CPPFLAGS="-DSCO -D_REENTRANT" - else - apr_addto_bugger="-DSCO -D_REENTRANT" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lPW -lmalloc\"" - LIBS="-lPW -lmalloc" - else - apr_addto_bugger="-lPW -lmalloc" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - *-solaris2*) - PLATOSVERS=`echo $host | sed 's/^.*solaris2.//'` - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSOLARIS2=$PLATOSVERS -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT\"" - CPPFLAGS="-DSOLARIS2=$PLATOSVERS -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT" - else - apr_addto_bugger="-DSOLARIS2=$PLATOSVERS -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - if test $PLATOSVERS -ge 10; then - - if test -z "$apr_lock_method"; then - test "x$silent" != "xyes" && echo " setting apr_lock_method to \"USE_PROC_PTHREAD_SERIALIZE\"" - apr_lock_method="USE_PROC_PTHREAD_SERIALIZE" - fi - - else - - if test -z "$apr_lock_method"; then - test "x$silent" != "xyes" && echo " setting apr_lock_method to \"USE_FCNTL_SERIALIZE\"" - apr_lock_method="USE_FCNTL_SERIALIZE" - fi - - fi - # readdir64_r error handling seems broken on Solaris (at least - # up till 2.8) -- it will return -1 at end-of-directory. - - if test -z "$ac_cv_func_readdir64_r"; then - test "x$silent" != "xyes" && echo " setting ac_cv_func_readdir64_r to \"no\"" - ac_cv_func_readdir64_r="no" - fi - - ;; - *-sunos4*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSUNOS4\"" - CPPFLAGS="-DSUNOS4" - else - apr_addto_bugger="-DSUNOS4" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *-unixware1) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DUW=100\"" - CPPFLAGS="-DUW=100" - else - apr_addto_bugger="-DUW=100" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *-unixware2) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DUW=200\"" - CPPFLAGS="-DUW=200" - else - apr_addto_bugger="-DUW=200" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lgen\"" - LIBS="-lgen" - else - apr_addto_bugger="-lgen" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - *-unixware211) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DUW=211\"" - CPPFLAGS="-DUW=211" - else - apr_addto_bugger="-DUW=211" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lgen\"" - LIBS="-lgen" - else - apr_addto_bugger="-lgen" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - *-unixware212) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DUW=212\"" - CPPFLAGS="-DUW=212" - else - apr_addto_bugger="-DUW=212" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lgen\"" - LIBS="-lgen" - else - apr_addto_bugger="-lgen" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - *-unixware7) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DUW=700\"" - CPPFLAGS="-DUW=700" - else - apr_addto_bugger="-DUW=700" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lgen\"" - LIBS="-lgen" - else - apr_addto_bugger="-lgen" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - maxion-*-sysv4*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSVR4\"" - CPPFLAGS="-DSVR4" - else - apr_addto_bugger="-DSVR4" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lc -lgen\"" - LIBS="-lc -lgen" - else - apr_addto_bugger="-lc -lgen" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - *-*-powermax*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSVR4\"" - CPPFLAGS="-DSVR4" - else - apr_addto_bugger="-DSVR4" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lgen\"" - LIBS="-lgen" - else - apr_addto_bugger="-lgen" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - TPF) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DTPF -D_POSIX_SOURCE\"" - CPPFLAGS="-DTPF -D_POSIX_SOURCE" - else - apr_addto_bugger="-DTPF -D_POSIX_SOURCE" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - bs2000*-siemens-sysv*) - - if test -z "$CFLAGS"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-O\"" - CFLAGS="-O" - fi - - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSVR4 -D_XPG_IV -D_KMEMUSER\"" - CPPFLAGS="-DSVR4 -D_XPG_IV -D_KMEMUSER" - else - apr_addto_bugger="-DSVR4 -D_XPG_IV -D_KMEMUSER" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lsocket\"" - LIBS="-lsocket" - else - apr_addto_bugger="-lsocket" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - - if test -z "$enable_threads"; then - test "x$silent" != "xyes" && echo " setting enable_threads to \"no\"" - enable_threads="no" - fi - - ;; - *-siemens-sysv4*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSVR4 -D_XPG_IV -DHAS_DLFCN -DUSE_MMAP_FILES -DUSE_SYSVSEM_SERIALIZED_ACCEPT\"" - CPPFLAGS="-DSVR4 -D_XPG_IV -DHAS_DLFCN -DUSE_MMAP_FILES -DUSE_SYSVSEM_SERIALIZED_ACCEPT" - else - apr_addto_bugger="-DSVR4 -D_XPG_IV -DHAS_DLFCN -DUSE_MMAP_FILES -DUSE_SYSVSEM_SERIALIZED_ACCEPT" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lc\"" - LIBS="-lc" - else - apr_addto_bugger="-lc" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - pyramid-pyramid-svr4) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSVR4 -DNO_LONG_DOUBLE\"" - CPPFLAGS="-DSVR4 -DNO_LONG_DOUBLE" - else - apr_addto_bugger="-DSVR4 -DNO_LONG_DOUBLE" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lc\"" - LIBS="-lc" - else - apr_addto_bugger="-lc" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - DS/90\ 7000-*-sysv4*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DUXPDS\"" - CPPFLAGS="-DUXPDS" - else - apr_addto_bugger="-DUXPDS" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *-tandem-sysv4*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSVR4\"" - CPPFLAGS="-DSVR4" - else - apr_addto_bugger="-DSVR4" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *-ncr-sysv4) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSVR4 -DMPRAS\"" - CPPFLAGS="-DSVR4 -DMPRAS" - else - apr_addto_bugger="-DSVR4 -DMPRAS" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lc -L/usr/ucblib -lucb\"" - LIBS="-lc -L/usr/ucblib -lucb" - else - apr_addto_bugger="-lc -L/usr/ucblib -lucb" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - *-sysv4*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSVR4\"" - CPPFLAGS="-DSVR4" - else - apr_addto_bugger="-DSVR4" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lc\"" - LIBS="-lc" - else - apr_addto_bugger="-lc" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - 88k-encore-sysv4) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSVR4 -DENCORE\"" - CPPFLAGS="-DSVR4 -DENCORE" - else - apr_addto_bugger="-DSVR4 -DENCORE" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lPW\"" - LIBS="-lPW" - else - apr_addto_bugger="-lPW" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - *-uts*) - PLATOSVERS=`echo $host | sed 's/^.*,//'` - case $PLATOSVERS in - 2*) - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DUTS21\"" - CPPFLAGS="-DUTS21" - else - apr_addto_bugger="-DUTS21" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-Xa -eft\"" - CFLAGS="-Xa -eft" - else - apr_addto_bugger="-Xa -eft" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lbsd -la\"" - LIBS="-lbsd -la" - else - apr_addto_bugger="-lbsd -la" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - *) - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSVR4\"" - CPPFLAGS="-DSVR4" - else - apr_addto_bugger="-DSVR4" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-Xa\"" - CFLAGS="-Xa" - else - apr_addto_bugger="-Xa" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - ;; - esac - ;; - *-ultrix) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DULTRIX\"" - CPPFLAGS="-DULTRIX" - else - apr_addto_bugger="-DULTRIX" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - test "x$silent" != "xyes" && echo " forcing SHELL to \"/bin/sh5\"" - SHELL="/bin/sh5" - - ;; - *powerpc-tenon-machten*) - - if test "x$LDFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting LDFLAGS to \"-Xlstack=0x14000 -Xldelcsect\"" - LDFLAGS="-Xlstack=0x14000 -Xldelcsect" - else - apr_addto_bugger="-Xlstack=0x14000 -Xldelcsect" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LDFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LDFLAGS" - LDFLAGS="$LDFLAGS $i" - fi - done - fi - - ;; - *-machten*) - - if test "x$LDFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting LDFLAGS to \"-stack 0x14000\"" - LDFLAGS="-stack 0x14000" - else - apr_addto_bugger="-stack 0x14000" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LDFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LDFLAGS" - LDFLAGS="$LDFLAGS $i" - fi - done - fi - - ;; - *convex-v11*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DCONVEXOS11\"" - CPPFLAGS="-DCONVEXOS11" - else - apr_addto_bugger="-DCONVEXOS11" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test -z "$CFLAGS"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-O1\"" - CFLAGS="-O1" - fi - - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-ext\"" - CFLAGS="-ext" - else - apr_addto_bugger="-ext" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - ;; - i860-intel-osf1) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DPARAGON\"" - CPPFLAGS="-DPARAGON" - else - apr_addto_bugger="-DPARAGON" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *-sequent-ptx2.*.*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSEQUENT=20\"" - CPPFLAGS="-DSEQUENT=20" - else - apr_addto_bugger="-DSEQUENT=20" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-Wc,-pw\"" - CFLAGS="-Wc,-pw" - else - apr_addto_bugger="-Wc,-pw" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-linet -lc -lseq\"" - LIBS="-linet -lc -lseq" - else - apr_addto_bugger="-linet -lc -lseq" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - *-sequent-ptx4.0.*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSEQUENT=40\"" - CPPFLAGS="-DSEQUENT=40" - else - apr_addto_bugger="-DSEQUENT=40" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-Wc,-pw\"" - CFLAGS="-Wc,-pw" - else - apr_addto_bugger="-Wc,-pw" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-linet -lc\"" - LIBS="-linet -lc" - else - apr_addto_bugger="-linet -lc" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - *-sequent-ptx4.[123].*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSEQUENT=41\"" - CPPFLAGS="-DSEQUENT=41" - else - apr_addto_bugger="-DSEQUENT=41" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-Wc,-pw\"" - CFLAGS="-Wc,-pw" - else - apr_addto_bugger="-Wc,-pw" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lc\"" - LIBS="-lc" - else - apr_addto_bugger="-lc" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - *-sequent-ptx4.4.*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSEQUENT=44\"" - CPPFLAGS="-DSEQUENT=44" - else - apr_addto_bugger="-DSEQUENT=44" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-Wc,-pw\"" - CFLAGS="-Wc,-pw" - else - apr_addto_bugger="-Wc,-pw" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lc\"" - LIBS="-lc" - else - apr_addto_bugger="-lc" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - *-sequent-ptx4.5.*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSEQUENT=45\"" - CPPFLAGS="-DSEQUENT=45" - else - apr_addto_bugger="-DSEQUENT=45" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-Wc,-pw\"" - CFLAGS="-Wc,-pw" - else - apr_addto_bugger="-Wc,-pw" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lc\"" - LIBS="-lc" - else - apr_addto_bugger="-lc" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - *-sequent-ptx5.0.*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSEQUENT=50\"" - CPPFLAGS="-DSEQUENT=50" - else - apr_addto_bugger="-DSEQUENT=50" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-Wc,-pw\"" - CFLAGS="-Wc,-pw" - else - apr_addto_bugger="-Wc,-pw" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lc\"" - LIBS="-lc" - else - apr_addto_bugger="-lc" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - *NEWS-OS*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DNEWSOS\"" - CPPFLAGS="-DNEWSOS" - else - apr_addto_bugger="-DNEWSOS" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *-riscix) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DRISCIX\"" - CPPFLAGS="-DRISCIX" - else - apr_addto_bugger="-DRISCIX" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test -z "$CFLAGS"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-O\"" - CFLAGS="-O" - fi - - ;; - *-irix*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-D_POSIX_THREAD_SAFE_FUNCTIONS\"" - CPPFLAGS="-D_POSIX_THREAD_SAFE_FUNCTIONS" - else - apr_addto_bugger="-D_POSIX_THREAD_SAFE_FUNCTIONS" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *beos*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DBEOS\"" - CPPFLAGS="-DBEOS" - else - apr_addto_bugger="-DBEOS" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - PLATOSVERS=`uname -r` - - if test -z "$apr_process_lock_is_global"; then - test "x$silent" != "xyes" && echo " setting apr_process_lock_is_global to \"yes\"" - apr_process_lock_is_global="yes" - fi - - case $PLATOSVERS in - 5.0.4) - - if test "x$LDFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting LDFLAGS to \"-L/boot/beos/system/lib\"" - LDFLAGS="-L/boot/beos/system/lib" - else - apr_addto_bugger="-L/boot/beos/system/lib" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LDFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LDFLAGS" - LDFLAGS="$LDFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lbind -lsocket\"" - LIBS="-lbind -lsocket" - else - apr_addto_bugger="-lbind -lsocket" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DBONE7\"" - CPPFLAGS="-DBONE7" - else - apr_addto_bugger="-DBONE7" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - 5.1) - - if test "x$LDFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting LDFLAGS to \"-L/boot/beos/system/lib\"" - LDFLAGS="-L/boot/beos/system/lib" - else - apr_addto_bugger="-L/boot/beos/system/lib" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LDFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LDFLAGS" - LDFLAGS="$LDFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lbind -lsocket\"" - LIBS="-lbind -lsocket" - else - apr_addto_bugger="-lbind -lsocket" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - esac - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSIGPROCMASK_SETS_THREAD_MASK\"" - CPPFLAGS="-DSIGPROCMASK_SETS_THREAD_MASK" - else - apr_addto_bugger="-DSIGPROCMASK_SETS_THREAD_MASK" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - 4850-*.*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSVR4 -DMPRAS\"" - CPPFLAGS="-DSVR4 -DMPRAS" - else - apr_addto_bugger="-DSVR4 -DMPRAS" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lc -L/usr/ucblib -lucb\"" - LIBS="-lc -L/usr/ucblib -lucb" - else - apr_addto_bugger="-lc -L/usr/ucblib -lucb" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - drs6000*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DSVR4\"" - CPPFLAGS="-DSVR4" - else - apr_addto_bugger="-DSVR4" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lc -L/usr/ucblib -lucb\"" - LIBS="-lc -L/usr/ucblib -lucb" - else - apr_addto_bugger="-lc -L/usr/ucblib -lucb" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ;; - m88k-*-CX/SX|CYBER) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-D_CX_SX\"" - CPPFLAGS="-D_CX_SX" - else - apr_addto_bugger="-D_CX_SX" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-Xa\"" - CFLAGS="-Xa" - else - apr_addto_bugger="-Xa" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - ;; - *-tandem-oss) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-D_TANDEM_SOURCE -D_XOPEN_SOURCE_EXTENDED=1\"" - CPPFLAGS="-D_TANDEM_SOURCE -D_XOPEN_SOURCE_EXTENDED=1" - else - apr_addto_bugger="-D_TANDEM_SOURCE -D_XOPEN_SOURCE_EXTENDED=1" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *-ibm-os390) - - if test -z "$apr_lock_method"; then - test "x$silent" != "xyes" && echo " setting apr_lock_method to \"USE_SYSVSEM_SERIALIZE\"" - apr_lock_method="USE_SYSVSEM_SERIALIZE" - fi - - - if test -z "$apr_sysvsem_is_global"; then - test "x$silent" != "xyes" && echo " setting apr_sysvsem_is_global to \"yes\"" - apr_sysvsem_is_global="yes" - fi - - - if test -z "$apr_gethostbyname_is_thread_safe"; then - test "x$silent" != "xyes" && echo " setting apr_gethostbyname_is_thread_safe to \"yes\"" - apr_gethostbyname_is_thread_safe="yes" - fi - - - if test -z "$apr_gethostbyaddr_is_thread_safe"; then - test "x$silent" != "xyes" && echo " setting apr_gethostbyaddr_is_thread_safe to \"yes\"" - apr_gethostbyaddr_is_thread_safe="yes" - fi - - - if test -z "$apr_getservbyname_is_thread_safe"; then - test "x$silent" != "xyes" && echo " setting apr_getservbyname_is_thread_safe to \"yes\"" - apr_getservbyname_is_thread_safe="yes" - fi - - -$as_echo "#define HAVE_ZOS_PTHREADS 1" >>confdefs.h - - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-U_NO_PROTO -DSIGPROCMASK_SETS_THREAD_MASK -DTCP_NODELAY=1\"" - CPPFLAGS="-U_NO_PROTO -DSIGPROCMASK_SETS_THREAD_MASK -DTCP_NODELAY=1" - else - apr_addto_bugger="-U_NO_PROTO -DSIGPROCMASK_SETS_THREAD_MASK -DTCP_NODELAY=1" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *-ibm-as400) - - if test -z "$apr_lock_method"; then - test "x$silent" != "xyes" && echo " setting apr_lock_method to \"USE_SYSVSEM_SERIALIZE\"" - apr_lock_method="USE_SYSVSEM_SERIALIZE" - fi - - - if test -z "$apr_process_lock_is_global"; then - test "x$silent" != "xyes" && echo " setting apr_process_lock_is_global to \"yes\"" - apr_process_lock_is_global="yes" - fi - - - if test -z "$apr_gethostbyname_is_thread_safe"; then - test "x$silent" != "xyes" && echo " setting apr_gethostbyname_is_thread_safe to \"yes\"" - apr_gethostbyname_is_thread_safe="yes" - fi - - - if test -z "$apr_gethostbyaddr_is_thread_safe"; then - test "x$silent" != "xyes" && echo " setting apr_gethostbyaddr_is_thread_safe to \"yes\"" - apr_gethostbyaddr_is_thread_safe="yes" - fi - - - if test -z "$apr_getservbyname_is_thread_safe"; then - test "x$silent" != "xyes" && echo " setting apr_getservbyname_is_thread_safe to \"yes\"" - apr_getservbyname_is_thread_safe="yes" - fi - - ;; - *cygwin*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DCYGWIN\"" - CPPFLAGS="-DCYGWIN" - else - apr_addto_bugger="-DCYGWIN" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - ;; - *mingw*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DWIN32 -D__MSVCRT__\"" - CPPFLAGS="-DWIN32 -D__MSVCRT__" - else - apr_addto_bugger="-DWIN32 -D__MSVCRT__" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$LDFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting LDFLAGS to \"-Wl,--enable-auto-import,--subsystem,console\"" - LDFLAGS="-Wl,--enable-auto-import,--subsystem,console" - else - apr_addto_bugger="-Wl,--enable-auto-import,--subsystem,console" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LDFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LDFLAGS" - LDFLAGS="$LDFLAGS $i" - fi - done - fi - - - if test -z "$have_unicode_fs"; then - test "x$silent" != "xyes" && echo " setting have_unicode_fs to \"1\"" - have_unicode_fs="1" - fi - - - if test -z "$have_proc_invoked"; then - test "x$silent" != "xyes" && echo " setting have_proc_invoked to \"1\"" - have_proc_invoked="1" - fi - - - if test -z "$apr_lock_method"; then - test "x$silent" != "xyes" && echo " setting apr_lock_method to \"win32\"" - apr_lock_method="win32" - fi - - - if test -z "$apr_process_lock_is_global"; then - test "x$silent" != "xyes" && echo " setting apr_process_lock_is_global to \"yes\"" - apr_process_lock_is_global="yes" - fi - - - if test -z "$apr_cv_use_lfs64"; then - test "x$silent" != "xyes" && echo " setting apr_cv_use_lfs64 to \"yes\"" - apr_cv_use_lfs64="yes" - fi - - - if test -z "$apr_cv_osuuid"; then - test "x$silent" != "xyes" && echo " setting apr_cv_osuuid to \"yes\"" - apr_cv_osuuid="yes" - fi - - - if test -z "$apr_cv_tcp_nodelay_with_cork"; then - test "x$silent" != "xyes" && echo " setting apr_cv_tcp_nodelay_with_cork to \"no\"" - apr_cv_tcp_nodelay_with_cork="no" - fi - - - if test -z "$apr_thread_func"; then - test "x$silent" != "xyes" && echo " setting apr_thread_func to \"__stdcall\"" - apr_thread_func="__stdcall" - fi - - - if test -z "$ac_cv_o_nonblock_inherited"; then - test "x$silent" != "xyes" && echo " setting ac_cv_o_nonblock_inherited to \"yes\"" - ac_cv_o_nonblock_inherited="yes" - fi - - - if test -z "$ac_cv_tcp_nodelay_inherited"; then - test "x$silent" != "xyes" && echo " setting ac_cv_tcp_nodelay_inherited to \"yes\"" - ac_cv_tcp_nodelay_inherited="yes" - fi - - - if test -z "$ac_cv_file__dev_zero"; then - test "x$silent" != "xyes" && echo " setting ac_cv_file__dev_zero to \"no\"" - ac_cv_file__dev_zero="no" - fi - - - if test -z "$ac_cv_func_setpgrp_void"; then - test "x$silent" != "xyes" && echo " setting ac_cv_func_setpgrp_void to \"no\"" - ac_cv_func_setpgrp_void="no" - fi - - - if test -z "$ac_cv_func_mmap"; then - test "x$silent" != "xyes" && echo " setting ac_cv_func_mmap to \"yes\"" - ac_cv_func_mmap="yes" - fi - - - if test -z "$ac_cv_define_sockaddr_in6"; then - test "x$silent" != "xyes" && echo " setting ac_cv_define_sockaddr_in6 to \"yes\"" - ac_cv_define_sockaddr_in6="yes" - fi - - - if test -z "$ac_cv_working_getaddrinfo"; then - test "x$silent" != "xyes" && echo " setting ac_cv_working_getaddrinfo to \"yes\"" - ac_cv_working_getaddrinfo="yes" - fi - - - if test -z "$ac_cv_working_getnameinfo"; then - test "x$silent" != "xyes" && echo " setting ac_cv_working_getnameinfo to \"yes\"" - ac_cv_working_getnameinfo="yes" - fi - - - if test -z "$ac_cv_func_gai_strerror"; then - test "x$silent" != "xyes" && echo " setting ac_cv_func_gai_strerror to \"yes\"" - ac_cv_func_gai_strerror="yes" - fi - - case $host in - *mingw32*) - - if test -z "$apr_has_xthread_files"; then - test "x$silent" != "xyes" && echo " setting apr_has_xthread_files to \"1\"" - apr_has_xthread_files="1" - fi - - - if test -z "$apr_has_user"; then - test "x$silent" != "xyes" && echo " setting apr_has_user to \"1\"" - apr_has_user="1" - fi - - - if test -z "$apr_procattr_user_set_requires_password"; then - test "x$silent" != "xyes" && echo " setting apr_procattr_user_set_requires_password to \"1\"" - apr_procattr_user_set_requires_password="1" - fi - - - if test -z "$ac_cv_func_sendfile"; then - test "x$silent" != "xyes" && echo " setting ac_cv_func_sendfile to \"yes\"" - ac_cv_func_sendfile="yes" - fi - - ;; - *mingwce) - - if test -z "$apr_has_xthread_files"; then - test "x$silent" != "xyes" && echo " setting apr_has_xthread_files to \"0\"" - apr_has_xthread_files="0" - fi - - - if test -z "$apr_has_user"; then - test "x$silent" != "xyes" && echo " setting apr_has_user to \"0\"" - apr_has_user="0" - fi - - - if test -z "$apr_procattr_user_set_requires_password"; then - test "x$silent" != "xyes" && echo " setting apr_procattr_user_set_requires_password to \"0\"" - apr_procattr_user_set_requires_password="0" - fi - - - if test -z "$ac_cv_func_sendfile"; then - test "x$silent" != "xyes" && echo " setting ac_cv_func_sendfile to \"no\"" - ac_cv_func_sendfile="no" - fi - - ;; - esac - ;; - esac - -fi - - -DEFAULT_OSDIR="unix" -echo "(Default will be ${DEFAULT_OSDIR})" - -apr_modules="file_io network_io threadproc misc locks time mmap shmem user memory atomic poll support random" - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } -set x ${MAKE-make} -ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat >conftest.make <<\_ACEOF -SHELL = /bin/sh -all: - @echo '@@@%%%=$(MAKE)=@@@%%%' -_ACEOF -# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. -case `${MAKE-make} -f conftest.make 2>/dev/null` in - *@@@%%%=?*=@@@%%%*) - eval ac_cv_prog_make_${ac_make}_set=yes;; - *) - eval ac_cv_prog_make_${ac_make}_set=no;; -esac -rm -f conftest.make -fi -if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - SET_MAKE= -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - SET_MAKE="MAKE=${MAKE-make}" -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if ${ac_cv_prog_CPP+:} false; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -$as_echo "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -for ac_prog in gawk mawk nawk awk -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AWK+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$AWK"; then - ac_cv_prog_AWK="$AWK" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_AWK="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -AWK=$ac_cv_prog_AWK -if test -n "$AWK"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 -$as_echo "$AWK" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$AWK" && break -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 -$as_echo_n "checking whether ln -s works... " >&6; } -LN_S=$as_ln_s -if test "$LN_S" = "ln -s"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 -$as_echo "no, using $LN_S" >&6; } -fi - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. -set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_RANLIB+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -RANLIB=$ac_cv_prog_RANLIB -if test -n "$RANLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 -$as_echo "$RANLIB" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_RANLIB"; then - ac_ct_RANLIB=$RANLIB - # Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_RANLIB"; then - ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_RANLIB="ranlib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB -if test -n "$ac_ct_RANLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 -$as_echo "$ac_ct_RANLIB" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_RANLIB" = x; then - RANLIB=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - RANLIB=$ac_ct_RANLIB - fi -else - RANLIB="$ac_cv_prog_RANLIB" -fi - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AmigaOS /C/install, which installs bootblocks on floppy discs -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# OS/2's system install, which has a completely different semantic -# ./install, which can be erroneously created by make from ./install.sh. -# Reject install programs that cannot install multiple files. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 -$as_echo_n "checking for a BSD-compatible install... " >&6; } -if test -z "$INSTALL"; then -if ${ac_cv_path_install+:} false; then : - $as_echo_n "(cached) " >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in #(( - ./ | .// | /[cC]/* | \ - /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ - /usr/ucb/* ) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then - if test $ac_prog = install && - grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - elif test $ac_prog = install && - grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # program-specific install script used by HP pwplus--don't use. - : - else - rm -rf conftest.one conftest.two conftest.dir - echo one > conftest.one - echo two > conftest.two - mkdir conftest.dir - if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && - test -s conftest.one && test -s conftest.two && - test -s conftest.dir/conftest.one && - test -s conftest.dir/conftest.two - then - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 - fi - fi - fi - done - done - ;; -esac - - done -IFS=$as_save_IFS - -rm -rf conftest.one conftest.two conftest.dir - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL=$ac_cv_path_install - else - # As a last resort, use the slow shell script. Don't cache a - # value for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the value is a relative name. - INSTALL=$ac_install_sh - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 -$as_echo "$INSTALL" >&6; } - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - -# Extract the first word of "rm", so it can be a program name with args. -set dummy rm; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_RM+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$RM"; then - ac_cv_prog_RM="$RM" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_RM="rm" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -RM=$ac_cv_prog_RM -if test -n "$RM"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RM" >&5 -$as_echo "$RM" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -# Extract the first word of "as", so it can be a program name with args. -set dummy as; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AS+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$AS"; then - ac_cv_prog_AS="$AS" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_AS="as" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -AS=$ac_cv_prog_AS -if test -n "$AS"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AS" >&5 -$as_echo "$AS" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -# Extract the first word of "cpp", so it can be a program name with args. -set dummy cpp; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ASCPP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ASCPP"; then - ac_cv_prog_ASCPP="$ASCPP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ASCPP="cpp" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ASCPP=$ac_cv_prog_ASCPP -if test -n "$ASCPP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ASCPP" >&5 -$as_echo "$ASCPP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. -set dummy ${ac_tool_prefix}ar; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AR+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$AR"; then - ac_cv_prog_AR="$AR" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_AR="${ac_tool_prefix}ar" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -AR=$ac_cv_prog_AR -if test -n "$AR"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 -$as_echo "$AR" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_AR"; then - ac_ct_AR=$AR - # Extract the first word of "ar", so it can be a program name with args. -set dummy ar; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_AR+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_AR"; then - ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_AR="ar" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_AR=$ac_cv_prog_ac_ct_AR -if test -n "$ac_ct_AR"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 -$as_echo "$ac_ct_AR" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_AR" = x; then - AR="ar" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - AR=$ac_ct_AR - fi -else - AR="$ac_cv_prog_AR" -fi - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if ${ac_cv_path_GREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_GREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_GREP=$GREP -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } -if ${ac_cv_path_EGREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_EGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_EGREP=$EGREP -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if ${ac_cv_header_stdc+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_stdc=yes -else - ac_cv_header_stdc=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -else - ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -$as_echo "#define STDC_HEADERS 1" >>confdefs.h - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default -" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - - - ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" -if test "x$ac_cv_header_minix_config_h" = xyes; then : - MINIX=yes -else - MINIX= -fi - - - if test "$MINIX" = yes; then - -$as_echo "#define _POSIX_SOURCE 1" >>confdefs.h - - -$as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h - - -$as_echo "#define _MINIX 1" >>confdefs.h - - fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 -$as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } -if ${ac_cv_safe_to_define___extensions__+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -# define __EXTENSIONS__ 1 - $ac_includes_default -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_safe_to_define___extensions__=yes -else - ac_cv_safe_to_define___extensions__=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5 -$as_echo "$ac_cv_safe_to_define___extensions__" >&6; } - test $ac_cv_safe_to_define___extensions__ = yes && - $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h - - $as_echo "#define _ALL_SOURCE 1" >>confdefs.h - - $as_echo "#define _GNU_SOURCE 1" >>confdefs.h - - $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h - - $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing strerror" >&5 -$as_echo_n "checking for library containing strerror... " >&6; } -if ${ac_cv_search_strerror+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char strerror (); -int -main () -{ -return strerror (); - ; - return 0; -} -_ACEOF -for ac_lib in '' cposix; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_strerror=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_strerror+:} false; then : - break -fi -done -if ${ac_cv_search_strerror+:} false; then : - -else - ac_cv_search_strerror=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_strerror" >&5 -$as_echo "$ac_cv_search_strerror" >&6; } -ac_res=$ac_cv_search_strerror -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether system uses EBCDIC" >&5 -$as_echo_n "checking whether system uses EBCDIC... " >&6; } -if ${ac_cv_ebcdic+:} false; then : - $as_echo_n "(cached) " >&6 -else - - if test "$cross_compiling" = yes; then : - - ac_cv_ebcdic="no" - -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int main(void) { - return (unsigned char)'A' != (unsigned char)0xC1; -} - -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - - ac_cv_ebcdic="yes" - -else - - ac_cv_ebcdic="no" - -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_ebcdic" >&5 -$as_echo "$ac_cv_ebcdic" >&6; } - if test "$ac_cv_ebcdic" = "yes"; then - apr_charset_ebcdic=1 - else - apr_charset_ebcdic=0 - fi - - - -APR_LIBNAME="apr${libsuffix}" - - -echo "performing libtool configuration..." - -# Check whether --enable-experimental-libtool was given. -if test "${enable_experimental_libtool+set}" = set; then : - enableval=$enable_experimental_libtool; experimental_libtool=$enableval -else - experimental_libtool=no -fi - - -if test "x$Xsed" = "x"; then - Xsed="$SED -e 1s/^X//" -fi - -case $host in -*-os2*) - # Use a custom-made libtool replacement - echo "using aplibtool" - LIBTOOL="$srcdir/build/aplibtool" - gcc $CFLAGS $CPPFLAGS -o $LIBTOOL.exe $LIBTOOL.c - ;; -*) - if test "x$LTFLAGS" = "x"; then - LTFLAGS='--silent' - fi - if test "$experimental_libtool" = "yes"; then - # Use a custom-made libtool replacement - echo "using jlibtool" - LIBTOOL="$apr_builddir/libtool" - LIBTOOL_SRC="$apr_srcdir/build/jlibtool.c" - $CC $CFLAGS $CPPFLAGS -o $LIBTOOL $LIBTOOL_SRC - eval `$apr_builddir/libtool --config | grep "^shlibpath_var=[A-Z_]*$"` - if test "x$shlibpath_var" = "x"; then - shlibpath_var=REPLACE_WITH_YOUR_SHLIBPATH_VAR - fi - else - enable_win32_dll=yes - -case $host in -*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. -set dummy ${ac_tool_prefix}as; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AS+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$AS"; then - ac_cv_prog_AS="$AS" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_AS="${ac_tool_prefix}as" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -AS=$ac_cv_prog_AS -if test -n "$AS"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AS" >&5 -$as_echo "$AS" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_AS"; then - ac_ct_AS=$AS - # Extract the first word of "as", so it can be a program name with args. -set dummy as; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_AS+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_AS"; then - ac_cv_prog_ac_ct_AS="$ac_ct_AS" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_AS="as" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_AS=$ac_cv_prog_ac_ct_AS -if test -n "$ac_ct_AS"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AS" >&5 -$as_echo "$ac_ct_AS" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_AS" = x; then - AS="false" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - AS=$ac_ct_AS - fi -else - AS="$ac_cv_prog_AS" -fi - - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. -set dummy ${ac_tool_prefix}dlltool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_DLLTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$DLLTOOL"; then - ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -DLLTOOL=$ac_cv_prog_DLLTOOL -if test -n "$DLLTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 -$as_echo "$DLLTOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_DLLTOOL"; then - ac_ct_DLLTOOL=$DLLTOOL - # Extract the first word of "dlltool", so it can be a program name with args. -set dummy dlltool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_DLLTOOL"; then - ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_DLLTOOL="dlltool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL -if test -n "$ac_ct_DLLTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 -$as_echo "$ac_ct_DLLTOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_DLLTOOL" = x; then - DLLTOOL="false" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - DLLTOOL=$ac_ct_DLLTOOL - fi -else - DLLTOOL="$ac_cv_prog_DLLTOOL" -fi - - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. -set dummy ${ac_tool_prefix}objdump; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OBJDUMP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OBJDUMP"; then - ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OBJDUMP=$ac_cv_prog_OBJDUMP -if test -n "$OBJDUMP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 -$as_echo "$OBJDUMP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OBJDUMP"; then - ac_ct_OBJDUMP=$OBJDUMP - # Extract the first word of "objdump", so it can be a program name with args. -set dummy objdump; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OBJDUMP"; then - ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_OBJDUMP="objdump" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP -if test -n "$ac_ct_OBJDUMP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 -$as_echo "$ac_ct_OBJDUMP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OBJDUMP" = x; then - OBJDUMP="false" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OBJDUMP=$ac_ct_OBJDUMP - fi -else - OBJDUMP="$ac_cv_prog_OBJDUMP" -fi - - ;; -esac - -test -z "$AS" && AS=as - - - - - -test -z "$DLLTOOL" && DLLTOOL=dlltool - - - - - -test -z "$OBJDUMP" && OBJDUMP=objdump - - - - - - - -case `pwd` in - *\ * | *\ *) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 -$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; -esac - - - -macro_version='2.4.2' -macro_revision='1.3337' - - - - - - - - - - - - - -ltmain="$ac_aux_dir/ltmain.sh" - -# Backslashify metacharacters that are still active within -# double-quoted strings. -sed_quote_subst='s/\(["`$\\]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\(["`\\]\)/\\\1/g' - -# Sed substitution to delay expansion of an escaped shell variable in a -# double_quote_subst'ed string. -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - -# Sed substitution to delay expansion of an escaped single quote. -delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' - -# Sed substitution to avoid accidental globbing in evaled expressions -no_glob_subst='s/\*/\\\*/g' - -ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO -ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 -$as_echo_n "checking how to print strings... " >&6; } -# Test print first, because it will be a builtin if present. -if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ - test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then - ECHO='print -r --' -elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then - ECHO='printf %s\n' -else - # Use this function as a fallback that always works. - func_fallback_echo () - { - eval 'cat <<_LTECHO_EOF -$1 -_LTECHO_EOF' - } - ECHO='func_fallback_echo' -fi - -# func_echo_all arg... -# Invoke $ECHO with all args, space-separated. -func_echo_all () -{ - $ECHO "" -} - -case "$ECHO" in - printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 -$as_echo "printf" >&6; } ;; - print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 -$as_echo "print -r" >&6; } ;; - *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 -$as_echo "cat" >&6; } ;; -esac - - - - - - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 -$as_echo_n "checking for a sed that does not truncate output... " >&6; } -if ${ac_cv_path_SED+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ - for ac_i in 1 2 3 4 5 6 7; do - ac_script="$ac_script$as_nl$ac_script" - done - echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed - { ac_script=; unset ac_script;} - if test -z "$SED"; then - ac_path_SED_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in sed gsed; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue -# Check for GNU ac_path_SED and select it if it is found. - # Check for GNU $ac_path_SED -case `"$ac_path_SED" --version 2>&1` in -*GNU*) - ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo '' >> "conftest.nl" - "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_SED_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_SED="$ac_path_SED" - ac_path_SED_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_SED_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_SED"; then - as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 - fi -else - ac_cv_path_SED=$SED -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 -$as_echo "$ac_cv_path_SED" >&6; } - SED="$ac_cv_path_SED" - rm -f conftest.sed - -test -z "$SED" && SED=sed -Xsed="$SED -e 1s/^X//" - - - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 -$as_echo_n "checking for fgrep... " >&6; } -if ${ac_cv_path_FGREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 - then ac_cv_path_FGREP="$GREP -F" - else - if test -z "$FGREP"; then - ac_path_FGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in fgrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue -# Check for GNU ac_path_FGREP and select it if it is found. - # Check for GNU $ac_path_FGREP -case `"$ac_path_FGREP" --version 2>&1` in -*GNU*) - ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'FGREP' >> "conftest.nl" - "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_FGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_FGREP="$ac_path_FGREP" - ac_path_FGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_FGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_FGREP"; then - as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_FGREP=$FGREP -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 -$as_echo "$ac_cv_path_FGREP" >&6; } - FGREP="$ac_cv_path_FGREP" - - -test -z "$GREP" && GREP=grep - - - - - - - - - - - - - - - - - - - -# Check whether --with-gnu-ld was given. -if test "${with_gnu_ld+set}" = set; then : - withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes -else - with_gnu_ld=no -fi - -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 -$as_echo_n "checking for ld used by $CC... " >&6; } - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [\\/]* | ?:[\\/]*) - re_direlt='/[^/][^/]*/\.\./' - # Canonicalize the pathname of ld - ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` - while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do - ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 -$as_echo_n "checking for GNU ld... " >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 -$as_echo_n "checking for non-GNU ld... " >&6; } -fi -if ${lt_cv_path_LD+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$LD"; then - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$lt_cv_path_LD" -v 2>&1 &5 -$as_echo "$LD" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi -test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 -$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } -if ${lt_cv_prog_gnu_ld+:} false; then : - $as_echo_n "(cached) " >&6 -else - # I'd rather use --version here, but apparently some GNU lds only accept -v. -case `$LD -v 2>&1 &5 -$as_echo "$lt_cv_prog_gnu_ld" >&6; } -with_gnu_ld=$lt_cv_prog_gnu_ld - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 -$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } -if ${lt_cv_path_NM+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$NM"; then - # Let the user override the test. - lt_cv_path_NM="$NM" -else - lt_nm_to_check="${ac_tool_prefix}nm" - if test -n "$ac_tool_prefix" && test "$build" = "$host"; then - lt_nm_to_check="$lt_nm_to_check nm" - fi - for lt_tmp_nm in $lt_nm_to_check; do - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - tmp_nm="$ac_dir/$lt_tmp_nm" - if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then - # Check to see if the nm accepts a BSD-compat flag. - # Adding the `sed 1q' prevents false positives on HP-UX, which says: - # nm: unknown option "B" ignored - # Tru64's nm complains that /dev/null is an invalid object file - case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in - */dev/null* | *'Invalid file or object type'*) - lt_cv_path_NM="$tmp_nm -B" - break - ;; - *) - case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in - */dev/null*) - lt_cv_path_NM="$tmp_nm -p" - break - ;; - *) - lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but - continue # so that we can try to find one that supports BSD flags - ;; - esac - ;; - esac - fi - done - IFS="$lt_save_ifs" - done - : ${lt_cv_path_NM=no} -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 -$as_echo "$lt_cv_path_NM" >&6; } -if test "$lt_cv_path_NM" != "no"; then - NM="$lt_cv_path_NM" -else - # Didn't find any BSD compatible name lister, look for dumpbin. - if test -n "$DUMPBIN"; then : - # Let the user override the test. - else - if test -n "$ac_tool_prefix"; then - for ac_prog in dumpbin "link -dump" - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_DUMPBIN+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$DUMPBIN"; then - ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -DUMPBIN=$ac_cv_prog_DUMPBIN -if test -n "$DUMPBIN"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 -$as_echo "$DUMPBIN" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$DUMPBIN" && break - done -fi -if test -z "$DUMPBIN"; then - ac_ct_DUMPBIN=$DUMPBIN - for ac_prog in dumpbin "link -dump" -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_DUMPBIN"; then - ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN -if test -n "$ac_ct_DUMPBIN"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 -$as_echo "$ac_ct_DUMPBIN" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_DUMPBIN" && break -done - - if test "x$ac_ct_DUMPBIN" = x; then - DUMPBIN=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - DUMPBIN=$ac_ct_DUMPBIN - fi -fi - - case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in - *COFF*) - DUMPBIN="$DUMPBIN -symbols" - ;; - *) - DUMPBIN=: - ;; - esac - fi - - if test "$DUMPBIN" != ":"; then - NM="$DUMPBIN" - fi -fi -test -z "$NM" && NM=nm - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 -$as_echo_n "checking the name lister ($NM) interface... " >&6; } -if ${lt_cv_nm_interface+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_nm_interface="BSD nm" - echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) - (eval "$ac_compile" 2>conftest.err) - cat conftest.err >&5 - (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) - (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) - cat conftest.err >&5 - (eval echo "\"\$as_me:$LINENO: output\"" >&5) - cat conftest.out >&5 - if $GREP 'External.*some_variable' conftest.out > /dev/null; then - lt_cv_nm_interface="MS dumpbin" - fi - rm -f conftest* -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 -$as_echo "$lt_cv_nm_interface" >&6; } - -# find the maximum length of command line arguments -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 -$as_echo_n "checking the maximum length of command line arguments... " >&6; } -if ${lt_cv_sys_max_cmd_len+:} false; then : - $as_echo_n "(cached) " >&6 -else - i=0 - teststring="ABCD" - - case $build_os in - msdosdjgpp*) - # On DJGPP, this test can blow up pretty badly due to problems in libc - # (any single argument exceeding 2000 bytes causes a buffer overrun - # during glob expansion). Even if it were fixed, the result of this - # check would be larger than it should be. - lt_cv_sys_max_cmd_len=12288; # 12K is about right - ;; - - gnu*) - # Under GNU Hurd, this test is not required because there is - # no limit to the length of command line arguments. - # Libtool will interpret -1 as no limit whatsoever - lt_cv_sys_max_cmd_len=-1; - ;; - - cygwin* | mingw* | cegcc*) - # On Win9x/ME, this test blows up -- it succeeds, but takes - # about 5 minutes as the teststring grows exponentially. - # Worse, since 9x/ME are not pre-emptively multitasking, - # you end up with a "frozen" computer, even though with patience - # the test eventually succeeds (with a max line length of 256k). - # Instead, let's just punt: use the minimum linelength reported by - # all of the supported platforms: 8192 (on NT/2K/XP). - lt_cv_sys_max_cmd_len=8192; - ;; - - mint*) - # On MiNT this can take a long time and run out of memory. - lt_cv_sys_max_cmd_len=8192; - ;; - - amigaos*) - # On AmigaOS with pdksh, this test takes hours, literally. - # So we just punt and use a minimum line length of 8192. - lt_cv_sys_max_cmd_len=8192; - ;; - - netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) - # This has been around since 386BSD, at least. Likely further. - if test -x /sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` - elif test -x /usr/sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` - else - lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs - fi - # And add a safety zone - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - ;; - - interix*) - # We know the value 262144 and hardcode it with a safety zone (like BSD) - lt_cv_sys_max_cmd_len=196608 - ;; - - os2*) - # The test takes a long time on OS/2. - lt_cv_sys_max_cmd_len=8192 - ;; - - osf*) - # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure - # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not - # nice to cause kernel panics so lets avoid the loop below. - # First set a reasonable default. - lt_cv_sys_max_cmd_len=16384 - # - if test -x /sbin/sysconfig; then - case `/sbin/sysconfig -q proc exec_disable_arg_limit` in - *1*) lt_cv_sys_max_cmd_len=-1 ;; - esac - fi - ;; - sco3.2v5*) - lt_cv_sys_max_cmd_len=102400 - ;; - sysv5* | sco5v6* | sysv4.2uw2*) - kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` - if test -n "$kargmax"; then - lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` - else - lt_cv_sys_max_cmd_len=32768 - fi - ;; - *) - lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` - if test -n "$lt_cv_sys_max_cmd_len"; then - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - else - # Make teststring a little bigger before we do anything with it. - # a 1K string should be a reasonable start. - for i in 1 2 3 4 5 6 7 8 ; do - teststring=$teststring$teststring - done - SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} - # If test is not a shell built-in, we'll probably end up computing a - # maximum length that is only half of the actual maximum length, but - # we can't tell. - while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ - = "X$teststring$teststring"; } >/dev/null 2>&1 && - test $i != 17 # 1/2 MB should be enough - do - i=`expr $i + 1` - teststring=$teststring$teststring - done - # Only check the string length outside the loop. - lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` - teststring= - # Add a significant safety factor because C++ compilers can tack on - # massive amounts of additional arguments before passing them to the - # linker. It appears as though 1/2 is a usable value. - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` - fi - ;; - esac - -fi - -if test -n $lt_cv_sys_max_cmd_len ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 -$as_echo "$lt_cv_sys_max_cmd_len" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 -$as_echo "none" >&6; } -fi -max_cmd_len=$lt_cv_sys_max_cmd_len - - - - - - -: ${CP="cp -f"} -: ${MV="mv -f"} -: ${RM="rm -f"} - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 -$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } -# Try some XSI features -xsi_shell=no -( _lt_dummy="a/b/c" - test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ - = c,a/b,b/c, \ - && eval 'test $(( 1 + 1 )) -eq 2 \ - && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ - && xsi_shell=yes -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 -$as_echo "$xsi_shell" >&6; } - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 -$as_echo_n "checking whether the shell understands \"+=\"... " >&6; } -lt_shell_append=no -( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ - >/dev/null 2>&1 \ - && lt_shell_append=yes -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 -$as_echo "$lt_shell_append" >&6; } - - -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - lt_unset=unset -else - lt_unset=false -fi - - - - - -# test EBCDIC or ASCII -case `echo X|tr X '\101'` in - A) # ASCII based system - # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr - lt_SP2NL='tr \040 \012' - lt_NL2SP='tr \015\012 \040\040' - ;; - *) # EBCDIC based system - lt_SP2NL='tr \100 \n' - lt_NL2SP='tr \r\n \100\100' - ;; -esac - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 -$as_echo_n "checking how to convert $build file names to $host format... " >&6; } -if ${lt_cv_to_host_file_cmd+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $host in - *-*-mingw* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 - ;; - *-*-cygwin* ) - lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 - ;; - * ) # otherwise, assume *nix - lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 - ;; - esac - ;; - *-*-cygwin* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin - ;; - *-*-cygwin* ) - lt_cv_to_host_file_cmd=func_convert_file_noop - ;; - * ) # otherwise, assume *nix - lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin - ;; - esac - ;; - * ) # unhandled hosts (and "normal" native builds) - lt_cv_to_host_file_cmd=func_convert_file_noop - ;; -esac - -fi - -to_host_file_cmd=$lt_cv_to_host_file_cmd -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 -$as_echo "$lt_cv_to_host_file_cmd" >&6; } - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 -$as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } -if ${lt_cv_to_tool_file_cmd+:} false; then : - $as_echo_n "(cached) " >&6 -else - #assume ordinary cross tools, or native build. -lt_cv_to_tool_file_cmd=func_convert_file_noop -case $host in - *-*-mingw* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 - ;; - esac - ;; -esac - -fi - -to_tool_file_cmd=$lt_cv_to_tool_file_cmd -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 -$as_echo "$lt_cv_to_tool_file_cmd" >&6; } - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 -$as_echo_n "checking for $LD option to reload object files... " >&6; } -if ${lt_cv_ld_reload_flag+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_ld_reload_flag='-r' -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 -$as_echo "$lt_cv_ld_reload_flag" >&6; } -reload_flag=$lt_cv_ld_reload_flag -case $reload_flag in -"" | " "*) ;; -*) reload_flag=" $reload_flag" ;; -esac -reload_cmds='$LD$reload_flag -o $output$reload_objs' -case $host_os in - cygwin* | mingw* | pw32* | cegcc*) - if test "$GCC" != yes; then - reload_cmds=false - fi - ;; - darwin*) - if test "$GCC" = yes; then - reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' - else - reload_cmds='$LD$reload_flag -o $output$reload_objs' - fi - ;; -esac - - - - - - - - - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. -set dummy ${ac_tool_prefix}objdump; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OBJDUMP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OBJDUMP"; then - ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OBJDUMP=$ac_cv_prog_OBJDUMP -if test -n "$OBJDUMP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 -$as_echo "$OBJDUMP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OBJDUMP"; then - ac_ct_OBJDUMP=$OBJDUMP - # Extract the first word of "objdump", so it can be a program name with args. -set dummy objdump; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OBJDUMP"; then - ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_OBJDUMP="objdump" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP -if test -n "$ac_ct_OBJDUMP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 -$as_echo "$ac_ct_OBJDUMP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OBJDUMP" = x; then - OBJDUMP="false" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OBJDUMP=$ac_ct_OBJDUMP - fi -else - OBJDUMP="$ac_cv_prog_OBJDUMP" -fi - -test -z "$OBJDUMP" && OBJDUMP=objdump - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 -$as_echo_n "checking how to recognize dependent libraries... " >&6; } -if ${lt_cv_deplibs_check_method+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_file_magic_cmd='$MAGIC_CMD' -lt_cv_file_magic_test_file= -lt_cv_deplibs_check_method='unknown' -# Need to set the preceding variable on all platforms that support -# interlibrary dependencies. -# 'none' -- dependencies not supported. -# `unknown' -- same as none, but documents that we really don't know. -# 'pass_all' -- all dependencies passed with no checks. -# 'test_compile' -- check by making test program. -# 'file_magic [[regex]]' -- check by looking for files in library path -# which responds to the $file_magic_cmd with a given extended regex. -# If you have `file' or equivalent on your system and you're not sure -# whether `pass_all' will *always* work, you probably want this one. - -case $host_os in -aix[4-9]*) - lt_cv_deplibs_check_method=pass_all - ;; - -beos*) - lt_cv_deplibs_check_method=pass_all - ;; - -bsdi[45]*) - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' - lt_cv_file_magic_cmd='/usr/bin/file -L' - lt_cv_file_magic_test_file=/shlib/libc.so - ;; - -cygwin*) - # func_win32_libid is a shell function defined in ltmain.sh - lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' - lt_cv_file_magic_cmd='func_win32_libid' - ;; - -mingw* | pw32*) - # Base MSYS/MinGW do not provide the 'file' command needed by - # func_win32_libid shell function, so use a weaker test based on 'objdump', - # unless we find 'file', for example because we are cross-compiling. - # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. - if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then - lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' - lt_cv_file_magic_cmd='func_win32_libid' - else - # Keep this pattern in sync with the one in func_win32_libid. - lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' - lt_cv_file_magic_cmd='$OBJDUMP -f' - fi - ;; - -cegcc*) - # use the weaker test based on 'objdump'. See mingw*. - lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' - lt_cv_file_magic_cmd='$OBJDUMP -f' - ;; - -darwin* | rhapsody*) - lt_cv_deplibs_check_method=pass_all - ;; - -freebsd* | dragonfly*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then - case $host_cpu in - i*86 ) - # Not sure whether the presence of OpenBSD here was a mistake. - # Let's accept both of them until this is cleared up. - lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` - ;; - esac - else - lt_cv_deplibs_check_method=pass_all - fi - ;; - -gnu*) - lt_cv_deplibs_check_method=pass_all - ;; - -haiku*) - lt_cv_deplibs_check_method=pass_all - ;; - -hpux10.20* | hpux11*) - lt_cv_file_magic_cmd=/usr/bin/file - case $host_cpu in - ia64*) - lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' - lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so - ;; - hppa*64*) - lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' - lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl - ;; - *) - lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' - lt_cv_file_magic_test_file=/usr/lib/libc.sl - ;; - esac - ;; - -interix[3-9]*) - # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' - ;; - -irix5* | irix6* | nonstopux*) - case $LD in - *-32|*"-32 ") libmagic=32-bit;; - *-n32|*"-n32 ") libmagic=N32;; - *-64|*"-64 ") libmagic=64-bit;; - *) libmagic=never-match;; - esac - lt_cv_deplibs_check_method=pass_all - ;; - -# This must be glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu) - lt_cv_deplibs_check_method=pass_all - ;; - -netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' - fi - ;; - -newos6*) - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=/usr/lib/libnls.so - ;; - -*nto* | *qnx*) - lt_cv_deplibs_check_method=pass_all - ;; - -openbsd*) - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' - fi - ;; - -osf3* | osf4* | osf5*) - lt_cv_deplibs_check_method=pass_all - ;; - -rdos*) - lt_cv_deplibs_check_method=pass_all - ;; - -solaris*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv4 | sysv4.3*) - case $host_vendor in - motorola) - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` - ;; - ncr) - lt_cv_deplibs_check_method=pass_all - ;; - sequent) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' - ;; - sni) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" - lt_cv_file_magic_test_file=/lib/libc.so - ;; - siemens) - lt_cv_deplibs_check_method=pass_all - ;; - pc) - lt_cv_deplibs_check_method=pass_all - ;; - esac - ;; - -tpf*) - lt_cv_deplibs_check_method=pass_all - ;; -esac - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 -$as_echo "$lt_cv_deplibs_check_method" >&6; } - -file_magic_glob= -want_nocaseglob=no -if test "$build" = "$host"; then - case $host_os in - mingw* | pw32*) - if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then - want_nocaseglob=yes - else - file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` - fi - ;; - esac -fi - -file_magic_cmd=$lt_cv_file_magic_cmd -deplibs_check_method=$lt_cv_deplibs_check_method -test -z "$deplibs_check_method" && deplibs_check_method=unknown - - - - - - - - - - - - - - - - - - - - - - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. -set dummy ${ac_tool_prefix}dlltool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_DLLTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$DLLTOOL"; then - ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -DLLTOOL=$ac_cv_prog_DLLTOOL -if test -n "$DLLTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 -$as_echo "$DLLTOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_DLLTOOL"; then - ac_ct_DLLTOOL=$DLLTOOL - # Extract the first word of "dlltool", so it can be a program name with args. -set dummy dlltool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_DLLTOOL"; then - ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_DLLTOOL="dlltool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL -if test -n "$ac_ct_DLLTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 -$as_echo "$ac_ct_DLLTOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_DLLTOOL" = x; then - DLLTOOL="false" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - DLLTOOL=$ac_ct_DLLTOOL - fi -else - DLLTOOL="$ac_cv_prog_DLLTOOL" -fi - -test -z "$DLLTOOL" && DLLTOOL=dlltool - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 -$as_echo_n "checking how to associate runtime and link libraries... " >&6; } -if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_sharedlib_from_linklib_cmd='unknown' - -case $host_os in -cygwin* | mingw* | pw32* | cegcc*) - # two different shell functions defined in ltmain.sh - # decide which to use based on capabilities of $DLLTOOL - case `$DLLTOOL --help 2>&1` in - *--identify-strict*) - lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib - ;; - *) - lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback - ;; - esac - ;; -*) - # fallback: assume linklib IS sharedlib - lt_cv_sharedlib_from_linklib_cmd="$ECHO" - ;; -esac - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 -$as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } -sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd -test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO - - - - - - - -if test -n "$ac_tool_prefix"; then - for ac_prog in ar - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AR+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$AR"; then - ac_cv_prog_AR="$AR" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_AR="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -AR=$ac_cv_prog_AR -if test -n "$AR"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 -$as_echo "$AR" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$AR" && break - done -fi -if test -z "$AR"; then - ac_ct_AR=$AR - for ac_prog in ar -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_AR+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_AR"; then - ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_AR="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_AR=$ac_cv_prog_ac_ct_AR -if test -n "$ac_ct_AR"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 -$as_echo "$ac_ct_AR" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_AR" && break -done - - if test "x$ac_ct_AR" = x; then - AR="false" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - AR=$ac_ct_AR - fi -fi - -: ${AR=ar} -: ${AR_FLAGS=cru} - - - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 -$as_echo_n "checking for archiver @FILE support... " >&6; } -if ${lt_cv_ar_at_file+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_ar_at_file=no - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - echo conftest.$ac_objext > conftest.lst - lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' - { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 - (eval $lt_ar_try) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if test "$ac_status" -eq 0; then - # Ensure the archiver fails upon bogus file names. - rm -f conftest.$ac_objext libconftest.a - { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 - (eval $lt_ar_try) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if test "$ac_status" -ne 0; then - lt_cv_ar_at_file=@ - fi - fi - rm -f conftest.* libconftest.a - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 -$as_echo "$lt_cv_ar_at_file" >&6; } - -if test "x$lt_cv_ar_at_file" = xno; then - archiver_list_spec= -else - archiver_list_spec=$lt_cv_ar_at_file -fi - - - - - - - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. -set dummy ${ac_tool_prefix}strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_STRIP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$STRIP"; then - ac_cv_prog_STRIP="$STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_STRIP="${ac_tool_prefix}strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -STRIP=$ac_cv_prog_STRIP -if test -n "$STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 -$as_echo "$STRIP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_STRIP"; then - ac_ct_STRIP=$STRIP - # Extract the first word of "strip", so it can be a program name with args. -set dummy strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_STRIP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_STRIP"; then - ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_STRIP="strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP -if test -n "$ac_ct_STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 -$as_echo "$ac_ct_STRIP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_STRIP" = x; then - STRIP=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - STRIP=$ac_ct_STRIP - fi -else - STRIP="$ac_cv_prog_STRIP" -fi - -test -z "$STRIP" && STRIP=: - - - - - - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. -set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_RANLIB+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -RANLIB=$ac_cv_prog_RANLIB -if test -n "$RANLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 -$as_echo "$RANLIB" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_RANLIB"; then - ac_ct_RANLIB=$RANLIB - # Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_RANLIB"; then - ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_RANLIB="ranlib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB -if test -n "$ac_ct_RANLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 -$as_echo "$ac_ct_RANLIB" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_RANLIB" = x; then - RANLIB=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - RANLIB=$ac_ct_RANLIB - fi -else - RANLIB="$ac_cv_prog_RANLIB" -fi - -test -z "$RANLIB" && RANLIB=: - - - - - - -# Determine commands to create old-style static archives. -old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= - -if test -n "$RANLIB"; then - case $host_os in - openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" - ;; - *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" - ;; - esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" -fi - -case $host_os in - darwin*) - lock_old_archive_extraction=yes ;; - *) - lock_old_archive_extraction=no ;; -esac - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC - - -# Check for command to grab the raw symbol name followed by C symbol from nm. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 -$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } -if ${lt_cv_sys_global_symbol_pipe+:} false; then : - $as_echo_n "(cached) " >&6 -else - -# These are sane defaults that work on at least a few old systems. -# [They come from Ultrix. What could be older than Ultrix?!! ;)] - -# Character class describing NM global symbol codes. -symcode='[BCDEGRST]' - -# Regexp to match symbols that can be accessed directly from C. -sympat='\([_A-Za-z][_A-Za-z0-9]*\)' - -# Define system-specific variables. -case $host_os in -aix*) - symcode='[BCDT]' - ;; -cygwin* | mingw* | pw32* | cegcc*) - symcode='[ABCDGISTW]' - ;; -hpux*) - if test "$host_cpu" = ia64; then - symcode='[ABCDEGRST]' - fi - ;; -irix* | nonstopux*) - symcode='[BCDEGRST]' - ;; -osf*) - symcode='[BCDEGQRST]' - ;; -solaris*) - symcode='[BDRT]' - ;; -sco3.2v5*) - symcode='[DT]' - ;; -sysv4.2uw2*) - symcode='[DT]' - ;; -sysv5* | sco5v6* | unixware* | OpenUNIX*) - symcode='[ABDT]' - ;; -sysv4) - symcode='[DFNSTU]' - ;; -esac - -# If we're using GNU nm, then use its standard symbol codes. -case `$NM -V 2>&1` in -*GNU* | *'with BFD'*) - symcode='[ABCDGIRSTW]' ;; -esac - -# Transform an extracted symbol line into a proper C declaration. -# Some systems (esp. on ia64) link data and code symbols differently, -# so use this general approach. -lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" - -# Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" - -# Handle CRLF in mingw tool chain -opt_cr= -case $build_os in -mingw*) - opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp - ;; -esac - -# Try without a prefix underscore, then with it. -for ac_symprfx in "" "_"; do - - # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. - symxfrm="\\1 $ac_symprfx\\2 \\2" - - # Write the raw and C identifiers. - if test "$lt_cv_nm_interface" = "MS dumpbin"; then - # Fake it for dumpbin and say T for any non-static function - # and D for any global variable. - # Also find C++ and __fastcall symbols from MSVC++, - # which start with @ or ?. - lt_cv_sys_global_symbol_pipe="$AWK '"\ -" {last_section=section; section=\$ 3};"\ -" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ -" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ -" \$ 0!~/External *\|/{next};"\ -" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ -" {if(hide[section]) next};"\ -" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ -" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ -" s[1]~/^[@?]/{print s[1], s[1]; next};"\ -" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ -" ' prfx=^$ac_symprfx" - else - lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" - fi - lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" - - # Check to see that the pipe works correctly. - pipe_works=no - - rm -f conftest* - cat > conftest.$ac_ext <<_LT_EOF -#ifdef __cplusplus -extern "C" { -#endif -char nm_test_var; -void nm_test_func(void); -void nm_test_func(void){} -#ifdef __cplusplus -} -#endif -int main(){nm_test_var='a';nm_test_func();return(0);} -_LT_EOF - - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - # Now try to grab the symbols. - nlist=conftest.nm - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 - (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s "$nlist"; then - # Try sorting and uniquifying the output. - if sort "$nlist" | uniq > "$nlist"T; then - mv -f "$nlist"T "$nlist" - else - rm -f "$nlist"T - fi - - # Make sure that we snagged all the symbols we need. - if $GREP ' nm_test_var$' "$nlist" >/dev/null; then - if $GREP ' nm_test_func$' "$nlist" >/dev/null; then - cat <<_LT_EOF > conftest.$ac_ext -/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ -#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) -/* DATA imports from DLLs on WIN32 con't be const, because runtime - relocations are performed -- see ld's documentation on pseudo-relocs. */ -# define LT_DLSYM_CONST -#elif defined(__osf__) -/* This system does not cope well with relocations in const data. */ -# define LT_DLSYM_CONST -#else -# define LT_DLSYM_CONST const -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -_LT_EOF - # Now generate the symbol file. - eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' - - cat <<_LT_EOF >> conftest.$ac_ext - -/* The mapping between symbol names and symbols. */ -LT_DLSYM_CONST struct { - const char *name; - void *address; -} -lt__PROGRAM__LTX_preloaded_symbols[] = -{ - { "@PROGRAM@", (void *) 0 }, -_LT_EOF - $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext - cat <<\_LT_EOF >> conftest.$ac_ext - {0, (void *) 0} -}; - -/* This works around a problem in FreeBSD linker */ -#ifdef FREEBSD_WORKAROUND -static const void *lt_preloaded_setup() { - return lt__PROGRAM__LTX_preloaded_symbols; -} -#endif - -#ifdef __cplusplus -} -#endif -_LT_EOF - # Now try linking the two files. - mv conftest.$ac_objext conftstm.$ac_objext - lt_globsym_save_LIBS=$LIBS - lt_globsym_save_CFLAGS=$CFLAGS - LIBS="conftstm.$ac_objext" - CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 - (eval $ac_link) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s conftest${ac_exeext}; then - pipe_works=yes - fi - LIBS=$lt_globsym_save_LIBS - CFLAGS=$lt_globsym_save_CFLAGS - else - echo "cannot find nm_test_func in $nlist" >&5 - fi - else - echo "cannot find nm_test_var in $nlist" >&5 - fi - else - echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 - fi - else - echo "$progname: failed program was:" >&5 - cat conftest.$ac_ext >&5 - fi - rm -rf conftest* conftst* - - # Do not use the global_symbol_pipe unless it works. - if test "$pipe_works" = yes; then - break - else - lt_cv_sys_global_symbol_pipe= - fi -done - -fi - -if test -z "$lt_cv_sys_global_symbol_pipe"; then - lt_cv_sys_global_symbol_to_cdecl= -fi -if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 -$as_echo "failed" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; } -fi - -# Response file support. -if test "$lt_cv_nm_interface" = "MS dumpbin"; then - nm_file_list_spec='@' -elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then - nm_file_list_spec='@' -fi - - - - - - - - - - - - - - - - - - - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 -$as_echo_n "checking for sysroot... " >&6; } - -# Check whether --with-sysroot was given. -if test "${with_sysroot+set}" = set; then : - withval=$with_sysroot; -else - with_sysroot=no -fi - - -lt_sysroot= -case ${with_sysroot} in #( - yes) - if test "$GCC" = yes; then - lt_sysroot=`$CC --print-sysroot 2>/dev/null` - fi - ;; #( - /*) - lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` - ;; #( - no|'') - ;; #( - *) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5 -$as_echo "${with_sysroot}" >&6; } - as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 - ;; -esac - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 -$as_echo "${lt_sysroot:-no}" >&6; } - - - - - -# Check whether --enable-libtool-lock was given. -if test "${enable_libtool_lock+set}" = set; then : - enableval=$enable_libtool_lock; -fi - -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes - -# Some flags need to be propagated to the compiler or linker for good -# libtool support. -case $host in -ia64-*-hpux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - case `/usr/bin/file conftest.$ac_objext` in - *ELF-32*) - HPUX_IA64_MODE="32" - ;; - *ELF-64*) - HPUX_IA64_MODE="64" - ;; - esac - fi - rm -rf conftest* - ;; -*-*-irix6*) - # Find out which ABI we are using. - echo '#line '$LINENO' "configure"' > conftest.$ac_ext - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - if test "$lt_cv_prog_gnu_ld" = yes; then - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -melf32bsmip" - ;; - *N32*) - LD="${LD-ld} -melf32bmipn32" - ;; - *64-bit*) - LD="${LD-ld} -melf64bmip" - ;; - esac - else - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -32" - ;; - *N32*) - LD="${LD-ld} -n32" - ;; - *64-bit*) - LD="${LD-ld} -64" - ;; - esac - fi - fi - rm -rf conftest* - ;; - -x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ -s390*-*linux*|s390*-*tpf*|sparc*-*linux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - case `/usr/bin/file conftest.o` in - *32-bit*) - case $host in - x86_64-*kfreebsd*-gnu) - LD="${LD-ld} -m elf_i386_fbsd" - ;; - x86_64-*linux*) - LD="${LD-ld} -m elf_i386" - ;; - ppc64-*linux*|powerpc64-*linux*) - LD="${LD-ld} -m elf32ppclinux" - ;; - s390x-*linux*) - LD="${LD-ld} -m elf_s390" - ;; - sparc64-*linux*) - LD="${LD-ld} -m elf32_sparc" - ;; - esac - ;; - *64-bit*) - case $host in - x86_64-*kfreebsd*-gnu) - LD="${LD-ld} -m elf_x86_64_fbsd" - ;; - x86_64-*linux*) - LD="${LD-ld} -m elf_x86_64" - ;; - ppc*-*linux*|powerpc*-*linux*) - LD="${LD-ld} -m elf64ppc" - ;; - s390*-*linux*|s390*-*tpf*) - LD="${LD-ld} -m elf64_s390" - ;; - sparc*-*linux*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; - -*-*-sco3.2v5*) - # On SCO OpenServer 5, we need -belf to get full-featured binaries. - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -belf" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 -$as_echo_n "checking whether the C compiler needs -belf... " >&6; } -if ${lt_cv_cc_needs_belf+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - lt_cv_cc_needs_belf=yes -else - lt_cv_cc_needs_belf=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 -$as_echo "$lt_cv_cc_needs_belf" >&6; } - if test x"$lt_cv_cc_needs_belf" != x"yes"; then - # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf - CFLAGS="$SAVE_CFLAGS" - fi - ;; -*-*solaris*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - case `/usr/bin/file conftest.o` in - *64-bit*) - case $lt_cv_prog_gnu_ld in - yes*) - case $host in - i?86-*-solaris*) - LD="${LD-ld} -m elf_x86_64" - ;; - sparc*-*-solaris*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - # GNU ld 2.21 introduced _sol2 emulations. Use them if available. - if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then - LD="${LD-ld}_sol2" - fi - ;; - *) - if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then - LD="${LD-ld} -64" - fi - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; -esac - -need_locks="$enable_libtool_lock" - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. -set dummy ${ac_tool_prefix}mt; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$MANIFEST_TOOL"; then - ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL -if test -n "$MANIFEST_TOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 -$as_echo "$MANIFEST_TOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_MANIFEST_TOOL"; then - ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL - # Extract the first word of "mt", so it can be a program name with args. -set dummy mt; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_MANIFEST_TOOL"; then - ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL -if test -n "$ac_ct_MANIFEST_TOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 -$as_echo "$ac_ct_MANIFEST_TOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_MANIFEST_TOOL" = x; then - MANIFEST_TOOL=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL - fi -else - MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" -fi - -test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 -$as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } -if ${lt_cv_path_mainfest_tool+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_path_mainfest_tool=no - echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 - $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out - cat conftest.err >&5 - if $GREP 'Manifest Tool' conftest.out > /dev/null; then - lt_cv_path_mainfest_tool=yes - fi - rm -f conftest* -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 -$as_echo "$lt_cv_path_mainfest_tool" >&6; } -if test "x$lt_cv_path_mainfest_tool" != xyes; then - MANIFEST_TOOL=: -fi - - - - - - - case $host_os in - rhapsody* | darwin*) - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. -set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_DSYMUTIL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$DSYMUTIL"; then - ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -DSYMUTIL=$ac_cv_prog_DSYMUTIL -if test -n "$DSYMUTIL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 -$as_echo "$DSYMUTIL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_DSYMUTIL"; then - ac_ct_DSYMUTIL=$DSYMUTIL - # Extract the first word of "dsymutil", so it can be a program name with args. -set dummy dsymutil; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_DSYMUTIL"; then - ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL -if test -n "$ac_ct_DSYMUTIL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 -$as_echo "$ac_ct_DSYMUTIL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_DSYMUTIL" = x; then - DSYMUTIL=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - DSYMUTIL=$ac_ct_DSYMUTIL - fi -else - DSYMUTIL="$ac_cv_prog_DSYMUTIL" -fi - - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. -set dummy ${ac_tool_prefix}nmedit; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_NMEDIT+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$NMEDIT"; then - ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -NMEDIT=$ac_cv_prog_NMEDIT -if test -n "$NMEDIT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 -$as_echo "$NMEDIT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_NMEDIT"; then - ac_ct_NMEDIT=$NMEDIT - # Extract the first word of "nmedit", so it can be a program name with args. -set dummy nmedit; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_NMEDIT"; then - ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_NMEDIT="nmedit" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT -if test -n "$ac_ct_NMEDIT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 -$as_echo "$ac_ct_NMEDIT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_NMEDIT" = x; then - NMEDIT=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - NMEDIT=$ac_ct_NMEDIT - fi -else - NMEDIT="$ac_cv_prog_NMEDIT" -fi - - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. -set dummy ${ac_tool_prefix}lipo; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_LIPO+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$LIPO"; then - ac_cv_prog_LIPO="$LIPO" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_LIPO="${ac_tool_prefix}lipo" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -LIPO=$ac_cv_prog_LIPO -if test -n "$LIPO"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 -$as_echo "$LIPO" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_LIPO"; then - ac_ct_LIPO=$LIPO - # Extract the first word of "lipo", so it can be a program name with args. -set dummy lipo; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_LIPO+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_LIPO"; then - ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_LIPO="lipo" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO -if test -n "$ac_ct_LIPO"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 -$as_echo "$ac_ct_LIPO" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_LIPO" = x; then - LIPO=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - LIPO=$ac_ct_LIPO - fi -else - LIPO="$ac_cv_prog_LIPO" -fi - - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. -set dummy ${ac_tool_prefix}otool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OTOOL"; then - ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_OTOOL="${ac_tool_prefix}otool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OTOOL=$ac_cv_prog_OTOOL -if test -n "$OTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 -$as_echo "$OTOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OTOOL"; then - ac_ct_OTOOL=$OTOOL - # Extract the first word of "otool", so it can be a program name with args. -set dummy otool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OTOOL"; then - ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_OTOOL="otool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL -if test -n "$ac_ct_OTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 -$as_echo "$ac_ct_OTOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OTOOL" = x; then - OTOOL=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OTOOL=$ac_ct_OTOOL - fi -else - OTOOL="$ac_cv_prog_OTOOL" -fi - - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. -set dummy ${ac_tool_prefix}otool64; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OTOOL64+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OTOOL64"; then - ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OTOOL64=$ac_cv_prog_OTOOL64 -if test -n "$OTOOL64"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 -$as_echo "$OTOOL64" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OTOOL64"; then - ac_ct_OTOOL64=$OTOOL64 - # Extract the first word of "otool64", so it can be a program name with args. -set dummy otool64; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OTOOL64"; then - ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_OTOOL64="otool64" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 -if test -n "$ac_ct_OTOOL64"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 -$as_echo "$ac_ct_OTOOL64" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OTOOL64" = x; then - OTOOL64=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OTOOL64=$ac_ct_OTOOL64 - fi -else - OTOOL64="$ac_cv_prog_OTOOL64" -fi - - - - - - - - - - - - - - - - - - - - - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 -$as_echo_n "checking for -single_module linker flag... " >&6; } -if ${lt_cv_apple_cc_single_mod+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_apple_cc_single_mod=no - if test -z "${LT_MULTI_MODULE}"; then - # By default we will add the -single_module flag. You can override - # by either setting the environment variable LT_MULTI_MODULE - # non-empty at configure time, or by adding -multi_module to the - # link flags. - rm -rf libconftest.dylib* - echo "int foo(void){return 1;}" > conftest.c - echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ --dynamiclib -Wl,-single_module conftest.c" >&5 - $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ - -dynamiclib -Wl,-single_module conftest.c 2>conftest.err - _lt_result=$? - # If there is a non-empty error log, and "single_module" - # appears in it, assume the flag caused a linker warning - if test -s conftest.err && $GREP single_module conftest.err; then - cat conftest.err >&5 - # Otherwise, if the output was created with a 0 exit code from - # the compiler, it worked. - elif test -f libconftest.dylib && test $_lt_result -eq 0; then - lt_cv_apple_cc_single_mod=yes - else - cat conftest.err >&5 - fi - rm -rf libconftest.dylib* - rm -f conftest.* - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 -$as_echo "$lt_cv_apple_cc_single_mod" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 -$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } -if ${lt_cv_ld_exported_symbols_list+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_ld_exported_symbols_list=no - save_LDFLAGS=$LDFLAGS - echo "_main" > conftest.sym - LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - lt_cv_ld_exported_symbols_list=yes -else - lt_cv_ld_exported_symbols_list=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS="$save_LDFLAGS" - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 -$as_echo "$lt_cv_ld_exported_symbols_list" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 -$as_echo_n "checking for -force_load linker flag... " >&6; } -if ${lt_cv_ld_force_load+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_ld_force_load=no - cat > conftest.c << _LT_EOF -int forced_loaded() { return 2;} -_LT_EOF - echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 - $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 - echo "$AR cru libconftest.a conftest.o" >&5 - $AR cru libconftest.a conftest.o 2>&5 - echo "$RANLIB libconftest.a" >&5 - $RANLIB libconftest.a 2>&5 - cat > conftest.c << _LT_EOF -int main() { return 0;} -_LT_EOF - echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 - $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err - _lt_result=$? - if test -s conftest.err && $GREP force_load conftest.err; then - cat conftest.err >&5 - elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then - lt_cv_ld_force_load=yes - else - cat conftest.err >&5 - fi - rm -f conftest.err libconftest.a conftest conftest.c - rm -rf conftest.dSYM - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 -$as_echo "$lt_cv_ld_force_load" >&6; } - case $host_os in - rhapsody* | darwin1.[012]) - _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; - darwin1.*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - darwin*) # darwin 5.x on - # if running on 10.5 or later, the deployment target defaults - # to the OS version, if on x86, and 10.4, the deployment - # target defaults to 10.4. Don't you love it? - case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in - 10.0,*86*-darwin8*|10.0,*-darwin[91]*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - 10.[012]*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - 10.*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - esac - ;; - esac - if test "$lt_cv_apple_cc_single_mod" = "yes"; then - _lt_dar_single_mod='$single_module' - fi - if test "$lt_cv_ld_exported_symbols_list" = "yes"; then - _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' - else - _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' - fi - if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then - _lt_dsymutil='~$DSYMUTIL $lib || :' - else - _lt_dsymutil= - fi - ;; - esac - -for ac_header in dlfcn.h -do : - ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default -" -if test "x$ac_cv_header_dlfcn_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_DLFCN_H 1 -_ACEOF - -fi - -done - - - - - -# Set options - - - - enable_dlopen=no - - - - # Check whether --enable-shared was given. -if test "${enable_shared+set}" = set; then : - enableval=$enable_shared; p=${PACKAGE-default} - case $enableval in - yes) enable_shared=yes ;; - no) enable_shared=no ;; - *) - enable_shared=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_shared=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac -else - enable_shared=yes -fi - - - - - - - - - - # Check whether --enable-static was given. -if test "${enable_static+set}" = set; then : - enableval=$enable_static; p=${PACKAGE-default} - case $enableval in - yes) enable_static=yes ;; - no) enable_static=no ;; - *) - enable_static=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_static=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac -else - enable_static=yes -fi - - - - - - - - - - -# Check whether --with-pic was given. -if test "${with_pic+set}" = set; then : - withval=$with_pic; lt_p=${PACKAGE-default} - case $withval in - yes|no) pic_mode=$withval ;; - *) - pic_mode=default - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for lt_pkg in $withval; do - IFS="$lt_save_ifs" - if test "X$lt_pkg" = "X$lt_p"; then - pic_mode=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac -else - pic_mode=default -fi - - -test -z "$pic_mode" && pic_mode=default - - - - - - - - # Check whether --enable-fast-install was given. -if test "${enable_fast_install+set}" = set; then : - enableval=$enable_fast_install; p=${PACKAGE-default} - case $enableval in - yes) enable_fast_install=yes ;; - no) enable_fast_install=no ;; - *) - enable_fast_install=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_fast_install=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac -else - enable_fast_install=yes -fi - - - - - - - - - - - -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ltmain" - -# Always use our own libtool. -LIBTOOL='$(SHELL) $(apr_builddir)/libtool' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -test -z "$LN_S" && LN_S="ln -s" - - - - - - - - - - - - - - -if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 -$as_echo_n "checking for objdir... " >&6; } -if ${lt_cv_objdir+:} false; then : - $as_echo_n "(cached) " >&6 -else - rm -f .libs 2>/dev/null -mkdir .libs 2>/dev/null -if test -d .libs; then - lt_cv_objdir=.libs -else - # MS-DOS does not allow filenames that begin with a dot. - lt_cv_objdir=_libs -fi -rmdir .libs 2>/dev/null -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 -$as_echo "$lt_cv_objdir" >&6; } -objdir=$lt_cv_objdir - - - - - -cat >>confdefs.h <<_ACEOF -#define LT_OBJDIR "$lt_cv_objdir/" -_ACEOF - - - - -case $host_os in -aix3*) - # AIX sometimes has problems with the GCC collect2 program. For some - # reason, if we set the COLLECT_NAMES environment variable, the problems - # vanish in a puff of smoke. - if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES - fi - ;; -esac - -# Global variables: -ofile=libtool -can_build_shared=yes - -# All known linkers require a `.a' archive for static linking (except MSVC, -# which needs '.lib'). -libext=a - -with_gnu_ld="$lt_cv_prog_gnu_ld" - -old_CC="$CC" -old_CFLAGS="$CFLAGS" - -# Set sane defaults for various variables -test -z "$CC" && CC=cc -test -z "$LTCC" && LTCC=$CC -test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS -test -z "$LD" && LD=ld -test -z "$ac_objext" && ac_objext=o - -for cc_temp in $compiler""; do - case $cc_temp in - compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; - distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` - - -# Only perform the check for file, if the check method requires it -test -z "$MAGIC_CMD" && MAGIC_CMD=file -case $deplibs_check_method in -file_magic*) - if test "$file_magic_cmd" = '$MAGIC_CMD'; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 -$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } -if ${lt_cv_path_MAGIC_CMD+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $MAGIC_CMD in -[\\/*] | ?:[\\/]*) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. - ;; -*) - lt_save_MAGIC_CMD="$MAGIC_CMD" - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" - for ac_dir in $ac_dummy; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/${ac_tool_prefix}file; then - lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" - if test -n "$file_magic_test_file"; then - case $deplibs_check_method in - "file_magic "*) - file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" - if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - $EGREP "$file_magic_regex" > /dev/null; then - : - else - cat <<_LT_EOF 1>&2 - -*** Warning: the command libtool uses to detect shared libraries, -*** $file_magic_cmd, produces output that libtool cannot recognize. -*** The result is that libtool may fail to recognize shared libraries -*** as such. This will affect the creation of libtool libraries that -*** depend on shared libraries, but programs linked with such libtool -*** libraries will work regardless of this problem. Nevertheless, you -*** may want to report the problem to your system manager and/or to -*** bug-libtool@gnu.org - -_LT_EOF - fi ;; - esac - fi - break - fi - done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" - ;; -esac -fi - -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -if test -n "$MAGIC_CMD"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 -$as_echo "$MAGIC_CMD" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - - - -if test -z "$lt_cv_path_MAGIC_CMD"; then - if test -n "$ac_tool_prefix"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 -$as_echo_n "checking for file... " >&6; } -if ${lt_cv_path_MAGIC_CMD+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $MAGIC_CMD in -[\\/*] | ?:[\\/]*) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. - ;; -*) - lt_save_MAGIC_CMD="$MAGIC_CMD" - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" - for ac_dir in $ac_dummy; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/file; then - lt_cv_path_MAGIC_CMD="$ac_dir/file" - if test -n "$file_magic_test_file"; then - case $deplibs_check_method in - "file_magic "*) - file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" - if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - $EGREP "$file_magic_regex" > /dev/null; then - : - else - cat <<_LT_EOF 1>&2 - -*** Warning: the command libtool uses to detect shared libraries, -*** $file_magic_cmd, produces output that libtool cannot recognize. -*** The result is that libtool may fail to recognize shared libraries -*** as such. This will affect the creation of libtool libraries that -*** depend on shared libraries, but programs linked with such libtool -*** libraries will work regardless of this problem. Nevertheless, you -*** may want to report the problem to your system manager and/or to -*** bug-libtool@gnu.org - -_LT_EOF - fi ;; - esac - fi - break - fi - done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" - ;; -esac -fi - -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -if test -n "$MAGIC_CMD"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 -$as_echo "$MAGIC_CMD" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - else - MAGIC_CMD=: - fi -fi - - fi - ;; -esac - -# Use C for the default configuration in the libtool script - -lt_save_CC="$CC" -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -# Source file extension for C test sources. -ac_ext=c - -# Object file extension for compiled C test sources. -objext=o -objext=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="int some_variable = 0;" - -# Code to be used in simple link tests -lt_simple_link_test_code='int main(){return(0);}' - - - - - - - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC - -# Save the default compiler, since it gets overwritten when the other -# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. -compiler_DEFAULT=$CC - -# save warnings/boilerplate of simple test code -ac_outfile=conftest.$ac_objext -echo "$lt_simple_compile_test_code" >conftest.$ac_ext -eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_compiler_boilerplate=`cat conftest.err` -$RM conftest* - -ac_outfile=conftest.$ac_objext -echo "$lt_simple_link_test_code" >conftest.$ac_ext -eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_linker_boilerplate=`cat conftest.err` -$RM -r conftest* - - -## CAVEAT EMPTOR: -## There is no encapsulation within the following macros, do not change -## the running order or otherwise move them around unless you know exactly -## what you are doing... -if test -n "$compiler"; then - -lt_prog_compiler_no_builtin_flag= - -if test "$GCC" = yes; then - case $cc_basename in - nvcc*) - lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; - *) - lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; - esac - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 -$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } -if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_rtti_exceptions=no - ac_outfile=conftest.$ac_objext - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="-fno-rtti -fno-exceptions" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - lt_cv_prog_compiler_rtti_exceptions=yes - fi - fi - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 -$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } - -if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then - lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" -else - : -fi - -fi - - - - - - - lt_prog_compiler_wl= -lt_prog_compiler_pic= -lt_prog_compiler_static= - - - if test "$GCC" = yes; then - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_static='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static='-Bstatic' - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - lt_prog_compiler_pic='-fPIC' - ;; - m68k) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' - ;; - esac - ;; - - beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - - mingw* | cygwin* | pw32* | os2* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - # Although the cygwin gcc ignores -fPIC, still need this for old-style - # (--disable-auto-import) libraries - lt_prog_compiler_pic='-DDLL_EXPORT' - ;; - - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - lt_prog_compiler_pic='-fno-common' - ;; - - haiku*) - # PIC is the default for Haiku. - # The "-static" flag exists, but is broken. - lt_prog_compiler_static= - ;; - - hpux*) - # PIC is the default for 64-bit PA HP-UX, but not for 32-bit - # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag - # sets the default TLS model and affects inlining. - case $host_cpu in - hppa*64*) - # +Z the default - ;; - *) - lt_prog_compiler_pic='-fPIC' - ;; - esac - ;; - - interix[3-9]*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - - msdosdjgpp*) - # Just because we use GCC doesn't mean we suddenly get shared libraries - # on systems that don't support them. - lt_prog_compiler_can_build_shared=no - enable_shared=no - ;; - - *nto* | *qnx*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - lt_prog_compiler_pic='-fPIC -shared' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - lt_prog_compiler_pic=-Kconform_pic - fi - ;; - - *) - lt_prog_compiler_pic='-fPIC' - ;; - esac - - case $cc_basename in - nvcc*) # Cuda Compiler Driver 2.2 - lt_prog_compiler_wl='-Xlinker ' - if test -n "$lt_prog_compiler_pic"; then - lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" - fi - ;; - esac - else - # PORTME Check for flag to pass linker flags through the system compiler. - case $host_os in - aix*) - lt_prog_compiler_wl='-Wl,' - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static='-Bstatic' - else - lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' - fi - ;; - - mingw* | cygwin* | pw32* | os2* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - lt_prog_compiler_pic='-DDLL_EXPORT' - ;; - - hpux9* | hpux10* | hpux11*) - lt_prog_compiler_wl='-Wl,' - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - lt_prog_compiler_pic='+Z' - ;; - esac - # Is there a better lt_prog_compiler_static that works with the bundled CC? - lt_prog_compiler_static='${wl}-a ${wl}archive' - ;; - - irix5* | irix6* | nonstopux*) - lt_prog_compiler_wl='-Wl,' - # PIC (with -KPIC) is the default. - lt_prog_compiler_static='-non_shared' - ;; - - linux* | k*bsd*-gnu | kopensolaris*-gnu) - case $cc_basename in - # old Intel for x86_64 which still supported -KPIC. - ecc*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-static' - ;; - # icc used to be incompatible with GCC. - # ICC 10 doesn't accept -KPIC any more. - icc* | ifort*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-fPIC' - lt_prog_compiler_static='-static' - ;; - # Lahey Fortran 8.1. - lf95*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='--shared' - lt_prog_compiler_static='--static' - ;; - nagfor*) - # NAG Fortran compiler - lt_prog_compiler_wl='-Wl,-Wl,,' - lt_prog_compiler_pic='-PIC' - lt_prog_compiler_static='-Bstatic' - ;; - pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) - # Portland Group compilers (*not* the Pentium gcc compiler, - # which looks to be a dead project) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-fpic' - lt_prog_compiler_static='-Bstatic' - ;; - ccc*) - lt_prog_compiler_wl='-Wl,' - # All Alpha code is PIC. - lt_prog_compiler_static='-non_shared' - ;; - xl* | bgxl* | bgf* | mpixl*) - # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-qpic' - lt_prog_compiler_static='-qstaticlink' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) - # Sun Fortran 8.3 passes all unrecognized flags to the linker - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - lt_prog_compiler_wl='' - ;; - *Sun\ F* | *Sun*Fortran*) - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - lt_prog_compiler_wl='-Qoption ld ' - ;; - *Sun\ C*) - # Sun C 5.9 - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - lt_prog_compiler_wl='-Wl,' - ;; - *Intel*\ [CF]*Compiler*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-fPIC' - lt_prog_compiler_static='-static' - ;; - *Portland\ Group*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-fpic' - lt_prog_compiler_static='-Bstatic' - ;; - esac - ;; - esac - ;; - - newsos6) - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - ;; - - *nto* | *qnx*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - lt_prog_compiler_pic='-fPIC -shared' - ;; - - osf3* | osf4* | osf5*) - lt_prog_compiler_wl='-Wl,' - # All OSF/1 code is PIC. - lt_prog_compiler_static='-non_shared' - ;; - - rdos*) - lt_prog_compiler_static='-non_shared' - ;; - - solaris*) - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - case $cc_basename in - f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) - lt_prog_compiler_wl='-Qoption ld ';; - *) - lt_prog_compiler_wl='-Wl,';; - esac - ;; - - sunos4*) - lt_prog_compiler_wl='-Qoption ld ' - lt_prog_compiler_pic='-PIC' - lt_prog_compiler_static='-Bstatic' - ;; - - sysv4 | sysv4.2uw2* | sysv4.3*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - ;; - - sysv4*MP*) - if test -d /usr/nec ;then - lt_prog_compiler_pic='-Kconform_pic' - lt_prog_compiler_static='-Bstatic' - fi - ;; - - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - ;; - - unicos*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_can_build_shared=no - ;; - - uts4*) - lt_prog_compiler_pic='-pic' - lt_prog_compiler_static='-Bstatic' - ;; - - *) - lt_prog_compiler_can_build_shared=no - ;; - esac - fi - -case $host_os in - # For platforms which do not support PIC, -DPIC is meaningless: - *djgpp*) - lt_prog_compiler_pic= - ;; - *) - lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" - ;; -esac - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 -$as_echo_n "checking for $compiler option to produce PIC... " >&6; } -if ${lt_cv_prog_compiler_pic+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_pic=$lt_prog_compiler_pic -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 -$as_echo "$lt_cv_prog_compiler_pic" >&6; } -lt_prog_compiler_pic=$lt_cv_prog_compiler_pic - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$lt_prog_compiler_pic"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 -$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } -if ${lt_cv_prog_compiler_pic_works+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_pic_works=no - ac_outfile=conftest.$ac_objext - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$lt_prog_compiler_pic -DPIC" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - lt_cv_prog_compiler_pic_works=yes - fi - fi - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 -$as_echo "$lt_cv_prog_compiler_pic_works" >&6; } - -if test x"$lt_cv_prog_compiler_pic_works" = xyes; then - case $lt_prog_compiler_pic in - "" | " "*) ;; - *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; - esac -else - lt_prog_compiler_pic= - lt_prog_compiler_can_build_shared=no -fi - -fi - - - - - - - - - - - -# -# Check to make sure the static flag actually works. -# -wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 -$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } -if ${lt_cv_prog_compiler_static_works+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_static_works=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $lt_tmp_static_flag" - echo "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The linker can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&5 - $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - lt_cv_prog_compiler_static_works=yes - fi - else - lt_cv_prog_compiler_static_works=yes - fi - fi - $RM -r conftest* - LDFLAGS="$save_LDFLAGS" - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 -$as_echo "$lt_cv_prog_compiler_static_works" >&6; } - -if test x"$lt_cv_prog_compiler_static_works" = xyes; then - : -else - lt_prog_compiler_static= -fi - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 -$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if ${lt_cv_prog_compiler_c_o+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_c_o=no - $RM -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - lt_cv_prog_compiler_c_o=yes - fi - fi - chmod u+w . 2>&5 - $RM conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files - $RM out/* && rmdir out - cd .. - $RM -r conftest - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 -$as_echo "$lt_cv_prog_compiler_c_o" >&6; } - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 -$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if ${lt_cv_prog_compiler_c_o+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_c_o=no - $RM -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - lt_cv_prog_compiler_c_o=yes - fi - fi - chmod u+w . 2>&5 - $RM conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files - $RM out/* && rmdir out - cd .. - $RM -r conftest - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 -$as_echo "$lt_cv_prog_compiler_c_o" >&6; } - - - - -hard_links="nottested" -if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 -$as_echo_n "checking if we can lock with hard links... " >&6; } - hard_links=yes - $RM conftest* - ln conftest.a conftest.b 2>/dev/null && hard_links=no - touch conftest.a - ln conftest.a conftest.b 2>&5 || hard_links=no - ln conftest.a conftest.b 2>/dev/null && hard_links=no - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 -$as_echo "$hard_links" >&6; } - if test "$hard_links" = no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 -$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} - need_locks=warn - fi -else - need_locks=no -fi - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } - - runpath_var= - allow_undefined_flag= - always_export_symbols=no - archive_cmds= - archive_expsym_cmds= - compiler_needs_object=no - enable_shared_with_static_runtimes=no - export_dynamic_flag_spec= - export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - hardcode_automatic=no - hardcode_direct=no - hardcode_direct_absolute=no - hardcode_libdir_flag_spec= - hardcode_libdir_separator= - hardcode_minus_L=no - hardcode_shlibpath_var=unsupported - inherit_rpath=no - link_all_deplibs=unknown - module_cmds= - module_expsym_cmds= - old_archive_from_new_cmds= - old_archive_from_expsyms_cmds= - thread_safe_flag_spec= - whole_archive_flag_spec= - # include_expsyms should be a list of space-separated symbols to be *always* - # included in the symbol list - include_expsyms= - # exclude_expsyms can be an extended regexp of symbols to exclude - # it will be wrapped by ` (' and `)$', so one must not match beginning or - # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', - # as well as any symbol that contains `d'. - exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' - # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out - # platforms (ab)use it in PIC code, but their linkers get confused if - # the symbol is explicitly referenced. Since portable code cannot - # rely on this symbol name, it's probably fine to never include it in - # preloaded symbol tables. - # Exclude shared library initialization/finalization symbols. - extract_expsyms_cmds= - - case $host_os in - cygwin* | mingw* | pw32* | cegcc*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - if test "$GCC" != yes; then - with_gnu_ld=no - fi - ;; - interix*) - # we just hope/assume this is gcc and not c89 (= MSVC++) - with_gnu_ld=yes - ;; - openbsd*) - with_gnu_ld=no - ;; - esac - - ld_shlibs=yes - - # On some targets, GNU ld is compatible enough with the native linker - # that we're better off using the native interface for both. - lt_use_gnu_ld_interface=no - if test "$with_gnu_ld" = yes; then - case $host_os in - aix*) - # The AIX port of GNU ld has always aspired to compatibility - # with the native linker. However, as the warning in the GNU ld - # block says, versions before 2.19.5* couldn't really create working - # shared libraries, regardless of the interface used. - case `$LD -v 2>&1` in - *\ \(GNU\ Binutils\)\ 2.19.5*) ;; - *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; - *\ \(GNU\ Binutils\)\ [3-9]*) ;; - *) - lt_use_gnu_ld_interface=yes - ;; - esac - ;; - *) - lt_use_gnu_ld_interface=yes - ;; - esac - fi - - if test "$lt_use_gnu_ld_interface" = yes; then - # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' - - # Set some defaults for GNU ld with shared library support. These - # are reset later if shared libraries are not supported. Putting them - # here allows them to be overridden if necessary. - runpath_var=LD_RUN_PATH - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - export_dynamic_flag_spec='${wl}--export-dynamic' - # ancient GNU ld didn't support --whole-archive et. al. - if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then - whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - whole_archive_flag_spec= - fi - supports_anon_versioning=no - case `$LD -v 2>&1` in - *GNU\ gold*) supports_anon_versioning=yes ;; - *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 - *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... - *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... - *\ 2.11.*) ;; # other 2.11 versions - *) supports_anon_versioning=yes ;; - esac - - # See if GNU ld supports shared libraries. - case $host_os in - aix[3-9]*) - # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then - ld_shlibs=no - cat <<_LT_EOF 1>&2 - -*** Warning: the GNU linker, at least up to release 2.19, is reported -*** to be unable to reliably create shared libraries on AIX. -*** Therefore, libtool is disabling shared libraries support. If you -*** really care for shared libraries, you may want to install binutils -*** 2.20 or above, or modify your PATH so that a non-GNU linker is found. -*** You will then need to restart the configuration process. - -_LT_EOF - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='' - ;; - m68k) - archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - ;; - esac - ;; - - beos*) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - allow_undefined_flag=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - ld_shlibs=no - fi - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, - # as there is no search path for DLLs. - hardcode_libdir_flag_spec='-L$libdir' - export_dynamic_flag_spec='${wl}--export-all-symbols' - allow_undefined_flag=unsupported - always_export_symbols=no - enable_shared_with_static_runtimes=yes - export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' - exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' - - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - ld_shlibs=no - fi - ;; - - haiku*) - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - link_all_deplibs=yes - ;; - - interix[3-9]*) - hardcode_direct=no - hardcode_shlibpath_var=no - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - export_dynamic_flag_spec='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - - gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) - tmp_diet=no - if test "$host_os" = linux-dietlibc; then - case $cc_basename in - diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) - esac - fi - if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ - && test "$tmp_diet" = no - then - tmp_addflag=' $pic_flag' - tmp_sharedflag='-shared' - case $cc_basename,$host_cpu in - pgcc*) # Portland Group C compiler - whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag' - ;; - pgf77* | pgf90* | pgf95* | pgfortran*) - # Portland Group f77 and f90 compilers - whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag -Mnomain' ;; - ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 - tmp_addflag=' -i_dynamic' ;; - efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 - tmp_addflag=' -i_dynamic -nofor_main' ;; - ifc* | ifort*) # Intel Fortran compiler - tmp_addflag=' -nofor_main' ;; - lf95*) # Lahey Fortran 8.1 - whole_archive_flag_spec= - tmp_sharedflag='--shared' ;; - xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) - tmp_sharedflag='-qmkshrobj' - tmp_addflag= ;; - nvcc*) # Cuda Compiler Driver 2.2 - whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - compiler_needs_object=yes - ;; - esac - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) # Sun C 5.9 - whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - compiler_needs_object=yes - tmp_sharedflag='-G' ;; - *Sun\ F*) # Sun Fortran 8.3 - tmp_sharedflag='-G' ;; - esac - archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - - if test "x$supports_anon_versioning" = xyes; then - archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - fi - - case $cc_basename in - xlf* | bgf* | bgxlf* | mpixlf*) - # IBM XL Fortran 10.1 on PPC cannot create shared libs itself - whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then - archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' - fi - ;; - esac - else - ld_shlibs=no - fi - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' - wlarc= - else - archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - fi - ;; - - solaris*) - if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then - ld_shlibs=no - cat <<_LT_EOF 1>&2 - -*** Warning: The releases 2.8.* of the GNU linker cannot reliably -*** create shared libraries on Solaris systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.9.1 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs=no - fi - ;; - - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) - case `$LD -v 2>&1` in - *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) - ld_shlibs=no - cat <<_LT_EOF 1>&2 - -*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not -*** reliably create shared libraries on SCO systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.16.91.0.3 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - ;; - *) - # For security reasons, it is highly recommended that you always - # use absolute paths for naming shared libraries, and exclude the - # DT_RUNPATH tag from executables and libraries. But doing so - # requires that you compile everything twice, which is a pain. - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs=no - fi - ;; - esac - ;; - - sunos4*) - archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' - wlarc= - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - *) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs=no - fi - ;; - esac - - if test "$ld_shlibs" = no; then - runpath_var= - hardcode_libdir_flag_spec= - export_dynamic_flag_spec= - whole_archive_flag_spec= - fi - else - # PORTME fill in a description of your system's linker (not GNU ld) - case $host_os in - aix3*) - allow_undefined_flag=unsupported - always_export_symbols=yes - archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - hardcode_minus_L=yes - if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - hardcode_direct=unsupported - fi - ;; - - aix[4-9]*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - # Also, AIX nm treats weak defined symbols like other global - # defined symbols, whereas GNU nm marks them as "W". - if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - else - export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - fi - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) - for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then - aix_use_runtimelinking=yes - break - fi - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - archive_cmds='' - hardcode_direct=yes - hardcode_direct_absolute=yes - hardcode_libdir_separator=':' - link_all_deplibs=yes - file_list_spec='${wl}-f,' - - if test "$GCC" = yes; then - case $host_os in aix4.[012]|aix4.[012].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && - strings "$collect2name" | $GREP resolve_lib_name >/dev/null - then - # We have reworked collect2 - : - else - # We have old collect2 - hardcode_direct=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - hardcode_minus_L=yes - hardcode_libdir_flag_spec='-L$libdir' - hardcode_libdir_separator= - fi - ;; - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - export_dynamic_flag_spec='${wl}-bexpall' - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to export. - always_export_symbols=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - allow_undefined_flag='-berok' - # Determine the default libpath from the value encoded in an - # empty executable. - if test "${lt_cv_aix_libpath+set}" = set; then - aix_libpath=$lt_cv_aix_libpath -else - if ${lt_cv_aix_libpath_+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - - lt_aix_libpath_sed=' - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\([^ ]*\) *$/\1/ - p - } - }' - lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - # Check for a 64-bit object if we didn't find anything. - if test -z "$lt_cv_aix_libpath_"; then - lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - fi -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - if test -z "$lt_cv_aix_libpath_"; then - lt_cv_aix_libpath_="/usr/lib:/lib" - fi - -fi - - aix_libpath=$lt_cv_aix_libpath_ -fi - - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" - archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' - allow_undefined_flag="-z nodefs" - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an - # empty executable. - if test "${lt_cv_aix_libpath+set}" = set; then - aix_libpath=$lt_cv_aix_libpath -else - if ${lt_cv_aix_libpath_+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - - lt_aix_libpath_sed=' - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\([^ ]*\) *$/\1/ - p - } - }' - lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - # Check for a 64-bit object if we didn't find anything. - if test -z "$lt_cv_aix_libpath_"; then - lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - fi -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - if test -z "$lt_cv_aix_libpath_"; then - lt_cv_aix_libpath_="/usr/lib:/lib" - fi - -fi - - aix_libpath=$lt_cv_aix_libpath_ -fi - - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - no_undefined_flag=' ${wl}-bernotok' - allow_undefined_flag=' ${wl}-berok' - if test "$with_gnu_ld" = yes; then - # We only use this code for GNU lds that support --whole-archive. - whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - else - # Exported symbols can be pulled into shared objects from archives - whole_archive_flag_spec='$convenience' - fi - archive_cmds_need_lc=yes - # This is similar to how AIX traditionally builds its shared libraries. - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='' - ;; - m68k) - archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - ;; - esac - ;; - - bsdi[45]*) - export_dynamic_flag_spec=-rdynamic - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - case $cc_basename in - cl*) - # Native MSVC - hardcode_libdir_flag_spec=' ' - allow_undefined_flag=unsupported - always_export_symbols=yes - file_list_spec='@' - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' - archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; - else - sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; - fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ - linknames=' - # The linker will not automatically build a static lib if we build a DLL. - # _LT_TAGVAR(old_archive_from_new_cmds, )='true' - enable_shared_with_static_runtimes=yes - exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' - export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' - # Don't use ranlib - old_postinstall_cmds='chmod 644 $oldlib' - postlink_cmds='lt_outputfile="@OUTPUT@"~ - lt_tool_outputfile="@TOOL_OUTPUT@"~ - case $lt_outputfile in - *.exe|*.EXE) ;; - *) - lt_outputfile="$lt_outputfile.exe" - lt_tool_outputfile="$lt_tool_outputfile.exe" - ;; - esac~ - if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then - $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; - $RM "$lt_outputfile.manifest"; - fi' - ;; - *) - # Assume MSVC wrapper - hardcode_libdir_flag_spec=' ' - allow_undefined_flag=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - old_archive_from_new_cmds='true' - # FIXME: Should let the user specify the lib program. - old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' - enable_shared_with_static_runtimes=yes - ;; - esac - ;; - - darwin* | rhapsody*) - - - archive_cmds_need_lc=no - hardcode_direct=no - hardcode_automatic=yes - hardcode_shlibpath_var=unsupported - if test "$lt_cv_ld_force_load" = "yes"; then - whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' - - else - whole_archive_flag_spec='' - fi - link_all_deplibs=yes - allow_undefined_flag="$_lt_dar_allow_undefined" - case $cc_basename in - ifort*) _lt_dar_can_shared=yes ;; - *) _lt_dar_can_shared=$GCC ;; - esac - if test "$_lt_dar_can_shared" = "yes"; then - output_verbose_link_cmd=func_echo_all - archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" - module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" - archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" - module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" - - else - ld_shlibs=no - fi - - ;; - - dgux*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_shlibpath_var=no - ;; - - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor - # support. Future versions do this automatically, but an explicit c++rt0.o - # does not break anything, and helps significantly (at the cost of a little - # extra space). - freebsd2.2*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2.*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | dragonfly*) - archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - hpux9*) - if test "$GCC" = yes; then - archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - fi - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_direct=yes - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - export_dynamic_flag_spec='${wl}-E' - ;; - - hpux10*) - if test "$GCC" = yes && test "$with_gnu_ld" = no; then - archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' - fi - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_direct=yes - hardcode_direct_absolute=yes - export_dynamic_flag_spec='${wl}-E' - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - fi - ;; - - hpux11*) - if test "$GCC" = yes && test "$with_gnu_ld" = no; then - case $host_cpu in - hppa*64*) - archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - else - case $host_cpu in - hppa*64*) - archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - - # Older versions of the 11.00 compiler do not understand -b yet - # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 -$as_echo_n "checking if $CC understands -b... " >&6; } -if ${lt_cv_prog_compiler__b+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler__b=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -b" - echo "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The linker can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&5 - $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - lt_cv_prog_compiler__b=yes - fi - else - lt_cv_prog_compiler__b=yes - fi - fi - $RM -r conftest* - LDFLAGS="$save_LDFLAGS" - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 -$as_echo "$lt_cv_prog_compiler__b" >&6; } - -if test x"$lt_cv_prog_compiler__b" = xyes; then - archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' -else - archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' -fi - - ;; - esac - fi - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - - case $host_cpu in - hppa*64*|ia64*) - hardcode_direct=no - hardcode_shlibpath_var=no - ;; - *) - hardcode_direct=yes - hardcode_direct_absolute=yes - export_dynamic_flag_spec='${wl}-E' - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - ;; - esac - fi - ;; - - irix5* | irix6* | nonstopux*) - if test "$GCC" = yes; then - archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - # Try to use the -exported_symbol ld option, if it does not - # work, assume that -exports_file does not work either and - # implicitly export all symbols. - # This should be the same for all languages, so no per-tag cache variable. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 -$as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } -if ${lt_cv_irix_exported_symbol+:} false; then : - $as_echo_n "(cached) " >&6 -else - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -int foo (void) { return 0; } -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - lt_cv_irix_exported_symbol=yes -else - lt_cv_irix_exported_symbol=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS="$save_LDFLAGS" -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 -$as_echo "$lt_cv_irix_exported_symbol" >&6; } - if test "$lt_cv_irix_exported_symbol" = yes; then - archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' - fi - else - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' - fi - archive_cmds_need_lc='no' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - inherit_rpath=yes - link_all_deplibs=yes - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out - else - archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF - fi - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - newsos6) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_shlibpath_var=no - ;; - - *nto* | *qnx*) - ;; - - openbsd*) - if test -f /usr/libexec/ld.so; then - hardcode_direct=yes - hardcode_shlibpath_var=no - hardcode_direct_absolute=yes - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - export_dynamic_flag_spec='${wl}-E' - else - case $host_os in - openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-R$libdir' - ;; - *) - archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - ;; - esac - fi - else - ld_shlibs=no - fi - ;; - - os2*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - allow_undefined_flag=unsupported - archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' - old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' - ;; - - osf3*) - if test "$GCC" = yes; then - allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - fi - archive_cmds_need_lc='no' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - ;; - - osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - else - allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ - $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' - - # Both c and cxx compiler support -rpath directly - hardcode_libdir_flag_spec='-rpath $libdir' - fi - archive_cmds_need_lc='no' - hardcode_libdir_separator=: - ;; - - solaris*) - no_undefined_flag=' -z defs' - if test "$GCC" = yes; then - wlarc='${wl}' - archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' - else - case `$CC -V 2>&1` in - *"Compilers 5.0"*) - wlarc='' - archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' - ;; - *) - wlarc='${wl}' - archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' - ;; - esac - fi - hardcode_libdir_flag_spec='-R$libdir' - hardcode_shlibpath_var=no - case $host_os in - solaris2.[0-5] | solaris2.[0-5].*) ;; - *) - # The compiler driver will combine and reorder linker options, - # but understands `-z linker_flag'. GCC discards it without `$wl', - # but is careful enough not to reorder. - # Supported since Solaris 2.6 (maybe 2.5.1?) - if test "$GCC" = yes; then - whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' - else - whole_archive_flag_spec='-z allextract$convenience -z defaultextract' - fi - ;; - esac - link_all_deplibs=yes - ;; - - sunos4*) - if test "x$host_vendor" = xsequent; then - # Use $CC to link under sequent, because it throws in some extra .o - # files that make .init and .fini sections work. - archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' - fi - hardcode_libdir_flag_spec='-L$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - sysv4) - case $host_vendor in - sni) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes # is this really true??? - ;; - siemens) - ## LD is ld it makes a PLAMLIB - ## CC just makes a GrossModule. - archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' - reload_cmds='$CC -r -o $output$reload_objs' - hardcode_direct=no - ;; - motorola) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=no #Motorola manual says yes, but my tests say they lie - ;; - esac - runpath_var='LD_RUN_PATH' - hardcode_shlibpath_var=no - ;; - - sysv4.3*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var=no - export_dynamic_flag_spec='-Bexport' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - ld_shlibs=yes - fi - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) - no_undefined_flag='${wl}-z,text' - archive_cmds_need_lc=no - hardcode_shlibpath_var=no - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - no_undefined_flag='${wl}-z,text' - allow_undefined_flag='${wl}-z,nodefs' - archive_cmds_need_lc=no - hardcode_shlibpath_var=no - hardcode_libdir_flag_spec='${wl}-R,$libdir' - hardcode_libdir_separator=':' - link_all_deplibs=yes - export_dynamic_flag_spec='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - uts4*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_shlibpath_var=no - ;; - - *) - ld_shlibs=no - ;; - esac - - if test x$host_vendor = xsni; then - case $host in - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - export_dynamic_flag_spec='${wl}-Blargedynsym' - ;; - esac - fi - fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 -$as_echo "$ld_shlibs" >&6; } -test "$ld_shlibs" = no && can_build_shared=no - -with_gnu_ld=$with_gnu_ld - - - - - - - - - - - - - - - -# -# Do we need to explicitly link libc? -# -case "x$archive_cmds_need_lc" in -x|xyes) - # Assume -lc should be added - archive_cmds_need_lc=yes - - if test "$enable_shared" = yes && test "$GCC" = yes; then - case $archive_cmds in - *'~'*) - # FIXME: we may have to deal with multi-command sequences. - ;; - '$CC '*) - # Test whether the compiler implicitly links with -lc since on some - # systems, -lgcc has to come before -lc. If gcc already passes -lc - # to ld, don't add -lc before -lgcc. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 -$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } -if ${lt_cv_archive_cmds_need_lc+:} false; then : - $as_echo_n "(cached) " >&6 -else - $RM conftest* - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$lt_prog_compiler_wl - pic_flag=$lt_prog_compiler_pic - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$allow_undefined_flag - allow_undefined_flag= - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 - (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - then - lt_cv_archive_cmds_need_lc=no - else - lt_cv_archive_cmds_need_lc=yes - fi - allow_undefined_flag=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 -$as_echo "$lt_cv_archive_cmds_need_lc" >&6; } - archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc - ;; - esac - fi - ;; -esac - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 -$as_echo_n "checking dynamic linker characteristics... " >&6; } - -if test "$GCC" = yes; then - case $host_os in - darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; - *) lt_awk_arg="/^libraries:/" ;; - esac - case $host_os in - mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;; - *) lt_sed_strip_eq="s,=/,/,g" ;; - esac - lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` - case $lt_search_path_spec in - *\;*) - # if the path contains ";" then we assume it to be the separator - # otherwise default to the standard path separator (i.e. ":") - it is - # assumed that no part of a normal pathname contains ";" but that should - # okay in the real world where ";" in dirpaths is itself problematic. - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` - ;; - *) - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` - ;; - esac - # Ok, now we have the path, separated by spaces, we can step through it - # and add multilib dir if necessary. - lt_tmp_lt_search_path_spec= - lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` - for lt_sys_path in $lt_search_path_spec; do - if test -d "$lt_sys_path/$lt_multi_os_dir"; then - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" - else - test -d "$lt_sys_path" && \ - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" - fi - done - lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' -BEGIN {RS=" "; FS="/|\n";} { - lt_foo=""; - lt_count=0; - for (lt_i = NF; lt_i > 0; lt_i--) { - if ($lt_i != "" && $lt_i != ".") { - if ($lt_i == "..") { - lt_count++; - } else { - if (lt_count == 0) { - lt_foo="/" $lt_i lt_foo; - } else { - lt_count--; - } - } - } - } - if (lt_foo != "") { lt_freq[lt_foo]++; } - if (lt_freq[lt_foo] == 1) { print lt_foo; } -}'` - # AWK program above erroneously prepends '/' to C:/dos/paths - # for these hosts. - case $host_os in - mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ - $SED 's,/\([A-Za-z]:\),\1,g'` ;; - esac - sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` -else - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -fi -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext_cmds=".so" -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -shlibpath_overrides_runpath=unknown -version_type=none -dynamic_linker="$host_os ld.so" -sys_lib_dlsearch_path_spec="/lib /usr/lib" -need_lib_prefix=unknown -hardcode_into_libs=no - -# when you set need_version to no, make sure it does not cause -set_version -# flags to be left without arguments -need_version=unknown - -case $host_os in -aix3*) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}${shared_ext}$major' - ;; - -aix[4-9]*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - hardcode_into_libs=yes - if test "$host_cpu" = ia64; then - # AIX 5 supports IA64 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - else - # With GCC up to 2.95.x, collect2 would create an import file - # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in - # development snapshots of GCC prior to 3.0. - case $host_os in - aix4 | aix4.[01] | aix4.[01].*) - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then - : - else - can_build_shared=no - fi - ;; - esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct - # soname into executable. Probably we can add versioning support to - # collect2, so additional links can be useful in future. - if test "$aix_use_runtimelinking" = yes; then - # If using run time linking (on AIX 4.2 or later) use lib.so - # instead of lib.a to let people know that these are not - # typical AIX shared libraries. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - else - # We preserve .a as extension for shared libraries through AIX4.2 - # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}${shared_ext}$major' - fi - shlibpath_var=LIBPATH - fi - ;; - -amigaos*) - case $host_cpu in - powerpc) - # Since July 2007 AmigaOS4 officially supports .so libraries. - # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - ;; - m68k) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' - ;; - esac - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi[45]*) - version_type=linux # correct to gnu/linux during the next big refactor - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" - sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" - # the default ld.so.conf also contains /usr/contrib/lib and - # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow - # libtool to hard-code these into programs - ;; - -cygwin* | mingw* | pw32* | cegcc*) - version_type=windows - shrext_cmds=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$cc_basename in - yes,*) - # gcc - library_names_spec='$libname.dll.a' - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname~ - chmod a+x \$dldir/$dlname~ - if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then - eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; - fi' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - - case $host_os in - cygwin*) - # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - - sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" - ;; - mingw* | cegcc*) - # MinGW DLLs use traditional 'lib' prefix - soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - ;; - pw32*) - # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - ;; - esac - dynamic_linker='Win32 ld.exe' - ;; - - *,cl*) - # Native MSVC - libname_spec='$name' - soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - library_names_spec='${libname}.dll.lib' - - case $build_os in - mingw*) - sys_lib_search_path_spec= - lt_save_ifs=$IFS - IFS=';' - for lt_path in $LIB - do - IFS=$lt_save_ifs - # Let DOS variable expansion print the short 8.3 style file name. - lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` - sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" - done - IFS=$lt_save_ifs - # Convert to MSYS style. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` - ;; - cygwin*) - # Convert to unix form, then to dos form, then back to unix form - # but this time dos style (no spaces!) so that the unix form looks - # like /cygdrive/c/PROGRA~1:/cygdr... - sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` - sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` - sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - ;; - *) - sys_lib_search_path_spec="$LIB" - if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then - # It is most probably a Windows format PATH. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - # FIXME: find the short name or the path components, as spaces are - # common. (e.g. "Program Files" -> "PROGRA~1") - ;; - esac - - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - dynamic_linker='Win32 link.exe' - ;; - - *) - # Assume MSVC wrapper - library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' - dynamic_linker='Win32 ld.exe' - ;; - esac - # FIXME: first we should search . and the directory the executable is in - shlibpath_var=PATH - ;; - -darwin* | rhapsody*) - dynamic_linker="$host_os dyld" - version_type=darwin - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' - soname_spec='${libname}${release}${major}$shared_ext' - shlibpath_overrides_runpath=yes - shlibpath_var=DYLD_LIBRARY_PATH - shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' - - sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" - sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' - ;; - -dgux*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -freebsd* | dragonfly*) - # DragonFly does not have aout. When/if they implement a new - # versioning mechanism, adjust this. - if test -x /usr/bin/objformat; then - objformat=`/usr/bin/objformat` - else - case $host_os in - freebsd[23].*) objformat=aout ;; - *) objformat=elf ;; - esac - fi - version_type=freebsd-$objformat - case $version_type in - freebsd-elf*) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - need_version=no - need_lib_prefix=no - ;; - freebsd-*) - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' - need_version=yes - ;; - esac - shlibpath_var=LD_LIBRARY_PATH - case $host_os in - freebsd2.*) - shlibpath_overrides_runpath=yes - ;; - freebsd3.[01]* | freebsdelf3.[01]*) - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ - freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - *) # from 4.6 on, and DragonFly - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - esac - ;; - -gnu*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -haiku*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - dynamic_linker="$host_os runtime_loader" - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LIBRARY_PATH - shlibpath_overrides_runpath=yes - sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' - hardcode_into_libs=yes - ;; - -hpux9* | hpux10* | hpux11*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - version_type=sunos - need_lib_prefix=no - need_version=no - case $host_cpu in - ia64*) - shrext_cmds='.so' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.so" - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - if test "X$HPUX_IA64_MODE" = X32; then - sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" - else - sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" - fi - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - hppa*64*) - shrext_cmds='.sl' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.sl" - shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - *) - shrext_cmds='.sl' - dynamic_linker="$host_os dld.sl" - shlibpath_var=SHLIB_PATH - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - ;; - esac - # HP-UX runs *really* slowly unless shared libraries are mode 555, ... - postinstall_cmds='chmod 555 $lib' - # or fails outright, so override atomically: - install_override_mode=555 - ;; - -interix[3-9]*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -irix5* | irix6* | nonstopux*) - case $host_os in - nonstopux*) version_type=nonstopux ;; - *) - if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux # correct to gnu/linux during the next big refactor - else - version_type=irix - fi ;; - esac - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' - case $host_os in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in # libtool.m4 will add one of these switches to LD - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") - libsuff= shlibsuff= libmagic=32-bit;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") - libsuff=32 shlibsuff=N32 libmagic=N32;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") - libsuff=64 shlibsuff=64 libmagic=64-bit;; - *) libsuff= shlibsuff= libmagic=never-match;; - esac - ;; - esac - shlibpath_var=LD_LIBRARY${shlibsuff}_PATH - shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" - hardcode_into_libs=yes - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux*oldld* | linux*aout* | linux*coff*) - dynamic_linker=no - ;; - -# This must be glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - - # Some binutils ld are patched to set DT_RUNPATH - if ${lt_cv_shlibpath_overrides_runpath+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_shlibpath_overrides_runpath=no - save_LDFLAGS=$LDFLAGS - save_libdir=$libdir - eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ - LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : - lt_cv_shlibpath_overrides_runpath=yes -fi -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS=$save_LDFLAGS - libdir=$save_libdir - -fi - - shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath - - # This implies no fast_install, which is unacceptable. - # Some rework will be needed to allow for fast_install - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on - # powerpc, because MkLinux only supported shared libraries with the - # GNU dynamic linker. Since this was broken with cross compilers, - # most powerpc-linux boxes support dynamic linking these days and - # people can always --disable-shared, the test was removed, and we - # assume the GNU/Linux dynamic linker is in use. - dynamic_linker='GNU/Linux ld.so' - ;; - -netbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - dynamic_linker='NetBSD (a.out) ld.so' - else - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='NetBSD ld.elf_so' - fi - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - -newsos6) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -*nto* | *qnx*) - version_type=qnx - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='ldqnx.so' - ;; - -openbsd*) - version_type=sunos - sys_lib_dlsearch_path_spec="/usr/lib" - need_lib_prefix=no - # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. - case $host_os in - openbsd3.3 | openbsd3.3.*) need_version=yes ;; - *) need_version=no ;; - esac - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case $host_os in - openbsd2.[89] | openbsd2.[89].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi - ;; - -os2*) - libname_spec='$name' - shrext_cmds=".dll" - need_lib_prefix=no - library_names_spec='$libname${shared_ext} $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - -osf3* | osf4* | osf5*) - version_type=osf - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" - ;; - -rdos*) - dynamic_linker=no - ;; - -solaris*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - # ldd complains unless libraries are executable - postinstall_cmds='chmod +x $lib' - ;; - -sunos4*) - version_type=sunos - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - fi - need_version=yes - ;; - -sysv4 | sysv4.3*) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - case $host_vendor in - sni) - shlibpath_overrides_runpath=no - need_lib_prefix=no - runpath_var=LD_RUN_PATH - ;; - siemens) - need_lib_prefix=no - ;; - motorola) - need_lib_prefix=no - need_version=no - shlibpath_overrides_runpath=no - sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' - ;; - esac - ;; - -sysv4*MP*) - if test -d /usr/nec ;then - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' - soname_spec='$libname${shared_ext}.$major' - shlibpath_var=LD_LIBRARY_PATH - fi - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - version_type=freebsd-elf - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - if test "$with_gnu_ld" = yes; then - sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' - else - sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' - case $host_os in - sco3.2v5*) - sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" - ;; - esac - fi - sys_lib_dlsearch_path_spec='/usr/lib' - ;; - -tpf*) - # TPF is a cross-target only. Preferred cross-host = GNU/Linux. - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -uts4*) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -*) - dynamic_linker=no - ;; -esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 -$as_echo "$dynamic_linker" >&6; } -test "$dynamic_linker" = no && can_build_shared=no - -variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then - variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -fi - -if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then - sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" -fi -if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then - sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" -fi - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 -$as_echo_n "checking how to hardcode library paths into programs... " >&6; } -hardcode_action= -if test -n "$hardcode_libdir_flag_spec" || - test -n "$runpath_var" || - test "X$hardcode_automatic" = "Xyes" ; then - - # We can hardcode non-existent directories. - if test "$hardcode_direct" != no && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && - test "$hardcode_minus_L" != no; then - # Linking always hardcodes the temporary library directory. - hardcode_action=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - hardcode_action=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - hardcode_action=unsupported -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 -$as_echo "$hardcode_action" >&6; } - -if test "$hardcode_action" = relink || - test "$inherit_rpath" = yes; then - # Fast installation is not supported - enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then - # Fast installation is not necessary - enable_fast_install=needless -fi - - - - - - - if test "x$enable_dlopen" != xyes; then - enable_dlopen=unknown - enable_dlopen_self=unknown - enable_dlopen_self_static=unknown -else - lt_cv_dlopen=no - lt_cv_dlopen_libs= - - case $host_os in - beos*) - lt_cv_dlopen="load_add_on" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ;; - - mingw* | pw32* | cegcc*) - lt_cv_dlopen="LoadLibrary" - lt_cv_dlopen_libs= - ;; - - cygwin*) - lt_cv_dlopen="dlopen" - lt_cv_dlopen_libs= - ;; - - darwin*) - # if libdl is installed we need to link against it - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 -$as_echo_n "checking for dlopen in -ldl... " >&6; } -if ${ac_cv_lib_dl_dlopen+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dlopen (); -int -main () -{ -return dlopen (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_dl_dlopen=yes -else - ac_cv_lib_dl_dlopen=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 -$as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = xyes; then : - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -else - - lt_cv_dlopen="dyld" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - -fi - - ;; - - *) - ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" -if test "x$ac_cv_func_shl_load" = xyes; then : - lt_cv_dlopen="shl_load" -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 -$as_echo_n "checking for shl_load in -ldld... " >&6; } -if ${ac_cv_lib_dld_shl_load+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldld $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char shl_load (); -int -main () -{ -return shl_load (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_dld_shl_load=yes -else - ac_cv_lib_dld_shl_load=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 -$as_echo "$ac_cv_lib_dld_shl_load" >&6; } -if test "x$ac_cv_lib_dld_shl_load" = xyes; then : - lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" -else - ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" -if test "x$ac_cv_func_dlopen" = xyes; then : - lt_cv_dlopen="dlopen" -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 -$as_echo_n "checking for dlopen in -ldl... " >&6; } -if ${ac_cv_lib_dl_dlopen+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dlopen (); -int -main () -{ -return dlopen (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_dl_dlopen=yes -else - ac_cv_lib_dl_dlopen=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 -$as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = xyes; then : - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 -$as_echo_n "checking for dlopen in -lsvld... " >&6; } -if ${ac_cv_lib_svld_dlopen+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lsvld $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dlopen (); -int -main () -{ -return dlopen (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_svld_dlopen=yes -else - ac_cv_lib_svld_dlopen=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 -$as_echo "$ac_cv_lib_svld_dlopen" >&6; } -if test "x$ac_cv_lib_svld_dlopen" = xyes; then : - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 -$as_echo_n "checking for dld_link in -ldld... " >&6; } -if ${ac_cv_lib_dld_dld_link+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldld $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dld_link (); -int -main () -{ -return dld_link (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_dld_dld_link=yes -else - ac_cv_lib_dld_dld_link=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 -$as_echo "$ac_cv_lib_dld_dld_link" >&6; } -if test "x$ac_cv_lib_dld_dld_link" = xyes; then : - lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" -fi - - -fi - - -fi - - -fi - - -fi - - -fi - - ;; - esac - - if test "x$lt_cv_dlopen" != xno; then - enable_dlopen=yes - else - enable_dlopen=no - fi - - case $lt_cv_dlopen in - dlopen) - save_CPPFLAGS="$CPPFLAGS" - test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" - - save_LDFLAGS="$LDFLAGS" - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - - save_LIBS="$LIBS" - LIBS="$lt_cv_dlopen_libs $LIBS" - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 -$as_echo_n "checking whether a program can dlopen itself... " >&6; } -if ${lt_cv_dlopen_self+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - lt_cv_dlopen_self=cross -else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<_LT_EOF -#line $LINENO "configure" -#include "confdefs.h" - -#if HAVE_DLFCN_H -#include -#endif - -#include - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -/* When -fvisbility=hidden is used, assume the code has been annotated - correspondingly for the symbols needed. */ -#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) -int fnord () __attribute__((visibility("default"))); -#endif - -int fnord () { return 42; } -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else - { - if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - else puts (dlerror ()); - } - /* dlclose (self); */ - } - else - puts (dlerror ()); - - return status; -} -_LT_EOF - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 - (eval $ac_link) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) >&5 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; - x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; - x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; - esac - else : - # compilation failed - lt_cv_dlopen_self=no - fi -fi -rm -fr conftest* - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 -$as_echo "$lt_cv_dlopen_self" >&6; } - - if test "x$lt_cv_dlopen_self" = xyes; then - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 -$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } -if ${lt_cv_dlopen_self_static+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - lt_cv_dlopen_self_static=cross -else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<_LT_EOF -#line $LINENO "configure" -#include "confdefs.h" - -#if HAVE_DLFCN_H -#include -#endif - -#include - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -/* When -fvisbility=hidden is used, assume the code has been annotated - correspondingly for the symbols needed. */ -#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) -int fnord () __attribute__((visibility("default"))); -#endif - -int fnord () { return 42; } -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else - { - if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - else puts (dlerror ()); - } - /* dlclose (self); */ - } - else - puts (dlerror ()); - - return status; -} -_LT_EOF - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 - (eval $ac_link) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) >&5 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; - x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; - x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; - esac - else : - # compilation failed - lt_cv_dlopen_self_static=no - fi -fi -rm -fr conftest* - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 -$as_echo "$lt_cv_dlopen_self_static" >&6; } - fi - - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - LIBS="$save_LIBS" - ;; - esac - - case $lt_cv_dlopen_self in - yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; - *) enable_dlopen_self=unknown ;; - esac - - case $lt_cv_dlopen_self_static in - yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; - *) enable_dlopen_self_static=unknown ;; - esac -fi - - - - - - - - - - - - - - - - - -striplib= -old_striplib= -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 -$as_echo_n "checking whether stripping libraries is possible... " >&6; } -if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" - test -z "$striplib" && striplib="$STRIP --strip-unneeded" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else -# FIXME - insert some real tests, host_os isn't really good enough - case $host_os in - darwin*) - if test -n "$STRIP" ; then - striplib="$STRIP -x" - old_striplib="$STRIP -S" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - fi - ;; - *) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - ;; - esac -fi - - - - - - - - - - - - - # Report which library types will actually be built - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 -$as_echo_n "checking if libtool supports shared libraries... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 -$as_echo "$can_build_shared" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 -$as_echo_n "checking whether to build shared libraries... " >&6; } - test "$can_build_shared" = "no" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - - aix[4-9]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - esac - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 -$as_echo "$enable_shared" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 -$as_echo_n "checking whether to build static libraries... " >&6; } - # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 -$as_echo "$enable_static" >&6; } - - - - -fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -CC="$lt_save_CC" - - - - - - - - - - - - - - - - ac_config_commands="$ac_config_commands libtool" - - - - -# Only expand once: - - - # get libtool's setting of shlibpath_var - eval `grep "^shlibpath_var=[A-Z_]*$" $apr_builddir/libtool` - if test "x$shlibpath_var" = "x"; then - shlibpath_var=REPLACE_WITH_YOUR_SHLIBPATH_VAR - fi - fi - ;; -esac - - -# Check whether --with-installbuilddir was given. -if test "${with_installbuilddir+set}" = set; then : - withval=$with_installbuilddir; installbuilddir=$withval -else - installbuilddir="${datadir}/build-${APR_MAJOR_VERSION}" -fi - - - - -# Check whether --with-libtool was given. -if test "${with_libtool+set}" = set; then : - withval=$with_libtool; use_libtool=$withval -else - use_libtool="yes" -fi - - -if test "x$use_libtool" = "xyes"; then - lt_compile='$(LIBTOOL) $(LTFLAGS) --mode=compile $(COMPILE) -o $@ -c $< && touch $@' - LT_VERSION="-version-info `$get_version libtool $version_hdr APR`" - link="\$(LIBTOOL) \$(LTFLAGS) --mode=link \$(LT_LDFLAGS) \$(COMPILE) \$(LT_VERSION) \$(ALL_LDFLAGS) -o \$@" - so_ext='lo' - lib_target='-rpath $(libdir) $(OBJECTS)' - export_lib_target='-rpath \$(libdir) \$(OBJECTS)' -else - lt_compile='$(COMPILE) -o $@ -c $<' - link='$(AR) cr $(TARGET_LIB) $(OBJECTS); $(RANLIB) $(TARGET_LIB)' - so_ext='o' - lib_target='' - export_lib_target='' -fi - -case $host in - *-solaris2*) - apr_platform_runtime_link_flag="-R" - ;; - *) - ;; -esac - - - - - - - - - - - -nl=' -' -echo "${nl}Check for compiler flags..." - - -case $host in - *os390) - if test "$ac_test_CFLAGS" != set; then - - if test "x$CFLAGS" = "x-g"; then - test "x$silent" != "xyes" && echo " nulling CFLAGS" - CFLAGS="" - else - apr_new_bugger="" - apr_removed=0 - for i in $CFLAGS; do - if test "x$i" != "x-g"; then - apr_new_bugger="$apr_new_bugger $i" - else - apr_removed=1 - fi - done - if test $apr_removed = "1"; then - test "x$silent" != "xyes" && echo " removed \"-g\" from CFLAGS" - CFLAGS=$apr_new_bugger - fi - fi - - fi - ;; -esac - -# Check whether --enable-debug was given. -if test "${enable_debug+set}" = set; then : - enableval=$enable_debug; - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-g\"" - CFLAGS="-g" - else - apr_addto_bugger="-g" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - if test "$GCC" = "yes"; then - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-Wall\"" - CFLAGS="-Wall" - else - apr_addto_bugger="-Wall" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - elif test "$AIX_XLC" = "yes"; then - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-qfullpath\"" - CFLAGS="-qfullpath" - else - apr_addto_bugger="-qfullpath" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - fi - -fi - -# Check whether --enable-maintainer-mode was given. -if test "${enable_maintainer_mode+set}" = set; then : - enableval=$enable_maintainer_mode; - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-g\"" - CFLAGS="-g" - else - apr_addto_bugger="-g" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - if test "$GCC" = "yes"; then - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations\"" - CFLAGS="-Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations" - else - apr_addto_bugger="-Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - elif test "$AIX_XLC" = "yes"; then - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-qfullpath -qinitauto=FE -qcheck=all -qinfo=pro\"" - CFLAGS="-qfullpath -qinitauto=FE -qcheck=all -qinfo=pro" - else - apr_addto_bugger="-qfullpath -qinitauto=FE -qcheck=all -qinfo=pro" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - fi - -fi - -# Check whether --enable-profile was given. -if test "${enable_profile+set}" = set; then : - enableval=$enable_profile; if test "$GCC" = "yes"; then - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-pg\"" - CFLAGS="-pg" - else - apr_addto_bugger="-pg" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - - if test "x$CFLAGS" = "x-g"; then - test "x$silent" != "xyes" && echo " nulling CFLAGS" - CFLAGS="" - else - apr_new_bugger="" - apr_removed=0 - for i in $CFLAGS; do - if test "x$i" != "x-g"; then - apr_new_bugger="$apr_new_bugger $i" - else - apr_removed=1 - fi - done - if test $apr_removed = "1"; then - test "x$silent" != "xyes" && echo " removed \"-g\" from CFLAGS" - CFLAGS=$apr_new_bugger - fi - fi - - if test "$host" = "i586-pc-beos"; then - - if test "x$CFLAGS" = "x-O2"; then - test "x$silent" != "xyes" && echo " nulling CFLAGS" - CFLAGS="" - else - apr_new_bugger="" - apr_removed=0 - for i in $CFLAGS; do - if test "x$i" != "x-O2"; then - apr_new_bugger="$apr_new_bugger $i" - else - apr_removed=1 - fi - done - if test $apr_removed = "1"; then - test "x$silent" != "xyes" && echo " removed \"-O2\" from CFLAGS" - CFLAGS=$apr_new_bugger - fi - fi - - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-O1\"" - CFLAGS="-O1" - else - apr_addto_bugger="-O1" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - - if test "x$LDFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting LDFLAGS to \"-p\"" - LDFLAGS="-p" - else - apr_addto_bugger="-p" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LDFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LDFLAGS" - LDFLAGS="$LDFLAGS $i" - fi - done - fi - - fi - fi - -fi - -# Check whether --enable-pool-debug was given. -if test "${enable_pool_debug+set}" = set; then : - enableval=$enable_pool_debug; if test -z "$enableval"; then - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DAPR_POOL_DEBUG=1\"" - CPPFLAGS="-DAPR_POOL_DEBUG=1" - else - apr_addto_bugger="-DAPR_POOL_DEBUG=1" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - elif test ! "$enableval" = "no"; then - apr_pool_debug=1 - - for i in $enableval - do - flag=0 - - case $i in - yes) - flag=1 - ;; - verbose) - flag=2 - ;; - lifetime) - flag=4 - ;; - owner) - flag=8 - ;; - verbose-alloc) - flag=16 - ;; - all) - apr_pool_debug=31 - ;; - *) - ;; - esac - - if test $flag -gt 0; then - apr_pool_debug=`expr '(' $apr_pool_debug - $apr_pool_debug % \ - '(' $flag '*' 2 ')' ')' + $flag + $apr_pool_debug % $flag` - fi - done - - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DAPR_POOL_DEBUG=$apr_pool_debug\"" - CPPFLAGS="-DAPR_POOL_DEBUG=$apr_pool_debug" - else - apr_addto_bugger="-DAPR_POOL_DEBUG=$apr_pool_debug" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - fi - -fi - - -if test "$host" = "i586-pc-beos"; then - # Check whether --enable-malloc-debug was given. -if test "${enable_malloc_debug+set}" = set; then : - enableval=$enable_malloc_debug; - if test "x$CFLAGS" = "x-O2"; then - test "x$silent" != "xyes" && echo " nulling CFLAGS" - CFLAGS="" - else - apr_new_bugger="" - apr_removed=0 - for i in $CFLAGS; do - if test "x$i" != "x-O2"; then - apr_new_bugger="$apr_new_bugger $i" - else - apr_removed=1 - fi - done - if test $apr_removed = "1"; then - test "x$silent" != "xyes" && echo " removed \"-O2\" from CFLAGS" - CFLAGS=$apr_new_bugger - fi - fi - - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-fcheck-memory-usage -D_KERNEL_MODE\"" - CPPFLAGS="-fcheck-memory-usage -D_KERNEL_MODE" - else - apr_addto_bugger="-fcheck-memory-usage -D_KERNEL_MODE" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - -fi - fi - -# this is the place to put specific options for platform/compiler -# combinations -case "$host:$CC" in - *-hp-hpux*:cc ) - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-Ae +Z\"" - CFLAGS="-Ae +Z" - else - apr_addto_bugger="-Ae +Z" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - case $host in - ia64-* ) - ;; - * ) - if echo "$CFLAGS " | grep '+DA' >/dev/null; then : - else - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"+DAportable\"" - CFLAGS="+DAportable" - else - apr_addto_bugger="+DAportable" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - fi - ;; - esac - ;; - powerpc-*-beos:mwcc* ) - - test "x$silent" != "xyes" && echo " forcing CPP to \"mwcc -E\"" - CPP="mwcc -E" - - - test "x$silent" != "xyes" && echo " forcing CC to \"mwcc\"" - CC="mwcc" - - - test "x$silent" != "xyes" && echo " forcing AR to \"ar\"" - AR="ar" - - ;; -esac - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler provides atomic builtins" >&5 -$as_echo_n "checking whether the compiler provides atomic builtins... " >&6; } -if ${ap_cv_atomic_builtins+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ap_cv_atomic_builtins=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int main() -{ - unsigned long val = 1010, tmp, *mem = &val; - - if (__sync_fetch_and_add(&val, 1010) != 1010 || val != 2020) - return 1; - - tmp = val; - - if (__sync_fetch_and_sub(mem, 1010) != tmp || val != 1010) - return 1; - - if (__sync_sub_and_fetch(&val, 1010) != 0 || val != 0) - return 1; - - tmp = 3030; - - if (__sync_val_compare_and_swap(mem, 0, tmp) != 0 || val != tmp) - return 1; - - if (__sync_lock_test_and_set(&val, 4040) != 3030) - return 1; - - mem = &tmp; - - if (__sync_val_compare_and_swap(&mem, &tmp, &val) != &tmp) - return 1; - - __sync_synchronize(); - - if (mem != &val) - return 1; - - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ap_cv_atomic_builtins=yes -else - ap_cv_atomic_builtins=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ap_cv_atomic_builtins" >&5 -$as_echo "$ap_cv_atomic_builtins" >&6; } - -if test "$ap_cv_atomic_builtins" = "yes"; then - -$as_echo "#define HAVE_ATOMIC_BUILTINS 1" >>confdefs.h - -fi - -case $host in - powerpc-405-*) - # The IBM ppc405cr processor has a bugged stwcx instruction. - -$as_echo "#define PPC405_ERRATA 1" >>confdefs.h - - ;; - *) - ;; -esac - - -if test "$GCC" = "yes"; then - MKDEP='$(CC) -MM' -else - rm -f conftest.c - cat > conftest.c < - int main() { return 0; } -EOF - MKDEP="true" - for i in "$CC -MM" "$CC -M" "$CPP -MM" "$CPP -M" "cpp -M"; do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $i can create proper make dependencies" >&5 -$as_echo_n "checking if $i can create proper make dependencies... " >&6; } - if $i conftest.c 2>/dev/null | grep 'conftest.o: conftest.c' >/dev/null; then - MKDEP=$i - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - break; - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - done - rm -f conftest.c -fi - - - - -proc_mutex_is_global=0 - -config_subdirs="none" -INSTALL_SUBDIRS="none" -OBJECTS_PLATFORM='$(OBJECTS_unix)' - -case $host in - i386-ibm-aix* | *-ibm-aix[1-2].* | *-ibm-aix3.* | *-ibm-aix4.1 | *-ibm-aix4.1.* | *-ibm-aix4.2 | *-ibm-aix4.2.*) - OSDIR="aix" - - if test "x$LDFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting LDFLAGS to \"-lld\"" - LDFLAGS="-lld" - else - apr_addto_bugger="-lld" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LDFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LDFLAGS" - LDFLAGS="$LDFLAGS $i" - fi - done - fi - - eolstr="\\n" - OBJECTS_PLATFORM='$(OBJECTS_aix)' - ;; - *-os2*) - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DOS2\"" - CPPFLAGS="-DOS2" - else - apr_addto_bugger="-DOS2" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"-Zmt\"" - CFLAGS="-Zmt" - else - apr_addto_bugger="-Zmt" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for random in -lbsd" >&5 -$as_echo_n "checking for random in -lbsd... " >&6; } -if ${ac_cv_lib_bsd_random+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lbsd $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char random (); -int -main () -{ -return random (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_bsd_random=yes -else - ac_cv_lib_bsd_random=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_random" >&5 -$as_echo "$ac_cv_lib_bsd_random" >&6; } -if test "x$ac_cv_lib_bsd_random" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBBSD 1 -_ACEOF - - LIBS="-lbsd $LIBS" - -fi - - OSDIR="os2" - enable_threads="system_threads" - eolstr="\\r\\n" - file_as_socket="0" - proc_mutex_is_global=1 - OBJECTS_PLATFORM='$(OBJECTS_os2)' - ;; - *beos*) - OSDIR="beos" - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DBEOS\"" - CPPFLAGS="-DBEOS" - else - apr_addto_bugger="-DBEOS" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - enable_threads="system_threads" - native_mmap_emul="1" - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BONE_VERSION in sys/socket.h" >&5 -$as_echo_n "checking for BONE_VERSION in sys/socket.h... " >&6; } -if ${ac_cv_define_BONE_VERSION+:} false; then : - $as_echo_n "(cached) " >&6 -else - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#ifdef BONE_VERSION -YES_IS_DEFINED -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "YES_IS_DEFINED" >/dev/null 2>&1; then : - ac_cv_define_BONE_VERSION=yes -else - ac_cv_define_BONE_VERSION=no -fi -rm -f conftest* - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_define_BONE_VERSION" >&5 -$as_echo "$ac_cv_define_BONE_VERSION" >&6; } - if test "$ac_cv_define_BONE_VERSION" = "yes"; then - -$as_echo "#define HAVE_BONE_VERSION 1" >>confdefs.h - - fi - - eolstr="\\n" - osver=`uname -r` - proc_mutex_is_global=1 - OBJECTS_PLATFORM='$(OBJECTS_beos)' - case $osver in - 5.0.4) - file_as_socket="1" - ;; - *) - file_as_socket="0" - ;; - esac - ;; - *os390) - OSDIR="os390" - OBJECTS_PLATFORM='$(OBJECTS_os390)' - eolstr="\\n" - ;; - *os400) - OSDIR="as400" - eolstr="\\n" - ;; - *mingw*) - OSDIR="win32" - enable_threads="system_threads" - eolstr="\\r\\n" - file_as_socket=0 - proc_mutex_is_global=1 - OBJECTS_PLATFORM='$(OBJECTS_win32)' - ;; - *cygwin*) - OSDIR="unix" - enable_threads="no" - eolstr="\\n" - ;; - *hpux10* ) - enable_threads="no" - OSDIR="unix" - eolstr="\\n" - ;; - *) - OSDIR="unix" - eolstr="\\n" - ;; -esac - - - -# Check whether LFS has explicitly been disabled -# Check whether --enable-lfs was given. -if test "${enable_lfs+set}" = set; then : - enableval=$enable_lfs; apr_lfs_choice=$enableval -else - apr_lfs_choice=yes -fi - - -if test "$apr_lfs_choice" = "yes"; then - # Check whether the transitional LFS API is sufficient - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable -D_LARGEFILE64_SOURCE" >&5 -$as_echo_n "checking whether to enable -D_LARGEFILE64_SOURCE... " >&6; } -if ${apr_cv_use_lfs64+:} false; then : - $as_echo_n "(cached) " >&6 -else - - apr_save_CPPFLAGS=$CPPFLAGS - CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE" - if test "$cross_compiling" = yes; then : - apr_cv_use_lfs64=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -#include -#include -#include - -void main(void) -{ - int fd, ret = 0; - struct stat64 st; - off64_t off = 4242; - - if (sizeof(off64_t) != 8 || sizeof(off_t) != 4) - exit(1); - if ((fd = open("conftest.lfs", O_LARGEFILE|O_CREAT|O_WRONLY, 0644)) < 0) - exit(2); - if (ftruncate64(fd, off) != 0) - ret = 3; - else if (fstat64(fd, &st) != 0 || st.st_size != off) - ret = 4; - else if (lseek64(fd, off, SEEK_SET) != off) - ret = 5; - else if (close(fd) != 0) - ret = 6; - else if (lstat64("conftest.lfs", &st) != 0 || st.st_size != off) - ret = 7; - else if (stat64("conftest.lfs", &st) != 0 || st.st_size != off) - ret = 8; - unlink("conftest.lfs"); - - exit(ret); -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - apr_cv_use_lfs64=yes -else - apr_cv_use_lfs64=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - - CPPFLAGS=$apr_save_CPPFLAGS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_use_lfs64" >&5 -$as_echo "$apr_cv_use_lfs64" >&6; } - if test "$apr_cv_use_lfs64" = "yes"; then - - if test "x$CPPFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-D_LARGEFILE64_SOURCE\"" - CPPFLAGS="-D_LARGEFILE64_SOURCE" - else - apr_addto_bugger="-D_LARGEFILE64_SOURCE" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CPPFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS="$CPPFLAGS $i" - fi - done - fi - - fi -fi - -# Check whether --enable-nonportable-atomics was given. -if test "${enable_nonportable_atomics+set}" = set; then : - enableval=$enable_nonportable_atomics; if test $enableval = yes; then - force_generic_atomics=no - else - force_generic_atomics=yes - fi - -else - case $host_cpu in - i[456]86) force_generic_atomics=yes ;; - *) force_generic_atomics=no ;; -esac - -fi - - -if test $force_generic_atomics = yes; then - -$as_echo "#define USE_ATOMICS_GENERIC 1" >>confdefs.h - -fi - - - - - -# For some platforms we need a version string which allows easy numeric -# comparisons. -case $host in - *freebsd*) - if test -x /sbin/sysctl; then - os_version=`/sbin/sysctl -n kern.osreldate` - else - os_version=000000 - fi - ;; - *linux*) - os_version=`uname -r | sed -e 's/\(.\)\.\(.\)\.\(.\).*/\1\2\3/'` - ;; - *os390) - os_version=`uname -r | sed -e 's/\.//g'` - ;; - *) - os_version=OS_VERSION_IS_NOT_SET - ;; -esac - -echo "${nl}Checking for libraries..." - -case $host in - *mingw*) - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lshell32 -ladvapi32 -lws2_32 -lrpcrt4 -lmswsock\"" - LIBS="-lshell32 -ladvapi32 -lws2_32 -lrpcrt4 -lmswsock" - else - apr_addto_bugger="-lshell32 -ladvapi32 -lws2_32 -lrpcrt4 -lmswsock" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - ac_cv_func_CreateFileMapping=yes - ;; - *) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5 -$as_echo_n "checking for library containing gethostbyname... " >&6; } -if ${ac_cv_search_gethostbyname+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char gethostbyname (); -int -main () -{ -return gethostbyname (); - ; - return 0; -} -_ACEOF -for ac_lib in '' nsl; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_gethostbyname=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_gethostbyname+:} false; then : - break -fi -done -if ${ac_cv_search_gethostbyname+:} false; then : - -else - ac_cv_search_gethostbyname=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostbyname" >&5 -$as_echo "$ac_cv_search_gethostbyname" >&6; } -ac_res=$ac_cv_search_gethostbyname -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostname" >&5 -$as_echo_n "checking for library containing gethostname... " >&6; } -if ${ac_cv_search_gethostname+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char gethostname (); -int -main () -{ -return gethostname (); - ; - return 0; -} -_ACEOF -for ac_lib in '' nsl; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_gethostname=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_gethostname+:} false; then : - break -fi -done -if ${ac_cv_search_gethostname+:} false; then : - -else - ac_cv_search_gethostname=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostname" >&5 -$as_echo "$ac_cv_search_gethostname" >&6; } -ac_res=$ac_cv_search_gethostname -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing socket" >&5 -$as_echo_n "checking for library containing socket... " >&6; } -if ${ac_cv_search_socket+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char socket (); -int -main () -{ -return socket (); - ; - return 0; -} -_ACEOF -for ac_lib in '' socket; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_socket=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_socket+:} false; then : - break -fi -done -if ${ac_cv_search_socket+:} false; then : - -else - ac_cv_search_socket=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_socket" >&5 -$as_echo "$ac_cv_search_socket" >&6; } -ac_res=$ac_cv_search_socket -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing crypt" >&5 -$as_echo_n "checking for library containing crypt... " >&6; } -if ${ac_cv_search_crypt+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char crypt (); -int -main () -{ -return crypt (); - ; - return 0; -} -_ACEOF -for ac_lib in '' crypt ufc; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_crypt=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_crypt+:} false; then : - break -fi -done -if ${ac_cv_search_crypt+:} false; then : - -else - ac_cv_search_crypt=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_crypt" >&5 -$as_echo "$ac_cv_search_crypt" >&6; } -ac_res=$ac_cv_search_crypt -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -ltruerand" >&5 -$as_echo_n "checking for main in -ltruerand... " >&6; } -if ${ac_cv_lib_truerand_main+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ltruerand $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - -int -main () -{ -return main (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_truerand_main=yes -else - ac_cv_lib_truerand_main=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_truerand_main" >&5 -$as_echo "$ac_cv_lib_truerand_main" >&6; } -if test "x$ac_cv_lib_truerand_main" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBTRUERAND 1 -_ACEOF - - LIBS="-ltruerand $LIBS" - -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing modf" >&5 -$as_echo_n "checking for library containing modf... " >&6; } -if ${ac_cv_search_modf+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char modf (); -int -main () -{ -return modf (); - ; - return 0; -} -_ACEOF -for ac_lib in '' m; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_modf=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_modf+:} false; then : - break -fi -done -if ${ac_cv_search_modf+:} false; then : - -else - ac_cv_search_modf=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_modf" >&5 -$as_echo "$ac_cv_search_modf" >&6; } -ac_res=$ac_cv_search_modf -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -fi - - ;; -esac - -echo "${nl}Checking for Threads..." - -if test -z "$enable_threads"; then - # Check whether --enable-threads was given. -if test "${enable_threads+set}" = set; then : - enableval=$enable_threads; enable_threads=$enableval -else - - if test "$GCC" = "yes"; then - SAVE_FL="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS -w" - for ac_header in pthread.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" -if test "x$ac_cv_header_pthread_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_PTHREAD_H 1 -_ACEOF - enable_threads="pthread" -else - enable_threads="no" -fi - -done - - CPPFLAGS="$SAVE_FL" - else - for ac_header in pthread.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" -if test "x$ac_cv_header_pthread_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_PTHREAD_H 1 -_ACEOF - enable_threads="pthread" -else - enable_threads="no" -fi - -done - - fi - -fi - -fi - -if test "$enable_threads" = "no"; then - threads="0" - pthreadh="0" - pthreadser="0" -else - if test "$enable_threads" = "pthread"; then -# We have specified pthreads for our threading library, just make sure -# that we have everything we need - - apr_pthsv_CFLAGS="$CFLAGS" - apr_pthsv_LIBS="$LIBS" - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CFLAGS needed for pthreads" >&5 -$as_echo_n "checking for CFLAGS needed for pthreads... " >&6; } -if ${apr_cv_pthreads_cflags+:} false; then : - $as_echo_n "(cached) " >&6 -else - apr_ptc_cflags=$CFLAGS - for flag in none -kthread -pthread -pthreads -mt -mthreads -Kthread -threads; do - CFLAGS=$apr_ptc_cflags - test "x$flag" != "xnone" && CFLAGS="$CFLAGS $flag" - -if test "$cross_compiling" = yes; then : - apr_p_t_r=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include - -void *thread_routine(void *data) { - return data; -} - -int main() { - pthread_t thd; - pthread_mutexattr_t mattr; - pthread_once_t once_init = PTHREAD_ONCE_INIT; - int data = 1; - pthread_mutexattr_init(&mattr); - return pthread_create(&thd, NULL, thread_routine, &data); -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - apr_p_t_r=yes -else - apr_p_t_r=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - - -if test $apr_p_t_r = yes; then - - apr_cv_pthreads_cflags="$flag" - break - -fi - - - done - CFLAGS=$apr_ptc_cflags - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_pthreads_cflags" >&5 -$as_echo "$apr_cv_pthreads_cflags" >&6; } - -if test -n "$apr_cv_pthreads_cflags"; then - pthreads_working=yes - if test "x$apr_cv_pthreads_cflags" != "xnone"; then - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"$apr_cv_pthreads_cflags\"" - CFLAGS="$apr_cv_pthreads_cflags" - else - apr_addto_bugger="$apr_cv_pthreads_cflags" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - fi -fi - -# The CFLAGS may or may not be sufficient to ensure that libapr -# depends on the pthreads library: some versions of libtool -# drop -pthread when passed on the link line; some versions of -# gcc ignore -pthread when linking a shared object. So always -# try and add the relevant library to LIBS too. - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBS needed for pthreads" >&5 -$as_echo_n "checking for LIBS needed for pthreads... " >&6; } -if ${apr_cv_pthreads_lib+:} false; then : - $as_echo_n "(cached) " >&6 -else - - apr_ptc_libs=$LIBS - for lib in -lpthread -lpthreads -lc_r; do - LIBS="$apr_ptc_libs $lib" - -if test "$cross_compiling" = yes; then : - apr_p_t_r=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include - -void *thread_routine(void *data) { - return data; -} - -int main() { - pthread_t thd; - pthread_mutexattr_t mattr; - pthread_once_t once_init = PTHREAD_ONCE_INIT; - int data = 1; - pthread_mutexattr_init(&mattr); - return pthread_create(&thd, NULL, thread_routine, &data); -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - apr_p_t_r=yes -else - apr_p_t_r=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - - -if test $apr_p_t_r = yes; then - - apr_cv_pthreads_lib=$lib - break - -fi - - - done - LIBS=$apr_ptc_libs - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_pthreads_lib" >&5 -$as_echo "$apr_cv_pthreads_lib" >&6; } - -if test -n "$apr_cv_pthreads_lib"; then - pthreads_working=yes - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"$apr_cv_pthreads_lib\"" - LIBS="$apr_cv_pthreads_lib" - else - apr_addto_bugger="$apr_cv_pthreads_lib" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - -fi - -if test "$pthreads_working" = "yes"; then - threads_result="POSIX Threads found" -else - threads_result="POSIX Threads not found" -fi - - - if test "$GCC" = "yes"; then - SAVE_FL="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS -w" - for ac_header in pthread.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" -if test "x$ac_cv_header_pthread_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_PTHREAD_H 1 -_ACEOF - - threads="1" - pthreadh="1" - pthreadser="1" -else - - threads="0" - pthreadh="0" - pthreadser="0" - - CFLAGS="$apr_pthsv_CFLAGS" - LIBS="$apr_pthsv_LIBS" - -fi - -done - - CPPFLAGS="$SAVE_FL" - else - for ac_header in pthread.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" -if test "x$ac_cv_header_pthread_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_PTHREAD_H 1 -_ACEOF - - threads="1" - pthreadh="1" - pthreadser="1" -else - - threads="0" - pthreadh="0" - pthreadser="0" - - CFLAGS="$apr_pthsv_CFLAGS" - LIBS="$apr_pthsv_LIBS" - -fi - -done - - fi - - elif test "$enable_threads" = "system_threads"; then - threads="1" - pthreadh="0" - pthreadser="0" - else -# We basically specified that we wanted threads, but not how to implement -# them. In this case, just look for pthreads. In the future, we can check -# for other threading libraries as well. - - apr_pthsv_CFLAGS="$CFLAGS" - apr_pthsv_LIBS="$LIBS" - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CFLAGS needed for pthreads" >&5 -$as_echo_n "checking for CFLAGS needed for pthreads... " >&6; } -if ${apr_cv_pthreads_cflags+:} false; then : - $as_echo_n "(cached) " >&6 -else - apr_ptc_cflags=$CFLAGS - for flag in none -kthread -pthread -pthreads -mt -mthreads -Kthread -threads; do - CFLAGS=$apr_ptc_cflags - test "x$flag" != "xnone" && CFLAGS="$CFLAGS $flag" - -if test "$cross_compiling" = yes; then : - apr_p_t_r=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include - -void *thread_routine(void *data) { - return data; -} - -int main() { - pthread_t thd; - pthread_mutexattr_t mattr; - pthread_once_t once_init = PTHREAD_ONCE_INIT; - int data = 1; - pthread_mutexattr_init(&mattr); - return pthread_create(&thd, NULL, thread_routine, &data); -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - apr_p_t_r=yes -else - apr_p_t_r=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - - -if test $apr_p_t_r = yes; then - - apr_cv_pthreads_cflags="$flag" - break - -fi - - - done - CFLAGS=$apr_ptc_cflags - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_pthreads_cflags" >&5 -$as_echo "$apr_cv_pthreads_cflags" >&6; } - -if test -n "$apr_cv_pthreads_cflags"; then - pthreads_working=yes - if test "x$apr_cv_pthreads_cflags" != "xnone"; then - - if test "x$CFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting CFLAGS to \"$apr_cv_pthreads_cflags\"" - CFLAGS="$apr_cv_pthreads_cflags" - else - apr_addto_bugger="$apr_cv_pthreads_cflags" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $CFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to CFLAGS" - CFLAGS="$CFLAGS $i" - fi - done - fi - - fi -fi - -# The CFLAGS may or may not be sufficient to ensure that libapr -# depends on the pthreads library: some versions of libtool -# drop -pthread when passed on the link line; some versions of -# gcc ignore -pthread when linking a shared object. So always -# try and add the relevant library to LIBS too. - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBS needed for pthreads" >&5 -$as_echo_n "checking for LIBS needed for pthreads... " >&6; } -if ${apr_cv_pthreads_lib+:} false; then : - $as_echo_n "(cached) " >&6 -else - - apr_ptc_libs=$LIBS - for lib in -lpthread -lpthreads -lc_r; do - LIBS="$apr_ptc_libs $lib" - -if test "$cross_compiling" = yes; then : - apr_p_t_r=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include - -void *thread_routine(void *data) { - return data; -} - -int main() { - pthread_t thd; - pthread_mutexattr_t mattr; - pthread_once_t once_init = PTHREAD_ONCE_INIT; - int data = 1; - pthread_mutexattr_init(&mattr); - return pthread_create(&thd, NULL, thread_routine, &data); -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - apr_p_t_r=yes -else - apr_p_t_r=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - - -if test $apr_p_t_r = yes; then - - apr_cv_pthreads_lib=$lib - break - -fi - - - done - LIBS=$apr_ptc_libs - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_pthreads_lib" >&5 -$as_echo "$apr_cv_pthreads_lib" >&6; } - -if test -n "$apr_cv_pthreads_lib"; then - pthreads_working=yes - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"$apr_cv_pthreads_lib\"" - LIBS="$apr_cv_pthreads_lib" - else - apr_addto_bugger="$apr_cv_pthreads_lib" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - -fi - -if test "$pthreads_working" = "yes"; then - threads_result="POSIX Threads found" -else - threads_result="POSIX Threads not found" -fi - - - if test "$GCC" = "yes"; then - SAVE_FL="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS -w" - for ac_header in pthread.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" -if test "x$ac_cv_header_pthread_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_PTHREAD_H 1 -_ACEOF - - threads="1" - pthreadh="1" - pthreadser="1" -else - - threads="0" - pthreadser="0" - pthreadh="0" - - CFLAGS="$apr_pthsv_CFLAGS" - LIBS="$apr_pthsv_LIBS" - -fi - -done - - CPPFLAGS="$SAVE_FL" - else - for ac_header in pthread.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" -if test "x$ac_cv_header_pthread_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_PTHREAD_H 1 -_ACEOF - - threads="1" - pthreadh="1" - pthreadser="1" -else - - threads="0" - pthreadser="0" - pthreadh="0" - - CFLAGS="$apr_pthsv_CFLAGS" - LIBS="$apr_pthsv_LIBS" - -fi - -done - - fi - - fi - if test "$pthreadh" = "1"; then - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthread_getspecific takes two arguments" >&5 -$as_echo_n "checking whether pthread_getspecific takes two arguments... " >&6; } -if ${ac_cv_pthread_getspecific_two_args+:} false; then : - $as_echo_n "(cached) " >&6 -else - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include - -int -main () -{ - -pthread_key_t key; -void *tmp; -pthread_getspecific(key,&tmp); - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - ac_cv_pthread_getspecific_two_args=yes - -else - - ac_cv_pthread_getspecific_two_args=no - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_pthread_getspecific_two_args" >&5 -$as_echo "$ac_cv_pthread_getspecific_two_args" >&6; } - -if test "$ac_cv_pthread_getspecific_two_args" = "yes"; then - -$as_echo "#define PTHREAD_GETSPECIFIC_TAKES_TWO_ARGS 1" >>confdefs.h - -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthread_attr_getdetachstate takes one argument" >&5 -$as_echo_n "checking whether pthread_attr_getdetachstate takes one argument... " >&6; } -if ${ac_cv_pthread_attr_getdetachstate_one_arg+:} false; then : - $as_echo_n "(cached) " >&6 -else - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include - -int -main () -{ - -pthread_attr_t *attr; -pthread_attr_getdetachstate(attr); - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - ac_cv_pthread_attr_getdetachstate_one_arg=yes - -else - - ac_cv_pthread_attr_getdetachstate_one_arg=no - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_pthread_attr_getdetachstate_one_arg" >&5 -$as_echo "$ac_cv_pthread_attr_getdetachstate_one_arg" >&6; } - -if test "$ac_cv_pthread_attr_getdetachstate_one_arg" = "yes"; then - -$as_echo "#define PTHREAD_ATTR_GETDETACHSTATE_TAKES_ONE_ARG 1" >>confdefs.h - -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for recursive mutex support" >&5 -$as_echo_n "checking for recursive mutex support... " >&6; } -if ${apr_cv_mutex_recursive+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - apr_cv_mutex_recursive=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include - -int main() { - pthread_mutexattr_t attr; - pthread_mutex_t m; - - exit (pthread_mutexattr_init(&attr) - || pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) - || pthread_mutex_init(&m, &attr)); -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - apr_cv_mutex_recursive=yes -else - apr_cv_mutex_recursive=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_mutex_recursive" >&5 -$as_echo "$apr_cv_mutex_recursive" >&6; } - -if test "$apr_cv_mutex_recursive" = "yes"; then - -$as_echo "#define HAVE_PTHREAD_MUTEX_RECURSIVE 1" >>confdefs.h - -fi - - for ac_func in pthread_key_delete pthread_rwlock_init \ - pthread_attr_setguardsize pthread_yield -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - - if test "$ac_cv_func_pthread_rwlock_init" = "yes"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_rwlock_t" >&5 -$as_echo_n "checking for pthread_rwlock_t... " >&6; } -if ${apr_cv_type_rwlock_t+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -int -main () -{ -pthread_rwlock_t *rwlock; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - apr_cv_type_rwlock_t=yes -else - apr_cv_type_rwlock_t=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_type_rwlock_t" >&5 -$as_echo "$apr_cv_type_rwlock_t" >&6; } - if test "$apr_cv_type_rwlock_t" = "yes"; then - -$as_echo "#define HAVE_PTHREAD_RWLOCKS 1" >>confdefs.h - - fi - fi - - if test "$ac_cv_func_pthread_yield" = "no"; then - for ac_header in sched.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "sched.h" "ac_cv_header_sched_h" "$ac_includes_default" -if test "x$ac_cv_header_sched_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_SCHED_H 1 -_ACEOF - -fi - -done - - for ac_func in sched_yield -do : - ac_fn_c_check_func "$LINENO" "sched_yield" "ac_cv_func_sched_yield" -if test "x$ac_cv_func_sched_yield" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_SCHED_YIELD 1 -_ACEOF - -fi -done - - fi - fi -fi - -ac_cv_define_READDIR_IS_THREAD_SAFE=no -ac_cv_define_GETHOSTBYNAME_IS_THREAD_SAFE=no -ac_cv_define_GETHOSTBYADDR_IS_THREAD_SAFE=no -ac_cv_define_GETSERVBYNAME_IS_THREAD_SAFE=no -if test "$threads" = "1"; then - echo "APR will use threads" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for readdir in -lc_r" >&5 -$as_echo_n "checking for readdir in -lc_r... " >&6; } -if ${ac_cv_lib_c_r_readdir+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lc_r $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char readdir (); -int -main () -{ -return readdir (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_c_r_readdir=yes -else - ac_cv_lib_c_r_readdir=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_r_readdir" >&5 -$as_echo "$ac_cv_lib_c_r_readdir" >&6; } -if test "x$ac_cv_lib_c_r_readdir" = xyes; then : - -$as_echo "#define READDIR_IS_THREAD_SAFE 1" >>confdefs.h - -fi - - if test "x$apr_gethostbyname_is_thread_safe" = "x"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lc_r" >&5 -$as_echo_n "checking for gethostbyname in -lc_r... " >&6; } -if ${ac_cv_lib_c_r_gethostbyname+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lc_r $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char gethostbyname (); -int -main () -{ -return gethostbyname (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_c_r_gethostbyname=yes -else - ac_cv_lib_c_r_gethostbyname=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_r_gethostbyname" >&5 -$as_echo "$ac_cv_lib_c_r_gethostbyname" >&6; } -if test "x$ac_cv_lib_c_r_gethostbyname" = xyes; then : - apr_gethostbyname_is_thread_safe=yes -fi - - fi - if test "$apr_gethostbyname_is_thread_safe" = "yes"; then - -$as_echo "#define GETHOSTBYNAME_IS_THREAD_SAFE 1" >>confdefs.h - - fi - if test "x$apr_gethostbyaddr_is_thread_safe" = "x"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyaddr in -lc_r" >&5 -$as_echo_n "checking for gethostbyaddr in -lc_r... " >&6; } -if ${ac_cv_lib_c_r_gethostbyaddr+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lc_r $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char gethostbyaddr (); -int -main () -{ -return gethostbyaddr (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_c_r_gethostbyaddr=yes -else - ac_cv_lib_c_r_gethostbyaddr=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_r_gethostbyaddr" >&5 -$as_echo "$ac_cv_lib_c_r_gethostbyaddr" >&6; } -if test "x$ac_cv_lib_c_r_gethostbyaddr" = xyes; then : - apr_gethostbyaddr_is_thread_safe=yes -fi - - fi - if test "$apr_gethostbyaddr_is_thread_safe" = "yes"; then - -$as_echo "#define GETHOSTBYADDR_IS_THREAD_SAFE 1" >>confdefs.h - - fi - if test "x$apr_getservbyname_is_thread_safe" = "x"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getservbyname in -lc_r" >&5 -$as_echo_n "checking for getservbyname in -lc_r... " >&6; } -if ${ac_cv_lib_c_r_getservbyname+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lc_r $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char getservbyname (); -int -main () -{ -return getservbyname (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_c_r_getservbyname=yes -else - ac_cv_lib_c_r_getservbyname=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_r_getservbyname" >&5 -$as_echo "$ac_cv_lib_c_r_getservbyname" >&6; } -if test "x$ac_cv_lib_c_r_getservbyname" = xyes; then : - apr_getservbyname_is_thread_safe=yes -fi - - fi - if test "$apr_getservbyname_is_thread_safe" = "yes"; then - -$as_echo "#define GETSERVBYNAME_IS_THREAD_SAFE 1" >>confdefs.h - - fi - for ac_func in gethostbyname_r gethostbyaddr_r getservbyname_r -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - -else - echo "APR will be non-threaded" -fi - - -# Check whether --with-efence was given. -if test "${with_efence+set}" = set; then : - withval=$with_efence; apr_efence_dir="$withval" - if test "$apr_efence_dir" != "yes"; then - - if test "x$LDFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting LDFLAGS to \"-L$apr_efence_dir/lib\"" - LDFLAGS="-L$apr_efence_dir/lib" - else - apr_addto_bugger="-L$apr_efence_dir/lib" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LDFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LDFLAGS" - LDFLAGS="$LDFLAGS $i" - fi - done - fi - - if test "x$apr_platform_runtime_link_flag" != "x"; then - - if test "x$LDFLAGS" = "x"; then - test "x$silent" != "xyes" && echo " setting LDFLAGS to \"$apr_platform_runtime_link_flag$apr_efence_dir/lib\"" - LDFLAGS="$apr_platform_runtime_link_flag$apr_efence_dir/lib" - else - apr_addto_bugger="$apr_platform_runtime_link_flag$apr_efence_dir/lib" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LDFLAGS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LDFLAGS" - LDFLAGS="$LDFLAGS $i" - fi - done - fi - - fi - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for malloc in -lefence" >&5 -$as_echo_n "checking for malloc in -lefence... " >&6; } -if ${ac_cv_lib_efence_malloc+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lefence $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char malloc (); -int -main () -{ -return malloc (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_efence_malloc=yes -else - ac_cv_lib_efence_malloc=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_efence_malloc" >&5 -$as_echo "$ac_cv_lib_efence_malloc" >&6; } -if test "x$ac_cv_lib_efence_malloc" = xyes; then : - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-lefence\"" - LIBS="-lefence" - else - apr_addto_bugger="-lefence" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - -else - as_fn_error $? "Electric Fence requested but not detected" "$LINENO" 5 -fi - - -fi - - -for ac_func in sigsuspend -do : - ac_fn_c_check_func "$LINENO" "sigsuspend" "ac_cv_func_sigsuspend" -if test "x$ac_cv_func_sigsuspend" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_SIGSUSPEND 1 -_ACEOF - have_sigsuspend="1" -else - have_sigsuspend="0" -fi -done - -for ac_func in sigwait -do : - ac_fn_c_check_func "$LINENO" "sigwait" "ac_cv_func_sigwait" -if test "x$ac_cv_func_sigwait" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_SIGWAIT 1 -_ACEOF - have_sigwait="1" -else - have_sigwait="0" -fi -done - -case $host in - *alpha*-dec-osf* ) - have_sigwait="1" - ;; -esac - - - - - -for ac_func in poll kqueue port_create -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - -# Check for the Linux epoll interface; epoll* may be available in libc -# but return ENOSYS on a pre-2.6 kernel, so do a run-time check. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for epoll support" >&5 -$as_echo_n "checking for epoll support... " >&6; } -if ${apr_cv_epoll+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - apr_cv_epoll=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include - -int main() -{ - return epoll_create(5) == -1; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - apr_cv_epoll=yes -else - apr_cv_epoll=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_epoll" >&5 -$as_echo "$apr_cv_epoll" >&6; } - -if test "$apr_cv_epoll" = "yes"; then - -$as_echo "#define HAVE_EPOLL 1" >>confdefs.h - -fi - -# test for epoll_create1 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for epoll_create1 support" >&5 -$as_echo_n "checking for epoll_create1 support... " >&6; } -if ${apr_cv_epoll_create1+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - apr_cv_epoll_create1=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include - -int main() -{ - return epoll_create1(0) == -1; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - apr_cv_epoll_create1=yes -else - apr_cv_epoll_create1=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_epoll_create1" >&5 -$as_echo "$apr_cv_epoll_create1" >&6; } - -if test "$apr_cv_epoll_create1" = "yes"; then - -$as_echo "#define HAVE_EPOLL_CREATE1 1" >>confdefs.h - -fi - -# test for dup3 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dup3 support" >&5 -$as_echo_n "checking for dup3 support... " >&6; } -if ${apr_cv_dup3+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - apr_cv_dup3=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include - -int main() -{ - return dup3(STDOUT_FILENO, STDERR_FILENO, 0) == -1; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - apr_cv_dup3=yes -else - apr_cv_dup3=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_dup3" >&5 -$as_echo "$apr_cv_dup3" >&6; } - -if test "$apr_cv_dup3" = "yes"; then - -$as_echo "#define HAVE_DUP3 1" >>confdefs.h - -fi - -# test for accept4 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for accept4 support" >&5 -$as_echo_n "checking for accept4 support... " >&6; } -if ${apr_cv_accept4+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - apr_cv_accept4=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -#include -#include -#include -#include - -#define A4_SOCK "./apr_accept4_test_socket" - -int main() -{ - pid_t pid; - int fd; - struct sockaddr_un loc, rem; - socklen_t rem_sz; - - if ((pid = fork())) { - int status; - - unlink(A4_SOCK); - - if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) - goto cleanup_failure2; - - loc.sun_family = AF_UNIX; - strncpy(loc.sun_path, A4_SOCK, sizeof(loc.sun_path) - 1); - - if (bind(fd, (struct sockaddr *) &loc, - sizeof(struct sockaddr_un)) == -1) - goto cleanup_failure; - - if (listen(fd, 5) == -1) - goto cleanup_failure; - - rem_sz = sizeof(struct sockaddr_un); - if (accept4(fd, (struct sockaddr *) &rem, &rem_sz, 0) == -1) { - goto cleanup_failure; - } - else { - close(fd); - waitpid(pid, &status, 0); - unlink(A4_SOCK); - return 0; - } - -cleanup_failure: - close(fd); -cleanup_failure2: - kill(pid, SIGKILL); - waitpid(pid, &status, 0); - unlink(A4_SOCK); - return 1; - } - else { - if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) - return 1; /* this will be bad: we'll hang */ - - loc.sun_family = AF_UNIX; - strncpy(loc.sun_path, A4_SOCK, sizeof(loc.sun_path) - 1); - - while(connect(fd, (struct sockaddr *) &loc, - sizeof(struct sockaddr_un)) == -1 && - (errno==ENOENT || errno==ECONNREFUSED)) - ; - - close(fd); - return 0; - } -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - apr_cv_accept4=yes -else - apr_cv_accept4=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_accept4" >&5 -$as_echo "$apr_cv_accept4" >&6; } - -if test "$apr_cv_accept4" = "yes"; then - -$as_echo "#define HAVE_ACCEPT4 1" >>confdefs.h - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SOCK_CLOEXEC support" >&5 -$as_echo_n "checking for SOCK_CLOEXEC support... " >&6; } -if ${apr_cv_sock_cloexec+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - apr_cv_sock_cloexec=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include - -int main() -{ - return socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0) == -1; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - apr_cv_sock_cloexec=yes -else - apr_cv_sock_cloexec=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_sock_cloexec" >&5 -$as_echo "$apr_cv_sock_cloexec" >&6; } - -if test "$apr_cv_sock_cloexec" = "yes"; then - -$as_echo "#define HAVE_SOCK_CLOEXEC 1" >>confdefs.h - -fi - -for ac_func in fdatasync -do : - ac_fn_c_check_func "$LINENO" "fdatasync" "ac_cv_func_fdatasync" -if test "x$ac_cv_func_fdatasync" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_FDATASYNC 1 -_ACEOF - -fi -done - - -# test for epoll_create1 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for epoll_create1 support" >&5 -$as_echo_n "checking for epoll_create1 support... " >&6; } -if ${apr_cv_epoll_create1+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - apr_cv_epoll_create1=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include - -int main() -{ - return epoll_create1(0) == -1; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - apr_cv_epoll_create1=yes -else - apr_cv_epoll_create1=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_epoll_create1" >&5 -$as_echo "$apr_cv_epoll_create1" >&6; } - -if test "$apr_cv_epoll_create1" = "yes"; then - -$as_echo "#define HAVE_EPOLL_CREATE1 1" >>confdefs.h - -fi - -# test for dup3 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dup3 support" >&5 -$as_echo_n "checking for dup3 support... " >&6; } -if ${apr_cv_dup3+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - apr_cv_dup3=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include - -int main() -{ - return dup3(STDOUT_FILENO, STDERR_FILENO, 0) == -1; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - apr_cv_dup3=yes -else - apr_cv_dup3=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_dup3" >&5 -$as_echo "$apr_cv_dup3" >&6; } - -if test "$apr_cv_dup3" = "yes"; then - -$as_echo "#define HAVE_DUP3 1" >>confdefs.h - -fi - -# test for accept4 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for accept4 support" >&5 -$as_echo_n "checking for accept4 support... " >&6; } -if ${apr_cv_accept4+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - apr_cv_accept4=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -#include -#include -#include -#include - -#define A4_SOCK "./apr_accept4_test_socket" - -int main() -{ - pid_t pid; - int fd; - struct sockaddr_un loc, rem; - socklen_t rem_sz; - - if ((pid = fork())) { - int status; - - unlink(A4_SOCK); - - if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) - goto cleanup_failure2; - - loc.sun_family = AF_UNIX; - strncpy(loc.sun_path, A4_SOCK, sizeof(loc.sun_path) - 1); - - if (bind(fd, (struct sockaddr *) &loc, - sizeof(struct sockaddr_un)) == -1) - goto cleanup_failure; - - if (listen(fd, 5) == -1) - goto cleanup_failure; - - rem_sz = sizeof(struct sockaddr_un); - if (accept4(fd, (struct sockaddr *) &rem, &rem_sz, 0) == -1) { - goto cleanup_failure; - } - else { - close(fd); - waitpid(pid, &status, 0); - unlink(A4_SOCK); - return 0; - } - -cleanup_failure: - close(fd); -cleanup_failure2: - kill(pid, SIGKILL); - waitpid(pid, &status, 0); - unlink(A4_SOCK); - return 1; - } - else { - if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) - return 1; /* this will be bad: we'll hang */ - - loc.sun_family = AF_UNIX; - strncpy(loc.sun_path, A4_SOCK, sizeof(loc.sun_path) - 1); - - while(connect(fd, (struct sockaddr *) &loc, - sizeof(struct sockaddr_un)) == -1 && - (errno==ENOENT || errno==ECONNREFUSED)) - ; - - close(fd); - return 0; - } -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - apr_cv_accept4=yes -else - apr_cv_accept4=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_accept4" >&5 -$as_echo "$apr_cv_accept4" >&6; } - -if test "$apr_cv_accept4" = "yes"; then - -$as_echo "#define HAVE_ACCEPT4 1" >>confdefs.h - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SOCK_CLOEXEC support" >&5 -$as_echo_n "checking for SOCK_CLOEXEC support... " >&6; } -if ${apr_cv_sock_cloexec+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - apr_cv_sock_cloexec=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include - -int main() -{ - return socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0) == -1; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - apr_cv_sock_cloexec=yes -else - apr_cv_sock_cloexec=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_sock_cloexec" >&5 -$as_echo "$apr_cv_sock_cloexec" >&6; } - -if test "$apr_cv_sock_cloexec" = "yes"; then - -$as_echo "#define HAVE_SOCK_CLOEXEC 1" >>confdefs.h - -fi - -for ac_func in getpwnam_r getpwuid_r getgrnam_r getgrgid_r -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - -echo "${nl}Checking for Shared Memory Support..." - -# The real-time POSIX extensions (e.g. shm_*, sem_*) may only -# be available if linking against librt. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing shm_open" >&5 -$as_echo_n "checking for library containing shm_open... " >&6; } -if ${ac_cv_search_shm_open+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char shm_open (); -int -main () -{ -return shm_open (); - ; - return 0; -} -_ACEOF -for ac_lib in '' rt; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_shm_open=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_shm_open+:} false; then : - break -fi -done -if ${ac_cv_search_shm_open+:} false; then : - -else - ac_cv_search_shm_open=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_shm_open" >&5 -$as_echo "$ac_cv_search_shm_open" >&6; } -ac_res=$ac_cv_search_shm_open -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -fi - - -case $host in - *-sysv*) - ac_includes_default="$ac_includes_default -#if HAVE_SYS_MUTEX_H /* needed to define lock_t for sys/shm.h */ -# include -#endif";; -esac - -for ac_header in sys/types.h sys/mman.h sys/ipc.h sys/mutex.h sys/shm.h sys/file.h kernel/OS.h os2.h windows.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - -for ac_func in mmap munmap shm_open shm_unlink shmget shmat shmdt shmctl \ - create_area -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MAP_ANON in sys/mman.h" >&5 -$as_echo_n "checking for MAP_ANON in sys/mman.h... " >&6; } -if ${ac_cv_define_MAP_ANON+:} false; then : - $as_echo_n "(cached) " >&6 -else - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#ifdef MAP_ANON -YES_IS_DEFINED -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "YES_IS_DEFINED" >/dev/null 2>&1; then : - ac_cv_define_MAP_ANON=yes -else - ac_cv_define_MAP_ANON=no -fi -rm -f conftest* - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_define_MAP_ANON" >&5 -$as_echo "$ac_cv_define_MAP_ANON" >&6; } - if test "$ac_cv_define_MAP_ANON" = "yes"; then - -$as_echo "#define HAVE_MAP_ANON 1" >>confdefs.h - - fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for /dev/zero" >&5 -$as_echo_n "checking for /dev/zero... " >&6; } -if ${ac_cv_file__dev_zero+:} false; then : - $as_echo_n "(cached) " >&6 -else - test "$cross_compiling" = yes && - as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 -if test -r "/dev/zero"; then - ac_cv_file__dev_zero=yes -else - ac_cv_file__dev_zero=no -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_file__dev_zero" >&5 -$as_echo "$ac_cv_file__dev_zero" >&6; } -if test "x$ac_cv_file__dev_zero" = xyes; then : - -fi - - -# Not all systems can mmap /dev/zero (such as HP-UX). Check for that. -if test "$ac_cv_func_mmap" = "yes" && - test "$ac_cv_file__dev_zero" = "yes"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mmap that can map /dev/zero" >&5 -$as_echo_n "checking for mmap that can map /dev/zero... " >&6; } - if test "$cross_compiling" = yes; then : - ac_cv_file__dev_zero=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -#ifdef HAVE_SYS_MMAN_H -#include -#endif - int main() - { - int fd; - void *m; - fd = open("/dev/zero", O_RDWR); - if (fd < 0) { - return 1; - } - m = mmap(0, sizeof(void*), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); - if (m == (void *)-1) { /* aka MAP_FAILED */ - return 2; - } - if (munmap(m, sizeof(void*)) < 0) { - return 3; - } - return 0; - } -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -else - ac_cv_file__dev_zero=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_file__dev_zero" >&5 -$as_echo "$ac_cv_file__dev_zero" >&6; } -fi - -# Now we determine which one is our anonymous shmem preference. -haveshmgetanon="0" -havemmapzero="0" -havemmapanon="0" -ac_decision_item='anonymous shared memory allocation method' -ac_decision_msg='FAILED' -ac_decision='' - -ac_rc=yes -for ac_spec in header:sys/ipc.h header:sys/shm.h header:sys/file.h func:shmget func:shmat func:shmdt func:shmctl; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - haveshmgetanon="1" - -ac_decision='USE_SHMEM_SHMGET_ANON' -ac_decision_msg='SysV IPC shmget()' -ac_decision_USE_SHMEM_SHMGET_ANON=yes -ac_decision_USE_SHMEM_SHMGET_ANON_msg='SysV IPC shmget()' - -else - : - -fi - -ac_rc=yes -for ac_spec in header:sys/mman.h func:mmap func:munmap file:/dev/zero; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - havemmapzero="1" - -ac_decision='USE_SHMEM_MMAP_ZERO' -ac_decision_msg='SVR4-style mmap() on /dev/zero' -ac_decision_USE_SHMEM_MMAP_ZERO=yes -ac_decision_USE_SHMEM_MMAP_ZERO_msg='SVR4-style mmap() on /dev/zero' - -else - : - -fi - -ac_rc=yes -for ac_spec in header:sys/mman.h func:mmap func:munmap define:MAP_ANON; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - havemmapanon="1" - -ac_decision='USE_SHMEM_MMAP_ANON' -ac_decision_msg='4.4BSD-style mmap() via MAP_ANON' -ac_decision_USE_SHMEM_MMAP_ANON=yes -ac_decision_USE_SHMEM_MMAP_ANON_msg='4.4BSD-style mmap() via MAP_ANON' - -else - : - -fi - -ac_rc=yes -for ac_spec in header:os2.h; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - haveos2shm="1" - -ac_decision='USE_SHMEM_OS2_ANON' -ac_decision_msg='OS/2 DosAllocSharedMem()' -ac_decision_USE_SHMEM_OS2_ANON=yes -ac_decision_USE_SHMEM_OS2_ANON_msg='OS/2 DosAllocSharedMem()' - -else - : - -fi - -ac_rc=yes -for ac_spec in header:kernel/OS.h func:create_area; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - havebeosshm="1" - -ac_decision='USE_SHMEM_BEOS_ANON' -ac_decision_msg='BeOS areas' -ac_decision_USE_SHMEM_BEOS_ANON=yes -ac_decision_USE_SHMEM_BEOS_ANON_msg='BeOS areas' - -else - : - -fi - -ac_rc=yes -for ac_spec in header:windows.h func:CreateFileMapping; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - havewin32shm="1" - -ac_decision='USE_SHMEM_WIN32_ANON' -ac_decision_msg='Windows CreateFileMapping()' -ac_decision_USE_SHMEM_WIN32_ANON=yes -ac_decision_USE_SHMEM_WIN32_ANON_msg='Windows CreateFileMapping()' - -else - : - -fi - -case $host in - *linux* ) - # Linux has problems with MM_SHMT_MMANON even though it reports - # that it has it. - # FIXME - find exact 2.3 version that MMANON was fixed in. It is - # confirmed fixed in 2.4 series. - if test $os_version -le "240"; then - ac_decision='' - for ac_item in USE_SHMEM_MMAP_ZERO USE_SHMEM_SHMGET_ANON; do - eval "ac_decision_this=\$ac_decision_${ac_item}" - if test ".$ac_decision_this" = .yes; then - ac_decision=$ac_item - eval "ac_decision_msg=\$ac_decision_${ac_item}_msg" - fi - done - - fi - ;; - *hpux11* ) - ac_decision='' - for ac_item in USE_SHMEM_SHMGET_ANON; do - eval "ac_decision_this=\$ac_decision_${ac_item}" - if test ".$ac_decision_this" = .yes; then - ac_decision=$ac_item - eval "ac_decision_msg=\$ac_decision_${ac_item}_msg" - fi - done - - ;; -esac -if test ".$ac_decision" = .; then - echo "$0:Error: decision on $ac_decision_item failed" 1>&2 - exit 1 -else - if test ".$ac_decision_msg" = .; then - ac_decision_msg="$ac_decision" - fi - cat >>confdefs.h <<_ACEOF -#define ${ac_decision_item} 1 -_ACEOF - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: decision on $ac_decision_item... $ac_decision_msg" >&5 -$as_echo "decision on $ac_decision_item... $ac_decision_msg" >&6; } -fi - -cat >>confdefs.h <<_ACEOF -#define $ac_decision 1 -_ACEOF - - -useshmgetanon="0" -usemmapzero="0" -usemmapanon="0" - -case $ac_decision in - USE_SHMEM_SHMGET_ANON ) - useshmgetanon="1" - ;; - USE_SHMEM_MMAP_ZERO ) - usemmapzero="1" - ;; - USE_SHMEM_MMAP_ANON ) - usemmapanon="1" - ;; -esac - - - - - - - - -# Now we determine which one is our name-based shmem preference. -havemmaptmp="0" -havemmapshm="0" -haveshmget="0" -havebeosarea="0" -haveos2shm="0" -havewin32shm="0" -ac_decision_item='namebased memory allocation method' -ac_decision_msg='FAILED' -ac_decision='' - -ac_rc=yes -for ac_spec in header:sys/mman.h func:mmap func:munmap; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - havemmaptmp="1" - -ac_decision='USE_SHMEM_MMAP_TMP' -ac_decision_msg='Classical mmap() on temporary file' -ac_decision_USE_SHMEM_MMAP_TMP=yes -ac_decision_USE_SHMEM_MMAP_TMP_msg='Classical mmap() on temporary file' - -else - : - -fi - -ac_rc=yes -for ac_spec in header:sys/mman.h func:mmap func:munmap func:shm_open func:shm_unlink; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - havemmapshm="1" - -ac_decision='USE_SHMEM_MMAP_SHM' -ac_decision_msg='mmap() via POSIX.1 shm_open() on temporary file' -ac_decision_USE_SHMEM_MMAP_SHM=yes -ac_decision_USE_SHMEM_MMAP_SHM_msg='mmap() via POSIX.1 shm_open() on temporary file' - -else - : - -fi - -ac_rc=yes -for ac_spec in header:sys/ipc.h header:sys/shm.h header:sys/file.h func:shmget func:shmat func:shmdt func:shmctl; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - haveshmget="1" - -ac_decision='USE_SHMEM_SHMGET' -ac_decision_msg='SysV IPC shmget()' -ac_decision_USE_SHMEM_SHMGET=yes -ac_decision_USE_SHMEM_SHMGET_msg='SysV IPC shmget()' - -else - : - -fi - -ac_rc=yes -for ac_spec in header:kernel/OS.h func:create_area; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - havebeosshm="1" - -ac_decision='USE_SHMEM_BEOS' -ac_decision_msg='BeOS areas' -ac_decision_USE_SHMEM_BEOS=yes -ac_decision_USE_SHMEM_BEOS_msg='BeOS areas' - -else - : - -fi - -ac_rc=yes -for ac_spec in header:os2.h; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - haveos2shm="1" - -ac_decision='USE_SHMEM_OS2' -ac_decision_msg='OS/2 DosAllocSharedMem()' -ac_decision_USE_SHMEM_OS2=yes -ac_decision_USE_SHMEM_OS2_msg='OS/2 DosAllocSharedMem()' - -else - : - -fi - -ac_rc=yes -for ac_spec in header:windows.h; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - havewin32shm="1" - -ac_decision='USE_SHMEM_WIN32' -ac_decision_msg='Windows shared memory' -ac_decision_USE_SHMEM_WIN32=yes -ac_decision_USE_SHMEM_WIN32_msg='Windows shared memory' - -else - : - -fi - -case $host in - *linux* ) - # Linux has problems with MM_SHMT_MMANON even though it reports - # that it has it. - # FIXME - find exact 2.3 version that MMANON was fixed in. It is - # confirmed fixed in 2.4 series. - if test $os_version -le "240"; then - ac_decision='' - for ac_item in USE_SHMEM_MMAP_TMP USE_SHMEM_MMAP_SHM USE_SHMEM_SHMGET; do - eval "ac_decision_this=\$ac_decision_${ac_item}" - if test ".$ac_decision_this" = .yes; then - ac_decision=$ac_item - eval "ac_decision_msg=\$ac_decision_${ac_item}_msg" - fi - done - - fi - ;; -esac -if test ".$ac_decision" = .; then - echo "$0:Error: decision on $ac_decision_item failed" 1>&2 - exit 1 -else - if test ".$ac_decision_msg" = .; then - ac_decision_msg="$ac_decision" - fi - cat >>confdefs.h <<_ACEOF -#define ${ac_decision_item} 1 -_ACEOF - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: decision on $ac_decision_item... $ac_decision_msg" >&5 -$as_echo "decision on $ac_decision_item... $ac_decision_msg" >&6; } -fi - -cat >>confdefs.h <<_ACEOF -#define $ac_decision 1 -_ACEOF - - -usemmaptmp="0" -usemmapshm="0" -useshmget="0" -usebeosarea="0" -useos2shm="0" -usewin32shm="0" - -case $ac_decision in - USE_SHMEM_MMAP_TMP ) - usemmaptmp="1" - ;; - USE_SHMEM_MMAP_SHM ) - usemmapshm="1" - ;; - USE_SHMEM_SHMGET ) - useshmget="1" - ;; - USE_SHMEM_BEOS ) - usebeosarea="1" - ;; - USE_SHMEM_OS2 ) - useos2shm="1" - ;; - USE_SHMEM_WIN32 ) - usewin32shm="1" - ;; -esac - -# Do we have any shared memory support? -if test "$usemmaptmp$usemmapshm$usemmapzero$useshmget$usemmapanon$usebeosarea$useos2shm$usewin32shm" = "00000000"; then - sharedmem="0" -else - sharedmem="1" -fi - - - - - - - - - - - - - - - - -ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" -if test "x$ac_cv_type_size_t" = xyes; then : - -else - -cat >>confdefs.h <<_ACEOF -#define size_t unsigned int -_ACEOF - -fi - -# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works -# for constant arguments. Useless! -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5 -$as_echo_n "checking for working alloca.h... " >&6; } -if ${ac_cv_working_alloca_h+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -char *p = (char *) alloca (2 * sizeof (int)); - if (p) return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_working_alloca_h=yes -else - ac_cv_working_alloca_h=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5 -$as_echo "$ac_cv_working_alloca_h" >&6; } -if test $ac_cv_working_alloca_h = yes; then - -$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5 -$as_echo_n "checking for alloca... " >&6; } -if ${ac_cv_func_alloca_works+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __GNUC__ -# define alloca __builtin_alloca -#else -# ifdef _MSC_VER -# include -# define alloca _alloca -# else -# ifdef HAVE_ALLOCA_H -# include -# else -# ifdef _AIX - #pragma alloca -# else -# ifndef alloca /* predefined by HP cc +Olibcalls */ -void *alloca (size_t); -# endif -# endif -# endif -# endif -#endif - -int -main () -{ -char *p = (char *) alloca (1); - if (p) return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_func_alloca_works=yes -else - ac_cv_func_alloca_works=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5 -$as_echo "$ac_cv_func_alloca_works" >&6; } - -if test $ac_cv_func_alloca_works = yes; then - -$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h - -else - # The SVR3 libPW and SVR4 libucb both contain incompatible functions -# that cause trouble. Some versions do not even contain alloca or -# contain a buggy version. If you still want to use their alloca, -# use ar to extract alloca.o from them instead of compiling alloca.c. - -ALLOCA=\${LIBOBJDIR}alloca.$ac_objext - -$as_echo "#define C_ALLOCA 1" >>confdefs.h - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5 -$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; } -if ${ac_cv_os_cray+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#if defined CRAY && ! defined CRAY2 -webecray -#else -wenotbecray -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "webecray" >/dev/null 2>&1; then : - ac_cv_os_cray=yes -else - ac_cv_os_cray=no -fi -rm -f conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5 -$as_echo "$ac_cv_os_cray" >&6; } -if test $ac_cv_os_cray = yes; then - for ac_func in _getb67 GETB67 getb67; do - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - -cat >>confdefs.h <<_ACEOF -#define CRAY_STACKSEG_END $ac_func -_ACEOF - - break -fi - - done -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5 -$as_echo_n "checking stack direction for C alloca... " >&6; } -if ${ac_cv_c_stack_direction+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_c_stack_direction=0 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -find_stack_direction () -{ - static char *addr = 0; - auto char dummy; - if (addr == 0) - { - addr = &dummy; - return find_stack_direction (); - } - else - return (&dummy > addr) ? 1 : -1; -} - -int -main () -{ - return find_stack_direction () < 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_c_stack_direction=1 -else - ac_cv_c_stack_direction=-1 -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5 -$as_echo "$ac_cv_c_stack_direction" >&6; } -cat >>confdefs.h <<_ACEOF -#define STACK_DIRECTION $ac_cv_c_stack_direction -_ACEOF - - -fi - - -for ac_func in calloc setsid isinf isnan \ - getenv putenv setenv unsetenv \ - writev getifaddrs utime utimes -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - -for ac_func in setrlimit -do : - ac_fn_c_check_func "$LINENO" "setrlimit" "ac_cv_func_setrlimit" -if test "x$ac_cv_func_setrlimit" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_SETRLIMIT 1 -_ACEOF - have_setrlimit="1" -else - have_setrlimit="0" -fi -done - -for ac_func in getrlimit -do : - ac_fn_c_check_func "$LINENO" "getrlimit" "ac_cv_func_getrlimit" -if test "x$ac_cv_func_getrlimit" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_GETRLIMIT 1 -_ACEOF - have_getrlimit="1" -else - have_getrlimit="0" -fi -done - -sendfile="0" -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sendfilev in -lsendfile" >&5 -$as_echo_n "checking for sendfilev in -lsendfile... " >&6; } -if ${ac_cv_lib_sendfile_sendfilev+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lsendfile $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char sendfilev (); -int -main () -{ -return sendfilev (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_sendfile_sendfilev=yes -else - ac_cv_lib_sendfile_sendfilev=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sendfile_sendfilev" >&5 -$as_echo "$ac_cv_lib_sendfile_sendfilev" >&6; } -if test "x$ac_cv_lib_sendfile_sendfilev" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBSENDFILE 1 -_ACEOF - - LIBS="-lsendfile $LIBS" - -fi - -for ac_func in sendfile send_file sendfilev -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - sendfile="1" -fi -done - - - - -# Check whether --with-sendfile was given. -if test "${with_sendfile+set}" = set; then : - withval=$with_sendfile; if test "$withval" = "yes"; then - sendfile="1" - else - sendfile="0" - fi -else - - orig_sendfile=$sendfile - case $host in - *freebsd*) - # FreeBSD < 4.2 has issues with threads+sendfile - if test $os_version -le "401999"; then - if test "$threads" = "1"; then - sendfile="0" - fi - fi - ;; - *alpha*-dec-osf* ) - sendfile="0" - ;; - s390-*-linux-gnu) - # disable sendfile support for 2.2 on S/390 - if test $os_version -lt 240; then - sendfile="0" - fi - ;; - *aix*) - # compiler-independent check for 64-bit build - # The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of void*" >&5 -$as_echo_n "checking size of void*... " >&6; } -if ${ac_cv_sizeof_voidp+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (void*))" "ac_cv_sizeof_voidp" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_voidp" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (void*) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_voidp=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_voidp" >&5 -$as_echo "$ac_cv_sizeof_voidp" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_VOIDP $ac_cv_sizeof_voidp -_ACEOF - - - if test "x$ac_cv_sizeof_voidp" = "x8"; then - # sendfile not working for 64-bit build - sendfile="0" - fi - ;; - esac - if test "$orig_sendfile" != "$sendfile"; then - echo "sendfile support disabled to avoid system problem" - fi -fi - - - -for ac_func in sigaction -do : - ac_fn_c_check_func "$LINENO" "sigaction" "ac_cv_func_sigaction" -if test "x$ac_cv_func_sigaction" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_SIGACTION 1 -_ACEOF - have_sigaction="1" -else - have_sigaction="0" -fi -done - -ac_fn_c_check_decl "$LINENO" "sys_siglist" "ac_cv_have_decl_sys_siglist" "#include -/* NetBSD declares sys_siglist in unistd.h. */ -#ifdef HAVE_UNISTD_H -# include -#endif - -" -if test "x$ac_cv_have_decl_sys_siglist" = xyes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_SYS_SIGLIST $ac_have_decl -_ACEOF - - - -for ac_func in fork -do : - ac_fn_c_check_func "$LINENO" "fork" "ac_cv_func_fork" -if test "x$ac_cv_func_fork" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_FORK 1 -_ACEOF - fork="1" -else - fork="0" -fi -done - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_addr" >&5 -$as_echo_n "checking for inet_addr... " >&6; } -if ${ac_cv_func_inet_addr+:} false; then : - $as_echo_n "(cached) " >&6 -else - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_ARPA_INET_H -#include -#endif - -int -main () -{ - -inet_addr("127.0.0.1"); - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - ac_cv_func_inet_addr=yes - -else - - ac_cv_func_inet_addr=no - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_inet_addr" >&5 -$as_echo "$ac_cv_func_inet_addr" >&6; } - -if test "$ac_cv_func_inet_addr" = "yes"; then - have_inet_addr=1 -else - have_inet_addr=0 -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_network" >&5 -$as_echo_n "checking for inet_network... " >&6; } -if ${ac_cv_func_inet_network+:} false; then : - $as_echo_n "(cached) " >&6 -else - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_ARPA_INET_H -#include -#endif - -int -main () -{ - -inet_network("127.0.0.1"); - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - ac_cv_func_inet_network=yes - -else - - ac_cv_func_inet_network=no - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_inet_network" >&5 -$as_echo "$ac_cv_func_inet_network" >&6; } - -if test "$ac_cv_func_inet_network" = "yes"; then - have_inet_network=1 -else - have_inet_network=0 -fi - - -ac_fn_c_check_func "$LINENO" "_getch" "ac_cv_func__getch" -if test "x$ac_cv_func__getch" = xyes; then : - -fi - -for ac_func in strerror_r -do : - ac_fn_c_check_func "$LINENO" "strerror_r" "ac_cv_func_strerror_r" -if test "x$ac_cv_func_strerror_r" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_STRERROR_R 1 -_ACEOF - strerror_r="1" -else - strerror_r="0" -fi -done - -if test "$strerror_r" = "1"; then - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for type of return code from strerror_r" >&5 -$as_echo_n "checking for type of return code from strerror_r... " >&6; } -if test "$cross_compiling" = yes; then : - - ac_cv_strerror_r_rc_int=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -main() -{ - char buf[1024]; - if (strerror_r(ERANGE, buf, sizeof buf) < 1) { - exit(0); - } - else { - exit(1); - } -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - - ac_cv_strerror_r_rc_int=yes -else - - ac_cv_strerror_r_rc_int=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -if test "x$ac_cv_strerror_r_rc_int" = xyes; then - -$as_echo "#define STRERROR_R_RC_INT 1" >>confdefs.h - - msg="int" -else - msg="pointer" -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $msg" >&5 -$as_echo "$msg" >&6; } - -fi -for ac_func in mmap -do : - ac_fn_c_check_func "$LINENO" "mmap" "ac_cv_func_mmap" -if test "x$ac_cv_func_mmap" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_MMAP 1 -_ACEOF - mmap="1" -else - mmap="0" -fi -done - -if test "$native_mmap_emul" = "1"; then - mmap="1" -fi -for ac_func in memmove -do : - ac_fn_c_check_func "$LINENO" "memmove" "ac_cv_func_memmove" -if test "x$ac_cv_func_memmove" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_MEMMOVE 1 -_ACEOF - have_memmove="1" -else - have_memmove="0" -fi -done - -for ac_func in getpass getpassphrase gmtime_r localtime_r mkstemp -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - - - - - - - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether sigwait takes one argument" >&5 -$as_echo_n "checking whether sigwait takes one argument... " >&6; } -if ${ac_cv_sigwait_one_arg+:} false; then : - $as_echo_n "(cached) " >&6 -else - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#if defined(__NETBSD__) || defined(DARWIN) - /* When using the unproven-pthreads package, we need to pull in this - * header to get a prototype for sigwait(). Else things will fail later - * on. XXX Should probably be fixed in the unproven-pthreads package. - * Darwin is declaring sigwait() in the wrong place as well. - */ -#include -#endif -#include - -int -main () -{ - - sigset_t set; - - sigwait(&set); - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - ac_cv_sigwait_one_arg=yes - -else - - ac_cv_sigwait_one_arg=no - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sigwait_one_arg" >&5 -$as_echo "$ac_cv_sigwait_one_arg" >&6; } - if test "$ac_cv_sigwait_one_arg" = "yes"; then - -$as_echo "#define SIGWAIT_TAKES_ONE_ARG 1" >>confdefs.h - - fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if ${ac_cv_header_stdc+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_stdc=yes -else - ac_cv_header_stdc=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -else - ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -$as_echo "#define STDC_HEADERS 1" >>confdefs.h - -fi - - - -for ac_header in ByteOrder.h \ - conio.h \ - crypt.h \ - ctype.h \ - dir.h \ - dirent.h \ - dl.h \ - dlfcn.h \ - errno.h \ - fcntl.h \ - grp.h \ - io.h \ - limits.h \ - mach-o/dyld.h \ - malloc.h \ - memory.h \ - netdb.h \ - osreldate.h \ - poll.h \ - process.h \ - pwd.h \ - semaphore.h \ - signal.h \ - stdarg.h \ - stddef.h \ - stdio.h \ - stdlib.h \ - string.h \ - strings.h \ - sysapi.h \ - sysgtime.h \ - termios.h \ - time.h \ - tpfeq.h \ - tpfio.h \ - unistd.h \ - unix.h \ - windows.h \ - winsock2.h \ - arpa/inet.h \ - kernel/OS.h \ - net/errno.h \ - netinet/in.h \ - netinet/sctp.h \ - netinet/sctp_uio.h \ - sys/file.h \ - sys/ioctl.h \ - sys/mman.h \ - sys/param.h \ - sys/poll.h \ - sys/resource.h \ - sys/select.h \ - sys/sem.h \ - sys/sendfile.h \ - sys/signal.h \ - sys/socket.h \ - sys/sockio.h \ - sys/stat.h \ - sys/sysctl.h \ - sys/syslimits.h \ - sys/time.h \ - sys/types.h \ - sys/uio.h \ - sys/un.h \ - sys/wait.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - -for aprt_i in ByteOrder.h \ - conio.h \ - crypt.h \ - ctype.h \ - dir.h \ - dirent.h \ - dl.h \ - dlfcn.h \ - errno.h \ - fcntl.h \ - grp.h \ - io.h \ - limits.h \ - mach-o/dyld.h \ - malloc.h \ - memory.h \ - netdb.h \ - osreldate.h \ - poll.h \ - process.h \ - pwd.h \ - semaphore.h \ - signal.h \ - stdarg.h \ - stddef.h \ - stdio.h \ - stdlib.h \ - string.h \ - strings.h \ - sysapi.h \ - sysgtime.h \ - termios.h \ - time.h \ - tpfeq.h \ - tpfio.h \ - unistd.h \ - unix.h \ - windows.h \ - winsock2.h \ - arpa/inet.h \ - kernel/OS.h \ - net/errno.h \ - netinet/in.h \ - netinet/sctp.h \ - netinet/sctp_uio.h \ - sys/file.h \ - sys/ioctl.h \ - sys/mman.h \ - sys/param.h \ - sys/poll.h \ - sys/resource.h \ - sys/select.h \ - sys/sem.h \ - sys/sendfile.h \ - sys/signal.h \ - sys/socket.h \ - sys/sockio.h \ - sys/stat.h \ - sys/sysctl.h \ - sys/syslimits.h \ - sys/time.h \ - sys/types.h \ - sys/uio.h \ - sys/un.h \ - sys/wait.h -do - ac_safe=`echo "$aprt_i" | sed 'y%./+-%__p_%'` - aprt_2=`echo "$aprt_i" | sed -e 's%/%_%g' -e 's/\.//g' -e 's/-//g'` - if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - eval "$aprt_2=1" - else - eval "$aprt_2=0" - fi -done - - -# IRIX 6.5 has a problem in which prevents it from -# being included by itself. Check for manually, -# including another header file first. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for netinet/tcp.h" >&5 -$as_echo_n "checking for netinet/tcp.h... " >&6; } -if ${apr_cv_hdr_netinet_tcp_h+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef HAVE_NETINET_IN_H -#include -#endif -#include - -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - apr_cv_hdr_netinet_tcp_h=yes -else - apr_cv_hdr_netinet_tcp_h=no -fi -rm -f conftest.err conftest.i conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_hdr_netinet_tcp_h" >&5 -$as_echo "$apr_cv_hdr_netinet_tcp_h" >&6; } -if test "$apr_cv_hdr_netinet_tcp_h" = "yes"; then - netinet_tcph=1 - -$as_echo "#define HAVE_NETINET_TCP_H 1" >>confdefs.h - -else - netinet_tcph=0 -fi - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Checking for h_errno in -if test "$netdbh" = "1"; then - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for h_errno in netdb.h" >&5 -$as_echo_n "checking for h_errno in netdb.h... " >&6; } - if ${ac_cv_h_errno_cppflags+:} false; then : - $as_echo_n "(cached) " >&6 -else - - - if test x != x; then - CPPFLAGS="-D $CPPFLAGS" - fi - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_NETDB_H -#include -#endif - -int -main () -{ - -int h_e = h_errno; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - if test x != x; then - ac_cv_h_errno_cppflags="" - else - ac_cv_h_errno_cppflags=yes - fi - -else - - ac_cv_h_errno_cppflags=no - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if test "$ac_cv_h_errno_cppflags" = "no"; then - ac_save="$CPPFLAGS" - for flag in _XOPEN_SOURCE_EXTENDED; do - - if test x$flag != x; then - CPPFLAGS="-D$flag $CPPFLAGS" - fi - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_NETDB_H -#include -#endif - -int -main () -{ - -int h_e = h_errno; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - if test x$flag != x; then - ac_cv_h_errno_cppflags="$flag" - else - ac_cv_h_errno_cppflags=yes - fi - -else - - ac_cv_h_errno_cppflags=no - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if test "$ac_cv_h_errno_cppflags" != "no"; then - break - fi - done - CPPFLAGS="$ac_save" - fi - -fi - - if test "$ac_cv_h_errno_cppflags" != "no"; then - if test "$ac_cv_h_errno_cppflags" != "yes"; then - CPPFLAGS="-D$ac_cv_h_errno_cppflags $CPPFLAGS" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, with -D$ac_cv_h_errno_cppflags" >&5 -$as_echo "yes, with -D$ac_cv_h_errno_cppflags" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_h_errno_cppflags" >&5 -$as_echo "$ac_cv_h_errno_cppflags" >&6; } - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_h_errno_cppflags" >&5 -$as_echo "$ac_cv_h_errno_cppflags" >&6; } - fi - - if test "$ac_cv_h_errno_cflags" = "no"; then - as_fn_error $? "can not find h_errno in netdb.h" "$LINENO" 5 - fi -fi - -# Check whether --enable-allocator-uses-mmap was given. -if test "${enable_allocator_uses_mmap+set}" = set; then : - enableval=$enable_allocator_uses_mmap; if test "$enableval" = "yes"; then - ac_rc=yes -for ac_spec in header:sys/mman.h func:mmap func:munmap define:MAP_ANON; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - -$as_echo "#define APR_ALLOCATOR_USES_MMAP 1" >>confdefs.h - -else - : - as_fn_error $? "mmap()/MAP_ANON not supported" "$LINENO" 5 - -fi - - fi - -fi - - -ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default" -if test "x$ac_cv_type_off_t" = xyes; then : - -else - -cat >>confdefs.h <<_ACEOF -#define off_t long int -_ACEOF - -fi - -ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" -if test "x$ac_cv_type_pid_t" = xyes; then : - -else - -cat >>confdefs.h <<_ACEOF -#define pid_t int -_ACEOF - -fi - -ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" -if test "x$ac_cv_type_size_t" = xyes; then : - -else - -cat >>confdefs.h <<_ACEOF -#define size_t unsigned int -_ACEOF - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5 -$as_echo_n "checking for uid_t in sys/types.h... " >&6; } -if ${ac_cv_type_uid_t+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "uid_t" >/dev/null 2>&1; then : - ac_cv_type_uid_t=yes -else - ac_cv_type_uid_t=no -fi -rm -f conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_uid_t" >&5 -$as_echo "$ac_cv_type_uid_t" >&6; } -if test $ac_cv_type_uid_t = no; then - -$as_echo "#define uid_t int" >>confdefs.h - - -$as_echo "#define gid_t int" >>confdefs.h - -fi - -ac_fn_c_check_type "$LINENO" "ssize_t" "ac_cv_type_ssize_t" "$ac_includes_default" -if test "x$ac_cv_type_ssize_t" = xyes; then : - -else - -cat >>confdefs.h <<_ACEOF -#define ssize_t int -_ACEOF - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 -$as_echo_n "checking for inline... " >&6; } -if ${ac_cv_c_inline+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_c_inline=no -for ac_kw in inline __inline__ __inline; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifndef __cplusplus -typedef int foo_t; -static $ac_kw foo_t static_foo () {return 0; } -$ac_kw foo_t foo () {return 0; } -#endif - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_c_inline=$ac_kw -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$ac_cv_c_inline" != no && break -done - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 -$as_echo "$ac_cv_c_inline" >&6; } - -case $ac_cv_c_inline in - inline | yes) ;; - *) - case $ac_cv_c_inline in - no) ac_val=;; - *) ac_val=$ac_cv_c_inline;; - esac - cat >>confdefs.h <<_ACEOF -#ifndef __cplusplus -#define inline $ac_val -#endif -_ACEOF - ;; -esac - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 -$as_echo_n "checking for an ANSI C-conforming const... " >&6; } -if ${ac_cv_c_const+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -/* FIXME: Include the comments suggested by Paul. */ -#ifndef __cplusplus - /* Ultrix mips cc rejects this. */ - typedef int charset[2]; - const charset cs; - /* SunOS 4.1.1 cc rejects this. */ - char const *const *pcpcc; - char **ppc; - /* NEC SVR4.0.2 mips cc rejects this. */ - struct point {int x, y;}; - static struct point const zero = {0,0}; - /* AIX XL C 1.02.0.0 rejects this. - It does not let you subtract one const X* pointer from another in - an arm of an if-expression whose if-part is not a constant - expression */ - const char *g = "string"; - pcpcc = &g + (g ? g-g : 0); - /* HPUX 7.0 cc rejects these. */ - ++pcpcc; - ppc = (char**) pcpcc; - pcpcc = (char const *const *) ppc; - { /* SCO 3.2v4 cc rejects this. */ - char *t; - char const *s = 0 ? (char *) 0 : (char const *) 0; - - *t++ = 0; - if (s) return 0; - } - { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ - int x[] = {25, 17}; - const int *foo = &x[0]; - ++foo; - } - { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ - typedef const int *iptr; - iptr p = 0; - ++p; - } - { /* AIX XL C 1.02.0.0 rejects this saying - "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; }; - struct s *b; b->j = 5; - } - { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ - const int foo = 10; - if (!foo) return 0; - } - return !cs[0] && !zero.x; -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_c_const=yes -else - ac_cv_c_const=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 -$as_echo "$ac_cv_c_const" >&6; } -if test $ac_cv_c_const = no; then - -$as_echo "#define const /**/" >>confdefs.h - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether setpgrp takes no argument" >&5 -$as_echo_n "checking whether setpgrp takes no argument... " >&6; } -if ${ac_cv_func_setpgrp_void+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - as_fn_error $? "cannot check setpgrp when cross compiling" "$LINENO" 5 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -/* If this system has a BSD-style setpgrp which takes arguments, - setpgrp(1, 1) will fail with ESRCH and return -1, in that case - exit successfully. */ - return setpgrp (1,1) != -1; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_setpgrp_void=no -else - ac_cv_func_setpgrp_void=yes -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_setpgrp_void" >&5 -$as_echo "$ac_cv_func_setpgrp_void" >&6; } -if test $ac_cv_func_setpgrp_void = yes; then - -$as_echo "#define SETPGRP_VOID 1" >>confdefs.h - -fi - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for socklen_t" >&5 -$as_echo_n "checking for socklen_t... " >&6; } -if ${ac_cv_socklen_t+:} false; then : - $as_echo_n "(cached) " >&6 -else - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_SOCKET_H -#include -#endif - -int -main () -{ - -socklen_t foo = (socklen_t) 0; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - ac_cv_socklen_t=yes - -else - - ac_cv_socklen_t=no - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_socklen_t" >&5 -$as_echo "$ac_cv_socklen_t" >&6; } - -if test "$ac_cv_socklen_t" = "yes"; then - -$as_echo "#define HAVE_SOCKLEN_T 1" >>confdefs.h - -fi - - -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of void*" >&5 -$as_echo_n "checking size of void*... " >&6; } -if ${ac_cv_sizeof_voidp+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (void*))" "ac_cv_sizeof_voidp" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_voidp" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (void*) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_voidp=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_voidp" >&5 -$as_echo "$ac_cv_sizeof_voidp" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_VOIDP $ac_cv_sizeof_voidp -_ACEOF - - - -if test "x$ac_cv_sizeof_voidp" != "x"; then - voidp_size=$ac_cv_sizeof_voidp -else - as_fn_error $? "Cannot determine size of void*" "$LINENO" 5 -fi - -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of char" >&5 -$as_echo_n "checking size of char... " >&6; } -if ${ac_cv_sizeof_char+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char))" "ac_cv_sizeof_char" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_char" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (char) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_char=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_char" >&5 -$as_echo "$ac_cv_sizeof_char" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_CHAR $ac_cv_sizeof_char -_ACEOF - - -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5 -$as_echo_n "checking size of int... " >&6; } -if ${ac_cv_sizeof_int+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_int" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (int) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_int=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5 -$as_echo "$ac_cv_sizeof_int" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_INT $ac_cv_sizeof_int -_ACEOF - - -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5 -$as_echo_n "checking size of long... " >&6; } -if ${ac_cv_sizeof_long+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_long" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (long) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_long=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5 -$as_echo "$ac_cv_sizeof_long" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_LONG $ac_cv_sizeof_long -_ACEOF - - -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of short" >&5 -$as_echo_n "checking size of short... " >&6; } -if ${ac_cv_sizeof_short+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_short" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (short) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_short=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_short" >&5 -$as_echo "$ac_cv_sizeof_short" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_SHORT $ac_cv_sizeof_short -_ACEOF - - -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long" >&5 -$as_echo_n "checking size of long long... " >&6; } -if ${ac_cv_sizeof_long_long+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_long_long" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (long long) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_long_long=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_long" >&5 -$as_echo "$ac_cv_sizeof_long_long" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long -_ACEOF - - - -if test "$ac_cv_sizeof_short" = "2"; then - short_value=short -fi -if test "$ac_cv_sizeof_int" = "4"; then - int_value=int -fi -# Now we need to find what apr_int64_t (sizeof == 8) will be. -# The first match is our preference. -if test "$ac_cv_sizeof_int" = "8"; then - int64_literal='#define APR_INT64_C(val) (val)' - uint64_literal='#define APR_UINT64_C(val) (val##U)' - int64_t_fmt='#define APR_INT64_T_FMT "d"' - uint64_t_fmt='#define APR_UINT64_T_FMT "u"' - uint64_t_hex_fmt='#define APR_UINT64_T_HEX_FMT "x"' - int64_value="int" - long_value=int - int64_strfn="strtoi" -elif test "$ac_cv_sizeof_long" = "8"; then - int64_literal='#define APR_INT64_C(val) (val##L)' - uint64_literal='#define APR_UINT64_C(val) (val##UL)' - int64_t_fmt='#define APR_INT64_T_FMT "ld"' - uint64_t_fmt='#define APR_UINT64_T_FMT "lu"' - uint64_t_hex_fmt='#define APR_UINT64_T_HEX_FMT "lx"' - int64_value="long" - long_value=long - int64_strfn="strtol" -elif test "$ac_cv_sizeof_long_long" = "8"; then - int64_literal='#define APR_INT64_C(val) (val##LL)' - uint64_literal='#define APR_UINT64_C(val) (val##ULL)' - # Linux, Solaris, FreeBSD all support ll with printf. - # BSD 4.4 originated 'q'. Solaris is more popular and - # doesn't support 'q'. Solaris wins. Exceptions can - # go to the OS-dependent section. - int64_t_fmt='#define APR_INT64_T_FMT "lld"' - uint64_t_fmt='#define APR_UINT64_T_FMT "llu"' - uint64_t_hex_fmt='#define APR_UINT64_T_HEX_FMT "llx"' - int64_value="long long" - long_value="long long" - int64_strfn="strtoll" -elif test "$ac_cv_sizeof_longlong" = "8"; then - int64_literal='#define APR_INT64_C(val) (val##LL)' - uint64_literal='#define APR_UINT64_C(val) (val##ULL)' - int64_t_fmt='#define APR_INT64_T_FMT "qd"' - uint64_t_fmt='#define APR_UINT64_T_FMT "qu"' - uint64_t_hex_fmt='#define APR_UINT64_T_HEX_FMT "qx"' - int64_value="__int64" - long_value="__int64" - int64_strfn="strtoll" -else - # int64_literal may be overriden if your compiler thinks you have - # a 64-bit value but APR does not agree. - as_fn_error $? "could not detect a 64-bit integer type" "$LINENO" 5 -fi - -# If present, allow the C99 macro INT64_C to override our conversion. -# -# HP-UX's ANSI C compiler provides this without any includes, so we -# will first look for INT64_C without adding stdint.h -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for INT64_C" >&5 -$as_echo_n "checking for INT64_C... " >&6; } -if ${apr_cv_define_INT64_C+:} false; then : - $as_echo_n "(cached) " >&6 -else - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef INT64_C -YES_IS_DEFINED -#endif -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "YES_IS_DEFINED" >/dev/null 2>&1; then : - apr_cv_define_INT64_C=yes -else - - # Now check for INT64_C in stdint.h - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#ifdef INT64_C -YES_IS_DEFINED -#endif -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "YES_IS_DEFINED" >/dev/null 2>&1; then : - apr_cv_define_INT64_C=yes -else - apr_cv_define_INT64_C=no -fi -rm -f conftest* - -fi -rm -f conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_define_INT64_C" >&5 -$as_echo "$apr_cv_define_INT64_C" >&6; } - -if test "$apr_cv_define_INT64_C" = "yes"; then - int64_literal='#define APR_INT64_C(val) INT64_C(val)' - uint64_literal='#define APR_UINT64_C(val) UINT64_C(val)' - stdint=1 -else - stdint=0 -fi - -if test "$ac_cv_type_size_t" = "yes"; then - size_t_value="size_t" -else - size_t_value="apr_int32_t" -fi -if test "$ac_cv_type_ssize_t" = "yes"; then - ssize_t_value="ssize_t" -else - ssize_t_value="apr_int32_t" -fi -if test "$ac_cv_socklen_t" = "yes"; then - socklen_t_value="socklen_t" - case $host in - *-hp-hpux*) - if test "$ac_cv_sizeof_long" = "8"; then - # 64-bit HP-UX requires 32-bit socklens in - # kernel, but user-space declarations say - # 64-bit (socklen_t == size_t == long). - # This will result in many compile warnings, - # but we're functionally busted otherwise. - socklen_t_value="int" - fi - ;; - esac -else - socklen_t_value="int" -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of pid_t" >&5 -$as_echo_n "checking size of pid_t... " >&6; } -if ${ac_cv_sizeof_pid_t+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_sizeof_pid_t=8 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -main() -{ - FILE *f=fopen("conftestval", "w"); - if (!f) exit(1); - fprintf(f, "%d\n", sizeof(pid_t)); - exit(0); -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_sizeof_pid_t=`cat conftestval` -else - ac_cv_sizeof_pid_t=0 -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_pid_t" >&5 -$as_echo "$ac_cv_sizeof_pid_t" >&6; } - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_PID_T $ac_cv_sizeof_pid_t -_ACEOF - - - -if test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_short"; then - pid_t_fmt='#define APR_PID_T_FMT "hd"' -elif test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_int"; then - pid_t_fmt='#define APR_PID_T_FMT "d"' -elif test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_long"; then - pid_t_fmt='#define APR_PID_T_FMT "ld"' -elif test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_long_long"; then - pid_t_fmt='#define APR_PID_T_FMT APR_INT64_T_FMT' -else - pid_t_fmt='#error Can not determine the proper size for pid_t' -fi - -# Basically, we have tried to figure out the correct format strings -# for APR types which vary between platforms, but we don't always get -# it right. -case $host in - s390*linux*) - # uniquely, the 31-bit Linux/s390 uses "unsigned long int" - # for size_t rather than "unsigned int": - size_t_fmt="lu" - ssize_t_fmt="ld" - ;; - *-os2*) - size_t_fmt="lu" - ;; - *-solaris*) - if test "$ac_cv_sizeof_long" = "8"; then - pid_t_fmt='#define APR_PID_T_FMT "d"' - else - pid_t_fmt='#define APR_PID_T_FMT "ld"' - fi - ;; - *aix4*|*aix5*) - ssize_t_fmt="ld" - size_t_fmt="lu" - ;; - *beos*) - ssize_t_fmt="ld" - size_t_fmt="ld" - ;; - *apple-darwin*) - osver=`uname -r` - case $osver in - [0-7].*) - ssize_t_fmt="d" - ;; - *) - ssize_t_fmt="ld" - ;; - esac - size_t_fmt="lu" - ;; - *-mingw*) - int64_t_fmt='#define APR_INT64_T_FMT "I64d"' - uint64_t_fmt='#define APR_UINT64_T_FMT "I64u"' - uint64_t_hex_fmt='#define APR_UINT64_T_HEX_FMT "I64x"' - int64_value="__int64" - long_value="__int64" - int64_strfn="_strtoi64" - ;; -esac - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ssize_t and int are the same" >&5 -$as_echo_n "checking whether ssize_t and int are the same... " >&6; } -if ${apr_cv_typematch_ssize_t_int+:} false; then : - $as_echo_n "(cached) " >&6 -else - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ - - int foo[0 - !__builtin_types_compatible_p(ssize_t, int)]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - apr_cv_typematch_ssize_t_int=yes -ssize_t_fmt="d" -else - apr_cv_typematch_ssize_t_int=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_typematch_ssize_t_int" >&5 -$as_echo "$apr_cv_typematch_ssize_t_int" >&6; } - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ssize_t and long are the same" >&5 -$as_echo_n "checking whether ssize_t and long are the same... " >&6; } -if ${apr_cv_typematch_ssize_t_long+:} false; then : - $as_echo_n "(cached) " >&6 -else - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ - - int foo[0 - !__builtin_types_compatible_p(ssize_t, long)]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - apr_cv_typematch_ssize_t_long=yes -ssize_t_fmt="ld" -else - apr_cv_typematch_ssize_t_long=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_typematch_ssize_t_long" >&5 -$as_echo "$apr_cv_typematch_ssize_t_long" >&6; } - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether size_t and unsigned int are the same" >&5 -$as_echo_n "checking whether size_t and unsigned int are the same... " >&6; } -if ${apr_cv_typematch_size_t_unsigned_int+:} false; then : - $as_echo_n "(cached) " >&6 -else - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ - - int foo[0 - !__builtin_types_compatible_p(size_t, unsigned int)]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - apr_cv_typematch_size_t_unsigned_int=yes -size_t_fmt="u" -else - apr_cv_typematch_size_t_unsigned_int=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_typematch_size_t_unsigned_int" >&5 -$as_echo "$apr_cv_typematch_size_t_unsigned_int" >&6; } - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether size_t and unsigned long are the same" >&5 -$as_echo_n "checking whether size_t and unsigned long are the same... " >&6; } -if ${apr_cv_typematch_size_t_unsigned_long+:} false; then : - $as_echo_n "(cached) " >&6 -else - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ - - int foo[0 - !__builtin_types_compatible_p(size_t, unsigned long)]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - apr_cv_typematch_size_t_unsigned_long=yes -size_t_fmt="lu" -else - apr_cv_typematch_size_t_unsigned_long=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_typematch_size_t_unsigned_long" >&5 -$as_echo "$apr_cv_typematch_size_t_unsigned_long" >&6; } - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of ssize_t" >&5 -$as_echo_n "checking size of ssize_t... " >&6; } -if ${ac_cv_sizeof_ssize_t+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_sizeof_ssize_t=8 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -main() -{ - FILE *f=fopen("conftestval", "w"); - if (!f) exit(1); - fprintf(f, "%d\n", sizeof(ssize_t)); - exit(0); -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_sizeof_ssize_t=`cat conftestval` -else - ac_cv_sizeof_ssize_t=0 -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_ssize_t" >&5 -$as_echo "$ac_cv_sizeof_ssize_t" >&6; } - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_SSIZE_T $ac_cv_sizeof_ssize_t -_ACEOF - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which format to use for apr_ssize_t" >&5 -$as_echo_n "checking which format to use for apr_ssize_t... " >&6; } -if test -n "$ssize_t_fmt"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: %$ssize_t_fmt" >&5 -$as_echo "%$ssize_t_fmt" >&6; } -elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_int"; then - ssize_t_fmt="d" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: %d" >&5 -$as_echo "%d" >&6; } -elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_long"; then - ssize_t_fmt="ld" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: %ld" >&5 -$as_echo "%ld" >&6; } -else - as_fn_error $? "could not determine the proper format for apr_ssize_t" "$LINENO" 5 -fi - -ssize_t_fmt="#define APR_SSIZE_T_FMT \"$ssize_t_fmt\"" - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of size_t" >&5 -$as_echo_n "checking size of size_t... " >&6; } -if ${ac_cv_sizeof_size_t+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_sizeof_size_t=8 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -main() -{ - FILE *f=fopen("conftestval", "w"); - if (!f) exit(1); - fprintf(f, "%d\n", sizeof(size_t)); - exit(0); -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_sizeof_size_t=`cat conftestval` -else - ac_cv_sizeof_size_t=0 -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_size_t" >&5 -$as_echo "$ac_cv_sizeof_size_t" >&6; } - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_SIZE_T $ac_cv_sizeof_size_t -_ACEOF - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which format to use for apr_size_t" >&5 -$as_echo_n "checking which format to use for apr_size_t... " >&6; } -if test -n "$size_t_fmt"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: %$size_t_fmt" >&5 -$as_echo "%$size_t_fmt" >&6; } -elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_int"; then - size_t_fmt="d" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: %d" >&5 -$as_echo "%d" >&6; } -elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_long"; then - size_t_fmt="ld" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: %ld" >&5 -$as_echo "%ld" >&6; } -else - as_fn_error $? "could not determine the proper format for apr_size_t" "$LINENO" 5 -fi - -size_t_fmt="#define APR_SIZE_T_FMT \"$size_t_fmt\"" - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of off_t" >&5 -$as_echo_n "checking size of off_t... " >&6; } -if ${ac_cv_sizeof_off_t+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_sizeof_off_t=8 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -main() -{ - FILE *f=fopen("conftestval", "w"); - if (!f) exit(1); - fprintf(f, "%d\n", sizeof(off_t)); - exit(0); -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_sizeof_off_t=`cat conftestval` -else - ac_cv_sizeof_off_t=0 -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_off_t" >&5 -$as_echo "$ac_cv_sizeof_off_t" >&6; } - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_OFF_T $ac_cv_sizeof_off_t -_ACEOF - - - -if test "${ac_cv_sizeof_off_t}${apr_cv_use_lfs64}" = "4yes"; then - # Enable LFS - aprlfs=1 - for ac_func in mmap64 sendfile64 sendfilev64 mkstemp64 readdir64_r -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - -elif test "${ac_cv_sizeof_off_t}" != "${ac_cv_sizeof_size_t}"; then - # unsure of using -gt above is as portable, can can't forsee where - # off_t can legitimately be smaller than size_t - aprlfs=1 -else - aprlfs=0 -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which type to use for apr_off_t" >&5 -$as_echo_n "checking which type to use for apr_off_t... " >&6; } -if test "${ac_cv_sizeof_off_t}${apr_cv_use_lfs64}" = "4yes"; then - # LFS is go! - off_t_fmt='#define APR_OFF_T_FMT APR_INT64_T_FMT' - off_t_value='off64_t' - off_t_strfn='apr_strtoi64' -elif test "${ac_cv_sizeof_off_t}x${ac_cv_sizeof_long}" = "4x4"; then - # Special case: off_t may change size with _FILE_OFFSET_BITS - # on 32-bit systems with LFS support. To avoid compatibility - # issues when other packages do define _FILE_OFFSET_BITS, - # hard-code apr_off_t to long. - off_t_value=long - off_t_fmt='#define APR_OFF_T_FMT "ld"' - off_t_strfn='strtol' -elif test "$ac_cv_type_off_t" = "yes"; then - off_t_value=off_t - # off_t is more commonly a long than an int; prefer that case - # where int and long are the same size. - if test "$ac_cv_sizeof_off_t" = "$ac_cv_sizeof_long"; then - off_t_fmt='#define APR_OFF_T_FMT "ld"' - off_t_strfn='strtol' - elif test "$ac_cv_sizeof_off_t" = "$ac_cv_sizeof_int"; then - off_t_fmt='#define APR_OFF_T_FMT "d"' - off_t_strfn='strtoi' - elif test "$ac_cv_sizeof_off_t" = "$ac_cv_sizeof_long_long"; then - off_t_fmt='#define APR_OFF_T_FMT APR_INT64_T_FMT' - off_t_strfn='apr_strtoi64' - else - as_fn_error $? "could not determine the size of off_t" "$LINENO" 5 - fi - # Per OS tuning... - case $host in - *-mingw*) - off_t_value=apr_int64_t - off_t_fmt='#define APR_OFF_T_FMT "I64d"' - off_t_strfn='_strtoi64' - ;; - esac -else - # Fallback on int - off_t_value=apr_int32_t - off_t_fmt=d - off_t_strfn='strtoi' -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $off_t_value" >&5 -$as_echo "$off_t_value" >&6; } - -# Regardless of whether _LARGEFILE64_SOURCE is used, on some -# platforms _FILE_OFFSET_BITS will affect the size of ino_t and hence -# the build-time ABI may be different from the apparent ABI when using -# APR with another package which *does* define _FILE_OFFSET_BITS. -# (Exactly as per the case above with off_t where LFS is *not* used) -# -# To be safe, hard-code apr_ino_t as 'unsigned long' or 'unsigned int' -# iff that is exactly the size of ino_t here; otherwise use ino_t as existing -# releases did. To be correct, apr_ino_t should have been made an -# ino64_t as apr_off_t is off64_t, but this can't be done now without -# breaking ABI. - -# Per OS tuning... -case $host in -*mingw*) - ino_t_value=apr_int64_t - ;; -*) - ino_t_value=ino_t - { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of ino_t" >&5 -$as_echo_n "checking size of ino_t... " >&6; } -if ${ac_cv_sizeof_ino_t+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_sizeof_ino_t=$ac_cv_sizeof_long -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -$ac_includes_default -main() -{ - FILE *f=fopen("conftestval", "w"); - if (!f) exit(1); - fprintf(f, "%d\n", sizeof(ino_t)); - exit(0); -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_sizeof_ino_t=`cat conftestval` -else - ac_cv_sizeof_ino_t=0 -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_ino_t" >&5 -$as_echo "$ac_cv_sizeof_ino_t" >&6; } - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_INO_T $ac_cv_sizeof_ino_t -_ACEOF - - - if test $ac_cv_sizeof_ino_t = 4; then - if test $ac_cv_sizeof_long = 4; then - ino_t_value="unsigned long" - else - ino_t_value="unsigned int" - fi - fi - ;; -esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: using $ino_t_value for ino_t" >&5 -$as_echo "$as_me: using $ino_t_value for ino_t" >&6;} - -# Checks for endianness - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 -$as_echo_n "checking whether byte ordering is bigendian... " >&6; } -if ${ac_cv_c_bigendian+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_c_bigendian=unknown - # See if we're dealing with a universal compiler. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifndef __APPLE_CC__ - not a universal capable compiler - #endif - typedef int dummy; - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - # Check for potential -arch flags. It is not universal unless - # there are at least two -arch flags with different values. - ac_arch= - ac_prev= - for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do - if test -n "$ac_prev"; then - case $ac_word in - i?86 | x86_64 | ppc | ppc64) - if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then - ac_arch=$ac_word - else - ac_cv_c_bigendian=universal - break - fi - ;; - esac - ac_prev= - elif test "x$ac_word" = "x-arch"; then - ac_prev=arch - fi - done -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if test $ac_cv_c_bigendian = unknown; then - # See if sys/param.h defines the BYTE_ORDER macro. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - #include - -int -main () -{ -#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ - && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ - && LITTLE_ENDIAN) - bogus endian macros - #endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - # It does; now see whether it defined to BIG_ENDIAN or not. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - #include - -int -main () -{ -#if BYTE_ORDER != BIG_ENDIAN - not big endian - #endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_c_bigendian=yes -else - ac_cv_c_bigendian=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - fi - if test $ac_cv_c_bigendian = unknown; then - # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -int -main () -{ -#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) - bogus endian macros - #endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - # It does; now see whether it defined to _BIG_ENDIAN or not. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -int -main () -{ -#ifndef _BIG_ENDIAN - not big endian - #endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_c_bigendian=yes -else - ac_cv_c_bigendian=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - fi - if test $ac_cv_c_bigendian = unknown; then - # Compile a test program. - if test "$cross_compiling" = yes; then : - # Try to guess by grepping values from an object file. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -short int ascii_mm[] = - { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; - short int ascii_ii[] = - { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; - int use_ascii (int i) { - return ascii_mm[i] + ascii_ii[i]; - } - short int ebcdic_ii[] = - { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; - short int ebcdic_mm[] = - { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; - int use_ebcdic (int i) { - return ebcdic_mm[i] + ebcdic_ii[i]; - } - extern int foo; - -int -main () -{ -return use_ascii (foo) == use_ebcdic (foo); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then - ac_cv_c_bigendian=yes - fi - if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then - if test "$ac_cv_c_bigendian" = unknown; then - ac_cv_c_bigendian=no - else - # finding both strings is unlikely to happen, but who knows? - ac_cv_c_bigendian=unknown - fi - fi -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ - - /* Are we little or big endian? From Harbison&Steele. */ - union - { - long int l; - char c[sizeof (long int)]; - } u; - u.l = 1; - return u.c[sizeof (long int) - 1] == 1; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_c_bigendian=no -else - ac_cv_c_bigendian=yes -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 -$as_echo "$ac_cv_c_bigendian" >&6; } - case $ac_cv_c_bigendian in #( - yes) - $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h -;; #( - no) - ;; #( - universal) - -$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h - - ;; #( - *) - as_fn_error $? "unknown endianness - presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; - esac - -if test $ac_cv_c_bigendian = yes; then - bigendian=1 -else - bigendian=0 -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of struct iovec" >&5 -$as_echo_n "checking size of struct iovec... " >&6; } -if ${ac_cv_sizeof_struct_iovec+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_sizeof_struct_iovec=0 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -main() -{ - FILE *f=fopen("conftestval", "w"); - if (!f) exit(1); - fprintf(f, "%d\n", sizeof(struct iovec)); - exit(0); -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_sizeof_struct_iovec=`cat conftestval` -else - ac_cv_sizeof_struct_iovec=0 -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_struct_iovec" >&5 -$as_echo "$ac_cv_sizeof_struct_iovec" >&6; } - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_STRUCT_IOVEC $ac_cv_sizeof_struct_iovec -_ACEOF - - -if test "$ac_cv_sizeof_struct_iovec" = "0"; then - have_iovec=0 -else - have_iovec=1 -fi - - - - - - - - - - - - - - - - - - - - - - - - - -for ac_func in strnicmp -do : - ac_fn_c_check_func "$LINENO" "strnicmp" "ac_cv_func_strnicmp" -if test "x$ac_cv_func_strnicmp" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_STRNICMP 1 -_ACEOF - have_strnicmp="1" -else - have_strnicmp="0" -fi -done - -for ac_func in strncasecmp -do : - ac_fn_c_check_func "$LINENO" "strncasecmp" "ac_cv_func_strncasecmp" -if test "x$ac_cv_func_strncasecmp" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_STRNCASECMP 1 -_ACEOF - have_strncasecmp="1" -else - have_strncasecmp="0" -fi -done - -for ac_func in stricmp -do : - ac_fn_c_check_func "$LINENO" "stricmp" "ac_cv_func_stricmp" -if test "x$ac_cv_func_stricmp" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_STRICMP 1 -_ACEOF - have_stricmp="1" -else - have_stricmp="0" -fi -done - -for ac_func in strcasecmp -do : - ac_fn_c_check_func "$LINENO" "strcasecmp" "ac_cv_func_strcasecmp" -if test "x$ac_cv_func_strcasecmp" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_STRCASECMP 1 -_ACEOF - have_strcasecmp="1" -else - have_strcasecmp="0" -fi -done - -for ac_func in strdup -do : - ac_fn_c_check_func "$LINENO" "strdup" "ac_cv_func_strdup" -if test "x$ac_cv_func_strdup" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_STRDUP 1 -_ACEOF - have_strdup="1" -else - have_strdup="0" -fi -done - -for ac_func in strstr -do : - ac_fn_c_check_func "$LINENO" "strstr" "ac_cv_func_strstr" -if test "x$ac_cv_func_strstr" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_STRSTR 1 -_ACEOF - have_strstr="1" -else - have_strstr="0" -fi -done - -for ac_func in memchr -do : - ac_fn_c_check_func "$LINENO" "memchr" "ac_cv_func_memchr" -if test "x$ac_cv_func_memchr" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_MEMCHR 1 -_ACEOF - have_memchr="1" -else - have_memchr="0" -fi -done - -as_ac_var=`$as_echo "ac_cv_func_$int64_strfn" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$int64_strfn" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - have_int64_strfn="1" -else - have_int64_strfn="0" -fi - - -if test "$have_int64_strfn" = "0" && test "$int64_strfn" = "strtoll"; then - int64_strfn="strtoq" - ac_fn_c_check_func "$LINENO" "strtoq" "ac_cv_func_strtoq" -if test "x$ac_cv_func_strtoq" = xyes; then : - have_int64_strfn=1 -else - have_int64_strfn=0 -fi - -fi - -if test "$have_int64_strfn" = "1"; then - -cat >>confdefs.h <<_ACEOF -#define APR_INT64_STRFN $int64_strfn -_ACEOF - -fi - - - - - - - - - -if test "$off_t_strfn" = "apr_strtoi64" && test "$have_int64_strfn" = "1"; then - off_t_strfn=$int64_strfn -fi - -cat >>confdefs.h <<_ACEOF -#define APR_OFF_T_STRFN $off_t_strfn -_ACEOF - - -echo "${nl}Checking for DSO..." -# Check whether --enable-dso was given. -if test "${enable_dso+set}" = set; then : - enableval=$enable_dso; if test "x$enableval" = "xyes"; then - dsotype=any - else - dsotype=$enableval - fi - -else - dsotype=any -fi - - -if test "$dsotype" = "any"; then - if test "$dsotype" = "any"; then - case $host in - *darwin[0-8]\.*) - # Original Darwin, not for 9.0!: - ac_fn_c_check_func "$LINENO" "NSLinkModule" "ac_cv_func_NSLinkModule" -if test "x$ac_cv_func_NSLinkModule" = xyes; then : - dsotype=dyld -fi -;; - hppa*-hpux[1-9]\.*|hppa*-hpux1[01]*) - # shl is specific to parisc hpux SOM binaries, not used for 64 bit - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 -$as_echo_n "checking for shl_load in -ldld... " >&6; } -if ${ac_cv_lib_dld_shl_load+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldld $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char shl_load (); -int -main () -{ -return shl_load (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_dld_shl_load=yes -else - ac_cv_lib_dld_shl_load=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 -$as_echo "$ac_cv_lib_dld_shl_load" >&6; } -if test "x$ac_cv_lib_dld_shl_load" = xyes; then : - have_shl=1 -fi - - if test "$ac_cv_sizeof_voidp$have_shl" = "41"; then - dsotype=shl; - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-ldld\"" - LIBS="-ldld" - else - apr_addto_bugger="-ldld" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - fi;; - *mingw*|*-os2*) - # several 'other's below probably belong up here. If they always - # use a platform implementation and shouldn't test the dlopen/dlfcn - # features, then bring them up here. - # But if they -should- optionally use dlfcn, and/or need the config - # detection of dlopen/dlsym, do not move them up. - dsotype=other ;; - esac - fi - # Normal POSIX: - if test "$dsotype" = "any"; then - ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" -if test "x$ac_cv_func_dlopen" = xyes; then : - dsotype=dlfcn -fi - - fi - if test "$dsotype" = "any"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 -$as_echo_n "checking for dlopen in -ldl... " >&6; } -if ${ac_cv_lib_dl_dlopen+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dlopen (); -int -main () -{ -return dlopen (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_dl_dlopen=yes -else - ac_cv_lib_dl_dlopen=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 -$as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = xyes; then : - dsotype=dlfcn; - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-ldl\"" - LIBS="-ldl" - else - apr_addto_bugger="-ldl" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - -fi - - fi - if test "$dsotype" = "dlfcn"; then - # ReliantUnix has dlopen() in libc but dlsym() in libdl :( - ac_fn_c_check_func "$LINENO" "dlsym" "ac_cv_func_dlsym" -if test "x$ac_cv_func_dlsym" = xyes; then : - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlsym in -ldl" >&5 -$as_echo_n "checking for dlsym in -ldl... " >&6; } -if ${ac_cv_lib_dl_dlsym+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dlsym (); -int -main () -{ -return dlsym (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_dl_dlsym=yes -else - ac_cv_lib_dl_dlsym=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlsym" >&5 -$as_echo "$ac_cv_lib_dl_dlsym" >&6; } -if test "x$ac_cv_lib_dl_dlsym" = xyes; then : - - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-ldl\"" - LIBS="-ldl" - else - apr_addto_bugger="-ldl" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - -else - dsotype=any - echo "Weird: dlopen() was found but dlsym() was not found!" -fi - -fi - - fi - if test "$dsotype" = "any"; then - # BeOS: - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for load_image in -lroot" >&5 -$as_echo_n "checking for load_image in -lroot... " >&6; } -if ${ac_cv_lib_root_load_image+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lroot $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char load_image (); -int -main () -{ -return load_image (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_root_load_image=yes -else - ac_cv_lib_root_load_image=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_root_load_image" >&5 -$as_echo "$ac_cv_lib_root_load_image" >&6; } -if test "x$ac_cv_lib_root_load_image" = xyes; then : - dsotype=other -fi - - fi - # Everything else: - if test "$dsotype" = "any"; then - case $host in - *os390|*os400|*-aix*) - # Some -aix5 will use dl, no hassles. Keep that pattern here. - dsotype=other ;; - *-hpux*) - if test "$have_shl" = "1"; then - dsotype=shl; - if test "x$LIBS" = "x"; then - test "x$silent" != "xyes" && echo " setting LIBS to \"-ldld\"" - LIBS="-ldld" - else - apr_addto_bugger="-ldld" - for i in $apr_addto_bugger; do - apr_addto_duplicate="0" - for j in $LIBS; do - if test "x$i" = "x$j"; then - apr_addto_duplicate="1" - break - fi - done - if test $apr_addto_duplicate = "0"; then - test "x$silent" != "xyes" && echo " adding \"$i\" to LIBS" - LIBS="$LIBS $i" - fi - done - fi - - fi;; - esac - fi -fi - -if test "$dsotype" = "any"; then - as_fn_error $? "Could not detect suitable DSO implementation" "$LINENO" 5 -elif test "$dsotype" = "no"; then - aprdso="0" -else - case "$dsotype" in - dlfcn) -$as_echo "#define DSO_USE_DLFCN 1" >>confdefs.h -;; - shl) -$as_echo "#define DSO_USE_SHL 1" >>confdefs.h -;; - dyld) -$as_echo "#define DSO_USE_DYLD 1" >>confdefs.h -;; - other) ;; # Use whatever is in dso/OSDIR - *) as_fn_error $? "Unknown DSO implementation \"$dsotype\"" "$LINENO" 5;; - esac - aprdso="1" - apr_modules="$apr_modules dso" -fi - - - -echo "${nl}Checking for Processes..." - -for ac_func in waitpid -do : - ac_fn_c_check_func "$LINENO" "waitpid" "ac_cv_func_waitpid" -if test "x$ac_cv_func_waitpid" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_WAITPID 1 -_ACEOF - -fi -done - - -# Check whether --enable-other-child was given. -if test "${enable_other_child+set}" = set; then : - enableval=$enable_other_child; if test "$enableval" = "yes"; then - oc="1" - else - oc="0" - fi -else - oc=1 -fi - - - - -if test -z "$have_proc_invoked"; then - have_proc_invoked="0" -fi - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Variable Length Arrays" >&5 -$as_echo_n "checking for Variable Length Arrays... " >&6; } -apr_save_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS $CFLAGS_WARN" - if test "$ac_cv_c_compiler_gnu" = "yes"; then - CFLAGS="$CFLAGS -Werror" - fi - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include "confdefs.h" - - - int main(int argc, const char *const *argv) { - - int foo[argc]; - foo[0] = 0; - - return 0; } - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - vla_msg=yes -else - vla_msg=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$apr_save_CFLAGS - -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $vla_msg" >&5 -$as_echo "$vla_msg" >&6; } -if test "$vla_msg" = "yes"; then - -$as_echo "#define HAVE_VLA 1" >>confdefs.h - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking struct rlimit" >&5 -$as_echo_n "checking struct rlimit... " >&6; } -if ${ac_cv_struct_rlimit+:} false; then : - $as_echo_n "(cached) " >&6 -else - -if test "$cross_compiling" = yes; then : - - ac_cv_struct_rlimit=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -main() -{ - struct rlimit limit; - limit.rlim_cur = 0; - limit.rlim_max = 0; - exit(0); -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - - ac_cv_struct_rlimit=yes -else - - ac_cv_struct_rlimit=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_rlimit" >&5 -$as_echo "$ac_cv_struct_rlimit" >&6; } -struct_rlimit=0 -test "x$ac_cv_struct_rlimit" = xyes && struct_rlimit=1 - - -echo "${nl}Checking for Locking..." - -for ac_func in semget semctl flock -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - -for ac_header in semaphore.h OS.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sem_open" >&5 -$as_echo_n "checking for library containing sem_open... " >&6; } -if ${ac_cv_search_sem_open+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char sem_open (); -int -main () -{ -return sem_open (); - ; - return 0; -} -_ACEOF -for ac_lib in '' rt; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_sem_open=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_sem_open+:} false; then : - break -fi -done -if ${ac_cv_search_sem_open+:} false; then : - -else - ac_cv_search_sem_open=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_sem_open" >&5 -$as_echo "$ac_cv_search_sem_open" >&6; } -ac_res=$ac_cv_search_sem_open -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -fi - -for ac_func in sem_close sem_unlink sem_post sem_wait create_sem -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - -# Some systems return ENOSYS from sem_open. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working sem_open" >&5 -$as_echo_n "checking for working sem_open... " >&6; } -if ${ac_cv_func_sem_open+:} false; then : - $as_echo_n "(cached) " >&6 -else - -if test "$cross_compiling" = yes; then : - ac_cv_func_sem_open=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -#include -#ifndef SEM_FAILED -#define SEM_FAILED (-1) -#endif -main() -{ - sem_t *psem; - const char *sem_name = "/apr_autoconf"; - - psem = sem_open(sem_name, O_CREAT, 0644, 1); - if (psem == (sem_t *)SEM_FAILED) { - exit(1); - } - sem_close(psem); - psem = sem_open(sem_name, O_CREAT | O_EXCL, 0644, 1); - if (psem != (sem_t *)SEM_FAILED) { - sem_close(psem); - exit(1); - } - sem_unlink(sem_name); - exit(0); -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_sem_open=yes -else - ac_cv_func_sem_open=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_sem_open" >&5 -$as_echo "$ac_cv_func_sem_open" >&6; } - -# It's stupid, but not all platforms have union semun, even those that need it. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for union semun in sys/sem.h" >&5 -$as_echo_n "checking for union semun in sys/sem.h... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include - -int -main () -{ - -union semun arg; -semctl(0, 0, 0, arg); - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - have_union_semun="1" union_semun=yes -msg=yes -else - -have_union_semun="0" -msg=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $msg" >&5 -$as_echo "$msg" >&6; } - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LOCK_EX in sys/file.h" >&5 -$as_echo_n "checking for LOCK_EX in sys/file.h... " >&6; } -if ${ac_cv_define_LOCK_EX+:} false; then : - $as_echo_n "(cached) " >&6 -else - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#ifdef LOCK_EX -YES_IS_DEFINED -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "YES_IS_DEFINED" >/dev/null 2>&1; then : - ac_cv_define_LOCK_EX=yes -else - ac_cv_define_LOCK_EX=no -fi -rm -f conftest* - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_define_LOCK_EX" >&5 -$as_echo "$ac_cv_define_LOCK_EX" >&6; } - if test "$ac_cv_define_LOCK_EX" = "yes"; then - -$as_echo "#define HAVE_LOCK_EX 1" >>confdefs.h - - fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for F_SETLK in fcntl.h" >&5 -$as_echo_n "checking for F_SETLK in fcntl.h... " >&6; } -if ${ac_cv_define_F_SETLK+:} false; then : - $as_echo_n "(cached) " >&6 -else - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#ifdef F_SETLK -YES_IS_DEFINED -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "YES_IS_DEFINED" >/dev/null 2>&1; then : - ac_cv_define_F_SETLK=yes -else - ac_cv_define_F_SETLK=no -fi -rm -f conftest* - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_define_F_SETLK" >&5 -$as_echo "$ac_cv_define_F_SETLK" >&6; } - if test "$ac_cv_define_F_SETLK" = "yes"; then - -$as_echo "#define HAVE_F_SETLK 1" >>confdefs.h - - fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SEM_UNDO in sys/sem.h" >&5 -$as_echo_n "checking for SEM_UNDO in sys/sem.h... " >&6; } -if ${ac_cv_define_SEM_UNDO+:} false; then : - $as_echo_n "(cached) " >&6 -else - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#ifdef SEM_UNDO -YES_IS_DEFINED -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "YES_IS_DEFINED" >/dev/null 2>&1; then : - ac_cv_define_SEM_UNDO=yes -else - ac_cv_define_SEM_UNDO=no -fi -rm -f conftest* - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_define_SEM_UNDO" >&5 -$as_echo "$ac_cv_define_SEM_UNDO" >&6; } - if test "$ac_cv_define_SEM_UNDO" = "yes"; then - -$as_echo "#define HAVE_SEM_UNDO 1" >>confdefs.h - - fi - - -# We are assuming that if the platform doesn't have POLLIN, it doesn't have -# any POLL definitions. - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for POLLIN in poll.h sys/poll.h" >&5 -$as_echo_n "checking for POLLIN in poll.h sys/poll.h... " >&6; } -if ${ac_cv_define_POLLIN+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ac_cv_define_POLLIN=no - for curhdr in poll.h sys/poll.h - do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include <$curhdr> -#ifdef POLLIN -YES_IS_DEFINED -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "YES_IS_DEFINED" >/dev/null 2>&1; then : - ac_cv_define_POLLIN=yes -fi -rm -f conftest* - - done - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_define_POLLIN" >&5 -$as_echo "$ac_cv_define_POLLIN" >&6; } - if test "$ac_cv_define_POLLIN" = "yes"; then - -$as_echo "#define HAVE_POLLIN 1" >>confdefs.h - - fi - - -if test "$threads" = "1"; then - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PTHREAD_PROCESS_SHARED in pthread.h" >&5 -$as_echo_n "checking for PTHREAD_PROCESS_SHARED in pthread.h... " >&6; } -if ${ac_cv_define_PTHREAD_PROCESS_SHARED+:} false; then : - $as_echo_n "(cached) " >&6 -else - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#ifdef PTHREAD_PROCESS_SHARED -YES_IS_DEFINED -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "YES_IS_DEFINED" >/dev/null 2>&1; then : - ac_cv_define_PTHREAD_PROCESS_SHARED=yes -else - ac_cv_define_PTHREAD_PROCESS_SHARED=no -fi -rm -f conftest* - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_define_PTHREAD_PROCESS_SHARED" >&5 -$as_echo "$ac_cv_define_PTHREAD_PROCESS_SHARED" >&6; } - if test "$ac_cv_define_PTHREAD_PROCESS_SHARED" = "yes"; then - -$as_echo "#define HAVE_PTHREAD_PROCESS_SHARED 1" >>confdefs.h - - fi - - for ac_func in pthread_mutexattr_setpshared -do : - ac_fn_c_check_func "$LINENO" "pthread_mutexattr_setpshared" "ac_cv_func_pthread_mutexattr_setpshared" -if test "x$ac_cv_func_pthread_mutexattr_setpshared" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_PTHREAD_MUTEXATTR_SETPSHARED 1 -_ACEOF - -fi -done - - # Some systems have setpshared and define PROCESS_SHARED, but don't - # really support PROCESS_SHARED locks. So, we must validate that we - # can go through the steps without receiving some sort of system error. - # Linux and older versions of AIX have this problem. - ac_rc=yes -for ac_spec in header:pthread.h define:PTHREAD_PROCESS_SHARED func:pthread_mutexattr_setpshared; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working PROCESS_SHARED locks" >&5 -$as_echo_n "checking for working PROCESS_SHARED locks... " >&6; } -if ${apr_cv_process_shared_works+:} false; then : - $as_echo_n "(cached) " >&6 -else - - if test "$cross_compiling" = yes; then : - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run test program while cross compiling -See \`config.log' for more details" "$LINENO" 5; } -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include - int main() - { - pthread_mutex_t mutex; - pthread_mutexattr_t attr; - if (pthread_mutexattr_init(&attr)) - exit(1); - if (pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED)) - exit(2); - if (pthread_mutex_init(&mutex, &attr)) - exit(3); - if (pthread_mutexattr_destroy(&attr)) - exit(4); - if (pthread_mutex_destroy(&mutex)) - exit(5); - exit(0); - } -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - apr_cv_process_shared_works=yes -else - apr_cv_process_shared_works=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_process_shared_works" >&5 -$as_echo "$apr_cv_process_shared_works" >&6; } - # Override detection of pthread_mutexattr_setpshared - ac_cv_func_pthread_mutexattr_setpshared=$apr_cv_process_shared_works -else - : - -fi - - - if test "$ac_cv_func_pthread_mutexattr_setpshared" = "yes"; then - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for robust cross-process mutex support" >&5 -$as_echo_n "checking for robust cross-process mutex support... " >&6; } -if ${apr_cv_mutex_robust_shared+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run test program while cross compiling -See \`config.log' for more details" "$LINENO" 5; } -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include - -int main(int argc, char **argv) -{ - pthread_mutex_t mutex; - pthread_mutexattr_t attr; - - if (pthread_mutexattr_init(&attr)) - exit(1); - if (pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED)) - exit(2); - if (pthread_mutexattr_setrobust_np(&attr, PTHREAD_MUTEX_ROBUST_NP)) - exit(3); - if (pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT)) - exit(4); - if (pthread_mutex_init(&mutex, &attr)) - exit(5); - if (pthread_mutexattr_destroy(&attr)) - exit(6); - if (pthread_mutex_destroy(&mutex)) - exit(7); - - exit(0); -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - apr_cv_mutex_robust_shared=yes -else - apr_cv_mutex_robust_shared=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_mutex_robust_shared" >&5 -$as_echo "$apr_cv_mutex_robust_shared" >&6; } - -if test "$apr_cv_mutex_robust_shared" = "yes"; then - -$as_echo "#define HAVE_PTHREAD_MUTEX_ROBUST 1" >>confdefs.h - -fi - - fi -fi - -# See which lock mechanisms we can support on this system. -ac_rc=yes -for ac_spec in header:semaphore.h func:sem_open func:sem_close func:sem_unlink func:sem_post func:sem_wait; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - hasposixser="1" -else - : - hasposixser="0" -fi - -ac_rc=yes -for ac_spec in func:semget func:semctl define:SEM_UNDO; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - hassysvser="1" -else - : - hassysvser="0" -fi - -ac_rc=yes -for ac_spec in func:flock define:LOCK_EX; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - hasflockser="1" -else - : - hasflockser="0" -fi - -ac_rc=yes -for ac_spec in header:fcntl.h define:F_SETLK; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - hasfcntlser="1" -else - : - hasfcntlser="0" -fi - -# note: the current APR use of shared mutex requires /dev/zero -ac_rc=yes -for ac_spec in header:pthread.h define:PTHREAD_PROCESS_SHARED func:pthread_mutexattr_setpshared file:/dev/zero; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - hasprocpthreadser="1" -else - : - hasprocpthreadser="0" -fi - -ac_rc=yes -for ac_spec in header:OS.h func:create_sem; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - hasbeossem="1" -else - : - hasbeossem="0" -fi - - -# See which lock mechanism we'll select by default on this system. -# The last APR_DECIDE to execute sets the default. -# At this stage, we match the ordering in Apache 1.3 -# which is (highest to lowest): sysvsem -> fcntl -> flock. -# POSIX semaphores and cross-process pthread mutexes are not -# used by default since they have less desirable behaviour when -# e.g. a process holding the mutex segfaults. -# The BEOSSEM decision doesn't require any substitutions but is -# included here to prevent the fcntl() branch being selected -# from the decision making. -ac_decision_item='apr_lock implementation method' -ac_decision_msg='FAILED' -ac_decision='' - -ac_rc=yes -for ac_spec in func:flock define:LOCK_EX; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - -ac_decision='USE_FLOCK_SERIALIZE' -ac_decision_msg='4.2BSD-style flock()' -ac_decision_USE_FLOCK_SERIALIZE=yes -ac_decision_USE_FLOCK_SERIALIZE_msg='4.2BSD-style flock()' - -else - : - -fi - -ac_rc=yes -for ac_spec in header:fcntl.h define:F_SETLK; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - -ac_decision='USE_FCNTL_SERIALIZE' -ac_decision_msg='SVR4-style fcntl()' -ac_decision_USE_FCNTL_SERIALIZE=yes -ac_decision_USE_FCNTL_SERIALIZE_msg='SVR4-style fcntl()' - -else - : - -fi - -ac_rc=yes -for ac_spec in func:semget func:semctl define:SEM_UNDO; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - -ac_decision='USE_SYSVSEM_SERIALIZE' -ac_decision_msg='SysV IPC semget()' -ac_decision_USE_SYSVSEM_SERIALIZE=yes -ac_decision_USE_SYSVSEM_SERIALIZE_msg='SysV IPC semget()' - -else - : - -fi - -ac_rc=yes -for ac_spec in header:OS.h func:create_sem; do - ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` - ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` - case $ac_type in - header ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_header_$ac_item" - ;; - file ) - ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` - ac_var="ac_cv_file_$ac_item" - ;; - func ) ac_var="ac_cv_func_$ac_item" ;; - struct ) ac_var="ac_cv_struct_$ac_item" ;; - define ) ac_var="ac_cv_define_$ac_item" ;; - custom ) ac_var="$ac_item" ;; - esac - eval "ac_val=\$$ac_var" - if test ".$ac_val" != .yes; then - ac_rc=no - break - fi -done -if test ".$ac_rc" = .yes; then - : - -ac_decision='USE_BEOSSEM' -ac_decision_msg='BeOS Semaphores' -ac_decision_USE_BEOSSEM=yes -ac_decision_USE_BEOSSEM_msg='BeOS Semaphores' - -else - : - -fi - -if test "x$apr_lock_method" != "x"; then - ac_decision="$apr_lock_method" -eval "ac_decision_msg=\"\$ac_decision_${ac_decision}_msg\"" - -fi -if test ".$ac_decision" = .; then - echo "$0:Error: decision on $ac_decision_item failed" 1>&2 - exit 1 -else - if test ".$ac_decision_msg" = .; then - ac_decision_msg="$ac_decision" - fi - cat >>confdefs.h <<_ACEOF -#define ${ac_decision_item} 1 -_ACEOF - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: decision on $ac_decision_item... $ac_decision_msg" >&5 -$as_echo "decision on $ac_decision_item... $ac_decision_msg" >&6; } -fi - -cat >>confdefs.h <<_ACEOF -#define $ac_decision 1 -_ACEOF - - -flockser="0" -sysvser="0" -posixser="0" -procpthreadser="0" -fcntlser="0" -case $ac_decision in - USE_FLOCK_SERIALIZE ) - flockser="1" - ;; - USE_FCNTL_SERIALIZE ) - fcntlser="1" - ;; - USE_SYSVSEM_SERIALIZE ) - sysvser="1" - ;; - USE_POSIXSEM_SERIALIZE ) - posixser="1" - ;; - USE_PROC_PTHREAD_SERIALIZE ) - procpthreadser="1" - ;; - USE_BEOSSEM ) - beossem="1" - ;; -esac - -if test $hasfcntlser = "1"; then -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if fcntl returns EACCES when F_SETLK is already held" >&5 -$as_echo_n "checking if fcntl returns EACCES when F_SETLK is already held... " >&6; } -if test "$cross_compiling" = yes; then : - apr_fcntl_tryacquire_eacces=0 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#ifdef HAVE_STDLIB_H -#include -#endif -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif -#ifdef HAVE_SYS_WAIT_H -#include -#endif -#if defined(HAVE_UNISTD_H) -#include -#endif -#include -#include - -int fd; -struct flock proc_mutex_lock_it = {0}; -const char *fname = "conftest.fcntl"; - -int main() -{ - int rc, status;; - proc_mutex_lock_it.l_whence = SEEK_SET; /* from current point */ - proc_mutex_lock_it.l_type = F_WRLCK; /* set exclusive/write lock */ - - fd = creat(fname, S_IRWXU); - unlink(fname); - - if (rc = lockit()) { - exit(-1); - } - - if (fork()) { - wait(&status); - } - else { - return(lockit()); - } - - close(fd); - exit(WEXITSTATUS(status) != EACCES); -} - -int lockit() { - int rc; - do { - rc = fcntl(fd, F_SETLK, &proc_mutex_lock_it); - } while ( rc < 0 && errno == EINTR); - - return (rc < 0) ? errno : 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - apr_fcntl_tryacquire_eacces=1 -else - apr_fcntl_tryacquire_eacces=0 -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi - -if test "$apr_fcntl_tryacquire_eacces" = "1"; then - -$as_echo "#define FCNTL_TRYACQUIRE_EACCES 1" >>confdefs.h - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - - - - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if all interprocess locks affect threads" >&5 -$as_echo_n "checking if all interprocess locks affect threads... " >&6; } -if test "x$apr_process_lock_is_global" = "xyes"; then - proclockglobal="1" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - proclockglobal="0" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if POSIX sems affect threads in the same process" >&5 -$as_echo_n "checking if POSIX sems affect threads in the same process... " >&6; } -if test "x$apr_posixsem_is_global" = "xyes"; then - -$as_echo "#define POSIXSEM_IS_GLOBAL 1" >>confdefs.h - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if SysV sems affect threads in the same process" >&5 -$as_echo_n "checking if SysV sems affect threads in the same process... " >&6; } -if test "x$apr_sysvsem_is_global" = "xyes"; then - -$as_echo "#define SYSVSEM_IS_GLOBAL 1" >>confdefs.h - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if fcntl locks affect threads in the same process" >&5 -$as_echo_n "checking if fcntl locks affect threads in the same process... " >&6; } -if test "x$apr_fcntl_is_global" = "xyes"; then - -$as_echo "#define FCNTL_IS_GLOBAL 1" >>confdefs.h - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if flock locks affect threads in the same process" >&5 -$as_echo_n "checking if flock locks affect threads in the same process... " >&6; } -if test "x$apr_flock_is_global" = "xyes"; then - -$as_echo "#define FLOCK_IS_GLOBAL 1" >>confdefs.h - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for entropy source" >&5 -$as_echo_n "checking for entropy source... " >&6; } - -why_no_rand="" - - -# Check whether --with-egd was given. -if test "${with_egd+set}" = set; then : - withval=$with_egd; -$as_echo "#define HAVE_EGD 1" >>confdefs.h - - if test "$withval" = "yes"; then - -cat >>confdefs.h <<_ACEOF -#define EGD_DEFAULT_SOCKET "/var/run/egd-pool","/dev/egd-pool","/etc/egd-pool","/etc/entropy" -_ACEOF - - else - cat >>confdefs.h <<_ACEOF -#define EGD_DEFAULT_SOCKET "$withval" -_ACEOF - - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: EGD-compatible daemon" >&5 -$as_echo "EGD-compatible daemon" >&6; } - rand="1" - -fi - - -if test "$rand" != "1"; then - -# Check whether --with-devrandom was given. -if test "${with_devrandom+set}" = set; then : - withval=$with_devrandom; apr_devrandom="$withval" -else - apr_devrandom="yes" -fi - - - if test "$apr_devrandom" = "yes"; then - # /dev/random on OpenBSD doesn't provide random data, so - # prefer /dev/arandom, which does; see random(4). - for f in /dev/arandom /dev/urandom /dev/random; do - if test -r $f; then - apr_devrandom=$f - rand=1 - break - fi - done - elif test "$apr_devrandom" != "no"; then - if test -r "$apr_devrandom"; then - rand="1" - else - as_fn_error $? "$apr_devrandom not found or unreadable." "$LINENO" 5 - fi - fi - - if test "$rand" = "1"; then - case $host in - *os390) - if test $os_version -lt 1700; then - rand="0" - why_no_rand=" ($apr_devrandom unusable on z/OS before V1R7)" - fi - ;; - esac - fi - - if test "$rand" = "1"; then - -cat >>confdefs.h <<_ACEOF -#define DEV_RANDOM "$apr_devrandom" -_ACEOF - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_devrandom" >&5 -$as_echo "$apr_devrandom" >&6; } - fi -fi - -if test "$rand" != "1"; then - case $host in - # we have built in support for OS/2 - *-os2*) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: Using OS/2 builtin random" >&5 -$as_echo "Using OS/2 builtin random" >&6; } - rand="1" - ;; - *) - if test "$rand" != "1"; then - if test "$ac_cv_lib_truerand_main" = "yes"; then - -$as_echo "#define HAVE_TRUERAND 1" >>confdefs.h - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: truerand" >&5 -$as_echo "truerand" >&6; } - rand="1" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found$why_no_rand" >&5 -$as_echo "not found$why_no_rand" >&6; } - rand="0" - fi - fi - ;; - esac -fi - - - -echo "${nl}Checking for File Info Support..." -ac_fn_c_check_member "$LINENO" "struct stat" "st_blocks" "ac_cv_member_struct_stat_st_blocks" " -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif -#ifdef HAVE_UNISTD_H -#include -#endif -" -if test "x$ac_cv_member_struct_stat_st_blocks" = xyes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_STAT_ST_BLOCKS 1 -_ACEOF - - -fi -ac_fn_c_check_member "$LINENO" "struct stat" "st_atimensec" "ac_cv_member_struct_stat_st_atimensec" " -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif -#ifdef HAVE_UNISTD_H -#include -#endif -" -if test "x$ac_cv_member_struct_stat_st_atimensec" = xyes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_STAT_ST_ATIMENSEC 1 -_ACEOF - - -fi -ac_fn_c_check_member "$LINENO" "struct stat" "st_ctimensec" "ac_cv_member_struct_stat_st_ctimensec" " -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif -#ifdef HAVE_UNISTD_H -#include -#endif -" -if test "x$ac_cv_member_struct_stat_st_ctimensec" = xyes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_STAT_ST_CTIMENSEC 1 -_ACEOF - - -fi -ac_fn_c_check_member "$LINENO" "struct stat" "st_mtimensec" "ac_cv_member_struct_stat_st_mtimensec" " -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif -#ifdef HAVE_UNISTD_H -#include -#endif -" -if test "x$ac_cv_member_struct_stat_st_mtimensec" = xyes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_STAT_ST_MTIMENSEC 1 -_ACEOF - - -fi -ac_fn_c_check_member "$LINENO" "struct stat" "st_atim.tv_nsec" "ac_cv_member_struct_stat_st_atim_tv_nsec" " -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif -#ifdef HAVE_UNISTD_H -#include -#endif -" -if test "x$ac_cv_member_struct_stat_st_atim_tv_nsec" = xyes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC 1 -_ACEOF - - -fi -ac_fn_c_check_member "$LINENO" "struct stat" "st_ctim.tv_nsec" "ac_cv_member_struct_stat_st_ctim_tv_nsec" " -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif -#ifdef HAVE_UNISTD_H -#include -#endif -" -if test "x$ac_cv_member_struct_stat_st_ctim_tv_nsec" = xyes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_STAT_ST_CTIM_TV_NSEC 1 -_ACEOF - - -fi -ac_fn_c_check_member "$LINENO" "struct stat" "st_mtim.tv_nsec" "ac_cv_member_struct_stat_st_mtim_tv_nsec" " -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif -#ifdef HAVE_UNISTD_H -#include -#endif -" -if test "x$ac_cv_member_struct_stat_st_mtim_tv_nsec" = xyes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1 -_ACEOF - - -fi -ac_fn_c_check_member "$LINENO" "struct stat" "st_atime_n" "ac_cv_member_struct_stat_st_atime_n" " -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif -#ifdef HAVE_UNISTD_H -#include -#endif -" -if test "x$ac_cv_member_struct_stat_st_atime_n" = xyes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_STAT_ST_ATIME_N 1 -_ACEOF - - -fi -ac_fn_c_check_member "$LINENO" "struct stat" "st_ctime_n" "ac_cv_member_struct_stat_st_ctime_n" " -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif -#ifdef HAVE_UNISTD_H -#include -#endif -" -if test "x$ac_cv_member_struct_stat_st_ctime_n" = xyes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_STAT_ST_CTIME_N 1 -_ACEOF - - -fi -ac_fn_c_check_member "$LINENO" "struct stat" "st_mtime_n" "ac_cv_member_struct_stat_st_mtime_n" " -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif -#ifdef HAVE_UNISTD_H -#include -#endif -" -if test "x$ac_cv_member_struct_stat_st_mtime_n" = xyes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_STAT_ST_MTIME_N 1 -_ACEOF - - -fi - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inode member of struct dirent" >&5 -$as_echo_n "checking for inode member of struct dirent... " >&6; } -if ${apr_cv_dirent_inode+:} false; then : - $as_echo_n "(cached) " >&6 -else - -apr_cv_dirent_inode=no -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include - -int -main () -{ - -#ifdef d_ino -#undef d_ino -#endif -struct dirent de; de.d_fileno; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - apr_cv_dirent_inode=d_fileno -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -if test "$apr_cv_dirent_inode" = "no"; then -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include - -int -main () -{ - -#ifdef d_fileno -#undef d_fileno -#endif -struct dirent de; de.d_ino; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - apr_cv_dirent_inode=d_ino -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_dirent_inode" >&5 -$as_echo "$apr_cv_dirent_inode" >&6; } -if test "$apr_cv_dirent_inode" != "no"; then - -cat >>confdefs.h <<_ACEOF -#define DIRENT_INODE $apr_cv_dirent_inode -_ACEOF - -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for file type member of struct dirent" >&5 -$as_echo_n "checking for file type member of struct dirent... " >&6; } -if ${apr_cv_dirent_type+:} false; then : - $as_echo_n "(cached) " >&6 -else - -apr_cv_dirent_type=no -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include - -int -main () -{ - -struct dirent de; de.d_type = DT_REG; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - apr_cv_dirent_type=d_type -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_dirent_type" >&5 -$as_echo "$apr_cv_dirent_type" >&6; } -if test "$apr_cv_dirent_type" != "no"; then - -cat >>confdefs.h <<_ACEOF -#define DIRENT_TYPE $apr_cv_dirent_type -_ACEOF - -fi - - -echo "${nl}Checking for OS UUID Support..." - -for ac_header in uuid.h uuid/uuid.h sys/uuid.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - break -fi - -done - - -apr_revert_save_LIBS=$LIBS - -# Prefer the flavor(s) that live in libc; -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing uuid_create" >&5 -$as_echo_n "checking for library containing uuid_create... " >&6; } -if ${ac_cv_search_uuid_create+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char uuid_create (); -int -main () -{ -return uuid_create (); - ; - return 0; -} -_ACEOF -for ac_lib in '' uuid; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_uuid_create=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_uuid_create+:} false; then : - break -fi -done -if ${ac_cv_search_uuid_create+:} false; then : - -else - ac_cv_search_uuid_create=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_uuid_create" >&5 -$as_echo "$ac_cv_search_uuid_create" >&6; } -ac_res=$ac_cv_search_uuid_create -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing uuid_generate" >&5 -$as_echo_n "checking for library containing uuid_generate... " >&6; } -if ${ac_cv_search_uuid_generate+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char uuid_generate (); -int -main () -{ -return uuid_generate (); - ; - return 0; -} -_ACEOF -for ac_lib in '' uuid; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_uuid_generate=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_uuid_generate+:} false; then : - break -fi -done -if ${ac_cv_search_uuid_generate+:} false; then : - -else - ac_cv_search_uuid_generate=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_uuid_generate" >&5 -$as_echo "$ac_cv_search_uuid_generate" >&6; } -ac_res=$ac_cv_search_uuid_generate -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -fi - -if test "$ac_cv_search_uuid_create" = "none required" -o \ - "$ac_cv_search_uuid_generate" = "none required"; then - LIBS=$apr_revert_save_LIBS -fi - -for ac_func in uuid_create uuid_generate -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for os uuid usability" >&5 -$as_echo_n "checking for os uuid usability... " >&6; } -if ${apr_cv_osuuid+:} false; then : - $as_echo_n "(cached) " >&6 -else - -# Ensure this test closely mirrors misc/unix/rand.c! -uuid_includes=" -#if defined(HAVE_SYS_TYPES_H) -#include -#endif -#if defined(HAVE_UNISTD_H) -#include -#endif -#if defined(HAVE_UUID_H) -#include -#elif defined(HAVE_UUID_UUID_H) -#include -#elif defined(HAVE_SYS_UUID_H) -#include -#endif -" - apr_cv_osuuid=no - if test $ac_cv_func_uuid_create = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$uuid_includes -int -main () -{ - - uuid_t g; - uint32_t s; - uuid_create(&g, &s); - if (s == uuid_s_ok) s = 0; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - apr_cv_osuuid=yes -else - apr_cv_func_uuid_create=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - fi - if test $ac_cv_func_uuid_generate = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$uuid_includes -int -main () -{ - - uuid_t g; - uuid_generate(g); - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - apr_cv_osuuid=yes -else - apr_cv_func_uuid_generate=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_osuuid" >&5 -$as_echo "$apr_cv_osuuid" >&6; } - -if test $apr_cv_osuuid = yes; then - osuuid="1" -else - osuuid="0" - LIBS=$apr_revert_save_LIBS -fi - - - -echo "${nl}Checking for Time Support..." - -ac_fn_c_check_member "$LINENO" "struct tm" "tm_gmtoff" "ac_cv_member_struct_tm_tm_gmtoff" " -#include -#include -" -if test "x$ac_cv_member_struct_tm_tm_gmtoff" = xyes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_TM_TM_GMTOFF 1 -_ACEOF - - -fi -ac_fn_c_check_member "$LINENO" "struct tm" "__tm_gmtoff" "ac_cv_member_struct_tm___tm_gmtoff" " -#include -#include -" -if test "x$ac_cv_member_struct_tm___tm_gmtoff" = xyes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_TM___TM_GMTOFF 1 -_ACEOF - - -fi - - -echo "${nl}Checking for Networking support..." - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for type in_addr" >&5 -$as_echo_n "checking for type in_addr... " >&6; } -if ${ac_cv_type_in_addr+:} false; then : - $as_echo_n "(cached) " >&6 -else - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_WINSOCK2_H -#include -#endif - -int -main () -{ - - struct in_addr arg; - arg.s_addr = htonl(INADDR_ANY); - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_type_in_addr="yes" -else - -ac_cv_type_in_addr="no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_in_addr" >&5 -$as_echo "$ac_cv_type_in_addr" >&6; } - -if test "$ac_cv_type_in_addr" = "yes"; then - have_in_addr="1" -else - have_in_addr="0" -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if fd == socket on this platform" >&5 -$as_echo_n "checking if fd == socket on this platform... " >&6; } -if test "x$file_as_socket" != "x0" ; then - file_as_socket="1"; - echo "yes" -else - echo "no" -fi - - - - -if test "$ac_cv_func_poll $file_as_socket" = "yes 1"; then - -$as_echo "#define WAITIO_USES_POLL 1" >>confdefs.h - -fi - -# Check the types only if we have gethostbyname_r -if test "$ac_cv_func_gethostbyname_r" = "yes"; then - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking style of gethostbyname_r routine" >&5 -$as_echo_n "checking style of gethostbyname_r routine... " >&6; } -if ${ac_cv_gethostbyname_r_style+:} false; then : - $as_echo_n "(cached) " >&6 -else - apr_save_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS $CFLAGS_WARN" - if test "$ac_cv_c_compiler_gnu" = "yes"; then - CFLAGS="$CFLAGS -Werror" - fi - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include "confdefs.h" - - -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_ARPA_INET_H -#include -#endif -#ifdef HAVE_NETDB_H -#include -#endif -#ifdef HAVE_STDLIB_H -#include -#endif - - int main(int argc, const char *const *argv) { - -int tmp = gethostbyname_r((const char *) 0, (struct hostent *) 0, - (char *) 0, 0, (struct hostent **) 0, &tmp); -/* use tmp to suppress the warning */ -tmp=0; - - return 0; } - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_gethostbyname_r_style=glibc2 -else - ac_cv_gethostbyname_r_style=none -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$apr_save_CFLAGS - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_gethostbyname_r_style" >&5 -$as_echo "$ac_cv_gethostbyname_r_style" >&6; } - -if test "$ac_cv_gethostbyname_r_style" = "glibc2"; then - -$as_echo "#define GETHOSTBYNAME_R_GLIBC2 1" >>confdefs.h - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking 3rd argument to the gethostbyname_r routines" >&5 -$as_echo_n "checking 3rd argument to the gethostbyname_r routines... " >&6; } -if ${ac_cv_gethostbyname_r_arg+:} false; then : - $as_echo_n "(cached) " >&6 -else - apr_save_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS $CFLAGS_WARN" - if test "$ac_cv_c_compiler_gnu" = "yes"; then - CFLAGS="$CFLAGS -Werror" - fi - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include "confdefs.h" - - -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_ARPA_INET_H -#include -#endif -#ifdef HAVE_NETDB_H -#include -#endif -#ifdef HAVE_STDLIB_H -#include -#endif - - int main(int argc, const char *const *argv) { - -int tmp = gethostbyname_r((const char *) 0, (struct hostent *) 0, - (struct hostent_data *) 0); -/* use tmp to suppress the warning */ -tmp=0; - - return 0; } - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_gethostbyname_r_arg=hostent_data -else - ac_cv_gethostbyname_r_arg=char -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$apr_save_CFLAGS - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_gethostbyname_r_arg" >&5 -$as_echo "$ac_cv_gethostbyname_r_arg" >&6; } - -if test "$ac_cv_gethostbyname_r_arg" = "hostent_data"; then - -$as_echo "#define GETHOSTBYNAME_R_HOSTENT_DATA 1" >>confdefs.h - -fi - -fi - -# Check the types only if we have getservbyname_r -if test "$ac_cv_func_getservbyname_r" = "yes"; then - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking style of getservbyname_r routine" >&5 -$as_echo_n "checking style of getservbyname_r routine... " >&6; } -if ${ac_cv_getservbyname_r_style+:} false; then : - $as_echo_n "(cached) " >&6 -else - -apr_save_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS $CFLAGS_WARN" - if test "$ac_cv_c_compiler_gnu" = "yes"; then - CFLAGS="$CFLAGS -Werror" - fi - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include "confdefs.h" - - -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_ARPA_INET_H -#include -#endif -#ifdef HAVE_NETDB_H -#include -#endif -#ifdef HAVE_STDLIB_H -#include -#endif - - int main(int argc, const char *const *argv) { - -int tmp = getservbyname_r((const char *) 0, (const char *) 0, - (struct servent *) 0, (char *) 0, 0, - (struct servent **) 0); -/* use tmp to suppress the warning */ -tmp=0; - - return 0; } - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_getservbyname_r_style=glibc2 -else - ac_cv_getservbyname_r_style=none -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$apr_save_CFLAGS - - -if test "$ac_cv_getservbyname_r_style" = "none"; then - apr_save_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS $CFLAGS_WARN" - if test "$ac_cv_c_compiler_gnu" = "yes"; then - CFLAGS="$CFLAGS -Werror" - fi - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include "confdefs.h" - - - #ifdef HAVE_SYS_TYPES_H - #include - #endif - #ifdef HAVE_NETINET_IN_H - #include - #endif - #ifdef HAVE_ARPA_INET_H - #include - #endif - #ifdef HAVE_NETDB_H - #include - #endif - #ifdef HAVE_STDLIB_H - #include - #endif - - int main(int argc, const char *const *argv) { - - struct servent *tmp = getservbyname_r((const char *) 0, (const char *) 0, - (struct servent *) 0, (char *) 0, 0); - /* use tmp to suppress the warning */ - tmp=NULL; - - return 0; } - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_getservbyname_r_style=solaris -else - ac_cv_getservbyname_r_style=none -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$apr_save_CFLAGS - -fi - -if test "$ac_cv_getservbyname_r_style" = "none"; then - apr_save_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS $CFLAGS_WARN" - if test "$ac_cv_c_compiler_gnu" = "yes"; then - CFLAGS="$CFLAGS -Werror" - fi - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include "confdefs.h" - - - #ifdef HAVE_SYS_TYPES_H - #include - #endif - #ifdef HAVE_NETINET_IN_H - #include - #endif - #ifdef HAVE_ARPA_INET_H - #include - #endif - #ifdef HAVE_NETDB_H - #include - #endif - #ifdef HAVE_STDLIB_H - #include - #endif - - int main(int argc, const char *const *argv) { - - int tmp = getservbyname_r((const char *) 0, (const char *) 0, - (struct servent *) 0, (struct servent_data *) 0); - /* use tmp to suppress the warning */ - tmp=0; - - return 0; } - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_getservbyname_r_style=osf1 -else - ac_cv_getservbyname_r_style=none -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$apr_save_CFLAGS - -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_getservbyname_r_style" >&5 -$as_echo "$ac_cv_getservbyname_r_style" >&6; } - -if test "$ac_cv_getservbyname_r_style" = "glibc2"; then - -$as_echo "#define GETSERVBYNAME_R_GLIBC2 1" >>confdefs.h - -elif test "$ac_cv_getservbyname_r_style" = "solaris"; then - -$as_echo "#define GETSERVBYNAME_R_SOLARIS 1" >>confdefs.h - -elif test "$ac_cv_getservbyname_r_style" = "osf1"; then - -$as_echo "#define GETSERVBYNAME_R_OSF1 1" >>confdefs.h - -fi - -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if TCP_NODELAY setting is inherited from listening sockets" >&5 -$as_echo_n "checking if TCP_NODELAY setting is inherited from listening sockets... " >&6; } -if ${ac_cv_tcp_nodelay_inherited+:} false; then : - $as_echo_n "(cached) " >&6 -else - - if test "$cross_compiling" = yes; then : - - ac_cv_tcp_nodelay_inherited="yes" - -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_SOCKET_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_NETINET_TCP_H -#include -#endif -#ifndef HAVE_SOCKLEN_T -typedef int socklen_t; -#endif -int main(void) { - int listen_s, connected_s, client_s; - int listen_port, rc; - struct sockaddr_in sa; - socklen_t sa_len; - socklen_t option_len; - int option; - - listen_s = socket(AF_INET, SOCK_STREAM, 0); - if (listen_s < 0) { - perror("socket"); - exit(1); - } - option = 1; - rc = setsockopt(listen_s, IPPROTO_TCP, TCP_NODELAY, &option, sizeof option); - if (rc < 0) { - perror("setsockopt TCP_NODELAY"); - exit(1); - } - memset(&sa, 0, sizeof sa); - sa.sin_family = AF_INET; -#ifdef BEOS - sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); -#endif - /* leave port 0 to get ephemeral */ - rc = bind(listen_s, (struct sockaddr *)&sa, sizeof sa); - if (rc < 0) { - perror("bind for ephemeral port"); - exit(1); - } - /* find ephemeral port */ - sa_len = sizeof(sa); - rc = getsockname(listen_s, (struct sockaddr *)&sa, &sa_len); - if (rc < 0) { - perror("getsockname"); - exit(1); - } - listen_port = sa.sin_port; - rc = listen(listen_s, 5); - if (rc < 0) { - perror("listen"); - exit(1); - } - client_s = socket(AF_INET, SOCK_STREAM, 0); - if (client_s < 0) { - perror("socket"); - exit(1); - } - memset(&sa, 0, sizeof sa); - sa.sin_family = AF_INET; - sa.sin_port = listen_port; -#ifdef BEOS - sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); -#endif - /* leave sin_addr all zeros to use loopback */ - rc = connect(client_s, (struct sockaddr *)&sa, sizeof sa); - if (rc < 0) { - perror("connect"); - exit(1); - } - sa_len = sizeof sa; - connected_s = accept(listen_s, (struct sockaddr *)&sa, &sa_len); - if (connected_s < 0) { - perror("accept"); - exit(1); - } - option_len = sizeof option; - rc = getsockopt(connected_s, IPPROTO_TCP, TCP_NODELAY, &option, &option_len); - if (rc < 0) { - perror("getsockopt"); - exit(1); - } - if (!option) { - fprintf(stderr, "TCP_NODELAY is not set in the child.\n"); - exit(1); - } - return 0; -} - -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - - ac_cv_tcp_nodelay_inherited="yes" - -else - - ac_cv_tcp_nodelay_inherited="no" - -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_tcp_nodelay_inherited" >&5 -$as_echo "$ac_cv_tcp_nodelay_inherited" >&6; } -if test "$ac_cv_tcp_nodelay_inherited" = "yes"; then - tcp_nodelay_inherited=1 -else - tcp_nodelay_inherited=0 -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if O_NONBLOCK setting is inherited from listening sockets" >&5 -$as_echo_n "checking if O_NONBLOCK setting is inherited from listening sockets... " >&6; } -if ${ac_cv_o_nonblock_inherited+:} false; then : - $as_echo_n "(cached) " >&6 -else - - if test "$cross_compiling" = yes; then : - - ac_cv_o_nonblock_inherited="yes" - -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_SOCKET_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_NETINET_TCP_H -#include -#endif -#ifndef HAVE_SOCKLEN_T -typedef int socklen_t; -#endif -#ifdef HAVE_FCNTL_H -#include -#endif -int main(void) { - int listen_s, connected_s, client_s; - int listen_port, rc; - struct sockaddr_in sa; - socklen_t sa_len; - - listen_s = socket(AF_INET, SOCK_STREAM, 0); - if (listen_s < 0) { - perror("socket"); - exit(1); - } - memset(&sa, 0, sizeof sa); - sa.sin_family = AF_INET; -#ifdef BEOS - sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); -#endif - /* leave port 0 to get ephemeral */ - rc = bind(listen_s, (struct sockaddr *)&sa, sizeof sa); - if (rc < 0) { - perror("bind for ephemeral port"); - exit(1); - } - /* find ephemeral port */ - sa_len = sizeof(sa); - rc = getsockname(listen_s, (struct sockaddr *)&sa, &sa_len); - if (rc < 0) { - perror("getsockname"); - exit(1); - } - listen_port = sa.sin_port; - rc = listen(listen_s, 5); - if (rc < 0) { - perror("listen"); - exit(1); - } - rc = fcntl(listen_s, F_SETFL, O_NONBLOCK); - if (rc < 0) { - perror("fcntl(F_SETFL)"); - exit(1); - } - client_s = socket(AF_INET, SOCK_STREAM, 0); - if (client_s < 0) { - perror("socket"); - exit(1); - } - memset(&sa, 0, sizeof sa); - sa.sin_family = AF_INET; - sa.sin_port = listen_port; -#ifdef BEOS - sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); -#endif - /* leave sin_addr all zeros to use loopback */ - rc = connect(client_s, (struct sockaddr *)&sa, sizeof sa); - if (rc < 0) { - perror("connect"); - exit(1); - } - sa_len = sizeof sa; - connected_s = accept(listen_s, (struct sockaddr *)&sa, &sa_len); - if (connected_s < 0) { - perror("accept"); - exit(1); - } - rc = fcntl(connected_s, F_GETFL, 0); - if (rc < 0) { - perror("fcntl(F_GETFL)"); - exit(1); - } - if (!(rc & O_NONBLOCK)) { - fprintf(stderr, "O_NONBLOCK is not set in the child.\n"); - exit(1); - } - return 0; -} - -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - - ac_cv_o_nonblock_inherited="yes" - -else - - ac_cv_o_nonblock_inherited="no" - -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_o_nonblock_inherited" >&5 -$as_echo "$ac_cv_o_nonblock_inherited" >&6; } -if test "$ac_cv_o_nonblock_inherited" = "yes"; then - o_nonblock_inherited=1 -else - o_nonblock_inherited=0 -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether TCP_NODELAY and TCP_CORK can both be enabled" >&5 -$as_echo_n "checking whether TCP_NODELAY and TCP_CORK can both be enabled... " >&6; } -if ${apr_cv_tcp_nodelay_with_cork+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run test program while cross compiling -See \`config.log' for more details" "$LINENO" 5; } -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_SOCKET_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_NETINET_TCP_H -#include -#endif -#include -#include - -int -main () -{ - - int fd, flag, rc; - - fd = socket(AF_INET, SOCK_STREAM, 0); - if (fd < 0) { - exit(1); - } - - flag = 1; - rc = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof flag); - if (rc < 0) { - perror("setsockopt TCP_NODELAY"); - exit(2); - } - - flag = 1; - rc = setsockopt(fd, IPPROTO_TCP, TCP_CORK, &flag, sizeof flag); - if (rc < 0) { - perror("setsockopt TCP_CORK"); - exit(3); - } - - exit(0); - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - apr_cv_tcp_nodelay_with_cork=yes -else - apr_cv_tcp_nodelay_with_cork=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_tcp_nodelay_with_cork" >&5 -$as_echo "$apr_cv_tcp_nodelay_with_cork" >&6; } - -if test "$apr_cv_tcp_nodelay_with_cork" = "yes"; then - -$as_echo "#define HAVE_TCP_NODELAY_WITH_CORK 1" >>confdefs.h - -fi - - -# Look for a way of corking TCP... - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for TCP_CORK in netinet/tcp.h" >&5 -$as_echo_n "checking for TCP_CORK in netinet/tcp.h... " >&6; } -if ${ac_cv_define_TCP_CORK+:} false; then : - $as_echo_n "(cached) " >&6 -else - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#ifdef TCP_CORK -YES_IS_DEFINED -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "YES_IS_DEFINED" >/dev/null 2>&1; then : - ac_cv_define_TCP_CORK=yes -else - ac_cv_define_TCP_CORK=no -fi -rm -f conftest* - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_define_TCP_CORK" >&5 -$as_echo "$ac_cv_define_TCP_CORK" >&6; } - if test "$ac_cv_define_TCP_CORK" = "yes"; then - -$as_echo "#define HAVE_TCP_CORK 1" >>confdefs.h - - fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for TCP_NOPUSH in netinet/tcp.h" >&5 -$as_echo_n "checking for TCP_NOPUSH in netinet/tcp.h... " >&6; } -if ${ac_cv_define_TCP_NOPUSH+:} false; then : - $as_echo_n "(cached) " >&6 -else - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#ifdef TCP_NOPUSH -YES_IS_DEFINED -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "YES_IS_DEFINED" >/dev/null 2>&1; then : - ac_cv_define_TCP_NOPUSH=yes -else - ac_cv_define_TCP_NOPUSH=no -fi -rm -f conftest* - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_define_TCP_NOPUSH" >&5 -$as_echo "$ac_cv_define_TCP_NOPUSH" >&6; } - if test "$ac_cv_define_TCP_NOPUSH" = "yes"; then - -$as_echo "#define HAVE_TCP_NOPUSH 1" >>confdefs.h - - fi - -apr_tcp_nopush_flag="0" -have_corkable_tcp="0" -if test "x$ac_cv_define_TCP_CORK" = "xyes"; then - apr_tcp_nopush_flag="TCP_CORK" - have_corkable_tcp="1" -else - case $host in - *linux*) - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#ifdef TCP_CORK -yes -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "yes" >/dev/null 2>&1; then : - - apr_tcp_nopush_flag="3" - have_corkable_tcp="1" - -fi -rm -f conftest* - - ;; - *) - ;; - esac -fi -if test "x$ac_cv_define_TCP_NOPUSH" = "xyes"; then - apr_tcp_nopush_flag="TCP_NOPUSH" - have_corkable_tcp="1" -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SO_ACCEPTFILTER in sys/socket.h" >&5 -$as_echo_n "checking for SO_ACCEPTFILTER in sys/socket.h... " >&6; } -if ${ac_cv_define_SO_ACCEPTFILTER+:} false; then : - $as_echo_n "(cached) " >&6 -else - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#ifdef SO_ACCEPTFILTER -YES_IS_DEFINED -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "YES_IS_DEFINED" >/dev/null 2>&1; then : - ac_cv_define_SO_ACCEPTFILTER=yes -else - ac_cv_define_SO_ACCEPTFILTER=no -fi -rm -f conftest* - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_define_SO_ACCEPTFILTER" >&5 -$as_echo "$ac_cv_define_SO_ACCEPTFILTER" >&6; } - if test "$ac_cv_define_SO_ACCEPTFILTER" = "yes"; then - -$as_echo "#define HAVE_SO_ACCEPTFILTER 1" >>confdefs.h - - fi - -if test "x$ac_cv_define_SO_ACCEPTFILTER" = "xyes"; then - acceptfilter="1" -else - acceptfilter="0" -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether SCTP is supported" >&5 -$as_echo_n "checking whether SCTP is supported... " >&6; } -if ${apr_cv_sctp+:} false; then : - $as_echo_n "(cached) " >&6 -else - - if test "$cross_compiling" = yes; then : - apr_cv_sctp=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_SOCKET_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_NETINET_SCTP_H -#include -#endif -#ifdef HAVE_NETINET_SCTP_UIO_H -#include -#endif -#include -int main(void) { - int s, opt = 1; - if ((s = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP)) < 0) - exit(1); - if (setsockopt(s, IPPROTO_SCTP, SCTP_NODELAY, &opt, sizeof(int)) < 0) - exit(2); - exit(0); -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - apr_cv_sctp=yes -else - apr_cv_sctp=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_sctp" >&5 -$as_echo "$apr_cv_sctp" >&6; } - -if test "$apr_cv_sctp" = "yes"; then - have_sctp=1 -else - have_sctp=0 -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct ip_mreq" >&5 -$as_echo_n "checking for struct ip_mreq... " >&6; } -if ${apr_cv_struct_ipmreq+:} false; then : - $as_echo_n "(cached) " >&6 -else - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include - -int -main () -{ - - struct ip_mreq mip; - mip.imr_interface.s_addr = INADDR_ANY; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - apr_cv_struct_ipmreq=yes -else - apr_cv_struct_ipmreq=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_struct_ipmreq" >&5 -$as_echo "$apr_cv_struct_ipmreq" >&6; } - -if test $apr_cv_struct_ipmreq = yes; then - -$as_echo "#define HAVE_STRUCT_IPMREQ 1" >>confdefs.h - -fi - - - - - - - -for ac_func in set_h_errno -do : - ac_fn_c_check_func "$LINENO" "set_h_errno" "ac_cv_func_set_h_errno" -if test "x$ac_cv_func_set_h_errno" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_SET_H_ERRNO 1 -_ACEOF - -fi -done - - -echo "${nl}Checking for IPv6 Networking support..." - -# Check whether --enable-ipv6 was given. -if test "${enable_ipv6+set}" = set; then : - enableval=$enable_ipv6; if test "$enableval" = "no"; then - user_disabled_ipv6=1 - fi -else - user_disabled_ipv6=0 -fi - - -case $host in - *) - broken_ipv6=0 -esac - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing getaddrinfo" >&5 -$as_echo_n "checking for library containing getaddrinfo... " >&6; } -if ${ac_cv_search_getaddrinfo+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char getaddrinfo (); -int -main () -{ -return getaddrinfo (); - ; - return 0; -} -_ACEOF -for ac_lib in '' socket inet6; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_getaddrinfo=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_getaddrinfo+:} false; then : - break -fi -done -if ${ac_cv_search_getaddrinfo+:} false; then : - -else - ac_cv_search_getaddrinfo=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_getaddrinfo" >&5 -$as_echo "$ac_cv_search_getaddrinfo" >&6; } -ac_res=$ac_cv_search_getaddrinfo -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gai_strerror" >&5 -$as_echo_n "checking for library containing gai_strerror... " >&6; } -if ${ac_cv_search_gai_strerror+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char gai_strerror (); -int -main () -{ -return gai_strerror (); - ; - return 0; -} -_ACEOF -for ac_lib in '' socket inet6; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_gai_strerror=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_gai_strerror+:} false; then : - break -fi -done -if ${ac_cv_search_gai_strerror+:} false; then : - -else - ac_cv_search_gai_strerror=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gai_strerror" >&5 -$as_echo "$ac_cv_search_gai_strerror" >&6; } -ac_res=$ac_cv_search_gai_strerror -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing getnameinfo" >&5 -$as_echo_n "checking for library containing getnameinfo... " >&6; } -if ${ac_cv_search_getnameinfo+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char getnameinfo (); -int -main () -{ -return getnameinfo (); - ; - return 0; -} -_ACEOF -for ac_lib in '' socket inet6; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_getnameinfo=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_getnameinfo+:} false; then : - break -fi -done -if ${ac_cv_search_getnameinfo+:} false; then : - -else - ac_cv_search_getnameinfo=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_getnameinfo" >&5 -$as_echo "$ac_cv_search_getnameinfo" >&6; } -ac_res=$ac_cv_search_getnameinfo -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -fi - -for ac_func in gai_strerror -do : - ac_fn_c_check_func "$LINENO" "gai_strerror" "ac_cv_func_gai_strerror" -if test "x$ac_cv_func_gai_strerror" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_GAI_STRERROR 1 -_ACEOF - -fi -done - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working getaddrinfo" >&5 -$as_echo_n "checking for working getaddrinfo... " >&6; } -if ${ac_cv_working_getaddrinfo+:} false; then : - $as_echo_n "(cached) " >&6 -else - - if test "$cross_compiling" = yes; then : - - ac_cv_working_getaddrinfo="yes" - -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#ifdef HAVE_NETDB_H -#include -#endif -#ifdef HAVE_STRING_H -#include -#endif -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_SOCKET_H -#include -#endif - -void main(void) { - struct addrinfo hints, *ai; - int error; - - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - error = getaddrinfo("127.0.0.1", NULL, &hints, &ai); - if (error) { - exit(1); - } - if (ai->ai_addr->sa_family != AF_INET) { - exit(1); - } - exit(0); -} - -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - - ac_cv_working_getaddrinfo="yes" - -else - - ac_cv_working_getaddrinfo="no" - -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_getaddrinfo" >&5 -$as_echo "$ac_cv_working_getaddrinfo" >&6; } -if test "$ac_cv_working_getaddrinfo" = "yes"; then - if test "$ac_cv_func_gai_strerror" != "yes"; then - ac_cv_working_getaddrinfo="no" - else - -$as_echo "#define HAVE_GETADDRINFO 1" >>confdefs.h - - fi -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for negative error codes for getaddrinfo" >&5 -$as_echo_n "checking for negative error codes for getaddrinfo... " >&6; } -if ${ac_cv_negative_eai+:} false; then : - $as_echo_n "(cached) " >&6 -else - - if test "$cross_compiling" = yes; then : - - ac_cv_negative_eai="no" - -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#ifdef HAVE_NETDB_H -#include -#endif - -void main(void) { - if (EAI_ADDRFAMILY < 0) { - exit(0); - } - exit(1); -} - -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - - ac_cv_negative_eai="yes" - -else - - ac_cv_negative_eai="no" - -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_negative_eai" >&5 -$as_echo "$ac_cv_negative_eai" >&6; } -if test "$ac_cv_negative_eai" = "yes"; then - -$as_echo "#define NEGATIVE_EAI 1" >>confdefs.h - -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working getnameinfo" >&5 -$as_echo_n "checking for working getnameinfo... " >&6; } -if ${ac_cv_working_getnameinfo+:} false; then : - $as_echo_n "(cached) " >&6 -else - - if test "$cross_compiling" = yes; then : - - ac_cv_working_getnameinfo="yes" - -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#ifdef HAVE_NETDB_H -#include -#endif -#ifdef HAVE_STRING_H -#include -#endif -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_SOCKET_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif - -void main(void) { - struct sockaddr_in sa; - char hbuf[256]; - int error; - - sa.sin_family = AF_INET; - sa.sin_port = 0; - sa.sin_addr.s_addr = inet_addr("127.0.0.1"); -#ifdef SIN6_LEN - sa.sin_len = sizeof(sa); -#endif - - error = getnameinfo((const struct sockaddr *)&sa, sizeof(sa), - hbuf, 256, NULL, 0, - NI_NUMERICHOST); - if (error) { - exit(1); - } else { - exit(0); - } -} - -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - - ac_cv_working_getnameinfo="yes" - -else - - ac_cv_working_getnameinfo="no" - -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_getnameinfo" >&5 -$as_echo "$ac_cv_working_getnameinfo" >&6; } -if test "$ac_cv_working_getnameinfo" = "yes"; then - -$as_echo "#define HAVE_GETNAMEINFO 1" >>confdefs.h - -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sockaddr_in6" >&5 -$as_echo_n "checking for sockaddr_in6... " >&6; } -if ${ac_cv_define_sockaddr_in6+:} false; then : - $as_echo_n "(cached) " >&6 -else - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif - -int -main () -{ - -struct sockaddr_in6 sa; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - ac_cv_define_sockaddr_in6=yes - -else - - ac_cv_define_sockaddr_in6=no - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_define_sockaddr_in6" >&5 -$as_echo "$ac_cv_define_sockaddr_in6" >&6; } - -if test "$ac_cv_define_sockaddr_in6" = "yes"; then - have_sockaddr_in6=1 -else - have_sockaddr_in6=0 -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sockaddr_storage" >&5 -$as_echo_n "checking for sockaddr_storage... " >&6; } -if ${apr_cv_define_sockaddr_storage+:} false; then : - $as_echo_n "(cached) " >&6 -else - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif - -int -main () -{ -struct sockaddr_storage sa; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - apr_cv_define_sockaddr_storage=yes -else - apr_cv_define_sockaddr_storage=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_define_sockaddr_storage" >&5 -$as_echo "$apr_cv_define_sockaddr_storage" >&6; } - -if test "$apr_cv_define_sockaddr_storage" = "yes"; then - have_sa_storage=1 -else - have_sa_storage=0 -fi - - - -have_ipv6="0" -if test "$user_disabled_ipv6" = 1; then - ipv6_result="no -- disabled by user" -else - if test "x$broken_ipv6" = "x0"; then - if test "x$have_sockaddr_in6" = "x1"; then - if test "x$ac_cv_working_getaddrinfo" = "xyes"; then - if test "x$ac_cv_working_getnameinfo" = "xyes"; then - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working AI_ADDRCONFIG" >&5 -$as_echo_n "checking for working AI_ADDRCONFIG... " >&6; } -if ${apr_cv_gai_addrconfig+:} false; then : - $as_echo_n "(cached) " >&6 -else - - if test "$cross_compiling" = yes; then : - apr_cv_gai_addrconfig=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#ifdef HAVE_NETDB_H -#include -#endif -#ifdef HAVE_STRING_H -#include -#endif -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_SOCKET_H -#include -#endif - -int main(int argc, char **argv) { - struct addrinfo hints, *ai; - - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_ADDRCONFIG; - return getaddrinfo("localhost", NULL, &hints, &ai) != 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - apr_cv_gai_addrconfig=yes -else - apr_cv_gai_addrconfig=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_cv_gai_addrconfig" >&5 -$as_echo "$apr_cv_gai_addrconfig" >&6; } - -if test $apr_cv_gai_addrconfig = yes; then - -$as_echo "#define HAVE_GAI_ADDRCONFIG 1" >>confdefs.h - -fi - - have_ipv6="1" - ipv6_result="yes" - else - ipv6_result="no -- no getnameinfo" - fi - else - ipv6_result="no -- no working getaddrinfo" - fi - else - ipv6_result="no -- no sockaddr_in6" - fi - else - ipv6_result="no -- the platform has known problems supporting IPv6" - fi -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if APR supports IPv6" >&5 -$as_echo_n "checking if APR supports IPv6... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ipv6_result" >&5 -$as_echo "$ipv6_result" >&6; } - - - -# hstrerror is only needed if IPv6 is not enabled, -# so getaddrinfo/gai_strerror are not used. -if test $have_ipv6 = 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing hstrerror" >&5 -$as_echo_n "checking for library containing hstrerror... " >&6; } -if ${ac_cv_search_hstrerror+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char hstrerror (); -int -main () -{ -return hstrerror (); - ; - return 0; -} -_ACEOF -for ac_lib in '' resolv; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_hstrerror=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_hstrerror+:} false; then : - break -fi -done -if ${ac_cv_search_hstrerror+:} false; then : - -else - ac_cv_search_hstrerror=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_hstrerror" >&5 -$as_echo "$ac_cv_search_hstrerror" >&6; } -ac_res=$ac_cv_search_hstrerror -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -$as_echo "#define HAVE_HSTRERROR 1" >>confdefs.h - -fi - -fi - - -for ac_header in langinfo.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "langinfo.h" "ac_cv_header_langinfo_h" "$ac_includes_default" -if test "x$ac_cv_header_langinfo_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LANGINFO_H 1 -_ACEOF - -fi - -done - -for ac_func in nl_langinfo -do : - ac_fn_c_check_func "$LINENO" "nl_langinfo" "ac_cv_func_nl_langinfo" -if test "x$ac_cv_func_nl_langinfo" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_NL_LANGINFO 1 -_ACEOF - -fi -done - - - - - if test -z "$have_unicode_fs"; then - test "x$silent" != "xyes" && echo " setting have_unicode_fs to \"0\"" - have_unicode_fs="0" - fi - - - - - if test -z "$apr_has_xthread_files"; then - test "x$silent" != "xyes" && echo " setting apr_has_xthread_files to \"0\"" - apr_has_xthread_files="0" - fi - - - - - if test -z "$apr_procattr_user_set_requires_password"; then - test "x$silent" != "xyes" && echo " setting apr_procattr_user_set_requires_password to \"0\"" - apr_procattr_user_set_requires_password="0" - fi - - - - - if test -z "$apr_thread_func"; then - test "x$silent" != "xyes" && echo " setting apr_thread_func to \"\"" - apr_thread_func="" - fi - - - - - if test -z "$apr_has_user"; then - test "x$silent" != "xyes" && echo " setting apr_has_user to \"1\"" - apr_has_user="1" - fi - - - - -echo "${nl}Restore user-defined environment settings..." - - -set X $apr_ste_save_CPPFLAGS -if test ${#} -eq 1; then - EXTRA_CPPFLAGS="$CPPFLAGS" - CPPFLAGS= -else - if test "x$apr_ste_save_CPPFLAGS" = "x$CPPFLAGS"; then - EXTRA_CPPFLAGS= - else - EXTRA_CPPFLAGS=`echo "$CPPFLAGS" | sed -e "s%${apr_ste_save_CPPFLAGS}%%"` - CPPFLAGS="$apr_ste_save_CPPFLAGS" - fi -fi -if test "x$silent" != "xyes"; then - echo " restoring CPPFLAGS to \"$CPPFLAGS\"" - echo " setting EXTRA_CPPFLAGS to \"$EXTRA_CPPFLAGS\"" -fi - - - -set X $apr_ste_save_CFLAGS -if test ${#} -eq 1; then - EXTRA_CFLAGS="$CFLAGS" - CFLAGS= -else - if test "x$apr_ste_save_CFLAGS" = "x$CFLAGS"; then - EXTRA_CFLAGS= - else - EXTRA_CFLAGS=`echo "$CFLAGS" | sed -e "s%${apr_ste_save_CFLAGS}%%"` - CFLAGS="$apr_ste_save_CFLAGS" - fi -fi -if test "x$silent" != "xyes"; then - echo " restoring CFLAGS to \"$CFLAGS\"" - echo " setting EXTRA_CFLAGS to \"$EXTRA_CFLAGS\"" -fi - - - -set X $apr_ste_save_LDFLAGS -if test ${#} -eq 1; then - EXTRA_LDFLAGS="$LDFLAGS" - LDFLAGS= -else - if test "x$apr_ste_save_LDFLAGS" = "x$LDFLAGS"; then - EXTRA_LDFLAGS= - else - EXTRA_LDFLAGS=`echo "$LDFLAGS" | sed -e "s%${apr_ste_save_LDFLAGS}%%"` - LDFLAGS="$apr_ste_save_LDFLAGS" - fi -fi -if test "x$silent" != "xyes"; then - echo " restoring LDFLAGS to \"$LDFLAGS\"" - echo " setting EXTRA_LDFLAGS to \"$EXTRA_LDFLAGS\"" -fi - - - -set X $apr_ste_save_LIBS -if test ${#} -eq 1; then - EXTRA_LIBS="$LIBS" - LIBS= -else - if test "x$apr_ste_save_LIBS" = "x$LIBS"; then - EXTRA_LIBS= - else - EXTRA_LIBS=`echo "$LIBS" | sed -e "s%${apr_ste_save_LIBS}%%"` - LIBS="$apr_ste_save_LIBS" - fi -fi -if test "x$silent" != "xyes"; then - echo " restoring LIBS to \"$LIBS\"" - echo " setting EXTRA_LIBS to \"$EXTRA_LIBS\"" -fi - - - -set X $apr_ste_save_INCLUDES -if test ${#} -eq 1; then - EXTRA_INCLUDES="$INCLUDES" - INCLUDES= -else - if test "x$apr_ste_save_INCLUDES" = "x$INCLUDES"; then - EXTRA_INCLUDES= - else - EXTRA_INCLUDES=`echo "$INCLUDES" | sed -e "s%${apr_ste_save_INCLUDES}%%"` - INCLUDES="$apr_ste_save_INCLUDES" - fi -fi -if test "x$silent" != "xyes"; then - echo " restoring INCLUDES to \"$INCLUDES\"" - echo " setting EXTRA_INCLUDES to \"$EXTRA_INCLUDES\"" -fi - - - - - - - - - - - - - - - - - - -# Use -no-install to link the test programs on all platforms -# but Darwin, where it would cause the programs to be linked -# against installed versions of libapr instead of those just -# built. -case $host in -*-apple-darwin*) LT_NO_INSTALL="" ;; -*) LT_NO_INSTALL="-no-install" ;; -esac - - -# -# BSD/OS (BSDi) needs to use a different include syntax in the Makefiles -# -case $host in -*bsdi*) - # Check whether they've installed GNU make - if make --version > /dev/null 2>&1; then - INCLUDE_RULES="include $apr_buildout/apr_rules.mk" - INCLUDE_OUTPUTS="include $apr_srcdir/build-outputs.mk" - else - # BSDi make - INCLUDE_RULES=".include \"$apr_buildout/apr_rules.mk\"" - INCLUDE_OUTPUTS=".include \"$apr_srcdir/build-outputs.mk\"" - fi - ;; -*) - INCLUDE_RULES="include $apr_buildout/apr_rules.mk" - INCLUDE_OUTPUTS="include $apr_srcdir/build-outputs.mk" - ;; -esac - - - -ac_config_files="$ac_config_files Makefile include/apr.h build/apr_rules.mk build/pkg/pkginfo apr-$APR_MAJOR_VERSION-config:apr-config.in apr.pc" - - -if test -d $srcdir/test; then - ac_config_files="$ac_config_files test/Makefile test/internal/Makefile" - -fi - -dir=include/arch/unix -test -d $dir || $MKDIR $dir - -ac_config_commands="$ac_config_commands default" - - -cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, we kill variables containing newlines. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -( - for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - - (set) 2>&1 | - case $as_nl`(ac_space=' '; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes: double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \. - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; #( - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) | - sed ' - /^ac_cv_env_/b end - t clear - :clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ - t end - s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - :end' >>confcache -if diff "$cache_file" confcache >/dev/null 2>&1; then :; else - if test -w "$cache_file"; then - if test "x$cache_file" != "x/dev/null"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 -$as_echo "$as_me: updating cache $cache_file" >&6;} - if test ! -f "$cache_file" || test -h "$cache_file"; then - cat confcache >"$cache_file" - else - case $cache_file in #( - */* | ?:*) - mv -f confcache "$cache_file"$$ && - mv -f "$cache_file"$$ "$cache_file" ;; #( - *) - mv -f confcache "$cache_file" ;; - esac - fi - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 -$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} - fi -fi -rm -f confcache - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -DEFS=-DHAVE_CONFIG_H - -ac_libobjs= -ac_ltlibobjs= -U= -for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`$as_echo "$ac_i" | sed "$ac_script"` - # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR - # will be set to the directory where LIBOBJS objects are built. - as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" - as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' -done -LIBOBJS=$ac_libobjs - -LTLIBOBJS=$ac_ltlibobjs - - - - -: "${CONFIG_STATUS=./config.status}" -ac_write_fail=0 -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} -as_write_fail=0 -cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 -#! $SHELL -# Generated by $as_me. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false - -SHELL=\${CONFIG_SHELL-$SHELL} -export SHELL -_ASEOF -cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -as_myself= -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -p' - fi -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -exec 6>&1 -## ----------------------------------- ## -## Main body of $CONFIG_STATUS script. ## -## ----------------------------------- ## -_ASEOF -test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# Save the log message, to keep $0 and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. -ac_log=" -This file was extended by $as_me, which was -generated by GNU Autoconf 2.68. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -on `(hostname || uname -n) 2>/dev/null | sed 1q` -" - -_ACEOF - -case $ac_config_files in *" -"*) set x $ac_config_files; shift; ac_config_files=$*;; -esac - -case $ac_config_headers in *" -"*) set x $ac_config_headers; shift; ac_config_headers=$*;; -esac - - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# Files that config.status was made for. -config_files="$ac_config_files" -config_headers="$ac_config_headers" -config_commands="$ac_config_commands" - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -ac_cs_usage="\ -\`$as_me' instantiates files and other configuration actions -from templates according to the current configuration. Unless the files -and actions are specified as TAGs, all are instantiated by default. - -Usage: $0 [OPTION]... [TAG]... - - -h, --help print this help, then exit - -V, --version print version number and configuration settings, then exit - --config print configuration, then exit - -q, --quiet, --silent - do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - --header=FILE[:TEMPLATE] - instantiate the configuration header FILE - -Configuration files: -$config_files - -Configuration headers: -$config_headers - -Configuration commands: -$config_commands - -Report bugs to the package provider." - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" -ac_cs_version="\\ -config.status -configured by $0, generated by GNU Autoconf 2.68, - with options \\"\$ac_cs_config\\" - -Copyright (C) 2010 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." - -ac_pwd='$ac_pwd' -srcdir='$srcdir' -INSTALL='$INSTALL' -AWK='$AWK' -test -n "\$AWK" || AWK=awk -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# The default lists apply if the user does not specify any file. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=?*) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` - ac_shift=: - ;; - --*=) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg= - ac_shift=: - ;; - *) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - esac - - case $ac_option in - # Handling of the options. - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - $as_echo "$ac_cs_version"; exit ;; - --config | --confi | --conf | --con | --co | --c ) - $as_echo "$ac_cs_config"; exit ;; - --debug | --debu | --deb | --de | --d | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - '') as_fn_error $? "missing file argument" ;; - esac - as_fn_append CONFIG_FILES " '$ac_optarg'" - ac_need_defaults=false;; - --header | --heade | --head | --hea ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - as_fn_append CONFIG_HEADERS " '$ac_optarg'" - ac_need_defaults=false;; - --he | --h) - # Conflict between --help and --header - as_fn_error $? "ambiguous option: \`$1' -Try \`$0 --help' for more information.";; - --help | --hel | -h ) - $as_echo "$ac_cs_usage"; exit ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) as_fn_error $? "unrecognized option: \`$1' -Try \`$0 --help' for more information." ;; - - *) as_fn_append ac_config_targets " $1" - ac_need_defaults=false ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -if \$ac_cs_recheck; then - set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion - shift - \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 - CONFIG_SHELL='$SHELL' - export CONFIG_SHELL - exec "\$@" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX - $as_echo "$ac_log" -} >&5 - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# -# INIT-COMMANDS -# - - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -sed_quote_subst='$sed_quote_subst' -double_quote_subst='$double_quote_subst' -delay_variable_subst='$delay_variable_subst' -AS='`$ECHO "$AS" | $SED "$delay_single_quote_subst"`' -DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' -OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' -macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' -macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' -enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' -enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' -pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' -enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' -SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' -ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' -PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' -host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' -host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' -host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' -build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' -build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' -build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' -SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' -Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' -GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' -EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' -FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' -LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' -NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' -LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' -max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' -ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' -exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' -lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' -lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' -lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' -lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' -lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' -reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' -reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' -deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' -file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' -file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' -want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' -sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' -AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' -AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' -archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' -STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' -RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' -old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' -old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' -old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' -lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' -CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' -CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' -compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' -GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' -nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' -lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' -objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' -MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' -lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' -need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' -MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' -DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' -NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' -LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' -OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' -OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' -libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' -shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' -extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' -archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' -enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' -export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' -whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' -compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' -old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' -old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' -archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' -archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' -module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' -module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' -with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' -allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' -no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' -hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' -hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' -hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' -hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' -hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' -hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' -hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' -inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' -link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' -always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' -export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' -exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' -include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' -prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' -postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' -file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' -variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' -need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' -need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' -version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' -runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' -shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' -shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' -libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' -library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' -soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' -install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' -postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' -postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' -finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' -finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' -hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' -sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' -sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`' -hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' -enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' -enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' -enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' -old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' -striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' - -LTCC='$LTCC' -LTCFLAGS='$LTCFLAGS' -compiler='$compiler_DEFAULT' - -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -\$1 -_LTECHO_EOF' -} - -# Quote evaled strings. -for var in AS \ -DLLTOOL \ -OBJDUMP \ -SHELL \ -ECHO \ -PATH_SEPARATOR \ -SED \ -GREP \ -EGREP \ -FGREP \ -LD \ -NM \ -LN_S \ -lt_SP2NL \ -lt_NL2SP \ -reload_flag \ -deplibs_check_method \ -file_magic_cmd \ -file_magic_glob \ -want_nocaseglob \ -sharedlib_from_linklib_cmd \ -AR \ -AR_FLAGS \ -archiver_list_spec \ -STRIP \ -RANLIB \ -CC \ -CFLAGS \ -compiler \ -lt_cv_sys_global_symbol_pipe \ -lt_cv_sys_global_symbol_to_cdecl \ -lt_cv_sys_global_symbol_to_c_name_address \ -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ -nm_file_list_spec \ -lt_prog_compiler_no_builtin_flag \ -lt_prog_compiler_pic \ -lt_prog_compiler_wl \ -lt_prog_compiler_static \ -lt_cv_prog_compiler_c_o \ -need_locks \ -MANIFEST_TOOL \ -DSYMUTIL \ -NMEDIT \ -LIPO \ -OTOOL \ -OTOOL64 \ -shrext_cmds \ -export_dynamic_flag_spec \ -whole_archive_flag_spec \ -compiler_needs_object \ -with_gnu_ld \ -allow_undefined_flag \ -no_undefined_flag \ -hardcode_libdir_flag_spec \ -hardcode_libdir_separator \ -exclude_expsyms \ -include_expsyms \ -file_list_spec \ -variables_saved_for_relink \ -libname_spec \ -library_names_spec \ -soname_spec \ -install_override_mode \ -finish_eval \ -old_striplib \ -striplib; do - case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in - *[\\\\\\\`\\"\\\$]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -# Double-quote double-evaled strings. -for var in reload_cmds \ -old_postinstall_cmds \ -old_postuninstall_cmds \ -old_archive_cmds \ -extract_expsyms_cmds \ -old_archive_from_new_cmds \ -old_archive_from_expsyms_cmds \ -archive_cmds \ -archive_expsym_cmds \ -module_cmds \ -module_expsym_cmds \ -export_symbols_cmds \ -prelink_cmds \ -postlink_cmds \ -postinstall_cmds \ -postuninstall_cmds \ -finish_cmds \ -sys_lib_search_path_spec \ -sys_lib_dlsearch_path_spec; do - case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in - *[\\\\\\\`\\"\\\$]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -ac_aux_dir='$ac_aux_dir' -xsi_shell='$xsi_shell' -lt_shell_append='$lt_shell_append' - -# See if we are running on zsh, and set the options which allow our -# commands through without removal of \ escapes INIT. -if test -n "\${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST -fi - - - PACKAGE='$PACKAGE' - VERSION='$VERSION' - TIMESTAMP='$TIMESTAMP' - RM='$RM' - ofile='$ofile' - - - - - -# Commands run at the beginning of config.status: -APR_SAVE_HEADERS="include/apr.h include/arch/unix/apr_private.h" -APR_MAJOR_VERSION=$APR_MAJOR_VERSION -APR_PLATFORM=$host - -for apri in \${APR_SAVE_HEADERS}; do - test -r \${apri} && mv \${apri} \${apri}.save -done - - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - -# Handling of arguments. -for ac_config_target in $ac_config_targets -do - case $ac_config_target in - "include/arch/unix/apr_private.h") CONFIG_HEADERS="$CONFIG_HEADERS include/arch/unix/apr_private.h" ;; - "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "include/apr.h") CONFIG_FILES="$CONFIG_FILES include/apr.h" ;; - "build/apr_rules.mk") CONFIG_FILES="$CONFIG_FILES build/apr_rules.mk" ;; - "build/pkg/pkginfo") CONFIG_FILES="$CONFIG_FILES build/pkg/pkginfo" ;; - "apr-$APR_MAJOR_VERSION-config") CONFIG_FILES="$CONFIG_FILES apr-$APR_MAJOR_VERSION-config:apr-config.in" ;; - "apr.pc") CONFIG_FILES="$CONFIG_FILES apr.pc" ;; - "test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;; - "test/internal/Makefile") CONFIG_FILES="$CONFIG_FILES test/internal/Makefile" ;; - "default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;; - - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; - esac -done - - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files - test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers - test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason against having it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Hook for its removal unless debugging. -# Note that there is a small window in which the directory will not be cleaned: -# after its creation but before its name has been assigned to `$tmp'. -$debug || -{ - tmp= ac_tmp= - trap 'exit_status=$? - : "${ac_tmp:=$tmp}" - { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status -' 0 - trap 'as_fn_exit 1' 1 2 13 15 -} -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -d "$tmp" -} || -{ - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") -} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 -ac_tmp=$tmp - -# Set up the scripts for CONFIG_FILES section. -# No need to generate them if there are no CONFIG_FILES. -# This happens for instance with `./config.status config.h'. -if test -n "$CONFIG_FILES"; then - - -ac_cr=`echo X | tr X '\015'` -# On cygwin, bash can eat \r inside `` if the user requested igncr. -# But we know of no other shell where ac_cr would be empty at this -# point, so we can use a bashism as a fallback. -if test "x$ac_cr" = x; then - eval ac_cr=\$\'\\r\' -fi -ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` -if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\\r' -else - ac_cs_awk_cr=$ac_cr -fi - -echo 'BEGIN {' >"$ac_tmp/subs1.awk" && -_ACEOF - - -{ - echo "cat >conf$$subs.awk <<_ACEOF" && - echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && - echo "_ACEOF" -} >conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` -ac_delim='%!_!# ' -for ac_last_try in false false false false false :; do - . ./conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - - ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` - if test $ac_delim_n = $ac_delim_num; then - break - elif $ac_last_try; then - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done -rm -f conf$$subs.sh - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && -_ACEOF -sed -n ' -h -s/^/S["/; s/!.*/"]=/ -p -g -s/^[^!]*!// -:repl -t repl -s/'"$ac_delim"'$// -t delim -:nl -h -s/\(.\{148\}\)..*/\1/ -t more1 -s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ -p -n -b repl -:more1 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t nl -:delim -h -s/\(.\{148\}\)..*/\1/ -t more2 -s/["\\]/\\&/g; s/^/"/; s/$/"/ -p -b -:more2 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t delim -' >$CONFIG_STATUS || ac_write_fail=1 -rm -f conf$$subs.awk -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACAWK -cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && - for (key in S) S_is_set[key] = 1 - FS = "" - -} -{ - line = $ 0 - nfields = split(line, field, "@") - substed = 0 - len = length(field[1]) - for (i = 2; i < nfields; i++) { - key = field[i] - keylen = length(key) - if (S_is_set[key]) { - value = S[key] - line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) - len += length(value) + length(field[++i]) - substed = 1 - } else - len += 1 + keylen - } - - print line -} - -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then - sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" -else - cat -fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ - || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 -_ACEOF - -# VPATH may cause trouble with some makes, so we remove sole $(srcdir), -# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ -h -s/// -s/^/:/ -s/[ ]*$/:/ -s/:\$(srcdir):/:/g -s/:\${srcdir}:/:/g -s/:@srcdir@:/:/g -s/^:*// -s/:*$// -x -s/\(=[ ]*\).*/\1/ -G -s/\n// -s/^[^=]*=[ ]*$// -}' -fi - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -fi # test -n "$CONFIG_FILES" - -# Set up the scripts for CONFIG_HEADERS section. -# No need to generate them if there are no CONFIG_HEADERS. -# This happens for instance with `./config.status Makefile'. -if test -n "$CONFIG_HEADERS"; then -cat >"$ac_tmp/defines.awk" <<\_ACAWK || -BEGIN { -_ACEOF - -# Transform confdefs.h into an awk script `defines.awk', embedded as -# here-document in config.status, that substitutes the proper values into -# config.h.in to produce config.h. - -# Create a delimiter string that does not exist in confdefs.h, to ease -# handling of long lines. -ac_delim='%!_!# ' -for ac_last_try in false false :; do - ac_tt=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_tt"; then - break - elif $ac_last_try; then - as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done - -# For the awk script, D is an array of macro values keyed by name, -# likewise P contains macro parameters if any. Preserve backslash -# newline sequences. - -ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* -sed -n ' -s/.\{148\}/&'"$ac_delim"'/g -t rset -:rset -s/^[ ]*#[ ]*define[ ][ ]*/ / -t def -d -:def -s/\\$// -t bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3"/p -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p -d -:bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3\\\\\\n"\\/p -t cont -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p -t cont -d -:cont -n -s/.\{148\}/&'"$ac_delim"'/g -t clear -:clear -s/\\$// -t bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/"/p -d -:bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p -b cont -' >$CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - for (key in D) D_is_set[key] = 1 - FS = "" -} -/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { - line = \$ 0 - split(line, arg, " ") - if (arg[1] == "#") { - defundef = arg[2] - mac1 = arg[3] - } else { - defundef = substr(arg[1], 2) - mac1 = arg[2] - } - split(mac1, mac2, "(") #) - macro = mac2[1] - prefix = substr(line, 1, index(line, defundef) - 1) - if (D_is_set[macro]) { - # Preserve the white space surrounding the "#". - print prefix "define", macro P[macro] D[macro] - next - } else { - # Replace #undef with comments. This is necessary, for example, - # in the case of _POSIX_SOURCE, which is predefined and required - # on some systems where configure will not decide to define it. - if (defundef == "undef") { - print "/*", prefix defundef, macro, "*/" - next - } - } -} -{ print } -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 -fi # test -n "$CONFIG_HEADERS" - - -eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" -shift -for ac_tag -do - case $ac_tag in - :[FHLC]) ac_mode=$ac_tag; continue;; - esac - case $ac_mode$ac_tag in - :[FHL]*:*);; - :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; - :[FH]-) ac_tag=-:-;; - :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; - esac - ac_save_IFS=$IFS - IFS=: - set x $ac_tag - IFS=$ac_save_IFS - shift - ac_file=$1 - shift - - case $ac_mode in - :L) ac_source=$1;; - :[FH]) - ac_file_inputs= - for ac_f - do - case $ac_f in - -) ac_f="$ac_tmp/stdin";; - *) # Look for the file first in the build tree, then in the source tree - # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. - test -f "$ac_f" || - case $ac_f in - [\\/$]*) false;; - *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; - esac || - as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; - esac - case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - as_fn_append ac_file_inputs " '$ac_f'" - done - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - configure_input='Generated from '` - $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' - `' by configure.' - if test x"$ac_file" != x-; then - configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 -$as_echo "$as_me: creating $ac_file" >&6;} - fi - # Neutralize special characters interpreted by sed in replacement strings. - case $configure_input in #( - *\&* | *\|* | *\\* ) - ac_sed_conf_input=`$as_echo "$configure_input" | - sed 's/[\\\\&|]/\\\\&/g'`;; #( - *) ac_sed_conf_input=$configure_input;; - esac - - case $ac_tag in - *:-:* | *:-) cat >"$ac_tmp/stdin" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; - esac - ;; - esac - - ac_dir=`$as_dirname -- "$ac_file" || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - as_dir="$ac_dir"; as_fn_mkdir_p - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - - case $ac_mode in - :F) - # - # CONFIG_FILE - # - - case $INSTALL in - [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; - *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; - esac -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# If the template does not know about datarootdir, expand it. -# FIXME: This hack should be removed a few years after 2.60. -ac_datarootdir_hack=; ac_datarootdir_seen= -ac_sed_dataroot=' -/datarootdir/ { - p - q -} -/@datadir@/p -/@docdir@/p -/@infodir@/p -/@localedir@/p -/@mandir@/p' -case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in -*datarootdir*) ac_datarootdir_seen=yes;; -*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - ac_datarootdir_hack=' - s&@datadir@&$datadir&g - s&@docdir@&$docdir&g - s&@infodir@&$infodir&g - s&@localedir@&$localedir&g - s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; -esac -_ACEOF - -# Neutralize VPATH when `$srcdir' = `.'. -# Shell code in configure.ac might set extrasub. -# FIXME: do we really want to maintain this feature? -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_sed_extra="$ac_vpsub -$extrasub -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s|@configure_input@|$ac_sed_conf_input|;t t -s&@top_builddir@&$ac_top_builddir_sub&;t t -s&@top_build_prefix@&$ac_top_build_prefix&;t t -s&@srcdir@&$ac_srcdir&;t t -s&@abs_srcdir@&$ac_abs_srcdir&;t t -s&@top_srcdir@&$ac_top_srcdir&;t t -s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t -s&@builddir@&$ac_builddir&;t t -s&@abs_builddir@&$ac_abs_builddir&;t t -s&@abs_top_builddir@&$ac_abs_top_builddir&;t t -s&@INSTALL@&$ac_INSTALL&;t t -$ac_datarootdir_hack -" -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ - >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - -test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ - "$ac_tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&5 -$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&2;} - - rm -f "$ac_tmp/stdin" - case $ac_file in - -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; - *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; - esac \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - ;; - :H) - # - # CONFIG_HEADER - # - if test x"$ac_file" != x-; then - { - $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" - } >"$ac_tmp/config.h" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then - { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 -$as_echo "$as_me: $ac_file is unchanged" >&6;} - else - rm -f "$ac_file" - mv "$ac_tmp/config.h" "$ac_file" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - fi - else - $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ - || as_fn_error $? "could not create -" "$LINENO" 5 - fi - ;; - - :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 -$as_echo "$as_me: executing $ac_file commands" >&6;} - ;; - esac - - - case $ac_file$ac_mode in - "libtool":C) - - # See if we are running on zsh, and set the options which allow our - # commands through without removal of \ escapes. - if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST - fi - - cfgfile="${ofile}T" - trap "$RM \"$cfgfile\"; exit 1" 1 2 15 - $RM "$cfgfile" - - cat <<_LT_EOF >> "$cfgfile" -#! $SHELL - -# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. -# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# NOTE: Changes made to this file will be lost: look at ltmain.sh. -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010, 2011 Free Software -# Foundation, Inc. -# Written by Gordon Matzigkeit, 1996 -# -# This file is part of GNU Libtool. -# -# GNU Libtool 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. -# -# As a special exception to the GNU General Public License, -# if you distribute this file as part of a program or library that -# is built using GNU Libtool, you may include this file under the -# same distribution terms that you use for the rest of that program. -# -# GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy -# can be downloaded from http://www.gnu.org/licenses/gpl.html, or -# obtained by writing to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - -# The names of the tagged configurations supported by this script. -available_tags="" - -# ### BEGIN LIBTOOL CONFIG - -# Assembler program. -AS=$lt_AS - -# DLL creation program. -DLLTOOL=$lt_DLLTOOL - -# Object dumper program. -OBJDUMP=$lt_OBJDUMP - -# Which release of libtool.m4 was used? -macro_version=$macro_version -macro_revision=$macro_revision - -# Whether or not to build shared libraries. -build_libtool_libs=$enable_shared - -# Whether or not to build static libraries. -build_old_libs=$enable_static - -# What type of objects to build. -pic_mode=$pic_mode - -# Whether or not to optimize for fast installation. -fast_install=$enable_fast_install - -# Shell to use when invoking shell scripts. -SHELL=$lt_SHELL - -# An echo program that protects backslashes. -ECHO=$lt_ECHO - -# The PATH separator for the build system. -PATH_SEPARATOR=$lt_PATH_SEPARATOR - -# The host system. -host_alias=$host_alias -host=$host -host_os=$host_os - -# The build system. -build_alias=$build_alias -build=$build -build_os=$build_os - -# A sed program that does not truncate output. -SED=$lt_SED - -# Sed that helps us avoid accidentally triggering echo(1) options like -n. -Xsed="\$SED -e 1s/^X//" - -# A grep program that handles long lines. -GREP=$lt_GREP - -# An ERE matcher. -EGREP=$lt_EGREP - -# A literal string matcher. -FGREP=$lt_FGREP - -# A BSD- or MS-compatible name lister. -NM=$lt_NM - -# Whether we need soft or hard links. -LN_S=$lt_LN_S - -# What is the maximum length of a command? -max_cmd_len=$max_cmd_len - -# Object file suffix (normally "o"). -objext=$ac_objext - -# Executable file suffix (normally ""). -exeext=$exeext - -# whether the shell understands "unset". -lt_unset=$lt_unset - -# turn spaces into newlines. -SP2NL=$lt_lt_SP2NL - -# turn newlines into spaces. -NL2SP=$lt_lt_NL2SP - -# convert \$build file names to \$host format. -to_host_file_cmd=$lt_cv_to_host_file_cmd - -# convert \$build files to toolchain format. -to_tool_file_cmd=$lt_cv_to_tool_file_cmd - -# Method to check whether dependent libraries are shared objects. -deplibs_check_method=$lt_deplibs_check_method - -# Command to use when deplibs_check_method = "file_magic". -file_magic_cmd=$lt_file_magic_cmd - -# How to find potential files when deplibs_check_method = "file_magic". -file_magic_glob=$lt_file_magic_glob - -# Find potential files using nocaseglob when deplibs_check_method = "file_magic". -want_nocaseglob=$lt_want_nocaseglob - -# Command to associate shared and link libraries. -sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd - -# The archiver. -AR=$lt_AR - -# Flags to create an archive. -AR_FLAGS=$lt_AR_FLAGS - -# How to feed a file listing to the archiver. -archiver_list_spec=$lt_archiver_list_spec - -# A symbol stripping program. -STRIP=$lt_STRIP - -# Commands used to install an old-style archive. -RANLIB=$lt_RANLIB -old_postinstall_cmds=$lt_old_postinstall_cmds -old_postuninstall_cmds=$lt_old_postuninstall_cmds - -# Whether to use a lock for old archive extraction. -lock_old_archive_extraction=$lock_old_archive_extraction - -# A C compiler. -LTCC=$lt_CC - -# LTCC compiler flags. -LTCFLAGS=$lt_CFLAGS - -# Take the output of nm and produce a listing of raw symbols and C names. -global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe - -# Transform the output of nm in a proper C declaration. -global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl - -# Transform the output of nm in a C name address pair. -global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address - -# Transform the output of nm in a C name address pair when lib prefix is needed. -global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix - -# Specify filename containing input files for \$NM. -nm_file_list_spec=$lt_nm_file_list_spec - -# The root where to search for dependent libraries,and in which our libraries should be installed. -lt_sysroot=$lt_sysroot - -# The name of the directory that contains temporary libtool files. -objdir=$objdir - -# Used to examine libraries when file_magic_cmd begins with "file". -MAGIC_CMD=$MAGIC_CMD - -# Must we lock files when doing compilation? -need_locks=$lt_need_locks - -# Manifest tool. -MANIFEST_TOOL=$lt_MANIFEST_TOOL - -# Tool to manipulate archived DWARF debug symbol files on Mac OS X. -DSYMUTIL=$lt_DSYMUTIL - -# Tool to change global to local symbols on Mac OS X. -NMEDIT=$lt_NMEDIT - -# Tool to manipulate fat objects and archives on Mac OS X. -LIPO=$lt_LIPO - -# ldd/readelf like tool for Mach-O binaries on Mac OS X. -OTOOL=$lt_OTOOL - -# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. -OTOOL64=$lt_OTOOL64 - -# Old archive suffix (normally "a"). -libext=$libext - -# Shared library suffix (normally ".so"). -shrext_cmds=$lt_shrext_cmds - -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds=$lt_extract_expsyms_cmds - -# Variables whose values should be saved in libtool wrapper scripts and -# restored at link time. -variables_saved_for_relink=$lt_variables_saved_for_relink - -# Do we need the "lib" prefix for modules? -need_lib_prefix=$need_lib_prefix - -# Do we need a version for libraries? -need_version=$need_version - -# Library versioning type. -version_type=$version_type - -# Shared library runtime path variable. -runpath_var=$runpath_var - -# Shared library path variable. -shlibpath_var=$shlibpath_var - -# Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=$shlibpath_overrides_runpath - -# Format of library name prefix. -libname_spec=$lt_libname_spec - -# List of archive names. First name is the real one, the rest are links. -# The last name is the one that the linker finds with -lNAME -library_names_spec=$lt_library_names_spec - -# The coded name of the library, if different from the real name. -soname_spec=$lt_soname_spec - -# Permission mode override for installation of shared libraries. -install_override_mode=$lt_install_override_mode - -# Command to use after installation of a shared archive. -postinstall_cmds=$lt_postinstall_cmds - -# Command to use after uninstallation of a shared archive. -postuninstall_cmds=$lt_postuninstall_cmds - -# Commands used to finish a libtool library installation in a directory. -finish_cmds=$lt_finish_cmds - -# As "finish_cmds", except a single script fragment to be evaled but -# not shown. -finish_eval=$lt_finish_eval - -# Whether we should hardcode library paths into libraries. -hardcode_into_libs=$hardcode_into_libs - -# Compile-time system search path for libraries. -sys_lib_search_path_spec=$lt_sys_lib_search_path_spec - -# Run-time system search path for libraries. -sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec - -# Whether dlopen is supported. -dlopen_support=$enable_dlopen - -# Whether dlopen of programs is supported. -dlopen_self=$enable_dlopen_self - -# Whether dlopen of statically linked programs is supported. -dlopen_self_static=$enable_dlopen_self_static - -# Commands to strip libraries. -old_striplib=$lt_old_striplib -striplib=$lt_striplib - - -# The linker used to build libraries. -LD=$lt_LD - -# How to create reloadable object files. -reload_flag=$lt_reload_flag -reload_cmds=$lt_reload_cmds - -# Commands used to build an old-style archive. -old_archive_cmds=$lt_old_archive_cmds - -# A language specific compiler. -CC=$lt_compiler - -# Is the compiler the GNU compiler? -with_gcc=$GCC - -# Compiler flag to turn off builtin functions. -no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag - -# Additional compiler flags for building library objects. -pic_flag=$lt_lt_prog_compiler_pic - -# How to pass a linker flag through the compiler. -wl=$lt_lt_prog_compiler_wl - -# Compiler flag to prevent dynamic linking. -link_static_flag=$lt_lt_prog_compiler_static - -# Does compiler simultaneously support -c and -o options? -compiler_c_o=$lt_lt_cv_prog_compiler_c_o - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$archive_cmds_need_lc - -# Whether or not to disallow shared libs when runtime libs are static. -allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec=$lt_export_dynamic_flag_spec - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec=$lt_whole_archive_flag_spec - -# Whether the compiler copes with passing no objects directly. -compiler_needs_object=$lt_compiler_needs_object - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds=$lt_old_archive_from_new_cmds - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds - -# Commands used to build a shared archive. -archive_cmds=$lt_archive_cmds -archive_expsym_cmds=$lt_archive_expsym_cmds - -# Commands used to build a loadable module if different from building -# a shared archive. -module_cmds=$lt_module_cmds -module_expsym_cmds=$lt_module_expsym_cmds - -# Whether we are building with GNU ld or not. -with_gnu_ld=$lt_with_gnu_ld - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag=$lt_allow_undefined_flag - -# Flag that enforces no undefined symbols. -no_undefined_flag=$lt_no_undefined_flag - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist -hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec - -# Whether we need a single "-rpath" flag with a separated argument. -hardcode_libdir_separator=$lt_hardcode_libdir_separator - -# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes -# DIR into the resulting binary. -hardcode_direct=$hardcode_direct - -# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes -# DIR into the resulting binary and the resulting library dependency is -# "absolute",i.e impossible to change by setting \${shlibpath_var} if the -# library is relocated. -hardcode_direct_absolute=$hardcode_direct_absolute - -# Set to "yes" if using the -LDIR flag during linking hardcodes DIR -# into the resulting binary. -hardcode_minus_L=$hardcode_minus_L - -# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR -# into the resulting binary. -hardcode_shlibpath_var=$hardcode_shlibpath_var - -# Set to "yes" if building a shared library automatically hardcodes DIR -# into the library and all subsequent libraries and executables linked -# against it. -hardcode_automatic=$hardcode_automatic - -# Set to yes if linker adds runtime paths of dependent libraries -# to runtime path list. -inherit_rpath=$inherit_rpath - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=$link_all_deplibs - -# Set to "yes" if exported symbols are required. -always_export_symbols=$always_export_symbols - -# The commands to list exported symbols. -export_symbols_cmds=$lt_export_symbols_cmds - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms=$lt_exclude_expsyms - -# Symbols that must always be exported. -include_expsyms=$lt_include_expsyms - -# Commands necessary for linking programs (against libraries) with templates. -prelink_cmds=$lt_prelink_cmds - -# Commands necessary for finishing linking programs. -postlink_cmds=$lt_postlink_cmds - -# Specify filename containing input files. -file_list_spec=$lt_file_list_spec - -# How to hardcode a shared library path into an executable. -hardcode_action=$hardcode_action - -# ### END LIBTOOL CONFIG - -_LT_EOF - - case $host_os in - aix3*) - cat <<\_LT_EOF >> "$cfgfile" -# AIX sometimes has problems with the GCC collect2 program. For some -# reason, if we set the COLLECT_NAMES environment variable, the problems -# vanish in a puff of smoke. -if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES -fi -_LT_EOF - ;; - esac - - -ltmain="$ac_aux_dir/ltmain.sh" - - - # We use sed instead of cat because bash on DJGPP gets confused if - # if finds mixed CR/LF and LF-only lines. Since sed operates in - # text mode, it properly converts lines to CR/LF. This bash problem - # is reportedly fixed, but why not run on old versions too? - sed '$q' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - if test x"$xsi_shell" = xyes; then - sed -e '/^func_dirname ()$/,/^} # func_dirname /c\ -func_dirname ()\ -{\ -\ case ${1} in\ -\ */*) func_dirname_result="${1%/*}${2}" ;;\ -\ * ) func_dirname_result="${3}" ;;\ -\ esac\ -} # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_basename ()$/,/^} # func_basename /c\ -func_basename ()\ -{\ -\ func_basename_result="${1##*/}"\ -} # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\ -func_dirname_and_basename ()\ -{\ -\ case ${1} in\ -\ */*) func_dirname_result="${1%/*}${2}" ;;\ -\ * ) func_dirname_result="${3}" ;;\ -\ esac\ -\ func_basename_result="${1##*/}"\ -} # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_stripname ()$/,/^} # func_stripname /c\ -func_stripname ()\ -{\ -\ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\ -\ # positional parameters, so assign one to ordinary parameter first.\ -\ func_stripname_result=${3}\ -\ func_stripname_result=${func_stripname_result#"${1}"}\ -\ func_stripname_result=${func_stripname_result%"${2}"}\ -} # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\ -func_split_long_opt ()\ -{\ -\ func_split_long_opt_name=${1%%=*}\ -\ func_split_long_opt_arg=${1#*=}\ -} # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\ -func_split_short_opt ()\ -{\ -\ func_split_short_opt_arg=${1#??}\ -\ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\ -} # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\ -func_lo2o ()\ -{\ -\ case ${1} in\ -\ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\ -\ *) func_lo2o_result=${1} ;;\ -\ esac\ -} # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_xform ()$/,/^} # func_xform /c\ -func_xform ()\ -{\ - func_xform_result=${1%.*}.lo\ -} # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_arith ()$/,/^} # func_arith /c\ -func_arith ()\ -{\ - func_arith_result=$(( $* ))\ -} # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_len ()$/,/^} # func_len /c\ -func_len ()\ -{\ - func_len_result=${#1}\ -} # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - -fi - -if test x"$lt_shell_append" = xyes; then - sed -e '/^func_append ()$/,/^} # func_append /c\ -func_append ()\ -{\ - eval "${1}+=\\${2}"\ -} # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\ -func_append_quoted ()\ -{\ -\ func_quote_for_eval "${2}"\ -\ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\ -} # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - # Save a `func_append' function call where possible by direct use of '+=' - sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") - test 0 -eq $? || _lt_function_replace_fail=: -else - # Save a `func_append' function call even when '+=' is not available - sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") - test 0 -eq $? || _lt_function_replace_fail=: -fi - -if test x"$_lt_function_replace_fail" = x":"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5 -$as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;} -fi - - - mv -f "$cfgfile" "$ofile" || - (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") - chmod +x "$ofile" - - ;; - "default":C) -# Commands run at the end of config.status: -for i in $APR_SAVE_HEADERS; do - if cmp -s $i $i.save 2>/dev/null; then - mv $i.save $i - { $as_echo "$as_me:${as_lineno-$LINENO}: $i is unchanged" >&5 -$as_echo "$as_me: $i is unchanged" >&6;} - fi - rm -f $i.save -done -chmod +x apr-$APR_MAJOR_VERSION-config - ;; - - esac -done # for ac_tag - - -as_fn_exit 0 -_ACEOF -ac_clean_files=$ac_clean_files_save - -test $ac_write_fail = 0 || - as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 - - -# configure is writing to config.log, and then calls config.status. -# config.status does its own redirection, appending to config.log. -# Unfortunately, on DOS this fails, as config.log is still kept open -# by configure, so config.status won't be able to write to it; its -# output is simply discarded. So we exec the FD to /dev/null, -# effectively closing config.log, so it can be properly (re)opened and -# appended to by config.status. When coming back to configure, we -# need to make the FD available again. -if test "$no_create" != yes; then - ac_cs_success=: - ac_config_status_args= - test "$silent" = yes && - ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null - $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit 1 -fi -if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 -$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} -fi - diff --git a/libs/apr/configure.in b/libs/apr/configure.in deleted file mode 100644 index 655de8df..00000000 --- a/libs/apr/configure.in +++ /dev/null @@ -1,2809 +0,0 @@ -dnl -dnl Autoconf configuration file for APR -dnl -dnl Process this file with autoconf to produce a configure script. -dnl Use ./buildconf to prepare build files and run autoconf for APR. - -AC_PREREQ(2.59) - -AC_INIT(build/apr_common.m4) -AC_CONFIG_HEADER(include/arch/unix/apr_private.h) -AC_CONFIG_AUX_DIR(build) -AC_CONFIG_MACRO_DIR(build) - -dnl -dnl Include our own M4 macros along with those for libtool -dnl -sinclude(build/apr_common.m4) -sinclude(build/apr_network.m4) -sinclude(build/apr_threads.m4) -sinclude(build/apr_win32.m4) -sinclude(build/apr_hints.m4) -sinclude(build/libtool.m4) -sinclude(build/ltsugar.m4) -sinclude(build/argz.m4) -sinclude(build/ltoptions.m4) -sinclude(build/ltversion.m4) -sinclude(build/lt~obsolete.m4) - -dnl Hard-coded top of apr_private.h: -AH_TOP([ -#ifndef APR_PRIVATE_H -#define APR_PRIVATE_H -]) - -dnl Hard-coded inclusion at the tail end of apr_private.h: -AH_BOTTOM([ -/* switch this on if we have a BeOS version below BONE */ -#if BEOS && !HAVE_BONE_VERSION -#define BEOS_R5 1 -#else -#define BEOS_BONE 1 -#endif - -/* - * Darwin 10's default compiler (gcc42) builds for both 64 and - * 32 bit architectures unless specifically told not to. - * In those cases, we need to override types depending on how - * we're being built at compile time. - * NOTE: This is an ugly work-around for Darwin's - * concept of universal binaries, a single package - * (executable, lib, etc...) which contains both 32 - * and 64 bit versions. The issue is that if APR is - * built universally, if something else is compiled - * against it, some bit sizes will depend on whether - * it is 32 or 64 bit. This is determined by the __LP64__ - * flag. Since we need to support both, we have to - * handle OS X unqiuely. - */ -#ifdef DARWIN_10 - -#undef APR_OFF_T_STRFN -#undef APR_INT64_STRFN -#undef SIZEOF_LONG -#undef SIZEOF_SIZE_T -#undef SIZEOF_SSIZE_T -#undef SIZEOF_VOIDP -#undef SIZEOF_STRUCT_IOVEC - -#ifdef __LP64__ - #define APR_INT64_STRFN strtol - #define SIZEOF_LONG 8 - #define SIZEOF_SIZE_T 8 - #define SIZEOF_SSIZE_T 8 - #define SIZEOF_VOIDP 8 - #define SIZEOF_STRUCT_IOVEC 16 -#else - #define APR_INT64_STRFN strtoll - #define SIZEOF_LONG 4 - #define SIZEOF_SIZE_T 4 - #define SIZEOF_SSIZE_T 4 - #define SIZEOF_VOIDP 4 - #define SIZEOF_STRUCT_IOVEC 8 -#endif - -#undef APR_OFF_T_STRFN -#define APR_OFF_T_STRFN APR_INT64_STRFN - - -#undef SETPGRP_VOID -#ifdef __DARWIN_UNIX03 - #define SETPGRP_VOID 1 -#else -/* #undef SETPGRP_VOID */ -#endif - -#endif /* DARWIN_10 */ - -/* - * Include common private declarations. - */ -#include "../apr_private_common.h" -#endif /* APR_PRIVATE_H */ -]) - -dnl Save user-defined environment settings for later restoration -dnl -APR_SAVE_THE_ENVIRONMENT(CPPFLAGS) -APR_SAVE_THE_ENVIRONMENT(CFLAGS) -APR_SAVE_THE_ENVIRONMENT(LDFLAGS) -APR_SAVE_THE_ENVIRONMENT(LIBS) -APR_SAVE_THE_ENVIRONMENT(INCLUDES) - -dnl Generate ./config.nice for reproducing runs of configure -dnl -APR_CONFIG_NICE(config.nice) - -AC_CANONICAL_SYSTEM -echo "Configuring APR library" -echo "Platform: $host" - -dnl Some initial steps for configuration. We setup the default directory -dnl and which files are to be configured. - -dnl Setup the directory macros now - -# Absolute source/build directory -apr_srcdir=`(cd $srcdir && pwd)` -apr_builddir=`pwd` -AC_SUBST(apr_srcdir) -AC_SUBST(apr_builddir) - -if test "$apr_builddir" != "$apr_srcdir"; then - USE_VPATH=1 - APR_CONFIG_LOCATION=build -else - APR_CONFIG_LOCATION=source -fi - -AC_SUBST(APR_CONFIG_LOCATION) - -# Libtool might need this symbol -- it must point to the location of -# the generated libtool script (not necessarily the "top" build dir). -# -top_builddir="$apr_builddir" -AC_SUBST(top_builddir) - -# Directory containing apr build macros, helpers, and make rules -# NOTE: make rules (apr_rules.mk) will be in the builddir for vpath -# -apr_buildout=$apr_builddir/build -apr_builders=$apr_srcdir/build -AC_SUBST(apr_builders) - -MKDIR=$apr_builders/mkdir.sh - -dnl Initialize mkdir -p functionality. -APR_MKDIR_P_CHECK($apr_builders/mkdir.sh) - -# get our version information -get_version="$apr_builders/get-version.sh" -version_hdr="$apr_srcdir/include/apr_version.h" -APR_MAJOR_VERSION="`$get_version major $version_hdr APR`" -APR_DOTTED_VERSION="`$get_version all $version_hdr APR`" - -AC_SUBST(APR_DOTTED_VERSION) -AC_SUBST(APR_MAJOR_VERSION) - -echo "APR Version: ${APR_DOTTED_VERSION}" - -dnl Enable the layout handling code, then reparse the prefix-style -dnl arguments due to autoconf being a PITA. -APR_ENABLE_LAYOUT(apr) -APR_PARSE_ARGUMENTS - -dnl Set optional CC hints here in case autoconf makes an inappropriate choice. -dnl This allows us to suggest what the compiler should be, but still -dnl allows the user to override CC externally. -APR_CC_HINTS - -dnl Do the various CC checks *before* preloading values. The preload code -dnl may need to use compiler characteristics to make decisions. This macro -dnl can only be used once within a configure script, so this prevents a -dnl preload section from invoking the macro to get compiler info. -AC_PROG_CC - -dnl AC_PROG_SED is only avaliable in recent autoconf versions. -dnl Use AC_CHECK_PROG instead if AC_PROG_SED is not present. -ifdef([AC_PROG_SED], - [AC_PROG_SED], - [AC_CHECK_PROG(SED, sed, sed)]) - -dnl Preload -APR_PRELOAD - -dnl These added to allow default directories to be used... -DEFAULT_OSDIR="unix" -echo "(Default will be ${DEFAULT_OSDIR})" - -apr_modules="file_io network_io threadproc misc locks time mmap shmem user memory atomic poll support random" - -dnl Checks for programs. -AC_PROG_MAKE_SET -AC_PROG_CPP -AC_PROG_AWK -AC_PROG_LN_S -AC_PROG_RANLIB -AC_PROG_INSTALL -AC_CHECK_PROG(RM, rm, rm) -AC_CHECK_PROG(AS, as, as) -AC_CHECK_PROG(ASCPP, cpp, cpp) -AC_CHECK_TOOL(AR, ar, ar) - -dnl Various OS checks that apparently set required flags -ifdef([AC_USE_SYSTEM_EXTENSIONS], [ -AC_USE_SYSTEM_EXTENSIONS -], [ -AC_AIX -AC_MINIX -]) - -AC_ISC_POSIX -APR_EBCDIC - -dnl this is our library name -APR_LIBNAME="apr${libsuffix}" -AC_SUBST(APR_LIBNAME) - -dnl prep libtool -dnl -echo "performing libtool configuration..." - -AC_ARG_ENABLE(experimental-libtool,[ --enable-experimental-libtool Use experimental custom libtool], - [experimental_libtool=$enableval],[experimental_libtool=no]) - -dnl Workarounds for busted Libtool 2.x when we don't call AC_PROG_LIBTOOL -if test "x$Xsed" = "x"; then - Xsed="$SED -e 1s/^X//" -fi - -case $host in -*-os2*) - # Use a custom-made libtool replacement - echo "using aplibtool" - LIBTOOL="$srcdir/build/aplibtool" - gcc $CFLAGS $CPPFLAGS -o $LIBTOOL.exe $LIBTOOL.c - ;; -*) - if test "x$LTFLAGS" = "x"; then - LTFLAGS='--silent' - fi - if test "$experimental_libtool" = "yes"; then - # Use a custom-made libtool replacement - echo "using jlibtool" - LIBTOOL="$apr_builddir/libtool" - LIBTOOL_SRC="$apr_srcdir/build/jlibtool.c" - $CC $CFLAGS $CPPFLAGS -o $LIBTOOL $LIBTOOL_SRC - eval `$apr_builddir/libtool --config | grep "^shlibpath_var=[[A-Z_]]*$"` - if test "x$shlibpath_var" = "x"; then - shlibpath_var=REPLACE_WITH_YOUR_SHLIBPATH_VAR - fi - else - dnl libtoolize requires that the following not be indented - dnl should become LT_INIT(win32-dll) -AC_LIBTOOL_WIN32_DLL -AC_PROG_LIBTOOL - # get libtool's setting of shlibpath_var - eval `grep "^shlibpath_var=[[A-Z_]]*$" $apr_builddir/libtool` - if test "x$shlibpath_var" = "x"; then - shlibpath_var=REPLACE_WITH_YOUR_SHLIBPATH_VAR - fi - fi - ;; -esac - -AC_ARG_WITH(installbuilddir, [ --with-installbuilddir=DIR location to store APR build files (defaults to '${datadir}/build')], - [ installbuilddir=$withval ], [ installbuilddir="${datadir}/build-${APR_MAJOR_VERSION}" ] ) -AC_SUBST(installbuilddir) - -AC_ARG_WITH(libtool, [ --without-libtool avoid using libtool to link the library], - [ use_libtool=$withval ], [ use_libtool="yes" ] ) - -if test "x$use_libtool" = "xyes"; then - lt_compile='$(LIBTOOL) $(LTFLAGS) --mode=compile $(COMPILE) -o $@ -c $< && touch $@' - LT_VERSION="-version-info `$get_version libtool $version_hdr APR`" - link="\$(LIBTOOL) \$(LTFLAGS) --mode=link \$(LT_LDFLAGS) \$(COMPILE) \$(LT_VERSION) \$(ALL_LDFLAGS) -o \$@" - so_ext='lo' - lib_target='-rpath $(libdir) $(OBJECTS)' - export_lib_target='-rpath \$(libdir) \$(OBJECTS)' -else - lt_compile='$(COMPILE) -o $@ -c $<' - link='$(AR) cr $(TARGET_LIB) $(OBJECTS); $(RANLIB) $(TARGET_LIB)' - so_ext='o' - lib_target='' - export_lib_target='' -fi - -case $host in - *-solaris2*) - apr_platform_runtime_link_flag="-R" - ;; - *) - ;; -esac - -AC_SUBST(lt_compile) -AC_SUBST(link) -AC_SUBST(so_ext) -AC_SUBST(lib_target) -AC_SUBST(export_lib_target) -AC_SUBST(shlibpath_var) -AC_SUBST(LTFLAGS) -AC_SUBST(LT_LDFLAGS) -AC_SUBST(LT_VERSION) - -dnl ----------------------------- Checks for compiler flags -nl=' -' -echo "${nl}Check for compiler flags..." - -dnl AC_PROG_CC sets -g in CFLAGS (and -O2 for gcc) by default. -dnl On OS/390 this causes the compiler to insert extra debugger -dnl hook instructions. That's fine for debug/maintainer builds, not fine -dnl otherwise. - -case $host in - *os390) - if test "$ac_test_CFLAGS" != set; then - APR_REMOVEFROM(CFLAGS,-g) - fi - ;; -esac - -AC_ARG_ENABLE(debug,[ --enable-debug Turn on debugging and compile time warnings], - [APR_ADDTO(CFLAGS,-g) - if test "$GCC" = "yes"; then - APR_ADDTO(CFLAGS,-Wall) - elif test "$AIX_XLC" = "yes"; then - APR_ADDTO(CFLAGS,-qfullpath) - fi -])dnl - -AC_ARG_ENABLE(maintainer-mode,[ --enable-maintainer-mode Turn on debugging and compile time warnings], - [APR_ADDTO(CFLAGS,-g) - if test "$GCC" = "yes"; then - APR_ADDTO(CFLAGS,[-Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations]) - elif test "$AIX_XLC" = "yes"; then - APR_ADDTO(CFLAGS,-qfullpath -qinitauto=FE -qcheck=all -qinfo=pro) - fi -])dnl - -AC_ARG_ENABLE(profile,[ --enable-profile Turn on profiling for the build (GCC)], - if test "$GCC" = "yes"; then - APR_ADDTO(CFLAGS, -pg) - APR_REMOVEFROM(CFLAGS, -g) - if test "$host" = "i586-pc-beos"; then - APR_REMOVEFROM(CFLAGS, -O2) - APR_ADDTO(CFLAGS, -O1) - APR_ADDTO(LDFLAGS, -p) - fi - fi -)dnl - -AC_ARG_ENABLE(pool-debug, - [ --enable-pool-debug[[=yes|no|verbose|verbose-alloc|lifetime|owner|all]] Turn on pools debugging], - [ if test -z "$enableval"; then - APR_ADDTO(CPPFLAGS, -DAPR_POOL_DEBUG=1) - elif test ! "$enableval" = "no"; then - apr_pool_debug=1 - - for i in $enableval - do - flag=0 - - case $i in - yes) - flag=1 - ;; - verbose) - flag=2 - ;; - lifetime) - flag=4 - ;; - owner) - flag=8 - ;; - verbose-alloc) - flag=16 - ;; - all) - apr_pool_debug=31 - ;; - *) - ;; - esac - - if test $flag -gt 0; then - apr_pool_debug=`expr '(' $apr_pool_debug - $apr_pool_debug % \ - '(' $flag '*' 2 ')' ')' + $flag + $apr_pool_debug % $flag` - fi - done - - APR_ADDTO(CPPFLAGS, -DAPR_POOL_DEBUG=$apr_pool_debug) - fi - ]) - -if test "$host" = "i586-pc-beos"; then - AC_ARG_ENABLE(malloc-debug,[ --enable-malloc-debug Switch on malloc_debug for BeOS], - APR_REMOVEFROM(CFLAGS, -O2) - APR_ADDTO(CPPFLAGS, -fcheck-memory-usage -D_KERNEL_MODE) - ) dnl -fi - -# this is the place to put specific options for platform/compiler -# combinations -case "$host:$CC" in - *-hp-hpux*:cc ) - APR_ADDTO(CFLAGS,[-Ae +Z]) - case $host in - ia64-* ) - ;; - * ) - if echo "$CFLAGS " | grep '+DA' >/dev/null; then : - else - APR_ADDTO(CFLAGS,[+DAportable]) - fi - ;; - esac - ;; - powerpc-*-beos:mwcc* ) - APR_SETVAR(CPP,[mwcc -E]) - APR_SETVAR(CC,mwcc) - APR_SETVAR(AR,ar) - ;; -esac - -AC_CACHE_CHECK([whether the compiler provides atomic builtins], [ap_cv_atomic_builtins], -[AC_TRY_RUN([ -int main() -{ - unsigned long val = 1010, tmp, *mem = &val; - - if (__sync_fetch_and_add(&val, 1010) != 1010 || val != 2020) - return 1; - - tmp = val; - - if (__sync_fetch_and_sub(mem, 1010) != tmp || val != 1010) - return 1; - - if (__sync_sub_and_fetch(&val, 1010) != 0 || val != 0) - return 1; - - tmp = 3030; - - if (__sync_val_compare_and_swap(mem, 0, tmp) != 0 || val != tmp) - return 1; - - if (__sync_lock_test_and_set(&val, 4040) != 3030) - return 1; - - mem = &tmp; - - if (__sync_val_compare_and_swap(&mem, &tmp, &val) != &tmp) - return 1; - - __sync_synchronize(); - - if (mem != &val) - return 1; - - return 0; -}], [ap_cv_atomic_builtins=yes], [ap_cv_atomic_builtins=no], [ap_cv_atomic_builtins=no])]) - -if test "$ap_cv_atomic_builtins" = "yes"; then - AC_DEFINE(HAVE_ATOMIC_BUILTINS, 1, [Define if compiler provides atomic builtins]) -fi - -case $host in - powerpc-405-*) - # The IBM ppc405cr processor has a bugged stwcx instruction. - AC_DEFINE(PPC405_ERRATA, 1, [Define on PowerPC 405 where errata 77 applies]) - ;; - *) - ;; -esac - -dnl Check the depend program we can use -APR_CHECK_DEPEND - -proc_mutex_is_global=0 - -config_subdirs="none" -INSTALL_SUBDIRS="none" -OBJECTS_PLATFORM='$(OBJECTS_unix)' - -case $host in - i386-ibm-aix* | *-ibm-aix[[1-2]].* | *-ibm-aix3.* | *-ibm-aix4.1 | *-ibm-aix4.1.* | *-ibm-aix4.2 | *-ibm-aix4.2.*) - OSDIR="aix" - APR_ADDTO(LDFLAGS,-lld) - eolstr="\\n" - OBJECTS_PLATFORM='$(OBJECTS_aix)' - ;; - *-os2*) - APR_ADDTO(CPPFLAGS,-DOS2) - APR_ADDTO(CFLAGS,-Zmt) - AC_CHECK_LIB(bsd, random) - OSDIR="os2" - enable_threads="system_threads" - eolstr="\\r\\n" - file_as_socket="0" - proc_mutex_is_global=1 - OBJECTS_PLATFORM='$(OBJECTS_os2)' - ;; - *beos*) - OSDIR="beos" - APR_ADDTO(CPPFLAGS,-DBEOS) - enable_threads="system_threads" - native_mmap_emul="1" - APR_CHECK_DEFINE(BONE_VERSION, sys/socket.h) - eolstr="\\n" - osver=`uname -r` - proc_mutex_is_global=1 - OBJECTS_PLATFORM='$(OBJECTS_beos)' - case $osver in - 5.0.4) - file_as_socket="1" - ;; - *) - file_as_socket="0" - ;; - esac - ;; - *os390) - OSDIR="os390" - OBJECTS_PLATFORM='$(OBJECTS_os390)' - eolstr="\\n" - ;; - *os400) - OSDIR="as400" - eolstr="\\n" - ;; - *mingw*) - OSDIR="win32" - enable_threads="system_threads" - eolstr="\\r\\n" - file_as_socket=0 - proc_mutex_is_global=1 - OBJECTS_PLATFORM='$(OBJECTS_win32)' - ;; - *cygwin*) - OSDIR="unix" - enable_threads="no" - eolstr="\\n" - ;; - *hpux10* ) - enable_threads="no" - OSDIR="unix" - eolstr="\\n" - ;; - *) - OSDIR="unix" - eolstr="\\n" - ;; -esac - -AC_SUBST(OBJECTS_PLATFORM) - -# Check whether LFS has explicitly been disabled -AC_ARG_ENABLE(lfs,[ --disable-lfs Disable large file support on 32-bit platforms], -[apr_lfs_choice=$enableval], [apr_lfs_choice=yes]) - -if test "$apr_lfs_choice" = "yes"; then - # Check whether the transitional LFS API is sufficient - AC_CACHE_CHECK([whether to enable -D_LARGEFILE64_SOURCE], [apr_cv_use_lfs64], [ - apr_save_CPPFLAGS=$CPPFLAGS - CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE" - AC_TRY_RUN([ -#include -#include -#include -#include -#include -#include - -void main(void) -{ - int fd, ret = 0; - struct stat64 st; - off64_t off = 4242; - - if (sizeof(off64_t) != 8 || sizeof(off_t) != 4) - exit(1); - if ((fd = open("conftest.lfs", O_LARGEFILE|O_CREAT|O_WRONLY, 0644)) < 0) - exit(2); - if (ftruncate64(fd, off) != 0) - ret = 3; - else if (fstat64(fd, &st) != 0 || st.st_size != off) - ret = 4; - else if (lseek64(fd, off, SEEK_SET) != off) - ret = 5; - else if (close(fd) != 0) - ret = 6; - else if (lstat64("conftest.lfs", &st) != 0 || st.st_size != off) - ret = 7; - else if (stat64("conftest.lfs", &st) != 0 || st.st_size != off) - ret = 8; - unlink("conftest.lfs"); - - exit(ret); -}], [apr_cv_use_lfs64=yes], [apr_cv_use_lfs64=no], [apr_cv_use_lfs64=no]) - CPPFLAGS=$apr_save_CPPFLAGS]) - if test "$apr_cv_use_lfs64" = "yes"; then - APR_ADDTO(CPPFLAGS, [-D_LARGEFILE64_SOURCE]) - fi -fi - -AC_ARG_ENABLE(nonportable-atomics, -[ --enable-nonportable-atomics Use optimized atomic code which may produce nonportable binaries], -[if test $enableval = yes; then - force_generic_atomics=no - else - force_generic_atomics=yes - fi -], -[case $host_cpu in - i[[456]]86) force_generic_atomics=yes ;; - *) force_generic_atomics=no ;; -esac -]) - -if test $force_generic_atomics = yes; then - AC_DEFINE([USE_ATOMICS_GENERIC], 1, - [Define if use of generic atomics is requested]) -fi - -AC_SUBST(proc_mutex_is_global) -AC_SUBST(eolstr) -AC_SUBST(INSTALL_SUBDIRS) - -# For some platforms we need a version string which allows easy numeric -# comparisons. -case $host in - *freebsd*) - if test -x /sbin/sysctl; then - os_version=`/sbin/sysctl -n kern.osreldate` - else - os_version=000000 - fi - ;; - *linux*) - os_version=`uname -r | sed -e 's/\(.\)\.\(.\)\.\(.\).*/\1\2\3/'` - ;; - *os390) - os_version=`uname -r | sed -e 's/\.//g'` - ;; - *) - os_version=OS_VERSION_IS_NOT_SET - ;; -esac - -echo "${nl}Checking for libraries..." - -dnl ----------------------------- Checks for Any required Libraries -dnl Note: Autoconf will always append LIBS with an extra " " in AC_CHECK_LIB. -dnl It should check for LIBS being empty and set LIBS equal to the new value -dnl without the extra " " in that case, but they didn't do that. So, we -dnl end up LIBS="-lm -lcrypt -lnsl -ldl" which is an annoyance. -case $host in - *mingw*) - APR_ADDTO(LIBS,[-lshell32 -ladvapi32 -lws2_32 -lrpcrt4 -lmswsock]) - ac_cv_func_CreateFileMapping=yes - ;; - *) - AC_SEARCH_LIBS(gethostbyname, nsl) - AC_SEARCH_LIBS(gethostname, nsl) - AC_SEARCH_LIBS(socket, socket) - AC_SEARCH_LIBS(crypt, crypt ufc) - AC_CHECK_LIB(truerand, main) - AC_SEARCH_LIBS(modf, m) - ;; -esac - -dnl ----------------------------- Checking for Threads -echo "${nl}Checking for Threads..." - -if test -z "$enable_threads"; then - AC_ARG_ENABLE(threads, - [ --enable-threads Enable threading support in APR.], - [ enable_threads=$enableval] , - [ APR_CHECK_PTHREADS_H([ enable_threads="pthread" ] , - [ enable_threads="no" ] ) ] ) -fi - -if test "$enable_threads" = "no"; then - threads="0" - pthreadh="0" - pthreadser="0" -else - if test "$enable_threads" = "pthread"; then -# We have specified pthreads for our threading library, just make sure -# that we have everything we need - APR_PTHREADS_CHECK_SAVE - APR_PTHREADS_CHECK - APR_CHECK_PTHREADS_H([ - threads="1" - pthreadh="1" - pthreadser="1" ], [ - threads="0" - pthreadh="0" - pthreadser="0" - APR_PTHREADS_CHECK_RESTORE ] ) - elif test "$enable_threads" = "system_threads"; then - threads="1" - pthreadh="0" - pthreadser="0" - else -# We basically specified that we wanted threads, but not how to implement -# them. In this case, just look for pthreads. In the future, we can check -# for other threading libraries as well. - APR_PTHREADS_CHECK_SAVE - APR_PTHREADS_CHECK - APR_CHECK_PTHREADS_H([ - threads="1" - pthreadh="1" - pthreadser="1" ], [ - threads="0" - pthreadser="0" - pthreadh="0" - APR_PTHREADS_CHECK_RESTORE ] ) - fi - if test "$pthreadh" = "1"; then - APR_CHECK_PTHREAD_GETSPECIFIC_TWO_ARGS - APR_CHECK_PTHREAD_ATTR_GETDETACHSTATE_ONE_ARG - APR_CHECK_PTHREAD_RECURSIVE_MUTEX - AC_CHECK_FUNCS([pthread_key_delete pthread_rwlock_init \ - pthread_attr_setguardsize pthread_yield]) - - if test "$ac_cv_func_pthread_rwlock_init" = "yes"; then - dnl ----------------------------- Checking for pthread_rwlock_t - AC_CACHE_CHECK([for pthread_rwlock_t], [apr_cv_type_rwlock_t], - AC_TRY_COMPILE([#include -#include ], [pthread_rwlock_t *rwlock;], - [apr_cv_type_rwlock_t=yes], [apr_cv_type_rwlock_t=no], - [apr_cv_type_rwlock_t=no])) - if test "$apr_cv_type_rwlock_t" = "yes"; then - AC_DEFINE(HAVE_PTHREAD_RWLOCKS, 1, [Define if pthread rwlocks are available]) - fi - fi - - if test "$ac_cv_func_pthread_yield" = "no"; then - dnl ----------------------------- Checking for sched_yield - AC_CHECK_HEADERS([sched.h]) - AC_CHECK_FUNCS([sched_yield]) - fi - fi -fi - -ac_cv_define_READDIR_IS_THREAD_SAFE=no -ac_cv_define_GETHOSTBYNAME_IS_THREAD_SAFE=no -ac_cv_define_GETHOSTBYADDR_IS_THREAD_SAFE=no -ac_cv_define_GETSERVBYNAME_IS_THREAD_SAFE=no -if test "$threads" = "1"; then - echo "APR will use threads" - AC_CHECK_LIB(c_r, readdir, - AC_DEFINE(READDIR_IS_THREAD_SAFE, 1, - [Define if readdir is thread safe])) - if test "x$apr_gethostbyname_is_thread_safe" = "x"; then - AC_CHECK_LIB(c_r, gethostbyname, apr_gethostbyname_is_thread_safe=yes) - fi - if test "$apr_gethostbyname_is_thread_safe" = "yes"; then - AC_DEFINE(GETHOSTBYNAME_IS_THREAD_SAFE, 1, - [Define if gethostbyname is thread safe]) - fi - if test "x$apr_gethostbyaddr_is_thread_safe" = "x"; then - AC_CHECK_LIB(c_r, gethostbyaddr, apr_gethostbyaddr_is_thread_safe=yes) - fi - if test "$apr_gethostbyaddr_is_thread_safe" = "yes"; then - AC_DEFINE(GETHOSTBYADDR_IS_THREAD_SAFE, 1, - [Define if gethostbyaddr is thread safe]) - fi - if test "x$apr_getservbyname_is_thread_safe" = "x"; then - AC_CHECK_LIB(c_r, getservbyname, apr_getservbyname_is_thread_safe=yes) - fi - if test "$apr_getservbyname_is_thread_safe" = "yes"; then - AC_DEFINE(GETSERVBYNAME_IS_THREAD_SAFE, 1, - [Define if getservbyname is thread safe]) - fi - AC_CHECK_FUNCS(gethostbyname_r gethostbyaddr_r getservbyname_r) -else - echo "APR will be non-threaded" -fi - -dnl Electric Fence malloc checker. -dnl --with-efence specifies the path to Electric Fence. -dnl This test should remain after the threads checks since libefence -dnl may depend on libpthread. -AC_ARG_WITH(efence, - [ --with-efence[[=DIR]] path to Electric Fence installation], - [ apr_efence_dir="$withval" - if test "$apr_efence_dir" != "yes"; then - APR_ADDTO(LDFLAGS,[-L$apr_efence_dir/lib]) - if test "x$apr_platform_runtime_link_flag" != "x"; then - APR_ADDTO(LDFLAGS, - [$apr_platform_runtime_link_flag$apr_efence_dir/lib]) - fi - fi - AC_CHECK_LIB(efence, malloc, - [ APR_ADDTO(LIBS,-lefence) ], - [ AC_MSG_ERROR(Electric Fence requested but not detected) ]) - ]) - -AC_CHECK_FUNCS(sigsuspend, [ have_sigsuspend="1" ], [ have_sigsuspend="0" ]) -AC_CHECK_FUNCS(sigwait, [ have_sigwait="1" ], [ have_sigwait="0" ]) -dnl AC_CHECK_FUNCS doesn't work for this on Tru64 since the function -dnl is renamed in signal.h. Todo: Autodetect -case $host in - *alpha*-dec-osf* ) - have_sigwait="1" - ;; -esac - -AC_SUBST(threads) -AC_SUBST(have_sigsuspend) -AC_SUBST(have_sigwait) - -AC_CHECK_FUNCS(poll kqueue port_create) - -# Check for the Linux epoll interface; epoll* may be available in libc -# but return ENOSYS on a pre-2.6 kernel, so do a run-time check. -AC_CACHE_CHECK([for epoll support], [apr_cv_epoll], -[AC_TRY_RUN([ -#include -#include - -int main() -{ - return epoll_create(5) == -1; -}], [apr_cv_epoll=yes], [apr_cv_epoll=no], [apr_cv_epoll=no])]) - -if test "$apr_cv_epoll" = "yes"; then - AC_DEFINE([HAVE_EPOLL], 1, [Define if the epoll interface is supported]) -fi - -dnl ----------------------------- Checking for extended file descriptor handling -# test for epoll_create1 -AC_CACHE_CHECK([for epoll_create1 support], [apr_cv_epoll_create1], -[AC_TRY_RUN([ -#include -#include - -int main() -{ - return epoll_create1(0) == -1; -}], [apr_cv_epoll_create1=yes], [apr_cv_epoll_create1=no], [apr_cv_epoll_create1=no])]) - -if test "$apr_cv_epoll_create1" = "yes"; then - AC_DEFINE([HAVE_EPOLL_CREATE1], 1, [Define if epoll_create1 function is supported]) -fi - -# test for dup3 -AC_CACHE_CHECK([for dup3 support], [apr_cv_dup3], -[AC_TRY_RUN([ -#include - -int main() -{ - return dup3(STDOUT_FILENO, STDERR_FILENO, 0) == -1; -}], [apr_cv_dup3=yes], [apr_cv_dup3=no], [apr_cv_dup3=no])]) - -if test "$apr_cv_dup3" = "yes"; then - AC_DEFINE([HAVE_DUP3], 1, [Define if dup3 function is supported]) -fi - -# test for accept4 -AC_CACHE_CHECK([for accept4 support], [apr_cv_accept4], -[AC_TRY_RUN([ -#include -#include -#include -#include -#include -#include -#include - -#define A4_SOCK "./apr_accept4_test_socket" - -int main() -{ - pid_t pid; - int fd; - struct sockaddr_un loc, rem; - socklen_t rem_sz; - - if ((pid = fork())) { - int status; - - unlink(A4_SOCK); - - if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) - goto cleanup_failure2; - - loc.sun_family = AF_UNIX; - strncpy(loc.sun_path, A4_SOCK, sizeof(loc.sun_path) - 1); - - if (bind(fd, (struct sockaddr *) &loc, - sizeof(struct sockaddr_un)) == -1) - goto cleanup_failure; - - if (listen(fd, 5) == -1) - goto cleanup_failure; - - rem_sz = sizeof(struct sockaddr_un); - if (accept4(fd, (struct sockaddr *) &rem, &rem_sz, 0) == -1) { - goto cleanup_failure; - } - else { - close(fd); - waitpid(pid, &status, 0); - unlink(A4_SOCK); - return 0; - } - -cleanup_failure: - close(fd); -cleanup_failure2: - kill(pid, SIGKILL); - waitpid(pid, &status, 0); - unlink(A4_SOCK); - return 1; - } - else { - if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) - return 1; /* this will be bad: we'll hang */ - - loc.sun_family = AF_UNIX; - strncpy(loc.sun_path, A4_SOCK, sizeof(loc.sun_path) - 1); - - while(connect(fd, (struct sockaddr *) &loc, - sizeof(struct sockaddr_un)) == -1 && - (errno==ENOENT || errno==ECONNREFUSED)) - ; - - close(fd); - return 0; - } -}], [apr_cv_accept4=yes], [apr_cv_accept4=no], [apr_cv_accept4=no])]) - -if test "$apr_cv_accept4" = "yes"; then - AC_DEFINE([HAVE_ACCEPT4], 1, [Define if accept4 function is supported]) -fi - -AC_CACHE_CHECK([for SOCK_CLOEXEC support], [apr_cv_sock_cloexec], -[AC_TRY_RUN([ -#include -#include - -int main() -{ - return socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0) == -1; -}], [apr_cv_sock_cloexec=yes], [apr_cv_sock_cloexec=no], [apr_cv_sock_cloexec=no])]) - -if test "$apr_cv_sock_cloexec" = "yes"; then - AC_DEFINE([HAVE_SOCK_CLOEXEC], 1, [Define if the SOCK_CLOEXEC flag is supported]) -fi - -dnl ----------------------------- Checking for fdatasync: OS X doesn't have it -AC_CHECK_FUNCS(fdatasync) - -dnl ----------------------------- Checking for extended file descriptor handling -# test for epoll_create1 -AC_CACHE_CHECK([for epoll_create1 support], [apr_cv_epoll_create1], -[AC_TRY_RUN([ -#include -#include - -int main() -{ - return epoll_create1(0) == -1; -}], [apr_cv_epoll_create1=yes], [apr_cv_epoll_create1=no], [apr_cv_epoll_create1=no])]) - -if test "$apr_cv_epoll_create1" = "yes"; then - AC_DEFINE([HAVE_EPOLL_CREATE1], 1, [Define if epoll_create1 function is supported]) -fi - -# test for dup3 -AC_CACHE_CHECK([for dup3 support], [apr_cv_dup3], -[AC_TRY_RUN([ -#include - -int main() -{ - return dup3(STDOUT_FILENO, STDERR_FILENO, 0) == -1; -}], [apr_cv_dup3=yes], [apr_cv_dup3=no], [apr_cv_dup3=no])]) - -if test "$apr_cv_dup3" = "yes"; then - AC_DEFINE([HAVE_DUP3], 1, [Define if dup3 function is supported]) -fi - -# test for accept4 -AC_CACHE_CHECK([for accept4 support], [apr_cv_accept4], -[AC_TRY_RUN([ -#include -#include -#include -#include -#include -#include -#include - -#define A4_SOCK "./apr_accept4_test_socket" - -int main() -{ - pid_t pid; - int fd; - struct sockaddr_un loc, rem; - socklen_t rem_sz; - - if ((pid = fork())) { - int status; - - unlink(A4_SOCK); - - if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) - goto cleanup_failure2; - - loc.sun_family = AF_UNIX; - strncpy(loc.sun_path, A4_SOCK, sizeof(loc.sun_path) - 1); - - if (bind(fd, (struct sockaddr *) &loc, - sizeof(struct sockaddr_un)) == -1) - goto cleanup_failure; - - if (listen(fd, 5) == -1) - goto cleanup_failure; - - rem_sz = sizeof(struct sockaddr_un); - if (accept4(fd, (struct sockaddr *) &rem, &rem_sz, 0) == -1) { - goto cleanup_failure; - } - else { - close(fd); - waitpid(pid, &status, 0); - unlink(A4_SOCK); - return 0; - } - -cleanup_failure: - close(fd); -cleanup_failure2: - kill(pid, SIGKILL); - waitpid(pid, &status, 0); - unlink(A4_SOCK); - return 1; - } - else { - if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) - return 1; /* this will be bad: we'll hang */ - - loc.sun_family = AF_UNIX; - strncpy(loc.sun_path, A4_SOCK, sizeof(loc.sun_path) - 1); - - while(connect(fd, (struct sockaddr *) &loc, - sizeof(struct sockaddr_un)) == -1 && - (errno==ENOENT || errno==ECONNREFUSED)) - ; - - close(fd); - return 0; - } -}], [apr_cv_accept4=yes], [apr_cv_accept4=no], [apr_cv_accept4=no])]) - -if test "$apr_cv_accept4" = "yes"; then - AC_DEFINE([HAVE_ACCEPT4], 1, [Define if accept4 function is supported]) -fi - -AC_CACHE_CHECK([for SOCK_CLOEXEC support], [apr_cv_sock_cloexec], -[AC_TRY_RUN([ -#include -#include - -int main() -{ - return socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0) == -1; -}], [apr_cv_sock_cloexec=yes], [apr_cv_sock_cloexec=no], [apr_cv_sock_cloexec=no])]) - -if test "$apr_cv_sock_cloexec" = "yes"; then - AC_DEFINE([HAVE_SOCK_CLOEXEC], 1, [Define if the SOCK_CLOEXEC flag is supported]) -fi - -dnl ----------------------------- Checking for missing POSIX thread functions -AC_CHECK_FUNCS([getpwnam_r getpwuid_r getgrnam_r getgrgid_r]) - -dnl ----------------------------- Checking for Shared Memory Support -echo "${nl}Checking for Shared Memory Support..." - -# The real-time POSIX extensions (e.g. shm_*, sem_*) may only -# be available if linking against librt. -AC_SEARCH_LIBS(shm_open, rt) - -case $host in - *-sysv*) - ac_includes_default="$ac_includes_default -#if HAVE_SYS_MUTEX_H /* needed to define lock_t for sys/shm.h */ -# include -#endif";; -esac - -AC_CHECK_HEADERS([sys/types.h sys/mman.h sys/ipc.h sys/mutex.h sys/shm.h sys/file.h kernel/OS.h os2.h windows.h]) -AC_CHECK_FUNCS([mmap munmap shm_open shm_unlink shmget shmat shmdt shmctl \ - create_area]) - -APR_CHECK_DEFINE(MAP_ANON, sys/mman.h) -AC_CHECK_FILE(/dev/zero) - -# Not all systems can mmap /dev/zero (such as HP-UX). Check for that. -if test "$ac_cv_func_mmap" = "yes" && - test "$ac_cv_file__dev_zero" = "yes"; then - AC_MSG_CHECKING(for mmap that can map /dev/zero) - AC_TRY_RUN([ -#include -#include -#include -#ifdef HAVE_SYS_MMAN_H -#include -#endif - int main() - { - int fd; - void *m; - fd = open("/dev/zero", O_RDWR); - if (fd < 0) { - return 1; - } - m = mmap(0, sizeof(void*), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); - if (m == (void *)-1) { /* aka MAP_FAILED */ - return 2; - } - if (munmap(m, sizeof(void*)) < 0) { - return 3; - } - return 0; - }], [], [ac_cv_file__dev_zero=no], [ac_cv_file__dev_zero=no]) - - AC_MSG_RESULT($ac_cv_file__dev_zero) -fi - -# Now we determine which one is our anonymous shmem preference. -haveshmgetanon="0" -havemmapzero="0" -havemmapanon="0" -APR_BEGIN_DECISION([anonymous shared memory allocation method]) -APR_IFALLYES(header:sys/ipc.h header:sys/shm.h header:sys/file.h dnl - func:shmget func:shmat func:shmdt func:shmctl, - [haveshmgetanon="1" - APR_DECIDE(USE_SHMEM_SHMGET_ANON, [SysV IPC shmget()])]) -APR_IFALLYES(header:sys/mman.h func:mmap func:munmap file:/dev/zero, - [havemmapzero="1" - APR_DECIDE(USE_SHMEM_MMAP_ZERO, - [SVR4-style mmap() on /dev/zero])]) -APR_IFALLYES(header:sys/mman.h func:mmap func:munmap define:MAP_ANON, - [havemmapanon="1" - APR_DECIDE(USE_SHMEM_MMAP_ANON, - [4.4BSD-style mmap() via MAP_ANON])]) -APR_IFALLYES(header:os2.h, - [haveos2shm="1" - APR_DECIDE(USE_SHMEM_OS2_ANON, [OS/2 DosAllocSharedMem()])]) -APR_IFALLYES(header:kernel/OS.h func:create_area, - [havebeosshm="1" - APR_DECIDE(USE_SHMEM_BEOS_ANON, - [BeOS areas])]) -APR_IFALLYES(header:windows.h func:CreateFileMapping, - [havewin32shm="1" - APR_DECIDE(USE_SHMEM_WIN32_ANON, - [Windows CreateFileMapping()])]) -case $host in - *linux* ) - # Linux has problems with MM_SHMT_MMANON even though it reports - # that it has it. - # FIXME - find exact 2.3 version that MMANON was fixed in. It is - # confirmed fixed in 2.4 series. - if test $os_version -le "240"; then - APR_DECISION_OVERRIDE(USE_SHMEM_MMAP_ZERO USE_SHMEM_SHMGET_ANON) - fi - ;; - *hpux11* ) - APR_DECISION_OVERRIDE(USE_SHMEM_SHMGET_ANON) - ;; -esac -APR_END_DECISION -AC_DEFINE_UNQUOTED($ac_decision) - -useshmgetanon="0" -usemmapzero="0" -usemmapanon="0" - -case $ac_decision in - USE_SHMEM_SHMGET_ANON ) - useshmgetanon="1" - ;; - USE_SHMEM_MMAP_ZERO ) - usemmapzero="1" - ;; - USE_SHMEM_MMAP_ANON ) - usemmapanon="1" - ;; -esac - -AC_SUBST(useshmgetanon) -AC_SUBST(usemmapzero) -AC_SUBST(usemmapanon) -AC_SUBST(haveshmgetanon) -AC_SUBST(havemmapzero) -AC_SUBST(havemmapanon) - -# Now we determine which one is our name-based shmem preference. -havemmaptmp="0" -havemmapshm="0" -haveshmget="0" -havebeosarea="0" -haveos2shm="0" -havewin32shm="0" -APR_BEGIN_DECISION([namebased memory allocation method]) -APR_IFALLYES(header:sys/mman.h func:mmap func:munmap, - [havemmaptmp="1" - APR_DECIDE(USE_SHMEM_MMAP_TMP, - [Classical mmap() on temporary file])]) -APR_IFALLYES(header:sys/mman.h func:mmap func:munmap func:shm_open dnl - func:shm_unlink, - [havemmapshm="1" - APR_DECIDE(USE_SHMEM_MMAP_SHM, - [mmap() via POSIX.1 shm_open() on temporary file])]) -APR_IFALLYES(header:sys/ipc.h header:sys/shm.h header:sys/file.h dnl - func:shmget func:shmat func:shmdt func:shmctl, - [haveshmget="1" - APR_DECIDE(USE_SHMEM_SHMGET, [SysV IPC shmget()])]) -APR_IFALLYES(header:kernel/OS.h func:create_area, - [havebeosshm="1" - APR_DECIDE(USE_SHMEM_BEOS, [BeOS areas])]) -APR_IFALLYES(header:os2.h, - [haveos2shm="1" - APR_DECIDE(USE_SHMEM_OS2, [OS/2 DosAllocSharedMem()])]) -APR_IFALLYES(header:windows.h, - [havewin32shm="1" - APR_DECIDE(USE_SHMEM_WIN32, [Windows shared memory])]) -case $host in - *linux* ) - # Linux has problems with MM_SHMT_MMANON even though it reports - # that it has it. - # FIXME - find exact 2.3 version that MMANON was fixed in. It is - # confirmed fixed in 2.4 series. - if test $os_version -le "240"; then - APR_DECISION_OVERRIDE(USE_SHMEM_MMAP_TMP USE_SHMEM_MMAP_SHM dnl - USE_SHMEM_SHMGET) - fi - ;; -esac -APR_END_DECISION -AC_DEFINE_UNQUOTED($ac_decision) - -usemmaptmp="0" -usemmapshm="0" -useshmget="0" -usebeosarea="0" -useos2shm="0" -usewin32shm="0" - -case $ac_decision in - USE_SHMEM_MMAP_TMP ) - usemmaptmp="1" - ;; - USE_SHMEM_MMAP_SHM ) - usemmapshm="1" - ;; - USE_SHMEM_SHMGET ) - useshmget="1" - ;; - USE_SHMEM_BEOS ) - usebeosarea="1" - ;; - USE_SHMEM_OS2 ) - useos2shm="1" - ;; - USE_SHMEM_WIN32 ) - usewin32shm="1" - ;; -esac - -# Do we have any shared memory support? -if test "$usemmaptmp$usemmapshm$usemmapzero$useshmget$usemmapanon$usebeosarea$useos2shm$usewin32shm" = "00000000"; then - sharedmem="0" -else - sharedmem="1" -fi - -AC_SUBST(usemmaptmp) -AC_SUBST(usemmapshm) -AC_SUBST(useshmget) -AC_SUBST(usebeosarea) -AC_SUBST(useos2shm) -AC_SUBST(usewin32shm) -AC_SUBST(havemmaptmp) -AC_SUBST(havemmapshm) -AC_SUBST(haveshmget) -AC_SUBST(havebeosarea) -AC_SUBST(haveos2shm) -AC_SUBST(havewin32shm) -AC_SUBST(sharedmem) - -dnl ----------------------------- Checks for Any required Functions -dnl Checks for library functions. (N.B. poll is further down) - -AC_FUNC_ALLOCA - -AC_CHECK_FUNCS([calloc setsid isinf isnan \ - getenv putenv setenv unsetenv \ - writev getifaddrs utime utimes]) -AC_CHECK_FUNCS(setrlimit, [ have_setrlimit="1" ], [ have_setrlimit="0" ]) -AC_CHECK_FUNCS(getrlimit, [ have_getrlimit="1" ], [ have_getrlimit="0" ]) -sendfile="0" -AC_CHECK_LIB(sendfile, sendfilev) -AC_CHECK_FUNCS(sendfile send_file sendfilev, [ sendfile="1" ]) - -dnl THIS MUST COME AFTER THE THREAD TESTS - FreeBSD doesn't always have a -dnl threaded poll() and we don't want to use sendfile on early FreeBSD -dnl systems if we are also using threads. - -AC_ARG_WITH(sendfile, [ --with-sendfile Override decision to use sendfile], - [ if test "$withval" = "yes"; then - sendfile="1" - else - sendfile="0" - fi ], [ - orig_sendfile=$sendfile - case $host in - *freebsd*) - # FreeBSD < 4.2 has issues with threads+sendfile - if test $os_version -le "401999"; then - if test "$threads" = "1"; then - sendfile="0" - fi - fi - ;; - *alpha*-dec-osf* ) - sendfile="0" - ;; - s390-*-linux-gnu) - # disable sendfile support for 2.2 on S/390 - if test $os_version -lt 240; then - sendfile="0" - fi - ;; - *aix*) - # compiler-independent check for 64-bit build - AC_CHECK_SIZEOF(void*, 4) - if test "x$ac_cv_sizeof_voidp" = "x8"; then - # sendfile not working for 64-bit build - sendfile="0" - fi - ;; - esac - if test "$orig_sendfile" != "$sendfile"; then - echo "sendfile support disabled to avoid system problem" - fi ] ) -AC_SUBST(sendfile) - -AC_CHECK_FUNCS(sigaction, [ have_sigaction="1" ], [ have_sigaction="0" ]) -AC_DECL_SYS_SIGLIST - -AC_CHECK_FUNCS(fork, [ fork="1" ], [ fork="0" ]) -APR_CHECK_INET_ADDR -APR_CHECK_INET_NETWORK -AC_SUBST(apr_inaddr_none) -AC_CHECK_FUNC(_getch) -AC_CHECK_FUNCS(strerror_r, [ strerror_r="1" ], [ strerror_r="0" ]) -if test "$strerror_r" = "1"; then - APR_CHECK_STRERROR_R_RC -fi -AC_CHECK_FUNCS(mmap, [ mmap="1" ], [ mmap="0" ]) -if test "$native_mmap_emul" = "1"; then - mmap="1" -fi -AC_CHECK_FUNCS(memmove, [ have_memmove="1" ], [have_memmove="0" ]) -AC_CHECK_FUNCS([getpass getpassphrase gmtime_r localtime_r mkstemp]) - -AC_SUBST(fork) -AC_SUBST(have_inet_addr) -AC_SUBST(tcp_nodelay_inherited) -AC_SUBST(o_nonblock_inherited) -AC_SUBST(have_inet_network) -AC_SUBST(have_sigaction) -AC_SUBST(have_setrlimit) -AC_SUBST(have_getrlimit) -AC_SUBST(mmap) -AC_SUBST(have_memmove) - -APR_CHECK_SIGWAIT_ONE_ARG - -dnl ----------------------------- Checks for Any required Headers -AC_HEADER_STDC - -APR_FLAG_HEADERS( - ByteOrder.h \ - conio.h \ - crypt.h \ - ctype.h \ - dir.h \ - dirent.h \ - dl.h \ - dlfcn.h \ - errno.h \ - fcntl.h \ - grp.h \ - io.h \ - limits.h \ - mach-o/dyld.h \ - malloc.h \ - memory.h \ - netdb.h \ - osreldate.h \ - poll.h \ - process.h \ - pwd.h \ - semaphore.h \ - signal.h \ - stdarg.h \ - stddef.h \ - stdio.h \ - stdlib.h \ - string.h \ - strings.h \ - sysapi.h \ - sysgtime.h \ - termios.h \ - time.h \ - tpfeq.h \ - tpfio.h \ - unistd.h \ - unix.h \ - windows.h \ - winsock2.h \ - arpa/inet.h \ - kernel/OS.h \ - net/errno.h \ - netinet/in.h \ - netinet/sctp.h \ - netinet/sctp_uio.h \ - sys/file.h \ - sys/ioctl.h \ - sys/mman.h \ - sys/param.h \ - sys/poll.h \ - sys/resource.h \ - sys/select.h \ - sys/sem.h \ - sys/sendfile.h \ - sys/signal.h \ - sys/socket.h \ - sys/sockio.h \ - sys/stat.h \ - sys/sysctl.h \ - sys/syslimits.h \ - sys/time.h \ - sys/types.h \ - sys/uio.h \ - sys/un.h \ - sys/wait.h) - -# IRIX 6.5 has a problem in which prevents it from -# being included by itself. Check for manually, -# including another header file first. -AC_CACHE_CHECK([for netinet/tcp.h], [apr_cv_hdr_netinet_tcp_h], -[AC_TRY_CPP( -[#ifdef HAVE_NETINET_IN_H -#include -#endif -#include -], [apr_cv_hdr_netinet_tcp_h=yes], [apr_cv_hdr_netinet_tcp_h=no])]) -if test "$apr_cv_hdr_netinet_tcp_h" = "yes"; then - netinet_tcph=1 - AC_DEFINE([HAVE_NETINET_TCP_H], 1, [Defined if netinet/tcp.h is present]) -else - netinet_tcph=0 -fi - -AC_SUBST(arpa_ineth) -AC_SUBST(conioh) -AC_SUBST(ctypeh) -AC_SUBST(crypth) -AC_SUBST(errnoh) -AC_SUBST(direnth) -AC_SUBST(fcntlh) -AC_SUBST(ioh) -AC_SUBST(limitsh) -AC_SUBST(netdbh) -AC_SUBST(sys_syslimitsh) -AC_SUBST(netinet_inh) -AC_SUBST(netinet_sctph) -AC_SUBST(netinet_sctp_uioh) -AC_SUBST(netinet_tcph) -AC_SUBST(stdargh) -AC_SUBST(stdioh) -AC_SUBST(stdlibh) -AC_SUBST(stringh) -AC_SUBST(stringsh) -AC_SUBST(sys_ioctlh) -AC_SUBST(sys_sendfileh) -AC_SUBST(sys_signalh) -AC_SUBST(sys_socketh) -AC_SUBST(sys_sockioh) -AC_SUBST(sys_typesh) -AC_SUBST(sys_timeh) -AC_SUBST(sys_uioh) -AC_SUBST(sys_unh) -AC_SUBST(timeh) -AC_SUBST(unistdh) -AC_SUBST(signalh) -AC_SUBST(sys_waith) -AC_SUBST(processh) -AC_SUBST(pthreadh) -AC_SUBST(semaphoreh) -AC_SUBST(windowsh) -AC_SUBST(winsock2h) - -# Checking for h_errno in -if test "$netdbh" = "1"; then - APR_CHECK_H_ERRNO_FLAG - if test "$ac_cv_h_errno_cflags" = "no"; then - AC_MSG_ERROR([can not find h_errno in netdb.h]) - fi -fi - -AC_ARG_ENABLE(allocator-uses-mmap, - [ --enable-allocator-uses-mmap Use mmap in apr_allocator instead of malloc (experimental)], - [ if test "$enableval" = "yes"; then - APR_IFALLYES(header:sys/mman.h func:mmap func:munmap define:MAP_ANON, - [AC_DEFINE(APR_ALLOCATOR_USES_MMAP, 1, - [Define if apr_allocator should use mmap]) ], - [AC_MSG_ERROR([mmap()/MAP_ANON not supported]) ] - ) - fi ] -) - -dnl ----------------------------- Checks for standard typedefs -AC_TYPE_OFF_T -AC_TYPE_PID_T -AC_TYPE_SIZE_T -AC_TYPE_UID_T -AC_CHECK_TYPE(ssize_t, int) -AC_C_INLINE -AC_C_CONST -AC_FUNC_SETPGRP - -APR_CHECK_SOCKLEN_T - -dnl Checks for pointer size -AC_CHECK_SIZEOF(void*, 4) - -if test "x$ac_cv_sizeof_voidp" != "x"; then - voidp_size=$ac_cv_sizeof_voidp -else - AC_ERROR([Cannot determine size of void*]) -fi - -dnl Checks for integer size -AC_CHECK_SIZEOF(char, 1) -AC_CHECK_SIZEOF(int, 4) -AC_CHECK_SIZEOF(long, 4) -AC_CHECK_SIZEOF(short, 2) -AC_CHECK_SIZEOF(long long, 8) - -if test "$ac_cv_sizeof_short" = "2"; then - short_value=short -fi -if test "$ac_cv_sizeof_int" = "4"; then - int_value=int -fi -# Now we need to find what apr_int64_t (sizeof == 8) will be. -# The first match is our preference. -if test "$ac_cv_sizeof_int" = "8"; then - int64_literal='#define APR_INT64_C(val) (val)' - uint64_literal='#define APR_UINT64_C(val) (val##U)' - int64_t_fmt='#define APR_INT64_T_FMT "d"' - uint64_t_fmt='#define APR_UINT64_T_FMT "u"' - uint64_t_hex_fmt='#define APR_UINT64_T_HEX_FMT "x"' - int64_value="int" - long_value=int - int64_strfn="strtoi" -elif test "$ac_cv_sizeof_long" = "8"; then - int64_literal='#define APR_INT64_C(val) (val##L)' - uint64_literal='#define APR_UINT64_C(val) (val##UL)' - int64_t_fmt='#define APR_INT64_T_FMT "ld"' - uint64_t_fmt='#define APR_UINT64_T_FMT "lu"' - uint64_t_hex_fmt='#define APR_UINT64_T_HEX_FMT "lx"' - int64_value="long" - long_value=long - int64_strfn="strtol" -elif test "$ac_cv_sizeof_long_long" = "8"; then - int64_literal='#define APR_INT64_C(val) (val##LL)' - uint64_literal='#define APR_UINT64_C(val) (val##ULL)' - # Linux, Solaris, FreeBSD all support ll with printf. - # BSD 4.4 originated 'q'. Solaris is more popular and - # doesn't support 'q'. Solaris wins. Exceptions can - # go to the OS-dependent section. - int64_t_fmt='#define APR_INT64_T_FMT "lld"' - uint64_t_fmt='#define APR_UINT64_T_FMT "llu"' - uint64_t_hex_fmt='#define APR_UINT64_T_HEX_FMT "llx"' - int64_value="long long" - long_value="long long" - int64_strfn="strtoll" -elif test "$ac_cv_sizeof_longlong" = "8"; then - int64_literal='#define APR_INT64_C(val) (val##LL)' - uint64_literal='#define APR_UINT64_C(val) (val##ULL)' - int64_t_fmt='#define APR_INT64_T_FMT "qd"' - uint64_t_fmt='#define APR_UINT64_T_FMT "qu"' - uint64_t_hex_fmt='#define APR_UINT64_T_HEX_FMT "qx"' - int64_value="__int64" - long_value="__int64" - int64_strfn="strtoll" -else - # int64_literal may be overriden if your compiler thinks you have - # a 64-bit value but APR does not agree. - AC_ERROR([could not detect a 64-bit integer type]) -fi - -# If present, allow the C99 macro INT64_C to override our conversion. -# -# HP-UX's ANSI C compiler provides this without any includes, so we -# will first look for INT64_C without adding stdint.h -AC_CACHE_CHECK([for INT64_C], [apr_cv_define_INT64_C], [ -AC_EGREP_CPP(YES_IS_DEFINED, -[#ifdef INT64_C -YES_IS_DEFINED -#endif], [apr_cv_define_INT64_C=yes], [ - # Now check for INT64_C in stdint.h - AC_EGREP_CPP(YES_IS_DEFINED, [#include -#ifdef INT64_C -YES_IS_DEFINED -#endif], [apr_cv_define_INT64_C=yes], [apr_cv_define_INT64_C=no])])]) - -if test "$apr_cv_define_INT64_C" = "yes"; then - int64_literal='#define APR_INT64_C(val) INT64_C(val)' - uint64_literal='#define APR_UINT64_C(val) UINT64_C(val)' - stdint=1 -else - stdint=0 -fi - -if test "$ac_cv_type_size_t" = "yes"; then - size_t_value="size_t" -else - size_t_value="apr_int32_t" -fi -if test "$ac_cv_type_ssize_t" = "yes"; then - ssize_t_value="ssize_t" -else - ssize_t_value="apr_int32_t" -fi -if test "$ac_cv_socklen_t" = "yes"; then - socklen_t_value="socklen_t" - case $host in - *-hp-hpux*) - if test "$ac_cv_sizeof_long" = "8"; then - # 64-bit HP-UX requires 32-bit socklens in - # kernel, but user-space declarations say - # 64-bit (socklen_t == size_t == long). - # This will result in many compile warnings, - # but we're functionally busted otherwise. - socklen_t_value="int" - fi - ;; - esac -else - socklen_t_value="int" -fi - -APR_CHECK_SIZEOF_EXTENDED([#include ], pid_t, 8) - -if test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_short"; then - pid_t_fmt='#define APR_PID_T_FMT "hd"' -elif test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_int"; then - pid_t_fmt='#define APR_PID_T_FMT "d"' -elif test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_long"; then - pid_t_fmt='#define APR_PID_T_FMT "ld"' -elif test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_long_long"; then - pid_t_fmt='#define APR_PID_T_FMT APR_INT64_T_FMT' -else - pid_t_fmt='#error Can not determine the proper size for pid_t' -fi - -# Basically, we have tried to figure out the correct format strings -# for APR types which vary between platforms, but we don't always get -# it right. -case $host in - s390*linux*) - # uniquely, the 31-bit Linux/s390 uses "unsigned long int" - # for size_t rather than "unsigned int": - size_t_fmt="lu" - ssize_t_fmt="ld" - ;; - *-os2*) - size_t_fmt="lu" - ;; - *-solaris*) - if test "$ac_cv_sizeof_long" = "8"; then - pid_t_fmt='#define APR_PID_T_FMT "d"' - else - pid_t_fmt='#define APR_PID_T_FMT "ld"' - fi - ;; - *aix4*|*aix5*) - ssize_t_fmt="ld" - size_t_fmt="lu" - ;; - *beos*) - ssize_t_fmt="ld" - size_t_fmt="ld" - ;; - *apple-darwin*) - osver=`uname -r` - case $osver in - [[0-7]].*) - ssize_t_fmt="d" - ;; - *) - ssize_t_fmt="ld" - ;; - esac - size_t_fmt="lu" - ;; - *-mingw*) - int64_t_fmt='#define APR_INT64_T_FMT "I64d"' - uint64_t_fmt='#define APR_UINT64_T_FMT "I64u"' - uint64_t_hex_fmt='#define APR_UINT64_T_HEX_FMT "I64x"' - int64_value="__int64" - long_value="__int64" - int64_strfn="_strtoi64" - ;; -esac - -APR_CHECK_TYPES_COMPATIBLE(ssize_t, int, [ssize_t_fmt="d"]) -APR_CHECK_TYPES_COMPATIBLE(ssize_t, long, [ssize_t_fmt="ld"]) -APR_CHECK_TYPES_COMPATIBLE(size_t, unsigned int, [size_t_fmt="u"]) -APR_CHECK_TYPES_COMPATIBLE(size_t, unsigned long, [size_t_fmt="lu"]) - -APR_CHECK_SIZEOF_EXTENDED([#include ], ssize_t, 8) - -AC_MSG_CHECKING([which format to use for apr_ssize_t]) -if test -n "$ssize_t_fmt"; then - AC_MSG_RESULT(%$ssize_t_fmt) -elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_int"; then - ssize_t_fmt="d" - AC_MSG_RESULT(%d) -elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_long"; then - ssize_t_fmt="ld" - AC_MSG_RESULT(%ld) -else - AC_ERROR([could not determine the proper format for apr_ssize_t]) -fi - -ssize_t_fmt="#define APR_SSIZE_T_FMT \"$ssize_t_fmt\"" - -APR_CHECK_SIZEOF_EXTENDED([#include ], size_t, 8) - -AC_MSG_CHECKING([which format to use for apr_size_t]) -if test -n "$size_t_fmt"; then - AC_MSG_RESULT(%$size_t_fmt) -elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_int"; then - size_t_fmt="d" - AC_MSG_RESULT(%d) -elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_long"; then - size_t_fmt="ld" - AC_MSG_RESULT(%ld) -else - AC_ERROR([could not determine the proper format for apr_size_t]) -fi - -size_t_fmt="#define APR_SIZE_T_FMT \"$size_t_fmt\"" - -APR_CHECK_SIZEOF_EXTENDED([#include ], off_t, 8) - -if test "${ac_cv_sizeof_off_t}${apr_cv_use_lfs64}" = "4yes"; then - # Enable LFS - aprlfs=1 - AC_CHECK_FUNCS([mmap64 sendfile64 sendfilev64 mkstemp64 readdir64_r]) -elif test "${ac_cv_sizeof_off_t}" != "${ac_cv_sizeof_size_t}"; then - # unsure of using -gt above is as portable, can can't forsee where - # off_t can legitimately be smaller than size_t - aprlfs=1 -else - aprlfs=0 -fi - -AC_MSG_CHECKING([which type to use for apr_off_t]) -if test "${ac_cv_sizeof_off_t}${apr_cv_use_lfs64}" = "4yes"; then - # LFS is go! - off_t_fmt='#define APR_OFF_T_FMT APR_INT64_T_FMT' - off_t_value='off64_t' - off_t_strfn='apr_strtoi64' -elif test "${ac_cv_sizeof_off_t}x${ac_cv_sizeof_long}" = "4x4"; then - # Special case: off_t may change size with _FILE_OFFSET_BITS - # on 32-bit systems with LFS support. To avoid compatibility - # issues when other packages do define _FILE_OFFSET_BITS, - # hard-code apr_off_t to long. - off_t_value=long - off_t_fmt='#define APR_OFF_T_FMT "ld"' - off_t_strfn='strtol' -elif test "$ac_cv_type_off_t" = "yes"; then - off_t_value=off_t - # off_t is more commonly a long than an int; prefer that case - # where int and long are the same size. - if test "$ac_cv_sizeof_off_t" = "$ac_cv_sizeof_long"; then - off_t_fmt='#define APR_OFF_T_FMT "ld"' - off_t_strfn='strtol' - elif test "$ac_cv_sizeof_off_t" = "$ac_cv_sizeof_int"; then - off_t_fmt='#define APR_OFF_T_FMT "d"' - off_t_strfn='strtoi' - elif test "$ac_cv_sizeof_off_t" = "$ac_cv_sizeof_long_long"; then - off_t_fmt='#define APR_OFF_T_FMT APR_INT64_T_FMT' - off_t_strfn='apr_strtoi64' - else - AC_ERROR([could not determine the size of off_t]) - fi - # Per OS tuning... - case $host in - *-mingw*) - off_t_value=apr_int64_t - off_t_fmt='#define APR_OFF_T_FMT "I64d"' - off_t_strfn='_strtoi64' - ;; - esac -else - # Fallback on int - off_t_value=apr_int32_t - off_t_fmt=d - off_t_strfn='strtoi' -fi -AC_MSG_RESULT($off_t_value) - -# Regardless of whether _LARGEFILE64_SOURCE is used, on some -# platforms _FILE_OFFSET_BITS will affect the size of ino_t and hence -# the build-time ABI may be different from the apparent ABI when using -# APR with another package which *does* define _FILE_OFFSET_BITS. -# (Exactly as per the case above with off_t where LFS is *not* used) -# -# To be safe, hard-code apr_ino_t as 'unsigned long' or 'unsigned int' -# iff that is exactly the size of ino_t here; otherwise use ino_t as existing -# releases did. To be correct, apr_ino_t should have been made an -# ino64_t as apr_off_t is off64_t, but this can't be done now without -# breaking ABI. - -# Per OS tuning... -case $host in -*mingw*) - ino_t_value=apr_int64_t - ;; -*) - ino_t_value=ino_t - APR_CHECK_SIZEOF_EXTENDED(AC_INCLUDES_DEFAULT, ino_t, $ac_cv_sizeof_long) - if test $ac_cv_sizeof_ino_t = 4; then - if test $ac_cv_sizeof_long = 4; then - ino_t_value="unsigned long" - else - ino_t_value="unsigned int" - fi - fi - ;; -esac -AC_MSG_NOTICE([using $ino_t_value for ino_t]) - -# Checks for endianness -AC_C_BIGENDIAN -if test $ac_cv_c_bigendian = yes; then - bigendian=1 -else - bigendian=0 -fi - -APR_CHECK_SIZEOF_EXTENDED([#include -#include ],struct iovec,0) -if test "$ac_cv_sizeof_struct_iovec" = "0"; then - have_iovec=0 -else - have_iovec=1 -fi - -AC_SUBST(voidp_size) -AC_SUBST(short_value) -AC_SUBST(int_value) -AC_SUBST(long_value) -AC_SUBST(int64_value) -AC_SUBST(off_t_value) -AC_SUBST(size_t_value) -AC_SUBST(ssize_t_value) -AC_SUBST(socklen_t_value) -AC_SUBST(int64_t_fmt) -AC_SUBST(uint64_t_fmt) -AC_SUBST(uint64_t_hex_fmt) -AC_SUBST(ssize_t_fmt) -AC_SUBST(size_t_fmt) -AC_SUBST(off_t_fmt) -AC_SUBST(pid_t_fmt) -AC_SUBST(int64_literal) -AC_SUBST(uint64_literal) -AC_SUBST(stdint) -AC_SUBST(bigendian) -AC_SUBST(aprlfs) -AC_SUBST(have_iovec) -AC_SUBST(ino_t_value) - -dnl ----------------------------- Checking for string functions -AC_CHECK_FUNCS(strnicmp, have_strnicmp="1", have_strnicmp="0") -AC_CHECK_FUNCS(strncasecmp, have_strncasecmp="1", have_strncasecmp="0") -AC_CHECK_FUNCS(stricmp, have_stricmp="1", have_stricmp="0") -AC_CHECK_FUNCS(strcasecmp, have_strcasecmp="1", have_strcasecmp="0") -AC_CHECK_FUNCS(strdup, have_strdup="1", have_strdup="0") -AC_CHECK_FUNCS(strstr, have_strstr="1", have_strstr="0") -AC_CHECK_FUNCS(memchr, have_memchr="1", have_memchr="0") -AC_CHECK_FUNC($int64_strfn, have_int64_strfn="1", have_int64_strfn="0") - -dnl ----------------------------- We have a fallback position -if test "$have_int64_strfn" = "0" && test "$int64_strfn" = "strtoll"; then - int64_strfn="strtoq" - AC_CHECK_FUNC(strtoq, [have_int64_strfn=1], [have_int64_strfn=0]) -fi - -if test "$have_int64_strfn" = "1"; then - AC_DEFINE_UNQUOTED(APR_INT64_STRFN, [$int64_strfn], - [Define as function which can be used for conversion of strings to apr_int64_t]) -fi - -AC_SUBST(have_strnicmp) -AC_SUBST(have_strncasecmp) -AC_SUBST(have_stricmp) -AC_SUBST(have_strcasecmp) -AC_SUBST(have_strdup) -AC_SUBST(have_strstr) -AC_SUBST(have_memchr) - -if test "$off_t_strfn" = "apr_strtoi64" && test "$have_int64_strfn" = "1"; then - off_t_strfn=$int64_strfn -fi -AC_DEFINE_UNQUOTED(APR_OFF_T_STRFN, [$off_t_strfn], - [Define as function used for conversion of strings to apr_off_t]) - -dnl ----------------------------- Checking for DSO support -echo "${nl}Checking for DSO..." -AC_ARG_ENABLE(dso, - [ --disable-dso Disable DSO support ], - [if test "x$enableval" = "xyes"; then - dsotype=any - else - dsotype=$enableval - fi - ], [dsotype=any]) - -if test "$dsotype" = "any"; then - if test "$dsotype" = "any"; then - case $host in - *darwin[[0-8]]\.*) - # Original Darwin, not for 9.0!: - AC_CHECK_FUNC(NSLinkModule, [dsotype=dyld]);; - hppa*-hpux[[1-9]]\.*|hppa*-hpux1[[01]]*) - # shl is specific to parisc hpux SOM binaries, not used for 64 bit - AC_CHECK_LIB(dld, shl_load, [have_shl=1]) - if test "$ac_cv_sizeof_voidp$have_shl" = "41"; then - dsotype=shl; APR_ADDTO(LIBS,-ldld) - fi;; - *mingw*|*-os2*) - # several 'other's below probably belong up here. If they always - # use a platform implementation and shouldn't test the dlopen/dlfcn - # features, then bring them up here. - # But if they -should- optionally use dlfcn, and/or need the config - # detection of dlopen/dlsym, do not move them up. - dsotype=other ;; - esac - fi - # Normal POSIX: - if test "$dsotype" = "any"; then - AC_CHECK_FUNC(dlopen, [dsotype=dlfcn]) - fi - if test "$dsotype" = "any"; then - AC_CHECK_LIB(dl, dlopen, [dsotype=dlfcn; APR_ADDTO(LIBS,-ldl)]) - fi - if test "$dsotype" = "dlfcn"; then - # ReliantUnix has dlopen() in libc but dlsym() in libdl :( - AC_CHECK_FUNC(dlsym, [], - [AC_CHECK_LIB(dl, dlsym, - [APR_ADDTO(LIBS, -ldl)], - [dsotype=any - echo "Weird: dlopen() was found but dlsym() was not found!"])]) - fi - if test "$dsotype" = "any"; then - # BeOS: - AC_CHECK_LIB(root, load_image, [dsotype=other]) - fi - # Everything else: - if test "$dsotype" = "any"; then - case $host in - *os390|*os400|*-aix*) - # Some -aix5 will use dl, no hassles. Keep that pattern here. - dsotype=other ;; - *-hpux*) - if test "$have_shl" = "1"; then - dsotype=shl; APR_ADDTO(LIBS,-ldld) - fi;; - esac - fi -fi - -if test "$dsotype" = "any"; then - AC_MSG_ERROR([Could not detect suitable DSO implementation]) -elif test "$dsotype" = "no"; then - aprdso="0" -else - case "$dsotype" in - dlfcn) AC_DEFINE(DSO_USE_DLFCN, 1, [Define if DSO support uses dlfcn.h]);; - shl) AC_DEFINE(DSO_USE_SHL, 1, [Define if DSO support uses shl_load]);; - dyld) AC_DEFINE(DSO_USE_DYLD, 1, [Define if DSO support uses dyld.h]);; - other) ;; # Use whatever is in dso/OSDIR - *) AC_MSG_ERROR([Unknown DSO implementation "$dsotype"]);; - esac - aprdso="1" - apr_modules="$apr_modules dso" -fi - -AC_SUBST(aprdso) - -dnl ----------------------------- Checking for Processes -echo "${nl}Checking for Processes..." - -AC_CHECK_FUNCS(waitpid) - -AC_ARG_ENABLE(other-child, - [ --enable-other-child Enable reliable child processes ], - [ if test "$enableval" = "yes"; then - oc="1" - else - oc="0" - fi ], - [ oc=1 ] ) - -AC_SUBST(oc) - -if test -z "$have_proc_invoked"; then - have_proc_invoked="0" -fi - -AC_SUBST(have_proc_invoked) - -AC_MSG_CHECKING(for Variable Length Arrays) -APR_TRY_COMPILE_NO_WARNING([], -[ - int foo[argc]; - foo[0] = 0; -], vla_msg=yes, vla_msg=no ) -AC_MSG_RESULT([$vla_msg]) -if test "$vla_msg" = "yes"; then - AC_DEFINE(HAVE_VLA, 1, [Define if C compiler supports VLA]) -fi - -AC_CACHE_CHECK(struct rlimit,ac_cv_struct_rlimit,[ -AC_TRY_RUN([ -#include -#include -#include -main() -{ - struct rlimit limit; - limit.rlim_cur = 0; - limit.rlim_max = 0; - exit(0); -}], [ - ac_cv_struct_rlimit=yes ], [ - ac_cv_struct_rlimit=no ], [ - ac_cv_struct_rlimit=no ] ) ] ) -struct_rlimit=0 -test "x$ac_cv_struct_rlimit" = xyes && struct_rlimit=1 -AC_SUBST(struct_rlimit) - -dnl ----------------------------- Checking for Locking Characteristics -echo "${nl}Checking for Locking..." - -AC_CHECK_FUNCS(semget semctl flock) -AC_CHECK_HEADERS(semaphore.h OS.h) -AC_SEARCH_LIBS(sem_open, rt) -AC_CHECK_FUNCS(sem_close sem_unlink sem_post sem_wait create_sem) - -# Some systems return ENOSYS from sem_open. -AC_CACHE_CHECK(for working sem_open,ac_cv_func_sem_open,[ -AC_TRY_RUN([ -#include -#include -#include -#include -#ifndef SEM_FAILED -#define SEM_FAILED (-1) -#endif -main() -{ - sem_t *psem; - const char *sem_name = "/apr_autoconf"; - - psem = sem_open(sem_name, O_CREAT, 0644, 1); - if (psem == (sem_t *)SEM_FAILED) { - exit(1); - } - sem_close(psem); - psem = sem_open(sem_name, O_CREAT | O_EXCL, 0644, 1); - if (psem != (sem_t *)SEM_FAILED) { - sem_close(psem); - exit(1); - } - sem_unlink(sem_name); - exit(0); -}], [ac_cv_func_sem_open=yes], [ac_cv_func_sem_open=no], -[ac_cv_func_sem_open=no])]) - -# It's stupid, but not all platforms have union semun, even those that need it. -AC_MSG_CHECKING(for union semun in sys/sem.h) -AC_TRY_COMPILE([ -#include -#include -#include -],[ -union semun arg; -semctl(0, 0, 0, arg); -], [have_union_semun="1" union_semun=yes ] -msg=yes, [ -have_union_semun="0" -msg=no ] ) -AC_MSG_RESULT([$msg]) -AC_SUBST(have_union_semun) - -dnl Checks for libraries. -APR_CHECK_DEFINE(LOCK_EX, sys/file.h) -APR_CHECK_DEFINE(F_SETLK, fcntl.h) -APR_CHECK_DEFINE(SEM_UNDO, sys/sem.h) - -# We are assuming that if the platform doesn't have POLLIN, it doesn't have -# any POLL definitions. -APR_CHECK_DEFINE_FILES(POLLIN, poll.h sys/poll.h) - -if test "$threads" = "1"; then - APR_CHECK_DEFINE(PTHREAD_PROCESS_SHARED, pthread.h) - AC_CHECK_FUNCS(pthread_mutexattr_setpshared) - # Some systems have setpshared and define PROCESS_SHARED, but don't - # really support PROCESS_SHARED locks. So, we must validate that we - # can go through the steps without receiving some sort of system error. - # Linux and older versions of AIX have this problem. - APR_IFALLYES(header:pthread.h define:PTHREAD_PROCESS_SHARED func:pthread_mutexattr_setpshared, [ - AC_CACHE_CHECK([for working PROCESS_SHARED locks], apr_cv_process_shared_works, [ - AC_TRY_RUN([ -#include -#include - int main() - { - pthread_mutex_t mutex; - pthread_mutexattr_t attr; - if (pthread_mutexattr_init(&attr)) - exit(1); - if (pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED)) - exit(2); - if (pthread_mutex_init(&mutex, &attr)) - exit(3); - if (pthread_mutexattr_destroy(&attr)) - exit(4); - if (pthread_mutex_destroy(&mutex)) - exit(5); - exit(0); - }], [apr_cv_process_shared_works=yes], [apr_cv_process_shared_works=no])]) - # Override detection of pthread_mutexattr_setpshared - ac_cv_func_pthread_mutexattr_setpshared=$apr_cv_process_shared_works]) - - if test "$ac_cv_func_pthread_mutexattr_setpshared" = "yes"; then - APR_CHECK_PTHREAD_ROBUST_SHARED_MUTEX - fi -fi - -# See which lock mechanisms we can support on this system. -APR_IFALLYES(header:semaphore.h func:sem_open func:sem_close dnl - func:sem_unlink func:sem_post func:sem_wait, - hasposixser="1", hasposixser="0") -APR_IFALLYES(func:semget func:semctl define:SEM_UNDO, hassysvser="1", - hassysvser="0") -APR_IFALLYES(func:flock define:LOCK_EX, hasflockser="1", hasflockser="0") -APR_IFALLYES(header:fcntl.h define:F_SETLK, hasfcntlser="1", hasfcntlser="0") -# note: the current APR use of shared mutex requires /dev/zero -APR_IFALLYES(header:pthread.h define:PTHREAD_PROCESS_SHARED dnl - func:pthread_mutexattr_setpshared dnl - file:/dev/zero, - hasprocpthreadser="1", hasprocpthreadser="0") -APR_IFALLYES(header:OS.h func:create_sem, hasbeossem="1", hasbeossem="0") - -# See which lock mechanism we'll select by default on this system. -# The last APR_DECIDE to execute sets the default. -# At this stage, we match the ordering in Apache 1.3 -# which is (highest to lowest): sysvsem -> fcntl -> flock. -# POSIX semaphores and cross-process pthread mutexes are not -# used by default since they have less desirable behaviour when -# e.g. a process holding the mutex segfaults. -# The BEOSSEM decision doesn't require any substitutions but is -# included here to prevent the fcntl() branch being selected -# from the decision making. -APR_BEGIN_DECISION([apr_lock implementation method]) -APR_IFALLYES(func:flock define:LOCK_EX, - APR_DECIDE(USE_FLOCK_SERIALIZE, [4.2BSD-style flock()])) -APR_IFALLYES(header:fcntl.h define:F_SETLK, - APR_DECIDE(USE_FCNTL_SERIALIZE, [SVR4-style fcntl()])) -APR_IFALLYES(func:semget func:semctl define:SEM_UNDO, - APR_DECIDE(USE_SYSVSEM_SERIALIZE, [SysV IPC semget()])) -APR_IFALLYES(header:OS.h func:create_sem, - APR_DECIDE(USE_BEOSSEM, [BeOS Semaphores])) -if test "x$apr_lock_method" != "x"; then - APR_DECISION_FORCE($apr_lock_method) -fi -APR_END_DECISION -AC_DEFINE_UNQUOTED($ac_decision) - -flockser="0" -sysvser="0" -posixser="0" -procpthreadser="0" -fcntlser="0" -case $ac_decision in - USE_FLOCK_SERIALIZE ) - flockser="1" - ;; - USE_FCNTL_SERIALIZE ) - fcntlser="1" - ;; - USE_SYSVSEM_SERIALIZE ) - sysvser="1" - ;; - USE_POSIXSEM_SERIALIZE ) - posixser="1" - ;; - USE_PROC_PTHREAD_SERIALIZE ) - procpthreadser="1" - ;; - USE_BEOSSEM ) - beossem="1" - ;; -esac - -if test $hasfcntlser = "1"; then -AC_MSG_CHECKING(if fcntl returns EACCES when F_SETLK is already held) -AC_TRY_RUN([ -#ifdef HAVE_STDLIB_H -#include -#endif -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif -#ifdef HAVE_SYS_WAIT_H -#include -#endif -#if defined(HAVE_UNISTD_H) -#include -#endif -#include -#include - -int fd; -struct flock proc_mutex_lock_it = {0}; -const char *fname = "conftest.fcntl"; - -int main() -{ - int rc, status;; - proc_mutex_lock_it.l_whence = SEEK_SET; /* from current point */ - proc_mutex_lock_it.l_type = F_WRLCK; /* set exclusive/write lock */ - - fd = creat(fname, S_IRWXU); - unlink(fname); - - if (rc = lockit()) { - exit(-1); - } - - if (fork()) { - wait(&status); - } - else { - return(lockit()); - } - - close(fd); - exit(WEXITSTATUS(status) != EACCES); -} - -int lockit() { - int rc; - do { - rc = fcntl(fd, F_SETLK, &proc_mutex_lock_it); - } while ( rc < 0 && errno == EINTR); - - return (rc < 0) ? errno : 0; -}], [apr_fcntl_tryacquire_eacces=1], [apr_fcntl_tryacquire_eacces=0], [apr_fcntl_tryacquire_eacces=0]) -fi - -if test "$apr_fcntl_tryacquire_eacces" = "1"; then - AC_DEFINE(FCNTL_TRYACQUIRE_EACCES, 1, [Define if fcntl returns EACCES when F_SETLK is already held]) - AC_MSG_RESULT(yes) -else - AC_MSG_RESULT(no) -fi - - -AC_SUBST(hasflockser) -AC_SUBST(hassysvser) -AC_SUBST(hasposixser) -AC_SUBST(hasfcntlser) -AC_SUBST(hasprocpthreadser) -AC_SUBST(flockser) -AC_SUBST(sysvser) -AC_SUBST(posixser) -AC_SUBST(fcntlser) -AC_SUBST(procpthreadser) -AC_SUBST(pthreadser) - -AC_MSG_CHECKING(if all interprocess locks affect threads) -if test "x$apr_process_lock_is_global" = "xyes"; then - proclockglobal="1" - AC_MSG_RESULT(yes) -else - proclockglobal="0" - AC_MSG_RESULT(no) -fi - -AC_SUBST(proclockglobal) - -AC_MSG_CHECKING(if POSIX sems affect threads in the same process) -if test "x$apr_posixsem_is_global" = "xyes"; then - AC_DEFINE(POSIXSEM_IS_GLOBAL, 1, - [Define if POSIX semaphores affect threads within the process]) - AC_MSG_RESULT(yes) -else - AC_MSG_RESULT(no) -fi - -AC_MSG_CHECKING(if SysV sems affect threads in the same process) -if test "x$apr_sysvsem_is_global" = "xyes"; then - AC_DEFINE(SYSVSEM_IS_GLOBAL, 1, - [Define if SysV semaphores affect threads within the process]) - AC_MSG_RESULT(yes) -else - AC_MSG_RESULT(no) -fi - -AC_MSG_CHECKING(if fcntl locks affect threads in the same process) -if test "x$apr_fcntl_is_global" = "xyes"; then - AC_DEFINE(FCNTL_IS_GLOBAL, 1, - [Define if fcntl locks affect threads within the process]) - AC_MSG_RESULT(yes) -else - AC_MSG_RESULT(no) -fi - -AC_MSG_CHECKING(if flock locks affect threads in the same process) -if test "x$apr_flock_is_global" = "xyes"; then - AC_DEFINE(FLOCK_IS_GLOBAL, 1, - [Define if flock locks affect threads within the process]) - AC_MSG_RESULT(yes) -else - AC_MSG_RESULT(no) -fi - -dnl ----------------------------- Checking for /dev/random -AC_MSG_CHECKING(for entropy source) - -why_no_rand="" - -AC_ARG_WITH(egd, - [ --with-egd[[=DIR]] use EGD-compatible socket], - [ AC_DEFINE(HAVE_EGD, 1, [Define if EGD is supported]) - if test "$withval" = "yes"; then - AC_DEFINE_UNQUOTED(EGD_DEFAULT_SOCKET, ["/var/run/egd-pool","/dev/egd-pool","/etc/egd-pool","/etc/entropy"], - [Define to list of paths to EGD sockets]) - else - AC_DEFINE_UNQUOTED(EGD_DEFAULT_SOCKET, ["$withval"]) - fi - AC_MSG_RESULT(EGD-compatible daemon) - rand="1" - ]) - -if test "$rand" != "1"; then - AC_ARG_WITH(devrandom, - [ --with-devrandom[[=DEV]] use /dev/random or compatible [[searches by default]]], - [ apr_devrandom="$withval" ], [ apr_devrandom="yes" ]) - - if test "$apr_devrandom" = "yes"; then - # /dev/random on OpenBSD doesn't provide random data, so - # prefer /dev/arandom, which does; see random(4). - for f in /dev/arandom /dev/urandom /dev/random; do - if test -r $f; then - apr_devrandom=$f - rand=1 - break - fi - done - elif test "$apr_devrandom" != "no"; then - if test -r "$apr_devrandom"; then - rand="1" - else - AC_ERROR([$apr_devrandom not found or unreadable.]) - fi - fi - - if test "$rand" = "1"; then - case $host in - *os390) - if test $os_version -lt 1700; then - rand="0" - why_no_rand=" ($apr_devrandom unusable on z/OS before V1R7)" - fi - ;; - esac - fi - - if test "$rand" = "1"; then - AC_DEFINE_UNQUOTED(DEV_RANDOM, ["$apr_devrandom"], [Define to path of random device]) - AC_MSG_RESULT([$apr_devrandom]) - fi -fi - -if test "$rand" != "1"; then - case $host in - # we have built in support for OS/2 - *-os2*) - AC_MSG_RESULT([Using OS/2 builtin random]) - rand="1" - ;; - *) - if test "$rand" != "1"; then - if test "$ac_cv_lib_truerand_main" = "yes"; then - AC_DEFINE(HAVE_TRUERAND, 1, [Define if truerand is supported]) - AC_MSG_RESULT(truerand) - rand="1" - else - AC_MSG_RESULT(not found$why_no_rand) - rand="0" - fi - fi - ;; - esac -fi - -AC_SUBST(rand) - -dnl ----------------------------- Checking for File Info Support -echo "${nl}Checking for File Info Support..." -AC_CHECK_MEMBERS([struct stat.st_blocks, struct stat.st_atimensec, -struct stat.st_ctimensec, struct stat.st_mtimensec, struct stat.st_atim.tv_nsec, -struct stat.st_ctim.tv_nsec, struct stat.st_mtim.tv_nsec, -struct stat.st_atime_n, struct stat.st_ctime_n, struct stat.st_mtime_n],,,[ -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif -#ifdef HAVE_UNISTD_H -#include -#endif]) - -APR_CHECK_DIRENT_INODE -APR_CHECK_DIRENT_TYPE - -dnl ----------------------------- Checking for UUID Support -echo "${nl}Checking for OS UUID Support..." - -AC_CHECK_HEADERS(uuid.h uuid/uuid.h sys/uuid.h, break) - -apr_revert_save_LIBS=$LIBS - -# Prefer the flavor(s) that live in libc; -AC_SEARCH_LIBS(uuid_create, uuid) -AC_SEARCH_LIBS(uuid_generate, uuid) -if test "$ac_cv_search_uuid_create" = "none required" -o \ - "$ac_cv_search_uuid_generate" = "none required"; then - LIBS=$apr_revert_save_LIBS -fi - -AC_CHECK_FUNCS(uuid_create uuid_generate) - -AC_CACHE_CHECK([for os uuid usability], [apr_cv_osuuid], [ -# Ensure this test closely mirrors misc/unix/rand.c! -uuid_includes=" -#if defined(HAVE_SYS_TYPES_H) -#include -#endif -#if defined(HAVE_UNISTD_H) -#include -#endif -#if defined(HAVE_UUID_H) -#include -#elif defined(HAVE_UUID_UUID_H) -#include -#elif defined(HAVE_SYS_UUID_H) -#include -#endif -" - apr_cv_osuuid=no - if test $ac_cv_func_uuid_create = yes; then - AC_TRY_LINK([$uuid_includes], [ - uuid_t g; - uint32_t s; - uuid_create(&g, &s); - if (s == uuid_s_ok) s = 0; - ], [apr_cv_osuuid=yes], [apr_cv_func_uuid_create=no]) - fi - if test $ac_cv_func_uuid_generate = yes; then - AC_TRY_LINK([$uuid_includes], [ - uuid_t g; - uuid_generate(g); - ], [apr_cv_osuuid=yes], [apr_cv_func_uuid_generate=no]) - fi -]) - -if test $apr_cv_osuuid = yes; then - osuuid="1" -else - osuuid="0" - LIBS=$apr_revert_save_LIBS -fi -AC_SUBST(osuuid) - - -dnl ----------------------------- Checking for Time Support -echo "${nl}Checking for Time Support..." - -AC_CHECK_MEMBERS([struct tm.tm_gmtoff, struct tm.__tm_gmtoff],,,[ -#include -#include ]) - -dnl ----------------------------- Checking for Networking Support -echo "${nl}Checking for Networking support..." -APR_TYPE_IN_ADDR -if test "$ac_cv_type_in_addr" = "yes"; then - have_in_addr="1" -else - have_in_addr="0" -fi - -AC_MSG_CHECKING([if fd == socket on this platform]) -if test "x$file_as_socket" != "x0" ; then - file_as_socket="1"; - echo "yes" -else - echo "no" -fi - -AC_SUBST(have_in_addr) -AC_SUBST(file_as_socket) - -if test "$ac_cv_func_poll $file_as_socket" = "yes 1"; then - AC_DEFINE(WAITIO_USES_POLL, 1, - [Define if apr_wait_for_io_or_timeout() uses poll(2)]) -fi - -# Check the types only if we have gethostbyname_r -if test "$ac_cv_func_gethostbyname_r" = "yes"; then - APR_CHECK_GETHOSTBYNAME_R_STYLE -fi - -# Check the types only if we have getservbyname_r -if test "$ac_cv_func_getservbyname_r" = "yes"; then - APR_CHECK_GETSERVBYNAME_R_STYLE -fi - -APR_CHECK_TCP_NODELAY_INHERITED -APR_CHECK_O_NONBLOCK_INHERITED -APR_CHECK_TCP_NODELAY_WITH_CORK - -# Look for a way of corking TCP... -APR_CHECK_DEFINE(TCP_CORK, netinet/tcp.h) -APR_CHECK_DEFINE(TCP_NOPUSH, netinet/tcp.h) -apr_tcp_nopush_flag="0" -have_corkable_tcp="0" -if test "x$ac_cv_define_TCP_CORK" = "xyes"; then - apr_tcp_nopush_flag="TCP_CORK" - have_corkable_tcp="1" -else - case $host in - *linux*) - AC_EGREP_CPP(yes,[ -#include -#ifdef TCP_CORK -yes -#endif - ],[ - apr_tcp_nopush_flag="3" - have_corkable_tcp="1" - ]) - ;; - *) - ;; - esac -fi -if test "x$ac_cv_define_TCP_NOPUSH" = "xyes"; then - apr_tcp_nopush_flag="TCP_NOPUSH" - have_corkable_tcp="1" -fi - -APR_CHECK_DEFINE(SO_ACCEPTFILTER, sys/socket.h) -if test "x$ac_cv_define_SO_ACCEPTFILTER" = "xyes"; then - acceptfilter="1" -else - acceptfilter="0" -fi - -APR_CHECK_SCTP -APR_CHECK_MCAST - -AC_SUBST(apr_tcp_nopush_flag) -AC_SUBST(have_corkable_tcp) -AC_SUBST(acceptfilter) -AC_SUBST(have_sctp) - -AC_CHECK_FUNCS(set_h_errno) - -echo "${nl}Checking for IPv6 Networking support..." -dnl Start of checking for IPv6 support... - -AC_ARG_ENABLE(ipv6, - [ --disable-ipv6 Disable IPv6 support in APR.], - [ if test "$enableval" = "no"; then - user_disabled_ipv6=1 - fi ], - [ user_disabled_ipv6=0 ] ) - -case $host in - *) - broken_ipv6=0 -esac - -AC_SEARCH_LIBS(getaddrinfo, socket inet6) -AC_SEARCH_LIBS(gai_strerror, socket inet6) -AC_SEARCH_LIBS(getnameinfo, socket inet6) -AC_CHECK_FUNCS(gai_strerror) -APR_CHECK_WORKING_GETADDRINFO -APR_CHECK_NEGATIVE_EAI -APR_CHECK_WORKING_GETNAMEINFO -APR_CHECK_SOCKADDR_IN6 -APR_CHECK_SOCKADDR_STORAGE - -have_ipv6="0" -if test "$user_disabled_ipv6" = 1; then - ipv6_result="no -- disabled by user" -else - if test "x$broken_ipv6" = "x0"; then - if test "x$have_sockaddr_in6" = "x1"; then - if test "x$ac_cv_working_getaddrinfo" = "xyes"; then - if test "x$ac_cv_working_getnameinfo" = "xyes"; then - APR_CHECK_GETADDRINFO_ADDRCONFIG - have_ipv6="1" - ipv6_result="yes" - else - ipv6_result="no -- no getnameinfo" - fi - else - ipv6_result="no -- no working getaddrinfo" - fi - else - ipv6_result="no -- no sockaddr_in6" - fi - else - ipv6_result="no -- the platform has known problems supporting IPv6" - fi -fi - -AC_MSG_CHECKING(if APR supports IPv6) -AC_MSG_RESULT($ipv6_result) - -AC_SUBST(have_ipv6) - -# hstrerror is only needed if IPv6 is not enabled, -# so getaddrinfo/gai_strerror are not used. -if test $have_ipv6 = 0; then - AC_SEARCH_LIBS(hstrerror, resolv, - [AC_DEFINE(HAVE_HSTRERROR, 1, [Define if hstrerror is present])]) -fi - -dnl Check for langinfo support - -AC_CHECK_HEADERS(langinfo.h) -AC_CHECK_FUNCS(nl_langinfo) - -dnl ------------------------------ Defaults for some platform nuances - -dnl Do we have a Win32-centric Unicode FS? -APR_SETIFNULL(have_unicode_fs, [0]) -AC_SUBST(have_unicode_fs) - -APR_SETIFNULL(apr_has_xthread_files, [0]) -AC_SUBST(apr_has_xthread_files) - -APR_SETIFNULL(apr_procattr_user_set_requires_password, [0]) -AC_SUBST(apr_procattr_user_set_requires_password) - -APR_SETIFNULL(apr_thread_func, []) -AC_SUBST(apr_thread_func) - -APR_SETIFNULL(apr_has_user, [1]) -AC_SUBST(apr_has_user) - -dnl ----------------------------- Finalize the variables - -echo "${nl}Restore user-defined environment settings..." - -APR_RESTORE_THE_ENVIRONMENT(CPPFLAGS, EXTRA_) -APR_RESTORE_THE_ENVIRONMENT(CFLAGS, EXTRA_) -APR_RESTORE_THE_ENVIRONMENT(LDFLAGS, EXTRA_) -APR_RESTORE_THE_ENVIRONMENT(LIBS, EXTRA_) -APR_RESTORE_THE_ENVIRONMENT(INCLUDES, EXTRA_) -AC_SUBST(NOTEST_CPPFLAGS) -AC_SUBST(NOTEST_CFLAGS) -AC_SUBST(NOTEST_LDFLAGS) -AC_SUBST(NOTEST_LIBS) -AC_SUBST(NOTEST_INCLUDES) - -dnl ----------------------------- Construct the files - -AC_SUBST(LDLIBS) -AC_SUBST(INCLUDES) -AC_SUBST(AR) -AC_SUBST(RM) -AC_SUBST(OSDIR) -AC_SUBST(DEFAULT_OSDIR) -AC_SUBST(EXEEXT) -AC_SUBST(LIBTOOL_LIBS) - -# Use -no-install to link the test programs on all platforms -# but Darwin, where it would cause the programs to be linked -# against installed versions of libapr instead of those just -# built. -case $host in -*-apple-darwin*) LT_NO_INSTALL="" ;; -*) LT_NO_INSTALL="-no-install" ;; -esac -AC_SUBST(LT_NO_INSTALL) - -# -# BSD/OS (BSDi) needs to use a different include syntax in the Makefiles -# -case $host in -*bsdi*) - # Check whether they've installed GNU make - if make --version > /dev/null 2>&1; then - INCLUDE_RULES="include $apr_buildout/apr_rules.mk" - INCLUDE_OUTPUTS="include $apr_srcdir/build-outputs.mk" - else - # BSDi make - INCLUDE_RULES=".include \"$apr_buildout/apr_rules.mk\"" - INCLUDE_OUTPUTS=".include \"$apr_srcdir/build-outputs.mk\"" - fi - ;; -*) - INCLUDE_RULES="include $apr_buildout/apr_rules.mk" - INCLUDE_OUTPUTS="include $apr_srcdir/build-outputs.mk" - ;; -esac -AC_SUBST(INCLUDE_RULES) -AC_SUBST(INCLUDE_OUTPUTS) - -AC_CONFIG_FILES([Makefile - include/apr.h - build/apr_rules.mk - build/pkg/pkginfo - apr-$APR_MAJOR_VERSION-config:apr-config.in - apr.pc]) - -if test -d $srcdir/test; then - AC_CONFIG_FILES([test/Makefile test/internal/Makefile]) -fi - -dir=include/arch/unix -test -d $dir || $MKDIR $dir - -AC_CONFIG_COMMANDS([default], [ -# Commands run at the end of config.status: -for i in $APR_SAVE_HEADERS; do - if cmp -s $i $i.save 2>/dev/null; then - mv $i.save $i - AC_MSG_NOTICE([$i is unchanged]) - fi - rm -f $i.save -done -chmod +x apr-$APR_MAJOR_VERSION-config -],[ -dnl This section is expanded by configure UNQUOTED so variable -dnl references must be backslash-escaped as necessary. - -# Commands run at the beginning of config.status: -APR_SAVE_HEADERS="include/apr.h include/arch/unix/apr_private.h" -APR_MAJOR_VERSION=$APR_MAJOR_VERSION -APR_PLATFORM=$host - -for apri in \${APR_SAVE_HEADERS}; do - test -r \${apri} && mv \${apri} \${apri}.save -done -]) - -AC_OUTPUT diff --git a/libs/apr/docs/APRDesign.html b/libs/apr/docs/APRDesign.html deleted file mode 100644 index 7d1caeb8..00000000 --- a/libs/apr/docs/APRDesign.html +++ /dev/null @@ -1,399 +0,0 @@ - -APR Design Document - -

    Design of APR

    - -

    The Apache Portable Run-time libraries have been designed to provide a common -interface to low level routines across any platform. The original goal of APR -was to combine all code in Apache to one common code base. This is not the -correct approach however, so the goal of APR has changed. There are places -where common code is not a good thing. For example, how to map requests -to either threads or processes should be platform specific. APR's place -is now to combine any code that can be safely combined without sacrificing -performance.

    - -

    To this end we have created a set of operations that are required for cross -platform development. There may be other types that are desired and those -will be implemented in the future.

    - -

    This document will discuss the structure of APR, and how best to contribute -code to the effort.

    - -

    APR On Windows and Netware

    - -

    APR on Windows and Netware is different from APR on all other systems, -because those platforms don't use autoconf. On Unix, apr_private.h (private to -APR) and apr.h (public, used by applications that use APR) are generated by -autoconf from acconfig.h and apr.h.in respectively. On Windows (and Netware), -apr_private.h and apr.h are created from apr_private.hw (apr_private.hwn) -and apr.hw (apr.hwn) respectively.

    - -

    - If you add code to acconfig.h or tests to configure.in or aclocal.m4, - please give some thought to whether or not Windows and Netware need - these additions as well. A general rule of thumb, is that if it is - a feature macro, such as APR_HAS_THREADS, Windows and Netware need it. - In other words, if the definition is going to be used in a public APR - header file, such as apr_general.h, Windows needs it. - - The only time it is safe to add a macro or test without also adding - the macro to apr*.h[n]w, is if the macro tells APR how to build. For - example, a test for a header file does not need to be added to Windows. -

    - -

    APR Features

    - -

    One of the goals of APR is to provide a common set of features across all -platforms. This is an admirable goal, it is also not realistic. We cannot -expect to be able to implement ALL features on ALL platforms. So we are -going to do the next best thing. Provide a common interface to ALL APR -features on MOST platforms.

    - -

    APR developers should create FEATURE MACROS for any feature that is not -available on ALL platforms. This should be a simple definition which has -the form:

    - -APR_HAS_FEATURE - -

    This macro should evaluate to true if APR has this feature on this platform. -For example, Linux and Windows have mmap'ed files, and APR is providing an -interface for mmapp'ing a file. On both Linux and Windows, APR_HAS_MMAP -should evaluate to one, and the ap_mmap_* functions should map files into -memory and return the appropriate status codes.

    - -

    If your OS of choice does not have mmap'ed files, APR_HAS_MMAP should -evaluate to zero, and all ap_mmap_* functions should not be defined. The -second step is a precaution that will allow us to break at compile time if a -programmer tries to use unsupported functions.

    - -

    APR types

    - -

    The base types in APR

    - -
      -
    • dso
      - Shared library routines -
    • mmap
      - Memory-mapped files -
    • poll
      - Polling I/O -
    • time
      - Time -
    • user
      - Users and groups -
    • locks
      - Process and thread locks (critical sections) -
    • shmem
      - Shared memory -
    • file_io
      - File I/O, including pipes -
    • atomic
      - Atomic integer operations -
    • strings
      - String handling routines -
    • memory
      - Pool-based memory allocation -
    • passwd
      - Reading passwords from the terminal -
    • tables
      - Tables and hashes -
    • network_io
      - Network I/O -
    • threadproc
      - Threads and processes -
    • misc
      - Any APR type which doesn't have any other place to belong. This - should be used sparingly. -
    • support
      - Functions meant to be used across multiple APR types. This area - is for internal functions only. If a function is exposed, it should - not be put here. -
    - -

    Directory Structure

    - -

    Each type has a base directory. Inside this base directory, are -subdirectories, which contain the actual code. These subdirectories are named -after the platforms the are compiled on. Unix is also used as a common -directory. If the code you are writing is POSIX based, you should look at the -code in the unix directory. A good rule of thumb, is that if more than half -your code needs to be ifdef'ed out, and the structures required for your code -are substantively different from the POSIX code, you should create a new -directory.

    - -

    Currently, the APR code is written for Unix, BeOS, Windows, and OS/2. An -example of the directory structure is the file I/O directory:

    - -
    -apr
    -  |
    -   ->  file_io
    -          |
    -           -> unix            The Unix and common base code
    -          |
    -           -> win32           The Windows code
    -          | 
    -           -> os2             The OS/2 code
    -
    - -

    Obviously, BeOS does not have a directory. This is because BeOS is currently -using the Unix directory for it's file_io.

    - -

    There are a few special top level directories. These are test and include. -Test is a directory which stores all test programs. It is expected -that if a new type is developed, there will also be a new test program, to -help people port this new type to different platforms. A small document -describing how to create new tests that integrate with the test suite can be -found in the test/ directory. Include is a directory which stores all -required APR header files for external use.

    - -

    Creating an APR Type

    - -

    The current design of APR requires that most APR types be incomplete. -It is not possible to write flexible portable code if programs can access -the internals of APR types. This is because different platforms are -likely to define different native types. There are only two execptions to -this rule:

    - -
      -
    • The first exception to this rule is if the type can only reasonably be -implemented one way. For example, time is a complete type because there -is only one reasonable time implementation. - -
    • The second exception to the incomplete type rule can be found in -apr_portable.h. This file defines the native types for each platform. -Using these types, it is possible to extract native types for any APR type.

      -
    - -

    For this reason, each platform defines a structure in their own directories. -Those structures are then typedef'ed in an external header file. For example -in file_io/unix/fileio.h:

    - -
    -    struct ap_file_t {
    -        apr_pool_t *cntxt;
    -        int filedes;
    -        FILE *filehand;
    -        ...
    -    }
    -
    - -

    In include/apr_file_io.h:

    - - typedef struct ap_file_t ap_file_t; - - -

    This will cause a compiler error if somebody tries to access the filedes -field in this structure. Windows does not have a filedes field, so obviously, -it is important that programs not be able to access these.

    - -

    You may notice the apr_pool_t field. Most APR types have this field. This -type is used to allocate memory within APR. Because every APR type has a pool, -any APR function can allocate memory if it needs to. This is very important -and it is one of the reasons that APR works. If you create a new type, you -must add a pool to it. If you do not, then all functions that operate on that -type will need a pool argument.

    - -

    New Function

    - -

    When creating a new function, please try to adhere to these rules.

    - -
      -
    • Result arguments should be the first arguments. -
    • If a function needs a pool, it should be the last argument. -
    • These rules are flexible, especially if it makes the code easier - to understand because it mimics a standard function. -
    - -

    Documentation

    - -

    Whenever a new function is added to APR, it MUST be documented. New -functions will not be committed unless there are docs to go along with them. -The documentation should be a comment block above the function in the header -file.

    - -

    The format for the comment block is:

    - -
    -    /**
    -     * Brief description of the function
    -     * @param parma_1_name explanation
    -     * @param parma_2_name explanation
    -     * @param parma_n_name explanation
    -     * @tip Any extra information people should know.
    -     * @deffunc function prototype if required
    -     */ 
    -
    - -

    For an actual example, look at any file in the include directory. The -reason the docs are in the header files is to ensure that the docs always -reflect the current code. If you change paramters or return values for a -function, please be sure to update the documentation.

    - -

    APR Error reporting

    - -

    Most APR functions should return an ap_status_t type. The only time an -APR function does not return an ap_status_t is if it absolutely CAN NOT -fail. Examples of this would be filling out an array when you know you are -not beyond the array's range. If it cannot fail on your platform, but it -could conceivably fail on another platform, it should return an ap_status_t. -Unless you are sure, return an ap_status_t.

    - - - This includes functions that return TRUE/FALSE values. How that - is handled is discussed below - - -

    All platforms return errno values unchanged. Each platform can also have -one system error type, which can be returned after an offset is added. -There are five types of error values in APR, each with it's own offset.

    - - -
    -    Name			Purpose
    -0) 			This is 0 for all platforms and isn't really defined
    - 			anywhere, but it is the offset for errno values.
    -			(This has no name because it isn't actually defined, 
    -                        but for completeness we are discussing it here).
    -
    -1) APR_OS_START_ERROR	This is platform dependent, and is the offset at which
    -			APR errors start to be defined.  Error values are 
    -			defined as anything which caused the APR function to 
    -			fail.  APR errors in this range should be named 
    -			APR_E* (i.e. APR_ENOSOCKET)
    -
    -2) APR_OS_START_STATUS	This is platform dependent, and is the offset at which
    -			APR status values start.  Status values do not indicate
    -			success or failure, and should be returned if 
    -			APR_SUCCESS does not make sense.  APR status codes in 
    -			this range should be name APR_* (i.e. APR_DETACH)
    -
    -4) APR_OS_START_USEERR	This is platform dependent, and is the offset at which
    -			APR apps can begin to add their own error codes.
    -
    -3) APR_OS_START_SYSERR	This is platform dependent, and is the offset at which
    -			system error values begin.
    -
    - -The difference in naming between APR_OS_START_ERROR and -APR_OS_START_STATUS mentioned above allows programmers to easily determine if -the error code indicates an error condition or a status codition. - -

    If your function has multiple return codes that all indicate success, but -with different results, or if your function can only return PASS/FAIL, you -should still return an apr_status_t. In the first case, define one -APR status code for each return value, an example of this is -apr_proc_wait, which can only return APR_CHILDDONE, -APR_CHILDNOTDONE, or an error code. In the second case, please return -APR_SUCCESS for PASS, and define a new APR status code for failure, an -example of this is apr_compare_users, which can only return -APR_SUCCESS, APR_EMISMATCH, or an error code.

    - -

    All of these definitions can be found in apr_errno.h for all platforms. When -an error occurs in an APR function, the function must return an error code. -If the error occurred in a system call and that system call uses errno to -report an error, then the code is returned unchanged. For example:

    - -
    -    if (open(fname, oflags, 0777) < 0)
    -        return errno;
    -
    - -

    The next place an error can occur is a system call that uses some error value -other than the primary error value on a platform. This can also be handled -by APR applications. For example:

    - -
    -    if (CreateFile(fname, oflags, sharemod, NULL, 
    -                   createflags, attributes, 0) == INVALID_HANDLE_VALUE
    -        return (GetLAstError() + APR_OS_START_SYSERR);
    -
    - -

    These two examples implement the same function for two different platforms. -Obviously even if the underlying problem is the same on both platforms, this -will result in two different error codes being returned. This is OKAY, and -is correct for APR. APR relies on the fact that most of the time an error -occurs, the program logs the error and continues, it does not try to -programatically solve the problem. This does not mean we have not provided -support for programmatically solving the problem, it just isn't the default -case. We'll get to how this problem is solved in a little while.

    - -

    If the error occurs in an APR function but it is not due to a system call, -but it is actually an APR error or just a status code from APR, then the -appropriate code should be returned. These codes are defined in apr_errno.h -and should be self explanatory.

    - -

    No APR code should ever return a code between APR_OS_START_USEERR and -APR_OS_START_SYSERR, those codes are reserved for APR applications.

    - -

    To programmatically correct an error in a running application, the error -codes need to be consistent across platforms. This should make sense. APR -has provided macros to test for status code equivalency. For example, to -determine if the code that you received from the APR function means EOF, you -would use the macro APR_STATUS_IS_EOF().

    - -

    Why did APR take this approach? There are two ways to deal with error -codes portably.

    - -
      -
    1. Return the same error code across all platforms. -
    2. Return platform specific error codes and convert them when necessary. -
    - -

    The problem with option number one is that it takes time to convert error -codes to a common code, and most of the time programs want to just output -an error string. If we convert all errors to a common subset, we have four -steps to output an error string:

    - -

    The seocnd problem with option 1, is that it is a lossy conversion. For -example, Windows and OS/2 have a couple hundred error codes, but POSIX errno -only defines about 50 errno values. This means that if we convert to a -canonical error value immediately, there is no way for the programmer to -get the actual system error.

    - -
    -    make syscall that fails
    -        convert to common error code                 step 1
    -        return common error code
    -            check for success
    -            call error output function               step 2
    -                convert back to system error         step 3
    -                output error string                  step 4
    -
    - -

    By keeping the errors platform specific, we can output error strings in two -steps.

    - -
    -    make syscall that fails
    -        return error code
    -            check for success
    -            call error output function               step 1
    -                output error string                  step 2
    -
    - -

    Less often, programs change their execution based on what error was returned. -This is no more expensive using option 2 than it is using option 1, but we -put the onus of converting the error code on the programmer themselves. -For example, using option 1:

    - -
    -    make syscall that fails
    -        convert to common error code
    -        return common error code
    -            decide execution based on common error code
    -
    - -

    Using option 2:

    - -
    -    make syscall that fails
    -        return error code
    -            convert to common error code (using ap_canonical_error)
    -            decide execution based on common error code
    -
    - -

    Finally, there is one more operation on error codes. You can get a string -that explains in human readable form what has happened. To do this using -APR, call ap_strerror().

    - diff --git a/libs/apr/docs/canonical_filenames.html b/libs/apr/docs/canonical_filenames.html deleted file mode 100644 index 10867d37..00000000 --- a/libs/apr/docs/canonical_filenames.html +++ /dev/null @@ -1,156 +0,0 @@ - -APR Canonical Filenames - -

    APR Canonical Filename

    - -

    Requirements

    - -

    APR porters need to address the underlying discrepancies between -file systems. To achieve a reasonable degree of security, the -program depending upon APR needs to know that two paths may be -compared, and that a mismatch is guarenteed to reflect that the -two paths do not return the same resource

    . - -

    The first discrepancy is in volume roots. Unix and pure deriviates -have only one root path, "/". Win32 and OS2 share root paths of -the form "D:/", D: is the volume designation. However, this can -be specified as "//./D:/" as well, indicating D: volume of the -'this' machine. Win32 and OS2 also may employ a UNC root path, -of the form "//server/share/" where share is a share-point of the -specified network server. Finally, NetWare root paths are of the -form "server/volume:/", or the simpler "volume:/" syntax for 'this' -machine. All these non-Unix file systems accept volume:path, -without a slash following the colon, as a path relative to the -current working directory, which APR will treat as ambigious, that -is, neither an absolute nor a relative path per se.

    - -

    The second discrepancy is in the meaning of the 'this' directory. -In general, 'this' must be eliminated from the path where it occurs. -The syntax "path/./" and "path/" are both aliases to path. However, -this isn't file system independent, since the double slash "//" has -a special meaning on OS2 and Win32 at the start of the path name, -and is invalid on those platforms before the "//server/share/" UNC -root path is completed. Finally, as noted above, "//./volume/" is -legal root syntax on WinNT, and perhaps others.

    - -

    The third discrepancy is in the context of the 'parent' directory. -When "parent/path/.." occurs, the path must be unwound to "parent". -It's also critical to simply truncate leading "/../" paths to "/", -since the parent of the root is root. This gets tricky on the -Win32 and OS2 platforms, since the ".." element is invalid before -the "//server/share/" is complete, and the "//server/share/../" -seqence is the complete UNC root "//server/share/". In relative -paths, leading ".." elements are significant, until they are merged -with an absolute path. The relative form must only retain the ".." -segments as leading segments, to be resolved once merged to another -relative or an absolute path.

    - -

    The fourth discrepancy occurs with acceptance of alternate character -codes for the same element. Path seperators are not retained within -the APR canonical forms. The OS filesystem and APR (slashed) forms -can both be returned as strings, to be used in the proper context. -Unix, Win32 and Netware all accept slashes and backslashes as the -same path seperator symbol, although unix strictly accepts slashes. -While the APR form of the name strictly uses slashes, always consider -that there could be a platform that actually accepts slashes as a -character within a segment name.

    - -

    The fifth and worst discrepancy plauges Win32, OS2, Netware, and some -filesystems mounted in Unix. Case insensitivity can permit the same -file to slip through in both it's proper case and alternate cases. -Simply changing the case is insufficient for any character set beyond -ASCII, since various dilectic forms of characters suffer from one to -many or many to one translations. An example would be u-umlaut, which -might be accepted as a single character u-umlaut, a two character -sequence u and the zero-width umlaut, the upper case form of the same, -or perhaps even a captial U alone. This can be handled in different -ways depending on the purposes of the APR based program, but the one -requirement is that the path must be absolute in order to resolve these -ambiguities. Methods employed include comparison of device and inode -file uniqifiers, which is a fairly fast operation, or quering the OS -for the true form of the name, which can be much slower. Only the -acknowledgement of the file names by the OS can validate the equality -of two different cases of the same filename.

    - -

    The sixth discrepancy, illegal or insignificant characters, is especially -significant in non-unix file systems. Trailing periods are accepted -but never stored, therefore trailing periods must be ignored for any -form of comparison. And all OS's have certain expectations of what -characters are illegal (or undesireable due to confusion.)

    - -

    A final warning, canonical functions don't transform or resolve case -or character ambiguity issues until they are resolved into an absolute -path. The relative canonical path, while useful, while useful for URL -or similar identifiers, cannot be used for testing or comparison of file -system objects.

    - -
    - -

    Canonical API

    - -Functions to manipulate the apr_canon_file_t (an opaque type) include: - -
      -
    • Create canon_file_t (from char* path and canon_file_t parent path) -
    • Merged canon_file_t (from path and parent, both canon_file_t) -
    • Get char* path of all or some segments -
    • Get path flags of IsRelative, IsVirtualRoot, and IsAbsolute -
    • Compare two canon_file_t structures for file equality -
    - -

    The path is corrected to the file system case only if is in absolute -form. The apr_canon_file_t should be preserved as long as possible and -used as the parent to create child entries to reduce the number of expensive -stat and case canonicalization calls to the OS.

    - -

    The comparison operation provides that the APR can postpone correction -of case by simply relying upon the device and inode for equivilance. The -stat implementation provides that two files are the same, while their -strings are not equivilant, and eliminates the need for the operating -system to return the proper form of the name.

    - -

    In any case, returning the char* path, with a flag to request the proper -case, forces the OS calls to resolve the true names of each segment. Where -there is a penality for this operation and the stat device and inode test -is faster, case correction is postponed until the char* result is requested. -On platforms that identify the inode, device, or proper name interchangably -with no penalities, this may occur when the name is initially processed.

    - -
    - -

    Unix Example

    - -

    First the simplest case:

    - -
    -Parse Canonical Name 
    -accepts parent path as canonical_t
    -        this path as string
    -
    -Split this path Segments on '/'
    -
    -For each of this path Segments
    -  If first Segment
    -    If this Segment is Empty ([nothing]/)
    -      Append this Root Segment (don't merge)
    -      Continue to next Segment
    -    Else is relative
    -      Append parent Segments (to merge)
    -      Continue with this Segment
    -  If Segment is '.' or empty (2 slashes)
    -    Discard this Segment
    -    Continue with next Segment
    -  If Segment is '..'
    -    If no previous Segment or previous Segment is '..'
    -      Append this Segment
    -      Continue with next Segment
    -    If previous Segment and previous is not Root Segment
    -      Discard previous Segment
    -    Discard this Segment
    -    Continue with next Segment
    -  Append this Relative Segment
    -  Continue with next Segment        
    -
    - - - \ No newline at end of file diff --git a/libs/apr/docs/doxygen.conf b/libs/apr/docs/doxygen.conf deleted file mode 100644 index 29c2cbf6..00000000 --- a/libs/apr/docs/doxygen.conf +++ /dev/null @@ -1,38 +0,0 @@ -PROJECT_NAME="Apache Portable Runtime" - -INPUT=. -QUIET=YES -RECURSIVE=YES -FILE_PATTERNS=*.h - -OUTPUT_DIRECTORY=docs/dox - -MACRO_EXPANSION=YES -EXPAND_ONLY_PREDEF=YES -#EXPAND_AS_DEFINED= -# not sure why this doesn't work as EXPAND_AS_DEFINED, it should! -PREDEFINED="APR_DECLARE(x)=x" \ - "APR_DECLARE_NONSTD(x)=x" \ - "APR_DECLARE_DATA" \ - "APR_POOL_DECLARE_ACCESSOR(x)=apr_pool_t* apr_##x##_pool_get (const apr_##x##_t *the##x)" \ - "APR_DECLARE_INHERIT_SET(x)=apr_status_t apr_##x##_inherit_set(apr_##x##_t *the##x)" \ - "APR_DECLARE_INHERIT_UNSET(x)=apr_status_t apr_##x##_inherit_unset(apr_##x##_t *the##x)" \ - "APR_HAS_THREADS" \ - "__attribute__(x)=" \ - DOXYGEN= - -OPTIMIZE_OUTPUT_FOR_C=YES -STRIP_CODE_COMMENTS=NO - -FULL_PATH_NAMES=NO -CASE_SENSE_NAMES=NO -# some autoconf guru needs to make configure set this correctly... -# in the meantime, simply listing the headers should be alright -#STRIP_FROM_PATH=/buildpath/apr - -EXCLUDE_PATTERNS="*/acconfig.h" \ - "*/test/*" \ - "*/arch/*" - -GENERATE_TAGFILE=docs/dox/apr.tag - diff --git a/libs/apr/docs/incomplete_types b/libs/apr/docs/incomplete_types deleted file mode 100644 index cbed7774..00000000 --- a/libs/apr/docs/incomplete_types +++ /dev/null @@ -1,84 +0,0 @@ -The question has been asked multiple times, "Why is APR using Incomplete -types?" This document will try to explain that. - -Incomplete types are used in APR because they can enforce portability, and -they make the APR developers job easier, as well as allowing APR to use native -types on all platforms. Imagine a scenario where APR wasn't using incomplete -types. The ap_file_t type would have to be defined as: - -typedef struct ap_file_t { - ap_pool_t *pool - char *fname; - int eof_hit; - int pipe; - ap_interval_time_t timeout; -#ifdef WIN32 - HANDLE file_handle; - DWORD dwFileAttributes; -#elif defined(OS2) - HFILE filedes; - HEV PipeSem -#else - int filedes; - int ungetchar; -#endif - -#ifndef WIN32 - int buffered; - ap_int32_flags - int isopen; - - /* Stuff for buffered mode */ - char *buffer; - int bufpos; - unsigned long dataRead; - int direction; - unsigned long filePtr; - ap_lock_t *mutex; -#endif -} ap_file_t; - -This captures the essense of what is currently being defined for ap_file_t -using incomplete types. However, using this structure leads developers to -believe that they are safe accessing any of the fields in this structure. -This is not true. On some platforms, such as Windows, about half of the -structure disappears. We could combine some of these definitions with -macros, for example: - -#ifdef WIN32 -#define filetype HANDLE -#elif OS2 -#define filetype HFILE -#else -#define filetype int -#endif - -And then in the defintion for ap_file_t, we could say: - filetype filedes; - -This gets rid of some of the complexity, by moving it off to the side, but -it is still not safe for a programmers to access the filedes field directly -outside of APR, because the programmer has no way of knowing what the actual -type is. So for example printing the filedes using printf would yield wildly -varying results on Windows and OS2 when compared to Unix. - -Another option also presents itself. Stick strictly to POSIX. This means -that all code can be shared on any POSIX compliant platform. The problem -with this is performance. One of the benefits to APR, is that it allows -developers to easily use native types on all platforms with the same code. -This has proven to provide a substantial performance boost on most non-Unix -platforms. - -Having said all of that, sometimes incomplete types just don't make sense. -For example, the first implementation of time functions used incomplete types, -which added a layer of complexity that turned out to be unnecessary. If -a platform cannot provide a simple number that represents the number of seconds -elapsed since a specifed date and time, then APR doesn't really want to -provide support for that platform. - -APR is trying hard to provide a balance of incomplete and complete types, -but like all things, sometimes the developers make mistakes. If you are -using APR and find that there is an incomplete type that doesn't need to be -an incomplete type, please let us know, we are more than willing to listen -and design parts of APR that do not use incomplete types. - diff --git a/libs/apr/docs/non_apr_programs b/libs/apr/docs/non_apr_programs deleted file mode 100644 index 5003a8bd..00000000 --- a/libs/apr/docs/non_apr_programs +++ /dev/null @@ -1,47 +0,0 @@ -How do I use APR'ized programs in connection with programs that don't -use APR? These darn incomplete types don't let me fill out the APR types. - -The APR developers acknowledge that most programs are not using APR, and -we don't expect them to migrate to using APR just because APR has been -released. So, we have provided a way for non-APR'ized programs to interact -very cleanly with APR. - -There are a set of functions, all documented in apr_portable.h, which allow -a programmer to either get a native type from an APR type, or to setup an -APR type from a native type. - -For example, if you are writing an add-on to another program that does not use -APR for file I/O, but you (in your infinite wisdom) want to use APR to make -sure your section is portable. Assume the program provides a type foo_t with -a file descriptor in it (fd). - -void function_using_apr(foo_t non_apr_struct, ap_pool_t *p) -{ - ap_file_t *apr_file = NULL; - - ap_put_os_file(&apr_file, &non_apr_struct->fd, p); - - ... -} - -There are portable functions for each APR incomplete type. They are all -called ap_put_os_foobar(), and they each take the same basic arguments, a -pointer to a pointer to the incomplete type (the last pointer in that list -should be NULL), a pointer to the native type, and a pool. Each of these can -be found in apr_portable.h. - -If you have to do the exact opposite (take an APR type and convert it to a -native type, there are functions for that too. For example: - -void function_not_using_apr(apr_file_t *apr_file) -{ - int unix_file_desc; - - ap_get_os_file(&unix_file_desc, apr_file); - - ... -} - -For each ap_put_os_foobar, there is a corresponding ap_get_os_file. These are -also documented in apr_portable.h. - diff --git a/libs/apr/docs/pool-design.html b/libs/apr/docs/pool-design.html deleted file mode 100644 index 406c4810..00000000 --- a/libs/apr/docs/pool-design.html +++ /dev/null @@ -1,100 +0,0 @@ - - - Using APR Pools - - -
    - Last modified at [$Date: 2013/08/12 10:04:43 $] -
    - -

    Using APR Pools

    - -

    - From Subversion, we - have learned a lot about how to use pools in a heavily - structured/object-based environment. - Apache httpd is a - completely different beast: "allocate a request pool. use - it. destroy it." -

    - -

    - In a complex app, that request-style of behavior is not - present. Luckily, the "proper" use of pools can be described in - just a few rules: -

    - -
      -
    • - Objects should not have their own pools. An object is - allocated into a pool defined by the constructor's caller. The - caller knows the lifetime of the object and - will manage it via the pool. Generally, this also means that - objects will not have a "close" or a "free" since those - operations will happen implicitly as part of the destruction - of the pool the objects live within. -
    • - -
    • -

      - Functions should not create/destroy pools for their - operation; they should use a pool provided by the - caller. Again, the caller knows more about - how the function will be used, how often, how many times, - etc. Thus, it should be in charge of the function's memory - usage. -

      -

      - As an example, the caller might know that the app will exit - upon the function's return. Thus, the function would be - creating extra work if it built and destroyed a - pool. Instead, it should use the passed-in pool, which the - caller is going to be tossing as part of app-exit anyways. -

      -
    • - -
    • -

      - Whenever an unbounded iteration occurs, a subpool should be - used. The general pattern is: -

      -
      -
      -subpool = apr_create_subpool(pool);
      -for (i = 0; i < n; ++i) {
      -  apr_pool_clear(subpool);
      -
      -  do_operation(..., subpool);
      -}
      -apr_pool_destroy(subpool);
      -
      -

      - This pattern prevents the 'pool' from growing unbounded and - consuming all of memory. Note that it is slightly more - optimal to clear the pool on loop-entry. This pattern also - allows for a 'continue' to occur within the loop, - yet still ensure the pool will be cleared. -

      -
    • - -
    • - Given all of the above, it is pretty well mandatory to pass a - pool to every function. Since objects are not - recording pools for themselves, and the caller is always - supposed to be managing memory, then each function needs a - pool, rather than relying on some hidden magic pool. In - limited cases, objects may record the pool used for their - construction so that they can construct sub-parts, but these - cases should be examined carefully. Internal pools can lead to - unbounded pool usage if the object is not careful. -
    • -
    - -
    -
    Greg Stein
    - - -Last modified: Wed Jun 25 14:50:19 PDT 2003 - - - diff --git a/libs/apr/docs/win32_builds.html b/libs/apr/docs/win32_builds.html deleted file mode 100644 index ad57d8e1..00000000 --- a/libs/apr/docs/win32_builds.html +++ /dev/null @@ -1,57 +0,0 @@ - -APR Win32 Builds and Debugging - -

    APR Win32 Builds and Debugging

    - -

    Configuration and Flavors

    - -

    The Win32 APR Developer Studio projects consist of

    - -
    -
    apr/apr.dsp
    -
    Builds the static apr.lib library (-D APR_DECLARE_STATIC)
    -
    apr/libapr.dsp
    -
    Builds the dynamic libapr.dll library (no define required)
    -
    apr-util/aprutil.dsp
    -
    Builds the static aprutil.lib library (-D APU_DECLARE_STATIC)
    -
    apr-util/libaprutil.dsp
    -
    Builds the dynamic libaprutil.dll library (no define required)
    -
    apr-iconv/apriconv.dsp
    -
    Builds the static apriconv.lib library (-D API_DECLARE_STATIC)
    -
    apr-iconv/libapriconv.dsp
    -
    Builds the dynamic libapriconv.dll library (no define required)
    -
    - -

    In order to prepare to use one of the static libraries above, - your application must be compiled with the define shown above, so that the - correct linkage is created. The APR authors intended the use of dynamic - libraries by default, so application authors do not need any special - defines in order to link to the dynamic library flavors.

    - -

    In order to build APR, you must use the proper dependencies. A good - example of those dependencies is given in the apr-util/aprutil.dsw - Developer Studio workspace. You can borrow the parts of that structure - your application needs, that workspace defines both the dynamic and static - library dependencies.

    - -

    The APR libraries (dynamic and static) are compiled with debugging symbols, - even in Release builds. The dynamic library symbols are always usable, - simply keep the correspond .pdb file in the same path as the library .dll. - (E.g. both libapr.dll and libapr.pdb should be copied to the same path.)

    - -

    The static symbols will only be fully usable if your application does not - link with the /pdbtype:sept flag! At the time your application links to - an APR library, the corresponding _src.pdb file should exist in the original - path the library was built, or it may be sufficient to keep the _src.pdb file - in the same path as the library file. (E.g. apr.lib and apr_src.pdb should - reside together in your lib directory.) The later option is unconfirmed.

    - -

    In order to keep the symbols compiled into the static library, your application - must use the linker's /debug flag. If you do not want the application to be - debuggable with its corresponding .pdb file, omit the /debug flag and all debug - symbolic information is discarded. Note that your application can only be - debugged with the corresponding .pdb file created by the linker, unless you use - /debugtype:coff or /debugtype:both in your link options.

    - - - diff --git a/libs/apr/dso/aix/dso.c b/libs/apr/dso/aix/dso.c deleted file mode 100644 index 25f6262a..00000000 --- a/libs/apr/dso/aix/dso.c +++ /dev/null @@ -1,714 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * dso.c -- DSO system function emulation for AIX - * - * This is *only* intended for AIX < 4.3. - */ - -/* - * Based on libdl (dlfcn.c/dlfcn.h) which is - * Copyright (c) 1992,1993,1995,1996,1997,1988 - * Jens-Uwe Mager, Helios Software GmbH, Hannover, Germany. - * - * Not derived from licensed software. - * - * Permission is granted to freely use, copy, modify, and redistribute - * this software, provided that the author is not construed to be liable - * for any results of using the software, alterations are clearly marked - * as such, and this notice is not modified. - * - * Changes marked with `--jwe' were made on April 7 1996 by - * John W. Eaton to support g++ - * - * Bundled, stripped and adjusted on April 1998 as one single source file - * for inclusion into the Apache HTTP server by - * Ralf S. Engelschall - * - * Added to APR by David Reid April 2000 - */ - -#include -#include -#include -#include -#include -#include -#include -#include "apr_arch_dso.h" -#include "apr_portable.h" - -#if APR_HAS_DSO - -#undef FREAD -#undef FWRITE -#include - -/* - * AIX 4.3 does remove some useful definitions from ldfcn.h. Define - * these here to compensate for that lossage. - */ -#ifndef BEGINNING -#define BEGINNING SEEK_SET -#endif -#ifndef FSEEK -#define FSEEK(ldptr,o,p) fseek(IOPTR(ldptr),(p==BEGINNING)?(OFFSET(ldptr) +o):o,p) -#endif -#ifndef FREAD -#define FREAD(p,s,n,ldptr) fread(p,s,n,IOPTR(ldptr)) -#endif - -/* - * Mode flags for the dlopen routine. - */ -#undef RTLD_LAZY -#define RTLD_LAZY 1 /* lazy function call binding */ -#undef RTLD_NOW -#define RTLD_NOW 2 /* immediate function call binding */ -#undef RTLD_GLOBAL -#define RTLD_GLOBAL 0x100 /* allow symbols to be global */ - -/* - * To be able to initialize, a library may provide a dl_info structure - * that contains functions to be called to initialize and terminate. - */ -struct dl_info { - void (*init) (void); - void (*fini) (void); -}; - -/* APR functions... - * - * As the AIX functions have been declared in the header file we just - * add the basic "wrappers" here. - */ - -APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso, - apr_os_dso_handle_t osdso, - apr_pool_t *pool) -{ - *aprdso = apr_pcalloc(pool, sizeof **aprdso); - (*aprdso)->handle = osdso; - (*aprdso)->pool = pool; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *osdso, - apr_dso_handle_t *aprdso) -{ - *osdso = aprdso->handle; - return APR_SUCCESS; -} - -static apr_status_t dso_cleanup(void *thedso) -{ - apr_dso_handle_t *dso = thedso; - - if (dso->handle != NULL && dlclose(dso->handle) != 0) - return APR_EINIT; - dso->handle = NULL; - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, - const char *path, apr_pool_t *ctx) -{ - void *os_handle = dlopen((char *)path, RTLD_NOW | RTLD_GLOBAL); - - *res_handle = apr_pcalloc(ctx, sizeof(*res_handle)); - - if(os_handle == NULL) { - (*res_handle)->errormsg = dlerror(); - return APR_EDSOOPEN; - } - - (*res_handle)->handle = (void*)os_handle; - (*res_handle)->pool = ctx; - (*res_handle)->errormsg = NULL; - - apr_pool_cleanup_register(ctx, *res_handle, dso_cleanup, apr_pool_cleanup_null); - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_dso_unload(apr_dso_handle_t *handle) -{ - return apr_pool_cleanup_run(handle->pool, handle, dso_cleanup); -} - -APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, - apr_dso_handle_t *handle, - const char *symname) -{ - void *retval = dlsym(handle->handle, symname); - - if (retval == NULL) { - handle->errormsg = dlerror(); - return APR_ESYMNOTFOUND; - } - - *ressym = retval; - return APR_SUCCESS; -} - -APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *dso, char *buffer, apr_size_t buflen) -{ - if (dso->errormsg) { - apr_cpystrn(buffer, dso->errormsg, buflen); - return dso->errormsg; - } - return "No Error"; -} - - - -/* - * We simulate dlopen() et al. through a call to load. Because AIX has - * no call to find an exported symbol we read the loader section of the - * loaded module and build a list of exported symbols and their virtual - * address. - */ - -typedef struct { - char *name; /* the symbols's name */ - void *addr; /* its relocated virtual address */ -} Export, *ExportPtr; - -/* - * xlC uses the following structure to list its constructors and - * destructors. This is gleaned from the output of munch. - */ -typedef struct { - void (*init) (void); /* call static constructors */ - void (*term) (void); /* call static destructors */ -} Cdtor, *CdtorPtr; - -typedef void (*GccCDtorPtr) (void); - -/* - * The void * handle returned from dlopen is actually a ModulePtr. - */ -typedef struct Module { - struct Module *next; - char *name; /* module name for refcounting */ - int refCnt; /* the number of references */ - void *entry; /* entry point from load */ - struct dl_info *info; /* optional init/terminate functions */ - CdtorPtr cdtors; /* optional C++ constructors */ - GccCDtorPtr gcc_ctor; /* g++ constructors --jwe */ - GccCDtorPtr gcc_dtor; /* g++ destructors --jwe */ - int nExports; /* the number of exports found */ - ExportPtr exports; /* the array of exports */ -} Module, *ModulePtr; - -/* - * We keep a list of all loaded modules to be able to call the fini - * handlers and destructors at atexit() time. - */ -static ModulePtr modList; - -/* - * The last error from one of the dl* routines is kept in static - * variables here. Each error is returned only once to the caller. - */ -static char errbuf[BUFSIZ]; -static int errvalid; - -/* - * The `fixed' gcc header files on AIX 3.2.5 provide a prototype for - * strdup(). --jwe - */ -extern char *strdup(const char *); -static void caterr(char *); -static int readExports(ModulePtr); -static void terminate(void); -static void *findMain(void); - -void *dlopen(const char *path, int mode) -{ - register ModulePtr mp; - static void *mainModule; - - /* - * Upon the first call register a terminate handler that will - * close all libraries. Also get a reference to the main module - * for use with loadbind. - */ - if (!mainModule) { - if ((mainModule = findMain()) == NULL) - return NULL; - atexit(terminate); - } - /* - * Scan the list of modules if we have the module already loaded. - */ - for (mp = modList; mp; mp = mp->next) - if (strcmp(mp->name, path) == 0) { - mp->refCnt++; - return mp; - } - if ((mp = (ModulePtr) calloc(1, sizeof(*mp))) == NULL) { - errvalid++; - strcpy(errbuf, "calloc: "); - strcat(errbuf, strerror(errno)); - return NULL; - } - if ((mp->name = strdup(path)) == NULL) { - errvalid++; - strcpy(errbuf, "strdup: "); - strcat(errbuf, strerror(errno)); - free(mp); - return NULL; - } - /* - * load should be declared load(const char *...). Thus we - * cast the path to a normal char *. Ugly. - */ - if ((mp->entry = (void *) loadAndInit((char *) path, L_NOAUTODEFER, NULL)) == NULL) { - free(mp->name); - free(mp); - errvalid++; - strcpy(errbuf, "dlopen: "); - strcat(errbuf, path); - strcat(errbuf, ": "); - /* - * If AIX says the file is not executable, the error - * can be further described by querying the loader about - * the last error. - */ - if (errno == ENOEXEC) { - char *tmp[BUFSIZ / sizeof(char *)]; - if (loadquery(L_GETMESSAGES, tmp, sizeof(tmp)) == -1) - strcpy(errbuf, strerror(errno)); - else { - char **p; - for (p = tmp; *p; p++) - caterr(*p); - } - } - else - strcat(errbuf, strerror(errno)); - return NULL; - } - mp->refCnt = 1; - mp->next = modList; - modList = mp; - if (loadbind(0, mainModule, mp->entry) == -1) { - dlclose(mp); - errvalid++; - strcpy(errbuf, "loadbind: "); - strcat(errbuf, strerror(errno)); - return NULL; - } - /* - * If the user wants global binding, loadbind against all other - * loaded modules. - */ - if (mode & RTLD_GLOBAL) { - register ModulePtr mp1; - for (mp1 = mp->next; mp1; mp1 = mp1->next) - if (loadbind(0, mp1->entry, mp->entry) == -1) { - dlclose(mp); - errvalid++; - strcpy(errbuf, "loadbind: "); - strcat(errbuf, strerror(errno)); - return NULL; - } - } - if (readExports(mp) == -1) { - dlclose(mp); - return NULL; - } - /* - * If there is a dl_info structure, call the init function. - */ - if (mp->info = (struct dl_info *) dlsym(mp, "dl_info")) { - if (mp->info->init) - (*mp->info->init) (); - } - else - errvalid = 0; - /* - * If the shared object was compiled using xlC we will need - * to call static constructors (and later on dlclose destructors). - */ - if (mp->cdtors = (CdtorPtr) dlsym(mp, "__cdtors")) { - CdtorPtr cp = mp->cdtors; - while (cp->init || cp->term) { - if (cp->init && cp->init != (void (*)(void)) 0xffffffff) - (*cp->init) (); - cp++; - } - /* - * If the shared object was compiled using g++, we will need - * to call global constructors using the _GLOBAL__DI function, - * and later, global destructors using the _GLOBAL_DD - * funciton. --jwe - */ - } - else if (mp->gcc_ctor = (GccCDtorPtr) dlsym(mp, "_GLOBAL__DI")) { - (*mp->gcc_ctor) (); - mp->gcc_dtor = (GccCDtorPtr) dlsym(mp, "_GLOBAL__DD"); - } - else - errvalid = 0; - return mp; -} - -/* - * Attempt to decipher an AIX loader error message and append it - * to our static error message buffer. - */ -static void caterr(char *s) -{ - register char *p = s; - - while (*p >= '0' && *p <= '9') - p++; - switch (atoi(s)) { - case L_ERROR_TOOMANY: - strcat(errbuf, "to many errors"); - break; - case L_ERROR_NOLIB: - strcat(errbuf, "can't load library"); - strcat(errbuf, p); - break; - case L_ERROR_UNDEF: - strcat(errbuf, "can't find symbol"); - strcat(errbuf, p); - break; - case L_ERROR_RLDBAD: - strcat(errbuf, "bad RLD"); - strcat(errbuf, p); - break; - case L_ERROR_FORMAT: - strcat(errbuf, "bad exec format in"); - strcat(errbuf, p); - break; - case L_ERROR_ERRNO: - strcat(errbuf, strerror(atoi(++p))); - break; - default: - strcat(errbuf, s); - break; - } -} - -void *dlsym(void *handle, const char *symbol) -{ - register ModulePtr mp = (ModulePtr) handle; - register ExportPtr ep; - register int i; - - /* - * Could speed up the search, but I assume that one assigns - * the result to function pointers anyways. - */ - for (ep = mp->exports, i = mp->nExports; i; i--, ep++) - if (strcmp(ep->name, symbol) == 0) - return ep->addr; - errvalid++; - strcpy(errbuf, "dlsym: undefined symbol "); - strcat(errbuf, symbol); - return NULL; -} - -const char *dlerror(void) -{ - if (errvalid) { - errvalid = 0; - return errbuf; - } - return NULL; -} - -int dlclose(void *handle) -{ - register ModulePtr mp = (ModulePtr) handle; - int result; - register ModulePtr mp1; - - if (--mp->refCnt > 0) - return 0; - if (mp->info && mp->info->fini) - (*mp->info->fini) (); - if (mp->cdtors) { - CdtorPtr cp = mp->cdtors; - while (cp->init || cp->term) { - if (cp->term && cp->init != (void (*)(void)) 0xffffffff) - (*cp->term) (); - cp++; - } - /* - * If the function to handle global destructors for g++ - * exists, call it. --jwe - */ - } - else if (mp->gcc_dtor) { - (*mp->gcc_dtor) (); - } - result = unload(mp->entry); - if (result == -1) { - errvalid++; - strcpy(errbuf, strerror(errno)); - } - if (mp->exports) { - register ExportPtr ep; - register int i; - for (ep = mp->exports, i = mp->nExports; i; i--, ep++) - if (ep->name) - free(ep->name); - free(mp->exports); - } - if (mp == modList) - modList = mp->next; - else { - for (mp1 = modList; mp1; mp1 = mp1->next) - if (mp1->next == mp) { - mp1->next = mp->next; - break; - } - } - free(mp->name); - free(mp); - return result; -} - -static void terminate(void) -{ - while (modList) - dlclose(modList); -} - -/* - * Build the export table from the XCOFF .loader section. - */ -static int readExports(ModulePtr mp) -{ - LDFILE *ldp = NULL; - SCNHDR sh, shdata; - LDHDR *lhp; - char *ldbuf; - LDSYM *ls; - int i; - ExportPtr ep; - struct ld_info *lp; - char *buf; - int size = 4 * 1024; - void *dataorg; - - /* - * The module might be loaded due to the LIBPATH - * environment variable. Search for the loaded - * module using L_GETINFO. - */ - if ((buf = malloc(size)) == NULL) { - errvalid++; - strcpy(errbuf, "readExports: "); - strcat(errbuf, strerror(errno)); - return -1; - } - while ((i = loadquery(L_GETINFO, buf, size)) == -1 && errno == ENOMEM) { - free(buf); - size += 4 * 1024; - if ((buf = malloc(size)) == NULL) { - errvalid++; - strcpy(errbuf, "readExports: "); - strcat(errbuf, strerror(errno)); - return -1; - } - } - if (i == -1) { - errvalid++; - strcpy(errbuf, "readExports: "); - strcat(errbuf, strerror(errno)); - free(buf); - return -1; - } - /* - * Traverse the list of loaded modules. The entry point - * returned by load() does actually point to the TOC - * entry contained in the data segment. - */ - lp = (struct ld_info *) buf; - while (lp) { - if ((unsigned long) mp->entry >= (unsigned long) lp->ldinfo_dataorg && - (unsigned long) mp->entry < (unsigned long) lp->ldinfo_dataorg + - lp->ldinfo_datasize) { - dataorg = lp->ldinfo_dataorg; - ldp = ldopen(lp->ldinfo_filename, ldp); - break; - } - if (lp->ldinfo_next == 0) - lp = NULL; - else - lp = (struct ld_info *) ((char *) lp + lp->ldinfo_next); - } - free(buf); - if (!ldp) { - errvalid++; - strcpy(errbuf, "readExports: "); - strcat(errbuf, strerror(errno)); - return -1; - } - if (TYPE(ldp) != U802TOCMAGIC) { - errvalid++; - strcpy(errbuf, "readExports: bad magic"); - while (ldclose(ldp) == FAILURE); - return -1; - } - /* - * Get the padding for the data section. This is needed for - * AIX 4.1 compilers. This is used when building the final - * function pointer to the exported symbol. - */ - if (ldnshread(ldp, _DATA, &shdata) != SUCCESS) { - errvalid++; - strcpy(errbuf, "readExports: cannot read data section header"); - while (ldclose(ldp) == FAILURE); - return -1; - } - if (ldnshread(ldp, _LOADER, &sh) != SUCCESS) { - errvalid++; - strcpy(errbuf, "readExports: cannot read loader section header"); - while (ldclose(ldp) == FAILURE); - return -1; - } - /* - * We read the complete loader section in one chunk, this makes - * finding long symbol names residing in the string table easier. - */ - if ((ldbuf = (char *) malloc(sh.s_size)) == NULL) { - errvalid++; - strcpy(errbuf, "readExports: "); - strcat(errbuf, strerror(errno)); - while (ldclose(ldp) == FAILURE); - return -1; - } - if (FSEEK(ldp, sh.s_scnptr, BEGINNING) != OKFSEEK) { - errvalid++; - strcpy(errbuf, "readExports: cannot seek to loader section"); - free(ldbuf); - while (ldclose(ldp) == FAILURE); - return -1; - } - if (FREAD(ldbuf, sh.s_size, 1, ldp) != 1) { - errvalid++; - strcpy(errbuf, "readExports: cannot read loader section"); - free(ldbuf); - while (ldclose(ldp) == FAILURE); - return -1; - } - lhp = (LDHDR *) ldbuf; - ls = (LDSYM *) (ldbuf + LDHDRSZ); - /* - * Count the number of exports to include in our export table. - */ - for (i = lhp->l_nsyms; i; i--, ls++) { - if (!LDR_EXPORT(*ls)) - continue; - mp->nExports++; - } - if ((mp->exports = (ExportPtr) calloc(mp->nExports, sizeof(*mp->exports))) == NULL) { - errvalid++; - strcpy(errbuf, "readExports: "); - strcat(errbuf, strerror(errno)); - free(ldbuf); - while (ldclose(ldp) == FAILURE); - return -1; - } - /* - * Fill in the export table. All entries are relative to - * the beginning of the data origin. - */ - ep = mp->exports; - ls = (LDSYM *) (ldbuf + LDHDRSZ); - for (i = lhp->l_nsyms; i; i--, ls++) { - char *symname; - char tmpsym[SYMNMLEN + 1]; - if (!LDR_EXPORT(*ls)) - continue; - if (ls->l_zeroes == 0) - symname = ls->l_offset + lhp->l_stoff + ldbuf; - else { - /* - * The l_name member is not zero terminated, we - * must copy the first SYMNMLEN chars and make - * sure we have a zero byte at the end. - */ - strncpy(tmpsym, ls->l_name, SYMNMLEN); - tmpsym[SYMNMLEN] = '\0'; - symname = tmpsym; - } - ep->name = strdup(symname); - ep->addr = (void *) ((unsigned long) dataorg + - ls->l_value - shdata.s_vaddr); - ep++; - } - free(ldbuf); - while (ldclose(ldp) == FAILURE); - return 0; -} - -/* - * Find the main modules data origin. This is used as export pointer - * for loadbind() to be able to resolve references to the main part. - */ -static void *findMain(void) -{ - struct ld_info *lp; - char *buf; - int size = 4 * 1024; - int i; - void *ret; - - if ((buf = malloc(size)) == NULL) { - errvalid++; - strcpy(errbuf, "findMain: "); - strcat(errbuf, strerror(errno)); - return NULL; - } - while ((i = loadquery(L_GETINFO, buf, size)) == -1 && errno == ENOMEM) { - free(buf); - size += 4 * 1024; - if ((buf = malloc(size)) == NULL) { - errvalid++; - strcpy(errbuf, "findMain: "); - strcat(errbuf, strerror(errno)); - return NULL; - } - } - if (i == -1) { - errvalid++; - strcpy(errbuf, "findMain: "); - strcat(errbuf, strerror(errno)); - free(buf); - return NULL; - } - /* - * The first entry is the main module. The data segment - * starts with the TOC entries for all exports, so the - * data segment origin works as argument for loadbind. - */ - lp = (struct ld_info *) buf; - ret = lp->ldinfo_dataorg; - free(buf); - return ret; -} - -#endif diff --git a/libs/apr/dso/beos/dso.c b/libs/apr/dso/beos/dso.c deleted file mode 100644 index 91dd1b4e..00000000 --- a/libs/apr/dso/beos/dso.c +++ /dev/null @@ -1,98 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_dso.h" -#include "apr_portable.h" - -#if APR_HAS_DSO - -static apr_status_t dso_cleanup(void *thedso) -{ - apr_dso_handle_t *dso = thedso; - - if (dso->handle > 0 && unload_add_on(dso->handle) < B_NO_ERROR) - return APR_EINIT; - dso->handle = -1; - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, - const char *path, apr_pool_t *pool) -{ - image_id newid = -1; - - *res_handle = apr_pcalloc(pool, sizeof(*res_handle)); - - if((newid = load_add_on(path)) < B_NO_ERROR) { - (*res_handle)->errormsg = strerror(newid); - return APR_EDSOOPEN; - } - - (*res_handle)->pool = pool; - (*res_handle)->handle = newid; - - apr_pool_cleanup_register(pool, *res_handle, dso_cleanup, apr_pool_cleanup_null); - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_dso_unload(apr_dso_handle_t *handle) -{ - return apr_pool_cleanup_run(handle->pool, handle, dso_cleanup); -} - -APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, apr_dso_handle_t *handle, - const char *symname) -{ - int err; - - if (symname == NULL) - return APR_ESYMNOTFOUND; - - err = get_image_symbol(handle->handle, symname, B_SYMBOL_TYPE_ANY, - ressym); - - if(err != B_OK) - return APR_ESYMNOTFOUND; - - return APR_SUCCESS; -} - -APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *dso, char *buffer, apr_size_t buflen) -{ - strncpy(buffer, strerror(errno), buflen); - return buffer; -} - -APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso, - apr_os_dso_handle_t osdso, - apr_pool_t *pool) -{ - *aprdso = apr_pcalloc(pool, sizeof **aprdso); - (*aprdso)->handle = osdso; - (*aprdso)->pool = pool; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *osdso, - apr_dso_handle_t *aprdso) -{ - *osdso = aprdso->handle; - return APR_SUCCESS; -} - -#endif diff --git a/libs/apr/dso/netware/dso.c b/libs/apr/dso/netware/dso.c deleted file mode 100644 index 4cd2ad61..00000000 --- a/libs/apr/dso/netware/dso.c +++ /dev/null @@ -1,137 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_dso.h" -#include "apr_strings.h" -#include "apr_portable.h" - -#include -#include - -APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso, - apr_os_dso_handle_t osdso, - apr_pool_t *pool) -{ - *aprdso = apr_pcalloc(pool, sizeof **aprdso); - (*aprdso)->handle = osdso; - (*aprdso)->pool = pool; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *osdso, - apr_dso_handle_t *aprdso) -{ - *osdso = aprdso->handle; - return APR_SUCCESS; -} - -static apr_status_t dso_cleanup(void *thedso) -{ - apr_dso_handle_t *dso = thedso; - sym_list *symbol = NULL; - void *NLMHandle = getnlmhandle(); - - if (dso->handle == NULL) - return APR_SUCCESS; - - if (dso->symbols != NULL) { - symbol = dso->symbols; - while (symbol) { - UnImportPublicObject(NLMHandle, symbol->symbol); - symbol = symbol->next; - } - } - - if (dlclose(dso->handle) != 0) - return APR_EINIT; - - dso->handle = NULL; - dso->symbols = NULL; - dso->path = NULL; - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, - const char *path, apr_pool_t *pool) -{ - - void *os_handle = NULL; - char *fullpath = NULL; - apr_status_t rv; - - if ((rv = apr_filepath_merge(&fullpath, NULL, path, - APR_FILEPATH_NATIVE, pool)) != APR_SUCCESS) { - return rv; - } - - os_handle = dlopen(fullpath, RTLD_NOW | RTLD_LOCAL); - - *res_handle = apr_pcalloc(pool, sizeof(**res_handle)); - - if(os_handle == NULL) { - (*res_handle)->errormsg = dlerror(); - return APR_EDSOOPEN; - } - - (*res_handle)->handle = (void*)os_handle; - (*res_handle)->pool = pool; - (*res_handle)->errormsg = NULL; - (*res_handle)->symbols = NULL; - (*res_handle)->path = apr_pstrdup(pool, fullpath); - - apr_pool_cleanup_register(pool, *res_handle, dso_cleanup, apr_pool_cleanup_null); - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_dso_unload(apr_dso_handle_t *handle) -{ - return apr_pool_cleanup_run(handle->pool, handle, dso_cleanup); -} - -APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, - apr_dso_handle_t *handle, - const char *symname) -{ - sym_list *symbol = NULL; - void *retval = dlsym(handle->handle, symname); - - if (retval == NULL) { - handle->errormsg = dlerror(); - return APR_ESYMNOTFOUND; - } - - symbol = apr_pcalloc(handle->pool, sizeof(sym_list)); - symbol->next = handle->symbols; - handle->symbols = symbol; - symbol->symbol = apr_pstrdup(handle->pool, symname); - - *ressym = retval; - - return APR_SUCCESS; -} - -APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *dso, char *buffer, - apr_size_t buflen) -{ - if (dso->errormsg) { - apr_cpystrn(buffer, dso->errormsg, buflen); - return dso->errormsg; - } - return "No Error"; -} - diff --git a/libs/apr/dso/os2/dso.c b/libs/apr/dso/os2/dso.c deleted file mode 100644 index 1a7f7de8..00000000 --- a/libs/apr/dso/os2/dso.c +++ /dev/null @@ -1,132 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_dso.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include -#include - -#if APR_HAS_DSO - -static apr_status_t dso_cleanup(void *thedso) -{ - apr_dso_handle_t *dso = thedso; - int rc; - - if (dso->handle == 0) - return APR_SUCCESS; - - rc = DosFreeModule(dso->handle); - - if (rc == 0) - dso->handle = 0; - - return APR_FROM_OS_ERROR(rc); -} - - -APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, const char *path, apr_pool_t *ctx) -{ - char failed_module[200]; - HMODULE handle; - int rc; - - *res_handle = apr_pcalloc(ctx, sizeof(**res_handle)); - (*res_handle)->cont = ctx; - (*res_handle)->load_error = APR_SUCCESS; - (*res_handle)->failed_module = NULL; - - if ((rc = DosLoadModule(failed_module, sizeof(failed_module), path, &handle)) != 0) { - (*res_handle)->load_error = APR_FROM_OS_ERROR(rc); - (*res_handle)->failed_module = apr_pstrdup(ctx, failed_module); - return APR_FROM_OS_ERROR(rc); - } - - (*res_handle)->handle = handle; - apr_pool_cleanup_register(ctx, *res_handle, dso_cleanup, apr_pool_cleanup_null); - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_dso_unload(apr_dso_handle_t *handle) -{ - return apr_pool_cleanup_run(handle->cont, handle, dso_cleanup); -} - - - -APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, - apr_dso_handle_t *handle, - const char *symname) -{ - PFN func; - int rc; - - if (symname == NULL || ressym == NULL) - return APR_ESYMNOTFOUND; - - if ((rc = DosQueryProcAddr(handle->handle, 0, symname, &func)) != 0) { - handle->load_error = APR_FROM_OS_ERROR(rc); - return handle->load_error; - } - - *ressym = func; - return APR_SUCCESS; -} - - - -APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *dso, char *buffer, apr_size_t buflen) -{ - char message[200]; - apr_strerror(dso->load_error, message, sizeof(message)); - - if (dso->failed_module != NULL) { - strcat(message, " ("); - strcat(message, dso->failed_module); - strcat(message, ")"); - } - - apr_cpystrn(buffer, message, buflen); - return buffer; -} - - - -APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso, - apr_os_dso_handle_t osdso, - apr_pool_t *pool) -{ - *aprdso = apr_pcalloc(pool, sizeof **aprdso); - (*aprdso)->handle = osdso; - (*aprdso)->cont = pool; - (*aprdso)->load_error = APR_SUCCESS; - (*aprdso)->failed_module = NULL; - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *osdso, - apr_dso_handle_t *aprdso) -{ - *osdso = aprdso->handle; - return APR_SUCCESS; -} - -#endif diff --git a/libs/apr/dso/os390/dso.c b/libs/apr/dso/os390/dso.c deleted file mode 100644 index 9344c71a..00000000 --- a/libs/apr/dso/os390/dso.c +++ /dev/null @@ -1,109 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_portable.h" -#include "apr_strings.h" -#include "apr_arch_dso.h" -#include -#include - -#if APR_HAS_DSO - -APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso, - apr_os_dso_handle_t osdso, - apr_pool_t *pool) -{ - *aprdso = apr_pcalloc(pool, sizeof **aprdso); - (*aprdso)->handle = osdso; - (*aprdso)->pool = pool; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *osdso, - apr_dso_handle_t *aprdso) -{ - *osdso = aprdso->handle; - return APR_SUCCESS; -} - -static apr_status_t dso_cleanup(void *thedso) -{ - apr_dso_handle_t *dso = thedso; - int rc; - - if (dso->handle == 0) - return APR_SUCCESS; - - rc = dllfree(dso->handle); - - if (rc == 0) { - dso->handle = 0; - return APR_SUCCESS; - } - dso->failing_errno = errno; - return errno; -} - -APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, - const char *path, apr_pool_t *ctx) -{ - dllhandle *handle; - int rc; - - *res_handle = apr_pcalloc(ctx, sizeof(**res_handle)); - (*res_handle)->pool = ctx; - if ((handle = dllload(path)) != NULL) { - (*res_handle)->handle = handle; - apr_pool_cleanup_register(ctx, *res_handle, dso_cleanup, apr_pool_cleanup_null); - return APR_SUCCESS; - } - - (*res_handle)->failing_errno = errno; - return APR_EDSOOPEN; -} - -APR_DECLARE(apr_status_t) apr_dso_unload(apr_dso_handle_t *handle) -{ - return apr_pool_cleanup_run(handle->pool, handle, dso_cleanup); -} - -APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, - apr_dso_handle_t *handle, - const char *symname) -{ - void *func_ptr; - void *var_ptr; - - if ((var_ptr = dllqueryvar(handle->handle, symname)) != NULL) { - *ressym = var_ptr; - return APR_SUCCESS; - } - if ((func_ptr = (void *)dllqueryfn(handle->handle, symname)) != NULL) { - *ressym = func_ptr; - return APR_SUCCESS; - } - handle->failing_errno = errno; - return APR_ESYMNOTFOUND; -} - -APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *handle, char *buffer, - apr_size_t buflen) -{ - apr_cpystrn(buffer, strerror(handle->failing_errno), buflen); - return buffer; -} - -#endif diff --git a/libs/apr/dso/unix/dso.c b/libs/apr/dso/unix/dso.c deleted file mode 100644 index fdd56f1d..00000000 --- a/libs/apr/dso/unix/dso.c +++ /dev/null @@ -1,251 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_dso.h" -#include "apr_strings.h" -#include "apr_portable.h" - -#if APR_HAS_DSO - -#if !defined(DSO_USE_DLFCN) && !defined(DSO_USE_SHL) && !defined(DSO_USE_DYLD) -#error No DSO implementation specified. -#endif - -#ifdef HAVE_STDDEF_H -#include -#endif -#if APR_HAVE_STDLIB_H -#include /* malloc(), free() */ -#endif -#if APR_HAVE_STRING_H -#include /* for strerror() on HP-UX */ -#endif - -#if defined(DSO_USE_DYLD) -#define DYLD_LIBRARY_HANDLE (void *)-1 -#endif - -APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso, - apr_os_dso_handle_t osdso, - apr_pool_t *pool) -{ - *aprdso = apr_pcalloc(pool, sizeof **aprdso); - (*aprdso)->handle = osdso; - (*aprdso)->pool = pool; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *osdso, - apr_dso_handle_t *aprdso) -{ - *osdso = aprdso->handle; - return APR_SUCCESS; -} - -static apr_status_t dso_cleanup(void *thedso) -{ - apr_dso_handle_t *dso = thedso; - - if (dso->handle == NULL) - return APR_SUCCESS; - -#if defined(DSO_USE_SHL) - shl_unload((shl_t)dso->handle); -#elif defined(DSO_USE_DYLD) - if (dso->handle != DYLD_LIBRARY_HANDLE) { - NSUnLinkModule(dso->handle, FALSE); - } -#elif defined(DSO_USE_DLFCN) - if (dlclose(dso->handle) != 0) - return APR_EINIT; -#endif - dso->handle = NULL; - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, - const char *path, apr_pool_t *pool) -{ -#if defined(DSO_USE_SHL) - shl_t os_handle = shl_load(path, BIND_IMMEDIATE, 0L); - -#elif defined(DSO_USE_DYLD) - NSObjectFileImage image; - NSModule os_handle = NULL; - NSObjectFileImageReturnCode dsoerr; - const char* err_msg = NULL; - dsoerr = NSCreateObjectFileImageFromFile(path, &image); - - if (dsoerr == NSObjectFileImageSuccess) { -#if defined(NSLINKMODULE_OPTION_RETURN_ON_ERROR) && defined(NSLINKMODULE_OPTION_NONE) - os_handle = NSLinkModule(image, path, - NSLINKMODULE_OPTION_RETURN_ON_ERROR | - NSLINKMODULE_OPTION_NONE); - /* If something went wrong, get the errors... */ - if (!os_handle) { - NSLinkEditErrors errors; - int errorNumber; - const char *fileName; - NSLinkEditError(&errors, &errorNumber, &fileName, &err_msg); - } -#else - os_handle = NSLinkModule(image, path, FALSE); -#endif - NSDestroyObjectFileImage(image); - } - else if ((dsoerr == NSObjectFileImageFormat || - dsoerr == NSObjectFileImageInappropriateFile) && - NSAddLibrary(path) == TRUE) { - os_handle = (NSModule)DYLD_LIBRARY_HANDLE; - } - else { - err_msg = "cannot create object file image or add library"; - } - -#elif defined(DSO_USE_DLFCN) -#if defined(OSF1) || defined(SEQUENT) || defined(SNI) ||\ - (defined(__FreeBSD_version) && (__FreeBSD_version >= 220000)) ||\ - defined(__DragonFly__) - void *os_handle = dlopen((char *)path, RTLD_NOW | RTLD_GLOBAL); - -#else - int flags = RTLD_NOW | RTLD_GLOBAL; - void *os_handle; -#ifdef _AIX - if (strchr(path + 1, '(') && path[strlen(path) - 1] == ')') - { - /* This special archive.a(dso.so) syntax is required for - * the way libtool likes to build shared libraries on AIX. - * dlopen() support for such a library requires that the - * RTLD_MEMBER flag be enabled. - */ - flags |= RTLD_MEMBER; - } -#endif - os_handle = dlopen(path, flags); -#endif -#endif /* DSO_USE_x */ - - *res_handle = apr_pcalloc(pool, sizeof(**res_handle)); - - if(os_handle == NULL) { -#if defined(DSO_USE_SHL) - (*res_handle)->errormsg = strerror(errno); - return APR_EDSOOPEN; -#elif defined(DSO_USE_DYLD) - (*res_handle)->errormsg = (err_msg) ? err_msg : "link failed"; - return APR_EDSOOPEN; -#elif defined(DSO_USE_DLFCN) - (*res_handle)->errormsg = dlerror(); - return APR_EDSOOPEN; -#endif - } - - (*res_handle)->handle = (void*)os_handle; - (*res_handle)->pool = pool; - (*res_handle)->errormsg = NULL; - - apr_pool_cleanup_register(pool, *res_handle, dso_cleanup, apr_pool_cleanup_null); - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_dso_unload(apr_dso_handle_t *handle) -{ - return apr_pool_cleanup_run(handle->pool, handle, dso_cleanup); -} - -APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, - apr_dso_handle_t *handle, - const char *symname) -{ -#if defined(DSO_USE_SHL) - void *symaddr = NULL; - int status; - - errno = 0; - status = shl_findsym((void *)&handle->handle, symname, TYPE_PROCEDURE, &symaddr); - if (status == -1 && errno == 0) /* try TYPE_DATA instead */ - status = shl_findsym((void *)&handle->handle, symname, TYPE_DATA, &symaddr); - if (status == -1) - return APR_ESYMNOTFOUND; - *ressym = symaddr; - return APR_SUCCESS; - -#elif defined(DSO_USE_DYLD) - void *retval = NULL; - NSSymbol symbol; - char *symname2 = (char*)malloc(sizeof(char)*(strlen(symname)+2)); - sprintf(symname2, "_%s", symname); -#ifdef NSLINKMODULE_OPTION_PRIVATE - if (handle->handle == DYLD_LIBRARY_HANDLE) { - symbol = NSLookupAndBindSymbol(symname2); - } - else { - symbol = NSLookupSymbolInModule((NSModule)handle->handle, symname2); - } -#else - symbol = NSLookupAndBindSymbol(symname2); -#endif - free(symname2); - if (symbol == NULL) { - handle->errormsg = "undefined symbol"; - return APR_ESYMNOTFOUND; - } - retval = NSAddressOfSymbol(symbol); - if (retval == NULL) { - handle->errormsg = "cannot resolve symbol"; - return APR_ESYMNOTFOUND; - } - *ressym = retval; - return APR_SUCCESS; -#elif defined(DSO_USE_DLFCN) - -#if defined(DLSYM_NEEDS_UNDERSCORE) - void *retval; - char *symbol = (char*)malloc(sizeof(char)*(strlen(symname)+2)); - sprintf(symbol, "_%s", symname); - retval = dlsym(handle->handle, symbol); - free(symbol); -#elif defined(SEQUENT) || defined(SNI) - void *retval = dlsym(handle->handle, (char *)symname); -#else - void *retval = dlsym(handle->handle, symname); -#endif /* DLSYM_NEEDS_UNDERSCORE */ - - if (retval == NULL) { - handle->errormsg = dlerror(); - return APR_ESYMNOTFOUND; - } - - *ressym = retval; - - return APR_SUCCESS; -#endif /* DSO_USE_x */ -} - -APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *dso, char *buffer, - apr_size_t buflen) -{ - if (dso->errormsg) { - apr_cpystrn(buffer, dso->errormsg, buflen); - return dso->errormsg; - } - return "No Error"; -} - -#endif diff --git a/libs/apr/dso/win32/dso.c b/libs/apr/dso/win32/dso.c deleted file mode 100644 index d4a68938..00000000 --- a/libs/apr/dso/win32/dso.c +++ /dev/null @@ -1,167 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_dso.h" -#include "apr_strings.h" -#include "apr_private.h" -#include "apr_arch_file_io.h" -#include "apr_arch_utf8.h" - -#if APR_HAS_DSO - -APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso, - apr_os_dso_handle_t osdso, - apr_pool_t *pool) -{ - *aprdso = apr_pcalloc(pool, sizeof **aprdso); - (*aprdso)->handle = osdso; - (*aprdso)->cont = pool; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *osdso, - apr_dso_handle_t *aprdso) -{ - *osdso = aprdso->handle; - return APR_SUCCESS; -} - -static apr_status_t dso_cleanup(void *thedso) -{ - apr_dso_handle_t *dso = thedso; - - if (dso->handle != NULL && !FreeLibrary(dso->handle)) { - return apr_get_os_error(); - } - dso->handle = NULL; - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_dso_load(struct apr_dso_handle_t **res_handle, - const char *path, apr_pool_t *ctx) -{ - HINSTANCE os_handle; - apr_status_t rv; -#ifndef _WIN32_WCE - UINT em; -#endif - -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - apr_wchar_t wpath[APR_PATH_MAX]; - if ((rv = utf8_to_unicode_path(wpath, sizeof(wpath) - / sizeof(apr_wchar_t), path)) - != APR_SUCCESS) { - *res_handle = apr_pcalloc(ctx, sizeof(**res_handle)); - return ((*res_handle)->load_error = rv); - } - /* Prevent ugly popups from killing our app */ -#ifndef _WIN32_WCE - em = SetErrorMode(SEM_FAILCRITICALERRORS); -#endif - os_handle = LoadLibraryExW(wpath, NULL, 0); - if (!os_handle) - os_handle = LoadLibraryExW(wpath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); - if (!os_handle) - rv = apr_get_os_error(); -#ifndef _WIN32_WCE - SetErrorMode(em); -#endif - } -#endif /* APR_HAS_UNICODE_FS */ -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - char fspec[APR_PATH_MAX], *p = fspec; - /* Must convert path from / to \ notation. - * Per PR2555, the LoadLibraryEx function is very picky about slashes. - * Debugging on NT 4 SP 6a reveals First Chance Exception within NTDLL. - * LoadLibrary in the MS PSDK also reveals that it -explicitly- states - * that backslashes must be used for the LoadLibrary family of calls. - */ - apr_cpystrn(fspec, path, sizeof(fspec)); - while ((p = strchr(p, '/')) != NULL) - *p = '\\'; - - /* Prevent ugly popups from killing our app */ - em = SetErrorMode(SEM_FAILCRITICALERRORS); - os_handle = LoadLibraryEx(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); - if (!os_handle) - os_handle = LoadLibraryEx(path, NULL, 0); - if (!os_handle) - rv = apr_get_os_error(); - else - rv = APR_SUCCESS; - SetErrorMode(em); - } -#endif - - *res_handle = apr_pcalloc(ctx, sizeof(**res_handle)); - (*res_handle)->cont = ctx; - - if (rv) { - return ((*res_handle)->load_error = rv); - } - - (*res_handle)->handle = (void*)os_handle; - (*res_handle)->load_error = APR_SUCCESS; - - apr_pool_cleanup_register(ctx, *res_handle, dso_cleanup, apr_pool_cleanup_null); - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_dso_unload(struct apr_dso_handle_t *handle) -{ - return apr_pool_cleanup_run(handle->cont, handle, dso_cleanup); -} - -APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, - struct apr_dso_handle_t *handle, - const char *symname) -{ -#ifdef _WIN32_WCE - apr_size_t symlen = strlen(symname) + 1; - apr_size_t wsymlen = 256; - apr_wchar_t wsymname[256]; - apr_status_t rv; - - rv = apr_conv_utf8_to_ucs2(wsymname, &wsymlen, symname, &symlen); - if (rv != APR_SUCCESS) { - return rv; - } - else if (symlen) { - return APR_ENAMETOOLONG; - } - - *ressym = (apr_dso_handle_sym_t)GetProcAddressW(handle->handle, wsymname); -#else - *ressym = (apr_dso_handle_sym_t)GetProcAddress(handle->handle, symname); -#endif - if (!*ressym) { - return apr_get_os_error(); - } - return APR_SUCCESS; -} - -APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *dso, char *buf, apr_size_t bufsize) -{ - return apr_strerror(dso->load_error, buf, bufsize); -} - -#endif diff --git a/libs/apr/emacs-mode b/libs/apr/emacs-mode deleted file mode 100644 index 2c7abe98..00000000 --- a/libs/apr/emacs-mode +++ /dev/null @@ -1,15 +0,0 @@ -;; M-x load-file -;; or emacs -l -;; to use this style: C-c . apache -(c-add-style "apache" - '((inclass . ++) - (defun-block-intro . ++) - (statement-block-intro . ++) - (substatement . ++) - (brace-list-intro . ++) - (statement-case-intro . ++) - (inextern-lang . 0) - )) -(setq-default indent-tabs-mode nil) -;; if you forgot to do this at startup, then M-x eval-expression -;; (setq indent-tabs-mode nil) on each buffer diff --git a/libs/apr/file_io/netware/filepath.c b/libs/apr/file_io/netware/filepath.c deleted file mode 100644 index e4bb3f36..00000000 --- a/libs/apr/file_io/netware/filepath.c +++ /dev/null @@ -1,4 +0,0 @@ -/* NetWare & Win32 have much in common with regards to file names (both are - * DOSish) so it makes sense to share some code - */ -#include "../win32/filepath.c" diff --git a/libs/apr/file_io/netware/filestat.c b/libs/apr/file_io/netware/filestat.c deleted file mode 100644 index 66279512..00000000 --- a/libs/apr/file_io/netware/filestat.c +++ /dev/null @@ -1,417 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_file_io.h" -#include "fsio.h" -#include "nks/dirio.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_errno.h" -#include "apr_hash.h" -#include "apr_thread_rwlock.h" - -#ifdef HAVE_UTIME_H -#include -#endif - -#define APR_HAS_PSA - -static apr_filetype_e filetype_from_mode(mode_t mode) -{ - apr_filetype_e type = APR_NOFILE; - - if (S_ISREG(mode)) - type = APR_REG; - else if (S_ISDIR(mode)) - type = APR_DIR; - else if (S_ISCHR(mode)) - type = APR_CHR; - else if (S_ISBLK(mode)) - type = APR_BLK; - else if (S_ISFIFO(mode)) - type = APR_PIPE; - else if (S_ISLNK(mode)) - type = APR_LNK; - else if (S_ISSOCK(mode)) - type = APR_SOCK; - else - type = APR_UNKFILE; - return type; -} - -static void fill_out_finfo(apr_finfo_t *finfo, struct stat *info, - apr_int32_t wanted) -{ - finfo->valid = APR_FINFO_MIN | APR_FINFO_IDENT | APR_FINFO_NLINK - | APR_FINFO_OWNER | APR_FINFO_PROT; - - finfo->protection = apr_unix_mode2perms(info->st_mode); - finfo->filetype = filetype_from_mode(info->st_mode); - finfo->user = info->st_uid; - finfo->group = info->st_gid; - finfo->size = info->st_size; - finfo->inode = info->st_ino; - finfo->device = info->st_dev; - finfo->nlink = info->st_nlink; - - apr_time_ansi_put(&finfo->atime, info->st_atime.tv_sec); - apr_time_ansi_put(&finfo->mtime, info->st_mtime.tv_sec); - apr_time_ansi_put(&finfo->ctime, info->st_ctime.tv_sec); - -#ifdef HAVE_STRUCT_STAT_ST_BLOCKS -#ifdef DEV_BSIZE - finfo->csize = (apr_off_t)info->st_blocks * (apr_off_t)DEV_BSIZE; -#else - finfo->csize = (apr_off_t)info->st_blocks * (apr_off_t)512; -#endif - finfo->valid |= APR_FINFO_CSIZE; -#endif -} - -apr_status_t apr_file_info_get_locked(apr_finfo_t *finfo, apr_int32_t wanted, - apr_file_t *thefile) -{ - struct_stat info; - - if (thefile->buffered) { - apr_status_t rv = apr_file_flush_locked(thefile); - if (rv != APR_SUCCESS) - return rv; - } - - if (fstat(thefile->filedes, &info) == 0) { - finfo->pool = thefile->pool; - finfo->fname = thefile->fname; - fill_out_finfo(finfo, &info, wanted); - return (wanted & ~finfo->valid) ? APR_INCOMPLETE : APR_SUCCESS; - } - else { - return errno; - } -} - -APR_DECLARE(apr_status_t) apr_file_info_get(apr_finfo_t *finfo, - apr_int32_t wanted, - apr_file_t *thefile) -{ - struct stat info; - - if (thefile->buffered) { - /* XXX: flush here is not mutex protected */ - apr_status_t rv = apr_file_flush(thefile); - if (rv != APR_SUCCESS) - return rv; - } - - if (fstat(thefile->filedes, &info) == 0) { - finfo->pool = thefile->pool; - finfo->fname = thefile->fname; - fill_out_finfo(finfo, &info, wanted); - return (wanted & ~finfo->valid) ? APR_INCOMPLETE : APR_SUCCESS; - } - else { - return errno; - } -} - -APR_DECLARE(apr_status_t) apr_file_perms_set(const char *fname, - apr_fileperms_t perms) -{ - mode_t mode = apr_unix_perms2mode(perms); - - if (chmod(fname, mode) == -1) - return errno; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, - apr_fileattrs_t attributes, - apr_fileattrs_t attr_mask, - apr_pool_t *pool) -{ - apr_status_t status; - apr_finfo_t finfo; - - /* Don't do anything if we can't handle the requested attributes */ - if (!(attr_mask & (APR_FILE_ATTR_READONLY - | APR_FILE_ATTR_EXECUTABLE))) - return APR_SUCCESS; - - status = apr_stat(&finfo, fname, APR_FINFO_PROT, pool); - if (status) - return status; - - /* ### TODO: should added bits be umask'd? */ - if (attr_mask & APR_FILE_ATTR_READONLY) - { - if (attributes & APR_FILE_ATTR_READONLY) - { - finfo.protection &= ~APR_UWRITE; - finfo.protection &= ~APR_GWRITE; - finfo.protection &= ~APR_WWRITE; - } - else - { - /* ### umask this! */ - finfo.protection |= APR_UWRITE; - finfo.protection |= APR_GWRITE; - finfo.protection |= APR_WWRITE; - } - } - - if (attr_mask & APR_FILE_ATTR_EXECUTABLE) - { - if (attributes & APR_FILE_ATTR_EXECUTABLE) - { - /* ### umask this! */ - finfo.protection |= APR_UEXECUTE; - finfo.protection |= APR_GEXECUTE; - finfo.protection |= APR_WEXECUTE; - } - else - { - finfo.protection &= ~APR_UEXECUTE; - finfo.protection &= ~APR_GEXECUTE; - finfo.protection &= ~APR_WEXECUTE; - } - } - - return apr_file_perms_set(fname, finfo.protection); -} - -#ifndef APR_HAS_PSA -static apr_status_t stat_cache_cleanup(void *data) -{ - apr_pool_t *p = (apr_pool_t *)getGlobalPool(); - apr_hash_index_t *hi; - apr_hash_t *statCache = (apr_hash_t*)data; - char *key; - apr_ssize_t keylen; - NXPathCtx_t pathctx; - - for (hi = apr_hash_first(p, statCache); hi; hi = apr_hash_next(hi)) { - apr_hash_this(hi, (const void**)&key, &keylen, (void**)&pathctx); - - if (pathctx) { - NXFreePathContext(pathctx); - } - } - - return APR_SUCCESS; -} - -int cstat (NXPathCtx_t ctx, char *path, struct stat *buf, unsigned long requestmap, apr_pool_t *p) -{ - apr_pool_t *gPool = (apr_pool_t *)getGlobalPool(); - apr_hash_t *statCache = NULL; - apr_thread_rwlock_t *rwlock = NULL; - - NXPathCtx_t pathctx = 0; - char *ptr = NULL, *tr; - int len = 0, x; - char *ppath; - char *pinfo; - - if (ctx == 1) { - - /* If there isn't a global pool then just stat the file - and return */ - if (!gPool) { - char poolname[50]; - - if (apr_pool_create(&gPool, NULL) != APR_SUCCESS) { - return getstat(ctx, path, buf, requestmap); - } - - setGlobalPool(gPool); - apr_pool_tag(gPool, apr_pstrdup(gPool, "cstat_mem_pool")); - - statCache = apr_hash_make(gPool); - apr_pool_userdata_set ((void*)statCache, "STAT_CACHE", stat_cache_cleanup, gPool); - - apr_thread_rwlock_create(&rwlock, gPool); - apr_pool_userdata_set ((void*)rwlock, "STAT_CACHE_LOCK", apr_pool_cleanup_null, gPool); - } - else { - apr_pool_userdata_get((void**)&statCache, "STAT_CACHE", gPool); - apr_pool_userdata_get((void**)&rwlock, "STAT_CACHE_LOCK", gPool); - } - - if (!gPool || !statCache || !rwlock) { - return getstat(ctx, path, buf, requestmap); - } - - for (x = 0,tr = path;*tr != '\0';tr++,x++) { - if (*tr == '\\' || *tr == '/') { - ptr = tr; - len = x; - } - if (*tr == ':') { - ptr = "\\"; - len = x; - } - } - - if (ptr) { - ppath = apr_pstrndup (p, path, len); - strlwr(ppath); - if (ptr[1] != '\0') { - ptr++; - } - /* If the path ended in a trailing slash then our result path - will be a single slash. To avoid stat'ing the root with a - slash, we need to make sure we stat the current directory - with a dot */ - if (((*ptr == '/') || (*ptr == '\\')) && (*(ptr+1) == '\0')) { - pinfo = apr_pstrdup (p, "."); - } - else { - pinfo = apr_pstrdup (p, ptr); - } - } - - /* If we have a statCache then try to pull the information - from the cache. Otherwise just stat the file and return.*/ - if (statCache) { - apr_thread_rwlock_rdlock(rwlock); - pathctx = (NXPathCtx_t) apr_hash_get(statCache, ppath, APR_HASH_KEY_STRING); - apr_thread_rwlock_unlock(rwlock); - if (pathctx) { - return getstat(pathctx, pinfo, buf, requestmap); - } - else { - int err; - - err = NXCreatePathContext(0, ppath, 0, NULL, &pathctx); - if (!err) { - apr_thread_rwlock_wrlock(rwlock); - apr_hash_set(statCache, apr_pstrdup(gPool,ppath) , APR_HASH_KEY_STRING, (void*)pathctx); - apr_thread_rwlock_unlock(rwlock); - return getstat(pathctx, pinfo, buf, requestmap); - } - } - } - } - return getstat(ctx, path, buf, requestmap); -} -#endif - -APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, - const char *fname, - apr_int32_t wanted, apr_pool_t *pool) -{ - struct stat info; - int srv; - NXPathCtx_t pathCtx = 0; - - getcwdpath(NULL, &pathCtx, CTX_ACTUAL_CWD); -#ifdef APR_HAS_PSA - srv = getstat(pathCtx, (char*)fname, &info, ST_STAT_BITS|ST_NAME_BIT); -#else - srv = cstat(pathCtx, (char*)fname, &info, ST_STAT_BITS|ST_NAME_BIT, pool); -#endif - errno = srv; - - if (srv == 0) { - finfo->pool = pool; - finfo->fname = fname; - fill_out_finfo(finfo, &info, wanted); - if (wanted & APR_FINFO_LINK) - wanted &= ~APR_FINFO_LINK; - if (wanted & APR_FINFO_NAME) { - finfo->name = apr_pstrdup(pool, info.st_name); - finfo->valid |= APR_FINFO_NAME; - } - return (wanted & ~finfo->valid) ? APR_INCOMPLETE : APR_SUCCESS; - } - else { -#if !defined(ENOENT) || !defined(ENOTDIR) -#error ENOENT || ENOTDIR not defined; please see the -#error comments at this line in the source for a workaround. - /* - * If ENOENT || ENOTDIR is not defined in one of the your OS's - * include files, APR cannot report a good reason why the stat() - * of the file failed; there are cases where it can fail even though - * the file exists. This opens holes in Apache, for example, because - * it becomes possible for someone to get a directory listing of a - * directory even though there is an index (eg. index.html) file in - * it. If you do not have a problem with this, delete the above - * #error lines and start the compile again. If you need to do this, - * please submit a bug report to http://www.apache.org/bug_report.html - * letting us know that you needed to do this. Please be sure to - * include the operating system you are using. - */ - /* WARNING: All errors will be handled as not found - */ -#if !defined(ENOENT) - return APR_ENOENT; -#else - /* WARNING: All errors but not found will be handled as not directory - */ - if (errno != ENOENT) - return APR_ENOENT; - else - return errno; -#endif -#else /* All was defined well, report the usual: */ - return errno; -#endif - } -} - -APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname, - apr_time_t mtime, - apr_pool_t *pool) -{ - apr_status_t status; - apr_finfo_t finfo; - - status = apr_stat(&finfo, fname, APR_FINFO_ATIME, pool); - if (status) { - return status; - } - -#ifdef HAVE_UTIMES - { - struct timeval tvp[2]; - - tvp[0].tv_sec = apr_time_sec(finfo.atime); - tvp[0].tv_usec = apr_time_usec(finfo.atime); - tvp[1].tv_sec = apr_time_sec(mtime); - tvp[1].tv_usec = apr_time_usec(mtime); - - if (utimes(fname, tvp) == -1) { - return errno; - } - } -#elif defined(HAVE_UTIME) - { - struct utimbuf buf; - - buf.actime = (time_t) (finfo.atime / APR_USEC_PER_SEC); - buf.modtime = (time_t) (mtime / APR_USEC_PER_SEC); - - if (utime(fname, &buf) == -1) { - return errno; - } - } -#else - return APR_ENOTIMPL; -#endif - - return APR_SUCCESS; -} diff --git a/libs/apr/file_io/netware/filesys.c b/libs/apr/file_io/netware/filesys.c deleted file mode 100644 index 05c44cec..00000000 --- a/libs/apr/file_io/netware/filesys.c +++ /dev/null @@ -1,106 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_arch_file_io.h" -#include "apr_strings.h" - -apr_status_t filepath_root_case(char **rootpath, char *root, apr_pool_t *p) -{ -/* See the Windows code to figure out what to do here. - It probably checks to make sure that the root exists - and case it correctly according to the file system. -*/ - *rootpath = apr_pstrdup(p, root); - return APR_SUCCESS; -} - -apr_status_t filepath_has_drive(const char *rootpath, int only, apr_pool_t *p) -{ - char *s; - - if (rootpath) { - s = strchr (rootpath, ':'); - if (only) - /* Test if the path only has a drive/volume and nothing else - */ - return (s && (s != rootpath) && !s[1]); - else - /* Test if the path includes a drive/volume - */ - return (s && (s != rootpath)); - } - return 0; -} - -apr_status_t filepath_compare_drive(const char *path1, const char *path2, apr_pool_t *p) -{ - char *s1, *s2; - - if (path1 && path2) { - s1 = strchr (path1, ':'); - s2 = strchr (path2, ':'); - - /* Make sure that they both have a drive/volume delimiter - and are the same size. Then see if they match. - */ - if (s1 && s2 && ((s1-path1) == (s2-path2))) { - return strnicmp (s1, s2, s1-path1); - } - } - return -1; -} - -APR_DECLARE(apr_status_t) apr_filepath_get(char **rootpath, apr_int32_t flags, - apr_pool_t *p) -{ - char path[APR_PATH_MAX]; - char *ptr; - - /* use getcwdpath to make sure that we get the volume name*/ - if (!getcwdpath(path, NULL, 0)) { - if (errno == ERANGE) - return APR_ENAMETOOLONG; - else - return errno; - } - /* Strip off the server name if there is one*/ - ptr = strpbrk(path, "\\/:"); - if (!ptr) { - return APR_ENOENT; - } - if (*ptr == ':') { - ptr = path; - } - *rootpath = apr_pstrdup(p, ptr); - if (!(flags & APR_FILEPATH_NATIVE)) { - for (ptr = *rootpath; *ptr; ++ptr) { - if (*ptr == '\\') - *ptr = '/'; - } - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_filepath_set(const char *rootpath, - apr_pool_t *p) -{ - if (chdir2(rootpath) != 0) - return errno; - return APR_SUCCESS; -} - - diff --git a/libs/apr/file_io/netware/flock.c b/libs/apr/file_io/netware/flock.c deleted file mode 100644 index c083a0ed..00000000 --- a/libs/apr/file_io/netware/flock.c +++ /dev/null @@ -1,39 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include "apr_arch_file_io.h" - - -apr_status_t apr_file_lock(apr_file_t *thefile, int type) -{ - int fc; - - fc = (type & APR_FLOCK_NONBLOCK) ? NX_RANGE_LOCK_TRYLOCK : NX_RANGE_LOCK_CHECK; - - if(NXFileRangeLock(thefile->filedes,fc, 0, 0) == -1) - return errno; - - return APR_SUCCESS; -} - -apr_status_t apr_file_unlock(apr_file_t *thefile) -{ - if(NXFileRangeUnlock(thefile->filedes,NX_RANGE_LOCK_CANCEL,0 , 0) == -1) - return errno; - - return APR_SUCCESS; -} diff --git a/libs/apr/file_io/netware/mktemp.c b/libs/apr/file_io/netware/mktemp.c deleted file mode 100644 index 4f78226e..00000000 --- a/libs/apr/file_io/netware/mktemp.c +++ /dev/null @@ -1,64 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_private.h" -#include "apr_file_io.h" /* prototype of apr_mkstemp() */ -#include "apr_strings.h" /* prototype of apr_mkstemp() */ -#include "apr_arch_file_io.h" /* prototype of apr_mkstemp() */ -#include "apr_portable.h" /* for apr_os_file_put() */ -#include "apr_arch_inherit.h" - -#include /* for mkstemp() - Single Unix */ - -APR_DECLARE(apr_status_t) apr_file_mktemp(apr_file_t **fp, char *template, apr_int32_t flags, apr_pool_t *p) -{ - int fd; - apr_status_t rv; - - flags = (!flags) ? APR_FOPEN_CREATE | APR_FOPEN_READ | APR_FOPEN_WRITE | - APR_FOPEN_DELONCLOSE : flags & ~APR_FOPEN_EXCL; - - fd = mkstemp(template); - if (fd == -1) { - return errno; - } - /* We need to reopen the file to get rid of the o_excl flag. - * Otherwise file locking will not allow the file to be shared. - */ - close(fd); - if ((rv = apr_file_open(fp, template, flags|APR_FOPEN_NOCLEANUP, - APR_UREAD | APR_UWRITE, p)) == APR_SUCCESS) { - - - if (!(flags & APR_FOPEN_NOCLEANUP)) { - int flags; - - if ((flags = fcntl((*fp)->filedes, F_GETFD)) == -1) - return errno; - - flags |= FD_CLOEXEC; - if (fcntl((*fp)->filedes, F_SETFD, flags) == -1) - return errno; - - apr_pool_cleanup_register((*fp)->pool, (void *)(*fp), - apr_unix_file_cleanup, - apr_unix_child_file_cleanup); - } - } - - return rv; -} - diff --git a/libs/apr/file_io/netware/pipe.c b/libs/apr/file_io/netware/pipe.c deleted file mode 100644 index f88f1e62..00000000 --- a/libs/apr/file_io/netware/pipe.c +++ /dev/null @@ -1,211 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#include "apr_arch_file_io.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_arch_inherit.h" - -static apr_status_t pipeblock(apr_file_t *thepipe) -{ -#ifdef USE_FLAGS - unsigned long flags; - - if (fcntl(thepipe->filedes, F_GETFL, &flags) != -1) - { - flags &= ~FNDELAY; - fcntl(thepipe->filedes, F_SETFL, flags); - } -#else - errno = 0; - fcntl(thepipe->filedes, F_SETFL, 0); -#endif - - if (errno) - return errno; - - thepipe->blocking = BLK_ON; - return APR_SUCCESS; -} - -static apr_status_t pipenonblock(apr_file_t *thepipe) -{ -#ifdef USE_FLAGS - unsigned long flags; - - errno = 0; - if (fcntl(thepipe->filedes, F_GETFL, &flags) != -1) - { - flags |= FNDELAY; - fcntl(thepipe->filedes, F_SETFL, flags); - } -#else - errno = 0; - fcntl(thepipe->filedes, F_SETFL, FNDELAY); -#endif - - if (errno) - return errno; - - thepipe->blocking = BLK_OFF; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_pipe_timeout_set(apr_file_t *thepipe, apr_interval_time_t timeout) -{ - if (thepipe->is_pipe == 1) { - thepipe->timeout = timeout; - if (timeout >= 0) { - if (thepipe->blocking != BLK_OFF) { /* blocking or unknown state */ - return pipenonblock(thepipe); - } - } - else { - if (thepipe->blocking != BLK_ON) { /* non-blocking or unknown state */ - return pipeblock(thepipe); - } - } - return APR_SUCCESS; - } - return APR_EINVAL; -} - -APR_DECLARE(apr_status_t) apr_file_pipe_timeout_get(apr_file_t *thepipe, apr_interval_time_t *timeout) -{ - if (thepipe->is_pipe == 1) { - *timeout = thepipe->timeout; - return APR_SUCCESS; - } - return APR_EINVAL; -} - -APR_DECLARE(apr_status_t) apr_os_pipe_put_ex(apr_file_t **file, - apr_os_file_t *thefile, - int register_cleanup, - apr_pool_t *pool) -{ - int *dafile = thefile; - - (*file) = apr_pcalloc(pool, sizeof(apr_file_t)); - (*file)->pool = pool; - (*file)->eof_hit = 0; - (*file)->is_pipe = 1; - (*file)->blocking = BLK_UNKNOWN; /* app needs to make a timeout call */ - (*file)->timeout = -1; - (*file)->ungetchar = -1; /* no char avail */ - (*file)->filedes = *dafile; - if (!register_cleanup) { - (*file)->flags = APR_FOPEN_NOCLEANUP; - } - (*file)->buffered = 0; -#if APR_HAS_THREADS - (*file)->thlock = NULL; -#endif - if (register_cleanup) { - apr_pool_cleanup_register((*file)->pool, (void *)(*file), - apr_unix_file_cleanup, - apr_pool_cleanup_null); - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_pipe_put(apr_file_t **file, - apr_os_file_t *thefile, - apr_pool_t *pool) -{ - return apr_os_pipe_put_ex(file, thefile, 0, pool); -} - -APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, apr_file_t **out, apr_pool_t *pool) -{ - int filedes[2]; - - if (pipe(filedes) == -1) { - return errno; - } - - (*in) = (apr_file_t *)apr_pcalloc(pool, sizeof(apr_file_t)); - (*out) = (apr_file_t *)apr_pcalloc(pool, sizeof(apr_file_t)); - - (*in)->pool = - (*out)->pool = pool; - (*in)->filedes = filedes[0]; - (*out)->filedes = filedes[1]; - (*in)->flags = APR_INHERIT; - (*out)->flags = APR_INHERIT; - (*in)->is_pipe = - (*out)->is_pipe = 1; - (*out)->fname = - (*in)->fname = NULL; - (*in)->buffered = - (*out)->buffered = 0; - (*in)->blocking = - (*out)->blocking = BLK_ON; - (*in)->timeout = - (*out)->timeout = -1; - (*in)->ungetchar = -1; - (*in)->thlock = - (*out)->thlock = NULL; - (void) apr_pollset_create(&(*in)->pollset, 1, pool, 0); - (void) apr_pollset_create(&(*out)->pollset, 1, pool, 0); - - apr_pool_cleanup_register((*in)->pool, (void *)(*in), apr_unix_file_cleanup, - apr_pool_cleanup_null); - apr_pool_cleanup_register((*out)->pool, (void *)(*out), apr_unix_file_cleanup, - apr_pool_cleanup_null); - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_pipe_create_ex(apr_file_t **in, - apr_file_t **out, - apr_int32_t blocking, - apr_pool_t *pool) -{ - apr_status_t status; - - if ((status = apr_file_pipe_create(in, out, pool)) != APR_SUCCESS) - return status; - - switch (blocking) { - case APR_FULL_BLOCK: - break; - case APR_READ_BLOCK: - apr_file_pipe_timeout_set(*out, 0); - break; - case APR_WRITE_BLOCK: - apr_file_pipe_timeout_set(*in, 0); - break; - default: - apr_file_pipe_timeout_set(*out, 0); - apr_file_pipe_timeout_set(*in, 0); - } - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_namedpipe_create(const char *filename, - apr_fileperms_t perm, apr_pool_t *pool) -{ - return APR_ENOTIMPL; -} - - - diff --git a/libs/apr/file_io/os2/buffer.c b/libs/apr/file_io/os2/buffer.c deleted file mode 100644 index 34e4e639..00000000 --- a/libs/apr/file_io/os2/buffer.c +++ /dev/null @@ -1,59 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_file_io.h" -#include "apr_thread_mutex.h" - -APR_DECLARE(apr_status_t) apr_file_buffer_set(apr_file_t *file, - char * buffer, - apr_size_t bufsize) -{ - apr_status_t rv; - - apr_thread_mutex_lock(file->mutex); - - if(file->buffered) { - /* Flush the existing buffer */ - rv = apr_file_flush(file); - if (rv != APR_SUCCESS) { - apr_thread_mutex_unlock(file->mutex); - return rv; - } - } - - file->buffer = buffer; - file->bufsize = bufsize; - file->buffered = 1; - file->bufpos = 0; - file->direction = 0; - file->dataRead = 0; - - if (file->bufsize == 0) { - /* Setting the buffer size to zero is equivalent to turning - * buffering off. - */ - file->buffered = 0; - } - - apr_thread_mutex_unlock(file->mutex); - - return APR_SUCCESS; -} - -APR_DECLARE(apr_size_t) apr_file_buffer_size_get(apr_file_t *file) -{ - return file->bufsize; -} diff --git a/libs/apr/file_io/os2/copy.c b/libs/apr/file_io/os2/copy.c deleted file mode 100644 index f4ce010f..00000000 --- a/libs/apr/file_io/os2/copy.c +++ /dev/null @@ -1 +0,0 @@ -#include "../unix/copy.c" diff --git a/libs/apr/file_io/os2/dir.c b/libs/apr/file_io/os2/dir.c deleted file mode 100644 index 3b08355f..00000000 --- a/libs/apr/file_io/os2/dir.c +++ /dev/null @@ -1,167 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include - -static apr_status_t dir_cleanup(void *thedir) -{ - apr_dir_t *dir = thedir; - return apr_dir_close(dir); -} - - - -APR_DECLARE(apr_status_t) apr_dir_open(apr_dir_t **new, const char *dirname, apr_pool_t *pool) -{ - apr_dir_t *thedir = (apr_dir_t *)apr_palloc(pool, sizeof(apr_dir_t)); - - if (thedir == NULL) - return APR_ENOMEM; - - thedir->pool = pool; - thedir->dirname = apr_pstrdup(pool, dirname); - - if (thedir->dirname == NULL) - return APR_ENOMEM; - - thedir->handle = 0; - thedir->validentry = FALSE; - *new = thedir; - apr_pool_cleanup_register(pool, thedir, dir_cleanup, apr_pool_cleanup_null); - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_dir_close(apr_dir_t *thedir) -{ - int rv = 0; - - if (thedir->handle) { - rv = DosFindClose(thedir->handle); - - if (rv == 0) { - thedir->handle = 0; - } - } - - return APR_FROM_OS_ERROR(rv); -} - - - -APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, - apr_dir_t *thedir) -{ - int rv; - ULONG entries = 1; - - if (thedir->handle == 0) { - thedir->handle = HDIR_CREATE; - rv = DosFindFirst(apr_pstrcat(thedir->pool, thedir->dirname, "/*", NULL), &thedir->handle, - FILE_ARCHIVED|FILE_DIRECTORY|FILE_SYSTEM|FILE_HIDDEN|FILE_READONLY, - &thedir->entry, sizeof(thedir->entry), &entries, FIL_STANDARD); - } else { - rv = DosFindNext(thedir->handle, &thedir->entry, sizeof(thedir->entry), &entries); - } - - finfo->pool = thedir->pool; - finfo->fname = NULL; - finfo->valid = 0; - - if (rv == 0 && entries == 1) { - thedir->validentry = TRUE; - - /* We passed a name off the stack that has popped */ - finfo->fname = NULL; - finfo->size = thedir->entry.cbFile; - finfo->csize = thedir->entry.cbFileAlloc; - - /* Only directories & regular files show up in directory listings */ - finfo->filetype = (thedir->entry.attrFile & FILE_DIRECTORY) ? APR_DIR : APR_REG; - - apr_os2_time_to_apr_time(&finfo->mtime, thedir->entry.fdateLastWrite, - thedir->entry.ftimeLastWrite); - apr_os2_time_to_apr_time(&finfo->atime, thedir->entry.fdateLastAccess, - thedir->entry.ftimeLastAccess); - apr_os2_time_to_apr_time(&finfo->ctime, thedir->entry.fdateCreation, - thedir->entry.ftimeCreation); - - finfo->name = thedir->entry.achName; - finfo->valid = APR_FINFO_NAME | APR_FINFO_MTIME | APR_FINFO_ATIME | - APR_FINFO_CTIME | APR_FINFO_TYPE | APR_FINFO_SIZE | - APR_FINFO_CSIZE; - - return APR_SUCCESS; - } - - thedir->validentry = FALSE; - - if (rv) - return APR_FROM_OS_ERROR(rv); - - return APR_ENOENT; -} - - - -APR_DECLARE(apr_status_t) apr_dir_rewind(apr_dir_t *thedir) -{ - return apr_dir_close(thedir); -} - - - -APR_DECLARE(apr_status_t) apr_dir_make(const char *path, apr_fileperms_t perm, apr_pool_t *pool) -{ - return APR_FROM_OS_ERROR(DosCreateDir(path, NULL)); -} - - - -APR_DECLARE(apr_status_t) apr_dir_remove(const char *path, apr_pool_t *pool) -{ - return APR_FROM_OS_ERROR(DosDeleteDir(path)); -} - - - -APR_DECLARE(apr_status_t) apr_os_dir_get(apr_os_dir_t **thedir, apr_dir_t *dir) -{ - if (dir == NULL) { - return APR_ENODIR; - } - *thedir = &dir->handle; - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_os_dir_put(apr_dir_t **dir, apr_os_dir_t *thedir, - apr_pool_t *pool) -{ - if ((*dir) == NULL) { - (*dir) = (apr_dir_t *)apr_pcalloc(pool, sizeof(apr_dir_t)); - (*dir)->pool = pool; - } - (*dir)->handle = *thedir; - return APR_SUCCESS; -} diff --git a/libs/apr/file_io/os2/dir_make_recurse.c b/libs/apr/file_io/os2/dir_make_recurse.c deleted file mode 100644 index 602a621a..00000000 --- a/libs/apr/file_io/os2/dir_make_recurse.c +++ /dev/null @@ -1,90 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_file_io.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include - -#define IS_SEP(c) (c == '/' || c == '\\') - -/* Remove trailing separators that don't affect the meaning of PATH. */ -static const char *path_canonicalize(const char *path, apr_pool_t *pool) -{ - /* At some point this could eliminate redundant components. For - * now, it just makes sure there is no trailing slash. */ - apr_size_t len = strlen(path); - apr_size_t orig_len = len; - - while ((len > 0) && IS_SEP(path[len - 1])) { - len--; - } - - if (len != orig_len) { - return apr_pstrndup(pool, path, len); - } - else { - return path; - } -} - - - -/* Remove one component off the end of PATH. */ -static char *path_remove_last_component(const char *path, apr_pool_t *pool) -{ - const char *newpath = path_canonicalize(path, pool); - int i; - - for (i = strlen(newpath) - 1; i >= 0; i--) { - if (IS_SEP(path[i])) { - break; - } - } - - return apr_pstrndup(pool, path, (i < 0) ? 0 : i); -} - - - -apr_status_t apr_dir_make_recursive(const char *path, apr_fileperms_t perm, - apr_pool_t *pool) -{ - apr_status_t apr_err = APR_SUCCESS; - - apr_err = apr_dir_make(path, perm, pool); /* Try to make PATH right out */ - - if (APR_STATUS_IS_ENOENT(apr_err)) { /* Missing an intermediate dir */ - char *dir; - - dir = path_remove_last_component(path, pool); - apr_err = apr_dir_make_recursive(dir, perm, pool); - - if (!apr_err) { - apr_err = apr_dir_make(path, perm, pool); - } - } - - /* - * It's OK if PATH exists. Timing issues can lead to the second - * apr_dir_make being called on existing dir, therefore this check - * has to come last. - */ - if (APR_STATUS_IS_EEXIST(apr_err)) - return APR_SUCCESS; - - return apr_err; -} diff --git a/libs/apr/file_io/os2/fileacc.c b/libs/apr/file_io/os2/fileacc.c deleted file mode 100644 index b5c1afd5..00000000 --- a/libs/apr/file_io/os2/fileacc.c +++ /dev/null @@ -1,18 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "../unix/fileacc.c" - diff --git a/libs/apr/file_io/os2/filedup.c b/libs/apr/file_io/os2/filedup.c deleted file mode 100644 index b1063f57..00000000 --- a/libs/apr/file_io/os2/filedup.c +++ /dev/null @@ -1,126 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include -#include "apr_arch_inherit.h" - -static apr_status_t file_dup(apr_file_t **new_file, apr_file_t *old_file, apr_pool_t *p) -{ - int rv; - apr_file_t *dup_file; - - if (*new_file == NULL) { - dup_file = (apr_file_t *)apr_palloc(p, sizeof(apr_file_t)); - - if (dup_file == NULL) { - return APR_ENOMEM; - } - - dup_file->filedes = -1; - } else { - dup_file = *new_file; - } - - dup_file->pool = p; - rv = DosDupHandle(old_file->filedes, &dup_file->filedes); - - if (rv) { - return APR_FROM_OS_ERROR(rv); - } - - dup_file->fname = apr_pstrdup(dup_file->pool, old_file->fname); - dup_file->buffered = old_file->buffered; - dup_file->isopen = old_file->isopen; - dup_file->flags = old_file->flags & ~APR_INHERIT; - /* TODO - dup pipes correctly */ - dup_file->pipe = old_file->pipe; - - if (*new_file == NULL) { - apr_pool_cleanup_register(dup_file->pool, dup_file, apr_file_cleanup, - apr_pool_cleanup_null); - *new_file = dup_file; - } - - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_file_dup(apr_file_t **new_file, apr_file_t *old_file, apr_pool_t *p) -{ - if (*new_file) { - apr_file_close(*new_file); - (*new_file)->filedes = -1; - } - - return file_dup(new_file, old_file, p); -} - - - -APR_DECLARE(apr_status_t) apr_file_dup2(apr_file_t *new_file, apr_file_t *old_file, apr_pool_t *p) -{ - return file_dup(&new_file, old_file, p); -} - - - -APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file, - apr_file_t *old_file, - apr_pool_t *p) -{ - *new_file = (apr_file_t *)apr_palloc(p, sizeof(apr_file_t)); - memcpy(*new_file, old_file, sizeof(apr_file_t)); - (*new_file)->pool = p; - - if (old_file->buffered) { - (*new_file)->buffer = apr_palloc(p, old_file->bufsize); - (*new_file)->bufsize = old_file->bufsize; - - if (old_file->direction == 1) { - memcpy((*new_file)->buffer, old_file->buffer, old_file->bufpos); - } - else { - memcpy((*new_file)->buffer, old_file->buffer, old_file->dataRead); - } - - if (old_file->mutex) { - apr_thread_mutex_create(&((*new_file)->mutex), - APR_THREAD_MUTEX_DEFAULT, p); - apr_thread_mutex_destroy(old_file->mutex); - } - } - - if (old_file->fname) { - (*new_file)->fname = apr_pstrdup(p, old_file->fname); - } - - if (!(old_file->flags & APR_FOPEN_NOCLEANUP)) { - apr_pool_cleanup_register(p, (void *)(*new_file), - apr_file_cleanup, - apr_file_cleanup); - } - - old_file->filedes = -1; - apr_pool_cleanup_kill(old_file->pool, (void *)old_file, - apr_file_cleanup); - - return APR_SUCCESS; -} diff --git a/libs/apr/file_io/os2/filepath.c b/libs/apr/file_io/os2/filepath.c deleted file mode 100644 index 9422faa9..00000000 --- a/libs/apr/file_io/os2/filepath.c +++ /dev/null @@ -1,16 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "../win32/filepath.c" diff --git a/libs/apr/file_io/os2/filepath_util.c b/libs/apr/file_io/os2/filepath_util.c deleted file mode 100644 index a89c173e..00000000 --- a/libs/apr/file_io/os2/filepath_util.c +++ /dev/null @@ -1 +0,0 @@ -#include "../unix/filepath_util.c" diff --git a/libs/apr/file_io/os2/filestat.c b/libs/apr/file_io/os2/filestat.c deleted file mode 100644 index cd163e41..00000000 --- a/libs/apr/file_io/os2/filestat.c +++ /dev/null @@ -1,241 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define INCL_DOS -#define INCL_DOSERRORS -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_lib.h" -#include -#include "apr_strings.h" - - -static void FS3_to_finfo(apr_finfo_t *finfo, FILESTATUS3 *fstatus) -{ - finfo->protection = (fstatus->attrFile & FILE_READONLY) ? 0x555 : 0x777; - - if (fstatus->attrFile & FILE_DIRECTORY) - finfo->filetype = APR_DIR; - else - finfo->filetype = APR_REG; - /* XXX: No other possible types from FS3? */ - - finfo->user = 0; - finfo->group = 0; - finfo->inode = 0; - finfo->device = 0; - finfo->size = fstatus->cbFile; - finfo->csize = fstatus->cbFileAlloc; - apr_os2_time_to_apr_time(&finfo->atime, fstatus->fdateLastAccess, - fstatus->ftimeLastAccess ); - apr_os2_time_to_apr_time(&finfo->mtime, fstatus->fdateLastWrite, - fstatus->ftimeLastWrite ); - apr_os2_time_to_apr_time(&finfo->ctime, fstatus->fdateCreation, - fstatus->ftimeCreation ); - finfo->valid = APR_FINFO_TYPE | APR_FINFO_PROT | APR_FINFO_SIZE - | APR_FINFO_CSIZE | APR_FINFO_MTIME - | APR_FINFO_CTIME | APR_FINFO_ATIME | APR_FINFO_LINK; -} - - - -static apr_status_t handle_type(apr_filetype_e *ftype, HFILE file) -{ - ULONG filetype, fileattr, rc; - - rc = DosQueryHType(file, &filetype, &fileattr); - - if (rc == 0) { - switch (filetype & 0xff) { - case 0: - *ftype = APR_REG; - break; - - case 1: - *ftype = APR_CHR; - break; - - case 2: - *ftype = APR_PIPE; - break; - - default: - /* Brian, is this correct??? - */ - *ftype = APR_UNKFILE; - break; - } - - return APR_SUCCESS; - } - return APR_FROM_OS_ERROR(rc); -} - - - -APR_DECLARE(apr_status_t) apr_file_info_get(apr_finfo_t *finfo, apr_int32_t wanted, - apr_file_t *thefile) -{ - ULONG rc; - FILESTATUS3 fstatus; - - if (thefile->isopen) { - if (thefile->buffered) { - /* XXX: flush here is not mutex protected */ - apr_status_t rv = apr_file_flush(thefile); - - if (rv != APR_SUCCESS) { - return rv; - } - } - - rc = DosQueryFileInfo(thefile->filedes, FIL_STANDARD, &fstatus, sizeof(fstatus)); - } - else - rc = DosQueryPathInfo(thefile->fname, FIL_STANDARD, &fstatus, sizeof(fstatus)); - - if (rc == 0) { - FS3_to_finfo(finfo, &fstatus); - finfo->fname = thefile->fname; - - if (finfo->filetype == APR_REG) { - if (thefile->isopen) { - return handle_type(&finfo->filetype, thefile->filedes); - } - } else { - return APR_SUCCESS; - } - } - - finfo->protection = 0; - finfo->filetype = APR_NOFILE; - return APR_FROM_OS_ERROR(rc); -} - -APR_DECLARE(apr_status_t) apr_file_perms_set(const char *fname, apr_fileperms_t perms) -{ - return APR_ENOTIMPL; -} - - -APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, - apr_int32_t wanted, apr_pool_t *cont) -{ - ULONG rc; - FILESTATUS3 fstatus; - - finfo->protection = 0; - finfo->filetype = APR_NOFILE; - finfo->name = NULL; - rc = DosQueryPathInfo(fname, FIL_STANDARD, &fstatus, sizeof(fstatus)); - - if (rc == 0) { - FS3_to_finfo(finfo, &fstatus); - finfo->fname = fname; - - if (wanted & APR_FINFO_NAME) { - ULONG count = 1; - HDIR hDir = HDIR_SYSTEM; - FILEFINDBUF3 ffb; - rc = DosFindFirst(fname, &hDir, - FILE_DIRECTORY|FILE_HIDDEN|FILE_SYSTEM|FILE_ARCHIVED, - &ffb, sizeof(ffb), &count, FIL_STANDARD); - if (rc == 0 && count == 1) { - finfo->name = apr_pstrdup(cont, ffb.achName); - finfo->valid |= APR_FINFO_NAME; - } - } - } else if (rc == ERROR_INVALID_ACCESS) { - memset(finfo, 0, sizeof(apr_finfo_t)); - finfo->valid = APR_FINFO_TYPE | APR_FINFO_PROT; - finfo->protection = 0666; - finfo->filetype = APR_CHR; - - if (wanted & APR_FINFO_NAME) { - finfo->name = apr_pstrdup(cont, fname); - finfo->valid |= APR_FINFO_NAME; - } - } else { - return APR_FROM_OS_ERROR(rc); - } - - return (wanted & ~finfo->valid) ? APR_INCOMPLETE : APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, - apr_fileattrs_t attributes, - apr_fileattrs_t attr_mask, - apr_pool_t *cont) -{ - FILESTATUS3 fs3; - ULONG rc; - - /* Don't do anything if we can't handle the requested attributes */ - if (!(attr_mask & (APR_FILE_ATTR_READONLY - | APR_FILE_ATTR_HIDDEN))) - return APR_SUCCESS; - - rc = DosQueryPathInfo(fname, FIL_STANDARD, &fs3, sizeof(fs3)); - if (rc == 0) { - ULONG old_attr = fs3.attrFile; - - if (attr_mask & APR_FILE_ATTR_READONLY) - { - if (attributes & APR_FILE_ATTR_READONLY) { - fs3.attrFile |= FILE_READONLY; - } else { - fs3.attrFile &= ~FILE_READONLY; - } - } - - if (attr_mask & APR_FILE_ATTR_HIDDEN) - { - if (attributes & APR_FILE_ATTR_HIDDEN) { - fs3.attrFile |= FILE_HIDDEN; - } else { - fs3.attrFile &= ~FILE_HIDDEN; - } - } - - if (fs3.attrFile != old_attr) { - rc = DosSetPathInfo(fname, FIL_STANDARD, &fs3, sizeof(fs3), 0); - } - } - - return APR_FROM_OS_ERROR(rc); -} - - -/* ### Somebody please write this! */ -APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname, - apr_time_t mtime, - apr_pool_t *pool) -{ - FILESTATUS3 fs3; - ULONG rc; - rc = DosQueryPathInfo(fname, FIL_STANDARD, &fs3, sizeof(fs3)); - - if (rc) { - return APR_FROM_OS_ERROR(rc); - } - - apr_apr_time_to_os2_time(&fs3.fdateLastWrite, &fs3.ftimeLastWrite, mtime); - - rc = DosSetPathInfo(fname, FIL_STANDARD, &fs3, sizeof(fs3), 0); - return APR_FROM_OS_ERROR(rc); -} diff --git a/libs/apr/file_io/os2/filesys.c b/libs/apr/file_io/os2/filesys.c deleted file mode 100644 index ae43bc0a..00000000 --- a/libs/apr/file_io/os2/filesys.c +++ /dev/null @@ -1,148 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_arch_file_io.h" -#include "apr_strings.h" -#include "apr_lib.h" -#include - -/* OS/2 Exceptions: - * - * Note that trailing spaces and trailing periods are never recorded - * in the file system. - * - * Leading spaces and periods are accepted, however. - * The * ? < > codes all have wildcard side effects - * The " / \ : are exclusively component separator tokens - * The system doesn't accept | for any (known) purpose - * Oddly, \x7f _is_ acceptable ;) - */ - -const char c_is_fnchar[256] = -{/* Reject all ctrl codes... */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - /* " * / : < > ? */ - 1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,0, 1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,0, - /* \ */ - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1, - /* | */ - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1, - /* High bit codes are accepted */ - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 -}; - - -#define IS_SLASH(c) (c == '/' || c == '\\') - - -apr_status_t filepath_root_test(char *path, apr_pool_t *p) -{ - char drive = apr_toupper(path[0]); - - if (drive >= 'A' && drive <= 'Z' && path[1] == ':' && IS_SLASH(path[2])) - return APR_SUCCESS; - - return APR_EBADPATH; -} - - -apr_status_t filepath_drive_get(char **rootpath, char drive, - apr_int32_t flags, apr_pool_t *p) -{ - char path[APR_PATH_MAX]; - char *pos; - ULONG rc; - ULONG bufsize = sizeof(path) - 3; - - path[0] = drive; - path[1] = ':'; - path[2] = '/'; - - rc = DosQueryCurrentDir(apr_toupper(drive) - 'A', path+3, &bufsize); - - if (rc) { - return APR_FROM_OS_ERROR(rc); - } - - if (!(flags & APR_FILEPATH_NATIVE)) { - for (pos=path; *pos; pos++) { - if (*pos == '\\') - *pos = '/'; - } - } - - *rootpath = apr_pstrdup(p, path); - return APR_SUCCESS; -} - - -apr_status_t filepath_root_case(char **rootpath, char *root, apr_pool_t *p) -{ - if (root[0] && apr_islower(root[0]) && root[1] == ':') { - *rootpath = apr_pstrdup(p, root); - (*rootpath)[0] = apr_toupper((*rootpath)[0]); - } - else { - *rootpath = root; - } - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_filepath_get(char **defpath, apr_int32_t flags, - apr_pool_t *p) -{ - char path[APR_PATH_MAX]; - ULONG drive; - ULONG drivemap; - ULONG rv, pathlen = sizeof(path) - 3; - char *pos; - - DosQueryCurrentDisk(&drive, &drivemap); - path[0] = '@' + drive; - strcpy(path+1, ":\\"); - rv = DosQueryCurrentDir(drive, path+3, &pathlen); - - *defpath = apr_pstrdup(p, path); - - if (!(flags & APR_FILEPATH_NATIVE)) { - for (pos=*defpath; *pos; pos++) { - if (*pos == '\\') - *pos = '/'; - } - } - - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_filepath_set(const char *path, apr_pool_t *p) -{ - ULONG rv = 0; - - if (path[1] == ':') - rv = DosSetDefaultDisk(apr_toupper(path[0]) - '@'); - - if (rv == 0) - rv = DosSetCurrentDir(path); - - return APR_FROM_OS_ERROR(rv); -} diff --git a/libs/apr/file_io/os2/flock.c b/libs/apr/file_io/os2/flock.c deleted file mode 100644 index ec940220..00000000 --- a/libs/apr/file_io/os2/flock.c +++ /dev/null @@ -1,37 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_file_io.h" - -APR_DECLARE(apr_status_t) apr_file_lock(apr_file_t *thefile, int type) -{ - FILELOCK lockrange = { 0, 0x7fffffff }; - ULONG rc; - - rc = DosSetFileLocks(thefile->filedes, NULL, &lockrange, - (type & APR_FLOCK_NONBLOCK) ? 0 : (ULONG)-1, - (type & APR_FLOCK_TYPEMASK) == APR_FLOCK_SHARED); - return APR_FROM_OS_ERROR(rc); -} - -APR_DECLARE(apr_status_t) apr_file_unlock(apr_file_t *thefile) -{ - FILELOCK unlockrange = { 0, 0x7fffffff }; - ULONG rc; - - rc = DosSetFileLocks(thefile->filedes, &unlockrange, NULL, 0, 0); - return APR_FROM_OS_ERROR(rc); -} diff --git a/libs/apr/file_io/os2/fullrw.c b/libs/apr/file_io/os2/fullrw.c deleted file mode 100644 index cf629488..00000000 --- a/libs/apr/file_io/os2/fullrw.c +++ /dev/null @@ -1 +0,0 @@ -#include "../unix/fullrw.c" diff --git a/libs/apr/file_io/os2/maperrorcode.c b/libs/apr/file_io/os2/maperrorcode.c deleted file mode 100644 index 282338bb..00000000 --- a/libs/apr/file_io/os2/maperrorcode.c +++ /dev/null @@ -1,95 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define INCL_DOSERRORS -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include -#include -#include "apr_errno.h" - -static int errormap[][2] = { - { NO_ERROR, APR_SUCCESS }, - { ERROR_FILE_NOT_FOUND, APR_ENOENT }, - { ERROR_PATH_NOT_FOUND, APR_ENOENT }, - { ERROR_TOO_MANY_OPEN_FILES, APR_EMFILE }, - { ERROR_ACCESS_DENIED, APR_EACCES }, - { ERROR_SHARING_VIOLATION, APR_EACCES }, - { ERROR_INVALID_PARAMETER, APR_EINVAL }, - { ERROR_OPEN_FAILED, APR_ENOENT }, - { ERROR_DISK_FULL, APR_ENOSPC }, - { ERROR_FILENAME_EXCED_RANGE, APR_ENAMETOOLONG }, - { ERROR_INVALID_FUNCTION, APR_EINVAL }, - { ERROR_INVALID_HANDLE, APR_EBADF }, - { ERROR_NEGATIVE_SEEK, APR_ESPIPE }, - { ERROR_NO_SIGNAL_SENT, ESRCH }, - { ERROR_NO_DATA, APR_EAGAIN }, - { SOCEINTR, EINTR }, - { SOCEWOULDBLOCK, EWOULDBLOCK }, - { SOCEINPROGRESS, EINPROGRESS }, - { SOCEALREADY, EALREADY }, - { SOCENOTSOCK, ENOTSOCK }, - { SOCEDESTADDRREQ, EDESTADDRREQ }, - { SOCEMSGSIZE, EMSGSIZE }, - { SOCEPROTOTYPE, EPROTOTYPE }, - { SOCENOPROTOOPT, ENOPROTOOPT }, - { SOCEPROTONOSUPPORT, EPROTONOSUPPORT }, - { SOCESOCKTNOSUPPORT, ESOCKTNOSUPPORT }, - { SOCEOPNOTSUPP, EOPNOTSUPP }, - { SOCEPFNOSUPPORT, EPFNOSUPPORT }, - { SOCEAFNOSUPPORT, EAFNOSUPPORT }, - { SOCEADDRINUSE, EADDRINUSE }, - { SOCEADDRNOTAVAIL, EADDRNOTAVAIL }, - { SOCENETDOWN, ENETDOWN }, - { SOCENETUNREACH, ENETUNREACH }, - { SOCENETRESET, ENETRESET }, - { SOCECONNABORTED, ECONNABORTED }, - { SOCECONNRESET, ECONNRESET }, - { SOCENOBUFS, ENOBUFS }, - { SOCEISCONN, EISCONN }, - { SOCENOTCONN, ENOTCONN }, - { SOCESHUTDOWN, ESHUTDOWN }, - { SOCETOOMANYREFS, ETOOMANYREFS }, - { SOCETIMEDOUT, ETIMEDOUT }, - { SOCECONNREFUSED, ECONNREFUSED }, - { SOCELOOP, ELOOP }, - { SOCENAMETOOLONG, ENAMETOOLONG }, - { SOCEHOSTDOWN, EHOSTDOWN }, - { SOCEHOSTUNREACH, EHOSTUNREACH }, - { SOCENOTEMPTY, ENOTEMPTY }, - { SOCEPIPE, EPIPE } -}; - -#define MAPSIZE (sizeof(errormap)/sizeof(errormap[0])) - -int apr_canonical_error(apr_status_t err) -{ - int rv = -1, index; - - if (err < APR_OS_START_SYSERR) - return err; - - err -= APR_OS_START_SYSERR; - - for (index=0; index - -apr_status_t apr_file_cleanup(void *thefile) -{ - apr_file_t *file = thefile; - return apr_file_close(file); -} - - - -APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname, apr_int32_t flag, apr_fileperms_t perm, apr_pool_t *pool) -{ - int oflags = 0; - int mflags = OPEN_FLAGS_FAIL_ON_ERROR|OPEN_SHARE_DENYNONE|OPEN_FLAGS_NOINHERIT; - int rv; - ULONG action; - apr_file_t *dafile = (apr_file_t *)apr_palloc(pool, sizeof(apr_file_t)); - - dafile->pool = pool; - dafile->isopen = FALSE; - dafile->eof_hit = FALSE; - dafile->buffer = NULL; - dafile->flags = flag; - dafile->blocking = BLK_ON; - - if ((flag & APR_FOPEN_READ) && (flag & APR_FOPEN_WRITE)) { - mflags |= OPEN_ACCESS_READWRITE; - } else if (flag & APR_FOPEN_READ) { - mflags |= OPEN_ACCESS_READONLY; - } else if (flag & APR_FOPEN_WRITE) { - mflags |= OPEN_ACCESS_WRITEONLY; - } else { - dafile->filedes = -1; - return APR_EACCES; - } - - dafile->buffered = (flag & APR_FOPEN_BUFFERED) > 0; - - if (dafile->buffered) { - dafile->buffer = apr_palloc(pool, APR_FILE_DEFAULT_BUFSIZE); - dafile->bufsize = APR_FILE_DEFAULT_BUFSIZE; - rv = apr_thread_mutex_create(&dafile->mutex, 0, pool); - - if (rv) - return rv; - } - - if (flag & APR_FOPEN_CREATE) { - oflags |= OPEN_ACTION_CREATE_IF_NEW; - - if (!(flag & APR_FOPEN_EXCL) && !(flag & APR_FOPEN_TRUNCATE)) { - oflags |= OPEN_ACTION_OPEN_IF_EXISTS; - } - } - - if ((flag & APR_FOPEN_EXCL) && !(flag & APR_FOPEN_CREATE)) - return APR_EACCES; - - if (flag & APR_FOPEN_TRUNCATE) { - oflags |= OPEN_ACTION_REPLACE_IF_EXISTS; - } else if ((oflags & 0xFF) == 0) { - oflags |= OPEN_ACTION_OPEN_IF_EXISTS; - } - - rv = DosOpen(fname, &(dafile->filedes), &action, 0, 0, oflags, mflags, NULL); - - if (rv == 0 && (flag & APR_FOPEN_APPEND)) { - ULONG newptr; - rv = DosSetFilePtr(dafile->filedes, 0, FILE_END, &newptr ); - - if (rv) - DosClose(dafile->filedes); - } - - if (rv != 0) - return APR_FROM_OS_ERROR(rv); - - dafile->isopen = TRUE; - dafile->fname = apr_pstrdup(pool, fname); - dafile->filePtr = 0; - dafile->bufpos = 0; - dafile->dataRead = 0; - dafile->direction = 0; - dafile->pipe = FALSE; - - if (!(flag & APR_FOPEN_NOCLEANUP)) { - apr_pool_cleanup_register(dafile->pool, dafile, apr_file_cleanup, apr_file_cleanup); - } - - *new = dafile; - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_file_close(apr_file_t *file) -{ - ULONG rc; - apr_status_t status; - - if (file && file->isopen) { - /* XXX: flush here is not mutex protected */ - status = apr_file_flush(file); - rc = DosClose(file->filedes); - - if (rc == 0) { - file->isopen = FALSE; - - if (file->flags & APR_FOPEN_DELONCLOSE) { - status = APR_FROM_OS_ERROR(DosDelete(file->fname)); - } - /* else we return the status of the flush attempt - * when all else succeeds - */ - } else { - return APR_FROM_OS_ERROR(rc); - } - } - - if (file->buffered) - apr_thread_mutex_destroy(file->mutex); - - return status; -} - - - -APR_DECLARE(apr_status_t) apr_file_remove(const char *path, apr_pool_t *pool) -{ - ULONG rc = DosDelete(path); - return APR_FROM_OS_ERROR(rc); -} - - - -APR_DECLARE(apr_status_t) apr_file_rename(const char *from_path, const char *to_path, - apr_pool_t *p) -{ - ULONG rc = DosMove(from_path, to_path); - - if (rc == ERROR_ACCESS_DENIED || rc == ERROR_ALREADY_EXISTS) { - rc = DosDelete(to_path); - - if (rc == 0 || rc == ERROR_FILE_NOT_FOUND) { - rc = DosMove(from_path, to_path); - } - } - - return APR_FROM_OS_ERROR(rc); -} - - - -APR_DECLARE(apr_status_t) apr_os_file_get(apr_os_file_t *thefile, apr_file_t *file) -{ - *thefile = file->filedes; - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_os_file_put(apr_file_t **file, apr_os_file_t *thefile, apr_int32_t flags, apr_pool_t *pool) -{ - apr_os_file_t *dafile = thefile; - - (*file) = apr_palloc(pool, sizeof(apr_file_t)); - (*file)->pool = pool; - (*file)->filedes = *dafile; - (*file)->isopen = TRUE; - (*file)->eof_hit = FALSE; - (*file)->flags = flags; - (*file)->pipe = FALSE; - (*file)->buffered = (flags & APR_FOPEN_BUFFERED) > 0; - - if ((*file)->buffered) { - apr_status_t rv; - - (*file)->buffer = apr_palloc(pool, APR_FILE_DEFAULT_BUFSIZE); - (*file)->bufsize = APR_FILE_DEFAULT_BUFSIZE; - rv = apr_thread_mutex_create(&(*file)->mutex, 0, pool); - - if (rv) - return rv; - } - - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_file_eof(apr_file_t *fptr) -{ - if (!fptr->isopen || fptr->eof_hit == 1) { - return APR_EOF; - } - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_file_open_flags_stderr(apr_file_t **thefile, - apr_int32_t flags, - apr_pool_t *pool) -{ - apr_os_file_t fd = 2; - - return apr_os_file_put(thefile, &fd, flags | APR_FOPEN_WRITE, pool); -} - - -APR_DECLARE(apr_status_t) apr_file_open_flags_stdout(apr_file_t **thefile, - apr_int32_t flags, - apr_pool_t *pool) -{ - apr_os_file_t fd = 1; - - return apr_os_file_put(thefile, &fd, flags | APR_FOPEN_WRITE, pool); -} - - -APR_DECLARE(apr_status_t) apr_file_open_flags_stdin(apr_file_t **thefile, - apr_int32_t flags, - apr_pool_t *pool) -{ - apr_os_file_t fd = 0; - - return apr_os_file_put(thefile, &fd, flags | APR_FOPEN_READ, pool); -} - - -APR_DECLARE(apr_status_t) apr_file_open_stderr(apr_file_t **thefile, apr_pool_t *pool) -{ - return apr_file_open_flags_stderr(thefile, 0, pool); -} - - -APR_DECLARE(apr_status_t) apr_file_open_stdout(apr_file_t **thefile, apr_pool_t *pool) -{ - return apr_file_open_flags_stdout(thefile, 0, pool); -} - - -APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile, apr_pool_t *pool) -{ - return apr_file_open_flags_stdin(thefile, 0, pool); -} - -APR_POOL_IMPLEMENT_ACCESSOR(file); - - - -APR_DECLARE(apr_status_t) apr_file_inherit_set(apr_file_t *thefile) -{ - int rv; - ULONG state; - - rv = DosQueryFHState(thefile->filedes, &state); - - if (rv == 0 && (state & OPEN_FLAGS_NOINHERIT) != 0) { - rv = DosSetFHState(thefile->filedes, state & ~OPEN_FLAGS_NOINHERIT); - } - - return APR_FROM_OS_ERROR(rv); -} - - - -APR_DECLARE(apr_status_t) apr_file_inherit_unset(apr_file_t *thefile) -{ - int rv; - ULONG state; - - rv = DosQueryFHState(thefile->filedes, &state); - - if (rv == 0 && (state & OPEN_FLAGS_NOINHERIT) == 0) { - rv = DosSetFHState(thefile->filedes, state | OPEN_FLAGS_NOINHERIT); - } - - return APR_FROM_OS_ERROR(rv); -} diff --git a/libs/apr/file_io/os2/pipe.c b/libs/apr/file_io/os2/pipe.c deleted file mode 100644 index 211c43cd..00000000 --- a/libs/apr/file_io/os2/pipe.c +++ /dev/null @@ -1,206 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define INCL_DOSERRORS -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include -#include - -APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, apr_file_t **out, apr_pool_t *pool) -{ - ULONG filedes[2]; - ULONG rc, action; - static int id = 0; - char pipename[50]; - - sprintf(pipename, "/pipe/%d.%d", getpid(), id++); - rc = DosCreateNPipe(pipename, filedes, NP_ACCESS_INBOUND, NP_NOWAIT|1, 4096, 4096, 0); - - if (rc) - return APR_FROM_OS_ERROR(rc); - - rc = DosConnectNPipe(filedes[0]); - - if (rc && rc != ERROR_PIPE_NOT_CONNECTED) { - DosClose(filedes[0]); - return APR_FROM_OS_ERROR(rc); - } - - rc = DosOpen (pipename, filedes+1, &action, 0, FILE_NORMAL, - OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW, - OPEN_ACCESS_WRITEONLY | OPEN_SHARE_DENYREADWRITE, - NULL); - - if (rc) { - DosClose(filedes[0]); - return APR_FROM_OS_ERROR(rc); - } - - (*in) = (apr_file_t *)apr_palloc(pool, sizeof(apr_file_t)); - rc = DosCreateEventSem(NULL, &(*in)->pipeSem, DC_SEM_SHARED, FALSE); - - if (rc) { - DosClose(filedes[0]); - DosClose(filedes[1]); - return APR_FROM_OS_ERROR(rc); - } - - rc = DosSetNPipeSem(filedes[0], (HSEM)(*in)->pipeSem, 1); - - if (!rc) { - rc = DosSetNPHState(filedes[0], NP_WAIT); - } - - if (rc) { - DosClose(filedes[0]); - DosClose(filedes[1]); - DosCloseEventSem((*in)->pipeSem); - return APR_FROM_OS_ERROR(rc); - } - - (*in)->pool = pool; - (*in)->filedes = filedes[0]; - (*in)->fname = apr_pstrdup(pool, pipename); - (*in)->isopen = TRUE; - (*in)->buffered = FALSE; - (*in)->flags = 0; - (*in)->pipe = 1; - (*in)->timeout = -1; - (*in)->blocking = BLK_ON; - apr_pool_cleanup_register(pool, *in, apr_file_cleanup, apr_pool_cleanup_null); - - (*out) = (apr_file_t *)apr_palloc(pool, sizeof(apr_file_t)); - (*out)->pool = pool; - (*out)->filedes = filedes[1]; - (*out)->fname = apr_pstrdup(pool, pipename); - (*out)->isopen = TRUE; - (*out)->buffered = FALSE; - (*out)->flags = 0; - (*out)->pipe = 1; - (*out)->timeout = -1; - (*out)->blocking = BLK_ON; - apr_pool_cleanup_register(pool, *out, apr_file_cleanup, apr_pool_cleanup_null); - - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_file_pipe_create_ex(apr_file_t **in, - apr_file_t **out, - apr_int32_t blocking, - apr_pool_t *pool) -{ - apr_status_t status; - - if ((status = apr_file_pipe_create(in, out, pool)) != APR_SUCCESS) - return status; - - switch (blocking) { - case APR_FULL_BLOCK: - break; - case APR_READ_BLOCK: - apr_file_pipe_timeout_set(*out, 0); - break; - case APR_WRITE_BLOCK: - apr_file_pipe_timeout_set(*in, 0); - break; - default: - apr_file_pipe_timeout_set(*out, 0); - apr_file_pipe_timeout_set(*in, 0); - } - - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_file_namedpipe_create(const char *filename, apr_fileperms_t perm, apr_pool_t *pool) -{ - /* Not yet implemented, interface not suitable */ - return APR_ENOTIMPL; -} - - - -APR_DECLARE(apr_status_t) apr_file_pipe_timeout_set(apr_file_t *thepipe, apr_interval_time_t timeout) -{ - if (thepipe->pipe == 1) { - thepipe->timeout = timeout; - - if (thepipe->timeout >= 0) { - if (thepipe->blocking != BLK_OFF) { - thepipe->blocking = BLK_OFF; - return APR_FROM_OS_ERROR(DosSetNPHState(thepipe->filedes, NP_NOWAIT)); - } - } - else if (thepipe->timeout == -1) { - if (thepipe->blocking != BLK_ON) { - thepipe->blocking = BLK_ON; - return APR_FROM_OS_ERROR(DosSetNPHState(thepipe->filedes, NP_WAIT)); - } - } - } - return APR_EINVAL; -} - - - -APR_DECLARE(apr_status_t) apr_file_pipe_timeout_get(apr_file_t *thepipe, apr_interval_time_t *timeout) -{ - if (thepipe->pipe == 1) { - *timeout = thepipe->timeout; - return APR_SUCCESS; - } - return APR_EINVAL; -} - - - -APR_DECLARE(apr_status_t) apr_os_pipe_put_ex(apr_file_t **file, - apr_os_file_t *thefile, - int register_cleanup, - apr_pool_t *pool) -{ - (*file) = apr_pcalloc(pool, sizeof(apr_file_t)); - (*file)->pool = pool; - (*file)->isopen = TRUE; - (*file)->pipe = 1; - (*file)->blocking = BLK_UNKNOWN; /* app needs to make a timeout call */ - (*file)->timeout = -1; - (*file)->filedes = *thefile; - - if (register_cleanup) { - apr_pool_cleanup_register(pool, *file, apr_file_cleanup, - apr_pool_cleanup_null); - } - - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_os_pipe_put(apr_file_t **file, - apr_os_file_t *thefile, - apr_pool_t *pool) -{ - return apr_os_pipe_put_ex(file, thefile, 0, pool); -} diff --git a/libs/apr/file_io/os2/readwrite.c b/libs/apr/file_io/os2/readwrite.c deleted file mode 100644 index d00591d7..00000000 --- a/libs/apr/file_io/os2/readwrite.c +++ /dev/null @@ -1,388 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define INCL_DOS -#define INCL_DOSERRORS - -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_lib.h" -#include "apr_strings.h" - -#include - -APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size_t *nbytes) -{ - ULONG rc = 0; - ULONG bytesread; - - if (!thefile->isopen) { - *nbytes = 0; - return APR_EBADF; - } - - if (thefile->buffered) { - char *pos = (char *)buf; - ULONG blocksize; - ULONG size = *nbytes; - - apr_thread_mutex_lock(thefile->mutex); - - if (thefile->direction == 1) { - int rv = apr_file_flush(thefile); - - if (rv != APR_SUCCESS) { - apr_thread_mutex_unlock(thefile->mutex); - return rv; - } - - thefile->bufpos = 0; - thefile->direction = 0; - thefile->dataRead = 0; - } - - while (rc == 0 && size > 0) { - if (thefile->bufpos >= thefile->dataRead) { - ULONG bytesread; - rc = DosRead(thefile->filedes, thefile->buffer, - thefile->bufsize, &bytesread); - - if (bytesread == 0) { - if (rc == 0) - thefile->eof_hit = TRUE; - break; - } - - thefile->dataRead = bytesread; - thefile->filePtr += thefile->dataRead; - thefile->bufpos = 0; - } - - blocksize = size > thefile->dataRead - thefile->bufpos ? thefile->dataRead - thefile->bufpos : size; - memcpy(pos, thefile->buffer + thefile->bufpos, blocksize); - thefile->bufpos += blocksize; - pos += blocksize; - size -= blocksize; - } - - *nbytes = rc == 0 ? pos - (char *)buf : 0; - apr_thread_mutex_unlock(thefile->mutex); - - if (*nbytes == 0 && rc == 0 && thefile->eof_hit) { - return APR_EOF; - } - - return APR_FROM_OS_ERROR(rc); - } else { - if (thefile->pipe) - DosResetEventSem(thefile->pipeSem, &rc); - - rc = DosRead(thefile->filedes, buf, *nbytes, &bytesread); - - if (rc == ERROR_NO_DATA && thefile->timeout != 0) { - int rcwait = DosWaitEventSem(thefile->pipeSem, thefile->timeout >= 0 ? thefile->timeout / 1000 : SEM_INDEFINITE_WAIT); - - if (rcwait == 0) { - rc = DosRead(thefile->filedes, buf, *nbytes, &bytesread); - } - else if (rcwait == ERROR_TIMEOUT) { - *nbytes = 0; - return APR_TIMEUP; - } - } - - if (rc) { - *nbytes = 0; - return APR_FROM_OS_ERROR(rc); - } - - *nbytes = bytesread; - - if (bytesread == 0) { - thefile->eof_hit = TRUE; - return APR_EOF; - } - - return APR_SUCCESS; - } -} - - - -APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, apr_size_t *nbytes) -{ - ULONG rc = 0; - ULONG byteswritten; - - if (!thefile->isopen) { - *nbytes = 0; - return APR_EBADF; - } - - if (thefile->buffered) { - char *pos = (char *)buf; - int blocksize; - int size = *nbytes; - - apr_thread_mutex_lock(thefile->mutex); - - if ( thefile->direction == 0 ) { - /* Position file pointer for writing at the offset we are logically reading from */ - ULONG offset = thefile->filePtr - thefile->dataRead + thefile->bufpos; - if (offset != thefile->filePtr) - DosSetFilePtr(thefile->filedes, offset, FILE_BEGIN, &thefile->filePtr ); - thefile->bufpos = thefile->dataRead = 0; - thefile->direction = 1; - } - - while (rc == 0 && size > 0) { - if (thefile->bufpos == thefile->bufsize) /* write buffer is full */ - /* XXX bug; - rc is double-transformed os->apr below */ - rc = apr_file_flush(thefile); - - blocksize = size > thefile->bufsize - thefile->bufpos ? thefile->bufsize - thefile->bufpos : size; - memcpy(thefile->buffer + thefile->bufpos, pos, blocksize); - thefile->bufpos += blocksize; - pos += blocksize; - size -= blocksize; - } - - apr_thread_mutex_unlock(thefile->mutex); - return APR_FROM_OS_ERROR(rc); - } else { - if (thefile->flags & APR_FOPEN_APPEND) { - FILELOCK all = { 0, 0x7fffffff }; - ULONG newpos; - rc = DosSetFileLocks(thefile->filedes, NULL, &all, -1, 0); - - if (rc == 0) { - rc = DosSetFilePtr(thefile->filedes, 0, FILE_END, &newpos); - - if (rc == 0) { - rc = DosWrite(thefile->filedes, buf, *nbytes, &byteswritten); - } - - DosSetFileLocks(thefile->filedes, &all, NULL, -1, 0); - } - } else { - rc = DosWrite(thefile->filedes, buf, *nbytes, &byteswritten); - } - - if (rc) { - *nbytes = 0; - return APR_FROM_OS_ERROR(rc); - } - - *nbytes = byteswritten; - return APR_SUCCESS; - } -} - - - -#ifdef HAVE_WRITEV - -APR_DECLARE(apr_status_t) apr_file_writev(apr_file_t *thefile, const struct iovec *vec, apr_size_t nvec, apr_size_t *nbytes) -{ - int bytes; - - if (thefile->buffered) { - apr_status_t rv = apr_file_flush(thefile); - if (rv != APR_SUCCESS) { - return rv; - } - } - - if ((bytes = writev(thefile->filedes, vec, nvec)) < 0) { - *nbytes = 0; - return errno; - } - else { - *nbytes = bytes; - return APR_SUCCESS; - } -} -#endif - - - -APR_DECLARE(apr_status_t) apr_file_putc(char ch, apr_file_t *thefile) -{ - ULONG rc; - ULONG byteswritten; - - if (!thefile->isopen) { - return APR_EBADF; - } - - rc = DosWrite(thefile->filedes, &ch, 1, &byteswritten); - - if (rc) { - return APR_FROM_OS_ERROR(rc); - } - - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_file_ungetc(char ch, apr_file_t *thefile) -{ - apr_off_t offset = -1; - return apr_file_seek(thefile, APR_CUR, &offset); -} - - -APR_DECLARE(apr_status_t) apr_file_getc(char *ch, apr_file_t *thefile) -{ - ULONG rc; - apr_size_t bytesread; - - if (!thefile->isopen) { - return APR_EBADF; - } - - bytesread = 1; - rc = apr_file_read(thefile, ch, &bytesread); - - if (rc) { - return rc; - } - - if (bytesread == 0) { - thefile->eof_hit = TRUE; - return APR_EOF; - } - - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_file_puts(const char *str, apr_file_t *thefile) -{ - apr_size_t len; - - len = strlen(str); - return apr_file_write(thefile, str, &len); -} - - -APR_DECLARE(apr_status_t) apr_file_flush(apr_file_t *thefile) -{ - if (thefile->buffered) { - ULONG written = 0; - int rc = 0; - - if (thefile->direction == 1 && thefile->bufpos) { - rc = DosWrite(thefile->filedes, thefile->buffer, thefile->bufpos, &written); - thefile->filePtr += written; - - if (rc == 0) - thefile->bufpos = 0; - } - - return APR_FROM_OS_ERROR(rc); - } else { - /* There isn't anything to do if we aren't buffering the output - * so just return success. - */ - return APR_SUCCESS; - } -} - -APR_DECLARE(apr_status_t) apr_file_sync(apr_file_t *thefile) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_file_datasync(apr_file_t *thefile) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, apr_file_t *thefile) -{ - apr_size_t readlen; - apr_status_t rv = APR_SUCCESS; - int i; - - for (i = 0; i < len-1; i++) { - readlen = 1; - rv = apr_file_read(thefile, str+i, &readlen); - - if (rv != APR_SUCCESS) { - break; - } - - if (readlen != 1) { - rv = APR_EOF; - break; - } - - if (str[i] == '\n') { - i++; - break; - } - } - str[i] = 0; - if (i > 0) { - /* we stored chars; don't report EOF or any other errors; - * the app will find out about that on the next call - */ - return APR_SUCCESS; - } - return rv; -} - - - -APR_DECLARE_NONSTD(int) apr_file_printf(apr_file_t *fptr, - const char *format, ...) -{ - int cc; - va_list ap; - char *buf; - int len; - - buf = malloc(HUGE_STRING_LEN); - if (buf == NULL) { - return 0; - } - va_start(ap, format); - len = apr_vsnprintf(buf, HUGE_STRING_LEN, format, ap); - cc = apr_file_puts(buf, fptr); - va_end(ap); - free(buf); - return (cc == APR_SUCCESS) ? len : -1; -} - - - -apr_status_t apr_file_check_read(apr_file_t *fd) -{ - int rc; - - if (!fd->pipe) - return APR_SUCCESS; /* Not a pipe, assume no waiting */ - - rc = DosWaitEventSem(fd->pipeSem, SEM_IMMEDIATE_RETURN); - - if (rc == ERROR_TIMEOUT) - return APR_TIMEUP; - - return APR_FROM_OS_ERROR(rc); -} diff --git a/libs/apr/file_io/os2/seek.c b/libs/apr/file_io/os2/seek.c deleted file mode 100644 index a8d13fe2..00000000 --- a/libs/apr/file_io/os2/seek.c +++ /dev/null @@ -1,120 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_lib.h" -#include -#include - - -static apr_status_t setptr(apr_file_t *thefile, unsigned long pos ) -{ - long newbufpos; - ULONG rc; - - if (thefile->direction == 1) { - /* XXX: flush here is not mutex protected */ - apr_status_t rv = apr_file_flush(thefile); - - if (rv != APR_SUCCESS) { - return rv; - } - - thefile->bufpos = thefile->direction = thefile->dataRead = 0; - } - - newbufpos = pos - (thefile->filePtr - thefile->dataRead); - if (newbufpos >= 0 && newbufpos <= thefile->dataRead) { - thefile->bufpos = newbufpos; - rc = 0; - } else { - rc = DosSetFilePtr(thefile->filedes, pos, FILE_BEGIN, &thefile->filePtr ); - - if ( !rc ) - thefile->bufpos = thefile->dataRead = 0; - } - - return APR_FROM_OS_ERROR(rc); -} - - - -APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile, apr_seek_where_t where, apr_off_t *offset) -{ - if (!thefile->isopen) { - return APR_EBADF; - } - - thefile->eof_hit = 0; - - if (thefile->buffered) { - int rc = EINVAL; - apr_finfo_t finfo; - - switch (where) { - case APR_SET: - rc = setptr(thefile, *offset); - break; - - case APR_CUR: - rc = setptr(thefile, thefile->filePtr - thefile->dataRead + thefile->bufpos + *offset); - break; - - case APR_END: - rc = apr_file_info_get(&finfo, APR_FINFO_NORM, thefile); - if (rc == APR_SUCCESS) - rc = setptr(thefile, finfo.size + *offset); - break; - } - - *offset = thefile->filePtr - thefile->dataRead + thefile->bufpos; - return rc; - } else { - switch (where) { - case APR_SET: - where = FILE_BEGIN; - break; - - case APR_CUR: - where = FILE_CURRENT; - break; - - case APR_END: - where = FILE_END; - break; - } - - return APR_FROM_OS_ERROR(DosSetFilePtr(thefile->filedes, *offset, where, (ULONG *)offset)); - } -} - - - -APR_DECLARE(apr_status_t) apr_file_trunc(apr_file_t *fp, apr_off_t offset) -{ - int rc = DosSetFileSize(fp->filedes, offset); - - if (rc != 0) { - return APR_FROM_OS_ERROR(rc); - } - - if (fp->buffered) { - return setptr(fp, offset); - } - - return APR_SUCCESS; -} diff --git a/libs/apr/file_io/os2/tempdir.c b/libs/apr/file_io/os2/tempdir.c deleted file mode 100644 index 6823569f..00000000 --- a/libs/apr/file_io/os2/tempdir.c +++ /dev/null @@ -1 +0,0 @@ -#include "../unix/tempdir.c" diff --git a/libs/apr/file_io/unix/buffer.c b/libs/apr/file_io/unix/buffer.c deleted file mode 100644 index ba2a8a7c..00000000 --- a/libs/apr/file_io/unix/buffer.c +++ /dev/null @@ -1,60 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_file_io.h" -#include "apr_pools.h" -#include "apr_thread_mutex.h" - -APR_DECLARE(apr_status_t) apr_file_buffer_set(apr_file_t *file, - char * buffer, - apr_size_t bufsize) -{ - apr_status_t rv; - - file_lock(file); - - if(file->buffered) { - /* Flush the existing buffer */ - rv = apr_file_flush_locked(file); - if (rv != APR_SUCCESS) { - file_unlock(file); - return rv; - } - } - - file->buffer = buffer; - file->bufsize = bufsize; - file->buffered = 1; - file->bufpos = 0; - file->direction = 0; - file->dataRead = 0; - - if (file->bufsize == 0) { - /* Setting the buffer size to zero is equivalent to turning - * buffering off. - */ - file->buffered = 0; - } - - file_unlock(file); - - return APR_SUCCESS; -} - -APR_DECLARE(apr_size_t) apr_file_buffer_size_get(apr_file_t *file) -{ - return file->bufsize; -} diff --git a/libs/apr/file_io/unix/copy.c b/libs/apr/file_io/unix/copy.c deleted file mode 100644 index df3a49c8..00000000 --- a/libs/apr/file_io/unix/copy.c +++ /dev/null @@ -1,118 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_file_io.h" -#include "apr_file_io.h" - -static apr_status_t apr_file_transfer_contents(const char *from_path, - const char *to_path, - apr_int32_t flags, - apr_fileperms_t to_perms, - apr_pool_t *pool) -{ - apr_file_t *s, *d; - apr_status_t status; - apr_finfo_t finfo; - apr_fileperms_t perms; - - /* Open source file. */ - status = apr_file_open(&s, from_path, APR_FOPEN_READ, APR_OS_DEFAULT, pool); - if (status) - return status; - - /* Maybe get its permissions. */ - if (to_perms == APR_FILE_SOURCE_PERMS) { - status = apr_file_info_get(&finfo, APR_FINFO_PROT, s); - if (status != APR_SUCCESS && status != APR_INCOMPLETE) { - apr_file_close(s); /* toss any error */ - return status; - } - perms = finfo.protection; - } - else - perms = to_perms; - - /* Open dest file. */ - status = apr_file_open(&d, to_path, flags, perms, pool); - if (status) { - apr_file_close(s); /* toss any error */ - return status; - } - -#if BUFSIZ > APR_FILE_DEFAULT_BUFSIZE -#define COPY_BUFSIZ BUFSIZ -#else -#define COPY_BUFSIZ APR_FILE_DEFAULT_BUFSIZE -#endif - - /* Copy bytes till the cows come home. */ - while (1) { - char buf[COPY_BUFSIZ]; - apr_size_t bytes_this_time = sizeof(buf); - apr_status_t read_err; - apr_status_t write_err; - - /* Read 'em. */ - read_err = apr_file_read(s, buf, &bytes_this_time); - if (read_err && !APR_STATUS_IS_EOF(read_err)) { - apr_file_close(s); /* toss any error */ - apr_file_close(d); /* toss any error */ - return read_err; - } - - /* Write 'em. */ - write_err = apr_file_write_full(d, buf, bytes_this_time, NULL); - if (write_err) { - apr_file_close(s); /* toss any error */ - apr_file_close(d); /* toss any error */ - return write_err; - } - - if (read_err && APR_STATUS_IS_EOF(read_err)) { - status = apr_file_close(s); - if (status) { - apr_file_close(d); /* toss any error */ - return status; - } - - /* return the results of this close: an error, or success */ - return apr_file_close(d); - } - } - /* NOTREACHED */ -} - -APR_DECLARE(apr_status_t) apr_file_copy(const char *from_path, - const char *to_path, - apr_fileperms_t perms, - apr_pool_t *pool) -{ - return apr_file_transfer_contents(from_path, to_path, - (APR_FOPEN_WRITE | APR_FOPEN_CREATE | APR_FOPEN_TRUNCATE), - perms, - pool); -} - -APR_DECLARE(apr_status_t) apr_file_append(const char *from_path, - const char *to_path, - apr_fileperms_t perms, - apr_pool_t *pool) -{ - return apr_file_transfer_contents(from_path, to_path, - (APR_FOPEN_WRITE | APR_FOPEN_CREATE | APR_FOPEN_APPEND), - perms, - pool); -} diff --git a/libs/apr/file_io/unix/dir.c b/libs/apr/file_io/unix/dir.c deleted file mode 100644 index 28d9e069..00000000 --- a/libs/apr/file_io/unix/dir.c +++ /dev/null @@ -1,364 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_file_io.h" -#include "apr_strings.h" -#include "apr_portable.h" -#if APR_HAVE_SYS_SYSLIMITS_H -#include -#endif -#if APR_HAVE_LIMITS_H -#include -#endif - -static apr_status_t dir_cleanup(void *thedir) -{ - apr_dir_t *dir = thedir; - if (closedir(dir->dirstruct) == 0) { - return APR_SUCCESS; - } - else { - return errno; - } -} - -#define PATH_SEPARATOR '/' - -/* Remove trailing separators that don't affect the meaning of PATH. */ -static const char *path_canonicalize (const char *path, apr_pool_t *pool) -{ - /* At some point this could eliminate redundant components. For - * now, it just makes sure there is no trailing slash. */ - apr_size_t len = strlen (path); - apr_size_t orig_len = len; - - while ((len > 0) && (path[len - 1] == PATH_SEPARATOR)) - len--; - - if (len != orig_len) - return apr_pstrndup (pool, path, len); - else - return path; -} - -/* Remove one component off the end of PATH. */ -static char *path_remove_last_component (const char *path, apr_pool_t *pool) -{ - const char *newpath = path_canonicalize (path, pool); - int i; - - for (i = (strlen(newpath) - 1); i >= 0; i--) { - if (path[i] == PATH_SEPARATOR) - break; - } - - return apr_pstrndup (pool, path, (i < 0) ? 0 : i); -} - -apr_status_t apr_dir_open(apr_dir_t **new, const char *dirname, - apr_pool_t *pool) -{ - /* On some platforms (e.g., Linux+GNU libc), d_name[] in struct - * dirent is declared with enough storage for the name. On other - * platforms (e.g., Solaris 8 for Intel), d_name is declared as a - * one-byte array. Note: gcc evaluates this at compile time. - */ - apr_size_t dirent_size = - sizeof(*(*new)->entry) + - (sizeof((*new)->entry->d_name) > 1 ? 0 : 255); - DIR *dir = opendir(dirname); - - if (!dir) { - return errno; - } - - (*new) = (apr_dir_t *)apr_palloc(pool, sizeof(apr_dir_t)); - - (*new)->pool = pool; - (*new)->dirname = apr_pstrdup(pool, dirname); - (*new)->dirstruct = dir; - (*new)->entry = apr_pcalloc(pool, dirent_size); - - apr_pool_cleanup_register((*new)->pool, *new, dir_cleanup, - apr_pool_cleanup_null); - return APR_SUCCESS; -} - -apr_status_t apr_dir_close(apr_dir_t *thedir) -{ - return apr_pool_cleanup_run(thedir->pool, thedir, dir_cleanup); -} - -#ifdef DIRENT_TYPE -static apr_filetype_e filetype_from_dirent_type(int type) -{ - switch (type) { - case DT_REG: - return APR_REG; - case DT_DIR: - return APR_DIR; - case DT_LNK: - return APR_LNK; - case DT_CHR: - return APR_CHR; - case DT_BLK: - return APR_BLK; -#if defined(DT_FIFO) - case DT_FIFO: - return APR_PIPE; -#endif -#if !defined(BEOS) && defined(DT_SOCK) - case DT_SOCK: - return APR_SOCK; -#endif - default: - return APR_UNKFILE; - } -} -#endif - -apr_status_t apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, - apr_dir_t *thedir) -{ - apr_status_t ret = 0; -#ifdef DIRENT_TYPE - apr_filetype_e type; -#endif -#if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) \ - && !defined(READDIR_IS_THREAD_SAFE) -#ifdef APR_USE_READDIR64_R - struct dirent64 *retent; - - /* If LFS is enabled and readdir64_r is available, readdir64_r is - * used in preference to readdir_r. This allows directories to be - * read which contain a (64-bit) inode number which doesn't fit - * into the 32-bit apr_ino_t, iff the caller doesn't actually care - * about the inode number (i.e. wanted & APR_FINFO_INODE == 0). - * (such inodes may be seen in some wonky NFS environments) - * - * Similarly, if the d_off field cannot be reprented in a 32-bit - * offset, the libc readdir_r() would barf; using readdir64_r - * bypasses that case entirely since APR does not care about - * d_off. */ - - ret = readdir64_r(thedir->dirstruct, thedir->entry, &retent); -#else - - struct dirent *retent; - - ret = readdir_r(thedir->dirstruct, thedir->entry, &retent); -#endif - - /* POSIX treats "end of directory" as a non-error case, so ret - * will be zero and retent will be set to NULL in that case. */ - if (!ret && retent == NULL) { - ret = APR_ENOENT; - } - - /* Solaris is a bit strange, if there are no more entries in the - * directory, it returns EINVAL. Since this is against POSIX, we - * hack around the problem here. EINVAL is possible from other - * readdir implementations, but only if the result buffer is too small. - * since we control the size of that buffer, we should never have - * that problem. - */ - if (ret == EINVAL) { - ret = APR_ENOENT; - } -#else - /* We're about to call a non-thread-safe readdir() that may - possibly set `errno', and the logic below actually cares about - errno after the call. Therefore we need to clear errno first. */ - errno = 0; - thedir->entry = readdir(thedir->dirstruct); - if (thedir->entry == NULL) { - /* If NULL was returned, this can NEVER be a success. Can it?! */ - if (errno == APR_SUCCESS) { - ret = APR_ENOENT; - } - else - ret = errno; - } -#endif - - /* No valid bit flag to test here - do we want one? */ - finfo->fname = NULL; - - if (ret) { - finfo->valid = 0; - return ret; - } - -#ifdef DIRENT_TYPE - type = filetype_from_dirent_type(thedir->entry->DIRENT_TYPE); - if (type != APR_UNKFILE) { - wanted &= ~APR_FINFO_TYPE; - } -#endif -#ifdef DIRENT_INODE - if (thedir->entry->DIRENT_INODE && thedir->entry->DIRENT_INODE != -1) { -#ifdef APR_USE_READDIR64_R - /* If readdir64_r is used, check for the overflow case of trying - * to fit a 64-bit integer into a 32-bit integer. */ - if (sizeof(apr_ino_t) >= sizeof(retent->DIRENT_INODE) - || (apr_ino_t)retent->DIRENT_INODE == retent->DIRENT_INODE) { - wanted &= ~APR_FINFO_INODE; - } else { - /* Prevent the fallback code below from filling in the - * inode if the stat call fails. */ - retent->DIRENT_INODE = 0; - } -#else - wanted &= ~APR_FINFO_INODE; -#endif /* APR_USE_READDIR64_R */ - } -#endif /* DIRENT_INODE */ - - wanted &= ~APR_FINFO_NAME; - - if (wanted) - { - char fspec[APR_PATH_MAX]; - char *end; - - end = apr_cpystrn(fspec, thedir->dirname, sizeof fspec); - - if (end > fspec && end[-1] != '/' && (end < fspec + APR_PATH_MAX)) - *end++ = '/'; - - apr_cpystrn(end, thedir->entry->d_name, - sizeof fspec - (end - fspec)); - - ret = apr_stat(finfo, fspec, APR_FINFO_LINK | wanted, thedir->pool); - /* We passed a stack name that will disappear */ - finfo->fname = NULL; - } - - if (wanted && (ret == APR_SUCCESS || ret == APR_INCOMPLETE)) { - wanted &= ~finfo->valid; - } - else { - /* We don't bail because we fail to stat, when we are only -required- - * to readdir... but the result will be APR_INCOMPLETE - */ - finfo->pool = thedir->pool; - finfo->valid = 0; -#ifdef DIRENT_TYPE - if (type != APR_UNKFILE) { - finfo->filetype = type; - finfo->valid |= APR_FINFO_TYPE; - } -#endif -#ifdef DIRENT_INODE - if (thedir->entry->DIRENT_INODE && thedir->entry->DIRENT_INODE != -1) { - finfo->inode = thedir->entry->DIRENT_INODE; - finfo->valid |= APR_FINFO_INODE; - } -#endif - } - - finfo->name = apr_pstrdup(thedir->pool, thedir->entry->d_name); - finfo->valid |= APR_FINFO_NAME; - - if (wanted) - return APR_INCOMPLETE; - - return APR_SUCCESS; -} - -apr_status_t apr_dir_rewind(apr_dir_t *thedir) -{ - rewinddir(thedir->dirstruct); - return APR_SUCCESS; -} - -apr_status_t apr_dir_make(const char *path, apr_fileperms_t perm, - apr_pool_t *pool) -{ - mode_t mode = apr_unix_perms2mode(perm); - - if (mkdir(path, mode) == 0) { - return APR_SUCCESS; - } - else { - return errno; - } -} - -apr_status_t apr_dir_make_recursive(const char *path, apr_fileperms_t perm, - apr_pool_t *pool) -{ - apr_status_t apr_err = 0; - - apr_err = apr_dir_make (path, perm, pool); /* Try to make PATH right out */ - - if (apr_err == ENOENT) { /* Missing an intermediate dir */ - char *dir; - - dir = path_remove_last_component(path, pool); - /* If there is no path left, give up. */ - if (dir[0] == '\0') { - return apr_err; - } - - apr_err = apr_dir_make_recursive(dir, perm, pool); - - if (!apr_err) - apr_err = apr_dir_make (path, perm, pool); - } - - /* - * It's OK if PATH exists. Timing issues can lead to the second - * apr_dir_make being called on existing dir, therefore this check - * has to come last. - */ - if (APR_STATUS_IS_EEXIST(apr_err)) - return APR_SUCCESS; - - return apr_err; -} - -apr_status_t apr_dir_remove(const char *path, apr_pool_t *pool) -{ - if (rmdir(path) == 0) { - return APR_SUCCESS; - } - else { - return errno; - } -} - -apr_status_t apr_os_dir_get(apr_os_dir_t **thedir, apr_dir_t *dir) -{ - if (dir == NULL) { - return APR_ENODIR; - } - *thedir = dir->dirstruct; - return APR_SUCCESS; -} - -apr_status_t apr_os_dir_put(apr_dir_t **dir, apr_os_dir_t *thedir, - apr_pool_t *pool) -{ - if ((*dir) == NULL) { - (*dir) = (apr_dir_t *)apr_pcalloc(pool, sizeof(apr_dir_t)); - (*dir)->pool = pool; - } - (*dir)->dirstruct = thedir; - return APR_SUCCESS; -} - - diff --git a/libs/apr/file_io/unix/fileacc.c b/libs/apr/file_io/unix/fileacc.c deleted file mode 100644 index 437f3589..00000000 --- a/libs/apr/file_io/unix/fileacc.c +++ /dev/null @@ -1,119 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_strings.h" -#include "apr_arch_file_io.h" - -/* A file to put ALL of the accessor functions for apr_file_t types. */ - -APR_DECLARE(apr_status_t) apr_file_name_get(const char **fname, - apr_file_t *thefile) -{ - *fname = thefile->fname; - return APR_SUCCESS; -} - -APR_DECLARE(apr_int32_t) apr_file_flags_get(apr_file_t *f) -{ - return f->flags; -} - -#if !defined(OS2) && !defined(WIN32) -mode_t apr_unix_perms2mode(apr_fileperms_t perms) -{ - mode_t mode = 0; - - if (perms & APR_USETID) - mode |= S_ISUID; - if (perms & APR_UREAD) - mode |= S_IRUSR; - if (perms & APR_UWRITE) - mode |= S_IWUSR; - if (perms & APR_UEXECUTE) - mode |= S_IXUSR; - - if (perms & APR_GSETID) - mode |= S_ISGID; - if (perms & APR_GREAD) - mode |= S_IRGRP; - if (perms & APR_GWRITE) - mode |= S_IWGRP; - if (perms & APR_GEXECUTE) - mode |= S_IXGRP; - -#ifdef S_ISVTX - if (perms & APR_WSTICKY) - mode |= S_ISVTX; -#endif - if (perms & APR_WREAD) - mode |= S_IROTH; - if (perms & APR_WWRITE) - mode |= S_IWOTH; - if (perms & APR_WEXECUTE) - mode |= S_IXOTH; - - return mode; -} - -apr_fileperms_t apr_unix_mode2perms(mode_t mode) -{ - apr_fileperms_t perms = 0; - - if (mode & S_ISUID) - perms |= APR_USETID; - if (mode & S_IRUSR) - perms |= APR_UREAD; - if (mode & S_IWUSR) - perms |= APR_UWRITE; - if (mode & S_IXUSR) - perms |= APR_UEXECUTE; - - if (mode & S_ISGID) - perms |= APR_GSETID; - if (mode & S_IRGRP) - perms |= APR_GREAD; - if (mode & S_IWGRP) - perms |= APR_GWRITE; - if (mode & S_IXGRP) - perms |= APR_GEXECUTE; - -#ifdef S_ISVTX - if (mode & S_ISVTX) - perms |= APR_WSTICKY; -#endif - if (mode & S_IROTH) - perms |= APR_WREAD; - if (mode & S_IWOTH) - perms |= APR_WWRITE; - if (mode & S_IXOTH) - perms |= APR_WEXECUTE; - - return perms; -} -#endif - -APR_DECLARE(apr_status_t) apr_file_data_get(void **data, const char *key, - apr_file_t *file) -{ - return apr_pool_userdata_get(data, key, file->pool); -} - -APR_DECLARE(apr_status_t) apr_file_data_set(apr_file_t *file, void *data, - const char *key, - apr_status_t (*cleanup)(void *)) -{ - return apr_pool_userdata_set(data, key, cleanup, file->pool); -} diff --git a/libs/apr/file_io/unix/filedup.c b/libs/apr/file_io/unix/filedup.c deleted file mode 100644 index eb4fbdc6..00000000 --- a/libs/apr/file_io/unix/filedup.c +++ /dev/null @@ -1,182 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_file_io.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_thread_mutex.h" -#include "apr_arch_inherit.h" - -static apr_status_t file_dup(apr_file_t **new_file, - apr_file_t *old_file, apr_pool_t *p, - int which_dup) -{ - int rv; -#ifdef HAVE_DUP3 - int flags = 0; -#endif - - if (which_dup == 2) { - if ((*new_file) == NULL) { - /* We can't dup2 unless we have a valid new_file */ - return APR_EINVAL; - } -#ifdef HAVE_DUP3 - if (!((*new_file)->flags & (APR_FOPEN_NOCLEANUP|APR_INHERIT))) - flags |= O_CLOEXEC; - rv = dup3(old_file->filedes, (*new_file)->filedes, flags); -#else - rv = dup2(old_file->filedes, (*new_file)->filedes); - if (!((*new_file)->flags & (APR_FOPEN_NOCLEANUP|APR_INHERIT))) { - int flags; - - if (rv == -1) - return errno; - - if ((flags = fcntl((*new_file)->filedes, F_GETFD)) == -1) - return errno; - - flags |= FD_CLOEXEC; - if (fcntl((*new_file)->filedes, F_SETFD, flags) == -1) - return errno; - - } -#endif - } else { - rv = dup(old_file->filedes); - } - - if (rv == -1) - return errno; - - if (which_dup == 1) { - (*new_file) = (apr_file_t *)apr_pcalloc(p, sizeof(apr_file_t)); - (*new_file)->pool = p; - (*new_file)->filedes = rv; - } - - (*new_file)->fname = apr_pstrdup(p, old_file->fname); - (*new_file)->buffered = old_file->buffered; - - /* If the existing socket in a dup2 is already buffered, we - * have an existing and valid (hopefully) mutex, so we don't - * want to create it again as we could leak! - */ -#if APR_HAS_THREADS - if ((*new_file)->buffered && !(*new_file)->thlock && old_file->thlock) { - apr_thread_mutex_create(&((*new_file)->thlock), - APR_THREAD_MUTEX_DEFAULT, p); - } -#endif - /* As above, only create the buffer if we haven't already - * got one. - */ - if ((*new_file)->buffered && !(*new_file)->buffer) { - (*new_file)->buffer = apr_palloc(p, old_file->bufsize); - (*new_file)->bufsize = old_file->bufsize; - } - - /* this is the way dup() works */ - (*new_file)->blocking = old_file->blocking; - - /* make sure unget behavior is consistent */ - (*new_file)->ungetchar = old_file->ungetchar; - - /* apr_file_dup2() retains the original cleanup, reflecting - * the existing inherit and nocleanup flags. This means, - * that apr_file_dup2() cannot be called against an apr_file_t - * already closed with apr_file_close, because the expected - * cleanup was already killed. - */ - if (which_dup == 2) { - return APR_SUCCESS; - } - - /* apr_file_dup() retains all old_file flags with the exceptions - * of APR_INHERIT and APR_FOPEN_NOCLEANUP. - * The user must call apr_file_inherit_set() on the dupped - * apr_file_t when desired. - */ - (*new_file)->flags = old_file->flags - & ~(APR_INHERIT | APR_FOPEN_NOCLEANUP); - - apr_pool_cleanup_register((*new_file)->pool, (void *)(*new_file), - apr_unix_file_cleanup, - apr_unix_child_file_cleanup); -#ifndef WAITIO_USES_POLL - /* Start out with no pollset. apr_wait_for_io_or_timeout() will - * initialize the pollset if needed. - */ - (*new_file)->pollset = NULL; -#endif - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_dup(apr_file_t **new_file, - apr_file_t *old_file, apr_pool_t *p) -{ - return file_dup(new_file, old_file, p, 1); -} - -APR_DECLARE(apr_status_t) apr_file_dup2(apr_file_t *new_file, - apr_file_t *old_file, apr_pool_t *p) -{ - return file_dup(&new_file, old_file, p, 2); -} - -APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file, - apr_file_t *old_file, - apr_pool_t *p) -{ - *new_file = (apr_file_t *)apr_palloc(p, sizeof(apr_file_t)); - memcpy(*new_file, old_file, sizeof(apr_file_t)); - (*new_file)->pool = p; - if (old_file->buffered) { - (*new_file)->buffer = apr_palloc(p, old_file->bufsize); - (*new_file)->bufsize = old_file->bufsize; - if (old_file->direction == 1) { - memcpy((*new_file)->buffer, old_file->buffer, old_file->bufpos); - } - else { - memcpy((*new_file)->buffer, old_file->buffer, old_file->dataRead); - } -#if APR_HAS_THREADS - if (old_file->thlock) { - apr_thread_mutex_create(&((*new_file)->thlock), - APR_THREAD_MUTEX_DEFAULT, p); - apr_thread_mutex_destroy(old_file->thlock); - } -#endif /* APR_HAS_THREADS */ - } - if (old_file->fname) { - (*new_file)->fname = apr_pstrdup(p, old_file->fname); - } - if (!(old_file->flags & APR_FOPEN_NOCLEANUP)) { - apr_pool_cleanup_register(p, (void *)(*new_file), - apr_unix_file_cleanup, - ((*new_file)->flags & APR_INHERIT) - ? apr_pool_cleanup_null - : apr_unix_child_file_cleanup); - } - - old_file->filedes = -1; - apr_pool_cleanup_kill(old_file->pool, (void *)old_file, - apr_unix_file_cleanup); -#ifndef WAITIO_USES_POLL - (*new_file)->pollset = NULL; -#endif - return APR_SUCCESS; -} diff --git a/libs/apr/file_io/unix/filepath.c b/libs/apr/file_io/unix/filepath.c deleted file mode 100644 index 6a65b202..00000000 --- a/libs/apr/file_io/unix/filepath.c +++ /dev/null @@ -1,314 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_private.h" -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_strings.h" -#define APR_WANT_STRFUNC -#include "apr_want.h" -#if APR_HAVE_UNISTD_H -#include -#endif - -/* Win32 malpropism that can go away once everyone believes this - * code is golden, and I'm not testing it anymore :-) - */ -#if APR_HAVE_DIRENT_H -#include -#endif - -/* Any OS that requires/refuses trailing slashes should be dealt with here. - */ -APR_DECLARE(apr_status_t) apr_filepath_get(char **defpath, apr_int32_t flags, - apr_pool_t *p) -{ - char path[APR_PATH_MAX]; - - if (!getcwd(path, sizeof(path))) { - if (errno == ERANGE) - return APR_ENAMETOOLONG; - else - return errno; - } - *defpath = apr_pstrdup(p, path); - - return APR_SUCCESS; -} - - -/* Any OS that requires/refuses trailing slashes should be dealt with here - */ -APR_DECLARE(apr_status_t) apr_filepath_set(const char *path, apr_pool_t *p) -{ - if (chdir(path) != 0) - return errno; - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_filepath_root(const char **rootpath, - const char **inpath, - apr_int32_t flags, - apr_pool_t *p) -{ - if (**inpath == '/') { - *rootpath = apr_pstrdup(p, "/"); - do { - ++(*inpath); - } while (**inpath == '/'); - - return APR_SUCCESS; - } - - return APR_ERELATIVE; -} - -APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, - const char *rootpath, - const char *addpath, - apr_int32_t flags, - apr_pool_t *p) -{ - char *path; - apr_size_t rootlen; /* is the length of the src rootpath */ - apr_size_t maxlen; /* maximum total path length */ - apr_size_t keptlen; /* is the length of the retained rootpath */ - apr_size_t pathlen; /* is the length of the result path */ - apr_size_t seglen; /* is the end of the current segment */ - apr_status_t rv; - - /* Treat null as an empty path. - */ - if (!addpath) - addpath = ""; - - if (addpath[0] == '/') { - /* If addpath is rooted, then rootpath is unused. - * Ths violates any APR_FILEPATH_SECUREROOTTEST and - * APR_FILEPATH_NOTABSOLUTE flags specified. - */ - if (flags & APR_FILEPATH_SECUREROOTTEST) - return APR_EABOVEROOT; - if (flags & APR_FILEPATH_NOTABSOLUTE) - return APR_EABSOLUTE; - - /* If APR_FILEPATH_NOTABOVEROOT wasn't specified, - * we won't test the root again, it's ignored. - * Waste no CPU retrieving the working path. - */ - if (!rootpath && !(flags & APR_FILEPATH_NOTABOVEROOT)) - rootpath = ""; - } - else { - /* If APR_FILEPATH_NOTABSOLUTE is specified, the caller - * requires a relative result. If the rootpath is - * ommitted, we do not retrieve the working path, - * if rootpath was supplied as absolute then fail. - */ - if (flags & APR_FILEPATH_NOTABSOLUTE) { - if (!rootpath) - rootpath = ""; - else if (rootpath[0] == '/') - return APR_EABSOLUTE; - } - } - - if (!rootpath) { - /* Start with the current working path. This is bass akwards, - * but required since the compiler (at least vc) doesn't like - * passing the address of a char const* for a char** arg. - */ - char *getpath; - rv = apr_filepath_get(&getpath, flags, p); - rootpath = getpath; - if (rv != APR_SUCCESS) - return errno; - - /* XXX: Any kernel subject to goofy, uncanonical results - * must run the rootpath against the user's given flags. - * Simplest would be a recursive call to apr_filepath_merge - * with an empty (not null) rootpath and addpath of the cwd. - */ - } - - rootlen = strlen(rootpath); - maxlen = rootlen + strlen(addpath) + 4; /* 4 for slashes at start, after - * root, and at end, plus trailing - * null */ - if (maxlen > APR_PATH_MAX) { - return APR_ENAMETOOLONG; - } - path = (char *)apr_palloc(p, maxlen); - - if (addpath[0] == '/') { - /* Ignore the given root path, strip off leading - * '/'s to a single leading '/' from the addpath, - * and leave addpath at the first non-'/' character. - */ - keptlen = 0; - while (addpath[0] == '/') - ++addpath; - path[0] = '/'; - pathlen = 1; - } - else { - /* If both paths are relative, fail early - */ - if (rootpath[0] != '/' && (flags & APR_FILEPATH_NOTRELATIVE)) - return APR_ERELATIVE; - - /* Base the result path on the rootpath - */ - keptlen = rootlen; - memcpy(path, rootpath, rootlen); - - /* Always '/' terminate the given root path - */ - if (keptlen && path[keptlen - 1] != '/') { - path[keptlen++] = '/'; - } - pathlen = keptlen; - } - - while (*addpath) { - /* Parse each segment, find the closing '/' - */ - const char *next = addpath; - while (*next && (*next != '/')) { - ++next; - } - seglen = next - addpath; - - if (seglen == 0 || (seglen == 1 && addpath[0] == '.')) { - /* noop segment (/ or ./) so skip it - */ - } - else if (seglen == 2 && addpath[0] == '.' && addpath[1] == '.') { - /* backpath (../) */ - if (pathlen == 1 && path[0] == '/') { - /* Attempt to move above root. Always die if the - * APR_FILEPATH_SECUREROOTTEST flag is specified. - */ - if (flags & APR_FILEPATH_SECUREROOTTEST) { - return APR_EABOVEROOT; - } - - /* Otherwise this is simply a noop, above root is root. - * Flag that rootpath was entirely replaced. - */ - keptlen = 0; - } - else if (pathlen == 0 - || (pathlen == 3 - && !memcmp(path + pathlen - 3, "../", 3)) - || (pathlen > 3 - && !memcmp(path + pathlen - 4, "/../", 4))) { - /* Path is already backpathed or empty, if the - * APR_FILEPATH_SECUREROOTTEST.was given die now. - */ - if (flags & APR_FILEPATH_SECUREROOTTEST) { - return APR_EABOVEROOT; - } - - /* Otherwise append another backpath, including - * trailing slash if present. - */ - memcpy(path + pathlen, "../", *next ? 3 : 2); - pathlen += *next ? 3 : 2; - } - else { - /* otherwise crop the prior segment - */ - do { - --pathlen; - } while (pathlen && path[pathlen - 1] != '/'); - } - - /* Now test if we are above where we started and back up - * the keptlen offset to reflect the added/altered path. - */ - if (pathlen < keptlen) { - if (flags & APR_FILEPATH_SECUREROOTTEST) { - return APR_EABOVEROOT; - } - keptlen = pathlen; - } - } - else { - /* An actual segment, append it to the destination path - */ - if (*next) { - seglen++; - } - memcpy(path + pathlen, addpath, seglen); - pathlen += seglen; - } - - /* Skip over trailing slash to the next segment - */ - if (*next) { - ++next; - } - - addpath = next; - } - path[pathlen] = '\0'; - - /* keptlen will be the rootlen unless the addpath contained - * backpath elements. If so, and APR_FILEPATH_NOTABOVEROOT - * is specified (APR_FILEPATH_SECUREROOTTEST was caught above), - * compare the original root to assure the result path is - * still within given root path. - */ - if ((flags & APR_FILEPATH_NOTABOVEROOT) && keptlen < rootlen) { - if (strncmp(rootpath, path, rootlen)) { - return APR_EABOVEROOT; - } - if (rootpath[rootlen - 1] != '/' - && path[rootlen] && path[rootlen] != '/') { - return APR_EABOVEROOT; - } - } - - *newpath = path; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_filepath_list_split(apr_array_header_t **pathelts, - const char *liststr, - apr_pool_t *p) -{ - return apr_filepath_list_split_impl(pathelts, liststr, ':', p); -} - -APR_DECLARE(apr_status_t) apr_filepath_list_merge(char **liststr, - apr_array_header_t *pathelts, - apr_pool_t *p) -{ - return apr_filepath_list_merge_impl(liststr, pathelts, ':', p); -} - -APR_DECLARE(apr_status_t) apr_filepath_encoding(int *style, apr_pool_t *p) -{ -#if defined(DARWIN) - *style = APR_FILEPATH_ENCODING_UTF8; -#else - *style = APR_FILEPATH_ENCODING_LOCALE; -#endif - return APR_SUCCESS; -} diff --git a/libs/apr/file_io/unix/filepath_util.c b/libs/apr/file_io/unix/filepath_util.c deleted file mode 100644 index d8ccc567..00000000 --- a/libs/apr/file_io/unix/filepath_util.c +++ /dev/null @@ -1,111 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#define APR_WANT_STRFUNC -#define APR_WANT_MEMFUNC -#include "apr_want.h" - -#include "apr_errno.h" -#include "apr_pools.h" -#include "apr_strings.h" -#include "apr_tables.h" - -#include "apr_private.h" - -apr_status_t apr_filepath_list_split_impl(apr_array_header_t **pathelts, - const char *liststr, - char separator, - apr_pool_t *p) -{ - char *path, *part, *ptr; - char separator_string[2] = { '\0', '\0' }; - apr_array_header_t *elts; - int nelts; - - separator_string[0] = separator; - /* Count the number of path elements. We know there'll be at least - one even if path is an empty string. */ - path = apr_pstrdup(p, liststr); - for (nelts = 0, ptr = path; ptr != NULL; ++nelts) - { - ptr = strchr(ptr, separator); - if (ptr) - ++ptr; - } - - /* Split the path into the array. */ - elts = apr_array_make(p, nelts, sizeof(char*)); - while ((part = apr_strtok(path, separator_string, &ptr)) != NULL) - { - if (*part == '\0') /* Ignore empty path components. */ - continue; - - *(char**)apr_array_push(elts) = part; - path = NULL; /* For the next call to apr_strtok */ - } - - *pathelts = elts; - return APR_SUCCESS; -} - - -apr_status_t apr_filepath_list_merge_impl(char **liststr, - apr_array_header_t *pathelts, - char separator, - apr_pool_t *p) -{ - apr_size_t path_size = 0; - char *path; - int i; - - /* This test isn't 100% certain, but it'll catch at least some - invalid uses... */ - if (pathelts->elt_size != sizeof(char*)) - return APR_EINVAL; - - /* Calculate the size of the merged path */ - for (i = 0; i < pathelts->nelts; ++i) - path_size += strlen(((char**)pathelts->elts)[i]); - - if (path_size == 0) - { - *liststr = NULL; - return APR_SUCCESS; - } - - if (i > 0) /* Add space for the separators */ - path_size += (i - 1); - - /* Merge the path components */ - path = *liststr = apr_palloc(p, path_size + 1); - for (i = 0; i < pathelts->nelts; ++i) - { - /* ### Hmmmm. Calling strlen twice on the same string. Yuck. - But is is better than reallocation in apr_pstrcat? */ - const char *part = ((char**)pathelts->elts)[i]; - apr_size_t part_size = strlen(part); - if (part_size == 0) /* Ignore empty path components. */ - continue; - - if (i > 0) - *path++ = separator; - memcpy(path, part, part_size); - path += part_size; - } - *path = '\0'; - return APR_SUCCESS; -} diff --git a/libs/apr/file_io/unix/filestat.c b/libs/apr/file_io/unix/filestat.c deleted file mode 100644 index 9bee6511..00000000 --- a/libs/apr/file_io/unix/filestat.c +++ /dev/null @@ -1,339 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_errno.h" - -#ifdef HAVE_UTIME -#include -#endif - -static apr_filetype_e filetype_from_mode(mode_t mode) -{ - apr_filetype_e type; - - switch (mode & S_IFMT) { - case S_IFREG: - type = APR_REG; break; - case S_IFDIR: - type = APR_DIR; break; - case S_IFLNK: - type = APR_LNK; break; - case S_IFCHR: - type = APR_CHR; break; - case S_IFBLK: - type = APR_BLK; break; -#if defined(S_IFFIFO) - case S_IFFIFO: - type = APR_PIPE; break; -#endif -#if !defined(BEOS) && defined(S_IFSOCK) - case S_IFSOCK: - type = APR_SOCK; break; -#endif - - default: - /* Work around missing S_IFxxx values above - * for Linux et al. - */ -#if !defined(S_IFFIFO) && defined(S_ISFIFO) - if (S_ISFIFO(mode)) { - type = APR_PIPE; - } else -#endif -#if !defined(BEOS) && !defined(S_IFSOCK) && defined(S_ISSOCK) - if (S_ISSOCK(mode)) { - type = APR_SOCK; - } else -#endif - type = APR_UNKFILE; - } - return type; -} - -static void fill_out_finfo(apr_finfo_t *finfo, struct_stat *info, - apr_int32_t wanted) -{ - finfo->valid = APR_FINFO_MIN | APR_FINFO_IDENT | APR_FINFO_NLINK - | APR_FINFO_OWNER | APR_FINFO_PROT; - finfo->protection = apr_unix_mode2perms(info->st_mode); - finfo->filetype = filetype_from_mode(info->st_mode); - finfo->user = info->st_uid; - finfo->group = info->st_gid; - finfo->size = info->st_size; - finfo->device = info->st_dev; - finfo->nlink = info->st_nlink; - - /* Check for overflow if storing a 64-bit st_ino in a 32-bit - * apr_ino_t for LFS builds: */ - if (sizeof(apr_ino_t) >= sizeof(info->st_ino) - || (apr_ino_t)info->st_ino == info->st_ino) { - finfo->inode = info->st_ino; - } else { - finfo->valid &= ~APR_FINFO_INODE; - } - - apr_time_ansi_put(&finfo->atime, info->st_atime); -#ifdef HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC - finfo->atime += info->st_atim.tv_nsec / APR_TIME_C(1000); -#elif defined(HAVE_STRUCT_STAT_ST_ATIMENSEC) - finfo->atime += info->st_atimensec / APR_TIME_C(1000); -#elif defined(HAVE_STRUCT_STAT_ST_ATIME_N) - finfo->ctime += info->st_atime_n / APR_TIME_C(1000); -#endif - - apr_time_ansi_put(&finfo->mtime, info->st_mtime); -#ifdef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC - finfo->mtime += info->st_mtim.tv_nsec / APR_TIME_C(1000); -#elif defined(HAVE_STRUCT_STAT_ST_MTIMENSEC) - finfo->mtime += info->st_mtimensec / APR_TIME_C(1000); -#elif defined(HAVE_STRUCT_STAT_ST_MTIME_N) - finfo->ctime += info->st_mtime_n / APR_TIME_C(1000); -#endif - - apr_time_ansi_put(&finfo->ctime, info->st_ctime); -#ifdef HAVE_STRUCT_STAT_ST_CTIM_TV_NSEC - finfo->ctime += info->st_ctim.tv_nsec / APR_TIME_C(1000); -#elif defined(HAVE_STRUCT_STAT_ST_CTIMENSEC) - finfo->ctime += info->st_ctimensec / APR_TIME_C(1000); -#elif defined(HAVE_STRUCT_STAT_ST_CTIME_N) - finfo->ctime += info->st_ctime_n / APR_TIME_C(1000); -#endif - -#ifdef HAVE_STRUCT_STAT_ST_BLOCKS -#ifdef DEV_BSIZE - finfo->csize = (apr_off_t)info->st_blocks * (apr_off_t)DEV_BSIZE; -#else - finfo->csize = (apr_off_t)info->st_blocks * (apr_off_t)512; -#endif - finfo->valid |= APR_FINFO_CSIZE; -#endif -} - -apr_status_t apr_file_info_get_locked(apr_finfo_t *finfo, apr_int32_t wanted, - apr_file_t *thefile) -{ - struct_stat info; - - if (thefile->buffered) { - apr_status_t rv = apr_file_flush_locked(thefile); - if (rv != APR_SUCCESS) - return rv; - } - - if (fstat(thefile->filedes, &info) == 0) { - finfo->pool = thefile->pool; - finfo->fname = thefile->fname; - fill_out_finfo(finfo, &info, wanted); - return (wanted & ~finfo->valid) ? APR_INCOMPLETE : APR_SUCCESS; - } - else { - return errno; - } -} - -APR_DECLARE(apr_status_t) apr_file_info_get(apr_finfo_t *finfo, - apr_int32_t wanted, - apr_file_t *thefile) -{ - struct_stat info; - - if (thefile->buffered) { - apr_status_t rv = apr_file_flush(thefile); - if (rv != APR_SUCCESS) - return rv; - } - - if (fstat(thefile->filedes, &info) == 0) { - finfo->pool = thefile->pool; - finfo->fname = thefile->fname; - fill_out_finfo(finfo, &info, wanted); - return (wanted & ~finfo->valid) ? APR_INCOMPLETE : APR_SUCCESS; - } - else { - return errno; - } -} - -APR_DECLARE(apr_status_t) apr_file_perms_set(const char *fname, - apr_fileperms_t perms) -{ - mode_t mode = apr_unix_perms2mode(perms); - - if (chmod(fname, mode) == -1) - return errno; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, - apr_fileattrs_t attributes, - apr_fileattrs_t attr_mask, - apr_pool_t *pool) -{ - apr_status_t status; - apr_finfo_t finfo; - - /* Don't do anything if we can't handle the requested attributes */ - if (!(attr_mask & (APR_FILE_ATTR_READONLY - | APR_FILE_ATTR_EXECUTABLE))) - return APR_SUCCESS; - - status = apr_stat(&finfo, fname, APR_FINFO_PROT, pool); - if (status) - return status; - - /* ### TODO: should added bits be umask'd? */ - if (attr_mask & APR_FILE_ATTR_READONLY) - { - if (attributes & APR_FILE_ATTR_READONLY) - { - finfo.protection &= ~APR_UWRITE; - finfo.protection &= ~APR_GWRITE; - finfo.protection &= ~APR_WWRITE; - } - else - { - /* ### umask this! */ - finfo.protection |= APR_UWRITE; - finfo.protection |= APR_GWRITE; - finfo.protection |= APR_WWRITE; - } - } - - if (attr_mask & APR_FILE_ATTR_EXECUTABLE) - { - if (attributes & APR_FILE_ATTR_EXECUTABLE) - { - /* ### umask this! */ - finfo.protection |= APR_UEXECUTE; - finfo.protection |= APR_GEXECUTE; - finfo.protection |= APR_WEXECUTE; - } - else - { - finfo.protection &= ~APR_UEXECUTE; - finfo.protection &= ~APR_GEXECUTE; - finfo.protection &= ~APR_WEXECUTE; - } - } - - return apr_file_perms_set(fname, finfo.protection); -} - - -APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname, - apr_time_t mtime, - apr_pool_t *pool) -{ - apr_status_t status; - apr_finfo_t finfo; - - status = apr_stat(&finfo, fname, APR_FINFO_ATIME, pool); - if (status) { - return status; - } - -#ifdef HAVE_UTIMES - { - struct timeval tvp[2]; - - tvp[0].tv_sec = apr_time_sec(finfo.atime); - tvp[0].tv_usec = apr_time_usec(finfo.atime); - tvp[1].tv_sec = apr_time_sec(mtime); - tvp[1].tv_usec = apr_time_usec(mtime); - - if (utimes(fname, tvp) == -1) { - return errno; - } - } -#elif defined(HAVE_UTIME) - { - struct utimbuf buf; - - buf.actime = (time_t) (finfo.atime / APR_USEC_PER_SEC); - buf.modtime = (time_t) (mtime / APR_USEC_PER_SEC); - - if (utime(fname, &buf) == -1) { - return errno; - } - } -#else - return APR_ENOTIMPL; -#endif - - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, - const char *fname, - apr_int32_t wanted, apr_pool_t *pool) -{ - struct_stat info; - int srv; - - if (wanted & APR_FINFO_LINK) - srv = lstat(fname, &info); - else - srv = stat(fname, &info); - - if (srv == 0) { - finfo->pool = pool; - finfo->fname = fname; - fill_out_finfo(finfo, &info, wanted); - if (wanted & APR_FINFO_LINK) - wanted &= ~APR_FINFO_LINK; - return (wanted & ~finfo->valid) ? APR_INCOMPLETE : APR_SUCCESS; - } - else { -#if !defined(ENOENT) || !defined(ENOTDIR) -#error ENOENT || ENOTDIR not defined; please see the -#error comments at this line in the source for a workaround. - /* - * If ENOENT || ENOTDIR is not defined in one of the your OS's - * include files, APR cannot report a good reason why the stat() - * of the file failed; there are cases where it can fail even though - * the file exists. This opens holes in Apache, for example, because - * it becomes possible for someone to get a directory listing of a - * directory even though there is an index (eg. index.html) file in - * it. If you do not have a problem with this, delete the above - * #error lines and start the compile again. If you need to do this, - * please submit a bug report to http://www.apache.org/bug_report.html - * letting us know that you needed to do this. Please be sure to - * include the operating system you are using. - */ - /* WARNING: All errors will be handled as not found - */ -#if !defined(ENOENT) - return APR_ENOENT; -#else - /* WARNING: All errors but not found will be handled as not directory - */ - if (errno != ENOENT) - return APR_ENOENT; - else - return errno; -#endif -#else /* All was defined well, report the usual: */ - return errno; -#endif - } -} - - diff --git a/libs/apr/file_io/unix/flock.c b/libs/apr/file_io/unix/flock.c deleted file mode 100644 index f400a967..00000000 --- a/libs/apr/file_io/unix/flock.c +++ /dev/null @@ -1,120 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_file_io.h" - -#if APR_HAVE_FCNTL_H -#include -#endif -#ifdef HAVE_SYS_FILE_H -#include -#endif - -APR_DECLARE(apr_status_t) apr_file_lock(apr_file_t *thefile, int type) -{ - int rc; - -#if defined(HAVE_FCNTL_H) - { - struct flock l = { 0 }; - int fc; - - l.l_whence = SEEK_SET; /* lock from current point */ - l.l_start = 0; /* begin lock at this offset */ - l.l_len = 0; /* lock to end of file */ - if ((type & APR_FLOCK_TYPEMASK) == APR_FLOCK_SHARED) - l.l_type = F_RDLCK; - else - l.l_type = F_WRLCK; - - fc = (type & APR_FLOCK_NONBLOCK) ? F_SETLK : F_SETLKW; - - /* keep trying if fcntl() gets interrupted (by a signal) */ - while ((rc = fcntl(thefile->filedes, fc, &l)) < 0 && errno == EINTR) - continue; - - if (rc == -1) { - /* on some Unix boxes (e.g., Tru64), we get EACCES instead - * of EAGAIN; we don't want APR_STATUS_IS_EAGAIN() matching EACCES - * since that breaks other things, so fix up the retcode here - */ - if (errno == EACCES) { - return EAGAIN; - } - return errno; - } - } -#elif defined(HAVE_SYS_FILE_H) - { - int ltype; - - if ((type & APR_FLOCK_TYPEMASK) == APR_FLOCK_SHARED) - ltype = LOCK_SH; - else - ltype = LOCK_EX; - if ((type & APR_FLOCK_NONBLOCK) != 0) - ltype |= LOCK_NB; - - /* keep trying if flock() gets interrupted (by a signal) */ - while ((rc = flock(thefile->filedes, ltype)) < 0 && errno == EINTR) - continue; - - if (rc == -1) - return errno; - } -#else -#error No file locking mechanism is available. -#endif - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_unlock(apr_file_t *thefile) -{ - int rc; - -#if defined(HAVE_FCNTL_H) - { - struct flock l = { 0 }; - - l.l_whence = SEEK_SET; /* lock from current point */ - l.l_start = 0; /* begin lock at this offset */ - l.l_len = 0; /* lock to end of file */ - l.l_type = F_UNLCK; - - /* keep trying if fcntl() gets interrupted (by a signal) */ - while ((rc = fcntl(thefile->filedes, F_SETLKW, &l)) < 0 - && errno == EINTR) - continue; - - if (rc == -1) - return errno; - } -#elif defined(HAVE_SYS_FILE_H) - { - /* keep trying if flock() gets interrupted (by a signal) */ - while ((rc = flock(thefile->filedes, LOCK_UN)) < 0 && errno == EINTR) - continue; - - if (rc == -1) - return errno; - } -#else -#error No file locking mechanism is available. -#endif - - return APR_SUCCESS; -} diff --git a/libs/apr/file_io/unix/fullrw.c b/libs/apr/file_io/unix/fullrw.c deleted file mode 100644 index 3c67f659..00000000 --- a/libs/apr/file_io/unix/fullrw.c +++ /dev/null @@ -1,111 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_file_io.h" - - -APR_DECLARE(apr_status_t) apr_file_read_full(apr_file_t *thefile, void *buf, - apr_size_t nbytes, - apr_size_t *bytes_read) -{ - apr_status_t status; - apr_size_t total_read = 0; - - do { - apr_size_t amt = nbytes; - - status = apr_file_read(thefile, buf, &amt); - buf = (char *)buf + amt; - nbytes -= amt; - total_read += amt; - } while (status == APR_SUCCESS && nbytes > 0); - - if (bytes_read != NULL) - *bytes_read = total_read; - - return status; -} - -APR_DECLARE(apr_status_t) apr_file_write_full(apr_file_t *thefile, - const void *buf, - apr_size_t nbytes, - apr_size_t *bytes_written) -{ - apr_status_t status; - apr_size_t total_written = 0; - - do { - apr_size_t amt = nbytes; - - status = apr_file_write(thefile, buf, &amt); - buf = (char *)buf + amt; - nbytes -= amt; - total_written += amt; - } while (status == APR_SUCCESS && nbytes > 0); - - if (bytes_written != NULL) - *bytes_written = total_written; - - return status; -} - -APR_DECLARE(apr_status_t) apr_file_writev_full(apr_file_t *thefile, - const struct iovec *vec, - apr_size_t nvec, - apr_size_t *bytes_written) -{ - apr_status_t rv = APR_SUCCESS; - apr_size_t i; - apr_size_t amt = 0; - apr_size_t total = 0; - - for (i = 0; i < nvec; i++) { - total += vec[i].iov_len; - } - - rv = apr_file_writev(thefile, vec, nvec, &amt); - - if (bytes_written != NULL) - *bytes_written = amt; - - if (rv != APR_SUCCESS || (amt == total)) { - return rv; - } - - for (i = 0; i < nvec && amt; i++) { - if (amt >= vec[i].iov_len) { - amt -= vec[i].iov_len; - } - else { - break; - } - } - - if (amt) { - rv = apr_file_write_full(thefile, (const char *)vec[i].iov_base + amt, - vec[i].iov_len - amt, NULL); - } - - for (; i < nvec && rv == APR_SUCCESS; i++) { - rv = apr_file_write_full(thefile, vec[i].iov_base, - vec[i].iov_len, &amt); - } - - if (bytes_written != NULL) - *bytes_written = total; - - return rv; -} diff --git a/libs/apr/file_io/unix/mktemp.c b/libs/apr/file_io/unix/mktemp.c deleted file mode 100644 index 28aaf90e..00000000 --- a/libs/apr/file_io/unix/mktemp.c +++ /dev/null @@ -1,223 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Copyright (c) 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "apr_private.h" -#include "apr_file_io.h" /* prototype of apr_mkstemp() */ -#include "apr_strings.h" /* prototype of apr_mkstemp() */ -#include "apr_arch_file_io.h" /* prototype of apr_mkstemp() */ -#include "apr_portable.h" /* for apr_os_file_put() */ -#include "apr_arch_inherit.h" - -#ifndef HAVE_MKSTEMP - -#if defined(SVR4) || defined(WIN32) || defined(NETWARE) -#ifdef SVR4 -#if HAVE_INTTYPES_H -#include -#endif -#endif -#define arc4random() rand() -#define seedrandom(a) srand(a) -#else -#if APR_HAVE_STDINT_H -#include -#endif -#define arc4random() random() -#define seedrandom(a) srandom(a) -#endif - -#if APR_HAVE_SYS_TYPES_H -#include -#endif -#if APR_HAVE_SYS_STAT_H -#include -#endif -#if APR_HAVE_FCNTL_H -#include -#endif -#include -#include -#include -#include -#ifdef HAVE_TIME_H -#include -#endif - -static const unsigned char padchar[] = -"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; -static apr_uint32_t randseed=0; - -static int gettemp(char *path, apr_file_t **doopen, apr_int32_t flags, apr_pool_t *p) -{ - register char *start, *trv, *suffp; - char *pad; - apr_finfo_t sbuf; - apr_status_t rv; - apr_uint32_t randnum; - - if (randseed==0) { - randseed = (int)apr_time_now(); - seedrandom(randseed); - } - - for (trv = path; *trv; ++trv) - ; - suffp = trv; - --trv; - if (trv < path) { - return APR_EINVAL; - } - - /* Fill space with random characters */ - while (*trv == 'X') { - randnum = arc4random() % (sizeof(padchar) - 1); - *trv-- = padchar[randnum]; - } - start = trv + 1; - - /* - * check the target directory. - */ - for (;; --trv) { - if (trv <= path) - break; - if (*trv == '/') { - *trv = '\0'; - rv = apr_stat(&sbuf, path, APR_FINFO_TYPE, p); - *trv = '/'; - if (rv != APR_SUCCESS) - return rv; - if (sbuf.filetype != APR_DIR) { - return APR_ENOTDIR; - } - break; - } - } - - for (;;) { - if ((rv = apr_file_open(doopen, path, flags, - APR_UREAD | APR_UWRITE, p)) == APR_SUCCESS) - return APR_SUCCESS; - if (!APR_STATUS_IS_EEXIST(rv)) - return rv; - - /* If we have a collision, cycle through the space of filenames */ - for (trv = start;;) { - if (*trv == '\0' || trv == suffp) - return APR_EINVAL; /* XXX: is this the correct return code? */ - pad = strchr((char *)padchar, *trv); - if (pad == NULL || !*++pad) { - *trv++ = padchar[0]; - } - else { - *trv++ = *pad; - break; - } - } - } - /*NOTREACHED*/ -} - -#else - -#if APR_HAVE_STDLIB_H -#include /* for mkstemp() - Single Unix */ -#endif -#if APR_HAVE_UNISTD_H -#include /* for mkstemp() - FreeBSD */ -#endif -#endif /* !defined(HAVE_MKSTEMP) */ - -APR_DECLARE(apr_status_t) apr_file_mktemp(apr_file_t **fp, char *template, apr_int32_t flags, apr_pool_t *p) -{ -#ifdef HAVE_MKSTEMP - int fd; -#endif - flags = (!flags) ? APR_FOPEN_CREATE | APR_FOPEN_READ | APR_FOPEN_WRITE | APR_FOPEN_EXCL | - APR_FOPEN_DELONCLOSE : flags; -#ifndef HAVE_MKSTEMP - return gettemp(template, fp, flags, p); -#else - -#ifdef HAVE_MKSTEMP64 - fd = mkstemp64(template); -#else - fd = mkstemp(template); -#endif - - if (fd == -1) { - return errno; - } - /* XXX: We must reset several flags values as passed-in, since - * mkstemp didn't subscribe to our preference flags. - * - * We either have to unset the flags, or fix up the fd and other - * xthread and inherit bits appropriately. Since gettemp() above - * calls apr_file_open, our flags are respected in that code path. - */ - apr_os_file_put(fp, &fd, flags, p); - (*fp)->fname = apr_pstrdup(p, template); - - if (!(flags & APR_FOPEN_NOCLEANUP)) { - int flags; - - if ((flags = fcntl(fd, F_GETFD)) == -1) - return errno; - - flags |= FD_CLOEXEC; - if (fcntl(fd, F_SETFD, flags) == -1) - return errno; - - apr_pool_cleanup_register((*fp)->pool, (void *)(*fp), - apr_unix_file_cleanup, - apr_unix_child_file_cleanup); - } -#endif - return APR_SUCCESS; -} - diff --git a/libs/apr/file_io/unix/open.c b/libs/apr/file_io/unix/open.c deleted file mode 100644 index 6373ee5b..00000000 --- a/libs/apr/file_io/unix/open.c +++ /dev/null @@ -1,409 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_file_io.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_thread_mutex.h" -#include "apr_arch_inherit.h" - -#ifdef NETWARE -#include "nks/dirio.h" -#include "apr_hash.h" -#include "fsio.h" -#endif - -static apr_status_t file_cleanup(apr_file_t *file, int is_child) -{ - apr_status_t rv = APR_SUCCESS; - int fd = file->filedes; - - /* Set file descriptor to -1 before close(), so that there is no - * chance of returning an already closed FD from apr_os_file_get(). - */ - file->filedes = -1; - - if (close(fd) == 0) { - /* Only the parent process should delete the file! */ - if (!is_child && (file->flags & APR_FOPEN_DELONCLOSE)) { - unlink(file->fname); - } -#if APR_HAS_THREADS - if (file->thlock) { - rv = apr_thread_mutex_destroy(file->thlock); - } -#endif - } - else { - /* Restore, close() was not successful. */ - file->filedes = fd; - - /* Are there any error conditions other than EINTR or EBADF? */ - rv = errno; - } -#ifndef WAITIO_USES_POLL - if (file->pollset != NULL) { - apr_status_t pollset_rv = apr_pollset_destroy(file->pollset); - /* If the file close failed, return its error value, - * not apr_pollset_destroy()'s. - */ - if (rv == APR_SUCCESS) { - rv = pollset_rv; - } - } -#endif /* !WAITIO_USES_POLL */ - return rv; -} - -apr_status_t apr_unix_file_cleanup(void *thefile) -{ - apr_file_t *file = thefile; - apr_status_t flush_rv = APR_SUCCESS, rv = APR_SUCCESS; - - if (file->buffered) { - flush_rv = apr_file_flush(file); - } - - rv = file_cleanup(file, 0); - - return rv != APR_SUCCESS ? rv : flush_rv; -} - -apr_status_t apr_unix_child_file_cleanup(void *thefile) -{ - return file_cleanup(thefile, 1); -} - -APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, - const char *fname, - apr_int32_t flag, - apr_fileperms_t perm, - apr_pool_t *pool) -{ - apr_os_file_t fd; - int oflags = 0; -#if APR_HAS_THREADS - apr_thread_mutex_t *thlock; - apr_status_t rv; -#endif - - if ((flag & APR_FOPEN_READ) && (flag & APR_FOPEN_WRITE)) { - oflags = O_RDWR; - } - else if (flag & APR_FOPEN_READ) { - oflags = O_RDONLY; - } - else if (flag & APR_FOPEN_WRITE) { - oflags = O_WRONLY; - } - else { - return APR_EACCES; - } - - if (flag & APR_FOPEN_CREATE) { - oflags |= O_CREAT; - if (flag & APR_FOPEN_EXCL) { - oflags |= O_EXCL; - } - } - if ((flag & APR_FOPEN_EXCL) && !(flag & APR_FOPEN_CREATE)) { - return APR_EACCES; - } - - if (flag & APR_FOPEN_APPEND) { - oflags |= O_APPEND; - } - if (flag & APR_FOPEN_TRUNCATE) { - oflags |= O_TRUNC; - } -#ifdef O_BINARY - if (flag & APR_FOPEN_BINARY) { - oflags |= O_BINARY; - } -#endif - -#ifdef O_CLOEXEC - /* Introduced in Linux 2.6.23. Silently ignored on earlier Linux kernels. - */ - if (!(flag & APR_FOPEN_NOCLEANUP)) { - oflags |= O_CLOEXEC; -} -#endif - -#if APR_HAS_LARGE_FILES && defined(_LARGEFILE64_SOURCE) - oflags |= O_LARGEFILE; -#elif defined(O_LARGEFILE) - if (flag & APR_FOPEN_LARGEFILE) { - oflags |= O_LARGEFILE; - } -#endif - -#if APR_HAS_THREADS - if ((flag & APR_FOPEN_BUFFERED) && (flag & APR_FOPEN_XTHREAD)) { - rv = apr_thread_mutex_create(&thlock, - APR_THREAD_MUTEX_DEFAULT, pool); - if (rv) { - return rv; - } - } -#endif - - if (perm == APR_OS_DEFAULT) { - fd = open(fname, oflags, 0666); - } - else { - fd = open(fname, oflags, apr_unix_perms2mode(perm)); - } - if (fd < 0) { - return errno; - } - if (!(flag & APR_FOPEN_NOCLEANUP)) { -#ifdef O_CLOEXEC - static int has_o_cloexec = 0; - if (!has_o_cloexec) -#endif - { - int flags; - - if ((flags = fcntl(fd, F_GETFD)) == -1) { - close(fd); - return errno; - } - if ((flags & FD_CLOEXEC) == 0) { - flags |= FD_CLOEXEC; - if (fcntl(fd, F_SETFD, flags) == -1) { - close(fd); - return errno; - } - } -#ifdef O_CLOEXEC - else { - has_o_cloexec = 1; - } -#endif - } - } - - (*new) = (apr_file_t *)apr_pcalloc(pool, sizeof(apr_file_t)); - (*new)->pool = pool; - (*new)->flags = flag; - (*new)->filedes = fd; - - (*new)->fname = apr_pstrdup(pool, fname); - - (*new)->blocking = BLK_ON; - (*new)->buffered = (flag & APR_FOPEN_BUFFERED) > 0; - - if ((*new)->buffered) { - (*new)->buffer = apr_palloc(pool, APR_FILE_DEFAULT_BUFSIZE); - (*new)->bufsize = APR_FILE_DEFAULT_BUFSIZE; -#if APR_HAS_THREADS - if ((*new)->flags & APR_FOPEN_XTHREAD) { - (*new)->thlock = thlock; - } -#endif - } - else { - (*new)->buffer = NULL; - } - - (*new)->is_pipe = 0; - (*new)->timeout = -1; - (*new)->ungetchar = -1; - (*new)->eof_hit = 0; - (*new)->filePtr = 0; - (*new)->bufpos = 0; - (*new)->dataRead = 0; - (*new)->direction = 0; -#ifndef WAITIO_USES_POLL - /* Start out with no pollset. apr_wait_for_io_or_timeout() will - * initialize the pollset if needed. - */ - (*new)->pollset = NULL; -#endif - if (!(flag & APR_FOPEN_NOCLEANUP)) { - apr_pool_cleanup_register((*new)->pool, (void *)(*new), - apr_unix_file_cleanup, - apr_unix_child_file_cleanup); - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_close(apr_file_t *file) -{ - return apr_pool_cleanup_run(file->pool, file, apr_unix_file_cleanup); -} - -APR_DECLARE(apr_status_t) apr_file_remove(const char *path, apr_pool_t *pool) -{ - if (unlink(path) == 0) { - return APR_SUCCESS; - } - else { - return errno; - } -} - -APR_DECLARE(apr_status_t) apr_file_rename(const char *from_path, - const char *to_path, - apr_pool_t *p) -{ - if (rename(from_path, to_path) != 0) { - return errno; - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_file_get(apr_os_file_t *thefile, - apr_file_t *file) -{ - *thefile = file->filedes; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_file_put(apr_file_t **file, - apr_os_file_t *thefile, - apr_int32_t flags, apr_pool_t *pool) -{ - int *dafile = thefile; - - (*file) = apr_pcalloc(pool, sizeof(apr_file_t)); - (*file)->pool = pool; - (*file)->eof_hit = 0; - (*file)->blocking = BLK_UNKNOWN; /* in case it is a pipe */ - (*file)->timeout = -1; - (*file)->ungetchar = -1; /* no char avail */ - (*file)->filedes = *dafile; - (*file)->flags = flags | APR_FOPEN_NOCLEANUP; - (*file)->buffered = (flags & APR_FOPEN_BUFFERED) > 0; - -#ifndef WAITIO_USES_POLL - /* Start out with no pollset. apr_wait_for_io_or_timeout() will - * initialize the pollset if needed. - */ - (*file)->pollset = NULL; -#endif - - if ((*file)->buffered) { - (*file)->buffer = apr_palloc(pool, APR_FILE_DEFAULT_BUFSIZE); - (*file)->bufsize = APR_FILE_DEFAULT_BUFSIZE; -#if APR_HAS_THREADS - if ((*file)->flags & APR_FOPEN_XTHREAD) { - apr_status_t rv; - rv = apr_thread_mutex_create(&((*file)->thlock), - APR_THREAD_MUTEX_DEFAULT, pool); - if (rv) { - return rv; - } - } -#endif - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_eof(apr_file_t *fptr) -{ - if (fptr->eof_hit == 1) { - return APR_EOF; - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_open_flags_stderr(apr_file_t **thefile, - apr_int32_t flags, - apr_pool_t *pool) -{ - int fd = STDERR_FILENO; - - return apr_os_file_put(thefile, &fd, flags | APR_FOPEN_WRITE, pool); -} - -APR_DECLARE(apr_status_t) apr_file_open_flags_stdout(apr_file_t **thefile, - apr_int32_t flags, - apr_pool_t *pool) -{ - int fd = STDOUT_FILENO; - - return apr_os_file_put(thefile, &fd, flags | APR_FOPEN_WRITE, pool); -} - -APR_DECLARE(apr_status_t) apr_file_open_flags_stdin(apr_file_t **thefile, - apr_int32_t flags, - apr_pool_t *pool) -{ - int fd = STDIN_FILENO; - - return apr_os_file_put(thefile, &fd, flags | APR_FOPEN_READ, pool); -} - -APR_DECLARE(apr_status_t) apr_file_open_stderr(apr_file_t **thefile, - apr_pool_t *pool) -{ - return apr_file_open_flags_stderr(thefile, 0, pool); -} - -APR_DECLARE(apr_status_t) apr_file_open_stdout(apr_file_t **thefile, - apr_pool_t *pool) -{ - return apr_file_open_flags_stdout(thefile, 0, pool); -} - -APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile, - apr_pool_t *pool) -{ - return apr_file_open_flags_stdin(thefile, 0, pool); -} - -APR_IMPLEMENT_INHERIT_SET(file, flags, pool, apr_unix_file_cleanup) - -/* We need to do this by hand instead of using APR_IMPLEMENT_INHERIT_UNSET - * because the macro sets both cleanups to the same function, which is not - * suitable on Unix (see PR 41119). */ -APR_DECLARE(apr_status_t) apr_file_inherit_unset(apr_file_t *thefile) -{ - if (thefile->flags & APR_FOPEN_NOCLEANUP) { - return APR_EINVAL; - } - if (thefile->flags & APR_INHERIT) { - int flags; - - if ((flags = fcntl(thefile->filedes, F_GETFD)) == -1) - return errno; - - flags |= FD_CLOEXEC; - if (fcntl(thefile->filedes, F_SETFD, flags) == -1) - return errno; - - thefile->flags &= ~APR_INHERIT; - apr_pool_child_cleanup_set(thefile->pool, - (void *)thefile, - apr_unix_file_cleanup, - apr_unix_child_file_cleanup); - } - return APR_SUCCESS; -} - -APR_POOL_IMPLEMENT_ACCESSOR(file) - -APR_DECLARE(apr_status_t) apr_file_link(const char *from_path, - const char *to_path) -{ - if (link(from_path, to_path) == -1) { - return errno; - } - - return APR_SUCCESS; -} diff --git a/libs/apr/file_io/unix/pipe.c b/libs/apr/file_io/unix/pipe.c deleted file mode 100644 index 7b8f01fb..00000000 --- a/libs/apr/file_io/unix/pipe.c +++ /dev/null @@ -1,264 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_file_io.h" -#include "apr_strings.h" -#include "apr_portable.h" - -#include "apr_arch_inherit.h" - -/* Figure out how to get pipe block/nonblock on BeOS... - * Basically, BONE7 changed things again so that ioctl didn't work, - * but now fcntl does, hence we need to do this extra checking. - * The joys of beta programs. :-) - */ -#if BEOS -#if !BONE7 -# define BEOS_BLOCKING 1 -#else -# define BEOS_BLOCKING 0 -#endif -#endif - -static apr_status_t pipeblock(apr_file_t *thepipe) -{ -#if !BEOS_BLOCKING - int fd_flags; - - fd_flags = fcntl(thepipe->filedes, F_GETFL, 0); -# if defined(O_NONBLOCK) - fd_flags &= ~O_NONBLOCK; -# elif defined(O_NDELAY) - fd_flags &= ~O_NDELAY; -# elif defined(O_FNDELAY) - fd_flags &= ~O_FNDELAY; -# else - /* XXXX: this breaks things, but an alternative isn't obvious...*/ - return APR_ENOTIMPL; -# endif - if (fcntl(thepipe->filedes, F_SETFL, fd_flags) == -1) { - return errno; - } -#else /* BEOS_BLOCKING */ - -# if BEOS_BONE /* This only works on BONE 0-6 */ - int on = 0; - if (ioctl(thepipe->filedes, FIONBIO, &on, sizeof(on)) < 0) { - return errno; - } -# else /* "classic" BeOS doesn't support this at all */ - return APR_ENOTIMPL; -# endif - -#endif /* !BEOS_BLOCKING */ - - thepipe->blocking = BLK_ON; - return APR_SUCCESS; -} - -static apr_status_t pipenonblock(apr_file_t *thepipe) -{ -#if !BEOS_BLOCKING - int fd_flags = fcntl(thepipe->filedes, F_GETFL, 0); - -# if defined(O_NONBLOCK) - fd_flags |= O_NONBLOCK; -# elif defined(O_NDELAY) - fd_flags |= O_NDELAY; -# elif defined(O_FNDELAY) - fd_flags |= O_FNDELAY; -# else - /* XXXX: this breaks things, but an alternative isn't obvious...*/ - return APR_ENOTIMPL; -# endif - if (fcntl(thepipe->filedes, F_SETFL, fd_flags) == -1) { - return errno; - } - -#else /* BEOS_BLOCKING */ - -# if BEOS_BONE /* This only works on BONE 0-6 */ - int on = 1; - if (ioctl(thepipe->filedes, FIONBIO, &on, sizeof(on)) < 0) { - return errno; - } -# else /* "classic" BeOS doesn't support this at all */ - return APR_ENOTIMPL; -# endif - -#endif /* !BEOS_BLOCKING */ - - thepipe->blocking = BLK_OFF; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_pipe_timeout_set(apr_file_t *thepipe, apr_interval_time_t timeout) -{ - if (thepipe->is_pipe == 1) { - thepipe->timeout = timeout; - if (timeout >= 0) { - if (thepipe->blocking != BLK_OFF) { /* blocking or unknown state */ - return pipenonblock(thepipe); - } - } - else { - if (thepipe->blocking != BLK_ON) { /* non-blocking or unknown state */ - return pipeblock(thepipe); - } - } - return APR_SUCCESS; - } - return APR_EINVAL; -} - -APR_DECLARE(apr_status_t) apr_file_pipe_timeout_get(apr_file_t *thepipe, apr_interval_time_t *timeout) -{ - if (thepipe->is_pipe == 1) { - *timeout = thepipe->timeout; - return APR_SUCCESS; - } - return APR_EINVAL; -} - -APR_DECLARE(apr_status_t) apr_os_pipe_put_ex(apr_file_t **file, - apr_os_file_t *thefile, - int register_cleanup, - apr_pool_t *pool) -{ - int *dafile = thefile; - - (*file) = apr_pcalloc(pool, sizeof(apr_file_t)); - (*file)->pool = pool; - (*file)->eof_hit = 0; - (*file)->is_pipe = 1; - (*file)->blocking = BLK_UNKNOWN; /* app needs to make a timeout call */ - (*file)->timeout = -1; - (*file)->ungetchar = -1; /* no char avail */ - (*file)->filedes = *dafile; - if (!register_cleanup) { - (*file)->flags = APR_FOPEN_NOCLEANUP; - } - (*file)->buffered = 0; -#if APR_HAS_THREADS - (*file)->thlock = NULL; -#endif - if (register_cleanup) { - apr_pool_cleanup_register((*file)->pool, (void *)(*file), - apr_unix_file_cleanup, - apr_pool_cleanup_null); - } -#ifndef WAITIO_USES_POLL - /* Start out with no pollset. apr_wait_for_io_or_timeout() will - * initialize the pollset if needed. - */ - (*file)->pollset = NULL; -#endif - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_pipe_put(apr_file_t **file, - apr_os_file_t *thefile, - apr_pool_t *pool) -{ - return apr_os_pipe_put_ex(file, thefile, 0, pool); -} - -APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, apr_file_t **out, apr_pool_t *pool) -{ - int filedes[2]; - - if (pipe(filedes) == -1) { - return errno; - } - - (*in) = (apr_file_t *)apr_pcalloc(pool, sizeof(apr_file_t)); - (*in)->pool = pool; - (*in)->filedes = filedes[0]; - (*in)->is_pipe = 1; - (*in)->fname = NULL; - (*in)->buffered = 0; - (*in)->blocking = BLK_ON; - (*in)->timeout = -1; - (*in)->ungetchar = -1; - (*in)->flags = APR_INHERIT; -#if APR_HAS_THREADS - (*in)->thlock = NULL; -#endif -#ifndef WAITIO_USES_POLL - (*in)->pollset = NULL; -#endif - (*out) = (apr_file_t *)apr_pcalloc(pool, sizeof(apr_file_t)); - (*out)->pool = pool; - (*out)->filedes = filedes[1]; - (*out)->is_pipe = 1; - (*out)->fname = NULL; - (*out)->buffered = 0; - (*out)->blocking = BLK_ON; - (*out)->flags = APR_INHERIT; - (*out)->timeout = -1; -#if APR_HAS_THREADS - (*out)->thlock = NULL; -#endif -#ifndef WAITIO_USES_POLL - (*out)->pollset = NULL; -#endif - apr_pool_cleanup_register((*in)->pool, (void *)(*in), apr_unix_file_cleanup, - apr_pool_cleanup_null); - apr_pool_cleanup_register((*out)->pool, (void *)(*out), apr_unix_file_cleanup, - apr_pool_cleanup_null); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_pipe_create_ex(apr_file_t **in, - apr_file_t **out, - apr_int32_t blocking, - apr_pool_t *pool) -{ - apr_status_t status; - - if ((status = apr_file_pipe_create(in, out, pool)) != APR_SUCCESS) - return status; - - switch (blocking) { - case APR_FULL_BLOCK: - break; - case APR_READ_BLOCK: - apr_file_pipe_timeout_set(*out, 0); - break; - case APR_WRITE_BLOCK: - apr_file_pipe_timeout_set(*in, 0); - break; - default: - apr_file_pipe_timeout_set(*out, 0); - apr_file_pipe_timeout_set(*in, 0); - } - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_namedpipe_create(const char *filename, - apr_fileperms_t perm, apr_pool_t *pool) -{ - mode_t mode = apr_unix_perms2mode(perm); - - if (mkfifo(filename, mode) == -1) { - return errno; - } - return APR_SUCCESS; -} - - - diff --git a/libs/apr/file_io/unix/readwrite.c b/libs/apr/file_io/unix/readwrite.c deleted file mode 100644 index 4b3e7368..00000000 --- a/libs/apr/file_io/unix/readwrite.c +++ /dev/null @@ -1,526 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_file_io.h" -#include "apr_strings.h" -#include "apr_thread_mutex.h" -#include "apr_support.h" - -/* The only case where we don't use wait_for_io_or_timeout is on - * pre-BONE BeOS, so this check should be sufficient and simpler */ -#if !BEOS_R5 -#define USE_WAIT_FOR_IO -#endif - -static apr_status_t file_read_buffered(apr_file_t *thefile, void *buf, - apr_size_t *nbytes) -{ - apr_ssize_t rv; - char *pos = (char *)buf; - apr_uint64_t blocksize; - apr_uint64_t size = *nbytes; - - if (thefile->direction == 1) { - rv = apr_file_flush_locked(thefile); - if (rv) { - return rv; - } - thefile->bufpos = 0; - thefile->direction = 0; - thefile->dataRead = 0; - } - - rv = 0; - if (thefile->ungetchar != -1) { - *pos = (char)thefile->ungetchar; - ++pos; - --size; - thefile->ungetchar = -1; - } - while (rv == 0 && size > 0) { - if (thefile->bufpos >= thefile->dataRead) { - int bytesread = read(thefile->filedes, thefile->buffer, - thefile->bufsize); - if (bytesread == 0) { - thefile->eof_hit = TRUE; - rv = APR_EOF; - break; - } - else if (bytesread == -1) { - rv = errno; - break; - } - thefile->dataRead = bytesread; - thefile->filePtr += thefile->dataRead; - thefile->bufpos = 0; - } - - blocksize = size > thefile->dataRead - thefile->bufpos ? thefile->dataRead - thefile->bufpos : size; - memcpy(pos, thefile->buffer + thefile->bufpos, blocksize); - thefile->bufpos += blocksize; - pos += blocksize; - size -= blocksize; - } - - *nbytes = pos - (char *)buf; - if (*nbytes) { - rv = 0; - } - return rv; -} - -APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size_t *nbytes) -{ - apr_ssize_t rv; - apr_size_t bytes_read; - - if (*nbytes <= 0) { - *nbytes = 0; - return APR_SUCCESS; - } - - if (thefile->buffered) { - file_lock(thefile); - rv = file_read_buffered(thefile, buf, nbytes); - file_unlock(thefile); - return rv; - } - else { - bytes_read = 0; - if (thefile->ungetchar != -1) { - bytes_read = 1; - *(char *)buf = (char)thefile->ungetchar; - buf = (char *)buf + 1; - (*nbytes)--; - thefile->ungetchar = -1; - if (*nbytes == 0) { - *nbytes = bytes_read; - return APR_SUCCESS; - } - } - - do { - rv = read(thefile->filedes, buf, *nbytes); - } while (rv == -1 && errno == EINTR); -#ifdef USE_WAIT_FOR_IO - if (rv == -1 && - (errno == EAGAIN || errno == EWOULDBLOCK) && - thefile->timeout != 0) { - apr_status_t arv = apr_wait_for_io_or_timeout(thefile, NULL, 1); - if (arv != APR_SUCCESS) { - *nbytes = bytes_read; - return arv; - } - else { - do { - rv = read(thefile->filedes, buf, *nbytes); - } while (rv == -1 && errno == EINTR); - } - } -#endif - *nbytes = bytes_read; - if (rv == 0) { - thefile->eof_hit = TRUE; - return APR_EOF; - } - if (rv > 0) { - *nbytes += rv; - return APR_SUCCESS; - } - return errno; - } -} - -APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, apr_size_t *nbytes) -{ - apr_size_t rv; - - if (thefile->buffered) { - char *pos = (char *)buf; - int blocksize; - int size = *nbytes; - - file_lock(thefile); - - if ( thefile->direction == 0 ) { - /* Position file pointer for writing at the offset we are - * logically reading from - */ - apr_int64_t offset = thefile->filePtr - thefile->dataRead + thefile->bufpos; - if (offset != thefile->filePtr) - lseek(thefile->filedes, offset, SEEK_SET); - thefile->bufpos = thefile->dataRead = 0; - thefile->direction = 1; - } - - rv = 0; - while (rv == 0 && size > 0) { - if (thefile->bufpos == thefile->bufsize) /* write buffer is full*/ - rv = apr_file_flush_locked(thefile); - - blocksize = size > thefile->bufsize - thefile->bufpos ? - thefile->bufsize - thefile->bufpos : size; - memcpy(thefile->buffer + thefile->bufpos, pos, blocksize); - thefile->bufpos += blocksize; - pos += blocksize; - size -= blocksize; - } - - file_unlock(thefile); - - return rv; - } - else { - do { - rv = write(thefile->filedes, buf, *nbytes); - } while (rv == (apr_size_t)-1 && errno == EINTR); -#ifdef USE_WAIT_FOR_IO - if (rv == (apr_size_t)-1 && - (errno == EAGAIN || errno == EWOULDBLOCK) && - thefile->timeout != 0) { - apr_status_t arv = apr_wait_for_io_or_timeout(thefile, NULL, 0); - if (arv != APR_SUCCESS) { - *nbytes = 0; - return arv; - } - else { - do { - do { - rv = write(thefile->filedes, buf, *nbytes); - } while (rv == (apr_size_t)-1 && errno == EINTR); - if (rv == (apr_size_t)-1 && - (errno == EAGAIN || errno == EWOULDBLOCK)) { - *nbytes /= 2; /* yes, we'll loop if kernel lied - * and we can't even write 1 byte - */ - } - else { - break; - } - } while (1); - } - } -#endif - if (rv == (apr_size_t)-1) { - (*nbytes) = 0; - return errno; - } - *nbytes = rv; - return APR_SUCCESS; - } -} - -APR_DECLARE(apr_status_t) apr_file_writev(apr_file_t *thefile, const struct iovec *vec, - apr_size_t nvec, apr_size_t *nbytes) -{ -#ifdef HAVE_WRITEV - apr_status_t rv; - apr_ssize_t bytes; - - if (thefile->buffered) { - file_lock(thefile); - - rv = apr_file_flush_locked(thefile); - if (rv != APR_SUCCESS) { - file_unlock(thefile); - return rv; - } - if (thefile->direction == 0) { - /* Position file pointer for writing at the offset we are - * logically reading from - */ - apr_int64_t offset = thefile->filePtr - thefile->dataRead + - thefile->bufpos; - if (offset != thefile->filePtr) - lseek(thefile->filedes, offset, SEEK_SET); - thefile->bufpos = thefile->dataRead = 0; - } - - file_unlock(thefile); - } - - if ((bytes = writev(thefile->filedes, vec, nvec)) < 0) { - *nbytes = 0; - rv = errno; - } - else { - *nbytes = bytes; - rv = APR_SUCCESS; - } - return rv; -#else - /** - * The problem with trying to output the entire iovec is that we cannot - * maintain the behaviour that a real writev would have. If we iterate - * over the iovec one at a time, we lose the atomic properties of - * writev(). The other option is to combine the entire iovec into one - * buffer that we could then send in one call to write(). This is not - * reasonable since we do not know how much data an iovec could contain. - * - * The only reasonable option, that maintains the semantics of a real - * writev(), is to only write the first iovec. Callers of file_writev() - * must deal with partial writes as they normally would. If you want to - * ensure an entire iovec is written, use apr_file_writev_full(). - */ - - *nbytes = vec[0].iov_len; - return apr_file_write(thefile, vec[0].iov_base, nbytes); -#endif -} - -APR_DECLARE(apr_status_t) apr_file_putc(char ch, apr_file_t *thefile) -{ - apr_size_t nbytes = 1; - - return apr_file_write(thefile, &ch, &nbytes); -} - -APR_DECLARE(apr_status_t) apr_file_ungetc(char ch, apr_file_t *thefile) -{ - thefile->ungetchar = (unsigned char)ch; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_getc(char *ch, apr_file_t *thefile) -{ - apr_size_t nbytes = 1; - - return apr_file_read(thefile, ch, &nbytes); -} - -APR_DECLARE(apr_status_t) apr_file_puts(const char *str, apr_file_t *thefile) -{ - return apr_file_write_full(thefile, str, strlen(str), NULL); -} - -apr_status_t apr_file_flush_locked(apr_file_t *thefile) -{ - apr_status_t rv = APR_SUCCESS; - - if (thefile->direction == 1 && thefile->bufpos) { - apr_ssize_t written = 0, ret; - - do { - ret = write(thefile->filedes, thefile->buffer + written, - thefile->bufpos - written); - if (ret > 0) - written += ret; - } while (written < thefile->bufpos && - (ret > 0 || (ret == -1 && errno == EINTR))); - if (ret == -1) { - rv = errno; - } else { - thefile->filePtr += written; - thefile->bufpos = 0; - } - } - - return rv; -} - -APR_DECLARE(apr_status_t) apr_file_flush(apr_file_t *thefile) -{ - apr_status_t rv = APR_SUCCESS; - - if (thefile->buffered) { - file_lock(thefile); - rv = apr_file_flush_locked(thefile); - file_unlock(thefile); - } - /* There isn't anything to do if we aren't buffering the output - * so just return success. - */ - return rv; -} - -APR_DECLARE(apr_status_t) apr_file_sync(apr_file_t *thefile) -{ - apr_status_t rv = APR_SUCCESS; - - file_lock(thefile); - - if (thefile->buffered) { - rv = apr_file_flush_locked(thefile); - - if (rv != APR_SUCCESS) { - file_unlock(thefile); - return rv; - } - } - - if (fsync(thefile->filedes)) { - rv = apr_get_os_error(); - } - - file_unlock(thefile); - - return rv; -} - -APR_DECLARE(apr_status_t) apr_file_datasync(apr_file_t *thefile) -{ - apr_status_t rv = APR_SUCCESS; - - file_lock(thefile); - - if (thefile->buffered) { - rv = apr_file_flush_locked(thefile); - - if (rv != APR_SUCCESS) { - file_unlock(thefile); - return rv; - } - } - -#ifdef HAVE_FDATASYNC - if (fdatasync(thefile->filedes)) { -#else - if (fsync(thefile->filedes)) { -#endif - rv = apr_get_os_error(); - } - - file_unlock(thefile); - - return rv; -} - -APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, apr_file_t *thefile) -{ - apr_status_t rv = APR_SUCCESS; /* get rid of gcc warning */ - apr_size_t nbytes; - const char *str_start = str; - char *final = str + len - 1; - - if (len <= 1) { - /* sort of like fgets(), which returns NULL and stores no bytes - */ - return APR_SUCCESS; - } - - /* If we have an underlying buffer, we can be *much* more efficient - * and skip over the apr_file_read calls. - */ - if (thefile->buffered) { - file_lock(thefile); - - if (thefile->direction == 1) { - rv = apr_file_flush_locked(thefile); - if (rv) { - file_unlock(thefile); - return rv; - } - - thefile->direction = 0; - thefile->bufpos = 0; - thefile->dataRead = 0; - } - - while (str < final) { /* leave room for trailing '\0' */ - /* Force ungetc leftover to call apr_file_read. */ - if (thefile->bufpos < thefile->dataRead && - thefile->ungetchar == -1) { - *str = thefile->buffer[thefile->bufpos++]; - } - else { - nbytes = 1; - rv = file_read_buffered(thefile, str, &nbytes); - if (rv != APR_SUCCESS) { - break; - } - } - if (*str == '\n') { - ++str; - break; - } - ++str; - } - file_unlock(thefile); - } - else { - while (str < final) { /* leave room for trailing '\0' */ - nbytes = 1; - rv = apr_file_read(thefile, str, &nbytes); - if (rv != APR_SUCCESS) { - break; - } - if (*str == '\n') { - ++str; - break; - } - ++str; - } - } - - /* We must store a terminating '\0' if we've stored any chars. We can - * get away with storing it if we hit an error first. - */ - *str = '\0'; - if (str > str_start) { - /* we stored chars; don't report EOF or any other errors; - * the app will find out about that on the next call - */ - return APR_SUCCESS; - } - return rv; -} - -struct apr_file_printf_data { - apr_vformatter_buff_t vbuff; - apr_file_t *fptr; - char *buf; -}; - -static int file_printf_flush(apr_vformatter_buff_t *buff) -{ - struct apr_file_printf_data *data = (struct apr_file_printf_data *)buff; - - if (apr_file_write_full(data->fptr, data->buf, - data->vbuff.curpos - data->buf, NULL)) { - return -1; - } - - data->vbuff.curpos = data->buf; - return 0; -} - -APR_DECLARE_NONSTD(int) apr_file_printf(apr_file_t *fptr, - const char *format, ...) -{ - struct apr_file_printf_data data; - va_list ap; - int count; - - /* don't really need a HUGE_STRING_LEN anymore */ - data.buf = malloc(HUGE_STRING_LEN); - if (data.buf == NULL) { - return -1; - } - data.vbuff.curpos = data.buf; - data.vbuff.endpos = data.buf + HUGE_STRING_LEN; - data.fptr = fptr; - va_start(ap, format); - count = apr_vformatter(file_printf_flush, - (apr_vformatter_buff_t *)&data, format, ap); - /* apr_vformatter does not call flush for the last bits */ - if (count >= 0) file_printf_flush((apr_vformatter_buff_t *)&data); - - va_end(ap); - - free(data.buf); - - return count; -} diff --git a/libs/apr/file_io/unix/seek.c b/libs/apr/file_io/unix/seek.c deleted file mode 100644 index e70805d7..00000000 --- a/libs/apr/file_io/unix/seek.c +++ /dev/null @@ -1,129 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_file_io.h" - -static apr_status_t setptr(apr_file_t *thefile, apr_off_t pos ) -{ - apr_off_t newbufpos; - apr_status_t rv; - - if (thefile->direction == 1) { - rv = apr_file_flush_locked(thefile); - if (rv) { - return rv; - } - thefile->bufpos = thefile->direction = thefile->dataRead = 0; - } - - newbufpos = pos - (thefile->filePtr - thefile->dataRead); - if (newbufpos >= 0 && newbufpos <= thefile->dataRead) { - thefile->bufpos = newbufpos; - rv = APR_SUCCESS; - } - else { - if (lseek(thefile->filedes, pos, SEEK_SET) != -1) { - thefile->bufpos = thefile->dataRead = 0; - thefile->filePtr = pos; - rv = APR_SUCCESS; - } - else { - rv = errno; - } - } - - return rv; -} - - -APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile, apr_seek_where_t where, apr_off_t *offset) -{ - apr_off_t rv; - - thefile->eof_hit = 0; - - if (thefile->buffered) { - int rc = EINVAL; - apr_finfo_t finfo; - - file_lock(thefile); - - switch (where) { - case APR_SET: - rc = setptr(thefile, *offset); - break; - - case APR_CUR: - rc = setptr(thefile, thefile->filePtr - thefile->dataRead + thefile->bufpos + *offset); - break; - - case APR_END: - rc = apr_file_info_get_locked(&finfo, APR_FINFO_SIZE, thefile); - if (rc == APR_SUCCESS) - rc = setptr(thefile, finfo.size + *offset); - break; - } - - *offset = thefile->filePtr - thefile->dataRead + thefile->bufpos; - - file_unlock(thefile); - - return rc; - } - else { - rv = lseek(thefile->filedes, *offset, where); - if (rv == -1) { - *offset = -1; - return errno; - } - else { - *offset = rv; - return APR_SUCCESS; - } - } -} - -apr_status_t apr_file_trunc(apr_file_t *fp, apr_off_t offset) -{ - if (fp->buffered) { - int rc = 0; - file_lock(fp); - if (fp->direction == 1 && fp->bufpos != 0) { - apr_off_t len = fp->filePtr + fp->bufpos; - if (offset < len) { - /* New file end fall below our write buffer limit. - * Figure out if and what needs to be flushed. - */ - apr_off_t off = len - offset; - if (off >= 0 && off <= fp->bufpos) - fp->bufpos = fp->bufpos - (size_t)off; - else - fp->bufpos = 0; - } - rc = apr_file_flush_locked(fp); - /* Reset buffer positions for write mode */ - fp->bufpos = fp->direction = fp->dataRead = 0; - } - if (rc) { - return rc; - } - file_unlock(fp); - } - if (ftruncate(fp->filedes, offset) == -1) { - return errno; - } - return apr_file_seek(fp, APR_SET, &offset); -} diff --git a/libs/apr/file_io/unix/tempdir.c b/libs/apr/file_io/unix/tempdir.c deleted file mode 100644 index 22325eff..00000000 --- a/libs/apr/file_io/unix/tempdir.c +++ /dev/null @@ -1,129 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "apr_private.h" -#include "apr_file_io.h" -#include "apr_strings.h" -#include "apr_env.h" - - -/* Try to open a temporary file in the temporary dir, write to it, - and then close it. */ -static int test_tempdir(const char *temp_dir, apr_pool_t *p) -{ - apr_file_t *dummy_file; - char *path = apr_pstrcat(p, temp_dir, "/apr-tmp.XXXXXX", NULL); - - if (apr_file_mktemp(&dummy_file, path, 0, p) == APR_SUCCESS) { - if (apr_file_putc('!', dummy_file) == APR_SUCCESS) { - if (apr_file_close(dummy_file) == APR_SUCCESS) { - return 1; - } - } - } - return 0; -} - - -APR_DECLARE(apr_status_t) apr_temp_dir_get(const char **temp_dir, - apr_pool_t *p) -{ - apr_status_t apr_err; - const char *try_dirs[] = { "/tmp", "/usr/tmp", "/var/tmp" }; - const char *try_envs[] = { "TMPDIR", "TMP", "TEMP"}; - const char *dir; - char *cwd; - int i; - - /* Our goal is to find a temporary directory suitable for writing - into. - Here's the order in which we'll try various paths: - - $TMPDIR - $TMP - $TEMP - "C:\TEMP" (windows only) - "SYS:\TMP" (netware only) - "/tmp" - "/var/tmp" - "/usr/tmp" - P_tmpdir (POSIX define) - `pwd` - - NOTE: This algorithm is basically the same one used by Python - 2.2's tempfile.py module. */ - - /* Try the environment first. */ - for (i = 0; i < (sizeof(try_envs) / sizeof(const char *)); i++) { - char *value; - apr_err = apr_env_get(&value, try_envs[i], p); - if ((apr_err == APR_SUCCESS) && value) { - apr_size_t len = strlen(value); - if (len && (len < APR_PATH_MAX) && test_tempdir(value, p)) { - dir = value; - goto end; - } - } - } - -#ifdef WIN32 - /* Next, on Win32, try the C:\TEMP directory. */ - if (test_tempdir("C:\\TEMP", p)) { - dir = "C:\\TEMP"; - goto end; - } -#endif -#ifdef NETWARE - /* Next, on NetWare, try the SYS:/TMP directory. */ - if (test_tempdir("SYS:/TMP", p)) { - dir = "SYS:/TMP"; - goto end; - } -#endif - - /* Next, try a set of hard-coded paths. */ - for (i = 0; i < (sizeof(try_dirs) / sizeof(const char *)); i++) { - if (test_tempdir(try_dirs[i], p)) { - dir = try_dirs[i]; - goto end; - } - } - -#ifdef P_tmpdir - /* - * If we have it, use the POSIX definition of where - * the tmpdir should be - */ - if (test_tempdir(P_tmpdir, p)) { - dir = P_tmpdir; - goto end; - } -#endif - - /* Finally, try the current working directory. */ - if (APR_SUCCESS == apr_filepath_get(&cwd, APR_FILEPATH_NATIVE, p)) { - if (test_tempdir(cwd, p)) { - dir = cwd; - goto end; - } - } - - /* We didn't find a suitable temp dir anywhere */ - return APR_EGENERAL; - -end: - *temp_dir = apr_pstrdup(p, dir); - return APR_SUCCESS; -} diff --git a/libs/apr/file_io/win32/buffer.c b/libs/apr/file_io/win32/buffer.c deleted file mode 100644 index 34e4e639..00000000 --- a/libs/apr/file_io/win32/buffer.c +++ /dev/null @@ -1,59 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_file_io.h" -#include "apr_thread_mutex.h" - -APR_DECLARE(apr_status_t) apr_file_buffer_set(apr_file_t *file, - char * buffer, - apr_size_t bufsize) -{ - apr_status_t rv; - - apr_thread_mutex_lock(file->mutex); - - if(file->buffered) { - /* Flush the existing buffer */ - rv = apr_file_flush(file); - if (rv != APR_SUCCESS) { - apr_thread_mutex_unlock(file->mutex); - return rv; - } - } - - file->buffer = buffer; - file->bufsize = bufsize; - file->buffered = 1; - file->bufpos = 0; - file->direction = 0; - file->dataRead = 0; - - if (file->bufsize == 0) { - /* Setting the buffer size to zero is equivalent to turning - * buffering off. - */ - file->buffered = 0; - } - - apr_thread_mutex_unlock(file->mutex); - - return APR_SUCCESS; -} - -APR_DECLARE(apr_size_t) apr_file_buffer_size_get(apr_file_t *file) -{ - return file->bufsize; -} diff --git a/libs/apr/file_io/win32/dir.c b/libs/apr/file_io/win32/dir.c deleted file mode 100644 index f6eeb872..00000000 --- a/libs/apr/file_io/win32/dir.c +++ /dev/null @@ -1,401 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_arch_atime.h" - -#if APR_HAVE_ERRNO_H -#include -#endif -#if APR_HAVE_STRING_H -#include -#endif -#if APR_HAVE_DIRENT_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif - - -static apr_status_t dir_cleanup(void *thedir) -{ - apr_dir_t *dir = thedir; - if (dir->dirhand != INVALID_HANDLE_VALUE && !FindClose(dir->dirhand)) { - return apr_get_os_error(); - } - dir->dirhand = INVALID_HANDLE_VALUE; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_dir_open(apr_dir_t **new, const char *dirname, - apr_pool_t *pool) -{ - apr_status_t rv; - - apr_size_t len = strlen(dirname); - (*new) = apr_pcalloc(pool, sizeof(apr_dir_t)); - /* Leave room here to add and pop the '*' wildcard for FindFirstFile - * and double-null terminate so we have one character to change. - */ - (*new)->dirname = apr_palloc(pool, len + 3); - memcpy((*new)->dirname, dirname, len); - if (len && (*new)->dirname[len - 1] != '/') { - (*new)->dirname[len++] = '/'; - } - (*new)->dirname[len++] = '\0'; - (*new)->dirname[len] = '\0'; - -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - /* Create a buffer for the longest file name we will ever see - */ - (*new)->w.entry = apr_pcalloc(pool, sizeof(WIN32_FIND_DATAW)); - (*new)->name = apr_pcalloc(pool, APR_FILE_MAX * 3 + 1); - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - /* Note that we won't open a directory that is greater than MAX_PATH, - * counting the additional '/' '*' wildcard suffix. If a * won't fit - * then neither will any other file name within the directory. - * The length not including the trailing '*' is stored as rootlen, to - * skip over all paths which are too long. - */ - if (len >= APR_PATH_MAX) { - (*new) = NULL; - return APR_ENAMETOOLONG; - } - (*new)->n.entry = apr_pcalloc(pool, sizeof(WIN32_FIND_DATAW)); - } -#endif - (*new)->rootlen = len - 1; - (*new)->pool = pool; - (*new)->dirhand = INVALID_HANDLE_VALUE; - apr_pool_cleanup_register((*new)->pool, (void *)(*new), dir_cleanup, - apr_pool_cleanup_null); - - rv = apr_dir_read(NULL, 0, *new); - if (rv != APR_SUCCESS) { - dir_cleanup(*new); - *new = NULL; - } - - return rv; -} - -APR_DECLARE(apr_status_t) apr_dir_close(apr_dir_t *dir) -{ - apr_pool_cleanup_kill(dir->pool, dir, dir_cleanup); - return dir_cleanup(dir); -} - -APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, - apr_dir_t *thedir) -{ - apr_status_t rv; - char *fname; - /* The while loops below allow us to skip all invalid file names, so that - * we aren't reporting any files where their absolute paths are too long. - */ -#if APR_HAS_UNICODE_FS - apr_wchar_t wdirname[APR_PATH_MAX]; - apr_wchar_t *eos = NULL; - IF_WIN_OS_IS_UNICODE - { - /* This code path is always be invoked by apr_dir_open or - * apr_dir_rewind, so return without filling out the finfo. - */ - if (thedir->dirhand == INVALID_HANDLE_VALUE) - { - apr_status_t rv; - if ((rv = utf8_to_unicode_path(wdirname, sizeof(wdirname) - / sizeof(apr_wchar_t), - thedir->dirname))) { - return rv; - } - eos = wcschr(wdirname, '\0'); - eos[0] = '*'; - eos[1] = '\0'; - thedir->dirhand = FindFirstFileW(wdirname, thedir->w.entry); - eos[0] = '\0'; - if (thedir->dirhand == INVALID_HANDLE_VALUE) { - return apr_get_os_error(); - } - thedir->bof = 1; - return APR_SUCCESS; - } - else if (thedir->bof) { - /* Noop - we already called FindFirstFileW from - * either apr_dir_open or apr_dir_rewind ... use - * that first record. - */ - thedir->bof = 0; - } - else if (!FindNextFileW(thedir->dirhand, thedir->w.entry)) { - return apr_get_os_error(); - } - - while (thedir->rootlen && - thedir->rootlen + wcslen(thedir->w.entry->cFileName) >= APR_PATH_MAX) - { - if (!FindNextFileW(thedir->dirhand, thedir->w.entry)) { - return apr_get_os_error(); - } - } - if ((rv = unicode_to_utf8_path(thedir->name, APR_FILE_MAX * 3 + 1, - thedir->w.entry->cFileName))) - return rv; - fname = thedir->name; - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - /* This code path is always be invoked by apr_dir_open or - * apr_dir_rewind, so return without filling out the finfo. - */ - if (thedir->dirhand == INVALID_HANDLE_VALUE) { - /* '/' terminated, so add the '*' and pop it when we finish */ - char *eop = strchr(thedir->dirname, '\0'); - eop[0] = '*'; - eop[1] = '\0'; - thedir->dirhand = FindFirstFileA(thedir->dirname, - thedir->n.entry); - eop[0] = '\0'; - if (thedir->dirhand == INVALID_HANDLE_VALUE) { - return apr_get_os_error(); - } - thedir->bof = 1; - return APR_SUCCESS; - } - else if (thedir->bof) { - /* Noop - we already called FindFirstFileW from - * either apr_dir_open or apr_dir_rewind ... use - * that first record. - */ - thedir->bof = 0; - } - else if (!FindNextFileA(thedir->dirhand, thedir->n.entry)) { - return apr_get_os_error(); - } - while (thedir->rootlen && - thedir->rootlen + strlen(thedir->n.entry->cFileName) >= MAX_PATH) - { - if (!FindNextFileA(thedir->dirhand, thedir->n.entry)) { - return apr_get_os_error(); - } - } - fname = thedir->n.entry->cFileName; - } -#endif - - fillin_fileinfo(finfo, (WIN32_FILE_ATTRIBUTE_DATA *) thedir->w.entry, - 0, wanted); - finfo->pool = thedir->pool; - - finfo->valid |= APR_FINFO_NAME; - finfo->name = fname; - - if (wanted &= ~finfo->valid) { - /* Go back and get more_info if we can't answer the whole inquiry - */ -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - /* Almost all our work is done. Tack on the wide file name - * to the end of the wdirname (already / delimited) - */ - if (!eos) - eos = wcschr(wdirname, '\0'); - wcscpy(eos, thedir->w.entry->cFileName); - rv = more_finfo(finfo, wdirname, wanted, MORE_OF_WFSPEC); - eos[0] = '\0'; - return rv; - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { -#if APR_HAS_UNICODE_FS - /* Don't waste stack space on a second buffer, the one we set - * aside for the wide directory name is twice what we need. - */ - char *fspec = (char*)wdirname; -#else - char fspec[APR_PATH_MAX]; -#endif - apr_size_t dirlen = strlen(thedir->dirname); - if (dirlen >= sizeof(fspec)) - dirlen = sizeof(fspec) - 1; - apr_cpystrn(fspec, thedir->dirname, sizeof(fspec)); - apr_cpystrn(fspec + dirlen, fname, sizeof(fspec) - dirlen); - return more_finfo(finfo, fspec, wanted, MORE_OF_FSPEC); - } -#endif - } - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_dir_rewind(apr_dir_t *dir) -{ - apr_status_t rv; - - /* this will mark the handle as invalid and we'll open it - * again if apr_dir_read() is subsequently called - */ - rv = dir_cleanup(dir); - - if (rv == APR_SUCCESS) - rv = apr_dir_read(NULL, 0, dir); - - return rv; -} - -APR_DECLARE(apr_status_t) apr_dir_make(const char *path, apr_fileperms_t perm, - apr_pool_t *pool) -{ -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - apr_wchar_t wpath[APR_PATH_MAX]; - apr_status_t rv; - if ((rv = utf8_to_unicode_path(wpath, - sizeof(wpath) / sizeof(apr_wchar_t), - path))) { - return rv; - } - if (!CreateDirectoryW(wpath, NULL)) { - return apr_get_os_error(); - } - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - if (!CreateDirectory(path, NULL)) { - return apr_get_os_error(); - } -#endif - return APR_SUCCESS; -} - - -static apr_status_t dir_make_parent(char *path, - apr_fileperms_t perm, - apr_pool_t *pool) -{ - apr_status_t rv; - char *ch = strrchr(path, '\\'); - if (!ch) { - return APR_ENOENT; - } - - *ch = '\0'; - rv = apr_dir_make (path, perm, pool); /* Try to make straight off */ - - if (APR_STATUS_IS_ENOENT(rv)) { /* Missing an intermediate dir */ - rv = dir_make_parent(path, perm, pool); - - if (rv == APR_SUCCESS) { - rv = apr_dir_make (path, perm, pool); /* And complete the path */ - } - } - - *ch = '\\'; /* Always replace the slash before returning */ - return rv; -} - -APR_DECLARE(apr_status_t) apr_dir_make_recursive(const char *path, - apr_fileperms_t perm, - apr_pool_t *pool) -{ - apr_status_t rv = 0; - - rv = apr_dir_make (path, perm, pool); /* Try to make PATH right out */ - - if (APR_STATUS_IS_ENOENT(rv)) { /* Missing an intermediate dir */ - char *dir; - - rv = apr_filepath_merge(&dir, "", path, APR_FILEPATH_NATIVE, pool); - - if (rv == APR_SUCCESS) - rv = dir_make_parent(dir, perm, pool); /* Make intermediate dirs */ - - if (rv == APR_SUCCESS) - rv = apr_dir_make (dir, perm, pool); /* And complete the path */ - } - - /* - * It's OK if PATH exists. Timing issues can lead to the second - * apr_dir_make being called on existing dir, therefore this check - * has to come last. - */ - if (APR_STATUS_IS_EEXIST(rv)) - return APR_SUCCESS; - - return rv; -} - - -APR_DECLARE(apr_status_t) apr_dir_remove(const char *path, apr_pool_t *pool) -{ -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - apr_wchar_t wpath[APR_PATH_MAX]; - apr_status_t rv; - if ((rv = utf8_to_unicode_path(wpath, - sizeof(wpath) / sizeof(apr_wchar_t), - path))) { - return rv; - } - if (!RemoveDirectoryW(wpath)) { - return apr_get_os_error(); - } - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - if (!RemoveDirectory(path)) { - return apr_get_os_error(); - } -#endif - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_dir_get(apr_os_dir_t **thedir, - apr_dir_t *dir) -{ - if (dir == NULL) { - return APR_ENODIR; - } - *thedir = dir->dirhand; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_dir_put(apr_dir_t **dir, - apr_os_dir_t *thedir, - apr_pool_t *pool) -{ - return APR_ENOTIMPL; -} diff --git a/libs/apr/file_io/win32/filedup.c b/libs/apr/file_io/win32/filedup.c deleted file mode 100644 index 6e79ad2c..00000000 --- a/libs/apr/file_io/win32/filedup.c +++ /dev/null @@ -1,230 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_strings.h" -#include -#include "apr_arch_inherit.h" -#include /* for [_open/_get]_osfhandle */ - -#if defined(__BORLANDC__) -#define _dup2 dup2 -// #define _close close -#define _setmode setmode -# endif - -APR_DECLARE(apr_status_t) apr_file_dup(apr_file_t **new_file, - apr_file_t *old_file, apr_pool_t *p) -{ -#ifdef _WIN32_WCE - return APR_ENOTIMPL; -#else - HANDLE hproc = GetCurrentProcess(); - HANDLE newhand = NULL; - - if (!DuplicateHandle(hproc, old_file->filehand, - hproc, &newhand, 0, FALSE, - DUPLICATE_SAME_ACCESS)) { - return apr_get_os_error(); - } - - (*new_file) = (apr_file_t *) apr_pcalloc(p, sizeof(apr_file_t)); - (*new_file)->filehand = newhand; - (*new_file)->flags = old_file->flags & ~(APR_STD_FLAGS | APR_INHERIT); - (*new_file)->pool = p; - (*new_file)->fname = apr_pstrdup(p, old_file->fname); - (*new_file)->append = old_file->append; - (*new_file)->buffered = FALSE; - (*new_file)->ungetchar = old_file->ungetchar; - -#if APR_HAS_THREADS - if (old_file->mutex) { - apr_thread_mutex_create(&((*new_file)->mutex), - APR_THREAD_MUTEX_DEFAULT, p); - } -#endif - - apr_pool_cleanup_register((*new_file)->pool, (void *)(*new_file), file_cleanup, - apr_pool_cleanup_null); - - /* Create a pollset with room for one descriptor. */ - /* ### check return codes */ - (void) apr_pollset_create(&(*new_file)->pollset, 1, p, 0); - - return APR_SUCCESS; -#endif /* !defined(_WIN32_WCE) */ -} - -APR_DECLARE(apr_status_t) apr_file_dup2(apr_file_t *new_file, - apr_file_t *old_file, apr_pool_t *p) -{ -#ifdef _WIN32_WCE - return APR_ENOTIMPL; -#else - HANDLE hproc = GetCurrentProcess(); - HANDLE newhand = NULL; - apr_int32_t newflags; - int fd; - - if (new_file->flags & APR_STD_FLAGS) - { - if ((new_file->flags & APR_STD_FLAGS) == APR_STDERR_FLAG) - { - /* Flush stderr and unset its buffer, then commit the fd-based buffer. - * This is typically a noop for Win2K/XP since services with NULL std - * handles [but valid FILE *'s, oddly enough], but is required - * for NT 4.0 and to use this code outside of services. - */ - fflush(stderr); - setvbuf(stderr, NULL, _IONBF, 0); - _commit(2 /* stderr */); - - /* Clone a handle can _close() without harming the source handle, - * open an MSVCRT-based pseudo-fd for the file handle, then dup2 - * and close our temporary pseudo-fd once it's been duplicated. - * This will incidently keep the FILE-based stderr in sync. - * Note the apparently redundant _O_BINARY coersions are required. - * Note the _dup2 will close the previous std Win32 handle. - */ - if (!DuplicateHandle(hproc, old_file->filehand, hproc, &newhand, - 0, FALSE, DUPLICATE_SAME_ACCESS)) { - return apr_get_os_error(); - } - fd = _open_osfhandle((INT_PTR)newhand, _O_WRONLY | _O_BINARY); - _dup2(fd, 2); - _close(fd); - _setmode(2, _O_BINARY); - - /* hPipeWrite was _close()'ed above, and _dup2()'ed - * to fd 2 creating a new, inherited Win32 handle. - * Recover that real handle from fd 2. Note that - * SetStdHandle(STD_ERROR_HANDLE, _get_osfhandle(2)) - * is implicit in the dup2() call above - */ - newhand = (HANDLE)_get_osfhandle(2); - } - else if ((new_file->flags & APR_STD_FLAGS) == APR_STDOUT_FLAG) { - /* For the process flow see the stderr case above */ - fflush(stdout); - setvbuf(stdout, NULL, _IONBF, 0); - _commit(1 /* stdout */); - - if (!DuplicateHandle(hproc, old_file->filehand, hproc, &newhand, - 0, FALSE, DUPLICATE_SAME_ACCESS)) { - return apr_get_os_error(); - } - fd = _open_osfhandle((INT_PTR)newhand, _O_WRONLY | _O_BINARY); - _dup2(fd, 1); - _close(fd); - _setmode(1, _O_BINARY); - newhand = (HANDLE)_get_osfhandle(1); - } - else if ((new_file->flags & APR_STD_FLAGS) == APR_STDIN_FLAG) { - /* For the process flow see the stderr case above */ - fflush(stdin); - setvbuf(stdin, NULL, _IONBF, 0); - _commit(0 /* stdin */); - - if (!DuplicateHandle(hproc, old_file->filehand, hproc, &newhand, - 0, FALSE, DUPLICATE_SAME_ACCESS)) { - return apr_get_os_error(); - } - fd = _open_osfhandle((INT_PTR)newhand, _O_RDONLY | _O_BINARY); - _dup2(fd, 0); - _close(fd); - _setmode(0, _O_BINARY); - newhand = (HANDLE)_get_osfhandle(0); - } - newflags = (new_file->flags & APR_STD_FLAGS) - | (old_file->flags & ~APR_STD_FLAGS) | APR_INHERIT; - - /* No need to close the old file, _dup2() above did that for us */ - } - else { - if (!DuplicateHandle(hproc, old_file->filehand, - hproc, &newhand, 0, - FALSE, DUPLICATE_SAME_ACCESS)) { - return apr_get_os_error(); - } - newflags = old_file->flags & ~(APR_STD_FLAGS | APR_INHERIT); - - if (new_file->filehand - && (new_file->filehand != INVALID_HANDLE_VALUE)) { - CloseHandle(new_file->filehand); - } - } - - new_file->flags = newflags; - new_file->filehand = newhand; - new_file->fname = apr_pstrdup(new_file->pool, old_file->fname); - new_file->append = old_file->append; - new_file->buffered = FALSE; - new_file->ungetchar = old_file->ungetchar; - -#if APR_HAS_THREADS - if (old_file->mutex) { - apr_thread_mutex_create(&(new_file->mutex), - APR_THREAD_MUTEX_DEFAULT, p); - } -#endif - - return APR_SUCCESS; -#endif /* !defined(_WIN32_WCE) */ -} - -APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file, - apr_file_t *old_file, - apr_pool_t *p) -{ - *new_file = (apr_file_t *)apr_palloc(p, sizeof(apr_file_t)); - memcpy(*new_file, old_file, sizeof(apr_file_t)); - (*new_file)->pool = p; - if (old_file->buffered) { - (*new_file)->buffer = apr_palloc(p, old_file->bufsize); - (*new_file)->bufsize = old_file->bufsize; - if (old_file->direction == 1) { - memcpy((*new_file)->buffer, old_file->buffer, old_file->bufpos); - } - else { - memcpy((*new_file)->buffer, old_file->buffer, old_file->dataRead); - } - } - if (old_file->mutex) { - apr_thread_mutex_create(&((*new_file)->mutex), - APR_THREAD_MUTEX_DEFAULT, p); - apr_thread_mutex_destroy(old_file->mutex); - } - if (old_file->fname) { - (*new_file)->fname = apr_pstrdup(p, old_file->fname); - } - if (!(old_file->flags & APR_FOPEN_NOCLEANUP)) { - apr_pool_cleanup_register(p, (void *)(*new_file), - file_cleanup, - file_cleanup); - } - - old_file->filehand = INVALID_HANDLE_VALUE; - apr_pool_cleanup_kill(old_file->pool, (void *)old_file, - file_cleanup); - - /* Create a pollset with room for one descriptor. */ - /* ### check return codes */ - (void) apr_pollset_create(&(*new_file)->pollset, 1, p, 0); - - return APR_SUCCESS; -} diff --git a/libs/apr/file_io/win32/filepath.c b/libs/apr/file_io/win32/filepath.c deleted file mode 100644 index 559d1b28..00000000 --- a/libs/apr/file_io/win32/filepath.c +++ /dev/null @@ -1,1005 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_private.h" -#include "apr_arch_file_io.h" -#include "apr_strings.h" -#include "apr_lib.h" -#include -#include - -#ifdef NETWARE -#include -#include -#endif - - /* WinNT accepts several odd forms of a 'root' path. Under Unicode - * calls (ApiFunctionW) the //?/C:/foo or //?/UNC/mach/share/foo forms - * are accepted. Ansi and Unicode functions both accept the //./C:/foo - * form under WinNT/2K. Since these forms are handled in the utf-8 to - * unicode translation phase, we don't want the user confused by them, so - * we will accept them but always return the canonical C:/ or //mach/share/ - * - * OS2 appears immune from the nonsense :) - */ - -APR_DECLARE(apr_status_t) apr_filepath_root(const char **rootpath, - const char **inpath, - apr_int32_t flags, - apr_pool_t *p) -{ - const char *testpath = *inpath; - char *newpath; -#ifdef NETWARE - char seperator[2] = { 0, 0}; - char server[APR_PATH_MAX+1]; - char volume[APR_PATH_MAX+1]; - char file[APR_PATH_MAX+1]; - char *volsep = NULL; - int elements; - - if (inpath && *inpath) - volsep = strchr (*inpath, ':'); - else - return APR_EBADPATH; - - if (strlen(*inpath) > APR_PATH_MAX) { - return APR_EBADPATH; - } - - seperator[0] = (flags & APR_FILEPATH_NATIVE) ? '\\' : '/'; - - /* Allocate and initialize each of the segment buffers - */ - server[0] = volume[0] = file[0] = '\0'; - - /* If we don't have a volume separator then don't bother deconstructing - the path since we won't use the deconstructed information anyway. - */ - if (volsep) { - /* Split the inpath into its separate parts. */ - deconstruct(testpath, server, volume, NULL, file, NULL, &elements, PATH_UNDEF); - - /* If we got a volume part then continue splitting out the root. - Otherwise we either have an incomplete or relative path - */ - if (volume && strlen(volume) > 0) { - newpath = apr_pcalloc(p, strlen(server)+strlen(volume)+5); - construct(newpath, server, volume, NULL, NULL, NULL, PATH_NETWARE); - - /* NetWare doesn't add the root slash so we need to add it manually. - */ - strcat(newpath, seperator); - *rootpath = newpath; - - /* Skip the inpath pointer down to the first non-root character - */ - newpath = volsep; - do { - ++newpath; - } while (*newpath && ((*newpath == '/') || (*newpath == '\\'))); - *inpath = newpath; - - /* Need to handle APR_FILEPATH_TRUENAME checking here. */ - - return APR_SUCCESS; - } - else - return APR_EBADPATH; - } - else if ((**inpath == '/') || (**inpath == '\\')) { - /* if we have a root path without a volume then just split - in same manner as unix although this path will be - incomplete. - */ - *rootpath = apr_pstrdup(p, seperator); - do { - ++(*inpath); - } while ((**inpath == '/') || (**inpath == '\\')); - } - else - return APR_ERELATIVE; - - return APR_EINCOMPLETE; - -#else /* ndef(NETWARE) */ - - char seperator[2]; - const char *delim1; - const char *delim2; - - seperator[0] = (flags & APR_FILEPATH_NATIVE) ? '\\' : '/'; - seperator[1] = 0; - - if (testpath[0] == '/' || testpath[0] == '\\') { - if (testpath[1] == '/' || testpath[1] == '\\') { - -#ifdef WIN32 /* //server/share isn't the only // delimited syntax */ - if ((testpath[2] == '?' || testpath[2] == '.') - && (testpath[3] == '/' || testpath[3] == '\\')) { - if (IS_FNCHAR(testpath[4]) && testpath[5] == ':') - { - apr_status_t rv; - testpath += 4; - /* given '//?/C: or //./C: let us try this - * all over again from the drive designator - */ - rv = apr_filepath_root(rootpath, &testpath, flags, p); - if (!rv || rv == APR_EINCOMPLETE) - *inpath = testpath; - return rv; - } - else if (strncasecmp(testpath + 4, "UNC", 3) == 0 - && (testpath[7] == '/' || testpath[7] == '\\') - && (testpath[2] == '?')) { - /* given '//?/UNC/machine/share, a little magic - * at the end makes this all work out by using - * 'C/machine' as the starting point and replacing - * the UNC delimiters with \'s, including the 'C' - */ - testpath += 6; - } - else - /* This must not be a path to a file, but rather - * a volume or device. Die for now. - */ - return APR_EBADPATH; - } -#endif /* WIN32 (non - //server/share syntax) */ - - /* Evaluate path of '//[machine/[share[/]]]' */ - delim1 = testpath + 2; - do { - /* Protect against //X/ where X is illegal */ - if (*delim1 && !IS_FNCHAR(*(delim1++))) - return APR_EBADPATH; - } while (*delim1 && *delim1 != '/' && *delim1 != '\\'); - - if (*delim1) { - apr_status_t rv; - delim2 = delim1 + 1; - while (*delim2 && *delim2 != '/' && *delim2 != '\\') { - /* Protect against //machine/X/ where X is illegal */ - if (!IS_FNCHAR(*(delim2++))) - return APR_EBADPATH; - } - - /* Copy the '//machine/[share[/]]' path, always providing - * an extra byte for the trailing slash. - */ - newpath = apr_pstrmemdup(p, testpath, delim2 - testpath + 1); - - if (delim2 == delim1 + 1) { - /* We found simply \\machine\, so give up already - */ - *rootpath = newpath; - *inpath = delim2; - return APR_EINCOMPLETE; - } - - if (flags & APR_FILEPATH_TRUENAME) { - /* Validate the \\Machine\Share\ designation, - * Win32 will argue about slashed in UNC paths, - * so use backslashes till we finish testing, - * and add the trailing backslash [required]. - * apr_pstrmemdup above guarentees us the new - * trailing null character. - */ - newpath[0] = '\\'; - newpath[1] = '\\'; - newpath[delim1 - testpath] = '\\'; - newpath[delim2 - testpath] = '\\'; - - rv = filepath_root_test(newpath, p); - if (rv) - return rv; - rv = filepath_root_case(&newpath, newpath, p); - if (rv) - return rv; - newpath[0] = seperator[0]; - newpath[1] = seperator[0]; - newpath[delim1 - testpath] = seperator[0]; - newpath[delim2 - testpath] = (*delim2 ? seperator[0] : '\0'); - } - else { - /* Give back the caller's own choice of delimiters - */ - newpath[0] = testpath[0]; - newpath[1] = testpath[1]; - newpath[delim1 - testpath] = *delim1; - newpath[delim2 - testpath] = *delim2; - } - - /* If this root included the trailing / or \ designation - * then lop off multiple trailing slashes and give back - * appropriate delimiters. - */ - if (*delim2) { - *inpath = delim2 + 1; - while (**inpath == '/' || **inpath == '\\') - ++*inpath; - } - else { - *inpath = delim2; - } - - *rootpath = newpath; - return APR_SUCCESS; - } - - /* Have path of '\\[machine]', if the machine is given, - * append same trailing slash as the leading slash - */ - delim1 = strchr(testpath, '\0'); - if (delim1 > testpath + 2) { - newpath = apr_pstrndup(p, testpath, delim1 - testpath + 1); - if (flags & APR_FILEPATH_TRUENAME) - newpath[delim1 - testpath] = seperator[0]; - else - newpath[delim1 - testpath] = newpath[0]; - newpath[delim1 - testpath + 1] = '\0'; - } - else { - newpath = apr_pstrndup(p, testpath, delim1 - testpath); - } - if (flags & APR_FILEPATH_TRUENAME) { - newpath[0] = seperator[0]; - newpath[1] = seperator[0]; - } - *rootpath = newpath; - *inpath = delim1; - return APR_EINCOMPLETE; - } - - /* Left with a path of '/', what drive are we asking about? - */ - *inpath = testpath + 1; - newpath = apr_palloc(p, 2); - if (flags & APR_FILEPATH_TRUENAME) - newpath[0] = seperator[0]; - else - newpath[0] = testpath[0]; - newpath[1] = '\0'; - *rootpath = newpath; - return APR_EINCOMPLETE; - } - - /* Evaluate path of 'd:[/]' */ - if (IS_FNCHAR(*testpath) && testpath[1] == ':') - { - apr_status_t rv; - /* Validate that D:\ drive exists, test must be rooted - * Note that posix/win32 insists a drive letter is upper case, - * so who are we to argue with a 'feature'. - * It is a safe fold, since only A-Z is legal, and has no - * side effects of legal mis-mapped non-us-ascii codes. - */ - newpath = apr_palloc(p, 4); - newpath[0] = testpath[0]; - newpath[1] = testpath[1]; - newpath[2] = seperator[0]; - newpath[3] = '\0'; - if (flags & APR_FILEPATH_TRUENAME) { - newpath[0] = apr_toupper(newpath[0]); - rv = filepath_root_test(newpath, p); - if (rv) - return rv; - } - /* Just give back the root the user handed to us. - */ - if (testpath[2] != '/' && testpath[2] != '\\') { - newpath[2] = '\0'; - *rootpath = newpath; - *inpath = testpath + 2; - return APR_EINCOMPLETE; - } - - /* strip off remaining slashes that designate the root, - * give the caller back their original choice of slash - * unless this is TRUENAME'ed - */ - *inpath = testpath + 3; - while (**inpath == '/' || **inpath == '\\') - ++*inpath; - if (!(flags & APR_FILEPATH_TRUENAME)) - newpath[2] = testpath[2]; - *rootpath = newpath; - return APR_SUCCESS; - } - - /* Nothing interesting */ - return APR_ERELATIVE; - -#endif /* ndef(NETWARE) */ -} - -#if !defined(NETWARE) -static int same_drive(const char *path1, const char *path2) -{ - char drive1 = path1[0]; - char drive2 = path2[0]; - - if (!drive1 || !drive2 || path1[1] != ':' || path2[1] != ':') - return FALSE; - - if (drive1 == drive2) - return TRUE; - - if (drive1 >= 'a' && drive1 <= 'z') - drive1 += 'A' - 'a'; - - if (drive2 >= 'a' && drive2 <= 'z') - drive2 += 'A' - 'a'; - - return (drive1 == drive2); -} -#endif - -APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, - const char *basepath, - const char *addpath, - apr_int32_t flags, - apr_pool_t *p) -{ - char path[APR_PATH_MAX]; /* isn't null term */ - const char *baseroot = NULL; - const char *addroot; - apr_size_t rootlen; /* the length of the root portion of path, d:/ is 3 */ - apr_size_t baselen; /* the length of basepath (excluding baseroot) */ - apr_size_t keptlen; /* the length of the retained basepath (incl root) */ - apr_size_t pathlen; /* the length of the result path */ - apr_size_t segend; /* the end of the current segment */ - apr_size_t seglen; /* the length of the segment (excl trailing chars) */ - apr_status_t basetype = 0; /* from parsing the basepath's baseroot */ - apr_status_t addtype; /* from parsing the addpath's addroot */ - apr_status_t rv; -#ifndef NETWARE - int fixunc = 0; /* flag to complete an incomplete UNC basepath */ -#endif - - /* Treat null as an empty path, otherwise split addroot from the addpath - */ - if (!addpath) { - addpath = addroot = ""; - addtype = APR_ERELATIVE; - } - else { - /* This call _should_ test the path - */ - addtype = apr_filepath_root(&addroot, &addpath, - APR_FILEPATH_TRUENAME - | (flags & APR_FILEPATH_NATIVE), - p); - if (addtype == APR_SUCCESS) { - addtype = APR_EABSOLUTE; - } - else if (addtype == APR_ERELATIVE) { - addroot = ""; - } - else if (addtype != APR_EINCOMPLETE) { - /* apr_filepath_root was incomprehensible so fail already - */ - return addtype; - } - } - - /* If addpath is (even partially) rooted, then basepath is - * unused. Ths violates any APR_FILEPATH_SECUREROOTTEST - * and APR_FILEPATH_NOTABSOLUTE flags specified. - */ - if (addtype == APR_EABSOLUTE || addtype == APR_EINCOMPLETE) - { - if (flags & APR_FILEPATH_SECUREROOTTEST) - return APR_EABOVEROOT; - if (flags & APR_FILEPATH_NOTABSOLUTE) - return addtype; - } - - /* Optimized tests before we query the current working path - */ - if (!basepath) { - - /* If APR_FILEPATH_NOTABOVEROOT wasn't specified, - * we won't test the root again, it's ignored. - * Waste no CPU retrieving the working path. - */ - if (addtype == APR_EABSOLUTE && !(flags & APR_FILEPATH_NOTABOVEROOT)) { - basepath = baseroot = ""; - basetype = APR_ERELATIVE; - } - - /* If APR_FILEPATH_NOTABSOLUTE is specified, the caller - * requires an absolutely relative result, So do not retrieve - * the working path. - */ - if (addtype == APR_ERELATIVE && (flags & APR_FILEPATH_NOTABSOLUTE)) { - basepath = baseroot = ""; - basetype = APR_ERELATIVE; - } - } - - if (!basepath) - { - /* Start with the current working path. This is bass akwards, - * but required since the compiler (at least vc) doesn't like - * passing the address of a char const* for a char** arg. - * We must grab the current path of the designated drive - * if addroot is given in drive-relative form (e.g. d:foo) - */ - char *getpath; -#ifndef NETWARE - if (addtype == APR_EINCOMPLETE && addroot[1] == ':') - rv = filepath_drive_get(&getpath, addroot[0], flags, p); - else -#endif - rv = apr_filepath_get(&getpath, flags, p); - if (rv != APR_SUCCESS) - return rv; - basepath = getpath; - } - - if (!baseroot) { - /* This call should _not_ test the path - */ - basetype = apr_filepath_root(&baseroot, &basepath, - (flags & APR_FILEPATH_NATIVE), p); - if (basetype == APR_SUCCESS) { - basetype = APR_EABSOLUTE; - } - else if (basetype == APR_ERELATIVE) { - baseroot = ""; - } - else if (basetype != APR_EINCOMPLETE) { - /* apr_filepath_root was incomprehensible so fail already - */ - return basetype; - } - } - baselen = strlen(basepath); - - /* If APR_FILEPATH_NOTABSOLUTE is specified, the caller - * requires an absolutely relative result. If the given - * basepath is not relative then fail. - */ - if ((flags & APR_FILEPATH_NOTABSOLUTE) && basetype != APR_ERELATIVE) - return basetype; - - /* The Win32 nightmare on unc street... start combining for - * many possible root combinations. - */ - if (addtype == APR_EABSOLUTE) - { - /* Ignore the given root path, and start with the addroot - */ - if ((flags & APR_FILEPATH_NOTABOVEROOT) - && strncmp(baseroot, addroot, strlen(baseroot))) - return APR_EABOVEROOT; - keptlen = 0; - rootlen = pathlen = strlen(addroot); - memcpy(path, addroot, pathlen); - } - else if (addtype == APR_EINCOMPLETE) - { - /* There are several types of incomplete paths, - * incomplete UNC paths (//foo/ or //), - * drives without rooted paths (d: as in d:foo), - * and simple roots (/ as in /foo). - * Deal with these in significantly different manners... - */ -#ifndef NETWARE - if ((addroot[0] == '/' || addroot[0] == '\\') && - (addroot[1] == '/' || addroot[1] == '\\')) - { - /* Ignore the given root path if the incomplete addpath is UNC, - * (note that the final result will be incomplete). - */ - if (flags & APR_FILEPATH_NOTRELATIVE) - return addtype; - if ((flags & APR_FILEPATH_NOTABOVEROOT) - && strncmp(baseroot, addroot, strlen(baseroot))) - return APR_EABOVEROOT; - fixunc = 1; - keptlen = 0; - rootlen = pathlen = strlen(addroot); - memcpy(path, addroot, pathlen); - } - else -#endif - if ((addroot[0] == '/' || addroot[0] == '\\') && !addroot[1]) - { - /* Bring together the drive or UNC root from the baseroot - * if the addpath is a simple root and basepath is rooted, - * otherwise disregard the basepath entirely. - */ - if (basetype != APR_EABSOLUTE && (flags & APR_FILEPATH_NOTRELATIVE)) - return basetype; - if (basetype != APR_ERELATIVE) { -#ifndef NETWARE - if (basetype == APR_INCOMPLETE - && (baseroot[0] == '/' || baseroot[0] == '\\') - && (baseroot[1] == '/' || baseroot[1] == '\\')) - fixunc = 1; -#endif - keptlen = rootlen = pathlen = strlen(baseroot); - memcpy(path, baseroot, pathlen); - } - else { - if (flags & APR_FILEPATH_NOTABOVEROOT) - return APR_EABOVEROOT; - keptlen = 0; - rootlen = pathlen = strlen(addroot); - memcpy(path, addroot, pathlen); - } - } -#ifdef NETWARE - else if (filepath_has_drive(addroot, DRIVE_ONLY, p)) - { - /* If the addroot is a drive (without a volume root) - * use the basepath _if_ it matches this drive letter! - * Otherwise we must discard the basepath. - */ - if (!filepath_compare_drive(addroot, baseroot, p) && - filepath_has_drive(baseroot, 0, p)) { -#else - else if (addroot[0] && addroot[1] == ':' && !addroot[2]) - { - /* If the addroot is a drive (without a volume root) - * use the basepath _if_ it matches this drive letter! - * Otherwise we must discard the basepath. - */ - if (same_drive(addroot, baseroot)) { -#endif - /* Base the result path on the basepath - */ - if (basetype != APR_EABSOLUTE && (flags & APR_FILEPATH_NOTRELATIVE)) - return basetype; - rootlen = strlen(baseroot); - keptlen = pathlen = rootlen + baselen; - if (keptlen >= sizeof(path)) - return APR_ENAMETOOLONG; - memcpy(path, baseroot, rootlen); - memcpy(path + rootlen, basepath, baselen); - } - else { - if (flags & APR_FILEPATH_NOTRELATIVE) - return addtype; - if (flags & APR_FILEPATH_NOTABOVEROOT) - return APR_EABOVEROOT; - keptlen = 0; - rootlen = pathlen = strlen(addroot); - memcpy(path, addroot, pathlen); - } - } - else { - /* Now this is unexpected, we aren't aware of any other - * incomplete path forms! Fail now. - */ - return APR_EBADPATH; - } - } - else { /* addtype == APR_ERELATIVE */ - /* If both paths are relative, fail early - */ - if (basetype != APR_EABSOLUTE && (flags & APR_FILEPATH_NOTRELATIVE)) - return basetype; - -#ifndef NETWARE - /* An incomplete UNC path must be completed - */ - if (basetype == APR_INCOMPLETE - && (baseroot[0] == '/' || baseroot[0] == '\\') - && (baseroot[1] == '/' || baseroot[1] == '\\')) - fixunc = 1; -#endif - - /* Base the result path on the basepath - */ - rootlen = strlen(baseroot); - keptlen = pathlen = rootlen + baselen; - if (keptlen >= sizeof(path)) - return APR_ENAMETOOLONG; - memcpy(path, baseroot, rootlen); - memcpy(path + rootlen, basepath, baselen); - } - - /* '/' terminate the given root path unless it's already terminated - * or is an incomplete drive root. Correct the trailing slash unless - * we have an incomplete UNC path still to fix. - */ - if (pathlen && path[pathlen - 1] != ':') { - if (path[pathlen - 1] != '/' && path[pathlen - 1] != '\\') { - if (pathlen + 1 >= sizeof(path)) - return APR_ENAMETOOLONG; - - path[pathlen++] = ((flags & APR_FILEPATH_NATIVE) ? '\\' : '/'); - } - /* XXX: wrong, but gotta figure out what I intended; - * else if (!fixunc) - * path[pathlen++] = ((flags & APR_FILEPATH_NATIVE) ? '\\' : '/'); - */ - } - - while (*addpath) - { - /* Parse each segment, find the closing '/' - */ - seglen = 0; - while (addpath[seglen] && addpath[seglen] != '/' - && addpath[seglen] != '\\') - ++seglen; - - /* Truncate all trailing spaces and all but the first two dots */ - segend = seglen; - while (seglen && (addpath[seglen - 1] == ' ' - || addpath[seglen - 1] == '.')) { - if (seglen > 2 || addpath[seglen - 1] != '.' || addpath[0] != '.') - --seglen; - else - break; - } - - if (seglen == 0 || (seglen == 1 && addpath[0] == '.')) - { - /* NOTE: win32 _hates_ '/ /' and '/. /' (yes, with spaces in there) - * so eliminate all preconceptions that it is valid. - */ - if (seglen < segend) - return APR_EBADPATH; - -#ifndef NETWARE - /* This isn't legal unless the unc path is completed - */ - if (fixunc) - return APR_EBADPATH; -#endif - - /* Otherwise, this is a noop segment (/ or ./) so ignore it - */ - } - else if (seglen == 2 && addpath[0] == '.' && addpath[1] == '.') - { - /* NOTE: win32 _hates_ '/.. /' (yes, with a space in there) - * and '/..../', some functions treat it as ".", and some - * fail! Eliminate all preconceptions that they are valid. - */ - if (seglen < segend && (seglen != 3 || addpath[2] != '.')) - return APR_EBADPATH; - -#ifndef NETWARE - /* This isn't legal unless the unc path is completed - */ - if (fixunc) - return APR_EBADPATH; -#endif - - /* backpath (../) when an absolute path is given */ - if (rootlen && (pathlen <= rootlen)) - { - /* Attempt to move above root. Always die if the - * APR_FILEPATH_SECUREROOTTEST flag is specified. - */ - if (flags & APR_FILEPATH_SECUREROOTTEST) - return APR_EABOVEROOT; - - /* Otherwise this is simply a noop, above root is root. - */ - } - else if (pathlen == 0 - || (pathlen >= 3 - && (pathlen == 3 - || path[pathlen - 4] == ':' - || path[pathlen - 4] == '/' - || path[pathlen - 4] == '\\') - && path[pathlen - 3] == '.' - && path[pathlen - 2] == '.' - && (path[pathlen - 1] == '/' - || path[pathlen - 1] == '\\'))) - { - /* Verified path is empty, exactly "..[/\]", or ends - * in "[:/\]..[/\]" - these patterns we will not back - * over since they aren't 'prior segements'. - * - * If APR_FILEPATH_SECUREROOTTEST.was given, die now. - */ - if (flags & APR_FILEPATH_SECUREROOTTEST) - return APR_EABOVEROOT; - - /* Otherwise append another backpath. - */ - if (pathlen + 3 >= sizeof(path)) - return APR_ENAMETOOLONG; - path[pathlen++] = '.'; - path[pathlen++] = '.'; - if (addpath[segend]) { - path[pathlen++] = ((flags & APR_FILEPATH_NATIVE) - ? '\\' : ((flags & APR_FILEPATH_TRUENAME) - ? '/' : addpath[segend])); - } - /* The 'root' part of this path now includes the ../ path, - * because that backpath will not be parsed by the truename - * code below. - */ - keptlen = pathlen; - } - else - { - /* otherwise crop the prior segment - */ - do { - --pathlen; - } while (pathlen && path[pathlen - 1] != '/' - && path[pathlen - 1] != '\\'); - - /* Now test if we are above where we started and back up - * the keptlen offset to reflect the added/altered path. - */ - if (pathlen < keptlen) - { - if (flags & APR_FILEPATH_SECUREROOTTEST) - return APR_EABOVEROOT; - keptlen = pathlen; - } - } - } - else /* not empty or dots */ - { -#ifndef NETWARE - if (fixunc) { - const char *testpath = path; - const char *testroot; - apr_status_t testtype; - apr_size_t i = (addpath[segend] != '\0'); - - /* This isn't legal unless the unc path is complete! - */ - if (seglen < segend) - return APR_EBADPATH; - if (pathlen + seglen + 1 >= sizeof(path)) - return APR_ENAMETOOLONG; - memcpy(path + pathlen, addpath, seglen + i); - - /* Always add the trailing slash to a UNC segment - */ - path[pathlen + seglen] = ((flags & APR_FILEPATH_NATIVE) - ? '\\' : '/'); - pathlen += seglen + 1; - - /* Recanonicalize the UNC root with the new UNC segment, - * and if we succeed, reset this test and the rootlen, - * and replace our path with the canonical UNC root path - */ - path[pathlen] = '\0'; - /* This call _should_ test the path - */ - testtype = apr_filepath_root(&testroot, &testpath, - APR_FILEPATH_TRUENAME - | (flags & APR_FILEPATH_NATIVE), - p); - if (testtype == APR_SUCCESS) { - rootlen = pathlen = (testpath - path); - memcpy(path, testroot, pathlen); - fixunc = 0; - } - else if (testtype != APR_EINCOMPLETE) { - /* apr_filepath_root was very unexpected so fail already - */ - return testtype; - } - } - else -#endif - { - /* An actual segment, append it to the destination path - */ - apr_size_t i = (addpath[segend] != '\0'); - if (pathlen + seglen + i >= sizeof(path)) - return APR_ENAMETOOLONG; - memcpy(path + pathlen, addpath, seglen + i); - if (i) - path[pathlen + seglen] = ((flags & APR_FILEPATH_NATIVE) - ? '\\' : '/'); - pathlen += seglen + i; - } - } - - /* Skip over trailing slash to the next segment - */ - if (addpath[segend]) - ++segend; - - addpath += segend; - } - - /* keptlen will be the baselen unless the addpath contained - * backpath elements. If so, and APR_FILEPATH_NOTABOVEROOT - * is specified (APR_FILEPATH_SECUREROOTTEST was caught above), - * compare the string beyond the root to assure the result path - * is still within given basepath. Note that the root path - * segment is thoroughly tested prior to path parsing. - */ - if ((flags & APR_FILEPATH_NOTABOVEROOT) && baselen) { - if (memcmp(basepath, path + rootlen, baselen) != 0) - return APR_EABOVEROOT; - - /* Ahem... if we have a basepath without a trailing slash, - * we better be sure that /foo wasn't replaced with /foobar! - */ - if (basepath[baselen - 1] != '/' && basepath[baselen - 1] != '\\' - && path[rootlen + baselen] && path[rootlen + baselen] != '/' - && path[rootlen + baselen] != '\\') - return APR_EABOVEROOT; - } - - if (addpath && (flags & APR_FILEPATH_TRUENAME)) { - /* We can always skip the root, it's already true-named. */ - if (rootlen > keptlen) - keptlen = rootlen; - if ((path[keptlen] == '/') || (path[keptlen] == '\\')) { - /* By rights, keptlen may grown longer than pathlen. - * we wont' use it again (in that case) so we don't care. - */ - ++keptlen; - } - /* Go through all the new segments */ - while (keptlen < pathlen) { - apr_finfo_t finfo; - char saveslash = 0; - seglen = 0; - /* find any slash and set it aside for a minute. */ - for (seglen = 0; keptlen + seglen < pathlen; ++seglen) { - if ((path[keptlen + seglen] == '/') || - (path[keptlen + seglen] == '\\')) { - saveslash = path[keptlen + seglen]; - break; - } - } - /* Null term for stat! */ - path[keptlen + seglen] = '\0'; - if ((rv = apr_stat(&finfo, path, - APR_FINFO_LINK | APR_FINFO_TYPE | APR_FINFO_NAME, p)) - == APR_SUCCESS) { - apr_size_t namelen = strlen(finfo.name); - -#if defined(OS2) /* only has case folding, never aliases that change the length */ - - if (memcmp(finfo.name, path + keptlen, seglen) != 0) { - memcpy(path + keptlen, finfo.name, namelen); - } -#else /* WIN32 || NETWARE; here there be aliases that gire and gimble and change length */ - - if ((namelen != seglen) || - (memcmp(finfo.name, path + keptlen, seglen) != 0)) - { - if (namelen <= seglen) { - memcpy(path + keptlen, finfo.name, namelen); - if ((namelen < seglen) && saveslash) { - memmove(path + keptlen + namelen + 1, - path + keptlen + seglen + 1, - pathlen - keptlen - seglen); - pathlen += namelen - seglen; - seglen = namelen; - } - } - else { /* namelen > seglen */ - if (pathlen + namelen - seglen >= sizeof(path)) - return APR_ENAMETOOLONG; - if (saveslash) { - memmove(path + keptlen + namelen + 1, - path + keptlen + seglen + 1, - pathlen - keptlen - seglen); - } - memcpy(path + keptlen, finfo.name, namelen); - pathlen += namelen - seglen; - seglen = namelen; - } - } -#endif /* !OS2 (Whatever that alias was we're over it) */ - - /* That's it, the rest is path info. - * I don't know how we aught to handle this. Should - * we define a new error to indicate 'more info'? - * Should we split out the rest of the path? - */ - if ((finfo.filetype != APR_DIR) && - (finfo.filetype != APR_LNK) && saveslash) - rv = APR_ENOTDIR; -#ifdef XXX_FIGURE_THIS_OUT - { - /* the example inserts a null between the end of - * the filename and the next segment, and increments - * the path length so we would return both segments. - */ - if (saveslash) { - keptlen += seglen; - path[keptlen] = saveslash; - if (pathlen + 1 >= sizeof(path)) - return APR_ENAMETOOLONG; - memmove(path + keptlen + 1, - path + keptlen, - pathlen - keptlen); - path[keptlen] = '\0'; - ++pathlen; - break; - } - } -#endif - } - - /* put back the '/' */ - if (saveslash) { - path[keptlen + seglen] = saveslash; - ++seglen; - } - keptlen += seglen; - - if (rv != APR_SUCCESS) { - if (APR_STATUS_IS_ENOENT(rv)) - break; - if (APR_STATUS_IS_EPATHWILD(rv)) - /* This path included wildcards. The path elements - * that did not contain wildcards are canonicalized, - * so we will return the path, although later elements - * don't necessarily exist, and aren't canonical. - */ - break; - else if (APR_STATUS_IS_ENOTDIR(rv)) - /* This is a little more serious, we just added a name - * onto a filename (think http's PATH_INFO) - * If the caller is foolish enough to do this, we expect - * the've already canonicalized the root) that they knew - * what they are doing :( - */ - break; - else - return rv; - } - } - } - - *newpath = apr_pstrmemdup(p, path, pathlen); - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_filepath_list_split(apr_array_header_t **pathelts, - const char *liststr, - apr_pool_t *p) -{ - return apr_filepath_list_split_impl(pathelts, liststr, ';', p); -} - -APR_DECLARE(apr_status_t) apr_filepath_list_merge(char **liststr, - apr_array_header_t *pathelts, - apr_pool_t *p) -{ - return apr_filepath_list_merge_impl(liststr, pathelts, ';', p); -} - - -APR_DECLARE(apr_status_t) apr_filepath_encoding(int *style, apr_pool_t *p) -{ -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - *style = APR_FILEPATH_ENCODING_UTF8; - return APR_SUCCESS; - } -#endif - - *style = APR_FILEPATH_ENCODING_LOCALE; - return APR_SUCCESS; -} diff --git a/libs/apr/file_io/win32/filestat.c b/libs/apr/file_io/win32/filestat.c deleted file mode 100644 index 0d2225a9..00000000 --- a/libs/apr/file_io/win32/filestat.c +++ /dev/null @@ -1,807 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include -#include "apr_private.h" -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_errno.h" -#include "apr_time.h" -#include -#include "apr_arch_atime.h" -#include "apr_arch_misc.h" - -/* We have to assure that the file name contains no '*'s, or other - * wildcards when using FindFirstFile to recover the true file name. - */ -static apr_status_t test_safe_name(const char *name) -{ - /* Only accept ':' in the second position of the filename, - * as the drive letter delimiter: - */ - if (apr_isalpha(*name) && (name[1] == ':')) { - name += 2; - } - while (*name) { - if (!IS_FNCHAR(*name) && (*name != '\\') && (*name != '/')) { - if (*name == '?' || *name == '*') - return APR_EPATHWILD; - else - return APR_EBADPATH; - } - ++name; - } - return APR_SUCCESS; -} - -static apr_status_t free_localheap(void *heap) { - LocalFree(heap); - return APR_SUCCESS; -} - -static apr_gid_t worldid = NULL; - -static void free_world(void) -{ - if (worldid) { - FreeSid(worldid); - worldid = NULL; - } -} - -/* Left bit shifts from World scope to given scope */ -typedef enum prot_scope_e { - prot_scope_world = 0, - prot_scope_group = 4, - prot_scope_user = 8 -} prot_scope_e; - -static apr_fileperms_t convert_prot(ACCESS_MASK acc, prot_scope_e scope) -{ - /* These choices are based on the single filesystem bit that controls - * the given behavior. They are -not- recommended for any set protection - * function, such a function should -set- use GENERIC_READ/WRITE/EXECUTE - */ - apr_fileperms_t prot = 0; - if (acc & FILE_EXECUTE) - prot |= APR_WEXECUTE; - if (acc & FILE_WRITE_DATA) - prot |= APR_WWRITE; - if (acc & FILE_READ_DATA) - prot |= APR_WREAD; - return (prot << scope); -} - -static void resolve_prot(apr_finfo_t *finfo, apr_int32_t wanted, PACL dacl) -{ - TRUSTEE_W ident = {NULL, NO_MULTIPLE_TRUSTEE, TRUSTEE_IS_SID}; - ACCESS_MASK acc; - /* - * This function is only invoked for WinNT, - * there is no reason for os_level testing here. - */ - if ((wanted & APR_FINFO_WPROT) && !worldid) { - SID_IDENTIFIER_AUTHORITY SIDAuth = {SECURITY_WORLD_SID_AUTHORITY}; - if (AllocateAndInitializeSid(&SIDAuth, 1, SECURITY_WORLD_RID, - 0, 0, 0, 0, 0, 0, 0, &worldid)) - atexit(free_world); - else - worldid = NULL; - } - if ((wanted & APR_FINFO_UPROT) && (finfo->valid & APR_FINFO_USER)) { - ident.TrusteeType = TRUSTEE_IS_USER; - ident.ptstrName = finfo->user; - /* GetEffectiveRightsFromAcl isn't supported under Win9x, - * which shouldn't come as a surprize. Since we are passing - * TRUSTEE_IS_SID, always skip the A->W layer. - */ - if (GetEffectiveRightsFromAclW(dacl, &ident, &acc) == ERROR_SUCCESS) { - finfo->protection |= convert_prot(acc, prot_scope_user); - finfo->valid |= APR_FINFO_UPROT; - } - } - /* Windows NT: did not return group rights. - * Windows 2000 returns group rights information. - * Since WinNT kernels don't follow the unix model of - * group associations, this all all pretty mute. - */ - if ((wanted & APR_FINFO_GPROT) && (finfo->valid & APR_FINFO_GROUP)) { - ident.TrusteeType = TRUSTEE_IS_GROUP; - ident.ptstrName = finfo->group; - if (GetEffectiveRightsFromAclW(dacl, &ident, &acc) == ERROR_SUCCESS) { - finfo->protection |= convert_prot(acc, prot_scope_group); - finfo->valid |= APR_FINFO_GPROT; - } - } - if ((wanted & APR_FINFO_WPROT) && (worldid)) { - ident.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP; - ident.ptstrName = worldid; - if (GetEffectiveRightsFromAclW(dacl, &ident, &acc) == ERROR_SUCCESS) { - finfo->protection |= convert_prot(acc, prot_scope_world); - finfo->valid |= APR_FINFO_WPROT; - } - } -} - -static apr_status_t resolve_ident(apr_finfo_t *finfo, const char *fname, - apr_int32_t wanted, apr_pool_t *pool) -{ - apr_file_t *thefile = NULL; - apr_status_t rv; - /* - * NT5 (W2K) only supports symlinks in the same manner as mount points. - * This code should eventually take that into account, for now treat - * every reparse point as a symlink... - * - * We must open the file with READ_CONTROL if we plan to retrieve the - * user, group or permissions. - */ - - if ((rv = apr_file_open(&thefile, fname, APR_OPENINFO - | ((wanted & APR_FINFO_LINK) ? APR_OPENLINK : 0) - | ((wanted & (APR_FINFO_PROT | APR_FINFO_OWNER)) - ? APR_READCONTROL : 0), - APR_OS_DEFAULT, pool)) == APR_SUCCESS) { - rv = apr_file_info_get(finfo, wanted, thefile); - finfo->filehand = NULL; - apr_file_close(thefile); - } - else if (APR_STATUS_IS_EACCES(rv) && (wanted & (APR_FINFO_PROT - | APR_FINFO_OWNER))) { - /* We have a backup plan. Perhaps we couldn't grab READ_CONTROL? - * proceed without asking for that permission... - */ - if ((rv = apr_file_open(&thefile, fname, APR_OPENINFO - | ((wanted & APR_FINFO_LINK) ? APR_OPENLINK : 0), - APR_OS_DEFAULT, pool)) == APR_SUCCESS) { - rv = apr_file_info_get(finfo, wanted & ~(APR_FINFO_PROT - | APR_FINFO_OWNER), - thefile); - finfo->filehand = NULL; - apr_file_close(thefile); - } - } - - if (rv != APR_SUCCESS && rv != APR_INCOMPLETE) - return (rv); - - /* We picked up this case above and had opened the link's properties */ - if (wanted & APR_FINFO_LINK) - finfo->valid |= APR_FINFO_LINK; - - return rv; -} - -static apr_status_t guess_protection_bits(apr_finfo_t *finfo, - apr_int32_t wanted) -{ - /* Read, write execute for owner. In the Win9x environment, any - * readable file is executable (well, not entirely 100% true, but - * still looking for some cheap logic that would help us here.) - * The same holds on NT if a file doesn't have a DACL (e.g., on FAT) - */ - if (finfo->protection & APR_FREADONLY) { - finfo->protection |= APR_WREAD | APR_WEXECUTE; - } - else { - finfo->protection |= APR_WREAD | APR_WEXECUTE | APR_WWRITE; - } - finfo->protection |= (finfo->protection << prot_scope_group) - | (finfo->protection << prot_scope_user); - - finfo->valid |= APR_FINFO_UPROT | APR_FINFO_GPROT | APR_FINFO_WPROT; - - return ((wanted & ~finfo->valid) ? APR_INCOMPLETE : APR_SUCCESS); -} - -apr_status_t more_finfo(apr_finfo_t *finfo, const void *ufile, - apr_int32_t wanted, int whatfile) -{ - PSID user = NULL, grp = NULL; - PACL dacl = NULL; - apr_status_t rv; - - if (apr_os_level < APR_WIN_NT) - return guess_protection_bits(finfo, wanted); - - if (wanted & (APR_FINFO_PROT | APR_FINFO_OWNER)) - { - /* On NT this request is incredibly expensive, but accurate. - * Since the WinNT-only functions below are protected by the - * (apr_os_level < APR_WIN_NT) case above, we need no extra - * tests, but remember GetNamedSecurityInfo & GetSecurityInfo - * are not supported on 9x. - */ - SECURITY_INFORMATION sinf = 0; - PSECURITY_DESCRIPTOR pdesc = NULL; - if (wanted & (APR_FINFO_USER | APR_FINFO_UPROT)) - sinf |= OWNER_SECURITY_INFORMATION; - if (wanted & (APR_FINFO_GROUP | APR_FINFO_GPROT)) - sinf |= GROUP_SECURITY_INFORMATION; - if (wanted & APR_FINFO_PROT) - sinf |= DACL_SECURITY_INFORMATION; - if (whatfile == MORE_OF_WFSPEC) { - apr_wchar_t *wfile = (apr_wchar_t*) ufile; - int fix = 0; - if (wcsncmp(wfile, L"\\\\?\\", 4) == 0) { - fix = 4; - if (wcsncmp(wfile + fix, L"UNC\\", 4) == 0) - wfile[6] = L'\\', fix = 6; - } - rv = GetNamedSecurityInfoW(wfile + fix, - SE_FILE_OBJECT, sinf, - ((wanted & (APR_FINFO_USER | APR_FINFO_UPROT)) ? &user : NULL), - ((wanted & (APR_FINFO_GROUP | APR_FINFO_GPROT)) ? &grp : NULL), - ((wanted & APR_FINFO_PROT) ? &dacl : NULL), - NULL, &pdesc); - if (fix == 6) - wfile[6] = L'C'; - } - else if (whatfile == MORE_OF_FSPEC) - rv = GetNamedSecurityInfoA((char*)ufile, - SE_FILE_OBJECT, sinf, - ((wanted & (APR_FINFO_USER | APR_FINFO_UPROT)) ? &user : NULL), - ((wanted & (APR_FINFO_GROUP | APR_FINFO_GPROT)) ? &grp : NULL), - ((wanted & APR_FINFO_PROT) ? &dacl : NULL), - NULL, &pdesc); - else if (whatfile == MORE_OF_HANDLE) - rv = GetSecurityInfo((HANDLE)ufile, - SE_FILE_OBJECT, sinf, - ((wanted & (APR_FINFO_USER | APR_FINFO_UPROT)) ? &user : NULL), - ((wanted & (APR_FINFO_GROUP | APR_FINFO_GPROT)) ? &grp : NULL), - ((wanted & APR_FINFO_PROT) ? &dacl : NULL), - NULL, &pdesc); - else - return APR_INCOMPLETE; /* should not occur */ - if (rv == ERROR_SUCCESS) - apr_pool_cleanup_register(finfo->pool, pdesc, free_localheap, - apr_pool_cleanup_null); - else - user = grp = dacl = NULL; - - if (user) { - finfo->user = user; - finfo->valid |= APR_FINFO_USER; - } - - if (grp) { - finfo->group = grp; - finfo->valid |= APR_FINFO_GROUP; - } - - if (dacl) { - /* Retrieved the discresionary access list */ - resolve_prot(finfo, wanted, dacl); - } - else if (wanted & APR_FINFO_PROT) - guess_protection_bits(finfo, wanted); - } - - if ((apr_os_level >= APR_WIN_2000) && (wanted & APR_FINFO_CSIZE) - && (finfo->filetype == APR_REG)) - { - DWORD sizelo, sizehi; - if (whatfile == MORE_OF_HANDLE) { - /* Not available for development and implementation under - * a reasonable license; if you review the licensing - * terms and conditions of; - * http://go.microsoft.com/fwlink/?linkid=84083 - * you probably understand why APR chooses not to implement. - */ - IOSB sb; - FSI fi; - if ((ZwQueryInformationFile((HANDLE)ufile, &sb, - &fi, sizeof(fi), 5) == 0) - && (sb.Status == 0)) { - finfo->csize = fi.AllocationSize; - finfo->valid |= APR_FINFO_CSIZE; - } - } - else { - SetLastError(NO_ERROR); - if (whatfile == MORE_OF_WFSPEC) - sizelo = GetCompressedFileSizeW((apr_wchar_t*)ufile, &sizehi); - else if (whatfile == MORE_OF_FSPEC) - sizelo = GetCompressedFileSizeA((char*)ufile, &sizehi); - else - return APR_EGENERAL; /* should not occur */ - - if (sizelo != INVALID_FILE_SIZE || GetLastError() == NO_ERROR) { -#if APR_HAS_LARGE_FILES - finfo->csize = (apr_off_t)sizelo - | ((apr_off_t)sizehi << 32); -#else - finfo->csize = (apr_off_t)sizelo; - if (finfo->csize < 0 || sizehi) - finfo->csize = 0x7fffffff; -#endif - finfo->valid |= APR_FINFO_CSIZE; - } - } - } - return ((wanted & ~finfo->valid) ? APR_INCOMPLETE : APR_SUCCESS); -} - - -/* This generic fillin depends upon byhandle to be passed as 0 when - * a WIN32_FILE_ATTRIBUTE_DATA or either WIN32_FIND_DATA [A or W] is - * passed for wininfo. When the BY_HANDLE_FILE_INFORMATION structure - * is passed for wininfo, byhandle is passed as 1 to offset the one - * dword discrepancy in offset of the High/Low size structure members. - * - * The generic fillin returns 1 if the caller should further inquire - * if this is a CHR filetype. If it's reasonably certain it can't be, - * then the function returns 0. - */ -int fillin_fileinfo(apr_finfo_t *finfo, - WIN32_FILE_ATTRIBUTE_DATA *wininfo, - int byhandle, apr_int32_t wanted) -{ - DWORD *sizes = &wininfo->nFileSizeHigh + byhandle; - int warn = 0; - - memset(finfo, '\0', sizeof(*finfo)); - - FileTimeToAprTime(&finfo->atime, &wininfo->ftLastAccessTime); - FileTimeToAprTime(&finfo->ctime, &wininfo->ftCreationTime); - FileTimeToAprTime(&finfo->mtime, &wininfo->ftLastWriteTime); - -#if APR_HAS_LARGE_FILES - finfo->size = (apr_off_t)sizes[1] - | ((apr_off_t)sizes[0] << 32); -#else - finfo->size = (apr_off_t)sizes[1]; - if (finfo->size < 0 || sizes[0]) - finfo->size = 0x7fffffff; -#endif - - if (wanted & APR_FINFO_LINK && - wininfo->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { - finfo->filetype = APR_LNK; - } - else if (wininfo->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - finfo->filetype = APR_DIR; - } - else if (wininfo->dwFileAttributes & FILE_ATTRIBUTE_DEVICE) { - /* Warning: This test only succeeds on Win9x, on NT these files - * (con, aux, nul, lpt#, com# etc) escape early detection! - */ - finfo->filetype = APR_CHR; - } - else { - /* Warning: Short of opening the handle to the file, the 'FileType' - * appears to be unknowable (in any trustworthy or consistent sense) - * on WinNT/2K as far as PIPE, CHR, etc are concerned. - */ - if (!wininfo->ftLastWriteTime.dwLowDateTime - && !wininfo->ftLastWriteTime.dwHighDateTime - && !finfo->size) - warn = 1; - finfo->filetype = APR_REG; - } - - /* The following flags are [for this moment] private to Win32. - * That's the only excuse for not toggling valid bits to reflect them. - */ - if (wininfo->dwFileAttributes & FILE_ATTRIBUTE_READONLY) - finfo->protection = APR_FREADONLY; - - finfo->valid = APR_FINFO_ATIME | APR_FINFO_CTIME | APR_FINFO_MTIME - | APR_FINFO_SIZE | APR_FINFO_TYPE; /* == APR_FINFO_MIN */ - - /* Only byhandle optionally tests link targets, so tell that caller - * what it wants to hear, otherwise the byattributes is never - * reporting anything but the link. - */ - if (!byhandle || (wanted & APR_FINFO_LINK)) - finfo->valid |= APR_FINFO_LINK; - return warn; -} - - -APR_DECLARE(apr_status_t) apr_file_info_get(apr_finfo_t *finfo, apr_int32_t wanted, - apr_file_t *thefile) -{ - BY_HANDLE_FILE_INFORMATION FileInfo; - - if (thefile->buffered) { - /* XXX: flush here is not mutex protected */ - apr_status_t rv = apr_file_flush(thefile); - if (rv != APR_SUCCESS) - return rv; - } - - if (!GetFileInformationByHandle(thefile->filehand, &FileInfo)) { - return apr_get_os_error(); - } - - fillin_fileinfo(finfo, (WIN32_FILE_ATTRIBUTE_DATA *) &FileInfo, 1, wanted); - - if (finfo->filetype == APR_REG) - { - /* Go the extra mile to be -certain- that we have a real, regular - * file, since the attribute bits aren't a certain thing. Even - * though fillin should have hinted if we *must* do this, we - * don't need to take chances while the handle is already open. - */ - DWORD FileType; - if ((FileType = GetFileType(thefile->filehand))) { - if (FileType == FILE_TYPE_CHAR) { - finfo->filetype = APR_CHR; - } - else if (FileType == FILE_TYPE_PIPE) { - finfo->filetype = APR_PIPE; - } - /* Otherwise leave the original conclusion alone - */ - } - } - - finfo->pool = thefile->pool; - - /* ### The finfo lifetime may exceed the lifetime of thefile->pool - * but finfo's aren't managed in pools, so where on earth would - * we pstrdup the fname into??? - */ - finfo->fname = thefile->fname; - - /* Extra goodies known only by GetFileInformationByHandle() */ - finfo->inode = (apr_ino_t)FileInfo.nFileIndexLow - | ((apr_ino_t)FileInfo.nFileIndexHigh << 32); - finfo->device = FileInfo.dwVolumeSerialNumber; - finfo->nlink = FileInfo.nNumberOfLinks; - - finfo->valid |= APR_FINFO_IDENT | APR_FINFO_NLINK; - - /* If we still want something more (besides the name) go get it! - */ - if ((wanted &= ~finfo->valid) & ~APR_FINFO_NAME) { - return more_finfo(finfo, thefile->filehand, wanted, MORE_OF_HANDLE); - } - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_perms_set(const char *fname, - apr_fileperms_t perms) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, - apr_int32_t wanted, apr_pool_t *pool) -{ - /* XXX: is constant - needs testing - which requires a lighter-weight root test fn */ - int isroot = 0; - apr_status_t ident_rv = 0; - apr_status_t rv; -#if APR_HAS_UNICODE_FS - apr_wchar_t wfname[APR_PATH_MAX]; - -#endif - char *filename = NULL; - /* These all share a common subset of this structure */ - union { - WIN32_FIND_DATAW w; - WIN32_FIND_DATAA n; - WIN32_FILE_ATTRIBUTE_DATA i; - } FileInfo; - - /* Catch fname length == MAX_PATH since GetFileAttributesEx fails - * with PATH_NOT_FOUND. We would rather indicate length error than - * 'not found' - */ - if (strlen(fname) >= APR_PATH_MAX) { - return APR_ENAMETOOLONG; - } - -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - if ((wanted & (APR_FINFO_IDENT | APR_FINFO_NLINK)) - || (~wanted & APR_FINFO_LINK)) { - /* FindFirstFile and GetFileAttributesEx can't figure the inode, - * device or number of links, so we need to resolve with an open - * file handle. If the user has asked for these fields, fall over - * to the get file info by handle method. If we fail, or the user - * also asks for the file name, continue by our usual means. - * - * We also must use this method for a 'true' stat, that resolves - * a symlink (NTFS Junction) target. This is because all fileinfo - * on a Junction always returns the junction, opening the target - * is the only way to resolve the target's attributes. - */ - if ((ident_rv = resolve_ident(finfo, fname, wanted, pool)) - == APR_SUCCESS) - return ident_rv; - else if (ident_rv == APR_INCOMPLETE) - wanted &= ~finfo->valid; - } - - if ((rv = utf8_to_unicode_path(wfname, sizeof(wfname) - / sizeof(apr_wchar_t), fname))) - return rv; - if (!(wanted & APR_FINFO_NAME)) { - if (!GetFileAttributesExW(wfname, GetFileExInfoStandard, - &FileInfo.i)) - return apr_get_os_error(); - } - else { - /* Guard against bogus wildcards and retrieve by name - * since we want the true name, and set aside a long - * enough string to handle the longest file name. - */ - char tmpname[APR_FILE_MAX * 3 + 1]; - HANDLE hFind; - if ((rv = test_safe_name(fname)) != APR_SUCCESS) { - return rv; - } - hFind = FindFirstFileW(wfname, &FileInfo.w); - if (hFind == INVALID_HANDLE_VALUE) - return apr_get_os_error(); - FindClose(hFind); - if (unicode_to_utf8_path(tmpname, sizeof(tmpname), - FileInfo.w.cFileName)) { - return APR_ENAMETOOLONG; - } - filename = apr_pstrdup(pool, tmpname); - } - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - char *root = NULL; - const char *test = fname; - rv = apr_filepath_root(&root, &test, APR_FILEPATH_NATIVE, pool); - isroot = (root && *root && !(*test)); - - if ((apr_os_level >= APR_WIN_98) && (!(wanted & APR_FINFO_NAME) || isroot)) - { - /* cannot use FindFile on a Win98 root, it returns \* - * GetFileAttributesExA is not available on Win95 - */ - if (!GetFileAttributesExA(fname, GetFileExInfoStandard, - &FileInfo.i)) { - return apr_get_os_error(); - } - } - else if (isroot) { - /* This is Win95 and we are trying to stat a root. Lie. - */ - if (GetDriveType(fname) != DRIVE_UNKNOWN) - { - finfo->pool = pool; - finfo->filetype = 0; - finfo->mtime = apr_time_now(); - finfo->protection |= APR_WREAD | APR_WEXECUTE | APR_WWRITE; - finfo->protection |= (finfo->protection << prot_scope_group) - | (finfo->protection << prot_scope_user); - finfo->valid |= APR_FINFO_TYPE | APR_FINFO_PROT - | APR_FINFO_MTIME - | (wanted & APR_FINFO_LINK); - return (wanted &= ~finfo->valid) ? APR_INCOMPLETE - : APR_SUCCESS; - } - else - return APR_FROM_OS_ERROR(ERROR_PATH_NOT_FOUND); - } - else { - /* Guard against bogus wildcards and retrieve by name - * since we want the true name, or are stuck in Win95, - * or are looking for the root of a Win98 drive. - */ - HANDLE hFind; - if ((rv = test_safe_name(fname)) != APR_SUCCESS) { - return rv; - } - hFind = FindFirstFileA(fname, &FileInfo.n); - if (hFind == INVALID_HANDLE_VALUE) { - return apr_get_os_error(); - } - FindClose(hFind); - filename = apr_pstrdup(pool, FileInfo.n.cFileName); - } - } -#endif - - if (ident_rv != APR_INCOMPLETE) { - if (fillin_fileinfo(finfo, (WIN32_FILE_ATTRIBUTE_DATA *) &FileInfo, - 0, wanted)) - { - /* Go the extra mile to assure we have a file. WinNT/2000 seems - * to reliably translate char devices to the path '\\.\device' - * so go ask for the full path. - */ - if (apr_os_level >= APR_WIN_NT) - { -#if APR_HAS_UNICODE_FS - apr_wchar_t tmpname[APR_FILE_MAX]; - apr_wchar_t *tmpoff = NULL; - if (GetFullPathNameW(wfname, sizeof(tmpname) / sizeof(apr_wchar_t), - tmpname, &tmpoff)) - { - if (!wcsncmp(tmpname, L"\\\\.\\", 4)) { -#else - /* Same initial logic as above, but - * only for WinNT/non-UTF-8 builds of APR: - */ - char tmpname[APR_FILE_MAX]; - char *tmpoff; - if (GetFullPathName(fname, sizeof(tmpname), tmpname, &tmpoff)) - { - if (!strncmp(tmpname, "\\\\.\\", 4)) { -#endif - if (tmpoff == tmpname + 4) { - finfo->filetype = APR_CHR; - } - /* For WHATEVER reason, CHR devices such as \\.\con - * or \\.\lpt1 *may*not* update tmpoff; in fact the - * resulting tmpoff is set to NULL. Guard against - * either case. - * - * This code is identical for wide and narrow chars... - */ - else if (!tmpoff) { - tmpoff = tmpname + 4; - while (*tmpoff) { - if (*tmpoff == '\\' || *tmpoff == '/') { - break; - } - ++tmpoff; - } - if (!*tmpoff) { - finfo->filetype = APR_CHR; - } - } - } - } - else { - finfo->valid &= ~APR_FINFO_TYPE; - } - - } - else { - finfo->valid &= ~APR_FINFO_TYPE; - } - } - finfo->pool = pool; - } - - if (filename && !isroot) { - finfo->name = filename; - finfo->valid |= APR_FINFO_NAME; - } - - if (wanted &= ~finfo->valid) { - /* Caller wants more than APR_FINFO_MIN | APR_FINFO_NAME */ -#if APR_HAS_UNICODE_FS - if (apr_os_level >= APR_WIN_NT) - return more_finfo(finfo, wfname, wanted, MORE_OF_WFSPEC); -#endif - return more_finfo(finfo, fname, wanted, MORE_OF_FSPEC); - } - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, - apr_fileattrs_t attributes, - apr_fileattrs_t attr_mask, - apr_pool_t *pool) -{ - DWORD flags; - apr_status_t rv; -#if APR_HAS_UNICODE_FS - apr_wchar_t wfname[APR_PATH_MAX]; -#endif - - /* Don't do anything if we can't handle the requested attributes */ - if (!(attr_mask & (APR_FILE_ATTR_READONLY - | APR_FILE_ATTR_HIDDEN))) - return APR_SUCCESS; - -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - if ((rv = utf8_to_unicode_path(wfname, - sizeof(wfname) / sizeof(wfname[0]), - fname))) - return rv; - flags = GetFileAttributesW(wfname); - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - flags = GetFileAttributesA(fname); - } -#endif - - if (flags == 0xFFFFFFFF) - return apr_get_os_error(); - - if (attr_mask & APR_FILE_ATTR_READONLY) - { - if (attributes & APR_FILE_ATTR_READONLY) - flags |= FILE_ATTRIBUTE_READONLY; - else - flags &= ~FILE_ATTRIBUTE_READONLY; - } - - if (attr_mask & APR_FILE_ATTR_HIDDEN) - { - if (attributes & APR_FILE_ATTR_HIDDEN) - flags |= FILE_ATTRIBUTE_HIDDEN; - else - flags &= ~FILE_ATTRIBUTE_HIDDEN; - } - -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - rv = SetFileAttributesW(wfname, flags); - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - rv = SetFileAttributesA(fname, flags); - } -#endif - - if (rv == 0) - return apr_get_os_error(); - - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname, - apr_time_t mtime, - apr_pool_t *pool) -{ - apr_file_t *thefile; - apr_status_t rv; - - rv = apr_file_open(&thefile, fname, - APR_FOPEN_READ | APR_WRITEATTRS, - APR_OS_DEFAULT, pool); - if (!rv) - { - FILETIME file_ctime; - FILETIME file_atime; - FILETIME file_mtime; - - if (!GetFileTime(thefile->filehand, - &file_ctime, &file_atime, &file_mtime)) - rv = apr_get_os_error(); - else - { - AprTimeToFileTime(&file_mtime, mtime); - if (!SetFileTime(thefile->filehand, - &file_ctime, &file_atime, &file_mtime)) - rv = apr_get_os_error(); - } - - apr_file_close(thefile); - } - - return rv; -} diff --git a/libs/apr/file_io/win32/filesys.c b/libs/apr/file_io/win32/filesys.c deleted file mode 100644 index e8121395..00000000 --- a/libs/apr/file_io/win32/filesys.c +++ /dev/null @@ -1,229 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_arch_file_io.h" -#include "apr_strings.h" - -/* Win32 Exceptions: - * - * Note that trailing spaces and trailing periods are never recorded - * in the file system, except by a very obscure bug where any file - * that is created with a trailing space or period, followed by the - * ':' stream designator on an NTFS volume can never be accessed again. - * In other words, don't ever accept them when designating a stream! - * - * An interesting side effect is that two or three periods are both - * treated as the parent directory, although the fourth and on are - * not [strongly suggest all trailing periods are trimmed off, or - * down to two if there are no other characters.] - * - * Leading spaces and periods are accepted, however. - * The * ? < > codes all have wildcard side effects - * The " / \ : are exclusively component separator tokens - * The system doesn't accept | for any (known) purpose - * Oddly, \x7f _is_ acceptable ;) - */ - -/* apr_c_is_fnchar[] maps Win32's file name and shell escape symbols - * - * element & 1 == valid file name character [excluding delimiters] - * element & 2 == character should be shell (caret) escaped from cmd.exe - * - * this must be in-sync with Apache httpd's gen_test_char.c for cgi escaping. - */ - -const char apr_c_is_fnchar[256] = -{/* Reject all ctrl codes... Escape \n and \r (ascii 10 and 13) */ - 0,0,0,0,0,0,0,0,0,0,2,0,0,2,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - /* ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ - 1,1,2,1,3,3,3,3,3,3,2,1,1,1,1,0, 1,1,1,1,1,1,1,1,1,1,0,3,2,1,2,2, - /* @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ */ - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,3,2,3,3,1, - /* ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ */ - 3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,3,2,3,3,1, - /* High bit codes are accepted (subject to utf-8->Unicode xlation) */ - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 -}; - - -apr_status_t filepath_root_test(char *path, apr_pool_t *p) -{ - apr_status_t rv; -#if APR_HAS_UNICODE_FS - if (apr_os_level >= APR_WIN_NT) - { - apr_wchar_t wpath[APR_PATH_MAX]; - if ((rv = utf8_to_unicode_path(wpath, sizeof(wpath) - / sizeof(apr_wchar_t), path))) - return rv; - rv = GetDriveTypeW(wpath); - } - else -#endif - rv = GetDriveType(path); - - if (rv == DRIVE_UNKNOWN || rv == DRIVE_NO_ROOT_DIR) - return APR_EBADPATH; - return APR_SUCCESS; -} - - -apr_status_t filepath_drive_get(char **rootpath, char drive, - apr_int32_t flags, apr_pool_t *p) -{ - char path[APR_PATH_MAX]; -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - apr_wchar_t *ignored; - apr_wchar_t wdrive[8]; - apr_wchar_t wpath[APR_PATH_MAX]; - apr_status_t rv; - /* ???: This needs review, apparently "\\?\d:." returns "\\?\d:" - * as if that is useful for anything. - */ - wcscpy(wdrive, L"D:."); - wdrive[0] = (apr_wchar_t)(unsigned char)drive; - if (!GetFullPathNameW(wdrive, sizeof(wpath) / sizeof(apr_wchar_t), wpath, &ignored)) - return apr_get_os_error(); - if ((rv = unicode_to_utf8_path(path, sizeof(path), wpath))) - return rv; - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - char *ignored; - char drivestr[4]; - drivestr[0] = drive; - drivestr[1] = ':'; - drivestr[2] = '.';; - drivestr[3] = '\0'; - if (!GetFullPathName(drivestr, sizeof(path), path, &ignored)) - return apr_get_os_error(); - } -#endif - if (!(flags & APR_FILEPATH_NATIVE)) { - for (*rootpath = path; **rootpath; ++*rootpath) { - if (**rootpath == '\\') - **rootpath = '/'; - } - } - *rootpath = apr_pstrdup(p, path); - return APR_SUCCESS; -} - - -apr_status_t filepath_root_case(char **rootpath, char *root, apr_pool_t *p) -{ -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - apr_wchar_t *ignored; - apr_wchar_t wpath[APR_PATH_MAX]; - apr_status_t rv; - apr_wchar_t wroot[APR_PATH_MAX]; - /* ???: This needs review, apparently "\\?\d:." returns "\\?\d:" - * as if that is useful for anything. - */ - if ((rv = utf8_to_unicode_path(wroot, sizeof(wroot) - / sizeof(apr_wchar_t), root))) - return rv; - if (!GetFullPathNameW(wroot, sizeof(wpath) / sizeof(apr_wchar_t), wpath, &ignored)) - return apr_get_os_error(); - - /* Borrow wroot as a char buffer (twice as big as necessary) - */ - if ((rv = unicode_to_utf8_path((char*)wroot, sizeof(wroot), wpath))) - return rv; - *rootpath = apr_pstrdup(p, (char*)wroot); - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - char path[APR_PATH_MAX]; - char *ignored; - if (!GetFullPathName(root, sizeof(path), path, &ignored)) - return apr_get_os_error(); - *rootpath = apr_pstrdup(p, path); - } -#endif - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_filepath_get(char **rootpath, apr_int32_t flags, - apr_pool_t *p) -{ - char path[APR_PATH_MAX]; -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - apr_wchar_t wpath[APR_PATH_MAX]; - apr_status_t rv; - if (!GetCurrentDirectoryW(sizeof(wpath) / sizeof(apr_wchar_t), wpath)) - return apr_get_os_error(); - if ((rv = unicode_to_utf8_path(path, sizeof(path), wpath))) - return rv; - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - if (!GetCurrentDirectory(sizeof(path), path)) - return apr_get_os_error(); - } -#endif - if (!(flags & APR_FILEPATH_NATIVE)) { - for (*rootpath = path; **rootpath; ++*rootpath) { - if (**rootpath == '\\') - **rootpath = '/'; - } - } - *rootpath = apr_pstrdup(p, path); - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_filepath_set(const char *rootpath, - apr_pool_t *p) -{ -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - apr_wchar_t wpath[APR_PATH_MAX]; - apr_status_t rv; - if ((rv = utf8_to_unicode_path(wpath, sizeof(wpath) - / sizeof(apr_wchar_t), rootpath))) - return rv; - if (!SetCurrentDirectoryW(wpath)) - return apr_get_os_error(); - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - if (!SetCurrentDirectory(rootpath)) - return apr_get_os_error(); - } -#endif - return APR_SUCCESS; -} diff --git a/libs/apr/file_io/win32/flock.c b/libs/apr/file_io/win32/flock.c deleted file mode 100644 index e08e08a7..00000000 --- a/libs/apr/file_io/win32/flock.c +++ /dev/null @@ -1,86 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_file_io.h" - -APR_DECLARE(apr_status_t) apr_file_lock(apr_file_t *thefile, int type) -{ -#ifdef _WIN32_WCE - /* The File locking is unsuported on WCE */ - return APR_ENOTIMPL; -#else - const DWORD len = 0xffffffff; - DWORD flags; - - flags = ((type & APR_FLOCK_NONBLOCK) ? LOCKFILE_FAIL_IMMEDIATELY : 0) - + (((type & APR_FLOCK_TYPEMASK) == APR_FLOCK_SHARED) - ? 0 : LOCKFILE_EXCLUSIVE_LOCK); - if (apr_os_level >= APR_WIN_NT) { - /* Syntax is correct, len is passed for LengthLow and LengthHigh*/ - OVERLAPPED offset; - memset (&offset, 0, sizeof(offset)); - if (!LockFileEx(thefile->filehand, flags, 0, len, len, &offset)) - return apr_get_os_error(); - } - else { - /* On Win9x, LockFile() never blocks. Hack in a crufty poll. - * - * Note that this hack exposes threads to being unserviced forever, - * in the situation that the given lock has low availability. - * When implemented in the kernel, LockFile will typically use - * FIFO or round robin distribution to ensure all threads get - * one crack at the lock; but in this case we can't emulate that. - * - * However Win9x are barely maintainable anyways, if the user does - * choose to build to them, this is the best we can do. - */ - while (!LockFile(thefile->filehand, 0, 0, len, 0)) { - DWORD err = GetLastError(); - if ((err == ERROR_LOCK_VIOLATION) && !(type & APR_FLOCK_NONBLOCK)) - { - Sleep(500); /* pause for a half second */ - continue; /* ... and then poll again */ - } - return APR_FROM_OS_ERROR(err); - } - } - - return APR_SUCCESS; -#endif /* !defined(_WIN32_WCE) */ -} - -APR_DECLARE(apr_status_t) apr_file_unlock(apr_file_t *thefile) -{ -#ifdef _WIN32_WCE - return APR_ENOTIMPL; -#else - DWORD len = 0xffffffff; - - if (apr_os_level >= APR_WIN_NT) { - /* Syntax is correct, len is passed for LengthLow and LengthHigh*/ - OVERLAPPED offset; - memset (&offset, 0, sizeof(offset)); - if (!UnlockFileEx(thefile->filehand, 0, len, len, &offset)) - return apr_get_os_error(); - } - else { - if (!UnlockFile(thefile->filehand, 0, 0, len, 0)) - return apr_get_os_error(); - } - - return APR_SUCCESS; -#endif /* !defined(_WIN32_WCE) */ -} diff --git a/libs/apr/file_io/win32/open.c b/libs/apr/file_io/win32/open.c deleted file mode 100644 index e683fa56..00000000 --- a/libs/apr/file_io/win32/open.c +++ /dev/null @@ -1,753 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_private.h" -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_thread_mutex.h" -#if APR_HAVE_ERRNO_H -#include -#endif -#include -#include -#if APR_HAVE_SYS_STAT_H -#include -#endif -#include "apr_arch_misc.h" -#include "apr_arch_inherit.h" -#include -#include - -#if APR_HAS_UNICODE_FS -apr_status_t utf8_to_unicode_path(apr_wchar_t* retstr, apr_size_t retlen, - const char* srcstr) -{ - /* TODO: The computations could preconvert the string to determine - * the true size of the retstr, but that's a memory over speed - * tradeoff that isn't appropriate this early in development. - * - * Allocate the maximum string length based on leading 4 - * characters of \\?\ (allowing nearly unlimited path lengths) - * plus the trailing null, then transform /'s into \\'s since - * the \\?\ form doesn't allow '/' path seperators. - * - * Note that the \\?\ form only works for local drive paths, and - * \\?\UNC\ is needed UNC paths. - */ - apr_size_t srcremains = strlen(srcstr) + 1; - apr_wchar_t *t = retstr; - apr_status_t rv; - - /* This is correct, we don't twist the filename if it is will - * definately be shorter than 248 characters. It merits some - * performance testing to see if this has any effect, but there - * seem to be applications that get confused by the resulting - * Unicode \\?\ style file names, especially if they use argv[0] - * or call the Win32 API functions such as GetModuleName, etc. - * Not every application is prepared to handle such names. - * - * Note also this is shorter than MAX_PATH, as directory paths - * are actually limited to 248 characters. - * - * Note that a utf-8 name can never result in more wide chars - * than the original number of utf-8 narrow chars. - */ - if (srcremains > 248) { - if (srcstr[1] == ':' && (srcstr[2] == '/' || srcstr[2] == '\\')) { - wcscpy (retstr, L"\\\\?\\"); - retlen -= 4; - t += 4; - } - else if ((srcstr[0] == '/' || srcstr[0] == '\\') - && (srcstr[1] == '/' || srcstr[1] == '\\') - && (srcstr[2] != '?')) { - /* Skip the slashes */ - srcstr += 2; - srcremains -= 2; - wcscpy (retstr, L"\\\\?\\UNC\\"); - retlen -= 8; - t += 8; - } - } - - if ((rv = apr_conv_utf8_to_ucs2(srcstr, &srcremains, t, &retlen))) { - return (rv == APR_INCOMPLETE) ? APR_EINVAL : rv; - } - if (srcremains) { - return APR_ENAMETOOLONG; - } - for (; *t; ++t) - if (*t == L'/') - *t = L'\\'; - return APR_SUCCESS; -} - -apr_status_t unicode_to_utf8_path(char* retstr, apr_size_t retlen, - const apr_wchar_t* srcstr) -{ - /* Skip the leading 4 characters if the path begins \\?\, or substitute - * // for the \\?\UNC\ path prefix, allocating the maximum string - * length based on the remaining string, plus the trailing null. - * then transform \\'s back into /'s since the \\?\ form never - * allows '/' path seperators, and APR always uses '/'s. - */ - apr_size_t srcremains = wcslen(srcstr) + 1; - apr_status_t rv; - char *t = retstr; - if (srcstr[0] == L'\\' && srcstr[1] == L'\\' && - srcstr[2] == L'?' && srcstr[3] == L'\\') { - if (srcstr[4] == L'U' && srcstr[5] == L'N' && - srcstr[6] == L'C' && srcstr[7] == L'\\') { - srcremains -= 8; - srcstr += 8; - retstr[0] = '\\'; - retstr[1] = '\\'; - retlen -= 2; - t += 2; - } - else { - srcremains -= 4; - srcstr += 4; - } - } - - if ((rv = apr_conv_ucs2_to_utf8(srcstr, &srcremains, t, &retlen))) { - return rv; - } - if (srcremains) { - return APR_ENAMETOOLONG; - } - return APR_SUCCESS; -} -#endif - -void *res_name_from_filename(const char *file, int global, apr_pool_t *pool) -{ -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - apr_wchar_t *wpre, *wfile, *ch; - apr_size_t n = strlen(file) + 1; - apr_size_t r, d; - - if (apr_os_level >= APR_WIN_2000) { - if (global) - wpre = L"Global\\"; - else - wpre = L"Local\\"; - } - else - wpre = L""; - r = wcslen(wpre); - - if (n > 256 - r) { - file += n - 256 - r; - n = 256; - /* skip utf8 continuation bytes */ - while ((*file & 0xC0) == 0x80) { - ++file; - --n; - } - } - wfile = apr_palloc(pool, (r + n) * sizeof(apr_wchar_t)); - wcscpy(wfile, wpre); - d = n; - if (apr_conv_utf8_to_ucs2(file, &n, wfile + r, &d)) { - return NULL; - } - for (ch = wfile + r; *ch; ++ch) { - if (*ch == ':' || *ch == '/' || *ch == '\\') - *ch = '_'; - } - return wfile; - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - char *nfile, *ch; - apr_size_t n = strlen(file) + 1; - -#if !APR_HAS_UNICODE_FS - apr_size_t r, d; - char *pre; - - if (apr_os_level >= APR_WIN_2000) { - if (global) - pre = "Global\\"; - else - pre = "Local\\"; - } - else - pre = ""; - r = strlen(pre); - - if (n > 256 - r) { - file += n - 256 - r; - n = 256; - } - nfile = apr_palloc(pool, (r + n) * sizeof(apr_wchar_t)); - memcpy(nfile, pre, r); - memcpy(nfile + r, file, n); -#else - const apr_size_t r = 0; - if (n > 256) { - file += n - 256; - n = 256; - } - nfile = apr_pmemdup(pool, file, n); -#endif - for (ch = nfile + r; *ch; ++ch) { - if (*ch == ':' || *ch == '/' || *ch == '\\') - *ch = '_'; - } - return nfile; - } -#endif -} - -#if APR_HAS_UNICODE_FS -static apr_status_t make_sparse_file(apr_file_t *file) -{ - BY_HANDLE_FILE_INFORMATION info; - apr_status_t rv; - DWORD bytesread = 0; - DWORD res; - - /* test */ - - if (GetFileInformationByHandle(file->filehand, &info) - && (info.dwFileAttributes & FILE_ATTRIBUTE_SPARSE_FILE)) - return APR_SUCCESS; - - if (file->pOverlapped) { - file->pOverlapped->Offset = 0; - file->pOverlapped->OffsetHigh = 0; - } - - if (DeviceIoControl(file->filehand, FSCTL_SET_SPARSE, NULL, 0, NULL, 0, - &bytesread, file->pOverlapped)) { - rv = APR_SUCCESS; - } - else - { - rv = apr_get_os_error(); - - if (rv == APR_FROM_OS_ERROR(ERROR_IO_PENDING)) - { - do { - res = WaitForSingleObject(file->pOverlapped->hEvent, - (file->timeout > 0) - ? (DWORD)(file->timeout/1000) - : ((file->timeout == -1) - ? INFINITE : 0)); - } while (res == WAIT_ABANDONED); - - if (res != WAIT_OBJECT_0) { - CancelIo(file->filehand); - } - - if (GetOverlappedResult(file->filehand, file->pOverlapped, - &bytesread, TRUE)) - rv = APR_SUCCESS; - else - rv = apr_get_os_error(); - } - } - return rv; -} -#endif - -apr_status_t file_cleanup(void *thefile) -{ - apr_file_t *file = thefile; - apr_status_t flush_rv = APR_SUCCESS; - - if (file->filehand != INVALID_HANDLE_VALUE) { - - if (file->buffered) { - /* XXX: flush here is not mutex protected */ - flush_rv = apr_file_flush((apr_file_t *)thefile); - } - - /* In order to avoid later segfaults with handle 'reuse', - * we must protect against the case that a dup2'ed handle - * is being closed, and invalidate the corresponding StdHandle - * We also tell msvcrt when stdhandles are closed. - */ - if (file->flags & APR_STD_FLAGS) - { - if ((file->flags & APR_STD_FLAGS) == APR_STDERR_FLAG) { - _close(2); - SetStdHandle(STD_ERROR_HANDLE, INVALID_HANDLE_VALUE); - } - else if ((file->flags & APR_STD_FLAGS) == APR_STDOUT_FLAG) { - _close(1); - SetStdHandle(STD_OUTPUT_HANDLE, INVALID_HANDLE_VALUE); - } - else if ((file->flags & APR_STD_FLAGS) == APR_STDIN_FLAG) { - _close(0); - SetStdHandle(STD_INPUT_HANDLE, INVALID_HANDLE_VALUE); - } - } - else - CloseHandle(file->filehand); - - file->filehand = INVALID_HANDLE_VALUE; - } - if (file->pOverlapped && file->pOverlapped->hEvent) { - CloseHandle(file->pOverlapped->hEvent); - file->pOverlapped = NULL; - } - return flush_rv; -} - -APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname, - apr_int32_t flag, apr_fileperms_t perm, - apr_pool_t *pool) -{ - HANDLE handle = INVALID_HANDLE_VALUE; - DWORD oflags = 0; - DWORD createflags = 0; - DWORD attributes = 0; - DWORD sharemode = FILE_SHARE_READ | FILE_SHARE_WRITE; - apr_status_t rv; - - if (flag & APR_FOPEN_READ) { - oflags |= GENERIC_READ; - } - if (flag & APR_FOPEN_WRITE) { - oflags |= GENERIC_WRITE; - } - if (flag & APR_WRITEATTRS) { - oflags |= FILE_WRITE_ATTRIBUTES; - } - - if (apr_os_level >= APR_WIN_NT) - sharemode |= FILE_SHARE_DELETE; - - if (flag & APR_FOPEN_CREATE) { - if (flag & APR_FOPEN_EXCL) { - /* only create new if file does not already exist */ - createflags = CREATE_NEW; - } else if (flag & APR_FOPEN_TRUNCATE) { - /* truncate existing file or create new */ - createflags = CREATE_ALWAYS; - } else { - /* open existing but create if necessary */ - createflags = OPEN_ALWAYS; - } - } else if (flag & APR_FOPEN_TRUNCATE) { - /* only truncate if file already exists */ - createflags = TRUNCATE_EXISTING; - } else { - /* only open if file already exists */ - createflags = OPEN_EXISTING; - } - - if ((flag & APR_FOPEN_EXCL) && !(flag & APR_FOPEN_CREATE)) { - return APR_EACCES; - } - - if (flag & APR_FOPEN_DELONCLOSE) { - attributes |= FILE_FLAG_DELETE_ON_CLOSE; - } - - if (flag & APR_OPENLINK) { - attributes |= FILE_FLAG_OPEN_REPARSE_POINT; - } - - /* Without READ or WRITE, we fail unless apr called apr_file_open - * internally with the private APR_OPENINFO flag. - * - * With the APR_OPENINFO flag on NT, use the option flag - * FILE_FLAG_BACKUP_SEMANTICS to allow us to open directories. - * See the static resolve_ident() fn in file_io/win32/filestat.c - */ - if (!(flag & (APR_FOPEN_READ | APR_FOPEN_WRITE))) { - if (flag & APR_OPENINFO) { - if (apr_os_level >= APR_WIN_NT) { - attributes |= FILE_FLAG_BACKUP_SEMANTICS; - } - } - else { - return APR_EACCES; - } - if (flag & APR_READCONTROL) - oflags |= READ_CONTROL; - } - - if (flag & APR_FOPEN_XTHREAD) { - /* This win32 specific feature is required - * to allow multiple threads to work with the file. - */ - attributes |= FILE_FLAG_OVERLAPPED; - } - -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - apr_wchar_t wfname[APR_PATH_MAX]; - - if (flag & APR_FOPEN_SENDFILE_ENABLED) { - /* This feature is required to enable sendfile operations - * against the file on Win32. Also implies APR_FOPEN_XTHREAD. - */ - flag |= APR_FOPEN_XTHREAD; - attributes |= FILE_FLAG_SEQUENTIAL_SCAN | FILE_FLAG_OVERLAPPED; - } - - if ((rv = utf8_to_unicode_path(wfname, sizeof(wfname) - / sizeof(apr_wchar_t), fname))) - return rv; - handle = CreateFileW(wfname, oflags, sharemode, - NULL, createflags, attributes, 0); - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI { - handle = CreateFileA(fname, oflags, sharemode, - NULL, createflags, attributes, 0); - /* This feature is not supported on this platform. */ - flag &= ~APR_FOPEN_SENDFILE_ENABLED; - } -#endif - if (handle == INVALID_HANDLE_VALUE) { - return apr_get_os_error(); - } - - (*new) = (apr_file_t *)apr_pcalloc(pool, sizeof(apr_file_t)); - (*new)->pool = pool; - (*new)->filehand = handle; - (*new)->fname = apr_pstrdup(pool, fname); - (*new)->flags = flag; - (*new)->timeout = -1; - (*new)->ungetchar = -1; - - if (flag & APR_FOPEN_APPEND) { - (*new)->append = 1; - SetFilePointer((*new)->filehand, 0, NULL, FILE_END); - } - if (flag & APR_FOPEN_BUFFERED) { - (*new)->buffered = 1; - (*new)->buffer = apr_palloc(pool, APR_FILE_DEFAULT_BUFSIZE); - (*new)->bufsize = APR_FILE_DEFAULT_BUFSIZE; - } - /* Need the mutex to handled buffered and O_APPEND style file i/o */ - if ((*new)->buffered || (*new)->append) { - rv = apr_thread_mutex_create(&(*new)->mutex, - APR_THREAD_MUTEX_DEFAULT, pool); - if (rv) { - if (file_cleanup(*new) == APR_SUCCESS) { - apr_pool_cleanup_kill(pool, *new, file_cleanup); - } - return rv; - } - } - -#if APR_HAS_UNICODE_FS - if ((apr_os_level >= APR_WIN_2000) && ((*new)->flags & APR_FOPEN_SPARSE)) { - if ((rv = make_sparse_file(*new)) != APR_SUCCESS) - /* The great mystery; do we close the file and return an error? - * Do we add a new APR_INCOMPLETE style error saying opened, but - * NOTSPARSE? For now let's simply mark the file as not-sparse. - */ - (*new)->flags &= ~APR_FOPEN_SPARSE; - } - else -#endif - /* This feature is not supported on this platform. */ - (*new)->flags &= ~APR_FOPEN_SPARSE; - - /* Create a pollset with room for one descriptor. */ - /* ### check return codes */ - (void) apr_pollset_create(&(*new)->pollset, 1, pool, 0); - - if (!(flag & APR_FOPEN_NOCLEANUP)) { - apr_pool_cleanup_register((*new)->pool, (void *)(*new), file_cleanup, - apr_pool_cleanup_null); - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_close(apr_file_t *file) -{ - apr_status_t stat; - if ((stat = file_cleanup(file)) == APR_SUCCESS) { - apr_pool_cleanup_kill(file->pool, file, file_cleanup); - - if (file->mutex) { - apr_thread_mutex_destroy(file->mutex); - } - - return APR_SUCCESS; - } - return stat; -} - -APR_DECLARE(apr_status_t) apr_file_remove(const char *path, apr_pool_t *pool) -{ -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - apr_wchar_t wpath[APR_PATH_MAX]; - apr_status_t rv; - if ((rv = utf8_to_unicode_path(wpath, sizeof(wpath) - / sizeof(apr_wchar_t), path))) { - return rv; - } - if (DeleteFileW(wpath)) - return APR_SUCCESS; - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - if (DeleteFile(path)) - return APR_SUCCESS; -#endif - return apr_get_os_error(); -} - -APR_DECLARE(apr_status_t) apr_file_rename(const char *frompath, - const char *topath, - apr_pool_t *pool) -{ - IF_WIN_OS_IS_UNICODE - { -#if APR_HAS_UNICODE_FS - apr_wchar_t wfrompath[APR_PATH_MAX], wtopath[APR_PATH_MAX]; - apr_status_t rv; - if ((rv = utf8_to_unicode_path(wfrompath, - sizeof(wfrompath) / sizeof(apr_wchar_t), - frompath))) { - return rv; - } - if ((rv = utf8_to_unicode_path(wtopath, - sizeof(wtopath) / sizeof(apr_wchar_t), - topath))) { - return rv; - } -#ifndef _WIN32_WCE - if (MoveFileExW(wfrompath, wtopath, MOVEFILE_REPLACE_EXISTING | - MOVEFILE_COPY_ALLOWED)) -#else - if (MoveFileW(wfrompath, wtopath)) -#endif - return APR_SUCCESS; -#else - if (MoveFileEx(frompath, topath, MOVEFILE_REPLACE_EXISTING | - MOVEFILE_COPY_ALLOWED)) - return APR_SUCCESS; -#endif - } -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - /* Windows 95 and 98 do not support MoveFileEx, so we'll use - * the old MoveFile function. However, MoveFile requires that - * the new file not already exist...so we have to delete that - * file if it does. Perhaps we should back up the to-be-deleted - * file in case something happens? - */ - HANDLE handle = INVALID_HANDLE_VALUE; - - if ((handle = CreateFile(topath, GENERIC_WRITE, 0, 0, - OPEN_EXISTING, 0, 0 )) != INVALID_HANDLE_VALUE ) - { - CloseHandle(handle); - if (!DeleteFile(topath)) - return apr_get_os_error(); - } - if (MoveFile(frompath, topath)) - return APR_SUCCESS; - } -#endif - return apr_get_os_error(); -} - -APR_DECLARE(apr_status_t) apr_file_link(const char *from_path, - const char *to_path) -{ - apr_status_t rv = APR_SUCCESS; - -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - apr_wchar_t wfrom_path[APR_PATH_MAX]; - apr_wchar_t wto_path[APR_PATH_MAX]; - - if ((rv = utf8_to_unicode_path(wfrom_path, - sizeof(wfrom_path) / sizeof(apr_wchar_t), - from_path))) - return rv; - if ((rv = utf8_to_unicode_path(wto_path, - sizeof(wto_path) / sizeof(apr_wchar_t), - to_path))) - return rv; - - if (!CreateHardLinkW(wto_path, wfrom_path, NULL)) - return apr_get_os_error(); - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI { - if (!CreateHardLinkA(to_path, from_path, NULL)) - return apr_get_os_error(); - } -#endif - return rv; -} - -APR_DECLARE(apr_status_t) apr_os_file_get(apr_os_file_t *thefile, - apr_file_t *file) -{ - *thefile = file->filehand; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_file_put(apr_file_t **file, - apr_os_file_t *thefile, - apr_int32_t flags, - apr_pool_t *pool) -{ - (*file) = apr_pcalloc(pool, sizeof(apr_file_t)); - (*file)->pool = pool; - (*file)->filehand = *thefile; - (*file)->ungetchar = -1; /* no char avail */ - (*file)->timeout = -1; - (*file)->flags = flags; - - if (flags & APR_FOPEN_APPEND) { - (*file)->append = 1; - } - if (flags & APR_FOPEN_BUFFERED) { - (*file)->buffered = 1; - (*file)->buffer = apr_palloc(pool, APR_FILE_DEFAULT_BUFSIZE); - (*file)->bufsize = APR_FILE_DEFAULT_BUFSIZE; - } - - if ((*file)->append || (*file)->buffered) { - apr_status_t rv; - rv = apr_thread_mutex_create(&(*file)->mutex, - APR_THREAD_MUTEX_DEFAULT, pool); - if (rv) { - if (file_cleanup(*file) == APR_SUCCESS) { - apr_pool_cleanup_kill(pool, *file, file_cleanup); - } - return rv; - } - } - - /* Create a pollset with room for one descriptor. */ - /* ### check return codes */ - (void) apr_pollset_create(&(*file)->pollset, 1, pool, 0); - - /* Should we be testing if thefile is a handle to - * a PIPE and set up the mechanics appropriately? - * - * (*file)->pipe; - */ - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_eof(apr_file_t *fptr) -{ - if (fptr->eof_hit == 1) { - return APR_EOF; - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_open_flags_stderr(apr_file_t **thefile, - apr_int32_t flags, - apr_pool_t *pool) -{ -#ifdef _WIN32_WCE - return APR_ENOTIMPL; -#else - apr_os_file_t file_handle; - - apr_set_os_error(APR_SUCCESS); - file_handle = GetStdHandle(STD_ERROR_HANDLE); - if (!file_handle) - file_handle = INVALID_HANDLE_VALUE; - - return apr_os_file_put(thefile, &file_handle, - flags | APR_FOPEN_WRITE | APR_STDERR_FLAG, pool); -#endif -} - -APR_DECLARE(apr_status_t) apr_file_open_flags_stdout(apr_file_t **thefile, - apr_int32_t flags, - apr_pool_t *pool) -{ -#ifdef _WIN32_WCE - return APR_ENOTIMPL; -#else - apr_os_file_t file_handle; - - apr_set_os_error(APR_SUCCESS); - file_handle = GetStdHandle(STD_OUTPUT_HANDLE); - if (!file_handle) - file_handle = INVALID_HANDLE_VALUE; - - return apr_os_file_put(thefile, &file_handle, - flags | APR_FOPEN_WRITE | APR_STDOUT_FLAG, pool); -#endif -} - -APR_DECLARE(apr_status_t) apr_file_open_flags_stdin(apr_file_t **thefile, - apr_int32_t flags, - apr_pool_t *pool) -{ -#ifdef _WIN32_WCE - return APR_ENOTIMPL; -#else - apr_os_file_t file_handle; - - apr_set_os_error(APR_SUCCESS); - file_handle = GetStdHandle(STD_INPUT_HANDLE); - if (!file_handle) - file_handle = INVALID_HANDLE_VALUE; - - return apr_os_file_put(thefile, &file_handle, - flags | APR_FOPEN_READ | APR_STDIN_FLAG, pool); -#endif -} - -APR_DECLARE(apr_status_t) apr_file_open_stderr(apr_file_t **thefile, apr_pool_t *pool) -{ - return apr_file_open_flags_stderr(thefile, 0, pool); -} - -APR_DECLARE(apr_status_t) apr_file_open_stdout(apr_file_t **thefile, apr_pool_t *pool) -{ - return apr_file_open_flags_stdout(thefile, 0, pool); -} - -APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile, apr_pool_t *pool) -{ - return apr_file_open_flags_stdin(thefile, 0, pool); -} - -APR_POOL_IMPLEMENT_ACCESSOR(file); - -APR_IMPLEMENT_INHERIT_SET(file, flags, pool, file_cleanup) - -APR_IMPLEMENT_INHERIT_UNSET(file, flags, pool, file_cleanup) diff --git a/libs/apr/file_io/win32/pipe.c b/libs/apr/file_io/win32/pipe.c deleted file mode 100644 index 9344c7ae..00000000 --- a/libs/apr/file_io/win32/pipe.c +++ /dev/null @@ -1,441 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_strings.h" -#if APR_HAVE_ERRNO_H -#include -#endif -#include -#include -#if APR_HAVE_SYS_TYPES_H -#include -#endif -#if APR_HAVE_SYS_STAT_H -#include -#endif -#if APR_HAVE_PROCESS_H -#include /* for getpid() on Win32 */ -#endif -#include "apr_arch_misc.h" - -APR_DECLARE(apr_status_t) apr_file_pipe_timeout_set(apr_file_t *thepipe, - apr_interval_time_t timeout) -{ - /* Always OK to unset timeouts */ - if (timeout == -1) { - thepipe->timeout = timeout; - return APR_SUCCESS; - } - if (!thepipe->pipe) { - return APR_ENOTIMPL; - } - if (timeout && !(thepipe->pOverlapped)) { - /* Cannot be nonzero if a pipe was opened blocking */ - return APR_EINVAL; - } - thepipe->timeout = timeout; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_pipe_timeout_get(apr_file_t *thepipe, - apr_interval_time_t *timeout) -{ - /* Always OK to get the timeout (even if it's unset ... -1) */ - *timeout = thepipe->timeout; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, - apr_file_t **out, - apr_pool_t *p) -{ - /* Unix creates full blocking pipes. */ - return apr_file_pipe_create_ex(in, out, APR_FULL_BLOCK, p); -} - -APR_DECLARE(apr_status_t) apr_file_pipe_create_ex(apr_file_t **in, - apr_file_t **out, - apr_int32_t blocking, - apr_pool_t *p) -{ -#ifdef _WIN32_WCE - return APR_ENOTIMPL; -#else - SECURITY_ATTRIBUTES sa; - static unsigned long id = 0; - DWORD dwPipeMode; - DWORD dwOpenMode; - char name[50]; - - sa.nLength = sizeof(sa); - -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - sa.bInheritHandle = FALSE; -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - sa.bInheritHandle = TRUE; -#endif - sa.lpSecurityDescriptor = NULL; - - (*in) = (apr_file_t *)apr_pcalloc(p, sizeof(apr_file_t)); - (*in)->pool = p; - (*in)->fname = NULL; - (*in)->pipe = 1; - (*in)->timeout = -1; - (*in)->ungetchar = -1; - (*in)->eof_hit = 0; - (*in)->filePtr = 0; - (*in)->bufpos = 0; - (*in)->dataRead = 0; - (*in)->direction = 0; - (*in)->pOverlapped = NULL; - (void) apr_pollset_create(&(*in)->pollset, 1, p, 0); - - (*out) = (apr_file_t *)apr_pcalloc(p, sizeof(apr_file_t)); - (*out)->pool = p; - (*out)->fname = NULL; - (*out)->pipe = 1; - (*out)->timeout = -1; - (*out)->ungetchar = -1; - (*out)->eof_hit = 0; - (*out)->filePtr = 0; - (*out)->bufpos = 0; - (*out)->dataRead = 0; - (*out)->direction = 0; - (*out)->pOverlapped = NULL; - (void) apr_pollset_create(&(*out)->pollset, 1, p, 0); - - if (apr_os_level >= APR_WIN_NT) { - /* Create the read end of the pipe */ - dwOpenMode = PIPE_ACCESS_INBOUND; - if (blocking == APR_WRITE_BLOCK /* READ_NONBLOCK */ - || blocking == APR_FULL_NONBLOCK) { - dwOpenMode |= FILE_FLAG_OVERLAPPED; - (*in)->pOverlapped = (OVERLAPPED*) apr_pcalloc(p, sizeof(OVERLAPPED)); - (*in)->pOverlapped->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - (*in)->timeout = 0; - } - - dwPipeMode = 0; - - sprintf(name, "\\\\.\\pipe\\apr-pipe-%u.%lu", getpid(), id++); - - (*in)->filehand = CreateNamedPipe(name, - dwOpenMode, - dwPipeMode, - 1, /* nMaxInstances, */ - 0, /* nOutBufferSize, */ - 65536, /* nInBufferSize, */ - 1, /* nDefaultTimeOut, */ - &sa); - - /* Create the write end of the pipe */ - dwOpenMode = FILE_ATTRIBUTE_NORMAL; - if (blocking == APR_READ_BLOCK /* WRITE_NONBLOCK */ - || blocking == APR_FULL_NONBLOCK) { - dwOpenMode |= FILE_FLAG_OVERLAPPED; - (*out)->pOverlapped = (OVERLAPPED*) apr_pcalloc(p, sizeof(OVERLAPPED)); - (*out)->pOverlapped->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - (*out)->timeout = 0; - } - - (*out)->filehand = CreateFile(name, - GENERIC_WRITE, /* access mode */ - 0, /* share mode */ - &sa, /* Security attributes */ - OPEN_EXISTING, /* dwCreationDisposition */ - dwOpenMode, /* Pipe attributes */ - NULL); /* handle to template file */ - } - else { - /* Pipes on Win9* are blocking. Live with it. */ - if (!CreatePipe(&(*in)->filehand, &(*out)->filehand, &sa, 65536)) { - return apr_get_os_error(); - } - } - - apr_pool_cleanup_register((*in)->pool, (void *)(*in), file_cleanup, - apr_pool_cleanup_null); - apr_pool_cleanup_register((*out)->pool, (void *)(*out), file_cleanup, - apr_pool_cleanup_null); - return APR_SUCCESS; -#endif /* _WIN32_WCE */ -} - - -APR_DECLARE(apr_status_t) apr_file_namedpipe_create(const char *filename, - apr_fileperms_t perm, - apr_pool_t *pool) -{ - /* Not yet implemented, interface not suitable. - * Win32 requires the named pipe to be *opened* at the time it's - * created, and to do so, blocking or non blocking must be elected. - */ - return APR_ENOTIMPL; -} - - -/* XXX: Problem; we need to choose between blocking and nonblocking based - * on how *thefile was opened, and we don't have that information :-/ - * Hack; assume a blocking socket, since the most common use for the fn - * would be to handle stdio-style or blocking pipes. Win32 doesn't have - * select() blocking for pipes anyways :( - */ -APR_DECLARE(apr_status_t) apr_os_pipe_put_ex(apr_file_t **file, - apr_os_file_t *thefile, - int register_cleanup, - apr_pool_t *pool) -{ - (*file) = apr_pcalloc(pool, sizeof(apr_file_t)); - (*file)->pool = pool; - (*file)->pipe = 1; - (*file)->timeout = -1; - (*file)->ungetchar = -1; - (*file)->filehand = *thefile; - (void) apr_pollset_create(&(*file)->pollset, 1, pool, 0); - - if (register_cleanup) { - apr_pool_cleanup_register(pool, *file, file_cleanup, - apr_pool_cleanup_null); - } - - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_os_pipe_put(apr_file_t **file, - apr_os_file_t *thefile, - apr_pool_t *pool) -{ - return apr_os_pipe_put_ex(file, thefile, 0, pool); -} - -static apr_status_t create_socket_pipe(SOCKET *rd, SOCKET *wr) -{ - static int id = 0; - FD_SET rs; - SOCKET ls; - struct timeval socktm; - struct sockaddr_in pa; - struct sockaddr_in la; - struct sockaddr_in ca; - int nrd; - apr_status_t rv = APR_SUCCESS; - int ll = sizeof(la); - int lc = sizeof(ca); - unsigned long bm = 1; - int uid[2]; - int iid[2]; - - *rd = INVALID_SOCKET; - *wr = INVALID_SOCKET; - - /* Create the unique socket identifier - * so that we know the connection originated - * from us. - */ - uid[0] = getpid(); - uid[1] = id++; - if ((ls = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) { - return apr_get_netos_error(); - } - - pa.sin_family = AF_INET; - pa.sin_port = 0; - pa.sin_addr.s_addr = inet_addr("127.0.0.1"); - - if (bind(ls, (SOCKADDR *)&pa, sizeof(pa)) == SOCKET_ERROR) { - rv = apr_get_netos_error(); - goto cleanup; - } - if (getsockname(ls, (SOCKADDR *)&la, &ll) == SOCKET_ERROR) { - rv = apr_get_netos_error(); - goto cleanup; - } - if (listen(ls, 1) == SOCKET_ERROR) { - rv = apr_get_netos_error(); - goto cleanup; - } - if ((*wr = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) { - rv = apr_get_netos_error(); - goto cleanup; - } - if (connect(*wr, (SOCKADDR *)&la, sizeof(la)) == SOCKET_ERROR) { - rv = apr_get_netos_error(); - goto cleanup; - } - if (send(*wr, (char *)uid, sizeof(uid), 0) != sizeof(uid)) { - if ((rv = apr_get_netos_error()) == 0) { - rv = APR_EINVAL; - } - goto cleanup; - } - if (ioctlsocket(ls, FIONBIO, &bm) == SOCKET_ERROR) { - rv = apr_get_netos_error(); - goto cleanup; - } - for (;;) { - int ns; - int nc = 0; - /* Listening socket is nonblocking by now. - * The accept should create the socket - * immediatelly because we are connected already. - * However on buys systems this can take a while - * until winsock gets a chance to handle the events. - */ - FD_ZERO(&rs); - FD_SET(ls, &rs); - - socktm.tv_sec = 1; - socktm.tv_usec = 0; - if ((ns = select(0, &rs, NULL, NULL, &socktm)) == SOCKET_ERROR) { - /* Accept still not signaled */ - Sleep(100); - continue; - } - if (ns == 0) { - /* No connections in the last second */ - continue; - } - if ((*rd = accept(ls, (SOCKADDR *)&ca, &lc)) == INVALID_SOCKET) { - rv = apr_get_netos_error(); - goto cleanup; - } - /* Verify the connection by reading the send identification. - */ - do { - if (nc++) - Sleep(1); - nrd = recv(*rd, (char *)iid, sizeof(iid), 0); - rv = nrd == SOCKET_ERROR ? apr_get_netos_error() : APR_SUCCESS; - } while (APR_STATUS_IS_EAGAIN(rv)); - - if (nrd == sizeof(iid)) { - if (memcmp(uid, iid, sizeof(uid)) == 0) { - /* Wow, we recived what we send. - * Put read side of the pipe to the blocking - * mode and return. - */ - bm = 0; - if (ioctlsocket(*rd, FIONBIO, &bm) == SOCKET_ERROR) { - rv = apr_get_netos_error(); - goto cleanup; - } - break; - } - } - else if (nrd == SOCKET_ERROR) { - goto cleanup; - } - closesocket(*rd); - } - /* We don't need the listening socket any more */ - closesocket(ls); - return 0; - -cleanup: - /* Don't leak resources */ - if (*rd != INVALID_SOCKET) - closesocket(*rd); - if (*wr != INVALID_SOCKET) - closesocket(*wr); - - *rd = INVALID_SOCKET; - *wr = INVALID_SOCKET; - closesocket(ls); - return rv; -} - -static apr_status_t socket_pipe_cleanup(void *thefile) -{ - apr_file_t *file = thefile; - if (file->filehand != INVALID_HANDLE_VALUE) { - shutdown((SOCKET)file->filehand, SD_BOTH); - closesocket((SOCKET)file->filehand); - file->filehand = INVALID_HANDLE_VALUE; - } - return APR_SUCCESS; -} - -apr_status_t apr_file_socket_pipe_create(apr_file_t **in, - apr_file_t **out, - apr_pool_t *p) -{ - apr_status_t rv; - SOCKET rd; - SOCKET wr; - - if ((rv = create_socket_pipe(&rd, &wr)) != APR_SUCCESS) { - return rv; - } - (*in) = (apr_file_t *)apr_pcalloc(p, sizeof(apr_file_t)); - (*in)->pool = p; - (*in)->fname = NULL; - (*in)->pipe = 1; - (*in)->timeout = -1; - (*in)->ungetchar = -1; - (*in)->eof_hit = 0; - (*in)->filePtr = 0; - (*in)->bufpos = 0; - (*in)->dataRead = 0; - (*in)->direction = 0; - (*in)->pOverlapped = (OVERLAPPED*)apr_pcalloc(p, sizeof(OVERLAPPED)); - (*in)->filehand = (HANDLE)rd; - - (*out) = (apr_file_t *)apr_pcalloc(p, sizeof(apr_file_t)); - (*out)->pool = p; - (*out)->fname = NULL; - (*out)->pipe = 1; - (*out)->timeout = -1; - (*out)->ungetchar = -1; - (*out)->eof_hit = 0; - (*out)->filePtr = 0; - (*out)->bufpos = 0; - (*out)->dataRead = 0; - (*out)->direction = 0; - (*out)->pOverlapped = (OVERLAPPED*)apr_pcalloc(p, sizeof(OVERLAPPED)); - (*out)->filehand = (HANDLE)wr; - - apr_pool_cleanup_register(p, (void *)(*in), socket_pipe_cleanup, - apr_pool_cleanup_null); - apr_pool_cleanup_register(p, (void *)(*out), socket_pipe_cleanup, - apr_pool_cleanup_null); - - return rv; -} - -apr_status_t apr_file_socket_pipe_close(apr_file_t *file) -{ - apr_status_t stat; - if (!file->pipe) - return apr_file_close(file); - if ((stat = socket_pipe_cleanup(file)) == APR_SUCCESS) { - apr_pool_cleanup_kill(file->pool, file, socket_pipe_cleanup); - - if (file->mutex) { - apr_thread_mutex_destroy(file->mutex); - } - - return APR_SUCCESS; - } - return stat; -} - diff --git a/libs/apr/file_io/win32/readwrite.c b/libs/apr/file_io/win32/readwrite.c deleted file mode 100644 index 1d0014d5..00000000 --- a/libs/apr/file_io/win32/readwrite.c +++ /dev/null @@ -1,581 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_lib.h" -#include "apr_errno.h" -#include -#include "apr_arch_atime.h" -#include "apr_arch_misc.h" - -/* - * read_with_timeout() - * Uses async i/o to emulate unix non-blocking i/o with timeouts. - */ -static apr_status_t read_with_timeout(apr_file_t *file, void *buf, apr_size_t len_in, apr_size_t *nbytes) -{ - apr_status_t rv; - DWORD res; - DWORD len = (DWORD)len_in; - DWORD bytesread = 0; - - /* Handle the zero timeout non-blocking case */ - if (file->timeout == 0) { - /* Peek at the pipe. If there is no data available, return APR_EAGAIN. - * If data is available, go ahead and read it. - */ - if (file->pipe) { - DWORD bytes; - if (!PeekNamedPipe(file->filehand, NULL, 0, NULL, &bytes, NULL)) { - rv = apr_get_os_error(); - if (rv == APR_FROM_OS_ERROR(ERROR_BROKEN_PIPE)) { - rv = APR_EOF; - } - *nbytes = 0; - return rv; - } - else { - if (bytes == 0) { - *nbytes = 0; - return APR_EAGAIN; - } - if (len > bytes) { - len = bytes; - } - } - } - else { - /* ToDo: Handle zero timeout non-blocking file i/o - * This is not needed until an APR application needs to - * timeout file i/o (which means setting file i/o non-blocking) - */ - } - } - - if (file->pOverlapped && !file->pipe) { - file->pOverlapped->Offset = (DWORD)file->filePtr; - file->pOverlapped->OffsetHigh = (DWORD)(file->filePtr >> 32); - } - - if (ReadFile(file->filehand, buf, len, - &bytesread, file->pOverlapped)) { - rv = APR_SUCCESS; - } - else { - rv = apr_get_os_error(); - if (rv == APR_FROM_OS_ERROR(ERROR_IO_PENDING)) { - /* Wait for the pending i/o, timeout converted from us to ms - * Note that we loop if someone gives up the event, since - * folks suggest that WAIT_ABANDONED isn't actually a result - * but an alert that ownership of the event has passed from - * one owner to a new proc/thread. - */ - do { - res = WaitForSingleObject(file->pOverlapped->hEvent, - (file->timeout > 0) - ? (DWORD)(file->timeout/1000) - : ((file->timeout == -1) - ? INFINITE : 0)); - } while (res == WAIT_ABANDONED); - - /* There is one case that represents entirely - * successful operations, otherwise we will cancel - * the operation in progress. - */ - if (res != WAIT_OBJECT_0) { - CancelIo(file->filehand); - } - - /* Ignore any failures above. Attempt to complete - * the overlapped operation and use only _its_ result. - * For example, CancelIo or WaitForSingleObject can - * fail if the handle is closed, yet the read may have - * completed before we attempted to CancelIo... - */ - if (GetOverlappedResult(file->filehand, file->pOverlapped, - &bytesread, TRUE)) { - rv = APR_SUCCESS; - } - else { - rv = apr_get_os_error(); - if (((rv == APR_FROM_OS_ERROR(ERROR_IO_INCOMPLETE)) - || (rv == APR_FROM_OS_ERROR(ERROR_OPERATION_ABORTED))) - && (res == WAIT_TIMEOUT)) - rv = APR_TIMEUP; - } - } - if (rv == APR_FROM_OS_ERROR(ERROR_BROKEN_PIPE)) { - /* Assume ERROR_BROKEN_PIPE signals an EOF reading from a pipe */ - rv = APR_EOF; - } else if (rv == APR_FROM_OS_ERROR(ERROR_HANDLE_EOF)) { - /* Did we hit EOF reading from the handle? */ - rv = APR_EOF; - } - } - - /* OK and 0 bytes read ==> end of file */ - if (rv == APR_SUCCESS && bytesread == 0) - rv = APR_EOF; - - if (rv == APR_SUCCESS && file->pOverlapped && !file->pipe) { - file->filePtr += bytesread; - } - *nbytes = bytesread; - return rv; -} - -APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size_t *len) -{ - apr_status_t rv; - DWORD bytes_read = 0; - - if (*len <= 0) { - *len = 0; - return APR_SUCCESS; - } - - /* If the file is open for xthread support, allocate and - * initialize the overlapped and io completion event (hEvent). - * Threads should NOT share an apr_file_t or its hEvent. - */ - if ((thefile->flags & APR_FOPEN_XTHREAD) && !thefile->pOverlapped ) { - thefile->pOverlapped = (OVERLAPPED*) apr_pcalloc(thefile->pool, - sizeof(OVERLAPPED)); - thefile->pOverlapped->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - if (!thefile->pOverlapped->hEvent) { - rv = apr_get_os_error(); - return rv; - } - } - - /* Handle the ungetchar if there is one */ - if (thefile->ungetchar != -1) { - bytes_read = 1; - *(char *)buf = (char)thefile->ungetchar; - buf = (char *)buf + 1; - (*len)--; - thefile->ungetchar = -1; - if (*len == 0) { - *len = bytes_read; - return APR_SUCCESS; - } - } - if (thefile->buffered) { - char *pos = (char *)buf; - apr_size_t blocksize; - apr_size_t size = *len; - - apr_thread_mutex_lock(thefile->mutex); - - if (thefile->direction == 1) { - rv = apr_file_flush(thefile); - if (rv != APR_SUCCESS) { - apr_thread_mutex_unlock(thefile->mutex); - return rv; - } - thefile->bufpos = 0; - thefile->direction = 0; - thefile->dataRead = 0; - } - - rv = 0; - while (rv == 0 && size > 0) { - if (thefile->bufpos >= thefile->dataRead) { - apr_size_t read; - rv = read_with_timeout(thefile, thefile->buffer, - thefile->bufsize, &read); - if (read == 0) { - if (rv == APR_EOF) - thefile->eof_hit = TRUE; - break; - } - else { - thefile->dataRead = read; - thefile->filePtr += thefile->dataRead; - thefile->bufpos = 0; - } - } - - blocksize = size > thefile->dataRead - thefile->bufpos ? thefile->dataRead - thefile->bufpos : size; - memcpy(pos, thefile->buffer + thefile->bufpos, blocksize); - thefile->bufpos += blocksize; - pos += blocksize; - size -= blocksize; - } - - *len = pos - (char *)buf; - if (*len) { - rv = APR_SUCCESS; - } - apr_thread_mutex_unlock(thefile->mutex); - } else { - /* Unbuffered i/o */ - apr_size_t nbytes; - rv = read_with_timeout(thefile, buf, *len, &nbytes); - if (rv == APR_EOF) - thefile->eof_hit = TRUE; - *len = nbytes; - } - - return rv; -} - -APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, apr_size_t *nbytes) -{ - apr_status_t rv; - DWORD bwrote; - - /* If the file is open for xthread support, allocate and - * initialize the overlapped and io completion event (hEvent). - * Threads should NOT share an apr_file_t or its hEvent. - */ - if ((thefile->flags & APR_FOPEN_XTHREAD) && !thefile->pOverlapped ) { - thefile->pOverlapped = (OVERLAPPED*) apr_pcalloc(thefile->pool, - sizeof(OVERLAPPED)); - thefile->pOverlapped->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - if (!thefile->pOverlapped->hEvent) { - rv = apr_get_os_error(); - return rv; - } - } - - if (thefile->buffered) { - char *pos = (char *)buf; - apr_size_t blocksize; - apr_size_t size = *nbytes; - - apr_thread_mutex_lock(thefile->mutex); - - if (thefile->direction == 0) { - /* Position file pointer for writing at the offset we are logically reading from */ - apr_off_t offset = thefile->filePtr - thefile->dataRead + thefile->bufpos; - DWORD offlo = (DWORD)offset; - LONG offhi = (LONG)(offset >> 32); - if (offset != thefile->filePtr) - SetFilePointer(thefile->filehand, offlo, &offhi, FILE_BEGIN); - thefile->bufpos = thefile->dataRead = 0; - thefile->direction = 1; - } - - rv = 0; - while (rv == 0 && size > 0) { - if (thefile->bufpos == thefile->bufsize) // write buffer is full - rv = apr_file_flush(thefile); - - blocksize = size > thefile->bufsize - thefile->bufpos ? - thefile->bufsize - thefile->bufpos : size; - memcpy(thefile->buffer + thefile->bufpos, pos, blocksize); - thefile->bufpos += blocksize; - pos += blocksize; - size -= blocksize; - } - - apr_thread_mutex_unlock(thefile->mutex); - return rv; - } else { - if (!thefile->pipe) { - apr_off_t offset = 0; - apr_status_t rc; - if (thefile->append) { - /* apr_file_lock will mutex the file across processes. - * The call to apr_thread_mutex_lock is added to avoid - * a race condition between LockFile and WriteFile - * that occasionally leads to deadlocked threads. - */ - apr_thread_mutex_lock(thefile->mutex); - rc = apr_file_lock(thefile, APR_FLOCK_EXCLUSIVE); - if (rc != APR_SUCCESS) { - apr_thread_mutex_unlock(thefile->mutex); - return rc; - } - rc = apr_file_seek(thefile, APR_END, &offset); - if (rc != APR_SUCCESS) { - apr_thread_mutex_unlock(thefile->mutex); - return rc; - } - } - if (thefile->pOverlapped) { - thefile->pOverlapped->Offset = (DWORD)thefile->filePtr; - thefile->pOverlapped->OffsetHigh = (DWORD)(thefile->filePtr >> 32); - } - rv = WriteFile(thefile->filehand, buf, (DWORD)*nbytes, &bwrote, - thefile->pOverlapped); - if (thefile->append) { - apr_file_unlock(thefile); - apr_thread_mutex_unlock(thefile->mutex); - } - } - else { - rv = WriteFile(thefile->filehand, buf, (DWORD)*nbytes, &bwrote, - thefile->pOverlapped); - } - if (rv) { - *nbytes = bwrote; - rv = APR_SUCCESS; - } - else { - (*nbytes) = 0; - rv = apr_get_os_error(); - - /* XXX: This must be corrected, per the apr_file_read logic!!! */ - if (rv == APR_FROM_OS_ERROR(ERROR_IO_PENDING)) { - - DWORD timeout_ms; - - if (thefile->timeout == 0) { - timeout_ms = 0; - } - else if (thefile->timeout < 0) { - timeout_ms = INFINITE; - } - else { - timeout_ms = (DWORD)(thefile->timeout / 1000); - } - - rv = WaitForSingleObject(thefile->pOverlapped->hEvent, timeout_ms); - switch (rv) { - case WAIT_OBJECT_0: - GetOverlappedResult(thefile->filehand, thefile->pOverlapped, - &bwrote, TRUE); - *nbytes = bwrote; - rv = APR_SUCCESS; - break; - case WAIT_TIMEOUT: - rv = (timeout_ms == 0) ? APR_EAGAIN : APR_TIMEUP; - break; - case WAIT_FAILED: - rv = apr_get_os_error(); - break; - default: - break; - } - if (rv != APR_SUCCESS) { - if (apr_os_level >= APR_WIN_98) - CancelIo(thefile->filehand); - } - } - } - if (rv == APR_SUCCESS && thefile->pOverlapped && !thefile->pipe) { - thefile->filePtr += *nbytes; - } - } - return rv; -} -/* ToDo: Write for it anyway and test the oslevel! - * Too bad WriteFileGather() is not supported on 95&98 (or NT prior to SP2) - */ -APR_DECLARE(apr_status_t) apr_file_writev(apr_file_t *thefile, - const struct iovec *vec, - apr_size_t nvec, - apr_size_t *nbytes) -{ - apr_status_t rv = APR_SUCCESS; - apr_size_t i; - apr_size_t bwrote = 0; - char *buf; - - *nbytes = 0; - for (i = 0; i < nvec; i++) { - buf = vec[i].iov_base; - bwrote = vec[i].iov_len; - rv = apr_file_write(thefile, buf, &bwrote); - *nbytes += bwrote; - if (rv != APR_SUCCESS) { - break; - } - } - return rv; -} - -APR_DECLARE(apr_status_t) apr_file_putc(char ch, apr_file_t *thefile) -{ - apr_size_t len = 1; - - return apr_file_write(thefile, &ch, &len); -} - -APR_DECLARE(apr_status_t) apr_file_ungetc(char ch, apr_file_t *thefile) -{ - thefile->ungetchar = (unsigned char) ch; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_getc(char *ch, apr_file_t *thefile) -{ - apr_status_t rc; - apr_size_t bread; - - bread = 1; - rc = apr_file_read(thefile, ch, &bread); - - if (rc) { - return rc; - } - - if (bread == 0) { - thefile->eof_hit = TRUE; - return APR_EOF; - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_puts(const char *str, apr_file_t *thefile) -{ - apr_size_t len = strlen(str); - - return apr_file_write(thefile, str, &len); -} - -APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, apr_file_t *thefile) -{ - apr_size_t readlen; - apr_status_t rv = APR_SUCCESS; - int i; - - for (i = 0; i < len-1; i++) { - readlen = 1; - rv = apr_file_read(thefile, str+i, &readlen); - - if (rv != APR_SUCCESS && rv != APR_EOF) - return rv; - - if (readlen == 0) { - /* If we have bytes, defer APR_EOF to the next call */ - if (i > 0) - rv = APR_SUCCESS; - break; - } - - if (str[i] == '\n') { - i++; /* don't clobber this char below */ - break; - } - } - str[i] = 0; - return rv; -} - -APR_DECLARE(apr_status_t) apr_file_flush(apr_file_t *thefile) -{ - if (thefile->buffered) { - DWORD numbytes, written = 0; - apr_status_t rc = 0; - char *buffer; - apr_size_t bytesleft; - - if (thefile->direction == 1 && thefile->bufpos) { - buffer = thefile->buffer; - bytesleft = thefile->bufpos; - - do { - if (bytesleft > APR_DWORD_MAX) { - numbytes = APR_DWORD_MAX; - } - else { - numbytes = (DWORD)bytesleft; - } - - if (!WriteFile(thefile->filehand, buffer, numbytes, &written, NULL)) { - rc = apr_get_os_error(); - thefile->filePtr += written; - break; - } - - thefile->filePtr += written; - bytesleft -= written; - buffer += written; - - } while (bytesleft > 0); - - if (rc == 0) - thefile->bufpos = 0; - } - - return rc; - } - - /* There isn't anything to do if we aren't buffering the output - * so just return success. - */ - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_file_sync(apr_file_t *thefile){ - apr_status_t rv; - - rv = apr_file_flush(thefile); - if (rv != APR_SUCCESS) { - return rv; - } - - if (!FlushFileBuffers(thefile->filehand)) { - rv = apr_get_os_error(); - } - - return rv; -} - -APR_DECLARE(apr_status_t) apr_file_datasync(apr_file_t *thefile){ - return apr_file_sync(thefile); -} - -struct apr_file_printf_data { - apr_vformatter_buff_t vbuff; - apr_file_t *fptr; - char *buf; -}; - -static int file_printf_flush(apr_vformatter_buff_t *buff) -{ - struct apr_file_printf_data *data = (struct apr_file_printf_data *)buff; - - if (apr_file_write_full(data->fptr, data->buf, - data->vbuff.curpos - data->buf, NULL)) { - return -1; - } - - data->vbuff.curpos = data->buf; - return 0; -} - -APR_DECLARE_NONSTD(int) apr_file_printf(apr_file_t *fptr, - const char *format, ...) -{ - struct apr_file_printf_data data; - va_list ap; - int count; - - data.buf = malloc(HUGE_STRING_LEN); - if (data.buf == NULL) { - return 0; - } - data.vbuff.curpos = data.buf; - data.vbuff.endpos = data.buf + HUGE_STRING_LEN; - data.fptr = fptr; - va_start(ap, format); - count = apr_vformatter(file_printf_flush, - (apr_vformatter_buff_t *)&data, format, ap); - /* apr_vformatter does not call flush for the last bits */ - if (count >= 0) file_printf_flush((apr_vformatter_buff_t *)&data); - - va_end(ap); - - free(data.buf); - return count; -} diff --git a/libs/apr/file_io/win32/seek.c b/libs/apr/file_io/win32/seek.c deleted file mode 100644 index b412fd4c..00000000 --- a/libs/apr/file_io/win32/seek.c +++ /dev/null @@ -1,177 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include -#include - -static apr_status_t setptr(apr_file_t *thefile, apr_off_t pos ) -{ - apr_off_t newbufpos; - apr_status_t rv; - DWORD rc; - - if (thefile->direction == 1) { - /* XXX: flush here is not mutex protected */ - rv = apr_file_flush(thefile); - if (rv != APR_SUCCESS) - return rv; - thefile->bufpos = thefile->dataRead = 0; - thefile->direction = 0; - } - - /* We may be truncating to size here. - * XXX: testing an 'unsigned' as >= 0 below indicates a bug - */ - newbufpos = pos - (thefile->filePtr - thefile->dataRead); - - if (newbufpos >= 0 && newbufpos <= (apr_off_t)thefile->dataRead) { - thefile->bufpos = (apr_size_t)newbufpos; - rv = APR_SUCCESS; - } else { - DWORD offlo = (DWORD)pos; - LONG offhi = (LONG)(pos >> 32); - rc = SetFilePointer(thefile->filehand, offlo, &offhi, FILE_BEGIN); - - if (rc == (DWORD)-1) - /* A legal value, perhaps? MSDN implies prior SetLastError isn't - * needed, googling for SetLastError SetFilePointer seems - * to confirm this. INVALID_SET_FILE_POINTER is too recently - * added for us to rely on it as a constant. - */ - rv = apr_get_os_error(); - else - rv = APR_SUCCESS; - - if (rv == APR_SUCCESS) { - rv = APR_SUCCESS; - thefile->eof_hit = 0; - thefile->bufpos = thefile->dataRead = 0; - thefile->filePtr = pos; - } - } - - return rv; -} - - -APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile, apr_seek_where_t where, apr_off_t *offset) -{ - apr_finfo_t finfo; - apr_status_t rc = APR_SUCCESS; - - thefile->eof_hit = 0; - - if (thefile->buffered) { - switch (where) { - case APR_SET: - rc = setptr(thefile, *offset); - break; - - case APR_CUR: - rc = setptr(thefile, thefile->filePtr - thefile->dataRead - + thefile->bufpos + *offset); - break; - - case APR_END: - rc = apr_file_info_get(&finfo, APR_FINFO_SIZE, thefile); - if (rc == APR_SUCCESS) - rc = setptr(thefile, finfo.size + *offset); - break; - - default: - return APR_EINVAL; - } - - *offset = thefile->filePtr - thefile->dataRead + thefile->bufpos; - return rc; - } - /* A file opened with APR_FOPEN_XTHREAD has been opened for overlapped i/o. - * APR must explicitly track the file pointer in this case. - */ - else if (thefile->pOverlapped || thefile->flags & APR_FOPEN_XTHREAD) { - switch(where) { - case APR_SET: - thefile->filePtr = *offset; - break; - - case APR_CUR: - thefile->filePtr += *offset; - break; - - case APR_END: - rc = apr_file_info_get(&finfo, APR_FINFO_SIZE, thefile); - if (rc == APR_SUCCESS && finfo.size + *offset >= 0) - thefile->filePtr = finfo.size + *offset; - break; - - default: - return APR_EINVAL; - } - *offset = thefile->filePtr; - return rc; - } - else { - DWORD howmove; - DWORD offlo = (DWORD)*offset; - DWORD offhi = (DWORD)(*offset >> 32); - - switch(where) { - case APR_SET: - howmove = FILE_BEGIN; break; - case APR_CUR: - howmove = FILE_CURRENT; break; - case APR_END: - howmove = FILE_END; break; - default: - return APR_EINVAL; - } - offlo = SetFilePointer(thefile->filehand, (LONG)offlo, - (LONG*)&offhi, howmove); - if (offlo == 0xFFFFFFFF) - rc = apr_get_os_error(); - else - rc = APR_SUCCESS; - /* Since we can land at 0xffffffff we will measure our APR_SUCCESS */ - if (rc == APR_SUCCESS) - *offset = ((apr_off_t)offhi << 32) | offlo; - return rc; - } -} - - -APR_DECLARE(apr_status_t) apr_file_trunc(apr_file_t *thefile, apr_off_t offset) -{ - apr_status_t rv; - DWORD offlo = (DWORD)offset; - LONG offhi = (LONG)(offset >> 32); - DWORD rc; - - rc = SetFilePointer(thefile->filehand, offlo, &offhi, FILE_BEGIN); - if (rc == 0xFFFFFFFF) - if ((rv = apr_get_os_error()) != APR_SUCCESS) - return rv; - - if (!SetEndOfFile(thefile->filehand)) - return apr_get_os_error(); - - if (thefile->buffered) { - return setptr(thefile, offset); - } - - return APR_SUCCESS; -} diff --git a/libs/apr/helpers/apr_rename.pl b/libs/apr/helpers/apr_rename.pl deleted file mode 100644 index 25b9d52d..00000000 --- a/libs/apr/helpers/apr_rename.pl +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/perl -w -use strict; -use ExtUtils::MakeMaker qw(prompt); -use File::Find; - -my $just_check = @ARGV ? $ARGV[0] eq '-c' : 0; -shift if $just_check; -my $dir = shift || '.'; -my %names; - -my $prefix = 'apr_'; - -while () { - chomp; - my($old, $new) = grep { s/^$prefix//o } split; - next unless $old and $new; - $names{$old} = $new; -} - -my $pattern = join '|', keys %names; -#print "replacement pattern=$pattern\n"; - -find sub { - chomp; - return unless /\.[ch]$/; - my $file = "$File::Find::dir/$_"; - print "looking in $file\n"; - - replace($_, !$just_check); - -}, $dir; - -sub replace { - my($file, $replace) = @_; - local *IN, *OUT; - my @lines; - my $found = 0; - - open IN, $file or die "open $file: $!"; - - while () { - for (m/[^_\"]*$prefix($pattern)\b/og) { - $found++; - print " $file:$. apr_$_ -> apr_$names{$_}\n"; - } - push @lines, $_ if $replace; - } - - close IN; - - return unless $found and $replace; - -# my $ans = prompt("replace?", 'y'); -# return unless $ans =~ /^y/i; - - open OUT, ">$file" or die "open $file: $!"; - - for (@lines) { - unless (/^\#include/) { - s/([^_\"]*$prefix)($pattern)\b/$1$names{$2}/og; - } - print OUT $_; - } - - close OUT; -} - -__DATA__ -apr_time_t: -apr_implode_gmt apr_time_exp_gmt_get - -apr_socket_t: -apr_close_socket apr_socket_close -apr_create_socket apr_socket_create -apr_get_sockaddr apr_socket_addr_get -apr_get_socketdata apr_socket_data_get -apr_set_socketdata apr_socket_data_set -apr_shutdown apr_socket_shutdown -apr_bind apr_socket_bind -apr_listen apr_socket_listen -apr_accept apr_socket_accept -apr_connect apr_socket_connect -apr_send apr_socket_send -apr_sendv apr_socket_sendv -apr_sendto apr_socket_sendto -apr_recvfrom apr_socket_recvfrom -apr_sendfile apr_socket_sendfile -apr_recv apr_socket_recv - -apr_filepath_*: -apr_filename_of_pathname apr_filepath_name_get - -apr_gid_t: -apr_get_groupid apr_gid_get -apr_get_groupname apr_gid_name_get -apr_group_name_get apr_gid_name_get -apr_compare_groups apr_gid_compare - -apr_uid_t: -apr_get_home_directory apr_uid_homepath_get -apr_get_userid apr_uid_get -apr_current_userid apr_uid_current -apr_compare_users apr_uid_compare -apr_get_username apr_uid_name_get -apr_compare_users apr_uid_compare - diff --git a/libs/apr/include/apr.h b/libs/apr/include/apr.h deleted file mode 100644 index 0aaa62c6..00000000 --- a/libs/apr/include/apr.h +++ /dev/null @@ -1,638 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef APR_H -#define APR_H - -/* GENERATED FILE WARNING! DO NOT EDIT apr.h - * - * You must modify apr.hw instead. - * - * And please, make an effort to stub apr.hnw and apr.h.in in the process. - * - * This is the Win32 specific version of apr.h. It is copied from - * apr.hw by the apr.dsp and libapr.dsp projects. - */ - -/** - * @file apr.h - * @brief APR Platform Definitions - * @remark This is a generated header generated from include/apr.h.in by - * ./configure, or copied from include/apr.hw or include/apr.hnw - * for Win32 or Netware by those build environments, respectively. - */ - -#if defined(WIN32) || defined(DOXYGEN) - -/* Ignore most warnings (back down to /W3) for poorly constructed headers - */ -#if defined(_MSC_VER) && _MSC_VER >= 1200 -#pragma warning(push, 3) -#endif - -/* disable or reduce the frequency of... - * C4057: indirection to slightly different base types - * C4075: slight indirection changes (unsigned short* vs short[]) - * C4100: unreferenced formal parameter - * C4127: conditional expression is constant - * C4163: '_rotl64' : not available as an intrinsic function - * C4201: nonstandard extension nameless struct/unions - * C4244: int to char/short - precision loss - * C4514: unreferenced inline function removed - */ -#pragma warning(disable: 4100 4127 4163 4201 4514; once: 4057 4075 4244) - -/* Ignore Microsoft's interpretation of secure development - * and the POSIX string handling API - */ -#if defined(_MSC_VER) && _MSC_VER >= 1400 -#ifndef _CRT_SECURE_NO_DEPRECATE -#define _CRT_SECURE_NO_DEPRECATE -#endif -#pragma warning(disable: 4996) -#endif - -/* Has windows.h already been included? If so, our preferences don't matter, - * but we will still need the winsock things no matter what was included. - * If not, include a restricted set of windows headers to our tastes. - */ -#ifndef _WINDOWS_ -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#ifndef _WIN32_WINNT - -/* Restrict the server to a subset of Windows XP header files by default - */ -#define _WIN32_WINNT 0x0501 -#endif -#ifndef NOUSER -#define NOUSER -#endif -#ifndef NOMCX -#define NOMCX -#endif -#ifndef NOIME -#define NOIME -#endif -#include -/* - * Add a _very_few_ declarations missing from the restricted set of headers - * (If this list becomes extensive, re-enable the required headers above!) - * winsock headers were excluded by WIN32_LEAN_AND_MEAN, so include them now - */ -#define SW_HIDE 0 -#ifndef _WIN32_WCE -#include -#include -#include -#else -#include -#endif -#endif /* !_WINDOWS_ */ - -/** - * @defgroup APR Apache Portability Runtime library - * @{ - */ -/** - * @defgroup apr_platform Platform Definitions - * @{ - * @warning - * The actual values of macros and typedefs on this page
    - * are platform specific and should NOT be relied upon!
    - */ - -#define APR_INLINE __inline -#define APR_HAS_INLINE 1 -#if !defined(__GNUC__) && !defined(__attribute__) -#define __attribute__(__x) -#endif - -#ifndef _WIN32_WCE -#define APR_HAVE_ARPA_INET_H 0 -#define APR_HAVE_CONIO_H 1 -#define APR_HAVE_CRYPT_H 0 -#define APR_HAVE_CTYPE_H 1 -#define APR_HAVE_DIRENT_H 0 -#define APR_HAVE_ERRNO_H 1 -#define APR_HAVE_FCNTL_H 1 -#define APR_HAVE_IO_H 1 -#define APR_HAVE_LIMITS_H 1 -#define APR_HAVE_NETDB_H 0 -#define APR_HAVE_NETINET_IN_H 0 -#define APR_HAVE_NETINET_SCTP_H 0 -#define APR_HAVE_NETINET_SCTP_UIO_H 0 -#define APR_HAVE_NETINET_TCP_H 0 -#define APR_HAVE_PTHREAD_H 0 -#define APR_HAVE_SEMAPHORE_H 0 -#define APR_HAVE_SIGNAL_H 1 -#define APR_HAVE_STDARG_H 1 -#define APR_HAVE_STDINT_H 0 -#define APR_HAVE_STDIO_H 1 -#define APR_HAVE_STDLIB_H 1 -#define APR_HAVE_STRING_H 1 -#define APR_HAVE_STRINGS_H 0 -#define APR_HAVE_SYS_IOCTL_H 0 -#define APR_HAVE_SYS_SENDFILE_H 0 -#define APR_HAVE_SYS_SIGNAL_H 0 -#define APR_HAVE_SYS_SOCKET_H 0 -#define APR_HAVE_SYS_SOCKIO_H 0 -#define APR_HAVE_SYS_SYSLIMITS_H 0 -#define APR_HAVE_SYS_TIME_H 0 -#define APR_HAVE_SYS_TYPES_H 1 -#define APR_HAVE_SYS_UIO_H 0 -#define APR_HAVE_SYS_UN_H 0 -#define APR_HAVE_SYS_WAIT_H 0 -#define APR_HAVE_TIME_H 1 -#define APR_HAVE_UNISTD_H 0 -#define APR_HAVE_STDDEF_H 1 -#define APR_HAVE_PROCESS_H 1 -#else -#define APR_HAVE_ARPA_INET_H 0 -#define APR_HAVE_CONIO_H 0 -#define APR_HAVE_CRYPT_H 0 -#define APR_HAVE_CTYPE_H 0 -#define APR_HAVE_DIRENT_H 0 -#define APR_HAVE_ERRNO_H 0 -#define APR_HAVE_FCNTL_H 0 -#define APR_HAVE_IO_H 0 -#define APR_HAVE_LIMITS_H 0 -#define APR_HAVE_NETDB_H 0 -#define APR_HAVE_NETINET_IN_H 0 -#define APR_HAVE_NETINET_SCTP_H 0 -#define APR_HAVE_NETINET_SCTP_UIO_H 0 -#define APR_HAVE_NETINET_TCP_H 0 -#define APR_HAVE_PTHREAD_H 0 -#define APR_HAVE_SEMAPHORE_H 0 -#define APR_HAVE_SIGNAL_H 0 -#define APR_HAVE_STDARG_H 0 -#define APR_HAVE_STDINT_H 0 -#define APR_HAVE_STDIO_H 1 -#define APR_HAVE_STDLIB_H 1 -#define APR_HAVE_STRING_H 1 -#define APR_HAVE_STRINGS_H 0 -#define APR_HAVE_SYS_IOCTL_H 0 -#define APR_HAVE_SYS_SENDFILE_H 0 -#define APR_HAVE_SYS_SIGNAL_H 0 -#define APR_HAVE_SYS_SOCKET_H 0 -#define APR_HAVE_SYS_SOCKIO_H 0 -#define APR_HAVE_SYS_SYSLIMITS_H 0 -#define APR_HAVE_SYS_TIME_H 0 -#define APR_HAVE_SYS_TYPES_H 0 -#define APR_HAVE_SYS_UIO_H 0 -#define APR_HAVE_SYS_UN_H 0 -#define APR_HAVE_SYS_WAIT_H 0 -#define APR_HAVE_TIME_H 0 -#define APR_HAVE_UNISTD_H 0 -#define APR_HAVE_STDDEF_H 0 -#define APR_HAVE_PROCESS_H 0 -#endif - -/** @} */ -/** @} */ - -/* We don't include our conditional headers within the doxyblocks - * or the extern "C" namespace - */ - -#if APR_HAVE_STDLIB_H -#include -#endif -#if APR_HAVE_STDIO_H -#include -#endif -#if APR_HAVE_SYS_TYPES_H -#include -#endif -#if APR_HAVE_STDDEF_H -#include -#endif -#if APR_HAVE_TIME_H -#include -#endif -#if APR_HAVE_PROCESS_H -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup apr_platform - * @ingroup APR - * @{ - */ - -#define APR_HAVE_SHMEM_MMAP_TMP 0 -#define APR_HAVE_SHMEM_MMAP_SHM 0 -#define APR_HAVE_SHMEM_MMAP_ZERO 0 -#define APR_HAVE_SHMEM_SHMGET_ANON 0 -#define APR_HAVE_SHMEM_SHMGET 0 -#define APR_HAVE_SHMEM_MMAP_ANON 0 -#define APR_HAVE_SHMEM_BEOS 0 - -#define APR_USE_SHMEM_MMAP_TMP 0 -#define APR_USE_SHMEM_MMAP_SHM 0 -#define APR_USE_SHMEM_MMAP_ZERO 0 -#define APR_USE_SHMEM_SHMGET_ANON 0 -#define APR_USE_SHMEM_SHMGET 0 -#define APR_USE_SHMEM_MMAP_ANON 0 -#define APR_USE_SHMEM_BEOS 0 - -#define APR_USE_FLOCK_SERIALIZE 0 -#define APR_USE_POSIXSEM_SERIALIZE 0 -#define APR_USE_SYSVSEM_SERIALIZE 0 -#define APR_USE_FCNTL_SERIALIZE 0 -#define APR_USE_PROC_PTHREAD_SERIALIZE 0 -#define APR_USE_PTHREAD_SERIALIZE 0 - -#define APR_HAS_FLOCK_SERIALIZE 0 -#define APR_HAS_SYSVSEM_SERIALIZE 0 -#define APR_HAS_POSIXSEM_SERIALIZE 0 -#define APR_HAS_FCNTL_SERIALIZE 0 -#define APR_HAS_PROC_PTHREAD_SERIALIZE 0 - -#define APR_PROCESS_LOCK_IS_GLOBAL 0 - -#define APR_HAVE_CORKABLE_TCP 0 -#define APR_HAVE_GETRLIMIT 0 -#define APR_HAVE_ICONV 0 -#define APR_HAVE_IN_ADDR 1 -#define APR_HAVE_INET_ADDR 1 -#define APR_HAVE_INET_NETWORK 0 -#define APR_HAVE_IPV6 0 -#define APR_HAVE_MEMMOVE 1 -#define APR_HAVE_SETRLIMIT 0 -#define APR_HAVE_SIGACTION 0 -#define APR_HAVE_SIGSUSPEND 0 -#define APR_HAVE_SIGWAIT 0 -#define APR_HAVE_SA_STORAGE 0 -#define APR_HAVE_STRCASECMP 0 -#define APR_HAVE_STRDUP 1 -#define APR_HAVE_STRNCASECMP 0 -#define APR_HAVE_STRSTR 1 -#define APR_HAVE_MEMCHR 1 -#define APR_HAVE_STRUCT_RLIMIT 0 -#define APR_HAVE_UNION_SEMUN 0 -#define APR_HAVE_SCTP 0 -#define APR_HAVE_IOVEC 0 - -#ifndef _WIN32_WCE -#define APR_HAVE_STRICMP 1 -#define APR_HAVE_STRNICMP 1 -#else -#define APR_HAVE_STRICMP 0 -#define APR_HAVE_STRNICMP 0 -#endif - -/* APR Feature Macros */ -#define APR_HAS_SHARED_MEMORY 1 -#define APR_HAS_THREADS 1 -#define APR_HAS_MMAP 1 -#define APR_HAS_FORK 0 -#define APR_HAS_RANDOM 1 -#define APR_HAS_OTHER_CHILD 1 -#define APR_HAS_DSO 1 -#define APR_HAS_SO_ACCEPTFILTER 0 -#define APR_HAS_UNICODE_FS 1 -#define APR_HAS_PROC_INVOKED 1 -#define APR_HAS_OS_UUID 1 - -#ifndef _WIN32_WCE -#define APR_HAS_SENDFILE 1 -#define APR_HAS_USER 1 -#define APR_HAS_LARGE_FILES 1 -#define APR_HAS_XTHREAD_FILES 1 -#define APR_PROCATTR_USER_SET_REQUIRES_PASSWORD 1 -#else -#define APR_HAS_SENDFILE 0 -#define APR_HAS_USER 0 -#define APR_HAS_LARGE_FILES 0 -#define APR_HAS_XTHREAD_FILES 0 -#define APR_PROCATTR_USER_SET_REQUIRES_PASSWORD 0 -#endif - -/* APR sets APR_FILES_AS_SOCKETS to 1 on systems where it is possible - * to poll on files/pipes. - */ -#define APR_FILES_AS_SOCKETS 0 - -/* This macro indicates whether or not EBCDIC is the native character set. - */ -#define APR_CHARSET_EBCDIC 0 - -/* If we have a TCP implementation that can be "corked", what flag - * do we use? - */ -#define APR_TCP_NOPUSH_FLAG @apr_tcp_nopush_flag@ - -/* Is the TCP_NODELAY socket option inherited from listening sockets? - */ -#define APR_TCP_NODELAY_INHERITED 1 - -/* Is the O_NONBLOCK flag inherited from listening sockets? - */ -#define APR_O_NONBLOCK_INHERITED 1 - -/* Typedefs that APR needs. */ - -typedef unsigned char apr_byte_t; - -typedef short apr_int16_t; -typedef unsigned short apr_uint16_t; - -typedef int apr_int32_t; -typedef unsigned int apr_uint32_t; - -typedef __int64 apr_int64_t; -typedef unsigned __int64 apr_uint64_t; - -typedef size_t apr_size_t; -#if APR_HAVE_STDDEF_H -typedef ptrdiff_t apr_ssize_t; -#else -typedef int apr_ssize_t; -#endif -#if APR_HAS_LARGE_FILES -typedef __int64 apr_off_t; -#else -typedef int apr_off_t; -#endif -typedef int apr_socklen_t; -typedef apr_uint64_t apr_ino_t; - -#ifdef WIN64 -#define APR_SIZEOF_VOIDP 8 -#else -#define APR_SIZEOF_VOIDP 4 -#endif - -#if APR_SIZEOF_VOIDP == 8 -typedef apr_uint64_t apr_uintptr_t; -#else -typedef apr_uint32_t apr_uintptr_t; -#endif - -/* Are we big endian? */ -/* XXX: Fatal assumption on Alpha platforms */ -#define APR_IS_BIGENDIAN 0 - -/* Mechanisms to properly type numeric literals */ - -#ifndef __GNUC__ -#define APR_INT64_C(val) (val##i64) -#define APR_UINT64_C(val) (val##Ui64) -#else -#define APR_INT64_C(val) (val##LL) -#define APR_UINT64_C(val) (val##ULL) -#endif - -#ifdef INT16_MIN -#define APR_INT16_MIN INT16_MIN -#else -#define APR_INT16_MIN (-0x7fff - 1) -#endif - -#ifdef INT16_MAX -#define APR_INT16_MAX INT16_MAX -#else -#define APR_INT16_MAX (0x7fff) -#endif - -#ifdef UINT16_MAX -#define APR_UINT16_MAX UINT16_MAX -#else -#define APR_UINT16_MAX (0xffff) -#endif - -#ifdef INT32_MIN -#define APR_INT32_MIN INT32_MIN -#else -#define APR_INT32_MIN (-0x7fffffff - 1) -#endif - -#ifdef INT32_MAX -#define APR_INT32_MAX INT32_MAX -#else -#define APR_INT32_MAX 0x7fffffff -#endif - -#ifdef UINT32_MAX -#define APR_UINT32_MAX UINT32_MAX -#else -#define APR_UINT32_MAX (0xffffffffU) -#endif - -#ifdef INT64_MIN -#define APR_INT64_MIN INT64_MIN -#else -#define APR_INT64_MIN (APR_INT64_C(-0x7fffffffffffffff) - 1) -#endif - -#ifdef INT64_MAX -#define APR_INT64_MAX INT64_MAX -#else -#define APR_INT64_MAX APR_INT64_C(0x7fffffffffffffff) -#endif - -#ifdef UINT64_MAX -#define APR_UINT64_MAX UINT64_MAX -#else -#define APR_UINT64_MAX APR_UINT64_C(0xffffffffffffffff) -#endif - -#define APR_SIZE_MAX (~((apr_size_t)0)) - -/* Definitions that APR programs need to work properly. */ - -/** - * APR public API wrap for C++ compilers. - */ -#ifdef __cplusplus -#define APR_BEGIN_DECLS extern "C" { -#define APR_END_DECLS } -#else -#define APR_BEGIN_DECLS -#define APR_END_DECLS -#endif - -/** - * Thread callbacks from APR functions must be declared with APR_THREAD_FUNC, - * so that they follow the platform's calling convention. - *
    - *
    - * void* APR_THREAD_FUNC my_thread_entry_fn(apr_thread_t *thd, void *data);
    - *
    - * 
    - */ -#define APR_THREAD_FUNC __stdcall - - -#if defined(DOXYGEN) || !defined(WIN32) - -/** - * The public APR functions are declared with APR_DECLARE(), so they may - * use the most appropriate calling convention. Public APR functions with - * variable arguments must use APR_DECLARE_NONSTD(). - * - * @remark Both the declaration and implementations must use the same macro. - * - *
    - * APR_DECLARE(rettype) apr_func(args)
    - * 
    - * @see APR_DECLARE_NONSTD @see APR_DECLARE_DATA - * @remark Note that when APR compiles the library itself, it passes the - * symbol -DAPR_DECLARE_EXPORT to the compiler on some platforms (e.g. Win32) - * to export public symbols from the dynamic library build.\n - * The user must define the APR_DECLARE_STATIC when compiling to target - * the static APR library on some platforms (e.g. Win32.) The public symbols - * are neither exported nor imported when APR_DECLARE_STATIC is defined.\n - * By default, compiling an application and including the APR public - * headers, without defining APR_DECLARE_STATIC, will prepare the code to be - * linked to the dynamic library. - */ -#define APR_DECLARE(type) type - -/** - * The public APR functions using variable arguments are declared with - * APR_DECLARE_NONSTD(), as they must follow the C language calling convention. - * @see APR_DECLARE @see APR_DECLARE_DATA - * @remark Both the declaration and implementations must use the same macro. - *
    - *
    - * APR_DECLARE_NONSTD(rettype) apr_func(args, ...);
    - *
    - * 
    - */ -#define APR_DECLARE_NONSTD(type) type - -/** - * The public APR variables are declared with AP_MODULE_DECLARE_DATA. - * This assures the appropriate indirection is invoked at compile time. - * @see APR_DECLARE @see APR_DECLARE_NONSTD - * @remark Note that the declaration and implementations use different forms, - * but both must include the macro. - * - *
    - *
    - * extern APR_DECLARE_DATA type apr_variable;\n
    - * APR_DECLARE_DATA type apr_variable = value;
    - *
    - * 
    - */ -#define APR_DECLARE_DATA - -#elif defined(APR_DECLARE_STATIC) -#define APR_DECLARE(type) type __stdcall -#define APR_DECLARE_NONSTD(type) type __cdecl -#define APR_DECLARE_DATA -#elif defined(APR_DECLARE_EXPORT) -#define APR_DECLARE(type) __declspec(dllexport) type __stdcall -#define APR_DECLARE_NONSTD(type) __declspec(dllexport) type __cdecl -#define APR_DECLARE_DATA __declspec(dllexport) -#else -#define APR_DECLARE(type) __declspec(dllimport) type __stdcall -#define APR_DECLARE_NONSTD(type) __declspec(dllimport) type __cdecl -#define APR_DECLARE_DATA __declspec(dllimport) -#endif - -#ifdef WIN64 -#define APR_SSIZE_T_FMT "I64d" -#define APR_SIZE_T_FMT "I64u" -#else -#define APR_SSIZE_T_FMT "d" -#define APR_SIZE_T_FMT "u" -#endif - -#if APR_HAS_LARGE_FILES -#define APR_OFF_T_FMT "I64d" -#else -#define APR_OFF_T_FMT "d" -#endif - -#define APR_PID_T_FMT "d" - -#define APR_INT64_T_FMT "I64d" -#define APR_UINT64_T_FMT "I64u" -#define APR_UINT64_T_HEX_FMT "I64x" - -/* No difference between PROC and GLOBAL mutex */ -#define APR_PROC_MUTEX_IS_GLOBAL 1 - -/* Local machine definition for console and log output. */ -#define APR_EOL_STR "\r\n" - -typedef int apr_wait_t; - -#if APR_HAS_UNICODE_FS -/* An arbitrary size that is digestable. True max is a bit less than 32000 */ -#define APR_PATH_MAX 8192 -#else /* !APR_HAS_UNICODE_FS */ -#define APR_PATH_MAX MAX_PATH -#endif - -#define APR_DSOPATH "PATH" - -/** @} */ - -/* Definitions that only Win32 programs need to compile properly. */ - -/* XXX These simply don't belong here, perhaps in apr_portable.h - * based on some APR_HAVE_PID/GID/UID? - */ -#ifndef __GNUC__ -typedef int pid_t; -#endif -typedef int uid_t; -typedef int gid_t; - -/* Win32 .h ommissions we really need */ -#define STDIN_FILENO 0 -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 - -#if APR_HAVE_IPV6 - -/* Appears in later flavors, not the originals. */ -#ifndef in_addr6 -#define in6_addr in_addr6 -#endif - -#ifndef WS2TCPIP_INLINE -#define IN6_IS_ADDR_V4MAPPED(a) \ - ( (*(const apr_uint64_t *)(const void *)(&(a)->s6_addr[0]) == 0) \ - && (*(const apr_uint32_t *)(const void *)(&(a)->s6_addr[8]) == ntohl(0x0000ffff))) -#endif - -#endif /* APR_HAS_IPV6 */ - -#ifdef __cplusplus -} -#endif - -/* Done with badly written headers - */ -#if defined(_MSC_VER) && _MSC_VER >= 1200 -#pragma warning(pop) -#pragma warning(disable: 4996) -#endif - -#endif /* WIN32 */ - -#endif /* APR_H */ diff --git a/libs/apr/include/apr.h.in b/libs/apr/include/apr.h.in deleted file mode 100644 index a411dd02..00000000 --- a/libs/apr/include/apr.h.in +++ /dev/null @@ -1,621 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef APR_H -#define APR_H - -/* GENERATED FILE WARNING! DO NOT EDIT apr.h - * - * You must modify apr.h.in instead. - * - * And please, make an effort to stub apr.hw and apr.hnw in the process. - */ - -/** - * @file apr.h - * @brief APR Platform Definitions - * @remark This is a generated header generated from include/apr.h.in by - * ./configure, or copied from include/apr.hw or include/apr.hnw - * for Win32 or Netware by those build environments, respectively. - */ - -/** - * @defgroup APR Apache Portability Runtime library - * @{ - */ -/** - * @defgroup apr_platform Platform Definitions - * @{ - * @warning - * The actual values of macros and typedefs on this page
    - * are platform specific and should NOT be relied upon!
    - */ - -/* So that we can use inline on some critical functions, and use - * GNUC attributes (such as to get -Wall warnings for printf-like - * functions). Only do this in gcc 2.7 or later ... it may work - * on earlier stuff, but why chance it. - * - * We've since discovered that the gcc shipped with NeXT systems - * as "cc" is completely broken. It claims to be __GNUC__ and so - * on, but it doesn't implement half of the things that __GNUC__ - * means. In particular it's missing inline and the __attribute__ - * stuff. So we hack around it. PR#1613. -djg - */ -#if !defined(__GNUC__) || __GNUC__ < 2 || \ - (__GNUC__ == 2 && __GNUC_MINOR__ < 7) ||\ - defined(NEXT) -#ifndef __attribute__ -#define __attribute__(__x) -#endif -#define APR_INLINE -#define APR_HAS_INLINE 0 -#else -#define APR_INLINE __inline__ -#define APR_HAS_INLINE 1 -#endif - -#define APR_HAVE_ARPA_INET_H @arpa_ineth@ -#define APR_HAVE_CONIO_H @conioh@ -#define APR_HAVE_CRYPT_H @crypth@ -#define APR_HAVE_CTYPE_H @ctypeh@ -#define APR_HAVE_DIRENT_H @direnth@ -#define APR_HAVE_ERRNO_H @errnoh@ -#define APR_HAVE_FCNTL_H @fcntlh@ -#define APR_HAVE_IO_H @ioh@ -#define APR_HAVE_LIMITS_H @limitsh@ -#define APR_HAVE_NETDB_H @netdbh@ -#define APR_HAVE_NETINET_IN_H @netinet_inh@ -#define APR_HAVE_NETINET_SCTP_H @netinet_sctph@ -#define APR_HAVE_NETINET_SCTP_UIO_H @netinet_sctp_uioh@ -#define APR_HAVE_NETINET_TCP_H @netinet_tcph@ -#define APR_HAVE_PROCESS_H @processh@ -#define APR_HAVE_PTHREAD_H @pthreadh@ -#define APR_HAVE_SEMAPHORE_H @semaphoreh@ -#define APR_HAVE_SIGNAL_H @signalh@ -#define APR_HAVE_STDARG_H @stdargh@ -#define APR_HAVE_STDINT_H @stdint@ -#define APR_HAVE_STDIO_H @stdioh@ -#define APR_HAVE_STDLIB_H @stdlibh@ -#define APR_HAVE_STRING_H @stringh@ -#define APR_HAVE_STRINGS_H @stringsh@ -#define APR_HAVE_SYS_IOCTL_H @sys_ioctlh@ -#define APR_HAVE_SYS_SENDFILE_H @sys_sendfileh@ -#define APR_HAVE_SYS_SIGNAL_H @sys_signalh@ -#define APR_HAVE_SYS_SOCKET_H @sys_socketh@ -#define APR_HAVE_SYS_SOCKIO_H @sys_sockioh@ -#define APR_HAVE_SYS_SYSLIMITS_H @sys_syslimitsh@ -#define APR_HAVE_SYS_TIME_H @sys_timeh@ -#define APR_HAVE_SYS_TYPES_H @sys_typesh@ -#define APR_HAVE_SYS_UIO_H @sys_uioh@ -#define APR_HAVE_SYS_UN_H @sys_unh@ -#define APR_HAVE_SYS_WAIT_H @sys_waith@ -#define APR_HAVE_TIME_H @timeh@ -#define APR_HAVE_UNISTD_H @unistdh@ -#define APR_HAVE_WINDOWS_H @windowsh@ -#define APR_HAVE_WINSOCK2_H @winsock2h@ - -/** @} */ -/** @} */ - -/* We don't include our conditional headers within the doxyblocks - * or the extern "C" namespace - */ - -#if APR_HAVE_WINDOWS_H -/* If windows.h was already included, our preferences don't matter. - * If not, include a restricted set of windows headers to our tastes. - */ -#ifndef _WINDOWS_ - -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif - -#ifndef _WIN32_WINNT -/* Restrict the server to a subset of Windows XP header files by default - */ -#define _WIN32_WINNT 0x0501 -#endif - -#ifndef NOUSER -#define NOUSER -#endif -#ifndef NOMCX -#define NOMCX -#endif -#ifndef NOIME -#define NOIME -#endif - -#include -/* - * Add a _very_few_ declarations missing from the restricted set of headers - * (If this list becomes extensive, re-enable the required headers above!) - * winsock headers were excluded by WIN32_LEAN_AND_MEAN, so include them now - */ -#define SW_HIDE 0 -#ifndef _WIN32_WCE -#include -#include -#include -#else -#include -#endif - -#endif /* ndef _WINDOWS_ */ -#endif /* APR_HAVE_WINDOWS_H */ - -#if APR_HAVE_SYS_TYPES_H -#include -#endif - -#if APR_HAVE_SYS_SOCKET_H -#include -#endif - -#if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS) -/* C99 7.18.4 requires that stdint.h only exposes INT64_C - * and UINT64_C for C++ implementations if this is defined: */ -#define __STDC_CONSTANT_MACROS -#endif - -#if APR_HAVE_STDINT_H -#include -#endif - -#if APR_HAVE_SYS_WAIT_H -#include -#endif - -#ifdef OS2 -#define INCL_DOS -#define INCL_DOSERRORS -#include -#endif - -/* header files for PATH_MAX, _POSIX_PATH_MAX */ -#if APR_HAVE_LIMITS_H -#include -#else -#if APR_HAVE_SYS_SYSLIMITS_H -#include -#endif -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup apr_platform - * @ingroup APR - * @{ - */ - -#define APR_HAVE_SHMEM_MMAP_TMP @havemmaptmp@ -#define APR_HAVE_SHMEM_MMAP_SHM @havemmapshm@ -#define APR_HAVE_SHMEM_MMAP_ZERO @havemmapzero@ -#define APR_HAVE_SHMEM_SHMGET_ANON @haveshmgetanon@ -#define APR_HAVE_SHMEM_SHMGET @haveshmget@ -#define APR_HAVE_SHMEM_MMAP_ANON @havemmapanon@ -#define APR_HAVE_SHMEM_BEOS @havebeosarea@ - -#define APR_USE_SHMEM_MMAP_TMP @usemmaptmp@ -#define APR_USE_SHMEM_MMAP_SHM @usemmapshm@ -#define APR_USE_SHMEM_MMAP_ZERO @usemmapzero@ -#define APR_USE_SHMEM_SHMGET_ANON @useshmgetanon@ -#define APR_USE_SHMEM_SHMGET @useshmget@ -#define APR_USE_SHMEM_MMAP_ANON @usemmapanon@ -#define APR_USE_SHMEM_BEOS @usebeosarea@ - -#define APR_USE_FLOCK_SERIALIZE @flockser@ -#define APR_USE_SYSVSEM_SERIALIZE @sysvser@ -#define APR_USE_POSIXSEM_SERIALIZE @posixser@ -#define APR_USE_FCNTL_SERIALIZE @fcntlser@ -#define APR_USE_PROC_PTHREAD_SERIALIZE @procpthreadser@ -#define APR_USE_PTHREAD_SERIALIZE @pthreadser@ - -#define APR_HAS_FLOCK_SERIALIZE @hasflockser@ -#define APR_HAS_SYSVSEM_SERIALIZE @hassysvser@ -#define APR_HAS_POSIXSEM_SERIALIZE @hasposixser@ -#define APR_HAS_FCNTL_SERIALIZE @hasfcntlser@ -#define APR_HAS_PROC_PTHREAD_SERIALIZE @hasprocpthreadser@ - -#define APR_PROCESS_LOCK_IS_GLOBAL @proclockglobal@ - -#define APR_HAVE_CORKABLE_TCP @have_corkable_tcp@ -#define APR_HAVE_GETRLIMIT @have_getrlimit@ -#define APR_HAVE_IN_ADDR @have_in_addr@ -#define APR_HAVE_INET_ADDR @have_inet_addr@ -#define APR_HAVE_INET_NETWORK @have_inet_network@ -#define APR_HAVE_IPV6 @have_ipv6@ -#define APR_HAVE_MEMMOVE @have_memmove@ -#define APR_HAVE_SETRLIMIT @have_setrlimit@ -#define APR_HAVE_SIGACTION @have_sigaction@ -#define APR_HAVE_SIGSUSPEND @have_sigsuspend@ -#define APR_HAVE_SIGWAIT @have_sigwait@ -#define APR_HAVE_SA_STORAGE @have_sa_storage@ -#define APR_HAVE_STRCASECMP @have_strcasecmp@ -#define APR_HAVE_STRDUP @have_strdup@ -#define APR_HAVE_STRICMP @have_stricmp@ -#define APR_HAVE_STRNCASECMP @have_strncasecmp@ -#define APR_HAVE_STRNICMP @have_strnicmp@ -#define APR_HAVE_STRSTR @have_strstr@ -#define APR_HAVE_MEMCHR @have_memchr@ -#define APR_HAVE_STRUCT_RLIMIT @struct_rlimit@ -#define APR_HAVE_UNION_SEMUN @have_union_semun@ -#define APR_HAVE_SCTP @have_sctp@ -#define APR_HAVE_IOVEC @have_iovec@ - -/* APR Feature Macros */ -#define APR_HAS_SHARED_MEMORY @sharedmem@ -#define APR_HAS_THREADS @threads@ -#define APR_HAS_SENDFILE @sendfile@ -#define APR_HAS_MMAP @mmap@ -#define APR_HAS_FORK @fork@ -#define APR_HAS_RANDOM @rand@ -#define APR_HAS_OTHER_CHILD @oc@ -#define APR_HAS_DSO @aprdso@ -#define APR_HAS_SO_ACCEPTFILTER @acceptfilter@ -#define APR_HAS_UNICODE_FS @have_unicode_fs@ -#define APR_HAS_PROC_INVOKED @have_proc_invoked@ -#define APR_HAS_USER @apr_has_user@ -#define APR_HAS_LARGE_FILES @aprlfs@ -#define APR_HAS_XTHREAD_FILES @apr_has_xthread_files@ -#define APR_HAS_OS_UUID @osuuid@ - -#define APR_PROCATTR_USER_SET_REQUIRES_PASSWORD @apr_procattr_user_set_requires_password@ - -/* APR sets APR_FILES_AS_SOCKETS to 1 on systems where it is possible - * to poll on files/pipes. - */ -#define APR_FILES_AS_SOCKETS @file_as_socket@ - -/* This macro indicates whether or not EBCDIC is the native character set. - */ -#define APR_CHARSET_EBCDIC @apr_charset_ebcdic@ - -/* If we have a TCP implementation that can be "corked", what flag - * do we use? - */ -#define APR_TCP_NOPUSH_FLAG @apr_tcp_nopush_flag@ - -/* Is the TCP_NODELAY socket option inherited from listening sockets? -*/ -#define APR_TCP_NODELAY_INHERITED @tcp_nodelay_inherited@ - -/* Is the O_NONBLOCK flag inherited from listening sockets? -*/ -#define APR_O_NONBLOCK_INHERITED @o_nonblock_inherited@ - -/* Typedefs that APR needs. */ - -typedef unsigned char apr_byte_t; - -typedef @short_value@ apr_int16_t; -typedef unsigned @short_value@ apr_uint16_t; - -typedef @int_value@ apr_int32_t; -typedef unsigned @int_value@ apr_uint32_t; - -#define APR_SIZEOF_VOIDP @voidp_size@ - -/* - * Darwin 10's default compiler (gcc42) builds for both 64 and - * 32 bit architectures unless specifically told not to. - * In those cases, we need to override types depending on how - * we're being built at compile time. - * NOTE: This is an ugly work-around for Darwin's - * concept of universal binaries, a single package - * (executable, lib, etc...) which contains both 32 - * and 64 bit versions. The issue is that if APR is - * built universally, if something else is compiled - * against it, some bit sizes will depend on whether - * it is 32 or 64 bit. This is determined by the __LP64__ - * flag. Since we need to support both, we have to - * handle OS X unqiuely. - */ -#ifdef DARWIN_10 -#undef APR_SIZEOF_VOIDP -#undef INT64_C -#undef UINT64_C -#ifdef __LP64__ - typedef long apr_int64_t; - typedef unsigned long apr_uint64_t; - #define APR_SIZEOF_VOIDP 8 - #define INT64_C(v) (v ## L) - #define UINT64_C(v) (v ## UL) -#else - typedef long long apr_int64_t; - typedef unsigned long long apr_uint64_t; - #define APR_SIZEOF_VOIDP 4 - #define INT64_C(v) (v ## LL) - #define UINT64_C(v) (v ## ULL) -#endif -#else - typedef @long_value@ apr_int64_t; - typedef unsigned @long_value@ apr_uint64_t; -#endif - -typedef @size_t_value@ apr_size_t; -typedef @ssize_t_value@ apr_ssize_t; -typedef @off_t_value@ apr_off_t; -typedef @socklen_t_value@ apr_socklen_t; -typedef @ino_t_value@ apr_ino_t; - -#if APR_SIZEOF_VOIDP == 8 -typedef apr_uint64_t apr_uintptr_t; -#else -typedef apr_uint32_t apr_uintptr_t; -#endif - -/* Are we big endian? */ -#define APR_IS_BIGENDIAN @bigendian@ - -/* Mechanisms to properly type numeric literals */ -@int64_literal@ -@uint64_literal@ - -#ifdef INT16_MIN -#define APR_INT16_MIN INT16_MIN -#else -#define APR_INT16_MIN (-0x7fff - 1) -#endif - -#ifdef INT16_MAX -#define APR_INT16_MAX INT16_MAX -#else -#define APR_INT16_MAX (0x7fff) -#endif - -#ifdef UINT16_MAX -#define APR_UINT16_MAX UINT16_MAX -#else -#define APR_UINT16_MAX (0xffff) -#endif - -#ifdef INT32_MIN -#define APR_INT32_MIN INT32_MIN -#else -#define APR_INT32_MIN (-0x7fffffff - 1) -#endif - -#ifdef INT32_MAX -#define APR_INT32_MAX INT32_MAX -#else -#define APR_INT32_MAX 0x7fffffff -#endif - -#ifdef UINT32_MAX -#define APR_UINT32_MAX UINT32_MAX -#else -#define APR_UINT32_MAX (0xffffffffU) -#endif - -#ifdef INT64_MIN -#define APR_INT64_MIN INT64_MIN -#else -#define APR_INT64_MIN (APR_INT64_C(-0x7fffffffffffffff) - 1) -#endif - -#ifdef INT64_MAX -#define APR_INT64_MAX INT64_MAX -#else -#define APR_INT64_MAX APR_INT64_C(0x7fffffffffffffff) -#endif - -#ifdef UINT64_MAX -#define APR_UINT64_MAX UINT64_MAX -#else -#define APR_UINT64_MAX APR_UINT64_C(0xffffffffffffffff) -#endif - -#define APR_SIZE_MAX (~((apr_size_t)0)) - - -/* Definitions that APR programs need to work properly. */ - -/** - * APR public API wrap for C++ compilers. - */ -#ifdef __cplusplus -#define APR_BEGIN_DECLS extern "C" { -#define APR_END_DECLS } -#else -#define APR_BEGIN_DECLS -#define APR_END_DECLS -#endif - -/** - * Thread callbacks from APR functions must be declared with APR_THREAD_FUNC, - * so that they follow the platform's calling convention. - *
    - *
    - * void* APR_THREAD_FUNC my_thread_entry_fn(apr_thread_t *thd, void *data);
    - *
    - * 
    - */ -#define APR_THREAD_FUNC @apr_thread_func@ - -/** - * The public APR functions are declared with APR_DECLARE(), so they may - * use the most appropriate calling convention. Public APR functions with - * variable arguments must use APR_DECLARE_NONSTD(). - * - * @remark Both the declaration and implementations must use the same macro. - * - *
    - * APR_DECLARE(rettype) apr_func(args)
    - * 
    - * @see APR_DECLARE_NONSTD @see APR_DECLARE_DATA - * @remark Note that when APR compiles the library itself, it passes the - * symbol -DAPR_DECLARE_EXPORT to the compiler on some platforms (e.g. Win32) - * to export public symbols from the dynamic library build.\n - * The user must define the APR_DECLARE_STATIC when compiling to target - * the static APR library on some platforms (e.g. Win32.) The public symbols - * are neither exported nor imported when APR_DECLARE_STATIC is defined.\n - * By default, compiling an application and including the APR public - * headers, without defining APR_DECLARE_STATIC, will prepare the code to be - * linked to the dynamic library. - */ -#define APR_DECLARE(type) type - -/** - * The public APR functions using variable arguments are declared with - * APR_DECLARE_NONSTD(), as they must follow the C language calling convention. - * @see APR_DECLARE @see APR_DECLARE_DATA - * @remark Both the declaration and implementations must use the same macro. - *
    - *
    - * APR_DECLARE_NONSTD(rettype) apr_func(args, ...);
    - *
    - * 
    - */ -#define APR_DECLARE_NONSTD(type) type - -/** - * The public APR variables are declared with AP_MODULE_DECLARE_DATA. - * This assures the appropriate indirection is invoked at compile time. - * @see APR_DECLARE @see APR_DECLARE_NONSTD - * @remark Note that the declaration and implementations use different forms, - * but both must include the macro. - * - *
    - *
    - * extern APR_DECLARE_DATA type apr_variable;\n
    - * APR_DECLARE_DATA type apr_variable = value;
    - *
    - * 
    - */ -#define APR_DECLARE_DATA - -/* Define APR_SSIZE_T_FMT. - * If ssize_t is an integer we define it to be "d", - * if ssize_t is a long int we define it to be "ld", - * if ssize_t is neither we declare an error here. - * I looked for a better way to define this here, but couldn't find one, so - * to find the logic for this definition search for "ssize_t_fmt" in - * configure.in. - */ - -@ssize_t_fmt@ - -/* And APR_SIZE_T_FMT */ -@size_t_fmt@ - -/* And APR_OFF_T_FMT */ -@off_t_fmt@ - -/* And APR_PID_T_FMT */ -@pid_t_fmt@ - -/* And APR_INT64_T_FMT */ -@int64_t_fmt@ - -/* And APR_UINT64_T_FMT */ -@uint64_t_fmt@ - -/* And APR_UINT64_T_HEX_FMT */ -@uint64_t_hex_fmt@ - -/* - * Ensure we work with universal binaries on Darwin - */ -#ifdef DARWIN_10 - -#undef APR_HAS_LARGE_FILES -#undef APR_SIZEOF_VOIDP -#undef APR_INT64_T_FMT -#undef APR_UINT64_T_FMT -#undef APR_UINT64_T_HEX_FMT - -#ifdef __LP64__ - #define APR_HAS_LARGE_FILES 0 - #define APR_SIZEOF_VOIDP 8 - #define APR_INT64_T_FMT "ld" - #define APR_UINT64_T_FMT "lu" - #define APR_UINT64_T_HEX_FMT "lx" -#else - #define APR_HAS_LARGE_FILES 1 - #define APR_SIZEOF_VOIDP 4 - #define APR_INT64_T_FMT "lld" - #define APR_UINT64_T_FMT "llu" - #define APR_UINT64_T_HEX_FMT "llx" -#endif - -#undef APR_IS_BIGENDIAN -#ifdef __BIG_ENDIAN__ - #define APR_IS_BIGENDIAN 1 -#else - #define APR_IS_BIGENDIAN 0 -#endif - -#undef APR_OFF_T_FMT -#define APR_OFF_T_FMT "lld" - -#endif /* DARWIN_10 */ - -/* Does the proc mutex lock threads too */ -#define APR_PROC_MUTEX_IS_GLOBAL @proc_mutex_is_global@ - -/* Local machine definition for console and log output. */ -#define APR_EOL_STR "@eolstr@" - -#if APR_HAVE_SYS_WAIT_H -#ifdef WEXITSTATUS -#define apr_wait_t int -#else -#define apr_wait_t union wait -#define WEXITSTATUS(status) (int)((status).w_retcode) -#define WTERMSIG(status) (int)((status).w_termsig) -#endif /* !WEXITSTATUS */ -#elif defined(__MINGW32__) -typedef int apr_wait_t; -#endif /* HAVE_SYS_WAIT_H */ - -#if defined(PATH_MAX) -#define APR_PATH_MAX PATH_MAX -#elif defined(_POSIX_PATH_MAX) -#define APR_PATH_MAX _POSIX_PATH_MAX -#else -#error no decision has been made on APR_PATH_MAX for your platform -#endif - -#define APR_DSOPATH "@shlibpath_var@" - -/** @} */ - -/* Definitions that only Win32 programs need to compile properly. */ - -/* XXX These simply don't belong here, perhaps in apr_portable.h - * based on some APR_HAVE_PID/GID/UID? - */ -#ifdef __MINGW32__ -#ifndef __GNUC__ -typedef int pid_t; -#endif -typedef int uid_t; -typedef int gid_t; -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* APR_H */ diff --git a/libs/apr/include/apr.hnw b/libs/apr/include/apr.hnw deleted file mode 100644 index d0c77e00..00000000 --- a/libs/apr/include/apr.hnw +++ /dev/null @@ -1,443 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef APR_H -#define APR_H - -/* GENERATED FILE WARNING! DO NOT EDIT apr.h - * - * You must modify apr.hnw instead. - * - * And please, make an effort to stub apr.hw and apr.h.in in the process. - * - * This is the NetWare specific version of apr.h. It is copied from - * apr.hnw at the start of a NetWare build by the ./build/NWGNmakefile. - */ - -/** - * @file apr.h - * @brief APR Platform Definitions - * @remark This is a generated header generated from include/apr.h.in by - * ./configure, or copied from include/apr.hw or include/apr.hnw - * for Win32 or Netware by those build environments, respectively. - */ - -#if defined(NETWARE) || defined(DOXYGEN) - -#undef FD_SETSIZE -#define FD_SETSIZE 1024 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef USE_WINSOCK -#include -#ifdef NW_BUILD_IPV6 -#include -#endif -#else -#include -#include -#endif -#include - -#define _POSIX_THREAD_SAFE_FUNCTIONS 1 -#define READDIR_IS_THREAD_SAFE 1 - -/* Keep #include'd headers from within the __cplusplus or doxyblocks */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup apr_platform Platform Definitions - * @ingroup APR - * @{ - */ - -#define APR_INLINE -#define APR_HAS_INLINE 0 -#ifndef __attribute__ -#define __attribute__(__x) -#endif -#define ENUM_BITFIELD(e,n,w) signed int n : w - -#define APR_HAVE_CONIO_H 0 -#define APR_HAVE_CRYPT_H 0 -#define APR_HAVE_CTYPE_H 1 -#define APR_HAVE_DIRENT_H 1 -#define APR_HAVE_ERRNO_H 1 -#define APR_HAVE_FCNTL_H 1 -#define APR_HAVE_IO_H 0 -#define APR_HAVE_LIMITS_H 1 -#ifdef USE_WINSOCK -#define APR_HAVE_ARPA_INET_H 0 -#define APR_HAVE_NETDB_H 0 -#define APR_HAVE_NETINET_IN_H 0 -#else -#define APR_HAVE_ARPA_INET_H 1 -#define APR_HAVE_NETDB_H 1 -#define APR_HAVE_NETINET_IN_H 1 -#endif -#define APR_HAVE_NETINET_SCTP_H 0 -#define APR_HAVE_NETINET_SCTP_UIO_H 0 -#define APR_HAVE_NETINET_TCP_H 0 -#define APR_HAVE_PTHREAD_H 0 -#define APR_HAVE_SIGNAL_H 1 -#define APR_HAVE_STDARG_H 1 -#define APR_HAVE_STDINT_H 0 -#define APR_HAVE_STDIO_H 1 -#define APR_HAVE_STDLIB_H 1 -#define APR_HAVE_STRING_H 1 -#define APR_HAVE_STRINGS_H 0 -#define APR_HAVE_STRTOLL 1 -#define APR_HAVE_SYS_SENDFILE_H 0 -#define APR_HAVE_SYS_SYSLIMITS_H 0 -#ifdef USE_WINSOCK -#define APR_HAVE_SYS_SOCKET_H 0 -#define APR_HAVE_SYS_SOCKIO_H 0 -#define APR_HAVE_SYS_UN_H 0 -#else -#define APR_HAVE_SYS_SOCKET_H 1 -#define APR_HAVE_SYS_SOCKIO_H 1 -#define APR_HAVE_SYS_UN_H 1 -#endif -#define APR_HAVE_SYS_SIGNAL_H 1 -#define APR_HAVE_SYS_TIME_H 1 -#define APR_HAVE_SYS_TYPES_H 1 -#define APR_HAVE_SYS_UIO_H 1 -#define APR_HAVE_SYS_WAIT_H 1 -#define APR_HAVE_TIME_H 1 -#define APR_HAVE_UNISTD_H 1 - -#define APR_HAVE_SHMEM_MMAP_TMP 0 -#define APR_HAVE_SHMEM_MMAP_SHM 0 -#define APR_HAVE_SHMEM_MMAP_ZERO 0 -#define APR_HAVE_SHMEM_SHMGET_ANON 0 -#define APR_HAVE_SHMEM_SHMGET 0 -#define APR_HAVE_SHMEM_MMAP_ANON 0 -#define APR_HAVE_SHMEM_BEOS 0 - -#define APR_USE_SHMEM_MMAP_TMP 0 -#define APR_USE_SHMEM_MMAP_SHM 0 -#define APR_USE_SHMEM_MMAP_ZERO 0 -#define APR_USE_SHMEM_SHMGET_ANON 0 -#define APR_USE_SHMEM_SHMGET 0 -#define APR_USE_SHMEM_MMAP_ANON 0 -#define APR_USE_SHMEM_BEOS 0 - -#define APR_USE_FLOCK_SERIALIZE 0 -#define APR_USE_SYSVSEM_SERIALIZE 0 -#define APR_USE_FCNTL_SERIALIZE 0 -#define APR_USE_PROC_PTHREAD_SERIALIZE 0 -#define APR_USE_PTHREAD_SERIALIZE 0 - -#define APR_HAS_FLOCK_SERIALIZE 0 -#define APR_HAS_SYSVSEM_SERIALIZE 0 -#define APR_HAS_FCNTL_SERIALIZE 0 -#define APR_HAS_PROC_PTHREAD_SERIALIZE 0 -#define APR_HAS_RWLOCK_SERIALIZE 0 - -#define APR_HAS_LOCK_CREATE_NP 0 - -#define APR_PROCESS_LOCK_IS_GLOBAL 1 - -#define APR_FILE_BASED_SHM 0 - -#define APR_HAVE_CORKABLE_TCP 0 -#define APR_HAVE_GETRLIMIT 0 -#define APR_HAVE_ICONV 0 -#define APR_HAVE_IN_ADDR 1 -#define APR_HAVE_INET_ADDR 1 -#define APR_HAVE_INET_NETWORK 0 -#ifdef NW_BUILD_IPV6 -#define APR_HAVE_IPV6 1 -#else -#define APR_HAVE_IPV6 0 -#endif -#define APR_HAVE_MEMCHR 1 -#define APR_HAVE_MEMMOVE 1 -#define APR_HAVE_SETRLIMIT 0 -#define APR_HAVE_SIGACTION 0 -#define APR_HAVE_SIGSUSPEND 0 -#define APR_HAVE_SIGWAIT 0 -#define APR_HAVE_STRCASECMP 1 -#define APR_HAVE_STRDUP 1 -#define APR_HAVE_STRICMP 1 -#define APR_HAVE_STRNCASECMP 1 -#define APR_HAVE_STRNICMP 1 -#define APR_HAVE_STRSTR 1 -#define APR_HAVE_STRUCT_RLIMIT 0 -#define APR_HAVE_UNION_SEMUN 0 -#define APR_HAVE_SCTP 0 -#define APR_HAVE_IOVEC 1 - -/* APR Feature Macros */ -#define APR_HAS_SHARED_MEMORY 0 -#define APR_HAS_THREADS 1 -#define APR_HAS_SENDFILE 0 -#define APR_HAS_MMAP 0 -#define APR_HAS_FORK 0 -#define APR_HAS_RANDOM 1 -#define APR_HAS_OTHER_CHILD 0 -#define APR_HAS_DSO 1 -#define APR_HAS_SO_ACCEPTFILTER 0 -#define APR_HAS_UNICODE_FS 0 -#define APR_HAS_PROC_INVOKED 0 -#define APR_HAS_USER 1 -#define APR_HAS_LARGE_FILES 1 -#define APR_HAS_XTHREAD_FILES 0 -#define APR_HAS_OS_UUID 0 - -#define APR_PROCATTR_USER_SET_REQUIRES_PASSWORD 0 - -/* Netware can poll on files/pipes. - */ -#define APR_FILES_AS_SOCKETS 1 - -/* This macro indicates whether or not EBCDIC is the native character set. - */ -#define APR_CHARSET_EBCDIC 0 - -/* Is the TCP_NODELAY socket option inherited from listening sockets? -*/ -#define APR_TCP_NODELAY_INHERITED 1 - -/* Is the O_NONBLOCK flag inherited from listening sockets? -*/ -#define APR_O_NONBLOCK_INHERITED 1 - -/* Typedefs that APR needs. */ - -typedef unsigned char apr_byte_t; - -typedef short apr_int16_t; -typedef unsigned short apr_uint16_t; - -typedef int apr_int32_t; -typedef unsigned int apr_uint32_t; - -typedef long long apr_int64_t; -typedef unsigned long long apr_uint64_t; - -typedef size_t apr_size_t; -typedef ssize_t apr_ssize_t; -#if APR_HAS_LARGE_FILES -typedef off64_t apr_off_t; -#else -typedef off_t apr_off_t; -#endif -#ifdef USE_WINSOCK -typedef int apr_socklen_t; -#else -typedef size_t apr_socklen_t; -#endif -typedef apr_uint64_t apr_ino_t; - -/* Are we big endian? */ -/* XXX: Fatal assumption on Alpha platforms */ -#define APR_IS_BIGENDIAN 0 - -#ifdef UNKNOWN_NETWARE_64BIT_FLAG_NEEDED -#define APR_SIZEOF_VOIDP 8 -#else -#define APR_SIZEOF_VOIDP 4 -#endif - -#if APR_SIZEOF_VOIDP == 8 -typedef apr_uint64_t apr_uintptr_t; -#else -typedef apr_uint32_t apr_uintptr_t; -#endif - -/* Mechanisms to properly type numeric literals */ -#define APR_INT64_C(val) (val##LL) -#define APR_UINT64_C(val) (val##ULL) - -#ifdef INT16_MIN -#define APR_INT16_MIN INT16_MIN -#else -#define APR_INT16_MIN (-0x7fff - 1) -#endif - -#ifdef INT16_MAX -#define APR_INT16_MAX INT16_MAX -#else -#define APR_INT16_MAX (0x7fff) -#endif - -#ifdef UINT16_MAX -#define APR_UINT16_MAX UINT16_MAX -#else -#define APR_UINT16_MAX (0xffff) -#endif - -#ifdef INT32_MIN -#define APR_INT32_MIN INT32_MIN -#else -#define APR_INT32_MIN (-0x7fffffff - 1) -#endif - -#ifdef INT32_MAX -#define APR_INT32_MAX INT32_MAX -#else -#define APR_INT32_MAX 0x7fffffff -#endif - -#ifdef UINT32_MAX -#define APR_UINT32_MAX UINT32_MAX -#else -#define APR_UINT32_MAX (0xffffffffU) -#endif - -#ifdef INT64_MIN -#define APR_INT64_MIN INT64_MIN -#else -#define APR_INT64_MIN (APR_INT64_C(-0x7fffffffffffffff) - 1) -#endif - -#ifdef INT64_MAX -#define APR_INT64_MAX INT64_MAX -#else -#define APR_INT64_MAX APR_INT64_C(0x7fffffffffffffff) -#endif - -#ifdef UINT64_MAX -#define APR_UINT64_MAX UINT64_MAX -#else -#define APR_UINT64_MAX APR_UINT64_C(0xffffffffffffffff) -#endif - -#define APR_SIZE_MAX (~((apr_size_t)0)) - -/* PROC mutex is a GLOBAL mutex on Netware */ -#define APR_PROC_MUTEX_IS_GLOBAL 1 - -/* Definitions that APR programs need to work properly. */ - -/** - * APR public API wrap for C++ compilers. - */ -#ifdef __cplusplus -#define APR_BEGIN_DECLS extern "C" { -#define APR_END_DECLS } -#else -#define APR_BEGIN_DECLS -#define APR_END_DECLS -#endif - -/** - * Thread callbacks from APR functions must be declared with APR_THREAD_FUNC, - * so that they follow the platform's calling convention. - * @example - */ -/** void* APR_THREAD_FUNC my_thread_entry_fn(apr_thread_t *thd, void *data); - */ -#define APR_THREAD_FUNC - -/** - * The public APR functions are declared with APR_DECLARE(), so they may - * use the most appropriate calling convention. Public APR functions with - * variable arguments must use APR_DECLARE_NONSTD(). - * - * @remark Both the declaration and implementations must use the same macro. - * @example - */ -/** APR_DECLARE(rettype) apr_func(args) - * @see APR_DECLARE_NONSTD @see APR_DECLARE_DATA - * @remark Note that when APR compiles the library itself, it passes the - * symbol -DAPR_DECLARE_EXPORT to the compiler on some platforms (e.g. Win32) - * to export public symbols from the dynamic library build.\n - * The user must define the APR_DECLARE_STATIC when compiling to target - * the static APR library on some platforms (e.g. Win32.) The public symbols - * are neither exported nor imported when APR_DECLARE_STATIC is defined.\n - * By default, compiling an application and including the APR public - * headers, without defining APR_DECLARE_STATIC, will prepare the code to be - * linked to the dynamic library. - */ -#define APR_DECLARE(type) type - -/** - * The public APR functions using variable arguments are declared with - * APR_DECLARE_NONSTD(), as they must follow the C language calling convention. - * @see APR_DECLARE @see APR_DECLARE_DATA - * @remark Both the declaration and implementations must use the same macro. - * @example - */ -/** APR_DECLARE_NONSTD(rettype) apr_func(args, ...); - */ -#define APR_DECLARE_NONSTD(type) type - -/** - * The public APR variables are declared with APR_DECLARE_DATA. - * This assures the appropriate indirection is invoked at compile time. - * @see APR_DECLARE @see APR_DECLARE_NONSTD - * @remark Note that the declaration and implementations use different forms, - * but both must include the macro. - * @example - */ -/** extern APR_DECLARE_DATA type apr_variable;\n - * APR_DECLARE_DATA type apr_variable = value; - */ -#define APR_DECLARE_DATA - -#define APR_SSIZE_T_FMT "d" - -#define APR_SIZE_T_FMT "d" - -#if APR_HAS_LARGE_FILES -#define APR_OFF_T_FMT "lld" -#else -#define APR_OFF_T_FMT "ld" -#endif - -#define APR_PID_T_FMT "d" - -/* Local machine definition for console and log output. */ -#define APR_EOL_STR "\r\n" - -typedef int apr_wait_t; - -#define APR_PATH_MAX PATH_MAX - -#define APR_DSOPATH "PATH" - -#define APR_INT64_T_FMT "lld" -#define APR_UINT64_T_FMT "llu" -#define APR_UINT64_T_HEX_FMT "llx" -#define APR_TIME_T_FMT APR_INT64_T_FMT - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* NETWARE */ - -#endif /* APR_H */ diff --git a/libs/apr/include/apr.hw b/libs/apr/include/apr.hw deleted file mode 100644 index 0aaa62c6..00000000 --- a/libs/apr/include/apr.hw +++ /dev/null @@ -1,638 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef APR_H -#define APR_H - -/* GENERATED FILE WARNING! DO NOT EDIT apr.h - * - * You must modify apr.hw instead. - * - * And please, make an effort to stub apr.hnw and apr.h.in in the process. - * - * This is the Win32 specific version of apr.h. It is copied from - * apr.hw by the apr.dsp and libapr.dsp projects. - */ - -/** - * @file apr.h - * @brief APR Platform Definitions - * @remark This is a generated header generated from include/apr.h.in by - * ./configure, or copied from include/apr.hw or include/apr.hnw - * for Win32 or Netware by those build environments, respectively. - */ - -#if defined(WIN32) || defined(DOXYGEN) - -/* Ignore most warnings (back down to /W3) for poorly constructed headers - */ -#if defined(_MSC_VER) && _MSC_VER >= 1200 -#pragma warning(push, 3) -#endif - -/* disable or reduce the frequency of... - * C4057: indirection to slightly different base types - * C4075: slight indirection changes (unsigned short* vs short[]) - * C4100: unreferenced formal parameter - * C4127: conditional expression is constant - * C4163: '_rotl64' : not available as an intrinsic function - * C4201: nonstandard extension nameless struct/unions - * C4244: int to char/short - precision loss - * C4514: unreferenced inline function removed - */ -#pragma warning(disable: 4100 4127 4163 4201 4514; once: 4057 4075 4244) - -/* Ignore Microsoft's interpretation of secure development - * and the POSIX string handling API - */ -#if defined(_MSC_VER) && _MSC_VER >= 1400 -#ifndef _CRT_SECURE_NO_DEPRECATE -#define _CRT_SECURE_NO_DEPRECATE -#endif -#pragma warning(disable: 4996) -#endif - -/* Has windows.h already been included? If so, our preferences don't matter, - * but we will still need the winsock things no matter what was included. - * If not, include a restricted set of windows headers to our tastes. - */ -#ifndef _WINDOWS_ -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#ifndef _WIN32_WINNT - -/* Restrict the server to a subset of Windows XP header files by default - */ -#define _WIN32_WINNT 0x0501 -#endif -#ifndef NOUSER -#define NOUSER -#endif -#ifndef NOMCX -#define NOMCX -#endif -#ifndef NOIME -#define NOIME -#endif -#include -/* - * Add a _very_few_ declarations missing from the restricted set of headers - * (If this list becomes extensive, re-enable the required headers above!) - * winsock headers were excluded by WIN32_LEAN_AND_MEAN, so include them now - */ -#define SW_HIDE 0 -#ifndef _WIN32_WCE -#include -#include -#include -#else -#include -#endif -#endif /* !_WINDOWS_ */ - -/** - * @defgroup APR Apache Portability Runtime library - * @{ - */ -/** - * @defgroup apr_platform Platform Definitions - * @{ - * @warning - * The actual values of macros and typedefs on this page
    - * are platform specific and should NOT be relied upon!
    - */ - -#define APR_INLINE __inline -#define APR_HAS_INLINE 1 -#if !defined(__GNUC__) && !defined(__attribute__) -#define __attribute__(__x) -#endif - -#ifndef _WIN32_WCE -#define APR_HAVE_ARPA_INET_H 0 -#define APR_HAVE_CONIO_H 1 -#define APR_HAVE_CRYPT_H 0 -#define APR_HAVE_CTYPE_H 1 -#define APR_HAVE_DIRENT_H 0 -#define APR_HAVE_ERRNO_H 1 -#define APR_HAVE_FCNTL_H 1 -#define APR_HAVE_IO_H 1 -#define APR_HAVE_LIMITS_H 1 -#define APR_HAVE_NETDB_H 0 -#define APR_HAVE_NETINET_IN_H 0 -#define APR_HAVE_NETINET_SCTP_H 0 -#define APR_HAVE_NETINET_SCTP_UIO_H 0 -#define APR_HAVE_NETINET_TCP_H 0 -#define APR_HAVE_PTHREAD_H 0 -#define APR_HAVE_SEMAPHORE_H 0 -#define APR_HAVE_SIGNAL_H 1 -#define APR_HAVE_STDARG_H 1 -#define APR_HAVE_STDINT_H 0 -#define APR_HAVE_STDIO_H 1 -#define APR_HAVE_STDLIB_H 1 -#define APR_HAVE_STRING_H 1 -#define APR_HAVE_STRINGS_H 0 -#define APR_HAVE_SYS_IOCTL_H 0 -#define APR_HAVE_SYS_SENDFILE_H 0 -#define APR_HAVE_SYS_SIGNAL_H 0 -#define APR_HAVE_SYS_SOCKET_H 0 -#define APR_HAVE_SYS_SOCKIO_H 0 -#define APR_HAVE_SYS_SYSLIMITS_H 0 -#define APR_HAVE_SYS_TIME_H 0 -#define APR_HAVE_SYS_TYPES_H 1 -#define APR_HAVE_SYS_UIO_H 0 -#define APR_HAVE_SYS_UN_H 0 -#define APR_HAVE_SYS_WAIT_H 0 -#define APR_HAVE_TIME_H 1 -#define APR_HAVE_UNISTD_H 0 -#define APR_HAVE_STDDEF_H 1 -#define APR_HAVE_PROCESS_H 1 -#else -#define APR_HAVE_ARPA_INET_H 0 -#define APR_HAVE_CONIO_H 0 -#define APR_HAVE_CRYPT_H 0 -#define APR_HAVE_CTYPE_H 0 -#define APR_HAVE_DIRENT_H 0 -#define APR_HAVE_ERRNO_H 0 -#define APR_HAVE_FCNTL_H 0 -#define APR_HAVE_IO_H 0 -#define APR_HAVE_LIMITS_H 0 -#define APR_HAVE_NETDB_H 0 -#define APR_HAVE_NETINET_IN_H 0 -#define APR_HAVE_NETINET_SCTP_H 0 -#define APR_HAVE_NETINET_SCTP_UIO_H 0 -#define APR_HAVE_NETINET_TCP_H 0 -#define APR_HAVE_PTHREAD_H 0 -#define APR_HAVE_SEMAPHORE_H 0 -#define APR_HAVE_SIGNAL_H 0 -#define APR_HAVE_STDARG_H 0 -#define APR_HAVE_STDINT_H 0 -#define APR_HAVE_STDIO_H 1 -#define APR_HAVE_STDLIB_H 1 -#define APR_HAVE_STRING_H 1 -#define APR_HAVE_STRINGS_H 0 -#define APR_HAVE_SYS_IOCTL_H 0 -#define APR_HAVE_SYS_SENDFILE_H 0 -#define APR_HAVE_SYS_SIGNAL_H 0 -#define APR_HAVE_SYS_SOCKET_H 0 -#define APR_HAVE_SYS_SOCKIO_H 0 -#define APR_HAVE_SYS_SYSLIMITS_H 0 -#define APR_HAVE_SYS_TIME_H 0 -#define APR_HAVE_SYS_TYPES_H 0 -#define APR_HAVE_SYS_UIO_H 0 -#define APR_HAVE_SYS_UN_H 0 -#define APR_HAVE_SYS_WAIT_H 0 -#define APR_HAVE_TIME_H 0 -#define APR_HAVE_UNISTD_H 0 -#define APR_HAVE_STDDEF_H 0 -#define APR_HAVE_PROCESS_H 0 -#endif - -/** @} */ -/** @} */ - -/* We don't include our conditional headers within the doxyblocks - * or the extern "C" namespace - */ - -#if APR_HAVE_STDLIB_H -#include -#endif -#if APR_HAVE_STDIO_H -#include -#endif -#if APR_HAVE_SYS_TYPES_H -#include -#endif -#if APR_HAVE_STDDEF_H -#include -#endif -#if APR_HAVE_TIME_H -#include -#endif -#if APR_HAVE_PROCESS_H -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup apr_platform - * @ingroup APR - * @{ - */ - -#define APR_HAVE_SHMEM_MMAP_TMP 0 -#define APR_HAVE_SHMEM_MMAP_SHM 0 -#define APR_HAVE_SHMEM_MMAP_ZERO 0 -#define APR_HAVE_SHMEM_SHMGET_ANON 0 -#define APR_HAVE_SHMEM_SHMGET 0 -#define APR_HAVE_SHMEM_MMAP_ANON 0 -#define APR_HAVE_SHMEM_BEOS 0 - -#define APR_USE_SHMEM_MMAP_TMP 0 -#define APR_USE_SHMEM_MMAP_SHM 0 -#define APR_USE_SHMEM_MMAP_ZERO 0 -#define APR_USE_SHMEM_SHMGET_ANON 0 -#define APR_USE_SHMEM_SHMGET 0 -#define APR_USE_SHMEM_MMAP_ANON 0 -#define APR_USE_SHMEM_BEOS 0 - -#define APR_USE_FLOCK_SERIALIZE 0 -#define APR_USE_POSIXSEM_SERIALIZE 0 -#define APR_USE_SYSVSEM_SERIALIZE 0 -#define APR_USE_FCNTL_SERIALIZE 0 -#define APR_USE_PROC_PTHREAD_SERIALIZE 0 -#define APR_USE_PTHREAD_SERIALIZE 0 - -#define APR_HAS_FLOCK_SERIALIZE 0 -#define APR_HAS_SYSVSEM_SERIALIZE 0 -#define APR_HAS_POSIXSEM_SERIALIZE 0 -#define APR_HAS_FCNTL_SERIALIZE 0 -#define APR_HAS_PROC_PTHREAD_SERIALIZE 0 - -#define APR_PROCESS_LOCK_IS_GLOBAL 0 - -#define APR_HAVE_CORKABLE_TCP 0 -#define APR_HAVE_GETRLIMIT 0 -#define APR_HAVE_ICONV 0 -#define APR_HAVE_IN_ADDR 1 -#define APR_HAVE_INET_ADDR 1 -#define APR_HAVE_INET_NETWORK 0 -#define APR_HAVE_IPV6 0 -#define APR_HAVE_MEMMOVE 1 -#define APR_HAVE_SETRLIMIT 0 -#define APR_HAVE_SIGACTION 0 -#define APR_HAVE_SIGSUSPEND 0 -#define APR_HAVE_SIGWAIT 0 -#define APR_HAVE_SA_STORAGE 0 -#define APR_HAVE_STRCASECMP 0 -#define APR_HAVE_STRDUP 1 -#define APR_HAVE_STRNCASECMP 0 -#define APR_HAVE_STRSTR 1 -#define APR_HAVE_MEMCHR 1 -#define APR_HAVE_STRUCT_RLIMIT 0 -#define APR_HAVE_UNION_SEMUN 0 -#define APR_HAVE_SCTP 0 -#define APR_HAVE_IOVEC 0 - -#ifndef _WIN32_WCE -#define APR_HAVE_STRICMP 1 -#define APR_HAVE_STRNICMP 1 -#else -#define APR_HAVE_STRICMP 0 -#define APR_HAVE_STRNICMP 0 -#endif - -/* APR Feature Macros */ -#define APR_HAS_SHARED_MEMORY 1 -#define APR_HAS_THREADS 1 -#define APR_HAS_MMAP 1 -#define APR_HAS_FORK 0 -#define APR_HAS_RANDOM 1 -#define APR_HAS_OTHER_CHILD 1 -#define APR_HAS_DSO 1 -#define APR_HAS_SO_ACCEPTFILTER 0 -#define APR_HAS_UNICODE_FS 1 -#define APR_HAS_PROC_INVOKED 1 -#define APR_HAS_OS_UUID 1 - -#ifndef _WIN32_WCE -#define APR_HAS_SENDFILE 1 -#define APR_HAS_USER 1 -#define APR_HAS_LARGE_FILES 1 -#define APR_HAS_XTHREAD_FILES 1 -#define APR_PROCATTR_USER_SET_REQUIRES_PASSWORD 1 -#else -#define APR_HAS_SENDFILE 0 -#define APR_HAS_USER 0 -#define APR_HAS_LARGE_FILES 0 -#define APR_HAS_XTHREAD_FILES 0 -#define APR_PROCATTR_USER_SET_REQUIRES_PASSWORD 0 -#endif - -/* APR sets APR_FILES_AS_SOCKETS to 1 on systems where it is possible - * to poll on files/pipes. - */ -#define APR_FILES_AS_SOCKETS 0 - -/* This macro indicates whether or not EBCDIC is the native character set. - */ -#define APR_CHARSET_EBCDIC 0 - -/* If we have a TCP implementation that can be "corked", what flag - * do we use? - */ -#define APR_TCP_NOPUSH_FLAG @apr_tcp_nopush_flag@ - -/* Is the TCP_NODELAY socket option inherited from listening sockets? - */ -#define APR_TCP_NODELAY_INHERITED 1 - -/* Is the O_NONBLOCK flag inherited from listening sockets? - */ -#define APR_O_NONBLOCK_INHERITED 1 - -/* Typedefs that APR needs. */ - -typedef unsigned char apr_byte_t; - -typedef short apr_int16_t; -typedef unsigned short apr_uint16_t; - -typedef int apr_int32_t; -typedef unsigned int apr_uint32_t; - -typedef __int64 apr_int64_t; -typedef unsigned __int64 apr_uint64_t; - -typedef size_t apr_size_t; -#if APR_HAVE_STDDEF_H -typedef ptrdiff_t apr_ssize_t; -#else -typedef int apr_ssize_t; -#endif -#if APR_HAS_LARGE_FILES -typedef __int64 apr_off_t; -#else -typedef int apr_off_t; -#endif -typedef int apr_socklen_t; -typedef apr_uint64_t apr_ino_t; - -#ifdef WIN64 -#define APR_SIZEOF_VOIDP 8 -#else -#define APR_SIZEOF_VOIDP 4 -#endif - -#if APR_SIZEOF_VOIDP == 8 -typedef apr_uint64_t apr_uintptr_t; -#else -typedef apr_uint32_t apr_uintptr_t; -#endif - -/* Are we big endian? */ -/* XXX: Fatal assumption on Alpha platforms */ -#define APR_IS_BIGENDIAN 0 - -/* Mechanisms to properly type numeric literals */ - -#ifndef __GNUC__ -#define APR_INT64_C(val) (val##i64) -#define APR_UINT64_C(val) (val##Ui64) -#else -#define APR_INT64_C(val) (val##LL) -#define APR_UINT64_C(val) (val##ULL) -#endif - -#ifdef INT16_MIN -#define APR_INT16_MIN INT16_MIN -#else -#define APR_INT16_MIN (-0x7fff - 1) -#endif - -#ifdef INT16_MAX -#define APR_INT16_MAX INT16_MAX -#else -#define APR_INT16_MAX (0x7fff) -#endif - -#ifdef UINT16_MAX -#define APR_UINT16_MAX UINT16_MAX -#else -#define APR_UINT16_MAX (0xffff) -#endif - -#ifdef INT32_MIN -#define APR_INT32_MIN INT32_MIN -#else -#define APR_INT32_MIN (-0x7fffffff - 1) -#endif - -#ifdef INT32_MAX -#define APR_INT32_MAX INT32_MAX -#else -#define APR_INT32_MAX 0x7fffffff -#endif - -#ifdef UINT32_MAX -#define APR_UINT32_MAX UINT32_MAX -#else -#define APR_UINT32_MAX (0xffffffffU) -#endif - -#ifdef INT64_MIN -#define APR_INT64_MIN INT64_MIN -#else -#define APR_INT64_MIN (APR_INT64_C(-0x7fffffffffffffff) - 1) -#endif - -#ifdef INT64_MAX -#define APR_INT64_MAX INT64_MAX -#else -#define APR_INT64_MAX APR_INT64_C(0x7fffffffffffffff) -#endif - -#ifdef UINT64_MAX -#define APR_UINT64_MAX UINT64_MAX -#else -#define APR_UINT64_MAX APR_UINT64_C(0xffffffffffffffff) -#endif - -#define APR_SIZE_MAX (~((apr_size_t)0)) - -/* Definitions that APR programs need to work properly. */ - -/** - * APR public API wrap for C++ compilers. - */ -#ifdef __cplusplus -#define APR_BEGIN_DECLS extern "C" { -#define APR_END_DECLS } -#else -#define APR_BEGIN_DECLS -#define APR_END_DECLS -#endif - -/** - * Thread callbacks from APR functions must be declared with APR_THREAD_FUNC, - * so that they follow the platform's calling convention. - *
    - *
    - * void* APR_THREAD_FUNC my_thread_entry_fn(apr_thread_t *thd, void *data);
    - *
    - * 
    - */ -#define APR_THREAD_FUNC __stdcall - - -#if defined(DOXYGEN) || !defined(WIN32) - -/** - * The public APR functions are declared with APR_DECLARE(), so they may - * use the most appropriate calling convention. Public APR functions with - * variable arguments must use APR_DECLARE_NONSTD(). - * - * @remark Both the declaration and implementations must use the same macro. - * - *
    - * APR_DECLARE(rettype) apr_func(args)
    - * 
    - * @see APR_DECLARE_NONSTD @see APR_DECLARE_DATA - * @remark Note that when APR compiles the library itself, it passes the - * symbol -DAPR_DECLARE_EXPORT to the compiler on some platforms (e.g. Win32) - * to export public symbols from the dynamic library build.\n - * The user must define the APR_DECLARE_STATIC when compiling to target - * the static APR library on some platforms (e.g. Win32.) The public symbols - * are neither exported nor imported when APR_DECLARE_STATIC is defined.\n - * By default, compiling an application and including the APR public - * headers, without defining APR_DECLARE_STATIC, will prepare the code to be - * linked to the dynamic library. - */ -#define APR_DECLARE(type) type - -/** - * The public APR functions using variable arguments are declared with - * APR_DECLARE_NONSTD(), as they must follow the C language calling convention. - * @see APR_DECLARE @see APR_DECLARE_DATA - * @remark Both the declaration and implementations must use the same macro. - *
    - *
    - * APR_DECLARE_NONSTD(rettype) apr_func(args, ...);
    - *
    - * 
    - */ -#define APR_DECLARE_NONSTD(type) type - -/** - * The public APR variables are declared with AP_MODULE_DECLARE_DATA. - * This assures the appropriate indirection is invoked at compile time. - * @see APR_DECLARE @see APR_DECLARE_NONSTD - * @remark Note that the declaration and implementations use different forms, - * but both must include the macro. - * - *
    - *
    - * extern APR_DECLARE_DATA type apr_variable;\n
    - * APR_DECLARE_DATA type apr_variable = value;
    - *
    - * 
    - */ -#define APR_DECLARE_DATA - -#elif defined(APR_DECLARE_STATIC) -#define APR_DECLARE(type) type __stdcall -#define APR_DECLARE_NONSTD(type) type __cdecl -#define APR_DECLARE_DATA -#elif defined(APR_DECLARE_EXPORT) -#define APR_DECLARE(type) __declspec(dllexport) type __stdcall -#define APR_DECLARE_NONSTD(type) __declspec(dllexport) type __cdecl -#define APR_DECLARE_DATA __declspec(dllexport) -#else -#define APR_DECLARE(type) __declspec(dllimport) type __stdcall -#define APR_DECLARE_NONSTD(type) __declspec(dllimport) type __cdecl -#define APR_DECLARE_DATA __declspec(dllimport) -#endif - -#ifdef WIN64 -#define APR_SSIZE_T_FMT "I64d" -#define APR_SIZE_T_FMT "I64u" -#else -#define APR_SSIZE_T_FMT "d" -#define APR_SIZE_T_FMT "u" -#endif - -#if APR_HAS_LARGE_FILES -#define APR_OFF_T_FMT "I64d" -#else -#define APR_OFF_T_FMT "d" -#endif - -#define APR_PID_T_FMT "d" - -#define APR_INT64_T_FMT "I64d" -#define APR_UINT64_T_FMT "I64u" -#define APR_UINT64_T_HEX_FMT "I64x" - -/* No difference between PROC and GLOBAL mutex */ -#define APR_PROC_MUTEX_IS_GLOBAL 1 - -/* Local machine definition for console and log output. */ -#define APR_EOL_STR "\r\n" - -typedef int apr_wait_t; - -#if APR_HAS_UNICODE_FS -/* An arbitrary size that is digestable. True max is a bit less than 32000 */ -#define APR_PATH_MAX 8192 -#else /* !APR_HAS_UNICODE_FS */ -#define APR_PATH_MAX MAX_PATH -#endif - -#define APR_DSOPATH "PATH" - -/** @} */ - -/* Definitions that only Win32 programs need to compile properly. */ - -/* XXX These simply don't belong here, perhaps in apr_portable.h - * based on some APR_HAVE_PID/GID/UID? - */ -#ifndef __GNUC__ -typedef int pid_t; -#endif -typedef int uid_t; -typedef int gid_t; - -/* Win32 .h ommissions we really need */ -#define STDIN_FILENO 0 -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 - -#if APR_HAVE_IPV6 - -/* Appears in later flavors, not the originals. */ -#ifndef in_addr6 -#define in6_addr in_addr6 -#endif - -#ifndef WS2TCPIP_INLINE -#define IN6_IS_ADDR_V4MAPPED(a) \ - ( (*(const apr_uint64_t *)(const void *)(&(a)->s6_addr[0]) == 0) \ - && (*(const apr_uint32_t *)(const void *)(&(a)->s6_addr[8]) == ntohl(0x0000ffff))) -#endif - -#endif /* APR_HAS_IPV6 */ - -#ifdef __cplusplus -} -#endif - -/* Done with badly written headers - */ -#if defined(_MSC_VER) && _MSC_VER >= 1200 -#pragma warning(pop) -#pragma warning(disable: 4996) -#endif - -#endif /* WIN32 */ - -#endif /* APR_H */ diff --git a/libs/apr/include/apr_allocator.h b/libs/apr/include/apr_allocator.h deleted file mode 100644 index 5aaeb1b2..00000000 --- a/libs/apr/include/apr_allocator.h +++ /dev/null @@ -1,160 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_ALLOCATOR_H -#define APR_ALLOCATOR_H - -/** - * @file apr_allocator.h - * @brief APR Internal Memory Allocation - */ - -#include "apr.h" -#include "apr_errno.h" -#define APR_WANT_MEMFUNC /**< For no good reason? */ -#include "apr_want.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup apr_allocator Internal Memory Allocation - * @ingroup APR - * @{ - */ - -/** the allocator structure */ -typedef struct apr_allocator_t apr_allocator_t; -/** the structure which holds information about the allocation */ -typedef struct apr_memnode_t apr_memnode_t; - -/** basic memory node structure - * @note The next, ref and first_avail fields are available for use by the - * caller of apr_allocator_alloc(), the remaining fields are read-only. - * The next field has to be used with caution and sensibly set when the - * memnode is passed back to apr_allocator_free(). See apr_allocator_free() - * for details. - * The ref and first_avail fields will be properly restored by - * apr_allocator_free(). - */ -struct apr_memnode_t { - apr_memnode_t *next; /**< next memnode */ - apr_memnode_t **ref; /**< reference to self */ - apr_uint32_t index; /**< size */ - apr_uint32_t free_index; /**< how much free */ - char *first_avail; /**< pointer to first free memory */ - char *endp; /**< pointer to end of free memory */ -}; - -/** The base size of a memory node - aligned. */ -#define APR_MEMNODE_T_SIZE APR_ALIGN_DEFAULT(sizeof(apr_memnode_t)) - -/** Symbolic constants */ -#define APR_ALLOCATOR_MAX_FREE_UNLIMITED 0 - -/** - * Create a new allocator - * @param allocator The allocator we have just created. - * - */ -APR_DECLARE(apr_status_t) apr_allocator_create(apr_allocator_t **allocator); - -/** - * Destroy an allocator - * @param allocator The allocator to be destroyed - * @remark Any memnodes not given back to the allocator prior to destroying - * will _not_ be free()d. - */ -APR_DECLARE(void) apr_allocator_destroy(apr_allocator_t *allocator); - -/** - * Allocate a block of mem from the allocator - * @param allocator The allocator to allocate from - * @param size The size of the mem to allocate (excluding the - * memnode structure) - */ -APR_DECLARE(apr_memnode_t *) apr_allocator_alloc(apr_allocator_t *allocator, - apr_size_t size); - -/** - * Free a list of blocks of mem, giving them back to the allocator. - * The list is typically terminated by a memnode with its next field - * set to NULL. - * @param allocator The allocator to give the mem back to - * @param memnode The memory node to return - */ -APR_DECLARE(void) apr_allocator_free(apr_allocator_t *allocator, - apr_memnode_t *memnode); - -#include "apr_pools.h" - -/** - * Set the owner of the allocator - * @param allocator The allocator to set the owner for - * @param pool The pool that is to own the allocator - * @remark Typically pool is the highest level pool using the allocator - */ -/* - * XXX: see if we can come up with something a bit better. Currently - * you can make a pool an owner, but if the pool doesn't use the allocator - * the allocator will never be destroyed. - */ -APR_DECLARE(void) apr_allocator_owner_set(apr_allocator_t *allocator, - apr_pool_t *pool); - -/** - * Get the current owner of the allocator - * @param allocator The allocator to get the owner from - */ -APR_DECLARE(apr_pool_t *) apr_allocator_owner_get(apr_allocator_t *allocator); - -/** - * Set the current threshold at which the allocator should start - * giving blocks back to the system. - * @param allocator The allocator the set the threshold on - * @param size The threshold. 0 == unlimited. - */ -APR_DECLARE(void) apr_allocator_max_free_set(apr_allocator_t *allocator, - apr_size_t size); - -#include "apr_thread_mutex.h" - -#if APR_HAS_THREADS -/** - * Set a mutex for the allocator to use - * @param allocator The allocator to set the mutex for - * @param mutex The mutex - */ -APR_DECLARE(void) apr_allocator_mutex_set(apr_allocator_t *allocator, - apr_thread_mutex_t *mutex); - -/** - * Get the mutex currently set for the allocator - * @param allocator The allocator - */ -APR_DECLARE(apr_thread_mutex_t *) apr_allocator_mutex_get( - apr_allocator_t *allocator); - -#endif /* APR_HAS_THREADS */ - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* !APR_ALLOCATOR_H */ diff --git a/libs/apr/include/apr_atomic.h b/libs/apr/include/apr_atomic.h deleted file mode 100644 index 60e4bb54..00000000 --- a/libs/apr/include/apr_atomic.h +++ /dev/null @@ -1,140 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_ATOMIC_H -#define APR_ATOMIC_H - -/** - * @file apr_atomic.h - * @brief APR Atomic Operations - */ - -#include "apr.h" -#include "apr_pools.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup apr_atomic Atomic Operations - * @ingroup APR - * @{ - */ - -/** - * this function is required on some platforms to initialize the - * atomic operation's internal structures - * @param p pool - * @return APR_SUCCESS on successful completion - * @remark Programs do NOT need to call this directly. APR will call this - * automatically from apr_initialize. - * @internal - */ -APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p); - -/* - * Atomic operations on 32-bit values - * Note: Each of these functions internally implements a memory barrier - * on platforms that require it - */ - -/** - * atomically read an apr_uint32_t from memory - * @param mem the pointer - */ -APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem); - -/** - * atomically set an apr_uint32_t in memory - * @param mem pointer to the object - * @param val value that the object will assume - */ -APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val); - -/** - * atomically add 'val' to an apr_uint32_t - * @param mem pointer to the object - * @param val amount to add - * @return old value pointed to by mem - */ -APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val); - -/** - * atomically subtract 'val' from an apr_uint32_t - * @param mem pointer to the object - * @param val amount to subtract - */ -APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val); - -/** - * atomically increment an apr_uint32_t by 1 - * @param mem pointer to the object - * @return old value pointed to by mem - */ -APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem); - -/** - * atomically decrement an apr_uint32_t by 1 - * @param mem pointer to the atomic value - * @return zero if the value becomes zero on decrement, otherwise non-zero - */ -APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem); - -/** - * compare an apr_uint32_t's value with 'cmp'. - * If they are the same swap the value with 'with' - * @param mem pointer to the value - * @param with what to swap it with - * @param cmp the value to compare it to - * @return the old value of *mem - */ -APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with, - apr_uint32_t cmp); - -/** - * exchange an apr_uint32_t's value with 'val'. - * @param mem pointer to the value - * @param val what to swap it with - * @return the old value of *mem - */ -APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val); - -/** - * compare the pointer's value with cmp. - * If they are the same swap the value with 'with' - * @param mem pointer to the pointer - * @param with what to swap it with - * @param cmp the value to compare it to - * @return the old value of the pointer - */ -APR_DECLARE(void*) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp); - -/** - * exchange a pair of pointer values - * @param mem pointer to the pointer - * @param with what to swap it with - * @return the old value of the pointer - */ -APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem, void *with); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* !APR_ATOMIC_H */ diff --git a/libs/apr/include/apr_dso.h b/libs/apr/include/apr_dso.h deleted file mode 100644 index ac701cfd..00000000 --- a/libs/apr/include/apr_dso.h +++ /dev/null @@ -1,94 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_DSO_DOT_H -#define APR_DSO_DOT_H - -/** - * @file apr_dso.h - * @brief APR Dynamic Object Handling Routines - */ - -#include "apr.h" -#include "apr_pools.h" -#include "apr_errno.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup apr_dso Dynamic Object Handling - * @ingroup APR - * @{ - */ - -#if APR_HAS_DSO || defined(DOXYGEN) - -/** - * Structure for referencing dynamic objects - */ -typedef struct apr_dso_handle_t apr_dso_handle_t; - -/** - * Structure for referencing symbols from dynamic objects - */ -typedef void * apr_dso_handle_sym_t; - -/** - * Load a DSO library. - * @param res_handle Location to store new handle for the DSO. - * @param path Path to the DSO library - * @param ctx Pool to use. - * @bug We aught to provide an alternative to RTLD_GLOBAL, which - * is the only supported method of loading DSOs today. - */ -APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, - const char *path, apr_pool_t *ctx); - -/** - * Close a DSO library. - * @param handle handle to close. - */ -APR_DECLARE(apr_status_t) apr_dso_unload(apr_dso_handle_t *handle); - -/** - * Load a symbol from a DSO handle. - * @param ressym Location to store the loaded symbol - * @param handle handle to load the symbol from. - * @param symname Name of the symbol to load. - */ -APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, - apr_dso_handle_t *handle, - const char *symname); - -/** - * Report more information when a DSO function fails. - * @param dso The dso handle that has been opened - * @param buf Location to store the dso error - * @param bufsize The size of the provided buffer - */ -APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *dso, char *buf, apr_size_t bufsize); - -#endif /* APR_HAS_DSO */ - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libs/apr/include/apr_env.h b/libs/apr/include/apr_env.h deleted file mode 100644 index 85ab6704..00000000 --- a/libs/apr/include/apr_env.h +++ /dev/null @@ -1,67 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_ENV_H -#define APR_ENV_H -/** - * @file apr_env.h - * @brief APR Environment functions - */ -#include "apr_errno.h" -#include "apr_pools.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup apr_env Functions for manipulating the environment - * @ingroup APR - * @{ - */ - -/** - * Get the value of an environment variable - * @param value the returned value, allocated from @a pool - * @param envvar the name of the environment variable - * @param pool where to allocate @a value and any temporary storage from - */ -APR_DECLARE(apr_status_t) apr_env_get(char **value, const char *envvar, - apr_pool_t *pool); - -/** - * Set the value of an environment variable - * @param envvar the name of the environment variable - * @param value the value to set - * @param pool where to allocate temporary storage from - */ -APR_DECLARE(apr_status_t) apr_env_set(const char *envvar, const char *value, - apr_pool_t *pool); - -/** - * Delete a variable from the environment - * @param envvar the name of the environment variable - * @param pool where to allocate temporary storage from - */ -APR_DECLARE(apr_status_t) apr_env_delete(const char *envvar, apr_pool_t *pool); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ! APR_ENV_H */ diff --git a/libs/apr/include/apr_errno.h b/libs/apr/include/apr_errno.h deleted file mode 100644 index d4d44cb1..00000000 --- a/libs/apr/include/apr_errno.h +++ /dev/null @@ -1,1315 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_ERRNO_H -#define APR_ERRNO_H - -/** - * @file apr_errno.h - * @brief APR Error Codes - */ - -#include "apr.h" - -#if APR_HAVE_ERRNO_H -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup apr_errno Error Codes - * @ingroup APR - * @{ - */ - -/** - * Type for specifying an error or status code. - */ -typedef int apr_status_t; - -/** - * Return a human readable string describing the specified error. - * @param statcode The error code the get a string for. - * @param buf A buffer to hold the error string. - * @param bufsize Size of the buffer to hold the string. - */ -APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf, - apr_size_t bufsize); - -#if defined(DOXYGEN) -/** - * @def APR_FROM_OS_ERROR(os_err_type syserr) - * Fold a platform specific error into an apr_status_t code. - * @return apr_status_t - * @param e The platform os error code. - * @warning macro implementation; the syserr argument may be evaluated - * multiple times. - */ -#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR) - -/** - * @def APR_TO_OS_ERROR(apr_status_t statcode) - * @return os_err_type - * Fold an apr_status_t code back to the native platform defined error. - * @param e The apr_status_t folded platform os error code. - * @warning macro implementation; the statcode argument may be evaluated - * multiple times. If the statcode was not created by apr_get_os_error - * or APR_FROM_OS_ERROR, the results are undefined. - */ -#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR) - -/** @def apr_get_os_error() - * @return apr_status_t the last platform error, folded into apr_status_t, on most platforms - * @remark This retrieves errno, or calls a GetLastError() style function, and - * folds it with APR_FROM_OS_ERROR. Some platforms (such as OS2) have no - * such mechanism, so this call may be unsupported. Do NOT use this - * call for socket errors from socket, send, recv etc! - */ - -/** @def apr_set_os_error(e) - * Reset the last platform error, unfolded from an apr_status_t, on some platforms - * @param e The OS error folded in a prior call to APR_FROM_OS_ERROR() - * @warning This is a macro implementation; the statcode argument may be evaluated - * multiple times. If the statcode was not created by apr_get_os_error - * or APR_FROM_OS_ERROR, the results are undefined. This macro sets - * errno, or calls a SetLastError() style function, unfolding statcode - * with APR_TO_OS_ERROR. Some platforms (such as OS2) have no such - * mechanism, so this call may be unsupported. - */ - -/** @def apr_get_netos_error() - * Return the last socket error, folded into apr_status_t, on all platforms - * @remark This retrieves errno or calls a GetLastSocketError() style function, - * and folds it with APR_FROM_OS_ERROR. - */ - -/** @def apr_set_netos_error(e) - * Reset the last socket error, unfolded from an apr_status_t - * @param e The socket error folded in a prior call to APR_FROM_OS_ERROR() - * @warning This is a macro implementation; the statcode argument may be evaluated - * multiple times. If the statcode was not created by apr_get_os_error - * or APR_FROM_OS_ERROR, the results are undefined. This macro sets - * errno, or calls a WSASetLastError() style function, unfolding - * socketcode with APR_TO_OS_ERROR. - */ - -#endif /* defined(DOXYGEN) */ - -/** - * APR_OS_START_ERROR is where the APR specific error values start. - */ -#define APR_OS_START_ERROR 20000 -/** - * APR_OS_ERRSPACE_SIZE is the maximum number of errors you can fit - * into one of the error/status ranges below -- except for - * APR_OS_START_USERERR, which see. - */ -#define APR_OS_ERRSPACE_SIZE 50000 -/** - * APR_UTIL_ERRSPACE_SIZE is the size of the space that is reserved for - * use within apr-util. This space is reserved above that used by APR - * internally. - * @note This number MUST be smaller than APR_OS_ERRSPACE_SIZE by a - * large enough amount that APR has sufficient room for it's - * codes. - */ -#define APR_UTIL_ERRSPACE_SIZE 20000 -/** - * APR_OS_START_STATUS is where the APR specific status codes start. - */ -#define APR_OS_START_STATUS (APR_OS_START_ERROR + APR_OS_ERRSPACE_SIZE) -/** - * APR_UTIL_START_STATUS is where APR-Util starts defining it's - * status codes. - */ -#define APR_UTIL_START_STATUS (APR_OS_START_STATUS + \ - (APR_OS_ERRSPACE_SIZE - APR_UTIL_ERRSPACE_SIZE)) -/** - * APR_OS_START_USERERR are reserved for applications that use APR that - * layer their own error codes along with APR's. Note that the - * error immediately following this one is set ten times farther - * away than usual, so that users of apr have a lot of room in - * which to declare custom error codes. - * - * In general applications should try and create unique error codes. To try - * and assist in finding suitable ranges of numbers to use, the following - * ranges are known to be used by the listed applications. If your - * application defines error codes please advise the range of numbers it - * uses to dev@apr.apache.org for inclusion in this list. - * - * Ranges shown are in relation to APR_OS_START_USERERR - * - * Subversion - Defined ranges, of less than 100, at intervals of 5000 - * starting at an offset of 5000, e.g. - * +5000 to 5100, +10000 to 10100 - * - * Apache HTTPD - +2000 to 2999 - */ -#define APR_OS_START_USERERR (APR_OS_START_STATUS + APR_OS_ERRSPACE_SIZE) -/** - * APR_OS_START_USEERR is obsolete, defined for compatibility only. - * Use APR_OS_START_USERERR instead. - */ -#define APR_OS_START_USEERR APR_OS_START_USERERR -/** - * APR_OS_START_CANONERR is where APR versions of errno values are defined - * on systems which don't have the corresponding errno. - */ -#define APR_OS_START_CANONERR (APR_OS_START_USERERR \ - + (APR_OS_ERRSPACE_SIZE * 10)) -/** - * APR_OS_START_EAIERR folds EAI_ error codes from getaddrinfo() into - * apr_status_t values. - */ -#define APR_OS_START_EAIERR (APR_OS_START_CANONERR + APR_OS_ERRSPACE_SIZE) -/** - * APR_OS_START_SYSERR folds platform-specific system error values into - * apr_status_t values. - */ -#define APR_OS_START_SYSERR (APR_OS_START_EAIERR + APR_OS_ERRSPACE_SIZE) - -/** - * @defgroup APR_ERROR_map APR Error Space - *
    - * The following attempts to show the relation of the various constants
    - * used for mapping APR Status codes.
    - *
    - *       0
    - *
    - *  20,000     APR_OS_START_ERROR
    - *
    - *         + APR_OS_ERRSPACE_SIZE (50,000)
    - *
    - *  70,000      APR_OS_START_STATUS
    - *
    - *         + APR_OS_ERRSPACE_SIZE - APR_UTIL_ERRSPACE_SIZE (30,000)
    - *
    - * 100,000      APR_UTIL_START_STATUS
    - *
    - *         + APR_UTIL_ERRSPACE_SIZE (20,000)
    - *
    - * 120,000      APR_OS_START_USERERR
    - *
    - *         + 10 x APR_OS_ERRSPACE_SIZE (50,000 * 10)
    - *
    - * 620,000      APR_OS_START_CANONERR
    - *
    - *         + APR_OS_ERRSPACE_SIZE (50,000)
    - *
    - * 670,000      APR_OS_START_EAIERR
    - *
    - *         + APR_OS_ERRSPACE_SIZE (50,000)
    - *
    - * 720,000      APR_OS_START_SYSERR
    - *
    - * 
    - */ - -/** no error. */ -#define APR_SUCCESS 0 - -/** - * @defgroup APR_Error APR Error Values - *
    - * APR ERROR VALUES
    - * APR_ENOSTAT      APR was unable to perform a stat on the file
    - * APR_ENOPOOL      APR was not provided a pool with which to allocate memory
    - * APR_EBADDATE     APR was given an invalid date
    - * APR_EINVALSOCK   APR was given an invalid socket
    - * APR_ENOPROC      APR was not given a process structure
    - * APR_ENOTIME      APR was not given a time structure
    - * APR_ENODIR       APR was not given a directory structure
    - * APR_ENOLOCK      APR was not given a lock structure
    - * APR_ENOPOLL      APR was not given a poll structure
    - * APR_ENOSOCKET    APR was not given a socket
    - * APR_ENOTHREAD    APR was not given a thread structure
    - * APR_ENOTHDKEY    APR was not given a thread key structure
    - * APR_ENOSHMAVAIL  There is no more shared memory available
    - * APR_EDSOOPEN     APR was unable to open the dso object.  For more
    - *                  information call apr_dso_error().
    - * APR_EGENERAL     General failure (specific information not available)
    - * APR_EBADIP       The specified IP address is invalid
    - * APR_EBADMASK     The specified netmask is invalid
    - * APR_ESYMNOTFOUND Could not find the requested symbol
    - * APR_ENOTENOUGHENTROPY Not enough entropy to continue
    - * 
    - * - *
    - * APR STATUS VALUES
    - * APR_INCHILD        Program is currently executing in the child
    - * APR_INPARENT       Program is currently executing in the parent
    - * APR_DETACH         The thread is detached
    - * APR_NOTDETACH      The thread is not detached
    - * APR_CHILD_DONE     The child has finished executing
    - * APR_CHILD_NOTDONE  The child has not finished executing
    - * APR_TIMEUP         The operation did not finish before the timeout
    - * APR_INCOMPLETE     The operation was incomplete although some processing
    - *                    was performed and the results are partially valid
    - * APR_BADCH          Getopt found an option not in the option string
    - * APR_BADARG         Getopt found an option that is missing an argument
    - *                    and an argument was specified in the option string
    - * APR_EOF            APR has encountered the end of the file
    - * APR_NOTFOUND       APR was unable to find the socket in the poll structure
    - * APR_ANONYMOUS      APR is using anonymous shared memory
    - * APR_FILEBASED      APR is using a file name as the key to the shared memory
    - * APR_KEYBASED       APR is using a shared key as the key to the shared memory
    - * APR_EINIT          Ininitalizer value.  If no option has been found, but
    - *                    the status variable requires a value, this should be used
    - * APR_ENOTIMPL       The APR function has not been implemented on this
    - *                    platform, either because nobody has gotten to it yet,
    - *                    or the function is impossible on this platform.
    - * APR_EMISMATCH      Two passwords do not match.
    - * APR_EABSOLUTE      The given path was absolute.
    - * APR_ERELATIVE      The given path was relative.
    - * APR_EINCOMPLETE    The given path was neither relative nor absolute.
    - * APR_EABOVEROOT     The given path was above the root path.
    - * APR_EBUSY          The given lock was busy.
    - * APR_EPROC_UNKNOWN  The given process wasn't recognized by APR
    - * 
    - * @{ - */ -/** @see APR_STATUS_IS_ENOSTAT */ -#define APR_ENOSTAT (APR_OS_START_ERROR + 1) -/** @see APR_STATUS_IS_ENOPOOL */ -#define APR_ENOPOOL (APR_OS_START_ERROR + 2) -/* empty slot: +3 */ -/** @see APR_STATUS_IS_EBADDATE */ -#define APR_EBADDATE (APR_OS_START_ERROR + 4) -/** @see APR_STATUS_IS_EINVALSOCK */ -#define APR_EINVALSOCK (APR_OS_START_ERROR + 5) -/** @see APR_STATUS_IS_ENOPROC */ -#define APR_ENOPROC (APR_OS_START_ERROR + 6) -/** @see APR_STATUS_IS_ENOTIME */ -#define APR_ENOTIME (APR_OS_START_ERROR + 7) -/** @see APR_STATUS_IS_ENODIR */ -#define APR_ENODIR (APR_OS_START_ERROR + 8) -/** @see APR_STATUS_IS_ENOLOCK */ -#define APR_ENOLOCK (APR_OS_START_ERROR + 9) -/** @see APR_STATUS_IS_ENOPOLL */ -#define APR_ENOPOLL (APR_OS_START_ERROR + 10) -/** @see APR_STATUS_IS_ENOSOCKET */ -#define APR_ENOSOCKET (APR_OS_START_ERROR + 11) -/** @see APR_STATUS_IS_ENOTHREAD */ -#define APR_ENOTHREAD (APR_OS_START_ERROR + 12) -/** @see APR_STATUS_IS_ENOTHDKEY */ -#define APR_ENOTHDKEY (APR_OS_START_ERROR + 13) -/** @see APR_STATUS_IS_EGENERAL */ -#define APR_EGENERAL (APR_OS_START_ERROR + 14) -/** @see APR_STATUS_IS_ENOSHMAVAIL */ -#define APR_ENOSHMAVAIL (APR_OS_START_ERROR + 15) -/** @see APR_STATUS_IS_EBADIP */ -#define APR_EBADIP (APR_OS_START_ERROR + 16) -/** @see APR_STATUS_IS_EBADMASK */ -#define APR_EBADMASK (APR_OS_START_ERROR + 17) -/* empty slot: +18 */ -/** @see APR_STATUS_IS_EDSOPEN */ -#define APR_EDSOOPEN (APR_OS_START_ERROR + 19) -/** @see APR_STATUS_IS_EABSOLUTE */ -#define APR_EABSOLUTE (APR_OS_START_ERROR + 20) -/** @see APR_STATUS_IS_ERELATIVE */ -#define APR_ERELATIVE (APR_OS_START_ERROR + 21) -/** @see APR_STATUS_IS_EINCOMPLETE */ -#define APR_EINCOMPLETE (APR_OS_START_ERROR + 22) -/** @see APR_STATUS_IS_EABOVEROOT */ -#define APR_EABOVEROOT (APR_OS_START_ERROR + 23) -/** @see APR_STATUS_IS_EBADPATH */ -#define APR_EBADPATH (APR_OS_START_ERROR + 24) -/** @see APR_STATUS_IS_EPATHWILD */ -#define APR_EPATHWILD (APR_OS_START_ERROR + 25) -/** @see APR_STATUS_IS_ESYMNOTFOUND */ -#define APR_ESYMNOTFOUND (APR_OS_START_ERROR + 26) -/** @see APR_STATUS_IS_EPROC_UNKNOWN */ -#define APR_EPROC_UNKNOWN (APR_OS_START_ERROR + 27) -/** @see APR_STATUS_IS_ENOTENOUGHENTROPY */ -#define APR_ENOTENOUGHENTROPY (APR_OS_START_ERROR + 28) -/** @} */ - -/** - * @defgroup APR_STATUS_IS Status Value Tests - * @warning For any particular error condition, more than one of these tests - * may match. This is because platform-specific error codes may not - * always match the semantics of the POSIX codes these tests (and the - * corresponding APR error codes) are named after. A notable example - * are the APR_STATUS_IS_ENOENT and APR_STATUS_IS_ENOTDIR tests on - * Win32 platforms. The programmer should always be aware of this and - * adjust the order of the tests accordingly. - * @{ - */ -/** - * APR was unable to perform a stat on the file - * @warning always use this test, as platform-specific variances may meet this - * more than one error code - */ -#define APR_STATUS_IS_ENOSTAT(s) ((s) == APR_ENOSTAT) -/** - * APR was not provided a pool with which to allocate memory - * @warning always use this test, as platform-specific variances may meet this - * more than one error code - */ -#define APR_STATUS_IS_ENOPOOL(s) ((s) == APR_ENOPOOL) -/** APR was given an invalid date */ -#define APR_STATUS_IS_EBADDATE(s) ((s) == APR_EBADDATE) -/** APR was given an invalid socket */ -#define APR_STATUS_IS_EINVALSOCK(s) ((s) == APR_EINVALSOCK) -/** APR was not given a process structure */ -#define APR_STATUS_IS_ENOPROC(s) ((s) == APR_ENOPROC) -/** APR was not given a time structure */ -#define APR_STATUS_IS_ENOTIME(s) ((s) == APR_ENOTIME) -/** APR was not given a directory structure */ -#define APR_STATUS_IS_ENODIR(s) ((s) == APR_ENODIR) -/** APR was not given a lock structure */ -#define APR_STATUS_IS_ENOLOCK(s) ((s) == APR_ENOLOCK) -/** APR was not given a poll structure */ -#define APR_STATUS_IS_ENOPOLL(s) ((s) == APR_ENOPOLL) -/** APR was not given a socket */ -#define APR_STATUS_IS_ENOSOCKET(s) ((s) == APR_ENOSOCKET) -/** APR was not given a thread structure */ -#define APR_STATUS_IS_ENOTHREAD(s) ((s) == APR_ENOTHREAD) -/** APR was not given a thread key structure */ -#define APR_STATUS_IS_ENOTHDKEY(s) ((s) == APR_ENOTHDKEY) -/** Generic Error which can not be put into another spot */ -#define APR_STATUS_IS_EGENERAL(s) ((s) == APR_EGENERAL) -/** There is no more shared memory available */ -#define APR_STATUS_IS_ENOSHMAVAIL(s) ((s) == APR_ENOSHMAVAIL) -/** The specified IP address is invalid */ -#define APR_STATUS_IS_EBADIP(s) ((s) == APR_EBADIP) -/** The specified netmask is invalid */ -#define APR_STATUS_IS_EBADMASK(s) ((s) == APR_EBADMASK) -/* empty slot: +18 */ -/** - * APR was unable to open the dso object. - * For more information call apr_dso_error(). - */ -#if defined(WIN32) -#define APR_STATUS_IS_EDSOOPEN(s) ((s) == APR_EDSOOPEN \ - || APR_TO_OS_ERROR(s) == ERROR_MOD_NOT_FOUND) -#else -#define APR_STATUS_IS_EDSOOPEN(s) ((s) == APR_EDSOOPEN) -#endif -/** The given path was absolute. */ -#define APR_STATUS_IS_EABSOLUTE(s) ((s) == APR_EABSOLUTE) -/** The given path was relative. */ -#define APR_STATUS_IS_ERELATIVE(s) ((s) == APR_ERELATIVE) -/** The given path was neither relative nor absolute. */ -#define APR_STATUS_IS_EINCOMPLETE(s) ((s) == APR_EINCOMPLETE) -/** The given path was above the root path. */ -#define APR_STATUS_IS_EABOVEROOT(s) ((s) == APR_EABOVEROOT) -/** The given path was bad. */ -#define APR_STATUS_IS_EBADPATH(s) ((s) == APR_EBADPATH) -/** The given path contained wildcards. */ -#define APR_STATUS_IS_EPATHWILD(s) ((s) == APR_EPATHWILD) -/** Could not find the requested symbol. - * For more information call apr_dso_error(). - */ -#if defined(WIN32) -#define APR_STATUS_IS_ESYMNOTFOUND(s) ((s) == APR_ESYMNOTFOUND \ - || APR_TO_OS_ERROR(s) == ERROR_PROC_NOT_FOUND) -#else -#define APR_STATUS_IS_ESYMNOTFOUND(s) ((s) == APR_ESYMNOTFOUND) -#endif -/** The given process was not recognized by APR. */ -#define APR_STATUS_IS_EPROC_UNKNOWN(s) ((s) == APR_EPROC_UNKNOWN) -/** APR could not gather enough entropy to continue. */ -#define APR_STATUS_IS_ENOTENOUGHENTROPY(s) ((s) == APR_ENOTENOUGHENTROPY) - -/** @} */ - -/** - * @addtogroup APR_Error - * @{ - */ -/** @see APR_STATUS_IS_INCHILD */ -#define APR_INCHILD (APR_OS_START_STATUS + 1) -/** @see APR_STATUS_IS_INPARENT */ -#define APR_INPARENT (APR_OS_START_STATUS + 2) -/** @see APR_STATUS_IS_DETACH */ -#define APR_DETACH (APR_OS_START_STATUS + 3) -/** @see APR_STATUS_IS_NOTDETACH */ -#define APR_NOTDETACH (APR_OS_START_STATUS + 4) -/** @see APR_STATUS_IS_CHILD_DONE */ -#define APR_CHILD_DONE (APR_OS_START_STATUS + 5) -/** @see APR_STATUS_IS_CHILD_NOTDONE */ -#define APR_CHILD_NOTDONE (APR_OS_START_STATUS + 6) -/** @see APR_STATUS_IS_TIMEUP */ -#define APR_TIMEUP (APR_OS_START_STATUS + 7) -/** @see APR_STATUS_IS_INCOMPLETE */ -#define APR_INCOMPLETE (APR_OS_START_STATUS + 8) -/* empty slot: +9 */ -/* empty slot: +10 */ -/* empty slot: +11 */ -/** @see APR_STATUS_IS_BADCH */ -#define APR_BADCH (APR_OS_START_STATUS + 12) -/** @see APR_STATUS_IS_BADARG */ -#define APR_BADARG (APR_OS_START_STATUS + 13) -/** @see APR_STATUS_IS_EOF */ -#define APR_EOF (APR_OS_START_STATUS + 14) -/** @see APR_STATUS_IS_NOTFOUND */ -#define APR_NOTFOUND (APR_OS_START_STATUS + 15) -/* empty slot: +16 */ -/* empty slot: +17 */ -/* empty slot: +18 */ -/** @see APR_STATUS_IS_ANONYMOUS */ -#define APR_ANONYMOUS (APR_OS_START_STATUS + 19) -/** @see APR_STATUS_IS_FILEBASED */ -#define APR_FILEBASED (APR_OS_START_STATUS + 20) -/** @see APR_STATUS_IS_KEYBASED */ -#define APR_KEYBASED (APR_OS_START_STATUS + 21) -/** @see APR_STATUS_IS_EINIT */ -#define APR_EINIT (APR_OS_START_STATUS + 22) -/** @see APR_STATUS_IS_ENOTIMPL */ -#define APR_ENOTIMPL (APR_OS_START_STATUS + 23) -/** @see APR_STATUS_IS_EMISMATCH */ -#define APR_EMISMATCH (APR_OS_START_STATUS + 24) -/** @see APR_STATUS_IS_EBUSY */ -#define APR_EBUSY (APR_OS_START_STATUS + 25) -/** @} */ - -/** - * @addtogroup APR_STATUS_IS - * @{ - */ -/** - * Program is currently executing in the child - * @warning - * always use this test, as platform-specific variances may meet this - * more than one error code */ -#define APR_STATUS_IS_INCHILD(s) ((s) == APR_INCHILD) -/** - * Program is currently executing in the parent - * @warning - * always use this test, as platform-specific variances may meet this - * more than one error code - */ -#define APR_STATUS_IS_INPARENT(s) ((s) == APR_INPARENT) -/** - * The thread is detached - * @warning - * always use this test, as platform-specific variances may meet this - * more than one error code - */ -#define APR_STATUS_IS_DETACH(s) ((s) == APR_DETACH) -/** - * The thread is not detached - * @warning - * always use this test, as platform-specific variances may meet this - * more than one error code - */ -#define APR_STATUS_IS_NOTDETACH(s) ((s) == APR_NOTDETACH) -/** - * The child has finished executing - * @warning - * always use this test, as platform-specific variances may meet this - * more than one error code - */ -#define APR_STATUS_IS_CHILD_DONE(s) ((s) == APR_CHILD_DONE) -/** - * The child has not finished executing - * @warning - * always use this test, as platform-specific variances may meet this - * more than one error code - */ -#define APR_STATUS_IS_CHILD_NOTDONE(s) ((s) == APR_CHILD_NOTDONE) -/** - * The operation did not finish before the timeout - * @warning - * always use this test, as platform-specific variances may meet this - * more than one error code - */ -#define APR_STATUS_IS_TIMEUP(s) ((s) == APR_TIMEUP) -/** - * The operation was incomplete although some processing was performed - * and the results are partially valid. - * @warning - * always use this test, as platform-specific variances may meet this - * more than one error code - */ -#define APR_STATUS_IS_INCOMPLETE(s) ((s) == APR_INCOMPLETE) -/* empty slot: +9 */ -/* empty slot: +10 */ -/* empty slot: +11 */ -/** - * Getopt found an option not in the option string - * @warning - * always use this test, as platform-specific variances may meet this - * more than one error code - */ -#define APR_STATUS_IS_BADCH(s) ((s) == APR_BADCH) -/** - * Getopt found an option not in the option string and an argument was - * specified in the option string - * @warning - * always use this test, as platform-specific variances may meet this - * more than one error code - */ -#define APR_STATUS_IS_BADARG(s) ((s) == APR_BADARG) -/** - * APR has encountered the end of the file - * @warning - * always use this test, as platform-specific variances may meet this - * more than one error code - */ -#define APR_STATUS_IS_EOF(s) ((s) == APR_EOF) -/** - * APR was unable to find the socket in the poll structure - * @warning - * always use this test, as platform-specific variances may meet this - * more than one error code - */ -#define APR_STATUS_IS_NOTFOUND(s) ((s) == APR_NOTFOUND) -/* empty slot: +16 */ -/* empty slot: +17 */ -/* empty slot: +18 */ -/** - * APR is using anonymous shared memory - * @warning - * always use this test, as platform-specific variances may meet this - * more than one error code - */ -#define APR_STATUS_IS_ANONYMOUS(s) ((s) == APR_ANONYMOUS) -/** - * APR is using a file name as the key to the shared memory - * @warning - * always use this test, as platform-specific variances may meet this - * more than one error code - */ -#define APR_STATUS_IS_FILEBASED(s) ((s) == APR_FILEBASED) -/** - * APR is using a shared key as the key to the shared memory - * @warning - * always use this test, as platform-specific variances may meet this - * more than one error code - */ -#define APR_STATUS_IS_KEYBASED(s) ((s) == APR_KEYBASED) -/** - * Ininitalizer value. If no option has been found, but - * the status variable requires a value, this should be used - * @warning - * always use this test, as platform-specific variances may meet this - * more than one error code - */ -#define APR_STATUS_IS_EINIT(s) ((s) == APR_EINIT) -/** - * The APR function has not been implemented on this - * platform, either because nobody has gotten to it yet, - * or the function is impossible on this platform. - * @warning - * always use this test, as platform-specific variances may meet this - * more than one error code - */ -#define APR_STATUS_IS_ENOTIMPL(s) ((s) == APR_ENOTIMPL) -/** - * Two passwords do not match. - * @warning - * always use this test, as platform-specific variances may meet this - * more than one error code - */ -#define APR_STATUS_IS_EMISMATCH(s) ((s) == APR_EMISMATCH) -/** - * The given lock was busy - * @warning always use this test, as platform-specific variances may meet this - * more than one error code - */ -#define APR_STATUS_IS_EBUSY(s) ((s) == APR_EBUSY) - -/** @} */ - -/** - * @addtogroup APR_Error APR Error Values - * @{ - */ -/* APR CANONICAL ERROR VALUES */ -/** @see APR_STATUS_IS_EACCES */ -#ifdef EACCES -#define APR_EACCES EACCES -#else -#define APR_EACCES (APR_OS_START_CANONERR + 1) -#endif - -/** @see APR_STATUS_IS_EEXIST */ -#ifdef EEXIST -#define APR_EEXIST EEXIST -#else -#define APR_EEXIST (APR_OS_START_CANONERR + 2) -#endif - -/** @see APR_STATUS_IS_ENAMETOOLONG */ -#ifdef ENAMETOOLONG -#define APR_ENAMETOOLONG ENAMETOOLONG -#else -#define APR_ENAMETOOLONG (APR_OS_START_CANONERR + 3) -#endif - -/** @see APR_STATUS_IS_ENOENT */ -#ifdef ENOENT -#define APR_ENOENT ENOENT -#else -#define APR_ENOENT (APR_OS_START_CANONERR + 4) -#endif - -/** @see APR_STATUS_IS_ENOTDIR */ -#ifdef ENOTDIR -#define APR_ENOTDIR ENOTDIR -#else -#define APR_ENOTDIR (APR_OS_START_CANONERR + 5) -#endif - -/** @see APR_STATUS_IS_ENOSPC */ -#ifdef ENOSPC -#define APR_ENOSPC ENOSPC -#else -#define APR_ENOSPC (APR_OS_START_CANONERR + 6) -#endif - -/** @see APR_STATUS_IS_ENOMEM */ -#ifdef ENOMEM -#define APR_ENOMEM ENOMEM -#else -#define APR_ENOMEM (APR_OS_START_CANONERR + 7) -#endif - -/** @see APR_STATUS_IS_EMFILE */ -#ifdef EMFILE -#define APR_EMFILE EMFILE -#else -#define APR_EMFILE (APR_OS_START_CANONERR + 8) -#endif - -/** @see APR_STATUS_IS_ENFILE */ -#ifdef ENFILE -#define APR_ENFILE ENFILE -#else -#define APR_ENFILE (APR_OS_START_CANONERR + 9) -#endif - -/** @see APR_STATUS_IS_EBADF */ -#ifdef EBADF -#define APR_EBADF EBADF -#else -#define APR_EBADF (APR_OS_START_CANONERR + 10) -#endif - -/** @see APR_STATUS_IS_EINVAL */ -#ifdef EINVAL -#define APR_EINVAL EINVAL -#else -#define APR_EINVAL (APR_OS_START_CANONERR + 11) -#endif - -/** @see APR_STATUS_IS_ESPIPE */ -#ifdef ESPIPE -#define APR_ESPIPE ESPIPE -#else -#define APR_ESPIPE (APR_OS_START_CANONERR + 12) -#endif - -/** - * @see APR_STATUS_IS_EAGAIN - * @warning use APR_STATUS_IS_EAGAIN instead of just testing this value - */ -#ifdef EAGAIN -#define APR_EAGAIN EAGAIN -#elif defined(EWOULDBLOCK) -#define APR_EAGAIN EWOULDBLOCK -#else -#define APR_EAGAIN (APR_OS_START_CANONERR + 13) -#endif - -/** @see APR_STATUS_IS_EINTR */ -#ifdef EINTR -#define APR_EINTR EINTR -#else -#define APR_EINTR (APR_OS_START_CANONERR + 14) -#endif - -/** @see APR_STATUS_IS_ENOTSOCK */ -#ifdef ENOTSOCK -#define APR_ENOTSOCK ENOTSOCK -#else -#define APR_ENOTSOCK (APR_OS_START_CANONERR + 15) -#endif - -/** @see APR_STATUS_IS_ECONNREFUSED */ -#ifdef ECONNREFUSED -#define APR_ECONNREFUSED ECONNREFUSED -#else -#define APR_ECONNREFUSED (APR_OS_START_CANONERR + 16) -#endif - -/** @see APR_STATUS_IS_EINPROGRESS */ -#ifdef EINPROGRESS -#define APR_EINPROGRESS EINPROGRESS -#else -#define APR_EINPROGRESS (APR_OS_START_CANONERR + 17) -#endif - -/** - * @see APR_STATUS_IS_ECONNABORTED - * @warning use APR_STATUS_IS_ECONNABORTED instead of just testing this value - */ - -#ifdef ECONNABORTED -#define APR_ECONNABORTED ECONNABORTED -#else -#define APR_ECONNABORTED (APR_OS_START_CANONERR + 18) -#endif - -/** @see APR_STATUS_IS_ECONNRESET */ -#ifdef ECONNRESET -#define APR_ECONNRESET ECONNRESET -#else -#define APR_ECONNRESET (APR_OS_START_CANONERR + 19) -#endif - -/** @see APR_STATUS_IS_ETIMEDOUT - * @deprecated */ -#ifdef ETIMEDOUT -#define APR_ETIMEDOUT ETIMEDOUT -#else -#define APR_ETIMEDOUT (APR_OS_START_CANONERR + 20) -#endif - -/** @see APR_STATUS_IS_EHOSTUNREACH */ -#ifdef EHOSTUNREACH -#define APR_EHOSTUNREACH EHOSTUNREACH -#else -#define APR_EHOSTUNREACH (APR_OS_START_CANONERR + 21) -#endif - -/** @see APR_STATUS_IS_ENETUNREACH */ -#ifdef ENETUNREACH -#define APR_ENETUNREACH ENETUNREACH -#else -#define APR_ENETUNREACH (APR_OS_START_CANONERR + 22) -#endif - -/** @see APR_STATUS_IS_EFTYPE */ -#ifdef EFTYPE -#define APR_EFTYPE EFTYPE -#else -#define APR_EFTYPE (APR_OS_START_CANONERR + 23) -#endif - -/** @see APR_STATUS_IS_EPIPE */ -#ifdef EPIPE -#define APR_EPIPE EPIPE -#else -#define APR_EPIPE (APR_OS_START_CANONERR + 24) -#endif - -/** @see APR_STATUS_IS_EXDEV */ -#ifdef EXDEV -#define APR_EXDEV EXDEV -#else -#define APR_EXDEV (APR_OS_START_CANONERR + 25) -#endif - -/** @see APR_STATUS_IS_ENOTEMPTY */ -#ifdef ENOTEMPTY -#define APR_ENOTEMPTY ENOTEMPTY -#else -#define APR_ENOTEMPTY (APR_OS_START_CANONERR + 26) -#endif - -/** @see APR_STATUS_IS_EAFNOSUPPORT */ -#ifdef EAFNOSUPPORT -#define APR_EAFNOSUPPORT EAFNOSUPPORT -#else -#define APR_EAFNOSUPPORT (APR_OS_START_CANONERR + 27) -#endif - -/** @} */ - -#if defined(OS2) && !defined(DOXYGEN) - -#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR) -#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR) - -#define INCL_DOSERRORS -#define INCL_DOS - -/* Leave these undefined. - * OS2 doesn't rely on the errno concept. - * The API calls always return a result codes which - * should be filtered through APR_FROM_OS_ERROR(). - * - * #define apr_get_os_error() (APR_FROM_OS_ERROR(GetLastError())) - * #define apr_set_os_error(e) (SetLastError(APR_TO_OS_ERROR(e))) - */ - -/* A special case, only socket calls require this; - */ -#define apr_get_netos_error() (APR_FROM_OS_ERROR(errno)) -#define apr_set_netos_error(e) (errno = APR_TO_OS_ERROR(e)) - -/* And this needs to be greped away for good: - */ -#define APR_OS2_STATUS(e) (APR_FROM_OS_ERROR(e)) - -/* These can't sit in a private header, so in spite of the extra size, - * they need to be made available here. - */ -#define SOCBASEERR 10000 -#define SOCEPERM (SOCBASEERR+1) /* Not owner */ -#define SOCESRCH (SOCBASEERR+3) /* No such process */ -#define SOCEINTR (SOCBASEERR+4) /* Interrupted system call */ -#define SOCENXIO (SOCBASEERR+6) /* No such device or address */ -#define SOCEBADF (SOCBASEERR+9) /* Bad file number */ -#define SOCEACCES (SOCBASEERR+13) /* Permission denied */ -#define SOCEFAULT (SOCBASEERR+14) /* Bad address */ -#define SOCEINVAL (SOCBASEERR+22) /* Invalid argument */ -#define SOCEMFILE (SOCBASEERR+24) /* Too many open files */ -#define SOCEPIPE (SOCBASEERR+32) /* Broken pipe */ -#define SOCEOS2ERR (SOCBASEERR+100) /* OS/2 Error */ -#define SOCEWOULDBLOCK (SOCBASEERR+35) /* Operation would block */ -#define SOCEINPROGRESS (SOCBASEERR+36) /* Operation now in progress */ -#define SOCEALREADY (SOCBASEERR+37) /* Operation already in progress */ -#define SOCENOTSOCK (SOCBASEERR+38) /* Socket operation on non-socket */ -#define SOCEDESTADDRREQ (SOCBASEERR+39) /* Destination address required */ -#define SOCEMSGSIZE (SOCBASEERR+40) /* Message too long */ -#define SOCEPROTOTYPE (SOCBASEERR+41) /* Protocol wrong type for socket */ -#define SOCENOPROTOOPT (SOCBASEERR+42) /* Protocol not available */ -#define SOCEPROTONOSUPPORT (SOCBASEERR+43) /* Protocol not supported */ -#define SOCESOCKTNOSUPPORT (SOCBASEERR+44) /* Socket type not supported */ -#define SOCEOPNOTSUPP (SOCBASEERR+45) /* Operation not supported on socket */ -#define SOCEPFNOSUPPORT (SOCBASEERR+46) /* Protocol family not supported */ -#define SOCEAFNOSUPPORT (SOCBASEERR+47) /* Address family not supported by protocol family */ -#define SOCEADDRINUSE (SOCBASEERR+48) /* Address already in use */ -#define SOCEADDRNOTAVAIL (SOCBASEERR+49) /* Can't assign requested address */ -#define SOCENETDOWN (SOCBASEERR+50) /* Network is down */ -#define SOCENETUNREACH (SOCBASEERR+51) /* Network is unreachable */ -#define SOCENETRESET (SOCBASEERR+52) /* Network dropped connection on reset */ -#define SOCECONNABORTED (SOCBASEERR+53) /* Software caused connection abort */ -#define SOCECONNRESET (SOCBASEERR+54) /* Connection reset by peer */ -#define SOCENOBUFS (SOCBASEERR+55) /* No buffer space available */ -#define SOCEISCONN (SOCBASEERR+56) /* Socket is already connected */ -#define SOCENOTCONN (SOCBASEERR+57) /* Socket is not connected */ -#define SOCESHUTDOWN (SOCBASEERR+58) /* Can't send after socket shutdown */ -#define SOCETOOMANYREFS (SOCBASEERR+59) /* Too many references: can't splice */ -#define SOCETIMEDOUT (SOCBASEERR+60) /* Connection timed out */ -#define SOCECONNREFUSED (SOCBASEERR+61) /* Connection refused */ -#define SOCELOOP (SOCBASEERR+62) /* Too many levels of symbolic links */ -#define SOCENAMETOOLONG (SOCBASEERR+63) /* File name too long */ -#define SOCEHOSTDOWN (SOCBASEERR+64) /* Host is down */ -#define SOCEHOSTUNREACH (SOCBASEERR+65) /* No route to host */ -#define SOCENOTEMPTY (SOCBASEERR+66) /* Directory not empty */ - -/* APR CANONICAL ERROR TESTS */ -#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES \ - || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED \ - || (s) == APR_OS_START_SYSERR + ERROR_SHARING_VIOLATION) -#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST \ - || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED \ - || (s) == APR_OS_START_SYSERR + ERROR_FILE_EXISTS \ - || (s) == APR_OS_START_SYSERR + ERROR_ALREADY_EXISTS \ - || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED) -#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG \ - || (s) == APR_OS_START_SYSERR + ERROR_FILENAME_EXCED_RANGE \ - || (s) == APR_OS_START_SYSERR + SOCENAMETOOLONG) -#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT \ - || (s) == APR_OS_START_SYSERR + ERROR_FILE_NOT_FOUND \ - || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \ - || (s) == APR_OS_START_SYSERR + ERROR_NO_MORE_FILES \ - || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED) -#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR) -#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC \ - || (s) == APR_OS_START_SYSERR + ERROR_DISK_FULL) -#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM) -#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE \ - || (s) == APR_OS_START_SYSERR + ERROR_TOO_MANY_OPEN_FILES) -#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE) -#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF \ - || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE) -#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL \ - || (s) == APR_OS_START_SYSERR + ERROR_INVALID_PARAMETER \ - || (s) == APR_OS_START_SYSERR + ERROR_INVALID_FUNCTION) -#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE \ - || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK) -#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \ - || (s) == APR_OS_START_SYSERR + ERROR_NO_DATA \ - || (s) == APR_OS_START_SYSERR + SOCEWOULDBLOCK \ - || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION) -#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR \ - || (s) == APR_OS_START_SYSERR + SOCEINTR) -#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK \ - || (s) == APR_OS_START_SYSERR + SOCENOTSOCK) -#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED \ - || (s) == APR_OS_START_SYSERR + SOCECONNREFUSED) -#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS \ - || (s) == APR_OS_START_SYSERR + SOCEINPROGRESS) -#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \ - || (s) == APR_OS_START_SYSERR + SOCECONNABORTED) -#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET \ - || (s) == APR_OS_START_SYSERR + SOCECONNRESET) -/* XXX deprecated */ -#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT \ - || (s) == APR_OS_START_SYSERR + SOCETIMEDOUT) -#undef APR_STATUS_IS_TIMEUP -#define APR_STATUS_IS_TIMEUP(s) ((s) == APR_TIMEUP \ - || (s) == APR_OS_START_SYSERR + SOCETIMEDOUT) -#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH \ - || (s) == APR_OS_START_SYSERR + SOCEHOSTUNREACH) -#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH \ - || (s) == APR_OS_START_SYSERR + SOCENETUNREACH) -#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE) -#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE \ - || (s) == APR_OS_START_SYSERR + ERROR_BROKEN_PIPE \ - || (s) == APR_OS_START_SYSERR + SOCEPIPE) -#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV \ - || (s) == APR_OS_START_SYSERR + ERROR_NOT_SAME_DEVICE) -#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY \ - || (s) == APR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY \ - || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED) -#define APR_STATUS_IS_EAFNOSUPPORT(s) ((s) == APR_AFNOSUPPORT \ - || (s) == APR_OS_START_SYSERR + SOCEAFNOSUPPORT) - -/* - Sorry, too tired to wrap this up for OS2... feel free to - fit the following into their best matches. - - { ERROR_NO_SIGNAL_SENT, ESRCH }, - { SOCEALREADY, EALREADY }, - { SOCEDESTADDRREQ, EDESTADDRREQ }, - { SOCEMSGSIZE, EMSGSIZE }, - { SOCEPROTOTYPE, EPROTOTYPE }, - { SOCENOPROTOOPT, ENOPROTOOPT }, - { SOCEPROTONOSUPPORT, EPROTONOSUPPORT }, - { SOCESOCKTNOSUPPORT, ESOCKTNOSUPPORT }, - { SOCEOPNOTSUPP, EOPNOTSUPP }, - { SOCEPFNOSUPPORT, EPFNOSUPPORT }, - { SOCEADDRINUSE, EADDRINUSE }, - { SOCEADDRNOTAVAIL, EADDRNOTAVAIL }, - { SOCENETDOWN, ENETDOWN }, - { SOCENETRESET, ENETRESET }, - { SOCENOBUFS, ENOBUFS }, - { SOCEISCONN, EISCONN }, - { SOCENOTCONN, ENOTCONN }, - { SOCESHUTDOWN, ESHUTDOWN }, - { SOCETOOMANYREFS, ETOOMANYREFS }, - { SOCELOOP, ELOOP }, - { SOCEHOSTDOWN, EHOSTDOWN }, - { SOCENOTEMPTY, ENOTEMPTY }, - { SOCEPIPE, EPIPE } -*/ - -#elif defined(WIN32) && !defined(DOXYGEN) /* !defined(OS2) */ - -#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR) -#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR) - -#define apr_get_os_error() (APR_FROM_OS_ERROR(GetLastError())) -#define apr_set_os_error(e) (SetLastError(APR_TO_OS_ERROR(e))) - -/* A special case, only socket calls require this: - */ -#define apr_get_netos_error() (APR_FROM_OS_ERROR(WSAGetLastError())) -#define apr_set_netos_error(e) (WSASetLastError(APR_TO_OS_ERROR(e))) - -/* APR CANONICAL ERROR TESTS */ -#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES \ - || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED \ - || (s) == APR_OS_START_SYSERR + ERROR_CANNOT_MAKE \ - || (s) == APR_OS_START_SYSERR + ERROR_CURRENT_DIRECTORY \ - || (s) == APR_OS_START_SYSERR + ERROR_DRIVE_LOCKED \ - || (s) == APR_OS_START_SYSERR + ERROR_FAIL_I24 \ - || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION \ - || (s) == APR_OS_START_SYSERR + ERROR_LOCK_FAILED \ - || (s) == APR_OS_START_SYSERR + ERROR_NOT_LOCKED \ - || (s) == APR_OS_START_SYSERR + ERROR_NETWORK_ACCESS_DENIED \ - || (s) == APR_OS_START_SYSERR + ERROR_SHARING_VIOLATION) -#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST \ - || (s) == APR_OS_START_SYSERR + ERROR_FILE_EXISTS \ - || (s) == APR_OS_START_SYSERR + ERROR_ALREADY_EXISTS) -#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG \ - || (s) == APR_OS_START_SYSERR + ERROR_FILENAME_EXCED_RANGE \ - || (s) == APR_OS_START_SYSERR + WSAENAMETOOLONG) -#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT \ - || (s) == APR_OS_START_SYSERR + ERROR_FILE_NOT_FOUND \ - || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \ - || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED \ - || (s) == APR_OS_START_SYSERR + ERROR_NO_MORE_FILES) -#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR \ - || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \ - || (s) == APR_OS_START_SYSERR + ERROR_BAD_NETPATH \ - || (s) == APR_OS_START_SYSERR + ERROR_BAD_NET_NAME \ - || (s) == APR_OS_START_SYSERR + ERROR_BAD_PATHNAME \ - || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DRIVE \ - || (s) == APR_OS_START_SYSERR + ERROR_DIRECTORY) -#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC \ - || (s) == APR_OS_START_SYSERR + ERROR_DISK_FULL) -#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM \ - || (s) == APR_OS_START_SYSERR + ERROR_ARENA_TRASHED \ - || (s) == APR_OS_START_SYSERR + ERROR_NOT_ENOUGH_MEMORY \ - || (s) == APR_OS_START_SYSERR + ERROR_INVALID_BLOCK \ - || (s) == APR_OS_START_SYSERR + ERROR_NOT_ENOUGH_QUOTA \ - || (s) == APR_OS_START_SYSERR + ERROR_OUTOFMEMORY) -#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE \ - || (s) == APR_OS_START_SYSERR + ERROR_TOO_MANY_OPEN_FILES) -#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE) -#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF \ - || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE \ - || (s) == APR_OS_START_SYSERR + ERROR_INVALID_TARGET_HANDLE) -#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL \ - || (s) == APR_OS_START_SYSERR + ERROR_INVALID_ACCESS \ - || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DATA \ - || (s) == APR_OS_START_SYSERR + ERROR_INVALID_FUNCTION \ - || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE \ - || (s) == APR_OS_START_SYSERR + ERROR_INVALID_PARAMETER \ - || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK) -#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE \ - || (s) == APR_OS_START_SYSERR + ERROR_SEEK_ON_DEVICE \ - || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK) -#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \ - || (s) == APR_OS_START_SYSERR + ERROR_NO_DATA \ - || (s) == APR_OS_START_SYSERR + ERROR_NO_PROC_SLOTS \ - || (s) == APR_OS_START_SYSERR + ERROR_NESTING_NOT_ALLOWED \ - || (s) == APR_OS_START_SYSERR + ERROR_MAX_THRDS_REACHED \ - || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION \ - || (s) == APR_OS_START_SYSERR + WSAEWOULDBLOCK) -#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR \ - || (s) == APR_OS_START_SYSERR + WSAEINTR) -#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK \ - || (s) == APR_OS_START_SYSERR + WSAENOTSOCK) -#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED \ - || (s) == APR_OS_START_SYSERR + WSAECONNREFUSED) -#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS \ - || (s) == APR_OS_START_SYSERR + WSAEINPROGRESS) -#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \ - || (s) == APR_OS_START_SYSERR + WSAECONNABORTED) -#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET \ - || (s) == APR_OS_START_SYSERR + ERROR_NETNAME_DELETED \ - || (s) == APR_OS_START_SYSERR + WSAECONNRESET) -/* XXX deprecated */ -#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT \ - || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \ - || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT) -#undef APR_STATUS_IS_TIMEUP -#define APR_STATUS_IS_TIMEUP(s) ((s) == APR_TIMEUP \ - || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \ - || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT) -#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH \ - || (s) == APR_OS_START_SYSERR + WSAEHOSTUNREACH) -#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH \ - || (s) == APR_OS_START_SYSERR + WSAENETUNREACH) -#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE \ - || (s) == APR_OS_START_SYSERR + ERROR_EXE_MACHINE_TYPE_MISMATCH \ - || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DLL \ - || (s) == APR_OS_START_SYSERR + ERROR_INVALID_MODULETYPE \ - || (s) == APR_OS_START_SYSERR + ERROR_BAD_EXE_FORMAT \ - || (s) == APR_OS_START_SYSERR + ERROR_INVALID_EXE_SIGNATURE \ - || (s) == APR_OS_START_SYSERR + ERROR_FILE_CORRUPT \ - || (s) == APR_OS_START_SYSERR + ERROR_BAD_FORMAT) -#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE \ - || (s) == APR_OS_START_SYSERR + ERROR_BROKEN_PIPE) -#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV \ - || (s) == APR_OS_START_SYSERR + ERROR_NOT_SAME_DEVICE) -#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY \ - || (s) == APR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY) -#define APR_STATUS_IS_EAFNOSUPPORT(s) ((s) == APR_EAFNOSUPPORT \ - || (s) == APR_OS_START_SYSERR + WSAEAFNOSUPPORT) - -#elif defined(NETWARE) && defined(USE_WINSOCK) && !defined(DOXYGEN) /* !defined(OS2) && !defined(WIN32) */ - -#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR) -#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR) - -#define apr_get_os_error() (errno) -#define apr_set_os_error(e) (errno = (e)) - -/* A special case, only socket calls require this: */ -#define apr_get_netos_error() (APR_FROM_OS_ERROR(WSAGetLastError())) -#define apr_set_netos_error(e) (WSASetLastError(APR_TO_OS_ERROR(e))) - -/* APR CANONICAL ERROR TESTS */ -#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES) -#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST) -#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG) -#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT) -#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR) -#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC) -#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM) -#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE) -#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE) -#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF) -#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL) -#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE) - -#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \ - || (s) == EWOULDBLOCK \ - || (s) == APR_OS_START_SYSERR + WSAEWOULDBLOCK) -#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR \ - || (s) == APR_OS_START_SYSERR + WSAEINTR) -#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK \ - || (s) == APR_OS_START_SYSERR + WSAENOTSOCK) -#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED \ - || (s) == APR_OS_START_SYSERR + WSAECONNREFUSED) -#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS \ - || (s) == APR_OS_START_SYSERR + WSAEINPROGRESS) -#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \ - || (s) == APR_OS_START_SYSERR + WSAECONNABORTED) -#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET \ - || (s) == APR_OS_START_SYSERR + WSAECONNRESET) -/* XXX deprecated */ -#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT \ - || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \ - || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT) -#undef APR_STATUS_IS_TIMEUP -#define APR_STATUS_IS_TIMEUP(s) ((s) == APR_TIMEUP \ - || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \ - || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT) -#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH \ - || (s) == APR_OS_START_SYSERR + WSAEHOSTUNREACH) -#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH \ - || (s) == APR_OS_START_SYSERR + WSAENETUNREACH) -#define APR_STATUS_IS_ENETDOWN(s) ((s) == APR_OS_START_SYSERR + WSAENETDOWN) -#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE) -#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE) -#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV) -#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY) -#define APR_STATUS_IS_EAFNOSUPPORT(s) ((s) == APR_EAFNOSUPPORT \ - || (s) == APR_OS_START_SYSERR + WSAEAFNOSUPPORT) - -#else /* !defined(NETWARE) && !defined(OS2) && !defined(WIN32) */ - -/* - * os error codes are clib error codes - */ -#define APR_FROM_OS_ERROR(e) (e) -#define APR_TO_OS_ERROR(e) (e) - -#define apr_get_os_error() (errno) -#define apr_set_os_error(e) (errno = (e)) - -/* A special case, only socket calls require this: - */ -#define apr_get_netos_error() (errno) -#define apr_set_netos_error(e) (errno = (e)) - -/** - * @addtogroup APR_STATUS_IS - * @{ - */ - -/** permission denied */ -#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES) -/** file exists */ -#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST) -/** path name is too long */ -#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG) -/** - * no such file or directory - * @remark - * EMVSCATLG can be returned by the automounter on z/OS for - * paths which do not exist. - */ -#ifdef EMVSCATLG -#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT \ - || (s) == EMVSCATLG) -#else -#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT) -#endif -/** not a directory */ -#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR) -/** no space left on device */ -#ifdef EDQUOT -#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC \ - || (s) == EDQUOT) -#else -#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC) -#endif -/** not enough memory */ -#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM) -/** too many open files */ -#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE) -/** file table overflow */ -#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE) -/** bad file # */ -#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF) -/** invalid argument */ -#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL) -/** illegal seek */ -#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE) - -/** operation would block */ -#if !defined(EWOULDBLOCK) || !defined(EAGAIN) -#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN) -#elif (EWOULDBLOCK == EAGAIN) -#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN) -#else -#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \ - || (s) == EWOULDBLOCK) -#endif - -/** interrupted system call */ -#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR) -/** socket operation on a non-socket */ -#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK) -/** Connection Refused */ -#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED) -/** operation now in progress */ -#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS) - -/** - * Software caused connection abort - * @remark - * EPROTO on certain older kernels really means ECONNABORTED, so we need to - * ignore it for them. See discussion in new-httpd archives nh.9701 & nh.9603 - * - * There is potentially a bug in Solaris 2.x x<6, and other boxes that - * implement tcp sockets in userland (i.e. on top of STREAMS). On these - * systems, EPROTO can actually result in a fatal loop. See PR#981 for - * example. It's hard to handle both uses of EPROTO. - */ -#ifdef EPROTO -#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \ - || (s) == EPROTO) -#else -#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED) -#endif - -/** Connection Reset by peer */ -#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET) -/** Operation timed out - * @deprecated */ -#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT) -/** no route to host */ -#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH) -/** network is unreachable */ -#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH) -/** inappropiate file type or format */ -#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE) -/** broken pipe */ -#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE) -/** cross device link */ -#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV) -/** Directory Not Empty */ -#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY || \ - (s) == APR_EEXIST) -/** Address Family not supported */ -#define APR_STATUS_IS_EAFNOSUPPORT(s) ((s) == APR_EAFNOSUPPORT) -/** @} */ - -#endif /* !defined(NETWARE) && !defined(OS2) && !defined(WIN32) */ - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ! APR_ERRNO_H */ diff --git a/libs/apr/include/apr_file_info.h b/libs/apr/include/apr_file_info.h deleted file mode 100644 index 94e84e87..00000000 --- a/libs/apr/include/apr_file_info.h +++ /dev/null @@ -1,428 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_FILE_INFO_H -#define APR_FILE_INFO_H - -/** - * @file apr_file_info.h - * @brief APR File Information - */ - -#include "apr.h" -#include "apr_user.h" -#include "apr_pools.h" -#include "apr_tables.h" -#include "apr_time.h" -#include "apr_errno.h" - -#if APR_HAVE_SYS_UIO_H -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup apr_file_info File Information - * @ingroup APR - * @{ - */ - -/* Many applications use the type member to determine the - * existance of a file or initialization of the file info, - * so the APR_NOFILE value must be distinct from APR_UNKFILE. - */ - -/** apr_filetype_e values for the filetype member of the - * apr_file_info_t structure - * @warning: Not all of the filetypes below can be determined. - * For example, a given platform might not correctly report - * a socket descriptor as APR_SOCK if that type isn't - * well-identified on that platform. In such cases where - * a filetype exists but cannot be described by the recognized - * flags below, the filetype will be APR_UNKFILE. If the - * filetype member is not determined, the type will be APR_NOFILE. - */ - -typedef enum { - APR_NOFILE = 0, /**< no file type determined */ - APR_REG, /**< a regular file */ - APR_DIR, /**< a directory */ - APR_CHR, /**< a character device */ - APR_BLK, /**< a block device */ - APR_PIPE, /**< a FIFO / pipe */ - APR_LNK, /**< a symbolic link */ - APR_SOCK, /**< a [unix domain] socket */ - APR_UNKFILE = 127 /**< a file of some other unknown type */ -} apr_filetype_e; - -/** - * @defgroup apr_file_permissions File Permissions flags - * @{ - */ - -#define APR_FPROT_USETID 0x8000 /**< Set user id */ -#define APR_FPROT_UREAD 0x0400 /**< Read by user */ -#define APR_FPROT_UWRITE 0x0200 /**< Write by user */ -#define APR_FPROT_UEXECUTE 0x0100 /**< Execute by user */ - -#define APR_FPROT_GSETID 0x4000 /**< Set group id */ -#define APR_FPROT_GREAD 0x0040 /**< Read by group */ -#define APR_FPROT_GWRITE 0x0020 /**< Write by group */ -#define APR_FPROT_GEXECUTE 0x0010 /**< Execute by group */ - -#define APR_FPROT_WSTICKY 0x2000 /**< Sticky bit */ -#define APR_FPROT_WREAD 0x0004 /**< Read by others */ -#define APR_FPROT_WWRITE 0x0002 /**< Write by others */ -#define APR_FPROT_WEXECUTE 0x0001 /**< Execute by others */ - -#define APR_FPROT_OS_DEFAULT 0x0FFF /**< use OS's default permissions */ - -/* additional permission flags for apr_file_copy and apr_file_append */ -#define APR_FPROT_FILE_SOURCE_PERMS 0x1000 /**< Copy source file's permissions */ - -/* backcompat */ -#define APR_USETID APR_FPROT_USETID /**< @deprecated @see APR_FPROT_USETID */ -#define APR_UREAD APR_FPROT_UREAD /**< @deprecated @see APR_FPROT_UREAD */ -#define APR_UWRITE APR_FPROT_UWRITE /**< @deprecated @see APR_FPROT_UWRITE */ -#define APR_UEXECUTE APR_FPROT_UEXECUTE /**< @deprecated @see APR_FPROT_UEXECUTE */ -#define APR_GSETID APR_FPROT_GSETID /**< @deprecated @see APR_FPROT_GSETID */ -#define APR_GREAD APR_FPROT_GREAD /**< @deprecated @see APR_FPROT_GREAD */ -#define APR_GWRITE APR_FPROT_GWRITE /**< @deprecated @see APR_FPROT_GWRITE */ -#define APR_GEXECUTE APR_FPROT_GEXECUTE /**< @deprecated @see APR_FPROT_GEXECUTE */ -#define APR_WSTICKY APR_FPROT_WSTICKY /**< @deprecated @see APR_FPROT_WSTICKY */ -#define APR_WREAD APR_FPROT_WREAD /**< @deprecated @see APR_FPROT_WREAD */ -#define APR_WWRITE APR_FPROT_WWRITE /**< @deprecated @see APR_FPROT_WWRITE */ -#define APR_WEXECUTE APR_FPROT_WEXECUTE /**< @deprecated @see APR_FPROT_WEXECUTE */ -#define APR_OS_DEFAULT APR_FPROT_OS_DEFAULT /**< @deprecated @see APR_FPROT_OS_DEFAULT */ -#define APR_FILE_SOURCE_PERMS APR_FPROT_FILE_SOURCE_PERMS /**< @deprecated @see APR_FPROT_FILE_SOURCE_PERMS */ - -/** @} */ - - -/** - * Structure for referencing directories. - */ -typedef struct apr_dir_t apr_dir_t; -/** - * Structure for determining file permissions. - */ -typedef apr_int32_t apr_fileperms_t; -#if (defined WIN32) || (defined NETWARE) -/** - * Structure for determining the device the file is on. - */ -typedef apr_uint32_t apr_dev_t; -#else -/** - * Structure for determining the device the file is on. - */ -typedef dev_t apr_dev_t; -#endif - -/** - * @defgroup apr_file_stat Stat Functions - * @{ - */ -/** file info structure */ -typedef struct apr_finfo_t apr_finfo_t; - -#define APR_FINFO_LINK 0x00000001 /**< Stat the link not the file itself if it is a link */ -#define APR_FINFO_MTIME 0x00000010 /**< Modification Time */ -#define APR_FINFO_CTIME 0x00000020 /**< Creation or inode-changed time */ -#define APR_FINFO_ATIME 0x00000040 /**< Access Time */ -#define APR_FINFO_SIZE 0x00000100 /**< Size of the file */ -#define APR_FINFO_CSIZE 0x00000200 /**< Storage size consumed by the file */ -#define APR_FINFO_DEV 0x00001000 /**< Device */ -#define APR_FINFO_INODE 0x00002000 /**< Inode */ -#define APR_FINFO_NLINK 0x00004000 /**< Number of links */ -#define APR_FINFO_TYPE 0x00008000 /**< Type */ -#define APR_FINFO_USER 0x00010000 /**< User */ -#define APR_FINFO_GROUP 0x00020000 /**< Group */ -#define APR_FINFO_UPROT 0x00100000 /**< User protection bits */ -#define APR_FINFO_GPROT 0x00200000 /**< Group protection bits */ -#define APR_FINFO_WPROT 0x00400000 /**< World protection bits */ -#define APR_FINFO_ICASE 0x01000000 /**< if dev is case insensitive */ -#define APR_FINFO_NAME 0x02000000 /**< ->name in proper case */ - -#define APR_FINFO_MIN 0x00008170 /**< type, mtime, ctime, atime, size */ -#define APR_FINFO_IDENT 0x00003000 /**< dev and inode */ -#define APR_FINFO_OWNER 0x00030000 /**< user and group */ -#define APR_FINFO_PROT 0x00700000 /**< all protections */ -#define APR_FINFO_NORM 0x0073b170 /**< an atomic unix apr_stat() */ -#define APR_FINFO_DIRENT 0x02000000 /**< an atomic unix apr_dir_read() */ - -/** - * The file information structure. This is analogous to the POSIX - * stat structure. - */ -struct apr_finfo_t { - /** Allocates memory and closes lingering handles in the specified pool */ - apr_pool_t *pool; - /** The bitmask describing valid fields of this apr_finfo_t structure - * including all available 'wanted' fields and potentially more */ - apr_int32_t valid; - /** The access permissions of the file. Mimics Unix access rights. */ - apr_fileperms_t protection; - /** The type of file. One of APR_REG, APR_DIR, APR_CHR, APR_BLK, APR_PIPE, - * APR_LNK or APR_SOCK. If the type is undetermined, the value is APR_NOFILE. - * If the type cannot be determined, the value is APR_UNKFILE. - */ - apr_filetype_e filetype; - /** The user id that owns the file */ - apr_uid_t user; - /** The group id that owns the file */ - apr_gid_t group; - /** The inode of the file. */ - apr_ino_t inode; - /** The id of the device the file is on. */ - apr_dev_t device; - /** The number of hard links to the file. */ - apr_int32_t nlink; - /** The size of the file */ - apr_off_t size; - /** The storage size consumed by the file */ - apr_off_t csize; - /** The time the file was last accessed */ - apr_time_t atime; - /** The time the file was last modified */ - apr_time_t mtime; - /** The time the file was created, or the inode was last changed */ - apr_time_t ctime; - /** The pathname of the file (possibly unrooted) */ - const char *fname; - /** The file's name (no path) in filesystem case */ - const char *name; - /** The file's handle, if accessed (can be submitted to apr_duphandle) */ - struct apr_file_t *filehand; -}; - -/** - * get the specified file's stats. The file is specified by filename, - * instead of using a pre-opened file. - * @param finfo Where to store the information about the file, which is - * never touched if the call fails. - * @param fname The name of the file to stat. - * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ - values - * @param pool the pool to use to allocate the new file. - * - * @note If @c APR_INCOMPLETE is returned all the fields in @a finfo may - * not be filled in, and you need to check the @c finfo->valid bitmask - * to verify that what you're looking for is there. - */ -APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, - apr_int32_t wanted, apr_pool_t *pool); - -/** @} */ -/** - * @defgroup apr_dir Directory Manipulation Functions - * @{ - */ - -/** - * Open the specified directory. - * @param new_dir The opened directory descriptor. - * @param dirname The full path to the directory (use / on all systems) - * @param pool The pool to use. - */ -APR_DECLARE(apr_status_t) apr_dir_open(apr_dir_t **new_dir, - const char *dirname, - apr_pool_t *pool); - -/** - * close the specified directory. - * @param thedir the directory descriptor to close. - */ -APR_DECLARE(apr_status_t) apr_dir_close(apr_dir_t *thedir); - -/** - * Read the next entry from the specified directory. - * @param finfo the file info structure and filled in by apr_dir_read - * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ - values - * @param thedir the directory descriptor returned from apr_dir_open - * @remark No ordering is guaranteed for the entries read. - * - * @note If @c APR_INCOMPLETE is returned all the fields in @a finfo may - * not be filled in, and you need to check the @c finfo->valid bitmask - * to verify that what you're looking for is there. When no more - * entries are available, APR_ENOENT is returned. - */ -APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, - apr_dir_t *thedir); - -/** - * Rewind the directory to the first entry. - * @param thedir the directory descriptor to rewind. - */ -APR_DECLARE(apr_status_t) apr_dir_rewind(apr_dir_t *thedir); -/** @} */ - -/** - * @defgroup apr_filepath Filepath Manipulation Functions - * @{ - */ - -/** Cause apr_filepath_merge to fail if addpath is above rootpath - * @bug in APR 0.9 and 1.x, this flag's behavior is undefined - * if the rootpath is NULL or empty. In APR 2.0 this should be - * changed to imply NOTABSOLUTE if the rootpath is NULL or empty. - */ -#define APR_FILEPATH_NOTABOVEROOT 0x01 - -/** internal: Only meaningful with APR_FILEPATH_NOTABOVEROOT */ -#define APR_FILEPATH_SECUREROOTTEST 0x02 - -/** Cause apr_filepath_merge to fail if addpath is above rootpath, - * even given a rootpath /foo/bar and an addpath ../bar/bash - */ -#define APR_FILEPATH_SECUREROOT 0x03 - -/** Fail apr_filepath_merge if the merged path is relative */ -#define APR_FILEPATH_NOTRELATIVE 0x04 - -/** Fail apr_filepath_merge if the merged path is absolute */ -#define APR_FILEPATH_NOTABSOLUTE 0x08 - -/** Return the file system's native path format (e.g. path delimiters - * of ':' on MacOS9, '\' on Win32, etc.) */ -#define APR_FILEPATH_NATIVE 0x10 - -/** Resolve the true case of existing directories and file elements - * of addpath, (resolving any aliases on Win32) and append a proper - * trailing slash if a directory - */ -#define APR_FILEPATH_TRUENAME 0x20 - -/** - * Extract the rootpath from the given filepath - * @param rootpath the root file path returned with APR_SUCCESS or APR_EINCOMPLETE - * @param filepath the pathname to parse for its root component - * @param flags the desired rules to apply, from - *
    - *      APR_FILEPATH_NATIVE    Use native path seperators (e.g. '\' on Win32)
    - *      APR_FILEPATH_TRUENAME  Tests that the root exists, and makes it proper
    - * 
    - * @param p the pool to allocate the new path string from - * @remark on return, filepath points to the first non-root character in the - * given filepath. In the simplest example, given a filepath of "/foo", - * returns the rootpath of "/" and filepath points at "foo". This is far - * more complex on other platforms, which will canonicalize the root form - * to a consistant format, given the APR_FILEPATH_TRUENAME flag, and also - * test for the validity of that root (e.g., that a drive d:/ or network - * share //machine/foovol/). - * The function returns APR_ERELATIVE if filepath isn't rooted (an - * error), APR_EINCOMPLETE if the root path is ambigious (but potentially - * legitimate, e.g. "/" on Windows is incomplete because it doesn't specify - * the drive letter), or APR_EBADPATH if the root is simply invalid. - * APR_SUCCESS is returned if filepath is an absolute path. - */ -APR_DECLARE(apr_status_t) apr_filepath_root(const char **rootpath, - const char **filepath, - apr_int32_t flags, - apr_pool_t *p); - -/** - * Merge additional file path onto the previously processed rootpath - * @param newpath the merged paths returned - * @param rootpath the root file path (NULL uses the current working path) - * @param addpath the path to add to the root path - * @param flags the desired APR_FILEPATH_ rules to apply when merging - * @param p the pool to allocate the new path string from - * @remark if the flag APR_FILEPATH_TRUENAME is given, and the addpath - * contains wildcard characters ('*', '?') on platforms that don't support - * such characters within filenames, the paths will be merged, but the - * result code will be APR_EPATHWILD, and all further segments will not - * reflect the true filenames including the wildcard and following segments. - */ -APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, - const char *rootpath, - const char *addpath, - apr_int32_t flags, - apr_pool_t *p); - -/** - * Split a search path into separate components - * @param pathelts the returned components of the search path - * @param liststr the search path (e.g., getenv("PATH")) - * @param p the pool to allocate the array and path components from - * @remark empty path componenta do not become part of @a pathelts. - * @remark the path separator in @a liststr is system specific; - * e.g., ':' on Unix, ';' on Windows, etc. - */ -APR_DECLARE(apr_status_t) apr_filepath_list_split(apr_array_header_t **pathelts, - const char *liststr, - apr_pool_t *p); - -/** - * Merge a list of search path components into a single search path - * @param liststr the returned search path; may be NULL if @a pathelts is empty - * @param pathelts the components of the search path - * @param p the pool to allocate the search path from - * @remark emtpy strings in the source array are ignored. - * @remark the path separator in @a liststr is system specific; - * e.g., ':' on Unix, ';' on Windows, etc. - */ -APR_DECLARE(apr_status_t) apr_filepath_list_merge(char **liststr, - apr_array_header_t *pathelts, - apr_pool_t *p); - -/** - * Return the default file path (for relative file names) - * @param path the default path string returned - * @param flags optional flag APR_FILEPATH_NATIVE to retrieve the - * default file path in os-native format. - * @param p the pool to allocate the default path string from - */ -APR_DECLARE(apr_status_t) apr_filepath_get(char **path, apr_int32_t flags, - apr_pool_t *p); - -/** - * Set the default file path (for relative file names) - * @param path the default path returned - * @param p the pool to allocate any working storage - */ -APR_DECLARE(apr_status_t) apr_filepath_set(const char *path, apr_pool_t *p); - -/** The FilePath character encoding is unknown */ -#define APR_FILEPATH_ENCODING_UNKNOWN 0 - -/** The FilePath character encoding is locale-dependent */ -#define APR_FILEPATH_ENCODING_LOCALE 1 - -/** The FilePath character encoding is UTF-8 */ -#define APR_FILEPATH_ENCODING_UTF8 2 - -/** - * Determine the encoding used internally by the FilePath functions - * @param style points to a variable which receives the encoding style flag - * @param p the pool to allocate any working storage - * @remark Use @c apr_os_locale_encoding and/or @c apr_os_default_encoding - * to get the name of the path encoding if it's not UTF-8. - */ -APR_DECLARE(apr_status_t) apr_filepath_encoding(int *style, apr_pool_t *p); -/** @} */ - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ! APR_FILE_INFO_H */ diff --git a/libs/apr/include/apr_file_io.h b/libs/apr/include/apr_file_io.h deleted file mode 100644 index ca997514..00000000 --- a/libs/apr/include/apr_file_io.h +++ /dev/null @@ -1,945 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_FILE_IO_H -#define APR_FILE_IO_H - -/** - * @file apr_file_io.h - * @brief APR File I/O Handling - */ - -#include "apr.h" -#include "apr_pools.h" -#include "apr_time.h" -#include "apr_errno.h" -#include "apr_file_info.h" -#include "apr_inherit.h" - -#define APR_WANT_STDIO /**< for SEEK_* */ -#define APR_WANT_IOVEC /**< for apr_file_writev */ -#include "apr_want.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup apr_file_io File I/O Handling Functions - * @ingroup APR - * @{ - */ - -/** - * @defgroup apr_file_open_flags File Open Flags/Routines - * @{ - */ - -/* Note to implementors: Values in the range 0x00100000--0x80000000 - are reserved for platform-specific values. */ - -#define APR_FOPEN_READ 0x00001 /**< Open the file for reading */ -#define APR_FOPEN_WRITE 0x00002 /**< Open the file for writing */ -#define APR_FOPEN_CREATE 0x00004 /**< Create the file if not there */ -#define APR_FOPEN_APPEND 0x00008 /**< Append to the end of the file */ -#define APR_FOPEN_TRUNCATE 0x00010 /**< Open the file and truncate - to 0 length */ -#define APR_FOPEN_BINARY 0x00020 /**< Open the file in binary mode */ -#define APR_FOPEN_EXCL 0x00040 /**< Open should fail if APR_CREATE - and file exists. */ -#define APR_FOPEN_BUFFERED 0x00080 /**< Open the file for buffered I/O */ -#define APR_FOPEN_DELONCLOSE 0x00100 /**< Delete the file after close */ -#define APR_FOPEN_XTHREAD 0x00200 /**< Platform dependent tag to open - the file for use across multiple - threads */ -#define APR_FOPEN_SHARELOCK 0x00400 /**< Platform dependent support for - higher level locked read/write - access to support writes across - process/machines */ -#define APR_FOPEN_NOCLEANUP 0x00800 /**< Do not register a cleanup - when the file is opened */ -#define APR_FOPEN_SENDFILE_ENABLED 0x01000 /**< Advisory flag that this - file should support - apr_socket_sendfile operation */ -#define APR_FOPEN_LARGEFILE 0x04000 /**< Platform dependent flag to enable - * large file support, see WARNING below - */ -#define APR_FOPEN_SPARSE 0x08000 /**< Platform dependent flag to enable - * sparse file support, see WARNING below - */ - -/* backcompat */ -#define APR_READ APR_FOPEN_READ /**< @deprecated @see APR_FOPEN_READ */ -#define APR_WRITE APR_FOPEN_WRITE /**< @deprecated @see APR_FOPEN_WRITE */ -#define APR_CREATE APR_FOPEN_CREATE /**< @deprecated @see APR_FOPEN_CREATE */ -#define APR_APPEND APR_FOPEN_APPEND /**< @deprecated @see APR_FOPEN_APPEND */ -#define APR_TRUNCATE APR_FOPEN_TRUNCATE /**< @deprecated @see APR_FOPEN_TRUNCATE */ -#define APR_BINARY APR_FOPEN_BINARY /**< @deprecated @see APR_FOPEN_BINARY */ -#define APR_EXCL APR_FOPEN_EXCL /**< @deprecated @see APR_FOPEN_EXCL */ -#define APR_BUFFERED APR_FOPEN_BUFFERED /**< @deprecated @see APR_FOPEN_BUFFERED */ -#define APR_DELONCLOSE APR_FOPEN_DELONCLOSE /**< @deprecated @see APR_FOPEN_DELONCLOSE */ -#define APR_XTHREAD APR_FOPEN_XTHREAD /**< @deprecated @see APR_FOPEN_XTHREAD */ -#define APR_SHARELOCK APR_FOPEN_SHARELOCK /**< @deprecated @see APR_FOPEN_SHARELOCK */ -#define APR_FILE_NOCLEANUP APR_FOPEN_NOCLEANUP /**< @deprecated @see APR_FOPEN_NOCLEANUP */ -#define APR_SENDFILE_ENABLED APR_FOPEN_SENDFILE_ENABLED /**< @deprecated @see APR_FOPEN_SENDFILE_ENABLED */ -#define APR_LARGEFILE APR_FOPEN_LARGEFILE /**< @deprecated @see APR_FOPEN_LARGEFILE */ - -/** @warning APR_FOPEN_LARGEFILE flag only has effect on some - * platforms where sizeof(apr_off_t) == 4. Where implemented, it - * allows opening and writing to a file which exceeds the size which - * can be represented by apr_off_t (2 gigabytes). When a file's size - * does exceed 2Gb, apr_file_info_get() will fail with an error on the - * descriptor, likewise apr_stat()/apr_lstat() will fail on the - * filename. apr_dir_read() will fail with APR_INCOMPLETE on a - * directory entry for a large file depending on the particular - * APR_FINFO_* flags. Generally, it is not recommended to use this - * flag. - * - * @warning APR_FOPEN_SPARSE may, depending on platform, convert a - * normal file to a sparse file. Some applications may be unable - * to decipher a sparse file, so it's critical that the sparse file - * flag should only be used for files accessed only by APR or other - * applications known to be able to decipher them. APR does not - * guarantee that it will compress the file into sparse segments - * if it was previously created and written without the sparse flag. - * On platforms which do not understand, or on file systems which - * cannot handle sparse files, the flag is ignored by apr_file_open(). - */ - -/** @} */ - -/** - * @defgroup apr_file_seek_flags File Seek Flags - * @{ - */ - -/* flags for apr_file_seek */ -/** Set the file position */ -#define APR_SET SEEK_SET -/** Current */ -#define APR_CUR SEEK_CUR -/** Go to end of file */ -#define APR_END SEEK_END -/** @} */ - -/** - * @defgroup apr_file_attrs_set_flags File Attribute Flags - * @{ - */ - -/* flags for apr_file_attrs_set */ -#define APR_FILE_ATTR_READONLY 0x01 /**< File is read-only */ -#define APR_FILE_ATTR_EXECUTABLE 0x02 /**< File is executable */ -#define APR_FILE_ATTR_HIDDEN 0x04 /**< File is hidden */ -/** @} */ - -/** - * @defgroup apr_file_writev{_full} max iovec size - * @{ - */ -#if defined(DOXYGEN) -#define APR_MAX_IOVEC_SIZE 1024 /**< System dependent maximum - size of an iovec array */ -#elif defined(IOV_MAX) -#define APR_MAX_IOVEC_SIZE IOV_MAX -#elif defined(MAX_IOVEC) -#define APR_MAX_IOVEC_SIZE MAX_IOVEC -#else -#define APR_MAX_IOVEC_SIZE 1024 -#endif -/** @} */ - -/** File attributes */ -typedef apr_uint32_t apr_fileattrs_t; - -/** Type to pass as whence argument to apr_file_seek. */ -typedef int apr_seek_where_t; - -/** - * Structure for referencing files. - */ -typedef struct apr_file_t apr_file_t; - -/* File lock types/flags */ -/** - * @defgroup apr_file_lock_types File Lock Types - * @{ - */ - -#define APR_FLOCK_SHARED 1 /**< Shared lock. More than one process - or thread can hold a shared lock - at any given time. Essentially, - this is a "read lock", preventing - writers from establishing an - exclusive lock. */ -#define APR_FLOCK_EXCLUSIVE 2 /**< Exclusive lock. Only one process - may hold an exclusive lock at any - given time. This is analogous to - a "write lock". */ - -#define APR_FLOCK_TYPEMASK 0x000F /**< mask to extract lock type */ -#define APR_FLOCK_NONBLOCK 0x0010 /**< do not block while acquiring the - file lock */ -/** @} */ - -/** - * Open the specified file. - * @param newf The opened file descriptor. - * @param fname The full path to the file (using / on all systems) - * @param flag Or'ed value of: - *
    - *         APR_READ              open for reading
    - *         APR_WRITE             open for writing
    - *         APR_CREATE            create the file if not there
    - *         APR_APPEND            file ptr is set to end prior to all writes
    - *         APR_TRUNCATE          set length to zero if file exists
    - *         APR_BINARY            not a text file (This flag is ignored on 
    - *                               UNIX because it has no meaning)
    - *         APR_BUFFERED          buffer the data.  Default is non-buffered
    - *         APR_EXCL              return error if APR_CREATE and file exists
    - *         APR_DELONCLOSE        delete the file after closing.
    - *         APR_XTHREAD           Platform dependent tag to open the file
    - *                               for use across multiple threads
    - *         APR_SHARELOCK         Platform dependent support for higher
    - *                               level locked read/write access to support
    - *                               writes across process/machines
    - *         APR_FILE_NOCLEANUP    Do not register a cleanup with the pool 
    - *                               passed in on the pool argument (see below).
    - *                               The apr_os_file_t handle in apr_file_t will not
    - *                               be closed when the pool is destroyed.
    - *         APR_SENDFILE_ENABLED  Open with appropriate platform semantics
    - *                               for sendfile operations.  Advisory only,
    - *                               apr_socket_sendfile does not check this flag.
    - * 
    - * @param perm Access permissions for file. - * @param pool The pool to use. - * @remark If perm is APR_OS_DEFAULT and the file is being created, - * appropriate default permissions will be used. - * @remark By default, the returned file descriptor will not be - * inherited by child processes created by apr_proc_create(). This - * can be changed using apr_file_inherit_set(). - */ -APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **newf, const char *fname, - apr_int32_t flag, apr_fileperms_t perm, - apr_pool_t *pool); - -/** - * Close the specified file. - * @param file The file descriptor to close. - */ -APR_DECLARE(apr_status_t) apr_file_close(apr_file_t *file); - -/** - * Delete the specified file. - * @param path The full path to the file (using / on all systems) - * @param pool The pool to use. - * @remark If the file is open, it won't be removed until all - * instances are closed. - */ -APR_DECLARE(apr_status_t) apr_file_remove(const char *path, apr_pool_t *pool); - -/** - * Rename the specified file. - * @param from_path The full path to the original file (using / on all systems) - * @param to_path The full path to the new file (using / on all systems) - * @param pool The pool to use. - * @warning If a file exists at the new location, then it will be - * overwritten. Moving files or directories across devices may not be - * possible. - */ -APR_DECLARE(apr_status_t) apr_file_rename(const char *from_path, - const char *to_path, - apr_pool_t *pool); - -/** - * Create a hard link to the specified file. - * @param from_path The full path to the original file (using / on all systems) - * @param to_path The full path to the new file (using / on all systems) - * @remark Both files must reside on the same device. - */ -APR_DECLARE(apr_status_t) apr_file_link(const char *from_path, - const char *to_path); - -/** - * Copy the specified file to another file. - * @param from_path The full path to the original file (using / on all systems) - * @param to_path The full path to the new file (using / on all systems) - * @param perms Access permissions for the new file if it is created. - * In place of the usual or'd combination of file permissions, the - * value APR_FILE_SOURCE_PERMS may be given, in which case the source - * file's permissions are copied. - * @param pool The pool to use. - * @remark The new file does not need to exist, it will be created if required. - * @warning If the new file already exists, its contents will be overwritten. - */ -APR_DECLARE(apr_status_t) apr_file_copy(const char *from_path, - const char *to_path, - apr_fileperms_t perms, - apr_pool_t *pool); - -/** - * Append the specified file to another file. - * @param from_path The full path to the source file (use / on all systems) - * @param to_path The full path to the destination file (use / on all systems) - * @param perms Access permissions for the destination file if it is created. - * In place of the usual or'd combination of file permissions, the - * value APR_FILE_SOURCE_PERMS may be given, in which case the source - * file's permissions are copied. - * @param pool The pool to use. - * @remark The new file does not need to exist, it will be created if required. - */ -APR_DECLARE(apr_status_t) apr_file_append(const char *from_path, - const char *to_path, - apr_fileperms_t perms, - apr_pool_t *pool); - -/** - * Are we at the end of the file - * @param fptr The apr file we are testing. - * @remark Returns APR_EOF if we are at the end of file, APR_SUCCESS otherwise. - */ -APR_DECLARE(apr_status_t) apr_file_eof(apr_file_t *fptr); - -/** - * Open standard error as an apr file pointer. - * @param thefile The apr file to use as stderr. - * @param pool The pool to allocate the file out of. - * - * @remark The only reason that the apr_file_open_std* functions exist - * is that you may not always have a stderr/out/in on Windows. This - * is generally a problem with newer versions of Windows and services. - * - * @remark The other problem is that the C library functions generally work - * differently on Windows and Unix. So, by using apr_file_open_std* - * functions, you can get a handle to an APR struct that works with - * the APR functions which are supposed to work identically on all - * platforms. - */ -APR_DECLARE(apr_status_t) apr_file_open_stderr(apr_file_t **thefile, - apr_pool_t *pool); - -/** - * open standard output as an apr file pointer. - * @param thefile The apr file to use as stdout. - * @param pool The pool to allocate the file out of. - * - * @remark See remarks for apr_file_open_stderr. - */ -APR_DECLARE(apr_status_t) apr_file_open_stdout(apr_file_t **thefile, - apr_pool_t *pool); - -/** - * open standard input as an apr file pointer. - * @param thefile The apr file to use as stdin. - * @param pool The pool to allocate the file out of. - * - * @remark See remarks for apr_file_open_stderr. - */ -APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile, - apr_pool_t *pool); - -/** - * open standard error as an apr file pointer, with flags. - * @param thefile The apr file to use as stderr. - * @param flags The flags to open the file with. Only the APR_EXCL, - * APR_BUFFERED, APR_XTHREAD, APR_SHARELOCK, - * APR_SENDFILE_ENABLED and APR_LARGEFILE flags should - * be used. The APR_WRITE flag will be set unconditionally. - * @param pool The pool to allocate the file out of. - * - * @remark See remarks for apr_file_open_stderr. - */ -APR_DECLARE(apr_status_t) apr_file_open_flags_stderr(apr_file_t **thefile, - apr_int32_t flags, - apr_pool_t *pool); - -/** - * open standard output as an apr file pointer, with flags. - * @param thefile The apr file to use as stdout. - * @param flags The flags to open the file with. Only the APR_EXCL, - * APR_BUFFERED, APR_XTHREAD, APR_SHARELOCK, - * APR_SENDFILE_ENABLED and APR_LARGEFILE flags should - * be used. The APR_WRITE flag will be set unconditionally. - * @param pool The pool to allocate the file out of. - * - * @remark See remarks for apr_file_open_stderr. - */ -APR_DECLARE(apr_status_t) apr_file_open_flags_stdout(apr_file_t **thefile, - apr_int32_t flags, - apr_pool_t *pool); - -/** - * open standard input as an apr file pointer, with flags. - * @param thefile The apr file to use as stdin. - * @param flags The flags to open the file with. Only the APR_EXCL, - * APR_BUFFERED, APR_XTHREAD, APR_SHARELOCK, - * APR_SENDFILE_ENABLED and APR_LARGEFILE flags should - * be used. The APR_READ flag will be set unconditionally. - * @param pool The pool to allocate the file out of. - * - * @remark See remarks for apr_file_open_stderr. - */ -APR_DECLARE(apr_status_t) apr_file_open_flags_stdin(apr_file_t **thefile, - apr_int32_t flags, - apr_pool_t *pool); - -/** - * Read data from the specified file. - * @param thefile The file descriptor to read from. - * @param buf The buffer to store the data to. - * @param nbytes On entry, the number of bytes to read; on exit, the number - * of bytes read. - * - * @remark apr_file_read will read up to the specified number of - * bytes, but never more. If there isn't enough data to fill that - * number of bytes, all of the available data is read. The third - * argument is modified to reflect the number of bytes read. If a - * char was put back into the stream via ungetc, it will be the first - * character returned. - * - * @remark It is not possible for both bytes to be read and an APR_EOF - * or other error to be returned. APR_EINTR is never returned. - */ -APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, - apr_size_t *nbytes); - -/** - * Write data to the specified file. - * @param thefile The file descriptor to write to. - * @param buf The buffer which contains the data. - * @param nbytes On entry, the number of bytes to write; on exit, the number - * of bytes written. - * - * @remark apr_file_write will write up to the specified number of - * bytes, but never more. If the OS cannot write that many bytes, it - * will write as many as it can. The third argument is modified to - * reflect the * number of bytes written. - * - * @remark It is possible for both bytes to be written and an error to - * be returned. APR_EINTR is never returned. - */ -APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, - apr_size_t *nbytes); - -/** - * Write data from iovec array to the specified file. - * @param thefile The file descriptor to write to. - * @param vec The array from which to get the data to write to the file. - * @param nvec The number of elements in the struct iovec array. This must - * be smaller than APR_MAX_IOVEC_SIZE. If it isn't, the function - * will fail with APR_EINVAL. - * @param nbytes The number of bytes written. - * - * @remark It is possible for both bytes to be written and an error to - * be returned. APR_EINTR is never returned. - * - * @remark apr_file_writev is available even if the underlying - * operating system doesn't provide writev(). - */ -APR_DECLARE(apr_status_t) apr_file_writev(apr_file_t *thefile, - const struct iovec *vec, - apr_size_t nvec, apr_size_t *nbytes); - -/** - * Read data from the specified file, ensuring that the buffer is filled - * before returning. - * @param thefile The file descriptor to read from. - * @param buf The buffer to store the data to. - * @param nbytes The number of bytes to read. - * @param bytes_read If non-NULL, this will contain the number of bytes read. - * - * @remark apr_file_read will read up to the specified number of - * bytes, but never more. If there isn't enough data to fill that - * number of bytes, then the process/thread will block until it is - * available or EOF is reached. If a char was put back into the - * stream via ungetc, it will be the first character returned. - * - * @remark It is possible for both bytes to be read and an error to be - * returned. And if *bytes_read is less than nbytes, an accompanying - * error is _always_ returned. - * - * @remark APR_EINTR is never returned. - */ -APR_DECLARE(apr_status_t) apr_file_read_full(apr_file_t *thefile, void *buf, - apr_size_t nbytes, - apr_size_t *bytes_read); - -/** - * Write data to the specified file, ensuring that all of the data is - * written before returning. - * @param thefile The file descriptor to write to. - * @param buf The buffer which contains the data. - * @param nbytes The number of bytes to write. - * @param bytes_written If non-NULL, set to the number of bytes written. - * - * @remark apr_file_write will write up to the specified number of - * bytes, but never more. If the OS cannot write that many bytes, the - * process/thread will block until they can be written. Exceptional - * error such as "out of space" or "pipe closed" will terminate with - * an error. - * - * @remark It is possible for both bytes to be written and an error to - * be returned. And if *bytes_written is less than nbytes, an - * accompanying error is _always_ returned. - * - * @remark APR_EINTR is never returned. - */ -APR_DECLARE(apr_status_t) apr_file_write_full(apr_file_t *thefile, - const void *buf, - apr_size_t nbytes, - apr_size_t *bytes_written); - - -/** - * Write data from iovec array to the specified file, ensuring that all of the - * data is written before returning. - * @param thefile The file descriptor to write to. - * @param vec The array from which to get the data to write to the file. - * @param nvec The number of elements in the struct iovec array. This must - * be smaller than APR_MAX_IOVEC_SIZE. If it isn't, the function - * will fail with APR_EINVAL. - * @param nbytes The number of bytes written. - * - * @remark apr_file_writev_full is available even if the underlying - * operating system doesn't provide writev(). - */ -APR_DECLARE(apr_status_t) apr_file_writev_full(apr_file_t *thefile, - const struct iovec *vec, - apr_size_t nvec, - apr_size_t *nbytes); -/** - * Write a character into the specified file. - * @param ch The character to write. - * @param thefile The file descriptor to write to - */ -APR_DECLARE(apr_status_t) apr_file_putc(char ch, apr_file_t *thefile); - -/** - * Read a character from the specified file. - * @param ch The character to read into - * @param thefile The file descriptor to read from - */ -APR_DECLARE(apr_status_t) apr_file_getc(char *ch, apr_file_t *thefile); - -/** - * Put a character back onto a specified stream. - * @param ch The character to write. - * @param thefile The file descriptor to write to - */ -APR_DECLARE(apr_status_t) apr_file_ungetc(char ch, apr_file_t *thefile); - -/** - * Read a line from the specified file - * @param str The buffer to store the string in. - * @param len The length of the string - * @param thefile The file descriptor to read from - * @remark The buffer will be NUL-terminated if any characters are stored. - * The newline at the end of the line will not be stripped. - */ -APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, - apr_file_t *thefile); - -/** - * Write the string into the specified file. - * @param str The string to write. - * @param thefile The file descriptor to write to - */ -APR_DECLARE(apr_status_t) apr_file_puts(const char *str, apr_file_t *thefile); - -/** - * Flush the file's buffer. - * @param thefile The file descriptor to flush - */ -APR_DECLARE(apr_status_t) apr_file_flush(apr_file_t *thefile); - -/** - * Transfer all file modified data and metadata to disk. - * @param thefile The file descriptor to sync - */ -APR_DECLARE(apr_status_t) apr_file_sync(apr_file_t *thefile); - -/** - * Transfer all file modified data to disk. - * @param thefile The file descriptor to sync - */ -APR_DECLARE(apr_status_t) apr_file_datasync(apr_file_t *thefile); - -/** - * Duplicate the specified file descriptor. - * @param new_file The structure to duplicate into. - * @param old_file The file to duplicate. - * @param p The pool to use for the new file. - * @remark *new_file must point to a valid apr_file_t, or point to NULL. - */ -APR_DECLARE(apr_status_t) apr_file_dup(apr_file_t **new_file, - apr_file_t *old_file, - apr_pool_t *p); - -/** - * Duplicate the specified file descriptor and close the original - * @param new_file The old file that is to be closed and reused - * @param old_file The file to duplicate - * @param p The pool to use for the new file - * - * @remark new_file MUST point at a valid apr_file_t. It cannot be NULL. - */ -APR_DECLARE(apr_status_t) apr_file_dup2(apr_file_t *new_file, - apr_file_t *old_file, - apr_pool_t *p); - -/** - * Move the specified file descriptor to a new pool - * @param new_file Pointer in which to return the new apr_file_t - * @param old_file The file to move - * @param p The pool to which the descriptor is to be moved - * @remark Unlike apr_file_dup2(), this function doesn't do an - * OS dup() operation on the underlying descriptor; it just - * moves the descriptor's apr_file_t wrapper to a new pool. - * @remark The new pool need not be an ancestor of old_file's pool. - * @remark After calling this function, old_file may not be used - */ -APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file, - apr_file_t *old_file, - apr_pool_t *p); - -/** - * Give the specified apr file handle a new buffer - * @param thefile The file handle that is to be modified - * @param buffer The buffer - * @param bufsize The size of the buffer - * @remark It is possible to add a buffer to previously unbuffered - * file handles, the APR_BUFFERED flag will be added to - * the file handle's flags. Likewise, with buffer=NULL and - * bufsize=0 arguments it is possible to make a previously - * buffered file handle unbuffered. - */ -APR_DECLARE(apr_status_t) apr_file_buffer_set(apr_file_t *thefile, - char * buffer, - apr_size_t bufsize); - -/** - * Get the size of any buffer for the specified apr file handle - * @param thefile The file handle - */ -APR_DECLARE(apr_size_t) apr_file_buffer_size_get(apr_file_t *thefile); - -/** - * Move the read/write file offset to a specified byte within a file. - * @param thefile The file descriptor - * @param where How to move the pointer, one of: - *
    - *            APR_SET  --  set the offset to offset
    - *            APR_CUR  --  add the offset to the current position 
    - *            APR_END  --  add the offset to the current file size 
    - * 
    - * @param offset The offset to move the pointer to. - * @remark The third argument is modified to be the offset the pointer - was actually moved to. - */ -APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile, - apr_seek_where_t where, - apr_off_t *offset); - -/** - * Create an anonymous pipe. - * @param in The newly created pipe's file for reading. - * @param out The newly created pipe's file for writing. - * @param pool The pool to operate on. - * @remark By default, the returned file descriptors will be inherited - * by child processes created using apr_proc_create(). This can be - * changed using apr_file_inherit_unset(). - * @bug Some platforms cannot toggle between blocking and nonblocking, - * and when passing a pipe as a standard handle to an application which - * does not expect it, a non-blocking stream will fluxor the client app. - * @deprecated @see apr_file_pipe_create_ex - */ -APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, - apr_file_t **out, - apr_pool_t *pool); - -/** - * Create an anonymous pipe which portably supports async timeout options. - * @param in The newly created pipe's file for reading. - * @param out The newly created pipe's file for writing. - * @param blocking one of these values defined in apr_thread_proc.h; - * @param pool The pool to operate on. - *
    - *       APR_FULL_BLOCK
    - *       APR_READ_BLOCK
    - *       APR_WRITE_BLOCK
    - *       APR_FULL_NONBLOCK
    - * 
    - * @remark By default, the returned file descriptors will be inherited - * by child processes created using apr_proc_create(). This can be - * changed using apr_file_inherit_unset(). - * @remark Some platforms cannot toggle between blocking and nonblocking, - * and when passing a pipe as a standard handle to an application which - * does not expect it, a non-blocking stream will fluxor the client app. - * Use this function rather than apr_file_pipe_create to create pipes - * where one or both ends require non-blocking semantics. - */ -APR_DECLARE(apr_status_t) apr_file_pipe_create_ex(apr_file_t **in, - apr_file_t **out, - apr_int32_t blocking, - apr_pool_t *pool); - -/** - * Create a named pipe. - * @param filename The filename of the named pipe - * @param perm The permissions for the newly created pipe. - * @param pool The pool to operate on. - */ -APR_DECLARE(apr_status_t) apr_file_namedpipe_create(const char *filename, - apr_fileperms_t perm, - apr_pool_t *pool); - -/** - * Get the timeout value for a pipe or manipulate the blocking state. - * @param thepipe The pipe we are getting a timeout for. - * @param timeout The current timeout value in microseconds. - */ -APR_DECLARE(apr_status_t) apr_file_pipe_timeout_get(apr_file_t *thepipe, - apr_interval_time_t *timeout); - -/** - * Set the timeout value for a pipe or manipulate the blocking state. - * @param thepipe The pipe we are setting a timeout on. - * @param timeout The timeout value in microseconds. Values < 0 mean wait - * forever, 0 means do not wait at all. - */ -APR_DECLARE(apr_status_t) apr_file_pipe_timeout_set(apr_file_t *thepipe, - apr_interval_time_t timeout); - -/** file (un)locking functions. */ - -/** - * Establish a lock on the specified, open file. The lock may be advisory - * or mandatory, at the discretion of the platform. The lock applies to - * the file as a whole, rather than a specific range. Locks are established - * on a per-thread/process basis; a second lock by the same thread will not - * block. - * @param thefile The file to lock. - * @param type The type of lock to establish on the file. - */ -APR_DECLARE(apr_status_t) apr_file_lock(apr_file_t *thefile, int type); - -/** - * Remove any outstanding locks on the file. - * @param thefile The file to unlock. - */ -APR_DECLARE(apr_status_t) apr_file_unlock(apr_file_t *thefile); - -/**accessor and general file_io functions. */ - -/** - * return the file name of the current file. - * @param new_path The path of the file. - * @param thefile The currently open file. - */ -APR_DECLARE(apr_status_t) apr_file_name_get(const char **new_path, - apr_file_t *thefile); - -/** - * Return the data associated with the current file. - * @param data The user data associated with the file. - * @param key The key to use for retrieving data associated with this file. - * @param file The currently open file. - */ -APR_DECLARE(apr_status_t) apr_file_data_get(void **data, const char *key, - apr_file_t *file); - -/** - * Set the data associated with the current file. - * @param file The currently open file. - * @param data The user data to associate with the file. - * @param key The key to use for associating data with the file. - * @param cleanup The cleanup routine to use when the file is destroyed. - */ -APR_DECLARE(apr_status_t) apr_file_data_set(apr_file_t *file, void *data, - const char *key, - apr_status_t (*cleanup)(void *)); - -/** - * Write a string to a file using a printf format. - * @param fptr The file to write to. - * @param format The format string - * @param ... The values to substitute in the format string - * @return The number of bytes written - */ -APR_DECLARE_NONSTD(int) apr_file_printf(apr_file_t *fptr, - const char *format, ...) - __attribute__((format(printf,2,3))); - -/** - * set the specified file's permission bits. - * @param fname The file (name) to apply the permissions to. - * @param perms The permission bits to apply to the file. - * - * @warning Some platforms may not be able to apply all of the - * available permission bits; APR_INCOMPLETE will be returned if some - * permissions are specified which could not be set. - * - * @warning Platforms which do not implement this feature will return - * APR_ENOTIMPL. - */ -APR_DECLARE(apr_status_t) apr_file_perms_set(const char *fname, - apr_fileperms_t perms); - -/** - * Set attributes of the specified file. - * @param fname The full path to the file (using / on all systems) - * @param attributes Or'd combination of - *
    - *            APR_FILE_ATTR_READONLY   - make the file readonly
    - *            APR_FILE_ATTR_EXECUTABLE - make the file executable
    - *            APR_FILE_ATTR_HIDDEN     - make the file hidden
    - * 
    - * @param attr_mask Mask of valid bits in attributes. - * @param pool the pool to use. - * @remark This function should be used in preference to explicit manipulation - * of the file permissions, because the operations to provide these - * attributes are platform specific and may involve more than simply - * setting permission bits. - * @warning Platforms which do not implement this feature will return - * APR_ENOTIMPL. - */ -APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, - apr_fileattrs_t attributes, - apr_fileattrs_t attr_mask, - apr_pool_t *pool); - -/** - * Set the mtime of the specified file. - * @param fname The full path to the file (using / on all systems) - * @param mtime The mtime to apply to the file. - * @param pool The pool to use. - * @warning Platforms which do not implement this feature will return - * APR_ENOTIMPL. - */ -APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname, - apr_time_t mtime, - apr_pool_t *pool); - -/** - * Create a new directory on the file system. - * @param path the path for the directory to be created. (use / on all systems) - * @param perm Permissions for the new directory. - * @param pool the pool to use. - */ -APR_DECLARE(apr_status_t) apr_dir_make(const char *path, apr_fileperms_t perm, - apr_pool_t *pool); - -/** Creates a new directory on the file system, but behaves like - * 'mkdir -p'. Creates intermediate directories as required. No error - * will be reported if PATH already exists. - * @param path the path for the directory to be created. (use / on all systems) - * @param perm Permissions for the new directory. - * @param pool the pool to use. - */ -APR_DECLARE(apr_status_t) apr_dir_make_recursive(const char *path, - apr_fileperms_t perm, - apr_pool_t *pool); - -/** - * Remove directory from the file system. - * @param path the path for the directory to be removed. (use / on all systems) - * @param pool the pool to use. - * @remark Removing a directory which is in-use (e.g., the current working - * directory, or during apr_dir_read, or with an open file) is not portable. - */ -APR_DECLARE(apr_status_t) apr_dir_remove(const char *path, apr_pool_t *pool); - -/** - * get the specified file's stats. - * @param finfo Where to store the information about the file. - * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ values - * @param thefile The file to get information about. - */ -APR_DECLARE(apr_status_t) apr_file_info_get(apr_finfo_t *finfo, - apr_int32_t wanted, - apr_file_t *thefile); - - -/** - * Truncate the file's length to the specified offset - * @param fp The file to truncate - * @param offset The offset to truncate to. - * @remark The read/write file offset is repositioned to offset. - */ -APR_DECLARE(apr_status_t) apr_file_trunc(apr_file_t *fp, apr_off_t offset); - -/** - * Retrieve the flags that were passed into apr_file_open() - * when the file was opened. - * @return apr_int32_t the flags - */ -APR_DECLARE(apr_int32_t) apr_file_flags_get(apr_file_t *f); - -/** - * Get the pool used by the file. - */ -APR_POOL_DECLARE_ACCESSOR(file); - -/** - * Set a file to be inherited by child processes. - * - */ -APR_DECLARE_INHERIT_SET(file); - -/** - * Unset a file from being inherited by child processes. - */ -APR_DECLARE_INHERIT_UNSET(file); - -/** - * Open a temporary file - * @param fp The apr file to use as a temporary file. - * @param templ The template to use when creating a temp file. - * @param flags The flags to open the file with. If this is zero, - * the file is opened with - * APR_CREATE | APR_READ | APR_WRITE | APR_EXCL | APR_DELONCLOSE - * @param p The pool to allocate the file out of. - * @remark - * This function generates a unique temporary file name from template. - * The last six characters of template must be XXXXXX and these are replaced - * with a string that makes the filename unique. Since it will be modified, - * template must not be a string constant, but should be declared as a character - * array. - * - */ -APR_DECLARE(apr_status_t) apr_file_mktemp(apr_file_t **fp, char *templ, - apr_int32_t flags, apr_pool_t *p); - - -/** - * Find an existing directory suitable as a temporary storage location. - * @param temp_dir The temp directory. - * @param p The pool to use for any necessary allocations. - * @remark - * This function uses an algorithm to search for a directory that an - * an application can use for temporary storage. - * - */ -APR_DECLARE(apr_status_t) apr_temp_dir_get(const char **temp_dir, - apr_pool_t *p); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ! APR_FILE_IO_H */ diff --git a/libs/apr/include/apr_fnmatch.h b/libs/apr/include/apr_fnmatch.h deleted file mode 100644 index ef6d0b25..00000000 --- a/libs/apr/include/apr_fnmatch.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)fnmatch.h 8.1 (Berkeley) 6/2/93 - */ - -/* This file has been modified by the Apache Software Foundation. */ -#ifndef _APR_FNMATCH_H_ -#define _APR_FNMATCH_H_ - -/** - * @file apr_fnmatch.h - * @brief APR FNMatch Functions - */ - -#include "apr_errno.h" -#include "apr_tables.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup apr_fnmatch Filename Matching Functions - * @ingroup APR - * @{ - */ - -#define APR_FNM_NOMATCH 1 /**< Match failed. */ - -#define APR_FNM_NOESCAPE 0x01 /**< Disable backslash escaping. */ -#define APR_FNM_PATHNAME 0x02 /**< Slash must be matched by slash. */ -#define APR_FNM_PERIOD 0x04 /**< Period must be matched by period. */ -#define APR_FNM_CASE_BLIND 0x08 /**< Compare characters case-insensitively. - * @remark This flag is an Apache addition - */ - -/** - * Try to match the string to the given pattern, return APR_SUCCESS if - * match, else return APR_FNM_NOMATCH. Note that there is no such thing as - * an illegal pattern. - * - * With all flags unset, a pattern is interpreted as such: - * - * PATTERN: Backslash followed by any character, including another - * backslash.
    - * MATCHES: That character exactly. - * - *

    - * PATTERN: ?
    - * MATCHES: Any single character. - *

    - * - *

    - * PATTERN: *
    - * MATCHES: Any sequence of zero or more characters. (Note that multiple - * *s in a row are equivalent to one.) - * - * PATTERN: Any character other than \?*[ or a \ at the end of the pattern
    - * MATCHES: That character exactly. (Case sensitive.) - * - * PATTERN: [ followed by a class description followed by ]
    - * MATCHES: A single character described by the class description. - * (Never matches, if the class description reaches until the - * end of the string without a ].) If the first character of - * the class description is ^ or !, the sense of the description - * is reversed. The rest of the class description is a list of - * single characters or pairs of characters separated by -. Any - * of those characters can have a backslash in front of them, - * which is ignored; this lets you use the characters ] and - - * in the character class, as well as ^ and ! at the - * beginning. The pattern matches a single character if it - * is one of the listed characters or falls into one of the - * listed ranges (inclusive, case sensitive). Ranges with - * the first character larger than the second are legal but - * never match. Edge cases: [] never matches, and [^] and [!] - * always match without consuming a character. - * - * Note that these patterns attempt to match the entire string, not - * just find a substring matching the pattern. - * - * @param pattern The pattern to match to - * @param strings The string we are trying to match - * @param flags flags to use in the match. Bitwise OR of: - *

    - *              APR_FNM_NOESCAPE       Disable backslash escaping
    - *              APR_FNM_PATHNAME       Slash must be matched by slash
    - *              APR_FNM_PERIOD         Period must be matched by period
    - *              APR_FNM_CASE_BLIND     Compare characters case-insensitively.
    - * 
    - */ - -APR_DECLARE(apr_status_t) apr_fnmatch(const char *pattern, - const char *strings, int flags); - -/** - * Determine if the given pattern is a regular expression. - * @param pattern The pattern to search for glob characters. - * @return non-zero if pattern has any glob characters in it - */ -APR_DECLARE(int) apr_fnmatch_test(const char *pattern); - -/** - * Find all files that match a specified pattern. - * @param pattern The pattern to use for finding files. - * @param result Array to use when storing the results - * @param p The pool to use. - * @return non-zero if pattern has any glob characters in it - */ -APR_DECLARE(apr_status_t) apr_match_glob(const char *pattern, - apr_array_header_t **result, - apr_pool_t *p); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* !_APR_FNMATCH_H_ */ diff --git a/libs/apr/include/apr_general.h b/libs/apr/include/apr_general.h deleted file mode 100644 index 1ead8b66..00000000 --- a/libs/apr/include/apr_general.h +++ /dev/null @@ -1,243 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_GENERAL_H -#define APR_GENERAL_H - -/** - * @file apr_general.h - * This is collection of oddballs that didn't fit anywhere else, - * and might move to more appropriate headers with the release - * of APR 1.0. - * @brief APR Miscellaneous library routines - */ - -#include "apr.h" -#include "apr_pools.h" -#include "apr_errno.h" - -#if APR_HAVE_SIGNAL_H -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup apr_general Miscellaneous library routines - * @ingroup APR - * This is collection of oddballs that didn't fit anywhere else, - * and might move to more appropriate headers with the release - * of APR 1.0. - * @{ - */ - -/** FALSE */ -#ifndef FALSE -#define FALSE 0 -#endif -/** TRUE */ -#ifndef TRUE -#define TRUE (!FALSE) -#endif - -/** a space */ -#define APR_ASCII_BLANK '\040' -/** a carrige return */ -#define APR_ASCII_CR '\015' -/** a line feed */ -#define APR_ASCII_LF '\012' -/** a tab */ -#define APR_ASCII_TAB '\011' - -/** signal numbers typedef */ -typedef int apr_signum_t; - -/** - * Finding offsets of elements within structures. - * Taken from the X code... they've sweated portability of this stuff - * so we don't have to. Sigh... - * @param p_type pointer type name - * @param field data field within the structure pointed to - * @return offset - */ - -#if defined(CRAY) || (defined(__arm) && !defined(LINUX)) -#ifdef __STDC__ -#define APR_OFFSET(p_type,field) _Offsetof(p_type,field) -#else -#ifdef CRAY2 -#define APR_OFFSET(p_type,field) \ - (sizeof(int)*((unsigned int)&(((p_type)NULL)->field))) - -#else /* !CRAY2 */ - -#define APR_OFFSET(p_type,field) ((unsigned int)&(((p_type)NULL)->field)) - -#endif /* !CRAY2 */ -#endif /* __STDC__ */ -#else /* ! (CRAY || __arm) */ - -#define APR_OFFSET(p_type,field) \ - ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL))) - -#endif /* !CRAY */ - -/** - * Finding offsets of elements within structures. - * @param s_type structure type name - * @param field data field within the structure - * @return offset - */ -#if defined(offsetof) && !defined(__cplusplus) -#define APR_OFFSETOF(s_type,field) offsetof(s_type,field) -#else -#define APR_OFFSETOF(s_type,field) APR_OFFSET(s_type*,field) -#endif - -#ifndef DOXYGEN - -/* A couple of prototypes for functions in case some platform doesn't - * have it - */ -#if (!APR_HAVE_STRCASECMP) && (APR_HAVE_STRICMP) -#define strcasecmp(s1, s2) stricmp(s1, s2) -#elif (!APR_HAVE_STRCASECMP) -int strcasecmp(const char *a, const char *b); -#endif - -#if (!APR_HAVE_STRNCASECMP) && (APR_HAVE_STRNICMP) -#define strncasecmp(s1, s2, n) strnicmp(s1, s2, n) -#elif (!APR_HAVE_STRNCASECMP) -int strncasecmp(const char *a, const char *b, size_t n); -#endif - -#endif - -/** - * Alignment macros - */ - -/* APR_ALIGN() is only to be used to align on a power of 2 boundary */ -#define APR_ALIGN(size, boundary) \ - (((size) + ((boundary) - 1)) & ~((boundary) - 1)) - -/** Default alignment */ -#define APR_ALIGN_DEFAULT(size) APR_ALIGN(size, 8) - - -/** - * String and memory functions - */ - -/* APR_STRINGIFY is defined here, and also in apr_release.h, so wrap it */ -#ifndef APR_STRINGIFY -/** Properly quote a value as a string in the C preprocessor */ -#define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n) -/** Helper macro for APR_STRINGIFY */ -#define APR_STRINGIFY_HELPER(n) #n -#endif - -#if (!APR_HAVE_MEMMOVE) -#define memmove(a,b,c) bcopy(b,a,c) -#endif - -#if (!APR_HAVE_MEMCHR) -void *memchr(const void *s, int c, size_t n); -#endif - -/** @} */ - -/** - * @defgroup apr_library Library initialization and termination - * @{ - */ - -/** - * Setup any APR internal data structures. This MUST be the first function - * called for any APR library. It is safe to call apr_initialize several - * times as long as apr_terminate is called the same number of times. - * @remark See apr_app_initialize if this is an application, rather than - * a library consumer of apr. - */ -APR_DECLARE(apr_status_t) apr_initialize(void); - -/** - * Set up an application with normalized argc, argv (and optionally env) in - * order to deal with platform-specific oddities, such as Win32 services, - * code pages and signals. This must be the first function called for any - * APR program. - * @param argc Pointer to the argc that may be corrected - * @param argv Pointer to the argv that may be corrected - * @param env Pointer to the env that may be corrected, may be NULL - * @remark See apr_initialize if this is a library consumer of apr. - * Otherwise, this call is identical to apr_initialize, and must be closed - * with a call to apr_terminate at the end of program execution. - */ -APR_DECLARE(apr_status_t) apr_app_initialize(int *argc, - char const * const * *argv, - char const * const * *env); - -/** - * Tear down any APR internal data structures which aren't torn down - * automatically. apr_terminate must be called once for every call to - * apr_initialize() or apr_app_initialize(). - * @remark An APR program must call this function at termination once it - * has stopped using APR services. The APR developers suggest using - * atexit to ensure this is called. When using APR from a language - * other than C that has problems with the calling convention, use - * apr_terminate2() instead. - */ -APR_DECLARE_NONSTD(void) apr_terminate(void); - -/** - * Tear down any APR internal data structures which aren't torn down - * automatically, same as apr_terminate - * @remark An APR program must call either the apr_terminate or apr_terminate2 - * function once it it has finished using APR services. The APR - * developers suggest using atexit(apr_terminate) to ensure this is done. - * apr_terminate2 exists to allow non-c language apps to tear down apr, - * while apr_terminate is recommended from c language applications. - */ -APR_DECLARE(void) apr_terminate2(void); - -/** @} */ - -/** - * @defgroup apr_random Random Functions - * @{ - */ - -#if APR_HAS_RANDOM || defined(DOXYGEN) - -/* TODO: I'm not sure this is the best place to put this prototype...*/ -/** - * Generate random bytes. - * @param buf Buffer to fill with random bytes - * @param length Length of buffer in bytes - */ -APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char * buf, - apr_size_t length); - -#endif -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ! APR_GENERAL_H */ diff --git a/libs/apr/include/apr_getopt.h b/libs/apr/include/apr_getopt.h deleted file mode 100644 index 75ad5663..00000000 --- a/libs/apr/include/apr_getopt.h +++ /dev/null @@ -1,160 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_GETOPT_H -#define APR_GETOPT_H - -/** - * @file apr_getopt.h - * @brief APR Command Arguments (getopt) - */ - -#include "apr_pools.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup apr_getopt Command Argument Parsing - * @ingroup APR - * @{ - */ - -/** - * An @c apr_getopt_t error callback function. - * - * @a arg is this @c apr_getopt_t's @c errarg member. - */ -typedef void (apr_getopt_err_fn_t)(void *arg, const char *err, ...); - -/** @see apr_getopt_t */ -typedef struct apr_getopt_t apr_getopt_t; - -/** - * Structure to store command line argument information. - */ -struct apr_getopt_t { - /** context for processing */ - apr_pool_t *cont; - /** function to print error message (NULL == no messages) */ - apr_getopt_err_fn_t *errfn; - /** user defined first arg to pass to error message */ - void *errarg; - /** index into parent argv vector */ - int ind; - /** character checked for validity */ - int opt; - /** reset getopt */ - int reset; - /** count of arguments */ - int argc; - /** array of pointers to arguments */ - const char **argv; - /** argument associated with option */ - char const* place; - /** set to nonzero to support interleaving options with regular args */ - int interleave; - /** start of non-option arguments skipped for interleaving */ - int skip_start; - /** end of non-option arguments skipped for interleaving */ - int skip_end; -}; - -/** @see apr_getopt_option_t */ -typedef struct apr_getopt_option_t apr_getopt_option_t; - -/** - * Structure used to describe options that getopt should search for. - */ -struct apr_getopt_option_t { - /** long option name, or NULL if option has no long name */ - const char *name; - /** option letter, or a value greater than 255 if option has no letter */ - int optch; - /** nonzero if option takes an argument */ - int has_arg; - /** a description of the option */ - const char *description; -}; - -/** - * Initialize the arguments for parsing by apr_getopt(). - * @param os The options structure created for apr_getopt() - * @param cont The pool to operate on - * @param argc The number of arguments to parse - * @param argv The array of arguments to parse - * @remark Arguments 3 and 4 are most commonly argc and argv from main(argc, argv) - * The (*os)->errfn is initialized to fprintf(stderr... but may be overridden. - */ -APR_DECLARE(apr_status_t) apr_getopt_init(apr_getopt_t **os, apr_pool_t *cont, - int argc, const char * const *argv); - -/** - * Parse the options initialized by apr_getopt_init(). - * @param os The apr_opt_t structure returned by apr_getopt_init() - * @param opts A string of characters that are acceptable options to the - * program. Characters followed by ":" are required to have an - * option associated - * @param option_ch The next option character parsed - * @param option_arg The argument following the option character: - * @return There are four potential status values on exit. They are: - *
    - *             APR_EOF      --  No more options to parse
    - *             APR_BADCH    --  Found a bad option character
    - *             APR_BADARG   --  No argument followed the option flag
    - *             APR_SUCCESS  --  The next option was found.
    - * 
    - */ -APR_DECLARE(apr_status_t) apr_getopt(apr_getopt_t *os, const char *opts, - char *option_ch, const char **option_arg); - -/** - * Parse the options initialized by apr_getopt_init(), accepting long - * options beginning with "--" in addition to single-character - * options beginning with "-". - * @param os The apr_getopt_t structure created by apr_getopt_init() - * @param opts A pointer to a list of apr_getopt_option_t structures, which - * can be initialized with { "name", optch, has_args }. has_args - * is nonzero if the option requires an argument. A structure - * with an optch value of 0 terminates the list. - * @param option_ch Receives the value of "optch" from the apr_getopt_option_t - * structure corresponding to the next option matched. - * @param option_arg Receives the argument following the option, if any. - * @return There are four potential status values on exit. They are: - *
    - *             APR_EOF      --  No more options to parse
    - *             APR_BADCH    --  Found a bad option character
    - *             APR_BADARG   --  No argument followed the option flag
    - *             APR_SUCCESS  --  The next option was found.
    - * 
    - * When APR_SUCCESS is returned, os->ind gives the index of the first - * non-option argument. On error, a message will be printed to stdout unless - * os->err is set to 0. If os->interleave is set to nonzero, options can come - * after arguments, and os->argv will be permuted to leave non-option arguments - * at the end (the original argv is unaffected). - */ -APR_DECLARE(apr_status_t) apr_getopt_long(apr_getopt_t *os, - const apr_getopt_option_t *opts, - int *option_ch, - const char **option_arg); -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ! APR_GETOPT_H */ diff --git a/libs/apr/include/apr_global_mutex.h b/libs/apr/include/apr_global_mutex.h deleted file mode 100644 index db193013..00000000 --- a/libs/apr/include/apr_global_mutex.h +++ /dev/null @@ -1,169 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_GLOBAL_MUTEX_H -#define APR_GLOBAL_MUTEX_H - -/** - * @file apr_global_mutex.h - * @brief APR Global Locking Routines - */ - -#include "apr.h" -#include "apr_proc_mutex.h" /* only for apr_lockmech_e */ -#include "apr_pools.h" -#include "apr_errno.h" -#if APR_PROC_MUTEX_IS_GLOBAL -#include "apr_proc_mutex.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup APR_GlobalMutex Global Locking Routines - * @ingroup APR - * @{ - */ - -#if !APR_PROC_MUTEX_IS_GLOBAL || defined(DOXYGEN) - -/** Opaque global mutex structure. */ -typedef struct apr_global_mutex_t apr_global_mutex_t; - -/* Function definitions */ - -/** - * Create and initialize a mutex that can be used to synchronize both - * processes and threads. Note: There is considerable overhead in using - * this API if only cross-process or cross-thread mutual exclusion is - * required. See apr_proc_mutex.h and apr_thread_mutex.h for more - * specialized lock routines. - * @param mutex the memory address where the newly created mutex will be - * stored. - * @param fname A file name to use if the lock mechanism requires one. This - * argument should always be provided. The lock code itself will - * determine if it should be used. - * @param mech The mechanism to use for the interprocess lock, if any; one of - *
    - *            APR_LOCK_FCNTL
    - *            APR_LOCK_FLOCK
    - *            APR_LOCK_SYSVSEM
    - *            APR_LOCK_POSIXSEM
    - *            APR_LOCK_PROC_PTHREAD
    - *            APR_LOCK_DEFAULT     pick the default mechanism for the platform
    - * 
    - * @param pool the pool from which to allocate the mutex. - * @warning Check APR_HAS_foo_SERIALIZE defines to see if the platform supports - * APR_LOCK_foo. Only APR_LOCK_DEFAULT is portable. - */ -APR_DECLARE(apr_status_t) apr_global_mutex_create(apr_global_mutex_t **mutex, - const char *fname, - apr_lockmech_e mech, - apr_pool_t *pool); - -/** - * Re-open a mutex in a child process. - * @param mutex The newly re-opened mutex structure. - * @param fname A file name to use if the mutex mechanism requires one. This - * argument should always be provided. The mutex code itself will - * determine if it should be used. This filename should be the - * same one that was passed to apr_global_mutex_create(). - * @param pool The pool to operate on. - * @remark This function must be called to maintain portability, even - * if the underlying lock mechanism does not require it. - */ -APR_DECLARE(apr_status_t) apr_global_mutex_child_init( - apr_global_mutex_t **mutex, - const char *fname, - apr_pool_t *pool); - -/** - * Acquire the lock for the given mutex. If the mutex is already locked, - * the current thread will be put to sleep until the lock becomes available. - * @param mutex the mutex on which to acquire the lock. - */ -APR_DECLARE(apr_status_t) apr_global_mutex_lock(apr_global_mutex_t *mutex); - -/** - * Attempt to acquire the lock for the given mutex. If the mutex has already - * been acquired, the call returns immediately with APR_EBUSY. Note: it - * is important that the APR_STATUS_IS_EBUSY(s) macro be used to determine - * if the return value was APR_EBUSY, for portability reasons. - * @param mutex the mutex on which to attempt the lock acquiring. - */ -APR_DECLARE(apr_status_t) apr_global_mutex_trylock(apr_global_mutex_t *mutex); - -/** - * Release the lock for the given mutex. - * @param mutex the mutex from which to release the lock. - */ -APR_DECLARE(apr_status_t) apr_global_mutex_unlock(apr_global_mutex_t *mutex); - -/** - * Destroy the mutex and free the memory associated with the lock. - * @param mutex the mutex to destroy. - */ -APR_DECLARE(apr_status_t) apr_global_mutex_destroy(apr_global_mutex_t *mutex); - -/** - * Return the name of the lockfile for the mutex, or NULL - * if the mutex doesn't use a lock file - */ -APR_DECLARE(const char *) apr_global_mutex_lockfile(apr_global_mutex_t *mutex); - -/** - * Display the name of the mutex, as it relates to the actual method used - * for the underlying apr_proc_mutex_t, if any. NULL is returned if - * there is no underlying apr_proc_mutex_t. - * @param mutex the name of the mutex - */ -APR_DECLARE(const char *) apr_global_mutex_name(apr_global_mutex_t *mutex); - -/** - * Get the pool used by this global_mutex. - * @return apr_pool_t the pool - */ -APR_POOL_DECLARE_ACCESSOR(global_mutex); - -#else /* APR_PROC_MUTEX_IS_GLOBAL */ - -/* Some platforms [e.g. Win32] have cross process locks that are truly - * global locks, since there isn't the concept of cross-process locks. - * Define these platforms in terms of an apr_proc_mutex_t. - */ - -#define apr_global_mutex_t apr_proc_mutex_t -#define apr_global_mutex_create apr_proc_mutex_create -#define apr_global_mutex_child_init apr_proc_mutex_child_init -#define apr_global_mutex_lock apr_proc_mutex_lock -#define apr_global_mutex_trylock apr_proc_mutex_trylock -#define apr_global_mutex_unlock apr_proc_mutex_unlock -#define apr_global_mutex_destroy apr_proc_mutex_destroy -#define apr_global_mutex_lockfile apr_proc_mutex_lockfile -#define apr_global_mutex_name apr_proc_mutex_name -#define apr_global_mutex_pool_get apr_proc_mutex_pool_get - -#endif - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ndef APR_GLOBAL_MUTEX_H */ diff --git a/libs/apr/include/apr_hash.h b/libs/apr/include/apr_hash.h deleted file mode 100644 index 8e48c7ec..00000000 --- a/libs/apr/include/apr_hash.h +++ /dev/null @@ -1,261 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_HASH_H -#define APR_HASH_H - -/** - * @file apr_hash.h - * @brief APR Hash Tables - */ - -#include "apr_pools.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup apr_hash Hash Tables - * @ingroup APR - * @{ - */ - -/** - * When passing a key to apr_hash_set or apr_hash_get, this value can be - * passed to indicate a string-valued key, and have apr_hash compute the - * length automatically. - * - * @remark apr_hash will use strlen(key) for the length. The NUL terminator - * is not included in the hash value (why throw a constant in?). - * Since the hash table merely references the provided key (rather - * than copying it), apr_hash_this() will return the NUL-term'd key. - */ -#define APR_HASH_KEY_STRING (-1) - -/** - * Abstract type for hash tables. - */ -typedef struct apr_hash_t apr_hash_t; - -/** - * Abstract type for scanning hash tables. - */ -typedef struct apr_hash_index_t apr_hash_index_t; - -/** - * Callback functions for calculating hash values. - * @param key The key. - * @param klen The length of the key, or APR_HASH_KEY_STRING to use the string - * length. If APR_HASH_KEY_STRING then returns the actual key length. - */ -typedef unsigned int (*apr_hashfunc_t)(const char *key, apr_ssize_t *klen); - -/** - * The default hash function. - */ -APR_DECLARE_NONSTD(unsigned int) apr_hashfunc_default(const char *key, - apr_ssize_t *klen); - -/** - * Create a hash table. - * @param pool The pool to allocate the hash table out of - * @return The hash table just created - */ -APR_DECLARE(apr_hash_t *) apr_hash_make(apr_pool_t *pool); - -/** - * Create a hash table with a custom hash function - * @param pool The pool to allocate the hash table out of - * @param hash_func A custom hash function. - * @return The hash table just created - */ -APR_DECLARE(apr_hash_t *) apr_hash_make_custom(apr_pool_t *pool, - apr_hashfunc_t hash_func); - -/** - * Make a copy of a hash table - * @param pool The pool from which to allocate the new hash table - * @param h The hash table to clone - * @return The hash table just created - * @remark Makes a shallow copy - */ -APR_DECLARE(apr_hash_t *) apr_hash_copy(apr_pool_t *pool, - const apr_hash_t *h); - -/** - * Associate a value with a key in a hash table. - * @param ht The hash table - * @param key Pointer to the key - * @param klen Length of the key. Can be APR_HASH_KEY_STRING to use the string length. - * @param val Value to associate with the key - * @remark If the value is NULL the hash entry is deleted. - */ -APR_DECLARE(void) apr_hash_set(apr_hash_t *ht, const void *key, - apr_ssize_t klen, const void *val); - -/** - * Look up the value associated with a key in a hash table. - * @param ht The hash table - * @param key Pointer to the key - * @param klen Length of the key. Can be APR_HASH_KEY_STRING to use the string length. - * @return Returns NULL if the key is not present. - */ -APR_DECLARE(void *) apr_hash_get(apr_hash_t *ht, const void *key, - apr_ssize_t klen); - -/** - * Start iterating over the entries in a hash table. - * @param p The pool to allocate the apr_hash_index_t iterator. If this - * pool is NULL, then an internal, non-thread-safe iterator is used. - * @param ht The hash table - * @return The iteration state - * @remark There is no restriction on adding or deleting hash entries during - * an iteration (although the results may be unpredictable unless all you do - * is delete the current entry) and multiple iterations can be in - * progress at the same time. - * - * @par Example: - * - * @code - * int sum_values(apr_pool_t *p, apr_hash_t *ht) - * { - * apr_hash_index_t *hi; - * void *val; - * int sum = 0; - * for (hi = apr_hash_first(p, ht); hi; hi = apr_hash_next(hi)) { - * apr_hash_this(hi, NULL, NULL, &val); - * sum += *(int *)val; - * } - * return sum; - * } - * @endcode - */ -APR_DECLARE(apr_hash_index_t *) apr_hash_first(apr_pool_t *p, apr_hash_t *ht); - -/** - * Continue iterating over the entries in a hash table. - * @param hi The iteration state - * @return a pointer to the updated iteration state. NULL if there are no more - * entries. - */ -APR_DECLARE(apr_hash_index_t *) apr_hash_next(apr_hash_index_t *hi); - -/** - * Get the current entry's details from the iteration state. - * @param hi The iteration state - * @param key Return pointer for the pointer to the key. - * @param klen Return pointer for the key length. - * @param val Return pointer for the associated value. - * @remark The return pointers should point to a variable that will be set to the - * corresponding data, or they may be NULL if the data isn't interesting. - */ -APR_DECLARE(void) apr_hash_this(apr_hash_index_t *hi, const void **key, - apr_ssize_t *klen, void **val); - -/** - * Get the number of key/value pairs in the hash table. - * @param ht The hash table - * @return The number of key/value pairs in the hash table. - */ -APR_DECLARE(unsigned int) apr_hash_count(apr_hash_t *ht); - -/** - * Clear any key/value pairs in the hash table. - * @param ht The hash table - */ -APR_DECLARE(void) apr_hash_clear(apr_hash_t *ht); - -/** - * Merge two hash tables into one new hash table. The values of the overlay - * hash override the values of the base if both have the same key. Both - * hash tables must use the same hash function. - * @param p The pool to use for the new hash table - * @param overlay The table to add to the initial table - * @param base The table that represents the initial values of the new table - * @return A new hash table containing all of the data from the two passed in - */ -APR_DECLARE(apr_hash_t *) apr_hash_overlay(apr_pool_t *p, - const apr_hash_t *overlay, - const apr_hash_t *base); - -/** - * Merge two hash tables into one new hash table. If the same key - * is present in both tables, call the supplied merge function to - * produce a merged value for the key in the new table. Both - * hash tables must use the same hash function. - * @param p The pool to use for the new hash table - * @param h1 The first of the tables to merge - * @param h2 The second of the tables to merge - * @param merger A callback function to merge values, or NULL to - * make values from h1 override values from h2 (same semantics as - * apr_hash_overlay()) - * @param data Client data to pass to the merger function - * @return A new hash table containing all of the data from the two passed in - */ -APR_DECLARE(apr_hash_t *) apr_hash_merge(apr_pool_t *p, - const apr_hash_t *h1, - const apr_hash_t *h2, - void * (*merger)(apr_pool_t *p, - const void *key, - apr_ssize_t klen, - const void *h1_val, - const void *h2_val, - const void *data), - const void *data); - -/** - * Declaration prototype for the iterator callback function of apr_hash_do(). - * - * @param rec The data passed as the first argument to apr_hash_[v]do() - * @param key The key from this iteration of the hash table - * @param klen The key length from this iteration of the hash table - * @param value The value from this iteration of the hash table - * @remark Iteration continues while this callback function returns non-zero. - * To export the callback function for apr_hash_do() it must be declared - * in the _NONSTD convention. - */ -typedef int (apr_hash_do_callback_fn_t)(void *rec, const void *key, - apr_ssize_t klen, - const void *value); - -/** - * Iterate over a hash table running the provided function once for every - * element in the hash table. The @param comp function will be invoked for - * every element in the hash table. - * - * @param comp The function to run - * @param rec The data to pass as the first argument to the function - * @param ht The hash table to iterate over - * @return FALSE if one of the comp() iterations returned zero; TRUE if all - * iterations returned non-zero - * @see apr_hash_do_callback_fn_t - */ -APR_DECLARE(int) apr_hash_do(apr_hash_do_callback_fn_t *comp, - void *rec, const apr_hash_t *ht); - -/** - * Get a pointer to the pool which the hash table was created in - */ -APR_POOL_DECLARE_ACCESSOR(hash); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* !APR_HASH_H */ diff --git a/libs/apr/include/apr_inherit.h b/libs/apr/include/apr_inherit.h deleted file mode 100644 index b7f7480f..00000000 --- a/libs/apr/include/apr_inherit.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_INHERIT_H -#define APR_INHERIT_H - -/** - * @file apr_inherit.h - * @brief APR File Handle Inheritance Helpers - * @remark This internal header includes internal declaration helpers - * for other headers to declare apr_foo_inherit_[un]set functions. - */ - -/** - * Prototype for type-specific declarations of apr_foo_inherit_set - * functions. - * @remark Doxygen unwraps this macro (via doxygen.conf) to provide - * actual help for each specific occurance of apr_foo_inherit_set. - * @remark the linkage is specified for APR. It would be possible to expand - * the macros to support other linkages. - */ -#define APR_DECLARE_INHERIT_SET(type) \ - APR_DECLARE(apr_status_t) apr_##type##_inherit_set( \ - apr_##type##_t *the##type) - -/** - * Prototype for type-specific declarations of apr_foo_inherit_unset - * functions. - * @remark Doxygen unwraps this macro (via doxygen.conf) to provide - * actual help for each specific occurance of apr_foo_inherit_unset. - * @remark the linkage is specified for APR. It would be possible to expand - * the macros to support other linkages. - */ -#define APR_DECLARE_INHERIT_UNSET(type) \ - APR_DECLARE(apr_status_t) apr_##type##_inherit_unset( \ - apr_##type##_t *the##type) - -#endif /* ! APR_INHERIT_H */ diff --git a/libs/apr/include/apr_lib.h b/libs/apr/include/apr_lib.h deleted file mode 100644 index 8c0fea74..00000000 --- a/libs/apr/include/apr_lib.h +++ /dev/null @@ -1,241 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_LIB_H -#define APR_LIB_H - -/** - * @file apr_lib.h - * This is collection of oddballs that didn't fit anywhere else, - * and might move to more appropriate headers with the release - * of APR 1.0. - * @brief APR general purpose library routines - */ - -#include "apr.h" -#include "apr_errno.h" - -#if APR_HAVE_CTYPE_H -#include -#endif -#if APR_HAVE_STDARG_H -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup apr_lib General Purpose Library Routines - * @ingroup APR - * This is collection of oddballs that didn't fit anywhere else, - * and might move to more appropriate headers with the release - * of APR 1.0. - * @{ - */ - -/** A constant representing a 'large' string. */ -#define HUGE_STRING_LEN 8192 - -/* - * Define the structures used by the APR general-purpose library. - */ - -/** @see apr_vformatter_buff_t */ -typedef struct apr_vformatter_buff_t apr_vformatter_buff_t; - -/** - * Structure used by the variable-formatter routines. - */ -struct apr_vformatter_buff_t { - /** The current position */ - char *curpos; - /** The end position of the format string */ - char *endpos; -}; - -/** - * return the final element of the pathname - * @param pathname The path to get the final element of - * @return the final element of the path - * @remark - *
    - * For example:
    - *                 "/foo/bar/gum"    -> "gum"
    - *                 "/foo/bar/gum/"   -> ""
    - *                 "gum"             -> "gum"
    - *                 "bs\\path\\stuff" -> "stuff"
    - * 
    - */ -APR_DECLARE(const char *) apr_filepath_name_get(const char *pathname); - -/** - * apr_killpg - * Small utility macros to make things easier to read. Not usually a - * goal, to be sure.. - */ - -#ifdef WIN32 -#define apr_killpg(x, y) -#else /* WIN32 */ -#ifdef NO_KILLPG -#define apr_killpg(x, y) (kill (-(x), (y))) -#else /* NO_KILLPG */ -#define apr_killpg(x, y) (killpg ((x), (y))) -#endif /* NO_KILLPG */ -#endif /* WIN32 */ - -/** - * apr_vformatter() is a generic printf-style formatting routine - * with some extensions. - * @param flush_func The function to call when the buffer is full - * @param c The buffer to write to - * @param fmt The format string - * @param ap The arguments to use to fill out the format string. - * - * @remark - *
    - * The extensions are:
    - *
    - * %%pA	takes a struct in_addr *, and prints it as a.b.c.d
    - * %%pI	takes an apr_sockaddr_t * and prints it as a.b.c.d:port or
    - *      [ipv6-address]:port
    - * %%pT takes an apr_os_thread_t * and prints it in decimal
    - *      ('0' is printed if !APR_HAS_THREADS)
    - * %%pt takes an apr_os_thread_t * and prints it in hexadecimal
    - *      ('0' is printed if !APR_HAS_THREADS)
    - * %%pm takes an apr_status_t * and prints the appropriate error
    - *      string (from apr_strerror) corresponding to that error code.
    - * %%pp takes a void * and outputs it in hex
    - * %%pB takes a apr_uint32_t * as bytes and outputs it's apr_strfsize
    - * %%pF same as above, but takes a apr_off_t *
    - * %%pS same as above, but takes a apr_size_t *
    - *
    - * %%pA, %%pI, %%pT, %%pp are available from APR 1.0.0 onwards (and in 0.9.x).
    - * %%pt is only available from APR 1.2.0 onwards.
    - * %%pm, %%pB, %%pF and %%pS are only available from APR 1.3.0 onwards.
    - *
    - * The %%p hacks are to force gcc's printf warning code to skip
    - * over a pointer argument without complaining.  This does
    - * mean that the ANSI-style %%p (output a void * in hex format) won't
    - * work as expected at all, but that seems to be a fair trade-off
    - * for the increased robustness of having printf-warnings work.
    - *
    - * Additionally, apr_vformatter allows for arbitrary output methods
    - * using the apr_vformatter_buff and flush_func.
    - *
    - * The apr_vformatter_buff has two elements curpos and endpos.
    - * curpos is where apr_vformatter will write the next byte of output.
    - * It proceeds writing output to curpos, and updating curpos, until
    - * either the end of output is reached, or curpos == endpos (i.e. the
    - * buffer is full).
    - *
    - * If the end of output is reached, apr_vformatter returns the
    - * number of bytes written.
    - *
    - * When the buffer is full, the flush_func is called.  The flush_func
    - * can return -1 to indicate that no further output should be attempted,
    - * and apr_vformatter will return immediately with -1.  Otherwise
    - * the flush_func should flush the buffer in whatever manner is
    - * appropriate, re apr_pool_t nitialize curpos and endpos, and return 0.
    - *
    - * Note that flush_func is only invoked as a result of attempting to
    - * write another byte at curpos when curpos >= endpos.  So for
    - * example, it's possible when the output exactly matches the buffer
    - * space available that curpos == endpos will be true when
    - * apr_vformatter returns.
    - *
    - * apr_vformatter does not call out to any other code, it is entirely
    - * self-contained.  This allows the callers to do things which are
    - * otherwise "unsafe".  For example, apr_psprintf uses the "scratch"
    - * space at the unallocated end of a block, and doesn't actually
    - * complete the allocation until apr_vformatter returns.  apr_psprintf
    - * would be completely broken if apr_vformatter were to call anything
    - * that used this same pool.  Similarly http_bprintf() uses the "scratch"
    - * space at the end of its output buffer, and doesn't actually note
    - * that the space is in use until it either has to flush the buffer
    - * or until apr_vformatter returns.
    - * 
    - */ -APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *b), - apr_vformatter_buff_t *c, const char *fmt, - va_list ap); - -/** - * Display a prompt and read in the password from stdin. - * @param prompt The prompt to display - * @param pwbuf Buffer to store the password - * @param bufsize The length of the password buffer. - * @remark If the password entered must be truncated to fit in - * the provided buffer, APR_ENAMETOOLONG will be returned. - * Note that the bufsize paramater is passed by reference for no - * reason; its value will never be modified by the apr_password_get() - * function. - */ -APR_DECLARE(apr_status_t) apr_password_get(const char *prompt, char *pwbuf, - apr_size_t *bufsize); - -/** @} */ - -/** - * @defgroup apr_ctype ctype functions - * These macros allow correct support of 8-bit characters on systems which - * support 8-bit characters. Pretty dumb how the cast is required, but - * that's legacy libc for ya. These new macros do not support EOF like - * the standard macros do. Tough. - * @{ - */ -/** @see isalnum */ -#define apr_isalnum(c) (isalnum(((unsigned char)(c)))) -/** @see isalpha */ -#define apr_isalpha(c) (isalpha(((unsigned char)(c)))) -/** @see iscntrl */ -#define apr_iscntrl(c) (iscntrl(((unsigned char)(c)))) -/** @see isdigit */ -#define apr_isdigit(c) (isdigit(((unsigned char)(c)))) -/** @see isgraph */ -#define apr_isgraph(c) (isgraph(((unsigned char)(c)))) -/** @see islower*/ -#define apr_islower(c) (islower(((unsigned char)(c)))) -/** @see isascii */ -#ifdef isascii -#define apr_isascii(c) (isascii(((unsigned char)(c)))) -#else -#define apr_isascii(c) (((c) & ~0x7f)==0) -#endif -/** @see isprint */ -#define apr_isprint(c) (isprint(((unsigned char)(c)))) -/** @see ispunct */ -#define apr_ispunct(c) (ispunct(((unsigned char)(c)))) -/** @see isspace */ -#define apr_isspace(c) (isspace(((unsigned char)(c)))) -/** @see isupper */ -#define apr_isupper(c) (isupper(((unsigned char)(c)))) -/** @see isxdigit */ -#define apr_isxdigit(c) (isxdigit(((unsigned char)(c)))) -/** @see tolower */ -#define apr_tolower(c) (tolower(((unsigned char)(c)))) -/** @see toupper */ -#define apr_toupper(c) (toupper(((unsigned char)(c)))) - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ! APR_LIB_H */ diff --git a/libs/apr/include/apr_mmap.h b/libs/apr/include/apr_mmap.h deleted file mode 100644 index 77d697f5..00000000 --- a/libs/apr/include/apr_mmap.h +++ /dev/null @@ -1,171 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_MMAP_H -#define APR_MMAP_H - -/** - * @file apr_mmap.h - * @brief APR MMAP routines - */ - -#include "apr.h" -#include "apr_pools.h" -#include "apr_errno.h" -#include "apr_ring.h" -#include "apr_file_io.h" /* for apr_file_t */ - -#ifdef BEOS -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup apr_mmap MMAP (Memory Map) Routines - * @ingroup APR - * @{ - */ - -/** MMap opened for reading */ -#define APR_MMAP_READ 1 -/** MMap opened for writing */ -#define APR_MMAP_WRITE 2 - -/** @see apr_mmap_t */ -typedef struct apr_mmap_t apr_mmap_t; - -/** - * @remark - * As far as I can tell the only really sane way to store an MMAP is as a - * void * and a length. BeOS requires this area_id, but that's just a little - * something extra. I am exposing this type, because it doesn't make much - * sense to keep it private, and opening it up makes some stuff easier in - * Apache. - */ -/** The MMAP structure */ -struct apr_mmap_t { - /** The pool the mmap structure was allocated out of. */ - apr_pool_t *cntxt; -#ifdef BEOS - /** An area ID. Only valid on BeOS */ - area_id area; -#endif -#ifdef WIN32 - /** The handle of the file mapping */ - HANDLE mhandle; - /** The start of the real memory page area (mapped view) */ - void *mv; - /** The physical start, size and offset */ - apr_off_t pstart; - apr_size_t psize; - apr_off_t poffset; -#endif - /** The start of the memory mapped area */ - void *mm; - /** The amount of data in the mmap */ - apr_size_t size; - /** ring of apr_mmap_t's that reference the same - * mmap'ed region; acts in place of a reference count */ - APR_RING_ENTRY(apr_mmap_t) link; -}; - -#if APR_HAS_MMAP || defined(DOXYGEN) - -/** @def APR_MMAP_THRESHOLD - * Files have to be at least this big before they're mmap()d. This is to deal - * with systems where the expense of doing an mmap() and an munmap() outweighs - * the benefit for small files. It shouldn't be set lower than 1. - */ -#ifdef MMAP_THRESHOLD -# define APR_MMAP_THRESHOLD MMAP_THRESHOLD -#else -# ifdef SUNOS4 -# define APR_MMAP_THRESHOLD (8*1024) -# else -# define APR_MMAP_THRESHOLD 1 -# endif /* SUNOS4 */ -#endif /* MMAP_THRESHOLD */ - -/** @def APR_MMAP_LIMIT - * Maximum size of MMap region - */ -#ifdef MMAP_LIMIT -# define APR_MMAP_LIMIT MMAP_LIMIT -#else -# define APR_MMAP_LIMIT (4*1024*1024) -#endif /* MMAP_LIMIT */ - -/** Can this file be MMaped */ -#define APR_MMAP_CANDIDATE(filelength) \ - ((filelength >= APR_MMAP_THRESHOLD) && (filelength < APR_MMAP_LIMIT)) - -/* Function definitions */ - -/** - * Create a new mmap'ed file out of an existing APR file. - * @param newmmap The newly created mmap'ed file. - * @param file The file turn into an mmap. - * @param offset The offset into the file to start the data pointer at. - * @param size The size of the file - * @param flag bit-wise or of: - *
    - *          APR_MMAP_READ       MMap opened for reading
    - *          APR_MMAP_WRITE      MMap opened for writing
    - * 
    - * @param cntxt The pool to use when creating the mmap. - */ -APR_DECLARE(apr_status_t) apr_mmap_create(apr_mmap_t **newmmap, - apr_file_t *file, apr_off_t offset, - apr_size_t size, apr_int32_t flag, - apr_pool_t *cntxt); - -/** - * Duplicate the specified MMAP. - * @param new_mmap The structure to duplicate into. - * @param old_mmap The mmap to duplicate. - * @param p The pool to use for new_mmap. - */ -APR_DECLARE(apr_status_t) apr_mmap_dup(apr_mmap_t **new_mmap, - apr_mmap_t *old_mmap, - apr_pool_t *p); - -/** - * Remove a mmap'ed. - * @param mm The mmap'ed file. - */ -APR_DECLARE(apr_status_t) apr_mmap_delete(apr_mmap_t *mm); - -/** - * Move the pointer into the mmap'ed file to the specified offset. - * @param addr The pointer to the offset specified. - * @param mm The mmap'ed file. - * @param offset The offset to move to. - */ -APR_DECLARE(apr_status_t) apr_mmap_offset(void **addr, apr_mmap_t *mm, - apr_off_t offset); - -#endif /* APR_HAS_MMAP */ - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ! APR_MMAP_H */ diff --git a/libs/apr/include/apr_network_io.h b/libs/apr/include/apr_network_io.h deleted file mode 100644 index 0335da9d..00000000 --- a/libs/apr/include/apr_network_io.h +++ /dev/null @@ -1,857 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_NETWORK_IO_H -#define APR_NETWORK_IO_H -/** - * @file apr_network_io.h - * @brief APR Network library - */ - -#include "apr.h" -#include "apr_pools.h" -#include "apr_file_io.h" -#include "apr_errno.h" -#include "apr_inherit.h" - -#if APR_HAVE_NETINET_IN_H -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup apr_network_io Network Routines - * @ingroup APR - * @{ - */ - -#ifndef APR_MAX_SECS_TO_LINGER -/** Maximum seconds to linger */ -#define APR_MAX_SECS_TO_LINGER 30 -#endif - -#ifndef APRMAXHOSTLEN -/** Maximum hostname length */ -#define APRMAXHOSTLEN 256 -#endif - -#ifndef APR_ANYADDR -/** Default 'any' address */ -#define APR_ANYADDR "0.0.0.0" -#endif - -/** - * @defgroup apr_sockopt Socket option definitions - * @{ - */ -#define APR_SO_LINGER 1 /**< Linger */ -#define APR_SO_KEEPALIVE 2 /**< Keepalive */ -#define APR_SO_DEBUG 4 /**< Debug */ -#define APR_SO_NONBLOCK 8 /**< Non-blocking IO */ -#define APR_SO_REUSEADDR 16 /**< Reuse addresses */ -#define APR_SO_SNDBUF 64 /**< Send buffer */ -#define APR_SO_RCVBUF 128 /**< Receive buffer */ -#define APR_SO_DISCONNECTED 256 /**< Disconnected */ -#define APR_TCP_NODELAY 512 /**< For SCTP sockets, this is mapped - * to STCP_NODELAY internally. - */ -#define APR_TCP_NOPUSH 1024 /**< No push */ -#define APR_RESET_NODELAY 2048 /**< This flag is ONLY set internally - * when we set APR_TCP_NOPUSH with - * APR_TCP_NODELAY set to tell us that - * APR_TCP_NODELAY should be turned on - * again when NOPUSH is turned off - */ -#define APR_INCOMPLETE_READ 4096 /**< Set on non-blocking sockets - * (timeout != 0) on which the - * previous read() did not fill a buffer - * completely. the next apr_socket_recv() - * will first call select()/poll() rather than - * going straight into read(). (Can also - * be set by an application to force a - * select()/poll() call before the next - * read, in cases where the app expects - * that an immediate read would fail.) - */ -#define APR_INCOMPLETE_WRITE 8192 /**< like APR_INCOMPLETE_READ, but for write - * @see APR_INCOMPLETE_READ - */ -#define APR_IPV6_V6ONLY 16384 /**< Don't accept IPv4 connections on an - * IPv6 listening socket. - */ -#define APR_TCP_DEFER_ACCEPT 32768 /**< Delay accepting of new connections - * until data is available. - * @see apr_socket_accept_filter - */ - -/** @} */ - -/** Define what type of socket shutdown should occur. */ -typedef enum { - APR_SHUTDOWN_READ, /**< no longer allow read request */ - APR_SHUTDOWN_WRITE, /**< no longer allow write requests */ - APR_SHUTDOWN_READWRITE /**< no longer allow read or write requests */ -} apr_shutdown_how_e; - -#define APR_IPV4_ADDR_OK 0x01 /**< @see apr_sockaddr_info_get() */ -#define APR_IPV6_ADDR_OK 0x02 /**< @see apr_sockaddr_info_get() */ - -#if (!APR_HAVE_IN_ADDR) -/** - * We need to make sure we always have an in_addr type, so APR will just - * define it ourselves, if the platform doesn't provide it. - */ -struct in_addr { - apr_uint32_t s_addr; /**< storage to hold the IP# */ -}; -#endif - -/** @def APR_INADDR_NONE - * Not all platforms have a real INADDR_NONE. This macro replaces - * INADDR_NONE on all platforms. - */ -#ifdef INADDR_NONE -#define APR_INADDR_NONE INADDR_NONE -#else -#define APR_INADDR_NONE ((unsigned int) 0xffffffff) -#endif - -/** - * @def APR_INET - * Not all platforms have these defined, so we'll define them here - * The default values come from FreeBSD 4.1.1 - */ -#define APR_INET AF_INET -/** @def APR_UNSPEC - * Let the system decide which address family to use - */ -#ifdef AF_UNSPEC -#define APR_UNSPEC AF_UNSPEC -#else -#define APR_UNSPEC 0 -#endif -#if APR_HAVE_IPV6 -/** @def APR_INET6 -* IPv6 Address Family. Not all platforms may have this defined. -*/ - -#define APR_INET6 AF_INET6 -#endif - -/** - * @defgroup IP_Proto IP Protocol Definitions for use when creating sockets - * @{ - */ -#define APR_PROTO_TCP 6 /**< TCP */ -#define APR_PROTO_UDP 17 /**< UDP */ -#define APR_PROTO_SCTP 132 /**< SCTP */ -/** @} */ - -/** - * Enum used to denote either the local and remote endpoint of a - * connection. - */ -typedef enum { - APR_LOCAL, /**< Socket information for local end of connection */ - APR_REMOTE /**< Socket information for remote end of connection */ -} apr_interface_e; - -/** - * The specific declaration of inet_addr's ... some platforms fall back - * inet_network (this is not good, but necessary) - */ - -#if APR_HAVE_INET_ADDR -#define apr_inet_addr inet_addr -#elif APR_HAVE_INET_NETWORK /* only DGUX, as far as I know */ -/** - * @warning - * not generally safe... inet_network() and inet_addr() perform - * different functions */ -#define apr_inet_addr inet_network -#endif - -/** A structure to represent sockets */ -typedef struct apr_socket_t apr_socket_t; -/** - * A structure to encapsulate headers and trailers for apr_socket_sendfile - */ -typedef struct apr_hdtr_t apr_hdtr_t; -/** A structure to represent in_addr */ -typedef struct in_addr apr_in_addr_t; -/** A structure to represent an IP subnet */ -typedef struct apr_ipsubnet_t apr_ipsubnet_t; - -/** @remark use apr_uint16_t just in case some system has a short that isn't 16 bits... */ -typedef apr_uint16_t apr_port_t; - -/** @remark It's defined here as I think it should all be platform safe... - * @see apr_sockaddr_t - */ -typedef struct apr_sockaddr_t apr_sockaddr_t; -/** - * APRs socket address type, used to ensure protocol independence - */ -struct apr_sockaddr_t { - /** The pool to use... */ - apr_pool_t *pool; - /** The hostname */ - char *hostname; - /** Either a string of the port number or the service name for the port */ - char *servname; - /** The numeric port */ - apr_port_t port; - /** The family */ - apr_int32_t family; - /** How big is the sockaddr we're using? */ - apr_socklen_t salen; - /** How big is the ip address structure we're using? */ - int ipaddr_len; - /** How big should the address buffer be? 16 for v4 or 46 for v6 - * used in inet_ntop... */ - int addr_str_len; - /** This points to the IP address structure within the appropriate - * sockaddr structure. */ - void *ipaddr_ptr; - /** If multiple addresses were found by apr_sockaddr_info_get(), this - * points to a representation of the next address. */ - apr_sockaddr_t *next; - /** Union of either IPv4 or IPv6 sockaddr. */ - union { - /** IPv4 sockaddr structure */ - struct sockaddr_in sin; -#if APR_HAVE_IPV6 - /** IPv6 sockaddr structure */ - struct sockaddr_in6 sin6; -#endif -#if APR_HAVE_SA_STORAGE - /** Placeholder to ensure that the size of this union is not - * dependent on whether APR_HAVE_IPV6 is defined. */ - struct sockaddr_storage sas; -#endif - } sa; -}; - -#if APR_HAS_SENDFILE -/** - * Support reusing the socket on platforms which support it (from disconnect, - * specifically Win32. - * @remark Optional flag passed into apr_socket_sendfile() - */ -#define APR_SENDFILE_DISCONNECT_SOCKET 1 -#endif - -/** A structure to encapsulate headers and trailers for apr_socket_sendfile */ -struct apr_hdtr_t { - /** An iovec to store the headers sent before the file. */ - struct iovec* headers; - /** number of headers in the iovec */ - int numheaders; - /** An iovec to store the trailers sent after the file. */ - struct iovec* trailers; - /** number of trailers in the iovec */ - int numtrailers; -}; - -/* function definitions */ - -/** - * Create a socket. - * @param new_sock The new socket that has been set up. - * @param family The address family of the socket (e.g., APR_INET). - * @param type The type of the socket (e.g., SOCK_STREAM). - * @param protocol The protocol of the socket (e.g., APR_PROTO_TCP). - * @param cont The pool for the apr_socket_t and associated storage. - */ -APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new_sock, - int family, int type, - int protocol, - apr_pool_t *cont); - -/** - * Shutdown either reading, writing, or both sides of a socket. - * @param thesocket The socket to close - * @param how How to shutdown the socket. One of: - *
    - *            APR_SHUTDOWN_READ         no longer allow read requests
    - *            APR_SHUTDOWN_WRITE        no longer allow write requests
    - *            APR_SHUTDOWN_READWRITE    no longer allow read or write requests 
    - * 
    - * @see apr_shutdown_how_e - * @remark This does not actually close the socket descriptor, it just - * controls which calls are still valid on the socket. - */ -APR_DECLARE(apr_status_t) apr_socket_shutdown(apr_socket_t *thesocket, - apr_shutdown_how_e how); - -/** - * Close a socket. - * @param thesocket The socket to close - */ -APR_DECLARE(apr_status_t) apr_socket_close(apr_socket_t *thesocket); - -/** - * Bind the socket to its associated port - * @param sock The socket to bind - * @param sa The socket address to bind to - * @remark This may be where we will find out if there is any other process - * using the selected port. - */ -APR_DECLARE(apr_status_t) apr_socket_bind(apr_socket_t *sock, - apr_sockaddr_t *sa); - -/** - * Listen to a bound socket for connections. - * @param sock The socket to listen on - * @param backlog The number of outstanding connections allowed in the sockets - * listen queue. If this value is less than zero, the listen - * queue size is set to zero. - */ -APR_DECLARE(apr_status_t) apr_socket_listen(apr_socket_t *sock, - apr_int32_t backlog); - -/** - * Accept a new connection request - * @param new_sock A copy of the socket that is connected to the socket that - * made the connection request. This is the socket which should - * be used for all future communication. - * @param sock The socket we are listening on. - * @param connection_pool The pool for the new socket. - */ -APR_DECLARE(apr_status_t) apr_socket_accept(apr_socket_t **new_sock, - apr_socket_t *sock, - apr_pool_t *connection_pool); - -/** - * Issue a connection request to a socket either on the same machine - * or a different one. - * @param sock The socket we wish to use for our side of the connection - * @param sa The address of the machine we wish to connect to. - */ -APR_DECLARE(apr_status_t) apr_socket_connect(apr_socket_t *sock, - apr_sockaddr_t *sa); - -/** - * Determine whether the receive part of the socket has been closed by - * the peer (such that a subsequent call to apr_socket_read would - * return APR_EOF), if the socket's receive buffer is empty. This - * function does not block waiting for I/O. - * - * @param sock The socket to check - * @param atreadeof If APR_SUCCESS is returned, *atreadeof is set to - * non-zero if a subsequent read would return APR_EOF - * @return an error is returned if it was not possible to determine the - * status, in which case *atreadeof is not changed. - */ -APR_DECLARE(apr_status_t) apr_socket_atreadeof(apr_socket_t *sock, - int *atreadeof); - -/** - * Create apr_sockaddr_t from hostname, address family, and port. - * @param sa The new apr_sockaddr_t. - * @param hostname The hostname or numeric address string to resolve/parse, or - * NULL to build an address that corresponds to 0.0.0.0 or :: - * @param family The address family to use, or APR_UNSPEC if the system should - * decide. - * @param port The port number. - * @param flags Special processing flags: - *
    - *       APR_IPV4_ADDR_OK          first query for IPv4 addresses; only look
    - *                                 for IPv6 addresses if the first query failed;
    - *                                 only valid if family is APR_UNSPEC and hostname
    - *                                 isn't NULL; mutually exclusive with
    - *                                 APR_IPV6_ADDR_OK
    - *       APR_IPV6_ADDR_OK          first query for IPv6 addresses; only look
    - *                                 for IPv4 addresses if the first query failed;
    - *                                 only valid if family is APR_UNSPEC and hostname
    - *                                 isn't NULL and APR_HAVE_IPV6; mutually exclusive
    - *                                 with APR_IPV4_ADDR_OK
    - * 
    - * @param p The pool for the apr_sockaddr_t and associated storage. - */ -APR_DECLARE(apr_status_t) apr_sockaddr_info_get(apr_sockaddr_t **sa, - const char *hostname, - apr_int32_t family, - apr_port_t port, - apr_int32_t flags, - apr_pool_t *p); - -/** - * Look up the host name from an apr_sockaddr_t. - * @param hostname The hostname. - * @param sa The apr_sockaddr_t. - * @param flags Special processing flags. - */ -APR_DECLARE(apr_status_t) apr_getnameinfo(char **hostname, - apr_sockaddr_t *sa, - apr_int32_t flags); - -/** - * Parse hostname/IP address with scope id and port. - * - * Any of the following strings are accepted: - * 8080 (just the port number) - * www.apache.org (just the hostname) - * www.apache.org:8080 (hostname and port number) - * [fe80::1]:80 (IPv6 numeric address string only) - * [fe80::1%eth0] (IPv6 numeric address string and scope id) - * - * Invalid strings: - * (empty string) - * [abc] (not valid IPv6 numeric address string) - * abc:65536 (invalid port number) - * - * @param addr The new buffer containing just the hostname. On output, *addr - * will be NULL if no hostname/IP address was specfied. - * @param scope_id The new buffer containing just the scope id. On output, - * *scope_id will be NULL if no scope id was specified. - * @param port The port number. On output, *port will be 0 if no port was - * specified. - * ### FIXME: 0 is a legal port (per RFC 1700). this should - * ### return something besides zero if the port is missing. - * @param str The input string to be parsed. - * @param p The pool from which *addr and *scope_id are allocated. - * @remark If scope id shouldn't be allowed, check for scope_id != NULL in - * addition to checking the return code. If addr/hostname should be - * required, check for addr == NULL in addition to checking the - * return code. - */ -APR_DECLARE(apr_status_t) apr_parse_addr_port(char **addr, - char **scope_id, - apr_port_t *port, - const char *str, - apr_pool_t *p); - -/** - * Get name of the current machine - * @param buf A buffer to store the hostname in. - * @param len The maximum length of the hostname that can be stored in the - * buffer provided. The suggested length is APRMAXHOSTLEN + 1. - * @param cont The pool to use. - * @remark If the buffer was not large enough, an error will be returned. - */ -APR_DECLARE(apr_status_t) apr_gethostname(char *buf, int len, apr_pool_t *cont); - -/** - * Return the data associated with the current socket - * @param data The user data associated with the socket. - * @param key The key to associate with the user data. - * @param sock The currently open socket. - */ -APR_DECLARE(apr_status_t) apr_socket_data_get(void **data, const char *key, - apr_socket_t *sock); - -/** - * Set the data associated with the current socket. - * @param sock The currently open socket. - * @param data The user data to associate with the socket. - * @param key The key to associate with the data. - * @param cleanup The cleanup to call when the socket is destroyed. - */ -APR_DECLARE(apr_status_t) apr_socket_data_set(apr_socket_t *sock, void *data, - const char *key, - apr_status_t (*cleanup)(void*)); - -/** - * Send data over a network. - * @param sock The socket to send the data over. - * @param buf The buffer which contains the data to be sent. - * @param len On entry, the number of bytes to send; on exit, the number - * of bytes sent. - * @remark - *
    - * This functions acts like a blocking write by default.  To change 
    - * this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK
    - * socket option.
    - *
    - * It is possible for both bytes to be sent and an error to be returned.
    - *
    - * APR_EINTR is never returned.
    - * 
    - */ -APR_DECLARE(apr_status_t) apr_socket_send(apr_socket_t *sock, const char *buf, - apr_size_t *len); - -/** - * Send multiple packets of data over a network. - * @param sock The socket to send the data over. - * @param vec The array of iovec structs containing the data to send - * @param nvec The number of iovec structs in the array - * @param len Receives the number of bytes actually written - * @remark - *
    - * This functions acts like a blocking write by default.  To change 
    - * this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK
    - * socket option.
    - * The number of bytes actually sent is stored in argument 3.
    - *
    - * It is possible for both bytes to be sent and an error to be returned.
    - *
    - * APR_EINTR is never returned.
    - * 
    - */ -APR_DECLARE(apr_status_t) apr_socket_sendv(apr_socket_t *sock, - const struct iovec *vec, - apr_int32_t nvec, apr_size_t *len); - -/** - * @param sock The socket to send from - * @param where The apr_sockaddr_t describing where to send the data - * @param flags The flags to use - * @param buf The data to send - * @param len The length of the data to send - */ -APR_DECLARE(apr_status_t) apr_socket_sendto(apr_socket_t *sock, - apr_sockaddr_t *where, - apr_int32_t flags, const char *buf, - apr_size_t *len); - -/** - * Read data from a socket. On success, the address of the peer from - * which the data was sent is copied into the @a from parameter, and the - * @a len parameter is updated to give the number of bytes written to - * @a buf. - * - * @param from Updated with the address from which the data was received - * @param sock The socket to use - * @param flags The flags to use - * @param buf The buffer to use - * @param len The length of the available buffer - */ - -APR_DECLARE(apr_status_t) apr_socket_recvfrom(apr_sockaddr_t *from, - apr_socket_t *sock, - apr_int32_t flags, char *buf, - apr_size_t *len); - -#if APR_HAS_SENDFILE || defined(DOXYGEN) - -/** - * Send a file from an open file descriptor to a socket, along with - * optional headers and trailers - * @param sock The socket to which we're writing - * @param file The open file from which to read - * @param hdtr A structure containing the headers and trailers to send - * @param offset Offset into the file where we should begin writing - * @param len (input) - Number of bytes to send from the file - * (output) - Number of bytes actually sent, - * including headers, file, and trailers - * @param flags APR flags that are mapped to OS specific flags - * @remark This functions acts like a blocking write by default. To change - * this behavior, use apr_socket_timeout_set() or the - * APR_SO_NONBLOCK socket option. - * The number of bytes actually sent is stored in the len parameter. - * The offset parameter is passed by reference for no reason; its - * value will never be modified by the apr_socket_sendfile() function. - */ -APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock, - apr_file_t *file, - apr_hdtr_t *hdtr, - apr_off_t *offset, - apr_size_t *len, - apr_int32_t flags); - -#endif /* APR_HAS_SENDFILE */ - -/** - * Read data from a network. - * @param sock The socket to read the data from. - * @param buf The buffer to store the data in. - * @param len On entry, the number of bytes to receive; on exit, the number - * of bytes received. - * @remark - *
    - * This functions acts like a blocking read by default.  To change 
    - * this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK
    - * socket option.
    - * The number of bytes actually received is stored in argument 3.
    - *
    - * It is possible for both bytes to be received and an APR_EOF or
    - * other error to be returned.
    - *
    - * APR_EINTR is never returned.
    - * 
    - */ -APR_DECLARE(apr_status_t) apr_socket_recv(apr_socket_t *sock, - char *buf, apr_size_t *len); - -/** - * Setup socket options for the specified socket - * @param sock The socket to set up. - * @param opt The option we would like to configure. One of: - *
    - *            APR_SO_DEBUG      --  turn on debugging information 
    - *            APR_SO_KEEPALIVE  --  keep connections active
    - *            APR_SO_LINGER     --  lingers on close if data is present
    - *            APR_SO_NONBLOCK   --  Turns blocking on/off for socket
    - *                                  When this option is enabled, use
    - *                                  the APR_STATUS_IS_EAGAIN() macro to
    - *                                  see if a send or receive function
    - *                                  could not transfer data without
    - *                                  blocking.
    - *            APR_SO_REUSEADDR  --  The rules used in validating addresses
    - *                                  supplied to bind should allow reuse
    - *                                  of local addresses.
    - *            APR_SO_SNDBUF     --  Set the SendBufferSize
    - *            APR_SO_RCVBUF     --  Set the ReceiveBufferSize
    - * 
    - * @param on Value for the option. - */ -APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock, - apr_int32_t opt, apr_int32_t on); - -/** - * Setup socket timeout for the specified socket - * @param sock The socket to set up. - * @param t Value for the timeout. - *
    - *   t > 0  -- read and write calls return APR_TIMEUP if specified time
    - *             elapsess with no data read or written
    - *   t == 0 -- read and write calls never block
    - *   t < 0  -- read and write calls block
    - * 
    - */ -APR_DECLARE(apr_status_t) apr_socket_timeout_set(apr_socket_t *sock, - apr_interval_time_t t); - -/** - * Query socket options for the specified socket - * @param sock The socket to query - * @param opt The option we would like to query. One of: - *
    - *            APR_SO_DEBUG      --  turn on debugging information 
    - *            APR_SO_KEEPALIVE  --  keep connections active
    - *            APR_SO_LINGER     --  lingers on close if data is present
    - *            APR_SO_NONBLOCK   --  Turns blocking on/off for socket
    - *            APR_SO_REUSEADDR  --  The rules used in validating addresses
    - *                                  supplied to bind should allow reuse
    - *                                  of local addresses.
    - *            APR_SO_SNDBUF     --  Set the SendBufferSize
    - *            APR_SO_RCVBUF     --  Set the ReceiveBufferSize
    - *            APR_SO_DISCONNECTED -- Query the disconnected state of the socket.
    - *                                  (Currently only used on Windows)
    - * 
    - * @param on Socket option returned on the call. - */ -APR_DECLARE(apr_status_t) apr_socket_opt_get(apr_socket_t *sock, - apr_int32_t opt, apr_int32_t *on); - -/** - * Query socket timeout for the specified socket - * @param sock The socket to query - * @param t Socket timeout returned from the query. - */ -APR_DECLARE(apr_status_t) apr_socket_timeout_get(apr_socket_t *sock, - apr_interval_time_t *t); - -/** - * Query the specified socket if at the OOB/Urgent data mark - * @param sock The socket to query - * @param atmark Is set to true if socket is at the OOB/urgent mark, - * otherwise is set to false. - */ -APR_DECLARE(apr_status_t) apr_socket_atmark(apr_socket_t *sock, - int *atmark); - -/** - * Return an address associated with a socket; either the address to - * which the socket is bound locally or the the address of the peer - * to which the socket is connected. - * @param sa The returned apr_sockaddr_t. - * @param which Whether to retrieve the local or remote address - * @param sock The socket to use - */ -APR_DECLARE(apr_status_t) apr_socket_addr_get(apr_sockaddr_t **sa, - apr_interface_e which, - apr_socket_t *sock); - -/** - * Return the IP address (in numeric address string format) in - * an APR socket address. APR will allocate storage for the IP address - * string from the pool of the apr_sockaddr_t. - * @param addr The IP address. - * @param sockaddr The socket address to reference. - */ -APR_DECLARE(apr_status_t) apr_sockaddr_ip_get(char **addr, - apr_sockaddr_t *sockaddr); - -/** - * Write the IP address (in numeric address string format) of the APR - * socket address @a sockaddr into the buffer @a buf (of size @a buflen). - * @param sockaddr The socket address to reference. - */ -APR_DECLARE(apr_status_t) apr_sockaddr_ip_getbuf(char *buf, apr_size_t buflen, - apr_sockaddr_t *sockaddr); - -/** - * See if the IP addresses in two APR socket addresses are - * equivalent. Appropriate logic is present for comparing - * IPv4-mapped IPv6 addresses with IPv4 addresses. - * - * @param addr1 One of the APR socket addresses. - * @param addr2 The other APR socket address. - * @remark The return value will be non-zero if the addresses - * are equivalent. - */ -APR_DECLARE(int) apr_sockaddr_equal(const apr_sockaddr_t *addr1, - const apr_sockaddr_t *addr2); - -/** -* Return the type of the socket. -* @param sock The socket to query. -* @param type The returned type (e.g., SOCK_STREAM). -*/ -APR_DECLARE(apr_status_t) apr_socket_type_get(apr_socket_t *sock, - int *type); - -/** - * Given an apr_sockaddr_t and a service name, set the port for the service - * @param sockaddr The apr_sockaddr_t that will have its port set - * @param servname The name of the service you wish to use - */ -APR_DECLARE(apr_status_t) apr_getservbyname(apr_sockaddr_t *sockaddr, - const char *servname); -/** - * Build an ip-subnet representation from an IP address and optional netmask or - * number-of-bits. - * @param ipsub The new ip-subnet representation - * @param ipstr The input IP address string - * @param mask_or_numbits The input netmask or number-of-bits string, or NULL - * @param p The pool to allocate from - */ -APR_DECLARE(apr_status_t) apr_ipsubnet_create(apr_ipsubnet_t **ipsub, - const char *ipstr, - const char *mask_or_numbits, - apr_pool_t *p); - -/** - * Test the IP address in an apr_sockaddr_t against a pre-built ip-subnet - * representation. - * @param ipsub The ip-subnet representation - * @param sa The socket address to test - * @return non-zero if the socket address is within the subnet, 0 otherwise - */ -APR_DECLARE(int) apr_ipsubnet_test(apr_ipsubnet_t *ipsub, apr_sockaddr_t *sa); - -#if APR_HAS_SO_ACCEPTFILTER || defined(DOXYGEN) -/** - * Set an OS level accept filter. - * @param sock The socket to put the accept filter on. - * @param name The accept filter - * @param args Any extra args to the accept filter. Passing NULL here removes - * the accept filter. - */ -apr_status_t apr_socket_accept_filter(apr_socket_t *sock, char *name, - char *args); -#endif - -/** - * Return the protocol of the socket. - * @param sock The socket to query. - * @param protocol The returned protocol (e.g., APR_PROTO_TCP). - */ -APR_DECLARE(apr_status_t) apr_socket_protocol_get(apr_socket_t *sock, - int *protocol); - -/** - * Get the pool used by the socket. - */ -APR_POOL_DECLARE_ACCESSOR(socket); - -/** - * Set a socket to be inherited by child processes. - */ -APR_DECLARE_INHERIT_SET(socket); - -/** - * Unset a socket from being inherited by child processes. - */ -APR_DECLARE_INHERIT_UNSET(socket); - -/** - * @defgroup apr_mcast IP Multicast - * @{ - */ - -/** - * Join a Multicast Group - * @param sock The socket to join a multicast group - * @param join The address of the multicast group to join - * @param iface Address of the interface to use. If NULL is passed, the - * default multicast interface will be used. (OS Dependent) - * @param source Source Address to accept transmissions from (non-NULL - * implies Source-Specific Multicast) - */ -APR_DECLARE(apr_status_t) apr_mcast_join(apr_socket_t *sock, - apr_sockaddr_t *join, - apr_sockaddr_t *iface, - apr_sockaddr_t *source); - -/** - * Leave a Multicast Group. All arguments must be the same as - * apr_mcast_join. - * @param sock The socket to leave a multicast group - * @param addr The address of the multicast group to leave - * @param iface Address of the interface to use. If NULL is passed, the - * default multicast interface will be used. (OS Dependent) - * @param source Source Address to accept transmissions from (non-NULL - * implies Source-Specific Multicast) - */ -APR_DECLARE(apr_status_t) apr_mcast_leave(apr_socket_t *sock, - apr_sockaddr_t *addr, - apr_sockaddr_t *iface, - apr_sockaddr_t *source); - -/** - * Set the Multicast Time to Live (ttl) for a multicast transmission. - * @param sock The socket to set the multicast ttl - * @param ttl Time to live to Assign. 0-255, default=1 - * @remark If the TTL is 0, packets will only be seen by sockets on - * the local machine, and only when multicast loopback is enabled. - */ -APR_DECLARE(apr_status_t) apr_mcast_hops(apr_socket_t *sock, - apr_byte_t ttl); - -/** - * Toggle IP Multicast Loopback - * @param sock The socket to set multicast loopback - * @param opt 0=disable, 1=enable - */ -APR_DECLARE(apr_status_t) apr_mcast_loopback(apr_socket_t *sock, - apr_byte_t opt); - - -/** - * Set the Interface to be used for outgoing Multicast Transmissions. - * @param sock The socket to set the multicast interface on - * @param iface Address of the interface to use for Multicast - */ -APR_DECLARE(apr_status_t) apr_mcast_interface(apr_socket_t *sock, - apr_sockaddr_t *iface); - -/** @} */ - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ! APR_NETWORK_IO_H */ - diff --git a/libs/apr/include/apr_poll.h b/libs/apr/include/apr_poll.h deleted file mode 100644 index 3e8d092b..00000000 --- a/libs/apr/include/apr_poll.h +++ /dev/null @@ -1,415 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_POLL_H -#define APR_POLL_H -/** - * @file apr_poll.h - * @brief APR Poll interface - */ -#include "apr.h" -#include "apr_pools.h" -#include "apr_errno.h" -#include "apr_inherit.h" -#include "apr_file_io.h" -#include "apr_network_io.h" - -#if APR_HAVE_NETINET_IN_H -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup apr_poll Poll Routines - * @ingroup APR - * @{ - */ - -/** - * Poll options - */ -#define APR_POLLIN 0x001 /**< Can read without blocking */ -#define APR_POLLPRI 0x002 /**< Priority data available */ -#define APR_POLLOUT 0x004 /**< Can write without blocking */ -#define APR_POLLERR 0x010 /**< Pending error */ -#define APR_POLLHUP 0x020 /**< Hangup occurred */ -#define APR_POLLNVAL 0x040 /**< Descriptor invalid */ - -/** - * Pollset Flags - */ -#define APR_POLLSET_THREADSAFE 0x001 /**< Adding or removing a descriptor is - * thread-safe - */ -#define APR_POLLSET_NOCOPY 0x002 /**< Descriptors passed to apr_pollset_add() - * are not copied - */ -#define APR_POLLSET_WAKEABLE 0x004 /**< Poll operations are interruptable by - * apr_pollset_wakeup() - */ -#define APR_POLLSET_NODEFAULT 0x010 /**< Do not try to use the default method if - * the specified non-default method cannot be - * used - */ - -/** - * Pollset Methods - */ -typedef enum { - APR_POLLSET_DEFAULT, /**< Platform default poll method */ - APR_POLLSET_SELECT, /**< Poll uses select method */ - APR_POLLSET_KQUEUE, /**< Poll uses kqueue method */ - APR_POLLSET_PORT, /**< Poll uses Solaris event port method */ - APR_POLLSET_EPOLL, /**< Poll uses epoll method */ - APR_POLLSET_POLL /**< Poll uses poll method */ -} apr_pollset_method_e; - -/** Used in apr_pollfd_t to determine what the apr_descriptor is */ -typedef enum { - APR_NO_DESC, /**< nothing here */ - APR_POLL_SOCKET, /**< descriptor refers to a socket */ - APR_POLL_FILE, /**< descriptor refers to a file */ - APR_POLL_LASTDESC /**< @deprecated descriptor is the last one in the list */ -} apr_datatype_e ; - -/** Union of either an APR file or socket. */ -typedef union { - apr_file_t *f; /**< file */ - apr_socket_t *s; /**< socket */ -} apr_descriptor; - -/** @see apr_pollfd_t */ -typedef struct apr_pollfd_t apr_pollfd_t; - -/** Poll descriptor set. */ -struct apr_pollfd_t { - apr_pool_t *p; /**< associated pool */ - apr_datatype_e desc_type; /**< descriptor type */ - apr_int16_t reqevents; /**< requested events */ - apr_int16_t rtnevents; /**< returned events */ - apr_descriptor desc; /**< @see apr_descriptor */ - void *client_data; /**< allows app to associate context */ -}; - - -/* General-purpose poll API for arbitrarily large numbers of - * file descriptors - */ - -/** Opaque structure used for pollset API */ -typedef struct apr_pollset_t apr_pollset_t; - -/** - * Set up a pollset object - * @param pollset The pointer in which to return the newly created object - * @param size The maximum number of descriptors that this pollset can hold - * @param p The pool from which to allocate the pollset - * @param flags Optional flags to modify the operation of the pollset. - * - * @remark If flags contains APR_POLLSET_THREADSAFE, then a pollset is - * created on which it is safe to make concurrent calls to - * apr_pollset_add(), apr_pollset_remove() and apr_pollset_poll() - * from separate threads. This feature is only supported on some - * platforms; the apr_pollset_create() call will fail with - * APR_ENOTIMPL on platforms where it is not supported. - * @remark If flags contains APR_POLLSET_WAKEABLE, then a pollset is - * created with an additional internal pipe object used for the - * apr_pollset_wakeup() call. The actual size of pollset is - * in that case size + 1. This feature is only supported on some - * platforms; the apr_pollset_create() call will fail with - * APR_ENOTIMPL on platforms where it is not supported. - * @remark If flags contains APR_POLLSET_NOCOPY, then the apr_pollfd_t - * structures passed to apr_pollset_add() are not copied and - * must have a lifetime at least as long as the pollset. - * @remark Some poll methods (including APR_POLLSET_KQUEUE, - * APR_POLLSET_PORT, and APR_POLLSET_EPOLL) do not have a - * fixed limit on the size of the pollset. For these methods, - * the size parameter controls the maximum number of - * descriptors that will be returned by a single call to - * apr_pollset_poll(). - */ -APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags); - -/** - * Set up a pollset object - * @param pollset The pointer in which to return the newly created object - * @param size The maximum number of descriptors that this pollset can hold - * @param p The pool from which to allocate the pollset - * @param flags Optional flags to modify the operation of the pollset. - * @param method Poll method to use. See #apr_pollset_method_e. If this - * method cannot be used, the default method will be used unless the - * APR_POLLSET_NODEFAULT flag has been specified. - * - * @remark If flags contains APR_POLLSET_THREADSAFE, then a pollset is - * created on which it is safe to make concurrent calls to - * apr_pollset_add(), apr_pollset_remove() and apr_pollset_poll() - * from separate threads. This feature is only supported on some - * platforms; the apr_pollset_create_ex() call will fail with - * APR_ENOTIMPL on platforms where it is not supported. - * @remark If flags contains APR_POLLSET_WAKEABLE, then a pollset is - * created with additional internal pipe object used for the - * apr_pollset_wakeup() call. The actual size of pollset is - * in that case size + 1. This feature is only supported on some - * platforms; the apr_pollset_create_ex() call will fail with - * APR_ENOTIMPL on platforms where it is not supported. - * @remark If flags contains APR_POLLSET_NOCOPY, then the apr_pollfd_t - * structures passed to apr_pollset_add() are not copied and - * must have a lifetime at least as long as the pollset. - * @remark Some poll methods (including APR_POLLSET_KQUEUE, - * APR_POLLSET_PORT, and APR_POLLSET_EPOLL) do not have a - * fixed limit on the size of the pollset. For these methods, - * the size parameter controls the maximum number of - * descriptors that will be returned by a single call to - * apr_pollset_poll(). - */ -APR_DECLARE(apr_status_t) apr_pollset_create_ex(apr_pollset_t **pollset, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags, - apr_pollset_method_e method); - -/** - * Destroy a pollset object - * @param pollset The pollset to destroy - */ -APR_DECLARE(apr_status_t) apr_pollset_destroy(apr_pollset_t *pollset); - -/** - * Add a socket or file descriptor to a pollset - * @param pollset The pollset to which to add the descriptor - * @param descriptor The descriptor to add - * @remark If you set client_data in the descriptor, that value - * will be returned in the client_data field whenever this - * descriptor is signalled in apr_pollset_poll(). - * @remark If the pollset has been created with APR_POLLSET_THREADSAFE - * and thread T1 is blocked in a call to apr_pollset_poll() for - * this same pollset that is being modified via apr_pollset_add() - * in thread T2, the currently executing apr_pollset_poll() call in - * T1 will either: (1) automatically include the newly added descriptor - * in the set of descriptors it is watching or (2) return immediately - * with APR_EINTR. Option (1) is recommended, but option (2) is - * allowed for implementations where option (1) is impossible - * or impractical. - * @remark If the pollset has been created with APR_POLLSET_NOCOPY, the - * apr_pollfd_t structure referenced by descriptor will not be copied - * and must have a lifetime at least as long as the pollset. - * @remark Do not add the same socket or file descriptor to the same pollset - * multiple times, even if the requested events differ for the - * different calls to apr_pollset_add(). If the events of interest - * for a descriptor change, you must first remove the descriptor - * from the pollset with apr_pollset_remove(), then add it again - * specifying all requested events. - */ -APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor); - -/** - * Remove a descriptor from a pollset - * @param pollset The pollset from which to remove the descriptor - * @param descriptor The descriptor to remove - * @remark If the pollset has been created with APR_POLLSET_THREADSAFE - * and thread T1 is blocked in a call to apr_pollset_poll() for - * this same pollset that is being modified via apr_pollset_remove() - * in thread T2, the currently executing apr_pollset_poll() call in - * T1 will either: (1) automatically exclude the newly added descriptor - * in the set of descriptors it is watching or (2) return immediately - * with APR_EINTR. Option (1) is recommended, but option (2) is - * allowed for implementations where option (1) is impossible - * or impractical. - * @remark apr_pollset_remove() cannot be used to remove a subset of requested - * events for a descriptor. The reqevents field in the apr_pollfd_t - * parameter must contain the same value when removing as when adding. - */ -APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor); - -/** - * Block for activity on the descriptor(s) in a pollset - * @param pollset The pollset to use - * @param timeout The amount of time in microseconds to wait. This is a - * maximum, not a minimum. If a descriptor is signalled, the - * function will return before this time. If timeout is - * negative, the function will block until a descriptor is - * signalled or until apr_pollset_wakeup() has been called. - * @param num Number of signalled descriptors (output parameter) - * @param descriptors Array of signalled descriptors (output parameter) - * @remark APR_EINTR will be returned if the pollset has been created with - * APR_POLLSET_WAKEABLE, apr_pollset_wakeup() has been called while - * waiting for activity, and there were no signalled descriptors at the - * time of the wakeup call. - * @remark Multiple signalled conditions for the same descriptor may be reported - * in one or more returned apr_pollfd_t structures, depending on the - * implementation. - * @bug With versions 1.4.2 and prior on Windows, a call with no descriptors - * and timeout will return immediately with the wrong error code. - */ -APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset, - apr_interval_time_t timeout, - apr_int32_t *num, - const apr_pollfd_t **descriptors); - -/** - * Interrupt the blocked apr_pollset_poll() call. - * @param pollset The pollset to use - * @remark If the pollset was not created with APR_POLLSET_WAKEABLE the - * return value is APR_EINIT. - */ -APR_DECLARE(apr_status_t) apr_pollset_wakeup(apr_pollset_t *pollset); - -/** - * Poll the descriptors in the poll structure - * @param aprset The poll structure we will be using. - * @param numsock The number of descriptors we are polling - * @param nsds The number of descriptors signalled (output parameter) - * @param timeout The amount of time in microseconds to wait. This is a - * maximum, not a minimum. If a descriptor is signalled, the - * function will return before this time. If timeout is - * negative, the function will block until a descriptor is - * signalled or until apr_pollset_wakeup() has been called. - * @remark The number of descriptors signalled is returned in the third argument. - * This is a blocking call, and it will not return until either a - * descriptor has been signalled or the timeout has expired. - * @remark The rtnevents field in the apr_pollfd_t array will only be filled- - * in if the return value is APR_SUCCESS. - * @bug With versions 1.4.2 and prior on Windows, a call with no descriptors - * and timeout will return immediately with the wrong error code. - */ -APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, apr_int32_t numsock, - apr_int32_t *nsds, - apr_interval_time_t timeout); - -/** - * Return a printable representation of the pollset method. - * @param pollset The pollset to use - */ -APR_DECLARE(const char *) apr_pollset_method_name(apr_pollset_t *pollset); - -/** - * Return a printable representation of the default pollset method - * (APR_POLLSET_DEFAULT). - */ -APR_DECLARE(const char *) apr_poll_method_defname(void); - -/** Opaque structure used for pollset API */ -typedef struct apr_pollcb_t apr_pollcb_t; - -/** - * Set up a pollcb object - * @param pollcb The pointer in which to return the newly created object - * @param size The maximum number of descriptors that a single _poll can return. - * @param p The pool from which to allocate the pollcb - * @param flags Optional flags to modify the operation of the pollcb. - * - * @remark Pollcb is only supported on some platforms; the apr_pollcb_create() - * call will fail with APR_ENOTIMPL on platforms where it is not supported. - */ -APR_DECLARE(apr_status_t) apr_pollcb_create(apr_pollcb_t **pollcb, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags); - -/** - * Set up a pollcb object - * @param pollcb The pointer in which to return the newly created object - * @param size The maximum number of descriptors that a single _poll can return. - * @param p The pool from which to allocate the pollcb - * @param flags Optional flags to modify the operation of the pollcb. - * @param method Poll method to use. See #apr_pollset_method_e. If this - * method cannot be used, the default method will be used unless the - * APR_POLLSET_NODEFAULT flag has been specified. - * - * @remark Pollcb is only supported on some platforms; the apr_pollcb_create_ex() - * call will fail with APR_ENOTIMPL on platforms where it is not supported. - */ -APR_DECLARE(apr_status_t) apr_pollcb_create_ex(apr_pollcb_t **pollcb, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags, - apr_pollset_method_e method); - -/** - * Add a socket or file descriptor to a pollcb - * @param pollcb The pollcb to which to add the descriptor - * @param descriptor The descriptor to add - * @remark If you set client_data in the descriptor, that value will be - * returned in the client_data field whenever this descriptor is - * signalled in apr_pollcb_poll(). - * @remark Unlike the apr_pollset API, the descriptor is not copied, and users - * must retain the memory used by descriptor, as the same pointer will - * be returned to them from apr_pollcb_poll. - * @remark Do not add the same socket or file descriptor to the same pollcb - * multiple times, even if the requested events differ for the - * different calls to apr_pollcb_add(). If the events of interest - * for a descriptor change, you must first remove the descriptor - * from the pollcb with apr_pollcb_remove(), then add it again - * specifying all requested events. - */ -APR_DECLARE(apr_status_t) apr_pollcb_add(apr_pollcb_t *pollcb, - apr_pollfd_t *descriptor); -/** - * Remove a descriptor from a pollcb - * @param pollcb The pollcb from which to remove the descriptor - * @param descriptor The descriptor to remove - * @remark apr_pollcb_remove() cannot be used to remove a subset of requested - * events for a descriptor. The reqevents field in the apr_pollfd_t - * parameter must contain the same value when removing as when adding. - */ -APR_DECLARE(apr_status_t) apr_pollcb_remove(apr_pollcb_t *pollcb, - apr_pollfd_t *descriptor); - -/** Function prototype for pollcb handlers - * @param baton Opaque baton passed into apr_pollcb_poll() - * @param descriptor Contains the notification for an active descriptor, - * the rtnevents member contains what events were triggered - * for this descriptor. - */ -typedef apr_status_t (*apr_pollcb_cb_t)(void *baton, apr_pollfd_t *descriptor); - -/** - * Block for activity on the descriptor(s) in a pollcb - * @param pollcb The pollcb to use - * @param timeout The amount of time in microseconds to wait. This is a - * maximum, not a minimum. If a descriptor is signalled, the - * function will return before this time. If timeout is - * negative, the function will block until a descriptor is - * signalled. - * @param func Callback function to call for each active descriptor. - * @param baton Opaque baton passed to the callback function. - * @remark Multiple signalled conditions for the same descriptor may be reported - * in one or more calls to the callback function, depending on the - * implementation. - * @bug With versions 1.4.2 and prior on Windows, a call with no descriptors - * and timeout will return immediately with the wrong error code. - */ -APR_DECLARE(apr_status_t) apr_pollcb_poll(apr_pollcb_t *pollcb, - apr_interval_time_t timeout, - apr_pollcb_cb_t func, - void *baton); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ! APR_POLL_H */ - diff --git a/libs/apr/include/apr_pools.h b/libs/apr/include/apr_pools.h deleted file mode 100644 index 7ae1ed6b..00000000 --- a/libs/apr/include/apr_pools.h +++ /dev/null @@ -1,788 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_POOLS_H -#define APR_POOLS_H - -/** - * @file apr_pools.h - * @brief APR memory allocation - * - * Resource allocation routines... - * - * designed so that we don't have to keep track of EVERYTHING so that - * it can be explicitly freed later (a fundamentally unsound strategy --- - * particularly in the presence of die()). - * - * Instead, we maintain pools, and allocate items (both memory and I/O - * handlers) from the pools --- currently there are two, one for - * per-transaction info, and one for config info. When a transaction is - * over, we can delete everything in the per-transaction apr_pool_t without - * fear, and without thinking too hard about it either. - * - * Note that most operations on pools are not thread-safe: a single pool - * should only be accessed by a single thread at any given time. The one - * exception to this rule is creating a subpool of a given pool: one or more - * threads can safely create subpools at the same time that another thread - * accesses the parent pool. - */ - -#include "apr.h" -#include "apr_errno.h" -#include "apr_general.h" /* for APR_STRINGIFY */ -#define APR_WANT_MEMFUNC /**< for no good reason? */ -#include "apr_want.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup apr_pools Memory Pool Functions - * @ingroup APR - * @{ - */ - -/** The fundamental pool type */ -typedef struct apr_pool_t apr_pool_t; - - -/** - * Declaration helper macro to construct apr_foo_pool_get()s. - * - * This standardized macro is used by opaque (APR) data types to return - * the apr_pool_t that is associated with the data type. - * - * APR_POOL_DECLARE_ACCESSOR() is used in a header file to declare the - * accessor function. A typical usage and result would be: - *
    - *    APR_POOL_DECLARE_ACCESSOR(file);
    - * becomes:
    - *    APR_DECLARE(apr_pool_t *) apr_file_pool_get(apr_file_t *ob);
    - * 
    - * @remark Doxygen unwraps this macro (via doxygen.conf) to provide - * actual help for each specific occurance of apr_foo_pool_get. - * @remark the linkage is specified for APR. It would be possible to expand - * the macros to support other linkages. - */ -#define APR_POOL_DECLARE_ACCESSOR(type) \ - APR_DECLARE(apr_pool_t *) apr_##type##_pool_get \ - (const apr_##type##_t *the##type) - -/** - * Implementation helper macro to provide apr_foo_pool_get()s. - * - * In the implementation, the APR_POOL_IMPLEMENT_ACCESSOR() is used to - * actually define the function. It assumes the field is named "pool". - */ -#define APR_POOL_IMPLEMENT_ACCESSOR(type) \ - APR_DECLARE(apr_pool_t *) apr_##type##_pool_get \ - (const apr_##type##_t *the##type) \ - { return the##type->pool; } - - -/** - * Pool debug levels - * - *
    - * | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
    - * ---------------------------------
    - * |   |   |   |   |   |   |   | x |  General debug code enabled (useful in
    - *                                    combination with --with-efence).
    - *
    - * |   |   |   |   |   |   | x |   |  Verbose output on stderr (report
    - *                                    CREATE, CLEAR, DESTROY).
    - *
    - * |   |   |   | x |   |   |   |   |  Verbose output on stderr (report
    - *                                    PALLOC, PCALLOC).
    - *
    - * |   |   |   |   |   | x |   |   |  Lifetime checking. On each use of a
    - *                                    pool, check its lifetime.  If the pool
    - *                                    is out of scope, abort().
    - *                                    In combination with the verbose flag
    - *                                    above, it will output LIFE in such an
    - *                                    event prior to aborting.
    - *
    - * |   |   |   |   | x |   |   |   |  Pool owner checking.  On each use of a
    - *                                    pool, check if the current thread is the
    - *                                    pools owner.  If not, abort().  In
    - *                                    combination with the verbose flag above,
    - *                                    it will output OWNER in such an event
    - *                                    prior to aborting.  Use the debug
    - *                                    function apr_pool_owner_set() to switch
    - *                                    a pools ownership.
    - *
    - * When no debug level was specified, assume general debug mode.
    - * If level 0 was specified, debugging is switched off
    - * 
    - */ -#if defined(APR_POOL_DEBUG) -/* If APR_POOL_DEBUG is blank, we get 1; if it is a number, we get -1. */ -#if (APR_POOL_DEBUG - APR_POOL_DEBUG -1 == 1) -#undef APR_POOL_DEBUG -#define APR_POOL_DEBUG 1 -#endif -#else -#define APR_POOL_DEBUG 0 -#endif - -/** the place in the code where the particular function was called */ -#define APR_POOL__FILE_LINE__ __FILE__ ":" APR_STRINGIFY(__LINE__) - - - -/** A function that is called when allocation fails. */ -typedef int (*apr_abortfunc_t)(int retcode); - -/* - * APR memory structure manipulators (pools, tables, and arrays). - */ - -/* - * Initialization - */ - -/** - * Setup all of the internal structures required to use pools - * @remark Programs do NOT need to call this directly. APR will call this - * automatically from apr_initialize. - * @internal - */ -APR_DECLARE(apr_status_t) apr_pool_initialize(void); - -/** - * Tear down all of the internal structures required to use pools - * @remark Programs do NOT need to call this directly. APR will call this - * automatically from apr_terminate. - * @internal - */ -APR_DECLARE(void) apr_pool_terminate(void); - - -/* - * Pool creation/destruction - */ - -#include "apr_allocator.h" - -/** - * Create a new pool. - * @param newpool The pool we have just created. - * @param parent The parent pool. If this is NULL, the new pool is a root - * pool. If it is non-NULL, the new pool will inherit all - * of its parent pool's attributes, except the apr_pool_t will - * be a sub-pool. - * @param abort_fn A function to use if the pool cannot allocate more memory. - * @param allocator The allocator to use with the new pool. If NULL the - * allocator of the parent pool will be used. - * @remark This function is thread-safe, in the sense that multiple threads - * can safely create subpools of the same parent pool concurrently. - * Similarly, a subpool can be created by one thread at the same - * time that another thread accesses the parent pool. - */ -APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool, - apr_pool_t *parent, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator); - -/** - * Create a new pool. - * @deprecated @see apr_pool_create_unmanaged_ex. - */ -APR_DECLARE(apr_status_t) apr_pool_create_core_ex(apr_pool_t **newpool, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator); - -/** - * Create a new unmanaged pool. - * @param newpool The pool we have just created. - * @param abort_fn A function to use if the pool cannot allocate more memory. - * @param allocator The allocator to use with the new pool. If NULL a - * new allocator will be crated with newpool as owner. - * @remark An unmanaged pool is a special pool without a parent; it will - * NOT be destroyed upon apr_terminate. It must be explicitly - * destroyed by calling apr_pool_destroy, to prevent memory leaks. - * Use of this function is discouraged, think twice about whether - * you really really need it. - */ -APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex(apr_pool_t **newpool, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator); - -/** - * Debug version of apr_pool_create_ex. - * @param newpool @see apr_pool_create. - * @param parent @see apr_pool_create. - * @param abort_fn @see apr_pool_create. - * @param allocator @see apr_pool_create. - * @param file_line Where the function is called from. - * This is usually APR_POOL__FILE_LINE__. - * @remark Only available when APR_POOL_DEBUG is defined. - * Call this directly if you have you apr_pool_create_ex - * calls in a wrapper function and wish to override - * the file_line argument to reflect the caller of - * your wrapper function. If you do not have - * apr_pool_create_ex in a wrapper, trust the macro - * and don't call apr_pool_create_ex_debug directly. - */ -APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool, - apr_pool_t *parent, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator, - const char *file_line); - -#if APR_POOL_DEBUG -#define apr_pool_create_ex(newpool, parent, abort_fn, allocator) \ - apr_pool_create_ex_debug(newpool, parent, abort_fn, allocator, \ - APR_POOL__FILE_LINE__) -#endif - -/** - * Debug version of apr_pool_create_core_ex. - * @deprecated @see apr_pool_create_unmanaged_ex_debug. - */ -APR_DECLARE(apr_status_t) apr_pool_create_core_ex_debug(apr_pool_t **newpool, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator, - const char *file_line); - -/** - * Debug version of apr_pool_create_unmanaged_ex. - * @param newpool @see apr_pool_create_unmanaged. - * @param abort_fn @see apr_pool_create_unmanaged. - * @param allocator @see apr_pool_create_unmanaged. - * @param file_line Where the function is called from. - * This is usually APR_POOL__FILE_LINE__. - * @remark Only available when APR_POOL_DEBUG is defined. - * Call this directly if you have you apr_pool_create_unmanaged_ex - * calls in a wrapper function and wish to override - * the file_line argument to reflect the caller of - * your wrapper function. If you do not have - * apr_pool_create_core_ex in a wrapper, trust the macro - * and don't call apr_pool_create_core_ex_debug directly. - */ -APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex_debug(apr_pool_t **newpool, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator, - const char *file_line); - -#if APR_POOL_DEBUG -#define apr_pool_create_core_ex(newpool, abort_fn, allocator) \ - apr_pool_create_unmanaged_ex_debug(newpool, abort_fn, allocator, \ - APR_POOL__FILE_LINE__) - -#define apr_pool_create_unmanaged_ex(newpool, abort_fn, allocator) \ - apr_pool_create_unmanaged_ex_debug(newpool, abort_fn, allocator, \ - APR_POOL__FILE_LINE__) - -#endif - -/** - * Create a new pool. - * @param newpool The pool we have just created. - * @param parent The parent pool. If this is NULL, the new pool is a root - * pool. If it is non-NULL, the new pool will inherit all - * of its parent pool's attributes, except the apr_pool_t will - * be a sub-pool. - * @remark This function is thread-safe, in the sense that multiple threads - * can safely create subpools of the same parent pool concurrently. - * Similarly, a subpool can be created by one thread at the same - * time that another thread accesses the parent pool. - */ -#if defined(DOXYGEN) -APR_DECLARE(apr_status_t) apr_pool_create(apr_pool_t **newpool, - apr_pool_t *parent); -#else -#if APR_POOL_DEBUG -#define apr_pool_create(newpool, parent) \ - apr_pool_create_ex_debug(newpool, parent, NULL, NULL, \ - APR_POOL__FILE_LINE__) -#else -#define apr_pool_create(newpool, parent) \ - apr_pool_create_ex(newpool, parent, NULL, NULL) -#endif -#endif - -/** - * Create a new pool. - * @param newpool The pool we have just created. - */ -#if defined(DOXYGEN) -APR_DECLARE(apr_status_t) apr_pool_create_core(apr_pool_t **newpool); -APR_DECLARE(apr_status_t) apr_pool_create_unmanaged(apr_pool_t **newpool); -#else -#if APR_POOL_DEBUG -#define apr_pool_create_core(newpool) \ - apr_pool_create_unmanaged_ex_debug(newpool, NULL, NULL, \ - APR_POOL__FILE_LINE__) -#define apr_pool_create_unmanaged(newpool) \ - apr_pool_create_unmanaged_ex_debug(newpool, NULL, NULL, \ - APR_POOL__FILE_LINE__) -#else -#define apr_pool_create_core(newpool) \ - apr_pool_create_unmanaged_ex(newpool, NULL, NULL) -#define apr_pool_create_unmanaged(newpool) \ - apr_pool_create_unmanaged_ex(newpool, NULL, NULL) -#endif -#endif - -/** - * Find the pool's allocator - * @param pool The pool to get the allocator from. - */ -APR_DECLARE(apr_allocator_t *) apr_pool_allocator_get(apr_pool_t *pool); - -/** - * Clear all memory in the pool and run all the cleanups. This also destroys all - * subpools. - * @param p The pool to clear - * @remark This does not actually free the memory, it just allows the pool - * to re-use this memory for the next allocation. - * @see apr_pool_destroy() - */ -APR_DECLARE(void) apr_pool_clear(apr_pool_t *p); - -/** - * Debug version of apr_pool_clear. - * @param p See: apr_pool_clear. - * @param file_line Where the function is called from. - * This is usually APR_POOL__FILE_LINE__. - * @remark Only available when APR_POOL_DEBUG is defined. - * Call this directly if you have you apr_pool_clear - * calls in a wrapper function and wish to override - * the file_line argument to reflect the caller of - * your wrapper function. If you do not have - * apr_pool_clear in a wrapper, trust the macro - * and don't call apr_pool_destroy_clear directly. - */ -APR_DECLARE(void) apr_pool_clear_debug(apr_pool_t *p, - const char *file_line); - -#if APR_POOL_DEBUG -#define apr_pool_clear(p) \ - apr_pool_clear_debug(p, APR_POOL__FILE_LINE__) -#endif - -/** - * Destroy the pool. This takes similar action as apr_pool_clear() and then - * frees all the memory. - * @param p The pool to destroy - * @remark This will actually free the memory - */ -APR_DECLARE(void) apr_pool_destroy(apr_pool_t *p); - -/** - * Debug version of apr_pool_destroy. - * @param p See: apr_pool_destroy. - * @param file_line Where the function is called from. - * This is usually APR_POOL__FILE_LINE__. - * @remark Only available when APR_POOL_DEBUG is defined. - * Call this directly if you have you apr_pool_destroy - * calls in a wrapper function and wish to override - * the file_line argument to reflect the caller of - * your wrapper function. If you do not have - * apr_pool_destroy in a wrapper, trust the macro - * and don't call apr_pool_destroy_debug directly. - */ -APR_DECLARE(void) apr_pool_destroy_debug(apr_pool_t *p, - const char *file_line); - -#if APR_POOL_DEBUG -#define apr_pool_destroy(p) \ - apr_pool_destroy_debug(p, APR_POOL__FILE_LINE__) -#endif - - -/* - * Memory allocation - */ - -/** - * Allocate a block of memory from a pool - * @param p The pool to allocate from - * @param size The amount of memory to allocate - * @return The allocated memory - */ -APR_DECLARE(void *) apr_palloc(apr_pool_t *p, apr_size_t size); - -/** - * Debug version of apr_palloc - * @param p See: apr_palloc - * @param size See: apr_palloc - * @param file_line Where the function is called from. - * This is usually APR_POOL__FILE_LINE__. - * @return See: apr_palloc - */ -APR_DECLARE(void *) apr_palloc_debug(apr_pool_t *p, apr_size_t size, - const char *file_line); - -#if APR_POOL_DEBUG -#define apr_palloc(p, size) \ - apr_palloc_debug(p, size, APR_POOL__FILE_LINE__) -#endif - -/** - * Allocate a block of memory from a pool and set all of the memory to 0 - * @param p The pool to allocate from - * @param size The amount of memory to allocate - * @return The allocated memory - */ -#if defined(DOXYGEN) -APR_DECLARE(void *) apr_pcalloc(apr_pool_t *p, apr_size_t size); -#elif !APR_POOL_DEBUG -#define apr_pcalloc(p, size) memset(apr_palloc(p, size), 0, size) -#endif - -/** - * Debug version of apr_pcalloc - * @param p See: apr_pcalloc - * @param size See: apr_pcalloc - * @param file_line Where the function is called from. - * This is usually APR_POOL__FILE_LINE__. - * @return See: apr_pcalloc - */ -APR_DECLARE(void *) apr_pcalloc_debug(apr_pool_t *p, apr_size_t size, - const char *file_line); - -#if APR_POOL_DEBUG -#define apr_pcalloc(p, size) \ - apr_pcalloc_debug(p, size, APR_POOL__FILE_LINE__) -#endif - - -/* - * Pool Properties - */ - -/** - * Set the function to be called when an allocation failure occurs. - * @remark If the program wants APR to exit on a memory allocation error, - * then this function can be called to set the callback to use (for - * performing cleanup and then exiting). If this function is not called, - * then APR will return an error and expect the calling program to - * deal with the error accordingly. - */ -APR_DECLARE(void) apr_pool_abort_set(apr_abortfunc_t abortfunc, - apr_pool_t *pool); - -/** - * Get the abort function associated with the specified pool. - * @param pool The pool for retrieving the abort function. - * @return The abort function for the given pool. - */ -APR_DECLARE(apr_abortfunc_t) apr_pool_abort_get(apr_pool_t *pool); - -/** - * Get the parent pool of the specified pool. - * @param pool The pool for retrieving the parent pool. - * @return The parent of the given pool. - */ -APR_DECLARE(apr_pool_t *) apr_pool_parent_get(apr_pool_t *pool); - -/** - * Determine if pool a is an ancestor of pool b. - * @param a The pool to search - * @param b The pool to search for - * @return True if a is an ancestor of b, NULL is considered an ancestor - * of all pools. - * @remark if compiled with APR_POOL_DEBUG, this function will also - * return true if A is a pool which has been guaranteed by the caller - * (using apr_pool_join) to have a lifetime at least as long as some - * ancestor of pool B. - */ -APR_DECLARE(int) apr_pool_is_ancestor(apr_pool_t *a, apr_pool_t *b); - -/** - * Tag a pool (give it a name) - * @param pool The pool to tag - * @param tag The tag - */ -APR_DECLARE(void) apr_pool_tag(apr_pool_t *pool, const char *tag); - - -/* - * User data management - */ - -/** - * Set the data associated with the current pool - * @param data The user data associated with the pool. - * @param key The key to use for association - * @param cleanup The cleanup program to use to cleanup the data (NULL if none) - * @param pool The current pool - * @warning The data to be attached to the pool should have a life span - * at least as long as the pool it is being attached to. - * - * Users of APR must take EXTREME care when choosing a key to - * use for their data. It is possible to accidentally overwrite - * data by choosing a key that another part of the program is using. - * Therefore it is advised that steps are taken to ensure that unique - * keys are used for all of the userdata objects in a particular pool - * (the same key in two different pools or a pool and one of its - * subpools is okay) at all times. Careful namespace prefixing of - * key names is a typical way to help ensure this uniqueness. - * - */ -APR_DECLARE(apr_status_t) apr_pool_userdata_set( - const void *data, - const char *key, - apr_status_t (*cleanup)(void *), - apr_pool_t *pool); - -/** - * Set the data associated with the current pool - * @param data The user data associated with the pool. - * @param key The key to use for association - * @param cleanup The cleanup program to use to cleanup the data (NULL if none) - * @param pool The current pool - * @note same as apr_pool_userdata_set(), except that this version doesn't - * make a copy of the key (this function is useful, for example, when - * the key is a string literal) - * @warning This should NOT be used if the key could change addresses by - * any means between the apr_pool_userdata_setn() call and a - * subsequent apr_pool_userdata_get() on that key, such as if a - * static string is used as a userdata key in a DSO and the DSO could - * be unloaded and reloaded between the _setn() and the _get(). You - * MUST use apr_pool_userdata_set() in such cases. - * @warning More generally, the key and the data to be attached to the - * pool should have a life span at least as long as the pool itself. - * - */ -APR_DECLARE(apr_status_t) apr_pool_userdata_setn( - const void *data, - const char *key, - apr_status_t (*cleanup)(void *), - apr_pool_t *pool); - -/** - * Return the data associated with the current pool. - * @param data The user data associated with the pool. - * @param key The key for the data to retrieve - * @param pool The current pool. - */ -APR_DECLARE(apr_status_t) apr_pool_userdata_get(void **data, const char *key, - apr_pool_t *pool); - - -/** - * @defgroup PoolCleanup Pool Cleanup Functions - * - * Cleanups are performed in the reverse order they were registered. That is: - * Last In, First Out. A cleanup function can safely allocate memory from - * the pool that is being cleaned up. It can also safely register additional - * cleanups which will be run LIFO, directly after the current cleanup - * terminates. Cleanups have to take caution in calling functions that - * create subpools. Subpools, created during cleanup will NOT automatically - * be cleaned up. In other words, cleanups are to clean up after themselves. - * - * @{ - */ - -/** - * Register a function to be called when a pool is cleared or destroyed - * @param p The pool register the cleanup with - * @param data The data to pass to the cleanup function. - * @param plain_cleanup The function to call when the pool is cleared - * or destroyed - * @param child_cleanup The function to call when a child process is about - * to exec - this function is called in the child, obviously! - */ -APR_DECLARE(void) apr_pool_cleanup_register( - apr_pool_t *p, - const void *data, - apr_status_t (*plain_cleanup)(void *), - apr_status_t (*child_cleanup)(void *)); - -/** - * Register a function to be called when a pool is cleared or destroyed. - * - * Unlike apr_pool_cleanup_register which register a cleanup - * that is called AFTER all subpools are destroyed this function register - * a function that will be called before any of the subpool is destoryed. - * - * @param p The pool register the cleanup with - * @param data The data to pass to the cleanup function. - * @param plain_cleanup The function to call when the pool is cleared - * or destroyed - */ -APR_DECLARE(void) apr_pool_pre_cleanup_register( - apr_pool_t *p, - const void *data, - apr_status_t (*plain_cleanup)(void *)); - -/** - * Remove a previously registered cleanup function. - * - * The cleanup most recently registered with @a p having the same values of - * @a data and @a cleanup will be removed. - * - * @param p The pool to remove the cleanup from - * @param data The data of the registered cleanup - * @param cleanup The function to remove from cleanup - * @remarks For some strange reason only the plain_cleanup is handled by this - * function - */ -APR_DECLARE(void) apr_pool_cleanup_kill(apr_pool_t *p, const void *data, - apr_status_t (*cleanup)(void *)); - -/** - * Replace the child cleanup function of a previously registered cleanup. - * - * The cleanup most recently registered with @a p having the same values of - * @a data and @a plain_cleanup will have the registered child cleanup - * function replaced with @a child_cleanup. - * - * @param p The pool of the registered cleanup - * @param data The data of the registered cleanup - * @param plain_cleanup The plain cleanup function of the registered cleanup - * @param child_cleanup The function to register as the child cleanup - */ -APR_DECLARE(void) apr_pool_child_cleanup_set( - apr_pool_t *p, - const void *data, - apr_status_t (*plain_cleanup)(void *), - apr_status_t (*child_cleanup)(void *)); - -/** - * Run the specified cleanup function immediately and unregister it. - * - * The cleanup most recently registered with @a p having the same values of - * @a data and @a cleanup will be removed and @a cleanup will be called - * with @a data as the argument. - * - * @param p The pool to remove the cleanup from - * @param data The data to remove from cleanup - * @param cleanup The function to remove from cleanup - */ -APR_DECLARE(apr_status_t) apr_pool_cleanup_run( - apr_pool_t *p, - void *data, - apr_status_t (*cleanup)(void *)); - -/** - * An empty cleanup function. - * - * Passed to apr_pool_cleanup_register() when no cleanup is required. - * - * @param data The data to cleanup, will not be used by this function. - */ -APR_DECLARE_NONSTD(apr_status_t) apr_pool_cleanup_null(void *data); - -/** - * Run all registered child cleanups, in preparation for an exec() - * call in a forked child -- close files, etc., but *don't* flush I/O - * buffers, *don't* wait for subprocesses, and *don't* free any - * memory. - */ -APR_DECLARE(void) apr_pool_cleanup_for_exec(void); - -/** @} */ - -/** - * @defgroup PoolDebug Pool Debugging functions. - * - * pools have nested lifetimes -- sub_pools are destroyed when the - * parent pool is cleared. We allow certain liberties with operations - * on things such as tables (and on other structures in a more general - * sense) where we allow the caller to insert values into a table which - * were not allocated from the table's pool. The table's data will - * remain valid as long as all the pools from which its values are - * allocated remain valid. - * - * For example, if B is a sub pool of A, and you build a table T in - * pool B, then it's safe to insert data allocated in A or B into T - * (because B lives at most as long as A does, and T is destroyed when - * B is cleared/destroyed). On the other hand, if S is a table in - * pool A, it is safe to insert data allocated in A into S, but it - * is *not safe* to insert data allocated from B into S... because - * B can be cleared/destroyed before A is (which would leave dangling - * pointers in T's data structures). - * - * In general we say that it is safe to insert data into a table T - * if the data is allocated in any ancestor of T's pool. This is the - * basis on which the APR_POOL_DEBUG code works -- it tests these ancestor - * relationships for all data inserted into tables. APR_POOL_DEBUG also - * provides tools (apr_pool_find, and apr_pool_is_ancestor) for other - * folks to implement similar restrictions for their own data - * structures. - * - * However, sometimes this ancestor requirement is inconvenient -- - * sometimes it's necessary to create a sub pool where the sub pool is - * guaranteed to have the same lifetime as the parent pool. This is a - * guarantee implemented by the *caller*, not by the pool code. That - * is, the caller guarantees they won't destroy the sub pool - * individually prior to destroying the parent pool. - * - * In this case the caller must call apr_pool_join() to indicate this - * guarantee to the APR_POOL_DEBUG code. - * - * These functions are only implemented when #APR_POOL_DEBUG is set. - * - * @{ - */ -#if APR_POOL_DEBUG || defined(DOXYGEN) -/** - * Guarantee that a subpool has the same lifetime as the parent. - * @param p The parent pool - * @param sub The subpool - */ -APR_DECLARE(void) apr_pool_join(apr_pool_t *p, apr_pool_t *sub); - -/** - * Find a pool from something allocated in it. - * @param mem The thing allocated in the pool - * @return The pool it is allocated in - */ -APR_DECLARE(apr_pool_t *) apr_pool_find(const void *mem); - -/** - * Report the number of bytes currently in the pool - * @param p The pool to inspect - * @param recurse Recurse/include the subpools' sizes - * @return The number of bytes - */ -APR_DECLARE(apr_size_t) apr_pool_num_bytes(apr_pool_t *p, int recurse); - -/** - * Lock a pool - * @param pool The pool to lock - * @param flag The flag - */ -APR_DECLARE(void) apr_pool_lock(apr_pool_t *pool, int flag); - -/* @} */ - -#else /* APR_POOL_DEBUG or DOXYGEN */ - -#ifdef apr_pool_join -#undef apr_pool_join -#endif -#define apr_pool_join(a,b) - -#ifdef apr_pool_lock -#undef apr_pool_lock -#endif -#define apr_pool_lock(pool, lock) - -#endif /* APR_POOL_DEBUG or DOXYGEN */ - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* !APR_POOLS_H */ diff --git a/libs/apr/include/apr_portable.h b/libs/apr/include/apr_portable.h deleted file mode 100644 index 45d53eb1..00000000 --- a/libs/apr/include/apr_portable.h +++ /dev/null @@ -1,508 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* This header file is where you should put ANY platform specific information. - * This should be the only header file that programs need to include that - * actually has platform dependent code which refers to the . - */ -#ifndef APR_PORTABLE_H -#define APR_PORTABLE_H -/** - * @file apr_portable.h - * @brief APR Portability Routines - */ - -#include "apr.h" -#include "apr_pools.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include "apr_network_io.h" -#include "apr_errno.h" -#include "apr_global_mutex.h" -#include "apr_proc_mutex.h" -#include "apr_time.h" -#include "apr_dso.h" -#include "apr_shm.h" - -#if APR_HAVE_DIRENT_H -#include -#endif -#if APR_HAVE_FCNTL_H -#include -#endif -#if APR_HAVE_PTHREAD_H -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup apr_portabile Portability Routines - * @ingroup APR - * @{ - */ - -#ifdef WIN32 -/* The primitives for Windows types */ -typedef HANDLE apr_os_file_t; -typedef HANDLE apr_os_dir_t; -typedef SOCKET apr_os_sock_t; -typedef HANDLE apr_os_proc_mutex_t; -typedef HANDLE apr_os_thread_t; -typedef HANDLE apr_os_proc_t; -typedef DWORD apr_os_threadkey_t; -typedef FILETIME apr_os_imp_time_t; -typedef SYSTEMTIME apr_os_exp_time_t; -typedef HANDLE apr_os_dso_handle_t; -typedef HANDLE apr_os_shm_t; - -#elif defined(OS2) -typedef HFILE apr_os_file_t; -typedef HDIR apr_os_dir_t; -typedef int apr_os_sock_t; -typedef HMTX apr_os_proc_mutex_t; -typedef TID apr_os_thread_t; -typedef PID apr_os_proc_t; -typedef PULONG apr_os_threadkey_t; -typedef struct timeval apr_os_imp_time_t; -typedef struct tm apr_os_exp_time_t; -typedef HMODULE apr_os_dso_handle_t; -typedef void* apr_os_shm_t; - -#elif defined(__BEOS__) -#include -#include - -struct apr_os_proc_mutex_t { - sem_id sem; - int32 ben; -}; - -typedef int apr_os_file_t; -typedef DIR apr_os_dir_t; -typedef int apr_os_sock_t; -typedef struct apr_os_proc_mutex_t apr_os_proc_mutex_t; -typedef thread_id apr_os_thread_t; -typedef thread_id apr_os_proc_t; -typedef int apr_os_threadkey_t; -typedef struct timeval apr_os_imp_time_t; -typedef struct tm apr_os_exp_time_t; -typedef image_id apr_os_dso_handle_t; -typedef void* apr_os_shm_t; - -#elif defined(NETWARE) -typedef int apr_os_file_t; -typedef DIR apr_os_dir_t; -typedef int apr_os_sock_t; -typedef NXMutex_t apr_os_proc_mutex_t; -typedef NXThreadId_t apr_os_thread_t; -typedef long apr_os_proc_t; -typedef NXKey_t apr_os_threadkey_t; -typedef struct timeval apr_os_imp_time_t; -typedef struct tm apr_os_exp_time_t; -typedef void * apr_os_dso_handle_t; -typedef void* apr_os_shm_t; - -#else -/* Any other OS should go above this one. This is the lowest common - * denominator typedefs for all UNIX-like systems. :) - */ - -/** Basic OS process mutex structure. */ -struct apr_os_proc_mutex_t { -#if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE - /** Value used for SYS V Semaphore, FCNTL and FLOCK serialization */ - int crossproc; -#endif -#if APR_HAS_PROC_PTHREAD_SERIALIZE - /** Value used for PTHREAD serialization */ - pthread_mutex_t *pthread_interproc; -#endif -#if APR_HAS_THREADS - /* If no threads, no need for thread locks */ -#if APR_USE_PTHREAD_SERIALIZE - /** This value is currently unused within APR and Apache */ - pthread_mutex_t *intraproc; -#endif -#endif -}; - -typedef int apr_os_file_t; /**< native file */ -typedef DIR apr_os_dir_t; /**< native dir */ -typedef int apr_os_sock_t; /**< native dir */ -typedef struct apr_os_proc_mutex_t apr_os_proc_mutex_t; /**< native process - * mutex - */ -#if APR_HAS_THREADS && APR_HAVE_PTHREAD_H -typedef pthread_t apr_os_thread_t; /**< native thread */ -typedef pthread_key_t apr_os_threadkey_t; /**< native thread address - * space */ -#endif -typedef pid_t apr_os_proc_t; /**< native pid */ -typedef struct timeval apr_os_imp_time_t; /**< native timeval */ -typedef struct tm apr_os_exp_time_t; /**< native tm */ -/** @var apr_os_dso_handle_t - * native dso types - */ -#if defined(HPUX) || defined(HPUX10) || defined(HPUX11) -#include -typedef shl_t apr_os_dso_handle_t; -#elif defined(DARWIN) -#include -typedef NSModule apr_os_dso_handle_t; -#else -typedef void * apr_os_dso_handle_t; -#endif -typedef void* apr_os_shm_t; /**< native SHM */ - -#endif - -/** - * @typedef apr_os_sock_info_t - * @brief alias for local OS socket - */ -/** - * everything APR needs to know about an active socket to construct - * an APR socket from it; currently, this is platform-independent - */ -struct apr_os_sock_info_t { - apr_os_sock_t *os_sock; /**< always required */ - struct sockaddr *local; /**< NULL if not yet bound */ - struct sockaddr *remote; /**< NULL if not connected */ - int family; /**< always required (APR_INET, APR_INET6, etc.) */ - int type; /**< always required (SOCK_STREAM, SOCK_DGRAM, etc.) */ - int protocol; /**< 0 or actual protocol (APR_PROTO_SCTP, APR_PROTO_TCP, etc.) */ -}; - -typedef struct apr_os_sock_info_t apr_os_sock_info_t; - -#if APR_PROC_MUTEX_IS_GLOBAL || defined(DOXYGEN) -/** Opaque global mutex type */ -#define apr_os_global_mutex_t apr_os_proc_mutex_t -/** @return apr_os_global_mutex */ -#define apr_os_global_mutex_get apr_os_proc_mutex_get -#else - /** Thread and process mutex for those platforms where process mutexes - * are not held in threads. - */ - struct apr_os_global_mutex_t { - apr_pool_t *pool; - apr_proc_mutex_t *proc_mutex; -#if APR_HAS_THREADS - apr_thread_mutex_t *thread_mutex; -#endif /* APR_HAS_THREADS */ - }; - typedef struct apr_os_global_mutex_t apr_os_global_mutex_t; - -APR_DECLARE(apr_status_t) apr_os_global_mutex_get(apr_os_global_mutex_t *ospmutex, - apr_global_mutex_t *pmutex); -#endif - - -/** - * convert the file from apr type to os specific type. - * @param thefile The os specific file we are converting to - * @param file The apr file to convert. - * @remark On Unix, it is only possible to get a file descriptor from - * an apr file type. - */ -APR_DECLARE(apr_status_t) apr_os_file_get(apr_os_file_t *thefile, - apr_file_t *file); - -/** - * convert the dir from apr type to os specific type. - * @param thedir The os specific dir we are converting to - * @param dir The apr dir to convert. - */ -APR_DECLARE(apr_status_t) apr_os_dir_get(apr_os_dir_t **thedir, - apr_dir_t *dir); - -/** - * Convert the socket from an apr type to an OS specific socket - * @param thesock The socket to convert. - * @param sock The os specific equivalent of the apr socket.. - */ -APR_DECLARE(apr_status_t) apr_os_sock_get(apr_os_sock_t *thesock, - apr_socket_t *sock); - -/** - * Convert the proc mutex from os specific type to apr type - * @param ospmutex The os specific proc mutex we are converting to. - * @param pmutex The apr proc mutex to convert. - */ -APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex, - apr_proc_mutex_t *pmutex); - -/** - * Get the exploded time in the platforms native format. - * @param ostime the native time format - * @param aprtime the time to convert - */ -APR_DECLARE(apr_status_t) apr_os_exp_time_get(apr_os_exp_time_t **ostime, - apr_time_exp_t *aprtime); - -/** - * Get the imploded time in the platforms native format. - * @param ostime the native time format - * @param aprtime the time to convert - */ -APR_DECLARE(apr_status_t) apr_os_imp_time_get(apr_os_imp_time_t **ostime, - apr_time_t *aprtime); - -/** - * convert the shm from apr type to os specific type. - * @param osshm The os specific shm representation - * @param shm The apr shm to convert. - */ -APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm, - apr_shm_t *shm); - -#if APR_HAS_THREADS || defined(DOXYGEN) -/** - * @defgroup apr_os_thread Thread portability Routines - * @{ - */ -/** - * convert the thread to os specific type from apr type. - * @param thethd The apr thread to convert - * @param thd The os specific thread we are converting to - */ -APR_DECLARE(apr_status_t) apr_os_thread_get(apr_os_thread_t **thethd, - apr_thread_t *thd); - -/** - * convert the thread private memory key to os specific type from an apr type. - * @param thekey The apr handle we are converting from. - * @param key The os specific handle we are converting to. - */ -APR_DECLARE(apr_status_t) apr_os_threadkey_get(apr_os_threadkey_t *thekey, - apr_threadkey_t *key); - -/** - * convert the thread from os specific type to apr type. - * @param thd The apr thread we are converting to. - * @param thethd The os specific thread to convert - * @param cont The pool to use if it is needed. - */ -APR_DECLARE(apr_status_t) apr_os_thread_put(apr_thread_t **thd, - apr_os_thread_t *thethd, - apr_pool_t *cont); - -/** - * convert the thread private memory key from os specific type to apr type. - * @param key The apr handle we are converting to. - * @param thekey The os specific handle to convert - * @param cont The pool to use if it is needed. - */ -APR_DECLARE(apr_status_t) apr_os_threadkey_put(apr_threadkey_t **key, - apr_os_threadkey_t *thekey, - apr_pool_t *cont); -/** - * Get the thread ID - */ -APR_DECLARE(apr_os_thread_t) apr_os_thread_current(void); - -/** - * Compare two thread id's - * @param tid1 1st Thread ID to compare - * @param tid2 2nd Thread ID to compare - * @return non-zero if the two threads are equal, zero otherwise - */ -APR_DECLARE(int) apr_os_thread_equal(apr_os_thread_t tid1, - apr_os_thread_t tid2); - -/** @} */ -#endif /* APR_HAS_THREADS */ - -/** - * convert the file from os specific type to apr type. - * @param file The apr file we are converting to. - * @param thefile The os specific file to convert - * @param flags The flags that were used to open this file. - * @param cont The pool to use if it is needed. - * @remark On Unix, it is only possible to put a file descriptor into - * an apr file type. - */ -APR_DECLARE(apr_status_t) apr_os_file_put(apr_file_t **file, - apr_os_file_t *thefile, - apr_int32_t flags, apr_pool_t *cont); - -/** - * convert the file from os specific type to apr type. - * @param file The apr file we are converting to. - * @param thefile The os specific pipe to convert - * @param cont The pool to use if it is needed. - * @remark On Unix, it is only possible to put a file descriptor into - * an apr file type. - */ -APR_DECLARE(apr_status_t) apr_os_pipe_put(apr_file_t **file, - apr_os_file_t *thefile, - apr_pool_t *cont); - -/** - * convert the file from os specific type to apr type. - * @param file The apr file we are converting to. - * @param thefile The os specific pipe to convert - * @param register_cleanup A cleanup will be registered on the apr_file_t - * to issue apr_file_close(). - * @param cont The pool to use if it is needed. - * @remark On Unix, it is only possible to put a file descriptor into - * an apr file type. - */ -APR_DECLARE(apr_status_t) apr_os_pipe_put_ex(apr_file_t **file, - apr_os_file_t *thefile, - int register_cleanup, - apr_pool_t *cont); - -/** - * convert the dir from os specific type to apr type. - * @param dir The apr dir we are converting to. - * @param thedir The os specific dir to convert - * @param cont The pool to use when creating to apr directory. - */ -APR_DECLARE(apr_status_t) apr_os_dir_put(apr_dir_t **dir, - apr_os_dir_t *thedir, - apr_pool_t *cont); - -/** - * Convert a socket from the os specific type to the apr type - * @param sock The pool to use. - * @param thesock The socket to convert to. - * @param cont The socket we are converting to an apr type. - * @remark If it is a true socket, it is best to call apr_os_sock_make() - * and provide APR with more information about the socket. - */ -APR_DECLARE(apr_status_t) apr_os_sock_put(apr_socket_t **sock, - apr_os_sock_t *thesock, - apr_pool_t *cont); - -/** - * Create a socket from an existing descriptor and local and remote - * socket addresses. - * @param apr_sock The new socket that has been set up - * @param os_sock_info The os representation of the socket handle and - * other characteristics of the socket - * @param cont The pool to use - * @remark If you only know the descriptor/handle or if it isn't really - * a true socket, use apr_os_sock_put() instead. - */ -APR_DECLARE(apr_status_t) apr_os_sock_make(apr_socket_t **apr_sock, - apr_os_sock_info_t *os_sock_info, - apr_pool_t *cont); - -/** - * Convert the proc mutex from os specific type to apr type - * @param pmutex The apr proc mutex we are converting to. - * @param ospmutex The os specific proc mutex to convert. - * @param cont The pool to use if it is needed. - */ -APR_DECLARE(apr_status_t) apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex, - apr_os_proc_mutex_t *ospmutex, - apr_pool_t *cont); - -/** - * Put the imploded time in the APR format. - * @param aprtime the APR time format - * @param ostime the time to convert - * @param cont the pool to use if necessary - */ -APR_DECLARE(apr_status_t) apr_os_imp_time_put(apr_time_t *aprtime, - apr_os_imp_time_t **ostime, - apr_pool_t *cont); - -/** - * Put the exploded time in the APR format. - * @param aprtime the APR time format - * @param ostime the time to convert - * @param cont the pool to use if necessary - */ -APR_DECLARE(apr_status_t) apr_os_exp_time_put(apr_time_exp_t *aprtime, - apr_os_exp_time_t **ostime, - apr_pool_t *cont); - -/** - * convert the shared memory from os specific type to apr type. - * @param shm The apr shm representation of osshm - * @param osshm The os specific shm identity - * @param cont The pool to use if it is needed. - * @remark On fork()ed architectures, this is typically nothing more than - * the memory block mapped. On non-fork architectures, this is typically - * some internal handle to pass the mapping from process to process. - */ -APR_DECLARE(apr_status_t) apr_os_shm_put(apr_shm_t **shm, - apr_os_shm_t *osshm, - apr_pool_t *cont); - - -#if APR_HAS_DSO || defined(DOXYGEN) -/** - * @defgroup apr_os_dso DSO (Dynamic Loading) Portability Routines - * @{ - */ -/** - * convert the dso handle from os specific to apr - * @param dso The apr handle we are converting to - * @param thedso the os specific handle to convert - * @param pool the pool to use if it is needed - */ -APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **dso, - apr_os_dso_handle_t thedso, - apr_pool_t *pool); - -/** - * convert the apr dso handle into an os specific one - * @param aprdso The apr dso handle to convert - * @param dso The os specific dso to return - */ -APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *dso, - apr_dso_handle_t *aprdso); - -/** @} */ -#endif /* APR_HAS_DSO */ - - -#if APR_HAS_OS_UUID -/** - * Private: apr-util's apr_uuid module when supported by the platform - */ -APR_DECLARE(apr_status_t) apr_os_uuid_get(unsigned char *uuid_data); -#endif - - -/** - * Get the name of the system default character set. - * @param pool the pool to allocate the name from, if needed - */ -APR_DECLARE(const char*) apr_os_default_encoding(apr_pool_t *pool); - - -/** - * Get the name of the current locale character set. - * @param pool the pool to allocate the name from, if needed - * @remark Defers to apr_os_default_encoding if the current locale's - * data can't be retrieved on this system. - */ -APR_DECLARE(const char*) apr_os_locale_encoding(apr_pool_t *pool); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ! APR_PORTABLE_H */ diff --git a/libs/apr/include/apr_proc_mutex.h b/libs/apr/include/apr_proc_mutex.h deleted file mode 100644 index ceb9c82a..00000000 --- a/libs/apr/include/apr_proc_mutex.h +++ /dev/null @@ -1,166 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_PROC_MUTEX_H -#define APR_PROC_MUTEX_H - -/** - * @file apr_proc_mutex.h - * @brief APR Process Locking Routines - */ - -#include "apr.h" -#include "apr_pools.h" -#include "apr_errno.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup apr_proc_mutex Process Locking Routines - * @ingroup APR - * @{ - */ - -/** - * Enumerated potential types for APR process locking methods - * @warning Check APR_HAS_foo_SERIALIZE defines to see if the platform supports - * APR_LOCK_foo. Only APR_LOCK_DEFAULT is portable. - */ -typedef enum { - APR_LOCK_FCNTL, /**< fcntl() */ - APR_LOCK_FLOCK, /**< flock() */ - APR_LOCK_SYSVSEM, /**< System V Semaphores */ - APR_LOCK_PROC_PTHREAD, /**< POSIX pthread process-based locking */ - APR_LOCK_POSIXSEM, /**< POSIX semaphore process-based locking */ - APR_LOCK_DEFAULT /**< Use the default process lock */ -} apr_lockmech_e; - -/** Opaque structure representing a process mutex. */ -typedef struct apr_proc_mutex_t apr_proc_mutex_t; - -/* Function definitions */ - -/** - * Create and initialize a mutex that can be used to synchronize processes. - * @param mutex the memory address where the newly created mutex will be - * stored. - * @param fname A file name to use if the lock mechanism requires one. This - * argument should always be provided. The lock code itself will - * determine if it should be used. - * @param mech The mechanism to use for the interprocess lock, if any; one of - *
    - *            APR_LOCK_FCNTL
    - *            APR_LOCK_FLOCK
    - *            APR_LOCK_SYSVSEM
    - *            APR_LOCK_POSIXSEM
    - *            APR_LOCK_PROC_PTHREAD
    - *            APR_LOCK_DEFAULT     pick the default mechanism for the platform
    - * 
    - * @param pool the pool from which to allocate the mutex. - * @see apr_lockmech_e - * @warning Check APR_HAS_foo_SERIALIZE defines to see if the platform supports - * APR_LOCK_foo. Only APR_LOCK_DEFAULT is portable. - */ -APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex, - const char *fname, - apr_lockmech_e mech, - apr_pool_t *pool); - -/** - * Re-open a mutex in a child process. - * @param mutex The newly re-opened mutex structure. - * @param fname A file name to use if the mutex mechanism requires one. This - * argument should always be provided. The mutex code itself will - * determine if it should be used. This filename should be the - * same one that was passed to apr_proc_mutex_create(). - * @param pool The pool to operate on. - * @remark This function must be called to maintain portability, even - * if the underlying lock mechanism does not require it. - */ -APR_DECLARE(apr_status_t) apr_proc_mutex_child_init(apr_proc_mutex_t **mutex, - const char *fname, - apr_pool_t *pool); - -/** - * Acquire the lock for the given mutex. If the mutex is already locked, - * the current thread will be put to sleep until the lock becomes available. - * @param mutex the mutex on which to acquire the lock. - */ -APR_DECLARE(apr_status_t) apr_proc_mutex_lock(apr_proc_mutex_t *mutex); - -/** - * Attempt to acquire the lock for the given mutex. If the mutex has already - * been acquired, the call returns immediately with APR_EBUSY. Note: it - * is important that the APR_STATUS_IS_EBUSY(s) macro be used to determine - * if the return value was APR_EBUSY, for portability reasons. - * @param mutex the mutex on which to attempt the lock acquiring. - */ -APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex); - -/** - * Release the lock for the given mutex. - * @param mutex the mutex from which to release the lock. - */ -APR_DECLARE(apr_status_t) apr_proc_mutex_unlock(apr_proc_mutex_t *mutex); - -/** - * Destroy the mutex and free the memory associated with the lock. - * @param mutex the mutex to destroy. - */ -APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex); - -/** - * Destroy the mutex and free the memory associated with the lock. - * @param mutex the mutex to destroy. - * @note This function is generally used to kill a cleanup on an already - * created mutex - */ -APR_DECLARE(apr_status_t) apr_proc_mutex_cleanup(void *mutex); - -/** - * Return the name of the lockfile for the mutex, or NULL - * if the mutex doesn't use a lock file - */ - -APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex); - -/** - * Display the name of the mutex, as it relates to the actual method used. - * This matches the valid options for Apache's AcceptMutex directive - * @param mutex the name of the mutex - */ -APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex); - -/** - * Display the name of the default mutex: APR_LOCK_DEFAULT - */ -APR_DECLARE(const char *) apr_proc_mutex_defname(void); - -/** - * Get the pool used by this proc_mutex. - * @return apr_pool_t the pool - */ -APR_POOL_DECLARE_ACCESSOR(proc_mutex); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ! APR_PROC_MUTEX_H */ diff --git a/libs/apr/include/apr_random.h b/libs/apr/include/apr_random.h deleted file mode 100644 index 29154358..00000000 --- a/libs/apr/include/apr_random.h +++ /dev/null @@ -1,153 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_RANDOM_H -#define APR_RANDOM_H - -/** - * @file apr_random.h - * @brief APR PRNG routines - */ - -#include "apr_pools.h" -#include "apr_thread_proc.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup apr_random PRNG Routines - * @ingroup APR - * @{ - */ - -typedef struct apr_crypto_hash_t apr_crypto_hash_t; - -typedef void apr_crypto_hash_init_t(apr_crypto_hash_t *hash); -typedef void apr_crypto_hash_add_t(apr_crypto_hash_t *hash, const void *data, - apr_size_t bytes); -typedef void apr_crypto_hash_finish_t(apr_crypto_hash_t *hash, - unsigned char *result); - - -/* FIXME: make this opaque */ -struct apr_crypto_hash_t { - apr_crypto_hash_init_t *init; - apr_crypto_hash_add_t *add; - apr_crypto_hash_finish_t *finish; - apr_size_t size; - void *data; -}; - -/** - * Allocate and initialize the SHA-256 context - * @param p The pool to allocate from - */ -APR_DECLARE(apr_crypto_hash_t *) apr_crypto_sha256_new(apr_pool_t *p); - -/** Opaque PRNG structure. */ -typedef struct apr_random_t apr_random_t; - -/** - * Initialize a PRNG state - * @param g The PRNG state - * @param p The pool to allocate from - * @param pool_hash Pool hash functions - * @param key_hash Key hash functions - * @param prng_hash PRNG hash functions - */ -APR_DECLARE(void) apr_random_init(apr_random_t *g, apr_pool_t *p, - apr_crypto_hash_t *pool_hash, - apr_crypto_hash_t *key_hash, - apr_crypto_hash_t *prng_hash); -/** - * Allocate and initialize (apr_crypto_sha256_new) a new PRNG state. - * @param p The pool to allocate from - */ -APR_DECLARE(apr_random_t *) apr_random_standard_new(apr_pool_t *p); - -/** - * Mix the randomness pools. - * @param g The PRNG state - * @param entropy_ Entropy buffer - * @param bytes Length of entropy_ in bytes - */ -APR_DECLARE(void) apr_random_add_entropy(apr_random_t *g, - const void *entropy_, - apr_size_t bytes); -/** - * Generate cryptographically insecure random bytes. - * @param g The RNG state - * @param random Buffer to fill with random bytes - * @param bytes Length of buffer in bytes - */ -APR_DECLARE(apr_status_t) apr_random_insecure_bytes(apr_random_t *g, - void *random, - apr_size_t bytes); - -/** - * Generate cryptographically secure random bytes. - * @param g The RNG state - * @param random Buffer to fill with random bytes - * @param bytes Length of buffer in bytes - */ -APR_DECLARE(apr_status_t) apr_random_secure_bytes(apr_random_t *g, - void *random, - apr_size_t bytes); -/** - * Ensures that E bits of conditional entropy are mixed into the PRNG - * before any further randomness is extracted. - * @param g The RNG state - */ -APR_DECLARE(void) apr_random_barrier(apr_random_t *g); - -/** - * Return APR_SUCCESS if the cryptographic PRNG has been seeded with - * enough data, APR_ENOTENOUGHENTROPY otherwise. - * @param r The RNG state - */ -APR_DECLARE(apr_status_t) apr_random_secure_ready(apr_random_t *r); - -/** - * Return APR_SUCCESS if the PRNG has been seeded with enough data, - * APR_ENOTENOUGHENTROPY otherwise. - * @param r The PRNG state - */ -APR_DECLARE(apr_status_t) apr_random_insecure_ready(apr_random_t *r); - -/** - * Mix the randomness pools after forking. - * @param proc The resulting process handle from apr_proc_fork() - * @remark Call this in the child after forking to mix the randomness - * pools. Note that its generally a bad idea to fork a process with a - * real PRNG in it - better to have the PRNG externally and get the - * randomness from there. However, if you really must do it, then you - * should supply all your entropy to all the PRNGs - don't worry, they - * won't produce the same output. - * @remark Note that apr_proc_fork() calls this for you, so only weird - * applications need ever call it themselves. - * @internal - */ -APR_DECLARE(void) apr_random_after_fork(apr_proc_t *proc); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* !APR_RANDOM_H */ diff --git a/libs/apr/include/apr_ring.h b/libs/apr/include/apr_ring.h deleted file mode 100644 index eec735fc..00000000 --- a/libs/apr/include/apr_ring.h +++ /dev/null @@ -1,513 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * This code draws heavily from the 4.4BSD macros - * and Dean Gaudet's "splim/ring.h". - * - * - * - * We'd use Dean's code directly if we could guarantee the - * availability of inline functions. - */ - -#ifndef APR_RING_H -#define APR_RING_H - -/** - * @file apr_ring.h - * @brief APR Rings - */ - -/* - * for offsetof() - */ -#include "apr_general.h" - -/** - * @defgroup apr_ring Ring Macro Implementations - * @ingroup APR - * A ring is a kind of doubly-linked list that can be manipulated - * without knowing where its head is. - * @{ - */ - -/** - * The Ring Element - * - * A ring element struct is linked to the other elements in the ring - * through its ring entry field, e.g. - *
    - *      struct my_element_t {
    - *          APR_RING_ENTRY(my_element_t) link;
    - *          int foo;
    - *          char *bar;
    - *      };
    - * 
    - * - * An element struct may be put on more than one ring if it has more - * than one APR_RING_ENTRY field. Each APR_RING_ENTRY has a corresponding - * APR_RING_HEAD declaration. - * - * @warning For strict C standards compliance you should put the APR_RING_ENTRY - * first in the element struct unless the head is always part of a larger - * object with enough earlier fields to accommodate the offsetof() used - * to compute the ring sentinel below. You can usually ignore this caveat. - */ -#define APR_RING_ENTRY(elem) \ - struct { \ - struct elem * volatile next; \ - struct elem * volatile prev; \ - } - -/** - * The Ring Head - * - * Each ring is managed via its head, which is a struct declared like this: - *
    - *      APR_RING_HEAD(my_ring_t, my_element_t);
    - *      struct my_ring_t ring, *ringp;
    - * 
    - * - * This struct looks just like the element link struct so that we can - * be sure that the typecasting games will work as expected. - * - * The first element in the ring is next after the head, and the last - * element is just before the head. - */ -#define APR_RING_HEAD(head, elem) \ - struct head { \ - struct elem * volatile next; \ - struct elem * volatile prev; \ - } - -/** - * The Ring Sentinel - * - * This is the magic pointer value that occurs before the first and - * after the last elements in the ring, computed from the address of - * the ring's head. The head itself isn't an element, but in order to - * get rid of all the special cases when dealing with the ends of the - * ring, we play typecasting games to make it look like one. - * - * Here is a diagram to illustrate the arrangements of the next and - * prev pointers of each element in a single ring. Note that they point - * to the start of each element, not to the APR_RING_ENTRY structure. - * - *
    - *     +->+------+<-+  +->+------+<-+  +->+------+<-+
    - *     |  |struct|  |  |  |struct|  |  |  |struct|  |
    - *    /   | elem |   \/   | elem |   \/   | elem |  \
    - * ...    |      |   /\   |      |   /\   |      |   ...
    - *        +------+  |  |  +------+  |  |  +------+
    - *   ...--|prev  |  |  +--|ring  |  |  +--|prev  |
    - *        |  next|--+     | entry|--+     |  next|--...
    - *        +------+        +------+        +------+
    - *        | etc. |        | etc. |        | etc. |
    - *        :      :        :      :        :      :
    - * 
    - * - * The APR_RING_HEAD is nothing but a bare APR_RING_ENTRY. The prev - * and next pointers in the first and last elements don't actually - * point to the head, they point to a phantom place called the - * sentinel. Its value is such that last->next->next == first because - * the offset from the sentinel to the head's next pointer is the same - * as the offset from the start of an element to its next pointer. - * This also works in the opposite direction. - * - *
    - *        last                            first
    - *     +->+------+<-+  +->sentinel<-+  +->+------+<-+
    - *     |  |struct|  |  |            |  |  |struct|  |
    - *    /   | elem |   \/              \/   | elem |  \
    - * ...    |      |   /\              /\   |      |   ...
    - *        +------+  |  |  +------+  |  |  +------+
    - *   ...--|prev  |  |  +--|ring  |  |  +--|prev  |
    - *        |  next|--+     |  head|--+     |  next|--...
    - *        +------+        +------+        +------+
    - *        | etc. |                        | etc. |
    - *        :      :                        :      :
    - * 
    - * - * Note that the offset mentioned above is different for each kind of - * ring that the element may be on, and each kind of ring has a unique - * name for its APR_RING_ENTRY in each element, and has its own type - * for its APR_RING_HEAD. - * - * Note also that if the offset is non-zero (which is required if an - * element has more than one APR_RING_ENTRY), the unreality of the - * sentinel may have bad implications on very perverse implementations - * of C -- see the warning in APR_RING_ENTRY. - * - * @param hp The head of the ring - * @param elem The name of the element struct - * @param link The name of the APR_RING_ENTRY in the element struct - */ -#define APR_RING_SENTINEL(hp, elem, link) \ - (struct elem *)((char *)(&(hp)->next) - APR_OFFSETOF(struct elem, link)) - -/** - * The first element of the ring - * @param hp The head of the ring - */ -#define APR_RING_FIRST(hp) (hp)->next -/** - * The last element of the ring - * @param hp The head of the ring - */ -#define APR_RING_LAST(hp) (hp)->prev -/** - * The next element in the ring - * @param ep The current element - * @param link The name of the APR_RING_ENTRY in the element struct - */ -#define APR_RING_NEXT(ep, link) (ep)->link.next -/** - * The previous element in the ring - * @param ep The current element - * @param link The name of the APR_RING_ENTRY in the element struct - */ -#define APR_RING_PREV(ep, link) (ep)->link.prev - - -/** - * Initialize a ring - * @param hp The head of the ring - * @param elem The name of the element struct - * @param link The name of the APR_RING_ENTRY in the element struct - */ -#define APR_RING_INIT(hp, elem, link) do { \ - APR_RING_FIRST((hp)) = APR_RING_SENTINEL((hp), elem, link); \ - APR_RING_LAST((hp)) = APR_RING_SENTINEL((hp), elem, link); \ - } while (0) - -/** - * Determine if a ring is empty - * @param hp The head of the ring - * @param elem The name of the element struct - * @param link The name of the APR_RING_ENTRY in the element struct - * @return true or false - */ -#define APR_RING_EMPTY(hp, elem, link) \ - (APR_RING_FIRST((hp)) == APR_RING_SENTINEL((hp), elem, link)) - -/** - * Initialize a singleton element - * @param ep The element - * @param link The name of the APR_RING_ENTRY in the element struct - */ -#define APR_RING_ELEM_INIT(ep, link) do { \ - APR_RING_NEXT((ep), link) = (ep); \ - APR_RING_PREV((ep), link) = (ep); \ - } while (0) - - -/** - * Splice the sequence ep1..epN into the ring before element lep - * (..lep.. becomes ..ep1..epN..lep..) - * @warning This doesn't work for splicing before the first element or on - * empty rings... see APR_RING_SPLICE_HEAD for one that does - * @param lep Element in the ring to splice before - * @param ep1 First element in the sequence to splice in - * @param epN Last element in the sequence to splice in - * @param link The name of the APR_RING_ENTRY in the element struct - */ -#define APR_RING_SPLICE_BEFORE(lep, ep1, epN, link) do { \ - APR_RING_NEXT((epN), link) = (lep); \ - APR_RING_PREV((ep1), link) = APR_RING_PREV((lep), link); \ - APR_RING_NEXT(APR_RING_PREV((lep), link), link) = (ep1); \ - APR_RING_PREV((lep), link) = (epN); \ - } while (0) - -/** - * Splice the sequence ep1..epN into the ring after element lep - * (..lep.. becomes ..lep..ep1..epN..) - * @warning This doesn't work for splicing after the last element or on - * empty rings... see APR_RING_SPLICE_TAIL for one that does - * @param lep Element in the ring to splice after - * @param ep1 First element in the sequence to splice in - * @param epN Last element in the sequence to splice in - * @param link The name of the APR_RING_ENTRY in the element struct - */ -#define APR_RING_SPLICE_AFTER(lep, ep1, epN, link) do { \ - APR_RING_PREV((ep1), link) = (lep); \ - APR_RING_NEXT((epN), link) = APR_RING_NEXT((lep), link); \ - APR_RING_PREV(APR_RING_NEXT((lep), link), link) = (epN); \ - APR_RING_NEXT((lep), link) = (ep1); \ - } while (0) - -/** - * Insert the element nep into the ring before element lep - * (..lep.. becomes ..nep..lep..) - * @warning This doesn't work for inserting before the first element or on - * empty rings... see APR_RING_INSERT_HEAD for one that does - * @param lep Element in the ring to insert before - * @param nep Element to insert - * @param link The name of the APR_RING_ENTRY in the element struct - */ -#define APR_RING_INSERT_BEFORE(lep, nep, link) \ - APR_RING_SPLICE_BEFORE((lep), (nep), (nep), link) - -/** - * Insert the element nep into the ring after element lep - * (..lep.. becomes ..lep..nep..) - * @warning This doesn't work for inserting after the last element or on - * empty rings... see APR_RING_INSERT_TAIL for one that does - * @param lep Element in the ring to insert after - * @param nep Element to insert - * @param link The name of the APR_RING_ENTRY in the element struct - */ -#define APR_RING_INSERT_AFTER(lep, nep, link) \ - APR_RING_SPLICE_AFTER((lep), (nep), (nep), link) - - -/** - * Splice the sequence ep1..epN into the ring before the first element - * (..hp.. becomes ..hp..ep1..epN..) - * @param hp Head of the ring - * @param ep1 First element in the sequence to splice in - * @param epN Last element in the sequence to splice in - * @param elem The name of the element struct - * @param link The name of the APR_RING_ENTRY in the element struct - */ -#define APR_RING_SPLICE_HEAD(hp, ep1, epN, elem, link) \ - APR_RING_SPLICE_AFTER(APR_RING_SENTINEL((hp), elem, link), \ - (ep1), (epN), link) - -/** - * Splice the sequence ep1..epN into the ring after the last element - * (..hp.. becomes ..ep1..epN..hp..) - * @param hp Head of the ring - * @param ep1 First element in the sequence to splice in - * @param epN Last element in the sequence to splice in - * @param elem The name of the element struct - * @param link The name of the APR_RING_ENTRY in the element struct - */ -#define APR_RING_SPLICE_TAIL(hp, ep1, epN, elem, link) \ - APR_RING_SPLICE_BEFORE(APR_RING_SENTINEL((hp), elem, link), \ - (ep1), (epN), link) - -/** - * Insert the element nep into the ring before the first element - * (..hp.. becomes ..hp..nep..) - * @param hp Head of the ring - * @param nep Element to insert - * @param elem The name of the element struct - * @param link The name of the APR_RING_ENTRY in the element struct - */ -#define APR_RING_INSERT_HEAD(hp, nep, elem, link) \ - APR_RING_SPLICE_HEAD((hp), (nep), (nep), elem, link) - -/** - * Insert the element nep into the ring after the last element - * (..hp.. becomes ..nep..hp..) - * @param hp Head of the ring - * @param nep Element to insert - * @param elem The name of the element struct - * @param link The name of the APR_RING_ENTRY in the element struct - */ -#define APR_RING_INSERT_TAIL(hp, nep, elem, link) \ - APR_RING_SPLICE_TAIL((hp), (nep), (nep), elem, link) - -/** - * Concatenate ring h2 onto the end of ring h1, leaving h2 empty. - * @param h1 Head of the ring to concatenate onto - * @param h2 Head of the ring to concatenate - * @param elem The name of the element struct - * @param link The name of the APR_RING_ENTRY in the element struct - */ -#define APR_RING_CONCAT(h1, h2, elem, link) do { \ - if (!APR_RING_EMPTY((h2), elem, link)) { \ - APR_RING_SPLICE_BEFORE(APR_RING_SENTINEL((h1), elem, link), \ - APR_RING_FIRST((h2)), \ - APR_RING_LAST((h2)), link); \ - APR_RING_INIT((h2), elem, link); \ - } \ - } while (0) - -/** - * Prepend ring h2 onto the beginning of ring h1, leaving h2 empty. - * @param h1 Head of the ring to prepend onto - * @param h2 Head of the ring to prepend - * @param elem The name of the element struct - * @param link The name of the APR_RING_ENTRY in the element struct - */ -#define APR_RING_PREPEND(h1, h2, elem, link) do { \ - if (!APR_RING_EMPTY((h2), elem, link)) { \ - APR_RING_SPLICE_AFTER(APR_RING_SENTINEL((h1), elem, link), \ - APR_RING_FIRST((h2)), \ - APR_RING_LAST((h2)), link); \ - APR_RING_INIT((h2), elem, link); \ - } \ - } while (0) - -/** - * Unsplice a sequence of elements from a ring - * @warning The unspliced sequence is left with dangling pointers at either end - * @param ep1 First element in the sequence to unsplice - * @param epN Last element in the sequence to unsplice - * @param link The name of the APR_RING_ENTRY in the element struct - */ -#define APR_RING_UNSPLICE(ep1, epN, link) do { \ - APR_RING_NEXT(APR_RING_PREV((ep1), link), link) = \ - APR_RING_NEXT((epN), link); \ - APR_RING_PREV(APR_RING_NEXT((epN), link), link) = \ - APR_RING_PREV((ep1), link); \ - } while (0) - -/** - * Remove a single element from a ring - * @warning The unspliced element is left with dangling pointers at either end - * @param ep Element to remove - * @param link The name of the APR_RING_ENTRY in the element struct - */ -#define APR_RING_REMOVE(ep, link) \ - APR_RING_UNSPLICE((ep), (ep), link) - -/** - * Iterate over a ring - * @param ep The current element - * @param head The head of the ring - * @param elem The name of the element struct - * @param link The name of the APR_RING_ENTRY in the element struct - */ -#define APR_RING_FOREACH(ep, head, elem, link) \ - for (ep = APR_RING_FIRST(head); \ - ep != APR_RING_SENTINEL(head, elem, link); \ - ep = APR_RING_NEXT(ep, link)) - -/** - * Iterate over a ring safe against removal of the current element - * @param ep1 The current element - * @param ep2 Iteration cursor - * @param head The head of the ring - * @param elem The name of the element struct - * @param link The name of the APR_RING_ENTRY in the element struct - */ -#define APR_RING_FOREACH_SAFE(ep1, ep2, head, elem, link) \ - for (ep1 = APR_RING_FIRST(head), ep2 = APR_RING_NEXT(ep1, link); \ - ep1 != APR_RING_SENTINEL(head, elem, link); \ - ep1 = ep2, ep2 = APR_RING_NEXT(ep1, link)) - -/* Debugging tools: */ - -#ifdef APR_RING_DEBUG -#include -#include - -#define APR_RING_CHECK_ONE(msg, ptr) \ - fprintf(stderr, "*** %s %p\n", msg, ptr) - -#define APR_RING_CHECK(hp, elem, link, msg) \ - APR_RING_CHECK_ELEM(APR_RING_SENTINEL(hp, elem, link), elem, link, msg) - -#define APR_RING_CHECK_ELEM(ep, elem, link, msg) do { \ - struct elem *start = (ep); \ - struct elem *here = start; \ - fprintf(stderr, "*** ring check start -- %s\n", msg); \ - do { \ - fprintf(stderr, "\telem %p\n", here); \ - fprintf(stderr, "\telem->next %p\n", \ - APR_RING_NEXT(here, link)); \ - fprintf(stderr, "\telem->prev %p\n", \ - APR_RING_PREV(here, link)); \ - fprintf(stderr, "\telem->next->prev %p\n", \ - APR_RING_PREV(APR_RING_NEXT(here, link), link)); \ - fprintf(stderr, "\telem->prev->next %p\n", \ - APR_RING_NEXT(APR_RING_PREV(here, link), link)); \ - if (APR_RING_PREV(APR_RING_NEXT(here, link), link) != here) { \ - fprintf(stderr, "\t*** elem->next->prev != elem\n"); \ - break; \ - } \ - if (APR_RING_NEXT(APR_RING_PREV(here, link), link) != here) { \ - fprintf(stderr, "\t*** elem->prev->next != elem\n"); \ - break; \ - } \ - here = APR_RING_NEXT(here, link); \ - } while (here != start); \ - fprintf(stderr, "*** ring check end\n"); \ - } while (0) - -#define APR_RING_CHECK_CONSISTENCY(hp, elem, link) \ - APR_RING_CHECK_ELEM_CONSISTENCY(APR_RING_SENTINEL(hp, elem, link),\ - elem, link) - -#define APR_RING_CHECK_ELEM_CONSISTENCY(ep, elem, link) do { \ - struct elem *start = (ep); \ - struct elem *here = start; \ - do { \ - assert(APR_RING_PREV(APR_RING_NEXT(here, link), link) == here); \ - assert(APR_RING_NEXT(APR_RING_PREV(here, link), link) == here); \ - here = APR_RING_NEXT(here, link); \ - } while (here != start); \ - } while (0) - -#else -/** - * Print a single pointer value to STDERR - * (This is a no-op unless APR_RING_DEBUG is defined.) - * @param msg Descriptive message - * @param ptr Pointer value to print - */ -#define APR_RING_CHECK_ONE(msg, ptr) -/** - * Dump all ring pointers to STDERR, starting with the head and looping all - * the way around the ring back to the head. Aborts if an inconsistency - * is found. - * (This is a no-op unless APR_RING_DEBUG is defined.) - * @param hp Head of the ring - * @param elem The name of the element struct - * @param link The name of the APR_RING_ENTRY in the element struct - * @param msg Descriptive message - */ -#define APR_RING_CHECK(hp, elem, link, msg) -/** - * Loops around a ring and checks all the pointers for consistency. Pops - * an assertion if any inconsistency is found. Same idea as APR_RING_CHECK() - * except that it's silent if all is well. - * (This is a no-op unless APR_RING_DEBUG is defined.) - * @param hp Head of the ring - * @param elem The name of the element struct - * @param link The name of the APR_RING_ENTRY in the element struct - */ -#define APR_RING_CHECK_CONSISTENCY(hp, elem, link) -/** - * Dump all ring pointers to STDERR, starting with the given element and - * looping all the way around the ring back to that element. Aborts if - * an inconsistency is found. - * (This is a no-op unless APR_RING_DEBUG is defined.) - * @param ep The element - * @param elem The name of the element struct - * @param link The name of the APR_RING_ENTRY in the element struct - * @param msg Descriptive message - */ -#define APR_RING_CHECK_ELEM(ep, elem, link, msg) -/** - * Loops around a ring, starting with the given element, and checks all - * the pointers for consistency. Pops an assertion if any inconsistency - * is found. Same idea as APR_RING_CHECK_ELEM() except that it's silent - * if all is well. - * (This is a no-op unless APR_RING_DEBUG is defined.) - * @param ep The element - * @param elem The name of the element struct - * @param link The name of the APR_RING_ENTRY in the element struct - */ -#define APR_RING_CHECK_ELEM_CONSISTENCY(ep, elem, link) -#endif - -/** @} */ - -#endif /* !APR_RING_H */ diff --git a/libs/apr/include/apr_shm.h b/libs/apr/include/apr_shm.h deleted file mode 100644 index 2b1d50f6..00000000 --- a/libs/apr/include/apr_shm.h +++ /dev/null @@ -1,146 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_SHM_H -#define APR_SHM_H - -/** - * @file apr_shm.h - * @brief APR Shared Memory Routines - */ - -#include "apr.h" -#include "apr_pools.h" -#include "apr_errno.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup apr_shm Shared Memory Routines - * @ingroup APR - * @{ - */ - -/** - * Private, platform-specific data struture representing a shared memory - * segment. - */ -typedef struct apr_shm_t apr_shm_t; - -/** - * Create and make accessable a shared memory segment. - * @param m The shared memory structure to create. - * @param reqsize The desired size of the segment. - * @param filename The file to use for shared memory on platforms that - * require it. - * @param pool the pool from which to allocate the shared memory - * structure. - * @remark A note about Anonymous vs. Named shared memory segments: - * Not all plaforms support anonymous shared memory segments, but in - * some cases it is prefered over other types of shared memory - * implementations. Passing a NULL 'file' parameter to this function - * will cause the subsystem to use anonymous shared memory segments. - * If such a system is not available, APR_ENOTIMPL is returned. - * @remark A note about allocation sizes: - * On some platforms it is necessary to store some metainformation - * about the segment within the actual segment. In order to supply - * the caller with the requested size it may be necessary for the - * implementation to request a slightly greater segment length - * from the subsystem. In all cases, the apr_shm_baseaddr_get() - * function will return the first usable byte of memory. - * - */ -APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, - apr_size_t reqsize, - const char *filename, - apr_pool_t *pool); - -/** - * Remove named resource associated with a shared memory segment, - * preventing attachments to the resource, but not destroying it. - * @param filename The filename associated with shared-memory segment which - * needs to be removed - * @param pool The pool used for file operations - * @remark This function is only supported on platforms which support - * name-based shared memory segments, and will return APR_ENOTIMPL on - * platforms without such support. Removing the file while the shm - * is in use is not entirely portable, caller may use this to enhance - * obscurity of the resource, but be prepared for the the call to fail, - * and for concurrent attempts to create a resource of the same name - * to also fail. The pool cleanup of apr_shm_create (apr_shm_destroy) - * also removes the named resource. - */ -APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename, - apr_pool_t *pool); - -/** - * Destroy a shared memory segment and associated memory. - * @param m The shared memory segment structure to destroy. - */ -APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shm_t *m); - -/** - * Attach to a shared memory segment that was created - * by another process. - * @param m The shared memory structure to create. - * @param filename The file used to create the original segment. - * (This MUST match the original filename.) - * @param pool the pool from which to allocate the shared memory - * structure for this process. - */ -APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, - const char *filename, - apr_pool_t *pool); - -/** - * Detach from a shared memory segment without destroying it. - * @param m The shared memory structure representing the segment - * to detach from. - */ -APR_DECLARE(apr_status_t) apr_shm_detach(apr_shm_t *m); - -/** - * Retrieve the base address of the shared memory segment. - * NOTE: This address is only usable within the callers address - * space, since this API does not guarantee that other attaching - * processes will maintain the same address mapping. - * @param m The shared memory segment from which to retrieve - * the base address. - * @return address, aligned by APR_ALIGN_DEFAULT. - */ -APR_DECLARE(void *) apr_shm_baseaddr_get(const apr_shm_t *m); - -/** - * Retrieve the length of a shared memory segment in bytes. - * @param m The shared memory segment from which to retrieve - * the segment length. - */ -APR_DECLARE(apr_size_t) apr_shm_size_get(const apr_shm_t *m); - -/** - * Get the pool used by this shared memory segment. - */ -APR_POOL_DECLARE_ACCESSOR(shm); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* APR_SHM_T */ diff --git a/libs/apr/include/apr_signal.h b/libs/apr/include/apr_signal.h deleted file mode 100644 index 20631333..00000000 --- a/libs/apr/include/apr_signal.h +++ /dev/null @@ -1,109 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_SIGNAL_H -#define APR_SIGNAL_H - -/** - * @file apr_signal.h - * @brief APR Signal Handling - */ - -#include "apr.h" -#include "apr_pools.h" - -#if APR_HAVE_SIGNAL_H -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup apr_signal Signal Handling - * @ingroup APR - * @{ - */ - -#if APR_HAVE_SIGACTION || defined(DOXYGEN) - -#if defined(DARWIN) && !defined(__cplusplus) && !defined(_ANSI_SOURCE) -/* work around Darwin header file bugs - * http://www.opensource.apple.com/bugs/X/BSD%20Kernel/2657228.html - */ -#undef SIG_DFL -#undef SIG_IGN -#undef SIG_ERR -#define SIG_DFL (void (*)(int))0 -#define SIG_IGN (void (*)(int))1 -#define SIG_ERR (void (*)(int))-1 -#endif - -/** Function prototype for signal handlers */ -typedef void apr_sigfunc_t(int); - -/** - * Set the signal handler function for a given signal - * @param signo The signal (eg... SIGWINCH) - * @param func the function to get called - */ -APR_DECLARE(apr_sigfunc_t *) apr_signal(int signo, apr_sigfunc_t * func); - -#if defined(SIG_IGN) && !defined(SIG_ERR) -#define SIG_ERR ((apr_sigfunc_t *) -1) -#endif - -#else /* !APR_HAVE_SIGACTION */ -#define apr_signal(a, b) signal(a, b) -#endif - - -/** - * Get the description for a specific signal number - * @param signum The signal number - * @return The description of the signal - */ -APR_DECLARE(const char *) apr_signal_description_get(int signum); - -/** - * APR-private function for initializing the signal package - * @internal - * @param pglobal The internal, global pool - */ -void apr_signal_init(apr_pool_t *pglobal); - -/** - * Block the delivery of a particular signal - * @param signum The signal number - * @return status - */ -APR_DECLARE(apr_status_t) apr_signal_block(int signum); - -/** - * Enable the delivery of a particular signal - * @param signum The signal number - * @return status - */ -APR_DECLARE(apr_status_t) apr_signal_unblock(int signum); - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* APR_SIGNAL_H */ diff --git a/libs/apr/include/apr_strings.h b/libs/apr/include/apr_strings.h deleted file mode 100644 index 6b71ff17..00000000 --- a/libs/apr/include/apr_strings.h +++ /dev/null @@ -1,366 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* Portions of this file are covered by */ -/* -*- mode: c; c-file-style: "k&r" -*- - - strnatcmp.c -- Perform 'natural order' comparisons of strings in C. - Copyright (C) 2000 by Martin Pool - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef APR_STRINGS_H -#define APR_STRINGS_H - -/** - * @file apr_strings.h - * @brief APR Strings library - */ - -#include "apr.h" -#include "apr_errno.h" -#include "apr_pools.h" -#define APR_WANT_IOVEC -#include "apr_want.h" - -#if APR_HAVE_STDARG_H -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup apr_strings String routines - * @ingroup APR - * @{ - */ - -/** - * Do a natural order comparison of two strings. - * @param a The first string to compare - * @param b The second string to compare - * @return Either <0, 0, or >0. If the first string is less than the second - * this returns <0, if they are equivalent it returns 0, and if the - * first string is greater than second string it retuns >0. - */ -APR_DECLARE(int) apr_strnatcmp(char const *a, char const *b); - -/** - * Do a natural order comparison of two strings ignoring the case of the - * strings. - * @param a The first string to compare - * @param b The second string to compare - * @return Either <0, 0, or >0. If the first string is less than the second - * this returns <0, if they are equivalent it returns 0, and if the - * first string is greater than second string it retuns >0. - */ -APR_DECLARE(int) apr_strnatcasecmp(char const *a, char const *b); - -/** - * duplicate a string into memory allocated out of a pool - * @param p The pool to allocate out of - * @param s The string to duplicate - * @return The new string - */ -APR_DECLARE(char *) apr_pstrdup(apr_pool_t *p, const char *s); - -/** - * Create a null-terminated string by making a copy of a sequence - * of characters and appending a null byte - * @param p The pool to allocate out of - * @param s The block of characters to duplicate - * @param n The number of characters to duplicate - * @return The new string - * @remark This is a faster alternative to apr_pstrndup, for use - * when you know that the string being duplicated really - * has 'n' or more characters. If the string might contain - * fewer characters, use apr_pstrndup. - */ -APR_DECLARE(char *) apr_pstrmemdup(apr_pool_t *p, const char *s, apr_size_t n); - -/** - * Duplicate at most n characters of a string into memory allocated - * out of a pool; the new string will be NUL-terminated - * @param p The pool to allocate out of - * @param s The string to duplicate - * @param n The maximum number of characters to duplicate - * @return The new string - * @remark The amount of memory allocated from the pool is the length - * of the returned string including the NUL terminator - */ -APR_DECLARE(char *) apr_pstrndup(apr_pool_t *p, const char *s, apr_size_t n); - -/** - * Duplicate a block of memory. - * - * @param p The pool to allocate from - * @param m The memory to duplicate - * @param n The number of bytes to duplicate - * @return The new block of memory - */ -APR_DECLARE(void *) apr_pmemdup(apr_pool_t *p, const void *m, apr_size_t n); - -/** - * Concatenate multiple strings, allocating memory out a pool - * @param p The pool to allocate out of - * @param ... The strings to concatenate. The final string must be NULL - * @return The new string - */ -APR_DECLARE_NONSTD(char *) apr_pstrcat(apr_pool_t *p, ...) -#if defined(__GNUC__) && __GNUC__ >= 4 - __attribute__((sentinel)) -#endif - ; - -/** - * Concatenate multiple strings specified in a writev-style vector - * @param p The pool from which to allocate - * @param vec The strings to concatenate - * @param nvec The number of strings to concatenate - * @param nbytes (output) strlen of new string (pass in NULL to omit) - * @return The new string - */ -APR_DECLARE(char *) apr_pstrcatv(apr_pool_t *p, const struct iovec *vec, - apr_size_t nvec, apr_size_t *nbytes); - -/** - * printf-style style printing routine. The data is output to a string - * allocated from a pool - * @param p The pool to allocate out of - * @param fmt The format of the string - * @param ap The arguments to use while printing the data - * @return The new string - */ -APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *p, const char *fmt, va_list ap); - -/** - * printf-style style printing routine. The data is output to a string - * allocated from a pool - * @param p The pool to allocate out of - * @param fmt The format of the string - * @param ... The arguments to use while printing the data - * @return The new string - */ -APR_DECLARE_NONSTD(char *) apr_psprintf(apr_pool_t *p, const char *fmt, ...) - __attribute__((format(printf,2,3))); - -/** - * Copy up to dst_size characters from src to dst; does not copy - * past a NUL terminator in src, but always terminates dst with a NUL - * regardless. - * @param dst The destination string - * @param src The source string - * @param dst_size The space available in dst; dst always receives - * NUL termination, so if src is longer than - * dst_size, the actual number of characters copied is - * dst_size - 1. - * @return Pointer to the NUL terminator of the destination string, dst - * @remark - *
    - * Note the differences between this function and strncpy():
    - *  1) strncpy() doesn't always NUL terminate; apr_cpystrn() does.
    - *  2) strncpy() pads the destination string with NULs, which is often 
    - *     unnecessary; apr_cpystrn() does not.
    - *  3) strncpy() returns a pointer to the beginning of the dst string;
    - *     apr_cpystrn() returns a pointer to the NUL terminator of dst, 
    - *     to allow a check for truncation.
    - * 
    - */ -APR_DECLARE(char *) apr_cpystrn(char *dst, const char *src, - apr_size_t dst_size); - -/** - * Remove all whitespace from a string - * @param dest The destination string. It is okay to modify the string - * in place. Namely dest == src - * @param src The string to rid the spaces from. - * @return A pointer to the destination string's null terminator. - */ -APR_DECLARE(char *) apr_collapse_spaces(char *dest, const char *src); - -/** - * Convert the arguments to a program from one string to an array of - * strings terminated by a NULL pointer - * @param arg_str The arguments to convert - * @param argv_out Output location. This is a pointer to an array of strings. - * @param token_context Pool to use. - */ -APR_DECLARE(apr_status_t) apr_tokenize_to_argv(const char *arg_str, - char ***argv_out, - apr_pool_t *token_context); - -/** - * Split a string into separate null-terminated tokens. The tokens are - * delimited in the string by one or more characters from the sep - * argument. - * @param str The string to separate; this should be specified on the - * first call to apr_strtok() for a given string, and NULL - * on subsequent calls. - * @param sep The set of delimiters - * @param last Internal state saved by apr_strtok() between calls. - * @return The next token from the string - */ -APR_DECLARE(char *) apr_strtok(char *str, const char *sep, char **last); - -/** - * @defgroup APR_Strings_Snprintf snprintf implementations - * @warning - * These are snprintf implementations based on apr_vformatter(). - * - * Note that various standards and implementations disagree on the return - * value of snprintf, and side-effects due to %n in the formatting string. - * apr_snprintf (and apr_vsnprintf) behaves as follows: - * - * Process the format string until the entire string is exhausted, or - * the buffer fills. If the buffer fills then stop processing immediately - * (so no further %n arguments are processed), and return the buffer - * length. In all cases the buffer is NUL terminated. It will return the - * number of characters inserted into the buffer, not including the - * terminating NUL. As a special case, if len is 0, apr_snprintf will - * return the number of characters that would have been inserted if - * the buffer had been infinite (in this case, *buffer can be NULL) - * - * In no event does apr_snprintf return a negative number. - * @{ - */ - -/** - * snprintf routine based on apr_vformatter. This means it understands the - * same extensions. - * @param buf The buffer to write to - * @param len The size of the buffer - * @param format The format string - * @param ... The arguments to use to fill out the format string. - */ -APR_DECLARE_NONSTD(int) apr_snprintf(char *buf, apr_size_t len, - const char *format, ...) - __attribute__((format(printf,3,4))); - -/** - * vsnprintf routine based on apr_vformatter. This means it understands the - * same extensions. - * @param buf The buffer to write to - * @param len The size of the buffer - * @param format The format string - * @param ap The arguments to use to fill out the format string. - */ -APR_DECLARE(int) apr_vsnprintf(char *buf, apr_size_t len, const char *format, - va_list ap); -/** @} */ - -/** - * create a string representation of an int, allocated from a pool - * @param p The pool from which to allocate - * @param n The number to format - * @return The string representation of the number - */ -APR_DECLARE(char *) apr_itoa(apr_pool_t *p, int n); - -/** - * create a string representation of a long, allocated from a pool - * @param p The pool from which to allocate - * @param n The number to format - * @return The string representation of the number - */ -APR_DECLARE(char *) apr_ltoa(apr_pool_t *p, long n); - -/** - * create a string representation of an apr_off_t, allocated from a pool - * @param p The pool from which to allocate - * @param n The number to format - * @return The string representation of the number - */ -APR_DECLARE(char *) apr_off_t_toa(apr_pool_t *p, apr_off_t n); - -/** - * Convert a numeric string into an apr_off_t numeric value. - * @param offset The value of the parsed string. - * @param buf The string to parse. It may contain optional whitespace, - * followed by an optional '+' (positive, default) or '-' (negative) - * character, followed by an optional '0x' prefix if base is 0 or 16, - * followed by numeric digits appropriate for base. - * @param end A pointer to the end of the valid character in buf. If - * not NULL, it is set to the first invalid character in buf. - * @param base A numeric base in the range between 2 and 36 inclusive, - * or 0. If base is zero, buf will be treated as base ten unless its - * digits are prefixed with '0x', in which case it will be treated as - * base 16. - * @bug *end breaks type safety; where *buf is const, *end needs to be - * declared as const in APR 2.0 - */ -APR_DECLARE(apr_status_t) apr_strtoff(apr_off_t *offset, const char *buf, - char **end, int base); - -/** - * parse a numeric string into a 64-bit numeric value - * @param buf The string to parse. It may contain optional whitespace, - * followed by an optional '+' (positive, default) or '-' (negative) - * character, followed by an optional '0x' prefix if base is 0 or 16, - * followed by numeric digits appropriate for base. - * @param end A pointer to the end of the valid character in buf. If - * not NULL, it is set to the first invalid character in buf. - * @param base A numeric base in the range between 2 and 36 inclusive, - * or 0. If base is zero, buf will be treated as base ten unless its - * digits are prefixed with '0x', in which case it will be treated as - * base 16. - * @return The numeric value of the string. On overflow, errno is set - * to ERANGE. On success, errno is set to 0. - */ -APR_DECLARE(apr_int64_t) apr_strtoi64(const char *buf, char **end, int base); - -/** - * parse a base-10 numeric string into a 64-bit numeric value. - * Equivalent to apr_strtoi64(buf, (char**)NULL, 10). - * @param buf The string to parse - * @return The numeric value of the string. On overflow, errno is set - * to ERANGE. On success, errno is set to 0. - */ -APR_DECLARE(apr_int64_t) apr_atoi64(const char *buf); - -/** - * Format a binary size (magnitiudes are 2^10 rather than 10^3) from an apr_off_t, - * as bytes, K, M, T, etc, to a four character compacted human readable string. - * @param size The size to format - * @param buf The 5 byte text buffer (counting the trailing null) - * @return The buf passed to apr_strfsize() - * @remark All negative sizes report ' - ', apr_strfsize only formats positive values. - */ -APR_DECLARE(char *) apr_strfsize(apr_off_t size, char *buf); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* !APR_STRINGS_H */ diff --git a/libs/apr/include/apr_support.h b/libs/apr/include/apr_support.h deleted file mode 100644 index 79c8cb47..00000000 --- a/libs/apr/include/apr_support.h +++ /dev/null @@ -1,57 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_SUPPORT_H -#define APR_SUPPORT_H - -/** - * @file apr_support.h - * @brief APR Support functions - */ - -#include "apr.h" -#include "apr_network_io.h" -#include "apr_file_io.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup apr_support Internal APR support functions - * @ingroup APR - * @{ - */ - -/** - * Wait for IO to occur or timeout. - * - * @param f The file to wait on. - * @param s The socket to wait on if @a f is @c NULL. - * @param for_read If non-zero wait for data to be available to read, - * otherwise wait for data to be able to be written. - * @return APR_TIMEUP if we run out of time. - */ -apr_status_t apr_wait_for_io_or_timeout(apr_file_t *f, apr_socket_t *s, - int for_read); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ! APR_SUPPORT_H */ diff --git a/libs/apr/include/apr_tables.h b/libs/apr/include/apr_tables.h deleted file mode 100644 index 1e7a57d1..00000000 --- a/libs/apr/include/apr_tables.h +++ /dev/null @@ -1,487 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_TABLES_H -#define APR_TABLES_H - -/** - * @file apr_tables.h - * @brief APR Table library - */ - -#include "apr.h" -#include "apr_pools.h" - -#if APR_HAVE_STDARG_H -#include /* for va_list */ -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup apr_tables Table and Array Functions - * @ingroup APR - * Arrays are used to store data which is referenced sequentially or - * as a stack. Functions are provided to push and pop individual - * elements as well as to operate on the entire array. - * - * Tables are used to store data which can be referenced by key. - * Limited capabilities are provided for tables with multiple elements - * which share a key; while key lookup will return only a single - * element, iteration is available. Additionally, a table can be - * compressed to resolve duplicates. - * - * Both arrays and tables may store string or binary data; some features, - * such as concatenation or merging of elements, work only for string - * data. - * @{ - */ - -/** the table abstract data type */ -typedef struct apr_table_t apr_table_t; - -/** @see apr_array_header_t */ -typedef struct apr_array_header_t apr_array_header_t; - -/** An opaque array type */ -struct apr_array_header_t { - /** The pool the array is allocated out of */ - apr_pool_t *pool; - /** The amount of memory allocated for each element of the array */ - int elt_size; - /** The number of active elements in the array */ - int nelts; - /** The number of elements allocated in the array */ - int nalloc; - /** The elements in the array */ - char *elts; -}; - -/** - * The (opaque) structure for string-content tables. - */ -typedef struct apr_table_entry_t apr_table_entry_t; - -/** The type for each entry in a string-content table */ -struct apr_table_entry_t { - /** The key for the current table entry */ - char *key; /* maybe NULL in future; - * check when iterating thru table_elts - */ - /** The value for the current table entry */ - char *val; - - /** A checksum for the key, for use by the apr_table internals */ - apr_uint32_t key_checksum; -}; - -/** - * Get the elements from a table. - * @param t The table - * @return An array containing the contents of the table - */ -APR_DECLARE(const apr_array_header_t *) apr_table_elts(const apr_table_t *t); - -/** - * Determine if the table is empty (either NULL or having no elements). - * @param t The table to check - * @return True if empty, False otherwise - */ -APR_DECLARE(int) apr_is_empty_table(const apr_table_t *t); - -/** - * Determine if the array is empty (either NULL or having no elements). - * @param a The array to check - * @return True if empty, False otherwise - */ -APR_DECLARE(int) apr_is_empty_array(const apr_array_header_t *a); - -/** - * Create an array. - * @param p The pool to allocate the memory out of - * @param nelts the number of elements in the initial array - * @param elt_size The size of each element in the array. - * @return The new array - */ -APR_DECLARE(apr_array_header_t *) apr_array_make(apr_pool_t *p, - int nelts, int elt_size); - -/** - * Add a new element to an array (as a first-in, last-out stack). - * @param arr The array to add an element to. - * @return Location for the new element in the array. - * @remark If there are no free spots in the array, then this function will - * allocate new space for the new element. - */ -APR_DECLARE(void *) apr_array_push(apr_array_header_t *arr); - -/** A helper macro for accessing a member of an APR array. - * - * @param ary the array - * @param i the index into the array to return - * @param type the type of the objects stored in the array - * - * @return the item at index i - */ -#define APR_ARRAY_IDX(ary,i,type) (((type *)(ary)->elts)[i]) - -/** A helper macro for pushing elements into an APR array. - * - * @param ary the array - * @param type the type of the objects stored in the array - * - * @return the location where the new object should be placed - */ -#define APR_ARRAY_PUSH(ary,type) (*((type *)apr_array_push(ary))) - -/** - * Remove an element from an array (as a first-in, last-out stack). - * @param arr The array to remove an element from. - * @return Location of the element in the array. - * @remark If there are no elements in the array, NULL is returned. - */ -APR_DECLARE(void *) apr_array_pop(apr_array_header_t *arr); - -/** - * Remove all elements from an array. - * @param arr The array to remove all elements from. - * @remark As the underlying storage is allocated from a pool, no - * memory is freed by this operation, but is available for reuse. - */ -APR_DECLARE(void) apr_array_clear(apr_array_header_t *arr); - -/** - * Concatenate two arrays together. - * @param dst The destination array, and the one to go first in the combined - * array - * @param src The source array to add to the destination array - */ -APR_DECLARE(void) apr_array_cat(apr_array_header_t *dst, - const apr_array_header_t *src); - -/** - * Copy the entire array. - * @param p The pool to allocate the copy of the array out of - * @param arr The array to copy - * @return An exact copy of the array passed in - * @remark The alternate apr_array_copy_hdr copies only the header, and arranges - * for the elements to be copied if (and only if) the code subsequently - * does a push or arraycat. - */ -APR_DECLARE(apr_array_header_t *) apr_array_copy(apr_pool_t *p, - const apr_array_header_t *arr); -/** - * Copy the headers of the array, and arrange for the elements to be copied if - * and only if the code subsequently does a push or arraycat. - * @param p The pool to allocate the copy of the array out of - * @param arr The array to copy - * @return An exact copy of the array passed in - * @remark The alternate apr_array_copy copies the *entire* array. - */ -APR_DECLARE(apr_array_header_t *) apr_array_copy_hdr(apr_pool_t *p, - const apr_array_header_t *arr); - -/** - * Append one array to the end of another, creating a new array in the process. - * @param p The pool to allocate the new array out of - * @param first The array to put first in the new array. - * @param second The array to put second in the new array. - * @return A new array containing the data from the two arrays passed in. -*/ -APR_DECLARE(apr_array_header_t *) apr_array_append(apr_pool_t *p, - const apr_array_header_t *first, - const apr_array_header_t *second); - -/** - * Generate a new string from the apr_pool_t containing the concatenated - * sequence of substrings referenced as elements within the array. The string - * will be empty if all substrings are empty or null, or if there are no - * elements in the array. If sep is non-NUL, it will be inserted between - * elements as a separator. - * @param p The pool to allocate the string out of - * @param arr The array to generate the string from - * @param sep The separator to use - * @return A string containing all of the data in the array. - */ -APR_DECLARE(char *) apr_array_pstrcat(apr_pool_t *p, - const apr_array_header_t *arr, - const char sep); - -/** - * Make a new table. - * @param p The pool to allocate the pool out of - * @param nelts The number of elements in the initial table. - * @return The new table. - * @warning This table can only store text data - */ -APR_DECLARE(apr_table_t *) apr_table_make(apr_pool_t *p, int nelts); - -/** - * Create a new table and copy another table into it. - * @param p The pool to allocate the new table out of - * @param t The table to copy - * @return A copy of the table passed in - * @warning The table keys and respective values are not copied - */ -APR_DECLARE(apr_table_t *) apr_table_copy(apr_pool_t *p, - const apr_table_t *t); - -/** - * Create a new table whose contents are deep copied from the given - * table. A deep copy operation copies all fields, and makes copies - * of dynamically allocated memory pointed to by the fields. - * @param p The pool to allocate the new table out of - * @param t The table to clone - * @return A deep copy of the table passed in - */ -APR_DECLARE(apr_table_t *) apr_table_clone(apr_pool_t *p, - const apr_table_t *t); - -/** - * Delete all of the elements from a table. - * @param t The table to clear - */ -APR_DECLARE(void) apr_table_clear(apr_table_t *t); - -/** - * Get the value associated with a given key from the table. After this call, - * the data is still in the table. - * @param t The table to search for the key - * @param key The key to search for (case does not matter) - * @return The value associated with the key, or NULL if the key does not exist. - */ -APR_DECLARE(const char *) apr_table_get(const apr_table_t *t, const char *key); - -/** - * Add a key/value pair to a table. If another element already exists with the - * same key, this will overwrite the old data. - * @param t The table to add the data to. - * @param key The key to use (case does not matter) - * @param val The value to add - * @remark When adding data, this function makes a copy of both the key and the - * value. - */ -APR_DECLARE(void) apr_table_set(apr_table_t *t, const char *key, - const char *val); - -/** - * Add a key/value pair to a table. If another element already exists with the - * same key, this will overwrite the old data. - * @param t The table to add the data to. - * @param key The key to use (case does not matter) - * @param val The value to add - * @warning When adding data, this function does not make a copy of the key or - * the value, so care should be taken to ensure that the values will - * not change after they have been added.. - */ -APR_DECLARE(void) apr_table_setn(apr_table_t *t, const char *key, - const char *val); - -/** - * Remove data from the table. - * @param t The table to remove data from - * @param key The key of the data being removed (case does not matter) - */ -APR_DECLARE(void) apr_table_unset(apr_table_t *t, const char *key); - -/** - * Add data to a table by merging the value with data that has already been - * stored. The merging is done by concatenating the two values, separated - * by the string ", ". - * @param t The table to search for the data - * @param key The key to merge data for (case does not matter) - * @param val The data to add - * @remark If the key is not found, then this function acts like apr_table_add - */ -APR_DECLARE(void) apr_table_merge(apr_table_t *t, const char *key, - const char *val); - -/** - * Add data to a table by merging the value with data that has already been - * stored. The merging is done by concatenating the two values, separated - * by the string ", ". - * @param t The table to search for the data - * @param key The key to merge data for (case does not matter) - * @param val The data to add - * @remark If the key is not found, then this function acts like apr_table_addn - */ -APR_DECLARE(void) apr_table_mergen(apr_table_t *t, const char *key, - const char *val); - -/** - * Add data to a table, regardless of whether there is another element with the - * same key. - * @param t The table to add to - * @param key The key to use - * @param val The value to add. - * @remark When adding data, this function makes a copy of both the key and the - * value. - */ -APR_DECLARE(void) apr_table_add(apr_table_t *t, const char *key, - const char *val); - -/** - * Add data to a table, regardless of whether there is another element with the - * same key. - * @param t The table to add to - * @param key The key to use - * @param val The value to add. - * @remark When adding data, this function does not make a copy of the key or the - * value, so care should be taken to ensure that the values will not - * change after they have been added. - */ -APR_DECLARE(void) apr_table_addn(apr_table_t *t, const char *key, - const char *val); - -/** - * Merge two tables into one new table. - * @param p The pool to use for the new table - * @param overlay The first table to put in the new table - * @param base The table to add at the end of the new table - * @return A new table containing all of the data from the two passed in - */ -APR_DECLARE(apr_table_t *) apr_table_overlay(apr_pool_t *p, - const apr_table_t *overlay, - const apr_table_t *base); - -/** - * Declaration prototype for the iterator callback function of apr_table_do() - * and apr_table_vdo(). - * @param rec The data passed as the first argument to apr_table_[v]do() - * @param key The key from this iteration of the table - * @param value The value from this iteration of the table - * @remark Iteration continues while this callback function returns non-zero. - * To export the callback function for apr_table_[v]do() it must be declared - * in the _NONSTD convention. - */ -typedef int (apr_table_do_callback_fn_t)(void *rec, const char *key, - const char *value); - -/** - * Iterate over a table running the provided function once for every - * element in the table. The varargs array must be a list of zero or - * more (char *) keys followed by a NULL pointer. If zero keys are - * given, the @param comp function will be invoked for every element - * in the table. Otherwise, the function is invoked only for those - * elements matching the keys specified. - * - * If an invocation of the @param comp function returns zero, - * iteration will continue using the next specified key, if any. - * - * @param comp The function to run - * @param rec The data to pass as the first argument to the function - * @param t The table to iterate over - * @param ... A varargs array of zero or more (char *) keys followed by NULL - * @return FALSE if one of the comp() iterations returned zero; TRUE if all - * iterations returned non-zero - * @see apr_table_do_callback_fn_t - */ -APR_DECLARE_NONSTD(int) apr_table_do(apr_table_do_callback_fn_t *comp, - void *rec, const apr_table_t *t, ...) -#if defined(__GNUC__) && __GNUC__ >= 4 - __attribute__((sentinel)) -#endif - ; - -/** - * Iterate over a table running the provided function once for every - * element in the table. The @param vp varargs parameter must be a - * list of zero or more (char *) keys followed by a NULL pointer. If - * zero keys are given, the @param comp function will be invoked for - * every element in the table. Otherwise, the function is invoked - * only for those elements matching the keys specified. - * - * If an invocation of the @param comp function returns zero, - * iteration will continue using the next specified key, if any. - * - * @param comp The function to run - * @param rec The data to pass as the first argument to the function - * @param t The table to iterate over - * @param vp List of zero or more (char *) keys followed by NULL - * @return FALSE if one of the comp() iterations returned zero; TRUE if all - * iterations returned non-zero - * @see apr_table_do_callback_fn_t - */ -APR_DECLARE(int) apr_table_vdo(apr_table_do_callback_fn_t *comp, - void *rec, const apr_table_t *t, va_list vp); - -/** flag for overlap to use apr_table_setn */ -#define APR_OVERLAP_TABLES_SET (0) -/** flag for overlap to use apr_table_mergen */ -#define APR_OVERLAP_TABLES_MERGE (1) -/** - * For each element in table b, either use setn or mergen to add the data - * to table a. Which method is used is determined by the flags passed in. - * @param a The table to add the data to. - * @param b The table to iterate over, adding its data to table a - * @param flags How to add the table to table a. One of: - * APR_OVERLAP_TABLES_SET Use apr_table_setn - * APR_OVERLAP_TABLES_MERGE Use apr_table_mergen - * @remark When merging duplicates, the two values are concatenated, - * separated by the string ", ". - * @remark This function is highly optimized, and uses less memory and CPU cycles - * than a function that just loops through table b calling other functions. - */ -/** - * Conceptually, apr_table_overlap does this: - * - *
    - *  apr_array_header_t *barr = apr_table_elts(b);
    - *  apr_table_entry_t *belt = (apr_table_entry_t *)barr->elts;
    - *  int i;
    - *
    - *  for (i = 0; i < barr->nelts; ++i) {
    - *      if (flags & APR_OVERLAP_TABLES_MERGE) {
    - *          apr_table_mergen(a, belt[i].key, belt[i].val);
    - *      }
    - *      else {
    - *          apr_table_setn(a, belt[i].key, belt[i].val);
    - *      }
    - *  }
    - * 
    - * - * Except that it is more efficient (less space and cpu-time) especially - * when b has many elements. - * - * Notice the assumptions on the keys and values in b -- they must be - * in an ancestor of a's pool. In practice b and a are usually from - * the same pool. - */ - -APR_DECLARE(void) apr_table_overlap(apr_table_t *a, const apr_table_t *b, - unsigned flags); - -/** - * Eliminate redundant entries in a table by either overwriting - * or merging duplicates. - * - * @param t Table. - * @param flags APR_OVERLAP_TABLES_MERGE to merge, or - * APR_OVERLAP_TABLES_SET to overwrite - * @remark When merging duplicates, the two values are concatenated, - * separated by the string ", ". - */ -APR_DECLARE(void) apr_table_compress(apr_table_t *t, unsigned flags); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ! APR_TABLES_H */ diff --git a/libs/apr/include/apr_thread_cond.h b/libs/apr/include/apr_thread_cond.h deleted file mode 100644 index 199f1ded..00000000 --- a/libs/apr/include/apr_thread_cond.h +++ /dev/null @@ -1,139 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_THREAD_COND_H -#define APR_THREAD_COND_H - -/** - * @file apr_thread_cond.h - * @brief APR Condition Variable Routines - */ - -#include "apr.h" -#include "apr_pools.h" -#include "apr_errno.h" -#include "apr_time.h" -#include "apr_thread_mutex.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#if APR_HAS_THREADS || defined(DOXYGEN) - -/** - * @defgroup apr_thread_cond Condition Variable Routines - * @ingroup APR - * @{ - */ - -/** Opaque structure for thread condition variables */ -typedef struct apr_thread_cond_t apr_thread_cond_t; - -/** - * Note: destroying a condition variable (or likewise, destroying or - * clearing the pool from which a condition variable was allocated) if - * any threads are blocked waiting on it gives undefined results. - */ - -/** - * Create and initialize a condition variable that can be used to signal - * and schedule threads in a single process. - * @param cond the memory address where the newly created condition variable - * will be stored. - * @param pool the pool from which to allocate the condition. - */ -APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond, - apr_pool_t *pool); - -/** - * Put the active calling thread to sleep until signaled to wake up. Each - * condition variable must be associated with a mutex, and that mutex must - * be locked before calling this function, or the behavior will be - * undefined. As the calling thread is put to sleep, the given mutex - * will be simultaneously released; and as this thread wakes up the lock - * is again simultaneously acquired. - * @param cond the condition variable on which to block. - * @param mutex the mutex that must be locked upon entering this function, - * is released while the thread is asleep, and is again acquired before - * returning from this function. - * @remark Spurious wakeups may occur. Before and after every call to wait on - * a condition variable, the caller should test whether the condition is already - * met. - */ -APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex); - -/** - * Put the active calling thread to sleep until signaled to wake up or - * the timeout is reached. Each condition variable must be associated - * with a mutex, and that mutex must be locked before calling this - * function, or the behavior will be undefined. As the calling thread - * is put to sleep, the given mutex will be simultaneously released; - * and as this thread wakes up the lock is again simultaneously acquired. - * @param cond the condition variable on which to block. - * @param mutex the mutex that must be locked upon entering this function, - * is released while the thread is asleep, and is again acquired before - * returning from this function. - * @param timeout The amount of time in microseconds to wait. This is - * a maximum, not a minimum. If the condition is signaled, we - * will wake up before this time, otherwise the error APR_TIMEUP - * is returned. - */ -APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex, - apr_interval_time_t timeout); - -/** - * Signals a single thread, if one exists, that is blocking on the given - * condition variable. That thread is then scheduled to wake up and acquire - * the associated mutex. Although it is not required, if predictable scheduling - * is desired, that mutex must be locked while calling this function. - * @param cond the condition variable on which to produce the signal. - * @remark If no threads are waiting on the condition variable, nothing happens. - */ -APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond); - -/** - * Signals all threads blocking on the given condition variable. - * Each thread that was signaled is then scheduled to wake up and acquire - * the associated mutex. This will happen in a serialized manner. - * @param cond the condition variable on which to produce the broadcast. - * @remark If no threads are waiting on the condition variable, nothing happens. - */ -APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond); - -/** - * Destroy the condition variable and free the associated memory. - * @param cond the condition variable to destroy. - */ -APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond); - -/** - * Get the pool used by this thread_cond. - * @return apr_pool_t the pool - */ -APR_POOL_DECLARE_ACCESSOR(thread_cond); - -#endif /* APR_HAS_THREADS */ - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ! APR_THREAD_COND_H */ diff --git a/libs/apr/include/apr_thread_mutex.h b/libs/apr/include/apr_thread_mutex.h deleted file mode 100644 index 4596dce5..00000000 --- a/libs/apr/include/apr_thread_mutex.h +++ /dev/null @@ -1,110 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_THREAD_MUTEX_H -#define APR_THREAD_MUTEX_H - -/** - * @file apr_thread_mutex.h - * @brief APR Thread Mutex Routines - */ - -#include "apr.h" -#include "apr_errno.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#if APR_HAS_THREADS || defined(DOXYGEN) - -/** - * @defgroup apr_thread_mutex Thread Mutex Routines - * @ingroup APR - * @{ - */ - -/** Opaque thread-local mutex structure */ -typedef struct apr_thread_mutex_t apr_thread_mutex_t; - -#define APR_THREAD_MUTEX_DEFAULT 0x0 /**< platform-optimal lock behavior */ -#define APR_THREAD_MUTEX_NESTED 0x1 /**< enable nested (recursive) locks */ -#define APR_THREAD_MUTEX_UNNESTED 0x2 /**< disable nested locks */ - -/* Delayed the include to avoid a circular reference */ -#include "apr_pools.h" - -/** - * Create and initialize a mutex that can be used to synchronize threads. - * @param mutex the memory address where the newly created mutex will be - * stored. - * @param flags Or'ed value of: - *
    - *           APR_THREAD_MUTEX_DEFAULT   platform-optimal lock behavior.
    - *           APR_THREAD_MUTEX_NESTED    enable nested (recursive) locks.
    - *           APR_THREAD_MUTEX_UNNESTED  disable nested locks (non-recursive).
    - * 
    - * @param pool the pool from which to allocate the mutex. - * @warning Be cautious in using APR_THREAD_MUTEX_DEFAULT. While this is the - * most optimial mutex based on a given platform's performance charateristics, - * it will behave as either a nested or an unnested lock. - */ -APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex, - unsigned int flags, - apr_pool_t *pool); -/** - * Acquire the lock for the given mutex. If the mutex is already locked, - * the current thread will be put to sleep until the lock becomes available. - * @param mutex the mutex on which to acquire the lock. - */ -APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex); - -/** - * Attempt to acquire the lock for the given mutex. If the mutex has already - * been acquired, the call returns immediately with APR_EBUSY. Note: it - * is important that the APR_STATUS_IS_EBUSY(s) macro be used to determine - * if the return value was APR_EBUSY, for portability reasons. - * @param mutex the mutex on which to attempt the lock acquiring. - */ -APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex); - -/** - * Release the lock for the given mutex. - * @param mutex the mutex from which to release the lock. - */ -APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex); - -/** - * Destroy the mutex and free the memory associated with the lock. - * @param mutex the mutex to destroy. - */ -APR_DECLARE(apr_status_t) apr_thread_mutex_destroy(apr_thread_mutex_t *mutex); - -/** - * Get the pool used by this thread_mutex. - * @return apr_pool_t the pool - */ -APR_POOL_DECLARE_ACCESSOR(thread_mutex); - -#endif /* APR_HAS_THREADS */ - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ! APR_THREAD_MUTEX_H */ diff --git a/libs/apr/include/apr_thread_proc.h b/libs/apr/include/apr_thread_proc.h deleted file mode 100644 index 7df84ef3..00000000 --- a/libs/apr/include/apr_thread_proc.h +++ /dev/null @@ -1,824 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_THREAD_PROC_H -#define APR_THREAD_PROC_H - -/** - * @file apr_thread_proc.h - * @brief APR Thread and Process Library - */ - -#include "apr.h" -#include "apr_file_io.h" -#include "apr_pools.h" -#include "apr_errno.h" - -#if APR_HAVE_STRUCT_RLIMIT -#include -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup apr_thread_proc Threads and Process Functions - * @ingroup APR - * @{ - */ - -typedef enum { - APR_SHELLCMD, /**< use the shell to invoke the program */ - APR_PROGRAM, /**< invoke the program directly, no copied env */ - APR_PROGRAM_ENV, /**< invoke the program, replicating our environment */ - APR_PROGRAM_PATH, /**< find program on PATH, use our environment */ - APR_SHELLCMD_ENV /**< use the shell to invoke the program, - * replicating our environment - */ -} apr_cmdtype_e; - -typedef enum { - APR_WAIT, /**< wait for the specified process to finish */ - APR_NOWAIT /**< do not wait -- just see if it has finished */ -} apr_wait_how_e; - -/* I am specifically calling out the values so that the macros below make - * more sense. Yes, I know I don't need to, but I am hoping this makes what - * I am doing more clear. If you want to add more reasons to exit, continue - * to use bitmasks. - */ -typedef enum { - APR_PROC_EXIT = 1, /**< process exited normally */ - APR_PROC_SIGNAL = 2, /**< process exited due to a signal */ - APR_PROC_SIGNAL_CORE = 4 /**< process exited and dumped a core file */ -} apr_exit_why_e; - -/** did we exit the process */ -#define APR_PROC_CHECK_EXIT(x) (x & APR_PROC_EXIT) -/** did we get a signal */ -#define APR_PROC_CHECK_SIGNALED(x) (x & APR_PROC_SIGNAL) -/** did we get core */ -#define APR_PROC_CHECK_CORE_DUMP(x) (x & APR_PROC_SIGNAL_CORE) - -/** @see apr_procattr_io_set */ -#define APR_NO_PIPE 0 -/** @see apr_procattr_io_set and apr_file_pipe_create_ex */ -#define APR_FULL_BLOCK 1 -/** @see apr_procattr_io_set and apr_file_pipe_create_ex */ -#define APR_FULL_NONBLOCK 2 -/** @see apr_procattr_io_set */ -#define APR_PARENT_BLOCK 3 -/** @see apr_procattr_io_set */ -#define APR_CHILD_BLOCK 4 -/** @see apr_procattr_io_set */ -#define APR_NO_FILE 8 - -/** @see apr_file_pipe_create_ex */ -#define APR_READ_BLOCK 3 -/** @see apr_file_pipe_create_ex */ -#define APR_WRITE_BLOCK 4 - -/** @see apr_procattr_io_set - * @note Win32 only effective with version 1.2.12, portably introduced in 1.3.0 - */ -#define APR_NO_FILE 8 - -/** @see apr_procattr_limit_set */ -#define APR_LIMIT_CPU 0 -/** @see apr_procattr_limit_set */ -#define APR_LIMIT_MEM 1 -/** @see apr_procattr_limit_set */ -#define APR_LIMIT_NPROC 2 -/** @see apr_procattr_limit_set */ -#define APR_LIMIT_NOFILE 3 - -/** - * @defgroup APR_OC Other Child Flags - * @{ - */ -#define APR_OC_REASON_DEATH 0 /**< child has died, caller must call - * unregister still */ -#define APR_OC_REASON_UNWRITABLE 1 /**< write_fd is unwritable */ -#define APR_OC_REASON_RESTART 2 /**< a restart is occuring, perform - * any necessary cleanup (including - * sending a special signal to child) - */ -#define APR_OC_REASON_UNREGISTER 3 /**< unregister has been called, do - * whatever is necessary (including - * kill the child) */ -#define APR_OC_REASON_LOST 4 /**< somehow the child exited without - * us knowing ... buggy os? */ -#define APR_OC_REASON_RUNNING 5 /**< a health check is occuring, - * for most maintainence functions - * this is a no-op. - */ -/** @} */ - -/** The APR process type */ -typedef struct apr_proc_t { - /** The process ID */ - pid_t pid; - /** Parent's side of pipe to child's stdin */ - apr_file_t *in; - /** Parent's side of pipe to child's stdout */ - apr_file_t *out; - /** Parent's side of pipe to child's stdouterr */ - apr_file_t *err; -#if APR_HAS_PROC_INVOKED || defined(DOXYGEN) - /** Diagnositics/debugging string of the command invoked for - * this process [only present if APR_HAS_PROC_INVOKED is true] - * @remark Only enabled on Win32 by default. - * @bug This should either always or never be present in release - * builds - since it breaks binary compatibility. We may enable - * it always in APR 1.0 yet leave it undefined in most cases. - */ - char *invoked; -#endif -#if defined(WIN32) || defined(DOXYGEN) - /** (Win32 only) Creator's handle granting access to the process - * @remark This handle is closed and reset to NULL in every case - * corresponding to a waitpid() on Unix which returns the exit status. - * Therefore Win32 correspond's to Unix's zombie reaping characteristics - * and avoids potential handle leaks. - */ - HANDLE hproc; -#endif -} apr_proc_t; - -/** - * The prototype for APR child errfn functions. (See the description - * of apr_procattr_child_errfn_set() for more information.) - * It is passed the following parameters: - * @param pool Pool associated with the apr_proc_t. If your child - * error function needs user data, associate it with this - * pool. - * @param err APR error code describing the error - * @param description Text description of type of processing which failed - */ -typedef void (apr_child_errfn_t)(apr_pool_t *proc, apr_status_t err, - const char *description); - -/** Opaque Thread structure. */ -typedef struct apr_thread_t apr_thread_t; - -/** Opaque Thread attributes structure. */ -typedef struct apr_threadattr_t apr_threadattr_t; - -/** Opaque Process attributes structure. */ -typedef struct apr_procattr_t apr_procattr_t; - -/** Opaque control variable for one-time atomic variables. */ -typedef struct apr_thread_once_t apr_thread_once_t; - -/** Opaque thread private address space. */ -typedef struct apr_threadkey_t apr_threadkey_t; - -/** Opaque record of child process. */ -typedef struct apr_other_child_rec_t apr_other_child_rec_t; - -/** - * The prototype for any APR thread worker functions. - */ -typedef void *(APR_THREAD_FUNC *apr_thread_start_t)(apr_thread_t*, void*); - -typedef enum { - APR_KILL_NEVER, /**< process is never sent any signals */ - APR_KILL_ALWAYS, /**< process is sent SIGKILL on apr_pool_t cleanup */ - APR_KILL_AFTER_TIMEOUT, /**< SIGTERM, wait 3 seconds, SIGKILL */ - APR_JUST_WAIT, /**< wait forever for the process to complete */ - APR_KILL_ONLY_ONCE /**< send SIGTERM and then wait */ -} apr_kill_conditions_e; - -/* Thread Function definitions */ - -#if APR_HAS_THREADS - -/** - * Create and initialize a new threadattr variable - * @param new_attr The newly created threadattr. - * @param cont The pool to use - */ -APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new_attr, - apr_pool_t *cont); - -/** - * Set if newly created threads should be created in detached state. - * @param attr The threadattr to affect - * @param on Non-zero if detached threads should be created. - */ -APR_DECLARE(apr_status_t) apr_threadattr_detach_set(apr_threadattr_t *attr, - apr_int32_t on); - -/** - * Get the detach state for this threadattr. - * @param attr The threadattr to reference - * @return APR_DETACH if threads are to be detached, or APR_NOTDETACH - * if threads are to be joinable. - */ -APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr); - -/** - * Set the stack size of newly created threads. - * @param attr The threadattr to affect - * @param stacksize The stack size in bytes - */ -APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, - apr_size_t stacksize); - -/** - * Set the stack guard area size of newly created threads. - * @param attr The threadattr to affect - * @param guardsize The stack guard area size in bytes - * @note Thread library implementations commonly use a "guard area" - * after each thread's stack which is not readable or writable such that - * stack overflows cause a segfault; this consumes e.g. 4K of memory - * and increases memory management overhead. Setting the guard area - * size to zero hence trades off reliable behaviour on stack overflow - * for performance. */ -APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr, - apr_size_t guardsize); - -/** - * Create a new thread of execution - * @param new_thread The newly created thread handle. - * @param attr The threadattr to use to determine how to create the thread - * @param func The function to start the new thread in - * @param data Any data to be passed to the starting function - * @param cont The pool to use - */ -APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new_thread, - apr_threadattr_t *attr, - apr_thread_start_t func, - void *data, apr_pool_t *cont); - -/** - * stop the current thread - * @param thd The thread to stop - * @param retval The return value to pass back to any thread that cares - */ -APR_DECLARE(apr_status_t) apr_thread_exit(apr_thread_t *thd, - apr_status_t retval); - -/** - * block until the desired thread stops executing. - * @param retval The return value from the dead thread. - * @param thd The thread to join - */ -APR_DECLARE(apr_status_t) apr_thread_join(apr_status_t *retval, - apr_thread_t *thd); - -/** - * force the current thread to yield the processor - */ -APR_DECLARE(void) apr_thread_yield(void); - -/** - * Initialize the control variable for apr_thread_once. If this isn't - * called, apr_initialize won't work. - * @param control The control variable to initialize - * @param p The pool to allocate data from. - */ -APR_DECLARE(apr_status_t) apr_thread_once_init(apr_thread_once_t **control, - apr_pool_t *p); - -/** - * Run the specified function one time, regardless of how many threads - * call it. - * @param control The control variable. The same variable should - * be passed in each time the function is tried to be - * called. This is how the underlying functions determine - * if the function has ever been called before. - * @param func The function to call. - */ -APR_DECLARE(apr_status_t) apr_thread_once(apr_thread_once_t *control, - void (*func)(void)); - -/** - * detach a thread - * @param thd The thread to detach - */ -APR_DECLARE(apr_status_t) apr_thread_detach(apr_thread_t *thd); - -/** - * Return the pool associated with the current thread. - * @param data The user data associated with the thread. - * @param key The key to associate with the data - * @param thread The currently open thread. - */ -APR_DECLARE(apr_status_t) apr_thread_data_get(void **data, const char *key, - apr_thread_t *thread); - -/** - * Return the pool associated with the current thread. - * @param data The user data to associate with the thread. - * @param key The key to use for associating the data with the thread - * @param cleanup The cleanup routine to use when the thread is destroyed. - * @param thread The currently open thread. - */ -APR_DECLARE(apr_status_t) apr_thread_data_set(void *data, const char *key, - apr_status_t (*cleanup) (void *), - apr_thread_t *thread); - -/** - * Create and initialize a new thread private address space - * @param key The thread private handle. - * @param dest The destructor to use when freeing the private memory. - * @param cont The pool to use - */ -APR_DECLARE(apr_status_t) apr_threadkey_private_create(apr_threadkey_t **key, - void (*dest)(void *), - apr_pool_t *cont); - -/** - * Get a pointer to the thread private memory - * @param new_mem The data stored in private memory - * @param key The handle for the desired thread private memory - */ -APR_DECLARE(apr_status_t) apr_threadkey_private_get(void **new_mem, - apr_threadkey_t *key); - -/** - * Set the data to be stored in thread private memory - * @param priv The data to be stored in private memory - * @param key The handle for the desired thread private memory - */ -APR_DECLARE(apr_status_t) apr_threadkey_private_set(void *priv, - apr_threadkey_t *key); - -/** - * Free the thread private memory - * @param key The handle for the desired thread private memory - */ -APR_DECLARE(apr_status_t) apr_threadkey_private_delete(apr_threadkey_t *key); - -/** - * Return the pool associated with the current threadkey. - * @param data The user data associated with the threadkey. - * @param key The key associated with the data - * @param threadkey The currently open threadkey. - */ -APR_DECLARE(apr_status_t) apr_threadkey_data_get(void **data, const char *key, - apr_threadkey_t *threadkey); - -/** - * Return the pool associated with the current threadkey. - * @param data The data to set. - * @param key The key to associate with the data. - * @param cleanup The cleanup routine to use when the file is destroyed. - * @param threadkey The currently open threadkey. - */ -APR_DECLARE(apr_status_t) apr_threadkey_data_set(void *data, const char *key, - apr_status_t (*cleanup) (void *), - apr_threadkey_t *threadkey); - -#endif - -/** - * Create and initialize a new procattr variable - * @param new_attr The newly created procattr. - * @param cont The pool to use - */ -APR_DECLARE(apr_status_t) apr_procattr_create(apr_procattr_t **new_attr, - apr_pool_t *cont); - -/** - * Determine if any of stdin, stdout, or stderr should be linked to pipes - * when starting a child process. - * @param attr The procattr we care about. - * @param in Should stdin be a pipe back to the parent? - * @param out Should stdout be a pipe back to the parent? - * @param err Should stderr be a pipe back to the parent? - * @note If APR_NO_PIPE, there will be no special channel, the child - * inherits the parent's corresponding stdio stream. If APR_NO_FILE is - * specified, that corresponding stream is closed in the child (and will - * be INVALID_HANDLE_VALUE when inspected on Win32). This can have ugly - * side effects, as the next file opened in the child on Unix will fall - * into the stdio stream fd slot! - */ -APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, - apr_int32_t in, apr_int32_t out, - apr_int32_t err); - -/** - * Set the child_in and/or parent_in values to existing apr_file_t values. - * @param attr The procattr we care about. - * @param child_in apr_file_t value to use as child_in. Must be a valid file. - * @param parent_in apr_file_t value to use as parent_in. Must be a valid file. - * @remark This is NOT a required initializer function. This is - * useful if you have already opened a pipe (or multiple files) - * that you wish to use, perhaps persistently across multiple - * process invocations - such as a log file. You can save some - * extra function calls by not creating your own pipe since this - * creates one in the process space for you. - * @bug Note that calling this function with two NULL files on some platforms - * creates an APR_FULL_BLOCK pipe, but this behavior is neither portable nor - * is it supported. @see apr_procattr_io_set instead for simple pipes. - */ -APR_DECLARE(apr_status_t) apr_procattr_child_in_set(struct apr_procattr_t *attr, - apr_file_t *child_in, - apr_file_t *parent_in); - -/** - * Set the child_out and parent_out values to existing apr_file_t values. - * @param attr The procattr we care about. - * @param child_out apr_file_t value to use as child_out. Must be a valid file. - * @param parent_out apr_file_t value to use as parent_out. Must be a valid file. - * @remark This is NOT a required initializer function. This is - * useful if you have already opened a pipe (or multiple files) - * that you wish to use, perhaps persistently across multiple - * process invocations - such as a log file. - * @bug Note that calling this function with two NULL files on some platforms - * creates an APR_FULL_BLOCK pipe, but this behavior is neither portable nor - * is it supported. @see apr_procattr_io_set instead for simple pipes. - */ -APR_DECLARE(apr_status_t) apr_procattr_child_out_set(struct apr_procattr_t *attr, - apr_file_t *child_out, - apr_file_t *parent_out); - -/** - * Set the child_err and parent_err values to existing apr_file_t values. - * @param attr The procattr we care about. - * @param child_err apr_file_t value to use as child_err. Must be a valid file. - * @param parent_err apr_file_t value to use as parent_err. Must be a valid file. - * @remark This is NOT a required initializer function. This is - * useful if you have already opened a pipe (or multiple files) - * that you wish to use, perhaps persistently across multiple - * process invocations - such as a log file. - * @bug Note that calling this function with two NULL files on some platforms - * creates an APR_FULL_BLOCK pipe, but this behavior is neither portable nor - * is it supported. @see apr_procattr_io_set instead for simple pipes. - */ -APR_DECLARE(apr_status_t) apr_procattr_child_err_set(struct apr_procattr_t *attr, - apr_file_t *child_err, - apr_file_t *parent_err); - -/** - * Set which directory the child process should start executing in. - * @param attr The procattr we care about. - * @param dir Which dir to start in. By default, this is the same dir as - * the parent currently resides in, when the createprocess call - * is made. - */ -APR_DECLARE(apr_status_t) apr_procattr_dir_set(apr_procattr_t *attr, - const char *dir); - -/** - * Set what type of command the child process will call. - * @param attr The procattr we care about. - * @param cmd The type of command. One of: - *
    - *            APR_SHELLCMD     --  Anything that the shell can handle
    - *            APR_PROGRAM      --  Executable program   (default) 
    - *            APR_PROGRAM_ENV  --  Executable program, copy environment
    - *            APR_PROGRAM_PATH --  Executable program on PATH, copy env
    - * 
    - */ -APR_DECLARE(apr_status_t) apr_procattr_cmdtype_set(apr_procattr_t *attr, - apr_cmdtype_e cmd); - -/** - * Determine if the child should start in detached state. - * @param attr The procattr we care about. - * @param detach Should the child start in detached state? Default is no. - */ -APR_DECLARE(apr_status_t) apr_procattr_detach_set(apr_procattr_t *attr, - apr_int32_t detach); - -#if APR_HAVE_STRUCT_RLIMIT -/** - * Set the Resource Utilization limits when starting a new process. - * @param attr The procattr we care about. - * @param what Which limit to set, one of: - *
    - *                 APR_LIMIT_CPU
    - *                 APR_LIMIT_MEM
    - *                 APR_LIMIT_NPROC
    - *                 APR_LIMIT_NOFILE
    - * 
    - * @param limit Value to set the limit to. - */ -APR_DECLARE(apr_status_t) apr_procattr_limit_set(apr_procattr_t *attr, - apr_int32_t what, - struct rlimit *limit); -#endif - -/** - * Specify an error function to be called in the child process if APR - * encounters an error in the child prior to running the specified program. - * @param attr The procattr describing the child process to be created. - * @param errfn The function to call in the child process. - * @remark At the present time, it will only be called from apr_proc_create() - * on platforms where fork() is used. It will never be called on other - * platforms, on those platforms apr_proc_create() will return the error - * in the parent process rather than invoke the callback in the now-forked - * child process. - */ -APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr, - apr_child_errfn_t *errfn); - -/** - * Specify that apr_proc_create() should do whatever it can to report - * failures to the caller of apr_proc_create(), rather than find out in - * the child. - * @param attr The procattr describing the child process to be created. - * @param chk Flag to indicate whether or not extra work should be done - * to try to report failures to the caller. - * @remark This flag only affects apr_proc_create() on platforms where - * fork() is used. This leads to extra overhead in the calling - * process, but that may help the application handle such - * errors more gracefully. - */ -APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr, - apr_int32_t chk); - -/** - * Determine if the child should start in its own address space or using the - * current one from its parent - * @param attr The procattr we care about. - * @param addrspace Should the child start in its own address space? Default - * is no on NetWare and yes on other platforms. - */ -APR_DECLARE(apr_status_t) apr_procattr_addrspace_set(apr_procattr_t *attr, - apr_int32_t addrspace); - -/** - * Set the username used for running process - * @param attr The procattr we care about. - * @param username The username used - * @param password User password if needed. Password is needed on WIN32 - * or any other platform having - * APR_PROCATTR_USER_SET_REQUIRES_PASSWORD set. - */ -APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr, - const char *username, - const char *password); - -/** - * Set the group used for running process - * @param attr The procattr we care about. - * @param groupname The group name used - */ -APR_DECLARE(apr_status_t) apr_procattr_group_set(apr_procattr_t *attr, - const char *groupname); - - -#if APR_HAS_FORK -/** - * This is currently the only non-portable call in APR. This executes - * a standard unix fork. - * @param proc The resulting process handle. - * @param cont The pool to use. - * @remark returns APR_INCHILD for the child, and APR_INPARENT for the parent - * or an error. - */ -APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *cont); -#endif - -/** - * Create a new process and execute a new program within that process. - * @param new_proc The resulting process handle. - * @param progname The program to run - * @param args the arguments to pass to the new program. The first - * one should be the program name. - * @param env The new environment table for the new process. This - * should be a list of NULL-terminated strings. This argument - * is ignored for APR_PROGRAM_ENV, APR_PROGRAM_PATH, and - * APR_SHELLCMD_ENV types of commands. - * @param attr the procattr we should use to determine how to create the new - * process - * @param pool The pool to use. - * @note This function returns without waiting for the new process to terminate; - * use apr_proc_wait for that. - */ -APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new_proc, - const char *progname, - const char * const *args, - const char * const *env, - apr_procattr_t *attr, - apr_pool_t *pool); - -/** - * Wait for a child process to die - * @param proc The process handle that corresponds to the desired child process - * @param exitcode The returned exit status of the child, if a child process - * dies, or the signal that caused the child to die. - * On platforms that don't support obtaining this information, - * the status parameter will be returned as APR_ENOTIMPL. - * @param exitwhy Why the child died, the bitwise or of: - *
    - *            APR_PROC_EXIT         -- process terminated normally
    - *            APR_PROC_SIGNAL       -- process was killed by a signal
    - *            APR_PROC_SIGNAL_CORE  -- process was killed by a signal, and
    - *                                     generated a core dump.
    - * 
    - * @param waithow How should we wait. One of: - *
    - *            APR_WAIT   -- block until the child process dies.
    - *            APR_NOWAIT -- return immediately regardless of if the 
    - *                          child is dead or not.
    - * 
    - * @remark The childs status is in the return code to this process. It is one of: - *
    - *            APR_CHILD_DONE     -- child is no longer running.
    - *            APR_CHILD_NOTDONE  -- child is still running.
    - * 
    - */ -APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, - int *exitcode, apr_exit_why_e *exitwhy, - apr_wait_how_e waithow); - -/** - * Wait for any current child process to die and return information - * about that child. - * @param proc Pointer to NULL on entry, will be filled out with child's - * information - * @param exitcode The returned exit status of the child, if a child process - * dies, or the signal that caused the child to die. - * On platforms that don't support obtaining this information, - * the status parameter will be returned as APR_ENOTIMPL. - * @param exitwhy Why the child died, the bitwise or of: - *
    - *            APR_PROC_EXIT         -- process terminated normally
    - *            APR_PROC_SIGNAL       -- process was killed by a signal
    - *            APR_PROC_SIGNAL_CORE  -- process was killed by a signal, and
    - *                                     generated a core dump.
    - * 
    - * @param waithow How should we wait. One of: - *
    - *            APR_WAIT   -- block until the child process dies.
    - *            APR_NOWAIT -- return immediately regardless of if the 
    - *                          child is dead or not.
    - * 
    - * @param p Pool to allocate child information out of. - * @bug Passing proc as a *proc rather than **proc was an odd choice - * for some platforms... this should be revisited in 1.0 - */ -APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc, - int *exitcode, - apr_exit_why_e *exitwhy, - apr_wait_how_e waithow, - apr_pool_t *p); - -#define APR_PROC_DETACH_FOREGROUND 0 /**< Do not detach */ -#define APR_PROC_DETACH_DAEMONIZE 1 /**< Detach */ - -/** - * Detach the process from the controlling terminal. - * @param daemonize set to non-zero if the process should daemonize - * and become a background process, else it will - * stay in the foreground. - */ -APR_DECLARE(apr_status_t) apr_proc_detach(int daemonize); - -/** - * Register an other_child -- a child associated to its registered - * maintence callback. This callback is invoked when the process - * dies, is disconnected or disappears. - * @param proc The child process to register. - * @param maintenance maintenance is a function that is invoked with a - * reason and the data pointer passed here. - * @param data Opaque context data passed to the maintenance function. - * @param write_fd An fd that is probed for writing. If it is ever unwritable - * then the maintenance is invoked with reason - * OC_REASON_UNWRITABLE. - * @param p The pool to use for allocating memory. - * @bug write_fd duplicates the proc->out stream, it's really redundant - * and should be replaced in the APR 1.0 API with a bitflag of which - * proc->in/out/err handles should be health checked. - * @bug no platform currently tests the pipes health. - */ -APR_DECLARE(void) apr_proc_other_child_register(apr_proc_t *proc, - void (*maintenance) (int reason, - void *, - int status), - void *data, apr_file_t *write_fd, - apr_pool_t *p); - -/** - * Stop watching the specified other child. - * @param data The data to pass to the maintenance function. This is - * used to find the process to unregister. - * @warning Since this can be called by a maintenance function while we're - * scanning the other_children list, all scanners should protect - * themself by loading ocr->next before calling any maintenance - * function. - */ -APR_DECLARE(void) apr_proc_other_child_unregister(void *data); - -/** - * Notify the maintenance callback of a registered other child process - * that application has detected an event, such as death. - * @param proc The process to check - * @param reason The reason code to pass to the maintenance function - * @param status The status to pass to the maintenance function - * @remark An example of code using this behavior; - *
    - * rv = apr_proc_wait_all_procs(&proc, &exitcode, &status, APR_WAIT, p);
    - * if (APR_STATUS_IS_CHILD_DONE(rv)) {
    - * \#if APR_HAS_OTHER_CHILD
    - *     if (apr_proc_other_child_alert(&proc, APR_OC_REASON_DEATH, status)
    - *             == APR_SUCCESS) {
    - *         ;  (already handled)
    - *     }
    - *     else
    - * \#endif
    - *         [... handling non-otherchild processes death ...]
    - * 
    - */ -APR_DECLARE(apr_status_t) apr_proc_other_child_alert(apr_proc_t *proc, - int reason, - int status); - -/** - * Test one specific other child processes and invoke the maintenance callback - * with the appropriate reason code, if still running, or the appropriate reason - * code if the process is no longer healthy. - * @param ocr The registered other child - * @param reason The reason code (e.g. APR_OC_REASON_RESTART) if still running - */ -APR_DECLARE(void) apr_proc_other_child_refresh(apr_other_child_rec_t *ocr, - int reason); - -/** - * Test all registered other child processes and invoke the maintenance callback - * with the appropriate reason code, if still running, or the appropriate reason - * code if the process is no longer healthy. - * @param reason The reason code (e.g. APR_OC_REASON_RESTART) to running processes - */ -APR_DECLARE(void) apr_proc_other_child_refresh_all(int reason); - -/** - * Terminate a process. - * @param proc The process to terminate. - * @param sig How to kill the process. - */ -APR_DECLARE(apr_status_t) apr_proc_kill(apr_proc_t *proc, int sig); - -/** - * Register a process to be killed when a pool dies. - * @param a The pool to use to define the processes lifetime - * @param proc The process to register - * @param how How to kill the process, one of: - *
    - *         APR_KILL_NEVER         -- process is never sent any signals
    - *         APR_KILL_ALWAYS        -- process is sent SIGKILL on apr_pool_t cleanup
    - *         APR_KILL_AFTER_TIMEOUT -- SIGTERM, wait 3 seconds, SIGKILL
    - *         APR_JUST_WAIT          -- wait forever for the process to complete
    - *         APR_KILL_ONLY_ONCE     -- send SIGTERM and then wait
    - * 
    - */ -APR_DECLARE(void) apr_pool_note_subprocess(apr_pool_t *a, apr_proc_t *proc, - apr_kill_conditions_e how); - -#if APR_HAS_THREADS - -#if (APR_HAVE_SIGWAIT || APR_HAVE_SIGSUSPEND) && !defined(OS2) - -/** - * Setup the process for a single thread to be used for all signal handling. - * @warning This must be called before any threads are created - */ -APR_DECLARE(apr_status_t) apr_setup_signal_thread(void); - -/** - * Make the current thread listen for signals. This thread will loop - * forever, calling a provided function whenever it receives a signal. That - * functions should return 1 if the signal has been handled, 0 otherwise. - * @param signal_handler The function to call when a signal is received - * apr_status_t apr_signal_thread((int)(*signal_handler)(int signum)) - */ -APR_DECLARE(apr_status_t) apr_signal_thread(int(*signal_handler)(int signum)); - -#endif /* (APR_HAVE_SIGWAIT || APR_HAVE_SIGSUSPEND) && !defined(OS2) */ - -/** - * Get the child-pool used by the thread from the thread info. - * @return apr_pool_t the pool - */ -APR_POOL_DECLARE_ACCESSOR(thread); - -#endif /* APR_HAS_THREADS */ - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ! APR_THREAD_PROC_H */ - diff --git a/libs/apr/include/apr_thread_rwlock.h b/libs/apr/include/apr_thread_rwlock.h deleted file mode 100644 index 0bd958fb..00000000 --- a/libs/apr/include/apr_thread_rwlock.h +++ /dev/null @@ -1,129 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_THREAD_RWLOCK_H -#define APR_THREAD_RWLOCK_H - -/** - * @file apr_thread_rwlock.h - * @brief APR Reader/Writer Lock Routines - */ - -#include "apr.h" -#include "apr_pools.h" -#include "apr_errno.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#if APR_HAS_THREADS - -/** - * @defgroup apr_thread_rwlock Reader/Writer Lock Routines - * @ingroup APR - * @{ - */ - -/** Opaque read-write thread-safe lock. */ -typedef struct apr_thread_rwlock_t apr_thread_rwlock_t; - -/** - * Note: The following operations have undefined results: unlocking a - * read-write lock which is not locked in the calling thread; write - * locking a read-write lock which is already locked by the calling - * thread; destroying a read-write lock more than once; clearing or - * destroying the pool from which a locked read-write lock is - * allocated. - */ - -/** - * Create and initialize a read-write lock that can be used to synchronize - * threads. - * @param rwlock the memory address where the newly created readwrite lock - * will be stored. - * @param pool the pool from which to allocate the mutex. - */ -APR_DECLARE(apr_status_t) apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock, - apr_pool_t *pool); -/** - * Acquire a shared-read lock on the given read-write lock. This will allow - * multiple threads to enter the same critical section while they have acquired - * the read lock. - * @param rwlock the read-write lock on which to acquire the shared read. - */ -APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock); - -/** - * Attempt to acquire the shared-read lock on the given read-write lock. This - * is the same as apr_thread_rwlock_rdlock(), only that the function fails - * if there is another thread holding the write lock, or if there are any - * write threads blocking on the lock. If the function fails for this case, - * APR_EBUSY will be returned. Note: it is important that the - * APR_STATUS_IS_EBUSY(s) macro be used to determine if the return value was - * APR_EBUSY, for portability reasons. - * @param rwlock the rwlock on which to attempt the shared read. - */ -APR_DECLARE(apr_status_t) apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwlock); - -/** - * Acquire an exclusive-write lock on the given read-write lock. This will - * allow only one single thread to enter the critical sections. If there - * are any threads currently holding the read-lock, this thread is put to - * sleep until it can have exclusive access to the lock. - * @param rwlock the read-write lock on which to acquire the exclusive write. - */ -APR_DECLARE(apr_status_t) apr_thread_rwlock_wrlock(apr_thread_rwlock_t *rwlock); - -/** - * Attempt to acquire the exclusive-write lock on the given read-write lock. - * This is the same as apr_thread_rwlock_wrlock(), only that the function fails - * if there is any other thread holding the lock (for reading or writing), - * in which case the function will return APR_EBUSY. Note: it is important - * that the APR_STATUS_IS_EBUSY(s) macro be used to determine if the return - * value was APR_EBUSY, for portability reasons. - * @param rwlock the rwlock on which to attempt the exclusive write. - */ -APR_DECLARE(apr_status_t) apr_thread_rwlock_trywrlock(apr_thread_rwlock_t *rwlock); - -/** - * Release either the read or write lock currently held by the calling thread - * associated with the given read-write lock. - * @param rwlock the read-write lock to be released (unlocked). - */ -APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock); - -/** - * Destroy the read-write lock and free the associated memory. - * @param rwlock the rwlock to destroy. - */ -APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t *rwlock); - -/** - * Get the pool used by this thread_rwlock. - * @return apr_pool_t the pool - */ -APR_POOL_DECLARE_ACCESSOR(thread_rwlock); - -#endif /* APR_HAS_THREADS */ - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ! APR_THREAD_RWLOCK_H */ diff --git a/libs/apr/include/apr_time.h b/libs/apr/include/apr_time.h deleted file mode 100644 index 6dd70cc8..00000000 --- a/libs/apr/include/apr_time.h +++ /dev/null @@ -1,235 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_TIME_H -#define APR_TIME_H - -/** - * @file apr_time.h - * @brief APR Time Library - */ - -#include "apr.h" -#include "apr_pools.h" -#include "apr_errno.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup apr_time Time Routines - * @ingroup APR - * @{ - */ - -/** month names */ -APR_DECLARE_DATA extern const char apr_month_snames[12][4]; -/** day names */ -APR_DECLARE_DATA extern const char apr_day_snames[7][4]; - - -/** number of microseconds since 00:00:00 january 1, 1970 UTC */ -typedef apr_int64_t apr_time_t; - - -/** mechanism to properly type apr_time_t literals */ -#define APR_TIME_C(val) APR_INT64_C(val) - -/** mechanism to properly print apr_time_t values */ -#define APR_TIME_T_FMT APR_INT64_T_FMT - -/** intervals for I/O timeouts, in microseconds */ -typedef apr_int64_t apr_interval_time_t; -/** short interval for I/O timeouts, in microseconds */ -typedef apr_int32_t apr_short_interval_time_t; - -/** number of microseconds per second */ -#define APR_USEC_PER_SEC APR_TIME_C(1000000) - -/** @return apr_time_t as a second */ -#define apr_time_sec(time) ((time) / APR_USEC_PER_SEC) - -/** @return apr_time_t as a usec */ -#define apr_time_usec(time) ((time) % APR_USEC_PER_SEC) - -/** @return apr_time_t as a msec */ -#define apr_time_msec(time) (((time) / 1000) % 1000) - -/** @return apr_time_t as a msec */ -#define apr_time_as_msec(time) ((time) / 1000) - -/** @return milliseconds as an apr_time_t */ -#define apr_time_from_msec(msec) ((apr_time_t)(msec) * 1000) - -/** @return seconds as an apr_time_t */ -#define apr_time_from_sec(sec) ((apr_time_t)(sec) * APR_USEC_PER_SEC) - -/** @return a second and usec combination as an apr_time_t */ -#define apr_time_make(sec, usec) ((apr_time_t)(sec) * APR_USEC_PER_SEC \ - + (apr_time_t)(usec)) - -/** - * @return the current time - */ -APR_DECLARE(apr_time_t) apr_time_now(void); - -/** @see apr_time_exp_t */ -typedef struct apr_time_exp_t apr_time_exp_t; - -/** - * a structure similar to ANSI struct tm with the following differences: - * - tm_usec isn't an ANSI field - * - tm_gmtoff isn't an ANSI field (it's a bsdism) - */ -struct apr_time_exp_t { - /** microseconds past tm_sec */ - apr_int32_t tm_usec; - /** (0-61) seconds past tm_min */ - apr_int32_t tm_sec; - /** (0-59) minutes past tm_hour */ - apr_int32_t tm_min; - /** (0-23) hours past midnight */ - apr_int32_t tm_hour; - /** (1-31) day of the month */ - apr_int32_t tm_mday; - /** (0-11) month of the year */ - apr_int32_t tm_mon; - /** year since 1900 */ - apr_int32_t tm_year; - /** (0-6) days since sunday */ - apr_int32_t tm_wday; - /** (0-365) days since jan 1 */ - apr_int32_t tm_yday; - /** daylight saving time */ - apr_int32_t tm_isdst; - /** seconds east of UTC */ - apr_int32_t tm_gmtoff; -}; - -/** - * convert an ansi time_t to an apr_time_t - * @param result the resulting apr_time_t - * @param input the time_t to convert - */ -APR_DECLARE(apr_status_t) apr_time_ansi_put(apr_time_t *result, - time_t input); - -/** - * convert a time to its human readable components using an offset - * from GMT - * @param result the exploded time - * @param input the time to explode - * @param offs the number of seconds offset to apply - */ -APR_DECLARE(apr_status_t) apr_time_exp_tz(apr_time_exp_t *result, - apr_time_t input, - apr_int32_t offs); - -/** - * convert a time to its human readable components in GMT timezone - * @param result the exploded time - * @param input the time to explode - */ -APR_DECLARE(apr_status_t) apr_time_exp_gmt(apr_time_exp_t *result, - apr_time_t input); - -/** - * convert a time to its human readable components in local timezone - * @param result the exploded time - * @param input the time to explode - */ -APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result, - apr_time_t input); - -/** - * Convert time value from human readable format to a numeric apr_time_t - * e.g. elapsed usec since epoch - * @param result the resulting imploded time - * @param input the input exploded time - */ -APR_DECLARE(apr_status_t) apr_time_exp_get(apr_time_t *result, - apr_time_exp_t *input); - -/** - * Convert time value from human readable format to a numeric apr_time_t that - * always represents GMT - * @param result the resulting imploded time - * @param input the input exploded time - */ -APR_DECLARE(apr_status_t) apr_time_exp_gmt_get(apr_time_t *result, - apr_time_exp_t *input); - -/** - * Sleep for the specified number of micro-seconds. - * @param t desired amount of time to sleep. - * @warning May sleep for longer than the specified time. - */ -APR_DECLARE(void) apr_sleep(apr_interval_time_t t); - -/** length of a RFC822 Date */ -#define APR_RFC822_DATE_LEN (30) -/** - * apr_rfc822_date formats dates in the RFC822 - * format in an efficient manner. It is a fixed length - * format which requires the indicated amount of storage, - * including the trailing NUL terminator. - * @param date_str String to write to. - * @param t the time to convert - */ -APR_DECLARE(apr_status_t) apr_rfc822_date(char *date_str, apr_time_t t); - -/** length of a CTIME date */ -#define APR_CTIME_LEN (25) -/** - * apr_ctime formats dates in the ctime() format - * in an efficient manner. it is a fixed length format - * and requires the indicated amount of storage including - * the trailing NUL terminator. - * Unlike ANSI/ISO C ctime(), apr_ctime() does not include - * a \n at the end of the string. - * @param date_str String to write to. - * @param t the time to convert - */ -APR_DECLARE(apr_status_t) apr_ctime(char *date_str, apr_time_t t); - -/** - * formats the exploded time according to the format specified - * @param s string to write to - * @param retsize The length of the returned string - * @param max The maximum length of the string - * @param format The format for the time string - * @param tm The time to convert - */ -APR_DECLARE(apr_status_t) apr_strftime(char *s, apr_size_t *retsize, - apr_size_t max, const char *format, - apr_time_exp_t *tm); - -/** - * Improve the clock resolution for the lifetime of the given pool. - * Generally this is only desireable on benchmarking and other very - * time-sensitive applications, and has no impact on most platforms. - * @param p The pool to associate the finer clock resolution - */ -APR_DECLARE(void) apr_time_clock_hires(apr_pool_t *p); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ! APR_TIME_H */ diff --git a/libs/apr/include/apr_user.h b/libs/apr/include/apr_user.h deleted file mode 100644 index 0179e226..00000000 --- a/libs/apr/include/apr_user.h +++ /dev/null @@ -1,158 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_USER_H -#define APR_USER_H - -/** - * @file apr_user.h - * @brief APR User ID Services - */ - -#include "apr.h" -#include "apr_errno.h" -#include "apr_pools.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup apr_user User and Group ID Services - * @ingroup APR - * @{ - */ - -/** - * Structure for determining user ownership. - */ -#ifdef WIN32 -typedef PSID apr_uid_t; -#else -typedef uid_t apr_uid_t; -#endif - -/** - * Structure for determining group ownership. - */ -#ifdef WIN32 -typedef PSID apr_gid_t; -#else -typedef gid_t apr_gid_t; -#endif - -#if APR_HAS_USER - -/** - * Get the userid (and groupid) of the calling process - * @param userid Returns the user id - * @param groupid Returns the user's group id - * @param p The pool from which to allocate working space - * @remark This function is available only if APR_HAS_USER is defined. - */ -APR_DECLARE(apr_status_t) apr_uid_current(apr_uid_t *userid, - apr_gid_t *groupid, - apr_pool_t *p); - -/** - * Get the user name for a specified userid - * @param username Pointer to new string containing user name (on output) - * @param userid The userid - * @param p The pool from which to allocate the string - * @remark This function is available only if APR_HAS_USER is defined. - */ -APR_DECLARE(apr_status_t) apr_uid_name_get(char **username, apr_uid_t userid, - apr_pool_t *p); - -/** - * Get the userid (and groupid) for the specified username - * @param userid Returns the user id - * @param groupid Returns the user's group id - * @param username The username to lookup - * @param p The pool from which to allocate working space - * @remark This function is available only if APR_HAS_USER is defined. - */ -APR_DECLARE(apr_status_t) apr_uid_get(apr_uid_t *userid, apr_gid_t *groupid, - const char *username, apr_pool_t *p); - -/** - * Get the home directory for the named user - * @param dirname Pointer to new string containing directory name (on output) - * @param username The named user - * @param p The pool from which to allocate the string - * @remark This function is available only if APR_HAS_USER is defined. - */ -APR_DECLARE(apr_status_t) apr_uid_homepath_get(char **dirname, - const char *username, - apr_pool_t *p); - -/** - * Compare two user identifiers for equality. - * @param left One uid to test - * @param right Another uid to test - * @return APR_SUCCESS if the apr_uid_t strutures identify the same user, - * APR_EMISMATCH if not, APR_BADARG if an apr_uid_t is invalid. - * @remark This function is available only if APR_HAS_USER is defined. - */ -#if defined(WIN32) -APR_DECLARE(apr_status_t) apr_uid_compare(apr_uid_t left, apr_uid_t right); -#else -#define apr_uid_compare(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH) -#endif - -/** - * Get the group name for a specified groupid - * @param groupname Pointer to new string containing group name (on output) - * @param groupid The groupid - * @param p The pool from which to allocate the string - * @remark This function is available only if APR_HAS_USER is defined. - */ -APR_DECLARE(apr_status_t) apr_gid_name_get(char **groupname, - apr_gid_t groupid, apr_pool_t *p); - -/** - * Get the groupid for a specified group name - * @param groupid Pointer to the group id (on output) - * @param groupname The group name to look up - * @param p The pool from which to allocate the string - * @remark This function is available only if APR_HAS_USER is defined. - */ -APR_DECLARE(apr_status_t) apr_gid_get(apr_gid_t *groupid, - const char *groupname, apr_pool_t *p); - -/** - * Compare two group identifiers for equality. - * @param left One gid to test - * @param right Another gid to test - * @return APR_SUCCESS if the apr_gid_t strutures identify the same group, - * APR_EMISMATCH if not, APR_BADARG if an apr_gid_t is invalid. - * @remark This function is available only if APR_HAS_USER is defined. - */ -#if defined(WIN32) -APR_DECLARE(apr_status_t) apr_gid_compare(apr_gid_t left, apr_gid_t right); -#else -#define apr_gid_compare(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH) -#endif - -#endif /* ! APR_HAS_USER */ - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ! APR_USER_H */ diff --git a/libs/apr/include/apr_version.h b/libs/apr/include/apr_version.h deleted file mode 100644 index 81223207..00000000 --- a/libs/apr/include/apr_version.h +++ /dev/null @@ -1,159 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_VERSION_H -#define APR_VERSION_H - -/** - * @file apr_version.h - * @brief APR Versioning Interface - * - * APR's Version - * - * There are several different mechanisms for accessing the version. There - * is a string form, and a set of numbers; in addition, there are constants - * which can be compiled into your application, and you can query the library - * being used for its actual version. - * - * Note that it is possible for an application to detect that it has been - * compiled against a different version of APR by use of the compile-time - * constants and the use of the run-time query function. - * - * APR version numbering follows the guidelines specified in: - * - * http://apr.apache.org/versioning.html - */ - - -/* The numeric compile-time version constants. These constants are the - * authoritative version numbers for APR. - */ - -/** major version - * Major API changes that could cause compatibility problems for older - * programs such as structure size changes. No binary compatibility is - * possible across a change in the major version. - */ -#define APR_MAJOR_VERSION 1 - -/** minor version - * Minor API changes that do not cause binary compatibility problems. - * Reset to 0 when upgrading APR_MAJOR_VERSION - */ -#define APR_MINOR_VERSION 4 - -/** patch level - * The Patch Level never includes API changes, simply bug fixes. - * Reset to 0 when upgrading APR_MINOR_VERSION - */ -#define APR_PATCH_VERSION 6 - -/** - * The symbol APR_IS_DEV_VERSION is only defined for internal, - * "development" copies of APR. It is undefined for released versions - * of APR. - */ -/* #define APR_IS_DEV_VERSION */ - -/** - * Check at compile time if the APR version is at least a certain - * level. - * @param major The major version component of the version checked - * for (e.g., the "1" of "1.3.0"). - * @param minor The minor version component of the version checked - * for (e.g., the "3" of "1.3.0"). - * @param patch The patch level component of the version checked - * for (e.g., the "0" of "1.3.0"). - * @remark This macro is available with APR versions starting with - * 1.3.0. - */ -#define APR_VERSION_AT_LEAST(major,minor,patch) \ -(((major) < APR_MAJOR_VERSION) \ - || ((major) == APR_MAJOR_VERSION && (minor) < APR_MINOR_VERSION) \ - || ((major) == APR_MAJOR_VERSION && (minor) == APR_MINOR_VERSION && (patch) <= APR_PATCH_VERSION)) - -#if defined(APR_IS_DEV_VERSION) || defined(DOXYGEN) -/** Internal: string form of the "is dev" flag */ -#define APR_IS_DEV_STRING "-dev" -#else -#define APR_IS_DEV_STRING "" -#endif - -/* APR_STRINGIFY is defined here, and also in apr_general.h, so wrap it */ -#ifndef APR_STRINGIFY -/** Properly quote a value as a string in the C preprocessor */ -#define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n) -/** Helper macro for APR_STRINGIFY */ -#define APR_STRINGIFY_HELPER(n) #n -#endif - -/** The formatted string of APR's version */ -#define APR_VERSION_STRING \ - APR_STRINGIFY(APR_MAJOR_VERSION) "." \ - APR_STRINGIFY(APR_MINOR_VERSION) "." \ - APR_STRINGIFY(APR_PATCH_VERSION) \ - APR_IS_DEV_STRING - -/** An alternative formatted string of APR's version */ -/* macro for Win32 .rc files using numeric csv representation */ -#define APR_VERSION_STRING_CSV APR_MAJOR_VERSION ##, \ - ##APR_MINOR_VERSION ##, \ - ##APR_PATCH_VERSION - - -#ifndef APR_VERSION_ONLY - -/* The C language API to access the version at run time, - * as opposed to compile time. APR_VERSION_ONLY may be defined - * externally when preprocessing apr_version.h to obtain strictly - * the C Preprocessor macro declarations. - */ - -#include "apr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * The numeric version information is broken out into fields within this - * structure. - */ -typedef struct { - int major; /**< major number */ - int minor; /**< minor number */ - int patch; /**< patch number */ - int is_dev; /**< is development (1 or 0) */ -} apr_version_t; - -/** - * Return APR's version information information in a numeric form. - * - * @param pvsn Pointer to a version structure for returning the version - * information. - */ -APR_DECLARE(void) apr_version(apr_version_t *pvsn); - -/** Return APR's version information as a string. */ -APR_DECLARE(const char *) apr_version_string(void); - -#ifdef __cplusplus -} -#endif - -#endif /* ndef APR_VERSION_ONLY */ - -#endif /* ndef APR_VERSION_H */ diff --git a/libs/apr/include/apr_want.h b/libs/apr/include/apr_want.h deleted file mode 100644 index 2863b001..00000000 --- a/libs/apr/include/apr_want.h +++ /dev/null @@ -1,124 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" /* configuration data */ -/** - * @file apr_want.h - * @brief APR Standard Headers Support - * - *
    - * Features:
    - *
    - *   APR_WANT_STRFUNC:  strcmp, strcat, strcpy, etc
    - *   APR_WANT_MEMFUNC:  memcmp, memcpy, etc
    - *   APR_WANT_STDIO:     and related bits
    - *   APR_WANT_IOVEC:    struct iovec
    - *   APR_WANT_BYTEFUNC: htons, htonl, ntohl, ntohs
    - *
    - * Typical usage:
    - *
    - *   \#define APR_WANT_STRFUNC
    - *   \#define APR_WANT_MEMFUNC
    - *   \#include "apr_want.h"
    - *
    - * The appropriate headers will be included.
    - *
    - * Note: it is safe to use this in a header (it won't interfere with other
    - *       headers' or source files' use of apr_want.h)
    - * 
    - */ - -/* --------------------------------------------------------------------- */ - -#ifdef APR_WANT_STRFUNC - -#if APR_HAVE_STRING_H -#include -#endif -#if APR_HAVE_STRINGS_H -#include -#endif - -#undef APR_WANT_STRFUNC -#endif - -/* --------------------------------------------------------------------- */ - -#ifdef APR_WANT_MEMFUNC - -#if APR_HAVE_STRING_H -#include -#endif - -#undef APR_WANT_MEMFUNC -#endif - -/* --------------------------------------------------------------------- */ - -#ifdef APR_WANT_STDIO - -#if APR_HAVE_STDIO_H -#include -#endif - -#undef APR_WANT_STDIO -#endif - -/* --------------------------------------------------------------------- */ - -#ifdef APR_WANT_IOVEC - -#if APR_HAVE_IOVEC - -#if APR_HAVE_SYS_UIO_H -#include -#endif - -#else - -#ifndef APR_IOVEC_DEFINED -#define APR_IOVEC_DEFINED -struct iovec -{ - void *iov_base; - size_t iov_len; -}; -#endif /* !APR_IOVEC_DEFINED */ - -#endif /* APR_HAVE_IOVEC */ - -#undef APR_WANT_IOVEC -#endif - -/* --------------------------------------------------------------------- */ - -#ifdef APR_WANT_BYTEFUNC - -/* Single Unix says they are in arpa/inet.h. Linux has them in - * netinet/in.h. FreeBSD has them in arpa/inet.h but requires that - * netinet/in.h be included first. - */ -#if APR_HAVE_NETINET_IN_H -#include -#endif -#if APR_HAVE_ARPA_INET_H -#include -#endif - -#undef APR_WANT_BYTEFUNC -#endif - -/* --------------------------------------------------------------------- */ diff --git a/libs/apr/include/arch/aix/apr_arch_dso.h b/libs/apr/include/arch/aix/apr_arch_dso.h deleted file mode 100644 index d1cac684..00000000 --- a/libs/apr/include/arch/aix/apr_arch_dso.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DSO_H -#define DSO_H - -#include "apr_private.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_dso.h" -#include "apr.h" - -#if APR_HAS_DSO - -void *dlopen(const char *path, int mode); -void *dlsym(void *handle, const char *symbol); -const char *dlerror(void); -int dlclose(void *handle); - -struct apr_dso_handle_t { - apr_pool_t *pool; - void *handle; - const char *errormsg; -}; - -#endif - -#endif diff --git a/libs/apr/include/arch/apr_private_common.h b/libs/apr/include/arch/apr_private_common.h deleted file mode 100644 index ec850c65..00000000 --- a/libs/apr/include/arch/apr_private_common.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * This file contains private declarations common to all architectures. - */ - -#ifndef APR_PRIVATE_COMMON_H -#define APR_PRIVATE_COMMON_H - -#include "apr_pools.h" -#include "apr_tables.h" - -apr_status_t apr_filepath_list_split_impl(apr_array_header_t **pathelts, - const char *liststr, - char separator, - apr_pool_t *p); - -apr_status_t apr_filepath_list_merge_impl(char **liststr, - apr_array_header_t *pathelts, - char separator, - apr_pool_t *p); - -/* temporary defines to handle 64bit compile mismatches */ -#define APR_INT_TRUNC_CAST int -#define APR_UINT32_TRUNC_CAST apr_uint32_t - -#endif /*APR_PRIVATE_COMMON_H*/ diff --git a/libs/apr/include/arch/beos/apr_arch_dso.h b/libs/apr/include/arch/beos/apr_arch_dso.h deleted file mode 100644 index fbc5c2ff..00000000 --- a/libs/apr/include/arch/beos/apr_arch_dso.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DSO_H -#define DSO_H - -#include "apr_private.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_errno.h" -#include "apr_dso.h" -#include "apr.h" -#include -#include - -#if APR_HAS_DSO - -struct apr_dso_handle_t { - image_id handle; /* Handle to the DSO loaded */ - apr_pool_t *pool; - const char *errormsg; /* if the load fails, we have an error - * message here :) - */ -}; - -#endif - -#endif diff --git a/libs/apr/include/arch/beos/apr_arch_proc_mutex.h b/libs/apr/include/arch/beos/apr_arch_proc_mutex.h deleted file mode 100644 index c60d8c62..00000000 --- a/libs/apr/include/arch/beos/apr_arch_proc_mutex.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PROC_MUTEX_H -#define PROC_MUTEX_H - -#include "apr_pools.h" -#include "apr_proc_mutex.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_portable.h" - -struct apr_proc_mutex_t { - apr_pool_t *pool; - - /* Our lock :) */ - sem_id Lock; - int32 LockCount; -}; - -#endif /* PROC_MUTEX_H */ - diff --git a/libs/apr/include/arch/beos/apr_arch_thread_cond.h b/libs/apr/include/arch/beos/apr_arch_thread_cond.h deleted file mode 100644 index c9420b53..00000000 --- a/libs/apr/include/arch/beos/apr_arch_thread_cond.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef THREAD_COND_H -#define THREAD_COND_H - -#include -#include "apr_pools.h" -#include "apr_thread_cond.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_portable.h" -#include "apr_ring.h" - -struct waiter_t { - APR_RING_ENTRY(waiter_t) link; - sem_id sem; -}; - -struct apr_thread_cond_t { - apr_pool_t *pool; - sem_id lock; - apr_thread_mutex_t *condlock; - thread_id owner; - /* active list */ - APR_RING_HEAD(active_list, waiter_t) alist; - /* free list */ - APR_RING_HEAD(free_list, waiter_t) flist; -}; - -#endif /* THREAD_COND_H */ - diff --git a/libs/apr/include/arch/beos/apr_arch_thread_mutex.h b/libs/apr/include/arch/beos/apr_arch_thread_mutex.h deleted file mode 100644 index bb7d4ae8..00000000 --- a/libs/apr/include/arch/beos/apr_arch_thread_mutex.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef THREAD_MUTEX_H -#define THREAD_MUTEX_H - -#include -#include "apr_pools.h" -#include "apr_thread_mutex.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_portable.h" - -struct apr_thread_mutex_t { - apr_pool_t *pool; - - /* Our lock :) */ - sem_id Lock; - int32 LockCount; - - /* If we nest locks we need these... */ - int nested; - apr_os_thread_t owner; - int owner_ref; -}; - -#endif /* THREAD_MUTEX_H */ - diff --git a/libs/apr/include/arch/beos/apr_arch_thread_rwlock.h b/libs/apr/include/arch/beos/apr_arch_thread_rwlock.h deleted file mode 100644 index 694b0d50..00000000 --- a/libs/apr/include/arch/beos/apr_arch_thread_rwlock.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef THREAD_RWLOCK_H -#define THREAD_RWLOCK_H - -#include -#include "apr_pools.h" -#include "apr_thread_rwlock.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_portable.h" - -struct apr_thread_rwlock_t { - apr_pool_t *pool; - - /* Our lock :) */ - sem_id Lock; - int32 LockCount; - /* Read/Write lock stuff */ - sem_id Read; - int32 ReadCount; - sem_id Write; - int32 WriteCount; - int32 Nested; - - thread_id writer; -}; - -#endif /* THREAD_RWLOCK_H */ - diff --git a/libs/apr/include/arch/beos/apr_arch_threadproc.h b/libs/apr/include/arch/beos/apr_arch_threadproc.h deleted file mode 100644 index 13de0536..00000000 --- a/libs/apr/include/arch/beos/apr_arch_threadproc.h +++ /dev/null @@ -1,95 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_thread_proc.h" -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_thread_proc.h" -#include "apr_general.h" -#include "apr_portable.h" -#include -#include -#include -#include -#include - -#ifndef THREAD_PROC_H -#define THREAD_PROC_H - -#define SHELL_PATH "/bin/sh" - -#define PTHREAD_CANCEL_AYNCHRONOUS CANCEL_ASYNCH; -#define PTHREAD_CANCEL_DEFERRED CANCEL_DEFER; - -#define PTHREAD_CANCEL_ENABLE CANCEL_ENABLE; -#define PTHREAD_CANCEL_DISABLE CANCEL_DISABLE; - -#define BEOS_MAX_DATAKEYS 128 - -struct apr_thread_t { - apr_pool_t *pool; - thread_id td; - void *data; - apr_thread_start_t func; - apr_status_t exitval; -}; - -struct apr_threadattr_t { - apr_pool_t *pool; - int32 attr; - int detached; - int joinable; -}; - -struct apr_threadkey_t { - apr_pool_t *pool; - int32 key; -}; - -struct beos_private_data { - const void ** data; - int count; - volatile thread_id td; -}; - -struct beos_key { - int assigned; - int count; - sem_id lock; - int32 ben_lock; - void (* destructor) (void *); -}; - -struct apr_procattr_t { - apr_pool_t *pool; - apr_file_t *parent_in; - apr_file_t *child_in; - apr_file_t *parent_out; - apr_file_t *child_out; - apr_file_t *parent_err; - apr_file_t *child_err; - char *currdir; - apr_int32_t cmdtype; - apr_int32_t detached; -}; - -struct apr_thread_once_t { - sem_id sem; - int hit; -}; - -#endif /* ! THREAD_PROC_H */ - diff --git a/libs/apr/include/arch/netware/apr_arch_dso.h b/libs/apr/include/arch/netware/apr_arch_dso.h deleted file mode 100644 index ea0fe8c2..00000000 --- a/libs/apr/include/arch/netware/apr_arch_dso.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DSO_H -#define DSO_H - -#include "apr_private.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_dso.h" -#include "apr.h" - -#include - -typedef struct sym_list sym_list; - -struct sym_list { - sym_list *next; - char *symbol; -}; - -struct apr_dso_handle_t { - apr_pool_t *pool; - void *handle; - const char *errormsg; - sym_list *symbols; - char *path; -}; - -#endif diff --git a/libs/apr/include/arch/netware/apr_arch_file_io.h b/libs/apr/include/arch/netware/apr_arch_file_io.h deleted file mode 100644 index 8bd2a72c..00000000 --- a/libs/apr/include/arch/netware/apr_arch_file_io.h +++ /dev/null @@ -1,176 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FILE_IO_H -#define FILE_IO_H - -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_tables.h" -#include "apr_file_io.h" -#include "apr_file_info.h" -#include "apr_errno.h" -#include "apr_lib.h" -#include "apr_poll.h" - -/* System headers the file I/O library needs */ -#if APR_HAVE_FCNTL_H -#include -#endif -#if APR_HAVE_SYS_TYPES_H -#include -#endif -#if APR_HAVE_ERRNO_H -#include -#endif -#if APR_HAVE_STRING_H -#include -#endif -#if APR_HAVE_STRINGS_H -#include -#endif -#if APR_HAVE_DIRENT_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif -#if APR_HAVE_UNISTD_H -#include -#endif -#if APR_HAVE_STDIO_H -#include -#endif -#if APR_HAVE_STDLIB_H -#include -#endif -#if APR_HAVE_SYS_UIO_H -#include -#endif -#if APR_HAVE_SYS_TIME_H -#include -#endif - -#include - -/* End System headers */ - -#define APR_FILE_DEFAULT_BUFSIZE 4096 -/* For backwards compat */ -#define APR_FILE_BUFSIZE APR_FILE_DEFAULT_BUFSIZE - -#if APR_HAS_THREADS -#define file_lock(f) do { \ - if ((f)->thlock) \ - apr_thread_mutex_lock((f)->thlock); \ - } while (0) -#define file_unlock(f) do { \ - if ((f)->thlock) \ - apr_thread_mutex_unlock((f)->thlock); \ - } while (0) -#else -#define file_lock(f) do {} while (0) -#define file_unlock(f) do {} while (0) -#endif - -#if APR_HAS_LARGE_FILES -#define lseek(f,o,w) lseek64(f,o,w) -#define ftruncate(f,l) ftruncate64(f,l) -#endif - -typedef struct stat struct_stat; - -struct apr_file_t { - apr_pool_t *pool; - int filedes; - char *fname; - apr_int32_t flags; - int eof_hit; - int is_pipe; - apr_interval_time_t timeout; - int buffered; - enum {BLK_UNKNOWN, BLK_OFF, BLK_ON } blocking; - int ungetchar; /* Last char provided by an unget op. (-1 = no char)*/ - - /* if there is a timeout set, then this pollset is used */ - apr_pollset_t *pollset; - - /* Stuff for buffered mode */ - char *buffer; - apr_size_t bufpos; /* Read/Write position in buffer */ - apr_size_t bufsize; /* The buffer size */ - apr_off_t dataRead; /* amount of valid data read into buffer */ - int direction; /* buffer being used for 0 = read, 1 = write */ - apr_off_t filePtr; /* position in file of handle */ -#if APR_HAS_THREADS - struct apr_thread_mutex_t *thlock; -#endif -}; - -struct apr_dir_t { - apr_pool_t *pool; - char *dirname; - DIR *dirstruct; - struct dirent *entry; -}; - -typedef struct apr_stat_entry_t apr_stat_entry_t; - -struct apr_stat_entry_t { - struct stat info; - char *casedName; - apr_time_t expire; - NXPathCtx_t pathCtx; -}; - -#define MAX_SERVER_NAME 64 -#define MAX_VOLUME_NAME 64 -#define MAX_PATH_NAME 256 -#define MAX_FILE_NAME 256 - -#define DRIVE_ONLY 1 - -/* If the user passes d: vs. D: (or //mach/share vs. //MACH/SHARE), - * we need to fold the case to canonical form. This function is - * supposed to do so. - */ -apr_status_t filepath_root_case(char **rootpath, char *root, apr_pool_t *p); - -/* This function check to see of the given path includes a drive/volume - * specifier. If the _only_ parameter is set to DRIVE_ONLY then it - * check to see of the path only contains a drive/volume specifier and - * nothing else. - */ -apr_status_t filepath_has_drive(const char *rootpath, int only, apr_pool_t *p); - -/* This function compares the drive/volume specifiers for each given path. - * It returns zero if they match or non-zero if not. - */ -apr_status_t filepath_compare_drive(const char *path1, const char *path2, apr_pool_t *p); - -apr_status_t apr_unix_file_cleanup(void *); -apr_status_t apr_unix_child_file_cleanup(void *); - -mode_t apr_unix_perms2mode(apr_fileperms_t perms); -apr_fileperms_t apr_unix_mode2perms(mode_t mode); - -apr_status_t apr_file_flush_locked(apr_file_t *thefile); -apr_status_t apr_file_info_get_locked(apr_finfo_t *finfo, apr_int32_t wanted, - apr_file_t *thefile); - -#endif /* ! FILE_IO_H */ - diff --git a/libs/apr/include/arch/netware/apr_arch_global_mutex.h b/libs/apr/include/arch/netware/apr_arch_global_mutex.h deleted file mode 100644 index 4167d378..00000000 --- a/libs/apr/include/arch/netware/apr_arch_global_mutex.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLOBAL_MUTEX_H -#define GLOBAL_MUTEX_H - -#include "apr_global_mutex.h" -#include "apr_thread_mutex.h" - -struct apr_global_mutex_t { - apr_pool_t *pool; - apr_thread_mutex_t *mutex; -}; - -#endif /* GLOBAL_MUTEX_H */ - diff --git a/libs/apr/include/arch/netware/apr_arch_internal_time.h b/libs/apr/include/arch/netware/apr_arch_internal_time.h deleted file mode 100644 index 59f10672..00000000 --- a/libs/apr/include/arch/netware/apr_arch_internal_time.h +++ /dev/null @@ -1,26 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef TIME_INTERNAL_H -#define TIME_INTERNAL_H - -#include "apr.h" - -#define TZONE (*___timezone()) - -void apr_netware_setup_time(void); - -#endif /* TIME_INTERNAL_H */ diff --git a/libs/apr/include/arch/netware/apr_arch_networkio.h b/libs/apr/include/arch/netware/apr_arch_networkio.h deleted file mode 100644 index 63f17abe..00000000 --- a/libs/apr/include/arch/netware/apr_arch_networkio.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef NETWORK_IO_H - -#ifdef USE_WINSOCK -/* Making sure that we include the correct networkio.h since the - the project file is configured to first look for headers in - arch/netware and then arch/unix. But in this specific case we - want arch/win32. -*/ -#include <../win32/apr_arch_networkio.h> -#else -#include <../unix/apr_arch_networkio.h> -#endif - -#endif /* ! NETWORK_IO_H */ - diff --git a/libs/apr/include/arch/netware/apr_arch_pre_nw.h b/libs/apr/include/arch/netware/apr_arch_pre_nw.h deleted file mode 100644 index 7380e118..00000000 --- a/libs/apr/include/arch/netware/apr_arch_pre_nw.h +++ /dev/null @@ -1,57 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef __pre_nw__ -#define __pre_nw__ - -#include - -#ifndef __GNUC__ -#pragma precompile_target "precomp.mch" -#endif - -#define NETWARE - -#define N_PLAT_NLM - -#define FAR -#define far - -/* no-op for Codewarrior C compiler; a functions are cdecl - by default */ -#define cdecl - -/* if we have wchar_t enabled in C++, predefine this type to avoid - a conflict in Novell's header files */ -#ifndef __GNUC__ -#ifndef DOXYGEN -#if (__option(cplusplus) && __option(wchar_type)) -#define _WCHAR_T -#endif -#endif -#endif - -/* C9X defintion used by MSL C++ library */ -#define DECIMAL_DIG 17 - -/* some code may want to use the MS convention for long long */ -#ifndef __int64 -#define __int64 long long -#endif - -#endif - - - diff --git a/libs/apr/include/arch/netware/apr_arch_proc_mutex.h b/libs/apr/include/arch/netware/apr_arch_proc_mutex.h deleted file mode 100644 index 7a634c2e..00000000 --- a/libs/apr/include/arch/netware/apr_arch_proc_mutex.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PROC_MUTEX_H -#define PROC_MUTEX_H - -#include "apr_proc_mutex.h" -#include "apr_thread_mutex.h" - -struct apr_proc_mutex_t { - apr_pool_t *pool; - apr_thread_mutex_t *mutex; -}; - -#endif /* PROC_MUTEX_H */ - diff --git a/libs/apr/include/arch/netware/apr_arch_thread_cond.h b/libs/apr/include/arch/netware/apr_arch_thread_cond.h deleted file mode 100644 index b11a5f86..00000000 --- a/libs/apr/include/arch/netware/apr_arch_thread_cond.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef THREAD_COND_H -#define THREAD_COND_H - -#include "apr_thread_cond.h" -#include - -struct apr_thread_cond_t { - apr_pool_t *pool; - NXCond_t *cond; -}; - -#endif /* THREAD_COND_H */ - diff --git a/libs/apr/include/arch/netware/apr_arch_thread_mutex.h b/libs/apr/include/arch/netware/apr_arch_thread_mutex.h deleted file mode 100644 index 0453799c..00000000 --- a/libs/apr/include/arch/netware/apr_arch_thread_mutex.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef THREAD_MUTEX_H -#define THREAD_MUTEX_H - -#include "apr_thread_mutex.h" -#include - -struct apr_thread_mutex_t { - apr_pool_t *pool; - NXMutex_t *mutex; -}; - -#endif /* THREAD_MUTEX_H */ - diff --git a/libs/apr/include/arch/netware/apr_arch_thread_rwlock.h b/libs/apr/include/arch/netware/apr_arch_thread_rwlock.h deleted file mode 100644 index d2dbd42f..00000000 --- a/libs/apr/include/arch/netware/apr_arch_thread_rwlock.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef THREAD_RWLOCK_H -#define THREAD_RWLOCK_H - -#include "apr_thread_rwlock.h" -#include - -struct apr_thread_rwlock_t { - apr_pool_t *pool; - NXRwLock_t *rwlock; -}; - -#endif /* THREAD_RWLOCK_H */ - diff --git a/libs/apr/include/arch/netware/apr_arch_threadproc.h b/libs/apr/include/arch/netware/apr_arch_threadproc.h deleted file mode 100644 index 2fee2c00..00000000 --- a/libs/apr/include/arch/netware/apr_arch_threadproc.h +++ /dev/null @@ -1,80 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" - -#include - -#ifndef THREAD_PROC_H -#define THREAD_PROC_H - -#define SHELL_PATH "" -#define APR_DEFAULT_STACK_SIZE 65536 - -struct apr_thread_t { - apr_pool_t *pool; - NXContext_t ctx; - NXThreadId_t td; - char *thread_name; - apr_int32_t cancel; - apr_int32_t cancel_how; - void *data; - apr_thread_start_t func; - apr_status_t exitval; -}; - -struct apr_threadattr_t { - apr_pool_t *pool; - apr_size_t stack_size; - apr_int32_t detach; - char *thread_name; -}; - -struct apr_threadkey_t { - apr_pool_t *pool; - NXKey_t key; -}; - -struct apr_procattr_t { - apr_pool_t *pool; - apr_file_t *parent_in; - apr_file_t *child_in; - apr_file_t *parent_out; - apr_file_t *child_out; - apr_file_t *parent_err; - apr_file_t *child_err; - char *currdir; - apr_int32_t cmdtype; - apr_int32_t detached; - apr_int32_t addrspace; -}; - -struct apr_thread_once_t { - unsigned long value; -}; - -/* -struct apr_proc_t { - apr_pool_t *pool; - pid_t pid; - apr_procattr_t *attr; -}; -*/ - -#endif /* ! THREAD_PROC_H */ - diff --git a/libs/apr/include/arch/netware/apr_private.h b/libs/apr/include/arch/netware/apr_private.h deleted file mode 100644 index dbb3d215..00000000 --- a/libs/apr/include/arch/netware/apr_private.h +++ /dev/null @@ -1,205 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Note: - * This is the netware-specific autoconf-like config file - * which unix creates at ./configure time. - */ - -#ifdef NETWARE - -#ifndef APR_PRIVATE_H -#define APR_PRIVATE_H - -/* Pick up publicly advertised headers and symbols before the - * APR internal private headers and symbols - */ -#include - -/* Pick up privately consumed headers */ -#include - -/* Include alloca.h to get compiler-dependent defines */ -#include - -#include -#include -#include -#include -#include -#include -#include - -/* Use this section to define all of the HAVE_FOO_H - * that are required to build properly. - */ -#define HAVE_DLFCN_H 1 -#define HAVE_LIMITS_H 1 -#define HAVE_SIGNAL_H 1 -#define HAVE_STDDEF_H 1 -#define HAVE_STDLIB_H 1 -#ifndef USE_WINSOCK -#define HAVE_SYS_SELECT_H 1 -#define HAVE_WRITEV 1 -#endif -#define HAVE_SYS_STAT_H 1 -#define HAVE_SYS_MMAN_H 1 -#define HAVE_FCNTL_H 1 -#define HAVE_ICONV_H 1 -#define HAVE_UTIME_H 1 - -#define HAVE_STRICMP 1 -#define HAVE_STRNICMP 1 -#define HAVE_STRDUP 1 -#define HAVE_STRSTR 1 -#define HAVE_MEMCHR 1 -#define HAVE_CALLOC 1 -#define HAVE_UTIME 1 - -#define HAVE_GETENV 1 -#define HAVE_SETENV 1 -#define HAVE_UNSETENV 1 - -#define HAVE_WRITEV 1 - -#define HAVE_GETPASS_R 1 -/* - * Hack around older NDKs which have only the getpassword() function, - * a threadsafe, API-equivilant of getpass_r(). - */ -#if (CURRENT_NDK_THRESHOLD < 709060000) -#define getpass_r getpassword -#endif - -/*#define DSO_USE_DLFCN */ - -#ifdef NW_BUILD_IPV6 -#define HAVE_GETADDRINFO 1 -#define HAVE_GETNAMEINFO 1 -#endif - -/* 1 is used for SIGABRT on netware */ -/* 2 is used for SIGFPE on netware */ -/* 3 is used for SIGILL on netware */ -/* 4 is used for SIGINT on netware */ -/* 5 is used for SIGSEGV on netware */ -/* 6 is used for SIGTERM on netware */ -/* 7 is used for SIGPOLL on netware */ - -#if (CURRENT_NDK_THRESHOLD < 306030000) -#define SIGKILL 11 -#define SIGALRM 13 -#define SIGCHLD 14 -#define SIGCONT 15 -#define SIGHUP 16 -#define SIGPIPE 17 -#define SIGQUIT 18 -#define SIGSTOP 19 -#define SIGTSTP 20 -#define SIGTTIN 21 -#define SIGTTOU 22 -#define SIGUSR1 23 -#define SIGUSR2 24 -#endif - -#define SIGTRAP 25 -#define SIGIOT 26 -#define SIGSTKFLT 28 -#define SIGURG 29 -#define SIGXCPU 30 -#define SIGXFSZ 31 -#define SIGVTALRM 32 -#define SIGPROF 33 -#define SIGWINCH 34 -#define SIGIO 35 - -#if (CURRENT_NDK_THRESHOLD < 406230000) -#undef SA_NOCLDSTOP -#define SA_NOCLDSTOP 0x00000001 -#endif -#ifndef SIGBUS -#define SIGBUS SIGSEGV -#endif - -#define _getch getcharacter - -#define SIZEOF_SHORT 2 -#define SIZEOF_INT 4 -#define SIZEOF_LONGLONG 8 -#define SIZEOF_CHAR 1 -#define SIZEOF_SSIZE_T SIZEOF_INT - -void netware_pool_proc_cleanup(); - -/* NLM registration routines for managing which NLMs - are using the library. */ -int register_NLM(void *NLMHandle); -int unregister_NLM(void *NLMHandle); - -/* Application global data management */ -extern int gLibId; -extern void *gLibHandle; - -typedef struct app_data { - int initialized; - void* gPool; - void* gs_aHooksToSort; - void* gs_phOptionalHooks; - void* gs_phOptionalFunctions; - void* gs_nlmhandle; - rtag_t gs_startup_rtag; - rtag_t gs_socket_rtag; - rtag_t gs_lookup_rtag; - rtag_t gs_event_rtag; - rtag_t gs_pcp_rtag; - void* gs_ldap_xref_lock; - void* gs_xref_head; -} APP_DATA; - -int setGlobalPool(void *data); -void* getGlobalPool(); -int setStatCache(void *data); -void* getStatCache(); - -/* Redefine malloc to use the library malloc call so - that all of the memory resources will be owned - and can be shared by the library. */ -#undef malloc -#define malloc(x) library_malloc(gLibHandle,x) -#ifndef __MWERKS__ -#define _alloca alloca -#endif - -/* 64-bit integer conversion function */ -#define APR_INT64_STRFN strtoll - -#if APR_HAS_LARGE_FILES -#define APR_OFF_T_STRFN strtoll -#else -#define APR_OFF_T_STRFN strtol -#endif - -/* used to check DWORD overflow for 64bit compiles */ -#define APR_DWORD_MAX 0xFFFFFFFFUL - -/* - * Include common private declarations. - */ -#include "../apr_private_common.h" - -#endif /*APR_PRIVATE_H*/ -#endif /*NETWARE*/ diff --git a/libs/apr/include/arch/os2/apr_arch_dso.h b/libs/apr/include/arch/os2/apr_arch_dso.h deleted file mode 100644 index 2bda6b7c..00000000 --- a/libs/apr/include/arch/os2/apr_arch_dso.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DSO_H -#define DSO_H - -#include "apr_private.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_dso.h" -#include "apr.h" - -#if APR_HAS_DSO - -struct apr_dso_handle_t { - apr_pool_t *cont; /* Context for returning error strings */ - HMODULE handle; /* Handle to the DSO loaded */ - apr_status_t load_error; - char *failed_module; -}; - -#endif - -#endif diff --git a/libs/apr/include/arch/os2/apr_arch_file_io.h b/libs/apr/include/arch/os2/apr_arch_file_io.h deleted file mode 100644 index 79a57964..00000000 --- a/libs/apr/include/arch/os2/apr_arch_file_io.h +++ /dev/null @@ -1,86 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FILE_IO_H -#define FILE_IO_H - -#include "apr_private.h" -#include "apr_general.h" -#include "apr_thread_mutex.h" -#include "apr_file_io.h" -#include "apr_file_info.h" -#include "apr_errno.h" -#include "apr_poll.h" - -/* We have an implementation of mkstemp but it's not very multi-threading - * friendly & is part of the POSIX emulation rather than native so don't - * use it. - */ -#undef HAVE_MKSTEMP - -#define APR_FILE_DEFAULT_BUFSIZE 4096 -#define APR_FILE_BUFSIZE APR_FILE_DEFAULT_BUFSIZE - -struct apr_file_t { - apr_pool_t *pool; - HFILE filedes; - char * fname; - int isopen; - int buffered; - int eof_hit; - apr_int32_t flags; - int timeout; - int pipe; - HEV pipeSem; - enum { BLK_UNKNOWN, BLK_OFF, BLK_ON } blocking; - - /* Stuff for buffered mode */ - char *buffer; - apr_size_t bufsize; /* Read/Write position in buffer */ - apr_size_t bufpos; /* Read/Write position in buffer */ - unsigned long dataRead; /* amount of valid data read into buffer */ - int direction; /* buffer being used for 0 = read, 1 = write */ - unsigned long filePtr; /* position in file of handle */ - apr_thread_mutex_t *mutex; /* mutex semaphore, must be owned to access - the above fields */ -}; - -struct apr_dir_t { - apr_pool_t *pool; - char *dirname; - ULONG handle; - FILEFINDBUF3 entry; - int validentry; -}; - -apr_status_t apr_file_cleanup(void *); -apr_status_t apr_os2_time_to_apr_time(apr_time_t *result, FDATE os2date, - FTIME os2time); -apr_status_t apr_apr_time_to_os2_time(FDATE *os2date, FTIME *os2time, - apr_time_t aprtime); - -/* see win32/fileio.h for description of these */ -extern const char c_is_fnchar[256]; - -#define IS_FNCHAR(c) c_is_fnchar[(unsigned char)c] - -apr_status_t filepath_root_test(char *path, apr_pool_t *p); -apr_status_t filepath_drive_get(char **rootpath, char drive, - apr_int32_t flags, apr_pool_t *p); -apr_status_t filepath_root_case(char **rootpath, char *root, apr_pool_t *p); - -#endif /* ! FILE_IO_H */ - diff --git a/libs/apr/include/arch/os2/apr_arch_inherit.h b/libs/apr/include/arch/os2/apr_arch_inherit.h deleted file mode 100644 index 494772ac..00000000 --- a/libs/apr/include/arch/os2/apr_arch_inherit.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef INHERIT_H -#define INHERIT_H - -#include "apr_inherit.h" - -#define APR_INHERIT (1 << 24) /* Must not conflict with other bits */ - -#define APR_IMPLEMENT_INHERIT_SET(name, flag, pool, cleanup) \ -APR_DECLARE(apr_status_t) apr_##name##_inherit_set(apr_##name##_t *the##name) \ -{ \ - int rv; \ - ULONG state; \ - if (((rv = DosQueryFHState(attr->parent_err->filedes, &state)) \ - != 0) || \ - ((rv = DosSetFHState(attr->parent_err->filedes, \ - state & ~OPEN_FLAGS_NOINHERIT)) != 0)) \ - return APR_FROM_OS_ERROR(rv); \ - return APR_SUCCESS; \ -} - -#define APR_IMPLEMENT_INHERIT_UNSET(name, flag, pool, cleanup) \ -APR_DECLARE(apr_status_t) apr_##name##_inherit_unset(apr_##name##_t *the##name)\ -{ \ - int rv; \ - ULONG state; \ - if (((rv = DosQueryFHState(attr->parent_err->filedes, &state)) \ - != 0) || \ - ((rv = DosSetFHState(attr->parent_err->filedes, \ - state | OPEN_FLAGS_NOINHERIT)) != 0)) \ - return APR_FROM_OS_ERROR(rv); \ - return APR_SUCCESS; \ -} - -#endif /* ! INHERIT_H */ diff --git a/libs/apr/include/arch/os2/apr_arch_networkio.h b/libs/apr/include/arch/os2/apr_arch_networkio.h deleted file mode 100644 index 10c6de81..00000000 --- a/libs/apr/include/arch/os2/apr_arch_networkio.h +++ /dev/null @@ -1,76 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef NETWORK_IO_H -#define NETWORK_IO_H - -#include "apr_private.h" -#include "apr_network_io.h" -#include "apr_general.h" -#include "apr_arch_os2calls.h" -#include "apr_poll.h" - -#if APR_HAVE_NETDB_H -#include -#endif - -typedef struct sock_userdata_t sock_userdata_t; -struct sock_userdata_t { - sock_userdata_t *next; - const char *key; - void *data; -}; - -struct apr_socket_t { - apr_pool_t *pool; - int socketdes; - int type; - int protocol; - apr_sockaddr_t *local_addr; - apr_sockaddr_t *remote_addr; - apr_interval_time_t timeout; - int nonblock; - int local_port_unknown; - int local_interface_unknown; - int remote_addr_unknown; - apr_int32_t options; - apr_int32_t inherit; - sock_userdata_t *userdata; - - /* if there is a timeout set, then this pollset is used */ - apr_pollset_t *pollset; -}; - -/* Error codes returned from sock_errno() */ -#define SOCBASEERR 10000 -#define SOCEPERM (SOCBASEERR+1) /* Not owner */ -#define SOCESRCH (SOCBASEERR+3) /* No such process */ -#define SOCEINTR (SOCBASEERR+4) /* Interrupted system call */ -#define SOCENXIO (SOCBASEERR+6) /* No such device or address */ -#define SOCEBADF (SOCBASEERR+9) /* Bad file number */ -#define SOCEACCES (SOCBASEERR+13) /* Permission denied */ -#define SOCEFAULT (SOCBASEERR+14) /* Bad address */ -#define SOCEINVAL (SOCBASEERR+22) /* Invalid argument */ -#define SOCEMFILE (SOCBASEERR+24) /* Too many open files */ -#define SOCEPIPE (SOCBASEERR+32) /* Broken pipe */ -#define SOCEOS2ERR (SOCBASEERR+100) /* OS/2 Error */ - -const char *apr_inet_ntop(int af, const void *src, char *dst, apr_size_t size); -int apr_inet_pton(int af, const char *src, void *dst); -void apr_sockaddr_vars_set(apr_sockaddr_t *, int, apr_port_t); - -#endif /* ! NETWORK_IO_H */ - diff --git a/libs/apr/include/arch/os2/apr_arch_os2calls.h b/libs/apr/include/arch/os2/apr_arch_os2calls.h deleted file mode 100644 index 3c739bfd..00000000 --- a/libs/apr/include/arch/os2/apr_arch_os2calls.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_errno.h" -#include -#include - -extern int (*apr_os2_socket)(int, int, int); -extern int (*apr_os2_select)(int *, int, int, int, long); -extern int (*apr_os2_sock_errno)(); -extern int (*apr_os2_accept)(int, struct sockaddr *, int *); -extern int (*apr_os2_bind)(int, struct sockaddr *, int); -extern int (*apr_os2_connect)(int, struct sockaddr *, int); -extern int (*apr_os2_getpeername)(int, struct sockaddr *, int *); -extern int (*apr_os2_getsockname)(int, struct sockaddr *, int *); -extern int (*apr_os2_getsockopt)(int, int, int, char *, int *); -extern int (*apr_os2_ioctl)(int, int, caddr_t, int); -extern int (*apr_os2_listen)(int, int); -extern int (*apr_os2_recv)(int, char *, int, int); -extern int (*apr_os2_send)(int, const char *, int, int); -extern int (*apr_os2_setsockopt)(int, int, int, char *, int); -extern int (*apr_os2_shutdown)(int, int); -extern int (*apr_os2_soclose)(int); -extern int (*apr_os2_writev)(int, struct iovec *, int); -extern int (*apr_os2_sendto)(int, const char *, int, int, const struct sockaddr *, int); -extern int (*apr_os2_recvfrom)(int, char *, int, int, struct sockaddr *, int *); - -#define socket apr_os2_socket -#define select apr_os2_select -#define sock_errno apr_os2_sock_errno -#define accept apr_os2_accept -#define bind apr_os2_bind -#define connect apr_os2_connect -#define getpeername apr_os2_getpeername -#define getsockname apr_os2_getsockname -#define getsockopt apr_os2_getsockopt -#define ioctl apr_os2_ioctl -#define listen apr_os2_listen -#define recv apr_os2_recv -#define send apr_os2_send -#define setsockopt apr_os2_setsockopt -#define shutdown apr_os2_shutdown -#define soclose apr_os2_soclose -#define writev apr_os2_writev -#define sendto apr_os2_sendto -#define recvfrom apr_os2_recvfrom diff --git a/libs/apr/include/arch/os2/apr_arch_proc_mutex.h b/libs/apr/include/arch/os2/apr_arch_proc_mutex.h deleted file mode 100644 index 8caf3369..00000000 --- a/libs/apr/include/arch/os2/apr_arch_proc_mutex.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PROC_MUTEX_H -#define PROC_MUTEX_H - -#include "apr_proc_mutex.h" -#include "apr_file_io.h" - -struct apr_proc_mutex_t { - apr_pool_t *pool; - HMTX hMutex; - TID owner; - int lock_count; -}; - -#endif /* PROC_MUTEX_H */ - diff --git a/libs/apr/include/arch/os2/apr_arch_thread_cond.h b/libs/apr/include/arch/os2/apr_arch_thread_cond.h deleted file mode 100644 index 648b85d1..00000000 --- a/libs/apr/include/arch/os2/apr_arch_thread_cond.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef THREAD_COND_H -#define THREAD_COND_H - -#include "apr_thread_cond.h" -#include "apr_file_io.h" - -struct apr_thread_cond_t { - apr_pool_t *pool; -}; - -#endif /* THREAD_COND_H */ - diff --git a/libs/apr/include/arch/os2/apr_arch_thread_mutex.h b/libs/apr/include/arch/os2/apr_arch_thread_mutex.h deleted file mode 100644 index 3ae2a41d..00000000 --- a/libs/apr/include/arch/os2/apr_arch_thread_mutex.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef THREAD_MUTEX_H -#define THREAD_MUTEX_H - -#include "apr_thread_mutex.h" -#include "apr_file_io.h" - -struct apr_thread_mutex_t { - apr_pool_t *pool; - HMTX hMutex; -}; - -#endif /* THREAD_MUTEX_H */ - diff --git a/libs/apr/include/arch/os2/apr_arch_thread_rwlock.h b/libs/apr/include/arch/os2/apr_arch_thread_rwlock.h deleted file mode 100644 index 7187d5cb..00000000 --- a/libs/apr/include/arch/os2/apr_arch_thread_rwlock.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef THREAD_RWLOCK_H -#define THREAD_RWLOCK_H - -#include "apr_thread_rwlock.h" -#include "apr_file_io.h" - -struct apr_thread_rwlock_t { - apr_pool_t *pool; - int readers; - HMTX write_lock; - HEV read_done; -}; - -#endif /* THREAD_RWLOCK_H */ - diff --git a/libs/apr/include/arch/os2/apr_arch_threadproc.h b/libs/apr/include/arch/os2/apr_arch_threadproc.h deleted file mode 100644 index c8017adb..00000000 --- a/libs/apr/include/arch/os2/apr_arch_threadproc.h +++ /dev/null @@ -1,67 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_thread_proc.h" -#include "apr_file_io.h" - -#ifndef THREAD_PROC_H -#define THREAD_PROC_H - -#define APR_THREADATTR_DETACHED 1 - -#define SHELL_PATH "cmd.exe" -#define APR_THREAD_STACKSIZE 65536 - -struct apr_threadattr_t { - apr_pool_t *pool; - unsigned long attr; - apr_size_t stacksize; -}; - -struct apr_thread_t { - apr_pool_t *pool; - struct apr_threadattr_t *attr; - unsigned long tid; - apr_thread_start_t func; - void *data; - apr_status_t exitval; -}; - -struct apr_threadkey_t { - apr_pool_t *pool; - unsigned long *key; -}; - -struct apr_procattr_t { - apr_pool_t *pool; - apr_file_t *parent_in; - apr_file_t *child_in; - apr_file_t *parent_out; - apr_file_t *child_out; - apr_file_t *parent_err; - apr_file_t *child_err; - char *currdir; - apr_int32_t cmdtype; - apr_int32_t detached; -}; - -struct apr_thread_once_t { - unsigned long sem; - char hit; -}; - -#endif /* ! THREAD_PROC_H */ - diff --git a/libs/apr/include/arch/os390/apr_arch_dso.h b/libs/apr/include/arch/os390/apr_arch_dso.h deleted file mode 100644 index 4263297b..00000000 --- a/libs/apr/include/arch/os390/apr_arch_dso.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DSO_H -#define DSO_H - -#include "apr_private.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_dso.h" -#include "apr.h" - -#if APR_HAS_DSO - -#include - -struct apr_dso_handle_t { - dllhandle *handle; /* Handle to the DSO loaded */ - int failing_errno; /* Don't save the buffer returned by - strerror(); it gets reused */ - apr_pool_t *pool; -}; - -#endif - -#endif diff --git a/libs/apr/include/arch/unix/apr_arch_atomic.h b/libs/apr/include/arch/unix/apr_arch_atomic.h deleted file mode 100644 index f8019060..00000000 --- a/libs/apr/include/arch/unix/apr_arch_atomic.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ATOMIC_H -#define ATOMIC_H - -#include "apr.h" -#include "apr_private.h" -#include "apr_atomic.h" -#include "apr_thread_mutex.h" - -#if defined(USE_ATOMICS_GENERIC) -/* noop */ -#elif defined(__GNUC__) && defined(__STRICT_ANSI__) -/* force use of generic atomics if building e.g. with -std=c89, which - * doesn't allow inline asm */ -# define USE_ATOMICS_GENERIC -#elif HAVE_ATOMIC_BUILTINS -# define USE_ATOMICS_BUILTINS -#elif defined(SOLARIS2) && SOLARIS2 >= 10 -# define USE_ATOMICS_SOLARIS -#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) -# define USE_ATOMICS_IA32 -#elif defined(__GNUC__) && (defined(__PPC__) || defined(__ppc__)) -# define USE_ATOMICS_PPC -#elif defined(__GNUC__) && (defined(__s390__) || defined(__s390x__)) -# define USE_ATOMICS_S390 -#else -# define USE_ATOMICS_GENERIC -#endif - -#endif /* ATOMIC_H */ diff --git a/libs/apr/include/arch/unix/apr_arch_dso.h b/libs/apr/include/arch/unix/apr_arch_dso.h deleted file mode 100644 index d82182d4..00000000 --- a/libs/apr/include/arch/unix/apr_arch_dso.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DSO_H -#define DSO_H - -#include "apr_private.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_dso.h" -#include "apr.h" - -#if APR_HAS_DSO - -#ifdef HAVE_MACH_O_DYLD_H -#include -#endif - -#ifdef HAVE_DLFCN_H -#include -#endif - -#ifdef HAVE_DL_H -#include -#endif - -#ifndef RTLD_NOW -#define RTLD_NOW 1 -#endif - -#ifndef RTLD_GLOBAL -#define RTLD_GLOBAL 0 -#endif - -#if (defined(__DragonFly__) ||\ - defined(__FreeBSD__) ||\ - defined(__OpenBSD__) ||\ - defined(__NetBSD__) ) && !defined(__ELF__) -#define DLSYM_NEEDS_UNDERSCORE -#endif - -struct apr_dso_handle_t { - apr_pool_t *pool; - void *handle; - const char *errormsg; -}; - -#endif - -#endif diff --git a/libs/apr/include/arch/unix/apr_arch_file_io.h b/libs/apr/include/arch/unix/apr_arch_file_io.h deleted file mode 100644 index 77a90917..00000000 --- a/libs/apr/include/arch/unix/apr_arch_file_io.h +++ /dev/null @@ -1,174 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FILE_IO_H -#define FILE_IO_H - -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_tables.h" -#include "apr_file_io.h" -#include "apr_file_info.h" -#include "apr_errno.h" -#include "apr_lib.h" -#include "apr_thread_mutex.h" -#ifndef WAITIO_USES_POLL -#include "apr_poll.h" -#endif - -/* System headers the file I/O library needs */ -#if APR_HAVE_FCNTL_H -#include -#endif -#if APR_HAVE_SYS_TYPES_H -#include -#endif -#if APR_HAVE_ERRNO_H -#include -#endif -#if APR_HAVE_STRING_H -#include -#endif -#if APR_HAVE_STRINGS_H -#include -#endif -#if APR_HAVE_DIRENT_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif -#if APR_HAVE_UNISTD_H -#include -#endif -#if APR_HAVE_STDIO_H -#include -#endif -#if APR_HAVE_STDLIB_H -#include -#endif -#if APR_HAVE_SYS_UIO_H -#include -#endif -#if APR_HAVE_SYS_TIME_H -#include -#endif -#ifdef BEOS -#include -#endif -/* Hunting down DEV_BSIZE if not from dirent.h, sys/stat.h etc */ -#ifdef HAVE_SYS_PARAM_H -#include -#endif - -#if BEOS_BONE -# ifndef BONE7 - /* prior to BONE/7 fd_set & select were defined in sys/socket.h */ -# include -# else - /* Be moved the fd_set stuff and also the FIONBIO definition... */ -# include -# endif -#endif -/* End System headers */ - -#define APR_FILE_DEFAULT_BUFSIZE 4096 -/* For backwards-compat */ -#define APR_FILE_BUFSIZE APR_FILE_DEFAULT_BUFSIZE - -struct apr_file_t { - apr_pool_t *pool; - int filedes; - char *fname; - apr_int32_t flags; - int eof_hit; - int is_pipe; - apr_interval_time_t timeout; - int buffered; - enum {BLK_UNKNOWN, BLK_OFF, BLK_ON } blocking; - int ungetchar; /* Last char provided by an unget op. (-1 = no char)*/ -#ifndef WAITIO_USES_POLL - /* if there is a timeout set, then this pollset is used */ - apr_pollset_t *pollset; -#endif - /* Stuff for buffered mode */ - char *buffer; - apr_size_t bufpos; /* Read/Write position in buffer */ - apr_size_t bufsize; /* The size of the buffer */ - unsigned long dataRead; /* amount of valid data read into buffer */ - int direction; /* buffer being used for 0 = read, 1 = write */ - apr_off_t filePtr; /* position in file of handle */ -#if APR_HAS_THREADS - struct apr_thread_mutex_t *thlock; -#endif -}; - -#if APR_HAS_THREADS -#define file_lock(f) do { \ - if ((f)->thlock) \ - apr_thread_mutex_lock((f)->thlock); \ - } while (0) -#define file_unlock(f) do { \ - if ((f)->thlock) \ - apr_thread_mutex_unlock((f)->thlock); \ - } while (0) -#else -#define file_lock(f) do {} while (0) -#define file_unlock(f) do {} while (0) -#endif - -#if APR_HAS_LARGE_FILES && defined(_LARGEFILE64_SOURCE) -#define stat(f,b) stat64(f,b) -#define lstat(f,b) lstat64(f,b) -#define fstat(f,b) fstat64(f,b) -#define lseek(f,o,w) lseek64(f,o,w) -#define ftruncate(f,l) ftruncate64(f,l) -typedef struct stat64 struct_stat; -#else -typedef struct stat struct_stat; -#endif - -/* readdir64_r is only used in specific cases: */ -#if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) \ - && !defined(READDIR_IS_THREAD_SAFE) && defined(HAVE_READDIR64_R) -#define APR_USE_READDIR64_R -#endif - -struct apr_dir_t { - apr_pool_t *pool; - char *dirname; - DIR *dirstruct; -#ifdef APR_USE_READDIR64_R - struct dirent64 *entry; -#else - struct dirent *entry; -#endif -}; - -apr_status_t apr_unix_file_cleanup(void *); -apr_status_t apr_unix_child_file_cleanup(void *); - -mode_t apr_unix_perms2mode(apr_fileperms_t perms); -apr_fileperms_t apr_unix_mode2perms(mode_t mode); - -apr_status_t apr_file_flush_locked(apr_file_t *thefile); -apr_status_t apr_file_info_get_locked(apr_finfo_t *finfo, apr_int32_t wanted, - apr_file_t *thefile); - - -#endif /* ! FILE_IO_H */ - diff --git a/libs/apr/include/arch/unix/apr_arch_global_mutex.h b/libs/apr/include/arch/unix/apr_arch_global_mutex.h deleted file mode 100644 index 3add9ecf..00000000 --- a/libs/apr/include/arch/unix/apr_arch_global_mutex.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLOBAL_MUTEX_H -#define GLOBAL_MUTEX_H - -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_global_mutex.h" -#include "apr_arch_proc_mutex.h" -#include "apr_arch_thread_mutex.h" - -struct apr_global_mutex_t { - apr_pool_t *pool; - apr_proc_mutex_t *proc_mutex; -#if APR_HAS_THREADS - apr_thread_mutex_t *thread_mutex; -#endif /* APR_HAS_THREADS */ -}; - -#endif /* GLOBAL_MUTEX_H */ - diff --git a/libs/apr/include/arch/unix/apr_arch_inherit.h b/libs/apr/include/arch/unix/apr_arch_inherit.h deleted file mode 100644 index 21543c1e..00000000 --- a/libs/apr/include/arch/unix/apr_arch_inherit.h +++ /dev/null @@ -1,64 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef INHERIT_H -#define INHERIT_H - -#include "apr_inherit.h" - -#define APR_INHERIT (1 << 24) /* Must not conflict with other bits */ - -#define APR_IMPLEMENT_INHERIT_SET(name, flag, pool, cleanup) \ -apr_status_t apr_##name##_inherit_set(apr_##name##_t *the##name) \ -{ \ - if (the##name->flag & APR_FOPEN_NOCLEANUP) \ - return APR_EINVAL; \ - if (!(the##name->flag & APR_INHERIT)) { \ - int flags = fcntl(the##name->name##des, F_GETFD); \ - if (flags == -1) \ - return errno; \ - flags &= ~(FD_CLOEXEC); \ - if (fcntl(the##name->name##des, F_SETFD, flags) == -1) \ - return errno; \ - the##name->flag |= APR_INHERIT; \ - apr_pool_child_cleanup_set(the##name->pool, \ - (void *)the##name, \ - cleanup, apr_pool_cleanup_null); \ - } \ - return APR_SUCCESS; \ -} - -#define APR_IMPLEMENT_INHERIT_UNSET(name, flag, pool, cleanup) \ -apr_status_t apr_##name##_inherit_unset(apr_##name##_t *the##name) \ -{ \ - if (the##name->flag & APR_FOPEN_NOCLEANUP) \ - return APR_EINVAL; \ - if (the##name->flag & APR_INHERIT) { \ - int flags; \ - if ((flags = fcntl(the##name->name##des, F_GETFD)) == -1) \ - return errno; \ - flags |= FD_CLOEXEC; \ - if (fcntl(the##name->name##des, F_SETFD, flags) == -1) \ - return errno; \ - the##name->flag &= ~APR_INHERIT; \ - apr_pool_child_cleanup_set(the##name->pool, \ - (void *)the##name, \ - cleanup, cleanup); \ - } \ - return APR_SUCCESS; \ -} - -#endif /* ! INHERIT_H */ diff --git a/libs/apr/include/arch/unix/apr_arch_internal_time.h b/libs/apr/include/arch/unix/apr_arch_internal_time.h deleted file mode 100644 index 6e12c674..00000000 --- a/libs/apr/include/arch/unix/apr_arch_internal_time.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef TIME_INTERNAL_H -#define TIME_INTERNAL_H - -#include "apr.h" - -void apr_unix_setup_time(void); - -#endif /* TIME_INTERNAL_H */ diff --git a/libs/apr/include/arch/unix/apr_arch_misc.h b/libs/apr/include/arch/unix/apr_arch_misc.h deleted file mode 100644 index 82351250..00000000 --- a/libs/apr/include/arch/unix/apr_arch_misc.h +++ /dev/null @@ -1,67 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef MISC_H -#define MISC_H - -#include "apr.h" -#include "apr_portable.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_getopt.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include "apr_errno.h" -#include "apr_getopt.h" - -#if APR_HAVE_STDIO_H -#include -#endif -#if APR_HAVE_SIGNAL_H -#include -#endif -#if APR_HAVE_PTHREAD_H -#include -#endif - -#if APR_HAVE_STDLIB_H -#include -#endif -#if APR_HAVE_STRING_H -#include -#endif - -#ifdef BEOS -#include -#endif - -struct apr_other_child_rec_t { - apr_pool_t *p; - struct apr_other_child_rec_t *next; - apr_proc_t *proc; - void (*maintenance) (int, void *, int); - void *data; - apr_os_file_t write_fd; -}; - -#if defined(WIN32) || defined(NETWARE) -#define WSAHighByte 2 -#define WSALowByte 0 -#endif - -#endif /* ! MISC_H */ - diff --git a/libs/apr/include/arch/unix/apr_arch_networkio.h b/libs/apr/include/arch/unix/apr_arch_networkio.h deleted file mode 100644 index 91018f7c..00000000 --- a/libs/apr/include/arch/unix/apr_arch_networkio.h +++ /dev/null @@ -1,142 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef NETWORK_IO_H -#define NETWORK_IO_H - -#include "apr.h" -#include "apr_private.h" -#include "apr_network_io.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_lib.h" -#ifndef WAITIO_USES_POLL -#include "apr_poll.h" -#endif - -/* System headers the network I/O library needs */ -#if APR_HAVE_SYS_TYPES_H -#include -#endif -#if APR_HAVE_SYS_UIO_H -#include -#endif -#ifdef HAVE_SYS_SELECT_H -#include -#endif -#if APR_HAVE_ERRNO_H -#include -#endif -#if APR_HAVE_SYS_TIME_H -#include -#endif -#if APR_HAVE_UNISTD_H -#include -#endif -#if APR_HAVE_STRING_H -#include -#endif -#if APR_HAVE_NETINET_TCP_H -#include -#endif -#if APR_HAVE_NETINET_SCTP_UIO_H -#include -#endif -#if APR_HAVE_NETINET_SCTP_H -#include -#endif -#if APR_HAVE_NETINET_IN_H -#include -#endif -#if APR_HAVE_ARPA_INET_H -#include -#endif -#if APR_HAVE_SYS_SOCKET_H -#include -#endif -#if APR_HAVE_SYS_SOCKIO_H -#include -#endif -#if APR_HAVE_NETDB_H -#include -#endif -#if APR_HAVE_FCNTL_H -#include -#endif -#if APR_HAVE_SYS_SENDFILE_H -#include -#endif -#if APR_HAVE_SYS_IOCTL_H -#include -#endif -/* End System Headers */ - -#ifndef HAVE_POLLIN -#define POLLIN 1 -#define POLLPRI 2 -#define POLLOUT 4 -#define POLLERR 8 -#define POLLHUP 16 -#define POLLNVAL 32 -#endif - -typedef struct sock_userdata_t sock_userdata_t; -struct sock_userdata_t { - sock_userdata_t *next; - const char *key; - void *data; -}; - -struct apr_socket_t { - apr_pool_t *pool; - int socketdes; - int type; - int protocol; - apr_sockaddr_t *local_addr; - apr_sockaddr_t *remote_addr; - apr_interval_time_t timeout; -#ifndef HAVE_POLL - int connected; -#endif - int local_port_unknown; - int local_interface_unknown; - int remote_addr_unknown; - apr_int32_t options; - apr_int32_t inherit; - sock_userdata_t *userdata; -#ifndef WAITIO_USES_POLL - /* if there is a timeout set, then this pollset is used */ - apr_pollset_t *pollset; -#endif -}; - -const char *apr_inet_ntop(int af, const void *src, char *dst, apr_size_t size); -int apr_inet_pton(int af, const char *src, void *dst); -void apr_sockaddr_vars_set(apr_sockaddr_t *, int, apr_port_t); - -#define apr_is_option_set(skt, option) \ - (((skt)->options & (option)) == (option)) - -#define apr_set_option(skt, option, on) \ - do { \ - if (on) \ - (skt)->options |= (option); \ - else \ - (skt)->options &= ~(option); \ - } while (0) - -#endif /* ! NETWORK_IO_H */ - diff --git a/libs/apr/include/arch/unix/apr_arch_poll_private.h b/libs/apr/include/arch/unix/apr_arch_poll_private.h deleted file mode 100644 index 1d31f96c..00000000 --- a/libs/apr/include/arch/unix/apr_arch_poll_private.h +++ /dev/null @@ -1,169 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_ARCH_POLL_PRIVATE_H -#define APR_ARCH_POLL_PRIVATE_H - -#if HAVE_POLL_H -#include -#endif - -#if HAVE_SYS_POLL_H -#include -#endif - -#ifdef HAVE_PORT_CREATE -#include -#include -#endif - -#ifdef HAVE_KQUEUE -#include -#include -#include -#endif - -#ifdef HAVE_EPOLL -#include -#endif - -#ifdef NETWARE -#define HAS_SOCKETS(dt) (dt == APR_POLL_SOCKET) ? 1 : 0 -#define HAS_PIPES(dt) (dt == APR_POLL_FILE) ? 1 : 0 -#endif - -/* Choose the best method platform specific to use in apr_pollset */ -#ifdef HAVE_KQUEUE -#define POLLSET_USES_KQUEUE -#define POLLSET_DEFAULT_METHOD APR_POLLSET_KQUEUE -#elif defined(HAVE_PORT_CREATE) -#define POLLSET_USES_PORT -#define POLLSET_DEFAULT_METHOD APR_POLLSET_PORT -#elif defined(HAVE_EPOLL) -#define POLLSET_USES_EPOLL -#define POLLSET_DEFAULT_METHOD APR_POLLSET_EPOLL -#elif defined(HAVE_POLL) -#define POLLSET_USES_POLL -#define POLLSET_DEFAULT_METHOD APR_POLLSET_POLL -#else -#define POLLSET_USES_SELECT -#define POLLSET_DEFAULT_METHOD APR_POLLSET_SELECT -#endif - -#ifdef WIN32 -#define POLL_USES_SELECT -#undef POLLSET_DEFAULT_METHOD -#define POLLSET_DEFAULT_METHOD APR_POLLSET_SELECT -#else -#ifdef HAVE_POLL -#define POLL_USES_POLL -#else -#define POLL_USES_SELECT -#endif -#endif - -#if defined(POLLSET_USES_KQUEUE) || defined(POLLSET_USES_EPOLL) || defined(POLLSET_USES_PORT) - -#include "apr_ring.h" - -#if APR_HAS_THREADS -#include "apr_thread_mutex.h" -#define pollset_lock_rings() \ - if (pollset->flags & APR_POLLSET_THREADSAFE) \ - apr_thread_mutex_lock(pollset->p->ring_lock); -#define pollset_unlock_rings() \ - if (pollset->flags & APR_POLLSET_THREADSAFE) \ - apr_thread_mutex_unlock(pollset->p->ring_lock); -#else -#define pollset_lock_rings() -#define pollset_unlock_rings() -#endif - -typedef struct pfd_elem_t pfd_elem_t; - -struct pfd_elem_t { - APR_RING_ENTRY(pfd_elem_t) link; - apr_pollfd_t pfd; -#ifdef HAVE_PORT_CREATE - int on_query_ring; -#endif -}; - -#endif - -typedef struct apr_pollset_private_t apr_pollset_private_t; -typedef struct apr_pollset_provider_t apr_pollset_provider_t; -typedef struct apr_pollcb_provider_t apr_pollcb_provider_t; -struct apr_pollset_t -{ - apr_pool_t *pool; - apr_uint32_t nelts; - apr_uint32_t nalloc; - apr_uint32_t flags; - /* Pipe descriptors used for wakeup */ - apr_file_t *wakeup_pipe[2]; - apr_pollfd_t wakeup_pfd; - apr_pollset_private_t *p; - apr_pollset_provider_t *provider; -}; - -typedef union { -#if defined(HAVE_EPOLL) - struct epoll_event *epoll; -#endif -#if defined(HAVE_PORT_CREATE) - port_event_t *port; -#endif -#if defined(HAVE_KQUEUE) - struct kevent *ke; -#endif -#if defined(HAVE_POLL) - struct pollfd *ps; -#endif - void *undef; -} apr_pollcb_pset; - -struct apr_pollcb_t { - apr_pool_t *pool; - apr_uint32_t nelts; - apr_uint32_t nalloc; - int fd; - apr_pollcb_pset pollset; - apr_pollfd_t **copyset; - apr_pollcb_provider_t *provider; -}; - -struct apr_pollset_provider_t { - apr_status_t (*create)(apr_pollset_t *, apr_uint32_t, apr_pool_t *, apr_uint32_t); - apr_status_t (*add)(apr_pollset_t *, const apr_pollfd_t *); - apr_status_t (*remove)(apr_pollset_t *, const apr_pollfd_t *); - apr_status_t (*poll)(apr_pollset_t *, apr_interval_time_t, apr_int32_t *, const apr_pollfd_t **); - apr_status_t (*cleanup)(apr_pollset_t *); - const char *name; -}; - -struct apr_pollcb_provider_t { - apr_status_t (*create)(apr_pollcb_t *, apr_uint32_t, apr_pool_t *, apr_uint32_t); - apr_status_t (*add)(apr_pollcb_t *, apr_pollfd_t *); - apr_status_t (*remove)(apr_pollcb_t *, apr_pollfd_t *); - apr_status_t (*poll)(apr_pollcb_t *, apr_interval_time_t, apr_pollcb_cb_t, void *); - const char *name; -}; - -/* Private functions */ -void apr_pollset_drain_wakeup_pipe(apr_pollset_t *pollset); - -#endif /* APR_ARCH_POLL_PRIVATE_H */ diff --git a/libs/apr/include/arch/unix/apr_arch_proc_mutex.h b/libs/apr/include/arch/unix/apr_arch_proc_mutex.h deleted file mode 100644 index ec9796bc..00000000 --- a/libs/apr/include/arch/unix/apr_arch_proc_mutex.h +++ /dev/null @@ -1,113 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PROC_MUTEX_H -#define PROC_MUTEX_H - -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_proc_mutex.h" -#include "apr_pools.h" -#include "apr_portable.h" -#include "apr_file_io.h" -#include "apr_arch_file_io.h" - -/* System headers required by Locks library */ -#if APR_HAVE_SYS_TYPES_H -#include -#endif -#if APR_HAVE_STDIO_H -#include -#endif -#if APR_HAVE_FCNTL_H -#include -#endif - -#ifdef HAVE_SYS_IPC_H -#include -#endif -#ifdef HAVE_SYS_SEM_H -#include -#endif -#ifdef HAVE_SYS_FILE_H -#include -#endif -#if APR_HAVE_STDLIB_H -#include -#endif -#if APR_HAVE_UNISTD_H -#include -#endif -#if APR_HAVE_STRING_H -#include -#endif -#ifdef HAVE_SYS_MMAN_H -#include -#endif -#if APR_HAVE_PTHREAD_H -#include -#endif -#if APR_HAVE_SEMAPHORE_H -#include -#endif -/* End System Headers */ - -struct apr_proc_mutex_unix_lock_methods_t { - unsigned int flags; - apr_status_t (*create)(apr_proc_mutex_t *, const char *); - apr_status_t (*acquire)(apr_proc_mutex_t *); - apr_status_t (*tryacquire)(apr_proc_mutex_t *); - apr_status_t (*release)(apr_proc_mutex_t *); - apr_status_t (*cleanup)(void *); - apr_status_t (*child_init)(apr_proc_mutex_t **, apr_pool_t *, const char *); - const char *name; -}; -typedef struct apr_proc_mutex_unix_lock_methods_t apr_proc_mutex_unix_lock_methods_t; - -/* bit values for flags field in apr_unix_lock_methods_t */ -#define APR_PROCESS_LOCK_MECH_IS_GLOBAL 1 - -#if !APR_HAVE_UNION_SEMUN && defined(APR_HAS_SYSVSEM_SERIALIZE) -union semun { - int val; - struct semid_ds *buf; - unsigned short *array; -}; -#endif - -struct apr_proc_mutex_t { - apr_pool_t *pool; - const apr_proc_mutex_unix_lock_methods_t *meth; - const apr_proc_mutex_unix_lock_methods_t *inter_meth; - int curr_locked; - char *fname; -#if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE - apr_file_t *interproc; -#endif -#if APR_HAS_POSIXSEM_SERIALIZE - sem_t *psem_interproc; -#endif -#if APR_HAS_PROC_PTHREAD_SERIALIZE - pthread_mutex_t *pthread_interproc; -#endif -}; - -void apr_proc_mutex_unix_setup_lock(void); - -#endif /* PROC_MUTEX_H */ - diff --git a/libs/apr/include/arch/unix/apr_arch_shm.h b/libs/apr/include/arch/unix/apr_arch_shm.h deleted file mode 100644 index bbd373e3..00000000 --- a/libs/apr/include/arch/unix/apr_arch_shm.h +++ /dev/null @@ -1,73 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SHM_H -#define SHM_H - -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_shm.h" -#include "apr_pools.h" -#include "apr_file_io.h" -#include "apr_network_io.h" -#include "apr_portable.h" - -#if APR_HAVE_UNISTD_H -#include -#endif -#ifdef HAVE_SYS_MMAN_H -#include -#endif -#ifdef HAVE_SYS_IPC_H -#include -#endif -#ifdef HAVE_SYS_MUTEX_H -#include -#endif -#ifdef HAVE_SYS_SHM_H -#include -#endif -#if !defined(SHM_R) -#define SHM_R 0400 -#endif -#if !defined(SHM_W) -#define SHM_W 0200 -#endif -#ifdef HAVE_SYS_FILE_H -#include -#endif - -/* Not all systems seem to have MAP_FAILED defined, but it should always - * just be (void *)-1. */ -#ifndef MAP_FAILED -#define MAP_FAILED ((void *)-1) -#endif - -struct apr_shm_t { - apr_pool_t *pool; - void *base; /* base real address */ - void *usable; /* base usable address */ - apr_size_t reqsize; /* requested segment size */ - apr_size_t realsize; /* actual segment size */ - const char *filename; /* NULL if anonymous */ -#if APR_USE_SHMEM_SHMGET || APR_USE_SHMEM_SHMGET_ANON - int shmid; /* shmem ID returned from shmget() */ -#endif -}; - -#endif /* SHM_H */ diff --git a/libs/apr/include/arch/unix/apr_arch_thread_cond.h b/libs/apr/include/arch/unix/apr_arch_thread_cond.h deleted file mode 100644 index 5c2b51d1..00000000 --- a/libs/apr/include/arch/unix/apr_arch_thread_cond.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef THREAD_COND_H -#define THREAD_COND_H - -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_thread_mutex.h" -#include "apr_thread_cond.h" -#include "apr_pools.h" - -#if APR_HAVE_PTHREAD_H -#include -#endif - -/* XXX: Should we have a better autoconf search, something like - * APR_HAS_PTHREAD_COND? -aaron */ -#if APR_HAS_THREADS -struct apr_thread_cond_t { - apr_pool_t *pool; - pthread_cond_t cond; -}; -#endif - -#endif /* THREAD_COND_H */ - diff --git a/libs/apr/include/arch/unix/apr_arch_thread_mutex.h b/libs/apr/include/arch/unix/apr_arch_thread_mutex.h deleted file mode 100644 index 40cdef3c..00000000 --- a/libs/apr/include/arch/unix/apr_arch_thread_mutex.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef THREAD_MUTEX_H -#define THREAD_MUTEX_H - -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_thread_mutex.h" -#include "apr_portable.h" -#include "apr_atomic.h" - -#if APR_HAVE_PTHREAD_H -#include -#endif - -#if APR_HAS_THREADS -struct apr_thread_mutex_t { - apr_pool_t *pool; - pthread_mutex_t mutex; -}; -#endif - -#endif /* THREAD_MUTEX_H */ - diff --git a/libs/apr/include/arch/unix/apr_arch_thread_rwlock.h b/libs/apr/include/arch/unix/apr_arch_thread_rwlock.h deleted file mode 100644 index 2cb43af6..00000000 --- a/libs/apr/include/arch/unix/apr_arch_thread_rwlock.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef THREAD_RWLOCK_H -#define THREAD_RWLOCK_H - -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_thread_rwlock.h" -#include "apr_pools.h" - -#if APR_HAVE_PTHREAD_H -/* this gives us pthread_rwlock_t */ -#include -#endif - -#if APR_HAS_THREADS -#ifdef HAVE_PTHREAD_RWLOCKS - -struct apr_thread_rwlock_t { - apr_pool_t *pool; - pthread_rwlock_t rwlock; -}; - -#else - -struct apr_thread_rwlock_t { - apr_pool_t *pool; -}; -#endif - -#endif - -#endif /* THREAD_RWLOCK_H */ - diff --git a/libs/apr/include/arch/unix/apr_arch_threadproc.h b/libs/apr/include/arch/unix/apr_arch_threadproc.h deleted file mode 100644 index b76dc9be..00000000 --- a/libs/apr/include/arch/unix/apr_arch_threadproc.h +++ /dev/null @@ -1,109 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_private.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include "apr_arch_file_io.h" - -/* System headers required for thread/process library */ -#if APR_HAVE_PTHREAD_H -#include -#endif -#ifdef HAVE_SYS_RESOURCE_H -#include -#endif -#if APR_HAVE_SIGNAL_H -#include -#endif -#if APR_HAVE_STRING_H -#include -#endif -#if APR_HAVE_SYS_WAIT_H -#include -#endif -#if APR_HAVE_STRING_H -#include -#endif -#if HAVE_SCHED_H -#include -#endif -/* End System Headers */ - - -#ifndef THREAD_PROC_H -#define THREAD_PROC_H - -#define SHELL_PATH "/bin/sh" - -#if APR_HAS_THREADS - -struct apr_thread_t { - apr_pool_t *pool; - pthread_t *td; - void *data; - apr_thread_start_t func; - apr_status_t exitval; -}; - -struct apr_threadattr_t { - apr_pool_t *pool; - pthread_attr_t attr; -}; - -struct apr_threadkey_t { - apr_pool_t *pool; - pthread_key_t key; -}; - -struct apr_thread_once_t { - pthread_once_t once; -}; - -#endif - -struct apr_procattr_t { - apr_pool_t *pool; - apr_file_t *parent_in; - apr_file_t *child_in; - apr_file_t *parent_out; - apr_file_t *child_out; - apr_file_t *parent_err; - apr_file_t *child_err; - char *currdir; - apr_int32_t cmdtype; - apr_int32_t detached; -#ifdef RLIMIT_CPU - struct rlimit *limit_cpu; -#endif -#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS) - struct rlimit *limit_mem; -#endif -#ifdef RLIMIT_NPROC - struct rlimit *limit_nproc; -#endif -#ifdef RLIMIT_NOFILE - struct rlimit *limit_nofile; -#endif - apr_child_errfn_t *errfn; - apr_int32_t errchk; - apr_uid_t uid; - apr_gid_t gid; -}; - -#endif /* ! THREAD_PROC_H */ - diff --git a/libs/apr/include/arch/unix/apr_private.h.in b/libs/apr/include/arch/unix/apr_private.h.in deleted file mode 100644 index f7ea7e9f..00000000 --- a/libs/apr/include/arch/unix/apr_private.h.in +++ /dev/null @@ -1,997 +0,0 @@ -/* include/arch/unix/apr_private.h.in. Generated from configure.in by autoheader. */ - - -#ifndef APR_PRIVATE_H -#define APR_PRIVATE_H - - -/* Define if building universal (internal helper macro) */ -#undef AC_APPLE_UNIVERSAL_BUILD - -/* Define if apr_allocator should use mmap */ -#undef APR_ALLOCATOR_USES_MMAP - -/* Define as function which can be used for conversion of strings to - apr_int64_t */ -#undef APR_INT64_STRFN - -/* Define as function used for conversion of strings to apr_off_t */ -#undef APR_OFF_T_STRFN - -/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP - systems. This function is required for `alloca.c' support on those systems. - */ -#undef CRAY_STACKSEG_END - -/* Define to 1 if using `alloca.c'. */ -#undef C_ALLOCA - -/* Define to path of random device */ -#undef DEV_RANDOM - -/* Define if struct dirent has an inode member */ -#undef DIRENT_INODE - -/* Define if struct dirent has a d_type member */ -#undef DIRENT_TYPE - -/* Define if DSO support uses dlfcn.h */ -#undef DSO_USE_DLFCN - -/* Define if DSO support uses dyld.h */ -#undef DSO_USE_DYLD - -/* Define if DSO support uses shl_load */ -#undef DSO_USE_SHL - -/* Define to list of paths to EGD sockets */ -#undef EGD_DEFAULT_SOCKET - -/* Define if fcntl locks affect threads within the process */ -#undef FCNTL_IS_GLOBAL - -/* Define if fcntl returns EACCES when F_SETLK is already held */ -#undef FCNTL_TRYACQUIRE_EACCES - -/* Define if flock locks affect threads within the process */ -#undef FLOCK_IS_GLOBAL - -/* Define if gethostbyaddr is thread safe */ -#undef GETHOSTBYADDR_IS_THREAD_SAFE - -/* Define if gethostbyname is thread safe */ -#undef GETHOSTBYNAME_IS_THREAD_SAFE - -/* Define if gethostbyname_r has the glibc style */ -#undef GETHOSTBYNAME_R_GLIBC2 - -/* Define if gethostbyname_r has the hostent_data for the third argument */ -#undef GETHOSTBYNAME_R_HOSTENT_DATA - -/* Define if getservbyname is thread safe */ -#undef GETSERVBYNAME_IS_THREAD_SAFE - -/* Define if getservbyname_r has the glibc style */ -#undef GETSERVBYNAME_R_GLIBC2 - -/* Define if getservbyname_r has the OSF/1 style */ -#undef GETSERVBYNAME_R_OSF1 - -/* Define if getservbyname_r has the Solaris style */ -#undef GETSERVBYNAME_R_SOLARIS - -/* Define if accept4 function is supported */ -#undef HAVE_ACCEPT4 - -/* Define to 1 if you have `alloca', as a function or macro. */ -#undef HAVE_ALLOCA - -/* Define to 1 if you have and it should be used (not on Ultrix). - */ -#undef HAVE_ALLOCA_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_ARPA_INET_H - -/* Define if compiler provides atomic builtins */ -#undef HAVE_ATOMIC_BUILTINS - -/* Define if BONE_VERSION is defined in sys/socket.h */ -#undef HAVE_BONE_VERSION - -/* Define to 1 if you have the header file. */ -#undef HAVE_BYTEORDER_H - -/* Define to 1 if you have the `calloc' function. */ -#undef HAVE_CALLOC - -/* Define to 1 if you have the header file. */ -#undef HAVE_CONIO_H - -/* Define to 1 if you have the `create_area' function. */ -#undef HAVE_CREATE_AREA - -/* Define to 1 if you have the `create_sem' function. */ -#undef HAVE_CREATE_SEM - -/* Define to 1 if you have the header file. */ -#undef HAVE_CRYPT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_CTYPE_H - -/* Define to 1 if you have the declaration of `sys_siglist', and to 0 if you - don't. */ -#undef HAVE_DECL_SYS_SIGLIST - -/* Define to 1 if you have the header file. */ -#undef HAVE_DIRENT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_DIR_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_DLFCN_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_DL_H - -/* Define if dup3 function is supported */ -#undef HAVE_DUP3 - -/* Define if EGD is supported */ -#undef HAVE_EGD - -/* Define if the epoll interface is supported */ -#undef HAVE_EPOLL - -/* Define if epoll_create1 function is supported */ -#undef HAVE_EPOLL_CREATE1 - -/* Define to 1 if you have the header file. */ -#undef HAVE_ERRNO_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_FCNTL_H - -/* Define to 1 if you have the `fdatasync' function. */ -#undef HAVE_FDATASYNC - -/* Define to 1 if you have the `flock' function. */ -#undef HAVE_FLOCK - -/* Define to 1 if you have the `fork' function. */ -#undef HAVE_FORK - -/* Define if F_SETLK is defined in fcntl.h */ -#undef HAVE_F_SETLK - -/* Define if getaddrinfo accepts the AI_ADDRCONFIG flag */ -#undef HAVE_GAI_ADDRCONFIG - -/* Define to 1 if you have the `gai_strerror' function. */ -#undef HAVE_GAI_STRERROR - -/* Define if getaddrinfo exists and works well enough for APR */ -#undef HAVE_GETADDRINFO - -/* Define to 1 if you have the `getenv' function. */ -#undef HAVE_GETENV - -/* Define to 1 if you have the `getgrgid_r' function. */ -#undef HAVE_GETGRGID_R - -/* Define to 1 if you have the `getgrnam_r' function. */ -#undef HAVE_GETGRNAM_R - -/* Define to 1 if you have the `gethostbyaddr_r' function. */ -#undef HAVE_GETHOSTBYADDR_R - -/* Define to 1 if you have the `gethostbyname_r' function. */ -#undef HAVE_GETHOSTBYNAME_R - -/* Define to 1 if you have the `getifaddrs' function. */ -#undef HAVE_GETIFADDRS - -/* Define if getnameinfo exists */ -#undef HAVE_GETNAMEINFO - -/* Define to 1 if you have the `getpass' function. */ -#undef HAVE_GETPASS - -/* Define to 1 if you have the `getpassphrase' function. */ -#undef HAVE_GETPASSPHRASE - -/* Define to 1 if you have the `getpwnam_r' function. */ -#undef HAVE_GETPWNAM_R - -/* Define to 1 if you have the `getpwuid_r' function. */ -#undef HAVE_GETPWUID_R - -/* Define to 1 if you have the `getrlimit' function. */ -#undef HAVE_GETRLIMIT - -/* Define to 1 if you have the `getservbyname_r' function. */ -#undef HAVE_GETSERVBYNAME_R - -/* Define to 1 if you have the `gmtime_r' function. */ -#undef HAVE_GMTIME_R - -/* Define to 1 if you have the header file. */ -#undef HAVE_GRP_H - -/* Define if hstrerror is present */ -#undef HAVE_HSTRERROR - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_IO_H - -/* Define to 1 if you have the `isinf' function. */ -#undef HAVE_ISINF - -/* Define to 1 if you have the `isnan' function. */ -#undef HAVE_ISNAN - -/* Define to 1 if you have the header file. */ -#undef HAVE_KERNEL_OS_H - -/* Define to 1 if you have the `kqueue' function. */ -#undef HAVE_KQUEUE - -/* Define to 1 if you have the header file. */ -#undef HAVE_LANGINFO_H - -/* Define to 1 if you have the `bsd' library (-lbsd). */ -#undef HAVE_LIBBSD - -/* Define to 1 if you have the `sendfile' library (-lsendfile). */ -#undef HAVE_LIBSENDFILE - -/* Define to 1 if you have the `truerand' library (-ltruerand). */ -#undef HAVE_LIBTRUERAND - -/* Define to 1 if you have the header file. */ -#undef HAVE_LIMITS_H - -/* Define to 1 if you have the `localtime_r' function. */ -#undef HAVE_LOCALTIME_R - -/* Define if LOCK_EX is defined in sys/file.h */ -#undef HAVE_LOCK_EX - -/* Define to 1 if you have the header file. */ -#undef HAVE_MACH_O_DYLD_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_MALLOC_H - -/* Define if MAP_ANON is defined in sys/mman.h */ -#undef HAVE_MAP_ANON - -/* Define to 1 if you have the `memchr' function. */ -#undef HAVE_MEMCHR - -/* Define to 1 if you have the `memmove' function. */ -#undef HAVE_MEMMOVE - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the `mkstemp' function. */ -#undef HAVE_MKSTEMP - -/* Define to 1 if you have the `mkstemp64' function. */ -#undef HAVE_MKSTEMP64 - -/* Define to 1 if you have the `mmap' function. */ -#undef HAVE_MMAP - -/* Define to 1 if you have the `mmap64' function. */ -#undef HAVE_MMAP64 - -/* Define to 1 if you have the `munmap' function. */ -#undef HAVE_MUNMAP - -/* Define to 1 if you have the header file. */ -#undef HAVE_NETDB_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_NETINET_IN_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_NETINET_SCTP_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_NETINET_SCTP_UIO_H - -/* Defined if netinet/tcp.h is present */ -#undef HAVE_NETINET_TCP_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_NET_ERRNO_H - -/* Define to 1 if you have the `nl_langinfo' function. */ -#undef HAVE_NL_LANGINFO - -/* Define to 1 if you have the header file. */ -#undef HAVE_OS2_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_OSRELDATE_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_OS_H - -/* Define to 1 if you have the `poll' function. */ -#undef HAVE_POLL - -/* Define if POLLIN is defined */ -#undef HAVE_POLLIN - -/* Define to 1 if you have the header file. */ -#undef HAVE_POLL_H - -/* Define to 1 if you have the `port_create' function. */ -#undef HAVE_PORT_CREATE - -/* Define to 1 if you have the header file. */ -#undef HAVE_PROCESS_H - -/* Define to 1 if you have the `pthread_attr_setguardsize' function. */ -#undef HAVE_PTHREAD_ATTR_SETGUARDSIZE - -/* Define to 1 if you have the header file. */ -#undef HAVE_PTHREAD_H - -/* Define to 1 if you have the `pthread_key_delete' function. */ -#undef HAVE_PTHREAD_KEY_DELETE - -/* Define to 1 if you have the `pthread_mutexattr_setpshared' function. */ -#undef HAVE_PTHREAD_MUTEXATTR_SETPSHARED - -/* Define if recursive pthread mutexes are available */ -#undef HAVE_PTHREAD_MUTEX_RECURSIVE - -/* Define if cross-process robust mutexes are available */ -#undef HAVE_PTHREAD_MUTEX_ROBUST - -/* Define if PTHREAD_PROCESS_SHARED is defined in pthread.h */ -#undef HAVE_PTHREAD_PROCESS_SHARED - -/* Define if pthread rwlocks are available */ -#undef HAVE_PTHREAD_RWLOCKS - -/* Define to 1 if you have the `pthread_rwlock_init' function. */ -#undef HAVE_PTHREAD_RWLOCK_INIT - -/* Define to 1 if you have the `pthread_yield' function. */ -#undef HAVE_PTHREAD_YIELD - -/* Define to 1 if you have the `putenv' function. */ -#undef HAVE_PUTENV - -/* Define to 1 if you have the header file. */ -#undef HAVE_PWD_H - -/* Define to 1 if you have the `readdir64_r' function. */ -#undef HAVE_READDIR64_R - -/* Define to 1 if you have the header file. */ -#undef HAVE_SCHED_H - -/* Define to 1 if you have the `sched_yield' function. */ -#undef HAVE_SCHED_YIELD - -/* Define to 1 if you have the header file. */ -#undef HAVE_SEMAPHORE_H - -/* Define to 1 if you have the `semctl' function. */ -#undef HAVE_SEMCTL - -/* Define to 1 if you have the `semget' function. */ -#undef HAVE_SEMGET - -/* Define to 1 if you have the `sem_close' function. */ -#undef HAVE_SEM_CLOSE - -/* Define to 1 if you have the `sem_post' function. */ -#undef HAVE_SEM_POST - -/* Define if SEM_UNDO is defined in sys/sem.h */ -#undef HAVE_SEM_UNDO - -/* Define to 1 if you have the `sem_unlink' function. */ -#undef HAVE_SEM_UNLINK - -/* Define to 1 if you have the `sem_wait' function. */ -#undef HAVE_SEM_WAIT - -/* Define to 1 if you have the `sendfile' function. */ -#undef HAVE_SENDFILE - -/* Define to 1 if you have the `sendfile64' function. */ -#undef HAVE_SENDFILE64 - -/* Define to 1 if you have the `sendfilev' function. */ -#undef HAVE_SENDFILEV - -/* Define to 1 if you have the `sendfilev64' function. */ -#undef HAVE_SENDFILEV64 - -/* Define to 1 if you have the `send_file' function. */ -#undef HAVE_SEND_FILE - -/* Define to 1 if you have the `setenv' function. */ -#undef HAVE_SETENV - -/* Define to 1 if you have the `setrlimit' function. */ -#undef HAVE_SETRLIMIT - -/* Define to 1 if you have the `setsid' function. */ -#undef HAVE_SETSID - -/* Define to 1 if you have the `set_h_errno' function. */ -#undef HAVE_SET_H_ERRNO - -/* Define to 1 if you have the `shmat' function. */ -#undef HAVE_SHMAT - -/* Define to 1 if you have the `shmctl' function. */ -#undef HAVE_SHMCTL - -/* Define to 1 if you have the `shmdt' function. */ -#undef HAVE_SHMDT - -/* Define to 1 if you have the `shmget' function. */ -#undef HAVE_SHMGET - -/* Define to 1 if you have the `shm_open' function. */ -#undef HAVE_SHM_OPEN - -/* Define to 1 if you have the `shm_unlink' function. */ -#undef HAVE_SHM_UNLINK - -/* Define to 1 if you have the `sigaction' function. */ -#undef HAVE_SIGACTION - -/* Define to 1 if you have the header file. */ -#undef HAVE_SIGNAL_H - -/* Define to 1 if you have the `sigsuspend' function. */ -#undef HAVE_SIGSUSPEND - -/* Define to 1 if you have the `sigwait' function. */ -#undef HAVE_SIGWAIT - -/* Whether you have socklen_t */ -#undef HAVE_SOCKLEN_T - -/* Define if the SOCK_CLOEXEC flag is supported */ -#undef HAVE_SOCK_CLOEXEC - -/* Define if SO_ACCEPTFILTER is defined in sys/socket.h */ -#undef HAVE_SO_ACCEPTFILTER - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDARG_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDDEF_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDIO_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the `strcasecmp' function. */ -#undef HAVE_STRCASECMP - -/* Define to 1 if you have the `strdup' function. */ -#undef HAVE_STRDUP - -/* Define to 1 if you have the `strerror_r' function. */ -#undef HAVE_STRERROR_R - -/* Define to 1 if you have the `stricmp' function. */ -#undef HAVE_STRICMP - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the `strncasecmp' function. */ -#undef HAVE_STRNCASECMP - -/* Define to 1 if you have the `strnicmp' function. */ -#undef HAVE_STRNICMP - -/* Define to 1 if you have the `strstr' function. */ -#undef HAVE_STRSTR - -/* Define if struct impreq was found */ -#undef HAVE_STRUCT_IPMREQ - -/* Define to 1 if `st_atimensec' is a member of `struct stat'. */ -#undef HAVE_STRUCT_STAT_ST_ATIMENSEC - -/* Define to 1 if `st_atime_n' is a member of `struct stat'. */ -#undef HAVE_STRUCT_STAT_ST_ATIME_N - -/* Define to 1 if `st_atim.tv_nsec' is a member of `struct stat'. */ -#undef HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC - -/* Define to 1 if `st_blocks' is a member of `struct stat'. */ -#undef HAVE_STRUCT_STAT_ST_BLOCKS - -/* Define to 1 if `st_ctimensec' is a member of `struct stat'. */ -#undef HAVE_STRUCT_STAT_ST_CTIMENSEC - -/* Define to 1 if `st_ctime_n' is a member of `struct stat'. */ -#undef HAVE_STRUCT_STAT_ST_CTIME_N - -/* Define to 1 if `st_ctim.tv_nsec' is a member of `struct stat'. */ -#undef HAVE_STRUCT_STAT_ST_CTIM_TV_NSEC - -/* Define to 1 if `st_mtimensec' is a member of `struct stat'. */ -#undef HAVE_STRUCT_STAT_ST_MTIMENSEC - -/* Define to 1 if `st_mtime_n' is a member of `struct stat'. */ -#undef HAVE_STRUCT_STAT_ST_MTIME_N - -/* Define to 1 if `st_mtim.tv_nsec' is a member of `struct stat'. */ -#undef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC - -/* Define to 1 if `tm_gmtoff' is a member of `struct tm'. */ -#undef HAVE_STRUCT_TM_TM_GMTOFF - -/* Define to 1 if `__tm_gmtoff' is a member of `struct tm'. */ -#undef HAVE_STRUCT_TM___TM_GMTOFF - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYSAPI_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYSGTIME_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_FILE_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_IOCTL_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_IPC_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_MMAN_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_MUTEX_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_PARAM_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_POLL_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_RESOURCE_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_SELECT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_SEM_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_SENDFILE_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_SHM_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_SIGNAL_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_SOCKET_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_SOCKIO_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_SYSCTL_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_SYSLIMITS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TIME_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_UIO_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_UN_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_UUID_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_WAIT_H - -/* Define if TCP_CORK is defined in netinet/tcp.h */ -#undef HAVE_TCP_CORK - -/* Define if TCP_NODELAY and TCP_CORK can be enabled at the same time */ -#undef HAVE_TCP_NODELAY_WITH_CORK - -/* Define if TCP_NOPUSH is defined in netinet/tcp.h */ -#undef HAVE_TCP_NOPUSH - -/* Define to 1 if you have the header file. */ -#undef HAVE_TERMIOS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_TIME_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_TPFEQ_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_TPFIO_H - -/* Define if truerand is supported */ -#undef HAVE_TRUERAND - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNIX_H - -/* Define to 1 if you have the `unsetenv' function. */ -#undef HAVE_UNSETENV - -/* Define to 1 if you have the `utime' function. */ -#undef HAVE_UTIME - -/* Define to 1 if you have the `utimes' function. */ -#undef HAVE_UTIMES - -/* Define to 1 if you have the `uuid_create' function. */ -#undef HAVE_UUID_CREATE - -/* Define to 1 if you have the `uuid_generate' function. */ -#undef HAVE_UUID_GENERATE - -/* Define to 1 if you have the header file. */ -#undef HAVE_UUID_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UUID_UUID_H - -/* Define if C compiler supports VLA */ -#undef HAVE_VLA - -/* Define to 1 if you have the `waitpid' function. */ -#undef HAVE_WAITPID - -/* Define to 1 if you have the header file. */ -#undef HAVE_WINDOWS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_WINSOCK2_H - -/* Define to 1 if you have the `writev' function. */ -#undef HAVE_WRITEV - -/* Define for z/OS pthread API nuances */ -#undef HAVE_ZOS_PTHREADS - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#undef LT_OBJDIR - -/* Define if EAI_ error codes from getaddrinfo are negative */ -#undef NEGATIVE_EAI - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the home page for this package. */ -#undef PACKAGE_URL - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Define if POSIX semaphores affect threads within the process */ -#undef POSIXSEM_IS_GLOBAL - -/* Define on PowerPC 405 where errata 77 applies */ -#undef PPC405_ERRATA - -/* Define if pthread_attr_getdetachstate() has one arg */ -#undef PTHREAD_ATTR_GETDETACHSTATE_TAKES_ONE_ARG - -/* Define if pthread_getspecific() has two args */ -#undef PTHREAD_GETSPECIFIC_TAKES_TWO_ARGS - -/* Define if readdir is thread safe */ -#undef READDIR_IS_THREAD_SAFE - -/* Define to 1 if the `setpgrp' function takes no argument. */ -#undef SETPGRP_VOID - -/* */ -#undef SIGWAIT_TAKES_ONE_ARG - -/* The size of `char', as computed by sizeof. */ -#undef SIZEOF_CHAR - -/* The size of ino_t */ -#undef SIZEOF_INO_T - -/* The size of `int', as computed by sizeof. */ -#undef SIZEOF_INT - -/* The size of `long', as computed by sizeof. */ -#undef SIZEOF_LONG - -/* The size of `long long', as computed by sizeof. */ -#undef SIZEOF_LONG_LONG - -/* The size of off_t */ -#undef SIZEOF_OFF_T - -/* The size of pid_t */ -#undef SIZEOF_PID_T - -/* The size of `short', as computed by sizeof. */ -#undef SIZEOF_SHORT - -/* The size of size_t */ -#undef SIZEOF_SIZE_T - -/* The size of ssize_t */ -#undef SIZEOF_SSIZE_T - -/* The size of struct iovec */ -#undef SIZEOF_STRUCT_IOVEC - -/* The size of `void*', as computed by sizeof. */ -#undef SIZEOF_VOIDP - -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at runtime. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ -#undef STACK_DIRECTION - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Define if strerror returns int */ -#undef STRERROR_R_RC_INT - -/* Define if SysV semaphores affect threads within the process */ -#undef SYSVSEM_IS_GLOBAL - -/* Define if use of generic atomics is requested */ -#undef USE_ATOMICS_GENERIC - -/* Define if BeOS Semaphores will be used */ -#undef USE_BEOSSEM - -/* Define if SVR4-style fcntl() will be used */ -#undef USE_FCNTL_SERIALIZE - -/* Define if 4.2BSD-style flock() will be used */ -#undef USE_FLOCK_SERIALIZE - -/* Define if BeOS areas will be used */ -#undef USE_SHMEM_BEOS - -/* Define if BeOS areas will be used */ -#undef USE_SHMEM_BEOS_ANON - -/* Define if 4.4BSD-style mmap() via MAP_ANON will be used */ -#undef USE_SHMEM_MMAP_ANON - -/* Define if mmap() via POSIX.1 shm_open() on temporary file will be used */ -#undef USE_SHMEM_MMAP_SHM - -/* Define if Classical mmap() on temporary file will be used */ -#undef USE_SHMEM_MMAP_TMP - -/* Define if SVR4-style mmap() on /dev/zero will be used */ -#undef USE_SHMEM_MMAP_ZERO - -/* Define if OS/2 DosAllocSharedMem() will be used */ -#undef USE_SHMEM_OS2 - -/* Define if OS/2 DosAllocSharedMem() will be used */ -#undef USE_SHMEM_OS2_ANON - -/* Define if SysV IPC shmget() will be used */ -#undef USE_SHMEM_SHMGET - -/* Define if SysV IPC shmget() will be used */ -#undef USE_SHMEM_SHMGET_ANON - -/* Define if Windows shared memory will be used */ -#undef USE_SHMEM_WIN32 - -/* Define if Windows CreateFileMapping() will be used */ -#undef USE_SHMEM_WIN32_ANON - -/* Enable extensions on AIX 3, Interix. */ -#ifndef _ALL_SOURCE -# undef _ALL_SOURCE -#endif -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# undef _GNU_SOURCE -#endif -/* Enable threading extensions on Solaris. */ -#ifndef _POSIX_PTHREAD_SEMANTICS -# undef _POSIX_PTHREAD_SEMANTICS -#endif -/* Enable extensions on HP NonStop. */ -#ifndef _TANDEM_SOURCE -# undef _TANDEM_SOURCE -#endif -/* Enable general extensions on Solaris. */ -#ifndef __EXTENSIONS__ -# undef __EXTENSIONS__ -#endif - - -/* Define if SysV IPC semget() will be used */ -#undef USE_SYSVSEM_SERIALIZE - -/* Define if apr_wait_for_io_or_timeout() uses poll(2) */ -#undef WAITIO_USES_POLL - -/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most - significant byte first (like Motorola and SPARC, unlike Intel). */ -#if defined AC_APPLE_UNIVERSAL_BUILD -# if defined __BIG_ENDIAN__ -# define WORDS_BIGENDIAN 1 -# endif -#else -# ifndef WORDS_BIGENDIAN -# undef WORDS_BIGENDIAN -# endif -#endif - -/* Define to 1 if on MINIX. */ -#undef _MINIX - -/* Define to 2 if the system does not provide POSIX.1 features except with - this defined. */ -#undef _POSIX_1_SOURCE - -/* Define to 1 if you need to in order for `stat' and other things to work. */ -#undef _POSIX_SOURCE - -/* Define to empty if `const' does not conform to ANSI C. */ -#undef const - -/* Define to `int' if doesn't define. */ -#undef gid_t - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -#undef inline -#endif - -/* Define to `long int' if does not define. */ -#undef off_t - -/* Define to `int' if does not define. */ -#undef pid_t - -/* Define to `unsigned int' if does not define. */ -#undef size_t - -/* Define to `int' if does not define. */ -#undef ssize_t - -/* Define to `int' if doesn't define. */ -#undef uid_t - - -/* switch this on if we have a BeOS version below BONE */ -#if BEOS && !HAVE_BONE_VERSION -#define BEOS_R5 1 -#else -#define BEOS_BONE 1 -#endif - -/* - * Darwin 10's default compiler (gcc42) builds for both 64 and - * 32 bit architectures unless specifically told not to. - * In those cases, we need to override types depending on how - * we're being built at compile time. - * NOTE: This is an ugly work-around for Darwin's - * concept of universal binaries, a single package - * (executable, lib, etc...) which contains both 32 - * and 64 bit versions. The issue is that if APR is - * built universally, if something else is compiled - * against it, some bit sizes will depend on whether - * it is 32 or 64 bit. This is determined by the __LP64__ - * flag. Since we need to support both, we have to - * handle OS X unqiuely. - */ -#ifdef DARWIN_10 - -#undef APR_OFF_T_STRFN -#undef APR_INT64_STRFN -#undef SIZEOF_LONG -#undef SIZEOF_SIZE_T -#undef SIZEOF_SSIZE_T -#undef SIZEOF_VOIDP -#undef SIZEOF_STRUCT_IOVEC - -#ifdef __LP64__ - #define APR_INT64_STRFN strtol - #define SIZEOF_LONG 8 - #define SIZEOF_SIZE_T 8 - #define SIZEOF_SSIZE_T 8 - #define SIZEOF_VOIDP 8 - #define SIZEOF_STRUCT_IOVEC 16 -#else - #define APR_INT64_STRFN strtoll - #define SIZEOF_LONG 4 - #define SIZEOF_SIZE_T 4 - #define SIZEOF_SSIZE_T 4 - #define SIZEOF_VOIDP 4 - #define SIZEOF_STRUCT_IOVEC 8 -#endif - -#undef APR_OFF_T_STRFN -#define APR_OFF_T_STRFN APR_INT64_STRFN - - -#undef SETPGRP_VOID -#ifdef __DARWIN_UNIX03 - #define SETPGRP_VOID 1 -#else -/* #undef SETPGRP_VOID */ -#endif - -#endif /* DARWIN_10 */ - -/* - * Include common private declarations. - */ -#include "../apr_private_common.h" -#endif /* APR_PRIVATE_H */ - diff --git a/libs/apr/include/arch/win32/apr_arch_atime.h b/libs/apr/include/arch/win32/apr_arch_atime.h deleted file mode 100644 index 35f2041a..00000000 --- a/libs/apr/include/arch/win32/apr_arch_atime.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ATIME_H -#define ATIME_H - -#include "apr_private.h" -#include "apr_time.h" -#if APR_HAVE_TIME_H -#include -#endif - -struct atime_t { - apr_pool_t *cntxt; - apr_time_t currtime; - SYSTEMTIME *explodedtime; -}; - - -/* Number of micro-seconds between the beginning of the Windows epoch - * (Jan. 1, 1601) and the Unix epoch (Jan. 1, 1970) - */ -#define APR_DELTA_EPOCH_IN_USEC APR_TIME_C(11644473600000000); - - -static APR_INLINE void FileTimeToAprTime(apr_time_t *result, FILETIME *input) -{ - /* Convert FILETIME one 64 bit number so we can work with it. */ - *result = input->dwHighDateTime; - *result = (*result) << 32; - *result |= input->dwLowDateTime; - *result /= 10; /* Convert from 100 nano-sec periods to micro-seconds. */ - *result -= APR_DELTA_EPOCH_IN_USEC; /* Convert from Windows epoch to Unix epoch */ - return; -} - - -static APR_INLINE void AprTimeToFileTime(LPFILETIME pft, apr_time_t t) -{ - LONGLONG ll; - t += APR_DELTA_EPOCH_IN_USEC; - ll = t * 10; - pft->dwLowDateTime = (DWORD)ll; - pft->dwHighDateTime = (DWORD) (ll >> 32); - return; -} - - -#endif /* ! ATIME_H */ - diff --git a/libs/apr/include/arch/win32/apr_arch_dso.h b/libs/apr/include/arch/win32/apr_arch_dso.h deleted file mode 100644 index e2e4e40f..00000000 --- a/libs/apr/include/arch/win32/apr_arch_dso.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DSO_H -#define DSO_H - -#include "apr_private.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_dso.h" -#include "apr.h" - -#if APR_HAS_DSO - -struct apr_dso_handle_t { - apr_pool_t *cont; - void *handle; - apr_status_t load_error; -}; - -#endif - -#endif diff --git a/libs/apr/include/arch/win32/apr_arch_file_io.h b/libs/apr/include/arch/win32/apr_arch_file_io.h deleted file mode 100644 index 38efa277..00000000 --- a/libs/apr/include/arch/win32/apr_arch_file_io.h +++ /dev/null @@ -1,263 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FILE_IO_H -#define FILE_IO_H - -#include "apr.h" -#include "apr_private.h" -#include "apr_pools.h" -#include "apr_general.h" -#include "apr_tables.h" -#include "apr_thread_mutex.h" -#include "apr_file_io.h" -#include "apr_file_info.h" -#include "apr_errno.h" -#include "apr_arch_misc.h" -#include "apr_poll.h" - -#ifdef HAVE_SYS_STAT_H -#include -#endif -#if APR_HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_FCNTL_H -#include -#endif -#ifdef HAVE_TIME_H -#include -#endif -#if APR_HAVE_DIRENT_H -#include -#endif -#ifdef HAVE_MALLOC_H -#include -#endif - -#if APR_HAS_UNICODE_FS -#include "arch/win32/apr_arch_utf8.h" -#include - -/* Helper functions for the WinNT ApiW() functions. APR treats all - * resource identifiers (files, etc) by their UTF-8 name, to provide - * access to all named identifiers. [UTF-8 completely maps Unicode - * into char type strings.] - * - * The _path flavors below provide us fast mappings of the - * Unicode filename //?/D:/path and //?/UNC/mach/share/path mappings, - * which allow unlimited (well, 32000 wide character) length names. - * These prefixes may appear in Unicode, but must not appear in the - * Ascii API calls. So we tack them on in utf8_to_unicode_path, and - * strip them right back off in unicode_to_utf8_path. - */ -apr_status_t utf8_to_unicode_path(apr_wchar_t* dststr, apr_size_t dstchars, - const char* srcstr); -apr_status_t unicode_to_utf8_path(char* dststr, apr_size_t dstchars, - const apr_wchar_t* srcstr); - -#endif /* APR_HAS_UNICODE_FS */ - -/* Another Helper functions for the WinNT ApiW() functions. We need to - * derive some 'resource' names (max length 255 characters, prefixed with - * Global/ or Local/ on WinNT) from something that looks like a filename. - * Since 'resource' names never contain slashes, convert these to '_'s - * and return the appropriate char* or wchar* for ApiA or ApiW calls. - */ - -void *res_name_from_filename(const char *file, int global, apr_pool_t *pool); - -#define APR_FILE_MAX MAX_PATH - -#define APR_FILE_DEFAULT_BUFSIZE 4096 -/* For backwards-compat */ -#define APR_FILE_BUFSIZE APR_FILE_DEFAULT_BUFSIZE - -/* obscure ommissions from msvc's sys/stat.h */ -#ifdef _MSC_VER -#define S_IFIFO _S_IFIFO /* pipe */ -#define S_IFBLK 0060000 /* Block Special */ -#define S_IFLNK 0120000 /* Symbolic Link */ -#define S_IFSOCK 0140000 /* Socket */ -#define S_IFWHT 0160000 /* Whiteout */ -#endif - -/* Internal Flags for apr_file_open */ -#define APR_OPENINFO 0x00100000 /* Open without READ or WRITE access */ -#define APR_OPENLINK 0x00200000 /* Open a link itself, if supported */ -#define APR_READCONTROL 0x00400000 /* Read the file's owner/perms */ -#define APR_WRITECONTROL 0x00800000 /* Modify the file's owner/perms */ -/* #define APR_INHERIT 0x01000000 -- Defined in apr_arch_inherit.h! */ -#define APR_STDIN_FLAG 0x02000000 /* Obtained via apr_file_open_stdin() */ -#define APR_STDOUT_FLAG 0x04000000 /* Obtained via apr_file_open_stdout() */ -#define APR_STDERR_FLAG 0x06000000 /* Obtained via apr_file_open_stderr() */ -#define APR_STD_FLAGS (APR_STDIN_FLAG | APR_STDOUT_FLAG | APR_STDERR_FLAG) -#define APR_WRITEATTRS 0x08000000 /* Modify the file's attributes */ - -/* Entries missing from the MSVC 5.0 Win32 SDK: - */ -#ifndef FILE_ATTRIBUTE_DEVICE -#define FILE_ATTRIBUTE_DEVICE 0x00000040 -#endif -#ifndef FILE_ATTRIBUTE_REPARSE_POINT -#define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400 -#endif -#ifndef FILE_FLAG_OPEN_NO_RECALL -#define FILE_FLAG_OPEN_NO_RECALL 0x00100000 -#endif -#ifndef FILE_FLAG_OPEN_REPARSE_POINT -#define FILE_FLAG_OPEN_REPARSE_POINT 0x00200000 -#endif -#ifndef TRUSTEE_IS_WELL_KNOWN_GROUP -#define TRUSTEE_IS_WELL_KNOWN_GROUP 5 -#endif - -/* Information bits available from the WIN32 FindFirstFile function */ -#define APR_FINFO_WIN32_DIR (APR_FINFO_NAME | APR_FINFO_TYPE \ - | APR_FINFO_CTIME | APR_FINFO_ATIME \ - | APR_FINFO_MTIME | APR_FINFO_SIZE) - -/* Sneak the Readonly bit through finfo->protection for internal use _only_ */ -#define APR_FREADONLY 0x10000000 - -/* Private function for apr_stat/lstat/getfileinfo/dir_read */ -int fillin_fileinfo(apr_finfo_t *finfo, WIN32_FILE_ATTRIBUTE_DATA *wininfo, - int byhandle, apr_int32_t wanted); - -/* Private function that extends apr_stat/lstat/getfileinfo/dir_read */ -apr_status_t more_finfo(apr_finfo_t *finfo, const void *ufile, - apr_int32_t wanted, int whatfile); - -/* whatfile types for the ufile arg */ -#define MORE_OF_HANDLE 0 -#define MORE_OF_FSPEC 1 -#define MORE_OF_WFSPEC 2 - -/* quick run-down of fields in windows' apr_file_t structure that may have - * obvious uses. - * fname -- the filename as passed to the open call. - * dwFileAttricutes -- Attributes used to open the file. - * append -- Windows doesn't support the append concept when opening files. - * APR needs to keep track of this, and always make sure we append - * correctly when writing to a file with this flag set TRUE. - */ - -/* for apr_poll.c */ -#define filedes filehand - -struct apr_file_t { - apr_pool_t *pool; - HANDLE filehand; - BOOLEAN pipe; /* Is this a pipe of a file? */ - OVERLAPPED *pOverlapped; - apr_interval_time_t timeout; - apr_int32_t flags; - - /* File specific info */ - apr_finfo_t *finfo; - char *fname; - DWORD dwFileAttributes; - int eof_hit; - BOOLEAN buffered; // Use buffered I/O? - int ungetchar; // Last char provided by an unget op. (-1 = no char) - int append; - - /* Stuff for buffered mode */ - char *buffer; - apr_size_t bufpos; // Read/Write position in buffer - apr_size_t bufsize; // The size of the buffer - apr_size_t dataRead; // amount of valid data read into buffer - int direction; // buffer being used for 0 = read, 1 = write - apr_off_t filePtr; // position in file of handle - apr_thread_mutex_t *mutex; // mutex semaphore, must be owned to access the above fields - - /* if there is a timeout set, then this pollset is used */ - apr_pollset_t *pollset; - - /* Pipe specific info */ -}; - -struct apr_dir_t { - apr_pool_t *pool; - HANDLE dirhand; - apr_size_t rootlen; - char *dirname; - char *name; - union { -#if APR_HAS_UNICODE_FS - struct { - WIN32_FIND_DATAW *entry; - } w; -#endif -#if APR_HAS_ANSI_FS - struct { - WIN32_FIND_DATAA *entry; - } n; -#endif - }; - int bof; -}; - -/* There are many goofy characters the filesystem can't accept - * or can confound the cmd.exe shell. Here's the list - * [declared in filesys.c] - */ -extern const char apr_c_is_fnchar[256]; - -#define IS_FNCHAR(c) (apr_c_is_fnchar[(unsigned char)(c)] & 1) -#define IS_SHCHAR(c) ((apr_c_is_fnchar[(unsigned char)(c)] & 2) == 2) - - -/* If the user passes APR_FILEPATH_TRUENAME to either - * apr_filepath_root or apr_filepath_merge, this fn determines - * that the root really exists. It's expensive, wouldn't want - * to do this too frequenly. - */ -apr_status_t filepath_root_test(char *path, apr_pool_t *p); - - -/* The apr_filepath_merge wants to canonicalize the cwd to the - * addpath if the user passes NULL as the old root path (this - * isn't true of an empty string "", which won't be concatenated. - * - * But we need to figure out what the cwd of a given volume is, - * when the user passes D:foo. This fn will determine D:'s cwd. - * - * If flags includes the bit APR_FILEPATH_NATIVE, the path returned - * is in the os-native format. - */ -apr_status_t filepath_drive_get(char **rootpath, char drive, - apr_int32_t flags, apr_pool_t *p); - - -/* If the user passes d: vs. D: (or //mach/share vs. //MACH/SHARE), - * we need to fold the case to canonical form. This function is - * supposed to do so. - */ -apr_status_t filepath_root_case(char **rootpath, char *root, apr_pool_t *p); - - -apr_status_t file_cleanup(void *); - -extern apr_status_t -apr_file_socket_pipe_create(apr_file_t **in, - apr_file_t **out, - apr_pool_t *p); - -extern apr_status_t -apr_file_socket_pipe_close(apr_file_t *file); - -#endif /* ! FILE_IO_H */ diff --git a/libs/apr/include/arch/win32/apr_arch_inherit.h b/libs/apr/include/arch/win32/apr_arch_inherit.h deleted file mode 100644 index 8969af66..00000000 --- a/libs/apr/include/arch/win32/apr_arch_inherit.h +++ /dev/null @@ -1,123 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef INHERIT_H -#define INHERIT_H - -#include "apr_inherit.h" - -#define APR_INHERIT (1 << 24) /* Must not conflict with other bits */ - -#if APR_HAS_UNICODE_FS && APR_HAS_ANSI_FS -/* !defined(_WIN32_WCE) is implicit here */ - -#define APR_IMPLEMENT_INHERIT_SET(name, flag, pool, cleanup) \ -APR_DECLARE(apr_status_t) apr_##name##_inherit_set(apr_##name##_t *the##name) \ -{ \ - IF_WIN_OS_IS_UNICODE \ - { \ -/* if (!SetHandleInformation(the##name->filehand, \ - * HANDLE_FLAG_INHERIT, \ - * HANDLE_FLAG_INHERIT)) \ - * return apr_get_os_error(); \ - */ } \ - ELSE_WIN_OS_IS_ANSI \ - { \ - HANDLE temp, hproc = GetCurrentProcess(); \ - if (!DuplicateHandle(hproc, the##name->filehand, \ - hproc, &temp, 0, TRUE, \ - DUPLICATE_SAME_ACCESS)) \ - return apr_get_os_error(); \ - CloseHandle(the##name->filehand); \ - the##name->filehand = temp; \ - } \ - return APR_SUCCESS; \ -} - -#define APR_IMPLEMENT_INHERIT_UNSET(name, flag, pool, cleanup) \ -APR_DECLARE(apr_status_t) apr_##name##_inherit_unset(apr_##name##_t *the##name)\ -{ \ - IF_WIN_OS_IS_UNICODE \ - { \ -/* if (!SetHandleInformation(the##name->filehand, \ - * HANDLE_FLAG_INHERIT, 0)) \ - * return apr_get_os_error(); \ - */ } \ - ELSE_WIN_OS_IS_ANSI \ - { \ - HANDLE temp, hproc = GetCurrentProcess(); \ - if (!DuplicateHandle(hproc, the##name->filehand, \ - hproc, &temp, 0, FALSE, \ - DUPLICATE_SAME_ACCESS)) \ - return apr_get_os_error(); \ - CloseHandle(the##name->filehand); \ - the##name->filehand = temp; \ - } \ - return APR_SUCCESS; \ -} - -#elif APR_HAS_ANSI_FS || defined(_WIN32_WCE) - -#define APR_IMPLEMENT_INHERIT_SET(name, flag, pool, cleanup) \ -APR_DECLARE(apr_status_t) apr_##name##_inherit_set(apr_##name##_t *the##name) \ -{ \ - HANDLE temp, hproc = GetCurrentProcess(); \ - if (!DuplicateHandle(hproc, the##name->filehand, \ - hproc, &temp, 0, TRUE, \ - DUPLICATE_SAME_ACCESS)) \ - return apr_get_os_error(); \ - CloseHandle(the##name->filehand); \ - the##name->filehand = temp; \ - return APR_SUCCESS; \ -} - -#define APR_IMPLEMENT_INHERIT_UNSET(name, flag, pool, cleanup) \ -APR_DECLARE(apr_status_t) apr_##name##_inherit_unset(apr_##name##_t *the##name)\ -{ \ - HANDLE temp, hproc = GetCurrentProcess(); \ - if (!DuplicateHandle(hproc, the##name->filehand, \ - hproc, &temp, 0, FALSE, \ - DUPLICATE_SAME_ACCESS)) \ - return apr_get_os_error(); \ - CloseHandle(the##name->filehand); \ - the##name->filehand = temp; \ - return APR_SUCCESS; \ -} - -#else /* APR_HAS_UNICODE_FS && !APR_HAS_ANSI_FS && !defined(_WIN32_WCE) */ - -#define APR_IMPLEMENT_INHERIT_SET(name, flag, pool, cleanup) \ -APR_DECLARE(apr_status_t) apr_##name##_inherit_set(apr_##name##_t *the##name) \ -{ \ -/* if (!SetHandleInformation(the##name->filehand, \ - * HANDLE_FLAG_INHERIT, \ - * HANDLE_FLAG_INHERIT)) \ - * return apr_get_os_error(); \ - */ return APR_SUCCESS; \ -} - -#define APR_IMPLEMENT_INHERIT_UNSET(name, flag, pool, cleanup) \ -APR_DECLARE(apr_status_t) apr_##name##_inherit_unset(apr_##name##_t *the##name)\ -{ \ -/* if (!SetHandleInformation(the##name->filehand, \ - * HANDLE_FLAG_INHERIT, 0)) \ - * return apr_get_os_error(); \ - */ return APR_SUCCESS; \ -} - -#endif /* defined(APR_HAS_UNICODE_FS) */ - -#endif /* ! INHERIT_H */ diff --git a/libs/apr/include/arch/win32/apr_arch_misc.h b/libs/apr/include/arch/win32/apr_arch_misc.h deleted file mode 100644 index caecaa17..00000000 --- a/libs/apr/include/arch/win32/apr_arch_misc.h +++ /dev/null @@ -1,486 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef MISC_H -#define MISC_H - -#include "apr.h" -#include "apr_portable.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_getopt.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include "apr_errno.h" -#include "apr_getopt.h" - -#if APR_HAVE_STDIO_H -#include -#endif -#if APR_HAVE_SIGNAL_H -#include -#endif -#if APR_HAVE_PTHREAD_H -#include -#endif -#if APR_HAVE_STDLIB_H -#include -#endif -#if APR_HAVE_STRING_H -#include -#endif -#ifndef _WIN32_WCE -#include -#endif - -struct apr_other_child_rec_t { - apr_pool_t *p; - struct apr_other_child_rec_t *next; - apr_proc_t *proc; - void (*maintenance) (int, void *, int); - void *data; - apr_os_file_t write_fd; -}; - -#define WSAHighByte 2 -#define WSALowByte 0 - -/* start.c and apr_app.c helpers and communication within misc.c - * - * They are not for public consumption, although apr_app_init_complete - * must be an exported symbol to avoid reinitialization. - */ -extern int APR_DECLARE_DATA apr_app_init_complete; - -int apr_wastrtoastr(char const * const * *retarr, - wchar_t const * const *arr, int args); - -/* Platform specific designation of run time os version. - * Gaps allow for specific service pack levels that - * export new kernel or winsock functions or behavior. - */ -typedef enum { - APR_WIN_UNK = 0, - APR_WIN_UNSUP = 1, - APR_WIN_95 = 10, - APR_WIN_95_B = 11, - APR_WIN_95_OSR2 = 12, - APR_WIN_98 = 14, - APR_WIN_98_SE = 16, - APR_WIN_ME = 18, - - APR_WIN_UNICODE = 20, /* Prior versions support only narrow chars */ - - APR_WIN_CE_3 = 23, /* CE is an odd beast, not supporting */ - /* some pre-NT features, such as the */ - APR_WIN_NT = 30, /* narrow charset APIs (fooA fns), while */ - APR_WIN_NT_3_5 = 35, /* not supporting some NT-family features. */ - APR_WIN_NT_3_51 = 36, - - APR_WIN_NT_4 = 40, - APR_WIN_NT_4_SP2 = 42, - APR_WIN_NT_4_SP3 = 43, - APR_WIN_NT_4_SP4 = 44, - APR_WIN_NT_4_SP5 = 45, - APR_WIN_NT_4_SP6 = 46, - - APR_WIN_2000 = 50, - APR_WIN_2000_SP1 = 51, - APR_WIN_2000_SP2 = 52, - APR_WIN_XP = 60, - APR_WIN_XP_SP1 = 61, - APR_WIN_XP_SP2 = 62, - APR_WIN_2003 = 70, - APR_WIN_VISTA = 80 -} apr_oslevel_e; - -extern APR_DECLARE_DATA apr_oslevel_e apr_os_level; - -apr_status_t apr_get_oslevel(apr_oslevel_e *); - -/* The APR_HAS_ANSI_FS symbol is PRIVATE, and internal to APR. - * APR only supports char data for filenames. Like most applications, - * characters >127 are essentially undefined. APR_HAS_UNICODE_FS lets - * the application know that utf-8 is the encoding method of APR, and - * only incidently hints that we have Wide OS calls. - * - * APR_HAS_ANSI_FS is simply an OS flag to tell us all calls must be - * the unicode eqivilant. - */ - -#if defined(_WIN32_WCE) || defined(WINNT) -#define APR_HAS_ANSI_FS 0 -#else -#define APR_HAS_ANSI_FS 1 -#endif - -/* IF_WIN_OS_IS_UNICODE / ELSE_WIN_OS_IS_ANSI help us keep the code trivial - * where have runtime tests for unicode-ness, that aren't needed in any - * build which supports only WINNT or WCE. - */ -#if APR_HAS_ANSI_FS && APR_HAS_UNICODE_FS -#define IF_WIN_OS_IS_UNICODE if (apr_os_level >= APR_WIN_UNICODE) -#define ELSE_WIN_OS_IS_ANSI else -#else /* APR_HAS_UNICODE_FS */ -#define IF_WIN_OS_IS_UNICODE -#define ELSE_WIN_OS_IS_ANSI -#endif /* WINNT */ - -#if defined(_MSC_VER) && !defined(_WIN32_WCE) -#include "crtdbg.h" - -static APR_INLINE void* apr_malloc_dbg(size_t size, const char* filename, - int linenumber) -{ - return _malloc_dbg(size, _CRT_BLOCK, filename, linenumber); -} - -static APR_INLINE void* apr_realloc_dbg(void* userData, size_t newSize, - const char* filename, int linenumber) -{ - return _realloc_dbg(userData, newSize, _CRT_BLOCK, filename, linenumber); -} - -#else - -static APR_INLINE void* apr_malloc_dbg(size_t size, const char* filename, - int linenumber) -{ - return malloc(size); -} - -static APR_INLINE void* apr_realloc_dbg(void* userData, size_t newSize, - const char* filename, int linenumber) -{ - return realloc(userData, newSize); -} - -#endif /* ! _MSC_VER */ - -typedef enum { - DLL_WINBASEAPI = 0, /* kernel32 From WinBase.h */ - DLL_WINADVAPI = 1, /* advapi32 From WinBase.h */ - DLL_WINSOCKAPI = 2, /* mswsock From WinSock.h */ - DLL_WINSOCK2API = 3, /* ws2_32 From WinSock2.h */ - DLL_SHSTDAPI = 4, /* shell32 From ShellAPI.h */ - DLL_NTDLL = 5, /* shell32 From our real kernel */ - DLL_defined = 6 /* must define as last idx_ + 1 */ -} apr_dlltoken_e; - -FARPROC apr_load_dll_func(apr_dlltoken_e fnLib, char *fnName, int ordinal); - -/* The apr_load_dll_func call WILL return 0 set error to - * ERROR_INVALID_FUNCTION if the function cannot be loaded - */ -#define APR_DECLARE_LATE_DLL_FUNC(lib, rettype, calltype, fn, ord, args, names) \ - typedef rettype (calltype *apr_winapi_fpt_##fn) args; \ - static apr_winapi_fpt_##fn apr_winapi_pfn_##fn = NULL; \ - static int apr_winapi_chk_##fn = 0; \ - static APR_INLINE int apr_winapi_ld_##fn(void) \ - { if (apr_winapi_pfn_##fn) return 1; \ - if (apr_winapi_chk_##fn ++) return 0; \ - if (!apr_winapi_pfn_##fn) \ - apr_winapi_pfn_##fn = (apr_winapi_fpt_##fn) \ - apr_load_dll_func(lib, #fn, ord); \ - if (apr_winapi_pfn_##fn) return 1; else return 0; }; \ - static APR_INLINE rettype apr_winapi_##fn args \ - { if (apr_winapi_ld_##fn()) \ - return (*(apr_winapi_pfn_##fn)) names; \ - else { ::SetLastError(ERROR_INVALID_FUNCTION); return 0;} }; \ - -#define APR_HAVE_LATE_DLL_FUNC(fn) apr_winapi_ld_##fn() - -/* Provide late bound declarations of every API function missing from - * one or more supported releases of the Win32 API - * - * lib is the enumerated token from apr_dlltoken_e, and must correspond - * to the string table entry in start.c used by the apr_load_dll_func(). - * Token names (attempt to) follow Windows.h declarations prefixed by DLL_ - * in order to facilitate comparison. Use the exact declaration syntax - * and names from Windows.h to prevent ambigutity and bugs. - * - * rettype and calltype follow the original declaration in Windows.h - * fn is the true function name - beware Ansi/Unicode #defined macros - * ord is the ordinal within the library, use 0 if it varies between versions - * args is the parameter list following the original declaration, in parens - * names is the parameter list sans data types, enclosed in parens - * - * #undef/re#define the Ansi/Unicode generic name to abate confusion - * In the case of non-text functions, simply #define the original name - */ - -#if !defined(_WIN32_WCE) && !defined(WINNT) -/* This group is available to all versions of WINNT 4.0 SP6 and later */ - -#ifdef GetFileAttributesExA -#undef GetFileAttributesExA -#endif -APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, GetFileAttributesExA, 0, ( - IN LPCSTR lpFileName, - IN GET_FILEEX_INFO_LEVELS fInfoLevelId, - OUT LPVOID lpFileInformation), - (lpFileName, fInfoLevelId, lpFileInformation)); -#define GetFileAttributesExA apr_winapi_GetFileAttributesExA -#undef GetFileAttributesEx -#define GetFileAttributesEx apr_winapi_GetFileAttributesExA - -#ifdef GetFileAttributesExW -#undef GetFileAttributesExW -#endif -APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, GetFileAttributesExW, 0, ( - IN LPCWSTR lpFileName, - IN GET_FILEEX_INFO_LEVELS fInfoLevelId, - OUT LPVOID lpFileInformation), - (lpFileName, fInfoLevelId, lpFileInformation)); -#define GetFileAttributesExW apr_winapi_GetFileAttributesExW - -APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, CancelIo, 0, ( - IN HANDLE hFile), - (hFile)); -#define CancelIo apr_winapi_CancelIo - -APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, TryEnterCriticalSection, 0, ( - LPCRITICAL_SECTION lpCriticalSection), - (lpCriticalSection)); -#define TryEnterCriticalSection apr_winapi_TryEnterCriticalSection - -APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, SwitchToThread, 0, ( - void), - ()); -#define SwitchToThread apr_winapi_SwitchToThread - -APR_DECLARE_LATE_DLL_FUNC(DLL_WINADVAPI, BOOL, WINAPI, GetEffectiveRightsFromAclW, 0, ( - IN PACL pacl, - IN PTRUSTEE_W pTrustee, - OUT PACCESS_MASK pAccessRights), - (pacl, pTrustee, pAccessRights)); -#define GetEffectiveRightsFromAclW apr_winapi_GetEffectiveRightsFromAclW - -APR_DECLARE_LATE_DLL_FUNC(DLL_WINADVAPI, BOOL, WINAPI, GetNamedSecurityInfoW, 0, ( - IN LPWSTR pObjectName, - IN SE_OBJECT_TYPE ObjectType, - IN SECURITY_INFORMATION SecurityInfo, - OUT PSID *ppsidOwner, - OUT PSID *ppsidGroup, - OUT PACL *ppDacl, - OUT PACL *ppSacl, - OUT PSECURITY_DESCRIPTOR *ppSecurityDescriptor), - (pObjectName, ObjectType, SecurityInfo, ppsidOwner, ppsidGroup, - ppDacl, ppSacl, ppSecurityDescriptor)); -#define GetNamedSecurityInfoW apr_winapi_GetNamedSecurityInfoW - -APR_DECLARE_LATE_DLL_FUNC(DLL_WINADVAPI, BOOL, WINAPI, GetNamedSecurityInfoA, 0, ( - IN LPSTR pObjectName, - IN SE_OBJECT_TYPE ObjectType, - IN SECURITY_INFORMATION SecurityInfo, - OUT PSID *ppsidOwner, - OUT PSID *ppsidGroup, - OUT PACL *ppDacl, - OUT PACL *ppSacl, - OUT PSECURITY_DESCRIPTOR *ppSecurityDescriptor), - (pObjectName, ObjectType, SecurityInfo, ppsidOwner, ppsidGroup, - ppDacl, ppSacl, ppSecurityDescriptor)); -#define GetNamedSecurityInfoA apr_winapi_GetNamedSecurityInfoA -#undef GetNamedSecurityInfo -#define GetNamedSecurityInfo apr_winapi_GetNamedSecurityInfoA - -APR_DECLARE_LATE_DLL_FUNC(DLL_WINADVAPI, BOOL, WINAPI, GetSecurityInfo, 0, ( - IN HANDLE handle, - IN SE_OBJECT_TYPE ObjectType, - IN SECURITY_INFORMATION SecurityInfo, - OUT PSID *ppsidOwner, - OUT PSID *ppsidGroup, - OUT PACL *ppDacl, - OUT PACL *ppSacl, - OUT PSECURITY_DESCRIPTOR *ppSecurityDescriptor), - (handle, ObjectType, SecurityInfo, ppsidOwner, ppsidGroup, - ppDacl, ppSacl, ppSecurityDescriptor)); -#define GetSecurityInfo apr_winapi_GetSecurityInfo - -APR_DECLARE_LATE_DLL_FUNC(DLL_SHSTDAPI, LPWSTR *, WINAPI, CommandLineToArgvW, 0, ( - LPCWSTR lpCmdLine, - int *pNumArgs), - (lpCmdLine, pNumArgs)); -#define CommandLineToArgvW apr_winapi_CommandLineToArgvW - -#endif /* !defined(_WIN32_WCE) && !defined(WINNT) */ - -#if !defined(_WIN32_WCE) -/* This group is NOT available to all versions of WinNT, - * these we must always look up - */ - -#ifdef GetCompressedFileSizeA -#undef GetCompressedFileSizeA -#endif -APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, DWORD, WINAPI, GetCompressedFileSizeA, 0, ( - IN LPCSTR lpFileName, - OUT LPDWORD lpFileSizeHigh), - (lpFileName, lpFileSizeHigh)); -#define GetCompressedFileSizeA apr_winapi_GetCompressedFileSizeA -#undef GetCompressedFileSize -#define GetCompressedFileSize apr_winapi_GetCompressedFileSizeA - -#ifdef GetCompressedFileSizeW -#undef GetCompressedFileSizeW -#endif -APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, DWORD, WINAPI, GetCompressedFileSizeW, 0, ( - IN LPCWSTR lpFileName, - OUT LPDWORD lpFileSizeHigh), - (lpFileName, lpFileSizeHigh)); -#define GetCompressedFileSizeW apr_winapi_GetCompressedFileSizeW - - -APR_DECLARE_LATE_DLL_FUNC(DLL_NTDLL, LONG, WINAPI, NtQueryTimerResolution, 0, ( - ULONG *pMaxRes, /* Minimum NS Resolution */ - ULONG *pMinRes, /* Maximum NS Resolution */ - ULONG *pCurRes), /* Current NS Resolution */ - (pMaxRes, pMinRes, pCurRes)); -#define QueryTimerResolution apr_winapi_NtQueryTimerResolution - -APR_DECLARE_LATE_DLL_FUNC(DLL_NTDLL, LONG, WINAPI, NtSetTimerResolution, 0, ( - ULONG ReqRes, /* Requested NS Clock Resolution */ - BOOL Acquire, /* Aquire (1) or Release (0) our interest */ - ULONG *pNewRes), /* The NS Clock Resolution granted */ - (ReqRes, Acquire, pNewRes)); -#define SetTimerResolution apr_winapi_NtSetTimerResolution - -typedef struct PBI { - LONG ExitStatus; - PVOID PebBaseAddress; - apr_uintptr_t AffinityMask; - LONG BasePriority; - apr_uintptr_t UniqueProcessId; - apr_uintptr_t InheritedFromUniqueProcessId; -} PBI, *PPBI; - -APR_DECLARE_LATE_DLL_FUNC(DLL_NTDLL, LONG, WINAPI, NtQueryInformationProcess, 0, ( - HANDLE hProcess, /* Obvious */ - INT info, /* Use 0 for PBI documented above */ - PVOID pPI, /* The PIB buffer */ - ULONG LenPI, /* Use sizeof(PBI) */ - ULONG *pSizePI), /* returns pPI buffer used (may pass NULL) */ - (hProcess, info, pPI, LenPI, pSizePI)); -#define QueryInformationProcess apr_winapi_NtQueryInformationProcess - -APR_DECLARE_LATE_DLL_FUNC(DLL_NTDLL, LONG, WINAPI, NtQueryObject, 0, ( - HANDLE hObject, /* Obvious */ - INT info, /* Use 0 for PBI documented above */ - PVOID pOI, /* The PIB buffer */ - ULONG LenOI, /* Use sizeof(PBI) */ - ULONG *pSizeOI), /* returns pPI buffer used (may pass NULL) */ - (hObject, info, pOI, LenOI, pSizeOI)); -#define QueryObject apr_winapi_NtQueryObject - -typedef struct IOSB { - union { - UINT Status; - PVOID reserved; - }; - apr_uintptr_t Information; /* Varies by op, consumed buffer size for FSI below */ -} IOSB, *PIOSB; - -typedef struct FSI { - LONGLONG AllocationSize; - LONGLONG EndOfFile; - ULONG NumberOfLinks; - BOOL DeletePending; - BOOL Directory; -} FSI, *PFSI; - -APR_DECLARE_LATE_DLL_FUNC(DLL_NTDLL, LONG, WINAPI, ZwQueryInformationFile, 0, ( - HANDLE hObject, /* Obvious */ - PVOID pIOSB, /* Point to the IOSB buffer for detailed return results */ - PVOID pFI, /* The buffer, using FIB above */ - ULONG LenFI, /* Use sizeof(FI) */ - ULONG info), /* Use 5 for FSI documented above*/ - (hObject, pIOSB, pFI, LenFI, info)); -#define ZwQueryInformationFile apr_winapi_ZwQueryInformationFile - -#ifdef CreateToolhelp32Snapshot -#undef CreateToolhelp32Snapshot -#endif -APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, HANDLE, WINAPI, CreateToolhelp32Snapshot, 0, ( - DWORD dwFlags, - DWORD th32ProcessID), - (dwFlags, th32ProcessID)); -#define CreateToolhelp32Snapshot apr_winapi_CreateToolhelp32Snapshot - -#ifdef Process32FirstW -#undef Process32FirstW -#endif -APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, Process32FirstW, 0, ( - HANDLE hSnapshot, - LPPROCESSENTRY32W lppe), - (hSnapshot, lppe)); -#define Process32FirstW apr_winapi_Process32FirstW - -#ifdef Process32NextW -#undef Process32NextW -#endif -APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, Process32NextW, 0, ( - HANDLE hSnapshot, - LPPROCESSENTRY32W lppe), - (hSnapshot, lppe)); -#define Process32NextW apr_winapi_Process32NextW - -#if !defined(POLLERR) -/* Event flag definitions for WSAPoll(). */ -#define POLLRDNORM 0x0100 -#define POLLRDBAND 0x0200 -#define POLLIN (POLLRDNORM | POLLRDBAND) -#define POLLPRI 0x0400 - -#define POLLWRNORM 0x0010 -#define POLLOUT (POLLWRNORM) -#define POLLWRBAND 0x0020 - -#define POLLERR 0x0001 -#define POLLHUP 0x0002 -#define POLLNVAL 0x0004 - -typedef struct pollfd { - SOCKET fd; - SHORT events; - SHORT revents; - -} WSAPOLLFD, *PWSAPOLLFD, FAR *LPWSAPOLLFD; - -#endif /* !defined(POLLERR) */ -#ifdef WSAPoll -#undef WSAPoll -#endif -APR_DECLARE_LATE_DLL_FUNC(DLL_WINSOCK2API, int, WSAAPI, WSAPoll, 0, ( - IN OUT LPWSAPOLLFD fdArray, - IN ULONG fds, - IN INT timeout), - (fdArray, fds, timeout)); -#define WSAPoll apr_winapi_WSAPoll -#define HAVE_POLL 1 - -#ifdef SetDllDirectoryW -#undef SetDllDirectoryW -#endif -APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, SetDllDirectoryW, 0, ( - IN LPCWSTR lpPathName), - (lpPathName)); -#define SetDllDirectoryW apr_winapi_SetDllDirectoryW - -#endif /* !defined(_WIN32_WCE) */ - -#endif /* ! MISC_H */ - diff --git a/libs/apr/include/arch/win32/apr_arch_networkio.h b/libs/apr/include/arch/win32/apr_arch_networkio.h deleted file mode 100644 index 04be5559..00000000 --- a/libs/apr/include/arch/win32/apr_arch_networkio.h +++ /dev/null @@ -1,90 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef NETWORK_IO_H -#define NETWORK_IO_H - -#include "apr_network_io.h" -#include "apr_general.h" -#include "apr_poll.h" - -typedef struct sock_userdata_t sock_userdata_t; -struct sock_userdata_t { - sock_userdata_t *next; - const char *key; - void *data; -}; - -struct apr_socket_t { - apr_pool_t *pool; - SOCKET socketdes; - int type; /* SOCK_STREAM, SOCK_DGRAM */ - int protocol; - apr_sockaddr_t *local_addr; - apr_sockaddr_t *remote_addr; - int timeout_ms; /* MUST MATCH if timeout > 0 */ - apr_interval_time_t timeout; - apr_int32_t disconnected; - int local_port_unknown; - int local_interface_unknown; - int remote_addr_unknown; - apr_int32_t options; - apr_int32_t inherit; -#if APR_HAS_SENDFILE - /* As of 07.20.04, the overlapped structure is only used by - * apr_socket_sendfile and that's where it will be allocated - * and initialized. - */ - OVERLAPPED *overlapped; -#endif - sock_userdata_t *userdata; - - /* if there is a timeout set, then this pollset is used */ - apr_pollset_t *pollset; -}; - -#ifdef _WIN32_WCE -#ifndef WSABUF -typedef struct _WSABUF { - u_long len; /* the length of the buffer */ - char FAR * buf; /* the pointer to the buffer */ -} WSABUF, FAR * LPWSABUF; -#endif -#else -#ifdef _MSC_VER -#define HAVE_STRUCT_IPMREQ -#endif -#endif - -apr_status_t status_from_res_error(int); - -const char *apr_inet_ntop(int af, const void *src, char *dst, apr_size_t size); -int apr_inet_pton(int af, const char *src, void *dst); -void apr_sockaddr_vars_set(apr_sockaddr_t *, int, apr_port_t); - -#define apr_is_option_set(skt, option) \ - (((skt)->options & (option)) == (option)) - -#define apr_set_option(skt, option, on) \ - do { \ - if (on) \ - (skt)->options |= (option); \ - else \ - (skt)->options &= ~(option); \ - } while (0) - -#endif /* ! NETWORK_IO_H */ - diff --git a/libs/apr/include/arch/win32/apr_arch_proc_mutex.h b/libs/apr/include/arch/win32/apr_arch_proc_mutex.h deleted file mode 100644 index 4e3e3993..00000000 --- a/libs/apr/include/arch/win32/apr_arch_proc_mutex.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PROC_MUTEX_H -#define PROC_MUTEX_H - -#include "apr_proc_mutex.h" - -struct apr_proc_mutex_t { - apr_pool_t *pool; - HANDLE handle; - const char *fname; -}; - -#endif /* PROC_MUTEX_H */ - diff --git a/libs/apr/include/arch/win32/apr_arch_thread_cond.h b/libs/apr/include/arch/win32/apr_arch_thread_cond.h deleted file mode 100644 index c7f69f80..00000000 --- a/libs/apr/include/arch/win32/apr_arch_thread_cond.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef THREAD_COND_H -#define THREAD_COND_H - -#include "apr_thread_cond.h" - -struct apr_thread_cond_t { - apr_pool_t *pool; - HANDLE semaphore; - CRITICAL_SECTION csection; - unsigned long num_waiting; - unsigned long num_wake; - unsigned long generation; -}; - -#endif /* THREAD_COND_H */ - diff --git a/libs/apr/include/arch/win32/apr_arch_thread_mutex.h b/libs/apr/include/arch/win32/apr_arch_thread_mutex.h deleted file mode 100644 index 13d3c1cb..00000000 --- a/libs/apr/include/arch/win32/apr_arch_thread_mutex.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef THREAD_MUTEX_H -#define THREAD_MUTEX_H - -#include "apr_pools.h" - -typedef enum thread_mutex_type { - thread_mutex_critical_section, - thread_mutex_unnested_event, - thread_mutex_nested_mutex -} thread_mutex_type; - -/* handle applies only to unnested_event on all platforms - * and nested_mutex on Win9x only. Otherwise critical_section - * is used for NT nexted mutexes providing optimal performance. - */ -struct apr_thread_mutex_t { - apr_pool_t *pool; - thread_mutex_type type; - HANDLE handle; - CRITICAL_SECTION section; -}; - -#endif /* THREAD_MUTEX_H */ - diff --git a/libs/apr/include/arch/win32/apr_arch_thread_rwlock.h b/libs/apr/include/arch/win32/apr_arch_thread_rwlock.h deleted file mode 100644 index 1177e529..00000000 --- a/libs/apr/include/arch/win32/apr_arch_thread_rwlock.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef THREAD_RWLOCK_H -#define THREAD_RWLOCK_H - -#include "apr_thread_rwlock.h" - -struct apr_thread_rwlock_t { - apr_pool_t *pool; - HANDLE write_mutex; - HANDLE read_event; - LONG readers; -}; - -#endif /* THREAD_RWLOCK_H */ - diff --git a/libs/apr/include/arch/win32/apr_arch_threadproc.h b/libs/apr/include/arch/win32/apr_arch_threadproc.h deleted file mode 100644 index d3ce9c51..00000000 --- a/libs/apr/include/arch/win32/apr_arch_threadproc.h +++ /dev/null @@ -1,74 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_private.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" - -#ifndef THREAD_PROC_H -#define THREAD_PROC_H - -#define SHELL_PATH "cmd.exe" - -struct apr_thread_t { - apr_pool_t *pool; - HANDLE td; - apr_int32_t cancel; - apr_int32_t cancel_how; - void *data; - apr_thread_start_t func; - apr_status_t exitval; -}; - -struct apr_threadattr_t { - apr_pool_t *pool; - apr_int32_t detach; - apr_size_t stacksize; -}; - -struct apr_threadkey_t { - apr_pool_t *pool; - DWORD key; -}; - -struct apr_procattr_t { - apr_pool_t *pool; - apr_file_t *parent_in; - apr_file_t *child_in; - apr_file_t *parent_out; - apr_file_t *child_out; - apr_file_t *parent_err; - apr_file_t *child_err; - char *currdir; - apr_int32_t cmdtype; - apr_int32_t detached; - apr_child_errfn_t *errfn; - apr_int32_t errchk; -#ifndef _WIN32_WCE - HANDLE user_token; - LPSECURITY_ATTRIBUTES sa; - LPVOID sd; -#endif -}; - -struct apr_thread_once_t { - long value; -}; - -extern apr_status_t apr_threadproc_init(apr_pool_t *pool); - -#endif /* ! THREAD_PROC_H */ - diff --git a/libs/apr/include/arch/win32/apr_arch_utf8.h b/libs/apr/include/arch/win32/apr_arch_utf8.h deleted file mode 100644 index 84f8bf77..00000000 --- a/libs/apr/include/arch/win32/apr_arch_utf8.h +++ /dev/null @@ -1,56 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef UTF8_H -#define UTF8_H - -#include "apr.h" -#include "apr_lib.h" -#include "apr_errno.h" - -/* If we ever support anything more exciting than char... this could move. - */ -typedef apr_uint16_t apr_wchar_t; - -/** - * An APR internal function for fast utf-8 octet-encoded Unicode conversion - * to the ucs-2 wide Unicode format. This function is used for filename and - * other resource conversions for platforms providing native Unicode support. - * - * @tip Only the errors APR_EINVAL and APR_INCOMPLETE may occur, the former - * when the character code is invalid (in or out of context) and the later - * when more characters were expected, but insufficient characters remain. - */ -APR_DECLARE(apr_status_t) apr_conv_utf8_to_ucs2(const char *in, - apr_size_t *inbytes, - apr_wchar_t *out, - apr_size_t *outwords); - -/** - * An APR internal function for fast ucs-2 wide Unicode format conversion to - * the utf-8 octet-encoded Unicode. This function is used for filename and - * other resource conversions for platforms providing native Unicode support. - * - * @tip Only the errors APR_EINVAL and APR_INCOMPLETE may occur, the former - * when the character code is invalid (in or out of context) and the later - * when more words were expected, but insufficient words remain. - */ -APR_DECLARE(apr_status_t) apr_conv_ucs2_to_utf8(const apr_wchar_t *in, - apr_size_t *inwords, - char *out, - apr_size_t *outbytes); - -#endif /* def UTF8_H */ diff --git a/libs/apr/include/arch/win32/apr_dbg_win32_handles.h b/libs/apr/include/arch/win32/apr_dbg_win32_handles.h deleted file mode 100644 index 471cd66d..00000000 --- a/libs/apr/include/arch/win32/apr_dbg_win32_handles.h +++ /dev/null @@ -1,217 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_DBG_WIN32_HANDLES_H -#define APR_DBG_WIN32_HANDLES_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* USAGE: - * - * Add the following include to apr_private.h for internal debugging, - * or copy this header into apr/include add the include below to apr.h - * for really global debugging; - * - * #include "apr_dbg_win32_handles.h" - * - * apr_dbg_log is the crux of this function ... it uses Win32 API and - * no apr calls itself to log all activity to a file named for the - * executing application with a .pid suffix. Ergo several instances - * may be executing and logged at once. - * - * HANDLE apr_dbg_log(char* fn, HANDLE ha, char* fl, int ln, int nh - * [, HANDLE *hv, char *dsc...]) - * - * returns: the handle passed in ha, which is cast back to the real return type. - * - * formats one line into the debug log file if nh is zero; - * ha (hex) seq(hex) tid(hex) fn fl ln - * xxxxxxxx xxxxxxxx xxxxxxxx func() sourcefile:lineno - * The macro apr_dbg_rv makes this simple to implement for many APIs - * that simply take args that don't interest us, and return a handle. - * - * formats multiple lines (nh) into the debug log file for each hv/dsc pair - * (nh must correspond to the number of pairs); - * hv (hex) seq(hex) tid(hex) fn dsc fl ln - * xxxxxxxx xxxxxxxx xxxxxxxx func(arg) sourcefile:lineno - * In this later usage, hv is the still the return value but is not - * treated as a handle. - */ - -APR_DECLARE_NONSTD(HANDLE) apr_dbg_log(char* fn, HANDLE ha, char* fl, int ln, - int nh,/* HANDLE *hv, char *dsc */...); - -#define apr_dbg_rv(fn, args) (apr_dbg_log(#fn,(fn) args,__FILE__,__LINE__,0)) - -#define CloseHandle(h) \ - ((BOOL)apr_dbg_log("CloseHandle", \ - (HANDLE)(CloseHandle)(h), \ - __FILE__,__LINE__,1, \ - &(h),"")) - -#define CreateEventA(sd,b1,b2,nm) apr_dbg_rv(CreateEventA,(sd,b1,b2,nm)) -#define CreateEventW(sd,b1,b2,nm) apr_dbg_rv(CreateEventW,(sd,b1,b2,nm)) - -#define CreateFileA(nm,d1,d2,sd,d3,d4,h) apr_dbg_rv(CreateFileA,(nm,d1,d2,sd,d3,d4,h)) -#define CreateFileW(nm,d1,d2,sd,d3,d4,h) apr_dbg_rv(CreateFileW,(nm,d1,d2,sd,d3,d4,h)) - -#define CreateFileMappingA(fh,sd,d1,d2,d3,nm) apr_dbg_rv(CreateFileMappingA,(fh,sd,d1,d2,d3,nm)) -#define CreateFileMappingW(fh,sd,d1,d2,d3,nm) apr_dbg_rv(CreateFileMappingW,(fh,sd,d1,d2,d3,nm)) - -#define CreateMutexA(sd,b,nm) apr_dbg_rv(CreateMutexA,(sd,b,nm)) -#define CreateMutexW(sd,b,nm) apr_dbg_rv(CreateMutexW,(sd,b,nm)) - -#define CreateIoCompletionPort(h1,h2,pd1,d2) apr_dbg_rv(CreateIoCompletionPort,(h1,h2,pd1,d2)) - -#define CreateNamedPipeA(nm,d1,d2,d3,d4,d5,d6,sd) apr_dbg_rv(CreateNamedPipeA,(nm,d1,d2,d3,d4,d5,d6,sd)) -#define CreateNamedPipeW(nm,d1,d2,d3,d4,d5,d6,sd) apr_dbg_rv(CreateNamedPipeW,(nm,d1,d2,d3,d4,d5,d6,sd)) - -#define CreatePipe(ph1,ph2,sd,d) \ - ((BOOL)apr_dbg_log("CreatePipe", \ - (HANDLE)(CreatePipe)(ph1,ph2,sd,d), \ - __FILE__,__LINE__,2, \ - (ph1),"hRead", \ - (ph2),"hWrite")) - -#define CreateProcessA(s1,s2,sd1,sd2,b,d1,s3,s4,pd2,hr) \ - ((BOOL)apr_dbg_log("CreateProcessA", \ - (HANDLE)(CreateProcessA)(s1,s2,sd1,sd2,b,d1,s3,s4,pd2,hr), \ - __FILE__,__LINE__,2, \ - &((hr)->hProcess),"hProcess", \ - &((hr)->hThread),"hThread")) -#define CreateProcessW(s1,s2,sd1,sd2,b,d1,s3,s4,pd2,hr) \ - ((BOOL)apr_dbg_log("CreateProcessW", \ - (HANDLE)(CreateProcessW)(s1,s2,sd1,sd2,b,d1,s3,s4,pd2,hr), \ - __FILE__,__LINE__,2, \ - &((hr)->hProcess),"hProcess", \ - &((hr)->hThread),"hThread")) - -#define CreateSemaphoreA(sd,d1,d2,nm) apr_dbg_rv(CreateSemaphoreA,(sd,d1,d2,nm)) -#define CreateSemaphoreW(sd,d1,d2,nm) apr_dbg_rv(CreateSemaphoreW,(sd,d1,d2,nm)) - -#define CreateThread(sd,d1,fn,pv,d2,pd3) apr_dbg_rv(CreateThread,(sd,d1,fn,pv,d2,pd3)) - -#define DeregisterEventSource(h) \ - ((BOOL)apr_dbg_log("DeregisterEventSource", \ - (HANDLE)(DeregisterEventSource)(h), \ - __FILE__,__LINE__,1, \ - &(h),"")) - -#define DuplicateHandle(h1,h2,h3,ph4,d1,b,d2) \ - ((BOOL)apr_dbg_log("DuplicateHandle", \ - (HANDLE)(DuplicateHandle)(h1,h2,h3,ph4,d1,b,d2), \ - __FILE__,__LINE__,2, \ - (ph4),((h3)==GetCurrentProcess()) \ - ? "Target" : "EXTERN Target", \ - &(h2),((h1)==GetCurrentProcess()) \ - ? "Source" : "EXTERN Source")) - -#define GetCurrentProcess() \ - (apr_dbg_log("GetCurrentProcess", \ - (GetCurrentProcess)(),__FILE__,__LINE__,0)) - -#define GetCurrentThread() \ - (apr_dbg_log("GetCurrentThread", \ - (GetCurrentThread)(),__FILE__,__LINE__,0)) - -#define GetModuleHandleA(nm) apr_dbg_rv(GetModuleHandleA,(nm)) -#define GetModuleHandleW(nm) apr_dbg_rv(GetModuleHandleW,(nm)) - -#define GetStdHandle(d) apr_dbg_rv(GetStdHandle,(d)) - -#define LoadLibraryA(nm) apr_dbg_rv(LoadLibraryA,(nm)) -#define LoadLibraryW(nm) apr_dbg_rv(LoadLibraryW,(nm)) - -#define LoadLibraryExA(nm,h,d) apr_dbg_rv(LoadLibraryExA,(nm,h,d)) -#define LoadLibraryExW(nm,h,d) apr_dbg_rv(LoadLibraryExW,(nm,h,d)) - -#define OpenEventA(d,b,nm) apr_dbg_rv(OpenEventA,(d,b,nm)) -#define OpenEventW(d,b,nm) apr_dbg_rv(OpenEventW,(d,b,nm)) - -#define OpenFileMappingA(d,b,nm) apr_dbg_rv(OpenFileMappingA,(d,b,nm)) -#define OpenFileMappingW(d,b,nm) apr_dbg_rv(OpenFileMappingW,(d,b,nm)) - -#define RegisterEventSourceA(s1,s2) apr_dbg_rv(RegisterEventSourceA,(s1,s2)) -#define RegisterEventSourceW(s1,s2) apr_dbg_rv(RegisterEventSourceW,(s1,s2)) - -#define SetEvent(h) \ - ((BOOL)apr_dbg_log("SetEvent", \ - (HANDLE)(SetEvent)(h), \ - __FILE__,__LINE__,1, \ - &(h),"")) - -#define SetStdHandle(d,h) \ - ((BOOL)apr_dbg_log("SetStdHandle", \ - (HANDLE)(SetStdHandle)(d,h), \ - __FILE__,__LINE__,1,&(h),"")) - -#define socket(i1,i2,i3) \ - ((SOCKET)apr_dbg_log("socket", \ - (HANDLE)(socket)(i1,i2,i3), \ - __FILE__,__LINE__,0)) - -#define WaitForSingleObject(h,d) \ - ((DWORD)apr_dbg_log("WaitForSingleObject", \ - (HANDLE)(WaitForSingleObject)(h,d), \ - __FILE__,__LINE__,1,&(h),"Signaled")) - -#define WaitForSingleObjectEx(h,d,b) \ - ((DWORD)apr_dbg_log("WaitForSingleObjectEx", \ - (HANDLE)(WaitForSingleObjectEx)(h,d,b), \ - __FILE__,__LINE__,1,&(h),"Signaled")) - -#define WaitForMultipleObjects(d1,ah,b,d2) \ - ((DWORD)apr_dbg_log("WaitForMultipleObjects", \ - (HANDLE)(WaitForMultipleObjects)(d1,ah,b,d2), \ - __FILE__,__LINE__,1,ah,"Signaled")) - -#define WaitForMultipleObjectsEx(d1,ah,b1,d2,b2) \ - ((DWORD)apr_dbg_log("WaitForMultipleObjectsEx", \ - (HANDLE)(WaitForMultipleObjectsEx)(d1,ah,b1,d2,b2), \ - __FILE__,__LINE__,1,ah,"Signaled")) - -#define WSASocketA(i1,i2,i3,pi,g,dw) \ - ((SOCKET)apr_dbg_log("WSASocketA", \ - (HANDLE)(WSASocketA)(i1,i2,i3,pi,g,dw), \ - __FILE__,__LINE__,0)) - -#define WSASocketW(i1,i2,i3,pi,g,dw) \ - ((SOCKET)apr_dbg_log("WSASocketW", \ - (HANDLE)(WSASocketW)(i1,i2,i3,pi,g,dw), \ - __FILE__,__LINE__,0)) - -#define closesocket(sh) \ - ((int)apr_dbg_log("closesocket", \ - (HANDLE)(closesocket)(sh), \ - __FILE__,__LINE__,1,&(sh),"")) - -#define _beginthread(fn,d,pv) \ - ((unsigned long)apr_dbg_log("_beginthread", \ - (HANDLE)(_beginthread)(fn,d,pv), \ - __FILE__,__LINE__,0)) - -#define _beginthreadex(sd,d1,fn,pv,d2,pd3) \ - ((unsigned long)apr_dbg_log("_beginthreadex", \ - (HANDLE)(_beginthreadex)(sd,d1,fn,pv,d2,pd3), \ - __FILE__,__LINE__,0)) - -#ifdef __cplusplus -} -#endif - -#endif /* !defined(APR_DBG_WIN32_HANDLES_H) */ diff --git a/libs/apr/include/arch/win32/apr_private.h b/libs/apr/include/arch/win32/apr_private.h deleted file mode 100644 index e2738891..00000000 --- a/libs/apr/include/arch/win32/apr_private.h +++ /dev/null @@ -1,173 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Note: - * This is the windows specific autoconf-like config file - * which unix would create at build time. - */ - -#ifdef WIN32 - -#ifndef APR_PRIVATE_H -#define APR_PRIVATE_H - -/* Include the public APR symbols, include our idea of the 'right' - * subset of the Windows.h header. This saves us repetition. - */ -#include "apr.h" - -/* - * Add a _very_few_ declarations missing from the restricted set of headers - * (If this list becomes extensive, re-enable the required headers above!) - * winsock headers were excluded by WIN32_LEAN_AND_MEAN, so include them now - */ -#ifndef SW_HIDE -#define SW_HIDE 0 -#endif - -/* For the misc.h late-loaded dynamic symbols, we need some obscure types - * Avoid dragging in wtypes.h unless it's absolutely necessary [generally - * not with APR itself, until some GUI-related security is introduced.] - */ -#ifndef _WIN32_WCE -#define HAVE_ACLAPI 1 -#ifdef __wtypes_h__ -#include -#else -#define __wtypes_h__ -#include -#undef __wtypes_h__ -#endif -#else -#define HAVE_ACLAPI 0 -#endif - -#if APR_HAVE_SYS_TYPES_H -#include -#endif -#if APR_HAVE_STDDEF_H -#include -#endif -#include -#if APR_HAVE_TIME_H -#include -#endif - -/* Use this section to define all of the HAVE_FOO_H - * that are required to build properly. - */ -#define HAVE_LIMITS_H 1 -#define HAVE_MALLOC_H 1 -#define HAVE_SIGNAL_H 1 -/* #define HAVE_STDDEF_H 1 why not? */ -#define HAVE_STDLIB_H 1 - -#define HAVE_STRICMP 1 -#define HAVE_STRNICMP 1 -#define HAVE_STRDUP 1 -#define HAVE_STRSTR 1 -#define HAVE_MEMCHR 1 - -#define SIGHUP 1 -/* 2 is used for SIGINT on windows */ -#define SIGQUIT 3 -/* 4 is used for SIGILL on windows */ -#define SIGTRAP 5 -#define SIGIOT 6 -#define SIGBUS 7 -/* 8 is used for SIGFPE on windows */ -#define SIGKILL 9 -#define SIGUSR1 10 -/* 11 is used for SIGSEGV on windows */ -#define SIGUSR2 12 -#define SIGPIPE 13 -#define SIGALRM 14 -/* 15 is used for SIGTERM on windows */ -#define SIGSTKFLT 16 -#define SIGCHLD 17 -#define SIGCONT 18 -#define SIGSTOP 19 -#define SIGTSTP 20 -/* 21 is used for SIGBREAK on windows */ -/* 22 is used for SIGABRT on windows */ -#define SIGTTIN 23 -#define SIGTTOU 24 -#define SIGURG 25 -#define SIGXCPU 26 -#define SIGXFSZ 27 -#define SIGVTALRM 28 -#define SIGPROF 29 -#define SIGWINCH 30 -#define SIGIO 31 - -/* APR COMPATABILITY FUNCTIONS - * This section should be used to define functions and - * macros which are need to make Windows features look - * like POSIX features. - */ -typedef void (Sigfunc)(int); - -#define sleep(t) Sleep((t) * 1000) - -#define SIZEOF_SHORT 2 -#define SIZEOF_INT 4 -#define SIZEOF_LONGLONG 8 -#define SIZEOF_CHAR 1 -#define SIZEOF_SSIZE_T SIZEOF_INT - -unsigned __stdcall SignalHandling(void *); -int thread_ready(void); - -#if !APR_HAVE_ERRNO_H -APR_DECLARE_DATA int errno; -#define ENOSPC 1 -#endif - -#if APR_HAVE_IPV6 -#define HAVE_GETADDRINFO 1 -#define HAVE_GETNAMEINFO 1 -#endif - -/* MSVC 7.0 introduced _strtoi64 */ -#if _MSC_VER >= 1300 && _INTEGRAL_MAX_BITS >= 64 && !defined(_WIN32_WCE) -#define APR_INT64_STRFN _strtoi64 -#endif - -#if APR_HAS_LARGE_FILES -#ifdef APR_INT64_STRFN -#define APR_OFF_T_STRFN APR_INT64_STRFN -#else -#define APR_OFF_T_STRFN apr_strtoi64 -#endif -#else -#if defined(_WIN32_WCE) -#define APR_OFF_T_STRFN strtol -#else -#define APR_OFF_T_STRFN strtoi -#endif -#endif - -/* used to check for DWORD overflow in 64bit compiles */ -#define APR_DWORD_MAX 0xFFFFFFFFUL - -/* - * Include common private declarations. - */ -#include "../apr_private_common.h" - -#endif /*APR_PRIVATE_H*/ -#endif /*WIN32*/ diff --git a/libs/apr/libapr.dep b/libs/apr/libapr.dep deleted file mode 100644 index 3efb8ec1..00000000 --- a/libs/apr/libapr.dep +++ /dev/null @@ -1,561 +0,0 @@ -# Microsoft Developer Studio Generated Dependency File, included by libapr.mak - -.\atomic\win32\apr_atomic.c : \ - ".\include\apr_atomic.h"\ - - -.\dso\win32\dso.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_dso.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\win32\buffer.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\unix\copy.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\win32\dir.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_atime.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\unix\fileacc.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\win32\filedup.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_inherit.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\win32\filepath.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\unix\filepath_util.c : \ - ".\include\apr_strings.h"\ - - -.\file_io\win32\filestat.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_atime.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\win32\filesys.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\win32\flock.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\unix\fullrw.c : \ - - -.\file_io\unix\mktemp.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_inherit.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\win32\open.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_inherit.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\win32\pipe.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\win32\readwrite.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_atime.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\win32\seek.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\file_io\unix\tempdir.c : \ - ".\include\apr_env.h"\ - ".\include\apr_strings.h"\ - - -.\locks\win32\proc_mutex.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_proc_mutex.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\locks\win32\thread_cond.c : \ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\apr_thread_cond.h"\ - ".\include\arch\win32\apr_arch_thread_cond.h"\ - ".\include\arch\win32\apr_arch_thread_mutex.h"\ - - -.\locks\win32\thread_mutex.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_thread_mutex.h"\ - - -.\locks\win32\thread_rwlock.c : \ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\apr_thread_rwlock.h"\ - ".\include\arch\win32\apr_arch_thread_rwlock.h"\ - - -.\memory\unix\apr_pools.c : \ - ".\include\apr_atomic.h"\ - ".\include\apr_env.h"\ - ".\include\apr_hash.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - - -.\misc\win32\charset.c : \ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - - -.\misc\win32\env.c : \ - ".\include\apr_env.h"\ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\misc\unix\errorcodes.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - - -.\misc\unix\getopt.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - - -.\misc\win32\internal.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\misc\win32\misc.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - ".\include\arch\win32\apr_dbg_win32_handles.h"\ - - -.\misc\unix\otherchild.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_threadproc.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\misc\win32\rand.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_portable.h"\ - - -.\misc\win32\start.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_signal.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_threadproc.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\misc\win32\utf8.c : \ - ".\include\apr_lib.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\misc\unix\version.c : \ - ".\include\apr_version.h"\ - - -.\mmap\unix\common.c : \ - ".\include\apr_mmap.h"\ - - -.\mmap\win32\mmap.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_mmap.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\network_io\unix\inet_ntop.c : \ - ".\include\apr_poll.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_networkio.h"\ - - -.\network_io\unix\inet_pton.c : \ - ".\include\apr_poll.h"\ - ".\include\arch\win32\apr_arch_networkio.h"\ - - -.\network_io\unix\multicast.c : \ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_support.h"\ - ".\include\arch\win32\apr_arch_inherit.h"\ - ".\include\arch\win32\apr_arch_networkio.h"\ - - -.\network_io\win32\sendrecv.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_networkio.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\network_io\unix\sockaddr.c : \ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_networkio.h"\ - - -.\network_io\unix\socket_util.c : \ - ".\include\apr_poll.h"\ - - -.\network_io\win32\sockets.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_inherit.h"\ - ".\include\arch\win32\apr_arch_networkio.h"\ - - -.\network_io\win32\sockopt.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_networkio.h"\ - - -.\passwd\apr_getpass.c : \ - ".\include\apr_lib.h"\ - ".\include\apr_strings.h"\ - - -.\poll\unix\poll.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\unix\apr_arch_poll_private.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_networkio.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\poll\unix\pollcb.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\unix\apr_arch_poll_private.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_networkio.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\poll\unix\pollset.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\unix\apr_arch_poll_private.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_inherit.h"\ - ".\include\arch\win32\apr_arch_networkio.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\poll\unix\select.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\unix\apr_arch_poll_private.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_networkio.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\random\unix\apr_random.c : \ - ".\include\apr_random.h"\ - - -.\random\unix\sha2.c : \ - ".\random\unix\sha2.h"\ - - -.\random\unix\sha2_glue.c : \ - ".\include\apr_random.h"\ - ".\random\unix\sha2.h"\ - - -.\shmem\win32\shm.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\strings\apr_cpystrn.c : \ - ".\include\apr_lib.h"\ - ".\include\apr_strings.h"\ - - -.\strings\apr_fnmatch.c : \ - ".\include\apr_fnmatch.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_strings.h"\ - - -.\strings\apr_snprintf.c : \ - ".\include\apr_lib.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - - -.\strings\apr_strings.c : \ - ".\include\apr_lib.h"\ - ".\include\apr_strings.h"\ - - -.\strings\apr_strnatcmp.c : \ - ".\include\apr_lib.h"\ - ".\include\apr_strings.h"\ - - -.\strings\apr_strtok.c : \ - ".\include\apr_strings.h"\ - - -.\tables\apr_hash.c : \ - ".\include\apr_hash.h"\ - - -.\tables\apr_tables.c : \ - ".\include\apr_lib.h"\ - ".\include\apr_strings.h"\ - - -.\threadproc\win32\proc.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_threadproc.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\threadproc\win32\signals.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_signal.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_threadproc.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -.\threadproc\win32\thread.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\win32\apr_arch_threadproc.h"\ - - -.\threadproc\win32\threadpriv.c : \ - ".\include\apr_lib.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\win32\apr_arch_threadproc.h"\ - - -.\time\win32\time.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_portable.h"\ - ".\include\arch\win32\apr_arch_atime.h"\ - - -.\time\win32\timestr.c : \ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_atime.h"\ - - -.\user\win32\groupinfo.c : \ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - - -.\user\win32\userinfo.c : \ - ".\include\apr_getopt.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_poll.h"\ - ".\include\apr_portable.h"\ - ".\include\apr_strings.h"\ - ".\include\arch\win32\apr_arch_file_io.h"\ - ".\include\arch\win32\apr_arch_utf8.h"\ - - -!IF "$(CFG)" == "libapr - Win32 Release" - -!ELSEIF "$(CFG)" == "libapr - Win32 Debug" - -!ELSEIF "$(CFG)" == "libapr - Win32 Release9x" - -!ELSEIF "$(CFG)" == "libapr - Win32 Debug9x" - -!ELSEIF "$(CFG)" == "libapr - x64 Release" - -!ELSEIF "$(CFG)" == "libapr - x64 Debug" - -!ENDIF - -.\libapr.rc : \ - ".\include\apr_version.h"\ - diff --git a/libs/apr/libapr.dsp b/libs/apr/libapr.dsp deleted file mode 100644 index b1783bf3..00000000 --- a/libs/apr/libapr.dsp +++ /dev/null @@ -1,873 +0,0 @@ -# Microsoft Developer Studio Project File - Name="libapr" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=libapr - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "libapr.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "libapr.mak" CFG="libapr - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "libapr - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libapr - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libapr - Win32 Release9x" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libapr - Win32 Debug9x" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libapr - x64 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libapr - x64 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "libapr - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MD /W3 /Zi /O2 /Oy- /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "NDEBUG" /D "APR_DECLARE_EXPORT" /D "WIN32" /D "WINNT" /D "_WINDOWS" /Fo"$(INTDIR)\" /Fd"$(INTDIR)\libapr_src" /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /i "./include" /d "NDEBUG" /d "APR_VERSION_ONLY" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib ole32.lib shell32.lib rpcrt4.lib /nologo /base:"0x6EEC0000" /subsystem:windows /dll /incremental:no /debug /opt:ref -# ADD LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib ole32.lib shell32.lib rpcrt4.lib /nologo /base:"0x6EEC0000" /subsystem:windows /dll /incremental:no /debug /out:"Release\libapr-1.dll" /pdb:"Release\libapr-1.pdb" /implib:"Release\libapr-1.lib" /MACHINE:X86 /opt:ref -# Begin Special Build Tool -TargetPath=Release\libapr-1.dll -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2 -# End Special Build Tool - -!ELSEIF "$(CFG)" == "libapr - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MDd /W3 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /EHsc /c -# ADD CPP /nologo /MDd /W3 /Zi /Od /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "_DEBUG" /D "APR_DECLARE_EXPORT" /D "WIN32" /D "WINNT" /D "_WINDOWS" /Fo"$(INTDIR)\" /Fd"$(INTDIR)\libapr_src" /FD /EHsc /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /i "./include" /d "_DEBUG" /d "APR_VERSION_ONLY" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib ole32.lib shell32.lib rpcrt4.lib /nologo /base:"0x6EEC0000" /subsystem:windows /dll /incremental:no /debug -# ADD LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib ole32.lib shell32.lib rpcrt4.lib /nologo /base:"0x6EEC0000" /subsystem:windows /dll /incremental:no /debug /out:"Debug\libapr-1.dll" /pdb:"Debug\libapr-1.pdb" /implib:"Debug\libapr-1.lib" /MACHINE:X86 -# Begin Special Build Tool -TargetPath=Debug\libapr-1.dll -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2 -# End Special Build Tool - -!ELSEIF "$(CFG)" == "libapr - Win32 Release9x" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "9x\Release" -# PROP BASE Intermediate_Dir "9x\Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "9x\Release" -# PROP Intermediate_Dir "9x\Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MD /W3 /Zi /O2 /Oy- /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "NDEBUG" /D "APR_DECLARE_EXPORT" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\" /Fd"$(INTDIR)\libapr_src" /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /i "./include" /d "NDEBUG" /d "APR_VERSION_ONLY" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib ole32.lib shell32.lib rpcrt4.lib /nologo /base:"0x6EEC0000" /subsystem:windows /dll /incremental:no /debug /opt:ref -# ADD LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib ole32.lib shell32.lib rpcrt4.lib /nologo /base:"0x6EEC0000" /subsystem:windows /dll /incremental:no /debug /out:"9x\Release\libapr-1.dll" /pdb:"9x\Release\libapr-1.pdb" /implib:"9x\Release\libapr-1.lib" /MACHINE:X86 /opt:ref -# Begin Special Build Tool -TargetPath=9x\Release\libapr.dll -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2 -# End Special Build Tool - -!ELSEIF "$(CFG)" == "libapr - Win32 Debug9x" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "9x\Debug" -# PROP BASE Intermediate_Dir "9x\Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "9x\Debug" -# PROP Intermediate_Dir "9x\Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MDd /W3 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /EHsc /c -# ADD CPP /nologo /MDd /W3 /Zi /Od /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "_DEBUG" /D "APR_DECLARE_EXPORT" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\" /Fd"$(INTDIR)\libapr_src" /FD /EHsc /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /i "./include" /d "_DEBUG" /d "APR_VERSION_ONLY" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib ole32.lib shell32.lib rpcrt4.lib /nologo /base:"0x6EEC0000" /subsystem:windows /dll /incremental:no /debug -# ADD LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib ole32.lib shell32.lib rpcrt4.lib /nologo /base:"0x6EEC0000" /subsystem:windows /dll /incremental:no /debug /out:"9x\Debug\libapr-1.dll" /pdb:"9x\Debug\libapr-1.pdb" /implib:"9x\Debug\libapr-1.lib" /MACHINE:X86 -# Begin Special Build Tool -TargetPath=9x\Debug\libapr-1.dll -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2 -# End Special Build Tool - -!ELSEIF "$(CFG)" == "libapr - x64 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "x64\Release" -# PROP BASE Intermediate_Dir "x64\Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "x64\Release" -# PROP Intermediate_Dir "x64\Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MD /W3 /Zi /O2 /Oy- /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "NDEBUG" /D "APR_DECLARE_EXPORT" /D "WIN32" /D "WINNT" /D "_WINDOWS" /Fo"$(INTDIR)\" /Fd"$(INTDIR)\libapr_src" /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /i "./include" /d "NDEBUG" /d "APR_VERSION_ONLY" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib ole32.lib shell32.lib rpcrt4.lib /nologo /base:"0x6EEC0000" /subsystem:windows /dll /incremental:no /debug /opt:ref -# ADD LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib ole32.lib shell32.lib rpcrt4.lib /nologo /base:"0x6EEC0000" /subsystem:windows /dll /incremental:no /debug /out:"x64\Release\libapr-1.dll" /pdb:"x64\Release\libapr-1.pdb" /implib:"x64\Release\libapr-1.lib" /MACHINE:X64 /opt:ref -# Begin Special Build Tool -TargetPath=x64\Release\libapr-1.dll -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2 -# End Special Build Tool - -!ELSEIF "$(CFG)" == "libapr - x64 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "x64\Debug" -# PROP BASE Intermediate_Dir "x64\Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "x64\Debug" -# PROP Intermediate_Dir "x64\Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MDd /W3 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /EHsc /c -# ADD CPP /nologo /MDd /W3 /Zi /Od /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "_DEBUG" /D "APR_DECLARE_EXPORT" /D "WIN32" /D "WINNT" /D "_WINDOWS" /Fo"$(INTDIR)\" /Fd"$(INTDIR)\libapr_src" /FD /EHsc /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /i "./include" /d "_DEBUG" /d "APR_VERSION_ONLY" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib ole32.lib shell32.lib rpcrt4.lib /nologo /base:"0x6EEC0000" /subsystem:windows /dll /incremental:no /debug -# ADD LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib ole32.lib shell32.lib rpcrt4.lib /nologo /base:"0x6EEC0000" /subsystem:windows /dll /incremental:no /debug /out:"x64\Debug\libapr-1.dll" /pdb:"x64\Debug\libapr-1.pdb" /implib:"x64\Debug\libapr-1.lib" /MACHINE:X64 -# Begin Special Build Tool -TargetPath=x64\Debug\libapr-1.dll -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2 -# End Special Build Tool - -!ENDIF - -# Begin Target - -# Name "libapr - Win32 Release" -# Name "libapr - Win32 Debug" -# Name "libapr - Win32 Release9x" -# Name "libapr - Win32 Debug9x" -# Name "libapr - x64 Release" -# Name "libapr - x64 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter ".c" -# Begin Group "atomic" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\atomic\win32\apr_atomic.c -# End Source File -# End Group -# Begin Group "dso" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\dso\win32\dso.c -# End Source File -# End Group -# Begin Group "file_io" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\file_io\win32\buffer.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\unix\copy.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\win32\dir.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\unix\fileacc.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\win32\filedup.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\win32\filepath.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\unix\filepath_util.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\win32\filestat.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\win32\filesys.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\win32\flock.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\unix\fullrw.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\unix\mktemp.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\win32\open.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\win32\pipe.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\win32\readwrite.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\win32\seek.c -# End Source File -# Begin Source File - -SOURCE=.\file_io\unix\tempdir.c -# End Source File -# End Group -# Begin Group "locks" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\locks\win32\proc_mutex.c -# End Source File -# Begin Source File - -SOURCE=.\locks\win32\thread_cond.c -# End Source File -# Begin Source File - -SOURCE=.\locks\win32\thread_mutex.c -# End Source File -# Begin Source File - -SOURCE=.\locks\win32\thread_rwlock.c -# End Source File -# End Group -# Begin Group "memory" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\memory\unix\apr_pools.c -# End Source File -# End Group -# Begin Group "misc" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\misc\win32\apr_app.c -# PROP Exclude_From_Build 1 -# End Source File -# Begin Source File - -SOURCE=.\misc\win32\charset.c -# End Source File -# Begin Source File - -SOURCE=.\misc\win32\env.c -# End Source File -# Begin Source File - -SOURCE=.\misc\unix\errorcodes.c -# End Source File -# Begin Source File - -SOURCE=.\misc\unix\getopt.c -# End Source File -# Begin Source File - -SOURCE=.\misc\win32\internal.c -# End Source File -# Begin Source File - -SOURCE=.\misc\win32\misc.c -# End Source File -# Begin Source File - -SOURCE=.\misc\unix\otherchild.c -# End Source File -# Begin Source File - -SOURCE=.\misc\win32\rand.c -# End Source File -# Begin Source File - -SOURCE=.\misc\win32\start.c -# End Source File -# Begin Source File - -SOURCE=.\misc\win32\utf8.c -# End Source File -# Begin Source File - -SOURCE=.\misc\unix\version.c -# End Source File -# End Group -# Begin Group "mmap" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\mmap\unix\common.c -# End Source File -# Begin Source File - -SOURCE=.\mmap\win32\mmap.c -# End Source File -# End Group -# Begin Group "network_io" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\network_io\unix\inet_ntop.c -# End Source File -# Begin Source File - -SOURCE=.\network_io\unix\inet_pton.c -# End Source File -# Begin Source File - -SOURCE=.\network_io\unix\multicast.c -# End Source File -# Begin Source File - -SOURCE=.\network_io\win32\sendrecv.c -# End Source File -# Begin Source File - -SOURCE=.\network_io\unix\sockaddr.c -# End Source File -# Begin Source File - -SOURCE=.\network_io\win32\sockets.c -# End Source File -# Begin Source File - -SOURCE=.\network_io\unix\socket_util.c -# End Source File -# Begin Source File - -SOURCE=.\network_io\win32\sockopt.c -# End Source File -# End Group -# Begin Group "passwd" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\passwd\apr_getpass.c -# End Source File -# End Group -# Begin Group "poll" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\poll\unix\poll.c -# End Source File -# Begin Source File - -SOURCE=.\poll\unix\pollcb.c -# End Source File -# Begin Source File - -SOURCE=.\poll\unix\pollset.c -# End Source File -# Begin Source File - -SOURCE=.\poll\unix\select.c -# End Source File -# End Group -# Begin Group "random" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\random\unix\apr_random.c -# End Source File -# Begin Source File - -SOURCE=.\random\unix\sha2.c -# End Source File -# Begin Source File - -SOURCE=.\random\unix\sha2_glue.c -# End Source File -# End Group -# Begin Group "shmem" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\shmem\win32\shm.c -# End Source File -# End Group -# Begin Group "strings" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\strings\apr_cpystrn.c -# End Source File -# Begin Source File - -SOURCE=.\strings\apr_fnmatch.c -# End Source File -# Begin Source File - -SOURCE=.\strings\apr_snprintf.c -# End Source File -# Begin Source File - -SOURCE=.\strings\apr_strings.c -# End Source File -# Begin Source File - -SOURCE=.\strings\apr_strnatcmp.c -# End Source File -# Begin Source File - -SOURCE=.\strings\apr_strtok.c -# End Source File -# End Group -# Begin Group "tables" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\tables\apr_hash.c -# End Source File -# Begin Source File - -SOURCE=.\tables\apr_tables.c -# End Source File -# End Group -# Begin Group "threadproc" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\threadproc\win32\proc.c -# End Source File -# Begin Source File - -SOURCE=.\threadproc\win32\signals.c -# End Source File -# Begin Source File - -SOURCE=.\threadproc\win32\thread.c -# End Source File -# Begin Source File - -SOURCE=.\threadproc\win32\threadpriv.c -# End Source File -# End Group -# Begin Group "time" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\time\win32\time.c -# End Source File -# Begin Source File - -SOURCE=.\time\win32\timestr.c -# End Source File -# End Group -# Begin Group "user" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\user\win32\groupinfo.c -# End Source File -# Begin Source File - -SOURCE=.\user\win32\userinfo.c -# End Source File -# End Group -# End Group -# Begin Group "Private Header Files" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\include\arch\win32\apr_arch_atime.h -# End Source File -# Begin Source File - -SOURCE=.\include\arch\win32\apr_arch_dso.h -# End Source File -# Begin Source File - -SOURCE=.\include\arch\win32\apr_arch_file_io.h -# End Source File -# Begin Source File - -SOURCE=.\include\arch\win32\apr_arch_inherit.h -# End Source File -# Begin Source File - -SOURCE=.\include\arch\win32\apr_arch_misc.h -# End Source File -# Begin Source File - -SOURCE=.\include\arch\win32\apr_arch_networkio.h -# End Source File -# Begin Source File - -SOURCE=.\include\arch\win32\apr_arch_thread_mutex.h -# End Source File -# Begin Source File - -SOURCE=.\include\arch\win32\apr_arch_thread_rwlock.h -# End Source File -# Begin Source File - -SOURCE=.\include\arch\win32\apr_arch_threadproc.h -# End Source File -# Begin Source File - -SOURCE=.\include\arch\win32\apr_arch_utf8.h -# End Source File -# Begin Source File - -SOURCE=.\include\arch\win32\apr_private.h -# End Source File -# Begin Source File - -SOURCE=.\include\arch\apr_private_common.h -# End Source File -# End Group -# Begin Group "Public Header Files" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\include\apr.h.in -# PROP Exclude_From_Build 1 -# End Source File -# Begin Source File - -SOURCE=.\include\apr.hnw -# PROP Exclude_From_Build 1 -# End Source File -# Begin Source File - -SOURCE=.\include\apr.hw - -!IF "$(CFG)" == "libapr - Win32 Release" - -# Begin Custom Build - Creating apr.h from apr.hw -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apr.hw > .\include\apr.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "libapr - Win32 Debug" - -# Begin Custom Build - Creating apr.h from apr.hw -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apr.hw > .\include\apr.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "libapr - Win32 Release9x" - -# Begin Custom Build - Creating apr.h from apr.hw -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apr.hw > .\include\apr.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "libapr - Win32 Debug9x" - -# Begin Custom Build - Creating apr.h from apr.hw -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apr.hw > .\include\apr.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "libapr - x64 Release" - -# Begin Custom Build - Creating apr.h from apr.hw -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apr.hw > .\include\apr.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "libapr - x64 Debug" - -# Begin Custom Build - Creating apr.h from apr.hw -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apr.hw > .\include\apr.h - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\include\apr_allocator.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_atomic.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_dso.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_env.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_errno.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_file_info.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_file_io.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_fnmatch.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_general.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_getopt.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_global_mutex.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_hash.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_inherit.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_lib.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_mmap.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_network_io.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_poll.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_pools.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_portable.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_proc_mutex.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_random.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_ring.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_shm.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_signal.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_strings.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_support.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_tables.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_thread_cond.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_thread_mutex.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_thread_proc.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_thread_rwlock.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_time.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_user.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_version.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_want.h -# End Source File -# End Group -# Begin Source File - -SOURCE=.\libapr.rc -# End Source File -# End Target -# End Project diff --git a/libs/apr/libapr.mak b/libs/apr/libapr.mak deleted file mode 100644 index fef3a482..00000000 --- a/libs/apr/libapr.mak +++ /dev/null @@ -1,1917 +0,0 @@ -# Microsoft Developer Studio Generated NMAKE File, Based on libapr.dsp -!IF "$(CFG)" == "" -CFG=libapr - Win32 Release -!MESSAGE No configuration specified. Defaulting to libapr - Win32 Release. -!ENDIF - -!IF "$(CFG)" != "libapr - Win32 Release" && "$(CFG)" != "libapr - Win32 Debug" && "$(CFG)" != "libapr - Win32 Release9x" && "$(CFG)" != "libapr - Win32 Debug9x" && "$(CFG)" != "libapr - x64 Release" && "$(CFG)" != "libapr - x64 Debug" -!MESSAGE Invalid configuration "$(CFG)" specified. -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "libapr.mak" CFG="libapr - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "libapr - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libapr - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libapr - Win32 Release9x" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libapr - Win32 Debug9x" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libapr - x64 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libapr - x64 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE -!ERROR An invalid configuration is specified. -!ENDIF - -!IF "$(OS)" == "Windows_NT" -NULL= -!ELSE -NULL=nul -!ENDIF - -!IF "$(CFG)" == "libapr - Win32 Release" - -OUTDIR=.\Release -INTDIR=.\Release -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep -# Begin Custom Macros -OutDir=.\Release -# End Custom Macros - -ALL : "$(OUTDIR)\libapr-1.dll" "$(DS_POSTBUILD_DEP)" - - -CLEAN : - -@erase "$(INTDIR)\apr_atomic.obj" - -@erase "$(INTDIR)\apr_cpystrn.obj" - -@erase "$(INTDIR)\apr_fnmatch.obj" - -@erase "$(INTDIR)\apr_getpass.obj" - -@erase "$(INTDIR)\apr_hash.obj" - -@erase "$(INTDIR)\apr_pools.obj" - -@erase "$(INTDIR)\apr_random.obj" - -@erase "$(INTDIR)\apr_snprintf.obj" - -@erase "$(INTDIR)\apr_strings.obj" - -@erase "$(INTDIR)\apr_strnatcmp.obj" - -@erase "$(INTDIR)\apr_strtok.obj" - -@erase "$(INTDIR)\apr_tables.obj" - -@erase "$(INTDIR)\buffer.obj" - -@erase "$(INTDIR)\charset.obj" - -@erase "$(INTDIR)\common.obj" - -@erase "$(INTDIR)\copy.obj" - -@erase "$(INTDIR)\dir.obj" - -@erase "$(INTDIR)\dso.obj" - -@erase "$(INTDIR)\env.obj" - -@erase "$(INTDIR)\errorcodes.obj" - -@erase "$(INTDIR)\fileacc.obj" - -@erase "$(INTDIR)\filedup.obj" - -@erase "$(INTDIR)\filepath.obj" - -@erase "$(INTDIR)\filepath_util.obj" - -@erase "$(INTDIR)\filestat.obj" - -@erase "$(INTDIR)\filesys.obj" - -@erase "$(INTDIR)\flock.obj" - -@erase "$(INTDIR)\fullrw.obj" - -@erase "$(INTDIR)\getopt.obj" - -@erase "$(INTDIR)\groupinfo.obj" - -@erase "$(INTDIR)\inet_ntop.obj" - -@erase "$(INTDIR)\inet_pton.obj" - -@erase "$(INTDIR)\internal.obj" - -@erase "$(INTDIR)\libapr.res" - -@erase "$(INTDIR)\libapr_src.idb" - -@erase "$(INTDIR)\libapr_src.pdb" - -@erase "$(INTDIR)\misc.obj" - -@erase "$(INTDIR)\mktemp.obj" - -@erase "$(INTDIR)\mmap.obj" - -@erase "$(INTDIR)\multicast.obj" - -@erase "$(INTDIR)\open.obj" - -@erase "$(INTDIR)\otherchild.obj" - -@erase "$(INTDIR)\pipe.obj" - -@erase "$(INTDIR)\poll.obj" - -@erase "$(INTDIR)\pollcb.obj" - -@erase "$(INTDIR)\pollset.obj" - -@erase "$(INTDIR)\proc.obj" - -@erase "$(INTDIR)\proc_mutex.obj" - -@erase "$(INTDIR)\rand.obj" - -@erase "$(INTDIR)\readwrite.obj" - -@erase "$(INTDIR)\seek.obj" - -@erase "$(INTDIR)\select.obj" - -@erase "$(INTDIR)\sendrecv.obj" - -@erase "$(INTDIR)\sha2.obj" - -@erase "$(INTDIR)\sha2_glue.obj" - -@erase "$(INTDIR)\shm.obj" - -@erase "$(INTDIR)\signals.obj" - -@erase "$(INTDIR)\sockaddr.obj" - -@erase "$(INTDIR)\socket_util.obj" - -@erase "$(INTDIR)\sockets.obj" - -@erase "$(INTDIR)\sockopt.obj" - -@erase "$(INTDIR)\start.obj" - -@erase "$(INTDIR)\tempdir.obj" - -@erase "$(INTDIR)\thread.obj" - -@erase "$(INTDIR)\thread_cond.obj" - -@erase "$(INTDIR)\thread_mutex.obj" - -@erase "$(INTDIR)\thread_rwlock.obj" - -@erase "$(INTDIR)\threadpriv.obj" - -@erase "$(INTDIR)\time.obj" - -@erase "$(INTDIR)\timestr.obj" - -@erase "$(INTDIR)\userinfo.obj" - -@erase "$(INTDIR)\utf8.obj" - -@erase "$(INTDIR)\version.obj" - -@erase "$(OUTDIR)\libapr-1.dll" - -@erase "$(OUTDIR)\libapr-1.exp" - -@erase "$(OUTDIR)\libapr-1.lib" - -@erase "$(OUTDIR)\libapr-1.pdb" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "NDEBUG" /D "APR_DECLARE_EXPORT" /D "WIN32" /D "WINNT" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\libapr_src" /FD /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -MTL=midl.exe -MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" -RSC=rc.exe -RSC_PROJ=/l 0x409 /fo"$(INTDIR)\libapr.res" /i "./include" /d "NDEBUG" /d "APR_VERSION_ONLY" -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\libapr.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -LINK32_FLAGS=kernel32.lib advapi32.lib ws2_32.lib mswsock.lib ole32.lib shell32.lib rpcrt4.lib /nologo /base:"0x6EEC0000" /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\libapr-1.pdb" /debug /out:"$(OUTDIR)\libapr-1.dll" /implib:"$(OUTDIR)\libapr-1.lib" /MACHINE:X86 /opt:ref -LINK32_OBJS= \ - "$(INTDIR)\apr_atomic.obj" \ - "$(INTDIR)\dso.obj" \ - "$(INTDIR)\buffer.obj" \ - "$(INTDIR)\copy.obj" \ - "$(INTDIR)\dir.obj" \ - "$(INTDIR)\fileacc.obj" \ - "$(INTDIR)\filedup.obj" \ - "$(INTDIR)\filepath.obj" \ - "$(INTDIR)\filepath_util.obj" \ - "$(INTDIR)\filestat.obj" \ - "$(INTDIR)\filesys.obj" \ - "$(INTDIR)\flock.obj" \ - "$(INTDIR)\fullrw.obj" \ - "$(INTDIR)\mktemp.obj" \ - "$(INTDIR)\open.obj" \ - "$(INTDIR)\pipe.obj" \ - "$(INTDIR)\readwrite.obj" \ - "$(INTDIR)\seek.obj" \ - "$(INTDIR)\tempdir.obj" \ - "$(INTDIR)\proc_mutex.obj" \ - "$(INTDIR)\thread_cond.obj" \ - "$(INTDIR)\thread_mutex.obj" \ - "$(INTDIR)\thread_rwlock.obj" \ - "$(INTDIR)\apr_pools.obj" \ - "$(INTDIR)\charset.obj" \ - "$(INTDIR)\env.obj" \ - "$(INTDIR)\errorcodes.obj" \ - "$(INTDIR)\getopt.obj" \ - "$(INTDIR)\internal.obj" \ - "$(INTDIR)\misc.obj" \ - "$(INTDIR)\otherchild.obj" \ - "$(INTDIR)\rand.obj" \ - "$(INTDIR)\start.obj" \ - "$(INTDIR)\utf8.obj" \ - "$(INTDIR)\version.obj" \ - "$(INTDIR)\common.obj" \ - "$(INTDIR)\mmap.obj" \ - "$(INTDIR)\inet_ntop.obj" \ - "$(INTDIR)\inet_pton.obj" \ - "$(INTDIR)\multicast.obj" \ - "$(INTDIR)\sendrecv.obj" \ - "$(INTDIR)\sockaddr.obj" \ - "$(INTDIR)\sockets.obj" \ - "$(INTDIR)\socket_util.obj" \ - "$(INTDIR)\sockopt.obj" \ - "$(INTDIR)\apr_getpass.obj" \ - "$(INTDIR)\poll.obj" \ - "$(INTDIR)\pollcb.obj" \ - "$(INTDIR)\pollset.obj" \ - "$(INTDIR)\select.obj" \ - "$(INTDIR)\apr_random.obj" \ - "$(INTDIR)\sha2.obj" \ - "$(INTDIR)\sha2_glue.obj" \ - "$(INTDIR)\shm.obj" \ - "$(INTDIR)\apr_cpystrn.obj" \ - "$(INTDIR)\apr_fnmatch.obj" \ - "$(INTDIR)\apr_snprintf.obj" \ - "$(INTDIR)\apr_strings.obj" \ - "$(INTDIR)\apr_strnatcmp.obj" \ - "$(INTDIR)\apr_strtok.obj" \ - "$(INTDIR)\apr_hash.obj" \ - "$(INTDIR)\apr_tables.obj" \ - "$(INTDIR)\proc.obj" \ - "$(INTDIR)\signals.obj" \ - "$(INTDIR)\thread.obj" \ - "$(INTDIR)\threadpriv.obj" \ - "$(INTDIR)\time.obj" \ - "$(INTDIR)\timestr.obj" \ - "$(INTDIR)\groupinfo.obj" \ - "$(INTDIR)\userinfo.obj" \ - "$(INTDIR)\libapr.res" - -"$(OUTDIR)\libapr-1.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -TargetPath=.\Release\libapr-1.dll -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep - -# Begin Custom Macros -OutDir=.\Release -# End Custom Macros - -"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\libapr-1.dll" - if exist .\Release\libapr-1.dll.manifest mt.exe -manifest .\Release\libapr-1.dll.manifest -outputresource:.\Release\libapr-1.dll;2 - echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" - -!ELSEIF "$(CFG)" == "libapr - Win32 Debug" - -OUTDIR=.\Debug -INTDIR=.\Debug -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep -# Begin Custom Macros -OutDir=.\Debug -# End Custom Macros - -ALL : ".\include\apr.h" "$(OUTDIR)\libapr-1.dll" "$(DS_POSTBUILD_DEP)" - - -CLEAN : - -@erase "$(INTDIR)\apr_atomic.obj" - -@erase "$(INTDIR)\apr_cpystrn.obj" - -@erase "$(INTDIR)\apr_fnmatch.obj" - -@erase "$(INTDIR)\apr_getpass.obj" - -@erase "$(INTDIR)\apr_hash.obj" - -@erase "$(INTDIR)\apr_pools.obj" - -@erase "$(INTDIR)\apr_random.obj" - -@erase "$(INTDIR)\apr_snprintf.obj" - -@erase "$(INTDIR)\apr_strings.obj" - -@erase "$(INTDIR)\apr_strnatcmp.obj" - -@erase "$(INTDIR)\apr_strtok.obj" - -@erase "$(INTDIR)\apr_tables.obj" - -@erase "$(INTDIR)\buffer.obj" - -@erase "$(INTDIR)\charset.obj" - -@erase "$(INTDIR)\common.obj" - -@erase "$(INTDIR)\copy.obj" - -@erase "$(INTDIR)\dir.obj" - -@erase "$(INTDIR)\dso.obj" - -@erase "$(INTDIR)\env.obj" - -@erase "$(INTDIR)\errorcodes.obj" - -@erase "$(INTDIR)\fileacc.obj" - -@erase "$(INTDIR)\filedup.obj" - -@erase "$(INTDIR)\filepath.obj" - -@erase "$(INTDIR)\filepath_util.obj" - -@erase "$(INTDIR)\filestat.obj" - -@erase "$(INTDIR)\filesys.obj" - -@erase "$(INTDIR)\flock.obj" - -@erase "$(INTDIR)\fullrw.obj" - -@erase "$(INTDIR)\getopt.obj" - -@erase "$(INTDIR)\groupinfo.obj" - -@erase "$(INTDIR)\inet_ntop.obj" - -@erase "$(INTDIR)\inet_pton.obj" - -@erase "$(INTDIR)\internal.obj" - -@erase "$(INTDIR)\libapr.res" - -@erase "$(INTDIR)\libapr_src.idb" - -@erase "$(INTDIR)\libapr_src.pdb" - -@erase "$(INTDIR)\misc.obj" - -@erase "$(INTDIR)\mktemp.obj" - -@erase "$(INTDIR)\mmap.obj" - -@erase "$(INTDIR)\multicast.obj" - -@erase "$(INTDIR)\open.obj" - -@erase "$(INTDIR)\otherchild.obj" - -@erase "$(INTDIR)\pipe.obj" - -@erase "$(INTDIR)\poll.obj" - -@erase "$(INTDIR)\pollcb.obj" - -@erase "$(INTDIR)\pollset.obj" - -@erase "$(INTDIR)\proc.obj" - -@erase "$(INTDIR)\proc_mutex.obj" - -@erase "$(INTDIR)\rand.obj" - -@erase "$(INTDIR)\readwrite.obj" - -@erase "$(INTDIR)\seek.obj" - -@erase "$(INTDIR)\select.obj" - -@erase "$(INTDIR)\sendrecv.obj" - -@erase "$(INTDIR)\sha2.obj" - -@erase "$(INTDIR)\sha2_glue.obj" - -@erase "$(INTDIR)\shm.obj" - -@erase "$(INTDIR)\signals.obj" - -@erase "$(INTDIR)\sockaddr.obj" - -@erase "$(INTDIR)\socket_util.obj" - -@erase "$(INTDIR)\sockets.obj" - -@erase "$(INTDIR)\sockopt.obj" - -@erase "$(INTDIR)\start.obj" - -@erase "$(INTDIR)\tempdir.obj" - -@erase "$(INTDIR)\thread.obj" - -@erase "$(INTDIR)\thread_cond.obj" - -@erase "$(INTDIR)\thread_mutex.obj" - -@erase "$(INTDIR)\thread_rwlock.obj" - -@erase "$(INTDIR)\threadpriv.obj" - -@erase "$(INTDIR)\time.obj" - -@erase "$(INTDIR)\timestr.obj" - -@erase "$(INTDIR)\userinfo.obj" - -@erase "$(INTDIR)\utf8.obj" - -@erase "$(INTDIR)\version.obj" - -@erase "$(OUTDIR)\libapr-1.dll" - -@erase "$(OUTDIR)\libapr-1.exp" - -@erase "$(OUTDIR)\libapr-1.lib" - -@erase "$(OUTDIR)\libapr-1.pdb" - -@erase ".\include\apr.h" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "_DEBUG" /D "APR_DECLARE_EXPORT" /D "WIN32" /D "WINNT" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\libapr_src" /FD /EHsc /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -MTL=midl.exe -MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" -RSC=rc.exe -RSC_PROJ=/l 0x409 /fo"$(INTDIR)\libapr.res" /i "./include" /d "_DEBUG" /d "APR_VERSION_ONLY" -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\libapr.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -LINK32_FLAGS=kernel32.lib advapi32.lib ws2_32.lib mswsock.lib ole32.lib shell32.lib rpcrt4.lib /nologo /base:"0x6EEC0000" /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\libapr-1.pdb" /debug /out:"$(OUTDIR)\libapr-1.dll" /implib:"$(OUTDIR)\libapr-1.lib" /MACHINE:X86 -LINK32_OBJS= \ - "$(INTDIR)\apr_atomic.obj" \ - "$(INTDIR)\dso.obj" \ - "$(INTDIR)\buffer.obj" \ - "$(INTDIR)\copy.obj" \ - "$(INTDIR)\dir.obj" \ - "$(INTDIR)\fileacc.obj" \ - "$(INTDIR)\filedup.obj" \ - "$(INTDIR)\filepath.obj" \ - "$(INTDIR)\filepath_util.obj" \ - "$(INTDIR)\filestat.obj" \ - "$(INTDIR)\filesys.obj" \ - "$(INTDIR)\flock.obj" \ - "$(INTDIR)\fullrw.obj" \ - "$(INTDIR)\mktemp.obj" \ - "$(INTDIR)\open.obj" \ - "$(INTDIR)\pipe.obj" \ - "$(INTDIR)\readwrite.obj" \ - "$(INTDIR)\seek.obj" \ - "$(INTDIR)\tempdir.obj" \ - "$(INTDIR)\proc_mutex.obj" \ - "$(INTDIR)\thread_cond.obj" \ - "$(INTDIR)\thread_mutex.obj" \ - "$(INTDIR)\thread_rwlock.obj" \ - "$(INTDIR)\apr_pools.obj" \ - "$(INTDIR)\charset.obj" \ - "$(INTDIR)\env.obj" \ - "$(INTDIR)\errorcodes.obj" \ - "$(INTDIR)\getopt.obj" \ - "$(INTDIR)\internal.obj" \ - "$(INTDIR)\misc.obj" \ - "$(INTDIR)\otherchild.obj" \ - "$(INTDIR)\rand.obj" \ - "$(INTDIR)\start.obj" \ - "$(INTDIR)\utf8.obj" \ - "$(INTDIR)\version.obj" \ - "$(INTDIR)\common.obj" \ - "$(INTDIR)\mmap.obj" \ - "$(INTDIR)\inet_ntop.obj" \ - "$(INTDIR)\inet_pton.obj" \ - "$(INTDIR)\multicast.obj" \ - "$(INTDIR)\sendrecv.obj" \ - "$(INTDIR)\sockaddr.obj" \ - "$(INTDIR)\sockets.obj" \ - "$(INTDIR)\socket_util.obj" \ - "$(INTDIR)\sockopt.obj" \ - "$(INTDIR)\apr_getpass.obj" \ - "$(INTDIR)\poll.obj" \ - "$(INTDIR)\pollcb.obj" \ - "$(INTDIR)\pollset.obj" \ - "$(INTDIR)\select.obj" \ - "$(INTDIR)\apr_random.obj" \ - "$(INTDIR)\sha2.obj" \ - "$(INTDIR)\sha2_glue.obj" \ - "$(INTDIR)\shm.obj" \ - "$(INTDIR)\apr_cpystrn.obj" \ - "$(INTDIR)\apr_fnmatch.obj" \ - "$(INTDIR)\apr_snprintf.obj" \ - "$(INTDIR)\apr_strings.obj" \ - "$(INTDIR)\apr_strnatcmp.obj" \ - "$(INTDIR)\apr_strtok.obj" \ - "$(INTDIR)\apr_hash.obj" \ - "$(INTDIR)\apr_tables.obj" \ - "$(INTDIR)\proc.obj" \ - "$(INTDIR)\signals.obj" \ - "$(INTDIR)\thread.obj" \ - "$(INTDIR)\threadpriv.obj" \ - "$(INTDIR)\time.obj" \ - "$(INTDIR)\timestr.obj" \ - "$(INTDIR)\groupinfo.obj" \ - "$(INTDIR)\userinfo.obj" \ - "$(INTDIR)\libapr.res" - -"$(OUTDIR)\libapr-1.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -TargetPath=.\Debug\libapr-1.dll -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep - -# Begin Custom Macros -OutDir=.\Debug -# End Custom Macros - -"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\libapr-1.dll" - if exist .\Debug\libapr-1.dll.manifest mt.exe -manifest .\Debug\libapr-1.dll.manifest -outputresource:.\Debug\libapr-1.dll;2 - echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" - -!ELSEIF "$(CFG)" == "libapr - Win32 Release9x" - -OUTDIR=.\9x\Release -INTDIR=.\9x\Release -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep -# Begin Custom Macros -OutDir=.\9x\Release -# End Custom Macros - -ALL : ".\include\apr.h" "$(OUTDIR)\libapr-1.dll" "$(DS_POSTBUILD_DEP)" - - -CLEAN : - -@erase "$(INTDIR)\apr_atomic.obj" - -@erase "$(INTDIR)\apr_cpystrn.obj" - -@erase "$(INTDIR)\apr_fnmatch.obj" - -@erase "$(INTDIR)\apr_getpass.obj" - -@erase "$(INTDIR)\apr_hash.obj" - -@erase "$(INTDIR)\apr_pools.obj" - -@erase "$(INTDIR)\apr_random.obj" - -@erase "$(INTDIR)\apr_snprintf.obj" - -@erase "$(INTDIR)\apr_strings.obj" - -@erase "$(INTDIR)\apr_strnatcmp.obj" - -@erase "$(INTDIR)\apr_strtok.obj" - -@erase "$(INTDIR)\apr_tables.obj" - -@erase "$(INTDIR)\buffer.obj" - -@erase "$(INTDIR)\charset.obj" - -@erase "$(INTDIR)\common.obj" - -@erase "$(INTDIR)\copy.obj" - -@erase "$(INTDIR)\dir.obj" - -@erase "$(INTDIR)\dso.obj" - -@erase "$(INTDIR)\env.obj" - -@erase "$(INTDIR)\errorcodes.obj" - -@erase "$(INTDIR)\fileacc.obj" - -@erase "$(INTDIR)\filedup.obj" - -@erase "$(INTDIR)\filepath.obj" - -@erase "$(INTDIR)\filepath_util.obj" - -@erase "$(INTDIR)\filestat.obj" - -@erase "$(INTDIR)\filesys.obj" - -@erase "$(INTDIR)\flock.obj" - -@erase "$(INTDIR)\fullrw.obj" - -@erase "$(INTDIR)\getopt.obj" - -@erase "$(INTDIR)\groupinfo.obj" - -@erase "$(INTDIR)\inet_ntop.obj" - -@erase "$(INTDIR)\inet_pton.obj" - -@erase "$(INTDIR)\internal.obj" - -@erase "$(INTDIR)\libapr.res" - -@erase "$(INTDIR)\libapr_src.idb" - -@erase "$(INTDIR)\libapr_src.pdb" - -@erase "$(INTDIR)\misc.obj" - -@erase "$(INTDIR)\mktemp.obj" - -@erase "$(INTDIR)\mmap.obj" - -@erase "$(INTDIR)\multicast.obj" - -@erase "$(INTDIR)\open.obj" - -@erase "$(INTDIR)\otherchild.obj" - -@erase "$(INTDIR)\pipe.obj" - -@erase "$(INTDIR)\poll.obj" - -@erase "$(INTDIR)\pollcb.obj" - -@erase "$(INTDIR)\pollset.obj" - -@erase "$(INTDIR)\proc.obj" - -@erase "$(INTDIR)\proc_mutex.obj" - -@erase "$(INTDIR)\rand.obj" - -@erase "$(INTDIR)\readwrite.obj" - -@erase "$(INTDIR)\seek.obj" - -@erase "$(INTDIR)\select.obj" - -@erase "$(INTDIR)\sendrecv.obj" - -@erase "$(INTDIR)\sha2.obj" - -@erase "$(INTDIR)\sha2_glue.obj" - -@erase "$(INTDIR)\shm.obj" - -@erase "$(INTDIR)\signals.obj" - -@erase "$(INTDIR)\sockaddr.obj" - -@erase "$(INTDIR)\socket_util.obj" - -@erase "$(INTDIR)\sockets.obj" - -@erase "$(INTDIR)\sockopt.obj" - -@erase "$(INTDIR)\start.obj" - -@erase "$(INTDIR)\tempdir.obj" - -@erase "$(INTDIR)\thread.obj" - -@erase "$(INTDIR)\thread_cond.obj" - -@erase "$(INTDIR)\thread_mutex.obj" - -@erase "$(INTDIR)\thread_rwlock.obj" - -@erase "$(INTDIR)\threadpriv.obj" - -@erase "$(INTDIR)\time.obj" - -@erase "$(INTDIR)\timestr.obj" - -@erase "$(INTDIR)\userinfo.obj" - -@erase "$(INTDIR)\utf8.obj" - -@erase "$(INTDIR)\version.obj" - -@erase "$(OUTDIR)\libapr-1.dll" - -@erase "$(OUTDIR)\libapr-1.exp" - -@erase "$(OUTDIR)\libapr-1.lib" - -@erase "$(OUTDIR)\libapr-1.pdb" - -@erase ".\include\apr.h" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "NDEBUG" /D "APR_DECLARE_EXPORT" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\libapr_src" /FD /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -MTL=midl.exe -MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" -RSC=rc.exe -RSC_PROJ=/l 0x409 /fo"$(INTDIR)\libapr.res" /i "./include" /d "NDEBUG" /d "APR_VERSION_ONLY" -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\libapr.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -LINK32_FLAGS=kernel32.lib advapi32.lib ws2_32.lib mswsock.lib ole32.lib shell32.lib rpcrt4.lib /nologo /base:"0x6EEC0000" /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\libapr-1.pdb" /debug /out:"$(OUTDIR)\libapr-1.dll" /implib:"$(OUTDIR)\libapr-1.lib" /MACHINE:X86 /opt:ref -LINK32_OBJS= \ - "$(INTDIR)\apr_atomic.obj" \ - "$(INTDIR)\dso.obj" \ - "$(INTDIR)\buffer.obj" \ - "$(INTDIR)\copy.obj" \ - "$(INTDIR)\dir.obj" \ - "$(INTDIR)\fileacc.obj" \ - "$(INTDIR)\filedup.obj" \ - "$(INTDIR)\filepath.obj" \ - "$(INTDIR)\filepath_util.obj" \ - "$(INTDIR)\filestat.obj" \ - "$(INTDIR)\filesys.obj" \ - "$(INTDIR)\flock.obj" \ - "$(INTDIR)\fullrw.obj" \ - "$(INTDIR)\mktemp.obj" \ - "$(INTDIR)\open.obj" \ - "$(INTDIR)\pipe.obj" \ - "$(INTDIR)\readwrite.obj" \ - "$(INTDIR)\seek.obj" \ - "$(INTDIR)\tempdir.obj" \ - "$(INTDIR)\proc_mutex.obj" \ - "$(INTDIR)\thread_cond.obj" \ - "$(INTDIR)\thread_mutex.obj" \ - "$(INTDIR)\thread_rwlock.obj" \ - "$(INTDIR)\apr_pools.obj" \ - "$(INTDIR)\charset.obj" \ - "$(INTDIR)\env.obj" \ - "$(INTDIR)\errorcodes.obj" \ - "$(INTDIR)\getopt.obj" \ - "$(INTDIR)\internal.obj" \ - "$(INTDIR)\misc.obj" \ - "$(INTDIR)\otherchild.obj" \ - "$(INTDIR)\rand.obj" \ - "$(INTDIR)\start.obj" \ - "$(INTDIR)\utf8.obj" \ - "$(INTDIR)\version.obj" \ - "$(INTDIR)\common.obj" \ - "$(INTDIR)\mmap.obj" \ - "$(INTDIR)\inet_ntop.obj" \ - "$(INTDIR)\inet_pton.obj" \ - "$(INTDIR)\multicast.obj" \ - "$(INTDIR)\sendrecv.obj" \ - "$(INTDIR)\sockaddr.obj" \ - "$(INTDIR)\sockets.obj" \ - "$(INTDIR)\socket_util.obj" \ - "$(INTDIR)\sockopt.obj" \ - "$(INTDIR)\apr_getpass.obj" \ - "$(INTDIR)\poll.obj" \ - "$(INTDIR)\pollcb.obj" \ - "$(INTDIR)\pollset.obj" \ - "$(INTDIR)\select.obj" \ - "$(INTDIR)\apr_random.obj" \ - "$(INTDIR)\sha2.obj" \ - "$(INTDIR)\sha2_glue.obj" \ - "$(INTDIR)\shm.obj" \ - "$(INTDIR)\apr_cpystrn.obj" \ - "$(INTDIR)\apr_fnmatch.obj" \ - "$(INTDIR)\apr_snprintf.obj" \ - "$(INTDIR)\apr_strings.obj" \ - "$(INTDIR)\apr_strnatcmp.obj" \ - "$(INTDIR)\apr_strtok.obj" \ - "$(INTDIR)\apr_hash.obj" \ - "$(INTDIR)\apr_tables.obj" \ - "$(INTDIR)\proc.obj" \ - "$(INTDIR)\signals.obj" \ - "$(INTDIR)\thread.obj" \ - "$(INTDIR)\threadpriv.obj" \ - "$(INTDIR)\time.obj" \ - "$(INTDIR)\timestr.obj" \ - "$(INTDIR)\groupinfo.obj" \ - "$(INTDIR)\userinfo.obj" \ - "$(INTDIR)\libapr.res" - -"$(OUTDIR)\libapr-1.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -TargetPath=.\9x\Release\libapr-1.dll -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep - -# Begin Custom Macros -OutDir=.\9x\Release -# End Custom Macros - -"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\libapr-1.dll" - if exist .\9x\Release\libapr-1.dll.manifest mt.exe -manifest .\9x\Release\libapr-1.dll.manifest -outputresource:.\9x\Release\libapr-1.dll;2 - echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" - -!ELSEIF "$(CFG)" == "libapr - Win32 Debug9x" - -OUTDIR=.\9x\Debug -INTDIR=.\9x\Debug -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep -# Begin Custom Macros -OutDir=.\9x\Debug -# End Custom Macros - -ALL : ".\include\apr.h" "$(OUTDIR)\libapr-1.dll" "$(DS_POSTBUILD_DEP)" - - -CLEAN : - -@erase "$(INTDIR)\apr_atomic.obj" - -@erase "$(INTDIR)\apr_cpystrn.obj" - -@erase "$(INTDIR)\apr_fnmatch.obj" - -@erase "$(INTDIR)\apr_getpass.obj" - -@erase "$(INTDIR)\apr_hash.obj" - -@erase "$(INTDIR)\apr_pools.obj" - -@erase "$(INTDIR)\apr_random.obj" - -@erase "$(INTDIR)\apr_snprintf.obj" - -@erase "$(INTDIR)\apr_strings.obj" - -@erase "$(INTDIR)\apr_strnatcmp.obj" - -@erase "$(INTDIR)\apr_strtok.obj" - -@erase "$(INTDIR)\apr_tables.obj" - -@erase "$(INTDIR)\buffer.obj" - -@erase "$(INTDIR)\charset.obj" - -@erase "$(INTDIR)\common.obj" - -@erase "$(INTDIR)\copy.obj" - -@erase "$(INTDIR)\dir.obj" - -@erase "$(INTDIR)\dso.obj" - -@erase "$(INTDIR)\env.obj" - -@erase "$(INTDIR)\errorcodes.obj" - -@erase "$(INTDIR)\fileacc.obj" - -@erase "$(INTDIR)\filedup.obj" - -@erase "$(INTDIR)\filepath.obj" - -@erase "$(INTDIR)\filepath_util.obj" - -@erase "$(INTDIR)\filestat.obj" - -@erase "$(INTDIR)\filesys.obj" - -@erase "$(INTDIR)\flock.obj" - -@erase "$(INTDIR)\fullrw.obj" - -@erase "$(INTDIR)\getopt.obj" - -@erase "$(INTDIR)\groupinfo.obj" - -@erase "$(INTDIR)\inet_ntop.obj" - -@erase "$(INTDIR)\inet_pton.obj" - -@erase "$(INTDIR)\internal.obj" - -@erase "$(INTDIR)\libapr.res" - -@erase "$(INTDIR)\libapr_src.idb" - -@erase "$(INTDIR)\libapr_src.pdb" - -@erase "$(INTDIR)\misc.obj" - -@erase "$(INTDIR)\mktemp.obj" - -@erase "$(INTDIR)\mmap.obj" - -@erase "$(INTDIR)\multicast.obj" - -@erase "$(INTDIR)\open.obj" - -@erase "$(INTDIR)\otherchild.obj" - -@erase "$(INTDIR)\pipe.obj" - -@erase "$(INTDIR)\poll.obj" - -@erase "$(INTDIR)\pollcb.obj" - -@erase "$(INTDIR)\pollset.obj" - -@erase "$(INTDIR)\proc.obj" - -@erase "$(INTDIR)\proc_mutex.obj" - -@erase "$(INTDIR)\rand.obj" - -@erase "$(INTDIR)\readwrite.obj" - -@erase "$(INTDIR)\seek.obj" - -@erase "$(INTDIR)\select.obj" - -@erase "$(INTDIR)\sendrecv.obj" - -@erase "$(INTDIR)\sha2.obj" - -@erase "$(INTDIR)\sha2_glue.obj" - -@erase "$(INTDIR)\shm.obj" - -@erase "$(INTDIR)\signals.obj" - -@erase "$(INTDIR)\sockaddr.obj" - -@erase "$(INTDIR)\socket_util.obj" - -@erase "$(INTDIR)\sockets.obj" - -@erase "$(INTDIR)\sockopt.obj" - -@erase "$(INTDIR)\start.obj" - -@erase "$(INTDIR)\tempdir.obj" - -@erase "$(INTDIR)\thread.obj" - -@erase "$(INTDIR)\thread_cond.obj" - -@erase "$(INTDIR)\thread_mutex.obj" - -@erase "$(INTDIR)\thread_rwlock.obj" - -@erase "$(INTDIR)\threadpriv.obj" - -@erase "$(INTDIR)\time.obj" - -@erase "$(INTDIR)\timestr.obj" - -@erase "$(INTDIR)\userinfo.obj" - -@erase "$(INTDIR)\utf8.obj" - -@erase "$(INTDIR)\version.obj" - -@erase "$(OUTDIR)\libapr-1.dll" - -@erase "$(OUTDIR)\libapr-1.exp" - -@erase "$(OUTDIR)\libapr-1.lib" - -@erase "$(OUTDIR)\libapr-1.pdb" - -@erase ".\include\apr.h" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "_DEBUG" /D "APR_DECLARE_EXPORT" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\libapr_src" /FD /EHsc /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -MTL=midl.exe -MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" -RSC=rc.exe -RSC_PROJ=/l 0x409 /fo"$(INTDIR)\libapr.res" /i "./include" /d "_DEBUG" /d "APR_VERSION_ONLY" -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\libapr.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -LINK32_FLAGS=kernel32.lib advapi32.lib ws2_32.lib mswsock.lib ole32.lib shell32.lib rpcrt4.lib /nologo /base:"0x6EEC0000" /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\libapr-1.pdb" /debug /out:"$(OUTDIR)\libapr-1.dll" /implib:"$(OUTDIR)\libapr-1.lib" /MACHINE:X86 -LINK32_OBJS= \ - "$(INTDIR)\apr_atomic.obj" \ - "$(INTDIR)\dso.obj" \ - "$(INTDIR)\buffer.obj" \ - "$(INTDIR)\copy.obj" \ - "$(INTDIR)\dir.obj" \ - "$(INTDIR)\fileacc.obj" \ - "$(INTDIR)\filedup.obj" \ - "$(INTDIR)\filepath.obj" \ - "$(INTDIR)\filepath_util.obj" \ - "$(INTDIR)\filestat.obj" \ - "$(INTDIR)\filesys.obj" \ - "$(INTDIR)\flock.obj" \ - "$(INTDIR)\fullrw.obj" \ - "$(INTDIR)\mktemp.obj" \ - "$(INTDIR)\open.obj" \ - "$(INTDIR)\pipe.obj" \ - "$(INTDIR)\readwrite.obj" \ - "$(INTDIR)\seek.obj" \ - "$(INTDIR)\tempdir.obj" \ - "$(INTDIR)\proc_mutex.obj" \ - "$(INTDIR)\thread_cond.obj" \ - "$(INTDIR)\thread_mutex.obj" \ - "$(INTDIR)\thread_rwlock.obj" \ - "$(INTDIR)\apr_pools.obj" \ - "$(INTDIR)\charset.obj" \ - "$(INTDIR)\env.obj" \ - "$(INTDIR)\errorcodes.obj" \ - "$(INTDIR)\getopt.obj" \ - "$(INTDIR)\internal.obj" \ - "$(INTDIR)\misc.obj" \ - "$(INTDIR)\otherchild.obj" \ - "$(INTDIR)\rand.obj" \ - "$(INTDIR)\start.obj" \ - "$(INTDIR)\utf8.obj" \ - "$(INTDIR)\version.obj" \ - "$(INTDIR)\common.obj" \ - "$(INTDIR)\mmap.obj" \ - "$(INTDIR)\inet_ntop.obj" \ - "$(INTDIR)\inet_pton.obj" \ - "$(INTDIR)\multicast.obj" \ - "$(INTDIR)\sendrecv.obj" \ - "$(INTDIR)\sockaddr.obj" \ - "$(INTDIR)\sockets.obj" \ - "$(INTDIR)\socket_util.obj" \ - "$(INTDIR)\sockopt.obj" \ - "$(INTDIR)\apr_getpass.obj" \ - "$(INTDIR)\poll.obj" \ - "$(INTDIR)\pollcb.obj" \ - "$(INTDIR)\pollset.obj" \ - "$(INTDIR)\select.obj" \ - "$(INTDIR)\apr_random.obj" \ - "$(INTDIR)\sha2.obj" \ - "$(INTDIR)\sha2_glue.obj" \ - "$(INTDIR)\shm.obj" \ - "$(INTDIR)\apr_cpystrn.obj" \ - "$(INTDIR)\apr_fnmatch.obj" \ - "$(INTDIR)\apr_snprintf.obj" \ - "$(INTDIR)\apr_strings.obj" \ - "$(INTDIR)\apr_strnatcmp.obj" \ - "$(INTDIR)\apr_strtok.obj" \ - "$(INTDIR)\apr_hash.obj" \ - "$(INTDIR)\apr_tables.obj" \ - "$(INTDIR)\proc.obj" \ - "$(INTDIR)\signals.obj" \ - "$(INTDIR)\thread.obj" \ - "$(INTDIR)\threadpriv.obj" \ - "$(INTDIR)\time.obj" \ - "$(INTDIR)\timestr.obj" \ - "$(INTDIR)\groupinfo.obj" \ - "$(INTDIR)\userinfo.obj" \ - "$(INTDIR)\libapr.res" - -"$(OUTDIR)\libapr-1.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -TargetPath=.\9x\Debug\libapr-1.dll -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep - -# Begin Custom Macros -OutDir=.\9x\Debug -# End Custom Macros - -"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\libapr-1.dll" - if exist .\9x\Debug\libapr-1.dll.manifest mt.exe -manifest .\9x\Debug\libapr-1.dll.manifest -outputresource:.\9x\Debug\libapr-1.dll;2 - echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" - -!ELSEIF "$(CFG)" == "libapr - x64 Release" - -OUTDIR=.\x64\Release -INTDIR=.\x64\Release -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep -# Begin Custom Macros -OutDir=.\x64\Release -# End Custom Macros - -ALL : ".\include\apr.h" "$(OUTDIR)\libapr-1.dll" "$(DS_POSTBUILD_DEP)" - - -CLEAN : - -@erase "$(INTDIR)\apr_atomic.obj" - -@erase "$(INTDIR)\apr_cpystrn.obj" - -@erase "$(INTDIR)\apr_fnmatch.obj" - -@erase "$(INTDIR)\apr_getpass.obj" - -@erase "$(INTDIR)\apr_hash.obj" - -@erase "$(INTDIR)\apr_pools.obj" - -@erase "$(INTDIR)\apr_random.obj" - -@erase "$(INTDIR)\apr_snprintf.obj" - -@erase "$(INTDIR)\apr_strings.obj" - -@erase "$(INTDIR)\apr_strnatcmp.obj" - -@erase "$(INTDIR)\apr_strtok.obj" - -@erase "$(INTDIR)\apr_tables.obj" - -@erase "$(INTDIR)\buffer.obj" - -@erase "$(INTDIR)\charset.obj" - -@erase "$(INTDIR)\common.obj" - -@erase "$(INTDIR)\copy.obj" - -@erase "$(INTDIR)\dir.obj" - -@erase "$(INTDIR)\dso.obj" - -@erase "$(INTDIR)\env.obj" - -@erase "$(INTDIR)\errorcodes.obj" - -@erase "$(INTDIR)\fileacc.obj" - -@erase "$(INTDIR)\filedup.obj" - -@erase "$(INTDIR)\filepath.obj" - -@erase "$(INTDIR)\filepath_util.obj" - -@erase "$(INTDIR)\filestat.obj" - -@erase "$(INTDIR)\filesys.obj" - -@erase "$(INTDIR)\flock.obj" - -@erase "$(INTDIR)\fullrw.obj" - -@erase "$(INTDIR)\getopt.obj" - -@erase "$(INTDIR)\groupinfo.obj" - -@erase "$(INTDIR)\inet_ntop.obj" - -@erase "$(INTDIR)\inet_pton.obj" - -@erase "$(INTDIR)\internal.obj" - -@erase "$(INTDIR)\libapr.res" - -@erase "$(INTDIR)\libapr_src.idb" - -@erase "$(INTDIR)\libapr_src.pdb" - -@erase "$(INTDIR)\misc.obj" - -@erase "$(INTDIR)\mktemp.obj" - -@erase "$(INTDIR)\mmap.obj" - -@erase "$(INTDIR)\multicast.obj" - -@erase "$(INTDIR)\open.obj" - -@erase "$(INTDIR)\otherchild.obj" - -@erase "$(INTDIR)\pipe.obj" - -@erase "$(INTDIR)\poll.obj" - -@erase "$(INTDIR)\pollcb.obj" - -@erase "$(INTDIR)\pollset.obj" - -@erase "$(INTDIR)\proc.obj" - -@erase "$(INTDIR)\proc_mutex.obj" - -@erase "$(INTDIR)\rand.obj" - -@erase "$(INTDIR)\readwrite.obj" - -@erase "$(INTDIR)\seek.obj" - -@erase "$(INTDIR)\select.obj" - -@erase "$(INTDIR)\sendrecv.obj" - -@erase "$(INTDIR)\sha2.obj" - -@erase "$(INTDIR)\sha2_glue.obj" - -@erase "$(INTDIR)\shm.obj" - -@erase "$(INTDIR)\signals.obj" - -@erase "$(INTDIR)\sockaddr.obj" - -@erase "$(INTDIR)\socket_util.obj" - -@erase "$(INTDIR)\sockets.obj" - -@erase "$(INTDIR)\sockopt.obj" - -@erase "$(INTDIR)\start.obj" - -@erase "$(INTDIR)\tempdir.obj" - -@erase "$(INTDIR)\thread.obj" - -@erase "$(INTDIR)\thread_cond.obj" - -@erase "$(INTDIR)\thread_mutex.obj" - -@erase "$(INTDIR)\thread_rwlock.obj" - -@erase "$(INTDIR)\threadpriv.obj" - -@erase "$(INTDIR)\time.obj" - -@erase "$(INTDIR)\timestr.obj" - -@erase "$(INTDIR)\userinfo.obj" - -@erase "$(INTDIR)\utf8.obj" - -@erase "$(INTDIR)\version.obj" - -@erase "$(OUTDIR)\libapr-1.dll" - -@erase "$(OUTDIR)\libapr-1.exp" - -@erase "$(OUTDIR)\libapr-1.lib" - -@erase "$(OUTDIR)\libapr-1.pdb" - -@erase ".\include\apr.h" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "NDEBUG" /D "APR_DECLARE_EXPORT" /D "WIN32" /D "WINNT" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\libapr_src" /FD /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -MTL=midl.exe -MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" -RSC=rc.exe -RSC_PROJ=/l 0x409 /fo"$(INTDIR)\libapr.res" /i "./include" /d "NDEBUG" /d "APR_VERSION_ONLY" -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\libapr.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -LINK32_FLAGS=kernel32.lib advapi32.lib ws2_32.lib mswsock.lib ole32.lib shell32.lib rpcrt4.lib /nologo /base:"0x6EEC0000" /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\libapr-1.pdb" /debug /out:"$(OUTDIR)\libapr-1.dll" /implib:"$(OUTDIR)\libapr-1.lib" /MACHINE:X64 /opt:ref -LINK32_OBJS= \ - "$(INTDIR)\apr_atomic.obj" \ - "$(INTDIR)\dso.obj" \ - "$(INTDIR)\buffer.obj" \ - "$(INTDIR)\copy.obj" \ - "$(INTDIR)\dir.obj" \ - "$(INTDIR)\fileacc.obj" \ - "$(INTDIR)\filedup.obj" \ - "$(INTDIR)\filepath.obj" \ - "$(INTDIR)\filepath_util.obj" \ - "$(INTDIR)\filestat.obj" \ - "$(INTDIR)\filesys.obj" \ - "$(INTDIR)\flock.obj" \ - "$(INTDIR)\fullrw.obj" \ - "$(INTDIR)\mktemp.obj" \ - "$(INTDIR)\open.obj" \ - "$(INTDIR)\pipe.obj" \ - "$(INTDIR)\readwrite.obj" \ - "$(INTDIR)\seek.obj" \ - "$(INTDIR)\tempdir.obj" \ - "$(INTDIR)\proc_mutex.obj" \ - "$(INTDIR)\thread_cond.obj" \ - "$(INTDIR)\thread_mutex.obj" \ - "$(INTDIR)\thread_rwlock.obj" \ - "$(INTDIR)\apr_pools.obj" \ - "$(INTDIR)\charset.obj" \ - "$(INTDIR)\env.obj" \ - "$(INTDIR)\errorcodes.obj" \ - "$(INTDIR)\getopt.obj" \ - "$(INTDIR)\internal.obj" \ - "$(INTDIR)\misc.obj" \ - "$(INTDIR)\otherchild.obj" \ - "$(INTDIR)\rand.obj" \ - "$(INTDIR)\start.obj" \ - "$(INTDIR)\utf8.obj" \ - "$(INTDIR)\version.obj" \ - "$(INTDIR)\common.obj" \ - "$(INTDIR)\mmap.obj" \ - "$(INTDIR)\inet_ntop.obj" \ - "$(INTDIR)\inet_pton.obj" \ - "$(INTDIR)\multicast.obj" \ - "$(INTDIR)\sendrecv.obj" \ - "$(INTDIR)\sockaddr.obj" \ - "$(INTDIR)\sockets.obj" \ - "$(INTDIR)\socket_util.obj" \ - "$(INTDIR)\sockopt.obj" \ - "$(INTDIR)\apr_getpass.obj" \ - "$(INTDIR)\poll.obj" \ - "$(INTDIR)\pollcb.obj" \ - "$(INTDIR)\pollset.obj" \ - "$(INTDIR)\select.obj" \ - "$(INTDIR)\apr_random.obj" \ - "$(INTDIR)\sha2.obj" \ - "$(INTDIR)\sha2_glue.obj" \ - "$(INTDIR)\shm.obj" \ - "$(INTDIR)\apr_cpystrn.obj" \ - "$(INTDIR)\apr_fnmatch.obj" \ - "$(INTDIR)\apr_snprintf.obj" \ - "$(INTDIR)\apr_strings.obj" \ - "$(INTDIR)\apr_strnatcmp.obj" \ - "$(INTDIR)\apr_strtok.obj" \ - "$(INTDIR)\apr_hash.obj" \ - "$(INTDIR)\apr_tables.obj" \ - "$(INTDIR)\proc.obj" \ - "$(INTDIR)\signals.obj" \ - "$(INTDIR)\thread.obj" \ - "$(INTDIR)\threadpriv.obj" \ - "$(INTDIR)\time.obj" \ - "$(INTDIR)\timestr.obj" \ - "$(INTDIR)\groupinfo.obj" \ - "$(INTDIR)\userinfo.obj" \ - "$(INTDIR)\libapr.res" - -"$(OUTDIR)\libapr-1.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -TargetPath=.\x64\Release\libapr-1.dll -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep - -# Begin Custom Macros -OutDir=.\x64\Release -# End Custom Macros - -"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\libapr-1.dll" - if exist .\x64\Release\libapr-1.dll.manifest mt.exe -manifest .\x64\Release\libapr-1.dll.manifest -outputresource:.\x64\Release\libapr-1.dll;2 - echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" - -!ELSEIF "$(CFG)" == "libapr - x64 Debug" - -OUTDIR=.\x64\Debug -INTDIR=.\x64\Debug -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep -# Begin Custom Macros -OutDir=.\x64\Debug -# End Custom Macros - -ALL : ".\include\apr.h" "$(OUTDIR)\libapr-1.dll" "$(DS_POSTBUILD_DEP)" - - -CLEAN : - -@erase "$(INTDIR)\apr_atomic.obj" - -@erase "$(INTDIR)\apr_cpystrn.obj" - -@erase "$(INTDIR)\apr_fnmatch.obj" - -@erase "$(INTDIR)\apr_getpass.obj" - -@erase "$(INTDIR)\apr_hash.obj" - -@erase "$(INTDIR)\apr_pools.obj" - -@erase "$(INTDIR)\apr_random.obj" - -@erase "$(INTDIR)\apr_snprintf.obj" - -@erase "$(INTDIR)\apr_strings.obj" - -@erase "$(INTDIR)\apr_strnatcmp.obj" - -@erase "$(INTDIR)\apr_strtok.obj" - -@erase "$(INTDIR)\apr_tables.obj" - -@erase "$(INTDIR)\buffer.obj" - -@erase "$(INTDIR)\charset.obj" - -@erase "$(INTDIR)\common.obj" - -@erase "$(INTDIR)\copy.obj" - -@erase "$(INTDIR)\dir.obj" - -@erase "$(INTDIR)\dso.obj" - -@erase "$(INTDIR)\env.obj" - -@erase "$(INTDIR)\errorcodes.obj" - -@erase "$(INTDIR)\fileacc.obj" - -@erase "$(INTDIR)\filedup.obj" - -@erase "$(INTDIR)\filepath.obj" - -@erase "$(INTDIR)\filepath_util.obj" - -@erase "$(INTDIR)\filestat.obj" - -@erase "$(INTDIR)\filesys.obj" - -@erase "$(INTDIR)\flock.obj" - -@erase "$(INTDIR)\fullrw.obj" - -@erase "$(INTDIR)\getopt.obj" - -@erase "$(INTDIR)\groupinfo.obj" - -@erase "$(INTDIR)\inet_ntop.obj" - -@erase "$(INTDIR)\inet_pton.obj" - -@erase "$(INTDIR)\internal.obj" - -@erase "$(INTDIR)\libapr.res" - -@erase "$(INTDIR)\libapr_src.idb" - -@erase "$(INTDIR)\libapr_src.pdb" - -@erase "$(INTDIR)\misc.obj" - -@erase "$(INTDIR)\mktemp.obj" - -@erase "$(INTDIR)\mmap.obj" - -@erase "$(INTDIR)\multicast.obj" - -@erase "$(INTDIR)\open.obj" - -@erase "$(INTDIR)\otherchild.obj" - -@erase "$(INTDIR)\pipe.obj" - -@erase "$(INTDIR)\poll.obj" - -@erase "$(INTDIR)\pollcb.obj" - -@erase "$(INTDIR)\pollset.obj" - -@erase "$(INTDIR)\proc.obj" - -@erase "$(INTDIR)\proc_mutex.obj" - -@erase "$(INTDIR)\rand.obj" - -@erase "$(INTDIR)\readwrite.obj" - -@erase "$(INTDIR)\seek.obj" - -@erase "$(INTDIR)\select.obj" - -@erase "$(INTDIR)\sendrecv.obj" - -@erase "$(INTDIR)\sha2.obj" - -@erase "$(INTDIR)\sha2_glue.obj" - -@erase "$(INTDIR)\shm.obj" - -@erase "$(INTDIR)\signals.obj" - -@erase "$(INTDIR)\sockaddr.obj" - -@erase "$(INTDIR)\socket_util.obj" - -@erase "$(INTDIR)\sockets.obj" - -@erase "$(INTDIR)\sockopt.obj" - -@erase "$(INTDIR)\start.obj" - -@erase "$(INTDIR)\tempdir.obj" - -@erase "$(INTDIR)\thread.obj" - -@erase "$(INTDIR)\thread_cond.obj" - -@erase "$(INTDIR)\thread_mutex.obj" - -@erase "$(INTDIR)\thread_rwlock.obj" - -@erase "$(INTDIR)\threadpriv.obj" - -@erase "$(INTDIR)\time.obj" - -@erase "$(INTDIR)\timestr.obj" - -@erase "$(INTDIR)\userinfo.obj" - -@erase "$(INTDIR)\utf8.obj" - -@erase "$(INTDIR)\version.obj" - -@erase "$(OUTDIR)\libapr-1.dll" - -@erase "$(OUTDIR)\libapr-1.exp" - -@erase "$(OUTDIR)\libapr-1.lib" - -@erase "$(OUTDIR)\libapr-1.pdb" - -@erase ".\include\apr.h" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "_DEBUG" /D "APR_DECLARE_EXPORT" /D "WIN32" /D "WINNT" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\libapr_src" /FD /EHsc /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -MTL=midl.exe -MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" -RSC=rc.exe -RSC_PROJ=/l 0x409 /fo"$(INTDIR)\libapr.res" /i "./include" /d "_DEBUG" /d "APR_VERSION_ONLY" -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\libapr.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -LINK32_FLAGS=kernel32.lib advapi32.lib ws2_32.lib mswsock.lib ole32.lib shell32.lib rpcrt4.lib /nologo /base:"0x6EEC0000" /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\libapr-1.pdb" /debug /out:"$(OUTDIR)\libapr-1.dll" /implib:"$(OUTDIR)\libapr-1.lib" /MACHINE:X64 -LINK32_OBJS= \ - "$(INTDIR)\apr_atomic.obj" \ - "$(INTDIR)\dso.obj" \ - "$(INTDIR)\buffer.obj" \ - "$(INTDIR)\copy.obj" \ - "$(INTDIR)\dir.obj" \ - "$(INTDIR)\fileacc.obj" \ - "$(INTDIR)\filedup.obj" \ - "$(INTDIR)\filepath.obj" \ - "$(INTDIR)\filepath_util.obj" \ - "$(INTDIR)\filestat.obj" \ - "$(INTDIR)\filesys.obj" \ - "$(INTDIR)\flock.obj" \ - "$(INTDIR)\fullrw.obj" \ - "$(INTDIR)\mktemp.obj" \ - "$(INTDIR)\open.obj" \ - "$(INTDIR)\pipe.obj" \ - "$(INTDIR)\readwrite.obj" \ - "$(INTDIR)\seek.obj" \ - "$(INTDIR)\tempdir.obj" \ - "$(INTDIR)\proc_mutex.obj" \ - "$(INTDIR)\thread_cond.obj" \ - "$(INTDIR)\thread_mutex.obj" \ - "$(INTDIR)\thread_rwlock.obj" \ - "$(INTDIR)\apr_pools.obj" \ - "$(INTDIR)\charset.obj" \ - "$(INTDIR)\env.obj" \ - "$(INTDIR)\errorcodes.obj" \ - "$(INTDIR)\getopt.obj" \ - "$(INTDIR)\internal.obj" \ - "$(INTDIR)\misc.obj" \ - "$(INTDIR)\otherchild.obj" \ - "$(INTDIR)\rand.obj" \ - "$(INTDIR)\start.obj" \ - "$(INTDIR)\utf8.obj" \ - "$(INTDIR)\version.obj" \ - "$(INTDIR)\common.obj" \ - "$(INTDIR)\mmap.obj" \ - "$(INTDIR)\inet_ntop.obj" \ - "$(INTDIR)\inet_pton.obj" \ - "$(INTDIR)\multicast.obj" \ - "$(INTDIR)\sendrecv.obj" \ - "$(INTDIR)\sockaddr.obj" \ - "$(INTDIR)\sockets.obj" \ - "$(INTDIR)\socket_util.obj" \ - "$(INTDIR)\sockopt.obj" \ - "$(INTDIR)\apr_getpass.obj" \ - "$(INTDIR)\poll.obj" \ - "$(INTDIR)\pollcb.obj" \ - "$(INTDIR)\pollset.obj" \ - "$(INTDIR)\select.obj" \ - "$(INTDIR)\apr_random.obj" \ - "$(INTDIR)\sha2.obj" \ - "$(INTDIR)\sha2_glue.obj" \ - "$(INTDIR)\shm.obj" \ - "$(INTDIR)\apr_cpystrn.obj" \ - "$(INTDIR)\apr_fnmatch.obj" \ - "$(INTDIR)\apr_snprintf.obj" \ - "$(INTDIR)\apr_strings.obj" \ - "$(INTDIR)\apr_strnatcmp.obj" \ - "$(INTDIR)\apr_strtok.obj" \ - "$(INTDIR)\apr_hash.obj" \ - "$(INTDIR)\apr_tables.obj" \ - "$(INTDIR)\proc.obj" \ - "$(INTDIR)\signals.obj" \ - "$(INTDIR)\thread.obj" \ - "$(INTDIR)\threadpriv.obj" \ - "$(INTDIR)\time.obj" \ - "$(INTDIR)\timestr.obj" \ - "$(INTDIR)\groupinfo.obj" \ - "$(INTDIR)\userinfo.obj" \ - "$(INTDIR)\libapr.res" - -"$(OUTDIR)\libapr-1.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -TargetPath=.\x64\Debug\libapr-1.dll -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep - -# Begin Custom Macros -OutDir=.\x64\Debug -# End Custom Macros - -"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\libapr-1.dll" - if exist .\x64\Debug\libapr-1.dll.manifest mt.exe -manifest .\x64\Debug\libapr-1.dll.manifest -outputresource:.\x64\Debug\libapr-1.dll;2 - echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" - -!ENDIF - - -!IF "$(NO_EXTERNAL_DEPS)" != "1" -!IF EXISTS("libapr.dep") -!INCLUDE "libapr.dep" -!ELSE -!MESSAGE Warning: cannot find "libapr.dep" -!ENDIF -!ENDIF - - -!IF "$(CFG)" == "libapr - Win32 Release" || "$(CFG)" == "libapr - Win32 Debug" || "$(CFG)" == "libapr - Win32 Release9x" || "$(CFG)" == "libapr - Win32 Debug9x" || "$(CFG)" == "libapr - x64 Release" || "$(CFG)" == "libapr - x64 Debug" -SOURCE=.\atomic\win32\apr_atomic.c - -"$(INTDIR)\apr_atomic.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\dso\win32\dso.c - -"$(INTDIR)\dso.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\win32\buffer.c - -"$(INTDIR)\buffer.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\unix\copy.c - -"$(INTDIR)\copy.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\win32\dir.c - -"$(INTDIR)\dir.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\unix\fileacc.c - -"$(INTDIR)\fileacc.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\win32\filedup.c - -"$(INTDIR)\filedup.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\win32\filepath.c - -"$(INTDIR)\filepath.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\unix\filepath_util.c - -"$(INTDIR)\filepath_util.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\win32\filestat.c - -"$(INTDIR)\filestat.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\win32\filesys.c - -"$(INTDIR)\filesys.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\win32\flock.c - -"$(INTDIR)\flock.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\unix\fullrw.c - -"$(INTDIR)\fullrw.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\unix\mktemp.c - -"$(INTDIR)\mktemp.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\win32\open.c - -"$(INTDIR)\open.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\win32\pipe.c - -"$(INTDIR)\pipe.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\win32\readwrite.c - -"$(INTDIR)\readwrite.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\win32\seek.c - -"$(INTDIR)\seek.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\file_io\unix\tempdir.c - -"$(INTDIR)\tempdir.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\locks\win32\proc_mutex.c - -"$(INTDIR)\proc_mutex.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\locks\win32\thread_cond.c - -"$(INTDIR)\thread_cond.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\locks\win32\thread_mutex.c - -"$(INTDIR)\thread_mutex.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\locks\win32\thread_rwlock.c - -"$(INTDIR)\thread_rwlock.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\memory\unix\apr_pools.c - -"$(INTDIR)\apr_pools.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\misc\win32\apr_app.c -SOURCE=.\misc\win32\charset.c - -"$(INTDIR)\charset.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\misc\win32\env.c - -"$(INTDIR)\env.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\misc\unix\errorcodes.c - -"$(INTDIR)\errorcodes.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\misc\unix\getopt.c - -"$(INTDIR)\getopt.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\misc\win32\internal.c - -"$(INTDIR)\internal.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\misc\win32\misc.c - -"$(INTDIR)\misc.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\misc\unix\otherchild.c - -"$(INTDIR)\otherchild.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\misc\win32\rand.c - -"$(INTDIR)\rand.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\misc\win32\start.c - -"$(INTDIR)\start.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\misc\win32\utf8.c - -"$(INTDIR)\utf8.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\misc\unix\version.c - -"$(INTDIR)\version.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\mmap\unix\common.c - -"$(INTDIR)\common.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\mmap\win32\mmap.c - -"$(INTDIR)\mmap.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\network_io\unix\inet_ntop.c - -"$(INTDIR)\inet_ntop.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\network_io\unix\inet_pton.c - -"$(INTDIR)\inet_pton.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\network_io\unix\multicast.c - -"$(INTDIR)\multicast.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\network_io\win32\sendrecv.c - -"$(INTDIR)\sendrecv.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\network_io\unix\sockaddr.c - -"$(INTDIR)\sockaddr.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\network_io\unix\socket_util.c - -"$(INTDIR)\socket_util.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\network_io\win32\sockets.c - -"$(INTDIR)\sockets.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\network_io\win32\sockopt.c - -"$(INTDIR)\sockopt.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\passwd\apr_getpass.c - -"$(INTDIR)\apr_getpass.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\poll\unix\poll.c - -"$(INTDIR)\poll.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\poll\unix\pollcb.c - -"$(INTDIR)\pollcb.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\poll\unix\pollset.c - -"$(INTDIR)\pollset.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\poll\unix\select.c - -"$(INTDIR)\select.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\random\unix\apr_random.c - -"$(INTDIR)\apr_random.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\random\unix\sha2.c - -"$(INTDIR)\sha2.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\random\unix\sha2_glue.c - -"$(INTDIR)\sha2_glue.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\shmem\win32\shm.c - -"$(INTDIR)\shm.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\strings\apr_cpystrn.c - -"$(INTDIR)\apr_cpystrn.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\strings\apr_fnmatch.c - -"$(INTDIR)\apr_fnmatch.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\strings\apr_snprintf.c - -"$(INTDIR)\apr_snprintf.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\strings\apr_strings.c - -"$(INTDIR)\apr_strings.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\strings\apr_strnatcmp.c - -"$(INTDIR)\apr_strnatcmp.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\strings\apr_strtok.c - -"$(INTDIR)\apr_strtok.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\tables\apr_hash.c - -"$(INTDIR)\apr_hash.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\tables\apr_tables.c - -"$(INTDIR)\apr_tables.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\threadproc\win32\proc.c - -"$(INTDIR)\proc.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\threadproc\win32\signals.c - -"$(INTDIR)\signals.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\threadproc\win32\thread.c - -"$(INTDIR)\thread.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\threadproc\win32\threadpriv.c - -"$(INTDIR)\threadpriv.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\time\win32\time.c - -"$(INTDIR)\time.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\time\win32\timestr.c - -"$(INTDIR)\timestr.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\user\win32\groupinfo.c - -"$(INTDIR)\groupinfo.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\user\win32\userinfo.c - -"$(INTDIR)\userinfo.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=.\include\apr.hw - -!IF "$(CFG)" == "libapr - Win32 Release" - -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - < .\include\apr.h -<< - - -!ELSEIF "$(CFG)" == "libapr - Win32 Debug" - -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - < .\include\apr.h -<< - - -!ELSEIF "$(CFG)" == "libapr - Win32 Release9x" - -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - < .\include\apr.h -<< - - -!ELSEIF "$(CFG)" == "libapr - Win32 Debug9x" - -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - < .\include\apr.h -<< - - -!ELSEIF "$(CFG)" == "libapr - x64 Release" - -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - < .\include\apr.h -<< - - -!ELSEIF "$(CFG)" == "libapr - x64 Debug" - -InputPath=.\include\apr.hw - -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - < .\include\apr.h -<< - - -!ENDIF - -SOURCE=.\libapr.rc - -"$(INTDIR)\libapr.res" : $(SOURCE) "$(INTDIR)" ".\include\apr.h" - $(RSC) $(RSC_PROJ) $(SOURCE) - - - -!ENDIF - diff --git a/libs/apr/libapr.rc b/libs/apr/libapr.rc deleted file mode 100644 index 098b5f15..00000000 --- a/libs/apr/libapr.rc +++ /dev/null @@ -1,67 +0,0 @@ -#include "apr_version.h" - -#define APR_COPYRIGHT "Copyright (c) 2011 The Apache Software " \ - "Foundation or its licensors, as applicable." - -#define APR_LICENSE \ - "Licensed to the Apache Software Foundation (ASF) under one or more " \ - "contributor license agreements. See the NOTICE file distributed with " \ - "this work for additional information regarding copyright ownership. " \ - "The ASF licenses this file to You under the Apache License, Version 2.0 " \ - "(the ""License""); you may not use this file except in compliance with " \ - "the License. You may obtain a copy of the License at\r\n\r\n" \ - "http://www.apache.org/licenses/LICENSE-2.0\r\n\r\n" \ - "Unless required by applicable law or agreed to in writing, software " \ - "distributed under the License is distributed on an ""AS IS"" BASIS, " \ - "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. " \ - "See the License for the specific language governing permissions and " \ - "limitations under the License." - -#define APR_DLL_BASENAME "libapr-" APR_STRINGIFY(APR_MAJOR_VERSION) - - -1 VERSIONINFO - FILEVERSION APR_VERSION_STRING_CSV,0 - PRODUCTVERSION APR_VERSION_STRING_CSV,0 - FILEFLAGSMASK 0x3fL -#if defined(APR_IS_DEV_VERSION) -#if defined(_DEBUG) - FILEFLAGS 0x03L -#else - FILEFLAGS 0x02L -#endif -#else -#if defined(_DEBUG) - FILEFLAGS 0x01L -#else - FILEFLAGS 0x00L -#endif -#endif -#if defined(WINNT) || defined(WIN64) - FILEOS 0x40004L -#else - FILEOS 0x4L -#endif - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "Comments", APR_LICENSE "\0" - VALUE "CompanyName", "Apache Software Foundation\0" - VALUE "FileDescription", "Apache Portable Runtime Library\0" - VALUE "FileVersion", APR_VERSION_STRING "\0" - VALUE "InternalName", APR_DLL_BASENAME "\0" - VALUE "LegalCopyright", APR_COPYRIGHT "\0" - VALUE "OriginalFilename", APR_DLL_BASENAME ".dll\0" - VALUE "ProductName", "Apache Portable Runtime Project\0" - VALUE "ProductVersion", APR_VERSION_STRING "\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END diff --git a/libs/apr/locks/beos/proc_mutex.c b/libs/apr/locks/beos/proc_mutex.c deleted file mode 100644 index ce2a580b..00000000 --- a/libs/apr/locks/beos/proc_mutex.c +++ /dev/null @@ -1,170 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*Read/Write locking implementation based on the MultiLock code from - * Stephen Beaulieu - */ - -#include "apr_arch_proc_mutex.h" -#include "apr_strings.h" -#include "apr_portable.h" - -static apr_status_t _proc_mutex_cleanup(void * data) -{ - apr_proc_mutex_t *lock = (apr_proc_mutex_t*)data; - if (lock->LockCount != 0) { - /* we're still locked... */ - while (atomic_add(&lock->LockCount , -1) > 1){ - /* OK we had more than one person waiting on the lock so - * the sem is also locked. Release it until we have no more - * locks left. - */ - release_sem (lock->Lock); - } - } - delete_sem(lock->Lock); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex, - const char *fname, - apr_lockmech_e mech, - apr_pool_t *pool) -{ - apr_proc_mutex_t *new; - apr_status_t stat = APR_SUCCESS; - - if (mech != APR_LOCK_DEFAULT) { - return APR_ENOTIMPL; - } - - new = (apr_proc_mutex_t *)apr_pcalloc(pool, sizeof(apr_proc_mutex_t)); - if (new == NULL){ - return APR_ENOMEM; - } - - if ((stat = create_sem(0, "APR_Lock")) < B_NO_ERROR) { - _proc_mutex_cleanup(new); - return stat; - } - new->LockCount = 0; - new->Lock = stat; - new->pool = pool; - - apr_pool_cleanup_register(new->pool, (void *)new, _proc_mutex_cleanup, - apr_pool_cleanup_null); - - (*mutex) = new; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_child_init(apr_proc_mutex_t **mutex, - const char *fname, - apr_pool_t *pool) -{ - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_lock(apr_proc_mutex_t *mutex) -{ - int32 stat; - - if (atomic_add(&mutex->LockCount, 1) > 0) { - if ((stat = acquire_sem(mutex->Lock)) < B_NO_ERROR) { - atomic_add(&mutex->LockCount, -1); - return stat; - } - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_unlock(apr_proc_mutex_t *mutex) -{ - int32 stat; - - if (atomic_add(&mutex->LockCount, -1) > 1) { - if ((stat = release_sem(mutex->Lock)) < B_NO_ERROR) { - atomic_add(&mutex->LockCount, 1); - return stat; - } - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex) -{ - apr_status_t stat; - if ((stat = _proc_mutex_cleanup(mutex)) == APR_SUCCESS) { - apr_pool_cleanup_kill(mutex->pool, mutex, _proc_mutex_cleanup); - return APR_SUCCESS; - } - return stat; -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_cleanup(void *mutex) -{ - return _proc_mutex_cleanup(mutex); -} - - -APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex) -{ - return NULL; -} - -APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex) -{ - return "beossem"; -} - -APR_DECLARE(const char *) apr_proc_mutex_defname(void) -{ - return "beossem"; -} - -APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex) - -/* Implement OS-specific accessors defined in apr_portable.h */ - -APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex, - apr_proc_mutex_t *pmutex) -{ - ospmutex->sem = pmutex->Lock; - ospmutex->ben = pmutex->LockCount; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex, - apr_os_proc_mutex_t *ospmutex, - apr_pool_t *pool) -{ - if (pool == NULL) { - return APR_ENOPOOL; - } - if ((*pmutex) == NULL) { - (*pmutex) = (apr_proc_mutex_t *)apr_pcalloc(pool, sizeof(apr_proc_mutex_t)); - (*pmutex)->pool = pool; - } - (*pmutex)->Lock = ospmutex->sem; - (*pmutex)->LockCount = ospmutex->ben; - return APR_SUCCESS; -} - diff --git a/libs/apr/locks/beos/thread_cond.c b/libs/apr/locks/beos/thread_cond.c deleted file mode 100644 index e3ea4600..00000000 --- a/libs/apr/locks/beos/thread_cond.c +++ /dev/null @@ -1,185 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_thread_mutex.h" -#include "apr_arch_thread_cond.h" -#include "apr_strings.h" -#include "apr_portable.h" - -static apr_status_t thread_cond_cleanup(void *data) -{ - struct waiter *w; - apr_thread_cond_t *cond = (apr_thread_cond_t *)data; - - acquire_sem(cond->lock); - delete_sem(cond->lock); - - return APR_SUCCESS; -} - -static struct waiter_t *make_waiter(apr_pool_t *pool) -{ - struct waiter_t *w = (struct waiter_t*) - apr_palloc(pool, sizeof(struct waiter_t)); - if (w == NULL) - return NULL; - - w->sem = create_sem(0, "apr conditional waiter"); - if (w->sem < 0) - return NULL; - - APR_RING_ELEM_INIT(w, link); - - return w; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond, - apr_pool_t *pool) -{ - apr_thread_cond_t *new_cond; - sem_id rv; - int i; - - new_cond = (apr_thread_cond_t *)apr_palloc(pool, sizeof(apr_thread_cond_t)); - - if (new_cond == NULL) - return APR_ENOMEM; - - if ((rv = create_sem(1, "apr conditional lock")) < B_OK) - return rv; - - new_cond->lock = rv; - new_cond->pool = pool; - APR_RING_INIT(&new_cond->alist, waiter_t, link); - APR_RING_INIT(&new_cond->flist, waiter_t, link); - - for (i=0;i < 10 ;i++) { - struct waiter_t *nw = make_waiter(pool); - APR_RING_INSERT_TAIL(&new_cond->flist, nw, waiter_t, link); - } - - apr_pool_cleanup_register(new_cond->pool, - (void *)new_cond, thread_cond_cleanup, - apr_pool_cleanup_null); - - *cond = new_cond; - return APR_SUCCESS; -} - - -static apr_status_t do_wait(apr_thread_cond_t *cond, apr_thread_mutex_t *mutex, - int timeout) -{ - struct waiter_t *wait; - thread_id cth = find_thread(NULL); - apr_status_t rv; - int flags = B_RELATIVE_TIMEOUT; - - /* We must be the owner of the mutex or we can't do this... */ - if (mutex->owner != cth) { - /* What should we return??? */ - return APR_EINVAL; - } - - acquire_sem(cond->lock); - wait = APR_RING_FIRST(&cond->flist); - if (wait) - APR_RING_REMOVE(wait, link); - else - wait = make_waiter(cond->pool); - APR_RING_INSERT_TAIL(&cond->alist, wait, waiter_t, link); - cond->condlock = mutex; - release_sem(cond->lock); - - apr_thread_mutex_unlock(cond->condlock); - - if (timeout == 0) - flags = 0; - - rv = acquire_sem_etc(wait->sem, 1, flags, timeout); - - apr_thread_mutex_lock(cond->condlock); - - if (rv != B_OK) - if (rv == B_TIMED_OUT) - return APR_TIMEUP; - return rv; - - acquire_sem(cond->lock); - APR_RING_REMOVE(wait, link); - APR_RING_INSERT_TAIL(&cond->flist, wait, waiter_t, link); - release_sem(cond->lock); - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex) -{ - return do_wait(cond, mutex, 0); -} - -APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex, - apr_interval_time_t timeout) -{ - return do_wait(cond, mutex, timeout); -} - -APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond) -{ - struct waiter_t *wake; - - acquire_sem(cond->lock); - if (!APR_RING_EMPTY(&cond->alist, waiter_t, link)) { - wake = APR_RING_FIRST(&cond->alist); - APR_RING_REMOVE(wake, link); - release_sem(wake->sem); - APR_RING_INSERT_TAIL(&cond->flist, wake, waiter_t, link); - } - release_sem(cond->lock); - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond) -{ - struct waiter_t *wake; - - acquire_sem(cond->lock); - while (! APR_RING_EMPTY(&cond->alist, waiter_t, link)) { - wake = APR_RING_FIRST(&cond->alist); - APR_RING_REMOVE(wake, link); - release_sem(wake->sem); - APR_RING_INSERT_TAIL(&cond->flist, wake, waiter_t, link); - } - release_sem(cond->lock); - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond) -{ - apr_status_t stat; - if ((stat = thread_cond_cleanup(cond)) == APR_SUCCESS) { - apr_pool_cleanup_kill(cond->pool, cond, thread_cond_cleanup); - return APR_SUCCESS; - } - return stat; -} - -APR_POOL_IMPLEMENT_ACCESSOR(thread_cond) - diff --git a/libs/apr/locks/beos/thread_mutex.c b/libs/apr/locks/beos/thread_mutex.c deleted file mode 100644 index b87f7660..00000000 --- a/libs/apr/locks/beos/thread_mutex.c +++ /dev/null @@ -1,147 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*Read/Write locking implementation based on the MultiLock code from - * Stephen Beaulieu - */ - -#include "apr_arch_thread_mutex.h" -#include "apr_strings.h" -#include "apr_portable.h" - -static apr_status_t _thread_mutex_cleanup(void * data) -{ - apr_thread_mutex_t *lock = (apr_thread_mutex_t*)data; - if (lock->LockCount != 0) { - /* we're still locked... */ - while (atomic_add(&lock->LockCount , -1) > 1){ - /* OK we had more than one person waiting on the lock so - * the sem is also locked. Release it until we have no more - * locks left. - */ - release_sem (lock->Lock); - } - } - delete_sem(lock->Lock); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex, - unsigned int flags, - apr_pool_t *pool) -{ - apr_thread_mutex_t *new_m; - apr_status_t stat = APR_SUCCESS; - - new_m = (apr_thread_mutex_t *)apr_pcalloc(pool, sizeof(apr_thread_mutex_t)); - if (new_m == NULL){ - return APR_ENOMEM; - } - - if ((stat = create_sem(0, "APR_Lock")) < B_NO_ERROR) { - _thread_mutex_cleanup(new_m); - return stat; - } - new_m->LockCount = 0; - new_m->Lock = stat; - new_m->pool = pool; - - /* Optimal default is APR_THREAD_MUTEX_UNNESTED, - * no additional checks required for either flag. - */ - new_m->nested = flags & APR_THREAD_MUTEX_NESTED; - - apr_pool_cleanup_register(new_m->pool, (void *)new_m, _thread_mutex_cleanup, - apr_pool_cleanup_null); - - (*mutex) = new_m; - return APR_SUCCESS; -} - -#if APR_HAS_CREATE_LOCKS_NP -APR_DECLARE(apr_status_t) apr_thread_mutex_create_np(apr_thread_mutex_t **mutex, - const char *fname, - apr_lockmech_e_np mech, - apr_pool_t *pool) -{ - return APR_ENOTIMPL; -} -#endif - -APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex) -{ - int32 stat; - thread_id me = find_thread(NULL); - - if (mutex->nested && mutex->owner == me) { - mutex->owner_ref++; - return APR_SUCCESS; - } - - if (atomic_add(&mutex->LockCount, 1) > 0) { - if ((stat = acquire_sem(mutex->Lock)) < B_NO_ERROR) { - /* Oh dear, acquire_sem failed!! */ - atomic_add(&mutex->LockCount, -1); - return stat; - } - } - - mutex->owner = me; - mutex->owner_ref = 1; - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex) -{ - int32 stat; - - if (mutex->nested && mutex->owner == find_thread(NULL)) { - mutex->owner_ref--; - if (mutex->owner_ref > 0) - return APR_SUCCESS; - } - - if (atomic_add(&mutex->LockCount, -1) > 1) { - if ((stat = release_sem(mutex->Lock)) < B_NO_ERROR) { - atomic_add(&mutex->LockCount, 1); - return stat; - } - } - - mutex->owner = -1; - mutex->owner_ref = 0; - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_mutex_destroy(apr_thread_mutex_t *mutex) -{ - apr_status_t stat; - if ((stat = _thread_mutex_cleanup(mutex)) == APR_SUCCESS) { - apr_pool_cleanup_kill(mutex->pool, mutex, _thread_mutex_cleanup); - return APR_SUCCESS; - } - return stat; -} - -APR_POOL_IMPLEMENT_ACCESSOR(thread_mutex) - diff --git a/libs/apr/locks/beos/thread_rwlock.c b/libs/apr/locks/beos/thread_rwlock.c deleted file mode 100644 index a540b445..00000000 --- a/libs/apr/locks/beos/thread_rwlock.c +++ /dev/null @@ -1,190 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*Read/Write locking implementation based on the MultiLock code from - * Stephen Beaulieu - */ - -#include "apr_arch_thread_rwlock.h" -#include "apr_strings.h" -#include "apr_portable.h" - -#define BIG_NUM 100000 - -static apr_status_t _thread_rw_cleanup(void * data) -{ - apr_thread_rwlock_t *mutex = (apr_thread_rwlock_t*)data; - - if (mutex->ReadCount != 0) { - while (atomic_add(&mutex->ReadCount , -1) > 1){ - release_sem (mutex->Read); - } - } - if (mutex->WriteCount != 0) { - while (atomic_add(&mutex->WriteCount , -1) > 1){ - release_sem (mutex->Write); - } - } - if (mutex->LockCount != 0) { - while (atomic_add(&mutex->LockCount , -1) > 1){ - release_sem (mutex->Lock); - } - } - - delete_sem(mutex->Read); - delete_sem(mutex->Write); - delete_sem(mutex->Lock); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock, - apr_pool_t *pool) -{ - apr_thread_rwlock_t *new; - - new = (apr_thread_rwlock_t *)apr_pcalloc(pool, sizeof(apr_thread_rwlock_t)); - if (new == NULL){ - return APR_ENOMEM; - } - - new->pool = pool; - /* we need to make 3 locks... */ - new->ReadCount = 0; - new->WriteCount = 0; - new->LockCount = 0; - new->Read = create_sem(0, "APR_ReadLock"); - new->Write = create_sem(0, "APR_WriteLock"); - new->Lock = create_sem(0, "APR_Lock"); - - if (new->Lock < 0 || new->Read < 0 || new->Write < 0) { - _thread_rw_cleanup(new); - return -1; - } - - apr_pool_cleanup_register(new->pool, (void *)new, _thread_rw_cleanup, - apr_pool_cleanup_null); - (*rwlock) = new; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock) -{ - int32 rv = APR_SUCCESS; - - if (find_thread(NULL) == rwlock->writer) { - /* we're the writer - no problem */ - rwlock->Nested++; - } else { - /* we're not the writer */ - int32 r = atomic_add(&rwlock->ReadCount, 1); - if (r < 0) { - /* Oh dear, writer holds lock, wait for sem */ - rv = acquire_sem_etc(rwlock->Read, 1, B_DO_NOT_RESCHEDULE, - B_INFINITE_TIMEOUT); - } - } - - return rv; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwlock) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_wrlock(apr_thread_rwlock_t *rwlock) -{ - int rv = APR_SUCCESS; - - if (find_thread(NULL) == rwlock->writer) { - rwlock->Nested++; - } else { - /* we're not the writer... */ - if (atomic_add(&rwlock->LockCount, 1) >= 1) { - /* we're locked - acquire the sem */ - rv = acquire_sem_etc(rwlock->Lock, 1, B_DO_NOT_RESCHEDULE, - B_INFINITE_TIMEOUT); - } - if (rv == APR_SUCCESS) { - /* decrement the ReadCount to a large -ve number so that - * we block on new readers... - */ - int32 readers = atomic_add(&rwlock->ReadCount, -BIG_NUM); - if (readers > 0) { - /* readers are holding the lock */ - rv = acquire_sem_etc(rwlock->Write, readers, B_DO_NOT_RESCHEDULE, - B_INFINITE_TIMEOUT); - } - if (rv == APR_SUCCESS) - rwlock->writer = find_thread(NULL); - } - } - - return rv; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_trywrlock(apr_thread_rwlock_t *rwlock) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock) -{ - apr_status_t rv = APR_SUCCESS; - int32 readers; - - /* we know we hold the lock, so don't check it :) */ - if (find_thread(NULL) == rwlock->writer) { - /* we know we hold the lock, so don't check it :) */ - if (rwlock->Nested > 1) { - /* we're recursively locked */ - rwlock->Nested--; - return APR_SUCCESS; - } - /* OK so we need to release the sem if we have it :) */ - readers = atomic_add(&rwlock->ReadCount, BIG_NUM) + BIG_NUM; - if (readers > 0) { - rv = release_sem_etc(rwlock->Read, readers, B_DO_NOT_RESCHEDULE); - } - if (rv == APR_SUCCESS) { - rwlock->writer = -1; - if (atomic_add(&rwlock->LockCount, -1) > 1) { - rv = release_sem_etc(rwlock->Lock, 1, B_DO_NOT_RESCHEDULE); - } - } - } else { - /* We weren't the Writer, so just release the ReadCount... */ - if (atomic_add(&rwlock->ReadCount, -1) < 0) { - /* we have a writer waiting for the lock, so release it */ - rv = release_sem_etc(rwlock->Write, 1, B_DO_NOT_RESCHEDULE); - } - } - - return rv; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t *rwlock) -{ - apr_status_t stat; - if ((stat = _thread_rw_cleanup(rwlock)) == APR_SUCCESS) { - apr_pool_cleanup_kill(rwlock->pool, rwlock, _thread_rw_cleanup); - return APR_SUCCESS; - } - return stat; -} - -APR_POOL_IMPLEMENT_ACCESSOR(thread_rwlock) - diff --git a/libs/apr/locks/netware/proc_mutex.c b/libs/apr/locks/netware/proc_mutex.c deleted file mode 100644 index 77411d0b..00000000 --- a/libs/apr/locks/netware/proc_mutex.c +++ /dev/null @@ -1,118 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_private.h" -#include "apr_portable.h" -#include "apr_arch_proc_mutex.h" -#include "apr_arch_thread_mutex.h" - -APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex, - const char *fname, - apr_lockmech_e mech, - apr_pool_t *pool) -{ - apr_status_t ret; - apr_proc_mutex_t *new_mutex = NULL; - new_mutex = (apr_proc_mutex_t *)apr_pcalloc(pool, sizeof(apr_proc_mutex_t)); - - if(new_mutex ==NULL) { - return APR_ENOMEM; - } - - new_mutex->pool = pool; - ret = apr_thread_mutex_create(&(new_mutex->mutex), APR_THREAD_MUTEX_DEFAULT, pool); - - if (ret == APR_SUCCESS) - *mutex = new_mutex; - - return ret; -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_child_init(apr_proc_mutex_t **mutex, - const char *fname, - apr_pool_t *pool) -{ - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_lock(apr_proc_mutex_t *mutex) -{ - if (mutex) - return apr_thread_mutex_lock(mutex->mutex); - return APR_ENOLOCK; -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex) -{ - if (mutex) - return apr_thread_mutex_trylock(mutex->mutex); - return APR_ENOLOCK; -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_unlock(apr_proc_mutex_t *mutex) -{ - if (mutex) - return apr_thread_mutex_unlock(mutex->mutex); - return APR_ENOLOCK; -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_cleanup(void *mutex) -{ - return apr_proc_mutex_destroy(mutex); -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex) -{ - if (mutex) - return apr_thread_mutex_destroy(mutex->mutex); - return APR_ENOLOCK; -} - -APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex) -{ - return NULL; -} - -APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex) -{ - return "netwarethread"; -} - -APR_DECLARE(const char *) apr_proc_mutex_defname(void) -{ - return "netwarethread"; -} - -APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex) - -/* Implement OS-specific accessors defined in apr_portable.h */ - -apr_status_t apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex, - apr_proc_mutex_t *pmutex) -{ - if (pmutex) - ospmutex = pmutex->mutex->mutex; - return APR_ENOLOCK; -} - -apr_status_t apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex, - apr_os_proc_mutex_t *ospmutex, - apr_pool_t *pool) -{ - return APR_ENOTIMPL; -} - diff --git a/libs/apr/locks/netware/thread_cond.c b/libs/apr/locks/netware/thread_cond.c deleted file mode 100644 index dcb21edc..00000000 --- a/libs/apr/locks/netware/thread_cond.c +++ /dev/null @@ -1,100 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_arch_thread_mutex.h" -#include "apr_arch_thread_cond.h" -#include "apr_portable.h" - -static apr_status_t thread_cond_cleanup(void *data) -{ - apr_thread_cond_t *cond = (apr_thread_cond_t *)data; - - NXCondFree(cond->cond); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond, - apr_pool_t *pool) -{ - apr_thread_cond_t *new_cond = NULL; - - new_cond = (apr_thread_cond_t *)apr_pcalloc(pool, sizeof(apr_thread_cond_t)); - - if(new_cond ==NULL) { - return APR_ENOMEM; - } - new_cond->pool = pool; - - new_cond->cond = NXCondAlloc(NULL); - - if(new_cond->cond == NULL) - return APR_ENOMEM; - - apr_pool_cleanup_register(new_cond->pool, new_cond, - (void*)thread_cond_cleanup, - apr_pool_cleanup_null); - *cond = new_cond; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex) -{ - if (NXCondWait(cond->cond, mutex->mutex) != 0) - return APR_EINTR; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex, - apr_interval_time_t timeout){ - if (NXCondTimedWait(cond->cond, mutex->mutex, - (timeout*1000)/NXGetSystemTick()) == NX_ETIMEDOUT) { - return APR_TIMEUP; - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond) -{ - NXCondSignal(cond->cond); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond) -{ - NXCondBroadcast(cond->cond); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond) -{ - apr_status_t stat; - if ((stat = thread_cond_cleanup(cond)) == APR_SUCCESS) { - apr_pool_cleanup_kill(cond->pool, cond, thread_cond_cleanup); - return APR_SUCCESS; - } - return stat; -} - -APR_POOL_IMPLEMENT_ACCESSOR(thread_cond) - diff --git a/libs/apr/locks/netware/thread_mutex.c b/libs/apr/locks/netware/thread_mutex.c deleted file mode 100644 index 98bf33bd..00000000 --- a/libs/apr/locks/netware/thread_mutex.c +++ /dev/null @@ -1,92 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_arch_thread_mutex.h" -#include "apr_portable.h" - -static apr_status_t thread_mutex_cleanup(void *data) -{ - apr_thread_mutex_t *mutex = (apr_thread_mutex_t *)data; - - NXMutexFree(mutex->mutex); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex, - unsigned int flags, - apr_pool_t *pool) -{ - apr_thread_mutex_t *new_mutex = NULL; - - /* XXX: Implement _UNNESTED flavor and favor _DEFAULT for performance - */ - if (flags & APR_THREAD_MUTEX_UNNESTED) { - return APR_ENOTIMPL; - } - new_mutex = (apr_thread_mutex_t *)apr_pcalloc(pool, sizeof(apr_thread_mutex_t)); - - if(new_mutex ==NULL) { - return APR_ENOMEM; - } - new_mutex->pool = pool; - - new_mutex->mutex = NXMutexAlloc(NX_MUTEX_RECURSIVE, 0, NULL); - - if(new_mutex->mutex == NULL) - return APR_ENOMEM; - - apr_pool_cleanup_register(new_mutex->pool, new_mutex, - (void*)thread_mutex_cleanup, - apr_pool_cleanup_null); - *mutex = new_mutex; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex) -{ - NXLock(mutex->mutex); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex) -{ - if (!NXTryLock(mutex->mutex)) - return APR_EBUSY; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex) -{ - NXUnlock(mutex->mutex); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_mutex_destroy(apr_thread_mutex_t *mutex) -{ - apr_status_t stat; - if ((stat = thread_mutex_cleanup(mutex)) == APR_SUCCESS) { - apr_pool_cleanup_kill(mutex->pool, mutex, thread_mutex_cleanup); - return APR_SUCCESS; - } - return stat; -} - -APR_POOL_IMPLEMENT_ACCESSOR(thread_mutex) - diff --git a/libs/apr/locks/netware/thread_rwlock.c b/libs/apr/locks/netware/thread_rwlock.c deleted file mode 100644 index f971aefd..00000000 --- a/libs/apr/locks/netware/thread_rwlock.c +++ /dev/null @@ -1,102 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_arch_thread_rwlock.h" -#include "apr_portable.h" - -static apr_status_t thread_rwlock_cleanup(void *data) -{ - apr_thread_rwlock_t *rwlock = (apr_thread_rwlock_t *)data; - - NXRwLockFree (rwlock->rwlock); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock, - apr_pool_t *pool) -{ - apr_thread_rwlock_t *new_rwlock = NULL; - - NXHierarchy_t hierarchy = 1; /* for libc NKS NXRwLockAlloc */ - NXLockInfo_t *info; /* for libc NKS NXRwLockAlloc */ - - new_rwlock = (apr_thread_rwlock_t *)apr_pcalloc(pool, sizeof(apr_thread_rwlock_t)); - - if(new_rwlock ==NULL) { - return APR_ENOMEM; - } - new_rwlock->pool = pool; - - info = (NXLockInfo_t *)apr_pcalloc(pool, sizeof(NXLockInfo_t)); - new_rwlock->rwlock = NXRwLockAlloc(hierarchy, info); - if(new_rwlock->rwlock == NULL) - return APR_ENOMEM; - - apr_pool_cleanup_register(new_rwlock->pool, new_rwlock, thread_rwlock_cleanup, - apr_pool_cleanup_null); - *rwlock = new_rwlock; - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock) -{ - NXRdLock(rwlock->rwlock); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwlock) -{ - if (!NXTryRdLock(rwlock->rwlock)) - return APR_EBUSY; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_wrlock(apr_thread_rwlock_t *rwlock) -{ - NXWrLock(rwlock->rwlock); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_trywrlock(apr_thread_rwlock_t *rwlock) -{ - if (!NXTryWrLock(rwlock->rwlock)) - return APR_EBUSY; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock) -{ - NXRwUnlock(rwlock->rwlock); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t *rwlock) -{ - apr_status_t stat; - if ((stat = thread_rwlock_cleanup(rwlock)) == APR_SUCCESS) { - apr_pool_cleanup_kill(rwlock->pool, rwlock, thread_rwlock_cleanup); - return APR_SUCCESS; - } - return stat; -} - -APR_POOL_IMPLEMENT_ACCESSOR(thread_rwlock) - diff --git a/libs/apr/locks/os2/proc_mutex.c b/libs/apr/locks/os2/proc_mutex.c deleted file mode 100644 index 0f3a564e..00000000 --- a/libs/apr/locks/os2/proc_mutex.c +++ /dev/null @@ -1,234 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_arch_proc_mutex.h" -#include "apr_arch_file_io.h" -#include -#include - -#define CurrentTid (*_threadid) - -static char *fixed_name(const char *fname, apr_pool_t *pool) -{ - char *semname; - - if (fname == NULL) - semname = NULL; - else { - /* Semaphores don't live in the file system, fix up the name */ - while (*fname == '/' || *fname == '\\') { - fname++; - } - - semname = apr_pstrcat(pool, "/SEM32/", fname, NULL); - - if (semname[8] == ':') { - semname[8] = '$'; - } - } - - return semname; -} - - - -APR_DECLARE(apr_status_t) apr_proc_mutex_cleanup(void *vmutex) -{ - apr_proc_mutex_t *mutex = vmutex; - return apr_proc_mutex_destroy(mutex); -} - -APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex) -{ - return NULL; -} - -APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex) -{ - return "os2sem"; -} - -APR_DECLARE(const char *) apr_proc_mutex_defname(void) -{ - return "os2sem"; -} - - -APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex, - const char *fname, - apr_lockmech_e mech, - apr_pool_t *pool) -{ - apr_proc_mutex_t *new; - ULONG rc; - char *semname; - - if (mech != APR_LOCK_DEFAULT) { - return APR_ENOTIMPL; - } - - new = (apr_proc_mutex_t *)apr_palloc(pool, sizeof(apr_proc_mutex_t)); - new->pool = pool; - new->owner = 0; - new->lock_count = 0; - *mutex = new; - - semname = fixed_name(fname, pool); - rc = DosCreateMutexSem(semname, &(new->hMutex), DC_SEM_SHARED, FALSE); - - if (!rc) { - apr_pool_cleanup_register(pool, new, apr_proc_mutex_cleanup, apr_pool_cleanup_null); - } - - return APR_FROM_OS_ERROR(rc); -} - - - -APR_DECLARE(apr_status_t) apr_proc_mutex_child_init(apr_proc_mutex_t **mutex, - const char *fname, - apr_pool_t *pool) -{ - apr_proc_mutex_t *new; - ULONG rc; - char *semname; - - new = (apr_proc_mutex_t *)apr_palloc(pool, sizeof(apr_proc_mutex_t)); - new->pool = pool; - new->owner = 0; - new->lock_count = 0; - - semname = fixed_name(fname, pool); - rc = DosOpenMutexSem(semname, &(new->hMutex)); - *mutex = new; - - if (!rc) { - apr_pool_cleanup_register(pool, new, apr_proc_mutex_cleanup, apr_pool_cleanup_null); - } - - return APR_FROM_OS_ERROR(rc); -} - - - -APR_DECLARE(apr_status_t) apr_proc_mutex_lock(apr_proc_mutex_t *mutex) -{ - ULONG rc = DosRequestMutexSem(mutex->hMutex, SEM_INDEFINITE_WAIT); - - if (rc == 0) { - mutex->owner = CurrentTid; - mutex->lock_count++; - } - - return APR_FROM_OS_ERROR(rc); -} - - - -APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex) -{ - ULONG rc = DosRequestMutexSem(mutex->hMutex, SEM_IMMEDIATE_RETURN); - - if (rc == 0) { - mutex->owner = CurrentTid; - mutex->lock_count++; - } - - return APR_FROM_OS_ERROR(rc); -} - - - -APR_DECLARE(apr_status_t) apr_proc_mutex_unlock(apr_proc_mutex_t *mutex) -{ - ULONG rc; - - if (mutex->owner == CurrentTid && mutex->lock_count > 0) { - mutex->lock_count--; - rc = DosReleaseMutexSem(mutex->hMutex); - return APR_FROM_OS_ERROR(rc); - } - - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex) -{ - ULONG rc; - apr_status_t status = APR_SUCCESS; - - if (mutex->owner == CurrentTid) { - while (mutex->lock_count > 0 && status == APR_SUCCESS) { - status = apr_proc_mutex_unlock(mutex); - } - } - - if (status != APR_SUCCESS) { - return status; - } - - if (mutex->hMutex == 0) { - return APR_SUCCESS; - } - - rc = DosCloseMutexSem(mutex->hMutex); - - if (!rc) { - mutex->hMutex = 0; - } - - return APR_FROM_OS_ERROR(rc); -} - - - -APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex) - - - -/* Implement OS-specific accessors defined in apr_portable.h */ - -APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex, - apr_proc_mutex_t *pmutex) -{ - *ospmutex = pmutex->hMutex; - return APR_ENOTIMPL; -} - - - -APR_DECLARE(apr_status_t) apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex, - apr_os_proc_mutex_t *ospmutex, - apr_pool_t *pool) -{ - apr_proc_mutex_t *new; - - new = (apr_proc_mutex_t *)apr_palloc(pool, sizeof(apr_proc_mutex_t)); - new->pool = pool; - new->owner = 0; - new->lock_count = 0; - new->hMutex = *ospmutex; - *pmutex = new; - - return APR_SUCCESS; -} - diff --git a/libs/apr/locks/os2/thread_cond.c b/libs/apr/locks/os2/thread_cond.c deleted file mode 100644 index ec6034f5..00000000 --- a/libs/apr/locks/os2/thread_cond.c +++ /dev/null @@ -1,60 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_arch_thread_mutex.h" -#include "apr_arch_thread_cond.h" -#include "apr_arch_file_io.h" -#include - -APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond, - apr_pool_t *pool) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex, - apr_interval_time_t timeout){ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond) -{ - return APR_ENOTIMPL; -} - -APR_POOL_IMPLEMENT_ACCESSOR(thread_cond) - diff --git a/libs/apr/locks/os2/thread_mutex.c b/libs/apr/locks/os2/thread_mutex.c deleted file mode 100644 index 5d8436be..00000000 --- a/libs/apr/locks/os2/thread_mutex.c +++ /dev/null @@ -1,102 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_arch_thread_mutex.h" -#include "apr_arch_file_io.h" -#include -#include - -static apr_status_t thread_mutex_cleanup(void *themutex) -{ - apr_thread_mutex_t *mutex = themutex; - return apr_thread_mutex_destroy(mutex); -} - - - -/* XXX: Need to respect APR_THREAD_MUTEX_[UN]NESTED flags argument - * or return APR_ENOTIMPL!!! - */ -APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex, - unsigned int flags, - apr_pool_t *pool) -{ - apr_thread_mutex_t *new_mutex; - ULONG rc; - - new_mutex = (apr_thread_mutex_t *)apr_palloc(pool, sizeof(apr_thread_mutex_t)); - new_mutex->pool = pool; - - rc = DosCreateMutexSem(NULL, &(new_mutex->hMutex), 0, FALSE); - *mutex = new_mutex; - - if (!rc) - apr_pool_cleanup_register(pool, new_mutex, thread_mutex_cleanup, apr_pool_cleanup_null); - - return APR_OS2_STATUS(rc); -} - - - -APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex) -{ - ULONG rc = DosRequestMutexSem(mutex->hMutex, SEM_INDEFINITE_WAIT); - return APR_OS2_STATUS(rc); -} - - - -APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex) -{ - ULONG rc = DosRequestMutexSem(mutex->hMutex, SEM_IMMEDIATE_RETURN); - return APR_OS2_STATUS(rc); -} - - - -APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex) -{ - ULONG rc = DosReleaseMutexSem(mutex->hMutex); - return APR_OS2_STATUS(rc); -} - - - -APR_DECLARE(apr_status_t) apr_thread_mutex_destroy(apr_thread_mutex_t *mutex) -{ - ULONG rc; - - if (mutex->hMutex == 0) - return APR_SUCCESS; - - while (DosReleaseMutexSem(mutex->hMutex) == 0); - - rc = DosCloseMutexSem(mutex->hMutex); - - if (!rc) { - mutex->hMutex = 0; - return APR_SUCCESS; - } - - return APR_FROM_OS_ERROR(rc); -} - -APR_POOL_IMPLEMENT_ACCESSOR(thread_mutex) - diff --git a/libs/apr/locks/os2/thread_rwlock.c b/libs/apr/locks/os2/thread_rwlock.c deleted file mode 100644 index 195a56bd..00000000 --- a/libs/apr/locks/os2/thread_rwlock.c +++ /dev/null @@ -1,200 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_arch_thread_rwlock.h" -#include "apr_arch_file_io.h" -#include - -static apr_status_t thread_rwlock_cleanup(void *therwlock) -{ - apr_thread_rwlock_t *rwlock = therwlock; - return apr_thread_rwlock_destroy(rwlock); -} - - - -APR_DECLARE(apr_status_t) apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock, - apr_pool_t *pool) -{ - apr_thread_rwlock_t *new_rwlock; - ULONG rc; - - new_rwlock = (apr_thread_rwlock_t *)apr_palloc(pool, sizeof(apr_thread_rwlock_t)); - new_rwlock->pool = pool; - new_rwlock->readers = 0; - - rc = DosCreateMutexSem(NULL, &(new_rwlock->write_lock), 0, FALSE); - - if (rc) - return APR_FROM_OS_ERROR(rc); - - rc = DosCreateEventSem(NULL, &(new_rwlock->read_done), 0, FALSE); - - if (rc) - return APR_FROM_OS_ERROR(rc); - - *rwlock = new_rwlock; - - if (!rc) - apr_pool_cleanup_register(pool, new_rwlock, thread_rwlock_cleanup, - apr_pool_cleanup_null); - - return APR_FROM_OS_ERROR(rc); -} - - - -APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock) -{ - ULONG rc, posts; - - rc = DosRequestMutexSem(rwlock->write_lock, SEM_INDEFINITE_WAIT); - - if (rc) - return APR_FROM_OS_ERROR(rc); - - /* We've successfully acquired the writer mutex so we can't be locked - * for write which means it's ok to add a reader lock. The writer mutex - * doubles as race condition protection for the readers counter. - */ - rwlock->readers++; - DosResetEventSem(rwlock->read_done, &posts); - rc = DosReleaseMutexSem(rwlock->write_lock); - return APR_FROM_OS_ERROR(rc); -} - - - -APR_DECLARE(apr_status_t) apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwlock) -{ - /* As above but with different wait time */ - ULONG rc, posts; - - rc = DosRequestMutexSem(rwlock->write_lock, SEM_IMMEDIATE_RETURN); - - if (rc) - return APR_FROM_OS_ERROR(rc); - - rwlock->readers++; - DosResetEventSem(rwlock->read_done, &posts); - rc = DosReleaseMutexSem(rwlock->write_lock); - return APR_FROM_OS_ERROR(rc); -} - - - -APR_DECLARE(apr_status_t) apr_thread_rwlock_wrlock(apr_thread_rwlock_t *rwlock) -{ - ULONG rc; - - rc = DosRequestMutexSem(rwlock->write_lock, SEM_INDEFINITE_WAIT); - - if (rc) - return APR_FROM_OS_ERROR(rc); - - /* We've got the writer lock but we have to wait for all readers to - * unlock before it's ok to use it - */ - - if (rwlock->readers) { - rc = DosWaitEventSem(rwlock->read_done, SEM_INDEFINITE_WAIT); - - if (rc) - DosReleaseMutexSem(rwlock->write_lock); - } - - return APR_FROM_OS_ERROR(rc); -} - - - -APR_DECLARE(apr_status_t) apr_thread_rwlock_trywrlock(apr_thread_rwlock_t *rwlock) -{ - ULONG rc; - - rc = DosRequestMutexSem(rwlock->write_lock, SEM_IMMEDIATE_RETURN); - - if (rc) - return APR_FROM_OS_ERROR(rc); - - /* We've got the writer lock but we have to wait for all readers to - * unlock before it's ok to use it - */ - - if (rwlock->readers) { - /* There are readers active, give up */ - DosReleaseMutexSem(rwlock->write_lock); - rc = ERROR_TIMEOUT; - } - - return APR_FROM_OS_ERROR(rc); -} - - - -APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock) -{ - ULONG rc; - - /* First, guess that we're unlocking a writer */ - rc = DosReleaseMutexSem(rwlock->write_lock); - - if (rc == ERROR_NOT_OWNER) { - /* Nope, we must have a read lock */ - if (rwlock->readers) { - DosEnterCritSec(); - rwlock->readers--; - - if (rwlock->readers == 0) { - DosPostEventSem(rwlock->read_done); - } - - DosExitCritSec(); - rc = 0; - } - } - - return APR_FROM_OS_ERROR(rc); -} - - - -APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t *rwlock) -{ - ULONG rc; - - if (rwlock->write_lock == 0) - return APR_SUCCESS; - - while (DosReleaseMutexSem(rwlock->write_lock) == 0); - - rc = DosCloseMutexSem(rwlock->write_lock); - - if (!rc) { - rwlock->write_lock = 0; - DosCloseEventSem(rwlock->read_done); - return APR_SUCCESS; - } - - return APR_FROM_OS_ERROR(rc); -} - -APR_POOL_IMPLEMENT_ACCESSOR(thread_rwlock) - diff --git a/libs/apr/locks/unix/global_mutex.c b/libs/apr/locks/unix/global_mutex.c deleted file mode 100644 index 18de7e45..00000000 --- a/libs/apr/locks/unix/global_mutex.c +++ /dev/null @@ -1,188 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_strings.h" -#include "apr_arch_global_mutex.h" -#include "apr_proc_mutex.h" -#include "apr_thread_mutex.h" -#include "apr_portable.h" - -static apr_status_t global_mutex_cleanup(void *data) -{ - apr_global_mutex_t *m = (apr_global_mutex_t *)data; - apr_status_t rv; - - rv = apr_proc_mutex_destroy(m->proc_mutex); - -#if APR_HAS_THREADS - if (m->thread_mutex) { - if (rv != APR_SUCCESS) { - (void)apr_thread_mutex_destroy(m->thread_mutex); - } - else { - rv = apr_thread_mutex_destroy(m->thread_mutex); - } - } -#endif /* APR_HAS_THREADS */ - - return rv; -} - -APR_DECLARE(apr_status_t) apr_global_mutex_create(apr_global_mutex_t **mutex, - const char *fname, - apr_lockmech_e mech, - apr_pool_t *pool) -{ - apr_status_t rv; - apr_global_mutex_t *m; - - m = (apr_global_mutex_t *)apr_palloc(pool, sizeof(*m)); - m->pool = pool; - - rv = apr_proc_mutex_create(&m->proc_mutex, fname, mech, m->pool); - if (rv != APR_SUCCESS) { - return rv; - } - -#if APR_HAS_THREADS - if (m->proc_mutex->inter_meth->flags & APR_PROCESS_LOCK_MECH_IS_GLOBAL) { - m->thread_mutex = NULL; /* We don't need a thread lock. */ - } - else { - rv = apr_thread_mutex_create(&m->thread_mutex, - APR_THREAD_MUTEX_DEFAULT, m->pool); - if (rv != APR_SUCCESS) { - rv = apr_proc_mutex_destroy(m->proc_mutex); - return rv; - } - } -#endif /* APR_HAS_THREADS */ - - apr_pool_cleanup_register(m->pool, (void *)m, - global_mutex_cleanup, apr_pool_cleanup_null); - *mutex = m; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_global_mutex_child_init( - apr_global_mutex_t **mutex, - const char *fname, - apr_pool_t *pool) -{ - apr_status_t rv; - - rv = apr_proc_mutex_child_init(&((*mutex)->proc_mutex), fname, pool); - return rv; -} - -APR_DECLARE(apr_status_t) apr_global_mutex_lock(apr_global_mutex_t *mutex) -{ - apr_status_t rv; - -#if APR_HAS_THREADS - if (mutex->thread_mutex) { - rv = apr_thread_mutex_lock(mutex->thread_mutex); - if (rv != APR_SUCCESS) { - return rv; - } - } -#endif /* APR_HAS_THREADS */ - - rv = apr_proc_mutex_lock(mutex->proc_mutex); - -#if APR_HAS_THREADS - if (rv != APR_SUCCESS) { - if (mutex->thread_mutex) { - (void)apr_thread_mutex_unlock(mutex->thread_mutex); - } - } -#endif /* APR_HAS_THREADS */ - - return rv; -} - -APR_DECLARE(apr_status_t) apr_global_mutex_trylock(apr_global_mutex_t *mutex) -{ - apr_status_t rv; - -#if APR_HAS_THREADS - if (mutex->thread_mutex) { - rv = apr_thread_mutex_trylock(mutex->thread_mutex); - if (rv != APR_SUCCESS) { - return rv; - } - } -#endif /* APR_HAS_THREADS */ - - rv = apr_proc_mutex_trylock(mutex->proc_mutex); - -#if APR_HAS_THREADS - if (rv != APR_SUCCESS) { - if (mutex->thread_mutex) { - (void)apr_thread_mutex_unlock(mutex->thread_mutex); - } - } -#endif /* APR_HAS_THREADS */ - - return rv; -} - -APR_DECLARE(apr_status_t) apr_global_mutex_unlock(apr_global_mutex_t *mutex) -{ - apr_status_t rv; - - rv = apr_proc_mutex_unlock(mutex->proc_mutex); -#if APR_HAS_THREADS - if (mutex->thread_mutex) { - if (rv != APR_SUCCESS) { - (void)apr_thread_mutex_unlock(mutex->thread_mutex); - } - else { - rv = apr_thread_mutex_unlock(mutex->thread_mutex); - } - } -#endif /* APR_HAS_THREADS */ - return rv; -} - -APR_DECLARE(apr_status_t) apr_os_global_mutex_get(apr_os_global_mutex_t *ospmutex, - apr_global_mutex_t *pmutex) -{ - ospmutex->pool = pmutex->pool; - ospmutex->proc_mutex = pmutex->proc_mutex; -#if APR_HAS_THREADS - ospmutex->thread_mutex = pmutex->thread_mutex; -#endif - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_global_mutex_destroy(apr_global_mutex_t *mutex) -{ - return apr_pool_cleanup_run(mutex->pool, mutex, global_mutex_cleanup); -} - -APR_DECLARE(const char *) apr_global_mutex_lockfile(apr_global_mutex_t *mutex) -{ - return apr_proc_mutex_lockfile(mutex->proc_mutex); -} - -APR_DECLARE(const char *) apr_global_mutex_name(apr_global_mutex_t *mutex) -{ - return apr_proc_mutex_name(mutex->proc_mutex); -} - -APR_POOL_IMPLEMENT_ACCESSOR(global_mutex) diff --git a/libs/apr/locks/unix/proc_mutex.c b/libs/apr/locks/unix/proc_mutex.c deleted file mode 100644 index f9637e03..00000000 --- a/libs/apr/locks/unix/proc_mutex.c +++ /dev/null @@ -1,982 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_strings.h" -#include "apr_arch_proc_mutex.h" -#include "apr_arch_file_io.h" /* for apr_mkstemp() */ -#include "apr_hash.h" - -APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex) -{ - return apr_pool_cleanup_run(mutex->pool, mutex, apr_proc_mutex_cleanup); -} - -#if APR_HAS_POSIXSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || \ - APR_HAS_PROC_PTHREAD_SERIALIZE || APR_HAS_SYSVSEM_SERIALIZE -static apr_status_t proc_mutex_no_child_init(apr_proc_mutex_t **mutex, - apr_pool_t *cont, - const char *fname) -{ - return APR_SUCCESS; -} -#endif - -#if APR_HAS_POSIXSEM_SERIALIZE - -#ifndef SEM_FAILED -#define SEM_FAILED (-1) -#endif - -static apr_status_t proc_mutex_posix_cleanup(void *mutex_) -{ - apr_proc_mutex_t *mutex = mutex_; - - if (sem_close(mutex->psem_interproc) < 0) { - return errno; - } - - return APR_SUCCESS; -} - -static unsigned int rshash (char *p) { - /* hash function from Robert Sedgwicks 'Algorithms in C' book */ - unsigned int b = 378551; - unsigned int a = 63689; - unsigned int retval = 0; - - for( ; *p; p++) - { - retval = retval * a + (*p); - a *= b; - } - - return retval; -} - -static apr_status_t proc_mutex_posix_create(apr_proc_mutex_t *new_mutex, - const char *fname) -{ - #define APR_POSIXSEM_NAME_MIN 13 - sem_t *psem; - char semname[32]; - - new_mutex->interproc = apr_palloc(new_mutex->pool, - sizeof(*new_mutex->interproc)); - /* - * This bogusness is to follow what appears to be the - * lowest common denominator in Posix semaphore naming: - * - start with '/' - * - be at most 14 chars - * - be unique and not match anything on the filesystem - * - * Because of this, we use fname to generate a (unique) hash - * and use that as the name of the semaphore. If no filename was - * given, we create one based on the time. We tuck the name - * away, since it might be useful for debugging. We use 2 hashing - * functions to try to avoid collisions. - * - * To make this as robust as possible, we initially try something - * larger (and hopefully more unique) and gracefully fail down to the - * LCD above. - * - * NOTE: Darwin (Mac OS X) seems to be the most restrictive - * implementation. Versions previous to Darwin 6.2 had the 14 - * char limit, but later rev's allow up to 31 characters. - * - */ - if (fname) { - apr_ssize_t flen = strlen(fname); - char *p = apr_pstrndup(new_mutex->pool, fname, strlen(fname)); - unsigned int h1, h2; - h1 = apr_hashfunc_default((const char *)p, &flen); - h2 = rshash(p); - apr_snprintf(semname, sizeof(semname), "/ApR.%xH%x", h1, h2); - } else { - apr_time_t now; - unsigned long sec; - unsigned long usec; - now = apr_time_now(); - sec = apr_time_sec(now); - usec = apr_time_usec(now); - apr_snprintf(semname, sizeof(semname), "/ApR.%lxZ%lx", sec, usec); - } - psem = sem_open(semname, O_CREAT | O_EXCL, 0644, 1); - if (psem == (sem_t *)SEM_FAILED) { - if (errno == ENAMETOOLONG) { - /* Oh well, good try */ - semname[APR_POSIXSEM_NAME_MIN] = '\0'; - } else { - return errno; - } - psem = sem_open(semname, O_CREAT | O_EXCL, 0644, 1); - } - - if (psem == (sem_t *)SEM_FAILED) { - return errno; - } - /* Ahhh. The joys of Posix sems. Predelete it... */ - sem_unlink(semname); - new_mutex->psem_interproc = psem; - new_mutex->fname = apr_pstrdup(new_mutex->pool, semname); - apr_pool_cleanup_register(new_mutex->pool, (void *)new_mutex, - apr_proc_mutex_cleanup, - apr_pool_cleanup_null); - return APR_SUCCESS; -} - -static apr_status_t proc_mutex_posix_acquire(apr_proc_mutex_t *mutex) -{ - if (sem_wait(mutex->psem_interproc) < 0) { - return errno; - } - mutex->curr_locked = 1; - return APR_SUCCESS; -} - -static apr_status_t proc_mutex_posix_tryacquire(apr_proc_mutex_t *mutex) -{ - if (sem_trywait(mutex->psem_interproc) < 0) { - if (errno == EAGAIN) { - return APR_EBUSY; - } - return errno; - } - mutex->curr_locked = 1; - return APR_SUCCESS; -} - -static apr_status_t proc_mutex_posix_release(apr_proc_mutex_t *mutex) -{ - mutex->curr_locked = 0; - if (sem_post(mutex->psem_interproc) < 0) { - /* any failure is probably fatal, so no big deal to leave - * ->curr_locked at 0. */ - return errno; - } - return APR_SUCCESS; -} - -static const apr_proc_mutex_unix_lock_methods_t mutex_posixsem_methods = -{ -#if APR_PROCESS_LOCK_IS_GLOBAL || !APR_HAS_THREADS || defined(POSIXSEM_IS_GLOBAL) - APR_PROCESS_LOCK_MECH_IS_GLOBAL, -#else - 0, -#endif - proc_mutex_posix_create, - proc_mutex_posix_acquire, - proc_mutex_posix_tryacquire, - proc_mutex_posix_release, - proc_mutex_posix_cleanup, - proc_mutex_no_child_init, - "posixsem" -}; - -#endif /* Posix sem implementation */ - -#if APR_HAS_SYSVSEM_SERIALIZE - -static struct sembuf proc_mutex_op_on; -static struct sembuf proc_mutex_op_try; -static struct sembuf proc_mutex_op_off; - -static void proc_mutex_sysv_setup(void) -{ - proc_mutex_op_on.sem_num = 0; - proc_mutex_op_on.sem_op = -1; - proc_mutex_op_on.sem_flg = SEM_UNDO; - proc_mutex_op_try.sem_num = 0; - proc_mutex_op_try.sem_op = -1; - proc_mutex_op_try.sem_flg = SEM_UNDO | IPC_NOWAIT; - proc_mutex_op_off.sem_num = 0; - proc_mutex_op_off.sem_op = 1; - proc_mutex_op_off.sem_flg = SEM_UNDO; -} - -static apr_status_t proc_mutex_sysv_cleanup(void *mutex_) -{ - apr_proc_mutex_t *mutex=mutex_; - union semun ick; - - if (mutex->interproc->filedes != -1) { - ick.val = 0; - semctl(mutex->interproc->filedes, 0, IPC_RMID, ick); - } - return APR_SUCCESS; -} - -static apr_status_t proc_mutex_sysv_create(apr_proc_mutex_t *new_mutex, - const char *fname) -{ - union semun ick; - apr_status_t rv; - - new_mutex->interproc = apr_palloc(new_mutex->pool, sizeof(*new_mutex->interproc)); - new_mutex->interproc->filedes = semget(IPC_PRIVATE, 1, IPC_CREAT | 0600); - - if (new_mutex->interproc->filedes < 0) { - rv = errno; - proc_mutex_sysv_cleanup(new_mutex); - return rv; - } - ick.val = 1; - if (semctl(new_mutex->interproc->filedes, 0, SETVAL, ick) < 0) { - rv = errno; - proc_mutex_sysv_cleanup(new_mutex); - return rv; - } - new_mutex->curr_locked = 0; - apr_pool_cleanup_register(new_mutex->pool, - (void *)new_mutex, apr_proc_mutex_cleanup, - apr_pool_cleanup_null); - return APR_SUCCESS; -} - -static apr_status_t proc_mutex_sysv_acquire(apr_proc_mutex_t *mutex) -{ - int rc; - - do { - rc = semop(mutex->interproc->filedes, &proc_mutex_op_on, 1); - } while (rc < 0 && errno == EINTR); - if (rc < 0) { - return errno; - } - mutex->curr_locked = 1; - return APR_SUCCESS; -} - -static apr_status_t proc_mutex_sysv_tryacquire(apr_proc_mutex_t *mutex) -{ - int rc; - - do { - rc = semop(mutex->interproc->filedes, &proc_mutex_op_try, 1); - } while (rc < 0 && errno == EINTR); - if (rc < 0) { - if (errno == EAGAIN) { - return APR_EBUSY; - } - return errno; - } - mutex->curr_locked = 1; - return APR_SUCCESS; -} - -static apr_status_t proc_mutex_sysv_release(apr_proc_mutex_t *mutex) -{ - int rc; - - mutex->curr_locked = 0; - do { - rc = semop(mutex->interproc->filedes, &proc_mutex_op_off, 1); - } while (rc < 0 && errno == EINTR); - if (rc < 0) { - return errno; - } - return APR_SUCCESS; -} - -static const apr_proc_mutex_unix_lock_methods_t mutex_sysv_methods = -{ -#if APR_PROCESS_LOCK_IS_GLOBAL || !APR_HAS_THREADS || defined(SYSVSEM_IS_GLOBAL) - APR_PROCESS_LOCK_MECH_IS_GLOBAL, -#else - 0, -#endif - proc_mutex_sysv_create, - proc_mutex_sysv_acquire, - proc_mutex_sysv_tryacquire, - proc_mutex_sysv_release, - proc_mutex_sysv_cleanup, - proc_mutex_no_child_init, - "sysvsem" -}; - -#endif /* SysV sem implementation */ - -#if APR_HAS_PROC_PTHREAD_SERIALIZE - -static apr_status_t proc_mutex_proc_pthread_cleanup(void *mutex_) -{ - apr_proc_mutex_t *mutex=mutex_; - apr_status_t rv; - - if (mutex->curr_locked == 1) { - if ((rv = pthread_mutex_unlock(mutex->pthread_interproc))) { -#ifdef HAVE_ZOS_PTHREADS - rv = errno; -#endif - return rv; - } - } - /* curr_locked is set to -1 until the mutex has been created */ - if (mutex->curr_locked != -1) { - if ((rv = pthread_mutex_destroy(mutex->pthread_interproc))) { -#ifdef HAVE_ZOS_PTHREADS - rv = errno; -#endif - return rv; - } - } - if (munmap((caddr_t)mutex->pthread_interproc, sizeof(pthread_mutex_t))) { - return errno; - } - return APR_SUCCESS; -} - -static apr_status_t proc_mutex_proc_pthread_create(apr_proc_mutex_t *new_mutex, - const char *fname) -{ - apr_status_t rv; - int fd; - pthread_mutexattr_t mattr; - - fd = open("/dev/zero", O_RDWR); - if (fd < 0) { - return errno; - } - - new_mutex->pthread_interproc = (pthread_mutex_t *)mmap( - (caddr_t) 0, - sizeof(pthread_mutex_t), - PROT_READ | PROT_WRITE, MAP_SHARED, - fd, 0); - if (new_mutex->pthread_interproc == (pthread_mutex_t *) (caddr_t) -1) { - close(fd); - return errno; - } - close(fd); - - new_mutex->curr_locked = -1; /* until the mutex has been created */ - - if ((rv = pthread_mutexattr_init(&mattr))) { -#ifdef HAVE_ZOS_PTHREADS - rv = errno; -#endif - proc_mutex_proc_pthread_cleanup(new_mutex); - return rv; - } - if ((rv = pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED))) { -#ifdef HAVE_ZOS_PTHREADS - rv = errno; -#endif - proc_mutex_proc_pthread_cleanup(new_mutex); - pthread_mutexattr_destroy(&mattr); - return rv; - } - -#ifdef HAVE_PTHREAD_MUTEX_ROBUST - if ((rv = pthread_mutexattr_setrobust_np(&mattr, - PTHREAD_MUTEX_ROBUST_NP))) { -#ifdef HAVE_ZOS_PTHREADS - rv = errno; -#endif - proc_mutex_proc_pthread_cleanup(new_mutex); - pthread_mutexattr_destroy(&mattr); - return rv; - } - if ((rv = pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT))) { -#ifdef HAVE_ZOS_PTHREADS - rv = errno; -#endif - proc_mutex_proc_pthread_cleanup(new_mutex); - pthread_mutexattr_destroy(&mattr); - return rv; - } -#endif /* HAVE_PTHREAD_MUTEX_ROBUST */ - - if ((rv = pthread_mutex_init(new_mutex->pthread_interproc, &mattr))) { -#ifdef HAVE_ZOS_PTHREADS - rv = errno; -#endif - proc_mutex_proc_pthread_cleanup(new_mutex); - pthread_mutexattr_destroy(&mattr); - return rv; - } - - new_mutex->curr_locked = 0; /* mutex created now */ - - if ((rv = pthread_mutexattr_destroy(&mattr))) { -#ifdef HAVE_ZOS_PTHREADS - rv = errno; -#endif - proc_mutex_proc_pthread_cleanup(new_mutex); - return rv; - } - - apr_pool_cleanup_register(new_mutex->pool, - (void *)new_mutex, - apr_proc_mutex_cleanup, - apr_pool_cleanup_null); - return APR_SUCCESS; -} - -static apr_status_t proc_mutex_proc_pthread_acquire(apr_proc_mutex_t *mutex) -{ - apr_status_t rv; - - if ((rv = pthread_mutex_lock(mutex->pthread_interproc))) { -#ifdef HAVE_ZOS_PTHREADS - rv = errno; -#endif -#ifdef HAVE_PTHREAD_MUTEX_ROBUST - /* Okay, our owner died. Let's try to make it consistent again. */ - if (rv == EOWNERDEAD) { - pthread_mutex_consistent_np(mutex->pthread_interproc); - } - else - return rv; -#else - return rv; -#endif - } - mutex->curr_locked = 1; - return APR_SUCCESS; -} - -static apr_status_t proc_mutex_proc_pthread_tryacquire(apr_proc_mutex_t *mutex) -{ - apr_status_t rv; - - if ((rv = pthread_mutex_trylock(mutex->pthread_interproc))) { -#ifdef HAVE_ZOS_PTHREADS - rv = errno; -#endif - if (rv == EBUSY) { - return APR_EBUSY; - } -#ifdef HAVE_PTHREAD_MUTEX_ROBUST - /* Okay, our owner died. Let's try to make it consistent again. */ - if (rv == EOWNERDEAD) { - pthread_mutex_consistent_np(mutex->pthread_interproc); - rv = APR_SUCCESS; - } - else - return rv; -#else - return rv; -#endif - } - mutex->curr_locked = 1; - return rv; -} - -static apr_status_t proc_mutex_proc_pthread_release(apr_proc_mutex_t *mutex) -{ - apr_status_t rv; - - mutex->curr_locked = 0; - if ((rv = pthread_mutex_unlock(mutex->pthread_interproc))) { -#ifdef HAVE_ZOS_PTHREADS - rv = errno; -#endif - return rv; - } - return APR_SUCCESS; -} - -static const apr_proc_mutex_unix_lock_methods_t mutex_proc_pthread_methods = -{ - APR_PROCESS_LOCK_MECH_IS_GLOBAL, - proc_mutex_proc_pthread_create, - proc_mutex_proc_pthread_acquire, - proc_mutex_proc_pthread_tryacquire, - proc_mutex_proc_pthread_release, - proc_mutex_proc_pthread_cleanup, - proc_mutex_no_child_init, - "pthread" -}; - -#endif - -#if APR_HAS_FCNTL_SERIALIZE - -static struct flock proc_mutex_lock_it; -static struct flock proc_mutex_unlock_it; - -static apr_status_t proc_mutex_fcntl_release(apr_proc_mutex_t *); - -static void proc_mutex_fcntl_setup(void) -{ - proc_mutex_lock_it.l_whence = SEEK_SET; /* from current point */ - proc_mutex_lock_it.l_start = 0; /* -"- */ - proc_mutex_lock_it.l_len = 0; /* until end of file */ - proc_mutex_lock_it.l_type = F_WRLCK; /* set exclusive/write lock */ - proc_mutex_lock_it.l_pid = 0; /* pid not actually interesting */ - proc_mutex_unlock_it.l_whence = SEEK_SET; /* from current point */ - proc_mutex_unlock_it.l_start = 0; /* -"- */ - proc_mutex_unlock_it.l_len = 0; /* until end of file */ - proc_mutex_unlock_it.l_type = F_UNLCK; /* set exclusive/write lock */ - proc_mutex_unlock_it.l_pid = 0; /* pid not actually interesting */ -} - -static apr_status_t proc_mutex_fcntl_cleanup(void *mutex_) -{ - apr_status_t status; - apr_proc_mutex_t *mutex=mutex_; - - if (mutex->curr_locked == 1) { - status = proc_mutex_fcntl_release(mutex); - if (status != APR_SUCCESS) - return status; - } - - return apr_file_close(mutex->interproc); -} - -static apr_status_t proc_mutex_fcntl_create(apr_proc_mutex_t *new_mutex, - const char *fname) -{ - int rv; - - if (fname) { - new_mutex->fname = apr_pstrdup(new_mutex->pool, fname); - rv = apr_file_open(&new_mutex->interproc, new_mutex->fname, - APR_FOPEN_CREATE | APR_FOPEN_WRITE | APR_FOPEN_EXCL, - APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD, - new_mutex->pool); - } - else { - new_mutex->fname = apr_pstrdup(new_mutex->pool, "/tmp/aprXXXXXX"); - rv = apr_file_mktemp(&new_mutex->interproc, new_mutex->fname, - APR_FOPEN_CREATE | APR_FOPEN_WRITE | APR_FOPEN_EXCL, - new_mutex->pool); - } - - if (rv != APR_SUCCESS) { - return rv; - } - - new_mutex->curr_locked = 0; - unlink(new_mutex->fname); - apr_pool_cleanup_register(new_mutex->pool, - (void*)new_mutex, - apr_proc_mutex_cleanup, - apr_pool_cleanup_null); - return APR_SUCCESS; -} - -static apr_status_t proc_mutex_fcntl_acquire(apr_proc_mutex_t *mutex) -{ - int rc; - - do { - rc = fcntl(mutex->interproc->filedes, F_SETLKW, &proc_mutex_lock_it); - } while (rc < 0 && errno == EINTR); - if (rc < 0) { - return errno; - } - mutex->curr_locked=1; - return APR_SUCCESS; -} - -static apr_status_t proc_mutex_fcntl_tryacquire(apr_proc_mutex_t *mutex) -{ - int rc; - - do { - rc = fcntl(mutex->interproc->filedes, F_SETLK, &proc_mutex_lock_it); - } while (rc < 0 && errno == EINTR); - if (rc < 0) { -#if FCNTL_TRYACQUIRE_EACCES - if (errno == EACCES) { -#else - if (errno == EAGAIN) { -#endif - return APR_EBUSY; - } - return errno; - } - mutex->curr_locked = 1; - return APR_SUCCESS; -} - -static apr_status_t proc_mutex_fcntl_release(apr_proc_mutex_t *mutex) -{ - int rc; - - mutex->curr_locked=0; - do { - rc = fcntl(mutex->interproc->filedes, F_SETLKW, &proc_mutex_unlock_it); - } while (rc < 0 && errno == EINTR); - if (rc < 0) { - return errno; - } - return APR_SUCCESS; -} - -static const apr_proc_mutex_unix_lock_methods_t mutex_fcntl_methods = -{ -#if APR_PROCESS_LOCK_IS_GLOBAL || !APR_HAS_THREADS || defined(FCNTL_IS_GLOBAL) - APR_PROCESS_LOCK_MECH_IS_GLOBAL, -#else - 0, -#endif - proc_mutex_fcntl_create, - proc_mutex_fcntl_acquire, - proc_mutex_fcntl_tryacquire, - proc_mutex_fcntl_release, - proc_mutex_fcntl_cleanup, - proc_mutex_no_child_init, - "fcntl" -}; - -#endif /* fcntl implementation */ - -#if APR_HAS_FLOCK_SERIALIZE - -static apr_status_t proc_mutex_flock_release(apr_proc_mutex_t *); - -static apr_status_t proc_mutex_flock_cleanup(void *mutex_) -{ - apr_status_t status; - apr_proc_mutex_t *mutex=mutex_; - - if (mutex->curr_locked == 1) { - status = proc_mutex_flock_release(mutex); - if (status != APR_SUCCESS) - return status; - } - if (mutex->interproc) { /* if it was opened properly */ - apr_file_close(mutex->interproc); - } - unlink(mutex->fname); - return APR_SUCCESS; -} - -static apr_status_t proc_mutex_flock_create(apr_proc_mutex_t *new_mutex, - const char *fname) -{ - int rv; - - if (fname) { - new_mutex->fname = apr_pstrdup(new_mutex->pool, fname); - rv = apr_file_open(&new_mutex->interproc, new_mutex->fname, - APR_FOPEN_CREATE | APR_FOPEN_WRITE | APR_FOPEN_EXCL, - APR_UREAD | APR_UWRITE, - new_mutex->pool); - } - else { - new_mutex->fname = apr_pstrdup(new_mutex->pool, "/tmp/aprXXXXXX"); - rv = apr_file_mktemp(&new_mutex->interproc, new_mutex->fname, - APR_FOPEN_CREATE | APR_FOPEN_WRITE | APR_FOPEN_EXCL, - new_mutex->pool); - } - - if (rv != APR_SUCCESS) { - proc_mutex_flock_cleanup(new_mutex); - return errno; - } - new_mutex->curr_locked = 0; - apr_pool_cleanup_register(new_mutex->pool, (void *)new_mutex, - apr_proc_mutex_cleanup, - apr_pool_cleanup_null); - return APR_SUCCESS; -} - -static apr_status_t proc_mutex_flock_acquire(apr_proc_mutex_t *mutex) -{ - int rc; - - do { - rc = flock(mutex->interproc->filedes, LOCK_EX); - } while (rc < 0 && errno == EINTR); - if (rc < 0) { - return errno; - } - mutex->curr_locked = 1; - return APR_SUCCESS; -} - -static apr_status_t proc_mutex_flock_tryacquire(apr_proc_mutex_t *mutex) -{ - int rc; - - do { - rc = flock(mutex->interproc->filedes, LOCK_EX | LOCK_NB); - } while (rc < 0 && errno == EINTR); - if (rc < 0) { - if (errno == EWOULDBLOCK || errno == EAGAIN) { - return APR_EBUSY; - } - return errno; - } - mutex->curr_locked = 1; - return APR_SUCCESS; -} - -static apr_status_t proc_mutex_flock_release(apr_proc_mutex_t *mutex) -{ - int rc; - - mutex->curr_locked = 0; - do { - rc = flock(mutex->interproc->filedes, LOCK_UN); - } while (rc < 0 && errno == EINTR); - if (rc < 0) { - return errno; - } - return APR_SUCCESS; -} - -static apr_status_t proc_mutex_flock_child_init(apr_proc_mutex_t **mutex, - apr_pool_t *pool, - const char *fname) -{ - apr_proc_mutex_t *new_mutex; - int rv; - - new_mutex = (apr_proc_mutex_t *)apr_palloc(pool, sizeof(apr_proc_mutex_t)); - - memcpy(new_mutex, *mutex, sizeof *new_mutex); - new_mutex->pool = pool; - if (!fname) { - fname = (*mutex)->fname; - } - new_mutex->fname = apr_pstrdup(pool, fname); - rv = apr_file_open(&new_mutex->interproc, new_mutex->fname, - APR_FOPEN_WRITE, 0, new_mutex->pool); - if (rv != APR_SUCCESS) { - return rv; - } - *mutex = new_mutex; - return APR_SUCCESS; -} - -static const apr_proc_mutex_unix_lock_methods_t mutex_flock_methods = -{ -#if APR_PROCESS_LOCK_IS_GLOBAL || !APR_HAS_THREADS || defined(FLOCK_IS_GLOBAL) - APR_PROCESS_LOCK_MECH_IS_GLOBAL, -#else - 0, -#endif - proc_mutex_flock_create, - proc_mutex_flock_acquire, - proc_mutex_flock_tryacquire, - proc_mutex_flock_release, - proc_mutex_flock_cleanup, - proc_mutex_flock_child_init, - "flock" -}; - -#endif /* flock implementation */ - -void apr_proc_mutex_unix_setup_lock(void) -{ - /* setup only needed for sysvsem and fnctl */ -#if APR_HAS_SYSVSEM_SERIALIZE - proc_mutex_sysv_setup(); -#endif -#if APR_HAS_FCNTL_SERIALIZE - proc_mutex_fcntl_setup(); -#endif -} - -static apr_status_t proc_mutex_choose_method(apr_proc_mutex_t *new_mutex, apr_lockmech_e mech) -{ - switch (mech) { - case APR_LOCK_FCNTL: -#if APR_HAS_FCNTL_SERIALIZE - new_mutex->inter_meth = &mutex_fcntl_methods; -#else - return APR_ENOTIMPL; -#endif - break; - case APR_LOCK_FLOCK: -#if APR_HAS_FLOCK_SERIALIZE - new_mutex->inter_meth = &mutex_flock_methods; -#else - return APR_ENOTIMPL; -#endif - break; - case APR_LOCK_SYSVSEM: -#if APR_HAS_SYSVSEM_SERIALIZE - new_mutex->inter_meth = &mutex_sysv_methods; -#else - return APR_ENOTIMPL; -#endif - break; - case APR_LOCK_POSIXSEM: -#if APR_HAS_POSIXSEM_SERIALIZE - new_mutex->inter_meth = &mutex_posixsem_methods; -#else - return APR_ENOTIMPL; -#endif - break; - case APR_LOCK_PROC_PTHREAD: -#if APR_HAS_PROC_PTHREAD_SERIALIZE - new_mutex->inter_meth = &mutex_proc_pthread_methods; -#else - return APR_ENOTIMPL; -#endif - break; - case APR_LOCK_DEFAULT: -#if APR_USE_FLOCK_SERIALIZE - new_mutex->inter_meth = &mutex_flock_methods; -#elif APR_USE_SYSVSEM_SERIALIZE - new_mutex->inter_meth = &mutex_sysv_methods; -#elif APR_USE_FCNTL_SERIALIZE - new_mutex->inter_meth = &mutex_fcntl_methods; -#elif APR_USE_PROC_PTHREAD_SERIALIZE - new_mutex->inter_meth = &mutex_proc_pthread_methods; -#elif APR_USE_POSIXSEM_SERIALIZE - new_mutex->inter_meth = &mutex_posixsem_methods; -#else - return APR_ENOTIMPL; -#endif - break; - default: - return APR_ENOTIMPL; - } - return APR_SUCCESS; -} - -APR_DECLARE(const char *) apr_proc_mutex_defname(void) -{ - apr_status_t rv; - apr_proc_mutex_t mutex; - - if ((rv = proc_mutex_choose_method(&mutex, APR_LOCK_DEFAULT)) != APR_SUCCESS) { - return "unknown"; - } - mutex.meth = mutex.inter_meth; - - return apr_proc_mutex_name(&mutex); -} - -static apr_status_t proc_mutex_create(apr_proc_mutex_t *new_mutex, apr_lockmech_e mech, const char *fname) -{ - apr_status_t rv; - - if ((rv = proc_mutex_choose_method(new_mutex, mech)) != APR_SUCCESS) { - return rv; - } - - new_mutex->meth = new_mutex->inter_meth; - - if ((rv = new_mutex->meth->create(new_mutex, fname)) != APR_SUCCESS) { - return rv; - } - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex, - const char *fname, - apr_lockmech_e mech, - apr_pool_t *pool) -{ - apr_proc_mutex_t *new_mutex; - apr_status_t rv; - - new_mutex = apr_pcalloc(pool, sizeof(apr_proc_mutex_t)); - new_mutex->pool = pool; - - if ((rv = proc_mutex_create(new_mutex, mech, fname)) != APR_SUCCESS) - return rv; - - *mutex = new_mutex; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_child_init(apr_proc_mutex_t **mutex, - const char *fname, - apr_pool_t *pool) -{ - return (*mutex)->meth->child_init(mutex, pool, fname); -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_lock(apr_proc_mutex_t *mutex) -{ - return mutex->meth->acquire(mutex); -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex) -{ - return mutex->meth->tryacquire(mutex); -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_unlock(apr_proc_mutex_t *mutex) -{ - return mutex->meth->release(mutex); -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_cleanup(void *mutex) -{ - return ((apr_proc_mutex_t *)mutex)->meth->cleanup(mutex); -} - -APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex) -{ - return mutex->meth->name; -} - -APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex) -{ - /* POSIX sems use the fname field but don't use a file, - * so be careful. */ -#if APR_HAS_FLOCK_SERIALIZE - if (mutex->meth == &mutex_flock_methods) { - return mutex->fname; - } -#endif -#if APR_HAS_FCNTL_SERIALIZE - if (mutex->meth == &mutex_fcntl_methods) { - return mutex->fname; - } -#endif - return NULL; -} - -APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex) - -/* Implement OS-specific accessors defined in apr_portable.h */ - -APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex, - apr_proc_mutex_t *pmutex) -{ -#if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE || APR_HAS_POSIXSEM_SERIALIZE - ospmutex->crossproc = pmutex->interproc->filedes; -#endif -#if APR_HAS_PROC_PTHREAD_SERIALIZE - ospmutex->pthread_interproc = pmutex->pthread_interproc; -#endif - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex, - apr_os_proc_mutex_t *ospmutex, - apr_pool_t *pool) -{ - if (pool == NULL) { - return APR_ENOPOOL; - } - if ((*pmutex) == NULL) { - (*pmutex) = (apr_proc_mutex_t *)apr_pcalloc(pool, - sizeof(apr_proc_mutex_t)); - (*pmutex)->pool = pool; - } -#if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE || APR_HAS_POSIXSEM_SERIALIZE - apr_os_file_put(&(*pmutex)->interproc, &ospmutex->crossproc, 0, pool); -#endif -#if APR_HAS_PROC_PTHREAD_SERIALIZE - (*pmutex)->pthread_interproc = ospmutex->pthread_interproc; -#endif - return APR_SUCCESS; -} - diff --git a/libs/apr/locks/unix/thread_cond.c b/libs/apr/locks/unix/thread_cond.c deleted file mode 100644 index db7dd4f0..00000000 --- a/libs/apr/locks/unix/thread_cond.c +++ /dev/null @@ -1,135 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" - -#if APR_HAS_THREADS - -#include "apr_arch_thread_mutex.h" -#include "apr_arch_thread_cond.h" - -static apr_status_t thread_cond_cleanup(void *data) -{ - apr_thread_cond_t *cond = (apr_thread_cond_t *)data; - apr_status_t rv; - - rv = pthread_cond_destroy(&cond->cond); -#ifdef HAVE_ZOS_PTHREADS - if (rv) { - rv = errno; - } -#endif - return rv; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond, - apr_pool_t *pool) -{ - apr_thread_cond_t *new_cond; - apr_status_t rv; - - new_cond = apr_palloc(pool, sizeof(apr_thread_cond_t)); - - new_cond->pool = pool; - - if ((rv = pthread_cond_init(&new_cond->cond, NULL))) { -#ifdef HAVE_ZOS_PTHREADS - rv = errno; -#endif - return rv; - } - - apr_pool_cleanup_register(new_cond->pool, - (void *)new_cond, thread_cond_cleanup, - apr_pool_cleanup_null); - - *cond = new_cond; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex) -{ - apr_status_t rv; - - rv = pthread_cond_wait(&cond->cond, &mutex->mutex); -#ifdef HAVE_ZOS_PTHREADS - if (rv) { - rv = errno; - } -#endif - return rv; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex, - apr_interval_time_t timeout) -{ - apr_status_t rv; - apr_time_t then; - struct timespec abstime; - - then = apr_time_now() + timeout; - abstime.tv_sec = apr_time_sec(then); - abstime.tv_nsec = apr_time_usec(then) * 1000; /* nanoseconds */ - - rv = pthread_cond_timedwait(&cond->cond, &mutex->mutex, &abstime); -#ifdef HAVE_ZOS_PTHREADS - if (rv) { - rv = errno; - } -#endif - if (ETIMEDOUT == rv) { - return APR_TIMEUP; - } - return rv; -} - - -APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond) -{ - apr_status_t rv; - - rv = pthread_cond_signal(&cond->cond); -#ifdef HAVE_ZOS_PTHREADS - if (rv) { - rv = errno; - } -#endif - return rv; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond) -{ - apr_status_t rv; - - rv = pthread_cond_broadcast(&cond->cond); -#ifdef HAVE_ZOS_PTHREADS - if (rv) { - rv = errno; - } -#endif - return rv; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond) -{ - return apr_pool_cleanup_run(cond->pool, cond, thread_cond_cleanup); -} - -APR_POOL_IMPLEMENT_ACCESSOR(thread_cond) - -#endif /* APR_HAS_THREADS */ diff --git a/libs/apr/locks/unix/thread_mutex.c b/libs/apr/locks/unix/thread_mutex.c deleted file mode 100644 index 73fd1e14..00000000 --- a/libs/apr/locks/unix/thread_mutex.c +++ /dev/null @@ -1,138 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_thread_mutex.h" -#define APR_WANT_MEMFUNC -#include "apr_want.h" - -#if APR_HAS_THREADS - -static apr_status_t thread_mutex_cleanup(void *data) -{ - apr_thread_mutex_t *mutex = data; - apr_status_t rv; - - rv = pthread_mutex_destroy(&mutex->mutex); -#ifdef HAVE_ZOS_PTHREADS - if (rv) { - rv = errno; - } -#endif - return rv; -} - -APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex, - unsigned int flags, - apr_pool_t *pool) -{ - apr_thread_mutex_t *new_mutex; - apr_status_t rv; - -#ifndef HAVE_PTHREAD_MUTEX_RECURSIVE - if (flags & APR_THREAD_MUTEX_NESTED) { - return APR_ENOTIMPL; - } -#endif - - new_mutex = apr_pcalloc(pool, sizeof(apr_thread_mutex_t)); - new_mutex->pool = pool; - -#ifdef HAVE_PTHREAD_MUTEX_RECURSIVE - if (flags & APR_THREAD_MUTEX_NESTED) { - pthread_mutexattr_t mattr; - - rv = pthread_mutexattr_init(&mattr); - if (rv) return rv; - - rv = pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE); - if (rv) { - pthread_mutexattr_destroy(&mattr); - return rv; - } - - rv = pthread_mutex_init(&new_mutex->mutex, &mattr); - - pthread_mutexattr_destroy(&mattr); - } else -#endif - rv = pthread_mutex_init(&new_mutex->mutex, NULL); - - if (rv) { -#ifdef HAVE_ZOS_PTHREADS - rv = errno; -#endif - return rv; - } - - apr_pool_cleanup_register(new_mutex->pool, - new_mutex, thread_mutex_cleanup, - apr_pool_cleanup_null); - - *mutex = new_mutex; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex) -{ - apr_status_t rv; - - rv = pthread_mutex_lock(&mutex->mutex); -#ifdef HAVE_ZOS_PTHREADS - if (rv) { - rv = errno; - } -#endif - - return rv; -} - -APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex) -{ - apr_status_t rv; - - rv = pthread_mutex_trylock(&mutex->mutex); - if (rv) { -#ifdef HAVE_ZOS_PTHREADS - rv = errno; -#endif - return (rv == EBUSY) ? APR_EBUSY : rv; - } - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex) -{ - apr_status_t status; - - status = pthread_mutex_unlock(&mutex->mutex); -#ifdef HAVE_ZOS_PTHREADS - if (status) { - status = errno; - } -#endif - - return status; -} - -APR_DECLARE(apr_status_t) apr_thread_mutex_destroy(apr_thread_mutex_t *mutex) -{ - return apr_pool_cleanup_run(mutex->pool, mutex, thread_mutex_cleanup); -} - -APR_POOL_IMPLEMENT_ACCESSOR(thread_mutex) - -#endif /* APR_HAS_THREADS */ diff --git a/libs/apr/locks/unix/thread_rwlock.c b/libs/apr/locks/unix/thread_rwlock.c deleted file mode 100644 index 0f8b7a79..00000000 --- a/libs/apr/locks/unix/thread_rwlock.c +++ /dev/null @@ -1,181 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_thread_rwlock.h" -#include "apr_private.h" - -#if APR_HAS_THREADS - -#ifdef HAVE_PTHREAD_RWLOCKS - -/* The rwlock must be initialized but not locked by any thread when - * cleanup is called. */ -static apr_status_t thread_rwlock_cleanup(void *data) -{ - apr_thread_rwlock_t *rwlock = (apr_thread_rwlock_t *)data; - apr_status_t stat; - - stat = pthread_rwlock_destroy(&rwlock->rwlock); -#ifdef HAVE_ZOS_PTHREADS - if (stat) { - stat = errno; - } -#endif - return stat; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock, - apr_pool_t *pool) -{ - apr_thread_rwlock_t *new_rwlock; - apr_status_t stat; - - new_rwlock = apr_palloc(pool, sizeof(apr_thread_rwlock_t)); - new_rwlock->pool = pool; - - if ((stat = pthread_rwlock_init(&new_rwlock->rwlock, NULL))) { -#ifdef HAVE_ZOS_PTHREADS - stat = errno; -#endif - return stat; - } - - apr_pool_cleanup_register(new_rwlock->pool, - (void *)new_rwlock, thread_rwlock_cleanup, - apr_pool_cleanup_null); - - *rwlock = new_rwlock; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock) -{ - apr_status_t stat; - - stat = pthread_rwlock_rdlock(&rwlock->rwlock); -#ifdef HAVE_ZOS_PTHREADS - if (stat) { - stat = errno; - } -#endif - return stat; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwlock) -{ - apr_status_t stat; - - stat = pthread_rwlock_tryrdlock(&rwlock->rwlock); -#ifdef HAVE_ZOS_PTHREADS - if (stat) { - stat = errno; - } -#endif - /* Normalize the return code. */ - if (stat == EBUSY) - stat = APR_EBUSY; - return stat; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_wrlock(apr_thread_rwlock_t *rwlock) -{ - apr_status_t stat; - - stat = pthread_rwlock_wrlock(&rwlock->rwlock); -#ifdef HAVE_ZOS_PTHREADS - if (stat) { - stat = errno; - } -#endif - return stat; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_trywrlock(apr_thread_rwlock_t *rwlock) -{ - apr_status_t stat; - - stat = pthread_rwlock_trywrlock(&rwlock->rwlock); -#ifdef HAVE_ZOS_PTHREADS - if (stat) { - stat = errno; - } -#endif - /* Normalize the return code. */ - if (stat == EBUSY) - stat = APR_EBUSY; - return stat; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock) -{ - apr_status_t stat; - - stat = pthread_rwlock_unlock(&rwlock->rwlock); -#ifdef HAVE_ZOS_PTHREADS - if (stat) { - stat = errno; - } -#endif - return stat; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t *rwlock) -{ - return apr_pool_cleanup_run(rwlock->pool, rwlock, thread_rwlock_cleanup); -} - -#else /* HAVE_PTHREAD_RWLOCKS */ - -APR_DECLARE(apr_status_t) apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock, - apr_pool_t *pool) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwlock) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_wrlock(apr_thread_rwlock_t *rwlock) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_trywrlock(apr_thread_rwlock_t *rwlock) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t *rwlock) -{ - return APR_ENOTIMPL; -} - -#endif /* HAVE_PTHREAD_RWLOCKS */ -APR_POOL_IMPLEMENT_ACCESSOR(thread_rwlock) - -#endif /* APR_HAS_THREADS */ diff --git a/libs/apr/locks/win32/proc_mutex.c b/libs/apr/locks/win32/proc_mutex.c deleted file mode 100644 index 3bd25efa..00000000 --- a/libs/apr/locks/win32/proc_mutex.c +++ /dev/null @@ -1,228 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_arch_file_io.h" -#include "apr_arch_proc_mutex.h" -#include "apr_arch_misc.h" - -static apr_status_t proc_mutex_cleanup(void *mutex_) -{ - apr_proc_mutex_t *mutex = mutex_; - - if (mutex->handle) { - if (CloseHandle(mutex->handle) == 0) { - return apr_get_os_error(); - } - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex, - const char *fname, - apr_lockmech_e mech, - apr_pool_t *pool) -{ - HANDLE hMutex; - void *mutexkey; - - /* res_name_from_filename turns fname into a pseduo-name - * without slashes or backslashes, and prepends the \global - * prefix on Win2K and later - */ - if (fname) { - mutexkey = res_name_from_filename(fname, 1, pool); - } - else { - mutexkey = NULL; - } - -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - hMutex = CreateMutexW(NULL, FALSE, mutexkey); - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - hMutex = CreateMutexA(NULL, FALSE, mutexkey); - } -#endif - - if (!hMutex) { - return apr_get_os_error(); - } - - *mutex = (apr_proc_mutex_t *)apr_palloc(pool, sizeof(apr_proc_mutex_t)); - (*mutex)->pool = pool; - (*mutex)->handle = hMutex; - (*mutex)->fname = fname; - apr_pool_cleanup_register((*mutex)->pool, *mutex, - proc_mutex_cleanup, apr_pool_cleanup_null); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_child_init(apr_proc_mutex_t **mutex, - const char *fname, - apr_pool_t *pool) -{ - HANDLE hMutex; - void *mutexkey; - - if (!fname) { - /* Reinitializing unnamed mutexes is a noop in the Unix code. */ - return APR_SUCCESS; - } - - /* res_name_from_filename turns file into a pseudo-name - * without slashes or backslashes, and prepends the \global - * prefix on Win2K and later - */ - mutexkey = res_name_from_filename(fname, 1, pool); - -#if defined(_WIN32_WCE) - hMutex = CreateMutex(NULL, FALSE, mutexkey); - if (hMutex && ERROR_ALREADY_EXISTS != GetLastError()) { - CloseHandle(hMutex); - hMutex = NULL; - SetLastError(ERROR_FILE_NOT_FOUND); - } -#else -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - hMutex = OpenMutexW(MUTEX_ALL_ACCESS, FALSE, mutexkey); - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - hMutex = OpenMutexA(MUTEX_ALL_ACCESS, FALSE, mutexkey); - } -#endif -#endif - - if (!hMutex) { - return apr_get_os_error(); - } - - *mutex = (apr_proc_mutex_t *)apr_palloc(pool, sizeof(apr_proc_mutex_t)); - (*mutex)->pool = pool; - (*mutex)->handle = hMutex; - (*mutex)->fname = fname; - apr_pool_cleanup_register((*mutex)->pool, *mutex, - proc_mutex_cleanup, apr_pool_cleanup_null); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_lock(apr_proc_mutex_t *mutex) -{ - DWORD rv; - - rv = WaitForSingleObject(mutex->handle, INFINITE); - - if (rv == WAIT_OBJECT_0 || rv == WAIT_ABANDONED) { - return APR_SUCCESS; - } - return apr_get_os_error(); -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex) -{ - DWORD rv; - - rv = WaitForSingleObject(mutex->handle, 0); - - if (rv == WAIT_OBJECT_0 || rv == WAIT_ABANDONED) { - return APR_SUCCESS; - } - else if (rv == WAIT_TIMEOUT) { - return APR_EBUSY; - } - return apr_get_os_error(); -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_unlock(apr_proc_mutex_t *mutex) -{ - if (ReleaseMutex(mutex->handle) == 0) { - return apr_get_os_error(); - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex) -{ - apr_status_t stat; - - stat = proc_mutex_cleanup(mutex); - if (stat == APR_SUCCESS) { - apr_pool_cleanup_kill(mutex->pool, mutex, proc_mutex_cleanup); - } - return stat; -} - -APR_DECLARE(apr_status_t) apr_proc_mutex_cleanup(void *mutex) -{ - return apr_proc_mutex_destroy((apr_proc_mutex_t *)mutex); -} - -APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex) -{ - return mutex->fname; -} - -APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex) -{ - return apr_proc_mutex_defname(); -} - -APR_DECLARE(const char *) apr_proc_mutex_defname(void) -{ - return "win32mutex"; -} - -APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex) - -/* Implement OS-specific accessors defined in apr_portable.h */ - -APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex, - apr_proc_mutex_t *mutex) -{ - *ospmutex = mutex->handle; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex, - apr_os_proc_mutex_t *ospmutex, - apr_pool_t *pool) -{ - if (pool == NULL) { - return APR_ENOPOOL; - } - if ((*pmutex) == NULL) { - (*pmutex) = (apr_proc_mutex_t *)apr_palloc(pool, - sizeof(apr_proc_mutex_t)); - (*pmutex)->pool = pool; - } - (*pmutex)->handle = *ospmutex; - return APR_SUCCESS; -} - diff --git a/libs/apr/locks/win32/thread_cond.c b/libs/apr/locks/win32/thread_cond.c deleted file mode 100644 index 60286e54..00000000 --- a/libs/apr/locks/win32/thread_cond.c +++ /dev/null @@ -1,168 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_arch_thread_mutex.h" -#include "apr_arch_thread_cond.h" -#include "apr_portable.h" - -#include - -static apr_status_t thread_cond_cleanup(void *data) -{ - apr_thread_cond_t *cond = data; - CloseHandle(cond->semaphore); - DeleteCriticalSection(&cond->csection); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond, - apr_pool_t *pool) -{ - apr_thread_cond_t *cv; - - cv = apr_pcalloc(pool, sizeof(**cond)); - if (cv == NULL) { - return APR_ENOMEM; - } - - cv->semaphore = CreateSemaphore(NULL, 0, LONG_MAX, NULL); - if (cv->semaphore == NULL) { - return apr_get_os_error(); - } - - *cond = cv; - cv->pool = pool; - InitializeCriticalSection(&cv->csection); - apr_pool_cleanup_register(cv->pool, cv, thread_cond_cleanup, - apr_pool_cleanup_null); - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond) -{ - return apr_pool_cleanup_run(cond->pool, cond, thread_cond_cleanup); -} - -static APR_INLINE apr_status_t _thread_cond_timedwait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex, - DWORD timeout_ms ) -{ - DWORD res; - apr_status_t rv; - unsigned int wake = 0; - unsigned long generation; - - EnterCriticalSection(&cond->csection); - cond->num_waiting++; - generation = cond->generation; - LeaveCriticalSection(&cond->csection); - - apr_thread_mutex_unlock(mutex); - - do { - res = WaitForSingleObject(cond->semaphore, timeout_ms); - - EnterCriticalSection(&cond->csection); - - if (cond->num_wake) { - if (cond->generation != generation) { - cond->num_wake--; - cond->num_waiting--; - rv = APR_SUCCESS; - break; - } else { - wake = 1; - } - } - else if (res != WAIT_OBJECT_0) { - cond->num_waiting--; - rv = APR_TIMEUP; - break; - } - - LeaveCriticalSection(&cond->csection); - - if (wake) { - wake = 0; - ReleaseSemaphore(cond->semaphore, 1, NULL); - } - } while (1); - - LeaveCriticalSection(&cond->csection); - apr_thread_mutex_lock(mutex); - - return rv; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex) -{ - return _thread_cond_timedwait(cond, mutex, INFINITE); -} - -APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex, - apr_interval_time_t timeout) -{ - DWORD timeout_ms = (DWORD) apr_time_as_msec(timeout); - - return _thread_cond_timedwait(cond, mutex, timeout_ms); -} - -APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond) -{ - unsigned int wake = 0; - - EnterCriticalSection(&cond->csection); - if (cond->num_waiting > cond->num_wake) { - wake = 1; - cond->num_wake++; - cond->generation++; - } - LeaveCriticalSection(&cond->csection); - - if (wake) { - ReleaseSemaphore(cond->semaphore, 1, NULL); - } - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond) -{ - unsigned long num_wake = 0; - - EnterCriticalSection(&cond->csection); - if (cond->num_waiting > cond->num_wake) { - num_wake = cond->num_waiting - cond->num_wake; - cond->num_wake = cond->num_waiting; - cond->generation++; - } - LeaveCriticalSection(&cond->csection); - - if (num_wake) { - ReleaseSemaphore(cond->semaphore, num_wake, NULL); - } - - return APR_SUCCESS; -} - -APR_POOL_IMPLEMENT_ACCESSOR(thread_cond) diff --git a/libs/apr/locks/win32/thread_mutex.c b/libs/apr/locks/win32/thread_mutex.c deleted file mode 100644 index 9b10d727..00000000 --- a/libs/apr/locks/win32/thread_mutex.c +++ /dev/null @@ -1,136 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_arch_thread_mutex.h" -#include "apr_thread_mutex.h" -#include "apr_portable.h" -#include "apr_arch_misc.h" - -static apr_status_t thread_mutex_cleanup(void *data) -{ - apr_thread_mutex_t *lock = data; - - if (lock->type == thread_mutex_critical_section) { - lock->type = -1; - DeleteCriticalSection(&lock->section); - } - else { - if (!CloseHandle(lock->handle)) { - return apr_get_os_error(); - } - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex, - unsigned int flags, - apr_pool_t *pool) -{ - (*mutex) = (apr_thread_mutex_t *)apr_palloc(pool, sizeof(**mutex)); - - (*mutex)->pool = pool; - - if (flags & APR_THREAD_MUTEX_UNNESTED) { - /* Use an auto-reset signaled event, ready to accept one - * waiting thread. - */ - (*mutex)->type = thread_mutex_unnested_event; - (*mutex)->handle = CreateEvent(NULL, FALSE, TRUE, NULL); - } - else { -#if APR_HAS_UNICODE_FS - /* Critical Sections are terrific, performance-wise, on NT. - * On Win9x, we cannot 'try' on a critical section, so we - * use a [slower] mutex object, instead. - */ - IF_WIN_OS_IS_UNICODE { - InitializeCriticalSection(&(*mutex)->section); - (*mutex)->type = thread_mutex_critical_section; - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI { - (*mutex)->type = thread_mutex_nested_mutex; - (*mutex)->handle = CreateMutex(NULL, FALSE, NULL); - - } -#endif - } - - apr_pool_cleanup_register((*mutex)->pool, (*mutex), thread_mutex_cleanup, - apr_pool_cleanup_null); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex) -{ - if (mutex->type == thread_mutex_critical_section) { - EnterCriticalSection(&mutex->section); - } - else { - DWORD rv = WaitForSingleObject(mutex->handle, INFINITE); - if ((rv != WAIT_OBJECT_0) && (rv != WAIT_ABANDONED)) { - return (rv == WAIT_TIMEOUT) ? APR_EBUSY : apr_get_os_error(); - } - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex) -{ - if (mutex->type == thread_mutex_critical_section) { - if (!TryEnterCriticalSection(&mutex->section)) { - return APR_EBUSY; - } - } - else { - DWORD rv = WaitForSingleObject(mutex->handle, 0); - if ((rv != WAIT_OBJECT_0) && (rv != WAIT_ABANDONED)) { - return (rv == WAIT_TIMEOUT) ? APR_EBUSY : apr_get_os_error(); - } - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex) -{ - if (mutex->type == thread_mutex_critical_section) { - LeaveCriticalSection(&mutex->section); - } - else if (mutex->type == thread_mutex_unnested_event) { - if (!SetEvent(mutex->handle)) { - return apr_get_os_error(); - } - } - else if (mutex->type == thread_mutex_nested_mutex) { - if (!ReleaseMutex(mutex->handle)) { - return apr_get_os_error(); - } - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_mutex_destroy(apr_thread_mutex_t *mutex) -{ - return apr_pool_cleanup_run(mutex->pool, mutex, thread_mutex_cleanup); -} - -APR_POOL_IMPLEMENT_ACCESSOR(thread_mutex) - diff --git a/libs/apr/locks/win32/thread_rwlock.c b/libs/apr/locks/win32/thread_rwlock.c deleted file mode 100644 index fd9d579f..00000000 --- a/libs/apr/locks/win32/thread_rwlock.c +++ /dev/null @@ -1,165 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_arch_thread_rwlock.h" -#include "apr_portable.h" - -static apr_status_t thread_rwlock_cleanup(void *data) -{ - apr_thread_rwlock_t *rwlock = data; - - if (! CloseHandle(rwlock->read_event)) - return apr_get_os_error(); - - if (! CloseHandle(rwlock->write_mutex)) - return apr_get_os_error(); - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t)apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock, - apr_pool_t *pool) -{ - *rwlock = apr_palloc(pool, sizeof(**rwlock)); - - (*rwlock)->pool = pool; - (*rwlock)->readers = 0; - - if (! ((*rwlock)->read_event = CreateEvent(NULL, TRUE, FALSE, NULL))) { - *rwlock = NULL; - return apr_get_os_error(); - } - - if (! ((*rwlock)->write_mutex = CreateMutex(NULL, FALSE, NULL))) { - CloseHandle((*rwlock)->read_event); - *rwlock = NULL; - return apr_get_os_error(); - } - - apr_pool_cleanup_register(pool, *rwlock, thread_rwlock_cleanup, - apr_pool_cleanup_null); - - return APR_SUCCESS; -} - -static apr_status_t apr_thread_rwlock_rdlock_core(apr_thread_rwlock_t *rwlock, - DWORD milliseconds) -{ - DWORD code = WaitForSingleObject(rwlock->write_mutex, milliseconds); - - if (code == WAIT_FAILED || code == WAIT_TIMEOUT) - return APR_FROM_OS_ERROR(code); - - /* We've successfully acquired the writer mutex, we can't be locked - * for write, so it's OK to add the reader lock. The writer mutex - * doubles as race condition protection for the readers counter. - */ - InterlockedIncrement(&rwlock->readers); - - if (! ResetEvent(rwlock->read_event)) - return apr_get_os_error(); - - if (! ReleaseMutex(rwlock->write_mutex)) - return apr_get_os_error(); - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock) -{ - return apr_thread_rwlock_rdlock_core(rwlock, INFINITE); -} - -APR_DECLARE(apr_status_t) -apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwlock) -{ - return apr_thread_rwlock_rdlock_core(rwlock, 0); -} - -static apr_status_t -apr_thread_rwlock_wrlock_core(apr_thread_rwlock_t *rwlock, DWORD milliseconds) -{ - DWORD code = WaitForSingleObject(rwlock->write_mutex, milliseconds); - - if (code == WAIT_FAILED || code == WAIT_TIMEOUT) - return APR_FROM_OS_ERROR(code); - - /* We've got the writer lock but we have to wait for all readers to - * unlock before it's ok to use it. - */ - if (rwlock->readers) { - /* Must wait for readers to finish before returning, unless this - * is an trywrlock (milliseconds == 0): - */ - code = milliseconds - ? WaitForSingleObject(rwlock->read_event, milliseconds) - : WAIT_TIMEOUT; - - if (code == WAIT_FAILED || code == WAIT_TIMEOUT) { - /* Unable to wait for readers to finish, release write lock: */ - if (! ReleaseMutex(rwlock->write_mutex)) - return apr_get_os_error(); - - return APR_FROM_OS_ERROR(code); - } - } - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_wrlock(apr_thread_rwlock_t *rwlock) -{ - return apr_thread_rwlock_wrlock_core(rwlock, INFINITE); -} - -APR_DECLARE(apr_status_t)apr_thread_rwlock_trywrlock(apr_thread_rwlock_t *rwlock) -{ - return apr_thread_rwlock_wrlock_core(rwlock, 0); -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock) -{ - apr_status_t rv = 0; - - /* First, guess that we're unlocking a writer */ - if (! ReleaseMutex(rwlock->write_mutex)) - rv = apr_get_os_error(); - - if (rv == APR_FROM_OS_ERROR(ERROR_NOT_OWNER)) { - /* Nope, we must have a read lock */ - if (rwlock->readers && - ! InterlockedDecrement(&rwlock->readers) && - ! SetEvent(rwlock->read_event)) { - rv = apr_get_os_error(); - } - else { - rv = 0; - } - } - - return rv; -} - -APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t *rwlock) -{ - return apr_pool_cleanup_run(rwlock->pool, rwlock, thread_rwlock_cleanup); -} - -APR_POOL_IMPLEMENT_ACCESSOR(thread_rwlock) diff --git a/libs/apr/memory/unix/apr_pools.c b/libs/apr/memory/unix/apr_pools.c deleted file mode 100644 index 5c1a1ff9..00000000 --- a/libs/apr/memory/unix/apr_pools.c +++ /dev/null @@ -1,2655 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_private.h" - -#include "apr_atomic.h" -#include "apr_portable.h" /* for get_os_proc */ -#include "apr_strings.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_allocator.h" -#include "apr_lib.h" -#include "apr_thread_mutex.h" -#include "apr_hash.h" -#include "apr_time.h" -#define APR_WANT_MEMFUNC -#include "apr_want.h" -#include "apr_env.h" - -#if APR_HAVE_STDLIB_H -#include /* for malloc, free and abort */ -#endif - -#if APR_HAVE_UNISTD_H -#include /* for getpid and sysconf */ -#endif - -#if APR_ALLOCATOR_USES_MMAP -#include -#endif - -/* - * Magic numbers - */ - -/* - * XXX: This is not optimal when using --enable-allocator-uses-mmap on - * XXX: machines with large pagesize, but currently the sink is assumed - * XXX: to be index 0, so MIN_ALLOC must be at least two pages. - */ -#define MIN_ALLOC (2 * BOUNDARY_SIZE) -#define MAX_INDEX 20 - -#if APR_ALLOCATOR_USES_MMAP && defined(_SC_PAGESIZE) -static unsigned int boundary_index; -static unsigned int boundary_size; -#define BOUNDARY_INDEX boundary_index -#define BOUNDARY_SIZE boundary_size -#else -#define BOUNDARY_INDEX 12 -#define BOUNDARY_SIZE (1 << BOUNDARY_INDEX) -#endif - -/* - * Timing constants for killing subprocesses - * There is a total 3-second delay between sending a SIGINT - * and sending of the final SIGKILL. - * TIMEOUT_INTERVAL should be set to TIMEOUT_USECS / 64 - * for the exponetial timeout alogrithm. - */ -#define TIMEOUT_USECS 3000000 -#define TIMEOUT_INTERVAL 46875 - -/* - * Allocator - * - * @note The max_free_index and current_free_index fields are not really - * indices, but quantities of BOUNDARY_SIZE big memory blocks. - */ - -struct apr_allocator_t { - /** largest used index into free[], always < MAX_INDEX */ - apr_uint32_t max_index; - /** Total size (in BOUNDARY_SIZE multiples) of unused memory before - * blocks are given back. @see apr_allocator_max_free_set(). - * @note Initialized to APR_ALLOCATOR_MAX_FREE_UNLIMITED, - * which means to never give back blocks. - */ - apr_uint32_t max_free_index; - /** - * Memory size (in BOUNDARY_SIZE multiples) that currently must be freed - * before blocks are given back. Range: 0..max_free_index - */ - apr_uint32_t current_free_index; -#if APR_HAS_THREADS - apr_thread_mutex_t *mutex; -#endif /* APR_HAS_THREADS */ - apr_pool_t *owner; - /** - * Lists of free nodes. Slot 0 is used for oversized nodes, - * and the slots 1..MAX_INDEX-1 contain nodes of sizes - * (i+1) * BOUNDARY_SIZE. Example for BOUNDARY_INDEX == 12: - * slot 0: nodes larger than 81920 - * slot 1: size 8192 - * slot 2: size 12288 - * ... - * slot 19: size 81920 - */ - apr_memnode_t *free[MAX_INDEX]; -}; - -#define SIZEOF_ALLOCATOR_T APR_ALIGN_DEFAULT(sizeof(apr_allocator_t)) - - -/* - * Allocator - */ - -APR_DECLARE(apr_status_t) apr_allocator_create(apr_allocator_t **allocator) -{ - apr_allocator_t *new_allocator; - - *allocator = NULL; - - if ((new_allocator = malloc(SIZEOF_ALLOCATOR_T)) == NULL) - return APR_ENOMEM; - - memset(new_allocator, 0, SIZEOF_ALLOCATOR_T); - new_allocator->max_free_index = APR_ALLOCATOR_MAX_FREE_UNLIMITED; - - *allocator = new_allocator; - - return APR_SUCCESS; -} - -APR_DECLARE(void) apr_allocator_destroy(apr_allocator_t *allocator) -{ - apr_uint32_t index; - apr_memnode_t *node, **ref; - - for (index = 0; index < MAX_INDEX; index++) { - ref = &allocator->free[index]; - while ((node = *ref) != NULL) { - *ref = node->next; -#if APR_ALLOCATOR_USES_MMAP - munmap(node, (node->index+1) << BOUNDARY_INDEX); -#else - free(node); -#endif - } - } - - free(allocator); -} - -#if APR_HAS_THREADS -APR_DECLARE(void) apr_allocator_mutex_set(apr_allocator_t *allocator, - apr_thread_mutex_t *mutex) -{ - allocator->mutex = mutex; -} - -APR_DECLARE(apr_thread_mutex_t *) apr_allocator_mutex_get( - apr_allocator_t *allocator) -{ - return allocator->mutex; -} -#endif /* APR_HAS_THREADS */ - -APR_DECLARE(void) apr_allocator_owner_set(apr_allocator_t *allocator, - apr_pool_t *pool) -{ - allocator->owner = pool; -} - -APR_DECLARE(apr_pool_t *) apr_allocator_owner_get(apr_allocator_t *allocator) -{ - return allocator->owner; -} - -APR_DECLARE(void) apr_allocator_max_free_set(apr_allocator_t *allocator, - apr_size_t in_size) -{ - apr_uint32_t max_free_index; - apr_uint32_t size = (APR_UINT32_TRUNC_CAST)in_size; - -#if APR_HAS_THREADS - apr_thread_mutex_t *mutex; - - mutex = apr_allocator_mutex_get(allocator); - if (mutex != NULL) - apr_thread_mutex_lock(mutex); -#endif /* APR_HAS_THREADS */ - - max_free_index = APR_ALIGN(size, BOUNDARY_SIZE) >> BOUNDARY_INDEX; - allocator->current_free_index += max_free_index; - allocator->current_free_index -= allocator->max_free_index; - allocator->max_free_index = max_free_index; - if (allocator->current_free_index > max_free_index) - allocator->current_free_index = max_free_index; - -#if APR_HAS_THREADS - if (mutex != NULL) - apr_thread_mutex_unlock(mutex); -#endif -} - -static APR_INLINE -apr_memnode_t *allocator_alloc(apr_allocator_t *allocator, apr_size_t in_size) -{ - apr_memnode_t *node, **ref; - apr_uint32_t max_index; - apr_size_t size, i, index; - - /* Round up the block size to the next boundary, but always - * allocate at least a certain size (MIN_ALLOC). - */ - size = APR_ALIGN(in_size + APR_MEMNODE_T_SIZE, BOUNDARY_SIZE); - if (size < in_size) { - return NULL; - } - if (size < MIN_ALLOC) - size = MIN_ALLOC; - - /* Find the index for this node size by - * dividing its size by the boundary size - */ - index = (size >> BOUNDARY_INDEX) - 1; - - if (index > APR_UINT32_MAX) { - return NULL; - } - - /* First see if there are any nodes in the area we know - * our node will fit into. - */ - if (index <= allocator->max_index) { -#if APR_HAS_THREADS - if (allocator->mutex) - apr_thread_mutex_lock(allocator->mutex); -#endif /* APR_HAS_THREADS */ - - /* Walk the free list to see if there are - * any nodes on it of the requested size - * - * NOTE: an optimization would be to check - * allocator->free[index] first and if no - * node is present, directly use - * allocator->free[max_index]. This seems - * like overkill though and could cause - * memory waste. - */ - max_index = allocator->max_index; - ref = &allocator->free[index]; - i = index; - while (*ref == NULL && i < max_index) { - ref++; - i++; - } - - if ((node = *ref) != NULL) { - /* If we have found a node and it doesn't have any - * nodes waiting in line behind it _and_ we are on - * the highest available index, find the new highest - * available index - */ - if ((*ref = node->next) == NULL && i >= max_index) { - do { - ref--; - max_index--; - } - while (*ref == NULL && max_index > 0); - - allocator->max_index = max_index; - } - - allocator->current_free_index += node->index + 1; - if (allocator->current_free_index > allocator->max_free_index) - allocator->current_free_index = allocator->max_free_index; - -#if APR_HAS_THREADS - if (allocator->mutex) - apr_thread_mutex_unlock(allocator->mutex); -#endif /* APR_HAS_THREADS */ - - node->next = NULL; - node->first_avail = (char *)node + APR_MEMNODE_T_SIZE; - - return node; - } - -#if APR_HAS_THREADS - if (allocator->mutex) - apr_thread_mutex_unlock(allocator->mutex); -#endif /* APR_HAS_THREADS */ - } - - /* If we found nothing, seek the sink (at index 0), if - * it is not empty. - */ - else if (allocator->free[0]) { -#if APR_HAS_THREADS - if (allocator->mutex) - apr_thread_mutex_lock(allocator->mutex); -#endif /* APR_HAS_THREADS */ - - /* Walk the free list to see if there are - * any nodes on it of the requested size - */ - ref = &allocator->free[0]; - while ((node = *ref) != NULL && index > node->index) - ref = &node->next; - - if (node) { - *ref = node->next; - - allocator->current_free_index += node->index + 1; - if (allocator->current_free_index > allocator->max_free_index) - allocator->current_free_index = allocator->max_free_index; - -#if APR_HAS_THREADS - if (allocator->mutex) - apr_thread_mutex_unlock(allocator->mutex); -#endif /* APR_HAS_THREADS */ - - node->next = NULL; - node->first_avail = (char *)node + APR_MEMNODE_T_SIZE; - - return node; - } - -#if APR_HAS_THREADS - if (allocator->mutex) - apr_thread_mutex_unlock(allocator->mutex); -#endif /* APR_HAS_THREADS */ - } - - /* If we haven't got a suitable node, malloc a new one - * and initialize it. - */ -#if APR_ALLOCATOR_USES_MMAP - if ((node = mmap(NULL, size, PROT_READ|PROT_WRITE, - MAP_PRIVATE|MAP_ANON, -1, 0)) == MAP_FAILED) -#else - if ((node = malloc(size)) == NULL) -#endif - return NULL; - - node->next = NULL; - node->index = (APR_UINT32_TRUNC_CAST)index; - node->first_avail = (char *)node + APR_MEMNODE_T_SIZE; - node->endp = (char *)node + size; - - return node; -} - -static APR_INLINE -void allocator_free(apr_allocator_t *allocator, apr_memnode_t *node) -{ - apr_memnode_t *next, *freelist = NULL; - apr_uint32_t index, max_index; - apr_uint32_t max_free_index, current_free_index; - -#if APR_HAS_THREADS - if (allocator->mutex) - apr_thread_mutex_lock(allocator->mutex); -#endif /* APR_HAS_THREADS */ - - max_index = allocator->max_index; - max_free_index = allocator->max_free_index; - current_free_index = allocator->current_free_index; - - /* Walk the list of submitted nodes and free them one by one, - * shoving them in the right 'size' buckets as we go. - */ - do { - next = node->next; - index = node->index; - - if (max_free_index != APR_ALLOCATOR_MAX_FREE_UNLIMITED - && index + 1 > current_free_index) { - node->next = freelist; - freelist = node; - } - else if (index < MAX_INDEX) { - /* Add the node to the appropiate 'size' bucket. Adjust - * the max_index when appropiate. - */ - if ((node->next = allocator->free[index]) == NULL - && index > max_index) { - max_index = index; - } - allocator->free[index] = node; - if (current_free_index >= index + 1) - current_free_index -= index + 1; - else - current_free_index = 0; - } - else { - /* This node is too large to keep in a specific size bucket, - * just add it to the sink (at index 0). - */ - node->next = allocator->free[0]; - allocator->free[0] = node; - if (current_free_index >= index + 1) - current_free_index -= index + 1; - else - current_free_index = 0; - } - } while ((node = next) != NULL); - - allocator->max_index = max_index; - allocator->current_free_index = current_free_index; - -#if APR_HAS_THREADS - if (allocator->mutex) - apr_thread_mutex_unlock(allocator->mutex); -#endif /* APR_HAS_THREADS */ - - while (freelist != NULL) { - node = freelist; - freelist = node->next; -#if APR_ALLOCATOR_USES_MMAP - munmap(node, (node->index+1) << BOUNDARY_INDEX); -#else - free(node); -#endif - } -} - -APR_DECLARE(apr_memnode_t *) apr_allocator_alloc(apr_allocator_t *allocator, - apr_size_t size) -{ - return allocator_alloc(allocator, size); -} - -APR_DECLARE(void) apr_allocator_free(apr_allocator_t *allocator, - apr_memnode_t *node) -{ - allocator_free(allocator, node); -} - - - -/* - * Debug level - */ - -#define APR_POOL_DEBUG_GENERAL 0x01 -#define APR_POOL_DEBUG_VERBOSE 0x02 -#define APR_POOL_DEBUG_LIFETIME 0x04 -#define APR_POOL_DEBUG_OWNER 0x08 -#define APR_POOL_DEBUG_VERBOSE_ALLOC 0x10 - -#define APR_POOL_DEBUG_VERBOSE_ALL (APR_POOL_DEBUG_VERBOSE \ - | APR_POOL_DEBUG_VERBOSE_ALLOC) - - -/* - * Structures - */ - -typedef struct cleanup_t cleanup_t; - -/** A list of processes */ -struct process_chain { - /** The process ID */ - apr_proc_t *proc; - apr_kill_conditions_e kill_how; - /** The next process in the list */ - struct process_chain *next; -}; - - -#if APR_POOL_DEBUG - -typedef struct debug_node_t debug_node_t; - -struct debug_node_t { - debug_node_t *next; - apr_uint32_t index; - void *beginp[64]; - void *endp[64]; -}; - -#define SIZEOF_DEBUG_NODE_T APR_ALIGN_DEFAULT(sizeof(debug_node_t)) - -#endif /* APR_POOL_DEBUG */ - -/* The ref field in the apr_pool_t struct holds a - * pointer to the pointer referencing this pool. - * It is used for parent, child, sibling management. - * Look at apr_pool_create_ex() and apr_pool_destroy() - * to see how it is used. - */ -struct apr_pool_t { - apr_pool_t *parent; - apr_pool_t *child; - apr_pool_t *sibling; - apr_pool_t **ref; - cleanup_t *cleanups; - cleanup_t *free_cleanups; - apr_allocator_t *allocator; - struct process_chain *subprocesses; - apr_abortfunc_t abort_fn; - apr_hash_t *user_data; - const char *tag; - -#if !APR_POOL_DEBUG - apr_memnode_t *active; - apr_memnode_t *self; /* The node containing the pool itself */ - char *self_first_avail; - -#else /* APR_POOL_DEBUG */ - apr_pool_t *joined; /* the caller has guaranteed that this pool - * will survive as long as ->joined */ - debug_node_t *nodes; - const char *file_line; - apr_uint32_t creation_flags; - unsigned int stat_alloc; - unsigned int stat_total_alloc; - unsigned int stat_clear; -#if APR_HAS_THREADS - apr_os_thread_t owner; - apr_thread_mutex_t *mutex; -#endif /* APR_HAS_THREADS */ -#endif /* APR_POOL_DEBUG */ -#ifdef NETWARE - apr_os_proc_t owner_proc; -#endif /* defined(NETWARE) */ - cleanup_t *pre_cleanups; -}; - -#define SIZEOF_POOL_T APR_ALIGN_DEFAULT(sizeof(apr_pool_t)) - - -/* - * Variables - */ - -static apr_byte_t apr_pools_initialized = 0; -static apr_pool_t *global_pool = NULL; - -#if !APR_POOL_DEBUG -static apr_allocator_t *global_allocator = NULL; -#endif /* !APR_POOL_DEBUG */ - -#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) -static apr_file_t *file_stderr = NULL; -#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */ - -/* - * Local functions - */ - -static void run_cleanups(cleanup_t **c); -static void free_proc_chain(struct process_chain *procs); - -#if APR_POOL_DEBUG -static void pool_destroy_debug(apr_pool_t *pool, const char *file_line); -#endif - -#if !APR_POOL_DEBUG -/* - * Initialization - */ - -APR_DECLARE(apr_status_t) apr_pool_initialize(void) -{ - apr_status_t rv; - - if (apr_pools_initialized++) - return APR_SUCCESS; - -#if APR_ALLOCATOR_USES_MMAP && defined(_SC_PAGESIZE) - boundary_size = sysconf(_SC_PAGESIZE); - boundary_index = 12; - while ( (1 << boundary_index) < boundary_size) - boundary_index++; - boundary_size = (1 << boundary_index); -#endif - - if ((rv = apr_allocator_create(&global_allocator)) != APR_SUCCESS) { - apr_pools_initialized = 0; - return rv; - } - - if ((rv = apr_pool_create_ex(&global_pool, NULL, NULL, - global_allocator)) != APR_SUCCESS) { - apr_allocator_destroy(global_allocator); - global_allocator = NULL; - apr_pools_initialized = 0; - return rv; - } - - apr_pool_tag(global_pool, "apr_global_pool"); - - /* This has to happen here because mutexes might be backed by - * atomics. It used to be snug and safe in apr_initialize(). - * - * Warning: apr_atomic_init() must always be called, by any - * means possible, from apr_initialize(). - */ - if ((rv = apr_atomic_init(global_pool)) != APR_SUCCESS) { - return rv; - } - -#if APR_HAS_THREADS - { - apr_thread_mutex_t *mutex; - - if ((rv = apr_thread_mutex_create(&mutex, - APR_THREAD_MUTEX_DEFAULT, - global_pool)) != APR_SUCCESS) { - return rv; - } - - apr_allocator_mutex_set(global_allocator, mutex); - } -#endif /* APR_HAS_THREADS */ - - apr_allocator_owner_set(global_allocator, global_pool); - - return APR_SUCCESS; -} - -APR_DECLARE(void) apr_pool_terminate(void) -{ - if (!apr_pools_initialized) - return; - - if (--apr_pools_initialized) - return; - - apr_pool_destroy(global_pool); /* This will also destroy the mutex */ - global_pool = NULL; - - global_allocator = NULL; -} - - -/* Node list management helper macros; list_insert() inserts 'node' - * before 'point'. */ -#define list_insert(node, point) do { \ - node->ref = point->ref; \ - *node->ref = node; \ - node->next = point; \ - point->ref = &node->next; \ -} while (0) - -/* list_remove() removes 'node' from its list. */ -#define list_remove(node) do { \ - *node->ref = node->next; \ - node->next->ref = node->ref; \ -} while (0) - -/* Returns the amount of free space in the given node. */ -#define node_free_space(node_) ((apr_size_t)(node_->endp - node_->first_avail)) - -/* - * Memory allocation - */ - -APR_DECLARE(void *) apr_palloc(apr_pool_t *pool, apr_size_t in_size) -{ - apr_memnode_t *active, *node; - void *mem; - apr_size_t size, free_index; - - size = APR_ALIGN_DEFAULT(in_size); - if (size < in_size) { - if (pool->abort_fn) - pool->abort_fn(APR_ENOMEM); - - return NULL; - } - active = pool->active; - - /* If the active node has enough bytes left, use it. */ - if (size <= node_free_space(active)) { - mem = active->first_avail; - active->first_avail += size; - - return mem; - } - - node = active->next; - if (size <= node_free_space(node)) { - list_remove(node); - } - else { - if ((node = allocator_alloc(pool->allocator, size)) == NULL) { - if (pool->abort_fn) - pool->abort_fn(APR_ENOMEM); - - return NULL; - } - } - - node->free_index = 0; - - mem = node->first_avail; - node->first_avail += size; - - list_insert(node, active); - - pool->active = node; - - free_index = (APR_ALIGN(active->endp - active->first_avail + 1, - BOUNDARY_SIZE) - BOUNDARY_SIZE) >> BOUNDARY_INDEX; - - active->free_index = (APR_UINT32_TRUNC_CAST)free_index; - node = active->next; - if (free_index >= node->free_index) - return mem; - - do { - node = node->next; - } - while (free_index < node->free_index); - - list_remove(active); - list_insert(active, node); - - return mem; -} - -/* Provide an implementation of apr_pcalloc for backward compatibility - * with code built before apr_pcalloc was a macro - */ - -#ifdef apr_pcalloc -#undef apr_pcalloc -#endif - -APR_DECLARE(void *) apr_pcalloc(apr_pool_t *pool, apr_size_t size); -APR_DECLARE(void *) apr_pcalloc(apr_pool_t *pool, apr_size_t size) -{ - void *mem; - - if ((mem = apr_palloc(pool, size)) != NULL) { - memset(mem, 0, size); - } - - return mem; -} - - -/* - * Pool creation/destruction - */ - -APR_DECLARE(void) apr_pool_clear(apr_pool_t *pool) -{ - apr_memnode_t *active; - - /* Run pre destroy cleanups */ - run_cleanups(&pool->pre_cleanups); - pool->pre_cleanups = NULL; - - /* Destroy the subpools. The subpools will detach themselves from - * this pool thus this loop is safe and easy. - */ - while (pool->child) - apr_pool_destroy(pool->child); - - /* Run cleanups */ - run_cleanups(&pool->cleanups); - pool->cleanups = NULL; - pool->free_cleanups = NULL; - - /* Free subprocesses */ - free_proc_chain(pool->subprocesses); - pool->subprocesses = NULL; - - /* Clear the user data. */ - pool->user_data = NULL; - - /* Find the node attached to the pool structure, reset it, make - * it the active node and free the rest of the nodes. - */ - active = pool->active = pool->self; - active->first_avail = pool->self_first_avail; - - if (active->next == active) - return; - - *active->ref = NULL; - allocator_free(pool->allocator, active->next); - active->next = active; - active->ref = &active->next; -} - -APR_DECLARE(void) apr_pool_destroy(apr_pool_t *pool) -{ - apr_memnode_t *active; - apr_allocator_t *allocator; - - /* Run pre destroy cleanups */ - run_cleanups(&pool->pre_cleanups); - pool->pre_cleanups = NULL; - - /* Destroy the subpools. The subpools will detach themselve from - * this pool thus this loop is safe and easy. - */ - while (pool->child) - apr_pool_destroy(pool->child); - - /* Run cleanups */ - run_cleanups(&pool->cleanups); - - /* Free subprocesses */ - free_proc_chain(pool->subprocesses); - - /* Remove the pool from the parents child list */ - if (pool->parent) { -#if APR_HAS_THREADS - apr_thread_mutex_t *mutex; - - if ((mutex = apr_allocator_mutex_get(pool->parent->allocator)) != NULL) - apr_thread_mutex_lock(mutex); -#endif /* APR_HAS_THREADS */ - - if ((*pool->ref = pool->sibling) != NULL) - pool->sibling->ref = pool->ref; - -#if APR_HAS_THREADS - if (mutex) - apr_thread_mutex_unlock(mutex); -#endif /* APR_HAS_THREADS */ - } - - /* Find the block attached to the pool structure. Save a copy of the - * allocator pointer, because the pool struct soon will be no more. - */ - allocator = pool->allocator; - active = pool->self; - *active->ref = NULL; - -#if APR_HAS_THREADS - if (apr_allocator_owner_get(allocator) == pool) { - /* Make sure to remove the lock, since it is highly likely to - * be invalid now. - */ - apr_allocator_mutex_set(allocator, NULL); - } -#endif /* APR_HAS_THREADS */ - - /* Free all the nodes in the pool (including the node holding the - * pool struct), by giving them back to the allocator. - */ - allocator_free(allocator, active); - - /* If this pool happens to be the owner of the allocator, free - * everything in the allocator (that includes the pool struct - * and the allocator). Don't worry about destroying the optional mutex - * in the allocator, it will have been destroyed by the cleanup function. - */ - if (apr_allocator_owner_get(allocator) == pool) { - apr_allocator_destroy(allocator); - } -} - -APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool, - apr_pool_t *parent, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator) -{ - apr_pool_t *pool; - apr_memnode_t *node; - - *newpool = NULL; - - if (!parent) - parent = global_pool; - - /* parent will always be non-NULL here except the first time a - * pool is created, in which case allocator is guaranteed to be - * non-NULL. */ - - if (!abort_fn && parent) - abort_fn = parent->abort_fn; - - if (allocator == NULL) - allocator = parent->allocator; - - if ((node = allocator_alloc(allocator, - MIN_ALLOC - APR_MEMNODE_T_SIZE)) == NULL) { - if (abort_fn) - abort_fn(APR_ENOMEM); - - return APR_ENOMEM; - } - - node->next = node; - node->ref = &node->next; - - pool = (apr_pool_t *)node->first_avail; - node->first_avail = pool->self_first_avail = (char *)pool + SIZEOF_POOL_T; - - pool->allocator = allocator; - pool->active = pool->self = node; - pool->abort_fn = abort_fn; - pool->child = NULL; - pool->cleanups = NULL; - pool->free_cleanups = NULL; - pool->pre_cleanups = NULL; - pool->subprocesses = NULL; - pool->user_data = NULL; - pool->tag = NULL; - -#ifdef NETWARE - pool->owner_proc = (apr_os_proc_t)getnlmhandle(); -#endif /* defined(NETWARE) */ - - if ((pool->parent = parent) != NULL) { -#if APR_HAS_THREADS - apr_thread_mutex_t *mutex; - - if ((mutex = apr_allocator_mutex_get(parent->allocator)) != NULL) - apr_thread_mutex_lock(mutex); -#endif /* APR_HAS_THREADS */ - - if ((pool->sibling = parent->child) != NULL) - pool->sibling->ref = &pool->sibling; - - parent->child = pool; - pool->ref = &parent->child; - -#if APR_HAS_THREADS - if (mutex) - apr_thread_mutex_unlock(mutex); -#endif /* APR_HAS_THREADS */ - } - else { - pool->sibling = NULL; - pool->ref = NULL; - } - - *newpool = pool; - - return APR_SUCCESS; -} - -/* Deprecated. Renamed to apr_pool_create_unmanaged_ex - */ -APR_DECLARE(apr_status_t) apr_pool_create_core_ex(apr_pool_t **newpool, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator) -{ - return apr_pool_create_unmanaged_ex(newpool, abort_fn, allocator); -} - -APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex(apr_pool_t **newpool, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator) -{ - apr_pool_t *pool; - apr_memnode_t *node; - apr_allocator_t *pool_allocator; - - *newpool = NULL; - - if (!apr_pools_initialized) - return APR_ENOPOOL; - if ((pool_allocator = allocator) == NULL) { - if ((pool_allocator = malloc(SIZEOF_ALLOCATOR_T)) == NULL) { - if (abort_fn) - abort_fn(APR_ENOMEM); - - return APR_ENOMEM; - } - memset(pool_allocator, 0, SIZEOF_ALLOCATOR_T); - pool_allocator->max_free_index = APR_ALLOCATOR_MAX_FREE_UNLIMITED; - } - if ((node = allocator_alloc(pool_allocator, - MIN_ALLOC - APR_MEMNODE_T_SIZE)) == NULL) { - if (abort_fn) - abort_fn(APR_ENOMEM); - - return APR_ENOMEM; - } - - node->next = node; - node->ref = &node->next; - - pool = (apr_pool_t *)node->first_avail; - node->first_avail = pool->self_first_avail = (char *)pool + SIZEOF_POOL_T; - - pool->allocator = pool_allocator; - pool->active = pool->self = node; - pool->abort_fn = abort_fn; - pool->child = NULL; - pool->cleanups = NULL; - pool->free_cleanups = NULL; - pool->pre_cleanups = NULL; - pool->subprocesses = NULL; - pool->user_data = NULL; - pool->tag = NULL; - pool->parent = NULL; - pool->sibling = NULL; - pool->ref = NULL; - -#ifdef NETWARE - pool->owner_proc = (apr_os_proc_t)getnlmhandle(); -#endif /* defined(NETWARE) */ - if (!allocator) - pool_allocator->owner = pool; - *newpool = pool; - - return APR_SUCCESS; -} - -/* - * "Print" functions - */ - -/* - * apr_psprintf is implemented by writing directly into the current - * block of the pool, starting right at first_avail. If there's - * insufficient room, then a new block is allocated and the earlier - * output is copied over. The new block isn't linked into the pool - * until all the output is done. - * - * Note that this is completely safe because nothing else can - * allocate in this apr_pool_t while apr_psprintf is running. alarms are - * blocked, and the only thing outside of apr_pools.c that's invoked - * is apr_vformatter -- which was purposefully written to be - * self-contained with no callouts. - */ - -struct psprintf_data { - apr_vformatter_buff_t vbuff; - apr_memnode_t *node; - apr_pool_t *pool; - apr_byte_t got_a_new_node; - apr_memnode_t *free; -}; - -#define APR_PSPRINTF_MIN_STRINGSIZE 32 - -static int psprintf_flush(apr_vformatter_buff_t *vbuff) -{ - struct psprintf_data *ps = (struct psprintf_data *)vbuff; - apr_memnode_t *node, *active; - apr_size_t cur_len, size; - char *strp; - apr_pool_t *pool; - apr_size_t free_index; - - pool = ps->pool; - active = ps->node; - strp = ps->vbuff.curpos; - cur_len = strp - active->first_avail; - size = cur_len << 1; - - /* Make sure that we don't try to use a block that has less - * than APR_PSPRINTF_MIN_STRINGSIZE bytes left in it. This - * also catches the case where size == 0, which would result - * in reusing a block that can't even hold the NUL byte. - */ - if (size < APR_PSPRINTF_MIN_STRINGSIZE) - size = APR_PSPRINTF_MIN_STRINGSIZE; - - node = active->next; - if (!ps->got_a_new_node && size <= node_free_space(node)) { - - list_remove(node); - list_insert(node, active); - - node->free_index = 0; - - pool->active = node; - - free_index = (APR_ALIGN(active->endp - active->first_avail + 1, - BOUNDARY_SIZE) - BOUNDARY_SIZE) >> BOUNDARY_INDEX; - - active->free_index = (APR_UINT32_TRUNC_CAST)free_index; - node = active->next; - if (free_index < node->free_index) { - do { - node = node->next; - } - while (free_index < node->free_index); - - list_remove(active); - list_insert(active, node); - } - - node = pool->active; - } - else { - if ((node = allocator_alloc(pool->allocator, size)) == NULL) - return -1; - - if (ps->got_a_new_node) { - active->next = ps->free; - ps->free = active; - } - - ps->got_a_new_node = 1; - } - - memcpy(node->first_avail, active->first_avail, cur_len); - - ps->node = node; - ps->vbuff.curpos = node->first_avail + cur_len; - ps->vbuff.endpos = node->endp - 1; /* Save a byte for NUL terminator */ - - return 0; -} - -APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *pool, const char *fmt, va_list ap) -{ - struct psprintf_data ps; - char *strp; - apr_size_t size; - apr_memnode_t *active, *node; - apr_size_t free_index; - - ps.node = active = pool->active; - ps.pool = pool; - ps.vbuff.curpos = ps.node->first_avail; - - /* Save a byte for the NUL terminator */ - ps.vbuff.endpos = ps.node->endp - 1; - ps.got_a_new_node = 0; - ps.free = NULL; - - /* Make sure that the first node passed to apr_vformatter has at least - * room to hold the NUL terminator. - */ - if (ps.node->first_avail == ps.node->endp) { - if (psprintf_flush(&ps.vbuff) == -1) { - if (pool->abort_fn) { - pool->abort_fn(APR_ENOMEM); - } - - return NULL; - } - } - - if (apr_vformatter(psprintf_flush, &ps.vbuff, fmt, ap) == -1) { - if (pool->abort_fn) - pool->abort_fn(APR_ENOMEM); - - return NULL; - } - - strp = ps.vbuff.curpos; - *strp++ = '\0'; - - size = strp - ps.node->first_avail; - size = APR_ALIGN_DEFAULT(size); - strp = ps.node->first_avail; - ps.node->first_avail += size; - - if (ps.free) - allocator_free(pool->allocator, ps.free); - - /* - * Link the node in if it's a new one - */ - if (!ps.got_a_new_node) - return strp; - - active = pool->active; - node = ps.node; - - node->free_index = 0; - - list_insert(node, active); - - pool->active = node; - - free_index = (APR_ALIGN(active->endp - active->first_avail + 1, - BOUNDARY_SIZE) - BOUNDARY_SIZE) >> BOUNDARY_INDEX; - - active->free_index = (APR_UINT32_TRUNC_CAST)free_index; - node = active->next; - - if (free_index >= node->free_index) - return strp; - - do { - node = node->next; - } - while (free_index < node->free_index); - - list_remove(active); - list_insert(active, node); - - return strp; -} - - -#else /* APR_POOL_DEBUG */ -/* - * Debug helper functions - */ - - -/* - * Walk the pool tree rooted at pool, depth first. When fn returns - * anything other than 0, abort the traversal and return the value - * returned by fn. - */ -static int apr_pool_walk_tree(apr_pool_t *pool, - int (*fn)(apr_pool_t *pool, void *data), - void *data) -{ - int rv; - apr_pool_t *child; - - rv = fn(pool, data); - if (rv) - return rv; - -#if APR_HAS_THREADS - if (pool->mutex) { - apr_thread_mutex_lock(pool->mutex); - } -#endif /* APR_HAS_THREADS */ - - child = pool->child; - while (child) { - rv = apr_pool_walk_tree(child, fn, data); - if (rv) - break; - - child = child->sibling; - } - -#if APR_HAS_THREADS - if (pool->mutex) { - apr_thread_mutex_unlock(pool->mutex); - } -#endif /* APR_HAS_THREADS */ - - return rv; -} - -#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) -static void apr_pool_log_event(apr_pool_t *pool, const char *event, - const char *file_line, int deref) -{ - if (file_stderr) { - if (deref) { - apr_file_printf(file_stderr, - "POOL DEBUG: " - "[%lu" -#if APR_HAS_THREADS - "/%lu" -#endif /* APR_HAS_THREADS */ - "] " - "%7s " - "(%10lu/%10lu/%10lu) " - "0x%pp \"%s\" " - "<%s> " - "(%u/%u/%u) " - "\n", - (unsigned long)getpid(), -#if APR_HAS_THREADS - (unsigned long)apr_os_thread_current(), -#endif /* APR_HAS_THREADS */ - event, - (unsigned long)apr_pool_num_bytes(pool, 0), - (unsigned long)apr_pool_num_bytes(pool, 1), - (unsigned long)apr_pool_num_bytes(global_pool, 1), - pool, pool->tag, - file_line, - pool->stat_alloc, pool->stat_total_alloc, pool->stat_clear); - } - else { - apr_file_printf(file_stderr, - "POOL DEBUG: " - "[%lu" -#if APR_HAS_THREADS - "/%lu" -#endif /* APR_HAS_THREADS */ - "] " - "%7s " - " " - "0x%pp " - "<%s> " - "\n", - (unsigned long)getpid(), -#if APR_HAS_THREADS - (unsigned long)apr_os_thread_current(), -#endif /* APR_HAS_THREADS */ - event, - pool, - file_line); - } - } -} -#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */ - -#if (APR_POOL_DEBUG & APR_POOL_DEBUG_LIFETIME) -static int pool_is_child_of(apr_pool_t *parent, void *data) -{ - apr_pool_t *pool = (apr_pool_t *)data; - - return (pool == parent); -} - -static int apr_pool_is_child_of(apr_pool_t *pool, apr_pool_t *parent) -{ - if (parent == NULL) - return 0; - - return apr_pool_walk_tree(parent, pool_is_child_of, pool); -} -#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_LIFETIME) */ - -static void apr_pool_check_integrity(apr_pool_t *pool) -{ - /* Rule of thumb: use of the global pool is always - * ok, since the only user is apr_pools.c. Unless - * people have searched for the top level parent and - * started to use that... - */ - if (pool == global_pool || global_pool == NULL) - return; - - /* Lifetime - * This basically checks to see if the pool being used is still - * a relative to the global pool. If not it was previously - * destroyed, in which case we abort(). - */ -#if (APR_POOL_DEBUG & APR_POOL_DEBUG_LIFETIME) - if (!apr_pool_is_child_of(pool, global_pool)) { -#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) - apr_pool_log_event(pool, "LIFE", - __FILE__ ":apr_pool_integrity check", 0); -#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */ - abort(); - } -#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_LIFETIME) */ - -#if (APR_POOL_DEBUG & APR_POOL_DEBUG_OWNER) -#if APR_HAS_THREADS - if (!apr_os_thread_equal(pool->owner, apr_os_thread_current())) { -#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) - apr_pool_log_event(pool, "THREAD", - __FILE__ ":apr_pool_integrity check", 0); -#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */ - abort(); - } -#endif /* APR_HAS_THREADS */ -#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_OWNER) */ -} - - -/* - * Initialization (debug) - */ - -APR_DECLARE(apr_status_t) apr_pool_initialize(void) -{ - apr_status_t rv; -#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) - char *logpath; - apr_file_t *debug_log = NULL; -#endif - - if (apr_pools_initialized++) - return APR_SUCCESS; - -#if APR_ALLOCATOR_USES_MMAP && defined(_SC_PAGESIZE) - boundary_size = sysconf(_SC_PAGESIZE); - boundary_index = 12; - while ( (1 << boundary_index) < boundary_size) - boundary_index++; - boundary_size = (1 << boundary_index); -#endif - - /* Since the debug code works a bit differently then the - * regular pools code, we ask for a lock here. The regular - * pools code has got this lock embedded in the global - * allocator, a concept unknown to debug mode. - */ - if ((rv = apr_pool_create_ex(&global_pool, NULL, NULL, - NULL)) != APR_SUCCESS) { - return rv; - } - - apr_pool_tag(global_pool, "APR global pool"); - - apr_pools_initialized = 1; - - /* This has to happen here because mutexes might be backed by - * atomics. It used to be snug and safe in apr_initialize(). - */ - if ((rv = apr_atomic_init(global_pool)) != APR_SUCCESS) { - return rv; - } - -#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) - rv = apr_env_get(&logpath, "APR_POOL_DEBUG_LOG", global_pool); - - /* Don't pass file_stderr directly to apr_file_open() here, since - * apr_file_open() can call back to apr_pool_log_event() and that - * may attempt to use then then non-NULL but partially set up file - * object. */ - if (rv == APR_SUCCESS) { - apr_file_open(&debug_log, logpath, APR_APPEND|APR_WRITE|APR_CREATE, - APR_OS_DEFAULT, global_pool); - } - else { - apr_file_open_stderr(&debug_log, global_pool); - } - - /* debug_log is now a file handle. */ - file_stderr = debug_log; - - if (file_stderr) { - apr_file_printf(file_stderr, - "POOL DEBUG: [PID" -#if APR_HAS_THREADS - "/TID" -#endif /* APR_HAS_THREADS */ - "] ACTION (SIZE /POOL SIZE /TOTAL SIZE) " - "POOL \"TAG\" <__FILE__:__LINE__> (ALLOCS/TOTAL ALLOCS/CLEARS)\n"); - - apr_pool_log_event(global_pool, "GLOBAL", __FILE__ ":apr_pool_initialize", 0); - } -#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */ - - return APR_SUCCESS; -} - -APR_DECLARE(void) apr_pool_terminate(void) -{ - if (!apr_pools_initialized) - return; - - if (--apr_pools_initialized) - return; - - apr_pool_destroy(global_pool); /* This will also destroy the mutex */ - global_pool = NULL; - -#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) - file_stderr = NULL; -#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */ -} - - -/* - * Memory allocation (debug) - */ - -static void *pool_alloc(apr_pool_t *pool, apr_size_t size) -{ - debug_node_t *node; - void *mem; - - if ((mem = malloc(size)) == NULL) { - if (pool->abort_fn) - pool->abort_fn(APR_ENOMEM); - - return NULL; - } - - node = pool->nodes; - if (node == NULL || node->index == 64) { - if ((node = malloc(SIZEOF_DEBUG_NODE_T)) == NULL) { - free(mem); - if (pool->abort_fn) - pool->abort_fn(APR_ENOMEM); - - return NULL; - } - - memset(node, 0, SIZEOF_DEBUG_NODE_T); - - node->next = pool->nodes; - pool->nodes = node; - node->index = 0; - } - - node->beginp[node->index] = mem; - node->endp[node->index] = (char *)mem + size; - node->index++; - - pool->stat_alloc++; - pool->stat_total_alloc++; - - return mem; -} - -APR_DECLARE(void *) apr_palloc_debug(apr_pool_t *pool, apr_size_t size, - const char *file_line) -{ - void *mem; - - apr_pool_check_integrity(pool); - - mem = pool_alloc(pool, size); - -#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALLOC) - apr_pool_log_event(pool, "PALLOC", file_line, 1); -#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALLOC) */ - - return mem; -} - -APR_DECLARE(void *) apr_pcalloc_debug(apr_pool_t *pool, apr_size_t size, - const char *file_line) -{ - void *mem; - - apr_pool_check_integrity(pool); - - mem = pool_alloc(pool, size); - memset(mem, 0, size); - -#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALLOC) - apr_pool_log_event(pool, "PCALLOC", file_line, 1); -#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALLOC) */ - - return mem; -} - - -/* - * Pool creation/destruction (debug) - */ - -#define POOL_POISON_BYTE 'A' - -static void pool_clear_debug(apr_pool_t *pool, const char *file_line) -{ - debug_node_t *node; - apr_uint32_t index; - - /* Run pre destroy cleanups */ - run_cleanups(&pool->pre_cleanups); - pool->pre_cleanups = NULL; - - /* Destroy the subpools. The subpools will detach themselves from - * this pool thus this loop is safe and easy. - */ - while (pool->child) - pool_destroy_debug(pool->child, file_line); - - /* Run cleanups */ - run_cleanups(&pool->cleanups); - pool->free_cleanups = NULL; - pool->cleanups = NULL; - - /* If new child pools showed up, this is a reason to raise a flag */ - if (pool->child) - abort(); - - /* Free subprocesses */ - free_proc_chain(pool->subprocesses); - pool->subprocesses = NULL; - - /* Clear the user data. */ - pool->user_data = NULL; - - /* Free the blocks, scribbling over them first to help highlight - * use-after-free issues. */ - while ((node = pool->nodes) != NULL) { - pool->nodes = node->next; - - for (index = 0; index < node->index; index++) { - memset(node->beginp[index], POOL_POISON_BYTE, - (char *)node->endp[index] - (char *)node->beginp[index]); - free(node->beginp[index]); - } - - memset(node, POOL_POISON_BYTE, SIZEOF_DEBUG_NODE_T); - free(node); - } - - pool->stat_alloc = 0; - pool->stat_clear++; -} - -APR_DECLARE(void) apr_pool_clear_debug(apr_pool_t *pool, - const char *file_line) -{ -#if APR_HAS_THREADS - apr_thread_mutex_t *mutex = NULL; -#endif - - apr_pool_check_integrity(pool); - -#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE) - apr_pool_log_event(pool, "CLEAR", file_line, 1); -#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE) */ - -#if APR_HAS_THREADS - if (pool->parent != NULL) - mutex = pool->parent->mutex; - - /* Lock the parent mutex before clearing so that if we have our - * own mutex it won't be accessed by apr_pool_walk_tree after - * it has been destroyed. - */ - if (mutex != NULL && mutex != pool->mutex) { - apr_thread_mutex_lock(mutex); - } -#endif - - pool_clear_debug(pool, file_line); - -#if APR_HAS_THREADS - /* If we had our own mutex, it will have been destroyed by - * the registered cleanups. Recreate the mutex. Unlock - * the mutex we obtained above. - */ - if (mutex != pool->mutex) { - (void)apr_thread_mutex_create(&pool->mutex, - APR_THREAD_MUTEX_NESTED, pool); - - if (mutex != NULL) - (void)apr_thread_mutex_unlock(mutex); - } -#endif /* APR_HAS_THREADS */ -} - -static void pool_destroy_debug(apr_pool_t *pool, const char *file_line) -{ - apr_pool_check_integrity(pool); - -#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE) - apr_pool_log_event(pool, "DESTROY", file_line, 1); -#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE) */ - - pool_clear_debug(pool, file_line); - - /* Remove the pool from the parents child list */ - if (pool->parent) { -#if APR_HAS_THREADS - apr_thread_mutex_t *mutex; - - if ((mutex = pool->parent->mutex) != NULL) - apr_thread_mutex_lock(mutex); -#endif /* APR_HAS_THREADS */ - - if ((*pool->ref = pool->sibling) != NULL) - pool->sibling->ref = pool->ref; - -#if APR_HAS_THREADS - if (mutex) - apr_thread_mutex_unlock(mutex); -#endif /* APR_HAS_THREADS */ - } - - if (pool->allocator != NULL - && apr_allocator_owner_get(pool->allocator) == pool) { - apr_allocator_destroy(pool->allocator); - } - - /* Free the pool itself */ - free(pool); -} - -APR_DECLARE(void) apr_pool_destroy_debug(apr_pool_t *pool, - const char *file_line) -{ - if (pool->joined) { - /* Joined pools must not be explicitly destroyed; the caller - * has broken the guarantee. */ -#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) - apr_pool_log_event(pool, "LIFE", - __FILE__ ":apr_pool_destroy abort on joined", 0); -#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */ - - abort(); - } - pool_destroy_debug(pool, file_line); -} - -APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool, - apr_pool_t *parent, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator, - const char *file_line) -{ - apr_pool_t *pool; - - *newpool = NULL; - - if (!parent) { - parent = global_pool; - } - else { - apr_pool_check_integrity(parent); - - if (!allocator) - allocator = parent->allocator; - } - - if (!abort_fn && parent) - abort_fn = parent->abort_fn; - - if ((pool = malloc(SIZEOF_POOL_T)) == NULL) { - if (abort_fn) - abort_fn(APR_ENOMEM); - - return APR_ENOMEM; - } - - memset(pool, 0, SIZEOF_POOL_T); - - pool->allocator = allocator; - pool->abort_fn = abort_fn; - pool->tag = file_line; - pool->file_line = file_line; - - if ((pool->parent = parent) != NULL) { -#if APR_HAS_THREADS - if (parent->mutex) - apr_thread_mutex_lock(parent->mutex); -#endif /* APR_HAS_THREADS */ - if ((pool->sibling = parent->child) != NULL) - pool->sibling->ref = &pool->sibling; - - parent->child = pool; - pool->ref = &parent->child; - -#if APR_HAS_THREADS - if (parent->mutex) - apr_thread_mutex_unlock(parent->mutex); -#endif /* APR_HAS_THREADS */ - } - else { - pool->sibling = NULL; - pool->ref = NULL; - } - -#if APR_HAS_THREADS - pool->owner = apr_os_thread_current(); -#endif /* APR_HAS_THREADS */ -#ifdef NETWARE - pool->owner_proc = (apr_os_proc_t)getnlmhandle(); -#endif /* defined(NETWARE) */ - - - if (parent == NULL || parent->allocator != allocator) { -#if APR_HAS_THREADS - apr_status_t rv; - - /* No matter what the creation flags say, always create - * a lock. Without it integrity_check and apr_pool_num_bytes - * blow up (because they traverse pools child lists that - * possibly belong to another thread, in combination with - * the pool having no lock). However, this might actually - * hide problems like creating a child pool of a pool - * belonging to another thread. - */ - if ((rv = apr_thread_mutex_create(&pool->mutex, - APR_THREAD_MUTEX_NESTED, pool)) != APR_SUCCESS) { - free(pool); - return rv; - } -#endif /* APR_HAS_THREADS */ - } - else { -#if APR_HAS_THREADS - if (parent) - pool->mutex = parent->mutex; -#endif /* APR_HAS_THREADS */ - } - - *newpool = pool; - -#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE) - apr_pool_log_event(pool, "CREATE", file_line, 1); -#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE) */ - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_pool_create_core_ex_debug(apr_pool_t **newpool, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator, - const char *file_line) -{ - return apr_pool_create_unmanaged_ex_debug(newpool, abort_fn, allocator, - file_line); -} - -APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex_debug(apr_pool_t **newpool, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator, - const char *file_line) -{ - apr_pool_t *pool; - apr_allocator_t *pool_allocator; - - *newpool = NULL; - - if ((pool = malloc(SIZEOF_POOL_T)) == NULL) { - if (abort_fn) - abort_fn(APR_ENOMEM); - - return APR_ENOMEM; - } - - memset(pool, 0, SIZEOF_POOL_T); - - pool->abort_fn = abort_fn; - pool->tag = file_line; - pool->file_line = file_line; - -#if APR_HAS_THREADS - pool->owner = apr_os_thread_current(); -#endif /* APR_HAS_THREADS */ -#ifdef NETWARE - pool->owner_proc = (apr_os_proc_t)getnlmhandle(); -#endif /* defined(NETWARE) */ - - if ((pool_allocator = allocator) == NULL) { - apr_status_t rv; - if ((rv = apr_allocator_create(&pool_allocator)) != APR_SUCCESS) { - if (abort_fn) - abort_fn(rv); - return rv; - } - pool_allocator->owner = pool; - } - pool->allocator = pool_allocator; - - if (pool->allocator != allocator) { -#if APR_HAS_THREADS - apr_status_t rv; - - /* No matter what the creation flags say, always create - * a lock. Without it integrity_check and apr_pool_num_bytes - * blow up (because they traverse pools child lists that - * possibly belong to another thread, in combination with - * the pool having no lock). However, this might actually - * hide problems like creating a child pool of a pool - * belonging to another thread. - */ - if ((rv = apr_thread_mutex_create(&pool->mutex, - APR_THREAD_MUTEX_NESTED, pool)) != APR_SUCCESS) { - free(pool); - return rv; - } -#endif /* APR_HAS_THREADS */ - } - - *newpool = pool; - -#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE) - apr_pool_log_event(pool, "CREATE", file_line, 1); -#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE) */ - - return APR_SUCCESS; -} - -/* - * "Print" functions (debug) - */ - -struct psprintf_data { - apr_vformatter_buff_t vbuff; - char *mem; - apr_size_t size; -}; - -static int psprintf_flush(apr_vformatter_buff_t *vbuff) -{ - struct psprintf_data *ps = (struct psprintf_data *)vbuff; - apr_size_t size; - - size = ps->vbuff.curpos - ps->mem; - - ps->size <<= 1; - if ((ps->mem = realloc(ps->mem, ps->size)) == NULL) - return -1; - - ps->vbuff.curpos = ps->mem + size; - ps->vbuff.endpos = ps->mem + ps->size - 1; - - return 0; -} - -APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *pool, const char *fmt, va_list ap) -{ - struct psprintf_data ps; - debug_node_t *node; - - apr_pool_check_integrity(pool); - - ps.size = 64; - ps.mem = malloc(ps.size); - ps.vbuff.curpos = ps.mem; - - /* Save a byte for the NUL terminator */ - ps.vbuff.endpos = ps.mem + ps.size - 1; - - if (apr_vformatter(psprintf_flush, &ps.vbuff, fmt, ap) == -1) { - if (pool->abort_fn) - pool->abort_fn(APR_ENOMEM); - - return NULL; - } - - *ps.vbuff.curpos++ = '\0'; - - /* - * Link the node in - */ - node = pool->nodes; - if (node == NULL || node->index == 64) { - if ((node = malloc(SIZEOF_DEBUG_NODE_T)) == NULL) { - if (pool->abort_fn) - pool->abort_fn(APR_ENOMEM); - - return NULL; - } - - node->next = pool->nodes; - pool->nodes = node; - node->index = 0; - } - - node->beginp[node->index] = ps.mem; - node->endp[node->index] = ps.mem + ps.size; - node->index++; - - return ps.mem; -} - - -/* - * Debug functions - */ - -APR_DECLARE(void) apr_pool_join(apr_pool_t *p, apr_pool_t *sub) -{ -#if APR_POOL_DEBUG - if (sub->parent != p) { - abort(); - } - sub->joined = p; -#endif -} - -static int pool_find(apr_pool_t *pool, void *data) -{ - void **pmem = (void **)data; - debug_node_t *node; - apr_uint32_t index; - - node = pool->nodes; - - while (node) { - for (index = 0; index < node->index; index++) { - if (node->beginp[index] <= *pmem - && node->endp[index] > *pmem) { - *pmem = pool; - return 1; - } - } - - node = node->next; - } - - return 0; -} - -APR_DECLARE(apr_pool_t *) apr_pool_find(const void *mem) -{ - void *pool = (void *)mem; - - if (apr_pool_walk_tree(global_pool, pool_find, &pool)) - return pool; - - return NULL; -} - -static int pool_num_bytes(apr_pool_t *pool, void *data) -{ - apr_size_t *psize = (apr_size_t *)data; - debug_node_t *node; - apr_uint32_t index; - - node = pool->nodes; - - while (node) { - for (index = 0; index < node->index; index++) { - *psize += (char *)node->endp[index] - (char *)node->beginp[index]; - } - - node = node->next; - } - - return 0; -} - -APR_DECLARE(apr_size_t) apr_pool_num_bytes(apr_pool_t *pool, int recurse) -{ - apr_size_t size = 0; - - if (!recurse) { - pool_num_bytes(pool, &size); - - return size; - } - - apr_pool_walk_tree(pool, pool_num_bytes, &size); - - return size; -} - -APR_DECLARE(void) apr_pool_lock(apr_pool_t *pool, int flag) -{ -} - -#endif /* !APR_POOL_DEBUG */ - -#ifdef NETWARE -void netware_pool_proc_cleanup () -{ - apr_pool_t *pool = global_pool->child; - apr_os_proc_t owner_proc = (apr_os_proc_t)getnlmhandle(); - - while (pool) { - if (pool->owner_proc == owner_proc) { - apr_pool_destroy (pool); - pool = global_pool->child; - } - else { - pool = pool->sibling; - } - } - return; -} -#endif /* defined(NETWARE) */ - - -/* - * "Print" functions (common) - */ - -APR_DECLARE_NONSTD(char *) apr_psprintf(apr_pool_t *p, const char *fmt, ...) -{ - va_list ap; - char *res; - - va_start(ap, fmt); - res = apr_pvsprintf(p, fmt, ap); - va_end(ap); - return res; -} - -/* - * Pool Properties - */ - -APR_DECLARE(void) apr_pool_abort_set(apr_abortfunc_t abort_fn, - apr_pool_t *pool) -{ - pool->abort_fn = abort_fn; -} - -APR_DECLARE(apr_abortfunc_t) apr_pool_abort_get(apr_pool_t *pool) -{ - return pool->abort_fn; -} - -APR_DECLARE(apr_pool_t *) apr_pool_parent_get(apr_pool_t *pool) -{ -#ifdef NETWARE - /* On NetWare, don't return the global_pool, return the application pool - as the top most pool */ - if (pool->parent == global_pool) - return pool; - else -#endif - return pool->parent; -} - -APR_DECLARE(apr_allocator_t *) apr_pool_allocator_get(apr_pool_t *pool) -{ - return pool->allocator; -} - -/* return TRUE if a is an ancestor of b - * NULL is considered an ancestor of all pools - */ -APR_DECLARE(int) apr_pool_is_ancestor(apr_pool_t *a, apr_pool_t *b) -{ - if (a == NULL) - return 1; - -#if APR_POOL_DEBUG - /* Find the pool with the longest lifetime guaranteed by the - * caller: */ - while (a->joined) { - a = a->joined; - } -#endif - - while (b) { - if (a == b) - return 1; - - b = b->parent; - } - - return 0; -} - -APR_DECLARE(void) apr_pool_tag(apr_pool_t *pool, const char *tag) -{ - pool->tag = tag; -} - - -/* - * User data management - */ - -APR_DECLARE(apr_status_t) apr_pool_userdata_set(const void *data, const char *key, - apr_status_t (*cleanup) (void *), - apr_pool_t *pool) -{ -#if APR_POOL_DEBUG - apr_pool_check_integrity(pool); -#endif /* APR_POOL_DEBUG */ - - if (pool->user_data == NULL) - pool->user_data = apr_hash_make(pool); - - if (apr_hash_get(pool->user_data, key, APR_HASH_KEY_STRING) == NULL) { - char *new_key = apr_pstrdup(pool, key); - apr_hash_set(pool->user_data, new_key, APR_HASH_KEY_STRING, data); - } - else { - apr_hash_set(pool->user_data, key, APR_HASH_KEY_STRING, data); - } - - if (cleanup) - apr_pool_cleanup_register(pool, data, cleanup, cleanup); - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_pool_userdata_setn(const void *data, - const char *key, - apr_status_t (*cleanup)(void *), - apr_pool_t *pool) -{ -#if APR_POOL_DEBUG - apr_pool_check_integrity(pool); -#endif /* APR_POOL_DEBUG */ - - if (pool->user_data == NULL) - pool->user_data = apr_hash_make(pool); - - apr_hash_set(pool->user_data, key, APR_HASH_KEY_STRING, data); - - if (cleanup) - apr_pool_cleanup_register(pool, data, cleanup, cleanup); - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_pool_userdata_get(void **data, const char *key, - apr_pool_t *pool) -{ -#if APR_POOL_DEBUG - apr_pool_check_integrity(pool); -#endif /* APR_POOL_DEBUG */ - - if (pool->user_data == NULL) { - *data = NULL; - } - else { - *data = apr_hash_get(pool->user_data, key, APR_HASH_KEY_STRING); - } - - return APR_SUCCESS; -} - - -/* - * Cleanup - */ - -struct cleanup_t { - struct cleanup_t *next; - const void *data; - apr_status_t (*plain_cleanup_fn)(void *data); - apr_status_t (*child_cleanup_fn)(void *data); -}; - -APR_DECLARE(void) apr_pool_cleanup_register(apr_pool_t *p, const void *data, - apr_status_t (*plain_cleanup_fn)(void *data), - apr_status_t (*child_cleanup_fn)(void *data)) -{ - cleanup_t *c; - -#if APR_POOL_DEBUG - apr_pool_check_integrity(p); -#endif /* APR_POOL_DEBUG */ - - if (p != NULL) { - if (p->free_cleanups) { - /* reuse a cleanup structure */ - c = p->free_cleanups; - p->free_cleanups = c->next; - } else { - c = apr_palloc(p, sizeof(cleanup_t)); - } - c->data = data; - c->plain_cleanup_fn = plain_cleanup_fn; - c->child_cleanup_fn = child_cleanup_fn; - c->next = p->cleanups; - p->cleanups = c; - } -} - -APR_DECLARE(void) apr_pool_pre_cleanup_register(apr_pool_t *p, const void *data, - apr_status_t (*plain_cleanup_fn)(void *data)) -{ - cleanup_t *c; - -#if APR_POOL_DEBUG - apr_pool_check_integrity(p); -#endif /* APR_POOL_DEBUG */ - - if (p != NULL) { - if (p->free_cleanups) { - /* reuse a cleanup structure */ - c = p->free_cleanups; - p->free_cleanups = c->next; - } else { - c = apr_palloc(p, sizeof(cleanup_t)); - } - c->data = data; - c->plain_cleanup_fn = plain_cleanup_fn; - c->next = p->pre_cleanups; - p->pre_cleanups = c; - } -} - -APR_DECLARE(void) apr_pool_cleanup_kill(apr_pool_t *p, const void *data, - apr_status_t (*cleanup_fn)(void *)) -{ - cleanup_t *c, **lastp; - -#if APR_POOL_DEBUG - apr_pool_check_integrity(p); -#endif /* APR_POOL_DEBUG */ - - if (p == NULL) - return; - - c = p->cleanups; - lastp = &p->cleanups; - while (c) { -#if APR_POOL_DEBUG - /* Some cheap loop detection to catch a corrupt list: */ - if (c == c->next - || (c->next && c == c->next->next) - || (c->next && c->next->next && c == c->next->next->next)) { - abort(); - } -#endif - - if (c->data == data && c->plain_cleanup_fn == cleanup_fn) { - *lastp = c->next; - /* move to freelist */ - c->next = p->free_cleanups; - p->free_cleanups = c; - break; - } - - lastp = &c->next; - c = c->next; - } - - /* Remove any pre-cleanup as well */ - c = p->pre_cleanups; - lastp = &p->pre_cleanups; - while (c) { -#if APR_POOL_DEBUG - /* Some cheap loop detection to catch a corrupt list: */ - if (c == c->next - || (c->next && c == c->next->next) - || (c->next && c->next->next && c == c->next->next->next)) { - abort(); - } -#endif - - if (c->data == data && c->plain_cleanup_fn == cleanup_fn) { - *lastp = c->next; - /* move to freelist */ - c->next = p->free_cleanups; - p->free_cleanups = c; - break; - } - - lastp = &c->next; - c = c->next; - } - -} - -APR_DECLARE(void) apr_pool_child_cleanup_set(apr_pool_t *p, const void *data, - apr_status_t (*plain_cleanup_fn)(void *), - apr_status_t (*child_cleanup_fn)(void *)) -{ - cleanup_t *c; - -#if APR_POOL_DEBUG - apr_pool_check_integrity(p); -#endif /* APR_POOL_DEBUG */ - - if (p == NULL) - return; - - c = p->cleanups; - while (c) { - if (c->data == data && c->plain_cleanup_fn == plain_cleanup_fn) { - c->child_cleanup_fn = child_cleanup_fn; - break; - } - - c = c->next; - } -} - -APR_DECLARE(apr_status_t) apr_pool_cleanup_run(apr_pool_t *p, void *data, - apr_status_t (*cleanup_fn)(void *)) -{ - apr_pool_cleanup_kill(p, data, cleanup_fn); - return (*cleanup_fn)(data); -} - -static void run_cleanups(cleanup_t **cref) -{ - cleanup_t *c = *cref; - - while (c) { - *cref = c->next; - (*c->plain_cleanup_fn)((void *)c->data); - c = *cref; - } -} - -#if !defined(WIN32) && !defined(OS2) - -static void run_child_cleanups(cleanup_t **cref) -{ - cleanup_t *c = *cref; - - while (c) { - *cref = c->next; - (*c->child_cleanup_fn)((void *)c->data); - c = *cref; - } -} - -static void cleanup_pool_for_exec(apr_pool_t *p) -{ - run_child_cleanups(&p->cleanups); - - for (p = p->child; p; p = p->sibling) - cleanup_pool_for_exec(p); -} - -APR_DECLARE(void) apr_pool_cleanup_for_exec(void) -{ - cleanup_pool_for_exec(global_pool); -} - -#else /* !defined(WIN32) && !defined(OS2) */ - -APR_DECLARE(void) apr_pool_cleanup_for_exec(void) -{ - /* - * Don't need to do anything on NT or OS/2, because - * these platforms will spawn the new process - not - * fork for exec. All handles that are not inheritable, - * will be automajically closed. The only problem is - * with file handles that are open, but there isn't - * much that can be done about that (except if the - * child decides to go out and close them, or the - * developer quits opening them shared) - */ - return; -} - -#endif /* !defined(WIN32) && !defined(OS2) */ - -APR_DECLARE_NONSTD(apr_status_t) apr_pool_cleanup_null(void *data) -{ - /* do nothing cleanup routine */ - return APR_SUCCESS; -} - -/* Subprocesses don't use the generic cleanup interface because - * we don't want multiple subprocesses to result in multiple - * three-second pauses; the subprocesses have to be "freed" all - * at once. If other resources are introduced with the same property, - * we might want to fold support for that into the generic interface. - * For now, it's a special case. - */ -APR_DECLARE(void) apr_pool_note_subprocess(apr_pool_t *pool, apr_proc_t *proc, - apr_kill_conditions_e how) -{ - struct process_chain *pc = apr_palloc(pool, sizeof(struct process_chain)); - - pc->proc = proc; - pc->kill_how = how; - pc->next = pool->subprocesses; - pool->subprocesses = pc; -} - -static void free_proc_chain(struct process_chain *procs) -{ - /* Dispose of the subprocesses we've spawned off in the course of - * whatever it was we're cleaning up now. This may involve killing - * some of them off... - */ - struct process_chain *pc; - int need_timeout = 0; - apr_time_t timeout_interval; - - if (!procs) - return; /* No work. Whew! */ - - /* First, check to see if we need to do the SIGTERM, sleep, SIGKILL - * dance with any of the processes we're cleaning up. If we've got - * any kill-on-sight subprocesses, ditch them now as well, so they - * don't waste any more cycles doing whatever it is that they shouldn't - * be doing anymore. - */ - -#ifndef NEED_WAITPID - /* Pick up all defunct processes */ - for (pc = procs; pc; pc = pc->next) { - if (apr_proc_wait(pc->proc, NULL, NULL, APR_NOWAIT) != APR_CHILD_NOTDONE) - pc->kill_how = APR_KILL_NEVER; - } -#endif /* !defined(NEED_WAITPID) */ - - for (pc = procs; pc; pc = pc->next) { -#ifndef WIN32 - if ((pc->kill_how == APR_KILL_AFTER_TIMEOUT) - || (pc->kill_how == APR_KILL_ONLY_ONCE)) { - /* - * Subprocess may be dead already. Only need the timeout if not. - * Note: apr_proc_kill on Windows is TerminateProcess(), which is - * similar to a SIGKILL, so always give the process a timeout - * under Windows before killing it. - */ - if (apr_proc_kill(pc->proc, SIGTERM) == APR_SUCCESS) - need_timeout = 1; - } - else if (pc->kill_how == APR_KILL_ALWAYS) { -#else /* WIN32 knows only one fast, clean method of killing processes today */ - if (pc->kill_how != APR_KILL_NEVER) { - need_timeout = 1; - pc->kill_how = APR_KILL_ALWAYS; -#endif - apr_proc_kill(pc->proc, SIGKILL); - } - } - - /* Sleep only if we have to. The sleep algorithm grows - * by a factor of two on each iteration. TIMEOUT_INTERVAL - * is equal to TIMEOUT_USECS / 64. - */ - if (need_timeout) { - timeout_interval = TIMEOUT_INTERVAL; - apr_sleep(timeout_interval); - - do { - /* check the status of the subprocesses */ - need_timeout = 0; - for (pc = procs; pc; pc = pc->next) { - if (pc->kill_how == APR_KILL_AFTER_TIMEOUT) { - if (apr_proc_wait(pc->proc, NULL, NULL, APR_NOWAIT) - == APR_CHILD_NOTDONE) - need_timeout = 1; /* subprocess is still active */ - else - pc->kill_how = APR_KILL_NEVER; /* subprocess has exited */ - } - } - if (need_timeout) { - if (timeout_interval >= TIMEOUT_USECS) { - break; - } - apr_sleep(timeout_interval); - timeout_interval *= 2; - } - } while (need_timeout); - } - - /* OK, the scripts we just timed out for have had a chance to clean up - * --- now, just get rid of them, and also clean up the system accounting - * goop... - */ - for (pc = procs; pc; pc = pc->next) { - if (pc->kill_how == APR_KILL_AFTER_TIMEOUT) - apr_proc_kill(pc->proc, SIGKILL); - } - - /* Now wait for all the signaled processes to die */ - for (pc = procs; pc; pc = pc->next) { - if (pc->kill_how != APR_KILL_NEVER) - (void)apr_proc_wait(pc->proc, NULL, NULL, APR_WAIT); - } -} - - -/* - * Pool creation/destruction stubs, for people who are running - * mixed release/debug enviroments. - */ - -#if !APR_POOL_DEBUG -APR_DECLARE(void *) apr_palloc_debug(apr_pool_t *pool, apr_size_t size, - const char *file_line) -{ - return apr_palloc(pool, size); -} - -APR_DECLARE(void *) apr_pcalloc_debug(apr_pool_t *pool, apr_size_t size, - const char *file_line) -{ - return apr_pcalloc(pool, size); -} - -APR_DECLARE(void) apr_pool_clear_debug(apr_pool_t *pool, - const char *file_line) -{ - apr_pool_clear(pool); -} - -APR_DECLARE(void) apr_pool_destroy_debug(apr_pool_t *pool, - const char *file_line) -{ - apr_pool_destroy(pool); -} - -APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool, - apr_pool_t *parent, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator, - const char *file_line) -{ - return apr_pool_create_ex(newpool, parent, abort_fn, allocator); -} - -APR_DECLARE(apr_status_t) apr_pool_create_core_ex_debug(apr_pool_t **newpool, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator, - const char *file_line) -{ - return apr_pool_create_unmanaged_ex(newpool, abort_fn, allocator); -} - -APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex_debug(apr_pool_t **newpool, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator, - const char *file_line) -{ - return apr_pool_create_unmanaged_ex(newpool, abort_fn, allocator); -} - -#else /* APR_POOL_DEBUG */ - -#undef apr_palloc -APR_DECLARE(void *) apr_palloc(apr_pool_t *pool, apr_size_t size); - -APR_DECLARE(void *) apr_palloc(apr_pool_t *pool, apr_size_t size) -{ - return apr_palloc_debug(pool, size, "undefined"); -} - -#undef apr_pcalloc -APR_DECLARE(void *) apr_pcalloc(apr_pool_t *pool, apr_size_t size); - -APR_DECLARE(void *) apr_pcalloc(apr_pool_t *pool, apr_size_t size) -{ - return apr_pcalloc_debug(pool, size, "undefined"); -} - -#undef apr_pool_clear -APR_DECLARE(void) apr_pool_clear(apr_pool_t *pool); - -APR_DECLARE(void) apr_pool_clear(apr_pool_t *pool) -{ - apr_pool_clear_debug(pool, "undefined"); -} - -#undef apr_pool_destroy -APR_DECLARE(void) apr_pool_destroy(apr_pool_t *pool); - -APR_DECLARE(void) apr_pool_destroy(apr_pool_t *pool) -{ - apr_pool_destroy_debug(pool, "undefined"); -} - -#undef apr_pool_create_ex -APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool, - apr_pool_t *parent, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator); - -APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool, - apr_pool_t *parent, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator) -{ - return apr_pool_create_ex_debug(newpool, parent, - abort_fn, allocator, - "undefined"); -} - -#undef apr_pool_create_core_ex -APR_DECLARE(apr_status_t) apr_pool_create_core_ex(apr_pool_t **newpool, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator); - -APR_DECLARE(apr_status_t) apr_pool_create_core_ex(apr_pool_t **newpool, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator) -{ - return apr_pool_create_unmanaged_ex_debug(newpool, abort_fn, - allocator, "undefined"); -} - -#undef apr_pool_create_unmanaged_ex -APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex(apr_pool_t **newpool, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator); - -APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex(apr_pool_t **newpool, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator) -{ - return apr_pool_create_unmanaged_ex_debug(newpool, abort_fn, - allocator, "undefined"); -} - -#endif /* APR_POOL_DEBUG */ diff --git a/libs/apr/misc/netware/apr.xdc b/libs/apr/misc/netware/apr.xdc deleted file mode 100644 index 12a7f6ba..00000000 Binary files a/libs/apr/misc/netware/apr.xdc and /dev/null differ diff --git a/libs/apr/misc/netware/aprlib.def b/libs/apr/misc/netware/aprlib.def deleted file mode 100644 index 0a2a01eb..00000000 --- a/libs/apr/misc/netware/aprlib.def +++ /dev/null @@ -1,3 +0,0 @@ -MODULE LIBC.NLM -MODULE WS2_32.NLM -EXPORT @aprlib.imp diff --git a/libs/apr/misc/netware/charset.c b/libs/apr/misc/netware/charset.c deleted file mode 100644 index b79add10..00000000 --- a/libs/apr/misc/netware/charset.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_strings.h" -#include "apr_portable.h" - -/* static struct utsname sysinfo; */ - -/* XXX This needs to be fixed to produce the correct system language */ - -APR_DECLARE(const char*) apr_os_default_encoding (apr_pool_t *pool) -{ - return apr_pstrdup(pool, "CP1252"); -} - - -APR_DECLARE(const char*) apr_os_locale_encoding (apr_pool_t *pool) -{ - return apr_os_default_encoding(pool); -} diff --git a/libs/apr/misc/netware/libprews.c b/libs/apr/misc/netware/libprews.c deleted file mode 100644 index 6e37ccf1..00000000 --- a/libs/apr/misc/netware/libprews.c +++ /dev/null @@ -1,186 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include -#include - -#include "apr_pools.h" -#include "apr_private.h" -#include "apr_arch_internal_time.h" - - -/* library-private data...*/ -int gLibId = -1; -void *gLibHandle = (void *) NULL; -NXMutex_t *gLibLock = (NXMutex_t *) NULL; - -/* internal library function prototypes...*/ -int DisposeLibraryData(void *); - -int _NonAppStart -( - void *NLMHandle, - void *errorScreen, - const char *cmdLine, - const char *loadDirPath, - size_t uninitializedDataLength, - void *NLMFileHandle, - int (*readRoutineP)( int conn, void *fileHandle, size_t offset, - size_t nbytes, size_t *bytesRead, void *buffer ), - size_t customDataOffset, - size_t customDataSize, - int messageCount, - const char **messages -) -{ -#ifdef USE_WINSOCK - WSADATA wsaData; -#endif - apr_status_t status; - - NX_LOCK_INFO_ALLOC(liblock, "Per-Application Data Lock", 0); - -#pragma unused(cmdLine) -#pragma unused(loadDirPath) -#pragma unused(uninitializedDataLength) -#pragma unused(NLMFileHandle) -#pragma unused(readRoutineP) -#pragma unused(customDataOffset) -#pragma unused(customDataSize) -#pragma unused(messageCount) -#pragma unused(messages) - - gLibId = register_library(DisposeLibraryData); - - if (gLibId < -1) - { - OutputToScreen(errorScreen, "Unable to register library with kernel.\n"); - return -1; - } - - gLibHandle = NLMHandle; - - gLibLock = NXMutexAlloc(0, 0, &liblock); - - if (!gLibLock) - { - OutputToScreen(errorScreen, "Unable to allocate library data lock.\n"); - return -1; - } - - apr_netware_setup_time(); - - if ((status = apr_pool_initialize()) != APR_SUCCESS) - return status; - -#ifdef USE_WINSOCK - return WSAStartup((WORD) MAKEWORD(2, 0), &wsaData); -#else - return 0; -#endif -} - -void _NonAppStop( void ) -{ - apr_pool_terminate(); - -#ifdef USE_WINSOCK - WSACleanup(); -#endif - - unregister_library(gLibId); - NXMutexFree(gLibLock); -} - -int _NonAppCheckUnload( void ) -{ - return 0; -} - -int register_NLM(void *NLMHandle) -{ - APP_DATA *app_data = (APP_DATA*) get_app_data(gLibId); - - NXLock(gLibLock); - if (!app_data) { - app_data = (APP_DATA*)library_malloc(gLibHandle, sizeof(APP_DATA)); - - if (app_data) { - memset (app_data, 0, sizeof(APP_DATA)); - set_app_data(gLibId, app_data); - app_data->gs_nlmhandle = NLMHandle; - } - } - - if (app_data && (!app_data->initialized)) { - app_data->initialized = 1; - NXUnlock(gLibLock); - return 0; - } - - NXUnlock(gLibLock); - return 1; -} - -int unregister_NLM(void *NLMHandle) -{ - APP_DATA *app_data = (APP_DATA*) get_app_data(gLibId); - - NXLock(gLibLock); - if (app_data) { - app_data->initialized = 0; - NXUnlock(gLibLock); - return 0; - } - NXUnlock(gLibLock); - return 1; -} - -int DisposeLibraryData(void *data) -{ - if (data) - { - library_free(data); - } - - return 0; -} - -int setGlobalPool(void *data) -{ - APP_DATA *app_data = (APP_DATA*) get_app_data(gLibId); - - NXLock(gLibLock); - - if (app_data && !app_data->gPool) { - app_data->gPool = data; - } - - NXUnlock(gLibLock); - return 1; -} - -void* getGlobalPool() -{ - APP_DATA *app_data = (APP_DATA*) get_app_data(gLibId); - - if (app_data) { - return app_data->gPool; - } - - return NULL; -} - diff --git a/libs/apr/misc/netware/rand.c b/libs/apr/misc/netware/rand.c deleted file mode 100644 index a2baae7e..00000000 --- a/libs/apr/misc/netware/rand.c +++ /dev/null @@ -1,70 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define APR_WANT_MEMFUNC -#include "apr_want.h" -#include "apr_general.h" -#include "apr_private.h" - -#if APR_HAS_RANDOM - -#include - -static int NXSeedRandomInternal( size_t width, void *seed ) -{ - static int init = 0; - int *s = (int *) seed; - union { int x; char y[4]; } u; - - if (!init) { - srand(NXGetSystemTick()); - init = 1; - } - - if (width > 3) - { - do - { - *s++ = rand(); - } - while ((width -= 4) > 3); - } - - if (width > 0) - { - char *p = (char *) s; - - u.x = rand(); - - while (width > 0) - *p++ = u.y[width--]; - } - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char *buf, - apr_size_t length) -{ - if (NXSeedRandom(length, buf) != 0) { - return NXSeedRandomInternal (length, buf); - } - return APR_SUCCESS; -} - - - -#endif /* APR_HAS_RANDOM */ diff --git a/libs/apr/misc/netware/start.c b/libs/apr/misc/netware/start.c deleted file mode 100644 index 76817d96..00000000 --- a/libs/apr/misc/netware/start.c +++ /dev/null @@ -1,203 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_signal.h" - -#include "apr_arch_misc.h" /* for WSAHighByte / WSALowByte */ -#include "apr_arch_proc_mutex.h" /* for apr_proc_mutex_unix_setup_lock() */ -#include "apr_arch_internal_time.h" -#include "apr_ldap.h" /* for apr_ldap_rebind_init() */ - -#ifdef USE_WINSOCK -/* Prototypes missing from older NDKs */ -int WSAStartupRTags(WORD wVersionRequested, - LPWSADATA lpWSAData, - rtag_t WSAStartupRTag, - rtag_t WSPSKTRTag, - rtag_t lookUpServiceBeginRTag, - rtag_t WSAEventRTag, - rtag_t WSPCPRTag); - -int WSACleanupRTag(rtag_t rTag); - -/* -** Resource tag signatures for using NetWare WinSock 2. These will no longer -** be needed by anyone once the new WSAStartupWithNlmHandle() is available -** since WinSock will make the calls to AllocateResourceTag(). -*/ -#define WS_LOAD_ENTRY_SIGNATURE (*(unsigned long *) "WLDE") -#define WS_SKT_SIGNATURE (*(unsigned long *) "WSKT") -#define WS_LOOKUP_SERVICE_SIGNATURE (*(unsigned long *) "WLUP") -#define WS_WSAEVENT_SIGNATURE (*(unsigned long *) "WEVT") -#define WS_CPORT_SIGNATURE (*(unsigned long *) "WCPT") - - -int (*WSAStartupWithNLMHandle)( WORD version, LPWSADATA data, void *handle ) = NULL; -int (*WSACleanupWithNLMHandle)( void *handle ) = NULL; - -static int wsa_startup_with_handle (WORD wVersionRequested, LPWSADATA data, void *handle) -{ - APP_DATA *app_data; - - if (!(app_data = (APP_DATA*) get_app_data(gLibId))) - return APR_EGENERAL; - - app_data->gs_startup_rtag = AllocateResourceTag(handle, "WinSock Start-up", WS_LOAD_ENTRY_SIGNATURE); - app_data->gs_socket_rtag = AllocateResourceTag(handle, "WinSock socket()", WS_SKT_SIGNATURE); - app_data->gs_lookup_rtag = AllocateResourceTag(handle, "WinSock Look-up", WS_LOOKUP_SERVICE_SIGNATURE); - app_data->gs_event_rtag = AllocateResourceTag(handle, "WinSock Event", WS_WSAEVENT_SIGNATURE); - app_data->gs_pcp_rtag = AllocateResourceTag(handle, "WinSock C-Port", WS_CPORT_SIGNATURE); - - return WSAStartupRTags(wVersionRequested, data, - app_data->gs_startup_rtag, - app_data->gs_socket_rtag, - app_data->gs_lookup_rtag, - app_data->gs_event_rtag, - app_data->gs_pcp_rtag); -} - -static int wsa_cleanup_with_handle (void *handle) -{ - APP_DATA *app_data; - - if (!(app_data = (APP_DATA*) get_app_data(gLibId))) - return APR_EGENERAL; - - return WSACleanupRTag(app_data->gs_startup_rtag); -} - -static int UnregisterAppWithWinSock (void *nlm_handle) -{ - if (!WSACleanupWithNLMHandle) - { - if (!(WSACleanupWithNLMHandle = ImportPublicObject(gLibHandle, "WSACleanupWithNLMHandle"))) - WSACleanupWithNLMHandle = wsa_cleanup_with_handle; - } - - return (*WSACleanupWithNLMHandle)(nlm_handle); -} - -static int RegisterAppWithWinSock (void *nlm_handle) -{ - int err; - WSADATA wsaData; - WORD wVersionRequested = MAKEWORD(WSAHighByte, WSALowByte); - - if (!WSAStartupWithNLMHandle) - { - if (!(WSAStartupWithNLMHandle = ImportPublicObject(gLibHandle, "WSAStartupWithNLMHandle"))) - WSAStartupWithNLMHandle = wsa_startup_with_handle; - } - - err = (*WSAStartupWithNLMHandle)(wVersionRequested, &wsaData, nlm_handle); - - if (LOBYTE(wsaData.wVersion) != WSAHighByte || - HIBYTE(wsaData.wVersion) != WSALowByte) { - - UnregisterAppWithWinSock (nlm_handle); - return APR_EEXIST; - } - - return err; -} -#endif - - - -APR_DECLARE(apr_status_t) apr_app_initialize(int *argc, - const char * const * *argv, - const char * const * *env) -{ - /* An absolute noop. At present, only Win32 requires this stub, but it's - * required in order to move command arguments passed through the service - * control manager into the process, and it's required to fix the char* - * data passed in from win32 unicode into utf-8, win32's apr internal fmt. - */ - return apr_initialize(); -} - -APR_DECLARE(apr_status_t) apr_initialize(void) -{ - apr_pool_t *pool; - void *nlmhandle = getnlmhandle(); - - /* Register the NLM as using APR. If it is already - registered then just return. */ - if (register_NLM(nlmhandle) != 0) { - return APR_SUCCESS; - } - - /* apr_pool_initialize() is being called from the library - startup code since all of the memory resources belong - to the library rather than the application. */ - - if (apr_pool_create(&pool, NULL) != APR_SUCCESS) { - return APR_ENOPOOL; - } - - apr_pool_tag(pool, "apr_initilialize"); - -#ifdef USE_WINSOCK - { - int err; - if ((err = RegisterAppWithWinSock (nlmhandle))) { - return err; - } - } -#endif - - apr_signal_init(pool); -#if APR_HAS_LDAP - apr_ldap_rebind_init(pool); -#endif - - return APR_SUCCESS; -} - -APR_DECLARE_NONSTD(void) apr_terminate(void) -{ - APP_DATA *app_data; - - /* Get our instance data for shutting down. */ - if (!(app_data = (APP_DATA*) get_app_data(gLibId))) - return; - - /* Unregister the NLM. If it is not registered - then just return. */ - if (unregister_NLM(app_data->gs_nlmhandle) != 0) { - return; - } - - /* apr_pool_terminate() is being called from the - library shutdown code since the memory resources - belong to the library rather than the application */ - - /* Just clean up the memory for the app that is going - away. */ - netware_pool_proc_cleanup (); - -#ifdef USE_WINSOCK - UnregisterAppWithWinSock (app_data->gs_nlmhandle); -#endif -} - -APR_DECLARE(void) apr_terminate2(void) -{ - apr_terminate(); -} diff --git a/libs/apr/misc/unix/charset.c b/libs/apr/misc/unix/charset.c deleted file mode 100644 index a16310cd..00000000 --- a/libs/apr/misc/unix/charset.c +++ /dev/null @@ -1,83 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_private.h" -#include "apr_strings.h" -#include "apr_portable.h" - -#ifdef HAVE_LANGINFO_H -#include -#endif - -/* - * simple heuristic to determine codepage of source code so that - * literal strings (e.g., "GET /\r\n") in source code can be translated - * properly - * - * If appropriate, a symbol can be set at configure time to determine - * this. On EBCDIC platforms, it will be important how the code was - * unpacked. - */ - -APR_DECLARE(const char*) apr_os_default_encoding (apr_pool_t *pool) -{ -#ifdef __MVS__ -# ifdef __CODESET__ - return __CODESET__; -# else - return "IBM-1047"; -# endif -#endif - - if ('}' == 0xD0) { - return "IBM-1047"; - } - - if ('{' == 0xFB) { - return "EDF04"; - } - - if ('A' == 0xC1) { - return "EBCDIC"; /* not useful */ - } - - if ('A' == 0x41) { - return "ISO-8859-1"; /* not necessarily true */ - } - - return "unknown"; -} - - -APR_DECLARE(const char*) apr_os_locale_encoding (apr_pool_t *pool) -{ -#if defined(HAVE_NL_LANGINFO) && defined(CODESET) - const char *charset; - - charset = nl_langinfo(CODESET); - if (charset && *charset) { -#ifdef _OSD_POSIX /* Bug workaround - delete as soon as fixed in OSD_POSIX */ - /* Some versions of OSD_POSIX return nl_langinfo(CODESET)="^[nN]" */ - /* Ignore the bogus information and use apr_os_default_encoding() */ - if (charset[0] != '^') -#endif - return apr_pstrdup(pool, charset); - } -#endif - - return apr_os_default_encoding(pool); -} diff --git a/libs/apr/misc/unix/env.c b/libs/apr/misc/unix/env.c deleted file mode 100644 index b41f8f17..00000000 --- a/libs/apr/misc/unix/env.c +++ /dev/null @@ -1,88 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define APR_WANT_STRFUNC -#include "apr_want.h" -#include "apr.h" -#include "apr_private.h" -#include "apr_env.h" -#include "apr_strings.h" - -#if APR_HAVE_UNISTD_H -#include -#endif -#if APR_HAVE_STDLIB_H -#include -#endif - -APR_DECLARE(apr_status_t) apr_env_get(char **value, - const char *envvar, - apr_pool_t *pool) -{ -#ifdef HAVE_GETENV - - char *val = getenv(envvar); - if (!val) - return APR_ENOENT; - *value = val; - return APR_SUCCESS; - -#else - return APR_ENOTIMPL; -#endif -} - - -APR_DECLARE(apr_status_t) apr_env_set(const char *envvar, - const char *value, - apr_pool_t *pool) -{ -#if defined(HAVE_SETENV) - - if (0 > setenv(envvar, value, 1)) - return APR_ENOMEM; - return APR_SUCCESS; - -#elif defined(HAVE_PUTENV) - - if (0 > putenv(apr_pstrcat(pool, envvar, "=", value, NULL))) - return APR_ENOMEM; - return APR_SUCCESS; - -#else - return APR_ENOTIMPL; -#endif -} - - -APR_DECLARE(apr_status_t) apr_env_delete(const char *envvar, apr_pool_t *pool) -{ -#ifdef HAVE_UNSETENV - - unsetenv(envvar); - return APR_SUCCESS; - -#else - /* hint: some platforms allow envvars to be unset via - * putenv("varname")... that isn't Single Unix spec, - * but if your platform doesn't have unsetenv() it is - * worth investigating and potentially adding a - * configure check to decide when to use that form of - * putenv() here - */ - return APR_ENOTIMPL; -#endif -} diff --git a/libs/apr/misc/unix/errorcodes.c b/libs/apr/misc/unix/errorcodes.c deleted file mode 100644 index 75567c24..00000000 --- a/libs/apr/misc/unix/errorcodes.c +++ /dev/null @@ -1,436 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_misc.h" -#include "apr_strings.h" -#include "apr_lib.h" -#include "apr_dso.h" - -#if APR_HAVE_NETDB_H -#include -#endif -#ifdef HAVE_DLFCN_H -#include -#endif - -/* - * stuffbuffer - like apr_cpystrn() but returns the address of the - * dest buffer instead of the address of the terminating '\0' - */ -static char *stuffbuffer(char *buf, apr_size_t bufsize, const char *s) -{ - apr_cpystrn(buf,s,bufsize); - return buf; -} - -static char *apr_error_string(apr_status_t statcode) -{ - switch (statcode) { - case APR_ENOPOOL: - return "A new pool could not be created."; - case APR_EBADDATE: - return "An invalid date has been provided"; - case APR_EINVALSOCK: - return "An invalid socket was returned"; - case APR_ENOPROC: - return "No process was provided and one was required."; - case APR_ENOTIME: - return "No time was provided and one was required."; - case APR_ENODIR: - return "No directory was provided and one was required."; - case APR_ENOLOCK: - return "No lock was provided and one was required."; - case APR_ENOPOLL: - return "No poll structure was provided and one was required."; - case APR_ENOSOCKET: - return "No socket was provided and one was required."; - case APR_ENOTHREAD: - return "No thread was provided and one was required."; - case APR_ENOTHDKEY: - return "No thread key structure was provided and one was required."; - case APR_ENOSHMAVAIL: - return "No shared memory is currently available"; - case APR_EDSOOPEN: -#if APR_HAS_DSO && defined(HAVE_LIBDL) - return dlerror(); -#else - return "DSO load failed"; -#endif /* HAVE_LIBDL */ - case APR_EBADIP: - return "The specified IP address is invalid."; - case APR_EBADMASK: - return "The specified network mask is invalid."; - - case APR_INCHILD: - return - "Your code just forked, and you are currently executing in the " - "child process"; - case APR_INPARENT: - return - "Your code just forked, and you are currently executing in the " - "parent process"; - case APR_DETACH: - return "The specified thread is detached"; - case APR_NOTDETACH: - return "The specified thread is not detached"; - case APR_CHILD_DONE: - return "The specified child process is done executing"; - case APR_CHILD_NOTDONE: - return "The specified child process is not done executing"; - case APR_TIMEUP: - return "The timeout specified has expired"; - case APR_INCOMPLETE: - return "Partial results are valid but processing is incomplete"; - case APR_BADCH: - return "Bad character specified on command line"; - case APR_BADARG: - return "Missing parameter for the specified command line option"; - case APR_EOF: - return "End of file found"; - case APR_NOTFOUND: - return "Could not find specified socket in poll list."; - case APR_ANONYMOUS: - return "Shared memory is implemented anonymously"; - case APR_FILEBASED: - return "Shared memory is implemented using files"; - case APR_KEYBASED: - return "Shared memory is implemented using a key system"; - case APR_EINIT: - return - "There is no error, this value signifies an initialized " - "error code"; - case APR_ENOTIMPL: - return "This function has not been implemented on this platform"; - case APR_EMISMATCH: - return "passwords do not match"; - case APR_EABSOLUTE: - return "The given path is absolute"; - case APR_ERELATIVE: - return "The given path is relative"; - case APR_EINCOMPLETE: - return "The given path is incomplete"; - case APR_EABOVEROOT: - return "The given path was above the root path"; - case APR_EBADPATH: - return "The given path is misformatted or contained invalid characters"; - case APR_EPATHWILD: - return "The given path contained wildcard characters"; - case APR_EPROC_UNKNOWN: - return "The process is not recognized."; - case APR_EGENERAL: - return "Internal error"; - default: - return "Error string not specified yet"; - } -} - - -#ifdef OS2 -#include - -int apr_canonical_error(apr_status_t err); - -static char *apr_os_strerror(char* buf, apr_size_t bufsize, int err) -{ - char result[200]; - unsigned char message[HUGE_STRING_LEN]; - ULONG len; - char *pos; - int c; - - if (err >= 10000 && err < 12000) { /* socket error codes */ - return stuffbuffer(buf, bufsize, - strerror(apr_canonical_error(err+APR_OS_START_SYSERR))); - } - else if (DosGetMessage(NULL, 0, message, HUGE_STRING_LEN, err, - "OSO001.MSG", &len) == 0) { - len--; - message[len] = 0; - pos = result; - - if (len >= sizeof(result)) - len = sizeof(result) - 1; - - for (c=0; c= 0) { - buf[i] = (char) msg[i]; - } else { - buf[i] = '?'; - } - } -#endif -#endif - - if (!len) { - for (i = 0; gaErrorList[i].msg; ++i) { - if (gaErrorList[i].code == errcode) { - apr_cpystrn(buf, gaErrorList[i].msg, bufsize); - len = strlen(buf); - break; - } - } - } - - if (len) { - /* FormatMessage put the message in the buffer, but it may - * have embedded a newline (\r\n), and possible more than one. - * Remove the newlines replacing them with a space. This is not - * as visually perfect as moving all the remaining message over, - * but more efficient. - */ - i = len; - while (i) { - i--; - if ((buf[i] == '\r') || (buf[i] == '\n')) - buf[i] = ' '; - } - } - else { - /* Windows didn't provide us with a message. Even stuff like * WSAECONNREFUSED won't get a message. - */ - apr_snprintf(buf, bufsize, "Unrecognized Win32 error code %d", errcode); - } - - return buf; -} - -#else -/* On Unix, apr_os_strerror() handles error codes from the resolver - * (h_errno). - */ -static char *apr_os_strerror(char* buf, apr_size_t bufsize, int err) -{ -#ifdef HAVE_HSTRERROR - return stuffbuffer(buf, bufsize, hstrerror(err)); -#else /* HAVE_HSTRERROR */ - const char *msg; - - switch(err) { - case HOST_NOT_FOUND: - msg = "Unknown host"; - break; -#if defined(NO_DATA) - case NO_DATA: -#if defined(NO_ADDRESS) && (NO_DATA != NO_ADDRESS) - case NO_ADDRESS: -#endif - msg = "No address for host"; - break; -#elif defined(NO_ADDRESS) - case NO_ADDRESS: - msg = "No address for host"; - break; -#endif /* NO_DATA */ - default: - msg = "Unrecognized resolver error"; - } - return stuffbuffer(buf, bufsize, msg); -#endif /* HAVE_STRERROR */ -} -#endif - -#if defined(HAVE_STRERROR_R) && defined(STRERROR_R_RC_INT) && !defined(BEOS) -/* AIX and Tru64 style */ -static char *native_strerror(apr_status_t statcode, char *buf, - apr_size_t bufsize) -{ - if (strerror_r(statcode, buf, bufsize) < 0) { - return stuffbuffer(buf, bufsize, - "APR does not understand this error code"); - } - else { - return buf; - } -} -#elif defined(HAVE_STRERROR_R) -/* glibc style */ - -/* BeOS has the function available, but it doesn't provide - * the prototype publically (doh!), so to avoid a build warning - * we add a suitable prototype here. - */ -#if defined(BEOS) -const char *strerror_r(apr_status_t, char *, apr_size_t); -#endif - -static char *native_strerror(apr_status_t statcode, char *buf, - apr_size_t bufsize) -{ - const char *msg; - - buf[0] = '\0'; - msg = strerror_r(statcode, buf, bufsize); - if (buf[0] == '\0') { /* libc didn't use our buffer */ - return stuffbuffer(buf, bufsize, msg); - } - else { - return buf; - } -} -#else -/* plain old strerror(); - * thread-safe on some platforms (e.g., Solaris, OS/390) - */ -static char *native_strerror(apr_status_t statcode, char *buf, - apr_size_t bufsize) -{ -#ifdef _WIN32_WCE - static char err[32]; - sprintf(err, "Native Error #%d", statcode); - return stuffbuffer(buf, bufsize, err); -#else - const char *err = strerror(statcode); - if (err) { - return stuffbuffer(buf, bufsize, err); - } else { - return stuffbuffer(buf, bufsize, - "APR does not understand this error code"); - } -#endif -} -#endif - -APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf, - apr_size_t bufsize) -{ - if (statcode < APR_OS_START_ERROR) { - return native_strerror(statcode, buf, bufsize); - } - else if (statcode < APR_OS_START_USERERR) { - return stuffbuffer(buf, bufsize, apr_error_string(statcode)); - } - else if (statcode < APR_OS_START_EAIERR) { - return stuffbuffer(buf, bufsize, "APR does not understand this error code"); - } - else if (statcode < APR_OS_START_SYSERR) { -#if defined(HAVE_GAI_STRERROR) - statcode -= APR_OS_START_EAIERR; -#if defined(NEGATIVE_EAI) - statcode = -statcode; -#endif - return stuffbuffer(buf, bufsize, gai_strerror(statcode)); -#else - return stuffbuffer(buf, bufsize, "APR does not understand this error code"); -#endif - } - else { - return apr_os_strerror(buf, bufsize, statcode - APR_OS_START_SYSERR); - } -} - diff --git a/libs/apr/misc/unix/getopt.c b/libs/apr/misc/unix/getopt.c deleted file mode 100644 index 24be3c82..00000000 --- a/libs/apr/misc/unix/getopt.c +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright (c) 1987, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "apr_arch_misc.h" -#include "apr_strings.h" -#include "apr_lib.h" - -#define EMSG "" - -APR_DECLARE(apr_status_t) apr_getopt_init(apr_getopt_t **os, apr_pool_t *cont, - int argc, const char *const *argv) -{ - void *argv_buff; - - *os = apr_palloc(cont, sizeof(apr_getopt_t)); - (*os)->cont = cont; - (*os)->reset = 0; - (*os)->errfn = (apr_getopt_err_fn_t*)(fprintf); - (*os)->errarg = (void*)(stderr); - - (*os)->place = EMSG; - (*os)->argc = argc; - - /* The argv parameter must be compatible with main()'s argv, since - that's the primary purpose of this function. But people might - want to use this function with arrays other than the main argv, - and we shouldn't touch the caller's data. So we copy. */ - argv_buff = apr_palloc(cont, (argc + 1) * sizeof(const char *)); - memcpy(argv_buff, argv, argc * sizeof(const char *)); - (*os)->argv = argv_buff; - (*os)->argv[argc] = NULL; - - (*os)->interleave = 0; - (*os)->ind = 1; - (*os)->skip_start = 1; - (*os)->skip_end = 1; - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_getopt(apr_getopt_t *os, const char *opts, - char *optch, const char **optarg) -{ - const char *oli; /* option letter list index */ - - if (os->reset || !*os->place) { /* update scanning pointer */ - os->reset = 0; - if (os->ind >= os->argc || *(os->place = os->argv[os->ind]) != '-') { - os->place = EMSG; - *optch = os->opt; - return (APR_EOF); - } - if (os->place[1] && *++os->place == '-') { /* found "--" */ - ++os->ind; - os->place = EMSG; - *optch = os->opt; - return (APR_EOF); - } - } /* option letter okay? */ - if ((os->opt = (int) *os->place++) == (int) ':' || - !(oli = strchr(opts, os->opt))) { - /* - * if the user didn't specify '-' as an option, - * assume it means -1. - */ - if (os->opt == (int) '-') { - *optch = os->opt; - return (APR_EOF); - } - if (!*os->place) - ++os->ind; - if (os->errfn && *opts != ':') { - (os->errfn)(os->errarg, "%s: illegal option -- %c\n", - apr_filepath_name_get(*os->argv), os->opt); - } - *optch = os->opt; - return (APR_BADCH); - } - if (*++oli != ':') { /* don't need argument */ - *optarg = NULL; - if (!*os->place) - ++os->ind; - } - else { /* need an argument */ - if (*os->place) /* no white space */ - *optarg = os->place; - else if (os->argc <= ++os->ind) { /* no arg */ - os->place = EMSG; - if (*opts == ':') { - *optch = os->opt; - return (APR_BADARG); - } - if (os->errfn) { - (os->errfn)(os->errarg, - "%s: option requires an argument -- %c\n", - apr_filepath_name_get(*os->argv), os->opt); - } - *optch = os->opt; - return (APR_BADCH); - } - else /* white space */ - *optarg = os->argv[os->ind]; - os->place = EMSG; - ++os->ind; - } - *optch = os->opt; - return APR_SUCCESS; -} - -/* Reverse the sequence argv[start..start+len-1]. */ -static void reverse(const char **argv, int start, int len) -{ - const char *temp; - - for (; len >= 2; start++, len -= 2) { - temp = argv[start]; - argv[start] = argv[start + len - 1]; - argv[start + len - 1] = temp; - } -} - -/* - * Permute os->argv with the goal that non-option arguments will all - * appear at the end. os->skip_start is where we started skipping - * non-option arguments, os->skip_end is where we stopped, and os->ind - * is where we are now. - */ -static void permute(apr_getopt_t *os) -{ - int len1 = os->skip_end - os->skip_start; - int len2 = os->ind - os->skip_end; - - if (os->interleave) { - /* - * Exchange the sequences argv[os->skip_start..os->skip_end-1] and - * argv[os->skip_end..os->ind-1]. The easiest way to do that is - * to reverse the entire range and then reverse the two - * sub-ranges. - */ - reverse(os->argv, os->skip_start, len1 + len2); - reverse(os->argv, os->skip_start, len2); - reverse(os->argv, os->skip_start + len2, len1); - } - - /* Reset skip range to the new location of the non-option sequence. */ - os->skip_start += len2; - os->skip_end += len2; -} - -/* Helper function to print out an error involving a long option */ -static apr_status_t serr(apr_getopt_t *os, const char *err, const char *str, - apr_status_t status) -{ - if (os->errfn) - (os->errfn)(os->errarg, "%s: %s: %s\n", - apr_filepath_name_get(*os->argv), err, str); - return status; -} - -/* Helper function to print out an error involving a short option */ -static apr_status_t cerr(apr_getopt_t *os, const char *err, int ch, - apr_status_t status) -{ - if (os->errfn) - (os->errfn)(os->errarg, "%s: %s: %c\n", - apr_filepath_name_get(*os->argv), err, ch); - return status; -} - -APR_DECLARE(apr_status_t) apr_getopt_long(apr_getopt_t *os, - const apr_getopt_option_t *opts, - int *optch, const char **optarg) -{ - const char *p; - int i; - - /* Let the calling program reset option processing. */ - if (os->reset) { - os->place = EMSG; - os->ind = 1; - os->reset = 0; - } - - /* - * We can be in one of two states: in the middle of processing a - * run of short options, or about to process a new argument. - * Since the second case can lead to the first one, handle that - * one first. */ - p = os->place; - if (*p == '\0') { - /* If we are interleaving, skip non-option arguments. */ - if (os->interleave) { - while (os->ind < os->argc && *os->argv[os->ind] != '-') - os->ind++; - os->skip_end = os->ind; - } - if (os->ind >= os->argc || *os->argv[os->ind] != '-') { - os->ind = os->skip_start; - return APR_EOF; - } - - p = os->argv[os->ind++] + 1; - if (*p == '-' && p[1] != '\0') { /* Long option */ - /* Search for the long option name in the caller's table. */ - apr_size_t len = 0; - - p++; - for (i = 0; ; i++) { - if (opts[i].optch == 0) /* No match */ - return serr(os, "invalid option", p - 2, APR_BADCH); - - if (opts[i].name) { - len = strlen(opts[i].name); - if (strncmp(p, opts[i].name, len) == 0 - && (p[len] == '\0' || p[len] == '=')) - break; - } - } - *optch = opts[i].optch; - - if (opts[i].has_arg) { - if (p[len] == '=') /* Argument inline */ - *optarg = p + len + 1; - else { - if (os->ind >= os->argc) /* Argument missing */ - return serr(os, "missing argument", p - 2, APR_BADARG); - else /* Argument in next arg */ - *optarg = os->argv[os->ind++]; - } - } else { - *optarg = NULL; - if (p[len] == '=') - return serr(os, "erroneous argument", p - 2, APR_BADARG); - } - permute(os); - return APR_SUCCESS; - } else { - if (*p == '-') { /* Bare "--"; we're done */ - permute(os); - os->ind = os->skip_start; - return APR_EOF; - } - else - if (*p == '\0') /* Bare "-" is illegal */ - return serr(os, "invalid option", p, APR_BADCH); - } - } - - /* - * Now we're in a run of short options, and *p is the next one. - * Look for it in the caller's table. - */ - for (i = 0; ; i++) { - if (opts[i].optch == 0) /* No match */ - return cerr(os, "invalid option character", *p, APR_BADCH); - - if (*p == opts[i].optch) - break; - } - *optch = *p++; - - if (opts[i].has_arg) { - if (*p != '\0') /* Argument inline */ - *optarg = p; - else { - if (os->ind >= os->argc) /* Argument missing */ - return cerr(os, "missing argument", *optch, APR_BADARG); - else /* Argument in next arg */ - *optarg = os->argv[os->ind++]; - } - os->place = EMSG; - } else { - *optarg = NULL; - os->place = p; - } - - permute(os); - return APR_SUCCESS; -} diff --git a/libs/apr/misc/unix/otherchild.c b/libs/apr/misc/unix/otherchild.c deleted file mode 100644 index 427a57e7..00000000 --- a/libs/apr/misc/unix/otherchild.c +++ /dev/null @@ -1,221 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_arch_misc.h" -#include "apr_arch_threadproc.h" -#include "apr_arch_file_io.h" - -#if APR_HAS_OTHER_CHILD - -#ifdef HAVE_TIME_H -#include -#endif -#ifdef HAVE_SYS_SELECT_H -#include -#endif -#if APR_HAVE_SYS_WAIT_H -#include -#endif -#ifdef BEOS -#include /* for fd_set definition! */ -#endif - -static apr_other_child_rec_t *other_children = NULL; - -static apr_status_t other_child_cleanup(void *data) -{ - apr_other_child_rec_t **pocr, *nocr; - - for (pocr = &other_children; *pocr; pocr = &(*pocr)->next) { - if ((*pocr)->data == data) { - nocr = (*pocr)->next; - (*(*pocr)->maintenance) (APR_OC_REASON_UNREGISTER, (*pocr)->data, -1); - *pocr = nocr; - /* XXX: um, well we've just wasted some space in pconf ? */ - return APR_SUCCESS; - } - } - return APR_SUCCESS; -} - -APR_DECLARE(void) apr_proc_other_child_register(apr_proc_t *proc, - void (*maintenance) (int reason, void *, int status), - void *data, apr_file_t *write_fd, apr_pool_t *p) -{ - apr_other_child_rec_t *ocr; - - ocr = apr_palloc(p, sizeof(*ocr)); - ocr->p = p; - ocr->proc = proc; - ocr->maintenance = maintenance; - ocr->data = data; - if (write_fd == NULL) { - ocr->write_fd = (apr_os_file_t) -1; - } - else { -#ifdef WIN32 - /* This should either go away as part of eliminating apr_proc_probe_writable_fds - * or write_fd should point to an apr_file_t - */ - ocr->write_fd = write_fd->filehand; -#else - ocr->write_fd = write_fd->filedes; -#endif - - } - ocr->next = other_children; - other_children = ocr; - apr_pool_cleanup_register(p, ocr->data, other_child_cleanup, - apr_pool_cleanup_null); -} - -APR_DECLARE(void) apr_proc_other_child_unregister(void *data) -{ - apr_other_child_rec_t *cur; - - cur = other_children; - while (cur) { - if (cur->data == data) { - break; - } - cur = cur->next; - } - - /* segfault if this function called with invalid parm */ - apr_pool_cleanup_kill(cur->p, cur->data, other_child_cleanup); - other_child_cleanup(data); -} - -APR_DECLARE(apr_status_t) apr_proc_other_child_alert(apr_proc_t *proc, - int reason, - int status) -{ - apr_other_child_rec_t *ocr, *nocr; - - for (ocr = other_children; ocr; ocr = nocr) { - nocr = ocr->next; - if (ocr->proc->pid != proc->pid) - continue; - - ocr->proc = NULL; - (*ocr->maintenance) (reason, ocr->data, status); - return APR_SUCCESS; - } - return APR_EPROC_UNKNOWN; -} - -APR_DECLARE(void) apr_proc_other_child_refresh(apr_other_child_rec_t *ocr, - int reason) -{ - /* Todo: - * Implement code to detect if pipes are still alive. - */ -#ifdef WIN32 - DWORD status; - - if (ocr->proc == NULL) - return; - - if (!ocr->proc->hproc) { - /* Already mopped up, perhaps we apr_proc_kill'ed it, - * they should have already unregistered! - */ - ocr->proc = NULL; - (*ocr->maintenance) (APR_OC_REASON_LOST, ocr->data, -1); - } - else if (!GetExitCodeProcess(ocr->proc->hproc, &status)) { - CloseHandle(ocr->proc->hproc); - ocr->proc->hproc = NULL; - ocr->proc = NULL; - (*ocr->maintenance) (APR_OC_REASON_LOST, ocr->data, -1); - } - else if (status == STILL_ACTIVE) { - (*ocr->maintenance) (reason, ocr->data, -1); - } - else { - CloseHandle(ocr->proc->hproc); - ocr->proc->hproc = NULL; - ocr->proc = NULL; - (*ocr->maintenance) (APR_OC_REASON_DEATH, ocr->data, status); - } - -#else /* ndef Win32 */ - pid_t waitret; - int status; - - if (ocr->proc == NULL) - return; - - waitret = waitpid(ocr->proc->pid, &status, WNOHANG); - if (waitret == ocr->proc->pid) { - ocr->proc = NULL; - (*ocr->maintenance) (APR_OC_REASON_DEATH, ocr->data, status); - } - else if (waitret == 0) { - (*ocr->maintenance) (reason, ocr->data, -1); - } - else if (waitret == -1) { - /* uh what the heck? they didn't call unregister? */ - ocr->proc = NULL; - (*ocr->maintenance) (APR_OC_REASON_LOST, ocr->data, -1); - } -#endif -} - -APR_DECLARE(void) apr_proc_other_child_refresh_all(int reason) -{ - apr_other_child_rec_t *ocr, *next_ocr; - - for (ocr = other_children; ocr; ocr = next_ocr) { - next_ocr = ocr->next; - apr_proc_other_child_refresh(ocr, reason); - } -} - -#else /* !APR_HAS_OTHER_CHILD */ - -APR_DECLARE(void) apr_proc_other_child_register(apr_proc_t *proc, - void (*maintenance) (int reason, void *, int status), - void *data, apr_file_t *write_fd, apr_pool_t *p) -{ - return; -} - -APR_DECLARE(void) apr_proc_other_child_unregister(void *data) -{ - return; -} - -APR_DECLARE(apr_status_t) apr_proc_other_child_alert(apr_proc_t *proc, - int reason, - int status) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(void) apr_proc_other_child_refresh(apr_other_child_rec_t *ocr, - int reason) -{ - return; -} - -APR_DECLARE(void) apr_proc_other_child_refresh_all(int reason) -{ - return; -} - -#endif /* APR_HAS_OTHER_CHILD */ diff --git a/libs/apr/misc/unix/rand.c b/libs/apr/misc/unix/rand.c deleted file mode 100644 index c1e1e8f6..00000000 --- a/libs/apr/misc/unix/rand.c +++ /dev/null @@ -1,250 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define APR_WANT_MEMFUNC -#include "apr_want.h" -#include "apr_general.h" - -#include "apr_arch_misc.h" -#include -#if APR_HAVE_SYS_TYPES_H -#include -#endif -#if APR_HAVE_SYS_SOCKET_H -#include -#endif -#if APR_HAVE_FCNTL_H -#include -#endif -#if APR_HAVE_UNISTD_H -#include -#endif -#if APR_HAVE_SYS_UN_H -#include -#endif -#if defined(HAVE_UUID_H) -#include -#elif defined(HAVE_UUID_UUID_H) -#include -#elif defined(HAVE_SYS_UUID_H) -#include -#endif - -#ifndef SHUT_RDWR -#define SHUT_RDWR 2 -#endif - -#if APR_HAS_OS_UUID - -#if defined(HAVE_UUID_CREATE) - -APR_DECLARE(apr_status_t) apr_os_uuid_get(unsigned char *uuid_data) -{ - uint32_t rv; - uuid_t g; - - uuid_create(&g, &rv); - - if (rv != uuid_s_ok) - return APR_EGENERAL; - - memcpy(uuid_data, &g, sizeof(uuid_t)); - - return APR_SUCCESS; -} - -#elif defined(HAVE_UUID_GENERATE) - -APR_DECLARE(apr_status_t) apr_os_uuid_get(unsigned char *uuid_data) -{ - uuid_t g; - - uuid_generate(g); - - memcpy(uuid_data, g, sizeof(uuid_t)); - - return APR_SUCCESS; -} -#endif - -#endif /* APR_HAS_OS_UUID */ - -#if APR_HAS_RANDOM - -APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char *buf, - apr_size_t length) -{ -#ifdef DEV_RANDOM - - int fd = -1; - - /* On BSD/OS 4.1, /dev/random gives out 8 bytes at a time, then - * gives EOF, so reading 'length' bytes may require opening the - * device several times. */ - do { - apr_ssize_t rc; - - if (fd == -1) - if ((fd = open(DEV_RANDOM, O_RDONLY)) == -1) - return errno; - - do { - rc = read(fd, buf, length); - } while (rc == -1 && errno == EINTR); - - if (rc < 0) { - int errnum = errno; - close(fd); - return errnum; - } - else if (rc == 0) { - close(fd); - fd = -1; /* force open() again */ - } - else { - buf += rc; - length -= rc; - } - } while (length > 0); - - close(fd); -#elif defined(OS2) - static UCHAR randbyte(); - unsigned int idx; - - for (idx=0; idx 0; egdsockname++) { - egd_path_len = strlen(*egdsockname); - - if (egd_path_len > sizeof(addr.sun_path)) { - return APR_EINVAL; - } - - memset(&addr, 0, sizeof(struct sockaddr_un)); - addr.sun_family = AF_UNIX; - memcpy(addr.sun_path, *egdsockname, egd_path_len); - egd_addr_len = APR_OFFSETOF(struct sockaddr_un, sun_path) + - egd_path_len; - - egd_socket = socket(PF_UNIX, SOCK_STREAM, 0); - - if (egd_socket == -1) { - return errno; - } - - rv = connect(egd_socket, (struct sockaddr*)&addr, egd_addr_len); - - if (rv == -1) { - bad_errno = errno; - continue; - } - - /* EGD can only return 255 bytes of data at a time. Silly. */ - while (length > 0) { - apr_ssize_t srv; - req[0] = 2; /* We'll block for now. */ - req[1] = length > 255 ? 255: length; - - srv = write(egd_socket, req, 2); - if (srv == -1) { - bad_errno = errno; - shutdown(egd_socket, SHUT_RDWR); - close(egd_socket); - break; - } - - if (srv != 2) { - shutdown(egd_socket, SHUT_RDWR); - close(egd_socket); - return APR_EGENERAL; - } - - resp_expected = req[1]; - srv = read(egd_socket, resp, resp_expected); - if (srv == -1) { - bad_errno = errno; - shutdown(egd_socket, SHUT_RDWR); - close(egd_socket); - return bad_errno; - } - - memcpy(curbuf, resp, srv); - curbuf += srv; - length -= srv; - } - - shutdown(egd_socket, SHUT_RDWR); - close(egd_socket); - } - - if (length > 0) { - /* We must have iterated through the list of sockets, - * and no go. Return the errno. - */ - return bad_errno; - } - -#elif defined(HAVE_TRUERAND) /* use truerand */ - - extern int randbyte(void); /* from the truerand library */ - unsigned int idx; - - /* this will increase the startup time of the server, unfortunately... - * (generating 20 bytes takes about 8 seconds) - */ - for (idx=0; idx> 8; - return byte; -} - - - -/* A bunch of system information like memory & process stats. - * Not highly random but every bit helps.... - */ -static UCHAR randbyte_sysinfo() -{ - UCHAR byte = 0; - UCHAR SysVars[100]; - int b; - - DosQuerySysInfo(1, QSV_FOREGROUND_PROCESS, SysVars, sizeof(SysVars)); - - for (b = 0; b < 100; b++) { - byte ^= SysVars[b]; - } - - return byte; -} - - - -/* Similar in concept to randbyte_hrtimer() but accesses the CPU's internal - * counters which run at the CPU's MHz speed. We get separate - * idle / busy / interrupt cycle counts which should provide very good - * randomness due to interference of hardware events. - * This only works on newer CPUs (at least PPro or K6) and newer OS/2 versions - * which is why it's run-time linked. - */ - -static APIRET APIENTRY(*DosPerfSysCall) (ULONG ulCommand, ULONG ulParm1, - ULONG ulParm2, ULONG ulParm3) = NULL; -static HMODULE hDoscalls = 0; -#define CMD_KI_RDCNT (0x63) - -typedef struct _CPUUTIL { - ULONG ulTimeLow; /* Low 32 bits of time stamp */ - ULONG ulTimeHigh; /* High 32 bits of time stamp */ - ULONG ulIdleLow; /* Low 32 bits of idle time */ - ULONG ulIdleHigh; /* High 32 bits of idle time */ - ULONG ulBusyLow; /* Low 32 bits of busy time */ - ULONG ulBusyHigh; /* High 32 bits of busy time */ - ULONG ulIntrLow; /* Low 32 bits of interrupt time */ - ULONG ulIntrHigh; /* High 32 bits of interrupt time */ -} CPUUTIL; - - -static UCHAR randbyte_perf() -{ - UCHAR byte = 0; - CPUUTIL util; - int c; - - if (hDoscalls == 0) { - char failed_module[20]; - ULONG rc; - - rc = DosLoadModule(failed_module, sizeof(failed_module), "DOSCALLS", - &hDoscalls); - - if (rc == 0) { - rc = DosQueryProcAddr(hDoscalls, 976, NULL, (PFN *)&DosPerfSysCall); - - if (rc) { - DosPerfSysCall = NULL; - } - } - } - - if (DosPerfSysCall) { - if (DosPerfSysCall(CMD_KI_RDCNT, (ULONG)&util, 0, 0) == 0) { - for (c = 0; c < sizeof(util); c++) { - byte ^= ((UCHAR *)&util)[c]; - } - } - else { - DosPerfSysCall = NULL; - } - } - - return byte; -} - - - -static UCHAR randbyte() -{ - return randbyte_hrtimer() ^ randbyte_sysinfo() ^ randbyte_perf(); -} diff --git a/libs/apr/misc/unix/start.c b/libs/apr/misc/unix/start.c deleted file mode 100644 index 4b8ad990..00000000 --- a/libs/apr/misc/unix/start.c +++ /dev/null @@ -1,89 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_signal.h" -#include "apr_atomic.h" - -#include "apr_arch_proc_mutex.h" /* for apr_proc_mutex_unix_setup_lock() */ -#include "apr_arch_internal_time.h" - - -APR_DECLARE(apr_status_t) apr_app_initialize(int *argc, - const char * const * *argv, - const char * const * *env) -{ - /* An absolute noop. At present, only Win32 requires this stub, but it's - * required in order to move command arguments passed through the service - * control manager into the process, and it's required to fix the char* - * data passed in from win32 unicode into utf-8, win32's apr internal fmt. - */ - return apr_initialize(); -} - -static int initialized = 0; - -APR_DECLARE(apr_status_t) apr_initialize(void) -{ - apr_pool_t *pool; - apr_status_t status; - - if (initialized++) { - return APR_SUCCESS; - } - -#if !defined(BEOS) && !defined(OS2) - apr_proc_mutex_unix_setup_lock(); - apr_unix_setup_time(); -#endif - - if ((status = apr_pool_initialize()) != APR_SUCCESS) - return status; - - if (apr_pool_create(&pool, NULL) != APR_SUCCESS) { - return APR_ENOPOOL; - } - - apr_pool_tag(pool, "apr_initialize"); - - /* apr_atomic_init() used to be called from here aswell. - * Pools rely on mutexes though, which can be backed by - * atomics. Due to this circular dependency - * apr_pool_initialize() is taking care of calling - * apr_atomic_init() at the correct time. - */ - - apr_signal_init(pool); - - return APR_SUCCESS; -} - -APR_DECLARE_NONSTD(void) apr_terminate(void) -{ - initialized--; - if (initialized) { - return; - } - apr_pool_terminate(); - -} - -APR_DECLARE(void) apr_terminate2(void) -{ - apr_terminate(); -} diff --git a/libs/apr/misc/unix/version.c b/libs/apr/misc/unix/version.c deleted file mode 100644 index 2f111bf9..00000000 --- a/libs/apr/misc/unix/version.c +++ /dev/null @@ -1,35 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_version.h" -#include "apr_general.h" /* for APR_STRINGIFY */ - -APR_DECLARE(void) apr_version(apr_version_t *pvsn) -{ - pvsn->major = APR_MAJOR_VERSION; - pvsn->minor = APR_MINOR_VERSION; - pvsn->patch = APR_PATCH_VERSION; -#ifdef APR_IS_DEV_VERSION - pvsn->is_dev = 1; -#else - pvsn->is_dev = 0; -#endif -} - -APR_DECLARE(const char *) apr_version_string(void) -{ - return APR_VERSION_STRING; -} diff --git a/libs/apr/misc/win32/apr_app.c b/libs/apr/misc/win32/apr_app.c deleted file mode 100644 index 4e08e33d..00000000 --- a/libs/apr/misc/win32/apr_app.c +++ /dev/null @@ -1,80 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* Usage Notes: - * - * this module, and the misc/win32/utf8.c modules must be - * compiled APR_EXPORT_STATIC and linked to an application with - * the /entry:wmainCRTStartup flag (which this module kindly - * provides to the developer who links to libaprapp-1.lib). - * This module becomes the true wmain entry point, and passes - * utf-8 reformatted argv and env arrays to the application's - * main() function as if nothing happened. - * - * This module is only compatible with Unicode operating systems. - * Mixed (Win9x backwards compatible) binaries should refer instead - * to the apr_startup.c module. - * - * _dbg_malloc/realloc is used in place of the usual API, in order - * to convince the MSVCRT that it created these entities. If we - * do not create them as _CRT_BLOCK entities, the crt will fault - * on an assert. We are not worrying about the crt's locks here, - * since we are single threaded [so far]. - */ - -#include "apr_general.h" -#include "ShellAPI.h" -#include "wchar.h" -#include "apr_arch_file_io.h" -#include "assert.h" -#include "apr_private.h" -#include "apr_arch_misc.h" - -#pragma comment(linker,"/ENTRY:wmainCRTStartup") - -extern int main(int argc, const char **argv, const char **env); - -int wmain(int argc, const wchar_t **wargv, const wchar_t **wenv) -{ - char **argv; - char **env; - int dupenv; - - (void)apr_wastrtoastr(&argv, wargv, argc); - - dupenv = apr_wastrtoastr(&env, wenv, -1); - - _environ = apr_malloc_dbg((dupenv + 1) * sizeof (char *), - __FILE__, __LINE__ ); - memcpy(_environ, env, (dupenv + 1) * sizeof (char *)); - - /* MSVCRT will attempt to maintain the wide environment calls - * on _putenv(), which is bogus if we've passed a non-ascii - * string to _putenv(), since they use MultiByteToWideChar - * and breaking the implicit utf-8 assumption we've built. - * - * Reset _wenviron for good measure. - */ - if (_wenviron) { - wenv = _wenviron; - _wenviron = NULL; - free((wchar_t **)wenv); - } - - apr_app_init_complete = 1; - - return main(argc, argv, env); -} diff --git a/libs/apr/misc/win32/charset.c b/libs/apr/misc/win32/charset.c deleted file mode 100644 index 41135b25..00000000 --- a/libs/apr/misc/win32/charset.c +++ /dev/null @@ -1,55 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_strings.h" -#include "apr_portable.h" - - -APR_DECLARE(const char*) apr_os_default_encoding (apr_pool_t *pool) -{ - return apr_psprintf(pool, "CP%u", (unsigned) GetACP()); -} - - -APR_DECLARE(const char*) apr_os_locale_encoding (apr_pool_t *pool) -{ -#ifdef _UNICODE - int i; -#endif -#if defined(_WIN32_WCE) - LCID locale = GetUserDefaultLCID(); -#else - LCID locale = GetThreadLocale(); -#endif - int len = GetLocaleInfo(locale, LOCALE_IDEFAULTANSICODEPAGE, NULL, 0); - char *cp = apr_palloc(pool, (len * sizeof(TCHAR)) + 2); - if (0 < GetLocaleInfo(locale, LOCALE_IDEFAULTANSICODEPAGE, (TCHAR*) (cp + 2), len)) - { - /* Fix up the returned number to make a valid codepage name of - the form "CPnnnn". */ - cp[0] = 'C'; - cp[1] = 'P'; -#ifdef _UNICODE - for(i = 0; i < len; i++) { - cp[i + 2] = (char) ((TCHAR*) (cp + 2))[i]; - } -#endif - return cp; - } - - return apr_os_default_encoding(pool); -} diff --git a/libs/apr/misc/win32/env.c b/libs/apr/misc/win32/env.c deleted file mode 100644 index 644f59b8..00000000 --- a/libs/apr/misc/win32/env.c +++ /dev/null @@ -1,192 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define APR_WANT_STRFUNC -#include "apr_want.h" -#include "apr.h" -#include "apr_arch_misc.h" -#include "apr_arch_utf8.h" -#include "apr_env.h" -#include "apr_errno.h" -#include "apr_pools.h" -#include "apr_strings.h" - -#if APR_HAS_UNICODE_FS && !defined(_WIN32_WCE) -static apr_status_t widen_envvar_name (apr_wchar_t *buffer, - apr_size_t bufflen, - const char *envvar) -{ - apr_size_t inchars; - apr_status_t status; - - inchars = strlen(envvar) + 1; - status = apr_conv_utf8_to_ucs2(envvar, &inchars, buffer, &bufflen); - if (status == APR_INCOMPLETE) - status = APR_ENAMETOOLONG; - - return status; -} -#endif - - -APR_DECLARE(apr_status_t) apr_env_get(char **value, - const char *envvar, - apr_pool_t *pool) -{ -#if defined(_WIN32_WCE) - return APR_ENOTIMPL; -#else - char *val = NULL; - DWORD size; - -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - apr_wchar_t wenvvar[APR_PATH_MAX]; - apr_size_t inchars, outchars; - apr_wchar_t *wvalue, dummy; - apr_status_t status; - - status = widen_envvar_name(wenvvar, APR_PATH_MAX, envvar); - if (status) - return status; - - SetLastError(0); - size = GetEnvironmentVariableW(wenvvar, &dummy, 0); - if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) - /* The environment variable doesn't exist. */ - return APR_ENOENT; - - if (size == 0) { - /* The environment value exists, but is zero-length. */ - *value = apr_pstrdup(pool, ""); - return APR_SUCCESS; - } - - wvalue = apr_palloc(pool, size * sizeof(*wvalue)); - size = GetEnvironmentVariableW(wenvvar, wvalue, size); - - inchars = wcslen(wvalue) + 1; - outchars = 3 * inchars; /* Enough for any UTF-8 representation */ - val = apr_palloc(pool, outchars); - status = apr_conv_ucs2_to_utf8(wvalue, &inchars, val, &outchars); - if (status) - return status; - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - char dummy; - - SetLastError(0); - size = GetEnvironmentVariableA(envvar, &dummy, 0); - if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) - /* The environment variable doesn't exist. */ - return APR_ENOENT; - - if (size == 0) { - /* The environment value exists, but is zero-length. */ - *value = apr_pstrdup(pool, ""); - return APR_SUCCESS; - } - - val = apr_palloc(pool, size); - size = GetEnvironmentVariableA(envvar, val, size); - if (size == 0) - /* Mid-air collision?. Somebody must've changed the env. var. */ - return APR_INCOMPLETE; - } -#endif - - *value = val; - return APR_SUCCESS; -#endif -} - - -APR_DECLARE(apr_status_t) apr_env_set(const char *envvar, - const char *value, - apr_pool_t *pool) -{ -#if defined(_WIN32_WCE) - return APR_ENOTIMPL; -#else -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - apr_wchar_t wenvvar[APR_PATH_MAX]; - apr_wchar_t *wvalue; - apr_size_t inchars, outchars; - apr_status_t status; - - status = widen_envvar_name(wenvvar, APR_PATH_MAX, envvar); - if (status) - return status; - - outchars = inchars = strlen(value) + 1; - wvalue = apr_palloc(pool, outchars * sizeof(*wvalue)); - status = apr_conv_utf8_to_ucs2(value, &inchars, wvalue, &outchars); - if (status) - return status; - - if (!SetEnvironmentVariableW(wenvvar, wvalue)) - return apr_get_os_error(); - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - if (!SetEnvironmentVariableA(envvar, value)) - return apr_get_os_error(); - } -#endif - - return APR_SUCCESS; -#endif -} - - -APR_DECLARE(apr_status_t) apr_env_delete(const char *envvar, apr_pool_t *pool) -{ -#if defined(_WIN32_WCE) - return APR_ENOTIMPL; -#else -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - apr_wchar_t wenvvar[APR_PATH_MAX]; - apr_status_t status; - - status = widen_envvar_name(wenvvar, APR_PATH_MAX, envvar); - if (status) - return status; - - if (!SetEnvironmentVariableW(wenvvar, NULL)) - return apr_get_os_error(); - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - if (!SetEnvironmentVariableA(envvar, NULL)) - return apr_get_os_error(); - } -#endif - - return APR_SUCCESS; -#endif -} diff --git a/libs/apr/misc/win32/internal.c b/libs/apr/misc/win32/internal.c deleted file mode 100644 index 03362cf5..00000000 --- a/libs/apr/misc/win32/internal.c +++ /dev/null @@ -1,101 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_private.h" - -#include "apr_arch_misc.h" -#include "apr_arch_file_io.h" -#include - -/* This module is the source of -static- helper functions that are - * entirely internal to apr. If the fn is exported - it does not - * belong here. - * - * Namespace decoration is still required to protect us from symbol - * clashes in static linkages. - */ - - -/* Shared by apr_app.c and start.c - * - * An internal apr function to convert an array of strings (either - * a counted or NULL terminated list, such as an argv[argc] or env[] - * list respectively) from wide Unicode strings to narrow utf-8 strings. - * These are allocated from the MSVCRT's _CRT_BLOCK to trick the system - * into trusting our store. - */ -int apr_wastrtoastr(char const * const * *retarr, - wchar_t const * const *arr, int args) -{ - apr_size_t elesize = 0; - char **newarr; - char *elements; - char *ele; - int arg; - - if (args < 0) { - for (args = 0; arr[args]; ++args) - ; - } - - newarr = apr_malloc_dbg((args + 1) * sizeof(char *), - __FILE__, __LINE__); - - for (arg = 0; arg < args; ++arg) { - newarr[arg] = (void*)(wcslen(arr[arg]) + 1); - elesize += (apr_size_t)newarr[arg]; - } - - /* This is a safe max allocation, we will realloc after - * processing and return the excess to the free store. - * 3 ucs bytes hold any single wchar_t value (16 bits) - * 4 ucs bytes will hold a wchar_t pair value (20 bits) - */ - elesize = elesize * 3 + 1; - ele = elements = apr_malloc_dbg(elesize * sizeof(char), - __FILE__, __LINE__); - - for (arg = 0; arg < args; ++arg) { - apr_size_t len = (apr_size_t)newarr[arg]; - apr_size_t newlen = elesize; - - newarr[arg] = ele; - (void)apr_conv_ucs2_to_utf8(arr[arg], &len, - newarr[arg], &elesize); - - newlen -= elesize; - ele += newlen; - assert(elesize && (len == 0)); - } - - newarr[arg] = NULL; - *(ele++) = '\0'; - - /* Return to the free store if the heap realloc is the least bit optimized - */ - ele = apr_realloc_dbg(elements, ele - elements, - __FILE__, __LINE__); - - if (ele != elements) { - apr_size_t diff = ele - elements; - for (arg = 0; arg < args; ++arg) { - newarr[arg] += diff; - } - } - - *retarr = (char const * const *)newarr; - return args; -} diff --git a/libs/apr/misc/win32/misc.c b/libs/apr/misc/win32/misc.c deleted file mode 100644 index 3f125244..00000000 --- a/libs/apr/misc/win32/misc.c +++ /dev/null @@ -1,263 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_private.h" -#include "apr_arch_misc.h" -#include "apr_arch_file_io.h" -#include "assert.h" -#include "apr_lib.h" -#include "tchar.h" - -APR_DECLARE_DATA apr_oslevel_e apr_os_level = APR_WIN_UNK; - -apr_status_t apr_get_oslevel(apr_oslevel_e *level) -{ - if (apr_os_level == APR_WIN_UNK) - { - static OSVERSIONINFO oslev; - oslev.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&oslev); - - if (oslev.dwPlatformId == VER_PLATFORM_WIN32_NT) - { - static unsigned int servpack = 0; - TCHAR *pservpack; - if ((pservpack = oslev.szCSDVersion)) { - while (*pservpack && !apr_isdigit(*pservpack)) { - pservpack++; - } - if (*pservpack) -#ifdef _UNICODE - servpack = _wtoi(pservpack); -#else - servpack = atoi(pservpack); -#endif - } - - if (oslev.dwMajorVersion < 3) { - apr_os_level = APR_WIN_UNSUP; - } - else if (oslev.dwMajorVersion == 3) { - if (oslev.dwMajorVersion < 50) { - apr_os_level = APR_WIN_UNSUP; - } - else if (oslev.dwMajorVersion == 50) { - apr_os_level = APR_WIN_NT_3_5; - } - else { - apr_os_level = APR_WIN_NT_3_51; - } - } - else if (oslev.dwMajorVersion == 4) { - if (servpack < 2) - apr_os_level = APR_WIN_NT_4; - else if (servpack <= 2) - apr_os_level = APR_WIN_NT_4_SP2; - else if (servpack <= 3) - apr_os_level = APR_WIN_NT_4_SP3; - else if (servpack <= 4) - apr_os_level = APR_WIN_NT_4_SP4; - else if (servpack <= 5) - apr_os_level = APR_WIN_NT_4_SP5; - else - apr_os_level = APR_WIN_NT_4_SP6; - } - else if (oslev.dwMajorVersion == 5) { - if (oslev.dwMinorVersion == 0) { - if (servpack == 0) - apr_os_level = APR_WIN_2000; - else if (servpack == 1) - apr_os_level = APR_WIN_2000_SP1; - else - apr_os_level = APR_WIN_2000_SP2; - } - else if (oslev.dwMinorVersion == 2) { - apr_os_level = APR_WIN_2003; - } - else { - if (servpack < 1) - apr_os_level = APR_WIN_XP; - else if (servpack == 1) - apr_os_level = APR_WIN_XP_SP1; - else - apr_os_level = APR_WIN_XP_SP2; - } - } - else if (oslev.dwMajorVersion == 6) { - apr_os_level = APR_WIN_VISTA; - } - else { - apr_os_level = APR_WIN_XP; - } - } -#ifndef WINNT - else if (oslev.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { - TCHAR *prevision; - if (prevision = oslev.szCSDVersion) { - while (*prevision && !apr_isupper(*prevision)) { - prevision++; - } - } - else prevision = _T(""); - - if (oslev.dwMinorVersion < 10) { - if (*prevision < _T('C')) - apr_os_level = APR_WIN_95; - else - apr_os_level = APR_WIN_95_OSR2; - } - else if (oslev.dwMinorVersion < 90) { - if (*prevision < _T('A')) - apr_os_level = APR_WIN_98; - else - apr_os_level = APR_WIN_98_SE; - } - else { - apr_os_level = APR_WIN_ME; - } - } -#endif -#ifdef _WIN32_WCE - else if (oslev.dwPlatformId == VER_PLATFORM_WIN32_CE) - { - if (oslev.dwMajorVersion < 3) { - apr_os_level = APR_WIN_UNSUP; - } - else { - apr_os_level = APR_WIN_CE_3; - } - } -#endif - else { - apr_os_level = APR_WIN_UNSUP; - } - } - - *level = apr_os_level; - - if (apr_os_level < APR_WIN_UNSUP) { - return APR_EGENERAL; - } - - return APR_SUCCESS; -} - - -/* This is the helper code to resolve late bound entry points - * missing from one or more releases of the Win32 API - */ - -static const char* const lateDllName[DLL_defined] = { - "kernel32", "advapi32", "mswsock", "ws2_32", "shell32", "ntdll.dll" }; -static HMODULE lateDllHandle[DLL_defined] = { - NULL, NULL, NULL, NULL, NULL, NULL }; - -FARPROC apr_load_dll_func(apr_dlltoken_e fnLib, char* fnName, int ordinal) -{ - if (!lateDllHandle[fnLib]) { - lateDllHandle[fnLib] = LoadLibraryA(lateDllName[fnLib]); - if (!lateDllHandle[fnLib]) - return NULL; - } -#if defined(_WIN32_WCE) - if (ordinal) - return GetProcAddressA(lateDllHandle[fnLib], (const char *) - (apr_ssize_t)ordinal); - else - return GetProcAddressA(lateDllHandle[fnLib], fnName); -#else - if (ordinal) - return GetProcAddress(lateDllHandle[fnLib], (const char *) - (apr_ssize_t)ordinal); - else - return GetProcAddress(lateDllHandle[fnLib], fnName); -#endif -} - -/* Declared in include/arch/win32/apr_dbg_win32_handles.h - */ -APR_DECLARE_NONSTD(HANDLE) apr_dbg_log(char* fn, HANDLE ha, char* fl, int ln, - int nh, /* HANDLE hv, char *dsc */...) -{ - static DWORD tlsid = 0xFFFFFFFF; - static HANDLE fh = NULL; - static long ctr = 0; - static CRITICAL_SECTION cs; - long seq; - DWORD wrote; - char *sbuf; - - seq = (InterlockedIncrement)(&ctr); - - if (tlsid == 0xFFFFFFFF) { - tlsid = (TlsAlloc)(); - } - - sbuf = (TlsGetValue)(tlsid); - if (!fh || !sbuf) { - sbuf = (malloc)(1024); - (TlsSetValue)(tlsid, sbuf); - sbuf[1023] = '\0'; - if (!fh) { - (GetModuleFileNameA)(NULL, sbuf, 250); - sprintf(strchr(sbuf, '\0'), ".%u", - (unsigned int)(GetCurrentProcessId)()); - fh = (CreateFileA)(sbuf, GENERIC_WRITE, 0, NULL, - CREATE_ALWAYS, 0, NULL); - (InitializeCriticalSection)(&cs); - } - } - - if (!nh) { - (sprintf)(sbuf, "%p %08x %08x %s() %s:%d\n", - ha, (unsigned int)seq, (unsigned int)GetCurrentThreadId(), - fn, fl, ln); - (EnterCriticalSection)(&cs); - (WriteFile)(fh, sbuf, (DWORD)strlen(sbuf), &wrote, NULL); - (LeaveCriticalSection)(&cs); - } - else { - va_list a; - va_start(a,nh); - (EnterCriticalSection)(&cs); - do { - HANDLE *hv = va_arg(a, HANDLE*); - char *dsc = va_arg(a, char*); - if (strcmp(dsc, "Signaled") == 0) { - if ((apr_ssize_t)ha >= STATUS_WAIT_0 - && (apr_ssize_t)ha < STATUS_ABANDONED_WAIT_0) { - hv += (apr_ssize_t)ha; - } - else if ((apr_ssize_t)ha >= STATUS_ABANDONED_WAIT_0 - && (apr_ssize_t)ha < STATUS_USER_APC) { - hv += (apr_ssize_t)ha - STATUS_ABANDONED_WAIT_0; - dsc = "Abandoned"; - } - else if ((apr_ssize_t)ha == WAIT_TIMEOUT) { - dsc = "Timed Out"; - } - } - (sprintf)(sbuf, "%p %08x %08x %s(%s) %s:%d\n", - *hv, (unsigned int)seq, - (unsigned int)GetCurrentThreadId(), - fn, dsc, fl, ln); - (WriteFile)(fh, sbuf, (DWORD)strlen(sbuf), &wrote, NULL); - } while (--nh); - (LeaveCriticalSection)(&cs); - va_end(a); - } - return ha; -} diff --git a/libs/apr/misc/win32/rand.c b/libs/apr/misc/win32/rand.c deleted file mode 100644 index cb5a6537..00000000 --- a/libs/apr/misc/win32/rand.c +++ /dev/null @@ -1,69 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include -#include -#include "apr_private.h" -#include "apr_general.h" -#include "apr_portable.h" -#include "apr_arch_misc.h" - - -APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char * buf, - apr_size_t length) -{ - HCRYPTPROV hProv; - apr_status_t res = APR_SUCCESS; - - /* 0x40 bit = CRYPT_SILENT, only introduced in more recent PSDKs - * and will only work for Win2K and later. - */ - DWORD flags = CRYPT_VERIFYCONTEXT - | ((apr_os_level >= APR_WIN_2000) ? 0x40 : 0); - - if (!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, flags)) { - return apr_get_os_error(); - } - /* XXX: An ugly hack for Win64, randomness is such that noone should - * ever expect > 2^31 bytes of data at once without the prng - * coming to a complete halt. - */ - if (!CryptGenRandom(hProv, (DWORD)length, buf)) { - res = apr_get_os_error(); - } - CryptReleaseContext(hProv, 0); - return res; -} - - -APR_DECLARE(apr_status_t) apr_os_uuid_get(unsigned char *uuid_data) -{ - /* Note: this call doesn't actually require CoInitialize() first - * - * XXX: we should scramble the bytes or some such to eliminate the - * possible misuse/abuse since uuid is based on the NIC address, and - * is therefore not only a uniqifier, but an identity (which might not - * be appropriate in all cases. - * - * Note that Win2000, XP and later no longer suffer from this problem, - * a scrambling fix is only needed for (apr_os_level < APR_WIN_2000) - */ - if (FAILED(UuidCreate((UUID *)uuid_data))) { - return APR_EGENERAL; - } - return APR_SUCCESS; -} diff --git a/libs/apr/misc/win32/start.c b/libs/apr/misc/win32/start.c deleted file mode 100644 index eb77d4a4..00000000 --- a/libs/apr/misc/win32/start.c +++ /dev/null @@ -1,234 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_private.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_signal.h" -#include "shellapi.h" - -#include "apr_arch_misc.h" /* for WSAHighByte / WSALowByte */ -#include "wchar.h" -#include "apr_arch_file_io.h" /* bring in unicode-ness */ -#include "apr_arch_threadproc.h" /* bring in apr_threadproc_init */ -#include "assert.h" - -/* This symbol is _private_, although it must be exported. - */ -int APR_DECLARE_DATA apr_app_init_complete = 0; - -#if !defined(_WIN32_WCE) -/* Used by apr_app_initialize to reprocess the environment - * - * An internal apr function to convert a double-null terminated set - * of single-null terminated strings from wide Unicode to narrow utf-8 - * as a list of strings. These are allocated from the MSVCRT's - * _CRT_BLOCK to trick the system into trusting our store. - */ -static int warrsztoastr(const char * const * *retarr, - const wchar_t * arrsz, int args) -{ - const apr_wchar_t *wch; - apr_size_t totlen; - apr_size_t newlen; - apr_size_t wsize; - char **env; - char *pstrs; - char *strs; - int arg; - - if (args < 0) { - for (args = 1, wch = arrsz; wch[0] || wch[1]; ++wch) - if (!*wch) - ++args; - } - wsize = 1 + wch - arrsz; - - /* This is a safe max allocation, we will alloc each - * string exactly after processing and return this - * temporary buffer to the free store. - * 3 ucs bytes hold any single wchar_t value (16 bits) - * 4 ucs bytes will hold a wchar_t pair value (20 bits) - */ - newlen = totlen = wsize * 3 + 1; - pstrs = strs = apr_malloc_dbg(newlen * sizeof(char), - __FILE__, __LINE__); - - (void)apr_conv_ucs2_to_utf8(arrsz, &wsize, strs, &newlen); - - assert(newlen && !wsize); - - *retarr = env = apr_malloc_dbg((args + 1) * sizeof(char*), - __FILE__, __LINE__); - for (arg = 0; arg < args; ++arg) { - char* p = pstrs; - int len = 0; - while (*p++) - ++len; - len += 1; - - *env = apr_malloc_dbg(len * sizeof(char), - __FILE__, __LINE__); - memcpy(*env, pstrs, len * sizeof(char)); - - pstrs += len; - ++env; - } - - *env = NULL; - free(strs); - - return args; -} -#endif - -/* Reprocess the arguments to main() for a completely apr-ized application - */ - -APR_DECLARE(apr_status_t) apr_app_initialize(int *argc, - const char * const * *argv, - const char * const * *env) -{ - apr_status_t rv = apr_initialize(); - - if (rv != APR_SUCCESS) { - return rv; - } - -#if defined(_WIN32_WCE) - apr_app_init_complete = 1; -#elif APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - apr_wchar_t **wstrs; - apr_wchar_t *sysstr; - int wstrc; - int dupenv; - - if (apr_app_init_complete) { - return rv; - } - - apr_app_init_complete = 1; - - sysstr = GetCommandLineW(); - if (sysstr) { - wstrs = CommandLineToArgvW(sysstr, &wstrc); - if (wstrs) { - *argc = apr_wastrtoastr(argv, wstrs, wstrc); - GlobalFree(wstrs); - } - } - - sysstr = GetEnvironmentStringsW(); - dupenv = warrsztoastr(&_environ, sysstr, -1); - - if (env) { - *env = apr_malloc_dbg((dupenv + 1) * sizeof (char *), - __FILE__, __LINE__ ); - memcpy((void*)*env, _environ, (dupenv + 1) * sizeof (char *)); - } - else { - } - - FreeEnvironmentStringsW(sysstr); - - /* MSVCRT will attempt to maintain the wide environment calls - * on _putenv(), which is bogus if we've passed a non-ascii - * string to _putenv(), since they use MultiByteToWideChar - * and breaking the implicit utf-8 assumption we've built. - * - * Reset _wenviron for good measure. - */ - if (_wenviron) { - apr_wchar_t **wenv = _wenviron; - _wenviron = NULL; - free(wenv); - } - - } -#endif - return rv; -} - -static int initialized = 0; - -/* Provide to win32/thread.c */ -extern DWORD tls_apr_thread; - -APR_DECLARE(apr_status_t) apr_initialize(void) -{ - apr_pool_t *pool; - apr_status_t status; - int iVersionRequested; - WSADATA wsaData; - int err; - apr_oslevel_e osver; - - if (initialized++) { - return APR_SUCCESS; - } - - /* Initialize apr_os_level global */ - if (apr_get_oslevel(&osver) != APR_SUCCESS) { - return APR_EEXIST; - } - - tls_apr_thread = TlsAlloc(); - if ((status = apr_pool_initialize()) != APR_SUCCESS) - return status; - - if (apr_pool_create(&pool, NULL) != APR_SUCCESS) { - return APR_ENOPOOL; - } - - apr_pool_tag(pool, "apr_initialize"); - - iVersionRequested = MAKEWORD(WSAHighByte, WSALowByte); - err = WSAStartup((WORD) iVersionRequested, &wsaData); - if (err) { - return err; - } - if (LOBYTE(wsaData.wVersion) != WSAHighByte || - HIBYTE(wsaData.wVersion) != WSALowByte) { - WSACleanup(); - return APR_EEXIST; - } - - apr_signal_init(pool); - - apr_threadproc_init(pool); - - return APR_SUCCESS; -} - -APR_DECLARE_NONSTD(void) apr_terminate(void) -{ - initialized--; - if (initialized) { - return; - } - apr_pool_terminate(); - - WSACleanup(); - - TlsFree(tls_apr_thread); -} - -APR_DECLARE(void) apr_terminate2(void) -{ - apr_terminate(); -} diff --git a/libs/apr/misc/win32/utf8.c b/libs/apr/misc/win32/utf8.c deleted file mode 100644 index 280f4064..00000000 --- a/libs/apr/misc/win32/utf8.c +++ /dev/null @@ -1,259 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_private.h" -#include "apr_errno.h" -#include "apr_arch_utf8.h" - -/* Implementation of RFC 3629, "UTF-8, a transformation format of ISO 10646" - * with particular attention to canonical translation forms (see section 10 - * "Security Considerations" of the RFC for more info). - * - * Since several architectures including Windows support unicode, with UCS2 - * used as the actual storage conventions by that archicture, these functions - * exist to transform or validate UCS2 strings into APR's 'char' type - * convention. It is left up to the operating system to determine the - * validitity of the string, e.g. normative forms, in the context of - * its native language support. Other file systems which support filename - * characters of 0x80-0xff but have no explicit requirement for Unicode - * will find this function useful only for validating the character sequences - * and rejecting poorly encoded UTF8 sequences. - * - * Len UCS-4 range (hex) UTF-8 octet sequence (binary) - * 1:2 00000000-0000007F 0xxxxxxx - * 2:2 00000080-000007FF 110XXXXx 10xxxxxx - * 3:2 00000800-0000FFFF 1110XXXX 10Xxxxxx 10xxxxxx - * 4:4 00010000-001FFFFF 11110XXX 10XXxxxx 10xxxxxx 10xxxxxx - * 00200000-03FFFFFF 111110XX 10XXXxxx 10xxxxxx 10xxxxxx 10xxxxxx - * 04000000-7FFFFFFF 1111110X 10XXXXxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx - * - * One of the X bits must be 1 to avoid overlong representation of ucs2 values. - * - * For conversion into ucs2, the 4th form is limited in range to 0010 FFFF, - * and the final two forms are used only by full ucs4, per RFC 3629; - * - * "Pairs of UCS-2 values between D800 and DFFF (surrogate pairs in - * Unicode parlance), being actually UCS-4 characters transformed - * through UTF-16, need special treatment: the UTF-16 transformation - * must be undone, yielding a UCS-4 character that is then transformed - * as above." - * - * From RFC2781 UTF-16: the compressed ISO 10646 encoding bitmask - * - * U' = U - 0x10000 - * U' = 00000000 0000yyyy yyyyyyxx xxxxxxxx - * W1 = 110110yy yyyyyyyy - * W2 = 110111xx xxxxxxxx - * Max U' = 0000 00001111 11111111 11111111 - * Max U = 0000 00010000 11111111 11111111 - * - * Len is the table above is a mapping of bytes used for utf8:ucs2 values, - * which results in these conclusions of maximum allocations; - * - * apr_conv_utf8_to_ucs2 out bytes:sizeof(in) * 1 <= Req <= sizeof(in) * 2 - * apr_conv_ucs2_to_utf8 out words:sizeof(in) / 2 <= Req <= sizeof(in) * 3 / 2 - */ - -APR_DECLARE(apr_status_t) apr_conv_utf8_to_ucs2(const char *in, - apr_size_t *inbytes, - apr_wchar_t *out, - apr_size_t *outwords) -{ - apr_int64_t newch, mask; - apr_size_t expect, eating; - int ch; - - while (*inbytes && *outwords) - { - ch = (unsigned char)(*in++); - if (!(ch & 0200)) { - /* US-ASCII-7 plain text - */ - --*inbytes; - --*outwords; - *(out++) = ch; - } - else - { - if ((ch & 0300) != 0300) { - /* Multibyte Continuation is out of place - */ - return APR_EINVAL; - } - else - { - /* Multibyte Sequence Lead Character - * - * Compute the expected bytes while adjusting - * or lead byte and leading zeros mask. - */ - mask = 0340; - expect = 1; - while ((ch & mask) == mask) { - mask |= mask >> 1; - if (++expect > 3) /* (truly 5 for ucs-4) */ - return APR_EINVAL; - } - newch = ch & ~mask; - eating = expect + 1; - if (*inbytes <= expect) - return APR_INCOMPLETE; - /* Reject values of excessive leading 0 bits - * utf-8 _demands_ the shortest possible byte length - */ - if (expect == 1) { - if (!(newch & 0036)) - return APR_EINVAL; - } - else { - /* Reject values of excessive leading 0 bits - */ - if (!newch && !((unsigned char)*in & 0077 & (mask << 1))) - return APR_EINVAL; - if (expect == 2) { - /* Reject values D800-DFFF when not utf16 encoded - * (may not be an appropriate restriction for ucs-4) - */ - if (newch == 0015 && ((unsigned char)*in & 0040)) - return APR_EINVAL; - } - else if (expect == 3) { - /* Short circuit values > 110000 - */ - if (newch > 4) - return APR_EINVAL; - if (newch == 4 && ((unsigned char)*in & 0060)) - return APR_EINVAL; - } - } - /* Where the boolean (expect > 2) is true, we will need - * an extra word for the output. - */ - if (*outwords < (apr_size_t)(expect > 2) + 1) - break; /* buffer full */ - while (expect--) - { - /* Multibyte Continuation must be legal */ - if (((ch = (unsigned char)*(in++)) & 0300) != 0200) - return APR_EINVAL; - newch <<= 6; - newch |= (ch & 0077); - } - *inbytes -= eating; - /* newch is now a true ucs-4 character - * - * now we need to fold to ucs-2 - */ - if (newch < 0x10000) - { - --*outwords; - *(out++) = (apr_wchar_t) newch; - } - else - { - *outwords -= 2; - newch -= 0x10000; - *(out++) = (apr_wchar_t) (0xD800 | (newch >> 10)); - *(out++) = (apr_wchar_t) (0xDC00 | (newch & 0x03FF)); - } - } - } - } - /* Buffer full 'errors' aren't errors, the client must inspect both - * the inbytes and outwords values - */ - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_conv_ucs2_to_utf8(const apr_wchar_t *in, - apr_size_t *inwords, - char *out, - apr_size_t *outbytes) -{ - apr_int64_t newch, require; - apr_size_t need; - char *invout; - int ch; - - while (*inwords && *outbytes) - { - ch = (unsigned short)(*in++); - if (ch < 0x80) - { - --*inwords; - --*outbytes; - *(out++) = (unsigned char) ch; - } - else - { - if ((ch & 0xFC00) == 0xDC00) { - /* Invalid Leading ucs-2 Multiword Continuation Character - */ - return APR_EINVAL; - } - if ((ch & 0xFC00) == 0xD800) { - /* Leading ucs-2 Multiword Character - */ - if (*inwords < 2) { - /* Missing ucs-2 Multiword Continuation Character - */ - return APR_INCOMPLETE; - } - if (((unsigned short)(*in) & 0xFC00) != 0xDC00) { - /* Invalid ucs-2 Multiword Continuation Character - */ - return APR_EINVAL; - } - newch = (ch & 0x03FF) << 10 | ((unsigned short)(*in++) & 0x03FF); - newch += 0x10000; - } - else { - /* ucs-2 Single Word Character - */ - newch = ch; - } - /* Determine the absolute minimum utf-8 bytes required - */ - require = newch >> 11; - need = 1; - while (require) - require >>= 5, ++need; - if (need >= *outbytes) - break; /* Insufficient buffer */ - *inwords -= (need > 2) + 1; - *outbytes -= need + 1; - /* Compute the utf-8 characters in last to first order, - * calculating the lead character length bits along the way. - */ - ch = 0200; - out += need + 1; - invout = out; - while (need--) { - ch |= ch >> 1; - *(--invout) = (unsigned char)(0200 | (newch & 0077)); - newch >>= 6; - } - /* Compute the lead utf-8 character and move the dest offset - */ - *(--invout) = (unsigned char)(ch | newch); - } - } - /* Buffer full 'errors' aren't errors, the client must inspect both - * the inwords and outbytes values - */ - return APR_SUCCESS; -} diff --git a/libs/apr/mmap/unix/common.c b/libs/apr/mmap/unix/common.c deleted file mode 100644 index 1172f3c8..00000000 --- a/libs/apr/mmap/unix/common.c +++ /dev/null @@ -1,43 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* common .c - * This file has any function that is truly common and platform - * neutral. Or at least that's the theory. - * - * The header files are a problem so there are a few #ifdef's to take - * care of those. - * - */ - -#include "apr.h" -#include "apr_private.h" -#include "apr_mmap.h" -#include "apr_errno.h" - -#if APR_HAS_MMAP || defined(BEOS) - -APR_DECLARE(apr_status_t) apr_mmap_offset(void **addr, apr_mmap_t *mmap, - apr_off_t offset) -{ - if (offset < 0 || (apr_size_t)offset > mmap->size) - return APR_EINVAL; - - (*addr) = (char *) mmap->mm + offset; - return APR_SUCCESS; -} - -#endif diff --git a/libs/apr/mmap/unix/mmap.c b/libs/apr/mmap/unix/mmap.c deleted file mode 100644 index 67195709..00000000 --- a/libs/apr/mmap/unix/mmap.c +++ /dev/null @@ -1,172 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_mmap.h" -#include "apr_errno.h" -#include "apr_arch_file_io.h" -#include "apr_portable.h" - -/* System headers required for the mmap library */ -#ifdef BEOS -#include -#endif -#if APR_HAVE_STRING_H -#include -#endif -#if APR_HAVE_STDIO_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif -#ifdef HAVE_SYS_MMAN_H -#include -#endif - -#if APR_HAS_MMAP || defined(BEOS) - -static apr_status_t mmap_cleanup(void *themmap) -{ - apr_mmap_t *mm = themmap; - apr_mmap_t *next = APR_RING_NEXT(mm,link); - int rv = 0; - - /* we no longer refer to the mmaped region */ - APR_RING_REMOVE(mm,link); - APR_RING_NEXT(mm,link) = NULL; - APR_RING_PREV(mm,link) = NULL; - - if (next != mm) { - /* more references exist, so we're done */ - return APR_SUCCESS; - } - -#ifdef BEOS - rv = delete_area(mm->area); -#else - rv = munmap(mm->mm, mm->size); -#endif - mm->mm = (void *)-1; - - if (rv == 0) { - return APR_SUCCESS; - } - return errno; -} - -APR_DECLARE(apr_status_t) apr_mmap_create(apr_mmap_t **new, - apr_file_t *file, apr_off_t offset, - apr_size_t size, apr_int32_t flag, - apr_pool_t *cont) -{ - void *mm; -#ifdef BEOS - area_id aid = -1; - uint32 pages = 0; -#else - apr_int32_t native_flags = 0; -#endif - -#if APR_HAS_LARGE_FILES && defined(HAVE_MMAP64) -#define mmap mmap64 -#elif APR_HAS_LARGE_FILES && SIZEOF_OFF_T == 4 - /* LFS but no mmap64: check for overflow */ - if ((apr_int64_t)offset + size > INT_MAX) - return APR_EINVAL; -#endif - - if (size == 0) - return APR_EINVAL; - - if (file == NULL || file->filedes == -1 || file->buffered) - return APR_EBADF; - (*new) = (apr_mmap_t *)apr_pcalloc(cont, sizeof(apr_mmap_t)); - -#ifdef BEOS - /* XXX: mmap shouldn't really change the seek offset */ - apr_file_seek(file, APR_SET, &offset); - - /* There seems to be some strange interactions that mean our area must - * be set as READ & WRITE or writev will fail! Go figure... - * So we ignore the value in flags and always ask for both READ and WRITE - */ - pages = (size + B_PAGE_SIZE -1) / B_PAGE_SIZE; - aid = create_area("apr_mmap", &mm , B_ANY_ADDRESS, pages * B_PAGE_SIZE, - B_NO_LOCK, B_WRITE_AREA|B_READ_AREA); - - if (aid < B_NO_ERROR) { - /* we failed to get an area we can use... */ - *new = NULL; - return APR_ENOMEM; - } - - if (aid >= B_NO_ERROR) - read(file->filedes, mm, size); - - (*new)->area = aid; -#else - - if (flag & APR_MMAP_WRITE) { - native_flags |= PROT_WRITE; - } - if (flag & APR_MMAP_READ) { - native_flags |= PROT_READ; - } - - mm = mmap(NULL, size, native_flags, MAP_SHARED, file->filedes, offset); - - if (mm == (void *)-1) { - /* we failed to get an mmap'd file... */ - *new = NULL; - return errno; - } -#endif - - (*new)->mm = mm; - (*new)->size = size; - (*new)->cntxt = cont; - APR_RING_ELEM_INIT(*new, link); - - /* register the cleanup... */ - apr_pool_cleanup_register((*new)->cntxt, (void*)(*new), mmap_cleanup, - apr_pool_cleanup_null); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_mmap_dup(apr_mmap_t **new_mmap, - apr_mmap_t *old_mmap, - apr_pool_t *p) -{ - *new_mmap = (apr_mmap_t *)apr_pmemdup(p, old_mmap, sizeof(apr_mmap_t)); - (*new_mmap)->cntxt = p; - - APR_RING_INSERT_AFTER(old_mmap, *new_mmap, link); - - apr_pool_cleanup_register(p, *new_mmap, mmap_cleanup, - apr_pool_cleanup_null); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_mmap_delete(apr_mmap_t *mm) -{ - return apr_pool_cleanup_run(mm->cntxt, mm, mmap_cleanup); -} - -#endif diff --git a/libs/apr/mmap/win32/mmap.c b/libs/apr/mmap/win32/mmap.c deleted file mode 100644 index d5d88aeb..00000000 --- a/libs/apr/mmap/win32/mmap.c +++ /dev/null @@ -1,161 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_mmap.h" -#include "apr_errno.h" -#include "apr_arch_file_io.h" -#include "apr_portable.h" -#include "apr_strings.h" - -#if APR_HAS_MMAP - -static apr_status_t mmap_cleanup(void *themmap) -{ - apr_mmap_t *mm = themmap; - apr_mmap_t *next = APR_RING_NEXT(mm,link); - - /* we no longer refer to the mmaped region */ - APR_RING_REMOVE(mm,link); - APR_RING_NEXT(mm,link) = NULL; - APR_RING_PREV(mm,link) = NULL; - - if (next != mm) { - /* more references exist, so we're done */ - return APR_SUCCESS; - } - - if (mm->mv) { - if (!UnmapViewOfFile(mm->mv)) - { - apr_status_t rv = apr_get_os_error(); - CloseHandle(mm->mhandle); - mm->mv = NULL; - mm->mhandle = NULL; - return rv; - } - mm->mv = NULL; - } - if (mm->mhandle) - { - if (!CloseHandle(mm->mhandle)) - { - apr_status_t rv = apr_get_os_error(); - CloseHandle(mm->mhandle); - mm->mhandle = NULL; - return rv; - } - mm->mhandle = NULL; - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_mmap_create(apr_mmap_t **new, apr_file_t *file, - apr_off_t offset, apr_size_t size, - apr_int32_t flag, apr_pool_t *cont) -{ - static DWORD memblock = 0; - DWORD fmaccess = 0; - DWORD mvaccess = 0; - DWORD offlo; - DWORD offhi; - - if (size == 0) - return APR_EINVAL; - - if (flag & APR_MMAP_WRITE) - fmaccess |= PAGE_READWRITE; - else if (flag & APR_MMAP_READ) - fmaccess |= PAGE_READONLY; - - if (flag & APR_MMAP_READ) - mvaccess |= FILE_MAP_READ; - if (flag & APR_MMAP_WRITE) - mvaccess |= FILE_MAP_WRITE; - - if (!file || !file->filehand || file->filehand == INVALID_HANDLE_VALUE - || file->buffered) - return APR_EBADF; - - if (!memblock) - { - SYSTEM_INFO si; - GetSystemInfo(&si); - memblock = si.dwAllocationGranularity; - } - - *new = apr_pcalloc(cont, sizeof(apr_mmap_t)); - (*new)->pstart = (offset / memblock) * memblock; - (*new)->poffset = offset - (*new)->pstart; - (*new)->psize = (apr_size_t)((*new)->poffset) + size; - /* The size of the CreateFileMapping object is the current size - * of the size of the mmap object (e.g. file size), not the size - * of the mapped region! - */ - - (*new)->mhandle = CreateFileMapping(file->filehand, NULL, fmaccess, - 0, 0, NULL); - if (!(*new)->mhandle || (*new)->mhandle == INVALID_HANDLE_VALUE) - { - *new = NULL; - return apr_get_os_error(); - } - - offlo = (DWORD)(*new)->pstart; - offhi = (DWORD)((*new)->pstart >> 32); - (*new)->mv = MapViewOfFile((*new)->mhandle, mvaccess, offhi, - offlo, (*new)->psize); - if (!(*new)->mv) - { - apr_status_t rv = apr_get_os_error(); - CloseHandle((*new)->mhandle); - *new = NULL; - return rv; - } - - (*new)->mm = (char*)((*new)->mv) + (*new)->poffset; - (*new)->size = size; - (*new)->cntxt = cont; - APR_RING_ELEM_INIT(*new, link); - - /* register the cleanup... */ - apr_pool_cleanup_register((*new)->cntxt, (void*)(*new), mmap_cleanup, - apr_pool_cleanup_null); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_mmap_dup(apr_mmap_t **new_mmap, - apr_mmap_t *old_mmap, - apr_pool_t *p) -{ - *new_mmap = (apr_mmap_t *)apr_pmemdup(p, old_mmap, sizeof(apr_mmap_t)); - (*new_mmap)->cntxt = p; - - APR_RING_INSERT_AFTER(old_mmap, *new_mmap, link); - - apr_pool_cleanup_register(p, *new_mmap, mmap_cleanup, - apr_pool_cleanup_null); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_mmap_delete(apr_mmap_t *mm) -{ - return apr_pool_cleanup_run(mm->cntxt, mm, mmap_cleanup); -} - -#endif diff --git a/libs/apr/network_io/beos/sendrecv.c b/libs/apr/network_io/beos/sendrecv.c deleted file mode 100644 index 201abf89..00000000 --- a/libs/apr/network_io/beos/sendrecv.c +++ /dev/null @@ -1,216 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_private.h" -#if BEOS_BONE /* BONE uses the unix code - woohoo */ -#include "../unix/sendrecv.c" -#else -#include "apr_arch_networkio.h" -#include "apr_time.h" - -static apr_status_t wait_for_io_or_timeout(apr_socket_t *sock, int for_read) -{ - struct timeval tv, *tvptr; - fd_set fdset; - int srv; - - do { - FD_ZERO(&fdset); - FD_SET(sock->socketdes, &fdset); - if (sock->timeout < 0) { - tvptr = NULL; - } - else { - tv.tv_sec = sock->timeout / APR_USEC_PER_SEC; - tv.tv_usec = sock->timeout % APR_USEC_PER_SEC; - tvptr = &tv; - } - srv = select(sock->socketdes + 1, - for_read ? &fdset : NULL, - for_read ? NULL : &fdset, - NULL, - tvptr); - /* TODO - timeout should be smaller on repeats of this loop */ - } while (srv == -1 && errno == EINTR); - - if (srv == 0) { - return APR_TIMEUP; - } - else if (srv < 0) { - return errno; - } - return APR_SUCCESS; -} - -#define SEND_WAIT APR_USEC_PER_SEC / 10 - -APR_DECLARE(apr_status_t) apr_socket_send(apr_socket_t *sock, const char *buf, - apr_size_t *len) -{ - apr_ssize_t rv; - - do { - rv = send(sock->socketdes, buf, (*len), 0); - } while (rv == -1 && errno == EINTR); - - if (rv == -1 && errno == EWOULDBLOCK && sock->timeout > 0) { - apr_int32_t snooze_val = SEND_WAIT; - apr_int32_t zzz = 0; - - do { - rv = send(sock->socketdes, buf, (*len), 0); - if (rv == -1 && errno == EWOULDBLOCK){ - apr_sleep (snooze_val); - zzz += snooze_val; - snooze_val += SEND_WAIT; - /* have we passed our timeout value */ - if (zzz > (sock->timeout * APR_USEC_PER_SEC)) - break; - } - } while (rv == -1 && (errno == EINTR || errno == EWOULDBLOCK)); - } - if (rv == -1) { - *len = 0; - return errno; - } - (*len) = rv; - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_socket_recv(apr_socket_t *sock, char *buf, - apr_size_t *len) -{ - apr_ssize_t rv; - - do { - rv = recv(sock->socketdes, buf, (*len), 0); - } while (rv == -1 && errno == EINTR); - - if (rv == -1 && errno == EWOULDBLOCK && sock->timeout > 0) { - apr_status_t arv = wait_for_io_or_timeout(sock, 1); - if (arv != APR_SUCCESS) { - *len = 0; - return arv; - } - else { - do { - rv = recv(sock->socketdes, buf, (*len), 0); - } while (rv == -1 && errno == EINTR); - } - } - if (rv == -1) { - (*len) = 0; - return errno; - } - (*len) = rv; - if (rv == 0) - return APR_EOF; - return APR_SUCCESS; -} - -/* BeOS doesn't have writev for sockets so we use the following instead... - */ -APR_DECLARE(apr_status_t) apr_socket_sendv(apr_socket_t * sock, - const struct iovec *vec, - apr_int32_t nvec, apr_size_t *len) -{ - *len = vec[0].iov_len; - return apr_socket_send(sock, vec[0].iov_base, len); -} - -APR_DECLARE(apr_status_t) apr_socket_sendto(apr_socket_t *sock, - apr_sockaddr_t *where, - apr_int32_t flags, const char *buf, - apr_size_t *len) -{ - apr_ssize_t rv; - - do { - rv = sendto(sock->socketdes, buf, (*len), flags, - (const struct sockaddr*)&where->sa, - where->salen); - } while (rv == -1 && errno == EINTR); - - if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) - && sock->timeout != 0) { - apr_status_t arv = wait_for_io_or_timeout(sock, 0); - if (arv != APR_SUCCESS) { - *len = 0; - return arv; - } else { - do { - rv = sendto(sock->socketdes, buf, (*len), flags, - (const struct sockaddr*)&where->sa, - where->salen); - } while (rv == -1 && errno == EINTR); - } - } - if (rv == -1) { - *len = 0; - return errno; - } - *len = rv; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_socket_recvfrom(apr_sockaddr_t *from, - apr_socket_t *sock, - apr_int32_t flags, char *buf, - apr_size_t *len) -{ - apr_ssize_t rv; - - if (from == NULL){ - return APR_ENOMEM; - /* Not sure if this is correct. Maybe we should just allocate - the memory?? - */ - } - - do { - rv = recvfrom(sock->socketdes, buf, (*len), flags, - (struct sockaddr*)&from->sa, &from->salen); - } while (rv == -1 && errno == EINTR); - - if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) && - sock->timeout != 0) { - apr_status_t arv = wait_for_io_or_timeout(sock, 1); - if (arv != APR_SUCCESS) { - *len = 0; - return arv; - } else { - do { - rv = recvfrom(sock->socketdes, buf, (*len), flags, - (struct sockaddr*)&from->sa, &from->salen); - } while (rv == -1 && errno == EINTR); - } - } - if (rv == -1) { - (*len) = 0; - return errno; - } - - from->port = ntohs(from->sa.sin.sin_port); - - (*len) = rv; - if (rv == 0) - return APR_EOF; - - return APR_SUCCESS; -} - -#endif /* ! BEOS_BONE */ diff --git a/libs/apr/network_io/beos/socketcommon.c b/libs/apr/network_io/beos/socketcommon.c deleted file mode 100644 index b9f594bb..00000000 --- a/libs/apr/network_io/beos/socketcommon.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "../unix/inet_ntop.c" -#include "../unix/inet_pton.c" -#include "../unix/sockets.c" -#include "../unix/sockaddr.c" -#include "../unix/sockopt.c" -#include "../unix/socket_util.c" diff --git a/libs/apr/network_io/os2/inet_ntop.c b/libs/apr/network_io/os2/inet_ntop.c deleted file mode 100644 index f1f79d49..00000000 --- a/libs/apr/network_io/os2/inet_ntop.c +++ /dev/null @@ -1 +0,0 @@ -#include "../unix/inet_ntop.c" diff --git a/libs/apr/network_io/os2/inet_pton.c b/libs/apr/network_io/os2/inet_pton.c deleted file mode 100644 index dbd3ac45..00000000 --- a/libs/apr/network_io/os2/inet_pton.c +++ /dev/null @@ -1 +0,0 @@ -#include "../unix/inet_pton.c" diff --git a/libs/apr/network_io/os2/os2calls.c b/libs/apr/network_io/os2/os2calls.c deleted file mode 100644 index 6bf1fcd0..00000000 --- a/libs/apr/network_io/os2/os2calls.c +++ /dev/null @@ -1,132 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_networkio.h" -#include "apr_network_io.h" -#include "apr_portable.h" -#include "apr_general.h" -#include "apr_lib.h" - -static int os2_socket_init(int, int ,int); - -int (*apr_os2_socket)(int, int, int) = os2_socket_init; -int (*apr_os2_select)(int *, int, int, int, long) = NULL; -int (*apr_os2_sock_errno)() = NULL; -int (*apr_os2_accept)(int, struct sockaddr *, int *) = NULL; -int (*apr_os2_bind)(int, struct sockaddr *, int) = NULL; -int (*apr_os2_connect)(int, struct sockaddr *, int) = NULL; -int (*apr_os2_getpeername)(int, struct sockaddr *, int *) = NULL; -int (*apr_os2_getsockname)(int, struct sockaddr *, int *) = NULL; -int (*apr_os2_getsockopt)(int, int, int, char *, int *) = NULL; -int (*apr_os2_ioctl)(int, int, caddr_t, int) = NULL; -int (*apr_os2_listen)(int, int) = NULL; -int (*apr_os2_recv)(int, char *, int, int) = NULL; -int (*apr_os2_send)(int, const char *, int, int) = NULL; -int (*apr_os2_setsockopt)(int, int, int, char *, int) = NULL; -int (*apr_os2_shutdown)(int, int) = NULL; -int (*apr_os2_soclose)(int) = NULL; -int (*apr_os2_writev)(int, struct iovec *, int) = NULL; -int (*apr_os2_sendto)(int, const char *, int, int, const struct sockaddr *, int); -int (*apr_os2_recvfrom)(int, char *, int, int, struct sockaddr *, int *); - -static HMODULE hSO32DLL; - -static int os2_fn_link() -{ - DosEnterCritSec(); /* Stop two threads doing this at the same time */ - - if (apr_os2_socket == os2_socket_init) { - ULONG rc; - char errorstr[200]; - - rc = DosLoadModule(errorstr, sizeof(errorstr), "SO32DLL", &hSO32DLL); - - if (rc) - return APR_OS2_STATUS(rc); - - rc = DosQueryProcAddr(hSO32DLL, 0, "SOCKET", &apr_os2_socket); - - if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "SELECT", &apr_os2_select); - - if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "SOCK_ERRNO", &apr_os2_sock_errno); - - if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "ACCEPT", &apr_os2_accept); - - if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "BIND", &apr_os2_bind); - - if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "CONNECT", &apr_os2_connect); - - if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "GETPEERNAME", &apr_os2_getpeername); - - if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "GETSOCKNAME", &apr_os2_getsockname); - - if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "GETSOCKOPT", &apr_os2_getsockopt); - - if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "IOCTL", &apr_os2_ioctl); - - if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "LISTEN", &apr_os2_listen); - - if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "RECV", &apr_os2_recv); - - if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "SEND", &apr_os2_send); - - if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "SETSOCKOPT", &apr_os2_setsockopt); - - if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "SHUTDOWN", &apr_os2_shutdown); - - if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "SOCLOSE", &apr_os2_soclose); - - if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "WRITEV", &apr_os2_writev); - - if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "SENDTO", &apr_os2_sendto); - - if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "RECVFROM", &apr_os2_recvfrom); - - if (rc) - return APR_OS2_STATUS(rc); - } - - DosExitCritSec(); - return APR_SUCCESS; -} - - - -static int os2_socket_init(int domain, int type, int protocol) -{ - int rc = os2_fn_link(); - if (rc == APR_SUCCESS) - return apr_os2_socket(domain, type, protocol); - return rc; -} diff --git a/libs/apr/network_io/os2/sendrecv.c b/libs/apr/network_io/os2/sendrecv.c deleted file mode 100644 index 839ff3f8..00000000 --- a/libs/apr/network_io/os2/sendrecv.c +++ /dev/null @@ -1,155 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_networkio.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_network_io.h" -#include "apr_lib.h" -#include - -APR_DECLARE(apr_status_t) apr_socket_send(apr_socket_t *sock, const char *buf, - apr_size_t *len) -{ - apr_ssize_t rv; - int fds, err = 0; - - if (*len > 65536) { - *len = 65536; - } - - do { - if (!sock->nonblock || err == SOCEWOULDBLOCK) { - fds = sock->socketdes; - rv = select(&fds, 0, 1, 0, sock->timeout >= 0 ? sock->timeout/1000 : -1); - - if (rv != 1) { - *len = 0; - err = sock_errno(); - - if (rv == 0) - return APR_TIMEUP; - - if (err == SOCEINTR) - continue; - - return APR_OS2_STATUS(err); - } - } - - rv = send(sock->socketdes, buf, (*len), 0); - err = rv < 0 ? sock_errno() : 0; - } while (err == SOCEINTR || err == SOCEWOULDBLOCK); - - if (err) { - *len = 0; - return APR_OS2_STATUS(err); - } - - (*len) = rv; - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_socket_recv(apr_socket_t *sock, char *buf, - apr_size_t *len) -{ - apr_ssize_t rv; - int fds, err = 0; - - do { - if (!sock->nonblock || (err == SOCEWOULDBLOCK && sock->timeout != 0)) { - fds = sock->socketdes; - rv = select(&fds, 1, 0, 0, sock->timeout >= 0 ? sock->timeout/1000 : -1); - - if (rv != 1) { - *len = 0; - err = sock_errno(); - - if (rv == 0) - return APR_TIMEUP; - - if (err == SOCEINTR) - continue; - - return APR_OS2_STATUS(err); - } - } - - rv = recv(sock->socketdes, buf, (*len), 0); - err = rv < 0 ? sock_errno() : 0; - } while (err == SOCEINTR || (err == SOCEWOULDBLOCK && sock->timeout != 0)); - - if (err) { - *len = 0; - return APR_OS2_STATUS(err); - } - - (*len) = rv; - return rv == 0 ? APR_EOF : APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_socket_sendv(apr_socket_t *sock, - const struct iovec *vec, - apr_int32_t nvec, apr_size_t *len) -{ - apr_status_t rv; - struct iovec *tmpvec; - int fds, err = 0; - int nv_tosend, total = 0; - - /* Make sure writev() only gets fed 64k at a time */ - for ( nv_tosend = 0; nv_tosend < nvec && total + vec[nv_tosend].iov_len < 65536; nv_tosend++ ) { - total += vec[nv_tosend].iov_len; - } - - tmpvec = alloca(sizeof(struct iovec) * nv_tosend); - memcpy(tmpvec, vec, sizeof(struct iovec) * nv_tosend); - - do { - if (!sock->nonblock || err == SOCEWOULDBLOCK) { - fds = sock->socketdes; - rv = select(&fds, 0, 1, 0, sock->timeout >= 0 ? sock->timeout/1000 : -1); - - if (rv != 1) { - *len = 0; - err = sock_errno(); - - if (rv == 0) - return APR_TIMEUP; - - if (err == SOCEINTR) - continue; - - return APR_OS2_STATUS(err); - } - } - - rv = writev(sock->socketdes, tmpvec, nv_tosend); - err = rv < 0 ? sock_errno() : 0; - } while (err == SOCEINTR || err == SOCEWOULDBLOCK); - - if (err) { - *len = 0; - return APR_OS2_STATUS(err); - } - - *len = rv; - return APR_SUCCESS; -} diff --git a/libs/apr/network_io/os2/sendrecv_udp.c b/libs/apr/network_io/os2/sendrecv_udp.c deleted file mode 100644 index c0dcd856..00000000 --- a/libs/apr/network_io/os2/sendrecv_udp.c +++ /dev/null @@ -1,104 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_networkio.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_network_io.h" -#include "apr_support.h" -#include "apr_lib.h" -#include - - -APR_DECLARE(apr_status_t) apr_socket_sendto(apr_socket_t *sock, - apr_sockaddr_t *where, - apr_int32_t flags, const char *buf, - apr_size_t *len) -{ - apr_ssize_t rv; - int serrno; - - do { - rv = sendto(sock->socketdes, buf, (*len), flags, - (struct sockaddr*)&where->sa, - where->salen); - } while (rv == -1 && (serrno = sock_errno()) == EINTR); - - if (rv == -1 && serrno == SOCEWOULDBLOCK && sock->timeout != 0) { - apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0); - - if (arv != APR_SUCCESS) { - *len = 0; - return arv; - } else { - do { - rv = sendto(sock->socketdes, buf, *len, flags, - (const struct sockaddr*)&where->sa, - where->salen); - } while (rv == -1 && (serrno = sock_errno()) == SOCEINTR); - } - } - - if (rv == -1) { - *len = 0; - return APR_FROM_OS_ERROR(serrno); - } - - *len = rv; - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_socket_recvfrom(apr_sockaddr_t *from, - apr_socket_t *sock, - apr_int32_t flags, char *buf, - apr_size_t *len) -{ - apr_ssize_t rv; - int serrno; - - do { - rv = recvfrom(sock->socketdes, buf, (*len), flags, - (struct sockaddr*)&from->sa, &from->salen); - } while (rv == -1 && (serrno = sock_errno()) == EINTR); - - if (rv == -1 && serrno == SOCEWOULDBLOCK && sock->timeout != 0) { - apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 1); - - if (arv != APR_SUCCESS) { - *len = 0; - return arv; - } else { - do { - rv = recvfrom(sock->socketdes, buf, *len, flags, - (struct sockaddr*)&from->sa, &from->salen); - } while (rv == -1 && (serrno = sock_errno()) == EINTR); - } - } - - if (rv == -1) { - (*len) = 0; - return APR_FROM_OS_ERROR(serrno); - } - - (*len) = rv; - - if (rv == 0 && sock->type == SOCK_STREAM) - return APR_EOF; - - return APR_SUCCESS; -} diff --git a/libs/apr/network_io/os2/sockaddr.c b/libs/apr/network_io/os2/sockaddr.c deleted file mode 100644 index 2afe4b77..00000000 --- a/libs/apr/network_io/os2/sockaddr.c +++ /dev/null @@ -1 +0,0 @@ -#include "../unix/sockaddr.c" diff --git a/libs/apr/network_io/os2/socket_util.c b/libs/apr/network_io/os2/socket_util.c deleted file mode 100644 index cdc1cea8..00000000 --- a/libs/apr/network_io/os2/socket_util.c +++ /dev/null @@ -1 +0,0 @@ -#include "../unix/socket_util.c" diff --git a/libs/apr/network_io/os2/sockets.c b/libs/apr/network_io/os2/sockets.c deleted file mode 100644 index bb951e4c..00000000 --- a/libs/apr/network_io/os2/sockets.c +++ /dev/null @@ -1,317 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_networkio.h" -#include "apr_arch_inherit.h" -#include "apr_network_io.h" -#include "apr_general.h" -#include "apr_portable.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include -#include -#include -#include -#include -#include -#include -#include "apr_arch_os2calls.h" - -static apr_status_t socket_cleanup(void *sock) -{ - apr_socket_t *thesocket = sock; - - if (thesocket->socketdes < 0) { - return APR_EINVALSOCK; - } - - if (soclose(thesocket->socketdes) == 0) { - thesocket->socketdes = -1; - return APR_SUCCESS; - } - else { - return APR_OS2_STATUS(sock_errno()); - } -} - -static void set_socket_vars(apr_socket_t *sock, int family, int type, int protocol) -{ - sock->type = type; - sock->protocol = protocol; - apr_sockaddr_vars_set(sock->local_addr, family, 0); - apr_sockaddr_vars_set(sock->remote_addr, family, 0); -} - -static void alloc_socket(apr_socket_t **new, apr_pool_t *p) -{ - *new = (apr_socket_t *)apr_pcalloc(p, sizeof(apr_socket_t)); - (*new)->pool = p; - (*new)->local_addr = (apr_sockaddr_t *)apr_pcalloc((*new)->pool, - sizeof(apr_sockaddr_t)); - (*new)->local_addr->pool = p; - - (*new)->remote_addr = (apr_sockaddr_t *)apr_pcalloc((*new)->pool, - sizeof(apr_sockaddr_t)); - (*new)->remote_addr->pool = p; - (*new)->remote_addr_unknown = 1; - - /* Create a pollset with room for one descriptor. */ - /* ### check return codes */ - (void) apr_pollset_create(&(*new)->pollset, 1, p, 0); -} - -APR_DECLARE(apr_status_t) apr_socket_protocol_get(apr_socket_t *sock, int *protocol) -{ - *protocol = sock->protocol; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new, int family, int type, - int protocol, apr_pool_t *cont) -{ - int downgrade = (family == AF_UNSPEC); - apr_pollfd_t pfd; - - if (family == AF_UNSPEC) { -#if APR_HAVE_IPV6 - family = AF_INET6; -#else - family = AF_INET; -#endif - } - - alloc_socket(new, cont); - - (*new)->socketdes = socket(family, type, protocol); -#if APR_HAVE_IPV6 - if ((*new)->socketdes < 0 && downgrade) { - family = AF_INET; - (*new)->socketdes = socket(family, type, protocol); - } -#endif - - if ((*new)->socketdes < 0) { - return APR_OS2_STATUS(sock_errno()); - } - set_socket_vars(*new, family, type, protocol); - - (*new)->timeout = -1; - (*new)->nonblock = FALSE; - apr_pool_cleanup_register((*new)->pool, (void *)(*new), - socket_cleanup, apr_pool_cleanup_null); - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_socket_shutdown(apr_socket_t *thesocket, - apr_shutdown_how_e how) -{ - if (shutdown(thesocket->socketdes, how) == 0) { - return APR_SUCCESS; - } - else { - return APR_OS2_STATUS(sock_errno()); - } -} - -APR_DECLARE(apr_status_t) apr_socket_close(apr_socket_t *thesocket) -{ - apr_pool_cleanup_kill(thesocket->pool, thesocket, socket_cleanup); - return socket_cleanup(thesocket); -} - -APR_DECLARE(apr_status_t) apr_socket_bind(apr_socket_t *sock, - apr_sockaddr_t *sa) -{ - if (bind(sock->socketdes, - (struct sockaddr *)&sa->sa, - sa->salen) == -1) - return APR_OS2_STATUS(sock_errno()); - else { - sock->local_addr = sa; - /* XXX IPv6 - this assumes sin_port and sin6_port at same offset */ - if (sock->local_addr->sa.sin.sin_port == 0) { /* no need for ntohs() when comparing w/ 0 */ - sock->local_port_unknown = 1; /* kernel got us an ephemeral port */ - } - return APR_SUCCESS; - } -} - -APR_DECLARE(apr_status_t) apr_socket_listen(apr_socket_t *sock, - apr_int32_t backlog) -{ - if (listen(sock->socketdes, backlog) == -1) - return APR_OS2_STATUS(sock_errno()); - else - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_socket_accept(apr_socket_t **new, - apr_socket_t *sock, - apr_pool_t *connection_context) -{ - alloc_socket(new, connection_context); - set_socket_vars(*new, sock->local_addr->sa.sin.sin_family, SOCK_STREAM, sock->protocol); - - (*new)->timeout = -1; - (*new)->nonblock = FALSE; - - (*new)->socketdes = accept(sock->socketdes, - (struct sockaddr *)&(*new)->remote_addr->sa, - &(*new)->remote_addr->salen); - - if ((*new)->socketdes < 0) { - return APR_OS2_STATUS(sock_errno()); - } - - *(*new)->local_addr = *sock->local_addr; - (*new)->local_addr->pool = connection_context; - (*new)->remote_addr->port = ntohs((*new)->remote_addr->sa.sin.sin_port); - - /* fix up any pointers which are no longer valid */ - if (sock->local_addr->sa.sin.sin_family == AF_INET) { - (*new)->local_addr->ipaddr_ptr = &(*new)->local_addr->sa.sin.sin_addr; - } - - apr_pool_cleanup_register((*new)->pool, (void *)(*new), - socket_cleanup, apr_pool_cleanup_null); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_socket_connect(apr_socket_t *sock, - apr_sockaddr_t *sa) -{ - if ((connect(sock->socketdes, (struct sockaddr *)&sa->sa.sin, - sa->salen) < 0) && - (sock_errno() != SOCEINPROGRESS)) { - return APR_OS2_STATUS(sock_errno()); - } - else { - int namelen = sizeof(sock->local_addr->sa.sin); - getsockname(sock->socketdes, (struct sockaddr *)&sock->local_addr->sa.sin, - &namelen); - sock->remote_addr = sa; - return APR_SUCCESS; - } -} - -APR_DECLARE(apr_status_t) apr_socket_type_get(apr_socket_t *sock, int *type) -{ - *type = sock->type; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_socket_data_get(void **data, const char *key, - apr_socket_t *sock) -{ - sock_userdata_t *cur = sock->userdata; - - *data = NULL; - - while (cur) { - if (!strcmp(cur->key, key)) { - *data = cur->data; - break; - } - cur = cur->next; - } - - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_socket_data_set(apr_socket_t *sock, void *data, const char *key, - apr_status_t (*cleanup) (void *)) -{ - sock_userdata_t *new = apr_palloc(sock->pool, sizeof(sock_userdata_t)); - - new->key = apr_pstrdup(sock->pool, key); - new->data = data; - new->next = sock->userdata; - sock->userdata = new; - - if (cleanup) { - apr_pool_cleanup_register(sock->pool, data, cleanup, cleanup); - } - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_sock_get(apr_os_sock_t *thesock, apr_socket_t *sock) -{ - *thesock = sock->socketdes; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_sock_make(apr_socket_t **apr_sock, - apr_os_sock_info_t *os_sock_info, - apr_pool_t *cont) -{ - alloc_socket(apr_sock, cont); - set_socket_vars(*apr_sock, os_sock_info->family, os_sock_info->type, os_sock_info->protocol); - (*apr_sock)->timeout = -1; - (*apr_sock)->socketdes = *os_sock_info->os_sock; - if (os_sock_info->local) { - memcpy(&(*apr_sock)->local_addr->sa.sin, - os_sock_info->local, - (*apr_sock)->local_addr->salen); - /* XXX IPv6 - this assumes sin_port and sin6_port at same offset */ - (*apr_sock)->local_addr->port = ntohs((*apr_sock)->local_addr->sa.sin.sin_port); - } - else { - (*apr_sock)->local_port_unknown = (*apr_sock)->local_interface_unknown = 1; - } - if (os_sock_info->remote) { - memcpy(&(*apr_sock)->remote_addr->sa.sin, - os_sock_info->remote, - (*apr_sock)->remote_addr->salen); - /* XXX IPv6 - this assumes sin_port and sin6_port at same offset */ - (*apr_sock)->remote_addr->port = ntohs((*apr_sock)->remote_addr->sa.sin.sin_port); - } - else { - (*apr_sock)->remote_addr_unknown = 1; - } - - apr_pool_cleanup_register((*apr_sock)->pool, (void *)(*apr_sock), - socket_cleanup, apr_pool_cleanup_null); - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_sock_put(apr_socket_t **sock, apr_os_sock_t *thesock, apr_pool_t *cont) -{ - if (cont == NULL) { - return APR_ENOPOOL; - } - if ((*sock) == NULL) { - alloc_socket(sock, cont); - set_socket_vars(*sock, AF_INET, SOCK_STREAM, 0); - (*sock)->timeout = -1; - } - - (*sock)->local_port_unknown = (*sock)->local_interface_unknown = 1; - (*sock)->remote_addr_unknown = 1; - (*sock)->socketdes = *thesock; - return APR_SUCCESS; -} - -APR_POOL_IMPLEMENT_ACCESSOR(socket); - -APR_IMPLEMENT_INHERIT_SET(socket, inherit, pool, socket_cleanup) - -APR_IMPLEMENT_INHERIT_UNSET(socket, inherit, pool, socket_cleanup) - diff --git a/libs/apr/network_io/os2/sockopt.c b/libs/apr/network_io/os2/sockopt.c deleted file mode 100644 index 101a952d..00000000 --- a/libs/apr/network_io/os2/sockopt.c +++ /dev/null @@ -1,139 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_networkio.h" -#include "apr_network_io.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include -#include -#include -#include -#include -#include -#include -#include - - -APR_DECLARE(apr_status_t) apr_socket_timeout_set(apr_socket_t *sock, - apr_interval_time_t t) -{ - sock->timeout = t; - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock, - apr_int32_t opt, apr_int32_t on) -{ - int one; - struct linger li; - - if (on) - one = 1; - else - one = 0; - - if (opt & APR_SO_KEEPALIVE) { - if (setsockopt(sock->socketdes, SOL_SOCKET, SO_KEEPALIVE, (void *)&one, sizeof(int)) == -1) { - return APR_OS2_STATUS(sock_errno()); - } - } - if (opt & APR_SO_DEBUG) { - if (setsockopt(sock->socketdes, SOL_SOCKET, SO_DEBUG, (void *)&one, sizeof(int)) == -1) { - return APR_OS2_STATUS(sock_errno()); - } - } - if (opt & APR_SO_REUSEADDR) { - if (setsockopt(sock->socketdes, SOL_SOCKET, SO_REUSEADDR, (void *)&one, sizeof(int)) == -1) { - return APR_OS2_STATUS(sock_errno()); - } - } - if (opt & APR_SO_SNDBUF) { - if (setsockopt(sock->socketdes, SOL_SOCKET, SO_SNDBUF, (void *)&on, sizeof(int)) == -1) { - return APR_OS2_STATUS(sock_errno()); - } - } - if (opt & APR_SO_NONBLOCK) { - if (ioctl(sock->socketdes, FIONBIO, (caddr_t)&one, sizeof(one)) == -1) { - return APR_OS2_STATUS(sock_errno()); - } else { - sock->nonblock = one; - } - } - if (opt & APR_SO_LINGER) { - li.l_onoff = on; - li.l_linger = APR_MAX_SECS_TO_LINGER; - if (setsockopt(sock->socketdes, SOL_SOCKET, SO_LINGER, (char *) &li, sizeof(struct linger)) == -1) { - return APR_OS2_STATUS(sock_errno()); - } - } - if (opt & APR_TCP_NODELAY) { - if (setsockopt(sock->socketdes, IPPROTO_TCP, TCP_NODELAY, (void *)&on, sizeof(int)) == -1) { - return APR_OS2_STATUS(sock_errno()); - } - } - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_socket_timeout_get(apr_socket_t *sock, - apr_interval_time_t *t) -{ - *t = sock->timeout; - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_socket_opt_get(apr_socket_t *sock, - apr_int32_t opt, apr_int32_t *on) -{ - switch(opt) { - default: - return APR_EINVAL; - } - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_socket_atmark(apr_socket_t *sock, int *atmark) -{ - int oobmark; - - if (ioctl(sock->socketdes, SIOCATMARK, (void*)&oobmark, sizeof(oobmark)) < 0) { - return APR_OS2_STATUS(sock_errno()); - } - - *atmark = (oobmark != 0); - - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_gethostname(char *buf, apr_int32_t len, - apr_pool_t *cont) -{ - if (gethostname(buf, len) == -1) { - buf[0] = '\0'; - return APR_OS2_STATUS(sock_errno()); - } - else if (!memchr(buf, '\0', len)) { /* buffer too small */ - buf[0] = '\0'; - return APR_ENAMETOOLONG; - } - return APR_SUCCESS; -} diff --git a/libs/apr/network_io/unix/inet_ntop.c b/libs/apr/network_io/unix/inet_ntop.c deleted file mode 100644 index 78dd3baa..00000000 --- a/libs/apr/network_io/unix/inet_ntop.c +++ /dev/null @@ -1,243 +0,0 @@ -/* Copyright (c) 1996 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -#include "apr_private.h" -#include "apr_arch_networkio.h" -#include "apr_strings.h" - -#if APR_HAVE_SYS_TYPES_H -#include -#endif -#if APR_HAVE_SYS_SOCKET_H -#include -#endif -#if APR_HAVE_NETINET_IN_H -#include -#endif -#if APR_HAVE_ARPA_INET_H -#include -#endif -#include -#if APR_HAVE_ERRNO_H -#include -#endif -#include - -#ifndef IN6ADDRSZ -#define IN6ADDRSZ 16 -#endif - -#ifndef INT16SZ -#define INT16SZ sizeof(apr_int16_t) -#endif - -#ifndef __P -#define __P(x) x -#endif - -#if !defined(EAFNOSUPPORT) && defined(WSAEAFNOSUPPORT) -#define EAFNOSUPPORT WSAEAFNOSUPPORT -#endif - -/* - * WARNING: Don't even consider trying to compile this on a system where - * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. - */ - -static const char *inet_ntop4 __P((const unsigned char *src, char *dst, apr_size_t size)); -#if APR_HAVE_IPV6 -static const char *inet_ntop6 __P((const unsigned char *src, char *dst, apr_size_t size)); -#endif - -/* char * - * inet_ntop(af, src, dst, size) - * convert a network format address to presentation format. - * return: - * pointer to presentation format address (`dst'), or NULL (see errno). - * author: - * Paul Vixie, 1996. - */ -const char * -apr_inet_ntop(int af, const void *src, char *dst, apr_size_t size) -{ - switch (af) { - case AF_INET: - return (inet_ntop4(src, dst, size)); -#if APR_HAVE_IPV6 - case AF_INET6: - return (inet_ntop6(src, dst, size)); -#endif - default: - errno = EAFNOSUPPORT; - return (NULL); - } - /* NOTREACHED */ -} - -/* const char * - * inet_ntop4(src, dst, size) - * format an IPv4 address, more or less like inet_ntoa() - * return: - * `dst' (as a const) - * notes: - * (1) uses no statics - * (2) takes a u_char* not an in_addr as input - * author: - * Paul Vixie, 1996. - */ -static const char * -inet_ntop4(const unsigned char *src, char *dst, apr_size_t size) -{ - const apr_size_t MIN_SIZE = 16; /* space for 255.255.255.255\0 */ - int n = 0; - char *next = dst; - - if (size < MIN_SIZE) { - errno = ENOSPC; - return NULL; - } - do { - unsigned char u = *src++; - if (u > 99) { - *next++ = '0' + u/100; - u %= 100; - *next++ = '0' + u/10; - u %= 10; - } - else if (u > 9) { - *next++ = '0' + u/10; - u %= 10; - } - *next++ = '0' + u; - *next++ = '.'; - n++; - } while (n < 4); - *--next = 0; - return dst; -} - -#if APR_HAVE_IPV6 -/* const char * - * inet_ntop6(src, dst, size) - * convert IPv6 binary address into presentation (printable) format - * author: - * Paul Vixie, 1996. - */ -static const char * -inet_ntop6(const unsigned char *src, char *dst, apr_size_t size) -{ - /* - * Note that int32_t and int16_t need only be "at least" large enough - * to contain a value of the specified size. On some systems, like - * Crays, there is no such thing as an integer variable with 16 bits. - * Keep this in mind if you think this function should have been coded - * to use pointer overlays. All the world's not a VAX. - */ - char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp; - struct { int base, len; } best = {-1, 0}, cur = {-1, 0}; - unsigned int words[IN6ADDRSZ / INT16SZ]; - int i; - const unsigned char *next_src, *src_end; - unsigned int *next_dest; - - /* - * Preprocess: - * Copy the input (bytewise) array into a wordwise array. - * Find the longest run of 0x00's in src[] for :: shorthanding. - */ - next_src = src; - src_end = src + IN6ADDRSZ; - next_dest = words; - i = 0; - do { - unsigned int next_word = (unsigned int)*next_src++; - next_word <<= 8; - next_word |= (unsigned int)*next_src++; - *next_dest++ = next_word; - - if (next_word == 0) { - if (cur.base == -1) { - cur.base = i; - cur.len = 1; - } - else { - cur.len++; - } - } else { - if (cur.base != -1) { - if (best.base == -1 || cur.len > best.len) { - best = cur; - } - cur.base = -1; - } - } - - i++; - } while (next_src < src_end); - - if (cur.base != -1) { - if (best.base == -1 || cur.len > best.len) { - best = cur; - } - } - if (best.base != -1 && best.len < 2) { - best.base = -1; - } - - /* - * Format the result. - */ - tp = tmp; - for (i = 0; i < (IN6ADDRSZ / INT16SZ);) { - /* Are we inside the best run of 0x00's? */ - if (i == best.base) { - *tp++ = ':'; - i += best.len; - continue; - } - /* Are we following an initial run of 0x00s or any real hex? */ - if (i != 0) { - *tp++ = ':'; - } - /* Is this address an encapsulated IPv4? */ - if (i == 6 && best.base == 0 && - (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) { - if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp))) { - return (NULL); - } - tp += strlen(tp); - break; - } - tp += apr_snprintf(tp, sizeof tmp - (tp - tmp), "%x", words[i]); - i++; - } - /* Was it a trailing run of 0x00's? */ - if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ)) { - *tp++ = ':'; - } - *tp++ = '\0'; - - /* - * Check for overflow, copy, and we're done. - */ - if ((apr_size_t)(tp - tmp) > size) { - errno = ENOSPC; - return (NULL); - } - strcpy(dst, tmp); - return (dst); -} -#endif diff --git a/libs/apr/network_io/unix/inet_pton.c b/libs/apr/network_io/unix/inet_pton.c deleted file mode 100644 index d41f7496..00000000 --- a/libs/apr/network_io/unix/inet_pton.c +++ /dev/null @@ -1,240 +0,0 @@ -/* Copyright (c) 1996 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -#include "apr_private.h" -#include "apr_arch_networkio.h" - -#if APR_HAVE_SYS_TYPES_H -#include -#endif -#if APR_HAVE_SYS_SOCKET_H -#include -#endif -#if APR_HAVE_NETINET_IN_H -#include -#endif -#if APR_HAVE_ARPA_INET_H -#include -#endif -#include -#if APR_HAVE_ERRNO_H -#include -#endif - -#ifndef IN6ADDRSZ -#define IN6ADDRSZ 16 -#endif - -#ifndef INT16SZ -#define INT16SZ sizeof(apr_int16_t) -#endif - -#ifndef INADDRSZ -#define INADDRSZ 4 -#endif - -#ifndef __P -#define __P(x) x -#endif - -#if !defined(EAFNOSUPPORT) && defined(WSAEAFNOSUPPORT) -#define EAFNOSUPPORT WSAEAFNOSUPPORT -#endif - -/* - * WARNING: Don't even consider trying to compile this on a system where - * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. - */ - -static int inet_pton4 __P((const char *src, unsigned char *dst)); -#if APR_HAVE_IPV6 -static int inet_pton6 __P((const char *src, unsigned char *dst)); -#endif - -/* int - * inet_pton(af, src, dst) - * convert from presentation format (which usually means ASCII printable) - * to network format (which is usually some kind of binary format). - * return: - * 1 if the address was valid for the specified address family - * 0 if the address wasn't valid (`dst' is untouched in this case) - * -1 if some other error occurred (`dst' is untouched in this case, too) - * author: - * Paul Vixie, 1996. - */ -int -apr_inet_pton(int af, const char *src, void *dst) -{ - switch (af) { - case AF_INET: - return (inet_pton4(src, dst)); -#if APR_HAVE_IPV6 - case AF_INET6: - return (inet_pton6(src, dst)); -#endif - default: - errno = EAFNOSUPPORT; - return (-1); - } - /* NOTREACHED */ -} - -/* int - * inet_pton4(src, dst) - * like inet_aton() but without all the hexadecimal and shorthand. - * return: - * 1 if `src' is a valid dotted quad, else 0. - * notice: - * does not touch `dst' unless it's returning 1. - * author: - * Paul Vixie, 1996. - */ -static int -inet_pton4(const char *src, unsigned char *dst) -{ - static const char digits[] = "0123456789"; - int saw_digit, octets, ch; - unsigned char tmp[INADDRSZ], *tp; - - saw_digit = 0; - octets = 0; - *(tp = tmp) = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - if ((pch = strchr(digits, ch)) != NULL) { - unsigned int new = *tp * 10 + (unsigned int)(pch - digits); - - if (new > 255) - return (0); - *tp = new; - if (! saw_digit) { - if (++octets > 4) - return (0); - saw_digit = 1; - } - } else if (ch == '.' && saw_digit) { - if (octets == 4) - return (0); - *++tp = 0; - saw_digit = 0; - } else - return (0); - } - if (octets < 4) - return (0); - - memcpy(dst, tmp, INADDRSZ); - return (1); -} - -#if APR_HAVE_IPV6 -/* int - * inet_pton6(src, dst) - * convert presentation level address to network order binary form. - * return: - * 1 if `src' is a valid [RFC1884 2.2] address, else 0. - * notice: - * (1) does not touch `dst' unless it's returning 1. - * (2) :: in a full address is silently ignored. - * credit: - * inspired by Mark Andrews. - * author: - * Paul Vixie, 1996. - */ -static int -inet_pton6(const char *src, unsigned char *dst) -{ - static const char xdigits_l[] = "0123456789abcdef", - xdigits_u[] = "0123456789ABCDEF"; - unsigned char tmp[IN6ADDRSZ], *tp, *endp, *colonp; - const char *xdigits, *curtok; - int ch, saw_xdigit; - unsigned int val; - - memset((tp = tmp), '\0', IN6ADDRSZ); - endp = tp + IN6ADDRSZ; - colonp = NULL; - /* Leading :: requires some special handling. */ - if (*src == ':') - if (*++src != ':') - return (0); - curtok = src; - saw_xdigit = 0; - val = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) - pch = strchr((xdigits = xdigits_u), ch); - if (pch != NULL) { - val <<= 4; - val |= (pch - xdigits); - if (val > 0xffff) - return (0); - saw_xdigit = 1; - continue; - } - if (ch == ':') { - curtok = src; - if (!saw_xdigit) { - if (colonp) - return (0); - colonp = tp; - continue; - } - if (tp + INT16SZ > endp) - return (0); - *tp++ = (unsigned char) (val >> 8) & 0xff; - *tp++ = (unsigned char) val & 0xff; - saw_xdigit = 0; - val = 0; - continue; - } - if (ch == '.' && ((tp + INADDRSZ) <= endp) && - inet_pton4(curtok, tp) > 0) { - tp += INADDRSZ; - saw_xdigit = 0; - break; /* '\0' was seen by inet_pton4(). */ - } - return (0); - } - if (saw_xdigit) { - if (tp + INT16SZ > endp) - return (0); - *tp++ = (unsigned char) (val >> 8) & 0xff; - *tp++ = (unsigned char) val & 0xff; - } - if (colonp != NULL) { - /* - * Since some memmove()'s erroneously fail to handle - * overlapping regions, we'll do the shift by hand. - */ - const apr_ssize_t n = tp - colonp; - apr_ssize_t i; - - for (i = 1; i <= n; i++) { - endp[- i] = colonp[n - i]; - colonp[n - i] = 0; - } - tp = endp; - } - if (tp != endp) - return (0); - memcpy(dst, tmp, IN6ADDRSZ); - return (1); -} -#endif diff --git a/libs/apr/network_io/unix/multicast.c b/libs/apr/network_io/unix/multicast.c deleted file mode 100644 index 67ab2457..00000000 --- a/libs/apr/network_io/unix/multicast.c +++ /dev/null @@ -1,310 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_networkio.h" -#include "apr_network_io.h" -#include "apr_support.h" -#include "apr_portable.h" -#include "apr_arch_inherit.h" - -#ifdef HAVE_GETIFADDRS -#include -#include -#endif - -#ifdef HAVE_STRUCT_IPMREQ -static void fill_mip_v4(struct ip_mreq *mip, apr_sockaddr_t *mcast, - apr_sockaddr_t *iface) -{ - mip->imr_multiaddr = mcast->sa.sin.sin_addr; - if (iface == NULL) { - mip->imr_interface.s_addr = INADDR_ANY; - } - else { - mip->imr_interface = iface->sa.sin.sin_addr; - } -} - -/* This function is only interested in AF_INET6 sockets, so a noop - * "return 0" implementation for the !APR_HAVE_IPV6 build is - * sufficient. */ -static unsigned int find_if_index(const apr_sockaddr_t *iface) -{ - unsigned int index = 0; -#if defined(HAVE_GETIFADDRS) && APR_HAVE_IPV6 - struct ifaddrs *ifp, *ifs; - - /** - * TODO: getifaddrs is only portable to *BSD and OS X. Using ioctl - * and SIOCGIFCONF is needed for Linux/Solaris support. - * - * There is a wrapper that takes the messy ioctl interface into - * getifaddrs. The license is acceptable, but, It is a fairly large - * chunk of code. - */ - if (getifaddrs(&ifs) != 0) { - return 0; - } - - for (ifp = ifs; ifp; ifp = ifp->ifa_next) { - if (ifp->ifa_addr != NULL && ifp->ifa_addr->sa_family == AF_INET6) { - if (memcmp(&iface->sa.sin6.sin6_addr, - &ifp->ifa_addr->sa_data[0], - sizeof(iface->sa.sin6.sin6_addr)) == 0) { - index = if_nametoindex(ifp->ifa_name); - break; - } - } - } - - freeifaddrs(ifs); -#endif - return index; -} - -#if APR_HAVE_IPV6 -static void fill_mip_v6(struct ipv6_mreq *mip, const apr_sockaddr_t *mcast, - const apr_sockaddr_t *iface) -{ - memcpy(&mip->ipv6mr_multiaddr, mcast->ipaddr_ptr, - sizeof(mip->ipv6mr_multiaddr)); - - if (iface == NULL) { - mip->ipv6mr_interface = 0; - } - else { - mip->ipv6mr_interface = find_if_index(iface); - } -} - -#endif - -static int sock_is_ipv4(apr_socket_t *sock) -{ - if (sock->local_addr->family == APR_INET) - return 1; - return 0; -} - -#if APR_HAVE_IPV6 -static int sock_is_ipv6(apr_socket_t *sock) -{ - if (sock->local_addr->family == APR_INET6) - return 1; - return 0; -} -#endif - -static apr_status_t do_mcast(int type, apr_socket_t *sock, - apr_sockaddr_t *mcast, apr_sockaddr_t *iface, - apr_sockaddr_t *source) -{ - struct ip_mreq mip4; - apr_status_t rv = APR_SUCCESS; -#if APR_HAVE_IPV6 - struct ipv6_mreq mip6; -#endif -#ifdef GROUP_FILTER_SIZE - struct group_source_req mip; - int ip_proto; -#endif - - if (source != NULL) { -#ifdef GROUP_FILTER_SIZE - if (sock_is_ipv4(sock)) { - ip_proto = IPPROTO_IP; - } -#if APR_HAVE_IPV6 - else if (sock_is_ipv6(sock)) { - ip_proto = IPPROTO_IPV6; - } -#endif - else { - return APR_ENOTIMPL; - } - - if (type == IP_ADD_MEMBERSHIP) - type = MCAST_JOIN_SOURCE_GROUP; - else if (type == IP_DROP_MEMBERSHIP) - type = MCAST_LEAVE_SOURCE_GROUP; - else - return APR_ENOTIMPL; - - mip.gsr_interface = find_if_index(iface); - memcpy(&mip.gsr_group, mcast->ipaddr_ptr, sizeof(mip.gsr_group)); - memcpy(&mip.gsr_source, source->ipaddr_ptr, sizeof(mip.gsr_source)); - - if (setsockopt(sock->socketdes, ip_proto, type, (const void *) &mip, - sizeof(mip)) == -1) { - rv = errno; - } -#else - /* We do not support Source-Specific Multicast. */ - return APR_ENOTIMPL; -#endif - } - else { - if (sock_is_ipv4(sock)) { - - fill_mip_v4(&mip4, mcast, iface); - - if (setsockopt(sock->socketdes, IPPROTO_IP, type, - (const void *) &mip4, sizeof(mip4)) == -1) { - rv = errno; - } - } -#if APR_HAVE_IPV6 && defined(IPV6_JOIN_GROUP) && defined(IPV6_LEAVE_GROUP) - else if (sock_is_ipv6(sock)) { - if (type == IP_ADD_MEMBERSHIP) { - type = IPV6_JOIN_GROUP; - } - else if (type == IP_DROP_MEMBERSHIP) { - type = IPV6_LEAVE_GROUP; - } - else { - return APR_ENOTIMPL; - } - - fill_mip_v6(&mip6, mcast, iface); - - if (setsockopt(sock->socketdes, IPPROTO_IPV6, type, - (const void *) &mip6, sizeof(mip6)) == -1) { - rv = errno; - } - } -#endif - else { - rv = APR_ENOTIMPL; - } - } - return rv; -} - -static apr_status_t do_mcast_opt(int type, apr_socket_t *sock, - apr_byte_t value) -{ - apr_status_t rv = APR_SUCCESS; - - if (sock_is_ipv4(sock)) { - if (setsockopt(sock->socketdes, IPPROTO_IP, type, - (const void *) &value, sizeof(value)) == -1) { - rv = errno; - } - } -#if APR_HAVE_IPV6 - else if (sock_is_ipv6(sock) && type == IP_MULTICAST_LOOP) { - unsigned int loopopt = value; - type = IPV6_MULTICAST_LOOP; - if (setsockopt(sock->socketdes, IPPROTO_IPV6, type, - (const void *) &loopopt, sizeof(loopopt)) == -1) { - rv = errno; - } - } - else if (sock_is_ipv6(sock)) { - if (type == IP_MULTICAST_TTL) { - type = IPV6_MULTICAST_HOPS; - } - else { - return APR_ENOTIMPL; - } - - if (setsockopt(sock->socketdes, IPPROTO_IPV6, type, - &value, sizeof(value)) == -1) { - rv = errno; - } - } -#endif - else { - rv = APR_ENOTIMPL; - } - - return rv; -} -#endif - -APR_DECLARE(apr_status_t) apr_mcast_join(apr_socket_t *sock, - apr_sockaddr_t *join, - apr_sockaddr_t *iface, - apr_sockaddr_t *source) -{ -#if defined(IP_ADD_MEMBERSHIP) && defined(HAVE_STRUCT_IPMREQ) - return do_mcast(IP_ADD_MEMBERSHIP, sock, join, iface, source); -#else - return APR_ENOTIMPL; -#endif -} - -APR_DECLARE(apr_status_t) apr_mcast_leave(apr_socket_t *sock, - apr_sockaddr_t *addr, - apr_sockaddr_t *iface, - apr_sockaddr_t *source) -{ -#if defined(IP_DROP_MEMBERSHIP) && defined(HAVE_STRUCT_IPMREQ) - return do_mcast(IP_DROP_MEMBERSHIP, sock, addr, iface, source); -#else - return APR_ENOTIMPL; -#endif -} - -APR_DECLARE(apr_status_t) apr_mcast_hops(apr_socket_t *sock, apr_byte_t ttl) -{ -#if defined(IP_MULTICAST_TTL) && defined(HAVE_STRUCT_IPMREQ) - return do_mcast_opt(IP_MULTICAST_TTL, sock, ttl); -#else - return APR_ENOTIMPL; -#endif -} - -APR_DECLARE(apr_status_t) apr_mcast_loopback(apr_socket_t *sock, - apr_byte_t opt) -{ -#if defined(IP_MULTICAST_LOOP) && defined(HAVE_STRUCT_IPMREQ) - return do_mcast_opt(IP_MULTICAST_LOOP, sock, opt); -#else - return APR_ENOTIMPL; -#endif -} - -APR_DECLARE(apr_status_t) apr_mcast_interface(apr_socket_t *sock, - apr_sockaddr_t *iface) -{ -#if defined(IP_MULTICAST_IF) && defined(HAVE_STRUCT_IPMREQ) - apr_status_t rv = APR_SUCCESS; - - if (sock_is_ipv4(sock)) { - if (setsockopt(sock->socketdes, IPPROTO_IP, IP_MULTICAST_IF, - (const void *) &iface->sa.sin.sin_addr, - sizeof(iface->sa.sin.sin_addr)) == -1) { - rv = errno; - } - } -#if APR_HAVE_IPV6 - else if (sock_is_ipv6(sock)) { - unsigned int idx = find_if_index(iface); - if (setsockopt(sock->socketdes, IPPROTO_IPV6, IPV6_MULTICAST_IF, - (const void *) &idx, sizeof(idx)) == -1) { - rv = errno; - } - } -#endif - else { - rv = APR_ENOTIMPL; - } - return rv; -#else - return APR_ENOTIMPL; -#endif -} diff --git a/libs/apr/network_io/unix/sendrecv.c b/libs/apr/network_io/unix/sendrecv.c deleted file mode 100644 index c133a26d..00000000 --- a/libs/apr/network_io/unix/sendrecv.c +++ /dev/null @@ -1,1106 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_networkio.h" -#include "apr_support.h" - -#if APR_HAS_SENDFILE -/* This file is needed to allow us access to the apr_file_t internals. */ -#include "apr_arch_file_io.h" -#endif /* APR_HAS_SENDFILE */ - -/* osreldate.h is only needed on FreeBSD for sendfile detection */ -#if defined(__FreeBSD__) -#include -#endif - -apr_status_t apr_socket_send(apr_socket_t *sock, const char *buf, - apr_size_t *len) -{ - apr_ssize_t rv; - - if (sock->options & APR_INCOMPLETE_WRITE) { - sock->options &= ~APR_INCOMPLETE_WRITE; - goto do_select; - } - - do { - rv = write(sock->socketdes, buf, (*len)); - } while (rv == -1 && errno == EINTR); - - while (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) - && (sock->timeout > 0)) { - apr_status_t arv; -do_select: - arv = apr_wait_for_io_or_timeout(NULL, sock, 0); - if (arv != APR_SUCCESS) { - *len = 0; - return arv; - } - else { - do { - rv = write(sock->socketdes, buf, (*len)); - } while (rv == -1 && errno == EINTR); - } - } - if (rv == -1) { - *len = 0; - return errno; - } - if ((sock->timeout > 0) && (rv < *len)) { - sock->options |= APR_INCOMPLETE_WRITE; - } - (*len) = rv; - return APR_SUCCESS; -} - -apr_status_t apr_socket_recv(apr_socket_t *sock, char *buf, apr_size_t *len) -{ - apr_ssize_t rv; - apr_status_t arv; - - if (sock->options & APR_INCOMPLETE_READ) { - sock->options &= ~APR_INCOMPLETE_READ; - goto do_select; - } - - do { - rv = read(sock->socketdes, buf, (*len)); - } while (rv == -1 && errno == EINTR); - - while ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK) - && (sock->timeout > 0)) { -do_select: - arv = apr_wait_for_io_or_timeout(NULL, sock, 1); - if (arv != APR_SUCCESS) { - *len = 0; - return arv; - } - else { - do { - rv = read(sock->socketdes, buf, (*len)); - } while (rv == -1 && errno == EINTR); - } - } - if (rv == -1) { - (*len) = 0; - return errno; - } - if ((sock->timeout > 0) && (rv < *len)) { - sock->options |= APR_INCOMPLETE_READ; - } - (*len) = rv; - if (rv == 0) { - return APR_EOF; - } - return APR_SUCCESS; -} - -apr_status_t apr_socket_sendto(apr_socket_t *sock, apr_sockaddr_t *where, - apr_int32_t flags, const char *buf, - apr_size_t *len) -{ - apr_ssize_t rv; - - do { - rv = sendto(sock->socketdes, buf, (*len), flags, - (const struct sockaddr*)&where->sa, - where->salen); - } while (rv == -1 && errno == EINTR); - - while ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK) - && (sock->timeout > 0)) { - apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0); - if (arv != APR_SUCCESS) { - *len = 0; - return arv; - } else { - do { - rv = sendto(sock->socketdes, buf, (*len), flags, - (const struct sockaddr*)&where->sa, - where->salen); - } while (rv == -1 && errno == EINTR); - } - } - if (rv == -1) { - *len = 0; - return errno; - } - *len = rv; - return APR_SUCCESS; -} - -apr_status_t apr_socket_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock, - apr_int32_t flags, char *buf, - apr_size_t *len) -{ - apr_ssize_t rv; - - from->salen = sizeof(from->sa); - - do { - rv = recvfrom(sock->socketdes, buf, (*len), flags, - (struct sockaddr*)&from->sa, &from->salen); - } while (rv == -1 && errno == EINTR); - - while ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK) - && (sock->timeout > 0)) { - apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 1); - if (arv != APR_SUCCESS) { - *len = 0; - return arv; - } else { - do { - rv = recvfrom(sock->socketdes, buf, (*len), flags, - (struct sockaddr*)&from->sa, &from->salen); - } while (rv == -1 && errno == EINTR); - } - } - if (rv == -1) { - (*len) = 0; - return errno; - } - - apr_sockaddr_vars_set(from, from->sa.sin.sin_family, ntohs(from->sa.sin.sin_port)); - - (*len) = rv; - if (rv == 0 && sock->type == SOCK_STREAM) { - return APR_EOF; - } - - return APR_SUCCESS; -} - -apr_status_t apr_socket_sendv(apr_socket_t * sock, const struct iovec *vec, - apr_int32_t nvec, apr_size_t *len) -{ -#ifdef HAVE_WRITEV - apr_ssize_t rv; - apr_size_t requested_len = 0; - apr_int32_t i; - - for (i = 0; i < nvec; i++) { - requested_len += vec[i].iov_len; - } - - if (sock->options & APR_INCOMPLETE_WRITE) { - sock->options &= ~APR_INCOMPLETE_WRITE; - goto do_select; - } - - do { - rv = writev(sock->socketdes, vec, nvec); - } while (rv == -1 && errno == EINTR); - - while ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK) - && (sock->timeout > 0)) { - apr_status_t arv; -do_select: - arv = apr_wait_for_io_or_timeout(NULL, sock, 0); - if (arv != APR_SUCCESS) { - *len = 0; - return arv; - } - else { - do { - rv = writev(sock->socketdes, vec, nvec); - } while (rv == -1 && errno == EINTR); - } - } - if (rv == -1) { - *len = 0; - return errno; - } - if ((sock->timeout > 0) && (rv < requested_len)) { - sock->options |= APR_INCOMPLETE_WRITE; - } - (*len) = rv; - return APR_SUCCESS; -#else - *len = vec[0].iov_len; - return apr_socket_send(sock, vec[0].iov_base, len); -#endif -} - -#if APR_HAS_SENDFILE - -/* TODO: Verify that all platforms handle the fd the same way, - * i.e. that they don't move the file pointer. - */ -/* TODO: what should flags be? int_32? */ - -/* Define a structure to pass in when we have a NULL header value */ -static apr_hdtr_t no_hdtr; - -#if defined(__linux__) && defined(HAVE_WRITEV) - -apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file, - apr_hdtr_t *hdtr, apr_off_t *offset, - apr_size_t *len, apr_int32_t flags) -{ - int rv, nbytes = 0, total_hdrbytes, i; - apr_status_t arv; - -#if APR_HAS_LARGE_FILES && defined(HAVE_SENDFILE64) - apr_off_t off = *offset; -#define sendfile sendfile64 - -#elif APR_HAS_LARGE_FILES && SIZEOF_OFF_T == 4 - /* 64-bit apr_off_t but no sendfile64(): fail if trying to send - * past the 2Gb limit. */ - off_t off; - - if ((apr_int64_t)*offset + *len > INT_MAX) { - return EINVAL; - } - - off = *offset; - -#else - off_t off = *offset; - - /* Multiple reports have shown sendfile failing with EINVAL if - * passed a >=2Gb count value on some 64-bit kernels. It won't - * noticably hurt performance to limit each call to <2Gb at a - * time, so avoid that issue here: */ - if (sizeof(off_t) == 8 && *len > INT_MAX) { - *len = INT_MAX; - } -#endif - - if (!hdtr) { - hdtr = &no_hdtr; - } - - /* Ignore flags for now. */ - flags = 0; - - if (hdtr->numheaders > 0) { - apr_size_t hdrbytes; - - /* cork before writing headers */ - rv = apr_socket_opt_set(sock, APR_TCP_NOPUSH, 1); - if (rv != APR_SUCCESS) { - return rv; - } - - /* Now write the headers */ - arv = apr_socket_sendv(sock, hdtr->headers, hdtr->numheaders, - &hdrbytes); - if (arv != APR_SUCCESS) { - *len = 0; - return errno; - } - nbytes += hdrbytes; - - /* If this was a partial write and we aren't doing timeouts, - * return now with the partial byte count; this is a non-blocking - * socket. - */ - total_hdrbytes = 0; - for (i = 0; i < hdtr->numheaders; i++) { - total_hdrbytes += hdtr->headers[i].iov_len; - } - if (hdrbytes < total_hdrbytes) { - *len = hdrbytes; - return apr_socket_opt_set(sock, APR_TCP_NOPUSH, 0); - } - } - - if (sock->options & APR_INCOMPLETE_WRITE) { - sock->options &= ~APR_INCOMPLETE_WRITE; - goto do_select; - } - - do { - rv = sendfile(sock->socketdes, /* socket */ - file->filedes, /* open file descriptor of the file to be sent */ - &off, /* where in the file to start */ - *len); /* number of bytes to send */ - } while (rv == -1 && errno == EINTR); - - while ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK) - && (sock->timeout > 0)) { -do_select: - arv = apr_wait_for_io_or_timeout(NULL, sock, 0); - if (arv != APR_SUCCESS) { - *len = 0; - return arv; - } - else { - do { - rv = sendfile(sock->socketdes, /* socket */ - file->filedes, /* open file descriptor of the file to be sent */ - &off, /* where in the file to start */ - *len); /* number of bytes to send */ - } while (rv == -1 && errno == EINTR); - } - } - - if (rv == -1) { - *len = nbytes; - rv = errno; - apr_socket_opt_set(sock, APR_TCP_NOPUSH, 0); - return rv; - } - - nbytes += rv; - - if (rv < *len) { - *len = nbytes; - arv = apr_socket_opt_set(sock, APR_TCP_NOPUSH, 0); - if (rv > 0) { - - /* If this was a partial write, return now with the - * partial byte count; this is a non-blocking socket. - */ - - if (sock->timeout > 0) { - sock->options |= APR_INCOMPLETE_WRITE; - } - return arv; - } - else { - /* If the file got smaller mid-request, eventually the offset - * becomes equal to the new file size and the kernel returns 0. - * Make this an error so the caller knows to log something and - * exit. - */ - return APR_EOF; - } - } - - /* Now write the footers */ - if (hdtr->numtrailers > 0) { - apr_size_t trbytes; - arv = apr_socket_sendv(sock, hdtr->trailers, hdtr->numtrailers, - &trbytes); - nbytes += trbytes; - if (arv != APR_SUCCESS) { - *len = nbytes; - rv = errno; - apr_socket_opt_set(sock, APR_TCP_NOPUSH, 0); - return rv; - } - } - - apr_socket_opt_set(sock, APR_TCP_NOPUSH, 0); - - (*len) = nbytes; - return rv < 0 ? errno : APR_SUCCESS; -} - -#elif defined(DARWIN) - -/* OS/X Release 10.5 or greater */ -apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file, - apr_hdtr_t *hdtr, apr_off_t *offset, - apr_size_t *len, apr_int32_t flags) -{ - apr_off_t nbytes = 0; - apr_off_t bytes_to_send = *len; - apr_off_t bytes_sent = 0; - apr_status_t arv; - int rv = 0; - - /* Ignore flags for now. */ - flags = 0; - - if (!hdtr) { - hdtr = &no_hdtr; - } - - /* OS X can send the headers/footers as part of the system call, - * but how it counts bytes isn't documented properly. We use - * apr_socket_sendv() instead. - */ - if (hdtr->numheaders > 0) { - apr_size_t hbytes; - int i; - - /* Now write the headers */ - arv = apr_socket_sendv(sock, hdtr->headers, hdtr->numheaders, - &hbytes); - if (arv != APR_SUCCESS) { - *len = 0; - return errno; - } - bytes_sent = hbytes; - - hbytes = 0; - for (i = 0; i < hdtr->numheaders; i++) { - hbytes += hdtr->headers[i].iov_len; - } - if (bytes_sent < hbytes) { - *len = bytes_sent; - return APR_SUCCESS; - } - } - - do { - if (!bytes_to_send) { - break; - } - if (sock->options & APR_INCOMPLETE_WRITE) { - apr_status_t arv; - sock->options &= ~APR_INCOMPLETE_WRITE; - arv = apr_wait_for_io_or_timeout(NULL, sock, 0); - if (arv != APR_SUCCESS) { - *len = 0; - return arv; - } - } - - nbytes = bytes_to_send; - rv = sendfile(file->filedes, /* file to be sent */ - sock->socketdes, /* socket */ - *offset, /* where in the file to start */ - &nbytes, /* number of bytes to write/written */ - NULL, /* Headers/footers */ - flags); /* undefined, set to 0 */ - - if (rv == -1) { - if (errno == EAGAIN) { - if (sock->timeout > 0) { - sock->options |= APR_INCOMPLETE_WRITE; - } - /* BSD's sendfile can return -1/EAGAIN even if it - * sent bytes. Sanitize the result so we get normal EAGAIN - * semantics w.r.t. bytes sent. - */ - if (nbytes) { - bytes_sent += nbytes; - /* normal exit for a big file & non-blocking io */ - (*len) = bytes_sent; - return APR_SUCCESS; - } - } - } - else { /* rv == 0 (or the kernel is broken) */ - bytes_sent += nbytes; - if (nbytes == 0) { - /* Most likely the file got smaller after the stat. - * Return an error so the caller can do the Right Thing. - */ - (*len) = bytes_sent; - return APR_EOF; - } - } - } while (rv == -1 && (errno == EINTR || errno == EAGAIN)); - - /* Now write the footers */ - if (hdtr->numtrailers > 0) { - apr_size_t tbytes; - arv = apr_socket_sendv(sock, hdtr->trailers, hdtr->numtrailers, - &tbytes); - bytes_sent += tbytes; - if (arv != APR_SUCCESS) { - *len = bytes_sent; - rv = errno; - return rv; - } - } - - (*len) = bytes_sent; - if (rv == -1) { - return errno; - } - return APR_SUCCESS; -} - -#elif defined(__FreeBSD__) || defined(__DragonFly__) - -/* Release 3.1 or greater */ -apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file, - apr_hdtr_t * hdtr, apr_off_t * offset, - apr_size_t * len, apr_int32_t flags) -{ - off_t nbytes = 0; - int rv; -#if defined(__FreeBSD_version) && __FreeBSD_version < 460001 - int i; -#endif - struct sf_hdtr headerstruct; - apr_size_t bytes_to_send = *len; - - /* Ignore flags for now. */ - flags = 0; - - if (!hdtr) { - hdtr = &no_hdtr; - } - -#if defined(__FreeBSD_version) && __FreeBSD_version < 460001 - else if (hdtr->numheaders) { - - /* On early versions of FreeBSD sendfile, the number of bytes to send - * must include the length of the headers. Don't look at the man page - * for this :( Instead, look at the the logic in - * src/sys/kern/uipc_syscalls::sendfile(). - * - * This was fixed in the middle of 4.6-STABLE - */ - for (i = 0; i < hdtr->numheaders; i++) { - bytes_to_send += hdtr->headers[i].iov_len; - } - } -#endif - - headerstruct.headers = hdtr->headers; - headerstruct.hdr_cnt = hdtr->numheaders; - headerstruct.trailers = hdtr->trailers; - headerstruct.trl_cnt = hdtr->numtrailers; - - /* FreeBSD can send the headers/footers as part of the system call */ - do { - if (sock->options & APR_INCOMPLETE_WRITE) { - apr_status_t arv; - sock->options &= ~APR_INCOMPLETE_WRITE; - arv = apr_wait_for_io_or_timeout(NULL, sock, 0); - if (arv != APR_SUCCESS) { - *len = 0; - return arv; - } - } - if (bytes_to_send) { - /* We won't dare call sendfile() if we don't have - * header or file bytes to send because bytes_to_send == 0 - * means send the whole file. - */ - rv = sendfile(file->filedes, /* file to be sent */ - sock->socketdes, /* socket */ - *offset, /* where in the file to start */ - bytes_to_send, /* number of bytes to send */ - &headerstruct, /* Headers/footers */ - &nbytes, /* number of bytes written */ - flags); /* undefined, set to 0 */ - - if (rv == -1) { - if (errno == EAGAIN) { - if (sock->timeout > 0) { - sock->options |= APR_INCOMPLETE_WRITE; - } - /* FreeBSD's sendfile can return -1/EAGAIN even if it - * sent bytes. Sanitize the result so we get normal EAGAIN - * semantics w.r.t. bytes sent. - */ - if (nbytes) { - /* normal exit for a big file & non-blocking io */ - (*len) = nbytes; - return APR_SUCCESS; - } - } - } - else { /* rv == 0 (or the kernel is broken) */ - if (nbytes == 0) { - /* Most likely the file got smaller after the stat. - * Return an error so the caller can do the Right Thing. - */ - (*len) = nbytes; - return APR_EOF; - } - } - } - else { - /* just trailer bytes... use writev() - */ - rv = writev(sock->socketdes, - hdtr->trailers, - hdtr->numtrailers); - if (rv > 0) { - nbytes = rv; - rv = 0; - } - else { - nbytes = 0; - } - } - if ((rv == -1) && (errno == EAGAIN) - && (sock->timeout > 0)) { - apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0); - if (arv != APR_SUCCESS) { - *len = 0; - return arv; - } - } - } while (rv == -1 && (errno == EINTR || errno == EAGAIN)); - - (*len) = nbytes; - if (rv == -1) { - return errno; - } - return APR_SUCCESS; -} - -#elif defined(__hpux) || defined(__hpux__) - -/* HP cc in ANSI mode defines __hpux; gcc defines __hpux__ */ - -/* HP-UX Version 10.30 or greater - * (no worries, because we only get here if autoconfiguration found sendfile) - */ - -/* ssize_t sendfile(int s, int fd, off_t offset, size_t nbytes, - * const struct iovec *hdtrl, int flags); - * - * nbytes is the number of bytes to send just from the file; as with FreeBSD, - * if nbytes == 0, the rest of the file (from offset) is sent - */ - -apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file, - apr_hdtr_t *hdtr, apr_off_t *offset, - apr_size_t *len, apr_int32_t flags) -{ - int i; - apr_ssize_t rc; - apr_size_t nbytes = *len, headerlen, trailerlen; - struct iovec hdtrarray[2]; - char *headerbuf, *trailerbuf; - -#if APR_HAS_LARGE_FILES && defined(HAVE_SENDFILE64) - /* later HP-UXes have a sendfile64() */ -#define sendfile sendfile64 - apr_off_t off = *offset; - -#elif APR_HAS_LARGE_FILES && SIZEOF_OFF_T == 4 - /* HP-UX 11.00 doesn't have a sendfile64(): fail if trying to send - * past the 2Gb limit */ - off_t off; - - if ((apr_int64_t)*offset + *len > INT_MAX) { - return EINVAL; - } - off = *offset; -#else - apr_off_t off = *offset; -#endif - - if (!hdtr) { - hdtr = &no_hdtr; - } - - /* Ignore flags for now. */ - flags = 0; - - /* HP-UX can only send one header iovec and one footer iovec; try to - * only allocate storage to combine input iovecs when we really have to - */ - - switch(hdtr->numheaders) { - case 0: - hdtrarray[0].iov_base = NULL; - hdtrarray[0].iov_len = 0; - break; - case 1: - hdtrarray[0] = hdtr->headers[0]; - break; - default: - headerlen = 0; - for (i = 0; i < hdtr->numheaders; i++) { - headerlen += hdtr->headers[i].iov_len; - } - - /* XXX: BUHHH? wow, what a memory leak! */ - headerbuf = hdtrarray[0].iov_base = apr_palloc(sock->pool, headerlen); - hdtrarray[0].iov_len = headerlen; - - for (i = 0; i < hdtr->numheaders; i++) { - memcpy(headerbuf, hdtr->headers[i].iov_base, - hdtr->headers[i].iov_len); - headerbuf += hdtr->headers[i].iov_len; - } - } - - switch(hdtr->numtrailers) { - case 0: - hdtrarray[1].iov_base = NULL; - hdtrarray[1].iov_len = 0; - break; - case 1: - hdtrarray[1] = hdtr->trailers[0]; - break; - default: - trailerlen = 0; - for (i = 0; i < hdtr->numtrailers; i++) { - trailerlen += hdtr->trailers[i].iov_len; - } - - /* XXX: BUHHH? wow, what a memory leak! */ - trailerbuf = hdtrarray[1].iov_base = apr_palloc(sock->pool, trailerlen); - hdtrarray[1].iov_len = trailerlen; - - for (i = 0; i < hdtr->numtrailers; i++) { - memcpy(trailerbuf, hdtr->trailers[i].iov_base, - hdtr->trailers[i].iov_len); - trailerbuf += hdtr->trailers[i].iov_len; - } - } - - do { - if (nbytes) { /* any bytes to send from the file? */ - rc = sendfile(sock->socketdes, /* socket */ - file->filedes, /* file descriptor to send */ - off, /* where in the file to start */ - nbytes, /* number of bytes to send from file */ - hdtrarray, /* Headers/footers */ - flags); /* undefined, set to 0 */ - } - else { /* we can't call sendfile() with no bytes to send from the file */ - rc = writev(sock->socketdes, hdtrarray, 2); - } - } while (rc == -1 && errno == EINTR); - - while ((rc == -1) && (errno == EAGAIN || errno == EWOULDBLOCK) - && (sock->timeout > 0)) { - apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0); - - if (arv != APR_SUCCESS) { - *len = 0; - return arv; - } - else { - do { - if (nbytes) { - rc = sendfile(sock->socketdes, /* socket */ - file->filedes, /* file descriptor to send */ - off, /* where in the file to start */ - nbytes, /* number of bytes to send from file */ - hdtrarray, /* Headers/footers */ - flags); /* undefined, set to 0 */ - } - else { /* we can't call sendfile() with no bytes to send from the file */ - rc = writev(sock->socketdes, hdtrarray, 2); - } - } while (rc == -1 && errno == EINTR); - } - } - - if (rc == -1) { - *len = 0; - return errno; - } - - /* Set len to the number of bytes written */ - *len = rc; - return APR_SUCCESS; -} -#elif defined(_AIX) || defined(__MVS__) -/* AIX and OS/390 have the same send_file() interface. - * - * subtle differences: - * AIX doesn't update the file ptr but OS/390 does - * - * availability (correctly determined by autoconf): - * - * AIX - version 4.3.2 with APAR IX85388, or version 4.3.3 and above - * OS/390 - V2R7 and above - */ -apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file, - apr_hdtr_t * hdtr, apr_off_t * offset, - apr_size_t * len, apr_int32_t flags) -{ - int i, ptr, rv = 0; - void * hbuf=NULL, * tbuf=NULL; - apr_status_t arv; - struct sf_parms parms; - - if (!hdtr) { - hdtr = &no_hdtr; - } - - /* Ignore flags for now. */ - flags = 0; - - /* word to the wise: by default, AIX stores files sent by send_file() - * in the network buffer cache... there are supposedly scenarios - * where the most recent copy of the file won't be sent, but I can't - * recreate the potential problem, perhaps because of the way we - * use send_file()... if you suspect such a problem, try turning - * on the SF_SYNC_CACHE flag - */ - - /* AIX can also send the headers/footers as part of the system call */ - parms.header_length = 0; - if (hdtr && hdtr->numheaders) { - if (hdtr->numheaders == 1) { - parms.header_data = hdtr->headers[0].iov_base; - parms.header_length = hdtr->headers[0].iov_len; - } - else { - for (i = 0; i < hdtr->numheaders; i++) { - parms.header_length += hdtr->headers[i].iov_len; - } -#if 0 - /* Keepalives make apr_palloc a bad idea */ - hbuf = malloc(parms.header_length); -#else - /* but headers are small, so maybe we can hold on to the - * memory for the life of the socket... - */ - hbuf = apr_palloc(sock->pool, parms.header_length); -#endif - ptr = 0; - for (i = 0; i < hdtr->numheaders; i++) { - memcpy((char *)hbuf + ptr, hdtr->headers[i].iov_base, - hdtr->headers[i].iov_len); - ptr += hdtr->headers[i].iov_len; - } - parms.header_data = hbuf; - } - } - else parms.header_data = NULL; - parms.trailer_length = 0; - if (hdtr && hdtr->numtrailers) { - if (hdtr->numtrailers == 1) { - parms.trailer_data = hdtr->trailers[0].iov_base; - parms.trailer_length = hdtr->trailers[0].iov_len; - } - else { - for (i = 0; i < hdtr->numtrailers; i++) { - parms.trailer_length += hdtr->trailers[i].iov_len; - } -#if 0 - /* Keepalives make apr_palloc a bad idea */ - tbuf = malloc(parms.trailer_length); -#else - tbuf = apr_palloc(sock->pool, parms.trailer_length); -#endif - ptr = 0; - for (i = 0; i < hdtr->numtrailers; i++) { - memcpy((char *)tbuf + ptr, hdtr->trailers[i].iov_base, - hdtr->trailers[i].iov_len); - ptr += hdtr->trailers[i].iov_len; - } - parms.trailer_data = tbuf; - } - } - else { - parms.trailer_data = NULL; - } - - /* Whew! Headers and trailers set up. Now for the file data */ - - parms.file_descriptor = file->filedes; - parms.file_offset = *offset; - parms.file_bytes = *len; - - /* O.K. All set up now. Let's go to town */ - - if (sock->options & APR_INCOMPLETE_WRITE) { - sock->options &= ~APR_INCOMPLETE_WRITE; - goto do_select; - } - - do { - rv = send_file(&(sock->socketdes), /* socket */ - &(parms), /* all data */ - flags); /* flags */ - } while (rv == -1 && errno == EINTR); - - while ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK) - && (sock->timeout > 0)) { -do_select: - arv = apr_wait_for_io_or_timeout(NULL, sock, 0); - if (arv != APR_SUCCESS) { - *len = 0; - return arv; - } - else { - do { - rv = send_file(&(sock->socketdes), /* socket */ - &(parms), /* all data */ - flags); /* flags */ - } while (rv == -1 && errno == EINTR); - } - } - - (*len) = parms.bytes_sent; - -#if 0 - /* Clean up after ourselves */ - if(hbuf) free(hbuf); - if(tbuf) free(tbuf); -#endif - - if (rv == -1) { - return errno; - } - - if ((sock->timeout > 0) - && (parms.bytes_sent - < (parms.file_bytes + parms.header_length + parms.trailer_length))) { - sock->options |= APR_INCOMPLETE_WRITE; - } - - return APR_SUCCESS; -} -#elif defined(__osf__) && defined (__alpha) -/* Tru64's sendfile implementation doesn't work, and we need to make sure that - * we don't use it until it is fixed. If it is used as it is now, it will - * hang the machine and the only way to fix it is a reboot. - */ -#elif defined(HAVE_SENDFILEV) -/* Solaris 8's sendfilev() interface - * - * SFV_FD_SELF refers to our memory space. - * - * Required Sparc patches (or newer): - * 111297-01, 108528-09, 109472-06, 109234-03, 108995-02, 111295-01, 109025-03, - * 108991-13 - * Required x86 patches (or newer): - * 111298-01, 108529-09, 109473-06, 109235-04, 108996-02, 111296-01, 109026-04, - * 108992-13 - */ - -#if APR_HAS_LARGE_FILES && defined(HAVE_SENDFILEV64) -#define sendfilevec_t sendfilevec64_t -#define sendfilev sendfilev64 -#endif - -apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file, - apr_hdtr_t *hdtr, apr_off_t *offset, - apr_size_t *len, apr_int32_t flags) -{ - apr_status_t rv, arv; - apr_size_t nbytes; - sendfilevec_t *sfv; - int vecs, curvec, i, repeat; - apr_size_t requested_len = 0; - - if (!hdtr) { - hdtr = &no_hdtr; - } - - /* Ignore flags for now. */ - flags = 0; - - /* Calculate how much space we need. */ - vecs = hdtr->numheaders + hdtr->numtrailers + 1; - sfv = apr_palloc(sock->pool, sizeof(sendfilevec_t) * vecs); - - curvec = 0; - - /* Add the headers */ - for (i = 0; i < hdtr->numheaders; i++, curvec++) { - sfv[curvec].sfv_fd = SFV_FD_SELF; - sfv[curvec].sfv_flag = 0; - /* Cast to unsigned long to prevent sign extension of the - * pointer value for the LFS case; see PR 39463. */ - sfv[curvec].sfv_off = (unsigned long)hdtr->headers[i].iov_base; - sfv[curvec].sfv_len = hdtr->headers[i].iov_len; - requested_len += sfv[curvec].sfv_len; - } - - /* If the len is 0, we skip the file. */ - if (*len) - { - sfv[curvec].sfv_fd = file->filedes; - sfv[curvec].sfv_flag = 0; - sfv[curvec].sfv_off = *offset; - sfv[curvec].sfv_len = *len; - requested_len += sfv[curvec].sfv_len; - - curvec++; - } - else { - vecs--; - } - - /* Add the footers */ - for (i = 0; i < hdtr->numtrailers; i++, curvec++) { - sfv[curvec].sfv_fd = SFV_FD_SELF; - sfv[curvec].sfv_flag = 0; - sfv[curvec].sfv_off = (unsigned long)hdtr->trailers[i].iov_base; - sfv[curvec].sfv_len = hdtr->trailers[i].iov_len; - requested_len += sfv[curvec].sfv_len; - } - - /* If the last write couldn't send all the requested data, - * wait for the socket to become writable before proceeding - */ - if (sock->options & APR_INCOMPLETE_WRITE) { - sock->options &= ~APR_INCOMPLETE_WRITE; - arv = apr_wait_for_io_or_timeout(NULL, sock, 0); - if (arv != APR_SUCCESS) { - *len = 0; - return arv; - } - } - - /* Actually do the sendfilev - * - * Solaris may return -1/EAGAIN even if it sent bytes on a non-block sock. - * - * If no bytes were originally sent (nbytes == 0) and we are on a TIMEOUT - * socket (which as far as the OS is concerned is a non-blocking socket), - * we want to retry after waiting for the other side to read the data (as - * determined by poll). Once it is clear to send, we want to retry - * sending the sendfilevec_t once more. - */ - arv = 0; - do { - /* Clear out the repeat */ - repeat = 0; - - /* socket, vecs, number of vecs, bytes written */ - rv = sendfilev(sock->socketdes, sfv, vecs, &nbytes); - - if (rv == -1 && errno == EAGAIN) { - if (nbytes) { - rv = 0; - } - else if (!arv && (sock->timeout > 0)) { - apr_status_t t = apr_wait_for_io_or_timeout(NULL, sock, 0); - - if (t != APR_SUCCESS) { - *len = 0; - return t; - } - - arv = 1; - repeat = 1; - } - } - } while ((rv == -1 && errno == EINTR) || repeat); - - if (rv == -1) { - *len = 0; - return errno; - } - - /* Update how much we sent */ - *len = nbytes; - - if (nbytes == 0) { - /* Most likely the file got smaller after the stat. - * Return an error so the caller can do the Right Thing. - */ - return APR_EOF; - } - - if ((sock->timeout > 0) && (*len < requested_len)) { - sock->options |= APR_INCOMPLETE_WRITE; - } - return APR_SUCCESS; -} -#else -#error APR has detected sendfile on your system, but nobody has written a -#error version of it for APR yet. To get past this, either write -#error apr_socket_sendfile or change APR_HAS_SENDFILE in apr.h to 0. -#endif /* __linux__, __FreeBSD__, __DragonFly__, __HPUX__, _AIX, __MVS__, - Tru64/OSF1 */ - -#endif /* APR_HAS_SENDFILE */ diff --git a/libs/apr/network_io/unix/sockaddr.c b/libs/apr/network_io/unix/sockaddr.c deleted file mode 100644 index ed4c474d..00000000 --- a/libs/apr/network_io/unix/sockaddr.c +++ /dev/null @@ -1,1041 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_networkio.h" -#include "apr_strings.h" -#include "apr.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_private.h" - -#if APR_HAVE_STDLIB_H -#include -#endif - -#define APR_WANT_STRFUNC -#include "apr_want.h" - -struct apr_ipsubnet_t { - int family; -#if APR_HAVE_IPV6 - apr_uint32_t sub[4]; /* big enough for IPv4 and IPv6 addresses */ - apr_uint32_t mask[4]; -#else - apr_uint32_t sub[1]; - apr_uint32_t mask[1]; -#endif -}; - -#if !defined(NETWARE) && !defined(WIN32) -#ifdef HAVE_SET_H_ERRNO -#define SET_H_ERRNO(newval) set_h_errno(newval) -#else -#define SET_H_ERRNO(newval) h_errno = (newval) -#endif -#else -#define SET_H_ERRNO(newval) -#endif - -#if APR_HAS_THREADS && !defined(GETHOSTBYNAME_IS_THREAD_SAFE) && \ - defined(HAVE_GETHOSTBYNAME_R) -/* This is the maximum size that may be returned from the reentrant - * gethostbyname_r function. If the system tries to use more, it - * should return ERANGE. - */ -#define GETHOSTBYNAME_BUFLEN 512 -#endif - -#ifdef _AIX -/* Some levels of AIX getaddrinfo() don't like servname = "0", so - * set servname to "1" when port is 0 and fix it up later. - */ -#define AIX_SERVNAME_HACK 1 -#else -#define AIX_SERVNAME_HACK 0 -#endif - -#ifdef _WIN32_WCE -/* XXX: BS solution. Need an HAVE_GETSERVBYNAME and actually - * do something here, to provide the obvious proto mappings. - */ -static void *getservbyname(const char *name, const char *proto) -{ - return NULL; -} -#endif - -static apr_status_t get_local_addr(apr_socket_t *sock) -{ - sock->local_addr->salen = sizeof(sock->local_addr->sa); - if (getsockname(sock->socketdes, (struct sockaddr *)&sock->local_addr->sa, - &sock->local_addr->salen) < 0) { - return apr_get_netos_error(); - } - else { - sock->local_port_unknown = sock->local_interface_unknown = 0; - /* XXX assumes sin_port and sin6_port at same offset */ - sock->local_addr->port = ntohs(sock->local_addr->sa.sin.sin_port); - return APR_SUCCESS; - } -} - -static apr_status_t get_remote_addr(apr_socket_t *sock) -{ - sock->remote_addr->salen = sizeof(sock->remote_addr->sa); - if (getpeername(sock->socketdes, (struct sockaddr *)&sock->remote_addr->sa, - &sock->remote_addr->salen) < 0) { - return apr_get_netos_error(); - } - else { - sock->remote_addr_unknown = 0; - /* XXX assumes sin_port and sin6_port at same offset */ - sock->remote_addr->port = ntohs(sock->remote_addr->sa.sin.sin_port); - return APR_SUCCESS; - } -} - -APR_DECLARE(apr_status_t) apr_sockaddr_ip_getbuf(char *buf, apr_size_t buflen, - apr_sockaddr_t *sockaddr) -{ - if (!apr_inet_ntop(sockaddr->family, sockaddr->ipaddr_ptr, buf, buflen)) { - return APR_ENOSPC; - } - -#if APR_HAVE_IPV6 - if (sockaddr->family == AF_INET6 - && IN6_IS_ADDR_V4MAPPED((struct in6_addr *)sockaddr->ipaddr_ptr) - && buflen > strlen("::ffff:")) { - /* This is an IPv4-mapped IPv6 address; drop the leading - * part of the address string so we're left with the familiar - * IPv4 format. - */ - memmove(buf, buf + strlen("::ffff:"), - strlen(buf + strlen("::ffff:"))+1); - } -#endif - /* ensure NUL termination if the buffer is too short */ - buf[buflen-1] = '\0'; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_sockaddr_ip_get(char **addr, - apr_sockaddr_t *sockaddr) -{ - *addr = apr_palloc(sockaddr->pool, sockaddr->addr_str_len); - return apr_sockaddr_ip_getbuf(*addr, sockaddr->addr_str_len, sockaddr); -} - -void apr_sockaddr_vars_set(apr_sockaddr_t *addr, int family, apr_port_t port) -{ - addr->family = family; - addr->sa.sin.sin_family = family; - if (port) { - /* XXX IPv6: assumes sin_port and sin6_port at same offset */ - addr->sa.sin.sin_port = htons(port); - addr->port = port; - } -#if AIX_SERVNAME_HACK - else { - addr->sa.sin.sin_port = htons(port); - } -#endif - - if (family == APR_INET) { - addr->salen = sizeof(struct sockaddr_in); - addr->addr_str_len = 16; - addr->ipaddr_ptr = &(addr->sa.sin.sin_addr); - addr->ipaddr_len = sizeof(struct in_addr); - } -#if APR_HAVE_IPV6 - else if (family == APR_INET6) { - addr->salen = sizeof(struct sockaddr_in6); - addr->addr_str_len = 46; - addr->ipaddr_ptr = &(addr->sa.sin6.sin6_addr); - addr->ipaddr_len = sizeof(struct in6_addr); - } -#endif -} - -APR_DECLARE(apr_status_t) apr_socket_addr_get(apr_sockaddr_t **sa, - apr_interface_e which, - apr_socket_t *sock) -{ - if (which == APR_LOCAL) { - if (sock->local_interface_unknown || sock->local_port_unknown) { - apr_status_t rv = get_local_addr(sock); - - if (rv != APR_SUCCESS) { - return rv; - } - } - *sa = sock->local_addr; - } - else if (which == APR_REMOTE) { - if (sock->remote_addr_unknown) { - apr_status_t rv = get_remote_addr(sock); - - if (rv != APR_SUCCESS) { - return rv; - } - } - *sa = sock->remote_addr; - } - else { - *sa = NULL; - return APR_EINVAL; - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_parse_addr_port(char **addr, - char **scope_id, - apr_port_t *port, - const char *str, - apr_pool_t *p) -{ - const char *ch, *lastchar; - int big_port; - apr_size_t addrlen; - - *addr = NULL; /* assume not specified */ - *scope_id = NULL; /* assume not specified */ - *port = 0; /* assume not specified */ - - /* First handle the optional port number. That may be all that - * is specified in the string. - */ - ch = lastchar = str + strlen(str) - 1; - while (ch >= str && apr_isdigit(*ch)) { - --ch; - } - - if (ch < str) { /* Entire string is the port. */ - big_port = atoi(str); - if (big_port < 1 || big_port > 65535) { - return APR_EINVAL; - } - *port = big_port; - return APR_SUCCESS; - } - - if (*ch == ':' && ch < lastchar) { /* host and port number specified */ - if (ch == str) { /* string starts with ':' -- bad */ - return APR_EINVAL; - } - big_port = atoi(ch + 1); - if (big_port < 1 || big_port > 65535) { - return APR_EINVAL; - } - *port = big_port; - lastchar = ch - 1; - } - - /* now handle the hostname */ - addrlen = lastchar - str + 1; - -/* XXX we don't really have to require APR_HAVE_IPV6 for this; - * just pass char[] for ipaddr (so we don't depend on struct in6_addr) - * and always define APR_INET6 - */ -#if APR_HAVE_IPV6 - if (*str == '[') { - const char *end_bracket = memchr(str, ']', addrlen); - struct in6_addr ipaddr; - const char *scope_delim; - - if (!end_bracket || end_bracket != lastchar) { - *port = 0; - return APR_EINVAL; - } - - /* handle scope id; this is the only context where it is allowed */ - scope_delim = memchr(str, '%', addrlen); - if (scope_delim) { - if (scope_delim == end_bracket - 1) { /* '%' without scope id */ - *port = 0; - return APR_EINVAL; - } - addrlen = scope_delim - str - 1; - *scope_id = apr_palloc(p, end_bracket - scope_delim); - memcpy(*scope_id, scope_delim + 1, end_bracket - scope_delim - 1); - (*scope_id)[end_bracket - scope_delim - 1] = '\0'; - } - else { - addrlen = addrlen - 2; /* minus 2 for '[' and ']' */ - } - - *addr = apr_palloc(p, addrlen + 1); - memcpy(*addr, - str + 1, - addrlen); - (*addr)[addrlen] = '\0'; - if (apr_inet_pton(AF_INET6, *addr, &ipaddr) != 1) { - *addr = NULL; - *scope_id = NULL; - *port = 0; - return APR_EINVAL; - } - } - else -#endif - { - /* XXX If '%' is not a valid char in a DNS name, we *could* check - * for bogus scope ids first. - */ - *addr = apr_palloc(p, addrlen + 1); - memcpy(*addr, str, addrlen); - (*addr)[addrlen] = '\0'; - } - return APR_SUCCESS; -} - -#if defined(HAVE_GETADDRINFO) - -static apr_status_t call_resolver(apr_sockaddr_t **sa, - const char *hostname, apr_int32_t family, - apr_port_t port, apr_int32_t flags, - apr_pool_t *p) -{ - struct addrinfo hints, *ai, *ai_list; - apr_sockaddr_t *prev_sa; - int error; - char *servname = NULL; - - memset(&hints, 0, sizeof(hints)); - hints.ai_family = family; - hints.ai_socktype = SOCK_STREAM; -#ifdef HAVE_GAI_ADDRCONFIG - if (family == APR_UNSPEC) { - /* By default, only look up addresses using address types for - * which a local interface is configured, i.e. no IPv6 if no - * IPv6 interfaces configured. */ - hints.ai_flags = AI_ADDRCONFIG; - } -#endif - if(hostname == NULL) { -#ifdef AI_PASSIVE - /* If hostname is NULL, assume we are trying to bind to all - * interfaces. */ - hints.ai_flags |= AI_PASSIVE; -#endif - /* getaddrinfo according to RFC 2553 must have either hostname - * or servname non-NULL. - */ -#ifdef OSF1 - /* The Tru64 5.0 getaddrinfo() can only resolve services given - * by the name listed in /etc/services; a numeric or unknown - * servname gets an EAI_SERVICE error. So just resolve the - * appropriate anyaddr and fill in the port later. */ - hostname = family == AF_INET6 ? "::" : "0.0.0.0"; - servname = NULL; -#ifdef AI_NUMERICHOST - hints.ai_flags |= AI_NUMERICHOST; -#endif -#else -#if AIX_SERVNAME_HACK - if (!port) { - servname = "1"; - } - else -#endif /* AIX_SERVNAME_HACK */ - servname = apr_itoa(p, port); -#endif /* OSF1 */ - } - error = getaddrinfo(hostname, servname, &hints, &ai_list); -#ifdef HAVE_GAI_ADDRCONFIG - if (error == EAI_BADFLAGS && family == APR_UNSPEC) { - /* Retry with no flags if AI_ADDRCONFIG was rejected. */ - hints.ai_flags = 0; - error = getaddrinfo(hostname, servname, &hints, &ai_list); - } -#endif - if (error) { -#if defined(WIN32) - return apr_get_netos_error(); -#else - if (error == EAI_SYSTEM) { - return errno; - } - else - { - /* issues with representing this with APR's error scheme: - * glibc uses negative values for these numbers, perhaps so - * they don't conflict with h_errno values... Tru64 uses - * positive values which conflict with h_errno values - */ -#if defined(NEGATIVE_EAI) - error = -error; -#endif - return error + APR_OS_START_EAIERR; - } -#endif /* WIN32 */ - } - - prev_sa = NULL; - ai = ai_list; - while (ai) { /* while more addresses to report */ - apr_sockaddr_t *new_sa; - - /* Ignore anything bogus: getaddrinfo in some old versions of - * glibc will return AF_UNIX entries for APR_UNSPEC+AI_PASSIVE - * lookups. */ -#if APR_HAVE_IPV6 - if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6) { -#else - if (ai->ai_family != AF_INET) { -#endif - ai = ai->ai_next; - continue; - } - - new_sa = apr_pcalloc(p, sizeof(apr_sockaddr_t)); - - new_sa->pool = p; - memcpy(&new_sa->sa, ai->ai_addr, ai->ai_addrlen); - apr_sockaddr_vars_set(new_sa, ai->ai_family, port); - - if (!prev_sa) { /* first element in new list */ - if (hostname) { - new_sa->hostname = apr_pstrdup(p, hostname); - } - *sa = new_sa; - } - else { - new_sa->hostname = prev_sa->hostname; - prev_sa->next = new_sa; - } - - prev_sa = new_sa; - ai = ai->ai_next; - } - freeaddrinfo(ai_list); - return APR_SUCCESS; -} - -static apr_status_t find_addresses(apr_sockaddr_t **sa, - const char *hostname, apr_int32_t family, - apr_port_t port, apr_int32_t flags, - apr_pool_t *p) -{ - if (flags & APR_IPV4_ADDR_OK) { - apr_status_t error = call_resolver(sa, hostname, AF_INET, port, flags, p); - -#if APR_HAVE_IPV6 - if (error) { - family = AF_INET6; /* try again */ - } - else -#endif - return error; - } -#if APR_HAVE_IPV6 - else if (flags & APR_IPV6_ADDR_OK) { - apr_status_t error = call_resolver(sa, hostname, AF_INET6, port, flags, p); - - if (error) { - family = AF_INET; /* try again */ - } - else { - return APR_SUCCESS; - } - } -#endif - - return call_resolver(sa, hostname, family, port, flags, p); -} - -#else /* end of HAVE_GETADDRINFO code */ - -static apr_status_t find_addresses(apr_sockaddr_t **sa, - const char *hostname, apr_int32_t family, - apr_port_t port, apr_int32_t flags, - apr_pool_t *p) -{ - struct hostent *hp; - apr_sockaddr_t *prev_sa; - int curaddr; -#if APR_HAS_THREADS && !defined(GETHOSTBYNAME_IS_THREAD_SAFE) && \ - defined(HAVE_GETHOSTBYNAME_R) && !defined(BEOS) -#ifdef GETHOSTBYNAME_R_HOSTENT_DATA - struct hostent_data hd; -#else - /* If you see ERANGE, that means GETHOSBYNAME_BUFLEN needs to be - * bumped. */ - char tmp[GETHOSTBYNAME_BUFLEN]; -#endif - int hosterror; -#endif - struct hostent hs; - struct in_addr ipaddr; - char *addr_list[2]; - const char *orig_hostname = hostname; - - if (hostname == NULL) { - /* if we are given a NULL hostname, assume '0.0.0.0' */ - hostname = "0.0.0.0"; - } - - if (*hostname >= '0' && *hostname <= '9' && - strspn(hostname, "0123456789.") == strlen(hostname)) { - - ipaddr.s_addr = inet_addr(hostname); - addr_list[0] = (char *)&ipaddr; - addr_list[1] = NULL; /* just one IP in list */ - hs.h_addr_list = (char **)addr_list; - hp = &hs; - } - else { -#if APR_HAS_THREADS && !defined(GETHOSTBYNAME_IS_THREAD_SAFE) && \ - defined(HAVE_GETHOSTBYNAME_R) && !defined(BEOS) -#if defined(GETHOSTBYNAME_R_HOSTENT_DATA) - /* AIX, HP/UX, D/UX et alia */ - gethostbyname_r(hostname, &hs, &hd); - hp = &hs; -#else -#if defined(GETHOSTBYNAME_R_GLIBC2) - /* Linux glibc2+ */ - gethostbyname_r(hostname, &hs, tmp, GETHOSTBYNAME_BUFLEN - 1, - &hp, &hosterror); -#else - /* Solaris, Irix et alia */ - hp = gethostbyname_r(hostname, &hs, tmp, GETHOSTBYNAME_BUFLEN - 1, - &hosterror); -#endif /* !defined(GETHOSTBYNAME_R_GLIBC2) */ - if (!hp) { - return (hosterror + APR_OS_START_SYSERR); - } -#endif /* !defined(GETHOSTBYNAME_R_HOSTENT_DATA) */ -#else - hp = gethostbyname(hostname); -#endif - - if (!hp) { -#ifdef WIN32 - return apr_get_netos_error(); -#else - return (h_errno + APR_OS_START_SYSERR); -#endif - } - } - - prev_sa = NULL; - curaddr = 0; - while (hp->h_addr_list[curaddr]) { - apr_sockaddr_t *new_sa = apr_pcalloc(p, sizeof(apr_sockaddr_t)); - - new_sa->pool = p; - new_sa->sa.sin.sin_addr = *(struct in_addr *)hp->h_addr_list[curaddr]; - apr_sockaddr_vars_set(new_sa, AF_INET, port); - - if (!prev_sa) { /* first element in new list */ - if (orig_hostname) { - new_sa->hostname = apr_pstrdup(p, orig_hostname); - } - *sa = new_sa; - } - else { - new_sa->hostname = prev_sa->hostname; - prev_sa->next = new_sa; - } - - prev_sa = new_sa; - ++curaddr; - } - - return APR_SUCCESS; -} - -#endif /* end of !HAVE_GETADDRINFO code */ - -APR_DECLARE(apr_status_t) apr_sockaddr_info_get(apr_sockaddr_t **sa, - const char *hostname, - apr_int32_t family, apr_port_t port, - apr_int32_t flags, apr_pool_t *p) -{ - apr_int32_t masked; - *sa = NULL; - - if ((masked = flags & (APR_IPV4_ADDR_OK | APR_IPV6_ADDR_OK))) { - if (!hostname || - family != APR_UNSPEC || - masked == (APR_IPV4_ADDR_OK | APR_IPV6_ADDR_OK)) { - return APR_EINVAL; - } -#if !APR_HAVE_IPV6 - if (flags & APR_IPV6_ADDR_OK) { - return APR_ENOTIMPL; - } -#endif - } -#if !APR_HAVE_IPV6 - /* What may happen is that APR is not IPv6-enabled, but we're still - * going to call getaddrinfo(), so we have to tell the OS we only - * want IPv4 addresses back since we won't know what to do with - * IPv6 addresses. - */ - if (family == APR_UNSPEC) { - family = APR_INET; - } -#endif - - return find_addresses(sa, hostname, family, port, flags, p); -} - -APR_DECLARE(apr_status_t) apr_getnameinfo(char **hostname, - apr_sockaddr_t *sockaddr, - apr_int32_t flags) -{ -#if defined(HAVE_GETNAMEINFO) - int rc; -#if defined(NI_MAXHOST) - char tmphostname[NI_MAXHOST]; -#else - char tmphostname[256]; -#endif - - /* don't know if it is portable for getnameinfo() to set h_errno; - * clear it then see if it was set */ - SET_H_ERRNO(0); - - /* default flags are NI_NAMREQD; otherwise, getnameinfo() will return - * a numeric address string if it fails to resolve the host name; - * that is *not* what we want here - * - * For IPv4-mapped IPv6 addresses, drop down to IPv4 before calling - * getnameinfo() to avoid getnameinfo bugs (MacOS X, glibc). - */ -#if APR_HAVE_IPV6 - if (sockaddr->family == AF_INET6 && - IN6_IS_ADDR_V4MAPPED(&sockaddr->sa.sin6.sin6_addr)) { - struct sockaddr_in tmpsa; - tmpsa.sin_family = AF_INET; - tmpsa.sin_port = 0; - tmpsa.sin_addr.s_addr = ((apr_uint32_t *)sockaddr->ipaddr_ptr)[3]; -#ifdef SIN6_LEN - tmpsa.sin_len = sizeof(tmpsa); -#endif - - rc = getnameinfo((const struct sockaddr *)&tmpsa, sizeof(tmpsa), - tmphostname, sizeof(tmphostname), NULL, 0, - flags != 0 ? flags : NI_NAMEREQD); - } - else -#endif - rc = getnameinfo((const struct sockaddr *)&sockaddr->sa, sockaddr->salen, - tmphostname, sizeof(tmphostname), NULL, 0, - flags != 0 ? flags : NI_NAMEREQD); - if (rc != 0) { - *hostname = NULL; - -#ifndef WIN32 - /* something went wrong. Look at the EAI_ error code */ - if (rc == EAI_SYSTEM) { - /* EAI_SYSTEM System error returned in errno. */ - /* IMHO, Implementations that set h_errno a simply broken. */ - if (h_errno) { /* for broken implementations which set h_errno */ - return h_errno + APR_OS_START_SYSERR; - } - else { /* "normal" case */ - return errno + APR_OS_START_SYSERR; - } - } - else -#endif - { -#if defined(NEGATIVE_EAI) - if (rc < 0) rc = -rc; -#endif - return rc + APR_OS_START_EAIERR; /* return the EAI_ error */ - } - } - *hostname = sockaddr->hostname = apr_pstrdup(sockaddr->pool, - tmphostname); - return APR_SUCCESS; -#else -#if APR_HAS_THREADS && !defined(GETHOSTBYADDR_IS_THREAD_SAFE) && \ - defined(HAVE_GETHOSTBYADDR_R) && !defined(BEOS) -#ifdef GETHOSTBYNAME_R_HOSTENT_DATA - struct hostent_data hd; -#else - char tmp[GETHOSTBYNAME_BUFLEN]; -#endif - int hosterror; - struct hostent hs, *hptr; - -#if defined(GETHOSTBYNAME_R_HOSTENT_DATA) - /* AIX, HP/UX, D/UX et alia */ - gethostbyaddr_r((char *)&sockaddr->sa.sin.sin_addr, - sizeof(struct in_addr), AF_INET, &hs, &hd); - hptr = &hs; -#else -#if defined(GETHOSTBYNAME_R_GLIBC2) - /* Linux glibc2+ */ - gethostbyaddr_r((char *)&sockaddr->sa.sin.sin_addr, - sizeof(struct in_addr), AF_INET, - &hs, tmp, GETHOSTBYNAME_BUFLEN - 1, &hptr, &hosterror); -#else - /* Solaris, Irix et alia */ - hptr = gethostbyaddr_r((char *)&sockaddr->sa.sin.sin_addr, - sizeof(struct in_addr), AF_INET, - &hs, tmp, GETHOSTBYNAME_BUFLEN, &hosterror); -#endif /* !defined(GETHOSTBYNAME_R_GLIBC2) */ - if (!hptr) { - *hostname = NULL; - return hosterror + APR_OS_START_SYSERR; - } -#endif /* !defined(GETHOSTBYNAME_R_HOSTENT_DATA) */ -#else - struct hostent *hptr; - hptr = gethostbyaddr((char *)&sockaddr->sa.sin.sin_addr, - sizeof(struct in_addr), AF_INET); -#endif - - if (hptr) { - *hostname = sockaddr->hostname = apr_pstrdup(sockaddr->pool, hptr->h_name); - return APR_SUCCESS; - } - *hostname = NULL; -#if defined(WIN32) - return apr_get_netos_error(); -#elif defined(OS2) - return h_errno; -#else - return h_errno + APR_OS_START_SYSERR; -#endif -#endif -} - -APR_DECLARE(apr_status_t) apr_getservbyname(apr_sockaddr_t *sockaddr, - const char *servname) -{ -#if APR_HAS_THREADS && !defined(GETSERVBYNAME_IS_THREAD_SAFE) && \ - defined(HAVE_GETSERVBYNAME_R) && \ - (defined(GETSERVBYNAME_R_GLIBC2) || defined(GETSERVBYNAME_R_SOLARIS) || \ - defined(GETSERVBYNAME_R_OSF1)) - struct servent se; -#if defined(GETSERVBYNAME_R_OSF1) - struct servent_data sed; - - memset(&sed, 0, sizeof(sed)); /* must zero fill before use */ -#else -#if defined(GETSERVBYNAME_R_GLIBC2) - struct servent *res; -#endif - char buf[1024]; -#endif -#else - struct servent *se; -#endif - - if (servname == NULL) - return APR_EINVAL; - -#if APR_HAS_THREADS && !defined(GETSERVBYNAME_IS_THREAD_SAFE) && \ - defined(HAVE_GETSERVBYNAME_R) && \ - (defined(GETSERVBYNAME_R_GLIBC2) || defined(GETSERVBYNAME_R_SOLARIS) || \ - defined(GETSERVBYNAME_R_OSF1)) -#if defined(GETSERVBYNAME_R_GLIBC2) - if (getservbyname_r(servname, NULL, - &se, buf, sizeof(buf), &res) == 0 && res != NULL) { - sockaddr->port = ntohs(res->s_port); - sockaddr->servname = apr_pstrdup(sockaddr->pool, servname); - sockaddr->sa.sin.sin_port = res->s_port; - return APR_SUCCESS; - } -#elif defined(GETSERVBYNAME_R_SOLARIS) - if (getservbyname_r(servname, NULL, &se, buf, sizeof(buf)) != NULL) { - sockaddr->port = ntohs(se.s_port); - sockaddr->servname = apr_pstrdup(sockaddr->pool, servname); - sockaddr->sa.sin.sin_port = se.s_port; - return APR_SUCCESS; - } -#elif defined(GETSERVBYNAME_R_OSF1) - if (getservbyname_r(servname, NULL, &se, &sed) == 0) { - sockaddr->port = ntohs(se.s_port); - sockaddr->servname = apr_pstrdup(sockaddr->pool, servname); - sockaddr->sa.sin.sin_port = se.s_port; - return APR_SUCCESS; - } -#endif -#else - if ((se = getservbyname(servname, NULL)) != NULL){ - sockaddr->port = ntohs(se->s_port); - sockaddr->servname = apr_pstrdup(sockaddr->pool, servname); - sockaddr->sa.sin.sin_port = se->s_port; - return APR_SUCCESS; - } -#endif - return APR_ENOENT; -} - -#define V4MAPPED_EQUAL(a,b) \ -((a)->sa.sin.sin_family == AF_INET && \ - (b)->sa.sin.sin_family == AF_INET6 && \ - IN6_IS_ADDR_V4MAPPED((struct in6_addr *)(b)->ipaddr_ptr) && \ - !memcmp((a)->ipaddr_ptr, \ - &((struct in6_addr *)(b)->ipaddr_ptr)->s6_addr[12], \ - (a)->ipaddr_len)) - -APR_DECLARE(int) apr_sockaddr_equal(const apr_sockaddr_t *addr1, - const apr_sockaddr_t *addr2) -{ - if (addr1->ipaddr_len == addr2->ipaddr_len && - !memcmp(addr1->ipaddr_ptr, addr2->ipaddr_ptr, addr1->ipaddr_len)) { - return 1; - } -#if APR_HAVE_IPV6 - if (V4MAPPED_EQUAL(addr1, addr2)) { - return 1; - } - if (V4MAPPED_EQUAL(addr2, addr1)) { - return 1; - } -#endif - return 0; /* not equal */ -} - -static apr_status_t parse_network(apr_ipsubnet_t *ipsub, const char *network) -{ - /* legacy syntax for ip addrs: a.b.c. ==> a.b.c.0/24 for example */ - int shift; - char *s, *t; - int octet; - char buf[sizeof "255.255.255.255"]; - - if (strlen(network) < sizeof buf) { - strcpy(buf, network); - } - else { - return APR_EBADIP; - } - - /* parse components */ - s = buf; - ipsub->sub[0] = 0; - ipsub->mask[0] = 0; - shift = 24; - while (*s) { - t = s; - if (!apr_isdigit(*t)) { - return APR_EBADIP; - } - while (apr_isdigit(*t)) { - ++t; - } - if (*t == '.') { - *t++ = 0; - } - else if (*t) { - return APR_EBADIP; - } - if (shift < 0) { - return APR_EBADIP; - } - octet = atoi(s); - if (octet < 0 || octet > 255) { - return APR_EBADIP; - } - ipsub->sub[0] |= octet << shift; - ipsub->mask[0] |= 0xFFUL << shift; - s = t; - shift -= 8; - } - ipsub->sub[0] = ntohl(ipsub->sub[0]); - ipsub->mask[0] = ntohl(ipsub->mask[0]); - ipsub->family = AF_INET; - return APR_SUCCESS; -} - -/* return values: - * APR_EINVAL not an IP address; caller should see if it is something else - * APR_BADIP IP address portion is is not valid - * APR_BADMASK mask portion is not valid - */ - -static apr_status_t parse_ip(apr_ipsubnet_t *ipsub, const char *ipstr, int network_allowed) -{ - /* supported flavors of IP: - * - * . IPv6 numeric address string (e.g., "fe80::1") - * - * IMPORTANT: Don't store IPv4-mapped IPv6 address as an IPv6 address. - * - * . IPv4 numeric address string (e.g., "127.0.0.1") - * - * . IPv4 network string (e.g., "9.67") - * - * IMPORTANT: This network form is only allowed if network_allowed is on. - */ - int rc; - -#if APR_HAVE_IPV6 - rc = apr_inet_pton(AF_INET6, ipstr, ipsub->sub); - if (rc == 1) { - if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ipsub->sub)) { - /* apr_ipsubnet_test() assumes that we don't create IPv4-mapped IPv6 - * addresses; this of course forces the user to specify IPv4 addresses - * in a.b.c.d style instead of ::ffff:a.b.c.d style. - */ - return APR_EBADIP; - } - ipsub->family = AF_INET6; - } - else -#endif - { - rc = apr_inet_pton(AF_INET, ipstr, ipsub->sub); - if (rc == 1) { - ipsub->family = AF_INET; - } - } - if (rc != 1) { - if (network_allowed) { - return parse_network(ipsub, ipstr); - } - else { - return APR_EBADIP; - } - } - return APR_SUCCESS; -} - -static int looks_like_ip(const char *ipstr) -{ - if (strchr(ipstr, ':')) { - /* definitely not a hostname; assume it is intended to be an IPv6 address */ - return 1; - } - - /* simple IPv4 address string check */ - while ((*ipstr == '.') || apr_isdigit(*ipstr)) - ipstr++; - return (*ipstr == '\0'); -} - -static void fix_subnet(apr_ipsubnet_t *ipsub) -{ - /* in case caller specified more bits in network address than are - * valid according to the mask, turn off the extra bits - */ - int i; - - for (i = 0; i < sizeof ipsub->mask / sizeof(apr_int32_t); i++) { - ipsub->sub[i] &= ipsub->mask[i]; - } -} - -/* be sure not to store any IPv4 address as a v4-mapped IPv6 address */ -APR_DECLARE(apr_status_t) apr_ipsubnet_create(apr_ipsubnet_t **ipsub, const char *ipstr, - const char *mask_or_numbits, apr_pool_t *p) -{ - apr_status_t rv; - char *endptr; - long bits, maxbits = 32; - - /* filter out stuff which doesn't look remotely like an IP address; this helps - * callers like mod_access which have a syntax allowing hostname or IP address; - * APR_EINVAL tells the caller that it was probably not intended to be an IP - * address - */ - if (!looks_like_ip(ipstr)) { - return APR_EINVAL; - } - - *ipsub = apr_pcalloc(p, sizeof(apr_ipsubnet_t)); - - /* assume ipstr is an individual IP address, not a subnet */ - memset((*ipsub)->mask, 0xFF, sizeof (*ipsub)->mask); - - rv = parse_ip(*ipsub, ipstr, mask_or_numbits == NULL); - if (rv != APR_SUCCESS) { - return rv; - } - - if (mask_or_numbits) { -#if APR_HAVE_IPV6 - if ((*ipsub)->family == AF_INET6) { - maxbits = 128; - } -#endif - bits = strtol(mask_or_numbits, &endptr, 10); - if (*endptr == '\0' && bits > 0 && bits <= maxbits) { - /* valid num-bits string; fill in mask appropriately */ - int cur_entry = 0; - apr_int32_t cur_bit_value; - - memset((*ipsub)->mask, 0, sizeof (*ipsub)->mask); - while (bits > 32) { - (*ipsub)->mask[cur_entry] = 0xFFFFFFFF; /* all 32 bits */ - bits -= 32; - ++cur_entry; - } - cur_bit_value = 0x80000000; - while (bits) { - (*ipsub)->mask[cur_entry] |= cur_bit_value; - --bits; - cur_bit_value /= 2; - } - (*ipsub)->mask[cur_entry] = htonl((*ipsub)->mask[cur_entry]); - } - else if (apr_inet_pton(AF_INET, mask_or_numbits, (*ipsub)->mask) == 1 && - (*ipsub)->family == AF_INET) { - /* valid IPv4 netmask */ - } - else { - return APR_EBADMASK; - } - } - - fix_subnet(*ipsub); - - return APR_SUCCESS; -} - -APR_DECLARE(int) apr_ipsubnet_test(apr_ipsubnet_t *ipsub, apr_sockaddr_t *sa) -{ -#if APR_HAVE_IPV6 - /* XXX This line will segv on Win32 build with APR_HAVE_IPV6, - * but without the IPV6 drivers installed. - */ - if (sa->sa.sin.sin_family == AF_INET) { - if (ipsub->family == AF_INET && - ((sa->sa.sin.sin_addr.s_addr & ipsub->mask[0]) == ipsub->sub[0])) { - return 1; - } - } - else if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)sa->ipaddr_ptr)) { - if (ipsub->family == AF_INET && - (((apr_uint32_t *)sa->ipaddr_ptr)[3] & ipsub->mask[0]) == ipsub->sub[0]) { - return 1; - } - } - else { - apr_uint32_t *addr = (apr_uint32_t *)sa->ipaddr_ptr; - - if ((addr[0] & ipsub->mask[0]) == ipsub->sub[0] && - (addr[1] & ipsub->mask[1]) == ipsub->sub[1] && - (addr[2] & ipsub->mask[2]) == ipsub->sub[2] && - (addr[3] & ipsub->mask[3]) == ipsub->sub[3]) { - return 1; - } - } -#else - if ((sa->sa.sin.sin_addr.s_addr & ipsub->mask[0]) == ipsub->sub[0]) { - return 1; - } -#endif /* APR_HAVE_IPV6 */ - return 0; /* no match */ -} diff --git a/libs/apr/network_io/unix/socket_util.c b/libs/apr/network_io/unix/socket_util.c deleted file mode 100644 index 6cd28a55..00000000 --- a/libs/apr/network_io/unix/socket_util.c +++ /dev/null @@ -1,74 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_network_io.h" -#include "apr_poll.h" - -APR_DECLARE(apr_status_t) apr_socket_atreadeof(apr_socket_t *sock, int *atreadeof) -{ - apr_pollfd_t pfds[1]; - apr_status_t rv; - apr_int32_t nfds; - - /* The purpose here is to return APR_SUCCESS only in cases in - * which it can be unambiguously determined whether or not the - * socket will return EOF on next read. In case of an unexpected - * error, return that. */ - - pfds[0].reqevents = APR_POLLIN; - pfds[0].desc_type = APR_POLL_SOCKET; - pfds[0].desc.s = sock; - - do { - rv = apr_poll(&pfds[0], 1, &nfds, 0); - } while (APR_STATUS_IS_EINTR(rv)); - - if (APR_STATUS_IS_TIMEUP(rv)) { - /* Read buffer empty -> subsequent reads would block, so, - * definitely not at EOF. */ - *atreadeof = 0; - return APR_SUCCESS; - } - else if (rv) { - /* Some other error -> unexpected error. */ - return rv; - } - else if (nfds == 1 && pfds[0].rtnevents == APR_POLLIN) { - apr_sockaddr_t unused; - apr_size_t len = 1; - char buf; - - /* The socket is readable - peek to see whether it returns EOF - * without consuming bytes from the socket buffer. */ - rv = apr_socket_recvfrom(&unused, sock, MSG_PEEK, &buf, &len); - if (rv == APR_EOF) { - *atreadeof = 1; - return APR_SUCCESS; - } - else if (rv) { - /* Read error -> unexpected error. */ - return rv; - } - else { - *atreadeof = 0; - return APR_SUCCESS; - } - } - - /* Should not fall through here. */ - return APR_EGENERAL; -} - diff --git a/libs/apr/network_io/unix/sockets.c b/libs/apr/network_io/unix/sockets.c deleted file mode 100644 index 748dd707..00000000 --- a/libs/apr/network_io/unix/sockets.c +++ /dev/null @@ -1,490 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_networkio.h" -#include "apr_network_io.h" -#include "apr_strings.h" -#include "apr_support.h" -#include "apr_portable.h" -#include "apr_arch_inherit.h" - -#ifdef BEOS_R5 -#undef close -#define close closesocket -#endif /* BEOS_R5 */ - -static char generic_inaddr_any[16] = {0}; /* big enough for IPv4 or IPv6 */ - -static apr_status_t socket_cleanup(void *sock) -{ - apr_socket_t *thesocket = sock; - int sd = thesocket->socketdes; - - /* Set socket descriptor to -1 before close(), so that there is no - * chance of returning an already closed FD from apr_os_sock_get(). - */ - thesocket->socketdes = -1; - - if (close(sd) == 0) { - return APR_SUCCESS; - } - else { - /* Restore, close() was not successful. */ - thesocket->socketdes = sd; - - return errno; - } -} - -static void set_socket_vars(apr_socket_t *sock, int family, int type, int protocol) -{ - sock->type = type; - sock->protocol = protocol; - apr_sockaddr_vars_set(sock->local_addr, family, 0); - apr_sockaddr_vars_set(sock->remote_addr, family, 0); - sock->options = 0; -#if defined(BEOS) && !defined(BEOS_BONE) - /* BeOS pre-BONE has TCP_NODELAY on by default and it can't be - * switched off! - */ - sock->options |= APR_TCP_NODELAY; -#endif -} - -static void alloc_socket(apr_socket_t **new, apr_pool_t *p) -{ - *new = (apr_socket_t *)apr_pcalloc(p, sizeof(apr_socket_t)); - (*new)->pool = p; - (*new)->local_addr = (apr_sockaddr_t *)apr_pcalloc((*new)->pool, - sizeof(apr_sockaddr_t)); - (*new)->local_addr->pool = p; - (*new)->remote_addr = (apr_sockaddr_t *)apr_pcalloc((*new)->pool, - sizeof(apr_sockaddr_t)); - (*new)->remote_addr->pool = p; - (*new)->remote_addr_unknown = 1; -#ifndef WAITIO_USES_POLL - /* Create a pollset with room for one descriptor. */ - /* ### check return codes */ - (void) apr_pollset_create(&(*new)->pollset, 1, p, 0); -#endif -} - -apr_status_t apr_socket_protocol_get(apr_socket_t *sock, int *protocol) -{ - *protocol = sock->protocol; - return APR_SUCCESS; -} - -apr_status_t apr_socket_create(apr_socket_t **new, int ofamily, int type, - int protocol, apr_pool_t *cont) -{ - int family = ofamily, flags = 0; - -#ifdef HAVE_SOCK_CLOEXEC - flags |= SOCK_CLOEXEC; -#endif - - if (family == APR_UNSPEC) { -#if APR_HAVE_IPV6 - family = APR_INET6; -#else - family = APR_INET; -#endif - } - - alloc_socket(new, cont); - -#ifndef BEOS_R5 - (*new)->socketdes = socket(family, type|flags, protocol); -#else - /* For some reason BeOS R5 has an unconventional protocol numbering, - * so we need to translate here. */ - switch (protocol) { - case 0: - (*new)->socketdes = socket(family, type|flags, 0); - break; - case APR_PROTO_TCP: - (*new)->socketdes = socket(family, type|flags, IPPROTO_TCP); - break; - case APR_PROTO_UDP: - (*new)->socketdes = socket(family, type|flags, IPPROTO_UDP); - break; - case APR_PROTO_SCTP: - default: - errno = EPROTONOSUPPORT; - (*new)->socketdes = -1; - break; - } -#endif /* BEOS_R5 */ - -#if APR_HAVE_IPV6 - if ((*new)->socketdes < 0 && ofamily == APR_UNSPEC) { - family = APR_INET; - (*new)->socketdes = socket(family, type|flags, protocol); - } -#endif - - if ((*new)->socketdes < 0) { - return errno; - } - set_socket_vars(*new, family, type, protocol); - -#ifndef HAVE_SOCK_CLOEXEC - { - int flags; - - if ((flags = fcntl((*new)->socketdes, F_GETFD)) == -1) - return errno; - - flags |= FD_CLOEXEC; - if (fcntl((*new)->socketdes, F_SETFD, flags) == -1) - return errno; - } -#endif - - (*new)->timeout = -1; - (*new)->inherit = 0; - apr_pool_cleanup_register((*new)->pool, (void *)(*new), socket_cleanup, - socket_cleanup); - - return APR_SUCCESS; -} - -apr_status_t apr_socket_shutdown(apr_socket_t *thesocket, - apr_shutdown_how_e how) -{ - return (shutdown(thesocket->socketdes, how) == -1) ? errno : APR_SUCCESS; -} - -apr_status_t apr_socket_close(apr_socket_t *thesocket) -{ - return apr_pool_cleanup_run(thesocket->pool, thesocket, socket_cleanup); -} - -apr_status_t apr_socket_bind(apr_socket_t *sock, apr_sockaddr_t *sa) -{ - if (bind(sock->socketdes, - (struct sockaddr *)&sa->sa, sa->salen) == -1) { - return errno; - } - else { - sock->local_addr = sa; - /* XXX IPv6 - this assumes sin_port and sin6_port at same offset */ - if (sock->local_addr->sa.sin.sin_port == 0) { /* no need for ntohs() when comparing w/ 0 */ - sock->local_port_unknown = 1; /* kernel got us an ephemeral port */ - } - return APR_SUCCESS; - } -} - -apr_status_t apr_socket_listen(apr_socket_t *sock, apr_int32_t backlog) -{ - if (listen(sock->socketdes, backlog) == -1) - return errno; - else - return APR_SUCCESS; -} - -apr_status_t apr_socket_accept(apr_socket_t **new, apr_socket_t *sock, - apr_pool_t *connection_context) -{ - int s; - apr_sockaddr_t sa; - - sa.salen = sizeof(sa.sa); - -#ifdef HAVE_ACCEPT4 - s = accept4(sock->socketdes, (struct sockaddr *)&sa.sa, &sa.salen, SOCK_CLOEXEC); -#else - s = accept(sock->socketdes, (struct sockaddr *)&sa.sa, &sa.salen); -#endif - - if (s < 0) { - return errno; - } -#ifdef TPF - if (s == 0) { - /* 0 is an invalid socket for TPF */ - return APR_EINTR; - } -#endif - alloc_socket(new, connection_context); - - /* Set up socket variables -- note that it may be possible for - * *new to be an AF_INET socket when sock is AF_INET6 in some - * dual-stack configurations, so ensure that the remote_/local_addr - * structures are adjusted for the family of the accepted - * socket: */ - set_socket_vars(*new, sa.sa.sin.sin_family, SOCK_STREAM, sock->protocol); - -#ifndef HAVE_POLL - (*new)->connected = 1; -#endif - (*new)->timeout = -1; - - (*new)->remote_addr_unknown = 0; - - (*new)->socketdes = s; - - /* Copy in peer's address. */ - (*new)->remote_addr->sa = sa.sa; - (*new)->remote_addr->salen = sa.salen; - - *(*new)->local_addr = *sock->local_addr; - - /* The above assignment just overwrote the pool entry. Setting the local_addr - pool for the accepted socket back to what it should be. Otherwise all - allocations for this socket will come from a server pool that is not - freed until the process goes down.*/ - (*new)->local_addr->pool = connection_context; - - /* fix up any pointers which are no longer valid */ - if (sock->local_addr->sa.sin.sin_family == AF_INET) { - (*new)->local_addr->ipaddr_ptr = &(*new)->local_addr->sa.sin.sin_addr; - } -#if APR_HAVE_IPV6 - else if (sock->local_addr->sa.sin.sin_family == AF_INET6) { - (*new)->local_addr->ipaddr_ptr = &(*new)->local_addr->sa.sin6.sin6_addr; - } -#endif - (*new)->remote_addr->port = ntohs((*new)->remote_addr->sa.sin.sin_port); - if (sock->local_port_unknown) { - /* not likely for a listening socket, but theoretically possible :) */ - (*new)->local_port_unknown = 1; - } - -#if APR_TCP_NODELAY_INHERITED - if (apr_is_option_set(sock, APR_TCP_NODELAY) == 1) { - apr_set_option(*new, APR_TCP_NODELAY, 1); - } -#endif /* TCP_NODELAY_INHERITED */ -#if APR_O_NONBLOCK_INHERITED - if (apr_is_option_set(sock, APR_SO_NONBLOCK) == 1) { - apr_set_option(*new, APR_SO_NONBLOCK, 1); - } -#endif /* APR_O_NONBLOCK_INHERITED */ - - if (sock->local_interface_unknown || - !memcmp(sock->local_addr->ipaddr_ptr, - generic_inaddr_any, - sock->local_addr->ipaddr_len)) { - /* If the interface address inside the listening socket's local_addr wasn't - * up-to-date, we don't know local interface of the connected socket either. - * - * If the listening socket was not bound to a specific interface, we - * don't know the local_addr of the connected socket. - */ - (*new)->local_interface_unknown = 1; - } - -#ifndef HAVE_ACCEPT4 - { - int flags; - - if ((flags = fcntl((*new)->socketdes, F_GETFD)) == -1) - return errno; - - flags |= FD_CLOEXEC; - if (fcntl((*new)->socketdes, F_SETFD, flags) == -1) - return errno; - } -#endif - - (*new)->inherit = 0; - apr_pool_cleanup_register((*new)->pool, (void *)(*new), socket_cleanup, - socket_cleanup); - return APR_SUCCESS; -} - -apr_status_t apr_socket_connect(apr_socket_t *sock, apr_sockaddr_t *sa) -{ - int rc; - - do { - rc = connect(sock->socketdes, - (const struct sockaddr *)&sa->sa.sin, - sa->salen); - } while (rc == -1 && errno == EINTR); - - /* we can see EINPROGRESS the first time connect is called on a non-blocking - * socket; if called again, we can see EALREADY - */ - if ((rc == -1) && (errno == EINPROGRESS || errno == EALREADY) - && (sock->timeout > 0)) { - rc = apr_wait_for_io_or_timeout(NULL, sock, 0); - if (rc != APR_SUCCESS) { - return rc; - } - -#ifdef SO_ERROR - { - int error; - apr_socklen_t len = sizeof(error); - if ((rc = getsockopt(sock->socketdes, SOL_SOCKET, SO_ERROR, - (char *)&error, &len)) < 0) { - return errno; - } - if (error) { - return error; - } - } -#endif /* SO_ERROR */ - } - - - if (memcmp(sa->ipaddr_ptr, generic_inaddr_any, sa->ipaddr_len)) { - /* A real remote address was passed in. If the unspecified - * address was used, the actual remote addr will have to be - * determined using getpeername() if required. */ - sock->remote_addr_unknown = 0; - - /* Copy the address structure details in. */ - sock->remote_addr->sa = sa->sa; - sock->remote_addr->salen = sa->salen; - /* Adjust ipaddr_ptr et al. */ - apr_sockaddr_vars_set(sock->remote_addr, sa->family, sa->port); - } - - if (sock->local_addr->port == 0) { - /* connect() got us an ephemeral port */ - sock->local_port_unknown = 1; - } - if (!memcmp(sock->local_addr->ipaddr_ptr, - generic_inaddr_any, - sock->local_addr->ipaddr_len)) { - /* not bound to specific local interface; connect() had to assign - * one for the socket - */ - sock->local_interface_unknown = 1; - } - - if (rc == -1 && errno != EISCONN) { - return errno; - } - -#ifndef HAVE_POLL - sock->connected=1; -#endif - return APR_SUCCESS; -} - -apr_status_t apr_socket_type_get(apr_socket_t *sock, int *type) -{ - *type = sock->type; - return APR_SUCCESS; -} - -apr_status_t apr_socket_data_get(void **data, const char *key, apr_socket_t *sock) -{ - sock_userdata_t *cur = sock->userdata; - - *data = NULL; - - while (cur) { - if (!strcmp(cur->key, key)) { - *data = cur->data; - break; - } - cur = cur->next; - } - - return APR_SUCCESS; -} - -apr_status_t apr_socket_data_set(apr_socket_t *sock, void *data, const char *key, - apr_status_t (*cleanup) (void *)) -{ - sock_userdata_t *new = apr_palloc(sock->pool, sizeof(sock_userdata_t)); - - new->key = apr_pstrdup(sock->pool, key); - new->data = data; - new->next = sock->userdata; - sock->userdata = new; - - if (cleanup) { - apr_pool_cleanup_register(sock->pool, data, cleanup, cleanup); - } - - return APR_SUCCESS; -} - -apr_status_t apr_os_sock_get(apr_os_sock_t *thesock, apr_socket_t *sock) -{ - *thesock = sock->socketdes; - return APR_SUCCESS; -} - -apr_status_t apr_os_sock_make(apr_socket_t **apr_sock, - apr_os_sock_info_t *os_sock_info, - apr_pool_t *cont) -{ - alloc_socket(apr_sock, cont); - set_socket_vars(*apr_sock, os_sock_info->family, os_sock_info->type, os_sock_info->protocol); - (*apr_sock)->timeout = -1; - (*apr_sock)->socketdes = *os_sock_info->os_sock; - if (os_sock_info->local) { - memcpy(&(*apr_sock)->local_addr->sa.sin, - os_sock_info->local, - (*apr_sock)->local_addr->salen); - /* XXX IPv6 - this assumes sin_port and sin6_port at same offset */ - (*apr_sock)->local_addr->port = ntohs((*apr_sock)->local_addr->sa.sin.sin_port); - } - else { - (*apr_sock)->local_port_unknown = (*apr_sock)->local_interface_unknown = 1; - } - if (os_sock_info->remote) { -#ifndef HAVE_POLL - (*apr_sock)->connected = 1; -#endif - memcpy(&(*apr_sock)->remote_addr->sa.sin, - os_sock_info->remote, - (*apr_sock)->remote_addr->salen); - /* XXX IPv6 - this assumes sin_port and sin6_port at same offset */ - (*apr_sock)->remote_addr->port = ntohs((*apr_sock)->remote_addr->sa.sin.sin_port); - } - else { - (*apr_sock)->remote_addr_unknown = 1; - } - - (*apr_sock)->inherit = 0; - apr_pool_cleanup_register((*apr_sock)->pool, (void *)(*apr_sock), - socket_cleanup, socket_cleanup); - return APR_SUCCESS; -} - -apr_status_t apr_os_sock_put(apr_socket_t **sock, apr_os_sock_t *thesock, - apr_pool_t *cont) -{ - /* XXX Bogus assumption that *sock points at anything legit */ - if ((*sock) == NULL) { - alloc_socket(sock, cont); - /* XXX IPv6 figure out the family here! */ - /* XXX figure out the actual socket type here */ - /* *or* just decide that apr_os_sock_put() has to be told the family and type */ - set_socket_vars(*sock, APR_INET, SOCK_STREAM, 0); - (*sock)->timeout = -1; - } - (*sock)->local_port_unknown = (*sock)->local_interface_unknown = 1; - (*sock)->remote_addr_unknown = 1; - (*sock)->socketdes = *thesock; - return APR_SUCCESS; -} - -APR_POOL_IMPLEMENT_ACCESSOR(socket) - -APR_IMPLEMENT_INHERIT_SET(socket, inherit, pool, socket_cleanup) - -APR_IMPLEMENT_INHERIT_UNSET(socket, inherit, pool, socket_cleanup) diff --git a/libs/apr/network_io/unix/sockopt.c b/libs/apr/network_io/unix/sockopt.c deleted file mode 100644 index 3fc932f4..00000000 --- a/libs/apr/network_io/unix/sockopt.c +++ /dev/null @@ -1,397 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_networkio.h" -#include "apr_strings.h" - - -static apr_status_t soblock(int sd) -{ -/* BeOS uses setsockopt at present for non blocking... */ -#ifndef BEOS - int fd_flags; - - fd_flags = fcntl(sd, F_GETFL, 0); -#if defined(O_NONBLOCK) - fd_flags &= ~O_NONBLOCK; -#elif defined(O_NDELAY) - fd_flags &= ~O_NDELAY; -#elif defined(FNDELAY) - fd_flags &= ~FNDELAY; -#else -#error Please teach APR how to make sockets blocking on your platform. -#endif - if (fcntl(sd, F_SETFL, fd_flags) == -1) { - return errno; - } -#else - int on = 0; - if (setsockopt(sd, SOL_SOCKET, SO_NONBLOCK, &on, sizeof(int)) < 0) - return errno; -#endif /* BEOS */ - return APR_SUCCESS; -} - -static apr_status_t sononblock(int sd) -{ -#ifndef BEOS - int fd_flags; - - fd_flags = fcntl(sd, F_GETFL, 0); -#if defined(O_NONBLOCK) - fd_flags |= O_NONBLOCK; -#elif defined(O_NDELAY) - fd_flags |= O_NDELAY; -#elif defined(FNDELAY) - fd_flags |= FNDELAY; -#else -#error Please teach APR how to make sockets non-blocking on your platform. -#endif - if (fcntl(sd, F_SETFL, fd_flags) == -1) { - return errno; - } -#else - int on = 1; - if (setsockopt(sd, SOL_SOCKET, SO_NONBLOCK, &on, sizeof(int)) < 0) - return errno; -#endif /* BEOS */ - return APR_SUCCESS; -} - - -apr_status_t apr_socket_timeout_set(apr_socket_t *sock, apr_interval_time_t t) -{ - apr_status_t stat; - - /* If our new timeout is non-negative and our old timeout was - * negative, then we need to ensure that we are non-blocking. - * Conversely, if our new timeout is negative and we had - * non-negative timeout, we must make sure our socket is blocking. - * We want to avoid calling fcntl more than necessary on the - * socket. - */ - if (t >= 0 && sock->timeout < 0) { - if (apr_is_option_set(sock, APR_SO_NONBLOCK) != 1) { - if ((stat = sononblock(sock->socketdes)) != APR_SUCCESS) { - return stat; - } - apr_set_option(sock, APR_SO_NONBLOCK, 1); - } - } - else if (t < 0 && sock->timeout >= 0) { - if (apr_is_option_set(sock, APR_SO_NONBLOCK) != 0) { - if ((stat = soblock(sock->socketdes)) != APR_SUCCESS) { - return stat; - } - apr_set_option(sock, APR_SO_NONBLOCK, 0); - } - } - /* must disable the incomplete read support if we disable - * a timeout - */ - if (t <= 0) { - sock->options &= ~APR_INCOMPLETE_READ; - } - sock->timeout = t; - return APR_SUCCESS; -} - - -apr_status_t apr_socket_opt_set(apr_socket_t *sock, - apr_int32_t opt, apr_int32_t on) -{ - int one; - apr_status_t rv; - - if (on) - one = 1; - else - one = 0; - switch(opt) { - case APR_SO_KEEPALIVE: -#ifdef SO_KEEPALIVE - if (on != apr_is_option_set(sock, APR_SO_KEEPALIVE)) { - if (setsockopt(sock->socketdes, SOL_SOCKET, SO_KEEPALIVE, (void *)&one, sizeof(int)) == -1) { - return errno; - } - apr_set_option(sock, APR_SO_KEEPALIVE, on); - } -#else - return APR_ENOTIMPL; -#endif - break; - case APR_SO_DEBUG: - if (on != apr_is_option_set(sock, APR_SO_DEBUG)) { - if (setsockopt(sock->socketdes, SOL_SOCKET, SO_DEBUG, (void *)&one, sizeof(int)) == -1) { - return errno; - } - apr_set_option(sock, APR_SO_DEBUG, on); - } - break; - case APR_SO_REUSEADDR: - if (on != apr_is_option_set(sock, APR_SO_REUSEADDR)) { - if (setsockopt(sock->socketdes, SOL_SOCKET, SO_REUSEADDR, (void *)&one, sizeof(int)) == -1) { - return errno; - } - apr_set_option(sock, APR_SO_REUSEADDR, on); - } - break; - case APR_SO_SNDBUF: -#ifdef SO_SNDBUF - if (setsockopt(sock->socketdes, SOL_SOCKET, SO_SNDBUF, (void *)&on, sizeof(int)) == -1) { - return errno; - } -#else - return APR_ENOTIMPL; -#endif - break; - case APR_SO_RCVBUF: -#ifdef SO_RCVBUF - if (setsockopt(sock->socketdes, SOL_SOCKET, SO_RCVBUF, (void *)&on, sizeof(int)) == -1) { - return errno; - } -#else - return APR_ENOTIMPL; -#endif - break; - case APR_SO_NONBLOCK: - if (apr_is_option_set(sock, APR_SO_NONBLOCK) != on) { - if (on) { - if ((rv = sononblock(sock->socketdes)) != APR_SUCCESS) - return rv; - } - else { - if ((rv = soblock(sock->socketdes)) != APR_SUCCESS) - return rv; - } - apr_set_option(sock, APR_SO_NONBLOCK, on); - } - break; - case APR_SO_LINGER: -#ifdef SO_LINGER - if (apr_is_option_set(sock, APR_SO_LINGER) != on) { - struct linger li; - li.l_onoff = on; - li.l_linger = APR_MAX_SECS_TO_LINGER; - if (setsockopt(sock->socketdes, SOL_SOCKET, SO_LINGER, (char *) &li, sizeof(struct linger)) == -1) { - return errno; - } - apr_set_option(sock, APR_SO_LINGER, on); - } -#else - return APR_ENOTIMPL; -#endif - break; - case APR_TCP_DEFER_ACCEPT: -#if defined(TCP_DEFER_ACCEPT) - if (apr_is_option_set(sock, APR_TCP_DEFER_ACCEPT) != on) { - int optlevel = IPPROTO_TCP; - int optname = TCP_DEFER_ACCEPT; - - if (setsockopt(sock->socketdes, optlevel, optname, - (void *)&on, sizeof(int)) == -1) { - return errno; - } - apr_set_option(sock, APR_TCP_DEFER_ACCEPT, on); - } -#else - return APR_ENOTIMPL; -#endif - break; - case APR_TCP_NODELAY: -#if defined(TCP_NODELAY) - if (apr_is_option_set(sock, APR_TCP_NODELAY) != on) { - int optlevel = IPPROTO_TCP; - int optname = TCP_NODELAY; - -#if APR_HAVE_SCTP - if (sock->protocol == IPPROTO_SCTP) { - optlevel = IPPROTO_SCTP; - optname = SCTP_NODELAY; - } -#endif - if (setsockopt(sock->socketdes, optlevel, optname, (void *)&on, sizeof(int)) == -1) { - return errno; - } - apr_set_option(sock, APR_TCP_NODELAY, on); - } -#else - /* BeOS pre-BONE has TCP_NODELAY set by default. - * As it can't be turned off we might as well check if they're asking - * for it to be turned on! - */ -#ifdef BEOS - if (on == 1) - return APR_SUCCESS; - else -#endif - return APR_ENOTIMPL; -#endif - break; - case APR_TCP_NOPUSH: -#if APR_TCP_NOPUSH_FLAG - /* TCP_NODELAY and TCP_CORK are mutually exclusive on Linux - * kernels < 2.6; on newer kernels they can be used together - * and TCP_CORK takes preference, which is the desired - * behaviour. On older kernels, TCP_NODELAY must be toggled - * to "off" whilst TCP_CORK is in effect. */ - if (apr_is_option_set(sock, APR_TCP_NOPUSH) != on) { -#ifndef HAVE_TCP_NODELAY_WITH_CORK - int optlevel = IPPROTO_TCP; - int optname = TCP_NODELAY; - -#if APR_HAVE_SCTP - if (sock->protocol == IPPROTO_SCTP) { - optlevel = IPPROTO_SCTP; - optname = SCTP_NODELAY; - } -#endif - /* OK we're going to change some settings here... */ - if (apr_is_option_set(sock, APR_TCP_NODELAY) == 1 && on) { - /* Now toggle TCP_NODELAY to off, if TCP_CORK is being - * turned on: */ - int tmpflag = 0; - if (setsockopt(sock->socketdes, optlevel, optname, - (void*)&tmpflag, sizeof(int)) == -1) { - return errno; - } - apr_set_option(sock, APR_RESET_NODELAY, 1); - apr_set_option(sock, APR_TCP_NODELAY, 0); - } else if (on) { - apr_set_option(sock, APR_RESET_NODELAY, 0); - } -#endif /* HAVE_TCP_NODELAY_WITH_CORK */ - - /* OK, now we can just set the TCP_NOPUSH flag accordingly...*/ - if (setsockopt(sock->socketdes, IPPROTO_TCP, APR_TCP_NOPUSH_FLAG, - (void*)&on, sizeof(int)) == -1) { - return errno; - } - apr_set_option(sock, APR_TCP_NOPUSH, on); -#ifndef HAVE_TCP_NODELAY_WITH_CORK - if (!on && apr_is_option_set(sock, APR_RESET_NODELAY)) { - /* Now, if TCP_CORK was just turned off, turn - * TCP_NODELAY back on again if it was earlier toggled - * to off: */ - int tmpflag = 1; - if (setsockopt(sock->socketdes, optlevel, optname, - (void*)&tmpflag, sizeof(int)) == -1) { - return errno; - } - apr_set_option(sock, APR_RESET_NODELAY,0); - apr_set_option(sock, APR_TCP_NODELAY, 1); - } -#endif /* HAVE_TCP_NODELAY_WITH_CORK */ - } -#else - return APR_ENOTIMPL; -#endif - break; - case APR_INCOMPLETE_READ: - apr_set_option(sock, APR_INCOMPLETE_READ, on); - break; - case APR_IPV6_V6ONLY: -#if APR_HAVE_IPV6 && defined(IPV6_V6ONLY) - /* we don't know the initial setting of this option, - * so don't check sock->options since that optimization - * won't work - */ - if (setsockopt(sock->socketdes, IPPROTO_IPV6, IPV6_V6ONLY, - (void *)&on, sizeof(int)) == -1) { - return errno; - } - apr_set_option(sock, APR_IPV6_V6ONLY, on); -#else - return APR_ENOTIMPL; -#endif - break; - default: - return APR_EINVAL; - } - - return APR_SUCCESS; -} - - -apr_status_t apr_socket_timeout_get(apr_socket_t *sock, apr_interval_time_t *t) -{ - *t = sock->timeout; - return APR_SUCCESS; -} - - -apr_status_t apr_socket_opt_get(apr_socket_t *sock, - apr_int32_t opt, apr_int32_t *on) -{ - switch(opt) { - default: - *on = apr_is_option_set(sock, opt); - } - return APR_SUCCESS; -} - - -apr_status_t apr_socket_atmark(apr_socket_t *sock, int *atmark) -{ -#ifndef BEOS_R5 - int oobmark; - - if (ioctl(sock->socketdes, SIOCATMARK, (void*) &oobmark) < 0) - return apr_get_netos_error(); - - *atmark = (oobmark != 0); - - return APR_SUCCESS; -#else /* BEOS_R5 */ - return APR_ENOTIMPL; -#endif -} - -apr_status_t apr_gethostname(char *buf, apr_int32_t len, apr_pool_t *cont) -{ -#ifdef BEOS_R5 - if (gethostname(buf, len) == 0) { -#else - if (gethostname(buf, len) != 0) { -#endif - buf[0] = '\0'; - return errno; - } - else if (!memchr(buf, '\0', len)) { /* buffer too small */ - /* note... most platforms just truncate in this condition - * linux+glibc return an error - */ - buf[0] = '\0'; - return APR_ENAMETOOLONG; - } - return APR_SUCCESS; -} - -#if APR_HAS_SO_ACCEPTFILTER -apr_status_t apr_socket_accept_filter(apr_socket_t *sock, char *name, - char *args) -{ - struct accept_filter_arg af; - strncpy(af.af_name, name, 16); - strncpy(af.af_arg, args, 256 - 16); - - if ((setsockopt(sock->socketdes, SOL_SOCKET, SO_ACCEPTFILTER, - &af, sizeof(af))) < 0) { - return errno; - } - return APR_SUCCESS; -} -#endif diff --git a/libs/apr/network_io/win32/sendrecv.c b/libs/apr/network_io/win32/sendrecv.c deleted file mode 100644 index 3fa0c8dd..00000000 --- a/libs/apr/network_io/win32/sendrecv.c +++ /dev/null @@ -1,457 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_networkio.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_network_io.h" -#include "apr_lib.h" -#include "apr_arch_file_io.h" -#if APR_HAVE_TIME_H -#include -#endif - -/* MAX_SEGMENT_SIZE is the maximum amount of data that will be sent to a client - * in one call of TransmitFile. This number must be small enough to give the - * slowest client time to receive the data before the socket timeout triggers. - * The same problem can exist with apr_socket_send(). In that case, we rely on - * the application to adjust socket timeouts and max send segment - * sizes appropriately. - * For example, Apache will in most cases call apr_socket_send() with less - * than 8193 bytes. - */ -#define MAX_SEGMENT_SIZE 65536 -#define WSABUF_ON_STACK 50 - -APR_DECLARE(apr_status_t) apr_socket_send(apr_socket_t *sock, const char *buf, - apr_size_t *len) -{ - apr_ssize_t rv; - WSABUF wsaData; - int lasterror; - DWORD dwBytes = 0; - - wsaData.len = (u_long)*len; - wsaData.buf = (char*) buf; - -#ifndef _WIN32_WCE - rv = WSASend(sock->socketdes, &wsaData, 1, &dwBytes, 0, NULL, NULL); -#else - rv = send(sock->socketdes, wsaData.buf, wsaData.len, 0); - dwBytes = rv; -#endif - if (rv == SOCKET_ERROR) { - lasterror = apr_get_netos_error(); - *len = 0; - return lasterror; - } - - *len = dwBytes; - - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_socket_recv(apr_socket_t *sock, char *buf, - apr_size_t *len) -{ - apr_ssize_t rv; - WSABUF wsaData; - int lasterror; - DWORD dwBytes = 0; - DWORD flags = 0; - - wsaData.len = (u_long)*len; - wsaData.buf = (char*) buf; - -#ifndef _WIN32_WCE - rv = WSARecv(sock->socketdes, &wsaData, 1, &dwBytes, &flags, NULL, NULL); -#else - rv = recv(sock->socketdes, wsaData.buf, wsaData.len, 0); - dwBytes = rv; -#endif - if (rv == SOCKET_ERROR) { - lasterror = apr_get_netos_error(); - *len = 0; - return lasterror; - } - - *len = dwBytes; - return dwBytes == 0 ? APR_EOF : APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_socket_sendv(apr_socket_t *sock, - const struct iovec *vec, - apr_int32_t in_vec, apr_size_t *nbytes) -{ - apr_status_t rc = APR_SUCCESS; - apr_ssize_t rv; - apr_size_t cur_len; - apr_int32_t nvec = 0; - int i, j = 0; - DWORD dwBytes = 0; - WSABUF *pWsaBuf; - - for (i = 0; i < in_vec; i++) { - cur_len = vec[i].iov_len; - nvec++; - while (cur_len > APR_DWORD_MAX) { - nvec++; - cur_len -= APR_DWORD_MAX; - } - } - - pWsaBuf = (nvec <= WSABUF_ON_STACK) ? _alloca(sizeof(WSABUF) * (nvec)) - : malloc(sizeof(WSABUF) * (nvec)); - if (!pWsaBuf) - return APR_ENOMEM; - - for (i = 0; i < in_vec; i++) { - char * base = vec[i].iov_base; - cur_len = vec[i].iov_len; - - do { - if (cur_len > APR_DWORD_MAX) { - pWsaBuf[j].buf = base; - pWsaBuf[j].len = APR_DWORD_MAX; - cur_len -= APR_DWORD_MAX; - base += APR_DWORD_MAX; - } - else { - pWsaBuf[j].buf = base; - pWsaBuf[j].len = (DWORD)cur_len; - cur_len = 0; - } - j++; - - } while (cur_len > 0); - } -#ifndef _WIN32_WCE - rv = WSASend(sock->socketdes, pWsaBuf, nvec, &dwBytes, 0, NULL, NULL); - if (rv == SOCKET_ERROR) { - rc = apr_get_netos_error(); - } -#else - for (i = 0; i < nvec; i++) { - rv = send(sock->socketdes, pWsaBuf[i].buf, pWsaBuf[i].len, 0); - if (rv == SOCKET_ERROR) { - rc = apr_get_netos_error(); - break; - } - dwBytes += rv; - } -#endif - if (nvec > WSABUF_ON_STACK) - free(pWsaBuf); - - *nbytes = dwBytes; - return rc; -} - - -APR_DECLARE(apr_status_t) apr_socket_sendto(apr_socket_t *sock, - apr_sockaddr_t *where, - apr_int32_t flags, const char *buf, - apr_size_t *len) -{ - apr_ssize_t rv; - - rv = sendto(sock->socketdes, buf, (int)*len, flags, - (const struct sockaddr*)&where->sa, - where->salen); - if (rv == SOCKET_ERROR) { - *len = 0; - return apr_get_netos_error(); - } - - *len = rv; - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_socket_recvfrom(apr_sockaddr_t *from, - apr_socket_t *sock, - apr_int32_t flags, - char *buf, apr_size_t *len) -{ - apr_ssize_t rv; - - from->salen = sizeof(from->sa); - - rv = recvfrom(sock->socketdes, buf, (int)*len, flags, - (struct sockaddr*)&from->sa, &from->salen); - if (rv == SOCKET_ERROR) { - (*len) = 0; - return apr_get_netos_error(); - } - - apr_sockaddr_vars_set(from, from->sa.sin.sin_family, - ntohs(from->sa.sin.sin_port)); - - (*len) = rv; - if (rv == 0 && sock->type == SOCK_STREAM) - return APR_EOF; - - return APR_SUCCESS; -} - - -#if APR_HAS_SENDFILE -static apr_status_t collapse_iovec(char **off, apr_size_t *len, - struct iovec *iovec, int numvec, - char *buf, apr_size_t buflen) -{ - if (numvec == 1) { - *off = iovec[0].iov_base; - *len = iovec[0].iov_len; - } - else { - int i; - for (i = 0; i < numvec; i++) { - *len += iovec[i].iov_len; - } - - if (*len > buflen) { - *len = 0; - return APR_INCOMPLETE; - } - - *off = buf; - - for (i = 0; i < numvec; i++) { - memcpy(buf, iovec[i].iov_base, iovec[i].iov_len); - buf += iovec[i].iov_len; - } - } - return APR_SUCCESS; -} - - -/* - * apr_status_t apr_socket_sendfile(apr_socket_t *, apr_file_t *, apr_hdtr_t *, - * apr_off_t *, apr_size_t *, apr_int32_t flags) - * Send a file from an open file descriptor to a socket, along with - * optional headers and trailers - * arg 1) The socket to which we're writing - * arg 2) The open file from which to read - * arg 3) A structure containing the headers and trailers to send - * arg 4) Offset into the file where we should begin writing - * arg 5) Number of bytes to send out of the file - * arg 6) APR flags that are mapped to OS specific flags - */ -APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock, - apr_file_t *file, - apr_hdtr_t *hdtr, - apr_off_t *offset, - apr_size_t *len, - apr_int32_t flags) -{ - apr_status_t status = APR_SUCCESS; - apr_status_t rv; - apr_off_t curoff = *offset; - DWORD dwFlags = 0; - apr_size_t nbytes; - TRANSMIT_FILE_BUFFERS tfb, *ptfb = NULL; - apr_size_t bytes_to_send; /* Bytes to send out of the file (not including headers) */ - int disconnected = 0; - int sendv_trailers = 0; - char hdtrbuf[4096]; - - if (apr_os_level < APR_WIN_NT) { - return APR_ENOTIMPL; - } - - /* Use len to keep track of number of total bytes sent (including headers) */ - bytes_to_send = *len; - *len = 0; - - /* Handle the goofy case of sending headers/trailers and a zero byte file */ - if (!bytes_to_send && hdtr) { - if (hdtr->numheaders) { - rv = apr_socket_sendv(sock, hdtr->headers, hdtr->numheaders, - &nbytes); - if (rv != APR_SUCCESS) - return rv; - *len += nbytes; - } - if (hdtr->numtrailers) { - rv = apr_socket_sendv(sock, hdtr->trailers, hdtr->numtrailers, - &nbytes); - if (rv != APR_SUCCESS) - return rv; - *len += nbytes; - } - return APR_SUCCESS; - } - - memset(&tfb, '\0', sizeof (tfb)); - - /* Collapse the headers into a single buffer */ - if (hdtr && hdtr->numheaders) { - apr_size_t head_length = tfb.HeadLength; - ptfb = &tfb; - nbytes = 0; - rv = collapse_iovec((char **)&ptfb->Head, &head_length, - hdtr->headers, hdtr->numheaders, - hdtrbuf, sizeof(hdtrbuf)); - - tfb.HeadLength = (DWORD)head_length; - - /* If not enough buffer, punt to sendv */ - if (rv == APR_INCOMPLETE) { - rv = apr_socket_sendv(sock, hdtr->headers, hdtr->numheaders, &nbytes); - if (rv != APR_SUCCESS) - return rv; - *len += nbytes; - ptfb = NULL; - } - } - - /* Initialize the overlapped structure used on TransmitFile - */ - if (!sock->overlapped) { - sock->overlapped = apr_pcalloc(sock->pool, sizeof(OVERLAPPED)); - sock->overlapped->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - } - while (bytes_to_send) { - DWORD xmitbytes; - - if (bytes_to_send > MAX_SEGMENT_SIZE) { - xmitbytes = MAX_SEGMENT_SIZE; - } - else { - /* Last call to TransmitFile() */ - xmitbytes = (DWORD)bytes_to_send; - /* Collapse the trailers into a single buffer */ - if (hdtr && hdtr->numtrailers) { - apr_size_t tail_length = tfb.TailLength; - ptfb = &tfb; - rv = collapse_iovec((char**) &ptfb->Tail, &tail_length, - hdtr->trailers, hdtr->numtrailers, - hdtrbuf + ptfb->HeadLength, - sizeof(hdtrbuf) - ptfb->HeadLength); - - tfb.TailLength = (DWORD)tail_length; - - if (rv == APR_INCOMPLETE) { - /* If not enough buffer, punt to sendv, later */ - sendv_trailers = 1; - } - } - /* Disconnect the socket after last send */ - if ((flags & APR_SENDFILE_DISCONNECT_SOCKET) - && !sendv_trailers) { - dwFlags |= TF_REUSE_SOCKET; - dwFlags |= TF_DISCONNECT; - disconnected = 1; - } - } - - sock->overlapped->Offset = (DWORD)(curoff); -#if APR_HAS_LARGE_FILES - sock->overlapped->OffsetHigh = (DWORD)(curoff >> 32); -#endif - /* XXX BoundsChecker claims dwFlags must not be zero. */ - rv = TransmitFile(sock->socketdes, /* socket */ - file->filehand, /* open file descriptor of the file to be sent */ - xmitbytes, /* number of bytes to send. 0=send all */ - 0, /* Number of bytes per send. 0=use default */ - sock->overlapped, /* OVERLAPPED structure */ - ptfb, /* header and trailer buffers */ - dwFlags); /* flags to control various aspects of TransmitFile */ - if (!rv) { - status = apr_get_netos_error(); - if ((status == APR_FROM_OS_ERROR(ERROR_IO_PENDING)) || - (status == APR_FROM_OS_ERROR(WSA_IO_PENDING))) - { - rv = WaitForSingleObject(sock->overlapped->hEvent, - (DWORD)(sock->timeout >= 0 - ? sock->timeout_ms : INFINITE)); - if (rv == WAIT_OBJECT_0) { - status = APR_SUCCESS; - if (!disconnected) { - if (!WSAGetOverlappedResult(sock->socketdes, - sock->overlapped, - &xmitbytes, - FALSE, - &dwFlags)) { - status = apr_get_netos_error(); - } - /* Ugly code alert: WSAGetOverlappedResult returns - * a count of all bytes sent. This loop only - * tracks bytes sent out of the file. - */ - else if (ptfb) { - xmitbytes -= (ptfb->HeadLength + ptfb->TailLength); - } - } - } - else if (rv == WAIT_TIMEOUT) { - status = APR_FROM_OS_ERROR(WAIT_TIMEOUT); - } - else if (rv == WAIT_ABANDONED) { - /* Hummm... WAIT_ABANDONDED is not an error code. It is - * a return specific to the Win32 WAIT functions that - * indicates that a thread exited while holding a - * mutex. Should consider triggering an assert - * to detect the condition... - */ - status = APR_FROM_OS_ERROR(WAIT_TIMEOUT); - } - else - status = apr_get_os_error(); - } - } - if (status != APR_SUCCESS) - break; - - bytes_to_send -= xmitbytes; - curoff += xmitbytes; - *len += xmitbytes; - /* Adjust len for any headers/trailers sent */ - if (ptfb) { - *len += (ptfb->HeadLength + ptfb->TailLength); - memset(&tfb, '\0', sizeof (tfb)); - ptfb = NULL; - } - } - - if (status == APR_SUCCESS) { - if (sendv_trailers) { - rv = apr_socket_sendv(sock, hdtr->trailers, hdtr->numtrailers, &nbytes); - if (rv != APR_SUCCESS) - return rv; - *len += nbytes; - } - - - /* Mark the socket as disconnected, but do not close it. - * Note: The application must have stored the socket prior to making - * the call to apr_socket_sendfile in order to either reuse it - * or close it. - */ - if (disconnected) { - sock->disconnected = 1; - sock->socketdes = INVALID_SOCKET; - } - } - - return status; -} - -#endif - diff --git a/libs/apr/network_io/win32/sockets.c b/libs/apr/network_io/win32/sockets.c deleted file mode 100644 index 1ed58d09..00000000 --- a/libs/apr/network_io/win32/sockets.c +++ /dev/null @@ -1,510 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_networkio.h" -#include "apr_network_io.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_portable.h" -#include "apr_strings.h" -#include -#include "apr_arch_inherit.h" -#include "apr_arch_misc.h" - -static char generic_inaddr_any[16] = {0}; /* big enough for IPv4 or IPv6 */ - -static apr_status_t socket_cleanup(void *sock) -{ - apr_socket_t *thesocket = sock; - - if (thesocket->socketdes != INVALID_SOCKET) { - if (closesocket(thesocket->socketdes) == SOCKET_ERROR) { - return apr_get_netos_error(); - } - thesocket->socketdes = INVALID_SOCKET; - } -#if APR_HAS_SENDFILE - if (thesocket->overlapped) { - CloseHandle(thesocket->overlapped->hEvent); - thesocket->overlapped = NULL; - } -#endif - return APR_SUCCESS; -} - -static void set_socket_vars(apr_socket_t *sock, int family, int type, int protocol) -{ - sock->type = type; - sock->protocol = protocol; - apr_sockaddr_vars_set(sock->local_addr, family, 0); - apr_sockaddr_vars_set(sock->remote_addr, family, 0); -#if APR_HAVE_IPV6 - /* hard-coded behavior for older Windows IPv6 */ - if (apr_os_level < APR_WIN_VISTA && family == AF_INET6) { - apr_set_option(sock, APR_IPV6_V6ONLY, 1); - } -#endif -} -static void alloc_socket(apr_socket_t **new, apr_pool_t *p) -{ - *new = (apr_socket_t *)apr_pcalloc(p, sizeof(apr_socket_t)); - (*new)->pool = p; - (*new)->local_addr = (apr_sockaddr_t *)apr_pcalloc((*new)->pool, - sizeof(apr_sockaddr_t)); - (*new)->local_addr->pool = p; - - (*new)->remote_addr = (apr_sockaddr_t *)apr_pcalloc((*new)->pool, - sizeof(apr_sockaddr_t)); - (*new)->remote_addr->pool = p; - (*new)->remote_addr_unknown = 1; - - /* Create a pollset with room for one descriptor. */ - /* ### check return codes */ - (void) apr_pollset_create(&(*new)->pollset, 1, p, 0); -} - -APR_DECLARE(apr_status_t) apr_socket_protocol_get(apr_socket_t *sock, - int *protocol) -{ - *protocol = sock->protocol; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new, int family, - int type, int protocol, - apr_pool_t *cont) -{ -#if APR_HAVE_IPV6 - int downgrade = (family == AF_UNSPEC); -#endif - - if (family == AF_UNSPEC) { -#if APR_HAVE_IPV6 - family = AF_INET6; -#else - family = AF_INET; -#endif - } - - alloc_socket(new, cont); - - /* For right now, we are not using socket groups. We may later. - * No flags to use when creating a socket, so use 0 for that parameter as well. - */ - (*new)->socketdes = socket(family, type, protocol); -#if APR_HAVE_IPV6 - if ((*new)->socketdes == INVALID_SOCKET && downgrade) { - family = AF_INET; - (*new)->socketdes = socket(family, type, protocol); - } -#endif - - if ((*new)->socketdes == INVALID_SOCKET) { - return apr_get_netos_error(); - } - -#ifdef WIN32 - /* Socket handles are never truly inheritable, there are too many - * bugs associated. WSADuplicateSocket will copy them, but for our - * purposes, always transform the socket() created as a non-inherited - * handle - */ -#if APR_HAS_UNICODE_FS && !defined(_WIN32_WCE) - IF_WIN_OS_IS_UNICODE { - /* A different approach. Many users report errors such as - * (32538)An operation was attempted on something that is not - * a socket. : Parent: WSADuplicateSocket failed... - * - * This appears that the duplicated handle is no longer recognized - * as a socket handle. SetHandleInformation should overcome that - * problem by not altering the handle identifier. But this won't - * work on 9x - it's unsupported. - */ - SetHandleInformation((HANDLE) (*new)->socketdes, - HANDLE_FLAG_INHERIT, 0); - } -#if APR_HAS_ANSI_FS - /* only if APR_HAS_ANSI_FS && APR_HAS_UNICODE_FS */ - ELSE_WIN_OS_IS_ANSI -#endif -#endif -#if APR_HAS_ANSI_FS || defined(_WIN32_WCE) - { - HANDLE hProcess = GetCurrentProcess(); - HANDLE dup; - if (DuplicateHandle(hProcess, (HANDLE) (*new)->socketdes, hProcess, - &dup, 0, FALSE, DUPLICATE_SAME_ACCESS)) { - closesocket((*new)->socketdes); - (*new)->socketdes = (SOCKET) dup; - } - } -#endif - -#endif /* def WIN32 */ - - set_socket_vars(*new, family, type, protocol); - - (*new)->timeout = -1; - (*new)->disconnected = 0; - - apr_pool_cleanup_register((*new)->pool, (void *)(*new), - socket_cleanup, apr_pool_cleanup_null); - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_socket_shutdown(apr_socket_t *thesocket, - apr_shutdown_how_e how) -{ - int winhow = 0; - -#ifdef SD_RECEIVE - switch (how) { - case APR_SHUTDOWN_READ: { - winhow = SD_RECEIVE; - break; - } - case APR_SHUTDOWN_WRITE: { - winhow = SD_SEND; - break; - } - case APR_SHUTDOWN_READWRITE: { - winhow = SD_BOTH; - break; - } - default: - return APR_BADARG; - } -#endif - if (shutdown(thesocket->socketdes, winhow) == 0) { - return APR_SUCCESS; - } - else { - return apr_get_netos_error(); - } -} - -APR_DECLARE(apr_status_t) apr_socket_close(apr_socket_t *thesocket) -{ - apr_pool_cleanup_kill(thesocket->pool, thesocket, socket_cleanup); - return socket_cleanup(thesocket); -} - -APR_DECLARE(apr_status_t) apr_socket_bind(apr_socket_t *sock, - apr_sockaddr_t *sa) -{ - if (bind(sock->socketdes, - (struct sockaddr *)&sa->sa, - sa->salen) == -1) { - return apr_get_netos_error(); - } - else { - sock->local_addr = sa; - if (sock->local_addr->sa.sin.sin_port == 0) { - sock->local_port_unknown = 1; /* ephemeral port */ - } - return APR_SUCCESS; - } -} - -APR_DECLARE(apr_status_t) apr_socket_listen(apr_socket_t *sock, - apr_int32_t backlog) -{ - if (listen(sock->socketdes, backlog) == SOCKET_ERROR) - return apr_get_netos_error(); - else - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_socket_accept(apr_socket_t **new, - apr_socket_t *sock, apr_pool_t *p) -{ - SOCKET s; -#if APR_HAVE_IPV6 - struct sockaddr_storage sa; -#else - struct sockaddr sa; -#endif - int salen = sizeof(sock->remote_addr->sa); - - /* Don't allocate the memory until after we call accept. This allows - us to work with nonblocking sockets. */ - s = accept(sock->socketdes, (struct sockaddr *)&sa, &salen); - if (s == INVALID_SOCKET) { - return apr_get_netos_error(); - } - - alloc_socket(new, p); - set_socket_vars(*new, sock->local_addr->sa.sin.sin_family, SOCK_STREAM, - sock->protocol); - - (*new)->timeout = -1; - (*new)->disconnected = 0; - - (*new)->socketdes = s; - /* XXX next line looks bogus w.r.t. AF_INET6 support */ - (*new)->remote_addr->salen = sizeof((*new)->remote_addr->sa); - memcpy (&(*new)->remote_addr->sa, &sa, salen); - *(*new)->local_addr = *sock->local_addr; - (*new)->remote_addr_unknown = 0; - - /* The above assignment just overwrote the pool entry. Setting the local_addr - pool for the accepted socket back to what it should be. Otherwise all - allocations for this socket will come from a server pool that is not - freed until the process goes down.*/ - (*new)->local_addr->pool = p; - - /* fix up any pointers which are no longer valid */ - if (sock->local_addr->sa.sin.sin_family == AF_INET) { - (*new)->local_addr->ipaddr_ptr = &(*new)->local_addr->sa.sin.sin_addr; - } -#if APR_HAVE_IPV6 - else if (sock->local_addr->sa.sin.sin_family == AF_INET6) { - (*new)->local_addr->ipaddr_ptr = &(*new)->local_addr->sa.sin6.sin6_addr; - } -#endif - (*new)->remote_addr->port = ntohs((*new)->remote_addr->sa.sin.sin_port); - if (sock->local_port_unknown) { - /* not likely for a listening socket, but theoretically possible :) */ - (*new)->local_port_unknown = 1; - } - -#if APR_TCP_NODELAY_INHERITED - if (apr_is_option_set(sock, APR_TCP_NODELAY) == 1) { - apr_set_option(*new, APR_TCP_NODELAY, 1); - } -#endif /* TCP_NODELAY_INHERITED */ -#if APR_O_NONBLOCK_INHERITED - if (apr_is_option_set(sock, APR_SO_NONBLOCK) == 1) { - apr_set_option(*new, APR_SO_NONBLOCK, 1); - } -#endif /* APR_O_NONBLOCK_INHERITED */ - - if (sock->local_interface_unknown || - !memcmp(sock->local_addr->ipaddr_ptr, - generic_inaddr_any, - sock->local_addr->ipaddr_len)) { - /* If the interface address inside the listening socket's local_addr wasn't - * up-to-date, we don't know local interface of the connected socket either. - * - * If the listening socket was not bound to a specific interface, we - * don't know the local_addr of the connected socket. - */ - (*new)->local_interface_unknown = 1; - } - - apr_pool_cleanup_register((*new)->pool, (void *)(*new), - socket_cleanup, apr_pool_cleanup_null); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_socket_connect(apr_socket_t *sock, - apr_sockaddr_t *sa) -{ - apr_status_t rv; - - if ((sock->socketdes == INVALID_SOCKET) || (!sock->local_addr)) { - return APR_ENOTSOCK; - } - - if (connect(sock->socketdes, (const struct sockaddr *)&sa->sa.sin, - sa->salen) == SOCKET_ERROR) { - int rc; - struct timeval tv, *tvptr; - fd_set wfdset, efdset; - - rv = apr_get_netos_error(); - if (rv != APR_FROM_OS_ERROR(WSAEWOULDBLOCK)) { - return rv; - } - - if (sock->timeout == 0) { - /* Tell the app that the connect is in progress... - * Gotta play some games here. connect on Unix will return - * EINPROGRESS under the same circumstances that Windows - * returns WSAEWOULDBLOCK. Do some adhoc canonicalization... - */ - return APR_FROM_OS_ERROR(WSAEINPROGRESS); - } - - /* wait for the connect to complete or timeout */ - FD_ZERO(&wfdset); - FD_SET(sock->socketdes, &wfdset); - FD_ZERO(&efdset); - FD_SET(sock->socketdes, &efdset); - - if (sock->timeout < 0) { - tvptr = NULL; - } - else { - /* casts for winsock/timeval definition */ - tv.tv_sec = (long)apr_time_sec(sock->timeout); - tv.tv_usec = (int)apr_time_usec(sock->timeout); - tvptr = &tv; - } - rc = select(FD_SETSIZE+1, NULL, &wfdset, &efdset, tvptr); - if (rc == SOCKET_ERROR) { - return apr_get_netos_error(); - } - else if (!rc) { - return APR_FROM_OS_ERROR(WSAETIMEDOUT); - } - /* Evaluate the efdset */ - if (FD_ISSET(sock->socketdes, &efdset)) { - /* The connect failed. */ - int rclen = sizeof(rc); - if (getsockopt(sock->socketdes, SOL_SOCKET, SO_ERROR, (char*) &rc, &rclen)) { - return apr_get_netos_error(); - } - return APR_FROM_OS_ERROR(rc); - } - } - /* connect was OK .. amazing */ - sock->remote_addr = sa; - if (sock->local_addr->sa.sin.sin_port == 0) { - sock->local_port_unknown = 1; - } - if (!memcmp(sock->local_addr->ipaddr_ptr, - generic_inaddr_any, - sock->local_addr->ipaddr_len)) { - /* not bound to specific local interface; connect() had to assign - * one for the socket - */ - sock->local_interface_unknown = 1; - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_socket_type_get(apr_socket_t *sock, int *type) -{ - *type = sock->type; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_socket_data_get(void **data, const char *key, - apr_socket_t *sock) -{ - sock_userdata_t *cur = sock->userdata; - - *data = NULL; - - while (cur) { - if (!strcmp(cur->key, key)) { - *data = cur->data; - break; - } - cur = cur->next; - } - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_socket_data_set(apr_socket_t *sock, void *data, - const char *key, - apr_status_t (*cleanup)(void *)) -{ - sock_userdata_t *new = apr_palloc(sock->pool, sizeof(sock_userdata_t)); - - new->key = apr_pstrdup(sock->pool, key); - new->data = data; - new->next = sock->userdata; - sock->userdata = new; - - if (cleanup) { - apr_pool_cleanup_register(sock->pool, data, cleanup, cleanup); - } - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_sock_get(apr_os_sock_t *thesock, - apr_socket_t *sock) -{ - *thesock = sock->socketdes; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_sock_make(apr_socket_t **apr_sock, - apr_os_sock_info_t *os_sock_info, - apr_pool_t *cont) -{ - alloc_socket(apr_sock, cont); - set_socket_vars(*apr_sock, os_sock_info->family, os_sock_info->type, os_sock_info->protocol); - (*apr_sock)->timeout = -1; - (*apr_sock)->disconnected = 0; - (*apr_sock)->socketdes = *os_sock_info->os_sock; - if (os_sock_info->local) { - memcpy(&(*apr_sock)->local_addr->sa.sin, - os_sock_info->local, - (*apr_sock)->local_addr->salen); - (*apr_sock)->local_addr->pool = cont; - /* XXX IPv6 - this assumes sin_port and sin6_port at same offset */ - (*apr_sock)->local_addr->port = ntohs((*apr_sock)->local_addr->sa.sin.sin_port); - } - else { - (*apr_sock)->local_port_unknown = (*apr_sock)->local_interface_unknown = 1; - } - if (os_sock_info->remote) { - memcpy(&(*apr_sock)->remote_addr->sa.sin, - os_sock_info->remote, - (*apr_sock)->remote_addr->salen); - (*apr_sock)->remote_addr->pool = cont; - /* XXX IPv6 - this assumes sin_port and sin6_port at same offset */ - (*apr_sock)->remote_addr->port = ntohs((*apr_sock)->remote_addr->sa.sin.sin_port); - (*apr_sock)->remote_addr_unknown = 0; - } - - apr_pool_cleanup_register((*apr_sock)->pool, (void *)(*apr_sock), - socket_cleanup, apr_pool_cleanup_null); - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_sock_put(apr_socket_t **sock, - apr_os_sock_t *thesock, - apr_pool_t *cont) -{ - if ((*sock) == NULL) { - alloc_socket(sock, cont); - /* XXX figure out the actual socket type here */ - /* *or* just decide that apr_os_sock_put() has to be told the family and type */ - set_socket_vars(*sock, AF_INET, SOCK_STREAM, 0); - (*sock)->timeout = -1; - (*sock)->disconnected = 0; - } - (*sock)->local_port_unknown = (*sock)->local_interface_unknown = 1; - (*sock)->remote_addr_unknown = 1; - (*sock)->socketdes = *thesock; - return APR_SUCCESS; -} - - -/* Sockets cannot be inherited through the standard sockets - * inheritence. WSADuplicateSocket must be used. - * This is not trivial to implement. - */ - -APR_DECLARE(apr_status_t) apr_socket_inherit_set(apr_socket_t *socket) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_socket_inherit_unset(apr_socket_t *socket) -{ - return APR_ENOTIMPL; -} - -APR_POOL_IMPLEMENT_ACCESSOR(socket); diff --git a/libs/apr/network_io/win32/sockopt.c b/libs/apr/network_io/win32/sockopt.c deleted file mode 100644 index 5914dfa8..00000000 --- a/libs/apr/network_io/win32/sockopt.c +++ /dev/null @@ -1,292 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_networkio.h" -#include "apr_arch_misc.h" /* apr_os_level */ -#include "apr_network_io.h" -#include "apr_general.h" -#include "apr_strings.h" -#include - -/* IPV6_V6ONLY is missing from pre-Windows 2008 SDK as well as MinGW - * (at least up through 1.0.16). - * Runtime support is a separate issue. - */ -#ifndef IPV6_V6ONLY -#define IPV6_V6ONLY 27 -#endif - -static apr_status_t soblock(SOCKET sd) -{ - u_long zero = 0; - - if (ioctlsocket(sd, FIONBIO, &zero) == SOCKET_ERROR) { - return apr_get_netos_error(); - } - return APR_SUCCESS; -} - -static apr_status_t sononblock(SOCKET sd) -{ - u_long one = 1; - - if (ioctlsocket(sd, FIONBIO, &one) == SOCKET_ERROR) { - return apr_get_netos_error(); - } - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_socket_timeout_set(apr_socket_t *sock, apr_interval_time_t t) -{ - apr_status_t stat; - - if (t == 0) { - /* Set the socket non-blocking if it was previously blocking */ - if (sock->timeout != 0) { - if ((stat = sononblock(sock->socketdes)) != APR_SUCCESS) - return stat; - } - } - else if (t > 0) { - /* Set the socket to blocking if it was previously non-blocking */ - if (sock->timeout == 0) { - if ((stat = soblock(sock->socketdes)) != APR_SUCCESS) - return stat; - } - /* Reset socket timeouts if the new timeout differs from the old timeout */ - if (sock->timeout != t) - { - /* Win32 timeouts are in msec, represented as int */ - sock->timeout_ms = (int)apr_time_as_msec(t); - setsockopt(sock->socketdes, SOL_SOCKET, SO_RCVTIMEO, - (char *) &sock->timeout_ms, - sizeof(sock->timeout_ms)); - setsockopt(sock->socketdes, SOL_SOCKET, SO_SNDTIMEO, - (char *) &sock->timeout_ms, - sizeof(sock->timeout_ms)); - } - } - else if (t < 0) { - int zero = 0; - /* Set the socket to blocking with infinite timeouts */ - if ((stat = soblock(sock->socketdes)) != APR_SUCCESS) - return stat; - setsockopt(sock->socketdes, SOL_SOCKET, SO_RCVTIMEO, - (char *) &zero, sizeof(zero)); - setsockopt(sock->socketdes, SOL_SOCKET, SO_SNDTIMEO, - (char *) &zero, sizeof(zero)); - } - sock->timeout = t; - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock, - apr_int32_t opt, apr_int32_t on) -{ - int one; - apr_status_t stat; - - one = on ? 1 : 0; - - switch (opt) { - case APR_SO_KEEPALIVE: - if (on != apr_is_option_set(sock, APR_SO_KEEPALIVE)) { - if (setsockopt(sock->socketdes, SOL_SOCKET, SO_KEEPALIVE, - (void *)&one, sizeof(int)) == -1) { - return apr_get_netos_error(); - } - apr_set_option(sock, APR_SO_KEEPALIVE, on); - } - break; - case APR_SO_DEBUG: - if (on != apr_is_option_set(sock, APR_SO_DEBUG)) { - if (setsockopt(sock->socketdes, SOL_SOCKET, SO_DEBUG, - (void *)&one, sizeof(int)) == -1) { - return apr_get_netos_error(); - } - apr_set_option(sock, APR_SO_DEBUG, on); - } - break; - case APR_SO_SNDBUF: - if (setsockopt(sock->socketdes, SOL_SOCKET, SO_SNDBUF, - (void *)&on, sizeof(int)) == -1) { - return apr_get_netos_error(); - } - break; - case APR_SO_RCVBUF: - if (setsockopt(sock->socketdes, SOL_SOCKET, SO_RCVBUF, - (void *)&on, sizeof(int)) == -1) { - return apr_get_netos_error(); - } - break; - case APR_SO_REUSEADDR: - if (on != apr_is_option_set(sock, APR_SO_REUSEADDR)) { - if (setsockopt(sock->socketdes, SOL_SOCKET, SO_REUSEADDR, - (void *)&one, sizeof(int)) == -1) { - return apr_get_netos_error(); - } - apr_set_option(sock, APR_SO_REUSEADDR, on); - } - break; - case APR_SO_NONBLOCK: - if (apr_is_option_set(sock, APR_SO_NONBLOCK) != on) { - if (on) { - if ((stat = sononblock(sock->socketdes)) != APR_SUCCESS) - return stat; - } - else { - if ((stat = soblock(sock->socketdes)) != APR_SUCCESS) - return stat; - } - apr_set_option(sock, APR_SO_NONBLOCK, on); - } - break; - case APR_SO_LINGER: - { - if (apr_is_option_set(sock, APR_SO_LINGER) != on) { - struct linger li; - li.l_onoff = on; - li.l_linger = APR_MAX_SECS_TO_LINGER; - if (setsockopt(sock->socketdes, SOL_SOCKET, SO_LINGER, - (char *) &li, sizeof(struct linger)) == -1) { - return apr_get_netos_error(); - } - apr_set_option(sock, APR_SO_LINGER, on); - } - break; - } - case APR_TCP_DEFER_ACCEPT: -#if defined(TCP_DEFER_ACCEPT) - if (apr_is_option_set(sock, APR_TCP_DEFER_ACCEPT) != on) { - int optlevel = IPPROTO_TCP; - int optname = TCP_DEFER_ACCEPT; - - if (setsockopt(sock->socketdes, optlevel, optname, - (void *)&on, sizeof(int)) == -1) { - return errno; - } - apr_set_option(sock, APR_TCP_DEFER_ACCEPT, on); - } -#else - return APR_ENOTIMPL; -#endif - case APR_TCP_NODELAY: - if (apr_is_option_set(sock, APR_TCP_NODELAY) != on) { - int optlevel = IPPROTO_TCP; - int optname = TCP_NODELAY; - -#if APR_HAVE_SCTP - if (sock->protocol == IPPROTO_SCTP) { - optlevel = IPPROTO_SCTP; - optname = SCTP_NODELAY; - } -#endif - if (setsockopt(sock->socketdes, optlevel, optname, - (void *)&on, sizeof(int)) == -1) { - return apr_get_netos_error(); - } - apr_set_option(sock, APR_TCP_NODELAY, on); - } - break; - case APR_IPV6_V6ONLY: -#if APR_HAVE_IPV6 - if (apr_os_level < APR_WIN_VISTA && - sock->local_addr->family == AF_INET6) { - /* apr_set_option() called at socket creation */ - if (on) { - return APR_SUCCESS; - } - else { - return APR_ENOTIMPL; - } - } - /* we don't know the initial setting of this option, - * so don't check sock->options since that optimization - * won't work - */ - if (setsockopt(sock->socketdes, IPPROTO_IPV6, IPV6_V6ONLY, - (void *)&on, sizeof(int)) == -1) { - return apr_get_netos_error(); - } - apr_set_option(sock, APR_IPV6_V6ONLY, on); -#else - return APR_ENOTIMPL; -#endif - break; - default: - return APR_EINVAL; - break; - } - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_socket_timeout_get(apr_socket_t *sock, apr_interval_time_t *t) -{ - *t = sock->timeout; - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_socket_opt_get(apr_socket_t *sock, - apr_int32_t opt, apr_int32_t *on) -{ - switch (opt) { - case APR_SO_DISCONNECTED: - *on = sock->disconnected; - break; - case APR_SO_KEEPALIVE: - case APR_SO_DEBUG: - case APR_SO_REUSEADDR: - case APR_SO_NONBLOCK: - case APR_SO_LINGER: - default: - *on = apr_is_option_set(sock, opt); - break; - } - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_socket_atmark(apr_socket_t *sock, int *atmark) -{ - u_long oobmark; - - if (ioctlsocket(sock->socketdes, SIOCATMARK, (void*) &oobmark) < 0) - return apr_get_netos_error(); - - *atmark = (oobmark != 0); - - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_gethostname(char *buf, int len, - apr_pool_t *cont) -{ - if (gethostname(buf, len) == -1) { - buf[0] = '\0'; - return apr_get_netos_error(); - } - else if (!memchr(buf, '\0', len)) { /* buffer too small */ - buf[0] = '\0'; - return APR_ENAMETOOLONG; - } - return APR_SUCCESS; -} - diff --git a/libs/apr/passwd/apr_getpass.c b/libs/apr/passwd/apr_getpass.c deleted file mode 100644 index f31cdafc..00000000 --- a/libs/apr/passwd/apr_getpass.c +++ /dev/null @@ -1,254 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* apr_password_get.c: abstraction to provide for obtaining a password from the - * command line in whatever way the OS supports. In the best case, it's a - * wrapper for the system library's getpass() routine; otherwise, we - * use one we define ourselves. - */ -#include "apr_private.h" -#include "apr_strings.h" -#include "apr_lib.h" -#include "apr_errno.h" -#if APR_HAVE_SYS_TYPES_H -#include -#endif -#if APR_HAVE_ERRNO_H -#include -#endif - -#if APR_HAVE_UNISTD_H -#include -#endif -#if APR_HAVE_CONIO_H -#ifdef _MSC_VER -#pragma warning(disable: 4032) -#include -#pragma warning(default: 4032) -#else -#include -#endif -#endif -#if APR_HAVE_STDLIB_H -#include -#endif -#if APR_HAVE_STRING_H -#include -#endif -#if APR_HAVE_STRINGS_H -#include -#endif - -/* Disable getpass() support when PASS_MAX is defined and is "small", - * for an arbitrary definition of "small". - * HP-UX truncates passwords (PR49496) so we disable getpass() for - * this platform too. - */ -#if defined(HAVE_GETPASS) && \ - (defined(PASS_MAX) && PASS_MAX < 32) || defined(__hpux) || defined(__hpux__) -#undef HAVE_GETPASS -#endif - -#if defined(HAVE_TERMIOS_H) && !defined(HAVE_GETPASS) -#include -#endif - -#if !APR_CHARSET_EBCDIC -#define LF 10 -#define CR 13 -#else /* APR_CHARSET_EBCDIC */ -#define LF '\n' -#define CR '\r' -#endif /* APR_CHARSET_EBCDIC */ - -#define MAX_STRING_LEN 256 - -#define ERR_OVERFLOW 5 - -#if !defined(HAVE_GETPASS) && !defined(HAVE_GETPASSPHRASE) && !defined(HAVE_GETPASS_R) - -/* MPE, Win32, NetWare and BeOS all lack a native getpass() */ - -#if !defined(HAVE_TERMIOS_H) && !defined(WIN32) && !defined(NETWARE) -/* - * MPE lacks getpass() and a way to suppress stdin echo. So for now, just - * issue the prompt and read the results with echo. (Ugh). - */ - -static char *get_password(const char *prompt) -{ - static char password[MAX_STRING_LEN]; - - fputs(prompt, stderr); - fgets((char *) &password, sizeof(password), stdin); - - return (char *) &password; -} - -#elif defined (HAVE_TERMIOS_H) -#include - -static char *get_password(const char *prompt) -{ - struct termios attr; - static char password[MAX_STRING_LEN]; - int n=0; - fputs(prompt, stderr); - fflush(stderr); - - if (tcgetattr(STDIN_FILENO, &attr) != 0) - return NULL; - attr.c_lflag &= ~(ECHO); - - if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &attr) != 0) - return NULL; - while ((password[n] = getchar()) != '\n') { - if (n < sizeof(password) - 1 && password[n] >= ' ' && password[n] <= '~') { - n++; - } else { - fprintf(stderr,"\n"); - fputs(prompt, stderr); - fflush(stderr); - n = 0; - } - } - - password[n] = '\0'; - printf("\n"); - if (n > (MAX_STRING_LEN - 1)) { - password[MAX_STRING_LEN - 1] = '\0'; - } - - attr.c_lflag |= ECHO; - tcsetattr(STDIN_FILENO, TCSANOW, &attr); - return (char*) &password; -} - -#else - -/* - * Windows lacks getpass(). So we'll re-implement it here. - */ - -static char *get_password(const char *prompt) -{ -/* WCE lacks console. So the getpass is unsuported - * The only way is to use the GUI so the getpass should be implemented - * on per-application basis. - */ -#ifdef _WIN32_WCE - return NULL; -#else - static char password[128]; - int n = 0; - int ch; - - fputs(prompt, stderr); - - while ((ch = _getch()) != '\r') { - if (ch == EOF) /* EOF */ { - fputs("[EOF]\n", stderr); - return NULL; - } - else if (ch == 0 || ch == 0xE0) { - /* FN Keys (0 or E0) are a sentinal for a FN code */ - ch = (ch << 4) | _getch(); - /* Catch {DELETE}, {<--}, Num{DEL} and Num{<--} */ - if ((ch == 0xE53 || ch == 0xE4B || ch == 0x053 || ch == 0x04b) && n) { - password[--n] = '\0'; - fputs("\b \b", stderr); - } - else { - fputc('\a', stderr); - } - } - else if ((ch == '\b' || ch == 127) && n) /* BS/DEL */ { - password[--n] = '\0'; - fputs("\b \b", stderr); - } - else if (ch == 3) /* CTRL+C */ { - /* _getch() bypasses Ctrl+C but not Ctrl+Break detection! */ - fputs("^C\n", stderr); - exit(-1); - } - else if (ch == 26) /* CTRL+Z */ { - fputs("^Z\n", stderr); - return NULL; - } - else if (ch == 27) /* ESC */ { - fputc('\n', stderr); - fputs(prompt, stderr); - n = 0; - } - else if ((n < sizeof(password) - 1) && !apr_iscntrl(ch)) { - password[n++] = ch; - fputc('*', stderr); - } - else { - fputc('\a', stderr); - } - } - - fputc('\n', stderr); - password[n] = '\0'; - return password; -#endif -} - -#endif /* no getchar or _getch */ - -#endif /* no getpass or getpassphrase or getpass_r */ - -/* - * Use the OS getpass() routine (or our own) to obtain a password from - * the input stream. - * - * Exit values: - * 0: Success - * 5: Partial success; entered text truncated to the size of the - * destination buffer - * - * Restrictions: Truncation also occurs according to the host system's - * getpass() semantics, or at position 255 if our own version is used, - * but the caller is *not* made aware of it unless their own buffer is - * smaller than our own. - */ - -APR_DECLARE(apr_status_t) apr_password_get(const char *prompt, char *pwbuf, apr_size_t *bufsiz) -{ - apr_status_t rv = APR_SUCCESS; -#if defined(HAVE_GETPASS_R) - if (getpass_r(prompt, pwbuf, *bufsiz) == NULL) - return APR_EINVAL; -#else -#if defined(HAVE_GETPASSPHRASE) - char *pw_got = getpassphrase(prompt); -#elif defined(HAVE_GETPASS) - char *pw_got = getpass(prompt); -#else /* use the replacement implementation above */ - char *pw_got = get_password(prompt); -#endif - - if (!pw_got) - return APR_EINVAL; - if (strlen(pw_got) >= *bufsiz) { - rv = APR_ENAMETOOLONG; - } - apr_cpystrn(pwbuf, pw_got, *bufsiz); - memset(pw_got, 0, strlen(pw_got)); -#endif /* HAVE_GETPASS_R */ - return rv; -} diff --git a/libs/apr/poll/os2/poll.c b/libs/apr/poll/os2/poll.c deleted file mode 100644 index 3c36e5e6..00000000 --- a/libs/apr/poll/os2/poll.c +++ /dev/null @@ -1,105 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_poll.h" -#include "apr_arch_networkio.h" - -APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, apr_int32_t num, - apr_int32_t *nsds, apr_interval_time_t timeout) -{ - int *pollset; - int i; - int num_read = 0, num_write = 0, num_except = 0, num_total; - int pos_read, pos_write, pos_except; - - for (i = 0; i < num; i++) { - if (aprset[i].desc_type == APR_POLL_SOCKET) { - num_read += (aprset[i].reqevents & APR_POLLIN) != 0; - num_write += (aprset[i].reqevents & APR_POLLOUT) != 0; - num_except += (aprset[i].reqevents & APR_POLLPRI) != 0; - } - } - - num_total = num_read + num_write + num_except; - pollset = alloca(sizeof(int) * num_total); - memset(pollset, 0, sizeof(int) * num_total); - - pos_read = 0; - pos_write = num_read; - pos_except = pos_write + num_write; - - for (i = 0; i < num; i++) { - if (aprset[i].desc_type == APR_POLL_SOCKET) { - if (aprset[i].reqevents & APR_POLLIN) { - pollset[pos_read++] = aprset[i].desc.s->socketdes; - } - - if (aprset[i].reqevents & APR_POLLOUT) { - pollset[pos_write++] = aprset[i].desc.s->socketdes; - } - - if (aprset[i].reqevents & APR_POLLPRI) { - pollset[pos_except++] = aprset[i].desc.s->socketdes; - } - - aprset[i].rtnevents = 0; - } - } - - if (timeout > 0) { - timeout /= 1000; /* convert microseconds to milliseconds */ - } - - i = select(pollset, num_read, num_write, num_except, timeout); - (*nsds) = i; - - if ((*nsds) < 0) { - return APR_FROM_OS_ERROR(sock_errno()); - } - - if ((*nsds) == 0) { - return APR_TIMEUP; - } - - pos_read = 0; - pos_write = num_read; - pos_except = pos_write + num_write; - - for (i = 0; i < num; i++) { - if (aprset[i].desc_type == APR_POLL_SOCKET) { - if (aprset[i].reqevents & APR_POLLIN) { - if (pollset[pos_read++] > 0) { - aprset[i].rtnevents |= APR_POLLIN; - } - } - - if (aprset[i].reqevents & APR_POLLOUT) { - if (pollset[pos_write++] > 0) { - aprset[i].rtnevents |= APR_POLLOUT; - } - } - - if (aprset[i].reqevents & APR_POLLPRI) { - if (pollset[pos_except++] > 0) { - aprset[i].rtnevents |= APR_POLLPRI; - } - } - } - } - - return APR_SUCCESS; -} diff --git a/libs/apr/poll/os2/pollset.c b/libs/apr/poll/os2/pollset.c deleted file mode 100644 index e77dc9a3..00000000 --- a/libs/apr/poll/os2/pollset.c +++ /dev/null @@ -1,230 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_poll.h" -#include "apr_arch_networkio.h" - - - -struct apr_pollset_t { - apr_pool_t *pool; - apr_uint32_t nelts; - apr_uint32_t nalloc; - int *pollset; - int num_read; - int num_write; - int num_except; - int num_total; - apr_pollfd_t *query_set; - apr_pollfd_t *result_set; -}; - - - -APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags) -{ - *pollset = apr_palloc(p, sizeof(**pollset)); - (*pollset)->pool = p; - (*pollset)->nelts = 0; - (*pollset)->nalloc = size; - (*pollset)->pollset = apr_palloc(p, size * sizeof(int) * 3); - (*pollset)->query_set = apr_palloc(p, size * sizeof(apr_pollfd_t)); - (*pollset)->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t)); - (*pollset)->num_read = -1; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_pollset_create_ex(apr_pollset_t **pollset, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags, - apr_pollset_method_e method) -{ - return apr_pollset_create(pollset, size, p, flags); -} - -APR_DECLARE(apr_status_t) apr_pollset_destroy(apr_pollset_t *pollset) -{ - /* A no-op function for now. If we later implement /dev/poll - * support, we'll need to close the /dev/poll fd here - */ - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) -{ - if (pollset->nelts == pollset->nalloc) { - return APR_ENOMEM; - } - - pollset->query_set[pollset->nelts] = *descriptor; - - if (descriptor->desc_type != APR_POLL_SOCKET) { - return APR_EBADF; - } - - pollset->nelts++; - pollset->num_read = -1; - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) -{ - apr_uint32_t i; - - for (i = 0; i < pollset->nelts; i++) { - if (descriptor->desc.s == pollset->query_set[i].desc.s) { - /* Found an instance of the fd: remove this and any other copies */ - apr_uint32_t dst = i; - apr_uint32_t old_nelts = pollset->nelts; - pollset->nelts--; - - for (i++; i < old_nelts; i++) { - if (descriptor->desc.s == pollset->query_set[i].desc.s) { - pollset->nelts--; - } - else { - pollset->pollset[dst] = pollset->pollset[i]; - pollset->query_set[dst] = pollset->query_set[i]; - dst++; - } - } - - pollset->num_read = -1; - return APR_SUCCESS; - } - } - - return APR_NOTFOUND; -} - - - -static void make_pollset(apr_pollset_t *pollset) -{ - int i; - int pos = 0; - - pollset->num_read = 0; - pollset->num_write = 0; - pollset->num_except = 0; - - for (i = 0; i < pollset->nelts; i++) { - if (pollset->query_set[i].reqevents & APR_POLLIN) { - pollset->pollset[pos++] = pollset->query_set[i].desc.s->socketdes; - pollset->num_read++; - } - } - - for (i = 0; i < pollset->nelts; i++) { - if (pollset->query_set[i].reqevents & APR_POLLOUT) { - pollset->pollset[pos++] = pollset->query_set[i].desc.s->socketdes; - pollset->num_write++; - } - } - - for (i = 0; i < pollset->nelts; i++) { - if (pollset->query_set[i].reqevents & APR_POLLPRI) { - pollset->pollset[pos++] = pollset->query_set[i].desc.s->socketdes; - pollset->num_except++; - } - } - - pollset->num_total = pollset->num_read + pollset->num_write + pollset->num_except; -} - - - -APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset, - apr_interval_time_t timeout, - apr_int32_t *num, - const apr_pollfd_t **descriptors) -{ - int rv; - apr_uint32_t i; - int *pollresult; - int read_pos, write_pos, except_pos; - - if (pollset->num_read < 0) { - make_pollset(pollset); - } - - pollresult = alloca(sizeof(int) * pollset->num_total); - memcpy(pollresult, pollset->pollset, sizeof(int) * pollset->num_total); - (*num) = 0; - - if (timeout > 0) { - timeout /= 1000; - } - - rv = select(pollresult, pollset->num_read, pollset->num_write, pollset->num_except, timeout); - - if (rv < 0) { - return APR_FROM_OS_ERROR(sock_errno()); - } - - if (rv == 0) { - return APR_TIMEUP; - } - - read_pos = 0; - write_pos = pollset->num_read; - except_pos = pollset->num_read + pollset->num_write; - - for (i = 0; i < pollset->nelts; i++) { - int rtnevents = 0; - - if (pollset->query_set[i].reqevents & APR_POLLIN) { - if (pollresult[read_pos++] != -1) { - rtnevents |= APR_POLLIN; - } - } - - if (pollset->query_set[i].reqevents & APR_POLLOUT) { - if (pollresult[write_pos++] != -1) { - rtnevents |= APR_POLLOUT; - } - } - - if (pollset->query_set[i].reqevents & APR_POLLPRI) { - if (pollresult[except_pos++] != -1) { - rtnevents |= APR_POLLPRI; - } - } - - if (rtnevents) { - pollset->result_set[*num] = pollset->query_set[i]; - pollset->result_set[*num].rtnevents = rtnevents; - (*num)++; - } - } - - if (descriptors) { - *descriptors = pollset->result_set; - } - - return APR_SUCCESS; -} diff --git a/libs/apr/poll/unix/epoll.c b/libs/apr/poll/unix/epoll.c deleted file mode 100644 index 326dac7b..00000000 --- a/libs/apr/poll/unix/epoll.c +++ /dev/null @@ -1,462 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_poll.h" -#include "apr_time.h" -#include "apr_portable.h" -#include "apr_arch_file_io.h" -#include "apr_arch_networkio.h" -#include "apr_arch_poll_private.h" -#include "apr_arch_inherit.h" - -#if defined(HAVE_EPOLL) - -static apr_int16_t get_epoll_event(apr_int16_t event) -{ - apr_int16_t rv = 0; - - if (event & APR_POLLIN) - rv |= EPOLLIN; - if (event & APR_POLLPRI) - rv |= EPOLLPRI; - if (event & APR_POLLOUT) - rv |= EPOLLOUT; - /* APR_POLLNVAL is not handled by epoll. EPOLLERR and EPOLLHUP are return-only */ - - return rv; -} - -static apr_int16_t get_epoll_revent(apr_int16_t event) -{ - apr_int16_t rv = 0; - - if (event & EPOLLIN) - rv |= APR_POLLIN; - if (event & EPOLLPRI) - rv |= APR_POLLPRI; - if (event & EPOLLOUT) - rv |= APR_POLLOUT; - if (event & EPOLLERR) - rv |= APR_POLLERR; - if (event & EPOLLHUP) - rv |= APR_POLLHUP; - /* APR_POLLNVAL is not handled by epoll. */ - - return rv; -} - -struct apr_pollset_private_t -{ - int epoll_fd; - struct epoll_event *pollset; - apr_pollfd_t *result_set; -#if APR_HAS_THREADS - /* A thread mutex to protect operations on the rings */ - apr_thread_mutex_t *ring_lock; -#endif - /* A ring containing all of the pollfd_t that are active */ - APR_RING_HEAD(pfd_query_ring_t, pfd_elem_t) query_ring; - /* A ring of pollfd_t that have been used, and then _remove()'d */ - APR_RING_HEAD(pfd_free_ring_t, pfd_elem_t) free_ring; - /* A ring of pollfd_t where rings that have been _remove()`ed but - might still be inside a _poll() */ - APR_RING_HEAD(pfd_dead_ring_t, pfd_elem_t) dead_ring; -}; - -static apr_status_t impl_pollset_cleanup(apr_pollset_t *pollset) -{ - close(pollset->p->epoll_fd); - return APR_SUCCESS; -} - - -static apr_status_t impl_pollset_create(apr_pollset_t *pollset, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags) -{ - apr_status_t rv; - int fd; - -#ifdef HAVE_EPOLL_CREATE1 - fd = epoll_create1(EPOLL_CLOEXEC); -#else - fd = epoll_create(size); -#endif - if (fd < 0) { - pollset->p = NULL; - return apr_get_netos_error(); - } - -#ifndef HAVE_EPOLL_CREATE1 - { - int flags; - - if ((flags = fcntl(fd, F_GETFD)) == -1) - return errno; - - flags |= FD_CLOEXEC; - if (fcntl(fd, F_SETFD, flags) == -1) - return errno; - } -#endif - - pollset->p = apr_palloc(p, sizeof(apr_pollset_private_t)); -#if APR_HAS_THREADS - if ((flags & APR_POLLSET_THREADSAFE) && - !(flags & APR_POLLSET_NOCOPY) && - ((rv = apr_thread_mutex_create(&pollset->p->ring_lock, - APR_THREAD_MUTEX_DEFAULT, - p)) != APR_SUCCESS)) { - pollset->p = NULL; - return rv; - } -#else - if (flags & APR_POLLSET_THREADSAFE) { - pollset->p = NULL; - return APR_ENOTIMPL; - } -#endif - pollset->p->epoll_fd = fd; - pollset->p->pollset = apr_palloc(p, size * sizeof(struct epoll_event)); - pollset->p->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t)); - - if (!(flags & APR_POLLSET_NOCOPY)) { - APR_RING_INIT(&pollset->p->query_ring, pfd_elem_t, link); - APR_RING_INIT(&pollset->p->free_ring, pfd_elem_t, link); - APR_RING_INIT(&pollset->p->dead_ring, pfd_elem_t, link); - } - return APR_SUCCESS; -} - -static apr_status_t impl_pollset_add(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) -{ - struct epoll_event ev = {0}; - int ret = -1; - pfd_elem_t *elem = NULL; - apr_status_t rv = APR_SUCCESS; - - ev.events = get_epoll_event(descriptor->reqevents); - - if (pollset->flags & APR_POLLSET_NOCOPY) { - ev.data.ptr = (void *)descriptor; - } - else { - pollset_lock_rings(); - - if (!APR_RING_EMPTY(&(pollset->p->free_ring), pfd_elem_t, link)) { - elem = APR_RING_FIRST(&(pollset->p->free_ring)); - APR_RING_REMOVE(elem, link); - } - else { - elem = (pfd_elem_t *) apr_palloc(pollset->pool, sizeof(pfd_elem_t)); - APR_RING_ELEM_INIT(elem, link); - } - elem->pfd = *descriptor; - ev.data.ptr = elem; - } - if (descriptor->desc_type == APR_POLL_SOCKET) { - ret = epoll_ctl(pollset->p->epoll_fd, EPOLL_CTL_ADD, - descriptor->desc.s->socketdes, &ev); - } - else { - ret = epoll_ctl(pollset->p->epoll_fd, EPOLL_CTL_ADD, - descriptor->desc.f->filedes, &ev); - } - - if (0 != ret) { - rv = apr_get_netos_error(); - } - - if (!(pollset->flags & APR_POLLSET_NOCOPY)) { - if (rv != APR_SUCCESS) { - APR_RING_INSERT_TAIL(&(pollset->p->free_ring), elem, pfd_elem_t, link); - } - else { - APR_RING_INSERT_TAIL(&(pollset->p->query_ring), elem, pfd_elem_t, link); - } - pollset_unlock_rings(); - } - - return rv; -} - -static apr_status_t impl_pollset_remove(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) -{ - pfd_elem_t *ep; - apr_status_t rv = APR_SUCCESS; - struct epoll_event ev = {0}; /* ignored, but must be passed with - * kernel < 2.6.9 - */ - int ret = -1; - - if (descriptor->desc_type == APR_POLL_SOCKET) { - ret = epoll_ctl(pollset->p->epoll_fd, EPOLL_CTL_DEL, - descriptor->desc.s->socketdes, &ev); - } - else { - ret = epoll_ctl(pollset->p->epoll_fd, EPOLL_CTL_DEL, - descriptor->desc.f->filedes, &ev); - } - if (ret < 0) { - rv = APR_NOTFOUND; - } - - if (!(pollset->flags & APR_POLLSET_NOCOPY)) { - pollset_lock_rings(); - - for (ep = APR_RING_FIRST(&(pollset->p->query_ring)); - ep != APR_RING_SENTINEL(&(pollset->p->query_ring), - pfd_elem_t, link); - ep = APR_RING_NEXT(ep, link)) { - - if (descriptor->desc.s == ep->pfd.desc.s) { - APR_RING_REMOVE(ep, link); - APR_RING_INSERT_TAIL(&(pollset->p->dead_ring), - ep, pfd_elem_t, link); - break; - } - } - - pollset_unlock_rings(); - } - - return rv; -} - -static apr_status_t impl_pollset_poll(apr_pollset_t *pollset, - apr_interval_time_t timeout, - apr_int32_t *num, - const apr_pollfd_t **descriptors) -{ - int ret, i, j; - apr_status_t rv = APR_SUCCESS; - apr_pollfd_t *fdptr; - - if (timeout > 0) { - timeout /= 1000; - } - - ret = epoll_wait(pollset->p->epoll_fd, pollset->p->pollset, pollset->nalloc, - timeout); - (*num) = ret; - - if (ret < 0) { - rv = apr_get_netos_error(); - } - else if (ret == 0) { - rv = APR_TIMEUP; - } - else { - for (i = 0, j = 0; i < ret; i++) { - if (pollset->flags & APR_POLLSET_NOCOPY) { - fdptr = (apr_pollfd_t *)(pollset->p->pollset[i].data.ptr); - } - else { - fdptr = &(((pfd_elem_t *) (pollset->p->pollset[i].data.ptr))->pfd); - } - /* Check if the polled descriptor is our - * wakeup pipe. In that case do not put it result set. - */ - if ((pollset->flags & APR_POLLSET_WAKEABLE) && - fdptr->desc_type == APR_POLL_FILE && - fdptr->desc.f == pollset->wakeup_pipe[0]) { - apr_pollset_drain_wakeup_pipe(pollset); - rv = APR_EINTR; - } - else { - pollset->p->result_set[j] = *fdptr; - pollset->p->result_set[j].rtnevents = - get_epoll_revent(pollset->p->pollset[i].events); - j++; - } - } - if (((*num) = j)) { /* any event besides wakeup pipe? */ - rv = APR_SUCCESS; - - if (descriptors) { - *descriptors = pollset->p->result_set; - } - } - } - - if (!(pollset->flags & APR_POLLSET_NOCOPY)) { - pollset_lock_rings(); - - /* Shift all PFDs in the Dead Ring to the Free Ring */ - APR_RING_CONCAT(&(pollset->p->free_ring), &(pollset->p->dead_ring), pfd_elem_t, link); - - pollset_unlock_rings(); - } - - return rv; -} - -static apr_pollset_provider_t impl = { - impl_pollset_create, - impl_pollset_add, - impl_pollset_remove, - impl_pollset_poll, - impl_pollset_cleanup, - "epoll" -}; - -apr_pollset_provider_t *apr_pollset_provider_epoll = &impl; - -static apr_status_t cb_cleanup(void *p_) -{ - apr_pollcb_t *pollcb = (apr_pollcb_t *) p_; - close(pollcb->fd); - return APR_SUCCESS; -} - -static apr_status_t impl_pollcb_create(apr_pollcb_t *pollcb, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags) -{ - int fd; - -#ifdef HAVE_EPOLL_CREATE1 - fd = epoll_create1(EPOLL_CLOEXEC); -#else - fd = epoll_create(size); -#endif - - if (fd < 0) { - return apr_get_netos_error(); - } - -#ifndef HAVE_EPOLL_CREATE1 - { - int flags; - - if ((flags = fcntl(fd, F_GETFD)) == -1) - return errno; - - flags |= FD_CLOEXEC; - if (fcntl(fd, F_SETFD, flags) == -1) - return errno; - } -#endif - - pollcb->fd = fd; - pollcb->pollset.epoll = apr_palloc(p, size * sizeof(struct epoll_event)); - apr_pool_cleanup_register(p, pollcb, cb_cleanup, apr_pool_cleanup_null); - - return APR_SUCCESS; -} - -static apr_status_t impl_pollcb_add(apr_pollcb_t *pollcb, - apr_pollfd_t *descriptor) -{ - struct epoll_event ev; - int ret; - - ev.events = get_epoll_event(descriptor->reqevents); - ev.data.ptr = (void *)descriptor; - - if (descriptor->desc_type == APR_POLL_SOCKET) { - ret = epoll_ctl(pollcb->fd, EPOLL_CTL_ADD, - descriptor->desc.s->socketdes, &ev); - } - else { - ret = epoll_ctl(pollcb->fd, EPOLL_CTL_ADD, - descriptor->desc.f->filedes, &ev); - } - - if (ret == -1) { - return apr_get_netos_error(); - } - - return APR_SUCCESS; -} - -static apr_status_t impl_pollcb_remove(apr_pollcb_t *pollcb, - apr_pollfd_t *descriptor) -{ - apr_status_t rv = APR_SUCCESS; - struct epoll_event ev = {0}; /* ignored, but must be passed with - * kernel < 2.6.9 - */ - int ret = -1; - - if (descriptor->desc_type == APR_POLL_SOCKET) { - ret = epoll_ctl(pollcb->fd, EPOLL_CTL_DEL, - descriptor->desc.s->socketdes, &ev); - } - else { - ret = epoll_ctl(pollcb->fd, EPOLL_CTL_DEL, - descriptor->desc.f->filedes, &ev); - } - - if (ret < 0) { - rv = APR_NOTFOUND; - } - - return rv; -} - - -static apr_status_t impl_pollcb_poll(apr_pollcb_t *pollcb, - apr_interval_time_t timeout, - apr_pollcb_cb_t func, - void *baton) -{ - int ret, i; - apr_status_t rv = APR_SUCCESS; - - if (timeout > 0) { - timeout /= 1000; - } - - ret = epoll_wait(pollcb->fd, pollcb->pollset.epoll, pollcb->nalloc, - timeout); - if (ret < 0) { - rv = apr_get_netos_error(); - } - else if (ret == 0) { - rv = APR_TIMEUP; - } - else { - for (i = 0; i < ret; i++) { - apr_pollfd_t *pollfd = (apr_pollfd_t *)(pollcb->pollset.epoll[i].data.ptr); - pollfd->rtnevents = get_epoll_revent(pollcb->pollset.epoll[i].events); - - rv = func(baton, pollfd); - if (rv) { - return rv; - } - } - } - - return rv; -} - -static apr_pollcb_provider_t impl_cb = { - impl_pollcb_create, - impl_pollcb_add, - impl_pollcb_remove, - impl_pollcb_poll, - "epoll" -}; - -apr_pollcb_provider_t *apr_pollcb_provider_epoll = &impl_cb; - -#endif /* HAVE_EPOLL */ diff --git a/libs/apr/poll/unix/kqueue.c b/libs/apr/poll/unix/kqueue.c deleted file mode 100644 index dbe785a1..00000000 --- a/libs/apr/poll/unix/kqueue.c +++ /dev/null @@ -1,480 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_poll.h" -#include "apr_time.h" -#include "apr_portable.h" -#include "apr_arch_file_io.h" -#include "apr_arch_networkio.h" -#include "apr_arch_poll_private.h" -#include "apr_arch_inherit.h" - -#ifdef HAVE_KQUEUE - -static apr_int16_t get_kqueue_revent(apr_int16_t event, apr_int16_t flags) -{ - apr_int16_t rv = 0; - - if (event == EVFILT_READ) - rv |= APR_POLLIN; - else if (event == EVFILT_WRITE) - rv |= APR_POLLOUT; - if (flags & EV_EOF) - rv |= APR_POLLHUP; - /* APR_POLLPRI, APR_POLLERR, and APR_POLLNVAL are not handled by this - * implementation. - * TODO: See if EV_ERROR + certain system errors in the returned data field - * should map to APR_POLLNVAL. - */ - return rv; -} - -struct apr_pollset_private_t -{ - int kqueue_fd; - struct kevent kevent; - apr_uint32_t setsize; - struct kevent *ke_set; - apr_pollfd_t *result_set; -#if APR_HAS_THREADS - /* A thread mutex to protect operations on the rings */ - apr_thread_mutex_t *ring_lock; -#endif - /* A ring containing all of the pollfd_t that are active */ - APR_RING_HEAD(pfd_query_ring_t, pfd_elem_t) query_ring; - /* A ring of pollfd_t that have been used, and then _remove'd */ - APR_RING_HEAD(pfd_free_ring_t, pfd_elem_t) free_ring; - /* A ring of pollfd_t where rings that have been _remove'd but - might still be inside a _poll */ - APR_RING_HEAD(pfd_dead_ring_t, pfd_elem_t) dead_ring; -}; - -static apr_status_t impl_pollset_cleanup(apr_pollset_t *pollset) -{ - close(pollset->p->kqueue_fd); - return APR_SUCCESS; -} - -static apr_status_t impl_pollset_create(apr_pollset_t *pollset, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags) -{ - apr_status_t rv; - pollset->p = apr_palloc(p, sizeof(apr_pollset_private_t)); -#if APR_HAS_THREADS - if (flags & APR_POLLSET_THREADSAFE && - ((rv = apr_thread_mutex_create(&pollset->p->ring_lock, - APR_THREAD_MUTEX_DEFAULT, - p)) != APR_SUCCESS)) { - pollset->p = NULL; - return rv; - } -#else - if (flags & APR_POLLSET_THREADSAFE) { - pollset->p = NULL; - return APR_ENOTIMPL; - } -#endif - - /* POLLIN and POLLOUT are represented in different returned - * events, so we need 2 entries per descriptor in the result set, - * both for what is returned by kevent() and what is returned to - * the caller of apr_pollset_poll() (since it doesn't spend the - * CPU to coalesce separate APR_POLLIN and APR_POLLOUT events - * for the same descriptor) - */ - pollset->p->setsize = 2 * size; - - pollset->p->ke_set = - (struct kevent *) apr_palloc(p, pollset->p->setsize * sizeof(struct kevent)); - - memset(pollset->p->ke_set, 0, pollset->p->setsize * sizeof(struct kevent)); - - pollset->p->kqueue_fd = kqueue(); - - if (pollset->p->kqueue_fd == -1) { - pollset->p = NULL; - return apr_get_netos_error(); - } - - { - int flags; - - if ((flags = fcntl(pollset->p->kqueue_fd, F_GETFD)) == -1) - return errno; - - flags |= FD_CLOEXEC; - if (fcntl(pollset->p->kqueue_fd, F_SETFD, flags) == -1) - return errno; - } - - pollset->p->result_set = apr_palloc(p, pollset->p->setsize * sizeof(apr_pollfd_t)); - - APR_RING_INIT(&pollset->p->query_ring, pfd_elem_t, link); - APR_RING_INIT(&pollset->p->free_ring, pfd_elem_t, link); - APR_RING_INIT(&pollset->p->dead_ring, pfd_elem_t, link); - - return APR_SUCCESS; -} - -static apr_status_t impl_pollset_add(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) -{ - apr_os_sock_t fd; - pfd_elem_t *elem; - apr_status_t rv = APR_SUCCESS; - - pollset_lock_rings(); - - if (!APR_RING_EMPTY(&(pollset->p->free_ring), pfd_elem_t, link)) { - elem = APR_RING_FIRST(&(pollset->p->free_ring)); - APR_RING_REMOVE(elem, link); - } - else { - elem = (pfd_elem_t *) apr_palloc(pollset->pool, sizeof(pfd_elem_t)); - APR_RING_ELEM_INIT(elem, link); - } - elem->pfd = *descriptor; - - if (descriptor->desc_type == APR_POLL_SOCKET) { - fd = descriptor->desc.s->socketdes; - } - else { - fd = descriptor->desc.f->filedes; - } - - if (descriptor->reqevents & APR_POLLIN) { - EV_SET(&pollset->p->kevent, fd, EVFILT_READ, EV_ADD, 0, 0, elem); - - if (kevent(pollset->p->kqueue_fd, &pollset->p->kevent, 1, NULL, 0, - NULL) == -1) { - rv = apr_get_netos_error(); - } - } - - if (descriptor->reqevents & APR_POLLOUT && rv == APR_SUCCESS) { - EV_SET(&pollset->p->kevent, fd, EVFILT_WRITE, EV_ADD, 0, 0, elem); - - if (kevent(pollset->p->kqueue_fd, &pollset->p->kevent, 1, NULL, 0, - NULL) == -1) { - rv = apr_get_netos_error(); - } - } - - if (rv == APR_SUCCESS) { - APR_RING_INSERT_TAIL(&(pollset->p->query_ring), elem, pfd_elem_t, link); - } - else { - APR_RING_INSERT_TAIL(&(pollset->p->free_ring), elem, pfd_elem_t, link); - } - - pollset_unlock_rings(); - - return rv; -} - -static apr_status_t impl_pollset_remove(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) -{ - pfd_elem_t *ep; - apr_status_t rv; - apr_os_sock_t fd; - - pollset_lock_rings(); - - if (descriptor->desc_type == APR_POLL_SOCKET) { - fd = descriptor->desc.s->socketdes; - } - else { - fd = descriptor->desc.f->filedes; - } - - rv = APR_NOTFOUND; /* unless at least one of the specified conditions is */ - if (descriptor->reqevents & APR_POLLIN) { - EV_SET(&pollset->p->kevent, fd, EVFILT_READ, EV_DELETE, 0, 0, NULL); - - if (kevent(pollset->p->kqueue_fd, &pollset->p->kevent, 1, NULL, 0, - NULL) != -1) { - rv = APR_SUCCESS; - } - } - - if (descriptor->reqevents & APR_POLLOUT) { - EV_SET(&pollset->p->kevent, fd, EVFILT_WRITE, EV_DELETE, 0, 0, NULL); - - if (kevent(pollset->p->kqueue_fd, &pollset->p->kevent, 1, NULL, 0, - NULL) != -1) { - rv = APR_SUCCESS; - } - } - - for (ep = APR_RING_FIRST(&(pollset->p->query_ring)); - ep != APR_RING_SENTINEL(&(pollset->p->query_ring), - pfd_elem_t, link); - ep = APR_RING_NEXT(ep, link)) { - - if (descriptor->desc.s == ep->pfd.desc.s) { - APR_RING_REMOVE(ep, link); - APR_RING_INSERT_TAIL(&(pollset->p->dead_ring), - ep, pfd_elem_t, link); - break; - } - } - - pollset_unlock_rings(); - - return rv; -} - -static apr_status_t impl_pollset_poll(apr_pollset_t *pollset, - apr_interval_time_t timeout, - apr_int32_t *num, - const apr_pollfd_t **descriptors) -{ - int ret, i, j; - struct timespec tv, *tvptr; - apr_status_t rv = APR_SUCCESS; - apr_pollfd_t fd; - - if (timeout < 0) { - tvptr = NULL; - } - else { - tv.tv_sec = (long) apr_time_sec(timeout); - tv.tv_nsec = (long) apr_time_usec(timeout) * 1000; - tvptr = &tv; - } - - ret = kevent(pollset->p->kqueue_fd, NULL, 0, pollset->p->ke_set, - pollset->p->setsize, tvptr); - (*num) = ret; - if (ret < 0) { - rv = apr_get_netos_error(); - } - else if (ret == 0) { - rv = APR_TIMEUP; - } - else { - for (i = 0, j = 0; i < ret; i++) { - fd = (((pfd_elem_t*)(pollset->p->ke_set[i].udata))->pfd); - if ((pollset->flags & APR_POLLSET_WAKEABLE) && - fd.desc_type == APR_POLL_FILE && - fd.desc.f == pollset->wakeup_pipe[0]) { - apr_pollset_drain_wakeup_pipe(pollset); - rv = APR_EINTR; - } - else { - pollset->p->result_set[j] = fd; - pollset->p->result_set[j].rtnevents = - get_kqueue_revent(pollset->p->ke_set[i].filter, - pollset->p->ke_set[i].flags); - j++; - } - } - if ((*num = j)) { /* any event besides wakeup pipe? */ - rv = APR_SUCCESS; - if (descriptors) { - *descriptors = pollset->p->result_set; - } - } - } - - - pollset_lock_rings(); - - /* Shift all PFDs in the Dead Ring to the Free Ring */ - APR_RING_CONCAT(&(pollset->p->free_ring), &(pollset->p->dead_ring), - pfd_elem_t, link); - - pollset_unlock_rings(); - - return rv; -} - -static apr_pollset_provider_t impl = { - impl_pollset_create, - impl_pollset_add, - impl_pollset_remove, - impl_pollset_poll, - impl_pollset_cleanup, - "kqueue" -}; - -apr_pollset_provider_t *apr_pollset_provider_kqueue = &impl; - -static apr_status_t cb_cleanup(void *b_) -{ - apr_pollcb_t *pollcb = (apr_pollcb_t *) b_; - close(pollcb->fd); - return APR_SUCCESS; -} - -static apr_status_t impl_pollcb_create(apr_pollcb_t *pollcb, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags) -{ - int fd; - - fd = kqueue(); - if (fd < 0) { - return apr_get_netos_error(); - } - - { - int flags; - - if ((flags = fcntl(fd, F_GETFD)) == -1) - return errno; - - flags |= FD_CLOEXEC; - if (fcntl(fd, F_SETFD, flags) == -1) - return errno; - } - - pollcb->fd = fd; - pollcb->pollset.ke = (struct kevent *)apr_pcalloc(p, 2 * size * sizeof(struct kevent)); - apr_pool_cleanup_register(p, pollcb, cb_cleanup, apr_pool_cleanup_null); - - return APR_SUCCESS; -} - -static apr_status_t impl_pollcb_add(apr_pollcb_t *pollcb, - apr_pollfd_t *descriptor) -{ - apr_os_sock_t fd; - struct kevent ev; - apr_status_t rv = APR_SUCCESS; - - if (descriptor->desc_type == APR_POLL_SOCKET) { - fd = descriptor->desc.s->socketdes; - } - else { - fd = descriptor->desc.f->filedes; - } - - if (descriptor->reqevents & APR_POLLIN) { - EV_SET(&ev, fd, EVFILT_READ, EV_ADD, 0, 0, descriptor); - - if (kevent(pollcb->fd, &ev, 1, NULL, 0, NULL) == -1) { - rv = apr_get_netos_error(); - } - } - - if (descriptor->reqevents & APR_POLLOUT && rv == APR_SUCCESS) { - EV_SET(&ev, fd, EVFILT_WRITE, EV_ADD, 0, 0, descriptor); - - if (kevent(pollcb->fd, &ev, 1, NULL, 0, NULL) == -1) { - rv = apr_get_netos_error(); - } - } - - return rv; -} - -static apr_status_t impl_pollcb_remove(apr_pollcb_t *pollcb, - apr_pollfd_t *descriptor) -{ - apr_status_t rv; - struct kevent ev; - apr_os_sock_t fd; - - if (descriptor->desc_type == APR_POLL_SOCKET) { - fd = descriptor->desc.s->socketdes; - } - else { - fd = descriptor->desc.f->filedes; - } - - rv = APR_NOTFOUND; /* unless at least one of the specified conditions is */ - if (descriptor->reqevents & APR_POLLIN) { - EV_SET(&ev, fd, EVFILT_READ, EV_DELETE, 0, 0, NULL); - - if (kevent(pollcb->fd, &ev, 1, NULL, 0, NULL) != -1) { - rv = APR_SUCCESS; - } - } - - if (descriptor->reqevents & APR_POLLOUT) { - EV_SET(&ev, fd, EVFILT_WRITE, EV_DELETE, 0, 0, NULL); - - if (kevent(pollcb->fd, &ev, 1, NULL, 0, NULL) != -1) { - rv = APR_SUCCESS; - } - } - - return rv; -} - - -static apr_status_t impl_pollcb_poll(apr_pollcb_t *pollcb, - apr_interval_time_t timeout, - apr_pollcb_cb_t func, - void *baton) -{ - int ret, i; - struct timespec tv, *tvptr; - apr_status_t rv = APR_SUCCESS; - - if (timeout < 0) { - tvptr = NULL; - } - else { - tv.tv_sec = (long) apr_time_sec(timeout); - tv.tv_nsec = (long) apr_time_usec(timeout) * 1000; - tvptr = &tv; - } - - ret = kevent(pollcb->fd, NULL, 0, pollcb->pollset.ke, 2 * pollcb->nalloc, - tvptr); - - if (ret < 0) { - rv = apr_get_netos_error(); - } - else if (ret == 0) { - rv = APR_TIMEUP; - } - else { - for (i = 0; i < ret; i++) { - apr_pollfd_t *pollfd = (apr_pollfd_t *)(pollcb->pollset.ke[i].udata); - - pollfd->rtnevents = get_kqueue_revent(pollcb->pollset.ke[i].filter, - pollcb->pollset.ke[i].flags); - - rv = func(baton, pollfd); - - if (rv) { - return rv; - } - } - } - - return rv; -} - -static apr_pollcb_provider_t impl_cb = { - impl_pollcb_create, - impl_pollcb_add, - impl_pollcb_remove, - impl_pollcb_poll, - "kqueue" -}; - -apr_pollcb_provider_t *apr_pollcb_provider_kqueue = &impl_cb; - -#endif /* HAVE_KQUEUE */ diff --git a/libs/apr/poll/unix/poll.c b/libs/apr/poll/unix/poll.c deleted file mode 100644 index 7d157367..00000000 --- a/libs/apr/poll/unix/poll.c +++ /dev/null @@ -1,440 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_poll.h" -#include "apr_time.h" -#include "apr_portable.h" -#include "apr_arch_file_io.h" -#include "apr_arch_networkio.h" -#include "apr_arch_misc.h" -#include "apr_arch_poll_private.h" - -#if defined(HAVE_POLL) - -#ifdef HAVE_ALLOCA_H -#include -#endif - -static apr_int16_t get_event(apr_int16_t event) -{ - apr_int16_t rv = 0; - - if (event & APR_POLLIN) - rv |= POLLIN; - if (event & APR_POLLPRI) - rv |= POLLPRI; - if (event & APR_POLLOUT) - rv |= POLLOUT; - /* POLLERR, POLLHUP, and POLLNVAL aren't valid as requested events */ - - return rv; -} - -static apr_int16_t get_revent(apr_int16_t event) -{ - apr_int16_t rv = 0; - - if (event & POLLIN) - rv |= APR_POLLIN; - if (event & POLLPRI) - rv |= APR_POLLPRI; - if (event & POLLOUT) - rv |= APR_POLLOUT; - if (event & POLLERR) - rv |= APR_POLLERR; - if (event & POLLHUP) - rv |= APR_POLLHUP; - if (event & POLLNVAL) - rv |= APR_POLLNVAL; - - return rv; -} - -#ifdef POLL_USES_POLL - -#define SMALL_POLLSET_LIMIT 8 - -APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, apr_int32_t num, - apr_int32_t *nsds, - apr_interval_time_t timeout) -{ - int i, num_to_poll; -#ifdef HAVE_VLA - /* XXX: I trust that this is a segv when insufficient stack exists? */ - struct pollfd pollset[num]; -#elif defined(HAVE_ALLOCA) - struct pollfd *pollset = alloca(sizeof(struct pollfd) * num); - if (!pollset) - return APR_ENOMEM; -#else - struct pollfd tmp_pollset[SMALL_POLLSET_LIMIT]; - struct pollfd *pollset; - - if (num <= SMALL_POLLSET_LIMIT) { - pollset = tmp_pollset; - } - else { - /* This does require O(n) to copy the descriptors to the internal - * mapping. - */ - pollset = malloc(sizeof(struct pollfd) * num); - /* The other option is adding an apr_pool_abort() fn to invoke - * the pool's out of memory handler - */ - if (!pollset) - return APR_ENOMEM; - } -#endif - for (i = 0; i < num; i++) { - if (aprset[i].desc_type == APR_POLL_SOCKET) { - pollset[i].fd = aprset[i].desc.s->socketdes; - } - else if (aprset[i].desc_type == APR_POLL_FILE) { - pollset[i].fd = aprset[i].desc.f->filedes; - } - else { - break; - } - pollset[i].events = get_event(aprset[i].reqevents); - } - num_to_poll = i; - - if (timeout > 0) { - timeout /= 1000; /* convert microseconds to milliseconds */ - } - - i = poll(pollset, num_to_poll, timeout); - (*nsds) = i; - - if (i > 0) { /* poll() sets revents only if an event was signalled; - * we don't promise to set rtnevents unless an event - * was signalled - */ - for (i = 0; i < num; i++) { - aprset[i].rtnevents = get_revent(pollset[i].revents); - } - } - -#if !defined(HAVE_VLA) && !defined(HAVE_ALLOCA) - if (num > SMALL_POLLSET_LIMIT) { - free(pollset); - } -#endif - - if ((*nsds) < 0) { - return apr_get_netos_error(); - } - if ((*nsds) == 0) { - return APR_TIMEUP; - } - return APR_SUCCESS; -} - - -#endif /* POLL_USES_POLL */ - -struct apr_pollset_private_t -{ - struct pollfd *pollset; - apr_pollfd_t *query_set; - apr_pollfd_t *result_set; -}; - -static apr_status_t impl_pollset_create(apr_pollset_t *pollset, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags) -{ - if (flags & APR_POLLSET_THREADSAFE) { - return APR_ENOTIMPL; - } -#ifdef WIN32 - if (!APR_HAVE_LATE_DLL_FUNC(WSAPoll)) { - return APR_ENOTIMPL; - } -#endif - pollset->p = apr_palloc(p, sizeof(apr_pollset_private_t)); - pollset->p->pollset = apr_palloc(p, size * sizeof(struct pollfd)); - pollset->p->query_set = apr_palloc(p, size * sizeof(apr_pollfd_t)); - pollset->p->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t)); - - return APR_SUCCESS; -} - -static apr_status_t impl_pollset_add(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) -{ - if (pollset->nelts == pollset->nalloc) { - return APR_ENOMEM; - } - - pollset->p->query_set[pollset->nelts] = *descriptor; - - if (descriptor->desc_type == APR_POLL_SOCKET) { - pollset->p->pollset[pollset->nelts].fd = descriptor->desc.s->socketdes; - } - else { -#if APR_FILES_AS_SOCKETS - pollset->p->pollset[pollset->nelts].fd = descriptor->desc.f->filedes; -#else - if ((pollset->flags & APR_POLLSET_WAKEABLE) && - descriptor->desc.f == pollset->wakeup_pipe[0]) - pollset->p->pollset[pollset->nelts].fd = (SOCKET)descriptor->desc.f->filedes; - else - return APR_EBADF; -#endif - } - pollset->p->pollset[pollset->nelts].events = - get_event(descriptor->reqevents); - pollset->nelts++; - - return APR_SUCCESS; -} - -static apr_status_t impl_pollset_remove(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) -{ - apr_uint32_t i; - - for (i = 0; i < pollset->nelts; i++) { - if (descriptor->desc.s == pollset->p->query_set[i].desc.s) { - /* Found an instance of the fd: remove this and any other copies */ - apr_uint32_t dst = i; - apr_uint32_t old_nelts = pollset->nelts; - pollset->nelts--; - for (i++; i < old_nelts; i++) { - if (descriptor->desc.s == pollset->p->query_set[i].desc.s) { - pollset->nelts--; - } - else { - pollset->p->pollset[dst] = pollset->p->pollset[i]; - pollset->p->query_set[dst] = pollset->p->query_set[i]; - dst++; - } - } - return APR_SUCCESS; - } - } - - return APR_NOTFOUND; -} - -static apr_status_t impl_pollset_poll(apr_pollset_t *pollset, - apr_interval_time_t timeout, - apr_int32_t *num, - const apr_pollfd_t **descriptors) -{ - int ret; - apr_status_t rv = APR_SUCCESS; -#ifdef WIN32 - apr_interval_time_t orig_timeout = timeout; -#endif - - if (timeout > 0) { - timeout /= 1000; - } -#ifdef WIN32 - /* WSAPoll() requires at least one socket. */ - if (pollset->nelts == 0) { - *num = 0; - if (orig_timeout > 0) { - apr_sleep(orig_timeout); - return APR_TIMEUP; - } - return APR_SUCCESS; - } - - ret = WSAPoll(pollset->p->pollset, pollset->nelts, (int)timeout); -#else - ret = poll(pollset->p->pollset, pollset->nelts, timeout); -#endif - (*num) = ret; - if (ret < 0) { - return apr_get_netos_error(); - } - else if (ret == 0) { - return APR_TIMEUP; - } - else { - apr_uint32_t i, j; - - for (i = 0, j = 0; i < pollset->nelts; i++) { - if (pollset->p->pollset[i].revents != 0) { - /* Check if the polled descriptor is our - * wakeup pipe. In that case do not put it result set. - */ - if ((pollset->flags & APR_POLLSET_WAKEABLE) && - pollset->p->query_set[i].desc_type == APR_POLL_FILE && - pollset->p->query_set[i].desc.f == pollset->wakeup_pipe[0]) { - apr_pollset_drain_wakeup_pipe(pollset); - rv = APR_EINTR; - } - else { - pollset->p->result_set[j] = pollset->p->query_set[i]; - pollset->p->result_set[j].rtnevents = - get_revent(pollset->p->pollset[i].revents); - j++; - } - } - } - if (((*num) = j) > 0) - rv = APR_SUCCESS; - } - if (descriptors && (*num)) - *descriptors = pollset->p->result_set; - return rv; -} - -static apr_pollset_provider_t impl = { - impl_pollset_create, - impl_pollset_add, - impl_pollset_remove, - impl_pollset_poll, - NULL, - "poll" -}; - -apr_pollset_provider_t *apr_pollset_provider_poll = &impl; - -/* Poll method pollcb. - * This is probably usable only for WIN32 having WSAPoll - */ -static apr_status_t impl_pollcb_create(apr_pollcb_t *pollcb, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags) -{ -#if APR_HAS_THREADS - return APR_ENOTIMPL; -#else - pollcb->fd = -1; -#ifdef WIN32 - if (!APR_HAVE_LATE_DLL_FUNC(WSAPoll)) { - return APR_ENOTIMPL; - } -#endif - - pollcb->pollset.ps = apr_palloc(p, size * sizeof(struct pollfd)); - pollcb->copyset = apr_palloc(p, size * sizeof(apr_pollfd_t *)); - - return APR_SUCCESS; -#endif -} - -static apr_status_t impl_pollcb_add(apr_pollcb_t *pollcb, - apr_pollfd_t *descriptor) -{ - if (pollcb->nelts == pollcb->nalloc) { - return APR_ENOMEM; - } - - if (descriptor->desc_type == APR_POLL_SOCKET) { - pollcb->pollset.ps[pollcb->nelts].fd = descriptor->desc.s->socketdes; - } - else { -#if APR_FILES_AS_SOCKETS - pollcb->pollset.ps[pollcb->nelts].fd = descriptor->desc.f->filedes; -#else - return APR_EBADF; -#endif - } - - pollcb->pollset.ps[pollcb->nelts].events = - get_event(descriptor->reqevents); - pollcb->copyset[pollcb->nelts] = descriptor; - pollcb->nelts++; - - return APR_SUCCESS; -} - -static apr_status_t impl_pollcb_remove(apr_pollcb_t *pollcb, - apr_pollfd_t *descriptor) -{ - apr_uint32_t i; - - for (i = 0; i < pollcb->nelts; i++) { - if (descriptor->desc.s == pollcb->copyset[i]->desc.s) { - /* Found an instance of the fd: remove this and any other copies */ - apr_uint32_t dst = i; - apr_uint32_t old_nelts = pollcb->nelts; - pollcb->nelts--; - for (i++; i < old_nelts; i++) { - if (descriptor->desc.s == pollcb->copyset[i]->desc.s) { - pollcb->nelts--; - } - else { - pollcb->pollset.ps[dst] = pollcb->pollset.ps[i]; - pollcb->copyset[dst] = pollcb->copyset[i]; - dst++; - } - } - return APR_SUCCESS; - } - } - - return APR_NOTFOUND; -} - -static apr_status_t impl_pollcb_poll(apr_pollcb_t *pollcb, - apr_interval_time_t timeout, - apr_pollcb_cb_t func, - void *baton) -{ - int ret; - apr_status_t rv = APR_SUCCESS; - apr_uint32_t i; - - if (timeout > 0) { - timeout /= 1000; - } -#ifdef WIN32 - ret = WSAPoll(pollcb->pollset.ps, pollcb->nelts, (int)timeout); -#else - ret = poll(pollcb->pollset.ps, pollcb->nelts, timeout); -#endif - if (ret < 0) { - return apr_get_netos_error(); - } - else if (ret == 0) { - return APR_TIMEUP; - } - else { - for (i = 0; i < pollcb->nelts; i++) { - if (pollcb->pollset.ps[i].revents != 0) { - apr_pollfd_t *pollfd = pollcb->copyset[i]; - pollfd->rtnevents = get_revent(pollcb->pollset.ps[i].revents); - rv = func(baton, pollfd); - if (rv) { - return rv; - } - } - } - } - return rv; -} - -static apr_pollcb_provider_t impl_cb = { - impl_pollcb_create, - impl_pollcb_add, - impl_pollcb_remove, - impl_pollcb_poll, - "poll" -}; - -apr_pollcb_provider_t *apr_pollcb_provider_poll = &impl_cb; - -#endif /* HAVE_POLL */ diff --git a/libs/apr/poll/unix/pollcb.c b/libs/apr/poll/unix/pollcb.c deleted file mode 100644 index 2971b021..00000000 --- a/libs/apr/poll/unix/pollcb.c +++ /dev/null @@ -1,171 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifdef WIN32 -/* POSIX defines 1024 for the FD_SETSIZE */ -#define FD_SETSIZE 1024 -#endif - -#include "apr.h" -#include "apr_poll.h" -#include "apr_time.h" -#include "apr_portable.h" -#include "apr_arch_file_io.h" -#include "apr_arch_networkio.h" -#include "apr_arch_poll_private.h" - -static apr_pollset_method_e pollset_default_method = POLLSET_DEFAULT_METHOD; -#if defined(HAVE_KQUEUE) -extern apr_pollcb_provider_t *apr_pollcb_provider_kqueue; -#endif -#if defined(HAVE_PORT_CREATE) -extern apr_pollcb_provider_t *apr_pollcb_provider_port; -#endif -#if defined(HAVE_EPOLL) -extern apr_pollcb_provider_t *apr_pollcb_provider_epoll; -#endif -#if defined(HAVE_POLL) -extern apr_pollcb_provider_t *apr_pollcb_provider_poll; -#endif - -static apr_pollcb_provider_t *pollcb_provider(apr_pollset_method_e method) -{ - apr_pollcb_provider_t *provider = NULL; - switch (method) { - case APR_POLLSET_KQUEUE: -#if defined(HAVE_KQUEUE) - provider = apr_pollcb_provider_kqueue; -#endif - break; - case APR_POLLSET_PORT: -#if defined(HAVE_PORT_CREATE) - provider = apr_pollcb_provider_port; -#endif - break; - case APR_POLLSET_EPOLL: -#if defined(HAVE_EPOLL) - provider = apr_pollcb_provider_epoll; -#endif - break; - case APR_POLLSET_POLL: -#if defined(HAVE_POLL) - provider = apr_pollcb_provider_poll; -#endif - break; - case APR_POLLSET_SELECT: - case APR_POLLSET_DEFAULT: - break; - } - return provider; -} - -APR_DECLARE(apr_status_t) apr_pollcb_create_ex(apr_pollcb_t **ret_pollcb, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags, - apr_pollset_method_e method) -{ - apr_status_t rv; - apr_pollcb_t *pollcb; - apr_pollcb_provider_t *provider = NULL; - - *ret_pollcb = NULL; - - #ifdef WIN32 - /* This will work only if ws2_32.dll has WSAPoll funtion. - * We could check the presence of the function here, - * but someone might implement other pollcb method in - * the future. - */ - if (method == APR_POLLSET_DEFAULT) { - method = APR_POLLSET_POLL; - } - #endif - - if (method == APR_POLLSET_DEFAULT) - method = pollset_default_method; - while (provider == NULL) { - provider = pollcb_provider(method); - if (!provider) { - if ((flags & APR_POLLSET_NODEFAULT) == APR_POLLSET_NODEFAULT) - return APR_ENOTIMPL; - if (method == pollset_default_method) - return APR_ENOTIMPL; - method = pollset_default_method; - } - } - - pollcb = apr_palloc(p, sizeof(*pollcb)); - pollcb->nelts = 0; - pollcb->nalloc = size; - pollcb->pool = p; - pollcb->provider = provider; - - rv = (*provider->create)(pollcb, size, p, flags); - if (rv == APR_ENOTIMPL) { - if (method == pollset_default_method) { - return rv; - } - - if ((flags & APR_POLLSET_NODEFAULT) == APR_POLLSET_NODEFAULT) { - return rv; - } - - /* Try with default provider */ - provider = pollcb_provider(pollset_default_method); - if (!provider) { - return APR_ENOTIMPL; - } - rv = (*provider->create)(pollcb, size, p, flags); - if (rv != APR_SUCCESS) { - return rv; - } - pollcb->provider = provider; - } - - *ret_pollcb = pollcb; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_pollcb_create(apr_pollcb_t **pollcb, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags) -{ - apr_pollset_method_e method = APR_POLLSET_DEFAULT; - return apr_pollcb_create_ex(pollcb, size, p, flags, method); -} - -APR_DECLARE(apr_status_t) apr_pollcb_add(apr_pollcb_t *pollcb, - apr_pollfd_t *descriptor) -{ - return (*pollcb->provider->add)(pollcb, descriptor); -} - -APR_DECLARE(apr_status_t) apr_pollcb_remove(apr_pollcb_t *pollcb, - apr_pollfd_t *descriptor) -{ - return (*pollcb->provider->remove)(pollcb, descriptor); -} - - -APR_DECLARE(apr_status_t) apr_pollcb_poll(apr_pollcb_t *pollcb, - apr_interval_time_t timeout, - apr_pollcb_cb_t func, - void *baton) -{ - return (*pollcb->provider->poll)(pollcb, timeout, func, baton); -} diff --git a/libs/apr/poll/unix/pollset.c b/libs/apr/poll/unix/pollset.c deleted file mode 100644 index 1a7396b4..00000000 --- a/libs/apr/poll/unix/pollset.c +++ /dev/null @@ -1,344 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifdef WIN32 -/* POSIX defines 1024 for the FD_SETSIZE */ -#define FD_SETSIZE 1024 -#endif - -#include "apr.h" -#include "apr_poll.h" -#include "apr_time.h" -#include "apr_portable.h" -#include "apr_arch_file_io.h" -#include "apr_arch_networkio.h" -#include "apr_arch_poll_private.h" -#include "apr_arch_inherit.h" - -static apr_pollset_method_e pollset_default_method = POLLSET_DEFAULT_METHOD; - -#if !APR_FILES_AS_SOCKETS -#if defined (WIN32) - -/* Create a dummy wakeup socket pipe for interrupting the poller - */ -static apr_status_t create_wakeup_pipe(apr_pollset_t *pollset) -{ - apr_status_t rv; - - if ((rv = apr_file_socket_pipe_create(&pollset->wakeup_pipe[0], - &pollset->wakeup_pipe[1], - pollset->pool)) != APR_SUCCESS) - return rv; - - pollset->wakeup_pfd.p = pollset->pool; - pollset->wakeup_pfd.reqevents = APR_POLLIN; - pollset->wakeup_pfd.desc_type = APR_POLL_FILE; - pollset->wakeup_pfd.desc.f = pollset->wakeup_pipe[0]; - - return apr_pollset_add(pollset, &pollset->wakeup_pfd); -} - -#else /* !WIN32 */ -static apr_status_t create_wakeup_pipe(apr_pollset_t *pollset) -{ - return APR_ENOTIMPL; -} - -static apr_status_t apr_file_socket_pipe_close(apr_file_t *file) -{ - return APR_ENOTIMPL; -} - -#endif /* WIN32 */ -#else /* APR_FILES_AS_SOCKETS */ - -/* Create a dummy wakeup pipe for interrupting the poller - */ -static apr_status_t create_wakeup_pipe(apr_pollset_t *pollset) -{ - apr_status_t rv; - - if ((rv = apr_file_pipe_create(&pollset->wakeup_pipe[0], - &pollset->wakeup_pipe[1], - pollset->pool)) != APR_SUCCESS) - return rv; - - pollset->wakeup_pfd.p = pollset->pool; - pollset->wakeup_pfd.reqevents = APR_POLLIN; - pollset->wakeup_pfd.desc_type = APR_POLL_FILE; - pollset->wakeup_pfd.desc.f = pollset->wakeup_pipe[0]; - - { - int flags; - - if ((flags = fcntl(pollset->wakeup_pipe[0]->filedes, F_GETFD)) == -1) - return errno; - - flags |= FD_CLOEXEC; - if (fcntl(pollset->wakeup_pipe[0]->filedes, F_SETFD, flags) == -1) - return errno; - } - { - int flags; - - if ((flags = fcntl(pollset->wakeup_pipe[1]->filedes, F_GETFD)) == -1) - return errno; - - flags |= FD_CLOEXEC; - if (fcntl(pollset->wakeup_pipe[1]->filedes, F_SETFD, flags) == -1) - return errno; - } - - return apr_pollset_add(pollset, &pollset->wakeup_pfd); -} -#endif /* !APR_FILES_AS_SOCKETS */ - -/* Read and discard what's ever in the wakeup pipe. - */ -void apr_pollset_drain_wakeup_pipe(apr_pollset_t *pollset) -{ - char rb[512]; - apr_size_t nr = sizeof(rb); - - while (apr_file_read(pollset->wakeup_pipe[0], rb, &nr) == APR_SUCCESS) { - /* Although we write just one byte to the other end of the pipe - * during wakeup, multiple threads could call the wakeup. - * So simply drain out from the input side of the pipe all - * the data. - */ - if (nr != sizeof(rb)) - break; - } -} - -static apr_status_t pollset_cleanup(void *p) -{ - apr_pollset_t *pollset = (apr_pollset_t *) p; - if (pollset->provider->cleanup) { - (*pollset->provider->cleanup)(pollset); - } - if (pollset->flags & APR_POLLSET_WAKEABLE) { - /* Close both sides of the wakeup pipe */ - if (pollset->wakeup_pipe[0]) { -#if APR_FILES_AS_SOCKETS - apr_file_close(pollset->wakeup_pipe[0]); -#else - apr_file_socket_pipe_close(pollset->wakeup_pipe[0]); -#endif - pollset->wakeup_pipe[0] = NULL; - } - if (pollset->wakeup_pipe[1]) { -#if APR_FILES_AS_SOCKETS - apr_file_close(pollset->wakeup_pipe[1]); -#else - apr_file_socket_pipe_close(pollset->wakeup_pipe[1]); -#endif - pollset->wakeup_pipe[1] = NULL; - } - } - - return APR_SUCCESS; -} - -#if defined(HAVE_KQUEUE) -extern apr_pollset_provider_t *apr_pollset_provider_kqueue; -#endif -#if defined(HAVE_PORT_CREATE) -extern apr_pollset_provider_t *apr_pollset_provider_port; -#endif -#if defined(HAVE_EPOLL) -extern apr_pollset_provider_t *apr_pollset_provider_epoll; -#endif -#if defined(HAVE_POLL) -extern apr_pollset_provider_t *apr_pollset_provider_poll; -#endif -extern apr_pollset_provider_t *apr_pollset_provider_select; - -static apr_pollset_provider_t *pollset_provider(apr_pollset_method_e method) -{ - apr_pollset_provider_t *provider = NULL; - switch (method) { - case APR_POLLSET_KQUEUE: -#if defined(HAVE_KQUEUE) - provider = apr_pollset_provider_kqueue; -#endif - break; - case APR_POLLSET_PORT: -#if defined(HAVE_PORT_CREATE) - provider = apr_pollset_provider_port; -#endif - break; - case APR_POLLSET_EPOLL: -#if defined(HAVE_EPOLL) - provider = apr_pollset_provider_epoll; -#endif - break; - case APR_POLLSET_POLL: -#if defined(HAVE_POLL) - provider = apr_pollset_provider_poll; -#endif - break; - case APR_POLLSET_SELECT: - provider = apr_pollset_provider_select; - break; - case APR_POLLSET_DEFAULT: - break; - } - return provider; -} - -APR_DECLARE(apr_status_t) apr_pollset_create_ex(apr_pollset_t **ret_pollset, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags, - apr_pollset_method_e method) -{ - apr_status_t rv; - apr_pollset_t *pollset; - apr_pollset_provider_t *provider = NULL; - - *ret_pollset = NULL; - - #ifdef WIN32 - /* Favor WSAPoll if supported. - * This will work only if ws2_32.dll has WSAPoll funtion. - * In other cases it will fall back to select() method unless - * the APR_POLLSET_NODEFAULT is added to the flags. - */ - if (method == APR_POLLSET_DEFAULT) { - method = APR_POLLSET_POLL; - } - #endif - - if (method == APR_POLLSET_DEFAULT) - method = pollset_default_method; - while (provider == NULL) { - provider = pollset_provider(method); - if (!provider) { - if ((flags & APR_POLLSET_NODEFAULT) == APR_POLLSET_NODEFAULT) - return APR_ENOTIMPL; - if (method == pollset_default_method) - return APR_ENOTIMPL; - method = pollset_default_method; - } - } - if (flags & APR_POLLSET_WAKEABLE) { - /* Add room for wakeup descriptor */ - size++; - } - - pollset = apr_palloc(p, sizeof(*pollset)); - pollset->nelts = 0; - pollset->nalloc = size; - pollset->pool = p; - pollset->flags = flags; - pollset->provider = provider; - - rv = (*provider->create)(pollset, size, p, flags); - if (rv == APR_ENOTIMPL) { - if (method == pollset_default_method) { - return rv; - } - provider = pollset_provider(pollset_default_method); - if (!provider) { - return APR_ENOTIMPL; - } - rv = (*provider->create)(pollset, size, p, flags); - if (rv != APR_SUCCESS) { - return rv; - } - pollset->provider = provider; - } - else if (rv != APR_SUCCESS) { - return rv; - } - if (flags & APR_POLLSET_WAKEABLE) { - /* Create wakeup pipe */ - if ((rv = create_wakeup_pipe(pollset)) != APR_SUCCESS) { - return rv; - } - } - if ((flags & APR_POLLSET_WAKEABLE) || provider->cleanup) - apr_pool_cleanup_register(p, pollset, pollset_cleanup, - apr_pool_cleanup_null); - - *ret_pollset = pollset; - return APR_SUCCESS; -} - -APR_DECLARE(const char *) apr_pollset_method_name(apr_pollset_t *pollset) -{ - return pollset->provider->name; -} - -APR_DECLARE(const char *) apr_poll_method_defname() -{ - apr_pollset_provider_t *provider = NULL; - - provider = pollset_provider(pollset_default_method); - if (provider) - return provider->name; - else - return "unknown"; -} - -APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags) -{ - apr_pollset_method_e method = APR_POLLSET_DEFAULT; - return apr_pollset_create_ex(pollset, size, p, flags, method); -} - -APR_DECLARE(apr_status_t) apr_pollset_destroy(apr_pollset_t * pollset) -{ - if (pollset->flags & APR_POLLSET_WAKEABLE || - pollset->provider->cleanup) - return apr_pool_cleanup_run(pollset->pool, pollset, - pollset_cleanup); - else - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_pollset_wakeup(apr_pollset_t *pollset) -{ - if (pollset->flags & APR_POLLSET_WAKEABLE) - return apr_file_putc(1, pollset->wakeup_pipe[1]); - else - return APR_EINIT; -} - -APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) -{ - return (*pollset->provider->add)(pollset, descriptor); -} - -APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) -{ - return (*pollset->provider->remove)(pollset, descriptor); -} - -APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset, - apr_interval_time_t timeout, - apr_int32_t *num, - const apr_pollfd_t **descriptors) -{ - return (*pollset->provider->poll)(pollset, timeout, num, descriptors); -} diff --git a/libs/apr/poll/unix/port.c b/libs/apr/poll/unix/port.c deleted file mode 100644 index 7a31c468..00000000 --- a/libs/apr/poll/unix/port.c +++ /dev/null @@ -1,577 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_poll.h" -#include "apr_time.h" -#include "apr_portable.h" -#include "apr_atomic.h" -#include "apr_arch_file_io.h" -#include "apr_arch_networkio.h" -#include "apr_arch_poll_private.h" -#include "apr_arch_inherit.h" - -#if defined(HAVE_PORT_CREATE) - -static apr_int16_t get_event(apr_int16_t event) -{ - apr_int16_t rv = 0; - - if (event & APR_POLLIN) - rv |= POLLIN; - if (event & APR_POLLPRI) - rv |= POLLPRI; - if (event & APR_POLLOUT) - rv |= POLLOUT; - /* POLLERR, POLLHUP, and POLLNVAL aren't valid as requested events */ - - return rv; -} - -static apr_int16_t get_revent(apr_int16_t event) -{ - apr_int16_t rv = 0; - - if (event & POLLIN) - rv |= APR_POLLIN; - if (event & POLLPRI) - rv |= APR_POLLPRI; - if (event & POLLOUT) - rv |= APR_POLLOUT; - if (event & POLLERR) - rv |= APR_POLLERR; - if (event & POLLHUP) - rv |= APR_POLLHUP; - if (event & POLLNVAL) - rv |= APR_POLLNVAL; - - return rv; -} - - -struct apr_pollset_private_t -{ - int port_fd; - port_event_t *port_set; - apr_pollfd_t *result_set; -#if APR_HAS_THREADS - /* A thread mutex to protect operations on the rings */ - apr_thread_mutex_t *ring_lock; -#endif - /* A ring containing all of the pollfd_t that are active */ - APR_RING_HEAD(pfd_query_ring_t, pfd_elem_t) query_ring; - /* A ring containing the pollfd_t that will be added on the - * next call to apr_pollset_poll(). - */ - APR_RING_HEAD(pfd_add_ring_t, pfd_elem_t) add_ring; - /* A ring of pollfd_t that have been used, and then _remove'd */ - APR_RING_HEAD(pfd_free_ring_t, pfd_elem_t) free_ring; - /* A ring of pollfd_t where rings that have been _remove'd but - might still be inside a _poll */ - APR_RING_HEAD(pfd_dead_ring_t, pfd_elem_t) dead_ring; - /* number of threads in poll */ - volatile apr_uint32_t waiting; -}; - -static apr_status_t call_port_getn(int port, port_event_t list[], - unsigned int max, unsigned int *nget, - apr_interval_time_t timeout) -{ - struct timespec tv, *tvptr; - int ret; - apr_status_t rv = APR_SUCCESS; - - if (timeout < 0) { - tvptr = NULL; - } - else { - tv.tv_sec = (long) apr_time_sec(timeout); - tv.tv_nsec = (long) apr_time_usec(timeout) * 1000; - tvptr = &tv; - } - - list[0].portev_user = (void *)-1; /* so we can double check that an - * event was returned - */ - - ret = port_getn(port, list, max, nget, tvptr); - /* Note: 32-bit port_getn() on Solaris 10 x86 returns large negative - * values instead of 0 when returning immediately. - */ - - if (ret == -1) { - rv = apr_get_netos_error(); - - switch(rv) { - case EINTR: - case ETIME: - if (*nget > 0 && list[0].portev_user != (void *)-1) { - /* This confusing API can return an event at the same time - * that it reports EINTR or ETIME. If that occurs, just - * report the event. With EINTR, nget can be > 0 without - * any event, so check that portev_user was filled in. - * - * (Maybe it will be simplified; see thread - * http://mail.opensolaris.org - * /pipermail/networking-discuss/2009-August/011979.html - * This code will still work afterwards.) - */ - rv = APR_SUCCESS; - break; - } - if (rv == ETIME) { - rv = APR_TIMEUP; - } - /* fall-through */ - default: - *nget = 0; - } - } - else if (*nget == 0) { - rv = APR_TIMEUP; - } - - return rv; -} - -static apr_status_t impl_pollset_cleanup(apr_pollset_t *pollset) -{ - close(pollset->p->port_fd); - return APR_SUCCESS; -} - -static apr_status_t impl_pollset_create(apr_pollset_t *pollset, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags) -{ - apr_status_t rv = APR_SUCCESS; - pollset->p = apr_palloc(p, sizeof(apr_pollset_private_t)); -#if APR_HAS_THREADS - if (flags & APR_POLLSET_THREADSAFE && - ((rv = apr_thread_mutex_create(&pollset->p->ring_lock, - APR_THREAD_MUTEX_DEFAULT, - p)) != APR_SUCCESS)) { - pollset->p = NULL; - return rv; - } -#else - if (flags & APR_POLLSET_THREADSAFE) { - pollset->p = NULL; - return APR_ENOTIMPL; - } -#endif - pollset->p->waiting = 0; - - pollset->p->port_set = apr_palloc(p, size * sizeof(port_event_t)); - - pollset->p->port_fd = port_create(); - - if (pollset->p->port_fd < 0) { - pollset->p = NULL; - return apr_get_netos_error(); - } - - { - int flags; - - if ((flags = fcntl(pollset->p->port_fd, F_GETFD)) == -1) - return errno; - - flags |= FD_CLOEXEC; - if (fcntl(pollset->p->port_fd, F_SETFD, flags) == -1) - return errno; - } - - pollset->p->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t)); - - APR_RING_INIT(&pollset->p->query_ring, pfd_elem_t, link); - APR_RING_INIT(&pollset->p->add_ring, pfd_elem_t, link); - APR_RING_INIT(&pollset->p->free_ring, pfd_elem_t, link); - APR_RING_INIT(&pollset->p->dead_ring, pfd_elem_t, link); - - return rv; -} - -static apr_status_t impl_pollset_add(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) -{ - apr_os_sock_t fd; - pfd_elem_t *elem; - int res; - apr_status_t rv = APR_SUCCESS; - - pollset_lock_rings(); - - if (!APR_RING_EMPTY(&(pollset->p->free_ring), pfd_elem_t, link)) { - elem = APR_RING_FIRST(&(pollset->p->free_ring)); - APR_RING_REMOVE(elem, link); - } - else { - elem = (pfd_elem_t *) apr_palloc(pollset->pool, sizeof(pfd_elem_t)); - APR_RING_ELEM_INIT(elem, link); - elem->on_query_ring = 0; - } - elem->pfd = *descriptor; - - if (descriptor->desc_type == APR_POLL_SOCKET) { - fd = descriptor->desc.s->socketdes; - } - else { - fd = descriptor->desc.f->filedes; - } - - /* If another thread is polling, notify the kernel immediately; otherwise, - * wait until the next call to apr_pollset_poll(). - */ - if (apr_atomic_read32(&pollset->p->waiting)) { - res = port_associate(pollset->p->port_fd, PORT_SOURCE_FD, fd, - get_event(descriptor->reqevents), (void *)elem); - - if (res < 0) { - rv = apr_get_netos_error(); - APR_RING_INSERT_TAIL(&(pollset->p->free_ring), elem, pfd_elem_t, link); - } - else { - elem->on_query_ring = 1; - APR_RING_INSERT_TAIL(&(pollset->p->query_ring), elem, pfd_elem_t, link); - } - } - else { - APR_RING_INSERT_TAIL(&(pollset->p->add_ring), elem, pfd_elem_t, link); - } - - pollset_unlock_rings(); - - return rv; -} - -static apr_status_t impl_pollset_remove(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) -{ - apr_os_sock_t fd; - pfd_elem_t *ep; - apr_status_t rv = APR_SUCCESS; - int res; - int err = 0; - int found; - - pollset_lock_rings(); - - if (descriptor->desc_type == APR_POLL_SOCKET) { - fd = descriptor->desc.s->socketdes; - } - else { - fd = descriptor->desc.f->filedes; - } - - /* Search the add ring first. This ring is often shorter, - * and it often contains the descriptor being removed. - * (For the common scenario where apr_pollset_poll() - * returns activity for the descriptor and the descriptor - * is then removed from the pollset, it will have just - * been moved to the add ring by apr_pollset_poll().) - * - * If it is on the add ring, it isn't associated with the - * event port yet/anymore. - */ - found = 0; - for (ep = APR_RING_FIRST(&(pollset->p->add_ring)); - ep != APR_RING_SENTINEL(&(pollset->p->add_ring), - pfd_elem_t, link); - ep = APR_RING_NEXT(ep, link)) { - - if (descriptor->desc.s == ep->pfd.desc.s) { - found = 1; - APR_RING_REMOVE(ep, link); - APR_RING_INSERT_TAIL(&(pollset->p->free_ring), - ep, pfd_elem_t, link); - break; - } - } - - if (!found) { - res = port_dissociate(pollset->p->port_fd, PORT_SOURCE_FD, fd); - - if (res < 0) { - /* The expected case for this failure is that another - * thread's call to port_getn() returned this fd and - * disassociated the fd from the event port, and - * impl_pollset_poll() is blocked on the ring lock, - * which this thread holds. - */ - err = errno; - rv = APR_NOTFOUND; - } - - for (ep = APR_RING_FIRST(&(pollset->p->query_ring)); - ep != APR_RING_SENTINEL(&(pollset->p->query_ring), - pfd_elem_t, link); - ep = APR_RING_NEXT(ep, link)) { - - if (descriptor->desc.s == ep->pfd.desc.s) { - APR_RING_REMOVE(ep, link); - ep->on_query_ring = 0; - APR_RING_INSERT_TAIL(&(pollset->p->dead_ring), - ep, pfd_elem_t, link); - if (ENOENT == err) { - rv = APR_SUCCESS; - } - break; - } - } - } - - pollset_unlock_rings(); - - return rv; -} - -static apr_status_t impl_pollset_poll(apr_pollset_t *pollset, - apr_interval_time_t timeout, - apr_int32_t *num, - const apr_pollfd_t **descriptors) -{ - apr_os_sock_t fd; - int ret, i, j; - unsigned int nget; - pfd_elem_t *ep; - apr_status_t rv = APR_SUCCESS; - apr_pollfd_t fp; - - nget = 1; - - pollset_lock_rings(); - - apr_atomic_inc32(&pollset->p->waiting); - - while (!APR_RING_EMPTY(&(pollset->p->add_ring), pfd_elem_t, link)) { - ep = APR_RING_FIRST(&(pollset->p->add_ring)); - APR_RING_REMOVE(ep, link); - - if (ep->pfd.desc_type == APR_POLL_SOCKET) { - fd = ep->pfd.desc.s->socketdes; - } - else { - fd = ep->pfd.desc.f->filedes; - } - - ret = port_associate(pollset->p->port_fd, PORT_SOURCE_FD, - fd, get_event(ep->pfd.reqevents), ep); - if (ret < 0) { - rv = apr_get_netos_error(); - APR_RING_INSERT_TAIL(&(pollset->p->free_ring), ep, pfd_elem_t, link); - break; - } - - ep->on_query_ring = 1; - APR_RING_INSERT_TAIL(&(pollset->p->query_ring), ep, pfd_elem_t, link); - } - - pollset_unlock_rings(); - - if (rv != APR_SUCCESS) { - apr_atomic_dec32(&pollset->p->waiting); - return rv; - } - - rv = call_port_getn(pollset->p->port_fd, pollset->p->port_set, - pollset->nalloc, &nget, timeout); - - /* decrease the waiting ASAP to reduce the window for calling - port_associate within apr_pollset_add() */ - apr_atomic_dec32(&pollset->p->waiting); - - (*num) = nget; - if (nget) { - - pollset_lock_rings(); - - for (i = 0, j = 0; i < nget; i++) { - fp = (((pfd_elem_t*)(pollset->p->port_set[i].portev_user))->pfd); - if ((pollset->flags & APR_POLLSET_WAKEABLE) && - fp.desc_type == APR_POLL_FILE && - fp.desc.f == pollset->wakeup_pipe[0]) { - apr_pollset_drain_wakeup_pipe(pollset); - rv = APR_EINTR; - } - else { - pollset->p->result_set[j] = fp; - pollset->p->result_set[j].rtnevents = - get_revent(pollset->p->port_set[i].portev_events); - - /* If the ring element is still on the query ring, move it - * to the add ring for re-association with the event port - * later. (It may have already been moved to the dead ring - * by a call to pollset_remove on another thread.) - */ - ep = (pfd_elem_t *)pollset->p->port_set[i].portev_user; - if (ep->on_query_ring) { - APR_RING_REMOVE(ep, link); - ep->on_query_ring = 0; - APR_RING_INSERT_TAIL(&(pollset->p->add_ring), ep, - pfd_elem_t, link); - } - j++; - } - } - pollset_unlock_rings(); - if ((*num = j)) { /* any event besides wakeup pipe? */ - rv = APR_SUCCESS; - if (descriptors) { - *descriptors = pollset->p->result_set; - } - } - } - - pollset_lock_rings(); - - /* Shift all PFDs in the Dead Ring to the Free Ring */ - APR_RING_CONCAT(&(pollset->p->free_ring), &(pollset->p->dead_ring), pfd_elem_t, link); - - pollset_unlock_rings(); - - return rv; -} - -static apr_pollset_provider_t impl = { - impl_pollset_create, - impl_pollset_add, - impl_pollset_remove, - impl_pollset_poll, - impl_pollset_cleanup, - "port" -}; - -apr_pollset_provider_t *apr_pollset_provider_port = &impl; - -static apr_status_t cb_cleanup(void *p_) -{ - apr_pollcb_t *pollcb = (apr_pollcb_t *) p_; - close(pollcb->fd); - return APR_SUCCESS; -} - -static apr_status_t impl_pollcb_create(apr_pollcb_t *pollcb, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags) -{ - pollcb->fd = port_create(); - - if (pollcb->fd < 0) { - return apr_get_netos_error(); - } - - { - int flags; - - if ((flags = fcntl(pollcb->fd, F_GETFD)) == -1) - return errno; - - flags |= FD_CLOEXEC; - if (fcntl(pollcb->fd, F_SETFD, flags) == -1) - return errno; - } - - pollcb->pollset.port = apr_palloc(p, size * sizeof(port_event_t)); - apr_pool_cleanup_register(p, pollcb, cb_cleanup, apr_pool_cleanup_null); - - return APR_SUCCESS; -} - -static apr_status_t impl_pollcb_add(apr_pollcb_t *pollcb, - apr_pollfd_t *descriptor) -{ - int ret, fd; - - if (descriptor->desc_type == APR_POLL_SOCKET) { - fd = descriptor->desc.s->socketdes; - } - else { - fd = descriptor->desc.f->filedes; - } - - ret = port_associate(pollcb->fd, PORT_SOURCE_FD, fd, - get_event(descriptor->reqevents), descriptor); - - if (ret == -1) { - return apr_get_netos_error(); - } - - return APR_SUCCESS; -} - -static apr_status_t impl_pollcb_remove(apr_pollcb_t *pollcb, - apr_pollfd_t *descriptor) -{ - int fd, ret; - - if (descriptor->desc_type == APR_POLL_SOCKET) { - fd = descriptor->desc.s->socketdes; - } - else { - fd = descriptor->desc.f->filedes; - } - - ret = port_dissociate(pollcb->fd, PORT_SOURCE_FD, fd); - - if (ret < 0) { - return APR_NOTFOUND; - } - - return APR_SUCCESS; -} - -static apr_status_t impl_pollcb_poll(apr_pollcb_t *pollcb, - apr_interval_time_t timeout, - apr_pollcb_cb_t func, - void *baton) -{ - apr_pollfd_t *pollfd; - apr_status_t rv; - unsigned int i, nget = 1; - - rv = call_port_getn(pollcb->fd, pollcb->pollset.port, pollcb->nalloc, - &nget, timeout); - - if (nget) { - for (i = 0; i < nget; i++) { - pollfd = (apr_pollfd_t *)(pollcb->pollset.port[i].portev_user); - pollfd->rtnevents = get_revent(pollcb->pollset.port[i].portev_events); - - rv = func(baton, pollfd); - if (rv) { - return rv; - } - rv = apr_pollcb_add(pollcb, pollfd); - } - } - - return rv; -} - -static apr_pollcb_provider_t impl_cb = { - impl_pollcb_create, - impl_pollcb_add, - impl_pollcb_remove, - impl_pollcb_poll, - "port" -}; - -apr_pollcb_provider_t *apr_pollcb_provider_port = &impl_cb; - -#endif /* HAVE_PORT_CREATE */ diff --git a/libs/apr/poll/unix/select.c b/libs/apr/poll/unix/select.c deleted file mode 100644 index 61a064f4..00000000 --- a/libs/apr/poll/unix/select.c +++ /dev/null @@ -1,449 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifdef WIN32 -/* POSIX defines 1024 for the FD_SETSIZE */ -#define FD_SETSIZE 1024 -#endif - -#include "apr.h" -#include "apr_poll.h" -#include "apr_time.h" -#include "apr_portable.h" -#include "apr_arch_file_io.h" -#include "apr_arch_networkio.h" -#include "apr_arch_poll_private.h" - -#ifdef POLL_USES_SELECT - -APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, int num, - apr_int32_t *nsds, - apr_interval_time_t timeout) -{ - fd_set readset, writeset, exceptset; - int rv, i; - int maxfd = -1; - struct timeval tv, *tvptr; -#ifdef NETWARE - apr_datatype_e set_type = APR_NO_DESC; -#endif - -#ifdef WIN32 - /* On Win32, select() must be presented with at least one socket to - * poll on, or select() will return WSAEINVAL. So, we'll just - * short-circuit and bail now. - */ - if (num == 0) { - (*nsds) = 0; - if (timeout > 0) { - apr_sleep(timeout); - return APR_TIMEUP; - } - return APR_SUCCESS; - } -#endif - - if (timeout < 0) { - tvptr = NULL; - } - else { - tv.tv_sec = (long) apr_time_sec(timeout); - tv.tv_usec = (long) apr_time_usec(timeout); - tvptr = &tv; - } - - FD_ZERO(&readset); - FD_ZERO(&writeset); - FD_ZERO(&exceptset); - - for (i = 0; i < num; i++) { - apr_os_sock_t fd; - - aprset[i].rtnevents = 0; - - if (aprset[i].desc_type == APR_POLL_SOCKET) { -#ifdef NETWARE - if (HAS_PIPES(set_type)) { - return APR_EBADF; - } - else { - set_type = APR_POLL_SOCKET; - } -#endif - fd = aprset[i].desc.s->socketdes; - } - else if (aprset[i].desc_type == APR_POLL_FILE) { -#if !APR_FILES_AS_SOCKETS - return APR_EBADF; -#else -#ifdef NETWARE - if (aprset[i].desc.f->is_pipe && !HAS_SOCKETS(set_type)) { - set_type = APR_POLL_FILE; - } - else - return APR_EBADF; -#endif /* NETWARE */ - - fd = aprset[i].desc.f->filedes; - -#endif /* APR_FILES_AS_SOCKETS */ - } - else { - break; - } -#if !defined(WIN32) && !defined(NETWARE) /* socket sets handled with array of handles */ - if (fd >= FD_SETSIZE) { - /* XXX invent new error code so application has a clue */ - return APR_EBADF; - } -#endif - if (aprset[i].reqevents & APR_POLLIN) { - FD_SET(fd, &readset); - } - if (aprset[i].reqevents & APR_POLLOUT) { - FD_SET(fd, &writeset); - } - if (aprset[i].reqevents & - (APR_POLLPRI | APR_POLLERR | APR_POLLHUP | APR_POLLNVAL)) { - FD_SET(fd, &exceptset); - } - if ((int) fd > maxfd) { - maxfd = (int) fd; - } - } - -#ifdef NETWARE - if (HAS_PIPES(set_type)) { - rv = pipe_select(maxfd + 1, &readset, &writeset, &exceptset, tvptr); - } - else { -#endif - - rv = select(maxfd + 1, &readset, &writeset, &exceptset, tvptr); - -#ifdef NETWARE - } -#endif - - (*nsds) = rv; - if ((*nsds) == 0) { - return APR_TIMEUP; - } - if ((*nsds) < 0) { - return apr_get_netos_error(); - } - - (*nsds) = 0; - for (i = 0; i < num; i++) { - apr_os_sock_t fd; - - if (aprset[i].desc_type == APR_POLL_SOCKET) { - fd = aprset[i].desc.s->socketdes; - } - else if (aprset[i].desc_type == APR_POLL_FILE) { -#if !APR_FILES_AS_SOCKETS - return APR_EBADF; -#else - fd = aprset[i].desc.f->filedes; -#endif - } - else { - break; - } - if (FD_ISSET(fd, &readset)) { - aprset[i].rtnevents |= APR_POLLIN; - } - if (FD_ISSET(fd, &writeset)) { - aprset[i].rtnevents |= APR_POLLOUT; - } - if (FD_ISSET(fd, &exceptset)) { - aprset[i].rtnevents |= APR_POLLERR; - } - if (aprset[i].rtnevents) { - (*nsds)++; - } - } - - return APR_SUCCESS; -} - -#endif /* POLL_USES_SELECT */ - -struct apr_pollset_private_t -{ - fd_set readset, writeset, exceptset; - int maxfd; - apr_pollfd_t *query_set; - apr_pollfd_t *result_set; - apr_uint32_t flags; -#ifdef NETWARE - int set_type; -#endif -}; - -static apr_status_t impl_pollset_create(apr_pollset_t *pollset, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags) -{ - if (flags & APR_POLLSET_THREADSAFE) { - pollset->p = NULL; - return APR_ENOTIMPL; - } -#ifdef FD_SETSIZE - if (size > FD_SETSIZE) { - pollset->p = NULL; - return APR_EINVAL; - } -#endif - pollset->p = apr_palloc(p, sizeof(apr_pollset_private_t)); - FD_ZERO(&(pollset->p->readset)); - FD_ZERO(&(pollset->p->writeset)); - FD_ZERO(&(pollset->p->exceptset)); - pollset->p->maxfd = 0; -#ifdef NETWARE - pollset->p->set_type = APR_NO_DESC; -#endif - pollset->p->query_set = apr_palloc(p, size * sizeof(apr_pollfd_t)); - pollset->p->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t)); - - return APR_SUCCESS; -} - -static apr_status_t impl_pollset_add(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) -{ - apr_os_sock_t fd; - - if (pollset->nelts == pollset->nalloc) { - return APR_ENOMEM; - } - - pollset->p->query_set[pollset->nelts] = *descriptor; - - if (descriptor->desc_type == APR_POLL_SOCKET) { -#ifdef NETWARE - /* NetWare can't handle mixed descriptor types in select() */ - if (HAS_PIPES(pollset->p->set_type)) { - return APR_EBADF; - } - else { - pollset->p->set_type = APR_POLL_SOCKET; - } -#endif - fd = descriptor->desc.s->socketdes; - } - else { -#if !APR_FILES_AS_SOCKETS - if ((pollset->flags & APR_POLLSET_WAKEABLE) && - descriptor->desc.f == pollset->wakeup_pipe[0]) - fd = (apr_os_sock_t)descriptor->desc.f->filedes; - else - return APR_EBADF; -#else -#ifdef NETWARE - /* NetWare can't handle mixed descriptor types in select() */ - if (descriptor->desc.f->is_pipe && !HAS_SOCKETS(pollset->p->set_type)) { - pollset->p->set_type = APR_POLL_FILE; - fd = descriptor->desc.f->filedes; - } - else { - return APR_EBADF; - } -#else - fd = descriptor->desc.f->filedes; -#endif -#endif - } -#if !defined(WIN32) && !defined(NETWARE) /* socket sets handled with array of handles */ - if (fd >= FD_SETSIZE) { - /* XXX invent new error code so application has a clue */ - return APR_EBADF; - } -#endif - if (descriptor->reqevents & APR_POLLIN) { - FD_SET(fd, &(pollset->p->readset)); - } - if (descriptor->reqevents & APR_POLLOUT) { - FD_SET(fd, &(pollset->p->writeset)); - } - if (descriptor->reqevents & - (APR_POLLPRI | APR_POLLERR | APR_POLLHUP | APR_POLLNVAL)) { - FD_SET(fd, &(pollset->p->exceptset)); - } - if ((int) fd > pollset->p->maxfd) { - pollset->p->maxfd = (int) fd; - } - pollset->nelts++; - return APR_SUCCESS; -} - -static apr_status_t impl_pollset_remove(apr_pollset_t * pollset, - const apr_pollfd_t * descriptor) -{ - apr_uint32_t i; - apr_os_sock_t fd; - - if (descriptor->desc_type == APR_POLL_SOCKET) { - fd = descriptor->desc.s->socketdes; - } - else { -#if !APR_FILES_AS_SOCKETS - return APR_EBADF; -#else - fd = descriptor->desc.f->filedes; -#endif - } - - for (i = 0; i < pollset->nelts; i++) { - if (descriptor->desc.s == pollset->p->query_set[i].desc.s) { - /* Found an instance of the fd: remove this and any other copies */ - apr_uint32_t dst = i; - apr_uint32_t old_nelts = pollset->nelts; - pollset->nelts--; - for (i++; i < old_nelts; i++) { - if (descriptor->desc.s == pollset->p->query_set[i].desc.s) { - pollset->nelts--; - } - else { - pollset->p->query_set[dst] = pollset->p->query_set[i]; - dst++; - } - } - FD_CLR(fd, &(pollset->p->readset)); - FD_CLR(fd, &(pollset->p->writeset)); - FD_CLR(fd, &(pollset->p->exceptset)); - if (((int) fd == pollset->p->maxfd) && (pollset->p->maxfd > 0)) { - pollset->p->maxfd--; - } - return APR_SUCCESS; - } - } - - return APR_NOTFOUND; -} - -static apr_status_t impl_pollset_poll(apr_pollset_t *pollset, - apr_interval_time_t timeout, - apr_int32_t *num, - const apr_pollfd_t **descriptors) -{ - int rs; - apr_uint32_t i, j; - struct timeval tv, *tvptr; - fd_set readset, writeset, exceptset; - apr_status_t rv = APR_SUCCESS; - -#ifdef WIN32 - /* On Win32, select() must be presented with at least one socket to - * poll on, or select() will return WSAEINVAL. So, we'll just - * short-circuit and bail now. - */ - if (pollset->nelts == 0) { - (*num) = 0; - if (timeout > 0) { - apr_sleep(timeout); - return APR_TIMEUP; - } - return APR_SUCCESS; - } -#endif - - if (timeout < 0) { - tvptr = NULL; - } - else { - tv.tv_sec = (long) apr_time_sec(timeout); - tv.tv_usec = (long) apr_time_usec(timeout); - tvptr = &tv; - } - - memcpy(&readset, &(pollset->p->readset), sizeof(fd_set)); - memcpy(&writeset, &(pollset->p->writeset), sizeof(fd_set)); - memcpy(&exceptset, &(pollset->p->exceptset), sizeof(fd_set)); - -#ifdef NETWARE - if (HAS_PIPES(pollset->p->set_type)) { - rs = pipe_select(pollset->p->maxfd + 1, &readset, &writeset, &exceptset, - tvptr); - } - else -#endif - rs = select(pollset->p->maxfd + 1, &readset, &writeset, &exceptset, - tvptr); - - (*num) = rs; - if (rs < 0) { - return apr_get_netos_error(); - } - if (rs == 0) { - return APR_TIMEUP; - } - j = 0; - for (i = 0; i < pollset->nelts; i++) { - apr_os_sock_t fd; - if (pollset->p->query_set[i].desc_type == APR_POLL_SOCKET) { - fd = pollset->p->query_set[i].desc.s->socketdes; - } - else { - if ((pollset->flags & APR_POLLSET_WAKEABLE) && - pollset->p->query_set[i].desc.f == pollset->wakeup_pipe[0]) { - apr_pollset_drain_wakeup_pipe(pollset); - rv = APR_EINTR; - continue; - } - else { -#if !APR_FILES_AS_SOCKETS - return APR_EBADF; -#else - fd = pollset->p->query_set[i].desc.f->filedes; -#endif - } - } - if (FD_ISSET(fd, &readset) || FD_ISSET(fd, &writeset) || - FD_ISSET(fd, &exceptset)) { - pollset->p->result_set[j] = pollset->p->query_set[i]; - pollset->p->result_set[j].rtnevents = 0; - if (FD_ISSET(fd, &readset)) { - pollset->p->result_set[j].rtnevents |= APR_POLLIN; - } - if (FD_ISSET(fd, &writeset)) { - pollset->p->result_set[j].rtnevents |= APR_POLLOUT; - } - if (FD_ISSET(fd, &exceptset)) { - pollset->p->result_set[j].rtnevents |= APR_POLLERR; - } - j++; - } - } - if (((*num) = j) != 0) - rv = APR_SUCCESS; - - if (descriptors) - *descriptors = pollset->p->result_set; - return rv; -} - -static apr_pollset_provider_t impl = { - impl_pollset_create, - impl_pollset_add, - impl_pollset_remove, - impl_pollset_poll, - NULL, - "select" -}; - -apr_pollset_provider_t *apr_pollset_provider_select = &impl; diff --git a/libs/apr/random/unix/apr_random.c b/libs/apr/random/unix/apr_random.c deleted file mode 100644 index b042b66b..00000000 --- a/libs/apr/random/unix/apr_random.c +++ /dev/null @@ -1,326 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * See the paper "On Randomness" by Ben Laurie for an explanation of this PRNG. - * http://www.apache-ssl.org/randomness.pdf - * XXX: Is there a formal proof of this PRNG? Couldn't we use the more popular - * Mersenne Twister PRNG (and BSD licensed)? - */ - -#include "apr.h" -#include "apr_pools.h" -#include "apr_random.h" -#include "apr_thread_proc.h" -#include - -#ifdef min -#undef min -#endif -#define min(a,b) ((a) < (b) ? (a) : (b)) - -#define APR_RANDOM_DEFAULT_POOLS 32 -#define APR_RANDOM_DEFAULT_REHASH_SIZE 1024 -#define APR_RANDOM_DEFAULT_RESEED_SIZE 32 -#define APR_RANDOM_DEFAULT_HASH_SECRET_SIZE 32 -#define APR_RANDOM_DEFAULT_G_FOR_INSECURE 32 -#define APR_RANDOM_DEFAULT_G_FOR_SECURE 320 - -typedef struct apr_random_pool_t { - unsigned char *pool; - unsigned int bytes; - unsigned int pool_size; -} apr_random_pool_t; - -#define hash_init(h) (h)->init(h) -#define hash_add(h,b,n) (h)->add(h,b,n) -#define hash_finish(h,r) (h)->finish(h,r) - -#define hash(h,r,b,n) hash_init(h),hash_add(h,b,n),hash_finish(h,r) - -#define crypt_setkey(c,k) (c)->set_key((c)->data,k) -#define crypt_crypt(c,out,in) (c)->crypt((c)->date,out,in) - -struct apr_random_t { - apr_pool_t *apr_pool; - apr_crypto_hash_t *pool_hash; - unsigned int npools; - apr_random_pool_t *pools; - unsigned int next_pool; - unsigned int generation; - apr_size_t rehash_size; - apr_size_t reseed_size; - apr_crypto_hash_t *key_hash; -#define K_size(g) ((g)->key_hash->size) - apr_crypto_hash_t *prng_hash; -#define B_size(g) ((g)->prng_hash->size) - - unsigned char *H; - unsigned char *H_waiting; -#define H_size(g) (B_size(g)+K_size(g)) -#define H_current(g) (((g)->insecure_started && !(g)->secure_started) \ - ? (g)->H_waiting : (g)->H) - - unsigned char *randomness; - apr_size_t random_bytes; - unsigned int g_for_insecure; - unsigned int g_for_secure; - unsigned int secure_base; - unsigned int insecure_started:1; - unsigned int secure_started:1; - - apr_random_t *next; -}; - -static apr_random_t *all_random; - -static apr_status_t random_cleanup(void *data) -{ - apr_random_t *remove_this = data, - *cur = all_random, - **prev_ptr = &all_random; - while (cur) { - if (cur == remove_this) { - *prev_ptr = cur->next; - break; - } - prev_ptr = &cur->next; - cur = cur->next; - } - return APR_SUCCESS; -} - - -APR_DECLARE(void) apr_random_init(apr_random_t *g,apr_pool_t *p, - apr_crypto_hash_t *pool_hash, - apr_crypto_hash_t *key_hash, - apr_crypto_hash_t *prng_hash) -{ - unsigned int n; - - g->apr_pool = p; - - g->pool_hash = pool_hash; - g->key_hash = key_hash; - g->prng_hash = prng_hash; - - g->npools = APR_RANDOM_DEFAULT_POOLS; - g->pools = apr_palloc(p,g->npools*sizeof *g->pools); - for (n = 0; n < g->npools; ++n) { - g->pools[n].bytes = g->pools[n].pool_size = 0; - g->pools[n].pool = NULL; - } - g->next_pool = 0; - - g->generation = 0; - - g->rehash_size = APR_RANDOM_DEFAULT_REHASH_SIZE; - /* Ensure that the rehash size is twice the size of the pool hasher */ - g->rehash_size = ((g->rehash_size+2*g->pool_hash->size-1)/g->pool_hash->size - /2)*g->pool_hash->size*2; - g->reseed_size = APR_RANDOM_DEFAULT_RESEED_SIZE; - - g->H = apr_pcalloc(p,H_size(g)); - g->H_waiting = apr_pcalloc(p,H_size(g)); - - g->randomness = apr_palloc(p,B_size(g)); - g->random_bytes = 0; - - g->g_for_insecure = APR_RANDOM_DEFAULT_G_FOR_INSECURE; - g->secure_base = 0; - g->g_for_secure = APR_RANDOM_DEFAULT_G_FOR_SECURE; - g->secure_started = g->insecure_started = 0; - - g->next = all_random; - all_random = g; - apr_pool_cleanup_register(p, g, random_cleanup, apr_pool_cleanup_null); -} - -static void mix_pid(apr_random_t *g,unsigned char *H,pid_t pid) -{ - hash_init(g->key_hash); - hash_add(g->key_hash,H,H_size(g)); - hash_add(g->key_hash,&pid,sizeof pid); - hash_finish(g->key_hash,H); -} - -static void mixer(apr_random_t *g,pid_t pid) -{ - unsigned char *H = H_current(g); - - /* mix the PID into the current H */ - mix_pid(g,H,pid); - /* if we are in waiting, then also mix into main H */ - if (H != g->H) - mix_pid(g,g->H,pid); - /* change order of pool mixing for good measure - note that going - backwards is much better than going forwards */ - --g->generation; - /* blow away any lingering randomness */ - g->random_bytes = 0; -} - -APR_DECLARE(void) apr_random_after_fork(apr_proc_t *proc) -{ - apr_random_t *r; - - for (r = all_random; r; r = r->next) - /* - * XXX Note: the pid does not provide sufficient entropy to - * actually call this secure. See Ben's paper referenced at - * the top of this file. - */ - mixer(r,proc->pid); -} - -APR_DECLARE(apr_random_t *) apr_random_standard_new(apr_pool_t *p) -{ - apr_random_t *r = apr_palloc(p,sizeof *r); - - apr_random_init(r,p,apr_crypto_sha256_new(p),apr_crypto_sha256_new(p), - apr_crypto_sha256_new(p)); - return r; -} - -static void rekey(apr_random_t *g) -{ - unsigned int n; - unsigned char *H = H_current(g); - - hash_init(g->key_hash); - hash_add(g->key_hash,H,H_size(g)); - for (n = 0 ; n < g->npools && (n == 0 || g->generation&(1 << (n-1))) - ; ++n) { - hash_add(g->key_hash,g->pools[n].pool,g->pools[n].bytes); - g->pools[n].bytes = 0; - } - hash_finish(g->key_hash,H+B_size(g)); - - ++g->generation; - if (!g->insecure_started && g->generation > g->g_for_insecure) { - g->insecure_started = 1; - if (!g->secure_started) { - memcpy(g->H_waiting,g->H,H_size(g)); - g->secure_base = g->generation; - } - } - - if (!g->secure_started && g->generation > g->secure_base+g->g_for_secure) { - g->secure_started = 1; - memcpy(g->H,g->H_waiting,H_size(g)); - } -} - -APR_DECLARE(void) apr_random_add_entropy(apr_random_t *g,const void *entropy_, - apr_size_t bytes) -{ - unsigned int n; - const unsigned char *entropy = entropy_; - - for (n = 0; n < bytes; ++n) { - apr_random_pool_t *p = &g->pools[g->next_pool]; - - if (++g->next_pool == g->npools) - g->next_pool = 0; - - if (p->pool_size < p->bytes+1) { - unsigned char *np = apr_palloc(g->apr_pool,(p->bytes+1)*2); - - memcpy(np,p->pool,p->bytes); - p->pool = np; - p->pool_size = (p->bytes+1)*2; - } - p->pool[p->bytes++] = entropy[n]; - - if (p->bytes == g->rehash_size) { - apr_size_t r; - - for (r = 0; r < p->bytes/2; r+=g->pool_hash->size) - hash(g->pool_hash,p->pool+r,p->pool+r*2,g->pool_hash->size*2); - p->bytes/=2; - } - assert(p->bytes < g->rehash_size); - } - - if (g->pools[0].bytes >= g->reseed_size) - rekey(g); -} - -/* This will give g->B_size bytes of randomness */ -static void apr_random_block(apr_random_t *g,unsigned char *random) -{ - /* FIXME: in principle, these are different hashes */ - hash(g->prng_hash,g->H,g->H,H_size(g)); - hash(g->prng_hash,random,g->H,B_size(g)); -} - -static void apr_random_bytes(apr_random_t *g,unsigned char *random, - apr_size_t bytes) -{ - apr_size_t n; - - for (n = 0; n < bytes; ) { - apr_size_t l; - - if (g->random_bytes == 0) { - apr_random_block(g,g->randomness); - g->random_bytes = B_size(g); - } - l = min(bytes-n,g->random_bytes); - memcpy(&random[n],g->randomness+B_size(g)-g->random_bytes,l); - g->random_bytes-=l; - n+=l; - } -} - -APR_DECLARE(apr_status_t) apr_random_secure_bytes(apr_random_t *g, - void *random, - apr_size_t bytes) -{ - if (!g->secure_started) - return APR_ENOTENOUGHENTROPY; - apr_random_bytes(g,random,bytes); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_random_insecure_bytes(apr_random_t *g, - void *random, - apr_size_t bytes) -{ - if (!g->insecure_started) - return APR_ENOTENOUGHENTROPY; - apr_random_bytes(g,random,bytes); - return APR_SUCCESS; -} - -APR_DECLARE(void) apr_random_barrier(apr_random_t *g) -{ - g->secure_started = 0; - g->secure_base = g->generation; -} - -APR_DECLARE(apr_status_t) apr_random_secure_ready(apr_random_t *r) -{ - if (!r->secure_started) - return APR_ENOTENOUGHENTROPY; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_random_insecure_ready(apr_random_t *r) -{ - if (!r->insecure_started) - return APR_ENOTENOUGHENTROPY; - return APR_SUCCESS; -} diff --git a/libs/apr/random/unix/sha2.c b/libs/apr/random/unix/sha2.c deleted file mode 100644 index 212c1b73..00000000 --- a/libs/apr/random/unix/sha2.c +++ /dev/null @@ -1,1000 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * FILE: sha2.c - * AUTHOR: Aaron D. Gifford - * - * A licence was granted to the ASF by Aaron on 4 November 2003. - */ - -#include /* memcpy()/memset() or bcopy()/bzero() */ -#include /* assert() */ -#include "sha2.h" - -/* - * ASSERT NOTE: - * Some sanity checking code is included using assert(). On my FreeBSD - * system, this additional code can be removed by compiling with NDEBUG - * defined. Check your own systems manpage on assert() to see how to - * compile WITHOUT the sanity checking code on your system. - * - * UNROLLED TRANSFORM LOOP NOTE: - * You can define SHA2_UNROLL_TRANSFORM to use the unrolled transform - * loop version for the hash transform rounds (defined using macros - * later in this file). Either define on the command line, for example: - * - * cc -DSHA2_UNROLL_TRANSFORM -o sha2 sha2.c sha2prog.c - * - * or define below: - * - * #define SHA2_UNROLL_TRANSFORM - * - */ - -/*** SHA-256/384/512 Machine Architecture Definitions *****************/ -typedef apr_byte_t sha2_byte; /* Exactly 1 byte */ -typedef apr_uint32_t sha2_word32; /* Exactly 4 bytes */ -typedef apr_uint64_t sha2_word64; /* Exactly 8 bytes */ - -/*** SHA-256/384/512 Various Length Definitions ***********************/ -/* NOTE: Most of these are in sha2.h */ -#define SHA256_SHORT_BLOCK_LENGTH (SHA256_BLOCK_LENGTH - 8) -#define SHA384_SHORT_BLOCK_LENGTH (SHA384_BLOCK_LENGTH - 16) -#define SHA512_SHORT_BLOCK_LENGTH (SHA512_BLOCK_LENGTH - 16) - - -/*** ENDIAN REVERSAL MACROS *******************************************/ -#if !APR_IS_BIGENDIAN -#define REVERSE32(w,x) { \ - sha2_word32 tmp = (w); \ - tmp = (tmp >> 16) | (tmp << 16); \ - (x) = ((tmp & 0xff00ff00UL) >> 8) | ((tmp & 0x00ff00ffUL) << 8); \ -} -#define REVERSE64(w,x) { \ - sha2_word64 tmp = (w); \ - tmp = (tmp >> 32) | (tmp << 32); \ - tmp = ((tmp & APR_UINT64_C(0xff00ff00ff00ff00)) >> 8) | \ - ((tmp & APR_UINT64_C(0x00ff00ff00ff00ff)) << 8); \ - (x) = ((tmp & APR_UINT64_C(0xffff0000ffff0000)) >> 16) | \ - ((tmp & APR_UINT64_C(0x0000ffff0000ffff)) << 16); \ -} -#endif /* !APR_IS_BIGENDIAN */ - -/* - * Macro for incrementally adding the unsigned 64-bit integer n to the - * unsigned 128-bit integer (represented using a two-element array of - * 64-bit words): - */ -#define ADDINC128(w,n) { \ - (w)[0] += (sha2_word64)(n); \ - if ((w)[0] < (n)) { \ - (w)[1]++; \ - } \ -} - -/* - * Macros for copying blocks of memory and for zeroing out ranges - * of memory. Using these macros makes it easy to switch from - * using memset()/memcpy() and using bzero()/bcopy(). - * - * Please define either SHA2_USE_MEMSET_MEMCPY or define - * SHA2_USE_BZERO_BCOPY depending on which function set you - * choose to use: - */ -#if !defined(SHA2_USE_MEMSET_MEMCPY) && !defined(SHA2_USE_BZERO_BCOPY) -/* Default to memset()/memcpy() if no option is specified */ -#define SHA2_USE_MEMSET_MEMCPY 1 -#endif -#if defined(SHA2_USE_MEMSET_MEMCPY) && defined(SHA2_USE_BZERO_BCOPY) -/* Abort with an error if BOTH options are defined */ -#error Define either SHA2_USE_MEMSET_MEMCPY or SHA2_USE_BZERO_BCOPY, not both! -#endif - -#ifdef SHA2_USE_MEMSET_MEMCPY -#define MEMSET_BZERO(p,l) memset((p), 0, (l)) -#define MEMCPY_BCOPY(d,s,l) memcpy((d), (s), (l)) -#endif -#ifdef SHA2_USE_BZERO_BCOPY -#define MEMSET_BZERO(p,l) bzero((p), (l)) -#define MEMCPY_BCOPY(d,s,l) bcopy((s), (d), (l)) -#endif - - -/*** THE SIX LOGICAL FUNCTIONS ****************************************/ -/* - * Bit shifting and rotation (used by the six SHA-XYZ logical functions: - * - * NOTE: The naming of R and S appears backwards here (R is a SHIFT and - * S is a ROTATION) because the SHA-256/384/512 description document - * (see http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf) uses this - * same "backwards" definition. - */ -/* Shift-right (used in SHA-256, SHA-384, and SHA-512): */ -#define R(b,x) ((x) >> (b)) -/* 32-bit Rotate-right (used in SHA-256): */ -#define S32(b,x) (((x) >> (b)) | ((x) << (32 - (b)))) -/* 64-bit Rotate-right (used in SHA-384 and SHA-512): */ -#define S64(b,x) (((x) >> (b)) | ((x) << (64 - (b)))) - -/* Two of six logical functions used in SHA-256, SHA-384, and SHA-512: */ -#define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z))) -#define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) - -/* Four of six logical functions used in SHA-256: */ -#define Sigma0_256(x) (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x))) -#define Sigma1_256(x) (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x))) -#define sigma0_256(x) (S32(7, (x)) ^ S32(18, (x)) ^ R(3 , (x))) -#define sigma1_256(x) (S32(17, (x)) ^ S32(19, (x)) ^ R(10, (x))) - -/* Four of six logical functions used in SHA-384 and SHA-512: */ -#define Sigma0_512(x) (S64(28, (x)) ^ S64(34, (x)) ^ S64(39, (x))) -#define Sigma1_512(x) (S64(14, (x)) ^ S64(18, (x)) ^ S64(41, (x))) -#define sigma0_512(x) (S64( 1, (x)) ^ S64( 8, (x)) ^ R( 7, (x))) -#define sigma1_512(x) (S64(19, (x)) ^ S64(61, (x)) ^ R( 6, (x))) - -/*** INTERNAL FUNCTION PROTOTYPES *************************************/ -/* NOTE: These should not be accessed directly from outside this - * library -- they are intended for private internal visibility/use - * only. - */ -void apr__SHA512_Last(SHA512_CTX*); -void apr__SHA256_Transform(SHA256_CTX*, const sha2_word32*); -void apr__SHA512_Transform(SHA512_CTX*, const sha2_word64*); - - -/*** SHA-XYZ INITIAL HASH VALUES AND CONSTANTS ************************/ -/* Hash constant words K for SHA-256: */ -static const sha2_word32 K256[64] = { - 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, - 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, - 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL, - 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL, - 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL, - 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, - 0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, - 0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL, - 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL, - 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL, - 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, - 0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, - 0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL, - 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL, - 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL, - 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL -}; - -/* Initial hash value H for SHA-256: */ -static const sha2_word32 sha256_initial_hash_value[8] = { - 0x6a09e667UL, - 0xbb67ae85UL, - 0x3c6ef372UL, - 0xa54ff53aUL, - 0x510e527fUL, - 0x9b05688cUL, - 0x1f83d9abUL, - 0x5be0cd19UL -}; - -/* Hash constant words K for SHA-384 and SHA-512: */ -static const sha2_word64 K512[80] = { - APR_UINT64_C(0x428a2f98d728ae22), APR_UINT64_C(0x7137449123ef65cd), - APR_UINT64_C(0xb5c0fbcfec4d3b2f), APR_UINT64_C(0xe9b5dba58189dbbc), - APR_UINT64_C(0x3956c25bf348b538), APR_UINT64_C(0x59f111f1b605d019), - APR_UINT64_C(0x923f82a4af194f9b), APR_UINT64_C(0xab1c5ed5da6d8118), - APR_UINT64_C(0xd807aa98a3030242), APR_UINT64_C(0x12835b0145706fbe), - APR_UINT64_C(0x243185be4ee4b28c), APR_UINT64_C(0x550c7dc3d5ffb4e2), - APR_UINT64_C(0x72be5d74f27b896f), APR_UINT64_C(0x80deb1fe3b1696b1), - APR_UINT64_C(0x9bdc06a725c71235), APR_UINT64_C(0xc19bf174cf692694), - APR_UINT64_C(0xe49b69c19ef14ad2), APR_UINT64_C(0xefbe4786384f25e3), - APR_UINT64_C(0x0fc19dc68b8cd5b5), APR_UINT64_C(0x240ca1cc77ac9c65), - APR_UINT64_C(0x2de92c6f592b0275), APR_UINT64_C(0x4a7484aa6ea6e483), - APR_UINT64_C(0x5cb0a9dcbd41fbd4), APR_UINT64_C(0x76f988da831153b5), - APR_UINT64_C(0x983e5152ee66dfab), APR_UINT64_C(0xa831c66d2db43210), - APR_UINT64_C(0xb00327c898fb213f), APR_UINT64_C(0xbf597fc7beef0ee4), - APR_UINT64_C(0xc6e00bf33da88fc2), APR_UINT64_C(0xd5a79147930aa725), - APR_UINT64_C(0x06ca6351e003826f), APR_UINT64_C(0x142929670a0e6e70), - APR_UINT64_C(0x27b70a8546d22ffc), APR_UINT64_C(0x2e1b21385c26c926), - APR_UINT64_C(0x4d2c6dfc5ac42aed), APR_UINT64_C(0x53380d139d95b3df), - APR_UINT64_C(0x650a73548baf63de), APR_UINT64_C(0x766a0abb3c77b2a8), - APR_UINT64_C(0x81c2c92e47edaee6), APR_UINT64_C(0x92722c851482353b), - APR_UINT64_C(0xa2bfe8a14cf10364), APR_UINT64_C(0xa81a664bbc423001), - APR_UINT64_C(0xc24b8b70d0f89791), APR_UINT64_C(0xc76c51a30654be30), - APR_UINT64_C(0xd192e819d6ef5218), APR_UINT64_C(0xd69906245565a910), - APR_UINT64_C(0xf40e35855771202a), APR_UINT64_C(0x106aa07032bbd1b8), - APR_UINT64_C(0x19a4c116b8d2d0c8), APR_UINT64_C(0x1e376c085141ab53), - APR_UINT64_C(0x2748774cdf8eeb99), APR_UINT64_C(0x34b0bcb5e19b48a8), - APR_UINT64_C(0x391c0cb3c5c95a63), APR_UINT64_C(0x4ed8aa4ae3418acb), - APR_UINT64_C(0x5b9cca4f7763e373), APR_UINT64_C(0x682e6ff3d6b2b8a3), - APR_UINT64_C(0x748f82ee5defb2fc), APR_UINT64_C(0x78a5636f43172f60), - APR_UINT64_C(0x84c87814a1f0ab72), APR_UINT64_C(0x8cc702081a6439ec), - APR_UINT64_C(0x90befffa23631e28), APR_UINT64_C(0xa4506cebde82bde9), - APR_UINT64_C(0xbef9a3f7b2c67915), APR_UINT64_C(0xc67178f2e372532b), - APR_UINT64_C(0xca273eceea26619c), APR_UINT64_C(0xd186b8c721c0c207), - APR_UINT64_C(0xeada7dd6cde0eb1e), APR_UINT64_C(0xf57d4f7fee6ed178), - APR_UINT64_C(0x06f067aa72176fba), APR_UINT64_C(0x0a637dc5a2c898a6), - APR_UINT64_C(0x113f9804bef90dae), APR_UINT64_C(0x1b710b35131c471b), - APR_UINT64_C(0x28db77f523047d84), APR_UINT64_C(0x32caab7b40c72493), - APR_UINT64_C(0x3c9ebe0a15c9bebc), APR_UINT64_C(0x431d67c49c100d4c), - APR_UINT64_C(0x4cc5d4becb3e42b6), APR_UINT64_C(0x597f299cfc657e2a), - APR_UINT64_C(0x5fcb6fab3ad6faec), APR_UINT64_C(0x6c44198c4a475817) -}; - -/* Initial hash value H for SHA-384 */ -static const sha2_word64 sha384_initial_hash_value[8] = { - APR_UINT64_C(0xcbbb9d5dc1059ed8), - APR_UINT64_C(0x629a292a367cd507), - APR_UINT64_C(0x9159015a3070dd17), - APR_UINT64_C(0x152fecd8f70e5939), - APR_UINT64_C(0x67332667ffc00b31), - APR_UINT64_C(0x8eb44a8768581511), - APR_UINT64_C(0xdb0c2e0d64f98fa7), - APR_UINT64_C(0x47b5481dbefa4fa4) -}; - -/* Initial hash value H for SHA-512 */ -static const sha2_word64 sha512_initial_hash_value[8] = { - APR_UINT64_C(0x6a09e667f3bcc908), - APR_UINT64_C(0xbb67ae8584caa73b), - APR_UINT64_C(0x3c6ef372fe94f82b), - APR_UINT64_C(0xa54ff53a5f1d36f1), - APR_UINT64_C(0x510e527fade682d1), - APR_UINT64_C(0x9b05688c2b3e6c1f), - APR_UINT64_C(0x1f83d9abfb41bd6b), - APR_UINT64_C(0x5be0cd19137e2179) -}; - -/* - * Constant used by SHA256/384/512_End() functions for converting the - * digest to a readable hexadecimal character string: - */ -static const char *sha2_hex_digits = "0123456789abcdef"; - - -/*** SHA-256: *********************************************************/ -void apr__SHA256_Init(SHA256_CTX* context) { - if (context == (SHA256_CTX*)0) { - return; - } - MEMCPY_BCOPY(context->state, sha256_initial_hash_value, SHA256_DIGEST_LENGTH); - MEMSET_BZERO(context->buffer, SHA256_BLOCK_LENGTH); - context->bitcount = 0; -} - -#ifdef SHA2_UNROLL_TRANSFORM - -/* Unrolled SHA-256 round macros: */ - -#if !APR_IS_BIGENDIAN - -#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \ - REVERSE32(*data++, W256[j]); \ - T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + \ - K256[j] + W256[j]; \ - (d) += T1; \ - (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ - j++ - - -#else /* APR_IS_BIGENDIAN */ - -#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \ - T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + \ - K256[j] + (W256[j] = *data++); \ - (d) += T1; \ - (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ - j++ - -#endif /* APR_IS_BIGENDIAN */ - -#define ROUND256(a,b,c,d,e,f,g,h) \ - s0 = W256[(j+1)&0x0f]; \ - s0 = sigma0_256(s0); \ - s1 = W256[(j+14)&0x0f]; \ - s1 = sigma1_256(s1); \ - T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + K256[j] + \ - (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); \ - (d) += T1; \ - (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ - j++ - -void apr__SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { - sha2_word32 a, b, c, d, e, f, g, h, s0, s1; - sha2_word32 T1, *W256; - int j; - - W256 = (sha2_word32*)context->buffer; - - /* Initialize registers with the prev. intermediate value */ - a = context->state[0]; - b = context->state[1]; - c = context->state[2]; - d = context->state[3]; - e = context->state[4]; - f = context->state[5]; - g = context->state[6]; - h = context->state[7]; - - j = 0; - do { - /* Rounds 0 to 15 (unrolled): */ - ROUND256_0_TO_15(a,b,c,d,e,f,g,h); - ROUND256_0_TO_15(h,a,b,c,d,e,f,g); - ROUND256_0_TO_15(g,h,a,b,c,d,e,f); - ROUND256_0_TO_15(f,g,h,a,b,c,d,e); - ROUND256_0_TO_15(e,f,g,h,a,b,c,d); - ROUND256_0_TO_15(d,e,f,g,h,a,b,c); - ROUND256_0_TO_15(c,d,e,f,g,h,a,b); - ROUND256_0_TO_15(b,c,d,e,f,g,h,a); - } while (j < 16); - - /* Now for the remaining rounds to 64: */ - do { - ROUND256(a,b,c,d,e,f,g,h); - ROUND256(h,a,b,c,d,e,f,g); - ROUND256(g,h,a,b,c,d,e,f); - ROUND256(f,g,h,a,b,c,d,e); - ROUND256(e,f,g,h,a,b,c,d); - ROUND256(d,e,f,g,h,a,b,c); - ROUND256(c,d,e,f,g,h,a,b); - ROUND256(b,c,d,e,f,g,h,a); - } while (j < 64); - - /* Compute the current intermediate hash value */ - context->state[0] += a; - context->state[1] += b; - context->state[2] += c; - context->state[3] += d; - context->state[4] += e; - context->state[5] += f; - context->state[6] += g; - context->state[7] += h; - - /* Clean up */ - a = b = c = d = e = f = g = h = T1 = 0; -} - -#else /* SHA2_UNROLL_TRANSFORM */ - -void apr__SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { - sha2_word32 a, b, c, d, e, f, g, h, s0, s1; - sha2_word32 T1, T2, *W256; - int j; - - W256 = (sha2_word32*)context->buffer; - - /* Initialize registers with the prev. intermediate value */ - a = context->state[0]; - b = context->state[1]; - c = context->state[2]; - d = context->state[3]; - e = context->state[4]; - f = context->state[5]; - g = context->state[6]; - h = context->state[7]; - - j = 0; - do { -#if !APR_IS_BIGENDIAN - /* Copy data while converting to host byte order */ - REVERSE32(*data++,W256[j]); - /* Apply the SHA-256 compression function to update a..h */ - T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + W256[j]; -#else /* APR_IS_BIGENDIAN */ - /* Apply the SHA-256 compression function to update a..h with copy */ - T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + (W256[j] = *data++); -#endif /* APR_IS_BIGENDIAN */ - T2 = Sigma0_256(a) + Maj(a, b, c); - h = g; - g = f; - f = e; - e = d + T1; - d = c; - c = b; - b = a; - a = T1 + T2; - - j++; - } while (j < 16); - - do { - /* Part of the message block expansion: */ - s0 = W256[(j+1)&0x0f]; - s0 = sigma0_256(s0); - s1 = W256[(j+14)&0x0f]; - s1 = sigma1_256(s1); - - /* Apply the SHA-256 compression function to update a..h */ - T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + - (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); - T2 = Sigma0_256(a) + Maj(a, b, c); - h = g; - g = f; - f = e; - e = d + T1; - d = c; - c = b; - b = a; - a = T1 + T2; - - j++; - } while (j < 64); - - /* Compute the current intermediate hash value */ - context->state[0] += a; - context->state[1] += b; - context->state[2] += c; - context->state[3] += d; - context->state[4] += e; - context->state[5] += f; - context->state[6] += g; - context->state[7] += h; - - /* Clean up */ - a = b = c = d = e = f = g = h = T1 = T2 = 0; -} - -#endif /* SHA2_UNROLL_TRANSFORM */ - -void apr__SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) { - unsigned int freespace, usedspace; - - if (len == 0) { - /* Calling with no data is valid - we do nothing */ - return; - } - - /* Sanity check: */ - assert(context != (SHA256_CTX*)0 && data != (sha2_byte*)0); - - usedspace = (unsigned int)((context->bitcount >> 3) - % SHA256_BLOCK_LENGTH); - if (usedspace > 0) { - /* Calculate how much free space is available in the buffer */ - freespace = SHA256_BLOCK_LENGTH - usedspace; - - if (len >= freespace) { - /* Fill the buffer completely and process it */ - MEMCPY_BCOPY(&context->buffer[usedspace], data, freespace); - context->bitcount += freespace << 3; - len -= freespace; - data += freespace; - apr__SHA256_Transform(context, (sha2_word32*)context->buffer); - } else { - /* The buffer is not yet full */ - MEMCPY_BCOPY(&context->buffer[usedspace], data, len); - context->bitcount += len << 3; - /* Clean up: */ - usedspace = freespace = 0; - return; - } - } - while (len >= SHA256_BLOCK_LENGTH) { - /* Process as many complete blocks as we can */ - apr__SHA256_Transform(context, (sha2_word32*)data); - context->bitcount += SHA256_BLOCK_LENGTH << 3; - len -= SHA256_BLOCK_LENGTH; - data += SHA256_BLOCK_LENGTH; - } - if (len > 0) { - /* There's left-overs, so save 'em */ - MEMCPY_BCOPY(context->buffer, data, len); - context->bitcount += len << 3; - } - /* Clean up: */ - usedspace = freespace = 0; -} - -void apr__SHA256_Final(sha2_byte digest[], SHA256_CTX* context) { - sha2_word32 *d = (sha2_word32*)digest; - unsigned int usedspace; - - /* Sanity check: */ - assert(context != (SHA256_CTX*)0); - - /* If no digest buffer is passed, we don't bother doing this: */ - if (digest != (sha2_byte*)0) { - usedspace = (unsigned int)((context->bitcount >> 3) - % SHA256_BLOCK_LENGTH); -#if !APR_IS_BIGENDIAN - /* Convert FROM host byte order */ - REVERSE64(context->bitcount,context->bitcount); -#endif - if (usedspace > 0) { - /* Begin padding with a 1 bit: */ - context->buffer[usedspace++] = 0x80; - - if (usedspace <= SHA256_SHORT_BLOCK_LENGTH) { - /* Set-up for the last transform: */ - MEMSET_BZERO(&context->buffer[usedspace], SHA256_SHORT_BLOCK_LENGTH - usedspace); - } else { - if (usedspace < SHA256_BLOCK_LENGTH) { - MEMSET_BZERO(&context->buffer[usedspace], SHA256_BLOCK_LENGTH - usedspace); - } - /* Do second-to-last transform: */ - apr__SHA256_Transform(context, (sha2_word32*)context->buffer); - - /* And set-up for the last transform: */ - MEMSET_BZERO(context->buffer, SHA256_SHORT_BLOCK_LENGTH); - } - } else { - /* Set-up for the last transform: */ - MEMSET_BZERO(context->buffer, SHA256_SHORT_BLOCK_LENGTH); - - /* Begin padding with a 1 bit: */ - *context->buffer = 0x80; - } - /* Set the bit count: */ - *(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount; - - /* Final transform: */ - apr__SHA256_Transform(context, (sha2_word32*)context->buffer); - -#if !APR_IS_BIGENDIAN - { - /* Convert TO host byte order */ - int j; - for (j = 0; j < 8; j++) { - REVERSE32(context->state[j],context->state[j]); - *d++ = context->state[j]; - } - } -#else - MEMCPY_BCOPY(d, context->state, SHA256_DIGEST_LENGTH); -#endif - } - - /* Clean up state data: */ - MEMSET_BZERO(context, sizeof(*context)); - usedspace = 0; -} - -char *apr__SHA256_End(SHA256_CTX* context, char buffer[]) { - sha2_byte digest[SHA256_DIGEST_LENGTH], *d = digest; - int i; - - /* Sanity check: */ - assert(context != (SHA256_CTX*)0); - - if (buffer != (char*)0) { - apr__SHA256_Final(digest, context); - - for (i = 0; i < SHA256_DIGEST_LENGTH; i++) { - *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4]; - *buffer++ = sha2_hex_digits[*d & 0x0f]; - d++; - } - *buffer = (char)0; - } else { - MEMSET_BZERO(context, sizeof(*context)); - } - MEMSET_BZERO(digest, SHA256_DIGEST_LENGTH); - return buffer; -} - -char* apr__SHA256_Data(const sha2_byte* data, size_t len, char digest[SHA256_DIGEST_STRING_LENGTH]) { - SHA256_CTX context; - - apr__SHA256_Init(&context); - apr__SHA256_Update(&context, data, len); - return apr__SHA256_End(&context, digest); -} - - -/*** SHA-512: *********************************************************/ -void apr__SHA512_Init(SHA512_CTX* context) { - if (context == (SHA512_CTX*)0) { - return; - } - MEMCPY_BCOPY(context->state, sha512_initial_hash_value, SHA512_DIGEST_LENGTH); - MEMSET_BZERO(context->buffer, SHA512_BLOCK_LENGTH); - context->bitcount[0] = context->bitcount[1] = 0; -} - -#ifdef SHA2_UNROLL_TRANSFORM - -/* Unrolled SHA-512 round macros: */ -#if !APR_IS_BIGENDIAN - -#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \ - REVERSE64(*data++, W512[j]); \ - T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \ - K512[j] + W512[j]; \ - (d) += T1, \ - (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)), \ - j++ - - -#else /* APR_IS_BIGENDIAN */ - -#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \ - T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \ - K512[j] + (W512[j] = *data++); \ - (d) += T1; \ - (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \ - j++ - -#endif /* APR_IS_BIGENDIAN */ - -#define ROUND512(a,b,c,d,e,f,g,h) \ - s0 = W512[(j+1)&0x0f]; \ - s0 = sigma0_512(s0); \ - s1 = W512[(j+14)&0x0f]; \ - s1 = sigma1_512(s1); \ - T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + K512[j] + \ - (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); \ - (d) += T1; \ - (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \ - j++ - -void apr__SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { - sha2_word64 a, b, c, d, e, f, g, h, s0, s1; - sha2_word64 T1, *W512 = (sha2_word64*)context->buffer; - int j; - - /* Initialize registers with the prev. intermediate value */ - a = context->state[0]; - b = context->state[1]; - c = context->state[2]; - d = context->state[3]; - e = context->state[4]; - f = context->state[5]; - g = context->state[6]; - h = context->state[7]; - - j = 0; - do { - ROUND512_0_TO_15(a,b,c,d,e,f,g,h); - ROUND512_0_TO_15(h,a,b,c,d,e,f,g); - ROUND512_0_TO_15(g,h,a,b,c,d,e,f); - ROUND512_0_TO_15(f,g,h,a,b,c,d,e); - ROUND512_0_TO_15(e,f,g,h,a,b,c,d); - ROUND512_0_TO_15(d,e,f,g,h,a,b,c); - ROUND512_0_TO_15(c,d,e,f,g,h,a,b); - ROUND512_0_TO_15(b,c,d,e,f,g,h,a); - } while (j < 16); - - /* Now for the remaining rounds up to 79: */ - do { - ROUND512(a,b,c,d,e,f,g,h); - ROUND512(h,a,b,c,d,e,f,g); - ROUND512(g,h,a,b,c,d,e,f); - ROUND512(f,g,h,a,b,c,d,e); - ROUND512(e,f,g,h,a,b,c,d); - ROUND512(d,e,f,g,h,a,b,c); - ROUND512(c,d,e,f,g,h,a,b); - ROUND512(b,c,d,e,f,g,h,a); - } while (j < 80); - - /* Compute the current intermediate hash value */ - context->state[0] += a; - context->state[1] += b; - context->state[2] += c; - context->state[3] += d; - context->state[4] += e; - context->state[5] += f; - context->state[6] += g; - context->state[7] += h; - - /* Clean up */ - a = b = c = d = e = f = g = h = T1 = 0; -} - -#else /* SHA2_UNROLL_TRANSFORM */ - -void apr__SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { - sha2_word64 a, b, c, d, e, f, g, h, s0, s1; - sha2_word64 T1, T2, *W512 = (sha2_word64*)context->buffer; - int j; - - /* Initialize registers with the prev. intermediate value */ - a = context->state[0]; - b = context->state[1]; - c = context->state[2]; - d = context->state[3]; - e = context->state[4]; - f = context->state[5]; - g = context->state[6]; - h = context->state[7]; - - j = 0; - do { -#if !APR_IS_BIGENDIAN - /* Convert TO host byte order */ - REVERSE64(*data++, W512[j]); - /* Apply the SHA-512 compression function to update a..h */ - T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + W512[j]; -#else /* APR_IS_BIGENDIAN */ - /* Apply the SHA-512 compression function to update a..h with copy */ - T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + (W512[j] = *data++); -#endif /* APR_IS_BIGENDIAN */ - T2 = Sigma0_512(a) + Maj(a, b, c); - h = g; - g = f; - f = e; - e = d + T1; - d = c; - c = b; - b = a; - a = T1 + T2; - - j++; - } while (j < 16); - - do { - /* Part of the message block expansion: */ - s0 = W512[(j+1)&0x0f]; - s0 = sigma0_512(s0); - s1 = W512[(j+14)&0x0f]; - s1 = sigma1_512(s1); - - /* Apply the SHA-512 compression function to update a..h */ - T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + - (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); - T2 = Sigma0_512(a) + Maj(a, b, c); - h = g; - g = f; - f = e; - e = d + T1; - d = c; - c = b; - b = a; - a = T1 + T2; - - j++; - } while (j < 80); - - /* Compute the current intermediate hash value */ - context->state[0] += a; - context->state[1] += b; - context->state[2] += c; - context->state[3] += d; - context->state[4] += e; - context->state[5] += f; - context->state[6] += g; - context->state[7] += h; - - /* Clean up */ - a = b = c = d = e = f = g = h = T1 = T2 = 0; -} - -#endif /* SHA2_UNROLL_TRANSFORM */ - -void apr__SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) { - unsigned int freespace, usedspace; - - if (len == 0) { - /* Calling with no data is valid - we do nothing */ - return; - } - - /* Sanity check: */ - assert(context != (SHA512_CTX*)0 && data != (sha2_byte*)0); - - usedspace = (unsigned int)((context->bitcount[0] >> 3) - % SHA512_BLOCK_LENGTH); - if (usedspace > 0) { - /* Calculate how much free space is available in the buffer */ - freespace = SHA512_BLOCK_LENGTH - usedspace; - - if (len >= freespace) { - /* Fill the buffer completely and process it */ - MEMCPY_BCOPY(&context->buffer[usedspace], data, freespace); - ADDINC128(context->bitcount, freespace << 3); - len -= freespace; - data += freespace; - apr__SHA512_Transform(context, (sha2_word64*)context->buffer); - } else { - /* The buffer is not yet full */ - MEMCPY_BCOPY(&context->buffer[usedspace], data, len); - ADDINC128(context->bitcount, len << 3); - /* Clean up: */ - usedspace = freespace = 0; - return; - } - } - while (len >= SHA512_BLOCK_LENGTH) { - /* Process as many complete blocks as we can */ - apr__SHA512_Transform(context, (sha2_word64*)data); - ADDINC128(context->bitcount, SHA512_BLOCK_LENGTH << 3); - len -= SHA512_BLOCK_LENGTH; - data += SHA512_BLOCK_LENGTH; - } - if (len > 0) { - /* There's left-overs, so save 'em */ - MEMCPY_BCOPY(context->buffer, data, len); - ADDINC128(context->bitcount, len << 3); - } - /* Clean up: */ - usedspace = freespace = 0; -} - -void apr__SHA512_Last(SHA512_CTX* context) { - unsigned int usedspace; - - usedspace = (unsigned int)((context->bitcount[0] >> 3) - % SHA512_BLOCK_LENGTH); -#if !APR_IS_BIGENDIAN - /* Convert FROM host byte order */ - REVERSE64(context->bitcount[0],context->bitcount[0]); - REVERSE64(context->bitcount[1],context->bitcount[1]); -#endif - if (usedspace > 0) { - /* Begin padding with a 1 bit: */ - context->buffer[usedspace++] = 0x80; - - if (usedspace <= SHA512_SHORT_BLOCK_LENGTH) { - /* Set-up for the last transform: */ - MEMSET_BZERO(&context->buffer[usedspace], SHA512_SHORT_BLOCK_LENGTH - usedspace); - } else { - if (usedspace < SHA512_BLOCK_LENGTH) { - MEMSET_BZERO(&context->buffer[usedspace], SHA512_BLOCK_LENGTH - usedspace); - } - /* Do second-to-last transform: */ - apr__SHA512_Transform(context, (sha2_word64*)context->buffer); - - /* And set-up for the last transform: */ - MEMSET_BZERO(context->buffer, SHA512_BLOCK_LENGTH - 2); - } - } else { - /* Prepare for final transform: */ - MEMSET_BZERO(context->buffer, SHA512_SHORT_BLOCK_LENGTH); - - /* Begin padding with a 1 bit: */ - *context->buffer = 0x80; - } - /* Store the length of input data (in bits): */ - *(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1]; - *(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0]; - - /* Final transform: */ - apr__SHA512_Transform(context, (sha2_word64*)context->buffer); -} - -void apr__SHA512_Final(sha2_byte digest[], SHA512_CTX* context) { - sha2_word64 *d = (sha2_word64*)digest; - - /* Sanity check: */ - assert(context != (SHA512_CTX*)0); - - /* If no digest buffer is passed, we don't bother doing this: */ - if (digest != (sha2_byte*)0) { - apr__SHA512_Last(context); - - /* Save the hash data for output: */ -#if !APR_IS_BIGENDIAN - { - /* Convert TO host byte order */ - int j; - for (j = 0; j < 8; j++) { - REVERSE64(context->state[j],context->state[j]); - *d++ = context->state[j]; - } - } -#else /* APR_IS_BIGENDIAN */ - MEMCPY_BCOPY(d, context->state, SHA512_DIGEST_LENGTH); -#endif /* APR_IS_BIGENDIAN */ - } - - /* Zero out state data */ - MEMSET_BZERO(context, sizeof(*context)); -} - -char *apr__SHA512_End(SHA512_CTX* context, char buffer[]) { - sha2_byte digest[SHA512_DIGEST_LENGTH], *d = digest; - int i; - - /* Sanity check: */ - assert(context != (SHA512_CTX*)0); - - if (buffer != (char*)0) { - apr__SHA512_Final(digest, context); - - for (i = 0; i < SHA512_DIGEST_LENGTH; i++) { - *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4]; - *buffer++ = sha2_hex_digits[*d & 0x0f]; - d++; - } - *buffer = (char)0; - } else { - MEMSET_BZERO(context, sizeof(*context)); - } - MEMSET_BZERO(digest, SHA512_DIGEST_LENGTH); - return buffer; -} - -char* apr__SHA512_Data(const sha2_byte* data, size_t len, char digest[SHA512_DIGEST_STRING_LENGTH]) { - SHA512_CTX context; - - apr__SHA512_Init(&context); - apr__SHA512_Update(&context, data, len); - return apr__SHA512_End(&context, digest); -} - - -/*** SHA-384: *********************************************************/ -void apr__SHA384_Init(SHA384_CTX* context) { - if (context == (SHA384_CTX*)0) { - return; - } - MEMCPY_BCOPY(context->state, sha384_initial_hash_value, SHA512_DIGEST_LENGTH); - MEMSET_BZERO(context->buffer, SHA384_BLOCK_LENGTH); - context->bitcount[0] = context->bitcount[1] = 0; -} - -void apr__SHA384_Update(SHA384_CTX* context, const sha2_byte* data, size_t len) { - apr__SHA512_Update((SHA512_CTX*)context, data, len); -} - -void apr__SHA384_Final(sha2_byte digest[], SHA384_CTX* context) { - sha2_word64 *d = (sha2_word64*)digest; - - /* Sanity check: */ - assert(context != (SHA384_CTX*)0); - - /* If no digest buffer is passed, we don't bother doing this: */ - if (digest != (sha2_byte*)0) { - apr__SHA512_Last((SHA512_CTX*)context); - - /* Save the hash data for output: */ -#if !APR_IS_BIGENDIAN - { - /* Convert TO host byte order */ - int j; - for (j = 0; j < 6; j++) { - REVERSE64(context->state[j],context->state[j]); - *d++ = context->state[j]; - } - } -#else /* APR_IS_BIGENDIAN */ - MEMCPY_BCOPY(d, context->state, SHA384_DIGEST_LENGTH); -#endif /* APR_IS_BIGENDIAN */ - } - - /* Zero out state data */ - MEMSET_BZERO(context, sizeof(*context)); -} - -char *apr__SHA384_End(SHA384_CTX* context, char buffer[]) { - sha2_byte digest[SHA384_DIGEST_LENGTH], *d = digest; - int i; - - /* Sanity check: */ - assert(context != (SHA384_CTX*)0); - - if (buffer != (char*)0) { - apr__SHA384_Final(digest, context); - - for (i = 0; i < SHA384_DIGEST_LENGTH; i++) { - *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4]; - *buffer++ = sha2_hex_digits[*d & 0x0f]; - d++; - } - *buffer = (char)0; - } else { - MEMSET_BZERO(context, sizeof(*context)); - } - MEMSET_BZERO(digest, SHA384_DIGEST_LENGTH); - return buffer; -} - -char* apr__SHA384_Data(const sha2_byte* data, size_t len, char digest[SHA384_DIGEST_STRING_LENGTH]) { - SHA384_CTX context; - - apr__SHA384_Init(&context); - apr__SHA384_Update(&context, data, len); - return apr__SHA384_End(&context, digest); -} - diff --git a/libs/apr/random/unix/sha2.h b/libs/apr/random/unix/sha2.h deleted file mode 100644 index 9f0d93e1..00000000 --- a/libs/apr/random/unix/sha2.h +++ /dev/null @@ -1,86 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * FILE: sha2.h - * AUTHOR: Aaron D. Gifford - * - * A licence was granted to the ASF by Aaron on 4 November 2003. - */ - -#ifndef __SHA2_H__ -#define __SHA2_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "apr.h" - -/*** SHA-256/384/512 Various Length Definitions ***********************/ -#define SHA256_BLOCK_LENGTH 64 -#define SHA256_DIGEST_LENGTH 32 -#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) -#define SHA384_BLOCK_LENGTH 128 -#define SHA384_DIGEST_LENGTH 48 -#define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1) -#define SHA512_BLOCK_LENGTH 128 -#define SHA512_DIGEST_LENGTH 64 -#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) - - -/*** SHA-256/384/512 Context Structures *******************************/ -typedef struct _SHA256_CTX { - apr_uint32_t state[8]; - apr_uint64_t bitcount; - apr_byte_t buffer[SHA256_BLOCK_LENGTH]; -} SHA256_CTX; -typedef struct _SHA512_CTX { - apr_uint64_t state[8]; - apr_uint64_t bitcount[2]; - apr_byte_t buffer[SHA512_BLOCK_LENGTH]; -} SHA512_CTX; - -typedef SHA512_CTX SHA384_CTX; - - -/*** SHA-256/384/512 Function Prototypes ******************************/ -void apr__SHA256_Init(SHA256_CTX *); -void apr__SHA256_Update(SHA256_CTX *, const apr_byte_t *, size_t); -void apr__SHA256_Final(apr_byte_t [SHA256_DIGEST_LENGTH], SHA256_CTX *); -char* apr__SHA256_End(SHA256_CTX *, char [SHA256_DIGEST_STRING_LENGTH]); -char* apr__SHA256_Data(const apr_byte_t *, size_t, - char [SHA256_DIGEST_STRING_LENGTH]); - -void apr__SHA384_Init(SHA384_CTX *); -void apr__SHA384_Update(SHA384_CTX *, const apr_byte_t *, size_t); -void apr__SHA384_Final(apr_byte_t [SHA384_DIGEST_LENGTH], SHA384_CTX *); -char* apr__SHA384_End(SHA384_CTX *, char [SHA384_DIGEST_STRING_LENGTH]); -char* apr__SHA384_Data(const apr_byte_t *, size_t, - char [SHA384_DIGEST_STRING_LENGTH]); - -void apr__SHA512_Init(SHA512_CTX *); -void apr__SHA512_Update(SHA512_CTX *, const apr_byte_t *, size_t); -void apr__SHA512_Final(apr_byte_t [SHA512_DIGEST_LENGTH], SHA512_CTX *); -char* apr__SHA512_End(SHA512_CTX *, char [SHA512_DIGEST_STRING_LENGTH]); -char* apr__SHA512_Data(const apr_byte_t *, size_t, - char [SHA512_DIGEST_STRING_LENGTH]); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __SHA2_H__ */ - diff --git a/libs/apr/random/unix/sha2_glue.c b/libs/apr/random/unix/sha2_glue.c deleted file mode 100644 index 4909a8fe..00000000 --- a/libs/apr/random/unix/sha2_glue.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include -#include -#include "sha2.h" - -static void sha256_init(apr_crypto_hash_t *h) - { - apr__SHA256_Init(h->data); - } - -static void sha256_add(apr_crypto_hash_t *h,const void *data, - apr_size_t bytes) - { - apr__SHA256_Update(h->data,data,bytes); - } - -static void sha256_finish(apr_crypto_hash_t *h,unsigned char *result) - { - apr__SHA256_Final(result,h->data); - } - -APR_DECLARE(apr_crypto_hash_t *) apr_crypto_sha256_new(apr_pool_t *p) - { - apr_crypto_hash_t *h=apr_palloc(p,sizeof *h); - - h->data=apr_palloc(p,sizeof(SHA256_CTX)); - h->init=sha256_init; - h->add=sha256_add; - h->finish=sha256_finish; - h->size=256/8; - - return h; - } diff --git a/libs/apr/shmem/beos/shm.c b/libs/apr/shmem/beos/shm.c deleted file mode 100644 index 1f06f78a..00000000 --- a/libs/apr/shmem/beos/shm.c +++ /dev/null @@ -1,166 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_general.h" -#include "apr_shm.h" -#include "apr_errno.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include -#include -#include -#include "apr_portable.h" - -struct apr_shm_t { - apr_pool_t *pool; - void *memblock; - void *ptr; - apr_size_t reqsize; - apr_size_t avail; - area_id aid; -}; - -APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, - apr_size_t reqsize, - const char *filename, - apr_pool_t *p) -{ - apr_size_t pagesize; - area_id newid; - char *addr; - char shname[B_OS_NAME_LENGTH]; - - (*m) = (apr_shm_t *)apr_pcalloc(p, sizeof(apr_shm_t)); - /* we MUST allocate in pages, so calculate how big an area we need... */ - pagesize = ((reqsize + B_PAGE_SIZE - 1) / B_PAGE_SIZE) * B_PAGE_SIZE; - - if (!filename) { - int num = 0; - snprintf(shname, B_OS_NAME_LENGTH, "apr_shmem_%ld", find_thread(NULL)); - while (find_area(shname) >= 0) - snprintf(shname, B_OS_NAME_LENGTH, "apr_shmem_%ld_%d", - find_thread(NULL), num++); - } - newid = create_area(filename ? filename : shname, - (void*)&addr, B_ANY_ADDRESS, - pagesize, B_LAZY_LOCK, B_READ_AREA|B_WRITE_AREA); - - if (newid < 0) - return errno; - - (*m)->pool = p; - (*m)->aid = newid; - (*m)->memblock = addr; - (*m)->ptr = (void*)addr; - (*m)->avail = pagesize; /* record how big an area we actually created... */ - (*m)->reqsize = reqsize; - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shm_t *m) -{ - delete_area(m->aid); - m->avail = 0; - m->memblock = NULL; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename, - apr_pool_t *pool) -{ - area_id deleteme = find_area(filename); - - if (deleteme == B_NAME_NOT_FOUND) - return APR_EINVAL; - - delete_area(deleteme); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, - const char *filename, - apr_pool_t *pool) -{ - area_info ai; - thread_info ti; - apr_shm_t *new_m; - area_id deleteme = find_area(filename); - - if (deleteme == B_NAME_NOT_FOUND) - return APR_EINVAL; - - new_m = (apr_shm_t*)apr_palloc(pool, sizeof(apr_shm_t*)); - if (new_m == NULL) - return APR_ENOMEM; - new_m->pool = pool; - - get_area_info(deleteme, &ai); - get_thread_info(find_thread(NULL), &ti); - - if (ti.team != ai.team) { - area_id narea; - - narea = clone_area(ai.name, &(ai.address), B_CLONE_ADDRESS, - B_READ_AREA|B_WRITE_AREA, ai.area); - - if (narea < B_OK) - return narea; - - get_area_info(narea, &ai); - new_m->aid = narea; - new_m->memblock = ai.address; - new_m->ptr = (void*)ai.address; - new_m->avail = ai.size; - new_m->reqsize = ai.size; - } - - (*m) = new_m; - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_shm_detach(apr_shm_t *m) -{ - delete_area(m->aid); - return APR_SUCCESS; -} - -APR_DECLARE(void *) apr_shm_baseaddr_get(const apr_shm_t *m) -{ - return m->memblock; -} - -APR_DECLARE(apr_size_t) apr_shm_size_get(const apr_shm_t *m) -{ - return m->reqsize; -} - -APR_POOL_IMPLEMENT_ACCESSOR(shm) - -APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm, - apr_shm_t *shm) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_os_shm_put(apr_shm_t **m, - apr_os_shm_t *osshm, - apr_pool_t *pool) -{ - return APR_ENOTIMPL; -} - diff --git a/libs/apr/shmem/os2/shm.c b/libs/apr/shmem/os2/shm.c deleted file mode 100644 index 340cae40..00000000 --- a/libs/apr/shmem/os2/shm.c +++ /dev/null @@ -1,144 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_general.h" -#include "apr_shm.h" -#include "apr_errno.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_portable.h" - -struct apr_shm_t { - apr_pool_t *pool; - void *memblock; -}; - -APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, - apr_size_t reqsize, - const char *filename, - apr_pool_t *pool) -{ - int rc; - apr_shm_t *newm = (apr_shm_t *)apr_palloc(pool, sizeof(apr_shm_t)); - char *name = NULL; - ULONG flags = PAG_COMMIT|PAG_READ|PAG_WRITE; - - newm->pool = pool; - - if (filename) { - name = apr_pstrcat(pool, "\\SHAREMEM\\", filename, NULL); - } - - if (name == NULL) { - flags |= OBJ_GETTABLE; - } - - rc = DosAllocSharedMem(&(newm->memblock), name, reqsize, flags); - - if (rc) { - return APR_OS2_STATUS(rc); - } - - *m = newm; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shm_t *m) -{ - DosFreeMem(m->memblock); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename, - apr_pool_t *pool) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, - const char *filename, - apr_pool_t *pool) -{ - int rc; - apr_shm_t *newm = (apr_shm_t *)apr_palloc(pool, sizeof(apr_shm_t)); - char *name = NULL; - ULONG flags = PAG_READ|PAG_WRITE; - - newm->pool = pool; - name = apr_pstrcat(pool, "\\SHAREMEM\\", filename, NULL); - - rc = DosGetNamedSharedMem(&(newm->memblock), name, flags); - - if (rc) { - return APR_FROM_OS_ERROR(rc); - } - - *m = newm; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_shm_detach(apr_shm_t *m) -{ - int rc = 0; - - if (m->memblock) { - rc = DosFreeMem(m->memblock); - } - - return APR_FROM_OS_ERROR(rc); -} - -APR_DECLARE(void *) apr_shm_baseaddr_get(const apr_shm_t *m) -{ - return m->memblock; -} - -APR_DECLARE(apr_size_t) apr_shm_size_get(const apr_shm_t *m) -{ - ULONG flags, size = 0x1000000; - DosQueryMem(m->memblock, &size, &flags); - return size; -} - -APR_POOL_IMPLEMENT_ACCESSOR(shm) - -APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm, - apr_shm_t *shm) -{ - *osshm = shm->memblock; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_shm_put(apr_shm_t **m, - apr_os_shm_t *osshm, - apr_pool_t *pool) -{ - int rc; - apr_shm_t *newm = (apr_shm_t *)apr_palloc(pool, sizeof(apr_shm_t)); - ULONG flags = PAG_COMMIT|PAG_READ|PAG_WRITE; - - newm->pool = pool; - - rc = DosGetSharedMem(&(newm->memblock), flags); - - if (rc) { - return APR_FROM_OS_ERROR(rc); - } - - *m = newm; - return APR_SUCCESS; -} - diff --git a/libs/apr/shmem/unix/shm.c b/libs/apr/shmem/unix/shm.c deleted file mode 100644 index 80d56894..00000000 --- a/libs/apr/shmem/unix/shm.c +++ /dev/null @@ -1,598 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_shm.h" - -#include "apr_general.h" -#include "apr_errno.h" -#include "apr_user.h" -#include "apr_strings.h" - -static apr_status_t shm_cleanup_owner(void *m_) -{ - apr_shm_t *m = (apr_shm_t *)m_; - - /* anonymous shared memory */ - if (m->filename == NULL) { -#if APR_USE_SHMEM_MMAP_ZERO || APR_USE_SHMEM_MMAP_ANON - if (munmap(m->base, m->realsize) == -1) { - return errno; - } - return APR_SUCCESS; -#elif APR_USE_SHMEM_SHMGET_ANON - if (shmdt(m->base) == -1) { - return errno; - } - /* This segment will automatically remove itself after all - * references have detached. */ - return APR_SUCCESS; -#endif - } - - /* name-based shared memory */ - else { -#if APR_USE_SHMEM_MMAP_TMP - if (munmap(m->base, m->realsize) == -1) { - return errno; - } - if (access(m->filename, F_OK)) { - return APR_SUCCESS; - } - else { - return apr_file_remove(m->filename, m->pool); - } -#elif APR_USE_SHMEM_MMAP_SHM - if (munmap(m->base, m->realsize) == -1) { - return errno; - } - if (shm_unlink(m->filename) == -1) { - return errno; - } - return APR_SUCCESS; -#elif APR_USE_SHMEM_SHMGET - /* Indicate that the segment is to be destroyed as soon - * as all processes have detached. This also disallows any - * new attachments to the segment. */ - if (shmctl(m->shmid, IPC_RMID, NULL) == -1 && errno != EINVAL) { - return errno; - } - if (shmdt(m->base) == -1) { - return errno; - } - if (access(m->filename, F_OK)) { - return APR_SUCCESS; - } - else { - return apr_file_remove(m->filename, m->pool); - } -#else - return APR_ENOTIMPL; -#endif - } -} - -APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, - apr_size_t reqsize, - const char *filename, - apr_pool_t *pool) -{ - apr_shm_t *new_m; - apr_status_t status; -#if APR_USE_SHMEM_SHMGET || APR_USE_SHMEM_SHMGET_ANON - struct shmid_ds shmbuf; - apr_uid_t uid; - apr_gid_t gid; -#endif -#if APR_USE_SHMEM_MMAP_TMP || APR_USE_SHMEM_MMAP_SHM || \ - APR_USE_SHMEM_MMAP_ZERO - int tmpfd; -#endif -#if APR_USE_SHMEM_SHMGET - apr_size_t nbytes; - key_t shmkey; -#endif -#if APR_USE_SHMEM_MMAP_ZERO || APR_USE_SHMEM_SHMGET || \ - APR_USE_SHMEM_MMAP_TMP || APR_USE_SHMEM_MMAP_SHM - apr_file_t *file; /* file where metadata is stored */ -#endif - - /* Check if they want anonymous or name-based shared memory */ - if (filename == NULL) { -#if APR_USE_SHMEM_MMAP_ZERO || APR_USE_SHMEM_MMAP_ANON - new_m = apr_palloc(pool, sizeof(apr_shm_t)); - new_m->pool = pool; - new_m->reqsize = reqsize; - new_m->realsize = reqsize + - APR_ALIGN_DEFAULT(sizeof(apr_size_t)); /* room for metadata */ - new_m->filename = NULL; - -#if APR_USE_SHMEM_MMAP_ZERO - status = apr_file_open(&file, "/dev/zero", APR_READ | APR_WRITE, - APR_OS_DEFAULT, pool); - if (status != APR_SUCCESS) { - return status; - } - status = apr_os_file_get(&tmpfd, file); - if (status != APR_SUCCESS) { - return status; - } - - new_m->base = mmap(NULL, new_m->realsize, PROT_READ|PROT_WRITE, - MAP_SHARED, tmpfd, 0); - if (new_m->base == (void *)MAP_FAILED) { - return errno; - } - - status = apr_file_close(file); - if (status != APR_SUCCESS) { - return status; - } - - /* store the real size in the metadata */ - *(apr_size_t*)(new_m->base) = new_m->realsize; - /* metadata isn't usable */ - new_m->usable = (char *)new_m->base + APR_ALIGN_DEFAULT(sizeof(apr_size_t)); - - apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_owner, - apr_pool_cleanup_null); - *m = new_m; - return APR_SUCCESS; - -#elif APR_USE_SHMEM_MMAP_ANON - new_m->base = mmap(NULL, new_m->realsize, PROT_READ|PROT_WRITE, - MAP_ANON|MAP_SHARED, -1, 0); - if (new_m->base == (void *)MAP_FAILED) { - return errno; - } - - /* store the real size in the metadata */ - *(apr_size_t*)(new_m->base) = new_m->realsize; - /* metadata isn't usable */ - new_m->usable = (char *)new_m->base + APR_ALIGN_DEFAULT(sizeof(apr_size_t)); - - apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_owner, - apr_pool_cleanup_null); - *m = new_m; - return APR_SUCCESS; - -#endif /* APR_USE_SHMEM_MMAP_ZERO */ -#elif APR_USE_SHMEM_SHMGET_ANON - new_m = apr_palloc(pool, sizeof(apr_shm_t)); - new_m->pool = pool; - new_m->reqsize = reqsize; - new_m->realsize = reqsize; - new_m->filename = NULL; - - if ((new_m->shmid = shmget(IPC_PRIVATE, new_m->realsize, - SHM_R | SHM_W | IPC_CREAT)) < 0) { - return errno; - } - - if ((new_m->base = shmat(new_m->shmid, NULL, 0)) == (void *)-1) { - return errno; - } - new_m->usable = new_m->base; - - if (shmctl(new_m->shmid, IPC_STAT, &shmbuf) == -1) { - return errno; - } - apr_uid_current(&uid, &gid, pool); - shmbuf.shm_perm.uid = uid; - shmbuf.shm_perm.gid = gid; - if (shmctl(new_m->shmid, IPC_SET, &shmbuf) == -1) { - return errno; - } - - /* Remove the segment once use count hits zero. - * We will not attach to this segment again, since it is - * anonymous memory, so it is ok to mark it for deletion. - */ - if (shmctl(new_m->shmid, IPC_RMID, NULL) == -1) { - return errno; - } - - apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_owner, - apr_pool_cleanup_null); - *m = new_m; - return APR_SUCCESS; -#else - /* It is an error if they want anonymous memory but we don't have it. */ - return APR_ENOTIMPL; /* requested anonymous but we don't have it */ -#endif - } - - /* Name-based shared memory */ - else { - new_m = apr_palloc(pool, sizeof(apr_shm_t)); - new_m->pool = pool; - new_m->reqsize = reqsize; - new_m->filename = apr_pstrdup(pool, filename); - -#if APR_USE_SHMEM_MMAP_TMP || APR_USE_SHMEM_MMAP_SHM - new_m->realsize = reqsize + - APR_ALIGN_DEFAULT(sizeof(apr_size_t)); /* room for metadata */ - /* FIXME: Ignore error for now. * - * status = apr_file_remove(file, pool);*/ - status = APR_SUCCESS; - -#if APR_USE_SHMEM_MMAP_TMP - /* FIXME: Is APR_OS_DEFAULT sufficient? */ - status = apr_file_open(&file, filename, - APR_READ | APR_WRITE | APR_CREATE | APR_EXCL, - APR_OS_DEFAULT, pool); - if (status != APR_SUCCESS) { - return status; - } - - status = apr_os_file_get(&tmpfd, file); - if (status != APR_SUCCESS) { - apr_file_close(file); /* ignore errors, we're failing */ - apr_file_remove(new_m->filename, new_m->pool); - return status; - } - - status = apr_file_trunc(file, new_m->realsize); - if (status != APR_SUCCESS) { - apr_file_close(file); /* ignore errors, we're failing */ - apr_file_remove(new_m->filename, new_m->pool); - return status; - } - - new_m->base = mmap(NULL, new_m->realsize, PROT_READ | PROT_WRITE, - MAP_SHARED, tmpfd, 0); - /* FIXME: check for errors */ - - status = apr_file_close(file); - if (status != APR_SUCCESS) { - return status; - } -#endif /* APR_USE_SHMEM_MMAP_TMP */ -#if APR_USE_SHMEM_MMAP_SHM - tmpfd = shm_open(filename, O_RDWR | O_CREAT | O_EXCL, 0644); - if (tmpfd == -1) { - return errno; - } - - status = apr_os_file_put(&file, &tmpfd, - APR_READ | APR_WRITE | APR_CREATE | APR_EXCL, - pool); - if (status != APR_SUCCESS) { - return status; - } - - status = apr_file_trunc(file, new_m->realsize); - if (status != APR_SUCCESS) { - shm_unlink(filename); /* we're failing, remove the object */ - return status; - } - new_m->base = mmap(NULL, reqsize, PROT_READ | PROT_WRITE, - MAP_SHARED, tmpfd, 0); - - /* FIXME: check for errors */ - - status = apr_file_close(file); - if (status != APR_SUCCESS) { - return status; - } -#endif /* APR_USE_SHMEM_MMAP_SHM */ - - /* store the real size in the metadata */ - *(apr_size_t*)(new_m->base) = new_m->realsize; - /* metadata isn't usable */ - new_m->usable = (char *)new_m->base + APR_ALIGN_DEFAULT(sizeof(apr_size_t)); - - apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_owner, - apr_pool_cleanup_null); - *m = new_m; - return APR_SUCCESS; - -#elif APR_USE_SHMEM_SHMGET - new_m->realsize = reqsize; - - /* FIXME: APR_OS_DEFAULT is too permissive, switch to 600 I think. */ - status = apr_file_open(&file, filename, - APR_FOPEN_WRITE | APR_FOPEN_CREATE | APR_FOPEN_EXCL, - APR_OS_DEFAULT, pool); - if (status != APR_SUCCESS) { - return status; - } - - /* ftok() (on solaris at least) requires that the file actually - * exist before calling ftok(). */ - shmkey = ftok(filename, 1); - if (shmkey == (key_t)-1) { - return errno; - } - - if ((new_m->shmid = shmget(shmkey, new_m->realsize, - SHM_R | SHM_W | IPC_CREAT | IPC_EXCL)) < 0) { - return errno; - } - - if ((new_m->base = shmat(new_m->shmid, NULL, 0)) == (void *)-1) { - return errno; - } - new_m->usable = new_m->base; - - if (shmctl(new_m->shmid, IPC_STAT, &shmbuf) == -1) { - return errno; - } - apr_uid_current(&uid, &gid, pool); - shmbuf.shm_perm.uid = uid; - shmbuf.shm_perm.gid = gid; - if (shmctl(new_m->shmid, IPC_SET, &shmbuf) == -1) { - return errno; - } - - nbytes = sizeof(reqsize); - status = apr_file_write(file, (const void *)&reqsize, - &nbytes); - if (status != APR_SUCCESS) { - return status; - } - status = apr_file_close(file); - if (status != APR_SUCCESS) { - return status; - } - - apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_owner, - apr_pool_cleanup_null); - *m = new_m; - return APR_SUCCESS; - -#else - return APR_ENOTIMPL; -#endif - } -} - -APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename, - apr_pool_t *pool) -{ -#if APR_USE_SHMEM_SHMGET - apr_status_t status; - apr_file_t *file; - key_t shmkey; - int shmid; -#endif - -#if APR_USE_SHMEM_MMAP_TMP - return apr_file_remove(filename, pool); -#elif APR_USE_SHMEM_MMAP_SHM - if (shm_unlink(filename) == -1) { - return errno; - } - return APR_SUCCESS; -#elif APR_USE_SHMEM_SHMGET - /* Presume that the file already exists; just open for writing */ - status = apr_file_open(&file, filename, APR_FOPEN_WRITE, - APR_OS_DEFAULT, pool); - if (status) { - return status; - } - - /* ftok() (on solaris at least) requires that the file actually - * exist before calling ftok(). */ - shmkey = ftok(filename, 1); - if (shmkey == (key_t)-1) { - goto shm_remove_failed; - } - - apr_file_close(file); - - if ((shmid = shmget(shmkey, 0, SHM_R | SHM_W)) < 0) { - goto shm_remove_failed; - } - - /* Indicate that the segment is to be destroyed as soon - * as all processes have detached. This also disallows any - * new attachments to the segment. */ - if (shmctl(shmid, IPC_RMID, NULL) == -1) { - goto shm_remove_failed; - } - return apr_file_remove(filename, pool); - -shm_remove_failed: - status = errno; - /* ensure the file has been removed anyway. */ - apr_file_remove(filename, pool); - return status; -#else - - /* No support for anonymous shm */ - return APR_ENOTIMPL; -#endif -} - -APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shm_t *m) -{ - return apr_pool_cleanup_run(m->pool, m, shm_cleanup_owner); -} - -static apr_status_t shm_cleanup_attach(void *m_) -{ - apr_shm_t *m = (apr_shm_t *)m_; - - if (m->filename == NULL) { - /* It doesn't make sense to detach from an anonymous memory segment. */ - return APR_EINVAL; - } - else { -#if APR_USE_SHMEM_MMAP_TMP || APR_USE_SHMEM_MMAP_SHM - if (munmap(m->base, m->realsize) == -1) { - return errno; - } - return APR_SUCCESS; -#elif APR_USE_SHMEM_SHMGET - if (shmdt(m->base) == -1) { - return errno; - } - return APR_SUCCESS; -#else - return APR_ENOTIMPL; -#endif - } -} - -APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, - const char *filename, - apr_pool_t *pool) -{ - if (filename == NULL) { - /* It doesn't make sense to attach to a segment if you don't know - * the filename. */ - return APR_EINVAL; - } - else { -#if APR_USE_SHMEM_MMAP_TMP || APR_USE_SHMEM_MMAP_SHM - apr_shm_t *new_m; - apr_status_t status; - int tmpfd; - apr_file_t *file; /* file where metadata is stored */ - apr_size_t nbytes; - - new_m = apr_palloc(pool, sizeof(apr_shm_t)); - new_m->pool = pool; - new_m->filename = apr_pstrdup(pool, filename); - - status = apr_file_open(&file, filename, - APR_READ | APR_WRITE, - APR_OS_DEFAULT, pool); - if (status != APR_SUCCESS) { - return status; - } - status = apr_os_file_get(&tmpfd, file); - if (status != APR_SUCCESS) { - return status; - } - - nbytes = sizeof(new_m->realsize); - status = apr_file_read(file, (void *)&(new_m->realsize), - &nbytes); - if (status != APR_SUCCESS) { - return status; - } - - status = apr_os_file_get(&tmpfd, file); - if (status != APR_SUCCESS) { - apr_file_close(file); /* ignore errors, we're failing */ - apr_file_remove(new_m->filename, new_m->pool); - return status; - } - - new_m->reqsize = new_m->realsize - sizeof(apr_size_t); - - new_m->base = mmap(NULL, new_m->realsize, PROT_READ | PROT_WRITE, - MAP_SHARED, tmpfd, 0); - /* FIXME: check for errors */ - - status = apr_file_close(file); - if (status != APR_SUCCESS) { - return status; - } - - /* metadata isn't part of the usable segment */ - new_m->usable = (char *)new_m->base + APR_ALIGN_DEFAULT(sizeof(apr_size_t)); - - apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_attach, - apr_pool_cleanup_null); - *m = new_m; - return APR_SUCCESS; - -#elif APR_USE_SHMEM_SHMGET - apr_shm_t *new_m; - apr_status_t status; - apr_file_t *file; /* file where metadata is stored */ - apr_size_t nbytes; - key_t shmkey; - - new_m = apr_palloc(pool, sizeof(apr_shm_t)); - - status = apr_file_open(&file, filename, - APR_FOPEN_READ, APR_OS_DEFAULT, pool); - if (status != APR_SUCCESS) { - return status; - } - - nbytes = sizeof(new_m->reqsize); - status = apr_file_read(file, (void *)&(new_m->reqsize), - &nbytes); - if (status != APR_SUCCESS) { - return status; - } - status = apr_file_close(file); - if (status != APR_SUCCESS) { - return status; - } - - new_m->filename = apr_pstrdup(pool, filename); - new_m->pool = pool; - shmkey = ftok(filename, 1); - if (shmkey == (key_t)-1) { - return errno; - } - if ((new_m->shmid = shmget(shmkey, 0, SHM_R | SHM_W)) == -1) { - return errno; - } - if ((new_m->base = shmat(new_m->shmid, NULL, 0)) == (void *)-1) { - return errno; - } - new_m->usable = new_m->base; - new_m->realsize = new_m->reqsize; - - apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_attach, - apr_pool_cleanup_null); - *m = new_m; - return APR_SUCCESS; - -#else - return APR_ENOTIMPL; -#endif - } -} - -APR_DECLARE(apr_status_t) apr_shm_detach(apr_shm_t *m) -{ - apr_status_t rv = shm_cleanup_attach(m); - apr_pool_cleanup_kill(m->pool, m, shm_cleanup_attach); - return rv; -} - -APR_DECLARE(void *) apr_shm_baseaddr_get(const apr_shm_t *m) -{ - return m->usable; -} - -APR_DECLARE(apr_size_t) apr_shm_size_get(const apr_shm_t *m) -{ - return m->reqsize; -} - -APR_POOL_IMPLEMENT_ACCESSOR(shm) - -APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm, - apr_shm_t *shm) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_os_shm_put(apr_shm_t **m, - apr_os_shm_t *osshm, - apr_pool_t *pool) -{ - return APR_ENOTIMPL; -} - diff --git a/libs/apr/shmem/win32/shm.c b/libs/apr/shmem/win32/shm.c deleted file mode 100644 index da736aa6..00000000 --- a/libs/apr/shmem/win32/shm.c +++ /dev/null @@ -1,317 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_general.h" -#include "apr_errno.h" -#include "apr_file_io.h" -#include "apr_shm.h" -#include "apr_strings.h" -#include "apr_arch_file_io.h" -#include "limits.h" - -typedef struct memblock_t { - apr_size_t size; - apr_size_t length; -} memblock_t; - -struct apr_shm_t { - apr_pool_t *pool; - memblock_t *memblk; - void *usrmem; - apr_size_t size; - apr_size_t length; - HANDLE hMap; - const char *filename; -}; - -static apr_status_t shm_cleanup(void* shm) -{ - apr_status_t rv = APR_SUCCESS; - apr_shm_t *m = shm; - - if (!UnmapViewOfFile(m->memblk)) { - rv = apr_get_os_error(); - } - if (!CloseHandle(m->hMap)) { - rv = rv != APR_SUCCESS ? rv : apr_get_os_error(); - } - if (m->filename) { - /* Remove file if file backed */ - apr_status_t rc = apr_file_remove(m->filename, m->pool); - rv = rv != APR_SUCCESS ? rv : rc; - } - return rv; -} - -APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, - apr_size_t reqsize, - const char *file, - apr_pool_t *pool) -{ - static apr_size_t memblock = 0; - HANDLE hMap, hFile; - apr_status_t rv; - apr_size_t size; - apr_file_t *f; - void *base; - void *mapkey; - DWORD err, sizelo, sizehi; - - reqsize += sizeof(memblock_t); - - if (!memblock) - { - SYSTEM_INFO si; - GetSystemInfo(&si); - memblock = si.dwAllocationGranularity; - } - - /* Compute the granualar multiple of the pagesize */ - size = memblock * (1 + (reqsize - 1) / memblock); - sizelo = (DWORD)size; -#ifdef WIN64 - sizehi = (DWORD)(size >> 32); -#else - sizehi = 0; -#endif - - if (!file) { - /* Do Anonymous, which must be passed as a duplicated handle */ -#ifndef _WIN32_WCE - hFile = INVALID_HANDLE_VALUE; -#endif - mapkey = NULL; - } - else { - /* Do file backed, which is not an inherited handle - * While we could open APR_EXCL, it doesn't seem that Unix - * ever did. Ignore that error here, but fail later when - * we discover we aren't the creator of the file map object. - */ - rv = apr_file_open(&f, file, - APR_READ | APR_WRITE | APR_BINARY | APR_CREATE, - APR_UREAD | APR_UWRITE, pool); - if ((rv != APR_SUCCESS) - || ((rv = apr_os_file_get(&hFile, f)) != APR_SUCCESS)) { - return rv; - } - rv = apr_file_trunc(f, size); - - /* res_name_from_filename turns file into a pseudo-name - * without slashes or backslashes, and prepends the \global - * prefix on Win2K and later - */ - mapkey = res_name_from_filename(file, 1, pool); - } - -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - hMap = CreateFileMappingW(hFile, NULL, PAGE_READWRITE, - sizehi, sizelo, mapkey); - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - hMap = CreateFileMappingA(hFile, NULL, PAGE_READWRITE, - sizehi, sizelo, mapkey); - } -#endif - err = apr_get_os_error(); - - if (file) { - apr_file_close(f); - } - - if (hMap && APR_STATUS_IS_EEXIST(err)) { - CloseHandle(hMap); - return APR_EEXIST; - } - if (!hMap) { - return err; - } - - base = MapViewOfFile(hMap, FILE_MAP_READ | FILE_MAP_WRITE, - 0, 0, size); - if (!base) { - CloseHandle(hMap); - return apr_get_os_error(); - } - - *m = (apr_shm_t *) apr_palloc(pool, sizeof(apr_shm_t)); - (*m)->pool = pool; - (*m)->hMap = hMap; - (*m)->memblk = base; - (*m)->size = size; - - (*m)->usrmem = (char*)base + sizeof(memblock_t); - (*m)->length = reqsize - sizeof(memblock_t);; - - (*m)->memblk->length = (*m)->length; - (*m)->memblk->size = (*m)->size; - (*m)->filename = file ? apr_pstrdup(pool, file) : NULL; - - apr_pool_cleanup_register((*m)->pool, *m, - shm_cleanup, apr_pool_cleanup_null); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shm_t *m) -{ - apr_status_t rv = shm_cleanup(m); - apr_pool_cleanup_kill(m->pool, m, shm_cleanup); - return rv; -} - -APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename, - apr_pool_t *pool) -{ - return apr_file_remove(filename, pool); -} - -APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, - const char *file, - apr_pool_t *pool) -{ - HANDLE hMap; - void *mapkey; - void *base; - - if (!file) { - return APR_EINVAL; - } - else { - /* res_name_from_filename turns file into a pseudo-name - * without slashes or backslashes, and prepends the \global - * prefix on Win2K and later - */ - mapkey = res_name_from_filename(file, 1, pool); - } - -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { -#ifndef _WIN32_WCE - hMap = OpenFileMappingW(FILE_MAP_READ | FILE_MAP_WRITE, FALSE, mapkey); -#else - /* The WCE 3.0 lacks OpenFileMapping. So we emulate one with - * opening the existing shmem and reading its size from the header - */ - hMap = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, - PAGE_READWRITE, 0, sizeof(apr_shm_t), mapkey); -#endif - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - hMap = OpenFileMappingA(FILE_MAP_READ | FILE_MAP_WRITE, FALSE, mapkey); - } -#endif - - if (!hMap) { - return apr_get_os_error(); - } - - base = MapViewOfFile(hMap, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0); - if (!base) { - CloseHandle(hMap); - return apr_get_os_error(); - } - - *m = (apr_shm_t *) apr_palloc(pool, sizeof(apr_shm_t)); - (*m)->pool = pool; - (*m)->memblk = base; - /* Real (*m)->mem->size could be recovered with VirtualQuery */ - (*m)->size = (*m)->memblk->size; -#if _WIN32_WCE - /* Reopen with real size */ - UnmapViewOfFile(base); - CloseHandle(hMap); - - hMap = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, - PAGE_READWRITE, 0, (*m)->size, mapkey); - if (!hMap) { - return apr_get_os_error(); - } - base = MapViewOfFile(hMap, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0); - if (!base) { - CloseHandle(hMap); - return apr_get_os_error(); - } -#endif - (*m)->hMap = hMap; - (*m)->length = (*m)->memblk->length; - (*m)->usrmem = (char*)base + sizeof(memblock_t); - (*m)->filename = NULL; - - apr_pool_cleanup_register((*m)->pool, *m, - shm_cleanup, apr_pool_cleanup_null); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_shm_detach(apr_shm_t *m) -{ - apr_status_t rv = shm_cleanup(m); - apr_pool_cleanup_kill(m->pool, m, shm_cleanup); - return rv; -} - -APR_DECLARE(void *) apr_shm_baseaddr_get(const apr_shm_t *m) -{ - return m->usrmem; -} - -APR_DECLARE(apr_size_t) apr_shm_size_get(const apr_shm_t *m) -{ - return m->length; -} - -APR_POOL_IMPLEMENT_ACCESSOR(shm) - -APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm, - apr_shm_t *shm) -{ - *osshm = shm->hMap; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_shm_put(apr_shm_t **m, - apr_os_shm_t *osshm, - apr_pool_t *pool) -{ - void* base; - base = MapViewOfFile(*osshm, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0); - if (!base) { - return apr_get_os_error(); - } - - *m = (apr_shm_t *) apr_palloc(pool, sizeof(apr_shm_t)); - (*m)->pool = pool; - (*m)->hMap = *osshm; - (*m)->memblk = base; - (*m)->usrmem = (char*)base + sizeof(memblock_t); - /* Real (*m)->mem->size could be recovered with VirtualQuery */ - (*m)->size = (*m)->memblk->size; - (*m)->length = (*m)->memblk->length; - (*m)->filename = NULL; - - apr_pool_cleanup_register((*m)->pool, *m, - shm_cleanup, apr_pool_cleanup_null); - return APR_SUCCESS; -} - diff --git a/libs/apr/strings/apr_cpystrn.c b/libs/apr/strings/apr_cpystrn.c deleted file mode 100644 index 6311c29f..00000000 --- a/libs/apr/strings/apr_cpystrn.c +++ /dev/null @@ -1,311 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_strings.h" -#include "apr_private.h" -#include "apr_lib.h" - -#if APR_HAVE_SYS_TYPES_H -#include -#endif -#if APR_HAVE_STRING_H -#include -#endif -#if APR_HAVE_CTYPE_H -#include -#endif - -/* - * Apache's "replacement" for the strncpy() function. We roll our - * own to implement these specific changes: - * (1) strncpy() doesn't always null terminate and we want it to. - * (2) strncpy() null fills, which is bogus, esp. when copy 8byte - * strings into 8k blocks. - * (3) Instead of returning the pointer to the beginning of - * the destination string, we return a pointer to the - * terminating '\0' to allow us to "check" for truncation - * - * apr_cpystrn() follows the same call structure as strncpy(). - */ - -APR_DECLARE(char *) apr_cpystrn(char *dst, const char *src, apr_size_t dst_size) -{ - - char *d, *end; - - if (dst_size == 0) { - return (dst); - } - - d = dst; - end = dst + dst_size - 1; - - for (; d < end; ++d, ++src) { - if (!(*d = *src)) { - return (d); - } - } - - *d = '\0'; /* always null terminate */ - - return (d); -} - - -/* - * This function provides a way to parse a generic argument string - * into a standard argv[] form of argument list. It respects the - * usual "whitespace" and quoteing rules. In the future this could - * be expanded to include support for the apr_call_exec command line - * string processing (including converting '+' to ' ' and doing the - * url processing. It does not currently support this function. - * - * token_context: Context from which pool allocations will occur. - * arg_str: Input argument string for conversion to argv[]. - * argv_out: Output location. This is a pointer to an array - * of pointers to strings (ie. &(char *argv[]). - * This value will be allocated from the contexts - * pool and filled in with copies of the tokens - * found during parsing of the arg_str. - */ -APR_DECLARE(apr_status_t) apr_tokenize_to_argv(const char *arg_str, - char ***argv_out, - apr_pool_t *token_context) -{ - const char *cp; - const char *ct; - char *cleaned, *dirty; - int escaped; - int isquoted, numargs = 0, argnum; - -#define SKIP_WHITESPACE(cp) \ - for ( ; *cp == ' ' || *cp == '\t'; ) { \ - cp++; \ - }; - -#define CHECK_QUOTATION(cp,isquoted) \ - isquoted = 0; \ - if (*cp == '"') { \ - isquoted = 1; \ - cp++; \ - } \ - else if (*cp == '\'') { \ - isquoted = 2; \ - cp++; \ - } - -/* DETERMINE_NEXTSTRING: - * At exit, cp will point to one of the following: NULL, SPACE, TAB or QUOTE. - * NULL implies the argument string has been fully traversed. - */ -#define DETERMINE_NEXTSTRING(cp,isquoted) \ - for ( ; *cp != '\0'; cp++) { \ - if ( (*cp == '\\' && (*(cp+1) == ' ' || *(cp+1) == '\t' || \ - *(cp+1) == '"' || *(cp+1) == '\''))) { \ - cp++; \ - continue; \ - } \ - if ( (!isquoted && (*cp == ' ' || *cp == '\t')) \ - || (isquoted == 1 && *cp == '"') \ - || (isquoted == 2 && *cp == '\'') ) { \ - break; \ - } \ - } - -/* REMOVE_ESCAPE_CHARS: - * Compresses the arg string to remove all of the '\' escape chars. - * The final argv strings should not have any extra escape chars in it. - */ -#define REMOVE_ESCAPE_CHARS(cleaned, dirty, escaped) \ - escaped = 0; \ - while(*dirty) { \ - if (!escaped && *dirty == '\\') { \ - escaped = 1; \ - } \ - else { \ - escaped = 0; \ - *cleaned++ = *dirty; \ - } \ - ++dirty; \ - } \ - *cleaned = 0; /* last line of macro... */ - - cp = arg_str; - SKIP_WHITESPACE(cp); - ct = cp; - - /* This is ugly and expensive, but if anyone wants to figure a - * way to support any number of args without counting and - * allocating, please go ahead and change the code. - * - * Must account for the trailing NULL arg. - */ - numargs = 1; - while (*ct != '\0') { - CHECK_QUOTATION(ct, isquoted); - DETERMINE_NEXTSTRING(ct, isquoted); - if (*ct != '\0') { - ct++; - } - numargs++; - SKIP_WHITESPACE(ct); - } - *argv_out = apr_palloc(token_context, numargs * sizeof(char*)); - - /* determine first argument */ - for (argnum = 0; argnum < (numargs-1); argnum++) { - SKIP_WHITESPACE(cp); - CHECK_QUOTATION(cp, isquoted); - ct = cp; - DETERMINE_NEXTSTRING(cp, isquoted); - cp++; - (*argv_out)[argnum] = apr_palloc(token_context, cp - ct); - apr_cpystrn((*argv_out)[argnum], ct, cp - ct); - cleaned = dirty = (*argv_out)[argnum]; - REMOVE_ESCAPE_CHARS(cleaned, dirty, escaped); - } - (*argv_out)[argnum] = NULL; - - return APR_SUCCESS; -} - -/* Filepath_name_get returns the final element of the pathname. - * Using the current platform's filename syntax. - * "/foo/bar/gum" -> "gum" - * "/foo/bar/gum/" -> "" - * "gum" -> "gum" - * "wi\\n32\\stuff" -> "stuff - * - * Corrected Win32 to accept "a/b\\stuff", "a:stuff" - */ - -APR_DECLARE(const char *) apr_filepath_name_get(const char *pathname) -{ - const char path_separator = '/'; - const char *s = strrchr(pathname, path_separator); - -#ifdef WIN32 - const char path_separator_win = '\\'; - const char drive_separator_win = ':'; - const char *s2 = strrchr(pathname, path_separator_win); - - if (s2 > s) s = s2; - - if (!s) s = strrchr(pathname, drive_separator_win); -#endif - - return s ? ++s : pathname; -} - -/* length of dest assumed >= length of src - * collapse in place (src == dest) is legal. - * returns terminating null ptr to dest string. - */ -APR_DECLARE(char *) apr_collapse_spaces(char *dest, const char *src) -{ - while (*src) { - if (!apr_isspace(*src)) - *dest++ = *src; - ++src; - } - *dest = 0; - return (dest); -} - -#if !APR_HAVE_STRDUP -char *strdup(const char *str) -{ - char *sdup; - size_t len = strlen(str) + 1; - - sdup = (char *) malloc(len); - memcpy(sdup, str, len); - - return sdup; -} -#endif - -/* The following two routines were donated for SVR4 by Andreas Vogel */ -#if (!APR_HAVE_STRCASECMP && !APR_HAVE_STRICMP) -int strcasecmp(const char *a, const char *b) -{ - const char *p = a; - const char *q = b; - for (p = a, q = b; *p && *q; p++, q++) { - int diff = apr_tolower(*p) - apr_tolower(*q); - if (diff) - return diff; - } - if (*p) - return 1; /* p was longer than q */ - if (*q) - return -1; /* p was shorter than q */ - return 0; /* Exact match */ -} - -#endif - -#if (!APR_HAVE_STRNCASECMP && !APR_HAVE_STRNICMP) -int strncasecmp(const char *a, const char *b, size_t n) -{ - const char *p = a; - const char *q = b; - - for (p = a, q = b; /*NOTHING */ ; p++, q++) { - int diff; - if (p == a + n) - return 0; /* Match up to n characters */ - if (!(*p && *q)) - return *p - *q; - diff = apr_tolower(*p) - apr_tolower(*q); - if (diff) - return diff; - } - /*NOTREACHED */ -} -#endif - -/* The following routine was donated for UTS21 by dwd@bell-labs.com */ -#if (!APR_HAVE_STRSTR) -char *strstr(char *s1, char *s2) -{ - char *p1, *p2; - if (*s2 == '\0') { - /* an empty s2 */ - return(s1); - } - while((s1 = strchr(s1, *s2)) != NULL) { - /* found first character of s2, see if the rest matches */ - p1 = s1; - p2 = s2; - while (*++p1 == *++p2) { - if (*p1 == '\0') { - /* both strings ended together */ - return(s1); - } - } - if (*p2 == '\0') { - /* second string ended, a match */ - break; - } - /* didn't find a match here, try starting at next character in s1 */ - s1++; - } - return(s1); -} -#endif - diff --git a/libs/apr/strings/apr_fnmatch.c b/libs/apr/strings/apr_fnmatch.c deleted file mode 100644 index c1c0e4af..00000000 --- a/libs/apr/strings/apr_fnmatch.c +++ /dev/null @@ -1,482 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/* Derived from The Open Group Base Specifications Issue 7, IEEE Std 1003.1-2008 - * as described in; - * http://pubs.opengroup.org/onlinepubs/9699919799/functions/fnmatch.html - * - * Filename pattern matches defined in section 2.13, "Pattern Matching Notation" - * from chapter 2. "Shell Command Language" - * http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13 - * where; 1. A bracket expression starting with an unquoted '^' - * character CONTINUES to specify a non-matching list; 2. an explicit '.' - * in a bracket expression matching list, e.g. "[.abc]" does NOT match a leading - * in a filename; 3. a '[' which does not introduce - * a valid bracket expression is treated as an ordinary character; 4. a differing - * number of consecutive slashes within pattern and string will NOT match; - * 5. a trailing '\' in FNM_ESCAPE mode is treated as an ordinary '\' character. - * - * Bracket expansion defined in section 9.3.5, "RE Bracket Expression", - * from chapter 9, "Regular Expressions" - * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03_05 - * with no support for collating symbols, equivalence class expressions or - * character class expressions. A partial range expression with a leading - * hyphen following a valid range expression will match only the ordinary - * and the ending character (e.g. "[a-m-z]" will match characters - * 'a' through 'm', a '-', or a 'z'). - * - * NOTE: Only POSIX/C single byte locales are correctly supported at this time. - * Notably, non-POSIX locales with FNM_CASEFOLD produce undefined results, - * particularly in ranges of mixed case (e.g. "[A-z]") or spanning alpha and - * nonalpha characters within a range. - * - * XXX comments below indicate porting required for multi-byte character sets - * and non-POSIX locale collation orders; requires mbr* APIs to track shift - * state of pattern and string (rewinding pattern and string repeatedly). - * - * Certain parts of the code assume 0x00-0x3F are unique with any MBCS (e.g. - * UTF-8, SHIFT-JIS, etc). Any implementation allowing '\' as an alternate - * path delimiter must be aware that 0x5C is NOT unique within SHIFT-JIS. - */ - -#include "apr_file_info.h" -#include "apr_fnmatch.h" -#include "apr_tables.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include -#if APR_HAVE_CTYPE_H -# include -#endif - - -/* Most MBCS/collation/case issues handled here. Wildcard '*' is not handled. - * EOS '\0' and the FNM_PATHNAME '/' delimiters are not advanced over, - * however the "\/" sequence is advanced to '/'. - * - * Both pattern and string are **char to support pointer increment of arbitrary - * multibyte characters for the given locale, in a later iteration of this code - */ -static APR_INLINE int fnmatch_ch(const char **pattern, const char **string, int flags) -{ - const char * const mismatch = *pattern; - const int nocase = !!(flags & APR_FNM_CASE_BLIND); - const int escape = !(flags & APR_FNM_NOESCAPE); - const int slash = !!(flags & APR_FNM_PATHNAME); - int result = APR_FNM_NOMATCH; - const char *startch; - int negate; - - if (**pattern == '[') - { - ++*pattern; - - /* Handle negation, either leading ! or ^ operators (never both) */ - negate = ((**pattern == '!') || (**pattern == '^')); - if (negate) - ++*pattern; - - /* ']' is an ordinary character at the start of the range pattern */ - if (**pattern == ']') - goto leadingclosebrace; - - while (**pattern) - { - if (**pattern == ']') { - ++*pattern; - /* XXX: Fix for MBCS character width */ - ++*string; - return (result ^ negate); - } - - if (escape && (**pattern == '\\')) { - ++*pattern; - - /* Patterns must be terminated with ']', not EOS */ - if (!**pattern) - break; - } - - /* Patterns must be terminated with ']' not '/' */ - if (slash && (**pattern == '/')) - break; - -leadingclosebrace: - /* Look at only well-formed range patterns; - * "x-]" is not allowed unless escaped ("x-\]") - * XXX: Fix for locale/MBCS character width - */ - if (((*pattern)[1] == '-') && ((*pattern)[2] != ']')) - { - startch = *pattern; - *pattern += (escape && ((*pattern)[2] == '\\')) ? 3 : 2; - - /* NOT a properly balanced [expr] pattern, EOS terminated - * or ranges containing a slash in FNM_PATHNAME mode pattern - * fall out to to the rewind and test '[' literal code path - */ - if (!**pattern || (slash && (**pattern == '/'))) - break; - - /* XXX: handle locale/MBCS comparison, advance by MBCS char width */ - if ((**string >= *startch) && (**string <= **pattern)) - result = 0; - else if (nocase && (isupper(**string) || isupper(*startch) - || isupper(**pattern)) - && (tolower(**string) >= tolower(*startch)) - && (tolower(**string) <= tolower(**pattern))) - result = 0; - - ++*pattern; - continue; - } - - /* XXX: handle locale/MBCS comparison, advance by MBCS char width */ - if ((**string == **pattern)) - result = 0; - else if (nocase && (isupper(**string) || isupper(**pattern)) - && (tolower(**string) == tolower(**pattern))) - result = 0; - - ++*pattern; - } - - /* NOT a properly balanced [expr] pattern; Rewind - * and reset result to test '[' literal - */ - *pattern = mismatch; - result = APR_FNM_NOMATCH; - } - else if (**pattern == '?') { - /* Optimize '?' match before unescaping **pattern */ - if (!**string || (slash && (**string == '/'))) - return APR_FNM_NOMATCH; - result = 0; - goto fnmatch_ch_success; - } - else if (escape && (**pattern == '\\') && (*pattern)[1]) { - ++*pattern; - } - - /* XXX: handle locale/MBCS comparison, advance by the MBCS char width */ - if (**string == **pattern) - result = 0; - else if (nocase && (isupper(**string) || isupper(**pattern)) - && (tolower(**string) == tolower(**pattern))) - result = 0; - - /* Refuse to advance over trailing slash or nulls - */ - if (!**string || !**pattern || (slash && ((**string == '/') || (**pattern == '/')))) - return result; - -fnmatch_ch_success: - ++*pattern; - ++*string; - return result; -} - - -APR_DECLARE(int) apr_fnmatch(const char *pattern, const char *string, int flags) -{ - static const char dummystring[2] = {' ', 0}; - const int escape = !(flags & APR_FNM_NOESCAPE); - const int slash = !!(flags & APR_FNM_PATHNAME); - const char *strendseg; - const char *dummyptr; - const char *matchptr; - int wild; - /* For '*' wild processing only; surpress 'used before initialization' - * warnings with dummy initialization values; - */ - const char *strstartseg = NULL; - const char *mismatch = NULL; - int matchlen = 0; - - if (*pattern == '*') - goto firstsegment; - - while (*pattern && *string) - { - /* Pre-decode "\/" which has no special significance, and - * match balanced slashes, starting a new segment pattern - */ - if (slash && escape && (*pattern == '\\') && (pattern[1] == '/')) - ++pattern; - if (slash && (*pattern == '/') && (*string == '/')) { - ++pattern; - ++string; - } - -firstsegment: - /* At the beginning of each segment, validate leading period behavior. - */ - if ((flags & APR_FNM_PERIOD) && (*string == '.')) - { - if (*pattern == '.') - ++pattern; - else if (escape && (*pattern == '\\') && (pattern[1] == '.')) - pattern += 2; - else - return APR_FNM_NOMATCH; - ++string; - } - - /* Determine the end of string segment - * - * Presumes '/' character is unique, not composite in any MBCS encoding - */ - if (slash) { - strendseg = strchr(string, '/'); - if (!strendseg) - strendseg = strchr(string, '\0'); - } - else { - strendseg = strchr(string, '\0'); - } - - /* Allow pattern '*' to be consumed even with no remaining string to match - */ - while (*pattern) - { - if ((string > strendseg) - || ((string == strendseg) && (*pattern != '*'))) - break; - - if (slash && ((*pattern == '/') - || (escape && (*pattern == '\\') - && (pattern[1] == '/')))) - break; - - /* Reduce groups of '*' and '?' to n '?' matches - * followed by one '*' test for simplicity - */ - for (wild = 0; ((*pattern == '*') || (*pattern == '?')); ++pattern) - { - if (*pattern == '*') { - wild = 1; - } - else if (string < strendseg) { /* && (*pattern == '?') */ - /* XXX: Advance 1 char for MBCS locale */ - ++string; - } - else { /* (string >= strendseg) && (*pattern == '?') */ - return APR_FNM_NOMATCH; - } - } - - if (wild) - { - strstartseg = string; - mismatch = pattern; - - /* Count fixed (non '*') char matches remaining in pattern - * excluding '/' (or "\/") and '*' - */ - for (matchptr = pattern, matchlen = 0; 1; ++matchlen) - { - if ((*matchptr == '\0') - || (slash && ((*matchptr == '/') - || (escape && (*matchptr == '\\') - && (matchptr[1] == '/'))))) - { - /* Compare precisely this many trailing string chars, - * the resulting match needs no wildcard loop - */ - /* XXX: Adjust for MBCS */ - if (string + matchlen > strendseg) - return APR_FNM_NOMATCH; - - string = strendseg - matchlen; - wild = 0; - break; - } - - if (*matchptr == '*') - { - /* Ensure at least this many trailing string chars remain - * for the first comparison - */ - /* XXX: Adjust for MBCS */ - if (string + matchlen > strendseg) - return APR_FNM_NOMATCH; - - /* Begin first wild comparison at the current position */ - break; - } - - /* Skip forward in pattern by a single character match - * Use a dummy fnmatch_ch() test to count one "[range]" escape - */ - /* XXX: Adjust for MBCS */ - if (escape && (*matchptr == '\\') && matchptr[1]) { - matchptr += 2; - } - else if (*matchptr == '[') { - dummyptr = dummystring; - fnmatch_ch(&matchptr, &dummyptr, flags); - } - else { - ++matchptr; - } - } - } - - /* Incrementally match string against the pattern - */ - while (*pattern && (string < strendseg)) - { - /* Success; begin a new wild pattern search - */ - if (*pattern == '*') - break; - - if (slash && ((*string == '/') - || (*pattern == '/') - || (escape && (*pattern == '\\') - && (pattern[1] == '/')))) - break; - - /* Compare ch's (the pattern is advanced over "\/" to the '/', - * but slashes will mismatch, and are not consumed) - */ - if (!fnmatch_ch(&pattern, &string, flags)) - continue; - - /* Failed to match, loop against next char offset of string segment - * until not enough string chars remain to match the fixed pattern - */ - if (wild) { - /* XXX: Advance 1 char for MBCS locale */ - string = ++strstartseg; - if (string + matchlen > strendseg) - return APR_FNM_NOMATCH; - - pattern = mismatch; - continue; - } - else - return APR_FNM_NOMATCH; - } - } - - if (*string && !(slash && (*string == '/'))) - return APR_FNM_NOMATCH; - - if (*pattern && !(slash && ((*pattern == '/') - || (escape && (*pattern == '\\') - && (pattern[1] == '/'))))) - return APR_FNM_NOMATCH; - } - - /* Where both pattern and string are at EOS, declare success - */ - if (!*string && !*pattern) - return 0; - - /* pattern didn't match to the end of string */ - return APR_FNM_NOMATCH; -} - - -/* This function is an Apache addition - * return non-zero if pattern has any glob chars in it - * @bug Function does not distinguish for FNM_PATHNAME mode, which renders - * a false positive for test[/]this (which is not a range, but - * seperate test[ and ]this segments and no glob.) - * @bug Function does not distinguish for non-FNM_ESCAPE mode. - * @bug Function does not parse []] correctly - * Solution may be to use fnmatch_ch() to walk the patterns? - */ -APR_DECLARE(int) apr_fnmatch_test(const char *pattern) -{ - int nesting; - - nesting = 0; - while (*pattern) { - switch (*pattern) { - case '?': - case '*': - return 1; - - case '\\': - if (*++pattern == '\0') { - return 0; - } - break; - - case '[': /* '[' is only a glob if it has a matching ']' */ - ++nesting; - break; - - case ']': - if (nesting) { - return 1; - } - break; - } - ++pattern; } - return 0; -} - - -/* Find all files matching the specified pattern */ -APR_DECLARE(apr_status_t) apr_match_glob(const char *pattern, - apr_array_header_t **result, - apr_pool_t *p) -{ - apr_dir_t *dir; - apr_finfo_t finfo; - apr_status_t rv; - char *path; - - /* XXX So, this is kind of bogus. Basically, I need to strip any leading - * directories off the pattern, but there is no portable way to do that. - * So, for now we just find the last occurance of '/' and if that doesn't - * return anything, then we look for '\'. This means that we could - * screw up on unix if the pattern is something like "foo\.*" That '\' - * isn't a directory delimiter, it is a part of the filename. To fix this, - * we really need apr_filepath_basename, which will be coming as soon as - * I get to it. rbb - */ - char *idx = strrchr(pattern, '/'); - - if (idx == NULL) { - idx = strrchr(pattern, '\\'); - } - if (idx == NULL) { - path = "."; - } - else { - path = apr_pstrndup(p, pattern, idx - pattern); - pattern = idx + 1; - } - - *result = apr_array_make(p, 0, sizeof(char *)); - rv = apr_dir_open(&dir, path, p); - if (rv != APR_SUCCESS) { - return rv; - } - - while (apr_dir_read(&finfo, APR_FINFO_NAME, dir) == APR_SUCCESS) { - if (apr_fnmatch(pattern, finfo.name, 0) == APR_SUCCESS) { - *(const char **)apr_array_push(*result) = apr_pstrdup(p, finfo.name); - } - } - apr_dir_close(dir); - return APR_SUCCESS; -} diff --git a/libs/apr/strings/apr_snprintf.c b/libs/apr/strings/apr_snprintf.c deleted file mode 100644 index 6a689a61..00000000 --- a/libs/apr/strings/apr_snprintf.c +++ /dev/null @@ -1,1408 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_private.h" - -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_network_io.h" -#include "apr_portable.h" -#include "apr_errno.h" -#include -#if APR_HAVE_CTYPE_H -#include -#endif -#if APR_HAVE_NETINET_IN_H -#include -#endif -#if APR_HAVE_SYS_SOCKET_H -#include -#endif -#if APR_HAVE_ARPA_INET_H -#include -#endif -#if APR_HAVE_LIMITS_H -#include -#endif -#if APR_HAVE_STRING_H -#include -#endif - -typedef enum { - NO = 0, YES = 1 -} boolean_e; - -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif -#define NUL '\0' - -static const char null_string[] = "(null)"; -#define S_NULL ((char *)null_string) -#define S_NULL_LEN 6 - -#define FLOAT_DIGITS 6 -#define EXPONENT_LENGTH 10 - -/* - * NUM_BUF_SIZE is the size of the buffer used for arithmetic conversions - * - * NOTICE: this is a magic number; do not decrease it - */ -#define NUM_BUF_SIZE 512 - -/* - * cvt - IEEE floating point formatting routines. - * Derived from UNIX V7, Copyright(C) Caldera International Inc. - */ - -/* - * apr_ecvt converts to decimal - * the number of digits is specified by ndigit - * decpt is set to the position of the decimal point - * sign is set to 0 for positive, 1 for negative - */ - -#define NDIG 80 - -/* buf must have at least NDIG bytes */ -static char *apr_cvt(double arg, int ndigits, int *decpt, int *sign, - int eflag, char *buf) -{ - register int r2; - double fi, fj; - register char *p, *p1; - - if (ndigits >= NDIG - 1) - ndigits = NDIG - 2; - r2 = 0; - *sign = 0; - p = &buf[0]; - if (arg < 0) { - *sign = 1; - arg = -arg; - } - arg = modf(arg, &fi); - p1 = &buf[NDIG]; - /* - * Do integer part - */ - if (fi != 0) { - p1 = &buf[NDIG]; - while (p1 > &buf[0] && fi != 0) { - fj = modf(fi / 10, &fi); - *--p1 = (int) ((fj + .03) * 10) + '0'; - r2++; - } - while (p1 < &buf[NDIG]) - *p++ = *p1++; - } - else if (arg > 0) { - while ((fj = arg * 10) < 1) { - arg = fj; - r2--; - } - } - p1 = &buf[ndigits]; - if (eflag == 0) - p1 += r2; - if (p1 < &buf[0]) { - *decpt = -ndigits; - buf[0] = '\0'; - return (buf); - } - *decpt = r2; - while (p <= p1 && p < &buf[NDIG]) { - arg *= 10; - arg = modf(arg, &fj); - *p++ = (int) fj + '0'; - } - if (p1 >= &buf[NDIG]) { - buf[NDIG - 1] = '\0'; - return (buf); - } - p = p1; - *p1 += 5; - while (*p1 > '9') { - *p1 = '0'; - if (p1 > buf) - ++ * --p1; - else { - *p1 = '1'; - (*decpt)++; - if (eflag == 0) { - if (p > buf) - *p = '0'; - p++; - } - } - } - *p = '\0'; - return (buf); -} - -static char *apr_ecvt(double arg, int ndigits, int *decpt, int *sign, char *buf) -{ - return (apr_cvt(arg, ndigits, decpt, sign, 1, buf)); -} - -static char *apr_fcvt(double arg, int ndigits, int *decpt, int *sign, char *buf) -{ - return (apr_cvt(arg, ndigits, decpt, sign, 0, buf)); -} - -/* - * apr_gcvt - Floating output conversion to - * minimal length string - */ - -static char *apr_gcvt(double number, int ndigit, char *buf, boolean_e altform) -{ - int sign, decpt; - register char *p1, *p2; - register int i; - char buf1[NDIG]; - - p1 = apr_ecvt(number, ndigit, &decpt, &sign, buf1); - p2 = buf; - if (sign) - *p2++ = '-'; - for (i = ndigit - 1; i > 0 && p1[i] == '0'; i--) - ndigit--; - if ((decpt >= 0 && decpt - ndigit > 4) - || (decpt < 0 && decpt < -3)) { /* use E-style */ - decpt--; - *p2++ = *p1++; - *p2++ = '.'; - for (i = 1; i < ndigit; i++) - *p2++ = *p1++; - *p2++ = 'e'; - if (decpt < 0) { - decpt = -decpt; - *p2++ = '-'; - } - else - *p2++ = '+'; - if (decpt / 100 > 0) - *p2++ = decpt / 100 + '0'; - if (decpt / 10 > 0) - *p2++ = (decpt % 100) / 10 + '0'; - *p2++ = decpt % 10 + '0'; - } - else { - if (decpt <= 0) { - if (*p1 != '0') - *p2++ = '.'; - while (decpt < 0) { - decpt++; - *p2++ = '0'; - } - } - for (i = 1; i <= ndigit; i++) { - *p2++ = *p1++; - if (i == decpt) - *p2++ = '.'; - } - if (ndigit < decpt) { - while (ndigit++ < decpt) - *p2++ = '0'; - *p2++ = '.'; - } - } - if (p2[-1] == '.' && !altform) - p2--; - *p2 = '\0'; - return (buf); -} - -/* - * The INS_CHAR macro inserts a character in the buffer and writes - * the buffer back to disk if necessary - * It uses the char pointers sp and bep: - * sp points to the next available character in the buffer - * bep points to the end-of-buffer+1 - * While using this macro, note that the nextb pointer is NOT updated. - * - * NOTE: Evaluation of the c argument should not have any side-effects - */ -#define INS_CHAR(c, sp, bep, cc) \ -{ \ - if (sp) { \ - if (sp >= bep) { \ - vbuff->curpos = sp; \ - if (flush_func(vbuff)) \ - return -1; \ - sp = vbuff->curpos; \ - bep = vbuff->endpos; \ - } \ - *sp++ = (c); \ - } \ - cc++; \ -} - -#define NUM(c) (c - '0') - -#define STR_TO_DEC(str, num) \ - num = NUM(*str++); \ - while (apr_isdigit(*str)) \ - { \ - num *= 10 ; \ - num += NUM(*str++); \ - } - -/* - * This macro does zero padding so that the precision - * requirement is satisfied. The padding is done by - * adding '0's to the left of the string that is going - * to be printed. We don't allow precision to be large - * enough that we continue past the start of s. - * - * NOTE: this makes use of the magic info that s is - * always based on num_buf with a size of NUM_BUF_SIZE. - */ -#define FIX_PRECISION(adjust, precision, s, s_len) \ - if (adjust) { \ - apr_size_t p = (precision + 1 < NUM_BUF_SIZE) \ - ? precision : NUM_BUF_SIZE - 1; \ - while (s_len < p) \ - { \ - *--s = '0'; \ - s_len++; \ - } \ - } - -/* - * Macro that does padding. The padding is done by printing - * the character ch. - */ -#define PAD(width, len, ch) \ -do \ -{ \ - INS_CHAR(ch, sp, bep, cc); \ - width--; \ -} \ -while (width > len) - -/* - * Prefix the character ch to the string str - * Increase length - * Set the has_prefix flag - */ -#define PREFIX(str, length, ch) \ - *--str = ch; \ - length++; \ - has_prefix=YES; - - -/* - * Convert num to its decimal format. - * Return value: - * - a pointer to a string containing the number (no sign) - * - len contains the length of the string - * - is_negative is set to TRUE or FALSE depending on the sign - * of the number (always set to FALSE if is_unsigned is TRUE) - * - * The caller provides a buffer for the string: that is the buf_end argument - * which is a pointer to the END of the buffer + 1 (i.e. if the buffer - * is declared as buf[ 100 ], buf_end should be &buf[ 100 ]) - * - * Note: we have 2 versions. One is used when we need to use quads - * (conv_10_quad), the other when we don't (conv_10). We're assuming the - * latter is faster. - */ -static char *conv_10(register apr_int32_t num, register int is_unsigned, - register int *is_negative, char *buf_end, - register apr_size_t *len) -{ - register char *p = buf_end; - register apr_uint32_t magnitude = num; - - if (is_unsigned) { - *is_negative = FALSE; - } - else { - *is_negative = (num < 0); - - /* - * On a 2's complement machine, negating the most negative integer - * results in a number that cannot be represented as a signed integer. - * Here is what we do to obtain the number's magnitude: - * a. add 1 to the number - * b. negate it (becomes positive) - * c. convert it to unsigned - * d. add 1 - */ - if (*is_negative) { - apr_int32_t t = num + 1; - magnitude = ((apr_uint32_t) -t) + 1; - } - } - - /* - * We use a do-while loop so that we write at least 1 digit - */ - do { - register apr_uint32_t new_magnitude = magnitude / 10; - - *--p = (char) (magnitude - new_magnitude * 10 + '0'); - magnitude = new_magnitude; - } - while (magnitude); - - *len = buf_end - p; - return (p); -} - -static char *conv_10_quad(apr_int64_t num, register int is_unsigned, - register int *is_negative, char *buf_end, - register apr_size_t *len) -{ - register char *p = buf_end; - apr_uint64_t magnitude = num; - - /* - * We see if we can use the faster non-quad version by checking the - * number against the largest long value it can be. If <=, we - * punt to the quicker version. - */ - if ((magnitude <= APR_UINT32_MAX && is_unsigned) - || (num <= APR_INT32_MAX && num >= APR_INT32_MIN && !is_unsigned)) - return(conv_10((apr_int32_t)num, is_unsigned, is_negative, buf_end, len)); - - if (is_unsigned) { - *is_negative = FALSE; - } - else { - *is_negative = (num < 0); - - /* - * On a 2's complement machine, negating the most negative integer - * results in a number that cannot be represented as a signed integer. - * Here is what we do to obtain the number's magnitude: - * a. add 1 to the number - * b. negate it (becomes positive) - * c. convert it to unsigned - * d. add 1 - */ - if (*is_negative) { - apr_int64_t t = num + 1; - magnitude = ((apr_uint64_t) -t) + 1; - } - } - - /* - * We use a do-while loop so that we write at least 1 digit - */ - do { - apr_uint64_t new_magnitude = magnitude / 10; - - *--p = (char) (magnitude - new_magnitude * 10 + '0'); - magnitude = new_magnitude; - } - while (magnitude); - - *len = buf_end - p; - return (p); -} - -static char *conv_in_addr(struct in_addr *ia, char *buf_end, apr_size_t *len) -{ - unsigned addr = ntohl(ia->s_addr); - char *p = buf_end; - int is_negative; - apr_size_t sub_len; - - p = conv_10((addr & 0x000000FF) , TRUE, &is_negative, p, &sub_len); - *--p = '.'; - p = conv_10((addr & 0x0000FF00) >> 8, TRUE, &is_negative, p, &sub_len); - *--p = '.'; - p = conv_10((addr & 0x00FF0000) >> 16, TRUE, &is_negative, p, &sub_len); - *--p = '.'; - p = conv_10((addr & 0xFF000000) >> 24, TRUE, &is_negative, p, &sub_len); - - *len = buf_end - p; - return (p); -} - - -/* Must be passed a buffer of size NUM_BUF_SIZE where buf_end points - * to 1 byte past the end of the buffer. */ -static char *conv_apr_sockaddr(apr_sockaddr_t *sa, char *buf_end, apr_size_t *len) -{ - char *p = buf_end; - int is_negative; - apr_size_t sub_len; - char *ipaddr_str; - - p = conv_10(sa->port, TRUE, &is_negative, p, &sub_len); - *--p = ':'; - ipaddr_str = buf_end - NUM_BUF_SIZE; - if (apr_sockaddr_ip_getbuf(ipaddr_str, sa->addr_str_len, sa)) { - /* Should only fail if the buffer is too small, which it - * should not be; but fail safe anyway: */ - *--p = '?'; - *len = buf_end - p; - return p; - } - sub_len = strlen(ipaddr_str); -#if APR_HAVE_IPV6 - if (sa->family == APR_INET6 && - !IN6_IS_ADDR_V4MAPPED(&sa->sa.sin6.sin6_addr)) { - *(p - 1) = ']'; - p -= sub_len + 2; - *p = '['; - memcpy(p + 1, ipaddr_str, sub_len); - } - else -#endif - { - p -= sub_len; - memcpy(p, ipaddr_str, sub_len); - } - - *len = buf_end - p; - return (p); -} - - - -#if APR_HAS_THREADS -static char *conv_os_thread_t(apr_os_thread_t *tid, char *buf_end, apr_size_t *len) -{ - union { - apr_os_thread_t tid; - apr_uint64_t u64; - apr_uint32_t u32; - } u; - int is_negative; - - u.tid = *tid; - switch(sizeof(u.tid)) { - case sizeof(apr_int32_t): - return conv_10(u.u32, TRUE, &is_negative, buf_end, len); - case sizeof(apr_int64_t): - return conv_10_quad(u.u64, TRUE, &is_negative, buf_end, len); - default: - /* not implemented; stick 0 in the buffer */ - return conv_10(0, TRUE, &is_negative, buf_end, len); - } -} -#endif - - - -/* - * Convert a floating point number to a string formats 'f', 'e' or 'E'. - * The result is placed in buf, and len denotes the length of the string - * The sign is returned in the is_negative argument (and is not placed - * in buf). - */ -static char *conv_fp(register char format, register double num, - boolean_e add_dp, int precision, int *is_negative, - char *buf, apr_size_t *len) -{ - register char *s = buf; - register char *p; - int decimal_point; - char buf1[NDIG]; - - if (format == 'f') - p = apr_fcvt(num, precision, &decimal_point, is_negative, buf1); - else /* either e or E format */ - p = apr_ecvt(num, precision + 1, &decimal_point, is_negative, buf1); - - /* - * Check for Infinity and NaN - */ - if (apr_isalpha(*p)) { - *len = strlen(p); - memcpy(buf, p, *len + 1); - *is_negative = FALSE; - return (buf); - } - - if (format == 'f') { - if (decimal_point <= 0) { - *s++ = '0'; - if (precision > 0) { - *s++ = '.'; - while (decimal_point++ < 0) - *s++ = '0'; - } - else if (add_dp) - *s++ = '.'; - } - else { - while (decimal_point-- > 0) - *s++ = *p++; - if (precision > 0 || add_dp) - *s++ = '.'; - } - } - else { - *s++ = *p++; - if (precision > 0 || add_dp) - *s++ = '.'; - } - - /* - * copy the rest of p, the NUL is NOT copied - */ - while (*p) - *s++ = *p++; - - if (format != 'f') { - char temp[EXPONENT_LENGTH]; /* for exponent conversion */ - apr_size_t t_len; - int exponent_is_negative; - - *s++ = format; /* either e or E */ - decimal_point--; - if (decimal_point != 0) { - p = conv_10((apr_int32_t) decimal_point, FALSE, &exponent_is_negative, - &temp[EXPONENT_LENGTH], &t_len); - *s++ = exponent_is_negative ? '-' : '+'; - - /* - * Make sure the exponent has at least 2 digits - */ - if (t_len == 1) - *s++ = '0'; - while (t_len--) - *s++ = *p++; - } - else { - *s++ = '+'; - *s++ = '0'; - *s++ = '0'; - } - } - - *len = s - buf; - return (buf); -} - - -/* - * Convert num to a base X number where X is a power of 2. nbits determines X. - * For example, if nbits is 3, we do base 8 conversion - * Return value: - * a pointer to a string containing the number - * - * The caller provides a buffer for the string: that is the buf_end argument - * which is a pointer to the END of the buffer + 1 (i.e. if the buffer - * is declared as buf[ 100 ], buf_end should be &buf[ 100 ]) - * - * As with conv_10, we have a faster version which is used when - * the number isn't quad size. - */ -static char *conv_p2(register apr_uint32_t num, register int nbits, - char format, char *buf_end, register apr_size_t *len) -{ - register int mask = (1 << nbits) - 1; - register char *p = buf_end; - static const char low_digits[] = "0123456789abcdef"; - static const char upper_digits[] = "0123456789ABCDEF"; - register const char *digits = (format == 'X') ? upper_digits : low_digits; - - do { - *--p = digits[num & mask]; - num >>= nbits; - } - while (num); - - *len = buf_end - p; - return (p); -} - -static char *conv_p2_quad(apr_uint64_t num, register int nbits, - char format, char *buf_end, register apr_size_t *len) -{ - register int mask = (1 << nbits) - 1; - register char *p = buf_end; - static const char low_digits[] = "0123456789abcdef"; - static const char upper_digits[] = "0123456789ABCDEF"; - register const char *digits = (format == 'X') ? upper_digits : low_digits; - - if (num <= APR_UINT32_MAX) - return(conv_p2((apr_uint32_t)num, nbits, format, buf_end, len)); - - do { - *--p = digits[num & mask]; - num >>= nbits; - } - while (num); - - *len = buf_end - p; - return (p); -} - -#if APR_HAS_THREADS -static char *conv_os_thread_t_hex(apr_os_thread_t *tid, char *buf_end, apr_size_t *len) -{ - union { - apr_os_thread_t tid; - apr_uint64_t u64; - apr_uint32_t u32; - } u; - int is_negative; - - u.tid = *tid; - switch(sizeof(u.tid)) { - case sizeof(apr_int32_t): - return conv_p2(u.u32, 4, 'x', buf_end, len); - case sizeof(apr_int64_t): - return conv_p2_quad(u.u64, 4, 'x', buf_end, len); - default: - /* not implemented; stick 0 in the buffer */ - return conv_10(0, TRUE, &is_negative, buf_end, len); - } -} -#endif - -/* - * Do format conversion placing the output in buffer - */ -APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *), - apr_vformatter_buff_t *vbuff, const char *fmt, va_list ap) -{ - register char *sp; - register char *bep; - register int cc = 0; - register apr_size_t i; - - register char *s = NULL; - char *q; - apr_size_t s_len = 0; - - register apr_size_t min_width = 0; - apr_size_t precision = 0; - enum { - LEFT, RIGHT - } adjust; - char pad_char; - char prefix_char; - - double fp_num; - apr_int64_t i_quad = 0; - apr_uint64_t ui_quad; - apr_int32_t i_num = 0; - apr_uint32_t ui_num = 0; - - char num_buf[NUM_BUF_SIZE]; - char char_buf[2]; /* for printing %% and % */ - - enum var_type_enum { - IS_QUAD, IS_LONG, IS_SHORT, IS_INT - }; - enum var_type_enum var_type = IS_INT; - - /* - * Flag variables - */ - boolean_e alternate_form; - boolean_e print_sign; - boolean_e print_blank; - boolean_e adjust_precision; - boolean_e adjust_width; - int is_negative; - - sp = vbuff->curpos; - bep = vbuff->endpos; - - while (*fmt) { - if (*fmt != '%') { - INS_CHAR(*fmt, sp, bep, cc); - } - else { - /* - * Default variable settings - */ - boolean_e print_something = YES; - adjust = RIGHT; - alternate_form = print_sign = print_blank = NO; - pad_char = ' '; - prefix_char = NUL; - - fmt++; - - /* - * Try to avoid checking for flags, width or precision - */ - if (!apr_islower(*fmt)) { - /* - * Recognize flags: -, #, BLANK, + - */ - for (;; fmt++) { - if (*fmt == '-') - adjust = LEFT; - else if (*fmt == '+') - print_sign = YES; - else if (*fmt == '#') - alternate_form = YES; - else if (*fmt == ' ') - print_blank = YES; - else if (*fmt == '0') - pad_char = '0'; - else - break; - } - - /* - * Check if a width was specified - */ - if (apr_isdigit(*fmt)) { - STR_TO_DEC(fmt, min_width); - adjust_width = YES; - } - else if (*fmt == '*') { - int v = va_arg(ap, int); - fmt++; - adjust_width = YES; - if (v < 0) { - adjust = LEFT; - min_width = (apr_size_t)(-v); - } - else - min_width = (apr_size_t)v; - } - else - adjust_width = NO; - - /* - * Check if a precision was specified - */ - if (*fmt == '.') { - adjust_precision = YES; - fmt++; - if (apr_isdigit(*fmt)) { - STR_TO_DEC(fmt, precision); - } - else if (*fmt == '*') { - int v = va_arg(ap, int); - fmt++; - precision = (v < 0) ? 0 : (apr_size_t)v; - } - else - precision = 0; - } - else - adjust_precision = NO; - } - else - adjust_precision = adjust_width = NO; - - /* - * Modifier check. In same cases, APR_OFF_T_FMT can be - * "lld" and APR_INT64_T_FMT can be "ld" (that is, off_t is - * "larger" than int64). Check that case 1st. - * Note that if APR_OFF_T_FMT is "d", - * the first if condition is never true. If APR_INT64_T_FMT - * is "d' then the second if condition is never true. - */ - if ((sizeof(APR_OFF_T_FMT) > sizeof(APR_INT64_T_FMT)) && - ((sizeof(APR_OFF_T_FMT) == 4 && - fmt[0] == APR_OFF_T_FMT[0] && - fmt[1] == APR_OFF_T_FMT[1]) || - (sizeof(APR_OFF_T_FMT) == 3 && - fmt[0] == APR_OFF_T_FMT[0]) || - (sizeof(APR_OFF_T_FMT) > 4 && - strncmp(fmt, APR_OFF_T_FMT, - sizeof(APR_OFF_T_FMT) - 2) == 0))) { - /* Need to account for trailing 'd' and null in sizeof() */ - var_type = IS_QUAD; - fmt += (sizeof(APR_OFF_T_FMT) - 2); - } - else if ((sizeof(APR_INT64_T_FMT) == 4 && - fmt[0] == APR_INT64_T_FMT[0] && - fmt[1] == APR_INT64_T_FMT[1]) || - (sizeof(APR_INT64_T_FMT) == 3 && - fmt[0] == APR_INT64_T_FMT[0]) || - (sizeof(APR_INT64_T_FMT) > 4 && - strncmp(fmt, APR_INT64_T_FMT, - sizeof(APR_INT64_T_FMT) - 2) == 0)) { - /* Need to account for trailing 'd' and null in sizeof() */ - var_type = IS_QUAD; - fmt += (sizeof(APR_INT64_T_FMT) - 2); - } - else if (*fmt == 'q') { - var_type = IS_QUAD; - fmt++; - } - else if (*fmt == 'l') { - var_type = IS_LONG; - fmt++; - } - else if (*fmt == 'h') { - var_type = IS_SHORT; - fmt++; - } - else { - var_type = IS_INT; - } - - /* - * Argument extraction and printing. - * First we determine the argument type. - * Then, we convert the argument to a string. - * On exit from the switch, s points to the string that - * must be printed, s_len has the length of the string - * The precision requirements, if any, are reflected in s_len. - * - * NOTE: pad_char may be set to '0' because of the 0 flag. - * It is reset to ' ' by non-numeric formats - */ - switch (*fmt) { - case 'u': - if (var_type == IS_QUAD) { - i_quad = va_arg(ap, apr_uint64_t); - s = conv_10_quad(i_quad, 1, &is_negative, - &num_buf[NUM_BUF_SIZE], &s_len); - } - else { - if (var_type == IS_LONG) - i_num = (apr_int32_t) va_arg(ap, apr_uint32_t); - else if (var_type == IS_SHORT) - i_num = (apr_int32_t) (unsigned short) va_arg(ap, unsigned int); - else - i_num = (apr_int32_t) va_arg(ap, unsigned int); - s = conv_10(i_num, 1, &is_negative, - &num_buf[NUM_BUF_SIZE], &s_len); - } - FIX_PRECISION(adjust_precision, precision, s, s_len); - break; - - case 'd': - case 'i': - if (var_type == IS_QUAD) { - i_quad = va_arg(ap, apr_int64_t); - s = conv_10_quad(i_quad, 0, &is_negative, - &num_buf[NUM_BUF_SIZE], &s_len); - } - else { - if (var_type == IS_LONG) - i_num = va_arg(ap, apr_int32_t); - else if (var_type == IS_SHORT) - i_num = (short) va_arg(ap, int); - else - i_num = va_arg(ap, int); - s = conv_10(i_num, 0, &is_negative, - &num_buf[NUM_BUF_SIZE], &s_len); - } - FIX_PRECISION(adjust_precision, precision, s, s_len); - - if (is_negative) - prefix_char = '-'; - else if (print_sign) - prefix_char = '+'; - else if (print_blank) - prefix_char = ' '; - break; - - - case 'o': - if (var_type == IS_QUAD) { - ui_quad = va_arg(ap, apr_uint64_t); - s = conv_p2_quad(ui_quad, 3, *fmt, - &num_buf[NUM_BUF_SIZE], &s_len); - } - else { - if (var_type == IS_LONG) - ui_num = va_arg(ap, apr_uint32_t); - else if (var_type == IS_SHORT) - ui_num = (unsigned short) va_arg(ap, unsigned int); - else - ui_num = va_arg(ap, unsigned int); - s = conv_p2(ui_num, 3, *fmt, - &num_buf[NUM_BUF_SIZE], &s_len); - } - FIX_PRECISION(adjust_precision, precision, s, s_len); - if (alternate_form && *s != '0') { - *--s = '0'; - s_len++; - } - break; - - - case 'x': - case 'X': - if (var_type == IS_QUAD) { - ui_quad = va_arg(ap, apr_uint64_t); - s = conv_p2_quad(ui_quad, 4, *fmt, - &num_buf[NUM_BUF_SIZE], &s_len); - } - else { - if (var_type == IS_LONG) - ui_num = va_arg(ap, apr_uint32_t); - else if (var_type == IS_SHORT) - ui_num = (unsigned short) va_arg(ap, unsigned int); - else - ui_num = va_arg(ap, unsigned int); - s = conv_p2(ui_num, 4, *fmt, - &num_buf[NUM_BUF_SIZE], &s_len); - } - FIX_PRECISION(adjust_precision, precision, s, s_len); - if (alternate_form && ui_num != 0) { - *--s = *fmt; /* 'x' or 'X' */ - *--s = '0'; - s_len += 2; - } - break; - - - case 's': - s = va_arg(ap, char *); - if (s != NULL) { - if (!adjust_precision) { - s_len = strlen(s); - } - else { - /* From the C library standard in section 7.9.6.1: - * ...if the precision is specified, no more then - * that many characters are written. If the - * precision is not specified or is greater - * than the size of the array, the array shall - * contain a null character. - * - * My reading is is precision is specified and - * is less then or equal to the size of the - * array, no null character is required. So - * we can't do a strlen. - * - * This figures out the length of the string - * up to the precision. Once it's long enough - * for the specified precision, we don't care - * anymore. - * - * NOTE: you must do the length comparison - * before the check for the null character. - * Otherwise, you'll check one beyond the - * last valid character. - */ - const char *walk; - - for (walk = s, s_len = 0; - (s_len < precision) && (*walk != '\0'); - ++walk, ++s_len); - } - } - else { - s = S_NULL; - s_len = S_NULL_LEN; - } - pad_char = ' '; - break; - - - case 'f': - case 'e': - case 'E': - fp_num = va_arg(ap, double); - /* - * We use &num_buf[ 1 ], so that we have room for the sign - */ - s = NULL; -#ifdef HAVE_ISNAN - if (isnan(fp_num)) { - s = "nan"; - s_len = 3; - } -#endif -#ifdef HAVE_ISINF - if (!s && isinf(fp_num)) { - s = "inf"; - s_len = 3; - } -#endif - if (!s) { - s = conv_fp(*fmt, fp_num, alternate_form, - (int)((adjust_precision == NO) ? FLOAT_DIGITS : precision), - &is_negative, &num_buf[1], &s_len); - if (is_negative) - prefix_char = '-'; - else if (print_sign) - prefix_char = '+'; - else if (print_blank) - prefix_char = ' '; - } - break; - - - case 'g': - case 'G': - if (adjust_precision == NO) - precision = FLOAT_DIGITS; - else if (precision == 0) - precision = 1; - /* - * * We use &num_buf[ 1 ], so that we have room for the sign - */ - s = apr_gcvt(va_arg(ap, double), (int) precision, &num_buf[1], - alternate_form); - if (*s == '-') - prefix_char = *s++; - else if (print_sign) - prefix_char = '+'; - else if (print_blank) - prefix_char = ' '; - - s_len = strlen(s); - - if (alternate_form && (q = strchr(s, '.')) == NULL) { - s[s_len++] = '.'; - s[s_len] = '\0'; /* delimit for following strchr() */ - } - if (*fmt == 'G' && (q = strchr(s, 'e')) != NULL) - *q = 'E'; - break; - - - case 'c': - char_buf[0] = (char) (va_arg(ap, int)); - s = &char_buf[0]; - s_len = 1; - pad_char = ' '; - break; - - - case '%': - char_buf[0] = '%'; - s = &char_buf[0]; - s_len = 1; - pad_char = ' '; - break; - - - case 'n': - if (var_type == IS_QUAD) - *(va_arg(ap, apr_int64_t *)) = cc; - else if (var_type == IS_LONG) - *(va_arg(ap, long *)) = cc; - else if (var_type == IS_SHORT) - *(va_arg(ap, short *)) = cc; - else - *(va_arg(ap, int *)) = cc; - print_something = NO; - break; - - /* - * This is where we extend the printf format, with a second - * type specifier - */ - case 'p': - switch(*++fmt) { - /* - * If the pointer size is equal to or smaller than the size - * of the largest unsigned int, we convert the pointer to a - * hex number, otherwise we print "%p" to indicate that we - * don't handle "%p". - */ - case 'p': -#if APR_SIZEOF_VOIDP == 8 - if (sizeof(void *) <= sizeof(apr_uint64_t)) { - ui_quad = (apr_uint64_t) va_arg(ap, void *); - s = conv_p2_quad(ui_quad, 4, 'x', - &num_buf[NUM_BUF_SIZE], &s_len); - } -#else - if (sizeof(void *) <= sizeof(apr_uint32_t)) { - ui_num = (apr_uint32_t) va_arg(ap, void *); - s = conv_p2(ui_num, 4, 'x', - &num_buf[NUM_BUF_SIZE], &s_len); - } -#endif - else { - s = "%p"; - s_len = 2; - prefix_char = NUL; - } - pad_char = ' '; - break; - - /* print an apr_sockaddr_t as a.b.c.d:port */ - case 'I': - { - apr_sockaddr_t *sa; - - sa = va_arg(ap, apr_sockaddr_t *); - if (sa != NULL) { - s = conv_apr_sockaddr(sa, &num_buf[NUM_BUF_SIZE], &s_len); - if (adjust_precision && precision < s_len) - s_len = precision; - } - else { - s = S_NULL; - s_len = S_NULL_LEN; - } - pad_char = ' '; - } - break; - - /* print a struct in_addr as a.b.c.d */ - case 'A': - { - struct in_addr *ia; - - ia = va_arg(ap, struct in_addr *); - if (ia != NULL) { - s = conv_in_addr(ia, &num_buf[NUM_BUF_SIZE], &s_len); - if (adjust_precision && precision < s_len) - s_len = precision; - } - else { - s = S_NULL; - s_len = S_NULL_LEN; - } - pad_char = ' '; - } - break; - - /* print the error for an apr_status_t */ - case 'm': - { - apr_status_t *mrv; - - mrv = va_arg(ap, apr_status_t *); - if (mrv != NULL) { - s = apr_strerror(*mrv, num_buf, NUM_BUF_SIZE-1); - s_len = strlen(s); - } - else { - s = S_NULL; - s_len = S_NULL_LEN; - } - pad_char = ' '; - } - break; - - case 'T': -#if APR_HAS_THREADS - { - apr_os_thread_t *tid; - - tid = va_arg(ap, apr_os_thread_t *); - if (tid != NULL) { - s = conv_os_thread_t(tid, &num_buf[NUM_BUF_SIZE], &s_len); - if (adjust_precision && precision < s_len) - s_len = precision; - } - else { - s = S_NULL; - s_len = S_NULL_LEN; - } - pad_char = ' '; - } -#else - char_buf[0] = '0'; - s = &char_buf[0]; - s_len = 1; - pad_char = ' '; -#endif - break; - - case 't': -#if APR_HAS_THREADS - { - apr_os_thread_t *tid; - - tid = va_arg(ap, apr_os_thread_t *); - if (tid != NULL) { - s = conv_os_thread_t_hex(tid, &num_buf[NUM_BUF_SIZE], &s_len); - if (adjust_precision && precision < s_len) - s_len = precision; - } - else { - s = S_NULL; - s_len = S_NULL_LEN; - } - pad_char = ' '; - } -#else - char_buf[0] = '0'; - s = &char_buf[0]; - s_len = 1; - pad_char = ' '; -#endif - break; - - case 'B': - case 'F': - case 'S': - { - char buf[5]; - apr_off_t size = 0; - - if (*fmt == 'B') { - apr_uint32_t *arg = va_arg(ap, apr_uint32_t *); - size = (arg) ? *arg : 0; - } - else if (*fmt == 'F') { - apr_off_t *arg = va_arg(ap, apr_off_t *); - size = (arg) ? *arg : 0; - } - else { - apr_size_t *arg = va_arg(ap, apr_size_t *); - size = (arg) ? *arg : 0; - } - - s = apr_strfsize(size, buf); - s_len = strlen(s); - pad_char = ' '; - } - break; - - case NUL: - /* if %p ends the string, oh well ignore it */ - continue; - - default: - s = "bogus %p"; - s_len = 8; - prefix_char = NUL; - (void)va_arg(ap, void *); /* skip the bogus argument on the stack */ - break; - } - break; - - case NUL: - /* - * The last character of the format string was %. - * We ignore it. - */ - continue; - - - /* - * The default case is for unrecognized %'s. - * We print % to help the user identify what - * option is not understood. - * This is also useful in case the user wants to pass - * the output of format_converter to another function - * that understands some other % (like syslog). - * Note that we can't point s inside fmt because the - * unknown could be preceded by width etc. - */ - default: - char_buf[0] = '%'; - char_buf[1] = *fmt; - s = char_buf; - s_len = 2; - pad_char = ' '; - break; - } - - if (prefix_char != NUL && s != S_NULL && s != char_buf) { - *--s = prefix_char; - s_len++; - } - - if (adjust_width && adjust == RIGHT && min_width > s_len) { - if (pad_char == '0' && prefix_char != NUL) { - INS_CHAR(*s, sp, bep, cc); - s++; - s_len--; - min_width--; - } - PAD(min_width, s_len, pad_char); - } - - /* - * Print the string s. - */ - if (print_something == YES) { - for (i = s_len; i != 0; i--) { - INS_CHAR(*s, sp, bep, cc); - s++; - } - } - - if (adjust_width && adjust == LEFT && min_width > s_len) - PAD(min_width, s_len, pad_char); - } - fmt++; - } - vbuff->curpos = sp; - - return cc; -} - - -static int snprintf_flush(apr_vformatter_buff_t *vbuff) -{ - /* if the buffer fills we have to abort immediately, there is no way - * to "flush" an apr_snprintf... there's nowhere to flush it to. - */ - return -1; -} - - -APR_DECLARE_NONSTD(int) apr_snprintf(char *buf, apr_size_t len, - const char *format, ...) -{ - int cc; - va_list ap; - apr_vformatter_buff_t vbuff; - - if (len == 0) { - /* NOTE: This is a special case; we just want to return the number - * of chars that would be written (minus \0) if the buffer - * size was infinite. We leverage the fact that INS_CHAR - * just does actual inserts iff the buffer pointer is non-NULL. - * In this case, we don't care what buf is; it can be NULL, since - * we don't touch it at all. - */ - vbuff.curpos = NULL; - vbuff.endpos = NULL; - } else { - /* save one byte for nul terminator */ - vbuff.curpos = buf; - vbuff.endpos = buf + len - 1; - } - va_start(ap, format); - cc = apr_vformatter(snprintf_flush, &vbuff, format, ap); - va_end(ap); - if (len != 0) { - *vbuff.curpos = '\0'; - } - return (cc == -1) ? (int)len - 1 : cc; -} - - -APR_DECLARE(int) apr_vsnprintf(char *buf, apr_size_t len, const char *format, - va_list ap) -{ - int cc; - apr_vformatter_buff_t vbuff; - - if (len == 0) { - /* See above note */ - vbuff.curpos = NULL; - vbuff.endpos = NULL; - } else { - /* save one byte for nul terminator */ - vbuff.curpos = buf; - vbuff.endpos = buf + len - 1; - } - cc = apr_vformatter(snprintf_flush, &vbuff, format, ap); - if (len != 0) { - *vbuff.curpos = '\0'; - } - return (cc == -1) ? (int)len - 1 : cc; -} diff --git a/libs/apr/strings/apr_strings.c b/libs/apr/strings/apr_strings.c deleted file mode 100644 index d20004ea..00000000 --- a/libs/apr/strings/apr_strings.c +++ /dev/null @@ -1,468 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "apr.h" -#include "apr_strings.h" -#include "apr_general.h" -#include "apr_private.h" -#include "apr_lib.h" -#define APR_WANT_STDIO -#define APR_WANT_STRFUNC -#include "apr_want.h" - -#ifdef HAVE_STDDEF_H -#include /* NULL */ -#endif - -#ifdef HAVE_STDLIB_H -#include /* strtol and strtoll */ -#endif - -/** this is used to cache lengths in apr_pstrcat */ -#define MAX_SAVED_LENGTHS 6 - -APR_DECLARE(char *) apr_pstrdup(apr_pool_t *a, const char *s) -{ - char *res; - apr_size_t len; - - if (s == NULL) { - return NULL; - } - len = strlen(s) + 1; - res = apr_palloc(a, len); - memcpy(res, s, len); - return res; -} - -APR_DECLARE(char *) apr_pstrndup(apr_pool_t *a, const char *s, apr_size_t n) -{ - char *res; - const char *end; - - if (s == NULL) { - return NULL; - } - end = memchr(s, '\0', n); - if (end != NULL) - n = end - s; - res = apr_palloc(a, n + 1); - memcpy(res, s, n); - res[n] = '\0'; - return res; -} - -APR_DECLARE(char *) apr_pstrmemdup(apr_pool_t *a, const char *s, apr_size_t n) -{ - char *res; - - if (s == NULL) { - return NULL; - } - res = apr_palloc(a, n + 1); - memcpy(res, s, n); - res[n] = '\0'; - return res; -} - -APR_DECLARE(void *) apr_pmemdup(apr_pool_t *a, const void *m, apr_size_t n) -{ - void *res; - - if (m == NULL) - return NULL; - res = apr_palloc(a, n); - memcpy(res, m, n); - return res; -} - -APR_DECLARE_NONSTD(char *) apr_pstrcat(apr_pool_t *a, ...) -{ - char *cp, *argp, *res; - apr_size_t saved_lengths[MAX_SAVED_LENGTHS]; - int nargs = 0; - - /* Pass one --- find length of required string */ - - apr_size_t len = 0; - va_list adummy; - - va_start(adummy, a); - - while ((cp = va_arg(adummy, char *)) != NULL) { - apr_size_t cplen = strlen(cp); - if (nargs < MAX_SAVED_LENGTHS) { - saved_lengths[nargs++] = cplen; - } - len += cplen; - } - - va_end(adummy); - - /* Allocate the required string */ - - res = (char *) apr_palloc(a, len + 1); - cp = res; - - /* Pass two --- copy the argument strings into the result space */ - - va_start(adummy, a); - - nargs = 0; - while ((argp = va_arg(adummy, char *)) != NULL) { - if (nargs < MAX_SAVED_LENGTHS) { - len = saved_lengths[nargs++]; - } - else { - len = strlen(argp); - } - - memcpy(cp, argp, len); - cp += len; - } - - va_end(adummy); - - /* Return the result string */ - - *cp = '\0'; - - return res; -} - -APR_DECLARE(char *) apr_pstrcatv(apr_pool_t *a, const struct iovec *vec, - apr_size_t nvec, apr_size_t *nbytes) -{ - apr_size_t i; - apr_size_t len; - const struct iovec *src; - char *res; - char *dst; - - /* Pass one --- find length of required string */ - len = 0; - src = vec; - for (i = nvec; i; i--) { - len += src->iov_len; - src++; - } - if (nbytes) { - *nbytes = len; - } - - /* Allocate the required string */ - res = (char *) apr_palloc(a, len + 1); - - /* Pass two --- copy the argument strings into the result space */ - src = vec; - dst = res; - for (i = nvec; i; i--) { - memcpy(dst, src->iov_base, src->iov_len); - dst += src->iov_len; - src++; - } - - /* Return the result string */ - *dst = '\0'; - - return res; -} - -#if (!APR_HAVE_MEMCHR) -void *memchr(const void *s, int c, size_t n) -{ - const char *cp; - - for (cp = s; n > 0; n--, cp++) { - if (*cp == c) - return (char *) cp; /* Casting away the const here */ - } - - return NULL; -} -#endif - -#ifndef INT64_MAX -#define INT64_MAX APR_INT64_C(0x7fffffffffffffff) -#endif -#ifndef INT64_MIN -#define INT64_MIN (-APR_INT64_C(0x7fffffffffffffff) - APR_INT64_C(1)) -#endif - -APR_DECLARE(apr_status_t) apr_strtoff(apr_off_t *offset, const char *nptr, - char **endptr, int base) -{ - errno = 0; - *offset = APR_OFF_T_STRFN(nptr, endptr, base); - return APR_FROM_OS_ERROR(errno); -} - -APR_DECLARE(apr_int64_t) apr_strtoi64(const char *nptr, char **endptr, int base) -{ -#ifdef APR_INT64_STRFN - errno = 0; - return APR_INT64_STRFN(nptr, endptr, base); -#else - const char *s; - apr_int64_t acc; - apr_int64_t val; - int neg, any; - char c; - - errno = 0; - /* - * Skip white space and pick up leading +/- sign if any. - * If base is 0, allow 0x for hex and 0 for octal, else - * assume decimal; if base is already 16, allow 0x. - */ - s = nptr; - do { - c = *s++; - } while (apr_isspace(c)); - if (c == '-') { - neg = 1; - c = *s++; - } else { - neg = 0; - if (c == '+') - c = *s++; - } - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) { - c = s[1]; - s += 2; - base = 16; - } - if (base == 0) - base = c == '0' ? 8 : 10; - acc = any = 0; - if (base < 2 || base > 36) { - errno = EINVAL; - if (endptr != NULL) - *endptr = (char *)(any ? s - 1 : nptr); - return acc; - } - - /* The classic bsd implementation requires div/mod operators - * to compute a cutoff. Benchmarking proves that is very, very - * evil to some 32 bit processors. Instead, look for underflow - * in both the mult and add/sub operation. Unlike the bsd impl, - * we also work strictly in a signed int64 word as we haven't - * implemented the unsigned type in win32. - * - * Set 'any' if any `digits' consumed; make it negative to indicate - * overflow. - */ - val = 0; - for ( ; ; c = *s++) { - if (c >= '0' && c <= '9') - c -= '0'; -#if (('Z' - 'A') == 25) - else if (c >= 'A' && c <= 'Z') - c -= 'A' - 10; - else if (c >= 'a' && c <= 'z') - c -= 'a' - 10; -#elif APR_CHARSET_EBCDIC - else if (c >= 'A' && c <= 'I') - c -= 'A' - 10; - else if (c >= 'J' && c <= 'R') - c -= 'J' - 19; - else if (c >= 'S' && c <= 'Z') - c -= 'S' - 28; - else if (c >= 'a' && c <= 'i') - c -= 'a' - 10; - else if (c >= 'j' && c <= 'r') - c -= 'j' - 19; - else if (c >= 's' && c <= 'z') - c -= 'z' - 28; -#else -#error "CANNOT COMPILE apr_strtoi64(), only ASCII and EBCDIC supported" -#endif - else - break; - if (c >= base) - break; - val *= base; - if ( (any < 0) /* already noted an over/under flow - short circuit */ - || (neg && (val > acc || (val -= c) > acc)) /* underflow */ - || (!neg && (val < acc || (val += c) < acc))) { /* overflow */ - any = -1; /* once noted, over/underflows never go away */ -#ifdef APR_STRTOI64_OVERFLOW_IS_BAD_CHAR - break; -#endif - } else { - acc = val; - any = 1; - } - } - - if (any < 0) { - acc = neg ? INT64_MIN : INT64_MAX; - errno = ERANGE; - } else if (!any) { - errno = EINVAL; - } - if (endptr != NULL) - *endptr = (char *)(any ? s - 1 : nptr); - return (acc); -#endif -} - -APR_DECLARE(apr_int64_t) apr_atoi64(const char *buf) -{ - return apr_strtoi64(buf, NULL, 10); -} - -APR_DECLARE(char *) apr_itoa(apr_pool_t *p, int n) -{ - const int BUFFER_SIZE = sizeof(int) * 3 + 2; - char *buf = apr_palloc(p, BUFFER_SIZE); - char *start = buf + BUFFER_SIZE - 1; - int negative; - if (n < 0) { - negative = 1; - n = -n; - } - else { - negative = 0; - } - *start = 0; - do { - *--start = '0' + (n % 10); - n /= 10; - } while (n); - if (negative) { - *--start = '-'; - } - return start; -} - -APR_DECLARE(char *) apr_ltoa(apr_pool_t *p, long n) -{ - const int BUFFER_SIZE = sizeof(long) * 3 + 2; - char *buf = apr_palloc(p, BUFFER_SIZE); - char *start = buf + BUFFER_SIZE - 1; - int negative; - if (n < 0) { - negative = 1; - n = -n; - } - else { - negative = 0; - } - *start = 0; - do { - *--start = (char)('0' + (n % 10)); - n /= 10; - } while (n); - if (negative) { - *--start = '-'; - } - return start; -} - -APR_DECLARE(char *) apr_off_t_toa(apr_pool_t *p, apr_off_t n) -{ - const int BUFFER_SIZE = sizeof(apr_off_t) * 3 + 2; - char *buf = apr_palloc(p, BUFFER_SIZE); - char *start = buf + BUFFER_SIZE - 1; - int negative; - if (n < 0) { - negative = 1; - n = -n; - } - else { - negative = 0; - } - *start = 0; - do { - *--start = '0' + (char)(n % 10); - n /= 10; - } while (n); - if (negative) { - *--start = '-'; - } - return start; -} - -APR_DECLARE(char *) apr_strfsize(apr_off_t size, char *buf) -{ - const char ord[] = "KMGTPE"; - const char *o = ord; - int remain; - - if (size < 0) { - return strcpy(buf, " - "); - } - if (size < 973) { - if (apr_snprintf(buf, 5, "%3d ", (int) size) < 0) - return strcpy(buf, "****"); - return buf; - } - do { - remain = (int)(size & 1023); - size >>= 10; - if (size >= 973) { - ++o; - continue; - } - if (size < 9 || (size == 9 && remain < 973)) { - if ((remain = ((remain * 5) + 256) / 512) >= 10) - ++size, remain = 0; - if (apr_snprintf(buf, 5, "%d.%d%c", (int) size, remain, *o) < 0) - return strcpy(buf, "****"); - return buf; - } - if (remain >= 512) - ++size; - if (apr_snprintf(buf, 5, "%3d%c", (int) size, *o) < 0) - return strcpy(buf, "****"); - return buf; - } while (1); -} - diff --git a/libs/apr/strings/apr_strnatcmp.c b/libs/apr/strings/apr_strnatcmp.c deleted file mode 100644 index 0e960e8a..00000000 --- a/libs/apr/strings/apr_strnatcmp.c +++ /dev/null @@ -1,149 +0,0 @@ -/* -*- mode: c; c-file-style: "k&r" -*- - - strnatcmp.c -- Perform 'natural order' comparisons of strings in C. - Copyright (C) 2000 by Martin Pool - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#include -#include -#include "apr_strings.h" -#include "apr_lib.h" /* for apr_is*() */ - -#if defined(__GNUC__) -# define UNUSED __attribute__((__unused__)) -#else -# define UNUSED -#endif - -/* based on "strnatcmp.c,v 1.6 2000/04/20 07:30:11 mbp Exp $" */ - -static int -compare_right(char const *a, char const *b) -{ - int bias = 0; - - /* The longest run of digits wins. That aside, the greatest - value wins, but we can't know that it will until we've scanned - both numbers to know that they have the same magnitude, so we - remember it in BIAS. */ - for (;; a++, b++) { - if (!apr_isdigit(*a) && !apr_isdigit(*b)) - break; - else if (!apr_isdigit(*a)) - return -1; - else if (!apr_isdigit(*b)) - return +1; - else if (*a < *b) { - if (!bias) - bias = -1; - } else if (*a > *b) { - if (!bias) - bias = +1; - } else if (!*a && !*b) - break; - } - - return bias; -} - - -static int -compare_left(char const *a, char const *b) -{ - /* Compare two left-aligned numbers: the first to have a - different value wins. */ - for (;; a++, b++) { - if (!apr_isdigit(*a) && !apr_isdigit(*b)) - break; - else if (!apr_isdigit(*a)) - return -1; - else if (!apr_isdigit(*b)) - return +1; - else if (*a < *b) - return -1; - else if (*a > *b) - return +1; - } - - return 0; -} - - -static int strnatcmp0(char const *a, char const *b, int fold_case) -{ - int ai, bi; - char ca, cb; - int fractional, result; - ai = bi = 0; - while (1) { - ca = a[ai]; cb = b[bi]; - - /* skip over leading spaces or zeros */ - while (apr_isspace(ca)) - ca = a[++ai]; - - while (apr_isspace(cb)) - cb = b[++bi]; - - /* process run of digits */ - if (apr_isdigit(ca) && apr_isdigit(cb)) { - fractional = (ca == '0' || cb == '0'); - - if (fractional) { - if ((result = compare_left(a+ai, b+bi)) != 0) - return result; - } else { - if ((result = compare_right(a+ai, b+bi)) != 0) - return result; - } - } - - if (!ca && !cb) { - /* The strings compare the same. Perhaps the caller - will want to call strcmp to break the tie. */ - return 0; - } - - if (fold_case) { - ca = apr_toupper(ca); - cb = apr_toupper(cb); - } - - if (ca < cb) - return -1; - else if (ca > cb) - return +1; - - ++ai; ++bi; - } -} - - - -APR_DECLARE(int) apr_strnatcmp(char const *a, char const *b) -{ - return strnatcmp0(a, b, 0); -} - - -/* Compare, recognizing numeric string and ignoring case. */ -APR_DECLARE(int) apr_strnatcasecmp(char const *a, char const *b) -{ - return strnatcmp0(a, b, 1); -} diff --git a/libs/apr/strings/apr_strtok.c b/libs/apr/strings/apr_strtok.c deleted file mode 100644 index 517b319d..00000000 --- a/libs/apr/strings/apr_strtok.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifdef HAVE_STDDEF_H -#include /* for NULL */ -#endif - -#include "apr.h" -#include "apr_strings.h" - -#define APR_WANT_STRFUNC /* for strchr() */ -#include "apr_want.h" - -APR_DECLARE(char *) apr_strtok(char *str, const char *sep, char **last) -{ - char *token; - - if (!str) /* subsequent call */ - str = *last; /* start where we left off */ - - /* skip characters in sep (will terminate at '\0') */ - while (*str && strchr(sep, *str)) - ++str; - - if (!*str) /* no more tokens */ - return NULL; - - token = str; - - /* skip valid token characters to terminate token and - * prepare for the next call (will terminate at '\0) - */ - *last = token + 1; - while (**last && !strchr(sep, **last)) - ++*last; - - if (**last) { - **last = '\0'; - ++*last; - } - - return token; -} diff --git a/libs/apr/support/unix/waitio.c b/libs/apr/support/unix/waitio.c deleted file mode 100644 index 7232cdd9..00000000 --- a/libs/apr/support/unix/waitio.c +++ /dev/null @@ -1,123 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_file_io.h" -#include "apr_arch_networkio.h" -#include "apr_poll.h" -#include "apr_errno.h" -#include "apr_support.h" - -/* The only case where we don't use wait_for_io_or_timeout is on - * pre-BONE BeOS, so this check should be sufficient and simpler */ -#if !BEOS_R5 -#define USE_WAIT_FOR_IO -#endif - -#ifdef USE_WAIT_FOR_IO - -#ifdef WAITIO_USES_POLL - -#ifdef HAVE_POLL_H -#include -#endif -#ifdef HAVE_SYS_POLL_H -#include -#endif - -apr_status_t apr_wait_for_io_or_timeout(apr_file_t *f, apr_socket_t *s, - int for_read) -{ - struct pollfd pfd; - int rc, timeout; - - timeout = f ? f->timeout / 1000 : s->timeout / 1000; - pfd.fd = f ? f->filedes : s->socketdes; - pfd.events = for_read ? POLLIN : POLLOUT; - - do { - rc = poll(&pfd, 1, timeout); - } while (rc == -1 && errno == EINTR); - if (rc == 0) { - return APR_TIMEUP; - } - else if (rc > 0) { - return APR_SUCCESS; - } - else { - return errno; - } -} - -#else /* !WAITIO_USES_POLL */ - -apr_status_t apr_wait_for_io_or_timeout(apr_file_t *f, apr_socket_t *s, - int for_read) -{ - apr_interval_time_t timeout; - apr_pollfd_t pfd; - int type = for_read ? APR_POLLIN : APR_POLLOUT; - apr_pollset_t *pollset; - apr_status_t status; - - /* TODO - timeout should be less each time through this loop */ - if (f) { - pfd.desc_type = APR_POLL_FILE; - pfd.desc.f = f; - - pollset = f->pollset; - if (pollset == NULL) { - status = apr_pollset_create(&(f->pollset), 1, f->pool, 0); - if (status != APR_SUCCESS) { - return status; - } - pollset = f->pollset; - } - timeout = f->timeout; - } - else { - pfd.desc_type = APR_POLL_SOCKET; - pfd.desc.s = s; - - pollset = s->pollset; - timeout = s->timeout; - } - pfd.reqevents = type; - - /* Remove the object if it was in the pollset, then add in the new - * object with the correct reqevents value. Ignore the status result - * on the remove, because it might not be in there (yet). - */ - (void) apr_pollset_remove(pollset, &pfd); - - /* ### check status code */ - (void) apr_pollset_add(pollset, &pfd); - - do { - int numdesc; - const apr_pollfd_t *pdesc; - - status = apr_pollset_poll(pollset, timeout, &numdesc, &pdesc); - - if (numdesc == 1 && (pdesc[0].rtnevents & type) != 0) { - return APR_SUCCESS; - } - } while (APR_STATUS_IS_EINTR(status)); - - return status; -} -#endif /* WAITIO_USES_POLL */ - -#endif /* USE_WAIT_FOR_IO */ diff --git a/libs/apr/tables/apr_hash.c b/libs/apr/tables/apr_hash.c deleted file mode 100644 index a6e8a649..00000000 --- a/libs/apr/tables/apr_hash.c +++ /dev/null @@ -1,529 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_private.h" - -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_time.h" - -#include "apr_hash.h" - -#if APR_HAVE_STDLIB_H -#include -#endif -#if APR_HAVE_STRING_H -#include -#endif - -#if APR_POOL_DEBUG && APR_HAVE_STDIO_H -#include -#endif - -/* - * The internal form of a hash table. - * - * The table is an array indexed by the hash of the key; collisions - * are resolved by hanging a linked list of hash entries off each - * element of the array. Although this is a really simple design it - * isn't too bad given that pools have a low allocation overhead. - */ - -typedef struct apr_hash_entry_t apr_hash_entry_t; - -struct apr_hash_entry_t { - apr_hash_entry_t *next; - unsigned int hash; - const void *key; - apr_ssize_t klen; - const void *val; -}; - -/* - * Data structure for iterating through a hash table. - * - * We keep a pointer to the next hash entry here to allow the current - * hash entry to be freed or otherwise mangled between calls to - * apr_hash_next(). - */ -struct apr_hash_index_t { - apr_hash_t *ht; - apr_hash_entry_t *this, *next; - unsigned int index; -}; - -/* - * The size of the array is always a power of two. We use the maximum - * index rather than the size so that we can use bitwise-AND for - * modular arithmetic. - * The count of hash entries may be greater depending on the chosen - * collision rate. - */ -struct apr_hash_t { - apr_pool_t *pool; - apr_hash_entry_t **array; - apr_hash_index_t iterator; /* For apr_hash_first(NULL, ...) */ - unsigned int count, max, seed; - apr_hashfunc_t hash_func; - apr_hash_entry_t *free; /* List of recycled entries */ -}; - -#define INITIAL_MAX 15 /* tunable == 2^n - 1 */ - - -/* - * Hash creation functions. - */ - -static apr_hash_entry_t **alloc_array(apr_hash_t *ht, unsigned int max) -{ - return apr_pcalloc(ht->pool, sizeof(*ht->array) * (max + 1)); -} - -APR_DECLARE(apr_hash_t *) apr_hash_make(apr_pool_t *pool) -{ - apr_hash_t *ht; - apr_time_t now = apr_time_now(); - - ht = apr_palloc(pool, sizeof(apr_hash_t)); - ht->pool = pool; - ht->free = NULL; - ht->count = 0; - ht->max = INITIAL_MAX; - ht->seed = (unsigned int)((now >> 32) ^ now ^ (apr_uintptr_t)pool ^ - (apr_uintptr_t)ht ^ (apr_uintptr_t)&now) - 1; - ht->array = alloc_array(ht, ht->max); - ht->hash_func = NULL; - - return ht; -} - -APR_DECLARE(apr_hash_t *) apr_hash_make_custom(apr_pool_t *pool, - apr_hashfunc_t hash_func) -{ - apr_hash_t *ht = apr_hash_make(pool); - ht->hash_func = hash_func; - return ht; -} - - -/* - * Hash iteration functions. - */ - -APR_DECLARE(apr_hash_index_t *) apr_hash_next(apr_hash_index_t *hi) -{ - hi->this = hi->next; - while (!hi->this) { - if (hi->index > hi->ht->max) - return NULL; - - hi->this = hi->ht->array[hi->index++]; - } - hi->next = hi->this->next; - return hi; -} - -APR_DECLARE(apr_hash_index_t *) apr_hash_first(apr_pool_t *p, apr_hash_t *ht) -{ - apr_hash_index_t *hi; - if (p) - hi = apr_palloc(p, sizeof(*hi)); - else - hi = &ht->iterator; - - hi->ht = ht; - hi->index = 0; - hi->this = NULL; - hi->next = NULL; - return apr_hash_next(hi); -} - -APR_DECLARE(void) apr_hash_this(apr_hash_index_t *hi, - const void **key, - apr_ssize_t *klen, - void **val) -{ - if (key) *key = hi->this->key; - if (klen) *klen = hi->this->klen; - if (val) *val = (void *)hi->this->val; -} - - -/* - * Expanding a hash table - */ - -static void expand_array(apr_hash_t *ht) -{ - apr_hash_index_t *hi; - apr_hash_entry_t **new_array; - unsigned int new_max; - - new_max = ht->max * 2 + 1; - new_array = alloc_array(ht, new_max); - for (hi = apr_hash_first(NULL, ht); hi; hi = apr_hash_next(hi)) { - unsigned int i = hi->this->hash & new_max; - hi->this->next = new_array[i]; - new_array[i] = hi->this; - } - ht->array = new_array; - ht->max = new_max; -} - -static unsigned int hashfunc_default(const char *char_key, apr_ssize_t *klen, - unsigned int hash) -{ - const unsigned char *key = (const unsigned char *)char_key; - const unsigned char *p; - apr_ssize_t i; - - /* - * This is the popular `times 33' hash algorithm which is used by - * perl and also appears in Berkeley DB. This is one of the best - * known hash functions for strings because it is both computed - * very fast and distributes very well. - * - * The originator may be Dan Bernstein but the code in Berkeley DB - * cites Chris Torek as the source. The best citation I have found - * is "Chris Torek, Hash function for text in C, Usenet message - * <27038@mimsy.umd.edu> in comp.lang.c , October, 1990." in Rich - * Salz's USENIX 1992 paper about INN which can be found at - * . - * - * The magic of number 33, i.e. why it works better than many other - * constants, prime or not, has never been adequately explained by - * anyone. So I try an explanation: if one experimentally tests all - * multipliers between 1 and 256 (as I did while writing a low-level - * data structure library some time ago) one detects that even - * numbers are not useable at all. The remaining 128 odd numbers - * (except for the number 1) work more or less all equally well. - * They all distribute in an acceptable way and this way fill a hash - * table with an average percent of approx. 86%. - * - * If one compares the chi^2 values of the variants (see - * Bob Jenkins ``Hashing Frequently Asked Questions'' at - * http://burtleburtle.net/bob/hash/hashfaq.html for a description - * of chi^2), the number 33 not even has the best value. But the - * number 33 and a few other equally good numbers like 17, 31, 63, - * 127 and 129 have nevertheless a great advantage to the remaining - * numbers in the large set of possible multipliers: their multiply - * operation can be replaced by a faster operation based on just one - * shift plus either a single addition or subtraction operation. And - * because a hash function has to both distribute good _and_ has to - * be very fast to compute, those few numbers should be preferred. - * - * -- Ralf S. Engelschall - */ - - if (*klen == APR_HASH_KEY_STRING) { - for (p = key; *p; p++) { - hash = hash * 33 + *p; - } - *klen = p - key; - } - else { - for (p = key, i = *klen; i; i--, p++) { - hash = hash * 33 + *p; - } - } - - return hash; -} - -APR_DECLARE_NONSTD(unsigned int) apr_hashfunc_default(const char *char_key, - apr_ssize_t *klen) -{ - return hashfunc_default(char_key, klen, 0); -} - -/* - * This is where we keep the details of the hash function and control - * the maximum collision rate. - * - * If val is non-NULL it creates and initializes a new hash entry if - * there isn't already one there; it returns an updatable pointer so - * that hash entries can be removed. - */ - -static apr_hash_entry_t **find_entry(apr_hash_t *ht, - const void *key, - apr_ssize_t klen, - const void *val) -{ - apr_hash_entry_t **hep, *he; - unsigned int hash; - - if (ht->hash_func) - hash = ht->hash_func(key, &klen); - else - hash = hashfunc_default(key, &klen, ht->seed); - - /* scan linked list */ - for (hep = &ht->array[hash & ht->max], he = *hep; - he; hep = &he->next, he = *hep) { - if (he->hash == hash - && he->klen == klen - && memcmp(he->key, key, klen) == 0) - break; - } - if (he || !val) - return hep; - - /* add a new entry for non-NULL values */ - if ((he = ht->free) != NULL) - ht->free = he->next; - else - he = apr_palloc(ht->pool, sizeof(*he)); - he->next = NULL; - he->hash = hash; - he->key = key; - he->klen = klen; - he->val = val; - *hep = he; - ht->count++; - return hep; -} - -APR_DECLARE(apr_hash_t *) apr_hash_copy(apr_pool_t *pool, - const apr_hash_t *orig) -{ - apr_hash_t *ht; - apr_hash_entry_t *new_vals; - unsigned int i, j; - - ht = apr_palloc(pool, sizeof(apr_hash_t) + - sizeof(*ht->array) * (orig->max + 1) + - sizeof(apr_hash_entry_t) * orig->count); - ht->pool = pool; - ht->free = NULL; - ht->count = orig->count; - ht->max = orig->max; - ht->seed = orig->seed; - ht->hash_func = orig->hash_func; - ht->array = (apr_hash_entry_t **)((char *)ht + sizeof(apr_hash_t)); - - new_vals = (apr_hash_entry_t *)((char *)(ht) + sizeof(apr_hash_t) + - sizeof(*ht->array) * (orig->max + 1)); - j = 0; - for (i = 0; i <= ht->max; i++) { - apr_hash_entry_t **new_entry = &(ht->array[i]); - apr_hash_entry_t *orig_entry = orig->array[i]; - while (orig_entry) { - *new_entry = &new_vals[j++]; - (*new_entry)->hash = orig_entry->hash; - (*new_entry)->key = orig_entry->key; - (*new_entry)->klen = orig_entry->klen; - (*new_entry)->val = orig_entry->val; - new_entry = &((*new_entry)->next); - orig_entry = orig_entry->next; - } - *new_entry = NULL; - } - return ht; -} - -APR_DECLARE(void *) apr_hash_get(apr_hash_t *ht, - const void *key, - apr_ssize_t klen) -{ - apr_hash_entry_t *he; - he = *find_entry(ht, key, klen, NULL); - if (he) - return (void *)he->val; - else - return NULL; -} - -APR_DECLARE(void) apr_hash_set(apr_hash_t *ht, - const void *key, - apr_ssize_t klen, - const void *val) -{ - apr_hash_entry_t **hep; - hep = find_entry(ht, key, klen, val); - if (*hep) { - if (!val) { - /* delete entry */ - apr_hash_entry_t *old = *hep; - *hep = (*hep)->next; - old->next = ht->free; - ht->free = old; - --ht->count; - } - else { - /* replace entry */ - (*hep)->val = val; - /* check that the collision rate isn't too high */ - if (ht->count > ht->max) { - expand_array(ht); - } - } - } - /* else key not present and val==NULL */ -} - -APR_DECLARE(unsigned int) apr_hash_count(apr_hash_t *ht) -{ - return ht->count; -} - -APR_DECLARE(void) apr_hash_clear(apr_hash_t *ht) -{ - apr_hash_index_t *hi; - for (hi = apr_hash_first(NULL, ht); hi; hi = apr_hash_next(hi)) - apr_hash_set(ht, hi->this->key, hi->this->klen, NULL); -} - -APR_DECLARE(apr_hash_t*) apr_hash_overlay(apr_pool_t *p, - const apr_hash_t *overlay, - const apr_hash_t *base) -{ - return apr_hash_merge(p, overlay, base, NULL, NULL); -} - -APR_DECLARE(apr_hash_t *) apr_hash_merge(apr_pool_t *p, - const apr_hash_t *overlay, - const apr_hash_t *base, - void * (*merger)(apr_pool_t *p, - const void *key, - apr_ssize_t klen, - const void *h1_val, - const void *h2_val, - const void *data), - const void *data) -{ - apr_hash_t *res; - apr_hash_entry_t *new_vals = NULL; - apr_hash_entry_t *iter; - apr_hash_entry_t *ent; - unsigned int i, j, k, hash; - -#if APR_POOL_DEBUG - /* we don't copy keys and values, so it's necessary that - * overlay->a.pool and base->a.pool have a life span at least - * as long as p - */ - if (!apr_pool_is_ancestor(overlay->pool, p)) { - fprintf(stderr, - "apr_hash_merge: overlay's pool is not an ancestor of p\n"); - abort(); - } - if (!apr_pool_is_ancestor(base->pool, p)) { - fprintf(stderr, - "apr_hash_merge: base's pool is not an ancestor of p\n"); - abort(); - } -#endif - - res = apr_palloc(p, sizeof(apr_hash_t)); - res->pool = p; - res->free = NULL; - res->hash_func = base->hash_func; - res->count = base->count; - res->max = (overlay->max > base->max) ? overlay->max : base->max; - if (base->count + overlay->count > res->max) { - res->max = res->max * 2 + 1; - } - res->seed = base->seed; - res->array = alloc_array(res, res->max); - if (base->count + overlay->count) { - new_vals = apr_palloc(p, sizeof(apr_hash_entry_t) * - (base->count + overlay->count)); - } - j = 0; - for (k = 0; k <= base->max; k++) { - for (iter = base->array[k]; iter; iter = iter->next) { - i = iter->hash & res->max; - new_vals[j].klen = iter->klen; - new_vals[j].key = iter->key; - new_vals[j].val = iter->val; - new_vals[j].hash = iter->hash; - new_vals[j].next = res->array[i]; - res->array[i] = &new_vals[j]; - j++; - } - } - - for (k = 0; k <= overlay->max; k++) { - for (iter = overlay->array[k]; iter; iter = iter->next) { - if (res->hash_func) - hash = res->hash_func(iter->key, &iter->klen); - else - hash = hashfunc_default(iter->key, &iter->klen, res->seed); - i = hash & res->max; - for (ent = res->array[i]; ent; ent = ent->next) { - if ((ent->klen == iter->klen) && - (memcmp(ent->key, iter->key, iter->klen) == 0)) { - if (merger) { - ent->val = (*merger)(p, iter->key, iter->klen, - iter->val, ent->val, data); - } - else { - ent->val = iter->val; - } - break; - } - } - if (!ent) { - new_vals[j].klen = iter->klen; - new_vals[j].key = iter->key; - new_vals[j].val = iter->val; - new_vals[j].hash = hash; - new_vals[j].next = res->array[i]; - res->array[i] = &new_vals[j]; - res->count++; - j++; - } - } - } - return res; -} - -/* This is basically the following... - * for every element in hash table { - * comp elemeny.key, element.value - * } - * - * Like with apr_table_do, the comp callback is called for each and every - * element of the hash table. - */ -APR_DECLARE(int) apr_hash_do(apr_hash_do_callback_fn_t *comp, - void *rec, const apr_hash_t *ht) -{ - apr_hash_index_t hix; - apr_hash_index_t *hi; - int rv, dorv = 1; - - hix.ht = (apr_hash_t *)ht; - hix.index = 0; - hix.this = NULL; - hix.next = NULL; - - if ((hi = apr_hash_next(&hix))) { - /* Scan the entire table */ - do { - rv = (*comp)(rec, hi->this->key, hi->this->klen, hi->this->val); - } while (rv && (hi = apr_hash_next(hi))); - - if (rv == 0) { - dorv = 0; - } - } - return dorv; -} - -APR_POOL_IMPLEMENT_ACCESSOR(hash) diff --git a/libs/apr/tables/apr_tables.c b/libs/apr/tables/apr_tables.c deleted file mode 100644 index 51b23407..00000000 --- a/libs/apr/tables/apr_tables.c +++ /dev/null @@ -1,1235 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Resource allocation code... the code here is responsible for making - * sure that nothing leaks. - * - * rst --- 4/95 --- 6/95 - */ - -#include "apr_private.h" - -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_tables.h" -#include "apr_strings.h" -#include "apr_lib.h" -#if APR_HAVE_STDLIB_H -#include -#endif -#if APR_HAVE_STRING_H -#include -#endif -#if APR_HAVE_STRINGS_H -#include -#endif - -#if (APR_POOL_DEBUG || defined(MAKE_TABLE_PROFILE)) && APR_HAVE_STDIO_H -#include -#endif - -/***************************************************************** - * This file contains array and apr_table_t functions only. - */ - -/***************************************************************** - * - * The 'array' functions... - */ - -static void make_array_core(apr_array_header_t *res, apr_pool_t *p, - int nelts, int elt_size, int clear) -{ - /* - * Assure sanity if someone asks for - * array of zero elts. - */ - if (nelts < 1) { - nelts = 1; - } - - if (clear) { - res->elts = apr_pcalloc(p, nelts * elt_size); - } - else { - res->elts = apr_palloc(p, nelts * elt_size); - } - - res->pool = p; - res->elt_size = elt_size; - res->nelts = 0; /* No active elements yet... */ - res->nalloc = nelts; /* ...but this many allocated */ -} - -APR_DECLARE(int) apr_is_empty_array(const apr_array_header_t *a) -{ - return ((a == NULL) || (a->nelts == 0)); -} - -APR_DECLARE(apr_array_header_t *) apr_array_make(apr_pool_t *p, - int nelts, int elt_size) -{ - apr_array_header_t *res; - - res = (apr_array_header_t *) apr_palloc(p, sizeof(apr_array_header_t)); - make_array_core(res, p, nelts, elt_size, 1); - return res; -} - -APR_DECLARE(void) apr_array_clear(apr_array_header_t *arr) -{ - arr->nelts = 0; -} - -APR_DECLARE(void *) apr_array_pop(apr_array_header_t *arr) -{ - if (apr_is_empty_array(arr)) { - return NULL; - } - - return arr->elts + (arr->elt_size * (--arr->nelts)); -} - -APR_DECLARE(void *) apr_array_push(apr_array_header_t *arr) -{ - if (arr->nelts == arr->nalloc) { - int new_size = (arr->nalloc <= 0) ? 1 : arr->nalloc * 2; - char *new_data; - - new_data = apr_palloc(arr->pool, arr->elt_size * new_size); - - memcpy(new_data, arr->elts, arr->nalloc * arr->elt_size); - memset(new_data + arr->nalloc * arr->elt_size, 0, - arr->elt_size * (new_size - arr->nalloc)); - arr->elts = new_data; - arr->nalloc = new_size; - } - - ++arr->nelts; - return arr->elts + (arr->elt_size * (arr->nelts - 1)); -} - -static void *apr_array_push_noclear(apr_array_header_t *arr) -{ - if (arr->nelts == arr->nalloc) { - int new_size = (arr->nalloc <= 0) ? 1 : arr->nalloc * 2; - char *new_data; - - new_data = apr_palloc(arr->pool, arr->elt_size * new_size); - - memcpy(new_data, arr->elts, arr->nalloc * arr->elt_size); - arr->elts = new_data; - arr->nalloc = new_size; - } - - ++arr->nelts; - return arr->elts + (arr->elt_size * (arr->nelts - 1)); -} - -APR_DECLARE(void) apr_array_cat(apr_array_header_t *dst, - const apr_array_header_t *src) -{ - int elt_size = dst->elt_size; - - if (dst->nelts + src->nelts > dst->nalloc) { - int new_size = (dst->nalloc <= 0) ? 1 : dst->nalloc * 2; - char *new_data; - - while (dst->nelts + src->nelts > new_size) { - new_size *= 2; - } - - new_data = apr_pcalloc(dst->pool, elt_size * new_size); - memcpy(new_data, dst->elts, dst->nalloc * elt_size); - - dst->elts = new_data; - dst->nalloc = new_size; - } - - memcpy(dst->elts + dst->nelts * elt_size, src->elts, - elt_size * src->nelts); - dst->nelts += src->nelts; -} - -APR_DECLARE(apr_array_header_t *) apr_array_copy(apr_pool_t *p, - const apr_array_header_t *arr) -{ - apr_array_header_t *res = - (apr_array_header_t *) apr_palloc(p, sizeof(apr_array_header_t)); - make_array_core(res, p, arr->nalloc, arr->elt_size, 0); - - memcpy(res->elts, arr->elts, arr->elt_size * arr->nelts); - res->nelts = arr->nelts; - memset(res->elts + res->elt_size * res->nelts, 0, - res->elt_size * (res->nalloc - res->nelts)); - return res; -} - -/* This cute function copies the array header *only*, but arranges - * for the data section to be copied on the first push or arraycat. - * It's useful when the elements of the array being copied are - * read only, but new stuff *might* get added on the end; we have the - * overhead of the full copy only where it is really needed. - */ - -static APR_INLINE void copy_array_hdr_core(apr_array_header_t *res, - const apr_array_header_t *arr) -{ - res->elts = arr->elts; - res->elt_size = arr->elt_size; - res->nelts = arr->nelts; - res->nalloc = arr->nelts; /* Force overflow on push */ -} - -APR_DECLARE(apr_array_header_t *) - apr_array_copy_hdr(apr_pool_t *p, - const apr_array_header_t *arr) -{ - apr_array_header_t *res; - - res = (apr_array_header_t *) apr_palloc(p, sizeof(apr_array_header_t)); - res->pool = p; - copy_array_hdr_core(res, arr); - return res; -} - -/* The above is used here to avoid consing multiple new array bodies... */ - -APR_DECLARE(apr_array_header_t *) - apr_array_append(apr_pool_t *p, - const apr_array_header_t *first, - const apr_array_header_t *second) -{ - apr_array_header_t *res = apr_array_copy_hdr(p, first); - - apr_array_cat(res, second); - return res; -} - -/* apr_array_pstrcat generates a new string from the apr_pool_t containing - * the concatenated sequence of substrings referenced as elements within - * the array. The string will be empty if all substrings are empty or null, - * or if there are no elements in the array. - * If sep is non-NUL, it will be inserted between elements as a separator. - */ -APR_DECLARE(char *) apr_array_pstrcat(apr_pool_t *p, - const apr_array_header_t *arr, - const char sep) -{ - char *cp, *res, **strpp; - apr_size_t len; - int i; - - if (arr->nelts <= 0 || arr->elts == NULL) { /* Empty table? */ - return (char *) apr_pcalloc(p, 1); - } - - /* Pass one --- find length of required string */ - - len = 0; - for (i = 0, strpp = (char **) arr->elts; ; ++strpp) { - if (strpp && *strpp != NULL) { - len += strlen(*strpp); - } - if (++i >= arr->nelts) { - break; - } - if (sep) { - ++len; - } - } - - /* Allocate the required string */ - - res = (char *) apr_palloc(p, len + 1); - cp = res; - - /* Pass two --- copy the argument strings into the result space */ - - for (i = 0, strpp = (char **) arr->elts; ; ++strpp) { - if (strpp && *strpp != NULL) { - len = strlen(*strpp); - memcpy(cp, *strpp, len); - cp += len; - } - if (++i >= arr->nelts) { - break; - } - if (sep) { - *cp++ = sep; - } - } - - *cp = '\0'; - - /* Return the result string */ - - return res; -} - - -/***************************************************************** - * - * The "table" functions. - */ - -#if APR_CHARSET_EBCDIC -#define CASE_MASK 0xbfbfbfbf -#else -#define CASE_MASK 0xdfdfdfdf -#endif - -#define TABLE_HASH_SIZE 32 -#define TABLE_INDEX_MASK 0x1f -#define TABLE_HASH(key) (TABLE_INDEX_MASK & *(unsigned char *)(key)) -#define TABLE_INDEX_IS_INITIALIZED(t, i) ((t)->index_initialized & (1 << (i))) -#define TABLE_SET_INDEX_INITIALIZED(t, i) ((t)->index_initialized |= (1 << (i))) - -/* Compute the "checksum" for a key, consisting of the first - * 4 bytes, normalized for case-insensitivity and packed into - * an int...this checksum allows us to do a single integer - * comparison as a fast check to determine whether we can - * skip a strcasecmp - */ -#define COMPUTE_KEY_CHECKSUM(key, checksum) \ -{ \ - const char *k = (key); \ - apr_uint32_t c = (apr_uint32_t)*k; \ - (checksum) = c; \ - (checksum) <<= 8; \ - if (c) { \ - c = (apr_uint32_t)*++k; \ - checksum |= c; \ - } \ - (checksum) <<= 8; \ - if (c) { \ - c = (apr_uint32_t)*++k; \ - checksum |= c; \ - } \ - (checksum) <<= 8; \ - if (c) { \ - c = (apr_uint32_t)*++k; \ - checksum |= c; \ - } \ - checksum &= CASE_MASK; \ -} - -/** The opaque string-content table type */ -struct apr_table_t { - /* This has to be first to promote backwards compatibility with - * older modules which cast a apr_table_t * to an apr_array_header_t *... - * they should use the apr_table_elts() function for most of the - * cases they do this for. - */ - /** The underlying array for the table */ - apr_array_header_t a; -#ifdef MAKE_TABLE_PROFILE - /** Who created the array. */ - void *creator; -#endif - /* An index to speed up table lookups. The way this works is: - * - Hash the key into the index: - * - index_first[TABLE_HASH(key)] is the offset within - * the table of the first entry with that key - * - index_last[TABLE_HASH(key)] is the offset within - * the table of the last entry with that key - * - If (and only if) there is no entry in the table whose - * key hashes to index element i, then the i'th bit - * of index_initialized will be zero. (Check this before - * trying to use index_first[i] or index_last[i]!) - */ - apr_uint32_t index_initialized; - int index_first[TABLE_HASH_SIZE]; - int index_last[TABLE_HASH_SIZE]; -}; - -/* - * NOTICE: if you tweak this you should look at is_empty_table() - * and table_elts() in alloc.h - */ -#ifdef MAKE_TABLE_PROFILE -static apr_table_entry_t *do_table_push(const char *func, apr_table_t *t) -{ - if (t->a.nelts == t->a.nalloc) { - fprintf(stderr, "%s: table created by %p hit limit of %u\n", - func ? func : "table_push", t->creator, t->a.nalloc); - } - return (apr_table_entry_t *) apr_array_push_noclear(&t->a); -} -#if defined(__GNUC__) && __GNUC__ >= 2 -#define table_push(t) do_table_push(__FUNCTION__, t) -#else -#define table_push(t) do_table_push(NULL, t) -#endif -#else /* MAKE_TABLE_PROFILE */ -#define table_push(t) ((apr_table_entry_t *) apr_array_push_noclear(&(t)->a)) -#endif /* MAKE_TABLE_PROFILE */ - -APR_DECLARE(const apr_array_header_t *) apr_table_elts(const apr_table_t *t) -{ - return (const apr_array_header_t *)t; -} - -APR_DECLARE(int) apr_is_empty_table(const apr_table_t *t) -{ - return ((t == NULL) || (t->a.nelts == 0)); -} - -APR_DECLARE(apr_table_t *) apr_table_make(apr_pool_t *p, int nelts) -{ - apr_table_t *t = apr_palloc(p, sizeof(apr_table_t)); - - make_array_core(&t->a, p, nelts, sizeof(apr_table_entry_t), 0); -#ifdef MAKE_TABLE_PROFILE - t->creator = __builtin_return_address(0); -#endif - t->index_initialized = 0; - return t; -} - -APR_DECLARE(apr_table_t *) apr_table_copy(apr_pool_t *p, const apr_table_t *t) -{ - apr_table_t *new = apr_palloc(p, sizeof(apr_table_t)); - -#if APR_POOL_DEBUG - /* we don't copy keys and values, so it's necessary that t->a.pool - * have a life span at least as long as p - */ - if (!apr_pool_is_ancestor(t->a.pool, p)) { - fprintf(stderr, "apr_table_copy: t's pool is not an ancestor of p\n"); - abort(); - } -#endif - make_array_core(&new->a, p, t->a.nalloc, sizeof(apr_table_entry_t), 0); - memcpy(new->a.elts, t->a.elts, t->a.nelts * sizeof(apr_table_entry_t)); - new->a.nelts = t->a.nelts; - memcpy(new->index_first, t->index_first, sizeof(int) * TABLE_HASH_SIZE); - memcpy(new->index_last, t->index_last, sizeof(int) * TABLE_HASH_SIZE); - new->index_initialized = t->index_initialized; - return new; -} - -APR_DECLARE(apr_table_t *) apr_table_clone(apr_pool_t *p, const apr_table_t *t) -{ - const apr_array_header_t *array = apr_table_elts(t); - apr_table_entry_t *elts = (apr_table_entry_t *) array->elts; - apr_table_t *new = apr_table_make(p, array->nelts); - int i; - - for (i = 0; i < array->nelts; i++) { - apr_table_add(new, elts[i].key, elts[i].val); - } - - return new; -} - -static void table_reindex(apr_table_t *t) -{ - int i; - int hash; - apr_table_entry_t *next_elt = (apr_table_entry_t *) t->a.elts; - - t->index_initialized = 0; - for (i = 0; i < t->a.nelts; i++, next_elt++) { - hash = TABLE_HASH(next_elt->key); - t->index_last[hash] = i; - if (!TABLE_INDEX_IS_INITIALIZED(t, hash)) { - t->index_first[hash] = i; - TABLE_SET_INDEX_INITIALIZED(t, hash); - } - } -} - -APR_DECLARE(void) apr_table_clear(apr_table_t *t) -{ - t->a.nelts = 0; - t->index_initialized = 0; -} - -APR_DECLARE(const char *) apr_table_get(const apr_table_t *t, const char *key) -{ - apr_table_entry_t *next_elt; - apr_table_entry_t *end_elt; - apr_uint32_t checksum; - int hash; - - if (key == NULL) { - return NULL; - } - - hash = TABLE_HASH(key); - if (!TABLE_INDEX_IS_INITIALIZED(t, hash)) { - return NULL; - } - COMPUTE_KEY_CHECKSUM(key, checksum); - next_elt = ((apr_table_entry_t *) t->a.elts) + t->index_first[hash];; - end_elt = ((apr_table_entry_t *) t->a.elts) + t->index_last[hash]; - - for (; next_elt <= end_elt; next_elt++) { - if ((checksum == next_elt->key_checksum) && - !strcasecmp(next_elt->key, key)) { - return next_elt->val; - } - } - - return NULL; -} - -APR_DECLARE(void) apr_table_set(apr_table_t *t, const char *key, - const char *val) -{ - apr_table_entry_t *next_elt; - apr_table_entry_t *end_elt; - apr_table_entry_t *table_end; - apr_uint32_t checksum; - int hash; - - COMPUTE_KEY_CHECKSUM(key, checksum); - hash = TABLE_HASH(key); - if (!TABLE_INDEX_IS_INITIALIZED(t, hash)) { - t->index_first[hash] = t->a.nelts; - TABLE_SET_INDEX_INITIALIZED(t, hash); - goto add_new_elt; - } - next_elt = ((apr_table_entry_t *) t->a.elts) + t->index_first[hash];; - end_elt = ((apr_table_entry_t *) t->a.elts) + t->index_last[hash]; - table_end =((apr_table_entry_t *) t->a.elts) + t->a.nelts; - - for (; next_elt <= end_elt; next_elt++) { - if ((checksum == next_elt->key_checksum) && - !strcasecmp(next_elt->key, key)) { - - /* Found an existing entry with the same key, so overwrite it */ - - int must_reindex = 0; - apr_table_entry_t *dst_elt = NULL; - - next_elt->val = apr_pstrdup(t->a.pool, val); - - /* Remove any other instances of this key */ - for (next_elt++; next_elt <= end_elt; next_elt++) { - if ((checksum == next_elt->key_checksum) && - !strcasecmp(next_elt->key, key)) { - t->a.nelts--; - if (!dst_elt) { - dst_elt = next_elt; - } - } - else if (dst_elt) { - *dst_elt++ = *next_elt; - must_reindex = 1; - } - } - - /* If we've removed anything, shift over the remainder - * of the table (note that the previous loop didn't - * run to the end of the table, just to the last match - * for the index) - */ - if (dst_elt) { - for (; next_elt < table_end; next_elt++) { - *dst_elt++ = *next_elt; - } - must_reindex = 1; - } - if (must_reindex) { - table_reindex(t); - } - return; - } - } - -add_new_elt: - t->index_last[hash] = t->a.nelts; - next_elt = (apr_table_entry_t *) table_push(t); - next_elt->key = apr_pstrdup(t->a.pool, key); - next_elt->val = apr_pstrdup(t->a.pool, val); - next_elt->key_checksum = checksum; -} - -APR_DECLARE(void) apr_table_setn(apr_table_t *t, const char *key, - const char *val) -{ - apr_table_entry_t *next_elt; - apr_table_entry_t *end_elt; - apr_table_entry_t *table_end; - apr_uint32_t checksum; - int hash; - - COMPUTE_KEY_CHECKSUM(key, checksum); - hash = TABLE_HASH(key); - if (!TABLE_INDEX_IS_INITIALIZED(t, hash)) { - t->index_first[hash] = t->a.nelts; - TABLE_SET_INDEX_INITIALIZED(t, hash); - goto add_new_elt; - } - next_elt = ((apr_table_entry_t *) t->a.elts) + t->index_first[hash];; - end_elt = ((apr_table_entry_t *) t->a.elts) + t->index_last[hash]; - table_end =((apr_table_entry_t *) t->a.elts) + t->a.nelts; - - for (; next_elt <= end_elt; next_elt++) { - if ((checksum == next_elt->key_checksum) && - !strcasecmp(next_elt->key, key)) { - - /* Found an existing entry with the same key, so overwrite it */ - - int must_reindex = 0; - apr_table_entry_t *dst_elt = NULL; - - next_elt->val = (char *)val; - - /* Remove any other instances of this key */ - for (next_elt++; next_elt <= end_elt; next_elt++) { - if ((checksum == next_elt->key_checksum) && - !strcasecmp(next_elt->key, key)) { - t->a.nelts--; - if (!dst_elt) { - dst_elt = next_elt; - } - } - else if (dst_elt) { - *dst_elt++ = *next_elt; - must_reindex = 1; - } - } - - /* If we've removed anything, shift over the remainder - * of the table (note that the previous loop didn't - * run to the end of the table, just to the last match - * for the index) - */ - if (dst_elt) { - for (; next_elt < table_end; next_elt++) { - *dst_elt++ = *next_elt; - } - must_reindex = 1; - } - if (must_reindex) { - table_reindex(t); - } - return; - } - } - -add_new_elt: - t->index_last[hash] = t->a.nelts; - next_elt = (apr_table_entry_t *) table_push(t); - next_elt->key = (char *)key; - next_elt->val = (char *)val; - next_elt->key_checksum = checksum; -} - -APR_DECLARE(void) apr_table_unset(apr_table_t *t, const char *key) -{ - apr_table_entry_t *next_elt; - apr_table_entry_t *end_elt; - apr_table_entry_t *dst_elt; - apr_uint32_t checksum; - int hash; - int must_reindex; - - hash = TABLE_HASH(key); - if (!TABLE_INDEX_IS_INITIALIZED(t, hash)) { - return; - } - COMPUTE_KEY_CHECKSUM(key, checksum); - next_elt = ((apr_table_entry_t *) t->a.elts) + t->index_first[hash]; - end_elt = ((apr_table_entry_t *) t->a.elts) + t->index_last[hash]; - must_reindex = 0; - for (; next_elt <= end_elt; next_elt++) { - if ((checksum == next_elt->key_checksum) && - !strcasecmp(next_elt->key, key)) { - - /* Found a match: remove this entry, plus any additional - * matches for the same key that might follow - */ - apr_table_entry_t *table_end = ((apr_table_entry_t *) t->a.elts) + - t->a.nelts; - t->a.nelts--; - dst_elt = next_elt; - for (next_elt++; next_elt <= end_elt; next_elt++) { - if ((checksum == next_elt->key_checksum) && - !strcasecmp(next_elt->key, key)) { - t->a.nelts--; - } - else { - *dst_elt++ = *next_elt; - } - } - - /* Shift over the remainder of the table (note that - * the previous loop didn't run to the end of the table, - * just to the last match for the index) - */ - for (; next_elt < table_end; next_elt++) { - *dst_elt++ = *next_elt; - } - must_reindex = 1; - break; - } - } - if (must_reindex) { - table_reindex(t); - } -} - -APR_DECLARE(void) apr_table_merge(apr_table_t *t, const char *key, - const char *val) -{ - apr_table_entry_t *next_elt; - apr_table_entry_t *end_elt; - apr_uint32_t checksum; - int hash; - - COMPUTE_KEY_CHECKSUM(key, checksum); - hash = TABLE_HASH(key); - if (!TABLE_INDEX_IS_INITIALIZED(t, hash)) { - t->index_first[hash] = t->a.nelts; - TABLE_SET_INDEX_INITIALIZED(t, hash); - goto add_new_elt; - } - next_elt = ((apr_table_entry_t *) t->a.elts) + t->index_first[hash]; - end_elt = ((apr_table_entry_t *) t->a.elts) + t->index_last[hash]; - - for (; next_elt <= end_elt; next_elt++) { - if ((checksum == next_elt->key_checksum) && - !strcasecmp(next_elt->key, key)) { - - /* Found an existing entry with the same key, so merge with it */ - next_elt->val = apr_pstrcat(t->a.pool, next_elt->val, ", ", - val, NULL); - return; - } - } - -add_new_elt: - t->index_last[hash] = t->a.nelts; - next_elt = (apr_table_entry_t *) table_push(t); - next_elt->key = apr_pstrdup(t->a.pool, key); - next_elt->val = apr_pstrdup(t->a.pool, val); - next_elt->key_checksum = checksum; -} - -APR_DECLARE(void) apr_table_mergen(apr_table_t *t, const char *key, - const char *val) -{ - apr_table_entry_t *next_elt; - apr_table_entry_t *end_elt; - apr_uint32_t checksum; - int hash; - -#if APR_POOL_DEBUG - { - if (!apr_pool_is_ancestor(apr_pool_find(key), t->a.pool)) { - fprintf(stderr, "apr_table_mergen: key not in ancestor pool of t\n"); - abort(); - } - if (!apr_pool_is_ancestor(apr_pool_find(val), t->a.pool)) { - fprintf(stderr, "apr_table_mergen: val not in ancestor pool of t\n"); - abort(); - } - } -#endif - - COMPUTE_KEY_CHECKSUM(key, checksum); - hash = TABLE_HASH(key); - if (!TABLE_INDEX_IS_INITIALIZED(t, hash)) { - t->index_first[hash] = t->a.nelts; - TABLE_SET_INDEX_INITIALIZED(t, hash); - goto add_new_elt; - } - next_elt = ((apr_table_entry_t *) t->a.elts) + t->index_first[hash];; - end_elt = ((apr_table_entry_t *) t->a.elts) + t->index_last[hash]; - - for (; next_elt <= end_elt; next_elt++) { - if ((checksum == next_elt->key_checksum) && - !strcasecmp(next_elt->key, key)) { - - /* Found an existing entry with the same key, so merge with it */ - next_elt->val = apr_pstrcat(t->a.pool, next_elt->val, ", ", - val, NULL); - return; - } - } - -add_new_elt: - t->index_last[hash] = t->a.nelts; - next_elt = (apr_table_entry_t *) table_push(t); - next_elt->key = (char *)key; - next_elt->val = (char *)val; - next_elt->key_checksum = checksum; -} - -APR_DECLARE(void) apr_table_add(apr_table_t *t, const char *key, - const char *val) -{ - apr_table_entry_t *elts; - apr_uint32_t checksum; - int hash; - - hash = TABLE_HASH(key); - t->index_last[hash] = t->a.nelts; - if (!TABLE_INDEX_IS_INITIALIZED(t, hash)) { - t->index_first[hash] = t->a.nelts; - TABLE_SET_INDEX_INITIALIZED(t, hash); - } - COMPUTE_KEY_CHECKSUM(key, checksum); - elts = (apr_table_entry_t *) table_push(t); - elts->key = apr_pstrdup(t->a.pool, key); - elts->val = apr_pstrdup(t->a.pool, val); - elts->key_checksum = checksum; -} - -APR_DECLARE(void) apr_table_addn(apr_table_t *t, const char *key, - const char *val) -{ - apr_table_entry_t *elts; - apr_uint32_t checksum; - int hash; - -#if APR_POOL_DEBUG - { - if (!apr_pool_is_ancestor(apr_pool_find(key), t->a.pool)) { - fprintf(stderr, "apr_table_addn: key not in ancestor pool of t\n"); - abort(); - } - if (!apr_pool_is_ancestor(apr_pool_find(val), t->a.pool)) { - fprintf(stderr, "apr_table_addn: val not in ancestor pool of t\n"); - abort(); - } - } -#endif - - hash = TABLE_HASH(key); - t->index_last[hash] = t->a.nelts; - if (!TABLE_INDEX_IS_INITIALIZED(t, hash)) { - t->index_first[hash] = t->a.nelts; - TABLE_SET_INDEX_INITIALIZED(t, hash); - } - COMPUTE_KEY_CHECKSUM(key, checksum); - elts = (apr_table_entry_t *) table_push(t); - elts->key = (char *)key; - elts->val = (char *)val; - elts->key_checksum = checksum; -} - -APR_DECLARE(apr_table_t *) apr_table_overlay(apr_pool_t *p, - const apr_table_t *overlay, - const apr_table_t *base) -{ - apr_table_t *res; - -#if APR_POOL_DEBUG - /* we don't copy keys and values, so it's necessary that - * overlay->a.pool and base->a.pool have a life span at least - * as long as p - */ - if (!apr_pool_is_ancestor(overlay->a.pool, p)) { - fprintf(stderr, - "apr_table_overlay: overlay's pool is not an ancestor of p\n"); - abort(); - } - if (!apr_pool_is_ancestor(base->a.pool, p)) { - fprintf(stderr, - "apr_table_overlay: base's pool is not an ancestor of p\n"); - abort(); - } -#endif - - res = apr_palloc(p, sizeof(apr_table_t)); - /* behave like append_arrays */ - res->a.pool = p; - copy_array_hdr_core(&res->a, &overlay->a); - apr_array_cat(&res->a, &base->a); - table_reindex(res); - return res; -} - -/* And now for something completely abstract ... - - * For each key value given as a vararg: - * run the function pointed to as - * int comp(void *r, char *key, char *value); - * on each valid key-value pair in the apr_table_t t that matches the vararg key, - * or once for every valid key-value pair if the vararg list is empty, - * until the function returns false (0) or we finish the table. - * - * Note that we restart the traversal for each vararg, which means that - * duplicate varargs will result in multiple executions of the function - * for each matching key. Note also that if the vararg list is empty, - * only one traversal will be made and will cut short if comp returns 0. - * - * Note that the table_get and table_merge functions assume that each key in - * the apr_table_t is unique (i.e., no multiple entries with the same key). This - * function does not make that assumption, since it (unfortunately) isn't - * true for some of Apache's tables. - * - * Note that rec is simply passed-on to the comp function, so that the - * caller can pass additional info for the task. - * - * ADDENDUM for apr_table_vdo(): - * - * The caching api will allow a user to walk the header values: - * - * apr_status_t apr_cache_el_header_walk(apr_cache_el *el, - * int (*comp)(void *, const char *, const char *), void *rec, ...); - * - * So it can be ..., however from there I use a callback that use a va_list: - * - * apr_status_t (*cache_el_header_walk)(apr_cache_el *el, - * int (*comp)(void *, const char *, const char *), void *rec, va_list); - * - * To pass those ...'s on down to the actual module that will handle walking - * their headers, in the file case this is actually just an apr_table - and - * rather than reimplementing apr_table_do (which IMHO would be bad) I just - * called it with the va_list. For mod_shmem_cache I don't need it since I - * can't use apr_table's, but mod_file_cache should (though a good hash would - * be better, but that's a different issue :). - * - * So to make mod_file_cache easier to maintain, it's a good thing - */ -APR_DECLARE_NONSTD(int) apr_table_do(apr_table_do_callback_fn_t *comp, - void *rec, const apr_table_t *t, ...) -{ - int rv; - - va_list vp; - va_start(vp, t); - rv = apr_table_vdo(comp, rec, t, vp); - va_end(vp); - - return rv; -} - -/* XXX: do the semantics of this routine make any sense? Right now, - * if the caller passed in a non-empty va_list of keys to search for, - * the "early termination" facility only terminates on *that* key; other - * keys will continue to process. Note that this only has any effect - * at all if there are multiple entries in the table with the same key, - * otherwise the called function can never effectively early-terminate - * this function, as the zero return value is effectively ignored. - * - * Note also that this behavior is at odds with the behavior seen if an - * empty va_list is passed in -- in that case, a zero return value terminates - * the entire apr_table_vdo (which is what I think should happen in - * both cases). - * - * If nobody objects soon, I'm going to change the order of the nested - * loops in this function so that any zero return value from the (*comp) - * function will cause a full termination of apr_table_vdo. I'm hesitant - * at the moment because these (funky) semantics have been around for a - * very long time, and although Apache doesn't seem to use them at all, - * some third-party vendor might. I can only think of one possible reason - * the existing semantics would make any sense, and it's very Apache-centric, - * which is this: if (*comp) is looking for matches of a particular - * substring in request headers (let's say it's looking for a particular - * cookie name in the Set-Cookie headers), then maybe it wants to be - * able to stop searching early as soon as it finds that one and move - * on to the next key. That's only an optimization of course, but changing - * the behavior of this function would mean that any code that tried - * to do that would stop working right. - * - * Sigh. --JCW, 06/28/02 - */ -APR_DECLARE(int) apr_table_vdo(apr_table_do_callback_fn_t *comp, - void *rec, const apr_table_t *t, va_list vp) -{ - char *argp; - apr_table_entry_t *elts = (apr_table_entry_t *) t->a.elts; - int vdorv = 1; - - argp = va_arg(vp, char *); - do { - int rv = 1, i; - if (argp) { - /* Scan for entries that match the next key */ - int hash = TABLE_HASH(argp); - if (TABLE_INDEX_IS_INITIALIZED(t, hash)) { - apr_uint32_t checksum; - COMPUTE_KEY_CHECKSUM(argp, checksum); - for (i = t->index_first[hash]; - rv && (i <= t->index_last[hash]); ++i) { - if (elts[i].key && (checksum == elts[i].key_checksum) && - !strcasecmp(elts[i].key, argp)) { - rv = (*comp) (rec, elts[i].key, elts[i].val); - } - } - } - } - else { - /* Scan the entire table */ - for (i = 0; rv && (i < t->a.nelts); ++i) { - if (elts[i].key) { - rv = (*comp) (rec, elts[i].key, elts[i].val); - } - } - } - if (rv == 0) { - vdorv = 0; - } - } while (argp && ((argp = va_arg(vp, char *)) != NULL)); - - return vdorv; -} - -static apr_table_entry_t **table_mergesort(apr_pool_t *pool, - apr_table_entry_t **values, - apr_size_t n) -{ - /* Bottom-up mergesort, based on design in Sedgewick's "Algorithms - * in C," chapter 8 - */ - apr_table_entry_t **values_tmp = - (apr_table_entry_t **)apr_palloc(pool, n * sizeof(apr_table_entry_t*)); - apr_size_t i; - apr_size_t blocksize; - - /* First pass: sort pairs of elements (blocksize=1) */ - for (i = 0; i + 1 < n; i += 2) { - if (strcasecmp(values[i]->key, values[i + 1]->key) > 0) { - apr_table_entry_t *swap = values[i]; - values[i] = values[i + 1]; - values[i + 1] = swap; - } - } - - /* Merge successively larger blocks */ - blocksize = 2; - while (blocksize < n) { - apr_table_entry_t **dst = values_tmp; - apr_size_t next_start; - apr_table_entry_t **swap; - - /* Merge consecutive pairs blocks of the next blocksize. - * Within a block, elements are in sorted order due to - * the previous iteration. - */ - for (next_start = 0; next_start + blocksize < n; - next_start += (blocksize + blocksize)) { - - apr_size_t block1_start = next_start; - apr_size_t block2_start = block1_start + blocksize; - apr_size_t block1_end = block2_start; - apr_size_t block2_end = block2_start + blocksize; - if (block2_end > n) { - /* The last block may be smaller than blocksize */ - block2_end = n; - } - for (;;) { - - /* Merge the next two blocks: - * Pick the smaller of the next element from - * block 1 and the next element from block 2. - * Once either of the blocks is emptied, copy - * over all the remaining elements from the - * other block - */ - if (block1_start == block1_end) { - for (; block2_start < block2_end; block2_start++) { - *dst++ = values[block2_start]; - } - break; - } - else if (block2_start == block2_end) { - for (; block1_start < block1_end; block1_start++) { - *dst++ = values[block1_start]; - } - break; - } - if (strcasecmp(values[block1_start]->key, - values[block2_start]->key) > 0) { - *dst++ = values[block2_start++]; - } - else { - *dst++ = values[block1_start++]; - } - } - } - - /* If n is not a multiple of 2*blocksize, some elements - * will be left over at the end of the array. - */ - for (i = dst - values_tmp; i < n; i++) { - values_tmp[i] = values[i]; - } - - /* The output array of this pass becomes the input - * array of the next pass, and vice versa - */ - swap = values_tmp; - values_tmp = values; - values = swap; - - blocksize += blocksize; - } - - return values; -} - -APR_DECLARE(void) apr_table_compress(apr_table_t *t, unsigned flags) -{ - apr_table_entry_t **sort_array; - apr_table_entry_t **sort_next; - apr_table_entry_t **sort_end; - apr_table_entry_t *table_next; - apr_table_entry_t **last; - int i; - int dups_found; - - if (t->a.nelts <= 1) { - return; - } - - /* Copy pointers to all the table elements into an - * array and sort to allow for easy detection of - * duplicate keys - */ - sort_array = (apr_table_entry_t **) - apr_palloc(t->a.pool, t->a.nelts * sizeof(apr_table_entry_t*)); - sort_next = sort_array; - table_next = (apr_table_entry_t *)t->a.elts; - i = t->a.nelts; - do { - *sort_next++ = table_next++; - } while (--i); - - /* Note: the merge is done with mergesort instead of quicksort - * because mergesort is a stable sort and runs in n*log(n) - * time regardless of its inputs (quicksort is quadratic in - * the worst case) - */ - sort_array = table_mergesort(t->a.pool, sort_array, t->a.nelts); - - /* Process any duplicate keys */ - dups_found = 0; - sort_next = sort_array; - sort_end = sort_array + t->a.nelts; - last = sort_next++; - while (sort_next < sort_end) { - if (((*sort_next)->key_checksum == (*last)->key_checksum) && - !strcasecmp((*sort_next)->key, (*last)->key)) { - apr_table_entry_t **dup_last = sort_next + 1; - dups_found = 1; - while ((dup_last < sort_end) && - ((*dup_last)->key_checksum == (*last)->key_checksum) && - !strcasecmp((*dup_last)->key, (*last)->key)) { - dup_last++; - } - dup_last--; /* Elements from last through dup_last, inclusive, - * all have the same key - */ - if (flags == APR_OVERLAP_TABLES_MERGE) { - apr_size_t len = 0; - apr_table_entry_t **next = last; - char *new_val; - char *val_dst; - do { - len += strlen((*next)->val); - len += 2; /* for ", " or trailing null */ - } while (++next <= dup_last); - new_val = (char *)apr_palloc(t->a.pool, len); - val_dst = new_val; - next = last; - for (;;) { - strcpy(val_dst, (*next)->val); - val_dst += strlen((*next)->val); - next++; - if (next > dup_last) { - *val_dst = 0; - break; - } - else { - *val_dst++ = ','; - *val_dst++ = ' '; - } - } - (*last)->val = new_val; - } - else { /* overwrite */ - (*last)->val = (*dup_last)->val; - } - do { - (*sort_next)->key = NULL; - } while (++sort_next <= dup_last); - } - else { - last = sort_next++; - } - } - - /* Shift elements to the left to fill holes left by removing duplicates */ - if (dups_found) { - apr_table_entry_t *src = (apr_table_entry_t *)t->a.elts; - apr_table_entry_t *dst = (apr_table_entry_t *)t->a.elts; - apr_table_entry_t *last_elt = src + t->a.nelts; - do { - if (src->key) { - *dst++ = *src; - } - } while (++src < last_elt); - t->a.nelts -= (int)(last_elt - dst); - } - - table_reindex(t); -} - -static void apr_table_cat(apr_table_t *t, const apr_table_t *s) -{ - const int n = t->a.nelts; - register int idx; - - apr_array_cat(&t->a,&s->a); - - if (n == 0) { - memcpy(t->index_first,s->index_first,sizeof(int) * TABLE_HASH_SIZE); - memcpy(t->index_last, s->index_last, sizeof(int) * TABLE_HASH_SIZE); - t->index_initialized = s->index_initialized; - return; - } - - for (idx = 0; idx < TABLE_HASH_SIZE; ++idx) { - if (TABLE_INDEX_IS_INITIALIZED(s, idx)) { - t->index_last[idx] = s->index_last[idx] + n; - if (!TABLE_INDEX_IS_INITIALIZED(t, idx)) { - t->index_first[idx] = s->index_first[idx] + n; - } - } - } - - t->index_initialized |= s->index_initialized; -} - -APR_DECLARE(void) apr_table_overlap(apr_table_t *a, const apr_table_t *b, - unsigned flags) -{ - if (a->a.nelts + b->a.nelts == 0) { - return; - } - -#if APR_POOL_DEBUG - /* Since the keys and values are not copied, it's required that - * b->a.pool has a lifetime at least as long as a->a.pool. */ - if (!apr_pool_is_ancestor(b->a.pool, a->a.pool)) { - fprintf(stderr, "apr_table_overlap: b's pool is not an ancestor of a's\n"); - abort(); - } -#endif - - apr_table_cat(a, b); - - apr_table_compress(a, flags); -} diff --git a/libs/apr/threadproc/beos/apr_proc_stub.c b/libs/apr/threadproc/beos/apr_proc_stub.c deleted file mode 100644 index 011d793e..00000000 --- a/libs/apr/threadproc/beos/apr_proc_stub.c +++ /dev/null @@ -1,76 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include - -struct pipefd { - int in; - int out; - int err; -}; - -int main(int argc, char *argv[]) { -/* we expect the following... - * - * argv[0] = this stub - * argv[1] = directory to run in... - * argv[2] = progname to execute - * rest of arguments to be passed to program - */ - char *progname = argv[2]; - char *directory = argv[1]; - struct pipefd *pfd; - thread_id sender; - void *buffer; - char ** newargs; - int i = 0; - - newargs = (char**)malloc(sizeof(char*) * (argc - 1)); - - buffer = (void*)malloc(sizeof(struct pipefd)); - /* this will block until we get the data */ - receive_data(&sender, buffer, sizeof(struct pipefd)); - pfd = (struct pipefd*)buffer; - - if (pfd->in > STDERR_FILENO) { - if (dup2(pfd->in, STDIN_FILENO) != STDIN_FILENO) return (-1); - close (pfd->in); - } - if (pfd->out > STDERR_FILENO) { - if (dup2(pfd->out, STDOUT_FILENO) != STDOUT_FILENO) return (-1); - close (pfd->out); - } - if (pfd->err > STDERR_FILENO) { - if (dup2(pfd->err, STDERR_FILENO) != STDERR_FILENO) return (-1); - close (pfd->err); - } - - for (i=3;i<=argc;i++){ - newargs[i-3] = argv[i]; - } - - /* tell the caller we're OK to start */ - send_data(sender,1,NULL,0); - - if (directory != NULL) - chdir(directory); - execve (progname, newargs, environ); - - return (-1); -} diff --git a/libs/apr/threadproc/beos/proc.c b/libs/apr/threadproc/beos/proc.c deleted file mode 100644 index 97c05a70..00000000 --- a/libs/apr/threadproc/beos/proc.c +++ /dev/null @@ -1,446 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_threadproc.h" -#include "apr_strings.h" - -/* Heavy on no'ops, here's what we want to pass if there is APR_NO_FILE - * requested for a specific child handle; - */ -static apr_file_t no_file = { NULL, -1, }; - -struct send_pipe { - int in; - int out; - int err; -}; - -APR_DECLARE(apr_status_t) apr_procattr_create(apr_procattr_t **new, apr_pool_t *pool) -{ - (*new) = (apr_procattr_t *)apr_palloc(pool, - sizeof(apr_procattr_t)); - - if ((*new) == NULL) { - return APR_ENOMEM; - } - (*new)->pool = pool; - (*new)->parent_in = NULL; - (*new)->child_in = NULL; - (*new)->parent_out = NULL; - (*new)->child_out = NULL; - (*new)->parent_err = NULL; - (*new)->child_err = NULL; - (*new)->currdir = NULL; - (*new)->cmdtype = APR_PROGRAM; - (*new)->detached = 0; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, - apr_int32_t in, - apr_int32_t out, - apr_int32_t err) -{ - apr_status_t rv; - - if ((in != APR_NO_PIPE) && (in != APR_NO_FILE)) { - /* APR_CHILD_BLOCK maps to APR_WRITE_BLOCK, while - * APR_PARENT_BLOCK maps to APR_READ_BLOCK, so transpose - * the CHILD/PARENT blocking flags for the stdin pipe. - * stdout/stderr map to the correct mode by default. - */ - if (in == APR_CHILD_BLOCK) - in = APR_READ_BLOCK; - else if (in == APR_PARENT_BLOCK) - in = APR_WRITE_BLOCK; - - if ((rv = apr_file_pipe_create_ex(&attr->child_in, &attr->parent_in, - in, attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_in); - if (rv != APR_SUCCESS) - return rv; - } - else if (in == APR_NO_FILE) - attr->child_in = &no_file; - - if ((out != APR_NO_PIPE) && (out != APR_NO_FILE)) { - if ((rv = apr_file_pipe_create_ex(&attr->parent_out, &attr->child_out, - out, attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_out); - if (rv != APR_SUCCESS) - return rv; - } - else if (out == APR_NO_FILE) - attr->child_out = &no_file; - - if ((err != APR_NO_PIPE) && (err != APR_NO_FILE)) { - if ((rv = apr_file_pipe_create_ex(&attr->parent_err, &attr->child_err, - err, attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_err); - if (rv != APR_SUCCESS) - return rv; - } - else if (err == APR_NO_FILE) - attr->child_err = &no_file; - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_dir_set(apr_procattr_t *attr, - const char *dir) -{ - char * cwd; - if (dir[0] != '/') { - cwd = (char*)malloc(sizeof(char) * PATH_MAX); - getcwd(cwd, PATH_MAX); - attr->currdir = (char *)apr_pstrcat(attr->pool, cwd, "/", dir, NULL); - free(cwd); - } else { - attr->currdir = (char *)apr_pstrdup(attr->pool, dir); - } - if (attr->currdir) { - return APR_SUCCESS; - } - return APR_ENOMEM; -} - -APR_DECLARE(apr_status_t) apr_procattr_cmdtype_set(apr_procattr_t *attr, - apr_cmdtype_e cmd) -{ - attr->cmdtype = cmd; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_detach_set(apr_procattr_t *attr, apr_int32_t detach) -{ - attr->detached = detach; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *pool) -{ - int pid; - - if ((pid = fork()) < 0) { - return errno; - } - else if (pid == 0) { - /* This is really ugly... - * The semantics of BeOS's fork() are that areas (used for shared - * memory) get COW'd :-( The only way we can make shared memory - * work across fork() is therefore to find any areas that have - * been created and then clone them into our address space. - * Thankfully only COW'd areas have the lock variable set at - * anything but 0, so we can use that to find the areas we need to - * copy. Of course what makes it even worse is that the loop through - * the area's will go into an infinite loop, eating memory and then - * eventually segfault unless we know when we reach then end of the - * "original" areas and stop. Why? Well, we delete the area and then - * add another to the end of the list... - */ - area_info ai; - int32 cookie = 0; - area_id highest = 0; - - while (get_next_area_info(0, &cookie, &ai) == B_OK) - if (ai.area > highest) - highest = ai.area; - cookie = 0; - while (get_next_area_info(0, &cookie, &ai) == B_OK) { - if (ai.area > highest) - break; - if (ai.lock > 0) { - area_id original = find_area(ai.name); - delete_area(ai.area); - clone_area(ai.name, &ai.address, B_CLONE_ADDRESS, - ai.protection, original); - } - } - - proc->pid = pid; - proc->in = NULL; - proc->out = NULL; - proc->err = NULL; - return APR_INCHILD; - } - proc->pid = pid; - proc->in = NULL; - proc->out = NULL; - proc->err = NULL; - return APR_INPARENT; -} - -APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr, - apr_child_errfn_t *errfn) -{ - /* won't ever be called on this platform, so don't save the function pointer */ - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr, - apr_int32_t chk) -{ - /* won't ever be used on this platform, so don't save the flag */ - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_addrspace_set(apr_procattr_t *attr, - apr_int32_t addrspace) -{ - /* won't ever be used on this platform, so don't save the flag */ - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, const char *progname, - const char * const *args, - const char * const *env, - apr_procattr_t *attr, - apr_pool_t *pool) -{ - int i=0,nargs=0; - char **newargs = NULL; - thread_id newproc, sender; - struct send_pipe *sp; - char * dir = NULL; - - sp = (struct send_pipe *)apr_palloc(pool, sizeof(struct send_pipe)); - - new->in = attr->parent_in; - new->err = attr->parent_err; - new->out = attr->parent_out; - sp->in = attr->child_in ? attr->child_in->filedes : FILENO_STDIN; - sp->out = attr->child_out ? attr->child_out->filedes : FILENO_STDOUT; - sp->err = attr->child_err ? attr->child_err->filedes : FILENO_STDERR; - - i = 0; - while (args && args[i]) { - i++; - } - - newargs = (char**)malloc(sizeof(char *) * (i + 4)); - newargs[0] = strdup("/boot/home/config/bin/apr_proc_stub"); - if (attr->currdir == NULL) { - /* we require the directory , so use a temp. variable */ - dir = malloc(sizeof(char) * PATH_MAX); - getcwd(dir, PATH_MAX); - newargs[1] = strdup(dir); - free(dir); - } else { - newargs[1] = strdup(attr->currdir); - } - newargs[2] = strdup(progname); - i=0;nargs = 3; - - while (args && args[i]) { - newargs[nargs] = strdup(args[i]); - i++;nargs++; - } - newargs[nargs] = NULL; - - /* ### we should be looking at attr->cmdtype in here... */ - - newproc = load_image(nargs, (const char**)newargs, (const char**)env); - - /* load_image copies the data so now we can free it... */ - while (--nargs >= 0) - free (newargs[nargs]); - free(newargs); - - if (newproc < B_NO_ERROR) { - return errno; - } - - resume_thread(newproc); - - if (attr->child_in && (attr->child_in->filedes != -1)) { - apr_file_close(attr->child_in); - } - if (attr->child_out && (attr->child_in->filedes != -1)) { - apr_file_close(attr->child_out); - } - if (attr->child_err && (attr->child_in->filedes != -1)) { - apr_file_close(attr->child_err); - } - - send_data(newproc, 0, (void*)sp, sizeof(struct send_pipe)); - new->pid = newproc; - - /* before we go charging on we need the new process to get to a - * certain point. When it gets there it'll let us know and we - * can carry on. */ - receive_data(&sender, (void*)NULL,0); - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc, - int *exitcode, - apr_exit_why_e *exitwhy, - apr_wait_how_e waithow, - apr_pool_t *p) -{ - proc->pid = -1; - return apr_proc_wait(proc, exitcode, exitwhy, waithow); -} - -APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, - int *exitcode, - apr_exit_why_e *exitwhy, - apr_wait_how_e waithow) -{ - pid_t pstatus; - int waitpid_options = WUNTRACED; - int exit_int; - int ignore; - apr_exit_why_e ignorewhy; - - if (exitcode == NULL) { - exitcode = &ignore; - } - if (exitwhy == NULL) { - exitwhy = &ignorewhy; - } - - if (waithow != APR_WAIT) { - waitpid_options |= WNOHANG; - } - - if ((pstatus = waitpid(proc->pid, &exit_int, waitpid_options)) > 0) { - proc->pid = pstatus; - if (WIFEXITED(exit_int)) { - *exitwhy = APR_PROC_EXIT; - *exitcode = WEXITSTATUS(exit_int); - } - else if (WIFSIGNALED(exit_int)) { - *exitwhy = APR_PROC_SIGNAL; - *exitcode = WTERMSIG(exit_int); - } - else { - - /* unexpected condition */ - return APR_EGENERAL; - } - return APR_CHILD_DONE; - } - else if (pstatus == 0) { - return APR_CHILD_NOTDONE; - } - - return errno; -} - -APR_DECLARE(apr_status_t) apr_procattr_child_in_set(apr_procattr_t *attr, apr_file_t *child_in, - apr_file_t *parent_in) -{ - apr_status_t rv; - - if (attr->child_in == NULL && attr->parent_in == NULL - && child_in == NULL && parent_in == NULL) - if ((rv = apr_file_pipe_create(&attr->child_in, &attr->parent_in, - attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_in); - - if (child_in != NULL && rv == APR_SUCCESS) { - if (attr->child_in && (attr->child_in->filedes != -1)) - rv = apr_file_dup2(attr->child_in, child_in, attr->pool); - else { - attr->child_in = NULL; - if ((rv = apr_file_dup(&attr->child_in, child_in, attr->pool)) - == APR_SUCCESS) - rv = apr_file_inherit_set(attr->child_in); - } - } - - if (parent_in != NULL && rv == APR_SUCCESS) - rv = apr_file_dup(&attr->parent_in, parent_in, attr->pool); - - return rv; -} - -APR_DECLARE(apr_status_t) apr_procattr_child_out_set(apr_procattr_t *attr, apr_file_t *child_out, - apr_file_t *parent_out) -{ - apr_status_t rv; - - if (attr->child_out == NULL && attr->parent_out == NULL - && child_out == NULL && parent_out == NULL) - if ((rv = apr_file_pipe_create(&attr->parent_out, &attr->child_out, - attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_out); - - if (child_out != NULL && rv == APR_SUCCESS) { - if (attr->child_out && (attr->child_out->filedes != -1)) - rv = apr_file_dup2(attr->child_out, child_out, attr->pool); - else { - attr->child_out = NULL; - if ((rv = apr_file_dup(&attr->child_out, child_out, attr->pool)) - == APR_SUCCESS) - rv = apr_file_inherit_set(attr->child_out); - } - } - - if (parent_out != NULL && rv == APR_SUCCESS) - rv = apr_file_dup(&attr->parent_out, parent_out, attr->pool); - - return rv; -} - -APR_DECLARE(apr_status_t) apr_procattr_child_err_set(apr_procattr_t *attr, apr_file_t *child_err, - apr_file_t *parent_err) -{ - apr_status_t rv; - - if (attr->child_err == NULL && attr->parent_err == NULL - && child_err == NULL && parent_err == NULL) - if ((rv = apr_file_pipe_create(&attr->parent_err, &attr->child_err, - attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_err); - - if (child_err != NULL && rv == APR_SUCCESS) { - if (attr->child_err && (attr->child_err->filedes != -1)) - rv = apr_file_dup2(attr->child_err, child_err, attr->pool); - else { - attr->child_err = NULL; - if ((rv = apr_file_dup(&attr->child_err, child_err, attr->pool)) - == APR_SUCCESS) - rv = apr_file_inherit_set(attr->child_err); - } - } - - if (parent_err != NULL && rv == APR_SUCCESS) - rv = apr_file_dup(&attr->parent_err, parent_err, attr->pool); - - return rv; -} - -APR_DECLARE(apr_status_t) apr_procattr_limit_set(apr_procattr_t *attr, apr_int32_t what, - void *limit) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr, - const char *username, - const char *password) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_procattr_group_set(apr_procattr_t *attr, - const char *groupname) -{ - return APR_ENOTIMPL; -} diff --git a/libs/apr/threadproc/beos/thread.c b/libs/apr/threadproc/beos/thread.c deleted file mode 100644 index 8d838394..00000000 --- a/libs/apr/threadproc/beos/thread.c +++ /dev/null @@ -1,237 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_threadproc.h" -#include "apr_portable.h" - -APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new, apr_pool_t *pool) -{ - (*new) = (apr_threadattr_t *)apr_palloc(pool, - sizeof(apr_threadattr_t)); - - if ((*new) == NULL) { - return APR_ENOMEM; - } - - (*new)->pool = pool; - (*new)->attr = (int32)B_NORMAL_PRIORITY; - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_threadattr_detach_set(apr_threadattr_t *attr, apr_int32_t on) -{ - if (on == 1){ - attr->detached = 1; - } else { - attr->detached = 0; - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr) -{ - if (attr->detached == 1){ - return APR_DETACH; - } - return APR_NOTDETACH; -} - -APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, - apr_size_t stacksize) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr, - apr_size_t size) -{ - return APR_ENOTIMPL; -} - -static void *dummy_worker(void *opaque) -{ - apr_thread_t *thd = (apr_thread_t*)opaque; - return thd->func(thd, thd->data); -} - -APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, apr_threadattr_t *attr, - apr_thread_start_t func, void *data, - apr_pool_t *pool) -{ - int32 temp; - apr_status_t stat; - - (*new) = (apr_thread_t *)apr_palloc(pool, sizeof(apr_thread_t)); - if ((*new) == NULL) { - return APR_ENOMEM; - } - - (*new)->data = data; - (*new)->func = func; - (*new)->exitval = -1; - - /* First we create the new thread...*/ - if (attr) - temp = attr->attr; - else - temp = B_NORMAL_PRIORITY; - - stat = apr_pool_create(&(*new)->pool, pool); - if (stat != APR_SUCCESS) { - return stat; - } - - (*new)->td = spawn_thread((thread_func)dummy_worker, - "apr thread", - temp, - (*new)); - - /* Now we try to run it...*/ - if (resume_thread((*new)->td) == B_NO_ERROR) { - return APR_SUCCESS; - } - else { - return errno; - } -} - -APR_DECLARE(apr_os_thread_t) apr_os_thread_current(void) -{ - return find_thread(NULL); -} - -int apr_os_thread_equal(apr_os_thread_t tid1, apr_os_thread_t tid2) -{ - return tid1 == tid2; -} - -APR_DECLARE(apr_status_t) apr_thread_exit(apr_thread_t *thd, apr_status_t retval) -{ - apr_pool_destroy(thd->pool); - thd->exitval = retval; - exit_thread ((status_t)(retval)); - /* This will never be reached... */ - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_join(apr_status_t *retval, apr_thread_t *thd) -{ - status_t rv = 0, ret; - ret = wait_for_thread(thd->td, &rv); - if (ret == B_NO_ERROR) { - *retval = rv; - return APR_SUCCESS; - } - else { - /* if we've missed the thread's death, did we set an exit value prior - * to it's demise? If we did return that. - */ - if (thd->exitval != -1) { - *retval = thd->exitval; - return APR_SUCCESS; - } else - return ret; - } -} - -APR_DECLARE(apr_status_t) apr_thread_detach(apr_thread_t *thd) -{ - if (suspend_thread(thd->td) == B_NO_ERROR){ - return APR_SUCCESS; - } - else { - return errno; - } -} - -void apr_thread_yield() -{ -} - -APR_DECLARE(apr_status_t) apr_thread_data_get(void **data, const char *key, apr_thread_t *thread) -{ - return apr_pool_userdata_get(data, key, thread->pool); -} - -APR_DECLARE(apr_status_t) apr_thread_data_set(void *data, const char *key, - apr_status_t (*cleanup) (void *), - apr_thread_t *thread) -{ - return apr_pool_userdata_set(data, key, cleanup, thread->pool); -} - -APR_DECLARE(apr_status_t) apr_os_thread_get(apr_os_thread_t **thethd, apr_thread_t *thd) -{ - *thethd = &thd->td; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_thread_put(apr_thread_t **thd, apr_os_thread_t *thethd, - apr_pool_t *pool) -{ - if (pool == NULL) { - return APR_ENOPOOL; - } - if ((*thd) == NULL) { - (*thd) = (apr_thread_t *)apr_pcalloc(pool, sizeof(apr_thread_t)); - (*thd)->pool = pool; - } - (*thd)->td = *thethd; - return APR_SUCCESS; -} - -static apr_status_t thread_once_cleanup(void *vcontrol) -{ - apr_thread_once_t *control = (apr_thread_once_t *)vcontrol; - - if (control->sem) { - release_sem(control->sem); - delete_sem(control->sem); - } - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_once_init(apr_thread_once_t **control, - apr_pool_t *p) -{ - int rc; - *control = (apr_thread_once_t *)apr_pcalloc(p, sizeof(apr_thread_once_t)); - (*control)->hit = 0; /* we haven't done it yet... */ - rc = ((*control)->sem = create_sem(1, "thread_once")); - if (rc < 0) - return rc; - - apr_pool_cleanup_register(p, control, thread_once_cleanup, apr_pool_cleanup_null); - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_thread_once(apr_thread_once_t *control, - void (*func)(void)) -{ - if (!control->hit) { - if (acquire_sem(control->sem) == B_OK) { - control->hit = 1; - func(); - } - } - return APR_SUCCESS; -} - -APR_POOL_IMPLEMENT_ACCESSOR(thread) diff --git a/libs/apr/threadproc/beos/threadpriv.c b/libs/apr/threadproc/beos/threadpriv.c deleted file mode 100644 index 442235f7..00000000 --- a/libs/apr/threadproc/beos/threadpriv.c +++ /dev/null @@ -1,180 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_threadproc.h" - -static struct beos_key key_table[BEOS_MAX_DATAKEYS]; -static struct beos_private_data *beos_data[BEOS_MAX_DATAKEYS]; -static sem_id lock; - -APR_DECLARE(apr_status_t) apr_threadkey_private_create(apr_threadkey_t **key, - void (*dest)(void *), apr_pool_t *pool) -{ - (*key) = (apr_threadkey_t *)apr_palloc(pool, sizeof(apr_threadkey_t)); - if ((*key) == NULL) { - return APR_ENOMEM; - } - - (*key)->pool = pool; - - acquire_sem(lock); - for ((*key)->key=0; (*key)->key < BEOS_MAX_DATAKEYS; (*key)->key++){ - if (key_table[(*key)->key].assigned == 0){ - key_table[(*key)->key].assigned = 1; - key_table[(*key)->key].destructor = dest; - release_sem(lock); - return APR_SUCCESS; - } - - } - release_sem(lock); - return APR_ENOMEM; -} - -APR_DECLARE(apr_status_t) apr_threadkey_private_get(void **new, apr_threadkey_t *key) -{ - thread_id tid; - int i, index=0; - tid = find_thread(NULL); - for (i=0;idata){ - /* it's been used */ - if (beos_data[i]->td == tid){ - index = i; - } - } - } - if (index == 0){ - /* no storage for thread so we can't get anything... */ - return APR_ENOMEM; - } - - if ((key->key < BEOS_MAX_DATAKEYS) && (key_table)){ - acquire_sem(key_table[key->key].lock); - if (key_table[key->key].count){ - (*new) = (void*)beos_data[index]->data[key->key]; - } else { - (*new) = NULL; - } - release_sem(key_table[key->key].lock); - } else { - (*new) = NULL; - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_threadkey_private_set(void *priv, apr_threadkey_t *key) -{ - thread_id tid; - int i,index = 0, ret = 0; - - tid = find_thread(NULL); - for (i=0; i < BEOS_MAX_DATAKEYS; i++){ - if (beos_data[i]->data){ - if (beos_data[i]->td == tid){index = i;} - } - } - if (index==0){ - /* not yet been allocated */ - for (i=0; i< BEOS_MAX_DATAKEYS; i++){ - if (! beos_data[i]->data){ - /* we'll take this one... */ - index = i; - beos_data[i]->data = (const void **)malloc(sizeof(void *) * BEOS_MAX_DATAKEYS); - memset((void *)beos_data[i]->data, 0, sizeof(void *) * BEOS_MAX_DATAKEYS); - beos_data[i]->count = (int)malloc(sizeof(int)); - beos_data[i]->td = (thread_id)malloc(sizeof(thread_id)); - beos_data[i]->td = tid; - } - } - } - if (index == 0){ - /* we're out of luck.. */ - return APR_ENOMEM; - } - if ((key->key < BEOS_MAX_DATAKEYS) && (key_table)){ - acquire_sem(key_table[key->key].lock); - if (key_table[key->key].count){ - if (beos_data[index]->data[key->key] == NULL){ - if (priv != NULL){ - beos_data[index]->count++; - key_table[key->key].count++; - } - } else { - if (priv == NULL){ - beos_data[index]->count--; - key_table[key->key].count--; - } - } - beos_data[index]->data[key->key] = priv; - ret = 1; - } else { - ret = 0; - } - release_sem(key_table[key->key].lock); - } - if (ret) - return APR_SUCCESS; - return APR_ENOMEM; -} - -APR_DECLARE(apr_status_t) apr_threadkey_private_delete(apr_threadkey_t *key) -{ - if (key->key < BEOS_MAX_DATAKEYS){ - acquire_sem(key_table[key->key].lock); - if (key_table[key->key].count == 1){ - key_table[key->key].destructor = NULL; - key_table[key->key].count = 0; - } - release_sem(key_table[key->key].lock); - } else { - return APR_ENOMEM; - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_threadkey_data_get(void **data, const char *key, - apr_threadkey_t *threadkey) -{ - return apr_pool_userdata_get(data, key, threadkey->pool); -} - -APR_DECLARE(apr_status_t) apr_threadkey_data_set(void *data, const char *key, - apr_status_t (*cleanup) (void *), - apr_threadkey_t *threadkey) -{ - return apr_pool_userdata_set(data, key, cleanup, threadkey->pool); -} - -APR_DECLARE(apr_status_t) apr_os_threadkey_get(apr_os_threadkey_t *thekey, apr_threadkey_t *key) -{ - *thekey = key->key; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_threadkey_put(apr_threadkey_t **key, - apr_os_threadkey_t *thekey, apr_pool_t *pool) -{ - if (pool == NULL) { - return APR_ENOPOOL; - } - if ((*key) == NULL) { - (*key) = (apr_threadkey_t *)apr_pcalloc(pool, sizeof(apr_threadkey_t)); - (*key)->pool = pool; - } - (*key)->key = *thekey; - return APR_SUCCESS; -} diff --git a/libs/apr/threadproc/beos/threadproc_common.c b/libs/apr/threadproc/beos/threadproc_common.c deleted file mode 100644 index 95e16254..00000000 --- a/libs/apr/threadproc/beos/threadproc_common.c +++ /dev/null @@ -1,21 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* As the signal code is identical, use the unix version to reduce - code duplication */ -#include "../unix/signals.c" -#include "../unix/procsup.c" - diff --git a/libs/apr/threadproc/netware/proc.c b/libs/apr/threadproc/netware/proc.c deleted file mode 100644 index d2404a82..00000000 --- a/libs/apr/threadproc/netware/proc.c +++ /dev/null @@ -1,507 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_threadproc.h" -#include "apr_arch_file_io.h" -#include "apr_strings.h" -#include "apr_portable.h" - -#include - -/* Heavy on no'ops, here's what we want to pass if there is APR_NO_FILE - * requested for a specific child handle; - */ -static apr_file_t no_file = { NULL, -1, }; - -static apr_status_t apr_netware_proc_cleanup(void *theproc) -{ - apr_proc_t *proc = theproc; - int exit_int; - int waitpid_options = WUNTRACED | WNOHANG; - - if (proc->pid > 0) { - waitpid(proc->pid, &exit_int, waitpid_options); - } - -/* NXVmDestroy(proc->pid); */ - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_create(apr_procattr_t **new,apr_pool_t *pool) -{ - (*new) = (apr_procattr_t *)apr_pcalloc(pool, sizeof(apr_procattr_t)); - - if ((*new) == NULL) { - return APR_ENOMEM; - } - (*new)->pool = pool; - (*new)->cmdtype = APR_PROGRAM; - /* Default to a current path since NetWare doesn't handle it very well */ - apr_filepath_get(&((*new)->currdir), APR_FILEPATH_NATIVE, pool); - (*new)->detached = 1; - return APR_SUCCESS; - -} - -APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, - apr_int32_t in, - apr_int32_t out, - apr_int32_t err) -{ - apr_status_t rv; - - if ((in != APR_NO_PIPE) && (in != APR_NO_FILE)) { - /* APR_CHILD_BLOCK maps to APR_WRITE_BLOCK, while - * APR_PARENT_BLOCK maps to APR_READ_BLOCK, so transpose - * the CHILD/PARENT blocking flags for the stdin pipe. - * stdout/stderr map to the correct mode by default. - */ - if (in == APR_CHILD_BLOCK) - in = APR_READ_BLOCK; - else if (in == APR_PARENT_BLOCK) - in = APR_WRITE_BLOCK; - - if ((rv = apr_file_pipe_create_ex(&attr->child_in, &attr->parent_in, - in, attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_in); - if (rv != APR_SUCCESS) - return rv; - } - else if (in == APR_NO_FILE) - attr->child_in = &no_file; - - if ((out != APR_NO_PIPE) && (out != APR_NO_FILE)) { - if ((rv = apr_file_pipe_create_ex(&attr->parent_out, &attr->child_out, - out, attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_out); - if (rv != APR_SUCCESS) - return rv; - } - else if (out == APR_NO_FILE) - attr->child_out = &no_file; - - if ((err != APR_NO_PIPE) && (err != APR_NO_FILE)) { - if ((rv = apr_file_pipe_create_ex(&attr->parent_err, &attr->child_err, - err, attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_err); - if (rv != APR_SUCCESS) - return rv; - } - else if (err == APR_NO_FILE) - attr->child_err = &no_file; - - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_procattr_child_in_set(apr_procattr_t *attr, apr_file_t *child_in, - apr_file_t *parent_in) -{ - apr_status_t rv = APR_SUCCESS; - - if (attr->child_in == NULL && attr->parent_in == NULL - && child_in == NULL && parent_in == NULL) - if ((rv = apr_file_pipe_create(&attr->child_in, &attr->parent_in, - attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_in); - - if (child_in != NULL && rv == APR_SUCCESS) { - if (attr->child_in && (attr->child_in->filedes != -1)) - rv = apr_file_dup2(attr->child_in, child_in, attr->pool); - else { - attr->child_in = NULL; - if ((rv = apr_file_dup(&attr->child_in, child_in, attr->pool)) - == APR_SUCCESS) - rv = apr_file_inherit_set(attr->child_in); - } - } - - if (parent_in != NULL && rv == APR_SUCCESS) { - rv = apr_file_dup(&attr->parent_in, parent_in, attr->pool); - } - - return rv; -} - - -APR_DECLARE(apr_status_t) apr_procattr_child_out_set(apr_procattr_t *attr, apr_file_t *child_out, - apr_file_t *parent_out) -{ - apr_status_t rv = APR_SUCCESS; - - if (attr->child_out == NULL && attr->parent_out == NULL - && child_out == NULL && parent_out == NULL) - if ((rv = apr_file_pipe_create(&attr->parent_out, &attr->child_out, - attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_out); - - if (child_out != NULL && rv == APR_SUCCESS) { - if (attr->child_out && (attr->child_out->filedes != -1)) - rv = apr_file_dup2(attr->child_out, child_out, attr->pool); - else { - attr->child_out = NULL; - if ((rv = apr_file_dup(&attr->child_out, child_out, attr->pool)) - == APR_SUCCESS) - rv = apr_file_inherit_set(attr->child_out); - } - } - - if (parent_out != NULL && rv == APR_SUCCESS) { - rv = apr_file_dup(&attr->parent_out, parent_out, attr->pool); - } - - return rv; -} - - -APR_DECLARE(apr_status_t) apr_procattr_child_err_set(apr_procattr_t *attr, apr_file_t *child_err, - apr_file_t *parent_err) -{ - apr_status_t rv = APR_SUCCESS; - - if (attr->child_err == NULL && attr->parent_err == NULL - && child_err == NULL && parent_err == NULL) - if ((rv = apr_file_pipe_create(&attr->parent_err, &attr->child_err, - attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_err); - - if (child_err != NULL && rv == APR_SUCCESS) { - if (attr->child_err && (attr->child_err->filedes != -1)) - rv = apr_file_dup2(attr->child_err, child_err, attr->pool); - else { - attr->child_err = NULL; - if ((rv = apr_file_dup(&attr->child_err, child_err, attr->pool)) - == APR_SUCCESS) - rv = apr_file_inherit_set(attr->child_err); - } - } - - if (parent_err != NULL && rv == APR_SUCCESS) { - rv = apr_file_dup(&attr->parent_err, parent_err, attr->pool); - } - - return rv; -} - - -APR_DECLARE(apr_status_t) apr_procattr_dir_set(apr_procattr_t *attr, - const char *dir) -{ - return apr_filepath_merge(&attr->currdir, NULL, dir, - APR_FILEPATH_NATIVE, attr->pool); -} - -APR_DECLARE(apr_status_t) apr_procattr_cmdtype_set(apr_procattr_t *attr, - apr_cmdtype_e cmd) -{ - /* won't ever be called on this platform, so don't save the function pointer */ - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_detach_set(apr_procattr_t *attr, apr_int32_t detach) -{ - attr->detached = detach; - return APR_SUCCESS; -} - -#if APR_HAS_FORK -APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *pool) -{ - int pid; - - if ((pid = fork()) < 0) { - return errno; - } - else if (pid == 0) { - proc->pid = pid; - proc->in = NULL; - proc->out = NULL; - proc->err = NULL; - return APR_INCHILD; - } - proc->pid = pid; - proc->in = NULL; - proc->out = NULL; - proc->err = NULL; - return APR_INPARENT; -} -#endif - -static apr_status_t limit_proc(apr_procattr_t *attr) -{ -#if APR_HAVE_STRUCT_RLIMIT && APR_HAVE_SETRLIMIT -#ifdef RLIMIT_CPU - if (attr->limit_cpu != NULL) { - if ((setrlimit(RLIMIT_CPU, attr->limit_cpu)) != 0) { - return errno; - } - } -#endif -#ifdef RLIMIT_NPROC - if (attr->limit_nproc != NULL) { - if ((setrlimit(RLIMIT_NPROC, attr->limit_nproc)) != 0) { - return errno; - } - } -#endif -#if defined(RLIMIT_AS) - if (attr->limit_mem != NULL) { - if ((setrlimit(RLIMIT_AS, attr->limit_mem)) != 0) { - return errno; - } - } -#elif defined(RLIMIT_DATA) - if (attr->limit_mem != NULL) { - if ((setrlimit(RLIMIT_DATA, attr->limit_mem)) != 0) { - return errno; - } - } -#elif defined(RLIMIT_VMEM) - if (attr->limit_mem != NULL) { - if ((setrlimit(RLIMIT_VMEM, attr->limit_mem)) != 0) { - return errno; - } - } -#endif -#else - /* - * Maybe make a note in error_log that setrlimit isn't supported?? - */ - -#endif - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr, - apr_child_errfn_t *errfn) -{ - /* won't ever be called on this platform, so don't save the function pointer */ - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr, - apr_int32_t chk) -{ - /* won't ever be used on this platform, so don't save the flag */ - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_addrspace_set(apr_procattr_t *attr, - apr_int32_t addrspace) -{ - attr->addrspace = addrspace; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *newproc, - const char *progname, - const char * const *args, - const char * const *env, - apr_procattr_t *attr, - apr_pool_t *pool) -{ - wiring_t wire; - int addr_space; - - wire.infd = attr->child_in - ? (attr->child_in->filedes != -1 ? attr->child_in->filedes - : FD_UNUSED) - : fileno(stdin); - wire.outfd = attr->child_out - ? (attr->child_out->filedes != -1 ? attr->child_out->filedes - : FD_UNUSED) - : fileno(stdout); - wire.errfd = attr->child_err - ? (attr->child_err->filedes != -1 ? attr->child_err->filedes - : FD_UNUSED) - : fileno(stderr); - - newproc->in = attr->parent_in; - newproc->out = attr->parent_out; - newproc->err = attr->parent_err; - - /* attr->detached and PROC_DETACHED do not mean the same thing. attr->detached means - * start the NLM in a separate address space. PROC_DETACHED means don't wait for the - * NLM to unload by calling wait() or waitpid(), just clean up */ - addr_space = PROC_LOAD_SILENT | (attr->addrspace ? 0 : PROC_CURRENT_SPACE); - addr_space |= (attr->detached ? PROC_DETACHED : 0); - - if (attr->currdir) { - char *fullpath = NULL; - apr_status_t rv; - - if ((rv = apr_filepath_merge(&fullpath, attr->currdir, progname, - APR_FILEPATH_NATIVE, pool)) != APR_SUCCESS) { - return rv; - } - progname = fullpath; - } - - if ((newproc->pid = procve(progname, addr_space, (const char**)env, &wire, - NULL, NULL, 0, NULL, (const char **)args)) == -1) { - return errno; - } - - if (attr->child_in && (attr->child_in->filedes != -1)) { - apr_pool_cleanup_kill(apr_file_pool_get(attr->child_in), - attr->child_in, apr_unix_file_cleanup); - apr_file_close(attr->child_in); - } - if (attr->child_out && (attr->child_out->filedes != -1)) { - apr_pool_cleanup_kill(apr_file_pool_get(attr->child_out), - attr->child_out, apr_unix_file_cleanup); - apr_file_close(attr->child_out); - } - if (attr->child_err && (attr->child_err->filedes != -1)) { - apr_pool_cleanup_kill(apr_file_pool_get(attr->child_err), - attr->child_err, apr_unix_file_cleanup); - apr_file_close(attr->child_err); - } - - apr_pool_cleanup_register(pool, (void *)newproc, apr_netware_proc_cleanup, - apr_pool_cleanup_null); - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc, - int *exitcode, - apr_exit_why_e *exitwhy, - apr_wait_how_e waithow, - apr_pool_t *p) -{ - proc->pid = -1; - return apr_proc_wait(proc, exitcode, exitwhy, waithow); -} - -APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, - int *exitcode, apr_exit_why_e *exitwhy, - apr_wait_how_e waithow) -{ - pid_t pstatus; - int waitpid_options = WUNTRACED; - int exit_int; - int ignore; - apr_exit_why_e ignorewhy; - - if (exitcode == NULL) { - exitcode = &ignore; - } - - if (exitwhy == NULL) { - exitwhy = &ignorewhy; - } - - if (waithow != APR_WAIT) { - waitpid_options |= WNOHANG; - } - - /* If the pid is 0 then the process was started detached. There - is no need to wait since there is nothing to wait for on a - detached process. Starting a process as non-detached and - then calling wait or waitpid could cause the thread to hang. - The reason for this is because NetWare does not have a way - to kill or even signal a process to be killed. Starting - all processes as detached avoids the possibility of a - thread hanging. */ - if (proc->pid == 0) { - *exitwhy = APR_PROC_EXIT; - *exitcode = 0; - return APR_CHILD_DONE; - } - - if ((pstatus = waitpid(proc->pid, &exit_int, waitpid_options)) > 0) { - proc->pid = pstatus; - - if (WIFEXITED(exit_int)) { - *exitwhy = APR_PROC_EXIT; - *exitcode = WEXITSTATUS(exit_int); - } - else if (WIFSIGNALED(exit_int)) { - *exitwhy = APR_PROC_SIGNAL; - *exitcode = WIFTERMSIG(exit_int); - } - else { - /* unexpected condition */ - return APR_EGENERAL; - } - - return APR_CHILD_DONE; - } - else if (pstatus == 0) { - return APR_CHILD_NOTDONE; - } - - return errno; -} - -#if APR_HAVE_STRUCT_RLIMIT -APR_DECLARE(apr_status_t) apr_procattr_limit_set(apr_procattr_t *attr, - apr_int32_t what, - struct rlimit *limit) -{ - switch(what) { - case APR_LIMIT_CPU: -#ifdef RLIMIT_CPU - attr->limit_cpu = limit; - break; -#else - return APR_ENOTIMPL; -#endif - - case APR_LIMIT_MEM: -#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS) - attr->limit_mem = limit; - break; -#else - return APR_ENOTIMPL; -#endif - - case APR_LIMIT_NPROC: -#ifdef RLIMIT_NPROC - attr->limit_nproc = limit; - break; -#else - return APR_ENOTIMPL; -#endif - - case APR_LIMIT_NOFILE: -#ifdef RLIMIT_NOFILE - attr->limit_nofile = limit; - break; -#else - return APR_ENOTIMPL; -#endif - - } - return APR_SUCCESS; -} -#endif /* APR_HAVE_STRUCT_RLIMIT */ - -APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr, - const char *username, - const char *password) -{ - /* Always return SUCCESS because NetWare threads don't run as a user */ - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_group_set(apr_procattr_t *attr, - const char *groupname) -{ - /* Always return SUCCESS because NetWare threads don't run within a group */ - return APR_SUCCESS; -} diff --git a/libs/apr/threadproc/netware/procsup.c b/libs/apr/threadproc/netware/procsup.c deleted file mode 100644 index 72fa1d97..00000000 --- a/libs/apr/threadproc/netware/procsup.c +++ /dev/null @@ -1,102 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_threadproc.h" - -apr_status_t apr_proc_detach(int daemonize) -{ -#if 0 - int x; - pid_t pgrp; - - chdir("/"); -#if !defined(MPE) && !defined(OS2) && !defined(TPF) && !defined(BEOS) -/* Don't detach for MPE because child processes can't survive the death of - the parent. */ - if ((x = fork()) > 0) - exit(0); - else if (x == -1) { - perror("fork"); - fprintf(stderr, "unable to fork new process\n"); - exit(1); /* we can't do anything here, so just exit. */ - } -/* RAISE_SIGSTOP(DETACH);*/ -#endif -#if APR_HAVE_SETSID - if ((pgrp = setsid()) == -1) { - return errno; - } -#elif defined(NEXT) || defined(NEWSOS) - if (setpgrp(0, getpid()) == -1 || (pgrp = getpgrp(0)) == -1) { - return errno; - } -#elif defined(OS2) || defined(TPF) - /* OS/2 don't support process group IDs */ - pgrp = getpid(); -#elif defined(MPE) - /* MPE uses negative pid for process group */ - pgrp = -getpid(); -#else - if ((pgrp = setpgid(0, 0)) == -1) { - return errno; - } -#endif - - /* close out the standard file descriptors */ - if (freopen("/dev/null", "r", stdin) == NULL) { - return errno; - /* continue anyhow -- note we can't close out descriptor 0 because we - * have nothing to replace it with, and if we didn't have a descriptor - * 0 the next file would be created with that value ... leading to - * havoc. - */ - } - if (freopen("/dev/null", "w", stdout) == NULL) { - return errno; - } - /* We are going to reopen this again in a little while to the error - * log file, but better to do it twice and suffer a small performance - * hit for consistancy than not reopen it here. - */ - if (freopen("/dev/null", "w", stderr) == NULL) { - return errno; - } -#endif - return APR_SUCCESS; -} - -#if 0 -#if (!HAVE_WAITPID) -/* From ikluft@amdahl.com - * this is not ideal but it works for SVR3 variants - * Modified by dwd@bell-labs.com to call wait3 instead of wait because - * apache started to use the WNOHANG option. - */ -int waitpid(pid_t pid, int *statusp, int options) -{ - int tmp_pid; - if (kill(pid, 0) == -1) { - errno = ECHILD; - return -1; - } - while (((tmp_pid = wait3(statusp, options, 0)) != pid) && - (tmp_pid != -1) && (tmp_pid != 0) && (pid != -1)) - ; - return tmp_pid; -} -#endif -#endif - diff --git a/libs/apr/threadproc/netware/signals.c b/libs/apr/threadproc/netware/signals.c deleted file mode 100644 index c744da5c..00000000 --- a/libs/apr/threadproc/netware/signals.c +++ /dev/null @@ -1,81 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_threadproc.h" -#include "apr_private.h" -#include "apr_pools.h" -#include "apr_signal.h" -#include "apr_strings.h" - -#include -#if APR_HAS_THREADS && APR_HAVE_PTHREAD_H -#include -#endif - -APR_DECLARE(apr_status_t) apr_proc_kill(apr_proc_t *proc, int signum) -{ - return APR_ENOTIMPL; -} - - -void apr_signal_init(apr_pool_t *pglobal) -{ -} - -const char *apr_signal_description_get(int signum) -{ - switch (signum) - { - case SIGABRT: - return "Abort"; - case SIGFPE: - return "Arithmetic exception"; - case SIGILL: - return "Illegal instruction"; - case SIGINT: - return "Interrupt"; - case SIGSEGV: - return "Segmentation fault"; - case SIGTERM: - return "Terminated"; - case SIGPOLL: - return "Pollable event occurred"; - default: - return "unknown signal (not supported)"; - } -} - -static void *signal_thread_func(void *signal_handler) -{ - return NULL; -} - -#if (APR_HAVE_SIGWAIT || APR_HAVE_SIGSUSPEND) -APR_DECLARE(apr_status_t) apr_setup_signal_thread(void) -{ - return 0; -} -#endif /* (APR_HAVE_SIGWAIT || APR_HAVE_SIGSUSPEND) */ - -APR_DECLARE(apr_status_t) apr_signal_block(int signum) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_signal_unblock(int signum) -{ - return APR_ENOTIMPL; -} diff --git a/libs/apr/threadproc/netware/thread.c b/libs/apr/threadproc/netware/thread.c deleted file mode 100644 index e1a46e6e..00000000 --- a/libs/apr/threadproc/netware/thread.c +++ /dev/null @@ -1,254 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_portable.h" -#include "apr_strings.h" -#include "apr_arch_threadproc.h" - -static int thread_count = 0; - -apr_status_t apr_threadattr_create(apr_threadattr_t **new, - apr_pool_t *pool) -{ - (*new) = (apr_threadattr_t *)apr_palloc(pool, - sizeof(apr_threadattr_t)); - - if ((*new) == NULL) { - return APR_ENOMEM; - } - - (*new)->pool = pool; - (*new)->stack_size = APR_DEFAULT_STACK_SIZE; - (*new)->detach = 0; - (*new)->thread_name = NULL; - return APR_SUCCESS; -} - -apr_status_t apr_threadattr_detach_set(apr_threadattr_t *attr,apr_int32_t on) -{ - attr->detach = on; - return APR_SUCCESS; -} - -apr_status_t apr_threadattr_detach_get(apr_threadattr_t *attr) -{ - if (attr->detach == 1) - return APR_DETACH; - return APR_NOTDETACH; -} - -APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, - apr_size_t stacksize) -{ - attr->stack_size = stacksize; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr, - apr_size_t size) -{ - return APR_ENOTIMPL; -} - -static void *dummy_worker(void *opaque) -{ - apr_thread_t *thd = (apr_thread_t *)opaque; - return thd->func(thd, thd->data); -} - -apr_status_t apr_thread_create(apr_thread_t **new, - apr_threadattr_t *attr, - apr_thread_start_t func, - void *data, - apr_pool_t *pool) -{ - apr_status_t stat; - long flags = NX_THR_BIND_CONTEXT; - char threadName[NX_MAX_OBJECT_NAME_LEN+1]; - size_t stack_size = APR_DEFAULT_STACK_SIZE; - - if (attr && attr->thread_name) { - strncpy (threadName, attr->thread_name, NX_MAX_OBJECT_NAME_LEN); - } - else { - sprintf(threadName, "APR_thread %04ld", ++thread_count); - } - - /* An original stack size of 0 will allow NXCreateThread() to - * assign a default system stack size. An original stack - * size of less than 0 will assign the APR default stack size. - * anything else will be taken as is. - */ - if (attr && (attr->stack_size >= 0)) { - stack_size = attr->stack_size; - } - - (*new) = (apr_thread_t *)apr_palloc(pool, sizeof(apr_thread_t)); - - if ((*new) == NULL) { - return APR_ENOMEM; - } - - (*new)->data = data; - (*new)->func = func; - (*new)->thread_name = (char*)apr_pstrdup(pool, threadName); - - stat = apr_pool_create(&(*new)->pool, pool); - if (stat != APR_SUCCESS) { - return stat; - } - - if (attr && attr->detach) { - flags |= NX_THR_DETACHED; - } - - (*new)->ctx = NXContextAlloc( - /* void(*start_routine)(void *arg) */ (void (*)(void *)) dummy_worker, - /* void *arg */ (*new), - /* int priority */ NX_PRIO_MED, - /* NXSize_t stackSize */ stack_size, - /* long flags */ NX_CTX_NORMAL, - /* int *error */ &stat); - - stat = NXContextSetName( - /* NXContext_t ctx */ (*new)->ctx, - /* const char *name */ threadName); - - stat = NXThreadCreate( - /* NXContext_t context */ (*new)->ctx, - /* long flags */ flags, - /* NXThreadId_t *thread_id */ &(*new)->td); - - if (stat == 0) - return APR_SUCCESS; - - return(stat); /* if error */ -} - -apr_os_thread_t apr_os_thread_current() -{ - return NXThreadGetId(); -} - -int apr_os_thread_equal(apr_os_thread_t tid1, apr_os_thread_t tid2) -{ - return (tid1 == tid2); -} - -void apr_thread_yield() -{ - NXThreadYield(); -} - -apr_status_t apr_thread_exit(apr_thread_t *thd, - apr_status_t retval) -{ - thd->exitval = retval; - apr_pool_destroy(thd->pool); - NXThreadExit(NULL); - return APR_SUCCESS; -} - -apr_status_t apr_thread_join(apr_status_t *retval, - apr_thread_t *thd) -{ - apr_status_t stat; - NXThreadId_t dthr; - - if ((stat = NXThreadJoin(thd->td, &dthr, NULL)) == 0) { - *retval = thd->exitval; - return APR_SUCCESS; - } - else { - return stat; - } -} - -apr_status_t apr_thread_detach(apr_thread_t *thd) -{ - return APR_SUCCESS; -} - -apr_status_t apr_thread_data_get(void **data, const char *key, - apr_thread_t *thread) -{ - if (thread != NULL) { - return apr_pool_userdata_get(data, key, thread->pool); - } - else { - data = NULL; - return APR_ENOTHREAD; - } -} - -apr_status_t apr_thread_data_set(void *data, const char *key, - apr_status_t (*cleanup) (void *), - apr_thread_t *thread) -{ - if (thread != NULL) { - return apr_pool_userdata_set(data, key, cleanup, thread->pool); - } - else { - data = NULL; - return APR_ENOTHREAD; - } -} - -APR_DECLARE(apr_status_t) apr_os_thread_get(apr_os_thread_t **thethd, - apr_thread_t *thd) -{ - if (thd == NULL) { - return APR_ENOTHREAD; - } - *thethd = &(thd->td); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_thread_put(apr_thread_t **thd, - apr_os_thread_t *thethd, - apr_pool_t *pool) -{ - if (pool == NULL) { - return APR_ENOPOOL; - } - if ((*thd) == NULL) { - (*thd) = (apr_thread_t *)apr_palloc(pool, sizeof(apr_thread_t)); - (*thd)->pool = pool; - } - (*thd)->td = *thethd; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_once_init(apr_thread_once_t **control, - apr_pool_t *p) -{ - (*control) = apr_pcalloc(p, sizeof(**control)); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_once(apr_thread_once_t *control, - void (*func)(void)) -{ - if (!atomic_xchg(&control->value, 1)) { - func(); - } - return APR_SUCCESS; -} - -APR_POOL_IMPLEMENT_ACCESSOR(thread) - - diff --git a/libs/apr/threadproc/netware/threadpriv.c b/libs/apr/threadproc/netware/threadpriv.c deleted file mode 100644 index 54680a56..00000000 --- a/libs/apr/threadproc/netware/threadpriv.c +++ /dev/null @@ -1,102 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_portable.h" -#include "apr_arch_threadproc.h" - -apr_status_t apr_threadkey_private_create(apr_threadkey_t **key, - void (*dest)(void *), apr_pool_t *pool) -{ - apr_status_t stat; - - (*key) = (apr_threadkey_t *)apr_palloc(pool, sizeof(apr_threadkey_t)); - if ((*key) == NULL) { - return APR_ENOMEM; - } - - (*key)->pool = pool; - - if ((stat = NXKeyCreate(NULL, dest, &(*key)->key)) == 0) { - return stat; - } - return stat; -} - -apr_status_t apr_threadkey_private_get(void **new, apr_threadkey_t *key) -{ - apr_status_t stat; - - if ((stat = NXKeyGetValue(key->key, new)) == 0) { - return APR_SUCCESS; - } - else { - return stat; - } -} - -apr_status_t apr_threadkey_private_set(void *priv, apr_threadkey_t *key) -{ - apr_status_t stat; - if ((stat = NXKeySetValue(key->key, priv)) == 0) { - return APR_SUCCESS; - } - else { - return stat; - } -} - -apr_status_t apr_threadkey_private_delete(apr_threadkey_t *key) -{ - apr_status_t stat; - if ((stat = NXKeyDelete(key->key)) == 0) { - return APR_SUCCESS; - } - return stat; -} - -apr_status_t apr_threadkey_data_get(void **data, const char *key, apr_threadkey_t *threadkey) -{ - return apr_pool_userdata_get(data, key, threadkey->pool); -} - -apr_status_t apr_threadkey_data_set(void *data, - const char *key, apr_status_t (*cleanup) (void *), - apr_threadkey_t *threadkey) -{ - return apr_pool_userdata_set(data, key, cleanup, threadkey->pool); -} - -apr_status_t apr_os_threadkey_get(apr_os_threadkey_t *thekey, - apr_threadkey_t *key) -{ - thekey = &(key->key); - return APR_SUCCESS; -} - -apr_status_t apr_os_threadkey_put(apr_threadkey_t **key, - apr_os_threadkey_t *thekey, apr_pool_t *pool) -{ - if (pool == NULL) { - return APR_ENOPOOL; - } - if ((*key) == NULL) { - (*key) = (apr_threadkey_t *)apr_palloc(pool, sizeof(apr_threadkey_t)); - (*key)->pool = pool; - } - (*key)->key = *thekey; - return APR_SUCCESS; -} - diff --git a/libs/apr/threadproc/os2/proc.c b/libs/apr/threadproc/os2/proc.c deleted file mode 100644 index bae2785f..00000000 --- a/libs/apr/threadproc/os2/proc.c +++ /dev/null @@ -1,664 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define INCL_DOS -#define INCL_DOSERRORS - -#include "apr_arch_threadproc.h" -#include "apr_arch_file_io.h" -#include "apr_private.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_portable.h" -#include "apr_strings.h" -#include "apr_signal.h" -#include -#include -#include -#include -#include -#include - -/* Heavy on no'ops, here's what we want to pass if there is APR_NO_FILE - * requested for a specific child handle; - */ -static apr_file_t no_file = { NULL, -1, }; - -APR_DECLARE(apr_status_t) apr_procattr_create(apr_procattr_t **new, apr_pool_t *pool) -{ - (*new) = (apr_procattr_t *)apr_palloc(pool, - sizeof(apr_procattr_t)); - - if ((*new) == NULL) { - return APR_ENOMEM; - } - (*new)->pool = pool; - (*new)->parent_in = NULL; - (*new)->child_in = NULL; - (*new)->parent_out = NULL; - (*new)->child_out = NULL; - (*new)->parent_err = NULL; - (*new)->child_err = NULL; - (*new)->currdir = NULL; - (*new)->cmdtype = APR_PROGRAM; - (*new)->detached = FALSE; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, - apr_int32_t in, - apr_int32_t out, - apr_int32_t err) -{ - apr_status_t rv; - - if ((in != APR_NO_PIPE) && (in != APR_NO_FILE)) { - /* APR_CHILD_BLOCK maps to APR_WRITE_BLOCK, while - * APR_PARENT_BLOCK maps to APR_READ_BLOCK, so transpose - * the CHILD/PARENT blocking flags for the stdin pipe. - * stdout/stderr map to the correct mode by default. - */ - if (in == APR_CHILD_BLOCK) - in = APR_READ_BLOCK; - else if (in == APR_PARENT_BLOCK) - in = APR_WRITE_BLOCK; - - if ((rv = apr_file_pipe_create_ex(&attr->child_in, &attr->parent_in, - in, attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_in); - if (rv != APR_SUCCESS) - return rv; - } - else if (in == APR_NO_FILE) - attr->child_in = &no_file; - - if ((out != APR_NO_PIPE) && (out != APR_NO_FILE)) { - if ((rv = apr_file_pipe_create_ex(&attr->parent_out, &attr->child_out, - out, attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_out); - if (rv != APR_SUCCESS) - return rv; - } - else if (out == APR_NO_FILE) - attr->child_out = &no_file; - - if ((err != APR_NO_PIPE) && (err != APR_NO_FILE)) { - if ((rv = apr_file_pipe_create_ex(&attr->parent_err, &attr->child_err, - err, attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_err); - if (rv != APR_SUCCESS) - return rv; - } - else if (err == APR_NO_FILE) - attr->child_err = &no_file; - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_child_in_set(apr_procattr_t *attr, apr_file_t *child_in, - apr_file_t *parent_in) -{ - apr_status_t rv; - - if (attr->child_in == NULL && attr->parent_in == NULL - && child_in == NULL && parent_in == NULL) - if ((rv = apr_file_pipe_create(&attr->child_in, &attr->parent_in, - attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_in); - - if (child_in != NULL && rv == APR_SUCCESS) { - if (attr->child_in && (attr->child_in->filedes != -1)) - rv = apr_file_dup2(attr->child_in, child_in, attr->pool); - else { - attr->child_in = NULL; - if ((rv = apr_file_dup(&attr->child_in, child_in, attr->pool)) - == APR_SUCCESS) - rv = apr_file_inherit_set(attr->child_in); - } - } - - if (parent_in != NULL && rv == APR_SUCCESS) { - rv = apr_file_dup(&attr->parent_in, parent_in, attr->pool); - } - - return rv; -} - -APR_DECLARE(apr_status_t) apr_procattr_child_out_set(apr_procattr_t *attr, apr_file_t *child_out, - apr_file_t *parent_out) -{ - apr_status_t rv; - - if (attr->child_out == NULL && attr->parent_out == NULL - && child_out == NULL && parent_out == NULL) - if ((rv = apr_file_pipe_create(&attr->parent_out, &attr->child_out, - attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_out); - - if (child_out != NULL && rv == APR_SUCCESS) { - if (attr->child_out && (attr->child_out->filedes != -1)) - rv = apr_file_dup2(attr->child_out, child_out, attr->pool); - else { - attr->child_out = NULL; - if ((rv = apr_file_dup(&attr->child_out, child_out, attr->pool)) - == APR_SUCCESS) - rv = apr_file_inherit_set(attr->child_out); - } - } - - if (parent_out != NULL && rv == APR_SUCCESS) { - rv = apr_file_dup(&attr->parent_out, parent_out, attr->pool); - } - - return rv; -} - -APR_DECLARE(apr_status_t) apr_procattr_child_err_set(apr_procattr_t *attr, apr_file_t *child_err, - apr_file_t *parent_err) -{ - apr_status_t rv; - - if (attr->child_err == NULL && attr->parent_err == NULL - && child_err == NULL && parent_err == NULL) - if ((rv = apr_file_pipe_create(&attr->parent_err, &attr->child_err, - attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_err); - - if (child_err != NULL && rv == APR_SUCCESS) { - if (attr->child_err && (attr->child_err->filedes != -1)) - rv = apr_file_dup2(attr->child_err, child_err, attr->pool); - else { - attr->child_err = NULL; - if ((rv = apr_file_dup(&attr->child_err, child_err, attr->pool)) - == APR_SUCCESS) - rv = apr_file_inherit_set(attr->child_err); - } - } - - if (parent_err != NULL && rv == APR_SUCCESS) { - rv = apr_file_dup(&attr->parent_err, parent_err, attr->pool); - } - - return rv; -} - -APR_DECLARE(apr_status_t) apr_procattr_dir_set(apr_procattr_t *attr, const char *dir) -{ - attr->currdir = apr_pstrdup(attr->pool, dir); - if (attr->currdir) { - return APR_SUCCESS; - } - return APR_ENOMEM; -} - -APR_DECLARE(apr_status_t) apr_procattr_cmdtype_set(apr_procattr_t *attr, - apr_cmdtype_e cmd) -{ - attr->cmdtype = cmd; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_detach_set(apr_procattr_t *attr, apr_int32_t detach) -{ - attr->detached = detach; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *pool) -{ - int pid; - - if ((pid = fork()) < 0) { - return errno; - } - else if (pid == 0) { - proc->pid = pid; - proc->in = NULL; - proc->out = NULL; - proc->err = NULL; - return APR_INCHILD; - } - proc->pid = pid; - proc->in = NULL; - proc->out = NULL; - proc->err = NULL; - return APR_INPARENT; -} - - - -/* quotes in the string are doubled up. - * Used to escape quotes in args passed to OS/2's cmd.exe - */ -static char *double_quotes(apr_pool_t *pool, const char *str) -{ - int num_quotes = 0; - int len = 0; - char *quote_doubled_str, *dest; - - while (str[len]) { - num_quotes += str[len++] == '\"'; - } - - quote_doubled_str = apr_palloc(pool, len + num_quotes + 1); - dest = quote_doubled_str; - - while (*str) { - if (*str == '\"') - *(dest++) = '\"'; - *(dest++) = *(str++); - } - - *dest = 0; - return quote_doubled_str; -} - - - -APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr, - apr_child_errfn_t *errfn) -{ - /* won't ever be called on this platform, so don't save the function pointer */ - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr, - apr_int32_t chk) -{ - /* won't ever be used on this platform, so don't save the flag */ - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_addrspace_set(apr_procattr_t *attr, - apr_int32_t addrspace) -{ - /* won't ever be used on this platform, so don't save the flag */ - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *proc, const char *progname, - const char * const *args, - const char * const *env, - apr_procattr_t *attr, apr_pool_t *pool) -{ - int i, arg, numargs, cmdlen; - apr_status_t status; - const char **newargs; - char savedir[300]; - HFILE save_in, save_out, save_err, dup; - int criticalsection = FALSE; - char *extension, *newprogname, *extra_arg = NULL, *cmdline, *cmdline_pos; - char interpreter[1024]; - char error_object[260]; - apr_file_t *progfile; - int env_len, e; - char *env_block, *env_block_pos; - RESULTCODES rescodes; - - proc->in = attr->parent_in; - proc->err = attr->parent_err; - proc->out = attr->parent_out; - - /* Prevent other threads from running while these process-wide resources are modified */ - if (attr->child_in || attr->child_out || attr->child_err || attr->currdir) { - criticalsection = TRUE; - DosEnterCritSec(); - } - - if (attr->child_in) { - save_in = -1; - DosDupHandle(STDIN_FILENO, &save_in); - dup = STDIN_FILENO; - if (attr->child_in->filedes == -1) - DosClose(dup); - else - DosDupHandle(attr->child_in->filedes, &dup); - } - - if (attr->child_out) { - save_out = -1; - DosDupHandle(STDOUT_FILENO, &save_out); - dup = STDOUT_FILENO; - if (attr->child_out->filedes == -1) - DosClose(dup); - else - DosDupHandle(attr->child_out->filedes, &dup); - } - - if (attr->child_err) { - save_err = -1; - DosDupHandle(STDERR_FILENO, &save_err); - dup = STDERR_FILENO; - if (attr->child_err->filedes == -1) - DosClose(dup); - else - DosDupHandle(attr->child_err->filedes, &dup); - } - - apr_signal(SIGCHLD, SIG_DFL); /*not sure if this is needed or not */ - - if (attr->currdir != NULL) { - _getcwd2(savedir, sizeof(savedir)); - - if (_chdir2(attr->currdir) < 0) { - if (criticalsection) - DosExitCritSec(); - return errno; - } - } - - interpreter[0] = 0; - extension = strrchr(progname, '.'); - - if (extension == NULL || strchr(extension, '/') || strchr(extension, '\\')) - extension = ""; - - /* ### how to handle APR_PROGRAM_ENV and APR_PROGRAM_PATH? */ - - if (attr->cmdtype == APR_SHELLCMD || - attr->cmdtype == APR_SHELLCMD_ENV || - strcasecmp(extension, ".cmd") == 0) { - strcpy(interpreter, "#!" SHELL_PATH); - extra_arg = "/C"; - } else if (stricmp(extension, ".exe") != 0) { - status = apr_file_open(&progfile, progname, APR_READ|APR_BUFFERED, 0, pool); - - if (status != APR_SUCCESS && APR_STATUS_IS_ENOENT(status)) { - progname = apr_pstrcat(pool, progname, ".exe", NULL); - } - - if (status == APR_SUCCESS) { - status = apr_file_gets(interpreter, sizeof(interpreter), progfile); - - if (status == APR_SUCCESS) { - if (interpreter[0] == '#' && interpreter[1] == '!') { - /* delete CR/LF & any other whitespace off the end */ - int end = strlen(interpreter) - 1; - - while (end >= 0 && apr_isspace(interpreter[end])) { - interpreter[end] = '\0'; - end--; - } - - if (interpreter[2] != '/' && interpreter[2] != '\\' && interpreter[3] != ':') { - char buffer[300]; - - if (DosSearchPath(SEARCH_ENVIRONMENT, "PATH", interpreter+2, buffer, sizeof(buffer)) == 0) { - strcpy(interpreter+2, buffer); - } else { - strcat(interpreter, ".exe"); - if (DosSearchPath(SEARCH_ENVIRONMENT, "PATH", interpreter+2, buffer, sizeof(buffer)) == 0) { - strcpy(interpreter+2, buffer); - } - } - } - } else { - interpreter[0] = 0; - } - } - - apr_file_close(progfile); - } - } - - i = 0; - - while (args && args[i]) { - i++; - } - - newargs = (const char **)apr_palloc(pool, sizeof (char *) * (i + 4)); - numargs = 0; - - if (interpreter[0]) - newargs[numargs++] = interpreter + 2; - if (extra_arg) - newargs[numargs++] = "/c"; - - newargs[numargs++] = newprogname = apr_pstrdup(pool, progname); - arg = 1; - - while (args && args[arg]) { - newargs[numargs++] = args[arg++]; - } - - newargs[numargs] = NULL; - - for (i=0; newprogname[i]; i++) - if (newprogname[i] == '/') - newprogname[i] = '\\'; - - cmdlen = 0; - - for (i=0; i\" ")) - a = apr_pstrcat(pool, "\"", double_quotes(pool, a), "\"", NULL); - - if (i) - *(cmdline_pos++) = ' '; - - strcpy(cmdline_pos, a); - cmdline_pos += strlen(cmdline_pos); - } - - *(++cmdline_pos) = 0; /* Add required second terminator */ - cmdline_pos = strchr(cmdline, ' '); - - if (cmdline_pos) { - *cmdline_pos = 0; - cmdline_pos++; - } - - /* Create environment block from list of envariables */ - if (env) { - for (env_len=1, e=0; env[e]; e++) - env_len += strlen(env[e]) + 1; - - env_block = apr_palloc(pool, env_len); - env_block_pos = env_block; - - for (e=0; env[e]; e++) { - strcpy(env_block_pos, env[e]); - env_block_pos += strlen(env_block_pos) + 1; - } - - *env_block_pos = 0; /* environment block is terminated by a double null */ - } else - env_block = NULL; - - status = DosExecPgm(error_object, sizeof(error_object), - attr->detached ? EXEC_BACKGROUND : EXEC_ASYNCRESULT, - cmdline, env_block, &rescodes, cmdline); - - proc->pid = rescodes.codeTerminate; - - if (attr->currdir != NULL) { - chdir(savedir); - } - - if (attr->child_in) { - if (attr->child_in->filedes != -1) { - apr_file_close(attr->child_in); - } - - dup = STDIN_FILENO; - DosDupHandle(save_in, &dup); - DosClose(save_in); - } - - if (attr->child_out) { - if (attr->child_out->filedes != -1) { - apr_file_close(attr->child_out); - } - - dup = STDOUT_FILENO; - DosDupHandle(save_out, &dup); - DosClose(save_out); - } - - if (attr->child_err) { - if (attr->child_err->filedes != -1) { - apr_file_close(attr->child_err); - } - - dup = STDERR_FILENO; - DosDupHandle(save_err, &dup); - DosClose(save_err); - } - - if (criticalsection) - DosExitCritSec(); - - return status; -} - - - -static void proces_result_codes(RESULTCODES codes, - int *exitcode, - apr_exit_why_e *exitwhy) -{ - int result = 0; - apr_exit_why_e why = APR_PROC_EXIT; - - switch (codes.codeTerminate) { - case TC_EXIT: /* Normal exit */ - why = APR_PROC_EXIT; - result = codes.codeResult; - break; - - case TC_HARDERROR: /* Hard error halt */ - why = APR_PROC_SIGNAL; - result = SIGSYS; - break; - - case TC_KILLPROCESS: /* Was killed by a DosKillProcess() */ - why = APR_PROC_SIGNAL; - result = SIGKILL; - break; - - case TC_TRAP: /* TRAP in 16 bit code */ - case TC_EXCEPTION: /* Threw an exception (32 bit code) */ - why = APR_PROC_SIGNAL; - - switch (codes.codeResult | XCPT_FATAL_EXCEPTION) { - case XCPT_ACCESS_VIOLATION: - result = SIGSEGV; - break; - - case XCPT_ILLEGAL_INSTRUCTION: - result = SIGILL; - break; - - case XCPT_FLOAT_DIVIDE_BY_ZERO: - case XCPT_INTEGER_DIVIDE_BY_ZERO: - result = SIGFPE; - break; - - default: - result = codes.codeResult; - break; - } - } - - if (exitcode) { - *exitcode = result; - } - - if (exitwhy) { - *exitwhy = why; - } -} - - - -APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc, - int *exitcode, - apr_exit_why_e *exitwhy, - apr_wait_how_e waithow, - apr_pool_t *p) -{ - RESULTCODES codes; - ULONG rc; - PID pid; - - rc = DosWaitChild(DCWA_PROCESSTREE, waithow == APR_WAIT ? DCWW_WAIT : DCWW_NOWAIT, &codes, &pid, 0); - - if (rc == 0) { - proc->pid = pid; - proces_result_codes(codes, exitcode, exitwhy); - return APR_CHILD_DONE; - } else if (rc == ERROR_CHILD_NOT_COMPLETE) { - return APR_CHILD_NOTDONE; - } - - return APR_OS2_STATUS(rc); -} - - - -APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, - int *exitcode, apr_exit_why_e *exitwhy, - apr_wait_how_e waithow) -{ - RESULTCODES codes; - ULONG rc; - PID pid; - rc = DosWaitChild(DCWA_PROCESS, waithow == APR_WAIT ? DCWW_WAIT : DCWW_NOWAIT, &codes, &pid, proc->pid); - - if (rc == 0) { - proces_result_codes(codes, exitcode, exitwhy); - return APR_CHILD_DONE; - } else if (rc == ERROR_CHILD_NOT_COMPLETE) { - return APR_CHILD_NOTDONE; - } - - return APR_OS2_STATUS(rc); -} - - - -APR_DECLARE(apr_status_t) apr_proc_detach(int daemonize) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr, - const char *username, - const char *password) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_procattr_group_set(apr_procattr_t *attr, - const char *groupname) -{ - return APR_ENOTIMPL; -} diff --git a/libs/apr/threadproc/os2/signals.c b/libs/apr/threadproc/os2/signals.c deleted file mode 100644 index e1727125..00000000 --- a/libs/apr/threadproc/os2/signals.c +++ /dev/null @@ -1 +0,0 @@ -#include "../unix/signals.c" diff --git a/libs/apr/threadproc/os2/thread.c b/libs/apr/threadproc/os2/thread.c deleted file mode 100644 index 00ec4eb5..00000000 --- a/libs/apr/threadproc/os2/thread.c +++ /dev/null @@ -1,260 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define INCL_DOSERRORS -#define INCL_DOS -#include "apr_arch_threadproc.h" -#include "apr_thread_proc.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_portable.h" -#include "apr_arch_file_io.h" -#include - -APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new, apr_pool_t *pool) -{ - (*new) = (apr_threadattr_t *)apr_palloc(pool, sizeof(apr_threadattr_t)); - - if ((*new) == NULL) { - return APR_ENOMEM; - } - - (*new)->pool = pool; - (*new)->attr = 0; - (*new)->stacksize = 0; - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_threadattr_detach_set(apr_threadattr_t *attr, apr_int32_t on) -{ - attr->attr |= APR_THREADATTR_DETACHED; - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr) -{ - return (attr->attr & APR_THREADATTR_DETACHED) ? APR_DETACH : APR_NOTDETACH; -} - -APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, - apr_size_t stacksize) -{ - attr->stacksize = stacksize; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr, - apr_size_t size) -{ - return APR_ENOTIMPL; -} - -static void apr_thread_begin(void *arg) -{ - apr_thread_t *thread = (apr_thread_t *)arg; - thread->exitval = thread->func(thread, thread->data); -} - - - -APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, apr_threadattr_t *attr, - apr_thread_start_t func, void *data, - apr_pool_t *pool) -{ - apr_status_t stat; - apr_thread_t *thread; - - thread = (apr_thread_t *)apr_palloc(pool, sizeof(apr_thread_t)); - *new = thread; - - if (thread == NULL) { - return APR_ENOMEM; - } - - thread->attr = attr; - thread->func = func; - thread->data = data; - stat = apr_pool_create(&thread->pool, pool); - - if (stat != APR_SUCCESS) { - return stat; - } - - if (attr == NULL) { - stat = apr_threadattr_create(&thread->attr, thread->pool); - - if (stat != APR_SUCCESS) { - return stat; - } - } - - thread->tid = _beginthread(apr_thread_begin, NULL, - thread->attr->stacksize > 0 ? - thread->attr->stacksize : APR_THREAD_STACKSIZE, - thread); - - if (thread->tid < 0) { - return errno; - } - - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_os_thread_t) apr_os_thread_current() -{ - PIB *ppib; - TIB *ptib; - DosGetInfoBlocks(&ptib, &ppib); - return ptib->tib_ptib2->tib2_ultid; -} - - - -APR_DECLARE(apr_status_t) apr_thread_exit(apr_thread_t *thd, apr_status_t retval) -{ - thd->exitval = retval; - _endthread(); - return -1; /* If we get here something's wrong */ -} - - - -APR_DECLARE(apr_status_t) apr_thread_join(apr_status_t *retval, apr_thread_t *thd) -{ - ULONG rc; - TID waittid = thd->tid; - - if (thd->attr->attr & APR_THREADATTR_DETACHED) - return APR_EINVAL; - - rc = DosWaitThread(&waittid, DCWW_WAIT); - - if (rc == ERROR_INVALID_THREADID) - rc = 0; /* Thread had already terminated */ - - *retval = thd->exitval; - return APR_OS2_STATUS(rc); -} - - - -APR_DECLARE(apr_status_t) apr_thread_detach(apr_thread_t *thd) -{ - thd->attr->attr |= APR_THREADATTR_DETACHED; - return APR_SUCCESS; -} - - - -void apr_thread_yield() -{ - DosSleep(0); -} - - - -APR_DECLARE(apr_status_t) apr_os_thread_get(apr_os_thread_t **thethd, apr_thread_t *thd) -{ - *thethd = &thd->tid; - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_os_thread_put(apr_thread_t **thd, apr_os_thread_t *thethd, - apr_pool_t *pool) -{ - if ((*thd) == NULL) { - (*thd) = (apr_thread_t *)apr_pcalloc(pool, sizeof(apr_thread_t)); - (*thd)->pool = pool; - } - (*thd)->tid = *thethd; - return APR_SUCCESS; -} - - - -int apr_os_thread_equal(apr_os_thread_t tid1, apr_os_thread_t tid2) -{ - return tid1 == tid2; -} - - - -APR_DECLARE(apr_status_t) apr_thread_data_get(void **data, const char *key, apr_thread_t *thread) -{ - return apr_pool_userdata_get(data, key, thread->pool); -} - - - -APR_DECLARE(apr_status_t) apr_thread_data_set(void *data, const char *key, - apr_status_t (*cleanup) (void *), - apr_thread_t *thread) -{ - return apr_pool_userdata_set(data, key, cleanup, thread->pool); -} - -APR_POOL_IMPLEMENT_ACCESSOR(thread) - - - -static apr_status_t thread_once_cleanup(void *vcontrol) -{ - apr_thread_once_t *control = (apr_thread_once_t *)vcontrol; - - if (control->sem) { - DosCloseEventSem(control->sem); - } - - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_thread_once_init(apr_thread_once_t **control, - apr_pool_t *p) -{ - ULONG rc; - *control = (apr_thread_once_t *)apr_pcalloc(p, sizeof(apr_thread_once_t)); - rc = DosCreateEventSem(NULL, &(*control)->sem, 0, TRUE); - apr_pool_cleanup_register(p, control, thread_once_cleanup, apr_pool_cleanup_null); - return APR_FROM_OS_ERROR(rc); -} - - - -APR_DECLARE(apr_status_t) apr_thread_once(apr_thread_once_t *control, - void (*func)(void)) -{ - if (!control->hit) { - ULONG count, rc; - rc = DosResetEventSem(control->sem, &count); - - if (rc == 0 && count) { - control->hit = 1; - func(); - } - } - - return APR_SUCCESS; -} diff --git a/libs/apr/threadproc/os2/threadpriv.c b/libs/apr/threadproc/os2/threadpriv.c deleted file mode 100644 index 107ec10d..00000000 --- a/libs/apr/threadproc/os2/threadpriv.c +++ /dev/null @@ -1,88 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_threadproc.h" -#include "apr_thread_proc.h" -#include "apr_portable.h" -#include "apr_general.h" -#include "apr_errno.h" -#include "apr_lib.h" -#include "apr_arch_file_io.h" - -APR_DECLARE(apr_status_t) apr_threadkey_private_create(apr_threadkey_t **key, - void (*dest)(void *), - apr_pool_t *pool) -{ - (*key) = (apr_threadkey_t *)apr_palloc(pool, sizeof(apr_threadkey_t)); - - if ((*key) == NULL) { - return APR_ENOMEM; - } - - (*key)->pool = pool; - return APR_OS2_STATUS(DosAllocThreadLocalMemory(1, &((*key)->key))); -} - -APR_DECLARE(apr_status_t) apr_threadkey_private_get(void **new, apr_threadkey_t *key) -{ - (*new) = (void *)*(key->key); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_threadkey_private_set(void *priv, apr_threadkey_t *key) -{ - *(key->key) = (ULONG)priv; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_threadkey_private_delete(apr_threadkey_t *key) -{ - return APR_OS2_STATUS(DosFreeThreadLocalMemory(key->key)); -} - -APR_DECLARE(apr_status_t) apr_threadkey_data_get(void **data, const char *key, - apr_threadkey_t *threadkey) -{ - return apr_pool_userdata_get(data, key, threadkey->pool); -} - -APR_DECLARE(apr_status_t) apr_threadkey_data_set(void *data, const char *key, - apr_status_t (*cleanup) (void *), - apr_threadkey_t *threadkey) -{ - return apr_pool_userdata_set(data, key, cleanup, threadkey->pool); -} - -APR_DECLARE(apr_status_t) apr_os_threadkey_get(apr_os_threadkey_t *thekey, apr_threadkey_t *key) -{ - *thekey = key->key; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_threadkey_put(apr_threadkey_t **key, - apr_os_threadkey_t *thekey, - apr_pool_t *pool) -{ - if (pool == NULL) { - return APR_ENOPOOL; - } - if ((*key) == NULL) { - (*key) = (apr_threadkey_t *)apr_pcalloc(pool, sizeof(apr_threadkey_t)); - (*key)->pool = pool; - } - (*key)->key = *thekey; - return APR_SUCCESS; -} diff --git a/libs/apr/threadproc/unix/proc.c b/libs/apr/threadproc/unix/proc.c deleted file mode 100644 index 3588a86b..00000000 --- a/libs/apr/threadproc/unix/proc.c +++ /dev/null @@ -1,711 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_threadproc.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_signal.h" -#include "apr_random.h" - -/* Heavy on no'ops, here's what we want to pass if there is APR_NO_FILE - * requested for a specific child handle; - */ -static apr_file_t no_file = { NULL, -1, }; - -APR_DECLARE(apr_status_t) apr_procattr_create(apr_procattr_t **new, - apr_pool_t *pool) -{ - (*new) = (apr_procattr_t *)apr_pcalloc(pool, sizeof(apr_procattr_t)); - - if ((*new) == NULL) { - return APR_ENOMEM; - } - (*new)->pool = pool; - (*new)->cmdtype = APR_PROGRAM; - (*new)->uid = (*new)->gid = -1; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, - apr_int32_t in, - apr_int32_t out, - apr_int32_t err) -{ - apr_status_t rv; - - if ((in != APR_NO_PIPE) && (in != APR_NO_FILE)) { - /* APR_CHILD_BLOCK maps to APR_WRITE_BLOCK, while - * APR_PARENT_BLOCK maps to APR_READ_BLOCK, so transpose - * the CHILD/PARENT blocking flags for the stdin pipe. - * stdout/stderr map to the correct mode by default. - */ - if (in == APR_CHILD_BLOCK) - in = APR_READ_BLOCK; - else if (in == APR_PARENT_BLOCK) - in = APR_WRITE_BLOCK; - - if ((rv = apr_file_pipe_create_ex(&attr->child_in, &attr->parent_in, - in, attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_in); - if (rv != APR_SUCCESS) - return rv; - } - else if (in == APR_NO_FILE) - attr->child_in = &no_file; - - if ((out != APR_NO_PIPE) && (out != APR_NO_FILE)) { - if ((rv = apr_file_pipe_create_ex(&attr->parent_out, &attr->child_out, - out, attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_out); - if (rv != APR_SUCCESS) - return rv; - } - else if (out == APR_NO_FILE) - attr->child_out = &no_file; - - if ((err != APR_NO_PIPE) && (err != APR_NO_FILE)) { - if ((rv = apr_file_pipe_create_ex(&attr->parent_err, &attr->child_err, - err, attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_err); - if (rv != APR_SUCCESS) - return rv; - } - else if (err == APR_NO_FILE) - attr->child_err = &no_file; - - return APR_SUCCESS; -} - - -APR_DECLARE(apr_status_t) apr_procattr_child_in_set(apr_procattr_t *attr, - apr_file_t *child_in, - apr_file_t *parent_in) -{ - apr_status_t rv = APR_SUCCESS; - - if (attr->child_in == NULL && attr->parent_in == NULL - && child_in == NULL && parent_in == NULL) - if ((rv = apr_file_pipe_create(&attr->child_in, &attr->parent_in, - attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_in); - - if (child_in != NULL && rv == APR_SUCCESS) { - if (attr->child_in && (attr->child_in->filedes != -1)) - rv = apr_file_dup2(attr->child_in, child_in, attr->pool); - else { - attr->child_in = NULL; - if ((rv = apr_file_dup(&attr->child_in, child_in, attr->pool)) - == APR_SUCCESS) - rv = apr_file_inherit_set(attr->child_in); - } - } - - if (parent_in != NULL && rv == APR_SUCCESS) { - if (attr->parent_in) - rv = apr_file_dup2(attr->parent_in, parent_in, attr->pool); - else - rv = apr_file_dup(&attr->parent_in, parent_in, attr->pool); - } - - return rv; -} - - -APR_DECLARE(apr_status_t) apr_procattr_child_out_set(apr_procattr_t *attr, - apr_file_t *child_out, - apr_file_t *parent_out) -{ - apr_status_t rv = APR_SUCCESS; - - if (attr->child_out == NULL && attr->parent_out == NULL - && child_out == NULL && parent_out == NULL) - if ((rv = apr_file_pipe_create(&attr->parent_out, &attr->child_out, - attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_out); - - if (child_out != NULL && rv == APR_SUCCESS) { - if (attr->child_out && (attr->child_out->filedes != -1)) - rv = apr_file_dup2(attr->child_out, child_out, attr->pool); - else { - attr->child_out = NULL; - if ((rv = apr_file_dup(&attr->child_out, child_out, attr->pool)) - == APR_SUCCESS) - rv = apr_file_inherit_set(attr->child_out); - } - } - - if (parent_out != NULL && rv == APR_SUCCESS) { - if (attr->parent_out) - rv = apr_file_dup2(attr->parent_out, parent_out, attr->pool); - else - rv = apr_file_dup(&attr->parent_out, parent_out, attr->pool); - } - - return rv; -} - - -APR_DECLARE(apr_status_t) apr_procattr_child_err_set(apr_procattr_t *attr, - apr_file_t *child_err, - apr_file_t *parent_err) -{ - apr_status_t rv = APR_SUCCESS; - - if (attr->child_err == NULL && attr->parent_err == NULL - && child_err == NULL && parent_err == NULL) - if ((rv = apr_file_pipe_create(&attr->parent_err, &attr->child_err, - attr->pool)) == APR_SUCCESS) - rv = apr_file_inherit_unset(attr->parent_err); - - if (child_err != NULL && rv == APR_SUCCESS) { - if (attr->child_err && (attr->child_err->filedes != -1)) - rv = apr_file_dup2(attr->child_err, child_err, attr->pool); - else { - attr->child_err = NULL; - if ((rv = apr_file_dup(&attr->child_err, child_err, attr->pool)) - == APR_SUCCESS) - rv = apr_file_inherit_set(attr->child_err); - } - } - if (parent_err != NULL && rv == APR_SUCCESS) { - if (attr->parent_err) - rv = apr_file_dup2(attr->parent_err, parent_err, attr->pool); - else - rv = apr_file_dup(&attr->parent_err, parent_err, attr->pool); - } - - return rv; -} - - -APR_DECLARE(apr_status_t) apr_procattr_dir_set(apr_procattr_t *attr, - const char *dir) -{ - attr->currdir = apr_pstrdup(attr->pool, dir); - if (attr->currdir) { - return APR_SUCCESS; - } - - return APR_ENOMEM; -} - -APR_DECLARE(apr_status_t) apr_procattr_cmdtype_set(apr_procattr_t *attr, - apr_cmdtype_e cmd) -{ - attr->cmdtype = cmd; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_detach_set(apr_procattr_t *attr, - apr_int32_t detach) -{ - attr->detached = detach; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *pool) -{ - int pid; - - memset(proc, 0, sizeof(apr_proc_t)); - - if ((pid = fork()) < 0) { - return errno; - } - else if (pid == 0) { - proc->pid = getpid(); - - apr_random_after_fork(proc); - - return APR_INCHILD; - } - - proc->pid = pid; - - return APR_INPARENT; -} - -static apr_status_t limit_proc(apr_procattr_t *attr) -{ -#if APR_HAVE_STRUCT_RLIMIT && APR_HAVE_SETRLIMIT -#ifdef RLIMIT_CPU - if (attr->limit_cpu != NULL) { - if ((setrlimit(RLIMIT_CPU, attr->limit_cpu)) != 0) { - return errno; - } - } -#endif -#ifdef RLIMIT_NPROC - if (attr->limit_nproc != NULL) { - if ((setrlimit(RLIMIT_NPROC, attr->limit_nproc)) != 0) { - return errno; - } - } -#endif -#ifdef RLIMIT_NOFILE - if (attr->limit_nofile != NULL) { - if ((setrlimit(RLIMIT_NOFILE, attr->limit_nofile)) != 0) { - return errno; - } - } -#endif -#if defined(RLIMIT_AS) - if (attr->limit_mem != NULL) { - if ((setrlimit(RLIMIT_AS, attr->limit_mem)) != 0) { - return errno; - } - } -#elif defined(RLIMIT_DATA) - if (attr->limit_mem != NULL) { - if ((setrlimit(RLIMIT_DATA, attr->limit_mem)) != 0) { - return errno; - } - } -#elif defined(RLIMIT_VMEM) - if (attr->limit_mem != NULL) { - if ((setrlimit(RLIMIT_VMEM, attr->limit_mem)) != 0) { - return errno; - } - } -#endif -#else - /* - * Maybe make a note in error_log that setrlimit isn't supported?? - */ - -#endif - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr, - apr_child_errfn_t *errfn) -{ - attr->errfn = errfn; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr, - apr_int32_t chk) -{ - attr->errchk = chk; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_addrspace_set(apr_procattr_t *attr, - apr_int32_t addrspace) -{ - /* won't ever be used on this platform, so don't save the flag */ - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr, - const char *username, - const char *password) -{ - apr_status_t rv; - apr_gid_t gid; - - if ((rv = apr_uid_get(&attr->uid, &gid, username, - attr->pool)) != APR_SUCCESS) { - attr->uid = -1; - return rv; - } - - /* Use default user group if not already set */ - if (attr->gid == -1) { - attr->gid = gid; - } - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_group_set(apr_procattr_t *attr, - const char *groupname) -{ - apr_status_t rv; - - if ((rv = apr_gid_get(&attr->gid, groupname, attr->pool)) != APR_SUCCESS) - attr->gid = -1; - return rv; -} - -APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, - const char *progname, - const char * const *args, - const char * const *env, - apr_procattr_t *attr, - apr_pool_t *pool) -{ - int i; - const char * const empty_envp[] = {NULL}; - - if (!env) { /* Specs require an empty array instead of NULL; - * Purify will trigger a failure, even if many - * implementations don't. - */ - env = empty_envp; - } - - new->in = attr->parent_in; - new->err = attr->parent_err; - new->out = attr->parent_out; - - if (attr->errchk) { - if (attr->currdir) { - if (access(attr->currdir, X_OK) == -1) { - /* chdir() in child wouldn't have worked */ - return errno; - } - } - - if (attr->cmdtype == APR_PROGRAM || - attr->cmdtype == APR_PROGRAM_ENV || - *progname == '/') { - /* for both of these values of cmdtype, caller must pass - * full path, so it is easy to check; - * caller can choose to pass full path for other - * values of cmdtype - */ - if (access(progname, X_OK) == -1) { - /* exec*() in child wouldn't have worked */ - return errno; - } - } - else { - /* todo: search PATH for progname then try to access it */ - } - } - - if ((new->pid = fork()) < 0) { - return errno; - } - else if (new->pid == 0) { - /* child process */ - - /* - * If we do exec cleanup before the dup2() calls to set up pipes - * on 0-2, we accidentally close the pipes used by programs like - * mod_cgid. - * - * If we do exec cleanup after the dup2() calls, cleanup can accidentally - * close our pipes which replaced any files which previously had - * descriptors 0-2. - * - * The solution is to kill the cleanup for the pipes, then do - * exec cleanup, then do the dup2() calls. - */ - - if (attr->child_in) { - apr_pool_cleanup_kill(apr_file_pool_get(attr->child_in), - attr->child_in, apr_unix_file_cleanup); - } - - if (attr->child_out) { - apr_pool_cleanup_kill(apr_file_pool_get(attr->child_out), - attr->child_out, apr_unix_file_cleanup); - } - - if (attr->child_err) { - apr_pool_cleanup_kill(apr_file_pool_get(attr->child_err), - attr->child_err, apr_unix_file_cleanup); - } - - apr_pool_cleanup_for_exec(); - - if ((attr->child_in) && (attr->child_in->filedes == -1)) { - close(STDIN_FILENO); - } - else if (attr->child_in && - attr->child_in->filedes != STDIN_FILENO) { - dup2(attr->child_in->filedes, STDIN_FILENO); - apr_file_close(attr->child_in); - } - - if ((attr->child_out) && (attr->child_out->filedes == -1)) { - close(STDOUT_FILENO); - } - else if (attr->child_out && - attr->child_out->filedes != STDOUT_FILENO) { - dup2(attr->child_out->filedes, STDOUT_FILENO); - apr_file_close(attr->child_out); - } - - if ((attr->child_err) && (attr->child_err->filedes == -1)) { - close(STDERR_FILENO); - } - else if (attr->child_err && - attr->child_err->filedes != STDERR_FILENO) { - dup2(attr->child_err->filedes, STDERR_FILENO); - apr_file_close(attr->child_err); - } - - apr_signal(SIGCHLD, SIG_DFL); /* not sure if this is needed or not */ - - if (attr->currdir != NULL) { - if (chdir(attr->currdir) == -1) { - if (attr->errfn) { - attr->errfn(pool, errno, "change of working directory failed"); - } - _exit(-1); /* We have big problems, the child should exit. */ - } - } - - /* Only try to switch if we are running as root */ - if (attr->gid != -1 && !geteuid()) { - if (setgid(attr->gid)) { - if (attr->errfn) { - attr->errfn(pool, errno, "setting of group failed"); - } - _exit(-1); /* We have big problems, the child should exit. */ - } - } - - if (attr->uid != -1 && !geteuid()) { - if (setuid(attr->uid)) { - if (attr->errfn) { - attr->errfn(pool, errno, "setting of user failed"); - } - _exit(-1); /* We have big problems, the child should exit. */ - } - } - - if (limit_proc(attr) != APR_SUCCESS) { - if (attr->errfn) { - attr->errfn(pool, errno, "setting of resource limits failed"); - } - _exit(-1); /* We have big problems, the child should exit. */ - } - - if (attr->cmdtype == APR_SHELLCMD || - attr->cmdtype == APR_SHELLCMD_ENV) { - int onearg_len = 0; - const char *newargs[4]; - - newargs[0] = SHELL_PATH; - newargs[1] = "-c"; - - i = 0; - while (args[i]) { - onearg_len += strlen(args[i]); - onearg_len++; /* for space delimiter */ - i++; - } - - switch(i) { - case 0: - /* bad parameters; we're doomed */ - break; - case 1: - /* no args, or caller already built a single string from - * progname and args - */ - newargs[2] = args[0]; - break; - default: - { - char *ch, *onearg; - - ch = onearg = apr_palloc(pool, onearg_len); - i = 0; - while (args[i]) { - size_t len = strlen(args[i]); - - memcpy(ch, args[i], len); - ch += len; - *ch = ' '; - ++ch; - ++i; - } - --ch; /* back up to trailing blank */ - *ch = '\0'; - newargs[2] = onearg; - } - } - - newargs[3] = NULL; - - if (attr->detached) { - apr_proc_detach(APR_PROC_DETACH_DAEMONIZE); - } - - if (attr->cmdtype == APR_SHELLCMD) { - execve(SHELL_PATH, (char * const *) newargs, (char * const *)env); - } - else { - execv(SHELL_PATH, (char * const *)newargs); - } - } - else if (attr->cmdtype == APR_PROGRAM) { - if (attr->detached) { - apr_proc_detach(APR_PROC_DETACH_DAEMONIZE); - } - - execve(progname, (char * const *)args, (char * const *)env); - } - else if (attr->cmdtype == APR_PROGRAM_ENV) { - if (attr->detached) { - apr_proc_detach(APR_PROC_DETACH_DAEMONIZE); - } - - execv(progname, (char * const *)args); - } - else { - /* APR_PROGRAM_PATH */ - if (attr->detached) { - apr_proc_detach(APR_PROC_DETACH_DAEMONIZE); - } - - execvp(progname, (char * const *)args); - } - if (attr->errfn) { - char *desc; - - desc = apr_psprintf(pool, "exec of '%s' failed", - progname); - attr->errfn(pool, errno, desc); - } - - _exit(-1); /* if we get here, there is a problem, so exit with an - * error code. */ - } - - /* Parent process */ - if (attr->child_in && (attr->child_in->filedes != -1)) { - apr_file_close(attr->child_in); - } - - if (attr->child_out && (attr->child_out->filedes != -1)) { - apr_file_close(attr->child_out); - } - - if (attr->child_err && (attr->child_err->filedes != -1)) { - apr_file_close(attr->child_err); - } - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc, - int *exitcode, - apr_exit_why_e *exitwhy, - apr_wait_how_e waithow, - apr_pool_t *p) -{ - proc->pid = -1; - return apr_proc_wait(proc, exitcode, exitwhy, waithow); -} - -APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, - int *exitcode, apr_exit_why_e *exitwhy, - apr_wait_how_e waithow) -{ - pid_t pstatus; - int waitpid_options = WUNTRACED; - int exit_int; - int ignore; - apr_exit_why_e ignorewhy; - - if (exitcode == NULL) { - exitcode = &ignore; - } - - if (exitwhy == NULL) { - exitwhy = &ignorewhy; - } - - if (waithow != APR_WAIT) { - waitpid_options |= WNOHANG; - } - - do { - pstatus = waitpid(proc->pid, &exit_int, waitpid_options); - } while (pstatus < 0 && errno == EINTR); - - if (pstatus > 0) { - proc->pid = pstatus; - - if (WIFEXITED(exit_int)) { - *exitwhy = APR_PROC_EXIT; - *exitcode = WEXITSTATUS(exit_int); - } - else if (WIFSIGNALED(exit_int)) { - *exitwhy = APR_PROC_SIGNAL; - -#ifdef WCOREDUMP - if (WCOREDUMP(exit_int)) { - *exitwhy |= APR_PROC_SIGNAL_CORE; - } -#endif - - *exitcode = WTERMSIG(exit_int); - } - else { - /* unexpected condition */ - return APR_EGENERAL; - } - - return APR_CHILD_DONE; - } - else if (pstatus == 0) { - return APR_CHILD_NOTDONE; - } - - return errno; -} - -#if APR_HAVE_STRUCT_RLIMIT -APR_DECLARE(apr_status_t) apr_procattr_limit_set(apr_procattr_t *attr, - apr_int32_t what, - struct rlimit *limit) -{ - switch(what) { - case APR_LIMIT_CPU: -#ifdef RLIMIT_CPU - attr->limit_cpu = limit; - break; -#else - return APR_ENOTIMPL; -#endif - - case APR_LIMIT_MEM: -#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS) - attr->limit_mem = limit; - break; -#else - return APR_ENOTIMPL; -#endif - - case APR_LIMIT_NPROC: -#ifdef RLIMIT_NPROC - attr->limit_nproc = limit; - break; -#else - return APR_ENOTIMPL; -#endif - - case APR_LIMIT_NOFILE: -#ifdef RLIMIT_NOFILE - attr->limit_nofile = limit; - break; -#else - return APR_ENOTIMPL; -#endif - - } - - return APR_SUCCESS; -} -#endif /* APR_HAVE_STRUCT_RLIMIT */ - diff --git a/libs/apr/threadproc/unix/procsup.c b/libs/apr/threadproc/unix/procsup.c deleted file mode 100644 index 94177f92..00000000 --- a/libs/apr/threadproc/unix/procsup.c +++ /dev/null @@ -1,104 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_threadproc.h" - -APR_DECLARE(apr_status_t) apr_proc_detach(int daemonize) -{ - if (chdir("/") == -1) { - return errno; - } - -#if !defined(MPE) && !defined(OS2) && !defined(TPF) && !defined(BEOS) - /* Don't detach for MPE because child processes can't survive the death of - * the parent. */ - if (daemonize) { - int x; - - if ((x = fork()) > 0) { - exit(0); - } - else if (x == -1) { - perror("fork"); - fprintf(stderr, "unable to fork new process\n"); - exit(1); /* we can't do anything here, so just exit. */ - } - /* RAISE_SIGSTOP(DETACH); */ - } -#endif - -#ifdef HAVE_SETSID - /* A setsid() failure is not fatal if we didn't just fork(). - * The calling process may be the process group leader, in - * which case setsid() will fail with EPERM. - */ - if (setsid() == -1 && daemonize) { - return errno; - } -#elif defined(NEXT) || defined(NEWSOS) - if (setpgrp(0, getpid()) == -1) { - return errno; - } -#elif defined(OS2) || defined(TPF) || defined(MPE) - /* do nothing */ -#else - if (setpgid(0, 0) == -1) { - return errno; - } -#endif - - /* close out the standard file descriptors */ - if (freopen("/dev/null", "r", stdin) == NULL) { - return errno; - /* continue anyhow -- note we can't close out descriptor 0 because we - * have nothing to replace it with, and if we didn't have a descriptor - * 0 the next file would be created with that value ... leading to - * havoc. - */ - } - if (freopen("/dev/null", "w", stdout) == NULL) { - return errno; - } - /* We are going to reopen this again in a little while to the error - * log file, but better to do it twice and suffer a small performance - * hit for consistancy than not reopen it here. - */ - if (freopen("/dev/null", "w", stderr) == NULL) { - return errno; - } - return APR_SUCCESS; -} - -#if (!HAVE_WAITPID) -/* From ikluft@amdahl.com - * this is not ideal but it works for SVR3 variants - * Modified by dwd@bell-labs.com to call wait3 instead of wait because - * apache started to use the WNOHANG option. - */ -int waitpid(pid_t pid, int *statusp, int options) -{ - int tmp_pid; - if (kill(pid, 0) == -1) { - errno = ECHILD; - return -1; - } - while (((tmp_pid = wait3(statusp, options, 0)) != pid) && - (tmp_pid != -1) && (tmp_pid != 0) && (pid != -1)) - ; - return tmp_pid; -} -#endif - diff --git a/libs/apr/threadproc/unix/signals.c b/libs/apr/threadproc/unix/signals.c deleted file mode 100644 index 57a31af9..00000000 --- a/libs/apr/threadproc/unix/signals.c +++ /dev/null @@ -1,487 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define INCL_DOSEXCEPTIONS /* for OS2 */ -#include "apr_arch_threadproc.h" -#include "apr_private.h" -#include "apr_pools.h" -#include "apr_signal.h" -#include "apr_strings.h" - -#include -#if APR_HAS_THREADS && APR_HAVE_PTHREAD_H -#include -#endif - -#ifdef SIGWAIT_TAKES_ONE_ARG -#define apr_sigwait(a,b) ((*(b)=sigwait((a)))<0?-1:0) -#else -#define apr_sigwait(a,b) sigwait((a),(b)) -#endif - -APR_DECLARE(apr_status_t) apr_proc_kill(apr_proc_t *proc, int signum) -{ -#ifdef OS2 - /* SIGTERM's don't work too well in OS/2 (only affects other EMX - * programs). CGIs may not be, esp. REXX scripts, so use a native - * call instead - */ - if (signum == SIGTERM) { - return APR_OS2_STATUS(DosSendSignalException(proc->pid, - XCPT_SIGNAL_BREAK)); - } -#endif /* OS2 */ - - if (kill(proc->pid, signum) == -1) { - return errno; - } - - return APR_SUCCESS; -} - - -#if APR_HAVE_SIGACTION - -#if defined(__NetBSD__) || defined(DARWIN) -static void avoid_zombies(int signo) -{ - int exit_status; - - while (waitpid(-1, &exit_status, WNOHANG) > 0) { - /* do nothing */ - } -} -#endif /* DARWIN */ - -/* - * Replace standard signal() with the more reliable sigaction equivalent - * from W. Richard Stevens' "Advanced Programming in the UNIX Environment" - * (the version that does not automatically restart system calls). - */ -APR_DECLARE(apr_sigfunc_t *) apr_signal(int signo, apr_sigfunc_t * func) -{ - struct sigaction act, oact; - - act.sa_handler = func; - sigemptyset(&act.sa_mask); - act.sa_flags = 0; -#ifdef SA_INTERRUPT /* SunOS */ - act.sa_flags |= SA_INTERRUPT; -#endif -#if defined(__osf__) && defined(__alpha) - /* XXX jeff thinks this should be enabled whenever SA_NOCLDWAIT is defined */ - - /* this is required on Tru64 to cause child processes to - * disappear gracefully - XPG4 compatible - */ - if ((signo == SIGCHLD) && (func == SIG_IGN)) { - act.sa_flags |= SA_NOCLDWAIT; - } -#endif -#if defined(__NetBSD__) || defined(DARWIN) - /* ignoring SIGCHLD or leaving the default disposition doesn't avoid zombies, - * and there is no SA_NOCLDWAIT flag, so catch the signal and reap status in - * the handler to avoid zombies - */ - if ((signo == SIGCHLD) && (func == SIG_IGN)) { - act.sa_handler = avoid_zombies; - } -#endif - if (sigaction(signo, &act, &oact) < 0) - return SIG_ERR; - return oact.sa_handler; -} - -#endif /* HAVE_SIGACTION */ - -/* AC_DECL_SYS_SIGLIST defines either of these symbols depending - * on the version of autoconf used. */ -#if defined(SYS_SIGLIST_DECLARED) || HAVE_DECL_SYS_SIGLIST - -void apr_signal_init(apr_pool_t *pglobal) -{ -} -const char *apr_signal_description_get(int signum) -{ - return (signum >= 0) ? sys_siglist[signum] : "unknown signal (number)"; -} - -#else /* !(SYS_SIGLIST_DECLARED || HAVE_DECL_SYS_SIGLIST) */ - -/* we need to roll our own signal description stuff */ - -#if defined(NSIG) -#define APR_NUMSIG NSIG -#elif defined(_NSIG) -#define APR_NUMSIG _NSIG -#elif defined(__NSIG) -#define APR_NUMSIG __NSIG -#else -#define APR_NUMSIG 33 /* breaks on OS/390 with < 33; 32 is o.k. for most */ -#endif - -static const char *signal_description[APR_NUMSIG]; - -#define store_desc(index, string) \ - do { \ - if (index >= APR_NUMSIG) { \ - assert(index < APR_NUMSIG); \ - } \ - else { \ - signal_description[index] = string; \ - } \ - } while (0) - -void apr_signal_init(apr_pool_t *pglobal) -{ - int sig; - - store_desc(0, "Signal 0"); - -#ifdef SIGHUP - store_desc(SIGHUP, "Hangup"); -#endif -#ifdef SIGINT - store_desc(SIGINT, "Interrupt"); -#endif -#ifdef SIGQUIT - store_desc(SIGQUIT, "Quit"); -#endif -#ifdef SIGILL - store_desc(SIGILL, "Illegal instruction"); -#endif -#ifdef SIGTRAP - store_desc(SIGTRAP, "Trace/BPT trap"); -#endif -#ifdef SIGIOT - store_desc(SIGIOT, "IOT instruction"); -#endif -#ifdef SIGABRT - store_desc(SIGABRT, "Abort"); -#endif -#ifdef SIGEMT - store_desc(SIGEMT, "Emulator trap"); -#endif -#ifdef SIGFPE - store_desc(SIGFPE, "Arithmetic exception"); -#endif -#ifdef SIGKILL - store_desc(SIGKILL, "Killed"); -#endif -#ifdef SIGBUS - store_desc(SIGBUS, "Bus error"); -#endif -#ifdef SIGSEGV - store_desc(SIGSEGV, "Segmentation fault"); -#endif -#ifdef SIGSYS - store_desc(SIGSYS, "Bad system call"); -#endif -#ifdef SIGPIPE - store_desc(SIGPIPE, "Broken pipe"); -#endif -#ifdef SIGALRM - store_desc(SIGALRM, "Alarm clock"); -#endif -#ifdef SIGTERM - store_desc(SIGTERM, "Terminated"); -#endif -#ifdef SIGUSR1 - store_desc(SIGUSR1, "User defined signal 1"); -#endif -#ifdef SIGUSR2 - store_desc(SIGUSR2, "User defined signal 2"); -#endif -#ifdef SIGCLD - store_desc(SIGCLD, "Child status change"); -#endif -#ifdef SIGCHLD - store_desc(SIGCHLD, "Child status change"); -#endif -#ifdef SIGPWR - store_desc(SIGPWR, "Power-fail restart"); -#endif -#ifdef SIGWINCH - store_desc(SIGWINCH, "Window changed"); -#endif -#ifdef SIGURG - store_desc(SIGURG, "urgent socket condition"); -#endif -#ifdef SIGPOLL - store_desc(SIGPOLL, "Pollable event occurred"); -#endif -#ifdef SIGIO - store_desc(SIGIO, "socket I/O possible"); -#endif -#ifdef SIGSTOP - store_desc(SIGSTOP, "Stopped (signal)"); -#endif -#ifdef SIGTSTP - store_desc(SIGTSTP, "Stopped"); -#endif -#ifdef SIGCONT - store_desc(SIGCONT, "Continued"); -#endif -#ifdef SIGTTIN - store_desc(SIGTTIN, "Stopped (tty input)"); -#endif -#ifdef SIGTTOU - store_desc(SIGTTOU, "Stopped (tty output)"); -#endif -#ifdef SIGVTALRM - store_desc(SIGVTALRM, "virtual timer expired"); -#endif -#ifdef SIGPROF - store_desc(SIGPROF, "profiling timer expired"); -#endif -#ifdef SIGXCPU - store_desc(SIGXCPU, "exceeded cpu limit"); -#endif -#ifdef SIGXFSZ - store_desc(SIGXFSZ, "exceeded file size limit"); -#endif - - for (sig = 0; sig < APR_NUMSIG; ++sig) - if (signal_description[sig] == NULL) - signal_description[sig] = apr_psprintf(pglobal, "signal #%d", sig); -} - -const char *apr_signal_description_get(int signum) -{ - return - (signum >= 0 && signum < APR_NUMSIG) - ? signal_description[signum] - : "unknown signal (number)"; -} - -#endif /* SYS_SIGLIST_DECLARED || HAVE_DECL_SYS_SIGLIST */ - -#if APR_HAS_THREADS && (HAVE_SIGSUSPEND || APR_HAVE_SIGWAIT) && !defined(OS2) - -static void remove_sync_sigs(sigset_t *sig_mask) -{ -#ifdef SIGABRT - sigdelset(sig_mask, SIGABRT); -#endif -#ifdef SIGBUS - sigdelset(sig_mask, SIGBUS); -#endif -#ifdef SIGEMT - sigdelset(sig_mask, SIGEMT); -#endif -#ifdef SIGFPE - sigdelset(sig_mask, SIGFPE); -#endif -#ifdef SIGILL - sigdelset(sig_mask, SIGILL); -#endif -#ifdef SIGIOT - sigdelset(sig_mask, SIGIOT); -#endif -#ifdef SIGPIPE - sigdelset(sig_mask, SIGPIPE); -#endif -#ifdef SIGSEGV - sigdelset(sig_mask, SIGSEGV); -#endif -#ifdef SIGSYS - sigdelset(sig_mask, SIGSYS); -#endif -#ifdef SIGTRAP - sigdelset(sig_mask, SIGTRAP); -#endif - -/* the rest of the signals removed from the mask in this function - * absolutely must be removed; you cannot block synchronous signals - * (requirement of pthreads API) - * - * SIGUSR2 is being removed from the mask for the convenience of - * Purify users (Solaris, HP-UX, SGI) since Purify uses SIGUSR2 - */ -#ifdef SIGUSR2 - sigdelset(sig_mask, SIGUSR2); -#endif -} - -APR_DECLARE(apr_status_t) apr_signal_thread(int(*signal_handler)(int signum)) -{ - sigset_t sig_mask; -#if APR_HAVE_SIGWAIT - int (*sig_func)(int signum) = (int (*)(int))signal_handler; -#endif - - /* This thread will be the one responsible for handling signals */ - sigfillset(&sig_mask); - - /* On certain platforms, sigwait() returns EINVAL if any of various - * unblockable signals are included in the mask. This was first - * observed on AIX and Tru64. - */ -#ifdef SIGKILL - sigdelset(&sig_mask, SIGKILL); -#endif -#ifdef SIGSTOP - sigdelset(&sig_mask, SIGSTOP); -#endif -#ifdef SIGCONT - sigdelset(&sig_mask, SIGCONT); -#endif -#ifdef SIGWAITING - sigdelset(&sig_mask, SIGWAITING); -#endif - - /* no synchronous signals should be in the mask passed to sigwait() */ - remove_sync_sigs(&sig_mask); - - /* On AIX (4.3.3, at least), sigwait() won't wake up if the high- - * order bit of the second word of flags is turned on. sigdelset() - * returns an error when trying to turn this off, so we'll turn it - * off manually. - * - * Note that the private fields differ between 32-bit and 64-bit - * and even between _ALL_SOURCE and !_ALL_SOURCE. Except that on - * AIX 4.3 32-bit builds and 64-bit builds use the same definition. - * - * Applicable AIX fixes such that this is no longer needed: - * - * APAR IY23096 for AIX 51B, fix included in AIX 51C, and - * APAR IY24162 for 43X. - */ -#if defined(_AIX) -#if defined(__64BIT__) && defined(_AIXVERSION_510) -#ifdef _ALL_SOURCE - sig_mask.ss_set[3] &= 0x7FFFFFFF; -#else /* not _ALL_SOURCE */ - sig_mask.__ss_set[3] &= 0x7FFFFFFF; -#endif -#else /* not 64-bit build, or 64-bit build on 4.3 */ -#ifdef _ALL_SOURCE - sig_mask.hisigs &= 0x7FFFFFFF; -#else /* not _ALL_SOURCE */ - sig_mask.__hisigs &= 0x7FFFFFFF; -#endif -#endif -#endif /* _AIX */ - - while (1) { -#if APR_HAVE_SIGWAIT - int signal_received; - - if (apr_sigwait(&sig_mask, &signal_received) != 0) - { - /* handle sigwait() error here */ - } - - if (sig_func(signal_received) == 1) { - return APR_SUCCESS; - } -#elif HAVE_SIGSUSPEND - sigsuspend(&sig_mask); -#else -#error No apr_sigwait() and no sigsuspend() -#endif - } -} - -APR_DECLARE(apr_status_t) apr_setup_signal_thread(void) -{ - sigset_t sig_mask; - int rv; - - /* All threads should mask out signals to be handled by - * the thread doing sigwait(). - * - * No thread should ever block synchronous signals. - * See the Solaris man page for pthread_sigmask() for - * some information. Solaris chooses to knock out such - * processes when a blocked synchronous signal is - * delivered, skipping any registered signal handler. - * AIX doesn't call a signal handler either. At least - * one level of linux+glibc does call the handler even - * when the synchronous signal is blocked. - */ - sigfillset(&sig_mask); - remove_sync_sigs(&sig_mask); - -#if defined(SIGPROCMASK_SETS_THREAD_MASK) || ! APR_HAS_THREADS - if ((rv = sigprocmask(SIG_SETMASK, &sig_mask, NULL)) != 0) { - rv = errno; - } -#else - if ((rv = pthread_sigmask(SIG_SETMASK, &sig_mask, NULL)) != 0) { -#ifdef HAVE_ZOS_PTHREADS - rv = errno; -#endif - } -#endif - return rv; -} - -#endif /* APR_HAS_THREADS && ... */ - -APR_DECLARE(apr_status_t) apr_signal_block(int signum) -{ -#if APR_HAVE_SIGACTION - sigset_t sig_mask; - int rv; - - sigemptyset(&sig_mask); - - sigaddset(&sig_mask, signum); - -#if defined(SIGPROCMASK_SETS_THREAD_MASK) || ! APR_HAS_THREADS - if ((rv = sigprocmask(SIG_BLOCK, &sig_mask, NULL)) != 0) { - rv = errno; - } -#else - if ((rv = pthread_sigmask(SIG_BLOCK, &sig_mask, NULL)) != 0) { -#ifdef HAVE_ZOS_PTHREADS - rv = errno; -#endif - } -#endif - return rv; -#else - return APR_ENOTIMPL; -#endif -} - -APR_DECLARE(apr_status_t) apr_signal_unblock(int signum) -{ -#if APR_HAVE_SIGACTION - sigset_t sig_mask; - int rv; - - sigemptyset(&sig_mask); - - sigaddset(&sig_mask, signum); - -#if defined(SIGPROCMASK_SETS_THREAD_MASK) || ! APR_HAS_THREADS - if ((rv = sigprocmask(SIG_UNBLOCK, &sig_mask, NULL)) != 0) { - rv = errno; - } -#else - if ((rv = pthread_sigmask(SIG_UNBLOCK, &sig_mask, NULL)) != 0) { -#ifdef HAVE_ZOS_PTHREADS - rv = errno; -#endif - } -#endif - return rv; -#else - return APR_ENOTIMPL; -#endif -} diff --git a/libs/apr/threadproc/unix/thread.c b/libs/apr/threadproc/unix/thread.c deleted file mode 100644 index 5639ac70..00000000 --- a/libs/apr/threadproc/unix/thread.c +++ /dev/null @@ -1,334 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_portable.h" -#include "apr_arch_threadproc.h" - -#if APR_HAS_THREADS - -#if APR_HAVE_PTHREAD_H - -/* Destroy the threadattr object */ -static apr_status_t threadattr_cleanup(void *data) -{ - apr_threadattr_t *attr = data; - apr_status_t rv; - - rv = pthread_attr_destroy(&attr->attr); -#ifdef HAVE_ZOS_PTHREADS - if (rv) { - rv = errno; - } -#endif - return rv; -} - -APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new, - apr_pool_t *pool) -{ - apr_status_t stat; - - (*new) = apr_palloc(pool, sizeof(apr_threadattr_t)); - (*new)->pool = pool; - stat = pthread_attr_init(&(*new)->attr); - - if (stat == 0) { - apr_pool_cleanup_register(pool, *new, threadattr_cleanup, - apr_pool_cleanup_null); - return APR_SUCCESS; - } -#ifdef HAVE_ZOS_PTHREADS - stat = errno; -#endif - - return stat; -} - -#if defined(PTHREAD_CREATE_DETACHED) -#define DETACH_ARG(v) ((v) ? PTHREAD_CREATE_DETACHED : PTHREAD_CREATE_JOINABLE) -#else -#define DETACH_ARG(v) ((v) ? 1 : 0) -#endif - -APR_DECLARE(apr_status_t) apr_threadattr_detach_set(apr_threadattr_t *attr, - apr_int32_t on) -{ - apr_status_t stat; -#ifdef HAVE_ZOS_PTHREADS - int arg = DETACH_ARG(on); - - if ((stat = pthread_attr_setdetachstate(&attr->attr, &arg)) == 0) { -#else - if ((stat = pthread_attr_setdetachstate(&attr->attr, - DETACH_ARG(on))) == 0) { -#endif - return APR_SUCCESS; - } - else { -#ifdef HAVE_ZOS_PTHREADS - stat = errno; -#endif - - return stat; - } -} - -APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr) -{ - int state; - -#ifdef PTHREAD_ATTR_GETDETACHSTATE_TAKES_ONE_ARG - state = pthread_attr_getdetachstate(&attr->attr); -#else - pthread_attr_getdetachstate(&attr->attr, &state); -#endif - if (state == 1) - return APR_DETACH; - return APR_NOTDETACH; -} - -APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, - apr_size_t stacksize) -{ - int stat; - - stat = pthread_attr_setstacksize(&attr->attr, stacksize); - if (stat == 0) { - return APR_SUCCESS; - } -#ifdef HAVE_ZOS_PTHREADS - stat = errno; -#endif - - return stat; -} - -APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr, - apr_size_t size) -{ -#ifdef HAVE_PTHREAD_ATTR_SETGUARDSIZE - apr_status_t rv; - - rv = pthread_attr_setguardsize(&attr->attr, size); - if (rv == 0) { - return APR_SUCCESS; - } -#ifdef HAVE_ZOS_PTHREADS - rv = errno; -#endif - return rv; -#else - return APR_ENOTIMPL; -#endif -} - -static void *dummy_worker(void *opaque) -{ - apr_thread_t *thread = (apr_thread_t*)opaque; - return thread->func(thread, thread->data); -} - -APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, - apr_threadattr_t *attr, - apr_thread_start_t func, - void *data, - apr_pool_t *pool) -{ - apr_status_t stat; - pthread_attr_t *temp; - - (*new) = (apr_thread_t *)apr_pcalloc(pool, sizeof(apr_thread_t)); - - if ((*new) == NULL) { - return APR_ENOMEM; - } - - (*new)->td = (pthread_t *)apr_pcalloc(pool, sizeof(pthread_t)); - - if ((*new)->td == NULL) { - return APR_ENOMEM; - } - - (*new)->data = data; - (*new)->func = func; - - if (attr) - temp = &attr->attr; - else - temp = NULL; - - stat = apr_pool_create(&(*new)->pool, pool); - if (stat != APR_SUCCESS) { - return stat; - } - - if ((stat = pthread_create((*new)->td, temp, dummy_worker, (*new))) == 0) { - return APR_SUCCESS; - } - else { -#ifdef HAVE_ZOS_PTHREADS - stat = errno; -#endif - - return stat; - } -} - -APR_DECLARE(apr_os_thread_t) apr_os_thread_current(void) -{ - return pthread_self(); -} - -APR_DECLARE(int) apr_os_thread_equal(apr_os_thread_t tid1, - apr_os_thread_t tid2) -{ - return pthread_equal(tid1, tid2); -} - -APR_DECLARE(apr_status_t) apr_thread_exit(apr_thread_t *thd, - apr_status_t retval) -{ - thd->exitval = retval; - apr_pool_destroy(thd->pool); - pthread_exit(NULL); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_join(apr_status_t *retval, - apr_thread_t *thd) -{ - apr_status_t stat; - apr_status_t *thread_stat; - - if ((stat = pthread_join(*thd->td,(void *)&thread_stat)) == 0) { - *retval = thd->exitval; - return APR_SUCCESS; - } - else { -#ifdef HAVE_ZOS_PTHREADS - stat = errno; -#endif - - return stat; - } -} - -APR_DECLARE(apr_status_t) apr_thread_detach(apr_thread_t *thd) -{ - apr_status_t stat; - -#ifdef HAVE_ZOS_PTHREADS - if ((stat = pthread_detach(thd->td)) == 0) { -#else - if ((stat = pthread_detach(*thd->td)) == 0) { -#endif - - return APR_SUCCESS; - } - else { -#ifdef HAVE_ZOS_PTHREADS - stat = errno; -#endif - - return stat; - } -} - -APR_DECLARE(void) apr_thread_yield(void) -{ -#ifdef HAVE_PTHREAD_YIELD -#ifdef HAVE_ZOS_PTHREADS - pthread_yield(NULL); -#else - pthread_yield(); -#endif /* HAVE_ZOS_PTHREADS */ -#else -#ifdef HAVE_SCHED_YIELD - sched_yield(); -#endif -#endif -} - -APR_DECLARE(apr_status_t) apr_thread_data_get(void **data, const char *key, - apr_thread_t *thread) -{ - return apr_pool_userdata_get(data, key, thread->pool); -} - -APR_DECLARE(apr_status_t) apr_thread_data_set(void *data, const char *key, - apr_status_t (*cleanup)(void *), - apr_thread_t *thread) -{ - return apr_pool_userdata_set(data, key, cleanup, thread->pool); -} - -APR_DECLARE(apr_status_t) apr_os_thread_get(apr_os_thread_t **thethd, - apr_thread_t *thd) -{ - *thethd = thd->td; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_thread_put(apr_thread_t **thd, - apr_os_thread_t *thethd, - apr_pool_t *pool) -{ - if (pool == NULL) { - return APR_ENOPOOL; - } - - if ((*thd) == NULL) { - (*thd) = (apr_thread_t *)apr_pcalloc(pool, sizeof(apr_thread_t)); - (*thd)->pool = pool; - } - - (*thd)->td = thethd; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_once_init(apr_thread_once_t **control, - apr_pool_t *p) -{ - static const pthread_once_t once_init = PTHREAD_ONCE_INIT; - - *control = apr_palloc(p, sizeof(**control)); - (*control)->once = once_init; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_once(apr_thread_once_t *control, - void (*func)(void)) -{ - return pthread_once(&control->once, func); -} - -APR_POOL_IMPLEMENT_ACCESSOR(thread) - -#endif /* HAVE_PTHREAD_H */ -#endif /* APR_HAS_THREADS */ - -#if !APR_HAS_THREADS - -/* avoid warning for no prototype */ -APR_DECLARE(apr_status_t) apr_os_thread_get(void); - -APR_DECLARE(apr_status_t) apr_os_thread_get(void) -{ - return APR_ENOTIMPL; -} - -#endif diff --git a/libs/apr/threadproc/unix/threadpriv.c b/libs/apr/threadproc/unix/threadpriv.c deleted file mode 100644 index c2785203..00000000 --- a/libs/apr/threadproc/unix/threadpriv.c +++ /dev/null @@ -1,129 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_portable.h" -#include "apr_arch_threadproc.h" - -#if APR_HAS_THREADS - -#if APR_HAVE_PTHREAD_H -APR_DECLARE(apr_status_t) apr_threadkey_private_create(apr_threadkey_t **key, - void (*dest)(void *), - apr_pool_t *pool) -{ - (*key) = (apr_threadkey_t *)apr_pcalloc(pool, sizeof(apr_threadkey_t)); - - if ((*key) == NULL) { - return APR_ENOMEM; - } - - (*key)->pool = pool; - - return pthread_key_create(&(*key)->key, dest); - -} - -APR_DECLARE(apr_status_t) apr_threadkey_private_get(void **new, - apr_threadkey_t *key) -{ -#ifdef PTHREAD_GETSPECIFIC_TAKES_TWO_ARGS - if (pthread_getspecific(key->key,new)) - *new = NULL; -#else - (*new) = pthread_getspecific(key->key); -#endif - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_threadkey_private_set(void *priv, - apr_threadkey_t *key) -{ - apr_status_t stat; - - if ((stat = pthread_setspecific(key->key, priv)) == 0) { - return APR_SUCCESS; - } - else { - return stat; - } -} - -APR_DECLARE(apr_status_t) apr_threadkey_private_delete(apr_threadkey_t *key) -{ -#ifdef HAVE_PTHREAD_KEY_DELETE - apr_status_t stat; - - if ((stat = pthread_key_delete(key->key)) == 0) { - return APR_SUCCESS; - } - - return stat; -#else - return APR_ENOTIMPL; -#endif -} - -APR_DECLARE(apr_status_t) apr_threadkey_data_get(void **data, const char *key, - apr_threadkey_t *threadkey) -{ - return apr_pool_userdata_get(data, key, threadkey->pool); -} - -APR_DECLARE(apr_status_t) apr_threadkey_data_set(void *data, const char *key, - apr_status_t (*cleanup)(void *), - apr_threadkey_t *threadkey) -{ - return apr_pool_userdata_set(data, key, cleanup, threadkey->pool); -} - -APR_DECLARE(apr_status_t) apr_os_threadkey_get(apr_os_threadkey_t *thekey, - apr_threadkey_t *key) -{ - *thekey = key->key; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_threadkey_put(apr_threadkey_t **key, - apr_os_threadkey_t *thekey, - apr_pool_t *pool) -{ - if (pool == NULL) { - return APR_ENOPOOL; - } - - if ((*key) == NULL) { - (*key) = (apr_threadkey_t *)apr_pcalloc(pool, sizeof(apr_threadkey_t)); - (*key)->pool = pool; - } - - (*key)->key = *thekey; - return APR_SUCCESS; -} -#endif /* APR_HAVE_PTHREAD_H */ -#endif /* APR_HAS_THREADS */ - -#if !APR_HAS_THREADS - -/* avoid warning for no prototype */ -APR_DECLARE(apr_status_t) apr_os_threadkey_get(void); - -APR_DECLARE(apr_status_t) apr_os_threadkey_get(void) -{ - return APR_ENOTIMPL; -} - -#endif diff --git a/libs/apr/threadproc/win32/proc.c b/libs/apr/threadproc/win32/proc.c deleted file mode 100644 index 79a2fd16..00000000 --- a/libs/apr/threadproc/win32/proc.c +++ /dev/null @@ -1,1149 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_threadproc.h" -#include "apr_arch_file_io.h" - -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_lib.h" -#include -#if APR_HAVE_SIGNAL_H -#include -#endif -#include -#if APR_HAVE_PROCESS_H -#include -#endif - -/* Heavy on no'ops, here's what we want to pass if there is APR_NO_FILE - * requested for a specific child handle; - */ -static apr_file_t no_file = { NULL, INVALID_HANDLE_VALUE, }; - -/* We have very carefully excluded volumes of definitions from the - * Microsoft Platform SDK, which kill the build time performance. - * These the sole constants we borrow from WinBase.h and WinUser.h - */ -#ifndef LOGON32_LOGON_NETWORK -#define LOGON32_LOGON_NETWORK 3 -#endif - -#ifdef _WIN32_WCE -#ifndef DETACHED_PROCESS -#define DETACHED_PROCESS 0 -#endif -#ifndef CREATE_UNICODE_ENVIRONMENT -#define CREATE_UNICODE_ENVIRONMENT 0 -#endif -#ifndef STARTF_USESHOWWINDOW -#define STARTF_USESHOWWINDOW 0 -#endif -#ifndef SW_HIDE -#define SW_HIDE 0 -#endif -#endif - -/* - * some of the ideas expressed herein are based off of Microsoft - * Knowledge Base article: Q190351 - * - */ -APR_DECLARE(apr_status_t) apr_procattr_create(apr_procattr_t **new, - apr_pool_t *pool) -{ - (*new) = (apr_procattr_t *)apr_pcalloc(pool, sizeof(apr_procattr_t)); - (*new)->pool = pool; - (*new)->cmdtype = APR_PROGRAM; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, - apr_int32_t in, - apr_int32_t out, - apr_int32_t err) -{ - apr_status_t stat = APR_SUCCESS; - - if (in) { - /* APR_CHILD_BLOCK maps to APR_WRITE_BLOCK, while - * APR_PARENT_BLOCK maps to APR_READ_BLOCK, so transpose - * the CHILD/PARENT blocking flags for the stdin pipe. - * stdout/stderr map to the correct mode by default. - */ - if (in == APR_CHILD_BLOCK) - in = APR_READ_BLOCK; - else if (in == APR_PARENT_BLOCK) - in = APR_WRITE_BLOCK; - - if (in == APR_NO_FILE) - attr->child_in = &no_file; - else { - stat = apr_file_pipe_create_ex(&attr->child_in, &attr->parent_in, - in, attr->pool); - } - if (stat == APR_SUCCESS) - stat = apr_file_inherit_unset(attr->parent_in); - } - if (out && stat == APR_SUCCESS) { - if (out == APR_NO_FILE) - attr->child_out = &no_file; - else { - stat = apr_file_pipe_create_ex(&attr->parent_out, &attr->child_out, - out, attr->pool); - } - if (stat == APR_SUCCESS) - stat = apr_file_inherit_unset(attr->parent_out); - } - if (err && stat == APR_SUCCESS) { - if (err == APR_NO_FILE) - attr->child_err = &no_file; - else { - stat = apr_file_pipe_create_ex(&attr->parent_err, &attr->child_err, - err, attr->pool); - } - if (stat == APR_SUCCESS) - stat = apr_file_inherit_unset(attr->parent_err); - } - return stat; -} - -APR_DECLARE(apr_status_t) apr_procattr_child_in_set(apr_procattr_t *attr, - apr_file_t *child_in, - apr_file_t *parent_in) -{ - apr_status_t rv = APR_SUCCESS; - - if (child_in) { - if ((attr->child_in == NULL) || (attr->child_in == &no_file)) - rv = apr_file_dup(&attr->child_in, child_in, attr->pool); - else - rv = apr_file_dup2(attr->child_in, child_in, attr->pool); - - if (rv == APR_SUCCESS) - rv = apr_file_inherit_set(attr->child_in); - } - - if (parent_in && rv == APR_SUCCESS) { - if (attr->parent_in == NULL) - rv = apr_file_dup(&attr->parent_in, parent_in, attr->pool); - else - rv = apr_file_dup2(attr->parent_in, parent_in, attr->pool); - } - - return rv; -} - -APR_DECLARE(apr_status_t) apr_procattr_child_out_set(apr_procattr_t *attr, - apr_file_t *child_out, - apr_file_t *parent_out) -{ - apr_status_t rv = APR_SUCCESS; - - if (child_out) { - if ((attr->child_out == NULL) || (attr->child_out == &no_file)) - rv = apr_file_dup(&attr->child_out, child_out, attr->pool); - else - rv = apr_file_dup2(attr->child_out, child_out, attr->pool); - - if (rv == APR_SUCCESS) - rv = apr_file_inherit_set(attr->child_out); - } - - if (parent_out && rv == APR_SUCCESS) { - if (attr->parent_out == NULL) - rv = apr_file_dup(&attr->parent_out, parent_out, attr->pool); - else - rv = apr_file_dup2(attr->parent_out, parent_out, attr->pool); - } - - return rv; -} - -APR_DECLARE(apr_status_t) apr_procattr_child_err_set(apr_procattr_t *attr, - apr_file_t *child_err, - apr_file_t *parent_err) -{ - apr_status_t rv = APR_SUCCESS; - - if (child_err) { - if ((attr->child_err == NULL) || (attr->child_err == &no_file)) - rv = apr_file_dup(&attr->child_err, child_err, attr->pool); - else - rv = apr_file_dup2(attr->child_err, child_err, attr->pool); - - if (rv == APR_SUCCESS) - rv = apr_file_inherit_set(attr->child_err); - } - - if (parent_err && rv == APR_SUCCESS) { - if (attr->parent_err == NULL) - rv = apr_file_dup(&attr->parent_err, parent_err, attr->pool); - else - rv = apr_file_dup2(attr->parent_err, parent_err, attr->pool); - } - - return rv; -} - -APR_DECLARE(apr_status_t) apr_procattr_dir_set(apr_procattr_t *attr, - const char *dir) -{ - /* curr dir must be in native format, there are all sorts of bugs in - * the NT library loading code that flunk the '/' parsing test. - */ - return apr_filepath_merge(&attr->currdir, NULL, dir, - APR_FILEPATH_NATIVE, attr->pool); -} - -APR_DECLARE(apr_status_t) apr_procattr_cmdtype_set(apr_procattr_t *attr, - apr_cmdtype_e cmd) -{ - attr->cmdtype = cmd; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_detach_set(apr_procattr_t *attr, - apr_int32_t det) -{ - attr->detached = det; - return APR_SUCCESS; -} - -#ifndef _WIN32_WCE -static apr_status_t attr_cleanup(void *theattr) -{ - apr_procattr_t *attr = (apr_procattr_t *)theattr; - if (attr->user_token) - CloseHandle(attr->user_token); - attr->user_token = NULL; - return APR_SUCCESS; -} -#endif - -APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr, - const char *username, - const char *password) -{ -#ifdef _WIN32_WCE - return APR_ENOTIMPL; -#else - HANDLE user; - apr_wchar_t *wusername = NULL; - apr_wchar_t *wpassword = NULL; - apr_status_t rv; - apr_size_t len, wlen; - - if (apr_os_level >= APR_WIN_NT_4) - { - if (attr->user_token) { - /* Cannot set that twice */ - if (attr->errfn) { - attr->errfn(attr->pool, 0, - apr_pstrcat(attr->pool, - "function called twice" - " on username: ", username, NULL)); - } - return APR_EINVAL; - } - len = strlen(username) + 1; - wlen = len; - wusername = apr_palloc(attr->pool, wlen * sizeof(apr_wchar_t)); - if ((rv = apr_conv_utf8_to_ucs2(username, &len, wusername, &wlen)) - != APR_SUCCESS) { - if (attr->errfn) { - attr->errfn(attr->pool, rv, - apr_pstrcat(attr->pool, - "utf8 to ucs2 conversion failed" - " on username: ", username, NULL)); - } - return rv; - } - if (password) { - len = strlen(password) + 1; - wlen = len; - wpassword = apr_palloc(attr->pool, wlen * sizeof(apr_wchar_t)); - if ((rv = apr_conv_utf8_to_ucs2(password, &len, wpassword, &wlen)) - != APR_SUCCESS) { - if (attr->errfn) { - attr->errfn(attr->pool, rv, - apr_pstrcat(attr->pool, - "utf8 to ucs2 conversion failed" - " on password: ", password, NULL)); - } - return rv; - } - } - if (!LogonUserW(wusername, - NULL, - wpassword ? wpassword : L"", - LOGON32_LOGON_NETWORK, - LOGON32_PROVIDER_DEFAULT, - &user)) { - /* Logon Failed */ - return apr_get_os_error(); - } - if (wpassword) - memset(wpassword, 0, wlen * sizeof(apr_wchar_t)); - /* Get the primary token for user */ - if (!DuplicateTokenEx(user, - TOKEN_QUERY | TOKEN_DUPLICATE | TOKEN_ASSIGN_PRIMARY, - NULL, - SecurityImpersonation, - TokenPrimary, - &(attr->user_token))) { - /* Failed to duplicate the user token */ - rv = apr_get_os_error(); - CloseHandle(user); - return rv; - } - CloseHandle(user); - - attr->sd = apr_pcalloc(attr->pool, SECURITY_DESCRIPTOR_MIN_LENGTH); - InitializeSecurityDescriptor(attr->sd, SECURITY_DESCRIPTOR_REVISION); - SetSecurityDescriptorDacl(attr->sd, -1, 0, 0); - attr->sa = apr_palloc(attr->pool, sizeof(SECURITY_ATTRIBUTES)); - attr->sa->nLength = sizeof (SECURITY_ATTRIBUTES); - attr->sa->lpSecurityDescriptor = attr->sd; - attr->sa->bInheritHandle = FALSE; - - /* register the cleanup */ - apr_pool_cleanup_register(attr->pool, (void *)attr, - attr_cleanup, - apr_pool_cleanup_null); - return APR_SUCCESS; - } - else - return APR_ENOTIMPL; -#endif -} - -APR_DECLARE(apr_status_t) apr_procattr_group_set(apr_procattr_t *attr, - const char *groupname) -{ - /* Always return SUCCESS cause groups are irrelevant */ - return APR_SUCCESS; -} - -static const char* has_space(const char *str) -{ - const char *ch; - for (ch = str; *ch; ++ch) { - if (apr_isspace(*ch)) { - return ch; - } - } - return NULL; -} - -static char *apr_caret_escape_args(apr_pool_t *p, const char *str) -{ - char *cmd; - unsigned char *d; - const unsigned char *s; - - cmd = apr_palloc(p, 2 * strlen(str) + 1); /* Be safe */ - d = (unsigned char *)cmd; - s = (const unsigned char *)str; - for (; *s; ++s) { - - /* - * Newlines to Win32/OS2 CreateProcess() are ill advised. - * Convert them to spaces since they are effectively white - * space to most applications - */ - if (*s == '\r' || *s == '\n') { - *d++ = ' '; - continue; - } - - if (IS_SHCHAR(*s)) { - *d++ = '^'; - } - *d++ = *s; - } - *d = '\0'; - - return cmd; -} - -APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr, - apr_child_errfn_t *errfn) -{ - attr->errfn = errfn; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr, - apr_int32_t chk) -{ - attr->errchk = chk; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_procattr_addrspace_set(apr_procattr_t *attr, - apr_int32_t addrspace) -{ - /* won't ever be used on this platform, so don't save the flag */ - return APR_SUCCESS; -} - -#if APR_HAS_UNICODE_FS && !defined(_WIN32_WCE) - -/* Used only for the NT code path, a critical section is the fastest - * implementation available. - */ -static CRITICAL_SECTION proc_lock; - -static apr_status_t threadproc_global_cleanup(void *ignored) -{ - DeleteCriticalSection(&proc_lock); - return APR_SUCCESS; -} - -/* Called from apr_initialize, we need a critical section to handle - * the pipe inheritance on win32. This will mutex any process create - * so as we change our inherited pipes, we prevent another process from - * also inheriting those alternate handles, and prevent the other process - * from failing to inherit our standard handles. - */ -apr_status_t apr_threadproc_init(apr_pool_t *pool) -{ - IF_WIN_OS_IS_UNICODE - { - InitializeCriticalSection(&proc_lock); - /* register the cleanup */ - apr_pool_cleanup_register(pool, &proc_lock, - threadproc_global_cleanup, - apr_pool_cleanup_null); - } - return APR_SUCCESS; -} - -#else /* !APR_HAS_UNICODE_FS || defined(_WIN32_WCE) */ - -apr_status_t apr_threadproc_init(apr_pool_t *pool) -{ - return APR_SUCCESS; -} - -#endif - -APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, - const char *progname, - const char * const *args, - const char * const *env, - apr_procattr_t *attr, - apr_pool_t *pool) -{ - apr_status_t rv; - apr_size_t i; - const char *argv0; - char *cmdline; - char *pEnvBlock; - PROCESS_INFORMATION pi; - DWORD dwCreationFlags = 0; - - new->in = attr->parent_in; - new->out = attr->parent_out; - new->err = attr->parent_err; - - if (attr->detached) { - /* If we are creating ourselves detached, Then we should hide the - * window we are starting in. And we had better redfine our - * handles for STDIN, STDOUT, and STDERR. Do not set the - * detached attribute for Win9x. We have found that Win9x does - * not manage the stdio handles properly when running old 16 - * bit executables if the detached attribute is set. - */ - if (apr_os_level >= APR_WIN_NT) { - /* - * XXX DETACHED_PROCESS won't on Win9x at all; on NT/W2K - * 16 bit executables fail (MS KB: Q150956) - */ - dwCreationFlags |= DETACHED_PROCESS; - } - } - - /* progname must be unquoted, in native format, as there are all sorts - * of bugs in the NT library loader code that fault when parsing '/'. - * XXX progname must be NULL if this is a 16 bit app running in WOW - */ - if (progname[0] == '\"') { - progname = apr_pstrndup(pool, progname + 1, strlen(progname) - 2); - } - - if (attr->cmdtype == APR_PROGRAM || attr->cmdtype == APR_PROGRAM_ENV) { - char *fullpath = NULL; - if ((rv = apr_filepath_merge(&fullpath, attr->currdir, progname, - APR_FILEPATH_NATIVE, pool)) != APR_SUCCESS) { - if (attr->errfn) { - attr->errfn(pool, rv, - apr_pstrcat(pool, "filepath_merge failed.", - " currdir: ", attr->currdir, - " progname: ", progname, NULL)); - } - return rv; - } - progname = fullpath; - } - else { - /* Do not fail if the path isn't parseable for APR_PROGRAM_PATH - * or APR_SHELLCMD. We only invoke apr_filepath_merge (with no - * left hand side expression) in order to correct the path slash - * delimiters. But the filename doesn't need to be in the CWD, - * nor does it need to be a filename at all (it could be a - * built-in shell command.) - */ - char *fullpath = NULL; - if ((rv = apr_filepath_merge(&fullpath, "", progname, - APR_FILEPATH_NATIVE, pool)) == APR_SUCCESS) { - progname = fullpath; - } - } - - if (has_space(progname)) { - argv0 = apr_pstrcat(pool, "\"", progname, "\"", NULL); - } - else { - argv0 = progname; - } - - /* Handle the args, seperate from argv0 */ - cmdline = ""; - for (i = 1; args && args[i]; ++i) { - if (has_space(args[i]) || !args[i][0]) { - cmdline = apr_pstrcat(pool, cmdline, " \"", args[i], "\"", NULL); - } - else { - cmdline = apr_pstrcat(pool, cmdline, " ", args[i], NULL); - } - } - -#ifndef _WIN32_WCE - if (attr->cmdtype == APR_SHELLCMD || attr->cmdtype == APR_SHELLCMD_ENV) { - char *shellcmd = getenv("COMSPEC"); - if (!shellcmd) { - if (attr->errfn) { - attr->errfn(pool, APR_EINVAL, "COMSPEC envar is not set"); - } - return APR_EINVAL; - } - if (shellcmd[0] == '"') { - progname = apr_pstrndup(pool, shellcmd + 1, strlen(shellcmd) - 2); - } - else { - progname = shellcmd; - if (has_space(shellcmd)) { - shellcmd = apr_pstrcat(pool, "\"", shellcmd, "\"", NULL); - } - } - /* Command.com does not support a quoted command, while cmd.exe demands one. - */ - i = strlen(progname); - if (i >= 11 && strcasecmp(progname + i - 11, "command.com") == 0) { - cmdline = apr_pstrcat(pool, shellcmd, " /C ", argv0, cmdline, NULL); - } - else { - cmdline = apr_pstrcat(pool, shellcmd, " /C \"", argv0, cmdline, "\"", NULL); - } - } - else -#endif - { -#if defined(_WIN32_WCE) - { -#else - /* Win32 is _different_ than unix. While unix will find the given - * program since it's already chdir'ed, Win32 cannot since the parent - * attempts to open the program with it's own path. - * ###: This solution isn't much better - it may defeat path searching - * when the path search was desired. Open to further discussion. - */ - i = strlen(progname); - if (i >= 4 && (strcasecmp(progname + i - 4, ".bat") == 0 - || strcasecmp(progname + i - 4, ".cmd") == 0)) - { - char *shellcmd = getenv("COMSPEC"); - if (!shellcmd) { - if (attr->errfn) { - attr->errfn(pool, APR_EINVAL, "COMSPEC envar is not set"); - } - return APR_EINVAL; - } - if (shellcmd[0] == '"') { - progname = apr_pstrndup(pool, shellcmd + 1, strlen(shellcmd) - 2); - } - else { - progname = shellcmd; - if (has_space(shellcmd)) { - shellcmd = apr_pstrcat(pool, "\"", shellcmd, "\"", NULL); - } - } - i = strlen(progname); - if (i >= 11 && strcasecmp(progname + i - 11, "command.com") == 0) { - /* XXX: Still insecure - need doubled-quotes on each individual - * arg of cmdline. Suspect we need to postpone cmdline parsing - * until this moment in all four code paths, with some flags - * to toggle 'which flavor' is needed. - */ - cmdline = apr_pstrcat(pool, shellcmd, " /C ", argv0, cmdline, NULL); - } - else { - /* We must protect the cmdline args from any interpolation - this - * is not a shellcmd, and the source of argv[] is untrusted. - * Notice we escape ALL the cmdline args, including the quotes - * around the individual args themselves. No sense in allowing - * the shift-state to be toggled, and the application will - * not see the caret escapes. - */ - cmdline = apr_caret_escape_args(pool, cmdline); - /* - * Our app name must always be quoted so the quotes surrounding - * the entire /c "command args" are unambigious. - */ - if (*argv0 != '"') { - cmdline = apr_pstrcat(pool, shellcmd, " /C \"\"", argv0, "\"", cmdline, "\"", NULL); - } - else { - cmdline = apr_pstrcat(pool, shellcmd, " /C \"", argv0, cmdline, "\"", NULL); - } - } - } - else { -#endif - /* A simple command we are directly invoking. Do not pass - * the first arg to CreateProc() for APR_PROGRAM_PATH - * invocation, since it would need to be a literal and - * complete file path. That is; "c:\bin\aprtest.exe" - * would succeed, but "c:\bin\aprtest" or "aprtest.exe" - * can fail. - */ - cmdline = apr_pstrcat(pool, argv0, cmdline, NULL); - - if (attr->cmdtype == APR_PROGRAM_PATH) { - progname = NULL; - } - } - } - - if (!env || attr->cmdtype == APR_PROGRAM_ENV || - attr->cmdtype == APR_SHELLCMD_ENV) { - pEnvBlock = NULL; - } - else { - apr_size_t iEnvBlockLen; - /* - * Win32's CreateProcess call requires that the environment - * be passed in an environment block, a null terminated block of - * null terminated strings. - */ - i = 0; - iEnvBlockLen = 1; - while (env[i]) { - iEnvBlockLen += strlen(env[i]) + 1; - i++; - } - if (!i) - ++iEnvBlockLen; - -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - apr_wchar_t *pNext; - pEnvBlock = (char *)apr_palloc(pool, iEnvBlockLen * 2); - dwCreationFlags |= CREATE_UNICODE_ENVIRONMENT; - - i = 0; - pNext = (apr_wchar_t*)pEnvBlock; - while (env[i]) { - apr_size_t in = strlen(env[i]) + 1; - if ((rv = apr_conv_utf8_to_ucs2(env[i], &in, - pNext, &iEnvBlockLen)) - != APR_SUCCESS) { - if (attr->errfn) { - attr->errfn(pool, rv, - apr_pstrcat(pool, - "utf8 to ucs2 conversion failed" - " on this string: ", env[i], NULL)); - } - return rv; - } - pNext = wcschr(pNext, L'\0') + 1; - i++; - } - if (!i) - *(pNext++) = L'\0'; - *pNext = L'\0'; - } -#endif /* APR_HAS_UNICODE_FS */ -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - char *pNext; - pEnvBlock = (char *)apr_palloc(pool, iEnvBlockLen); - - i = 0; - pNext = pEnvBlock; - while (env[i]) { - strcpy(pNext, env[i]); - pNext = strchr(pNext, '\0') + 1; - i++; - } - if (!i) - *(pNext++) = '\0'; - *pNext = '\0'; - } -#endif /* APR_HAS_ANSI_FS */ - } - - new->invoked = cmdline; - -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - STARTUPINFOW si; - DWORD stdin_reset = 0; - DWORD stdout_reset = 0; - DWORD stderr_reset = 0; - apr_wchar_t *wprg = NULL; - apr_wchar_t *wcmd = NULL; - apr_wchar_t *wcwd = NULL; - - if (progname) { - apr_size_t nprg = strlen(progname) + 1; - apr_size_t nwprg = nprg + 6; - wprg = apr_palloc(pool, nwprg * sizeof(wprg[0])); - if ((rv = apr_conv_utf8_to_ucs2(progname, &nprg, wprg, &nwprg)) - != APR_SUCCESS) { - if (attr->errfn) { - attr->errfn(pool, rv, - apr_pstrcat(pool, - "utf8 to ucs2 conversion failed" - " on progname: ", progname, NULL)); - } - return rv; - } - } - - if (cmdline) { - apr_size_t ncmd = strlen(cmdline) + 1; - apr_size_t nwcmd = ncmd; - wcmd = apr_palloc(pool, nwcmd * sizeof(wcmd[0])); - if ((rv = apr_conv_utf8_to_ucs2(cmdline, &ncmd, wcmd, &nwcmd)) - != APR_SUCCESS) { - if (attr->errfn) { - attr->errfn(pool, rv, - apr_pstrcat(pool, - "utf8 to ucs2 conversion failed" - " on cmdline: ", cmdline, NULL)); - } - return rv; - } - } - - if (attr->currdir) - { - apr_size_t ncwd = strlen(attr->currdir) + 1; - apr_size_t nwcwd = ncwd; - wcwd = apr_palloc(pool, ncwd * sizeof(wcwd[0])); - if ((rv = apr_conv_utf8_to_ucs2(attr->currdir, &ncwd, - wcwd, &nwcwd)) - != APR_SUCCESS) { - if (attr->errfn) { - attr->errfn(pool, rv, - apr_pstrcat(pool, - "utf8 to ucs2 conversion failed" - " on currdir: ", attr->currdir, NULL)); - } - return rv; - } - } - - memset(&si, 0, sizeof(si)); - si.cb = sizeof(si); - - if (attr->detached) { - si.dwFlags |= STARTF_USESHOWWINDOW; - si.wShowWindow = SW_HIDE; - } - -#ifndef _WIN32_WCE - /* LOCK CRITICAL SECTION - * before we begin to manipulate the inherited handles - */ - EnterCriticalSection(&proc_lock); - - if ((attr->child_in && attr->child_in->filehand) - || (attr->child_out && attr->child_out->filehand) - || (attr->child_err && attr->child_err->filehand)) - { - si.dwFlags |= STARTF_USESTDHANDLES; - - si.hStdInput = GetStdHandle(STD_INPUT_HANDLE); - if (attr->child_in && attr->child_in->filehand) - { - if (GetHandleInformation(si.hStdInput, - &stdin_reset) - && (stdin_reset &= HANDLE_FLAG_INHERIT)) - SetHandleInformation(si.hStdInput, - HANDLE_FLAG_INHERIT, 0); - - if ( (si.hStdInput = attr->child_in->filehand) - != INVALID_HANDLE_VALUE ) - SetHandleInformation(si.hStdInput, HANDLE_FLAG_INHERIT, - HANDLE_FLAG_INHERIT); - } - - si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); - if (attr->child_out && attr->child_out->filehand) - { - if (GetHandleInformation(si.hStdOutput, - &stdout_reset) - && (stdout_reset &= HANDLE_FLAG_INHERIT)) - SetHandleInformation(si.hStdOutput, - HANDLE_FLAG_INHERIT, 0); - - if ( (si.hStdOutput = attr->child_out->filehand) - != INVALID_HANDLE_VALUE ) - SetHandleInformation(si.hStdOutput, HANDLE_FLAG_INHERIT, - HANDLE_FLAG_INHERIT); - } - - si.hStdError = GetStdHandle(STD_ERROR_HANDLE); - if (attr->child_err && attr->child_err->filehand) - { - if (GetHandleInformation(si.hStdError, - &stderr_reset) - && (stderr_reset &= HANDLE_FLAG_INHERIT)) - SetHandleInformation(si.hStdError, - HANDLE_FLAG_INHERIT, 0); - - if ( (si.hStdError = attr->child_err->filehand) - != INVALID_HANDLE_VALUE ) - SetHandleInformation(si.hStdError, HANDLE_FLAG_INHERIT, - HANDLE_FLAG_INHERIT); - } - } - if (attr->user_token) { - /* XXX: for terminal services, handles can't be cannot be - * inherited across sessions. This process must be created - * in our existing session. lpDesktop assignment appears - * to be wrong according to these rules. - */ - si.lpDesktop = L"Winsta0\\Default"; - if (!ImpersonateLoggedOnUser(attr->user_token)) { - /* failed to impersonate the logged user */ - rv = apr_get_os_error(); - CloseHandle(attr->user_token); - attr->user_token = NULL; - return rv; - } - rv = CreateProcessAsUserW(attr->user_token, - wprg, wcmd, - attr->sa, - NULL, - TRUE, - dwCreationFlags, - pEnvBlock, - wcwd, - &si, &pi); - - RevertToSelf(); - } - else { - rv = CreateProcessW(wprg, wcmd, /* Executable & Command line */ - NULL, NULL, /* Proc & thread security attributes */ - TRUE, /* Inherit handles */ - dwCreationFlags, /* Creation flags */ - pEnvBlock, /* Environment block */ - wcwd, /* Current directory name */ - &si, &pi); - } - - if ((attr->child_in && attr->child_in->filehand) - || (attr->child_out && attr->child_out->filehand) - || (attr->child_err && attr->child_err->filehand)) - { - if (stdin_reset) - SetHandleInformation(GetStdHandle(STD_INPUT_HANDLE), - stdin_reset, stdin_reset); - - if (stdout_reset) - SetHandleInformation(GetStdHandle(STD_OUTPUT_HANDLE), - stdout_reset, stdout_reset); - - if (stderr_reset) - SetHandleInformation(GetStdHandle(STD_ERROR_HANDLE), - stderr_reset, stderr_reset); - } - /* RELEASE CRITICAL SECTION - * The state of the inherited handles has been restored. - */ - LeaveCriticalSection(&proc_lock); - -#else /* defined(_WIN32_WCE) */ - rv = CreateProcessW(wprg, wcmd, /* Executable & Command line */ - NULL, NULL, /* Proc & thread security attributes */ - FALSE, /* must be 0 */ - dwCreationFlags, /* Creation flags */ - NULL, /* Environment block must be NULL */ - NULL, /* Current directory name must be NULL*/ - NULL, /* STARTUPINFO not supported */ - &pi); -#endif - } -#endif /* APR_HAS_UNICODE_FS */ -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - STARTUPINFOA si; - memset(&si, 0, sizeof(si)); - si.cb = sizeof(si); - - if (attr->detached) { - si.dwFlags |= STARTF_USESHOWWINDOW; - si.wShowWindow = SW_HIDE; - } - - if ((attr->child_in && attr->child_in->filehand) - || (attr->child_out && attr->child_out->filehand) - || (attr->child_err && attr->child_err->filehand)) - { - si.dwFlags |= STARTF_USESTDHANDLES; - - si.hStdInput = (attr->child_in) - ? attr->child_in->filehand - : GetStdHandle(STD_INPUT_HANDLE); - - si.hStdOutput = (attr->child_out) - ? attr->child_out->filehand - : GetStdHandle(STD_OUTPUT_HANDLE); - - si.hStdError = (attr->child_err) - ? attr->child_err->filehand - : GetStdHandle(STD_ERROR_HANDLE); - } - - rv = CreateProcessA(progname, cmdline, /* Command line */ - NULL, NULL, /* Proc & thread security attributes */ - TRUE, /* Inherit handles */ - dwCreationFlags, /* Creation flags */ - pEnvBlock, /* Environment block */ - attr->currdir, /* Current directory name */ - &si, &pi); - } -#endif /* APR_HAS_ANSI_FS */ - - /* Check CreateProcess result - */ - if (!rv) - return apr_get_os_error(); - - /* XXX Orphaned handle warning - no fix due to broken apr_proc_t api. - */ - new->hproc = pi.hProcess; - new->pid = pi.dwProcessId; - - if ((attr->child_in) && (attr->child_in != &no_file)) { - apr_file_close(attr->child_in); - } - if ((attr->child_out) && (attr->child_out != &no_file)) { - apr_file_close(attr->child_out); - } - if ((attr->child_err) && (attr->child_err != &no_file)) { - apr_file_close(attr->child_err); - } - CloseHandle(pi.hThread); - - return APR_SUCCESS; -} - -static apr_exit_why_e why_from_exit_code(DWORD exit) { - /* See WinNT.h STATUS_ACCESS_VIOLATION and family for how - * this class of failures was determined - */ - if (((exit & 0xC0000000) == 0xC0000000) - && !(exit & 0x3FFF0000)) - return APR_PROC_SIGNAL; - else - return APR_PROC_EXIT; - - /* ### No way to tell if Dr Watson grabbed a core, AFAICT. */ -} - -APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc, - int *exitcode, - apr_exit_why_e *exitwhy, - apr_wait_how_e waithow, - apr_pool_t *p) -{ -#if APR_HAS_UNICODE_FS -#ifndef _WIN32_WCE - IF_WIN_OS_IS_UNICODE - { - DWORD dwId = GetCurrentProcessId(); - DWORD i; - DWORD nChilds = 0; - DWORD nActive = 0; - HANDLE ps32; - PROCESSENTRY32W pe32; - BOOL bHasMore = FALSE; - DWORD dwFlags = PROCESS_QUERY_INFORMATION; - apr_status_t rv = APR_EGENERAL; - - if (waithow == APR_WAIT) - dwFlags |= SYNCHRONIZE; - if (!(ps32 = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0))) { - return apr_get_os_error(); - } - pe32.dwSize = sizeof(PROCESSENTRY32W); - if (!Process32FirstW(ps32, &pe32)) { - if (GetLastError() == ERROR_NO_MORE_FILES) - return APR_EOF; - else - return apr_get_os_error(); - } - do { - DWORD dwRetval = 0; - DWORD nHandles = 0; - HANDLE hProcess = NULL; - HANDLE pHandles[MAXIMUM_WAIT_OBJECTS]; - do { - if (pe32.th32ParentProcessID == dwId) { - nChilds++; - if ((hProcess = OpenProcess(dwFlags, FALSE, - pe32.th32ProcessID)) != NULL) { - if (GetExitCodeProcess(hProcess, &dwRetval)) { - if (dwRetval == STILL_ACTIVE) { - nActive++; - if (waithow == APR_WAIT) - pHandles[nHandles++] = hProcess; - else - CloseHandle(hProcess); - } - else { - /* Process has exited. - * No need to wait for its termination. - */ - CloseHandle(hProcess); - if (exitcode) - *exitcode = dwRetval; - if (exitwhy) - *exitwhy = why_from_exit_code(dwRetval); - proc->pid = pe32.th32ProcessID; - } - } - else { - /* Unexpected error code. - * Cleanup and return; - */ - rv = apr_get_os_error(); - CloseHandle(hProcess); - for (i = 0; i < nHandles; i++) - CloseHandle(pHandles[i]); - return rv; - } - } - else { - /* This is our child, so it shouldn't happen - * that we cannot open our child's process handle. - * However if the child process increased the - * security token it might fail. - */ - } - } - } while ((bHasMore = Process32NextW(ps32, &pe32)) && - nHandles < MAXIMUM_WAIT_OBJECTS); - if (nHandles) { - /* Wait for all collected processes to finish */ - DWORD waitStatus = WaitForMultipleObjects(nHandles, pHandles, - TRUE, INFINITE); - for (i = 0; i < nHandles; i++) - CloseHandle(pHandles[i]); - if (waitStatus == WAIT_OBJECT_0) { - /* Decrease active count by the number of awaited - * processes. - */ - nActive -= nHandles; - } - else { - /* Broken from the infinite loop */ - break; - } - } - } while (bHasMore); - CloseHandle(ps32); - if (waithow != APR_WAIT) { - if (nChilds && nChilds == nActive) { - /* All child processes are running */ - rv = APR_CHILD_NOTDONE; - proc->pid = -1; - } - else { - /* proc->pid contains the pid of the - * exited processes - */ - rv = APR_CHILD_DONE; - } - } - if (nActive == 0) { - rv = APR_CHILD_DONE; - proc->pid = -1; - } - return rv; - } -#endif /* _WIN32_WCE */ -#endif /* APR_HAS_UNICODE_FS */ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, - int *exitcode, apr_exit_why_e *exitwhy, - apr_wait_how_e waithow) -{ - DWORD stat; - DWORD time; - - if (waithow == APR_WAIT) - time = INFINITE; - else - time = 0; - - if ((stat = WaitForSingleObject(proc->hproc, time)) == WAIT_OBJECT_0) { - if (GetExitCodeProcess(proc->hproc, &stat)) { - if (exitcode) - *exitcode = stat; - if (exitwhy) - *exitwhy = why_from_exit_code(stat); - CloseHandle(proc->hproc); - proc->hproc = NULL; - return APR_CHILD_DONE; - } - } - else if (stat == WAIT_TIMEOUT) { - return APR_CHILD_NOTDONE; - } - return apr_get_os_error(); -} - -APR_DECLARE(apr_status_t) apr_proc_detach(int daemonize) -{ - return APR_ENOTIMPL; -} diff --git a/libs/apr/threadproc/win32/signals.c b/libs/apr/threadproc/win32/signals.c deleted file mode 100644 index f19fb032..00000000 --- a/libs/apr/threadproc/win32/signals.c +++ /dev/null @@ -1,67 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_threadproc.h" -#include "apr_arch_file_io.h" -#include "apr_thread_proc.h" -#include "apr_signal.h" -#include "apr_file_io.h" -#include "apr_general.h" -#if APR_HAVE_SIGNAL_H -#include -#endif -#include -#if APR_HAVE_SYS_WAIT -#include -#endif - -/* Windows only really support killing process, but that will do for now. - * - * ### Actually, closing the input handle to the proc should also do fine - * for most console apps. This definately needs improvement... - */ -APR_DECLARE(apr_status_t) apr_proc_kill(apr_proc_t *proc, int signal) -{ - if (proc->hproc != NULL) { - if (TerminateProcess(proc->hproc, signal) == 0) { - return apr_get_os_error(); - } - /* On unix, SIGKILL leaves a apr_proc_wait()able pid lying around, - * so we will leave hproc alone until the app calls apr_proc_wait(). - */ - return APR_SUCCESS; - } - return APR_EPROC_UNKNOWN; -} - -void apr_signal_init(apr_pool_t *pglobal) -{ -} - -APR_DECLARE(const char *) apr_signal_description_get(int signum) -{ - return "unknown signal (not supported)"; -} - -APR_DECLARE(apr_status_t) apr_signal_block(int signum) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_signal_unblock(int signum) -{ - return APR_ENOTIMPL; -} diff --git a/libs/apr/threadproc/win32/thread.c b/libs/apr/threadproc/win32/thread.c deleted file mode 100644 index 25034571..00000000 --- a/libs/apr/threadproc/win32/thread.c +++ /dev/null @@ -1,281 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_private.h" -#include "apr_arch_threadproc.h" -#include "apr_thread_proc.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_portable.h" -#if APR_HAVE_PROCESS_H -#include -#endif -#include "apr_arch_misc.h" - -/* Chosen for us by apr_initialize */ -DWORD tls_apr_thread = 0; - -APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new, - apr_pool_t *pool) -{ - (*new) = (apr_threadattr_t *)apr_palloc(pool, - sizeof(apr_threadattr_t)); - - if ((*new) == NULL) { - return APR_ENOMEM; - } - - (*new)->pool = pool; - (*new)->detach = 0; - (*new)->stacksize = 0; - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_threadattr_detach_set(apr_threadattr_t *attr, - apr_int32_t on) -{ - attr->detach = on; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr) -{ - if (attr->detach == 1) - return APR_DETACH; - return APR_NOTDETACH; -} - -APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, - apr_size_t stacksize) -{ - attr->stacksize = stacksize; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr, - apr_size_t size) -{ - return APR_ENOTIMPL; -} - -static void *dummy_worker(void *opaque) -{ - apr_thread_t *thd = (apr_thread_t *)opaque; - TlsSetValue(tls_apr_thread, thd->td); - return thd->func(thd, thd->data); -} - -APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, - apr_threadattr_t *attr, - apr_thread_start_t func, - void *data, apr_pool_t *pool) -{ - apr_status_t stat; - unsigned temp; - HANDLE handle; - - (*new) = (apr_thread_t *)apr_palloc(pool, sizeof(apr_thread_t)); - - if ((*new) == NULL) { - return APR_ENOMEM; - } - - (*new)->data = data; - (*new)->func = func; - (*new)->td = NULL; - stat = apr_pool_create(&(*new)->pool, pool); - if (stat != APR_SUCCESS) { - return stat; - } - - /* Use 0 for default Thread Stack Size, because that will - * default the stack to the same size as the calling thread. - */ -#ifndef _WIN32_WCE - if ((handle = (HANDLE)_beginthreadex(NULL, - (DWORD) (attr ? attr->stacksize : 0), - (unsigned int (APR_THREAD_FUNC *)(void *))dummy_worker, - (*new), 0, &temp)) == 0) { - return APR_FROM_OS_ERROR(_doserrno); - } -#else - if ((handle = CreateThread(NULL, - attr && attr->stacksize > 0 ? attr->stacksize : 0, - (unsigned int (APR_THREAD_FUNC *)(void *))dummy_worker, - (*new), 0, &temp)) == 0) { - return apr_get_os_error(); - } -#endif - if (attr && attr->detach) { - CloseHandle(handle); - } - else - (*new)->td = handle; - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_exit(apr_thread_t *thd, - apr_status_t retval) -{ - thd->exitval = retval; - apr_pool_destroy(thd->pool); - thd->pool = NULL; -#ifndef _WIN32_WCE - _endthreadex(0); -#else - ExitThread(0); -#endif - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_join(apr_status_t *retval, - apr_thread_t *thd) -{ - apr_status_t rv = APR_SUCCESS; - - if (!thd->td) { - /* Can not join on detached threads */ - return APR_DETACH; - } - rv = WaitForSingleObject(thd->td, INFINITE); - if ( rv == WAIT_OBJECT_0 || rv == WAIT_ABANDONED) { - /* If the thread_exit has been called */ - if (!thd->pool) - *retval = thd->exitval; - else - rv = APR_INCOMPLETE; - } - else - rv = apr_get_os_error(); - CloseHandle(thd->td); - thd->td = NULL; - - return rv; -} - -APR_DECLARE(apr_status_t) apr_thread_detach(apr_thread_t *thd) -{ - if (thd->td && CloseHandle(thd->td)) { - thd->td = NULL; - return APR_SUCCESS; - } - else { - return apr_get_os_error(); - } -} - -APR_DECLARE(void) apr_thread_yield() -{ - /* SwitchToThread is not supported on Win9x, but since it's - * primarily a noop (entering time consuming code, therefore - * providing more critical threads a bit larger timeslice) - * we won't worry too much if it's not available. - */ -#ifndef _WIN32_WCE - if (apr_os_level >= APR_WIN_NT) { - SwitchToThread(); - } -#endif -} - -APR_DECLARE(apr_status_t) apr_thread_data_get(void **data, const char *key, - apr_thread_t *thread) -{ - return apr_pool_userdata_get(data, key, thread->pool); -} - -APR_DECLARE(apr_status_t) apr_thread_data_set(void *data, const char *key, - apr_status_t (*cleanup) (void *), - apr_thread_t *thread) -{ - return apr_pool_userdata_set(data, key, cleanup, thread->pool); -} - - -APR_DECLARE(apr_os_thread_t) apr_os_thread_current(void) -{ - HANDLE hthread = (HANDLE)TlsGetValue(tls_apr_thread); - HANDLE hproc; - - if (hthread) { - return hthread; - } - - hproc = GetCurrentProcess(); - hthread = GetCurrentThread(); - if (!DuplicateHandle(hproc, hthread, - hproc, &hthread, 0, FALSE, - DUPLICATE_SAME_ACCESS)) { - return NULL; - } - TlsSetValue(tls_apr_thread, hthread); - return hthread; -} - -APR_DECLARE(apr_status_t) apr_os_thread_get(apr_os_thread_t **thethd, - apr_thread_t *thd) -{ - if (thd == NULL) { - return APR_ENOTHREAD; - } - *thethd = thd->td; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_thread_put(apr_thread_t **thd, - apr_os_thread_t *thethd, - apr_pool_t *pool) -{ - if (pool == NULL) { - return APR_ENOPOOL; - } - if ((*thd) == NULL) { - (*thd) = (apr_thread_t *)apr_palloc(pool, sizeof(apr_thread_t)); - (*thd)->pool = pool; - } - (*thd)->td = thethd; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_once_init(apr_thread_once_t **control, - apr_pool_t *p) -{ - (*control) = apr_pcalloc(p, sizeof(**control)); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_thread_once(apr_thread_once_t *control, - void (*func)(void)) -{ - if (!InterlockedExchange(&control->value, 1)) { - func(); - } - return APR_SUCCESS; -} - -APR_DECLARE(int) apr_os_thread_equal(apr_os_thread_t tid1, - apr_os_thread_t tid2) -{ - /* Since the only tid's we support our are own, and - * apr_os_thread_current returns the identical handle - * to the one we created initially, the test is simple. - */ - return (tid1 == tid2); -} - -APR_POOL_IMPLEMENT_ACCESSOR(thread) diff --git a/libs/apr/threadproc/win32/threadpriv.c b/libs/apr/threadproc/win32/threadpriv.c deleted file mode 100644 index 787c142c..00000000 --- a/libs/apr/threadproc/win32/threadpriv.c +++ /dev/null @@ -1,101 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_threadproc.h" -#include "apr_thread_proc.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_errno.h" -#include "apr_portable.h" - -APR_DECLARE(apr_status_t) apr_threadkey_private_create(apr_threadkey_t **key, - void (*dest)(void *), - apr_pool_t *pool) -{ - (*key) = (apr_threadkey_t *)apr_palloc(pool, sizeof(apr_threadkey_t)); - if ((*key) == NULL) { - return APR_ENOMEM; - } - - (*key)->pool = pool; - - if (((*key)->key = TlsAlloc()) != 0xFFFFFFFF) { - return APR_SUCCESS; - } - return apr_get_os_error(); -} - -APR_DECLARE(apr_status_t) apr_threadkey_private_get(void **new, - apr_threadkey_t *key) -{ - if (((*new) = TlsGetValue(key->key))) { - return APR_SUCCESS; - } - return apr_get_os_error(); -} - -APR_DECLARE(apr_status_t) apr_threadkey_private_set(void *priv, - apr_threadkey_t *key) -{ - if (TlsSetValue(key->key, priv)) { - return APR_SUCCESS; - } - return apr_get_os_error(); -} - -APR_DECLARE(apr_status_t) apr_threadkey_private_delete(apr_threadkey_t *key) -{ - if (TlsFree(key->key)) { - return APR_SUCCESS; - } - return apr_get_os_error(); -} - -APR_DECLARE(apr_status_t) apr_threadkey_data_get(void **data, const char *key, - apr_threadkey_t *threadkey) -{ - return apr_pool_userdata_get(data, key, threadkey->pool); -} - -APR_DECLARE(apr_status_t) apr_threadkey_data_set(void *data, const char *key, - apr_status_t (*cleanup)(void *), - apr_threadkey_t *threadkey) -{ - return apr_pool_userdata_set(data, key, cleanup, threadkey->pool); -} - -APR_DECLARE(apr_status_t) apr_os_threadkey_get(apr_os_threadkey_t *thekey, - apr_threadkey_t *key) -{ - *thekey = key->key; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_threadkey_put(apr_threadkey_t **key, - apr_os_threadkey_t *thekey, - apr_pool_t *pool) -{ - if (pool == NULL) { - return APR_ENOPOOL; - } - if ((*key) == NULL) { - (*key) = (apr_threadkey_t *)apr_palloc(pool, sizeof(apr_threadkey_t)); - (*key)->pool = pool; - } - (*key)->key = *thekey; - return APR_SUCCESS; -} - diff --git a/libs/apr/time/unix/time.c b/libs/apr/time/unix/time.c deleted file mode 100644 index dfa45e69..00000000 --- a/libs/apr/time/unix/time.c +++ /dev/null @@ -1,349 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_portable.h" -#include "apr_time.h" -#include "apr_lib.h" -#include "apr_private.h" -#include "apr_strings.h" - -/* private APR headers */ -#include "apr_arch_internal_time.h" - -/* System Headers required for time library */ -#if APR_HAVE_SYS_TIME_H -#include -#endif -#if APR_HAVE_UNISTD_H -#include -#endif -#ifdef HAVE_TIME_H -#include -#endif -/* End System Headers */ - -#if !defined(HAVE_STRUCT_TM_TM_GMTOFF) && !defined(HAVE_STRUCT_TM___TM_GMTOFF) -static apr_int32_t server_gmt_offset; -#define NO_GMTOFF_IN_STRUCT_TM -#endif - -static apr_int32_t get_offset(struct tm *tm) -{ -#if defined(HAVE_STRUCT_TM_TM_GMTOFF) - return tm->tm_gmtoff; -#elif defined(HAVE_STRUCT_TM___TM_GMTOFF) - return tm->__tm_gmtoff; -#else -#ifdef NETWARE - /* Need to adjust the global variable each time otherwise - the web server would have to be restarted when daylight - savings changes. - */ - if (daylightOnOff) { - return server_gmt_offset + daylightOffset; - } -#else - if (tm->tm_isdst) - return server_gmt_offset + 3600; -#endif - return server_gmt_offset; -#endif -} - -APR_DECLARE(apr_status_t) apr_time_ansi_put(apr_time_t *result, - time_t input) -{ - *result = (apr_time_t)input * APR_USEC_PER_SEC; - return APR_SUCCESS; -} - -/* NB NB NB NB This returns GMT!!!!!!!!!! */ -APR_DECLARE(apr_time_t) apr_time_now(void) -{ - struct timeval tv; - gettimeofday(&tv, NULL); - return tv.tv_sec * APR_USEC_PER_SEC + tv.tv_usec; -} - -static void explode_time(apr_time_exp_t *xt, apr_time_t t, - apr_int32_t offset, int use_localtime) -{ - struct tm tm; - time_t tt = (t / APR_USEC_PER_SEC) + offset; - xt->tm_usec = t % APR_USEC_PER_SEC; - -#if APR_HAS_THREADS && defined (_POSIX_THREAD_SAFE_FUNCTIONS) - if (use_localtime) - localtime_r(&tt, &tm); - else - gmtime_r(&tt, &tm); -#else - if (use_localtime) - tm = *localtime(&tt); - else - tm = *gmtime(&tt); -#endif - - xt->tm_sec = tm.tm_sec; - xt->tm_min = tm.tm_min; - xt->tm_hour = tm.tm_hour; - xt->tm_mday = tm.tm_mday; - xt->tm_mon = tm.tm_mon; - xt->tm_year = tm.tm_year; - xt->tm_wday = tm.tm_wday; - xt->tm_yday = tm.tm_yday; - xt->tm_isdst = tm.tm_isdst; - xt->tm_gmtoff = get_offset(&tm); -} - -APR_DECLARE(apr_status_t) apr_time_exp_tz(apr_time_exp_t *result, - apr_time_t input, apr_int32_t offs) -{ - explode_time(result, input, offs, 0); - result->tm_gmtoff = offs; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_time_exp_gmt(apr_time_exp_t *result, - apr_time_t input) -{ - return apr_time_exp_tz(result, input, 0); -} - -APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result, - apr_time_t input) -{ -#if defined(__EMX__) - /* EMX gcc (OS/2) has a timezone global we can use */ - return apr_time_exp_tz(result, input, -timezone); -#else - explode_time(result, input, 0, 1); - return APR_SUCCESS; -#endif /* __EMX__ */ -} - -APR_DECLARE(apr_status_t) apr_time_exp_get(apr_time_t *t, apr_time_exp_t *xt) -{ - apr_time_t year = xt->tm_year; - apr_time_t days; - static const int dayoffset[12] = - {306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275}; - - /* shift new year to 1st March in order to make leap year calc easy */ - - if (xt->tm_mon < 2) - year--; - - /* Find number of days since 1st March 1900 (in the Gregorian calendar). */ - - days = year * 365 + year / 4 - year / 100 + (year / 100 + 3) / 4; - days += dayoffset[xt->tm_mon] + xt->tm_mday - 1; - days -= 25508; /* 1 jan 1970 is 25508 days since 1 mar 1900 */ - days = ((days * 24 + xt->tm_hour) * 60 + xt->tm_min) * 60 + xt->tm_sec; - - if (days < 0) { - return APR_EBADDATE; - } - *t = days * APR_USEC_PER_SEC + xt->tm_usec; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_time_exp_gmt_get(apr_time_t *t, - apr_time_exp_t *xt) -{ - apr_status_t status = apr_time_exp_get(t, xt); - if (status == APR_SUCCESS) - *t -= (apr_time_t) xt->tm_gmtoff * APR_USEC_PER_SEC; - return status; -} - -APR_DECLARE(apr_status_t) apr_os_imp_time_get(apr_os_imp_time_t **ostime, - apr_time_t *aprtime) -{ - (*ostime)->tv_usec = *aprtime % APR_USEC_PER_SEC; - (*ostime)->tv_sec = *aprtime / APR_USEC_PER_SEC; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_exp_time_get(apr_os_exp_time_t **ostime, - apr_time_exp_t *aprtime) -{ - (*ostime)->tm_sec = aprtime->tm_sec; - (*ostime)->tm_min = aprtime->tm_min; - (*ostime)->tm_hour = aprtime->tm_hour; - (*ostime)->tm_mday = aprtime->tm_mday; - (*ostime)->tm_mon = aprtime->tm_mon; - (*ostime)->tm_year = aprtime->tm_year; - (*ostime)->tm_wday = aprtime->tm_wday; - (*ostime)->tm_yday = aprtime->tm_yday; - (*ostime)->tm_isdst = aprtime->tm_isdst; - -#if defined(HAVE_STRUCT_TM_TM_GMTOFF) - (*ostime)->tm_gmtoff = aprtime->tm_gmtoff; -#elif defined(HAVE_STRUCT_TM___TM_GMTOFF) - (*ostime)->__tm_gmtoff = aprtime->tm_gmtoff; -#endif - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_imp_time_put(apr_time_t *aprtime, - apr_os_imp_time_t **ostime, - apr_pool_t *cont) -{ - *aprtime = (*ostime)->tv_sec * APR_USEC_PER_SEC + (*ostime)->tv_usec; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_exp_time_put(apr_time_exp_t *aprtime, - apr_os_exp_time_t **ostime, - apr_pool_t *cont) -{ - aprtime->tm_sec = (*ostime)->tm_sec; - aprtime->tm_min = (*ostime)->tm_min; - aprtime->tm_hour = (*ostime)->tm_hour; - aprtime->tm_mday = (*ostime)->tm_mday; - aprtime->tm_mon = (*ostime)->tm_mon; - aprtime->tm_year = (*ostime)->tm_year; - aprtime->tm_wday = (*ostime)->tm_wday; - aprtime->tm_yday = (*ostime)->tm_yday; - aprtime->tm_isdst = (*ostime)->tm_isdst; - -#if defined(HAVE_STRUCT_TM_TM_GMTOFF) - aprtime->tm_gmtoff = (*ostime)->tm_gmtoff; -#elif defined(HAVE_STRUCT_TM___TM_GMTOFF) - aprtime->tm_gmtoff = (*ostime)->__tm_gmtoff; -#endif - - return APR_SUCCESS; -} - -APR_DECLARE(void) apr_sleep(apr_interval_time_t t) -{ -#ifdef OS2 - DosSleep(t/1000); -#elif defined(BEOS) - snooze(t); -#elif defined(NETWARE) - delay(t/1000); -#else - struct timeval tv; - tv.tv_usec = t % APR_USEC_PER_SEC; - tv.tv_sec = t / APR_USEC_PER_SEC; - select(0, NULL, NULL, NULL, &tv); -#endif -} - -#ifdef OS2 -APR_DECLARE(apr_status_t) apr_os2_time_to_apr_time(apr_time_t *result, - FDATE os2date, - FTIME os2time) -{ - struct tm tmpdate; - - memset(&tmpdate, 0, sizeof(tmpdate)); - tmpdate.tm_hour = os2time.hours; - tmpdate.tm_min = os2time.minutes; - tmpdate.tm_sec = os2time.twosecs * 2; - - tmpdate.tm_mday = os2date.day; - tmpdate.tm_mon = os2date.month - 1; - tmpdate.tm_year = os2date.year + 80; - tmpdate.tm_isdst = -1; - - *result = mktime(&tmpdate) * APR_USEC_PER_SEC; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_apr_time_to_os2_time(FDATE *os2date, - FTIME *os2time, - apr_time_t aprtime) -{ - time_t ansitime = aprtime / APR_USEC_PER_SEC; - struct tm *lt; - lt = localtime(&ansitime); - os2time->hours = lt->tm_hour; - os2time->minutes = lt->tm_min; - os2time->twosecs = lt->tm_sec / 2; - - os2date->day = lt->tm_mday; - os2date->month = lt->tm_mon + 1; - os2date->year = lt->tm_year - 80; - return APR_SUCCESS; -} -#endif - -#ifdef NETWARE -APR_DECLARE(void) apr_netware_setup_time(void) -{ - tzset(); - server_gmt_offset = -TZONE; -} -#else -APR_DECLARE(void) apr_unix_setup_time(void) -{ -#ifdef NO_GMTOFF_IN_STRUCT_TM - /* Precompute the offset from GMT on systems where it's not - in struct tm. - - Note: This offset is normalized to be independent of daylight - savings time; if the calculation happens to be done in a - time/place where a daylight savings adjustment is in effect, - the returned offset has the same value that it would have - in the same location if daylight savings were not in effect. - The reason for this is that the returned offset can be - applied to a past or future timestamp in explode_time(), - so the DST adjustment obtained from the current time won't - necessarily be applicable. - - mktime() is the inverse of localtime(); so, presumably, - passing in a struct tm made by gmtime() let's us calculate - the true GMT offset. However, there's a catch: if daylight - savings is in effect, gmtime()will set the tm_isdst field - and confuse mktime() into returning a time that's offset - by one hour. In that case, we must adjust the calculated GMT - offset. - - */ - - struct timeval now; - time_t t1, t2; - struct tm t; - - gettimeofday(&now, NULL); - t1 = now.tv_sec; - t2 = 0; - -#if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) - gmtime_r(&t1, &t); -#else - t = *gmtime(&t1); -#endif - t.tm_isdst = 0; /* we know this GMT time isn't daylight-savings */ - t2 = mktime(&t); - server_gmt_offset = (apr_int32_t) difftime(t1, t2); -#endif /* NO_GMTOFF_IN_STRUCT_TM */ -} - -#endif - -/* A noop on all known Unix implementations */ -APR_DECLARE(void) apr_time_clock_hires(apr_pool_t *p) -{ - return; -} - - diff --git a/libs/apr/time/unix/timestr.c b/libs/apr/time/unix/timestr.c deleted file mode 100644 index f74febac..00000000 --- a/libs/apr/time/unix/timestr.c +++ /dev/null @@ -1,153 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_portable.h" -#include "apr_time.h" -#include "apr_lib.h" -#include "apr_private.h" -/* System Headers required for time library */ -#if APR_HAVE_SYS_TIME_H -#include -#endif -#ifdef HAVE_TIME_H -#include -#endif -#if APR_HAVE_STRING_H -#include -#endif -/* End System Headers */ - -APR_DECLARE_DATA const char apr_month_snames[12][4] = -{ - "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" -}; -APR_DECLARE_DATA const char apr_day_snames[7][4] = -{ - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" -}; - -apr_status_t apr_rfc822_date(char *date_str, apr_time_t t) -{ - apr_time_exp_t xt; - const char *s; - int real_year; - - apr_time_exp_gmt(&xt, t); - - /* example: "Sat, 08 Jan 2000 18:31:41 GMT" */ - /* 12345678901234567890123456789 */ - - s = &apr_day_snames[xt.tm_wday][0]; - *date_str++ = *s++; - *date_str++ = *s++; - *date_str++ = *s++; - *date_str++ = ','; - *date_str++ = ' '; - *date_str++ = xt.tm_mday / 10 + '0'; - *date_str++ = xt.tm_mday % 10 + '0'; - *date_str++ = ' '; - s = &apr_month_snames[xt.tm_mon][0]; - *date_str++ = *s++; - *date_str++ = *s++; - *date_str++ = *s++; - *date_str++ = ' '; - real_year = 1900 + xt.tm_year; - /* This routine isn't y10k ready. */ - *date_str++ = real_year / 1000 + '0'; - *date_str++ = real_year % 1000 / 100 + '0'; - *date_str++ = real_year % 100 / 10 + '0'; - *date_str++ = real_year % 10 + '0'; - *date_str++ = ' '; - *date_str++ = xt.tm_hour / 10 + '0'; - *date_str++ = xt.tm_hour % 10 + '0'; - *date_str++ = ':'; - *date_str++ = xt.tm_min / 10 + '0'; - *date_str++ = xt.tm_min % 10 + '0'; - *date_str++ = ':'; - *date_str++ = xt.tm_sec / 10 + '0'; - *date_str++ = xt.tm_sec % 10 + '0'; - *date_str++ = ' '; - *date_str++ = 'G'; - *date_str++ = 'M'; - *date_str++ = 'T'; - *date_str++ = 0; - return APR_SUCCESS; -} - -apr_status_t apr_ctime(char *date_str, apr_time_t t) -{ - apr_time_exp_t xt; - const char *s; - int real_year; - - /* example: "Wed Jun 30 21:49:08 1993" */ - /* 123456789012345678901234 */ - - apr_time_exp_lt(&xt, t); - s = &apr_day_snames[xt.tm_wday][0]; - *date_str++ = *s++; - *date_str++ = *s++; - *date_str++ = *s++; - *date_str++ = ' '; - s = &apr_month_snames[xt.tm_mon][0]; - *date_str++ = *s++; - *date_str++ = *s++; - *date_str++ = *s++; - *date_str++ = ' '; - *date_str++ = xt.tm_mday / 10 + '0'; - *date_str++ = xt.tm_mday % 10 + '0'; - *date_str++ = ' '; - *date_str++ = xt.tm_hour / 10 + '0'; - *date_str++ = xt.tm_hour % 10 + '0'; - *date_str++ = ':'; - *date_str++ = xt.tm_min / 10 + '0'; - *date_str++ = xt.tm_min % 10 + '0'; - *date_str++ = ':'; - *date_str++ = xt.tm_sec / 10 + '0'; - *date_str++ = xt.tm_sec % 10 + '0'; - *date_str++ = ' '; - real_year = 1900 + xt.tm_year; - *date_str++ = real_year / 1000 + '0'; - *date_str++ = real_year % 1000 / 100 + '0'; - *date_str++ = real_year % 100 / 10 + '0'; - *date_str++ = real_year % 10 + '0'; - *date_str++ = 0; - - return APR_SUCCESS; -} - -apr_status_t apr_strftime(char *s, apr_size_t *retsize, apr_size_t max, - const char *format, apr_time_exp_t *xt) -{ - struct tm tm; - memset(&tm, 0, sizeof tm); - tm.tm_sec = xt->tm_sec; - tm.tm_min = xt->tm_min; - tm.tm_hour = xt->tm_hour; - tm.tm_mday = xt->tm_mday; - tm.tm_mon = xt->tm_mon; - tm.tm_year = xt->tm_year; - tm.tm_wday = xt->tm_wday; - tm.tm_yday = xt->tm_yday; - tm.tm_isdst = xt->tm_isdst; -#if defined(HAVE_STRUCT_TM_TM_GMTOFF) - tm.tm_gmtoff = xt->tm_gmtoff; -#elif defined(HAVE_STRUCT_TM___TM_GMTOFF) - tm.__tm_gmtoff = xt->tm_gmtoff; -#endif - (*retsize) = strftime(s, max, format, &tm); - return APR_SUCCESS; -} diff --git a/libs/apr/time/win32/time.c b/libs/apr/time/win32/time.c deleted file mode 100644 index ecf02285..00000000 --- a/libs/apr/time/win32/time.c +++ /dev/null @@ -1,333 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_atime.h" -#include "apr_time.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_portable.h" -#if APR_HAVE_TIME_H -#include -#endif -#if APR_HAVE_ERRNO_H -#include -#endif -#include -#include -#include "apr_arch_misc.h" - -/* Leap year is any year divisible by four, but not by 100 unless also - * divisible by 400 - */ -#define IsLeapYear(y) ((!(y % 4)) ? (((!(y % 400)) && (y % 100)) ? 1 : 0) : 0) - -static DWORD get_local_timezone(TIME_ZONE_INFORMATION **tzresult) -{ - static TIME_ZONE_INFORMATION tz; - static DWORD result; - static int init = 0; - - if (!init) { - result = GetTimeZoneInformation(&tz); - init = 1; - } - - *tzresult = &tz; - return result; -} - -static void SystemTimeToAprExpTime(apr_time_exp_t *xt, SYSTEMTIME *tm) -{ - static const int dayoffset[12] = - {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; - - /* Note; the caller is responsible for filling in detailed tm_usec, - * tm_gmtoff and tm_isdst data when applicable. - */ - xt->tm_usec = tm->wMilliseconds * 1000; - xt->tm_sec = tm->wSecond; - xt->tm_min = tm->wMinute; - xt->tm_hour = tm->wHour; - xt->tm_mday = tm->wDay; - xt->tm_mon = tm->wMonth - 1; - xt->tm_year = tm->wYear - 1900; - xt->tm_wday = tm->wDayOfWeek; - xt->tm_yday = dayoffset[xt->tm_mon] + (tm->wDay - 1); - xt->tm_isdst = 0; - xt->tm_gmtoff = 0; - - /* If this is a leap year, and we're past the 28th of Feb. (the - * 58th day after Jan. 1), we'll increment our tm_yday by one. - */ - if (IsLeapYear(tm->wYear) && (xt->tm_yday > 58)) - xt->tm_yday++; -} - -APR_DECLARE(apr_status_t) apr_time_ansi_put(apr_time_t *result, - time_t input) -{ - *result = (apr_time_t) input * APR_USEC_PER_SEC; - return APR_SUCCESS; -} - -/* Return micro-seconds since the Unix epoch (jan. 1, 1970) UTC */ -APR_DECLARE(apr_time_t) apr_time_now(void) -{ - LONGLONG aprtime = 0; - FILETIME time; -#ifndef _WIN32_WCE - GetSystemTimeAsFileTime(&time); -#else - SYSTEMTIME st; - GetSystemTime(&st); - SystemTimeToFileTime(&st, &time); -#endif - FileTimeToAprTime(&aprtime, &time); - return aprtime; -} - -APR_DECLARE(apr_status_t) apr_time_exp_gmt(apr_time_exp_t *result, - apr_time_t input) -{ - FILETIME ft; - SYSTEMTIME st; - AprTimeToFileTime(&ft, input); - FileTimeToSystemTime(&ft, &st); - /* The Platform SDK documents that SYSTEMTIME/FILETIME are - * generally UTC, so no timezone info needed - */ - SystemTimeToAprExpTime(result, &st); - result->tm_usec = (apr_int32_t) (input % APR_USEC_PER_SEC); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_time_exp_tz(apr_time_exp_t *result, - apr_time_t input, - apr_int32_t offs) -{ - FILETIME ft; - SYSTEMTIME st; - AprTimeToFileTime(&ft, input + (offs * APR_USEC_PER_SEC)); - FileTimeToSystemTime(&ft, &st); - /* The Platform SDK documents that SYSTEMTIME/FILETIME are - * generally UTC, so we will simply note the offs used. - */ - SystemTimeToAprExpTime(result, &st); - result->tm_usec = (apr_int32_t) (input % APR_USEC_PER_SEC); - result->tm_gmtoff = offs; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result, - apr_time_t input) -{ - SYSTEMTIME st; - FILETIME ft, localft; - - AprTimeToFileTime(&ft, input); - -#if APR_HAS_UNICODE_FS && !defined(_WIN32_WCE) - IF_WIN_OS_IS_UNICODE - { - TIME_ZONE_INFORMATION *tz; - SYSTEMTIME localst; - apr_time_t localtime; - - get_local_timezone(&tz); - - FileTimeToSystemTime(&ft, &st); - - /* The Platform SDK documents that SYSTEMTIME/FILETIME are - * generally UTC. We use SystemTimeToTzSpecificLocalTime - * because FileTimeToLocalFileFime is documented that the - * resulting time local file time would have DST relative - * to the *present* date, not the date converted. - */ - SystemTimeToTzSpecificLocalTime(tz, &st, &localst); - SystemTimeToAprExpTime(result, &localst); - result->tm_usec = (apr_int32_t) (input % APR_USEC_PER_SEC); - - - /* Recover the resulting time as an apr time and use the - * delta for gmtoff in seconds (and ignore msec rounding) - */ - SystemTimeToFileTime(&localst, &localft); - FileTimeToAprTime(&localtime, &localft); - result->tm_gmtoff = (int)apr_time_sec(localtime) - - (int)apr_time_sec(input); - - /* To compute the dst flag, we compare the expected - * local (standard) timezone bias to the delta. - * [Note, in war time or double daylight time the - * resulting tm_isdst is, desireably, 2 hours] - */ - result->tm_isdst = (result->tm_gmtoff / 3600) - - (-(tz->Bias + tz->StandardBias) / 60); - } -#endif -#if APR_HAS_ANSI_FS || defined(_WIN32_WCE) - ELSE_WIN_OS_IS_ANSI - { - TIME_ZONE_INFORMATION tz; - /* XXX: This code is simply *wrong*. The time converted will always - * map to the *now current* status of daylight savings time. - */ - - FileTimeToLocalFileTime(&ft, &localft); - FileTimeToSystemTime(&localft, &st); - SystemTimeToAprExpTime(result, &st); - result->tm_usec = (apr_int32_t) (input % APR_USEC_PER_SEC); - - switch (GetTimeZoneInformation(&tz)) { - case TIME_ZONE_ID_UNKNOWN: - result->tm_isdst = 0; - /* Bias = UTC - local time in minutes - * tm_gmtoff is seconds east of UTC - */ - result->tm_gmtoff = tz.Bias * -60; - break; - case TIME_ZONE_ID_STANDARD: - result->tm_isdst = 0; - result->tm_gmtoff = (tz.Bias + tz.StandardBias) * -60; - break; - case TIME_ZONE_ID_DAYLIGHT: - result->tm_isdst = 1; - result->tm_gmtoff = (tz.Bias + tz.DaylightBias) * -60; - break; - default: - /* noop */; - } - } -#endif - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_time_exp_get(apr_time_t *t, - apr_time_exp_t *xt) -{ - apr_time_t year = xt->tm_year; - apr_time_t days; - static const int dayoffset[12] = - {306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275}; - - /* shift new year to 1st March in order to make leap year calc easy */ - - if (xt->tm_mon < 2) - year--; - - /* Find number of days since 1st March 1900 (in the Gregorian calendar). */ - - days = year * 365 + year / 4 - year / 100 + (year / 100 + 3) / 4; - days += dayoffset[xt->tm_mon] + xt->tm_mday - 1; - days -= 25508; /* 1 jan 1970 is 25508 days since 1 mar 1900 */ - - days = ((days * 24 + xt->tm_hour) * 60 + xt->tm_min) * 60 + xt->tm_sec; - - if (days < 0) { - return APR_EBADDATE; - } - *t = days * APR_USEC_PER_SEC + xt->tm_usec; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_time_exp_gmt_get(apr_time_t *t, - apr_time_exp_t *xt) -{ - apr_status_t status = apr_time_exp_get(t, xt); - if (status == APR_SUCCESS) - *t -= (apr_time_t) xt->tm_gmtoff * APR_USEC_PER_SEC; - return status; -} - -APR_DECLARE(apr_status_t) apr_os_imp_time_get(apr_os_imp_time_t **ostime, - apr_time_t *aprtime) -{ - /* TODO: Consider not passing in pointer to apr_time_t (e.g., call by value) */ - AprTimeToFileTime(*ostime, *aprtime); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_exp_time_get(apr_os_exp_time_t **ostime, - apr_time_exp_t *aprexptime) -{ - (*ostime)->wYear = aprexptime->tm_year + 1900; - (*ostime)->wMonth = aprexptime->tm_mon + 1; - (*ostime)->wDayOfWeek = aprexptime->tm_wday; - (*ostime)->wDay = aprexptime->tm_mday; - (*ostime)->wHour = aprexptime->tm_hour; - (*ostime)->wMinute = aprexptime->tm_min; - (*ostime)->wSecond = aprexptime->tm_sec; - (*ostime)->wMilliseconds = aprexptime->tm_usec / 1000; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_imp_time_put(apr_time_t *aprtime, - apr_os_imp_time_t **ostime, - apr_pool_t *cont) -{ - /* XXX: sanity failure, what is file time, gmt or local ? - */ - FileTimeToAprTime(aprtime, *ostime); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_os_exp_time_put(apr_time_exp_t *aprtime, - apr_os_exp_time_t **ostime, - apr_pool_t *cont) -{ - /* The Platform SDK documents that SYSTEMTIME/FILETIME are - * generally UTC, so no timezone info needed - */ - SystemTimeToAprExpTime(aprtime, *ostime); - return APR_SUCCESS; -} - -APR_DECLARE(void) apr_sleep(apr_interval_time_t t) -{ - /* One of the few sane situations for a cast, Sleep - * is in ms, not us, and passed as a DWORD value - */ - Sleep((DWORD)(t / 1000)); -} - -#if defined(_WIN32_WCE) -/* A noop on WinCE, like Unix implementation */ -APR_DECLARE(void) apr_time_clock_hires(apr_pool_t *p) -{ - return; -} -#else -static apr_status_t clock_restore(void *unsetres) -{ - ULONG newRes; - SetTimerResolution((ULONG)(apr_ssize_t)unsetres, FALSE, &newRes); - return APR_SUCCESS; -} - -APR_DECLARE(void) apr_time_clock_hires(apr_pool_t *p) -{ - ULONG newRes; - /* Timer resolution is stated in 100ns units. Note that TRUE requests the - * new clock resolution, FALSE above releases the request. - */ - if (SetTimerResolution(10000, TRUE, &newRes) == 0 /* STATUS_SUCCESS */) { - /* register the cleanup... */ - apr_pool_cleanup_register(p, (void*)10000, clock_restore, - apr_pool_cleanup_null); - } -} -#endif diff --git a/libs/apr/time/win32/timestr.c b/libs/apr/time/win32/timestr.c deleted file mode 100644 index 13841235..00000000 --- a/libs/apr/time/win32/timestr.c +++ /dev/null @@ -1,220 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_arch_atime.h" -#include "apr_portable.h" -#include "apr_strings.h" - -#if APR_HAVE_STDLIB_H -#include -#endif - -APR_DECLARE_DATA const char apr_month_snames[12][4] = -{ - "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" -}; -APR_DECLARE_DATA const char apr_day_snames[7][4] = -{ - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" -}; - -APR_DECLARE(apr_status_t) apr_rfc822_date(char *date_str, apr_time_t t) -{ - apr_time_exp_t xt; - const char *s; - int real_year; - - apr_time_exp_gmt(&xt, t); - - /* example: "Sat, 08 Jan 2000 18:31:41 GMT" */ - /* 12345678901234567890123456789 */ - - s = &apr_day_snames[xt.tm_wday][0]; - *date_str++ = *s++; - *date_str++ = *s++; - *date_str++ = *s++; - *date_str++ = ','; - *date_str++ = ' '; - *date_str++ = xt.tm_mday / 10 + '0'; - *date_str++ = xt.tm_mday % 10 + '0'; - *date_str++ = ' '; - s = &apr_month_snames[xt.tm_mon][0]; - *date_str++ = *s++; - *date_str++ = *s++; - *date_str++ = *s++; - *date_str++ = ' '; - real_year = 1900 + xt.tm_year; - /* This routine isn't y10k ready. */ - *date_str++ = real_year / 1000 + '0'; - *date_str++ = real_year % 1000 / 100 + '0'; - *date_str++ = real_year % 100 / 10 + '0'; - *date_str++ = real_year % 10 + '0'; - *date_str++ = ' '; - *date_str++ = xt.tm_hour / 10 + '0'; - *date_str++ = xt.tm_hour % 10 + '0'; - *date_str++ = ':'; - *date_str++ = xt.tm_min / 10 + '0'; - *date_str++ = xt.tm_min % 10 + '0'; - *date_str++ = ':'; - *date_str++ = xt.tm_sec / 10 + '0'; - *date_str++ = xt.tm_sec % 10 + '0'; - *date_str++ = ' '; - *date_str++ = 'G'; - *date_str++ = 'M'; - *date_str++ = 'T'; - *date_str++ = 0; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_ctime(char *date_str, apr_time_t t) -{ - apr_time_exp_t xt; - const char *s; - int real_year; - - /* example: "Wed Jun 30 21:49:08 1993" */ - /* 123456789012345678901234 */ - - apr_time_exp_lt(&xt, t); - s = &apr_day_snames[xt.tm_wday][0]; - *date_str++ = *s++; - *date_str++ = *s++; - *date_str++ = *s++; - *date_str++ = ' '; - s = &apr_month_snames[xt.tm_mon][0]; - *date_str++ = *s++; - *date_str++ = *s++; - *date_str++ = *s++; - *date_str++ = ' '; - *date_str++ = xt.tm_mday / 10 + '0'; - *date_str++ = xt.tm_mday % 10 + '0'; - *date_str++ = ' '; - *date_str++ = xt.tm_hour / 10 + '0'; - *date_str++ = xt.tm_hour % 10 + '0'; - *date_str++ = ':'; - *date_str++ = xt.tm_min / 10 + '0'; - *date_str++ = xt.tm_min % 10 + '0'; - *date_str++ = ':'; - *date_str++ = xt.tm_sec / 10 + '0'; - *date_str++ = xt.tm_sec % 10 + '0'; - *date_str++ = ' '; - real_year = 1900 + xt.tm_year; - *date_str++ = real_year / 1000 + '0'; - *date_str++ = real_year % 1000 / 100 + '0'; - *date_str++ = real_year % 100 / 10 + '0'; - *date_str++ = real_year % 10 + '0'; - *date_str++ = 0; - - return APR_SUCCESS; -} - - -#ifndef _WIN32_WCE - -static apr_size_t win32_strftime_extra(char *s, size_t max, const char *format, - const struct tm *tm) -{ - /* If the new format string is bigger than max, the result string won't fit - * anyway. If format strings are added, made sure the padding below is - * enough */ - char *new_format = (char *) malloc(max + 11); - size_t i, j, format_length = strlen(format); - apr_size_t return_value; - int length_written; - - for (i = 0, j = 0; (i < format_length && j < max);) { - if (format[i] != '%') { - new_format[j++] = format[i++]; - continue; - } - switch (format[i+1]) { - case 'C': - length_written = apr_snprintf(new_format + j, max - j, "%2d", - (tm->tm_year + 1970)/100); - j = (length_written == -1) ? max : (j + length_written); - i += 2; - break; - case 'D': - /* Is this locale dependent? Shouldn't be... - Also note the year 2000 exposure here */ - memcpy(new_format + j, "%m/%d/%y", 8); - i += 2; - j += 8; - break; - case 'r': - memcpy(new_format + j, "%I:%M:%S %p", 11); - i += 2; - j += 11; - break; - case 'R': - memcpy(new_format + j, "%H:%M", 5); - i += 2; - j += 5; - break; - case 'T': - memcpy(new_format + j, "%H:%M:%S", 8); - i += 2; - j += 8; - break; - case 'e': - length_written = apr_snprintf(new_format + j, max - j, "%2d", - tm->tm_mday); - j = (length_written == -1) ? max : (j + length_written); - i += 2; - break; - default: - /* We know we can advance two characters forward here. Also - * makes sure that %% is preserved. */ - new_format[j++] = format[i++]; - new_format[j++] = format[i++]; - } - } - if (j >= max) { - *s = '\0'; /* Defensive programming, okay since output is undefined*/ - return_value = 0; - } else { - new_format[j] = '\0'; - return_value = strftime(s, max, new_format, tm); - } - free(new_format); - return return_value; -} - -#endif - - -APR_DECLARE(apr_status_t) apr_strftime(char *s, apr_size_t *retsize, - apr_size_t max, const char *format, - apr_time_exp_t *xt) -{ -#ifdef _WIN32_WCE - return APR_ENOTIMPL; -#else - struct tm tm; - memset(&tm, 0, sizeof tm); - tm.tm_sec = xt->tm_sec; - tm.tm_min = xt->tm_min; - tm.tm_hour = xt->tm_hour; - tm.tm_mday = xt->tm_mday; - tm.tm_mon = xt->tm_mon; - tm.tm_year = xt->tm_year; - tm.tm_wday = xt->tm_wday; - tm.tm_yday = xt->tm_yday; - tm.tm_isdst = xt->tm_isdst; - (*retsize) = win32_strftime_extra(s, max, format, &tm); - return APR_SUCCESS; -#endif -} diff --git a/libs/apr/user/netware/groupinfo.c b/libs/apr/user/netware/groupinfo.c deleted file mode 100644 index e7cfd9b2..00000000 --- a/libs/apr/user/netware/groupinfo.c +++ /dev/null @@ -1,41 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_user.h" -#include "apr_private.h" -#ifdef HAVE_GRP_H -#include -#endif -#if APR_HAVE_SYS_TYPES_H -#include -#endif -#if APR_HAVE_UNISTD_H -#include /* for _POSIX_THREAD_SAFE_FUNCTIONS */ -#endif - -APR_DECLARE(apr_status_t) apr_gid_name_get(char **groupname, apr_gid_t groupid, - apr_pool_t *p) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_gid_get(apr_gid_t *groupid, - const char *groupname, apr_pool_t *p) -{ - return APR_ENOTIMPL; -} diff --git a/libs/apr/user/netware/userinfo.c b/libs/apr/user/netware/userinfo.c deleted file mode 100644 index b58991b8..00000000 --- a/libs/apr/user/netware/userinfo.c +++ /dev/null @@ -1,70 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_user.h" -#include "apr_private.h" -#ifdef HAVE_PWD_H -#include -#endif -#if APR_HAVE_SYS_TYPES_H -#include -#endif -#if APR_HAVE_UNISTD_H -#include /* for _POSIX_THREAD_SAFE_FUNCTIONS */ -#endif - -#define PWBUF_SIZE 512 - -static apr_status_t getpwnam_safe(const char *username, - struct passwd *pw, - char pwbuf[PWBUF_SIZE]) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_uid_homepath_get(char **dirname, - const char *username, - apr_pool_t *p) -{ - return APR_ENOTIMPL; -} - - - -APR_DECLARE(apr_status_t) apr_uid_current(apr_uid_t *uid, - apr_gid_t *gid, - apr_pool_t *p) -{ - return APR_ENOTIMPL; -} - - - - -APR_DECLARE(apr_status_t) apr_uid_get(apr_uid_t *uid, apr_gid_t *gid, - const char *username, apr_pool_t *p) -{ - return APR_ENOTIMPL; -} - -APR_DECLARE(apr_status_t) apr_uid_name_get(char **username, apr_uid_t userid, - apr_pool_t *p) -{ - return APR_ENOTIMPL; -} - diff --git a/libs/apr/user/unix/groupinfo.c b/libs/apr/user/unix/groupinfo.c deleted file mode 100644 index 7967219f..00000000 --- a/libs/apr/user/unix/groupinfo.c +++ /dev/null @@ -1,87 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_user.h" -#include "apr_private.h" -#ifdef HAVE_GRP_H -#include -#endif -#if APR_HAVE_SYS_TYPES_H -#include -#endif -#if APR_HAVE_UNISTD_H -#include /* for _POSIX_THREAD_SAFE_FUNCTIONS */ -#endif - -#define GRBUF_SIZE 8192 - -APR_DECLARE(apr_status_t) apr_gid_name_get(char **groupname, apr_gid_t groupid, - apr_pool_t *p) -{ - struct group *gr; - -#if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) - struct group grp; - char grbuf[GRBUF_SIZE]; - apr_status_t rv; - - /* See comment in getpwnam_safe on error handling. */ - rv = getgrgid_r(groupid, &grp, grbuf, sizeof(grbuf), &gr); - if (rv) { - return rv; - } - if (gr == NULL) { - return APR_ENOENT; - } -#else - errno = 0; - if ((gr = getgrgid(groupid)) == NULL) { - return errno ? errno : APR_ENOENT; - } -#endif - *groupname = apr_pstrdup(p, gr->gr_name); - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_gid_get(apr_gid_t *groupid, - const char *groupname, apr_pool_t *p) -{ - struct group *gr; - -#if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRNAM_R) - struct group grp; - char grbuf[GRBUF_SIZE]; - apr_status_t rv; - - /* See comment in getpwnam_safe on error handling. */ - rv = getgrnam_r(groupname, &grp, grbuf, sizeof(grbuf), &gr); - if (rv) { - return rv; - } - if (gr == NULL) { - return APR_ENOENT; - } -#else - errno = 0; - if ((gr = getgrnam(groupname)) == NULL) { - return errno ? errno : APR_ENOENT; - } -#endif - *groupid = gr->gr_gid; - return APR_SUCCESS; -} diff --git a/libs/apr/user/unix/userinfo.c b/libs/apr/user/unix/userinfo.c deleted file mode 100644 index 516445b5..00000000 --- a/libs/apr/user/unix/userinfo.c +++ /dev/null @@ -1,146 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_user.h" -#include "apr_private.h" -#ifdef HAVE_PWD_H -#include -#endif -#if APR_HAVE_SYS_TYPES_H -#include -#endif -#if APR_HAVE_UNISTD_H -#include /* for _POSIX_THREAD_SAFE_FUNCTIONS */ -#endif -#define APR_WANT_MEMFUNC -#include "apr_want.h" - -#define PWBUF_SIZE 2048 - -static apr_status_t getpwnam_safe(const char *username, - struct passwd *pw, - char pwbuf[PWBUF_SIZE]) -{ - struct passwd *pwptr; -#if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) - apr_status_t rv; - - /* POSIX defines getpwnam_r() et al to return the error number - * rather than set errno, and requires pwptr to be set to NULL if - * the entry is not found, imply that "not found" is not an error - * condition; some implementations do return 0 with pwptr set to - * NULL. */ - rv = getpwnam_r(username, pw, pwbuf, PWBUF_SIZE, &pwptr); - if (rv) { - return rv; - } - if (pwptr == NULL) { - return APR_ENOENT; - } -#else - /* Some platforms (e.g. FreeBSD 4.x) do not set errno on NULL "not - * found" return values for the non-threadsafe function either. */ - errno = 0; - if ((pwptr = getpwnam(username)) != NULL) { - memcpy(pw, pwptr, sizeof *pw); - } - else { - return errno ? errno : APR_ENOENT; - } -#endif - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_uid_homepath_get(char **dirname, - const char *username, - apr_pool_t *p) -{ - struct passwd pw; - char pwbuf[PWBUF_SIZE]; - apr_status_t rv; - - if ((rv = getpwnam_safe(username, &pw, pwbuf)) != APR_SUCCESS) - return rv; - -#ifdef OS2 - /* Need to manually add user name for OS/2 */ - *dirname = apr_pstrcat(p, pw.pw_dir, pw.pw_name, NULL); -#else - *dirname = apr_pstrdup(p, pw.pw_dir); -#endif - return APR_SUCCESS; -} - - - -APR_DECLARE(apr_status_t) apr_uid_current(apr_uid_t *uid, - apr_gid_t *gid, - apr_pool_t *p) -{ - *uid = getuid(); - *gid = getgid(); - - return APR_SUCCESS; -} - - - - -APR_DECLARE(apr_status_t) apr_uid_get(apr_uid_t *uid, apr_gid_t *gid, - const char *username, apr_pool_t *p) -{ - struct passwd pw; - char pwbuf[PWBUF_SIZE]; - apr_status_t rv; - - if ((rv = getpwnam_safe(username, &pw, pwbuf)) != APR_SUCCESS) - return rv; - - *uid = pw.pw_uid; - *gid = pw.pw_gid; - - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_uid_name_get(char **username, apr_uid_t userid, - apr_pool_t *p) -{ - struct passwd *pw; -#if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWUID_R) - struct passwd pwd; - char pwbuf[PWBUF_SIZE]; - apr_status_t rv; - - rv = getpwuid_r(userid, &pwd, pwbuf, sizeof(pwbuf), &pw); - if (rv) { - return rv; - } - - if (pw == NULL) { - return APR_ENOENT; - } - -#else - errno = 0; - if ((pw = getpwuid(userid)) == NULL) { - return errno ? errno : APR_ENOENT; - } -#endif - *username = apr_pstrdup(p, pw->pw_name); - return APR_SUCCESS; -} diff --git a/libs/apr/user/win32/groupinfo.c b/libs/apr/user/win32/groupinfo.c deleted file mode 100644 index 585642f0..00000000 --- a/libs/apr/user/win32/groupinfo.c +++ /dev/null @@ -1,100 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_user.h" -#include "apr_private.h" -#if APR_HAVE_SYS_TYPES_H -#include -#endif - -APR_DECLARE(apr_status_t) apr_gid_get(apr_gid_t *gid, - const char *groupname, apr_pool_t *p) -{ -#ifdef _WIN32_WCE - return APR_ENOTIMPL; -#else - SID_NAME_USE sidtype; - char anydomain[256]; - char *domain; - DWORD sidlen = 0; - DWORD domlen = sizeof(anydomain); - DWORD rv; - char *pos; - - if ((pos = strchr(groupname, '/'))) { - domain = apr_pstrndup(p, groupname, pos - groupname); - groupname = pos + 1; - } - else if ((pos = strchr(groupname, '\\'))) { - domain = apr_pstrndup(p, groupname, pos - groupname); - groupname = pos + 1; - } - else { - domain = NULL; - } - /* Get nothing on the first pass ... need to size the sid buffer - */ - rv = LookupAccountName(domain, groupname, domain, &sidlen, - anydomain, &domlen, &sidtype); - if (sidlen) { - /* Give it back on the second pass - */ - *gid = apr_palloc(p, sidlen); - domlen = sizeof(anydomain); - rv = LookupAccountName(domain, groupname, *gid, &sidlen, - anydomain, &domlen, &sidtype); - } - if (!sidlen || !rv) { - return apr_get_os_error(); - } - return APR_SUCCESS; -#endif -} - -APR_DECLARE(apr_status_t) apr_gid_name_get(char **groupname, apr_gid_t groupid, apr_pool_t *p) -{ -#ifdef _WIN32_WCE - *groupname = apr_pstrdup(p, "Administrators"); -#else - SID_NAME_USE type; - char name[MAX_PATH], domain[MAX_PATH]; - DWORD cbname = sizeof(name), cbdomain = sizeof(domain); - if (!groupid) - return APR_EINVAL; - if (!LookupAccountSid(NULL, groupid, name, &cbname, domain, &cbdomain, &type)) - return apr_get_os_error(); - if (type != SidTypeGroup && type != SidTypeWellKnownGroup - && type != SidTypeAlias) - return APR_EINVAL; - *groupname = apr_pstrdup(p, name); -#endif - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_gid_compare(apr_gid_t left, apr_gid_t right) -{ - if (!left || !right) - return APR_EINVAL; -#ifndef _WIN32_WCE - if (!IsValidSid(left) || !IsValidSid(right)) - return APR_EINVAL; - if (!EqualSid(left, right)) - return APR_EMISMATCH; -#endif - return APR_SUCCESS; -} diff --git a/libs/apr/user/win32/userinfo.c b/libs/apr/user/win32/userinfo.c deleted file mode 100644 index 12931ade..00000000 --- a/libs/apr/user/win32/userinfo.c +++ /dev/null @@ -1,280 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_private.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_user.h" -#include "apr_arch_file_io.h" -#if APR_HAVE_SYS_TYPES_H -#include -#endif - -#ifndef _WIN32_WCE -/* Internal sid binary to string translation, see MSKB Q131320. - * Several user related operations require our SID to access - * the registry, but in a string format. All error handling - * depends on IsValidSid(), which internally we better test long - * before we get here! - */ -static void get_sid_string(char *buf, apr_size_t blen, apr_uid_t id) -{ - PSID_IDENTIFIER_AUTHORITY psia; - DWORD nsa; - DWORD sa; - int slen; - - /* Determine authority values (these is a big-endian value, - * and NT records the value as hex if the value is > 2^32.) - */ - psia = GetSidIdentifierAuthority(id); - nsa = (DWORD)(psia->Value[5]) + ((DWORD)(psia->Value[4]) << 8) - + ((DWORD)(psia->Value[3]) << 16) + ((DWORD)(psia->Value[2]) << 24); - sa = (DWORD)(psia->Value[1]) + ((DWORD)(psia->Value[0]) << 8); - if (sa) { - slen = apr_snprintf(buf, blen, "S-%d-0x%04x%08x", - SID_REVISION, (unsigned int)sa, (unsigned int)nsa); - } else { - slen = apr_snprintf(buf, blen, "S-%d-%lu", - SID_REVISION, nsa); - } - - /* Now append all the subauthority strings. - */ - nsa = *GetSidSubAuthorityCount(id); - for (sa = 0; sa < nsa; ++sa) { - slen += apr_snprintf(buf + slen, blen - slen, "-%lu", - *GetSidSubAuthority(id, sa)); - } -} -#endif -/* Query the ProfileImagePath from the version-specific branch, where the - * regkey uses the user's name on 9x, and user's sid string on NT. - */ -APR_DECLARE(apr_status_t) apr_uid_homepath_get(char **dirname, - const char *username, - apr_pool_t *p) -{ -#ifdef _WIN32_WCE - *dirname = apr_pstrdup(p, "/My Documents"); - return APR_SUCCESS; -#else - apr_status_t rv; - char regkey[MAX_PATH * 2]; - char *fixch; - DWORD keylen; - DWORD type; - HKEY key; - - if (apr_os_level >= APR_WIN_NT) { - apr_uid_t uid; - apr_gid_t gid; - - if ((rv = apr_uid_get(&uid, &gid, username, p)) != APR_SUCCESS) - return rv; - - strcpy(regkey, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\" - "ProfileList\\"); - keylen = (DWORD)strlen(regkey); - get_sid_string(regkey + keylen, sizeof(regkey) - keylen, uid); - } - else { - strcpy(regkey, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" - "ProfileList\\"); - keylen = (DWORD)strlen(regkey); - apr_cpystrn(regkey + keylen, username, sizeof(regkey) - keylen); - } - - if ((rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE, regkey, 0, - KEY_QUERY_VALUE, &key)) != ERROR_SUCCESS) - return APR_FROM_OS_ERROR(rv); - -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - keylen = sizeof(regkey); - rv = RegQueryValueExW(key, L"ProfileImagePath", NULL, &type, - (void*)regkey, &keylen); - RegCloseKey(key); - if (rv != ERROR_SUCCESS) - return APR_FROM_OS_ERROR(rv); - if (type == REG_SZ) { - char retdir[MAX_PATH]; - if ((rv = unicode_to_utf8_path(retdir, sizeof(retdir), - (apr_wchar_t*)regkey)) != APR_SUCCESS) - return rv; - *dirname = apr_pstrdup(p, retdir); - } - else if (type == REG_EXPAND_SZ) { - apr_wchar_t path[MAX_PATH]; - char retdir[MAX_PATH]; - ExpandEnvironmentStringsW((apr_wchar_t*)regkey, path, - sizeof(path) / 2); - if ((rv = unicode_to_utf8_path(retdir, sizeof(retdir), path)) - != APR_SUCCESS) - return rv; - *dirname = apr_pstrdup(p, retdir); - } - else - return APR_ENOENT; - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - keylen = sizeof(regkey); - rv = RegQueryValueEx(key, "ProfileImagePath", NULL, &type, - (void*)regkey, &keylen); - RegCloseKey(key); - if (rv != ERROR_SUCCESS) - return APR_FROM_OS_ERROR(rv); - if (type == REG_SZ) { - *dirname = apr_pstrdup(p, regkey); - } - else if (type == REG_EXPAND_SZ) { - char path[MAX_PATH]; - ExpandEnvironmentStrings(regkey, path, sizeof(path)); - *dirname = apr_pstrdup(p, path); - } - else - return APR_ENOENT; - } -#endif /* APR_HAS_ANSI_FS */ - for (fixch = *dirname; *fixch; ++fixch) - if (*fixch == '\\') - *fixch = '/'; - return APR_SUCCESS; -#endif /* _WIN32_WCE */ -} - -APR_DECLARE(apr_status_t) apr_uid_current(apr_uid_t *uid, - apr_gid_t *gid, - apr_pool_t *p) -{ -#ifdef _WIN32_WCE - return APR_ENOTIMPL; -#else - HANDLE threadtok; - DWORD needed; - TOKEN_USER *usr; - TOKEN_PRIMARY_GROUP *grp; - - if(!OpenProcessToken(GetCurrentProcess(), STANDARD_RIGHTS_READ | READ_CONTROL | TOKEN_QUERY, &threadtok)) { - return apr_get_os_error(); - } - - *uid = NULL; - if (!GetTokenInformation(threadtok, TokenUser, NULL, 0, &needed) - && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) - && (usr = apr_palloc(p, needed)) - && GetTokenInformation(threadtok, TokenUser, usr, needed, &needed)) - *uid = usr->User.Sid; - else - return apr_get_os_error(); - - if (!GetTokenInformation(threadtok, TokenPrimaryGroup, NULL, 0, &needed) - && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) - && (grp = apr_palloc(p, needed)) - && GetTokenInformation(threadtok, TokenPrimaryGroup, grp, needed, &needed)) - *gid = grp->PrimaryGroup; - else - return apr_get_os_error(); - - return APR_SUCCESS; -#endif -} - -APR_DECLARE(apr_status_t) apr_uid_get(apr_uid_t *uid, apr_gid_t *gid, - const char *username, apr_pool_t *p) -{ -#ifdef _WIN32_WCE - return APR_ENOTIMPL; -#else - SID_NAME_USE sidtype; - char anydomain[256]; - char *domain; - DWORD sidlen = 0; - DWORD domlen = sizeof(anydomain); - DWORD rv; - char *pos; - - if ((pos = strchr(username, '/'))) { - domain = apr_pstrndup(p, username, pos - username); - username = pos + 1; - } - else if ((pos = strchr(username, '\\'))) { - domain = apr_pstrndup(p, username, pos - username); - username = pos + 1; - } - else { - domain = NULL; - } - /* Get nothing on the first pass ... need to size the sid buffer - */ - rv = LookupAccountName(domain, username, domain, &sidlen, - anydomain, &domlen, &sidtype); - if (sidlen) { - /* Give it back on the second pass - */ - *uid = apr_palloc(p, sidlen); - domlen = sizeof(anydomain); - rv = LookupAccountName(domain, username, *uid, &sidlen, - anydomain, &domlen, &sidtype); - } - if (!sidlen || !rv) { - return apr_get_os_error(); - } - /* There doesn't seem to be a simple way to retrieve the primary group sid - */ - *gid = NULL; - return APR_SUCCESS; -#endif -} - -APR_DECLARE(apr_status_t) apr_uid_name_get(char **username, apr_uid_t userid, - apr_pool_t *p) -{ -#ifdef _WIN32_WCE - *username = apr_pstrdup(p, "Administrator"); - return APR_SUCCESS; -#else - SID_NAME_USE type; - char name[MAX_PATH], domain[MAX_PATH]; - DWORD cbname = sizeof(name), cbdomain = sizeof(domain); - if (!userid) - return APR_EINVAL; - if (!LookupAccountSid(NULL, userid, name, &cbname, domain, &cbdomain, &type)) - return apr_get_os_error(); - if (type != SidTypeUser && type != SidTypeAlias && type != SidTypeWellKnownGroup) - return APR_EINVAL; - *username = apr_pstrdup(p, name); - return APR_SUCCESS; -#endif -} - -APR_DECLARE(apr_status_t) apr_uid_compare(apr_uid_t left, apr_uid_t right) -{ - if (!left || !right) - return APR_EINVAL; -#ifndef _WIN32_WCE - if (!IsValidSid(left) || !IsValidSid(right)) - return APR_EINVAL; - if (!EqualSid(left, right)) - return APR_EMISMATCH; -#endif - return APR_SUCCESS; -} - diff --git a/libs/buildlibs.bat b/libs/buildlibs.bat index 1569eabc..dcd00c8d 100644 --- a/libs/buildlibs.bat +++ b/libs/buildlibs.bat @@ -20,25 +20,6 @@ exit :SKIP_OPENSSL -rem ==== zlib ==== - -if exist lib\zlib.lib ( -echo zlib already built -goto SKIP_ZLIB -) - -echo Building zlib ... -cd zlib -make -f Makefile.bcb all -cd .. - -if not exist lib\zlib.lib ( -echo zlib build failed -exit -) - -:SKIP_ZLIB - rem ==== Expat ==== if exist lib\libexpats_mtd.lib ( @@ -61,25 +42,6 @@ copy expat\bcb5\release\libexpats_mtd.lib lib :SKIP_EXPAT -rem ==== APR ==== - -if exist lib\apr.lib ( -echo APR already built -goto SKIP_APR -) - -echo Building APR ... -cd apr -make -f Makefile.bcb all -cd .. - -if not exist lib\apr.lib ( -echo APR build failed -exit -) - -:SKIP_APR - rem ==== neon ==== if exist lib\neon.lib ( diff --git a/libs/cleaninterm.bat b/libs/cleaninterm.bat index a3fc81fb..9997850f 100644 --- a/libs/cleaninterm.bat +++ b/libs/cleaninterm.bat @@ -8,21 +8,11 @@ del /s *.obj cd ..\.. rmdir /s /q openssl\tmp -rem ==== zlib ==== - -echo Cleaning up zlib ... -rmdir /s /q zlib\tmp - rem ==== Expat ==== echo Cleaning up Expat ... rmdir /s /q expat\bcb5\release -rem ==== APR ==== - -echo Cleaning up APR ... -rmdir /s /q apr\tmp - rem ==== neon ==== echo Cleaning up neon ... diff --git a/libs/mfc/include/afxwin.h b/libs/mfc/include/afxwin.h index 468e8eb3..c08772b1 100644 --- a/libs/mfc/include/afxwin.h +++ b/libs/mfc/include/afxwin.h @@ -1465,7 +1465,7 @@ class COleCmdUI; ///////////////////////////////////////////////////////////////////////////// // OLE event sink map handling (more in AFXDISP.H) -#ifndef _AFX_NO_OCC_SUPPORT +//#ifndef _AFX_NO_OCC_SUPPORT struct AFX_EVENTSINKMAP_ENTRY; @@ -1501,7 +1501,7 @@ protected: \ #endif -#endif //!_AFX_NO_OCC_SUPPORT +//#endif //!_AFX_NO_OCC_SUPPORT ///////////////////////////////////////////////////////////////////////////// // OLE connection map handling (more in AFXDISP.H) diff --git a/libs/mfc/source/afxinl1.cpp b/libs/mfc/source/afxinl1.cpp index fb5ca7b3..92a4db11 100644 --- a/libs/mfc/source/afxinl1.cpp +++ b/libs/mfc/source/afxinl1.cpp @@ -34,13 +34,13 @@ static const char _szAfxDlgsInl[] = "afxdlgs.inl"; #undef THIS_FILE #define THIS_FILE _szAfxDlgsInl #define _AFXDLGS_INLINE -#include "afxdlgs.inl" +//#include "afxdlgs.inl" // expand inlines static const char _szAfxExtInl[] = "afxext.inl"; #undef THIS_FILE #define THIS_FILE _szAfxExtInl #define _AFXEXT_INLINE -#include "afxext.inl" +//#include "afxext.inl" #endif //!_AFX_ENABLE_INLINES diff --git a/libs/mfc/source/afxstate.cpp b/libs/mfc/source/afxstate.cpp index ada3ef8b..c742f75b 100644 --- a/libs/mfc/source/afxstate.cpp +++ b/libs/mfc/source/afxstate.cpp @@ -61,11 +61,11 @@ _AFX_THREAD_STATE::_AFX_THREAD_STATE() _AFX_THREAD_STATE::~_AFX_THREAD_STATE() { // cleanup thread local tooltip window - if (m_pToolTip != NULL) + /*if (m_pToolTip != NULL) { m_pToolTip->DestroyWindow(); delete m_pToolTip; - } + }*/ // unhook windows hooks if (m_hHookOldMsgFilter != NULL) @@ -141,11 +141,11 @@ AFX_MODULE_STATE::~AFX_MODULE_STATE() #endif // clean up type lib cache map, if any - if (m_pTypeLibCacheMap != NULL) + /*if (m_pTypeLibCacheMap != NULL) { m_pTypeLibCacheMap->RemoveAll(&m_typeLibCache); delete m_pTypeLibCacheMap; - } + }*/ } void CTypeLibCacheMap::RemoveAll(void* pExcept) @@ -257,7 +257,7 @@ AFX_MODULE_THREAD_STATE* AFXAPI AfxGetModuleThreadState() // CTypeLibCache::Unlock // (Note: the rest of CTypeLibCache is implemented in oletyplb.cpp) -void CTypeLibCache::Unlock() +/*void CTypeLibCache::Unlock() { ASSERT(m_cRef > 0); @@ -274,4 +274,4 @@ void CTypeLibCache::Unlock() m_ptlib = NULL; } } -} +}*/ diff --git a/libs/mfc/source/appui1.cpp b/libs/mfc/source/appui1.cpp index 52e143c2..290a6aab 100644 --- a/libs/mfc/source/appui1.cpp +++ b/libs/mfc/source/appui1.cpp @@ -34,11 +34,11 @@ void CWinApp::EnableModeless(BOOL bEnable) return; #ifndef _AFX_NO_OLE_SUPPORT - // check if notify hook installed + /*// check if notify hook installed ASSERT_KINDOF(CFrameWnd, pMainWnd); CFrameWnd* pFrameWnd = (CFrameWnd*)pMainWnd; if (pFrameWnd->m_pNotifyHook != NULL) - pFrameWnd->m_pNotifyHook->OnEnableModeless(bEnable); + pFrameWnd->m_pNotifyHook->OnEnableModeless(bEnable);*/ #endif } @@ -154,14 +154,14 @@ HWND PASCAL CWnd::GetSafeOwner_(HWND hParent, HWND* pWndTop) { // get window to start with HWND hWnd = hParent; - if (hWnd == NULL) + /*if (hWnd == NULL) { CFrameWnd* pFrame = CCmdTarget::GetRoutingFrame_(); if (pFrame != NULL) hWnd = pFrame->GetSafeHwnd(); else hWnd = AfxGetMainWnd()->GetSafeHwnd(); - } + }*/ // a popup window cannot be owned by a child window while (hWnd != NULL && (::GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD)) @@ -210,10 +210,11 @@ CView* PASCAL CCmdTarget::GetRoutingView_() CFrameWnd* PASCAL CCmdTarget::GetRoutingFrame_() { - CFrameWnd* pFrame = AfxGetThreadState()->m_pRoutingFrame; + /*CFrameWnd* pFrame = AfxGetThreadState()->m_pRoutingFrame; if (pFrame != NULL) ASSERT_VALID(pFrame); - return pFrame; + return pFrame;*/ + return NULL; } ///////////////////////////////////////////////////////////////////////////// diff --git a/libs/mfc/source/arccore.cpp b/libs/mfc/source/arccore.cpp index 59c01e77..fd725094 100644 --- a/libs/mfc/source/arccore.cpp +++ b/libs/mfc/source/arccore.cpp @@ -772,13 +772,13 @@ LPTSTR CArchive::ReadString(LPTSTR lpsz, UINT nMax) { while (nRead < nStop) { - *this >> ch; + AfxThrowArchiveException(CArchiveException::generic); // stop and end-of-line (trailing '\n' is ignored) if (ch == '\n' || ch == '\r') { if (ch == '\r') - *this >> ch; + AfxThrowArchiveException(CArchiveException::generic); // store the newline when called with negative nMax if ((int)nMax != nStop) lpsz[nRead++] = ch; diff --git a/libs/mfc/source/borland.mak b/libs/mfc/source/borland.mak index 58ab0080..5b20da5e 100644 --- a/libs/mfc/source/borland.mak +++ b/libs/mfc/source/borland.mak @@ -61,7 +61,7 @@ # ############################################################################# # Define defaults if not defined - +UNICODE=1 # Default to DEBUG mode !ifndef DEBUG DEBUG=0 @@ -137,7 +137,8 @@ NO_CLEAN_PCH=0 !endif BASE=W -MODEL=N +MODEL=U +TARGDEFS=/D_UNICODE /DUNICODE /D_AFX_NO_OLEDB_SUPPORT /D_AFX_NO_OCC_SUPPORT !if "$(MBCS)" != "0" TARGDEFS=$(TARGDEFS) /D_MBCS !endif @@ -301,51 +302,30 @@ MISC=\ afxdbcs.obj afxstate.obj afxtls.obj fixalloc.obj \ mtcore.obj mtex.obj -WINDOWS=\ - wincore.obj winfrm.obj winfrm2.obj winfrmx.obj \ - winmdi.obj tooltip.obj winmini.obj winhand.obj \ - winmain.obj barcore.obj bartool.obj bardlg.obj \ - barstat.obj bardock.obj dockcont.obj dockstat.obj \ - dcprev.obj dcmeta.obj trckrect.obj barcool.obj - -DIALOG=\ - winctrl1.obj winctrl2.obj winctrl3.obj winctrl4.obj \ - winbtn.obj dlgcore.obj dlgdata.obj dlgfloat.obj \ - dlgprop.obj dlgcomm.obj dlgfile.obj dlgprnt.obj \ - dlgclr.obj dlgfnt.obj dlgfr.obj ccdata.obj dlgtempl.obj \ - winctrl6.obj winctrl7.obj - -WINMISC=\ - wingdi.obj wingdix.obj winstr.obj winmenu.obj \ - auxdata.obj afxcrit.obj afxtrace.obj winutil.obj winocc.obj - -DOCVIEW=\ - cmdtarg.obj doccore.obj doctempl.obj \ - docsingl.obj docmulti.obj docmgr.obj \ - viewcore.obj viewprnt.obj winsplit.obj viewscrl.obj \ - viewform.obj viewedit.obj viewprev.obj viewcmn.obj \ - docmapi.obj +WINDOWS=winhand.obj + +DIALOG= + +WINMISC=afxcrit.obj winstr.obj winutil.obj auxdata.obj wingdi.obj + +DOCVIEW= INTERNET=inet.obj filefind.obj !if "$(UNICODE)" == "1" -INTERNET=$(INTERNET) isapimix.obj +#INTERNET=$(INTERNET) isapimix.obj !endif -APPLICATION=\ - thrdcore.obj appcore.obj appinit.obj appterm.obj \ - appui.obj appui1.obj appui2.obj appui3.obj appgray.obj \ - appdlg.obj app3d.obj appprnt.obj apphelp.obj apphelpx.obj \ - filelist.obj +APPLICATION=appterm.obj appui1.obj appinit.obj apphelp.obj thrdcore.obj !if "$(DLL)" != "2" -APPLICATION=$(APPLICATION) app3ds.obj \ - nolib.obj appmodul.obj dllmodul.obj oleexp.obj dumpstak.obj +#APPLICATION=$(APPLICATION) app3ds.obj \ +# nolib.obj appmodul.obj dllmodul.obj oleexp.obj dumpstak.obj !endif # ODBC components: -DB=\ - dbcore.obj dbrfx.obj dbview.obj dbflt.obj \ - dblong.obj dbvar.obj +#DB=\ +# dbcore.obj dbrfx.obj dbview.obj dbflt.obj \ +# dblong.obj dbvar.obj # # DAO is not supported under Borland C++ @@ -357,34 +337,9 @@ SOCKETS=sockcore.obj OLEREQ=olelock.obj -OLE=\ - oleinit.obj olecli1.obj olecli2.obj \ - olecli3.obj olecnvrt.obj oledobj1.obj oledobj2.obj \ - oledisp1.obj oledisp2.obj oledlgs1.obj oledlgs2.obj \ - oledlgs3.obj oledata.obj olevar.obj olevar1.obj \ - oledoc1.obj oledoc2.obj oledrop1.obj oledrop2.obj \ - olemsgf.obj oleenum.obj olefact.obj oleipfrm.obj \ - olelink.obj olemisc.obj olestrm.obj olesvr1.obj \ - olesvr2.obj olereg.obj oletsvr.obj oleui1.obj \ - oleui2.obj oleunk.obj oleverb.obj olecall.obj \ - viewrich.obj oledll.obj oletyplb.obj \ - olemon.obj winctrl5.obj viewhtml.obj \ - occmgr.obj occevent.obj occcont.obj occsite.obj \ - occlock.obj occddx.obj occddxf.obj occdlg.obj \ - oledocvw.obj oledocob.obj oledoctg.obj oledocip.obj \ - oledoccl.obj oleasmon.obj olebar.obj - -OLECTL=\ - ctlcache.obj ctlcore.obj ctlconn.obj \ - ctldata.obj ctlevent.obj ctlmodul.obj \ - ctlframe.obj ctlfont.obj ctlinplc.obj \ - ctllic.obj oleconn.obj ctlobj.obj ctlpict.obj \ - ctlpropx.obj ctlppg.obj ctlprop.obj \ - ctlpset.obj ctlpstg.obj ctlpstm.obj \ - ctlrefl.obj ctlreg.obj ctltrack.obj \ - ctlview.obj olepset.obj ctlpbag.obj \ - ctlquick.obj ctlnownd.obj \ - ppgcolor.obj ppgfont.obj ppgpict.obj ppgstock.obj +OLE=olevar.obj oleunk.obj + +OLECTL= !if "$(DEBUG)" == "1" OLECTL=$(OLECTL) ctlinl.obj @@ -543,8 +498,8 @@ $(CPPFLAGS) -I$(BCINCL);$(MFCINCL) /c $(PCH_CPP).cpp !if "$(DLL)" != "2" # Build final library -$(LIBDIR)\$(GOAL).lib: $(OBJS) - @-if exist $@ erase $@ +$(LIBDIR)\$(GOAL).lib: $(D)\$(OBJS) + # @-if exist $@ erase $@ @$(LIB32) $@ /P2048 @&&! +-$(**: = &^ +-) diff --git a/libs/mfc/source/inet.cpp b/libs/mfc/source/inet.cpp index aedeb37d..7bd82f35 100644 --- a/libs/mfc/source/inet.cpp +++ b/libs/mfc/source/inet.cpp @@ -674,44 +674,26 @@ BOOL CInternetSession::EnableStatusCallback(BOOL bEnable /* = TRUE */) BOOL CInternetSession::SetCookie(LPCSTR pstrUrl, LPCTSTR pstrCookieName, LPCTSTR pstrCookieData) { - ASSERT(AfxIsValidString(pstrUrl)); - ASSERT(AfxIsValidString(pstrCookieName)); - return InternetSetCookie(pstrUrl, pstrCookieName, pstrCookieData); + AfxThrowInternetException(GetLastError()); + return false; } BOOL CInternetSession::GetCookie(LPCSTR pstrUrl, LPCTSTR pstrCookieName, LPTSTR pstrCookieData, DWORD dwBufLen) { - ASSERT(AfxIsValidString(pstrUrl)); - ASSERT(AfxIsValidString(pstrCookieName)); - ASSERT(pstrCookieData != NULL); - return InternetGetCookie(pstrUrl, pstrCookieName, pstrCookieData, &dwBufLen); + AfxThrowInternetException(GetLastError()); + return false; } DWORD CInternetSession::GetCookieLength(LPCSTR pstrUrl, LPCTSTR pstrCookieName) { - ASSERT(AfxIsValidString(pstrUrl)); - ASSERT(AfxIsValidString(pstrCookieName)); - - DWORD dwRet; - if (!InternetGetCookie(pstrUrl, pstrCookieName, NULL, &dwRet)) - dwRet = 0; - return dwRet; + AfxThrowInternetException(GetLastError()); + return 0; } BOOL CInternetSession::GetCookie(LPCSTR pstrUrl, LPCTSTR pstrCookieName, CString& strCookieData) { - ASSERT(AfxIsValidString(pstrUrl)); - ASSERT(AfxIsValidString(pstrCookieName)); - - DWORD dwLen = GetCookieLength(pstrUrl, pstrCookieName); - - LPTSTR pstrTarget = strCookieData.GetBuffer(dwLen+1); - BOOL bRetVal = InternetGetCookie(pstrUrl, pstrCookieName, pstrTarget, &dwLen); - strCookieData.ReleaseBuffer(dwLen); - - if (!bRetVal) - strCookieData.Empty(); - return bRetVal; + AfxThrowInternetException(GetLastError()); + return false; } #ifdef _DEBUG diff --git a/libs/mfc/source/olecli1.cpp b/libs/mfc/source/olecli1.cpp index ed9435c6..a80dc2ac 100644 --- a/libs/mfc/source/olecli1.cpp +++ b/libs/mfc/source/olecli1.cpp @@ -278,7 +278,7 @@ static void AfxGetIconInfo(LPCTSTR lpszRegInfo, LPTSTR lpszImagePath, // extract the index if (*pstrSource != '\0') { - LPTSTR pstrIndex = _tcsinc(pstrSource); + LPCTSTR pstrIndex = _tcsinc(pstrSource); nIndex = (UINT) _ttol(pstrIndex); } else diff --git a/libs/mfc/source/stdafx.h b/libs/mfc/source/stdafx.h index 3adb71f0..f67c61c6 100644 --- a/libs/mfc/source/stdafx.h +++ b/libs/mfc/source/stdafx.h @@ -215,4 +215,7 @@ #endif //_AFX_OLD_EXCEPTIONS +#define min std::min +#define max std::max + ///////////////////////////////////////////////////////////////////////////// diff --git a/libs/mfc/source/strex.cpp b/libs/mfc/source/strex.cpp index 9369a294..02725282 100644 --- a/libs/mfc/source/strex.cpp +++ b/libs/mfc/source/strex.cpp @@ -428,6 +428,7 @@ int CString::Find(LPCTSTR lpszSub, int nStart) const #define FORCE_ANSI 0x10000 #define FORCE_UNICODE 0x20000 #define FORCE_INT64 0x40000 +#define _tclen(__a) (1) void CString::FormatV(LPCTSTR lpszFormat, va_list argList) { diff --git a/libs/neon/.version b/libs/neon/.version index 476163a9..c25c8e5b 100644 --- a/libs/neon/.version +++ b/libs/neon/.version @@ -1 +1 @@ -0.29.6 +0.30.0 diff --git a/libs/neon/ChangeLog b/libs/neon/ChangeLog index 9ece2790..f4499ef8 100644 --- a/libs/neon/ChangeLog +++ b/libs/neon/ChangeLog @@ -1,490 +1,828 @@ ------------------------------------------------------------------------ -r1843 | joe | 2011-05-03 13:15:08 +0100 (Tue, 03 May 2011) | 1 line +r1932 | joe | 2013-07-31 17:00:59 +0100 (Wed, 31 Jul 2013) | 2 lines + +Tag 0.30, third time lucky. -Tag release 0.29.6. ------------------------------------------------------------------------ -r1842 | joe | 2011-05-03 13:14:56 +0100 (Tue, 03 May 2011) | 2 lines +r1930 | joe | 2013-07-31 16:55:25 +0100 (Wed, 31 Jul 2013) | 3 lines -* macros/neon.m4: Bump to .6. +* macros/neon.m4, configure.in: Fix ABI versioning for backwards-compat + with 0.27.x. ------------------------------------------------------------------------ -r1841 | joe | 2011-05-03 13:09:46 +0100 (Tue, 03 May 2011) | 2 lines +r1928 | joe | 2013-07-31 16:48:33 +0100 (Wed, 31 Jul 2013) | 2 lines -* NEWS: Tweak ordering. +* po/: make update-po. ------------------------------------------------------------------------ -r1840 | joe | 2011-05-03 13:09:18 +0100 (Tue, 03 May 2011) | 2 lines +r1925 | joe | 2013-07-31 16:36:53 +0100 (Wed, 31 Jul 2013) | 2 lines -* More news. +* src/ne_socket.c: Another GnuTLS 3.x deprecation warning fix. ------------------------------------------------------------------------ -r1839 | joe | 2011-05-03 13:07:08 +0100 (Tue, 03 May 2011) | 22 lines +r1924 | joe | 2013-07-31 16:35:34 +0100 (Wed, 31 Jul 2013) | 1 line -Merge r1836, r1837, r1838 from trunk: +Drop -dev. +------------------------------------------------------------------------ +r1923 | joe | 2013-07-31 16:34:39 +0100 (Wed, 31 Jul 2013) | 1 line -* src/ne_gnutls.c (ne__ssl_init): Fix for GnuTLS with Nettle. +Note GnuTLS 3.x fixes. +------------------------------------------------------------------------ +r1922 | joe | 2013-07-31 16:22:20 +0100 (Wed, 31 Jul 2013) | 2 lines -* src/ne_auth.c (get_cnonce): Likewise. +* src/ne_gnutls.c (provide_client_cert): Avoid segfaults with GnuTLS 3.x. -Submitted by: Arfrever Frehtes Taifersar Arahesis +------------------------------------------------------------------------ +r1921 | joe | 2013-07-31 15:46:50 +0100 (Wed, 31 Jul 2013) | 2 lines -* src/ne_auth.c - (ah_post_send): Clear SSPI context only after successful authentication. +* test/.gdbinit: New file. -Submitted by: Ivan Zhakov +------------------------------------------------------------------------ +r1920 | joe | 2013-07-31 15:46:37 +0100 (Wed, 31 Jul 2013) | 2 lines -Fix some errors flagged by a Coverity scan: +* test/common/child.c: More debugging. -* src/ne_auth.c (verify_negotiate_response): Check for NULL pointer. +------------------------------------------------------------------------ +r1919 | joe | 2013-07-31 15:40:56 +0100 (Wed, 31 Jul 2013) | 6 lines -* src/ne_gnutls.c (check_certificate): Initiatialize 'failures'. - (pkcs12_parse): Check for _crt_init failure. +* test/request.c (status, status_chunked): Revert r1910. Expect hostname of + 127.0.0.1. + +* test/utils.c (session_server, sessi -* src/ne_session.c (ne__ssl_set_verify_err): Pass size-1 to strncat. ------------------------------------------------------------------------ -r1835 | joe | 2011-03-01 13:28:28 +0000 (Tue, 01 Mar 2011) | 2 lines +r1918 | joe | 2013-07-31 15:21:04 +0100 (Wed, 31 Jul 2013) | 3 lines -* NEWS: Update. +* src/ne_gnutls.c (x509_crt_copy, make_peers_chain): Fix potential segv, + patch by Matthias Petschick. ------------------------------------------------------------------------ -r1834 | joe | 2011-03-01 13:26:04 +0000 (Tue, 01 Mar 2011) | 6 lines +r1917 | joe | 2013-07-31 15:15:05 +0100 (Wed, 31 Jul 2013) | 3 lines -Merge r1833 from trunk: +* src/ne_privssl.h, src/ne_gnutls.c, src/ne_socket.c: Avoid olde GnuTLS types, + avoiding deprecation warnings. -* src/ne_request.c (ne_request_create): Pass copied method to - pre_send hooks to avoid lifetime issues (Patrick Ohly). +------------------------------------------------------------------------ +r1916 | joe | 2013-07-31 15:08:25 +0100 (Wed, 31 Jul 2013) | 5 lines + +Omitted in previous commit: +* src/ne_socket.c: Support build with GnuTLS 3, patch by Bartosz + Brachaczek. ------------------------------------------------------------------------ -r1832 | joe | 2010-11-11 12:32:11 +0000 (Thu, 11 Nov 2010) | 2 lines +r1915 | joe | 2013-07-31 15:05:23 +0100 (Wed, 31 Jul 2013) | 3 lines -* macros/neon.m4: Really bump to -dev. +* src/ne_gnutls.c, macros/neon.m4: Support build with GnuTLS 3, patch by + Bartosz Brachaczek. ------------------------------------------------------------------------ -r1831 | joe | 2010-11-11 12:31:39 +0000 (Thu, 11 Nov 2010) | 2 lines +r1914 | joe | 2013-07-31 14:56:22 +0100 (Wed, 31 Jul 2013) | 2 lines -* macros/neon.m4, NEWS: Bump to .6-dev. +* macros/ld-version-script.m4: Update from gnulib. ------------------------------------------------------------------------ -r1830 | joe | 2010-11-11 12:29:51 +0000 (Thu, 11 Nov 2010) | 5 lines +r1913 | joe | 2013-07-31 14:50:34 +0100 (Wed, 31 Jul 2013) | 2 lines -Merge r1827 from trunk: +* test/common/tests.c (main): Note fatal errors. -* doc/ref/iaddr.xml: Update ne_iaddr_* docs. +------------------------------------------------------------------------ +r1912 | joe | 2013-07-31 14:49:58 +0100 (Wed, 31 Jul 2013) | 2 lines +* test/ssl.c: Disable SSLv2 test, redundant with modern SSL libraries. ------------------------------------------------------------------------ -r1829 | joe | 2010-11-11 12:26:45 +0000 (Thu, 11 Nov 2010) | 7 lines +r1911 | joe | 2013-07-26 19:33:54 +0100 (Fri, 26 Jul 2013) | 2 lines -Merge r1828 from trunk: +* src/ne_request.c (send_request_body): Use chunk length without prefix in progress. -* src/ne_gnutls.c (provide_client_cert): Return success with no cert - if no cert is available; match behaviour with OpenSSL. Thanks to - Patrick Ohly. +------------------------------------------------------------------------ +r1910 | joe | 2013-07-26 19:32:08 +0100 (Fri, 26 Jul 2013) | 4 lines +* test/request.c (print_addr, notifier): Factor out from status; fix for + multiple mappings from "localhost" addr. + (status_plain, status_chunked): Adapt to use notifier. ------------------------------------------------------------------------ -r1825 | joe | 2010-10-14 16:04:44 +0100 (Thu, 14 Oct 2010) | 2 lines +r1909 | joe | 2013-07-26 19:25:09 +0100 (Fri, 26 Jul 2013) | 2 lines -* NEWS: Tweak. +* src/ne_request.c (send_request_body): Fix double counting. ------------------------------------------------------------------------ -r1824 | joe | 2010-10-14 16:03:02 +0100 (Thu, 14 Oct 2010) | 2 lines +r1908 | joe | 2013-07-26 19:08:37 +0100 (Fri, 26 Jul 2013) | 3 lines -* NEWS: Update with GnuTLS fix. +* test/request.c (retry_after_abort): Correctly catch errors. + Re-order tests to avoid triggering some weird glibc getaddrinfo issue. ------------------------------------------------------------------------ -r1823 | joe | 2010-10-14 16:02:41 +0100 (Thu, 14 Oct 2010) | 10 lines +r1907 | joe | 2013-07-26 18:58:53 +0100 (Fri, 26 Jul 2013) | 2 lines -Merge r1818 from trunk: +* macros/neon.m4 (NEON_I18N): Check for bindtextdomain with -liconv. (Brad Smith) -* test/socket.c (addr_reverse) [HAVE_GETHOSTNAME]: Accept system - hostname as reverse of 127.0.0.1. +------------------------------------------------------------------------ +r1906 | joe | 2013-07-26 18:57:48 +0100 (Fri, 26 Jul 2013) | 4 lines -* macros/neon-test.m4 (NEON_TEST): Check for gethostname(). +* src/ne_socket.c: Include sys/uio.h for writev(2) (Brad Smith). -Submitted by: joe -Reviewed by: jorton +* macros/neon.m4: Check for it. ------------------------------------------------------------------------ -r1822 | joe | 2010-10-14 16:01:53 +0100 (Thu, 14 Oct 2010) | 2 lines +r1905 | joe | 2013-07-26 18:51:23 +0100 (Fri, 26 Jul 2013) | 8 lines + +Support chunked bodies; patch by Julien Reichel. -* NEWS, macros/neon.m4: Prepare for 0.29.5. +* src/ne_request.c (send_request_body): Support chunked bodies. + (set_body_length): Negative length implies chunked, not C-L. + (send_request): Adjust for chunked. + +* src/ne_request.h: Update ne_set_request_body_provider API. ------------------------------------------------------------------------ -r1821 | joe | 2010-10-14 16:00:53 +0100 (Thu, 14 Oct 2010) | 6 lines +r1904 | joe | 2013-07-26 18:38:05 +0100 (Fri, 26 Jul 2013) | 2 lines -Merge r1797 from trunk: +* src/ne_basic.h: Update comment. -* src/ne_auth.c: Add handling of 2xx responses in SSPI code. -(Danil Shopyrin ) +------------------------------------------------------------------------ +r1903 | joe | 2013-07-26 17:17:08 +0100 (Fri, 26 Jul 2013) | 1 line + +Win32 fixes. +------------------------------------------------------------------------ +r1902 | joe | 2013-07-26 17:16:21 +0100 (Fri, 26 Jul 2013) | 3 lines +* config.hw.in, src/ne_defs.h: Add LFS support for Win32 (patch by +Diego Santa Cruz). ------------------------------------------------------------------------ -r1820 | joe | 2010-10-09 17:07:17 +0100 (Sat, 09 Oct 2010) | 6 lines +r1901 | joe | 2013-07-26 17:15:19 +0100 (Fri, 26 Jul 2013) | 2 lines -Merge r1819 from trunk: +* config.hw.in, src/ne_openssl.c: Add thread-safety support for SSL on Windows. -* src/ne_socket.c (ne_sock_connect_ssl): Ignore TLS warnings - during handshake (Bryan Cain). +------------------------------------------------------------------------ +r1900 | joe | 2013-07-26 17:11:57 +0100 (Fri, 26 Jul 2013) | 2 lines +* test/run-tests.sh: Use MALLOC_PERTURB. ------------------------------------------------------------------------ -r1816 | joe | 2010-10-01 13:00:02 +0100 (Fri, 01 Oct 2010) | 2 lines +r1899 | joe | 2013-07-26 17:11:35 +0100 (Fri, 26 Jul 2013) | 1 line -* po/: make update-po. +Changes in trunk. +------------------------------------------------------------------------ +r1898 | joe | 2013-07-26 17:10:53 +0100 (Fri, 26 Jul 2013) | 2 lines + +* test/utils.c (proxied_session_server): Debug more. ------------------------------------------------------------------------ -r1814 | joe | 2010-09-28 13:02:37 +0100 (Tue, 28 Sep 2010) | 2 lines +r1897 | joe | 2013-07-26 17:08:57 +0100 (Fri, 26 Jul 2013) | 5 lines -* NEWS: Update. +* src/ne_session.c (free_proxies): Fix possible double-free. +(patch by Diego Santa Cruz) + +* test/session.c (proxies): Add test case. ------------------------------------------------------------------------ -r1813 | joe | 2010-09-28 13:00:48 +0100 (Tue, 28 Sep 2010) | 10 lines +r1896 | joe | 2013-03-18 10:33:56 +0000 (Mon, 18 Mar 2013) | 4 lines -Merge r1811 from trunk: +* src/ne_md5.c (md5_finish_ctx): Fix aliasing problem. -* src/ne_session.c (ne__ssl_match_hostname): Deny a wildcard match - against anything which parses as an IP address. +http://permalink.gmane.org/gmane.comp.gnu.binutils/58378 -* test/ssl.c (fail_wildcard_ip): Add test case. +------------------------------------------------------------------------ +r1895 | joe | 2012-07-06 22:23:20 +0100 (Fri, 06 Jul 2012) | 3 lines -* test/makekeys.sh: Generate test wildcard IP cert. +* src/ne_socket.c (ne_sock_connect_ssl): Drop OpenSSL version check, + inappropriate with OpenSSL 1.x; patch by Mike Frysinger. +------------------------------------------------------------------------ +r1894 | joe | 2012-07-06 08:55:32 +0100 (Fri, 06 Jul 2012) | 2 lines + +* src/ne_auth.c: Fix build, from Nathanael Rensen. ------------------------------------------------------------------------ -r1812 | joe | 2010-09-28 12:57:26 +0100 (Tue, 28 Sep 2010) | 8 lines +r1893 | joe | 2012-07-05 21:46:03 +0100 (Thu, 05 Jul 2012) | 3 lines -Merge r1809 from trunk: +* src/ne_socket.c (timed_connect, ne_sock_connect): Capture socket + error code correctly for Windows. (Vlad Grachov) -* src/ne_request.c (open_connection): If SOCKS proxy fails, set return - value to NE_ERROR. +------------------------------------------------------------------------ +r1892 | joe | 2012-07-05 21:41:43 +0100 (Thu, 05 Jul 2012) | 7 lines -* test/request.c (socks_fail): Add test case. +Patch from Nathanael Rensen: +* src/ne_auth.c (ah_post_send): Clear SSPI context for any + non-auth-failure response code. + +* src/ne_sspi.c (ne_sspi_clear_context): Clear continueNeeded flag. ------------------------------------------------------------------------ -r1808 | joe | 2010-09-22 21:42:08 +0100 (Wed, 22 Sep 2010) | 2 lines +r1891 | joe | 2012-07-04 09:41:44 +0100 (Wed, 04 Jul 2012) | 3 lines -* NEWS: Update for 0.29.4. +* test/makekeys.sh: Use 1024 bit RSA keys to prevent weird OpenSSL + test failures. ------------------------------------------------------------------------ -r1807 | joe | 2010-09-22 20:33:36 +0100 (Wed, 22 Sep 2010) | 9 lines +r1890 | joe | 2012-06-26 11:13:33 +0100 (Tue, 26 Jun 2012) | 2 lines -Merge r1801 from trunk: +* test/utils.c (fakeproxied_session_server): New function. -* src/ne_request.c (body_fd_send): Handle read() errors; thanks to Lou - Montulli. +------------------------------------------------------------------------ +r1889 | joe | 2012-06-26 11:12:55 +0100 (Tue, 26 Jun 2012) | 3 lines -* test/request.c (serve_mirror, send_length): Add test case. +* test/common/child.c (new_spawn_server2): Factored out, return + address used. Fix to ensure local host address is resolved. -* test/Makefile.in (foobar.txt): Create test file. +------------------------------------------------------------------------ +r1888 | joe | 2012-06-26 11:02:58 +0100 (Tue, 26 Jun 2012) | 6 lines + +* src/ne_session.c (ne_set_addrlist2): Factored out of + ne_set_addrlist, take port as argument. + (ne_set_addrlist): Reimplement using the above. + +* src/neon.vers: Add ne_set_addrlist2. ------------------------------------------------------------------------ -r1806 | joe | 2010-09-22 20:25:52 +0100 (Wed, 22 Sep 2010) | 8 lines +r1887 | joe | 2012-06-26 09:17:20 +0100 (Tue, 26 Jun 2012) | 7 lines -Merge r1802, r1805 from trunk: +* src/ne_auth.h: Add NE_AUTH_GSSAPI_ONLY, NE_AUTH_SSPI. -* macros/neon.m4 (NE_CHECK_FUNCS): Fix AI_ADDRCONFIG detection. +* src/ne_auth.c: Adjust for new constants. + (auth_register): Map NE_AUTH_GSSAPI to _GSSAPI_ONLY|_SSPI -* src/ne_auth.c (ah_post_send): Always clear the SSPI context. -(Danil Shopyrin) +Patch by Nathanael Rensen + +------------------------------------------------------------------------ +r1886 | joe | 2012-06-25 12:21:39 +0100 (Mon, 25 Jun 2012) | 3 lines +* test/ssl.c (fail_ssl_request_with_error2): Fix tests with "fake" hostname + where localhost maps to multiple addresses. ------------------------------------------------------------------------ -r1800 | joe | 2010-05-05 09:13:00 +0100 (Wed, 05 May 2010) | 5 lines +r1885 | joe | 2012-05-22 15:43:58 +0100 (Tue, 22 May 2012) | 2 lines -Merge r1794 from trunk: +* test/uri-tests.c (cmp): Don't depend on exact magnitude of *cmp. -* src/ne_session.c (ne_session_create): Fix to enable SNI by default again. - (Tobias Gruetzmacher) +------------------------------------------------------------------------ +r1882 | joe | 2012-01-19 22:17:13 +0000 (Thu, 19 Jan 2012) | 2 lines + +* test/basic.c (options2): Untabify. ------------------------------------------------------------------------ -r1796 | joe | 2010-03-29 10:19:04 +0100 (Mon, 29 Mar 2010) | 9 lines +r1881 | joe | 2012-01-19 22:16:11 +0000 (Thu, 19 Jan 2012) | 6 lines -Merge r1792, r1793, r1795 from trunk: +* src/ne_basic.h: Add NE_CAP_EXT_MKCOL. -* src/ne_request.c (do_connect): Tweak debugging. +* src/ne_basic.c (options_map): Add NE_CAP_EXT_MKCOL. -* doc/ref/: Fix some refpurposes. +* test/basic.c (options2): Add test. -* doc/ref/reqflags.xml: Doc tweak. +------------------------------------------------------------------------ +r1874 | joe | 2011-12-09 13:43:02 +0000 (Fri, 09 Dec 2011) | 3 lines +* src/ne_socket.c (ne_iaddr_reverse) [!USE_GETADDRINFO]: + Fix build with Open Watcom compiler. (NormW ) ------------------------------------------------------------------------ -r1782 | joe | 2010-01-11 10:40:42 +0000 (Mon, 11 Jan 2010) | 2 lines +r1863 | joe | 2011-10-03 23:33:52 +0100 (Mon, 03 Oct 2011) | 3 lines -* NEWS: Document ne_sock_close() changes. +* src/ne_socket.c (ne_addr_resolve): Use a bit-wise + comparison, suggested by Ivan Zhakov. ------------------------------------------------------------------------ -r1781 | joe | 2010-01-11 10:36:14 +0000 (Mon, 11 Jan 2010) | 8 lines +r1862 | joe | 2011-10-03 22:48:59 +0100 (Mon, 03 Oct 2011) | 3 lines -Merge r1780 from trunk: +* src/ne_socket.c (timed_connect): Don't overwrite an error when + resetting fd flags. -* src/ne_socket.c (ne_sock_close): Do not wait for the peer's - close_notify alert with either GnuTLS or OpenSSL. - [HAVE_GNUTLS]: Fix memory leak: free the session object. +------------------------------------------------------------------------ +r1861 | joe | 2011-10-03 22:41:51 +0100 (Mon, 03 Oct 2011) | 2 lines -* src/ne_socket.h (ne_sock_close): Clarify close_notify handling. +* src/ne_socket.c: Tweak comment. ------------------------------------------------------------------------ -r1775 | joe | 2009-12-30 21:31:55 +0000 (Wed, 30 Dec 2009) | 2 lines +r1860 | joe | 2011-10-03 22:35:49 +0100 (Mon, 03 Oct 2011) | 3 lines -* po/: make update-po. +* src/ne_request.c (ne_set_request_flag, ne_get_request_flag): Fix + warnings with gcc 4.5 -Wenum-compare. ------------------------------------------------------------------------ -r1774 | joe | 2009-12-30 21:31:30 +0000 (Wed, 30 Dec 2009) | 2 lines +r1859 | joe | 2011-09-18 21:05:37 +0100 (Sun, 18 Sep 2011) | 2 lines -* macros/neon.m4: Bump version. +* test/common/child.c: Better debugging output. ------------------------------------------------------------------------ -r1773 | joe | 2009-12-30 21:30:55 +0000 (Wed, 30 Dec 2009) | 2 lines +r1858 | joe | 2011-09-18 21:04:49 +0100 (Sun, 18 Sep 2011) | 2 lines -* NEWS: 0.29.2 news. +* src/neon.vers: No version 0.31 needed (yet?!). ------------------------------------------------------------------------ -r1772 | joe | 2009-12-30 21:29:30 +0000 (Wed, 30 Dec 2009) | 10 lines +r1857 | joe | 2011-09-18 21:04:23 +0100 (Sun, 18 Sep 2011) | 2 lines -Merge r1748 from trunk: +* src/Makefile.in: Update deps. -Clear sspi_token buffer after each request. +------------------------------------------------------------------------ +r1856 | joe | 2011-09-18 20:58:06 +0100 (Sun, 18 Sep 2011) | 3 lines -* src/ne_auth.c (request_sspi): Return NULL if sspi_token is not present. +* src/ne_auth.c (continue_sspi, auth_register): Use the proxy hostname + for proxy auth with SSPI. -* src/ne_auth.c (ah_post_send): Clear the buffered sspi_token. +------------------------------------------------------------------------ +r1855 | joe | 2011-09-14 10:15:08 +0100 (Wed, 14 Sep 2011) | 3 lines -Submitted by: Danil Shopyrin +* test/common/child.c (spawn_server, spawn_server_repeat): Better + debugging output. ------------------------------------------------------------------------ -r1771 | joe | 2009-12-30 21:28:48 +0000 (Wed, 30 Dec 2009) | 7 lines +r1854 | joe | 2011-09-14 09:53:24 +0100 (Wed, 14 Sep 2011) | 3 lines -Merge r1770 from trunk: +* test/request.c, test/ssl.c, test/redirect.c: Fix various + memory leaks in the test suite, found by --enable-memleak. -* src/ne_openssl.c (verify_callback): Handle OpenSSL error code - X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT as an untrusted cert. +------------------------------------------------------------------------ +r1853 | joe | 2011-09-02 10:52:44 +0100 (Fri, 02 Sep 2011) | 3 lines -Submitted by: Tom C +* src/ne_sspi.c (canonical_hostname): Use NE_ADDR_CANON to determine + canonical hostname. ------------------------------------------------------------------------ -r1767 | joe | 2009-12-15 22:24:26 +0000 (Tue, 15 Dec 2009) | 2 lines +r1852 | joe | 2011-09-02 10:51:02 +0100 (Fri, 02 Sep 2011) | 11 lines -* po/: make update-po. +* src/ne_socket.h: Add NE_ADDR_CANON flag, ne_addr_canonical. + +* src/ne_socket.c (struct ne_sock_addr_s): Add name field for non-gai. + (ne_addr_resolve): Handle NE_ADDR_CANON. + (ne_addr_canonical): New function. + (ne_addr_destroy): Free name field. + +* test/socket.c (addr_canonical): New test. + +* src/neon.vers: Add ne_addr_canonical. ------------------------------------------------------------------------ -r1753 | joe | 2009-12-14 20:45:16 +0000 (Mon, 14 Dec 2009) | 2 lines +r1851 | joe | 2011-07-10 20:22:13 +0100 (Sun, 10 Jul 2011) | 3 lines -* macros/neon.m4, NEWS: Prepare for 0.29.1. +* test/ssl.c (cache_verify): Trap errors from request dispatch, + remove unused variable. ------------------------------------------------------------------------ -r1751 | joe | 2009-12-02 21:40:41 +0000 (Wed, 02 Dec 2009) | 4 lines +r1850 | joe | 2011-07-10 20:19:26 +0100 (Sun, 10 Jul 2011) | 2 lines -Merge r1750 from trunk: +* test/props.c (unbounded_response): Remove set-but-unused variable. -* src/ne_gnutls.c (map_verify_failures): Fix build for GnuTLS < 2.8. +------------------------------------------------------------------------ +r1849 | joe | 2011-06-23 14:09:44 +0100 (Thu, 23 Jun 2011) | 2 lines + +* src/ne_ssl.h: Tweak wording on ne_ssl_clicert_read,import. ------------------------------------------------------------------------ -r1749 | joe | 2009-12-02 21:27:34 +0000 (Wed, 02 Dec 2009) | 13 lines +r1848 | joe | 2011-06-23 13:41:00 +0100 (Thu, 23 Jun 2011) | 2 lines -Merge r1739, r1744, r1746, r1747 from trunk: +* NEWS: Synch with 0.29.x. -* config.hw.in: Fix socklen_t with recent SDKs, thanks to Stefan Kung. +------------------------------------------------------------------------ +r1847 | joe | 2011-06-23 13:40:30 +0100 (Thu, 23 Jun 2011) | 18 lines -* src/ne_socket.c: Fixed 'missing symbol' win2k runtime problem. +* src/ne_ssl.h (ne_ssl_clicert_import): New function. -* src/ne_ntlm.c (ne__ntlm_authenticate) -* src/ne_auth.c (ntlm_challenge): - In case of session timeout, do not call auth callback; use - existing credentials. +* src/ne_openssl.c (parse_client_cert): Factor out from + ne_ssl_clicert_read. + (ne_ssl_clicert_read): Reimplement using above. + (ne_ssl_clicert_import): New function. -* src/ne_ntlm.c (mkhash): Fix buffer overflow (basic@mozdev.org). +* src/ne_gnutls.c (ne_ssl_clicert_import): Factor out from + ne_ssl_clicert_read. + (ne_ssl_clicert_import): Reimplement using above. + +* test/utils.c (file_to_buffer): Move to here... + +* test/compress.c (file2buf): ... from here. + (do_fetch): Use it. + +* test/ssl.c (clicert_import): New test. ------------------------------------------------------------------------ -r1743 | joe | 2009-10-25 11:25:24 +0000 (Sun, 25 Oct 2009) | 5 lines +r1846 | joe | 2011-06-17 11:54:54 +0100 (Fri, 17 Jun 2011) | 3 lines -Merge r1742 from trunk: +* doc/ref/proxy.xml, doc/ref/sess.xml, doc/manual.xml: Split out, and + complete, documentation of proxy support. -* src/ne_session.c (ne_session_create): Only enable SNI by default if - the server hostname does not parse as a numeric IP address. +------------------------------------------------------------------------ +r1845 | joe | 2011-05-03 16:27:18 +0100 (Tue, 03 May 2011) | 4 lines + +* src/ne_socket.c (ne_sock_accept_ssl) [HAVE_GNUTLS]: + Require a client cert if necessary, matching behaviour + w/ OpenSSL. ------------------------------------------------------------------------ -r1740 | joe | 2009-09-26 20:58:08 +0100 (Sat, 26 Sep 2009) | 9 lines +r1844 | joe | 2011-05-03 16:26:03 +0100 (Tue, 03 May 2011) | 2 lines -Merge r1738, r1739 from trunk: +* src/Makefile.in: Update deps. -* src/ne_socket.c (ne_iaddr_parse): Fix Win32 build for both - USE_GETADDRINFO and !USE_GETADDRINFO cases. +------------------------------------------------------------------------ +r1838 | joe | 2011-05-03 13:04:23 +0100 (Tue, 03 May 2011) | 9 lines -* config.hw.in: Fix socklen_t with recent SDKs, thanks to Stefan Kung. +Fix some errors flagged by a Coverity scan: -Reviewed by: jorton +* src/ne_auth.c (verify_negotiate_response): Check for NULL pointer. + +* src/ne_gnutls.c (check_certificate): Initiatialize 'failures'. + (pkcs12_parse): Check for _crt_init failure. + +* src/ne_session.c (ne__ssl_set_verify_err): Pass size-1 to strncat. ------------------------------------------------------------------------ -r1735 | joe | 2009-09-13 13:12:27 +0100 (Sun, 13 Sep 2009) | 2 lines +r1837 | joe | 2011-05-03 12:58:24 +0100 (Tue, 03 May 2011) | 5 lines -* macros/neon.m4: Don't ABI-tag LFS builds. +* src/ne_auth.c + (ah_post_send): Clear SSPI context only after successful authentication. + +Submitted by: Ivan Zhakov ------------------------------------------------------------------------ -r1733 | joe | 2009-09-13 12:57:58 +0100 (Sun, 13 Sep 2009) | 2 lines +r1836 | joe | 2011-05-03 12:57:03 +0100 (Tue, 03 May 2011) | 6 lines -* po/: make update-po. +* src/ne_gnutls.c (ne__ssl_init): Fix for GnuTLS with Nettle. + +* src/ne_auth.c (get_cnonce): Likewise. + +Submitted by: Arfrever Frehtes Taifersar Arahesis ------------------------------------------------------------------------ -r1732 | joe | 2009-09-13 12:57:18 +0100 (Sun, 13 Sep 2009) | 2 lines +r1833 | joe | 2011-03-01 13:23:43 +0000 (Tue, 01 Mar 2011) | 3 lines -* test/ssl.c (simple_sslv2): Skip better. +* src/ne_request.c (ne_request_create): Pass copied method to + pre_send hooks to avoid lifetime issues (Patrick Ohly). ------------------------------------------------------------------------ -r1731 | joe | 2009-09-13 12:56:25 +0100 (Sun, 13 Sep 2009) | 2 lines +r1828 | joe | 2010-11-11 12:23:05 +0000 (Thu, 11 Nov 2010) | 4 lines -* test/ssl.c (simple_sslv2): Skip for OpenSSL. +* src/ne_gnutls.c (provide_client_cert): Return success with no cert + if no cert is available; match behaviour with OpenSSL. Thanks to + Patrick Ohly. ------------------------------------------------------------------------ -r1730 | joe | 2009-09-13 12:56:10 +0100 (Sun, 13 Sep 2009) | 2 lines +r1827 | joe | 2010-11-07 19:41:27 +0000 (Sun, 07 Nov 2010) | 2 lines -* macros/neon.m4: Prep for 0.29.0. +* doc/ref/iaddr.xml: Update ne_iaddr_* docs. ------------------------------------------------------------------------ -r1729 | joe | 2009-09-13 12:43:01 +0100 (Sun, 13 Sep 2009) | 2 lines +r1819 | joe | 2010-10-09 17:01:29 +0100 (Sat, 09 Oct 2010) | 3 lines -* NEWS: Tweak wording. +* src/ne_socket.c (ne_sock_connect_ssl): Ignore TLS warnings + during handshake (Bryan Cain). ------------------------------------------------------------------------ -r1728 | joe | 2009-09-13 12:41:22 +0100 (Sun, 13 Sep 2009) | 2 lines +r1818 | joe | 2010-10-09 16:56:20 +0100 (Sat, 09 Oct 2010) | 5 lines -* NEWS: Note OpenSSL 1.0 beta build fix. +* test/socket.c (addr_reverse) [HAVE_GETHOSTNAME]: Accept system + hostname as reverse of 127.0.0.1. + +* macros/neon-test.m4 (NEON_TEST): Check for gethostname(). ------------------------------------------------------------------------ -r1727 | joe | 2009-09-13 12:40:59 +0100 (Sun, 13 Sep 2009) | 5 lines +r1811 | joe | 2010-09-28 12:55:07 +0100 (Tue, 28 Sep 2010) | 7 lines -Merge r1726 from trunk: +* src/ne_session.c (ne__ssl_match_hostname): Deny a wildcard match + against anything which parses as an IP address. -* src/ne_socket.c (ne_sock_close) [HAVE_OPENSSL]: Ensure SSL - connection is shut down cleanly. +* test/ssl.c (fail_wildcard_ip): Add test case. + +* test/makekeys.sh: Generate test wildcard IP cert. ------------------------------------------------------------------------ -r1725 | joe | 2009-09-13 12:26:52 +0100 (Sun, 13 Sep 2009) | 10 lines +r1810 | joe | 2010-09-28 09:49:04 +0100 (Tue, 28 Sep 2010) | 2 lines -Merge r1724 from trunk: +* test/request.c: Adjust to new test API throughout. -* src/ne_openssl.c: Include opensslv.h. - (SSL_SESSION_cmp): Define if not available, for OpenSSL >= 1.0. +------------------------------------------------------------------------ +r1809 | joe | 2010-09-28 09:47:07 +0100 (Tue, 28 Sep 2010) | 5 lines -* src/ne_socket.c (ne_sock_accept_ssl): Add debug log output if - session is resumed. +* src/ne_request.c (open_connection): If SOCKS proxy fails, set return + value to NE_ERROR. -* macros/neon.m4 (NEON_SSL): Check for SSL_SESSION_cmp. +* test/request.c (socks_fail): Add test case. ------------------------------------------------------------------------ -r1723 | joe | 2009-09-04 08:36:26 +0100 (Fri, 04 Sep 2009) | 6 lines +r1805 | joe | 2010-09-22 20:23:49 +0100 (Wed, 22 Sep 2010) | 4 lines + +* src/ne_auth.c (ah_post_send): Always clear the SSPI context. +(Danil Shopyrin) -Merge r1722 from trunk: -* Makefile.in, README: Collect copyright notices from po/*. +------------------------------------------------------------------------ +r1804 | joe | 2010-09-04 14:17:30 +0100 (Sat, 04 Sep 2010) | 2 lines -* po/: Update copyright notices. +* test/ssl.c (fail_ssl_request_with_error2): Document better. ------------------------------------------------------------------------ -r1721 | joe | 2009-09-04 08:29:23 +0100 (Fri, 04 Sep 2009) | 2 lines +r1803 | joe | 2010-09-04 14:16:22 +0100 (Sat, 04 Sep 2010) | 2 lines -* po/pl.po, NEWS: Update Polish translation (Arfrever Frehtes Taifersar Arahesis). +* src/ne_session.h: Wording tweak. ------------------------------------------------------------------------ -r1720 | joe | 2009-09-04 08:27:49 +0100 (Fri, 04 Sep 2009) | 2 lines +r1802 | joe | 2010-09-04 14:15:29 +0100 (Sat, 04 Sep 2010) | 2 lines -* NEWS: Update. +* macros/neon.m4 (NE_CHECK_FUNCS): Fix AI_ADDRCONFIG detection. ------------------------------------------------------------------------ -r1717 | joe | 2009-09-02 21:44:08 +0100 (Wed, 02 Sep 2009) | 2 lines +r1801 | joe | 2010-05-05 09:25:17 +0100 (Wed, 05 May 2010) | 7 lines -* po/: make update-po. +* src/ne_request.c (body_fd_send): Handle read() errors; thanks to Lou + Montulli. + +* test/request.c (serve_mirror, send_length): Add test case. + +* test/Makefile.in (foobar.txt): Create test file. ------------------------------------------------------------------------ -r1716 | joe | 2009-09-02 21:43:09 +0100 (Wed, 02 Sep 2009) | 2 lines +r1799 | joe | 2010-04-23 10:02:28 +0100 (Fri, 23 Apr 2010) | 2 lines -* NEWS: Update. +* src/ne_socket.c (raw_poll): Check for execptions in select(). ------------------------------------------------------------------------ -r1715 | joe | 2009-09-02 21:29:42 +0100 (Wed, 02 Sep 2009) | 10 lines +r1798 | joe | 2010-04-21 21:41:01 +0100 (Wed, 21 Apr 2010) | 3 lines -Merge r1713, r1714 from trunk: +* test/lock.c (fake_session): New function. + (everywhere): Replace use of make_session with fake_session. -* src/ne_request.c (socks_origin_lookup): New function. - (open_connection): Use it to fix support for SOCKSv4 servers. +------------------------------------------------------------------------ +r1797 | joe | 2010-04-21 21:30:46 +0100 (Wed, 21 Apr 2010) | 3 lines -* test/request.c (socks_v4_proxy): Add test case. +* src/ne_auth.c: Add handling of 2xx responses in SSPI code. +(Danil Shopyrin ) + +------------------------------------------------------------------------ +r1795 | joe | 2010-03-29 10:14:16 +0100 (Mon, 29 Mar 2010) | 2 lines + +* doc/ref/reqflags.xml: Doc tweak. + +------------------------------------------------------------------------ +r1794 | joe | 2010-03-29 09:49:56 +0100 (Mon, 29 Mar 2010) | 3 lines + +* src/ne_session.c (ne_session_create): Fix to enable SNI by default again. + (Tobias Gruetzmacher) + +------------------------------------------------------------------------ +r1793 | joe | 2010-03-25 07:57:36 +0000 (Thu, 25 Mar 2010) | 2 lines + +* doc/ref/: Fix some refpurposes. + +------------------------------------------------------------------------ +r1792 | joe | 2010-03-11 10:03:38 +0000 (Thu, 11 Mar 2010) | 2 lines + +* src/ne_request.c (do_connect): Tweak debugging. + +------------------------------------------------------------------------ +r1780 | joe | 2010-01-11 10:23:06 +0000 (Mon, 11 Jan 2010) | 3 lines + +* test/socket.c (ssl_closure, ssl_truncate): Don't expect clean + closure. + +------------------------------------------------------------------------ +r1779 | joe | 2010-01-10 22:42:55 +0000 (Sun, 10 Jan 2010) | 3 lines + +* test/socket.c (ssl_closure, ssl_truncate): Don't expect clean + closure. + +------------------------------------------------------------------------ +r1778 | joe | 2010-01-10 21:53:58 +0000 (Sun, 10 Jan 2010) | 2 lines + +* src/ne_socket.c (ne_sock_accept): Set the socket error string. + +------------------------------------------------------------------------ +r1777 | joe | 2010-01-08 11:09:36 +0000 (Fri, 08 Jan 2010) | 4 lines + +* src/ne_defs.h: Only define NE_PRIVATE if undefined. + +* configure.in: Define NE_PRIVATE to 'extern' for a static build. + +------------------------------------------------------------------------ +r1770 | joe | 2009-12-30 21:26:50 +0000 (Wed, 30 Dec 2009) | 5 lines + +* src/ne_openssl.c (verify_callback): Handle OpenSSL error code + X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT as an untrusted cert. + +Submitted by: Tom C + +------------------------------------------------------------------------ +r1764 | joe | 2009-12-15 22:19:06 +0000 (Tue, 15 Dec 2009) | 1 line + +NEWS: Sync with 0.29.x branch. +------------------------------------------------------------------------ +r1761 | joe | 2009-12-14 21:43:45 +0000 (Mon, 14 Dec 2009) | 2 lines + +* test/session.c: Avoid hard-coded references to port 7777. + +------------------------------------------------------------------------ +r1760 | joe | 2009-12-14 21:43:22 +0000 (Mon, 14 Dec 2009) | 3 lines + +* test/auth.c: Adjust to use {proxied_,}session_server API, avoid + hard-coded use of port 7777. + +------------------------------------------------------------------------ +r1759 | joe | 2009-12-14 21:41:24 +0000 (Mon, 14 Dec 2009) | 4 lines + +* test/common/child.c (new_spawn_server): Take 'repeat' argument. + +* test/socket.c, test/utils.c: Adjust accordingly. + +------------------------------------------------------------------------ +r1758 | joe | 2009-12-14 21:01:35 +0000 (Mon, 14 Dec 2009) | 2 lines + +* test/utils.c (proxied_session_server): Take scheme argument. + +------------------------------------------------------------------------ +r1757 | joe | 2009-12-14 20:56:20 +0000 (Mon, 14 Dec 2009) | 2 lines + +* test/socket.c, test/stubs.c: Adapt for {proxied_}session_server. + +------------------------------------------------------------------------ +r1756 | joe | 2009-12-14 20:55:43 +0000 (Mon, 14 Dec 2009) | 3 lines + +* test/auth.c, test/redirect.c, test/props.c: Adapt to use + session_server, proxied_session_server. + +------------------------------------------------------------------------ +r1755 | joe | 2009-12-14 20:52:45 +0000 (Mon, 14 Dec 2009) | 3 lines + +* test/utils.c (session_server, proxied_session_server): New + functions. (make_session): Use session_server. + +------------------------------------------------------------------------ +r1754 | joe | 2009-12-14 20:48:40 +0000 (Mon, 14 Dec 2009) | 2 lines + +* test/common/child.c, child.h (new_spawn_server): New function. + +------------------------------------------------------------------------ +r1750 | joe | 2009-12-02 21:38:17 +0000 (Wed, 02 Dec 2009) | 2 lines + +* src/ne_gnutls.c (map_verify_failures): Fix build for GnuTLS < 2.8. + +------------------------------------------------------------------------ +r1748 | joe | 2009-12-02 21:16:17 +0000 (Wed, 02 Dec 2009) | 8 lines + +Clear sspi_token buffer after each request. + +* src/ne_auth.c (request_sspi): Return NULL if sspi_token is not present. + +* src/ne_auth.c (ah_post_send): Clear the buffered sspi_token. + +Submitted by: Danil Shopyrin + +------------------------------------------------------------------------ +r1747 | joe | 2009-12-02 21:15:12 +0000 (Wed, 02 Dec 2009) | 2 lines + +* src/ne_ntlm.c (mkhash): Fix buffer overflow (basic@mozdev.org). + +------------------------------------------------------------------------ +r1746 | kso | 2009-11-19 22:36:08 +0000 (Thu, 19 Nov 2009) | 5 lines + +* src/ne_ntlm.c (ne__ntlm_authenticate) +* src/ne_auth.c (ntlm_challenge) + - in case of session timeout, do not call auth callback; use + existing credentials. + +------------------------------------------------------------------------ +r1745 | kso | 2009-11-13 09:29:37 +0000 (Fri, 13 Nov 2009) | 1 line + +* src/ne_utils.c, src/ne_utils.h : Added NE_FEATURE_SSPI. +------------------------------------------------------------------------ +r1744 | kso | 2009-11-13 08:56:21 +0000 (Fri, 13 Nov 2009) | 1 line + +fixed 'missing symbol' win2k runtime problem. +------------------------------------------------------------------------ +r1742 | joe | 2009-10-25 10:20:19 +0000 (Sun, 25 Oct 2009) | 3 lines + +* src/ne_session.c (ne_session_create): Only enable SNI by default if + the server hostname does not parse as a numeric IP address. + +------------------------------------------------------------------------ +r1739 | joe | 2009-09-26 20:56:52 +0100 (Sat, 26 Sep 2009) | 2 lines + +* config.hw.in: Fix socklen_t with recent SDKs, thanks to Stefan Kung. + +------------------------------------------------------------------------ +r1738 | joe | 2009-09-26 20:55:51 +0100 (Sat, 26 Sep 2009) | 3 lines + +* src/ne_socket.c (ne_sock_close) [HAVE_OPENSSL]: Ensure SSL + connection is shut down cleanly. + +------------------------------------------------------------------------ +r1726 | joe | 2009-09-13 12:37:13 +0100 (Sun, 13 Sep 2009) | 3 lines + +* src/ne_socket.c (ne_sock_close) [HAVE_OPENSSL]: Ensure SSL + connection is shut down cleanly. + +------------------------------------------------------------------------ +r1724 | joe | 2009-09-12 21:03:49 +0100 (Sat, 12 Sep 2009) | 8 lines * macros/neon.m4 (LIBNEON_SOURCE_CHECKS): Require inet_pton for getaddrinfo support. +* src/ne_socket.c (ne_sock_accept_ssl): Add debug log output if + session is resumed. + +* macros/neon.m4 (NEON_SSL): Check for SSL_SESSION_cmp. + ------------------------------------------------------------------------ -r1712 | joe | 2009-09-02 20:43:05 +0100 (Wed, 02 Sep 2009) | 22 lines +r1722 | joe | 2009-09-04 08:35:11 +0100 (Fri, 04 Sep 2009) | 4 lines -Merge r1709, r1710, r1711 from trunk: +* Makefile.in, README: Collect copyright notices from po/*. -* test/util-socks.c (read_socks_0string): Pass through context string. - (socks_server): Fail for v4 server without expected address. - Don't write "ok" message for v4 server without say_hello flag. +* po/: Update copyright notices. -* src/ne_socket.c (ne_iaddr_parse): New function. - -* test/socket.c (check_is_raw127): Factored out from addr_make_v4. - (parse_v4): New function. - (addr_make_v6): Test ne_iaddr_parse for IPv6 addresses. - (socks_proxy): Fix for non-v6-enabled builds. +------------------------------------------------------------------------ +r1719 | joe | 2009-09-04 08:14:03 +0100 (Fri, 04 Sep 2009) | 2 lines -* src/ne_socket.c (ne_iaddr_parse) [!USE_GETADDRINFO]: Fail for IPv6 - addresses. +* po/pl.po: Update, from Arfrever Frehtes Taifersar Arahesis. -* test/socket.c (addr_make_v6) [!TEST_IPV6]: Test for failure. +------------------------------------------------------------------------ +r1718 | joe | 2009-09-04 08:12:58 +0100 (Fri, 04 Sep 2009) | 1 line -Also: +* macros/neon.m4: Bump to 0.30.0-dev. +------------------------------------------------------------------------ +r1714 | joe | 2009-09-02 21:26:39 +0100 (Wed, 02 Sep 2009) | 3 lines -* src/neon.vers: Add ne_iaddr_parse. +* macros/neon.m4 (LIBNEON_SOURCE_CHECKS): Require inet_pton for + getaddrinfo support. ------------------------------------------------------------------------ -r1708 | joe | 2009-09-02 15:51:26 +0100 (Wed, 02 Sep 2009) | 2 lines +r1713 | joe | 2009-09-02 21:25:59 +0100 (Wed, 02 Sep 2009) | 5 lines -* macros/neon.m4: Set libtool versions as backwards-compat to 0.27.x. +* src/ne_request.c (socks_origin_lookup): New function. + (open_connection): Use it to fix support for SOCKSv4 servers. + +* test/request.c (socks_v4_proxy): Add test case. ------------------------------------------------------------------------ -r1707 | joe | 2009-09-02 15:50:59 +0100 (Wed, 02 Sep 2009) | 2 lines +r1711 | joe | 2009-09-02 18:28:56 +0100 (Wed, 02 Sep 2009) | 5 lines -* po/: make update-po. +* src/ne_socket.c (ne_iaddr_parse) [!USE_GETADDRINFO]: Fail for IPv6 + addresses. + +* test/socket.c (addr_make_v6) [!TEST_IPV6]: Test for failure. ------------------------------------------------------------------------ -r1706 | joe | 2009-09-02 15:40:47 +0100 (Wed, 02 Sep 2009) | 2 lines +r1710 | joe | 2009-09-02 17:06:11 +0100 (Wed, 02 Sep 2009) | 7 lines -Branch for 0.29.x. +* src/ne_socket.c (ne_iaddr_parse): New function. + +* test/socket.c (check_is_raw127): Factored out from addr_make_v4. + (parse_v4): New function. + (addr_make_v6): Test ne_iaddr_parse for IPv6 addresses. + (socks_proxy): Fix for non-v6-enabled builds. + +------------------------------------------------------------------------ +r1709 | joe | 2009-09-02 16:50:05 +0100 (Wed, 02 Sep 2009) | 4 lines + +* test/util-socks.c (read_socks_0string): Pass through context string. + (socks_server): Fail for v4 server without expected address. + Don't write "ok" message for v4 server without say_hello flag. ------------------------------------------------------------------------ r1705 | joe | 2009-09-02 15:40:13 +0100 (Wed, 02 Sep 2009) | 2 lines diff --git a/libs/neon/Makefile.bcb b/libs/neon/Makefile.bcb index 2f96da4b..9676652f 100644 --- a/libs/neon/Makefile.bcb +++ b/libs/neon/Makefile.bcb @@ -1,12 +1,11 @@ # Set your compiler options OPENSSL_CFLAG=-DWIN32_LEAN_AND_MEAN -q -w-ccc -w-rch -w-pia -w-aus -w-par -w-inl -w-eff -w-sus -w-dup -w-spa -w-csu -w-rvl -c -tWC -tWM -DOPENSSL_SYSNAME_WIN32 -DL_ENDIAN -DDSO_WIN32 -D_stricmp=stricmp -D_strnicmp=strnicmp -O2 -ff -fp -DBN_ASM -DMD5_ASM -DSHA1_ASM -DRMD160_ASM -DOPENSSL_NO_CAMELLIA -DOPENSSL_NO_SEED -DOPENSSL_NO_RC5 -DOPENSSL_NO_MDC2 -DOPENSSL_NO_CMS -DOPENSSL_NO_CAPIENG -DOPENSSL_NO_KRB5 -DOPENSSL_NO_ENGINE -DOPENSSL_NO_DYNAMIC_ENGINE -DOPENSSL_DISABLE_OLD_DES_SUPPORT -DNO_CHMOD -DOPENSSL_NO_SOCK -DOPENSSL_NO_DGRAM -DOPENSSL_NO_EC -DOPENSSL_NO_ECDH -DOPENSSL_NO_ECDSA -DDOPENSSL_NO_EC_NISTP_64_GCC_128 -ZLIB_CFLAG=-DWIN32 -DWIN32_LEAN_AND_MEAN -q -w-ccc -w-rch -w-pia -w-aus -w-par -w-inl -w-eff -w-sus -w-dup -w-spa -w-csu -w-rvl -c -tWC -tWM -D_stricmp=stricmp -D_strnicmp=strnicmp -O2 -ff -fp -DNE_HAVE_SSL;HAVE_OPENSSL;HAVE_EXPAT;HAVE_EXPAT_H;NE_HAVE_DAV;NE_HAVE_ZLIB;USE_GETADDRINFO;NOUSER;NOGDI;COMPILED_FROM_DSP;XML_STATIC;_RTLDLL; -D__STDC__ EXPAT_CFLAG1=-D_WINDOWS;WIN32;NDEBUG;_LIB;COMPILED_FROM_DSP;XML_STATIC; EXPAT_CFLAG2=-D_NO_VCL;_ASSERTE;NO_STRICT;_RTLDLL -CFLAG=-DWIN32 -DWIN32_LEAN_AND_MEAN -q -w-ccc -w-rch -w-pia -w-aus -w-par -w-inl -w-eff -w-sus -w-dup -w-spa -w-csu -w-rvl -c -tWC -tWM -D_stricmp=stricmp -D_strnicmp=strnicmp -O2 -ff -fp -DNE_HAVE_SSL;HAVE_OPENSSL;HAVE_EXPAT;HAVE_EXPAT_H;NE_HAVE_DAV;NE_HAVE_ZLIB;USE_GETADDRINFO;NOUSER;NOGDI;COMPILED_FROM_DSP;XML_STATIC;_RTLDLL; -D__STDC__ +CFLAG=-DWIN32 -DWIN32_LEAN_AND_MEAN -q -w-ccc -w-rch -w-pia -w-aus -w-par -w-inl -w-eff -w-sus -w-dup -w-spa -w-csu -w-rvl -c -tWC -tWM -D_stricmp=stricmp -D_strnicmp=strnicmp -O2 -ff -fp -DNE_HAVE_SSL;HAVE_OPENSSL;HAVE_EXPAT;HAVE_EXPAT_H;NE_HAVE_DAV;NE_LFS;USE_GETADDRINFO;NOUSER;NOGDI;COMPILED_FROM_DSP;XML_STATIC;_RTLDLL;HAVE_STRTOLL;WINSCP; CFLAG = $(CFLAG) -w-8065 -w-8069 -LIB_CFLAG=$(OPENSSL_CFLAG) $(ZLIB_CFLAG) $(EXPAT_CFLAG1) $(EXPAT_CFLAG2) +LIB_CFLAG=$(OPENSSL_CFLAG) $(EXPAT_CFLAG1) $(EXPAT_CFLAG2) # neon directory SRC_D=. @@ -31,7 +30,7 @@ ASM=nasm -f obj -d__omf__ # OBJ_D - temp object file directory OBJ_D=$(TMP_D) INCL_D=src -INCL=$(INCL_D);../openssl;../zlib/src;../expat/lib; +INCL=$(INCL_D);../openssl;../expat/lib; O_NEON=$(OUT_D)\neon.lib diff --git a/libs/neon/NEWS b/libs/neon/NEWS index babeb95c..3f5058c2 100644 --- a/libs/neon/NEWS +++ b/libs/neon/NEWS @@ -1,8 +1,26 @@ +Changes in release 0.30.0: +* Interface changes: + - none, API and ABI backwards-compatible with 0.27.x and later +* New interfaces and features: + - ne_ssl.h: added ne_ssl_clicert_import, ne_ssl_context_get_flag + - ne_session.h: added ne_set_addrlist2 + - ne_socket.h: added ne_addr_canonical + - ne_auth.h: added NE_AUTH_GSSAPI_ONLY, NE_AUTH_SSPI (Nathanael Rensen) + - ne_basic.h: added NE_CAP_EXT_MKCOL options test + - ne_request.h: support chunked bodies with negative length passed to + ne_set_request_body_provider (Julien Reichel) +* Bug fixes: + - ne_path_escape: fix excessive memory allocation (Pierre Crokaert) + - SSPI auth: use canonical server hostname, clear SSPI context after + successful auth (Nathanael Rensen) + - build fixes for Open Watcom compiler (NormW) + - fix Win32 error code handling for local ne_sock_prebind bind failure + - Win32: support LFS, thread-safe OpenSSL (Diego Santa Cruz) + - GnuTLS: fix GnuTLS 3.x support (Matthias Petschick, Bartosz Brachaczek) + Changes in release 0.29.6: * Don't abort SSL handshake with GnuTLS if a client cert is requested but none is configured/available (thanks to Patrick Ohly) -* Fix GnuTLS build with Nettle (Arfrever Frehtes Taifersar Arahesis) -* Win32: Fix handling of SSPI challenges (Ivan Zhakov) * Fix the method string passed to create_request hooks to have the same lifetime as the request object (Patrick Ohly) * Docs updates. @@ -38,6 +56,7 @@ Changes in release 0.29.1: * Fixes for (Unix) NTLM implementation: - fix handling of session timeout (Kai Sommerfeld) - fix possible crash (basic@mozdev.org) +* Fix unnecessary re-authentication with SSPI (Danil Shopyrin) * Build fixes for Win32: - fix use of socklen_t with recent SDKs (Stefan Kung) - fix USE_GETADDRINFO on Win2K (Kai Sommerfeld) diff --git a/libs/neon/aclocal.m4 b/libs/neon/aclocal.m4 index f810d836..4963e5bf 100644 --- a/libs/neon/aclocal.m4 +++ b/libs/neon/aclocal.m4 @@ -1,7 +1,7 @@ -# generated automatically by aclocal 1.11.1 -*- Autoconf -*- +# generated automatically by aclocal 1.13.4 -*- Autoconf -*- + +# Copyright (C) 1996-2013 Free Software Foundation, Inc. -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -11,11 +11,12 @@ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. +m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010 Free Software Foundation, -# Inc. +# 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives @@ -24,8 +25,8 @@ m4_define([_LT_COPYING], [dnl # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010 Free Software Foundation, -# Inc. +# 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. @@ -159,6 +160,8 @@ AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl +_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl +dnl _LT_DECL([], [host_alias], [0], [The host system])dnl _LT_DECL([], [host], [0])dnl _LT_DECL([], [host_os], [0])dnl @@ -181,10 +184,13 @@ _LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl +m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl m4_require([_LT_CMD_RELOAD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl +m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl +m4_require([_LT_WITH_SYSROOT])dnl _LT_CONFIG_LIBTOOL_INIT([ # See if we are running on zsh, and set the options which allow our @@ -641,7 +647,7 @@ m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2011 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." @@ -755,15 +761,12 @@ _LT_EOF # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? - sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) + sed '$q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) - _LT_PROG_XSI_SHELLFNS + _LT_PROG_REPLACE_SHELLFNS - sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - mv -f "$cfgfile" "$ofile" || + mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ], @@ -808,6 +811,7 @@ AC_DEFUN([LT_LANG], m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], + [Go], [_LT_LANG(GO)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], [Fortran], [_LT_LANG(FC)], @@ -829,6 +833,29 @@ m4_defun([_LT_LANG], ])# _LT_LANG +m4_ifndef([AC_PROG_GO], [ +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_GO. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +m4_defun([AC_PROG_GO], +[AC_LANG_PUSH(Go)dnl +AC_ARG_VAR([GOC], [Go compiler command])dnl +AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl +_AC_ARG_VAR_LDFLAGS()dnl +AC_CHECK_TOOL(GOC, gccgo) +if test -z "$GOC"; then + if test -n "$ac_tool_prefix"; then + AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) + fi +fi +if test -z "$GOC"; then + AC_CHECK_PROG(GOC, gccgo, gccgo, false) +fi +])#m4_defun +])#m4_ifndef + + # _LT_LANG_DEFAULT_CONFIG # ----------------------- m4_defun([_LT_LANG_DEFAULT_CONFIG], @@ -859,6 +886,10 @@ AC_PROVIDE_IFELSE([AC_PROG_GCJ], m4_ifdef([LT_PROG_GCJ], [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) +AC_PROVIDE_IFELSE([AC_PROG_GO], + [LT_LANG(GO)], + [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) + AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) @@ -961,7 +992,13 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? - if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then + # If there is a non-empty error log, and "single_module" + # appears in it, assume the flag caused a linker warning + if test -s conftest.err && $GREP single_module conftest.err; then + cat conftest.err >&AS_MESSAGE_LOG_FD + # Otherwise, if the output was created with a 0 exit code from + # the compiler, it worked. + elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD @@ -969,6 +1006,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ rm -rf libconftest.dylib* rm -f conftest.* fi]) + AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no @@ -980,6 +1018,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ [lt_cv_ld_exported_symbols_list=no]) LDFLAGS="$save_LDFLAGS" ]) + AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], [lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF @@ -997,7 +1036,9 @@ _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? - if test -f conftest && test ! -s conftest.err && test $_lt_result = 0 && $GREP forced_load conftest 2>&1 >/dev/null; then + if test -s conftest.err && $GREP force_load conftest.err; then + cat conftest.err >&AS_MESSAGE_LOG_FD + elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&AS_MESSAGE_LOG_FD @@ -1042,8 +1083,8 @@ _LT_EOF ]) -# _LT_DARWIN_LINKER_FEATURES -# -------------------------- +# _LT_DARWIN_LINKER_FEATURES([TAG]) +# --------------------------------- # Checks for linker and compiler features on darwin m4_defun([_LT_DARWIN_LINKER_FEATURES], [ @@ -1054,6 +1095,8 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES], _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported if test "$lt_cv_ld_force_load" = "yes"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' + m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], + [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) else _LT_TAGVAR(whole_archive_flag_spec, $1)='' fi @@ -1080,30 +1123,41 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES], fi ]) -# _LT_SYS_MODULE_PATH_AIX -# ----------------------- +# _LT_SYS_MODULE_PATH_AIX([TAGNAME]) +# ---------------------------------- # Links a minimal program and checks the executable # for the system default hardcoded library path. In most cases, # this is /usr/lib:/lib, but when the MPI compilers are used # the location of the communication and MPI libs are included too. # If we don't find anything, use the default library path according # to the aix ld manual. +# Store the results from the different compilers for each TAGNAME. +# Allow to override them for all tags through lt_cv_aix_libpath. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl -AC_LINK_IFELSE(AC_LANG_PROGRAM,[ -lt_aix_libpath_sed=' - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\(.*\)$/\1/ - p - } - }' -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then - aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -fi],[]) -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +if test "${lt_cv_aix_libpath+set}" = set; then + aix_libpath=$lt_cv_aix_libpath +else + AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], + [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ + lt_aix_libpath_sed='[ + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\([^ ]*\) *$/\1/ + p + } + }]' + _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + # Check for a 64-bit object if we didn't find anything. + if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then + _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + fi],[]) + if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then + _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib" + fi + ]) + aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) +fi ])# _LT_SYS_MODULE_PATH_AIX @@ -1128,7 +1182,7 @@ ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO AC_MSG_CHECKING([how to print strings]) # Test print first, because it will be a builtin if present. -if test "X`print -r -- -n 2>/dev/null`" = X-n && \ +if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then @@ -1172,6 +1226,39 @@ _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) ])# _LT_PROG_ECHO_BACKSLASH +# _LT_WITH_SYSROOT +# ---------------- +AC_DEFUN([_LT_WITH_SYSROOT], +[AC_MSG_CHECKING([for sysroot]) +AC_ARG_WITH([sysroot], +[ --with-sysroot[=DIR] Search for dependent libraries within DIR + (or the compiler's sysroot if not specified).], +[], [with_sysroot=no]) + +dnl lt_sysroot will always be passed unquoted. We quote it here +dnl in case the user passed a directory name. +lt_sysroot= +case ${with_sysroot} in #( + yes) + if test "$GCC" = yes; then + lt_sysroot=`$CC --print-sysroot 2>/dev/null` + fi + ;; #( + /*) + lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` + ;; #( + no|'') + ;; #( + *) + AC_MSG_RESULT([${with_sysroot}]) + AC_MSG_ERROR([The sysroot must be an absolute path.]) + ;; +esac + + AC_MSG_RESULT([${lt_sysroot:-no}]) +_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl +[dependent libraries, and in which our libraries should be installed.])]) + # _LT_ENABLE_LOCK # --------------- m4_defun([_LT_ENABLE_LOCK], @@ -1293,14 +1380,27 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) CFLAGS="$SAVE_CFLAGS" fi ;; -sparc*-*solaris*) +*-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in - yes*) LD="${LD-ld} -m elf64_sparc" ;; + yes*) + case $host in + i?86-*-solaris*) + LD="${LD-ld} -m elf_x86_64" + ;; + sparc*-*-solaris*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + # GNU ld 2.21 introduced _sol2 emulations. Use them if available. + if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then + LD="${LD-ld}_sol2" + fi + ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" @@ -1318,14 +1418,47 @@ need_locks="$enable_libtool_lock" ])# _LT_ENABLE_LOCK +# _LT_PROG_AR +# ----------- +m4_defun([_LT_PROG_AR], +[AC_CHECK_TOOLS(AR, [ar], false) +: ${AR=ar} +: ${AR_FLAGS=cru} +_LT_DECL([], [AR], [1], [The archiver]) +_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) + +AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], + [lt_cv_ar_at_file=no + AC_COMPILE_IFELSE([AC_LANG_PROGRAM], + [echo conftest.$ac_objext > conftest.lst + lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' + AC_TRY_EVAL([lt_ar_try]) + if test "$ac_status" -eq 0; then + # Ensure the archiver fails upon bogus file names. + rm -f conftest.$ac_objext libconftest.a + AC_TRY_EVAL([lt_ar_try]) + if test "$ac_status" -ne 0; then + lt_cv_ar_at_file=@ + fi + fi + rm -f conftest.* libconftest.a + ]) + ]) + +if test "x$lt_cv_ar_at_file" = xno; then + archiver_list_spec= +else + archiver_list_spec=$lt_cv_ar_at_file +fi +_LT_DECL([], [archiver_list_spec], [1], + [How to feed a file listing to the archiver]) +])# _LT_PROG_AR + + # _LT_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], -[AC_CHECK_TOOL(AR, ar, false) -test -z "$AR" && AR=ar -test -z "$AR_FLAGS" && AR_FLAGS=cru -_LT_DECL([], [AR], [1], [The archiver]) -_LT_DECL([], [AR_FLAGS], [1]) +[_LT_PROG_AR AC_CHECK_TOOL(STRIP, strip, :) test -z "$STRIP" && STRIP=: @@ -1344,13 +1477,13 @@ old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" + old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in @@ -1530,6 +1663,11 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl lt_cv_sys_max_cmd_len=196608 ;; + os2*) + # The test takes a long time on OS/2. + lt_cv_sys_max_cmd_len=8192 + ;; + osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not @@ -1569,7 +1707,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. - while { test "X"`func_fallback_echo "$teststring$teststring" 2>/dev/null` \ + while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do @@ -1665,10 +1803,10 @@ else /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) -void fnord () __attribute__((visibility("default"))); +int fnord () __attribute__((visibility("default"))); #endif -void fnord () { int i=42; } +int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); @@ -2115,7 +2253,7 @@ need_version=unknown case $host_os in aix3*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH @@ -2124,7 +2262,7 @@ aix3*) ;; aix[[4-9]]*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes @@ -2189,7 +2327,7 @@ beos*) ;; bsdi[[45]]*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' @@ -2208,8 +2346,9 @@ cygwin* | mingw* | pw32* | cegcc*) need_version=no need_lib_prefix=no - case $GCC,$host_os in - yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) + case $GCC,$cc_basename in + yes,*) + # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ @@ -2242,13 +2381,71 @@ m4_if([$1], [],[ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; esac + dynamic_linker='Win32 ld.exe' + ;; + + *,cl*) + # Native MSVC + libname_spec='$name' + soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + library_names_spec='${libname}.dll.lib' + + case $build_os in + mingw*) + sys_lib_search_path_spec= + lt_save_ifs=$IFS + IFS=';' + for lt_path in $LIB + do + IFS=$lt_save_ifs + # Let DOS variable expansion print the short 8.3 style file name. + lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` + sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" + done + IFS=$lt_save_ifs + # Convert to MSYS style. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` + ;; + cygwin*) + # Convert to unix form, then to dos form, then back to unix form + # but this time dos style (no spaces!) so that the unix form looks + # like /cygdrive/c/PROGRA~1:/cygdr... + sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` + sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` + sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + ;; + *) + sys_lib_search_path_spec="$LIB" + if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then + # It is most probably a Windows format PATH. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # FIXME: find the short name or the path components, as spaces are + # common. (e.g. "Program Files" -> "PROGRA~1") + ;; + esac + + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + dynamic_linker='Win32 link.exe' ;; *) + # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' + dynamic_linker='Win32 ld.exe' ;; esac - dynamic_linker='Win32 ld.exe' # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; @@ -2269,7 +2466,7 @@ m4_if([$1], [],[ ;; dgux*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' @@ -2277,10 +2474,6 @@ dgux*) shlibpath_var=LD_LIBRARY_PATH ;; -freebsd1*) - dynamic_linker=no - ;; - freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. @@ -2288,7 +2481,7 @@ freebsd* | dragonfly*) objformat=`/usr/bin/objformat` else case $host_os in - freebsd[[123]]*) objformat=aout ;; + freebsd[[23]].*) objformat=aout ;; *) objformat=elf ;; esac fi @@ -2306,7 +2499,7 @@ freebsd* | dragonfly*) esac shlibpath_var=LD_LIBRARY_PATH case $host_os in - freebsd2*) + freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[[01]]* | freebsdelf3.[[01]]*) @@ -2326,17 +2519,18 @@ freebsd* | dragonfly*) ;; gnu*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; haiku*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" @@ -2397,7 +2591,7 @@ hpux9* | hpux10* | hpux11*) ;; interix[[3-9]]*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' @@ -2413,7 +2607,7 @@ irix5* | irix6* | nonstopux*) nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; @@ -2450,9 +2644,9 @@ linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; -# This must be Linux ELF. +# This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -2519,7 +2713,7 @@ netbsd*) ;; newsos6) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes @@ -2588,7 +2782,7 @@ rdos*) ;; solaris*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -2613,7 +2807,7 @@ sunos4*) ;; sysv4 | sysv4.3*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH @@ -2637,7 +2831,7 @@ sysv4 | sysv4.3*) sysv4*MP*) if test -d /usr/nec ;then - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH @@ -2668,7 +2862,7 @@ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -2678,7 +2872,7 @@ tpf*) ;; uts4*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH @@ -2956,6 +3150,11 @@ case $reload_flag in esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + if test "$GCC" != yes; then + reload_cmds=false + fi + ;; darwin*) if test "$GCC" = yes; then reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' @@ -3095,7 +3294,7 @@ irix5* | irix6* | nonstopux*) lt_cv_deplibs_check_method=pass_all ;; -# This must be Linux ELF. +# This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; @@ -3174,6 +3373,21 @@ tpf*) ;; esac ]) + +file_magic_glob= +want_nocaseglob=no +if test "$build" = "$host"; then + case $host_os in + mingw* | pw32*) + if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then + want_nocaseglob=yes + else + file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` + fi + ;; + esac +fi + file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown @@ -3181,7 +3395,11 @@ test -z "$deplibs_check_method" && deplibs_check_method=unknown _LT_DECL([], [deplibs_check_method], [1], [Method to check whether dependent libraries are shared objects]) _LT_DECL([], [file_magic_cmd], [1], - [Command to use when deplibs_check_method == "file_magic"]) + [Command to use when deplibs_check_method = "file_magic"]) +_LT_DECL([], [file_magic_glob], [1], + [How to find potential files when deplibs_check_method = "file_magic"]) +_LT_DECL([], [want_nocaseglob], [1], + [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) ])# _LT_CHECK_MAGIC_METHOD @@ -3284,6 +3502,67 @@ dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_PROG_NM], []) dnl AC_DEFUN([AC_PROG_NM], []) +# _LT_CHECK_SHAREDLIB_FROM_LINKLIB +# -------------------------------- +# how to determine the name of the shared library +# associated with a specific link library. +# -- PORTME fill in with the dynamic library characteristics +m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], +[m4_require([_LT_DECL_EGREP]) +m4_require([_LT_DECL_OBJDUMP]) +m4_require([_LT_DECL_DLLTOOL]) +AC_CACHE_CHECK([how to associate runtime and link libraries], +lt_cv_sharedlib_from_linklib_cmd, +[lt_cv_sharedlib_from_linklib_cmd='unknown' + +case $host_os in +cygwin* | mingw* | pw32* | cegcc*) + # two different shell functions defined in ltmain.sh + # decide which to use based on capabilities of $DLLTOOL + case `$DLLTOOL --help 2>&1` in + *--identify-strict*) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib + ;; + *) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback + ;; + esac + ;; +*) + # fallback: assume linklib IS sharedlib + lt_cv_sharedlib_from_linklib_cmd="$ECHO" + ;; +esac +]) +sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd +test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO + +_LT_DECL([], [sharedlib_from_linklib_cmd], [1], + [Command to associate shared and link libraries]) +])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB + + +# _LT_PATH_MANIFEST_TOOL +# ---------------------- +# locate the manifest tool +m4_defun([_LT_PATH_MANIFEST_TOOL], +[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) +test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt +AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], + [lt_cv_path_mainfest_tool=no + echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD + $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out + cat conftest.err >&AS_MESSAGE_LOG_FD + if $GREP 'Manifest Tool' conftest.out > /dev/null; then + lt_cv_path_mainfest_tool=yes + fi + rm -f conftest*]) +if test "x$lt_cv_path_mainfest_tool" != xyes; then + MANIFEST_TOOL=: +fi +_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl +])# _LT_PATH_MANIFEST_TOOL + # LT_LIB_M # -------- @@ -3410,8 +3689,8 @@ esac lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= @@ -3435,6 +3714,7 @@ for ac_symprfx in "" "_"; do # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ +" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ @@ -3447,6 +3727,7 @@ for ac_symprfx in "" "_"; do else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi + lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no @@ -3480,6 +3761,18 @@ _LT_EOF if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) +/* DATA imports from DLLs on WIN32 con't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT@&t@_DLSYM_CONST +#elif defined(__osf__) +/* This system does not cope well with relocations in const data. */ +# define LT@&t@_DLSYM_CONST +#else +# define LT@&t@_DLSYM_CONST const +#endif + #ifdef __cplusplus extern "C" { #endif @@ -3491,7 +3784,7 @@ _LT_EOF cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ -const struct { +LT@&t@_DLSYM_CONST struct { const char *name; void *address; } @@ -3517,15 +3810,15 @@ static const void *lt_preloaded_setup() { _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext - lt_save_LIBS="$LIBS" - lt_save_CFLAGS="$CFLAGS" + lt_globsym_save_LIBS=$LIBS + lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then pipe_works=yes fi - LIBS="$lt_save_LIBS" - CFLAGS="$lt_save_CFLAGS" + LIBS=$lt_globsym_save_LIBS + CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD fi @@ -3558,6 +3851,13 @@ else AC_MSG_RESULT(ok) fi +# Response file support. +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + nm_file_list_spec='@' +elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then + nm_file_list_spec='@' +fi + _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], [Take the output of nm and produce a listing of raw symbols and C names]) _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], @@ -3568,6 +3868,8 @@ _LT_DECL([global_symbol_to_c_name_address], _LT_DECL([global_symbol_to_c_name_address_lib_prefix], [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], [Transform the output of nm in a C name address pair when lib prefix is needed]) +_LT_DECL([], [nm_file_list_spec], [1], + [Specify filename containing input files for $NM]) ]) # _LT_CMD_GLOBAL_SYMBOLS @@ -3579,7 +3881,6 @@ _LT_TAGVAR(lt_prog_compiler_wl, $1)= _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)= -AC_MSG_CHECKING([for $compiler option to produce PIC]) m4_if([$1], [CXX], [ # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then @@ -3684,6 +3985,12 @@ m4_if([$1], [CXX], [ ;; esac ;; + mingw* | cygwin* | os2* | pw32* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; dgux*) case $cc_basename in ec++*) @@ -3992,7 +4299,9 @@ m4_if([$1], [CXX], [ case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Xcompiler -fPIC' + if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" + fi ;; esac else @@ -4058,6 +4367,12 @@ m4_if([$1], [CXX], [ _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' ;; + nagfor*) + # NAG Fortran compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) @@ -4078,18 +4393,33 @@ m4_if([$1], [CXX], [ ;; *) case `$CC -V 2>&1 | sed 5q` in - *Sun\ F* | *Sun*Fortran*) + *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='' ;; + *Sun\ F* | *Sun*Fortran*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; + *Intel*\ [[CF]]*Compiler*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + *Portland\ Group*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; esac ;; esac @@ -4177,9 +4507,11 @@ case $host_os in _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" ;; esac -AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) -_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], - [How to pass a linker flag through the compiler]) + +AC_CACHE_CHECK([for $compiler option to produce PIC], + [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], + [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) +_LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) # # Check to make sure the PIC flag actually works. @@ -4198,6 +4530,8 @@ fi _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], [Additional compiler flags for building library objects]) +_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], + [How to pass a linker flag through the compiler]) # # Check to make sure the static flag actually works. # @@ -4218,6 +4552,7 @@ _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], m4_defun([_LT_LINKER_SHLIBS], [AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl +m4_require([_LT_PATH_MANIFEST_TOOL])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_DECL_SED])dnl @@ -4226,6 +4561,7 @@ m4_require([_LT_TAG_COMPILER])dnl AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) m4_if([$1], [CXX], [ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] case $host_os in aix[[4-9]]*) # If we're using GNU nm, then we don't want the "-C" option. @@ -4240,15 +4576,22 @@ m4_if([$1], [CXX], [ ;; pw32*) _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" - ;; + ;; cygwin* | mingw* | cegcc*) - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' - ;; + case $cc_basename in + cl*) + _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + ;; + *) + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] + ;; + esac + ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - ;; + ;; esac - _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] ], [ runpath_var= _LT_TAGVAR(allow_undefined_flag, $1)= @@ -4263,7 +4606,6 @@ m4_if([$1], [CXX], [ _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported @@ -4416,7 +4758,8 @@ _LT_EOF _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' @@ -4464,7 +4807,7 @@ _LT_EOF if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then - tmp_addflag= + tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler @@ -4513,8 +4856,7 @@ _LT_EOF xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ @@ -4534,8 +4876,8 @@ _LT_EOF _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; @@ -4553,8 +4895,8 @@ _LT_EOF _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi @@ -4600,8 +4942,8 @@ _LT_EOF *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi @@ -4731,7 +5073,7 @@ _LT_EOF _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an # empty executable. - _LT_SYS_MODULE_PATH_AIX + _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else @@ -4742,7 +5084,7 @@ _LT_EOF else # Determine the default libpath from the value encoded in an # empty executable. - _LT_SYS_MODULE_PATH_AIX + _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. @@ -4786,20 +5128,64 @@ _LT_EOF # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' - # FIXME: Should let the user specify the lib program. - _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' - _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + case $cc_basename in + cl*) + # Native MSVC + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='@' + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; + else + sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' + # The linker will not automatically build a static lib if we build a DLL. + # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' + # Don't use ranlib + _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' + _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile="$lt_outputfile.exe" + lt_tool_outputfile="$lt_tool_outputfile.exe" + ;; + esac~ + if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' + ;; + *) + # Assume MSVC wrapper + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + # FIXME: Should let the user specify the lib program. + _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + esac ;; darwin* | rhapsody*) @@ -4812,10 +5198,6 @@ _LT_EOF _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; - freebsd1*) - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little @@ -4828,7 +5210,7 @@ _LT_EOF ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) + freebsd2.*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes @@ -4837,7 +5219,7 @@ _LT_EOF # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no @@ -4845,7 +5227,7 @@ _LT_EOF hpux9*) if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi @@ -4861,13 +5243,12 @@ _LT_EOF hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes @@ -4885,10 +5266,10 @@ _LT_EOF _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else @@ -4935,16 +5316,31 @@ _LT_EOF irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" - AC_LINK_IFELSE(int foo(void) {}, - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' - ) - LDFLAGS="$save_LDFLAGS" + # This should be the same for all languages, so no per-tag cache variable. + AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], + [lt_cv_irix_exported_symbol], + [save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" + AC_LINK_IFELSE( + [AC_LANG_SOURCE( + [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], + [C++], [[int foo (void) { return 0; }]], + [Fortran 77], [[ + subroutine foo + end]], + [Fortran], [[ + subroutine foo + end]])])], + [lt_cv_irix_exported_symbol=yes], + [lt_cv_irix_exported_symbol=no]) + LDFLAGS="$save_LDFLAGS"]) + if test "$lt_cv_irix_exported_symbol" = yes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' + fi else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' @@ -5029,7 +5425,7 @@ _LT_EOF osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' @@ -5048,9 +5444,9 @@ _LT_EOF _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) @@ -5294,9 +5690,6 @@ _LT_TAGDECL([], [no_undefined_flag], [1], _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], [Flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]) -_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1], - [[If ld is used when linking, flag to hardcode $libdir into a binary - during linking. This must work even if $libdir does not exist]]) _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], @@ -5322,8 +5715,6 @@ _LT_TAGDECL([], [inherit_rpath], [0], to runtime path list]) _LT_TAGDECL([], [link_all_deplibs], [0], [Whether libtool must link a program against all its dependency libraries]) -_LT_TAGDECL([], [fix_srcfile_path], [1], - [Fix the shell variable $srcfile for the compiler]) _LT_TAGDECL([], [always_export_symbols], [0], [Set to "yes" if exported symbols are required]) _LT_TAGDECL([], [export_symbols_cmds], [2], @@ -5334,6 +5725,8 @@ _LT_TAGDECL([], [include_expsyms], [1], [Symbols that must always be exported]) _LT_TAGDECL([], [prelink_cmds], [2], [Commands necessary for linking programs (against libraries) with templates]) +_LT_TAGDECL([], [postlink_cmds], [2], + [Commands necessary for finishing linking programs]) _LT_TAGDECL([], [file_list_spec], [1], [Specify filename containing input files]) dnl FIXME: Not yet implemented @@ -5431,6 +5824,7 @@ CC="$lt_save_CC" m4_defun([_LT_LANG_CXX_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_PATH_MANIFEST_TOOL])dnl if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then @@ -5449,7 +5843,6 @@ _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported @@ -5492,6 +5885,7 @@ if test "$_lt_caught_CXX_error" != yes; then # Allow CC to be a program name with arguments. lt_save_CC=$CC + lt_save_CFLAGS=$CFLAGS lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX @@ -5509,6 +5903,7 @@ if test "$_lt_caught_CXX_error" != yes; then fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} + CFLAGS=$CXXFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) @@ -5530,8 +5925,8 @@ if test "$_lt_caught_CXX_error" != yes; then # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' @@ -5672,7 +6067,7 @@ if test "$_lt_caught_CXX_error" != yes; then _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an empty # executable. - _LT_SYS_MODULE_PATH_AIX + _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" @@ -5684,7 +6079,7 @@ if test "$_lt_caught_CXX_error" != yes; then else # Determine the default libpath from the value encoded in an # empty executable. - _LT_SYS_MODULE_PATH_AIX + _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. @@ -5726,29 +6121,75 @@ if test "$_lt_caught_CXX_error" != yes; then ;; cygwin* | mingw* | pw32* | cegcc*) - # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, - # as there is no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=no - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; + case $GXX,$cc_basename in + ,cl* | no,cl*) + # Native MSVC + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='@' + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; + else + $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' + # The linker will not automatically build a static lib if we build a DLL. + # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + # Don't use ranlib + _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' + _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile="$lt_outputfile.exe" + lt_tool_outputfile="$lt_tool_outputfile.exe" + ;; + esac~ + func_to_tool_file "$lt_outputfile"~ + if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' + ;; + *) + # g++ + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; @@ -5771,7 +6212,7 @@ if test "$_lt_caught_CXX_error" != yes; then esac ;; - freebsd[[12]]*) + freebsd2.*) # C++ shared libraries reported to be fairly broken before # switch to ELF _LT_TAGVAR(ld_shlibs, $1)=no @@ -5823,7 +6264,7 @@ if test "$_lt_caught_CXX_error" != yes; then ;; *) if test "$GXX" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no @@ -5894,10 +6335,10 @@ if test "$_lt_caught_CXX_error" != yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi @@ -5938,9 +6379,9 @@ if test "$_lt_caught_CXX_error" != yes; then *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' fi fi _LT_TAGVAR(link_all_deplibs, $1)=yes @@ -6218,7 +6659,7 @@ if test "$_lt_caught_CXX_error" != yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; esac @@ -6305,9 +6746,9 @@ if test "$_lt_caught_CXX_error" != yes; then if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when @@ -6436,6 +6877,7 @@ if test "$_lt_caught_CXX_error" != yes; then fi # test -n "$compiler" CC=$lt_save_CC + CFLAGS=$lt_save_CFLAGS LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC @@ -6450,6 +6892,29 @@ AC_LANG_POP ])# _LT_LANG_CXX_CONFIG +# _LT_FUNC_STRIPNAME_CNF +# ---------------------- +# func_stripname_cnf prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +# +# This function is identical to the (non-XSI) version of func_stripname, +# except this one can be used by m4 code that may be executed by configure, +# rather than the libtool script. +m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl +AC_REQUIRE([_LT_DECL_SED]) +AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) +func_stripname_cnf () +{ + case ${2} in + .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; + *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; + esac +} # func_stripname_cnf +])# _LT_FUNC_STRIPNAME_CNF + # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) # --------------------------------- # Figure out "hidden" library dependencies from verbose @@ -6458,6 +6923,7 @@ AC_LANG_POP # objects, libraries and library flags. m4_defun([_LT_SYS_HIDDEN_LIBDEPS], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl +AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl # Dependencies to place before and after the object being linked: _LT_TAGVAR(predep_objects, $1)= _LT_TAGVAR(postdep_objects, $1)= @@ -6507,7 +6973,20 @@ public class foo { } }; _LT_EOF +], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF +package foo +func foo() { +} +_LT_EOF ]) + +_lt_libdeps_save_CFLAGS=$CFLAGS +case "$CC $CFLAGS " in #( +*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; +*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; +*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; +esac + dnl Parse the compiler output and extract the necessary dnl objects, libraries and library flags. if AC_TRY_EVAL(ac_compile); then @@ -6519,7 +6998,7 @@ if AC_TRY_EVAL(ac_compile); then pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do - case $p in + case ${prev}${p} in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. @@ -6528,13 +7007,22 @@ if AC_TRY_EVAL(ac_compile); then test $p = "-R"; then prev=$p continue - else - prev= fi + # Expand the sysroot to ease extracting the directories later. + if test -z "$prev"; then + case $p in + -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; + -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; + -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; + esac + fi + case $p in + =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; + esac if test "$pre_test_object_deps_done" = no; then - case $p in - -L* | -R*) + case ${prev} in + -L | -R) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. @@ -6554,8 +7042,10 @@ if AC_TRY_EVAL(ac_compile); then _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" fi fi + prev= ;; + *.lto.$objext) ;; # Ignore GCC LTO objects *.$objext) # This assumes that the test object file only shows up # once in the compiler output. @@ -6591,6 +7081,7 @@ else fi $RM -f confest.$objext +CFLAGS=$_lt_libdeps_save_CFLAGS # PORTME: override above test on systems where it is broken m4_if([$1], [CXX], @@ -6690,7 +7181,6 @@ _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no @@ -6740,7 +7230,9 @@ if test "$_lt_disable_F77" != yes; then # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC + lt_save_CFLAGS=$CFLAGS CC=${F77-"f77"} + CFLAGS=$FFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) @@ -6794,6 +7286,7 @@ if test "$_lt_disable_F77" != yes; then GCC=$lt_save_GCC CC="$lt_save_CC" + CFLAGS="$lt_save_CFLAGS" fi # test "$_lt_disable_F77" != yes AC_LANG_POP @@ -6820,7 +7313,6 @@ _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no @@ -6870,7 +7362,9 @@ if test "$_lt_disable_FC" != yes; then # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC + lt_save_CFLAGS=$CFLAGS CC=${FC-"f95"} + CFLAGS=$FCFLAGS compiler=$CC GCC=$ac_cv_fc_compiler_gnu @@ -6926,7 +7420,8 @@ if test "$_lt_disable_FC" != yes; then fi # test -n "$compiler" GCC=$lt_save_GCC - CC="$lt_save_CC" + CC=$lt_save_CC + CFLAGS=$lt_save_CFLAGS fi # test "$_lt_disable_FC" != yes AC_LANG_POP @@ -6963,10 +7458,12 @@ _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. -lt_save_CC="$CC" +lt_save_CC=$CC +lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GCJ-"gcj"} +CFLAGS=$GCJFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" @@ -6993,10 +7490,78 @@ fi AC_LANG_RESTORE GCC=$lt_save_GCC -CC="$lt_save_CC" +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GCJ_CONFIG +# _LT_LANG_GO_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Go compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_GO_CONFIG], +[AC_REQUIRE([LT_PROG_GO])dnl +AC_LANG_SAVE + +# Source file extension for Go test sources. +ac_ext=go + +# Object file extension for compiled Go test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="package main; func main() { }" + +# Code to be used in simple link tests +lt_simple_link_test_code='package main; func main() { }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC=yes +CC=${GOC-"gccgo"} +CFLAGS=$GOFLAGS +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)="$LD" +_LT_CC_BASENAME([$compiler]) + +# Go did not exist at the time GCC didn't implicitly link libc in. +_LT_TAGVAR(archive_cmds_need_lc, $1)=no + +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds + +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) +fi + +AC_LANG_RESTORE + +GCC=$lt_save_GCC +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_GO_CONFIG + + # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler @@ -7028,9 +7593,11 @@ _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" +lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC= CC=${RC-"windres"} +CFLAGS= compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) @@ -7043,7 +7610,8 @@ fi GCC=$lt_save_GCC AC_LANG_RESTORE -CC="$lt_save_CC" +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_RC_CONFIG @@ -7063,6 +7631,13 @@ dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_GCJ], []) +# LT_PROG_GO +# ---------- +AC_DEFUN([LT_PROG_GO], +[AC_CHECK_TOOL(GOC, gccgo,) +]) + + # LT_PROG_RC # ---------- AC_DEFUN([LT_PROG_RC], @@ -7102,6 +7677,15 @@ _LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) AC_SUBST([OBJDUMP]) ]) +# _LT_DECL_DLLTOOL +# ---------------- +# Ensure DLLTOOL variable is set. +m4_defun([_LT_DECL_DLLTOOL], +[AC_CHECK_TOOL(DLLTOOL, dlltool, false) +test -z "$DLLTOOL" && DLLTOOL=dlltool +_LT_DECL([], [DLLTOOL], [1], [DLL creation program]) +AC_SUBST([DLLTOOL]) +]) # _LT_DECL_SED # ------------ @@ -7193,8 +7777,8 @@ m4_defun([_LT_CHECK_SHELL_FEATURES], # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" - test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ - = c,a/b,, \ + test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ + = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes @@ -7233,209 +7817,165 @@ _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl ])# _LT_CHECK_SHELL_FEATURES -# _LT_PROG_XSI_SHELLFNS -# --------------------- -# Bourne and XSI compatible variants of some useful shell functions. -m4_defun([_LT_PROG_XSI_SHELLFNS], -[case $xsi_shell in - yes) - cat << \_LT_EOF >> "$cfgfile" - -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac -} - -# func_basename file -func_basename () -{ - func_basename_result="${1##*/}" -} - -# func_dirname_and_basename file append nondir_replacement -# perform func_basename and func_dirname in a single function -# call: -# dirname: Compute the dirname of FILE. If nonempty, -# add APPEND to the result, otherwise set result -# to NONDIR_REPLACEMENT. -# value returned in "$func_dirname_result" -# basename: Compute filename of FILE. -# value retuned in "$func_basename_result" -# Implementation must be kept synchronized with func_dirname -# and func_basename. For efficiency, we do not delegate to -# those functions but instead duplicate the functionality here. -func_dirname_and_basename () -{ - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac - func_basename_result="${1##*/}" -} - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -func_stripname () -{ - # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are - # positional parameters, so assign one to ordinary parameter first. - func_stripname_result=${3} - func_stripname_result=${func_stripname_result#"${1}"} - func_stripname_result=${func_stripname_result%"${2}"} -} - -# func_opt_split -func_opt_split () -{ - func_opt_split_opt=${1%%=*} - func_opt_split_arg=${1#*=} -} - -# func_lo2o object -func_lo2o () -{ - case ${1} in - *.lo) func_lo2o_result=${1%.lo}.${objext} ;; - *) func_lo2o_result=${1} ;; - esac -} - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=${1%.*}.lo -} - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=$(( $[*] )) -} +# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY) +# ------------------------------------------------------ +# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and +# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY. +m4_defun([_LT_PROG_FUNCTION_REPLACE], +[dnl { +sed -e '/^$1 ()$/,/^} # $1 /c\ +$1 ()\ +{\ +m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1]) +} # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: +]) -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=${#1} -} -_LT_EOF - ;; - *) # Bourne compatible functions. - cat << \_LT_EOF >> "$cfgfile" +# _LT_PROG_REPLACE_SHELLFNS +# ------------------------- +# Replace existing portable implementations of several shell functions with +# equivalent extended shell implementations where those features are available.. +m4_defun([_LT_PROG_REPLACE_SHELLFNS], +[if test x"$xsi_shell" = xyes; then + _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac]) + + _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl + func_basename_result="${1##*/}"]) + + _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac + func_basename_result="${1##*/}"]) -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - # Extract subdirectory from the argument. - func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" - fi -} + _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl + # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are + # positional parameters, so assign one to ordinary parameter first. + func_stripname_result=${3} + func_stripname_result=${func_stripname_result#"${1}"} + func_stripname_result=${func_stripname_result%"${2}"}]) -# func_basename file -func_basename () -{ - func_basename_result=`$ECHO "${1}" | $SED "$basename"` -} + _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl + func_split_long_opt_name=${1%%=*} + func_split_long_opt_arg=${1#*=}]) -dnl func_dirname_and_basename -dnl A portable version of this function is already defined in general.m4sh -dnl so there is no need for it here. + _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl + func_split_short_opt_arg=${1#??} + func_split_short_opt_name=${1%"$func_split_short_opt_arg"}]) -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -# func_strip_suffix prefix name -func_stripname () -{ - case ${2} in - .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; - esac -} + _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl + case ${1} in + *.lo) func_lo2o_result=${1%.lo}.${objext} ;; + *) func_lo2o_result=${1} ;; + esac]) -# sed scripts: -my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q' -my_sed_long_arg='1s/^-[[^=]]*=//' + _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo]) -# func_opt_split -func_opt_split () -{ - func_opt_split_opt=`$ECHO "${1}" | $SED "$my_sed_long_opt"` - func_opt_split_arg=`$ECHO "${1}" | $SED "$my_sed_long_arg"` -} + _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))]) -# func_lo2o object -func_lo2o () -{ - func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` -} - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=`$ECHO "${1}" | $SED 's/\.[[^.]]*$/.lo/'` -} + _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}]) +fi -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=`expr "$[@]"` -} +if test x"$lt_shell_append" = xyes; then + _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"]) -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len` -} + _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl + func_quote_for_eval "${2}" +dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \ + eval "${1}+=\\\\ \\$func_quote_for_eval_result"]) -_LT_EOF -esac + # Save a `func_append' function call where possible by direct use of '+=' + sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") + test 0 -eq $? || _lt_function_replace_fail=: +else + # Save a `func_append' function call even when '+=' is not available + sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") + test 0 -eq $? || _lt_function_replace_fail=: +fi -case $lt_shell_append in - yes) - cat << \_LT_EOF >> "$cfgfile" +if test x"$_lt_function_replace_fail" = x":"; then + AC_MSG_WARN([Unable to substitute extended shell functions in $ofile]) +fi +]) -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "$[1]+=\$[2]" -} -_LT_EOF +# _LT_PATH_CONVERSION_FUNCTIONS +# ----------------------------- +# Determine which file name conversion functions should be used by +# func_to_host_file (and, implicitly, by func_to_host_path). These are needed +# for certain cross-compile configurations and native mingw. +m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_MSG_CHECKING([how to convert $build file names to $host format]) +AC_CACHE_VAL(lt_cv_to_host_file_cmd, +[case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 + ;; + esac ;; - *) - cat << \_LT_EOF >> "$cfgfile" - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "$[1]=\$$[1]\$[2]" -} - -_LT_EOF + *-*-cygwin* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin + ;; + esac ;; - esac + * ) # unhandled hosts (and "normal" native builds) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; +esac +]) +to_host_file_cmd=$lt_cv_to_host_file_cmd +AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) +_LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], + [0], [convert $build file names to $host format])dnl + +AC_MSG_CHECKING([how to convert $build file names to toolchain format]) +AC_CACHE_VAL(lt_cv_to_tool_file_cmd, +[#assume ordinary cross tools, or native build. +lt_cv_to_tool_file_cmd=func_convert_file_noop +case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 + ;; + esac + ;; +esac ]) +to_tool_file_cmd=$lt_cv_to_tool_file_cmd +AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) +_LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], + [0], [convert $build files to toolchain format])dnl +])# _LT_PATH_CONVERSION_FUNCTIONS # Helper functions for option handling. -*- Autoconf -*- # @@ -7762,9 +8302,24 @@ dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) # MODE is either `yes' or `no'. If omitted, it defaults to `both'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], - [AS_HELP_STRING([--with-pic], + [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], - [pic_mode="$withval"], + [lt_p=${PACKAGE-default} + case $withval in + yes|no) pic_mode=$withval ;; + *) + pic_mode=default + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for lt_pkg in $withval; do + IFS="$lt_save_ifs" + if test "X$lt_pkg" = "X$lt_p"; then + pic_mode=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], [pic_mode=default]) test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) @@ -7934,17 +8489,17 @@ m4_define([lt_dict_filter], # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. -# Generated from ltversion.in. +# @configure_input@ -# serial 3175 ltversion.m4 +# serial 3337 ltversion.m4 # This file is part of GNU Libtool -m4_define([LT_PACKAGE_VERSION], [2.2.10]) -m4_define([LT_PACKAGE_REVISION], [1.3175]) +m4_define([LT_PACKAGE_VERSION], [2.4.2]) +m4_define([LT_PACKAGE_REVISION], [1.3337]) AC_DEFUN([LTVERSION_VERSION], -[macro_version='2.2.10' -macro_revision='1.3175' +[macro_version='2.4.2' +macro_revision='1.3337' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) @@ -8048,6 +8603,56 @@ m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright (C) 1997-2013 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ([2.52])dnl + m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE])dnl +AC_SUBST([$1_FALSE])dnl +_AM_SUBST_NOTMAKE([$1_TRUE])dnl +_AM_SUBST_NOTMAKE([$1_FALSE])dnl +m4_define([_AM_COND_VALUE_$1], [$2])dnl +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([[conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]]) +fi])]) + +# Copyright (C) 2006-2013 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_SUBST_NOTMAKE(VARIABLE) +# --------------------------- +# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. +# This macro is traced by Automake. +AC_DEFUN([_AM_SUBST_NOTMAKE]) + +# AM_SUBST_NOTMAKE(VARIABLE) +# -------------------------- +# Public sister of _AM_SUBST_NOTMAKE. +AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) + m4_include([macros/ld-version-script.m4]) m4_include([macros/neon-test.m4]) m4_include([macros/neon-xml-parser.m4]) diff --git a/libs/neon/config.guess b/libs/neon/config.guess index dc84c68e..1804e9fc 100644 --- a/libs/neon/config.guess +++ b/libs/neon/config.guess @@ -1,14 +1,14 @@ #! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 -# Free Software Foundation, Inc. +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +# 2011, 2012, 2013 Free Software Foundation, Inc. -timestamp='2009-11-20' +timestamp='2012-12-29' # This file 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 +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but @@ -17,26 +17,22 @@ timestamp='2009-11-20' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - - -# Originally written by Per Bothner. Please send patches (context -# diff format) to and include a ChangeLog -# entry. +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). # -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. +# Originally written by Per Bothner. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +# +# Please send patches with a ChangeLog entry to config-patches@gnu.org. + me=`echo "$0" | sed -e 's,.*/,,'` @@ -56,8 +52,9 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, +2012, 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -144,7 +141,7 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward @@ -180,7 +177,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in fi ;; *) - os=netbsd + os=netbsd ;; esac # The OS release @@ -201,6 +198,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} @@ -223,7 +224,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on @@ -269,7 +270,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit ;; + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead @@ -295,12 +299,12 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in echo s390-ibm-zvmoe exit ;; *:OS400:*:*) - echo powerpc-ibm-os400 + echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; - arm:riscos:*:*|arm:RISCOS:*:*) + arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) @@ -394,23 +398,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; @@ -480,8 +484,8 @@ EOF echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ @@ -494,7 +498,7 @@ EOF else echo i586-dg-dgux${UNAME_RELEASE} fi - exit ;; + exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; @@ -551,7 +555,7 @@ EOF echo rs6000-ibm-aix3.2 fi exit ;; - *:AIX:*:[456]) + *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 @@ -594,52 +598,52 @@ EOF 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac + esac ;; + esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + sed 's/^ //' << EOF >$dummy.c - #define _HPUX_SOURCE - #include - #include + #define _HPUX_SOURCE + #include + #include - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa @@ -730,22 +734,22 @@ EOF exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd - exit ;; + exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi - exit ;; + exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd - exit ;; + exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd - exit ;; + exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd - exit ;; + exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; @@ -769,14 +773,14 @@ EOF exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} @@ -788,30 +792,35 @@ EOF echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) - case ${UNAME_MACHINE} in - pc98) - echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + UNAME_PROCESSOR=`/usr/bin/uname -p` + case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; + *:MINGW64*:*) + echo ${UNAME_MACHINE}-pc-mingw64 + exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; + i*:MSYS*:*) + echo ${UNAME_MACHINE}-pc-msys + exit ;; i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) - case ${UNAME_MACHINE} in + case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; @@ -857,6 +866,13 @@ EOF i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; + aarch64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; @@ -866,7 +882,7 @@ EOF EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; - esac + esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} @@ -878,20 +894,29 @@ EOF then echo ${UNAME_MACHINE}-unknown-linux-gnu else - echo ${UNAME_MACHINE}-unknown-linux-gnueabi + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo ${UNAME_MACHINE}-unknown-linux-gnueabi + else + echo ${UNAME_MACHINE}-unknown-linux-gnueabihf + fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) - echo cris-axis-linux-gnu + echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; crisv32:Linux:*:*) - echo crisv32-axis-linux-gnu + echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; frv:Linux:*:*) - echo frv-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + hexagon:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:Linux:*:*) LIBC=gnu @@ -933,7 +958,7 @@ EOF test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) - echo or32-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; padre:Linux:*:*) echo sparc-unknown-linux-gnu @@ -959,7 +984,7 @@ EOF echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu @@ -967,14 +992,17 @@ EOF sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; + tile*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. @@ -983,11 +1011,11 @@ EOF echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. + # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) @@ -1019,7 +1047,7 @@ EOF fi exit ;; i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. + # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; @@ -1047,13 +1075,13 @@ EOF exit ;; pc:*:*:*) # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i586. + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp - exit ;; + exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; @@ -1088,8 +1116,8 @@ EOF /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ @@ -1132,10 +1160,10 @@ EOF echo ns32k-sni-sysv fi exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm @@ -1161,11 +1189,11 @@ EOF exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + echo mips-nec-sysv${UNAME_RELEASE} else - echo mips-unknown-sysv${UNAME_RELEASE} + echo mips-unknown-sysv${UNAME_RELEASE} fi - exit ;; + exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; @@ -1178,6 +1206,9 @@ EOF BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; + x86_64:Haiku:*:*) + echo x86_64-unknown-haiku + exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; @@ -1230,7 +1261,10 @@ EOF *:QNX:*:4*) echo i386-pc-qnx exit ;; - NSE-?:NONSTOP_KERNEL:*:*) + NEO-?:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk${UNAME_RELEASE} + exit ;; + NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) @@ -1275,13 +1309,13 @@ EOF echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} + echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` + UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; @@ -1299,11 +1333,11 @@ EOF i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; + x86_64:VMkernel:*:*) + echo ${UNAME_MACHINE}-unknown-esx + exit ;; esac -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - eval $set_cc_for_build cat >$dummy.c < printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 - "4" + "4" #else - "" + "" #endif - ); exit (0); + ); exit (0); #endif #endif diff --git a/libs/neon/config.h.in b/libs/neon/config.h.in index 9c5efc17..c28a2680 100644 --- a/libs/neon/config.h.in +++ b/libs/neon/config.h.in @@ -66,18 +66,21 @@ /* Define if GnuTLS support is enabled */ #undef HAVE_GNUTLS +/* Define to 1 if you have the `gnutls_certificate_get_issuer' function. */ +#undef HAVE_GNUTLS_CERTIFICATE_GET_ISSUER + /* Define to 1 if you have the `gnutls_certificate_get_x509_cas' function. */ #undef HAVE_GNUTLS_CERTIFICATE_GET_X509_CAS -/* Define to 1 if you have the `gnutls_certificate_verify_peers2' function. */ -#undef HAVE_GNUTLS_CERTIFICATE_VERIFY_PEERS2 - /* Define to 1 if you have the `gnutls_session_get_data2' function. */ #undef HAVE_GNUTLS_SESSION_GET_DATA2 /* Define to 1 if you have the `gnutls_sign_callback_set' function. */ #undef HAVE_GNUTLS_SIGN_CALLBACK_SET +/* Define to 1 if you have the `gnutls_x509_crt_sign2' function. */ +#undef HAVE_GNUTLS_X509_CRT_SIGN2 + /* Define to 1 if you have the `gnutls_x509_dn_get_rdn_ava' function. */ #undef HAVE_GNUTLS_X509_DN_GET_RDN_AVA @@ -264,6 +267,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_UIO_H + /* Define if the timezone global is available */ #undef HAVE_TIMEZONE diff --git a/libs/neon/config.hw b/libs/neon/config.hw index dd8b30e9..77a03587 100644 --- a/libs/neon/config.hw +++ b/libs/neon/config.hw @@ -25,9 +25,9 @@ #ifdef WIN32 -#define NEON_VERSION "0.29.6" +#define NEON_VERSION "0.30.0" #define NE_VERSION_MAJOR (0) -#define NE_VERSION_MINOR (29) +#define NE_VERSION_MINOR (30) #define HAVE_ERRNO_H #define HAVE_LIMITS_H @@ -39,12 +39,15 @@ #define HAVE_SSPI +#define NE_HAVE_TS_SSL 1 + /* Define to enable debugging */ #define NE_DEBUGGING 1 #define NE_FMT_SIZE_T "u" #define NE_FMT_SSIZE_T "d" #define NE_FMT_OFF_T "ld" +#define NE_FMT_OFF64_T "I64d" #define NE_FMT_NE_OFF_T NE_FMT_OFF_T #ifndef NE_FMT_XML_SIZE @@ -69,9 +72,19 @@ #define strcasecmp strcmpi #define strncasecmp strnicmp #endif +#if defined(_MSC_VER) && _MSC_VER >= 1300 +#define HAVE_STRTOLL +#define strtoll _strtoi64 +#endif #define ssize_t int #define inline __inline +#if defined(NE_LFS) +#define lseek64 _lseeki64 +#define fstat64 _fstat64 +#define stat64 __stat64 +#else #define off_t _off_t +#endif #ifndef USE_GETADDRINFO #define in_addr_t unsigned int diff --git a/libs/neon/config.hw.in b/libs/neon/config.hw.in index c2d7204a..5bee7595 100644 --- a/libs/neon/config.hw.in +++ b/libs/neon/config.hw.in @@ -39,12 +39,15 @@ #define HAVE_SSPI +#define NE_HAVE_TS_SSL 1 + /* Define to enable debugging */ #define NE_DEBUGGING 1 #define NE_FMT_SIZE_T "u" #define NE_FMT_SSIZE_T "d" #define NE_FMT_OFF_T "ld" +#define NE_FMT_OFF64_T "I64d" #define NE_FMT_NE_OFF_T NE_FMT_OFF_T #ifndef NE_FMT_XML_SIZE @@ -69,9 +72,19 @@ #define strcasecmp strcmpi #define strncasecmp strnicmp #endif +#if defined(_MSC_VER) && _MSC_VER >= 1300 +#define HAVE_STRTOLL +#define strtoll _strtoi64 +#endif #define ssize_t int #define inline __inline +#if defined(NE_LFS) +#define lseek64 _lseeki64 +#define fstat64 _fstat64 +#define stat64 __stat64 +#else #define off_t _off_t +#endif #ifndef USE_GETADDRINFO #define in_addr_t unsigned int diff --git a/libs/neon/config.sub b/libs/neon/config.sub index 2a55a507..52f04bcd 100644 --- a/libs/neon/config.sub +++ b/libs/neon/config.sub @@ -1,38 +1,33 @@ #! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 -# Free Software Foundation, Inc. +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +# 2011, 2012, 2013 Free Software Foundation, Inc. -timestamp='2009-11-20' +timestamp='2012-12-29' -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# This file 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 +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). -# Please send patches to . Submit a context -# diff and a properly formatted GNU ChangeLog entry. +# Please send patches with a ChangeLog entry to config-patches@gnu.org. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. @@ -75,8 +70,9 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, +2012, 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -123,13 +119,18 @@ esac # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ - uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ + linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; + android-linux) + os=-linux-android + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] @@ -152,12 +153,12 @@ case $os in -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze) + -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; - -bluegene*) - os=-cnk + -bluegene*) + os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= @@ -173,10 +174,10 @@ case $os in os=-chorusos basic_machine=$1 ;; - -chorusrdb) - os=-chorusrdb + -chorusrdb) + os=-chorusrdb basic_machine=$1 - ;; + ;; -hiux*) os=-hiuxwe2 ;; @@ -221,6 +222,12 @@ case $os in -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; + -lynx*178) + os=-lynxos178 + ;; + -lynx*5) + os=-lynxos5 + ;; -lynx*) os=-lynxos ;; @@ -245,20 +252,27 @@ case $basic_machine in # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ + | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ + | arc \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ + | avr | avr32 \ + | be32 | be64 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ + | epiphany \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ + | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | mcore | mep | metag \ + | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ @@ -281,29 +295,39 @@ case $basic_machine in | moxie \ | mt \ | msp430 \ + | nds32 | nds32le | nds32be \ | nios | nios2 \ | ns16k | ns32k \ + | open8 \ | or32 \ | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ - | rx \ + | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu | strongarm \ - | tahoe | thumb | tic4x | tic80 | tron \ + | spu \ + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ - | v850 | v850e \ + | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | we32k \ - | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ + | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; - m6811 | m68hc11 | m6812 | m68hc12 | picochip) - # Motorola 68HC11/12. + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) basic_machine=$basic_machine-unknown os=-none ;; @@ -313,6 +337,21 @@ case $basic_machine in basic_machine=mt-unknown ;; + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + xgate) + basic_machine=$basic_machine-unknown + os=-none + ;; + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown + ;; + # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. @@ -327,25 +366,30 @@ case $basic_machine in # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ + | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ + | be32-* | be64-* \ | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ + | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ @@ -367,25 +411,29 @@ case $basic_machine in | mmix-* \ | mt-* \ | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ - | romp-* | rs6000-* | rx-* \ + | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ - | tahoe-* | thumb-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ + | tahoe-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile*-* \ | tron-* \ | ubicom32-* \ - | v850-* | v850e-* | vax-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | vax-* \ | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) @@ -410,7 +458,7 @@ case $basic_machine in basic_machine=a29k-amd os=-udi ;; - abacus) + abacus) basic_machine=abacus-unknown ;; adobe68k) @@ -480,11 +528,20 @@ case $basic_machine in basic_machine=powerpc-ibm os=-cnk ;; + c54x-*) + basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; c90) basic_machine=c90-cray os=-unicos ;; - cegcc) + cegcc) basic_machine=arm-unknown os=-cegcc ;; @@ -516,7 +573,7 @@ case $basic_machine in basic_machine=craynv-cray os=-unicosmp ;; - cr16) + cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; @@ -674,7 +731,6 @@ case $basic_machine in i370-ibm* | ibm*) basic_machine=i370-ibm ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 @@ -732,9 +788,13 @@ case $basic_machine in basic_machine=ns32k-utek os=-sysv ;; - microblaze) + microblaze*) basic_machine=microblaze-xilinx ;; + mingw64) + basic_machine=x86_64-pc + os=-mingw64 + ;; mingw32) basic_machine=i386-pc os=-mingw32 @@ -771,10 +831,18 @@ case $basic_machine in ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; + msys) + basic_machine=i386-pc + os=-msys + ;; mvs) basic_machine=i370-ibm os=-mvs ;; + nacl) + basic_machine=le32-unknown + os=-nacl + ;; ncr3000) basic_machine=i486-ncr os=-sysv4 @@ -839,6 +907,12 @@ case $basic_machine in np1) basic_machine=np1-gould ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; nsr-tandem) basic_machine=nsr-tandem ;; @@ -921,9 +995,10 @@ case $basic_machine in ;; power) basic_machine=power-ibm ;; - ppc) basic_machine=powerpc-unknown + ppc | ppcbe) basic_machine=powerpc-unknown ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown @@ -933,7 +1008,7 @@ case $basic_machine in ;; ppc64) basic_machine=powerpc64-unknown ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ppc64-* | ppc64p7-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown @@ -948,7 +1023,11 @@ case $basic_machine in basic_machine=i586-unknown os=-pw32 ;; - rdos) + rdos | rdos64) + basic_machine=x86_64-pc + os=-rdos + ;; + rdos32) basic_machine=i386-pc os=-rdos ;; @@ -1017,6 +1096,9 @@ case $basic_machine in basic_machine=i860-stratus os=-sysv4 ;; + strongarm-* | thumb-*) + basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; sun2) basic_machine=m68000-sun ;; @@ -1073,20 +1155,8 @@ case $basic_machine in basic_machine=t90-cray os=-unicos ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tic55x | c55x*) - basic_machine=tic55x-unknown - os=-coff - ;; - tic6x | c6x*) - basic_machine=tic6x-unknown - os=-coff - ;; tile*) - basic_machine=tile-unknown + basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) @@ -1156,6 +1226,9 @@ case $basic_machine in xps | xps100) basic_machine=xps100-honeywell ;; + xscale-* | xscalee[bl]-*) + basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + ;; ymp) basic_machine=ymp-cray os=-unicos @@ -1253,11 +1326,11 @@ esac if [ x"$os" != x"" ] then case $os in - # First match some system type aliases - # that might get confused with valid system types. + # First match some system type aliases + # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux + -auroraux) + os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` @@ -1287,14 +1360,15 @@ case $os in | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -openbsd* | -solidbsd* \ + | -bitrig* | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ @@ -1341,7 +1415,7 @@ case $os in -opened*) os=-openedition ;; - -os400*) + -os400*) os=-os400 ;; -wince*) @@ -1390,7 +1464,7 @@ case $os in -sinix*) os=-sysv4 ;; - -tpf*) + -tpf*) os=-tpf ;; -triton*) @@ -1435,6 +1509,8 @@ case $os in -dicos*) os=-dicos ;; + -nacl*) + ;; -none) ;; *) @@ -1457,10 +1533,10 @@ else # system, and we'll never get to this point. case $basic_machine in - score-*) + score-*) os=-elf ;; - spu-*) + spu-*) os=-elf ;; *-acorn) @@ -1472,8 +1548,20 @@ case $basic_machine in arm*-semi) os=-aout ;; - c4x-* | tic4x-*) - os=-coff + c4x-* | tic4x-*) + os=-coff + ;; + hexagon-*) + os=-elf + ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff ;; # This must come before the *-dec entry. pdp10-*) @@ -1493,14 +1581,11 @@ case $basic_machine in ;; m68000-sun) os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 ;; m68*-cisco) os=-aout ;; - mep-*) + mep-*) os=-elf ;; mips*-cisco) @@ -1527,7 +1612,7 @@ case $basic_machine in *-ibm) os=-aix ;; - *-knuth) + *-knuth) os=-mmixware ;; *-wec) diff --git a/libs/neon/configure b/libs/neon/configure index 00626652..b0a79084 100644 --- a/libs/neon/configure +++ b/libs/neon/configure @@ -1,13 +1,11 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.66 for neon 0.29.6. +# Generated by GNU Autoconf 2.69 for neon 0.30.0. # # Report bugs to . # # -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software -# Foundation, Inc. +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -96,6 +94,7 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. +as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -140,6 +139,31 @@ export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh @@ -173,7 +197,8 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi -test x\$exitcode = x0 || exit 1" +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && @@ -226,14 +251,25 @@ IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : - # We cannot yet assume a decent shell, so we have to provide a - # neutralization value for shells without unset; and this also - # works around shells that cannot unset nonexistent variables. - BASH_ENV=/dev/null - ENV=/dev/null - (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 fi if test x$as_have_required = xno; then : @@ -336,6 +372,14 @@ $as_echo X"$as_dir" | } # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take @@ -457,6 +501,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). @@ -491,16 +539,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -512,28 +560,8 @@ else as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -567,8 +595,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='neon' PACKAGE_TARNAME='neon' -PACKAGE_VERSION='0.29.6' -PACKAGE_STRING='neon 0.29.6' +PACKAGE_VERSION='0.30.0' +PACKAGE_STRING='neon 0.30.0' PACKAGE_BUGREPORT='neon@lists.manyfish.co.uk' PACKAGE_URL='' @@ -618,6 +646,8 @@ top_builddir NEON_BUILD_BUNDLED NEON_VERSION ALL_LINGUAS +HAVE_LD_VERSION_SCRIPT_FALSE +HAVE_LD_VERSION_SCRIPT_TRUE NEON_PC_LIBS TEST_LDFLAGS PK12UTIL @@ -636,10 +666,13 @@ OTOOL LIPO NMEDIT DSYMUTIL +MANIFEST_TOOL AWK RANLIB STRIP +ac_ct_AR AR +DLLTOOL OBJDUMP LN_S NM @@ -741,6 +774,7 @@ enable_static with_pic enable_fast_install with_gnu_ld +with_sysroot enable_libtool_lock with_libxml2 with_expat @@ -822,8 +856,9 @@ do fi case $ac_option in - *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *) ac_optarg=yes ;; + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. @@ -1163,7 +1198,7 @@ Try \`$0 --help' for more information" $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac @@ -1214,8 +1249,6 @@ target=$target_alias if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1301,7 +1334,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures neon 0.29.6 to adapt to many kinds of systems. +\`configure' configures neon 0.30.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1366,7 +1399,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of neon 0.29.6:";; + short | recursive ) echo "Configuration of neon 0.30.0:";; esac cat <<\_ACEOF @@ -1405,9 +1438,11 @@ Optional Packages: --with-ca-bundle specify filename of an SSL CA root bundle --without-gssapi disable GSSAPI support --without-libproxy disable libproxy support - --with-pic try to use only PIC/non-PIC objects [default=use + --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] + --with-sysroot=DIR Search for dependent libraries within DIR + (or the compiler's sysroot if not specified). --with-libxml2 force use of libxml 2.x --with-expat force use of expat @@ -1487,10 +1522,10 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -neon configure 0.29.6 -generated by GNU Autoconf 2.66 +neon configure 0.30.0 +generated by GNU Autoconf 2.69 -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. @@ -1539,7 +1574,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile @@ -1565,7 +1600,7 @@ $as_echo "$ac_try_echo"; } >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } >/dev/null && { + test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : @@ -1576,7 +1611,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp @@ -1589,10 +1624,10 @@ fi ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if eval "test \"\${$3+set}\"" = set; then : + if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 @@ -1628,7 +1663,7 @@ if ac_fn_c_try_cpp "$LINENO"; then : else ac_header_preproc=no fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } @@ -1659,7 +1694,7 @@ $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" @@ -1668,7 +1703,7 @@ eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel @@ -1709,7 +1744,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run @@ -1723,7 +1758,7 @@ ac_fn_c_check_header_compile () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -1741,7 +1776,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile @@ -1754,7 +1789,7 @@ ac_fn_c_check_type () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" @@ -1795,7 +1830,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type @@ -1816,7 +1851,8 @@ int main () { static int test_array [1 - 2 * !(($2) >= 0)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -1832,7 +1868,8 @@ int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -1858,7 +1895,8 @@ int main () { static int test_array [1 - 2 * !(($2) < 0)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -1874,7 +1912,8 @@ int main () { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -1908,7 +1947,8 @@ int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -1972,7 +2012,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ rm -f conftest.val fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_compute_int @@ -1988,7 +2028,7 @@ ac_fn_c_check_decl () as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 $as_echo_n "checking whether $as_decl_name is declared... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2019,7 +2059,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_decl @@ -2050,7 +2090,7 @@ $as_echo "$ac_try_echo"; } >&5 test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext + test -x conftest$ac_exeext }; then : ac_retval=0 else @@ -2064,7 +2104,7 @@ fi # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link @@ -2077,7 +2117,7 @@ ac_fn_c_check_func () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2132,7 +2172,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func @@ -2145,7 +2185,7 @@ ac_fn_c_check_member () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 $as_echo_n "checking for $2.$3... " >&6; } -if eval "test \"\${$4+set}\"" = set; then : +if eval \${$4+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2189,15 +2229,15 @@ fi eval ac_res=\$$4 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_member cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by neon $as_me 0.29.6, which was -generated by GNU Autoconf 2.66. Invocation command line was +It was created by neon $as_me 0.30.0, which was +generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2636,7 +2676,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then : +if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -2656,7 +2696,7 @@ case $as_dir/ in #(( # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. @@ -2741,12 +2781,12 @@ NEON_BUILD_BUNDLED=yes # Define the current versions. NE_VERSION_MAJOR=0 -NE_VERSION_MINOR=29 -NE_VERSION_PATCH=6 +NE_VERSION_MINOR=30 +NE_VERSION_PATCH=0 NE_VERSION_TAG= -# 0.29.x is backwards-compatible to 0.27.x, so AGE=2 -NE_LIBTOOL_VERSINFO="29:${NE_VERSION_PATCH}:2" +# 0.30.x is backwards-compatible to 0.27.x, so AGE=3 +NE_LIBTOOL_VERSINFO="30:${NE_VERSION_PATCH}:3" @@ -2786,7 +2826,7 @@ if test -n "$ac_tool_prefix"; then set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2798,7 +2838,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2826,7 +2866,7 @@ if test -z "$ac_cv_prog_CC"; then set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : +if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -2838,7 +2878,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2879,7 +2919,7 @@ if test -z "$CC"; then set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2891,7 +2931,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2919,7 +2959,7 @@ if test -z "$CC"; then set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2932,7 +2972,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -2978,7 +3018,7 @@ if test -z "$CC"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2990,7 +3030,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3022,7 +3062,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : +if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -3034,7 +3074,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3305,7 +3345,7 @@ rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } -if test "${ac_cv_objext+set}" = set; then : +if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -3356,7 +3396,7 @@ OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then : +if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -3393,7 +3433,7 @@ ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then : +if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag @@ -3471,7 +3511,7 @@ else fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then : +if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no @@ -3480,8 +3520,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include -#include -#include +struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -3579,7 +3618,7 @@ if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then : + if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded @@ -3609,7 +3648,7 @@ else # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. @@ -3625,11 +3664,11 @@ else ac_preproc_ok=: break fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext +rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi @@ -3668,7 +3707,7 @@ else # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. @@ -3684,11 +3723,11 @@ else ac_preproc_ok=: break fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext +rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else @@ -3707,7 +3746,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if test "${ac_cv_path_GREP+set}" = set; then : +if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then @@ -3721,7 +3760,7 @@ do for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue + as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in @@ -3770,7 +3809,7 @@ $as_echo "$ac_cv_path_GREP" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then : +if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 @@ -3787,7 +3826,7 @@ do for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue + as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in @@ -3837,7 +3876,7 @@ $as_echo "$ac_cv_path_EGREP" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then : +if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -3966,7 +4005,7 @@ done ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" -if test "x$ac_cv_header_minix_config_h" = x""yes; then : +if test "x$ac_cv_header_minix_config_h" = xyes; then : MINIX=yes else MINIX= @@ -3988,14 +4027,14 @@ $as_echo "#define _MINIX 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 $as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } -if test "${ac_cv_safe_to_define___extensions__+set}" = set; then : +if ${ac_cv_safe_to_define___extensions__+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -# define __EXTENSIONS__ 1 - $ac_includes_default +# define __EXTENSIONS__ 1 + $ac_includes_default int main () { @@ -4027,7 +4066,7 @@ $as_echo "$ac_cv_safe_to_define___extensions__" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } -if test "${ac_cv_c_inline+set}" = set; then : +if ${ac_cv_c_inline+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_inline=no @@ -4069,7 +4108,7 @@ esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } -if test "${ac_cv_c_const+set}" = set; then : +if ${ac_cv_c_const+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -4078,11 +4117,11 @@ else int main () { -/* FIXME: Include the comments suggested by Paul. */ + #ifndef __cplusplus - /* Ultrix mips cc rejects this. */ + /* Ultrix mips cc rejects this sort of thing. */ typedef int charset[2]; - const charset cs; + const charset cs = { 0, 0 }; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; @@ -4099,8 +4138,9 @@ main () ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; - { /* SCO 3.2v4 cc rejects this. */ - char *t; + { /* SCO 3.2v4 cc rejects this sort of thing. */ + char tx; + char *t = &tx; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; @@ -4116,10 +4156,10 @@ main () iptr p = 0; ++p; } - { /* AIX XL C 1.02.0.0 rejects this saying + { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; }; - struct s *b; b->j = 5; + struct s { int j; const int *ap[3]; } bx; + struct s *b = &bx; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; @@ -4148,7 +4188,7 @@ $as_echo "#define const /**/" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" -if test "x$ac_cv_type_size_t" = x""yes; then : +if test "x$ac_cv_type_size_t" = xyes; then : else @@ -4159,7 +4199,7 @@ _ACEOF fi ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default" -if test "x$ac_cv_type_off_t" = x""yes; then : +if test "x$ac_cv_type_off_t" = xyes; then : else @@ -4173,7 +4213,7 @@ fi # Check for Darwin, which needs extra cpp and linker flags. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uname" >&5 $as_echo_n "checking for uname... " >&6; } -if test "${ne_cv_os_uname+set}" = set; then : +if ${ne_cv_os_uname+:} false; then : $as_echo_n "(cached) " >&6 else @@ -4196,7 +4236,7 @@ fi $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\"" = set; then : +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF @@ -4230,7 +4270,7 @@ fi # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5 $as_echo_n "checking size of int... " >&6; } -if test "${ac_cv_sizeof_int+set}" = set; then : +if ${ac_cv_sizeof_int+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default"; then : @@ -4263,7 +4303,7 @@ _ACEOF # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5 $as_echo_n "checking size of long... " >&6; } -if test "${ac_cv_sizeof_long+set}" = set; then : +if ${ac_cv_sizeof_long+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long" "$ac_includes_default"; then : @@ -4296,7 +4336,7 @@ _ACEOF # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long" >&5 $as_echo_n "checking size of long long... " >&6; } -if test "${ac_cv_sizeof_long_long+set}" = set; then : +if ${ac_cv_sizeof_long_long+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long" "$ac_includes_default"; then : @@ -4326,7 +4366,7 @@ _ACEOF if test "$GCC" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc -Wformat -Werror sanity" >&5 $as_echo_n "checking for gcc -Wformat -Werror sanity... " >&6; } -if test "${ne_cv_cc_werror+set}" = set; then : +if ${ne_cv_cc_werror+:} false; then : $as_echo_n "(cached) " >&6 else @@ -4378,7 +4418,7 @@ fi -for ac_header in errno.h stdarg.h string.h stdlib.h +for ac_header in errno.h stdarg.h string.h stdlib.h sys/uio.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -4402,7 +4442,7 @@ done # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of size_t" >&5 $as_echo_n "checking size of size_t... " >&6; } -if test "${ac_cv_sizeof_size_t+set}" = set; then : +if ${ac_cv_sizeof_size_t+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (size_t))" "ac_cv_sizeof_size_t" "$ac_includes_default @@ -4438,7 +4478,7 @@ _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print size_t" >&5 $as_echo_n "checking how to print size_t... " >&6; } -if test "${ne_cv_fmt_size_t+set}" = set; then : +if ${ne_cv_fmt_size_t+:} false; then : $as_echo_n "(cached) " >&6 else @@ -4500,7 +4540,7 @@ _ACEOF # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of off_t" >&5 $as_echo_n "checking size of off_t... " >&6; } -if test "${ac_cv_sizeof_off_t+set}" = set; then : +if ${ac_cv_sizeof_off_t+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (off_t))" "ac_cv_sizeof_off_t" "$ac_includes_default @@ -4536,7 +4576,7 @@ _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print off_t" >&5 $as_echo_n "checking how to print off_t... " >&6; } -if test "${ne_cv_fmt_off_t+set}" = set; then : +if ${ne_cv_fmt_off_t+:} false; then : $as_echo_n "(cached) " >&6 else @@ -4599,7 +4639,7 @@ _ACEOF # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of ssize_t" >&5 $as_echo_n "checking size of ssize_t... " >&6; } -if test "${ac_cv_sizeof_ssize_t+set}" = set; then : +if ${ac_cv_sizeof_ssize_t+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (ssize_t))" "ac_cv_sizeof_ssize_t" "$ac_includes_default @@ -4635,7 +4675,7 @@ _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print ssize_t" >&5 $as_echo_n "checking how to print ssize_t... " >&6; } -if test "${ne_cv_fmt_ssize_t+set}" = set; then : +if ${ne_cv_fmt_ssize_t+:} false; then : $as_echo_n "(cached) " >&6 else @@ -4692,7 +4732,7 @@ _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } -if test "${ac_cv_c_bigendian+set}" = set; then : +if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown @@ -4915,7 +4955,7 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h esac ac_fn_c_check_decl "$LINENO" "strerror_r" "ac_cv_have_decl_strerror_r" "$ac_includes_default" -if test "x$ac_cv_have_decl_strerror_r" = x""yes; then : +if test "x$ac_cv_have_decl_strerror_r" = xyes; then : ac_have_decl=1 else ac_have_decl=0 @@ -4928,7 +4968,7 @@ _ACEOF for ac_func in strerror_r do : ac_fn_c_check_func "$LINENO" "strerror_r" "ac_cv_func_strerror_r" -if test "x$ac_cv_func_strerror_r" = x""yes; then : +if test "x$ac_cv_func_strerror_r" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRERROR_R 1 _ACEOF @@ -4938,7 +4978,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strerror_r returns char *" >&5 $as_echo_n "checking whether strerror_r returns char *... " >&6; } -if test "${ac_cv_func_strerror_r_char_p+set}" = set; then : +if ${ac_cv_func_strerror_r_char_p+:} false; then : $as_echo_n "(cached) " >&6 else @@ -5022,7 +5062,7 @@ else LIBS="$LIBS -lm" # Always need -lm { $as_echo "$as_me:${as_lineno-$LINENO}: checking for trio_vsnprintf in -ltrio" >&5 $as_echo_n "checking for trio_vsnprintf in -ltrio... " >&6; } -if test "${ac_cv_lib_trio_trio_vsnprintf+set}" = set; then : +if ${ac_cv_lib_trio_trio_vsnprintf+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -5056,11 +5096,11 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_trio_trio_vsnprintf" >&5 $as_echo "$ac_cv_lib_trio_trio_vsnprintf" >&6; } -if test "x$ac_cv_lib_trio_trio_vsnprintf" = x""yes; then : +if test "x$ac_cv_lib_trio_trio_vsnprintf" = xyes; then : for ac_header in trio.h do : ac_fn_c_check_header_mongrel "$LINENO" "trio.h" "ac_cv_header_trio_h" "$ac_includes_default" -if test "x$ac_cv_header_trio_h" = x""yes; then : +if test "x$ac_cv_header_trio_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_TRIO_H 1 _ACEOF @@ -5121,7 +5161,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for timezone global" >&5 $as_echo_n "checking for timezone global... " >&6; } -if test "${ne_cv_cc_timezone+set}" = set; then : +if ${ne_cv_cc_timezone+:} false; then : $as_echo_n "(cached) " >&6 else @@ -5205,7 +5245,7 @@ else ne_save_CPPFLAGS=$CPPFLAGS CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE" ac_fn_c_check_type "$LINENO" "off64_t" "ac_cv_type_off64_t" "$ac_includes_default" -if test "x$ac_cv_type_off64_t" = x""yes; then : +if test "x$ac_cv_type_off64_t" = xyes; then : @@ -5217,7 +5257,7 @@ if test "x$ac_cv_type_off64_t" = x""yes; then : # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of off64_t" >&5 $as_echo_n "checking size of off64_t... " >&6; } -if test "${ac_cv_sizeof_off64_t+set}" = set; then : +if ${ac_cv_sizeof_off64_t+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (off64_t))" "ac_cv_sizeof_off64_t" "$ac_includes_default @@ -5253,7 +5293,7 @@ _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print off64_t" >&5 $as_echo_n "checking how to print off64_t... " >&6; } -if test "${ne_cv_fmt_off64_t+set}" = set; then : +if ${ne_cv_fmt_off64_t+:} false; then : $as_echo_n "(cached) " >&6 else @@ -5373,6 +5413,13 @@ cat >>confdefs.h <<_ACEOF #define NE_FMT_NE_OFF_T NE_FMT_OFF64_T _ACEOF + +if test "x${NE_LIBTOOL_RELEASE}y" = "xy"; then + NE_LIBTOOL_RELEASE="LFS" +else + NE_LIBTOOL_RELEASE="${NE_LIBTOOL_RELEASE}-LFS" +fi + else cat >>confdefs.h <<_ACEOF #define NE_FMT_NE_OFF_T NE_FMT_OFF_T @@ -5382,7 +5429,7 @@ fi ac_fn_c_check_func "$LINENO" "strcasecmp" "ac_cv_func_strcasecmp" -if test "x$ac_cv_func_strcasecmp" = x""yes; then : +if test "x$ac_cv_func_strcasecmp" = xyes; then : $as_echo "#define HAVE_STRCASECMP 1" >>confdefs.h else @@ -5417,7 +5464,7 @@ fi if test "$ac_cv_func_stpcpy" = "yes"; then ac_fn_c_check_decl "$LINENO" "stpcpy" "ac_cv_have_decl_stpcpy" "$ac_includes_default" -if test "x$ac_cv_have_decl_stpcpy" = x""yes; then : +if test "x$ac_cv_have_decl_stpcpy" = xyes; then : ac_have_decl=1 else ac_have_decl=0 @@ -5441,7 +5488,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing socket" >&5 $as_echo_n "checking for library containing socket... " >&6; } -if test "${ne_cv_libsfor_socket+set}" = set; then : +if ${ne_cv_libsfor_socket+:} false; then : $as_echo_n "(cached) " >&6 else @@ -5513,7 +5560,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing getaddrinfo" >&5 $as_echo_n "checking for library containing getaddrinfo... " >&6; } -if test "${ne_cv_libsfor_getaddrinfo+set}" = set; then : +if ${ne_cv_libsfor_getaddrinfo+:} false; then : $as_echo_n "(cached) " >&6 else @@ -5647,7 +5694,7 @@ $as_echo "#define USE_GETADDRINFO 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working AI_ADDRCONFIG" >&5 $as_echo_n "checking for working AI_ADDRCONFIG... " >&6; } -if test "${ne_cv_gai_addrconfig+set}" = set; then : +if ${ne_cv_gai_addrconfig+:} false; then : $as_echo_n "(cached) " >&6 else @@ -5696,7 +5743,7 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5 $as_echo_n "checking for library containing gethostbyname... " >&6; } -if test "${ne_cv_libsfor_gethostbyname+set}" = set; then : +if ${ne_cv_libsfor_gethostbyname+:} false; then : $as_echo_n "(cached) " >&6 else @@ -5765,7 +5812,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing hstrerror" >&5 $as_echo_n "checking for library containing hstrerror... " >&6; } -if test "${ne_cv_libsfor_hstrerror+set}" = set; then : +if ${ne_cv_libsfor_hstrerror+:} false; then : $as_echo_n "(cached) " >&6 else @@ -5834,7 +5881,7 @@ LIBS="$LIBS $NEON_LIBS" for ac_func in hstrerror do : ac_fn_c_check_func "$LINENO" "hstrerror" "ac_cv_func_hstrerror" -if test "x$ac_cv_func_hstrerror" = x""yes; then : +if test "x$ac_cv_func_hstrerror" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_HSTRERROR 1 _ACEOF @@ -5846,7 +5893,7 @@ LIBS=$ne_cf_save_LIBS # Older Unixes don't declare h_errno. ac_fn_c_check_decl "$LINENO" "h_errno" "ac_cv_have_decl_h_errno" "#include " -if test "x$ac_cv_have_decl_h_errno" = x""yes; then : +if test "x$ac_cv_have_decl_h_errno" = xyes; then : ac_have_decl=1 else ac_have_decl=0 @@ -5865,7 +5912,7 @@ _ACEOF #endif " -if test "x$ac_cv_type_in_addr_t" = x""yes; then : +if test "x$ac_cv_type_in_addr_t" = xyes; then : else @@ -5885,7 +5932,7 @@ ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" " #endif " -if test "x$ac_cv_type_socklen_t" = x""yes; then : +if test "x$ac_cv_type_socklen_t" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SOCKLEN_T 1 @@ -5902,7 +5949,7 @@ fi ac_fn_c_check_member "$LINENO" "struct tm" "tm_gmtoff" "ac_cv_member_struct_tm_tm_gmtoff" "#include " -if test "x$ac_cv_member_struct_tm_tm_gmtoff" = x""yes; then : +if test "x$ac_cv_member_struct_tm_tm_gmtoff" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_TM_TM_GMTOFF 1 @@ -5912,7 +5959,7 @@ _ACEOF fi ac_fn_c_check_member "$LINENO" "struct tm" "__tm_gmtoff" "ac_cv_member_struct_tm___tm_gmtoff" "#include " -if test "x$ac_cv_member_struct_tm___tm_gmtoff" = x""yes; then : +if test "x$ac_cv_member_struct_tm___tm_gmtoff" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_TM___TM_GMTOFF 1 @@ -5940,11 +5987,11 @@ fi if test "$ne_use_zlib" = "yes"; then ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" -if test "x$ac_cv_header_zlib_h" = x""yes; then : +if test "x$ac_cv_header_zlib_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inflate in -lz" >&5 $as_echo_n "checking for inflate in -lz... " >&6; } -if test "${ac_cv_lib_z_inflate+set}" = set; then : +if ${ac_cv_lib_z_inflate+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -5978,7 +6025,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_inflate" >&5 $as_echo "$ac_cv_lib_z_inflate" >&6; } -if test "x$ac_cv_lib_z_inflate" = x""yes; then : +if test "x$ac_cv_lib_z_inflate" = xyes; then : NEON_LIBS="$NEON_LIBS -lz" @@ -6074,7 +6121,7 @@ yes|openssl) set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : +if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in @@ -6088,7 +6135,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6120,7 +6167,7 @@ if test "$PKG_CONFIG" = "no"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing RSA_new" >&5 $as_echo_n "checking for library containing RSA_new... " >&6; } -if test "${ne_cv_libsfor_RSA_new+set}" = set; then : +if ${ne_cv_libsfor_RSA_new+:} false; then : $as_echo_n "(cached) " >&6 else @@ -6205,7 +6252,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing SSL_library_init" >&5 $as_echo_n "checking for library containing SSL_library_init... " >&6; } -if test "${ne_cv_libsfor_SSL_library_init+set}" = set; then : +if ${ne_cv_libsfor_SSL_library_init+:} false; then : $as_echo_n "(cached) " >&6 else @@ -6287,7 +6334,7 @@ fi else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for openssl pkg-config data" >&5 $as_echo_n "checking for openssl pkg-config data... " >&6; } -if test "${ne_cv_pkg_openssl+set}" = set; then : +if ${ne_cv_pkg_openssl+:} false; then : $as_echo_n "(cached) " >&6 else if $PKG_CONFIG openssl; then @@ -6316,7 +6363,7 @@ $as_echo "$as_me: using SSL library configuration from pkg-config" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing RSA_new" >&5 $as_echo_n "checking for library containing RSA_new... " >&6; } -if test "${ne_cv_libsfor_RSA_new+set}" = set; then : +if ${ne_cv_libsfor_RSA_new+:} false; then : $as_echo_n "(cached) " >&6 else @@ -6401,7 +6448,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing SSL_library_init" >&5 $as_echo_n "checking for library containing SSL_library_init... " >&6; } -if test "${ne_cv_libsfor_SSL_library_init+set}" = set; then : +if ${ne_cv_libsfor_SSL_library_init+:} false; then : $as_echo_n "(cached) " >&6 else @@ -6506,7 +6553,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking OpenSSL version is >= 0.9.7" >&5 $as_echo_n "checking OpenSSL version is >= 0.9.7... " >&6; } -if test "${ne_cv_lib_ssl097+set}" = set; then : +if ${ne_cv_lib_ssl097+:} false; then : $as_echo_n "(cached) " >&6 else @@ -6562,7 +6609,7 @@ LIBS=$ne_cf_save_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: checking OpenSSL version is >= 0.9.6" >&5 $as_echo_n "checking OpenSSL version is >= 0.9.6... " >&6; } -if test "${ne_cv_lib_ssl096+set}" = set; then : +if ${ne_cv_lib_ssl096+:} false; then : $as_echo_n "(cached) " >&6 else @@ -6609,7 +6656,7 @@ _ACEOF *) # Guess whether EGD support is needed { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable EGD support" >&5 $as_echo_n "checking whether to enable EGD support... " >&6; } -if test "${ne_cv_lib_sslegd+set}" = set; then : +if ${ne_cv_lib_sslegd+:} false; then : $as_echo_n "(cached) " >&6 else if test -r /dev/random || test -r /dev/urandom; then @@ -6648,7 +6695,7 @@ gnutls) set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : +if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in @@ -6662,7 +6709,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6693,7 +6740,7 @@ if test "$PKG_CONFIG" = "no"; then set dummy libgnutls-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_GNUTLS_CONFIG+set}" = set; then : +if ${ac_cv_path_GNUTLS_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $GNUTLS_CONFIG in @@ -6707,7 +6754,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_GNUTLS_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6743,7 +6790,7 @@ fi else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gnutls pkg-config data" >&5 $as_echo_n "checking for gnutls pkg-config data... " >&6; } -if test "${ne_cv_pkg_gnutls+set}" = set; then : +if ${ne_cv_pkg_gnutls+:} false; then : $as_echo_n "(cached) " >&6 else if $PKG_CONFIG gnutls; then @@ -6774,7 +6821,7 @@ $as_echo "$as_me: using GnuTLS configuration from pkg-config" >&6;} set dummy libgnutls-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_GNUTLS_CONFIG+set}" = set; then : +if ${ac_cv_path_GNUTLS_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $GNUTLS_CONFIG in @@ -6788,7 +6835,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_GNUTLS_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6828,7 +6875,7 @@ fi ac_fn_c_check_header_mongrel "$LINENO" "gnutls/gnutls.h" "ac_cv_header_gnutls_gnutls_h" "$ac_includes_default" -if test "x$ac_cv_header_gnutls_gnutls_h" = x""yes; then : +if test "x$ac_cv_header_gnutls_gnutls_h" = xyes; then : else as_fn_error $? "could not find gnutls/gnutls.h in include path" "$LINENO" 5 @@ -6857,8 +6904,9 @@ ne_cf_save_LIBS=$LIBS LIBS="$LIBS $NEON_LIBS" for ac_func in gnutls_session_get_data2 gnutls_x509_dn_get_rdn_ava \ gnutls_sign_callback_set \ + gnutls_certificate_get_issuer \ gnutls_certificate_get_x509_cas \ - gnutls_certificate_verify_peers2 + gnutls_x509_crt_sign2 do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -6872,9 +6920,9 @@ done LIBS=$ne_cf_save_LIBS - # fail if gnutls_certificate_verify_peers2 is not found - if test x${ac_cv_func_gnutls_certificate_verify_peers2} != xyes; then - as_fn_error $? "GnuTLS version predates gnutls_certificate_verify_peers2, newer version required" "$LINENO" 5 + # fail if gnutls_x509_crt_sign2 is not found (it was introduced in 1.2.0, which is required) + if test x${ac_cv_func_gnutls_x509_crt_sign2} != xyes; then + as_fn_error $? "GnuTLS version predates gnutls_x509_crt_sign2, newer version required (at least 1.2.0)" "$LINENO" 5 fi # Check for iconv support if using the new RDN access functions: @@ -6882,7 +6930,7 @@ LIBS=$ne_cf_save_LIBS for ac_func in iconv do : ac_fn_c_check_func "$LINENO" "iconv" "ac_cv_func_iconv" -if test "x$ac_cv_func_iconv" = x""yes; then : +if test "x$ac_cv_func_iconv" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ICONV 1 _ACEOF @@ -6995,7 +7043,7 @@ noX*Y*) ;; set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : +if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in @@ -7009,7 +7057,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -7039,7 +7087,7 @@ $as_echo "$as_me: pakchois library not found; no PKCS#11 support" >&6;} else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pakchois pkg-config data" >&5 $as_echo_n "checking for pakchois pkg-config data... " >&6; } -if test "${ne_cv_pkg_pakchois+set}" = set; then : +if ${ne_cv_pkg_pakchois+:} false; then : $as_echo_n "(cached) " >&6 else if $PKG_CONFIG pakchois; then @@ -7086,7 +7134,7 @@ if test "$with_gssapi" != "no"; then set dummy krb5-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_KRB5_CONFIG+set}" = set; then : +if ${ac_cv_path_KRB5_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $KRB5_CONFIG in @@ -7101,7 +7149,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_KRB5_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -7148,7 +7196,7 @@ LIBS="$LIBS $NEON_LIBS" for ac_func in gss_init_sec_context do : ac_fn_c_check_func "$LINENO" "gss_init_sec_context" "ac_cv_func_gss_init_sec_context" -if test "x$ac_cv_func_gss_init_sec_context" = x""yes; then : +if test "x$ac_cv_func_gss_init_sec_context" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GSS_INIT_SEC_CONTEXT 1 _ACEOF @@ -7163,7 +7211,7 @@ $as_echo "#define HAVE_GSSAPI 1" >>confdefs.h for ac_header in gssapi/gssapi_generic.h do : ac_fn_c_check_header_mongrel "$LINENO" "gssapi/gssapi_generic.h" "ac_cv_header_gssapi_gssapi_generic_h" "$ac_includes_default" -if test "x$ac_cv_header_gssapi_gssapi_generic_h" = x""yes; then : +if test "x$ac_cv_header_gssapi_gssapi_generic_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GSSAPI_GSSAPI_GENERIC_H 1 _ACEOF @@ -7179,7 +7227,7 @@ done #include #endif " -if test "x$ac_cv_have_decl_GSS_C_NT_HOSTBASED_SERVICE" = x""yes; then : +if test "x$ac_cv_have_decl_GSS_C_NT_HOSTBASED_SERVICE" = xyes; then : else @@ -7215,7 +7263,7 @@ if test "x$with_libproxy" != "xno"; then set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : +if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in @@ -7229,7 +7277,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -7264,7 +7312,7 @@ $as_echo "$as_me: libproxy support not enabled" >&6;} else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libproxy-1.0 pkg-config data" >&5 $as_echo_n "checking for libproxy-1.0 pkg-config data... " >&6; } -if test "${ne_cv_pkg_libproxy_1_0+set}" = set; then : +if ${ne_cv_pkg_libproxy_1_0+:} false; then : $as_echo_n "(cached) " >&6 else if $PKG_CONFIG libproxy-1.0; then @@ -7367,8 +7415,8 @@ esac -macro_version='2.2.10' -macro_revision='1.3175' +macro_version='2.4.2' +macro_revision='1.3337' @@ -7390,7 +7438,7 @@ $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } -if test "${ac_cv_build+set}" = set; then : +if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias @@ -7424,7 +7472,7 @@ case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } -if test "${ac_cv_host+set}" = set; then : +if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then @@ -7479,7 +7527,7 @@ ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 $as_echo_n "checking how to print strings... " >&6; } # Test print first, because it will be a builtin if present. -if test "X`print -r -- -n 2>/dev/null`" = X-n && \ +if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then @@ -7526,7 +7574,7 @@ esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } -if test "${ac_cv_path_SED+set}" = set; then : +if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ @@ -7546,7 +7594,7 @@ do for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue + as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in @@ -7608,7 +7656,7 @@ Xsed="$SED -e 1s/^X//" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } -if test "${ac_cv_path_FGREP+set}" = set; then : +if ${ac_cv_path_FGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 @@ -7625,7 +7673,7 @@ do for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue + as_fn_executable_p "$ac_path_FGREP" || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in @@ -7739,7 +7787,7 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi -if test "${lt_cv_path_LD+set}" = set; then : +if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then @@ -7779,7 +7827,7 @@ fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } -if test "${lt_cv_prog_gnu_ld+set}" = set; then : +if ${lt_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. @@ -7806,7 +7854,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } -if test "${lt_cv_path_NM+set}" = set; then : +if ${lt_cv_path_NM+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then @@ -7869,7 +7917,7 @@ else set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_DUMPBIN+set}" = set; then : +if ${ac_cv_prog_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then @@ -7881,7 +7929,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -7913,7 +7961,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_DUMPBIN+set}" = set; then : +if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DUMPBIN"; then @@ -7925,7 +7973,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -7985,7 +8033,7 @@ test -z "$NM" && NM=nm { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 $as_echo_n "checking the name lister ($NM) interface... " >&6; } -if test "${lt_cv_nm_interface+set}" = set; then : +if ${lt_cv_nm_interface+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_nm_interface="BSD nm" @@ -8020,7 +8068,7 @@ fi # find the maximum length of command line arguments { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 $as_echo_n "checking the maximum length of command line arguments... " >&6; } -if test "${lt_cv_sys_max_cmd_len+set}" = set; then : +if ${lt_cv_sys_max_cmd_len+:} false; then : $as_echo_n "(cached) " >&6 else i=0 @@ -8083,6 +8131,11 @@ else lt_cv_sys_max_cmd_len=196608 ;; + os2*) + # The test takes a long time on OS/2. + lt_cv_sys_max_cmd_len=8192 + ;; + osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not @@ -8122,7 +8175,7 @@ else # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. - while { test "X"`func_fallback_echo "$teststring$teststring" 2>/dev/null` \ + while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do @@ -8165,8 +8218,8 @@ $as_echo_n "checking whether the shell understands some XSI constructs... " >&6; # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" - test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ - = c,a/b,, \ + test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ + = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes @@ -8215,9 +8268,83 @@ esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 +$as_echo_n "checking how to convert $build file names to $host format... " >&6; } +if ${lt_cv_to_host_file_cmd+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 + ;; + esac + ;; + *-*-cygwin* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin + ;; + esac + ;; + * ) # unhandled hosts (and "normal" native builds) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; +esac + +fi + +to_host_file_cmd=$lt_cv_to_host_file_cmd +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 +$as_echo "$lt_cv_to_host_file_cmd" >&6; } + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 +$as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } +if ${lt_cv_to_tool_file_cmd+:} false; then : + $as_echo_n "(cached) " >&6 +else + #assume ordinary cross tools, or native build. +lt_cv_to_tool_file_cmd=func_convert_file_noop +case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 + ;; + esac + ;; +esac + +fi + +to_tool_file_cmd=$lt_cv_to_tool_file_cmd +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 +$as_echo "$lt_cv_to_tool_file_cmd" >&6; } + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 $as_echo_n "checking for $LD option to reload object files... " >&6; } -if test "${lt_cv_ld_reload_flag+set}" = set; then : +if ${lt_cv_ld_reload_flag+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_reload_flag='-r' @@ -8231,6 +8358,11 @@ case $reload_flag in esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + if test "$GCC" != yes; then + reload_cmds=false + fi + ;; darwin*) if test "$GCC" = yes; then reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' @@ -8253,7 +8385,7 @@ if test -n "$ac_tool_prefix"; then set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OBJDUMP+set}" = set; then : +if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then @@ -8265,7 +8397,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -8293,7 +8425,7 @@ if test -z "$ac_cv_prog_OBJDUMP"; then set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then : +if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then @@ -8305,7 +8437,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -8352,7 +8484,7 @@ test -z "$OBJDUMP" && OBJDUMP=objdump { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 $as_echo_n "checking how to recognize dependent libraries... " >&6; } -if test "${lt_cv_deplibs_check_method+set}" = set; then : +if ${lt_cv_deplibs_check_method+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' @@ -8472,7 +8604,7 @@ irix5* | irix6* | nonstopux*) lt_cv_deplibs_check_method=pass_all ;; -# This must be Linux ELF. +# This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; @@ -8554,6 +8686,21 @@ esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 $as_echo "$lt_cv_deplibs_check_method" >&6; } + +file_magic_glob= +want_nocaseglob=no +if test "$build" = "$host"; then + case $host_os in + mingw* | pw32*) + if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then + want_nocaseglob=yes + else + file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` + fi + ;; + esac +fi + file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown @@ -8567,14 +8714,167 @@ test -z "$deplibs_check_method" && deplibs_check_method=unknown + + + + + + + + + + if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. -set dummy ${ac_tool_prefix}ar; ac_word=$2 + # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. +set dummy ${ac_tool_prefix}dlltool; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_DLLTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$DLLTOOL"; then + ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +DLLTOOL=$ac_cv_prog_DLLTOOL +if test -n "$DLLTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 +$as_echo "$DLLTOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_DLLTOOL"; then + ac_ct_DLLTOOL=$DLLTOOL + # Extract the first word of "dlltool", so it can be a program name with args. +set dummy dlltool; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_DLLTOOL"; then + ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_DLLTOOL="dlltool" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL +if test -n "$ac_ct_DLLTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 +$as_echo "$ac_ct_DLLTOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_DLLTOOL" = x; then + DLLTOOL="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DLLTOOL=$ac_ct_DLLTOOL + fi +else + DLLTOOL="$ac_cv_prog_DLLTOOL" +fi + +test -z "$DLLTOOL" && DLLTOOL=dlltool + + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 +$as_echo_n "checking how to associate runtime and link libraries... " >&6; } +if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_sharedlib_from_linklib_cmd='unknown' + +case $host_os in +cygwin* | mingw* | pw32* | cegcc*) + # two different shell functions defined in ltmain.sh + # decide which to use based on capabilities of $DLLTOOL + case `$DLLTOOL --help 2>&1` in + *--identify-strict*) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib + ;; + *) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback + ;; + esac + ;; +*) + # fallback: assume linklib IS sharedlib + lt_cv_sharedlib_from_linklib_cmd="$ECHO" + ;; +esac + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 +$as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } +sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd +test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO + + + + + + + +if test -n "$ac_tool_prefix"; then + for ac_prog in ar + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_AR+set}" = set; then : +if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then @@ -8586,8 +8886,8 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_AR="${ac_tool_prefix}ar" + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -8607,14 +8907,18 @@ $as_echo "no" >&6; } fi + test -n "$AR" && break + done fi -if test -z "$ac_cv_prog_AR"; then +if test -z "$AR"; then ac_ct_AR=$AR - # Extract the first word of "ar", so it can be a program name with args. -set dummy ar; ac_word=$2 + for ac_prog in ar +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_AR+set}" = set; then : +if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then @@ -8626,8 +8930,8 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_AR="ar" + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -8646,6 +8950,10 @@ else $as_echo "no" >&6; } fi + + test -n "$ac_ct_AR" && break +done + if test "x$ac_ct_AR" = x; then AR="false" else @@ -8657,12 +8965,10 @@ ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi -else - AR="$ac_cv_prog_AR" fi -test -z "$AR" && AR=ar -test -z "$AR_FLAGS" && AR_FLAGS=cru +: ${AR=ar} +: ${AR_FLAGS=cru} @@ -8674,12 +8980,70 @@ test -z "$AR_FLAGS" && AR_FLAGS=cru +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 +$as_echo_n "checking for archiver @FILE support... " >&6; } +if ${lt_cv_ar_at_file+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_ar_at_file=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + echo conftest.$ac_objext > conftest.lst + lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 + (eval $lt_ar_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if test "$ac_status" -eq 0; then + # Ensure the archiver fails upon bogus file names. + rm -f conftest.$ac_objext libconftest.a + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 + (eval $lt_ar_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if test "$ac_status" -ne 0; then + lt_cv_ar_at_file=@ + fi + fi + rm -f conftest.* libconftest.a + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 +$as_echo "$lt_cv_ar_at_file" >&6; } + +if test "x$lt_cv_ar_at_file" = xno; then + archiver_list_spec= +else + archiver_list_spec=$lt_cv_ar_at_file +fi + + + + + + + if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_STRIP+set}" = set; then : +if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then @@ -8691,7 +9055,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -8719,7 +9083,7 @@ if test -z "$ac_cv_prog_STRIP"; then set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : +if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then @@ -8731,7 +9095,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -8778,7 +9142,7 @@ if test -n "$ac_tool_prefix"; then set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_RANLIB+set}" = set; then : +if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then @@ -8790,7 +9154,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -8818,7 +9182,7 @@ if test -z "$ac_cv_prog_RANLIB"; then set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then : +if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then @@ -8830,7 +9194,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -8880,13 +9244,13 @@ old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" + old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in @@ -8922,7 +9286,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_AWK+set}" = set; then : +if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then @@ -8934,7 +9298,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -8989,7 +9353,7 @@ compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } -if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then : +if ${lt_cv_sys_global_symbol_pipe+:} false; then : $as_echo_n "(cached) " >&6 else @@ -9050,8 +9414,8 @@ esac lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= @@ -9075,6 +9439,7 @@ for ac_symprfx in "" "_"; do # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ +" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ @@ -9087,6 +9452,7 @@ for ac_symprfx in "" "_"; do else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi + lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no @@ -9128,6 +9494,18 @@ _LT_EOF if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) +/* DATA imports from DLLs on WIN32 con't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT_DLSYM_CONST +#elif defined(__osf__) +/* This system does not cope well with relocations in const data. */ +# define LT_DLSYM_CONST +#else +# define LT_DLSYM_CONST const +#endif + #ifdef __cplusplus extern "C" { #endif @@ -9139,7 +9517,7 @@ _LT_EOF cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ -const struct { +LT_DLSYM_CONST struct { const char *name; void *address; } @@ -9165,8 +9543,8 @@ static const void *lt_preloaded_setup() { _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext - lt_save_LIBS="$LIBS" - lt_save_CFLAGS="$CFLAGS" + lt_globsym_save_LIBS=$LIBS + lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 @@ -9176,8 +9554,8 @@ _LT_EOF test $ac_status = 0; } && test -s conftest${ac_exeext}; then pipe_works=yes fi - LIBS="$lt_save_LIBS" - CFLAGS="$lt_save_CFLAGS" + LIBS=$lt_globsym_save_LIBS + CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&5 fi @@ -9214,6 +9592,19 @@ else $as_echo "ok" >&6; } fi +# Response file support. +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + nm_file_list_spec='@' +elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then + nm_file_list_spec='@' +fi + + + + + + + @@ -9230,6 +9621,42 @@ fi + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 +$as_echo_n "checking for sysroot... " >&6; } + +# Check whether --with-sysroot was given. +if test "${with_sysroot+set}" = set; then : + withval=$with_sysroot; +else + with_sysroot=no +fi + + +lt_sysroot= +case ${with_sysroot} in #( + yes) + if test "$GCC" = yes; then + lt_sysroot=`$CC --print-sysroot 2>/dev/null` + fi + ;; #( + /*) + lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` + ;; #( + no|'') + ;; #( + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5 +$as_echo "${with_sysroot}" >&6; } + as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 + ;; +esac + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 +$as_echo "${lt_sysroot:-no}" >&6; } @@ -9360,7 +9787,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) CFLAGS="$CFLAGS -belf" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 $as_echo_n "checking whether the C compiler needs -belf... " >&6; } -if test "${lt_cv_cc_needs_belf+set}" = set; then : +if ${lt_cv_cc_needs_belf+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c @@ -9401,7 +9828,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; } CFLAGS="$SAVE_CFLAGS" fi ;; -sparc*-*solaris*) +*-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 @@ -9412,7 +9839,20 @@ sparc*-*solaris*) case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in - yes*) LD="${LD-ld} -m elf64_sparc" ;; + yes*) + case $host in + i?86-*-solaris*) + LD="${LD-ld} -m elf_x86_64" + ;; + sparc*-*-solaris*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + # GNU ld 2.21 introduced _sol2 emulations. Use them if available. + if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then + LD="${LD-ld}_sol2" + fi + ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" @@ -9428,7 +9868,124 @@ esac need_locks="$enable_libtool_lock" - +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. +set dummy ${ac_tool_prefix}mt; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$MANIFEST_TOOL"; then + ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL +if test -n "$MANIFEST_TOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 +$as_echo "$MANIFEST_TOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_MANIFEST_TOOL"; then + ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL + # Extract the first word of "mt", so it can be a program name with args. +set dummy mt; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_MANIFEST_TOOL"; then + ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL +if test -n "$ac_ct_MANIFEST_TOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 +$as_echo "$ac_ct_MANIFEST_TOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_MANIFEST_TOOL" = x; then + MANIFEST_TOOL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL + fi +else + MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" +fi + +test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 +$as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } +if ${lt_cv_path_mainfest_tool+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_path_mainfest_tool=no + echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 + $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out + cat conftest.err >&5 + if $GREP 'Manifest Tool' conftest.out > /dev/null; then + lt_cv_path_mainfest_tool=yes + fi + rm -f conftest* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 +$as_echo "$lt_cv_path_mainfest_tool" >&6; } +if test "x$lt_cv_path_mainfest_tool" != xyes; then + MANIFEST_TOOL=: +fi + + + + + + case $host_os in rhapsody* | darwin*) if test -n "$ac_tool_prefix"; then @@ -9436,7 +9993,7 @@ need_locks="$enable_libtool_lock" set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_DSYMUTIL+set}" = set; then : +if ${ac_cv_prog_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DSYMUTIL"; then @@ -9448,7 +10005,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -9476,7 +10033,7 @@ if test -z "$ac_cv_prog_DSYMUTIL"; then set dummy dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_DSYMUTIL+set}" = set; then : +if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DSYMUTIL"; then @@ -9488,7 +10045,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -9528,7 +10085,7 @@ fi set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_NMEDIT+set}" = set; then : +if ${ac_cv_prog_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NMEDIT"; then @@ -9540,7 +10097,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -9568,7 +10125,7 @@ if test -z "$ac_cv_prog_NMEDIT"; then set dummy nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_NMEDIT+set}" = set; then : +if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NMEDIT"; then @@ -9580,7 +10137,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -9620,7 +10177,7 @@ fi set dummy ${ac_tool_prefix}lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_LIPO+set}" = set; then : +if ${ac_cv_prog_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LIPO"; then @@ -9632,7 +10189,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -9660,7 +10217,7 @@ if test -z "$ac_cv_prog_LIPO"; then set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_LIPO+set}" = set; then : +if ${ac_cv_prog_ac_ct_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_LIPO"; then @@ -9672,7 +10229,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -9712,7 +10269,7 @@ fi set dummy ${ac_tool_prefix}otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OTOOL+set}" = set; then : +if ${ac_cv_prog_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL"; then @@ -9724,7 +10281,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -9752,7 +10309,7 @@ if test -z "$ac_cv_prog_OTOOL"; then set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OTOOL+set}" = set; then : +if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL"; then @@ -9764,7 +10321,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -9804,7 +10361,7 @@ fi set dummy ${ac_tool_prefix}otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OTOOL64+set}" = set; then : +if ${ac_cv_prog_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL64"; then @@ -9816,7 +10373,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -9844,7 +10401,7 @@ if test -z "$ac_cv_prog_OTOOL64"; then set dummy otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OTOOL64+set}" = set; then : +if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL64"; then @@ -9856,7 +10413,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -9919,7 +10476,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 $as_echo_n "checking for -single_module linker flag... " >&6; } -if test "${lt_cv_apple_cc_single_mod+set}" = set; then : +if ${lt_cv_apple_cc_single_mod+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_apple_cc_single_mod=no @@ -9935,7 +10492,13 @@ else $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? - if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then + # If there is a non-empty error log, and "single_module" + # appears in it, assume the flag caused a linker warning + if test -s conftest.err && $GREP single_module conftest.err; then + cat conftest.err >&5 + # Otherwise, if the output was created with a 0 exit code from + # the compiler, it worked. + elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 @@ -9946,9 +10509,10 @@ else fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 $as_echo "$lt_cv_apple_cc_single_mod" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } -if test "${lt_cv_ld_exported_symbols_list+set}" = set; then : +if ${lt_cv_ld_exported_symbols_list+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_exported_symbols_list=no @@ -9978,9 +10542,10 @@ rm -f core conftest.err conftest.$ac_objext \ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 $as_echo_n "checking for -force_load linker flag... " >&6; } -if test "${lt_cv_ld_force_load+set}" = set; then : +if ${lt_cv_ld_force_load+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_force_load=no @@ -9999,7 +10564,9 @@ _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? - if test -f conftest && test ! -s conftest.err && test $_lt_result = 0 && $GREP forced_load conftest 2>&1 >/dev/null; then + if test -s conftest.err && $GREP force_load conftest.err; then + cat conftest.err >&5 + elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&5 @@ -10049,7 +10616,7 @@ for ac_header in dlfcn.h do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " -if test "x$ac_cv_header_dlfcn_h" = x""yes; then : +if test "x$ac_cv_header_dlfcn_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF @@ -10107,7 +10674,22 @@ fi # Check whether --with-pic was given. if test "${with_pic+set}" = set; then : - withval=$with_pic; pic_mode="$withval" + withval=$with_pic; lt_p=${PACKAGE-default} + case $withval in + yes|no) pic_mode=$withval ;; + *) + pic_mode=default + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for lt_pkg in $withval; do + IFS="$lt_save_ifs" + if test "X$lt_pkg" = "X$lt_p"; then + pic_mode=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac else pic_mode=default fi @@ -10180,6 +10762,10 @@ LIBTOOL='$(SHELL) $(top_builddir)/libtool' + + + + @@ -10206,7 +10792,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 $as_echo_n "checking for objdir... " >&6; } -if test "${lt_cv_objdir+set}" = set; then : +if ${lt_cv_objdir+:} false; then : $as_echo_n "(cached) " >&6 else rm -f .libs 2>/dev/null @@ -10284,7 +10870,7 @@ file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } -if test "${lt_cv_path_MAGIC_CMD+set}" = set; then : +if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in @@ -10350,7 +10936,7 @@ if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 $as_echo_n "checking for file... " >&6; } -if test "${lt_cv_path_MAGIC_CMD+set}" = set; then : +if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in @@ -10488,7 +11074,7 @@ if test "$GCC" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } -if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then : +if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_rtti_exceptions=no @@ -10541,8 +11127,6 @@ fi lt_prog_compiler_pic= lt_prog_compiler_static= -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 -$as_echo_n "checking for $compiler option to produce PIC... " >&6; } if test "$GCC" = yes; then lt_prog_compiler_wl='-Wl,' @@ -10642,7 +11226,9 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; } case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 lt_prog_compiler_wl='-Xlinker ' - lt_prog_compiler_pic='-Xcompiler -fPIC' + if test -n "$lt_prog_compiler_pic"; then + lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" + fi ;; esac else @@ -10707,6 +11293,12 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; } lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; + nagfor*) + # NAG Fortran compiler + lt_prog_compiler_wl='-Wl,-Wl,,' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) @@ -10727,18 +11319,33 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; } ;; *) case `$CC -V 2>&1 | sed 5q` in - *Sun\ F* | *Sun*Fortran*) + *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; + *Sun\ F* | *Sun*Fortran*) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='-Qoption ld ' + ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; + *Intel*\ [CF]*Compiler*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + *Portland\ Group*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fpic' + lt_prog_compiler_static='-Bstatic' + ;; esac ;; esac @@ -10826,13 +11433,17 @@ case $host_os in lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic" >&5 -$as_echo "$lt_prog_compiler_pic" >&6; } - - - - +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 +$as_echo_n "checking for $compiler option to produce PIC... " >&6; } +if ${lt_cv_prog_compiler_pic+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_pic=$lt_prog_compiler_pic +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 +$as_echo "$lt_cv_prog_compiler_pic" >&6; } +lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # Check to make sure the PIC flag actually works. @@ -10840,7 +11451,7 @@ $as_echo "$lt_prog_compiler_pic" >&6; } if test -n "$lt_prog_compiler_pic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } -if test "${lt_cv_prog_compiler_pic_works+set}" = set; then : +if ${lt_cv_prog_compiler_pic_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works=no @@ -10893,13 +11504,18 @@ fi + + + + + # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } -if test "${lt_cv_prog_compiler_static_works+set}" = set; then : +if ${lt_cv_prog_compiler_static_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works=no @@ -10942,7 +11558,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if test "${lt_cv_prog_compiler_c_o+set}" = set; then : +if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no @@ -10997,7 +11613,7 @@ $as_echo "$lt_cv_prog_compiler_c_o" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if test "${lt_cv_prog_compiler_c_o+set}" = set; then : +if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no @@ -11091,7 +11707,6 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= - hardcode_libdir_flag_spec_ld= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported @@ -11243,7 +11858,8 @@ _LT_EOF allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes - export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' + exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' @@ -11291,7 +11907,7 @@ _LT_EOF if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then - tmp_addflag= + tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler @@ -11340,8 +11956,7 @@ _LT_EOF xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' - hardcode_libdir_flag_spec= - hardcode_libdir_flag_spec_ld='-rpath $libdir' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ @@ -11361,8 +11976,8 @@ _LT_EOF archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; @@ -11380,8 +11995,8 @@ _LT_EOF _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi @@ -11427,8 +12042,8 @@ _LT_EOF *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi @@ -11558,7 +12173,13 @@ _LT_EOF allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test "${lt_cv_aix_libpath+set}" = set; then + aix_libpath=$lt_cv_aix_libpath +else + if ${lt_cv_aix_libpath_+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -11571,22 +12192,29 @@ main () _ACEOF if ac_fn_c_try_link "$LINENO"; then : -lt_aix_libpath_sed=' - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\(.*\)$/\1/ - p - } - }' -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then - aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -fi + lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\([^ ]*\) *$/\1/ + p + } + }' + lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + # Check for a 64-bit object if we didn't find anything. + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_="/usr/lib:/lib" + fi + +fi + + aix_libpath=$lt_cv_aix_libpath_ +fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" @@ -11598,7 +12226,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi else # Determine the default libpath from the value encoded in an # empty executable. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test "${lt_cv_aix_libpath+set}" = set; then + aix_libpath=$lt_cv_aix_libpath +else + if ${lt_cv_aix_libpath_+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -11611,22 +12245,29 @@ main () _ACEOF if ac_fn_c_try_link "$LINENO"; then : -lt_aix_libpath_sed=' - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\(.*\)$/\1/ - p - } - }' -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then - aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -fi + lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\([^ ]*\) *$/\1/ + p + } + }' + lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + # Check for a 64-bit object if we didn't find anything. + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_="/usr/lib:/lib" + fi + +fi + + aix_libpath=$lt_cv_aix_libpath_ +fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, @@ -11671,20 +12312,64 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. - hardcode_libdir_flag_spec=' ' - allow_undefined_flag=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - old_archive_from_new_cmds='true' - # FIXME: Should let the user specify the lib program. - old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' - fix_srcfile_path='`cygpath -w "$srcfile"`' - enable_shared_with_static_runtimes=yes + case $cc_basename in + cl*) + # Native MSVC + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + always_export_symbols=yes + file_list_spec='@' + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' + archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; + else + sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' + # The linker will not automatically build a static lib if we build a DLL. + # _LT_TAGVAR(old_archive_from_new_cmds, )='true' + enable_shared_with_static_runtimes=yes + exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' + # Don't use ranlib + old_postinstall_cmds='chmod 644 $oldlib' + postlink_cmds='lt_outputfile="@OUTPUT@"~ + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile="$lt_outputfile.exe" + lt_tool_outputfile="$lt_tool_outputfile.exe" + ;; + esac~ + if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' + ;; + *) + # Assume MSVC wrapper + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_from_new_cmds='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' + enable_shared_with_static_runtimes=yes + ;; + esac ;; darwin* | rhapsody*) @@ -11696,6 +12381,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_shlibpath_var=unsupported if test "$lt_cv_ld_force_load" = "yes"; then whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' + else whole_archive_flag_spec='' fi @@ -11724,10 +12410,6 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_shlibpath_var=no ;; - freebsd1*) - ld_shlibs=no - ;; - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little @@ -11740,7 +12422,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) + freebsd2.*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes @@ -11749,7 +12431,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) - archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no @@ -11757,7 +12439,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hpux9*) if test "$GCC" = yes; then - archive_cmds='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi @@ -11773,13 +12455,12 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then - archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_flag_spec_ld='+b $libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes @@ -11797,10 +12478,10 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) - archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) - archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else @@ -11817,7 +12498,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 $as_echo_n "checking if $CC understands -b... " >&6; } -if test "${lt_cv_prog_compiler__b+set}" = set; then : +if ${lt_cv_prog_compiler__b+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler__b=no @@ -11879,23 +12560,36 @@ fi irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + # This should be the same for all languages, so no per-tag cache variable. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 +$as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } +if ${lt_cv_irix_exported_symbol+:} false; then : + $as_echo_n "(cached) " >&6 +else + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -int foo(void) {} +int foo (void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' - + lt_cv_irix_exported_symbol=yes +else + lt_cv_irix_exported_symbol=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - LDFLAGS="$save_LDFLAGS" + LDFLAGS="$save_LDFLAGS" +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 +$as_echo "$lt_cv_irix_exported_symbol" >&6; } + if test "$lt_cv_irix_exported_symbol" = yes; then + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' + fi else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' @@ -11980,7 +12674,7 @@ rm -f core conftest.err conftest.$ac_objext \ osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' else allow_undefined_flag=' -expect_unresolved \*' @@ -11999,9 +12693,9 @@ rm -f core conftest.err conftest.$ac_objext \ no_undefined_flag=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' - archive_cmds='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) @@ -12189,7 +12883,7 @@ x|xyes) # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } -if test "${lt_cv_archive_cmds_need_lc+set}" = set; then : +if ${lt_cv_archive_cmds_need_lc+:} false; then : $as_echo_n "(cached) " >&6 else $RM conftest* @@ -12384,11 +13078,6 @@ esac - - - - - @@ -12484,7 +13173,7 @@ need_version=unknown case $host_os in aix3*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH @@ -12493,7 +13182,7 @@ aix3*) ;; aix[4-9]*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes @@ -12558,7 +13247,7 @@ beos*) ;; bsdi[45]*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' @@ -12577,8 +13266,9 @@ cygwin* | mingw* | pw32* | cegcc*) need_version=no need_lib_prefix=no - case $GCC,$host_os in - yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) + case $GCC,$cc_basename in + yes,*) + # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ @@ -12611,13 +13301,71 @@ cygwin* | mingw* | pw32* | cegcc*) library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac + dynamic_linker='Win32 ld.exe' + ;; + + *,cl*) + # Native MSVC + libname_spec='$name' + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + library_names_spec='${libname}.dll.lib' + + case $build_os in + mingw*) + sys_lib_search_path_spec= + lt_save_ifs=$IFS + IFS=';' + for lt_path in $LIB + do + IFS=$lt_save_ifs + # Let DOS variable expansion print the short 8.3 style file name. + lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` + sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" + done + IFS=$lt_save_ifs + # Convert to MSYS style. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` + ;; + cygwin*) + # Convert to unix form, then to dos form, then back to unix form + # but this time dos style (no spaces!) so that the unix form looks + # like /cygdrive/c/PROGRA~1:/cygdr... + sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` + sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` + sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + ;; + *) + sys_lib_search_path_spec="$LIB" + if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # FIXME: find the short name or the path components, as spaces are + # common. (e.g. "Program Files" -> "PROGRA~1") + ;; + esac + + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + dynamic_linker='Win32 link.exe' ;; *) + # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + dynamic_linker='Win32 ld.exe' ;; esac - dynamic_linker='Win32 ld.exe' # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; @@ -12638,7 +13386,7 @@ darwin* | rhapsody*) ;; dgux*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' @@ -12646,10 +13394,6 @@ dgux*) shlibpath_var=LD_LIBRARY_PATH ;; -freebsd1*) - dynamic_linker=no - ;; - freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. @@ -12657,7 +13401,7 @@ freebsd* | dragonfly*) objformat=`/usr/bin/objformat` else case $host_os in - freebsd[123]*) objformat=aout ;; + freebsd[23].*) objformat=aout ;; *) objformat=elf ;; esac fi @@ -12675,7 +13419,7 @@ freebsd* | dragonfly*) esac shlibpath_var=LD_LIBRARY_PATH case $host_os in - freebsd2*) + freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) @@ -12695,17 +13439,18 @@ freebsd* | dragonfly*) ;; gnu*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; haiku*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" @@ -12766,7 +13511,7 @@ hpux9* | hpux10* | hpux11*) ;; interix[3-9]*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' @@ -12782,7 +13527,7 @@ irix5* | irix6* | nonstopux*) nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; @@ -12819,9 +13564,9 @@ linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; -# This must be Linux ELF. +# This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -12831,7 +13576,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu) shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH - if test "${lt_cv_shlibpath_overrides_runpath+set}" = set; then : + if ${lt_cv_shlibpath_overrides_runpath+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no @@ -12907,7 +13652,7 @@ netbsd*) ;; newsos6) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes @@ -12976,7 +13721,7 @@ rdos*) ;; solaris*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -13001,7 +13746,7 @@ sunos4*) ;; sysv4 | sysv4.3*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH @@ -13025,7 +13770,7 @@ sysv4 | sysv4.3*) sysv4*MP*) if test -d /usr/nec ;then - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH @@ -13056,7 +13801,7 @@ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -13066,7 +13811,7 @@ tpf*) ;; uts4*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH @@ -13255,7 +14000,7 @@ else # if libdl is installed we need to link against it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } -if test "${ac_cv_lib_dl_dlopen+set}" = set; then : +if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -13289,7 +14034,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : +if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else @@ -13303,12 +14048,12 @@ fi *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" -if test "x$ac_cv_func_shl_load" = x""yes; then : +if test "x$ac_cv_func_shl_load" = xyes; then : lt_cv_dlopen="shl_load" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } -if test "${ac_cv_lib_dld_shl_load+set}" = set; then : +if ${ac_cv_lib_dld_shl_load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -13342,16 +14087,16 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } -if test "x$ac_cv_lib_dld_shl_load" = x""yes; then : +if test "x$ac_cv_lib_dld_shl_load" = xyes; then : lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" -if test "x$ac_cv_func_dlopen" = x""yes; then : +if test "x$ac_cv_func_dlopen" = xyes; then : lt_cv_dlopen="dlopen" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } -if test "${ac_cv_lib_dl_dlopen+set}" = set; then : +if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -13385,12 +14130,12 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : +if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } -if test "${ac_cv_lib_svld_dlopen+set}" = set; then : +if ${ac_cv_lib_svld_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -13424,12 +14169,12 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } -if test "x$ac_cv_lib_svld_dlopen" = x""yes; then : +if test "x$ac_cv_lib_svld_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } -if test "${ac_cv_lib_dld_dld_link+set}" = set; then : +if ${ac_cv_lib_dld_dld_link+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -13463,7 +14208,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } -if test "x$ac_cv_lib_dld_dld_link" = x""yes; then : +if test "x$ac_cv_lib_dld_dld_link" = xyes; then : lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" fi @@ -13504,7 +14249,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 $as_echo_n "checking whether a program can dlopen itself... " >&6; } -if test "${lt_cv_dlopen_self+set}" = set; then : +if ${lt_cv_dlopen_self+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : @@ -13557,10 +14302,10 @@ else /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) -void fnord () __attribute__((visibility("default"))); +int fnord () __attribute__((visibility("default"))); #endif -void fnord () { int i=42; } +int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); @@ -13610,7 +14355,7 @@ $as_echo "$lt_cv_dlopen_self" >&6; } wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } -if test "${lt_cv_dlopen_self_static+set}" = set; then : +if ${lt_cv_dlopen_self_static+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : @@ -13663,10 +14408,10 @@ else /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) -void fnord () __attribute__((visibility("default"))); +int fnord () __attribute__((visibility("default"))); #endif -void fnord () { int i=42; } +int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); @@ -13848,6 +14593,8 @@ CC="$lt_save_CC" + + ac_config_commands="$ac_config_commands libtool" @@ -13871,7 +14618,7 @@ CC="$lt_save_CC" # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of time_t" >&5 $as_echo_n "checking size of time_t... " >&6; } -if test "${ac_cv_sizeof_time_t+set}" = set; then : +if ${ac_cv_sizeof_time_t+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (time_t))" "ac_cv_sizeof_time_t" "$ac_includes_default @@ -13910,7 +14657,7 @@ _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print time_t" >&5 $as_echo_n "checking how to print time_t... " >&6; } -if test "${ne_cv_fmt_time_t+set}" = set; then : +if ${ne_cv_fmt_time_t+:} false; then : $as_echo_n "(cached) " >&6 else @@ -13968,7 +14715,7 @@ _ACEOF ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" -if test "x$ac_cv_type_pid_t" = x""yes; then : +if test "x$ac_cv_type_pid_t" = xyes; then : else @@ -13980,7 +14727,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } -if test "${ac_cv_header_time+set}" = set; then : +if ${ac_cv_header_time+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -14022,7 +14769,7 @@ if test -n "$ac_tool_prefix"; then set dummy ${ac_tool_prefix}ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_AR+set}" = set; then : +if ${ac_cv_path_AR+:} false; then : $as_echo_n "(cached) " >&6 else case $AR in @@ -14036,7 +14783,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_AR="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -14065,7 +14812,7 @@ if test -z "$ac_cv_path_AR"; then set dummy ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_ac_pt_AR+set}" = set; then : +if ${ac_cv_path_ac_pt_AR+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_AR in @@ -14079,7 +14826,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_AR="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -14123,7 +14870,7 @@ if test -n "$ac_tool_prefix"; then set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_RANLIB+set}" = set; then : +if ${ac_cv_path_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else case $RANLIB in @@ -14137,7 +14884,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_RANLIB="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -14166,7 +14913,7 @@ if test -z "$ac_cv_path_RANLIB"; then set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_ac_pt_RANLIB+set}" = set; then : +if ${ac_cv_path_ac_pt_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_RANLIB in @@ -14180,7 +14927,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_RANLIB="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -14228,7 +14975,7 @@ fi -for ac_header in sys/time.h stdint.h locale.h signal.h +for ac_header in sys/time.h stdint.h locale.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -14343,10 +15090,10 @@ if test "$NEON_NEED_XML_PARSER" = "yes"; then case $with_expat in yes) ac_fn_c_check_header_mongrel "$LINENO" "expat.h" "ac_cv_header_expat_h" "$ac_includes_default" -if test "x$ac_cv_header_expat_h" = x""yes; then : +if test "x$ac_cv_header_expat_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XML_SetXmlDeclHandler in -lexpat" >&5 $as_echo_n "checking for XML_SetXmlDeclHandler in -lexpat... " >&6; } -if test "${ac_cv_lib_expat_XML_SetXmlDeclHandler+set}" = set; then : +if ${ac_cv_lib_expat_XML_SetXmlDeclHandler+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -14380,7 +15127,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_expat_XML_SetXmlDeclHandler" >&5 $as_echo "$ac_cv_lib_expat_XML_SetXmlDeclHandler" >&6; } -if test "x$ac_cv_lib_expat_XML_SetXmlDeclHandler" = x""yes; then : +if test "x$ac_cv_lib_expat_XML_SetXmlDeclHandler" = xyes; then : $as_echo "#define HAVE_EXPAT 1" >>confdefs.h @@ -14390,7 +15137,7 @@ $as_echo "#define HAVE_EXPAT 1" >>confdefs.h neon_xml_parser=expat ac_fn_c_check_type "$LINENO" "XML_Size" "ac_cv_type_XML_Size" "#include " -if test "x$ac_cv_type_XML_Size" = x""yes; then : +if test "x$ac_cv_type_XML_Size" = xyes; then : @@ -14401,7 +15148,7 @@ if test "x$ac_cv_type_XML_Size" = x""yes; then : # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of XML_Size" >&5 $as_echo_n "checking size of XML_Size... " >&6; } -if test "${ac_cv_sizeof_XML_Size+set}" = set; then : +if ${ac_cv_sizeof_XML_Size+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (XML_Size))" "ac_cv_sizeof_XML_Size" "$ac_includes_default @@ -14437,7 +15184,7 @@ _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print XML_Size" >&5 $as_echo_n "checking how to print XML_Size... " >&6; } -if test "${ne_cv_fmt_XML_Size+set}" = set; then : +if ${ne_cv_fmt_XML_Size+:} false; then : $as_echo_n "(cached) " >&6 else @@ -14538,7 +15285,7 @@ _ACEOF set dummy xml2-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_XML2_CONFIG+set}" = set; then : +if ${ac_cv_prog_XML2_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$XML2_CONFIG"; then @@ -14550,7 +15297,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_XML2_CONFIG="xml2-config" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -14607,10 +15354,10 @@ fi if test "${neon_xml_parser}-${with_included_expat}" = "none-no"; then ac_fn_c_check_header_mongrel "$LINENO" "expat.h" "ac_cv_header_expat_h" "$ac_includes_default" -if test "x$ac_cv_header_expat_h" = x""yes; then : +if test "x$ac_cv_header_expat_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XML_SetXmlDeclHandler in -lexpat" >&5 $as_echo_n "checking for XML_SetXmlDeclHandler in -lexpat... " >&6; } -if test "${ac_cv_lib_expat_XML_SetXmlDeclHandler+set}" = set; then : +if ${ac_cv_lib_expat_XML_SetXmlDeclHandler+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -14644,7 +15391,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_expat_XML_SetXmlDeclHandler" >&5 $as_echo "$ac_cv_lib_expat_XML_SetXmlDeclHandler" >&6; } -if test "x$ac_cv_lib_expat_XML_SetXmlDeclHandler" = x""yes; then : +if test "x$ac_cv_lib_expat_XML_SetXmlDeclHandler" = xyes; then : $as_echo "#define HAVE_EXPAT 1" >>confdefs.h @@ -14654,7 +15401,7 @@ $as_echo "#define HAVE_EXPAT 1" >>confdefs.h neon_xml_parser=expat ac_fn_c_check_type "$LINENO" "XML_Size" "ac_cv_type_XML_Size" "#include " -if test "x$ac_cv_type_XML_Size" = x""yes; then : +if test "x$ac_cv_type_XML_Size" = xyes; then : @@ -14665,7 +15412,7 @@ if test "x$ac_cv_type_XML_Size" = x""yes; then : # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of XML_Size" >&5 $as_echo_n "checking size of XML_Size... " >&6; } -if test "${ac_cv_sizeof_XML_Size+set}" = set; then : +if ${ac_cv_sizeof_XML_Size+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (XML_Size))" "ac_cv_sizeof_XML_Size" "$ac_includes_default @@ -14701,7 +15448,7 @@ _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print XML_Size" >&5 $as_echo_n "checking how to print XML_Size... " >&6; } -if test "${ne_cv_fmt_XML_Size+set}" = set; then : +if ${ne_cv_fmt_XML_Size+:} false; then : $as_echo_n "(cached) " >&6 else @@ -14768,7 +15515,7 @@ else set dummy xml2-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_XML2_CONFIG+set}" = set; then : +if ${ac_cv_prog_XML2_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$XML2_CONFIG"; then @@ -14780,7 +15527,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_XML2_CONFIG="xml2-config" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -14839,7 +15586,7 @@ else set dummy xml2-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_XML2_CONFIG+set}" = set; then : +if ${ac_cv_prog_XML2_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$XML2_CONFIG"; then @@ -14851,7 +15598,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_XML2_CONFIG="xml2-config" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -14939,7 +15686,7 @@ if test x${enable_nls} = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing bindtextdomain" >&5 $as_echo_n "checking for library containing bindtextdomain... " >&6; } -if test "${ne_cv_libsfor_bindtextdomain+set}" = set; then : +if ${ne_cv_libsfor_bindtextdomain+:} false; then : $as_echo_n "(cached) " >&6 else @@ -14984,7 +15731,23 @@ if ac_fn_c_try_link "$LINENO"; then : fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext + LIBS="$ne_sl_save_LIBS -l$lib -liconv $NEON_LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int +main () +{ +$ne__code + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ne_cv_libsfor_bindtextdomain="-l$lib -liconv "; break +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext done LIBS=$ne_sl_save_LIBS fi @@ -15008,7 +15771,7 @@ LIBS="$LIBS $NEON_LIBS" for ac_func in bind_textdomain_codeset do : ac_fn_c_check_func "$LINENO" "bind_textdomain_codeset" "ac_cv_func_bind_textdomain_codeset" -if test "x$ac_cv_func_bind_textdomain_codeset" = x""yes; then : +if test "x$ac_cv_func_bind_textdomain_codeset" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_BIND_TEXTDOMAIN_CODESET 1 _ACEOF @@ -15122,7 +15885,7 @@ if test $NE_FLAG_SSL = yes; then set dummy openssl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_OPENSSL+set}" = set; then : +if ${ac_cv_path_OPENSSL+:} false; then : $as_echo_n "(cached) " >&6 else case $OPENSSL in @@ -15136,7 +15899,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_OPENSSL="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -15171,7 +15934,7 @@ $as_echo "$as_me: WARNING: no openssl binary in \$PATH: SSL tests disabled" >&2; set dummy certutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CERTUTIL+set}" = set; then : +if ${ac_cv_path_CERTUTIL+:} false; then : $as_echo_n "(cached) " >&6 else case $CERTUTIL in @@ -15185,7 +15948,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_CERTUTIL="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -15212,7 +15975,7 @@ fi set dummy pk12util; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PK12UTIL+set}" = set; then : +if ${ac_cv_path_PK12UTIL+:} false; then : $as_echo_n "(cached) " >&6 else case $PK12UTIL in @@ -15226,7 +15989,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PK12UTIL="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -15278,7 +16041,7 @@ fi set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : +if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in @@ -15292,7 +16055,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -15328,9 +16091,10 @@ fi # Pass the interface version on to libtool when linking libneon.la NEON_LINK_FLAGS="-version-info ${NE_LIBTOOL_VERSINFO}" # If any non-default ABI variations are used, add them to the SONAME: -if test "x${NE_LIBTOOL_RELEASE}y" != "xy"; then - NEON_LINK_FLAGS="${NEON_LINK_FLAGS} -release ${NE_LIBTOOL_RELEASE}" -fi +### disabled for backwards-compat with 0.27.x +#if test "x${NE_LIBTOOL_RELEASE}y" != "xy"; then +# NEON_LINK_FLAGS="${NEON_LINK_FLAGS} -release ${NE_LIBTOOL_RELEASE}" +#fi # Check whether --enable-ld-version-script was given. @@ -15344,15 +16108,37 @@ $as_echo_n "checking if LD -Wl,--version-script works... " >&6; } save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map" cat > conftest.map <conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + accepts_syntax_errors=yes +else + accepts_syntax_errors=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test "$accepts_syntax_errors" = no; then + cat > conftest.map <conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -15370,11 +16156,22 @@ else fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext + else + have_ld_version_script=no + fi rm -f conftest.map LDFLAGS="$save_LDFLAGS" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_ld_version_script" >&5 $as_echo "$have_ld_version_script" >&6; } fi + if test "$have_ld_version_script" = "yes"; then + HAVE_LD_VERSION_SCRIPT_TRUE= + HAVE_LD_VERSION_SCRIPT_FALSE='#' +else + HAVE_LD_VERSION_SCRIPT_TRUE='#' + HAVE_LD_VERSION_SCRIPT_FALSE= +fi + # If ld version scripts are supported, enable symbol versioning. # Otherwise, fall back to any libtool-supported symbol export @@ -15483,10 +16280,21 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then - test "x$cache_file" != "x/dev/null" && + if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} - cat confcache >$cache_file + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} @@ -15518,8 +16326,12 @@ LTLIBOBJS=$ac_ltlibobjs +if test -z "${HAVE_LD_VERSION_SCRIPT_TRUE}" && test -z "${HAVE_LD_VERSION_SCRIPT_FALSE}"; then + as_fn_error $? "conditional \"HAVE_LD_VERSION_SCRIPT\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi -: ${CONFIG_STATUS=./config.status} +: "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" @@ -15620,6 +16432,7 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. +as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -15815,16 +16628,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -15884,28 +16697,16 @@ else as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -15926,8 +16727,8 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by neon $as_me 0.29.6, which was -generated by GNU Autoconf 2.66. Invocation command line was +This file was extended by neon $as_me 0.30.0, which was +generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -15992,11 +16793,11 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -neon config.status 0.29.6 -configured by $0, generated by GNU Autoconf 2.66, +neon config.status 0.30.0 +configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -16013,11 +16814,16 @@ ac_need_defaults=: while test $# != 0 do case $1 in - --*=*) + --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; *) ac_option=$1 ac_optarg=$2 @@ -16039,6 +16845,7 @@ do $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; @@ -16080,7 +16887,7 @@ fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then - set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' @@ -16121,6 +16928,7 @@ pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' +PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' @@ -16141,13 +16949,20 @@ exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' +lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' +lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' +file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' +want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' +DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' +sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' +archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' @@ -16162,14 +16977,17 @@ lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$de lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' +nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' +lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' +MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' @@ -16193,7 +17011,6 @@ with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' -hardcode_libdir_flag_spec_ld='`$ECHO "$hardcode_libdir_flag_spec_ld" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' @@ -16202,12 +17019,12 @@ hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_q hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' -fix_srcfile_path='`$ECHO "$fix_srcfile_path" | $SED "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' +postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' @@ -16249,6 +17066,7 @@ _LTECHO_EOF' # Quote evaled strings. for var in SHELL \ ECHO \ +PATH_SEPARATOR \ SED \ GREP \ EGREP \ @@ -16262,8 +17080,13 @@ reload_flag \ OBJDUMP \ deplibs_check_method \ file_magic_cmd \ +file_magic_glob \ +want_nocaseglob \ +DLLTOOL \ +sharedlib_from_linklib_cmd \ AR \ AR_FLAGS \ +archiver_list_spec \ STRIP \ RANLIB \ CC \ @@ -16273,12 +17096,14 @@ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ +nm_file_list_spec \ lt_prog_compiler_no_builtin_flag \ -lt_prog_compiler_wl \ lt_prog_compiler_pic \ +lt_prog_compiler_wl \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ +MANIFEST_TOOL \ DSYMUTIL \ NMEDIT \ LIPO \ @@ -16292,9 +17117,7 @@ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ -hardcode_libdir_flag_spec_ld \ hardcode_libdir_separator \ -fix_srcfile_path \ exclude_expsyms \ include_expsyms \ file_list_spec \ @@ -16330,6 +17153,7 @@ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ +postlink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ @@ -16405,9 +17229,10 @@ fi # after its creation but before its name has been assigned to `$tmp'. $debug || { - tmp= + tmp= ac_tmp= trap 'exit_status=$? - { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } @@ -16415,12 +17240,13 @@ $debug || { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" + test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -16442,7 +17268,7 @@ else ac_cs_awk_cr=$ac_cr fi -echo 'BEGIN {' >"$tmp/subs1.awk" && +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF @@ -16470,7 +17296,7 @@ done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$tmp/subs1.awk" <<\\_ACAWK && +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h @@ -16518,7 +17344,7 @@ t delim rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK -cat >>"\$tmp/subs1.awk" <<_ACAWK && +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" @@ -16550,7 +17376,7 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat -fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF @@ -16584,7 +17410,7 @@ fi # test -n "$CONFIG_FILES" # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then -cat >"$tmp/defines.awk" <<\_ACAWK || +cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF @@ -16596,8 +17422,8 @@ _ACEOF # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do - ac_t=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_t"; then + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 @@ -16717,7 +17543,7 @@ do for ac_f do case $ac_f in - -) ac_f="$tmp/stdin";; + -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. @@ -16752,7 +17578,7 @@ $as_echo "$as_me: creating $ac_file" >&6;} esac case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin" \ + *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; @@ -16883,21 +17709,22 @@ s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t $ac_datarootdir_hack " -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} - rm -f "$tmp/stdin" + rm -f "$ac_tmp/stdin" case $ac_file in - -) cat "$tmp/out" && rm -f "$tmp/out";; - *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; @@ -16908,20 +17735,20 @@ which seems to be undefined. Please make sure it is defined" >&2;} if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" - } >"$tmp/config.h" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" - mv "$tmp/config.h" "$ac_file" \ + mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; @@ -16954,8 +17781,8 @@ $as_echo "$as_me: executing $ac_file commands" >&6;} # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010 Free Software Foundation, -# Inc. +# 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. @@ -17009,6 +17836,9 @@ SHELL=$lt_SHELL # An echo program that protects backslashes. ECHO=$lt_ECHO +# The PATH separator for the build system. +PATH_SEPARATOR=$lt_PATH_SEPARATOR + # The host system. host_alias=$host_alias host=$host @@ -17058,19 +17888,42 @@ SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP +# convert \$build file names to \$host format. +to_host_file_cmd=$lt_cv_to_host_file_cmd + +# convert \$build files to toolchain format. +to_tool_file_cmd=$lt_cv_to_tool_file_cmd + # An object symbol dumper. OBJDUMP=$lt_OBJDUMP # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method -# Command to use when deplibs_check_method == "file_magic". +# Command to use when deplibs_check_method = "file_magic". file_magic_cmd=$lt_file_magic_cmd +# How to find potential files when deplibs_check_method = "file_magic". +file_magic_glob=$lt_file_magic_glob + +# Find potential files using nocaseglob when deplibs_check_method = "file_magic". +want_nocaseglob=$lt_want_nocaseglob + +# DLL creation program. +DLLTOOL=$lt_DLLTOOL + +# Command to associate shared and link libraries. +sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd + # The archiver. AR=$lt_AR + +# Flags to create an archive. AR_FLAGS=$lt_AR_FLAGS +# How to feed a file listing to the archiver. +archiver_list_spec=$lt_archiver_list_spec + # A symbol stripping program. STRIP=$lt_STRIP @@ -17100,6 +17953,12 @@ global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix +# Specify filename containing input files for \$NM. +nm_file_list_spec=$lt_nm_file_list_spec + +# The root where to search for dependent libraries,and in which our libraries should be installed. +lt_sysroot=$lt_sysroot + # The name of the directory that contains temporary libtool files. objdir=$objdir @@ -17109,6 +17968,9 @@ MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks +# Manifest tool. +MANIFEST_TOOL=$lt_MANIFEST_TOOL + # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL @@ -17223,12 +18085,12 @@ with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag -# How to pass a linker flag through the compiler. -wl=$lt_lt_prog_compiler_wl - # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl + # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static @@ -17278,10 +18140,6 @@ no_undefined_flag=$lt_no_undefined_flag # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec -# If ld is used when linking, flag to hardcode \$libdir into a binary -# during linking. This must work even if \$libdir does not exist. -hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld - # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator @@ -17315,9 +18173,6 @@ inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs -# Fix the shell variable \$srcfile for the compiler. -fix_srcfile_path=$lt_fix_srcfile_path - # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols @@ -17333,6 +18188,9 @@ include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds +# Commands necessary for finishing linking programs. +postlink_cmds=$lt_postlink_cmds + # Specify filename containing input files. file_list_spec=$lt_file_list_spec @@ -17365,210 +18223,169 @@ ltmain="$ac_aux_dir/ltmain.sh" # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? - sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - case $xsi_shell in - yes) - cat << \_LT_EOF >> "$cfgfile" - -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac -} - -# func_basename file -func_basename () -{ - func_basename_result="${1##*/}" -} - -# func_dirname_and_basename file append nondir_replacement -# perform func_basename and func_dirname in a single function -# call: -# dirname: Compute the dirname of FILE. If nonempty, -# add APPEND to the result, otherwise set result -# to NONDIR_REPLACEMENT. -# value returned in "$func_dirname_result" -# basename: Compute filename of FILE. -# value retuned in "$func_basename_result" -# Implementation must be kept synchronized with func_dirname -# and func_basename. For efficiency, we do not delegate to -# those functions but instead duplicate the functionality here. -func_dirname_and_basename () -{ - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac - func_basename_result="${1##*/}" -} - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -func_stripname () -{ - # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are - # positional parameters, so assign one to ordinary parameter first. - func_stripname_result=${3} - func_stripname_result=${func_stripname_result#"${1}"} - func_stripname_result=${func_stripname_result%"${2}"} -} - -# func_opt_split -func_opt_split () -{ - func_opt_split_opt=${1%%=*} - func_opt_split_arg=${1#*=} -} - -# func_lo2o object -func_lo2o () -{ - case ${1} in - *.lo) func_lo2o_result=${1%.lo}.${objext} ;; - *) func_lo2o_result=${1} ;; - esac -} - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=${1%.*}.lo -} - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=$(( $* )) -} - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=${#1} -} - -_LT_EOF - ;; - *) # Bourne compatible functions. - cat << \_LT_EOF >> "$cfgfile" - -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - # Extract subdirectory from the argument. - func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" - fi -} - -# func_basename file -func_basename () -{ - func_basename_result=`$ECHO "${1}" | $SED "$basename"` -} - - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -# func_strip_suffix prefix name -func_stripname () -{ - case ${2} in - .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; - esac -} - -# sed scripts: -my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q' -my_sed_long_arg='1s/^-[^=]*=//' - -# func_opt_split -func_opt_split () -{ - func_opt_split_opt=`$ECHO "${1}" | $SED "$my_sed_long_opt"` - func_opt_split_arg=`$ECHO "${1}" | $SED "$my_sed_long_arg"` -} - -# func_lo2o object -func_lo2o () -{ - func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` -} - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` -} - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=`expr "$@"` -} - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` -} - -_LT_EOF -esac - -case $lt_shell_append in - yes) - cat << \_LT_EOF >> "$cfgfile" - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "$1+=\$2" -} -_LT_EOF - ;; - *) - cat << \_LT_EOF >> "$cfgfile" - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "$1=\$$1\$2" -} - -_LT_EOF - ;; - esac - - - sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - mv -f "$cfgfile" "$ofile" || + sed '$q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + if test x"$xsi_shell" = xyes; then + sed -e '/^func_dirname ()$/,/^} # func_dirname /c\ +func_dirname ()\ +{\ +\ case ${1} in\ +\ */*) func_dirname_result="${1%/*}${2}" ;;\ +\ * ) func_dirname_result="${3}" ;;\ +\ esac\ +} # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_basename ()$/,/^} # func_basename /c\ +func_basename ()\ +{\ +\ func_basename_result="${1##*/}"\ +} # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\ +func_dirname_and_basename ()\ +{\ +\ case ${1} in\ +\ */*) func_dirname_result="${1%/*}${2}" ;;\ +\ * ) func_dirname_result="${3}" ;;\ +\ esac\ +\ func_basename_result="${1##*/}"\ +} # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_stripname ()$/,/^} # func_stripname /c\ +func_stripname ()\ +{\ +\ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\ +\ # positional parameters, so assign one to ordinary parameter first.\ +\ func_stripname_result=${3}\ +\ func_stripname_result=${func_stripname_result#"${1}"}\ +\ func_stripname_result=${func_stripname_result%"${2}"}\ +} # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\ +func_split_long_opt ()\ +{\ +\ func_split_long_opt_name=${1%%=*}\ +\ func_split_long_opt_arg=${1#*=}\ +} # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\ +func_split_short_opt ()\ +{\ +\ func_split_short_opt_arg=${1#??}\ +\ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\ +} # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\ +func_lo2o ()\ +{\ +\ case ${1} in\ +\ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\ +\ *) func_lo2o_result=${1} ;;\ +\ esac\ +} # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_xform ()$/,/^} # func_xform /c\ +func_xform ()\ +{\ + func_xform_result=${1%.*}.lo\ +} # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_arith ()$/,/^} # func_arith /c\ +func_arith ()\ +{\ + func_arith_result=$(( $* ))\ +} # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_len ()$/,/^} # func_len /c\ +func_len ()\ +{\ + func_len_result=${#1}\ +} # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + +fi + +if test x"$lt_shell_append" = xyes; then + sed -e '/^func_append ()$/,/^} # func_append /c\ +func_append ()\ +{\ + eval "${1}+=\\${2}"\ +} # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\ +func_append_quoted ()\ +{\ +\ func_quote_for_eval "${2}"\ +\ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\ +} # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + # Save a `func_append' function call where possible by direct use of '+=' + sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") + test 0 -eq $? || _lt_function_replace_fail=: +else + # Save a `func_append' function call even when '+=' is not available + sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") + test 0 -eq $? || _lt_function_replace_fail=: +fi + +if test x"$_lt_function_replace_fail" = x":"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5 +$as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;} +fi + + + mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" @@ -17617,7 +18434,7 @@ fi # for VPATH builds: test -d test/common || mkdir test/common -{ $as_echo "$as_me:${as_lineno-$LINENO}: Configured to build neon 0.29.6: +{ $as_echo "$as_me:${as_lineno-$LINENO}: Configured to build neon 0.30.0: Install prefix: ${prefix} Compiler: ${CC} @@ -17626,7 +18443,7 @@ test -d test/common || mkdir test/common zlib support: ${ne_ZLIB_message} Build libraries: Shared=${enable_shared}, Static=${enable_static} " >&5 -$as_echo "$as_me: Configured to build neon 0.29.6: +$as_echo "$as_me: Configured to build neon 0.30.0: Install prefix: ${prefix} Compiler: ${CC} diff --git a/libs/neon/configure.in b/libs/neon/configure.in index 65985ced..37b14ec6 100644 --- a/libs/neon/configure.in +++ b/libs/neon/configure.in @@ -143,9 +143,10 @@ AC_SUBST(NEON_PC_LIBS) # Pass the interface version on to libtool when linking libneon.la NEON_LINK_FLAGS="-version-info ${NE_LIBTOOL_VERSINFO}" # If any non-default ABI variations are used, add them to the SONAME: -if test "x${NE_LIBTOOL_RELEASE}y" != "xy"; then - NEON_LINK_FLAGS="${NEON_LINK_FLAGS} -release ${NE_LIBTOOL_RELEASE}" -fi +### disabled for backwards-compat with 0.27.x +#if test "x${NE_LIBTOOL_RELEASE}y" != "xy"; then +# NEON_LINK_FLAGS="${NEON_LINK_FLAGS} -release ${NE_LIBTOOL_RELEASE}" +#fi gl_LD_VERSION_SCRIPT # If ld version scripts are supported, enable symbol versioning. diff --git a/libs/neon/doc/date.xml b/libs/neon/doc/date.xml index c6051579..13861d2c 100644 --- a/libs/neon/doc/date.xml +++ b/libs/neon/doc/date.xml @@ -1 +1 @@ - 3 May 2011 \ No newline at end of file +31 July 2013 \ No newline at end of file diff --git a/libs/neon/doc/html/api.html b/libs/neon/doc/html/api.html index 3ef1a3e7..aa5bb8c4 100644 --- a/libs/neon/doc/html/api.html +++ b/libs/neon/doc/html/api.html @@ -1,4 +1,4 @@ -Chapter 2. The neon C language interface

    Chapter 2. The neon C language interface

    The documentation for the neon interface is split between +Chapter 2. The neon C language interface

    Chapter 2. The neon C language interface

    The documentation for the neon interface is split between this chapter, which gives a broad introduction to the abstractions exposed by the library, and neon API reference, which gives a function-by-function breakdown of the interface.

    diff --git a/libs/neon/doc/html/biblio.html b/libs/neon/doc/html/biblio.html index 6f563c46..b336e00e 100644 --- a/libs/neon/doc/html/biblio.html +++ b/libs/neon/doc/html/biblio.html @@ -1,4 +1,4 @@ -Bibliography

    Bibliography

    [SSL-and-TLS] SSL and - TLS: Designing and Building Secure Systems. Eric Rescorla. 0-201-62598-3. Addison-Wesley. March 2001.

    [REC-XML-names] World Wide Web Consortium. Namespaces in XML. January 1999.

    [RFC2616] Hypertext Transfer - Protocol—HTTP/1.1. Roy Fielding, Jim Gettys, Jeff Mogul, Henrik Frystyk, Larry Masinter, Paul Leach, and Tim Berners-Lee. IETF. June 1999.

    [RFC2518] HTTP Extensions for Distributed Authoring—WEBDAV. Yaron Goland, Jim Whitehead, Asad Faizi, Steve Carter, and Del Jensen. IETF. February 1999.

    [RFC3280] Internet X.509 Public Key Infrastructure +Bibliography

    Bibliography

    [SSL-and-TLS] SSL and + TLS: Designing and Building Secure Systems. Eric Rescorla. 0-201-62598-3. Addison-Wesley. March 2001.

    [REC-XML-names] World Wide Web Consortium. Namespaces in XML. January 1999.

    [RFC2616] Hypertext Transfer + Protocol—HTTP/1.1. Roy Fielding, Jim Gettys, Jeff Mogul, Henrik Frystyk, Larry Masinter, Paul Leach, and Tim Berners-Lee. IETF. June 1999.

    [RFC2518] HTTP Extensions for Distributed Authoring—WEBDAV. Yaron Goland, Jim Whitehead, Asad Faizi, Steve Carter, and Del Jensen. IETF. February 1999.

    [RFC3280] Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile. Russel Housley, Warwick Ford, Tim Polk, and David Solo. IETF. April 2002.

    diff --git a/libs/neon/doc/html/compliance.html b/libs/neon/doc/html/compliance.html index 1694ad5e..94a33cae 100644 --- a/libs/neon/doc/html/compliance.html +++ b/libs/neon/doc/html/compliance.html @@ -1,12 +1,12 @@ -Standards compliance

    Standards compliance

    neon is intended to be compliant with the IETF and W3C +Standards compliance

    Standards compliance

    neon is intended to be compliant with the IETF and W3C standards which it implements, with a few exceptions due to practical necessity or interoperability issues. These - exceptions are documented in this section.

    RFC 2518, HTTP Extensions for Distributed Authoring—WebDAV

    neon is deliberately not compliant with section + exceptions are documented in this section.

    RFC 2518, HTTP Extensions for Distributed Authoring—WebDAV

    neon is deliberately not compliant with section 23.4.2, and treats property names as a (namespace-URI, name) pair. This is generally considered to be correct behaviour by the WebDAV working group, and is likely to formally adopted in a future - revision of the specification.

    RFC 2616, Hypertext Transfer Protocol—HTTP/1.1

    There is some confusion in this specification about the + revision of the specification.

    RFC 2616, Hypertext Transfer Protocol—HTTP/1.1

    There is some confusion in this specification about the use of the “identity†transfer-coding. neon ignores the Transfer-Encoding response header if it @@ -15,7 +15,7 @@ the header was not present. neon will give an error if a response includes a Transfer-Encoding header with a value other than “identity†or - “chunkedâ€.

    RFC 2617, HTTP Authentication: Basic and Digest Access Authentication

    neon is not strictly compliant with the quoting rules + “chunkedâ€.

    RFC 2617, HTTP Authentication: Basic and Digest Access Authentication

    neon is not strictly compliant with the quoting rules given in the grammar for the Authorization header. The grammar requires that the qop and algorithm parameters are not quoted, @@ -23,7 +23,7 @@ (Microsoft® IIS 5) rejects the request if these parameters are not quoted. neon sends these parameters with quotes—this is not known to cause any problems with - other server implementations.

    Namespaces in XML

    The neon XML parser interface will accept and parse + other server implementations.

    Namespaces in XML

    The neon XML parser interface will accept and parse without error some XML documents which are well-formed according to the XML specification but do not conform to the "Namespaces in XML" specification [REC-XML-names]. Specifically: the restrictions on diff --git a/libs/neon/doc/html/features.html b/libs/neon/doc/html/features.html index 132f613b..a5605f3f 100644 --- a/libs/neon/doc/html/features.html +++ b/libs/neon/doc/html/features.html @@ -1,4 +1,4 @@ -Feature list

    Feature list

    The major features of the neon library are as follows:

    • A high-level interface to common HTTP and WebDAV +Feature list

      Feature list

      The major features of the neon library are as follows:

      • A high-level interface to common HTTP and WebDAV methods. This allows you to easily dispatch a GET or a MKCOL request against a resource with a single function call.

      • A low-level interface for HTTP request handling; allowing you to implement requests using arbitrary methods diff --git a/libs/neon/doc/html/index.html b/libs/neon/doc/html/index.html index ae93f50a..9445b694 100644 --- a/libs/neon/doc/html/index.html +++ b/libs/neon/doc/html/index.html @@ -1,4 +1,4 @@ -neon HTTP/WebDAV client library

        neon HTTP/WebDAV client library

        This document is free documentation; you can redistribute +neon HTTP/WebDAV client library

        neon HTTP/WebDAV client library

        This document is free documentation; 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 @@ -10,5 +10,5 @@ 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., 675 Mass Ave, Cambridge, MA 02139, - USA.


        Table of Contents

        1. Introduction
        Feature list
        How to use neon from your application
        Standards compliance
        RFC 2518, HTTP Extensions for Distributed Authoring—WebDAV
        RFC 2616, Hypertext Transfer Protocol—HTTP/1.1
        RFC 2617, HTTP Authentication: Basic and Digest Access Authentication
        Namespaces in XML
        HTTP Client Security
        CPU or memory consumption attacks
        SSL/TLS connection security
        Control character insertion in error messages
        Attacks against authentication credentials
        2. The neon C language interface
        Parsing XML
        Introduction to SAX
        Stacked SAX handlers
        Maintaining state
        XML namespaces
        I. neon API reference
        neon — HTTP and WebDAV client library
        neon-config — script providing information about installed copy - of neon library
        ne_addr_resolve — functions to resolve hostnames to addresses
        ne_buffer — string buffer handling
        ne_buffer_append — append data to a string buffer
        ne_buffer_clear — clear, grow, or mark as altered a string buffer
        ne_buffer_create — create a string buffer
        ne_buffer_destroy — destroy a buffer object
        ne_get_error — error handling for HTTP sessions
        ne_get_status — retrieve HTTP response status for request
        ne_has_support — determine feature support status
        ne_i18n_init — functions to initialize internationalization support
        ne_iaddr_make — functions to manipulate network addresses
        ne_malloc — memory allocation wrappers
        ne_session_create — set up HTTP sessions
        ne_set_session_flag — set and retrieve session flags
        ne_request_create — low-level HTTP request handling
        ne_add_request_header — add headers to a request
        ne_get_response_header — functions to access response headers
        ne_set_useragent — common properties for HTTP sessions
        ne_set_request_flag — set and retrieve per-request flags
        ne_set_request_body_buffer — include a message body with a request
        ne_set_server_auth — register authentication callbacks
        ne_shave — trim whitespace from a string
        ne_sock_init — perform library initialization
        ne_ssl_cert_identity — functions to access certificate properties
        ne_ssl_cert_cmp — functions to operate on certificate objects
        ne_ssl_cert_read — functions to read or write certificates to and from files or strings
        ne_ssl_dname — SSL distinguished name handling
        ne_ssl_trust_cert — functions to indicate that certificates are trusted
        ne_ssl_set_verify — register an SSL certificate verification callback
        ne_ssl_client_cert — SSL client certificate handling
        ne_status — HTTP status structure
        ne_token — string tokenizers
        ne_version_match — library versioning
        ne_xml_create — create and destroy an XML parser
        Bibliography

        List of Examples

        2.1. An example XML document
        + USA.


        Table of Contents

        1. Introduction
        Feature list
        How to use neon from your application
        Standards compliance
        RFC 2518, HTTP Extensions for Distributed Authoring—WebDAV
        RFC 2616, Hypertext Transfer Protocol—HTTP/1.1
        RFC 2617, HTTP Authentication: Basic and Digest Access Authentication
        Namespaces in XML
        HTTP Client Security
        CPU or memory consumption attacks
        SSL/TLS connection security
        Control character insertion in error messages
        Attacks against authentication credentials
        2. The neon C language interface
        Parsing XML
        Introduction to SAX
        Stacked SAX handlers
        Maintaining state
        XML namespaces
        I. neon API reference
        neon — HTTP and WebDAV client library
        neon-config — script providing information about installed copy + of neon library
        ne_addr_resolve — functions to resolve hostnames to addresses
        ne_buffer — string buffer handling
        ne_buffer_append — append data to a string buffer
        ne_buffer_clear — clear, grow, or mark as altered a string buffer
        ne_buffer_create — create a string buffer
        ne_buffer_destroy — destroy a buffer object
        ne_get_error — error handling for HTTP sessions
        ne_get_status — retrieve HTTP response status for request
        ne_has_support — determine feature support status
        ne_i18n_init — functions to initialize internationalization support
        ne_iaddr_make — functions to manipulate network addresses
        ne_malloc — memory allocation wrappers
        ne_session_create — set up HTTP sessions
        ne_session_proxy — configure proxy servers
        ne_set_session_flag — set and retrieve session flags
        ne_request_create — low-level HTTP request handling
        ne_add_request_header — add headers to a request
        ne_get_response_header — functions to access response headers
        ne_set_useragent — common properties for HTTP sessions
        ne_set_request_flag — set and retrieve per-request flags
        ne_set_request_body_buffer — include a message body with a request
        ne_set_server_auth — register authentication callbacks
        ne_shave — trim whitespace from a string
        ne_sock_init — perform library initialization
        ne_ssl_cert_identity — functions to access certificate properties
        ne_ssl_cert_cmp — functions to operate on certificate objects
        ne_ssl_cert_read — functions to read or write certificates to and from files or strings
        ne_ssl_dname — SSL distinguished name handling
        ne_ssl_trust_cert — functions to indicate that certificates are trusted
        ne_ssl_set_verify — register an SSL certificate verification callback
        ne_ssl_client_cert — SSL client certificate handling
        ne_status — HTTP status structure
        ne_token — string tokenizers
        ne_version_match — library versioning
        ne_xml_create — create and destroy an XML parser
        Bibliography

        List of Examples

        2.1. An example XML document
        diff --git a/libs/neon/doc/html/intro.html b/libs/neon/doc/html/intro.html index cbda5fc4..a2a1901e 100644 --- a/libs/neon/doc/html/intro.html +++ b/libs/neon/doc/html/intro.html @@ -1,4 +1,4 @@ -Chapter 1. Introduction

        Chapter 1. Introduction

        This chapter provides an introduction to neon, giving an +Chapter 1. Introduction

        Chapter 1. Introduction

        This chapter provides an introduction to neon, giving an overview of the range of features offered, and some general guidelines for using the neon API.

        neon aims to provide a modern, flexible, and simple API in the C programming language for implementing HTTP and WebDAV diff --git a/libs/neon/doc/html/manual.proc b/libs/neon/doc/html/manual.proc new file mode 100644 index 00000000..e69de29b diff --git a/libs/neon/doc/html/ref.html b/libs/neon/doc/html/ref.html index 37245e02..253b00d9 100644 --- a/libs/neon/doc/html/ref.html +++ b/libs/neon/doc/html/ref.html @@ -1,2 +1,2 @@ -neon API reference

        neon API reference


        Table of Contents

        neon — HTTP and WebDAV client library
        neon-config — script providing information about installed copy - of neon library
        ne_addr_resolve — functions to resolve hostnames to addresses
        ne_buffer — string buffer handling
        ne_buffer_append — append data to a string buffer
        ne_buffer_clear — clear, grow, or mark as altered a string buffer
        ne_buffer_create — create a string buffer
        ne_buffer_destroy — destroy a buffer object
        ne_get_error — error handling for HTTP sessions
        ne_get_status — retrieve HTTP response status for request
        ne_has_support — determine feature support status
        ne_i18n_init — functions to initialize internationalization support
        ne_iaddr_make — functions to manipulate network addresses
        ne_malloc — memory allocation wrappers
        ne_session_create — set up HTTP sessions
        ne_set_session_flag — set and retrieve session flags
        ne_request_create — low-level HTTP request handling
        ne_add_request_header — add headers to a request
        ne_get_response_header — functions to access response headers
        ne_set_useragent — common properties for HTTP sessions
        ne_set_request_flag — set and retrieve per-request flags
        ne_set_request_body_buffer — include a message body with a request
        ne_set_server_auth — register authentication callbacks
        ne_shave — trim whitespace from a string
        ne_sock_init — perform library initialization
        ne_ssl_cert_identity — functions to access certificate properties
        ne_ssl_cert_cmp — functions to operate on certificate objects
        ne_ssl_cert_read — functions to read or write certificates to and from files or strings
        ne_ssl_dname — SSL distinguished name handling
        ne_ssl_trust_cert — functions to indicate that certificates are trusted
        ne_ssl_set_verify — register an SSL certificate verification callback
        ne_ssl_client_cert — SSL client certificate handling
        ne_status — HTTP status structure
        ne_token — string tokenizers
        ne_version_match — library versioning
        ne_xml_create — create and destroy an XML parser
        +neon API reference

        neon API reference


        Table of Contents

        neon — HTTP and WebDAV client library
        neon-config — script providing information about installed copy + of neon library
        ne_addr_resolve — functions to resolve hostnames to addresses
        ne_buffer — string buffer handling
        ne_buffer_append — append data to a string buffer
        ne_buffer_clear — clear, grow, or mark as altered a string buffer
        ne_buffer_create — create a string buffer
        ne_buffer_destroy — destroy a buffer object
        ne_get_error — error handling for HTTP sessions
        ne_get_status — retrieve HTTP response status for request
        ne_has_support — determine feature support status
        ne_i18n_init — functions to initialize internationalization support
        ne_iaddr_make — functions to manipulate network addresses
        ne_malloc — memory allocation wrappers
        ne_session_create — set up HTTP sessions
        ne_session_proxy — configure proxy servers
        ne_set_session_flag — set and retrieve session flags
        ne_request_create — low-level HTTP request handling
        ne_add_request_header — add headers to a request
        ne_get_response_header — functions to access response headers
        ne_set_useragent — common properties for HTTP sessions
        ne_set_request_flag — set and retrieve per-request flags
        ne_set_request_body_buffer — include a message body with a request
        ne_set_server_auth — register authentication callbacks
        ne_shave — trim whitespace from a string
        ne_sock_init — perform library initialization
        ne_ssl_cert_identity — functions to access certificate properties
        ne_ssl_cert_cmp — functions to operate on certificate objects
        ne_ssl_cert_read — functions to read or write certificates to and from files or strings
        ne_ssl_dname — SSL distinguished name handling
        ne_ssl_trust_cert — functions to indicate that certificates are trusted
        ne_ssl_set_verify — register an SSL certificate verification callback
        ne_ssl_client_cert — SSL client certificate handling
        ne_status — HTTP status structure
        ne_token — string tokenizers
        ne_version_match — library versioning
        ne_xml_create — create and destroy an XML parser
        diff --git a/libs/neon/doc/html/refalloc.html b/libs/neon/doc/html/refalloc.html index 656d4e01..96ab4abd 100644 --- a/libs/neon/doc/html/refalloc.html +++ b/libs/neon/doc/html/refalloc.html @@ -1,4 +1,4 @@ -ne_malloc

        Name

        ne_malloc, ne_calloc, ne_realloc, ne_strdup, ne_strndup, ne_oom_callback — memory allocation wrappers

        Synopsis

        #include <ne_alloc.h>
        void *ne_malloc(size_t size);
         
        void *ne_calloc(size_t size);
         
        void *ne_realloc(void *size,
         size_t len);
         
        char *ne_strdup(const char *s);
         
        char *ne_strndup(const char *s,
         size_t size);
         
        void ne_oom_callback(void (*callback)(void));
         

        Description

        The functions ne_malloc, +ne_malloc

        Name

        ne_malloc, ne_calloc, ne_realloc, ne_strdup, ne_strndup, ne_oom_callback — memory allocation wrappers

        Synopsis

        #include <ne_alloc.h>
        void *ne_malloc(size_t size);
         
        void *ne_calloc(size_t size);
         
        void *ne_realloc(void *size,
         size_t len);
         
        char *ne_strdup(const char *s);
         
        char *ne_strndup(const char *s,
         size_t size);
         
        void ne_oom_callback(void (*callback)(void));
         

        Description

        The functions ne_malloc, ne_calloc, ne_realloc, ne_strdup and ne_strdnup provide wrappers for the equivalent functions in the standard C @@ -6,7 +6,7 @@ library equivalent returns NULL when no memory is available, an optional callback will be called, and the library will then call abort().

        ne_oom_callback registers a callback -which will be invoked if an out of memory error is detected.

        Notes

        If the operating system uses optimistic memory +which will be invoked if an out of memory error is detected.

        Notes

        If the operating system uses optimistic memory allocation, the C library memory allocation routines will not return NULL, so it is not possible to gracefully handle memory allocation failures.

        diff --git a/libs/neon/doc/html/refauth.html b/libs/neon/doc/html/refauth.html index ae341167..aecd6abb 100644 --- a/libs/neon/doc/html/refauth.html +++ b/libs/neon/doc/html/refauth.html @@ -1,4 +1,4 @@ -ne_set_server_auth

        Name

        ne_set_server_auth, ne_set_proxy_auth, ne_forget_auth — register authentication callbacks

        Synopsis

        #include <ne_auth.h>
        typedef int (*ne_auth_creds)(void *userdata,
         const char *realm,
         int attempt,
         char *username,
         char *password);
         
        void ne_set_server_auth(ne_session *session,
         ne_auth_creds callback,
         void *userdata);
         
        void ne_set_proxy_auth(ne_session *session,
         ne_auth_creds callback,
         void *userdata);
         
        void ne_forget_auth(ne_session *session);
         

        Description

        The ne_auth_creds function type defines a +ne_set_server_auth

        Name

        ne_set_server_auth, ne_set_proxy_auth, ne_forget_auth — register authentication callbacks

        Synopsis

        #include <ne_auth.h>
        typedef int (*ne_auth_creds)(void *userdata,
         const char *realm,
         int attempt,
         char *username,
         char *password);
         
        void ne_set_server_auth(ne_session *session,
         ne_auth_creds callback,
         void *userdata);
         
        void ne_set_proxy_auth(ne_session *session,
         ne_auth_creds callback,
         void *userdata);
         
        void ne_forget_auth(ne_session *session);
         

        Description

        The ne_auth_creds function type defines a callback which is invoked when a server or proxy server requires user authentication for a particular request. The realm string is supplied by the server. The attempt is a counter giving the @@ -9,13 +9,13 @@ username and password buffers must contain NUL-terminated strings. The NE_ABUFSIZ constant gives the size of these -buffers.

        Tip

        If you only wish to allow the user one attempt to enter +buffers.

        Tip

        If you only wish to allow the user one attempt to enter credentials, use the value of the attempt parameter as the return value of the callback.

        To abort the request, the callback should return a non-zero value; in which case the contents of the username and password buffers are ignored.

        The ne_forget_auth function can be -used to discard the cached authentication credentials.

        Examples

        +used to discard the cached authentication credentials.

        Examples

         /* Function which prompts for a line of user input: */
         extern char *prompt_for(const char *prompt);
         
        diff --git a/libs/neon/doc/html/refbuf.html b/libs/neon/doc/html/refbuf.html
        index 568c3597..1dc33535 100644
        --- a/libs/neon/doc/html/refbuf.html
        +++ b/libs/neon/doc/html/refbuf.html
        @@ -1,10 +1,10 @@
        -ne_buffer

        Name

        ne_buffer — string buffer handling

        Synopsis

        #include <ne_string.h>
        +ne_buffer

        Name

        ne_buffer — string buffer handling

        Synopsis

        #include <ne_string.h>
         
         typedef struct {
             char *data;
             size_t used;
             size_t length;
        -} ne_buffer;

        Description

        The ne_buffer type represents an expandable +} ne_buffer;

        Description

        The ne_buffer type represents an expandable memory buffer for holding NUL-terminated strings. The data field points to the beginnning of the string, the length of which is given by the diff --git a/libs/neon/doc/html/refbufapp.html b/libs/neon/doc/html/refbufapp.html index ab503d4e..4c48c6a8 100644 --- a/libs/neon/doc/html/refbufapp.html +++ b/libs/neon/doc/html/refbufapp.html @@ -1,4 +1,4 @@ -ne_buffer_append

        Name

        ne_buffer_append, ne_buffer_zappend, ne_buffer_concat — append data to a string buffer

        Synopsis

        #include <ne_string.h>
        void ne_buffer_append(ne_buffer *buf,
         const char *string,
         size_t len);
         
        void ne_buffer_zappend(ne_buffer *buf,
         const char *string);
         
        void ne_buffer_concat(ne_buffer *buf,
         const char *str,
         ...);
         

        Description

        The ne_buffer_append and +ne_buffer_append

        Name

        ne_buffer_append, ne_buffer_zappend, ne_buffer_concat — append data to a string buffer

        Synopsis

        #include <ne_string.h>
        void ne_buffer_append(ne_buffer *buf,
         const char *string,
         size_t len);
         
        void ne_buffer_zappend(ne_buffer *buf,
         const char *string);
         
        void ne_buffer_concat(ne_buffer *buf,
         const char *str,
         ...);
         

        Description

        The ne_buffer_append and ne_buffer_zappend functions append a string to the end of a buffer; extending the buffer as necessary. The len passed to @@ -13,10 +13,10 @@ argument to mark the end of the list. The strings (including str) are appended to the buffer in the order given. None of the strings passed to -ne_buffer_concat are modified.

        Examples

        The following code will output "Hello, world. +ne_buffer_concat are modified.

        Examples

        The following code will output "Hello, world. And goodbye.".

        ne_buffer *buf = ne_buffer_create();
         ne_buffer_zappend(buf, "Hello");
         ne_buffer_concat(buf, ", world. ", "And ", "goodbye.", NULL);
         puts(buf->data);
        -ne_buffer_destroy(buf);

        See also

        ne_buffer, ne_buffer_create, +ne_buffer_destroy(buf);

        diff --git a/libs/neon/doc/html/refbufcr.html b/libs/neon/doc/html/refbufcr.html index 1626895f..16c449ec 100644 --- a/libs/neon/doc/html/refbufcr.html +++ b/libs/neon/doc/html/refbufcr.html @@ -1,7 +1,7 @@ -ne_buffer_create

        Name

        ne_buffer_create, ne_buffer_ncreate — create a string buffer

        Synopsis

        #include <ne_alloc.h>
        ne_buffer *ne_buffer_create(void); 
         
        ne_buffer *ne_buffer_ncreate(size_t size);
         

        Description

        ne_buffer_create creates a new +ne_buffer_create

        Name

        ne_buffer_create, ne_buffer_ncreate — create a string buffer

        Synopsis

        #include <ne_alloc.h>
        ne_buffer *ne_buffer_create(void); 
         
        ne_buffer *ne_buffer_ncreate(size_t size);
         

        Description

        ne_buffer_create creates a new buffer object, with an implementation-defined initial size. ne_buffer_ncreate creates an ne_buffer where the minimum initial size is given in the size parameter. The buffer created will -contain the empty string ("").

        Return value

        Both functions return a pointer to a new buffer object, -and never NULL.

        See also

        ne_buffer

        +contain the empty string ("").

        Return value

        Both functions return a pointer to a new buffer object, +and never NULL.

        See also

        ne_buffer

        diff --git a/libs/neon/doc/html/refbufdest.html b/libs/neon/doc/html/refbufdest.html index 71d2771c..b02f4c7f 100644 --- a/libs/neon/doc/html/refbufdest.html +++ b/libs/neon/doc/html/refbufdest.html @@ -1,10 +1,10 @@ -ne_buffer_destroy

        Name

        ne_buffer_destroy, ne_buffer_finish — destroy a buffer object

        Synopsis

        #include <ne_string.h>
        void ne_buffer_destroy(ne_buffer *buf);
         
        char *ne_buffer_finish(ne_buffer *buf);
         

        Description

        ne_buffer_destroy frees all memory +ne_buffer_destroy

        Name

        ne_buffer_destroy, ne_buffer_finish — destroy a buffer object

        Synopsis

        #include <ne_string.h>
        void ne_buffer_destroy(ne_buffer *buf);
         
        char *ne_buffer_finish(ne_buffer *buf);
         

        Description

        ne_buffer_destroy frees all memory associated with the buffer. ne_buffer_finish frees the buffer structure, but not the actual string stored in the buffer, which is returned and must be free()d by the caller.

        Any use of the buffer object after calling either of these -functions gives undefined behaviour.

        Return value

        ne_buffer_finish returns the -malloc-allocated string stored in the buffer.

        Examples

        An example use of ne_buffer_finish; +functions gives undefined behaviour.

        Return value

        ne_buffer_finish returns the +malloc-allocated string stored in the buffer.

        Examples

        An example use of ne_buffer_finish; the duplicate function returns a string made up of n copies of str:

        static char *duplicate(int n, const char *str)
         {
        @@ -13,5 +13,5 @@
             ne_buffer_zappend(buf, str);
           }
           return ne_buffer_finish(buf);
        -}
        diff --git a/libs/neon/doc/html/refbufutil.html b/libs/neon/doc/html/refbufutil.html index 4f0bcf21..78be8d08 100644 --- a/libs/neon/doc/html/refbufutil.html +++ b/libs/neon/doc/html/refbufutil.html @@ -1,4 +1,4 @@ -ne_buffer_clear

        Name

        ne_buffer_clear, ne_buffer_grow, ne_buffer_altered — clear, grow, or mark as altered a string buffer

        Synopsis

        #include <ne_string.h>
        void ne_buffer_clear(ne_buffer *buf);
         
        void ne_buffer_altered(ne_buffer *buf);
         
        void ne_buffer_grow(ne_buffer *buf,
         size_t size);
         

        Description

        The ne_buffer_clear function sets +ne_buffer_clear

        Name

        ne_buffer_clear, ne_buffer_grow, ne_buffer_altered — clear, grow, or mark as altered a string buffer

        Synopsis

        #include <ne_string.h>
        void ne_buffer_clear(ne_buffer *buf);
         
        void ne_buffer_altered(ne_buffer *buf);
         
        void ne_buffer_grow(ne_buffer *buf,
         size_t size);
         

        Description

        The ne_buffer_clear function sets the string stored in buf to be the empty string ("").

        The ne_buffer_altered function must be used after the string stored in the buffer diff --git a/libs/neon/doc/html/refcert.html b/libs/neon/doc/html/refcert.html index 5290e13d..85d7472c 100644 --- a/libs/neon/doc/html/refcert.html +++ b/libs/neon/doc/html/refcert.html @@ -1,4 +1,4 @@ -ne_ssl_cert_identity

        Name

        ne_ssl_cert_identity, ne_ssl_cert_signedby, ne_ssl_cert_issuer, ne_ssl_cert_subject — functions to access certificate properties

        Synopsis

        #include <ne_ssl.h>
        const char *ne_ssl_cert_identity(const ne_ssl_certificate *cert);
         
        const ne_ssl_certificate *ne_ssl_cert_signedby(const ne_ssl_certificate *cert);
         
        const ne_ssl_dname *ne_ssl_cert_subject(const ne_ssl_certificate *cert);
         
        const ne_ssl_dname *ne_ssl_cert_issuer(const ne_ssl_certificate *cert);
         

        Description

        The function ne_ssl_cert_identity +ne_ssl_cert_identity

        Name

        ne_ssl_cert_identity, ne_ssl_cert_signedby, ne_ssl_cert_issuer, ne_ssl_cert_subject — functions to access certificate properties

        Synopsis

        #include <ne_ssl.h>
        const char *ne_ssl_cert_identity(const ne_ssl_certificate *cert);
         
        const ne_ssl_certificate *ne_ssl_cert_signedby(const ne_ssl_certificate *cert);
         
        const ne_ssl_dname *ne_ssl_cert_subject(const ne_ssl_certificate *cert);
         
        const ne_ssl_dname *ne_ssl_cert_issuer(const ne_ssl_certificate *cert);
         

        Description

        The function ne_ssl_cert_identity retrieves the “identity†of a certificate; for an SSL server certificate, this will be the hostname for which the certificate was issued. In PKI parlance, the identity is the @@ -10,12 +10,12 @@ ne_ssl_cert_signedby can be used to find the certificate which signed a particular certificate. For a self-signed certificate or a certificate for which the full chain - is not available, this function will return NULL.

        Return value

        ne_ssl_cert_issuer and + is not available, this function will return NULL.

        Return value

        ne_ssl_cert_issuer and ne_ssl_cert_subject are guaranteed to never return NULL. ne_ssl_cert_identity may return NULL if the certificate has no specific “identityâ€. ne_ssl_cert_signedby - may return NULL as covered above.

        Examples

        The following function could be used to display information + may return NULL as covered above.

        Examples

        The following function could be used to display information about a given certificate:

        void dump_cert(const ne_ssl_certificate *cert) {
           const char *id = ne_ssl_cert_identity(cert);
           char *dn;
        @@ -30,4 +30,4 @@
           dn = ne_ssl_readable_dname(ne_ssl_cert_issuer(cert));
           printf("Issuer: %s\n", dn);
           free(dn);
        -}
        +}
        diff --git a/libs/neon/doc/html/refclicert.html b/libs/neon/doc/html/refclicert.html index 41e05afd..f7535d5f 100644 --- a/libs/neon/doc/html/refclicert.html +++ b/libs/neon/doc/html/refclicert.html @@ -1,4 +1,4 @@ -ne_ssl_client_cert

        Name

        ne_ssl_clicert_read, ne_ssl_clicert_name, ne_ssl_clicert_encrypted, ne_ssl_clicert_decrypt, ne_ssl_clicert_owner, ne_ssl_clicert_free — SSL client certificate handling

        Synopsis

        #include <ne_ssl.h>
        ne_ssl_client_cert *ne_ssl_clicert_read(const char *filename);
         
        const char *ne_ssl_clicert_name(const ne_ssl_client_cert *ccert);
         
        int ne_ssl_clicert_encrypted(const ne_ssl_client_cert *ccert);
         
        int ne_ssl_clicert_decrypt(ne_ssl_client_cert *ccert,
         const char *password);
         
        const ne_ssl_certificate *ne_ssl_clicert_owner(const ne_ssl_client_cert *ccert);
         
        void ne_ssl_clicert_free(ne_ssl_client_cert *ccert);
         

        Description

        The ne_ssl_clicert_read function reads +ne_ssl_client_cert

        Name

        ne_ssl_clicert_read, ne_ssl_clicert_name, ne_ssl_clicert_encrypted, ne_ssl_clicert_decrypt, ne_ssl_clicert_owner, ne_ssl_clicert_free — SSL client certificate handling

        Synopsis

        #include <ne_ssl.h>
        ne_ssl_client_cert *ne_ssl_clicert_read(const char *filename);
         
        const char *ne_ssl_clicert_name(const ne_ssl_client_cert *ccert);
         
        int ne_ssl_clicert_encrypted(const ne_ssl_client_cert *ccert);
         
        int ne_ssl_clicert_decrypt(ne_ssl_client_cert *ccert,
         const char *password);
         
        const ne_ssl_certificate *ne_ssl_clicert_owner(const ne_ssl_client_cert *ccert);
         
        void ne_ssl_clicert_free(ne_ssl_client_cert *ccert);
         

        Description

        The ne_ssl_clicert_read function reads a client certificate from a PKCS#12-formatted file, and returns an ne_ssl_client_cert object. If the client @@ -29,14 +29,14 @@ only be called if the client certificate is in the decrypted state.

        When the client certificate is no longer needed, the ne_ssl_clicert_free function should be used - to destroy the object.

        Return value

        ne_ssl_clicert_read returns a client + to destroy the object.

        Return value

        ne_ssl_clicert_read returns a client certificate object, or NULL if the file could not be read. ne_ssl_clicert_encrypted returns zero if the object is in the decrypted state, or non-zero if it is in the encrypted state. ne_ssl_clicert_name returns a NUL-terminated friendly name string, or NULL. ne_ssl_clicert_owner returns a certificate - object.

        Examples

        The following code reads a client certificate and decrypts + object.

        Examples

        The following code reads a client certificate and decrypts it if necessary, then loads it into an HTTP session.

        ne_ssl_client_cert *ccert;
         
         ccert = ne_ssl_clicert_read("/path/to/client.p12");
        @@ -52,4 +52,4 @@
         }
         
         ne_ssl_set_clicert(sess, ccert);
        -
        +
        diff --git a/libs/neon/doc/html/refconfig.html b/libs/neon/doc/html/refconfig.html index 10171fe2..ef7ed178 100644 --- a/libs/neon/doc/html/refconfig.html +++ b/libs/neon/doc/html/refconfig.html @@ -1,11 +1,11 @@ -neon-config

        Name

        neon-config — script providing information about installed copy - of neon library

        Synopsis

        neon-config [--prefix] [[--cflags] | [--libs] | [--la-file] | [--support feature] | [--help] | [--version]]

        Description

        The neon-config script provides +neon-config

        Name

        neon-config — script providing information about installed copy + of neon library

        Synopsis

        neon-config [--prefix] [[--cflags] | [--libs] | [--la-file] | [--support feature] | [--help] | [--version]]

        Description

        The neon-config script provides information about an installed copy of the neon library. The --cflags and --libs options instruct how to compile and link an application against the library; the --version and --support options can help determine whether the library meets the applications -requirements.

        Options

        --cflags

        Print the flags which should be passed to +requirements.

        Options

        --cflags

        Print the flags which should be passed to the C compiler when compiling object files, when the object files use neon header files.

        --libs

        Print the flags which should be passed to the linker when linking an application which uses the neon @@ -17,7 +17,7 @@ installation prefix of the library.

        --support feature

        The script exits with success if feature is supported by the library.

        --help

        Print help message; includes list of known - features and whether they are supported or not.

        Example

        Below is a Makefile fragment which could be used to + features and whether they are supported or not.

        Example

        Below is a Makefile fragment which could be used to build an application against an installed neon library, when the neon-config script can be found in $PATH.

        CFLAGS = `neon-config --cflags`
        diff --git a/libs/neon/doc/html/referr.html b/libs/neon/doc/html/referr.html
        index da86b007..33c13c23 100644
        --- a/libs/neon/doc/html/referr.html
        +++ b/libs/neon/doc/html/referr.html
        @@ -1,4 +1,4 @@
        -ne_get_error

        Name

        ne_get_error, ne_set_error — error handling for HTTP sessions

        Synopsis

        #include <ne_session.h>
        const char *ne_get_error(ne_sesssion *session);
         
        void ne_set_error(ne_sesssion *session,
         const char *format,
         ...);
         

        Description

        The session error string is used to store any +ne_get_error

        Name

        ne_get_error, ne_set_error — error handling for HTTP sessions

        Synopsis

        #include <ne_session.h>
        const char *ne_get_error(ne_sesssion *session);
         
        void ne_set_error(ne_sesssion *session,
         const char *format,
         ...);
         

        Description

        The session error string is used to store any human-readable error information associated with any errors which occur whilst using the HTTP session.

        The ne_get_error function returns the current session error string. This string persists only @@ -8,10 +8,10 @@ translated into the user's current locale.

        The ne_set_error function can be used to set a new session error string, using a printf-style format string - interface.

        Return value

        ne_set_error returns a constant + interface.

        Return value

        ne_set_error returns a constant NUL-terminated string. In the default English locale, the returned string will not have a - terminating “.†period character.

        Examples

        Retrieve the current error string:

        ne_session *sess = ne_session_create(...);
        +        terminating “.†period character.

        Examples

        Retrieve the current error string:

        ne_session *sess = ne_session_create(...);
         ...
         printf("Error was: %s\n", ne_get_error(sess));

        Set a new error string:

        ne_session *sess = ne_session_create(...);
         ...
        diff --git a/libs/neon/doc/html/reffeat.html b/libs/neon/doc/html/reffeat.html
        index 6e11669c..8f118c7c 100644
        --- a/libs/neon/doc/html/reffeat.html
        +++ b/libs/neon/doc/html/reffeat.html
        @@ -1,10 +1,10 @@
        -ne_has_support

        Name

        ne_has_support — determine feature support status

        Synopsis

        #include <ne_utils.h>
        int ne_has_support(int feature);
         

        Description

        The ne_has_support function can be used +ne_has_support

        Name

        ne_has_support — determine feature support status

        Synopsis

        #include <ne_utils.h>
        int ne_has_support(int feature);
         

        Description

        The ne_has_support function can be used to determine whether a particular optional feature, given by the feature code feature, is supported. The following feature codes are available: -

        NE_FEATURE_SSL

        Indicates support for SSL/TLS

        NE_FEATURE_ZLIB

        Indicates support for compressed responses

        NE_FEATURE_IPV6

        Indicates support for IPv6

        NE_FEATURE_LFS

        Indicates support for large files

        NE_FEATURE_SOCKS

        Indicates support for SOCKSv5

        NE_FEATURE_TS_SSL

        Indicates support for thread-safe SSL +

        NE_FEATURE_SSL

        Indicates support for SSL/TLS

        NE_FEATURE_ZLIB

        Indicates support for compressed responses

        NE_FEATURE_IPV6

        Indicates support for IPv6

        NE_FEATURE_LFS

        Indicates support for large files

        NE_FEATURE_SOCKS

        Indicates support for SOCKSv5

        NE_FEATURE_TS_SSL

        Indicates support for thread-safe SSL initialization — see ne_sock_init

        -

        Return value

        ne_has_support returns non-zero if - the given feature is supported, or zero otherwise.

        +

        Return value

        ne_has_support returns non-zero if + the given feature is supported, or zero otherwise.

        diff --git a/libs/neon/doc/html/refgetst.html b/libs/neon/doc/html/refgetst.html index 76f3c831..6f1c955b 100644 --- a/libs/neon/doc/html/refgetst.html +++ b/libs/neon/doc/html/refgetst.html @@ -1,10 +1,10 @@ -ne_get_status

        Name

        ne_get_status — retrieve HTTP response status for request

        Synopsis

        #include <ne_request.h>
        const ne_status *ne_get_status(const ne_request *request);
         

        Description

        The ne_get_status function returns +ne_get_status

        Name

        ne_get_status — retrieve HTTP response status for request

        Synopsis

        #include <ne_request.h>
        const ne_status *ne_get_status(const ne_request *request);
         

        Description

        The ne_get_status function returns a pointer to the HTTP status object giving the result of a request. The object returned only becomes valid once the request has been successfully dispatched (the return value of ne_request_dispatch or ne_begin_request was zero). The object remains -valid until the associated request object is destroyed.

        Example

        Display the response status code of applying the +valid until the associated request object is destroyed.

        Example

        Display the response status code of applying the HEAD method to some resource.

        ne_request *req = ne_request_create(sess, "HEAD", "/foo/bar");
         if (ne_request_dispatch(req))
            /* handle errors... */
        diff --git a/libs/neon/doc/html/refi18n.html b/libs/neon/doc/html/refi18n.html
        index fe7bb268..691828f2 100644
        --- a/libs/neon/doc/html/refi18n.html
        +++ b/libs/neon/doc/html/refi18n.html
        @@ -1,4 +1,4 @@
        -ne_i18n_init

        Name

        ne_i18n_init — functions to initialize internationalization support

        Synopsis

        #include <ne_i18n.h>
        void ne_i18n_init(const char *encoding);
         

        Description

        The ne_i18n_init function can be used +ne_i18n_init

        Name

        ne_i18n_init — functions to initialize internationalization support

        Synopsis

        #include <ne_i18n.h>
        void ne_i18n_init(const char *encoding);
         

        Description

        The ne_i18n_init function can be used to enable support for translated messages in the neon library. The encoding parameter, if non-NULL, specifies the character encoding required for generated translated @@ -15,4 +15,4 @@ will otherwise operate correctly.

        Note that the encoding used is a process-global setting and so results may be unexpected if other users of neon within the process call ne_i18n_init with a different - encoding parameter.

        See also

        ne_sock_init

        + encoding parameter.

        See also

        ne_sock_init

        diff --git a/libs/neon/doc/html/refiaddr.html b/libs/neon/doc/html/refiaddr.html index b497adb0..55d3f78c 100644 --- a/libs/neon/doc/html/refiaddr.html +++ b/libs/neon/doc/html/refiaddr.html @@ -1,9 +1,9 @@ -ne_iaddr_make

        Name

        ne_iaddr_make, ne_iaddr_cmp, ne_iaddr_print, ne_iaddr_typeof, ne_iaddr_parse, ne_iaddr_raw, ne_iaddr_reverse, ne_iaddr_free — functions to manipulate network addresses

        Synopsis

        #include <ne_socket.h>
        +ne_iaddr_make

        Name

        ne_iaddr_make, ne_iaddr_cmp, ne_iaddr_print, ne_iaddr_typeof, ne_iaddr_parse, ne_iaddr_raw, ne_iaddr_reverse, ne_iaddr_free — functions to manipulate network addresses

        Synopsis

        #include <ne_socket.h>
         
         typedef enum {
             ne_iaddr_ipv4 = 0,
             ne_iaddr_ipv6
        -} ne_iaddr_type;
        ne_inet_addr *ne_iaddr_make(ne_iaddr_type type,
         const unsigned char *raw);
         
        int ne_iaddr_cmp(const ne_inet_addr *ia1,
         const ne_inet_addr *ia2);
         
        char *ne_iaddr_print(const ne_inet_addr *ia,
         char *buffer,
         size_t bufsiz);
         
        ne_iaddr_type ne_iaddr_typeof(const ne_inet_addr *ia);
         
        ne_inet_addr *ne_iaddr_parse(const char *address,
         ne_iaddr_type type);
         
        unsigned char *ne_iaddr_raw(const ne_inet_addr *ia,
         unsigned char *buffer);
         
        int ne_iaddr_reverse(const ne_inet_addr *ia,
         char *buffer,
         size_t buflen);
         
        void ne_iaddr_free(const ne_inet_addr *ia);
         

        Description

        ne_iaddr_make creates an +} ne_iaddr_type;

        ne_inet_addr *ne_iaddr_make(ne_iaddr_type type,
         const unsigned char *raw);
         
        int ne_iaddr_cmp(const ne_inet_addr *ia1,
         const ne_inet_addr *ia2);
         
        char *ne_iaddr_print(const ne_inet_addr *ia,
         char *buffer,
         size_t bufsiz);
         
        ne_iaddr_type ne_iaddr_typeof(const ne_inet_addr *ia);
         
        ne_inet_addr *ne_iaddr_parse(const char *address,
         ne_iaddr_type type);
         
        unsigned char *ne_iaddr_raw(const ne_inet_addr *ia,
         unsigned char *buffer);
         
        int ne_iaddr_reverse(const ne_inet_addr *ia,
         char *buffer,
         size_t buflen);
         
        void ne_iaddr_free(const ne_inet_addr *ia);
         

        Description

        ne_iaddr_make creates an ne_inet_addr object from a raw binary network address; for instance the four bytes 0x7f 0x00 0x00 0x01 represent the IPv4 address @@ -31,7 +31,7 @@ hostname is longer than the buffer it will be silently truncated; on success the string written to the buffer is always NUL-terminated.

        ne_iaddr_free releases the memory - associated with a network address object.

        Return value

        ne_iaddr_make returns NULL if the + associated with a network address object.

        Return value

        ne_iaddr_make returns NULL if the address type passed is not supported (for instance on a platform which does not support IPv6).

        ne_iaddr_print returns the buffer pointer, and never NULL.

        ne_iaddr_parse returns a network @@ -39,7 +39,7 @@ address parameter.

        ne_iaddr_reverse returns zero on success or non-zero if no hostname is associated with the address.

        ne_iaddr_raw returns the - buffer parameter, and never NULL.

        Examples

        The following example connects a socket to port 80 at the + buffer parameter, and never NULL.

        Examples

        The following example connects a socket to port 80 at the address 127.0.0.1.

        unsigned char addr[] = "\0x7f\0x00\0x00\0x01";
         ne_inet_addr *ia;
         
        @@ -50,4 +50,4 @@
             /* ... */
         } else {
             /* ... */
        -}
        +}
        diff --git a/libs/neon/doc/html/refneon.html b/libs/neon/doc/html/refneon.html index e1a2e405..5f844ff7 100644 --- a/libs/neon/doc/html/refneon.html +++ b/libs/neon/doc/html/refneon.html @@ -1,11 +1,11 @@ -neon

        Name

        neon — HTTP and WebDAV client library

        Description

        neon is an HTTP and WebDAV client library. The major +neon

        Name

        neon — HTTP and WebDAV client library

        Description

        neon is an HTTP and WebDAV client library. The major abstractions exposed are the HTTP session, created by ne_session_create; and the HTTP request, created by ne_request_create. HTTP authentication is handled transparently for server and proxy servers, see ne_set_server_auth; complete SSL/TLS support is also - included, see ne_ssl_set_verify.

        Conventions

        Some conventions are used throughout the neon API, to + included, see ne_ssl_set_verify.

        Conventions

        Some conventions are used throughout the neon API, to provide a consistent and simple interface; these are documented - below.

        Thread-safeness and global initialization

        neon itself is implemented to be thread-safe (avoiding any + below.

        Thread-safeness and global initialization

        neon itself is implemented to be thread-safe (avoiding any use of global state), but relies on the operating system providing a thread-safe resolver interface. Modern operating systems offer the thread-safe getaddrinfo interface, which @@ -19,7 +19,7 @@ OpenSSL or GnuTLS.

        Some platforms and libraries used by neon require global initialization before use; notably: -

        • The SIGPIPE signal +

          • The SIGPIPE signal disposition must be set to ignored or otherwise handled to avoid process termination when writing to a socket which has been shutdown by the peer.
          • OpenSSL and GnuTLS require global @@ -35,23 +35,23 @@ (and ne_sock_exit); neon neither checks whether these functions are called nor calls them itself.

            For some applications and configurations it may be necessary to call ne_i18n_init to initialize the support - for internationalization in neon.

          Asynchronous signal safety

          No function in neon is defined to be “async-signal safe†- + for internationalization in neon.

          Asynchronous signal safety

          No function in neon is defined to be “async-signal safe†- that is, no function is safe to call from a signal handler. Any call into the neon library from a signal handler will have undefined behaviour - in other words, it may crash the - process.

          Functions using global state

          Any function in neon may modify the + process.

          Functions using global state

          Any function in neon may modify the errno global variable as a side-effect. Except where explicitly documented, the value of errno is unspecified after any neon function call.

          Other than in the use of errno, the only functions which use or modify process-global state in neon are as follows: -

          Namespaces

          To avoid possible collisions between names used for symbols + malloc failure

        Namespaces

        To avoid possible collisions between names used for symbols and preprocessor macros by an application and the libraries it uses, it is good practice for each library to reserve a particular namespace prefix. An application which @@ -65,7 +65,7 @@ collisions can only be detected at link time, when the linker attempts to resolve symbols. The following list documents some of the namespaces claimed by libraries used by neon; this list may - be incomplete.

        SSL, ssl, TLS, tls, ERR_, BIO_, d2i_, i2d_, ASN1_

        Some of the many prefixes used by the OpenSSL + be incomplete.

        SSL, ssl, TLS, tls, ERR_, BIO_, d2i_, i2d_, ASN1_

        Some of the many prefixes used by the OpenSSL library; little attempt has been made to keep exported symbols within any particular prefixes for this library.

        gnutls_, gcry_, gpg_

        Namespaces used by the GnuTLS library (and @@ -80,28 +80,28 @@ library and dependencies thereof; a number of symbols lie outside these prefixes.

        pakchois_

        Namespace used by the pakchois library.

        px_

        Namespace used by the libproxy - library.

        Argument validation

        neon does not attempt to validate that the parameters + library.

        Argument validation

        neon does not attempt to validate that the parameters passed to functions conform to the API (for instance, checking that pointer arguments are not NULL). Any use of the neon API which is not documented to produce a certain behaviour results is said to produce undefined behaviour; it is - likely that neon will segfault under these conditions.

        URI paths, WebDAV metadata

        The path strings passed to any function must be + likely that neon will segfault under these conditions.

        URI paths, WebDAV metadata

        The path strings passed to any function must be URI-encoded by the application; neon never performs any URI encoding or decoding internally. WebDAV property names and values must be valid UTF-8 encoded Unicode - strings.

        User interaction

        As a pure library interface, neon will never produce + strings.

        User interaction

        As a pure library interface, neon will never produce output on stdout or stderr; all user interaction is the - responsibilty of the application.

        Memory handling

        neon does not attempt to cope gracefully with an + responsibilty of the application.

        Memory handling

        neon does not attempt to cope gracefully with an out-of-memory situation; instead, by default, the abort function is called to immediately terminate the process. An application may register a custom function which will be called before abort in - such a situation; see ne_oom_callback.

        Callbacks and userdata

        Whenever a callback is registered, a + such a situation; see ne_oom_callback.

        Callbacks and userdata

        Whenever a callback is registered, a userdata pointer is also used to allow the application to associate a context with the callback. The userdata is of type void *, allowing any pointer to - be used.

        Large File Support

        Since version 0.27.0, neon transparently uses the "LFS + be used.

        Large File Support

        Since version 0.27.0, neon transparently uses the "LFS transitional" interfaces in places where file-backed file descriptors are manipulated. This means files larger than 2GiB can be handled on platforms with a native 32-bit @@ -110,4 +110,4 @@ which is defined to be either off_t or off64_t according to whether LFS support is detected at build time. neon does not use or require the - -D_FILE_OFFSET_BITS=64 macro definition.

        + -D_FILE_OFFSET_BITS=64 macro definition.

        diff --git a/libs/neon/doc/html/refopts.html b/libs/neon/doc/html/refopts.html index a7eff48a..c07bec50 100644 --- a/libs/neon/doc/html/refopts.html +++ b/libs/neon/doc/html/refopts.html @@ -1,4 +1,4 @@ -ne_set_useragent

        Name

        ne_set_useragent, ne_set_read_timeout, ne_set_connect_timeout, ne_get_scheme, ne_get_server_hostport — common properties for HTTP sessions

        Synopsis

        #include <ne_session.h>
        void ne_set_useragent(ne_session *session,
         const char *product);
         
        void ne_set_read_timeout(ne_session *session,
         int timeout);
         
        void ne_set_connect_timeout(ne_session *session,
         int timeout);
         
        const char *ne_get_scheme(ne_sesssion *session);
         
        const char *ne_get_server_hostport(ne_sesssion *session);
         

        Description

        The User-Agent request header is used +ne_set_useragent

        Name

        ne_set_useragent, ne_set_read_timeout, ne_set_connect_timeout, ne_get_scheme, ne_get_server_hostport — common properties for HTTP sessions

        Synopsis

        #include <ne_session.h>
        void ne_set_useragent(ne_session *session,
         const char *product);
         
        void ne_set_read_timeout(ne_session *session,
         int timeout);
         
        void ne_set_connect_timeout(ne_session *session,
         int timeout);
         
        const char *ne_get_scheme(ne_sesssion *session);
         
        const char *ne_get_server_hostport(ne_sesssion *session);
         

        Description

        The User-Agent request header is used to identify the software which generated the request for statistical or debugging purposes. neon does not send a User-Agent header unless a call is made to the @@ -23,6 +23,6 @@ ne_get_server_hostport; for example www.example.com:8080. Note that the :port will be omitted if the default port - for the scheme is used.

        Examples

        Set a user-agent string:

        ne_session *sess = ne_session_create(...);
        +         for the scheme is used.

        Examples

        Set a user-agent string:

        ne_session *sess = ne_session_create(...);
         ne_set_useragent(sess, "MyApplication/2.1");

        Set a 30 second read timeout:

        ne_session *sess = ne_session_create(...);
        -ne_set_read_timeout(sess, 30);
        +ne_set_read_timeout(sess, 30);
        diff --git a/libs/neon/doc/html/refproxy.html b/libs/neon/doc/html/refproxy.html new file mode 100644 index 00000000..ed127bc2 --- /dev/null +++ b/libs/neon/doc/html/refproxy.html @@ -0,0 +1,53 @@ +ne_session_proxy

        Name

        ne_session_proxy, ne_session_socks_proxy, ne_session_system_proxy, ne_set_addrlist — configure proxy servers

        Synopsis

        #include <ne_session.h>
        void ne_session_proxy(ne_session *session,
         const char *hostname,
         unsigned int port);
         
        void ne_session_system_proxy(ne_session *session,
         unsigned int flags);
         
        void ne_session_socks_proxy(ne_session *session,
         enum ne_sock_sversion version,
         const char *hostname,
         unsigned int port,
         const char *username,
         const char *password);
         
        void ne_set_addrlist(ne_session *session,
         const ne_inet_addr **addrlist,
         size_t count);
         

        Description

        One (and no more than one) of the functions + ne_session_proxy, + ne_session_system_proxy, + ne_session_socks_proxy, + ne_set_addrlist can be used to configure + a proxy server for a given session object. If more than one + function is invoked for any given session object, only the + last call has effect. If one of the functions is to be used, + it must be used before the creation of any request object for + the session.

        HTTP proxy specification

        The ne_session_proxy function + configures use of an HTTP proxy server for the session, the + location of which is given by the + hostname and + port paramters. If the proxy + requires authentication, ne_set_proxy_auth + should be used.

        System proxy configuration

        The ne_session_system_proxy + function configures the session to use any proxy servers + specified by the system configuration. Support for this + function is platform-specific; if unsupported, the function + has no effect.

        SOCKS proxy configuration

        The ne_session_socks_proxy + function configures the session to use a SOCKS proxy. The + version indicates which version of + the SOCKS protocol should be used. The + hostname and + port parameters specify the SOCKS + proxy location. Note that a server with only an IPv6 + address cannot be used with SOCKS v4 or v4A. The + interpretation of the other arguments depends on the version + specified:

        NE_SOCK_SOCKSV4 (version 4)

        The username parameter + must be non-NULL; the password + parameter is ignored.

        NE_SOCK_SOCKSV4A (version 4A)

        The username parameter + must be non-NULL; the password + parameter is ignored.

        NE_SOCK_SOCKSV5 (version 5)

        The username parameter + may be NULL; if it is non-NULL, + the password parameter must also + be non-NULL; otherwise, it is ignored..

        Origin server address override

        The ne_set_addrlist function + forces use of an address and port the a specified list when + establishing a TCP connection, ignoring the "real" hostname + and port identifying the origin server for the session (as + passed to ne_session_create). The + origin server's "real" hostname and port will still be used + in the Host header in HTTP requests. + When a connection is required, the library will iterate + through the addrlist list, attempting + to connect to the address addrlist[0] + through to addrlist[count-1] in turn, + until a connection can be established.

        Return Values

        None of the functions described here has a return + value.

        Examples

        Create and destroy a session:

        ne_session *sess;
        +sess = ne_session_create("http", "host.example.com", 80);
        +ne_session_proxy(sess, "proxy.example.com", 3128);
        +/* ... use sess ... */
        +ne_session_destroy(sess);
        +
        diff --git a/libs/neon/doc/html/refreq.html b/libs/neon/doc/html/refreq.html index 0b9ea744..3b1be6ee 100644 --- a/libs/neon/doc/html/refreq.html +++ b/libs/neon/doc/html/refreq.html @@ -1,11 +1,11 @@ -ne_request_create

        Name

        ne_request_create, ne_request_dispatch, ne_request_destroy — low-level HTTP request handling

        Synopsis

        #include <ne_request.h>
        ne_request *ne_request_create(ne_session *session,
         const char *method,
         const char *path);
         
        int ne_request_dispatch(ne_request *req);
         
        void ne_request_destroy(ne_request *req);
         

        Description

        An HTTP request, represented by the -ne_request type, specifies that some operation is to be -performed on some resource. The -ne_request_create function creates a request -object, specifying the operation in the method -parameter. The location of the resource is determined by the server in -use for the session given by the sess -parameter, combined with the path parameter.

        The path string used must conform to the +ne_request_create

        Name

        ne_request_create, ne_request_dispatch, ne_request_destroy — low-level HTTP request handling

        Synopsis

        #include <ne_request.h>
        ne_request *ne_request_create(ne_session *session,
         const char *method,
         const char *path);
         
        int ne_request_dispatch(ne_request *req);
         
        void ne_request_destroy(ne_request *req);
         

        Description

        The ne_request object represents an HTTP + request and the associated response. + The ne_request_create function creates a + new request object for the + given session. The target resource for + the request is identified by the path, + and the method to be performed on that resource via + the method parameter.

        The path string used must conform to the abs_path definition given in RFC2396, with an optional "?query" part, and must be URI-escaped by the caller (for instance, using ne_path_escape). If the string @@ -33,14 +33,14 @@ request object produces undefined behaviour.

        If a request is being using a non-idempotent method such as POST, the NE_REQFLAG_IDEMPOTENT flag should be - disabled; see ne_set_request_flag.

        Return value

        The ne_request_create function + disabled; see ne_set_request_flag.

        Return value

        The ne_request_create function returns a pointer to a request object (and never NULL).

        The ne_request_dispatch function returns zero if the request was dispatched successfully, and a -non-zero error code otherwise.

        Errors

        NE_ERROR

        Request failed (see session error string)

        NE_LOOKUP

        The DNS lookup for the server (or proxy server) failed.

        NE_AUTH

        Authentication failed on the server.

        NE_PROXYAUTH

        Authentication failed on the proxy server.

        NE_CONNECT

        A connection to the server could not be established.

        NE_TIMEOUT

        A timeout occurred while waiting for the server to respond.

        Example

        An example of applying a MKCOL +non-zero error code otherwise.

        Errors

        NE_ERROR

        Request failed (see session error string)

        NE_LOOKUP

        The DNS lookup for the server (or proxy server) failed.

        NE_AUTH

        Authentication failed on the server.

        NE_PROXYAUTH

        Authentication failed on the proxy server.

        NE_CONNECT

        A connection to the server could not be established.

        NE_TIMEOUT

        A timeout occurred while waiting for the server to respond.

        Example

        An example of applying a MKCOL operation to the resource at the location http://www.example.com/foo/bar/:

        ne_session *sess = ne_session_create("http", "www.example.com", 80);
         ne_request *req = ne_request_create(sess, "MKCOL", "/foo/bar/");
         if (ne_request_dispatch(req)) {
            printf("Request failed: %s\n", ne_get_error(sess));
         }
        -ne_request_destroy(req);
        +ne_request_destroy(req);
        diff --git a/libs/neon/doc/html/refreqbody.html b/libs/neon/doc/html/refreqbody.html index a5b8735d..d0bb2477 100644 --- a/libs/neon/doc/html/refreqbody.html +++ b/libs/neon/doc/html/refreqbody.html @@ -1,4 +1,4 @@ -ne_set_request_body_buffer

        Name

        ne_set_request_body_buffer, ne_set_request_body_fd, ne_set_request_body_fd64 — include a message body with a request

        Synopsis

        #include <ne_request.h>
        void ne_set_request_body_buffer(ne_request *req,
         const char *buf,
         size_t count);
         
        int ne_set_request_body_fd(ne_request *req,
         int fd,
         off_t begin,
         off_t length);
         

        Description

        The ne_set_request_body_buffer +ne_set_request_body_buffer

        Name

        ne_set_request_body_buffer, ne_set_request_body_fd, ne_set_request_body_fd64 — include a message body with a request

        Synopsis

        #include <ne_request.h>
        void ne_set_request_body_buffer(ne_request *req,
         const char *buf,
         size_t count);
         
        int ne_set_request_body_fd(ne_request *req,
         int fd,
         off_t begin,
         off_t length);
         

        Description

        The ne_set_request_body_buffer function specifies that a message body should be included with the body, which is stored in the count bytes buffer buf.

        The ne_set_request_body_fd function @@ -14,4 +14,4 @@ ne_set_request_body_buffer nor the file descriptor passed to ne_set_request_body_fd are copied - internally.

        + internally.

        diff --git a/libs/neon/doc/html/refreqflags.html b/libs/neon/doc/html/refreqflags.html index 88b7f790..fb25671b 100644 --- a/libs/neon/doc/html/refreqflags.html +++ b/libs/neon/doc/html/refreqflags.html @@ -1,7 +1,7 @@ -ne_set_request_flag

        Name

        ne_set_request_flag, ne_get_request_flag — set and retrieve per-request flags

        Synopsis

        #include <ne_request.h>
        void ne_set_request_flag(ne_request *req,
         ne_request_flag flag,
         int value);
         
        int ne_get_request_flag(ne_request *req,
         ne_request_flag flag);
         

        Description

        The ne_set_request_flag function +ne_set_request_flag

        Name

        ne_set_request_flag, ne_get_request_flag — set and retrieve per-request flags

        Synopsis

        #include <ne_request.h>
        void ne_set_request_flag(ne_request *req,
         ne_request_flag flag,
         int value);
         
        int ne_get_request_flag(ne_request *req,
         ne_request_flag flag);
         

        Description

        The ne_set_request_flag function enables or disables a per-request flag. Passing a non-zero value argument enables the flag, and zero - disables it.

        The following flags are defined:

        NE_REQFLAG_EXPECT100

        enable this flag to use the "Expect: + disables it.

        The following flags are defined:

        NE_REQFLAG_EXPECT100

        enable this flag to use the "Expect: 100-continue" feature of HTTP/1.1, which allows the server to process request headers without reading the entire request body. This saves time and bandwidth if @@ -9,6 +9,6 @@ the request to be resent), but has interoperability problems with some older servers.

        NE_REQFLAG_IDEMPOTENT

        disable this flag if the request uses a non-idempotent method such as - POST

        Return value

        The ne_get_request_flag function returns + POST

        Return value

        The ne_get_request_flag function returns zero if a flag is disabled, less than zero if the flag is not - supported, or greater than zero if the flag is enabled.

        + supported, or greater than zero if the flag is enabled.

        diff --git a/libs/neon/doc/html/refreqhdr.html b/libs/neon/doc/html/refreqhdr.html index 8da242fd..1255a409 100644 --- a/libs/neon/doc/html/refreqhdr.html +++ b/libs/neon/doc/html/refreqhdr.html @@ -1,8 +1,8 @@ -ne_add_request_header

        Name

        ne_add_request_header, ne_print_request_header — add headers to a request

        Synopsis

        #include <ne_request.h>
        void ne_add_request_header(ne_request *request,
         const char *name,
         const char *value);
         
        void ne_print_request_header(ne_request *request,
         const char *name,
         const char *format,
         ...);
         

        Description

        The functions ne_add_request_header +ne_add_request_header

        Name

        ne_add_request_header, ne_print_request_header — add headers to a request

        Synopsis

        #include <ne_request.h>
        void ne_add_request_header(ne_request *request,
         const char *name,
         const char *value);
         
        void ne_print_request_header(ne_request *request,
         const char *name,
         const char *format,
         ...);
         

        Description

        The functions ne_add_request_header and ne_print_request_header can be used to add headers to a request, before it is sent.

        ne_add_request_header simply adds a header of given name, with given value.

        ne_print_request_header adds a header of given name, taking the value from the printf-like format string -parameter and subsequent variable-length argument list.

        +parameter and subsequent variable-length argument list.

        diff --git a/libs/neon/doc/html/refresolve.html b/libs/neon/doc/html/refresolve.html index 5845b70f..fb7d6094 100644 --- a/libs/neon/doc/html/refresolve.html +++ b/libs/neon/doc/html/refresolve.html @@ -1,4 +1,4 @@ -ne_addr_resolve

        Name

        ne_addr_resolve, ne_addr_result, ne_addr_first, ne_addr_next, ne_addr_error, ne_addr_destroy — functions to resolve hostnames to addresses

        Synopsis

        #include <ne_socket.h>
        ne_sock_addr *ne_addr_resolve(const char *hostname,
         int flags);
         
        int ne_addr_result(const ne_sock_addr *addr);
         
        const ne_inet_addr *ne_addr_first(ne_sock_addr *addr);
         
        const ne_inet_addr *ne_addr_next(ne_sock_addr *addr);
         
        char *ne_addr_error(const ne_sock_addr *addr,
         char *buffer,
         size_t bufsiz);
         
        void ne_addr_destroy(ne_sock_addr *addr);
         

        Description

        The ne_addr_resolve function resolves +ne_addr_resolve

        Name

        ne_addr_resolve, ne_addr_result, ne_addr_first, ne_addr_next, ne_addr_error, ne_addr_destroy — functions to resolve hostnames to addresses

        Synopsis

        #include <ne_socket.h>
        ne_sock_addr *ne_addr_resolve(const char *hostname,
         int flags);
         
        int ne_addr_result(const ne_sock_addr *addr);
         
        const ne_inet_addr *ne_addr_first(ne_sock_addr *addr);
         
        const ne_inet_addr *ne_addr_next(ne_sock_addr *addr);
         
        char *ne_addr_error(const ne_sock_addr *addr,
         char *buffer,
         size_t bufsiz);
         
        void ne_addr_destroy(ne_sock_addr *addr);
         

        Description

        The ne_addr_resolve function resolves the given hostname, returning an ne_sock_addr object representing the address (or addresses) associated with the hostname. The @@ -25,10 +25,10 @@ addresses. The ne_inet_addr pointer returned by these functions can be passed to ne_sock_connect to connect a socket.

        After the address object has been used, it should be - destroyed using ne_addr_destroy.

        Return value

        ne_addr_resolve returns a pointer to an + destroyed using ne_addr_destroy.

        Return value

        ne_addr_resolve returns a pointer to an address object, and never NULL. ne_addr_error returns the - buffer parameter .

        Examples

        The code below prints out the set of addresses associated + buffer parameter .

        Examples

        The code below prints out the set of addresses associated with the hostname www.google.com.

        ne_sock_addr *addr;
         char buf[256];
         
        @@ -45,4 +45,4 @@
             putchar('\n');
         }
         ne_addr_destroy(addr);
        -
        +
        diff --git a/libs/neon/doc/html/refresphdr.html b/libs/neon/doc/html/refresphdr.html index 15d4095e..dcae0073 100644 --- a/libs/neon/doc/html/refresphdr.html +++ b/libs/neon/doc/html/refresphdr.html @@ -1,4 +1,4 @@ -ne_get_response_header

        Name

        ne_get_response_header, ne_response_header_iterate — functions to access response headers

        Synopsis

        #include <ne_request.h>
        const char *ne_get_response_header(ne_request *request,
         const char *name);
         
        void *ne_response_header_iterate(ne_request *request,
         void *cursor,
         const char **name,
         const char **value);
         

        Description

        To retrieve the value of a response header field, the +ne_get_response_header

        Name

        ne_get_response_header, ne_response_header_iterate — functions to access response headers

        Synopsis

        #include <ne_request.h>
        const char *ne_get_response_header(ne_request *request,
         const char *name);
         
        void *ne_response_header_iterate(ne_request *request,
         void *cursor,
         const char **name,
         const char **value);
         

        Description

        To retrieve the value of a response header field, the ne_get_response_header function can be used, and is given the name of the header to return.

        To iterate over all the response headers returned, the ne_response_header_iterate function can be @@ -8,14 +8,14 @@ the name and value parameters, and returns a new cursor pointer which can be passed to ne_response_header_iterate to retrieve the - next header.

        Return value

        ne_get_response_header returns a + next header.

        Return value

        ne_get_response_header returns a string, or NULL if no header with that name was given. If used during request processing, the return value pointer is valid only until the next call to ne_begin_request, or else, until the request object is destroyed.

        Likewise, the cursor, names, and values returned by ne_response_header_iterate are only valid until the next call to ne_begin_request or - until the request object is destroyed.

        Examples

        The following code will output the value of the + until the request object is destroyed.

        Examples

        The following code will output the value of the Last-Modified header for a resource:

        ne_request *req = ne_request_create(sess, "GET", "/foo.txt");
         if (ne_request_dispatch(req) == NE_OK) {
             const char *mtime = ne_get_response_header(req, "Last-Modified");
        @@ -23,4 +23,4 @@
                 printf("/foo.txt has last-modified value %s\n", mtime);
             }
         }
        -ne_request_destroy(req);
        +ne_request_destroy(req);
        diff --git a/libs/neon/doc/html/refsess.html b/libs/neon/doc/html/refsess.html index c12034e1..74d77334 100644 --- a/libs/neon/doc/html/refsess.html +++ b/libs/neon/doc/html/refsess.html @@ -1,36 +1,40 @@ -ne_session_create

        Name

        ne_session_create, ne_close_connection, ne_session_proxy, ne_session_destroy — set up HTTP sessions

        Synopsis

        #include <ne_session.h>
        ne_session *ne_session_create(const char *scheme,
         const char *hostname,
         unsigned int port);
         
        void ne_session_proxy(ne_session *session,
         const char *hostname,
         unsigned int port);
         
        void ne_close_connection(ne_session *session);
         
        void ne_session_destroy(ne_session *session);
         

        Description

        An ne_session object represents an HTTP +ne_session_create

        Name

        ne_session_create, ne_close_connection, ne_session_destroy — set up HTTP sessions

        Synopsis

        #include <ne_session.h>
        ne_session *ne_session_create(const char *scheme,
         const char *hostname,
         unsigned int port);
         
        void ne_close_connection(ne_session *session);
         
        void ne_session_destroy(ne_session *session);
         

        Description

        An ne_session object represents an HTTP session - a logical grouping of a sequence of HTTP requests made to a certain server. Any requests made using the session can use a persistent connection, share cached authentication credentials and any -other common attributes.

        A new HTTP session is created using -ne_session_create, giving the -hostname and port of the -server to use, along with the scheme used to -contact the server (usually "http"). Before the -first use of ne_session_create in a process, -ne_sock_init must have been called to perform any -global initialization needed by any libraries used by neon.

        To enable SSL/TLS for the session, pass the string +other common attributes.

        A new HTTP session is created using the +ne_session_create function; the +hostname and port +parameters specify the origin server to use, along with +the scheme (usually "http"). +Before the first use of ne_session_create in a +process, ne_sock_init must have been called to +perform any global initialization needed by any libraries used by +neon.

        To enable SSL/TLS for the session, pass the string "https" as the scheme parameter, and either register a certificate verification function (see ne_ssl_set_verify) or trust the appropriate -certificate (see ne_ssl_trust_cert, ne_ssl_trust_default_ca).

        If an HTTP proxy server should be used for the session, - ne_session_proxy must be called giving - the hostname and port on which to contact the proxy.

        Further per-session options may be changed using the - ne_set_request_flag interface.

        If it is known that the session will not be used for a +certificate (see ne_ssl_trust_cert, ne_ssl_trust_default_ca).

        To use a proxy server for the session, it must be + configured (see ne_session_proxy) before any + requests are created from session object.

        Further per-session options may be changed using the + ne_set_session_flag interface.

        If it is known that the session will not be used for a significant period of time, ne_close_connection can be called to close the connection, if one remains open. Use of this function is entirely optional, but it must not be called if there is a request active using the session.

        Once a session has been completed, -ne_session_destroy must be called to destroy the -resources associated with the session. Any subsequent use of the -session pointer produces undefined behaviour.

        Notes

        The hostname passed to + ne_session_destroy must be called to + destroy the resources associated with the session. Any + subsequent use of the session pointer produces undefined + behaviour. The session object must not be destroyed until + after all associated request objects have been + destroyed.

        Notes

        The hostname passed to ne_session_create is resolved when the first request using the session is dispatched; a DNS resolution failure can only be detected at that time (using the NE_LOOKUP error code); see ne_request_dispatch for -details.

        Return Values

        ne_session_create will return - a pointer to a new session object (and never NULL).

        Examples

        Create and destroy a session:

        ne_session *sess;
        +details.

        Return Values

        ne_session_create will return + a pointer to a new session object (and never NULL).

        Examples

        Create and destroy a session:

        ne_session *sess;
         sess = ne_session_create("http", "host.example.com", 80);
         /* ... use sess ... */
         ne_session_destroy(sess);
        -
        +
        diff --git a/libs/neon/doc/html/refsessflags.html b/libs/neon/doc/html/refsessflags.html index 93807344..d2aa2701 100644 --- a/libs/neon/doc/html/refsessflags.html +++ b/libs/neon/doc/html/refsessflags.html @@ -1,7 +1,7 @@ -ne_set_session_flag

        Name

        ne_set_session_flag, ne_get_session_flag — set and retrieve session flags

        Synopsis

        #include <ne_request.h>
        void ne_set_session_flag(ne_session *sess,
         ne_session_flag flag,
         int value);
         
        int ne_get_session_flag(ne_session *sess,
         ne_session_flag flag);
         

        Description

        The ne_set_session_flag function +ne_set_session_flag

        Name

        ne_set_session_flag, ne_get_session_flag — set and retrieve session flags

        Synopsis

        #include <ne_request.h>
        void ne_set_session_flag(ne_session *sess,
         ne_session_flag flag,
         int value);
         
        int ne_get_session_flag(ne_session *sess,
         ne_session_flag flag);
         

        Description

        The ne_set_session_flag function enables or disables a session flag. Passing a non-zero value argument enables the flag, and zero - disables it.

        The following flags are defined:

        NE_SESSFLAG_PERSIST

        disable this flag to prevent use of persistent + disables it.

        The following flags are defined:

        NE_SESSFLAG_PERSIST

        disable this flag to prevent use of persistent connections

        NE_SESSFLAG_ICYPROTO

        enable this flag to enable support for non-HTTP ShoutCast-style "ICY" responses

        NE_SESSFLAG_SSLv2

        disable this flag to disable support for the SSLv2 protocol

        NE_SESSFLAG_RFC4918

        enable this flag to enable support for @@ -12,6 +12,6 @@ which does not correctly support the TLS SNI extension

        NE_SESSFLAG_EXPECT100

        enable this flag to enable the request flag NE_REQFLAG_EXPECT100 for new - requests

        Return value

        The ne_get_session_flag function + requests

        Return value

        The ne_get_session_flag function returns zero if a flag is disabled, less than zero if the flag is - not supported, or greater than zero if the flag is enabled.

        + not supported, or greater than zero if the flag is enabled.

        diff --git a/libs/neon/doc/html/refshave.html b/libs/neon/doc/html/refshave.html index 1a6c2d08..411d39df 100644 --- a/libs/neon/doc/html/refshave.html +++ b/libs/neon/doc/html/refshave.html @@ -1,7 +1,7 @@ -ne_shave

        Name

        ne_shave — trim whitespace from a string

        Synopsis

        #include <ne_string.h>
        char *ne_shave(char *str,
         const char *whitespace);
         

        Description

        ne_shave returns a portion of +ne_shave

        Name

        ne_shave — trim whitespace from a string

        Synopsis

        #include <ne_string.h>
        char *ne_shave(char *str,
         const char *whitespace);
         

        Description

        ne_shave returns a portion of str with any leading or trailing characters in the whitespace array removed. str may be modified. Note that the return -value may not be equal to str.

        Examples

        The following code segment will output +value may not be equal to str.

        Examples

        The following code segment will output "fish":

        char s[] = ".!.fish!.!";
         puts(ne_shave(s, ".!"));
        diff --git a/libs/neon/doc/html/refsockinit.html b/libs/neon/doc/html/refsockinit.html index f4471349..cafa5728 100644 --- a/libs/neon/doc/html/refsockinit.html +++ b/libs/neon/doc/html/refsockinit.html @@ -1,4 +1,4 @@ -ne_sock_init

        Name

        ne_sock_init, ne_sock_exit — perform library initialization

        Synopsis

        #include <ne_socket.h>
        int ne_sock_init(void); 
         
        void ne_sock_exit(void); 
         

        Description

        In some platforms and configurations, neon may be using +ne_sock_init

        Name

        ne_sock_init, ne_sock_exit — perform library initialization

        Synopsis

        #include <ne_socket.h>
        int ne_sock_init(void); 
         
        void ne_sock_exit(void); 
         

        Description

        In some platforms and configurations, neon may be using some socket or SSL libraries which require global initialization before use. To perform this initialization, the ne_sock_init function must be called before @@ -25,10 +25,10 @@ section. Otherwise, it is not safe to use neon with SSL in a multi-threaded process. The ne_has_support function can be used to determine whether neon is built to - enable thread-safety support in the SSL library.

        Thread-safe SSL with OpenSSL

        neon follows two simple rules when dealing with the + enable thread-safety support in the SSL library.

        Thread-safe SSL with OpenSSL

        neon follows two simple rules when dealing with the OpenSSL locking callbacks: -

        • ne_sock_init will set +

          • ne_sock_init will set thread-safety locking callbacks if and only if no locking callbacks are already registered.
          • ne_sock_exit will unset the thread-safety locking callbacks if and only if the @@ -37,7 +37,7 @@ Applications and libraries should be able to co-operate to ensure that SSL use is always thread-safe if similar rules are - always followed.

          Thread-safe SSL with GnuTLS

          The cryptography library used by GnuTLS, libgcrypt, only + always followed.

          Thread-safe SSL with GnuTLS

          The cryptography library used by GnuTLS, libgcrypt, only supports an initialization operation to register thread-safety callbacks. ne_sock_init will register the thread-safe locking callbacks on first use; @@ -46,6 +46,6 @@ unsafe to dynamically unload neon from the process if neon is configured with thread-safe SSL support enabled (since the callbacks would be left pointing at unmapped memory once neon - is unloaded).

        Return value

        ne_sock_init returns zero on success, + is unloaded).

        Return value

        ne_sock_init returns zero on success, or non-zero on error. If an error occurs, no further use of the - neon library should be attempted.

        + neon library should be attempted.

        diff --git a/libs/neon/doc/html/refsslca.html b/libs/neon/doc/html/refsslca.html index 73ecfe01..e85ff6a4 100644 --- a/libs/neon/doc/html/refsslca.html +++ b/libs/neon/doc/html/refsslca.html @@ -1,10 +1,10 @@ -ne_ssl_trust_cert

        Name

        ne_ssl_trust_cert, ne_ssl_trust_default_ca — functions to indicate that certificates are trusted

        Synopsis

        #include <ne_session.h>
        void ne_ssl_trust_cert(ne_session *session,
         const ne_ssl_certificate *cert);
         
        void ne_ssl_trust_default_ca(ne_session *session);
         

        Description

        To indicate that a given certificate is trusted by the +ne_ssl_trust_cert

        Name

        ne_ssl_trust_cert, ne_ssl_trust_default_ca — functions to indicate that certificates are trusted

        Synopsis

        #include <ne_session.h>
        void ne_ssl_trust_cert(ne_session *session,
         const ne_ssl_certificate *cert);
         
        void ne_ssl_trust_default_ca(ne_session *session);
         

        Description

        To indicate that a given certificate is trusted by the user, the certificate object can be passed to ne_ssl_trust_cert. The certificate object is duplicated internally and can subsequently be destroyed.

        The SSL library in use by neon may include a default set of CA certificates; calling the ne_ssl_trust_default_ca function will indicate -that these CAs are trusted by the user.

        Examples

        Load the CA certificate stored in /path/to/cacert.pem:

        ne_session *sess = ne_session_create(...);
        +that these CAs are trusted by the user.

        Examples

        Load the CA certificate stored in /path/to/cacert.pem:

        ne_session *sess = ne_session_create(...);
         ne_ssl_certificate *cert = ne_ssl_cert_read("/path/to/cacert.pem");
         
         if (cert) {
        @@ -12,4 +12,4 @@
            ne_ssl_cert_free(cert);
         } else {
            printf("Could not load CA cert: %s\n", ne_get_error(sess));
        -}
        +}
        diff --git a/libs/neon/doc/html/refsslcert2.html b/libs/neon/doc/html/refsslcert2.html index 1c0d4fb9..7c79f8e3 100644 --- a/libs/neon/doc/html/refsslcert2.html +++ b/libs/neon/doc/html/refsslcert2.html @@ -1,4 +1,4 @@ -ne_ssl_cert_cmp

        Name

        ne_ssl_cert_cmp, ne_ssl_cert_free — functions to operate on certificate objects

        Synopsis

        #include <ne_header.h>
        int ne_ssl_cert_cmp(const ne_ssl_certificate *c1,
         const ne_ssl_certificate *c2);
         
        void ne_ssl_cert_free(ne_ssl_certificate *cert);
         

        Description

        The ne_ssl_cert_cmp function can be +ne_ssl_cert_cmp

        Name

        ne_ssl_cert_cmp, ne_ssl_cert_free — functions to operate on certificate objects

        Synopsis

        #include <ne_header.h>
        int ne_ssl_cert_cmp(const ne_ssl_certificate *c1,
         const ne_ssl_certificate *c2);
         
        void ne_ssl_cert_free(ne_ssl_certificate *cert);
         

        Description

        The ne_ssl_cert_cmp function can be used to compare two certificate objects; it returns zero if they refer to the same certificate, and non-zero otherwise.

        The ne_ssl_cert_free function can be used to destroy a certificate object when it is no longer diff --git a/libs/neon/doc/html/refsslcertio.html b/libs/neon/doc/html/refsslcertio.html index c4bd5969..f818fc8a 100644 --- a/libs/neon/doc/html/refsslcertio.html +++ b/libs/neon/doc/html/refsslcertio.html @@ -1,4 +1,4 @@ -ne_ssl_cert_read

        Name

        ne_ssl_cert_read, ne_ssl_cert_write, ne_ssl_cert_import, ne_ssl_cert_export — functions to read or write certificates to and from files or strings

        Synopsis

        #include <ne_ssl.h>
        ne_ssl_certificate *ne_ssl_cert_read(const char *filename);
         
        int ne_ssl_cert_write(const ne_ssl_certificate *cert,
         const char *filename);
         
        ne_ssl_certificate *ne_ssl_cert_import(const char *data);
         
        char *ne_ssl_cert_export(const ne_ssl_certificate *cert);
         

        Description

        The ne_ssl_cert_write function writes a +ne_ssl_cert_read

        Name

        ne_ssl_cert_read, ne_ssl_cert_write, ne_ssl_cert_import, ne_ssl_cert_export — functions to read or write certificates to and from files or strings

        Synopsis

        #include <ne_ssl.h>
        ne_ssl_certificate *ne_ssl_cert_read(const char *filename);
         
        int ne_ssl_cert_write(const ne_ssl_certificate *cert,
         const char *filename);
         
        ne_ssl_certificate *ne_ssl_cert_import(const char *data);
         
        char *ne_ssl_cert_export(const ne_ssl_certificate *cert);
         

        Description

        The ne_ssl_cert_write function writes a certificate to a file using the PEM encoding. The ne_ssl_cert_export function returns a base64-encoded NUL-terminated string representing the @@ -9,14 +9,14 @@ returns a certificate object from a base64-encoded string, data, as returned by ne_ssl_cert_export. The certificate object - returned by these functions should be destroyed using ne_ssl_cert_free after use.

        Return value

        ne_ssl_cert_read returns NULL if a + returned by these functions should be destroyed using ne_ssl_cert_free after use.

        Return value

        ne_ssl_cert_read returns NULL if a certificate could not be read from the file. ne_ssl_cert_write returns non-zero if the certificate could not be written to the file. ne_ssl_cert_export always returns a NUL-terminated string, and never NULL. ne_ssl_cert_import returns NULL if the - string was not a valid base64-encoded certificate.

        Encoding Formats

        The string produced by + string was not a valid base64-encoded certificate.

        Encoding Formats

        The string produced by ne_ssl_cert_export is the base64 encoding of the DER representation of the certificate. The file written by ne_ssl_cert_write uses the PEM format: this diff --git a/libs/neon/doc/html/refssldname.html b/libs/neon/doc/html/refssldname.html index dd341a0a..64d685e8 100644 --- a/libs/neon/doc/html/refssldname.html +++ b/libs/neon/doc/html/refssldname.html @@ -1,9 +1,9 @@ -ne_ssl_dname

        Name

        ne_ssl_readable_dname, ne_ssl_dname_cmp — SSL distinguished name handling

        Synopsis

        #include <ne_ssl.h>
        const char *ne_ssl_readable_dname(const ne_ssl_dname *dname);
         
        int ne_ssl_dname_cmp(const ne_ssl_dname *dn1,
         const ne_ssl_dname *dn2);
         

        Description

        The ne_ssl_readable_dname function +ne_ssl_dname

        Name

        ne_ssl_readable_dname, ne_ssl_dname_cmp — SSL distinguished name handling

        Synopsis

        #include <ne_ssl.h>
        const char *ne_ssl_readable_dname(const ne_ssl_dname *dname);
         
        int ne_ssl_dname_cmp(const ne_ssl_dname *dn1,
         const ne_ssl_dname *dn2);
         

        Description

        The ne_ssl_readable_dname function creates a single-line, human-readable string out of an ne_ssl_dname object. The returned string is malloc()-allocated, and must be free()d by the caller.

        The ne_ssl_dname_cmp function compares two distinguished names, and returns zero if they are - equal, or non-zero otherwise.

        Return value

        ne_ssl_readable_dname returns a malloc-allocated - string, and never NULL.

        Examples

        See ne_ssl_cert_subject for an example - use of ne_ssl_readable_dname.

        + equal, or non-zero otherwise.

        Return value

        ne_ssl_readable_dname returns a malloc-allocated + string, and never NULL.

        Examples

        See ne_ssl_cert_subject for an example + use of ne_ssl_readable_dname.

        diff --git a/libs/neon/doc/html/refsslvfy.html b/libs/neon/doc/html/refsslvfy.html index 4d4fbd9b..3a61c1a4 100644 --- a/libs/neon/doc/html/refsslvfy.html +++ b/libs/neon/doc/html/refsslvfy.html @@ -1,4 +1,4 @@ -ne_ssl_set_verify

        Name

        ne_ssl_set_verify — register an SSL certificate verification callback

        Synopsis

        #include <ne_session.h>
        typedef int ne_ssl_verify_fn(void *userdata,
         int failures,
         const ne_ssl_certificate *cert);
         
        void ne_ssl_set_verify(ne_session *session,
         ne_ssl_verify_fn verify_fn,
         void *userdata);
         

        Description

        To enable manual SSL certificate verification, a +ne_ssl_set_verify

        Name

        ne_ssl_set_verify — register an SSL certificate verification callback

        Synopsis

        #include <ne_session.h>
        typedef int ne_ssl_verify_fn(void *userdata,
         int failures,
         const ne_ssl_certificate *cert);
         
        void ne_ssl_set_verify(ne_session *session,
         ne_ssl_verify_fn verify_fn,
         void *userdata);
         

        Description

        To enable manual SSL certificate verification, a callback can be registered using ne_ssl_set_verify. If such a callback is not registered, when a connection is established to an SSL server which @@ -7,7 +7,7 @@ failures parameter gives a bitmask indicating in what way the automatic certificate verification failed. The value is equal to the bit-wise OR of one or more of the following -constants (and is guaranteed to be non-zero):

        NE_SSL_NOTYETVALID

        The certificate is not yet valid.

        NE_SSL_EXPIRED

        The certificate has expired.

        NE_SSL_IDMISMATCH

        The hostname used for the session does not match +constants (and is guaranteed to be non-zero):

        NE_SSL_NOTYETVALID

        The certificate is not yet valid.

        NE_SSL_EXPIRED

        The certificate has expired.

        NE_SSL_IDMISMATCH

        The hostname used for the session does not match the hostname to which the certificate was issued.

        NE_SSL_UNTRUSTED

        The Certificate Authority which signed the certificate is not trusted.

        Note that if either of the NE_SSL_IDMISMATCH or @@ -18,9 +18,9 @@ If the server presented a chain of certificates, the chain can be accessed using ne_ssl_cert_signedby. The cert object given is not valid after the -callback returns.

        Return value

        The verification callback must return zero to indicate +callback returns.

        Return value

        The verification callback must return zero to indicate that the certificate should be trusted; and non-zero otherwise (in -which case, the connection will fail).

        Examples

        The following code implements an example verification +which case, the connection will fail).

        Examples

        The following code implements an example verification callback, using the dump_cert function from ne_ssl_cert_subject to display certification information. Notice that the hostname of the @@ -63,4 +63,4 @@ ne_session *sess = ne_session_create("https", "some.host.name", 443); ne_ssl_set_verify(sess, my_verify, "some.host.name"); ... -}

        +} diff --git a/libs/neon/doc/html/refstatus.html b/libs/neon/doc/html/refstatus.html index d86fb98c..a79f763c 100644 --- a/libs/neon/doc/html/refstatus.html +++ b/libs/neon/doc/html/refstatus.html @@ -1,10 +1,10 @@ -ne_status

        Name

        ne_status — HTTP status structure

        Synopsis

        #include <ne_utils.h>
        +ne_status

        Name

        ne_status — HTTP status structure

        Synopsis

        #include <ne_utils.h>
         
         typedef struct {
             int major_version, minor_version;
             int code, klass;
             const char *reason_phrase;
        -} ne_status;

        Description

        An ne_status type represents an HTTP +} ne_status;

        Description

        An ne_status type represents an HTTP response status; used in response messages giving a result of request. The major_version and minor_version fields give the HTTP version @@ -12,11 +12,11 @@ code field gives the status code of the result (lying between 100 and 999 inclusive), and the klass field gives the -class[2], which is equal to the most significant digit +class[2], which is equal to the most significant digit of the status.

        There are five classes of HTTP status code defined by - RFC2616:

        1xx

        Informational response.

        2xx

        Success: the operation was successful

        3xx

        Redirection

        4xx

        Client + RFC2616:

        1xx

        Informational response.

        2xx

        Success: the operation was successful

        3xx

        Redirection

        4xx

        Client error: the request made was incorrect in some - manner.

        5xx

        Server error

        See also

        ne_get_status.



        [2] the field is named “klass†not + manner.

        5xx

        Server error

        See also

        ne_get_status.



        [2] the field is named “klass†not “class†so that the header can be used from a C++ program, in which “class†is a reserved word)

        diff --git a/libs/neon/doc/html/reftok.html b/libs/neon/doc/html/reftok.html index 06f660dd..6923c6a4 100644 --- a/libs/neon/doc/html/reftok.html +++ b/libs/neon/doc/html/reftok.html @@ -1,4 +1,4 @@ -ne_token

        Name

        ne_token, ne_qtoken — string tokenizers

        Synopsis

        #include <ne_string.h>
        char *ne_token(char **str,
         char sep);
         
        char *ne_qtoken(char **str,
         char sep,
         const char *quotes);
         

        Description

        ne_token and +ne_token

        Name

        ne_token, ne_qtoken — string tokenizers

        Synopsis

        #include <ne_string.h>
        char *ne_token(char **str,
         char sep);
         
        char *ne_qtoken(char **str,
         char sep,
         const char *quotes);
         

        Description

        ne_token and ne_qtoken tokenize the string at the location stored in the pointer str. Each time the function is called, it returns the next token, and modifies the @@ -10,7 +10,7 @@ is enclosed in a pair of one of the characters given in the quotes string.

        The string being tokenized is modified each time the tokenizing function is called; replacing the next separator -character with a NUL terminator.

        Examples

        The following function prints out each token in a +character with a NUL terminator.

        Examples

        The following function prints out each token in a comma-separated string list, which is modified in-place:

        static void splitter(char *list)
         {
        diff --git a/libs/neon/doc/html/refvers.html b/libs/neon/doc/html/refvers.html
        index 5f1ac871..aa3efa19 100644
        --- a/libs/neon/doc/html/refvers.html
        +++ b/libs/neon/doc/html/refvers.html
        @@ -1,10 +1,10 @@
        -ne_version_match

        Name

        ne_version_match, ne_version_string — library versioning

        Synopsis

        #include <ne_utils.h>
        int ne_version_match(int major,
         int minor);
         
        const char *ne_version_string(void); 
         

        Description

        The ne_version_match function returns +ne_version_match

        Name

        ne_version_match, ne_version_string — library versioning

        Synopsis

        #include <ne_utils.h>
        int ne_version_match(int major,
         int minor);
         
        const char *ne_version_string(void); 
         

        Description

        The ne_version_match function returns non-zero if the library version is not of major version major, or the minor version is less than minor. For neon versions 0.x, every minor version is assumed to be incompatible with every other minor version.

        The ne_version_string function returns - a string giving the library version.

        Examples

        To require neon 1.x, version 1.2 or later:

        if (ne_version_match(1, 2)) {
        +    a string giving the library version.

        Examples

        To require neon 1.x, version 1.2 or later:

        if (ne_version_match(1, 2)) {
             printf("Library version out of date: 1.2 required, found %s.",
                    ne_version_string());
             exit(1);
        diff --git a/libs/neon/doc/html/refxml.html b/libs/neon/doc/html/refxml.html
        index 711ead89..280f6255 100644
        --- a/libs/neon/doc/html/refxml.html
        +++ b/libs/neon/doc/html/refxml.html
        @@ -1,4 +1,4 @@
        -ne_xml_create

        Name

        ne_xml_create, ne_xml_destroy — create and destroy an XML parser

        Synopsis

        #include <ne_xml.h>
        ne_xml_parser *ne_xml_create(void); 
         
        void ne_xml_destroy(ne_xml_parser *parser);
         

        Description

        The ne_xml_create function creates an +ne_xml_create

        Name

        ne_xml_create, ne_xml_destroy — create and destroy an XML parser

        Synopsis

        #include <ne_xml.h>
        ne_xml_parser *ne_xml_create(void); 
         
        void ne_xml_destroy(ne_xml_parser *parser);
         

        Description

        The ne_xml_create function creates an XML parser object, which can be used for parsing XML documents - using stacked SAX handlers.

        Return value

        ne_xml_create returns a pointer to an - XML parser object, and never NULL

        See also

        XXX

        + using stacked SAX handlers.

        Return value

        ne_xml_create returns a pointer to an + XML parser object, and never NULL

        See also

        XXX

        diff --git a/libs/neon/doc/html/security.html b/libs/neon/doc/html/security.html index c2f18037..02c3fe6e 100644 --- a/libs/neon/doc/html/security.html +++ b/libs/neon/doc/html/security.html @@ -1,11 +1,11 @@ -HTTP Client Security

        HTTP Client Security

        neon is intended to be secure against a specific threat +HTTP Client Security

        HTTP Client Security

        neon is intended to be secure against a specific threat model: use of a malicious HTTP server. Under this threat model, a range of attacks are possible against a client when the user (or application) can be tricked into accessing an HTTP server which is controlled by an attacker. This section documents various types of possible attack and describes what mitigation is used in - neon.

        CPU or memory consumption attacks

        neon uses fixed resource limits to prevent the following - attacks:

        • memory/CPU consumption attack using an unbounded number + neon.

          CPU or memory consumption attacks

          neon uses fixed resource limits to prevent the following + attacks:

          • memory/CPU consumption attack using an unbounded number of response header fields

          • memory consumption attack using an unbounded length of individual response header lines (or continuation headers)

          • memory consumption attack against the PROPFIND code @@ -17,11 +17,11 @@ must be mitigated at application level. Memory consumption in neon itself is fixed and is not proportional to the response size.

            Test cases for all the above attacks are present in the - neon test suite.

          SSL/TLS connection security

          When using a connection secured by SSL/TLS, it is necessary + neon test suite.

          SSL/TLS connection security

          When using a connection secured by SSL/TLS, it is necessary for clients to verify that the X.509 certificate presented by the server matches the server's expected identity. The algorithm required for this purpose is described in RFC 2818 and RFC 3280, - and is implemented by neon in the following manner:

          • the hostname argument passed to ne_session_create is the expected identity of the + and is implemented by neon in the following manner:

            • the hostname argument passed to ne_session_create is the expected identity of the server

            • the subjectAltName extension of the certificate is used for comparision against the expected identity, in preference to the Subject name's commonName attribute.

            • the dNSName, iPAddress, and uniformResourceIdentifier @@ -35,14 +35,14 @@ present the certificate details to a user for manual/off-line verification, if possible.

              Test cases for the correctness of the implementation of the identity verification algorithm are present in the neon test - suite.

            Control character insertion in error messages

            Where error messages (as returned by + suite.

            Control character insertion in error messages

            Where error messages (as returned by (ne_get_error) contain data supplied by the server, the untrusted data is sanitised to remove both control characters and non-ASCII characters. This prevents any attacks where such error messages are exposed to the user and can potentially distort the presentation of the interface (for example, through the use of a carriage return character in a text - user interface).

            Attacks against authentication credentials

            Authentication credentials can be compromised by a + user interface).

            Attacks against authentication credentials

            Authentication credentials can be compromised by a "downgrade attack" by an active attacker; for example, where a MITM presents a Basic authentication challenge in place of the server's Digest challenge. neon mitigates these attacks by diff --git a/libs/neon/doc/html/using.html b/libs/neon/doc/html/using.html index 8b53c2a2..bf0975b6 100644 --- a/libs/neon/doc/html/using.html +++ b/libs/neon/doc/html/using.html @@ -1,4 +1,4 @@ -How to use neon from your application

            How to use neon from your application

            This section describes how to add neon support to an +How to use neon from your application

            How to use neon from your application

            This section describes how to add neon support to an application. If you just want to quickly try out neon, use the neon-config script.

            The neon source code is designed to be easily embedded into an application source tree. neon has no dependencies on @@ -6,7 +6,7 @@ source tree can be configured to have no support for SSL or XML if desired. To configure the neon source code some GNU autoconf macros are supplied, which can be used in a number of ways, as - follows:

            • autoconf macros are distributed in the 'macros' + follows:

              • autoconf macros are distributed in the 'macros' subdirectory of the neon distribution. Use the NEON_LIBRARY macro from your configure.in to check for the presence of the neon library installed on the system. The macro adds an diff --git a/libs/neon/doc/html/xml.html b/libs/neon/doc/html/xml.html index e466f462..3b33c663 100644 --- a/libs/neon/doc/html/xml.html +++ b/libs/neon/doc/html/xml.html @@ -1,8 +1,8 @@ -Parsing XML

                Parsing XML

                The neon XML interface is exposed by the +Parsing XML

                Parsing XML

                The neon XML interface is exposed by the ne_xml.h header file. This interface gives a wrapper around the standard SAX API used by XML parsers, with an additional abstraction, stacked SAX - handlers, and also giving consistent XML Namespace support.

                Introduction to SAX

                A SAX-based parser works by emitting a sequence of + handlers, and also giving consistent XML Namespace support.

                Introduction to SAX

                A SAX-based parser works by emitting a sequence of events to reflect the tokens being parsed from the XML document. For example, parsing the following document fragment: @@ -19,13 +19,13 @@ subset of SAX exposed by the neon XML interface: start-element, character-data and end-element. In a C API, an “event†is implemented as a function callback; three callback types are used in - neon, one for each type of event.

                Stacked SAX handlers

                WebDAV property values are represented as fragments of XML, + neon, one for each type of event.

                Stacked SAX handlers

                WebDAV property values are represented as fragments of XML, transmitted as parts of larger XML documents over HTTP (notably in the body of the response to a PROPFIND request). When neon parses such documents, the SAX events generated for these property value fragments may need to be handled by the application, since neon has no knowledge of the structure of - properties used by the application.

                To solve this problem[1] the neon XML interface introduces + properties used by the application.

                To solve this problem[1] the neon XML interface introduces the concept of a SAX handler. A SAX handler comprises a start-element, character-data and end-element callback; the start-element callback being defined such that each handler may @@ -58,7 +58,7 @@ the stack. In the above example, handler A is at the base, and handler B at the top; if the name element had any children, only B's start-element would be invoked to accept - them.

                Maintaining state

                To facilitate communication between independent handlers, a + them.

                Maintaining state

                To facilitate communication between independent handlers, a state integer is associated with each element being parsed. This integer is returned by start-element callback and is passed to the subsequent character-data and end-element callbacks @@ -78,12 +78,12 @@ decline

              • B start-element (parent = 42, "name") → accept, state = 99
              • B character-data (state = 99, "Bob")
              • B end-element (state = 99, "name")
              • A end-element (state = 42, "cat")

              To avoid collisions between state integers used by different handlers, the interface definition of any handler includes the range - of integers it will use.

            XML namespaces

            To support XML namespaces, every element name is represented + of integers it will use.

            XML namespaces

            To support XML namespaces, every element name is represented as a (namespace, name) pair. The start-element and end-element callbacks are passed namespace and name strings accordingly. If an element in the XML document has no declared namespace, the namespace given will be the empty string, - "".



            [1] This + "".



            [1] This “problem†only needs solving because the SAX interface is so inflexible when implemented as C function callbacks; a better approach would be to use an XML parser interface which is not based diff --git a/libs/neon/doc/man/ne_add_request_header.3 b/libs/neon/doc/man/ne_add_request_header.3 index 7d34773e..7536ddab 100644 --- a/libs/neon/doc/man/ne_add_request_header.3 +++ b/libs/neon/doc/man/ne_add_request_header.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_add_request_header .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_ADD_REQUEST_HEADE" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_ADD_REQUEST_HEADE" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_addr_destroy.3 b/libs/neon/doc/man/ne_addr_destroy.3 index 156ac74e..ecf8e86b 100644 --- a/libs/neon/doc/man/ne_addr_destroy.3 +++ b/libs/neon/doc/man/ne_addr_destroy.3 @@ -1 +1 @@ -.so ne_addr_resolve.3 +.so man3/ne_addr_resolve.3 diff --git a/libs/neon/doc/man/ne_addr_error.3 b/libs/neon/doc/man/ne_addr_error.3 index 156ac74e..ecf8e86b 100644 --- a/libs/neon/doc/man/ne_addr_error.3 +++ b/libs/neon/doc/man/ne_addr_error.3 @@ -1 +1 @@ -.so ne_addr_resolve.3 +.so man3/ne_addr_resolve.3 diff --git a/libs/neon/doc/man/ne_addr_first.3 b/libs/neon/doc/man/ne_addr_first.3 index 156ac74e..ecf8e86b 100644 --- a/libs/neon/doc/man/ne_addr_first.3 +++ b/libs/neon/doc/man/ne_addr_first.3 @@ -1 +1 @@ -.so ne_addr_resolve.3 +.so man3/ne_addr_resolve.3 diff --git a/libs/neon/doc/man/ne_addr_next.3 b/libs/neon/doc/man/ne_addr_next.3 index 156ac74e..ecf8e86b 100644 --- a/libs/neon/doc/man/ne_addr_next.3 +++ b/libs/neon/doc/man/ne_addr_next.3 @@ -1 +1 @@ -.so ne_addr_resolve.3 +.so man3/ne_addr_resolve.3 diff --git a/libs/neon/doc/man/ne_addr_resolve.3 b/libs/neon/doc/man/ne_addr_resolve.3 index ec5618ce..9edf8e07 100644 --- a/libs/neon/doc/man/ne_addr_resolve.3 +++ b/libs/neon/doc/man/ne_addr_resolve.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_addr_resolve .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_ADDR_RESOLVE" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_ADDR_RESOLVE" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_addr_result.3 b/libs/neon/doc/man/ne_addr_result.3 index 156ac74e..ecf8e86b 100644 --- a/libs/neon/doc/man/ne_addr_result.3 +++ b/libs/neon/doc/man/ne_addr_result.3 @@ -1 +1 @@ -.so ne_addr_resolve.3 +.so man3/ne_addr_resolve.3 diff --git a/libs/neon/doc/man/ne_buffer.3 b/libs/neon/doc/man/ne_buffer.3 index 07e3f05f..5dbf1d52 100644 --- a/libs/neon/doc/man/ne_buffer.3 +++ b/libs/neon/doc/man/ne_buffer.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_buffer .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_BUFFER" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_BUFFER" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_buffer_altered.3 b/libs/neon/doc/man/ne_buffer_altered.3 index 705808a1..b0bbe5ea 100644 --- a/libs/neon/doc/man/ne_buffer_altered.3 +++ b/libs/neon/doc/man/ne_buffer_altered.3 @@ -1 +1 @@ -.so ne_buffer_clear.3 +.so man3/ne_buffer_clear.3 diff --git a/libs/neon/doc/man/ne_buffer_append.3 b/libs/neon/doc/man/ne_buffer_append.3 index 37c815b6..df205db2 100644 --- a/libs/neon/doc/man/ne_buffer_append.3 +++ b/libs/neon/doc/man/ne_buffer_append.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_buffer_append .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_BUFFER_APPEND" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_BUFFER_APPEND" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_buffer_clear.3 b/libs/neon/doc/man/ne_buffer_clear.3 index ad1bd2e8..3cea77d3 100644 --- a/libs/neon/doc/man/ne_buffer_clear.3 +++ b/libs/neon/doc/man/ne_buffer_clear.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_buffer_clear .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_BUFFER_CLEAR" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_BUFFER_CLEAR" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_buffer_concat.3 b/libs/neon/doc/man/ne_buffer_concat.3 index 8dedb2e7..d0f5b8f8 100644 --- a/libs/neon/doc/man/ne_buffer_concat.3 +++ b/libs/neon/doc/man/ne_buffer_concat.3 @@ -1 +1 @@ -.so ne_buffer_append.3 +.so man3/ne_buffer_append.3 diff --git a/libs/neon/doc/man/ne_buffer_create.3 b/libs/neon/doc/man/ne_buffer_create.3 index 710c7c22..bb143c28 100644 --- a/libs/neon/doc/man/ne_buffer_create.3 +++ b/libs/neon/doc/man/ne_buffer_create.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_buffer_create .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_BUFFER_CREATE" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_BUFFER_CREATE" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_buffer_destroy.3 b/libs/neon/doc/man/ne_buffer_destroy.3 index 7affb2ce..96529860 100644 --- a/libs/neon/doc/man/ne_buffer_destroy.3 +++ b/libs/neon/doc/man/ne_buffer_destroy.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_buffer_destroy .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_BUFFER_DESTROY" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_BUFFER_DESTROY" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_buffer_finish.3 b/libs/neon/doc/man/ne_buffer_finish.3 index 8384801f..5aac296f 100644 --- a/libs/neon/doc/man/ne_buffer_finish.3 +++ b/libs/neon/doc/man/ne_buffer_finish.3 @@ -1 +1 @@ -.so ne_buffer_destroy.3 +.so man3/ne_buffer_destroy.3 diff --git a/libs/neon/doc/man/ne_buffer_grow.3 b/libs/neon/doc/man/ne_buffer_grow.3 index 705808a1..b0bbe5ea 100644 --- a/libs/neon/doc/man/ne_buffer_grow.3 +++ b/libs/neon/doc/man/ne_buffer_grow.3 @@ -1 +1 @@ -.so ne_buffer_clear.3 +.so man3/ne_buffer_clear.3 diff --git a/libs/neon/doc/man/ne_buffer_ncreate.3 b/libs/neon/doc/man/ne_buffer_ncreate.3 index d4120e10..628991b0 100644 --- a/libs/neon/doc/man/ne_buffer_ncreate.3 +++ b/libs/neon/doc/man/ne_buffer_ncreate.3 @@ -1 +1 @@ -.so ne_buffer_create.3 +.so man3/ne_buffer_create.3 diff --git a/libs/neon/doc/man/ne_buffer_zappend.3 b/libs/neon/doc/man/ne_buffer_zappend.3 index 8dedb2e7..d0f5b8f8 100644 --- a/libs/neon/doc/man/ne_buffer_zappend.3 +++ b/libs/neon/doc/man/ne_buffer_zappend.3 @@ -1 +1 @@ -.so ne_buffer_append.3 +.so man3/ne_buffer_append.3 diff --git a/libs/neon/doc/man/ne_calloc.3 b/libs/neon/doc/man/ne_calloc.3 index 1ce5ecca..8564fc1a 100644 --- a/libs/neon/doc/man/ne_calloc.3 +++ b/libs/neon/doc/man/ne_calloc.3 @@ -1 +1 @@ -.so ne_malloc.3 +.so man3/ne_malloc.3 diff --git a/libs/neon/doc/man/ne_close_connection.3 b/libs/neon/doc/man/ne_close_connection.3 index 952fe78e..2a71e062 100644 --- a/libs/neon/doc/man/ne_close_connection.3 +++ b/libs/neon/doc/man/ne_close_connection.3 @@ -1 +1 @@ -.so ne_session_create.3 +.so man3/ne_session_create.3 diff --git a/libs/neon/doc/man/ne_forget_auth.3 b/libs/neon/doc/man/ne_forget_auth.3 index fc9de3c3..a6f0398a 100644 --- a/libs/neon/doc/man/ne_forget_auth.3 +++ b/libs/neon/doc/man/ne_forget_auth.3 @@ -1 +1 @@ -.so ne_set_server_auth.3 +.so man3/ne_set_server_auth.3 diff --git a/libs/neon/doc/man/ne_get_error.3 b/libs/neon/doc/man/ne_get_error.3 index 68532d94..c5832e01 100644 --- a/libs/neon/doc/man/ne_get_error.3 +++ b/libs/neon/doc/man/ne_get_error.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_get_error .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_GET_ERROR" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_GET_ERROR" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_get_request_flag.3 b/libs/neon/doc/man/ne_get_request_flag.3 index 6b65f016..11b05bd7 100644 --- a/libs/neon/doc/man/ne_get_request_flag.3 +++ b/libs/neon/doc/man/ne_get_request_flag.3 @@ -1 +1 @@ -.so ne_set_request_flag.3 +.so man3/ne_set_request_flag.3 diff --git a/libs/neon/doc/man/ne_get_response_header.3 b/libs/neon/doc/man/ne_get_response_header.3 index 8c5f2073..050bbff4 100644 --- a/libs/neon/doc/man/ne_get_response_header.3 +++ b/libs/neon/doc/man/ne_get_response_header.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_get_response_header .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_GET_RESPONSE_HEAD" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_GET_RESPONSE_HEAD" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_get_scheme.3 b/libs/neon/doc/man/ne_get_scheme.3 index 84ebba98..06ef4ae5 100644 --- a/libs/neon/doc/man/ne_get_scheme.3 +++ b/libs/neon/doc/man/ne_get_scheme.3 @@ -1 +1 @@ -.so ne_set_useragent.3 +.so man3/ne_set_useragent.3 diff --git a/libs/neon/doc/man/ne_get_server_hostport.3 b/libs/neon/doc/man/ne_get_server_hostport.3 index 84ebba98..06ef4ae5 100644 --- a/libs/neon/doc/man/ne_get_server_hostport.3 +++ b/libs/neon/doc/man/ne_get_server_hostport.3 @@ -1 +1 @@ -.so ne_set_useragent.3 +.so man3/ne_set_useragent.3 diff --git a/libs/neon/doc/man/ne_get_session_flag.3 b/libs/neon/doc/man/ne_get_session_flag.3 index f6e0f2f3..16dfb0ed 100644 --- a/libs/neon/doc/man/ne_get_session_flag.3 +++ b/libs/neon/doc/man/ne_get_session_flag.3 @@ -1 +1 @@ -.so ne_set_session_flag.3 +.so man3/ne_set_session_flag.3 diff --git a/libs/neon/doc/man/ne_get_status.3 b/libs/neon/doc/man/ne_get_status.3 index f7cef8e1..f38d3cf0 100644 --- a/libs/neon/doc/man/ne_get_status.3 +++ b/libs/neon/doc/man/ne_get_status.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_get_status .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_GET_STATUS" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_GET_STATUS" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_has_support.3 b/libs/neon/doc/man/ne_has_support.3 index 3ef5f42f..e4b0307c 100644 --- a/libs/neon/doc/man/ne_has_support.3 +++ b/libs/neon/doc/man/ne_has_support.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_has_support .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_HAS_SUPPORT" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_HAS_SUPPORT" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_i18n_init.3 b/libs/neon/doc/man/ne_i18n_init.3 index 13df5a5a..1adff48b 100644 --- a/libs/neon/doc/man/ne_i18n_init.3 +++ b/libs/neon/doc/man/ne_i18n_init.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_i18n_init .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_I18N_INIT" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_I18N_INIT" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_iaddr_cmp.3 b/libs/neon/doc/man/ne_iaddr_cmp.3 index 10660b85..0964908c 100644 --- a/libs/neon/doc/man/ne_iaddr_cmp.3 +++ b/libs/neon/doc/man/ne_iaddr_cmp.3 @@ -1 +1 @@ -.so ne_iaddr_make.3 +.so man3/ne_iaddr_make.3 diff --git a/libs/neon/doc/man/ne_iaddr_free.3 b/libs/neon/doc/man/ne_iaddr_free.3 index 10660b85..0964908c 100644 --- a/libs/neon/doc/man/ne_iaddr_free.3 +++ b/libs/neon/doc/man/ne_iaddr_free.3 @@ -1 +1 @@ -.so ne_iaddr_make.3 +.so man3/ne_iaddr_make.3 diff --git a/libs/neon/doc/man/ne_iaddr_make.3 b/libs/neon/doc/man/ne_iaddr_make.3 index 95005977..9fbecb09 100644 --- a/libs/neon/doc/man/ne_iaddr_make.3 +++ b/libs/neon/doc/man/ne_iaddr_make.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_iaddr_make .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_IADDR_MAKE" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_IADDR_MAKE" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_iaddr_parse.3 b/libs/neon/doc/man/ne_iaddr_parse.3 index 10660b85..0964908c 100644 --- a/libs/neon/doc/man/ne_iaddr_parse.3 +++ b/libs/neon/doc/man/ne_iaddr_parse.3 @@ -1 +1 @@ -.so ne_iaddr_make.3 +.so man3/ne_iaddr_make.3 diff --git a/libs/neon/doc/man/ne_iaddr_print.3 b/libs/neon/doc/man/ne_iaddr_print.3 index 10660b85..0964908c 100644 --- a/libs/neon/doc/man/ne_iaddr_print.3 +++ b/libs/neon/doc/man/ne_iaddr_print.3 @@ -1 +1 @@ -.so ne_iaddr_make.3 +.so man3/ne_iaddr_make.3 diff --git a/libs/neon/doc/man/ne_iaddr_raw.3 b/libs/neon/doc/man/ne_iaddr_raw.3 index 10660b85..0964908c 100644 --- a/libs/neon/doc/man/ne_iaddr_raw.3 +++ b/libs/neon/doc/man/ne_iaddr_raw.3 @@ -1 +1 @@ -.so ne_iaddr_make.3 +.so man3/ne_iaddr_make.3 diff --git a/libs/neon/doc/man/ne_iaddr_reverse.3 b/libs/neon/doc/man/ne_iaddr_reverse.3 index 10660b85..0964908c 100644 --- a/libs/neon/doc/man/ne_iaddr_reverse.3 +++ b/libs/neon/doc/man/ne_iaddr_reverse.3 @@ -1 +1 @@ -.so ne_iaddr_make.3 +.so man3/ne_iaddr_make.3 diff --git a/libs/neon/doc/man/ne_iaddr_typeof.3 b/libs/neon/doc/man/ne_iaddr_typeof.3 index 10660b85..0964908c 100644 --- a/libs/neon/doc/man/ne_iaddr_typeof.3 +++ b/libs/neon/doc/man/ne_iaddr_typeof.3 @@ -1 +1 @@ -.so ne_iaddr_make.3 +.so man3/ne_iaddr_make.3 diff --git a/libs/neon/doc/man/ne_malloc.3 b/libs/neon/doc/man/ne_malloc.3 index c77df9a0..d37c4718 100644 --- a/libs/neon/doc/man/ne_malloc.3 +++ b/libs/neon/doc/man/ne_malloc.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_malloc .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_MALLOC" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_MALLOC" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_oom_callback.3 b/libs/neon/doc/man/ne_oom_callback.3 index 1ce5ecca..8564fc1a 100644 --- a/libs/neon/doc/man/ne_oom_callback.3 +++ b/libs/neon/doc/man/ne_oom_callback.3 @@ -1 +1 @@ -.so ne_malloc.3 +.so man3/ne_malloc.3 diff --git a/libs/neon/doc/man/ne_print_request_header.3 b/libs/neon/doc/man/ne_print_request_header.3 index 616e34f7..a9ed2f77 100644 --- a/libs/neon/doc/man/ne_print_request_header.3 +++ b/libs/neon/doc/man/ne_print_request_header.3 @@ -1 +1 @@ -.so ne_add_request_header.3 +.so man3/ne_add_request_header.3 diff --git a/libs/neon/doc/man/ne_qtoken.3 b/libs/neon/doc/man/ne_qtoken.3 index b76d290f..b24c5741 100644 --- a/libs/neon/doc/man/ne_qtoken.3 +++ b/libs/neon/doc/man/ne_qtoken.3 @@ -1 +1 @@ -.so ne_token.3 +.so man3/ne_token.3 diff --git a/libs/neon/doc/man/ne_realloc.3 b/libs/neon/doc/man/ne_realloc.3 index 1ce5ecca..8564fc1a 100644 --- a/libs/neon/doc/man/ne_realloc.3 +++ b/libs/neon/doc/man/ne_realloc.3 @@ -1 +1 @@ -.so ne_malloc.3 +.so man3/ne_malloc.3 diff --git a/libs/neon/doc/man/ne_request_create.3 b/libs/neon/doc/man/ne_request_create.3 index caa01ec1..982ea8f6 100644 --- a/libs/neon/doc/man/ne_request_create.3 +++ b/libs/neon/doc/man/ne_request_create.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_request_create .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_REQUEST_CREATE" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_REQUEST_CREATE" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -44,16 +44,14 @@ ne_request_create, ne_request_dispatch, ne_request_destroy \- low\-level HTTP re .BI "void ne_request_destroy(ne_request\ *" "req" ");" .SH "DESCRIPTION" .PP -An HTTP request, represented by the +The \fBne_request\fR -type, specifies that some operation is to be performed on some resource\&. The +object represents an HTTP request and the associated response\&. The \fBne_request_create\fR -function creates a request object, specifying the operation in the +function creates a new request object for the given +\fIsession\fR\&. The target resource for the request is identified by the +\fIpath\fR, and the method to be performed on that resource via the \fImethod\fR -parameter\&. The location of the resource is determined by the server in use for the session given by the -\fIsess\fR -parameter, combined with the -\fIpath\fR parameter\&. .PP The diff --git a/libs/neon/doc/man/ne_request_destroy.3 b/libs/neon/doc/man/ne_request_destroy.3 index 12adee97..9c211a4f 100644 --- a/libs/neon/doc/man/ne_request_destroy.3 +++ b/libs/neon/doc/man/ne_request_destroy.3 @@ -1 +1 @@ -.so ne_request_create.3 +.so man3/ne_request_create.3 diff --git a/libs/neon/doc/man/ne_request_dispatch.3 b/libs/neon/doc/man/ne_request_dispatch.3 index 12adee97..9c211a4f 100644 --- a/libs/neon/doc/man/ne_request_dispatch.3 +++ b/libs/neon/doc/man/ne_request_dispatch.3 @@ -1 +1 @@ -.so ne_request_create.3 +.so man3/ne_request_create.3 diff --git a/libs/neon/doc/man/ne_response_header_iterate.3 b/libs/neon/doc/man/ne_response_header_iterate.3 index 30a56c3d..ac6864bc 100644 --- a/libs/neon/doc/man/ne_response_header_iterate.3 +++ b/libs/neon/doc/man/ne_response_header_iterate.3 @@ -1 +1 @@ -.so ne_get_response_header.3 +.so man3/ne_get_response_header.3 diff --git a/libs/neon/doc/man/ne_session_create.3 b/libs/neon/doc/man/ne_session_create.3 index a3bfd525..2e05a355 100644 --- a/libs/neon/doc/man/ne_session_create.3 +++ b/libs/neon/doc/man/ne_session_create.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_session_create .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_SESSION_CREATE" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_SESSION_CREATE" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -28,7 +28,7 @@ .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" -ne_session_create, ne_close_connection, ne_session_proxy, ne_session_destroy \- set up HTTP sessions +ne_session_create, ne_close_connection, ne_session_destroy \- set up HTTP sessions .SH "SYNOPSIS" .sp .ft B @@ -38,8 +38,6 @@ ne_session_create, ne_close_connection, ne_session_proxy, ne_session_destroy \- .ft .HP \w'ne_session\ *ne_session_create('u .BI "ne_session *ne_session_create(const\ char\ *" "scheme" ", const\ char\ *" "hostname" ", unsigned\ int\ " "port" ");" -.HP \w'void\ ne_session_proxy('u -.BI "void ne_session_proxy(ne_session\ *" "session" ", const\ char\ *" "hostname" ", unsigned\ int\ " "port" ");" .HP \w'void\ ne_close_connection('u .BI "void ne_close_connection(ne_session\ *" "session" ");" .HP \w'void\ ne_session_destroy('u @@ -50,14 +48,15 @@ An \fBne_session\fR object represents an HTTP session \- a logical grouping of a sequence of HTTP requests made to a certain server\&. Any requests made using the session can use a persistent connection, share cached authentication credentials and any other common attributes\&. .PP -A new HTTP session is created using -\fBne_session_create\fR, giving the +A new HTTP session is created using the +\fBne_session_create\fR +function; the \fIhostname\fR and \fIport\fR -of the server to use, along with the +parameters specify the origin server to use, along with the \fIscheme\fR -used to contact the server (usually +(usually "http")\&. Before the first use of \fBne_session_create\fR in a process, @@ -73,12 +72,11 @@ ne_ssl_set_verify) or trust the appropriate certificate (see ne_ssl_trust_cert, ne_ssl_trust_default_ca)\&. .PP -If an HTTP proxy server should be used for the session, -\fBne_session_proxy\fR -must be called giving the hostname and port on which to contact the proxy\&. +To use a proxy server for the session, it must be configured (see +ne_session_proxy) before any requests are created from session object\&. .PP Further per\-session options may be changed using the -ne_set_request_flag +ne_set_session_flag interface\&. .PP If it is known that the session will not be used for a significant period of time, @@ -87,7 +85,7 @@ can be called to close the connection, if one remains open\&. Use of this functi .PP Once a session has been completed, \fBne_session_destroy\fR -must be called to destroy the resources associated with the session\&. Any subsequent use of the session pointer produces undefined behaviour\&. +must be called to destroy the resources associated with the session\&. Any subsequent use of the session pointer produces undefined behaviour\&. The session object must not be destroyed until after all associated request objects have been destroyed\&. .SH "NOTES" .PP The hostname passed to diff --git a/libs/neon/doc/man/ne_session_destroy.3 b/libs/neon/doc/man/ne_session_destroy.3 index 952fe78e..2a71e062 100644 --- a/libs/neon/doc/man/ne_session_destroy.3 +++ b/libs/neon/doc/man/ne_session_destroy.3 @@ -1 +1 @@ -.so ne_session_create.3 +.so man3/ne_session_create.3 diff --git a/libs/neon/doc/man/ne_session_proxy.3 b/libs/neon/doc/man/ne_session_proxy.3 index 952fe78e..46897f6c 100644 --- a/libs/neon/doc/man/ne_session_proxy.3 +++ b/libs/neon/doc/man/ne_session_proxy.3 @@ -1 +1,157 @@ -.so ne_session_create.3 +'\" t +.\" Title: ne_session_proxy +.\" Author: +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 +.\" Manual: neon API reference +.\" Source: neon 0.30.0 +.\" Language: English +.\" +.TH "NE_SESSION_PROXY" "3" "31 July 2013" "neon 0.30.0" "neon API reference" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +ne_session_proxy, ne_session_socks_proxy, ne_session_system_proxy, ne_set_addrlist \- configure proxy servers +.SH "SYNOPSIS" +.sp +.ft B +.nf +#include +.fi +.ft +.HP \w'void\ ne_session_proxy('u +.BI "void ne_session_proxy(ne_session\ *" "session" ", const\ char\ *" "hostname" ", unsigned\ int\ " "port" ");" +.HP \w'void\ ne_session_system_proxy('u +.BI "void ne_session_system_proxy(ne_session\ *" "session" ", unsigned\ int\ " "flags" ");" +.HP \w'void\ ne_session_socks_proxy('u +.BI "void ne_session_socks_proxy(ne_session\ *" "session" ", enum\ ne_sock_sversion\ " "version" ", const\ char\ *" "hostname" ", unsigned\ int\ " "port" ", const\ char\ *" "username" ", const\ char\ *" "password" ");" +.HP \w'void\ ne_set_addrlist('u +.BI "void ne_set_addrlist(ne_session\ *" "session" ", const\ ne_inet_addr\ **" "addrlist" ", size_t\ " "count" ");" +.SH "DESCRIPTION" +.PP +One (and no more than one) of the functions +\fBne_session_proxy\fR, +\fBne_session_system_proxy\fR, +\fBne_session_socks_proxy\fR, +\fBne_set_addrlist\fR +can be used to configure a proxy server for a given session object\&. If more than one function is invoked for any given session object, only the last call has effect\&. If one of the functions is to be used, it must be used before the creation of any request object for the session\&. +.SS "HTTP proxy specification" +.PP +The +\fBne_session_proxy\fR +function configures use of an HTTP proxy server for the session, the location of which is given by the +\fIhostname\fR +and +\fIport\fR +paramters\&. If the proxy requires authentication, +ne_set_proxy_auth +should be used\&. +.SS "System proxy configuration" +.PP +The +\fBne_session_system_proxy\fR +function configures the session to use any proxy servers specified by the system configuration\&. Support for this function is platform\-specific; if unsupported, the function has no effect\&. +.SS "SOCKS proxy configuration" +.PP +The +\fBne_session_socks_proxy\fR +function configures the session to use a SOCKS proxy\&. The +\fIversion\fR +indicates which version of the SOCKS protocol should be used\&. The +\fIhostname\fR +and +\fIport\fR +parameters specify the SOCKS proxy location\&. Note that a server with only an IPv6 address cannot be used with SOCKS v4 or v4A\&. The interpretation of the other arguments depends on the version specified: +.PP +\fBNE_SOCK_SOCKSV4\fR (version 4) +.RS 4 +The +\fIusername\fR +parameter must be non\-NULL; the +\fIpassword\fR +parameter is ignored\&. +.RE +.PP +\fBNE_SOCK_SOCKSV4A\fR (version 4A) +.RS 4 +The +\fIusername\fR +parameter must be non\-NULL; the +\fIpassword\fR +parameter is ignored\&. +.RE +.PP +\fBNE_SOCK_SOCKSV5\fR (version 5) +.RS 4 +The +\fIusername\fR +parameter may be +NULL; if it is non\-NULL, the +\fIpassword\fR +parameter must also be non\-NULL; otherwise, it is ignored\&.\&. +.RE +.SS "Origin server address override" +.PP +The +\fBne_set_addrlist\fR +function forces use of an address and port the a specified list when establishing a TCP connection, ignoring the "real" hostname and port identifying the origin server for the session (as passed to +\fBne_session_create\fR)\&. The origin server\*(Aqs "real" hostname and port will still be used in the +Host +header in HTTP requests\&. When a connection is required, the library will iterate through the +\fIaddrlist\fR +list, attempting to connect to the address +\fIaddrlist[0]\fR +through to +\fIaddrlist[count\-1]\fR +in turn, until a connection can be established\&. +.SH "RETURN VALUES" +.PP +None of the functions described here has a return value\&. +.SH "EXAMPLES" +.PP +Create and destroy a session: +.sp +.if n \{\ +.RS 4 +.\} +.nf +ne_session *sess; +sess = ne_session_create("http", "host\&.example\&.com", 80); +ne_session_proxy(sess, "proxy\&.example\&.com", 3128); +/* \&.\&.\&. use sess \&.\&.\&. */ +ne_session_destroy(sess); +.fi +.if n \{\ +.RE +.\} +.SH "SEE ALSO" +.PP +ne_ssl_set_verify, +ne_ssl_trust_cert, +ne_sock_init, +ne_set_session_flag +.SH "AUTHOR" +.PP +\fBJoe Orton\fR <\&neon@lists.manyfish.co.uk\&> +.RS 4 +Author. +.RE +.SH "COPYRIGHT" +.br diff --git a/libs/neon/doc/man/ne_session_socks_proxy.3 b/libs/neon/doc/man/ne_session_socks_proxy.3 new file mode 100644 index 00000000..923f8e0a --- /dev/null +++ b/libs/neon/doc/man/ne_session_socks_proxy.3 @@ -0,0 +1 @@ +.so man3/ne_session_proxy.3 diff --git a/libs/neon/doc/man/ne_session_system_proxy.3 b/libs/neon/doc/man/ne_session_system_proxy.3 new file mode 100644 index 00000000..923f8e0a --- /dev/null +++ b/libs/neon/doc/man/ne_session_system_proxy.3 @@ -0,0 +1 @@ +.so man3/ne_session_proxy.3 diff --git a/libs/neon/doc/man/ne_set_addrlist.3 b/libs/neon/doc/man/ne_set_addrlist.3 new file mode 100644 index 00000000..923f8e0a --- /dev/null +++ b/libs/neon/doc/man/ne_set_addrlist.3 @@ -0,0 +1 @@ +.so man3/ne_session_proxy.3 diff --git a/libs/neon/doc/man/ne_set_connect_timeout.3 b/libs/neon/doc/man/ne_set_connect_timeout.3 index 84ebba98..06ef4ae5 100644 --- a/libs/neon/doc/man/ne_set_connect_timeout.3 +++ b/libs/neon/doc/man/ne_set_connect_timeout.3 @@ -1 +1 @@ -.so ne_set_useragent.3 +.so man3/ne_set_useragent.3 diff --git a/libs/neon/doc/man/ne_set_error.3 b/libs/neon/doc/man/ne_set_error.3 index e031e073..c317579d 100644 --- a/libs/neon/doc/man/ne_set_error.3 +++ b/libs/neon/doc/man/ne_set_error.3 @@ -1 +1 @@ -.so ne_get_error.3 +.so man3/ne_get_error.3 diff --git a/libs/neon/doc/man/ne_set_proxy_auth.3 b/libs/neon/doc/man/ne_set_proxy_auth.3 index fc9de3c3..a6f0398a 100644 --- a/libs/neon/doc/man/ne_set_proxy_auth.3 +++ b/libs/neon/doc/man/ne_set_proxy_auth.3 @@ -1 +1 @@ -.so ne_set_server_auth.3 +.so man3/ne_set_server_auth.3 diff --git a/libs/neon/doc/man/ne_set_read_timeout.3 b/libs/neon/doc/man/ne_set_read_timeout.3 index 84ebba98..06ef4ae5 100644 --- a/libs/neon/doc/man/ne_set_read_timeout.3 +++ b/libs/neon/doc/man/ne_set_read_timeout.3 @@ -1 +1 @@ -.so ne_set_useragent.3 +.so man3/ne_set_useragent.3 diff --git a/libs/neon/doc/man/ne_set_request_body_buffer.3 b/libs/neon/doc/man/ne_set_request_body_buffer.3 index 46691651..d3c67c48 100644 --- a/libs/neon/doc/man/ne_set_request_body_buffer.3 +++ b/libs/neon/doc/man/ne_set_request_body_buffer.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_set_request_body_buffer .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_SET_REQUEST_BODY_" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_SET_REQUEST_BODY_" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_set_request_body_fd.3 b/libs/neon/doc/man/ne_set_request_body_fd.3 index 07a18fdc..42452bee 100644 --- a/libs/neon/doc/man/ne_set_request_body_fd.3 +++ b/libs/neon/doc/man/ne_set_request_body_fd.3 @@ -1 +1 @@ -.so ne_set_request_body_buffer.3 +.so man3/ne_set_request_body_buffer.3 diff --git a/libs/neon/doc/man/ne_set_request_body_fd64.3 b/libs/neon/doc/man/ne_set_request_body_fd64.3 index 07a18fdc..42452bee 100644 --- a/libs/neon/doc/man/ne_set_request_body_fd64.3 +++ b/libs/neon/doc/man/ne_set_request_body_fd64.3 @@ -1 +1 @@ -.so ne_set_request_body_buffer.3 +.so man3/ne_set_request_body_buffer.3 diff --git a/libs/neon/doc/man/ne_set_request_flag.3 b/libs/neon/doc/man/ne_set_request_flag.3 index 23bdfa2f..c6e9e3d9 100644 --- a/libs/neon/doc/man/ne_set_request_flag.3 +++ b/libs/neon/doc/man/ne_set_request_flag.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_set_request_flag .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_SET_REQUEST_FLAG" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_SET_REQUEST_FLAG" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_set_server_auth.3 b/libs/neon/doc/man/ne_set_server_auth.3 index cf08a653..81dd0542 100644 --- a/libs/neon/doc/man/ne_set_server_auth.3 +++ b/libs/neon/doc/man/ne_set_server_auth.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_set_server_auth .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_SET_SERVER_AUTH" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_SET_SERVER_AUTH" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_set_session_flag.3 b/libs/neon/doc/man/ne_set_session_flag.3 index fe38fcf0..17653127 100644 --- a/libs/neon/doc/man/ne_set_session_flag.3 +++ b/libs/neon/doc/man/ne_set_session_flag.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_set_session_flag .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_SET_SESSION_FLAG" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_SET_SESSION_FLAG" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_set_useragent.3 b/libs/neon/doc/man/ne_set_useragent.3 index b70cd66b..2e912389 100644 --- a/libs/neon/doc/man/ne_set_useragent.3 +++ b/libs/neon/doc/man/ne_set_useragent.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_set_useragent .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_SET_USERAGENT" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_SET_USERAGENT" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_shave.3 b/libs/neon/doc/man/ne_shave.3 index 230837cc..36c59fe2 100644 --- a/libs/neon/doc/man/ne_shave.3 +++ b/libs/neon/doc/man/ne_shave.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_shave .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_SHAVE" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_SHAVE" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_sock_exit.3 b/libs/neon/doc/man/ne_sock_exit.3 index 33cc4ce3..e8666954 100644 --- a/libs/neon/doc/man/ne_sock_exit.3 +++ b/libs/neon/doc/man/ne_sock_exit.3 @@ -1 +1 @@ -.so ne_sock_init.3 +.so man3/ne_sock_init.3 diff --git a/libs/neon/doc/man/ne_sock_init.3 b/libs/neon/doc/man/ne_sock_init.3 index 70dde783..c07f4018 100644 --- a/libs/neon/doc/man/ne_sock_init.3 +++ b/libs/neon/doc/man/ne_sock_init.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_sock_init .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_SOCK_INIT" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_SOCK_INIT" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_ssl_cert_cmp.3 b/libs/neon/doc/man/ne_ssl_cert_cmp.3 index 67a8df61..53fd3e09 100644 --- a/libs/neon/doc/man/ne_ssl_cert_cmp.3 +++ b/libs/neon/doc/man/ne_ssl_cert_cmp.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_ssl_cert_cmp .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_SSL_CERT_CMP" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_SSL_CERT_CMP" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_ssl_cert_export.3 b/libs/neon/doc/man/ne_ssl_cert_export.3 index 709cc083..9c92144a 100644 --- a/libs/neon/doc/man/ne_ssl_cert_export.3 +++ b/libs/neon/doc/man/ne_ssl_cert_export.3 @@ -1 +1 @@ -.so ne_ssl_cert_read.3 +.so man3/ne_ssl_cert_read.3 diff --git a/libs/neon/doc/man/ne_ssl_cert_free.3 b/libs/neon/doc/man/ne_ssl_cert_free.3 index 60a5e59b..208e0df8 100644 --- a/libs/neon/doc/man/ne_ssl_cert_free.3 +++ b/libs/neon/doc/man/ne_ssl_cert_free.3 @@ -1 +1 @@ -.so ne_ssl_cert_cmp.3 +.so man3/ne_ssl_cert_cmp.3 diff --git a/libs/neon/doc/man/ne_ssl_cert_identity.3 b/libs/neon/doc/man/ne_ssl_cert_identity.3 index eb18ff24..fe66cf18 100644 --- a/libs/neon/doc/man/ne_ssl_cert_identity.3 +++ b/libs/neon/doc/man/ne_ssl_cert_identity.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_ssl_cert_identity .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_SSL_CERT_IDENTITY" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_SSL_CERT_IDENTITY" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_ssl_cert_import.3 b/libs/neon/doc/man/ne_ssl_cert_import.3 index 709cc083..9c92144a 100644 --- a/libs/neon/doc/man/ne_ssl_cert_import.3 +++ b/libs/neon/doc/man/ne_ssl_cert_import.3 @@ -1 +1 @@ -.so ne_ssl_cert_read.3 +.so man3/ne_ssl_cert_read.3 diff --git a/libs/neon/doc/man/ne_ssl_cert_issuer.3 b/libs/neon/doc/man/ne_ssl_cert_issuer.3 index ff5e7574..e752f389 100644 --- a/libs/neon/doc/man/ne_ssl_cert_issuer.3 +++ b/libs/neon/doc/man/ne_ssl_cert_issuer.3 @@ -1 +1 @@ -.so ne_ssl_cert_identity.3 +.so man3/ne_ssl_cert_identity.3 diff --git a/libs/neon/doc/man/ne_ssl_cert_read.3 b/libs/neon/doc/man/ne_ssl_cert_read.3 index b9b25987..406bcabd 100644 --- a/libs/neon/doc/man/ne_ssl_cert_read.3 +++ b/libs/neon/doc/man/ne_ssl_cert_read.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_ssl_cert_read .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_SSL_CERT_READ" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_SSL_CERT_READ" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_ssl_cert_signedby.3 b/libs/neon/doc/man/ne_ssl_cert_signedby.3 index ff5e7574..e752f389 100644 --- a/libs/neon/doc/man/ne_ssl_cert_signedby.3 +++ b/libs/neon/doc/man/ne_ssl_cert_signedby.3 @@ -1 +1 @@ -.so ne_ssl_cert_identity.3 +.so man3/ne_ssl_cert_identity.3 diff --git a/libs/neon/doc/man/ne_ssl_cert_subject.3 b/libs/neon/doc/man/ne_ssl_cert_subject.3 index ff5e7574..e752f389 100644 --- a/libs/neon/doc/man/ne_ssl_cert_subject.3 +++ b/libs/neon/doc/man/ne_ssl_cert_subject.3 @@ -1 +1 @@ -.so ne_ssl_cert_identity.3 +.so man3/ne_ssl_cert_identity.3 diff --git a/libs/neon/doc/man/ne_ssl_cert_write.3 b/libs/neon/doc/man/ne_ssl_cert_write.3 index 709cc083..9c92144a 100644 --- a/libs/neon/doc/man/ne_ssl_cert_write.3 +++ b/libs/neon/doc/man/ne_ssl_cert_write.3 @@ -1 +1 @@ -.so ne_ssl_cert_read.3 +.so man3/ne_ssl_cert_read.3 diff --git a/libs/neon/doc/man/ne_ssl_clicert_decrypt.3 b/libs/neon/doc/man/ne_ssl_clicert_decrypt.3 index 71f63072..f9f7d9c8 100644 --- a/libs/neon/doc/man/ne_ssl_clicert_decrypt.3 +++ b/libs/neon/doc/man/ne_ssl_clicert_decrypt.3 @@ -1 +1 @@ -.so ne_ssl_clicert_read.3 +.so man3/ne_ssl_clicert_read.3 diff --git a/libs/neon/doc/man/ne_ssl_clicert_encrypted.3 b/libs/neon/doc/man/ne_ssl_clicert_encrypted.3 index 71f63072..f9f7d9c8 100644 --- a/libs/neon/doc/man/ne_ssl_clicert_encrypted.3 +++ b/libs/neon/doc/man/ne_ssl_clicert_encrypted.3 @@ -1 +1 @@ -.so ne_ssl_clicert_read.3 +.so man3/ne_ssl_clicert_read.3 diff --git a/libs/neon/doc/man/ne_ssl_clicert_free.3 b/libs/neon/doc/man/ne_ssl_clicert_free.3 index 71f63072..f9f7d9c8 100644 --- a/libs/neon/doc/man/ne_ssl_clicert_free.3 +++ b/libs/neon/doc/man/ne_ssl_clicert_free.3 @@ -1 +1 @@ -.so ne_ssl_clicert_read.3 +.so man3/ne_ssl_clicert_read.3 diff --git a/libs/neon/doc/man/ne_ssl_clicert_name.3 b/libs/neon/doc/man/ne_ssl_clicert_name.3 index 71f63072..f9f7d9c8 100644 --- a/libs/neon/doc/man/ne_ssl_clicert_name.3 +++ b/libs/neon/doc/man/ne_ssl_clicert_name.3 @@ -1 +1 @@ -.so ne_ssl_clicert_read.3 +.so man3/ne_ssl_clicert_read.3 diff --git a/libs/neon/doc/man/ne_ssl_clicert_owner.3 b/libs/neon/doc/man/ne_ssl_clicert_owner.3 index 71f63072..f9f7d9c8 100644 --- a/libs/neon/doc/man/ne_ssl_clicert_owner.3 +++ b/libs/neon/doc/man/ne_ssl_clicert_owner.3 @@ -1 +1 @@ -.so ne_ssl_clicert_read.3 +.so man3/ne_ssl_clicert_read.3 diff --git a/libs/neon/doc/man/ne_ssl_clicert_read.3 b/libs/neon/doc/man/ne_ssl_clicert_read.3 index fb730ac5..540ece4c 100644 --- a/libs/neon/doc/man/ne_ssl_clicert_read.3 +++ b/libs/neon/doc/man/ne_ssl_clicert_read.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_ssl_client_cert .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_SSL_CLIENT_CERT" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_SSL_CLIENT_CERT" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_ssl_dname_cmp.3 b/libs/neon/doc/man/ne_ssl_dname_cmp.3 index 79c41bab..d2a16c23 100644 --- a/libs/neon/doc/man/ne_ssl_dname_cmp.3 +++ b/libs/neon/doc/man/ne_ssl_dname_cmp.3 @@ -1 +1 @@ -.so ne_ssl_readable_dname.3 +.so man3/ne_ssl_readable_dname.3 diff --git a/libs/neon/doc/man/ne_ssl_readable_dname.3 b/libs/neon/doc/man/ne_ssl_readable_dname.3 index 07f78e24..86694e81 100644 --- a/libs/neon/doc/man/ne_ssl_readable_dname.3 +++ b/libs/neon/doc/man/ne_ssl_readable_dname.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_ssl_dname .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_SSL_DNAME" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_SSL_DNAME" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_ssl_set_verify.3 b/libs/neon/doc/man/ne_ssl_set_verify.3 index 008a22da..ddaba510 100644 --- a/libs/neon/doc/man/ne_ssl_set_verify.3 +++ b/libs/neon/doc/man/ne_ssl_set_verify.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_ssl_set_verify .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_SSL_SET_VERIFY" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_SSL_SET_VERIFY" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_ssl_trust_cert.3 b/libs/neon/doc/man/ne_ssl_trust_cert.3 index d261a4bd..685eca5e 100644 --- a/libs/neon/doc/man/ne_ssl_trust_cert.3 +++ b/libs/neon/doc/man/ne_ssl_trust_cert.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_ssl_trust_cert .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_SSL_TRUST_CERT" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_SSL_TRUST_CERT" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_ssl_trust_default_ca.3 b/libs/neon/doc/man/ne_ssl_trust_default_ca.3 index 107af479..49af8c56 100644 --- a/libs/neon/doc/man/ne_ssl_trust_default_ca.3 +++ b/libs/neon/doc/man/ne_ssl_trust_default_ca.3 @@ -1 +1 @@ -.so ne_ssl_trust_cert.3 +.so man3/ne_ssl_trust_cert.3 diff --git a/libs/neon/doc/man/ne_status.3 b/libs/neon/doc/man/ne_status.3 index 3ee01f4b..59c9f49e 100644 --- a/libs/neon/doc/man/ne_status.3 +++ b/libs/neon/doc/man/ne_status.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_status .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_STATUS" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_STATUS" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_strdup.3 b/libs/neon/doc/man/ne_strdup.3 index 1ce5ecca..8564fc1a 100644 --- a/libs/neon/doc/man/ne_strdup.3 +++ b/libs/neon/doc/man/ne_strdup.3 @@ -1 +1 @@ -.so ne_malloc.3 +.so man3/ne_malloc.3 diff --git a/libs/neon/doc/man/ne_strndup.3 b/libs/neon/doc/man/ne_strndup.3 index 1ce5ecca..8564fc1a 100644 --- a/libs/neon/doc/man/ne_strndup.3 +++ b/libs/neon/doc/man/ne_strndup.3 @@ -1 +1 @@ -.so ne_malloc.3 +.so man3/ne_malloc.3 diff --git a/libs/neon/doc/man/ne_token.3 b/libs/neon/doc/man/ne_token.3 index 463e7798..144c5b3f 100644 --- a/libs/neon/doc/man/ne_token.3 +++ b/libs/neon/doc/man/ne_token.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_token .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_TOKEN" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_TOKEN" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_version_match.3 b/libs/neon/doc/man/ne_version_match.3 index 7cf212b1..e992d561 100644 --- a/libs/neon/doc/man/ne_version_match.3 +++ b/libs/neon/doc/man/ne_version_match.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_version_match .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_VERSION_MATCH" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_VERSION_MATCH" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_version_string.3 b/libs/neon/doc/man/ne_version_string.3 index d5d73540..4f3447d9 100644 --- a/libs/neon/doc/man/ne_version_string.3 +++ b/libs/neon/doc/man/ne_version_string.3 @@ -1 +1 @@ -.so ne_version_match.3 +.so man3/ne_version_match.3 diff --git a/libs/neon/doc/man/ne_xml_create.3 b/libs/neon/doc/man/ne_xml_create.3 index 3eefd7b8..6134bec5 100644 --- a/libs/neon/doc/man/ne_xml_create.3 +++ b/libs/neon/doc/man/ne_xml_create.3 @@ -1,13 +1,13 @@ '\" t .\" Title: ne_xml_create .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NE_XML_CREATE" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NE_XML_CREATE" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/ne_xml_destroy.3 b/libs/neon/doc/man/ne_xml_destroy.3 index 57fdc72b..e601ac3d 100644 --- a/libs/neon/doc/man/ne_xml_destroy.3 +++ b/libs/neon/doc/man/ne_xml_destroy.3 @@ -1 +1 @@ -.so ne_xml_create.3 +.so man3/ne_xml_create.3 diff --git a/libs/neon/doc/man/neon-config.1 b/libs/neon/doc/man/neon-config.1 index fdbcb9c6..5575a432 100644 --- a/libs/neon/doc/man/neon-config.1 +++ b/libs/neon/doc/man/neon-config.1 @@ -1,13 +1,13 @@ '\" t .\" Title: neon-config .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NEON\-CONFIG" "1" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NEON\-CONFIG" "1" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/man/neon.3 b/libs/neon/doc/man/neon.3 index b1f66829..a6b005fa 100644 --- a/libs/neon/doc/man/neon.3 +++ b/libs/neon/doc/man/neon.3 @@ -1,13 +1,13 @@ '\" t .\" Title: neon .\" Author: -.\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 3 May 2011 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 31 July 2013 .\" Manual: neon API reference -.\" Source: neon 0.29.6 +.\" Source: neon 0.30.0 .\" Language: English .\" -.TH "NEON" "3" "3 May 2011" "neon 0.29.6" "neon API reference" +.TH "NEON" "3" "31 July 2013" "neon 0.30.0" "neon API reference" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/libs/neon/doc/manual.xml b/libs/neon/doc/manual.xml index 82f669c6..a6bb531b 100644 --- a/libs/neon/doc/manual.xml +++ b/libs/neon/doc/manual.xml @@ -44,6 +44,7 @@ + @@ -176,6 +177,7 @@ ignoring the WebDAV support if desired. &refiaddr; &refalloc; &refsess; + &refproxy; &refsessflags; &refreq; &refreqhdr; diff --git a/libs/neon/doc/ref/proxy.xml b/libs/neon/doc/ref/proxy.xml new file mode 100644 index 00000000..7a410c78 --- /dev/null +++ b/libs/neon/doc/ref/proxy.xml @@ -0,0 +1,176 @@ + + + + ne_session_proxy + 3 + + + + ne_session_proxy + ne_session_socks_proxy + ne_session_system_proxy + ne_set_addrlist + configure proxy servers + + + + + + #include <ne_session.h> + + + void ne_session_proxy + ne_session *session + const char *hostname + unsigned int port + + + + void ne_session_system_proxy + ne_session *session + unsigned int flags + + + + void ne_session_socks_proxy + ne_session *session + enum ne_sock_sversion version + const char *hostname + unsigned int port + const char *username + const char *password + + + + void ne_set_addrlist + ne_session *session + const ne_inet_addr **addrlist + size_t count + + + + + + + Description + + One (and no more than one) of the functions + ne_session_proxy, + ne_session_system_proxy, + ne_session_socks_proxy, + ne_set_addrlist can be used to configure + a proxy server for a given session object. If more than one + function is invoked for any given session object, only the + last call has effect. If one of the functions is to be used, + it must be used before the creation of any request object for + the session. + + + HTTP proxy specification + + The ne_session_proxy function + configures use of an HTTP proxy server for the session, the + location of which is given by the + hostname and + port paramters. If the proxy + requires authentication, + should be used. + + + + System proxy configuration + + The ne_session_system_proxy + function configures the session to use any proxy servers + specified by the system configuration. Support for this + function is platform-specific; if unsupported, the function + has no effect. + + + + SOCKS proxy configuration + + The ne_session_socks_proxy + function configures the session to use a SOCKS proxy. The + version indicates which version of + the SOCKS protocol should be used. The + hostname and + port parameters specify the SOCKS + proxy location. Note that a server with only an IPv6 + address cannot be used with SOCKS v4 or v4A. The + interpretation of the other arguments depends on the version + specified: + + + NE_SOCK_SOCKSV4 (version 4) + + The username parameter + must be non-&null;; the password + parameter is ignored. + + + + NE_SOCK_SOCKSV4A (version 4A) + + The username parameter + must be non-&null;; the password + parameter is ignored. + + + + NE_SOCK_SOCKSV5 (version 5) + + The username parameter + may be &null;; if it is non-&null;, + the password parameter must also + be non-&null;; otherwise, it is ignored.. + + + + + + + + Origin server address override + + The ne_set_addrlist function + forces use of an address and port the a specified list when + establishing a TCP connection, ignoring the "real" hostname + and port identifying the origin server for the session (as + passed to ne_session_create). The + origin server's "real" hostname and port will still be used + in the Host header in HTTP requests. + When a connection is required, the library will iterate + through the addrlist list, attempting + to connect to the address addrlist[0] + through to addrlist[count-1] in turn, + until a connection can be established. + + + + + + + Return Values + None of the functions described here has a return + value. + + + + Examples + Create and destroy a session: + ne_session *sess; +sess = ne_session_create("http", "host.example.com", 80); +ne_session_proxy(sess, "proxy.example.com", 3128); +/* ... use sess ... */ +ne_session_destroy(sess); + + + + + See Also + + , , , + + + diff --git a/libs/neon/doc/ref/req.xml b/libs/neon/doc/ref/req.xml index cfcd456c..b2d754de 100644 --- a/libs/neon/doc/ref/req.xml +++ b/libs/neon/doc/ref/req.xml @@ -41,14 +41,14 @@ Description - An HTTP request, represented by the -ne_request type, specifies that some operation is to be -performed on some resource. The -ne_request_create function creates a request -object, specifying the operation in the method -parameter. The location of the resource is determined by the server in -use for the session given by the sess -parameter, combined with the path parameter. + The ne_request object represents an HTTP + request and the associated response. + The ne_request_create function creates a + new request object for the + given session. The target resource for + the request is identified by the path, + and the method to be performed on that resource via + the method parameter. The path string used must conform to the abs_path definition given in RFC2396, with an diff --git a/libs/neon/doc/ref/sess.xml b/libs/neon/doc/ref/sess.xml index 8c407abb..8ff6358b 100644 --- a/libs/neon/doc/ref/sess.xml +++ b/libs/neon/doc/ref/sess.xml @@ -8,7 +8,6 @@ ne_session_create ne_close_connection - ne_session_proxy ne_session_destroy set up HTTP sessions @@ -24,13 +23,6 @@ unsigned int port - - void ne_session_proxy - ne_session *session - const char *hostname - unsigned int port - - void ne_close_connection ne_session *session @@ -53,14 +45,15 @@ certain server. Any requests made using the session can use a persistent connection, share cached authentication credentials and any other common attributes. - A new HTTP session is created using -ne_session_create, giving the -hostname and port of the -server to use, along with the scheme used to -contact the server (usually "http"). Before the -first use of ne_session_create in a process, - must have been called to perform any -global initialization needed by any libraries used by &neon;. + A new HTTP session is created using the +ne_session_create function; the +hostname and port +parameters specify the origin server to use, along with +the scheme (usually "http"). +Before the first use of ne_session_create in a +process, must have been called to +perform any global initialization needed by any libraries used by +&neon;. To enable SSL/TLS for the session, pass the string "https" as the scheme @@ -69,12 +62,12 @@ parameter, and either register a certificate verification function certificate (see , ). - If an HTTP proxy server should be used for the session, - ne_session_proxy must be called giving - the hostname and port on which to contact the proxy. + To use a proxy server for the session, it must be + configured (see ) before any + requests are created from session object. Further per-session options may be changed using the - interface. + interface. If it is known that the session will not be used for a significant period of time, ne_close_connection @@ -83,9 +76,12 @@ this function is entirely optional, but it must not be called if there is a request active using the session. Once a session has been completed, -ne_session_destroy must be called to destroy the -resources associated with the session. Any subsequent use of the -session pointer produces undefined behaviour. + ne_session_destroy must be called to + destroy the resources associated with the session. Any + subsequent use of the session pointer produces undefined + behaviour. The session object must not be destroyed until + after all associated request objects have been + destroyed. diff --git a/libs/neon/doc/version.xml b/libs/neon/doc/version.xml index 9c2255d5..065d469b 100644 --- a/libs/neon/doc/version.xml +++ b/libs/neon/doc/version.xml @@ -1 +1 @@ -0.29.6 \ No newline at end of file +0.30.0 \ No newline at end of file diff --git a/libs/neon/install-sh b/libs/neon/install-sh index 6781b987..a9244eb0 100644 --- a/libs/neon/install-sh +++ b/libs/neon/install-sh @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2009-04-28.21; # UTC +scriptversion=2011-01-19.21; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -156,6 +156,10 @@ while test $# -ne 0; do -s) stripcmd=$stripprog;; -t) dst_arg=$2 + # Protect names problematic for `test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac shift;; -T) no_target_directory=true;; @@ -186,6 +190,10 @@ if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then fi shift # arg dst_arg=$arg + # Protect names problematic for `test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac done fi @@ -200,7 +208,11 @@ if test $# -eq 0; then fi if test -z "$dir_arg"; then - trap '(exit $?); exit' 1 2 13 15 + do_exit='(exit $ret); exit $ret' + trap "ret=129; $do_exit" 1 + trap "ret=130; $do_exit" 2 + trap "ret=141; $do_exit" 13 + trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. @@ -228,9 +240,9 @@ fi for src do - # Protect names starting with `-'. + # Protect names problematic for `test' and other utilities. case $src in - -*) src=./$src;; + -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then @@ -252,12 +264,7 @@ do echo "$0: no destination specified." >&2 exit 1 fi - dst=$dst_arg - # Protect names starting with `-'. - case $dst in - -*) dst=./$dst;; - esac # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. @@ -385,7 +392,7 @@ do case $dstdir in /*) prefix='/';; - -*) prefix='./';; + [-=\(\)!]*) prefix='./';; *) prefix='';; esac @@ -403,7 +410,7 @@ do for d do - test -z "$d" && continue + test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then diff --git a/libs/neon/libneon.vcxproj b/libs/neon/libneon.vcxproj deleted file mode 100644 index 71ab0598..00000000 --- a/libs/neon/libneon.vcxproj +++ /dev/null @@ -1,289 +0,0 @@ - - - - - Template - Win32 - - - Template - x64 - - - UnityDebug - Win32 - - - UnityDebug - x64 - - - UnityRelease - Win32 - - - UnityRelease - x64 - - - - {90DE9ADC-75C4-2AC0-72B1-5F2903110E0A} - libneon - - - - Application - - - Application - - - StaticLibrary - false - MultiByte - - - StaticLibrary - false - MultiByte - - - StaticLibrary - false - MultiByte - - - StaticLibrary - false - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - - - - - .\..\..\Temp\$(SolutionName)\$(Configuration)\x86\$(ProjectName)\ - .\..\..\Temp\$(SolutionName)\$(Configuration)\x86\$(ProjectName)\ - - - .\..\..\Temp\$(SolutionName)\$(Configuration)\x64\$(ProjectName)\ - .\..\..\Temp\$(SolutionName)\$(Configuration)\x64\$(ProjectName)\ - - - .\..\..\Temp\$(SolutionName)\$(Configuration)\x86\$(ProjectName)\ - .\..\..\Temp\$(SolutionName)\$(Configuration)\x86\$(ProjectName)\ - - - .\..\..\Temp\$(SolutionName)\$(Configuration)\x64\$(ProjectName)\ - .\..\..\Temp\$(SolutionName)\$(Configuration)\x64\$(ProjectName)\ - - - - MultiThreadedDebug - Default - false - Disabled - true - Level3 - EditAndContinue - WIN32;_DEBUG;_WINDOWS;_LIB;NE_HAVE_SSL;HAVE_OPENSSL;HAVE_EXPAT;HAVE_EXPAT_H;NE_HAVE_DAV;NE_HAVE_ZLIB;USE_GETADDRINFO;WIN32_LEAN_AND_MEAN;NOUSER;NOGDI;NONLS;NOCRYPT;_CRT_SECURE_NO_WARNINGS;XML_STATIC;%(PreprocessorDefinitions) - .\..\..\Temp\$(SolutionName)\$(Configuration)\x86\$(ProjectName)\ - true - .\..\..\Temp\$(SolutionName)\$(Configuration)\x86\$(ProjectName)\libneon.pch - .\..\..\Temp\$(SolutionName)\$(Configuration)\x86\$(ProjectName)\ - .\..\..\Temp\$(SolutionName)\$(Configuration)\x86\$(ProjectName)\ - EnableFastChecks - src;..\openssl\x86\inc32;..\expat\lib;..\zlib\src;%(AdditionalIncludeDirectories) - 4996 - - - 0x0409 - _DEBUG;%(PreprocessorDefinitions) - - - true - .\..\..\Temp\$(SolutionName)\$(Configuration)\x86\$(ProjectName)\libneon.bsc - - - true - .\..\..\Temp\$(SolutionName)\$(Configuration)\x86\$(ProjectName)\libneon.lib - - - - - MultiThreadedDebug - Default - false - Disabled - true - Level3 - ProgramDatabase - WIN32;WIN64;_DEBUG;_WINDOWS;_LIB;NE_HAVE_SSL;HAVE_OPENSSL;HAVE_EXPAT;HAVE_EXPAT_H;NE_HAVE_DAV;NE_HAVE_ZLIB;USE_GETADDRINFO;WIN32_LEAN_AND_MEAN;NOUSER;NOGDI;NONLS;NOCRYPT;_CRT_SECURE_NO_WARNINGS;XML_STATIC;%(PreprocessorDefinitions) - .\..\..\Temp\$(SolutionName)\$(Configuration)\x64\$(ProjectName)\ - true - .\..\..\Temp\$(SolutionName)\$(Configuration)\x64\$(ProjectName)\libneon.pch - .\..\..\Temp\$(SolutionName)\$(Configuration)\x64\$(ProjectName)\ - .\..\..\Temp\$(SolutionName)\$(Configuration)\x64\$(ProjectName)\ - EnableFastChecks - src;..\openssl\x64\inc32;..\expat\lib;..\zlib\src;%(AdditionalIncludeDirectories) - 4996 - - - 0x0409 - _DEBUG;%(PreprocessorDefinitions) - - - true - .\..\..\Temp\$(SolutionName)\$(Configuration)\x64\$(ProjectName)\libneon.bsc - - - true - .\..\..\Temp\$(SolutionName)\$(Configuration)\x64\$(ProjectName)\libneon.lib - - - - - MultiThreaded - OnlyExplicitInline - true - true - MaxSpeed - true - Level3 - WIN32;_WINDOWS;NDEBUG;_LIB;NE_HAVE_SSL;HAVE_OPENSSL;HAVE_EXPAT;HAVE_EXPAT_H;NE_HAVE_DAV;NE_HAVE_ZLIB;USE_GETADDRINFO;WIN32_LEAN_AND_MEAN;NOUSER;NOGDI;NONLS;NOCRYPT;_CRT_SECURE_NO_WARNINGS;XML_STATIC;%(PreprocessorDefinitions) - .\..\..\Temp\$(SolutionName)\$(Configuration)\x86\$(ProjectName)\ - .\..\..\Temp\$(SolutionName)\$(Configuration)\x86\$(ProjectName)\libneon.pch - .\..\..\Temp\$(SolutionName)\$(Configuration)\x86\$(ProjectName)\ - .\..\..\Temp\$(SolutionName)\$(Configuration)\x86\$(ProjectName)\ - src;..\openssl\x86\inc32;..\expat\lib;..\zlib\src;%(AdditionalIncludeDirectories) - 4996 - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\..\..\Temp\$(SolutionName)\$(Configuration)\x86\$(ProjectName)\libneon.bsc - - - true - .\..\..\Temp\$(SolutionName)\$(Configuration)\x86\$(ProjectName)\libneon.lib - - - - - MultiThreaded - OnlyExplicitInline - true - true - MaxSpeed - true - Level3 - WIN32;WIN64;_WINDOWS;NDEBUG;_LIB;NE_HAVE_SSL;HAVE_OPENSSL;HAVE_EXPAT;HAVE_EXPAT_H;NE_HAVE_DAV;NE_HAVE_ZLIB;USE_GETADDRINFO;WIN32_LEAN_AND_MEAN;NOUSER;NOGDI;NONLS;NOCRYPT;_CRT_SECURE_NO_WARNINGS;XML_STATIC;%(PreprocessorDefinitions) - .\..\..\Temp\$(SolutionName)\$(Configuration)\x64\$(ProjectName)\ - .\..\..\Temp\$(SolutionName)\$(Configuration)\x64\$(ProjectName)\libneon.pch - .\..\..\Temp\$(SolutionName)\$(Configuration)\x64\$(ProjectName)\ - .\..\..\Temp\$(SolutionName)\$(Configuration)\x64\$(ProjectName)\ - src;..\openssl\x64\inc32;..\expat\lib;..\zlib\src;%(AdditionalIncludeDirectories) - 4996 - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\..\..\Temp\$(SolutionName)\$(Configuration)\x64\$(ProjectName)\libneon.bsc - - - true - .\..\..\Temp\$(SolutionName)\$(Configuration)\x64\$(ProjectName)\libneon.lib - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/libs/neon/ltmain.sh b/libs/neon/ltmain.sh index d8efb57b..63ae69dc 100644 --- a/libs/neon/ltmain.sh +++ b/libs/neon/ltmain.sh @@ -1,10 +1,9 @@ -# Generated from ltmain.m4sh. -# libtool (GNU libtool) 2.2.10 +# libtool (GNU libtool) 2.4.2 # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, -# 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. @@ -42,6 +41,7 @@ # --quiet, --silent don't print informational messages # --no-quiet, --no-silent # print informational messages (default) +# --no-warn don't display warning messages # --tag=TAG use configuration variables from tag TAG # -v, --verbose print more informational messages than default # --no-verbose don't print the extra informational messages @@ -70,17 +70,19 @@ # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) -# $progname: (GNU libtool) 2.2.10 +# $progname: (GNU libtool) 2.4.2 # automake: $automake_version # autoconf: $autoconf_version # # Report bugs to . +# GNU libtool home page: . +# General help using GNU software: . PROGRAM=libtool PACKAGE=libtool -VERSION=2.2.10 +VERSION=2.4.2 TIMESTAMP="" -package_revision=1.3175 +package_revision=1.3337 # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then @@ -135,15 +137,10 @@ progpath="$0" : ${CP="cp -f"} test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} -: ${EGREP="/bin/grep -E"} -: ${FGREP="/bin/grep -F"} -: ${GREP="/bin/grep"} -: ${LN_S="ln -s"} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} -: ${SED="/bin/sed"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} : ${Xsed="$SED -e 1s/^X//"} @@ -163,6 +160,27 @@ IFS=" $lt_nl" dirname="s,/[^/]*$,," basename="s,^.*/,," +# func_dirname file append nondir_replacement +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +func_dirname () +{ + func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` + if test "X$func_dirname_result" = "X${1}"; then + func_dirname_result="${3}" + else + func_dirname_result="$func_dirname_result${2}" + fi +} # func_dirname may be replaced by extended shell implementation + + +# func_basename file +func_basename () +{ + func_basename_result=`$ECHO "${1}" | $SED "$basename"` +} # func_basename may be replaced by extended shell implementation + + # func_dirname_and_basename file append nondir_replacement # perform func_basename and func_dirname in a single function # call: @@ -177,17 +195,31 @@ basename="s,^.*/,," # those functions but instead duplicate the functionality here. func_dirname_and_basename () { - # Extract subdirectory from the argument. - func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" - fi - func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` -} + # Extract subdirectory from the argument. + func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` + if test "X$func_dirname_result" = "X${1}"; then + func_dirname_result="${3}" + else + func_dirname_result="$func_dirname_result${2}" + fi + func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` +} # func_dirname_and_basename may be replaced by extended shell implementation + + +# func_stripname prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +# func_strip_suffix prefix name +func_stripname () +{ + case ${2} in + .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; + *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; + esac +} # func_stripname may be replaced by extended shell implementation -# Generated shell functions inserted here. # These SED scripts presuppose an absolute path with a trailing slash. pathcar='s,^/\([^/]*\).*$,\1,' @@ -351,7 +383,7 @@ case $progpath in ;; *) save_IFS="$IFS" - IFS=: + IFS=${PATH_SEPARATOR-:} for progdir in $PATH; do IFS="$save_IFS" test -x "$progdir/$progname" && break @@ -370,6 +402,15 @@ sed_quote_subst='s/\([`"$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' +# Sed substitution that turns a string into a regex matching for the +# string literally. +sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' + +# Sed substitution that converts a w32 file name or path +# which contains forward slashes, into one that contains +# (escaped) backslashes. A very naive implementation. +lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' + # Re-`\' parameter expansions in output of double_quote_subst that were # `\'-ed in input to the same. If an odd number of `\' preceded a '$' # in input to double_quote_subst, that '$' was protected from expansion. @@ -398,7 +439,7 @@ opt_warning=: # name if it has been set yet. func_echo () { - $ECHO "$progname${mode+: }$mode: $*" + $ECHO "$progname: ${opt_mode+$opt_mode: }$*" } # func_verbose arg... @@ -424,14 +465,14 @@ func_echo_all () # Echo program name prefixed message to standard error. func_error () { - $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2 + $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 } # func_warning arg... # Echo program name prefixed warning message to standard error. func_warning () { - $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2 + $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 # bash bug again: : @@ -650,11 +691,30 @@ func_show_eval_locale () fi } +# func_tr_sh +# Turn $1 into a string suitable for a shell variable name. +# Result is stored in $func_tr_sh_result. All characters +# not in the set a-zA-Z0-9_ are replaced with '_'. Further, +# if $1 begins with a digit, a '_' is prepended as well. +func_tr_sh () +{ + case $1 in + [0-9]* | *[!a-zA-Z0-9_]*) + func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` + ;; + * ) + func_tr_sh_result=$1 + ;; + esac +} + # func_version # Echo version message to standard output and exit. func_version () { + $opt_debug + $SED -n '/(C)/!b go :more /\./!{ @@ -676,6 +736,8 @@ func_version () # Echo short help message to standard output and exit. func_usage () { + $opt_debug + $SED -n '/^# Usage:/,/^# *.*--help/ { s/^# // s/^# *$// @@ -692,7 +754,10 @@ func_usage () # unless 'noexit' is passed as argument. func_help () { + $opt_debug + $SED -n '/^# Usage:/,/# Report bugs to/ { + :print s/^# // s/^# *$// s*\$progname*'$progname'* @@ -702,10 +767,14 @@ func_help () s*\$LTCFLAGS*'"$LTCFLAGS"'* s*\$LD*'"$LD"'* s/\$with_gnu_ld/'"$with_gnu_ld"'/ - s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ - s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ + s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ + s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ p - }' < "$progpath" + d + } + /^# .* home page:/b print + /^# General help using/b print + ' < "$progpath" ret=$? if test -z "$1"; then exit $ret @@ -717,12 +786,39 @@ func_help () # exit_cmd. func_missing_arg () { + $opt_debug + func_error "missing argument for $1." exit_cmd=exit } -exit_cmd=: +# func_split_short_opt shortopt +# Set func_split_short_opt_name and func_split_short_opt_arg shell +# variables after splitting SHORTOPT after the 2nd character. +func_split_short_opt () +{ + my_sed_short_opt='1s/^\(..\).*$/\1/;q' + my_sed_short_rest='1s/^..\(.*\)$/\1/;q' + + func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` + func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` +} # func_split_short_opt may be replaced by extended shell implementation + + +# func_split_long_opt longopt +# Set func_split_long_opt_name and func_split_long_opt_arg shell +# variables after splitting LONGOPT at the `=' sign. +func_split_long_opt () +{ + my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' + my_sed_long_arg='1s/^--[^=]*=//' + + func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` + func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` +} # func_split_long_opt may be replaced by extended shell implementation + +exit_cmd=: @@ -732,25 +828,64 @@ magic="%%%MAGIC variable%%%" magic_exe="%%%MAGIC EXE variable%%%" # Global variables. -# $mode is unset nonopt= -execute_dlfiles= preserve_args= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" extracted_archives= extracted_serial=0 -opt_dry_run=false -opt_duplicate_deps=false -opt_silent=false -opt_debug=: - # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "${1}=\$${1}\${2}" +} # func_append may be replaced by extended shell implementation + +# func_append_quoted var value +# Quote VALUE and append to the end of shell variable VAR, separated +# by a space. +func_append_quoted () +{ + func_quote_for_eval "${2}" + eval "${1}=\$${1}\\ \$func_quote_for_eval_result" +} # func_append_quoted may be replaced by extended shell implementation + + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=`expr "${@}"` +} # func_arith may be replaced by extended shell implementation + + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` +} # func_len may be replaced by extended shell implementation + + +# func_lo2o object +func_lo2o () +{ + func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` +} # func_lo2o may be replaced by extended shell implementation + + +# func_xform libobj-or-source +func_xform () +{ + func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` +} # func_xform may be replaced by extended shell implementation + + # func_fatal_configuration arg... # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. @@ -840,129 +975,209 @@ func_enable_tag () esac } -# Parse options once, thoroughly. This comes as soon as possible in -# the script to make things like `libtool --version' happen quickly. +# func_check_version_match +# Ensure that we are using m4 macros, and libtool script from the same +# release of libtool. +func_check_version_match () { + if test "$package_revision" != "$macro_revision"; then + if test "$VERSION" != "$macro_version"; then + if test -z "$macro_version"; then + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, but the +$progname: definition of this LT_INIT comes from an older release. +$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION +$progname: and run autoconf again. +_LT_EOF + else + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, but the +$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. +$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION +$progname: and run autoconf again. +_LT_EOF + fi + else + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, +$progname: but the definition of this LT_INIT comes from revision $macro_revision. +$progname: You should recreate aclocal.m4 with macros from revision $package_revision +$progname: of $PACKAGE $VERSION and run autoconf again. +_LT_EOF + fi + + exit $EXIT_MISMATCH + fi +} + + +# Shorthand for --mode=foo, only valid as the first argument +case $1 in +clean|clea|cle|cl) + shift; set dummy --mode clean ${1+"$@"}; shift + ;; +compile|compil|compi|comp|com|co|c) + shift; set dummy --mode compile ${1+"$@"}; shift + ;; +execute|execut|execu|exec|exe|ex|e) + shift; set dummy --mode execute ${1+"$@"}; shift + ;; +finish|finis|fini|fin|fi|f) + shift; set dummy --mode finish ${1+"$@"}; shift + ;; +install|instal|insta|inst|ins|in|i) + shift; set dummy --mode install ${1+"$@"}; shift + ;; +link|lin|li|l) + shift; set dummy --mode link ${1+"$@"}; shift + ;; +uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) + shift; set dummy --mode uninstall ${1+"$@"}; shift + ;; +esac + + + +# Option defaults: +opt_debug=: +opt_dry_run=false +opt_config=false +opt_preserve_dup_deps=false +opt_features=false +opt_finish=false +opt_help=false +opt_help_all=false +opt_silent=: +opt_warning=: +opt_verbose=: +opt_silent=false +opt_verbose=false - # Shorthand for --mode=foo, only valid as the first argument - case $1 in - clean|clea|cle|cl) - shift; set dummy --mode clean ${1+"$@"}; shift - ;; - compile|compil|compi|comp|com|co|c) - shift; set dummy --mode compile ${1+"$@"}; shift - ;; - execute|execut|execu|exec|exe|ex|e) - shift; set dummy --mode execute ${1+"$@"}; shift - ;; - finish|finis|fini|fin|fi|f) - shift; set dummy --mode finish ${1+"$@"}; shift - ;; - install|instal|insta|inst|ins|in|i) - shift; set dummy --mode install ${1+"$@"}; shift - ;; - link|lin|li|l) - shift; set dummy --mode link ${1+"$@"}; shift - ;; - uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) - shift; set dummy --mode uninstall ${1+"$@"}; shift - ;; - esac - # Parse non-mode specific arguments: - while test "$#" -gt 0; do +# Parse options once, thoroughly. This comes as soon as possible in the +# script to make things like `--version' happen as quickly as we can. +{ + # this just eases exit handling + while test $# -gt 0; do opt="$1" shift - case $opt in - --config) func_config ;; - - --debug) preserve_args="$preserve_args $opt" + --debug|-x) opt_debug='set -x' func_echo "enabling shell trace mode" - opt_debug='set -x' $opt_debug ;; - - -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break - execute_dlfiles="$execute_dlfiles $1" - shift + --dry-run|--dryrun|-n) + opt_dry_run=: ;; - - --dry-run | -n) opt_dry_run=: ;; - --features) func_features ;; - --finish) mode="finish" ;; - - --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break - case $1 in - # Valid mode arguments: - clean) ;; - compile) ;; - execute) ;; - finish) ;; - install) ;; - link) ;; - relink) ;; - uninstall) ;; - - # Catch anything else as an error - *) func_error "invalid argument for $opt" - exit_cmd=exit - break - ;; - esac - - mode="$1" + --config) + opt_config=: +func_config + ;; + --dlopen|-dlopen) + optarg="$1" + opt_dlopen="${opt_dlopen+$opt_dlopen +}$optarg" shift ;; - --preserve-dup-deps) - opt_duplicate_deps=: ;; - - --quiet|--silent) preserve_args="$preserve_args $opt" - opt_silent=: - opt_verbose=false + opt_preserve_dup_deps=: ;; - - --no-quiet|--no-silent) - preserve_args="$preserve_args $opt" - opt_silent=false + --features) + opt_features=: +func_features ;; - - --verbose| -v) preserve_args="$preserve_args $opt" + --finish) + opt_finish=: +set dummy --mode finish ${1+"$@"}; shift + ;; + --help) + opt_help=: + ;; + --help-all) + opt_help_all=: +opt_help=': help-all' + ;; + --mode) + test $# = 0 && func_missing_arg $opt && break + optarg="$1" + opt_mode="$optarg" +case $optarg in + # Valid mode arguments: + clean|compile|execute|finish|install|link|relink|uninstall) ;; + + # Catch anything else as an error + *) func_error "invalid argument for $opt" + exit_cmd=exit + break + ;; +esac + shift + ;; + --no-silent|--no-quiet) opt_silent=false - opt_verbose=: +func_append preserve_args " $opt" ;; - - --no-verbose) preserve_args="$preserve_args $opt" + --no-warning|--no-warn) + opt_warning=false +func_append preserve_args " $opt" + ;; + --no-verbose) opt_verbose=false +func_append preserve_args " $opt" ;; - - --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break - preserve_args="$preserve_args $opt $1" - func_enable_tag "$1" # tagname is set here + --silent|--quiet) + opt_silent=: +func_append preserve_args " $opt" + opt_verbose=false + ;; + --verbose|-v) + opt_verbose=: +func_append preserve_args " $opt" +opt_silent=false + ;; + --tag) + test $# = 0 && func_missing_arg $opt && break + optarg="$1" + opt_tag="$optarg" +func_append preserve_args " $opt $optarg" +func_enable_tag "$optarg" shift ;; + -\?|-h) func_usage ;; + --help) func_help ;; + --version) func_version ;; + # Separate optargs to long options: - -dlopen=*|--mode=*|--tag=*) - func_opt_split "$opt" - set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"} + --*=*) + func_split_long_opt "$opt" + set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} shift ;; - -\?|-h) func_usage ;; - --help) opt_help=: ;; - --help-all) opt_help=': help-all' ;; - --version) func_version ;; - - -*) func_fatal_help "unrecognized option \`$opt'" ;; - - *) nonopt="$opt" - break + # Separate non-argument short options: + -\?*|-h*|-n*|-v*) + func_split_short_opt "$opt" + set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} + shift ;; + + --) break ;; + -*) func_fatal_help "unrecognized option \`$opt'" ;; + *) set dummy "$opt" ${1+"$@"}; shift; break ;; esac done + # Validate options: + + # save first non-option argument + if test "$#" -gt 0; then + nonopt="$opt" + shift + fi + + # preserve --debug + test "$opt_debug" = : || func_append preserve_args " --debug" case $host in *cygwin* | *mingw* | *pw32* | *cegcc*) @@ -970,82 +1185,44 @@ func_enable_tag () opt_duplicate_compiler_generated_deps=: ;; *) - opt_duplicate_compiler_generated_deps=$opt_duplicate_deps + opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps ;; esac - # Having warned about all mis-specified options, bail out if - # anything was wrong. - $exit_cmd $EXIT_FAILURE -} + $opt_help || { + # Sanity checks first: + func_check_version_match -# func_check_version_match -# Ensure that we are using m4 macros, and libtool script from the same -# release of libtool. -func_check_version_match () -{ - if test "$package_revision" != "$macro_revision"; then - if test "$VERSION" != "$macro_version"; then - if test -z "$macro_version"; then - cat >&2 <<_LT_EOF -$progname: Version mismatch error. This is $PACKAGE $VERSION, but the -$progname: definition of this LT_INIT comes from an older release. -$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION -$progname: and run autoconf again. -_LT_EOF - else - cat >&2 <<_LT_EOF -$progname: Version mismatch error. This is $PACKAGE $VERSION, but the -$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. -$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION -$progname: and run autoconf again. -_LT_EOF - fi - else - cat >&2 <<_LT_EOF -$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, -$progname: but the definition of this LT_INIT comes from revision $macro_revision. -$progname: You should recreate aclocal.m4 with macros from revision $package_revision -$progname: of $PACKAGE $VERSION and run autoconf again. -_LT_EOF + if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then + func_fatal_configuration "not configured to build any kind of library" fi - exit $EXIT_MISMATCH - fi -} + # Darwin sucks + eval std_shrext=\"$shrext_cmds\" + # Only execute mode is allowed to have -dlopen flags. + if test -n "$opt_dlopen" && test "$opt_mode" != execute; then + func_error "unrecognized option \`-dlopen'" + $ECHO "$help" 1>&2 + exit $EXIT_FAILURE + fi -## ----------- ## -## Main. ## -## ----------- ## - -$opt_help || { - # Sanity checks first: - func_check_version_match - - if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then - func_fatal_configuration "not configured to build any kind of library" - fi - - test -z "$mode" && func_fatal_error "error: you must specify a MODE." + # Change the help message to a mode-specific one. + generic_help="$help" + help="Try \`$progname --help --mode=$opt_mode' for more information." + } - # Darwin sucks - eval std_shrext=\"$shrext_cmds\" + # Bail if the options were screwed + $exit_cmd $EXIT_FAILURE +} - # Only execute mode is allowed to have -dlopen flags. - if test -n "$execute_dlfiles" && test "$mode" != execute; then - func_error "unrecognized option \`-dlopen'" - $ECHO "$help" 1>&2 - exit $EXIT_FAILURE - fi - # Change the help message to a mode-specific one. - generic_help="$help" - help="Try \`$progname --help --mode=$mode' for more information." -} +## ----------- ## +## Main. ## +## ----------- ## # func_lalib_p file # True iff FILE is a libtool `.la' library or `.lo' object file. @@ -1110,12 +1287,9 @@ func_ltwrapper_executable_p () # temporary ltwrapper_script. func_ltwrapper_scriptname () { - func_ltwrapper_scriptname_result="" - if func_ltwrapper_executable_p "$1"; then - func_dirname_and_basename "$1" "" "." - func_stripname '' '.exe' "$func_basename_result" - func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" - fi + func_dirname_and_basename "$1" "" "." + func_stripname '' '.exe' "$func_basename_result" + func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" } # func_ltwrapper_p file @@ -1161,6 +1335,37 @@ func_source () } +# func_resolve_sysroot PATH +# Replace a leading = in PATH with a sysroot. Store the result into +# func_resolve_sysroot_result +func_resolve_sysroot () +{ + func_resolve_sysroot_result=$1 + case $func_resolve_sysroot_result in + =*) + func_stripname '=' '' "$func_resolve_sysroot_result" + func_resolve_sysroot_result=$lt_sysroot$func_stripname_result + ;; + esac +} + +# func_replace_sysroot PATH +# If PATH begins with the sysroot, replace it with = and +# store the result into func_replace_sysroot_result. +func_replace_sysroot () +{ + case "$lt_sysroot:$1" in + ?*:"$lt_sysroot"*) + func_stripname "$lt_sysroot" '' "$1" + func_replace_sysroot_result="=$func_stripname_result" + ;; + *) + # Including no sysroot. + func_replace_sysroot_result=$1 + ;; + esac +} + # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. @@ -1173,8 +1378,7 @@ func_infer_tag () if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do - func_quote_for_eval "$arg" - CC_quoted="$CC_quoted $func_quote_for_eval_result" + func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` @@ -1193,8 +1397,7 @@ func_infer_tag () CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. - func_quote_for_eval "$arg" - CC_quoted="$CC_quoted $func_quote_for_eval_result" + func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` @@ -1225,43 +1428,523 @@ func_infer_tag () } - -# func_write_libtool_object output_name pic_name nonpic_name -# Create a libtool object file (analogous to a ".la" file), -# but don't create it if we're doing a dry run. -func_write_libtool_object () + +# func_write_libtool_object output_name pic_name nonpic_name +# Create a libtool object file (analogous to a ".la" file), +# but don't create it if we're doing a dry run. +func_write_libtool_object () +{ + write_libobj=${1} + if test "$build_libtool_libs" = yes; then + write_lobj=\'${2}\' + else + write_lobj=none + fi + + if test "$build_old_libs" = yes; then + write_oldobj=\'${3}\' + else + write_oldobj=none + fi + + $opt_dry_run || { + cat >${write_libobj}T </dev/null` + if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then + func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | + $SED -e "$lt_sed_naive_backslashify"` + else + func_convert_core_file_wine_to_w32_result= + fi + fi +} +# end: func_convert_core_file_wine_to_w32 + + +# func_convert_core_path_wine_to_w32 ARG +# Helper function used by path conversion functions when $build is *nix, and +# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly +# configured wine environment available, with the winepath program in $build's +# $PATH. Assumes ARG has no leading or trailing path separator characters. +# +# ARG is path to be converted from $build format to win32. +# Result is available in $func_convert_core_path_wine_to_w32_result. +# Unconvertible file (directory) names in ARG are skipped; if no directory names +# are convertible, then the result may be empty. +func_convert_core_path_wine_to_w32 () +{ + $opt_debug + # unfortunately, winepath doesn't convert paths, only file names + func_convert_core_path_wine_to_w32_result="" + if test -n "$1"; then + oldIFS=$IFS + IFS=: + for func_convert_core_path_wine_to_w32_f in $1; do + IFS=$oldIFS + func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" + if test -n "$func_convert_core_file_wine_to_w32_result" ; then + if test -z "$func_convert_core_path_wine_to_w32_result"; then + func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" + else + func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" + fi + fi + done + IFS=$oldIFS + fi +} +# end: func_convert_core_path_wine_to_w32 + + +# func_cygpath ARGS... +# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when +# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) +# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or +# (2), returns the Cygwin file name or path in func_cygpath_result (input +# file name or path is assumed to be in w32 format, as previously converted +# from $build's *nix or MSYS format). In case (3), returns the w32 file name +# or path in func_cygpath_result (input file name or path is assumed to be in +# Cygwin format). Returns an empty string on error. +# +# ARGS are passed to cygpath, with the last one being the file name or path to +# be converted. +# +# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH +# environment variable; do not put it in $PATH. +func_cygpath () +{ + $opt_debug + if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then + func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` + if test "$?" -ne 0; then + # on failure, ensure result is empty + func_cygpath_result= + fi + else + func_cygpath_result= + func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" + fi +} +#end: func_cygpath + + +# func_convert_core_msys_to_w32 ARG +# Convert file name or path ARG from MSYS format to w32 format. Return +# result in func_convert_core_msys_to_w32_result. +func_convert_core_msys_to_w32 () +{ + $opt_debug + # awkward: cmd appends spaces to result + func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | + $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` +} +#end: func_convert_core_msys_to_w32 + + +# func_convert_file_check ARG1 ARG2 +# Verify that ARG1 (a file name in $build format) was converted to $host +# format in ARG2. Otherwise, emit an error message, but continue (resetting +# func_to_host_file_result to ARG1). +func_convert_file_check () +{ + $opt_debug + if test -z "$2" && test -n "$1" ; then + func_error "Could not determine host file name corresponding to" + func_error " \`$1'" + func_error "Continuing, but uninstalled executables may not work." + # Fallback: + func_to_host_file_result="$1" + fi +} +# end func_convert_file_check + + +# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH +# Verify that FROM_PATH (a path in $build format) was converted to $host +# format in TO_PATH. Otherwise, emit an error message, but continue, resetting +# func_to_host_file_result to a simplistic fallback value (see below). +func_convert_path_check () +{ + $opt_debug + if test -z "$4" && test -n "$3"; then + func_error "Could not determine the host path corresponding to" + func_error " \`$3'" + func_error "Continuing, but uninstalled executables may not work." + # Fallback. This is a deliberately simplistic "conversion" and + # should not be "improved". See libtool.info. + if test "x$1" != "x$2"; then + lt_replace_pathsep_chars="s|$1|$2|g" + func_to_host_path_result=`echo "$3" | + $SED -e "$lt_replace_pathsep_chars"` + else + func_to_host_path_result="$3" + fi + fi +} +# end func_convert_path_check + + +# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG +# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT +# and appending REPL if ORIG matches BACKPAT. +func_convert_path_front_back_pathsep () +{ + $opt_debug + case $4 in + $1 ) func_to_host_path_result="$3$func_to_host_path_result" + ;; + esac + case $4 in + $2 ) func_append func_to_host_path_result "$3" + ;; + esac +} +# end func_convert_path_front_back_pathsep + + +################################################## +# $build to $host FILE NAME CONVERSION FUNCTIONS # +################################################## +# invoked via `$to_host_file_cmd ARG' +# +# In each case, ARG is the path to be converted from $build to $host format. +# Result will be available in $func_to_host_file_result. + + +# func_to_host_file ARG +# Converts the file name ARG from $build format to $host format. Return result +# in func_to_host_file_result. +func_to_host_file () +{ + $opt_debug + $to_host_file_cmd "$1" +} +# end func_to_host_file + + +# func_to_tool_file ARG LAZY +# converts the file name ARG from $build format to toolchain format. Return +# result in func_to_tool_file_result. If the conversion in use is listed +# in (the comma separated) LAZY, no conversion takes place. +func_to_tool_file () +{ + $opt_debug + case ,$2, in + *,"$to_tool_file_cmd",*) + func_to_tool_file_result=$1 + ;; + *) + $to_tool_file_cmd "$1" + func_to_tool_file_result=$func_to_host_file_result + ;; + esac +} +# end func_to_tool_file + + +# func_convert_file_noop ARG +# Copy ARG to func_to_host_file_result. +func_convert_file_noop () +{ + func_to_host_file_result="$1" +} +# end func_convert_file_noop + + +# func_convert_file_msys_to_w32 ARG +# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic +# conversion to w32 is not available inside the cwrapper. Returns result in +# func_to_host_file_result. +func_convert_file_msys_to_w32 () +{ + $opt_debug + func_to_host_file_result="$1" + if test -n "$1"; then + func_convert_core_msys_to_w32 "$1" + func_to_host_file_result="$func_convert_core_msys_to_w32_result" + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_msys_to_w32 + + +# func_convert_file_cygwin_to_w32 ARG +# Convert file name ARG from Cygwin to w32 format. Returns result in +# func_to_host_file_result. +func_convert_file_cygwin_to_w32 () +{ + $opt_debug + func_to_host_file_result="$1" + if test -n "$1"; then + # because $build is cygwin, we call "the" cygpath in $PATH; no need to use + # LT_CYGPATH in this case. + func_to_host_file_result=`cygpath -m "$1"` + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_cygwin_to_w32 + + +# func_convert_file_nix_to_w32 ARG +# Convert file name ARG from *nix to w32 format. Requires a wine environment +# and a working winepath. Returns result in func_to_host_file_result. +func_convert_file_nix_to_w32 () +{ + $opt_debug + func_to_host_file_result="$1" + if test -n "$1"; then + func_convert_core_file_wine_to_w32 "$1" + func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_nix_to_w32 + + +# func_convert_file_msys_to_cygwin ARG +# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. +# Returns result in func_to_host_file_result. +func_convert_file_msys_to_cygwin () +{ + $opt_debug + func_to_host_file_result="$1" + if test -n "$1"; then + func_convert_core_msys_to_w32 "$1" + func_cygpath -u "$func_convert_core_msys_to_w32_result" + func_to_host_file_result="$func_cygpath_result" + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_msys_to_cygwin + + +# func_convert_file_nix_to_cygwin ARG +# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed +# in a wine environment, working winepath, and LT_CYGPATH set. Returns result +# in func_to_host_file_result. +func_convert_file_nix_to_cygwin () +{ + $opt_debug + func_to_host_file_result="$1" + if test -n "$1"; then + # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. + func_convert_core_file_wine_to_w32 "$1" + func_cygpath -u "$func_convert_core_file_wine_to_w32_result" + func_to_host_file_result="$func_cygpath_result" + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_nix_to_cygwin + + +############################################# +# $build to $host PATH CONVERSION FUNCTIONS # +############################################# +# invoked via `$to_host_path_cmd ARG' +# +# In each case, ARG is the path to be converted from $build to $host format. +# The result will be available in $func_to_host_path_result. +# +# Path separators are also converted from $build format to $host format. If +# ARG begins or ends with a path separator character, it is preserved (but +# converted to $host format) on output. +# +# All path conversion functions are named using the following convention: +# file name conversion function : func_convert_file_X_to_Y () +# path conversion function : func_convert_path_X_to_Y () +# where, for any given $build/$host combination the 'X_to_Y' value is the +# same. If conversion functions are added for new $build/$host combinations, +# the two new functions must follow this pattern, or func_init_to_host_path_cmd +# will break. + + +# func_init_to_host_path_cmd +# Ensures that function "pointer" variable $to_host_path_cmd is set to the +# appropriate value, based on the value of $to_host_file_cmd. +to_host_path_cmd= +func_init_to_host_path_cmd () +{ + $opt_debug + if test -z "$to_host_path_cmd"; then + func_stripname 'func_convert_file_' '' "$to_host_file_cmd" + to_host_path_cmd="func_convert_path_${func_stripname_result}" + fi +} + + +# func_to_host_path ARG +# Converts the path ARG from $build format to $host format. Return result +# in func_to_host_path_result. +func_to_host_path () +{ + $opt_debug + func_init_to_host_path_cmd + $to_host_path_cmd "$1" +} +# end func_to_host_path + + +# func_convert_path_noop ARG +# Copy ARG to func_to_host_path_result. +func_convert_path_noop () +{ + func_to_host_path_result="$1" +} +# end func_convert_path_noop + + +# func_convert_path_msys_to_w32 ARG +# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic +# conversion to w32 is not available inside the cwrapper. Returns result in +# func_to_host_path_result. +func_convert_path_msys_to_w32 () +{ + $opt_debug + func_to_host_path_result="$1" + if test -n "$1"; then + # Remove leading and trailing path separator characters from ARG. MSYS + # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; + # and winepath ignores them completely. + func_stripname : : "$1" + func_to_host_path_tmp1=$func_stripname_result + func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" + func_to_host_path_result="$func_convert_core_msys_to_w32_result" + func_convert_path_check : ";" \ + "$func_to_host_path_tmp1" "$func_to_host_path_result" + func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" + fi +} +# end func_convert_path_msys_to_w32 + + +# func_convert_path_cygwin_to_w32 ARG +# Convert path ARG from Cygwin to w32 format. Returns result in +# func_to_host_file_result. +func_convert_path_cygwin_to_w32 () +{ + $opt_debug + func_to_host_path_result="$1" + if test -n "$1"; then + # See func_convert_path_msys_to_w32: + func_stripname : : "$1" + func_to_host_path_tmp1=$func_stripname_result + func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` + func_convert_path_check : ";" \ + "$func_to_host_path_tmp1" "$func_to_host_path_result" + func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" + fi +} +# end func_convert_path_cygwin_to_w32 + + +# func_convert_path_nix_to_w32 ARG +# Convert path ARG from *nix to w32 format. Requires a wine environment and +# a working winepath. Returns result in func_to_host_file_result. +func_convert_path_nix_to_w32 () { - write_libobj=${1} - if test "$build_libtool_libs" = yes; then - write_lobj=\'${2}\' - else - write_lobj=none - fi - - if test "$build_old_libs" = yes; then - write_oldobj=\'${3}\' - else - write_oldobj=none - fi + $opt_debug + func_to_host_path_result="$1" + if test -n "$1"; then + # See func_convert_path_msys_to_w32: + func_stripname : : "$1" + func_to_host_path_tmp1=$func_stripname_result + func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" + func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" + func_convert_path_check : ";" \ + "$func_to_host_path_tmp1" "$func_to_host_path_result" + func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" + fi +} +# end func_convert_path_nix_to_w32 - $opt_dry_run || { - cat >${write_libobj}T < "$lockfile" fi $opt_dry_run || $RM $removelist - removelist="$removelist $lockfile" + func_append removelist " $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 - if test -n "$fix_srcfile_path"; then - eval srcfile=\"$fix_srcfile_path\" - fi + func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 + srcfile=$func_to_tool_file_result func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result @@ -1515,7 +2195,7 @@ compiler." if test -z "$output_obj"; then # Place PIC objects in $objdir - command="$command -o $lobj" + func_append command " -o $lobj" fi func_show_eval_locale "$command" \ @@ -1562,11 +2242,11 @@ compiler." command="$base_compile $qsrcfile $pic_flag" fi if test "$compiler_c_o" = yes; then - command="$command -o $obj" + func_append command " -o $obj" fi # Suppress compiler output if we already did a PIC compilation. - command="$command$suppress_output" + func_append command "$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' @@ -1611,13 +2291,13 @@ compiler." } $opt_help || { - test "$mode" = compile && func_mode_compile ${1+"$@"} + test "$opt_mode" = compile && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. - case $mode in + case $opt_mode in "") # Generic help is extracted from the usage comments # at the start of this file. @@ -1793,7 +2473,7 @@ Otherwise, only FILE itself is deleted using RM." ;; *) - func_fatal_help "invalid operation mode \`$mode'" + func_fatal_help "invalid operation mode \`$opt_mode'" ;; esac @@ -1808,13 +2488,13 @@ if $opt_help; then else { func_help noexit - for mode in compile link execute install finish uninstall clean; do + for opt_mode in compile link execute install finish uninstall clean; do func_mode_help done } | sed -n '1p; 2,$s/^Usage:/ or: /p' { func_help noexit - for mode in compile link execute install finish uninstall clean; do + for opt_mode in compile link execute install finish uninstall clean; do echo func_mode_help done @@ -1843,13 +2523,16 @@ func_mode_execute () func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. - for file in $execute_dlfiles; do + for file in $opt_dlopen; do test -f "$file" \ || func_fatal_help "\`$file' is not a file" dir= case $file in *.la) + func_resolve_sysroot "$file" + file=$func_resolve_sysroot_result + # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$lib' is not a valid libtool archive" @@ -1871,7 +2554,7 @@ func_mode_execute () dir="$func_dirname_result" if test -f "$dir/$objdir/$dlname"; then - dir="$dir/$objdir" + func_append dir "/$objdir" else if test ! -f "$dir/$dlname"; then func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" @@ -1928,8 +2611,7 @@ func_mode_execute () ;; esac # Quote arguments (to preserve shell metacharacters). - func_quote_for_eval "$file" - args="$args $func_quote_for_eval_result" + func_append_quoted args "$file" done if test "X$opt_dry_run" = Xfalse; then @@ -1961,22 +2643,59 @@ func_mode_execute () fi } -test "$mode" = execute && func_mode_execute ${1+"$@"} +test "$opt_mode" = execute && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $opt_debug - libdirs="$nonopt" + libs= + libdirs= admincmds= - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - for dir - do - libdirs="$libdirs $dir" - done + for opt in "$nonopt" ${1+"$@"} + do + if test -d "$opt"; then + func_append libdirs " $opt" + + elif test -f "$opt"; then + if func_lalib_unsafe_p "$opt"; then + func_append libs " $opt" + else + func_warning "\`$opt' is not a valid libtool archive" + fi + + else + func_fatal_error "invalid argument \`$opt'" + fi + done + + if test -n "$libs"; then + if test -n "$lt_sysroot"; then + sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` + sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" + else + sysroot_cmd= + fi + + # Remove sysroot references + if $opt_dry_run; then + for lib in $libs; do + echo "removing references to $lt_sysroot and \`=' prefixes from $lib" + done + else + tmpdir=`func_mktempdir` + for lib in $libs; do + sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ + > $tmpdir/tmp-la + mv -f $tmpdir/tmp-la $lib + done + ${RM}r "$tmpdir" + fi + fi + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. @@ -1986,7 +2705,7 @@ func_mode_finish () if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" - $opt_dry_run || eval "$cmds" || admincmds="$admincmds + $opt_dry_run || eval "$cmds" || func_append admincmds " $cmds" fi done @@ -1995,53 +2714,55 @@ func_mode_finish () # Exit here if they wanted silent mode. $opt_silent && exit $EXIT_SUCCESS - echo "----------------------------------------------------------------------" - echo "Libraries have been installed in:" - for libdir in $libdirs; do - $ECHO " $libdir" - done - echo - echo "If you ever happen to want to link against installed libraries" - echo "in a given directory, LIBDIR, you must either use libtool, and" - echo "specify the full pathname of the library, or use the \`-LLIBDIR'" - echo "flag during linking and do at least one of the following:" - if test -n "$shlibpath_var"; then - echo " - add LIBDIR to the \`$shlibpath_var' environment variable" - echo " during execution" - fi - if test -n "$runpath_var"; then - echo " - add LIBDIR to the \`$runpath_var' environment variable" - echo " during linking" - fi - if test -n "$hardcode_libdir_flag_spec"; then - libdir=LIBDIR - eval flag=\"$hardcode_libdir_flag_spec\" + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + echo "----------------------------------------------------------------------" + echo "Libraries have been installed in:" + for libdir in $libdirs; do + $ECHO " $libdir" + done + echo + echo "If you ever happen to want to link against installed libraries" + echo "in a given directory, LIBDIR, you must either use libtool, and" + echo "specify the full pathname of the library, or use the \`-LLIBDIR'" + echo "flag during linking and do at least one of the following:" + if test -n "$shlibpath_var"; then + echo " - add LIBDIR to the \`$shlibpath_var' environment variable" + echo " during execution" + fi + if test -n "$runpath_var"; then + echo " - add LIBDIR to the \`$runpath_var' environment variable" + echo " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval flag=\"$hardcode_libdir_flag_spec\" - $ECHO " - use the \`$flag' linker flag" - fi - if test -n "$admincmds"; then - $ECHO " - have your system administrator run these commands:$admincmds" - fi - if test -f /etc/ld.so.conf; then - echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" - fi - echo + $ECHO " - use the \`$flag' linker flag" + fi + if test -n "$admincmds"; then + $ECHO " - have your system administrator run these commands:$admincmds" + fi + if test -f /etc/ld.so.conf; then + echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" + fi + echo - echo "See any operating system documentation about shared libraries for" - case $host in - solaris2.[6789]|solaris2.1[0-9]) - echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" - echo "pages." - ;; - *) - echo "more information, such as the ld(1) and ld.so(8) manual pages." - ;; - esac - echo "----------------------------------------------------------------------" + echo "See any operating system documentation about shared libraries for" + case $host in + solaris2.[6789]|solaris2.1[0-9]) + echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" + echo "pages." + ;; + *) + echo "more information, such as the ld(1) and ld.so(8) manual pages." + ;; + esac + echo "----------------------------------------------------------------------" + fi exit $EXIT_SUCCESS } -test "$mode" = finish && func_mode_finish ${1+"$@"} +test "$opt_mode" = finish && func_mode_finish ${1+"$@"} # func_mode_install arg... @@ -2066,7 +2787,7 @@ func_mode_install () # The real first argument should be the name of the installation program. # Aesthetically quote it. func_quote_for_eval "$arg" - install_prog="$install_prog$func_quote_for_eval_result" + func_append install_prog "$func_quote_for_eval_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; @@ -2086,7 +2807,7 @@ func_mode_install () do arg2= if test -n "$dest"; then - files="$files $dest" + func_append files " $dest" dest=$arg continue fi @@ -2124,11 +2845,11 @@ func_mode_install () # Aesthetically quote the argument. func_quote_for_eval "$arg" - install_prog="$install_prog $func_quote_for_eval_result" + func_append install_prog " $func_quote_for_eval_result" if test -n "$arg2"; then func_quote_for_eval "$arg2" fi - install_shared_prog="$install_shared_prog $func_quote_for_eval_result" + func_append install_shared_prog " $func_quote_for_eval_result" done test -z "$install_prog" && \ @@ -2140,7 +2861,7 @@ func_mode_install () if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else func_quote_for_eval "$install_override_mode" - install_shared_prog="$install_shared_prog -m $func_quote_for_eval_result" + func_append install_shared_prog " -m $func_quote_for_eval_result" fi fi @@ -2198,10 +2919,13 @@ func_mode_install () case $file in *.$libext) # Do the static libraries later. - staticlibs="$staticlibs $file" + func_append staticlibs " $file" ;; *.la) + func_resolve_sysroot "$file" + file=$func_resolve_sysroot_result + # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$file' is not a valid libtool archive" @@ -2215,19 +2939,19 @@ func_mode_install () if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; - *) current_libdirs="$current_libdirs $libdir" ;; + *) func_append current_libdirs " $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; - *) future_libdirs="$future_libdirs $libdir" ;; + *) func_append future_libdirs " $libdir" ;; esac fi func_dirname "$file" "/" "" dir="$func_dirname_result" - dir="$dir$objdir" + func_append dir "$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. @@ -2304,7 +3028,7 @@ func_mode_install () func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. - test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" + test -n "$old_library" && func_append staticlibs " $dir/$old_library" ;; *.lo) @@ -2478,11 +3202,13 @@ func_mode_install () # Set up the ranlib parameters. oldlib="$destdir/$name" + func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 + tool_oldlib=$func_to_tool_file_result func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then - func_show_eval "$old_striplib $oldlib" 'exit $?' + func_show_eval "$old_striplib $tool_oldlib" 'exit $?' fi # Do each command in the postinstall commands. @@ -2501,7 +3227,7 @@ func_mode_install () fi } -test "$mode" = install && func_mode_install ${1+"$@"} +test "$opt_mode" = install && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p @@ -2548,6 +3274,18 @@ extern \"C\" { #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) +/* DATA imports from DLLs on WIN32 con't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT_DLSYM_CONST +#elif defined(__osf__) +/* This system does not cope well with relocations in const data. */ +# define LT_DLSYM_CONST +#else +# define LT_DLSYM_CONST const +#endif + /* External symbol declarations for the compiler. */\ " @@ -2559,8 +3297,9 @@ extern \"C\" { # Add our own program objects to the symbol list. progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` for progfile in $progfiles; do - func_verbose "extracting global C symbols from \`$progfile'" - $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'" + func_to_tool_file "$progfile" func_convert_file_msys_to_w32 + func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" + $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then @@ -2609,10 +3348,52 @@ extern \"C\" { func_verbose "extracting global C symbols from \`$dlprefile'" func_basename "$dlprefile" name="$func_basename_result" - $opt_dry_run || { - eval '$ECHO ": $name " >> "$nlist"' - eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'" - } + case $host in + *cygwin* | *mingw* | *cegcc* ) + # if an import library, we need to obtain dlname + if func_win32_import_lib_p "$dlprefile"; then + func_tr_sh "$dlprefile" + eval "curr_lafile=\$libfile_$func_tr_sh_result" + dlprefile_dlbasename="" + if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then + # Use subshell, to avoid clobbering current variable values + dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` + if test -n "$dlprefile_dlname" ; then + func_basename "$dlprefile_dlname" + dlprefile_dlbasename="$func_basename_result" + else + # no lafile. user explicitly requested -dlpreopen . + $sharedlib_from_linklib_cmd "$dlprefile" + dlprefile_dlbasename=$sharedlib_from_linklib_result + fi + fi + $opt_dry_run || { + if test -n "$dlprefile_dlbasename" ; then + eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' + else + func_warning "Could not compute DLL name from $name" + eval '$ECHO ": $name " >> "$nlist"' + fi + func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 + eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | + $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" + } + else # not an import lib + $opt_dry_run || { + eval '$ECHO ": $name " >> "$nlist"' + func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 + eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" + } + fi + ;; + *) + $opt_dry_run || { + eval '$ECHO ": $name " >> "$nlist"' + func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 + eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" + } + ;; + esac done $opt_dry_run || { @@ -2650,26 +3431,9 @@ typedef struct { const char *name; void *address; } lt_dlsymlist; -" - case $host in - *cygwin* | *mingw* | *cegcc* ) - echo >> "$output_objdir/$my_dlsyms" "\ -/* DATA imports from DLLs on WIN32 con't be const, because - runtime relocations are performed -- see ld's documentation - on pseudo-relocs. */" - lt_dlsym_const= ;; - *osf5*) - echo >> "$output_objdir/$my_dlsyms" "\ -/* This system does not cope well with relocations in const data */" - lt_dlsym_const= ;; - *) - lt_dlsym_const=const ;; - esac - - echo >> "$output_objdir/$my_dlsyms" "\ -extern $lt_dlsym_const lt_dlsymlist +extern LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[]; -$lt_dlsym_const lt_dlsymlist +LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = {\ { \"$my_originator\", (void *) 0 }," @@ -2709,7 +3473,7 @@ static const void *lt_preloaded_setup() { # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. - *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) + *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; @@ -2725,7 +3489,7 @@ static const void *lt_preloaded_setup() { for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; - *) symtab_cflags="$symtab_cflags $arg" ;; + *) func_append symtab_cflags " $arg" ;; esac done @@ -2788,7 +3552,8 @@ func_win32_libid () # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then - win32_nmres=`eval $NM -f posix -A $1 | + func_to_tool_file "$1" func_convert_file_msys_to_w32 + win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | $SED -n -e ' 1,100{ / I /{ @@ -2817,6 +3582,131 @@ func_win32_libid () $ECHO "$win32_libid_type" } +# func_cygming_dll_for_implib ARG +# +# Platform-specific function to extract the +# name of the DLL associated with the specified +# import library ARG. +# Invoked by eval'ing the libtool variable +# $sharedlib_from_linklib_cmd +# Result is available in the variable +# $sharedlib_from_linklib_result +func_cygming_dll_for_implib () +{ + $opt_debug + sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` +} + +# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs +# +# The is the core of a fallback implementation of a +# platform-specific function to extract the name of the +# DLL associated with the specified import library LIBNAME. +# +# SECTION_NAME is either .idata$6 or .idata$7, depending +# on the platform and compiler that created the implib. +# +# Echos the name of the DLL associated with the +# specified import library. +func_cygming_dll_for_implib_fallback_core () +{ + $opt_debug + match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` + $OBJDUMP -s --section "$1" "$2" 2>/dev/null | + $SED '/^Contents of section '"$match_literal"':/{ + # Place marker at beginning of archive member dllname section + s/.*/====MARK====/ + p + d + } + # These lines can sometimes be longer than 43 characters, but + # are always uninteresting + /:[ ]*file format pe[i]\{,1\}-/d + /^In archive [^:]*:/d + # Ensure marker is printed + /^====MARK====/p + # Remove all lines with less than 43 characters + /^.\{43\}/!d + # From remaining lines, remove first 43 characters + s/^.\{43\}//' | + $SED -n ' + # Join marker and all lines until next marker into a single line + /^====MARK====/ b para + H + $ b para + b + :para + x + s/\n//g + # Remove the marker + s/^====MARK====// + # Remove trailing dots and whitespace + s/[\. \t]*$// + # Print + /./p' | + # we now have a list, one entry per line, of the stringified + # contents of the appropriate section of all members of the + # archive which possess that section. Heuristic: eliminate + # all those which have a first or second character that is + # a '.' (that is, objdump's representation of an unprintable + # character.) This should work for all archives with less than + # 0x302f exports -- but will fail for DLLs whose name actually + # begins with a literal '.' or a single character followed by + # a '.'. + # + # Of those that remain, print the first one. + $SED -e '/^\./d;/^.\./d;q' +} + +# func_cygming_gnu_implib_p ARG +# This predicate returns with zero status (TRUE) if +# ARG is a GNU/binutils-style import library. Returns +# with nonzero status (FALSE) otherwise. +func_cygming_gnu_implib_p () +{ + $opt_debug + func_to_tool_file "$1" func_convert_file_msys_to_w32 + func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` + test -n "$func_cygming_gnu_implib_tmp" +} + +# func_cygming_ms_implib_p ARG +# This predicate returns with zero status (TRUE) if +# ARG is an MS-style import library. Returns +# with nonzero status (FALSE) otherwise. +func_cygming_ms_implib_p () +{ + $opt_debug + func_to_tool_file "$1" func_convert_file_msys_to_w32 + func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` + test -n "$func_cygming_ms_implib_tmp" +} + +# func_cygming_dll_for_implib_fallback ARG +# Platform-specific function to extract the +# name of the DLL associated with the specified +# import library ARG. +# +# This fallback implementation is for use when $DLLTOOL +# does not support the --identify-strict option. +# Invoked by eval'ing the libtool variable +# $sharedlib_from_linklib_cmd +# Result is available in the variable +# $sharedlib_from_linklib_result +func_cygming_dll_for_implib_fallback () +{ + $opt_debug + if func_cygming_gnu_implib_p "$1" ; then + # binutils import library + sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` + elif func_cygming_ms_implib_p "$1" ; then + # ms-generated import library + sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` + else + # unknown + sharedlib_from_linklib_result="" + fi +} # func_extract_an_archive dir oldlib @@ -3095,14 +3985,17 @@ func_exec_program_core () # launches target application with the remaining arguments. func_exec_program () { - for lt_wr_arg - do - case \$lt_wr_arg in - --lt-*) ;; - *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; - esac - shift - done + case \" \$* \" in + *\\ --lt-*) + for lt_wr_arg + do + case \$lt_wr_arg in + --lt-*) ;; + *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; + esac + shift + done ;; + esac func_exec_program_core \${1+\"\$@\"} } @@ -3195,6 +4088,18 @@ func_exec_program () if test -f \"\$progdir/\$program\"; then" + # fixup the dll searchpath if we need to. + # + # Fix the DLL searchpath if we need to. Do this before prepending + # to shlibpath, because on Windows, both are PATH and uninstalled + # libraries must come first. + if test -n "$dllsearchpath"; then + $ECHO "\ + # Add the dll search path components to the executable PATH + PATH=$dllsearchpath:\$PATH +" + fi + # Export our shlibpath_var if we have one. if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $ECHO "\ @@ -3209,14 +4114,6 @@ func_exec_program () " fi - # fixup the dll searchpath if we need to. - if test -n "$dllsearchpath"; then - $ECHO "\ - # Add the dll search path components to the executable PATH - PATH=$dllsearchpath:\$PATH -" - fi - $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. @@ -3234,166 +4131,6 @@ fi\ } -# func_to_host_path arg -# -# Convert paths to host format when used with build tools. -# Intended for use with "native" mingw (where libtool itself -# is running under the msys shell), or in the following cross- -# build environments: -# $build $host -# mingw (msys) mingw [e.g. native] -# cygwin mingw -# *nix + wine mingw -# where wine is equipped with the `winepath' executable. -# In the native mingw case, the (msys) shell automatically -# converts paths for any non-msys applications it launches, -# but that facility isn't available from inside the cwrapper. -# Similar accommodations are necessary for $host mingw and -# $build cygwin. Calling this function does no harm for other -# $host/$build combinations not listed above. -# -# ARG is the path (on $build) that should be converted to -# the proper representation for $host. The result is stored -# in $func_to_host_path_result. -func_to_host_path () -{ - func_to_host_path_result="$1" - if test -n "$1"; then - case $host in - *mingw* ) - lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' - case $build in - *mingw* ) # actually, msys - # awkward: cmd appends spaces to result - func_to_host_path_result=`( cmd //c echo "$1" ) 2>/dev/null | - $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` - ;; - *cygwin* ) - func_to_host_path_result=`cygpath -w "$1" | - $SED -e "$lt_sed_naive_backslashify"` - ;; - * ) - # Unfortunately, winepath does not exit with a non-zero - # error code, so we are forced to check the contents of - # stdout. On the other hand, if the command is not - # found, the shell will set an exit code of 127 and print - # *an error message* to stdout. So we must check for both - # error code of zero AND non-empty stdout, which explains - # the odd construction: - func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null` - if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then - func_to_host_path_result=`$ECHO "$func_to_host_path_tmp1" | - $SED -e "$lt_sed_naive_backslashify"` - else - # Allow warning below. - func_to_host_path_result= - fi - ;; - esac - if test -z "$func_to_host_path_result" ; then - func_error "Could not determine host path corresponding to" - func_error " \`$1'" - func_error "Continuing, but uninstalled executables may not work." - # Fallback: - func_to_host_path_result="$1" - fi - ;; - esac - fi -} -# end: func_to_host_path - -# func_to_host_pathlist arg -# -# Convert pathlists to host format when used with build tools. -# See func_to_host_path(), above. This function supports the -# following $build/$host combinations (but does no harm for -# combinations not listed here): -# $build $host -# mingw (msys) mingw [e.g. native] -# cygwin mingw -# *nix + wine mingw -# -# Path separators are also converted from $build format to -# $host format. If ARG begins or ends with a path separator -# character, it is preserved (but converted to $host format) -# on output. -# -# ARG is a pathlist (on $build) that should be converted to -# the proper representation on $host. The result is stored -# in $func_to_host_pathlist_result. -func_to_host_pathlist () -{ - func_to_host_pathlist_result="$1" - if test -n "$1"; then - case $host in - *mingw* ) - lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' - # Remove leading and trailing path separator characters from - # ARG. msys behavior is inconsistent here, cygpath turns them - # into '.;' and ';.', and winepath ignores them completely. - func_stripname : : "$1" - func_to_host_pathlist_tmp1=$func_stripname_result - case $build in - *mingw* ) # Actually, msys. - # Awkward: cmd appends spaces to result. - func_to_host_pathlist_result=` - ( cmd //c echo "$func_to_host_pathlist_tmp1" ) 2>/dev/null | - $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` - ;; - *cygwin* ) - func_to_host_pathlist_result=`cygpath -w -p "$func_to_host_pathlist_tmp1" | - $SED -e "$lt_sed_naive_backslashify"` - ;; - * ) - # unfortunately, winepath doesn't convert pathlists - func_to_host_pathlist_result="" - func_to_host_pathlist_oldIFS=$IFS - IFS=: - for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do - IFS=$func_to_host_pathlist_oldIFS - if test -n "$func_to_host_pathlist_f" ; then - func_to_host_path "$func_to_host_pathlist_f" - if test -n "$func_to_host_path_result" ; then - if test -z "$func_to_host_pathlist_result" ; then - func_to_host_pathlist_result="$func_to_host_path_result" - else - func_append func_to_host_pathlist_result ";$func_to_host_path_result" - fi - fi - fi - done - IFS=$func_to_host_pathlist_oldIFS - ;; - esac - if test -z "$func_to_host_pathlist_result"; then - func_error "Could not determine the host path(s) corresponding to" - func_error " \`$1'" - func_error "Continuing, but uninstalled executables may not work." - # Fallback. This may break if $1 contains DOS-style drive - # specifications. The fix is not to complicate the expression - # below, but for the user to provide a working wine installation - # with winepath so that path translation in the cross-to-mingw - # case works properly. - lt_replace_pathsep_nix_to_dos="s|:|;|g" - func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\ - $SED -e "$lt_replace_pathsep_nix_to_dos"` - fi - # Now, add the leading and trailing path separators back - case "$1" in - :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result" - ;; - esac - case "$1" in - *: ) func_append func_to_host_pathlist_result ";" - ;; - esac - ;; - esac - fi -} -# end: func_to_host_pathlist - # func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout # Must ONLY be called from within func_mode_link because @@ -3563,14 +4300,14 @@ void lt_dump_script (FILE *f); EOF cat </dev/null` + if test "$want_nocaseglob" = yes; then + shopt -s nocaseglob + potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` + $nocaseglob + else + potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` + fi for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null | @@ -6999,7 +7827,7 @@ EOF if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then - newdeplibs="$newdeplibs $a_deplib" + func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi @@ -7024,7 +7852,7 @@ EOF ;; *) # Add a -L argument. - newdeplibs="$newdeplibs $a_deplib" + func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. @@ -7040,7 +7868,7 @@ EOF if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) - newdeplibs="$newdeplibs $a_deplib" + func_append newdeplibs " $a_deplib" a_deplib="" ;; esac @@ -7053,7 +7881,7 @@ EOF potlib="$potent_lib" # see symlink-check above in file_magic test if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then - newdeplibs="$newdeplibs $a_deplib" + func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi @@ -7078,7 +7906,7 @@ EOF ;; *) # Add a -L argument. - newdeplibs="$newdeplibs $a_deplib" + func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. @@ -7182,7 +8010,7 @@ EOF *) case " $deplibs " in *" -L$path/$objdir "*) - new_libs="$new_libs -L$path/$objdir" ;; + func_append new_libs " -L$path/$objdir" ;; esac ;; esac @@ -7192,10 +8020,10 @@ EOF -L*) case " $new_libs " in *" $deplib "*) ;; - *) new_libs="$new_libs $deplib" ;; + *) func_append new_libs " $deplib" ;; esac ;; - *) new_libs="$new_libs $deplib" ;; + *) func_append new_libs " $deplib" ;; esac done deplibs="$new_libs" @@ -7207,15 +8035,22 @@ EOF # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then + # Remove ${wl} instances when linking with ld. + # FIXME: should test the right _cmds variable. + case $archive_cmds in + *\$LD\ *) wl= ;; + esac if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" - test "$mode" != relink && rpath="$compile_rpath$rpath" + test "$opt_mode" != relink && rpath="$compile_rpath$rpath" for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then + func_replace_sysroot "$libdir" + libdir=$func_replace_sysroot_result if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else @@ -7224,18 +8059,18 @@ EOF *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" - dep_rpath="$dep_rpath $flag" + func_append dep_rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; - *) perm_rpath="$perm_rpath $libdir" ;; + *) func_append perm_rpath " $libdir" ;; esac fi done @@ -7243,17 +8078,13 @@ EOF if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" - if test -n "$hardcode_libdir_flag_spec_ld"; then - eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" - else - eval dep_rpath=\"$hardcode_libdir_flag_spec\" - fi + eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do - rpath="$rpath$dir:" + func_append rpath "$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi @@ -7261,7 +8092,7 @@ EOF fi shlibpath="$finalize_shlibpath" - test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" + test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi @@ -7287,7 +8118,7 @@ EOF linknames= for link do - linknames="$linknames $link" + func_append linknames " $link" done # Use standard objects if they are pic @@ -7298,7 +8129,7 @@ EOF if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" export_symbols="$output_objdir/$libname.uexp" - delfiles="$delfiles $export_symbols" + func_append delfiles " $export_symbols" fi orig_export_symbols= @@ -7329,13 +8160,45 @@ EOF $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do + for cmd1 in $cmds; do IFS="$save_ifs" - eval cmd=\"$cmd\" - func_len " $cmd" - len=$func_len_result - if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then + # Take the normal branch if the nm_file_list_spec branch + # doesn't work or if tool conversion is not needed. + case $nm_file_list_spec~$to_tool_file_cmd in + *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) + try_normal_branch=yes + eval cmd=\"$cmd1\" + func_len " $cmd" + len=$func_len_result + ;; + *) + try_normal_branch=no + ;; + esac + if test "$try_normal_branch" = yes \ + && { test "$len" -lt "$max_cmd_len" \ + || test "$max_cmd_len" -le -1; } + then + func_show_eval "$cmd" 'exit $?' + skipped_export=false + elif test -n "$nm_file_list_spec"; then + func_basename "$output" + output_la=$func_basename_result + save_libobjs=$libobjs + save_output=$output + output=${output_objdir}/${output_la}.nm + func_to_tool_file "$output" + libobjs=$nm_file_list_spec$func_to_tool_file_result + func_append delfiles " $output" + func_verbose "creating $NM input file list: $output" + for obj in $save_libobjs; do + func_to_tool_file "$obj" + $ECHO "$func_to_tool_file_result" + done > "$output" + eval cmd=\"$cmd1\" func_show_eval "$cmd" 'exit $?' + output=$save_output + libobjs=$save_libobjs skipped_export=false else # The command line is too long to execute in one step. @@ -7369,7 +8232,7 @@ EOF # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter - delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" + func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi @@ -7379,7 +8242,7 @@ EOF case " $convenience " in *" $test_deplib "*) ;; *) - tmp_deplibs="$tmp_deplibs $test_deplib" + func_append tmp_deplibs " $test_deplib" ;; esac done @@ -7399,21 +8262,21 @@ EOF test "X$libobjs" = "X " && libobjs= else gentop="$output_objdir/${outputname}x" - generated="$generated $gentop" + func_append generated " $gentop" func_extract_archives $gentop $convenience - libobjs="$libobjs $func_extract_archives_result" + func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" - linker_flags="$linker_flags $flag" + func_append linker_flags " $flag" fi # Make a backup of the uninstalled library when relinking - if test "$mode" = relink; then + if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi @@ -7475,10 +8338,13 @@ EOF echo 'INPUT (' > $output for obj in $save_libobjs do - $ECHO "$obj" >> $output + func_to_tool_file "$obj" + $ECHO "$func_to_tool_file_result" >> $output done echo ')' >> $output - delfiles="$delfiles $output" + func_append delfiles " $output" + func_to_tool_file "$output" + output=$func_to_tool_file_result elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then output=${output_objdir}/${output_la}.lnk func_verbose "creating linker input file list: $output" @@ -7492,10 +8358,12 @@ EOF fi for obj do - $ECHO "$obj" >> $output + func_to_tool_file "$obj" + $ECHO "$func_to_tool_file_result" >> $output done - delfiles="$delfiles $output" - output=$firstobj\"$file_list_spec$output\" + func_append delfiles " $output" + func_to_tool_file "$output" + output=$firstobj\"$file_list_spec$func_to_tool_file_result\" else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." @@ -7546,7 +8414,7 @@ EOF if test -n "$last_robj"; then eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" fi - delfiles="$delfiles $output" + func_append delfiles " $output" else output= @@ -7580,7 +8448,7 @@ EOF lt_exit=$? # Restore the uninstalled library and exit - if test "$mode" = relink; then + if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) @@ -7613,7 +8481,7 @@ EOF # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter - delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" + func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi @@ -7654,10 +8522,10 @@ EOF # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" - generated="$generated $gentop" + func_append generated " $gentop" func_extract_archives $gentop $dlprefiles - libobjs="$libobjs $func_extract_archives_result" + func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi @@ -7673,7 +8541,7 @@ EOF lt_exit=$? # Restore the uninstalled library and exit - if test "$mode" = relink; then + if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) @@ -7685,7 +8553,7 @@ EOF IFS="$save_ifs" # Restore the uninstalled library and exit - if test "$mode" = relink; then + if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then @@ -7769,13 +8637,16 @@ EOF reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` else gentop="$output_objdir/${obj}x" - generated="$generated $gentop" + func_append generated " $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi + # If we're not building shared, we need to use non_pic_objs + test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" + # Create the old-style object. reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test @@ -7849,8 +8720,8 @@ EOF if test "$tagname" = CXX ; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) - compile_command="$compile_command ${wl}-bind_at_load" - finalize_command="$finalize_command ${wl}-bind_at_load" + func_append compile_command " ${wl}-bind_at_load" + func_append finalize_command " ${wl}-bind_at_load" ;; esac fi @@ -7870,7 +8741,7 @@ EOF *) case " $compile_deplibs " in *" -L$path/$objdir "*) - new_libs="$new_libs -L$path/$objdir" ;; + func_append new_libs " -L$path/$objdir" ;; esac ;; esac @@ -7880,17 +8751,17 @@ EOF -L*) case " $new_libs " in *" $deplib "*) ;; - *) new_libs="$new_libs $deplib" ;; + *) func_append new_libs " $deplib" ;; esac ;; - *) new_libs="$new_libs $deplib" ;; + *) func_append new_libs " $deplib" ;; esac done compile_deplibs="$new_libs" - compile_command="$compile_command $compile_deplibs" - finalize_command="$finalize_command $finalize_deplibs" + func_append compile_command " $compile_deplibs" + func_append finalize_command " $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. @@ -7898,7 +8769,7 @@ EOF # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" ;; + *) func_append finalize_rpath " $libdir" ;; esac done fi @@ -7917,18 +8788,18 @@ EOF *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" - rpath="$rpath $flag" + func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; - *) perm_rpath="$perm_rpath $libdir" ;; + *) func_append perm_rpath " $libdir" ;; esac fi case $host in @@ -7937,12 +8808,12 @@ EOF case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; - *) dllsearchpath="$dllsearchpath:$libdir";; + *) func_append dllsearchpath ":$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; - *) dllsearchpath="$dllsearchpath:$testbindir";; + *) func_append dllsearchpath ":$testbindir";; esac ;; esac @@ -7968,18 +8839,18 @@ EOF *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" - rpath="$rpath $flag" + func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; - *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; + *) func_append finalize_perm_rpath " $libdir" ;; esac fi done @@ -8030,6 +8901,12 @@ EOF exit_status=0 func_show_eval "$link_command" 'exit_status=$?' + if test -n "$postlink_cmds"; then + func_to_tool_file "$output" + postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` + func_execute_cmds "$postlink_cmds" 'exit $?' + fi + # Delete the generated files. if test -f "$output_objdir/${outputname}S.${objext}"; then func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' @@ -8052,7 +8929,7 @@ EOF # We should set the runpath_var. rpath= for dir in $perm_rpath; do - rpath="$rpath$dir:" + func_append rpath "$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi @@ -8060,7 +8937,7 @@ EOF # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do - rpath="$rpath$dir:" + func_append rpath "$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi @@ -8075,6 +8952,13 @@ EOF $opt_dry_run || $RM $output # Link the executable and exit func_show_eval "$link_command" 'exit $?' + + if test -n "$postlink_cmds"; then + func_to_tool_file "$output" + postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` + func_execute_cmds "$postlink_cmds" 'exit $?' + fi + exit $EXIT_SUCCESS fi @@ -8108,6 +8992,12 @@ EOF func_show_eval "$link_command" 'exit $?' + if test -n "$postlink_cmds"; then + func_to_tool_file "$output_objdir/$outputname" + postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` + func_execute_cmds "$postlink_cmds" 'exit $?' + fi + # Now create the wrapper script. func_verbose "creating $output" @@ -8205,7 +9095,7 @@ EOF else oldobjs="$old_deplibs $non_pic_objects" if test "$preload" = yes && test -f "$symfileobj"; then - oldobjs="$oldobjs $symfileobj" + func_append oldobjs " $symfileobj" fi fi addlibs="$old_convenience" @@ -8213,10 +9103,10 @@ EOF if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" - generated="$generated $gentop" + func_append generated " $gentop" func_extract_archives $gentop $addlibs - oldobjs="$oldobjs $func_extract_archives_result" + func_append oldobjs " $func_extract_archives_result" fi # Do each command in the archive commands. @@ -8227,10 +9117,10 @@ EOF # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" - generated="$generated $gentop" + func_append generated " $gentop" func_extract_archives $gentop $dlprefiles - oldobjs="$oldobjs $func_extract_archives_result" + func_append oldobjs " $func_extract_archives_result" fi # POSIX demands no paths to be encoded in archives. We have @@ -8248,7 +9138,7 @@ EOF else echo "copying selected object files to avoid basename conflicts..." gentop="$output_objdir/${outputname}x" - generated="$generated $gentop" + func_append generated " $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs oldobjs= @@ -8272,18 +9162,30 @@ EOF esac done func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" - oldobjs="$oldobjs $gentop/$newobj" + func_append oldobjs " $gentop/$newobj" ;; - *) oldobjs="$oldobjs $obj" ;; + *) func_append oldobjs " $obj" ;; esac done fi + func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 + tool_oldlib=$func_to_tool_file_result eval cmds=\"$old_archive_cmds\" func_len " $cmds" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds + elif test -n "$archiver_list_spec"; then + func_verbose "using command file archive linking..." + for obj in $oldobjs + do + func_to_tool_file "$obj" + $ECHO "$func_to_tool_file_result" + done > $output_objdir/$libname.libcmd + func_to_tool_file "$output_objdir/$libname.libcmd" + oldobjs=" $archiver_list_spec$func_to_tool_file_result" + cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." @@ -8377,12 +9279,23 @@ EOF *.la) func_basename "$deplib" name="$func_basename_result" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + func_resolve_sysroot "$deplib" + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" - newdependency_libs="$newdependency_libs $libdir/$name" + func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" + ;; + -L*) + func_stripname -L '' "$deplib" + func_replace_sysroot "$func_stripname_result" + func_append newdependency_libs " -L$func_replace_sysroot_result" + ;; + -R*) + func_stripname -R '' "$deplib" + func_replace_sysroot "$func_stripname_result" + func_append newdependency_libs " -R$func_replace_sysroot_result" ;; - *) newdependency_libs="$newdependency_libs $deplib" ;; + *) func_append newdependency_libs " $deplib" ;; esac done dependency_libs="$newdependency_libs" @@ -8396,9 +9309,9 @@ EOF eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" - newdlfiles="$newdlfiles $libdir/$name" + func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" ;; - *) newdlfiles="$newdlfiles $lib" ;; + *) func_append newdlfiles " $lib" ;; esac done dlfiles="$newdlfiles" @@ -8415,7 +9328,7 @@ EOF eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" - newdlprefiles="$newdlprefiles $libdir/$name" + func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" ;; esac done @@ -8427,7 +9340,7 @@ EOF [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac - newdlfiles="$newdlfiles $abs" + func_append newdlfiles " $abs" done dlfiles="$newdlfiles" newdlprefiles= @@ -8436,7 +9349,7 @@ EOF [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac - newdlprefiles="$newdlprefiles $abs" + func_append newdlprefiles " $abs" done dlprefiles="$newdlprefiles" fi @@ -8521,7 +9434,7 @@ relink_command=\"$relink_command\"" exit $EXIT_SUCCESS } -{ test "$mode" = link || test "$mode" = relink; } && +{ test "$opt_mode" = link || test "$opt_mode" = relink; } && func_mode_link ${1+"$@"} @@ -8541,9 +9454,9 @@ func_mode_uninstall () for arg do case $arg in - -f) RM="$RM $arg"; rmforce=yes ;; - -*) RM="$RM $arg" ;; - *) files="$files $arg" ;; + -f) func_append RM " $arg"; rmforce=yes ;; + -*) func_append RM " $arg" ;; + *) func_append files " $arg" ;; esac done @@ -8552,24 +9465,23 @@ func_mode_uninstall () rmdirs= - origobjdir="$objdir" for file in $files; do func_dirname "$file" "" "." dir="$func_dirname_result" if test "X$dir" = X.; then - objdir="$origobjdir" + odir="$objdir" else - objdir="$dir/$origobjdir" + odir="$dir/$objdir" fi func_basename "$file" name="$func_basename_result" - test "$mode" = uninstall && objdir="$dir" + test "$opt_mode" = uninstall && odir="$dir" - # Remember objdir for removal later, being careful to avoid duplicates - if test "$mode" = clean; then + # Remember odir for removal later, being careful to avoid duplicates + if test "$opt_mode" = clean; then case " $rmdirs " in - *" $objdir "*) ;; - *) rmdirs="$rmdirs $objdir" ;; + *" $odir "*) ;; + *) func_append rmdirs " $odir" ;; esac fi @@ -8595,18 +9507,17 @@ func_mode_uninstall () # Delete the libtool libraries and symlinks. for n in $library_names; do - rmfiles="$rmfiles $objdir/$n" + func_append rmfiles " $odir/$n" done - test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" + test -n "$old_library" && func_append rmfiles " $odir/$old_library" - case "$mode" in + case "$opt_mode" in clean) - case " $library_names " in - # " " in the beginning catches empty $dlname + case " $library_names " in *" $dlname "*) ;; - *) rmfiles="$rmfiles $objdir/$dlname" ;; + *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; esac - test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" + test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" ;; uninstall) if test -n "$library_names"; then @@ -8634,19 +9545,19 @@ func_mode_uninstall () # Add PIC object to the list of files to remove. if test -n "$pic_object" && test "$pic_object" != none; then - rmfiles="$rmfiles $dir/$pic_object" + func_append rmfiles " $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test "$non_pic_object" != none; then - rmfiles="$rmfiles $dir/$non_pic_object" + func_append rmfiles " $dir/$non_pic_object" fi fi ;; *) - if test "$mode" = clean ; then + if test "$opt_mode" = clean ; then noexename=$name case $file in *.exe) @@ -8656,7 +9567,7 @@ func_mode_uninstall () noexename=$func_stripname_result # $file with .exe has already been added to rmfiles, # add $file without .exe - rmfiles="$rmfiles $file" + func_append rmfiles " $file" ;; esac # Do a test to see if this is a libtool program. @@ -8665,7 +9576,7 @@ func_mode_uninstall () func_ltwrapper_scriptname "$file" relink_command= func_source $func_ltwrapper_scriptname_result - rmfiles="$rmfiles $func_ltwrapper_scriptname_result" + func_append rmfiles " $func_ltwrapper_scriptname_result" else relink_command= func_source $dir/$noexename @@ -8673,12 +9584,12 @@ func_mode_uninstall () # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles - rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" + func_append rmfiles " $odir/$name $odir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then - rmfiles="$rmfiles $objdir/lt-$name" + func_append rmfiles " $odir/lt-$name" fi if test "X$noexename" != "X$name" ; then - rmfiles="$rmfiles $objdir/lt-${noexename}.c" + func_append rmfiles " $odir/lt-${noexename}.c" fi fi fi @@ -8686,7 +9597,6 @@ func_mode_uninstall () esac func_show_eval "$RM $rmfiles" 'exit_status=1' done - objdir="$origobjdir" # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do @@ -8698,16 +9608,16 @@ func_mode_uninstall () exit $exit_status } -{ test "$mode" = uninstall || test "$mode" = clean; } && +{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && func_mode_uninstall ${1+"$@"} -test -z "$mode" && { +test -z "$opt_mode" && { help="$generic_help" func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ - func_fatal_help "invalid operation mode \`$mode'" + func_fatal_help "invalid operation mode \`$opt_mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" diff --git a/libs/neon/macros/ld-version-script.m4 b/libs/neon/macros/ld-version-script.m4 index 4dec588b..63386f17 100644 --- a/libs/neon/macros/ld-version-script.m4 +++ b/libs/neon/macros/ld-version-script.m4 @@ -1,5 +1,5 @@ -# ld-version-script.m4 serial 1 -dnl Copyright (C) 2008, 2009 Free Software Foundation, Inc. +# ld-version-script.m4 serial 3 +dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -26,18 +26,28 @@ AC_DEFUN([gl_LD_VERSION_SCRIPT], save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map" cat > conftest.map < conftest.map < -*- autoconf -*- +# Copyright (C) 1998-2009 Joe Orton -*- autoconf -*- # Copyright (C) 2004 Aleix Conchillo Flaque # # This file is free software; you may copy and/or distribute it with @@ -136,12 +136,12 @@ AC_DEFUN([NE_VERSIONS_BUNDLED], [ # Define the current versions. NE_VERSION_MAJOR=0 -NE_VERSION_MINOR=29 -NE_VERSION_PATCH=6 +NE_VERSION_MINOR=30 +NE_VERSION_PATCH=0 NE_VERSION_TAG= -# 0.29.x is backwards-compatible to 0.27.x, so AGE=2 -NE_LIBTOOL_VERSINFO="29:${NE_VERSION_PATCH}:2" +# 0.30.x is backwards-compatible to 0.27.x, so AGE=3 +NE_LIBTOOL_VERSINFO="30:${NE_VERSION_PATCH}:3" NE_DEFINE_VERSIONS @@ -448,7 +448,7 @@ AC_REQUIRE([AC_PROG_MAKE_SET]) AC_REQUIRE([AC_HEADER_STDC]) -AC_CHECK_HEADERS([errno.h stdarg.h string.h stdlib.h]) +AC_CHECK_HEADERS([errno.h stdarg.h string.h stdlib.h sys/uio.h]) NEON_FORMAT(size_t,,u) dnl size_t is unsigned; use %u formats NEON_FORMAT(off_t) @@ -510,6 +510,7 @@ fi if test "$NE_FLAG_LFS" = "yes"; then AC_DEFINE_UNQUOTED([NE_FMT_NE_OFF_T], [NE_FMT_OFF64_T], [Define to be printf format string for ne_off_t]) + NE_ADD_ABITAG(LFS) else AC_DEFINE_UNQUOTED([NE_FMT_NE_OFF_T], [NE_FMT_OFF_T]) fi @@ -982,12 +983,13 @@ gnutls) # Check for functions in later releases NE_CHECK_FUNCS([gnutls_session_get_data2 gnutls_x509_dn_get_rdn_ava \ gnutls_sign_callback_set \ + gnutls_certificate_get_issuer \ gnutls_certificate_get_x509_cas \ - gnutls_certificate_verify_peers2]) + gnutls_x509_crt_sign2]) - # fail if gnutls_certificate_verify_peers2 is not found - if test x${ac_cv_func_gnutls_certificate_verify_peers2} != xyes; then - AC_MSG_ERROR([GnuTLS version predates gnutls_certificate_verify_peers2, newer version required]) + # fail if gnutls_x509_crt_sign2 is not found (it was introduced in 1.2.0, which is required) + if test x${ac_cv_func_gnutls_x509_crt_sign2} != xyes; then + AC_MSG_ERROR([GnuTLS version predates gnutls_x509_crt_sign2, newer version required (at least 1.2.0)]) fi # Check for iconv support if using the new RDN access functions: @@ -1181,7 +1183,7 @@ if test x${enable_nls} = xyes; then # presume that dgettext() is available if bindtextdomain() is... # checking for dgettext() itself is awkward because gcc has a # builtin of that function, which confuses AC_CHECK_FUNCS et al. - NE_SEARCH_LIBS(bindtextdomain, intl,,[enable_nls=no]) + NE_SEARCH_LIBS(bindtextdomain, intl, -liconv ,[enable_nls=no]) NE_CHECK_FUNCS(bind_textdomain_codeset) fi diff --git a/libs/neon/neon.mak b/libs/neon/neon.mak index 76d8a81d..ce53a30f 100644 --- a/libs/neon/neon.mak +++ b/libs/neon/neon.mak @@ -74,22 +74,22 @@ ZLIB_CLEAN = !ELSE ZLIB_CLEAN = ZLIB_CLEAN !IF "$(DEBUG_BUILD)" == "" -ZLIB_STATICLIB = $(TEMPDIR)\zlib\zlib.lib -ZLIB_SHAREDLIB = $(TEMPDIR)\zlib\zlib1.dll -ZLIB_IMPLIB = $(TEMPDIR)\zlib\zdll.lib +ZLIB_STATICLIB = zlib.lib +ZLIB_SHAREDLIB = zlib1.dll +ZLIB_IMPLIB = zdll.lib ZLIB_LDFLAGS = /nologo /release !ELSE -ZLIB_STATICLIB = $(TEMPDIR)\zlib\zlib.lib -ZLIB_SHAREDLIB = $(TEMPDIR)\zlib\zlib1.dll -ZLIB_IMPLIB = $(TEMPDIR)\zlib\zdll.lib +ZLIB_STATICLIB = zlib_d.lib +ZLIB_SHAREDLIB = zlib1_d.dll +ZLIB_IMPLIB = zdll_d.lib ZLIB_LDFLAGS = /nologo /debug !ENDIF ZLIB_FLAGS = /I "$(ZLIB_SRC)" /D NE_HAVE_ZLIB !IF "$(ZLIB_DLL)" == "" -ZLIB_LIBS = "$(ZLIB_STATICLIB)" +ZLIB_LIBS = "$(ZLIB_SRC)\$(ZLIB_STATICLIB)" !ELSE ZLIB_FLAGS = $(ZLIB_FLAGS) /D ZLIB_DLL -ZLIB_LIBS = "$(ZLIB_IMPLIB)" +ZLIB_LIBS = "$(ZLIB_SRC)\$(ZLIB_IMPLIB)" !ENDIF !ENDIF @@ -237,3 +237,23 @@ CLEAN: $(ZLIB_CLEAN) "$(INTDIR)\ne_xml.obj": .\src\ne_xml.c "$(INTDIR)\ne_xmlreq.obj": .\src\ne_xmlreq.c +"$(ZLIB_SRC)\$(ZLIB_STATICLIB)": + <\n" "Language-Team: cz\n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=iso-8859-2\n" "Content-Transfer-Encoding: 8bit\n" @@ -24,110 +25,115 @@ msgstr "" "Stavová øádka byla: %s" # src/console_fe.c:961 -#: src/ne_auth.c:134 +#: src/ne_auth.c:139 #, fuzzy, c-format msgid "Could not authenticate to server: %s" msgstr "Nelze se pøipojit k serveru" # src/console_fe.c:961 -#: src/ne_auth.c:139 +#: src/ne_auth.c:144 #, fuzzy, c-format msgid "Could not authenticate to proxy server: %s" msgstr "Nelze se pøipojit k proxy serveru" -#: src/ne_auth.c:374 +#: src/ne_auth.c:386 #, c-format msgid "rejected %s challenge" msgstr "" -#: src/ne_auth.c:390 +#: src/ne_auth.c:402 msgid "missing realm in Basic challenge" msgstr "" -#: src/ne_auth.c:485 +#: src/ne_auth.c:497 msgid "invalid Negotiate token" msgstr "" -#: src/ne_auth.c:508 +#: src/ne_auth.c:520 #, fuzzy msgid "GSSAPI authentication error: " msgstr "Je vy¾adována autentizace na %s `%s':\n" -#: src/ne_auth.c:521 +#: src/ne_auth.c:533 #, c-format msgid "GSSAPI failure (code %u)" msgstr "" -#: src/ne_auth.c:556 +#: src/ne_auth.c:568 msgid "ignoring empty Negotiate continuation" msgstr "" -#: src/ne_auth.c:571 +#: src/ne_auth.c:583 #, c-format msgid "Negotiate response verification failed: invalid response header token" msgstr "" -#: src/ne_auth.c:593 +#: src/ne_auth.c:605 #, c-format msgid "Negotiate response verification failure: %s" msgstr "" -#: src/ne_auth.c:765 +#: src/ne_auth.c:669 +#, c-format +msgid "SSPI response verification failed: invalid response header token" +msgstr "" + +#: src/ne_auth.c:802 msgid "unknown algorithm in Digest challenge" msgstr "" -#: src/ne_auth.c:769 +#: src/ne_auth.c:806 msgid "incompatible algorithm in Digest challenge" msgstr "" -#: src/ne_auth.c:773 +#: src/ne_auth.c:810 msgid "missing parameter in Digest challenge" msgstr "" -#: src/ne_auth.c:777 +#: src/ne_auth.c:814 msgid "initial Digest challenge was stale" msgstr "" -#: src/ne_auth.c:784 +#: src/ne_auth.c:821 msgid "stale Digest challenge with new algorithm or realm" msgstr "" -#: src/ne_auth.c:796 +#: src/ne_auth.c:833 #, fuzzy msgid "could not parse domain in Digest challenge" msgstr "Nelze zpracovat velikost bloku" -#: src/ne_auth.c:1105 +#: src/ne_auth.c:1142 #, c-format msgid "Digest mutual authentication failure: missing parameters" msgstr "" -#: src/ne_auth.c:1110 +#: src/ne_auth.c:1147 #, c-format msgid "Digest mutual authentication failure: client nonce mismatch" msgstr "" -#: src/ne_auth.c:1120 +#: src/ne_auth.c:1157 #, c-format msgid "Digest mutual authentication failure: could not parse nonce count" msgstr "" -#: src/ne_auth.c:1125 +#: src/ne_auth.c:1162 #, c-format msgid "Digest mutual authentication failure: nonce count mismatch (%u not %u)" msgstr "" -#: src/ne_auth.c:1168 +#: src/ne_auth.c:1205 #, c-format msgid "Digest mutual authentication failure: request-digest mismatch" msgstr "" -#: src/ne_auth.c:1299 +#: src/ne_auth.c:1336 #, c-format msgid "ignored %s challenge" msgstr "" -#: src/ne_auth.c:1378 +#: src/ne_auth.c:1415 #, fuzzy msgid "could not parse challenge" msgstr "Nelze zpracovat velikost bloku" @@ -170,52 +176,52 @@ msgstr "Nelze otev msgid "Could not initialize zlib" msgstr "Nelze otevøít soubor: " -#: src/ne_gnutls.c:172 +#: src/ne_gnutls.c:176 #, c-format msgid "[unprintable:#%lu]" msgstr "" -#: src/ne_gnutls.c:201 +#: src/ne_gnutls.c:205 msgid "[unprintable]" msgstr "" -#: src/ne_gnutls.c:817 +#: src/ne_gnutls.c:845 msgid "signed using insecure algorithm" msgstr "" -#: src/ne_gnutls.c:820 +#: src/ne_gnutls.c:848 #, c-format msgid "unrecognized errors (%u)" msgstr "" -#: src/ne_gnutls.c:865 src/ne_openssl.c:468 +#: src/ne_gnutls.c:893 src/ne_openssl.c:470 #, c-format msgid "Server certificate was missing commonName attribute in subject name" msgstr "" # src/console_fe.c:992 -#: src/ne_gnutls.c:879 +#: src/ne_gnutls.c:907 #, fuzzy, c-format msgid "Could not verify server certificate: %s" msgstr "Nelze zapsat do souboru: %s" -#: src/ne_gnutls.c:891 src/ne_openssl.c:455 +#: src/ne_gnutls.c:919 src/ne_openssl.c:457 #, c-format msgid "Certificate verification error: %s" msgstr "" -#: src/ne_gnutls.c:924 src/ne_openssl.c:674 +#: src/ne_gnutls.c:952 src/ne_openssl.c:702 #, c-format msgid "SSL handshake failed, client certificate was requested: %s" msgstr "" # src/console_fe.c:992 -#: src/ne_gnutls.c:929 src/ne_openssl.c:679 +#: src/ne_gnutls.c:957 src/ne_openssl.c:707 #, fuzzy, c-format msgid "SSL handshake failed: %s" msgstr "Nelze zapsat do souboru: %s" -#: src/ne_gnutls.c:939 +#: src/ne_gnutls.c:967 #, c-format msgid "Server did not send certificate chain" msgstr "" @@ -234,12 +240,12 @@ msgstr "" msgid "No activelock for <%s> returned in LOCK refresh response" msgstr "" -#: src/ne_openssl.c:699 +#: src/ne_openssl.c:727 #, c-format msgid "SSL server did not present certificate" msgstr "" -#: src/ne_openssl.c:708 +#: src/ne_openssl.c:736 #, c-format msgid "Server certificate changed: connection intercepted?" msgstr "" @@ -291,208 +297,209 @@ msgstr "" msgid "Could not seek to offset %s of request body file: %s" msgstr "Nelze zapsat do souboru: %s" -#: src/ne_request.c:385 +#: src/ne_request.c:423 msgid "Could not send request body" msgstr "Nelze odeslat tìlo po¾adavku" -#: src/ne_request.c:728 +#: src/ne_request.c:450 +#, fuzzy +msgid "Could not send chunked request terminator" +msgstr "Nelze poslat po¾adavek" + +#: src/ne_request.c:784 msgid "Could not read chunk size" msgstr "Nelze naèíst velikost bloku" -#: src/ne_request.c:735 +#: src/ne_request.c:791 msgid "Could not parse chunk size" msgstr "Nelze zpracovat velikost bloku" -#: src/ne_request.c:772 +#: src/ne_request.c:828 msgid "Could not read response body" msgstr "Nelze naèíst tìlo odpovìdi" -#: src/ne_request.c:788 +#: src/ne_request.c:844 #, fuzzy msgid "Could not read chunk delimiter" msgstr "Nelze naèíst velikost bloku" -#: src/ne_request.c:791 +#: src/ne_request.c:847 msgid "Chunk delimiter was invalid" msgstr "" -#: src/ne_request.c:896 +#: src/ne_request.c:952 msgid "Could not read status line" msgstr "Nelze pøeèíst stavový øádek" -#: src/ne_request.c:918 +#: src/ne_request.c:974 #, fuzzy msgid "Could not parse response status line" msgstr "Nelze zpracovat stavový øádek odpovìdi." -#: src/ne_request.c:930 +#: src/ne_request.c:986 #, fuzzy msgid "Could not read interim response headers" msgstr "Nelze naèíst tìlo odpovìdi" -#: src/ne_request.c:964 +#: src/ne_request.c:1020 msgid "Could not send request" msgstr "Nelze poslat po¾adavek" -#: src/ne_request.c:1012 src/ne_request.c:1030 src/ne_request.c:1040 +#: src/ne_request.c:1068 src/ne_request.c:1086 src/ne_request.c:1096 msgid "Error reading response headers" msgstr "Chyba pøi ètení hlavièek odpovìdi" -#: src/ne_request.c:1058 +#: src/ne_request.c:1114 #, c-format msgid "Response header too long" msgstr "Hlavièka odpovìdi je pøíli¹ dlouhá" -#: src/ne_request.c:1140 +#: src/ne_request.c:1196 #, fuzzy msgid "Response exceeded maximum number of header fields" msgstr "Odpovìï pøekrocila maximální poøet polo¾ek v hlavicce." # src/console_fe.c:956 -#: src/ne_request.c:1155 +#: src/ne_request.c:1211 #, fuzzy, c-format msgid "Could not resolve hostname `%s': %s" msgstr "%s: Chyba: Nelze najít adresu vzdáleného poèítaèe (%s).\n" -#: src/ne_request.c:1286 +#: src/ne_request.c:1342 msgid "Unknown transfer-coding in response" msgstr "" -#: src/ne_request.c:1299 +#: src/ne_request.c:1355 msgid "Invalid Content-Length in response" msgstr "" # src/console_fe.c:992 -#: src/ne_request.c:1372 +#: src/ne_request.c:1428 #, c-format msgid "Could not write to file: %s" msgstr "Nelze zapsat do souboru: %s" -#: src/ne_request.c:1445 +#: src/ne_request.c:1501 #, fuzzy, c-format msgid "Could not create SSL connection through proxy server: %s" msgstr "Nelze navázat SSL spojení pøes proxy server." -#: src/ne_request.c:1484 +#: src/ne_request.c:1540 #, fuzzy, c-format msgid "Could not create socket" msgstr "Nelze navázat SSL spojení" # src/console_fe.c:961 -#: src/ne_request.c:1518 +#: src/ne_request.c:1574 msgid "Could not connect to server" msgstr "Nelze se pøipojit k serveru" # src/console_fe.c:961 -#: src/ne_request.c:1520 +#: src/ne_request.c:1576 msgid "Could not connect to proxy server" msgstr "Nelze se pøipojit k proxy serveru" -#: src/ne_request.c:1563 +#: src/ne_request.c:1619 #, c-format msgid "Could not find IPv4 address of hostname %s for SOCKS v4 proxy" msgstr "" -#: src/ne_request.c:1621 +#: src/ne_request.c:1677 #, fuzzy, c-format msgid "Could not establish connection from SOCKS proxy (%s:%u): %s" msgstr "Nelze navázat SSL spojení pøes proxy server." -#: src/ne_session.c:530 src/ne_session.c:541 +#: src/ne_session.c:538 src/ne_session.c:549 msgid "[invalid date]" msgstr "" -#: src/ne_session.c:554 +#: src/ne_session.c:562 msgid "certificate is not yet valid" msgstr "" -#: src/ne_session.c:555 +#: src/ne_session.c:563 msgid "certificate has expired" msgstr "" -#: src/ne_session.c:556 +#: src/ne_session.c:564 msgid "certificate issued for a different hostname" msgstr "" -#: src/ne_session.c:557 +#: src/ne_session.c:565 msgid "issuer is not trusted" msgstr "" -#: src/ne_session.c:558 +#: src/ne_session.c:566 msgid "bad certificate chain" msgstr "" -#: src/ne_session.c:559 +#: src/ne_session.c:567 msgid "certificate has been revoked" msgstr "" -#: src/ne_session.c:564 +#: src/ne_session.c:572 msgid "Server certificate verification failed: " msgstr "" -#: src/ne_socket.c:516 src/ne_socket.c:612 src/ne_socket.c:716 +#: src/ne_socket.c:522 src/ne_socket.c:618 src/ne_socket.c:722 #, fuzzy msgid "Connection closed" msgstr "Server ukonèil spojení." -#: src/ne_socket.c:622 src/ne_socket.c:728 +#: src/ne_socket.c:628 src/ne_socket.c:736 #, fuzzy msgid "Secure connection truncated" msgstr "Spojení vypr¹elo." -#: src/ne_socket.c:634 src/ne_socket.c:740 +#: src/ne_socket.c:640 src/ne_socket.c:748 #, fuzzy, c-format msgid "SSL error: %s" msgstr "%s: Chyba: %s\n" -#: src/ne_socket.c:637 +#: src/ne_socket.c:643 #, c-format msgid "SSL error code %d/%d/%lu" msgstr "" -#: src/ne_socket.c:721 +#: src/ne_socket.c:727 #, fuzzy, c-format msgid "SSL alert received: %s" msgstr "%s: Chyba: %s\n" -#: src/ne_socket.c:736 +#: src/ne_socket.c:744 msgid "SSL socket read failed" msgstr "" -#: src/ne_socket.c:867 +#: src/ne_socket.c:875 msgid "Line too long" msgstr "Øádek je pøíli¹ dlouhý" -#: src/ne_socket.c:1012 src/ne_socket.c:1018 +#: src/ne_socket.c:1036 src/ne_socket.c:1042 msgid "Host not found" msgstr "Poèítaè nenalezen" -#: src/ne_socket.c:1221 +#: src/ne_socket.c:1249 #, fuzzy msgid "Connection timed out" msgstr "%s: spojení vypr¹elo." -#: src/ne_socket.c:1412 +#: src/ne_socket.c:1442 msgid "Socket descriptor number exceeds FD_SETSIZE" msgstr "" -#: src/ne_socket.c:1474 +#: src/ne_socket.c:1504 msgid "Socket family not supported" msgstr "" -#: src/ne_socket.c:1701 +#: src/ne_socket.c:1735 msgid "Client certificate verification failed" msgstr "" -#: src/ne_socket.c:1717 +#: src/ne_socket.c:1751 msgid "SSL disabled due to lack of entropy" msgstr "" -#: src/ne_socket.c:1724 -msgid "SSL disabled due to library version mismatch" -msgstr "" - -#: src/ne_socket.c:1730 +#: src/ne_socket.c:1757 #, fuzzy msgid "Could not create SSL structure" msgstr "Nelze navázat SSL spojení" diff --git a/libs/neon/po/de.gmo b/libs/neon/po/de.gmo index 16c2377f..510e178f 100644 Binary files a/libs/neon/po/de.gmo and b/libs/neon/po/de.gmo differ diff --git a/libs/neon/po/de.po b/libs/neon/po/de.po index fae3fbe5..731a230f 100644 --- a/libs/neon/po/de.po +++ b/libs/neon/po/de.po @@ -5,10 +5,11 @@ msgid "" msgstr "" "Project-Id-Version: sitecopy 0.11.3\n" "Report-Msgid-Bugs-To: neon@lists.manyfish.co.uk\n" -"POT-Creation-Date: 2010-10-01 13:30+0100\n" +"POT-Creation-Date: 2013-07-31 16:46+0100\n" "PO-Revision-Date: 2002-01-13 13:37+0100\n" "Last-Translator: Thomas Schultz \n" "Language-Team: de\n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=iso-8859-1\n" "Content-Transfer-Encoding: 8bit\n" @@ -22,109 +23,114 @@ msgstr "" "Ungültige HTTP Status-Zeile im Status-Element in Zeile %d der Antwort:\n" "Status-Zeile war: %s" -#: src/ne_auth.c:134 +#: src/ne_auth.c:139 #, fuzzy, c-format msgid "Could not authenticate to server: %s" msgstr "Verbindungsaufbau zum Server gescheitert." -#: src/ne_auth.c:139 +#: src/ne_auth.c:144 #, fuzzy, c-format msgid "Could not authenticate to proxy server: %s" msgstr "Verbindungsaufbau zum Proxy-Server gescheitert." -#: src/ne_auth.c:374 +#: src/ne_auth.c:386 #, c-format msgid "rejected %s challenge" msgstr "" -#: src/ne_auth.c:390 +#: src/ne_auth.c:402 msgid "missing realm in Basic challenge" msgstr "" -#: src/ne_auth.c:485 +#: src/ne_auth.c:497 msgid "invalid Negotiate token" msgstr "" -#: src/ne_auth.c:508 +#: src/ne_auth.c:520 #, fuzzy msgid "GSSAPI authentication error: " msgstr "Anmeldung wird benötigt auf %s `%s':\n" -#: src/ne_auth.c:521 +#: src/ne_auth.c:533 #, c-format msgid "GSSAPI failure (code %u)" msgstr "" -#: src/ne_auth.c:556 +#: src/ne_auth.c:568 msgid "ignoring empty Negotiate continuation" msgstr "" -#: src/ne_auth.c:571 +#: src/ne_auth.c:583 #, c-format msgid "Negotiate response verification failed: invalid response header token" msgstr "" -#: src/ne_auth.c:593 +#: src/ne_auth.c:605 #, c-format msgid "Negotiate response verification failure: %s" msgstr "" -#: src/ne_auth.c:765 +#: src/ne_auth.c:669 +#, c-format +msgid "SSPI response verification failed: invalid response header token" +msgstr "" + +#: src/ne_auth.c:802 msgid "unknown algorithm in Digest challenge" msgstr "" -#: src/ne_auth.c:769 +#: src/ne_auth.c:806 msgid "incompatible algorithm in Digest challenge" msgstr "" -#: src/ne_auth.c:773 +#: src/ne_auth.c:810 msgid "missing parameter in Digest challenge" msgstr "" -#: src/ne_auth.c:777 +#: src/ne_auth.c:814 msgid "initial Digest challenge was stale" msgstr "" -#: src/ne_auth.c:784 +#: src/ne_auth.c:821 msgid "stale Digest challenge with new algorithm or realm" msgstr "" -#: src/ne_auth.c:796 +#: src/ne_auth.c:833 #, fuzzy msgid "could not parse domain in Digest challenge" msgstr "Parser-Fehler bei Ermittlung der Blockgröße" -#: src/ne_auth.c:1105 +#: src/ne_auth.c:1142 #, c-format msgid "Digest mutual authentication failure: missing parameters" msgstr "" -#: src/ne_auth.c:1110 +#: src/ne_auth.c:1147 #, c-format msgid "Digest mutual authentication failure: client nonce mismatch" msgstr "" -#: src/ne_auth.c:1120 +#: src/ne_auth.c:1157 #, c-format msgid "Digest mutual authentication failure: could not parse nonce count" msgstr "" -#: src/ne_auth.c:1125 +#: src/ne_auth.c:1162 #, c-format msgid "Digest mutual authentication failure: nonce count mismatch (%u not %u)" msgstr "" -#: src/ne_auth.c:1168 +#: src/ne_auth.c:1205 #, c-format msgid "Digest mutual authentication failure: request-digest mismatch" msgstr "" -#: src/ne_auth.c:1299 +#: src/ne_auth.c:1336 #, c-format msgid "ignored %s challenge" msgstr "" -#: src/ne_auth.c:1378 +#: src/ne_auth.c:1415 #, fuzzy msgid "could not parse challenge" msgstr "Parser-Fehler bei Ermittlung der Blockgröße" @@ -164,50 +170,50 @@ msgstr "Konnte Datei nicht msgid "Could not initialize zlib" msgstr "Konnte Datei nicht öffnen: " -#: src/ne_gnutls.c:172 +#: src/ne_gnutls.c:176 #, c-format msgid "[unprintable:#%lu]" msgstr "" -#: src/ne_gnutls.c:201 +#: src/ne_gnutls.c:205 msgid "[unprintable]" msgstr "" -#: src/ne_gnutls.c:817 +#: src/ne_gnutls.c:845 msgid "signed using insecure algorithm" msgstr "" -#: src/ne_gnutls.c:820 +#: src/ne_gnutls.c:848 #, c-format msgid "unrecognized errors (%u)" msgstr "" -#: src/ne_gnutls.c:865 src/ne_openssl.c:468 +#: src/ne_gnutls.c:893 src/ne_openssl.c:470 #, c-format msgid "Server certificate was missing commonName attribute in subject name" msgstr "" -#: src/ne_gnutls.c:879 +#: src/ne_gnutls.c:907 #, fuzzy, c-format msgid "Could not verify server certificate: %s" msgstr "Konnte nicht in diese Datei schreiben: %s" -#: src/ne_gnutls.c:891 src/ne_openssl.c:455 +#: src/ne_gnutls.c:919 src/ne_openssl.c:457 #, c-format msgid "Certificate verification error: %s" msgstr "" -#: src/ne_gnutls.c:924 src/ne_openssl.c:674 +#: src/ne_gnutls.c:952 src/ne_openssl.c:702 #, c-format msgid "SSL handshake failed, client certificate was requested: %s" msgstr "" -#: src/ne_gnutls.c:929 src/ne_openssl.c:679 +#: src/ne_gnutls.c:957 src/ne_openssl.c:707 #, fuzzy, c-format msgid "SSL handshake failed: %s" msgstr "Konnte nicht in diese Datei schreiben: %s" -#: src/ne_gnutls.c:939 +#: src/ne_gnutls.c:967 #, c-format msgid "Server did not send certificate chain" msgstr "" @@ -226,12 +232,12 @@ msgstr "" msgid "No activelock for <%s> returned in LOCK refresh response" msgstr "" -#: src/ne_openssl.c:699 +#: src/ne_openssl.c:727 #, c-format msgid "SSL server did not present certificate" msgstr "" -#: src/ne_openssl.c:708 +#: src/ne_openssl.c:736 #, c-format msgid "Server certificate changed: connection intercepted?" msgstr "" @@ -280,204 +286,205 @@ msgstr "" msgid "Could not seek to offset %s of request body file: %s" msgstr "Konnte nicht in diese Datei schreiben: %s" -#: src/ne_request.c:385 +#: src/ne_request.c:423 msgid "Could not send request body" msgstr "Konnte den Rumpf der Anfrage nicht schicken" -#: src/ne_request.c:728 +#: src/ne_request.c:450 +#, fuzzy +msgid "Could not send chunked request terminator" +msgstr "Konnte keine Anfrage (request) schicken" + +#: src/ne_request.c:784 msgid "Could not read chunk size" msgstr "Lesefehler bei Ermittlung der Blockgröße" -#: src/ne_request.c:735 +#: src/ne_request.c:791 msgid "Could not parse chunk size" msgstr "Parser-Fehler bei Ermittlung der Blockgröße" -#: src/ne_request.c:772 +#: src/ne_request.c:828 msgid "Could not read response body" msgstr "Konnte Rumpf der Antwort nicht lesen" -#: src/ne_request.c:788 +#: src/ne_request.c:844 #, fuzzy msgid "Could not read chunk delimiter" msgstr "Lesefehler bei Ermittlung der Blockgröße" -#: src/ne_request.c:791 +#: src/ne_request.c:847 msgid "Chunk delimiter was invalid" msgstr "" -#: src/ne_request.c:896 +#: src/ne_request.c:952 msgid "Could not read status line" msgstr "Konnte Status-Zeile des Servers nicht lesen" -#: src/ne_request.c:918 +#: src/ne_request.c:974 #, fuzzy msgid "Could not parse response status line" msgstr "Konnte Status-Zeile des Servers nicht interpretieren." -#: src/ne_request.c:930 +#: src/ne_request.c:986 #, fuzzy msgid "Could not read interim response headers" msgstr "Konnte Rumpf der Antwort nicht lesen" -#: src/ne_request.c:964 +#: src/ne_request.c:1020 msgid "Could not send request" msgstr "Konnte keine Anfrage (request) schicken" -#: src/ne_request.c:1012 src/ne_request.c:1030 src/ne_request.c:1040 +#: src/ne_request.c:1068 src/ne_request.c:1086 src/ne_request.c:1096 msgid "Error reading response headers" msgstr "Fehler beim Lesen der Kopfzeilen (header) der Antwort" -#: src/ne_request.c:1058 +#: src/ne_request.c:1114 #, c-format msgid "Response header too long" msgstr "Kopfzeilen (header) der Antwort zu lang" -#: src/ne_request.c:1140 +#: src/ne_request.c:1196 #, fuzzy msgid "Response exceeded maximum number of header fields" msgstr "Antwort hatte zu viele Header-Felder." -#: src/ne_request.c:1155 +#: src/ne_request.c:1211 #, fuzzy, c-format msgid "Could not resolve hostname `%s': %s" msgstr "%s: Fehler: Konnte den Namen des Servers nicht auflösen (%s).\n" -#: src/ne_request.c:1286 +#: src/ne_request.c:1342 msgid "Unknown transfer-coding in response" msgstr "" -#: src/ne_request.c:1299 +#: src/ne_request.c:1355 msgid "Invalid Content-Length in response" msgstr "" -#: src/ne_request.c:1372 +#: src/ne_request.c:1428 #, c-format msgid "Could not write to file: %s" msgstr "Konnte nicht in diese Datei schreiben: %s" -#: src/ne_request.c:1445 +#: src/ne_request.c:1501 #, fuzzy, c-format msgid "Could not create SSL connection through proxy server: %s" msgstr "Konnte durch den Proxy-Server keine SSL-Verbindung herstellen" -#: src/ne_request.c:1484 +#: src/ne_request.c:1540 #, fuzzy, c-format msgid "Could not create socket" msgstr "Konnte keine SSL-Sitzung herstellen" -#: src/ne_request.c:1518 +#: src/ne_request.c:1574 msgid "Could not connect to server" msgstr "Verbindungsaufbau zum Server gescheitert." -#: src/ne_request.c:1520 +#: src/ne_request.c:1576 msgid "Could not connect to proxy server" msgstr "Verbindungsaufbau zum Proxy-Server gescheitert." -#: src/ne_request.c:1563 +#: src/ne_request.c:1619 #, c-format msgid "Could not find IPv4 address of hostname %s for SOCKS v4 proxy" msgstr "" -#: src/ne_request.c:1621 +#: src/ne_request.c:1677 #, fuzzy, c-format msgid "Could not establish connection from SOCKS proxy (%s:%u): %s" msgstr "Konnte durch den Proxy-Server keine SSL-Verbindung herstellen" -#: src/ne_session.c:530 src/ne_session.c:541 +#: src/ne_session.c:538 src/ne_session.c:549 msgid "[invalid date]" msgstr "" -#: src/ne_session.c:554 +#: src/ne_session.c:562 msgid "certificate is not yet valid" msgstr "" -#: src/ne_session.c:555 +#: src/ne_session.c:563 msgid "certificate has expired" msgstr "" -#: src/ne_session.c:556 +#: src/ne_session.c:564 msgid "certificate issued for a different hostname" msgstr "" -#: src/ne_session.c:557 +#: src/ne_session.c:565 msgid "issuer is not trusted" msgstr "" -#: src/ne_session.c:558 +#: src/ne_session.c:566 msgid "bad certificate chain" msgstr "" -#: src/ne_session.c:559 +#: src/ne_session.c:567 msgid "certificate has been revoked" msgstr "" -#: src/ne_session.c:564 +#: src/ne_session.c:572 msgid "Server certificate verification failed: " msgstr "" -#: src/ne_socket.c:516 src/ne_socket.c:612 src/ne_socket.c:716 +#: src/ne_socket.c:522 src/ne_socket.c:618 src/ne_socket.c:722 #, fuzzy msgid "Connection closed" msgstr "Verbindung vom Server geschlossen" -#: src/ne_socket.c:622 src/ne_socket.c:728 +#: src/ne_socket.c:628 src/ne_socket.c:736 #, fuzzy msgid "Secure connection truncated" msgstr "Verbindung wegen Zeitüberschreitung abgebrochen." -#: src/ne_socket.c:634 src/ne_socket.c:740 +#: src/ne_socket.c:640 src/ne_socket.c:748 #, fuzzy, c-format msgid "SSL error: %s" msgstr "%s: Fehler: %s\n" -#: src/ne_socket.c:637 +#: src/ne_socket.c:643 #, c-format msgid "SSL error code %d/%d/%lu" msgstr "" -#: src/ne_socket.c:721 +#: src/ne_socket.c:727 #, fuzzy, c-format msgid "SSL alert received: %s" msgstr "%s: Fehler: %s\n" -#: src/ne_socket.c:736 +#: src/ne_socket.c:744 msgid "SSL socket read failed" msgstr "" -#: src/ne_socket.c:867 +#: src/ne_socket.c:875 msgid "Line too long" msgstr "Zeile zu lang" -#: src/ne_socket.c:1012 src/ne_socket.c:1018 +#: src/ne_socket.c:1036 src/ne_socket.c:1042 msgid "Host not found" msgstr "Host nicht gefunden" -#: src/ne_socket.c:1221 +#: src/ne_socket.c:1249 #, fuzzy msgid "Connection timed out" msgstr "%s: Verbindung wegen Zeitüberschreitung geschlossen." -#: src/ne_socket.c:1412 +#: src/ne_socket.c:1442 msgid "Socket descriptor number exceeds FD_SETSIZE" msgstr "" -#: src/ne_socket.c:1474 +#: src/ne_socket.c:1504 msgid "Socket family not supported" msgstr "" -#: src/ne_socket.c:1701 +#: src/ne_socket.c:1735 msgid "Client certificate verification failed" msgstr "" -#: src/ne_socket.c:1717 +#: src/ne_socket.c:1751 msgid "SSL disabled due to lack of entropy" msgstr "" -#: src/ne_socket.c:1724 -msgid "SSL disabled due to library version mismatch" -msgstr "" - -#: src/ne_socket.c:1730 +#: src/ne_socket.c:1757 #, fuzzy msgid "Could not create SSL structure" msgstr "Konnte keine SSL-Sitzung herstellen" diff --git a/libs/neon/po/fr.gmo b/libs/neon/po/fr.gmo index c66e74ac..33a3375b 100644 Binary files a/libs/neon/po/fr.gmo and b/libs/neon/po/fr.gmo differ diff --git a/libs/neon/po/fr.po b/libs/neon/po/fr.po index 6012b614..69bd238c 100644 --- a/libs/neon/po/fr.po +++ b/libs/neon/po/fr.po @@ -6,10 +6,11 @@ msgid "" msgstr "" "Project-Id-Version: sitecopy 0.9.3\n" "Report-Msgid-Bugs-To: neon@lists.manyfish.co.uk\n" -"POT-Creation-Date: 2010-10-01 13:30+0100\n" +"POT-Creation-Date: 2013-07-31 16:46+0100\n" "PO-Revision-Date: 2000-01-31 00:00+0100\n" "Last-Translator: Sylvain Glaize \n" "Language-Team: fr\n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=ISO-8859-1\n" "Content-Transfer-Encoding: 8bit\n" @@ -21,108 +22,113 @@ msgid "" "Status line was: %s" msgstr "" -#: src/ne_auth.c:134 +#: src/ne_auth.c:139 #, fuzzy, c-format msgid "Could not authenticate to server: %s" msgstr "%s: erreur: impossible de se connecter à l'hôte distant.\n" -#: src/ne_auth.c:139 +#: src/ne_auth.c:144 #, fuzzy, c-format msgid "Could not authenticate to proxy server: %s" msgstr "%s: erreur: impossible de se connecter à l'hôte distant.\n" -#: src/ne_auth.c:374 +#: src/ne_auth.c:386 #, c-format msgid "rejected %s challenge" msgstr "" -#: src/ne_auth.c:390 +#: src/ne_auth.c:402 msgid "missing realm in Basic challenge" msgstr "" -#: src/ne_auth.c:485 +#: src/ne_auth.c:497 msgid "invalid Negotiate token" msgstr "" -#: src/ne_auth.c:508 +#: src/ne_auth.c:520 msgid "GSSAPI authentication error: " msgstr "" -#: src/ne_auth.c:521 +#: src/ne_auth.c:533 #, c-format msgid "GSSAPI failure (code %u)" msgstr "" -#: src/ne_auth.c:556 +#: src/ne_auth.c:568 msgid "ignoring empty Negotiate continuation" msgstr "" -#: src/ne_auth.c:571 +#: src/ne_auth.c:583 #, c-format msgid "Negotiate response verification failed: invalid response header token" msgstr "" -#: src/ne_auth.c:593 +#: src/ne_auth.c:605 #, c-format msgid "Negotiate response verification failure: %s" msgstr "" -#: src/ne_auth.c:765 +#: src/ne_auth.c:669 +#, c-format +msgid "SSPI response verification failed: invalid response header token" +msgstr "" + +#: src/ne_auth.c:802 msgid "unknown algorithm in Digest challenge" msgstr "" -#: src/ne_auth.c:769 +#: src/ne_auth.c:806 msgid "incompatible algorithm in Digest challenge" msgstr "" -#: src/ne_auth.c:773 +#: src/ne_auth.c:810 msgid "missing parameter in Digest challenge" msgstr "" -#: src/ne_auth.c:777 +#: src/ne_auth.c:814 msgid "initial Digest challenge was stale" msgstr "" -#: src/ne_auth.c:784 +#: src/ne_auth.c:821 msgid "stale Digest challenge with new algorithm or realm" msgstr "" -#: src/ne_auth.c:796 +#: src/ne_auth.c:833 #, fuzzy msgid "could not parse domain in Digest challenge" msgstr "%s: erreur: impossible d'ouvrir le fichier de ressources: %s\n" -#: src/ne_auth.c:1105 +#: src/ne_auth.c:1142 #, c-format msgid "Digest mutual authentication failure: missing parameters" msgstr "" -#: src/ne_auth.c:1110 +#: src/ne_auth.c:1147 #, c-format msgid "Digest mutual authentication failure: client nonce mismatch" msgstr "" -#: src/ne_auth.c:1120 +#: src/ne_auth.c:1157 #, c-format msgid "Digest mutual authentication failure: could not parse nonce count" msgstr "" -#: src/ne_auth.c:1125 +#: src/ne_auth.c:1162 #, c-format msgid "Digest mutual authentication failure: nonce count mismatch (%u not %u)" msgstr "" -#: src/ne_auth.c:1168 +#: src/ne_auth.c:1205 #, c-format msgid "Digest mutual authentication failure: request-digest mismatch" msgstr "" -#: src/ne_auth.c:1299 +#: src/ne_auth.c:1336 #, c-format msgid "ignored %s challenge" msgstr "" -#: src/ne_auth.c:1378 +#: src/ne_auth.c:1415 #, fuzzy msgid "could not parse challenge" msgstr "%s: erreur: impossible d'ouvrir le fichier de ressources: %s\n" @@ -162,50 +168,50 @@ msgstr "%s: erreur: impossible d'ouvrir le fichier de ressources: %s\n" msgid "Could not initialize zlib" msgstr "%s: erreur: impossible d'ouvrir le fichier de ressources: %s\n" -#: src/ne_gnutls.c:172 +#: src/ne_gnutls.c:176 #, c-format msgid "[unprintable:#%lu]" msgstr "" -#: src/ne_gnutls.c:201 +#: src/ne_gnutls.c:205 msgid "[unprintable]" msgstr "" -#: src/ne_gnutls.c:817 +#: src/ne_gnutls.c:845 msgid "signed using insecure algorithm" msgstr "" -#: src/ne_gnutls.c:820 +#: src/ne_gnutls.c:848 #, c-format msgid "unrecognized errors (%u)" msgstr "" -#: src/ne_gnutls.c:865 src/ne_openssl.c:468 +#: src/ne_gnutls.c:893 src/ne_openssl.c:470 #, c-format msgid "Server certificate was missing commonName attribute in subject name" msgstr "" -#: src/ne_gnutls.c:879 +#: src/ne_gnutls.c:907 #, fuzzy, c-format msgid "Could not verify server certificate: %s" msgstr "%s: erreur: impossible d'ouvrir le fichier de ressources: %s\n" -#: src/ne_gnutls.c:891 src/ne_openssl.c:455 +#: src/ne_gnutls.c:919 src/ne_openssl.c:457 #, c-format msgid "Certificate verification error: %s" msgstr "" -#: src/ne_gnutls.c:924 src/ne_openssl.c:674 +#: src/ne_gnutls.c:952 src/ne_openssl.c:702 #, c-format msgid "SSL handshake failed, client certificate was requested: %s" msgstr "" -#: src/ne_gnutls.c:929 src/ne_openssl.c:679 +#: src/ne_gnutls.c:957 src/ne_openssl.c:707 #, fuzzy, c-format msgid "SSL handshake failed: %s" msgstr "%s: erreur: impossible d'ouvrir le fichier de ressources: %s\n" -#: src/ne_gnutls.c:939 +#: src/ne_gnutls.c:967 #, c-format msgid "Server did not send certificate chain" msgstr "" @@ -224,12 +230,12 @@ msgstr "" msgid "No activelock for <%s> returned in LOCK refresh response" msgstr "" -#: src/ne_openssl.c:699 +#: src/ne_openssl.c:727 #, c-format msgid "SSL server did not present certificate" msgstr "" -#: src/ne_openssl.c:708 +#: src/ne_openssl.c:736 #, c-format msgid "Server certificate changed: connection intercepted?" msgstr "" @@ -277,207 +283,208 @@ msgstr "" msgid "Could not seek to offset %s of request body file: %s" msgstr "%s: erreur: impossible d'ouvrir le fichier de ressources: %s\n" -#: src/ne_request.c:385 +#: src/ne_request.c:423 msgid "Could not send request body" msgstr "" -#: src/ne_request.c:728 +#: src/ne_request.c:450 +#, fuzzy +msgid "Could not send chunked request terminator" +msgstr "%s: erreur: impossible de se connecter à l'hôte distant.\n" + +#: src/ne_request.c:784 msgid "Could not read chunk size" msgstr "" -#: src/ne_request.c:735 +#: src/ne_request.c:791 #, fuzzy msgid "Could not parse chunk size" msgstr "%s: erreur: impossible d'ouvrir le fichier de ressources: %s\n" -#: src/ne_request.c:772 +#: src/ne_request.c:828 msgid "Could not read response body" msgstr "" -#: src/ne_request.c:788 +#: src/ne_request.c:844 #, fuzzy msgid "Could not read chunk delimiter" msgstr "%s: erreur: impossible d'ouvrir le fichier de ressources: %s\n" -#: src/ne_request.c:791 +#: src/ne_request.c:847 msgid "Chunk delimiter was invalid" msgstr "" -#: src/ne_request.c:896 +#: src/ne_request.c:952 msgid "Could not read status line" msgstr "" -#: src/ne_request.c:918 +#: src/ne_request.c:974 #, fuzzy msgid "Could not parse response status line" msgstr "%s: erreur: impossible d'ouvrir le fichier de ressources: %s\n" -#: src/ne_request.c:930 +#: src/ne_request.c:986 #, fuzzy msgid "Could not read interim response headers" msgstr "%s: erreur: impossible d'ouvrir le fichier de ressources: %s\n" -#: src/ne_request.c:964 +#: src/ne_request.c:1020 msgid "Could not send request" msgstr "" -#: src/ne_request.c:1012 src/ne_request.c:1030 src/ne_request.c:1040 +#: src/ne_request.c:1068 src/ne_request.c:1086 src/ne_request.c:1096 msgid "Error reading response headers" msgstr "" -#: src/ne_request.c:1058 +#: src/ne_request.c:1114 #, c-format msgid "Response header too long" msgstr "" -#: src/ne_request.c:1140 +#: src/ne_request.c:1196 msgid "Response exceeded maximum number of header fields" msgstr "" -#: src/ne_request.c:1155 +#: src/ne_request.c:1211 #, fuzzy, c-format msgid "Could not resolve hostname `%s': %s" msgstr "%s: erreur: impossible de trouver le nom de l'hôte distant.\n" -#: src/ne_request.c:1286 +#: src/ne_request.c:1342 msgid "Unknown transfer-coding in response" msgstr "" -#: src/ne_request.c:1299 +#: src/ne_request.c:1355 msgid "Invalid Content-Length in response" msgstr "" -#: src/ne_request.c:1372 +#: src/ne_request.c:1428 #, fuzzy, c-format msgid "Could not write to file: %s" msgstr "%s: erreur: impossible d'ouvrir le fichier de ressources: %s\n" -#: src/ne_request.c:1445 +#: src/ne_request.c:1501 #, fuzzy, c-format msgid "Could not create SSL connection through proxy server: %s" msgstr "%s: erreur: impossible de se connecter à l'hôte distant.\n" -#: src/ne_request.c:1484 +#: src/ne_request.c:1540 #, fuzzy, c-format msgid "Could not create socket" msgstr "%s: erreur: impossible de se connecter à l'hôte distant.\n" -#: src/ne_request.c:1518 +#: src/ne_request.c:1574 #, fuzzy msgid "Could not connect to server" msgstr "%s: erreur: impossible de se connecter à l'hôte distant.\n" -#: src/ne_request.c:1520 +#: src/ne_request.c:1576 #, fuzzy msgid "Could not connect to proxy server" msgstr "%s: erreur: impossible de se connecter à l'hôte distant.\n" -#: src/ne_request.c:1563 +#: src/ne_request.c:1619 #, c-format msgid "Could not find IPv4 address of hostname %s for SOCKS v4 proxy" msgstr "" -#: src/ne_request.c:1621 +#: src/ne_request.c:1677 #, fuzzy, c-format msgid "Could not establish connection from SOCKS proxy (%s:%u): %s" msgstr "%s: erreur: impossible de se connecter à l'hôte distant.\n" -#: src/ne_session.c:530 src/ne_session.c:541 +#: src/ne_session.c:538 src/ne_session.c:549 msgid "[invalid date]" msgstr "" -#: src/ne_session.c:554 +#: src/ne_session.c:562 msgid "certificate is not yet valid" msgstr "" -#: src/ne_session.c:555 +#: src/ne_session.c:563 msgid "certificate has expired" msgstr "" -#: src/ne_session.c:556 +#: src/ne_session.c:564 msgid "certificate issued for a different hostname" msgstr "" -#: src/ne_session.c:557 +#: src/ne_session.c:565 msgid "issuer is not trusted" msgstr "" -#: src/ne_session.c:558 +#: src/ne_session.c:566 msgid "bad certificate chain" msgstr "" -#: src/ne_session.c:559 +#: src/ne_session.c:567 msgid "certificate has been revoked" msgstr "" -#: src/ne_session.c:564 +#: src/ne_session.c:572 msgid "Server certificate verification failed: " msgstr "" -#: src/ne_socket.c:516 src/ne_socket.c:612 src/ne_socket.c:716 +#: src/ne_socket.c:522 src/ne_socket.c:618 src/ne_socket.c:722 msgid "Connection closed" msgstr "" -#: src/ne_socket.c:622 src/ne_socket.c:728 +#: src/ne_socket.c:628 src/ne_socket.c:736 msgid "Secure connection truncated" msgstr "" -#: src/ne_socket.c:634 src/ne_socket.c:740 +#: src/ne_socket.c:640 src/ne_socket.c:748 #, fuzzy, c-format msgid "SSL error: %s" msgstr "" "%s: dans issue_error\n" "%s" -#: src/ne_socket.c:637 +#: src/ne_socket.c:643 #, c-format msgid "SSL error code %d/%d/%lu" msgstr "" -#: src/ne_socket.c:721 +#: src/ne_socket.c:727 #, fuzzy, c-format msgid "SSL alert received: %s" msgstr "" "%s: dans issue_error\n" "%s" -#: src/ne_socket.c:736 +#: src/ne_socket.c:744 msgid "SSL socket read failed" msgstr "" -#: src/ne_socket.c:867 +#: src/ne_socket.c:875 msgid "Line too long" msgstr "" -#: src/ne_socket.c:1012 src/ne_socket.c:1018 +#: src/ne_socket.c:1036 src/ne_socket.c:1042 msgid "Host not found" msgstr "" -#: src/ne_socket.c:1221 +#: src/ne_socket.c:1249 msgid "Connection timed out" msgstr "" -#: src/ne_socket.c:1412 +#: src/ne_socket.c:1442 msgid "Socket descriptor number exceeds FD_SETSIZE" msgstr "" -#: src/ne_socket.c:1474 +#: src/ne_socket.c:1504 msgid "Socket family not supported" msgstr "" -#: src/ne_socket.c:1701 +#: src/ne_socket.c:1735 msgid "Client certificate verification failed" msgstr "" -#: src/ne_socket.c:1717 +#: src/ne_socket.c:1751 msgid "SSL disabled due to lack of entropy" msgstr "" -#: src/ne_socket.c:1724 -msgid "SSL disabled due to library version mismatch" -msgstr "" - -#: src/ne_socket.c:1730 +#: src/ne_socket.c:1757 #, fuzzy msgid "Could not create SSL structure" msgstr "%s: erreur: impossible de se connecter à l'hôte distant.\n" diff --git a/libs/neon/po/ja.gmo b/libs/neon/po/ja.gmo index df6f990f..be3cef5c 100644 Binary files a/libs/neon/po/ja.gmo and b/libs/neon/po/ja.gmo differ diff --git a/libs/neon/po/ja.po b/libs/neon/po/ja.po index 610e3564..3f5e25b0 100644 --- a/libs/neon/po/ja.po +++ b/libs/neon/po/ja.po @@ -6,10 +6,11 @@ msgid "" msgstr "" "Project-Id-Version: sitecopy 0.10.14\n" "Report-Msgid-Bugs-To: neon@lists.manyfish.co.uk\n" -"POT-Creation-Date: 2010-10-01 13:30+0100\n" +"POT-Creation-Date: 2013-07-31 16:46+0100\n" "PO-Revision-Date: 2001-01-16 07:32+0900\n" "Last-Translator: Nobuyuki Tsuchimura \n" "Language-Team: ja\n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=EUC-JP\n" "Content-Transfer-Encoding: 8-bit\n" @@ -21,109 +22,114 @@ msgid "" "Status line was: %s" msgstr "" -#: src/ne_auth.c:134 +#: src/ne_auth.c:139 #, fuzzy, c-format msgid "Could not authenticate to server: %s" msgstr "¥×¥í¥­¥·¡¼¥µ¡¼¥Ð¡¼¤ËÀܳ¤Ç¤­¤Þ¤»¤ó" -#: src/ne_auth.c:139 +#: src/ne_auth.c:144 #, fuzzy, c-format msgid "Could not authenticate to proxy server: %s" msgstr "¥×¥í¥­¥·¡¼¥µ¡¼¥Ð¡¼¤ËÀܳ¤Ç¤­¤Þ¤»¤ó" -#: src/ne_auth.c:374 +#: src/ne_auth.c:386 #, c-format msgid "rejected %s challenge" msgstr "" -#: src/ne_auth.c:390 +#: src/ne_auth.c:402 msgid "missing realm in Basic challenge" msgstr "" -#: src/ne_auth.c:485 +#: src/ne_auth.c:497 msgid "invalid Negotiate token" msgstr "" -#: src/ne_auth.c:508 +#: src/ne_auth.c:520 #, fuzzy msgid "GSSAPI authentication error: " msgstr "%s ¤Ø¤Îǧ¾Ú¤¬ %s ¤ÇɬÍפǤ¹ '%s':\n" -#: src/ne_auth.c:521 +#: src/ne_auth.c:533 #, c-format msgid "GSSAPI failure (code %u)" msgstr "" -#: src/ne_auth.c:556 +#: src/ne_auth.c:568 msgid "ignoring empty Negotiate continuation" msgstr "" -#: src/ne_auth.c:571 +#: src/ne_auth.c:583 #, c-format msgid "Negotiate response verification failed: invalid response header token" msgstr "" -#: src/ne_auth.c:593 +#: src/ne_auth.c:605 #, c-format msgid "Negotiate response verification failure: %s" msgstr "" -#: src/ne_auth.c:765 +#: src/ne_auth.c:669 +#, c-format +msgid "SSPI response verification failed: invalid response header token" +msgstr "" + +#: src/ne_auth.c:802 msgid "unknown algorithm in Digest challenge" msgstr "" -#: src/ne_auth.c:769 +#: src/ne_auth.c:806 msgid "incompatible algorithm in Digest challenge" msgstr "" -#: src/ne_auth.c:773 +#: src/ne_auth.c:810 msgid "missing parameter in Digest challenge" msgstr "" -#: src/ne_auth.c:777 +#: src/ne_auth.c:814 msgid "initial Digest challenge was stale" msgstr "" -#: src/ne_auth.c:784 +#: src/ne_auth.c:821 msgid "stale Digest challenge with new algorithm or realm" msgstr "" -#: src/ne_auth.c:796 +#: src/ne_auth.c:833 #, fuzzy msgid "could not parse domain in Digest challenge" msgstr "chunk ¤ÎÂ礭¤µ¤ò²òÀϤǤ­¤Þ¤»¤ó" -#: src/ne_auth.c:1105 +#: src/ne_auth.c:1142 #, c-format msgid "Digest mutual authentication failure: missing parameters" msgstr "" -#: src/ne_auth.c:1110 +#: src/ne_auth.c:1147 #, c-format msgid "Digest mutual authentication failure: client nonce mismatch" msgstr "" -#: src/ne_auth.c:1120 +#: src/ne_auth.c:1157 #, c-format msgid "Digest mutual authentication failure: could not parse nonce count" msgstr "" -#: src/ne_auth.c:1125 +#: src/ne_auth.c:1162 #, c-format msgid "Digest mutual authentication failure: nonce count mismatch (%u not %u)" msgstr "" -#: src/ne_auth.c:1168 +#: src/ne_auth.c:1205 #, c-format msgid "Digest mutual authentication failure: request-digest mismatch" msgstr "" -#: src/ne_auth.c:1299 +#: src/ne_auth.c:1336 #, c-format msgid "ignored %s challenge" msgstr "" -#: src/ne_auth.c:1378 +#: src/ne_auth.c:1415 #, fuzzy msgid "could not parse challenge" msgstr "chunk ¤ÎÂ礭¤µ¤ò²òÀϤǤ­¤Þ¤»¤ó" @@ -163,50 +169,50 @@ msgstr " msgid "Could not initialize zlib" msgstr "¥Õ¥¡¥¤¥ë¤¬½ñ¤±¤Þ¤»¤ó: " -#: src/ne_gnutls.c:172 +#: src/ne_gnutls.c:176 #, c-format msgid "[unprintable:#%lu]" msgstr "" -#: src/ne_gnutls.c:201 +#: src/ne_gnutls.c:205 msgid "[unprintable]" msgstr "" -#: src/ne_gnutls.c:817 +#: src/ne_gnutls.c:845 msgid "signed using insecure algorithm" msgstr "" -#: src/ne_gnutls.c:820 +#: src/ne_gnutls.c:848 #, c-format msgid "unrecognized errors (%u)" msgstr "" -#: src/ne_gnutls.c:865 src/ne_openssl.c:468 +#: src/ne_gnutls.c:893 src/ne_openssl.c:470 #, c-format msgid "Server certificate was missing commonName attribute in subject name" msgstr "" -#: src/ne_gnutls.c:879 +#: src/ne_gnutls.c:907 #, fuzzy, c-format msgid "Could not verify server certificate: %s" msgstr "¥Õ¥¡¥¤¥ë¤¬½ñ¤±¤Þ¤»¤ó: %s" -#: src/ne_gnutls.c:891 src/ne_openssl.c:455 +#: src/ne_gnutls.c:919 src/ne_openssl.c:457 #, c-format msgid "Certificate verification error: %s" msgstr "" -#: src/ne_gnutls.c:924 src/ne_openssl.c:674 +#: src/ne_gnutls.c:952 src/ne_openssl.c:702 #, c-format msgid "SSL handshake failed, client certificate was requested: %s" msgstr "" -#: src/ne_gnutls.c:929 src/ne_openssl.c:679 +#: src/ne_gnutls.c:957 src/ne_openssl.c:707 #, fuzzy, c-format msgid "SSL handshake failed: %s" msgstr "¥Õ¥¡¥¤¥ë¤¬½ñ¤±¤Þ¤»¤ó: %s" -#: src/ne_gnutls.c:939 +#: src/ne_gnutls.c:967 #, c-format msgid "Server did not send certificate chain" msgstr "" @@ -225,12 +231,12 @@ msgstr "" msgid "No activelock for <%s> returned in LOCK refresh response" msgstr "" -#: src/ne_openssl.c:699 +#: src/ne_openssl.c:727 #, c-format msgid "SSL server did not present certificate" msgstr "" -#: src/ne_openssl.c:708 +#: src/ne_openssl.c:736 #, c-format msgid "Server certificate changed: connection intercepted?" msgstr "" @@ -278,203 +284,204 @@ msgstr "" msgid "Could not seek to offset %s of request body file: %s" msgstr "¥Õ¥¡¥¤¥ë¤¬½ñ¤±¤Þ¤»¤ó: %s" -#: src/ne_request.c:385 +#: src/ne_request.c:423 msgid "Could not send request body" msgstr "" -#: src/ne_request.c:728 +#: src/ne_request.c:450 +#, fuzzy +msgid "Could not send chunked request terminator" +msgstr "¥×¥í¥­¥·¡¼¥µ¡¼¥Ð¡¼¤ËÀܳ¤Ç¤­¤Þ¤»¤ó" + +#: src/ne_request.c:784 msgid "Could not read chunk size" msgstr "chunk ¤ÎÂ礭¤µ¤¬Æɤá¤Þ¤»¤ó" -#: src/ne_request.c:735 +#: src/ne_request.c:791 msgid "Could not parse chunk size" msgstr "chunk ¤ÎÂ礭¤µ¤ò²òÀϤǤ­¤Þ¤»¤ó" -#: src/ne_request.c:772 +#: src/ne_request.c:828 msgid "Could not read response body" msgstr "response body ¤¬Æɤá¤Þ¤»¤ó" -#: src/ne_request.c:788 +#: src/ne_request.c:844 #, fuzzy msgid "Could not read chunk delimiter" msgstr "chunk ¤ÎÂ礭¤µ¤¬Æɤá¤Þ¤»¤ó" -#: src/ne_request.c:791 +#: src/ne_request.c:847 msgid "Chunk delimiter was invalid" msgstr "" -#: src/ne_request.c:896 +#: src/ne_request.c:952 msgid "Could not read status line" msgstr "" -#: src/ne_request.c:918 +#: src/ne_request.c:974 #, fuzzy msgid "Could not parse response status line" msgstr "response body ¤¬Æɤá¤Þ¤»¤ó" -#: src/ne_request.c:930 +#: src/ne_request.c:986 #, fuzzy msgid "Could not read interim response headers" msgstr "response body ¤¬Æɤá¤Þ¤»¤ó" -#: src/ne_request.c:964 +#: src/ne_request.c:1020 msgid "Could not send request" msgstr "" -#: src/ne_request.c:1012 src/ne_request.c:1030 src/ne_request.c:1040 +#: src/ne_request.c:1068 src/ne_request.c:1086 src/ne_request.c:1096 msgid "Error reading response headers" msgstr "" -#: src/ne_request.c:1058 +#: src/ne_request.c:1114 #, c-format msgid "Response header too long" msgstr "" -#: src/ne_request.c:1140 +#: src/ne_request.c:1196 msgid "Response exceeded maximum number of header fields" msgstr "" -#: src/ne_request.c:1155 +#: src/ne_request.c:1211 #, fuzzy, c-format msgid "Could not resolve hostname `%s': %s" msgstr "%s: ¥¨¥é¡¼: ¥µ¡¼¥Ð¡¼¤Î¥Û¥¹¥È̾ (%s) ¤ò IP ¥¢¥É¥ì¥¹¤ËÊÑ´¹¤Ç¤­¤Þ¤»¤ó¡£\n" -#: src/ne_request.c:1286 +#: src/ne_request.c:1342 msgid "Unknown transfer-coding in response" msgstr "" -#: src/ne_request.c:1299 +#: src/ne_request.c:1355 msgid "Invalid Content-Length in response" msgstr "" -#: src/ne_request.c:1372 +#: src/ne_request.c:1428 #, c-format msgid "Could not write to file: %s" msgstr "¥Õ¥¡¥¤¥ë¤¬½ñ¤±¤Þ¤»¤ó: %s" -#: src/ne_request.c:1445 +#: src/ne_request.c:1501 #, fuzzy, c-format msgid "Could not create SSL connection through proxy server: %s" msgstr "¥×¥í¥­¥·¡¼¥µ¡¼¥Ð¡¼¤Ë SSL Àܳ¤Ç¤­¤Þ¤»¤ó" -#: src/ne_request.c:1484 +#: src/ne_request.c:1540 #, fuzzy, c-format msgid "Could not create socket" msgstr "¥×¥í¥­¥·¡¼¥µ¡¼¥Ð¡¼¤Ë SSL Àܳ¤Ç¤­¤Þ¤»¤ó" -#: src/ne_request.c:1518 +#: src/ne_request.c:1574 msgid "Could not connect to server" msgstr "¥×¥í¥­¥·¡¼¥µ¡¼¥Ð¡¼¤ËÀܳ¤Ç¤­¤Þ¤»¤ó" -#: src/ne_request.c:1520 +#: src/ne_request.c:1576 msgid "Could not connect to proxy server" msgstr "¥×¥í¥­¥·¡¼¥µ¡¼¥Ð¡¼¤ËÀܳ¤Ç¤­¤Þ¤»¤ó" -#: src/ne_request.c:1563 +#: src/ne_request.c:1619 #, c-format msgid "Could not find IPv4 address of hostname %s for SOCKS v4 proxy" msgstr "" -#: src/ne_request.c:1621 +#: src/ne_request.c:1677 #, fuzzy, c-format msgid "Could not establish connection from SOCKS proxy (%s:%u): %s" msgstr "¥×¥í¥­¥·¡¼¥µ¡¼¥Ð¡¼¤Ë SSL Àܳ¤Ç¤­¤Þ¤»¤ó" -#: src/ne_session.c:530 src/ne_session.c:541 +#: src/ne_session.c:538 src/ne_session.c:549 msgid "[invalid date]" msgstr "" -#: src/ne_session.c:554 +#: src/ne_session.c:562 msgid "certificate is not yet valid" msgstr "" -#: src/ne_session.c:555 +#: src/ne_session.c:563 msgid "certificate has expired" msgstr "" -#: src/ne_session.c:556 +#: src/ne_session.c:564 msgid "certificate issued for a different hostname" msgstr "" -#: src/ne_session.c:557 +#: src/ne_session.c:565 msgid "issuer is not trusted" msgstr "" -#: src/ne_session.c:558 +#: src/ne_session.c:566 msgid "bad certificate chain" msgstr "" -#: src/ne_session.c:559 +#: src/ne_session.c:567 msgid "certificate has been revoked" msgstr "" -#: src/ne_session.c:564 +#: src/ne_session.c:572 msgid "Server certificate verification failed: " msgstr "" -#: src/ne_socket.c:516 src/ne_socket.c:612 src/ne_socket.c:716 +#: src/ne_socket.c:522 src/ne_socket.c:618 src/ne_socket.c:722 #, fuzzy msgid "Connection closed" msgstr "%s: Àܳ¤¬¥µ¡¼¥Ð¡¼¤ËÀÚ¤é¤ì¤Þ¤·¤¿¡£" -#: src/ne_socket.c:622 src/ne_socket.c:728 +#: src/ne_socket.c:628 src/ne_socket.c:736 #, fuzzy msgid "Secure connection truncated" msgstr "Àܳ¥¿¥¤¥à¥¢¥¦¥È¡£" -#: src/ne_socket.c:634 src/ne_socket.c:740 +#: src/ne_socket.c:640 src/ne_socket.c:748 #, c-format msgid "SSL error: %s" msgstr "" -#: src/ne_socket.c:637 +#: src/ne_socket.c:643 #, c-format msgid "SSL error code %d/%d/%lu" msgstr "" -#: src/ne_socket.c:721 +#: src/ne_socket.c:727 #, c-format msgid "SSL alert received: %s" msgstr "" -#: src/ne_socket.c:736 +#: src/ne_socket.c:744 msgid "SSL socket read failed" msgstr "" -#: src/ne_socket.c:867 +#: src/ne_socket.c:875 msgid "Line too long" msgstr "" -#: src/ne_socket.c:1012 src/ne_socket.c:1018 +#: src/ne_socket.c:1036 src/ne_socket.c:1042 msgid "Host not found" msgstr "" -#: src/ne_socket.c:1221 +#: src/ne_socket.c:1249 #, fuzzy msgid "Connection timed out" msgstr "%s: Àܳ¥¿¥¤¥à¥¢¥¦¥È¤Ç¤¹¡£" -#: src/ne_socket.c:1412 +#: src/ne_socket.c:1442 msgid "Socket descriptor number exceeds FD_SETSIZE" msgstr "" -#: src/ne_socket.c:1474 +#: src/ne_socket.c:1504 msgid "Socket family not supported" msgstr "" -#: src/ne_socket.c:1701 +#: src/ne_socket.c:1735 msgid "Client certificate verification failed" msgstr "" -#: src/ne_socket.c:1717 +#: src/ne_socket.c:1751 msgid "SSL disabled due to lack of entropy" msgstr "" -#: src/ne_socket.c:1724 -msgid "SSL disabled due to library version mismatch" -msgstr "" - -#: src/ne_socket.c:1730 +#: src/ne_socket.c:1757 #, fuzzy msgid "Could not create SSL structure" msgstr "¥×¥í¥­¥·¡¼¥µ¡¼¥Ð¡¼¤Ë SSL Àܳ¤Ç¤­¤Þ¤»¤ó" diff --git a/libs/neon/po/neon.pot b/libs/neon/po/neon.pot index f63c051f..2e7ed408 100644 --- a/libs/neon/po/neon.pot +++ b/libs/neon/po/neon.pot @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: neon@lists.manyfish.co.uk\n" -"POT-Creation-Date: 2010-10-01 13:30+0100\n" +"POT-Creation-Date: 2013-07-31 16:46+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" @@ -23,107 +24,112 @@ msgid "" "Status line was: %s" msgstr "" -#: src/ne_auth.c:134 +#: src/ne_auth.c:139 #, c-format msgid "Could not authenticate to server: %s" msgstr "" -#: src/ne_auth.c:139 +#: src/ne_auth.c:144 #, c-format msgid "Could not authenticate to proxy server: %s" msgstr "" -#: src/ne_auth.c:374 +#: src/ne_auth.c:386 #, c-format msgid "rejected %s challenge" msgstr "" -#: src/ne_auth.c:390 +#: src/ne_auth.c:402 msgid "missing realm in Basic challenge" msgstr "" -#: src/ne_auth.c:485 +#: src/ne_auth.c:497 msgid "invalid Negotiate token" msgstr "" -#: src/ne_auth.c:508 +#: src/ne_auth.c:520 msgid "GSSAPI authentication error: " msgstr "" -#: src/ne_auth.c:521 +#: src/ne_auth.c:533 #, c-format msgid "GSSAPI failure (code %u)" msgstr "" -#: src/ne_auth.c:556 +#: src/ne_auth.c:568 msgid "ignoring empty Negotiate continuation" msgstr "" -#: src/ne_auth.c:571 +#: src/ne_auth.c:583 #, c-format msgid "Negotiate response verification failed: invalid response header token" msgstr "" -#: src/ne_auth.c:593 +#: src/ne_auth.c:605 #, c-format msgid "Negotiate response verification failure: %s" msgstr "" -#: src/ne_auth.c:765 +#: src/ne_auth.c:669 +#, c-format +msgid "SSPI response verification failed: invalid response header token" +msgstr "" + +#: src/ne_auth.c:802 msgid "unknown algorithm in Digest challenge" msgstr "" -#: src/ne_auth.c:769 +#: src/ne_auth.c:806 msgid "incompatible algorithm in Digest challenge" msgstr "" -#: src/ne_auth.c:773 +#: src/ne_auth.c:810 msgid "missing parameter in Digest challenge" msgstr "" -#: src/ne_auth.c:777 +#: src/ne_auth.c:814 msgid "initial Digest challenge was stale" msgstr "" -#: src/ne_auth.c:784 +#: src/ne_auth.c:821 msgid "stale Digest challenge with new algorithm or realm" msgstr "" -#: src/ne_auth.c:796 +#: src/ne_auth.c:833 msgid "could not parse domain in Digest challenge" msgstr "" -#: src/ne_auth.c:1105 +#: src/ne_auth.c:1142 #, c-format msgid "Digest mutual authentication failure: missing parameters" msgstr "" -#: src/ne_auth.c:1110 +#: src/ne_auth.c:1147 #, c-format msgid "Digest mutual authentication failure: client nonce mismatch" msgstr "" -#: src/ne_auth.c:1120 +#: src/ne_auth.c:1157 #, c-format msgid "Digest mutual authentication failure: could not parse nonce count" msgstr "" -#: src/ne_auth.c:1125 +#: src/ne_auth.c:1162 #, c-format msgid "Digest mutual authentication failure: nonce count mismatch (%u not %u)" msgstr "" -#: src/ne_auth.c:1168 +#: src/ne_auth.c:1205 #, c-format msgid "Digest mutual authentication failure: request-digest mismatch" msgstr "" -#: src/ne_auth.c:1299 +#: src/ne_auth.c:1336 #, c-format msgid "ignored %s challenge" msgstr "" -#: src/ne_auth.c:1378 +#: src/ne_auth.c:1415 msgid "could not parse challenge" msgstr "" @@ -160,50 +166,50 @@ msgstr "" msgid "Could not initialize zlib" msgstr "" -#: src/ne_gnutls.c:172 +#: src/ne_gnutls.c:176 #, c-format msgid "[unprintable:#%lu]" msgstr "" -#: src/ne_gnutls.c:201 +#: src/ne_gnutls.c:205 msgid "[unprintable]" msgstr "" -#: src/ne_gnutls.c:817 +#: src/ne_gnutls.c:845 msgid "signed using insecure algorithm" msgstr "" -#: src/ne_gnutls.c:820 +#: src/ne_gnutls.c:848 #, c-format msgid "unrecognized errors (%u)" msgstr "" -#: src/ne_gnutls.c:865 src/ne_openssl.c:468 +#: src/ne_gnutls.c:893 src/ne_openssl.c:470 #, c-format msgid "Server certificate was missing commonName attribute in subject name" msgstr "" -#: src/ne_gnutls.c:879 +#: src/ne_gnutls.c:907 #, c-format msgid "Could not verify server certificate: %s" msgstr "" -#: src/ne_gnutls.c:891 src/ne_openssl.c:455 +#: src/ne_gnutls.c:919 src/ne_openssl.c:457 #, c-format msgid "Certificate verification error: %s" msgstr "" -#: src/ne_gnutls.c:924 src/ne_openssl.c:674 +#: src/ne_gnutls.c:952 src/ne_openssl.c:702 #, c-format msgid "SSL handshake failed, client certificate was requested: %s" msgstr "" -#: src/ne_gnutls.c:929 src/ne_openssl.c:679 +#: src/ne_gnutls.c:957 src/ne_openssl.c:707 #, c-format msgid "SSL handshake failed: %s" msgstr "" -#: src/ne_gnutls.c:939 +#: src/ne_gnutls.c:967 #, c-format msgid "Server did not send certificate chain" msgstr "" @@ -222,12 +228,12 @@ msgstr "" msgid "No activelock for <%s> returned in LOCK refresh response" msgstr "" -#: src/ne_openssl.c:699 +#: src/ne_openssl.c:727 #, c-format msgid "SSL server did not present certificate" msgstr "" -#: src/ne_openssl.c:708 +#: src/ne_openssl.c:736 #, c-format msgid "Server certificate changed: connection intercepted?" msgstr "" @@ -275,197 +281,197 @@ msgstr "" msgid "Could not seek to offset %s of request body file: %s" msgstr "" -#: src/ne_request.c:385 +#: src/ne_request.c:423 msgid "Could not send request body" msgstr "" -#: src/ne_request.c:728 +#: src/ne_request.c:450 +msgid "Could not send chunked request terminator" +msgstr "" + +#: src/ne_request.c:784 msgid "Could not read chunk size" msgstr "" -#: src/ne_request.c:735 +#: src/ne_request.c:791 msgid "Could not parse chunk size" msgstr "" -#: src/ne_request.c:772 +#: src/ne_request.c:828 msgid "Could not read response body" msgstr "" -#: src/ne_request.c:788 +#: src/ne_request.c:844 msgid "Could not read chunk delimiter" msgstr "" -#: src/ne_request.c:791 +#: src/ne_request.c:847 msgid "Chunk delimiter was invalid" msgstr "" -#: src/ne_request.c:896 +#: src/ne_request.c:952 msgid "Could not read status line" msgstr "" -#: src/ne_request.c:918 +#: src/ne_request.c:974 msgid "Could not parse response status line" msgstr "" -#: src/ne_request.c:930 +#: src/ne_request.c:986 msgid "Could not read interim response headers" msgstr "" -#: src/ne_request.c:964 +#: src/ne_request.c:1020 msgid "Could not send request" msgstr "" -#: src/ne_request.c:1012 src/ne_request.c:1030 src/ne_request.c:1040 +#: src/ne_request.c:1068 src/ne_request.c:1086 src/ne_request.c:1096 msgid "Error reading response headers" msgstr "" -#: src/ne_request.c:1058 +#: src/ne_request.c:1114 #, c-format msgid "Response header too long" msgstr "" -#: src/ne_request.c:1140 +#: src/ne_request.c:1196 msgid "Response exceeded maximum number of header fields" msgstr "" -#: src/ne_request.c:1155 +#: src/ne_request.c:1211 #, c-format msgid "Could not resolve hostname `%s': %s" msgstr "" -#: src/ne_request.c:1286 +#: src/ne_request.c:1342 msgid "Unknown transfer-coding in response" msgstr "" -#: src/ne_request.c:1299 +#: src/ne_request.c:1355 msgid "Invalid Content-Length in response" msgstr "" -#: src/ne_request.c:1372 +#: src/ne_request.c:1428 #, c-format msgid "Could not write to file: %s" msgstr "" -#: src/ne_request.c:1445 +#: src/ne_request.c:1501 #, c-format msgid "Could not create SSL connection through proxy server: %s" msgstr "" -#: src/ne_request.c:1484 +#: src/ne_request.c:1540 #, c-format msgid "Could not create socket" msgstr "" -#: src/ne_request.c:1518 +#: src/ne_request.c:1574 msgid "Could not connect to server" msgstr "" -#: src/ne_request.c:1520 +#: src/ne_request.c:1576 msgid "Could not connect to proxy server" msgstr "" -#: src/ne_request.c:1563 +#: src/ne_request.c:1619 #, c-format msgid "Could not find IPv4 address of hostname %s for SOCKS v4 proxy" msgstr "" -#: src/ne_request.c:1621 +#: src/ne_request.c:1677 #, c-format msgid "Could not establish connection from SOCKS proxy (%s:%u): %s" msgstr "" -#: src/ne_session.c:530 src/ne_session.c:541 +#: src/ne_session.c:538 src/ne_session.c:549 msgid "[invalid date]" msgstr "" -#: src/ne_session.c:554 +#: src/ne_session.c:562 msgid "certificate is not yet valid" msgstr "" -#: src/ne_session.c:555 +#: src/ne_session.c:563 msgid "certificate has expired" msgstr "" -#: src/ne_session.c:556 +#: src/ne_session.c:564 msgid "certificate issued for a different hostname" msgstr "" -#: src/ne_session.c:557 +#: src/ne_session.c:565 msgid "issuer is not trusted" msgstr "" -#: src/ne_session.c:558 +#: src/ne_session.c:566 msgid "bad certificate chain" msgstr "" -#: src/ne_session.c:559 +#: src/ne_session.c:567 msgid "certificate has been revoked" msgstr "" -#: src/ne_session.c:564 +#: src/ne_session.c:572 msgid "Server certificate verification failed: " msgstr "" -#: src/ne_socket.c:516 src/ne_socket.c:612 src/ne_socket.c:716 +#: src/ne_socket.c:522 src/ne_socket.c:618 src/ne_socket.c:722 msgid "Connection closed" msgstr "" -#: src/ne_socket.c:622 src/ne_socket.c:728 +#: src/ne_socket.c:628 src/ne_socket.c:736 msgid "Secure connection truncated" msgstr "" -#: src/ne_socket.c:634 src/ne_socket.c:740 +#: src/ne_socket.c:640 src/ne_socket.c:748 #, c-format msgid "SSL error: %s" msgstr "" -#: src/ne_socket.c:637 +#: src/ne_socket.c:643 #, c-format msgid "SSL error code %d/%d/%lu" msgstr "" -#: src/ne_socket.c:721 +#: src/ne_socket.c:727 #, c-format msgid "SSL alert received: %s" msgstr "" -#: src/ne_socket.c:736 +#: src/ne_socket.c:744 msgid "SSL socket read failed" msgstr "" -#: src/ne_socket.c:867 +#: src/ne_socket.c:875 msgid "Line too long" msgstr "" -#: src/ne_socket.c:1012 src/ne_socket.c:1018 +#: src/ne_socket.c:1036 src/ne_socket.c:1042 msgid "Host not found" msgstr "" -#: src/ne_socket.c:1221 +#: src/ne_socket.c:1249 msgid "Connection timed out" msgstr "" -#: src/ne_socket.c:1412 +#: src/ne_socket.c:1442 msgid "Socket descriptor number exceeds FD_SETSIZE" msgstr "" -#: src/ne_socket.c:1474 +#: src/ne_socket.c:1504 msgid "Socket family not supported" msgstr "" -#: src/ne_socket.c:1701 +#: src/ne_socket.c:1735 msgid "Client certificate verification failed" msgstr "" -#: src/ne_socket.c:1717 +#: src/ne_socket.c:1751 msgid "SSL disabled due to lack of entropy" msgstr "" -#: src/ne_socket.c:1724 -msgid "SSL disabled due to library version mismatch" -msgstr "" - -#: src/ne_socket.c:1730 +#: src/ne_socket.c:1757 msgid "Could not create SSL structure" msgstr "" diff --git a/libs/neon/po/nn.gmo b/libs/neon/po/nn.gmo index 9840bd47..8dc34aee 100644 Binary files a/libs/neon/po/nn.gmo and b/libs/neon/po/nn.gmo differ diff --git a/libs/neon/po/nn.po b/libs/neon/po/nn.po index 7f53f2f4..7b37c897 100644 --- a/libs/neon/po/nn.po +++ b/libs/neon/po/nn.po @@ -6,10 +6,11 @@ msgid "" msgstr "" "Project-Id-Version: sitecopy 0.11.4\n" "Report-Msgid-Bugs-To: neon@lists.manyfish.co.uk\n" -"POT-Creation-Date: 2010-10-01 13:30+0100\n" +"POT-Creation-Date: 2013-07-31 16:46+0100\n" "PO-Revision-Date: 2002-11-07 18:11+0100\n" "Last-Translator: Karl Ove Hufthammer \n" "Language-Team: Norwegian Nynorsk \n" +"Language: nn\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -23,109 +24,114 @@ msgstr "" "Ugyldig HTTP-statuslinje i statuselement pÃ¥ linje %d av svaret:\n" "Statuslinja var: %s" -#: src/ne_auth.c:134 +#: src/ne_auth.c:139 #, fuzzy, c-format msgid "Could not authenticate to server: %s" msgstr "Klarte ikkje kopla til tenaren." -#: src/ne_auth.c:139 +#: src/ne_auth.c:144 #, fuzzy, c-format msgid "Could not authenticate to proxy server: %s" msgstr "Klarte ikkje kopla til mellomtenar" -#: src/ne_auth.c:374 +#: src/ne_auth.c:386 #, c-format msgid "rejected %s challenge" msgstr "" -#: src/ne_auth.c:390 +#: src/ne_auth.c:402 msgid "missing realm in Basic challenge" msgstr "" -#: src/ne_auth.c:485 +#: src/ne_auth.c:497 msgid "invalid Negotiate token" msgstr "" -#: src/ne_auth.c:508 +#: src/ne_auth.c:520 #, fuzzy msgid "GSSAPI authentication error: " msgstr "Krev autentisering pÃ¥ %s «%s»:\n" -#: src/ne_auth.c:521 +#: src/ne_auth.c:533 #, c-format msgid "GSSAPI failure (code %u)" msgstr "" -#: src/ne_auth.c:556 +#: src/ne_auth.c:568 msgid "ignoring empty Negotiate continuation" msgstr "" -#: src/ne_auth.c:571 +#: src/ne_auth.c:583 #, c-format msgid "Negotiate response verification failed: invalid response header token" msgstr "" -#: src/ne_auth.c:593 +#: src/ne_auth.c:605 #, fuzzy, c-format msgid "Negotiate response verification failure: %s" msgstr "Tenarsertifikatet er utgÃ¥tt pÃ¥ dato." -#: src/ne_auth.c:765 +#: src/ne_auth.c:669 +#, c-format +msgid "SSPI response verification failed: invalid response header token" +msgstr "" + +#: src/ne_auth.c:802 msgid "unknown algorithm in Digest challenge" msgstr "" -#: src/ne_auth.c:769 +#: src/ne_auth.c:806 msgid "incompatible algorithm in Digest challenge" msgstr "" -#: src/ne_auth.c:773 +#: src/ne_auth.c:810 msgid "missing parameter in Digest challenge" msgstr "" -#: src/ne_auth.c:777 +#: src/ne_auth.c:814 msgid "initial Digest challenge was stale" msgstr "" -#: src/ne_auth.c:784 +#: src/ne_auth.c:821 msgid "stale Digest challenge with new algorithm or realm" msgstr "" -#: src/ne_auth.c:796 +#: src/ne_auth.c:833 #, fuzzy msgid "could not parse domain in Digest challenge" msgstr "Klarte ikkje tolka storleik pÃ¥ oppdelt svar" -#: src/ne_auth.c:1105 +#: src/ne_auth.c:1142 #, c-format msgid "Digest mutual authentication failure: missing parameters" msgstr "" -#: src/ne_auth.c:1110 +#: src/ne_auth.c:1147 #, c-format msgid "Digest mutual authentication failure: client nonce mismatch" msgstr "" -#: src/ne_auth.c:1120 +#: src/ne_auth.c:1157 #, c-format msgid "Digest mutual authentication failure: could not parse nonce count" msgstr "" -#: src/ne_auth.c:1125 +#: src/ne_auth.c:1162 #, c-format msgid "Digest mutual authentication failure: nonce count mismatch (%u not %u)" msgstr "" -#: src/ne_auth.c:1168 +#: src/ne_auth.c:1205 #, c-format msgid "Digest mutual authentication failure: request-digest mismatch" msgstr "" -#: src/ne_auth.c:1299 +#: src/ne_auth.c:1336 #, c-format msgid "ignored %s challenge" msgstr "" -#: src/ne_auth.c:1378 +#: src/ne_auth.c:1415 #, fuzzy msgid "could not parse challenge" msgstr "Klarte ikkje tolka storleik pÃ¥ oppdelt svar" @@ -165,50 +171,50 @@ msgstr "Klarte ikkje opna fil: " msgid "Could not initialize zlib" msgstr "Klarte ikkje opna fil: " -#: src/ne_gnutls.c:172 +#: src/ne_gnutls.c:176 #, c-format msgid "[unprintable:#%lu]" msgstr "" -#: src/ne_gnutls.c:201 +#: src/ne_gnutls.c:205 msgid "[unprintable]" msgstr "" -#: src/ne_gnutls.c:817 +#: src/ne_gnutls.c:845 msgid "signed using insecure algorithm" msgstr "" -#: src/ne_gnutls.c:820 +#: src/ne_gnutls.c:848 #, c-format msgid "unrecognized errors (%u)" msgstr "" -#: src/ne_gnutls.c:865 src/ne_openssl.c:468 +#: src/ne_gnutls.c:893 src/ne_openssl.c:470 #, c-format msgid "Server certificate was missing commonName attribute in subject name" msgstr "" -#: src/ne_gnutls.c:879 +#: src/ne_gnutls.c:907 #, fuzzy, c-format msgid "Could not verify server certificate: %s" msgstr "Klarte ikkje skriva til fil: %s" -#: src/ne_gnutls.c:891 src/ne_openssl.c:455 +#: src/ne_gnutls.c:919 src/ne_openssl.c:457 #, c-format msgid "Certificate verification error: %s" msgstr "" -#: src/ne_gnutls.c:924 src/ne_openssl.c:674 +#: src/ne_gnutls.c:952 src/ne_openssl.c:702 #, c-format msgid "SSL handshake failed, client certificate was requested: %s" msgstr "" -#: src/ne_gnutls.c:929 src/ne_openssl.c:679 +#: src/ne_gnutls.c:957 src/ne_openssl.c:707 #, fuzzy, c-format msgid "SSL handshake failed: %s" msgstr "Klarte ikkje skriva til fil: %s" -#: src/ne_gnutls.c:939 +#: src/ne_gnutls.c:967 #, c-format msgid "Server did not send certificate chain" msgstr "" @@ -227,12 +233,12 @@ msgstr "" msgid "No activelock for <%s> returned in LOCK refresh response" msgstr "" -#: src/ne_openssl.c:699 +#: src/ne_openssl.c:727 #, c-format msgid "SSL server did not present certificate" msgstr "" -#: src/ne_openssl.c:708 +#: src/ne_openssl.c:736 #, fuzzy, c-format msgid "Server certificate changed: connection intercepted?" msgstr "Tenarsertifikatet er utgÃ¥tt pÃ¥ dato." @@ -281,214 +287,214 @@ msgstr "" msgid "Could not seek to offset %s of request body file: %s" msgstr "Klarte ikkje skriva til fil: %s" -#: src/ne_request.c:385 +#: src/ne_request.c:423 msgid "Could not send request body" msgstr "Klarte ikkje senda førespurnad" -#: src/ne_request.c:728 +#: src/ne_request.c:450 +#, fuzzy +msgid "Could not send chunked request terminator" +msgstr "Klarte ikkje senda førespurnad" + +#: src/ne_request.c:784 msgid "Could not read chunk size" msgstr "Klarte ikkje lesa storleik pÃ¥ oppdelt svar" -#: src/ne_request.c:735 +#: src/ne_request.c:791 msgid "Could not parse chunk size" msgstr "Klarte ikkje tolka storleik pÃ¥ oppdelt svar" -#: src/ne_request.c:772 +#: src/ne_request.c:828 msgid "Could not read response body" msgstr "Klarte ikkje lesa svar" -#: src/ne_request.c:788 +#: src/ne_request.c:844 #, fuzzy msgid "Could not read chunk delimiter" msgstr "Klarte ikkje lesa storleik pÃ¥ oppdelt svar" -#: src/ne_request.c:791 +#: src/ne_request.c:847 msgid "Chunk delimiter was invalid" msgstr "" -#: src/ne_request.c:896 +#: src/ne_request.c:952 msgid "Could not read status line" msgstr "Klarte ikkje lesa statuslinja" -#: src/ne_request.c:918 +#: src/ne_request.c:974 #, fuzzy msgid "Could not parse response status line" msgstr "Klarte ikkje tolka statuslinja i svaret." -#: src/ne_request.c:930 +#: src/ne_request.c:986 #, fuzzy msgid "Could not read interim response headers" msgstr "Klarte ikkje lesa svarlinje" -#: src/ne_request.c:964 +#: src/ne_request.c:1020 msgid "Could not send request" msgstr "Klarte ikkje senda førespurnad" -#: src/ne_request.c:1012 src/ne_request.c:1030 src/ne_request.c:1040 +#: src/ne_request.c:1068 src/ne_request.c:1086 src/ne_request.c:1096 msgid "Error reading response headers" msgstr "Feil ved lesing av svarhovud" -#: src/ne_request.c:1058 +#: src/ne_request.c:1114 #, c-format msgid "Response header too long" msgstr "For langt svarhovud" -#: src/ne_request.c:1140 +#: src/ne_request.c:1196 #, fuzzy msgid "Response exceeded maximum number of header fields" msgstr "Svaret inneheld for mange header-felt." -#: src/ne_request.c:1155 +#: src/ne_request.c:1211 #, fuzzy, c-format msgid "Could not resolve hostname `%s': %s" msgstr "%s: Feil: Fann ikkje adressa til nettverksvert (%s).\n" -#: src/ne_request.c:1286 +#: src/ne_request.c:1342 msgid "Unknown transfer-coding in response" msgstr "" -#: src/ne_request.c:1299 +#: src/ne_request.c:1355 msgid "Invalid Content-Length in response" msgstr "" -#: src/ne_request.c:1372 +#: src/ne_request.c:1428 #, c-format msgid "Could not write to file: %s" msgstr "Klarte ikkje skriva til fil: %s" -#: src/ne_request.c:1445 +#: src/ne_request.c:1501 #, fuzzy, c-format msgid "Could not create SSL connection through proxy server: %s" msgstr "Klarte ikkje oppretta SSL-tilkopling til mellomtenar" -#: src/ne_request.c:1484 +#: src/ne_request.c:1540 #, fuzzy, c-format msgid "Could not create socket" msgstr "Klarte ikkje forhandla SSL-økt" -#: src/ne_request.c:1518 +#: src/ne_request.c:1574 msgid "Could not connect to server" msgstr "Klarte ikkje kopla til tenaren." -#: src/ne_request.c:1520 +#: src/ne_request.c:1576 msgid "Could not connect to proxy server" msgstr "Klarte ikkje kopla til mellomtenar" -#: src/ne_request.c:1563 +#: src/ne_request.c:1619 #, c-format msgid "Could not find IPv4 address of hostname %s for SOCKS v4 proxy" msgstr "" -#: src/ne_request.c:1621 +#: src/ne_request.c:1677 #, fuzzy, c-format msgid "Could not establish connection from SOCKS proxy (%s:%u): %s" msgstr "Klarte ikkje oppretta SSL-tilkopling til mellomtenar" -#: src/ne_session.c:530 src/ne_session.c:541 +#: src/ne_session.c:538 src/ne_session.c:549 #, fuzzy msgid "[invalid date]" msgstr "[ugyldig dato]" -#: src/ne_session.c:554 +#: src/ne_session.c:562 #, fuzzy msgid "certificate is not yet valid" msgstr "Sertifikatet er gyldig" -#: src/ne_session.c:555 +#: src/ne_session.c:563 #, fuzzy msgid "certificate has expired" msgstr "Tenarsertifikatet er utgÃ¥tt pÃ¥ dato." -#: src/ne_session.c:556 +#: src/ne_session.c:564 #, fuzzy msgid "certificate issued for a different hostname" msgstr "Sertifikatet er utferda av:" -#: src/ne_session.c:557 +#: src/ne_session.c:565 msgid "issuer is not trusted" msgstr "" -#: src/ne_session.c:558 +#: src/ne_session.c:566 #, fuzzy msgid "bad certificate chain" msgstr "Tenarsertifikatet er utgÃ¥tt pÃ¥ dato." -#: src/ne_session.c:559 +#: src/ne_session.c:567 #, fuzzy msgid "certificate has been revoked" msgstr "Tenarsertifikatet er utgÃ¥tt pÃ¥ dato." -#: src/ne_session.c:564 +#: src/ne_session.c:572 #, fuzzy msgid "Server certificate verification failed: " msgstr "Tenarsertifikatet er utgÃ¥tt pÃ¥ dato." -#: src/ne_socket.c:516 src/ne_socket.c:612 src/ne_socket.c:716 +#: src/ne_socket.c:522 src/ne_socket.c:618 src/ne_socket.c:722 #, fuzzy msgid "Connection closed" msgstr "Tilkoplinga vart lukka av tenaren" -#: src/ne_socket.c:622 src/ne_socket.c:728 +#: src/ne_socket.c:628 src/ne_socket.c:736 #, fuzzy msgid "Secure connection truncated" msgstr "Sambandet vart tidsavbrote." -#: src/ne_socket.c:634 src/ne_socket.c:740 +#: src/ne_socket.c:640 src/ne_socket.c:748 #, fuzzy, c-format msgid "SSL error: %s" msgstr "%s: Feil: %s\n" -#: src/ne_socket.c:637 +#: src/ne_socket.c:643 #, c-format msgid "SSL error code %d/%d/%lu" msgstr "" -#: src/ne_socket.c:721 +#: src/ne_socket.c:727 #, fuzzy, c-format msgid "SSL alert received: %s" msgstr "%s: Feil: %s\n" -#: src/ne_socket.c:736 +#: src/ne_socket.c:744 msgid "SSL socket read failed" msgstr "" -#: src/ne_socket.c:867 +#: src/ne_socket.c:875 msgid "Line too long" msgstr "For lang linje" -#: src/ne_socket.c:1012 src/ne_socket.c:1018 +#: src/ne_socket.c:1036 src/ne_socket.c:1042 msgid "Host not found" msgstr "Fann ikkje vert" -#: src/ne_socket.c:1221 +#: src/ne_socket.c:1249 #, fuzzy msgid "Connection timed out" msgstr "%s: sambandet vart tidsavbrote." -#: src/ne_socket.c:1412 +#: src/ne_socket.c:1442 msgid "Socket descriptor number exceeds FD_SETSIZE" msgstr "" -#: src/ne_socket.c:1474 +#: src/ne_socket.c:1504 msgid "Socket family not supported" msgstr "" -#: src/ne_socket.c:1701 +#: src/ne_socket.c:1735 #, fuzzy msgid "Client certificate verification failed" msgstr "Tenarsertifikatet er utgÃ¥tt pÃ¥ dato." -#: src/ne_socket.c:1717 +#: src/ne_socket.c:1751 #, fuzzy msgid "SSL disabled due to lack of entropy" msgstr "SSL avslÃ¥tt grunna mangel pÃ¥ entropi" -#: src/ne_socket.c:1724 -#, fuzzy -msgid "SSL disabled due to library version mismatch" -msgstr "SSL avslÃ¥tt grunna mangel pÃ¥ entropi" - -#: src/ne_socket.c:1730 +#: src/ne_socket.c:1757 #, fuzzy msgid "Could not create SSL structure" msgstr "Klarte ikkje forhandla SSL-økt" @@ -647,6 +653,10 @@ msgstr "XML-tolkingsfeil pÃ¥ linje %d: %s." msgid "Could not parse response: %s" msgstr "Klarte ikkje lesa «LIST»-svar." +#, fuzzy +#~ msgid "SSL disabled due to library version mismatch" +#~ msgstr "SSL avslÃ¥tt grunna mangel pÃ¥ entropi" + #, fuzzy #~ msgid "%s: %s" #~ msgstr "%s: %s\n" diff --git a/libs/neon/po/pl.gmo b/libs/neon/po/pl.gmo index 61bc4085..f5153c83 100644 Binary files a/libs/neon/po/pl.gmo and b/libs/neon/po/pl.gmo differ diff --git a/libs/neon/po/pl.po b/libs/neon/po/pl.po index 865c446d..68d4ef97 100644 --- a/libs/neon/po/pl.po +++ b/libs/neon/po/pl.po @@ -5,14 +5,15 @@ # msgid "" msgstr "" -"Project-Id-Version: Neon 0.29.0\n" +"Project-Id-Version: Neon 0.30.0\n" "Report-Msgid-Bugs-To: neon@lists.manyfish.co.uk\n" -"POT-Creation-Date: 2010-10-01 13:30+0100\n" +"POT-Creation-Date: 2013-07-31 16:46+0100\n" "PO-Revision-Date: 2009-09-04 02:00+0200\n" "Last-Translator: Arfrever Frehtes Taifersar Arahesis \n" "Language-Team: Polish Neon Translator Arfrever Frehtes Taifersar Arahesis " "\n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -26,116 +27,123 @@ msgstr "" "NiewÅ‚aÅ›ciwa linia statusu HTTP w elemencie statusu w linii %d odpowiedzi:\n" "Linia statusu byÅ‚a: %s" -#: src/ne_auth.c:134 +#: src/ne_auth.c:139 #, c-format msgid "Could not authenticate to server: %s" msgstr "Nie można autentykować siÄ™ do serwera: %s" -#: src/ne_auth.c:139 +#: src/ne_auth.c:144 #, c-format msgid "Could not authenticate to proxy server: %s" msgstr "Nie można autentykować siÄ™ do serwera proxy: %s" -#: src/ne_auth.c:374 +#: src/ne_auth.c:386 #, c-format msgid "rejected %s challenge" msgstr "odrzucone wezwanie %s" -#: src/ne_auth.c:390 +#: src/ne_auth.c:402 msgid "missing realm in Basic challenge" msgstr "brakujÄ…ca domena w wezwaniu Basic" -#: src/ne_auth.c:485 +#: src/ne_auth.c:497 msgid "invalid Negotiate token" msgstr "niewÅ‚aÅ›ciwy żeton Negotiate" -#: src/ne_auth.c:508 +#: src/ne_auth.c:520 msgid "GSSAPI authentication error: " msgstr "BÅ‚Ä…d autentykacji GSSAPI: " -#: src/ne_auth.c:521 +#: src/ne_auth.c:533 #, c-format msgid "GSSAPI failure (code %u)" msgstr "Porażka GSSAPI (kod %u)" -#: src/ne_auth.c:556 +#: src/ne_auth.c:568 msgid "ignoring empty Negotiate continuation" msgstr "ignorowanie pustej kontynuacji Negotiate" -#: src/ne_auth.c:571 +#: src/ne_auth.c:583 #, c-format msgid "Negotiate response verification failed: invalid response header token" msgstr "" "weryfikacja odpowiedzi Negotiate nie udaÅ‚a siÄ™: niewÅ‚aÅ›ciwy żeton nagłówka " "odpowiedzi" -#: src/ne_auth.c:593 +#: src/ne_auth.c:605 #, c-format msgid "Negotiate response verification failure: %s" msgstr "porażka weryfikacji odpowiedzi Negotiate: %s" -#: src/ne_auth.c:765 +#: src/ne_auth.c:669 +#, fuzzy, c-format +msgid "SSPI response verification failed: invalid response header token" +msgstr "" +"weryfikacja odpowiedzi Negotiate nie udaÅ‚a siÄ™: niewÅ‚aÅ›ciwy żeton nagłówka " +"odpowiedzi" + +#: src/ne_auth.c:802 msgid "unknown algorithm in Digest challenge" msgstr "nieznany algorytm w wezwaniu Digest" -#: src/ne_auth.c:769 +#: src/ne_auth.c:806 msgid "incompatible algorithm in Digest challenge" msgstr "niekompatybilny algorytm w wezwaniu Digest" -#: src/ne_auth.c:773 +#: src/ne_auth.c:810 msgid "missing parameter in Digest challenge" msgstr "brakujÄ…cy parametr w wezwaniu Digest" -#: src/ne_auth.c:777 +#: src/ne_auth.c:814 msgid "initial Digest challenge was stale" msgstr "poczÄ…tkowe wezwanie Digest byÅ‚o nieaktualne" -#: src/ne_auth.c:784 +#: src/ne_auth.c:821 msgid "stale Digest challenge with new algorithm or realm" msgstr "nieaktualne wezwanie Digest z nowym algorytmem lub domenÄ…" -#: src/ne_auth.c:796 +#: src/ne_auth.c:833 msgid "could not parse domain in Digest challenge" msgstr "nie można parsować domeny w wezwaniu Digest" -#: src/ne_auth.c:1105 +#: src/ne_auth.c:1142 #, c-format msgid "Digest mutual authentication failure: missing parameters" msgstr "Porażka wzajemnego uwierzytelniania Digest: brakujÄ…ce parametry" -#: src/ne_auth.c:1110 +#: src/ne_auth.c:1147 #, c-format msgid "Digest mutual authentication failure: client nonce mismatch" msgstr "" "Porażka wzajemnego uwierzytelniania Digest: niezgodność posÅ‚aÅ„ca klienta" -#: src/ne_auth.c:1120 +#: src/ne_auth.c:1157 #, c-format msgid "Digest mutual authentication failure: could not parse nonce count" msgstr "" "Porażka wzajemnego uwierzytelniania Digest: nie można parsować licznika " "posÅ‚aÅ„ca" -#: src/ne_auth.c:1125 +#: src/ne_auth.c:1162 #, c-format msgid "Digest mutual authentication failure: nonce count mismatch (%u not %u)" msgstr "" -"Porażka wzajemnego uwierzytelniania Digest: niezgodność licznika posÅ‚aÅ„ca (%" -"u nie %u)" +"Porażka wzajemnego uwierzytelniania Digest: niezgodność licznika posÅ‚aÅ„ca " +"(%u nie %u)" -#: src/ne_auth.c:1168 +#: src/ne_auth.c:1205 #, c-format msgid "Digest mutual authentication failure: request-digest mismatch" msgstr "" "Porażka wzajemnego uwierzytelniania Digest: niezgodność request-digest " "mismatch" -#: src/ne_auth.c:1299 +#: src/ne_auth.c:1336 #, c-format msgid "ignored %s challenge" msgstr "wezwanie %s zignorowane" -#: src/ne_auth.c:1378 +#: src/ne_auth.c:1415 msgid "could not parse challenge" msgstr "nie można parsować wezwania" @@ -172,50 +180,50 @@ msgstr "Nie można " msgid "Could not initialize zlib" msgstr "Nie można zainicjalizować zlib" -#: src/ne_gnutls.c:172 +#: src/ne_gnutls.c:176 #, c-format msgid "[unprintable:#%lu]" msgstr "[niedrukowalne:#%lu]" -#: src/ne_gnutls.c:201 +#: src/ne_gnutls.c:205 msgid "[unprintable]" msgstr "[niedrukowalne]" -#: src/ne_gnutls.c:817 +#: src/ne_gnutls.c:845 msgid "signed using insecure algorithm" msgstr "podpisane przy użyciu niebezpiecznego algorytmu" -#: src/ne_gnutls.c:820 +#: src/ne_gnutls.c:848 #, c-format msgid "unrecognized errors (%u)" msgstr "nierozpoznane bÅ‚Ä™dy (%u)" -#: src/ne_gnutls.c:865 src/ne_openssl.c:468 +#: src/ne_gnutls.c:893 src/ne_openssl.c:470 #, c-format msgid "Server certificate was missing commonName attribute in subject name" msgstr "Certyfikat serwera nie posiada atrybutu commonName w nazwie tematu" -#: src/ne_gnutls.c:879 +#: src/ne_gnutls.c:907 #, c-format msgid "Could not verify server certificate: %s" msgstr "Nie można zweryfikować certyfikatu serwera: %s" -#: src/ne_gnutls.c:891 src/ne_openssl.c:455 +#: src/ne_gnutls.c:919 src/ne_openssl.c:457 #, c-format msgid "Certificate verification error: %s" msgstr "BÅ‚Ä…d weryfikacji certyfikatu: %s" -#: src/ne_gnutls.c:924 src/ne_openssl.c:674 +#: src/ne_gnutls.c:952 src/ne_openssl.c:702 #, c-format msgid "SSL handshake failed, client certificate was requested: %s" msgstr "Uzgodnienie SSL nie udaÅ‚o siÄ™, certyfikat klienta zostaÅ‚ zażądany: %s" -#: src/ne_gnutls.c:929 src/ne_openssl.c:679 +#: src/ne_gnutls.c:957 src/ne_openssl.c:707 #, c-format msgid "SSL handshake failed: %s" msgstr "Uzgodnienie SSL nie udaÅ‚o siÄ™: %s" -#: src/ne_gnutls.c:939 +#: src/ne_gnutls.c:967 #, c-format msgid "Server did not send certificate chain" msgstr "Serwer nie wysÅ‚aÅ‚ Å‚aÅ„cucha certyfikatu" @@ -235,12 +243,12 @@ msgid "No activelock for <%s> returned in LOCK refresh response" msgstr "" "Nie zwrócono żadnej aktywnej blokady dla <%s> w odpowiedzi LOCK refresh" -#: src/ne_openssl.c:699 +#: src/ne_openssl.c:727 #, c-format msgid "SSL server did not present certificate" msgstr "Serwer SSL nie przedstawiÅ‚ certyfikatu" -#: src/ne_openssl.c:708 +#: src/ne_openssl.c:736 #, c-format msgid "Server certificate changed: connection intercepted?" msgstr "Certyfikat serwera zmieniÅ‚ siÄ™: poÅ‚Ä…czenie przechwycone?" @@ -288,197 +296,198 @@ msgstr "nieprawidÅ‚owe przesuniÄ™cie" msgid "Could not seek to offset %s of request body file: %s" msgstr "Nie można szukać przesuniÄ™cia %s pliku ciaÅ‚a żądania: %s" -#: src/ne_request.c:385 +#: src/ne_request.c:423 msgid "Could not send request body" msgstr "Nie można wysÅ‚ać ciaÅ‚a żądania" -#: src/ne_request.c:728 +#: src/ne_request.c:450 +#, fuzzy +msgid "Could not send chunked request terminator" +msgstr "Nie można wysÅ‚ać żądania poÅ‚Ä…czenia" + +#: src/ne_request.c:784 msgid "Could not read chunk size" msgstr "Nie można odczytać rozmiaru kawaÅ‚ka" -#: src/ne_request.c:735 +#: src/ne_request.c:791 msgid "Could not parse chunk size" msgstr "Nie można parsować rozmiaru kawaÅ‚ka" -#: src/ne_request.c:772 +#: src/ne_request.c:828 msgid "Could not read response body" msgstr "Nie można odczytać ciaÅ‚a odpowiedzi" -#: src/ne_request.c:788 +#: src/ne_request.c:844 msgid "Could not read chunk delimiter" msgstr "Nie można odczytać ogranicznika kawaÅ‚ka" -#: src/ne_request.c:791 +#: src/ne_request.c:847 msgid "Chunk delimiter was invalid" msgstr "Ogranicznik kawaÅ‚ka byÅ‚ nieprawidÅ‚owy" -#: src/ne_request.c:896 +#: src/ne_request.c:952 msgid "Could not read status line" msgstr "Nie można odczytać linii statusu" -#: src/ne_request.c:918 +#: src/ne_request.c:974 msgid "Could not parse response status line" msgstr "Nie można parsować linii statusu odpowiedzi" -#: src/ne_request.c:930 +#: src/ne_request.c:986 msgid "Could not read interim response headers" msgstr "Nie można odczytać nagłówków tymczasowej odpowiedzi" -#: src/ne_request.c:964 +#: src/ne_request.c:1020 msgid "Could not send request" msgstr "Nie można wysÅ‚ać żądania" -#: src/ne_request.c:1012 src/ne_request.c:1030 src/ne_request.c:1040 +#: src/ne_request.c:1068 src/ne_request.c:1086 src/ne_request.c:1096 msgid "Error reading response headers" msgstr "BÅ‚Ä…d podczas odczytywania nagłówków odpowiedzi" -#: src/ne_request.c:1058 +#: src/ne_request.c:1114 #, c-format msgid "Response header too long" msgstr "Nagłówek odpowiedzi zbyt dÅ‚ugi" -#: src/ne_request.c:1140 +#: src/ne_request.c:1196 msgid "Response exceeded maximum number of header fields" msgstr "Odpowiedź przekroczyÅ‚a maksymalnÄ… liczbÄ™ pól nagłówka" -#: src/ne_request.c:1155 +#: src/ne_request.c:1211 #, c-format msgid "Could not resolve hostname `%s': %s" msgstr "Nie można rozwiÄ…zać nazwy hosta `%s': %s" -#: src/ne_request.c:1286 +#: src/ne_request.c:1342 msgid "Unknown transfer-coding in response" msgstr "Nieznane transfer-coding w odpowiedzi" -#: src/ne_request.c:1299 +#: src/ne_request.c:1355 msgid "Invalid Content-Length in response" msgstr "NieprawidÅ‚owe Content-Length w odpowiedzi" -#: src/ne_request.c:1372 +#: src/ne_request.c:1428 #, c-format msgid "Could not write to file: %s" msgstr "Nie można pisać do pliku: %s" -#: src/ne_request.c:1445 +#: src/ne_request.c:1501 #, c-format msgid "Could not create SSL connection through proxy server: %s" msgstr "Nie można utworzyć poÅ‚Ä…czenia SSL przez serwer proxy: %s" -#: src/ne_request.c:1484 +#: src/ne_request.c:1540 #, c-format msgid "Could not create socket" msgstr "Nie można utworzyć gniazda" -#: src/ne_request.c:1518 +#: src/ne_request.c:1574 msgid "Could not connect to server" msgstr "Nie można poÅ‚Ä…czyć siÄ™ z serwerem" -#: src/ne_request.c:1520 +#: src/ne_request.c:1576 msgid "Could not connect to proxy server" msgstr "Nie można poÅ‚Ä…czyć siÄ™ z serwerem proxy" -#: src/ne_request.c:1563 +#: src/ne_request.c:1619 #, c-format msgid "Could not find IPv4 address of hostname %s for SOCKS v4 proxy" msgstr "Nie można znaleźć adresu IPv4 nazwy hosta %s dla proxy SOCKS v4" -#: src/ne_request.c:1621 +#: src/ne_request.c:1677 #, c-format msgid "Could not establish connection from SOCKS proxy (%s:%u): %s" msgstr "Nie można nawiÄ…zać poÅ‚Ä…czenia z proxy SOCKS (%s:%u): %s" -#: src/ne_session.c:530 src/ne_session.c:541 +#: src/ne_session.c:538 src/ne_session.c:549 msgid "[invalid date]" msgstr "[nieprawidÅ‚owa data]" -#: src/ne_session.c:554 +#: src/ne_session.c:562 msgid "certificate is not yet valid" msgstr "certyfikat nie jest jeszcze poprawny" -#: src/ne_session.c:555 +#: src/ne_session.c:563 msgid "certificate has expired" msgstr "certyfikat wygasÅ‚" -#: src/ne_session.c:556 +#: src/ne_session.c:564 msgid "certificate issued for a different hostname" msgstr "certyfikat wydany dla innej nazwy hosta" -#: src/ne_session.c:557 +#: src/ne_session.c:565 msgid "issuer is not trusted" msgstr "wydawca nie jest zaufany" -#: src/ne_session.c:558 +#: src/ne_session.c:566 msgid "bad certificate chain" msgstr "zÅ‚y Å‚aÅ„cuch certyfikatu" -#: src/ne_session.c:559 +#: src/ne_session.c:567 msgid "certificate has been revoked" msgstr "certyfikat zostaÅ‚ unieważniony" -#: src/ne_session.c:564 +#: src/ne_session.c:572 msgid "Server certificate verification failed: " msgstr "Weryfikacja certyfikatu serwera nie powiodÅ‚a siÄ™: " -#: src/ne_socket.c:516 src/ne_socket.c:612 src/ne_socket.c:716 +#: src/ne_socket.c:522 src/ne_socket.c:618 src/ne_socket.c:722 msgid "Connection closed" msgstr "PoÅ‚Ä…czenie zamkniÄ™te" -#: src/ne_socket.c:622 src/ne_socket.c:728 +#: src/ne_socket.c:628 src/ne_socket.c:736 msgid "Secure connection truncated" msgstr "Bezpieczne poÅ‚Ä…czenie obciÄ™te" -#: src/ne_socket.c:634 src/ne_socket.c:740 +#: src/ne_socket.c:640 src/ne_socket.c:748 #, c-format msgid "SSL error: %s" msgstr "BÅ‚Ä…d SSL: %s" -#: src/ne_socket.c:637 +#: src/ne_socket.c:643 #, c-format msgid "SSL error code %d/%d/%lu" msgstr "Kod bÅ‚Ä™du SSL %d/%d/%lu" -#: src/ne_socket.c:721 +#: src/ne_socket.c:727 #, c-format msgid "SSL alert received: %s" msgstr "Alarm SSL otrzymany: %s" -#: src/ne_socket.c:736 +#: src/ne_socket.c:744 msgid "SSL socket read failed" msgstr "Odczytywanie gniazda SSL nie powiodÅ‚o siÄ™" -#: src/ne_socket.c:867 +#: src/ne_socket.c:875 msgid "Line too long" msgstr "Linia zbyt dÅ‚uga" -#: src/ne_socket.c:1012 src/ne_socket.c:1018 +#: src/ne_socket.c:1036 src/ne_socket.c:1042 msgid "Host not found" msgstr "Host nieznaleziony" -#: src/ne_socket.c:1221 +#: src/ne_socket.c:1249 msgid "Connection timed out" msgstr "Czas poÅ‚Ä…czenia siÄ™ skoÅ„czyÅ‚" -#: src/ne_socket.c:1412 +#: src/ne_socket.c:1442 msgid "Socket descriptor number exceeds FD_SETSIZE" msgstr "Numer deskryptoru gniazda przekracza FD_SETSIZE" -#: src/ne_socket.c:1474 +#: src/ne_socket.c:1504 msgid "Socket family not supported" msgstr "Rodzina gniazda niewspierana" -#: src/ne_socket.c:1701 +#: src/ne_socket.c:1735 msgid "Client certificate verification failed" msgstr "Weryfikacja certyfikatu klienta nie powiodÅ‚a siÄ™" -#: src/ne_socket.c:1717 +#: src/ne_socket.c:1751 msgid "SSL disabled due to lack of entropy" msgstr "SSL wyÅ‚Ä…czone z powodu braku entropii" -#: src/ne_socket.c:1724 -msgid "SSL disabled due to library version mismatch" -msgstr "SSL wyÅ‚Ä…czone z powodu niezgodnoÅ›ci wersji biblioteki" - -#: src/ne_socket.c:1730 +#: src/ne_socket.c:1757 msgid "Could not create SSL structure" msgstr "Nie można utworzyć struktury SSL" @@ -622,3 +631,6 @@ msgstr "BÅ‚Ä…d podczas parsowania XML w linii %d: %s" #, c-format msgid "Could not parse response: %s" msgstr "Nie można parsować odpowiedzi: %s" + +#~ msgid "SSL disabled due to library version mismatch" +#~ msgstr "SSL wyÅ‚Ä…czone z powodu niezgodnoÅ›ci wersji biblioteki" diff --git a/libs/neon/po/ru.gmo b/libs/neon/po/ru.gmo index 7e0bb773..43c428e8 100644 Binary files a/libs/neon/po/ru.gmo and b/libs/neon/po/ru.gmo differ diff --git a/libs/neon/po/ru.po b/libs/neon/po/ru.po index 5cb1ac16..ea9dd582 100644 --- a/libs/neon/po/ru.po +++ b/libs/neon/po/ru.po @@ -6,10 +6,11 @@ msgid "" msgstr "" "Project-Id-Version: sitecopy 0.11.5\n" "Report-Msgid-Bugs-To: neon@lists.manyfish.co.uk\n" -"POT-Creation-Date: 2010-10-01 13:30+0100\n" +"POT-Creation-Date: 2013-07-31 16:46+0100\n" "PO-Revision-Date: 2002-11-11 14:28+0000\n" "Last-Translator: Michael Sobolev \n" "Language-Team: ru\n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=koi8-r\n" "Content-Transfer-Encoding: 8bit\n" @@ -21,108 +22,113 @@ msgid "" "Status line was: %s" msgstr "" -#: src/ne_auth.c:134 +#: src/ne_auth.c:139 #, fuzzy, c-format msgid "Could not authenticate to server: %s" msgstr "%s: ïÛÉÂËÁ: îÅ ÕÄÁÌÏÓØ ÏÔËÒÙÔØ ËÏÎÆÉÇÕÒÁÃÉÏÎÎÙÊ ÆÁÊÌ: %s\n" -#: src/ne_auth.c:139 +#: src/ne_auth.c:144 #, fuzzy, c-format msgid "Could not authenticate to proxy server: %s" msgstr "%s: ïÛÉÂËÁ: îÅ ÕÄÁÌÏÓØ ÏÔËÒÙÔØ ËÏÎÆÉÇÕÒÁÃÉÏÎÎÙÊ ÆÁÊÌ: %s\n" -#: src/ne_auth.c:374 +#: src/ne_auth.c:386 #, c-format msgid "rejected %s challenge" msgstr "" -#: src/ne_auth.c:390 +#: src/ne_auth.c:402 msgid "missing realm in Basic challenge" msgstr "" -#: src/ne_auth.c:485 +#: src/ne_auth.c:497 msgid "invalid Negotiate token" msgstr "" -#: src/ne_auth.c:508 +#: src/ne_auth.c:520 msgid "GSSAPI authentication error: " msgstr "" -#: src/ne_auth.c:521 +#: src/ne_auth.c:533 #, c-format msgid "GSSAPI failure (code %u)" msgstr "" -#: src/ne_auth.c:556 +#: src/ne_auth.c:568 msgid "ignoring empty Negotiate continuation" msgstr "" -#: src/ne_auth.c:571 +#: src/ne_auth.c:583 #, c-format msgid "Negotiate response verification failed: invalid response header token" msgstr "" -#: src/ne_auth.c:593 +#: src/ne_auth.c:605 #, c-format msgid "Negotiate response verification failure: %s" msgstr "" -#: src/ne_auth.c:765 +#: src/ne_auth.c:669 +#, c-format +msgid "SSPI response verification failed: invalid response header token" +msgstr "" + +#: src/ne_auth.c:802 msgid "unknown algorithm in Digest challenge" msgstr "" -#: src/ne_auth.c:769 +#: src/ne_auth.c:806 msgid "incompatible algorithm in Digest challenge" msgstr "" -#: src/ne_auth.c:773 +#: src/ne_auth.c:810 msgid "missing parameter in Digest challenge" msgstr "" -#: src/ne_auth.c:777 +#: src/ne_auth.c:814 msgid "initial Digest challenge was stale" msgstr "" -#: src/ne_auth.c:784 +#: src/ne_auth.c:821 msgid "stale Digest challenge with new algorithm or realm" msgstr "" -#: src/ne_auth.c:796 +#: src/ne_auth.c:833 #, fuzzy msgid "could not parse domain in Digest challenge" msgstr "%s: ïÛÉÂËÁ: îÅ ÕÄÁÌÏÓØ ÏÔËÒÙÔØ ËÏÎÆÉÇÕÒÁÃÉÏÎÎÙÊ ÆÁÊÌ: %s\n" -#: src/ne_auth.c:1105 +#: src/ne_auth.c:1142 #, c-format msgid "Digest mutual authentication failure: missing parameters" msgstr "" -#: src/ne_auth.c:1110 +#: src/ne_auth.c:1147 #, c-format msgid "Digest mutual authentication failure: client nonce mismatch" msgstr "" -#: src/ne_auth.c:1120 +#: src/ne_auth.c:1157 #, c-format msgid "Digest mutual authentication failure: could not parse nonce count" msgstr "" -#: src/ne_auth.c:1125 +#: src/ne_auth.c:1162 #, c-format msgid "Digest mutual authentication failure: nonce count mismatch (%u not %u)" msgstr "" -#: src/ne_auth.c:1168 +#: src/ne_auth.c:1205 #, c-format msgid "Digest mutual authentication failure: request-digest mismatch" msgstr "" -#: src/ne_auth.c:1299 +#: src/ne_auth.c:1336 #, c-format msgid "ignored %s challenge" msgstr "" -#: src/ne_auth.c:1378 +#: src/ne_auth.c:1415 #, fuzzy msgid "could not parse challenge" msgstr "%s: ïÛÉÂËÁ: îÅ ÕÄÁÌÏÓØ ÏÔËÒÙÔØ ËÏÎÆÉÇÕÒÁÃÉÏÎÎÙÊ ÆÁÊÌ: %s\n" @@ -162,50 +168,50 @@ msgstr "%s: msgid "Could not initialize zlib" msgstr "%s: ïÛÉÂËÁ: îÅ ÕÄÁÌÏÓØ ÏÔËÒÙÔØ ËÏÎÆÉÇÕÒÁÃÉÏÎÎÙÊ ÆÁÊÌ: %s\n" -#: src/ne_gnutls.c:172 +#: src/ne_gnutls.c:176 #, c-format msgid "[unprintable:#%lu]" msgstr "" -#: src/ne_gnutls.c:201 +#: src/ne_gnutls.c:205 msgid "[unprintable]" msgstr "" -#: src/ne_gnutls.c:817 +#: src/ne_gnutls.c:845 msgid "signed using insecure algorithm" msgstr "" -#: src/ne_gnutls.c:820 +#: src/ne_gnutls.c:848 #, c-format msgid "unrecognized errors (%u)" msgstr "" -#: src/ne_gnutls.c:865 src/ne_openssl.c:468 +#: src/ne_gnutls.c:893 src/ne_openssl.c:470 #, c-format msgid "Server certificate was missing commonName attribute in subject name" msgstr "" -#: src/ne_gnutls.c:879 +#: src/ne_gnutls.c:907 #, fuzzy, c-format msgid "Could not verify server certificate: %s" msgstr "%s: ïÛÉÂËÁ: îÅ ÕÄÁÌÏÓØ ÏÔËÒÙÔØ ËÏÎÆÉÇÕÒÁÃÉÏÎÎÙÊ ÆÁÊÌ: %s\n" -#: src/ne_gnutls.c:891 src/ne_openssl.c:455 +#: src/ne_gnutls.c:919 src/ne_openssl.c:457 #, c-format msgid "Certificate verification error: %s" msgstr "" -#: src/ne_gnutls.c:924 src/ne_openssl.c:674 +#: src/ne_gnutls.c:952 src/ne_openssl.c:702 #, c-format msgid "SSL handshake failed, client certificate was requested: %s" msgstr "" -#: src/ne_gnutls.c:929 src/ne_openssl.c:679 +#: src/ne_gnutls.c:957 src/ne_openssl.c:707 #, fuzzy, c-format msgid "SSL handshake failed: %s" msgstr "%s: ïÛÉÂËÁ: îÅ ÕÄÁÌÏÓØ ÏÔËÒÙÔØ ËÏÎÆÉÇÕÒÁÃÉÏÎÎÙÊ ÆÁÊÌ: %s\n" -#: src/ne_gnutls.c:939 +#: src/ne_gnutls.c:967 #, c-format msgid "Server did not send certificate chain" msgstr "" @@ -224,12 +230,12 @@ msgstr "" msgid "No activelock for <%s> returned in LOCK refresh response" msgstr "" -#: src/ne_openssl.c:699 +#: src/ne_openssl.c:727 #, c-format msgid "SSL server did not present certificate" msgstr "" -#: src/ne_openssl.c:708 +#: src/ne_openssl.c:736 #, c-format msgid "Server certificate changed: connection intercepted?" msgstr "" @@ -277,201 +283,202 @@ msgstr "" msgid "Could not seek to offset %s of request body file: %s" msgstr "%s: ïÛÉÂËÁ: îÅ ÕÄÁÌÏÓØ ÏÔËÒÙÔØ ËÏÎÆÉÇÕÒÁÃÉÏÎÎÙÊ ÆÁÊÌ: %s\n" -#: src/ne_request.c:385 +#: src/ne_request.c:423 msgid "Could not send request body" msgstr "" -#: src/ne_request.c:728 +#: src/ne_request.c:450 +#, fuzzy +msgid "Could not send chunked request terminator" +msgstr "%s: ïÛÉÂËÁ: îÅ ÕÄÁÌÏÓØ ÏÔËÒÙÔØ ËÏÎÆÉÇÕÒÁÃÉÏÎÎÙÊ ÆÁÊÌ: %s\n" + +#: src/ne_request.c:784 msgid "Could not read chunk size" msgstr "" -#: src/ne_request.c:735 +#: src/ne_request.c:791 #, fuzzy msgid "Could not parse chunk size" msgstr "%s: ïÛÉÂËÁ: îÅ ÕÄÁÌÏÓØ ÏÔËÒÙÔØ ËÏÎÆÉÇÕÒÁÃÉÏÎÎÙÊ ÆÁÊÌ: %s\n" -#: src/ne_request.c:772 +#: src/ne_request.c:828 msgid "Could not read response body" msgstr "" -#: src/ne_request.c:788 +#: src/ne_request.c:844 #, fuzzy msgid "Could not read chunk delimiter" msgstr "%s: ïÛÉÂËÁ: îÅ ÕÄÁÌÏÓØ ÏÔËÒÙÔØ ËÏÎÆÉÇÕÒÁÃÉÏÎÎÙÊ ÆÁÊÌ: %s\n" -#: src/ne_request.c:791 +#: src/ne_request.c:847 msgid "Chunk delimiter was invalid" msgstr "" -#: src/ne_request.c:896 +#: src/ne_request.c:952 msgid "Could not read status line" msgstr "" -#: src/ne_request.c:918 +#: src/ne_request.c:974 #, fuzzy msgid "Could not parse response status line" msgstr "%s: ïÛÉÂËÁ: îÅ ÕÄÁÌÏÓØ ÏÔËÒÙÔØ ËÏÎÆÉÇÕÒÁÃÉÏÎÎÙÊ ÆÁÊÌ: %s\n" -#: src/ne_request.c:930 +#: src/ne_request.c:986 #, fuzzy msgid "Could not read interim response headers" msgstr "%s: ïÛÉÂËÁ: îÅ ÕÄÁÌÏÓØ ÏÔËÒÙÔØ ËÏÎÆÉÇÕÒÁÃÉÏÎÎÙÊ ÆÁÊÌ: %s\n" -#: src/ne_request.c:964 +#: src/ne_request.c:1020 msgid "Could not send request" msgstr "" -#: src/ne_request.c:1012 src/ne_request.c:1030 src/ne_request.c:1040 +#: src/ne_request.c:1068 src/ne_request.c:1086 src/ne_request.c:1096 msgid "Error reading response headers" msgstr "" -#: src/ne_request.c:1058 +#: src/ne_request.c:1114 #, c-format msgid "Response header too long" msgstr "" -#: src/ne_request.c:1140 +#: src/ne_request.c:1196 msgid "Response exceeded maximum number of header fields" msgstr "" -#: src/ne_request.c:1155 +#: src/ne_request.c:1211 #, fuzzy, c-format msgid "Could not resolve hostname `%s': %s" msgstr "%s: ïÛÉÂËÁ: îÅ ÕÄÁÌÏÓØ ÏÔËÒÙÔØ ËÏÎÆÉÇÕÒÁÃÉÏÎÎÙÊ ÆÁÊÌ: %s.\n" -#: src/ne_request.c:1286 +#: src/ne_request.c:1342 msgid "Unknown transfer-coding in response" msgstr "" -#: src/ne_request.c:1299 +#: src/ne_request.c:1355 msgid "Invalid Content-Length in response" msgstr "" -#: src/ne_request.c:1372 +#: src/ne_request.c:1428 #, fuzzy, c-format msgid "Could not write to file: %s" msgstr "%s: ïÛÉÂËÁ: îÅ ÕÄÁÌÏÓØ ÏÔËÒÙÔØ ËÏÎÆÉÇÕÒÁÃÉÏÎÎÙÊ ÆÁÊÌ: %s\n" -#: src/ne_request.c:1445 +#: src/ne_request.c:1501 #, c-format msgid "Could not create SSL connection through proxy server: %s" msgstr "" -#: src/ne_request.c:1484 +#: src/ne_request.c:1540 #, fuzzy, c-format msgid "Could not create socket" msgstr "%s: ïÛÉÂËÁ: îÅ ÕÄÁÌÏÓØ ÏÔËÒÙÔØ ËÏÎÆÉÇÕÒÁÃÉÏÎÎÙÊ ÆÁÊÌ: %s\n" -#: src/ne_request.c:1518 +#: src/ne_request.c:1574 msgid "Could not connect to server" msgstr "" -#: src/ne_request.c:1520 +#: src/ne_request.c:1576 msgid "Could not connect to proxy server" msgstr "" -#: src/ne_request.c:1563 +#: src/ne_request.c:1619 #, c-format msgid "Could not find IPv4 address of hostname %s for SOCKS v4 proxy" msgstr "" -#: src/ne_request.c:1621 +#: src/ne_request.c:1677 #, c-format msgid "Could not establish connection from SOCKS proxy (%s:%u): %s" msgstr "" -#: src/ne_session.c:530 src/ne_session.c:541 +#: src/ne_session.c:538 src/ne_session.c:549 msgid "[invalid date]" msgstr "" -#: src/ne_session.c:554 +#: src/ne_session.c:562 msgid "certificate is not yet valid" msgstr "" -#: src/ne_session.c:555 +#: src/ne_session.c:563 msgid "certificate has expired" msgstr "" -#: src/ne_session.c:556 +#: src/ne_session.c:564 msgid "certificate issued for a different hostname" msgstr "" -#: src/ne_session.c:557 +#: src/ne_session.c:565 msgid "issuer is not trusted" msgstr "" -#: src/ne_session.c:558 +#: src/ne_session.c:566 msgid "bad certificate chain" msgstr "" -#: src/ne_session.c:559 +#: src/ne_session.c:567 msgid "certificate has been revoked" msgstr "" -#: src/ne_session.c:564 +#: src/ne_session.c:572 msgid "Server certificate verification failed: " msgstr "" -#: src/ne_socket.c:516 src/ne_socket.c:612 src/ne_socket.c:716 +#: src/ne_socket.c:522 src/ne_socket.c:618 src/ne_socket.c:722 msgid "Connection closed" msgstr "" -#: src/ne_socket.c:622 src/ne_socket.c:728 +#: src/ne_socket.c:628 src/ne_socket.c:736 msgid "Secure connection truncated" msgstr "" -#: src/ne_socket.c:634 src/ne_socket.c:740 +#: src/ne_socket.c:640 src/ne_socket.c:748 #, c-format msgid "SSL error: %s" msgstr "" -#: src/ne_socket.c:637 +#: src/ne_socket.c:643 #, c-format msgid "SSL error code %d/%d/%lu" msgstr "" -#: src/ne_socket.c:721 +#: src/ne_socket.c:727 #, c-format msgid "SSL alert received: %s" msgstr "" -#: src/ne_socket.c:736 +#: src/ne_socket.c:744 msgid "SSL socket read failed" msgstr "" -#: src/ne_socket.c:867 +#: src/ne_socket.c:875 msgid "Line too long" msgstr "" -#: src/ne_socket.c:1012 src/ne_socket.c:1018 +#: src/ne_socket.c:1036 src/ne_socket.c:1042 msgid "Host not found" msgstr "" -#: src/ne_socket.c:1221 +#: src/ne_socket.c:1249 msgid "Connection timed out" msgstr "" -#: src/ne_socket.c:1412 +#: src/ne_socket.c:1442 msgid "Socket descriptor number exceeds FD_SETSIZE" msgstr "" -#: src/ne_socket.c:1474 +#: src/ne_socket.c:1504 msgid "Socket family not supported" msgstr "" -#: src/ne_socket.c:1701 +#: src/ne_socket.c:1735 msgid "Client certificate verification failed" msgstr "" -#: src/ne_socket.c:1717 +#: src/ne_socket.c:1751 msgid "SSL disabled due to lack of entropy" msgstr "" -#: src/ne_socket.c:1724 -msgid "SSL disabled due to library version mismatch" -msgstr "" - -#: src/ne_socket.c:1730 +#: src/ne_socket.c:1757 msgid "Could not create SSL structure" msgstr "" diff --git a/libs/neon/po/tr.gmo b/libs/neon/po/tr.gmo index 33a5029e..20893f41 100644 Binary files a/libs/neon/po/tr.gmo and b/libs/neon/po/tr.gmo differ diff --git a/libs/neon/po/tr.po b/libs/neon/po/tr.po index 245a9007..ff99189e 100644 --- a/libs/neon/po/tr.po +++ b/libs/neon/po/tr.po @@ -7,10 +7,11 @@ msgid "" msgstr "" "Project-Id-Version: sitecopy-0.10.10\n" "Report-Msgid-Bugs-To: neon@lists.manyfish.co.uk\n" -"POT-Creation-Date: 2010-10-01 13:30+0100\n" +"POT-Creation-Date: 2013-07-31 16:46+0100\n" "PO-Revision-Date: 2001-01-03 HO:MI+ZONE\n" "Last-Translator: A. Sinan Unur \n" "Language-Team: tr\n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=iso-8859-9\n" "Content-Transfer-Encoding: 8bit\n" @@ -24,108 +25,113 @@ msgstr "" "Invalid HTTP status line in status element at line %d of response:\n" "Status line was: %s" -#: src/ne_auth.c:134 +#: src/ne_auth.c:139 #, fuzzy, c-format msgid "Could not authenticate to server: %s" msgstr "Sunucuyla baðlantý kurulamadý" -#: src/ne_auth.c:139 +#: src/ne_auth.c:144 #, fuzzy, c-format msgid "Could not authenticate to proxy server: %s" msgstr "Ara sunucuyla baðlantý kurulamadý" -#: src/ne_auth.c:374 +#: src/ne_auth.c:386 #, c-format msgid "rejected %s challenge" msgstr "" -#: src/ne_auth.c:390 +#: src/ne_auth.c:402 msgid "missing realm in Basic challenge" msgstr "" -#: src/ne_auth.c:485 +#: src/ne_auth.c:497 msgid "invalid Negotiate token" msgstr "" -#: src/ne_auth.c:508 +#: src/ne_auth.c:520 msgid "GSSAPI authentication error: " msgstr "" -#: src/ne_auth.c:521 +#: src/ne_auth.c:533 #, c-format msgid "GSSAPI failure (code %u)" msgstr "" -#: src/ne_auth.c:556 +#: src/ne_auth.c:568 msgid "ignoring empty Negotiate continuation" msgstr "" -#: src/ne_auth.c:571 +#: src/ne_auth.c:583 #, c-format msgid "Negotiate response verification failed: invalid response header token" msgstr "" -#: src/ne_auth.c:593 +#: src/ne_auth.c:605 #, c-format msgid "Negotiate response verification failure: %s" msgstr "" -#: src/ne_auth.c:765 +#: src/ne_auth.c:669 +#, c-format +msgid "SSPI response verification failed: invalid response header token" +msgstr "" + +#: src/ne_auth.c:802 msgid "unknown algorithm in Digest challenge" msgstr "" -#: src/ne_auth.c:769 +#: src/ne_auth.c:806 msgid "incompatible algorithm in Digest challenge" msgstr "" -#: src/ne_auth.c:773 +#: src/ne_auth.c:810 msgid "missing parameter in Digest challenge" msgstr "" -#: src/ne_auth.c:777 +#: src/ne_auth.c:814 msgid "initial Digest challenge was stale" msgstr "" -#: src/ne_auth.c:784 +#: src/ne_auth.c:821 msgid "stale Digest challenge with new algorithm or realm" msgstr "" -#: src/ne_auth.c:796 +#: src/ne_auth.c:833 #, fuzzy msgid "could not parse domain in Digest challenge" msgstr "Parça boyutu anlaþýlamadý" -#: src/ne_auth.c:1105 +#: src/ne_auth.c:1142 #, c-format msgid "Digest mutual authentication failure: missing parameters" msgstr "" -#: src/ne_auth.c:1110 +#: src/ne_auth.c:1147 #, c-format msgid "Digest mutual authentication failure: client nonce mismatch" msgstr "" -#: src/ne_auth.c:1120 +#: src/ne_auth.c:1157 #, c-format msgid "Digest mutual authentication failure: could not parse nonce count" msgstr "" -#: src/ne_auth.c:1125 +#: src/ne_auth.c:1162 #, c-format msgid "Digest mutual authentication failure: nonce count mismatch (%u not %u)" msgstr "" -#: src/ne_auth.c:1168 +#: src/ne_auth.c:1205 #, c-format msgid "Digest mutual authentication failure: request-digest mismatch" msgstr "" -#: src/ne_auth.c:1299 +#: src/ne_auth.c:1336 #, c-format msgid "ignored %s challenge" msgstr "" -#: src/ne_auth.c:1378 +#: src/ne_auth.c:1415 #, fuzzy msgid "could not parse challenge" msgstr "Parça boyutu anlaþýlamadý" @@ -165,50 +171,50 @@ msgstr "Dosya a msgid "Could not initialize zlib" msgstr "Dosyaya yazým yapýlamadý: " -#: src/ne_gnutls.c:172 +#: src/ne_gnutls.c:176 #, c-format msgid "[unprintable:#%lu]" msgstr "" -#: src/ne_gnutls.c:201 +#: src/ne_gnutls.c:205 msgid "[unprintable]" msgstr "" -#: src/ne_gnutls.c:817 +#: src/ne_gnutls.c:845 msgid "signed using insecure algorithm" msgstr "" -#: src/ne_gnutls.c:820 +#: src/ne_gnutls.c:848 #, c-format msgid "unrecognized errors (%u)" msgstr "" -#: src/ne_gnutls.c:865 src/ne_openssl.c:468 +#: src/ne_gnutls.c:893 src/ne_openssl.c:470 #, c-format msgid "Server certificate was missing commonName attribute in subject name" msgstr "" -#: src/ne_gnutls.c:879 +#: src/ne_gnutls.c:907 #, fuzzy, c-format msgid "Could not verify server certificate: %s" msgstr "%s dosyasýna yazým yapýlamadý" -#: src/ne_gnutls.c:891 src/ne_openssl.c:455 +#: src/ne_gnutls.c:919 src/ne_openssl.c:457 #, c-format msgid "Certificate verification error: %s" msgstr "" -#: src/ne_gnutls.c:924 src/ne_openssl.c:674 +#: src/ne_gnutls.c:952 src/ne_openssl.c:702 #, c-format msgid "SSL handshake failed, client certificate was requested: %s" msgstr "" -#: src/ne_gnutls.c:929 src/ne_openssl.c:679 +#: src/ne_gnutls.c:957 src/ne_openssl.c:707 #, fuzzy, c-format msgid "SSL handshake failed: %s" msgstr "%s dosyasýna yazým yapýlamadý" -#: src/ne_gnutls.c:939 +#: src/ne_gnutls.c:967 #, c-format msgid "Server did not send certificate chain" msgstr "" @@ -227,12 +233,12 @@ msgstr "" msgid "No activelock for <%s> returned in LOCK refresh response" msgstr "" -#: src/ne_openssl.c:699 +#: src/ne_openssl.c:727 #, c-format msgid "SSL server did not present certificate" msgstr "" -#: src/ne_openssl.c:708 +#: src/ne_openssl.c:736 #, c-format msgid "Server certificate changed: connection intercepted?" msgstr "" @@ -280,203 +286,204 @@ msgstr "" msgid "Could not seek to offset %s of request body file: %s" msgstr "%s dosyasýna yazým yapýlamadý" -#: src/ne_request.c:385 +#: src/ne_request.c:423 msgid "Could not send request body" msgstr "Ýstek metni gönderilemedi" -#: src/ne_request.c:728 +#: src/ne_request.c:450 +#, fuzzy +msgid "Could not send chunked request terminator" +msgstr "Ýstek gönderilemedi" + +#: src/ne_request.c:784 msgid "Could not read chunk size" msgstr "Parça boyutu öðrenilemedi" -#: src/ne_request.c:735 +#: src/ne_request.c:791 msgid "Could not parse chunk size" msgstr "Parça boyutu anlaþýlamadý" -#: src/ne_request.c:772 +#: src/ne_request.c:828 msgid "Could not read response body" msgstr "Yanýt metni okunamadý" -#: src/ne_request.c:788 +#: src/ne_request.c:844 #, fuzzy msgid "Could not read chunk delimiter" msgstr "Parça boyutu öðrenilemedi" -#: src/ne_request.c:791 +#: src/ne_request.c:847 msgid "Chunk delimiter was invalid" msgstr "" -#: src/ne_request.c:896 +#: src/ne_request.c:952 msgid "Could not read status line" msgstr "Durum satýrý okunamadý" -#: src/ne_request.c:918 +#: src/ne_request.c:974 #, fuzzy msgid "Could not parse response status line" msgstr "Durum satýrý anlaþýlamadý." -#: src/ne_request.c:930 +#: src/ne_request.c:986 #, fuzzy msgid "Could not read interim response headers" msgstr "Yanýt metni okunamadý" -#: src/ne_request.c:964 +#: src/ne_request.c:1020 msgid "Could not send request" msgstr "Ýstek gönderilemedi" -#: src/ne_request.c:1012 src/ne_request.c:1030 src/ne_request.c:1040 +#: src/ne_request.c:1068 src/ne_request.c:1086 src/ne_request.c:1096 msgid "Error reading response headers" msgstr "Yanýt baþlýklarý okunurken hata" -#: src/ne_request.c:1058 +#: src/ne_request.c:1114 #, c-format msgid "Response header too long" msgstr "Yanýt baþlýðý çok uzun" -#: src/ne_request.c:1140 +#: src/ne_request.c:1196 msgid "Response exceeded maximum number of header fields" msgstr "" -#: src/ne_request.c:1155 +#: src/ne_request.c:1211 #, fuzzy, c-format msgid "Could not resolve hostname `%s': %s" msgstr "%s: Hata: %s sunucusunun adresi bulunamadý.\n" -#: src/ne_request.c:1286 +#: src/ne_request.c:1342 msgid "Unknown transfer-coding in response" msgstr "" -#: src/ne_request.c:1299 +#: src/ne_request.c:1355 msgid "Invalid Content-Length in response" msgstr "" -#: src/ne_request.c:1372 +#: src/ne_request.c:1428 #, c-format msgid "Could not write to file: %s" msgstr "%s dosyasýna yazým yapýlamadý" -#: src/ne_request.c:1445 +#: src/ne_request.c:1501 #, fuzzy, c-format msgid "Could not create SSL connection through proxy server: %s" msgstr "Ara sunucu üzerinden SSL baðlantýsý kurulamadý" -#: src/ne_request.c:1484 +#: src/ne_request.c:1540 #, fuzzy, c-format msgid "Could not create socket" msgstr "SSL baðlantýsý kurulamadý" -#: src/ne_request.c:1518 +#: src/ne_request.c:1574 msgid "Could not connect to server" msgstr "Sunucuyla baðlantý kurulamadý" -#: src/ne_request.c:1520 +#: src/ne_request.c:1576 msgid "Could not connect to proxy server" msgstr "Ara sunucuyla baðlantý kurulamadý" -#: src/ne_request.c:1563 +#: src/ne_request.c:1619 #, c-format msgid "Could not find IPv4 address of hostname %s for SOCKS v4 proxy" msgstr "" -#: src/ne_request.c:1621 +#: src/ne_request.c:1677 #, fuzzy, c-format msgid "Could not establish connection from SOCKS proxy (%s:%u): %s" msgstr "Ara sunucu üzerinden SSL baðlantýsý kurulamadý" -#: src/ne_session.c:530 src/ne_session.c:541 +#: src/ne_session.c:538 src/ne_session.c:549 msgid "[invalid date]" msgstr "" -#: src/ne_session.c:554 +#: src/ne_session.c:562 msgid "certificate is not yet valid" msgstr "" -#: src/ne_session.c:555 +#: src/ne_session.c:563 msgid "certificate has expired" msgstr "" -#: src/ne_session.c:556 +#: src/ne_session.c:564 msgid "certificate issued for a different hostname" msgstr "" -#: src/ne_session.c:557 +#: src/ne_session.c:565 msgid "issuer is not trusted" msgstr "" -#: src/ne_session.c:558 +#: src/ne_session.c:566 msgid "bad certificate chain" msgstr "" -#: src/ne_session.c:559 +#: src/ne_session.c:567 msgid "certificate has been revoked" msgstr "" -#: src/ne_session.c:564 +#: src/ne_session.c:572 msgid "Server certificate verification failed: " msgstr "" -#: src/ne_socket.c:516 src/ne_socket.c:612 src/ne_socket.c:716 +#: src/ne_socket.c:522 src/ne_socket.c:618 src/ne_socket.c:722 #, fuzzy msgid "Connection closed" msgstr "Baðlantý sunucu tarafýndan kesildi" -#: src/ne_socket.c:622 src/ne_socket.c:728 +#: src/ne_socket.c:628 src/ne_socket.c:736 #, fuzzy msgid "Secure connection truncated" msgstr "Baðlantý süre sýnýrý aþýldý." -#: src/ne_socket.c:634 src/ne_socket.c:740 +#: src/ne_socket.c:640 src/ne_socket.c:748 #, fuzzy, c-format msgid "SSL error: %s" msgstr "%s: Hata: %s\n" -#: src/ne_socket.c:637 +#: src/ne_socket.c:643 #, c-format msgid "SSL error code %d/%d/%lu" msgstr "" -#: src/ne_socket.c:721 +#: src/ne_socket.c:727 #, fuzzy, c-format msgid "SSL alert received: %s" msgstr "%s: Hata: %s\n" -#: src/ne_socket.c:736 +#: src/ne_socket.c:744 msgid "SSL socket read failed" msgstr "" -#: src/ne_socket.c:867 +#: src/ne_socket.c:875 msgid "Line too long" msgstr "Satýr çok uzun" -#: src/ne_socket.c:1012 src/ne_socket.c:1018 +#: src/ne_socket.c:1036 src/ne_socket.c:1042 msgid "Host not found" msgstr "Sunucu bulunamadý" -#: src/ne_socket.c:1221 +#: src/ne_socket.c:1249 #, fuzzy msgid "Connection timed out" msgstr "%s: baðlantý bekleme sýnýrý aþýldý." -#: src/ne_socket.c:1412 +#: src/ne_socket.c:1442 msgid "Socket descriptor number exceeds FD_SETSIZE" msgstr "" -#: src/ne_socket.c:1474 +#: src/ne_socket.c:1504 msgid "Socket family not supported" msgstr "" -#: src/ne_socket.c:1701 +#: src/ne_socket.c:1735 msgid "Client certificate verification failed" msgstr "" -#: src/ne_socket.c:1717 +#: src/ne_socket.c:1751 msgid "SSL disabled due to lack of entropy" msgstr "" -#: src/ne_socket.c:1724 -msgid "SSL disabled due to library version mismatch" -msgstr "" - -#: src/ne_socket.c:1730 +#: src/ne_socket.c:1757 #, fuzzy msgid "Could not create SSL structure" msgstr "SSL baðlantýsý kurulamadý" diff --git a/libs/neon/po/zh_CN.gmo b/libs/neon/po/zh_CN.gmo index 5dd9dc39..f942eabe 100644 Binary files a/libs/neon/po/zh_CN.gmo and b/libs/neon/po/zh_CN.gmo differ diff --git a/libs/neon/po/zh_CN.po b/libs/neon/po/zh_CN.po index e036d2bb..b5e45c7c 100644 --- a/libs/neon/po/zh_CN.po +++ b/libs/neon/po/zh_CN.po @@ -9,10 +9,11 @@ msgid "" msgstr "" "Project-Id-Version: neon 0.29.x\n" "Report-Msgid-Bugs-To: neon@lists.manyfish.co.uk\n" -"POT-Creation-Date: 2010-10-01 13:30+0100\n" +"POT-Creation-Date: 2013-07-31 16:46+0100\n" "PO-Revision-Date: 2008-03-03 11:20+0800\n" "Last-Translator: Dongsheng Song \n" "Language-Team: neon@webdav.org\n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -26,107 +27,112 @@ msgstr "" "å“应信æ¯ä¸­ %d 行的状æ€å…ƒç´ ä¸­å‘现éžæ³• HTTP 状æ€è¡Œï¼š\n" "状æ€è¡Œæ˜¯: %s" -#: src/ne_auth.c:134 +#: src/ne_auth.c:139 #, c-format msgid "Could not authenticate to server: %s" msgstr "ä¸èƒ½è®¤è¯åˆ°æœåŠ¡å™¨: %s" -#: src/ne_auth.c:139 +#: src/ne_auth.c:144 #, c-format msgid "Could not authenticate to proxy server: %s" msgstr "ä¸èƒ½è®¤è¯åˆ°ä»£ç†æœåŠ¡å™¨: %s" -#: src/ne_auth.c:374 +#: src/ne_auth.c:386 #, c-format msgid "rejected %s challenge" msgstr "被拒ç»çš„ %s 挑战" -#: src/ne_auth.c:390 +#: src/ne_auth.c:402 msgid "missing realm in Basic challenge" msgstr "在基本挑战中丢失了领域" -#: src/ne_auth.c:485 +#: src/ne_auth.c:497 msgid "invalid Negotiate token" msgstr "éžæ³•ç£‹å•†ä»¤ç‰Œ" -#: src/ne_auth.c:508 +#: src/ne_auth.c:520 msgid "GSSAPI authentication error: " msgstr "GSSAPI 认è¯é”™è¯¯: " -#: src/ne_auth.c:521 +#: src/ne_auth.c:533 #, c-format msgid "GSSAPI failure (code %u)" msgstr "GSSAPI 失败(ä»£ç  %u)" -#: src/ne_auth.c:556 +#: src/ne_auth.c:568 msgid "ignoring empty Negotiate continuation" msgstr "忽略åŽç»­çš„空磋商" -#: src/ne_auth.c:571 +#: src/ne_auth.c:583 #, c-format msgid "Negotiate response verification failed: invalid response header token" msgstr "校验å商å“应失败:éžæ³•å“应头令牌" -#: src/ne_auth.c:593 +#: src/ne_auth.c:605 #, c-format msgid "Negotiate response verification failure: %s" msgstr "磋商å“应校验失败: %s" -#: src/ne_auth.c:765 +#: src/ne_auth.c:669 +#, fuzzy, c-format +msgid "SSPI response verification failed: invalid response header token" +msgstr "校验å商å“应失败:éžæ³•å“应头令牌" + +#: src/ne_auth.c:802 msgid "unknown algorithm in Digest challenge" msgstr "在摘è¦æŒ‘战中的算法ä¸å¯è¯†åˆ«" -#: src/ne_auth.c:769 +#: src/ne_auth.c:806 msgid "incompatible algorithm in Digest challenge" msgstr "在摘è¦æŒ‘战中的算法ä¸å…¼å®¹" -#: src/ne_auth.c:773 +#: src/ne_auth.c:810 msgid "missing parameter in Digest challenge" msgstr "在摘è¦æŒ‘战中的å‚数丢失" -#: src/ne_auth.c:777 +#: src/ne_auth.c:814 msgid "initial Digest challenge was stale" msgstr "陈旧的åˆå§‹åŒ–摘è¦æŒ‘战" -#: src/ne_auth.c:784 +#: src/ne_auth.c:821 msgid "stale Digest challenge with new algorithm or realm" msgstr "陈旧的摘è¦æŒ‘战用于新算法或新领域" -#: src/ne_auth.c:796 +#: src/ne_auth.c:833 msgid "could not parse domain in Digest challenge" msgstr "在摘è¦æŒ‘战中的ä¸èƒ½è§£æžåŸŸ" -#: src/ne_auth.c:1105 +#: src/ne_auth.c:1142 #, c-format msgid "Digest mutual authentication failure: missing parameters" msgstr "摘è¦äº’相认è¯å¤±è´¥ï¼šå‚æ•°é—æ¼" -#: src/ne_auth.c:1110 +#: src/ne_auth.c:1147 #, c-format msgid "Digest mutual authentication failure: client nonce mismatch" msgstr "摘è¦äº’相认è¯å¤±è´¥ï¼šå®¢æˆ·çŽ°æ—¶ä¸åŒ¹é…" -#: src/ne_auth.c:1120 +#: src/ne_auth.c:1157 #, c-format msgid "Digest mutual authentication failure: could not parse nonce count" msgstr "摘è¦äº’相认è¯å¤±è´¥ï¼šä¸èƒ½è§£æžçŽ°æ—¶è®¡æ•°" -#: src/ne_auth.c:1125 +#: src/ne_auth.c:1162 #, c-format msgid "Digest mutual authentication failure: nonce count mismatch (%u not %u)" msgstr "摘è¦äº’相认è¯å¤±è´¥ï¼šçŽ°æ—¶è®¡ç®—ä¸åŒ¹é… (应该是 %u,ä¸æ˜¯ %u)" -#: src/ne_auth.c:1168 +#: src/ne_auth.c:1205 #, c-format msgid "Digest mutual authentication failure: request-digest mismatch" msgstr "摘è¦äº’相认è¯å¤±è´¥ï¼šè¯·æ±‚摘è¦ä¸åŒ¹é…" -#: src/ne_auth.c:1299 +#: src/ne_auth.c:1336 #, c-format msgid "ignored %s challenge" msgstr "被忽略的 %s 挑战" -#: src/ne_auth.c:1378 +#: src/ne_auth.c:1415 msgid "could not parse challenge" msgstr "ä¸èƒ½è§£æžæŒ‘战" @@ -163,50 +169,50 @@ msgstr "解压数æ®å¤±è´¥" msgid "Could not initialize zlib" msgstr "åˆå§‹åŒ– zlib 失败" -#: src/ne_gnutls.c:172 +#: src/ne_gnutls.c:176 #, c-format msgid "[unprintable:#%lu]" msgstr "[éžæ‰“å°å­—符:#%lu]" -#: src/ne_gnutls.c:201 +#: src/ne_gnutls.c:205 msgid "[unprintable]" msgstr "[éžæ‰“å°å­—符]" -#: src/ne_gnutls.c:817 +#: src/ne_gnutls.c:845 msgid "signed using insecure algorithm" msgstr "" -#: src/ne_gnutls.c:820 +#: src/ne_gnutls.c:848 #, c-format msgid "unrecognized errors (%u)" msgstr "" -#: src/ne_gnutls.c:865 src/ne_openssl.c:468 +#: src/ne_gnutls.c:893 src/ne_openssl.c:470 #, c-format msgid "Server certificate was missing commonName attribute in subject name" msgstr "æœåŠ¡å™¨è¯ä¹¦åœ¨ä¸»é¢˜å称é—æ¼äº†å±žæ€§ commonName" -#: src/ne_gnutls.c:879 +#: src/ne_gnutls.c:907 #, fuzzy, c-format msgid "Could not verify server certificate: %s" msgstr "ä¸èƒ½å†™å…¥æ–‡ä»¶ï¼š%s" -#: src/ne_gnutls.c:891 src/ne_openssl.c:455 +#: src/ne_gnutls.c:919 src/ne_openssl.c:457 #, c-format msgid "Certificate verification error: %s" msgstr "è¯ä¹¦æ ¡éªŒå¤±è´¥ï¼š%s" -#: src/ne_gnutls.c:924 src/ne_openssl.c:674 +#: src/ne_gnutls.c:952 src/ne_openssl.c:702 #, c-format msgid "SSL handshake failed, client certificate was requested: %s" msgstr "" -#: src/ne_gnutls.c:929 src/ne_openssl.c:679 +#: src/ne_gnutls.c:957 src/ne_openssl.c:707 #, fuzzy, c-format msgid "SSL handshake failed: %s" msgstr "SSL å商失败:%s" -#: src/ne_gnutls.c:939 +#: src/ne_gnutls.c:967 #, c-format msgid "Server did not send certificate chain" msgstr "æœåŠ¡å™¨ä¸èƒ½å‘é€è¯ä¹¦é“¾" @@ -225,12 +231,12 @@ msgstr "é”定 %s çš„å“应é—æ¼äº†ä¸»åŠ¨é”" msgid "No activelock for <%s> returned in LOCK refresh response" msgstr "刷新é”定 %s çš„å“应没有返回主动é”" -#: src/ne_openssl.c:699 +#: src/ne_openssl.c:727 #, c-format msgid "SSL server did not present certificate" msgstr "SSL æœåŠ¡å™¨ä¸èƒ½å‘ˆçŽ°è¯ä¹¦" -#: src/ne_openssl.c:708 +#: src/ne_openssl.c:736 #, c-format msgid "Server certificate changed: connection intercepted?" msgstr "æœåŠ¡å™¨è¯ä¹¦æ”¹å˜ï¼šæ˜¯å¦è¢«æ‹¦æˆªæ”»å‡»ï¼Ÿ" @@ -278,199 +284,200 @@ msgstr "éžæ³•å移" msgid "Could not seek to offset %s of request body file: %s" msgstr "在请求主体文件ä¸èƒ½å®šä½åˆ°å移 %s: %s" -#: src/ne_request.c:385 +#: src/ne_request.c:423 msgid "Could not send request body" msgstr "ä¸èƒ½å‘é€è¯·æ±‚主体" -#: src/ne_request.c:728 +#: src/ne_request.c:450 +#, fuzzy +msgid "Could not send chunked request terminator" +msgstr "ä¸èƒ½å‘é€è¯·æ±‚" + +#: src/ne_request.c:784 msgid "Could not read chunk size" msgstr "ä¸èƒ½è¯»å—大å°" -#: src/ne_request.c:735 +#: src/ne_request.c:791 msgid "Could not parse chunk size" msgstr "ä¸èƒ½è§£æžå—大å°" -#: src/ne_request.c:772 +#: src/ne_request.c:828 msgid "Could not read response body" msgstr "ä¸èƒ½è¯»å–å“应主体" -#: src/ne_request.c:788 +#: src/ne_request.c:844 msgid "Could not read chunk delimiter" msgstr "ä¸èƒ½è¯»å—分割符" -#: src/ne_request.c:791 +#: src/ne_request.c:847 msgid "Chunk delimiter was invalid" msgstr "éžæ³•çš„分割符" -#: src/ne_request.c:896 +#: src/ne_request.c:952 msgid "Could not read status line" msgstr "ä¸èƒ½è¯»çŠ¶æ€è¡Œ" -#: src/ne_request.c:918 +#: src/ne_request.c:974 msgid "Could not parse response status line" msgstr "ä¸èƒ½è§£æžå“应状æ€è¡Œ" -#: src/ne_request.c:930 +#: src/ne_request.c:986 msgid "Could not read interim response headers" msgstr "ä¸èƒ½è¯»ä¸´æ—¶å“应头" -#: src/ne_request.c:964 +#: src/ne_request.c:1020 msgid "Could not send request" msgstr "ä¸èƒ½å‘é€è¯·æ±‚" -#: src/ne_request.c:1012 src/ne_request.c:1030 src/ne_request.c:1040 +#: src/ne_request.c:1068 src/ne_request.c:1086 src/ne_request.c:1096 msgid "Error reading response headers" msgstr "读å–å“应头出错" -#: src/ne_request.c:1058 +#: src/ne_request.c:1114 #, c-format msgid "Response header too long" msgstr "å“应头太长" -#: src/ne_request.c:1140 +#: src/ne_request.c:1196 msgid "Response exceeded maximum number of header fields" msgstr "å“应头的域数é‡è¶…出了最大数é‡" -#: src/ne_request.c:1155 +#: src/ne_request.c:1211 #, c-format msgid "Could not resolve hostname `%s': %s" msgstr "ä¸èƒ½è§£æžä¸»æœºå称 “%sâ€: %s" -#: src/ne_request.c:1286 +#: src/ne_request.c:1342 msgid "Unknown transfer-coding in response" msgstr "å“应中的传输代ç æœªçŸ¥" -#: src/ne_request.c:1299 +#: src/ne_request.c:1355 msgid "Invalid Content-Length in response" msgstr "éžæ³•çš„ Content-Length å“应域" -#: src/ne_request.c:1372 +#: src/ne_request.c:1428 #, c-format msgid "Could not write to file: %s" msgstr "ä¸èƒ½å†™å…¥æ–‡ä»¶ï¼š%s" -#: src/ne_request.c:1445 +#: src/ne_request.c:1501 #, c-format msgid "Could not create SSL connection through proxy server: %s" msgstr "ä¸èƒ½é€šè¿‡ä»£ç†æœåŠ¡å™¨ “%s†创建 SSL 连接" -#: src/ne_request.c:1484 +#: src/ne_request.c:1540 #, c-format msgid "Could not create socket" msgstr "ä¸èƒ½åˆ›å»ºå¥—接字" -#: src/ne_request.c:1518 +#: src/ne_request.c:1574 msgid "Could not connect to server" msgstr "ä¸èƒ½è¿žæŽ¥åˆ°æœåŠ¡å™¨" -#: src/ne_request.c:1520 +#: src/ne_request.c:1576 msgid "Could not connect to proxy server" msgstr "ä¸èƒ½è¿žæŽ¥åˆ°ä»£ç†æœåŠ¡å™¨" -#: src/ne_request.c:1563 +#: src/ne_request.c:1619 #, c-format msgid "Could not find IPv4 address of hostname %s for SOCKS v4 proxy" msgstr "" -#: src/ne_request.c:1621 +#: src/ne_request.c:1677 #, fuzzy, c-format msgid "Could not establish connection from SOCKS proxy (%s:%u): %s" msgstr "ä¸èƒ½é€šè¿‡ä»£ç†æœåŠ¡å™¨ “%s†创建 SSL 连接" -#: src/ne_session.c:530 src/ne_session.c:541 +#: src/ne_session.c:538 src/ne_session.c:549 msgid "[invalid date]" msgstr "[éžæ³•æ—¥æœŸ]" -#: src/ne_session.c:554 +#: src/ne_session.c:562 msgid "certificate is not yet valid" msgstr "è¯ä¹¦è¿˜æœªç”Ÿæ•ˆ" -#: src/ne_session.c:555 +#: src/ne_session.c:563 msgid "certificate has expired" msgstr "è¯ä¹¦å·²ç»è¿‡æ—¶" -#: src/ne_session.c:556 +#: src/ne_session.c:564 msgid "certificate issued for a different hostname" msgstr "æ­¤è¯ä¹¦æ˜¯ä¸ºä¸åŒçš„主机å称é¢å‘" -#: src/ne_session.c:557 +#: src/ne_session.c:565 msgid "issuer is not trusted" msgstr "è¯ä¹¦å‘行者ä¸è¢«ä¿¡ä»»" -#: src/ne_session.c:558 +#: src/ne_session.c:566 #, fuzzy msgid "bad certificate chain" msgstr "è¯ä¹¦å·²ç»è¿‡æ—¶" -#: src/ne_session.c:559 +#: src/ne_session.c:567 #, fuzzy msgid "certificate has been revoked" msgstr "è¯ä¹¦å·²ç»è¿‡æ—¶" -#: src/ne_session.c:564 +#: src/ne_session.c:572 msgid "Server certificate verification failed: " msgstr "æœåŠ¡å™¨è¯ä¹¦æ ¡éªŒå¤±è´¥" -#: src/ne_socket.c:516 src/ne_socket.c:612 src/ne_socket.c:716 +#: src/ne_socket.c:522 src/ne_socket.c:618 src/ne_socket.c:722 msgid "Connection closed" msgstr "连接关闭" -#: src/ne_socket.c:622 src/ne_socket.c:728 +#: src/ne_socket.c:628 src/ne_socket.c:736 msgid "Secure connection truncated" msgstr "安全连接切断" -#: src/ne_socket.c:634 src/ne_socket.c:740 +#: src/ne_socket.c:640 src/ne_socket.c:748 #, c-format msgid "SSL error: %s" msgstr "SSL 错误:%s" -#: src/ne_socket.c:637 +#: src/ne_socket.c:643 #, c-format msgid "SSL error code %d/%d/%lu" msgstr "SSL é”™è¯¯ä»£ç  %d/%d/%lu" -#: src/ne_socket.c:721 +#: src/ne_socket.c:727 #, c-format msgid "SSL alert received: %s" msgstr "收到 SSL 警报: %s" -#: src/ne_socket.c:736 +#: src/ne_socket.c:744 msgid "SSL socket read failed" msgstr "SSL 套接字读å–失败" -#: src/ne_socket.c:867 +#: src/ne_socket.c:875 msgid "Line too long" msgstr "行太长" -#: src/ne_socket.c:1012 src/ne_socket.c:1018 +#: src/ne_socket.c:1036 src/ne_socket.c:1042 msgid "Host not found" msgstr "没有å‘现主机" -#: src/ne_socket.c:1221 +#: src/ne_socket.c:1249 msgid "Connection timed out" msgstr "连接超时" -#: src/ne_socket.c:1412 +#: src/ne_socket.c:1442 msgid "Socket descriptor number exceeds FD_SETSIZE" msgstr "套接字数é‡è¶…过 FD_SETSIZE" -#: src/ne_socket.c:1474 +#: src/ne_socket.c:1504 msgid "Socket family not supported" msgstr "" -#: src/ne_socket.c:1701 +#: src/ne_socket.c:1735 msgid "Client certificate verification failed" msgstr "客户è¯ä¹¦æ ¡éªŒå¤±è´¥" -#: src/ne_socket.c:1717 +#: src/ne_socket.c:1751 msgid "SSL disabled due to lack of entropy" msgstr "由于缺少熵,SSL å·²ç»ç¦ç”¨" -#: src/ne_socket.c:1724 -msgid "SSL disabled due to library version mismatch" -msgstr "由于库版本ä¸åŒ¹é…,SSL å·²ç»ç¦ç”¨" - -#: src/ne_socket.c:1730 +#: src/ne_socket.c:1757 msgid "Could not create SSL structure" msgstr "ä¸èƒ½åˆ›å»º SSL 结构" @@ -627,3 +634,6 @@ msgstr "在 %d è¡Œè§£æž XML 错误: %s" #, c-format msgid "Could not parse response: %s" msgstr "ä¸èƒ½è§£æžå“应:%s" + +#~ msgid "SSL disabled due to library version mismatch" +#~ msgstr "由于库版本ä¸åŒ¹é…,SSL å·²ç»ç¦ç”¨" diff --git a/libs/neon/src/COPYING.LIB b/libs/neon/src/COPYING.LIB new file mode 100644 index 00000000..161a3d1d --- /dev/null +++ b/libs/neon/src/COPYING.LIB @@ -0,0 +1,482 @@ + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 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. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, 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 companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, 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 library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete 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 distribute a copy of this License along with the +Library. + + 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 Library or any portion +of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +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 Library, 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 Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you 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. + + If distribution of 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 satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. 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. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library 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. + + 9. 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 Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +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. + + 11. 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 Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library 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 Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library 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. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library 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 Library +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 Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +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 + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "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 +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. 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 LIBRARY 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 +LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. 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. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; 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. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/libs/neon/src/Makefile.in b/libs/neon/src/Makefile.in index 73d0515f..15fb02b9 100644 --- a/libs/neon/src/Makefile.in +++ b/libs/neon/src/Makefile.in @@ -117,54 +117,56 @@ ne_gnutls.@NEON_OBJEXT@: ne_gnutls.c $(top_builddir)/config.h ne_ssl.h ne_defs.h ne_private.h ne_request.h ne_utils.h ne_privssl.h #### ---CUT--- DO NOT REMOVE THIS LINE. Generated dependencies follow. #### ne_request.@NEON_OBJEXT@: ne_request.c $(top_builddir)/config.h ne_internal.h ne_defs.h ne_alloc.h \ - ne_request.h ne_utils.h ne_string.h ne_session.h ne_ssl.h ne_uri.h \ - ne_socket.h ne_private.h + ne_request.h ne_utils.h ne_string.h ne_session.h ne_ssl.h ne_uri.h \ + ne_socket.h ne_private.h ne_session.@NEON_OBJEXT@: ne_session.c $(top_builddir)/config.h ne_session.h ne_ssl.h ne_defs.h \ - ne_uri.h ne_socket.h ne_alloc.h ne_utils.h ne_internal.h ne_string.h \ - ne_dates.h ne_private.h ne_request.h + ne_uri.h ne_socket.h ne_alloc.h ne_utils.h ne_internal.h ne_string.h \ + ne_dates.h ne_private.h ne_request.h ne_basic.@NEON_OBJEXT@: ne_basic.c $(top_builddir)/config.h ne_request.h ne_utils.h ne_defs.h \ - ne_string.h ne_alloc.h ne_session.h ne_ssl.h ne_uri.h ne_socket.h \ - ne_basic.h ne_207.h ne_xml.h ne_locks.h ne_dates.h ne_internal.h + ne_string.h ne_alloc.h ne_session.h ne_ssl.h ne_uri.h ne_socket.h \ + ne_basic.h ne_207.h ne_xml.h ne_locks.h ne_dates.h ne_internal.h ne_string.@NEON_OBJEXT@: ne_string.c $(top_builddir)/config.h ne_alloc.h ne_defs.h ne_string.h ne_uri.@NEON_OBJEXT@: ne_uri.c $(top_builddir)/config.h ne_string.h ne_defs.h ne_alloc.h ne_uri.h ne_dates.@NEON_OBJEXT@: ne_dates.c $(top_builddir)/config.h ne_alloc.h ne_defs.h ne_dates.h \ - ne_string.h + ne_string.h ne_alloc.@NEON_OBJEXT@: ne_alloc.c $(top_builddir)/config.h ne_alloc.h ne_defs.h ne_md5.@NEON_OBJEXT@: ne_md5.c $(top_builddir)/config.h ne_md5.h ne_defs.h ne_string.h ne_alloc.h ne_utils.@NEON_OBJEXT@: ne_utils.c $(top_builddir)/config.h ne_utils.h ne_defs.h ne_string.h \ - ne_alloc.h ne_dates.h + ne_alloc.h ne_dates.h ne_socket.@NEON_OBJEXT@: ne_socket.c $(top_builddir)/config.h ne_privssl.h ne_ssl.h ne_defs.h \ - ne_socket.h ne_internal.h ne_utils.h ne_string.h ne_alloc.h ne_sspi.h + ne_socket.h ne_internal.h ne_utils.h ne_string.h ne_alloc.h ne_sspi.h ne_auth.@NEON_OBJEXT@: ne_auth.c $(top_builddir)/config.h ne_md5.h ne_defs.h ne_dates.h \ - ne_request.h ne_utils.h ne_string.h ne_alloc.h ne_session.h ne_ssl.h \ - ne_uri.h ne_socket.h ne_auth.h ne_internal.h + ne_request.h ne_utils.h ne_string.h ne_alloc.h ne_session.h ne_ssl.h \ + ne_uri.h ne_socket.h ne_auth.h ne_internal.h ne_ntlm.h ne_redirect.@NEON_OBJEXT@: ne_redirect.c $(top_builddir)/config.h ne_session.h ne_ssl.h ne_defs.h \ - ne_uri.h ne_socket.h ne_request.h ne_utils.h ne_string.h ne_alloc.h \ - ne_redirect.h ne_internal.h + ne_uri.h ne_socket.h ne_request.h ne_utils.h ne_string.h ne_alloc.h \ + ne_redirect.h ne_internal.h ne_compress.@NEON_OBJEXT@: ne_compress.c $(top_builddir)/config.h ne_request.h ne_utils.h \ - ne_defs.h ne_string.h ne_alloc.h ne_session.h ne_ssl.h ne_uri.h \ - ne_socket.h ne_compress.h ne_internal.h + ne_defs.h ne_string.h ne_alloc.h ne_session.h ne_ssl.h ne_uri.h \ + ne_socket.h ne_compress.h ne_internal.h ne_i18n.@NEON_OBJEXT@: ne_i18n.c $(top_builddir)/config.h ne_i18n.h ne_defs.h ne_socks.@NEON_OBJEXT@: ne_socks.c $(top_builddir)/config.h ne_internal.h ne_defs.h ne_string.h \ - ne_alloc.h ne_socket.h ne_ssl.h ne_utils.h + ne_alloc.h ne_socket.h ne_ssl.h ne_utils.h +ne_ntlm.@NEON_OBJEXT@: ne_ntlm.c ne_ntlm.h $(top_builddir)/config.h ne_defs.h ne_string.h \ + ne_alloc.h ne_207.@NEON_OBJEXT@: ne_207.c $(top_builddir)/config.h ne_alloc.h ne_defs.h ne_utils.h ne_xml.h \ - ne_207.h ne_request.h ne_string.h ne_session.h ne_ssl.h ne_uri.h \ - ne_socket.h ne_basic.h ne_internal.h + ne_207.h ne_request.h ne_string.h ne_session.h ne_ssl.h ne_uri.h \ + ne_socket.h ne_basic.h ne_internal.h ne_xml.@NEON_OBJEXT@: ne_xml.c $(top_builddir)/config.h ne_internal.h ne_defs.h ne_alloc.h \ - ne_xml.h ne_utils.h ne_string.h + ne_xml.h ne_utils.h ne_string.h ne_props.@NEON_OBJEXT@: ne_props.c $(top_builddir)/config.h ne_alloc.h ne_defs.h ne_xml.h \ - ne_props.h ne_request.h ne_utils.h ne_string.h ne_session.h ne_ssl.h \ - ne_uri.h ne_socket.h ne_207.h ne_basic.h ne_locks.h ne_internal.h + ne_props.h ne_request.h ne_utils.h ne_string.h ne_session.h ne_ssl.h \ + ne_uri.h ne_socket.h ne_207.h ne_basic.h ne_locks.h ne_internal.h ne_locks.@NEON_OBJEXT@: ne_locks.c $(top_builddir)/config.h ne_alloc.h ne_defs.h ne_request.h \ - ne_utils.h ne_string.h ne_session.h ne_ssl.h ne_uri.h ne_socket.h \ - ne_xml.h ne_locks.h ne_basic.h ne_props.h ne_207.h ne_internal.h \ - ne_xmlreq.h + ne_utils.h ne_string.h ne_session.h ne_ssl.h ne_uri.h ne_socket.h \ + ne_xml.h ne_locks.h ne_basic.h ne_props.h ne_207.h ne_internal.h \ + ne_xmlreq.h ne_xmlreq.@NEON_OBJEXT@: ne_xmlreq.c $(top_builddir)/config.h ne_internal.h ne_defs.h ne_xmlreq.h \ - ne_request.h ne_utils.h ne_string.h ne_alloc.h ne_session.h ne_ssl.h \ - ne_uri.h ne_socket.h ne_xml.h ne_basic.h + ne_request.h ne_utils.h ne_string.h ne_alloc.h ne_session.h ne_ssl.h \ + ne_uri.h ne_socket.h ne_xml.h ne_basic.h ne_oldacl.@NEON_OBJEXT@: ne_oldacl.c $(top_builddir)/config.h ne_request.h ne_utils.h ne_defs.h \ - ne_string.h ne_alloc.h ne_session.h ne_ssl.h ne_uri.h ne_socket.h \ - ne_locks.h ne_acl.h ne_xml.h + ne_string.h ne_alloc.h ne_session.h ne_ssl.h ne_uri.h ne_socket.h \ + ne_locks.h ne_acl.h ne_xml.h ne_acl3744.@NEON_OBJEXT@: ne_acl3744.c $(top_builddir)/config.h ne_request.h ne_utils.h ne_defs.h \ - ne_string.h ne_alloc.h ne_session.h ne_ssl.h ne_uri.h ne_socket.h \ - ne_locks.h ne_acl.h ne_xml.h + ne_string.h ne_alloc.h ne_session.h ne_ssl.h ne_uri.h ne_socket.h \ + ne_locks.h ne_acl3744.h ne_xml.h diff --git a/libs/neon/src/config.h b/libs/neon/src/config.h index 1107e23d..c375d629 100644 --- a/libs/neon/src/config.h +++ b/libs/neon/src/config.h @@ -25,9 +25,9 @@ #ifdef WIN32 -#define NEON_VERSION "0.29.6" +#define NEON_VERSION "0.30.0" #define NE_VERSION_MAJOR (0) -#define NE_VERSION_MINOR (29) +#define NE_VERSION_MINOR (30) #define HAVE_ERRNO_H #define HAVE_LIMITS_H @@ -36,16 +36,18 @@ #define HAVE_MEMCPY #define HAVE_SETSOCKOPT -#define HAVE_STRTOLL #define HAVE_SSPI +#define NE_HAVE_TS_SSL 1 + /* Define to enable debugging */ #define NE_DEBUGGING 1 #define NE_FMT_SIZE_T "u" #define NE_FMT_SSIZE_T "d" -#define NE_FMT_OFF_T "lld" +#define NE_FMT_OFF_T "ld" +#define NE_FMT_OFF64_T "I64d" #define NE_FMT_NE_OFF_T NE_FMT_OFF_T #ifndef NE_FMT_XML_SIZE @@ -70,9 +72,27 @@ #define strcasecmp strcmpi #define strncasecmp strnicmp #endif +#if defined(_MSC_VER) && _MSC_VER >= 1300 +#define HAVE_STRTOLL +#define strtoll _strtoi64 +#endif +#ifndef __BORLANDC__ #define ssize_t int +#endif #define inline __inline +#if defined(NE_LFS) +#ifdef __BORLANDC__ +#define lseek64 _lseeki64 +#define fstat64 _fstati64 +#define stat64 stati64 +#else +#define lseek64 _lseeki64 +#define fstat64 _fstat64 +#define stat64 __stat64 +#endif +#else #define off_t _off_t +#endif #ifndef USE_GETADDRINFO #define in_addr_t unsigned int diff --git a/libs/neon/src/ne_auth.c b/libs/neon/src/ne_auth.c index df640d5a..eb1ad999 100644 --- a/libs/neon/src/ne_auth.c +++ b/libs/neon/src/ne_auth.c @@ -1,6 +1,6 @@ /* HTTP Authentication routines - Copyright (C) 1999-2009, Joe Orton + Copyright (C) 1999-2011, Joe Orton This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -181,6 +181,7 @@ typedef struct { /* This is used for SSPI (Negotiate/NTLM) auth */ char *sspi_token; void *sspi_context; + char *sspi_host; #endif #ifdef HAVE_NTLM /* This is used for NTLM auth */ @@ -299,6 +300,8 @@ static void clean_session(auth_session *sess) sess->sspi_token = NULL; ne_sspi_destroy_context(sess->sspi_context); sess->sspi_context = NULL; + if (sess->sspi_host) ne_free(sess->sspi_host); + sess->sspi_host = NULL; #endif #ifdef HAVE_NTLM if (sess->ntlm_context) { @@ -482,6 +485,7 @@ static void make_gss_error(ne_buffer *buf, int *flag, static int continue_negotiate(auth_session *sess, const char *token, ne_buffer **errmsg) { + NE_DEBUG_WINSCP_CONTEXT(sess->sess); unsigned int major, minor; gss_buffer_desc input = GSS_C_EMPTY_BUFFER; gss_buffer_desc output = GSS_C_EMPTY_BUFFER; @@ -571,6 +575,7 @@ static int negotiate_challenge(auth_session *sess, int attempt, static int verify_negotiate_response(struct auth_request *req, auth_session *sess, const char *hdr) { + NE_DEBUG_WINSCP_CONTEXT(sess->sess); char *duphdr = ne_strdup(hdr); char *sep, *ptr = strchr(duphdr, ' '); int ret; @@ -621,20 +626,14 @@ static char *request_sspi(auth_session *sess, struct auth_request *request) static int continue_sspi(auth_session *sess, int ntlm, const char *hdr) { + NE_DEBUG_WINSCP_CONTEXT(sess->sess); int status; char *response = NULL; NE_DEBUG(NE_DBG_HTTPAUTH, "auth: SSPI challenge.\n"); if (!sess->sspi_context) { - ne_uri uri = {0}; - - ne_fill_server_uri(sess->sess, &uri); - - status = ne_sspi_create_context(&sess->sspi_context, uri.host, ntlm); - - ne_uri_free(&uri); - + status = ne_sspi_create_context(&sess->sspi_context, sess->sspi_host, ntlm); if (status) { return status; } @@ -666,6 +665,7 @@ static int sspi_challenge(auth_session *sess, int attempt, static int verify_sspi(struct auth_request *req, auth_session *sess, const char *hdr) { + NE_DEBUG_WINSCP_CONTEXT(sess->sess); int ntlm = ne_strncasecmp(hdr, "NTLM ", 5) == 0; char *ptr = strchr(hdr, ' '); @@ -692,6 +692,7 @@ static int verify_sspi(struct auth_request *req, auth_session *sess, * in the session appropriately. */ static int parse_domain(auth_session *sess, const char *domain) { + NE_DEBUG_WINSCP_CONTEXT(sess->sess); char *cp = ne_strdup(domain), *p = cp; ne_uri base; int invalid = 0; @@ -765,6 +766,7 @@ static int ntlm_challenge(auth_session *sess, int attempt, struct auth_challenge *parms, ne_buffer **errmsg) { + NE_DEBUG_WINSCP_CONTEXT(sess->sess); int status; NE_DEBUG(NE_DBG_HTTPAUTH, "auth: NTLM challenge.\n"); @@ -800,6 +802,7 @@ static int digest_challenge(auth_session *sess, int attempt, struct auth_challenge *parms, ne_buffer **errmsg) { + NE_DEBUG_WINSCP_CONTEXT(sess->sess); char password[NE_ABUFSIZ]; if (parms->alg == auth_alg_unknown) { @@ -915,6 +918,7 @@ static int digest_challenge(auth_session *sess, int attempt, * domain defined for the session. */ static int inside_domain(auth_session *sess, const char *req_uri) { + NE_DEBUG_WINSCP_CONTEXT(sess->sess); int inside = 0; size_t n; ne_uri uri; @@ -943,6 +947,7 @@ static int inside_domain(auth_session *sess, const char *req_uri) * session. */ static char *request_digest(auth_session *sess, struct auth_request *req) { + NE_DEBUG_WINSCP_CONTEXT(sess->sess); struct ne_md5_ctx *a2, *rdig; char a2_md5_ascii[33], rdig_md5_ascii[33]; char nc_value[9] = {0}; @@ -1103,6 +1108,7 @@ static int tokenize(char **hdr, char **key, char **value, char *sep, static int verify_digest_response(struct auth_request *req, auth_session *sess, const char *value) { + NE_DEBUG_WINSCP_CONTEXT(sess->sess); char *hdr, *pnt, *key, *val; auth_qop qop = auth_qop_none; char *nextnonce, *rspauth, *cnonce, *nc, *qop_value; @@ -1232,7 +1238,7 @@ static const struct auth_protocol protocols[] = { digest_challenge, request_digest, verify_digest_response, 0 }, #ifdef HAVE_GSSAPI - { NE_AUTH_GSSAPI, 30, "Negotiate", + { NE_AUTH_GSSAPI_ONLY, 30, "Negotiate", negotiate_challenge, request_negotiate, verify_negotiate_response, AUTH_FLAG_OPAQUE_PARAM|AUTH_FLAG_VERIFY_NON40x|AUTH_FLAG_CONN_AUTH }, #endif @@ -1240,7 +1246,7 @@ static const struct auth_protocol protocols[] = { { NE_AUTH_NTLM, 30, "NTLM", sspi_challenge, request_sspi, NULL, AUTH_FLAG_OPAQUE_PARAM|AUTH_FLAG_VERIFY_NON40x|AUTH_FLAG_CONN_AUTH }, - { NE_AUTH_GSSAPI, 30, "Negotiate", + { NE_AUTH_SSPI, 30, "Negotiate", sspi_challenge, request_sspi, verify_sspi, AUTH_FLAG_OPAQUE_PARAM|AUTH_FLAG_VERIFY_NON40x|AUTH_FLAG_CONN_AUTH }, #endif @@ -1306,6 +1312,7 @@ static void challenge_error(ne_buffer **errbuf, const char *fmt, ...) static int auth_challenge(auth_session *sess, int attempt, const char *value) { + NE_DEBUG_WINSCP_CONTEXT(sess->sess); char *pnt, *key, *val, *hdr, sep; struct auth_challenge *chall = NULL, *challenges = NULL; ne_buffer *errmsg = NULL; @@ -1435,6 +1442,7 @@ static void ah_create(ne_request *req, void *session, const char *method, const char *uri) { auth_session *sess = session; + NE_DEBUG_WINSCP_CONTEXT(sess->sess); int is_connect = strcmp(method, "CONNECT") == 0; if (sess->context == AUTH_ANY || @@ -1463,6 +1471,7 @@ static void ah_create(ne_request *req, void *session, const char *method, static void ah_pre_send(ne_request *r, void *cookie, ne_buffer *request) { auth_session *sess = cookie; + NE_DEBUG_WINSCP_CONTEXT(sess->sess); struct auth_request *req = ne_get_request_private(r, sess->spec->id); if (sess->protocol && req) { @@ -1484,6 +1493,7 @@ static void ah_pre_send(ne_request *r, void *cookie, ne_buffer *request) static int ah_post_send(ne_request *req, void *cookie, const ne_status *status) { auth_session *sess = cookie; + NE_DEBUG_WINSCP_CONTEXT(sess->sess); struct auth_request *areq = ne_get_request_private(req, sess->spec->id); const char *auth_hdr, *auth_info_hdr; int ret = NE_OK; @@ -1551,8 +1561,8 @@ static int ah_post_send(ne_request *req, void *cookie, const ne_status *status) } #ifdef HAVE_SSPI - /* Clear the SSPI context after successfull authentication. */ - if ((status->klass == 2 || status->klass == 3) && sess->sspi_context) { + /* Clear the SSPI context after successful authentication. */ + if (status->code != sess->spec->status_code && sess->sspi_context) { ne_sspi_clear_context(sess->sspi_context); } #endif @@ -1614,6 +1624,11 @@ static void auth_register(ne_session *sess, int isproxy, unsigned protomask, /* Map NEGOTIATE to NTLM | GSSAPI. */ protomask |= NE_AUTH_GSSAPI | NE_AUTH_NTLM; } + + if ((protomask & NE_AUTH_GSSAPI) == NE_AUTH_GSSAPI) { + /* Map GSSAPI to GSSAPI_ONLY | SSPI. */ + protomask |= NE_AUTH_GSSAPI_ONLY | NE_AUTH_SSPI; + } ahs = ne_get_session_private(sess, id); if (ahs == NULL) { @@ -1639,7 +1654,7 @@ static void auth_register(ne_session *sess, int isproxy, unsigned protomask, } #ifdef HAVE_GSSAPI - if ((protomask & NE_AUTH_GSSAPI) && ahs->gssname == GSS_C_NO_NAME) { + if ((protomask & NE_AUTH_GSSAPI_ONLY) && ahs->gssname == GSS_C_NO_NAME) { ne_uri uri = {0}; if (isproxy) @@ -1652,6 +1667,21 @@ static void auth_register(ne_session *sess, int isproxy, unsigned protomask, ne_uri_free(&uri); } #endif +#ifdef HAVE_SSPI + if ((protomask & (NE_AUTH_NTLM|NE_AUTH_SSPI)) && !ahs->sspi_host) { + ne_uri uri = {0}; + + if (isproxy) + ne_fill_proxy_uri(sess, &uri); + else + ne_fill_server_uri(sess, &uri); + + ahs->sspi_host = uri.host; + uri.host = NULL; + + ne_uri_free(&uri); + } +#endif /* Find the end of the handler list, and add a new one. */ hdl = &ahs->handlers; diff --git a/libs/neon/src/ne_auth.h b/libs/neon/src/ne_auth.h index 39f65d5f..98e7e189 100644 --- a/libs/neon/src/ne_auth.h +++ b/libs/neon/src/ne_auth.h @@ -82,7 +82,8 @@ void ne_set_proxy_auth(ne_session *sess, ne_auth_creds creds, void *userdata); /* NE_AUTH_GSSAPI: Use GSSAPI or SSPI to authenticate the user; an * active attacker can modify any of the request/response at will, so - * this must not be used over an unsecured channel. */ + * this must not be used over an unsecured channel. NE_AUTH_GSSAPI + * is currently equivalent to (NE_AUTH_GSSAPI_ONLY | NE_AUTH_SSPI). */ #define NE_AUTH_GSSAPI (0x0008) /* NE_AUTH_NTLM: Use NTLM to authenticate the user; an active attacker @@ -90,6 +91,16 @@ void ne_set_proxy_auth(ne_session *sess, ne_auth_creds creds, void *userdata); * used over an unsecured channel. */ #define NE_AUTH_NTLM (0x0010) +/* NE_AUTH_SSPI: Use SSPI to authenticate the user; an + * active attacker can modify any of the request/response at will, so + * this must not be used over an unsecured channel. */ +#define NE_AUTH_SSPI (0x0020) + +/* NE_AUTH_GSSAPI_ONLY: Use GSSAPI to authenticate the user; an + * active attacker can modify any of the request/response at will, so + * this must not be used over an unsecured channel. */ +#define NE_AUTH_GSSAPI_ONLY (0x0040) + /* The default set of supported protocols, as deemed appropriate for * the given session scheme. */ #define NE_AUTH_DEFAULT (0x1000) diff --git a/libs/neon/src/ne_basic.c b/libs/neon/src/ne_basic.c index 168fbfe7..ad6afd51 100644 --- a/libs/neon/src/ne_basic.c +++ b/libs/neon/src/ne_basic.c @@ -325,9 +325,25 @@ static const struct options_map { { "working-resource", NE_CAP_WORK_RESOURCE }, { "merge", NE_CAP_MERGE }, { "baseline", NE_CAP_BASELINE }, - { "version-controlled-collection", NE_CAP_VC_COLLECTION } + { "version-controlled-collection", NE_CAP_VC_COLLECTION }, + { "extended-mkcol", NE_CAP_EXT_MKCOL } }; +#ifdef WINSCP +const char * ne_capability_name(unsigned int cap) +{ + unsigned n; + for (n = 0; n < sizeof(options_map)/sizeof(options_map[0]); n++) + { + if (options_map[n].cap == cap) + { + return options_map[n].name; + } + } + return NULL; +} +#endif + static void parse_dav_header(const char *value, unsigned int *caps) { char *tokens = ne_strdup(value), *pnt = tokens; diff --git a/libs/neon/src/ne_basic.h b/libs/neon/src/ne_basic.h index 9edf075c..8854eaff 100644 --- a/libs/neon/src/ne_basic.h +++ b/libs/neon/src/ne_basic.h @@ -96,7 +96,8 @@ typedef struct { * property a. la. mod_dav */ } ne_server_capabilities; -/* DEPRECATED: Determines server capabilities (using OPTIONS). */ +/* DEPRECATED: Determines server capabilities (using OPTIONS). Use + * ne_options2() instead. */ int ne_options(ne_session *sess, const char *path, ne_server_capabilities *caps); @@ -116,12 +117,17 @@ int ne_options(ne_session *sess, const char *path, #define NE_CAP_BASELINE (0x2000) /* DeltaV baseline */ #define NE_CAP_ACTIVITY (0x4000) /* DeltaV activity */ #define NE_CAP_VC_COLLECTION (0x8000) /* DeltaV version-controlled-collection */ +#define NE_CAP_EXT_MKCOL (0x10000) /* extended-mkcol (RFC 5689) */ /* Determines resource capailities, using an OPTIONS request. On * return, *caps is set to a bit-mask of the above NE_CAP_* constants * describing the advertised resource capabilities. */ int ne_options2(ne_session *sess, const char *path, unsigned int *caps); +#ifdef WINSCP +const char * ne_capability_name(unsigned int cap); +#endif + /* Defines a range of bytes, starting at 'start' and ending * at 'end'. 'total' is the number of bytes in the range. */ diff --git a/libs/neon/src/ne_compress.c b/libs/neon/src/ne_compress.c index f122bf55..f461f138 100644 --- a/libs/neon/src/ne_compress.c +++ b/libs/neon/src/ne_compress.c @@ -106,6 +106,7 @@ struct ne_decompress_s { */ static int parse_header(ne_decompress *ctx) { + NE_DEBUG_WINSCP_CONTEXT(ctx->session); NE_DEBUG(NE_DBG_HTTP, "ID1: %d ID2: %d, cmeth %d, flags %d\n", HDR_ID1(ctx), HDR_ID2(ctx), HDR_CMETH(ctx), HDR_FLAGS(ctx)); @@ -140,6 +141,7 @@ static int parse_header(ne_decompress *ctx) static int process_footer(ne_decompress *ctx, const unsigned char *buf, size_t len) { + NE_DEBUG_WINSCP_CONTEXT(ctx->session); if (len + ctx->footcount > 8) { ne_set_error(ctx->session, "Too many bytes (%" NE_FMT_SIZE_T ") in gzip footer", @@ -188,6 +190,7 @@ static void set_zlib_error(ne_decompress *ctx, const char *msg, int code) /* Inflate response buffer 'buf' of length 'len'. */ static int do_inflate(ne_decompress *ctx, const char *buf, size_t len) { + NE_DEBUG_WINSCP_CONTEXT(ctx->session); int ret; ctx->zstr.avail_in = len; @@ -239,6 +242,7 @@ static int do_inflate(ne_decompress *ctx, const char *buf, size_t len) static int gz_reader(void *ud, const char *buf, size_t len) { ne_decompress *ctx = ud; + NE_DEBUG_WINSCP_CONTEXT(ctx->session); const char *zbuf; size_t count; const char *hdr; @@ -377,6 +381,7 @@ static int gz_reader(void *ud, const char *buf, size_t len) static void gz_pre_send(ne_request *r, void *ud, ne_buffer *req) { ne_decompress *ctx = ud; + NE_DEBUG_WINSCP_CONTEXT(ctx->session); if (ctx->request == r) { NE_DEBUG(NE_DBG_HTTP, "compress: Initialization.\n"); diff --git a/libs/neon/src/ne_defs.h b/libs/neon/src/ne_defs.h index 01d0da9a..44798035 100644 --- a/libs/neon/src/ne_defs.h +++ b/libs/neon/src/ne_defs.h @@ -35,13 +35,19 @@ #include #ifdef NE_LFS +# ifdef _MSC_VER +typedef __int64 off64_t; +# endif +# ifdef __BORLANDC__ +typedef __int64 off64_t; +# endif typedef off64_t ne_off_t; #else -typedef __int64 ne_off_t; +typedef off_t ne_off_t; #endif /* define ssize_t for Win32 */ -#if (defined(WIN32) || defined(WIN64)) && !defined(ssize_t) +#if defined(WIN32) && !defined(ssize_t) #define ssize_t int #endif diff --git a/libs/neon/src/ne_gnutls.c b/libs/neon/src/ne_gnutls.c deleted file mode 100644 index eec5655b..00000000 --- a/libs/neon/src/ne_gnutls.c +++ /dev/null @@ -1,1399 +0,0 @@ -/* - neon SSL/TLS support using GNU TLS - Copyright (C) 2002-2010, Joe Orton - Copyright (C) 2004, Aleix Conchillo Flaque - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA -*/ - -#include "config.h" - -#include - -#ifdef HAVE_STRING_H -#include -#endif - -#include -#include -#include -#include - -#include -#include - -#ifdef NE_HAVE_TS_SSL -#include -#include -#if LIBGNUTLS_VERSION_NUMBER < 0x020b01 -#include -GCRY_THREAD_OPTION_PTHREAD_IMPL; -#endif -#else -#if LIBGNUTLS_VERSION_NUMBER < 0x020b01 -#include -#endif -#endif - -#ifdef HAVE_ICONV -#include -#endif - -#include "ne_ssl.h" -#include "ne_string.h" -#include "ne_session.h" -#include "ne_internal.h" - -#include "ne_private.h" -#include "ne_privssl.h" - -#if LIBGNUTLS_VERSION_NUMBER >= 0x020302 -/* The GnuTLS DN functions in 2.3.2 and later allow a simpler DN - * abstraction to be used. */ -#define HAVE_NEW_DN_API -#endif - -struct ne_ssl_dname_s { -#ifdef HAVE_NEW_DN_API - gnutls_x509_dn_t dn; -#else - int subject; /* non-zero if this is the subject DN object */ - gnutls_x509_crt cert; -#endif -}; - -struct ne_ssl_certificate_s { - ne_ssl_dname subj_dn, issuer_dn; - gnutls_x509_crt subject; - ne_ssl_certificate *issuer; - char *identity; -}; - -struct ne_ssl_client_cert_s { - gnutls_pkcs12 p12; - int decrypted; /* non-zero if successfully decrypted. */ - int keyless; - ne_ssl_certificate cert; - gnutls_x509_privkey pkey; - char *friendly_name; -}; - -/* Returns the highest used index in subject (or issuer) DN of - * certificate CERT for OID, or -1 if no RDNs are present in the DN - * using that OID. */ -static int oid_find_highest_index(gnutls_x509_crt cert, int subject, const char *oid) -{ - int ret, idx = -1; - - do { - size_t len = 0; - - if (subject) - ret = gnutls_x509_crt_get_dn_by_oid(cert, oid, ++idx, 0, - NULL, &len); - else - ret = gnutls_x509_crt_get_issuer_dn_by_oid(cert, oid, ++idx, 0, - NULL, &len); - } while (ret == GNUTLS_E_SHORT_MEMORY_BUFFER); - - return idx - 1; -} - -#ifdef HAVE_GNUTLS_X509_DN_GET_RDN_AVA -/* New-style RDN handling introduced in GnuTLS 1.7.x. */ - -#ifdef HAVE_ICONV -static void convert_dirstring(ne_buffer *buf, const char *charset, - gnutls_datum *data) -{ - iconv_t id = iconv_open("UTF-8", charset); - size_t inlen = data->size, outlen = buf->length - buf->used; - char *inbuf = (char *)data->data; - char *outbuf = buf->data + buf->used - 1; - - if (id == (iconv_t)-1) { - char err[128], err2[128]; - - ne_snprintf(err, sizeof err, "[unprintable in %s: %s]", - charset, ne_strerror(errno, err2, sizeof err2)); - ne_buffer_zappend(buf, err); - return; - } - - ne_buffer_grow(buf, buf->used + 64); - - while (inlen && outlen - && iconv(id, &inbuf, &inlen, &outbuf, &outlen) == 0) - ; - - iconv_close(id); - buf->used += buf->length - buf->used - outlen; - buf->data[buf->used - 1] = '\0'; -} -#endif - -/* From section 11.13 of the Dubuisson ASN.1 bible: */ -#define TAG_UTF8 (12) -#define TAG_PRINTABLE (19) -#define TAG_T61 (20) -#define TAG_IA5 (22) -#define TAG_VISIBLE (26) -#define TAG_UNIVERSAL (28) -#define TAG_BMP (30) - -static void append_dirstring(ne_buffer *buf, gnutls_datum *data, unsigned long tag) -{ - switch (tag) { - case TAG_UTF8: - case TAG_IA5: - case TAG_PRINTABLE: - case TAG_VISIBLE: - ne_buffer_append(buf, (char *)data->data, data->size); - break; -#ifdef HAVE_ICONV - case TAG_T61: - convert_dirstring(buf, "ISO-8859-1", data); - break; - case TAG_BMP: - convert_dirstring(buf, "UCS-2BE", data); - break; -#endif - default: { - char tmp[128]; - ne_snprintf(tmp, sizeof tmp, _("[unprintable:#%lu]"), tag); - ne_buffer_zappend(buf, tmp); - } break; - } -} - -/* OIDs to not include in readable DNs by default: */ -#define OID_emailAddress "1.2.840.113549.1.9.1" -#define OID_commonName "2.5.4.3" - -#define CMPOID(a,o) ((a)->oid.size == sizeof(o) \ - && memcmp((a)->oid.data, o, strlen(o)) == 0) - -char *ne_ssl_readable_dname(const ne_ssl_dname *name) -{ - gnutls_x509_dn_t dn; - int ret, rdn = 0, flag = 0; - ne_buffer *buf; - gnutls_x509_ava_st val; - -#ifdef HAVE_NEW_DN_API - dn = name->dn; -#else - if (name->subject) - ret = gnutls_x509_crt_get_subject(name->cert, &dn); - else - ret = gnutls_x509_crt_get_issuer(name->cert, &dn); - - if (ret) - return ne_strdup(_("[unprintable]")); -#endif /* HAVE_NEW_DN_API */ - - buf = ne_buffer_create(); - - /* Find the highest rdn... */ - while (gnutls_x509_dn_get_rdn_ava(dn, rdn++, 0, &val) == 0) - ; - - /* ..then iterate back to the first: */ - while (--rdn >= 0) { - int ava = 0; - - /* Iterate through all AVAs for multivalued AVAs; better than - * ne_openssl can do! */ - do { - ret = gnutls_x509_dn_get_rdn_ava(dn, rdn, ava, &val); - - /* If the *only* attribute to append is the common name or - * email address, use it; otherwise skip those - * attributes. */ - if (ret == 0 && val.value.size > 0 - && ((!CMPOID(&val, OID_emailAddress) - && !CMPOID(&val, OID_commonName)) - || (buf->used == 1 && rdn == 0))) { - flag = 1; - if (buf->used > 1) ne_buffer_append(buf, ", ", 2); - - append_dirstring(buf, &val.value, val.value_tag); - } - - ava++; - } while (ret == 0); - } - - return ne_buffer_finish(buf); -} - -#else /* !HAVE_GNUTLS_X509_DN_GET_RDN_AVA */ - -/* Appends the value of RDN with given oid from certitifcate x5 - * subject (if subject is non-zero), or issuer DN to buffer 'buf': */ -static void append_rdn(ne_buffer *buf, gnutls_x509_crt x5, int subject, const char *oid) -{ - int idx, top, ret; - char rdn[50]; - - top = oid_find_highest_index(x5, subject, oid); - - for (idx = top; idx >= 0; idx--) { - size_t rdnlen = sizeof rdn; - - if (subject) - ret = gnutls_x509_crt_get_dn_by_oid(x5, oid, idx, 0, rdn, &rdnlen); - else - ret = gnutls_x509_crt_get_issuer_dn_by_oid(x5, oid, idx, 0, rdn, &rdnlen); - - if (ret < 0) - return; - - if (buf->used > 1) { - ne_buffer_append(buf, ", ", 2); - } - - ne_buffer_append(buf, rdn, rdnlen); - } -} - -char *ne_ssl_readable_dname(const ne_ssl_dname *name) -{ - ne_buffer *buf = ne_buffer_create(); - int ret, idx = 0; - - do { - char oid[32] = {0}; - size_t oidlen = sizeof oid; - - ret = name->subject - ? gnutls_x509_crt_get_dn_oid(name->cert, idx, oid, &oidlen) - : gnutls_x509_crt_get_issuer_dn_oid(name->cert, idx, oid, &oidlen); - - if (ret == 0) { - append_rdn(buf, name->cert, name->subject, oid); - idx++; - } - } while (ret != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE); - - return ne_buffer_finish(buf); -} -#endif /* HAVE_GNUTLS_X509_DN_GET_RDN_AVA */ - -int ne_ssl_dname_cmp(const ne_ssl_dname *dn1, const ne_ssl_dname *dn2) -{ - char c1[1024], c2[1024]; - size_t s1 = sizeof c1, s2 = sizeof c2; - -#ifdef HAVE_NEW_DN_API - if (gnutls_x509_dn_export(dn1->dn, GNUTLS_X509_FMT_DER, c1, &s1)) - return 1; - - if (gnutls_x509_dn_export(dn2->dn, GNUTLS_X509_FMT_DER, c2, &s2)) - return -1; -#else - int ret; - - if (dn1->subject) - ret = gnutls_x509_crt_get_dn(dn1->cert, c1, &s1); - else - ret = gnutls_x509_crt_get_issuer_dn(dn1->cert, c1, &s1); - if (ret) - return 1; - - if (dn2->subject) - ret = gnutls_x509_crt_get_dn(dn2->cert, c2, &s2); - else - ret = gnutls_x509_crt_get_issuer_dn(dn2->cert, c2, &s2); - if (ret) - return -1; -#endif /* HAVE_NEW_DN_API */ - - if (s1 != s2) - return s2 - s1; - - return memcmp(c1, c2, s1); -} - -void ne_ssl_clicert_free(ne_ssl_client_cert *cc) -{ - if (cc->p12) - gnutls_pkcs12_deinit(cc->p12); - if (cc->decrypted) { - if (cc->cert.identity) ne_free(cc->cert.identity); - if (cc->pkey) gnutls_x509_privkey_deinit(cc->pkey); - if (cc->cert.subject) gnutls_x509_crt_deinit(cc->cert.subject); - } - if (cc->friendly_name) ne_free(cc->friendly_name); - ne_free(cc); -} - -void ne_ssl_cert_validity_time(const ne_ssl_certificate *cert, - time_t *from, time_t *until) -{ - if (from) { - *from = gnutls_x509_crt_get_activation_time(cert->subject); - } - if (until) { - *until = gnutls_x509_crt_get_expiration_time(cert->subject); - } -} - -/* Check certificate identity. Returns zero if identity matches; 1 if - * identity does not match, or <0 if the certificate had no identity. - * If 'identity' is non-NULL, store the malloc-allocated identity in - * *identity. If 'server' is non-NULL, it must be the network address - * of the server in use, and identity must be NULL. */ -static int check_identity(const ne_uri *server, gnutls_x509_crt cert, - char **identity) -{ - char name[255]; - unsigned int critical; - int ret, seq = 0; - int match = 0, found = 0; - size_t len; - const char *hostname; - - hostname = server ? server->host : ""; - - do { - len = sizeof name - 1; - ret = gnutls_x509_crt_get_subject_alt_name(cert, seq, name, &len, - &critical); - switch (ret) { - case GNUTLS_SAN_DNSNAME: - name[len] = '\0'; - if (identity && !found) *identity = ne_strdup(name); - match = ne__ssl_match_hostname(name, len, hostname); - found = 1; - break; - case GNUTLS_SAN_IPADDRESS: { - ne_inet_addr *ia; - if (len == 4) - ia = ne_iaddr_make(ne_iaddr_ipv4, (unsigned char *)name); - else if (len == 16) - ia = ne_iaddr_make(ne_iaddr_ipv6, (unsigned char *)name); - else - ia = NULL; - if (ia) { - char buf[128]; - - match = strcmp(hostname, - ne_iaddr_print(ia, buf, sizeof buf)) == 0; - if (identity) *identity = ne_strdup(buf); - found = 1; - ne_iaddr_free(ia); - } else { - NE_DEBUG(NE_DBG_SSL, "iPAddress name with unsupported " - "address type (length %" NE_FMT_SIZE_T "), skipped.\n", - len); - } - } break; - case GNUTLS_SAN_URI: { - ne_uri uri; - - name[len] = '\0'; - - if (ne_uri_parse(name, &uri) == 0 && uri.host && uri.scheme) { - ne_uri tmp; - - if (identity && !found) *identity = ne_strdup(name); - found = 1; - - if (server) { - /* For comparison purposes, all that matters is - * host, scheme and port; ignore the rest. */ - memset(&tmp, 0, sizeof tmp); - tmp.host = uri.host; - tmp.scheme = uri.scheme; - tmp.port = uri.port; - - match = ne_uri_cmp(server, &tmp) == 0; - } - } - - ne_uri_free(&uri); - } break; - - default: - break; - } - seq++; - } while (!match && ret != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE); - - /* Check against the commonName if no DNS alt. names were found, - * as per RFC3280. */ - if (!found) { - seq = oid_find_highest_index(cert, 1, GNUTLS_OID_X520_COMMON_NAME); - - if (seq >= 0) { - len = sizeof name; - name[0] = '\0'; - ret = gnutls_x509_crt_get_dn_by_oid(cert, GNUTLS_OID_X520_COMMON_NAME, - seq, 0, name, &len); - if (ret == 0) { - if (identity) *identity = ne_strdup(name); - match = ne__ssl_match_hostname(name, len, hostname); - } - } else { - return -1; - } - } - - if (*hostname) - NE_DEBUG(NE_DBG_SSL, "ssl: Identity match for '%s': %s\n", hostname, - match ? "good" : "bad"); - - return match ? 0 : 1; -} - -/* Populate an ne_ssl_certificate structure from an X509 object. Note - * that x5 is owned by returned cert object and must not be otherwise - * freed by the caller. */ -static ne_ssl_certificate *populate_cert(ne_ssl_certificate *cert, - gnutls_x509_crt x5) -{ -#ifdef HAVE_NEW_DN_API - gnutls_x509_crt_get_subject(x5, &cert->subj_dn.dn); - gnutls_x509_crt_get_issuer(x5, &cert->issuer_dn.dn); -#else - cert->subj_dn.cert = x5; - cert->subj_dn.subject = 1; - cert->issuer_dn.cert = x5; - cert->issuer_dn.subject = 0; -#endif - cert->issuer = NULL; - cert->subject = x5; - cert->identity = NULL; - check_identity(NULL, x5, &cert->identity); - return cert; -} - -/* Returns a copy certificate of certificate SRC. */ -static gnutls_x509_crt x509_crt_copy(gnutls_x509_crt src) -{ - int ret; - size_t size; - gnutls_datum tmp; - gnutls_x509_crt dest; - - if (gnutls_x509_crt_init(&dest) != 0) { - return NULL; - } - - if (gnutls_x509_crt_export(src, GNUTLS_X509_FMT_DER, NULL, &size) - != GNUTLS_E_SHORT_MEMORY_BUFFER) { - gnutls_x509_crt_deinit(dest); - return NULL; - } - - tmp.data = ne_malloc(size); - ret = gnutls_x509_crt_export(src, GNUTLS_X509_FMT_DER, tmp.data, &size); - if (ret == 0) { - tmp.size = size; - ret = gnutls_x509_crt_import(dest, &tmp, GNUTLS_X509_FMT_DER); - } - - if (ret) { - gnutls_x509_crt_deinit(dest); - dest = NULL; - } - - ne_free(tmp.data); - return dest; -} - -/* Duplicate a client certificate, which must be in the decrypted state. */ -static ne_ssl_client_cert *dup_client_cert(const ne_ssl_client_cert *cc) -{ - int ret; - ne_ssl_client_cert *newcc = ne_calloc(sizeof *newcc); - - newcc->decrypted = 1; - - if (cc->keyless) { - newcc->keyless = 1; - } - else { - ret = gnutls_x509_privkey_init(&newcc->pkey); - if (ret != 0) goto dup_error; - - ret = gnutls_x509_privkey_cpy(newcc->pkey, cc->pkey); - if (ret != 0) goto dup_error; - } - - newcc->cert.subject = x509_crt_copy(cc->cert.subject); - if (!newcc->cert.subject) goto dup_error; - - if (cc->friendly_name) newcc->friendly_name = ne_strdup(cc->friendly_name); - - populate_cert(&newcc->cert, newcc->cert.subject); - return newcc; - -dup_error: - if (newcc->pkey) gnutls_x509_privkey_deinit(newcc->pkey); - if (newcc->cert.subject) gnutls_x509_crt_deinit(newcc->cert.subject); - ne_free(newcc); - return NULL; -} - -/* Callback invoked when the SSL server requests a client certificate. */ -static int provide_client_cert(gnutls_session session, - const gnutls_datum *req_ca_rdn, int nreqs, - const gnutls_pk_algorithm *sign_algos, - int sign_algos_length, gnutls_retr_st *st) -{ - ne_session *sess = gnutls_session_get_ptr(session); - - if (!sess) { - return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER; - } - - NE_DEBUG(NE_DBG_SSL, "ssl: Client cert provider callback; %d CA names.\n", - nreqs); - - if (!sess->client_cert && sess->ssl_provide_fn) { -#ifdef HAVE_NEW_DN_API - const ne_ssl_dname **dns; - ne_ssl_dname *dnarray; - unsigned dncount = 0; - int n; - - dns = ne_malloc(nreqs * sizeof(ne_ssl_dname *)); - dnarray = ne_calloc(nreqs * sizeof(ne_ssl_dname)); - - for (n = 0; n < nreqs; n++) { - gnutls_x509_dn_t dn; - - if (gnutls_x509_dn_init(&dn) == 0) { - dnarray[n].dn = dn; - if (gnutls_x509_dn_import(dn, &req_ca_rdn[n]) == 0) { - dns[dncount++] = &dnarray[n]; - } - else { - gnutls_x509_dn_deinit(dn); - } - } - } - - NE_DEBUG(NE_DBG_SSL, "ssl: Mapped %d CA names to %u DN objects.\n", - nreqs, dncount); - - sess->ssl_provide_fn(sess->ssl_provide_ud, sess, dns, dncount); - - for (n = 0; n < nreqs; n++) { - if (dnarray[n].dn) { - gnutls_x509_dn_deinit(dnarray[n].dn); - } - } - - ne_free(dns); - ne_free(dnarray); -#else /* HAVE_NEW_DN_API */ - /* Nothing to do here other than pretend no CA names were - * given, and hope the caller can cope. */ - sess->ssl_provide_fn(sess->ssl_provide_ud, sess, NULL, 0); -#endif - } - - if (sess->client_cert) { - gnutls_certificate_type type = gnutls_certificate_type_get(session); - if (type == GNUTLS_CRT_X509) { - NE_DEBUG(NE_DBG_SSL, "Supplying client certificate.\n"); - - st->type = type; - st->ncerts = 1; - st->cert.x509 = &sess->client_cert->cert.subject; - st->key.x509 = sess->client_cert->pkey; - - /* tell GNU TLS not to deallocate the certs. */ - st->deinit_all = 0; - } else { - return GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE; - } - } - else { - NE_DEBUG(NE_DBG_SSL, "No client certificate supplied.\n"); - st->ncerts = 0; - sess->ssl_cc_requested = 1; - return 0; - } - - return 0; -} - -void ne_ssl_set_clicert(ne_session *sess, const ne_ssl_client_cert *cc) -{ - sess->client_cert = dup_client_cert(cc); -} - -ne_ssl_context *ne_ssl_context_create(int flags) -{ - ne_ssl_context *ctx = ne_calloc(sizeof *ctx); - gnutls_certificate_allocate_credentials(&ctx->cred); - if (flags == NE_SSL_CTX_CLIENT) { - gnutls_certificate_client_set_retrieve_function(ctx->cred, - provide_client_cert); - } - gnutls_certificate_set_verify_flags(ctx->cred, - GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT); - return ctx; -} - -int ne_ssl_context_keypair(ne_ssl_context *ctx, - const char *cert, const char *key) -{ - gnutls_certificate_set_x509_key_file(ctx->cred, cert, key, - GNUTLS_X509_FMT_PEM); - return 0; -} - -int ne_ssl_context_set_verify(ne_ssl_context *ctx, int required, - const char *ca_names, const char *verify_cas) -{ - ctx->verify = required; - if (verify_cas) { - gnutls_certificate_set_x509_trust_file(ctx->cred, verify_cas, - GNUTLS_X509_FMT_PEM); - } - /* gnutls_certificate_send_x509_rdn_sequence in gnutls >= 1.2 can - * be used to *suppress* sending the CA names, but not control it, - * it seems. */ - return 0; -} - -void ne_ssl_context_set_flag(ne_ssl_context *ctx, int flag, int value) -{ - /* SSLv2 not supported. */ -} - -void ne_ssl_context_destroy(ne_ssl_context *ctx) -{ - gnutls_certificate_free_credentials(ctx->cred); - if (ctx->cache.client.data) { - ne_free(ctx->cache.client.data); - } else if (ctx->cache.server.key.data) { - gnutls_free(ctx->cache.server.key.data); - gnutls_free(ctx->cache.server.data.data); - } - ne_free(ctx); -} - -#ifdef HAVE_GNUTLS_CERTIFICATE_GET_X509_CAS -/* Return the issuer of the given certificate, or NULL if none can be - * found. */ -static gnutls_x509_crt find_issuer(gnutls_x509_crt *ca_list, - unsigned int num_cas, - gnutls_x509_crt cert) -{ - unsigned int n; - - for (n = 0; n < num_cas; n++) { - if (gnutls_x509_crt_check_issuer(cert, ca_list[n]) == 1) - return ca_list[n]; - } - - return NULL; -} -#endif - -/* Return the certificate chain sent by the peer, or NULL on error. */ -static ne_ssl_certificate *make_peers_chain(gnutls_session sock, - gnutls_certificate_credentials crd) -{ - ne_ssl_certificate *current = NULL, *top = NULL; - const gnutls_datum *certs; - unsigned int n, count; - ne_ssl_certificate *cert; - - certs = gnutls_certificate_get_peers(sock, &count); - if (!certs) { - return NULL; - } - - NE_DEBUG(NE_DBG_SSL, "ssl: Got %u certs in peer chain.\n", count); - - for (n = 0; n < count; n++) { - gnutls_x509_crt x5; - - if (gnutls_x509_crt_init(&x5) || - gnutls_x509_crt_import(x5, &certs[n], GNUTLS_X509_FMT_DER)) { - if (top) { - ne_ssl_cert_free(top); - } - return NULL; - } - - cert = populate_cert(ne_calloc(sizeof *cert), x5); - - if (top == NULL) { - current = top = cert; - } else { - current->issuer = cert; - current = cert; - } - } - -#ifdef HAVE_GNUTLS_CERTIFICATE_GET_X509_CAS - /* GnuTLS only returns the peers which were *sent* by the server - * in the Certificate list during the handshake. Fill in the - * complete chain manually against the certs we trust: */ - if (current->issuer == NULL) { - gnutls_x509_crt issuer; - gnutls_x509_crt *ca_list; - unsigned int num_cas; - - gnutls_certificate_get_x509_cas(crd, &ca_list, &num_cas); - - do { - /* Look up the issuer. */ - issuer = find_issuer(ca_list, num_cas, current->subject); - if (issuer) { - issuer = x509_crt_copy(issuer); - cert = populate_cert(ne_calloc(sizeof *cert), issuer); - /* Check that the issuer does not match the current - * cert. */ - if (ne_ssl_cert_cmp(current, cert)) { - current = current->issuer = cert; - } - else { - ne_ssl_cert_free(cert); - issuer = NULL; - } - } - } while (issuer); - } -#endif - - return top; -} - -/* Map from GnuTLS verify failure mask *status to NE_SSL_* failure - * bitmask, which is returned. *status is modified, removing all - * mapped bits. */ -static int map_verify_failures(unsigned int *status) -{ - static const struct { - gnutls_certificate_status_t from; - int to; - } map[] = { - { GNUTLS_CERT_REVOKED, NE_SSL_REVOKED }, -#if LIBGNUTLS_VERSION_NUMBER >= 0x020800 - { GNUTLS_CERT_NOT_ACTIVATED, NE_SSL_NOTYETVALID }, - { GNUTLS_CERT_EXPIRED, NE_SSL_EXPIRED }, -#endif - { GNUTLS_CERT_INVALID|GNUTLS_CERT_SIGNER_NOT_FOUND, NE_SSL_UNTRUSTED }, - { GNUTLS_CERT_INVALID|GNUTLS_CERT_SIGNER_NOT_CA, NE_SSL_UNTRUSTED } - }; - size_t n; - int ret = 0; - - for (n = 0; n < sizeof(map)/sizeof(map[0]); n++) { - if ((*status & map[n].from) == map[n].from) { - *status &= ~map[n].from; - ret |= map[n].to; - } - } - - return ret; -} - -/* Return a malloc-allocated human-readable error string describing - * GnuTLS verification error bitmask 'status'; return value must be - * freed by the caller. */ -static char *verify_error_string(unsigned int status) -{ - ne_buffer *buf = ne_buffer_create(); - - /* sorry, i18n-ers */ - if (status & GNUTLS_CERT_INSECURE_ALGORITHM) { - ne_buffer_zappend(buf, _("signed using insecure algorithm")); - } - else { - ne_buffer_snprintf(buf, 64, _("unrecognized errors (%u)"), - status); - } - - return ne_buffer_finish(buf); -} - -/* Return NE_SSL_* failure bits after checking chain expiry. */ -static int check_chain_expiry(ne_ssl_certificate *chain) -{ - time_t before, after, now = time(NULL); - ne_ssl_certificate *cert; - int failures = 0; - - /* Check that all certs within the chain are inside their defined - * validity period. Note that the errors flagged for the server - * cert are different from the generic error for issues higher up - * the chain. */ - for (cert = chain; cert; cert = cert->issuer) { - before = gnutls_x509_crt_get_activation_time(cert->subject); - after = gnutls_x509_crt_get_expiration_time(cert->subject); - - if (now < before) - failures |= (cert == chain) ? NE_SSL_NOTYETVALID : NE_SSL_BADCHAIN; - else if (now > after) - failures |= (cert == chain) ? NE_SSL_EXPIRED : NE_SSL_BADCHAIN; - } - - return failures; -} - -/* Verifies an SSL server certificate. */ -static int check_certificate(ne_session *sess, gnutls_session sock, - ne_ssl_certificate *chain) -{ - int ret, failures = 0; - ne_uri server; - unsigned int status; - - memset(&server, 0, sizeof server); - ne_fill_server_uri(sess, &server); - ret = check_identity(&server, chain->subject, NULL); - ne_uri_free(&server); - - if (ret < 0) { - ne_set_error(sess, _("Server certificate was missing commonName " - "attribute in subject name")); - return NE_ERROR; - } - else if (ret > 0) { - failures |= NE_SSL_IDMISMATCH; - } - - failures |= check_chain_expiry(chain); - - ret = gnutls_certificate_verify_peers2(sock, &status); - NE_DEBUG(NE_DBG_SSL, "ssl: Verify peers returned %d, status=%u\n", - ret, status); - if (ret != GNUTLS_E_SUCCESS) { - ne_set_error(sess, _("Could not verify server certificate: %s"), - gnutls_strerror(ret)); - return NE_ERROR; - } - - failures |= map_verify_failures(&status); - - NE_DEBUG(NE_DBG_SSL, "ssl: Verification failures = %d (status = %u).\n", - failures, status); - - if (status && status != GNUTLS_CERT_INVALID) { - char *errstr = verify_error_string(status); - ne_set_error(sess, _("Certificate verification error: %s"), errstr); - ne_free(errstr); - return NE_ERROR; - } - - if (failures == 0) { - ret = NE_OK; - } else { - ne__ssl_set_verify_err(sess, failures); - ret = NE_ERROR; - if (sess->ssl_verify_fn - && sess->ssl_verify_fn(sess->ssl_verify_ud, failures, chain) == 0) - ret = NE_OK; - } - - return ret; -} - -/* Negotiate an SSL connection. */ -int ne__negotiate_ssl(ne_session *sess) -{ - ne_ssl_context *const ctx = sess->ssl_context; - ne_ssl_certificate *chain; - gnutls_session sock; - - NE_DEBUG(NE_DBG_SSL, "Negotiating SSL connection.\n"); - - /* Pass through the hostname if SNI is enabled. */ - ctx->hostname = - sess->flags[NE_SESSFLAG_TLS_SNI] ? sess->server.hostname : NULL; - - if (ne_sock_connect_ssl(sess->socket, ctx, sess)) { - if (sess->ssl_cc_requested) { - ne_set_error(sess, _("SSL handshake failed, " - "client certificate was requested: %s"), - ne_sock_error(sess->socket)); - } - else { - ne_set_error(sess, _("SSL handshake failed: %s"), - ne_sock_error(sess->socket)); - } - return NE_ERROR; - } - - sock = ne__sock_sslsock(sess->socket); - - chain = make_peers_chain(sock, ctx->cred); - if (chain == NULL) { - ne_set_error(sess, _("Server did not send certificate chain")); - return NE_ERROR; - } - - if (sess->server_cert && ne_ssl_cert_cmp(sess->server_cert, chain) == 0) { - /* Same cert as last time; presume OK. This is not optimal as - * make_peers_chain() has already gone through and done the - * expensive DER parsing stuff for the whole chain by now. */ - ne_ssl_cert_free(chain); - return NE_OK; - } - - if (check_certificate(sess, sock, chain)) { - ne_ssl_cert_free(chain); - return NE_ERROR; - } - - sess->server_cert = chain; - - return NE_OK; -} - -const ne_ssl_dname *ne_ssl_cert_issuer(const ne_ssl_certificate *cert) -{ - return &cert->issuer_dn; -} - -const ne_ssl_dname *ne_ssl_cert_subject(const ne_ssl_certificate *cert) -{ - return &cert->subj_dn; -} - -const ne_ssl_certificate *ne_ssl_cert_signedby(const ne_ssl_certificate *cert) -{ - return cert->issuer; -} - -const char *ne_ssl_cert_identity(const ne_ssl_certificate *cert) -{ - return cert->identity; -} - -void ne_ssl_context_trustcert(ne_ssl_context *ctx, const ne_ssl_certificate *cert) -{ - gnutls_x509_crt certs = cert->subject; - gnutls_certificate_set_x509_trust(ctx->cred, &certs, 1); -} - -void ne_ssl_trust_default_ca(ne_session *sess) -{ -#ifdef NE_SSL_CA_BUNDLE - gnutls_certificate_set_x509_trust_file(sess->ssl_context->cred, - NE_SSL_CA_BUNDLE, - GNUTLS_X509_FMT_PEM); -#endif -} - -/* Read the contents of file FILENAME into *DATUM. */ -static int read_to_datum(const char *filename, gnutls_datum *datum) -{ - FILE *f = fopen(filename, "r"); - ne_buffer *buf; - char tmp[4192]; - size_t len; - - if (!f) { - return -1; - } - - buf = ne_buffer_ncreate(8192); - while ((len = fread(tmp, 1, sizeof tmp, f)) > 0) { - ne_buffer_append(buf, tmp, len); - } - - if (!feof(f)) { - fclose(f); - ne_buffer_destroy(buf); - return -1; - } - - fclose(f); - - datum->size = ne_buffer_size(buf); - datum->data = (unsigned char *)ne_buffer_finish(buf); - return 0; -} - -/* Parses a PKCS#12 structure and loads the certificate, private key - * and friendly name if possible. Returns zero on success, non-zero - * on error. */ -static int pkcs12_parse(gnutls_pkcs12 p12, gnutls_x509_privkey *pkey, - gnutls_x509_crt *x5, char **friendly_name, - const char *password) -{ - gnutls_pkcs12_bag bag = NULL; - int i, j, ret = 0; - - for (i = 0; ret == 0; ++i) { - if (bag) gnutls_pkcs12_bag_deinit(bag); - - ret = gnutls_pkcs12_bag_init(&bag); - if (ret < 0) continue; - - ret = gnutls_pkcs12_get_bag(p12, i, bag); - if (ret < 0) continue; - - gnutls_pkcs12_bag_decrypt(bag, password); - - for (j = 0; ret == 0 && j < gnutls_pkcs12_bag_get_count(bag); ++j) { - gnutls_pkcs12_bag_type type; - gnutls_datum data; - - if (friendly_name && *friendly_name == NULL) { - char *name = NULL; - gnutls_pkcs12_bag_get_friendly_name(bag, j, &name); - if (name) { - if (name[0] == '.') name++; /* weird GnuTLS bug? */ - *friendly_name = ne_strdup(name); - } - } - - type = gnutls_pkcs12_bag_get_type(bag, j); - switch (type) { - case GNUTLS_BAG_PKCS8_KEY: - case GNUTLS_BAG_PKCS8_ENCRYPTED_KEY: - /* Ignore any but the first key encountered; really - * need to match up keyids. */ - if (*pkey) break; - - gnutls_x509_privkey_init(pkey); - - ret = gnutls_pkcs12_bag_get_data(bag, j, &data); - if (ret < 0) continue; - - ret = gnutls_x509_privkey_import_pkcs8(*pkey, &data, - GNUTLS_X509_FMT_DER, - password, - 0); - if (ret < 0) continue; - break; - case GNUTLS_BAG_CERTIFICATE: - /* Ignore any but the first cert encountered; again, - * really need to match up keyids. */ - if (*x5) break; - - ret = gnutls_x509_crt_init(x5); - if (ret < 0) continue; - - ret = gnutls_pkcs12_bag_get_data(bag, j, &data); - if (ret < 0) continue; - - ret = gnutls_x509_crt_import(*x5, &data, GNUTLS_X509_FMT_DER); - if (ret < 0) continue; - - break; - default: - break; - } - } - } - - /* Make sure last bag is freed */ - if (bag) gnutls_pkcs12_bag_deinit(bag); - - /* Free in case of error */ - if (ret < 0 && ret != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) { - if (*x5) gnutls_x509_crt_deinit(*x5); - if (*pkey) gnutls_x509_privkey_deinit(*pkey); - if (friendly_name && *friendly_name) ne_free(*friendly_name); - } - - if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) ret = 0; - return ret; -} - -ne_ssl_client_cert *ne_ssl_clicert_read(const char *filename) -{ - int ret; - gnutls_datum data; - gnutls_pkcs12 p12; - ne_ssl_client_cert *cc; - char *friendly_name = NULL; - gnutls_x509_crt cert = NULL; - gnutls_x509_privkey pkey = NULL; - - if (read_to_datum(filename, &data)) - return NULL; - - if (gnutls_pkcs12_init(&p12) != 0) { - return NULL; - } - - ret = gnutls_pkcs12_import(p12, &data, GNUTLS_X509_FMT_DER, 0); - ne_free(data.data); - if (ret < 0) { - gnutls_pkcs12_deinit(p12); - return NULL; - } - - if (gnutls_pkcs12_verify_mac(p12, "") == 0) { - if (pkcs12_parse(p12, &pkey, &cert, &friendly_name, "") != 0 - || !cert || !pkey) { - gnutls_pkcs12_deinit(p12); - return NULL; - } - - cc = ne_calloc(sizeof *cc); - cc->pkey = pkey; - cc->decrypted = 1; - cc->friendly_name = friendly_name; - populate_cert(&cc->cert, cert); - gnutls_pkcs12_deinit(p12); - cc->p12 = NULL; - return cc; - } else { - /* TODO: calling pkcs12_parse() here to find the friendly_name - * seems to break horribly. */ - cc = ne_calloc(sizeof *cc); - cc->p12 = p12; - return cc; - } -} - -ne_ssl_client_cert *ne__ssl_clicert_exkey_import(const unsigned char *der, - size_t der_len) -{ - ne_ssl_client_cert *cc; - gnutls_x509_crt x5; - gnutls_datum datum; - - datum.data = (unsigned char *)der; - datum.size = der_len; - - if (gnutls_x509_crt_init(&x5) - || gnutls_x509_crt_import(x5, &datum, GNUTLS_X509_FMT_DER)) { - NE_DEBUG(NE_DBG_SSL, "ssl: crt_import failed.\n"); - return NULL; - } - - cc = ne_calloc(sizeof *cc); - cc->keyless = 1; - cc->decrypted = 1; - populate_cert(&cc->cert, x5); - - return cc; -} - -int ne_ssl_clicert_encrypted(const ne_ssl_client_cert *cc) -{ - return !cc->decrypted; -} - -int ne_ssl_clicert_decrypt(ne_ssl_client_cert *cc, const char *password) -{ - int ret; - gnutls_x509_crt cert = NULL; - gnutls_x509_privkey pkey = NULL; - - if (gnutls_pkcs12_verify_mac(cc->p12, password) != 0) { - return -1; - } - - ret = pkcs12_parse(cc->p12, &pkey, &cert, NULL, password); - if (ret < 0) - return ret; - - if (!cert || (!pkey && !cc->keyless)) { - if (cert) gnutls_x509_crt_deinit(cert); - if (pkey) gnutls_x509_privkey_deinit(pkey); - return -1; - } - - gnutls_pkcs12_deinit(cc->p12); - populate_cert(&cc->cert, cert); - cc->pkey = pkey; - cc->decrypted = 1; - cc->p12 = NULL; - return 0; -} - -const ne_ssl_certificate *ne_ssl_clicert_owner(const ne_ssl_client_cert *cc) -{ - return &cc->cert; -} - -const char *ne_ssl_clicert_name(const ne_ssl_client_cert *ccert) -{ - return ccert->friendly_name; -} - -ne_ssl_certificate *ne_ssl_cert_read(const char *filename) -{ - int ret; - gnutls_datum data; - gnutls_x509_crt x5; - - if (read_to_datum(filename, &data)) - return NULL; - - if (gnutls_x509_crt_init(&x5) != 0) - return NULL; - - ret = gnutls_x509_crt_import(x5, &data, GNUTLS_X509_FMT_PEM); - ne_free(data.data); - if (ret < 0) { - gnutls_x509_crt_deinit(x5); - return NULL; - } - - return populate_cert(ne_calloc(sizeof(struct ne_ssl_certificate_s)), x5); -} - -int ne_ssl_cert_write(const ne_ssl_certificate *cert, const char *filename) -{ - unsigned char buffer[10*1024]; - size_t len = sizeof buffer; - - FILE *fp = fopen(filename, "w"); - - if (fp == NULL) return -1; - - if (gnutls_x509_crt_export(cert->subject, GNUTLS_X509_FMT_PEM, buffer, - &len) < 0) { - fclose(fp); - return -1; - } - - if (fwrite(buffer, len, 1, fp) != 1) { - fclose(fp); - return -1; - } - - if (fclose(fp) != 0) - return -1; - - return 0; -} - -void ne_ssl_cert_free(ne_ssl_certificate *cert) -{ - gnutls_x509_crt_deinit(cert->subject); - if (cert->identity) ne_free(cert->identity); - if (cert->issuer) ne_ssl_cert_free(cert->issuer); - ne_free(cert); -} - -int ne_ssl_cert_cmp(const ne_ssl_certificate *c1, const ne_ssl_certificate *c2) -{ - char digest1[NE_SSL_DIGESTLEN], digest2[NE_SSL_DIGESTLEN]; - - if (ne_ssl_cert_digest(c1, digest1) || ne_ssl_cert_digest(c2, digest2)) { - return -1; - } - - return strcmp(digest1, digest2); -} - -/* The certificate import/export format is the base64 encoding of the - * raw DER; PEM without the newlines and wrapping. */ - -ne_ssl_certificate *ne_ssl_cert_import(const char *data) -{ - int ret; - size_t len; - unsigned char *der; - gnutls_datum buffer = { NULL, 0 }; - gnutls_x509_crt x5; - - if (gnutls_x509_crt_init(&x5) != 0) - return NULL; - - /* decode the base64 to get the raw DER representation */ - len = ne_unbase64(data, &der); - if (len == 0) return NULL; - - buffer.data = der; - buffer.size = len; - - ret = gnutls_x509_crt_import(x5, &buffer, GNUTLS_X509_FMT_DER); - ne_free(der); - - if (ret < 0) { - gnutls_x509_crt_deinit(x5); - return NULL; - } - - return populate_cert(ne_calloc(sizeof(struct ne_ssl_certificate_s)), x5); -} - -char *ne_ssl_cert_export(const ne_ssl_certificate *cert) -{ - unsigned char *der; - size_t len = 0; - char *ret; - - /* find the length of the DER encoding. */ - if (gnutls_x509_crt_export(cert->subject, GNUTLS_X509_FMT_DER, NULL, &len) != - GNUTLS_E_SHORT_MEMORY_BUFFER) { - return NULL; - } - - der = ne_malloc(len); - if (gnutls_x509_crt_export(cert->subject, GNUTLS_X509_FMT_DER, der, &len)) { - ne_free(der); - return NULL; - } - - ret = ne_base64(der, len); - ne_free(der); - return ret; -} - -int ne_ssl_cert_digest(const ne_ssl_certificate *cert, char *digest) -{ - char sha1[20], *p; - int j; - size_t len = sizeof sha1; - - if (gnutls_x509_crt_get_fingerprint(cert->subject, GNUTLS_DIG_SHA, - sha1, &len) < 0) - return -1; - - for (j = 0, p = digest; j < 20; j++) { - *p++ = NE_HEX2ASC((sha1[j] >> 4) & 0x0f); - *p++ = NE_HEX2ASC(sha1[j] & 0x0f); - *p++ = ':'; - } - - *--p = '\0'; - return 0; -} - -int ne__ssl_init(void) -{ -#if LIBGNUTLS_VERSION_NUMBER < 0x020b01 -#ifdef NE_HAVE_TS_SSL - gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); -#endif - gcry_control(GCRYCTL_ENABLE_QUICK_RANDOM, 0); -#endif - return gnutls_global_init(); -} - -void ne__ssl_exit(void) -{ - /* No way to unregister the thread callbacks. Doomed. */ -#if LIBGNUTLS_VERSION_MAJOR > 1 || LIBGNUTLS_VERSION_MINOR > 3 \ - || (LIBGNUTLS_VERSION_MINOR == 3 && LIBGNUTLS_VERSION_PATCH >= 3) - /* It's safe to call gnutls_global_deinit() here only with - * gnutls >= 1.3., since older versions don't refcount and - * doing so would prevent any other use of gnutls within - * the process. */ - gnutls_global_deinit(); -#endif -} diff --git a/libs/neon/src/ne_internal.h b/libs/neon/src/ne_internal.h index 386708c8..c9c6efff 100644 --- a/libs/neon/src/ne_internal.h +++ b/libs/neon/src/ne_internal.h @@ -71,12 +71,12 @@ && SIZEOF_OFF_T == SIZEOF_LONG_LONG #define NE_OFFT_MAX LONG_LONG_MAX #else -#define NE_OFFT_MAX LLONG_MAX +#define NE_OFFT_MAX LONG_MAX #endif -#if defined(HAVE_STRTOLL) +#if SIZEOF_OFF_T > SIZEOF_LONG && defined(HAVE_STRTOLL) #define ne_strtoff strtoll -#elif defined(HAVE_STRTOQ) +#elif SIZEOF_OFF_T > SIZEOF_LONG && defined(HAVE_STRTOQ) #define ne_strtoff strtoq #else #define ne_strtoff strtol diff --git a/libs/neon/src/ne_locks.c b/libs/neon/src/ne_locks.c index fbe390c2..8c171878 100644 --- a/libs/neon/src/ne_locks.c +++ b/libs/neon/src/ne_locks.c @@ -241,6 +241,7 @@ struct ne_lock *ne_lockstore_findbyuri(ne_lock_store *store, void ne_lock_using_parent(ne_request *req, const char *path) { + NE_DEBUG_WINSCP_CONTEXT(ne_get_session(req)); struct lh_req_cookie *lrc = ne_get_request_private(req, HOOK_ID); ne_uri u = {0}; struct lock_list *item; @@ -279,6 +280,7 @@ void ne_lock_using_parent(ne_request *req, const char *path) void ne_lock_using_resource(ne_request *req, const char *uri, int depth) { + NE_DEBUG_WINSCP_CONTEXT(ne_get_session(req)); struct lh_req_cookie *lrc = ne_get_request_private(req, HOOK_ID); struct lock_list *item; int match; @@ -567,6 +569,7 @@ static int lk_startelm(void *userdata, int parent, { struct lock_ctx *ctx = userdata; int id; + NE_DEBUG_WINSCP_CONTEXT(ne_get_session(ctx->req)); id = ne_xml_mapid(element_map, NE_XML_MAPLEN(element_map), nspace, name); diff --git a/libs/neon/src/ne_md5.c b/libs/neon/src/ne_md5.c index 3022c6f5..35d71094 100644 --- a/libs/neon/src/ne_md5.c +++ b/libs/neon/src/ne_md5.c @@ -139,6 +139,7 @@ md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) { /* Take yet unprocessed bytes into account. */ md5_uint32 bytes = ctx->buflen; + md5_uint32 swap_bytes; size_t pad; /* Now count remaining bytes. */ @@ -149,10 +150,13 @@ md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes; memcpy (&ctx->buffer[bytes], fillbuf, pad); - /* Put the 64-bit file length in *bits* at the end of the buffer. */ - *(md5_uint32 *) &ctx->buffer[bytes + pad] = SWAP (ctx->total[0] << 3); - *(md5_uint32 *) &ctx->buffer[bytes + pad + 4] = SWAP ((ctx->total[1] << 3) | - (ctx->total[0] >> 29)); + /* Put the 64-bit file length in *bits* at the end of the buffer. + Use memcpy to avoid aliasing problems. On most systems, this + will be optimized away to the same code. */ + swap_bytes = SWAP (ctx->total[0] << 3); + memcpy (&ctx->buffer[bytes + pad], &swap_bytes, sizeof (swap_bytes)); + swap_bytes = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29)); + memcpy (&ctx->buffer[bytes + pad + 4], &swap_bytes, sizeof (swap_bytes)); /* Process last bytes. */ md5_process_block (ctx->buffer, bytes + pad + 8, ctx); diff --git a/libs/neon/src/ne_openssl.c b/libs/neon/src/ne_openssl.c index bc2a0475..beef2905 100644 --- a/libs/neon/src/ne_openssl.c +++ b/libs/neon/src/ne_openssl.c @@ -1,6 +1,6 @@ /* neon SSL/TLS support using OpenSSL - Copyright (C) 2002-2009, Joe Orton + Copyright (C) 2002-2011, Joe Orton This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -38,8 +38,10 @@ #ifdef NE_HAVE_TS_SSL #include /* for abort() */ +#ifndef _WIN32 #include #endif +#endif #include "ne_ssl.h" #include "ne_string.h" @@ -249,7 +251,7 @@ static int check_identity(const ne_uri *server, X509 *cert, char **identity) char *name = dup_ia5string(nm->d.ia5); if (identity && !found) *identity = ne_strdup(name); match = ne__ssl_match_hostname(name, strlen(name), hostname); - free(name); + ne_free(name); found = 1; } else if (nm->type == GEN_IPADD) { @@ -298,7 +300,7 @@ static int check_identity(const ne_uri *server, X509 *cert, char **identity) } ne_uri_free(&uri); - free(name); + ne_free(name); } } /* free the whole stack. */ @@ -368,6 +370,7 @@ static int verify_callback(int ok, X509_STORE_CTX *ctx) int depth = X509_STORE_CTX_get_error_depth(ctx); int err = X509_STORE_CTX_get_error(ctx); int failures = 0; + NE_DEBUG_WINSCP_CONTEXT(sess); /* If there's no error, nothing to do here. */ if (ok) return ok; @@ -422,10 +425,12 @@ static ne_ssl_certificate *make_chain(STACK_OF(X509) *chain) ne_ssl_certificate *cert = ne_malloc(sizeof *cert); populate_cert(cert, X509_dup(sk_X509_value(chain, n))); #ifdef NE_DEBUGGING +#ifndef WINSCP if (ne_debug_mask & NE_DBG_SSL) { fprintf(ne_debug_stream, "Cert #%d:\n", n); X509_print_fp(ne_debug_stream, cert->subject); } +#endif #endif if (top == NULL) { current = top = cert; @@ -507,6 +512,7 @@ static ne_ssl_client_cert *dup_client_cert(const ne_ssl_client_cert *cc) static int provide_client_cert(SSL *ssl, X509 **cert, EVP_PKEY **pkey) { ne_session *const sess = SSL_get_app_data(ssl); + NE_DEBUG_WINSCP_CONTEXT(sess); if (!sess->client_cert && sess->ssl_provide_fn) { ne_ssl_dname **dnames = NULL, *dnarray = NULL; @@ -568,9 +574,19 @@ ne_ssl_context *ne_ssl_context_create(int mode) } else if (mode == NE_SSL_CTX_SERVER) { ctx->ctx = SSL_CTX_new(SSLv23_server_method()); SSL_CTX_set_session_cache_mode(ctx->ctx, SSL_SESS_CACHE_CLIENT); +#ifdef SSL_OP_NO_TICKET + /* disable ticket support since it inhibits testing of session + * caching. */ + SSL_CTX_set_options(ctx->ctx, SSL_OP_NO_TICKET); +#endif } else { +#ifdef OPENSSL_NO_SSL2 + ne_free(ctx); + return NULL; +#else ctx->ctx = SSL_CTX_new(SSLv2_server_method()); SSL_CTX_set_session_cache_mode(ctx->ctx, SSL_SESS_CACHE_CLIENT); +#endif } return ctx; } @@ -594,6 +610,22 @@ void ne_ssl_context_set_flag(ne_ssl_context *ctx, int flag, int value) SSL_CTX_set_options(ctx->ctx, opts); } +int ne_ssl_context_get_flag(ne_ssl_context *ctx, int flag) +{ + switch (flag) { + case NE_SSL_CTX_SSLv2: +#ifdef OPENSSL_NO_SSL2 + return 0; +#else + return ! (SSL_CTX_get_options(ctx->ctx) & SSL_OP_NO_SSLv2); +#endif + default: + break; + } + + return 0; +} + int ne_ssl_context_keypair(ne_ssl_context *ctx, const char *cert, const char *key) { @@ -650,6 +682,7 @@ static int SSL_SESSION_cmp(SSL_SESSION *a, SSL_SESSION *b) /* For internal use only. */ int ne__negotiate_ssl(ne_session *sess) { + NE_DEBUG_WINSCP_CONTEXT(sess); ne_ssl_context *ctx = sess->ssl_context; SSL *ssl; STACK_OF(X509) *chain; @@ -814,22 +847,12 @@ static char *find_friendly_name(PKCS12 *p12) return name; } -ne_ssl_client_cert *ne_ssl_clicert_read(const char *filename) +static ne_ssl_client_cert *parse_client_cert(PKCS12 *p12) { - PKCS12 *p12; - FILE *fp; X509 *cert; EVP_PKEY *pkey; ne_ssl_client_cert *cc; - fp = fopen(filename, "rb"); - if (fp == NULL) - return NULL; - - p12 = d2i_PKCS12_fp(fp, NULL); - - fclose(fp); - if (p12 == NULL) { ERR_clear_error(); return NULL; @@ -875,6 +898,34 @@ ne_ssl_client_cert *ne_ssl_clicert_read(const char *filename) } } +ne_ssl_client_cert *ne_ssl_clicert_import(const unsigned char *buffer, + size_t buflen) +{ + ne_d2i_uchar *p; + PKCS12 *p12; + + p = buffer; + p12 = d2i_PKCS12(NULL, &p, buflen); + + return parse_client_cert(p12); +} + +ne_ssl_client_cert *ne_ssl_clicert_read(const char *filename) +{ + PKCS12 *p12; + FILE *fp; + + fp = fopen(filename, "rb"); + if (fp == NULL) + return NULL; + + p12 = d2i_PKCS12_fp(fp, NULL); + + fclose(fp); + + return parse_client_cert(p12); +} + #ifdef HAVE_PAKCHOIS ne_ssl_client_cert *ne__ssl_clicert_exkey_import(const unsigned char *der, size_t der_len, @@ -1087,17 +1138,25 @@ int ne_ssl_cert_digest(const ne_ssl_certificate *cert, char *digest) * it's necessary to cast from a pthread_t to an unsigned long at some * point. */ +#ifndef _WIN32 static pthread_mutex_t *locks; +#else +static HANDLE *locks; +#endif static size_t num_locks; #ifndef HAVE_CRYPTO_SET_IDPTR_CALLBACK /* Named to be obvious when it shows up in a backtrace. */ static unsigned long thread_id_neon(void) { +#ifndef _WIN32 /* This will break if pthread_t is a structure; upgrading OpenSSL * >= 0.9.9 (which does not require this callback) is the only * solution. */ return (unsigned long) pthread_self(); +#else + return (unsigned long) GetCurrentThreadId(); +#endif } #endif @@ -1106,12 +1165,20 @@ static unsigned long thread_id_neon(void) static void thread_lock_neon(int mode, int n, const char *file, int line) { if (mode & CRYPTO_LOCK) { +#ifndef _WIN32 if (pthread_mutex_lock(&locks[n])) { +#else + if (WaitForSingleObject(locks[n], INFINITE)) { +#endif abort(); } } else { +#ifndef _WIN32 if (pthread_mutex_unlock(&locks[n])) { +#else + if (!ReleaseMutex(locks[n])) { +#endif abort(); } } @@ -1160,7 +1227,11 @@ int ne__ssl_init(void) locks = malloc(num_locks * sizeof *locks); for (n = 0; n < num_locks; n++) { +#ifndef _WIN32 if (pthread_mutex_init(&locks[n], NULL)) { +#else + if ((locks[n] = CreateMutex(NULL, FALSE, NULL)) == NULL) { +#endif NE_DEBUG(NE_DBG_SOCKET, "ssl: Failed to initialize pthread mutex.\n"); return -1; } @@ -1193,10 +1264,61 @@ void ne__ssl_exit(void) CRYPTO_set_locking_callback(NULL); for (n = 0; n < num_locks; n++) { +#ifndef _WIN32 pthread_mutex_destroy(&locks[n]); +#else + CloseHandle(locks[n]); +#endif } free(locks); } #endif } + +#ifdef WINSCP + +// see also CAsyncSslSocketLayer::PrintSessionInfo() +const char * ne_ssl_get_version(ne_session *sess) +{ + return SSL_get_version(ne__sock_sslsock(sess->socket)); +} + +char * ne_ssl_get_cipher(ne_session *sess) +{ + SSL * ssl = ne__sock_sslsock(sess->socket); + X509 * cert = SSL_get_peer_certificate(ssl); + const SSL_CIPHER * ciph = SSL_get_current_cipher(ssl); + char * buffer = ne_malloc(4096); + char enc[4096] = {0}; + + if (cert != NULL) + { + EVP_PKEY * pkey = X509_get_pubkey(cert); + if (pkey != NULL) + { + if ((pkey->type == EVP_PKEY_RSA) && (pkey->pkey.rsa != NULL) && + (pkey->pkey.rsa->n != NULL)) + { + ne_snprintf(enc, sizeof(enc), "%d bit RSA", BN_num_bits(pkey->pkey.rsa->n)); + } + else if ((pkey->type == EVP_PKEY_DSA) && (pkey->pkey.dsa != NULL) && + (pkey->pkey.dsa->p != NULL)) + { + ne_snprintf(enc, sizeof(enc), "%d bit DSA", BN_num_bits(pkey->pkey.dsa->p)); + } + EVP_PKEY_free(pkey); + } + X509_free(cert); + } + + ne_snprintf(buffer, 4096, + "%s: %s, %s", + SSL_CIPHER_get_version(ciph), + SSL_CIPHER_get_name(ciph), + enc); + + return buffer; +} + +#endif diff --git a/libs/neon/src/ne_pkcs11.c b/libs/neon/src/ne_pkcs11.c index 69875b69..67893602 100644 --- a/libs/neon/src/ne_pkcs11.c +++ b/libs/neon/src/ne_pkcs11.c @@ -455,6 +455,7 @@ static void pk11_provide(void *userdata, ne_session *sess, const ne_ssl_dname *const *dnames, int dncount) { + NE_DEBUG_WINSCP_CONTEXT(sess); ne_ssl_pkcs11_provider *prov = userdata; ck_slot_id_t *slots; unsigned long scount, n; diff --git a/libs/neon/src/ne_privssl.h b/libs/neon/src/ne_privssl.h index 1a5cabc9..57d53c86 100644 --- a/libs/neon/src/ne_privssl.h +++ b/libs/neon/src/ne_privssl.h @@ -59,7 +59,7 @@ ne__ssl_clicert_exkey_import(const unsigned char *der, #include struct ne_ssl_context_s { - gnutls_certificate_credentials cred; + gnutls_certificate_credentials_t cred; int verify; /* non-zero if client cert verification required */ const char *hostname; /* for SNI */ @@ -67,10 +67,10 @@ struct ne_ssl_context_s { /* Session cache. */ union ne_ssl_scache { struct { - gnutls_datum key, data; + gnutls_datum_t key, data; } server; #if defined(HAVE_GNUTLS_SESSION_GET_DATA2) - gnutls_datum client; + gnutls_datum_t client; #else struct { char *data; @@ -85,7 +85,7 @@ struct ne_ssl_context_s { #endif }; -typedef gnutls_session ne_ssl_socket; +typedef gnutls_session_t ne_ssl_socket; NE_PRIVATE ne_ssl_client_cert * ne__ssl_clicert_exkey_import(const unsigned char *der, size_t der_len); diff --git a/libs/neon/src/ne_props.c b/libs/neon/src/ne_props.c index 81317096..c81b6e6e 100644 --- a/libs/neon/src/ne_props.c +++ b/libs/neon/src/ne_props.c @@ -387,6 +387,7 @@ static int startelm(void *userdata, int parent, const char *nspace, const char *name, const char **atts) { ne_propfind_handler *hdl = userdata; + NE_DEBUG_WINSCP_CONTEXT(hdl->sess); struct propstat *pstat = ne_207_get_current_propstat(hdl->parser207); struct prop *prop; int n; diff --git a/libs/neon/src/ne_request.c b/libs/neon/src/ne_request.c index 9673ebc0..42ec81f8 100644 --- a/libs/neon/src/ne_request.c +++ b/libs/neon/src/ne_request.c @@ -183,6 +183,7 @@ static inline unsigned int hash_and_lower(char *name) static int aborted(ne_request *req, const char *doing, ssize_t code) { ne_session *sess = req->session; + NE_DEBUG_WINSCP_CONTEXT(sess); int ret = NE_ERROR; NE_DEBUG(NE_DBG_HTTP, "Aborted request (%" NE_FMT_SSIZE_T "): %s\n", @@ -357,6 +358,14 @@ static ssize_t body_fd_send(void *userdata, char *buffer, size_t count) ((((code) == NE_SOCK_CLOSED || (code) == NE_SOCK_RESET || \ (code) == NE_SOCK_TRUNC) && retry) ? NE_RETRY : (acode)) +/* For sending chunks, an 8-byte prefix is reserved at the beginning + * of the buffer. This is large enough for a trailing \r\n for the + * previous chunk, the chunk size, and the \r\n following the + * chunk-size. */ +#define CHUNK_OFFSET (8) +#define CHUNK_TERM "\r\n0\r\n\r\n" +#define CHUNK_NULL_TERM "0\r\n\r\n" + /* Sends the request body; returns 0 on success or an NE_* error code. * If retry is non-zero; will return NE_RETRY on persistent connection * timeout. On error, the session error string is set and the @@ -364,13 +373,29 @@ static ssize_t body_fd_send(void *userdata, char *buffer, size_t count) static int send_request_body(ne_request *req, int retry) { ne_session *const sess = req->session; - char buffer[NE_BUFSIZ]; + NE_DEBUG_WINSCP_CONTEXT(sess); + char buffer[NE_BUFSIZ], *start; ssize_t bytes; + size_t buflen; + int chunked = req->body_length < 0, chunknum = 0; + int ret; NE_DEBUG(NE_DBG_HTTP, "Sending request body:\n"); + /* Set up status union and (start, buflen) as the buffer to be + * passed the supplied callback. */ + if (chunked) { + start = buffer + CHUNK_OFFSET; + buflen = sizeof(buffer) - CHUNK_OFFSET; + req->session->status.sr.total = -1; + } + else { + start = buffer; + buflen = sizeof buffer; + req->session->status.sr.total = req->body_length; + } + req->session->status.sr.progress = 0; - req->session->status.sr.total = req->body_length; notify_status(sess, ne_status_sending); /* tell the source to start again from the beginning. */ @@ -379,8 +404,23 @@ static int send_request_body(ne_request *req, int retry) return NE_ERROR; } - while ((bytes = req->body_cb(req->body_ud, buffer, sizeof buffer)) > 0) { - int ret = ne_sock_fullwrite(sess->socket, buffer, bytes); + while ((bytes = req->body_cb(req->body_ud, start, buflen)) > 0) { + req->session->status.sr.progress += bytes; + if (chunked) { + /* Overwrite the buffer prefix with the appropriate chunk + * size; since ne_snprintf always NUL-terminates, the \n + * is omitted and placed over the NUL afterwards. */ + if (chunknum++ == 0) + ne_snprintf(buffer, CHUNK_OFFSET, + "%06x\r", (unsigned)bytes); + else + ne_snprintf(buffer, CHUNK_OFFSET, + "\r\n%04x\r", (unsigned)bytes); + buffer[CHUNK_OFFSET - 1] = '\n'; + bytes += CHUNK_OFFSET; + } + ret = ne_sock_fullwrite(sess->socket, buffer, bytes); + if (ret < 0) { int aret = aborted(req, _("Could not send request body"), ret); return RETRY_RET(retry, ret, aret); @@ -391,18 +431,31 @@ static int send_request_body(ne_request *req, int retry) bytes, (int)bytes, buffer); /* invoke progress callback */ - req->session->status.sr.progress += bytes; notify_status(sess, ne_status_sending); } - if (bytes == 0) { - return NE_OK; - } else { + if (bytes) { NE_DEBUG(NE_DBG_HTTP, "Request body provider failed with " "%" NE_FMT_SSIZE_T "\n", bytes); ne_close_connection(sess); return NE_ERROR; } + + if (chunked) { + if (chunknum == 0) + ret = ne_sock_fullwrite(sess->socket, CHUNK_NULL_TERM, + sizeof(CHUNK_NULL_TERM) - 1); + else + ret = ne_sock_fullwrite(sess->socket, CHUNK_TERM, + sizeof(CHUNK_TERM) - 1); + if (ret < 0) { + int aret = aborted(req, _("Could not send chunked " + "request terminator"), ret); + return RETRY_RET(retry, ret, aret); + } + } + + return NE_OK; } /* Lob the User-Agent, connection and host headers in to the request @@ -410,6 +463,7 @@ static int send_request_body(ne_request *req, int retry) static void add_fixed_headers(ne_request *req) { ne_session *const sess = req->session; + NE_DEBUG_WINSCP_CONTEXT(sess); if (sess->user_agent) { ne_buffer_zappend(req->headers, sess->user_agent); @@ -495,7 +549,12 @@ ne_request *ne_request_create(ne_session *sess, static void set_body_length(ne_request *req, ne_off_t length) { req->body_length = length; - ne_print_request_header(req, "Content-Length", "%" FMT_NE_OFF_T, length); + + if (length >= 0) + ne_print_request_header(req, "Content-Length", "%" FMT_NE_OFF_T, length); + else /* length < 0 => chunked body */ + ne_add_request_header(req, "Transfer-Encoding", "chunked"); + } void ne_set_request_body_buffer(ne_request *req, const char *buffer, @@ -527,16 +586,50 @@ void ne_set_request_body_fd(ne_request *req, int fd, set_body_length(req, length); } +#ifdef WINSCP + +#include + +void ne_set_request_body_provider_proxy(ne_request *req, + ne_provide_body provider, void * ud, + ne_provide_body * prev_provider, void ** prev_ud) +{ + if ((req->body_cb != provider) || + (req->body_ud != ud)) + { + assert(*prev_provider == NULL); + assert(*prev_ud == NULL); + *prev_provider = req->body_cb; + *prev_ud = req->body_ud; + req->body_cb = provider; + req->body_ud = ud; + } +} + +int ne_get_request_body_buffer(ne_request *req, const char **buffer, + size_t * size) +{ + int result = (req->body_cb == body_string_send); + if (result != 0) + { + *buffer = req->body.buf.buffer; + *size = req->body.buf.length; + } + return result; +} + +#endif + void ne_set_request_flag(ne_request *req, ne_request_flag flag, int value) { - if (flag < NE_SESSFLAG_LAST) { + if (flag < (ne_request_flag)NE_SESSFLAG_LAST) { req->flags[flag] = value; } } int ne_get_request_flag(ne_request *req, ne_request_flag flag) { - if (flag < NE_REQFLAG_LAST) { + if (flag < (ne_request_flag)NE_REQFLAG_LAST) { return req->flags[flag]; } return -1; @@ -664,6 +757,7 @@ void ne_add_response_body_reader(ne_request *req, ne_accept_response acpt, void ne_request_destroy(ne_request *req) { + NE_DEBUG_WINSCP_CONTEXT(req->session); struct body_reader *rdr, *next_rdr; struct hook *hk, *next_hk; @@ -679,7 +773,7 @@ void ne_request_destroy(ne_request *req) ne_buffer_destroy(req->headers); - NE_DEBUG(NE_DBG_HTTP, "Running destroy hooks.\n"); + NE_DEBUG(NE_DBG_WINSCP_HTTP_DETAIL, "Running destroy hooks.\n"); for (hk = req->session->destroy_req_hooks; hk; hk = next_hk) { ne_destroy_req_fn fn = (ne_destroy_req_fn)hk->fn; next_hk = hk->next; @@ -708,6 +802,7 @@ void ne_request_destroy(ne_request *req) static int read_response_block(ne_request *req, struct ne_response *resp, char *buffer, size_t *buflen) { + NE_DEBUG_WINSCP_CONTEXT(req->session); ne_socket *const sock = req->session->socket; size_t willread; ssize_t readlen; @@ -726,7 +821,7 @@ static int read_response_block(ne_request *req, struct ne_response *resp, SOCK_ERR(req, ne_sock_readline(sock, req->respbuf, sizeof req->respbuf), _("Could not read chunk size")); - NE_DEBUG(NE_DBG_HTTP, "[chunk] < %s", req->respbuf); + NE_DEBUG(NE_DBG_WINSCP_HTTP_DETAIL, "[chunk] < %s", req->respbuf); chunk_len = strtoul(req->respbuf, &ptr, 16); /* limit chunk size to <= UINT_MAX, so it will probably * fit in a size_t. */ @@ -734,7 +829,7 @@ static int read_response_block(ne_request *req, struct ne_response *resp, chunk_len == ULONG_MAX || chunk_len > UINT_MAX) { return aborted(req, _("Could not parse chunk size"), 0); } - NE_DEBUG(NE_DBG_HTTP, "Got chunk size: %lu\n", chunk_len); + NE_DEBUG(NE_DBG_WINSCP_HTTP_DETAIL, "Got chunk size: %lu\n", chunk_len); resp->body.chunk.remain = chunk_len; } willread = resp->body.chunk.remain > *buflen @@ -756,7 +851,7 @@ static int read_response_block(ne_request *req, struct ne_response *resp, *buflen = 0; return 0; } - NE_DEBUG(NE_DBG_HTTP, + NE_DEBUG(NE_DBG_WINSCP_HTTP_DETAIL, "Reading %" NE_FMT_SIZE_T " bytes of response body.\n", willread); readlen = ne_sock_read(sock, buffer, willread); @@ -765,13 +860,13 @@ static int read_response_block(ne_request *req, struct ne_response *resp, * any case, but SSL servers are just too buggy. */ if (resp->mode == R_TILLEOF && (readlen == NE_SOCK_CLOSED || readlen == NE_SOCK_TRUNC)) { - NE_DEBUG(NE_DBG_HTTP, "Got EOF.\n"); + NE_DEBUG(NE_DBG_WINSCP_HTTP_DETAIL, "Got EOF.\n"); req->can_persist = 0; readlen = 0; } else if (readlen < 0) { return aborted(req, _("Could not read response body"), readlen); } else { - NE_DEBUG(NE_DBG_HTTP, "Got %" NE_FMT_SSIZE_T " bytes.\n", readlen); + NE_DEBUG(NE_DBG_WINSCP_HTTP_DETAIL, "Got %" NE_FMT_SSIZE_T " bytes.\n", readlen); } /* safe to cast: readlen guaranteed to be >= 0 above */ *buflen = (size_t)readlen; @@ -824,6 +919,7 @@ ssize_t ne_read_response_block(ne_request *req, char *buffer, size_t buflen) /* Build the request string, returning the buffer. */ static ne_buffer *build_request(ne_request *req) { + NE_DEBUG_WINSCP_CONTEXT(req->session); struct hook *hk; ne_buffer *buf = ne_buffer_create(); @@ -837,7 +933,7 @@ static ne_buffer *build_request(ne_request *req) ne_buffer_czappend(buf, "Expect: 100-continue\r\n"); } - NE_DEBUG(NE_DBG_HTTP, "Running pre_send hooks\n"); + NE_DEBUG(NE_DBG_WINSCP_HTTP_DETAIL, "Running pre_send hooks\n"); for (hk = req->session->pre_send_hooks; hk!=NULL; hk = hk->next) { ne_pre_send_fn fn = (ne_pre_send_fn)hk->fn; fn(req, hk->userdata, buf); @@ -848,11 +944,18 @@ static ne_buffer *build_request(ne_request *req) } #ifdef NE_DEBUGGING +#ifdef WINSCP +#define DEBUG_DUMP_REQUEST(x) dump_request(req, x) + +static void dump_request(ne_request *req, const char *request) +#else #define DEBUG_DUMP_REQUEST(x) dump_request(x) static void dump_request(const char *request) -{ - if (ne_debug_mask & NE_DBG_HTTPPLAIN) { +#endif +{ + NE_DEBUG_WINSCP_CONTEXT(req->session); + if (ne_debug_mask & NE_DBG_HTTPPLAIN) { /* Display everything mode */ NE_DEBUG(NE_DBG_HTTP, "Sending request headers:\n%s", request); } else if (ne_debug_mask & NE_DBG_HTTP) { @@ -888,6 +991,7 @@ static inline void strip_eol(char *buf, ssize_t *len) * if an NE_RETRY should be returned if an EOF is received. */ static int read_status_line(ne_request *req, ne_status *status, int retry) { + NE_DEBUG_WINSCP_CONTEXT(req->session); char *buffer = req->respbuf; ssize_t ret; @@ -924,6 +1028,7 @@ static int read_status_line(ne_request *req, ne_status *status, int retry) /* Discard a set of message headers. */ static int discard_headers(ne_request *req) { + NE_DEBUG_WINSCP_CONTEXT(req->session); do { SOCK_ERR(req, ne_sock_readline(req->session->socket, req->respbuf, sizeof req->respbuf), @@ -944,6 +1049,7 @@ static int discard_headers(ne_request *req) static int send_request(ne_request *req, const ne_buffer *request) { ne_session *const sess = req->session; + NE_DEBUG_WINSCP_CONTEXT(sess); ne_status *const status = &req->status; int sentbody = 0; /* zero until body has been sent. */ int ret, retry; /* retry non-zero whilst the request should be retried */ @@ -965,7 +1071,7 @@ static int send_request(ne_request *req, const ne_buffer *request) return RETRY_RET(retry, sret, aret); } - if (!req->flags[NE_REQFLAG_EXPECT100] && req->body_length > 0) { + if (!req->flags[NE_REQFLAG_EXPECT100] && req->body_length) { /* Send request body, if not using 100-continue. */ ret = send_request_body(req, retry); if (ret) { @@ -985,7 +1091,7 @@ static int send_request(ne_request *req, const ne_buffer *request) if ((ret = discard_headers(req)) != NE_OK) break; if (req->flags[NE_REQFLAG_EXPECT100] && (status->code == 100) - && req->body_length > 0 && !sentbody) { + && req->body_length && !sentbody) { /* Send the body after receiving the first 100 Continue */ if ((ret = send_request_body(req, 0)) != NE_OK) break; sentbody = 1; @@ -1004,13 +1110,14 @@ static int send_request(ne_request *req, const ne_buffer *request) */ static int read_message_header(ne_request *req, char *buf, size_t buflen) { + NE_DEBUG_WINSCP_CONTEXT(req->session); ssize_t n; ne_socket *sock = req->session->socket; n = ne_sock_readline(sock, buf, buflen); if (n <= 0) return aborted(req, _("Error reading response headers"), n); - NE_DEBUG(NE_DBG_HTTP, "[hdr] %s", buf); + NE_DEBUG(NE_DBG_WINSCP_HTTP_DETAIL, "[hdr] %s", buf); strip_eol(buf, &n); @@ -1040,7 +1147,7 @@ static int read_message_header(ne_request *req, char *buf, size_t buflen) return aborted(req, _("Error reading response headers"), n); } - NE_DEBUG(NE_DBG_HTTP, "[cont] %s", buf); + NE_DEBUG(NE_DBG_WINSCP_HTTP_DETAIL, "[cont] %s", buf); strip_eol(buf, &n); @@ -1095,6 +1202,7 @@ static void add_response_header(ne_request *req, unsigned int hash, * closes connection on error. */ static int read_response_headers(ne_request *req) { + NE_DEBUG_WINSCP_CONTEXT(req->session); char hdr[MAX_HEADER_LEN]; int ret, count = 0; @@ -1146,6 +1254,7 @@ static int read_response_headers(ne_request *req) * returns NE_ code with error string set on error. */ static int lookup_host(ne_session *sess, struct host_info *info) { + NE_DEBUG_WINSCP_CONTEXT(sess); NE_DEBUG(NE_DBG_HTTP, "Doing DNS lookup on %s...\n", info->hostname); sess->status.lu.hostname = info->hostname; notify_status(sess, ne_status_lookup); @@ -1165,6 +1274,7 @@ static int lookup_host(ne_session *sess, struct host_info *info) int ne_begin_request(ne_request *req) { + NE_DEBUG_WINSCP_CONTEXT(req->session); struct body_reader *rdr; ne_buffer *data; const ne_status *const st = &req->status; @@ -1302,7 +1412,7 @@ int ne_begin_request(ne_request *req) req->resp.mode = R_TILLEOF; /* otherwise: read-till-eof mode */ } - NE_DEBUG(NE_DBG_HTTP, "Running post_headers hooks\n"); + NE_DEBUG(NE_DBG_WINSCP_HTTP_DETAIL, "Running post_headers hooks\n"); for (hk = req->session->post_headers_hooks; hk != NULL; hk = hk->next) { ne_post_headers_fn fn = (ne_post_headers_fn)hk->fn; fn(req, hk->userdata, &req->status); @@ -1325,6 +1435,7 @@ int ne_begin_request(ne_request *req) int ne_end_request(ne_request *req) { + NE_DEBUG_WINSCP_CONTEXT(req->session); struct hook *hk; int ret; @@ -1336,7 +1447,7 @@ int ne_end_request(ne_request *req) ret = NE_OK; } - NE_DEBUG(NE_DBG_HTTP, "Running post_send hooks\n"); + NE_DEBUG(NE_DBG_WINSCP_HTTP_DETAIL, "Running post_send hooks\n"); for (hk = req->session->post_send_hooks; ret == NE_OK && hk != NULL; hk = hk->next) { ne_post_send_fn fn = (ne_post_send_fn)hk->fn; @@ -1394,6 +1505,7 @@ int ne_discard_response(ne_request *req) int ne_request_dispatch(ne_request *req) { + NE_DEBUG_WINSCP_CONTEXT(req->session); int ret; do { @@ -1472,6 +1584,7 @@ static const ne_inet_addr *resolve_next(struct host_info *host) * connect. */ static int do_connect(ne_session *sess, struct host_info *host) { + NE_DEBUG_WINSCP_CONTEXT(sess); int ret; /* Resolve hostname if necessary. */ diff --git a/libs/neon/src/ne_request.h b/libs/neon/src/ne_request.h index bfe5cdce..22457f95 100644 --- a/libs/neon/src/ne_request.h +++ b/libs/neon/src/ne_request.h @@ -78,9 +78,20 @@ typedef ssize_t (*ne_provide_body)(void *userdata, /* Install a callback which is invoked as needed to provide the * request body, a block at a time. The total size of the request * body is 'length'; the callback must ensure that it returns no more - * than 'length' bytes in total. */ + * than 'length' bytes in total. If 'length' is set to -1, then the + * total size of the request is unknown by the caller and chunked + * tranfer will be used. */ void ne_set_request_body_provider(ne_request *req, ne_off_t length, - ne_provide_body provider, void *userdata); + ne_provide_body provider, void *userdata); + +#ifdef WINSCP +void ne_set_request_body_provider_proxy(ne_request *req, + ne_provide_body provider, void * ud, + ne_provide_body * prev_provider, void ** prev_ud); + +int ne_get_request_body_buffer(ne_request *req, const char **buffer, + size_t * size); +#endif /* Handling response bodies; two callbacks must be provided: * diff --git a/libs/neon/src/ne_session.c b/libs/neon/src/ne_session.c index d9a8ed3c..92a4a3d4 100644 --- a/libs/neon/src/ne_session.c +++ b/libs/neon/src/ne_session.c @@ -74,11 +74,13 @@ static void free_proxies(ne_session *sess) ne_free(hi); } + sess->proxies = NULL; sess->any_proxy_http = 0; } void ne_session_destroy(ne_session *sess) { + NE_DEBUG_WINSCP_CONTEXT(sess); struct hook *hk; NE_DEBUG(NE_DBG_HTTP, "sess: Destroying session.\n"); @@ -232,6 +234,7 @@ void ne_session_socks_proxy(ne_session *sess, enum ne_sock_sversion vers, void ne_session_system_proxy(ne_session *sess, unsigned int flags) { + NE_DEBUG_WINSCP_CONTEXT(sess); #ifdef HAVE_LIBPROXY pxProxyFactory *pxf = px_proxy_factory_new(); struct host_info *hi, **lasthi; @@ -320,7 +323,8 @@ void ne_session_system_proxy(ne_session *sess, unsigned int flags) #endif } -void ne_set_addrlist(ne_session *sess, const ne_inet_addr **addrs, size_t n) +void ne_set_addrlist2(ne_session *sess, unsigned int port, + const ne_inet_addr **addrs, size_t n) { struct host_info *hi, **lasthi; size_t i; @@ -334,12 +338,17 @@ void ne_set_addrlist(ne_session *sess, const ne_inet_addr **addrs, size_t n) hi->proxy = PROXY_NONE; hi->network = addrs[i]; - hi->port = sess->server.port; + hi->port = port; lasthi = &hi->next; } } +void ne_set_addrlist(ne_session *sess, const ne_inet_addr **addrs, size_t n) +{ + ne_set_addrlist2(sess, sess->server.port, addrs, n); +} + void ne_set_localaddr(ne_session *sess, const ne_inet_addr *addr) { sess->local_addr = addr; @@ -361,6 +370,7 @@ void ne_set_session_flag(ne_session *sess, ne_session_flag flag, int value) #ifdef NE_HAVE_SSL if (flag == NE_SESSFLAG_SSLv2 && sess->ssl_context) { ne_ssl_context_set_flag(sess->ssl_context, NE_SSL_CTX_SSLv2, value); + sess->flags[flag] = ne_ssl_context_get_flag(sess->ssl_context, NE_SSL_CTX_SSLv2); } #endif } @@ -464,6 +474,7 @@ const char *ne_get_error(ne_session *sess) void ne_close_connection(ne_session *sess) { + NE_DEBUG_WINSCP_CONTEXT(sess); if (sess->connected) { struct hook *hk; diff --git a/libs/neon/src/ne_session.h b/libs/neon/src/ne_session.h index ea80089d..ce9605c9 100644 --- a/libs/neon/src/ne_session.h +++ b/libs/neon/src/ne_session.h @@ -46,10 +46,9 @@ void ne_session_destroy(ne_session *sess); * session. */ void ne_close_connection(ne_session *sess); -/* Set the proxy server to be used for the session. This function - * will override (remove) any proxy servers previously configured, and - * must be called before any requests are created using this - * session. */ +/* Configure an HTTP proxy server for the session. This function will + * override (remove) any proxy servers previously configured, and must + * be called before any requests are created using this session. */ void ne_session_proxy(ne_session *sess, const char *hostname, unsigned int port); @@ -119,6 +118,16 @@ int ne_get_session_flag(ne_session *sess, ne_session_flag flag); * created using this session. */ void ne_set_addrlist(ne_session *sess, const ne_inet_addr **addrs, size_t n); +/* Bypass the normal name resolution; force the use of specific set of + * addresses for this session, addrs[0]...addrs[n-1]. The 'addrs' + * array and pointed-to objects must remain valid until the session is + * destroyed. This function will override (remove) any proxy servers + * previously configured, and must be called before any requests are + * created using this session. Port number 'port' will be used + * instead of the "real" session port, to connect to the proxy. */ +void ne_set_addrlist2(ne_session *sess, unsigned int port, + const ne_inet_addr **addrs, size_t n); + /* Bind connections to the specified local address. If the address * determined for the remote host has a different family (type) to * 'addr', 'addr' will be ignored. The 'addr' object must remain @@ -285,6 +294,13 @@ typedef void (*ne_ssl_provide_fn)(void *userdata, ne_session *sess, void ne_ssl_provide_clicert(ne_session *sess, ne_ssl_provide_fn fn, void *userdata); +#ifdef WINSCP +const char * ne_ssl_get_version(ne_session *sess); +char * ne_ssl_get_cipher(ne_session *sess); +struct ssl_st; +void ne_init_ssl_session(struct ssl_st *ssl, ne_session *sess); +#endif + /* Set the timeout (in seconds) used when reading from a socket. The * timeout value must be greater than zero. */ void ne_set_read_timeout(ne_session *sess, int timeout); diff --git a/libs/neon/src/ne_socket.c b/libs/neon/src/ne_socket.c index c946327c..a2e51ed1 100644 --- a/libs/neon/src/ne_socket.c +++ b/libs/neon/src/ne_socket.c @@ -1,6 +1,6 @@ /* Socket handling routines - Copyright (C) 1998-2009, Joe Orton + Copyright (C) 1998-2011, Joe Orton Copyright (C) 2004 Aleix Conchillo Flaque This library is free software; you can redistribute it and/or @@ -27,6 +27,9 @@ #include "config.h" #include +#ifdef HAVE_SYS_UIO_h +#include /* writev(2) */ +#endif #ifdef HAVE_SYS_TIME_H #include #endif @@ -227,6 +230,7 @@ struct ne_sock_addr_s { #else struct in_addr *addrs; size_t cursor, count; + char *name; #endif int errnum; }; @@ -392,12 +396,13 @@ static int raw_poll(int fdno, int rdwr, int secs) ret = poll(&fds, 1, timeout); } while (ret < 0 && NE_ISINTR(ne_errno)); #else - fd_set rdfds, wrfds; + fd_set rdfds, wrfds, exfds; struct timeval timeout, *tvp = (secs >= 0 ? &timeout : NULL); /* Init the fd set */ FD_ZERO(&rdfds); FD_ZERO(&wrfds); + FD_ZERO(&exfds); /* Note that (amazingly) the FD_SET macro does not expand * correctly on Netware if not inside a compound statement @@ -407,13 +412,14 @@ static int raw_poll(int fdno, int rdwr, int secs) } else { FD_SET(fdno, &wrfds); } + FD_SET(fdno, &exfds); if (tvp) { tvp->tv_sec = secs; tvp->tv_usec = 0; } do { - ret = select(fdno + 1, &rdfds, &wrfds, NULL, tvp); + ret = select(fdno + 1, &rdfds, &wrfds, &exfds, tvp); } while (ret < 0 && NE_ISINTR(ne_errno)); #endif return ret; @@ -721,9 +727,11 @@ static ssize_t error_gnutls(ne_socket *sock, ssize_t sret) _("SSL alert received: %s"), gnutls_alert_get_name(gnutls_alert_get(sock->ssl))); break; +#if GNUTLS_VERSION_MAJOR > 2 || (GNUTLS_VERSION_MAJOR == 2 && GNUTLS_VERSION_MINOR >= 99) + case GNUTLS_E_PREMATURE_TERMINATION: +#else case GNUTLS_E_UNEXPECTED_PACKET_LENGTH: - /* It's not exactly an API guarantee but this error will - * always mean a premature EOF. */ +#endif ret = NE_SOCK_TRUNC; set_error(sock, _("Secure connection truncated")); break; @@ -910,12 +918,16 @@ ne_sock_addr *ne_addr_resolve(const char *hostname, int flags) hints.ai_socktype = SOCK_STREAM; + if (flags & NE_ADDR_CANON) { + hints.ai_flags = AI_CANONNAME; + } + #ifdef AF_INET6 if (hostname[0] == '[' && ((pnt = strchr(hostname, ']')) != NULL)) { char *hn = ne_strdup(hostname + 1); hn[pnt - hostname - 1] = '\0'; #ifdef AI_NUMERICHOST /* added in the RFC2553 API */ - hints.ai_flags = AI_NUMERICHOST; + hints.ai_flags |= AI_NUMERICHOST; #endif hints.ai_family = AF_INET6; addr->errnum = getaddrinfo(hn, NULL, &hints, &addr->result); @@ -924,7 +936,7 @@ ne_sock_addr *ne_addr_resolve(const char *hostname, int flags) #endif /* AF_INET6 */ { #ifdef USE_GAI_ADDRCONFIG /* added in the RFC3493 API */ - hints.ai_flags = AI_ADDRCONFIG; + hints.ai_flags |= AI_ADDRCONFIG; hints.ai_family = AF_UNSPEC; addr->errnum = getaddrinfo(hostname, NULL, &hints, &addr->result); #else @@ -959,6 +971,9 @@ ne_sock_addr *ne_addr_resolve(const char *hostname, int flags) for (n = 0; n < addr->count; n++) memcpy(&addr->addrs[n], hp->h_addr_list[n], hp->h_length); + + if (hp->h_name && hp->h_name[0]) + addr->name = ne_strdup(hp->h_name); } } else { addr->addrs = ne_malloc(sizeof *addr->addrs); @@ -974,6 +989,15 @@ int ne_addr_result(const ne_sock_addr *addr) return addr->errnum; } +const char *ne_addr_canonical(const ne_sock_addr *addr) +{ +#ifdef USE_GETADDRINFO + return addr->result ? addr->result->ai_canonname : NULL; +#else + return addr->name; +#endif +} + const ne_inet_addr *ne_addr_first(ne_sock_addr *addr) { #ifdef USE_GETADDRINFO @@ -1135,7 +1159,9 @@ int ne_iaddr_reverse(const ne_inet_addr *ia, char *buf, size_t bufsiz) #else struct hostent *hp; - hp = gethostbyaddr(ia, sizeof *ia, AF_INET); + /* Cast to const void *; some old libc headers apparently expect + * const char * here. */ + hp = gethostbyaddr((const void *)ia, sizeof *ia, AF_INET); if (hp && hp->h_name) { ne_strnzcpy(buf, hp->h_name, bufsiz); return 0; @@ -1152,6 +1178,8 @@ void ne_addr_destroy(ne_sock_addr *addr) #else if (addr->addrs) ne_free(addr->addrs); + if (addr->name) + ne_free(addr->name); #endif ne_free(addr); } @@ -1230,18 +1258,18 @@ static int timed_connect(ne_socket *sock, int fd, } } - /* Reset to old flags: */ - if (fcntl(fd, F_SETFL, flags) == -1) { + /* Reset to old flags; fail on error if no previous error. */ + if (fcntl(fd, F_SETFL, flags) == -1 && !ret) { set_strerror(sock, errno); ret = NE_SOCK_ERROR; - } + } } else #endif /* USE_NONBLOCKING_CONNECT */ { ret = raw_connect(fd, sa, salen); if (ret < 0) { - set_strerror(sock, errno); + set_strerror(sock, ne_errno); ret = NE_SOCK_ERROR; } } @@ -1366,7 +1394,9 @@ static int do_bind(int fd, int peer_family, #ifdef SOCK_CLOEXEC /* sock_cloexec is initialized to SOCK_CLOEXEC and cleared to zero if - * a socket() call ever fails with EINVAL. */ + * a socket() call ever fails with EINVAL; not strictly thread-safe + * but in practice it will not matter if two threads race accessing + * the variable. */ static int sock_cloexec = SOCK_CLOEXEC; #define RETRY_ON_EINVAL #else @@ -1428,7 +1458,7 @@ int ne_sock_connect(ne_socket *sock, ia_family(sock->laddr) == ia_family(addr))) { ret = do_bind(fd, ia_family(addr), sock->laddr, sock->lport); if (ret < 0) { - int errnum = errno; + int errnum = ne_errno; ne_close(fd); set_strerror(sock, errnum); return NE_SOCK_ERROR; @@ -1579,8 +1609,10 @@ int ne_sock_accept(ne_socket *sock, int listener) { int fd = accept(listener, NULL, NULL); - if (fd < 0) + if (fd < 0) { + set_strerror(sock, ne_errno); return -1; + } sock->fd = fd; return 0; @@ -1608,14 +1640,14 @@ void ne_sock_connect_timeout(ne_socket *sock, int timeout) * session. */ /* Copy datum 'src' to 'dest'. */ -static void copy_datum(gnutls_datum *dest, gnutls_datum *src) +static void copy_datum(gnutls_datum_t *dest, gnutls_datum_t *src) { dest->size = src->size; dest->data = memcpy(gnutls_malloc(src->size), src->data, src->size); } /* Callback to store a session 'data' with id 'key'. */ -static int store_sess(void *userdata, gnutls_datum key, gnutls_datum data) +static int store_sess(void *userdata, gnutls_datum_t key, gnutls_datum_t data) { ne_ssl_context *ctx = userdata; @@ -1631,17 +1663,17 @@ static int store_sess(void *userdata, gnutls_datum key, gnutls_datum data) } /* Returns non-zero if d1 and d2 are the same datum. */ -static int match_datum(gnutls_datum *d1, gnutls_datum *d2) +static int match_datum(gnutls_datum_t *d1, gnutls_datum_t *d2) { return d1->size == d2->size && memcmp(d1->data, d2->data, d1->size) == 0; } /* Callback to retrieve a session of id 'key'. */ -static gnutls_datum retrieve_sess(void *userdata, gnutls_datum key) +static gnutls_datum_t retrieve_sess(void *userdata, gnutls_datum_t key) { ne_ssl_context *ctx = userdata; - gnutls_datum ret = { NULL, 0 }; + gnutls_datum_t ret = { NULL, 0 }; if (match_datum(&ctx->cache.server.key, &key)) { copy_datum(&ret, &ctx->cache.server.data); @@ -1652,7 +1684,7 @@ static gnutls_datum retrieve_sess(void *userdata, gnutls_datum key) /* Callback to remove a session of id 'key'; stub needed but * implementation seems unnecessary. */ -static int remove_sess(void *userdata, gnutls_datum key) +static int remove_sess(void *userdata, gnutls_datum_t key) { return -1; } @@ -1678,6 +1710,8 @@ int ne_sock_accept_ssl(ne_socket *sock, ne_ssl_context *ctx) NE_DEBUG(NE_DBG_SSL, "ssl: Server reused session.\n"); } #elif defined(HAVE_GNUTLS) + unsigned int verify_status; + gnutls_init(&ssl, GNUTLS_SERVER); gnutls_credentials_set(ssl, GNUTLS_CRD_CERTIFICATE, ctx->cred); gnutls_set_default_priority(ssl); @@ -1689,15 +1723,15 @@ int ne_sock_accept_ssl(ne_socket *sock, ne_ssl_context *ctx) gnutls_db_set_ptr(ssl, ctx); if (ctx->verify) - gnutls_certificate_server_set_request(ssl, GNUTLS_CERT_REQUEST); + gnutls_certificate_server_set_request(ssl, GNUTLS_CERT_REQUIRE); sock->ssl = ssl; - gnutls_transport_set_ptr(sock->ssl, (gnutls_transport_ptr)(long)sock->fd); + gnutls_transport_set_ptr(sock->ssl, (gnutls_transport_ptr_t)(long)sock->fd); ret = gnutls_handshake(ssl); if (ret < 0) { return error_gnutls(sock, ret); } - if (ctx->verify && gnutls_certificate_verify_peers(ssl)) { + if (ctx->verify && (gnutls_certificate_verify_peers2(ssl, &verify_status) || verify_status)) { set_error(sock, _("Client certificate verification failed")); return NE_SOCK_ERROR; } @@ -1718,13 +1752,6 @@ int ne_sock_connect_ssl(ne_socket *sock, ne_ssl_context *ctx, void *userdata) return NE_SOCK_ERROR; } - /* If runtime library version differs from compile-time version - * number in major/minor/fix level, abort soon. */ - if ((SSLeay() ^ OPENSSL_VERSION_NUMBER) & 0xFFFFF000) { - set_error(sock, _("SSL disabled due to library version mismatch")); - return NE_SOCK_ERROR; - } - sock->ssl = ssl = SSL_new(ctx->ctx); if (!ssl) { set_error(sock, _("Could not create SSL structure")); @@ -1750,6 +1777,10 @@ int ne_sock_connect_ssl(ne_socket *sock, ne_ssl_context *ctx, void *userdata) if (ctx->sess) SSL_set_session(ssl, ctx->sess); +#ifdef WINSCP + ne_init_ssl_session(ssl, userdata); +#endif + ret = SSL_connect(ssl); if (ret != 1) { error_ossl(sock, ret); @@ -1774,7 +1805,7 @@ int ne_sock_connect_ssl(ne_socket *sock, ne_ssl_context *ctx, void *userdata) strlen(ctx->hostname)); } - gnutls_transport_set_ptr(sock->ssl, (gnutls_transport_ptr)(long)sock->fd); + gnutls_transport_set_ptr(sock->ssl, (gnutls_transport_ptr_t)(long)sock->fd); if (ctx->cache.client.data) { #if defined(HAVE_GNUTLS_SESSION_GET_DATA2) diff --git a/libs/neon/src/ne_socket.h b/libs/neon/src/ne_socket.h index e02e86c7..22b203d7 100644 --- a/libs/neon/src/ne_socket.h +++ b/libs/neon/src/ne_socket.h @@ -62,9 +62,11 @@ int ne_sock_init(void); * times to ne_sock_init() for the process. */ void ne_sock_exit(void); -/* Resolve the given hostname. 'flags' must be zero. Hex - * string IPv6 addresses (e.g. `::1') may be enclosed in brackets - * (e.g. `[::1]'). */ +#define NE_ADDR_CANON (0x01) +/* Resolve the given hostname. Hex string IPv6 addresses (e.g. `::1') + * may be enclosed in brackets (e.g. `[::1]'). 'flags' should be + * zero, or if NE_ADDR_CANON is passed, the canonical name for the + * hostname will be determind. */ ne_sock_addr *ne_addr_resolve(const char *hostname, int flags); /* Returns zero if name resolution was successful, non-zero on @@ -88,6 +90,11 @@ const ne_inet_addr *ne_addr_next(ne_sock_addr *addr); * which is of size 'bufsiz'. 'buffer' is returned. */ char *ne_addr_error(const ne_sock_addr *addr, char *buffer, size_t bufsiz); +/* Returns the canonical name of the host as a NUL-terminated string, + * if NE_ADDR_CANON was used, and name resolution was successful. + * Otherwise, returns NULL. */ +const char *ne_addr_canonical(const ne_sock_addr *addr); + /* Destroys an address object created by ne_addr_resolve. */ void ne_addr_destroy(ne_sock_addr *addr); diff --git a/libs/neon/src/ne_ssl.h b/libs/neon/src/ne_ssl.h index cf9bbf54..685b2c92 100644 --- a/libs/neon/src/ne_ssl.h +++ b/libs/neon/src/ne_ssl.h @@ -121,12 +121,20 @@ void ne_ssl_cert_free(ne_ssl_certificate *cert); * "decrypted" state. */ typedef struct ne_ssl_client_cert_s ne_ssl_client_cert; -/* Read a client certificate and private key from a PKCS12 file; - * returns NULL if the file could not be parsed, or otherwise - * returning a client certificate object. The returned object may be - * in either the encrypted or decrypted state. */ +/* Read a client certificate (and private key) in PKCS#12 format from + * file 'filename'; returns NULL if the file could not be parsed, or + * otherwise returning a client certificate object. The returned + * object may be in either the encrypted or decrypted state. */ ne_ssl_client_cert *ne_ssl_clicert_read(const char *filename); +/* Read a client certificate (and private key) in PKCS#12 format from + * 'buffer', of length 'buflen', returning NULL if the certificate + * could not be parsed, or otherwise returning a client certificate + * object. The returned object may be in either the encrypted or + * decrypted state. */ +ne_ssl_client_cert *ne_ssl_clicert_import(const unsigned char *buffer, + size_t buflen); + /* Returns non-zero if client cert is in the encrypted state. */ int ne_ssl_clicert_encrypted(const ne_ssl_client_cert *ccert); @@ -182,6 +190,9 @@ int ne_ssl_context_set_verify(ne_ssl_context *ctx, int required, /* Set a flag for the SSL context. */ void ne_ssl_context_set_flag(ne_ssl_context *ctx, int flag, int value); +/* Return flag value. */ +int ne_ssl_context_get_flag(ne_ssl_context *ctx, int flag); + /* Destroy an SSL context. */ void ne_ssl_context_destroy(ne_ssl_context *ctx); diff --git a/libs/neon/src/ne_sspi.c b/libs/neon/src/ne_sspi.c index 4b59cdc8..9b40df77 100644 --- a/libs/neon/src/ne_sspi.c +++ b/libs/neon/src/ne_sspi.c @@ -337,34 +337,24 @@ static int freeBuffer(SecBufferDesc * secBufferDesc) */ static char *canonical_hostname(const char *serverName) { - char *hostname; - ne_sock_addr *addresses; + const char *hostname; + ne_sock_addr *addr; - /* DNS resolution. It would be useful to be able to use the - * AI_CANONNAME flag where getaddrinfo() is available, but the - * reverse-lookup is sufficient and simpler. */ - addresses = ne_addr_resolve(serverName, 0); - if (ne_addr_result(addresses)) { + addr = ne_addr_resolve(serverName, NE_ADDR_CANON); + if (ne_addr_result(addr) || ne_addr_canonical(addr) == NULL) { /* Lookup failed */ char buf[256]; NE_DEBUG(NE_DBG_HTTPAUTH, "sspi: Could not resolve IP address for `%s': %s\n", - serverName, ne_addr_error(addresses, buf, sizeof buf)); + serverName, ne_addr_error(addr, buf, sizeof buf)); hostname = ne_strdup(serverName); - } else { - char hostbuffer[256]; - const ne_inet_addr *address = ne_addr_first(addresses); - - if (ne_iaddr_reverse(address, hostbuffer, sizeof hostbuffer) == 0) { - hostname = ne_strdup(hostbuffer); - } else { - NE_DEBUG(NE_DBG_HTTPAUTH, "sspi: Could not resolve host name" - "from IP address for `%s'\n", serverName); - hostname = ne_strdup(serverName); - } } + else { + hostname = ne_strdup(ne_addr_canonical(addr)); + } + + ne_addr_destroy(addr); - ne_addr_destroy(addresses); return hostname; } @@ -477,6 +467,7 @@ int ne_sspi_clear_context(void *context) return status; } sspiContext->authfinished = 0; + sspiContext->continueNeeded = 0; return 0; } /* diff --git a/libs/neon/src/ne_stubssl.c b/libs/neon/src/ne_stubssl.c deleted file mode 100644 index 77f90558..00000000 --- a/libs/neon/src/ne_stubssl.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - Stubs for SSL support when no SSL library has been configured - Copyright (C) 2002-2006, Joe Orton - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA - -*/ - -#include "config.h" - -#include /* for NULL */ - -#include "ne_ssl.h" -#include "ne_session.h" - -char *ne_ssl_readable_dname(const ne_ssl_dname *dn) -{ - return NULL; -} - -ne_ssl_certificate *ne_ssl_cert_read(const char *filename) -{ - return NULL; -} - -int ne_ssl_cert_cmp(const ne_ssl_certificate *c1, const ne_ssl_certificate *c2) -{ - return 1; -} - -const ne_ssl_certificate *ne_ssl_cert_signedby(const ne_ssl_certificate *cert) -{ - return NULL; -} - -const ne_ssl_dname *ne_ssl_cert_issuer(const ne_ssl_certificate *cert) -{ - return NULL; -} - -const ne_ssl_dname *ne_ssl_cert_subject(const ne_ssl_certificate *cert) -{ - return NULL; -} - -void ne_ssl_cert_free(ne_ssl_certificate *cert) {} - -ne_ssl_client_cert *ne_ssl_clicert_read(const char *filename) -{ - return NULL; -} - -const ne_ssl_certificate *ne_ssl_clicert_owner(const ne_ssl_client_cert *ccert) -{ - return NULL; -} - -int ne_ssl_clicert_encrypted(const ne_ssl_client_cert *ccert) -{ - return -1; -} - -int ne_ssl_clicert_decrypt(ne_ssl_client_cert *ccert, const char *password) -{ - return -1; -} - -void ne_ssl_clicert_free(ne_ssl_client_cert *ccert) {} - -void ne_ssl_trust_default_ca(ne_session *sess) {} - -ne_ssl_context *ne_ssl_context_create(int mode) -{ - return NULL; -} - -void ne_ssl_context_trustcert(ne_ssl_context *ctx, const ne_ssl_certificate *cert) -{} - -int ne_ssl_context_set_verify(ne_ssl_context *ctx, - int required, - const char *ca_names, - const char *verify_cas) -{ - return -1; -} - -void ne_ssl_context_set_flag(ne_ssl_context *ctx, int flag, int value) {} - -void ne_ssl_context_destroy(ne_ssl_context *ctx) {} - -int ne_ssl_cert_digest(const ne_ssl_certificate *cert, char digest[60]) -{ - return -1; -} - -void ne_ssl_cert_validity_time(const ne_ssl_certificate *cert, - time_t *from, time_t *until) {} - -const char *ne_ssl_cert_identity(const ne_ssl_certificate *cert) -{ - return NULL; -} - - -const char *ne_ssl_clicert_name(const ne_ssl_client_cert *ccert) -{ - return NULL; -} - -int ne_ssl_dname_cmp(const ne_ssl_dname *dn1, const ne_ssl_dname *dn2) -{ - return -1; -} - -int ne_ssl_cert_write(const ne_ssl_certificate *cert, const char *filename) -{ - return -1; -} - -char *ne_ssl_cert_export(const ne_ssl_certificate *cert) -{ - return NULL; -} - -ne_ssl_certificate *ne_ssl_cert_import(const char *data) -{ - return NULL; -} - -void ne_ssl_set_clicert(ne_session *sess, const ne_ssl_client_cert *cc) -{} diff --git a/libs/neon/src/ne_uri.c b/libs/neon/src/ne_uri.c index 8d86c31d..4d0ab915 100644 --- a/libs/neon/src/ne_uri.c +++ b/libs/neon/src/ne_uri.c @@ -474,8 +474,8 @@ char *ne_path_unescape(const char *uri) } /* CH must be an unsigned char; evaluates to 1 if CH should be - * percent-encoded. */ -#define path_escape_ch(ch) (uri_lookup(ch) & URI_ESCAPE) + * percent-encoded (note !!x == x ? 1 : 0). */ +#define path_escape_ch(ch) (!!(uri_lookup(ch) & URI_ESCAPE)) char *ne_path_escape(const char *path) { diff --git a/libs/neon/src/ne_utils.c b/libs/neon/src/ne_utils.c index 93985afa..ae7788f5 100644 --- a/libs/neon/src/ne_utils.c +++ b/libs/neon/src/ne_utils.c @@ -54,6 +54,13 @@ #include "ne_dates.h" int ne_debug_mask = 0; + +#ifdef WINSCP + +void * ne_debug_context = NULL; + +#else + FILE *ne_debug_stream = NULL; void ne_debug_init(FILE *stream, int mask) @@ -79,6 +86,8 @@ void ne_debug(int ch, const char *template, ...) fflush(ne_debug_stream); } +#endif /* WINSCP */ + #define NE_STRINGIFY(x) # x #define NE_EXPAT_VER(x,y,z) NE_STRINGIFY(x) "." NE_STRINGIFY(y) "." NE_STRINGIFY(z) @@ -118,6 +127,9 @@ static const char version_string[] = "neon " NEON_VERSION ": " #ifdef HAVE_GNUTLS ", GNU TLS " LIBGNUTLS_VERSION #endif /* HAVE_GNUTLS */ +#ifdef HAVE_SSPI + ", SSPI" +#endif /* HAVE_SSPI */ "." ; @@ -137,7 +149,7 @@ int ne_has_support(int feature) switch (feature) { #if defined(NE_HAVE_SSL) || defined(NE_HAVE_ZLIB) || defined(NE_HAVE_IPV6) \ || defined(NE_HAVE_SOCKS) || defined(NE_HAVE_LFS) \ - || defined(NE_HAVE_TS_SSL) || defined(NE_HAVE_I18N) + || defined(NE_HAVE_TS_SSL) || defined(NE_HAVE_I18N) || defined(HAVE_SSPI) #ifdef NE_HAVE_SSL case NE_FEATURE_SSL: #endif @@ -158,6 +170,9 @@ int ne_has_support(int feature) #endif #ifdef NE_HAVE_I18N case NE_FEATURE_I18N: +#endif +#ifdef HAVE_SSPI + case NE_FEATURE_SSPI: #endif return 1; #endif /* NE_HAVE_* */ diff --git a/libs/neon/src/ne_utils.h b/libs/neon/src/ne_utils.h index d23a9456..1c13440d 100644 --- a/libs/neon/src/ne_utils.h +++ b/libs/neon/src/ne_utils.h @@ -54,6 +54,7 @@ int ne_version_match(int major, int minor); #define NE_FEATURE_SOCKS (5) /* SOCKSv5 support */ #define NE_FEATURE_TS_SSL (6) /* Thread-safe SSL/TLS support */ #define NE_FEATURE_I18N (7) /* i18n error message support */ +#define NE_FEATURE_SSPI (8) /* NTLM/Negotiate authentication protocol via SSPI */ /* Returns non-zero if library is built with support for the given * NE_FEATURE_* feature code 'code'. */ @@ -64,7 +65,11 @@ int ne_has_support(int feature); #ifndef NE_DEBUGGING #define NE_DEBUG if (0) ne_debug #else /* DEBUGGING */ +#ifdef WINSCP +#define NE_DEBUG(...) ne_debug(ne_debug_context, __VA_ARGS__) +#else #define NE_DEBUG ne_debug +#endif #endif /* DEBUGGING */ /* Debugging masks. */ @@ -77,22 +82,44 @@ int ne_has_support(int feature); #define NE_DBG_XMLPARSE (1<<6) /* low-level XML parser */ #define NE_DBG_HTTPBODY (1<<7) /* HTTP response body blocks */ #define NE_DBG_SSL (1<<8) /* SSL/TLS */ +#ifdef WINSCP +#define NE_DBG_WINSCP_HTTP_DETAIL (1<<29) +#endif #define NE_DBG_FLUSH (1<<30) /* always flush debugging */ +#ifdef WINSCP + +#define NE_DEBUG_WINSCP_CONTEXT(SESSION) void * ne_debug_context = (SESSION) + +extern void * ne_debug_context; + +void ne_debug(void * context, int ch, const char * fmt, ...); + +#else + +#define NE_DEBUG_WINSCP_CONTEXT(SESSION) + /* Send debugging output to 'stream', for all of the given debug * channels. To disable debugging, pass 'stream' as NULL and 'mask' * as 0. */ void ne_debug_init(FILE *stream, int mask); +#endif /* WINSCP */ + /* The current debug mask and stream set by the last call to * ne_debug_init. */ extern int ne_debug_mask; + +#ifndef WINSCP + extern FILE *ne_debug_stream; /* Produce debug output if any of channels 'ch' is enabled for * debugging. */ void ne_debug(int ch, const char *, ...) ne_attribute((format(printf, 2, 3))); +#endif /* WINSCP */ + /* Storing an HTTP status result */ typedef struct { int major_version; diff --git a/libs/neon/src/ne_xmlreq.c b/libs/neon/src/ne_xmlreq.c index c4fbf5ad..9d437342 100644 --- a/libs/neon/src/ne_xmlreq.c +++ b/libs/neon/src/ne_xmlreq.c @@ -64,7 +64,11 @@ int ne_xml_parse_response(ne_request *req, ne_xml_parser *parser) /* Returns non-zero if given content-type is an XML media type, * following the RFC 3023 rules. */ +#ifdef WINSCP +int media_type_is_xml(const ne_content_type *ctype) +#else static int media_type_is_xml(const ne_content_type *ctype) +#endif { size_t stlen; diff --git a/libs/neon/src/ne_xmlreq.h b/libs/neon/src/ne_xmlreq.h index 1bf667dc..3ea42338 100644 --- a/libs/neon/src/ne_xmlreq.h +++ b/libs/neon/src/ne_xmlreq.h @@ -24,6 +24,9 @@ #include "ne_request.h" #include "ne_xml.h" +#ifdef WINSCP +#include "ne_basic.h" +#endif NE_BEGIN_DECLS @@ -46,6 +49,10 @@ int ne_xml_parse_response(ne_request *req, ne_xml_parser *parser); * NE_ERROR is returned. */ int ne_xml_dispatch_request(ne_request *req, ne_xml_parser *parser); +#ifdef WINSCP +int media_type_is_xml(const ne_content_type *ctype); +#endif + NE_END_DECLS #endif /* NE_XMLREQ_H */ diff --git a/libs/neon/src/neon.vers b/libs/neon/src/neon.vers index e482b5ed..bed99c29 100644 --- a/libs/neon/src/neon.vers +++ b/libs/neon/src/neon.vers @@ -12,5 +12,11 @@ NEON_0_29 { ne_acl3744_set; ne_buffer_qappend; ne_strnqdup; - ne_iaddr_parse; +}; + +NEON_0_30 { + ne_ssl_clicert_import; + ne_addr_canonical; + ne_ssl_context_get_flag; + ne_set_addrlist2; }; diff --git a/libs/openssl/Makefile b/libs/openssl/Makefile index db1ae61b..5e48ae6b 100644 --- a/libs/openssl/Makefile +++ b/libs/openssl/Makefile @@ -11,11 +11,11 @@ # The one monster makefile better suits building in non-unix # environments. -# The makefile fwas further modified for WinSCP build. +# The makefile was further modified for WinSCP build. # Set your compiler options CC=bcc32 -CFLAG=-DWIN32_LEAN_AND_MEAN -q -w-ccc -w-rch -w-pia -w-aus -w-par -w-inl -w-eff -w-sus -w-dup -w-spa -w-csu -w-rvl -c -tWC -tWM -DOPENSSL_SYSNAME_WIN32 -DL_ENDIAN -DDSO_WIN32 -D_stricmp=stricmp -D_strnicmp=strnicmp -O2 -ff -fp -DBN_ASM -DMD5_ASM -DSHA1_ASM -DOPENSSL_NO_CAMELLIA -DOPENSSL_NO_SEED -DOPENSSL_NO_RC5 -DOPENSSL_NO_MDC2 -DOPENSSL_NO_CMS -DOPENSSL_NO_CAPIENG -DOPENSSL_NO_KRB5 -DOPENSSL_NO_ENGINE -DOPENSSL_NO_DYNAMIC_ENGINE -DOPENSSL_DISABLE_OLD_DES_SUPPORT -DNO_CHMOD -DOPENSSL_NO_DGRAM -DOPENSSL_NO_EC -DOPENSSL_NO_ECDH -DOPENSSL_NO_ECDSA -DDOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_WHIRLPOOL +CFLAG=-DWIN32_LEAN_AND_MEAN -q -w-ccc -w-rch -w-pia -w-aus -w-par -w-inl -w-eff -w-sus -w-dup -w-spa -w-csu -w-rvl -c -tWC -tWM -DOPENSSL_SYSNAME_WIN32 -DL_ENDIAN -DDSO_WIN32 -D_stricmp=stricmp -D_strnicmp=strnicmp -Od -ff -fp -DBN_ASM -DMD5_ASM -DSHA1_ASM -DOPENSSL_NO_CAMELLIA -DOPENSSL_NO_SEED -DOPENSSL_NO_RC5 -DOPENSSL_NO_MDC2 -DOPENSSL_NO_CMS -DOPENSSL_NO_CAPIENG -DOPENSSL_NO_KRB5 -DOPENSSL_NO_ENGINE -DOPENSSL_NO_DYNAMIC_ENGINE -DOPENSSL_DISABLE_OLD_DES_SUPPORT -DNO_CHMOD -DOPENSSL_NO_DGRAM -DDOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_WHIRLPOOL LIB_CFLAG= # The OpenSSL directory @@ -38,7 +38,7 @@ INCO_D=openssl CP=copy RM=del MKDIR=-mkdir -MKLIB=tlib /P64 /C +MKLIB=tlib /P128 /C ASM=nasm -f obj -d__omf__ ###################################################### @@ -106,7 +106,8 @@ EXHEADER=$(INCO_D)\e_os2.h \ $(INCO_D)\ssl23.h $(INCO_D)\tls1.h $(INCO_D)\dtls1.h \ $(INCO_D)\modes.h $(INCO_D)\ts.h \ $(INCO_D)\kssl.h $(INCO_D)\srtp.h $(INCO_D)\cmac.h \ - $(INCO_D)\srp.h + $(INCO_D)\srp.h \ + $(INCO_D)\ec.h $(INCO_D)\ecdh.h $(INCO_D)\ecdsa.h \ E_OBJ=$(OBJ_D)\verify.obj \ $(OBJ_D)\asn1pars.obj $(OBJ_D)\req.obj $(OBJ_D)\dgst.obj \ @@ -307,7 +308,19 @@ CRYPTOOBJ=$(OBJ_D)\cryptlib.obj \ $(OBJ_D)\ui_err.obj $(OBJ_D)\ui_lib.obj $(OBJ_D)\ui_openssl.obj \ $(OBJ_D)\ui_util.obj $(OBJ_D)\ui_compat.obj $(OBJ_D)\krb5_asn.obj \ $(OBJ_D)\pqueue.obj $(OBJ_D)\o_init.obj $(OBJ_D)\srp_lib.obj \ - $(OBJ_D)\srp_vfy.obj $(OBJ_D)\txt_db.obj + $(OBJ_D)\srp_vfy.obj $(OBJ_D)\txt_db.obj \ + $(OBJ_D)\ec_ameth.obj $(OBJ_D)\ec_asn1.obj $(OBJ_D)\ec_curve.obj \ + $(OBJ_D)\ec_cvt.obj $(OBJ_D)\ec_err.obj $(OBJ_D)\ec_check.obj \ + $(OBJ_D)\ec_key.obj $(OBJ_D)\ec_lib.obj $(OBJ_D)\ec_mult.obj \ + $(OBJ_D)\ec_oct.obj $(OBJ_D)\ec_pmeth.obj $(OBJ_D)\ec_print.obj \ + $(OBJ_D)\ec2_mult.obj $(OBJ_D)\ec2_oct.obj $(OBJ_D)\ec2_smpl.obj \ + $(OBJ_D)\eck_prn.obj $(OBJ_D)\ecp_mont.obj $(OBJ_D)\ecp_nist.obj \ + $(OBJ_D)\ecp_nistp224.obj $(OBJ_D)\ecp_nistp256.obj $(OBJ_D)\ecp_nistp521.obj \ + $(OBJ_D)\ecp_nistputil.obj $(OBJ_D)\ecp_oct.obj $(OBJ_D)\ecp_smpl.obj \ + $(OBJ_D)\ech_err.obj $(OBJ_D)\ech_key.obj $(OBJ_D)\ech_lib.obj \ + $(OBJ_D)\ech_ossl.obj $(OBJ_D)\ecs_asn1.obj $(OBJ_D)\ecs_err.obj \ + $(OBJ_D)\ecs_lib.obj $(OBJ_D)\ecs_ossl.obj $(OBJ_D)\ecs_sign.obj \ + $(OBJ_D)\ecs_vrf.obj $(OBJ_D)\m_ecdsa.obj ################################################################### all: banner $(TMP_D) $(INCO_D) headers lib @@ -629,6 +642,15 @@ $(INCO_D)\cmac.h: $(SRC_D)\crypto\cmac\cmac.h $(INCO_D)\srp.h: $(SRC_D)\crypto\srp\srp.h $(CP) "$(SRC_D)\crypto\srp\srp.h" "$(INCO_D)\srp.h" +$(INCO_D)\ec.h: $(SRC_D)\crypto\ec\ec.h + $(CP) "$(SRC_D)\crypto\ec\ec.h" "$(INCO_D)\ec.h" + +$(INCO_D)\ecdh.h: $(SRC_D)\crypto\ecdh\ecdh.h + $(CP) "$(SRC_D)\crypto\ecdh\ecdh.h" "$(INCO_D)\ecdh.h" + +$(INCO_D)\ecdsa.h: $(SRC_D)\crypto\ecdsa\ecdsa.h + $(CP) "$(SRC_D)\crypto\ecdsa\ecdsa.h" "$(INCO_D)\ecdsa.h" + $(OBJ_D)\s2_meth.obj: $(SRC_D)\ssl\s2_meth.c $(CC) -o$(OBJ_D)\s2_meth.obj $(LIB_CFLAGS) -c $(SRC_D)\ssl\s2_meth.c @@ -2159,6 +2181,111 @@ $(OBJ_D)\srp_vfy.obj: $(SRC_D)\crypto\srp\srp_vfy.c $(OBJ_D)\txt_db.obj: $(SRC_D)\crypto\txt_db\txt_db.c $(CC) -o$(OBJ_D)\txt_db.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\txt_db\txt_db.c +$(OBJ_D)\ec_ameth.obj: $(SRC_D)\crypto\ec\ec_ameth.c + $(CC) -o$(OBJ_D)\ec_ameth.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\ec_ameth.c + +$(OBJ_D)\ec_asn1.obj: $(SRC_D)\crypto\ec\ec_asn1.c + $(CC) -o$(OBJ_D)\ec_asn1.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\ec_asn1.c + +$(OBJ_D)\ec_curve.obj: $(SRC_D)\crypto\ec\ec_curve.c + $(CC) -o$(OBJ_D)\ec_curve.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\ec_curve.c + +$(OBJ_D)\ec_cvt.obj: $(SRC_D)\crypto\ec\ec_cvt.c + $(CC) -o$(OBJ_D)\ec_cvt.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\ec_cvt.c + +$(OBJ_D)\ec_err.obj: $(SRC_D)\crypto\ec\ec_err.c + $(CC) -o$(OBJ_D)\ec_err.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\ec_err.c + +$(OBJ_D)\ec_check.obj: $(SRC_D)\crypto\ec\ec_check.c + $(CC) -o$(OBJ_D)\ec_check.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\ec_check.c + +$(OBJ_D)\ec_key.obj: $(SRC_D)\crypto\ec\ec_key.c + $(CC) -o$(OBJ_D)\ec_key.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\ec_key.c + +$(OBJ_D)\ec_lib.obj: $(SRC_D)\crypto\ec\ec_lib.c + $(CC) -o$(OBJ_D)\ec_lib.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\ec_lib.c + +$(OBJ_D)\ec_mult.obj: $(SRC_D)\crypto\ec\ec_mult.c + $(CC) -o$(OBJ_D)\ec_mult.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\ec_mult.c + +$(OBJ_D)\ec_oct.obj: $(SRC_D)\crypto\ec\ec_oct.c + $(CC) -o$(OBJ_D)\ec_oct.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\ec_oct.c + +$(OBJ_D)\ec_pmeth.obj: $(SRC_D)\crypto\ec\ec_pmeth.c + $(CC) -o$(OBJ_D)\ec_pmeth.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\ec_pmeth.c + +$(OBJ_D)\ec_print.obj: $(SRC_D)\crypto\ec\ec_print.c + $(CC) -o$(OBJ_D)\ec_print.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\ec_print.c + +$(OBJ_D)\ec2_mult.obj: $(SRC_D)\crypto\ec\ec2_mult.c + $(CC) -o$(OBJ_D)\ec2_mult.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\ec2_mult.c + +$(OBJ_D)\ec2_oct.obj: $(SRC_D)\crypto\ec\ec2_oct.c + $(CC) -o$(OBJ_D)\ec2_oct.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\ec2_oct.c + +$(OBJ_D)\ec2_smpl.obj: $(SRC_D)\crypto\ec\ec2_smpl.c + $(CC) -o$(OBJ_D)\ec2_smpl.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\ec2_smpl.c + +$(OBJ_D)\eck_prn.obj: $(SRC_D)\crypto\ec\eck_prn.c + $(CC) -o$(OBJ_D)\eck_prn.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\eck_prn.c + +$(OBJ_D)\ecp_mont.obj: $(SRC_D)\crypto\ec\ecp_mont.c + $(CC) -o$(OBJ_D)\ecp_mont.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\ecp_mont.c + +$(OBJ_D)\ecp_nist.obj: $(SRC_D)\crypto\ec\ecp_nist.c + $(CC) -o$(OBJ_D)\ecp_nist.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\ecp_nist.c + +$(OBJ_D)\ecp_nistp224.obj: $(SRC_D)\crypto\ec\ecp_nistp224.c + $(CC) -o$(OBJ_D)\ecp_nistp224.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\ecp_nistp224.c + +$(OBJ_D)\ecp_nistp256.obj: $(SRC_D)\crypto\ec\ecp_nistp256.c + $(CC) -o$(OBJ_D)\ecp_nistp256.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\ecp_nistp256.c + +$(OBJ_D)\ecp_nistp521.obj: $(SRC_D)\crypto\ec\ecp_nistp521.c + $(CC) -o$(OBJ_D)\ecp_nistp521.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\ecp_nistp521.c + +$(OBJ_D)\ecp_nistputil.obj: $(SRC_D)\crypto\ec\ecp_nistputil.c + $(CC) -o$(OBJ_D)\ecp_nistputil.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\ecp_nistputil.c + +$(OBJ_D)\ecp_oct.obj: $(SRC_D)\crypto\ec\ecp_oct.c + $(CC) -o$(OBJ_D)\ecp_oct.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\ecp_oct.c + +$(OBJ_D)\ecp_smpl.obj: $(SRC_D)\crypto\ec\ecp_smpl.c + $(CC) -o$(OBJ_D)\ecp_smpl.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ec\ecp_smpl.c + +$(OBJ_D)\ech_err.obj: $(SRC_D)\crypto\ecdh\ech_err.c + $(CC) -o$(OBJ_D)\ech_err.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ecdh\ech_err.c + +$(OBJ_D)\ech_key.obj: $(SRC_D)\crypto\ecdh\ech_key.c + $(CC) -o$(OBJ_D)\ech_key.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ecdh\ech_key.c + +$(OBJ_D)\ech_lib.obj: $(SRC_D)\crypto\ecdh\ech_lib.c + $(CC) -o$(OBJ_D)\ech_lib.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ecdh\ech_lib.c + +$(OBJ_D)\ech_ossl.obj: $(SRC_D)\crypto\ecdh\ech_ossl.c + $(CC) -o$(OBJ_D)\ech_ossl.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ecdh\ech_ossl.c + +$(OBJ_D)\ecs_asn1.obj: $(SRC_D)\crypto\ecdsa\ecs_asn1.c + $(CC) -o$(OBJ_D)\ecs_asn1.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ecdsa\ecs_asn1.c + +$(OBJ_D)\ecs_err.obj: $(SRC_D)\crypto\ecdsa\ecs_err.c + $(CC) -o$(OBJ_D)\ecs_err.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ecdsa\ecs_err.c + +$(OBJ_D)\ecs_lib.obj: $(SRC_D)\crypto\ecdsa\ecs_lib.c + $(CC) -o$(OBJ_D)\ecs_lib.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ecdsa\ecs_lib.c + +$(OBJ_D)\ecs_ossl.obj: $(SRC_D)\crypto\ecdsa\ecs_ossl.c + $(CC) -o$(OBJ_D)\ecs_ossl.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ecdsa\ecs_ossl.c + +$(OBJ_D)\ecs_sign.obj: $(SRC_D)\crypto\ecdsa\ecs_sign.c + $(CC) -o$(OBJ_D)\ecs_sign.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ecdsa\ecs_sign.c + +$(OBJ_D)\ecs_vrf.obj: $(SRC_D)\crypto\ecdsa\ecs_vrf.c + $(CC) -o$(OBJ_D)\ecs_vrf.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\ecdsa\ecs_vrf.c + +$(OBJ_D)\m_ecdsa.obj: $(SRC_D)\crypto\evp\m_ecdsa.c + $(CC) -o$(OBJ_D)\m_ecdsa.obj $(LIB_CFLAGS) -c $(SRC_D)\crypto\evp\m_ecdsa.c + $(O_SSL): $(SSLOBJ) -if exist $(O_SSL) $(RM) $(O_SSL) $(MKLIB) $(O_SSL) @&&! diff --git a/libs/openssl/crypto/ec/ec.h b/libs/openssl/crypto/ec/ec.h new file mode 100644 index 00000000..dfe8710d --- /dev/null +++ b/libs/openssl/crypto/ec/ec.h @@ -0,0 +1,1167 @@ +/* crypto/ec/ec.h */ +/* + * Originally written by Bodo Moeller for the OpenSSL project. + */ +/** + * \file crypto/ec/ec.h Include file for the OpenSSL EC functions + * \author Originally written by Bodo Moeller for the OpenSSL project + */ +/* ==================================================================== + * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * Portions of the attached software ("Contribution") are developed by + * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. + * + * The Contribution is licensed pursuant to the OpenSSL open source + * license provided above. + * + * The elliptic curve binary polynomial software is originally written by + * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. + * + */ + +#ifndef HEADER_EC_H +#define HEADER_EC_H + +#include + +#ifdef OPENSSL_NO_EC +#error EC is disabled. +#endif + +#include +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifdef __cplusplus +extern "C" { +#elif defined(__SUNPRO_C) +# if __SUNPRO_C >= 0x520 +# pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) +# endif +#endif + + +#ifndef OPENSSL_ECC_MAX_FIELD_BITS +# define OPENSSL_ECC_MAX_FIELD_BITS 661 +#endif + +/** Enum for the point conversion form as defined in X9.62 (ECDSA) + * for the encoding of a elliptic curve point (x,y) */ +typedef enum { + /** the point is encoded as z||x, where the octet z specifies + * which solution of the quadratic equation y is */ + POINT_CONVERSION_COMPRESSED = 2, + /** the point is encoded as z||x||y, where z is the octet 0x02 */ + POINT_CONVERSION_UNCOMPRESSED = 4, + /** the point is encoded as z||x||y, where the octet z specifies + * which solution of the quadratic equation y is */ + POINT_CONVERSION_HYBRID = 6 +} point_conversion_form_t; + + +typedef struct ec_method_st EC_METHOD; + +typedef struct ec_group_st + /* + EC_METHOD *meth; + -- field definition + -- curve coefficients + -- optional generator with associated information (order, cofactor) + -- optional extra data (precomputed table for fast computation of multiples of generator) + -- ASN1 stuff + */ + EC_GROUP; + +typedef struct ec_point_st EC_POINT; + + +/********************************************************************/ +/* EC_METHODs for curves over GF(p) */ +/********************************************************************/ + +/** Returns the basic GFp ec methods which provides the basis for the + * optimized methods. + * \return EC_METHOD object + */ +const EC_METHOD *EC_GFp_simple_method(void); + +/** Returns GFp methods using montgomery multiplication. + * \return EC_METHOD object + */ +const EC_METHOD *EC_GFp_mont_method(void); + +/** Returns GFp methods using optimized methods for NIST recommended curves + * \return EC_METHOD object + */ +const EC_METHOD *EC_GFp_nist_method(void); + +#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 +/** Returns 64-bit optimized methods for nistp224 + * \return EC_METHOD object + */ +const EC_METHOD *EC_GFp_nistp224_method(void); + +/** Returns 64-bit optimized methods for nistp256 + * \return EC_METHOD object + */ +const EC_METHOD *EC_GFp_nistp256_method(void); + +/** Returns 64-bit optimized methods for nistp521 + * \return EC_METHOD object + */ +const EC_METHOD *EC_GFp_nistp521_method(void); +#endif + +#ifndef OPENSSL_NO_EC2M +/********************************************************************/ +/* EC_METHOD for curves over GF(2^m) */ +/********************************************************************/ + +/** Returns the basic GF2m ec method + * \return EC_METHOD object + */ +const EC_METHOD *EC_GF2m_simple_method(void); + +#endif + + +/********************************************************************/ +/* EC_GROUP functions */ +/********************************************************************/ + +/** Creates a new EC_GROUP object + * \param meth EC_METHOD to use + * \return newly created EC_GROUP object or NULL in case of an error. + */ +EC_GROUP *EC_GROUP_new(const EC_METHOD *meth); + +/** Frees a EC_GROUP object + * \param group EC_GROUP object to be freed. + */ +void EC_GROUP_free(EC_GROUP *group); + +/** Clears and frees a EC_GROUP object + * \param group EC_GROUP object to be cleared and freed. + */ +void EC_GROUP_clear_free(EC_GROUP *group); + +/** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD. + * \param dst destination EC_GROUP object + * \param src source EC_GROUP object + * \return 1 on success and 0 if an error occurred. + */ +int EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src); + +/** Creates a new EC_GROUP object and copies the copies the content + * form src to the newly created EC_KEY object + * \param src source EC_GROUP object + * \return newly created EC_GROUP object or NULL in case of an error. + */ +EC_GROUP *EC_GROUP_dup(const EC_GROUP *src); + +/** Returns the EC_METHOD of the EC_GROUP object. + * \param group EC_GROUP object + * \return EC_METHOD used in this EC_GROUP object. + */ +const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group); + +/** Returns the field type of the EC_METHOD. + * \param meth EC_METHOD object + * \return NID of the underlying field type OID. + */ +int EC_METHOD_get_field_type(const EC_METHOD *meth); + +/** Sets the generator and it's order/cofactor of a EC_GROUP object. + * \param group EC_GROUP object + * \param generator EC_POINT object with the generator. + * \param order the order of the group generated by the generator. + * \param cofactor the index of the sub-group generated by the generator + * in the group of all points on the elliptic curve. + * \return 1 on success and 0 if an error occured + */ +int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor); + +/** Returns the generator of a EC_GROUP object. + * \param group EC_GROUP object + * \return the currently used generator (possibly NULL). + */ +const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group); + +/** Gets the order of a EC_GROUP + * \param group EC_GROUP object + * \param order BIGNUM to which the order is copied + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occured + */ +int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx); + +/** Gets the cofactor of a EC_GROUP + * \param group EC_GROUP object + * \param cofactor BIGNUM to which the cofactor is copied + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occured + */ +int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx); + +/** Sets the name of a EC_GROUP object + * \param group EC_GROUP object + * \param nid NID of the curve name OID + */ +void EC_GROUP_set_curve_name(EC_GROUP *group, int nid); + +/** Returns the curve name of a EC_GROUP object + * \param group EC_GROUP object + * \return NID of the curve name OID or 0 if not set. + */ +int EC_GROUP_get_curve_name(const EC_GROUP *group); + +void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag); +int EC_GROUP_get_asn1_flag(const EC_GROUP *group); + +void EC_GROUP_set_point_conversion_form(EC_GROUP *group, point_conversion_form_t form); +point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *); + +unsigned char *EC_GROUP_get0_seed(const EC_GROUP *x); +size_t EC_GROUP_get_seed_len(const EC_GROUP *); +size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len); + +/** Sets the parameter of a ec over GFp defined by y^2 = x^3 + a*x + b + * \param group EC_GROUP object + * \param p BIGNUM with the prime number + * \param a BIGNUM with parameter a of the equation + * \param b BIGNUM with parameter b of the equation + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occured + */ +int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); + +/** Gets the parameter of the ec over GFp defined by y^2 = x^3 + a*x + b + * \param group EC_GROUP object + * \param p BIGNUM for the prime number + * \param a BIGNUM for parameter a of the equation + * \param b BIGNUM for parameter b of the equation + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occured + */ +int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); + +#ifndef OPENSSL_NO_EC2M +/** Sets the parameter of a ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b + * \param group EC_GROUP object + * \param p BIGNUM with the polynomial defining the underlying field + * \param a BIGNUM with parameter a of the equation + * \param b BIGNUM with parameter b of the equation + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occured + */ +int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); + +/** Gets the parameter of the ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b + * \param group EC_GROUP object + * \param p BIGNUM for the polynomial defining the underlying field + * \param a BIGNUM for parameter a of the equation + * \param b BIGNUM for parameter b of the equation + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occured + */ +int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); +#endif +/** Returns the number of bits needed to represent a field element + * \param group EC_GROUP object + * \return number of bits needed to represent a field element + */ +int EC_GROUP_get_degree(const EC_GROUP *group); + +/** Checks whether the parameter in the EC_GROUP define a valid ec group + * \param group EC_GROUP object + * \param ctx BN_CTX object (optional) + * \return 1 if group is a valid ec group and 0 otherwise + */ +int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx); + +/** Checks whether the discriminant of the elliptic curve is zero or not + * \param group EC_GROUP object + * \param ctx BN_CTX object (optional) + * \return 1 if the discriminant is not zero and 0 otherwise + */ +int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx); + +/** Compares two EC_GROUP objects + * \param a first EC_GROUP object + * \param b second EC_GROUP object + * \param ctx BN_CTX object (optional) + * \return 0 if both groups are equal and 1 otherwise + */ +int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx); + +/* EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() + * after choosing an appropriate EC_METHOD */ + +/** Creates a new EC_GROUP object with the specified parameters defined + * over GFp (defined by the equation y^2 = x^3 + a*x + b) + * \param p BIGNUM with the prime number + * \param a BIGNUM with the parameter a of the equation + * \param b BIGNUM with the parameter b of the equation + * \param ctx BN_CTX object (optional) + * \return newly created EC_GROUP object with the specified parameters + */ +EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); +#ifndef OPENSSL_NO_EC2M +/** Creates a new EC_GROUP object with the specified parameters defined + * over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b) + * \param p BIGNUM with the polynomial defining the underlying field + * \param a BIGNUM with the parameter a of the equation + * \param b BIGNUM with the parameter b of the equation + * \param ctx BN_CTX object (optional) + * \return newly created EC_GROUP object with the specified parameters + */ +EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); +#endif +/** Creates a EC_GROUP object with a curve specified by a NID + * \param nid NID of the OID of the curve name + * \return newly created EC_GROUP object with specified curve or NULL + * if an error occurred + */ +EC_GROUP *EC_GROUP_new_by_curve_name(int nid); + + +/********************************************************************/ +/* handling of internal curves */ +/********************************************************************/ + +typedef struct { + int nid; + const char *comment; + } EC_builtin_curve; + +/* EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number + * of all available curves or zero if a error occurred. + * In case r ist not zero nitems EC_builtin_curve structures + * are filled with the data of the first nitems internal groups */ +size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); + + +/********************************************************************/ +/* EC_POINT functions */ +/********************************************************************/ + +/** Creates a new EC_POINT object for the specified EC_GROUP + * \param group EC_GROUP the underlying EC_GROUP object + * \return newly created EC_POINT object or NULL if an error occurred + */ +EC_POINT *EC_POINT_new(const EC_GROUP *group); + +/** Frees a EC_POINT object + * \param point EC_POINT object to be freed + */ +void EC_POINT_free(EC_POINT *point); + +/** Clears and frees a EC_POINT object + * \param point EC_POINT object to be cleared and freed + */ +void EC_POINT_clear_free(EC_POINT *point); + +/** Copies EC_POINT object + * \param dst destination EC_POINT object + * \param src source EC_POINT object + * \return 1 on success and 0 if an error occured + */ +int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src); + +/** Creates a new EC_POINT object and copies the content of the supplied + * EC_POINT + * \param src source EC_POINT object + * \param group underlying the EC_GROUP object + * \return newly created EC_POINT object or NULL if an error occurred + */ +EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group); + +/** Returns the EC_METHOD used in EC_POINT object + * \param point EC_POINT object + * \return the EC_METHOD used + */ +const EC_METHOD *EC_POINT_method_of(const EC_POINT *point); + +/** Sets a point to infinity (neutral element) + * \param group underlying EC_GROUP object + * \param point EC_POINT to set to infinity + * \return 1 on success and 0 if an error occured + */ +int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point); + +/** Sets the jacobian projective coordinates of a EC_POINT over GFp + * \param group underlying EC_GROUP object + * \param p EC_POINT object + * \param x BIGNUM with the x-coordinate + * \param y BIGNUM with the y-coordinate + * \param z BIGNUM with the z-coordinate + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occured + */ +int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, + const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx); + +/** Gets the jacobian projective coordinates of a EC_POINT over GFp + * \param group underlying EC_GROUP object + * \param p EC_POINT object + * \param x BIGNUM for the x-coordinate + * \param y BIGNUM for the y-coordinate + * \param z BIGNUM for the z-coordinate + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occured + */ +int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, + const EC_POINT *p, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx); + +/** Sets the affine coordinates of a EC_POINT over GFp + * \param group underlying EC_GROUP object + * \param p EC_POINT object + * \param x BIGNUM with the x-coordinate + * \param y BIGNUM with the y-coordinate + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occured + */ +int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, + const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx); + +/** Gets the affine coordinates of a EC_POINT over GFp + * \param group underlying EC_GROUP object + * \param p EC_POINT object + * \param x BIGNUM for the x-coordinate + * \param y BIGNUM for the y-coordinate + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occured + */ +int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, + const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx); + +/** Sets the x9.62 compressed coordinates of a EC_POINT over GFp + * \param group underlying EC_GROUP object + * \param p EC_POINT object + * \param x BIGNUM with x-coordinate + * \param y_bit integer with the y-Bit (either 0 or 1) + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occured + */ +int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, + const BIGNUM *x, int y_bit, BN_CTX *ctx); +#ifndef OPENSSL_NO_EC2M +/** Sets the affine coordinates of a EC_POINT over GF2m + * \param group underlying EC_GROUP object + * \param p EC_POINT object + * \param x BIGNUM with the x-coordinate + * \param y BIGNUM with the y-coordinate + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occured + */ +int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p, + const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx); + +/** Gets the affine coordinates of a EC_POINT over GF2m + * \param group underlying EC_GROUP object + * \param p EC_POINT object + * \param x BIGNUM for the x-coordinate + * \param y BIGNUM for the y-coordinate + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occured + */ +int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, + const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx); + +/** Sets the x9.62 compressed coordinates of a EC_POINT over GF2m + * \param group underlying EC_GROUP object + * \param p EC_POINT object + * \param x BIGNUM with x-coordinate + * \param y_bit integer with the y-Bit (either 0 or 1) + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occured + */ +int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p, + const BIGNUM *x, int y_bit, BN_CTX *ctx); +#endif +/** Encodes a EC_POINT object to a octet string + * \param group underlying EC_GROUP object + * \param p EC_POINT object + * \param form point conversion form + * \param buf memory buffer for the result. If NULL the function returns + * required buffer size. + * \param len length of the memory buffer + * \param ctx BN_CTX object (optional) + * \return the length of the encoded octet string or 0 if an error occurred + */ +size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p, + point_conversion_form_t form, + unsigned char *buf, size_t len, BN_CTX *ctx); + +/** Decodes a EC_POINT from a octet string + * \param group underlying EC_GROUP object + * \param p EC_POINT object + * \param buf memory buffer with the encoded ec point + * \param len length of the encoded ec point + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occured + */ +int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p, + const unsigned char *buf, size_t len, BN_CTX *ctx); + +/* other interfaces to point2oct/oct2point: */ +BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *, + point_conversion_form_t form, BIGNUM *, BN_CTX *); +EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *, + EC_POINT *, BN_CTX *); +char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *, + point_conversion_form_t form, BN_CTX *); +EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, + EC_POINT *, BN_CTX *); + + +/********************************************************************/ +/* functions for doing EC_POINT arithmetic */ +/********************************************************************/ + +/** Computes the sum of two EC_POINT + * \param group underlying EC_GROUP object + * \param r EC_POINT object for the result (r = a + b) + * \param a EC_POINT object with the first summand + * \param b EC_POINT object with the second summand + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occured + */ +int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx); + +/** Computes the double of a EC_POINT + * \param group underlying EC_GROUP object + * \param r EC_POINT object for the result (r = 2 * a) + * \param a EC_POINT object + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occured + */ +int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx); + +/** Computes the inverse of a EC_POINT + * \param group underlying EC_GROUP object + * \param a EC_POINT object to be inverted (it's used for the result as well) + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occured + */ +int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx); + +/** Checks whether the point is the neutral element of the group + * \param group the underlying EC_GROUP object + * \param p EC_POINT object + * \return 1 if the point is the neutral element and 0 otherwise + */ +int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p); + +/** Checks whether the point is on the curve + * \param group underlying EC_GROUP object + * \param point EC_POINT object to check + * \param ctx BN_CTX object (optional) + * \return 1 if point if on the curve and 0 otherwise + */ +int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx); + +/** Compares two EC_POINTs + * \param group underlying EC_GROUP object + * \param a first EC_POINT object + * \param b second EC_POINT object + * \param ctx BN_CTX object (optional) + * \return 0 if both points are equal and a value != 0 otherwise + */ +int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx); + +int EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx); +int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx); + +/** Computes r = generator * n sum_{i=0}^num p[i] * m[i] + * \param group underlying EC_GROUP object + * \param r EC_POINT object for the result + * \param n BIGNUM with the multiplier for the group generator (optional) + * \param num number futher summands + * \param p array of size num of EC_POINT objects + * \param m array of size num of BIGNUM objects + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occured + */ +int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, size_t num, const EC_POINT *p[], const BIGNUM *m[], BN_CTX *ctx); + +/** Computes r = generator * n + q * m + * \param group underlying EC_GROUP object + * \param r EC_POINT object for the result + * \param n BIGNUM with the multiplier for the group generator (optional) + * \param q EC_POINT object with the first factor of the second summand + * \param m BIGNUM with the second factor of the second summand + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occured + */ +int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx); + +/** Stores multiples of generator for faster point multiplication + * \param group EC_GROUP object + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occured + */ +int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx); + +/** Reports whether a precomputation has been done + * \param group EC_GROUP object + * \return 1 if a pre-computation has been done and 0 otherwise + */ +int EC_GROUP_have_precompute_mult(const EC_GROUP *group); + + +/********************************************************************/ +/* ASN1 stuff */ +/********************************************************************/ + +/* EC_GROUP_get_basis_type() returns the NID of the basis type + * used to represent the field elements */ +int EC_GROUP_get_basis_type(const EC_GROUP *); +#ifndef OPENSSL_NO_EC2M +int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k); +int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, + unsigned int *k2, unsigned int *k3); +#endif + +#define OPENSSL_EC_NAMED_CURVE 0x001 + +typedef struct ecpk_parameters_st ECPKPARAMETERS; + +EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len); +int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out); + +#define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x) +#define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x) +#define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \ + (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x)) +#define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \ + (unsigned char *)(x)) + +#ifndef OPENSSL_NO_BIO +int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off); +#endif +#ifndef OPENSSL_NO_FP_API +int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off); +#endif + + +/********************************************************************/ +/* EC_KEY functions */ +/********************************************************************/ + +typedef struct ec_key_st EC_KEY; + +/* some values for the encoding_flag */ +#define EC_PKEY_NO_PARAMETERS 0x001 +#define EC_PKEY_NO_PUBKEY 0x002 + +/* some values for the flags field */ +#define EC_FLAG_NON_FIPS_ALLOW 0x1 +#define EC_FLAG_FIPS_CHECKED 0x2 + +/** Creates a new EC_KEY object. + * \return EC_KEY object or NULL if an error occurred. + */ +EC_KEY *EC_KEY_new(void); + +int EC_KEY_get_flags(const EC_KEY *key); + +void EC_KEY_set_flags(EC_KEY *key, int flags); + +void EC_KEY_clear_flags(EC_KEY *key, int flags); + +/** Creates a new EC_KEY object using a named curve as underlying + * EC_GROUP object. + * \param nid NID of the named curve. + * \return EC_KEY object or NULL if an error occurred. + */ +EC_KEY *EC_KEY_new_by_curve_name(int nid); + +/** Frees a EC_KEY object. + * \param key EC_KEY object to be freed. + */ +void EC_KEY_free(EC_KEY *key); + +/** Copies a EC_KEY object. + * \param dst destination EC_KEY object + * \param src src EC_KEY object + * \return dst or NULL if an error occurred. + */ +EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src); + +/** Creates a new EC_KEY object and copies the content from src to it. + * \param src the source EC_KEY object + * \return newly created EC_KEY object or NULL if an error occurred. + */ +EC_KEY *EC_KEY_dup(const EC_KEY *src); + +/** Increases the internal reference count of a EC_KEY object. + * \param key EC_KEY object + * \return 1 on success and 0 if an error occurred. + */ +int EC_KEY_up_ref(EC_KEY *key); + +/** Returns the EC_GROUP object of a EC_KEY object + * \param key EC_KEY object + * \return the EC_GROUP object (possibly NULL). + */ +const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key); + +/** Sets the EC_GROUP of a EC_KEY object. + * \param key EC_KEY object + * \param group EC_GROUP to use in the EC_KEY object (note: the EC_KEY + * object will use an own copy of the EC_GROUP). + * \return 1 on success and 0 if an error occurred. + */ +int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group); + +/** Returns the private key of a EC_KEY object. + * \param key EC_KEY object + * \return a BIGNUM with the private key (possibly NULL). + */ +const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key); + +/** Sets the private key of a EC_KEY object. + * \param key EC_KEY object + * \param prv BIGNUM with the private key (note: the EC_KEY object + * will use an own copy of the BIGNUM). + * \return 1 on success and 0 if an error occurred. + */ +int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv); + +/** Returns the public key of a EC_KEY object. + * \param key the EC_KEY object + * \return a EC_POINT object with the public key (possibly NULL) + */ +const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key); + +/** Sets the public key of a EC_KEY object. + * \param key EC_KEY object + * \param pub EC_POINT object with the public key (note: the EC_KEY object + * will use an own copy of the EC_POINT object). + * \return 1 on success and 0 if an error occurred. + */ +int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub); + +unsigned EC_KEY_get_enc_flags(const EC_KEY *key); +void EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags); +point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key); +void EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform); +/* functions to set/get method specific data */ +void *EC_KEY_get_key_method_data(EC_KEY *key, + void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); +/** Sets the key method data of an EC_KEY object, if none has yet been set. + * \param key EC_KEY object + * \param data opaque data to install. + * \param dup_func a function that duplicates |data|. + * \param free_func a function that frees |data|. + * \param clear_free_func a function that wipes and frees |data|. + * \return the previously set data pointer, or NULL if |data| was inserted. + */ +void *EC_KEY_insert_key_method_data(EC_KEY *key, void *data, + void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); +/* wrapper functions for the underlying EC_GROUP object */ +void EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag); + +/** Creates a table of pre-computed multiples of the generator to + * accelerate further EC_KEY operations. + * \param key EC_KEY object + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred. + */ +int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx); + +/** Creates a new ec private (and optional a new public) key. + * \param key EC_KEY object + * \return 1 on success and 0 if an error occurred. + */ +int EC_KEY_generate_key(EC_KEY *key); + +/** Verifies that a private and/or public key is valid. + * \param key the EC_KEY object + * \return 1 on success and 0 otherwise. + */ +int EC_KEY_check_key(const EC_KEY *key); + +/** Sets a public key from affine coordindates performing + * neccessary NIST PKV tests. + * \param key the EC_KEY object + * \param x public key x coordinate + * \param y public key y coordinate + * \return 1 on success and 0 otherwise. + */ +int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, BIGNUM *y); + + +/********************************************************************/ +/* de- and encoding functions for SEC1 ECPrivateKey */ +/********************************************************************/ + +/** Decodes a private key from a memory buffer. + * \param key a pointer to a EC_KEY object which should be used (or NULL) + * \param in pointer to memory with the DER encoded private key + * \param len length of the DER encoded private key + * \return the decoded private key or NULL if an error occurred. + */ +EC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len); + +/** Encodes a private key object and stores the result in a buffer. + * \param key the EC_KEY object to encode + * \param out the buffer for the result (if NULL the function returns number + * of bytes needed). + * \return 1 on success and 0 if an error occurred. + */ +int i2d_ECPrivateKey(EC_KEY *key, unsigned char **out); + + +/********************************************************************/ +/* de- and encoding functions for EC parameters */ +/********************************************************************/ + +/** Decodes ec parameter from a memory buffer. + * \param key a pointer to a EC_KEY object which should be used (or NULL) + * \param in pointer to memory with the DER encoded ec parameters + * \param len length of the DER encoded ec parameters + * \return a EC_KEY object with the decoded parameters or NULL if an error + * occurred. + */ +EC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len); + +/** Encodes ec parameter and stores the result in a buffer. + * \param key the EC_KEY object with ec paramters to encode + * \param out the buffer for the result (if NULL the function returns number + * of bytes needed). + * \return 1 on success and 0 if an error occurred. + */ +int i2d_ECParameters(EC_KEY *key, unsigned char **out); + + +/********************************************************************/ +/* de- and encoding functions for EC public key */ +/* (octet string, not DER -- hence 'o2i' and 'i2o') */ +/********************************************************************/ + +/** Decodes a ec public key from a octet string. + * \param key a pointer to a EC_KEY object which should be used + * \param in memory buffer with the encoded public key + * \param len length of the encoded public key + * \return EC_KEY object with decoded public key or NULL if an error + * occurred. + */ +EC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len); + +/** Encodes a ec public key in an octet string. + * \param key the EC_KEY object with the public key + * \param out the buffer for the result (if NULL the function returns number + * of bytes needed). + * \return 1 on success and 0 if an error occurred + */ +int i2o_ECPublicKey(EC_KEY *key, unsigned char **out); + +#ifndef OPENSSL_NO_BIO +/** Prints out the ec parameters on human readable form. + * \param bp BIO object to which the information is printed + * \param key EC_KEY object + * \return 1 on success and 0 if an error occurred + */ +int ECParameters_print(BIO *bp, const EC_KEY *key); + +/** Prints out the contents of a EC_KEY object + * \param bp BIO object to which the information is printed + * \param key EC_KEY object + * \param off line offset + * \return 1 on success and 0 if an error occurred + */ +int EC_KEY_print(BIO *bp, const EC_KEY *key, int off); + +#endif +#ifndef OPENSSL_NO_FP_API +/** Prints out the ec parameters on human readable form. + * \param fp file descriptor to which the information is printed + * \param key EC_KEY object + * \return 1 on success and 0 if an error occurred + */ +int ECParameters_print_fp(FILE *fp, const EC_KEY *key); + +/** Prints out the contents of a EC_KEY object + * \param fp file descriptor to which the information is printed + * \param key EC_KEY object + * \param off line offset + * \return 1 on success and 0 if an error occurred + */ +int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off); + +#endif + +#define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x) + +#ifndef __cplusplus +#if defined(__SUNPRO_C) +# if __SUNPRO_C >= 0x520 +# pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) +# endif +# endif +#endif + +#define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \ + EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, EVP_PKEY_OP_PARAMGEN, \ + EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL) + + +#define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID (EVP_PKEY_ALG_CTRL + 1) + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_EC_strings(void); + +/* Error codes for the EC functions. */ + +/* Function codes. */ +#define EC_F_BN_TO_FELEM 224 +#define EC_F_COMPUTE_WNAF 143 +#define EC_F_D2I_ECPARAMETERS 144 +#define EC_F_D2I_ECPKPARAMETERS 145 +#define EC_F_D2I_ECPRIVATEKEY 146 +#define EC_F_DO_EC_KEY_PRINT 221 +#define EC_F_ECKEY_PARAM2TYPE 223 +#define EC_F_ECKEY_PARAM_DECODE 212 +#define EC_F_ECKEY_PRIV_DECODE 213 +#define EC_F_ECKEY_PRIV_ENCODE 214 +#define EC_F_ECKEY_PUB_DECODE 215 +#define EC_F_ECKEY_PUB_ENCODE 216 +#define EC_F_ECKEY_TYPE2PARAM 220 +#define EC_F_ECPARAMETERS_PRINT 147 +#define EC_F_ECPARAMETERS_PRINT_FP 148 +#define EC_F_ECPKPARAMETERS_PRINT 149 +#define EC_F_ECPKPARAMETERS_PRINT_FP 150 +#define EC_F_ECP_NIST_MOD_192 203 +#define EC_F_ECP_NIST_MOD_224 204 +#define EC_F_ECP_NIST_MOD_256 205 +#define EC_F_ECP_NIST_MOD_521 206 +#define EC_F_EC_ASN1_GROUP2CURVE 153 +#define EC_F_EC_ASN1_GROUP2FIELDID 154 +#define EC_F_EC_ASN1_GROUP2PARAMETERS 155 +#define EC_F_EC_ASN1_GROUP2PKPARAMETERS 156 +#define EC_F_EC_ASN1_PARAMETERS2GROUP 157 +#define EC_F_EC_ASN1_PKPARAMETERS2GROUP 158 +#define EC_F_EC_EX_DATA_SET_DATA 211 +#define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 208 +#define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 159 +#define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 195 +#define EC_F_EC_GF2M_SIMPLE_OCT2POINT 160 +#define EC_F_EC_GF2M_SIMPLE_POINT2OCT 161 +#define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162 +#define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163 +#define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 164 +#define EC_F_EC_GFP_MONT_FIELD_DECODE 133 +#define EC_F_EC_GFP_MONT_FIELD_ENCODE 134 +#define EC_F_EC_GFP_MONT_FIELD_MUL 131 +#define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 209 +#define EC_F_EC_GFP_MONT_FIELD_SQR 132 +#define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 189 +#define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP 135 +#define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE 225 +#define EC_F_EC_GFP_NISTP224_POINTS_MUL 228 +#define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 226 +#define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE 230 +#define EC_F_EC_GFP_NISTP256_POINTS_MUL 231 +#define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 232 +#define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE 233 +#define EC_F_EC_GFP_NISTP521_POINTS_MUL 234 +#define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 235 +#define EC_F_EC_GFP_NIST_FIELD_MUL 200 +#define EC_F_EC_GFP_NIST_FIELD_SQR 201 +#define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 202 +#define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 165 +#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 166 +#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP 100 +#define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR 101 +#define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 102 +#define EC_F_EC_GFP_SIMPLE_OCT2POINT 103 +#define EC_F_EC_GFP_SIMPLE_POINT2OCT 104 +#define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 137 +#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 167 +#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105 +#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 168 +#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128 +#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 169 +#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129 +#define EC_F_EC_GROUP_CHECK 170 +#define EC_F_EC_GROUP_CHECK_DISCRIMINANT 171 +#define EC_F_EC_GROUP_COPY 106 +#define EC_F_EC_GROUP_GET0_GENERATOR 139 +#define EC_F_EC_GROUP_GET_COFACTOR 140 +#define EC_F_EC_GROUP_GET_CURVE_GF2M 172 +#define EC_F_EC_GROUP_GET_CURVE_GFP 130 +#define EC_F_EC_GROUP_GET_DEGREE 173 +#define EC_F_EC_GROUP_GET_ORDER 141 +#define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 193 +#define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 194 +#define EC_F_EC_GROUP_NEW 108 +#define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 174 +#define EC_F_EC_GROUP_NEW_FROM_DATA 175 +#define EC_F_EC_GROUP_PRECOMPUTE_MULT 142 +#define EC_F_EC_GROUP_SET_CURVE_GF2M 176 +#define EC_F_EC_GROUP_SET_CURVE_GFP 109 +#define EC_F_EC_GROUP_SET_EXTRA_DATA 110 +#define EC_F_EC_GROUP_SET_GENERATOR 111 +#define EC_F_EC_KEY_CHECK_KEY 177 +#define EC_F_EC_KEY_COPY 178 +#define EC_F_EC_KEY_GENERATE_KEY 179 +#define EC_F_EC_KEY_NEW 182 +#define EC_F_EC_KEY_PRINT 180 +#define EC_F_EC_KEY_PRINT_FP 181 +#define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES 229 +#define EC_F_EC_POINTS_MAKE_AFFINE 136 +#define EC_F_EC_POINT_ADD 112 +#define EC_F_EC_POINT_CMP 113 +#define EC_F_EC_POINT_COPY 114 +#define EC_F_EC_POINT_DBL 115 +#define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 183 +#define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116 +#define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117 +#define EC_F_EC_POINT_INVERT 210 +#define EC_F_EC_POINT_IS_AT_INFINITY 118 +#define EC_F_EC_POINT_IS_ON_CURVE 119 +#define EC_F_EC_POINT_MAKE_AFFINE 120 +#define EC_F_EC_POINT_MUL 184 +#define EC_F_EC_POINT_NEW 121 +#define EC_F_EC_POINT_OCT2POINT 122 +#define EC_F_EC_POINT_POINT2OCT 123 +#define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 185 +#define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124 +#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 186 +#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125 +#define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126 +#define EC_F_EC_POINT_SET_TO_INFINITY 127 +#define EC_F_EC_PRE_COMP_DUP 207 +#define EC_F_EC_PRE_COMP_NEW 196 +#define EC_F_EC_WNAF_MUL 187 +#define EC_F_EC_WNAF_PRECOMPUTE_MULT 188 +#define EC_F_I2D_ECPARAMETERS 190 +#define EC_F_I2D_ECPKPARAMETERS 191 +#define EC_F_I2D_ECPRIVATEKEY 192 +#define EC_F_I2O_ECPUBLICKEY 151 +#define EC_F_NISTP224_PRE_COMP_NEW 227 +#define EC_F_NISTP256_PRE_COMP_NEW 236 +#define EC_F_NISTP521_PRE_COMP_NEW 237 +#define EC_F_O2I_ECPUBLICKEY 152 +#define EC_F_OLD_EC_PRIV_DECODE 222 +#define EC_F_PKEY_EC_CTRL 197 +#define EC_F_PKEY_EC_CTRL_STR 198 +#define EC_F_PKEY_EC_DERIVE 217 +#define EC_F_PKEY_EC_KEYGEN 199 +#define EC_F_PKEY_EC_PARAMGEN 219 +#define EC_F_PKEY_EC_SIGN 218 + +/* Reason codes. */ +#define EC_R_ASN1_ERROR 115 +#define EC_R_ASN1_UNKNOWN_FIELD 116 +#define EC_R_BIGNUM_OUT_OF_RANGE 144 +#define EC_R_BUFFER_TOO_SMALL 100 +#define EC_R_COORDINATES_OUT_OF_RANGE 146 +#define EC_R_D2I_ECPKPARAMETERS_FAILURE 117 +#define EC_R_DECODE_ERROR 142 +#define EC_R_DISCRIMINANT_IS_ZERO 118 +#define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119 +#define EC_R_FIELD_TOO_LARGE 143 +#define EC_R_GF2M_NOT_SUPPORTED 147 +#define EC_R_GROUP2PKPARAMETERS_FAILURE 120 +#define EC_R_I2D_ECPKPARAMETERS_FAILURE 121 +#define EC_R_INCOMPATIBLE_OBJECTS 101 +#define EC_R_INVALID_ARGUMENT 112 +#define EC_R_INVALID_COMPRESSED_POINT 110 +#define EC_R_INVALID_COMPRESSION_BIT 109 +#define EC_R_INVALID_CURVE 141 +#define EC_R_INVALID_DIGEST_TYPE 138 +#define EC_R_INVALID_ENCODING 102 +#define EC_R_INVALID_FIELD 103 +#define EC_R_INVALID_FORM 104 +#define EC_R_INVALID_GROUP_ORDER 122 +#define EC_R_INVALID_PENTANOMIAL_BASIS 132 +#define EC_R_INVALID_PRIVATE_KEY 123 +#define EC_R_INVALID_TRINOMIAL_BASIS 137 +#define EC_R_KEYS_NOT_SET 140 +#define EC_R_MISSING_PARAMETERS 124 +#define EC_R_MISSING_PRIVATE_KEY 125 +#define EC_R_NOT_A_NIST_PRIME 135 +#define EC_R_NOT_A_SUPPORTED_NIST_PRIME 136 +#define EC_R_NOT_IMPLEMENTED 126 +#define EC_R_NOT_INITIALIZED 111 +#define EC_R_NO_FIELD_MOD 133 +#define EC_R_NO_PARAMETERS_SET 139 +#define EC_R_PASSED_NULL_PARAMETER 134 +#define EC_R_PKPARAMETERS2GROUP_FAILURE 127 +#define EC_R_POINT_AT_INFINITY 106 +#define EC_R_POINT_IS_NOT_ON_CURVE 107 +#define EC_R_SLOT_FULL 108 +#define EC_R_UNDEFINED_GENERATOR 113 +#define EC_R_UNDEFINED_ORDER 128 +#define EC_R_UNKNOWN_GROUP 129 +#define EC_R_UNKNOWN_ORDER 114 +#define EC_R_UNSUPPORTED_FIELD 131 +#define EC_R_WRONG_CURVE_PARAMETERS 145 +#define EC_R_WRONG_ORDER 130 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libs/openssl/crypto/ec/ec2_mult.c b/libs/openssl/crypto/ec/ec2_mult.c new file mode 100644 index 00000000..1c575dc4 --- /dev/null +++ b/libs/openssl/crypto/ec/ec2_mult.c @@ -0,0 +1,395 @@ +/* crypto/ec/ec2_mult.c */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * The Elliptic Curve Public-Key Crypto Library (ECC Code) included + * herein is developed by SUN MICROSYSTEMS, INC., and is contributed + * to the OpenSSL project. + * + * The ECC Code is licensed pursuant to the OpenSSL open source + * license provided below. + * + * The software is originally written by Sheueling Chang Shantz and + * Douglas Stebila of Sun Microsystems Laboratories. + * + */ +/* ==================================================================== + * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include + +#include "ec_lcl.h" + +#ifndef OPENSSL_NO_EC2M + + +/* Compute the x-coordinate x/z for the point 2*(x/z) in Montgomery projective + * coordinates. + * Uses algorithm Mdouble in appendix of + * Lopez, J. and Dahab, R. "Fast multiplication on elliptic curves over + * GF(2^m) without precomputation" (CHES '99, LNCS 1717). + * modified to not require precomputation of c=b^{2^{m-1}}. + */ +static int gf2m_Mdouble(const EC_GROUP *group, BIGNUM *x, BIGNUM *z, BN_CTX *ctx) + { + BIGNUM *t1; + int ret = 0; + + /* Since Mdouble is static we can guarantee that ctx != NULL. */ + BN_CTX_start(ctx); + t1 = BN_CTX_get(ctx); + if (t1 == NULL) goto err; + + if (!group->meth->field_sqr(group, x, x, ctx)) goto err; + if (!group->meth->field_sqr(group, t1, z, ctx)) goto err; + if (!group->meth->field_mul(group, z, x, t1, ctx)) goto err; + if (!group->meth->field_sqr(group, x, x, ctx)) goto err; + if (!group->meth->field_sqr(group, t1, t1, ctx)) goto err; + if (!group->meth->field_mul(group, t1, &group->b, t1, ctx)) goto err; + if (!BN_GF2m_add(x, x, t1)) goto err; + + ret = 1; + + err: + BN_CTX_end(ctx); + return ret; + } + +/* Compute the x-coordinate x1/z1 for the point (x1/z1)+(x2/x2) in Montgomery + * projective coordinates. + * Uses algorithm Madd in appendix of + * Lopez, J. and Dahab, R. "Fast multiplication on elliptic curves over + * GF(2^m) without precomputation" (CHES '99, LNCS 1717). + */ +static int gf2m_Madd(const EC_GROUP *group, const BIGNUM *x, BIGNUM *x1, BIGNUM *z1, + const BIGNUM *x2, const BIGNUM *z2, BN_CTX *ctx) + { + BIGNUM *t1, *t2; + int ret = 0; + + /* Since Madd is static we can guarantee that ctx != NULL. */ + BN_CTX_start(ctx); + t1 = BN_CTX_get(ctx); + t2 = BN_CTX_get(ctx); + if (t2 == NULL) goto err; + + if (!BN_copy(t1, x)) goto err; + if (!group->meth->field_mul(group, x1, x1, z2, ctx)) goto err; + if (!group->meth->field_mul(group, z1, z1, x2, ctx)) goto err; + if (!group->meth->field_mul(group, t2, x1, z1, ctx)) goto err; + if (!BN_GF2m_add(z1, z1, x1)) goto err; + if (!group->meth->field_sqr(group, z1, z1, ctx)) goto err; + if (!group->meth->field_mul(group, x1, z1, t1, ctx)) goto err; + if (!BN_GF2m_add(x1, x1, t2)) goto err; + + ret = 1; + + err: + BN_CTX_end(ctx); + return ret; + } + +/* Compute the x, y affine coordinates from the point (x1, z1) (x2, z2) + * using Montgomery point multiplication algorithm Mxy() in appendix of + * Lopez, J. and Dahab, R. "Fast multiplication on elliptic curves over + * GF(2^m) without precomputation" (CHES '99, LNCS 1717). + * Returns: + * 0 on error + * 1 if return value should be the point at infinity + * 2 otherwise + */ +static int gf2m_Mxy(const EC_GROUP *group, const BIGNUM *x, const BIGNUM *y, BIGNUM *x1, + BIGNUM *z1, BIGNUM *x2, BIGNUM *z2, BN_CTX *ctx) + { + BIGNUM *t3, *t4, *t5; + int ret = 0; + + if (BN_is_zero(z1)) + { + BN_zero(x2); + BN_zero(z2); + return 1; + } + + if (BN_is_zero(z2)) + { + if (!BN_copy(x2, x)) return 0; + if (!BN_GF2m_add(z2, x, y)) return 0; + return 2; + } + + /* Since Mxy is static we can guarantee that ctx != NULL. */ + BN_CTX_start(ctx); + t3 = BN_CTX_get(ctx); + t4 = BN_CTX_get(ctx); + t5 = BN_CTX_get(ctx); + if (t5 == NULL) goto err; + + if (!BN_one(t5)) goto err; + + if (!group->meth->field_mul(group, t3, z1, z2, ctx)) goto err; + + if (!group->meth->field_mul(group, z1, z1, x, ctx)) goto err; + if (!BN_GF2m_add(z1, z1, x1)) goto err; + if (!group->meth->field_mul(group, z2, z2, x, ctx)) goto err; + if (!group->meth->field_mul(group, x1, z2, x1, ctx)) goto err; + if (!BN_GF2m_add(z2, z2, x2)) goto err; + + if (!group->meth->field_mul(group, z2, z2, z1, ctx)) goto err; + if (!group->meth->field_sqr(group, t4, x, ctx)) goto err; + if (!BN_GF2m_add(t4, t4, y)) goto err; + if (!group->meth->field_mul(group, t4, t4, t3, ctx)) goto err; + if (!BN_GF2m_add(t4, t4, z2)) goto err; + + if (!group->meth->field_mul(group, t3, t3, x, ctx)) goto err; + if (!group->meth->field_div(group, t3, t5, t3, ctx)) goto err; + if (!group->meth->field_mul(group, t4, t3, t4, ctx)) goto err; + if (!group->meth->field_mul(group, x2, x1, t3, ctx)) goto err; + if (!BN_GF2m_add(z2, x2, x)) goto err; + + if (!group->meth->field_mul(group, z2, z2, t4, ctx)) goto err; + if (!BN_GF2m_add(z2, z2, y)) goto err; + + ret = 2; + + err: + BN_CTX_end(ctx); + return ret; + } + + +/* Computes scalar*point and stores the result in r. + * point can not equal r. + * Uses a modified algorithm 2P of + * Lopez, J. and Dahab, R. "Fast multiplication on elliptic curves over + * GF(2^m) without precomputation" (CHES '99, LNCS 1717). + * + * To protect against side-channel attack the function uses constant time swap, + * avoiding conditional branches. + */ +static int ec_GF2m_montgomery_point_multiply(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, + const EC_POINT *point, BN_CTX *ctx) + { + BIGNUM *x1, *x2, *z1, *z2; + int ret = 0, i; + BN_ULONG mask,word; + + if (r == point) + { + ECerr(EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY, EC_R_INVALID_ARGUMENT); + return 0; + } + + /* if result should be point at infinity */ + if ((scalar == NULL) || BN_is_zero(scalar) || (point == NULL) || + EC_POINT_is_at_infinity(group, point)) + { + return EC_POINT_set_to_infinity(group, r); + } + + /* only support affine coordinates */ + if (!point->Z_is_one) return 0; + + /* Since point_multiply is static we can guarantee that ctx != NULL. */ + BN_CTX_start(ctx); + x1 = BN_CTX_get(ctx); + z1 = BN_CTX_get(ctx); + if (z1 == NULL) goto err; + + x2 = &r->X; + z2 = &r->Y; + + bn_wexpand(x1, group->field.top); + bn_wexpand(z1, group->field.top); + bn_wexpand(x2, group->field.top); + bn_wexpand(z2, group->field.top); + + if (!BN_GF2m_mod_arr(x1, &point->X, group->poly)) goto err; /* x1 = x */ + if (!BN_one(z1)) goto err; /* z1 = 1 */ + if (!group->meth->field_sqr(group, z2, x1, ctx)) goto err; /* z2 = x1^2 = x^2 */ + if (!group->meth->field_sqr(group, x2, z2, ctx)) goto err; + if (!BN_GF2m_add(x2, x2, &group->b)) goto err; /* x2 = x^4 + b */ + + /* find top most bit and go one past it */ + i = scalar->top - 1; + mask = BN_TBIT; + word = scalar->d[i]; + while (!(word & mask)) mask >>= 1; + mask >>= 1; + /* if top most bit was at word break, go to next word */ + if (!mask) + { + i--; + mask = BN_TBIT; + } + + for (; i >= 0; i--) + { + word = scalar->d[i]; + while (mask) + { + BN_consttime_swap(word & mask, x1, x2, group->field.top); + BN_consttime_swap(word & mask, z1, z2, group->field.top); + if (!gf2m_Madd(group, &point->X, x2, z2, x1, z1, ctx)) goto err; + if (!gf2m_Mdouble(group, x1, z1, ctx)) goto err; + BN_consttime_swap(word & mask, x1, x2, group->field.top); + BN_consttime_swap(word & mask, z1, z2, group->field.top); + mask >>= 1; + } + mask = BN_TBIT; + } + + /* convert out of "projective" coordinates */ + i = gf2m_Mxy(group, &point->X, &point->Y, x1, z1, x2, z2, ctx); + if (i == 0) goto err; + else if (i == 1) + { + if (!EC_POINT_set_to_infinity(group, r)) goto err; + } + else + { + if (!BN_one(&r->Z)) goto err; + r->Z_is_one = 1; + } + + /* GF(2^m) field elements should always have BIGNUM::neg = 0 */ + BN_set_negative(&r->X, 0); + BN_set_negative(&r->Y, 0); + + ret = 1; + + err: + BN_CTX_end(ctx); + return ret; + } + + +/* Computes the sum + * scalar*group->generator + scalars[0]*points[0] + ... + scalars[num-1]*points[num-1] + * gracefully ignoring NULL scalar values. + */ +int ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, + size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx) + { + BN_CTX *new_ctx = NULL; + int ret = 0; + size_t i; + EC_POINT *p=NULL; + EC_POINT *acc = NULL; + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return 0; + } + + /* This implementation is more efficient than the wNAF implementation for 2 + * or fewer points. Use the ec_wNAF_mul implementation for 3 or more points, + * or if we can perform a fast multiplication based on precomputation. + */ + if ((scalar && (num > 1)) || (num > 2) || (num == 0 && EC_GROUP_have_precompute_mult(group))) + { + ret = ec_wNAF_mul(group, r, scalar, num, points, scalars, ctx); + goto err; + } + + if ((p = EC_POINT_new(group)) == NULL) goto err; + if ((acc = EC_POINT_new(group)) == NULL) goto err; + + if (!EC_POINT_set_to_infinity(group, acc)) goto err; + + if (scalar) + { + if (!ec_GF2m_montgomery_point_multiply(group, p, scalar, group->generator, ctx)) goto err; + if (BN_is_negative(scalar)) + if (!group->meth->invert(group, p, ctx)) goto err; + if (!group->meth->add(group, acc, acc, p, ctx)) goto err; + } + + for (i = 0; i < num; i++) + { + if (!ec_GF2m_montgomery_point_multiply(group, p, scalars[i], points[i], ctx)) goto err; + if (BN_is_negative(scalars[i])) + if (!group->meth->invert(group, p, ctx)) goto err; + if (!group->meth->add(group, acc, acc, p, ctx)) goto err; + } + + if (!EC_POINT_copy(r, acc)) goto err; + + ret = 1; + + err: + if (p) EC_POINT_free(p); + if (acc) EC_POINT_free(acc); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return ret; + } + + +/* Precomputation for point multiplication: fall back to wNAF methods + * because ec_GF2m_simple_mul() uses ec_wNAF_mul() if appropriate */ + +int ec_GF2m_precompute_mult(EC_GROUP *group, BN_CTX *ctx) + { + return ec_wNAF_precompute_mult(group, ctx); + } + +int ec_GF2m_have_precompute_mult(const EC_GROUP *group) + { + return ec_wNAF_have_precompute_mult(group); + } + +#endif diff --git a/libs/openssl/crypto/ec/ec2_oct.c b/libs/openssl/crypto/ec/ec2_oct.c new file mode 100644 index 00000000..f1d75e5d --- /dev/null +++ b/libs/openssl/crypto/ec/ec2_oct.c @@ -0,0 +1,407 @@ +/* crypto/ec/ec2_oct.c */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * The Elliptic Curve Public-Key Crypto Library (ECC Code) included + * herein is developed by SUN MICROSYSTEMS, INC., and is contributed + * to the OpenSSL project. + * + * The ECC Code is licensed pursuant to the OpenSSL open source + * license provided below. + * + * The software is originally written by Sheueling Chang Shantz and + * Douglas Stebila of Sun Microsystems Laboratories. + * + */ +/* ==================================================================== + * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include + +#include "ec_lcl.h" + +#ifndef OPENSSL_NO_EC2M + +/* Calculates and sets the affine coordinates of an EC_POINT from the given + * compressed coordinates. Uses algorithm 2.3.4 of SEC 1. + * Note that the simple implementation only uses affine coordinates. + * + * The method is from the following publication: + * + * Harper, Menezes, Vanstone: + * "Public-Key Cryptosystems with Very Small Key Lengths", + * EUROCRYPT '92, Springer-Verlag LNCS 658, + * published February 1993 + * + * US Patents 6,141,420 and 6,618,483 (Vanstone, Mullin, Agnew) describe + * the same method, but claim no priority date earlier than July 29, 1994 + * (and additionally fail to cite the EUROCRYPT '92 publication as prior art). + */ +int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point, + const BIGNUM *x_, int y_bit, BN_CTX *ctx) + { + BN_CTX *new_ctx = NULL; + BIGNUM *tmp, *x, *y, *z; + int ret = 0, z0; + + /* clear error queue */ + ERR_clear_error(); + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return 0; + } + + y_bit = (y_bit != 0) ? 1 : 0; + + BN_CTX_start(ctx); + tmp = BN_CTX_get(ctx); + x = BN_CTX_get(ctx); + y = BN_CTX_get(ctx); + z = BN_CTX_get(ctx); + if (z == NULL) goto err; + + if (!BN_GF2m_mod_arr(x, x_, group->poly)) goto err; + if (BN_is_zero(x)) + { + if (!BN_GF2m_mod_sqrt_arr(y, &group->b, group->poly, ctx)) goto err; + } + else + { + if (!group->meth->field_sqr(group, tmp, x, ctx)) goto err; + if (!group->meth->field_div(group, tmp, &group->b, tmp, ctx)) goto err; + if (!BN_GF2m_add(tmp, &group->a, tmp)) goto err; + if (!BN_GF2m_add(tmp, x, tmp)) goto err; + if (!BN_GF2m_mod_solve_quad_arr(z, tmp, group->poly, ctx)) + { + unsigned long err = ERR_peek_last_error(); + + if (ERR_GET_LIB(err) == ERR_LIB_BN && ERR_GET_REASON(err) == BN_R_NO_SOLUTION) + { + ERR_clear_error(); + ECerr(EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES, EC_R_INVALID_COMPRESSED_POINT); + } + else + ECerr(EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES, ERR_R_BN_LIB); + goto err; + } + z0 = (BN_is_odd(z)) ? 1 : 0; + if (!group->meth->field_mul(group, y, x, z, ctx)) goto err; + if (z0 != y_bit) + { + if (!BN_GF2m_add(y, y, x)) goto err; + } + } + + if (!EC_POINT_set_affine_coordinates_GF2m(group, point, x, y, ctx)) goto err; + + ret = 1; + + err: + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return ret; + } + + +/* Converts an EC_POINT to an octet string. + * If buf is NULL, the encoded length will be returned. + * If the length len of buf is smaller than required an error will be returned. + */ +size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form, + unsigned char *buf, size_t len, BN_CTX *ctx) + { + size_t ret; + BN_CTX *new_ctx = NULL; + int used_ctx = 0; + BIGNUM *x, *y, *yxi; + size_t field_len, i, skip; + + if ((form != POINT_CONVERSION_COMPRESSED) + && (form != POINT_CONVERSION_UNCOMPRESSED) + && (form != POINT_CONVERSION_HYBRID)) + { + ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, EC_R_INVALID_FORM); + goto err; + } + + if (EC_POINT_is_at_infinity(group, point)) + { + /* encodes to a single 0 octet */ + if (buf != NULL) + { + if (len < 1) + { + ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, EC_R_BUFFER_TOO_SMALL); + return 0; + } + buf[0] = 0; + } + return 1; + } + + + /* ret := required output buffer length */ + field_len = (EC_GROUP_get_degree(group) + 7) / 8; + ret = (form == POINT_CONVERSION_COMPRESSED) ? 1 + field_len : 1 + 2*field_len; + + /* if 'buf' is NULL, just return required length */ + if (buf != NULL) + { + if (len < ret) + { + ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, EC_R_BUFFER_TOO_SMALL); + goto err; + } + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return 0; + } + + BN_CTX_start(ctx); + used_ctx = 1; + x = BN_CTX_get(ctx); + y = BN_CTX_get(ctx); + yxi = BN_CTX_get(ctx); + if (yxi == NULL) goto err; + + if (!EC_POINT_get_affine_coordinates_GF2m(group, point, x, y, ctx)) goto err; + + buf[0] = form; + if ((form != POINT_CONVERSION_UNCOMPRESSED) && !BN_is_zero(x)) + { + if (!group->meth->field_div(group, yxi, y, x, ctx)) goto err; + if (BN_is_odd(yxi)) buf[0]++; + } + + i = 1; + + skip = field_len - BN_num_bytes(x); + if (skip > field_len) + { + ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR); + goto err; + } + while (skip > 0) + { + buf[i++] = 0; + skip--; + } + skip = BN_bn2bin(x, buf + i); + i += skip; + if (i != 1 + field_len) + { + ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR); + goto err; + } + + if (form == POINT_CONVERSION_UNCOMPRESSED || form == POINT_CONVERSION_HYBRID) + { + skip = field_len - BN_num_bytes(y); + if (skip > field_len) + { + ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR); + goto err; + } + while (skip > 0) + { + buf[i++] = 0; + skip--; + } + skip = BN_bn2bin(y, buf + i); + i += skip; + } + + if (i != ret) + { + ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR); + goto err; + } + } + + if (used_ctx) + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return ret; + + err: + if (used_ctx) + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return 0; + } + + +/* Converts an octet string representation to an EC_POINT. + * Note that the simple implementation only uses affine coordinates. + */ +int ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point, + const unsigned char *buf, size_t len, BN_CTX *ctx) + { + point_conversion_form_t form; + int y_bit; + BN_CTX *new_ctx = NULL; + BIGNUM *x, *y, *yxi; + size_t field_len, enc_len; + int ret = 0; + + if (len == 0) + { + ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_BUFFER_TOO_SMALL); + return 0; + } + form = buf[0]; + y_bit = form & 1; + form = form & ~1U; + if ((form != 0) && (form != POINT_CONVERSION_COMPRESSED) + && (form != POINT_CONVERSION_UNCOMPRESSED) + && (form != POINT_CONVERSION_HYBRID)) + { + ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); + return 0; + } + if ((form == 0 || form == POINT_CONVERSION_UNCOMPRESSED) && y_bit) + { + ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); + return 0; + } + + if (form == 0) + { + if (len != 1) + { + ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); + return 0; + } + + return EC_POINT_set_to_infinity(group, point); + } + + field_len = (EC_GROUP_get_degree(group) + 7) / 8; + enc_len = (form == POINT_CONVERSION_COMPRESSED) ? 1 + field_len : 1 + 2*field_len; + + if (len != enc_len) + { + ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); + return 0; + } + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return 0; + } + + BN_CTX_start(ctx); + x = BN_CTX_get(ctx); + y = BN_CTX_get(ctx); + yxi = BN_CTX_get(ctx); + if (yxi == NULL) goto err; + + if (!BN_bin2bn(buf + 1, field_len, x)) goto err; + if (BN_ucmp(x, &group->field) >= 0) + { + ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); + goto err; + } + + if (form == POINT_CONVERSION_COMPRESSED) + { + if (!EC_POINT_set_compressed_coordinates_GF2m(group, point, x, y_bit, ctx)) goto err; + } + else + { + if (!BN_bin2bn(buf + 1 + field_len, field_len, y)) goto err; + if (BN_ucmp(y, &group->field) >= 0) + { + ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); + goto err; + } + if (form == POINT_CONVERSION_HYBRID) + { + if (!group->meth->field_div(group, yxi, y, x, ctx)) goto err; + if (y_bit != BN_is_odd(yxi)) + { + ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); + goto err; + } + } + + if (!EC_POINT_set_affine_coordinates_GF2m(group, point, x, y, ctx)) goto err; + } + + if (!EC_POINT_is_on_curve(group, point, ctx)) /* test required by X9.62 */ + { + ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_POINT_IS_NOT_ON_CURVE); + goto err; + } + + ret = 1; + + err: + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return ret; + } +#endif diff --git a/libs/openssl/crypto/ec/ec2_smpl.c b/libs/openssl/crypto/ec/ec2_smpl.c new file mode 100644 index 00000000..e0e59c7d --- /dev/null +++ b/libs/openssl/crypto/ec/ec2_smpl.c @@ -0,0 +1,719 @@ +/* crypto/ec/ec2_smpl.c */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * The Elliptic Curve Public-Key Crypto Library (ECC Code) included + * herein is developed by SUN MICROSYSTEMS, INC., and is contributed + * to the OpenSSL project. + * + * The ECC Code is licensed pursuant to the OpenSSL open source + * license provided below. + * + * The software is originally written by Sheueling Chang Shantz and + * Douglas Stebila of Sun Microsystems Laboratories. + * + */ +/* ==================================================================== + * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include + +#include "ec_lcl.h" + +#ifndef OPENSSL_NO_EC2M + +#ifdef OPENSSL_FIPS +#include +#endif + + +const EC_METHOD *EC_GF2m_simple_method(void) + { +#ifdef OPENSSL_FIPS + return fips_ec_gf2m_simple_method(); +#else + static const EC_METHOD ret = { + EC_FLAGS_DEFAULT_OCT, + NID_X9_62_characteristic_two_field, + ec_GF2m_simple_group_init, + ec_GF2m_simple_group_finish, + ec_GF2m_simple_group_clear_finish, + ec_GF2m_simple_group_copy, + ec_GF2m_simple_group_set_curve, + ec_GF2m_simple_group_get_curve, + ec_GF2m_simple_group_get_degree, + ec_GF2m_simple_group_check_discriminant, + ec_GF2m_simple_point_init, + ec_GF2m_simple_point_finish, + ec_GF2m_simple_point_clear_finish, + ec_GF2m_simple_point_copy, + ec_GF2m_simple_point_set_to_infinity, + 0 /* set_Jprojective_coordinates_GFp */, + 0 /* get_Jprojective_coordinates_GFp */, + ec_GF2m_simple_point_set_affine_coordinates, + ec_GF2m_simple_point_get_affine_coordinates, + 0,0,0, + ec_GF2m_simple_add, + ec_GF2m_simple_dbl, + ec_GF2m_simple_invert, + ec_GF2m_simple_is_at_infinity, + ec_GF2m_simple_is_on_curve, + ec_GF2m_simple_cmp, + ec_GF2m_simple_make_affine, + ec_GF2m_simple_points_make_affine, + + /* the following three method functions are defined in ec2_mult.c */ + ec_GF2m_simple_mul, + ec_GF2m_precompute_mult, + ec_GF2m_have_precompute_mult, + + ec_GF2m_simple_field_mul, + ec_GF2m_simple_field_sqr, + ec_GF2m_simple_field_div, + 0 /* field_encode */, + 0 /* field_decode */, + 0 /* field_set_to_one */ }; + + return &ret; +#endif + } + + +/* Initialize a GF(2^m)-based EC_GROUP structure. + * Note that all other members are handled by EC_GROUP_new. + */ +int ec_GF2m_simple_group_init(EC_GROUP *group) + { + BN_init(&group->field); + BN_init(&group->a); + BN_init(&group->b); + return 1; + } + + +/* Free a GF(2^m)-based EC_GROUP structure. + * Note that all other members are handled by EC_GROUP_free. + */ +void ec_GF2m_simple_group_finish(EC_GROUP *group) + { + BN_free(&group->field); + BN_free(&group->a); + BN_free(&group->b); + } + + +/* Clear and free a GF(2^m)-based EC_GROUP structure. + * Note that all other members are handled by EC_GROUP_clear_free. + */ +void ec_GF2m_simple_group_clear_finish(EC_GROUP *group) + { + BN_clear_free(&group->field); + BN_clear_free(&group->a); + BN_clear_free(&group->b); + group->poly[0] = 0; + group->poly[1] = 0; + group->poly[2] = 0; + group->poly[3] = 0; + group->poly[4] = 0; + group->poly[5] = -1; + } + + +/* Copy a GF(2^m)-based EC_GROUP structure. + * Note that all other members are handled by EC_GROUP_copy. + */ +int ec_GF2m_simple_group_copy(EC_GROUP *dest, const EC_GROUP *src) + { + int i; + if (!BN_copy(&dest->field, &src->field)) return 0; + if (!BN_copy(&dest->a, &src->a)) return 0; + if (!BN_copy(&dest->b, &src->b)) return 0; + dest->poly[0] = src->poly[0]; + dest->poly[1] = src->poly[1]; + dest->poly[2] = src->poly[2]; + dest->poly[3] = src->poly[3]; + dest->poly[4] = src->poly[4]; + dest->poly[5] = src->poly[5]; + if (bn_wexpand(&dest->a, (int)(dest->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) return 0; + if (bn_wexpand(&dest->b, (int)(dest->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) return 0; + for (i = dest->a.top; i < dest->a.dmax; i++) dest->a.d[i] = 0; + for (i = dest->b.top; i < dest->b.dmax; i++) dest->b.d[i] = 0; + return 1; + } + + +/* Set the curve parameters of an EC_GROUP structure. */ +int ec_GF2m_simple_group_set_curve(EC_GROUP *group, + const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) + { + int ret = 0, i; + + /* group->field */ + if (!BN_copy(&group->field, p)) goto err; + i = BN_GF2m_poly2arr(&group->field, group->poly, 6) - 1; + if ((i != 5) && (i != 3)) + { + ECerr(EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE, EC_R_UNSUPPORTED_FIELD); + goto err; + } + + /* group->a */ + if (!BN_GF2m_mod_arr(&group->a, a, group->poly)) goto err; + if(bn_wexpand(&group->a, (int)(group->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) goto err; + for (i = group->a.top; i < group->a.dmax; i++) group->a.d[i] = 0; + + /* group->b */ + if (!BN_GF2m_mod_arr(&group->b, b, group->poly)) goto err; + if(bn_wexpand(&group->b, (int)(group->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) goto err; + for (i = group->b.top; i < group->b.dmax; i++) group->b.d[i] = 0; + + ret = 1; + err: + return ret; + } + + +/* Get the curve parameters of an EC_GROUP structure. + * If p, a, or b are NULL then there values will not be set but the method will return with success. + */ +int ec_GF2m_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx) + { + int ret = 0; + + if (p != NULL) + { + if (!BN_copy(p, &group->field)) return 0; + } + + if (a != NULL) + { + if (!BN_copy(a, &group->a)) goto err; + } + + if (b != NULL) + { + if (!BN_copy(b, &group->b)) goto err; + } + + ret = 1; + + err: + return ret; + } + + +/* Gets the degree of the field. For a curve over GF(2^m) this is the value m. */ +int ec_GF2m_simple_group_get_degree(const EC_GROUP *group) + { + return BN_num_bits(&group->field)-1; + } + + +/* Checks the discriminant of the curve. + * y^2 + x*y = x^3 + a*x^2 + b is an elliptic curve <=> b != 0 (mod p) + */ +int ec_GF2m_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx) + { + int ret = 0; + BIGNUM *b; + BN_CTX *new_ctx = NULL; + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + { + ECerr(EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT, ERR_R_MALLOC_FAILURE); + goto err; + } + } + BN_CTX_start(ctx); + b = BN_CTX_get(ctx); + if (b == NULL) goto err; + + if (!BN_GF2m_mod_arr(b, &group->b, group->poly)) goto err; + + /* check the discriminant: + * y^2 + x*y = x^3 + a*x^2 + b is an elliptic curve <=> b != 0 (mod p) + */ + if (BN_is_zero(b)) goto err; + + ret = 1; + +err: + if (ctx != NULL) + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return ret; + } + + +/* Initializes an EC_POINT. */ +int ec_GF2m_simple_point_init(EC_POINT *point) + { + BN_init(&point->X); + BN_init(&point->Y); + BN_init(&point->Z); + return 1; + } + + +/* Frees an EC_POINT. */ +void ec_GF2m_simple_point_finish(EC_POINT *point) + { + BN_free(&point->X); + BN_free(&point->Y); + BN_free(&point->Z); + } + + +/* Clears and frees an EC_POINT. */ +void ec_GF2m_simple_point_clear_finish(EC_POINT *point) + { + BN_clear_free(&point->X); + BN_clear_free(&point->Y); + BN_clear_free(&point->Z); + point->Z_is_one = 0; + } + + +/* Copy the contents of one EC_POINT into another. Assumes dest is initialized. */ +int ec_GF2m_simple_point_copy(EC_POINT *dest, const EC_POINT *src) + { + if (!BN_copy(&dest->X, &src->X)) return 0; + if (!BN_copy(&dest->Y, &src->Y)) return 0; + if (!BN_copy(&dest->Z, &src->Z)) return 0; + dest->Z_is_one = src->Z_is_one; + + return 1; + } + + +/* Set an EC_POINT to the point at infinity. + * A point at infinity is represented by having Z=0. + */ +int ec_GF2m_simple_point_set_to_infinity(const EC_GROUP *group, EC_POINT *point) + { + point->Z_is_one = 0; + BN_zero(&point->Z); + return 1; + } + + +/* Set the coordinates of an EC_POINT using affine coordinates. + * Note that the simple implementation only uses affine coordinates. + */ +int ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *group, EC_POINT *point, + const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx) + { + int ret = 0; + if (x == NULL || y == NULL) + { + ECerr(EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES, ERR_R_PASSED_NULL_PARAMETER); + return 0; + } + + if (!BN_copy(&point->X, x)) goto err; + BN_set_negative(&point->X, 0); + if (!BN_copy(&point->Y, y)) goto err; + BN_set_negative(&point->Y, 0); + if (!BN_copy(&point->Z, BN_value_one())) goto err; + BN_set_negative(&point->Z, 0); + point->Z_is_one = 1; + ret = 1; + + err: + return ret; + } + + +/* Gets the affine coordinates of an EC_POINT. + * Note that the simple implementation only uses affine coordinates. + */ +int ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point, + BIGNUM *x, BIGNUM *y, BN_CTX *ctx) + { + int ret = 0; + + if (EC_POINT_is_at_infinity(group, point)) + { + ECerr(EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES, EC_R_POINT_AT_INFINITY); + return 0; + } + + if (BN_cmp(&point->Z, BN_value_one())) + { + ECerr(EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + if (x != NULL) + { + if (!BN_copy(x, &point->X)) goto err; + BN_set_negative(x, 0); + } + if (y != NULL) + { + if (!BN_copy(y, &point->Y)) goto err; + BN_set_negative(y, 0); + } + ret = 1; + + err: + return ret; + } + +/* Computes a + b and stores the result in r. r could be a or b, a could be b. + * Uses algorithm A.10.2 of IEEE P1363. + */ +int ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx) + { + BN_CTX *new_ctx = NULL; + BIGNUM *x0, *y0, *x1, *y1, *x2, *y2, *s, *t; + int ret = 0; + + if (EC_POINT_is_at_infinity(group, a)) + { + if (!EC_POINT_copy(r, b)) return 0; + return 1; + } + + if (EC_POINT_is_at_infinity(group, b)) + { + if (!EC_POINT_copy(r, a)) return 0; + return 1; + } + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return 0; + } + + BN_CTX_start(ctx); + x0 = BN_CTX_get(ctx); + y0 = BN_CTX_get(ctx); + x1 = BN_CTX_get(ctx); + y1 = BN_CTX_get(ctx); + x2 = BN_CTX_get(ctx); + y2 = BN_CTX_get(ctx); + s = BN_CTX_get(ctx); + t = BN_CTX_get(ctx); + if (t == NULL) goto err; + + if (a->Z_is_one) + { + if (!BN_copy(x0, &a->X)) goto err; + if (!BN_copy(y0, &a->Y)) goto err; + } + else + { + if (!EC_POINT_get_affine_coordinates_GF2m(group, a, x0, y0, ctx)) goto err; + } + if (b->Z_is_one) + { + if (!BN_copy(x1, &b->X)) goto err; + if (!BN_copy(y1, &b->Y)) goto err; + } + else + { + if (!EC_POINT_get_affine_coordinates_GF2m(group, b, x1, y1, ctx)) goto err; + } + + + if (BN_GF2m_cmp(x0, x1)) + { + if (!BN_GF2m_add(t, x0, x1)) goto err; + if (!BN_GF2m_add(s, y0, y1)) goto err; + if (!group->meth->field_div(group, s, s, t, ctx)) goto err; + if (!group->meth->field_sqr(group, x2, s, ctx)) goto err; + if (!BN_GF2m_add(x2, x2, &group->a)) goto err; + if (!BN_GF2m_add(x2, x2, s)) goto err; + if (!BN_GF2m_add(x2, x2, t)) goto err; + } + else + { + if (BN_GF2m_cmp(y0, y1) || BN_is_zero(x1)) + { + if (!EC_POINT_set_to_infinity(group, r)) goto err; + ret = 1; + goto err; + } + if (!group->meth->field_div(group, s, y1, x1, ctx)) goto err; + if (!BN_GF2m_add(s, s, x1)) goto err; + + if (!group->meth->field_sqr(group, x2, s, ctx)) goto err; + if (!BN_GF2m_add(x2, x2, s)) goto err; + if (!BN_GF2m_add(x2, x2, &group->a)) goto err; + } + + if (!BN_GF2m_add(y2, x1, x2)) goto err; + if (!group->meth->field_mul(group, y2, y2, s, ctx)) goto err; + if (!BN_GF2m_add(y2, y2, x2)) goto err; + if (!BN_GF2m_add(y2, y2, y1)) goto err; + + if (!EC_POINT_set_affine_coordinates_GF2m(group, r, x2, y2, ctx)) goto err; + + ret = 1; + + err: + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return ret; + } + + +/* Computes 2 * a and stores the result in r. r could be a. + * Uses algorithm A.10.2 of IEEE P1363. + */ +int ec_GF2m_simple_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx) + { + return ec_GF2m_simple_add(group, r, a, a, ctx); + } + + +int ec_GF2m_simple_invert(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx) + { + if (EC_POINT_is_at_infinity(group, point) || BN_is_zero(&point->Y)) + /* point is its own inverse */ + return 1; + + if (!EC_POINT_make_affine(group, point, ctx)) return 0; + return BN_GF2m_add(&point->Y, &point->X, &point->Y); + } + + +/* Indicates whether the given point is the point at infinity. */ +int ec_GF2m_simple_is_at_infinity(const EC_GROUP *group, const EC_POINT *point) + { + return BN_is_zero(&point->Z); + } + + +/* Determines whether the given EC_POINT is an actual point on the curve defined + * in the EC_GROUP. A point is valid if it satisfies the Weierstrass equation: + * y^2 + x*y = x^3 + a*x^2 + b. + */ +int ec_GF2m_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx) + { + int ret = -1; + BN_CTX *new_ctx = NULL; + BIGNUM *lh, *y2; + int (*field_mul)(const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); + int (*field_sqr)(const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); + + if (EC_POINT_is_at_infinity(group, point)) + return 1; + + field_mul = group->meth->field_mul; + field_sqr = group->meth->field_sqr; + + /* only support affine coordinates */ + if (!point->Z_is_one) return -1; + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return -1; + } + + BN_CTX_start(ctx); + y2 = BN_CTX_get(ctx); + lh = BN_CTX_get(ctx); + if (lh == NULL) goto err; + + /* We have a curve defined by a Weierstrass equation + * y^2 + x*y = x^3 + a*x^2 + b. + * <=> x^3 + a*x^2 + x*y + b + y^2 = 0 + * <=> ((x + a) * x + y ) * x + b + y^2 = 0 + */ + if (!BN_GF2m_add(lh, &point->X, &group->a)) goto err; + if (!field_mul(group, lh, lh, &point->X, ctx)) goto err; + if (!BN_GF2m_add(lh, lh, &point->Y)) goto err; + if (!field_mul(group, lh, lh, &point->X, ctx)) goto err; + if (!BN_GF2m_add(lh, lh, &group->b)) goto err; + if (!field_sqr(group, y2, &point->Y, ctx)) goto err; + if (!BN_GF2m_add(lh, lh, y2)) goto err; + ret = BN_is_zero(lh); + err: + if (ctx) BN_CTX_end(ctx); + if (new_ctx) BN_CTX_free(new_ctx); + return ret; + } + + +/* Indicates whether two points are equal. + * Return values: + * -1 error + * 0 equal (in affine coordinates) + * 1 not equal + */ +int ec_GF2m_simple_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx) + { + BIGNUM *aX, *aY, *bX, *bY; + BN_CTX *new_ctx = NULL; + int ret = -1; + + if (EC_POINT_is_at_infinity(group, a)) + { + return EC_POINT_is_at_infinity(group, b) ? 0 : 1; + } + + if (EC_POINT_is_at_infinity(group, b)) + return 1; + + if (a->Z_is_one && b->Z_is_one) + { + return ((BN_cmp(&a->X, &b->X) == 0) && BN_cmp(&a->Y, &b->Y) == 0) ? 0 : 1; + } + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return -1; + } + + BN_CTX_start(ctx); + aX = BN_CTX_get(ctx); + aY = BN_CTX_get(ctx); + bX = BN_CTX_get(ctx); + bY = BN_CTX_get(ctx); + if (bY == NULL) goto err; + + if (!EC_POINT_get_affine_coordinates_GF2m(group, a, aX, aY, ctx)) goto err; + if (!EC_POINT_get_affine_coordinates_GF2m(group, b, bX, bY, ctx)) goto err; + ret = ((BN_cmp(aX, bX) == 0) && BN_cmp(aY, bY) == 0) ? 0 : 1; + + err: + if (ctx) BN_CTX_end(ctx); + if (new_ctx) BN_CTX_free(new_ctx); + return ret; + } + + +/* Forces the given EC_POINT to internally use affine coordinates. */ +int ec_GF2m_simple_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx) + { + BN_CTX *new_ctx = NULL; + BIGNUM *x, *y; + int ret = 0; + + if (point->Z_is_one || EC_POINT_is_at_infinity(group, point)) + return 1; + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return 0; + } + + BN_CTX_start(ctx); + x = BN_CTX_get(ctx); + y = BN_CTX_get(ctx); + if (y == NULL) goto err; + + if (!EC_POINT_get_affine_coordinates_GF2m(group, point, x, y, ctx)) goto err; + if (!BN_copy(&point->X, x)) goto err; + if (!BN_copy(&point->Y, y)) goto err; + if (!BN_one(&point->Z)) goto err; + + ret = 1; + + err: + if (ctx) BN_CTX_end(ctx); + if (new_ctx) BN_CTX_free(new_ctx); + return ret; + } + + +/* Forces each of the EC_POINTs in the given array to use affine coordinates. */ +int ec_GF2m_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx) + { + size_t i; + + for (i = 0; i < num; i++) + { + if (!group->meth->make_affine(group, points[i], ctx)) return 0; + } + + return 1; + } + + +/* Wrapper to simple binary polynomial field multiplication implementation. */ +int ec_GF2m_simple_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) + { + return BN_GF2m_mod_mul_arr(r, a, b, group->poly, ctx); + } + + +/* Wrapper to simple binary polynomial field squaring implementation. */ +int ec_GF2m_simple_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) + { + return BN_GF2m_mod_sqr_arr(r, a, group->poly, ctx); + } + + +/* Wrapper to simple binary polynomial field division implementation. */ +int ec_GF2m_simple_field_div(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) + { + return BN_GF2m_mod_div(r, a, b, &group->field, ctx); + } + +#endif diff --git a/libs/openssl/crypto/ec/ec_ameth.c b/libs/openssl/crypto/ec/ec_ameth.c new file mode 100644 index 00000000..f715a238 --- /dev/null +++ b/libs/openssl/crypto/ec/ec_ameth.c @@ -0,0 +1,661 @@ +/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL + * project 2006. + */ +/* ==================================================================== + * Copyright (c) 2006 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include +#include "cryptlib.h" +#include +#include +#include +#ifndef OPENSSL_NO_CMS +#include +#endif +#include "asn1_locl.h" + +static int eckey_param2type(int *pptype, void **ppval, EC_KEY *ec_key) + { + const EC_GROUP *group; + int nid; + if (ec_key == NULL || (group = EC_KEY_get0_group(ec_key)) == NULL) + { + ECerr(EC_F_ECKEY_PARAM2TYPE, EC_R_MISSING_PARAMETERS); + return 0; + } + if (EC_GROUP_get_asn1_flag(group) + && (nid = EC_GROUP_get_curve_name(group))) + /* we have a 'named curve' => just set the OID */ + { + *ppval = OBJ_nid2obj(nid); + *pptype = V_ASN1_OBJECT; + } + else /* explicit parameters */ + { + ASN1_STRING *pstr = NULL; + pstr = ASN1_STRING_new(); + if (!pstr) + return 0; + pstr->length = i2d_ECParameters(ec_key, &pstr->data); + if (pstr->length <= 0) + { + ASN1_STRING_free(pstr); + ECerr(EC_F_ECKEY_PARAM2TYPE, ERR_R_EC_LIB); + return 0; + } + *ppval = pstr; + *pptype = V_ASN1_SEQUENCE; + } + return 1; + } + +static int eckey_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) + { + EC_KEY *ec_key = pkey->pkey.ec; + void *pval = NULL; + int ptype; + unsigned char *penc = NULL, *p; + int penclen; + + if (!eckey_param2type(&ptype, &pval, ec_key)) + { + ECerr(EC_F_ECKEY_PUB_ENCODE, ERR_R_EC_LIB); + return 0; + } + penclen = i2o_ECPublicKey(ec_key, NULL); + if (penclen <= 0) + goto err; + penc = OPENSSL_malloc(penclen); + if (!penc) + goto err; + p = penc; + penclen = i2o_ECPublicKey(ec_key, &p); + if (penclen <= 0) + goto err; + if (X509_PUBKEY_set0_param(pk, OBJ_nid2obj(EVP_PKEY_EC), + ptype, pval, penc, penclen)) + return 1; + err: + if (ptype == V_ASN1_OBJECT) + ASN1_OBJECT_free(pval); + else + ASN1_STRING_free(pval); + if (penc) + OPENSSL_free(penc); + return 0; + } + +static EC_KEY *eckey_type2param(int ptype, void *pval) + { + EC_KEY *eckey = NULL; + if (ptype == V_ASN1_SEQUENCE) + { + ASN1_STRING *pstr = pval; + const unsigned char *pm = NULL; + int pmlen; + pm = pstr->data; + pmlen = pstr->length; + if (!(eckey = d2i_ECParameters(NULL, &pm, pmlen))) + { + ECerr(EC_F_ECKEY_TYPE2PARAM, EC_R_DECODE_ERROR); + goto ecerr; + } + } + else if (ptype == V_ASN1_OBJECT) + { + ASN1_OBJECT *poid = pval; + EC_GROUP *group; + + /* type == V_ASN1_OBJECT => the parameters are given + * by an asn1 OID + */ + if ((eckey = EC_KEY_new()) == NULL) + { + ECerr(EC_F_ECKEY_TYPE2PARAM, ERR_R_MALLOC_FAILURE); + goto ecerr; + } + group = EC_GROUP_new_by_curve_name(OBJ_obj2nid(poid)); + if (group == NULL) + goto ecerr; + EC_GROUP_set_asn1_flag(group, OPENSSL_EC_NAMED_CURVE); + if (EC_KEY_set_group(eckey, group) == 0) + goto ecerr; + EC_GROUP_free(group); + } + else + { + ECerr(EC_F_ECKEY_TYPE2PARAM, EC_R_DECODE_ERROR); + goto ecerr; + } + + return eckey; + + ecerr: + if (eckey) + EC_KEY_free(eckey); + return NULL; + } + +static int eckey_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) + { + const unsigned char *p = NULL; + void *pval; + int ptype, pklen; + EC_KEY *eckey = NULL; + X509_ALGOR *palg; + + if (!X509_PUBKEY_get0_param(NULL, &p, &pklen, &palg, pubkey)) + return 0; + X509_ALGOR_get0(NULL, &ptype, &pval, palg); + + eckey = eckey_type2param(ptype, pval); + + if (!eckey) + { + ECerr(EC_F_ECKEY_PUB_DECODE, ERR_R_EC_LIB); + return 0; + } + + /* We have parameters now set public key */ + if (!o2i_ECPublicKey(&eckey, &p, pklen)) + { + ECerr(EC_F_ECKEY_PUB_DECODE, EC_R_DECODE_ERROR); + goto ecerr; + } + + EVP_PKEY_assign_EC_KEY(pkey, eckey); + return 1; + + ecerr: + if (eckey) + EC_KEY_free(eckey); + return 0; + } + +static int eckey_pub_cmp(const EVP_PKEY *a, const EVP_PKEY *b) + { + int r; + const EC_GROUP *group = EC_KEY_get0_group(b->pkey.ec); + const EC_POINT *pa = EC_KEY_get0_public_key(a->pkey.ec), + *pb = EC_KEY_get0_public_key(b->pkey.ec); + r = EC_POINT_cmp(group, pa, pb, NULL); + if (r == 0) + return 1; + if (r == 1) + return 0; + return -2; + } + +static int eckey_priv_decode(EVP_PKEY *pkey, PKCS8_PRIV_KEY_INFO *p8) + { + const unsigned char *p = NULL; + void *pval; + int ptype, pklen; + EC_KEY *eckey = NULL; + X509_ALGOR *palg; + + if (!PKCS8_pkey_get0(NULL, &p, &pklen, &palg, p8)) + return 0; + X509_ALGOR_get0(NULL, &ptype, &pval, palg); + + eckey = eckey_type2param(ptype, pval); + + if (!eckey) + goto ecliberr; + + /* We have parameters now set private key */ + if (!d2i_ECPrivateKey(&eckey, &p, pklen)) + { + ECerr(EC_F_ECKEY_PRIV_DECODE, EC_R_DECODE_ERROR); + goto ecerr; + } + + /* calculate public key (if necessary) */ + if (EC_KEY_get0_public_key(eckey) == NULL) + { + const BIGNUM *priv_key; + const EC_GROUP *group; + EC_POINT *pub_key; + /* the public key was not included in the SEC1 private + * key => calculate the public key */ + group = EC_KEY_get0_group(eckey); + pub_key = EC_POINT_new(group); + if (pub_key == NULL) + { + ECerr(EC_F_ECKEY_PRIV_DECODE, ERR_R_EC_LIB); + goto ecliberr; + } + if (!EC_POINT_copy(pub_key, EC_GROUP_get0_generator(group))) + { + EC_POINT_free(pub_key); + ECerr(EC_F_ECKEY_PRIV_DECODE, ERR_R_EC_LIB); + goto ecliberr; + } + priv_key = EC_KEY_get0_private_key(eckey); + if (!EC_POINT_mul(group, pub_key, priv_key, NULL, NULL, NULL)) + { + EC_POINT_free(pub_key); + ECerr(EC_F_ECKEY_PRIV_DECODE, ERR_R_EC_LIB); + goto ecliberr; + } + if (EC_KEY_set_public_key(eckey, pub_key) == 0) + { + EC_POINT_free(pub_key); + ECerr(EC_F_ECKEY_PRIV_DECODE, ERR_R_EC_LIB); + goto ecliberr; + } + EC_POINT_free(pub_key); + } + + EVP_PKEY_assign_EC_KEY(pkey, eckey); + return 1; + + ecliberr: + ECerr(EC_F_ECKEY_PRIV_DECODE, ERR_R_EC_LIB); + ecerr: + if (eckey) + EC_KEY_free(eckey); + return 0; + } + +static int eckey_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) +{ + EC_KEY *ec_key; + unsigned char *ep, *p; + int eplen, ptype; + void *pval; + unsigned int tmp_flags, old_flags; + + ec_key = pkey->pkey.ec; + + if (!eckey_param2type(&ptype, &pval, ec_key)) + { + ECerr(EC_F_ECKEY_PRIV_ENCODE, EC_R_DECODE_ERROR); + return 0; + } + + /* set the private key */ + + /* do not include the parameters in the SEC1 private key + * see PKCS#11 12.11 */ + old_flags = EC_KEY_get_enc_flags(ec_key); + tmp_flags = old_flags | EC_PKEY_NO_PARAMETERS; + EC_KEY_set_enc_flags(ec_key, tmp_flags); + eplen = i2d_ECPrivateKey(ec_key, NULL); + if (!eplen) + { + EC_KEY_set_enc_flags(ec_key, old_flags); + ECerr(EC_F_ECKEY_PRIV_ENCODE, ERR_R_EC_LIB); + return 0; + } + ep = (unsigned char *) OPENSSL_malloc(eplen); + if (!ep) + { + EC_KEY_set_enc_flags(ec_key, old_flags); + ECerr(EC_F_ECKEY_PRIV_ENCODE, ERR_R_MALLOC_FAILURE); + return 0; + } + p = ep; + if (!i2d_ECPrivateKey(ec_key, &p)) + { + EC_KEY_set_enc_flags(ec_key, old_flags); + OPENSSL_free(ep); + ECerr(EC_F_ECKEY_PRIV_ENCODE, ERR_R_EC_LIB); + return 0; + } + /* restore old encoding flags */ + EC_KEY_set_enc_flags(ec_key, old_flags); + + if (!PKCS8_pkey_set0(p8, OBJ_nid2obj(NID_X9_62_id_ecPublicKey), 0, + ptype, pval, ep, eplen)) + return 0; + + return 1; +} + +static int int_ec_size(const EVP_PKEY *pkey) + { + return ECDSA_size(pkey->pkey.ec); + } + +static int ec_bits(const EVP_PKEY *pkey) + { + BIGNUM *order = BN_new(); + const EC_GROUP *group; + int ret; + + if (!order) + { + ERR_clear_error(); + return 0; + } + group = EC_KEY_get0_group(pkey->pkey.ec); + if (!EC_GROUP_get_order(group, order, NULL)) + { + ERR_clear_error(); + return 0; + } + + ret = BN_num_bits(order); + BN_free(order); + return ret; + } + +static int ec_missing_parameters(const EVP_PKEY *pkey) + { + if (EC_KEY_get0_group(pkey->pkey.ec) == NULL) + return 1; + return 0; + } + +static int ec_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from) + { + EC_GROUP *group = EC_GROUP_dup(EC_KEY_get0_group(from->pkey.ec)); + if (group == NULL) + return 0; + if (EC_KEY_set_group(to->pkey.ec, group) == 0) + return 0; + EC_GROUP_free(group); + return 1; + } + +static int ec_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b) + { + const EC_GROUP *group_a = EC_KEY_get0_group(a->pkey.ec), + *group_b = EC_KEY_get0_group(b->pkey.ec); + if (EC_GROUP_cmp(group_a, group_b, NULL)) + return 0; + else + return 1; + } + +static void int_ec_free(EVP_PKEY *pkey) + { + EC_KEY_free(pkey->pkey.ec); + } + +static int do_EC_KEY_print(BIO *bp, const EC_KEY *x, int off, int ktype) + { + unsigned char *buffer=NULL; + const char *ecstr; + size_t buf_len=0, i; + int ret=0, reason=ERR_R_BIO_LIB; + BIGNUM *pub_key=NULL, *order=NULL; + BN_CTX *ctx=NULL; + const EC_GROUP *group; + const EC_POINT *public_key; + const BIGNUM *priv_key; + + if (x == NULL || (group = EC_KEY_get0_group(x)) == NULL) + { + reason = ERR_R_PASSED_NULL_PARAMETER; + goto err; + } + + ctx = BN_CTX_new(); + if (ctx == NULL) + { + reason = ERR_R_MALLOC_FAILURE; + goto err; + } + + if (ktype > 0) + { + public_key = EC_KEY_get0_public_key(x); + if ((pub_key = EC_POINT_point2bn(group, public_key, + EC_KEY_get_conv_form(x), NULL, ctx)) == NULL) + { + reason = ERR_R_EC_LIB; + goto err; + } + if (pub_key) + buf_len = (size_t)BN_num_bytes(pub_key); + } + + if (ktype == 2) + { + priv_key = EC_KEY_get0_private_key(x); + if (priv_key && (i = (size_t)BN_num_bytes(priv_key)) > buf_len) + buf_len = i; + } + else + priv_key = NULL; + + if (ktype > 0) + { + buf_len += 10; + if ((buffer = OPENSSL_malloc(buf_len)) == NULL) + { + reason = ERR_R_MALLOC_FAILURE; + goto err; + } + } + if (ktype == 2) + ecstr = "Private-Key"; + else if (ktype == 1) + ecstr = "Public-Key"; + else + ecstr = "ECDSA-Parameters"; + + if (!BIO_indent(bp, off, 128)) + goto err; + if ((order = BN_new()) == NULL) + goto err; + if (!EC_GROUP_get_order(group, order, NULL)) + goto err; + if (BIO_printf(bp, "%s: (%d bit)\n", ecstr, + BN_num_bits(order)) <= 0) goto err; + + if ((priv_key != NULL) && !ASN1_bn_print(bp, "priv:", priv_key, + buffer, off)) + goto err; + if ((pub_key != NULL) && !ASN1_bn_print(bp, "pub: ", pub_key, + buffer, off)) + goto err; + if (!ECPKParameters_print(bp, group, off)) + goto err; + ret=1; +err: + if (!ret) + ECerr(EC_F_DO_EC_KEY_PRINT, reason); + if (pub_key) + BN_free(pub_key); + if (order) + BN_free(order); + if (ctx) + BN_CTX_free(ctx); + if (buffer != NULL) + OPENSSL_free(buffer); + return(ret); + } + +static int eckey_param_decode(EVP_PKEY *pkey, + const unsigned char **pder, int derlen) + { + EC_KEY *eckey; + if (!(eckey = d2i_ECParameters(NULL, pder, derlen))) + { + ECerr(EC_F_ECKEY_PARAM_DECODE, ERR_R_EC_LIB); + return 0; + } + EVP_PKEY_assign_EC_KEY(pkey, eckey); + return 1; + } + +static int eckey_param_encode(const EVP_PKEY *pkey, unsigned char **pder) + { + return i2d_ECParameters(pkey->pkey.ec, pder); + } + +static int eckey_param_print(BIO *bp, const EVP_PKEY *pkey, int indent, + ASN1_PCTX *ctx) + { + return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 0); + } + +static int eckey_pub_print(BIO *bp, const EVP_PKEY *pkey, int indent, + ASN1_PCTX *ctx) + { + return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 1); + } + + +static int eckey_priv_print(BIO *bp, const EVP_PKEY *pkey, int indent, + ASN1_PCTX *ctx) + { + return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 2); + } + +static int old_ec_priv_decode(EVP_PKEY *pkey, + const unsigned char **pder, int derlen) + { + EC_KEY *ec; + if (!(ec = d2i_ECPrivateKey (NULL, pder, derlen))) + { + ECerr(EC_F_OLD_EC_PRIV_DECODE, EC_R_DECODE_ERROR); + return 0; + } + EVP_PKEY_assign_EC_KEY(pkey, ec); + return 1; + } + +static int old_ec_priv_encode(const EVP_PKEY *pkey, unsigned char **pder) + { + return i2d_ECPrivateKey(pkey->pkey.ec, pder); + } + +static int ec_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) + { + switch (op) + { + case ASN1_PKEY_CTRL_PKCS7_SIGN: + if (arg1 == 0) + { + int snid, hnid; + X509_ALGOR *alg1, *alg2; + PKCS7_SIGNER_INFO_get0_algs(arg2, NULL, &alg1, &alg2); + if (alg1 == NULL || alg1->algorithm == NULL) + return -1; + hnid = OBJ_obj2nid(alg1->algorithm); + if (hnid == NID_undef) + return -1; + if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey))) + return -1; + X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 0); + } + return 1; +#ifndef OPENSSL_NO_CMS + case ASN1_PKEY_CTRL_CMS_SIGN: + if (arg1 == 0) + { + int snid, hnid; + X509_ALGOR *alg1, *alg2; + CMS_SignerInfo_get0_algs(arg2, NULL, NULL, + &alg1, &alg2); + if (alg1 == NULL || alg1->algorithm == NULL) + return -1; + hnid = OBJ_obj2nid(alg1->algorithm); + if (hnid == NID_undef) + return -1; + if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey))) + return -1; + X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 0); + } + return 1; +#endif + + case ASN1_PKEY_CTRL_DEFAULT_MD_NID: + *(int *)arg2 = NID_sha1; + return 2; + + default: + return -2; + + } + + } + +const EVP_PKEY_ASN1_METHOD eckey_asn1_meth = + { + EVP_PKEY_EC, + EVP_PKEY_EC, + 0, + "EC", + "OpenSSL EC algorithm", + + eckey_pub_decode, + eckey_pub_encode, + eckey_pub_cmp, + eckey_pub_print, + + eckey_priv_decode, + eckey_priv_encode, + eckey_priv_print, + + int_ec_size, + ec_bits, + + eckey_param_decode, + eckey_param_encode, + ec_missing_parameters, + ec_copy_parameters, + ec_cmp_parameters, + eckey_param_print, + 0, + + int_ec_free, + ec_pkey_ctrl, + old_ec_priv_decode, + old_ec_priv_encode + }; diff --git a/libs/openssl/crypto/ec/ec_asn1.c b/libs/openssl/crypto/ec/ec_asn1.c new file mode 100644 index 00000000..e94f34e1 --- /dev/null +++ b/libs/openssl/crypto/ec/ec_asn1.c @@ -0,0 +1,1448 @@ +/* crypto/ec/ec_asn1.c */ +/* + * Written by Nils Larsch for the OpenSSL project. + */ +/* ==================================================================== + * Copyright (c) 2000-2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include +#include "ec_lcl.h" +#include +#include +#include + + +int EC_GROUP_get_basis_type(const EC_GROUP *group) + { + int i=0; + + if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) != + NID_X9_62_characteristic_two_field) + /* everything else is currently not supported */ + return 0; + + while (group->poly[i] != 0) + i++; + + if (i == 4) + return NID_X9_62_ppBasis; + else if (i == 2) + return NID_X9_62_tpBasis; + else + /* everything else is currently not supported */ + return 0; + } +#ifndef OPENSSL_NO_EC2M +int EC_GROUP_get_trinomial_basis(const EC_GROUP *group, unsigned int *k) + { + if (group == NULL) + return 0; + + if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) != + NID_X9_62_characteristic_two_field + || !((group->poly[0] != 0) && (group->poly[1] != 0) && (group->poly[2] == 0))) + { + ECerr(EC_F_EC_GROUP_GET_TRINOMIAL_BASIS, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + + if (k) + *k = group->poly[1]; + + return 1; + } +int EC_GROUP_get_pentanomial_basis(const EC_GROUP *group, unsigned int *k1, + unsigned int *k2, unsigned int *k3) + { + if (group == NULL) + return 0; + + if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) != + NID_X9_62_characteristic_two_field + || !((group->poly[0] != 0) && (group->poly[1] != 0) && (group->poly[2] != 0) && (group->poly[3] != 0) && (group->poly[4] == 0))) + { + ECerr(EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + + if (k1) + *k1 = group->poly[3]; + if (k2) + *k2 = group->poly[2]; + if (k3) + *k3 = group->poly[1]; + + return 1; + } +#endif + + +/* some structures needed for the asn1 encoding */ +typedef struct x9_62_pentanomial_st { + long k1; + long k2; + long k3; + } X9_62_PENTANOMIAL; + +typedef struct x9_62_characteristic_two_st { + long m; + ASN1_OBJECT *type; + union { + char *ptr; + /* NID_X9_62_onBasis */ + ASN1_NULL *onBasis; + /* NID_X9_62_tpBasis */ + ASN1_INTEGER *tpBasis; + /* NID_X9_62_ppBasis */ + X9_62_PENTANOMIAL *ppBasis; + /* anything else */ + ASN1_TYPE *other; + } p; + } X9_62_CHARACTERISTIC_TWO; + +typedef struct x9_62_fieldid_st { + ASN1_OBJECT *fieldType; + union { + char *ptr; + /* NID_X9_62_prime_field */ + ASN1_INTEGER *prime; + /* NID_X9_62_characteristic_two_field */ + X9_62_CHARACTERISTIC_TWO *char_two; + /* anything else */ + ASN1_TYPE *other; + } p; + } X9_62_FIELDID; + +typedef struct x9_62_curve_st { + ASN1_OCTET_STRING *a; + ASN1_OCTET_STRING *b; + ASN1_BIT_STRING *seed; + } X9_62_CURVE; + +typedef struct ec_parameters_st { + long version; + X9_62_FIELDID *fieldID; + X9_62_CURVE *curve; + ASN1_OCTET_STRING *base; + ASN1_INTEGER *order; + ASN1_INTEGER *cofactor; + } ECPARAMETERS; + +struct ecpk_parameters_st { + int type; + union { + ASN1_OBJECT *named_curve; + ECPARAMETERS *parameters; + ASN1_NULL *implicitlyCA; + } value; + }/* ECPKPARAMETERS */; + +/* SEC1 ECPrivateKey */ +typedef struct ec_privatekey_st { + long version; + ASN1_OCTET_STRING *privateKey; + ECPKPARAMETERS *parameters; + ASN1_BIT_STRING *publicKey; + } EC_PRIVATEKEY; + +/* the OpenSSL ASN.1 definitions */ +ASN1_SEQUENCE(X9_62_PENTANOMIAL) = { + ASN1_SIMPLE(X9_62_PENTANOMIAL, k1, LONG), + ASN1_SIMPLE(X9_62_PENTANOMIAL, k2, LONG), + ASN1_SIMPLE(X9_62_PENTANOMIAL, k3, LONG) +} ASN1_SEQUENCE_END(X9_62_PENTANOMIAL) + +DECLARE_ASN1_ALLOC_FUNCTIONS(X9_62_PENTANOMIAL) +IMPLEMENT_ASN1_ALLOC_FUNCTIONS(X9_62_PENTANOMIAL) + +ASN1_ADB_TEMPLATE(char_two_def) = ASN1_SIMPLE(X9_62_CHARACTERISTIC_TWO, p.other, ASN1_ANY); + +ASN1_ADB(X9_62_CHARACTERISTIC_TWO) = { + ADB_ENTRY(NID_X9_62_onBasis, ASN1_SIMPLE(X9_62_CHARACTERISTIC_TWO, p.onBasis, ASN1_NULL)), + ADB_ENTRY(NID_X9_62_tpBasis, ASN1_SIMPLE(X9_62_CHARACTERISTIC_TWO, p.tpBasis, ASN1_INTEGER)), + ADB_ENTRY(NID_X9_62_ppBasis, ASN1_SIMPLE(X9_62_CHARACTERISTIC_TWO, p.ppBasis, X9_62_PENTANOMIAL)) +} ASN1_ADB_END(X9_62_CHARACTERISTIC_TWO, 0, type, 0, &char_two_def_tt, NULL); + +ASN1_SEQUENCE(X9_62_CHARACTERISTIC_TWO) = { + ASN1_SIMPLE(X9_62_CHARACTERISTIC_TWO, m, LONG), + ASN1_SIMPLE(X9_62_CHARACTERISTIC_TWO, type, ASN1_OBJECT), + ASN1_ADB_OBJECT(X9_62_CHARACTERISTIC_TWO) +} ASN1_SEQUENCE_END(X9_62_CHARACTERISTIC_TWO) + +DECLARE_ASN1_ALLOC_FUNCTIONS(X9_62_CHARACTERISTIC_TWO) +IMPLEMENT_ASN1_ALLOC_FUNCTIONS(X9_62_CHARACTERISTIC_TWO) + +ASN1_ADB_TEMPLATE(fieldID_def) = ASN1_SIMPLE(X9_62_FIELDID, p.other, ASN1_ANY); + +ASN1_ADB(X9_62_FIELDID) = { + ADB_ENTRY(NID_X9_62_prime_field, ASN1_SIMPLE(X9_62_FIELDID, p.prime, ASN1_INTEGER)), + ADB_ENTRY(NID_X9_62_characteristic_two_field, ASN1_SIMPLE(X9_62_FIELDID, p.char_two, X9_62_CHARACTERISTIC_TWO)) +} ASN1_ADB_END(X9_62_FIELDID, 0, fieldType, 0, &fieldID_def_tt, NULL); + +ASN1_SEQUENCE(X9_62_FIELDID) = { + ASN1_SIMPLE(X9_62_FIELDID, fieldType, ASN1_OBJECT), + ASN1_ADB_OBJECT(X9_62_FIELDID) +} ASN1_SEQUENCE_END(X9_62_FIELDID) + +ASN1_SEQUENCE(X9_62_CURVE) = { + ASN1_SIMPLE(X9_62_CURVE, a, ASN1_OCTET_STRING), + ASN1_SIMPLE(X9_62_CURVE, b, ASN1_OCTET_STRING), + ASN1_OPT(X9_62_CURVE, seed, ASN1_BIT_STRING) +} ASN1_SEQUENCE_END(X9_62_CURVE) + +ASN1_SEQUENCE(ECPARAMETERS) = { + ASN1_SIMPLE(ECPARAMETERS, version, LONG), + ASN1_SIMPLE(ECPARAMETERS, fieldID, X9_62_FIELDID), + ASN1_SIMPLE(ECPARAMETERS, curve, X9_62_CURVE), + ASN1_SIMPLE(ECPARAMETERS, base, ASN1_OCTET_STRING), + ASN1_SIMPLE(ECPARAMETERS, order, ASN1_INTEGER), + ASN1_OPT(ECPARAMETERS, cofactor, ASN1_INTEGER) +} ASN1_SEQUENCE_END(ECPARAMETERS) + +DECLARE_ASN1_ALLOC_FUNCTIONS(ECPARAMETERS) +IMPLEMENT_ASN1_ALLOC_FUNCTIONS(ECPARAMETERS) + +ASN1_CHOICE(ECPKPARAMETERS) = { + ASN1_SIMPLE(ECPKPARAMETERS, value.named_curve, ASN1_OBJECT), + ASN1_SIMPLE(ECPKPARAMETERS, value.parameters, ECPARAMETERS), + ASN1_SIMPLE(ECPKPARAMETERS, value.implicitlyCA, ASN1_NULL) +} ASN1_CHOICE_END(ECPKPARAMETERS) + +DECLARE_ASN1_FUNCTIONS_const(ECPKPARAMETERS) +DECLARE_ASN1_ENCODE_FUNCTIONS_const(ECPKPARAMETERS, ECPKPARAMETERS) +IMPLEMENT_ASN1_FUNCTIONS_const(ECPKPARAMETERS) + +ASN1_SEQUENCE(EC_PRIVATEKEY) = { + ASN1_SIMPLE(EC_PRIVATEKEY, version, LONG), + ASN1_SIMPLE(EC_PRIVATEKEY, privateKey, ASN1_OCTET_STRING), + ASN1_EXP_OPT(EC_PRIVATEKEY, parameters, ECPKPARAMETERS, 0), + ASN1_EXP_OPT(EC_PRIVATEKEY, publicKey, ASN1_BIT_STRING, 1) +} ASN1_SEQUENCE_END(EC_PRIVATEKEY) + +DECLARE_ASN1_FUNCTIONS_const(EC_PRIVATEKEY) +DECLARE_ASN1_ENCODE_FUNCTIONS_const(EC_PRIVATEKEY, EC_PRIVATEKEY) +IMPLEMENT_ASN1_FUNCTIONS_const(EC_PRIVATEKEY) + +/* some declarations of internal function */ + +/* ec_asn1_group2field() sets the values in a X9_62_FIELDID object */ +static int ec_asn1_group2fieldid(const EC_GROUP *, X9_62_FIELDID *); +/* ec_asn1_group2curve() sets the values in a X9_62_CURVE object */ +static int ec_asn1_group2curve(const EC_GROUP *, X9_62_CURVE *); +/* ec_asn1_parameters2group() creates a EC_GROUP object from a + * ECPARAMETERS object */ +static EC_GROUP *ec_asn1_parameters2group(const ECPARAMETERS *); +/* ec_asn1_group2parameters() creates a ECPARAMETERS object from a + * EC_GROUP object */ +static ECPARAMETERS *ec_asn1_group2parameters(const EC_GROUP *,ECPARAMETERS *); +/* ec_asn1_pkparameters2group() creates a EC_GROUP object from a + * ECPKPARAMETERS object */ +static EC_GROUP *ec_asn1_pkparameters2group(const ECPKPARAMETERS *); +/* ec_asn1_group2pkparameters() creates a ECPKPARAMETERS object from a + * EC_GROUP object */ +static ECPKPARAMETERS *ec_asn1_group2pkparameters(const EC_GROUP *, + ECPKPARAMETERS *); + + +/* the function definitions */ + +static int ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field) + { + int ok=0, nid; + BIGNUM *tmp = NULL; + + if (group == NULL || field == NULL) + return 0; + + /* clear the old values (if necessary) */ + if (field->fieldType != NULL) + ASN1_OBJECT_free(field->fieldType); + if (field->p.other != NULL) + ASN1_TYPE_free(field->p.other); + + nid = EC_METHOD_get_field_type(EC_GROUP_method_of(group)); + /* set OID for the field */ + if ((field->fieldType = OBJ_nid2obj(nid)) == NULL) + { + ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_OBJ_LIB); + goto err; + } + + if (nid == NID_X9_62_prime_field) + { + if ((tmp = BN_new()) == NULL) + { + ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_MALLOC_FAILURE); + goto err; + } + /* the parameters are specified by the prime number p */ + if (!EC_GROUP_get_curve_GFp(group, tmp, NULL, NULL, NULL)) + { + ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_EC_LIB); + goto err; + } + /* set the prime number */ + field->p.prime = BN_to_ASN1_INTEGER(tmp,NULL); + if (field->p.prime == NULL) + { + ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_ASN1_LIB); + goto err; + } + } + else /* nid == NID_X9_62_characteristic_two_field */ +#ifdef OPENSSL_NO_EC2M + { + ECerr(EC_F_EC_ASN1_GROUP2FIELDID, EC_R_GF2M_NOT_SUPPORTED); + goto err; + } +#else + { + int field_type; + X9_62_CHARACTERISTIC_TWO *char_two; + + field->p.char_two = X9_62_CHARACTERISTIC_TWO_new(); + char_two = field->p.char_two; + + if (char_two == NULL) + { + ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_MALLOC_FAILURE); + goto err; + } + + char_two->m = (long)EC_GROUP_get_degree(group); + + field_type = EC_GROUP_get_basis_type(group); + + if (field_type == 0) + { + ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_EC_LIB); + goto err; + } + /* set base type OID */ + if ((char_two->type = OBJ_nid2obj(field_type)) == NULL) + { + ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_OBJ_LIB); + goto err; + } + + if (field_type == NID_X9_62_tpBasis) + { + unsigned int k; + + if (!EC_GROUP_get_trinomial_basis(group, &k)) + goto err; + + char_two->p.tpBasis = ASN1_INTEGER_new(); + if (!char_two->p.tpBasis) + { + ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_MALLOC_FAILURE); + goto err; + } + if (!ASN1_INTEGER_set(char_two->p.tpBasis, (long)k)) + { + ECerr(EC_F_EC_ASN1_GROUP2FIELDID, + ERR_R_ASN1_LIB); + goto err; + } + } + else if (field_type == NID_X9_62_ppBasis) + { + unsigned int k1, k2, k3; + + if (!EC_GROUP_get_pentanomial_basis(group, &k1, &k2, &k3)) + goto err; + + char_two->p.ppBasis = X9_62_PENTANOMIAL_new(); + if (!char_two->p.ppBasis) + { + ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_MALLOC_FAILURE); + goto err; + } + + /* set k? values */ + char_two->p.ppBasis->k1 = (long)k1; + char_two->p.ppBasis->k2 = (long)k2; + char_two->p.ppBasis->k3 = (long)k3; + } + else /* field_type == NID_X9_62_onBasis */ + { + /* for ONB the parameters are (asn1) NULL */ + char_two->p.onBasis = ASN1_NULL_new(); + if (!char_two->p.onBasis) + { + ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_MALLOC_FAILURE); + goto err; + } + } + } +#endif + + ok = 1; + +err : if (tmp) + BN_free(tmp); + return(ok); +} + +static int ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve) + { + int ok=0, nid; + BIGNUM *tmp_1=NULL, *tmp_2=NULL; + unsigned char *buffer_1=NULL, *buffer_2=NULL, + *a_buf=NULL, *b_buf=NULL; + size_t len_1, len_2; + unsigned char char_zero = 0; + + if (!group || !curve || !curve->a || !curve->b) + return 0; + + if ((tmp_1 = BN_new()) == NULL || (tmp_2 = BN_new()) == NULL) + { + ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_MALLOC_FAILURE); + goto err; + } + + nid = EC_METHOD_get_field_type(EC_GROUP_method_of(group)); + + /* get a and b */ + if (nid == NID_X9_62_prime_field) + { + if (!EC_GROUP_get_curve_GFp(group, NULL, tmp_1, tmp_2, NULL)) + { + ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_EC_LIB); + goto err; + } + } +#ifndef OPENSSL_NO_EC2M + else /* nid == NID_X9_62_characteristic_two_field */ + { + if (!EC_GROUP_get_curve_GF2m(group, NULL, tmp_1, tmp_2, NULL)) + { + ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_EC_LIB); + goto err; + } + } +#endif + len_1 = (size_t)BN_num_bytes(tmp_1); + len_2 = (size_t)BN_num_bytes(tmp_2); + + if (len_1 == 0) + { + /* len_1 == 0 => a == 0 */ + a_buf = &char_zero; + len_1 = 1; + } + else + { + if ((buffer_1 = OPENSSL_malloc(len_1)) == NULL) + { + ECerr(EC_F_EC_ASN1_GROUP2CURVE, + ERR_R_MALLOC_FAILURE); + goto err; + } + if ( (len_1 = BN_bn2bin(tmp_1, buffer_1)) == 0) + { + ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_BN_LIB); + goto err; + } + a_buf = buffer_1; + } + + if (len_2 == 0) + { + /* len_2 == 0 => b == 0 */ + b_buf = &char_zero; + len_2 = 1; + } + else + { + if ((buffer_2 = OPENSSL_malloc(len_2)) == NULL) + { + ECerr(EC_F_EC_ASN1_GROUP2CURVE, + ERR_R_MALLOC_FAILURE); + goto err; + } + if ( (len_2 = BN_bn2bin(tmp_2, buffer_2)) == 0) + { + ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_BN_LIB); + goto err; + } + b_buf = buffer_2; + } + + /* set a and b */ + if (!M_ASN1_OCTET_STRING_set(curve->a, a_buf, len_1) || + !M_ASN1_OCTET_STRING_set(curve->b, b_buf, len_2)) + { + ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_ASN1_LIB); + goto err; + } + + /* set the seed (optional) */ + if (group->seed) + { + if (!curve->seed) + if ((curve->seed = ASN1_BIT_STRING_new()) == NULL) + { + ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_MALLOC_FAILURE); + goto err; + } + curve->seed->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); + curve->seed->flags |= ASN1_STRING_FLAG_BITS_LEFT; + if (!ASN1_BIT_STRING_set(curve->seed, group->seed, + (int)group->seed_len)) + { + ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_ASN1_LIB); + goto err; + } + } + else + { + if (curve->seed) + { + ASN1_BIT_STRING_free(curve->seed); + curve->seed = NULL; + } + } + + ok = 1; + +err: if (buffer_1) + OPENSSL_free(buffer_1); + if (buffer_2) + OPENSSL_free(buffer_2); + if (tmp_1) + BN_free(tmp_1); + if (tmp_2) + BN_free(tmp_2); + return(ok); + } + +static ECPARAMETERS *ec_asn1_group2parameters(const EC_GROUP *group, + ECPARAMETERS *param) + { + int ok=0; + size_t len=0; + ECPARAMETERS *ret=NULL; + BIGNUM *tmp=NULL; + unsigned char *buffer=NULL; + const EC_POINT *point=NULL; + point_conversion_form_t form; + + if ((tmp = BN_new()) == NULL) + { + ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_MALLOC_FAILURE); + goto err; + } + + if (param == NULL) + { + if ((ret = ECPARAMETERS_new()) == NULL) + { + ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, + ERR_R_MALLOC_FAILURE); + goto err; + } + } + else + ret = param; + + /* set the version (always one) */ + ret->version = (long)0x1; + + /* set the fieldID */ + if (!ec_asn1_group2fieldid(group, ret->fieldID)) + { + ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_EC_LIB); + goto err; + } + + /* set the curve */ + if (!ec_asn1_group2curve(group, ret->curve)) + { + ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_EC_LIB); + goto err; + } + + /* set the base point */ + if ((point = EC_GROUP_get0_generator(group)) == NULL) + { + ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, EC_R_UNDEFINED_GENERATOR); + goto err; + } + + form = EC_GROUP_get_point_conversion_form(group); + + len = EC_POINT_point2oct(group, point, form, NULL, len, NULL); + if (len == 0) + { + ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_EC_LIB); + goto err; + } + if ((buffer = OPENSSL_malloc(len)) == NULL) + { + ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_MALLOC_FAILURE); + goto err; + } + if (!EC_POINT_point2oct(group, point, form, buffer, len, NULL)) + { + ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_EC_LIB); + goto err; + } + if (ret->base == NULL && (ret->base = ASN1_OCTET_STRING_new()) == NULL) + { + ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_MALLOC_FAILURE); + goto err; + } + if (!ASN1_OCTET_STRING_set(ret->base, buffer, len)) + { + ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_ASN1_LIB); + goto err; + } + + /* set the order */ + if (!EC_GROUP_get_order(group, tmp, NULL)) + { + ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_EC_LIB); + goto err; + } + ret->order = BN_to_ASN1_INTEGER(tmp, ret->order); + if (ret->order == NULL) + { + ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_ASN1_LIB); + goto err; + } + + /* set the cofactor (optional) */ + if (EC_GROUP_get_cofactor(group, tmp, NULL)) + { + ret->cofactor = BN_to_ASN1_INTEGER(tmp, ret->cofactor); + if (ret->cofactor == NULL) + { + ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_ASN1_LIB); + goto err; + } + } + + ok = 1; + +err : if(!ok) + { + if (ret && !param) + ECPARAMETERS_free(ret); + ret = NULL; + } + if (tmp) + BN_free(tmp); + if (buffer) + OPENSSL_free(buffer); + return(ret); + } + +ECPKPARAMETERS *ec_asn1_group2pkparameters(const EC_GROUP *group, + ECPKPARAMETERS *params) + { + int ok = 1, tmp; + ECPKPARAMETERS *ret = params; + + if (ret == NULL) + { + if ((ret = ECPKPARAMETERS_new()) == NULL) + { + ECerr(EC_F_EC_ASN1_GROUP2PKPARAMETERS, + ERR_R_MALLOC_FAILURE); + return NULL; + } + } + else + { + if (ret->type == 0 && ret->value.named_curve) + ASN1_OBJECT_free(ret->value.named_curve); + else if (ret->type == 1 && ret->value.parameters) + ECPARAMETERS_free(ret->value.parameters); + } + + if (EC_GROUP_get_asn1_flag(group)) + { + /* use the asn1 OID to describe the + * the elliptic curve parameters + */ + tmp = EC_GROUP_get_curve_name(group); + if (tmp) + { + ret->type = 0; + if ((ret->value.named_curve = OBJ_nid2obj(tmp)) == NULL) + ok = 0; + } + else + /* we don't kmow the nid => ERROR */ + ok = 0; + } + else + { + /* use the ECPARAMETERS structure */ + ret->type = 1; + if ((ret->value.parameters = ec_asn1_group2parameters( + group, NULL)) == NULL) + ok = 0; + } + + if (!ok) + { + ECPKPARAMETERS_free(ret); + return NULL; + } + return ret; + } + +static EC_GROUP *ec_asn1_parameters2group(const ECPARAMETERS *params) + { + int ok = 0, tmp; + EC_GROUP *ret = NULL; + BIGNUM *p = NULL, *a = NULL, *b = NULL; + EC_POINT *point=NULL; + long field_bits; + + if (!params->fieldID || !params->fieldID->fieldType || + !params->fieldID->p.ptr) + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_ASN1_ERROR); + goto err; + } + + /* now extract the curve parameters a and b */ + if (!params->curve || !params->curve->a || + !params->curve->a->data || !params->curve->b || + !params->curve->b->data) + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_ASN1_ERROR); + goto err; + } + a = BN_bin2bn(params->curve->a->data, params->curve->a->length, NULL); + if (a == NULL) + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_BN_LIB); + goto err; + } + b = BN_bin2bn(params->curve->b->data, params->curve->b->length, NULL); + if (b == NULL) + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_BN_LIB); + goto err; + } + + /* get the field parameters */ + tmp = OBJ_obj2nid(params->fieldID->fieldType); + if (tmp == NID_X9_62_characteristic_two_field) +#ifdef OPENSSL_NO_EC2M + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_GF2M_NOT_SUPPORTED); + goto err; + } +#else + { + X9_62_CHARACTERISTIC_TWO *char_two; + + char_two = params->fieldID->p.char_two; + + field_bits = char_two->m; + if (field_bits > OPENSSL_ECC_MAX_FIELD_BITS) + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_FIELD_TOO_LARGE); + goto err; + } + + if ((p = BN_new()) == NULL) + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_MALLOC_FAILURE); + goto err; + } + + /* get the base type */ + tmp = OBJ_obj2nid(char_two->type); + + if (tmp == NID_X9_62_tpBasis) + { + long tmp_long; + + if (!char_two->p.tpBasis) + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_ASN1_ERROR); + goto err; + } + + tmp_long = ASN1_INTEGER_get(char_two->p.tpBasis); + + if (!(char_two->m > tmp_long && tmp_long > 0)) + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_INVALID_TRINOMIAL_BASIS); + goto err; + } + + /* create the polynomial */ + if (!BN_set_bit(p, (int)char_two->m)) + goto err; + if (!BN_set_bit(p, (int)tmp_long)) + goto err; + if (!BN_set_bit(p, 0)) + goto err; + } + else if (tmp == NID_X9_62_ppBasis) + { + X9_62_PENTANOMIAL *penta; + + penta = char_two->p.ppBasis; + if (!penta) + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_ASN1_ERROR); + goto err; + } + + if (!(char_two->m > penta->k3 && penta->k3 > penta->k2 && penta->k2 > penta->k1 && penta->k1 > 0)) + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_INVALID_PENTANOMIAL_BASIS); + goto err; + } + + /* create the polynomial */ + if (!BN_set_bit(p, (int)char_two->m)) goto err; + if (!BN_set_bit(p, (int)penta->k1)) goto err; + if (!BN_set_bit(p, (int)penta->k2)) goto err; + if (!BN_set_bit(p, (int)penta->k3)) goto err; + if (!BN_set_bit(p, 0)) goto err; + } + else if (tmp == NID_X9_62_onBasis) + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_NOT_IMPLEMENTED); + goto err; + } + else /* error */ + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_ASN1_ERROR); + goto err; + } + + /* create the EC_GROUP structure */ + ret = EC_GROUP_new_curve_GF2m(p, a, b, NULL); + } +#endif + else if (tmp == NID_X9_62_prime_field) + { + /* we have a curve over a prime field */ + /* extract the prime number */ + if (!params->fieldID->p.prime) + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_ASN1_ERROR); + goto err; + } + p = ASN1_INTEGER_to_BN(params->fieldID->p.prime, NULL); + if (p == NULL) + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_ASN1_LIB); + goto err; + } + + if (BN_is_negative(p) || BN_is_zero(p)) + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_INVALID_FIELD); + goto err; + } + + field_bits = BN_num_bits(p); + if (field_bits > OPENSSL_ECC_MAX_FIELD_BITS) + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_FIELD_TOO_LARGE); + goto err; + } + + /* create the EC_GROUP structure */ + ret = EC_GROUP_new_curve_GFp(p, a, b, NULL); + } + else + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_INVALID_FIELD); + goto err; + } + + if (ret == NULL) + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_EC_LIB); + goto err; + } + + /* extract seed (optional) */ + if (params->curve->seed != NULL) + { + if (ret->seed != NULL) + OPENSSL_free(ret->seed); + if (!(ret->seed = OPENSSL_malloc(params->curve->seed->length))) + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, + ERR_R_MALLOC_FAILURE); + goto err; + } + memcpy(ret->seed, params->curve->seed->data, + params->curve->seed->length); + ret->seed_len = params->curve->seed->length; + } + + if (!params->order || !params->base || !params->base->data) + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_ASN1_ERROR); + goto err; + } + + if ((point = EC_POINT_new(ret)) == NULL) goto err; + + /* set the point conversion form */ + EC_GROUP_set_point_conversion_form(ret, (point_conversion_form_t) + (params->base->data[0] & ~0x01)); + + /* extract the ec point */ + if (!EC_POINT_oct2point(ret, point, params->base->data, + params->base->length, NULL)) + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_EC_LIB); + goto err; + } + + /* extract the order */ + if ((a = ASN1_INTEGER_to_BN(params->order, a)) == NULL) + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_ASN1_LIB); + goto err; + } + if (BN_is_negative(a) || BN_is_zero(a)) + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_INVALID_GROUP_ORDER); + goto err; + } + if (BN_num_bits(a) > (int)field_bits + 1) /* Hasse bound */ + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_INVALID_GROUP_ORDER); + goto err; + } + + /* extract the cofactor (optional) */ + if (params->cofactor == NULL) + { + if (b) + { + BN_free(b); + b = NULL; + } + } + else + if ((b = ASN1_INTEGER_to_BN(params->cofactor, b)) == NULL) + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_ASN1_LIB); + goto err; + } + /* set the generator, order and cofactor (if present) */ + if (!EC_GROUP_set_generator(ret, point, a, b)) + { + ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_EC_LIB); + goto err; + } + + ok = 1; + +err: if (!ok) + { + if (ret) + EC_GROUP_clear_free(ret); + ret = NULL; + } + + if (p) + BN_free(p); + if (a) + BN_free(a); + if (b) + BN_free(b); + if (point) + EC_POINT_free(point); + return(ret); +} + +EC_GROUP *ec_asn1_pkparameters2group(const ECPKPARAMETERS *params) + { + EC_GROUP *ret=NULL; + int tmp=0; + + if (params == NULL) + { + ECerr(EC_F_EC_ASN1_PKPARAMETERS2GROUP, + EC_R_MISSING_PARAMETERS); + return NULL; + } + + if (params->type == 0) + { /* the curve is given by an OID */ + tmp = OBJ_obj2nid(params->value.named_curve); + if ((ret = EC_GROUP_new_by_curve_name(tmp)) == NULL) + { + ECerr(EC_F_EC_ASN1_PKPARAMETERS2GROUP, + EC_R_EC_GROUP_NEW_BY_NAME_FAILURE); + return NULL; + } + EC_GROUP_set_asn1_flag(ret, OPENSSL_EC_NAMED_CURVE); + } + else if (params->type == 1) + { /* the parameters are given by a ECPARAMETERS + * structure */ + ret = ec_asn1_parameters2group(params->value.parameters); + if (!ret) + { + ECerr(EC_F_EC_ASN1_PKPARAMETERS2GROUP, ERR_R_EC_LIB); + return NULL; + } + EC_GROUP_set_asn1_flag(ret, 0x0); + } + else if (params->type == 2) + { /* implicitlyCA */ + return NULL; + } + else + { + ECerr(EC_F_EC_ASN1_PKPARAMETERS2GROUP, EC_R_ASN1_ERROR); + return NULL; + } + + return ret; + } + +/* EC_GROUP <-> DER encoding of ECPKPARAMETERS */ + +EC_GROUP *d2i_ECPKParameters(EC_GROUP **a, const unsigned char **in, long len) + { + EC_GROUP *group = NULL; + ECPKPARAMETERS *params = NULL; + + if ((params = d2i_ECPKPARAMETERS(NULL, in, len)) == NULL) + { + ECerr(EC_F_D2I_ECPKPARAMETERS, EC_R_D2I_ECPKPARAMETERS_FAILURE); + ECPKPARAMETERS_free(params); + return NULL; + } + + if ((group = ec_asn1_pkparameters2group(params)) == NULL) + { + ECerr(EC_F_D2I_ECPKPARAMETERS, EC_R_PKPARAMETERS2GROUP_FAILURE); + ECPKPARAMETERS_free(params); + return NULL; + } + + + if (a && *a) + EC_GROUP_clear_free(*a); + if (a) + *a = group; + + ECPKPARAMETERS_free(params); + return(group); + } + +int i2d_ECPKParameters(const EC_GROUP *a, unsigned char **out) + { + int ret=0; + ECPKPARAMETERS *tmp = ec_asn1_group2pkparameters(a, NULL); + if (tmp == NULL) + { + ECerr(EC_F_I2D_ECPKPARAMETERS, EC_R_GROUP2PKPARAMETERS_FAILURE); + return 0; + } + if ((ret = i2d_ECPKPARAMETERS(tmp, out)) == 0) + { + ECerr(EC_F_I2D_ECPKPARAMETERS, EC_R_I2D_ECPKPARAMETERS_FAILURE); + ECPKPARAMETERS_free(tmp); + return 0; + } + ECPKPARAMETERS_free(tmp); + return(ret); + } + +/* some EC_KEY functions */ + +EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len) + { + int ok=0; + EC_KEY *ret=NULL; + EC_PRIVATEKEY *priv_key=NULL; + + if ((priv_key = EC_PRIVATEKEY_new()) == NULL) + { + ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_MALLOC_FAILURE); + return NULL; + } + + if ((priv_key = d2i_EC_PRIVATEKEY(&priv_key, in, len)) == NULL) + { + ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_EC_LIB); + EC_PRIVATEKEY_free(priv_key); + return NULL; + } + + if (a == NULL || *a == NULL) + { + if ((ret = EC_KEY_new()) == NULL) + { + ECerr(EC_F_D2I_ECPRIVATEKEY, + ERR_R_MALLOC_FAILURE); + goto err; + } + if (a) + *a = ret; + } + else + ret = *a; + + if (priv_key->parameters) + { + if (ret->group) + EC_GROUP_clear_free(ret->group); + ret->group = ec_asn1_pkparameters2group(priv_key->parameters); + } + + if (ret->group == NULL) + { + ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_EC_LIB); + goto err; + } + + ret->version = priv_key->version; + + if (priv_key->privateKey) + { + ret->priv_key = BN_bin2bn( + M_ASN1_STRING_data(priv_key->privateKey), + M_ASN1_STRING_length(priv_key->privateKey), + ret->priv_key); + if (ret->priv_key == NULL) + { + ECerr(EC_F_D2I_ECPRIVATEKEY, + ERR_R_BN_LIB); + goto err; + } + } + else + { + ECerr(EC_F_D2I_ECPRIVATEKEY, + EC_R_MISSING_PRIVATE_KEY); + goto err; + } + + if (priv_key->publicKey) + { + const unsigned char *pub_oct; + size_t pub_oct_len; + + if (ret->pub_key) + EC_POINT_clear_free(ret->pub_key); + ret->pub_key = EC_POINT_new(ret->group); + if (ret->pub_key == NULL) + { + ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_EC_LIB); + goto err; + } + pub_oct = M_ASN1_STRING_data(priv_key->publicKey); + pub_oct_len = M_ASN1_STRING_length(priv_key->publicKey); + /* save the point conversion form */ + ret->conv_form = (point_conversion_form_t)(pub_oct[0] & ~0x01); + if (!EC_POINT_oct2point(ret->group, ret->pub_key, + pub_oct, pub_oct_len, NULL)) + { + ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_EC_LIB); + goto err; + } + } + + ok = 1; +err: + if (!ok) + { + if (ret) + EC_KEY_free(ret); + ret = NULL; + } + + if (priv_key) + EC_PRIVATEKEY_free(priv_key); + + return(ret); + } + +int i2d_ECPrivateKey(EC_KEY *a, unsigned char **out) + { + int ret=0, ok=0; + unsigned char *buffer=NULL; + size_t buf_len=0, tmp_len; + EC_PRIVATEKEY *priv_key=NULL; + + if (a == NULL || a->group == NULL || a->priv_key == NULL) + { + ECerr(EC_F_I2D_ECPRIVATEKEY, + ERR_R_PASSED_NULL_PARAMETER); + goto err; + } + + if ((priv_key = EC_PRIVATEKEY_new()) == NULL) + { + ECerr(EC_F_I2D_ECPRIVATEKEY, + ERR_R_MALLOC_FAILURE); + goto err; + } + + priv_key->version = a->version; + + buf_len = (size_t)BN_num_bytes(a->priv_key); + buffer = OPENSSL_malloc(buf_len); + if (buffer == NULL) + { + ECerr(EC_F_I2D_ECPRIVATEKEY, + ERR_R_MALLOC_FAILURE); + goto err; + } + + if (!BN_bn2bin(a->priv_key, buffer)) + { + ECerr(EC_F_I2D_ECPRIVATEKEY, ERR_R_BN_LIB); + goto err; + } + + if (!M_ASN1_OCTET_STRING_set(priv_key->privateKey, buffer, buf_len)) + { + ECerr(EC_F_I2D_ECPRIVATEKEY, ERR_R_ASN1_LIB); + goto err; + } + + if (!(a->enc_flag & EC_PKEY_NO_PARAMETERS)) + { + if ((priv_key->parameters = ec_asn1_group2pkparameters( + a->group, priv_key->parameters)) == NULL) + { + ECerr(EC_F_I2D_ECPRIVATEKEY, ERR_R_EC_LIB); + goto err; + } + } + + if (!(a->enc_flag & EC_PKEY_NO_PUBKEY)) + { + priv_key->publicKey = M_ASN1_BIT_STRING_new(); + if (priv_key->publicKey == NULL) + { + ECerr(EC_F_I2D_ECPRIVATEKEY, + ERR_R_MALLOC_FAILURE); + goto err; + } + + tmp_len = EC_POINT_point2oct(a->group, a->pub_key, + a->conv_form, NULL, 0, NULL); + + if (tmp_len > buf_len) + { + unsigned char *tmp_buffer = OPENSSL_realloc(buffer, tmp_len); + if (!tmp_buffer) + { + ECerr(EC_F_I2D_ECPRIVATEKEY, ERR_R_MALLOC_FAILURE); + goto err; + } + buffer = tmp_buffer; + buf_len = tmp_len; + } + + if (!EC_POINT_point2oct(a->group, a->pub_key, + a->conv_form, buffer, buf_len, NULL)) + { + ECerr(EC_F_I2D_ECPRIVATEKEY, ERR_R_EC_LIB); + goto err; + } + + priv_key->publicKey->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); + priv_key->publicKey->flags |= ASN1_STRING_FLAG_BITS_LEFT; + if (!M_ASN1_BIT_STRING_set(priv_key->publicKey, buffer, + buf_len)) + { + ECerr(EC_F_I2D_ECPRIVATEKEY, ERR_R_ASN1_LIB); + goto err; + } + } + + if ((ret = i2d_EC_PRIVATEKEY(priv_key, out)) == 0) + { + ECerr(EC_F_I2D_ECPRIVATEKEY, ERR_R_EC_LIB); + goto err; + } + ok=1; +err: + if (buffer) + OPENSSL_free(buffer); + if (priv_key) + EC_PRIVATEKEY_free(priv_key); + return(ok?ret:0); + } + +int i2d_ECParameters(EC_KEY *a, unsigned char **out) + { + if (a == NULL) + { + ECerr(EC_F_I2D_ECPARAMETERS, ERR_R_PASSED_NULL_PARAMETER); + return 0; + } + return i2d_ECPKParameters(a->group, out); + } + +EC_KEY *d2i_ECParameters(EC_KEY **a, const unsigned char **in, long len) + { + EC_KEY *ret; + + if (in == NULL || *in == NULL) + { + ECerr(EC_F_D2I_ECPARAMETERS, ERR_R_PASSED_NULL_PARAMETER); + return NULL; + } + + if (a == NULL || *a == NULL) + { + if ((ret = EC_KEY_new()) == NULL) + { + ECerr(EC_F_D2I_ECPARAMETERS, ERR_R_MALLOC_FAILURE); + return NULL; + } + if (a) + *a = ret; + } + else + ret = *a; + + if (!d2i_ECPKParameters(&ret->group, in, len)) + { + ECerr(EC_F_D2I_ECPARAMETERS, ERR_R_EC_LIB); + return NULL; + } + + return ret; + } + +EC_KEY *o2i_ECPublicKey(EC_KEY **a, const unsigned char **in, long len) + { + EC_KEY *ret=NULL; + + if (a == NULL || (*a) == NULL || (*a)->group == NULL) + { + /* sorry, but a EC_GROUP-structur is necessary + * to set the public key */ + ECerr(EC_F_O2I_ECPUBLICKEY, ERR_R_PASSED_NULL_PARAMETER); + return 0; + } + ret = *a; + if (ret->pub_key == NULL && + (ret->pub_key = EC_POINT_new(ret->group)) == NULL) + { + ECerr(EC_F_O2I_ECPUBLICKEY, ERR_R_MALLOC_FAILURE); + return 0; + } + if (!EC_POINT_oct2point(ret->group, ret->pub_key, *in, len, NULL)) + { + ECerr(EC_F_O2I_ECPUBLICKEY, ERR_R_EC_LIB); + return 0; + } + /* save the point conversion form */ + ret->conv_form = (point_conversion_form_t)(*in[0] & ~0x01); + *in += len; + return ret; + } + +int i2o_ECPublicKey(EC_KEY *a, unsigned char **out) + { + size_t buf_len=0; + int new_buffer = 0; + + if (a == NULL) + { + ECerr(EC_F_I2O_ECPUBLICKEY, ERR_R_PASSED_NULL_PARAMETER); + return 0; + } + + buf_len = EC_POINT_point2oct(a->group, a->pub_key, + a->conv_form, NULL, 0, NULL); + + if (out == NULL || buf_len == 0) + /* out == NULL => just return the length of the octet string */ + return buf_len; + + if (*out == NULL) + { + if ((*out = OPENSSL_malloc(buf_len)) == NULL) + { + ECerr(EC_F_I2O_ECPUBLICKEY, ERR_R_MALLOC_FAILURE); + return 0; + } + new_buffer = 1; + } + if (!EC_POINT_point2oct(a->group, a->pub_key, a->conv_form, + *out, buf_len, NULL)) + { + ECerr(EC_F_I2O_ECPUBLICKEY, ERR_R_EC_LIB); + if (new_buffer) + { + OPENSSL_free(*out); + *out = NULL; + } + return 0; + } + if (!new_buffer) + *out += buf_len; + return buf_len; + } diff --git a/libs/openssl/crypto/ec/ec_check.c b/libs/openssl/crypto/ec/ec_check.c new file mode 100644 index 00000000..0e316b4b --- /dev/null +++ b/libs/openssl/crypto/ec/ec_check.c @@ -0,0 +1,123 @@ +/* crypto/ec/ec_check.c */ +/* ==================================================================== + * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include "ec_lcl.h" +#include + +int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx) + { + int ret = 0; + BIGNUM *order; + BN_CTX *new_ctx = NULL; + EC_POINT *point = NULL; + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + { + ECerr(EC_F_EC_GROUP_CHECK, ERR_R_MALLOC_FAILURE); + goto err; + } + } + BN_CTX_start(ctx); + if ((order = BN_CTX_get(ctx)) == NULL) goto err; + + /* check the discriminant */ + if (!EC_GROUP_check_discriminant(group, ctx)) + { + ECerr(EC_F_EC_GROUP_CHECK, EC_R_DISCRIMINANT_IS_ZERO); + goto err; + } + + /* check the generator */ + if (group->generator == NULL) + { + ECerr(EC_F_EC_GROUP_CHECK, EC_R_UNDEFINED_GENERATOR); + goto err; + } + if (!EC_POINT_is_on_curve(group, group->generator, ctx)) + { + ECerr(EC_F_EC_GROUP_CHECK, EC_R_POINT_IS_NOT_ON_CURVE); + goto err; + } + + /* check the order of the generator */ + if ((point = EC_POINT_new(group)) == NULL) goto err; + if (!EC_GROUP_get_order(group, order, ctx)) goto err; + if (BN_is_zero(order)) + { + ECerr(EC_F_EC_GROUP_CHECK, EC_R_UNDEFINED_ORDER); + goto err; + } + + if (!EC_POINT_mul(group, point, order, NULL, NULL, ctx)) goto err; + if (!EC_POINT_is_at_infinity(group, point)) + { + ECerr(EC_F_EC_GROUP_CHECK, EC_R_INVALID_GROUP_ORDER); + goto err; + } + + ret = 1; + +err: + if (ctx != NULL) + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + if (point) + EC_POINT_free(point); + return ret; + } diff --git a/libs/openssl/crypto/ec/ec_curve.c b/libs/openssl/crypto/ec/ec_curve.c new file mode 100644 index 00000000..c72fb269 --- /dev/null +++ b/libs/openssl/crypto/ec/ec_curve.c @@ -0,0 +1,2100 @@ +/* crypto/ec/ec_curve.c */ +/* + * Written by Nils Larsch for the OpenSSL project. + */ +/* ==================================================================== + * Copyright (c) 1998-2010 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * Portions of the attached software ("Contribution") are developed by + * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. + * + * The Contribution is licensed pursuant to the OpenSSL open source + * license provided above. + * + * The elliptic curve binary polynomial software is originally written by + * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. + * + */ + +#include "ec_lcl.h" +#include +#include +#include + +typedef struct { + int field_type, /* either NID_X9_62_prime_field or + * NID_X9_62_characteristic_two_field */ + seed_len, + param_len; + unsigned int cofactor; /* promoted to BN_ULONG */ +} EC_CURVE_DATA; + +/* the nist prime curves */ +static const struct { EC_CURVE_DATA h; unsigned char data[20+24*6]; } + _EC_NIST_PRIME_192 = { + { NID_X9_62_prime_field,20,24,1 }, + { 0x30,0x45,0xAE,0x6F,0xC8,0x42,0x2F,0x64,0xED,0x57, /* seed */ + 0x95,0x28,0xD3,0x81,0x20,0xEA,0xE1,0x21,0x96,0xD5, + + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFC, + 0x64,0x21,0x05,0x19,0xE5,0x9C,0x80,0xE7,0x0F,0xA7, /* b */ + 0xE9,0xAB,0x72,0x24,0x30,0x49,0xFE,0xB8,0xDE,0xEC, + 0xC1,0x46,0xB9,0xB1, + 0x18,0x8D,0xA8,0x0E,0xB0,0x30,0x90,0xF6,0x7C,0xBF, /* x */ + 0x20,0xEB,0x43,0xA1,0x88,0x00,0xF4,0xFF,0x0A,0xFD, + 0x82,0xFF,0x10,0x12, + 0x07,0x19,0x2b,0x95,0xff,0xc8,0xda,0x78,0x63,0x10, /* y */ + 0x11,0xed,0x6b,0x24,0xcd,0xd5,0x73,0xf9,0x77,0xa1, + 0x1e,0x79,0x48,0x11, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ + 0xFF,0xFF,0x99,0xDE,0xF8,0x36,0x14,0x6B,0xC9,0xB1, + 0xB4,0xD2,0x28,0x31 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+28*6]; } + _EC_NIST_PRIME_224 = { + { NID_X9_62_prime_field,20,28,1 }, + { 0xBD,0x71,0x34,0x47,0x99,0xD5,0xC7,0xFC,0xDC,0x45, /* seed */ + 0xB5,0x9F,0xA3,0xB9,0xAB,0x8F,0x6A,0x94,0x8B,0xC5, + + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE, + 0xB4,0x05,0x0A,0x85,0x0C,0x04,0xB3,0xAB,0xF5,0x41, /* b */ + 0x32,0x56,0x50,0x44,0xB0,0xB7,0xD7,0xBF,0xD8,0xBA, + 0x27,0x0B,0x39,0x43,0x23,0x55,0xFF,0xB4, + 0xB7,0x0E,0x0C,0xBD,0x6B,0xB4,0xBF,0x7F,0x32,0x13, /* x */ + 0x90,0xB9,0x4A,0x03,0xC1,0xD3,0x56,0xC2,0x11,0x22, + 0x34,0x32,0x80,0xD6,0x11,0x5C,0x1D,0x21, + 0xbd,0x37,0x63,0x88,0xb5,0xf7,0x23,0xfb,0x4c,0x22, /* y */ + 0xdf,0xe6,0xcd,0x43,0x75,0xa0,0x5a,0x07,0x47,0x64, + 0x44,0xd5,0x81,0x99,0x85,0x00,0x7e,0x34, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ + 0xFF,0xFF,0xFF,0xFF,0x16,0xA2,0xE0,0xB8,0xF0,0x3E, + 0x13,0xDD,0x29,0x45,0x5C,0x5C,0x2A,0x3D } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+48*6]; } + _EC_NIST_PRIME_384 = { + { NID_X9_62_prime_field,20,48,1 }, + { 0xA3,0x35,0x92,0x6A,0xA3,0x19,0xA2,0x7A,0x1D,0x00, /* seed */ + 0x89,0x6A,0x67,0x73,0xA4,0x82,0x7A,0xCD,0xAC,0x73, + + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFE,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFE,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFC, + 0xB3,0x31,0x2F,0xA7,0xE2,0x3E,0xE7,0xE4,0x98,0x8E, /* b */ + 0x05,0x6B,0xE3,0xF8,0x2D,0x19,0x18,0x1D,0x9C,0x6E, + 0xFE,0x81,0x41,0x12,0x03,0x14,0x08,0x8F,0x50,0x13, + 0x87,0x5A,0xC6,0x56,0x39,0x8D,0x8A,0x2E,0xD1,0x9D, + 0x2A,0x85,0xC8,0xED,0xD3,0xEC,0x2A,0xEF, + 0xAA,0x87,0xCA,0x22,0xBE,0x8B,0x05,0x37,0x8E,0xB1, /* x */ + 0xC7,0x1E,0xF3,0x20,0xAD,0x74,0x6E,0x1D,0x3B,0x62, + 0x8B,0xA7,0x9B,0x98,0x59,0xF7,0x41,0xE0,0x82,0x54, + 0x2A,0x38,0x55,0x02,0xF2,0x5D,0xBF,0x55,0x29,0x6C, + 0x3A,0x54,0x5E,0x38,0x72,0x76,0x0A,0xB7, + 0x36,0x17,0xde,0x4a,0x96,0x26,0x2c,0x6f,0x5d,0x9e, /* y */ + 0x98,0xbf,0x92,0x92,0xdc,0x29,0xf8,0xf4,0x1d,0xbd, + 0x28,0x9a,0x14,0x7c,0xe9,0xda,0x31,0x13,0xb5,0xf0, + 0xb8,0xc0,0x0a,0x60,0xb1,0xce,0x1d,0x7e,0x81,0x9d, + 0x7a,0x43,0x1d,0x7c,0x90,0xea,0x0e,0x5f, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xC7,0x63,0x4D,0x81,0xF4,0x37, + 0x2D,0xDF,0x58,0x1A,0x0D,0xB2,0x48,0xB0,0xA7,0x7A, + 0xEC,0xEC,0x19,0x6A,0xCC,0xC5,0x29,0x73 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+66*6]; } + _EC_NIST_PRIME_521 = { + { NID_X9_62_prime_field,20,66,1 }, + { 0xD0,0x9E,0x88,0x00,0x29,0x1C,0xB8,0x53,0x96,0xCC, /* seed */ + 0x67,0x17,0x39,0x32,0x84,0xAA,0xA0,0xDA,0x64,0xBA, + + 0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFC, + 0x00,0x51,0x95,0x3E,0xB9,0x61,0x8E,0x1C,0x9A,0x1F, /* b */ + 0x92,0x9A,0x21,0xA0,0xB6,0x85,0x40,0xEE,0xA2,0xDA, + 0x72,0x5B,0x99,0xB3,0x15,0xF3,0xB8,0xB4,0x89,0x91, + 0x8E,0xF1,0x09,0xE1,0x56,0x19,0x39,0x51,0xEC,0x7E, + 0x93,0x7B,0x16,0x52,0xC0,0xBD,0x3B,0xB1,0xBF,0x07, + 0x35,0x73,0xDF,0x88,0x3D,0x2C,0x34,0xF1,0xEF,0x45, + 0x1F,0xD4,0x6B,0x50,0x3F,0x00, + 0x00,0xC6,0x85,0x8E,0x06,0xB7,0x04,0x04,0xE9,0xCD, /* x */ + 0x9E,0x3E,0xCB,0x66,0x23,0x95,0xB4,0x42,0x9C,0x64, + 0x81,0x39,0x05,0x3F,0xB5,0x21,0xF8,0x28,0xAF,0x60, + 0x6B,0x4D,0x3D,0xBA,0xA1,0x4B,0x5E,0x77,0xEF,0xE7, + 0x59,0x28,0xFE,0x1D,0xC1,0x27,0xA2,0xFF,0xA8,0xDE, + 0x33,0x48,0xB3,0xC1,0x85,0x6A,0x42,0x9B,0xF9,0x7E, + 0x7E,0x31,0xC2,0xE5,0xBD,0x66, + 0x01,0x18,0x39,0x29,0x6a,0x78,0x9a,0x3b,0xc0,0x04, /* y */ + 0x5c,0x8a,0x5f,0xb4,0x2c,0x7d,0x1b,0xd9,0x98,0xf5, + 0x44,0x49,0x57,0x9b,0x44,0x68,0x17,0xaf,0xbd,0x17, + 0x27,0x3e,0x66,0x2c,0x97,0xee,0x72,0x99,0x5e,0xf4, + 0x26,0x40,0xc5,0x50,0xb9,0x01,0x3f,0xad,0x07,0x61, + 0x35,0x3c,0x70,0x86,0xa2,0x72,0xc2,0x40,0x88,0xbe, + 0x94,0x76,0x9f,0xd1,0x66,0x50, + 0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFA,0x51,0x86,0x87,0x83,0xBF,0x2F, + 0x96,0x6B,0x7F,0xCC,0x01,0x48,0xF7,0x09,0xA5,0xD0, + 0x3B,0xB5,0xC9,0xB8,0x89,0x9C,0x47,0xAE,0xBB,0x6F, + 0xB7,0x1E,0x91,0x38,0x64,0x09 } + }; + +/* the x9.62 prime curves (minus the nist prime curves) */ +static const struct { EC_CURVE_DATA h; unsigned char data[20+24*6]; } + _EC_X9_62_PRIME_192V2 = { + { NID_X9_62_prime_field,20,24,1 }, + { 0x31,0xA9,0x2E,0xE2,0x02,0x9F,0xD1,0x0D,0x90,0x1B, /* seed */ + 0x11,0x3E,0x99,0x07,0x10,0xF0,0xD2,0x1A,0xC6,0xB6, + + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFC, + 0xCC,0x22,0xD6,0xDF,0xB9,0x5C,0x6B,0x25,0xE4,0x9C, /* b */ + 0x0D,0x63,0x64,0xA4,0xE5,0x98,0x0C,0x39,0x3A,0xA2, + 0x16,0x68,0xD9,0x53, + 0xEE,0xA2,0xBA,0xE7,0xE1,0x49,0x78,0x42,0xF2,0xDE, /* x */ + 0x77,0x69,0xCF,0xE9,0xC9,0x89,0xC0,0x72,0xAD,0x69, + 0x6F,0x48,0x03,0x4A, + 0x65,0x74,0xd1,0x1d,0x69,0xb6,0xec,0x7a,0x67,0x2b, /* y */ + 0xb8,0x2a,0x08,0x3d,0xf2,0xf2,0xb0,0x84,0x7d,0xe9, + 0x70,0xb2,0xde,0x15, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ + 0xFF,0xFE,0x5F,0xB1,0xA7,0x24,0xDC,0x80,0x41,0x86, + 0x48,0xD8,0xDD,0x31 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+24*6]; } + _EC_X9_62_PRIME_192V3 = { + { NID_X9_62_prime_field,20,24,1 }, + { 0xC4,0x69,0x68,0x44,0x35,0xDE,0xB3,0x78,0xC4,0xB6, /* seed */ + 0x5C,0xA9,0x59,0x1E,0x2A,0x57,0x63,0x05,0x9A,0x2E, + + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFC, + 0x22,0x12,0x3D,0xC2,0x39,0x5A,0x05,0xCA,0xA7,0x42, /* b */ + 0x3D,0xAE,0xCC,0xC9,0x47,0x60,0xA7,0xD4,0x62,0x25, + 0x6B,0xD5,0x69,0x16, + 0x7D,0x29,0x77,0x81,0x00,0xC6,0x5A,0x1D,0xA1,0x78, /* x */ + 0x37,0x16,0x58,0x8D,0xCE,0x2B,0x8B,0x4A,0xEE,0x8E, + 0x22,0x8F,0x18,0x96, + 0x38,0xa9,0x0f,0x22,0x63,0x73,0x37,0x33,0x4b,0x49, /* y */ + 0xdc,0xb6,0x6a,0x6d,0xc8,0xf9,0x97,0x8a,0xca,0x76, + 0x48,0xa9,0x43,0xb0, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ + 0xFF,0xFF,0x7A,0x62,0xD0,0x31,0xC8,0x3F,0x42,0x94, + 0xF6,0x40,0xEC,0x13 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+30*6]; } + _EC_X9_62_PRIME_239V1 = { + { NID_X9_62_prime_field,20,30,1 }, + { 0xE4,0x3B,0xB4,0x60,0xF0,0xB8,0x0C,0xC0,0xC0,0xB0, /* seed */ + 0x75,0x79,0x8E,0x94,0x80,0x60,0xF8,0x32,0x1B,0x7D, + + 0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ + 0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00, + 0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF, + + 0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ + 0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00, + 0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFC, + + 0x6B,0x01,0x6C,0x3B,0xDC,0xF1,0x89,0x41,0xD0,0xD6, /* b */ + 0x54,0x92,0x14,0x75,0xCA,0x71,0xA9,0xDB,0x2F,0xB2, + 0x7D,0x1D,0x37,0x79,0x61,0x85,0xC2,0x94,0x2C,0x0A, + + 0x0F,0xFA,0x96,0x3C,0xDC,0xA8,0x81,0x6C,0xCC,0x33, /* x */ + 0xB8,0x64,0x2B,0xED,0xF9,0x05,0xC3,0xD3,0x58,0x57, + 0x3D,0x3F,0x27,0xFB,0xBD,0x3B,0x3C,0xB9,0xAA,0xAF, + + 0x7d,0xeb,0xe8,0xe4,0xe9,0x0a,0x5d,0xae,0x6e,0x40, /* y */ + 0x54,0xca,0x53,0x0b,0xa0,0x46,0x54,0xb3,0x68,0x18, + 0xce,0x22,0x6b,0x39,0xfc,0xcb,0x7b,0x02,0xf1,0xae, + + 0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ + 0xFF,0xFF,0x7F,0xFF,0xFF,0x9E,0x5E,0x9A,0x9F,0x5D, + 0x90,0x71,0xFB,0xD1,0x52,0x26,0x88,0x90,0x9D,0x0B } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+30*6]; } + _EC_X9_62_PRIME_239V2 = { + { NID_X9_62_prime_field,20,30,1 }, + { 0xE8,0xB4,0x01,0x16,0x04,0x09,0x53,0x03,0xCA,0x3B, /* seed */ + 0x80,0x99,0x98,0x2B,0xE0,0x9F,0xCB,0x9A,0xE6,0x16, + + 0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ + 0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00, + 0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF, + + 0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ + 0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00, + 0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFC, + + 0x61,0x7F,0xAB,0x68,0x32,0x57,0x6C,0xBB,0xFE,0xD5, /* b */ + 0x0D,0x99,0xF0,0x24,0x9C,0x3F,0xEE,0x58,0xB9,0x4B, + 0xA0,0x03,0x8C,0x7A,0xE8,0x4C,0x8C,0x83,0x2F,0x2C, + + 0x38,0xAF,0x09,0xD9,0x87,0x27,0x70,0x51,0x20,0xC9, /* x */ + 0x21,0xBB,0x5E,0x9E,0x26,0x29,0x6A,0x3C,0xDC,0xF2, + 0xF3,0x57,0x57,0xA0,0xEA,0xFD,0x87,0xB8,0x30,0xE7, + + 0x5b,0x01,0x25,0xe4,0xdb,0xea,0x0e,0xc7,0x20,0x6d, /* y */ + 0xa0,0xfc,0x01,0xd9,0xb0,0x81,0x32,0x9f,0xb5,0x55, + 0xde,0x6e,0xf4,0x60,0x23,0x7d,0xff,0x8b,0xe4,0xba, + + 0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ + 0xFF,0xFF,0x80,0x00,0x00,0xCF,0xA7,0xE8,0x59,0x43, + 0x77,0xD4,0x14,0xC0,0x38,0x21,0xBC,0x58,0x20,0x63 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+30*6]; } + _EC_X9_62_PRIME_239V3 = { + { NID_X9_62_prime_field,20,30,1 }, + { 0x7D,0x73,0x74,0x16,0x8F,0xFE,0x34,0x71,0xB6,0x0A, /* seed */ + 0x85,0x76,0x86,0xA1,0x94,0x75,0xD3,0xBF,0xA2,0xFF, + + 0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ + 0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00, + 0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF, + + 0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ + 0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00, + 0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFC, + + 0x25,0x57,0x05,0xFA,0x2A,0x30,0x66,0x54,0xB1,0xF4, /* b */ + 0xCB,0x03,0xD6,0xA7,0x50,0xA3,0x0C,0x25,0x01,0x02, + 0xD4,0x98,0x87,0x17,0xD9,0xBA,0x15,0xAB,0x6D,0x3E, + + 0x67,0x68,0xAE,0x8E,0x18,0xBB,0x92,0xCF,0xCF,0x00, /* x */ + 0x5C,0x94,0x9A,0xA2,0xC6,0xD9,0x48,0x53,0xD0,0xE6, + 0x60,0xBB,0xF8,0x54,0xB1,0xC9,0x50,0x5F,0xE9,0x5A, + + 0x16,0x07,0xe6,0x89,0x8f,0x39,0x0c,0x06,0xbc,0x1d, /* y */ + 0x55,0x2b,0xad,0x22,0x6f,0x3b,0x6f,0xcf,0xe4,0x8b, + 0x6e,0x81,0x84,0x99,0xaf,0x18,0xe3,0xed,0x6c,0xf3, + + 0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ + 0xFF,0xFF,0x7F,0xFF,0xFF,0x97,0x5D,0xEB,0x41,0xB3, + 0xA6,0x05,0x7C,0x3C,0x43,0x21,0x46,0x52,0x65,0x51 } + }; + + +static const struct { EC_CURVE_DATA h; unsigned char data[20+32*6]; } + _EC_X9_62_PRIME_256V1 = { + { NID_X9_62_prime_field,20,32,1 }, + { 0xC4,0x9D,0x36,0x08,0x86,0xE7,0x04,0x93,0x6A,0x66, /* seed */ + 0x78,0xE1,0x13,0x9D,0x26,0xB7,0x81,0x9F,0x7E,0x90, + + 0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x01,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x01,0x00,0x00, /* a */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFC, + 0x5A,0xC6,0x35,0xD8,0xAA,0x3A,0x93,0xE7,0xB3,0xEB, /* b */ + 0xBD,0x55,0x76,0x98,0x86,0xBC,0x65,0x1D,0x06,0xB0, + 0xCC,0x53,0xB0,0xF6,0x3B,0xCE,0x3C,0x3E,0x27,0xD2, + 0x60,0x4B, + 0x6B,0x17,0xD1,0xF2,0xE1,0x2C,0x42,0x47,0xF8,0xBC, /* x */ + 0xE6,0xE5,0x63,0xA4,0x40,0xF2,0x77,0x03,0x7D,0x81, + 0x2D,0xEB,0x33,0xA0,0xF4,0xA1,0x39,0x45,0xD8,0x98, + 0xC2,0x96, + 0x4f,0xe3,0x42,0xe2,0xfe,0x1a,0x7f,0x9b,0x8e,0xe7, /* y */ + 0xeb,0x4a,0x7c,0x0f,0x9e,0x16,0x2b,0xce,0x33,0x57, + 0x6b,0x31,0x5e,0xce,0xcb,0xb6,0x40,0x68,0x37,0xbf, + 0x51,0xf5, + 0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0xFF,0xFF, /* order */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xBC,0xE6,0xFA,0xAD, + 0xA7,0x17,0x9E,0x84,0xF3,0xB9,0xCA,0xC2,0xFC,0x63, + 0x25,0x51 } + }; + +/* the secg prime curves (minus the nist and x9.62 prime curves) */ +static const struct { EC_CURVE_DATA h; unsigned char data[20+14*6]; } + _EC_SECG_PRIME_112R1 = { + { NID_X9_62_prime_field,20,14,1 }, + { 0x00,0xF5,0x0B,0x02,0x8E,0x4D,0x69,0x6E,0x67,0x68, /* seed */ + 0x75,0x61,0x51,0x75,0x29,0x04,0x72,0x78,0x3F,0xB1, + + 0xDB,0x7C,0x2A,0xBF,0x62,0xE3,0x5E,0x66,0x80,0x76, /* p */ + 0xBE,0xAD,0x20,0x8B, + 0xDB,0x7C,0x2A,0xBF,0x62,0xE3,0x5E,0x66,0x80,0x76, /* a */ + 0xBE,0xAD,0x20,0x88, + 0x65,0x9E,0xF8,0xBA,0x04,0x39,0x16,0xEE,0xDE,0x89, /* b */ + 0x11,0x70,0x2B,0x22, + 0x09,0x48,0x72,0x39,0x99,0x5A,0x5E,0xE7,0x6B,0x55, /* x */ + 0xF9,0xC2,0xF0,0x98, + 0xa8,0x9c,0xe5,0xaf,0x87,0x24,0xc0,0xa2,0x3e,0x0e, /* y */ + 0x0f,0xf7,0x75,0x00, + 0xDB,0x7C,0x2A,0xBF,0x62,0xE3,0x5E,0x76,0x28,0xDF, /* order */ + 0xAC,0x65,0x61,0xC5 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+14*6]; } + _EC_SECG_PRIME_112R2 = { + { NID_X9_62_prime_field,20,14,4 }, + { 0x00,0x27,0x57,0xA1,0x11,0x4D,0x69,0x6E,0x67,0x68, /* seed */ + 0x75,0x61,0x51,0x75,0x53,0x16,0xC0,0x5E,0x0B,0xD4, + + 0xDB,0x7C,0x2A,0xBF,0x62,0xE3,0x5E,0x66,0x80,0x76, /* p */ + 0xBE,0xAD,0x20,0x8B, + 0x61,0x27,0xC2,0x4C,0x05,0xF3,0x8A,0x0A,0xAA,0xF6, /* a */ + 0x5C,0x0E,0xF0,0x2C, + 0x51,0xDE,0xF1,0x81,0x5D,0xB5,0xED,0x74,0xFC,0xC3, /* b */ + 0x4C,0x85,0xD7,0x09, + 0x4B,0xA3,0x0A,0xB5,0xE8,0x92,0xB4,0xE1,0x64,0x9D, /* x */ + 0xD0,0x92,0x86,0x43, + 0xad,0xcd,0x46,0xf5,0x88,0x2e,0x37,0x47,0xde,0xf3, /* y */ + 0x6e,0x95,0x6e,0x97, + 0x36,0xDF,0x0A,0xAF,0xD8,0xB8,0xD7,0x59,0x7C,0xA1, /* order */ + 0x05,0x20,0xD0,0x4B } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+16*6]; } + _EC_SECG_PRIME_128R1 = { + { NID_X9_62_prime_field,20,16,1 }, + { 0x00,0x0E,0x0D,0x4D,0x69,0x6E,0x67,0x68,0x75,0x61, /* seed */ + 0x51,0x75,0x0C,0xC0,0x3A,0x44,0x73,0xD0,0x36,0x79, + + 0xFF,0xFF,0xFF,0xFD,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFD,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFC, + 0xE8,0x75,0x79,0xC1,0x10,0x79,0xF4,0x3D,0xD8,0x24, /* b */ + 0x99,0x3C,0x2C,0xEE,0x5E,0xD3, + 0x16,0x1F,0xF7,0x52,0x8B,0x89,0x9B,0x2D,0x0C,0x28, /* x */ + 0x60,0x7C,0xA5,0x2C,0x5B,0x86, + 0xcf,0x5a,0xc8,0x39,0x5b,0xaf,0xeb,0x13,0xc0,0x2d, /* y */ + 0xa2,0x92,0xdd,0xed,0x7a,0x83, + 0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x75,0xA3, /* order */ + 0x0D,0x1B,0x90,0x38,0xA1,0x15 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+16*6]; } + _EC_SECG_PRIME_128R2 = { + { NID_X9_62_prime_field,20,16,4 }, + { 0x00,0x4D,0x69,0x6E,0x67,0x68,0x75,0x61,0x51,0x75, /* seed */ + 0x12,0xD8,0xF0,0x34,0x31,0xFC,0xE6,0x3B,0x88,0xF4, + + 0xFF,0xFF,0xFF,0xFD,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xD6,0x03,0x19,0x98,0xD1,0xB3,0xBB,0xFE,0xBF,0x59, /* a */ + 0xCC,0x9B,0xBF,0xF9,0xAE,0xE1, + 0x5E,0xEE,0xFC,0xA3,0x80,0xD0,0x29,0x19,0xDC,0x2C, /* b */ + 0x65,0x58,0xBB,0x6D,0x8A,0x5D, + 0x7B,0x6A,0xA5,0xD8,0x5E,0x57,0x29,0x83,0xE6,0xFB, /* x */ + 0x32,0xA7,0xCD,0xEB,0xC1,0x40, + 0x27,0xb6,0x91,0x6a,0x89,0x4d,0x3a,0xee,0x71,0x06, /* y */ + 0xfe,0x80,0x5f,0xc3,0x4b,0x44, + 0x3F,0xFF,0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xBE,0x00, /* order */ + 0x24,0x72,0x06,0x13,0xB5,0xA3 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[0+21*6]; } + _EC_SECG_PRIME_160K1 = { + { NID_X9_62_prime_field,0,21,1 }, + { /* no seed */ + 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xAC, + 0x73, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x07, + 0x00,0x3B,0x4C,0x38,0x2C,0xE3,0x7A,0xA1,0x92,0xA4, /* x */ + 0x01,0x9E,0x76,0x30,0x36,0xF4,0xF5,0xDD,0x4D,0x7E, + 0xBB, + 0x00,0x93,0x8c,0xf9,0x35,0x31,0x8f,0xdc,0xed,0x6b, /* y */ + 0xc2,0x82,0x86,0x53,0x17,0x33,0xc3,0xf0,0x3c,0x4f, + 0xee, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ + 0x01,0xB8,0xFA,0x16,0xDF,0xAB,0x9A,0xCA,0x16,0xB6, + 0xB3 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+21*6]; } + _EC_SECG_PRIME_160R1 = { + { NID_X9_62_prime_field,20,21,1 }, + { 0x10,0x53,0xCD,0xE4,0x2C,0x14,0xD6,0x96,0xE6,0x76, /* seed */ + 0x87,0x56,0x15,0x17,0x53,0x3B,0xF3,0xF8,0x33,0x45, + + 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0xFF, + 0xFF, + 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0xFF, + 0xFC, + 0x00,0x1C,0x97,0xBE,0xFC,0x54,0xBD,0x7A,0x8B,0x65, /* b */ + 0xAC,0xF8,0x9F,0x81,0xD4,0xD4,0xAD,0xC5,0x65,0xFA, + 0x45, + 0x00,0x4A,0x96,0xB5,0x68,0x8E,0xF5,0x73,0x28,0x46, /* x */ + 0x64,0x69,0x89,0x68,0xC3,0x8B,0xB9,0x13,0xCB,0xFC, + 0x82, + 0x00,0x23,0xa6,0x28,0x55,0x31,0x68,0x94,0x7d,0x59, /* y */ + 0xdc,0xc9,0x12,0x04,0x23,0x51,0x37,0x7a,0xc5,0xfb, + 0x32, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ + 0x01,0xF4,0xC8,0xF9,0x27,0xAE,0xD3,0xCA,0x75,0x22, + 0x57 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+21*6]; } + _EC_SECG_PRIME_160R2 = { + { NID_X9_62_prime_field,20,21,1 }, + { 0xB9,0x9B,0x99,0xB0,0x99,0xB3,0x23,0xE0,0x27,0x09, /* seed */ + 0xA4,0xD6,0x96,0xE6,0x76,0x87,0x56,0x15,0x17,0x51, + + 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xAC, + 0x73, + 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xAC, + 0x70, + 0x00,0xB4,0xE1,0x34,0xD3,0xFB,0x59,0xEB,0x8B,0xAB, /* b */ + 0x57,0x27,0x49,0x04,0x66,0x4D,0x5A,0xF5,0x03,0x88, + 0xBA, + 0x00,0x52,0xDC,0xB0,0x34,0x29,0x3A,0x11,0x7E,0x1F, /* x */ + 0x4F,0xF1,0x1B,0x30,0xF7,0x19,0x9D,0x31,0x44,0xCE, + 0x6D, + 0x00,0xfe,0xaf,0xfe,0xf2,0xe3,0x31,0xf2,0x96,0xe0, /* y */ + 0x71,0xfa,0x0d,0xf9,0x98,0x2c,0xfe,0xa7,0xd4,0x3f, + 0x2e, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ + 0x00,0x35,0x1E,0xE7,0x86,0xA8,0x18,0xF3,0xA1,0xA1, + 0x6B } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[0+24*6]; } + _EC_SECG_PRIME_192K1 = { + { NID_X9_62_prime_field,0,24,1 }, + { /* no seed */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE, + 0xFF,0xFF,0xEE,0x37, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x03, + 0xDB,0x4F,0xF1,0x0E,0xC0,0x57,0xE9,0xAE,0x26,0xB0, /* x */ + 0x7D,0x02,0x80,0xB7,0xF4,0x34,0x1D,0xA5,0xD1,0xB1, + 0xEA,0xE0,0x6C,0x7D, + 0x9b,0x2f,0x2f,0x6d,0x9c,0x56,0x28,0xa7,0x84,0x41, /* y */ + 0x63,0xd0,0x15,0xbe,0x86,0x34,0x40,0x82,0xaa,0x88, + 0xd9,0x5e,0x2f,0x9d, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ + 0xFF,0xFE,0x26,0xF2,0xFC,0x17,0x0F,0x69,0x46,0x6A, + 0x74,0xDE,0xFD,0x8D } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[0+29*6]; } + _EC_SECG_PRIME_224K1 = { + { NID_X9_62_prime_field,0,29,1 }, + { /* no seed */ + 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xE5,0x6D, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05, + 0x00,0xA1,0x45,0x5B,0x33,0x4D,0xF0,0x99,0xDF,0x30, /* x */ + 0xFC,0x28,0xA1,0x69,0xA4,0x67,0xE9,0xE4,0x70,0x75, + 0xA9,0x0F,0x7E,0x65,0x0E,0xB6,0xB7,0xA4,0x5C, + 0x00,0x7e,0x08,0x9f,0xed,0x7f,0xba,0x34,0x42,0x82, /* y */ + 0xca,0xfb,0xd6,0xf7,0xe3,0x19,0xf7,0xc0,0xb0,0xbd, + 0x59,0xe2,0xca,0x4b,0xdb,0x55,0x6d,0x61,0xa5, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ + 0x00,0x00,0x00,0x00,0x01,0xDC,0xE8,0xD2,0xEC,0x61, + 0x84,0xCA,0xF0,0xA9,0x71,0x76,0x9F,0xB1,0xF7 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[0+32*6]; } + _EC_SECG_PRIME_256K1 = { + { NID_X9_62_prime_field,0,32,1 }, + { /* no seed */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF, + 0xFC,0x2F, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x07, + 0x79,0xBE,0x66,0x7E,0xF9,0xDC,0xBB,0xAC,0x55,0xA0, /* x */ + 0x62,0x95,0xCE,0x87,0x0B,0x07,0x02,0x9B,0xFC,0xDB, + 0x2D,0xCE,0x28,0xD9,0x59,0xF2,0x81,0x5B,0x16,0xF8, + 0x17,0x98, + 0x48,0x3a,0xda,0x77,0x26,0xa3,0xc4,0x65,0x5d,0xa4, /* y */ + 0xfb,0xfc,0x0e,0x11,0x08,0xa8,0xfd,0x17,0xb4,0x48, + 0xa6,0x85,0x54,0x19,0x9c,0x47,0xd0,0x8f,0xfb,0x10, + 0xd4,0xb8, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xBA,0xAE,0xDC,0xE6, + 0xAF,0x48,0xA0,0x3B,0xBF,0xD2,0x5E,0x8C,0xD0,0x36, + 0x41,0x41 } + }; + +/* some wap/wtls curves */ +static const struct { EC_CURVE_DATA h; unsigned char data[0+15*6]; } + _EC_WTLS_8 = { + { NID_X9_62_prime_field,0,15,1 }, + { /* no seed */ + 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ + 0xFF,0xFF,0xFF,0xFD,0xE7, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ + 0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ + 0x00,0x00,0x00,0x00,0x03, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* x */ + 0x00,0x00,0x00,0x00,0x01, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* y */ + 0x00,0x00,0x00,0x00,0x02, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xEC,0xEA, /* order */ + 0x55,0x1A,0xD8,0x37,0xE9 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[0+21*6]; } + _EC_WTLS_9 = { + { NID_X9_62_prime_field,0,21,1 }, + { /* no seed */ + 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x80, + 0x8F, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x03, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* x */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* y */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x02, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ + 0x01,0xCD,0xC9,0x8A,0xE0,0xE2,0xDE,0x57,0x4A,0xBF, + 0x33 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[0+28*6]; } + _EC_WTLS_12 = { + { NID_X9_62_prime_field,0,28,1 }, + { /* no seed */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE, + 0xB4,0x05,0x0A,0x85,0x0C,0x04,0xB3,0xAB,0xF5,0x41, /* b */ + 0x32,0x56,0x50,0x44,0xB0,0xB7,0xD7,0xBF,0xD8,0xBA, + 0x27,0x0B,0x39,0x43,0x23,0x55,0xFF,0xB4, + 0xB7,0x0E,0x0C,0xBD,0x6B,0xB4,0xBF,0x7F,0x32,0x13, /* x */ + 0x90,0xB9,0x4A,0x03,0xC1,0xD3,0x56,0xC2,0x11,0x22, + 0x34,0x32,0x80,0xD6,0x11,0x5C,0x1D,0x21, + 0xbd,0x37,0x63,0x88,0xb5,0xf7,0x23,0xfb,0x4c,0x22, /* y */ + 0xdf,0xe6,0xcd,0x43,0x75,0xa0,0x5a,0x07,0x47,0x64, + 0x44,0xd5,0x81,0x99,0x85,0x00,0x7e,0x34, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ + 0xFF,0xFF,0xFF,0xFF,0x16,0xA2,0xE0,0xB8,0xF0,0x3E, + 0x13,0xDD,0x29,0x45,0x5C,0x5C,0x2A,0x3D } + }; + +#ifndef OPENSSL_NO_EC2M + +/* characteristic two curves */ +static const struct { EC_CURVE_DATA h; unsigned char data[20+15*6]; } + _EC_SECG_CHAR2_113R1 = { + { NID_X9_62_characteristic_two_field,20,15,2 }, + { 0x10,0xE7,0x23,0xAB,0x14,0xD6,0x96,0xE6,0x76,0x87, /* seed */ + 0x56,0x15,0x17,0x56,0xFE,0xBF,0x8F,0xCB,0x49,0xA9, + + 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x02,0x01, + 0x00,0x30,0x88,0x25,0x0C,0xA6,0xE7,0xC7,0xFE,0x64, /* a */ + 0x9C,0xE8,0x58,0x20,0xF7, + 0x00,0xE8,0xBE,0xE4,0xD3,0xE2,0x26,0x07,0x44,0x18, /* b */ + 0x8B,0xE0,0xE9,0xC7,0x23, + 0x00,0x9D,0x73,0x61,0x6F,0x35,0xF4,0xAB,0x14,0x07, /* x */ + 0xD7,0x35,0x62,0xC1,0x0F, + 0x00,0xA5,0x28,0x30,0x27,0x79,0x58,0xEE,0x84,0xD1, /* y */ + 0x31,0x5E,0xD3,0x18,0x86, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xD9,0xCC, /* order */ + 0xEC,0x8A,0x39,0xE5,0x6F } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+15*6]; } + _EC_SECG_CHAR2_113R2 = { + { NID_X9_62_characteristic_two_field,20,15,2 }, + { 0x10,0xC0,0xFB,0x15,0x76,0x08,0x60,0xDE,0xF1,0xEE, /* seed */ + 0xF4,0xD6,0x96,0xE6,0x76,0x87,0x56,0x15,0x17,0x5D, + + 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x02,0x01, + 0x00,0x68,0x99,0x18,0xDB,0xEC,0x7E,0x5A,0x0D,0xD6, /* a */ + 0xDF,0xC0,0xAA,0x55,0xC7, + 0x00,0x95,0xE9,0xA9,0xEC,0x9B,0x29,0x7B,0xD4,0xBF, /* b */ + 0x36,0xE0,0x59,0x18,0x4F, + 0x01,0xA5,0x7A,0x6A,0x7B,0x26,0xCA,0x5E,0xF5,0x2F, /* x */ + 0xCD,0xB8,0x16,0x47,0x97, + 0x00,0xB3,0xAD,0xC9,0x4E,0xD1,0xFE,0x67,0x4C,0x06, /* y */ + 0xE6,0x95,0xBA,0xBA,0x1D, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x08,0x78, /* order */ + 0x9B,0x24,0x96,0xAF,0x93 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+17*6]; } + _EC_SECG_CHAR2_131R1 = { + { NID_X9_62_characteristic_two_field,20,17,2 }, + { 0x4D,0x69,0x6E,0x67,0x68,0x75,0x61,0x51,0x75,0x98, /* seed */ + 0x5B,0xD3,0xAD,0xBA,0xDA,0x21,0xB4,0x3A,0x97,0xE2, + + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x01,0x0D, + 0x07,0xA1,0x1B,0x09,0xA7,0x6B,0x56,0x21,0x44,0x41, /* a */ + 0x8F,0xF3,0xFF,0x8C,0x25,0x70,0xB8, + 0x02,0x17,0xC0,0x56,0x10,0x88,0x4B,0x63,0xB9,0xC6, /* b */ + 0xC7,0x29,0x16,0x78,0xF9,0xD3,0x41, + 0x00,0x81,0xBA,0xF9,0x1F,0xDF,0x98,0x33,0xC4,0x0F, /* x */ + 0x9C,0x18,0x13,0x43,0x63,0x83,0x99, + 0x07,0x8C,0x6E,0x7E,0xA3,0x8C,0x00,0x1F,0x73,0xC8, /* y */ + 0x13,0x4B,0x1B,0x4E,0xF9,0xE1,0x50, + 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x31, /* order */ + 0x23,0x95,0x3A,0x94,0x64,0xB5,0x4D } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+17*6]; } + _EC_SECG_CHAR2_131R2 = { + { NID_X9_62_characteristic_two_field,20,17,2 }, + { 0x98,0x5B,0xD3,0xAD,0xBA,0xD4,0xD6,0x96,0xE6,0x76, /* seed */ + 0x87,0x56,0x15,0x17,0x5A,0x21,0xB4,0x3A,0x97,0xE3, + + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x01,0x0D, + 0x03,0xE5,0xA8,0x89,0x19,0xD7,0xCA,0xFC,0xBF,0x41, /* a */ + 0x5F,0x07,0xC2,0x17,0x65,0x73,0xB2, + 0x04,0xB8,0x26,0x6A,0x46,0xC5,0x56,0x57,0xAC,0x73, /* b */ + 0x4C,0xE3,0x8F,0x01,0x8F,0x21,0x92, + 0x03,0x56,0xDC,0xD8,0xF2,0xF9,0x50,0x31,0xAD,0x65, /* x */ + 0x2D,0x23,0x95,0x1B,0xB3,0x66,0xA8, + 0x06,0x48,0xF0,0x6D,0x86,0x79,0x40,0xA5,0x36,0x6D, /* y */ + 0x9E,0x26,0x5D,0xE9,0xEB,0x24,0x0F, + 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x69, /* order */ + 0x54,0xA2,0x33,0x04,0x9B,0xA9,0x8F } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[0+21*6]; } + _EC_NIST_CHAR2_163K = { + { NID_X9_62_characteristic_two_field,0,21,2 }, + { /* no seed */ + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xC9, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01, + 0x02,0xFE,0x13,0xC0,0x53,0x7B,0xBC,0x11,0xAC,0xAA, /* x */ + 0x07,0xD7,0x93,0xDE,0x4E,0x6D,0x5E,0x5C,0x94,0xEE, + 0xE8, + 0x02,0x89,0x07,0x0F,0xB0,0x5D,0x38,0xFF,0x58,0x32, /* y */ + 0x1F,0x2E,0x80,0x05,0x36,0xD5,0x38,0xCC,0xDA,0xA3, + 0xD9, + 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ + 0x02,0x01,0x08,0xA2,0xE0,0xCC,0x0D,0x99,0xF8,0xA5, + 0xEF } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[0+21*6]; } + _EC_SECG_CHAR2_163R1 = { + { NID_X9_62_characteristic_two_field,0,21,2 }, + { /* no seed */ +#if 0 +/* The algorithm used to derive the curve parameters from + * the seed used here is slightly different than the + * algorithm described in X9.62 . */ + 0x24,0xB7,0xB1,0x37,0xC8,0xA1,0x4D,0x69,0x6E,0x67, + 0x68,0x75,0x61,0x51,0x75,0x6F,0xD0,0xDA,0x2E,0x5C, +#endif + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xC9, + 0x07,0xB6,0x88,0x2C,0xAA,0xEF,0xA8,0x4F,0x95,0x54, /* a */ + 0xFF,0x84,0x28,0xBD,0x88,0xE2,0x46,0xD2,0x78,0x2A, + 0xE2, + 0x07,0x13,0x61,0x2D,0xCD,0xDC,0xB4,0x0A,0xAB,0x94, /* b */ + 0x6B,0xDA,0x29,0xCA,0x91,0xF7,0x3A,0xF9,0x58,0xAF, + 0xD9, + 0x03,0x69,0x97,0x96,0x97,0xAB,0x43,0x89,0x77,0x89, /* x */ + 0x56,0x67,0x89,0x56,0x7F,0x78,0x7A,0x78,0x76,0xA6, + 0x54, + 0x00,0x43,0x5E,0xDB,0x42,0xEF,0xAF,0xB2,0x98,0x9D, /* y */ + 0x51,0xFE,0xFC,0xE3,0xC8,0x09,0x88,0xF4,0x1F,0xF8, + 0x83, + 0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ + 0xFF,0x48,0xAA,0xB6,0x89,0xC2,0x9C,0xA7,0x10,0x27, + 0x9B } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[0+21*6]; } + _EC_NIST_CHAR2_163B = { + { NID_X9_62_characteristic_two_field,0,21,2 }, + { /* no seed */ +#if 0 +/* The seed here was used to created the curve parameters in normal + * basis representation (and not the polynomial representation used here) */ + 0x85,0xE2,0x5B,0xFE,0x5C,0x86,0x22,0x6C,0xDB,0x12, + 0x01,0x6F,0x75,0x53,0xF9,0xD0,0xE6,0x93,0xA2,0x68, +#endif + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xC9, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01, + 0x02,0x0A,0x60,0x19,0x07,0xB8,0xC9,0x53,0xCA,0x14, /* b */ + 0x81,0xEB,0x10,0x51,0x2F,0x78,0x74,0x4A,0x32,0x05, + 0xFD, + 0x03,0xF0,0xEB,0xA1,0x62,0x86,0xA2,0xD5,0x7E,0xA0, /* x */ + 0x99,0x11,0x68,0xD4,0x99,0x46,0x37,0xE8,0x34,0x3E, + 0x36, + 0x00,0xD5,0x1F,0xBC,0x6C,0x71,0xA0,0x09,0x4F,0xA2, /* y */ + 0xCD,0xD5,0x45,0xB1,0x1C,0x5C,0x0C,0x79,0x73,0x24, + 0xF1, + 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ + 0x02,0x92,0xFE,0x77,0xE7,0x0C,0x12,0xA4,0x23,0x4C, + 0x33 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+25*6]; } + _EC_SECG_CHAR2_193R1 = { + { NID_X9_62_characteristic_two_field,20,25,2 }, + { 0x10,0x3F,0xAE,0xC7,0x4D,0x69,0x6E,0x67,0x68,0x75, /* seed */ + 0x61,0x51,0x75,0x77,0x7F,0xC5,0xB1,0x91,0xEF,0x30, + + 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x80,0x01, + 0x00,0x17,0x85,0x8F,0xEB,0x7A,0x98,0x97,0x51,0x69, /* a */ + 0xE1,0x71,0xF7,0x7B,0x40,0x87,0xDE,0x09,0x8A,0xC8, + 0xA9,0x11,0xDF,0x7B,0x01, + 0x00,0xFD,0xFB,0x49,0xBF,0xE6,0xC3,0xA8,0x9F,0xAC, /* b */ + 0xAD,0xAA,0x7A,0x1E,0x5B,0xBC,0x7C,0xC1,0xC2,0xE5, + 0xD8,0x31,0x47,0x88,0x14, + 0x01,0xF4,0x81,0xBC,0x5F,0x0F,0xF8,0x4A,0x74,0xAD, /* x */ + 0x6C,0xDF,0x6F,0xDE,0xF4,0xBF,0x61,0x79,0x62,0x53, + 0x72,0xD8,0xC0,0xC5,0xE1, + 0x00,0x25,0xE3,0x99,0xF2,0x90,0x37,0x12,0xCC,0xF3, /* y */ + 0xEA,0x9E,0x3A,0x1A,0xD1,0x7F,0xB0,0xB3,0x20,0x1B, + 0x6A,0xF7,0xCE,0x1B,0x05, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ + 0x00,0x00,0x00,0xC7,0xF3,0x4A,0x77,0x8F,0x44,0x3A, + 0xCC,0x92,0x0E,0xBA,0x49 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+25*6]; } + _EC_SECG_CHAR2_193R2 = { + { NID_X9_62_characteristic_two_field,20,25,2 }, + { 0x10,0xB7,0xB4,0xD6,0x96,0xE6,0x76,0x87,0x56,0x15, /* seed */ + 0x17,0x51,0x37,0xC8,0xA1,0x6F,0xD0,0xDA,0x22,0x11, + + 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x80,0x01, + 0x01,0x63,0xF3,0x5A,0x51,0x37,0xC2,0xCE,0x3E,0xA6, /* a */ + 0xED,0x86,0x67,0x19,0x0B,0x0B,0xC4,0x3E,0xCD,0x69, + 0x97,0x77,0x02,0x70,0x9B, + 0x00,0xC9,0xBB,0x9E,0x89,0x27,0xD4,0xD6,0x4C,0x37, /* b */ + 0x7E,0x2A,0xB2,0x85,0x6A,0x5B,0x16,0xE3,0xEF,0xB7, + 0xF6,0x1D,0x43,0x16,0xAE, + 0x00,0xD9,0xB6,0x7D,0x19,0x2E,0x03,0x67,0xC8,0x03, /* x */ + 0xF3,0x9E,0x1A,0x7E,0x82,0xCA,0x14,0xA6,0x51,0x35, + 0x0A,0xAE,0x61,0x7E,0x8F, + 0x01,0xCE,0x94,0x33,0x56,0x07,0xC3,0x04,0xAC,0x29, /* y */ + 0xE7,0xDE,0xFB,0xD9,0xCA,0x01,0xF5,0x96,0xF9,0x27, + 0x22,0x4C,0xDE,0xCF,0x6C, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ + 0x00,0x00,0x01,0x5A,0xAB,0x56,0x1B,0x00,0x54,0x13, + 0xCC,0xD4,0xEE,0x99,0xD5 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[0+30*6]; } + _EC_NIST_CHAR2_233K = { + { NID_X9_62_characteristic_two_field,0,30,4 }, + { /* no seed */ + 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, + + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, + + 0x01,0x72,0x32,0xBA,0x85,0x3A,0x7E,0x73,0x1A,0xF1, /* x */ + 0x29,0xF2,0x2F,0xF4,0x14,0x95,0x63,0xA4,0x19,0xC2, + 0x6B,0xF5,0x0A,0x4C,0x9D,0x6E,0xEF,0xAD,0x61,0x26, + + 0x01,0xDB,0x53,0x7D,0xEC,0xE8,0x19,0xB7,0xF7,0x0F, /* y */ + 0x55,0x5A,0x67,0xC4,0x27,0xA8,0xCD,0x9B,0xF1,0x8A, + 0xEB,0x9B,0x56,0xE0,0xC1,0x10,0x56,0xFA,0xE6,0xA3, + + 0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ + 0x00,0x00,0x00,0x00,0x00,0x06,0x9D,0x5B,0xB9,0x15, + 0xBC,0xD4,0x6E,0xFB,0x1A,0xD5,0xF1,0x73,0xAB,0xDF } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+30*6]; } + _EC_NIST_CHAR2_233B = { + { NID_X9_62_characteristic_two_field,20,30,2 }, + { 0x74,0xD5,0x9F,0xF0,0x7F,0x6B,0x41,0x3D,0x0E,0xA1, /* seed */ + 0x4B,0x34,0x4B,0x20,0xA2,0xDB,0x04,0x9B,0x50,0xC3, + + 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, + + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, + + 0x00,0x66,0x64,0x7E,0xDE,0x6C,0x33,0x2C,0x7F,0x8C, /* b */ + 0x09,0x23,0xBB,0x58,0x21,0x3B,0x33,0x3B,0x20,0xE9, + 0xCE,0x42,0x81,0xFE,0x11,0x5F,0x7D,0x8F,0x90,0xAD, + + 0x00,0xFA,0xC9,0xDF,0xCB,0xAC,0x83,0x13,0xBB,0x21, /* x */ + 0x39,0xF1,0xBB,0x75,0x5F,0xEF,0x65,0xBC,0x39,0x1F, + 0x8B,0x36,0xF8,0xF8,0xEB,0x73,0x71,0xFD,0x55,0x8B, + + 0x01,0x00,0x6A,0x08,0xA4,0x19,0x03,0x35,0x06,0x78, /* y */ + 0xE5,0x85,0x28,0xBE,0xBF,0x8A,0x0B,0xEF,0xF8,0x67, + 0xA7,0xCA,0x36,0x71,0x6F,0x7E,0x01,0xF8,0x10,0x52, + + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ + 0x00,0x00,0x00,0x00,0x00,0x13,0xE9,0x74,0xE7,0x2F, + 0x8A,0x69,0x22,0x03,0x1D,0x26,0x03,0xCF,0xE0,0xD7 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[0+30*6]; } + _EC_SECG_CHAR2_239K1 = { + { NID_X9_62_characteristic_two_field,0,30,4 }, + { /* no seed */ + 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, + + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, + + 0x29,0xA0,0xB6,0xA8,0x87,0xA9,0x83,0xE9,0x73,0x09, /* x */ + 0x88,0xA6,0x87,0x27,0xA8,0xB2,0xD1,0x26,0xC4,0x4C, + 0xC2,0xCC,0x7B,0x2A,0x65,0x55,0x19,0x30,0x35,0xDC, + + 0x76,0x31,0x08,0x04,0xF1,0x2E,0x54,0x9B,0xDB,0x01, /* y */ + 0x1C,0x10,0x30,0x89,0xE7,0x35,0x10,0xAC,0xB2,0x75, + 0xFC,0x31,0x2A,0x5D,0xC6,0xB7,0x65,0x53,0xF0,0xCA, + + 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ + 0x00,0x00,0x00,0x00,0x00,0x5A,0x79,0xFE,0xC6,0x7C, + 0xB6,0xE9,0x1F,0x1C,0x1D,0xA8,0x00,0xE4,0x78,0xA5 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[0+36*6]; } + _EC_NIST_CHAR2_283K = { + { NID_X9_62_characteristic_two_field,0,36,4 }, + { /* no seed */ + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x10,0xA1, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x01, + 0x05,0x03,0x21,0x3F,0x78,0xCA,0x44,0x88,0x3F,0x1A, /* x */ + 0x3B,0x81,0x62,0xF1,0x88,0xE5,0x53,0xCD,0x26,0x5F, + 0x23,0xC1,0x56,0x7A,0x16,0x87,0x69,0x13,0xB0,0xC2, + 0xAC,0x24,0x58,0x49,0x28,0x36, + 0x01,0xCC,0xDA,0x38,0x0F,0x1C,0x9E,0x31,0x8D,0x90, /* y */ + 0xF9,0x5D,0x07,0xE5,0x42,0x6F,0xE8,0x7E,0x45,0xC0, + 0xE8,0x18,0x46,0x98,0xE4,0x59,0x62,0x36,0x4E,0x34, + 0x11,0x61,0x77,0xDD,0x22,0x59, + 0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE9,0xAE, + 0x2E,0xD0,0x75,0x77,0x26,0x5D,0xFF,0x7F,0x94,0x45, + 0x1E,0x06,0x1E,0x16,0x3C,0x61 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+36*6]; } + _EC_NIST_CHAR2_283B = { + { NID_X9_62_characteristic_two_field,20,36,2 }, + { 0x77,0xE2,0xB0,0x73,0x70,0xEB,0x0F,0x83,0x2A,0x6D, /* no seed */ + 0xD5,0xB6,0x2D,0xFC,0x88,0xCD,0x06,0xBB,0x84,0xBE, + + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x10,0xA1, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x01, + 0x02,0x7B,0x68,0x0A,0xC8,0xB8,0x59,0x6D,0xA5,0xA4, /* b */ + 0xAF,0x8A,0x19,0xA0,0x30,0x3F,0xCA,0x97,0xFD,0x76, + 0x45,0x30,0x9F,0xA2,0xA5,0x81,0x48,0x5A,0xF6,0x26, + 0x3E,0x31,0x3B,0x79,0xA2,0xF5, + 0x05,0xF9,0x39,0x25,0x8D,0xB7,0xDD,0x90,0xE1,0x93, /* x */ + 0x4F,0x8C,0x70,0xB0,0xDF,0xEC,0x2E,0xED,0x25,0xB8, + 0x55,0x7E,0xAC,0x9C,0x80,0xE2,0xE1,0x98,0xF8,0xCD, + 0xBE,0xCD,0x86,0xB1,0x20,0x53, + 0x03,0x67,0x68,0x54,0xFE,0x24,0x14,0x1C,0xB9,0x8F, /* y */ + 0xE6,0xD4,0xB2,0x0D,0x02,0xB4,0x51,0x6F,0xF7,0x02, + 0x35,0x0E,0xDD,0xB0,0x82,0x67,0x79,0xC8,0x13,0xF0, + 0xDF,0x45,0xBE,0x81,0x12,0xF4, + 0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xEF,0x90, + 0x39,0x96,0x60,0xFC,0x93,0x8A,0x90,0x16,0x5B,0x04, + 0x2A,0x7C,0xEF,0xAD,0xB3,0x07 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[0+52*6]; } + _EC_NIST_CHAR2_409K = { + { NID_X9_62_characteristic_two_field,0,52,4 }, + { /* no seed */ + 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x01, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x01, + 0x00,0x60,0xF0,0x5F,0x65,0x8F,0x49,0xC1,0xAD,0x3A, /* x */ + 0xB1,0x89,0x0F,0x71,0x84,0x21,0x0E,0xFD,0x09,0x87, + 0xE3,0x07,0xC8,0x4C,0x27,0xAC,0xCF,0xB8,0xF9,0xF6, + 0x7C,0xC2,0xC4,0x60,0x18,0x9E,0xB5,0xAA,0xAA,0x62, + 0xEE,0x22,0x2E,0xB1,0xB3,0x55,0x40,0xCF,0xE9,0x02, + 0x37,0x46, + 0x01,0xE3,0x69,0x05,0x0B,0x7C,0x4E,0x42,0xAC,0xBA, /* y */ + 0x1D,0xAC,0xBF,0x04,0x29,0x9C,0x34,0x60,0x78,0x2F, + 0x91,0x8E,0xA4,0x27,0xE6,0x32,0x51,0x65,0xE9,0xEA, + 0x10,0xE3,0xDA,0x5F,0x6C,0x42,0xE9,0xC5,0x52,0x15, + 0xAA,0x9C,0xA2,0x7A,0x58,0x63,0xEC,0x48,0xD8,0xE0, + 0x28,0x6B, + 0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0x5F,0x83,0xB2, + 0xD4,0xEA,0x20,0x40,0x0E,0xC4,0x55,0x7D,0x5E,0xD3, + 0xE3,0xE7,0xCA,0x5B,0x4B,0x5C,0x83,0xB8,0xE0,0x1E, + 0x5F,0xCF } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+52*6]; } + _EC_NIST_CHAR2_409B = { + { NID_X9_62_characteristic_two_field,20,52,2 }, + { 0x40,0x99,0xB5,0xA4,0x57,0xF9,0xD6,0x9F,0x79,0x21, /* seed */ + 0x3D,0x09,0x4C,0x4B,0xCD,0x4D,0x42,0x62,0x21,0x0B, + + 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x01, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x01, + 0x00,0x21,0xA5,0xC2,0xC8,0xEE,0x9F,0xEB,0x5C,0x4B, /* b */ + 0x9A,0x75,0x3B,0x7B,0x47,0x6B,0x7F,0xD6,0x42,0x2E, + 0xF1,0xF3,0xDD,0x67,0x47,0x61,0xFA,0x99,0xD6,0xAC, + 0x27,0xC8,0xA9,0xA1,0x97,0xB2,0x72,0x82,0x2F,0x6C, + 0xD5,0x7A,0x55,0xAA,0x4F,0x50,0xAE,0x31,0x7B,0x13, + 0x54,0x5F, + 0x01,0x5D,0x48,0x60,0xD0,0x88,0xDD,0xB3,0x49,0x6B, /* x */ + 0x0C,0x60,0x64,0x75,0x62,0x60,0x44,0x1C,0xDE,0x4A, + 0xF1,0x77,0x1D,0x4D,0xB0,0x1F,0xFE,0x5B,0x34,0xE5, + 0x97,0x03,0xDC,0x25,0x5A,0x86,0x8A,0x11,0x80,0x51, + 0x56,0x03,0xAE,0xAB,0x60,0x79,0x4E,0x54,0xBB,0x79, + 0x96,0xA7, + 0x00,0x61,0xB1,0xCF,0xAB,0x6B,0xE5,0xF3,0x2B,0xBF, /* y */ + 0xA7,0x83,0x24,0xED,0x10,0x6A,0x76,0x36,0xB9,0xC5, + 0xA7,0xBD,0x19,0x8D,0x01,0x58,0xAA,0x4F,0x54,0x88, + 0xD0,0x8F,0x38,0x51,0x4F,0x1F,0xDF,0x4B,0x4F,0x40, + 0xD2,0x18,0x1B,0x36,0x81,0xC3,0x64,0xBA,0x02,0x73, + 0xC7,0x06, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xE2,0xAA,0xD6, + 0xA6,0x12,0xF3,0x33,0x07,0xBE,0x5F,0xA4,0x7C,0x3C, + 0x9E,0x05,0x2F,0x83,0x81,0x64,0xCD,0x37,0xD9,0xA2, + 0x11,0x73 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[0+72*6]; } + _EC_NIST_CHAR2_571K = { + { NID_X9_62_characteristic_two_field,0,72,4 }, + { /* no seed */ + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x04,0x25, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x01, + 0x02,0x6E,0xB7,0xA8,0x59,0x92,0x3F,0xBC,0x82,0x18, /* x */ + 0x96,0x31,0xF8,0x10,0x3F,0xE4,0xAC,0x9C,0xA2,0x97, + 0x00,0x12,0xD5,0xD4,0x60,0x24,0x80,0x48,0x01,0x84, + 0x1C,0xA4,0x43,0x70,0x95,0x84,0x93,0xB2,0x05,0xE6, + 0x47,0xDA,0x30,0x4D,0xB4,0xCE,0xB0,0x8C,0xBB,0xD1, + 0xBA,0x39,0x49,0x47,0x76,0xFB,0x98,0x8B,0x47,0x17, + 0x4D,0xCA,0x88,0xC7,0xE2,0x94,0x52,0x83,0xA0,0x1C, + 0x89,0x72, + 0x03,0x49,0xDC,0x80,0x7F,0x4F,0xBF,0x37,0x4F,0x4A, /* y */ + 0xEA,0xDE,0x3B,0xCA,0x95,0x31,0x4D,0xD5,0x8C,0xEC, + 0x9F,0x30,0x7A,0x54,0xFF,0xC6,0x1E,0xFC,0x00,0x6D, + 0x8A,0x2C,0x9D,0x49,0x79,0xC0,0xAC,0x44,0xAE,0xA7, + 0x4F,0xBE,0xBB,0xB9,0xF7,0x72,0xAE,0xDC,0xB6,0x20, + 0xB0,0x1A,0x7B,0xA7,0xAF,0x1B,0x32,0x04,0x30,0xC8, + 0x59,0x19,0x84,0xF6,0x01,0xCD,0x4C,0x14,0x3E,0xF1, + 0xC7,0xA3, + 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x13,0x18,0x50,0xE1, + 0xF1,0x9A,0x63,0xE4,0xB3,0x91,0xA8,0xDB,0x91,0x7F, + 0x41,0x38,0xB6,0x30,0xD8,0x4B,0xE5,0xD6,0x39,0x38, + 0x1E,0x91,0xDE,0xB4,0x5C,0xFE,0x77,0x8F,0x63,0x7C, + 0x10,0x01 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+72*6]; } + _EC_NIST_CHAR2_571B = { + { NID_X9_62_characteristic_two_field,20,72,2 }, + { 0x2A,0xA0,0x58,0xF7,0x3A,0x0E,0x33,0xAB,0x48,0x6B, /* seed */ + 0x0F,0x61,0x04,0x10,0xC5,0x3A,0x7F,0x13,0x23,0x10, + + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x04,0x25, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x01, + 0x02,0xF4,0x0E,0x7E,0x22,0x21,0xF2,0x95,0xDE,0x29, /* b */ + 0x71,0x17,0xB7,0xF3,0xD6,0x2F,0x5C,0x6A,0x97,0xFF, + 0xCB,0x8C,0xEF,0xF1,0xCD,0x6B,0xA8,0xCE,0x4A,0x9A, + 0x18,0xAD,0x84,0xFF,0xAB,0xBD,0x8E,0xFA,0x59,0x33, + 0x2B,0xE7,0xAD,0x67,0x56,0xA6,0x6E,0x29,0x4A,0xFD, + 0x18,0x5A,0x78,0xFF,0x12,0xAA,0x52,0x0E,0x4D,0xE7, + 0x39,0xBA,0xCA,0x0C,0x7F,0xFE,0xFF,0x7F,0x29,0x55, + 0x72,0x7A, + 0x03,0x03,0x00,0x1D,0x34,0xB8,0x56,0x29,0x6C,0x16, /* x */ + 0xC0,0xD4,0x0D,0x3C,0xD7,0x75,0x0A,0x93,0xD1,0xD2, + 0x95,0x5F,0xA8,0x0A,0xA5,0xF4,0x0F,0xC8,0xDB,0x7B, + 0x2A,0xBD,0xBD,0xE5,0x39,0x50,0xF4,0xC0,0xD2,0x93, + 0xCD,0xD7,0x11,0xA3,0x5B,0x67,0xFB,0x14,0x99,0xAE, + 0x60,0x03,0x86,0x14,0xF1,0x39,0x4A,0xBF,0xA3,0xB4, + 0xC8,0x50,0xD9,0x27,0xE1,0xE7,0x76,0x9C,0x8E,0xEC, + 0x2D,0x19, + 0x03,0x7B,0xF2,0x73,0x42,0xDA,0x63,0x9B,0x6D,0xCC, /* y */ + 0xFF,0xFE,0xB7,0x3D,0x69,0xD7,0x8C,0x6C,0x27,0xA6, + 0x00,0x9C,0xBB,0xCA,0x19,0x80,0xF8,0x53,0x39,0x21, + 0xE8,0xA6,0x84,0x42,0x3E,0x43,0xBA,0xB0,0x8A,0x57, + 0x62,0x91,0xAF,0x8F,0x46,0x1B,0xB2,0xA8,0xB3,0x53, + 0x1D,0x2F,0x04,0x85,0xC1,0x9B,0x16,0xE2,0xF1,0x51, + 0x6E,0x23,0xDD,0x3C,0x1A,0x48,0x27,0xAF,0x1B,0x8A, + 0xC1,0x5B, + 0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE6,0x61,0xCE,0x18, + 0xFF,0x55,0x98,0x73,0x08,0x05,0x9B,0x18,0x68,0x23, + 0x85,0x1E,0xC7,0xDD,0x9C,0xA1,0x16,0x1D,0xE9,0x3D, + 0x51,0x74,0xD6,0x6E,0x83,0x82,0xE9,0xBB,0x2F,0xE8, + 0x4E,0x47 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+21*6]; } + _EC_X9_62_CHAR2_163V1 = { + { NID_X9_62_characteristic_two_field,20,21,2 }, + { 0xD2,0xC0,0xFB,0x15,0x76,0x08,0x60,0xDE,0xF1,0xEE, + 0xF4,0xD6,0x96,0xE6,0x76,0x87,0x56,0x15,0x17,0x54, /* seed */ + + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, + 0x07, + 0x07,0x25,0x46,0xB5,0x43,0x52,0x34,0xA4,0x22,0xE0, /* a */ + 0x78,0x96,0x75,0xF4,0x32,0xC8,0x94,0x35,0xDE,0x52, + 0x42, + 0x00,0xC9,0x51,0x7D,0x06,0xD5,0x24,0x0D,0x3C,0xFF, /* b */ + 0x38,0xC7,0x4B,0x20,0xB6,0xCD,0x4D,0x6F,0x9D,0xD4, + 0xD9, + 0x07,0xAF,0x69,0x98,0x95,0x46,0x10,0x3D,0x79,0x32, /* x */ + 0x9F,0xCC,0x3D,0x74,0x88,0x0F,0x33,0xBB,0xE8,0x03, + 0xCB, + 0x01,0xEC,0x23,0x21,0x1B,0x59,0x66,0xAD,0xEA,0x1D, /* y */ + 0x3F,0x87,0xF7,0xEA,0x58,0x48,0xAE,0xF0,0xB7,0xCA, + 0x9F, + 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ + 0x01,0xE6,0x0F,0xC8,0x82,0x1C,0xC7,0x4D,0xAE,0xAF, + 0xC1 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+21*6]; } + _EC_X9_62_CHAR2_163V2 = { + { NID_X9_62_characteristic_two_field,20,21,2 }, + { 0x53,0x81,0x4C,0x05,0x0D,0x44,0xD6,0x96,0xE6,0x76, /* seed */ + 0x87,0x56,0x15,0x17,0x58,0x0C,0xA4,0xE2,0x9F,0xFD, + + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, + 0x07, + 0x01,0x08,0xB3,0x9E,0x77,0xC4,0xB1,0x08,0xBE,0xD9, /* a */ + 0x81,0xED,0x0E,0x89,0x0E,0x11,0x7C,0x51,0x1C,0xF0, + 0x72, + 0x06,0x67,0xAC,0xEB,0x38,0xAF,0x4E,0x48,0x8C,0x40, /* b */ + 0x74,0x33,0xFF,0xAE,0x4F,0x1C,0x81,0x16,0x38,0xDF, + 0x20, + 0x00,0x24,0x26,0x6E,0x4E,0xB5,0x10,0x6D,0x0A,0x96, /* x */ + 0x4D,0x92,0xC4,0x86,0x0E,0x26,0x71,0xDB,0x9B,0x6C, + 0xC5, + 0x07,0x9F,0x68,0x4D,0xDF,0x66,0x84,0xC5,0xCD,0x25, /* y */ + 0x8B,0x38,0x90,0x02,0x1B,0x23,0x86,0xDF,0xD1,0x9F, + 0xC5, + 0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ + 0xFD,0xF6,0x4D,0xE1,0x15,0x1A,0xDB,0xB7,0x8F,0x10, + 0xA7 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+21*6]; } + _EC_X9_62_CHAR2_163V3 = { + { NID_X9_62_characteristic_two_field,20,21,2 }, + { 0x50,0xCB,0xF1,0xD9,0x5C,0xA9,0x4D,0x69,0x6E,0x67, /* seed */ + 0x68,0x75,0x61,0x51,0x75,0xF1,0x6A,0x36,0xA3,0xB8, + + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, + 0x07, + 0x07,0xA5,0x26,0xC6,0x3D,0x3E,0x25,0xA2,0x56,0xA0, /* a */ + 0x07,0x69,0x9F,0x54,0x47,0xE3,0x2A,0xE4,0x56,0xB5, + 0x0E, + 0x03,0xF7,0x06,0x17,0x98,0xEB,0x99,0xE2,0x38,0xFD, /* b */ + 0x6F,0x1B,0xF9,0x5B,0x48,0xFE,0xEB,0x48,0x54,0x25, + 0x2B, + 0x02,0xF9,0xF8,0x7B,0x7C,0x57,0x4D,0x0B,0xDE,0xCF, /* x */ + 0x8A,0x22,0xE6,0x52,0x47,0x75,0xF9,0x8C,0xDE,0xBD, + 0xCB, + 0x05,0xB9,0x35,0x59,0x0C,0x15,0x5E,0x17,0xEA,0x48, /* y */ + 0xEB,0x3F,0xF3,0x71,0x8B,0x89,0x3D,0xF5,0x9A,0x05, + 0xD0, + 0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ + 0xFE,0x1A,0xEE,0x14,0x0F,0x11,0x0A,0xFF,0x96,0x13, + 0x09 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[0+23*6]; } + _EC_X9_62_CHAR2_176V1 = { + { NID_X9_62_characteristic_two_field,0,23,0xFF6E }, + { /* no seed */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00, + 0x00,0x00,0x07, + 0x00,0xE4,0xE6,0xDB,0x29,0x95,0x06,0x5C,0x40,0x7D, /* a */ + 0x9D,0x39,0xB8,0xD0,0x96,0x7B,0x96,0x70,0x4B,0xA8, + 0xE9,0xC9,0x0B, + 0x00,0x5D,0xDA,0x47,0x0A,0xBE,0x64,0x14,0xDE,0x8E, /* b */ + 0xC1,0x33,0xAE,0x28,0xE9,0xBB,0xD7,0xFC,0xEC,0x0A, + 0xE0,0xFF,0xF2, + 0x00,0x8D,0x16,0xC2,0x86,0x67,0x98,0xB6,0x00,0xF9, /* x */ + 0xF0,0x8B,0xB4,0xA8,0xE8,0x60,0xF3,0x29,0x8C,0xE0, + 0x4A,0x57,0x98, + 0x00,0x6F,0xA4,0x53,0x9C,0x2D,0xAD,0xDD,0xD6,0xBA, /* y */ + 0xB5,0x16,0x7D,0x61,0xB4,0x36,0xE1,0xD9,0x2B,0xB1, + 0x6A,0x56,0x2C, + 0x00,0x00,0x01,0x00,0x92,0x53,0x73,0x97,0xEC,0xA4, /* order */ + 0xF6,0x14,0x57,0x99,0xD6,0x2B,0x0A,0x19,0xCE,0x06, + 0xFE,0x26,0xAD } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+24*6]; } + _EC_X9_62_CHAR2_191V1 = { + { NID_X9_62_characteristic_two_field,20,24,2 }, + { 0x4E,0x13,0xCA,0x54,0x27,0x44,0xD6,0x96,0xE6,0x76, /* seed */ + 0x87,0x56,0x15,0x17,0x55,0x2F,0x27,0x9A,0x8C,0x84, + + 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x02,0x01, + 0x28,0x66,0x53,0x7B,0x67,0x67,0x52,0x63,0x6A,0x68, /* a */ + 0xF5,0x65,0x54,0xE1,0x26,0x40,0x27,0x6B,0x64,0x9E, + 0xF7,0x52,0x62,0x67, + 0x2E,0x45,0xEF,0x57,0x1F,0x00,0x78,0x6F,0x67,0xB0, /* b */ + 0x08,0x1B,0x94,0x95,0xA3,0xD9,0x54,0x62,0xF5,0xDE, + 0x0A,0xA1,0x85,0xEC, + 0x36,0xB3,0xDA,0xF8,0xA2,0x32,0x06,0xF9,0xC4,0xF2, /* x */ + 0x99,0xD7,0xB2,0x1A,0x9C,0x36,0x91,0x37,0xF2,0xC8, + 0x4A,0xE1,0xAA,0x0D, + 0x76,0x5B,0xE7,0x34,0x33,0xB3,0xF9,0x5E,0x33,0x29, /* y */ + 0x32,0xE7,0x0E,0xA2,0x45,0xCA,0x24,0x18,0xEA,0x0E, + 0xF9,0x80,0x18,0xFB, + 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ + 0x00,0x00,0x04,0xA2,0x0E,0x90,0xC3,0x90,0x67,0xC8, + 0x93,0xBB,0xB9,0xA5 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+24*6]; } + _EC_X9_62_CHAR2_191V2 = { + { NID_X9_62_characteristic_two_field,20,24,4 }, + { 0x08,0x71,0xEF,0x2F,0xEF,0x24,0xD6,0x96,0xE6,0x76, /* seed */ + 0x87,0x56,0x15,0x17,0x58,0xBE,0xE0,0xD9,0x5C,0x15, + + 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x02,0x01, + 0x40,0x10,0x28,0x77,0x4D,0x77,0x77,0xC7,0xB7,0x66, /* a */ + 0x6D,0x13,0x66,0xEA,0x43,0x20,0x71,0x27,0x4F,0x89, + 0xFF,0x01,0xE7,0x18, + 0x06,0x20,0x04,0x8D,0x28,0xBC,0xBD,0x03,0xB6,0x24, /* b */ + 0x9C,0x99,0x18,0x2B,0x7C,0x8C,0xD1,0x97,0x00,0xC3, + 0x62,0xC4,0x6A,0x01, + 0x38,0x09,0xB2,0xB7,0xCC,0x1B,0x28,0xCC,0x5A,0x87, /* x */ + 0x92,0x6A,0xAD,0x83,0xFD,0x28,0x78,0x9E,0x81,0xE2, + 0xC9,0xE3,0xBF,0x10, + 0x17,0x43,0x43,0x86,0x62,0x6D,0x14,0xF3,0xDB,0xF0, /* y */ + 0x17,0x60,0xD9,0x21,0x3A,0x3E,0x1C,0xF3,0x7A,0xEC, + 0x43,0x7D,0x66,0x8A, + 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ + 0x00,0x00,0x50,0x50,0x8C,0xB8,0x9F,0x65,0x28,0x24, + 0xE0,0x6B,0x81,0x73 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+24*6]; } + _EC_X9_62_CHAR2_191V3 = { + { NID_X9_62_characteristic_two_field,20,24,6 }, + { 0xE0,0x53,0x51,0x2D,0xC6,0x84,0xD6,0x96,0xE6,0x76, /* seed */ + 0x87,0x56,0x15,0x17,0x50,0x67,0xAE,0x78,0x6D,0x1F, + + 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x02,0x01, + 0x6C,0x01,0x07,0x47,0x56,0x09,0x91,0x22,0x22,0x10, /* a */ + 0x56,0x91,0x1C,0x77,0xD7,0x7E,0x77,0xA7,0x77,0xE7, + 0xE7,0xE7,0x7F,0xCB, + 0x71,0xFE,0x1A,0xF9,0x26,0xCF,0x84,0x79,0x89,0xEF, /* b */ + 0xEF,0x8D,0xB4,0x59,0xF6,0x63,0x94,0xD9,0x0F,0x32, + 0xAD,0x3F,0x15,0xE8, + 0x37,0x5D,0x4C,0xE2,0x4F,0xDE,0x43,0x44,0x89,0xDE, /* x */ + 0x87,0x46,0xE7,0x17,0x86,0x01,0x50,0x09,0xE6,0x6E, + 0x38,0xA9,0x26,0xDD, + 0x54,0x5A,0x39,0x17,0x61,0x96,0x57,0x5D,0x98,0x59, /* y */ + 0x99,0x36,0x6E,0x6A,0xD3,0x4C,0xE0,0xA7,0x7C,0xD7, + 0x12,0x7B,0x06,0xBE, + 0x15,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55, /* order */ + 0x55,0x55,0x61,0x0C,0x0B,0x19,0x68,0x12,0xBF,0xB6, + 0x28,0x8A,0x3E,0xA3 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[0+27*6]; } + _EC_X9_62_CHAR2_208W1 = { + { NID_X9_62_characteristic_two_field,0,27,0xFE48 }, + { /* no seed */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x07, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0xC8,0x61,0x9E,0xD4,0x5A,0x62,0xE6,0x21,0x2E, /* b */ + 0x11,0x60,0x34,0x9E,0x2B,0xFA,0x84,0x44,0x39,0xFA, + 0xFC,0x2A,0x3F,0xD1,0x63,0x8F,0x9E, + 0x00,0x89,0xFD,0xFB,0xE4,0xAB,0xE1,0x93,0xDF,0x95, /* x */ + 0x59,0xEC,0xF0,0x7A,0xC0,0xCE,0x78,0x55,0x4E,0x27, + 0x84,0xEB,0x8C,0x1E,0xD1,0xA5,0x7A, + 0x00,0x0F,0x55,0xB5,0x1A,0x06,0xE7,0x8E,0x9A,0xC3, /* y */ + 0x8A,0x03,0x5F,0xF5,0x20,0xD8,0xB0,0x17,0x81,0xBE, + 0xB1,0xA6,0xBB,0x08,0x61,0x7D,0xE3, + 0x00,0x00,0x01,0x01,0xBA,0xF9,0x5C,0x97,0x23,0xC5, /* order */ + 0x7B,0x6C,0x21,0xDA,0x2E,0xFF,0x2D,0x5E,0xD5,0x88, + 0xBD,0xD5,0x71,0x7E,0x21,0x2F,0x9D } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+30*6]; } + _EC_X9_62_CHAR2_239V1 = { + { NID_X9_62_characteristic_two_field,20,30,4 }, + { 0xD3,0x4B,0x9A,0x4D,0x69,0x6E,0x67,0x68,0x75,0x61, /* seed */ + 0x51,0x75,0xCA,0x71,0xB9,0x20,0xBF,0xEF,0xB0,0x5D, + + 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x01, + + 0x32,0x01,0x08,0x57,0x07,0x7C,0x54,0x31,0x12,0x3A, /* a */ + 0x46,0xB8,0x08,0x90,0x67,0x56,0xF5,0x43,0x42,0x3E, + 0x8D,0x27,0x87,0x75,0x78,0x12,0x57,0x78,0xAC,0x76, + + 0x79,0x04,0x08,0xF2,0xEE,0xDA,0xF3,0x92,0xB0,0x12, /* b */ + 0xED,0xEF,0xB3,0x39,0x2F,0x30,0xF4,0x32,0x7C,0x0C, + 0xA3,0xF3,0x1F,0xC3,0x83,0xC4,0x22,0xAA,0x8C,0x16, + + 0x57,0x92,0x70,0x98,0xFA,0x93,0x2E,0x7C,0x0A,0x96, /* x */ + 0xD3,0xFD,0x5B,0x70,0x6E,0xF7,0xE5,0xF5,0xC1,0x56, + 0xE1,0x6B,0x7E,0x7C,0x86,0x03,0x85,0x52,0xE9,0x1D, + + 0x61,0xD8,0xEE,0x50,0x77,0xC3,0x3F,0xEC,0xF6,0xF1, /* y */ + 0xA1,0x6B,0x26,0x8D,0xE4,0x69,0xC3,0xC7,0x74,0x4E, + 0xA9,0xA9,0x71,0x64,0x9F,0xC7,0xA9,0x61,0x63,0x05, + + 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ + 0x00,0x00,0x00,0x00,0x00,0x0F,0x4D,0x42,0xFF,0xE1, + 0x49,0x2A,0x49,0x93,0xF1,0xCA,0xD6,0x66,0xE4,0x47 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+30*6]; } + _EC_X9_62_CHAR2_239V2 = { + { NID_X9_62_characteristic_two_field,20,30,6 }, + { 0x2A,0xA6,0x98,0x2F,0xDF,0xA4,0xD6,0x96,0xE6,0x76, /* seed */ + 0x87,0x56,0x15,0x17,0x5D,0x26,0x67,0x27,0x27,0x7D, + + 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x01, + + 0x42,0x30,0x01,0x77,0x57,0xA7,0x67,0xFA,0xE4,0x23, /* a */ + 0x98,0x56,0x9B,0x74,0x63,0x25,0xD4,0x53,0x13,0xAF, + 0x07,0x66,0x26,0x64,0x79,0xB7,0x56,0x54,0xE6,0x5F, + + 0x50,0x37,0xEA,0x65,0x41,0x96,0xCF,0xF0,0xCD,0x82, /* b */ + 0xB2,0xC1,0x4A,0x2F,0xCF,0x2E,0x3F,0xF8,0x77,0x52, + 0x85,0xB5,0x45,0x72,0x2F,0x03,0xEA,0xCD,0xB7,0x4B, + + 0x28,0xF9,0xD0,0x4E,0x90,0x00,0x69,0xC8,0xDC,0x47, /* x */ + 0xA0,0x85,0x34,0xFE,0x76,0xD2,0xB9,0x00,0xB7,0xD7, + 0xEF,0x31,0xF5,0x70,0x9F,0x20,0x0C,0x4C,0xA2,0x05, + + 0x56,0x67,0x33,0x4C,0x45,0xAF,0xF3,0xB5,0xA0,0x3B, /* y */ + 0xAD,0x9D,0xD7,0x5E,0x2C,0x71,0xA9,0x93,0x62,0x56, + 0x7D,0x54,0x53,0xF7,0xFA,0x6E,0x22,0x7E,0xC8,0x33, + + 0x15,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55, /* order */ + 0x55,0x55,0x55,0x55,0x55,0x3C,0x6F,0x28,0x85,0x25, + 0x9C,0x31,0xE3,0xFC,0xDF,0x15,0x46,0x24,0x52,0x2D } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+30*6]; } + _EC_X9_62_CHAR2_239V3 = { + { NID_X9_62_characteristic_two_field,20,30,0xA }, + { 0x9E,0x07,0x6F,0x4D,0x69,0x6E,0x67,0x68,0x75,0x61, /* seed */ + 0x51,0x75,0xE1,0x1E,0x9F,0xDD,0x77,0xF9,0x20,0x41, + + 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x01, + + 0x01,0x23,0x87,0x74,0x66,0x6A,0x67,0x76,0x6D,0x66, /* a */ + 0x76,0xF7,0x78,0xE6,0x76,0xB6,0x69,0x99,0x17,0x66, + 0x66,0xE6,0x87,0x66,0x6D,0x87,0x66,0xC6,0x6A,0x9F, + + 0x6A,0x94,0x19,0x77,0xBA,0x9F,0x6A,0x43,0x51,0x99, /* b */ + 0xAC,0xFC,0x51,0x06,0x7E,0xD5,0x87,0xF5,0x19,0xC5, + 0xEC,0xB5,0x41,0xB8,0xE4,0x41,0x11,0xDE,0x1D,0x40, + + 0x70,0xF6,0xE9,0xD0,0x4D,0x28,0x9C,0x4E,0x89,0x91, /* x */ + 0x3C,0xE3,0x53,0x0B,0xFD,0xE9,0x03,0x97,0x7D,0x42, + 0xB1,0x46,0xD5,0x39,0xBF,0x1B,0xDE,0x4E,0x9C,0x92, + + 0x2E,0x5A,0x0E,0xAF,0x6E,0x5E,0x13,0x05,0xB9,0x00, /* y */ + 0x4D,0xCE,0x5C,0x0E,0xD7,0xFE,0x59,0xA3,0x56,0x08, + 0xF3,0x38,0x37,0xC8,0x16,0xD8,0x0B,0x79,0xF4,0x61, + + 0x0C,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC, /* order */ + 0xCC,0xCC,0xCC,0xCC,0xCC,0xAC,0x49,0x12,0xD2,0xD9, + 0xDF,0x90,0x3E,0xF9,0x88,0x8B,0x8A,0x0E,0x4C,0xFF } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[0+35*6]; } + _EC_X9_62_CHAR2_272W1 = { + { NID_X9_62_characteristic_two_field,0,35,0xFF06 }, + { /* no seed */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00, + 0x00,0x00,0x00,0x00,0x0B, + 0x00,0x91,0xA0,0x91,0xF0,0x3B,0x5F,0xBA,0x4A,0xB2, /* a */ + 0xCC,0xF4,0x9C,0x4E,0xDD,0x22,0x0F,0xB0,0x28,0x71, + 0x2D,0x42,0xBE,0x75,0x2B,0x2C,0x40,0x09,0x4D,0xBA, + 0xCD,0xB5,0x86,0xFB,0x20, + 0x00,0x71,0x67,0xEF,0xC9,0x2B,0xB2,0xE3,0xCE,0x7C, /* b */ + 0x8A,0xAA,0xFF,0x34,0xE1,0x2A,0x9C,0x55,0x70,0x03, + 0xD7,0xC7,0x3A,0x6F,0xAF,0x00,0x3F,0x99,0xF6,0xCC, + 0x84,0x82,0xE5,0x40,0xF7, + 0x00,0x61,0x08,0xBA,0xBB,0x2C,0xEE,0xBC,0xF7,0x87, /* x */ + 0x05,0x8A,0x05,0x6C,0xBE,0x0C,0xFE,0x62,0x2D,0x77, + 0x23,0xA2,0x89,0xE0,0x8A,0x07,0xAE,0x13,0xEF,0x0D, + 0x10,0xD1,0x71,0xDD,0x8D, + 0x00,0x10,0xC7,0x69,0x57,0x16,0x85,0x1E,0xEF,0x6B, /* y */ + 0xA7,0xF6,0x87,0x2E,0x61,0x42,0xFB,0xD2,0x41,0xB8, + 0x30,0xFF,0x5E,0xFC,0xAC,0xEC,0xCA,0xB0,0x5E,0x02, + 0x00,0x5D,0xDE,0x9D,0x23, + 0x00,0x00,0x01,0x00,0xFA,0xF5,0x13,0x54,0xE0,0xE3, /* order */ + 0x9E,0x48,0x92,0xDF,0x6E,0x31,0x9C,0x72,0xC8,0x16, + 0x16,0x03,0xFA,0x45,0xAA,0x7B,0x99,0x8A,0x16,0x7B, + 0x8F,0x1E,0x62,0x95,0x21 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[0+39*6]; } + _EC_X9_62_CHAR2_304W1 = { + { NID_X9_62_characteristic_two_field,0,39,0xFE2E }, + { /* no seed */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x07, + 0x00,0xFD,0x0D,0x69,0x31,0x49,0xA1,0x18,0xF6,0x51, /* a */ + 0xE6,0xDC,0xE6,0x80,0x20,0x85,0x37,0x7E,0x5F,0x88, + 0x2D,0x1B,0x51,0x0B,0x44,0x16,0x00,0x74,0xC1,0x28, + 0x80,0x78,0x36,0x5A,0x03,0x96,0xC8,0xE6,0x81, + 0x00,0xBD,0xDB,0x97,0xE5,0x55,0xA5,0x0A,0x90,0x8E, /* b */ + 0x43,0xB0,0x1C,0x79,0x8E,0xA5,0xDA,0xA6,0x78,0x8F, + 0x1E,0xA2,0x79,0x4E,0xFC,0xF5,0x71,0x66,0xB8,0xC1, + 0x40,0x39,0x60,0x1E,0x55,0x82,0x73,0x40,0xBE, + 0x00,0x19,0x7B,0x07,0x84,0x5E,0x9B,0xE2,0xD9,0x6A, /* x */ + 0xDB,0x0F,0x5F,0x3C,0x7F,0x2C,0xFF,0xBD,0x7A,0x3E, + 0xB8,0xB6,0xFE,0xC3,0x5C,0x7F,0xD6,0x7F,0x26,0xDD, + 0xF6,0x28,0x5A,0x64,0x4F,0x74,0x0A,0x26,0x14, + 0x00,0xE1,0x9F,0xBE,0xB7,0x6E,0x0D,0xA1,0x71,0x51, /* y */ + 0x7E,0xCF,0x40,0x1B,0x50,0x28,0x9B,0xF0,0x14,0x10, + 0x32,0x88,0x52,0x7A,0x9B,0x41,0x6A,0x10,0x5E,0x80, + 0x26,0x0B,0x54,0x9F,0xDC,0x1B,0x92,0xC0,0x3B, + 0x00,0x00,0x01,0x01,0xD5,0x56,0x57,0x2A,0xAB,0xAC, /* order */ + 0x80,0x01,0x01,0xD5,0x56,0x57,0x2A,0xAB,0xAC,0x80, + 0x01,0x02,0x2D,0x5C,0x91,0xDD,0x17,0x3F,0x8F,0xB5, + 0x61,0xDA,0x68,0x99,0x16,0x44,0x43,0x05,0x1D } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[20+45*6]; } + _EC_X9_62_CHAR2_359V1 = { + { NID_X9_62_characteristic_two_field,20,45,0x4C }, + { 0x2B,0x35,0x49,0x20,0xB7,0x24,0xD6,0x96,0xE6,0x76, /* seed */ + 0x87,0x56,0x15,0x17,0x58,0x5B,0xA1,0x33,0x2D,0xC6, + + 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01, + 0x56,0x67,0x67,0x6A,0x65,0x4B,0x20,0x75,0x4F,0x35, /* a */ + 0x6E,0xA9,0x20,0x17,0xD9,0x46,0x56,0x7C,0x46,0x67, + 0x55,0x56,0xF1,0x95,0x56,0xA0,0x46,0x16,0xB5,0x67, + 0xD2,0x23,0xA5,0xE0,0x56,0x56,0xFB,0x54,0x90,0x16, + 0xA9,0x66,0x56,0xA5,0x57, + 0x24,0x72,0xE2,0xD0,0x19,0x7C,0x49,0x36,0x3F,0x1F, /* b */ + 0xE7,0xF5,0xB6,0xDB,0x07,0x5D,0x52,0xB6,0x94,0x7D, + 0x13,0x5D,0x8C,0xA4,0x45,0x80,0x5D,0x39,0xBC,0x34, + 0x56,0x26,0x08,0x96,0x87,0x74,0x2B,0x63,0x29,0xE7, + 0x06,0x80,0x23,0x19,0x88, + 0x3C,0x25,0x8E,0xF3,0x04,0x77,0x67,0xE7,0xED,0xE0, /* x */ + 0xF1,0xFD,0xAA,0x79,0xDA,0xEE,0x38,0x41,0x36,0x6A, + 0x13,0x2E,0x16,0x3A,0xCE,0xD4,0xED,0x24,0x01,0xDF, + 0x9C,0x6B,0xDC,0xDE,0x98,0xE8,0xE7,0x07,0xC0,0x7A, + 0x22,0x39,0xB1,0xB0,0x97, + 0x53,0xD7,0xE0,0x85,0x29,0x54,0x70,0x48,0x12,0x1E, /* y */ + 0x9C,0x95,0xF3,0x79,0x1D,0xD8,0x04,0x96,0x39,0x48, + 0xF3,0x4F,0xAE,0x7B,0xF4,0x4E,0xA8,0x23,0x65,0xDC, + 0x78,0x68,0xFE,0x57,0xE4,0xAE,0x2D,0xE2,0x11,0x30, + 0x5A,0x40,0x71,0x04,0xBD, + 0x01,0xAF,0x28,0x6B,0xCA,0x1A,0xF2,0x86,0xBC,0xA1, /* order */ + 0xAF,0x28,0x6B,0xCA,0x1A,0xF2,0x86,0xBC,0xA1,0xAF, + 0x28,0x6B,0xC9,0xFB,0x8F,0x6B,0x85,0xC5,0x56,0x89, + 0x2C,0x20,0xA7,0xEB,0x96,0x4F,0xE7,0x71,0x9E,0x74, + 0xF4,0x90,0x75,0x8D,0x3B } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[0+47*6]; } + _EC_X9_62_CHAR2_368W1 = { + { NID_X9_62_characteristic_two_field,0,47,0xFF70 }, + { /* no seed */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x07, + 0x00,0xE0,0xD2,0xEE,0x25,0x09,0x52,0x06,0xF5,0xE2, /* a */ + 0xA4,0xF9,0xED,0x22,0x9F,0x1F,0x25,0x6E,0x79,0xA0, + 0xE2,0xB4,0x55,0x97,0x0D,0x8D,0x0D,0x86,0x5B,0xD9, + 0x47,0x78,0xC5,0x76,0xD6,0x2F,0x0A,0xB7,0x51,0x9C, + 0xCD,0x2A,0x1A,0x90,0x6A,0xE3,0x0D, + 0x00,0xFC,0x12,0x17,0xD4,0x32,0x0A,0x90,0x45,0x2C, /* b */ + 0x76,0x0A,0x58,0xED,0xCD,0x30,0xC8,0xDD,0x06,0x9B, + 0x3C,0x34,0x45,0x38,0x37,0xA3,0x4E,0xD5,0x0C,0xB5, + 0x49,0x17,0xE1,0xC2,0x11,0x2D,0x84,0xD1,0x64,0xF4, + 0x44,0xF8,0xF7,0x47,0x86,0x04,0x6A, + 0x00,0x10,0x85,0xE2,0x75,0x53,0x81,0xDC,0xCC,0xE3, /* x */ + 0xC1,0x55,0x7A,0xFA,0x10,0xC2,0xF0,0xC0,0xC2,0x82, + 0x56,0x46,0xC5,0xB3,0x4A,0x39,0x4C,0xBC,0xFA,0x8B, + 0xC1,0x6B,0x22,0xE7,0xE7,0x89,0xE9,0x27,0xBE,0x21, + 0x6F,0x02,0xE1,0xFB,0x13,0x6A,0x5F, + 0x00,0x7B,0x3E,0xB1,0xBD,0xDC,0xBA,0x62,0xD5,0xD8, /* y */ + 0xB2,0x05,0x9B,0x52,0x57,0x97,0xFC,0x73,0x82,0x2C, + 0x59,0x05,0x9C,0x62,0x3A,0x45,0xFF,0x38,0x43,0xCE, + 0xE8,0xF8,0x7C,0xD1,0x85,0x5A,0xDA,0xA8,0x1E,0x2A, + 0x07,0x50,0xB8,0x0F,0xDA,0x23,0x10, + 0x00,0x00,0x01,0x00,0x90,0x51,0x2D,0xA9,0xAF,0x72, /* order */ + 0xB0,0x83,0x49,0xD9,0x8A,0x5D,0xD4,0xC7,0xB0,0x53, + 0x2E,0xCA,0x51,0xCE,0x03,0xE2,0xD1,0x0F,0x3B,0x7A, + 0xC5,0x79,0xBD,0x87,0xE9,0x09,0xAE,0x40,0xA6,0xF1, + 0x31,0xE9,0xCF,0xCE,0x5B,0xD9,0x67 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[0+54*6]; } + _EC_X9_62_CHAR2_431R1 = { + { NID_X9_62_characteristic_two_field,0,54,0x2760 }, + { /* no seed */ + 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x01, + 0x1A,0x82,0x7E,0xF0,0x0D,0xD6,0xFC,0x0E,0x23,0x4C, /* a */ + 0xAF,0x04,0x6C,0x6A,0x5D,0x8A,0x85,0x39,0x5B,0x23, + 0x6C,0xC4,0xAD,0x2C,0xF3,0x2A,0x0C,0xAD,0xBD,0xC9, + 0xDD,0xF6,0x20,0xB0,0xEB,0x99,0x06,0xD0,0x95,0x7F, + 0x6C,0x6F,0xEA,0xCD,0x61,0x54,0x68,0xDF,0x10,0x4D, + 0xE2,0x96,0xCD,0x8F, + 0x10,0xD9,0xB4,0xA3,0xD9,0x04,0x7D,0x8B,0x15,0x43, /* b */ + 0x59,0xAB,0xFB,0x1B,0x7F,0x54,0x85,0xB0,0x4C,0xEB, + 0x86,0x82,0x37,0xDD,0xC9,0xDE,0xDA,0x98,0x2A,0x67, + 0x9A,0x5A,0x91,0x9B,0x62,0x6D,0x4E,0x50,0xA8,0xDD, + 0x73,0x1B,0x10,0x7A,0x99,0x62,0x38,0x1F,0xB5,0xD8, + 0x07,0xBF,0x26,0x18, + 0x12,0x0F,0xC0,0x5D,0x3C,0x67,0xA9,0x9D,0xE1,0x61, /* x */ + 0xD2,0xF4,0x09,0x26,0x22,0xFE,0xCA,0x70,0x1B,0xE4, + 0xF5,0x0F,0x47,0x58,0x71,0x4E,0x8A,0x87,0xBB,0xF2, + 0xA6,0x58,0xEF,0x8C,0x21,0xE7,0xC5,0xEF,0xE9,0x65, + 0x36,0x1F,0x6C,0x29,0x99,0xC0,0xC2,0x47,0xB0,0xDB, + 0xD7,0x0C,0xE6,0xB7, + 0x20,0xD0,0xAF,0x89,0x03,0xA9,0x6F,0x8D,0x5F,0xA2, /* y */ + 0xC2,0x55,0x74,0x5D,0x3C,0x45,0x1B,0x30,0x2C,0x93, + 0x46,0xD9,0xB7,0xE4,0x85,0xE7,0xBC,0xE4,0x1F,0x6B, + 0x59,0x1F,0x3E,0x8F,0x6A,0xDD,0xCB,0xB0,0xBC,0x4C, + 0x2F,0x94,0x7A,0x7D,0xE1,0xA8,0x9B,0x62,0x5D,0x6A, + 0x59,0x8B,0x37,0x60, + 0x00,0x03,0x40,0x34,0x03,0x40,0x34,0x03,0x40,0x34, /* order */ + 0x03,0x40,0x34,0x03,0x40,0x34,0x03,0x40,0x34,0x03, + 0x40,0x34,0x03,0x40,0x34,0x03,0x40,0x34,0x03,0x23, + 0xC3,0x13,0xFA,0xB5,0x05,0x89,0x70,0x3B,0x5E,0xC6, + 0x8D,0x35,0x87,0xFE,0xC6,0x0D,0x16,0x1C,0xC1,0x49, + 0xC1,0xAD,0x4A,0x91 } + }; + +static const struct { EC_CURVE_DATA h; unsigned char data[0+15*6]; } + _EC_WTLS_1 = { + { NID_X9_62_characteristic_two_field,0,15,2 }, + { /* no seed */ + 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x02,0x01, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ + 0x00,0x00,0x00,0x00,0x01, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ + 0x00,0x00,0x00,0x00,0x01, + 0x01,0x66,0x79,0x79,0xA4,0x0B,0xA4,0x97,0xE5,0xD5, /* x */ + 0xC2,0x70,0x78,0x06,0x17, + 0x00,0xF4,0x4B,0x4A,0xF1,0xEC,0xC2,0x63,0x0E,0x08, /* y */ + 0x78,0x5C,0xEB,0xCC,0x15, + 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFD,0xBF, /* order */ + 0x91,0xAF,0x6D,0xEA,0x73 } + }; + +/* IPSec curves */ +/* NOTE: The of curves over a extension field of non prime degree + * is not recommended (Weil-descent). + * As the group order is not a prime this curve is not suitable + * for ECDSA. + */ +static const struct { EC_CURVE_DATA h; unsigned char data[0+20*6]; } + _EC_IPSEC_155_ID3 = { + { NID_X9_62_characteristic_two_field,0,20,3 }, + { /* no seed */ + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x01, + + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x33,0x8f, + + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* x */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7b, + + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* y */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xc8, + + 0x02,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA, /* order */ + 0xC7,0xF3,0xC7,0x88,0x1B,0xD0,0x86,0x8F,0xA8,0x6C } + }; + +/* NOTE: The of curves over a extension field of non prime degree + * is not recommended (Weil-descent). + * As the group order is not a prime this curve is not suitable + * for ECDSA. + */ +static const struct { EC_CURVE_DATA h; unsigned char data[0+24*6]; } + _EC_IPSEC_185_ID4 = { + { NID_X9_62_characteristic_two_field,0,24,2 }, + { /* no seed */ + 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ + 0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x01, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x1e,0xe9, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* x */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x18, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* y */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x0d, + 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ + 0xFF,0xFF,0xED,0xF9,0x7C,0x44,0xDB,0x9F,0x24,0x20, + 0xBA,0xFC,0xA7,0x5E } + }; + +#endif + +typedef struct _ec_list_element_st { + int nid; + const EC_CURVE_DATA *data; + const EC_METHOD *(*meth)(void); + const char *comment; + } ec_list_element; + +static const ec_list_element curve_list[] = { + /* prime field curves */ + /* secg curves */ + { NID_secp112r1, &_EC_SECG_PRIME_112R1.h, 0, "SECG/WTLS curve over a 112 bit prime field" }, + { NID_secp112r2, &_EC_SECG_PRIME_112R2.h, 0, "SECG curve over a 112 bit prime field" }, + { NID_secp128r1, &_EC_SECG_PRIME_128R1.h, 0, "SECG curve over a 128 bit prime field" }, + { NID_secp128r2, &_EC_SECG_PRIME_128R2.h, 0, "SECG curve over a 128 bit prime field" }, + { NID_secp160k1, &_EC_SECG_PRIME_160K1.h, 0, "SECG curve over a 160 bit prime field" }, + { NID_secp160r1, &_EC_SECG_PRIME_160R1.h, 0, "SECG curve over a 160 bit prime field" }, + { NID_secp160r2, &_EC_SECG_PRIME_160R2.h, 0, "SECG/WTLS curve over a 160 bit prime field" }, + /* SECG secp192r1 is the same as X9.62 prime192v1 and hence omitted */ + { NID_secp192k1, &_EC_SECG_PRIME_192K1.h, 0, "SECG curve over a 192 bit prime field" }, + { NID_secp224k1, &_EC_SECG_PRIME_224K1.h, 0, "SECG curve over a 224 bit prime field" }, +#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 + { NID_secp224r1, &_EC_NIST_PRIME_224.h, EC_GFp_nistp224_method, "NIST/SECG curve over a 224 bit prime field" }, +#else + { NID_secp224r1, &_EC_NIST_PRIME_224.h, 0, "NIST/SECG curve over a 224 bit prime field" }, +#endif + { NID_secp256k1, &_EC_SECG_PRIME_256K1.h, 0, "SECG curve over a 256 bit prime field" }, + /* SECG secp256r1 is the same as X9.62 prime256v1 and hence omitted */ + { NID_secp384r1, &_EC_NIST_PRIME_384.h, 0, "NIST/SECG curve over a 384 bit prime field" }, +#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 + { NID_secp521r1, &_EC_NIST_PRIME_521.h, EC_GFp_nistp521_method, "NIST/SECG curve over a 521 bit prime field" }, +#else + { NID_secp521r1, &_EC_NIST_PRIME_521.h, 0, "NIST/SECG curve over a 521 bit prime field" }, +#endif + /* X9.62 curves */ + { NID_X9_62_prime192v1, &_EC_NIST_PRIME_192.h, 0, "NIST/X9.62/SECG curve over a 192 bit prime field" }, + { NID_X9_62_prime192v2, &_EC_X9_62_PRIME_192V2.h, 0, "X9.62 curve over a 192 bit prime field" }, + { NID_X9_62_prime192v3, &_EC_X9_62_PRIME_192V3.h, 0, "X9.62 curve over a 192 bit prime field" }, + { NID_X9_62_prime239v1, &_EC_X9_62_PRIME_239V1.h, 0, "X9.62 curve over a 239 bit prime field" }, + { NID_X9_62_prime239v2, &_EC_X9_62_PRIME_239V2.h, 0, "X9.62 curve over a 239 bit prime field" }, + { NID_X9_62_prime239v3, &_EC_X9_62_PRIME_239V3.h, 0, "X9.62 curve over a 239 bit prime field" }, +#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 + { NID_X9_62_prime256v1, &_EC_X9_62_PRIME_256V1.h, EC_GFp_nistp256_method, "X9.62/SECG curve over a 256 bit prime field" }, +#else + { NID_X9_62_prime256v1, &_EC_X9_62_PRIME_256V1.h, 0, "X9.62/SECG curve over a 256 bit prime field" }, +#endif +#ifndef OPENSSL_NO_EC2M + /* characteristic two field curves */ + /* NIST/SECG curves */ + { NID_sect113r1, &_EC_SECG_CHAR2_113R1.h, 0, "SECG curve over a 113 bit binary field" }, + { NID_sect113r2, &_EC_SECG_CHAR2_113R2.h, 0, "SECG curve over a 113 bit binary field" }, + { NID_sect131r1, &_EC_SECG_CHAR2_131R1.h, 0, "SECG/WTLS curve over a 131 bit binary field" }, + { NID_sect131r2, &_EC_SECG_CHAR2_131R2.h, 0, "SECG curve over a 131 bit binary field" }, + { NID_sect163k1, &_EC_NIST_CHAR2_163K.h, 0, "NIST/SECG/WTLS curve over a 163 bit binary field" }, + { NID_sect163r1, &_EC_SECG_CHAR2_163R1.h, 0, "SECG curve over a 163 bit binary field" }, + { NID_sect163r2, &_EC_NIST_CHAR2_163B.h, 0, "NIST/SECG curve over a 163 bit binary field" }, + { NID_sect193r1, &_EC_SECG_CHAR2_193R1.h, 0, "SECG curve over a 193 bit binary field" }, + { NID_sect193r2, &_EC_SECG_CHAR2_193R2.h, 0, "SECG curve over a 193 bit binary field" }, + { NID_sect233k1, &_EC_NIST_CHAR2_233K.h, 0, "NIST/SECG/WTLS curve over a 233 bit binary field" }, + { NID_sect233r1, &_EC_NIST_CHAR2_233B.h, 0, "NIST/SECG/WTLS curve over a 233 bit binary field" }, + { NID_sect239k1, &_EC_SECG_CHAR2_239K1.h, 0, "SECG curve over a 239 bit binary field" }, + { NID_sect283k1, &_EC_NIST_CHAR2_283K.h, 0, "NIST/SECG curve over a 283 bit binary field" }, + { NID_sect283r1, &_EC_NIST_CHAR2_283B.h, 0, "NIST/SECG curve over a 283 bit binary field" }, + { NID_sect409k1, &_EC_NIST_CHAR2_409K.h, 0, "NIST/SECG curve over a 409 bit binary field" }, + { NID_sect409r1, &_EC_NIST_CHAR2_409B.h, 0, "NIST/SECG curve over a 409 bit binary field" }, + { NID_sect571k1, &_EC_NIST_CHAR2_571K.h, 0, "NIST/SECG curve over a 571 bit binary field" }, + { NID_sect571r1, &_EC_NIST_CHAR2_571B.h, 0, "NIST/SECG curve over a 571 bit binary field" }, + /* X9.62 curves */ + { NID_X9_62_c2pnb163v1, &_EC_X9_62_CHAR2_163V1.h, 0, "X9.62 curve over a 163 bit binary field" }, + { NID_X9_62_c2pnb163v2, &_EC_X9_62_CHAR2_163V2.h, 0, "X9.62 curve over a 163 bit binary field" }, + { NID_X9_62_c2pnb163v3, &_EC_X9_62_CHAR2_163V3.h, 0, "X9.62 curve over a 163 bit binary field" }, + { NID_X9_62_c2pnb176v1, &_EC_X9_62_CHAR2_176V1.h, 0, "X9.62 curve over a 176 bit binary field" }, + { NID_X9_62_c2tnb191v1, &_EC_X9_62_CHAR2_191V1.h, 0, "X9.62 curve over a 191 bit binary field" }, + { NID_X9_62_c2tnb191v2, &_EC_X9_62_CHAR2_191V2.h, 0, "X9.62 curve over a 191 bit binary field" }, + { NID_X9_62_c2tnb191v3, &_EC_X9_62_CHAR2_191V3.h, 0, "X9.62 curve over a 191 bit binary field" }, + { NID_X9_62_c2pnb208w1, &_EC_X9_62_CHAR2_208W1.h, 0, "X9.62 curve over a 208 bit binary field" }, + { NID_X9_62_c2tnb239v1, &_EC_X9_62_CHAR2_239V1.h, 0, "X9.62 curve over a 239 bit binary field" }, + { NID_X9_62_c2tnb239v2, &_EC_X9_62_CHAR2_239V2.h, 0, "X9.62 curve over a 239 bit binary field" }, + { NID_X9_62_c2tnb239v3, &_EC_X9_62_CHAR2_239V3.h, 0, "X9.62 curve over a 239 bit binary field" }, + { NID_X9_62_c2pnb272w1, &_EC_X9_62_CHAR2_272W1.h, 0, "X9.62 curve over a 272 bit binary field" }, + { NID_X9_62_c2pnb304w1, &_EC_X9_62_CHAR2_304W1.h, 0, "X9.62 curve over a 304 bit binary field" }, + { NID_X9_62_c2tnb359v1, &_EC_X9_62_CHAR2_359V1.h, 0, "X9.62 curve over a 359 bit binary field" }, + { NID_X9_62_c2pnb368w1, &_EC_X9_62_CHAR2_368W1.h, 0, "X9.62 curve over a 368 bit binary field" }, + { NID_X9_62_c2tnb431r1, &_EC_X9_62_CHAR2_431R1.h, 0, "X9.62 curve over a 431 bit binary field" }, + /* the WAP/WTLS curves + * [unlike SECG, spec has its own OIDs for curves from X9.62] */ + { NID_wap_wsg_idm_ecid_wtls1, &_EC_WTLS_1.h, 0, "WTLS curve over a 113 bit binary field" }, + { NID_wap_wsg_idm_ecid_wtls3, &_EC_NIST_CHAR2_163K.h, 0, "NIST/SECG/WTLS curve over a 163 bit binary field" }, + { NID_wap_wsg_idm_ecid_wtls4, &_EC_SECG_CHAR2_113R1.h, 0, "SECG curve over a 113 bit binary field" }, + { NID_wap_wsg_idm_ecid_wtls5, &_EC_X9_62_CHAR2_163V1.h, 0, "X9.62 curve over a 163 bit binary field" }, +#endif + { NID_wap_wsg_idm_ecid_wtls6, &_EC_SECG_PRIME_112R1.h, 0, "SECG/WTLS curve over a 112 bit prime field" }, + { NID_wap_wsg_idm_ecid_wtls7, &_EC_SECG_PRIME_160R2.h, 0, "SECG/WTLS curve over a 160 bit prime field" }, + { NID_wap_wsg_idm_ecid_wtls8, &_EC_WTLS_8.h, 0, "WTLS curve over a 112 bit prime field" }, + { NID_wap_wsg_idm_ecid_wtls9, &_EC_WTLS_9.h, 0, "WTLS curve over a 160 bit prime field" }, +#ifndef OPENSSL_NO_EC2M + { NID_wap_wsg_idm_ecid_wtls10, &_EC_NIST_CHAR2_233K.h, 0, "NIST/SECG/WTLS curve over a 233 bit binary field" }, + { NID_wap_wsg_idm_ecid_wtls11, &_EC_NIST_CHAR2_233B.h, 0, "NIST/SECG/WTLS curve over a 233 bit binary field" }, +#endif + { NID_wap_wsg_idm_ecid_wtls12, &_EC_WTLS_12.h, 0, "WTLS curvs over a 224 bit prime field" }, +#ifndef OPENSSL_NO_EC2M + /* IPSec curves */ + { NID_ipsec3, &_EC_IPSEC_155_ID3.h, 0, "\n\tIPSec/IKE/Oakley curve #3 over a 155 bit binary field.\n" + "\tNot suitable for ECDSA.\n\tQuestionable extension field!" }, + { NID_ipsec4, &_EC_IPSEC_185_ID4.h, 0, "\n\tIPSec/IKE/Oakley curve #4 over a 185 bit binary field.\n" + "\tNot suitable for ECDSA.\n\tQuestionable extension field!" }, +#endif +}; + +#define curve_list_length (sizeof(curve_list)/sizeof(ec_list_element)) + +static EC_GROUP *ec_group_new_from_data(const ec_list_element curve) + { + EC_GROUP *group=NULL; + EC_POINT *P=NULL; + BN_CTX *ctx=NULL; + BIGNUM *p=NULL, *a=NULL, *b=NULL, *x=NULL, *y=NULL, *order=NULL; + int ok=0; + int seed_len,param_len; + const EC_METHOD *meth; + const EC_CURVE_DATA *data; + const unsigned char *params; + + if ((ctx = BN_CTX_new()) == NULL) + { + ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_MALLOC_FAILURE); + goto err; + } + + data = curve.data; + seed_len = data->seed_len; + param_len = data->param_len; + params = (const unsigned char *)(data+1); /* skip header */ + params += seed_len; /* skip seed */ + + if (!(p = BN_bin2bn(params+0*param_len, param_len, NULL)) + || !(a = BN_bin2bn(params+1*param_len, param_len, NULL)) + || !(b = BN_bin2bn(params+2*param_len, param_len, NULL))) + { + ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB); + goto err; + } + + if (curve.meth != 0) + { + meth = curve.meth(); + if (((group = EC_GROUP_new(meth)) == NULL) || + (!(group->meth->group_set_curve(group, p, a, b, ctx)))) + { + ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); + goto err; + } + } + else if (data->field_type == NID_X9_62_prime_field) + { + if ((group = EC_GROUP_new_curve_GFp(p, a, b, ctx)) == NULL) + { + ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); + goto err; + } + } +#ifndef OPENSSL_NO_EC2M + else /* field_type == NID_X9_62_characteristic_two_field */ + { + if ((group = EC_GROUP_new_curve_GF2m(p, a, b, ctx)) == NULL) + { + ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); + goto err; + } + } +#endif + + if ((P = EC_POINT_new(group)) == NULL) + { + ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); + goto err; + } + + if (!(x = BN_bin2bn(params+3*param_len, param_len, NULL)) + || !(y = BN_bin2bn(params+4*param_len, param_len, NULL))) + { + ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB); + goto err; + } + if (!EC_POINT_set_affine_coordinates_GFp(group, P, x, y, ctx)) + { + ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); + goto err; + } + if (!(order = BN_bin2bn(params+5*param_len, param_len, NULL)) + || !BN_set_word(x, (BN_ULONG)data->cofactor)) + { + ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB); + goto err; + } + if (!EC_GROUP_set_generator(group, P, order, x)) + { + ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); + goto err; + } + if (seed_len) + { + if (!EC_GROUP_set_seed(group, params-seed_len, seed_len)) + { + ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); + goto err; + } + } + ok=1; +err: + if (!ok) + { + EC_GROUP_free(group); + group = NULL; + } + if (P) + EC_POINT_free(P); + if (ctx) + BN_CTX_free(ctx); + if (p) + BN_free(p); + if (a) + BN_free(a); + if (b) + BN_free(b); + if (order) + BN_free(order); + if (x) + BN_free(x); + if (y) + BN_free(y); + return group; + } + +EC_GROUP *EC_GROUP_new_by_curve_name(int nid) + { + size_t i; + EC_GROUP *ret = NULL; + + if (nid <= 0) + return NULL; + + for (i=0; i +#include "ec_lcl.h" + + +EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) + { + const EC_METHOD *meth; + EC_GROUP *ret; + +#if defined(OPENSSL_BN_ASM_MONT) + /* + * This might appear controversial, but the fact is that generic + * prime method was observed to deliver better performance even + * for NIST primes on a range of platforms, e.g.: 60%-15% + * improvement on IA-64, ~25% on ARM, 30%-90% on P4, 20%-25% + * in 32-bit build and 35%--12% in 64-bit build on Core2... + * Coefficients are relative to optimized bn_nist.c for most + * intensive ECDSA verify and ECDH operations for 192- and 521- + * bit keys respectively. Choice of these boundary values is + * arguable, because the dependency of improvement coefficient + * from key length is not a "monotone" curve. For example while + * 571-bit result is 23% on ARM, 384-bit one is -1%. But it's + * generally faster, sometimes "respectfully" faster, sometimes + * "tolerably" slower... What effectively happens is that loop + * with bn_mul_add_words is put against bn_mul_mont, and the + * latter "wins" on short vectors. Correct solution should be + * implementing dedicated NxN multiplication subroutines for + * small N. But till it materializes, let's stick to generic + * prime method... + * + */ + meth = EC_GFp_mont_method(); +#else + meth = EC_GFp_nist_method(); +#endif + + ret = EC_GROUP_new(meth); + if (ret == NULL) + return NULL; + + if (!EC_GROUP_set_curve_GFp(ret, p, a, b, ctx)) + { + unsigned long err; + + err = ERR_peek_last_error(); + + if (!(ERR_GET_LIB(err) == ERR_LIB_EC && + ((ERR_GET_REASON(err) == EC_R_NOT_A_NIST_PRIME) || + (ERR_GET_REASON(err) == EC_R_NOT_A_SUPPORTED_NIST_PRIME)))) + { + /* real error */ + + EC_GROUP_clear_free(ret); + return NULL; + } + + + /* not an actual error, we just cannot use EC_GFp_nist_method */ + + ERR_clear_error(); + + EC_GROUP_clear_free(ret); + meth = EC_GFp_mont_method(); + + ret = EC_GROUP_new(meth); + if (ret == NULL) + return NULL; + + if (!EC_GROUP_set_curve_GFp(ret, p, a, b, ctx)) + { + EC_GROUP_clear_free(ret); + return NULL; + } + } + + return ret; + } + +#ifndef OPENSSL_NO_EC2M +EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) + { + const EC_METHOD *meth; + EC_GROUP *ret; + + meth = EC_GF2m_simple_method(); + + ret = EC_GROUP_new(meth); + if (ret == NULL) + return NULL; + + if (!EC_GROUP_set_curve_GF2m(ret, p, a, b, ctx)) + { + EC_GROUP_clear_free(ret); + return NULL; + } + + return ret; + } +#endif diff --git a/libs/openssl/crypto/ec/ec_err.c b/libs/openssl/crypto/ec/ec_err.c new file mode 100644 index 00000000..0d193987 --- /dev/null +++ b/libs/openssl/crypto/ec/ec_err.c @@ -0,0 +1,276 @@ +/* crypto/ec/ec_err.c */ +/* ==================================================================== + * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +/* NOTE: this file was auto generated by the mkerr.pl script: any changes + * made to it will be overwritten when the script next updates this file, + * only reason strings will be preserved. + */ + +#include +#include +#include + +/* BEGIN ERROR CODES */ +#ifndef OPENSSL_NO_ERR + +#define ERR_FUNC(func) ERR_PACK(ERR_LIB_EC,func,0) +#define ERR_REASON(reason) ERR_PACK(ERR_LIB_EC,0,reason) + +static ERR_STRING_DATA EC_str_functs[]= + { +{ERR_FUNC(EC_F_BN_TO_FELEM), "BN_TO_FELEM"}, +{ERR_FUNC(EC_F_COMPUTE_WNAF), "COMPUTE_WNAF"}, +{ERR_FUNC(EC_F_D2I_ECPARAMETERS), "d2i_ECParameters"}, +{ERR_FUNC(EC_F_D2I_ECPKPARAMETERS), "d2i_ECPKParameters"}, +{ERR_FUNC(EC_F_D2I_ECPRIVATEKEY), "d2i_ECPrivateKey"}, +{ERR_FUNC(EC_F_DO_EC_KEY_PRINT), "DO_EC_KEY_PRINT"}, +{ERR_FUNC(EC_F_ECKEY_PARAM2TYPE), "ECKEY_PARAM2TYPE"}, +{ERR_FUNC(EC_F_ECKEY_PARAM_DECODE), "ECKEY_PARAM_DECODE"}, +{ERR_FUNC(EC_F_ECKEY_PRIV_DECODE), "ECKEY_PRIV_DECODE"}, +{ERR_FUNC(EC_F_ECKEY_PRIV_ENCODE), "ECKEY_PRIV_ENCODE"}, +{ERR_FUNC(EC_F_ECKEY_PUB_DECODE), "ECKEY_PUB_DECODE"}, +{ERR_FUNC(EC_F_ECKEY_PUB_ENCODE), "ECKEY_PUB_ENCODE"}, +{ERR_FUNC(EC_F_ECKEY_TYPE2PARAM), "ECKEY_TYPE2PARAM"}, +{ERR_FUNC(EC_F_ECPARAMETERS_PRINT), "ECParameters_print"}, +{ERR_FUNC(EC_F_ECPARAMETERS_PRINT_FP), "ECParameters_print_fp"}, +{ERR_FUNC(EC_F_ECPKPARAMETERS_PRINT), "ECPKParameters_print"}, +{ERR_FUNC(EC_F_ECPKPARAMETERS_PRINT_FP), "ECPKParameters_print_fp"}, +{ERR_FUNC(EC_F_ECP_NIST_MOD_192), "ECP_NIST_MOD_192"}, +{ERR_FUNC(EC_F_ECP_NIST_MOD_224), "ECP_NIST_MOD_224"}, +{ERR_FUNC(EC_F_ECP_NIST_MOD_256), "ECP_NIST_MOD_256"}, +{ERR_FUNC(EC_F_ECP_NIST_MOD_521), "ECP_NIST_MOD_521"}, +{ERR_FUNC(EC_F_EC_ASN1_GROUP2CURVE), "EC_ASN1_GROUP2CURVE"}, +{ERR_FUNC(EC_F_EC_ASN1_GROUP2FIELDID), "EC_ASN1_GROUP2FIELDID"}, +{ERR_FUNC(EC_F_EC_ASN1_GROUP2PARAMETERS), "EC_ASN1_GROUP2PARAMETERS"}, +{ERR_FUNC(EC_F_EC_ASN1_GROUP2PKPARAMETERS), "EC_ASN1_GROUP2PKPARAMETERS"}, +{ERR_FUNC(EC_F_EC_ASN1_PARAMETERS2GROUP), "EC_ASN1_PARAMETERS2GROUP"}, +{ERR_FUNC(EC_F_EC_ASN1_PKPARAMETERS2GROUP), "EC_ASN1_PKPARAMETERS2GROUP"}, +{ERR_FUNC(EC_F_EC_EX_DATA_SET_DATA), "EC_EX_DATA_set_data"}, +{ERR_FUNC(EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY), "EC_GF2M_MONTGOMERY_POINT_MULTIPLY"}, +{ERR_FUNC(EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT), "ec_GF2m_simple_group_check_discriminant"}, +{ERR_FUNC(EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE), "ec_GF2m_simple_group_set_curve"}, +{ERR_FUNC(EC_F_EC_GF2M_SIMPLE_OCT2POINT), "ec_GF2m_simple_oct2point"}, +{ERR_FUNC(EC_F_EC_GF2M_SIMPLE_POINT2OCT), "ec_GF2m_simple_point2oct"}, +{ERR_FUNC(EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES), "ec_GF2m_simple_point_get_affine_coordinates"}, +{ERR_FUNC(EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES), "ec_GF2m_simple_point_set_affine_coordinates"}, +{ERR_FUNC(EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES), "ec_GF2m_simple_set_compressed_coordinates"}, +{ERR_FUNC(EC_F_EC_GFP_MONT_FIELD_DECODE), "ec_GFp_mont_field_decode"}, +{ERR_FUNC(EC_F_EC_GFP_MONT_FIELD_ENCODE), "ec_GFp_mont_field_encode"}, +{ERR_FUNC(EC_F_EC_GFP_MONT_FIELD_MUL), "ec_GFp_mont_field_mul"}, +{ERR_FUNC(EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE), "ec_GFp_mont_field_set_to_one"}, +{ERR_FUNC(EC_F_EC_GFP_MONT_FIELD_SQR), "ec_GFp_mont_field_sqr"}, +{ERR_FUNC(EC_F_EC_GFP_MONT_GROUP_SET_CURVE), "ec_GFp_mont_group_set_curve"}, +{ERR_FUNC(EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP), "EC_GFP_MONT_GROUP_SET_CURVE_GFP"}, +{ERR_FUNC(EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE), "ec_GFp_nistp224_group_set_curve"}, +{ERR_FUNC(EC_F_EC_GFP_NISTP224_POINTS_MUL), "ec_GFp_nistp224_points_mul"}, +{ERR_FUNC(EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES), "ec_GFp_nistp224_point_get_affine_coordinates"}, +{ERR_FUNC(EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE), "ec_GFp_nistp256_group_set_curve"}, +{ERR_FUNC(EC_F_EC_GFP_NISTP256_POINTS_MUL), "ec_GFp_nistp256_points_mul"}, +{ERR_FUNC(EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES), "ec_GFp_nistp256_point_get_affine_coordinates"}, +{ERR_FUNC(EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE), "ec_GFp_nistp521_group_set_curve"}, +{ERR_FUNC(EC_F_EC_GFP_NISTP521_POINTS_MUL), "ec_GFp_nistp521_points_mul"}, +{ERR_FUNC(EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES), "ec_GFp_nistp521_point_get_affine_coordinates"}, +{ERR_FUNC(EC_F_EC_GFP_NIST_FIELD_MUL), "ec_GFp_nist_field_mul"}, +{ERR_FUNC(EC_F_EC_GFP_NIST_FIELD_SQR), "ec_GFp_nist_field_sqr"}, +{ERR_FUNC(EC_F_EC_GFP_NIST_GROUP_SET_CURVE), "ec_GFp_nist_group_set_curve"}, +{ERR_FUNC(EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT), "ec_GFp_simple_group_check_discriminant"}, +{ERR_FUNC(EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE), "ec_GFp_simple_group_set_curve"}, +{ERR_FUNC(EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP), "EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP"}, +{ERR_FUNC(EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR), "EC_GFP_SIMPLE_GROUP_SET_GENERATOR"}, +{ERR_FUNC(EC_F_EC_GFP_SIMPLE_MAKE_AFFINE), "ec_GFp_simple_make_affine"}, +{ERR_FUNC(EC_F_EC_GFP_SIMPLE_OCT2POINT), "ec_GFp_simple_oct2point"}, +{ERR_FUNC(EC_F_EC_GFP_SIMPLE_POINT2OCT), "ec_GFp_simple_point2oct"}, +{ERR_FUNC(EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE), "ec_GFp_simple_points_make_affine"}, +{ERR_FUNC(EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES), "ec_GFp_simple_point_get_affine_coordinates"}, +{ERR_FUNC(EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP), "EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP"}, +{ERR_FUNC(EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES), "ec_GFp_simple_point_set_affine_coordinates"}, +{ERR_FUNC(EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP), "EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP"}, +{ERR_FUNC(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES), "ec_GFp_simple_set_compressed_coordinates"}, +{ERR_FUNC(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP), "EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP"}, +{ERR_FUNC(EC_F_EC_GROUP_CHECK), "EC_GROUP_check"}, +{ERR_FUNC(EC_F_EC_GROUP_CHECK_DISCRIMINANT), "EC_GROUP_check_discriminant"}, +{ERR_FUNC(EC_F_EC_GROUP_COPY), "EC_GROUP_copy"}, +{ERR_FUNC(EC_F_EC_GROUP_GET0_GENERATOR), "EC_GROUP_get0_generator"}, +{ERR_FUNC(EC_F_EC_GROUP_GET_COFACTOR), "EC_GROUP_get_cofactor"}, +{ERR_FUNC(EC_F_EC_GROUP_GET_CURVE_GF2M), "EC_GROUP_get_curve_GF2m"}, +{ERR_FUNC(EC_F_EC_GROUP_GET_CURVE_GFP), "EC_GROUP_get_curve_GFp"}, +{ERR_FUNC(EC_F_EC_GROUP_GET_DEGREE), "EC_GROUP_get_degree"}, +{ERR_FUNC(EC_F_EC_GROUP_GET_ORDER), "EC_GROUP_get_order"}, +{ERR_FUNC(EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS), "EC_GROUP_get_pentanomial_basis"}, +{ERR_FUNC(EC_F_EC_GROUP_GET_TRINOMIAL_BASIS), "EC_GROUP_get_trinomial_basis"}, +{ERR_FUNC(EC_F_EC_GROUP_NEW), "EC_GROUP_new"}, +{ERR_FUNC(EC_F_EC_GROUP_NEW_BY_CURVE_NAME), "EC_GROUP_new_by_curve_name"}, +{ERR_FUNC(EC_F_EC_GROUP_NEW_FROM_DATA), "EC_GROUP_NEW_FROM_DATA"}, +{ERR_FUNC(EC_F_EC_GROUP_PRECOMPUTE_MULT), "EC_GROUP_precompute_mult"}, +{ERR_FUNC(EC_F_EC_GROUP_SET_CURVE_GF2M), "EC_GROUP_set_curve_GF2m"}, +{ERR_FUNC(EC_F_EC_GROUP_SET_CURVE_GFP), "EC_GROUP_set_curve_GFp"}, +{ERR_FUNC(EC_F_EC_GROUP_SET_EXTRA_DATA), "EC_GROUP_SET_EXTRA_DATA"}, +{ERR_FUNC(EC_F_EC_GROUP_SET_GENERATOR), "EC_GROUP_set_generator"}, +{ERR_FUNC(EC_F_EC_KEY_CHECK_KEY), "EC_KEY_check_key"}, +{ERR_FUNC(EC_F_EC_KEY_COPY), "EC_KEY_copy"}, +{ERR_FUNC(EC_F_EC_KEY_GENERATE_KEY), "EC_KEY_generate_key"}, +{ERR_FUNC(EC_F_EC_KEY_NEW), "EC_KEY_new"}, +{ERR_FUNC(EC_F_EC_KEY_PRINT), "EC_KEY_print"}, +{ERR_FUNC(EC_F_EC_KEY_PRINT_FP), "EC_KEY_print_fp"}, +{ERR_FUNC(EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES), "EC_KEY_set_public_key_affine_coordinates"}, +{ERR_FUNC(EC_F_EC_POINTS_MAKE_AFFINE), "EC_POINTs_make_affine"}, +{ERR_FUNC(EC_F_EC_POINT_ADD), "EC_POINT_add"}, +{ERR_FUNC(EC_F_EC_POINT_CMP), "EC_POINT_cmp"}, +{ERR_FUNC(EC_F_EC_POINT_COPY), "EC_POINT_copy"}, +{ERR_FUNC(EC_F_EC_POINT_DBL), "EC_POINT_dbl"}, +{ERR_FUNC(EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M), "EC_POINT_get_affine_coordinates_GF2m"}, +{ERR_FUNC(EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP), "EC_POINT_get_affine_coordinates_GFp"}, +{ERR_FUNC(EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP), "EC_POINT_get_Jprojective_coordinates_GFp"}, +{ERR_FUNC(EC_F_EC_POINT_INVERT), "EC_POINT_invert"}, +{ERR_FUNC(EC_F_EC_POINT_IS_AT_INFINITY), "EC_POINT_is_at_infinity"}, +{ERR_FUNC(EC_F_EC_POINT_IS_ON_CURVE), "EC_POINT_is_on_curve"}, +{ERR_FUNC(EC_F_EC_POINT_MAKE_AFFINE), "EC_POINT_make_affine"}, +{ERR_FUNC(EC_F_EC_POINT_MUL), "EC_POINT_mul"}, +{ERR_FUNC(EC_F_EC_POINT_NEW), "EC_POINT_new"}, +{ERR_FUNC(EC_F_EC_POINT_OCT2POINT), "EC_POINT_oct2point"}, +{ERR_FUNC(EC_F_EC_POINT_POINT2OCT), "EC_POINT_point2oct"}, +{ERR_FUNC(EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M), "EC_POINT_set_affine_coordinates_GF2m"}, +{ERR_FUNC(EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP), "EC_POINT_set_affine_coordinates_GFp"}, +{ERR_FUNC(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M), "EC_POINT_set_compressed_coordinates_GF2m"}, +{ERR_FUNC(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP), "EC_POINT_set_compressed_coordinates_GFp"}, +{ERR_FUNC(EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP), "EC_POINT_set_Jprojective_coordinates_GFp"}, +{ERR_FUNC(EC_F_EC_POINT_SET_TO_INFINITY), "EC_POINT_set_to_infinity"}, +{ERR_FUNC(EC_F_EC_PRE_COMP_DUP), "EC_PRE_COMP_DUP"}, +{ERR_FUNC(EC_F_EC_PRE_COMP_NEW), "EC_PRE_COMP_NEW"}, +{ERR_FUNC(EC_F_EC_WNAF_MUL), "ec_wNAF_mul"}, +{ERR_FUNC(EC_F_EC_WNAF_PRECOMPUTE_MULT), "ec_wNAF_precompute_mult"}, +{ERR_FUNC(EC_F_I2D_ECPARAMETERS), "i2d_ECParameters"}, +{ERR_FUNC(EC_F_I2D_ECPKPARAMETERS), "i2d_ECPKParameters"}, +{ERR_FUNC(EC_F_I2D_ECPRIVATEKEY), "i2d_ECPrivateKey"}, +{ERR_FUNC(EC_F_I2O_ECPUBLICKEY), "i2o_ECPublicKey"}, +{ERR_FUNC(EC_F_NISTP224_PRE_COMP_NEW), "NISTP224_PRE_COMP_NEW"}, +{ERR_FUNC(EC_F_NISTP256_PRE_COMP_NEW), "NISTP256_PRE_COMP_NEW"}, +{ERR_FUNC(EC_F_NISTP521_PRE_COMP_NEW), "NISTP521_PRE_COMP_NEW"}, +{ERR_FUNC(EC_F_O2I_ECPUBLICKEY), "o2i_ECPublicKey"}, +{ERR_FUNC(EC_F_OLD_EC_PRIV_DECODE), "OLD_EC_PRIV_DECODE"}, +{ERR_FUNC(EC_F_PKEY_EC_CTRL), "PKEY_EC_CTRL"}, +{ERR_FUNC(EC_F_PKEY_EC_CTRL_STR), "PKEY_EC_CTRL_STR"}, +{ERR_FUNC(EC_F_PKEY_EC_DERIVE), "PKEY_EC_DERIVE"}, +{ERR_FUNC(EC_F_PKEY_EC_KEYGEN), "PKEY_EC_KEYGEN"}, +{ERR_FUNC(EC_F_PKEY_EC_PARAMGEN), "PKEY_EC_PARAMGEN"}, +{ERR_FUNC(EC_F_PKEY_EC_SIGN), "PKEY_EC_SIGN"}, +{0,NULL} + }; + +static ERR_STRING_DATA EC_str_reasons[]= + { +{ERR_REASON(EC_R_ASN1_ERROR) ,"asn1 error"}, +{ERR_REASON(EC_R_ASN1_UNKNOWN_FIELD) ,"asn1 unknown field"}, +{ERR_REASON(EC_R_BIGNUM_OUT_OF_RANGE) ,"bignum out of range"}, +{ERR_REASON(EC_R_BUFFER_TOO_SMALL) ,"buffer too small"}, +{ERR_REASON(EC_R_COORDINATES_OUT_OF_RANGE),"coordinates out of range"}, +{ERR_REASON(EC_R_D2I_ECPKPARAMETERS_FAILURE),"d2i ecpkparameters failure"}, +{ERR_REASON(EC_R_DECODE_ERROR) ,"decode error"}, +{ERR_REASON(EC_R_DISCRIMINANT_IS_ZERO) ,"discriminant is zero"}, +{ERR_REASON(EC_R_EC_GROUP_NEW_BY_NAME_FAILURE),"ec group new by name failure"}, +{ERR_REASON(EC_R_FIELD_TOO_LARGE) ,"field too large"}, +{ERR_REASON(EC_R_GF2M_NOT_SUPPORTED) ,"gf2m not supported"}, +{ERR_REASON(EC_R_GROUP2PKPARAMETERS_FAILURE),"group2pkparameters failure"}, +{ERR_REASON(EC_R_I2D_ECPKPARAMETERS_FAILURE),"i2d ecpkparameters failure"}, +{ERR_REASON(EC_R_INCOMPATIBLE_OBJECTS) ,"incompatible objects"}, +{ERR_REASON(EC_R_INVALID_ARGUMENT) ,"invalid argument"}, +{ERR_REASON(EC_R_INVALID_COMPRESSED_POINT),"invalid compressed point"}, +{ERR_REASON(EC_R_INVALID_COMPRESSION_BIT),"invalid compression bit"}, +{ERR_REASON(EC_R_INVALID_CURVE) ,"invalid curve"}, +{ERR_REASON(EC_R_INVALID_DIGEST_TYPE) ,"invalid digest type"}, +{ERR_REASON(EC_R_INVALID_ENCODING) ,"invalid encoding"}, +{ERR_REASON(EC_R_INVALID_FIELD) ,"invalid field"}, +{ERR_REASON(EC_R_INVALID_FORM) ,"invalid form"}, +{ERR_REASON(EC_R_INVALID_GROUP_ORDER) ,"invalid group order"}, +{ERR_REASON(EC_R_INVALID_PENTANOMIAL_BASIS),"invalid pentanomial basis"}, +{ERR_REASON(EC_R_INVALID_PRIVATE_KEY) ,"invalid private key"}, +{ERR_REASON(EC_R_INVALID_TRINOMIAL_BASIS),"invalid trinomial basis"}, +{ERR_REASON(EC_R_KEYS_NOT_SET) ,"keys not set"}, +{ERR_REASON(EC_R_MISSING_PARAMETERS) ,"missing parameters"}, +{ERR_REASON(EC_R_MISSING_PRIVATE_KEY) ,"missing private key"}, +{ERR_REASON(EC_R_NOT_A_NIST_PRIME) ,"not a NIST prime"}, +{ERR_REASON(EC_R_NOT_A_SUPPORTED_NIST_PRIME),"not a supported NIST prime"}, +{ERR_REASON(EC_R_NOT_IMPLEMENTED) ,"not implemented"}, +{ERR_REASON(EC_R_NOT_INITIALIZED) ,"not initialized"}, +{ERR_REASON(EC_R_NO_FIELD_MOD) ,"no field mod"}, +{ERR_REASON(EC_R_NO_PARAMETERS_SET) ,"no parameters set"}, +{ERR_REASON(EC_R_PASSED_NULL_PARAMETER) ,"passed null parameter"}, +{ERR_REASON(EC_R_PKPARAMETERS2GROUP_FAILURE),"pkparameters2group failure"}, +{ERR_REASON(EC_R_POINT_AT_INFINITY) ,"point at infinity"}, +{ERR_REASON(EC_R_POINT_IS_NOT_ON_CURVE) ,"point is not on curve"}, +{ERR_REASON(EC_R_SLOT_FULL) ,"slot full"}, +{ERR_REASON(EC_R_UNDEFINED_GENERATOR) ,"undefined generator"}, +{ERR_REASON(EC_R_UNDEFINED_ORDER) ,"undefined order"}, +{ERR_REASON(EC_R_UNKNOWN_GROUP) ,"unknown group"}, +{ERR_REASON(EC_R_UNKNOWN_ORDER) ,"unknown order"}, +{ERR_REASON(EC_R_UNSUPPORTED_FIELD) ,"unsupported field"}, +{ERR_REASON(EC_R_WRONG_CURVE_PARAMETERS) ,"wrong curve parameters"}, +{ERR_REASON(EC_R_WRONG_ORDER) ,"wrong order"}, +{0,NULL} + }; + +#endif + +void ERR_load_EC_strings(void) + { +#ifndef OPENSSL_NO_ERR + + if (ERR_func_error_string(EC_str_functs[0].error) == NULL) + { + ERR_load_strings(0,EC_str_functs); + ERR_load_strings(0,EC_str_reasons); + } +#endif + } diff --git a/libs/openssl/crypto/ec/ec_key.c b/libs/openssl/crypto/ec/ec_key.c new file mode 100644 index 00000000..7fa24759 --- /dev/null +++ b/libs/openssl/crypto/ec/ec_key.c @@ -0,0 +1,572 @@ +/* crypto/ec/ec_key.c */ +/* + * Written by Nils Larsch for the OpenSSL project. + */ +/* ==================================================================== + * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * Portions originally developed by SUN MICROSYSTEMS, INC., and + * contributed to the OpenSSL project. + */ + +#include +#include "ec_lcl.h" +#include +#ifdef OPENSSL_FIPS +#include +#endif + +EC_KEY *EC_KEY_new(void) + { + EC_KEY *ret; + + ret=(EC_KEY *)OPENSSL_malloc(sizeof(EC_KEY)); + if (ret == NULL) + { + ECerr(EC_F_EC_KEY_NEW, ERR_R_MALLOC_FAILURE); + return(NULL); + } + + ret->version = 1; + ret->flags = 0; + ret->group = NULL; + ret->pub_key = NULL; + ret->priv_key= NULL; + ret->enc_flag= 0; + ret->conv_form = POINT_CONVERSION_UNCOMPRESSED; + ret->references= 1; + ret->method_data = NULL; + return(ret); + } + +EC_KEY *EC_KEY_new_by_curve_name(int nid) + { + EC_KEY *ret = EC_KEY_new(); + if (ret == NULL) + return NULL; + ret->group = EC_GROUP_new_by_curve_name(nid); + if (ret->group == NULL) + { + EC_KEY_free(ret); + return NULL; + } + return ret; + } + +void EC_KEY_free(EC_KEY *r) + { + int i; + + if (r == NULL) return; + + i=CRYPTO_add(&r->references,-1,CRYPTO_LOCK_EC); +#ifdef REF_PRINT + REF_PRINT("EC_KEY",r); +#endif + if (i > 0) return; +#ifdef REF_CHECK + if (i < 0) + { + fprintf(stderr,"EC_KEY_free, bad reference count\n"); + abort(); + } +#endif + + if (r->group != NULL) + EC_GROUP_free(r->group); + if (r->pub_key != NULL) + EC_POINT_free(r->pub_key); + if (r->priv_key != NULL) + BN_clear_free(r->priv_key); + + EC_EX_DATA_free_all_data(&r->method_data); + + OPENSSL_cleanse((void *)r, sizeof(EC_KEY)); + + OPENSSL_free(r); + } + +EC_KEY *EC_KEY_copy(EC_KEY *dest, const EC_KEY *src) + { + EC_EXTRA_DATA *d; + + if (dest == NULL || src == NULL) + { + ECerr(EC_F_EC_KEY_COPY, ERR_R_PASSED_NULL_PARAMETER); + return NULL; + } + /* copy the parameters */ + if (src->group) + { + const EC_METHOD *meth = EC_GROUP_method_of(src->group); + /* clear the old group */ + if (dest->group) + EC_GROUP_free(dest->group); + dest->group = EC_GROUP_new(meth); + if (dest->group == NULL) + return NULL; + if (!EC_GROUP_copy(dest->group, src->group)) + return NULL; + } + /* copy the public key */ + if (src->pub_key && src->group) + { + if (dest->pub_key) + EC_POINT_free(dest->pub_key); + dest->pub_key = EC_POINT_new(src->group); + if (dest->pub_key == NULL) + return NULL; + if (!EC_POINT_copy(dest->pub_key, src->pub_key)) + return NULL; + } + /* copy the private key */ + if (src->priv_key) + { + if (dest->priv_key == NULL) + { + dest->priv_key = BN_new(); + if (dest->priv_key == NULL) + return NULL; + } + if (!BN_copy(dest->priv_key, src->priv_key)) + return NULL; + } + /* copy method/extra data */ + EC_EX_DATA_free_all_data(&dest->method_data); + + for (d = src->method_data; d != NULL; d = d->next) + { + void *t = d->dup_func(d->data); + + if (t == NULL) + return 0; + if (!EC_EX_DATA_set_data(&dest->method_data, t, d->dup_func, d->free_func, d->clear_free_func)) + return 0; + } + + /* copy the rest */ + dest->enc_flag = src->enc_flag; + dest->conv_form = src->conv_form; + dest->version = src->version; + dest->flags = src->flags; + + return dest; + } + +EC_KEY *EC_KEY_dup(const EC_KEY *ec_key) + { + EC_KEY *ret = EC_KEY_new(); + if (ret == NULL) + return NULL; + if (EC_KEY_copy(ret, ec_key) == NULL) + { + EC_KEY_free(ret); + return NULL; + } + return ret; + } + +int EC_KEY_up_ref(EC_KEY *r) + { + int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_EC); +#ifdef REF_PRINT + REF_PRINT("EC_KEY",r); +#endif +#ifdef REF_CHECK + if (i < 2) + { + fprintf(stderr, "EC_KEY_up, bad reference count\n"); + abort(); + } +#endif + return ((i > 1) ? 1 : 0); + } + +int EC_KEY_generate_key(EC_KEY *eckey) + { + int ok = 0; + BN_CTX *ctx = NULL; + BIGNUM *priv_key = NULL, *order = NULL; + EC_POINT *pub_key = NULL; + +#ifdef OPENSSL_FIPS + if (FIPS_mode()) + return FIPS_ec_key_generate_key(eckey); +#endif + + if (!eckey || !eckey->group) + { + ECerr(EC_F_EC_KEY_GENERATE_KEY, ERR_R_PASSED_NULL_PARAMETER); + return 0; + } + + if ((order = BN_new()) == NULL) goto err; + if ((ctx = BN_CTX_new()) == NULL) goto err; + + if (eckey->priv_key == NULL) + { + priv_key = BN_new(); + if (priv_key == NULL) + goto err; + } + else + priv_key = eckey->priv_key; + + if (!EC_GROUP_get_order(eckey->group, order, ctx)) + goto err; + + do + if (!BN_rand_range(priv_key, order)) + goto err; + while (BN_is_zero(priv_key)); + + if (eckey->pub_key == NULL) + { + pub_key = EC_POINT_new(eckey->group); + if (pub_key == NULL) + goto err; + } + else + pub_key = eckey->pub_key; + + if (!EC_POINT_mul(eckey->group, pub_key, priv_key, NULL, NULL, ctx)) + goto err; + + eckey->priv_key = priv_key; + eckey->pub_key = pub_key; + + ok=1; + +err: + if (order) + BN_free(order); + if (pub_key != NULL && eckey->pub_key == NULL) + EC_POINT_free(pub_key); + if (priv_key != NULL && eckey->priv_key == NULL) + BN_free(priv_key); + if (ctx != NULL) + BN_CTX_free(ctx); + return(ok); + } + +int EC_KEY_check_key(const EC_KEY *eckey) + { + int ok = 0; + BN_CTX *ctx = NULL; + const BIGNUM *order = NULL; + EC_POINT *point = NULL; + + if (!eckey || !eckey->group || !eckey->pub_key) + { + ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_PASSED_NULL_PARAMETER); + return 0; + } + + if (EC_POINT_is_at_infinity(eckey->group, eckey->pub_key)) + { + ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_POINT_AT_INFINITY); + goto err; + } + + if ((ctx = BN_CTX_new()) == NULL) + goto err; + if ((point = EC_POINT_new(eckey->group)) == NULL) + goto err; + + /* testing whether the pub_key is on the elliptic curve */ + if (!EC_POINT_is_on_curve(eckey->group, eckey->pub_key, ctx)) + { + ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_POINT_IS_NOT_ON_CURVE); + goto err; + } + /* testing whether pub_key * order is the point at infinity */ + order = &eckey->group->order; + if (BN_is_zero(order)) + { + ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_INVALID_GROUP_ORDER); + goto err; + } + if (!EC_POINT_mul(eckey->group, point, NULL, eckey->pub_key, order, ctx)) + { + ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_EC_LIB); + goto err; + } + if (!EC_POINT_is_at_infinity(eckey->group, point)) + { + ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_WRONG_ORDER); + goto err; + } + /* in case the priv_key is present : + * check if generator * priv_key == pub_key + */ + if (eckey->priv_key) + { + if (BN_cmp(eckey->priv_key, order) >= 0) + { + ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_WRONG_ORDER); + goto err; + } + if (!EC_POINT_mul(eckey->group, point, eckey->priv_key, + NULL, NULL, ctx)) + { + ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_EC_LIB); + goto err; + } + if (EC_POINT_cmp(eckey->group, point, eckey->pub_key, + ctx) != 0) + { + ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_INVALID_PRIVATE_KEY); + goto err; + } + } + ok = 1; +err: + if (ctx != NULL) + BN_CTX_free(ctx); + if (point != NULL) + EC_POINT_free(point); + return(ok); + } + +int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, BIGNUM *y) + { + BN_CTX *ctx = NULL; + BIGNUM *tx, *ty; + EC_POINT *point = NULL; + int ok = 0, tmp_nid, is_char_two = 0; + + if (!key || !key->group || !x || !y) + { + ECerr(EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES, + ERR_R_PASSED_NULL_PARAMETER); + return 0; + } + ctx = BN_CTX_new(); + if (!ctx) + goto err; + + point = EC_POINT_new(key->group); + + if (!point) + goto err; + + tmp_nid = EC_METHOD_get_field_type(EC_GROUP_method_of(key->group)); + + if (tmp_nid == NID_X9_62_characteristic_two_field) + is_char_two = 1; + + tx = BN_CTX_get(ctx); + ty = BN_CTX_get(ctx); +#ifndef OPENSSL_NO_EC2M + if (is_char_two) + { + if (!EC_POINT_set_affine_coordinates_GF2m(key->group, point, + x, y, ctx)) + goto err; + if (!EC_POINT_get_affine_coordinates_GF2m(key->group, point, + tx, ty, ctx)) + goto err; + } + else +#endif + { + if (!EC_POINT_set_affine_coordinates_GFp(key->group, point, + x, y, ctx)) + goto err; + if (!EC_POINT_get_affine_coordinates_GFp(key->group, point, + tx, ty, ctx)) + goto err; + } + /* Check if retrieved coordinates match originals: if not values + * are out of range. + */ + if (BN_cmp(x, tx) || BN_cmp(y, ty)) + { + ECerr(EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES, + EC_R_COORDINATES_OUT_OF_RANGE); + goto err; + } + + if (!EC_KEY_set_public_key(key, point)) + goto err; + + if (EC_KEY_check_key(key) == 0) + goto err; + + ok = 1; + + err: + if (ctx) + BN_CTX_free(ctx); + if (point) + EC_POINT_free(point); + return ok; + + } + +const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key) + { + return key->group; + } + +int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group) + { + if (key->group != NULL) + EC_GROUP_free(key->group); + key->group = EC_GROUP_dup(group); + return (key->group == NULL) ? 0 : 1; + } + +const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key) + { + return key->priv_key; + } + +int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *priv_key) + { + if (key->priv_key) + BN_clear_free(key->priv_key); + key->priv_key = BN_dup(priv_key); + return (key->priv_key == NULL) ? 0 : 1; + } + +const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key) + { + return key->pub_key; + } + +int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub_key) + { + if (key->pub_key != NULL) + EC_POINT_free(key->pub_key); + key->pub_key = EC_POINT_dup(pub_key, key->group); + return (key->pub_key == NULL) ? 0 : 1; + } + +unsigned int EC_KEY_get_enc_flags(const EC_KEY *key) + { + return key->enc_flag; + } + +void EC_KEY_set_enc_flags(EC_KEY *key, unsigned int flags) + { + key->enc_flag = flags; + } + +point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key) + { + return key->conv_form; + } + +void EC_KEY_set_conv_form(EC_KEY *key, point_conversion_form_t cform) + { + key->conv_form = cform; + if (key->group != NULL) + EC_GROUP_set_point_conversion_form(key->group, cform); + } + +void *EC_KEY_get_key_method_data(EC_KEY *key, + void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)) + { + void *ret; + + CRYPTO_r_lock(CRYPTO_LOCK_EC); + ret = EC_EX_DATA_get_data(key->method_data, dup_func, free_func, clear_free_func); + CRYPTO_r_unlock(CRYPTO_LOCK_EC); + + return ret; + } + +void *EC_KEY_insert_key_method_data(EC_KEY *key, void *data, + void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)) + { + EC_EXTRA_DATA *ex_data; + + CRYPTO_w_lock(CRYPTO_LOCK_EC); + ex_data = EC_EX_DATA_get_data(key->method_data, dup_func, free_func, clear_free_func); + if (ex_data == NULL) + EC_EX_DATA_set_data(&key->method_data, data, dup_func, free_func, clear_free_func); + CRYPTO_w_unlock(CRYPTO_LOCK_EC); + + return ex_data; + } + +void EC_KEY_set_asn1_flag(EC_KEY *key, int flag) + { + if (key->group != NULL) + EC_GROUP_set_asn1_flag(key->group, flag); + } + +int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx) + { + if (key->group == NULL) + return 0; + return EC_GROUP_precompute_mult(key->group, ctx); + } + +int EC_KEY_get_flags(const EC_KEY *key) + { + return key->flags; + } + +void EC_KEY_set_flags(EC_KEY *key, int flags) + { + key->flags |= flags; + } + +void EC_KEY_clear_flags(EC_KEY *key, int flags) + { + key->flags &= ~flags; + } diff --git a/libs/openssl/crypto/ec/ec_lcl.h b/libs/openssl/crypto/ec/ec_lcl.h new file mode 100644 index 00000000..b0d48b6b --- /dev/null +++ b/libs/openssl/crypto/ec/ec_lcl.h @@ -0,0 +1,446 @@ +/* crypto/ec/ec_lcl.h */ +/* + * Originally written by Bodo Moeller for the OpenSSL project. + */ +/* ==================================================================== + * Copyright (c) 1998-2010 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * Portions of the attached software ("Contribution") are developed by + * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. + * + * The Contribution is licensed pursuant to the OpenSSL open source + * license provided above. + * + * The elliptic curve binary polynomial software is originally written by + * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. + * + */ + + +#include + +#include +#include +#include + +#if defined(__SUNPRO_C) +# if __SUNPRO_C >= 0x520 +# pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) +# endif +#endif + +/* Use default functions for poin2oct, oct2point and compressed coordinates */ +#define EC_FLAGS_DEFAULT_OCT 0x1 + +/* Structure details are not part of the exported interface, + * so all this may change in future versions. */ + +struct ec_method_st { + /* Various method flags */ + int flags; + /* used by EC_METHOD_get_field_type: */ + int field_type; /* a NID */ + + /* used by EC_GROUP_new, EC_GROUP_free, EC_GROUP_clear_free, EC_GROUP_copy: */ + int (*group_init)(EC_GROUP *); + void (*group_finish)(EC_GROUP *); + void (*group_clear_finish)(EC_GROUP *); + int (*group_copy)(EC_GROUP *, const EC_GROUP *); + + /* used by EC_GROUP_set_curve_GFp, EC_GROUP_get_curve_GFp, */ + /* EC_GROUP_set_curve_GF2m, and EC_GROUP_get_curve_GF2m: */ + int (*group_set_curve)(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); + int (*group_get_curve)(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); + + /* used by EC_GROUP_get_degree: */ + int (*group_get_degree)(const EC_GROUP *); + + /* used by EC_GROUP_check: */ + int (*group_check_discriminant)(const EC_GROUP *, BN_CTX *); + + /* used by EC_POINT_new, EC_POINT_free, EC_POINT_clear_free, EC_POINT_copy: */ + int (*point_init)(EC_POINT *); + void (*point_finish)(EC_POINT *); + void (*point_clear_finish)(EC_POINT *); + int (*point_copy)(EC_POINT *, const EC_POINT *); + + /* used by EC_POINT_set_to_infinity, + * EC_POINT_set_Jprojective_coordinates_GFp, + * EC_POINT_get_Jprojective_coordinates_GFp, + * EC_POINT_set_affine_coordinates_GFp, ..._GF2m, + * EC_POINT_get_affine_coordinates_GFp, ..._GF2m, + * EC_POINT_set_compressed_coordinates_GFp, ..._GF2m: + */ + int (*point_set_to_infinity)(const EC_GROUP *, EC_POINT *); + int (*point_set_Jprojective_coordinates_GFp)(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *); + int (*point_get_Jprojective_coordinates_GFp)(const EC_GROUP *, const EC_POINT *, + BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *); + int (*point_set_affine_coordinates)(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, const BIGNUM *y, BN_CTX *); + int (*point_get_affine_coordinates)(const EC_GROUP *, const EC_POINT *, + BIGNUM *x, BIGNUM *y, BN_CTX *); + int (*point_set_compressed_coordinates)(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, int y_bit, BN_CTX *); + + /* used by EC_POINT_point2oct, EC_POINT_oct2point: */ + size_t (*point2oct)(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form, + unsigned char *buf, size_t len, BN_CTX *); + int (*oct2point)(const EC_GROUP *, EC_POINT *, + const unsigned char *buf, size_t len, BN_CTX *); + + /* used by EC_POINT_add, EC_POINT_dbl, ECP_POINT_invert: */ + int (*add)(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *); + int (*dbl)(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *); + int (*invert)(const EC_GROUP *, EC_POINT *, BN_CTX *); + + /* used by EC_POINT_is_at_infinity, EC_POINT_is_on_curve, EC_POINT_cmp: */ + int (*is_at_infinity)(const EC_GROUP *, const EC_POINT *); + int (*is_on_curve)(const EC_GROUP *, const EC_POINT *, BN_CTX *); + int (*point_cmp)(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, BN_CTX *); + + /* used by EC_POINT_make_affine, EC_POINTs_make_affine: */ + int (*make_affine)(const EC_GROUP *, EC_POINT *, BN_CTX *); + int (*points_make_affine)(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *); + + /* used by EC_POINTs_mul, EC_POINT_mul, EC_POINT_precompute_mult, EC_POINT_have_precompute_mult + * (default implementations are used if the 'mul' pointer is 0): */ + int (*mul)(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, + size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *); + int (*precompute_mult)(EC_GROUP *group, BN_CTX *); + int (*have_precompute_mult)(const EC_GROUP *group); + + + /* internal functions */ + + /* 'field_mul', 'field_sqr', and 'field_div' can be used by 'add' and 'dbl' so that + * the same implementations of point operations can be used with different + * optimized implementations of expensive field operations: */ + int (*field_mul)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *); + int (*field_sqr)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); + int (*field_div)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *); + + int (*field_encode)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); /* e.g. to Montgomery */ + int (*field_decode)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); /* e.g. from Montgomery */ + int (*field_set_to_one)(const EC_GROUP *, BIGNUM *r, BN_CTX *); +} /* EC_METHOD */; + +typedef struct ec_extra_data_st { + struct ec_extra_data_st *next; + void *data; + void *(*dup_func)(void *); + void (*free_func)(void *); + void (*clear_free_func)(void *); +} EC_EXTRA_DATA; /* used in EC_GROUP */ + +struct ec_group_st { + const EC_METHOD *meth; + + EC_POINT *generator; /* optional */ + BIGNUM order, cofactor; + + int curve_name;/* optional NID for named curve */ + int asn1_flag; /* flag to control the asn1 encoding */ + point_conversion_form_t asn1_form; + + unsigned char *seed; /* optional seed for parameters (appears in ASN1) */ + size_t seed_len; + + EC_EXTRA_DATA *extra_data; /* linked list */ + + /* The following members are handled by the method functions, + * even if they appear generic */ + + BIGNUM field; /* Field specification. + * For curves over GF(p), this is the modulus; + * for curves over GF(2^m), this is the + * irreducible polynomial defining the field. + */ + + int poly[6]; /* Field specification for curves over GF(2^m). + * The irreducible f(t) is then of the form: + * t^poly[0] + t^poly[1] + ... + t^poly[k] + * where m = poly[0] > poly[1] > ... > poly[k] = 0. + * The array is terminated with poly[k+1]=-1. + * All elliptic curve irreducibles have at most 5 + * non-zero terms. + */ + + BIGNUM a, b; /* Curve coefficients. + * (Here the assumption is that BIGNUMs can be used + * or abused for all kinds of fields, not just GF(p).) + * For characteristic > 3, the curve is defined + * by a Weierstrass equation of the form + * y^2 = x^3 + a*x + b. + * For characteristic 2, the curve is defined by + * an equation of the form + * y^2 + x*y = x^3 + a*x^2 + b. + */ + + int a_is_minus3; /* enable optimized point arithmetics for special case */ + + void *field_data1; /* method-specific (e.g., Montgomery structure) */ + void *field_data2; /* method-specific */ + int (*field_mod_func)(BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); /* method-specific */ +} /* EC_GROUP */; + +struct ec_key_st { + int version; + + EC_GROUP *group; + + EC_POINT *pub_key; + BIGNUM *priv_key; + + unsigned int enc_flag; + point_conversion_form_t conv_form; + + int references; + int flags; + + EC_EXTRA_DATA *method_data; +} /* EC_KEY */; + +/* Basically a 'mixin' for extra data, but available for EC_GROUPs/EC_KEYs only + * (with visibility limited to 'package' level for now). + * We use the function pointers as index for retrieval; this obviates + * global ex_data-style index tables. + */ +int EC_EX_DATA_set_data(EC_EXTRA_DATA **, void *data, + void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); +void *EC_EX_DATA_get_data(const EC_EXTRA_DATA *, + void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); +void EC_EX_DATA_free_data(EC_EXTRA_DATA **, + void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); +void EC_EX_DATA_clear_free_data(EC_EXTRA_DATA **, + void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); +void EC_EX_DATA_free_all_data(EC_EXTRA_DATA **); +void EC_EX_DATA_clear_free_all_data(EC_EXTRA_DATA **); + + + +struct ec_point_st { + const EC_METHOD *meth; + + /* All members except 'meth' are handled by the method functions, + * even if they appear generic */ + + BIGNUM X; + BIGNUM Y; + BIGNUM Z; /* Jacobian projective coordinates: + * (X, Y, Z) represents (X/Z^2, Y/Z^3) if Z != 0 */ + int Z_is_one; /* enable optimized point arithmetics for special case */ +} /* EC_POINT */; + + + +/* method functions in ec_mult.c + * (ec_lib.c uses these as defaults if group->method->mul is 0) */ +int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, + size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *); +int ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *); +int ec_wNAF_have_precompute_mult(const EC_GROUP *group); + + +/* method functions in ecp_smpl.c */ +int ec_GFp_simple_group_init(EC_GROUP *); +void ec_GFp_simple_group_finish(EC_GROUP *); +void ec_GFp_simple_group_clear_finish(EC_GROUP *); +int ec_GFp_simple_group_copy(EC_GROUP *, const EC_GROUP *); +int ec_GFp_simple_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); +int ec_GFp_simple_group_get_curve(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); +int ec_GFp_simple_group_get_degree(const EC_GROUP *); +int ec_GFp_simple_group_check_discriminant(const EC_GROUP *, BN_CTX *); +int ec_GFp_simple_point_init(EC_POINT *); +void ec_GFp_simple_point_finish(EC_POINT *); +void ec_GFp_simple_point_clear_finish(EC_POINT *); +int ec_GFp_simple_point_copy(EC_POINT *, const EC_POINT *); +int ec_GFp_simple_point_set_to_infinity(const EC_GROUP *, EC_POINT *); +int ec_GFp_simple_set_Jprojective_coordinates_GFp(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *); +int ec_GFp_simple_get_Jprojective_coordinates_GFp(const EC_GROUP *, const EC_POINT *, + BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *); +int ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, const BIGNUM *y, BN_CTX *); +int ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *, const EC_POINT *, + BIGNUM *x, BIGNUM *y, BN_CTX *); +int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, int y_bit, BN_CTX *); +size_t ec_GFp_simple_point2oct(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form, + unsigned char *buf, size_t len, BN_CTX *); +int ec_GFp_simple_oct2point(const EC_GROUP *, EC_POINT *, + const unsigned char *buf, size_t len, BN_CTX *); +int ec_GFp_simple_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *); +int ec_GFp_simple_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *); +int ec_GFp_simple_invert(const EC_GROUP *, EC_POINT *, BN_CTX *); +int ec_GFp_simple_is_at_infinity(const EC_GROUP *, const EC_POINT *); +int ec_GFp_simple_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *); +int ec_GFp_simple_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, BN_CTX *); +int ec_GFp_simple_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *); +int ec_GFp_simple_points_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *); +int ec_GFp_simple_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *); +int ec_GFp_simple_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); + + +/* method functions in ecp_mont.c */ +int ec_GFp_mont_group_init(EC_GROUP *); +int ec_GFp_mont_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); +void ec_GFp_mont_group_finish(EC_GROUP *); +void ec_GFp_mont_group_clear_finish(EC_GROUP *); +int ec_GFp_mont_group_copy(EC_GROUP *, const EC_GROUP *); +int ec_GFp_mont_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *); +int ec_GFp_mont_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); +int ec_GFp_mont_field_encode(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); +int ec_GFp_mont_field_decode(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); +int ec_GFp_mont_field_set_to_one(const EC_GROUP *, BIGNUM *r, BN_CTX *); + + +/* method functions in ecp_nist.c */ +int ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src); +int ec_GFp_nist_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); +int ec_GFp_nist_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *); +int ec_GFp_nist_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); + + +/* method functions in ec2_smpl.c */ +int ec_GF2m_simple_group_init(EC_GROUP *); +void ec_GF2m_simple_group_finish(EC_GROUP *); +void ec_GF2m_simple_group_clear_finish(EC_GROUP *); +int ec_GF2m_simple_group_copy(EC_GROUP *, const EC_GROUP *); +int ec_GF2m_simple_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); +int ec_GF2m_simple_group_get_curve(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); +int ec_GF2m_simple_group_get_degree(const EC_GROUP *); +int ec_GF2m_simple_group_check_discriminant(const EC_GROUP *, BN_CTX *); +int ec_GF2m_simple_point_init(EC_POINT *); +void ec_GF2m_simple_point_finish(EC_POINT *); +void ec_GF2m_simple_point_clear_finish(EC_POINT *); +int ec_GF2m_simple_point_copy(EC_POINT *, const EC_POINT *); +int ec_GF2m_simple_point_set_to_infinity(const EC_GROUP *, EC_POINT *); +int ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, const BIGNUM *y, BN_CTX *); +int ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *, const EC_POINT *, + BIGNUM *x, BIGNUM *y, BN_CTX *); +int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, int y_bit, BN_CTX *); +size_t ec_GF2m_simple_point2oct(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form, + unsigned char *buf, size_t len, BN_CTX *); +int ec_GF2m_simple_oct2point(const EC_GROUP *, EC_POINT *, + const unsigned char *buf, size_t len, BN_CTX *); +int ec_GF2m_simple_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *); +int ec_GF2m_simple_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *); +int ec_GF2m_simple_invert(const EC_GROUP *, EC_POINT *, BN_CTX *); +int ec_GF2m_simple_is_at_infinity(const EC_GROUP *, const EC_POINT *); +int ec_GF2m_simple_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *); +int ec_GF2m_simple_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, BN_CTX *); +int ec_GF2m_simple_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *); +int ec_GF2m_simple_points_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *); +int ec_GF2m_simple_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *); +int ec_GF2m_simple_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); +int ec_GF2m_simple_field_div(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *); + + +/* method functions in ec2_mult.c */ +int ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, + size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *); +int ec_GF2m_precompute_mult(EC_GROUP *group, BN_CTX *ctx); +int ec_GF2m_have_precompute_mult(const EC_GROUP *group); + +/* method functions in ec2_mult.c */ +int ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, + size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *); +int ec_GF2m_precompute_mult(EC_GROUP *group, BN_CTX *ctx); +int ec_GF2m_have_precompute_mult(const EC_GROUP *group); + +#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 +/* method functions in ecp_nistp224.c */ +int ec_GFp_nistp224_group_init(EC_GROUP *group); +int ec_GFp_nistp224_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *n, BN_CTX *); +int ec_GFp_nistp224_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point, BIGNUM *x, BIGNUM *y, BN_CTX *ctx); +int ec_GFp_nistp224_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *); +int ec_GFp_nistp224_points_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx); +int ec_GFp_nistp224_precompute_mult(EC_GROUP *group, BN_CTX *ctx); +int ec_GFp_nistp224_have_precompute_mult(const EC_GROUP *group); + +/* method functions in ecp_nistp256.c */ +int ec_GFp_nistp256_group_init(EC_GROUP *group); +int ec_GFp_nistp256_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *n, BN_CTX *); +int ec_GFp_nistp256_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point, BIGNUM *x, BIGNUM *y, BN_CTX *ctx); +int ec_GFp_nistp256_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *); +int ec_GFp_nistp256_points_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx); +int ec_GFp_nistp256_precompute_mult(EC_GROUP *group, BN_CTX *ctx); +int ec_GFp_nistp256_have_precompute_mult(const EC_GROUP *group); + +/* method functions in ecp_nistp521.c */ +int ec_GFp_nistp521_group_init(EC_GROUP *group); +int ec_GFp_nistp521_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *n, BN_CTX *); +int ec_GFp_nistp521_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point, BIGNUM *x, BIGNUM *y, BN_CTX *ctx); +int ec_GFp_nistp521_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *); +int ec_GFp_nistp521_points_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx); +int ec_GFp_nistp521_precompute_mult(EC_GROUP *group, BN_CTX *ctx); +int ec_GFp_nistp521_have_precompute_mult(const EC_GROUP *group); + +/* utility functions in ecp_nistputil.c */ +void ec_GFp_nistp_points_make_affine_internal(size_t num, void *point_array, + size_t felem_size, void *tmp_felems, + void (*felem_one)(void *out), + int (*felem_is_zero)(const void *in), + void (*felem_assign)(void *out, const void *in), + void (*felem_square)(void *out, const void *in), + void (*felem_mul)(void *out, const void *in1, const void *in2), + void (*felem_inv)(void *out, const void *in), + void (*felem_contract)(void *out, const void *in)); +void ec_GFp_nistp_recode_scalar_bits(unsigned char *sign, unsigned char *digit, unsigned char in); +#endif diff --git a/libs/openssl/crypto/ec/ec_lib.c b/libs/openssl/crypto/ec/ec_lib.c new file mode 100644 index 00000000..de9a0cc2 --- /dev/null +++ b/libs/openssl/crypto/ec/ec_lib.c @@ -0,0 +1,1096 @@ +/* crypto/ec/ec_lib.c */ +/* + * Originally written by Bodo Moeller for the OpenSSL project. + */ +/* ==================================================================== + * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * Binary polynomial ECC support in OpenSSL originally developed by + * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. + */ + +#include + +#include +#include + +#include "ec_lcl.h" + +static const char EC_version[] = "EC" OPENSSL_VERSION_PTEXT; + + +/* functions for EC_GROUP objects */ + +EC_GROUP *EC_GROUP_new(const EC_METHOD *meth) + { + EC_GROUP *ret; + + if (meth == NULL) + { + ECerr(EC_F_EC_GROUP_NEW, EC_R_SLOT_FULL); + return NULL; + } + if (meth->group_init == 0) + { + ECerr(EC_F_EC_GROUP_NEW, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return NULL; + } + + ret = OPENSSL_malloc(sizeof *ret); + if (ret == NULL) + { + ECerr(EC_F_EC_GROUP_NEW, ERR_R_MALLOC_FAILURE); + return NULL; + } + + ret->meth = meth; + + ret->extra_data = NULL; + + ret->generator = NULL; + BN_init(&ret->order); + BN_init(&ret->cofactor); + + ret->curve_name = 0; + ret->asn1_flag = 0; + ret->asn1_form = POINT_CONVERSION_UNCOMPRESSED; + + ret->seed = NULL; + ret->seed_len = 0; + + if (!meth->group_init(ret)) + { + OPENSSL_free(ret); + return NULL; + } + + return ret; + } + + +void EC_GROUP_free(EC_GROUP *group) + { + if (!group) return; + + if (group->meth->group_finish != 0) + group->meth->group_finish(group); + + EC_EX_DATA_free_all_data(&group->extra_data); + + if (group->generator != NULL) + EC_POINT_free(group->generator); + BN_free(&group->order); + BN_free(&group->cofactor); + + if (group->seed) + OPENSSL_free(group->seed); + + OPENSSL_free(group); + } + + +void EC_GROUP_clear_free(EC_GROUP *group) + { + if (!group) return; + + if (group->meth->group_clear_finish != 0) + group->meth->group_clear_finish(group); + else if (group->meth->group_finish != 0) + group->meth->group_finish(group); + + EC_EX_DATA_clear_free_all_data(&group->extra_data); + + if (group->generator != NULL) + EC_POINT_clear_free(group->generator); + BN_clear_free(&group->order); + BN_clear_free(&group->cofactor); + + if (group->seed) + { + OPENSSL_cleanse(group->seed, group->seed_len); + OPENSSL_free(group->seed); + } + + OPENSSL_cleanse(group, sizeof *group); + OPENSSL_free(group); + } + + +int EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src) + { + EC_EXTRA_DATA *d; + + if (dest->meth->group_copy == 0) + { + ECerr(EC_F_EC_GROUP_COPY, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + if (dest->meth != src->meth) + { + ECerr(EC_F_EC_GROUP_COPY, EC_R_INCOMPATIBLE_OBJECTS); + return 0; + } + if (dest == src) + return 1; + + EC_EX_DATA_free_all_data(&dest->extra_data); + + for (d = src->extra_data; d != NULL; d = d->next) + { + void *t = d->dup_func(d->data); + + if (t == NULL) + return 0; + if (!EC_EX_DATA_set_data(&dest->extra_data, t, d->dup_func, d->free_func, d->clear_free_func)) + return 0; + } + + if (src->generator != NULL) + { + if (dest->generator == NULL) + { + dest->generator = EC_POINT_new(dest); + if (dest->generator == NULL) return 0; + } + if (!EC_POINT_copy(dest->generator, src->generator)) return 0; + } + else + { + /* src->generator == NULL */ + if (dest->generator != NULL) + { + EC_POINT_clear_free(dest->generator); + dest->generator = NULL; + } + } + + if (!BN_copy(&dest->order, &src->order)) return 0; + if (!BN_copy(&dest->cofactor, &src->cofactor)) return 0; + + dest->curve_name = src->curve_name; + dest->asn1_flag = src->asn1_flag; + dest->asn1_form = src->asn1_form; + + if (src->seed) + { + if (dest->seed) + OPENSSL_free(dest->seed); + dest->seed = OPENSSL_malloc(src->seed_len); + if (dest->seed == NULL) + return 0; + if (!memcpy(dest->seed, src->seed, src->seed_len)) + return 0; + dest->seed_len = src->seed_len; + } + else + { + if (dest->seed) + OPENSSL_free(dest->seed); + dest->seed = NULL; + dest->seed_len = 0; + } + + + return dest->meth->group_copy(dest, src); + } + + +EC_GROUP *EC_GROUP_dup(const EC_GROUP *a) + { + EC_GROUP *t = NULL; + int ok = 0; + + if (a == NULL) return NULL; + + if ((t = EC_GROUP_new(a->meth)) == NULL) return(NULL); + if (!EC_GROUP_copy(t, a)) goto err; + + ok = 1; + + err: + if (!ok) + { + if (t) EC_GROUP_free(t); + return NULL; + } + else return t; + } + + +const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group) + { + return group->meth; + } + + +int EC_METHOD_get_field_type(const EC_METHOD *meth) + { + return meth->field_type; + } + + +int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor) + { + if (generator == NULL) + { + ECerr(EC_F_EC_GROUP_SET_GENERATOR, ERR_R_PASSED_NULL_PARAMETER); + return 0 ; + } + + if (group->generator == NULL) + { + group->generator = EC_POINT_new(group); + if (group->generator == NULL) return 0; + } + if (!EC_POINT_copy(group->generator, generator)) return 0; + + if (order != NULL) + { if (!BN_copy(&group->order, order)) return 0; } + else + BN_zero(&group->order); + + if (cofactor != NULL) + { if (!BN_copy(&group->cofactor, cofactor)) return 0; } + else + BN_zero(&group->cofactor); + + return 1; + } + + +const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group) + { + return group->generator; + } + + +int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx) + { + if (!BN_copy(order, &group->order)) + return 0; + + return !BN_is_zero(order); + } + + +int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx) + { + if (!BN_copy(cofactor, &group->cofactor)) + return 0; + + return !BN_is_zero(&group->cofactor); + } + + +void EC_GROUP_set_curve_name(EC_GROUP *group, int nid) + { + group->curve_name = nid; + } + + +int EC_GROUP_get_curve_name(const EC_GROUP *group) + { + return group->curve_name; + } + + +void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag) + { + group->asn1_flag = flag; + } + + +int EC_GROUP_get_asn1_flag(const EC_GROUP *group) + { + return group->asn1_flag; + } + + +void EC_GROUP_set_point_conversion_form(EC_GROUP *group, + point_conversion_form_t form) + { + group->asn1_form = form; + } + + +point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *group) + { + return group->asn1_form; + } + + +size_t EC_GROUP_set_seed(EC_GROUP *group, const unsigned char *p, size_t len) + { + if (group->seed) + { + OPENSSL_free(group->seed); + group->seed = NULL; + group->seed_len = 0; + } + + if (!len || !p) + return 1; + + if ((group->seed = OPENSSL_malloc(len)) == NULL) + return 0; + memcpy(group->seed, p, len); + group->seed_len = len; + + return len; + } + + +unsigned char *EC_GROUP_get0_seed(const EC_GROUP *group) + { + return group->seed; + } + + +size_t EC_GROUP_get_seed_len(const EC_GROUP *group) + { + return group->seed_len; + } + + +int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) + { + if (group->meth->group_set_curve == 0) + { + ECerr(EC_F_EC_GROUP_SET_CURVE_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + return group->meth->group_set_curve(group, p, a, b, ctx); + } + + +int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx) + { + if (group->meth->group_get_curve == 0) + { + ECerr(EC_F_EC_GROUP_GET_CURVE_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + return group->meth->group_get_curve(group, p, a, b, ctx); + } + +#ifndef OPENSSL_NO_EC2M +int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) + { + if (group->meth->group_set_curve == 0) + { + ECerr(EC_F_EC_GROUP_SET_CURVE_GF2M, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + return group->meth->group_set_curve(group, p, a, b, ctx); + } + + +int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx) + { + if (group->meth->group_get_curve == 0) + { + ECerr(EC_F_EC_GROUP_GET_CURVE_GF2M, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + return group->meth->group_get_curve(group, p, a, b, ctx); + } +#endif + +int EC_GROUP_get_degree(const EC_GROUP *group) + { + if (group->meth->group_get_degree == 0) + { + ECerr(EC_F_EC_GROUP_GET_DEGREE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + return group->meth->group_get_degree(group); + } + + +int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx) + { + if (group->meth->group_check_discriminant == 0) + { + ECerr(EC_F_EC_GROUP_CHECK_DISCRIMINANT, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + return group->meth->group_check_discriminant(group, ctx); + } + + +int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx) + { + int r = 0; + BIGNUM *a1, *a2, *a3, *b1, *b2, *b3; + BN_CTX *ctx_new = NULL; + + /* compare the field types*/ + if (EC_METHOD_get_field_type(EC_GROUP_method_of(a)) != + EC_METHOD_get_field_type(EC_GROUP_method_of(b))) + return 1; + /* compare the curve name (if present in both) */ + if (EC_GROUP_get_curve_name(a) && EC_GROUP_get_curve_name(b) && + EC_GROUP_get_curve_name(a) != EC_GROUP_get_curve_name(b)) + return 1; + + if (!ctx) + ctx_new = ctx = BN_CTX_new(); + if (!ctx) + return -1; + + BN_CTX_start(ctx); + a1 = BN_CTX_get(ctx); + a2 = BN_CTX_get(ctx); + a3 = BN_CTX_get(ctx); + b1 = BN_CTX_get(ctx); + b2 = BN_CTX_get(ctx); + b3 = BN_CTX_get(ctx); + if (!b3) + { + BN_CTX_end(ctx); + if (ctx_new) + BN_CTX_free(ctx); + return -1; + } + + /* XXX This approach assumes that the external representation + * of curves over the same field type is the same. + */ + if (!a->meth->group_get_curve(a, a1, a2, a3, ctx) || + !b->meth->group_get_curve(b, b1, b2, b3, ctx)) + r = 1; + + if (r || BN_cmp(a1, b1) || BN_cmp(a2, b2) || BN_cmp(a3, b3)) + r = 1; + + /* XXX EC_POINT_cmp() assumes that the methods are equal */ + if (r || EC_POINT_cmp(a, EC_GROUP_get0_generator(a), + EC_GROUP_get0_generator(b), ctx)) + r = 1; + + if (!r) + { + /* compare the order and cofactor */ + if (!EC_GROUP_get_order(a, a1, ctx) || + !EC_GROUP_get_order(b, b1, ctx) || + !EC_GROUP_get_cofactor(a, a2, ctx) || + !EC_GROUP_get_cofactor(b, b2, ctx)) + { + BN_CTX_end(ctx); + if (ctx_new) + BN_CTX_free(ctx); + return -1; + } + if (BN_cmp(a1, b1) || BN_cmp(a2, b2)) + r = 1; + } + + BN_CTX_end(ctx); + if (ctx_new) + BN_CTX_free(ctx); + + return r; + } + + +/* this has 'package' visibility */ +int EC_EX_DATA_set_data(EC_EXTRA_DATA **ex_data, void *data, + void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)) + { + EC_EXTRA_DATA *d; + + if (ex_data == NULL) + return 0; + + for (d = *ex_data; d != NULL; d = d->next) + { + if (d->dup_func == dup_func && d->free_func == free_func && d->clear_free_func == clear_free_func) + { + ECerr(EC_F_EC_EX_DATA_SET_DATA, EC_R_SLOT_FULL); + return 0; + } + } + + if (data == NULL) + /* no explicit entry needed */ + return 1; + + d = OPENSSL_malloc(sizeof *d); + if (d == NULL) + return 0; + + d->data = data; + d->dup_func = dup_func; + d->free_func = free_func; + d->clear_free_func = clear_free_func; + + d->next = *ex_data; + *ex_data = d; + + return 1; + } + +/* this has 'package' visibility */ +void *EC_EX_DATA_get_data(const EC_EXTRA_DATA *ex_data, + void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)) + { + const EC_EXTRA_DATA *d; + + for (d = ex_data; d != NULL; d = d->next) + { + if (d->dup_func == dup_func && d->free_func == free_func && d->clear_free_func == clear_free_func) + return d->data; + } + + return NULL; + } + +/* this has 'package' visibility */ +void EC_EX_DATA_free_data(EC_EXTRA_DATA **ex_data, + void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)) + { + EC_EXTRA_DATA **p; + + if (ex_data == NULL) + return; + + for (p = ex_data; *p != NULL; p = &((*p)->next)) + { + if ((*p)->dup_func == dup_func && (*p)->free_func == free_func && (*p)->clear_free_func == clear_free_func) + { + EC_EXTRA_DATA *next = (*p)->next; + + (*p)->free_func((*p)->data); + OPENSSL_free(*p); + + *p = next; + return; + } + } + } + +/* this has 'package' visibility */ +void EC_EX_DATA_clear_free_data(EC_EXTRA_DATA **ex_data, + void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)) + { + EC_EXTRA_DATA **p; + + if (ex_data == NULL) + return; + + for (p = ex_data; *p != NULL; p = &((*p)->next)) + { + if ((*p)->dup_func == dup_func && (*p)->free_func == free_func && (*p)->clear_free_func == clear_free_func) + { + EC_EXTRA_DATA *next = (*p)->next; + + (*p)->clear_free_func((*p)->data); + OPENSSL_free(*p); + + *p = next; + return; + } + } + } + +/* this has 'package' visibility */ +void EC_EX_DATA_free_all_data(EC_EXTRA_DATA **ex_data) + { + EC_EXTRA_DATA *d; + + if (ex_data == NULL) + return; + + d = *ex_data; + while (d) + { + EC_EXTRA_DATA *next = d->next; + + d->free_func(d->data); + OPENSSL_free(d); + + d = next; + } + *ex_data = NULL; + } + +/* this has 'package' visibility */ +void EC_EX_DATA_clear_free_all_data(EC_EXTRA_DATA **ex_data) + { + EC_EXTRA_DATA *d; + + if (ex_data == NULL) + return; + + d = *ex_data; + while (d) + { + EC_EXTRA_DATA *next = d->next; + + d->clear_free_func(d->data); + OPENSSL_free(d); + + d = next; + } + *ex_data = NULL; + } + + +/* functions for EC_POINT objects */ + +EC_POINT *EC_POINT_new(const EC_GROUP *group) + { + EC_POINT *ret; + + if (group == NULL) + { + ECerr(EC_F_EC_POINT_NEW, ERR_R_PASSED_NULL_PARAMETER); + return NULL; + } + if (group->meth->point_init == 0) + { + ECerr(EC_F_EC_POINT_NEW, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return NULL; + } + + ret = OPENSSL_malloc(sizeof *ret); + if (ret == NULL) + { + ECerr(EC_F_EC_POINT_NEW, ERR_R_MALLOC_FAILURE); + return NULL; + } + + ret->meth = group->meth; + + if (!ret->meth->point_init(ret)) + { + OPENSSL_free(ret); + return NULL; + } + + return ret; + } + + +void EC_POINT_free(EC_POINT *point) + { + if (!point) return; + + if (point->meth->point_finish != 0) + point->meth->point_finish(point); + OPENSSL_free(point); + } + + +void EC_POINT_clear_free(EC_POINT *point) + { + if (!point) return; + + if (point->meth->point_clear_finish != 0) + point->meth->point_clear_finish(point); + else if (point->meth->point_finish != 0) + point->meth->point_finish(point); + OPENSSL_cleanse(point, sizeof *point); + OPENSSL_free(point); + } + + +int EC_POINT_copy(EC_POINT *dest, const EC_POINT *src) + { + if (dest->meth->point_copy == 0) + { + ECerr(EC_F_EC_POINT_COPY, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + if (dest->meth != src->meth) + { + ECerr(EC_F_EC_POINT_COPY, EC_R_INCOMPATIBLE_OBJECTS); + return 0; + } + if (dest == src) + return 1; + return dest->meth->point_copy(dest, src); + } + + +EC_POINT *EC_POINT_dup(const EC_POINT *a, const EC_GROUP *group) + { + EC_POINT *t; + int r; + + if (a == NULL) return NULL; + + t = EC_POINT_new(group); + if (t == NULL) return(NULL); + r = EC_POINT_copy(t, a); + if (!r) + { + EC_POINT_free(t); + return NULL; + } + else return t; + } + + +const EC_METHOD *EC_POINT_method_of(const EC_POINT *point) + { + return point->meth; + } + + +int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point) + { + if (group->meth->point_set_to_infinity == 0) + { + ECerr(EC_F_EC_POINT_SET_TO_INFINITY, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + if (group->meth != point->meth) + { + ECerr(EC_F_EC_POINT_SET_TO_INFINITY, EC_R_INCOMPATIBLE_OBJECTS); + return 0; + } + return group->meth->point_set_to_infinity(group, point); + } + + +int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *point, + const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx) + { + if (group->meth->point_set_Jprojective_coordinates_GFp == 0) + { + ECerr(EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + if (group->meth != point->meth) + { + ECerr(EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP, EC_R_INCOMPATIBLE_OBJECTS); + return 0; + } + return group->meth->point_set_Jprojective_coordinates_GFp(group, point, x, y, z, ctx); + } + + +int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, const EC_POINT *point, + BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx) + { + if (group->meth->point_get_Jprojective_coordinates_GFp == 0) + { + ECerr(EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + if (group->meth != point->meth) + { + ECerr(EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP, EC_R_INCOMPATIBLE_OBJECTS); + return 0; + } + return group->meth->point_get_Jprojective_coordinates_GFp(group, point, x, y, z, ctx); + } + + +int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *point, + const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx) + { + if (group->meth->point_set_affine_coordinates == 0) + { + ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + if (group->meth != point->meth) + { + ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP, EC_R_INCOMPATIBLE_OBJECTS); + return 0; + } + return group->meth->point_set_affine_coordinates(group, point, x, y, ctx); + } + +#ifndef OPENSSL_NO_EC2M +int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *point, + const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx) + { + if (group->meth->point_set_affine_coordinates == 0) + { + ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + if (group->meth != point->meth) + { + ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M, EC_R_INCOMPATIBLE_OBJECTS); + return 0; + } + return group->meth->point_set_affine_coordinates(group, point, x, y, ctx); + } +#endif + +int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, const EC_POINT *point, + BIGNUM *x, BIGNUM *y, BN_CTX *ctx) + { + if (group->meth->point_get_affine_coordinates == 0) + { + ECerr(EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + if (group->meth != point->meth) + { + ECerr(EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP, EC_R_INCOMPATIBLE_OBJECTS); + return 0; + } + return group->meth->point_get_affine_coordinates(group, point, x, y, ctx); + } + +#ifndef OPENSSL_NO_EC2M +int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, const EC_POINT *point, + BIGNUM *x, BIGNUM *y, BN_CTX *ctx) + { + if (group->meth->point_get_affine_coordinates == 0) + { + ECerr(EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + if (group->meth != point->meth) + { + ECerr(EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M, EC_R_INCOMPATIBLE_OBJECTS); + return 0; + } + return group->meth->point_get_affine_coordinates(group, point, x, y, ctx); + } +#endif + +int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx) + { + if (group->meth->add == 0) + { + ECerr(EC_F_EC_POINT_ADD, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + if ((group->meth != r->meth) || (r->meth != a->meth) || (a->meth != b->meth)) + { + ECerr(EC_F_EC_POINT_ADD, EC_R_INCOMPATIBLE_OBJECTS); + return 0; + } + return group->meth->add(group, r, a, b, ctx); + } + + +int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx) + { + if (group->meth->dbl == 0) + { + ECerr(EC_F_EC_POINT_DBL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + if ((group->meth != r->meth) || (r->meth != a->meth)) + { + ECerr(EC_F_EC_POINT_DBL, EC_R_INCOMPATIBLE_OBJECTS); + return 0; + } + return group->meth->dbl(group, r, a, ctx); + } + + +int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx) + { + if (group->meth->dbl == 0) + { + ECerr(EC_F_EC_POINT_INVERT, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + if (group->meth != a->meth) + { + ECerr(EC_F_EC_POINT_INVERT, EC_R_INCOMPATIBLE_OBJECTS); + return 0; + } + return group->meth->invert(group, a, ctx); + } + + +int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *point) + { + if (group->meth->is_at_infinity == 0) + { + ECerr(EC_F_EC_POINT_IS_AT_INFINITY, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + if (group->meth != point->meth) + { + ECerr(EC_F_EC_POINT_IS_AT_INFINITY, EC_R_INCOMPATIBLE_OBJECTS); + return 0; + } + return group->meth->is_at_infinity(group, point); + } + + +int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx) + { + if (group->meth->is_on_curve == 0) + { + ECerr(EC_F_EC_POINT_IS_ON_CURVE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + if (group->meth != point->meth) + { + ECerr(EC_F_EC_POINT_IS_ON_CURVE, EC_R_INCOMPATIBLE_OBJECTS); + return 0; + } + return group->meth->is_on_curve(group, point, ctx); + } + + +int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx) + { + if (group->meth->point_cmp == 0) + { + ECerr(EC_F_EC_POINT_CMP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return -1; + } + if ((group->meth != a->meth) || (a->meth != b->meth)) + { + ECerr(EC_F_EC_POINT_CMP, EC_R_INCOMPATIBLE_OBJECTS); + return -1; + } + return group->meth->point_cmp(group, a, b, ctx); + } + + +int EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx) + { + if (group->meth->make_affine == 0) + { + ECerr(EC_F_EC_POINT_MAKE_AFFINE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + if (group->meth != point->meth) + { + ECerr(EC_F_EC_POINT_MAKE_AFFINE, EC_R_INCOMPATIBLE_OBJECTS); + return 0; + } + return group->meth->make_affine(group, point, ctx); + } + + +int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx) + { + size_t i; + + if (group->meth->points_make_affine == 0) + { + ECerr(EC_F_EC_POINTS_MAKE_AFFINE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + for (i = 0; i < num; i++) + { + if (group->meth != points[i]->meth) + { + ECerr(EC_F_EC_POINTS_MAKE_AFFINE, EC_R_INCOMPATIBLE_OBJECTS); + return 0; + } + } + return group->meth->points_make_affine(group, num, points, ctx); + } + + +/* Functions for point multiplication. + * + * If group->meth->mul is 0, we use the wNAF-based implementations in ec_mult.c; + * otherwise we dispatch through methods. + */ + +int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, + size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx) + { + if (group->meth->mul == 0) + /* use default */ + return ec_wNAF_mul(group, r, scalar, num, points, scalars, ctx); + + return group->meth->mul(group, r, scalar, num, points, scalars, ctx); + } + +int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *g_scalar, + const EC_POINT *point, const BIGNUM *p_scalar, BN_CTX *ctx) + { + /* just a convenient interface to EC_POINTs_mul() */ + + const EC_POINT *points[1]; + const BIGNUM *scalars[1]; + + points[0] = point; + scalars[0] = p_scalar; + + return EC_POINTs_mul(group, r, g_scalar, (point != NULL && p_scalar != NULL), points, scalars, ctx); + } + +int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx) + { + if (group->meth->mul == 0) + /* use default */ + return ec_wNAF_precompute_mult(group, ctx); + + if (group->meth->precompute_mult != 0) + return group->meth->precompute_mult(group, ctx); + else + return 1; /* nothing to do, so report success */ + } + +int EC_GROUP_have_precompute_mult(const EC_GROUP *group) + { + if (group->meth->mul == 0) + /* use default */ + return ec_wNAF_have_precompute_mult(group); + + if (group->meth->have_precompute_mult != 0) + return group->meth->have_precompute_mult(group); + else + return 0; /* cannot tell whether precomputation has been performed */ + } diff --git a/libs/openssl/crypto/ec/ec_mult.c b/libs/openssl/crypto/ec/ec_mult.c new file mode 100644 index 00000000..19f21675 --- /dev/null +++ b/libs/openssl/crypto/ec/ec_mult.c @@ -0,0 +1,940 @@ +/* crypto/ec/ec_mult.c */ +/* + * Originally written by Bodo Moeller and Nils Larsch for the OpenSSL project. + */ +/* ==================================================================== + * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * Portions of this software developed by SUN MICROSYSTEMS, INC., + * and contributed to the OpenSSL project. + */ + +#include + +#include + +#include "ec_lcl.h" + + +/* + * This file implements the wNAF-based interleaving multi-exponentation method + * (); + * for multiplication with precomputation, we use wNAF splitting + * (). + */ + + + + +/* structure for precomputed multiples of the generator */ +typedef struct ec_pre_comp_st { + const EC_GROUP *group; /* parent EC_GROUP object */ + size_t blocksize; /* block size for wNAF splitting */ + size_t numblocks; /* max. number of blocks for which we have precomputation */ + size_t w; /* window size */ + EC_POINT **points; /* array with pre-calculated multiples of generator: + * 'num' pointers to EC_POINT objects followed by a NULL */ + size_t num; /* numblocks * 2^(w-1) */ + int references; +} EC_PRE_COMP; + +/* functions to manage EC_PRE_COMP within the EC_GROUP extra_data framework */ +static void *ec_pre_comp_dup(void *); +static void ec_pre_comp_free(void *); +static void ec_pre_comp_clear_free(void *); + +static EC_PRE_COMP *ec_pre_comp_new(const EC_GROUP *group) + { + EC_PRE_COMP *ret = NULL; + + if (!group) + return NULL; + + ret = (EC_PRE_COMP *)OPENSSL_malloc(sizeof(EC_PRE_COMP)); + if (!ret) + { + ECerr(EC_F_EC_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE); + return ret; + } + ret->group = group; + ret->blocksize = 8; /* default */ + ret->numblocks = 0; + ret->w = 4; /* default */ + ret->points = NULL; + ret->num = 0; + ret->references = 1; + return ret; + } + +static void *ec_pre_comp_dup(void *src_) + { + EC_PRE_COMP *src = src_; + + /* no need to actually copy, these objects never change! */ + + CRYPTO_add(&src->references, 1, CRYPTO_LOCK_EC_PRE_COMP); + + return src_; + } + +static void ec_pre_comp_free(void *pre_) + { + int i; + EC_PRE_COMP *pre = pre_; + + if (!pre) + return; + + i = CRYPTO_add(&pre->references, -1, CRYPTO_LOCK_EC_PRE_COMP); + if (i > 0) + return; + + if (pre->points) + { + EC_POINT **p; + + for (p = pre->points; *p != NULL; p++) + EC_POINT_free(*p); + OPENSSL_free(pre->points); + } + OPENSSL_free(pre); + } + +static void ec_pre_comp_clear_free(void *pre_) + { + int i; + EC_PRE_COMP *pre = pre_; + + if (!pre) + return; + + i = CRYPTO_add(&pre->references, -1, CRYPTO_LOCK_EC_PRE_COMP); + if (i > 0) + return; + + if (pre->points) + { + EC_POINT **p; + + for (p = pre->points; *p != NULL; p++) + { + EC_POINT_clear_free(*p); + OPENSSL_cleanse(p, sizeof *p); + } + OPENSSL_free(pre->points); + } + OPENSSL_cleanse(pre, sizeof *pre); + OPENSSL_free(pre); + } + + + + +/* Determine the modified width-(w+1) Non-Adjacent Form (wNAF) of 'scalar'. + * This is an array r[] of values that are either zero or odd with an + * absolute value less than 2^w satisfying + * scalar = \sum_j r[j]*2^j + * where at most one of any w+1 consecutive digits is non-zero + * with the exception that the most significant digit may be only + * w-1 zeros away from that next non-zero digit. + */ +static signed char *compute_wNAF(const BIGNUM *scalar, int w, size_t *ret_len) + { + int window_val; + int ok = 0; + signed char *r = NULL; + int sign = 1; + int bit, next_bit, mask; + size_t len = 0, j; + + if (BN_is_zero(scalar)) + { + r = OPENSSL_malloc(1); + if (!r) + { + ECerr(EC_F_COMPUTE_WNAF, ERR_R_MALLOC_FAILURE); + goto err; + } + r[0] = 0; + *ret_len = 1; + return r; + } + + if (w <= 0 || w > 7) /* 'signed char' can represent integers with absolute values less than 2^7 */ + { + ECerr(EC_F_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR); + goto err; + } + bit = 1 << w; /* at most 128 */ + next_bit = bit << 1; /* at most 256 */ + mask = next_bit - 1; /* at most 255 */ + + if (BN_is_negative(scalar)) + { + sign = -1; + } + + if (scalar->d == NULL || scalar->top == 0) + { + ECerr(EC_F_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR); + goto err; + } + + len = BN_num_bits(scalar); + r = OPENSSL_malloc(len + 1); /* modified wNAF may be one digit longer than binary representation + * (*ret_len will be set to the actual length, i.e. at most + * BN_num_bits(scalar) + 1) */ + if (r == NULL) + { + ECerr(EC_F_COMPUTE_WNAF, ERR_R_MALLOC_FAILURE); + goto err; + } + window_val = scalar->d[0] & mask; + j = 0; + while ((window_val != 0) || (j + w + 1 < len)) /* if j+w+1 >= len, window_val will not increase */ + { + int digit = 0; + + /* 0 <= window_val <= 2^(w+1) */ + + if (window_val & 1) + { + /* 0 < window_val < 2^(w+1) */ + + if (window_val & bit) + { + digit = window_val - next_bit; /* -2^w < digit < 0 */ + +#if 1 /* modified wNAF */ + if (j + w + 1 >= len) + { + /* special case for generating modified wNAFs: + * no new bits will be added into window_val, + * so using a positive digit here will decrease + * the total length of the representation */ + + digit = window_val & (mask >> 1); /* 0 < digit < 2^w */ + } +#endif + } + else + { + digit = window_val; /* 0 < digit < 2^w */ + } + + if (digit <= -bit || digit >= bit || !(digit & 1)) + { + ECerr(EC_F_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR); + goto err; + } + + window_val -= digit; + + /* now window_val is 0 or 2^(w+1) in standard wNAF generation; + * for modified window NAFs, it may also be 2^w + */ + if (window_val != 0 && window_val != next_bit && window_val != bit) + { + ECerr(EC_F_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR); + goto err; + } + } + + r[j++] = sign * digit; + + window_val >>= 1; + window_val += bit * BN_is_bit_set(scalar, j + w); + + if (window_val > next_bit) + { + ECerr(EC_F_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR); + goto err; + } + } + + if (j > len + 1) + { + ECerr(EC_F_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR); + goto err; + } + len = j; + ok = 1; + + err: + if (!ok) + { + OPENSSL_free(r); + r = NULL; + } + if (ok) + *ret_len = len; + return r; + } + + +/* TODO: table should be optimised for the wNAF-based implementation, + * sometimes smaller windows will give better performance + * (thus the boundaries should be increased) + */ +#define EC_window_bits_for_scalar_size(b) \ + ((size_t) \ + ((b) >= 2000 ? 6 : \ + (b) >= 800 ? 5 : \ + (b) >= 300 ? 4 : \ + (b) >= 70 ? 3 : \ + (b) >= 20 ? 2 : \ + 1)) + +/* Compute + * \sum scalars[i]*points[i], + * also including + * scalar*generator + * in the addition if scalar != NULL + */ +int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, + size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx) + { + BN_CTX *new_ctx = NULL; + const EC_POINT *generator = NULL; + EC_POINT *tmp = NULL; + size_t totalnum; + size_t blocksize = 0, numblocks = 0; /* for wNAF splitting */ + size_t pre_points_per_block = 0; + size_t i, j; + int k; + int r_is_inverted = 0; + int r_is_at_infinity = 1; + size_t *wsize = NULL; /* individual window sizes */ + signed char **wNAF = NULL; /* individual wNAFs */ + size_t *wNAF_len = NULL; + size_t max_len = 0; + size_t num_val; + EC_POINT **val = NULL; /* precomputation */ + EC_POINT **v; + EC_POINT ***val_sub = NULL; /* pointers to sub-arrays of 'val' or 'pre_comp->points' */ + const EC_PRE_COMP *pre_comp = NULL; + int num_scalar = 0; /* flag: will be set to 1 if 'scalar' must be treated like other scalars, + * i.e. precomputation is not available */ + int ret = 0; + + if (group->meth != r->meth) + { + ECerr(EC_F_EC_WNAF_MUL, EC_R_INCOMPATIBLE_OBJECTS); + return 0; + } + + if ((scalar == NULL) && (num == 0)) + { + return EC_POINT_set_to_infinity(group, r); + } + + for (i = 0; i < num; i++) + { + if (group->meth != points[i]->meth) + { + ECerr(EC_F_EC_WNAF_MUL, EC_R_INCOMPATIBLE_OBJECTS); + return 0; + } + } + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + goto err; + } + + if (scalar != NULL) + { + generator = EC_GROUP_get0_generator(group); + if (generator == NULL) + { + ECerr(EC_F_EC_WNAF_MUL, EC_R_UNDEFINED_GENERATOR); + goto err; + } + + /* look if we can use precomputed multiples of generator */ + + pre_comp = EC_EX_DATA_get_data(group->extra_data, ec_pre_comp_dup, ec_pre_comp_free, ec_pre_comp_clear_free); + + if (pre_comp && pre_comp->numblocks && (EC_POINT_cmp(group, generator, pre_comp->points[0], ctx) == 0)) + { + blocksize = pre_comp->blocksize; + + /* determine maximum number of blocks that wNAF splitting may yield + * (NB: maximum wNAF length is bit length plus one) */ + numblocks = (BN_num_bits(scalar) / blocksize) + 1; + + /* we cannot use more blocks than we have precomputation for */ + if (numblocks > pre_comp->numblocks) + numblocks = pre_comp->numblocks; + + pre_points_per_block = (size_t)1 << (pre_comp->w - 1); + + /* check that pre_comp looks sane */ + if (pre_comp->num != (pre_comp->numblocks * pre_points_per_block)) + { + ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR); + goto err; + } + } + else + { + /* can't use precomputation */ + pre_comp = NULL; + numblocks = 1; + num_scalar = 1; /* treat 'scalar' like 'num'-th element of 'scalars' */ + } + } + + totalnum = num + numblocks; + + wsize = OPENSSL_malloc(totalnum * sizeof wsize[0]); + wNAF_len = OPENSSL_malloc(totalnum * sizeof wNAF_len[0]); + wNAF = OPENSSL_malloc((totalnum + 1) * sizeof wNAF[0]); /* includes space for pivot */ + val_sub = OPENSSL_malloc(totalnum * sizeof val_sub[0]); + + if (!wsize || !wNAF_len || !wNAF || !val_sub) + { + ECerr(EC_F_EC_WNAF_MUL, ERR_R_MALLOC_FAILURE); + goto err; + } + + wNAF[0] = NULL; /* preliminary pivot */ + + /* num_val will be the total number of temporarily precomputed points */ + num_val = 0; + + for (i = 0; i < num + num_scalar; i++) + { + size_t bits; + + bits = i < num ? BN_num_bits(scalars[i]) : BN_num_bits(scalar); + wsize[i] = EC_window_bits_for_scalar_size(bits); + num_val += (size_t)1 << (wsize[i] - 1); + wNAF[i + 1] = NULL; /* make sure we always have a pivot */ + wNAF[i] = compute_wNAF((i < num ? scalars[i] : scalar), wsize[i], &wNAF_len[i]); + if (wNAF[i] == NULL) + goto err; + if (wNAF_len[i] > max_len) + max_len = wNAF_len[i]; + } + + if (numblocks) + { + /* we go here iff scalar != NULL */ + + if (pre_comp == NULL) + { + if (num_scalar != 1) + { + ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR); + goto err; + } + /* we have already generated a wNAF for 'scalar' */ + } + else + { + signed char *tmp_wNAF = NULL; + size_t tmp_len = 0; + + if (num_scalar != 0) + { + ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR); + goto err; + } + + /* use the window size for which we have precomputation */ + wsize[num] = pre_comp->w; + tmp_wNAF = compute_wNAF(scalar, wsize[num], &tmp_len); + if (!tmp_wNAF) + goto err; + + if (tmp_len <= max_len) + { + /* One of the other wNAFs is at least as long + * as the wNAF belonging to the generator, + * so wNAF splitting will not buy us anything. */ + + numblocks = 1; + totalnum = num + 1; /* don't use wNAF splitting */ + wNAF[num] = tmp_wNAF; + wNAF[num + 1] = NULL; + wNAF_len[num] = tmp_len; + if (tmp_len > max_len) + max_len = tmp_len; + /* pre_comp->points starts with the points that we need here: */ + val_sub[num] = pre_comp->points; + } + else + { + /* don't include tmp_wNAF directly into wNAF array + * - use wNAF splitting and include the blocks */ + + signed char *pp; + EC_POINT **tmp_points; + + if (tmp_len < numblocks * blocksize) + { + /* possibly we can do with fewer blocks than estimated */ + numblocks = (tmp_len + blocksize - 1) / blocksize; + if (numblocks > pre_comp->numblocks) + { + ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR); + goto err; + } + totalnum = num + numblocks; + } + + /* split wNAF in 'numblocks' parts */ + pp = tmp_wNAF; + tmp_points = pre_comp->points; + + for (i = num; i < totalnum; i++) + { + if (i < totalnum - 1) + { + wNAF_len[i] = blocksize; + if (tmp_len < blocksize) + { + ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR); + goto err; + } + tmp_len -= blocksize; + } + else + /* last block gets whatever is left + * (this could be more or less than 'blocksize'!) */ + wNAF_len[i] = tmp_len; + + wNAF[i + 1] = NULL; + wNAF[i] = OPENSSL_malloc(wNAF_len[i]); + if (wNAF[i] == NULL) + { + ECerr(EC_F_EC_WNAF_MUL, ERR_R_MALLOC_FAILURE); + OPENSSL_free(tmp_wNAF); + goto err; + } + memcpy(wNAF[i], pp, wNAF_len[i]); + if (wNAF_len[i] > max_len) + max_len = wNAF_len[i]; + + if (*tmp_points == NULL) + { + ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR); + OPENSSL_free(tmp_wNAF); + goto err; + } + val_sub[i] = tmp_points; + tmp_points += pre_points_per_block; + pp += blocksize; + } + OPENSSL_free(tmp_wNAF); + } + } + } + + /* All points we precompute now go into a single array 'val'. + * 'val_sub[i]' is a pointer to the subarray for the i-th point, + * or to a subarray of 'pre_comp->points' if we already have precomputation. */ + val = OPENSSL_malloc((num_val + 1) * sizeof val[0]); + if (val == NULL) + { + ECerr(EC_F_EC_WNAF_MUL, ERR_R_MALLOC_FAILURE); + goto err; + } + val[num_val] = NULL; /* pivot element */ + + /* allocate points for precomputation */ + v = val; + for (i = 0; i < num + num_scalar; i++) + { + val_sub[i] = v; + for (j = 0; j < ((size_t)1 << (wsize[i] - 1)); j++) + { + *v = EC_POINT_new(group); + if (*v == NULL) goto err; + v++; + } + } + if (!(v == val + num_val)) + { + ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR); + goto err; + } + + if (!(tmp = EC_POINT_new(group))) + goto err; + + /* prepare precomputed values: + * val_sub[i][0] := points[i] + * val_sub[i][1] := 3 * points[i] + * val_sub[i][2] := 5 * points[i] + * ... + */ + for (i = 0; i < num + num_scalar; i++) + { + if (i < num) + { + if (!EC_POINT_copy(val_sub[i][0], points[i])) goto err; + } + else + { + if (!EC_POINT_copy(val_sub[i][0], generator)) goto err; + } + + if (wsize[i] > 1) + { + if (!EC_POINT_dbl(group, tmp, val_sub[i][0], ctx)) goto err; + for (j = 1; j < ((size_t)1 << (wsize[i] - 1)); j++) + { + if (!EC_POINT_add(group, val_sub[i][j], val_sub[i][j - 1], tmp, ctx)) goto err; + } + } + } + +#if 1 /* optional; EC_window_bits_for_scalar_size assumes we do this step */ + if (!EC_POINTs_make_affine(group, num_val, val, ctx)) + goto err; +#endif + + r_is_at_infinity = 1; + + for (k = max_len - 1; k >= 0; k--) + { + if (!r_is_at_infinity) + { + if (!EC_POINT_dbl(group, r, r, ctx)) goto err; + } + + for (i = 0; i < totalnum; i++) + { + if (wNAF_len[i] > (size_t)k) + { + int digit = wNAF[i][k]; + int is_neg; + + if (digit) + { + is_neg = digit < 0; + + if (is_neg) + digit = -digit; + + if (is_neg != r_is_inverted) + { + if (!r_is_at_infinity) + { + if (!EC_POINT_invert(group, r, ctx)) goto err; + } + r_is_inverted = !r_is_inverted; + } + + /* digit > 0 */ + + if (r_is_at_infinity) + { + if (!EC_POINT_copy(r, val_sub[i][digit >> 1])) goto err; + r_is_at_infinity = 0; + } + else + { + if (!EC_POINT_add(group, r, r, val_sub[i][digit >> 1], ctx)) goto err; + } + } + } + } + } + + if (r_is_at_infinity) + { + if (!EC_POINT_set_to_infinity(group, r)) goto err; + } + else + { + if (r_is_inverted) + if (!EC_POINT_invert(group, r, ctx)) goto err; + } + + ret = 1; + + err: + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + if (tmp != NULL) + EC_POINT_free(tmp); + if (wsize != NULL) + OPENSSL_free(wsize); + if (wNAF_len != NULL) + OPENSSL_free(wNAF_len); + if (wNAF != NULL) + { + signed char **w; + + for (w = wNAF; *w != NULL; w++) + OPENSSL_free(*w); + + OPENSSL_free(wNAF); + } + if (val != NULL) + { + for (v = val; *v != NULL; v++) + EC_POINT_clear_free(*v); + + OPENSSL_free(val); + } + if (val_sub != NULL) + { + OPENSSL_free(val_sub); + } + return ret; + } + + +/* ec_wNAF_precompute_mult() + * creates an EC_PRE_COMP object with preprecomputed multiples of the generator + * for use with wNAF splitting as implemented in ec_wNAF_mul(). + * + * 'pre_comp->points' is an array of multiples of the generator + * of the following form: + * points[0] = generator; + * points[1] = 3 * generator; + * ... + * points[2^(w-1)-1] = (2^(w-1)-1) * generator; + * points[2^(w-1)] = 2^blocksize * generator; + * points[2^(w-1)+1] = 3 * 2^blocksize * generator; + * ... + * points[2^(w-1)*(numblocks-1)-1] = (2^(w-1)) * 2^(blocksize*(numblocks-2)) * generator + * points[2^(w-1)*(numblocks-1)] = 2^(blocksize*(numblocks-1)) * generator + * ... + * points[2^(w-1)*numblocks-1] = (2^(w-1)) * 2^(blocksize*(numblocks-1)) * generator + * points[2^(w-1)*numblocks] = NULL + */ +int ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *ctx) + { + const EC_POINT *generator; + EC_POINT *tmp_point = NULL, *base = NULL, **var; + BN_CTX *new_ctx = NULL; + BIGNUM *order; + size_t i, bits, w, pre_points_per_block, blocksize, numblocks, num; + EC_POINT **points = NULL; + EC_PRE_COMP *pre_comp; + int ret = 0; + + /* if there is an old EC_PRE_COMP object, throw it away */ + EC_EX_DATA_free_data(&group->extra_data, ec_pre_comp_dup, ec_pre_comp_free, ec_pre_comp_clear_free); + + if ((pre_comp = ec_pre_comp_new(group)) == NULL) + return 0; + + generator = EC_GROUP_get0_generator(group); + if (generator == NULL) + { + ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, EC_R_UNDEFINED_GENERATOR); + goto err; + } + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + goto err; + } + + BN_CTX_start(ctx); + order = BN_CTX_get(ctx); + if (order == NULL) goto err; + + if (!EC_GROUP_get_order(group, order, ctx)) goto err; + if (BN_is_zero(order)) + { + ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, EC_R_UNKNOWN_ORDER); + goto err; + } + + bits = BN_num_bits(order); + /* The following parameters mean we precompute (approximately) + * one point per bit. + * + * TBD: The combination 8, 4 is perfect for 160 bits; for other + * bit lengths, other parameter combinations might provide better + * efficiency. + */ + blocksize = 8; + w = 4; + if (EC_window_bits_for_scalar_size(bits) > w) + { + /* let's not make the window too small ... */ + w = EC_window_bits_for_scalar_size(bits); + } + + numblocks = (bits + blocksize - 1) / blocksize; /* max. number of blocks to use for wNAF splitting */ + + pre_points_per_block = (size_t)1 << (w - 1); + num = pre_points_per_block * numblocks; /* number of points to compute and store */ + + points = OPENSSL_malloc(sizeof (EC_POINT*)*(num + 1)); + if (!points) + { + ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_MALLOC_FAILURE); + goto err; + } + + var = points; + var[num] = NULL; /* pivot */ + for (i = 0; i < num; i++) + { + if ((var[i] = EC_POINT_new(group)) == NULL) + { + ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_MALLOC_FAILURE); + goto err; + } + } + + if (!(tmp_point = EC_POINT_new(group)) || !(base = EC_POINT_new(group))) + { + ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_MALLOC_FAILURE); + goto err; + } + + if (!EC_POINT_copy(base, generator)) + goto err; + + /* do the precomputation */ + for (i = 0; i < numblocks; i++) + { + size_t j; + + if (!EC_POINT_dbl(group, tmp_point, base, ctx)) + goto err; + + if (!EC_POINT_copy(*var++, base)) + goto err; + + for (j = 1; j < pre_points_per_block; j++, var++) + { + /* calculate odd multiples of the current base point */ + if (!EC_POINT_add(group, *var, tmp_point, *(var - 1), ctx)) + goto err; + } + + if (i < numblocks - 1) + { + /* get the next base (multiply current one by 2^blocksize) */ + size_t k; + + if (blocksize <= 2) + { + ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_INTERNAL_ERROR); + goto err; + } + + if (!EC_POINT_dbl(group, base, tmp_point, ctx)) + goto err; + for (k = 2; k < blocksize; k++) + { + if (!EC_POINT_dbl(group,base,base,ctx)) + goto err; + } + } + } + + if (!EC_POINTs_make_affine(group, num, points, ctx)) + goto err; + + pre_comp->group = group; + pre_comp->blocksize = blocksize; + pre_comp->numblocks = numblocks; + pre_comp->w = w; + pre_comp->points = points; + points = NULL; + pre_comp->num = num; + + if (!EC_EX_DATA_set_data(&group->extra_data, pre_comp, + ec_pre_comp_dup, ec_pre_comp_free, ec_pre_comp_clear_free)) + goto err; + pre_comp = NULL; + + ret = 1; + err: + if (ctx != NULL) + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + if (pre_comp) + ec_pre_comp_free(pre_comp); + if (points) + { + EC_POINT **p; + + for (p = points; *p != NULL; p++) + EC_POINT_free(*p); + OPENSSL_free(points); + } + if (tmp_point) + EC_POINT_free(tmp_point); + if (base) + EC_POINT_free(base); + return ret; + } + + +int ec_wNAF_have_precompute_mult(const EC_GROUP *group) + { + if (EC_EX_DATA_get_data(group->extra_data, ec_pre_comp_dup, ec_pre_comp_free, ec_pre_comp_clear_free) != NULL) + return 1; + else + return 0; + } diff --git a/libs/openssl/crypto/ec/ec_oct.c b/libs/openssl/crypto/ec/ec_oct.c new file mode 100644 index 00000000..fd9db079 --- /dev/null +++ b/libs/openssl/crypto/ec/ec_oct.c @@ -0,0 +1,199 @@ +/* crypto/ec/ec_lib.c */ +/* + * Originally written by Bodo Moeller for the OpenSSL project. + */ +/* ==================================================================== + * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * Binary polynomial ECC support in OpenSSL originally developed by + * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. + */ + +#include + +#include +#include + +#include "ec_lcl.h" + +int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *point, + const BIGNUM *x, int y_bit, BN_CTX *ctx) + { + if (group->meth->point_set_compressed_coordinates == 0 + && !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) + { + ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + if (group->meth != point->meth) + { + ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP, EC_R_INCOMPATIBLE_OBJECTS); + return 0; + } + if(group->meth->flags & EC_FLAGS_DEFAULT_OCT) + { + if (group->meth->field_type == NID_X9_62_prime_field) + return ec_GFp_simple_set_compressed_coordinates( + group, point, x, y_bit, ctx); + else +#ifdef OPENSSL_NO_EC2M + { + ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP, EC_R_GF2M_NOT_SUPPORTED); + return 0; + } +#else + return ec_GF2m_simple_set_compressed_coordinates( + group, point, x, y_bit, ctx); +#endif + } + return group->meth->point_set_compressed_coordinates(group, point, x, y_bit, ctx); + } + +#ifndef OPENSSL_NO_EC2M +int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *point, + const BIGNUM *x, int y_bit, BN_CTX *ctx) + { + if (group->meth->point_set_compressed_coordinates == 0 + && !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) + { + ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + if (group->meth != point->meth) + { + ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M, EC_R_INCOMPATIBLE_OBJECTS); + return 0; + } + if(group->meth->flags & EC_FLAGS_DEFAULT_OCT) + { + if (group->meth->field_type == NID_X9_62_prime_field) + return ec_GFp_simple_set_compressed_coordinates( + group, point, x, y_bit, ctx); + else + return ec_GF2m_simple_set_compressed_coordinates( + group, point, x, y_bit, ctx); + } + return group->meth->point_set_compressed_coordinates(group, point, x, y_bit, ctx); + } +#endif + +size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form, + unsigned char *buf, size_t len, BN_CTX *ctx) + { + if (group->meth->point2oct == 0 + && !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) + { + ECerr(EC_F_EC_POINT_POINT2OCT, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + if (group->meth != point->meth) + { + ECerr(EC_F_EC_POINT_POINT2OCT, EC_R_INCOMPATIBLE_OBJECTS); + return 0; + } + if(group->meth->flags & EC_FLAGS_DEFAULT_OCT) + { + if (group->meth->field_type == NID_X9_62_prime_field) + return ec_GFp_simple_point2oct(group, point, + form, buf, len, ctx); + else +#ifdef OPENSSL_NO_EC2M + { + ECerr(EC_F_EC_POINT_POINT2OCT, EC_R_GF2M_NOT_SUPPORTED); + return 0; + } +#else + return ec_GF2m_simple_point2oct(group, point, + form, buf, len, ctx); +#endif + } + + return group->meth->point2oct(group, point, form, buf, len, ctx); + } + + +int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *point, + const unsigned char *buf, size_t len, BN_CTX *ctx) + { + if (group->meth->oct2point == 0 + && !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) + { + ECerr(EC_F_EC_POINT_OCT2POINT, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + if (group->meth != point->meth) + { + ECerr(EC_F_EC_POINT_OCT2POINT, EC_R_INCOMPATIBLE_OBJECTS); + return 0; + } + if(group->meth->flags & EC_FLAGS_DEFAULT_OCT) + { + if (group->meth->field_type == NID_X9_62_prime_field) + return ec_GFp_simple_oct2point(group, point, + buf, len, ctx); + else +#ifdef OPENSSL_NO_EC2M + { + ECerr(EC_F_EC_POINT_OCT2POINT, EC_R_GF2M_NOT_SUPPORTED); + return 0; + } +#else + return ec_GF2m_simple_oct2point(group, point, + buf, len, ctx); +#endif + } + return group->meth->oct2point(group, point, buf, len, ctx); + } + diff --git a/libs/openssl/crypto/ec/ec_pmeth.c b/libs/openssl/crypto/ec/ec_pmeth.c new file mode 100644 index 00000000..66ee397d --- /dev/null +++ b/libs/openssl/crypto/ec/ec_pmeth.c @@ -0,0 +1,341 @@ +/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL + * project 2006. + */ +/* ==================================================================== + * Copyright (c) 2006 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include +#include "cryptlib.h" +#include +#include +#include +#include +#include +#include "evp_locl.h" + +/* EC pkey context structure */ + +typedef struct + { + /* Key and paramgen group */ + EC_GROUP *gen_group; + /* message digest */ + const EVP_MD *md; + } EC_PKEY_CTX; + +static int pkey_ec_init(EVP_PKEY_CTX *ctx) + { + EC_PKEY_CTX *dctx; + dctx = OPENSSL_malloc(sizeof(EC_PKEY_CTX)); + if (!dctx) + return 0; + dctx->gen_group = NULL; + dctx->md = NULL; + + ctx->data = dctx; + + return 1; + } + +static int pkey_ec_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src) + { + EC_PKEY_CTX *dctx, *sctx; + if (!pkey_ec_init(dst)) + return 0; + sctx = src->data; + dctx = dst->data; + if (sctx->gen_group) + { + dctx->gen_group = EC_GROUP_dup(sctx->gen_group); + if (!dctx->gen_group) + return 0; + } + dctx->md = sctx->md; + return 1; + } + +static void pkey_ec_cleanup(EVP_PKEY_CTX *ctx) + { + EC_PKEY_CTX *dctx = ctx->data; + if (dctx) + { + if (dctx->gen_group) + EC_GROUP_free(dctx->gen_group); + OPENSSL_free(dctx); + } + } + +static int pkey_ec_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, + const unsigned char *tbs, size_t tbslen) + { + int ret, type; + unsigned int sltmp; + EC_PKEY_CTX *dctx = ctx->data; + EC_KEY *ec = ctx->pkey->pkey.ec; + + if (!sig) + { + *siglen = ECDSA_size(ec); + return 1; + } + else if(*siglen < (size_t)ECDSA_size(ec)) + { + ECerr(EC_F_PKEY_EC_SIGN, EC_R_BUFFER_TOO_SMALL); + return 0; + } + + if (dctx->md) + type = EVP_MD_type(dctx->md); + else + type = NID_sha1; + + + ret = ECDSA_sign(type, tbs, tbslen, sig, &sltmp, ec); + + if (ret <= 0) + return ret; + *siglen = (size_t)sltmp; + return 1; + } + +static int pkey_ec_verify(EVP_PKEY_CTX *ctx, + const unsigned char *sig, size_t siglen, + const unsigned char *tbs, size_t tbslen) + { + int ret, type; + EC_PKEY_CTX *dctx = ctx->data; + EC_KEY *ec = ctx->pkey->pkey.ec; + + if (dctx->md) + type = EVP_MD_type(dctx->md); + else + type = NID_sha1; + + ret = ECDSA_verify(type, tbs, tbslen, sig, siglen, ec); + + return ret; + } + +static int pkey_ec_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen) + { + int ret; + size_t outlen; + const EC_POINT *pubkey = NULL; + if (!ctx->pkey || !ctx->peerkey) + { + ECerr(EC_F_PKEY_EC_DERIVE, EC_R_KEYS_NOT_SET); + return 0; + } + + if (!key) + { + const EC_GROUP *group; + group = EC_KEY_get0_group(ctx->pkey->pkey.ec); + *keylen = (EC_GROUP_get_degree(group) + 7)/8; + return 1; + } + + pubkey = EC_KEY_get0_public_key(ctx->peerkey->pkey.ec); + + /* NB: unlike PKCS#3 DH, if *outlen is less than maximum size this is + * not an error, the result is truncated. + */ + + outlen = *keylen; + + ret = ECDH_compute_key(key, outlen, pubkey, ctx->pkey->pkey.ec, 0); + if (ret < 0) + return ret; + *keylen = ret; + return 1; + } + +static int pkey_ec_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) + { + EC_PKEY_CTX *dctx = ctx->data; + EC_GROUP *group; + switch (type) + { + case EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID: + group = EC_GROUP_new_by_curve_name(p1); + if (group == NULL) + { + ECerr(EC_F_PKEY_EC_CTRL, EC_R_INVALID_CURVE); + return 0; + } + if (dctx->gen_group) + EC_GROUP_free(dctx->gen_group); + dctx->gen_group = group; + return 1; + + case EVP_PKEY_CTRL_MD: + if (EVP_MD_type((const EVP_MD *)p2) != NID_sha1 && + EVP_MD_type((const EVP_MD *)p2) != NID_ecdsa_with_SHA1 && + EVP_MD_type((const EVP_MD *)p2) != NID_sha224 && + EVP_MD_type((const EVP_MD *)p2) != NID_sha256 && + EVP_MD_type((const EVP_MD *)p2) != NID_sha384 && + EVP_MD_type((const EVP_MD *)p2) != NID_sha512) + { + ECerr(EC_F_PKEY_EC_CTRL, EC_R_INVALID_DIGEST_TYPE); + return 0; + } + dctx->md = p2; + return 1; + + case EVP_PKEY_CTRL_PEER_KEY: + /* Default behaviour is OK */ + case EVP_PKEY_CTRL_DIGESTINIT: + case EVP_PKEY_CTRL_PKCS7_SIGN: + case EVP_PKEY_CTRL_CMS_SIGN: + return 1; + + default: + return -2; + + } + } + +static int pkey_ec_ctrl_str(EVP_PKEY_CTX *ctx, + const char *type, const char *value) + { + if (!strcmp(type, "ec_paramgen_curve")) + { + int nid; + nid = OBJ_sn2nid(value); + if (nid == NID_undef) + nid = OBJ_ln2nid(value); + if (nid == NID_undef) + { + ECerr(EC_F_PKEY_EC_CTRL_STR, EC_R_INVALID_CURVE); + return 0; + } + return EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid); + } + return -2; + } + +static int pkey_ec_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) + { + EC_KEY *ec = NULL; + EC_PKEY_CTX *dctx = ctx->data; + int ret = 0; + if (dctx->gen_group == NULL) + { + ECerr(EC_F_PKEY_EC_PARAMGEN, EC_R_NO_PARAMETERS_SET); + return 0; + } + ec = EC_KEY_new(); + if (!ec) + return 0; + ret = EC_KEY_set_group(ec, dctx->gen_group); + if (ret) + EVP_PKEY_assign_EC_KEY(pkey, ec); + else + EC_KEY_free(ec); + return ret; + } + +static int pkey_ec_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) + { + EC_KEY *ec = NULL; + if (ctx->pkey == NULL) + { + ECerr(EC_F_PKEY_EC_KEYGEN, EC_R_NO_PARAMETERS_SET); + return 0; + } + ec = EC_KEY_new(); + if (!ec) + return 0; + EVP_PKEY_assign_EC_KEY(pkey, ec); + /* Note: if error return, pkey is freed by parent routine */ + if (!EVP_PKEY_copy_parameters(pkey, ctx->pkey)) + return 0; + return EC_KEY_generate_key(pkey->pkey.ec); + } + +const EVP_PKEY_METHOD ec_pkey_meth = + { + EVP_PKEY_EC, + 0, + pkey_ec_init, + pkey_ec_copy, + pkey_ec_cleanup, + + 0, + pkey_ec_paramgen, + + 0, + pkey_ec_keygen, + + 0, + pkey_ec_sign, + + 0, + pkey_ec_verify, + + 0,0, + + 0,0,0,0, + + 0,0, + + 0,0, + + 0, + pkey_ec_derive, + + pkey_ec_ctrl, + pkey_ec_ctrl_str + + }; diff --git a/libs/openssl/crypto/ec/ec_print.c b/libs/openssl/crypto/ec/ec_print.c new file mode 100644 index 00000000..f7c8a303 --- /dev/null +++ b/libs/openssl/crypto/ec/ec_print.c @@ -0,0 +1,195 @@ +/* crypto/ec/ec_print.c */ +/* ==================================================================== + * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include +#include "ec_lcl.h" + +BIGNUM *EC_POINT_point2bn(const EC_GROUP *group, + const EC_POINT *point, + point_conversion_form_t form, + BIGNUM *ret, + BN_CTX *ctx) + { + size_t buf_len=0; + unsigned char *buf; + + buf_len = EC_POINT_point2oct(group, point, form, + NULL, 0, ctx); + if (buf_len == 0) + return NULL; + + if ((buf = OPENSSL_malloc(buf_len)) == NULL) + return NULL; + + if (!EC_POINT_point2oct(group, point, form, buf, buf_len, ctx)) + { + OPENSSL_free(buf); + return NULL; + } + + ret = BN_bin2bn(buf, buf_len, ret); + + OPENSSL_free(buf); + + return ret; +} + +EC_POINT *EC_POINT_bn2point(const EC_GROUP *group, + const BIGNUM *bn, + EC_POINT *point, + BN_CTX *ctx) + { + size_t buf_len=0; + unsigned char *buf; + EC_POINT *ret; + + if ((buf_len = BN_num_bytes(bn)) == 0) return NULL; + buf = OPENSSL_malloc(buf_len); + if (buf == NULL) + return NULL; + + if (!BN_bn2bin(bn, buf)) + { + OPENSSL_free(buf); + return NULL; + } + + if (point == NULL) + { + if ((ret = EC_POINT_new(group)) == NULL) + { + OPENSSL_free(buf); + return NULL; + } + } + else + ret = point; + + if (!EC_POINT_oct2point(group, ret, buf, buf_len, ctx)) + { + if (point == NULL) + EC_POINT_clear_free(ret); + OPENSSL_free(buf); + return NULL; + } + + OPENSSL_free(buf); + return ret; + } + +static const char *HEX_DIGITS = "0123456789ABCDEF"; + +/* the return value must be freed (using OPENSSL_free()) */ +char *EC_POINT_point2hex(const EC_GROUP *group, + const EC_POINT *point, + point_conversion_form_t form, + BN_CTX *ctx) + { + char *ret, *p; + size_t buf_len=0,i; + unsigned char *buf, *pbuf; + + buf_len = EC_POINT_point2oct(group, point, form, + NULL, 0, ctx); + if (buf_len == 0) + return NULL; + + if ((buf = OPENSSL_malloc(buf_len)) == NULL) + return NULL; + + if (!EC_POINT_point2oct(group, point, form, buf, buf_len, ctx)) + { + OPENSSL_free(buf); + return NULL; + } + + ret = (char *)OPENSSL_malloc(buf_len*2+2); + if (ret == NULL) + { + OPENSSL_free(buf); + return NULL; + } + p = ret; + pbuf = buf; + for (i=buf_len; i > 0; i--) + { + int v = (int) *(pbuf++); + *(p++)=HEX_DIGITS[v>>4]; + *(p++)=HEX_DIGITS[v&0x0F]; + } + *p='\0'; + + OPENSSL_free(buf); + + return ret; + } + +EC_POINT *EC_POINT_hex2point(const EC_GROUP *group, + const char *buf, + EC_POINT *point, + BN_CTX *ctx) + { + EC_POINT *ret=NULL; + BIGNUM *tmp_bn=NULL; + + if (!BN_hex2bn(&tmp_bn, buf)) + return NULL; + + ret = EC_POINT_bn2point(group, tmp_bn, point, ctx); + + BN_clear_free(tmp_bn); + + return ret; + } diff --git a/libs/openssl/crypto/ec/eck_prn.c b/libs/openssl/crypto/ec/eck_prn.c new file mode 100644 index 00000000..06de8f39 --- /dev/null +++ b/libs/openssl/crypto/ec/eck_prn.c @@ -0,0 +1,392 @@ +/* crypto/ec/eck_prn.c */ +/* + * Written by Nils Larsch for the OpenSSL project. + */ +/* ==================================================================== + * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * Portions originally developed by SUN MICROSYSTEMS, INC., and + * contributed to the OpenSSL project. + */ + +#include +#include "cryptlib.h" +#include +#include +#include + +#ifndef OPENSSL_NO_FP_API +int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off) + { + BIO *b; + int ret; + + if ((b=BIO_new(BIO_s_file())) == NULL) + { + ECerr(EC_F_ECPKPARAMETERS_PRINT_FP,ERR_R_BUF_LIB); + return(0); + } + BIO_set_fp(b, fp, BIO_NOCLOSE); + ret = ECPKParameters_print(b, x, off); + BIO_free(b); + return(ret); + } + +int EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off) + { + BIO *b; + int ret; + + if ((b=BIO_new(BIO_s_file())) == NULL) + { + ECerr(EC_F_EC_KEY_PRINT_FP, ERR_R_BIO_LIB); + return(0); + } + BIO_set_fp(b, fp, BIO_NOCLOSE); + ret = EC_KEY_print(b, x, off); + BIO_free(b); + return(ret); + } + +int ECParameters_print_fp(FILE *fp, const EC_KEY *x) + { + BIO *b; + int ret; + + if ((b=BIO_new(BIO_s_file())) == NULL) + { + ECerr(EC_F_ECPARAMETERS_PRINT_FP, ERR_R_BIO_LIB); + return(0); + } + BIO_set_fp(b, fp, BIO_NOCLOSE); + ret = ECParameters_print(b, x); + BIO_free(b); + return(ret); + } +#endif + +int EC_KEY_print(BIO *bp, const EC_KEY *x, int off) + { + EVP_PKEY *pk; + int ret; + pk = EVP_PKEY_new(); + if (!pk || !EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *)x)) + return 0; + ret = EVP_PKEY_print_private(bp, pk, off, NULL); + EVP_PKEY_free(pk); + return ret; + } + +int ECParameters_print(BIO *bp, const EC_KEY *x) + { + EVP_PKEY *pk; + int ret; + pk = EVP_PKEY_new(); + if (!pk || !EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *)x)) + return 0; + ret = EVP_PKEY_print_params(bp, pk, 4, NULL); + EVP_PKEY_free(pk); + return ret; + } + +static int print_bin(BIO *fp, const char *str, const unsigned char *num, + size_t len, int off); + +int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off) + { + unsigned char *buffer=NULL; + size_t buf_len=0, i; + int ret=0, reason=ERR_R_BIO_LIB; + BN_CTX *ctx=NULL; + const EC_POINT *point=NULL; + BIGNUM *p=NULL, *a=NULL, *b=NULL, *gen=NULL, + *order=NULL, *cofactor=NULL; + const unsigned char *seed; + size_t seed_len=0; + + static const char *gen_compressed = "Generator (compressed):"; + static const char *gen_uncompressed = "Generator (uncompressed):"; + static const char *gen_hybrid = "Generator (hybrid):"; + + if (!x) + { + reason = ERR_R_PASSED_NULL_PARAMETER; + goto err; + } + + ctx = BN_CTX_new(); + if (ctx == NULL) + { + reason = ERR_R_MALLOC_FAILURE; + goto err; + } + + if (EC_GROUP_get_asn1_flag(x)) + { + /* the curve parameter are given by an asn1 OID */ + int nid; + + if (!BIO_indent(bp, off, 128)) + goto err; + + nid = EC_GROUP_get_curve_name(x); + if (nid == 0) + goto err; + + if (BIO_printf(bp, "ASN1 OID: %s", OBJ_nid2sn(nid)) <= 0) + goto err; + if (BIO_printf(bp, "\n") <= 0) + goto err; + } + else + { + /* explicit parameters */ + int is_char_two = 0; + point_conversion_form_t form; + int tmp_nid = EC_METHOD_get_field_type(EC_GROUP_method_of(x)); + + if (tmp_nid == NID_X9_62_characteristic_two_field) + is_char_two = 1; + + if ((p = BN_new()) == NULL || (a = BN_new()) == NULL || + (b = BN_new()) == NULL || (order = BN_new()) == NULL || + (cofactor = BN_new()) == NULL) + { + reason = ERR_R_MALLOC_FAILURE; + goto err; + } +#ifndef OPENSSL_NO_EC2M + if (is_char_two) + { + if (!EC_GROUP_get_curve_GF2m(x, p, a, b, ctx)) + { + reason = ERR_R_EC_LIB; + goto err; + } + } + else /* prime field */ +#endif + { + if (!EC_GROUP_get_curve_GFp(x, p, a, b, ctx)) + { + reason = ERR_R_EC_LIB; + goto err; + } + } + + if ((point = EC_GROUP_get0_generator(x)) == NULL) + { + reason = ERR_R_EC_LIB; + goto err; + } + if (!EC_GROUP_get_order(x, order, NULL) || + !EC_GROUP_get_cofactor(x, cofactor, NULL)) + { + reason = ERR_R_EC_LIB; + goto err; + } + + form = EC_GROUP_get_point_conversion_form(x); + + if ((gen = EC_POINT_point2bn(x, point, + form, NULL, ctx)) == NULL) + { + reason = ERR_R_EC_LIB; + goto err; + } + + buf_len = (size_t)BN_num_bytes(p); + if (buf_len < (i = (size_t)BN_num_bytes(a))) + buf_len = i; + if (buf_len < (i = (size_t)BN_num_bytes(b))) + buf_len = i; + if (buf_len < (i = (size_t)BN_num_bytes(gen))) + buf_len = i; + if (buf_len < (i = (size_t)BN_num_bytes(order))) + buf_len = i; + if (buf_len < (i = (size_t)BN_num_bytes(cofactor))) + buf_len = i; + + if ((seed = EC_GROUP_get0_seed(x)) != NULL) + seed_len = EC_GROUP_get_seed_len(x); + + buf_len += 10; + if ((buffer = OPENSSL_malloc(buf_len)) == NULL) + { + reason = ERR_R_MALLOC_FAILURE; + goto err; + } + + if (!BIO_indent(bp, off, 128)) + goto err; + + /* print the 'short name' of the field type */ + if (BIO_printf(bp, "Field Type: %s\n", OBJ_nid2sn(tmp_nid)) + <= 0) + goto err; + + if (is_char_two) + { + /* print the 'short name' of the base type OID */ + int basis_type = EC_GROUP_get_basis_type(x); + if (basis_type == 0) + goto err; + + if (!BIO_indent(bp, off, 128)) + goto err; + + if (BIO_printf(bp, "Basis Type: %s\n", + OBJ_nid2sn(basis_type)) <= 0) + goto err; + + /* print the polynomial */ + if ((p != NULL) && !ASN1_bn_print(bp, "Polynomial:", p, buffer, + off)) + goto err; + } + else + { + if ((p != NULL) && !ASN1_bn_print(bp, "Prime:", p, buffer,off)) + goto err; + } + if ((a != NULL) && !ASN1_bn_print(bp, "A: ", a, buffer, off)) + goto err; + if ((b != NULL) && !ASN1_bn_print(bp, "B: ", b, buffer, off)) + goto err; + if (form == POINT_CONVERSION_COMPRESSED) + { + if ((gen != NULL) && !ASN1_bn_print(bp, gen_compressed, gen, + buffer, off)) + goto err; + } + else if (form == POINT_CONVERSION_UNCOMPRESSED) + { + if ((gen != NULL) && !ASN1_bn_print(bp, gen_uncompressed, gen, + buffer, off)) + goto err; + } + else /* form == POINT_CONVERSION_HYBRID */ + { + if ((gen != NULL) && !ASN1_bn_print(bp, gen_hybrid, gen, + buffer, off)) + goto err; + } + if ((order != NULL) && !ASN1_bn_print(bp, "Order: ", order, + buffer, off)) goto err; + if ((cofactor != NULL) && !ASN1_bn_print(bp, "Cofactor: ", cofactor, + buffer, off)) goto err; + if (seed && !print_bin(bp, "Seed:", seed, seed_len, off)) + goto err; + } + ret=1; +err: + if (!ret) + ECerr(EC_F_ECPKPARAMETERS_PRINT, reason); + if (p) + BN_free(p); + if (a) + BN_free(a); + if (b) + BN_free(b); + if (gen) + BN_free(gen); + if (order) + BN_free(order); + if (cofactor) + BN_free(cofactor); + if (ctx) + BN_CTX_free(ctx); + if (buffer != NULL) + OPENSSL_free(buffer); + return(ret); + } + +static int print_bin(BIO *fp, const char *name, const unsigned char *buf, + size_t len, int off) + { + size_t i; + char str[128]; + + if (buf == NULL) + return 1; + if (off) + { + if (off > 128) + off=128; + memset(str,' ',off); + if (BIO_write(fp, str, off) <= 0) + return 0; + } + + if (BIO_printf(fp,"%s", name) <= 0) + return 0; + + for (i=0; i + +#ifdef OPENSSL_FIPS +#include +#endif + +#include "ec_lcl.h" + + +const EC_METHOD *EC_GFp_mont_method(void) + { +#ifdef OPENSSL_FIPS + return fips_ec_gfp_mont_method(); +#else + static const EC_METHOD ret = { + EC_FLAGS_DEFAULT_OCT, + NID_X9_62_prime_field, + ec_GFp_mont_group_init, + ec_GFp_mont_group_finish, + ec_GFp_mont_group_clear_finish, + ec_GFp_mont_group_copy, + ec_GFp_mont_group_set_curve, + ec_GFp_simple_group_get_curve, + ec_GFp_simple_group_get_degree, + ec_GFp_simple_group_check_discriminant, + ec_GFp_simple_point_init, + ec_GFp_simple_point_finish, + ec_GFp_simple_point_clear_finish, + ec_GFp_simple_point_copy, + ec_GFp_simple_point_set_to_infinity, + ec_GFp_simple_set_Jprojective_coordinates_GFp, + ec_GFp_simple_get_Jprojective_coordinates_GFp, + ec_GFp_simple_point_set_affine_coordinates, + ec_GFp_simple_point_get_affine_coordinates, + 0,0,0, + ec_GFp_simple_add, + ec_GFp_simple_dbl, + ec_GFp_simple_invert, + ec_GFp_simple_is_at_infinity, + ec_GFp_simple_is_on_curve, + ec_GFp_simple_cmp, + ec_GFp_simple_make_affine, + ec_GFp_simple_points_make_affine, + 0 /* mul */, + 0 /* precompute_mult */, + 0 /* have_precompute_mult */, + ec_GFp_mont_field_mul, + ec_GFp_mont_field_sqr, + 0 /* field_div */, + ec_GFp_mont_field_encode, + ec_GFp_mont_field_decode, + ec_GFp_mont_field_set_to_one }; + + return &ret; +#endif + } + + +int ec_GFp_mont_group_init(EC_GROUP *group) + { + int ok; + + ok = ec_GFp_simple_group_init(group); + group->field_data1 = NULL; + group->field_data2 = NULL; + return ok; + } + + +void ec_GFp_mont_group_finish(EC_GROUP *group) + { + if (group->field_data1 != NULL) + { + BN_MONT_CTX_free(group->field_data1); + group->field_data1 = NULL; + } + if (group->field_data2 != NULL) + { + BN_free(group->field_data2); + group->field_data2 = NULL; + } + ec_GFp_simple_group_finish(group); + } + + +void ec_GFp_mont_group_clear_finish(EC_GROUP *group) + { + if (group->field_data1 != NULL) + { + BN_MONT_CTX_free(group->field_data1); + group->field_data1 = NULL; + } + if (group->field_data2 != NULL) + { + BN_clear_free(group->field_data2); + group->field_data2 = NULL; + } + ec_GFp_simple_group_clear_finish(group); + } + + +int ec_GFp_mont_group_copy(EC_GROUP *dest, const EC_GROUP *src) + { + if (dest->field_data1 != NULL) + { + BN_MONT_CTX_free(dest->field_data1); + dest->field_data1 = NULL; + } + if (dest->field_data2 != NULL) + { + BN_clear_free(dest->field_data2); + dest->field_data2 = NULL; + } + + if (!ec_GFp_simple_group_copy(dest, src)) return 0; + + if (src->field_data1 != NULL) + { + dest->field_data1 = BN_MONT_CTX_new(); + if (dest->field_data1 == NULL) return 0; + if (!BN_MONT_CTX_copy(dest->field_data1, src->field_data1)) goto err; + } + if (src->field_data2 != NULL) + { + dest->field_data2 = BN_dup(src->field_data2); + if (dest->field_data2 == NULL) goto err; + } + + return 1; + + err: + if (dest->field_data1 != NULL) + { + BN_MONT_CTX_free(dest->field_data1); + dest->field_data1 = NULL; + } + return 0; + } + + +int ec_GFp_mont_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) + { + BN_CTX *new_ctx = NULL; + BN_MONT_CTX *mont = NULL; + BIGNUM *one = NULL; + int ret = 0; + + if (group->field_data1 != NULL) + { + BN_MONT_CTX_free(group->field_data1); + group->field_data1 = NULL; + } + if (group->field_data2 != NULL) + { + BN_free(group->field_data2); + group->field_data2 = NULL; + } + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return 0; + } + + mont = BN_MONT_CTX_new(); + if (mont == NULL) goto err; + if (!BN_MONT_CTX_set(mont, p, ctx)) + { + ECerr(EC_F_EC_GFP_MONT_GROUP_SET_CURVE, ERR_R_BN_LIB); + goto err; + } + one = BN_new(); + if (one == NULL) goto err; + if (!BN_to_montgomery(one, BN_value_one(), mont, ctx)) goto err; + + group->field_data1 = mont; + mont = NULL; + group->field_data2 = one; + one = NULL; + + ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx); + + if (!ret) + { + BN_MONT_CTX_free(group->field_data1); + group->field_data1 = NULL; + BN_free(group->field_data2); + group->field_data2 = NULL; + } + + err: + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + if (mont != NULL) + BN_MONT_CTX_free(mont); + return ret; + } + + +int ec_GFp_mont_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) + { + if (group->field_data1 == NULL) + { + ECerr(EC_F_EC_GFP_MONT_FIELD_MUL, EC_R_NOT_INITIALIZED); + return 0; + } + + return BN_mod_mul_montgomery(r, a, b, group->field_data1, ctx); + } + + +int ec_GFp_mont_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) + { + if (group->field_data1 == NULL) + { + ECerr(EC_F_EC_GFP_MONT_FIELD_SQR, EC_R_NOT_INITIALIZED); + return 0; + } + + return BN_mod_mul_montgomery(r, a, a, group->field_data1, ctx); + } + + +int ec_GFp_mont_field_encode(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) + { + if (group->field_data1 == NULL) + { + ECerr(EC_F_EC_GFP_MONT_FIELD_ENCODE, EC_R_NOT_INITIALIZED); + return 0; + } + + return BN_to_montgomery(r, a, (BN_MONT_CTX *)group->field_data1, ctx); + } + + +int ec_GFp_mont_field_decode(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) + { + if (group->field_data1 == NULL) + { + ECerr(EC_F_EC_GFP_MONT_FIELD_DECODE, EC_R_NOT_INITIALIZED); + return 0; + } + + return BN_from_montgomery(r, a, group->field_data1, ctx); + } + + +int ec_GFp_mont_field_set_to_one(const EC_GROUP *group, BIGNUM *r, BN_CTX *ctx) + { + if (group->field_data2 == NULL) + { + ECerr(EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE, EC_R_NOT_INITIALIZED); + return 0; + } + + if (!BN_copy(r, group->field_data2)) return 0; + return 1; + } diff --git a/libs/openssl/crypto/ec/ecp_nist.c b/libs/openssl/crypto/ec/ecp_nist.c new file mode 100644 index 00000000..aad2d5f4 --- /dev/null +++ b/libs/openssl/crypto/ec/ecp_nist.c @@ -0,0 +1,217 @@ +/* crypto/ec/ecp_nist.c */ +/* + * Written by Nils Larsch for the OpenSSL project. + */ +/* ==================================================================== + * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * Portions of this software developed by SUN MICROSYSTEMS, INC., + * and contributed to the OpenSSL project. + */ + +#include + +#include +#include +#include "ec_lcl.h" + +#ifdef OPENSSL_FIPS +#include +#endif + +const EC_METHOD *EC_GFp_nist_method(void) + { +#ifdef OPENSSL_FIPS + return fips_ec_gfp_nist_method(); +#else + static const EC_METHOD ret = { + EC_FLAGS_DEFAULT_OCT, + NID_X9_62_prime_field, + ec_GFp_simple_group_init, + ec_GFp_simple_group_finish, + ec_GFp_simple_group_clear_finish, + ec_GFp_nist_group_copy, + ec_GFp_nist_group_set_curve, + ec_GFp_simple_group_get_curve, + ec_GFp_simple_group_get_degree, + ec_GFp_simple_group_check_discriminant, + ec_GFp_simple_point_init, + ec_GFp_simple_point_finish, + ec_GFp_simple_point_clear_finish, + ec_GFp_simple_point_copy, + ec_GFp_simple_point_set_to_infinity, + ec_GFp_simple_set_Jprojective_coordinates_GFp, + ec_GFp_simple_get_Jprojective_coordinates_GFp, + ec_GFp_simple_point_set_affine_coordinates, + ec_GFp_simple_point_get_affine_coordinates, + 0,0,0, + ec_GFp_simple_add, + ec_GFp_simple_dbl, + ec_GFp_simple_invert, + ec_GFp_simple_is_at_infinity, + ec_GFp_simple_is_on_curve, + ec_GFp_simple_cmp, + ec_GFp_simple_make_affine, + ec_GFp_simple_points_make_affine, + 0 /* mul */, + 0 /* precompute_mult */, + 0 /* have_precompute_mult */, + ec_GFp_nist_field_mul, + ec_GFp_nist_field_sqr, + 0 /* field_div */, + 0 /* field_encode */, + 0 /* field_decode */, + 0 /* field_set_to_one */ }; + + return &ret; +#endif + } + +int ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src) + { + dest->field_mod_func = src->field_mod_func; + + return ec_GFp_simple_group_copy(dest, src); + } + +int ec_GFp_nist_group_set_curve(EC_GROUP *group, const BIGNUM *p, + const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) + { + int ret = 0; + BN_CTX *new_ctx = NULL; + BIGNUM *tmp_bn; + + if (ctx == NULL) + if ((ctx = new_ctx = BN_CTX_new()) == NULL) return 0; + + BN_CTX_start(ctx); + if ((tmp_bn = BN_CTX_get(ctx)) == NULL) goto err; + + if (BN_ucmp(BN_get0_nist_prime_192(), p) == 0) + group->field_mod_func = BN_nist_mod_192; + else if (BN_ucmp(BN_get0_nist_prime_224(), p) == 0) + group->field_mod_func = BN_nist_mod_224; + else if (BN_ucmp(BN_get0_nist_prime_256(), p) == 0) + group->field_mod_func = BN_nist_mod_256; + else if (BN_ucmp(BN_get0_nist_prime_384(), p) == 0) + group->field_mod_func = BN_nist_mod_384; + else if (BN_ucmp(BN_get0_nist_prime_521(), p) == 0) + group->field_mod_func = BN_nist_mod_521; + else + { + ECerr(EC_F_EC_GFP_NIST_GROUP_SET_CURVE, EC_R_NOT_A_NIST_PRIME); + goto err; + } + + ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx); + + err: + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return ret; + } + + +int ec_GFp_nist_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, + const BIGNUM *b, BN_CTX *ctx) + { + int ret=0; + BN_CTX *ctx_new=NULL; + + if (!group || !r || !a || !b) + { + ECerr(EC_F_EC_GFP_NIST_FIELD_MUL, ERR_R_PASSED_NULL_PARAMETER); + goto err; + } + if (!ctx) + if ((ctx_new = ctx = BN_CTX_new()) == NULL) goto err; + + if (!BN_mul(r, a, b, ctx)) goto err; + if (!group->field_mod_func(r, r, &group->field, ctx)) + goto err; + + ret=1; +err: + if (ctx_new) + BN_CTX_free(ctx_new); + return ret; + } + + +int ec_GFp_nist_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, + BN_CTX *ctx) + { + int ret=0; + BN_CTX *ctx_new=NULL; + + if (!group || !r || !a) + { + ECerr(EC_F_EC_GFP_NIST_FIELD_SQR, EC_R_PASSED_NULL_PARAMETER); + goto err; + } + if (!ctx) + if ((ctx_new = ctx = BN_CTX_new()) == NULL) goto err; + + if (!BN_sqr(r, a, ctx)) goto err; + if (!group->field_mod_func(r, r, &group->field, ctx)) + goto err; + + ret=1; +err: + if (ctx_new) + BN_CTX_free(ctx_new); + return ret; + } diff --git a/libs/openssl/crypto/ec/ecp_nistp224.c b/libs/openssl/crypto/ec/ecp_nistp224.c new file mode 100644 index 00000000..b5ff56c2 --- /dev/null +++ b/libs/openssl/crypto/ec/ecp_nistp224.c @@ -0,0 +1,1658 @@ +/* crypto/ec/ecp_nistp224.c */ +/* + * Written by Emilia Kasper (Google) for the OpenSSL project. + */ +/* Copyright 2011 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * A 64-bit implementation of the NIST P-224 elliptic curve point multiplication + * + * Inspired by Daniel J. Bernstein's public domain nistp224 implementation + * and Adam Langley's public domain 64-bit C implementation of curve25519 + */ + +#include +#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 + +#ifndef OPENSSL_SYS_VMS +#include +#else +#include +#endif + +#include +#include +#include "ec_lcl.h" + +#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) + /* even with gcc, the typedef won't work for 32-bit platforms */ + typedef __uint128_t uint128_t; /* nonstandard; implemented by gcc on 64-bit platforms */ +#else + #error "Need GCC 3.1 or later to define type uint128_t" +#endif + +typedef uint8_t u8; +typedef uint64_t u64; +typedef int64_t s64; + + +/******************************************************************************/ +/* INTERNAL REPRESENTATION OF FIELD ELEMENTS + * + * Field elements are represented as a_0 + 2^56*a_1 + 2^112*a_2 + 2^168*a_3 + * using 64-bit coefficients called 'limbs', + * and sometimes (for multiplication results) as + * b_0 + 2^56*b_1 + 2^112*b_2 + 2^168*b_3 + 2^224*b_4 + 2^280*b_5 + 2^336*b_6 + * using 128-bit coefficients called 'widelimbs'. + * A 4-limb representation is an 'felem'; + * a 7-widelimb representation is a 'widefelem'. + * Even within felems, bits of adjacent limbs overlap, and we don't always + * reduce the representations: we ensure that inputs to each felem + * multiplication satisfy a_i < 2^60, so outputs satisfy b_i < 4*2^60*2^60, + * and fit into a 128-bit word without overflow. The coefficients are then + * again partially reduced to obtain an felem satisfying a_i < 2^57. + * We only reduce to the unique minimal representation at the end of the + * computation. + */ + +typedef uint64_t limb; +typedef uint128_t widelimb; + +typedef limb felem[4]; +typedef widelimb widefelem[7]; + +/* Field element represented as a byte arrary. + * 28*8 = 224 bits is also the group order size for the elliptic curve, + * and we also use this type for scalars for point multiplication. + */ +typedef u8 felem_bytearray[28]; + +static const felem_bytearray nistp224_curve_params[5] = { + {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01}, + {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE}, + {0xB4,0x05,0x0A,0x85,0x0C,0x04,0xB3,0xAB,0xF5,0x41, /* b */ + 0x32,0x56,0x50,0x44,0xB0,0xB7,0xD7,0xBF,0xD8,0xBA, + 0x27,0x0B,0x39,0x43,0x23,0x55,0xFF,0xB4}, + {0xB7,0x0E,0x0C,0xBD,0x6B,0xB4,0xBF,0x7F,0x32,0x13, /* x */ + 0x90,0xB9,0x4A,0x03,0xC1,0xD3,0x56,0xC2,0x11,0x22, + 0x34,0x32,0x80,0xD6,0x11,0x5C,0x1D,0x21}, + {0xbd,0x37,0x63,0x88,0xb5,0xf7,0x23,0xfb,0x4c,0x22, /* y */ + 0xdf,0xe6,0xcd,0x43,0x75,0xa0,0x5a,0x07,0x47,0x64, + 0x44,0xd5,0x81,0x99,0x85,0x00,0x7e,0x34} +}; + +/* Precomputed multiples of the standard generator + * Points are given in coordinates (X, Y, Z) where Z normally is 1 + * (0 for the point at infinity). + * For each field element, slice a_0 is word 0, etc. + * + * The table has 2 * 16 elements, starting with the following: + * index | bits | point + * ------+---------+------------------------------ + * 0 | 0 0 0 0 | 0G + * 1 | 0 0 0 1 | 1G + * 2 | 0 0 1 0 | 2^56G + * 3 | 0 0 1 1 | (2^56 + 1)G + * 4 | 0 1 0 0 | 2^112G + * 5 | 0 1 0 1 | (2^112 + 1)G + * 6 | 0 1 1 0 | (2^112 + 2^56)G + * 7 | 0 1 1 1 | (2^112 + 2^56 + 1)G + * 8 | 1 0 0 0 | 2^168G + * 9 | 1 0 0 1 | (2^168 + 1)G + * 10 | 1 0 1 0 | (2^168 + 2^56)G + * 11 | 1 0 1 1 | (2^168 + 2^56 + 1)G + * 12 | 1 1 0 0 | (2^168 + 2^112)G + * 13 | 1 1 0 1 | (2^168 + 2^112 + 1)G + * 14 | 1 1 1 0 | (2^168 + 2^112 + 2^56)G + * 15 | 1 1 1 1 | (2^168 + 2^112 + 2^56 + 1)G + * followed by a copy of this with each element multiplied by 2^28. + * + * The reason for this is so that we can clock bits into four different + * locations when doing simple scalar multiplies against the base point, + * and then another four locations using the second 16 elements. + */ +static const felem gmul[2][16][3] = +{{{{0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}}, + {{0x3280d6115c1d21, 0xc1d356c2112234, 0x7f321390b94a03, 0xb70e0cbd6bb4bf}, + {0xd5819985007e34, 0x75a05a07476444, 0xfb4c22dfe6cd43, 0xbd376388b5f723}, + {1, 0, 0, 0}}, + {{0xfd9675666ebbe9, 0xbca7664d40ce5e, 0x2242df8d8a2a43, 0x1f49bbb0f99bc5}, + {0x29e0b892dc9c43, 0xece8608436e662, 0xdc858f185310d0, 0x9812dd4eb8d321}, + {1, 0, 0, 0}}, + {{0x6d3e678d5d8eb8, 0x559eed1cb362f1, 0x16e9a3bbce8a3f, 0xeedcccd8c2a748}, + {0xf19f90ed50266d, 0xabf2b4bf65f9df, 0x313865468fafec, 0x5cb379ba910a17}, + {1, 0, 0, 0}}, + {{0x0641966cab26e3, 0x91fb2991fab0a0, 0xefec27a4e13a0b, 0x0499aa8a5f8ebe}, + {0x7510407766af5d, 0x84d929610d5450, 0x81d77aae82f706, 0x6916f6d4338c5b}, + {1, 0, 0, 0}}, + {{0xea95ac3b1f15c6, 0x086000905e82d4, 0xdd323ae4d1c8b1, 0x932b56be7685a3}, + {0x9ef93dea25dbbf, 0x41665960f390f0, 0xfdec76dbe2a8a7, 0x523e80f019062a}, + {1, 0, 0, 0}}, + {{0x822fdd26732c73, 0xa01c83531b5d0f, 0x363f37347c1ba4, 0xc391b45c84725c}, + {0xbbd5e1b2d6ad24, 0xddfbcde19dfaec, 0xc393da7e222a7f, 0x1efb7890ede244}, + {1, 0, 0, 0}}, + {{0x4c9e90ca217da1, 0xd11beca79159bb, 0xff8d33c2c98b7c, 0x2610b39409f849}, + {0x44d1352ac64da0, 0xcdbb7b2c46b4fb, 0x966c079b753c89, 0xfe67e4e820b112}, + {1, 0, 0, 0}}, + {{0xe28cae2df5312d, 0xc71b61d16f5c6e, 0x79b7619a3e7c4c, 0x05c73240899b47}, + {0x9f7f6382c73e3a, 0x18615165c56bda, 0x641fab2116fd56, 0x72855882b08394}, + {1, 0, 0, 0}}, + {{0x0469182f161c09, 0x74a98ca8d00fb5, 0xb89da93489a3e0, 0x41c98768fb0c1d}, + {0xe5ea05fb32da81, 0x3dce9ffbca6855, 0x1cfe2d3fbf59e6, 0x0e5e03408738a7}, + {1, 0, 0, 0}}, + {{0xdab22b2333e87f, 0x4430137a5dd2f6, 0xe03ab9f738beb8, 0xcb0c5d0dc34f24}, + {0x764a7df0c8fda5, 0x185ba5c3fa2044, 0x9281d688bcbe50, 0xc40331df893881}, + {1, 0, 0, 0}}, + {{0xb89530796f0f60, 0xade92bd26909a3, 0x1a0c83fb4884da, 0x1765bf22a5a984}, + {0x772a9ee75db09e, 0x23bc6c67cec16f, 0x4c1edba8b14e2f, 0xe2a215d9611369}, + {1, 0, 0, 0}}, + {{0x571e509fb5efb3, 0xade88696410552, 0xc8ae85fada74fe, 0x6c7e4be83bbde3}, + {0xff9f51160f4652, 0xb47ce2495a6539, 0xa2946c53b582f4, 0x286d2db3ee9a60}, + {1, 0, 0, 0}}, + {{0x40bbd5081a44af, 0x0995183b13926c, 0xbcefba6f47f6d0, 0x215619e9cc0057}, + {0x8bc94d3b0df45e, 0xf11c54a3694f6f, 0x8631b93cdfe8b5, 0xe7e3f4b0982db9}, + {1, 0, 0, 0}}, + {{0xb17048ab3e1c7b, 0xac38f36ff8a1d8, 0x1c29819435d2c6, 0xc813132f4c07e9}, + {0x2891425503b11f, 0x08781030579fea, 0xf5426ba5cc9674, 0x1e28ebf18562bc}, + {1, 0, 0, 0}}, + {{0x9f31997cc864eb, 0x06cd91d28b5e4c, 0xff17036691a973, 0xf1aef351497c58}, + {0xdd1f2d600564ff, 0xdead073b1402db, 0x74a684435bd693, 0xeea7471f962558}, + {1, 0, 0, 0}}}, + {{{0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}}, + {{0x9665266dddf554, 0x9613d78b60ef2d, 0xce27a34cdba417, 0xd35ab74d6afc31}, + {0x85ccdd22deb15e, 0x2137e5783a6aab, 0xa141cffd8c93c6, 0x355a1830e90f2d}, + {1, 0, 0, 0}}, + {{0x1a494eadaade65, 0xd6da4da77fe53c, 0xe7992996abec86, 0x65c3553c6090e3}, + {0xfa610b1fb09346, 0xf1c6540b8a4aaf, 0xc51a13ccd3cbab, 0x02995b1b18c28a}, + {1, 0, 0, 0}}, + {{0x7874568e7295ef, 0x86b419fbe38d04, 0xdc0690a7550d9a, 0xd3966a44beac33}, + {0x2b7280ec29132f, 0xbeaa3b6a032df3, 0xdc7dd88ae41200, 0xd25e2513e3a100}, + {1, 0, 0, 0}}, + {{0x924857eb2efafd, 0xac2bce41223190, 0x8edaa1445553fc, 0x825800fd3562d5}, + {0x8d79148ea96621, 0x23a01c3dd9ed8d, 0xaf8b219f9416b5, 0xd8db0cc277daea}, + {1, 0, 0, 0}}, + {{0x76a9c3b1a700f0, 0xe9acd29bc7e691, 0x69212d1a6b0327, 0x6322e97fe154be}, + {0x469fc5465d62aa, 0x8d41ed18883b05, 0x1f8eae66c52b88, 0xe4fcbe9325be51}, + {1, 0, 0, 0}}, + {{0x825fdf583cac16, 0x020b857c7b023a, 0x683c17744b0165, 0x14ffd0a2daf2f1}, + {0x323b36184218f9, 0x4944ec4e3b47d4, 0xc15b3080841acf, 0x0bced4b01a28bb}, + {1, 0, 0, 0}}, + {{0x92ac22230df5c4, 0x52f33b4063eda8, 0xcb3f19870c0c93, 0x40064f2ba65233}, + {0xfe16f0924f8992, 0x012da25af5b517, 0x1a57bb24f723a6, 0x06f8bc76760def}, + {1, 0, 0, 0}}, + {{0x4a7084f7817cb9, 0xbcab0738ee9a78, 0x3ec11e11d9c326, 0xdc0fe90e0f1aae}, + {0xcf639ea5f98390, 0x5c350aa22ffb74, 0x9afae98a4047b7, 0x956ec2d617fc45}, + {1, 0, 0, 0}}, + {{0x4306d648c1be6a, 0x9247cd8bc9a462, 0xf5595e377d2f2e, 0xbd1c3caff1a52e}, + {0x045e14472409d0, 0x29f3e17078f773, 0x745a602b2d4f7d, 0x191837685cdfbb}, + {1, 0, 0, 0}}, + {{0x5b6ee254a8cb79, 0x4953433f5e7026, 0xe21faeb1d1def4, 0xc4c225785c09de}, + {0x307ce7bba1e518, 0x31b125b1036db8, 0x47e91868839e8f, 0xc765866e33b9f3}, + {1, 0, 0, 0}}, + {{0x3bfece24f96906, 0x4794da641e5093, 0xde5df64f95db26, 0x297ecd89714b05}, + {0x701bd3ebb2c3aa, 0x7073b4f53cb1d5, 0x13c5665658af16, 0x9895089d66fe58}, + {1, 0, 0, 0}}, + {{0x0fef05f78c4790, 0x2d773633b05d2e, 0x94229c3a951c94, 0xbbbd70df4911bb}, + {0xb2c6963d2c1168, 0x105f47a72b0d73, 0x9fdf6111614080, 0x7b7e94b39e67b0}, + {1, 0, 0, 0}}, + {{0xad1a7d6efbe2b3, 0xf012482c0da69d, 0x6b3bdf12438345, 0x40d7558d7aa4d9}, + {0x8a09fffb5c6d3d, 0x9a356e5d9ffd38, 0x5973f15f4f9b1c, 0xdcd5f59f63c3ea}, + {1, 0, 0, 0}}, + {{0xacf39f4c5ca7ab, 0x4c8071cc5fd737, 0xc64e3602cd1184, 0x0acd4644c9abba}, + {0x6c011a36d8bf6e, 0xfecd87ba24e32a, 0x19f6f56574fad8, 0x050b204ced9405}, + {1, 0, 0, 0}}, + {{0xed4f1cae7d9a96, 0x5ceef7ad94c40a, 0x778e4a3bf3ef9b, 0x7405783dc3b55e}, + {0x32477c61b6e8c6, 0xb46a97570f018b, 0x91176d0a7e95d1, 0x3df90fbc4c7d0e}, + {1, 0, 0, 0}}}}; + +/* Precomputation for the group generator. */ +typedef struct { + felem g_pre_comp[2][16][3]; + int references; +} NISTP224_PRE_COMP; + +const EC_METHOD *EC_GFp_nistp224_method(void) + { + static const EC_METHOD ret = { + EC_FLAGS_DEFAULT_OCT, + NID_X9_62_prime_field, + ec_GFp_nistp224_group_init, + ec_GFp_simple_group_finish, + ec_GFp_simple_group_clear_finish, + ec_GFp_nist_group_copy, + ec_GFp_nistp224_group_set_curve, + ec_GFp_simple_group_get_curve, + ec_GFp_simple_group_get_degree, + ec_GFp_simple_group_check_discriminant, + ec_GFp_simple_point_init, + ec_GFp_simple_point_finish, + ec_GFp_simple_point_clear_finish, + ec_GFp_simple_point_copy, + ec_GFp_simple_point_set_to_infinity, + ec_GFp_simple_set_Jprojective_coordinates_GFp, + ec_GFp_simple_get_Jprojective_coordinates_GFp, + ec_GFp_simple_point_set_affine_coordinates, + ec_GFp_nistp224_point_get_affine_coordinates, + 0 /* point_set_compressed_coordinates */, + 0 /* point2oct */, + 0 /* oct2point */, + ec_GFp_simple_add, + ec_GFp_simple_dbl, + ec_GFp_simple_invert, + ec_GFp_simple_is_at_infinity, + ec_GFp_simple_is_on_curve, + ec_GFp_simple_cmp, + ec_GFp_simple_make_affine, + ec_GFp_simple_points_make_affine, + ec_GFp_nistp224_points_mul, + ec_GFp_nistp224_precompute_mult, + ec_GFp_nistp224_have_precompute_mult, + ec_GFp_nist_field_mul, + ec_GFp_nist_field_sqr, + 0 /* field_div */, + 0 /* field_encode */, + 0 /* field_decode */, + 0 /* field_set_to_one */ }; + + return &ret; + } + +/* Helper functions to convert field elements to/from internal representation */ +static void bin28_to_felem(felem out, const u8 in[28]) + { + out[0] = *((const uint64_t *)(in)) & 0x00ffffffffffffff; + out[1] = (*((const uint64_t *)(in+7))) & 0x00ffffffffffffff; + out[2] = (*((const uint64_t *)(in+14))) & 0x00ffffffffffffff; + out[3] = (*((const uint64_t *)(in+21))) & 0x00ffffffffffffff; + } + +static void felem_to_bin28(u8 out[28], const felem in) + { + unsigned i; + for (i = 0; i < 7; ++i) + { + out[i] = in[0]>>(8*i); + out[i+7] = in[1]>>(8*i); + out[i+14] = in[2]>>(8*i); + out[i+21] = in[3]>>(8*i); + } + } + +/* To preserve endianness when using BN_bn2bin and BN_bin2bn */ +static void flip_endian(u8 *out, const u8 *in, unsigned len) + { + unsigned i; + for (i = 0; i < len; ++i) + out[i] = in[len-1-i]; + } + +/* From OpenSSL BIGNUM to internal representation */ +static int BN_to_felem(felem out, const BIGNUM *bn) + { + felem_bytearray b_in; + felem_bytearray b_out; + unsigned num_bytes; + + /* BN_bn2bin eats leading zeroes */ + memset(b_out, 0, sizeof b_out); + num_bytes = BN_num_bytes(bn); + if (num_bytes > sizeof b_out) + { + ECerr(EC_F_BN_TO_FELEM, EC_R_BIGNUM_OUT_OF_RANGE); + return 0; + } + if (BN_is_negative(bn)) + { + ECerr(EC_F_BN_TO_FELEM, EC_R_BIGNUM_OUT_OF_RANGE); + return 0; + } + num_bytes = BN_bn2bin(bn, b_in); + flip_endian(b_out, b_in, num_bytes); + bin28_to_felem(out, b_out); + return 1; + } + +/* From internal representation to OpenSSL BIGNUM */ +static BIGNUM *felem_to_BN(BIGNUM *out, const felem in) + { + felem_bytearray b_in, b_out; + felem_to_bin28(b_in, in); + flip_endian(b_out, b_in, sizeof b_out); + return BN_bin2bn(b_out, sizeof b_out, out); + } + +/******************************************************************************/ +/* FIELD OPERATIONS + * + * Field operations, using the internal representation of field elements. + * NB! These operations are specific to our point multiplication and cannot be + * expected to be correct in general - e.g., multiplication with a large scalar + * will cause an overflow. + * + */ + +static void felem_one(felem out) + { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + } + +static void felem_assign(felem out, const felem in) + { + out[0] = in[0]; + out[1] = in[1]; + out[2] = in[2]; + out[3] = in[3]; + } + +/* Sum two field elements: out += in */ +static void felem_sum(felem out, const felem in) + { + out[0] += in[0]; + out[1] += in[1]; + out[2] += in[2]; + out[3] += in[3]; + } + +/* Get negative value: out = -in */ +/* Assumes in[i] < 2^57 */ +static void felem_neg(felem out, const felem in) + { + static const limb two58p2 = (((limb) 1) << 58) + (((limb) 1) << 2); + static const limb two58m2 = (((limb) 1) << 58) - (((limb) 1) << 2); + static const limb two58m42m2 = (((limb) 1) << 58) - + (((limb) 1) << 42) - (((limb) 1) << 2); + + /* Set to 0 mod 2^224-2^96+1 to ensure out > in */ + out[0] = two58p2 - in[0]; + out[1] = two58m42m2 - in[1]; + out[2] = two58m2 - in[2]; + out[3] = two58m2 - in[3]; + } + +/* Subtract field elements: out -= in */ +/* Assumes in[i] < 2^57 */ +static void felem_diff(felem out, const felem in) + { + static const limb two58p2 = (((limb) 1) << 58) + (((limb) 1) << 2); + static const limb two58m2 = (((limb) 1) << 58) - (((limb) 1) << 2); + static const limb two58m42m2 = (((limb) 1) << 58) - + (((limb) 1) << 42) - (((limb) 1) << 2); + + /* Add 0 mod 2^224-2^96+1 to ensure out > in */ + out[0] += two58p2; + out[1] += two58m42m2; + out[2] += two58m2; + out[3] += two58m2; + + out[0] -= in[0]; + out[1] -= in[1]; + out[2] -= in[2]; + out[3] -= in[3]; + } + +/* Subtract in unreduced 128-bit mode: out -= in */ +/* Assumes in[i] < 2^119 */ +static void widefelem_diff(widefelem out, const widefelem in) + { + static const widelimb two120 = ((widelimb) 1) << 120; + static const widelimb two120m64 = (((widelimb) 1) << 120) - + (((widelimb) 1) << 64); + static const widelimb two120m104m64 = (((widelimb) 1) << 120) - + (((widelimb) 1) << 104) - (((widelimb) 1) << 64); + + /* Add 0 mod 2^224-2^96+1 to ensure out > in */ + out[0] += two120; + out[1] += two120m64; + out[2] += two120m64; + out[3] += two120; + out[4] += two120m104m64; + out[5] += two120m64; + out[6] += two120m64; + + out[0] -= in[0]; + out[1] -= in[1]; + out[2] -= in[2]; + out[3] -= in[3]; + out[4] -= in[4]; + out[5] -= in[5]; + out[6] -= in[6]; + } + +/* Subtract in mixed mode: out128 -= in64 */ +/* in[i] < 2^63 */ +static void felem_diff_128_64(widefelem out, const felem in) + { + static const widelimb two64p8 = (((widelimb) 1) << 64) + + (((widelimb) 1) << 8); + static const widelimb two64m8 = (((widelimb) 1) << 64) - + (((widelimb) 1) << 8); + static const widelimb two64m48m8 = (((widelimb) 1) << 64) - + (((widelimb) 1) << 48) - (((widelimb) 1) << 8); + + /* Add 0 mod 2^224-2^96+1 to ensure out > in */ + out[0] += two64p8; + out[1] += two64m48m8; + out[2] += two64m8; + out[3] += two64m8; + + out[0] -= in[0]; + out[1] -= in[1]; + out[2] -= in[2]; + out[3] -= in[3]; + } + +/* Multiply a field element by a scalar: out = out * scalar + * The scalars we actually use are small, so results fit without overflow */ +static void felem_scalar(felem out, const limb scalar) + { + out[0] *= scalar; + out[1] *= scalar; + out[2] *= scalar; + out[3] *= scalar; + } + +/* Multiply an unreduced field element by a scalar: out = out * scalar + * The scalars we actually use are small, so results fit without overflow */ +static void widefelem_scalar(widefelem out, const widelimb scalar) + { + out[0] *= scalar; + out[1] *= scalar; + out[2] *= scalar; + out[3] *= scalar; + out[4] *= scalar; + out[5] *= scalar; + out[6] *= scalar; + } + +/* Square a field element: out = in^2 */ +static void felem_square(widefelem out, const felem in) + { + limb tmp0, tmp1, tmp2; + tmp0 = 2 * in[0]; tmp1 = 2 * in[1]; tmp2 = 2 * in[2]; + out[0] = ((widelimb) in[0]) * in[0]; + out[1] = ((widelimb) in[0]) * tmp1; + out[2] = ((widelimb) in[0]) * tmp2 + ((widelimb) in[1]) * in[1]; + out[3] = ((widelimb) in[3]) * tmp0 + + ((widelimb) in[1]) * tmp2; + out[4] = ((widelimb) in[3]) * tmp1 + ((widelimb) in[2]) * in[2]; + out[5] = ((widelimb) in[3]) * tmp2; + out[6] = ((widelimb) in[3]) * in[3]; + } + +/* Multiply two field elements: out = in1 * in2 */ +static void felem_mul(widefelem out, const felem in1, const felem in2) + { + out[0] = ((widelimb) in1[0]) * in2[0]; + out[1] = ((widelimb) in1[0]) * in2[1] + ((widelimb) in1[1]) * in2[0]; + out[2] = ((widelimb) in1[0]) * in2[2] + ((widelimb) in1[1]) * in2[1] + + ((widelimb) in1[2]) * in2[0]; + out[3] = ((widelimb) in1[0]) * in2[3] + ((widelimb) in1[1]) * in2[2] + + ((widelimb) in1[2]) * in2[1] + ((widelimb) in1[3]) * in2[0]; + out[4] = ((widelimb) in1[1]) * in2[3] + ((widelimb) in1[2]) * in2[2] + + ((widelimb) in1[3]) * in2[1]; + out[5] = ((widelimb) in1[2]) * in2[3] + ((widelimb) in1[3]) * in2[2]; + out[6] = ((widelimb) in1[3]) * in2[3]; + } + +/* Reduce seven 128-bit coefficients to four 64-bit coefficients. + * Requires in[i] < 2^126, + * ensures out[0] < 2^56, out[1] < 2^56, out[2] < 2^56, out[3] <= 2^56 + 2^16 */ +static void felem_reduce(felem out, const widefelem in) + { + static const widelimb two127p15 = (((widelimb) 1) << 127) + + (((widelimb) 1) << 15); + static const widelimb two127m71 = (((widelimb) 1) << 127) - + (((widelimb) 1) << 71); + static const widelimb two127m71m55 = (((widelimb) 1) << 127) - + (((widelimb) 1) << 71) - (((widelimb) 1) << 55); + widelimb output[5]; + + /* Add 0 mod 2^224-2^96+1 to ensure all differences are positive */ + output[0] = in[0] + two127p15; + output[1] = in[1] + two127m71m55; + output[2] = in[2] + two127m71; + output[3] = in[3]; + output[4] = in[4]; + + /* Eliminate in[4], in[5], in[6] */ + output[4] += in[6] >> 16; + output[3] += (in[6] & 0xffff) << 40; + output[2] -= in[6]; + + output[3] += in[5] >> 16; + output[2] += (in[5] & 0xffff) << 40; + output[1] -= in[5]; + + output[2] += output[4] >> 16; + output[1] += (output[4] & 0xffff) << 40; + output[0] -= output[4]; + + /* Carry 2 -> 3 -> 4 */ + output[3] += output[2] >> 56; + output[2] &= 0x00ffffffffffffff; + + output[4] = output[3] >> 56; + output[3] &= 0x00ffffffffffffff; + + /* Now output[2] < 2^56, output[3] < 2^56, output[4] < 2^72 */ + + /* Eliminate output[4] */ + output[2] += output[4] >> 16; + /* output[2] < 2^56 + 2^56 = 2^57 */ + output[1] += (output[4] & 0xffff) << 40; + output[0] -= output[4]; + + /* Carry 0 -> 1 -> 2 -> 3 */ + output[1] += output[0] >> 56; + out[0] = output[0] & 0x00ffffffffffffff; + + output[2] += output[1] >> 56; + /* output[2] < 2^57 + 2^72 */ + out[1] = output[1] & 0x00ffffffffffffff; + output[3] += output[2] >> 56; + /* output[3] <= 2^56 + 2^16 */ + out[2] = output[2] & 0x00ffffffffffffff; + + /* out[0] < 2^56, out[1] < 2^56, out[2] < 2^56, + * out[3] <= 2^56 + 2^16 (due to final carry), + * so out < 2*p */ + out[3] = output[3]; + } + +static void felem_square_reduce(felem out, const felem in) + { + widefelem tmp; + felem_square(tmp, in); + felem_reduce(out, tmp); + } + +static void felem_mul_reduce(felem out, const felem in1, const felem in2) + { + widefelem tmp; + felem_mul(tmp, in1, in2); + felem_reduce(out, tmp); + } + +/* Reduce to unique minimal representation. + * Requires 0 <= in < 2*p (always call felem_reduce first) */ +static void felem_contract(felem out, const felem in) + { + static const int64_t two56 = ((limb) 1) << 56; + /* 0 <= in < 2*p, p = 2^224 - 2^96 + 1 */ + /* if in > p , reduce in = in - 2^224 + 2^96 - 1 */ + int64_t tmp[4], a; + tmp[0] = in[0]; + tmp[1] = in[1]; + tmp[2] = in[2]; + tmp[3] = in[3]; + /* Case 1: a = 1 iff in >= 2^224 */ + a = (in[3] >> 56); + tmp[0] -= a; + tmp[1] += a << 40; + tmp[3] &= 0x00ffffffffffffff; + /* Case 2: a = 0 iff p <= in < 2^224, i.e., + * the high 128 bits are all 1 and the lower part is non-zero */ + a = ((in[3] & in[2] & (in[1] | 0x000000ffffffffff)) + 1) | + (((int64_t)(in[0] + (in[1] & 0x000000ffffffffff)) - 1) >> 63); + a &= 0x00ffffffffffffff; + /* turn a into an all-one mask (if a = 0) or an all-zero mask */ + a = (a - 1) >> 63; + /* subtract 2^224 - 2^96 + 1 if a is all-one*/ + tmp[3] &= a ^ 0xffffffffffffffff; + tmp[2] &= a ^ 0xffffffffffffffff; + tmp[1] &= (a ^ 0xffffffffffffffff) | 0x000000ffffffffff; + tmp[0] -= 1 & a; + + /* eliminate negative coefficients: if tmp[0] is negative, tmp[1] must + * be non-zero, so we only need one step */ + a = tmp[0] >> 63; + tmp[0] += two56 & a; + tmp[1] -= 1 & a; + + /* carry 1 -> 2 -> 3 */ + tmp[2] += tmp[1] >> 56; + tmp[1] &= 0x00ffffffffffffff; + + tmp[3] += tmp[2] >> 56; + tmp[2] &= 0x00ffffffffffffff; + + /* Now 0 <= out < p */ + out[0] = tmp[0]; + out[1] = tmp[1]; + out[2] = tmp[2]; + out[3] = tmp[3]; + } + +/* Zero-check: returns 1 if input is 0, and 0 otherwise. + * We know that field elements are reduced to in < 2^225, + * so we only need to check three cases: 0, 2^224 - 2^96 + 1, + * and 2^225 - 2^97 + 2 */ +static limb felem_is_zero(const felem in) + { + limb zero, two224m96p1, two225m97p2; + + zero = in[0] | in[1] | in[2] | in[3]; + zero = (((int64_t)(zero) - 1) >> 63) & 1; + two224m96p1 = (in[0] ^ 1) | (in[1] ^ 0x00ffff0000000000) + | (in[2] ^ 0x00ffffffffffffff) | (in[3] ^ 0x00ffffffffffffff); + two224m96p1 = (((int64_t)(two224m96p1) - 1) >> 63) & 1; + two225m97p2 = (in[0] ^ 2) | (in[1] ^ 0x00fffe0000000000) + | (in[2] ^ 0x00ffffffffffffff) | (in[3] ^ 0x01ffffffffffffff); + two225m97p2 = (((int64_t)(two225m97p2) - 1) >> 63) & 1; + return (zero | two224m96p1 | two225m97p2); + } + +static limb felem_is_zero_int(const felem in) + { + return (int) (felem_is_zero(in) & ((limb)1)); + } + +/* Invert a field element */ +/* Computation chain copied from djb's code */ +static void felem_inv(felem out, const felem in) + { + felem ftmp, ftmp2, ftmp3, ftmp4; + widefelem tmp; + unsigned i; + + felem_square(tmp, in); felem_reduce(ftmp, tmp); /* 2 */ + felem_mul(tmp, in, ftmp); felem_reduce(ftmp, tmp); /* 2^2 - 1 */ + felem_square(tmp, ftmp); felem_reduce(ftmp, tmp); /* 2^3 - 2 */ + felem_mul(tmp, in, ftmp); felem_reduce(ftmp, tmp); /* 2^3 - 1 */ + felem_square(tmp, ftmp); felem_reduce(ftmp2, tmp); /* 2^4 - 2 */ + felem_square(tmp, ftmp2); felem_reduce(ftmp2, tmp); /* 2^5 - 4 */ + felem_square(tmp, ftmp2); felem_reduce(ftmp2, tmp); /* 2^6 - 8 */ + felem_mul(tmp, ftmp2, ftmp); felem_reduce(ftmp, tmp); /* 2^6 - 1 */ + felem_square(tmp, ftmp); felem_reduce(ftmp2, tmp); /* 2^7 - 2 */ + for (i = 0; i < 5; ++i) /* 2^12 - 2^6 */ + { + felem_square(tmp, ftmp2); felem_reduce(ftmp2, tmp); + } + felem_mul(tmp, ftmp2, ftmp); felem_reduce(ftmp2, tmp); /* 2^12 - 1 */ + felem_square(tmp, ftmp2); felem_reduce(ftmp3, tmp); /* 2^13 - 2 */ + for (i = 0; i < 11; ++i) /* 2^24 - 2^12 */ + { + felem_square(tmp, ftmp3); felem_reduce(ftmp3, tmp); + } + felem_mul(tmp, ftmp3, ftmp2); felem_reduce(ftmp2, tmp); /* 2^24 - 1 */ + felem_square(tmp, ftmp2); felem_reduce(ftmp3, tmp); /* 2^25 - 2 */ + for (i = 0; i < 23; ++i) /* 2^48 - 2^24 */ + { + felem_square(tmp, ftmp3); felem_reduce(ftmp3, tmp); + } + felem_mul(tmp, ftmp3, ftmp2); felem_reduce(ftmp3, tmp); /* 2^48 - 1 */ + felem_square(tmp, ftmp3); felem_reduce(ftmp4, tmp); /* 2^49 - 2 */ + for (i = 0; i < 47; ++i) /* 2^96 - 2^48 */ + { + felem_square(tmp, ftmp4); felem_reduce(ftmp4, tmp); + } + felem_mul(tmp, ftmp3, ftmp4); felem_reduce(ftmp3, tmp); /* 2^96 - 1 */ + felem_square(tmp, ftmp3); felem_reduce(ftmp4, tmp); /* 2^97 - 2 */ + for (i = 0; i < 23; ++i) /* 2^120 - 2^24 */ + { + felem_square(tmp, ftmp4); felem_reduce(ftmp4, tmp); + } + felem_mul(tmp, ftmp2, ftmp4); felem_reduce(ftmp2, tmp); /* 2^120 - 1 */ + for (i = 0; i < 6; ++i) /* 2^126 - 2^6 */ + { + felem_square(tmp, ftmp2); felem_reduce(ftmp2, tmp); + } + felem_mul(tmp, ftmp2, ftmp); felem_reduce(ftmp, tmp); /* 2^126 - 1 */ + felem_square(tmp, ftmp); felem_reduce(ftmp, tmp); /* 2^127 - 2 */ + felem_mul(tmp, ftmp, in); felem_reduce(ftmp, tmp); /* 2^127 - 1 */ + for (i = 0; i < 97; ++i) /* 2^224 - 2^97 */ + { + felem_square(tmp, ftmp); felem_reduce(ftmp, tmp); + } + felem_mul(tmp, ftmp, ftmp3); felem_reduce(out, tmp); /* 2^224 - 2^96 - 1 */ + } + +/* Copy in constant time: + * if icopy == 1, copy in to out, + * if icopy == 0, copy out to itself. */ +static void +copy_conditional(felem out, const felem in, limb icopy) + { + unsigned i; + /* icopy is a (64-bit) 0 or 1, so copy is either all-zero or all-one */ + const limb copy = -icopy; + for (i = 0; i < 4; ++i) + { + const limb tmp = copy & (in[i] ^ out[i]); + out[i] ^= tmp; + } + } + +/******************************************************************************/ +/* ELLIPTIC CURVE POINT OPERATIONS + * + * Points are represented in Jacobian projective coordinates: + * (X, Y, Z) corresponds to the affine point (X/Z^2, Y/Z^3), + * or to the point at infinity if Z == 0. + * + */ + +/* Double an elliptic curve point: + * (X', Y', Z') = 2 * (X, Y, Z), where + * X' = (3 * (X - Z^2) * (X + Z^2))^2 - 8 * X * Y^2 + * Y' = 3 * (X - Z^2) * (X + Z^2) * (4 * X * Y^2 - X') - 8 * Y^2 + * Z' = (Y + Z)^2 - Y^2 - Z^2 = 2 * Y * Z + * Outputs can equal corresponding inputs, i.e., x_out == x_in is allowed, + * while x_out == y_in is not (maybe this works, but it's not tested). */ +static void +point_double(felem x_out, felem y_out, felem z_out, + const felem x_in, const felem y_in, const felem z_in) + { + widefelem tmp, tmp2; + felem delta, gamma, beta, alpha, ftmp, ftmp2; + + felem_assign(ftmp, x_in); + felem_assign(ftmp2, x_in); + + /* delta = z^2 */ + felem_square(tmp, z_in); + felem_reduce(delta, tmp); + + /* gamma = y^2 */ + felem_square(tmp, y_in); + felem_reduce(gamma, tmp); + + /* beta = x*gamma */ + felem_mul(tmp, x_in, gamma); + felem_reduce(beta, tmp); + + /* alpha = 3*(x-delta)*(x+delta) */ + felem_diff(ftmp, delta); + /* ftmp[i] < 2^57 + 2^58 + 2 < 2^59 */ + felem_sum(ftmp2, delta); + /* ftmp2[i] < 2^57 + 2^57 = 2^58 */ + felem_scalar(ftmp2, 3); + /* ftmp2[i] < 3 * 2^58 < 2^60 */ + felem_mul(tmp, ftmp, ftmp2); + /* tmp[i] < 2^60 * 2^59 * 4 = 2^121 */ + felem_reduce(alpha, tmp); + + /* x' = alpha^2 - 8*beta */ + felem_square(tmp, alpha); + /* tmp[i] < 4 * 2^57 * 2^57 = 2^116 */ + felem_assign(ftmp, beta); + felem_scalar(ftmp, 8); + /* ftmp[i] < 8 * 2^57 = 2^60 */ + felem_diff_128_64(tmp, ftmp); + /* tmp[i] < 2^116 + 2^64 + 8 < 2^117 */ + felem_reduce(x_out, tmp); + + /* z' = (y + z)^2 - gamma - delta */ + felem_sum(delta, gamma); + /* delta[i] < 2^57 + 2^57 = 2^58 */ + felem_assign(ftmp, y_in); + felem_sum(ftmp, z_in); + /* ftmp[i] < 2^57 + 2^57 = 2^58 */ + felem_square(tmp, ftmp); + /* tmp[i] < 4 * 2^58 * 2^58 = 2^118 */ + felem_diff_128_64(tmp, delta); + /* tmp[i] < 2^118 + 2^64 + 8 < 2^119 */ + felem_reduce(z_out, tmp); + + /* y' = alpha*(4*beta - x') - 8*gamma^2 */ + felem_scalar(beta, 4); + /* beta[i] < 4 * 2^57 = 2^59 */ + felem_diff(beta, x_out); + /* beta[i] < 2^59 + 2^58 + 2 < 2^60 */ + felem_mul(tmp, alpha, beta); + /* tmp[i] < 4 * 2^57 * 2^60 = 2^119 */ + felem_square(tmp2, gamma); + /* tmp2[i] < 4 * 2^57 * 2^57 = 2^116 */ + widefelem_scalar(tmp2, 8); + /* tmp2[i] < 8 * 2^116 = 2^119 */ + widefelem_diff(tmp, tmp2); + /* tmp[i] < 2^119 + 2^120 < 2^121 */ + felem_reduce(y_out, tmp); + } + +/* Add two elliptic curve points: + * (X_1, Y_1, Z_1) + (X_2, Y_2, Z_2) = (X_3, Y_3, Z_3), where + * X_3 = (Z_1^3 * Y_2 - Z_2^3 * Y_1)^2 - (Z_1^2 * X_2 - Z_2^2 * X_1)^3 - + * 2 * Z_2^2 * X_1 * (Z_1^2 * X_2 - Z_2^2 * X_1)^2 + * Y_3 = (Z_1^3 * Y_2 - Z_2^3 * Y_1) * (Z_2^2 * X_1 * (Z_1^2 * X_2 - Z_2^2 * X_1)^2 - X_3) - + * Z_2^3 * Y_1 * (Z_1^2 * X_2 - Z_2^2 * X_1)^3 + * Z_3 = (Z_1^2 * X_2 - Z_2^2 * X_1) * (Z_1 * Z_2) + * + * This runs faster if 'mixed' is set, which requires Z_2 = 1 or Z_2 = 0. + */ + +/* This function is not entirely constant-time: + * it includes a branch for checking whether the two input points are equal, + * (while not equal to the point at infinity). + * This case never happens during single point multiplication, + * so there is no timing leak for ECDH or ECDSA signing. */ +static void point_add(felem x3, felem y3, felem z3, + const felem x1, const felem y1, const felem z1, + const int mixed, const felem x2, const felem y2, const felem z2) + { + felem ftmp, ftmp2, ftmp3, ftmp4, ftmp5, x_out, y_out, z_out; + widefelem tmp, tmp2; + limb z1_is_zero, z2_is_zero, x_equal, y_equal; + + if (!mixed) + { + /* ftmp2 = z2^2 */ + felem_square(tmp, z2); + felem_reduce(ftmp2, tmp); + + /* ftmp4 = z2^3 */ + felem_mul(tmp, ftmp2, z2); + felem_reduce(ftmp4, tmp); + + /* ftmp4 = z2^3*y1 */ + felem_mul(tmp2, ftmp4, y1); + felem_reduce(ftmp4, tmp2); + + /* ftmp2 = z2^2*x1 */ + felem_mul(tmp2, ftmp2, x1); + felem_reduce(ftmp2, tmp2); + } + else + { + /* We'll assume z2 = 1 (special case z2 = 0 is handled later) */ + + /* ftmp4 = z2^3*y1 */ + felem_assign(ftmp4, y1); + + /* ftmp2 = z2^2*x1 */ + felem_assign(ftmp2, x1); + } + + /* ftmp = z1^2 */ + felem_square(tmp, z1); + felem_reduce(ftmp, tmp); + + /* ftmp3 = z1^3 */ + felem_mul(tmp, ftmp, z1); + felem_reduce(ftmp3, tmp); + + /* tmp = z1^3*y2 */ + felem_mul(tmp, ftmp3, y2); + /* tmp[i] < 4 * 2^57 * 2^57 = 2^116 */ + + /* ftmp3 = z1^3*y2 - z2^3*y1 */ + felem_diff_128_64(tmp, ftmp4); + /* tmp[i] < 2^116 + 2^64 + 8 < 2^117 */ + felem_reduce(ftmp3, tmp); + + /* tmp = z1^2*x2 */ + felem_mul(tmp, ftmp, x2); + /* tmp[i] < 4 * 2^57 * 2^57 = 2^116 */ + + /* ftmp = z1^2*x2 - z2^2*x1 */ + felem_diff_128_64(tmp, ftmp2); + /* tmp[i] < 2^116 + 2^64 + 8 < 2^117 */ + felem_reduce(ftmp, tmp); + + /* the formulae are incorrect if the points are equal + * so we check for this and do doubling if this happens */ + x_equal = felem_is_zero(ftmp); + y_equal = felem_is_zero(ftmp3); + z1_is_zero = felem_is_zero(z1); + z2_is_zero = felem_is_zero(z2); + /* In affine coordinates, (X_1, Y_1) == (X_2, Y_2) */ + if (x_equal && y_equal && !z1_is_zero && !z2_is_zero) + { + point_double(x3, y3, z3, x1, y1, z1); + return; + } + + /* ftmp5 = z1*z2 */ + if (!mixed) + { + felem_mul(tmp, z1, z2); + felem_reduce(ftmp5, tmp); + } + else + { + /* special case z2 = 0 is handled later */ + felem_assign(ftmp5, z1); + } + + /* z_out = (z1^2*x2 - z2^2*x1)*(z1*z2) */ + felem_mul(tmp, ftmp, ftmp5); + felem_reduce(z_out, tmp); + + /* ftmp = (z1^2*x2 - z2^2*x1)^2 */ + felem_assign(ftmp5, ftmp); + felem_square(tmp, ftmp); + felem_reduce(ftmp, tmp); + + /* ftmp5 = (z1^2*x2 - z2^2*x1)^3 */ + felem_mul(tmp, ftmp, ftmp5); + felem_reduce(ftmp5, tmp); + + /* ftmp2 = z2^2*x1*(z1^2*x2 - z2^2*x1)^2 */ + felem_mul(tmp, ftmp2, ftmp); + felem_reduce(ftmp2, tmp); + + /* tmp = z2^3*y1*(z1^2*x2 - z2^2*x1)^3 */ + felem_mul(tmp, ftmp4, ftmp5); + /* tmp[i] < 4 * 2^57 * 2^57 = 2^116 */ + + /* tmp2 = (z1^3*y2 - z2^3*y1)^2 */ + felem_square(tmp2, ftmp3); + /* tmp2[i] < 4 * 2^57 * 2^57 < 2^116 */ + + /* tmp2 = (z1^3*y2 - z2^3*y1)^2 - (z1^2*x2 - z2^2*x1)^3 */ + felem_diff_128_64(tmp2, ftmp5); + /* tmp2[i] < 2^116 + 2^64 + 8 < 2^117 */ + + /* ftmp5 = 2*z2^2*x1*(z1^2*x2 - z2^2*x1)^2 */ + felem_assign(ftmp5, ftmp2); + felem_scalar(ftmp5, 2); + /* ftmp5[i] < 2 * 2^57 = 2^58 */ + + /* x_out = (z1^3*y2 - z2^3*y1)^2 - (z1^2*x2 - z2^2*x1)^3 - + 2*z2^2*x1*(z1^2*x2 - z2^2*x1)^2 */ + felem_diff_128_64(tmp2, ftmp5); + /* tmp2[i] < 2^117 + 2^64 + 8 < 2^118 */ + felem_reduce(x_out, tmp2); + + /* ftmp2 = z2^2*x1*(z1^2*x2 - z2^2*x1)^2 - x_out */ + felem_diff(ftmp2, x_out); + /* ftmp2[i] < 2^57 + 2^58 + 2 < 2^59 */ + + /* tmp2 = (z1^3*y2 - z2^3*y1)*(z2^2*x1*(z1^2*x2 - z2^2*x1)^2 - x_out) */ + felem_mul(tmp2, ftmp3, ftmp2); + /* tmp2[i] < 4 * 2^57 * 2^59 = 2^118 */ + + /* y_out = (z1^3*y2 - z2^3*y1)*(z2^2*x1*(z1^2*x2 - z2^2*x1)^2 - x_out) - + z2^3*y1*(z1^2*x2 - z2^2*x1)^3 */ + widefelem_diff(tmp2, tmp); + /* tmp2[i] < 2^118 + 2^120 < 2^121 */ + felem_reduce(y_out, tmp2); + + /* the result (x_out, y_out, z_out) is incorrect if one of the inputs is + * the point at infinity, so we need to check for this separately */ + + /* if point 1 is at infinity, copy point 2 to output, and vice versa */ + copy_conditional(x_out, x2, z1_is_zero); + copy_conditional(x_out, x1, z2_is_zero); + copy_conditional(y_out, y2, z1_is_zero); + copy_conditional(y_out, y1, z2_is_zero); + copy_conditional(z_out, z2, z1_is_zero); + copy_conditional(z_out, z1, z2_is_zero); + felem_assign(x3, x_out); + felem_assign(y3, y_out); + felem_assign(z3, z_out); + } + +/* select_point selects the |idx|th point from a precomputation table and + * copies it to out. */ +static void select_point(const u64 idx, unsigned int size, const felem pre_comp[/*size*/][3], felem out[3]) + { + unsigned i, j; + limb *outlimbs = &out[0][0]; + memset(outlimbs, 0, 3 * sizeof(felem)); + + for (i = 0; i < size; i++) + { + const limb *inlimbs = &pre_comp[i][0][0]; + u64 mask = i ^ idx; + mask |= mask >> 4; + mask |= mask >> 2; + mask |= mask >> 1; + mask &= 1; + mask--; + for (j = 0; j < 4 * 3; j++) + outlimbs[j] |= inlimbs[j] & mask; + } + } + +/* get_bit returns the |i|th bit in |in| */ +static char get_bit(const felem_bytearray in, unsigned i) + { + if (i >= 224) + return 0; + return (in[i >> 3] >> (i & 7)) & 1; + } + +/* Interleaved point multiplication using precomputed point multiples: + * The small point multiples 0*P, 1*P, ..., 16*P are in pre_comp[], + * the scalars in scalars[]. If g_scalar is non-NULL, we also add this multiple + * of the generator, using certain (large) precomputed multiples in g_pre_comp. + * Output point (X, Y, Z) is stored in x_out, y_out, z_out */ +static void batch_mul(felem x_out, felem y_out, felem z_out, + const felem_bytearray scalars[], const unsigned num_points, const u8 *g_scalar, + const int mixed, const felem pre_comp[][17][3], const felem g_pre_comp[2][16][3]) + { + int i, skip; + unsigned num; + unsigned gen_mul = (g_scalar != NULL); + felem nq[3], tmp[4]; + u64 bits; + u8 sign, digit; + + /* set nq to the point at infinity */ + memset(nq, 0, 3 * sizeof(felem)); + + /* Loop over all scalars msb-to-lsb, interleaving additions + * of multiples of the generator (two in each of the last 28 rounds) + * and additions of other points multiples (every 5th round). + */ + skip = 1; /* save two point operations in the first round */ + for (i = (num_points ? 220 : 27); i >= 0; --i) + { + /* double */ + if (!skip) + point_double(nq[0], nq[1], nq[2], nq[0], nq[1], nq[2]); + + /* add multiples of the generator */ + if (gen_mul && (i <= 27)) + { + /* first, look 28 bits upwards */ + bits = get_bit(g_scalar, i + 196) << 3; + bits |= get_bit(g_scalar, i + 140) << 2; + bits |= get_bit(g_scalar, i + 84) << 1; + bits |= get_bit(g_scalar, i + 28); + /* select the point to add, in constant time */ + select_point(bits, 16, g_pre_comp[1], tmp); + + if (!skip) + { + point_add(nq[0], nq[1], nq[2], + nq[0], nq[1], nq[2], + 1 /* mixed */, tmp[0], tmp[1], tmp[2]); + } + else + { + memcpy(nq, tmp, 3 * sizeof(felem)); + skip = 0; + } + + /* second, look at the current position */ + bits = get_bit(g_scalar, i + 168) << 3; + bits |= get_bit(g_scalar, i + 112) << 2; + bits |= get_bit(g_scalar, i + 56) << 1; + bits |= get_bit(g_scalar, i); + /* select the point to add, in constant time */ + select_point(bits, 16, g_pre_comp[0], tmp); + point_add(nq[0], nq[1], nq[2], + nq[0], nq[1], nq[2], + 1 /* mixed */, tmp[0], tmp[1], tmp[2]); + } + + /* do other additions every 5 doublings */ + if (num_points && (i % 5 == 0)) + { + /* loop over all scalars */ + for (num = 0; num < num_points; ++num) + { + bits = get_bit(scalars[num], i + 4) << 5; + bits |= get_bit(scalars[num], i + 3) << 4; + bits |= get_bit(scalars[num], i + 2) << 3; + bits |= get_bit(scalars[num], i + 1) << 2; + bits |= get_bit(scalars[num], i) << 1; + bits |= get_bit(scalars[num], i - 1); + ec_GFp_nistp_recode_scalar_bits(&sign, &digit, bits); + + /* select the point to add or subtract */ + select_point(digit, 17, pre_comp[num], tmp); + felem_neg(tmp[3], tmp[1]); /* (X, -Y, Z) is the negative point */ + copy_conditional(tmp[1], tmp[3], sign); + + if (!skip) + { + point_add(nq[0], nq[1], nq[2], + nq[0], nq[1], nq[2], + mixed, tmp[0], tmp[1], tmp[2]); + } + else + { + memcpy(nq, tmp, 3 * sizeof(felem)); + skip = 0; + } + } + } + } + felem_assign(x_out, nq[0]); + felem_assign(y_out, nq[1]); + felem_assign(z_out, nq[2]); + } + +/******************************************************************************/ +/* FUNCTIONS TO MANAGE PRECOMPUTATION + */ + +static NISTP224_PRE_COMP *nistp224_pre_comp_new() + { + NISTP224_PRE_COMP *ret = NULL; + ret = (NISTP224_PRE_COMP *) OPENSSL_malloc(sizeof *ret); + if (!ret) + { + ECerr(EC_F_NISTP224_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE); + return ret; + } + memset(ret->g_pre_comp, 0, sizeof(ret->g_pre_comp)); + ret->references = 1; + return ret; + } + +static void *nistp224_pre_comp_dup(void *src_) + { + NISTP224_PRE_COMP *src = src_; + + /* no need to actually copy, these objects never change! */ + CRYPTO_add(&src->references, 1, CRYPTO_LOCK_EC_PRE_COMP); + + return src_; + } + +static void nistp224_pre_comp_free(void *pre_) + { + int i; + NISTP224_PRE_COMP *pre = pre_; + + if (!pre) + return; + + i = CRYPTO_add(&pre->references, -1, CRYPTO_LOCK_EC_PRE_COMP); + if (i > 0) + return; + + OPENSSL_free(pre); + } + +static void nistp224_pre_comp_clear_free(void *pre_) + { + int i; + NISTP224_PRE_COMP *pre = pre_; + + if (!pre) + return; + + i = CRYPTO_add(&pre->references, -1, CRYPTO_LOCK_EC_PRE_COMP); + if (i > 0) + return; + + OPENSSL_cleanse(pre, sizeof *pre); + OPENSSL_free(pre); + } + +/******************************************************************************/ +/* OPENSSL EC_METHOD FUNCTIONS + */ + +int ec_GFp_nistp224_group_init(EC_GROUP *group) + { + int ret; + ret = ec_GFp_simple_group_init(group); + group->a_is_minus3 = 1; + return ret; + } + +int ec_GFp_nistp224_group_set_curve(EC_GROUP *group, const BIGNUM *p, + const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) + { + int ret = 0; + BN_CTX *new_ctx = NULL; + BIGNUM *curve_p, *curve_a, *curve_b; + + if (ctx == NULL) + if ((ctx = new_ctx = BN_CTX_new()) == NULL) return 0; + BN_CTX_start(ctx); + if (((curve_p = BN_CTX_get(ctx)) == NULL) || + ((curve_a = BN_CTX_get(ctx)) == NULL) || + ((curve_b = BN_CTX_get(ctx)) == NULL)) goto err; + BN_bin2bn(nistp224_curve_params[0], sizeof(felem_bytearray), curve_p); + BN_bin2bn(nistp224_curve_params[1], sizeof(felem_bytearray), curve_a); + BN_bin2bn(nistp224_curve_params[2], sizeof(felem_bytearray), curve_b); + if ((BN_cmp(curve_p, p)) || (BN_cmp(curve_a, a)) || + (BN_cmp(curve_b, b))) + { + ECerr(EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE, + EC_R_WRONG_CURVE_PARAMETERS); + goto err; + } + group->field_mod_func = BN_nist_mod_224; + ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx); +err: + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return ret; + } + +/* Takes the Jacobian coordinates (X, Y, Z) of a point and returns + * (X', Y') = (X/Z^2, Y/Z^3) */ +int ec_GFp_nistp224_point_get_affine_coordinates(const EC_GROUP *group, + const EC_POINT *point, BIGNUM *x, BIGNUM *y, BN_CTX *ctx) + { + felem z1, z2, x_in, y_in, x_out, y_out; + widefelem tmp; + + if (EC_POINT_is_at_infinity(group, point)) + { + ECerr(EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES, + EC_R_POINT_AT_INFINITY); + return 0; + } + if ((!BN_to_felem(x_in, &point->X)) || (!BN_to_felem(y_in, &point->Y)) || + (!BN_to_felem(z1, &point->Z))) return 0; + felem_inv(z2, z1); + felem_square(tmp, z2); felem_reduce(z1, tmp); + felem_mul(tmp, x_in, z1); felem_reduce(x_in, tmp); + felem_contract(x_out, x_in); + if (x != NULL) + { + if (!felem_to_BN(x, x_out)) { + ECerr(EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES, + ERR_R_BN_LIB); + return 0; + } + } + felem_mul(tmp, z1, z2); felem_reduce(z1, tmp); + felem_mul(tmp, y_in, z1); felem_reduce(y_in, tmp); + felem_contract(y_out, y_in); + if (y != NULL) + { + if (!felem_to_BN(y, y_out)) { + ECerr(EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES, + ERR_R_BN_LIB); + return 0; + } + } + return 1; + } + +static void make_points_affine(size_t num, felem points[/*num*/][3], felem tmp_felems[/*num+1*/]) + { + /* Runs in constant time, unless an input is the point at infinity + * (which normally shouldn't happen). */ + ec_GFp_nistp_points_make_affine_internal( + num, + points, + sizeof(felem), + tmp_felems, + (void (*)(void *)) felem_one, + (int (*)(const void *)) felem_is_zero_int, + (void (*)(void *, const void *)) felem_assign, + (void (*)(void *, const void *)) felem_square_reduce, + (void (*)(void *, const void *, const void *)) felem_mul_reduce, + (void (*)(void *, const void *)) felem_inv, + (void (*)(void *, const void *)) felem_contract); + } + +/* Computes scalar*generator + \sum scalars[i]*points[i], ignoring NULL values + * Result is stored in r (r can equal one of the inputs). */ +int ec_GFp_nistp224_points_mul(const EC_GROUP *group, EC_POINT *r, + const BIGNUM *scalar, size_t num, const EC_POINT *points[], + const BIGNUM *scalars[], BN_CTX *ctx) + { + int ret = 0; + int j; + unsigned i; + int mixed = 0; + BN_CTX *new_ctx = NULL; + BIGNUM *x, *y, *z, *tmp_scalar; + felem_bytearray g_secret; + felem_bytearray *secrets = NULL; + felem (*pre_comp)[17][3] = NULL; + felem *tmp_felems = NULL; + felem_bytearray tmp; + unsigned num_bytes; + int have_pre_comp = 0; + size_t num_points = num; + felem x_in, y_in, z_in, x_out, y_out, z_out; + NISTP224_PRE_COMP *pre = NULL; + const felem (*g_pre_comp)[16][3] = NULL; + EC_POINT *generator = NULL; + const EC_POINT *p = NULL; + const BIGNUM *p_scalar = NULL; + + if (ctx == NULL) + if ((ctx = new_ctx = BN_CTX_new()) == NULL) return 0; + BN_CTX_start(ctx); + if (((x = BN_CTX_get(ctx)) == NULL) || + ((y = BN_CTX_get(ctx)) == NULL) || + ((z = BN_CTX_get(ctx)) == NULL) || + ((tmp_scalar = BN_CTX_get(ctx)) == NULL)) + goto err; + + if (scalar != NULL) + { + pre = EC_EX_DATA_get_data(group->extra_data, + nistp224_pre_comp_dup, nistp224_pre_comp_free, + nistp224_pre_comp_clear_free); + if (pre) + /* we have precomputation, try to use it */ + g_pre_comp = (const felem (*)[16][3]) pre->g_pre_comp; + else + /* try to use the standard precomputation */ + g_pre_comp = &gmul[0]; + generator = EC_POINT_new(group); + if (generator == NULL) + goto err; + /* get the generator from precomputation */ + if (!felem_to_BN(x, g_pre_comp[0][1][0]) || + !felem_to_BN(y, g_pre_comp[0][1][1]) || + !felem_to_BN(z, g_pre_comp[0][1][2])) + { + ECerr(EC_F_EC_GFP_NISTP224_POINTS_MUL, ERR_R_BN_LIB); + goto err; + } + if (!EC_POINT_set_Jprojective_coordinates_GFp(group, + generator, x, y, z, ctx)) + goto err; + if (0 == EC_POINT_cmp(group, generator, group->generator, ctx)) + /* precomputation matches generator */ + have_pre_comp = 1; + else + /* we don't have valid precomputation: + * treat the generator as a random point */ + num_points = num_points + 1; + } + + if (num_points > 0) + { + if (num_points >= 3) + { + /* unless we precompute multiples for just one or two points, + * converting those into affine form is time well spent */ + mixed = 1; + } + secrets = OPENSSL_malloc(num_points * sizeof(felem_bytearray)); + pre_comp = OPENSSL_malloc(num_points * 17 * 3 * sizeof(felem)); + if (mixed) + tmp_felems = OPENSSL_malloc((num_points * 17 + 1) * sizeof(felem)); + if ((secrets == NULL) || (pre_comp == NULL) || (mixed && (tmp_felems == NULL))) + { + ECerr(EC_F_EC_GFP_NISTP224_POINTS_MUL, ERR_R_MALLOC_FAILURE); + goto err; + } + + /* we treat NULL scalars as 0, and NULL points as points at infinity, + * i.e., they contribute nothing to the linear combination */ + memset(secrets, 0, num_points * sizeof(felem_bytearray)); + memset(pre_comp, 0, num_points * 17 * 3 * sizeof(felem)); + for (i = 0; i < num_points; ++i) + { + if (i == num) + /* the generator */ + { + p = EC_GROUP_get0_generator(group); + p_scalar = scalar; + } + else + /* the i^th point */ + { + p = points[i]; + p_scalar = scalars[i]; + } + if ((p_scalar != NULL) && (p != NULL)) + { + /* reduce scalar to 0 <= scalar < 2^224 */ + if ((BN_num_bits(p_scalar) > 224) || (BN_is_negative(p_scalar))) + { + /* this is an unusual input, and we don't guarantee + * constant-timeness */ + if (!BN_nnmod(tmp_scalar, p_scalar, &group->order, ctx)) + { + ECerr(EC_F_EC_GFP_NISTP224_POINTS_MUL, ERR_R_BN_LIB); + goto err; + } + num_bytes = BN_bn2bin(tmp_scalar, tmp); + } + else + num_bytes = BN_bn2bin(p_scalar, tmp); + flip_endian(secrets[i], tmp, num_bytes); + /* precompute multiples */ + if ((!BN_to_felem(x_out, &p->X)) || + (!BN_to_felem(y_out, &p->Y)) || + (!BN_to_felem(z_out, &p->Z))) goto err; + felem_assign(pre_comp[i][1][0], x_out); + felem_assign(pre_comp[i][1][1], y_out); + felem_assign(pre_comp[i][1][2], z_out); + for (j = 2; j <= 16; ++j) + { + if (j & 1) + { + point_add( + pre_comp[i][j][0], pre_comp[i][j][1], pre_comp[i][j][2], + pre_comp[i][1][0], pre_comp[i][1][1], pre_comp[i][1][2], + 0, pre_comp[i][j-1][0], pre_comp[i][j-1][1], pre_comp[i][j-1][2]); + } + else + { + point_double( + pre_comp[i][j][0], pre_comp[i][j][1], pre_comp[i][j][2], + pre_comp[i][j/2][0], pre_comp[i][j/2][1], pre_comp[i][j/2][2]); + } + } + } + } + if (mixed) + make_points_affine(num_points * 17, pre_comp[0], tmp_felems); + } + + /* the scalar for the generator */ + if ((scalar != NULL) && (have_pre_comp)) + { + memset(g_secret, 0, sizeof g_secret); + /* reduce scalar to 0 <= scalar < 2^224 */ + if ((BN_num_bits(scalar) > 224) || (BN_is_negative(scalar))) + { + /* this is an unusual input, and we don't guarantee + * constant-timeness */ + if (!BN_nnmod(tmp_scalar, scalar, &group->order, ctx)) + { + ECerr(EC_F_EC_GFP_NISTP224_POINTS_MUL, ERR_R_BN_LIB); + goto err; + } + num_bytes = BN_bn2bin(tmp_scalar, tmp); + } + else + num_bytes = BN_bn2bin(scalar, tmp); + flip_endian(g_secret, tmp, num_bytes); + /* do the multiplication with generator precomputation*/ + batch_mul(x_out, y_out, z_out, + (const felem_bytearray (*)) secrets, num_points, + g_secret, + mixed, (const felem (*)[17][3]) pre_comp, + g_pre_comp); + } + else + /* do the multiplication without generator precomputation */ + batch_mul(x_out, y_out, z_out, + (const felem_bytearray (*)) secrets, num_points, + NULL, mixed, (const felem (*)[17][3]) pre_comp, NULL); + /* reduce the output to its unique minimal representation */ + felem_contract(x_in, x_out); + felem_contract(y_in, y_out); + felem_contract(z_in, z_out); + if ((!felem_to_BN(x, x_in)) || (!felem_to_BN(y, y_in)) || + (!felem_to_BN(z, z_in))) + { + ECerr(EC_F_EC_GFP_NISTP224_POINTS_MUL, ERR_R_BN_LIB); + goto err; + } + ret = EC_POINT_set_Jprojective_coordinates_GFp(group, r, x, y, z, ctx); + +err: + BN_CTX_end(ctx); + if (generator != NULL) + EC_POINT_free(generator); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + if (secrets != NULL) + OPENSSL_free(secrets); + if (pre_comp != NULL) + OPENSSL_free(pre_comp); + if (tmp_felems != NULL) + OPENSSL_free(tmp_felems); + return ret; + } + +int ec_GFp_nistp224_precompute_mult(EC_GROUP *group, BN_CTX *ctx) + { + int ret = 0; + NISTP224_PRE_COMP *pre = NULL; + int i, j; + BN_CTX *new_ctx = NULL; + BIGNUM *x, *y; + EC_POINT *generator = NULL; + felem tmp_felems[32]; + + /* throw away old precomputation */ + EC_EX_DATA_free_data(&group->extra_data, nistp224_pre_comp_dup, + nistp224_pre_comp_free, nistp224_pre_comp_clear_free); + if (ctx == NULL) + if ((ctx = new_ctx = BN_CTX_new()) == NULL) return 0; + BN_CTX_start(ctx); + if (((x = BN_CTX_get(ctx)) == NULL) || + ((y = BN_CTX_get(ctx)) == NULL)) + goto err; + /* get the generator */ + if (group->generator == NULL) goto err; + generator = EC_POINT_new(group); + if (generator == NULL) + goto err; + BN_bin2bn(nistp224_curve_params[3], sizeof (felem_bytearray), x); + BN_bin2bn(nistp224_curve_params[4], sizeof (felem_bytearray), y); + if (!EC_POINT_set_affine_coordinates_GFp(group, generator, x, y, ctx)) + goto err; + if ((pre = nistp224_pre_comp_new()) == NULL) + goto err; + /* if the generator is the standard one, use built-in precomputation */ + if (0 == EC_POINT_cmp(group, generator, group->generator, ctx)) + { + memcpy(pre->g_pre_comp, gmul, sizeof(pre->g_pre_comp)); + ret = 1; + goto err; + } + if ((!BN_to_felem(pre->g_pre_comp[0][1][0], &group->generator->X)) || + (!BN_to_felem(pre->g_pre_comp[0][1][1], &group->generator->Y)) || + (!BN_to_felem(pre->g_pre_comp[0][1][2], &group->generator->Z))) + goto err; + /* compute 2^56*G, 2^112*G, 2^168*G for the first table, + * 2^28*G, 2^84*G, 2^140*G, 2^196*G for the second one + */ + for (i = 1; i <= 8; i <<= 1) + { + point_double( + pre->g_pre_comp[1][i][0], pre->g_pre_comp[1][i][1], pre->g_pre_comp[1][i][2], + pre->g_pre_comp[0][i][0], pre->g_pre_comp[0][i][1], pre->g_pre_comp[0][i][2]); + for (j = 0; j < 27; ++j) + { + point_double( + pre->g_pre_comp[1][i][0], pre->g_pre_comp[1][i][1], pre->g_pre_comp[1][i][2], + pre->g_pre_comp[1][i][0], pre->g_pre_comp[1][i][1], pre->g_pre_comp[1][i][2]); + } + if (i == 8) + break; + point_double( + pre->g_pre_comp[0][2*i][0], pre->g_pre_comp[0][2*i][1], pre->g_pre_comp[0][2*i][2], + pre->g_pre_comp[1][i][0], pre->g_pre_comp[1][i][1], pre->g_pre_comp[1][i][2]); + for (j = 0; j < 27; ++j) + { + point_double( + pre->g_pre_comp[0][2*i][0], pre->g_pre_comp[0][2*i][1], pre->g_pre_comp[0][2*i][2], + pre->g_pre_comp[0][2*i][0], pre->g_pre_comp[0][2*i][1], pre->g_pre_comp[0][2*i][2]); + } + } + for (i = 0; i < 2; i++) + { + /* g_pre_comp[i][0] is the point at infinity */ + memset(pre->g_pre_comp[i][0], 0, sizeof(pre->g_pre_comp[i][0])); + /* the remaining multiples */ + /* 2^56*G + 2^112*G resp. 2^84*G + 2^140*G */ + point_add( + pre->g_pre_comp[i][6][0], pre->g_pre_comp[i][6][1], + pre->g_pre_comp[i][6][2], pre->g_pre_comp[i][4][0], + pre->g_pre_comp[i][4][1], pre->g_pre_comp[i][4][2], + 0, pre->g_pre_comp[i][2][0], pre->g_pre_comp[i][2][1], + pre->g_pre_comp[i][2][2]); + /* 2^56*G + 2^168*G resp. 2^84*G + 2^196*G */ + point_add( + pre->g_pre_comp[i][10][0], pre->g_pre_comp[i][10][1], + pre->g_pre_comp[i][10][2], pre->g_pre_comp[i][8][0], + pre->g_pre_comp[i][8][1], pre->g_pre_comp[i][8][2], + 0, pre->g_pre_comp[i][2][0], pre->g_pre_comp[i][2][1], + pre->g_pre_comp[i][2][2]); + /* 2^112*G + 2^168*G resp. 2^140*G + 2^196*G */ + point_add( + pre->g_pre_comp[i][12][0], pre->g_pre_comp[i][12][1], + pre->g_pre_comp[i][12][2], pre->g_pre_comp[i][8][0], + pre->g_pre_comp[i][8][1], pre->g_pre_comp[i][8][2], + 0, pre->g_pre_comp[i][4][0], pre->g_pre_comp[i][4][1], + pre->g_pre_comp[i][4][2]); + /* 2^56*G + 2^112*G + 2^168*G resp. 2^84*G + 2^140*G + 2^196*G */ + point_add( + pre->g_pre_comp[i][14][0], pre->g_pre_comp[i][14][1], + pre->g_pre_comp[i][14][2], pre->g_pre_comp[i][12][0], + pre->g_pre_comp[i][12][1], pre->g_pre_comp[i][12][2], + 0, pre->g_pre_comp[i][2][0], pre->g_pre_comp[i][2][1], + pre->g_pre_comp[i][2][2]); + for (j = 1; j < 8; ++j) + { + /* odd multiples: add G resp. 2^28*G */ + point_add( + pre->g_pre_comp[i][2*j+1][0], pre->g_pre_comp[i][2*j+1][1], + pre->g_pre_comp[i][2*j+1][2], pre->g_pre_comp[i][2*j][0], + pre->g_pre_comp[i][2*j][1], pre->g_pre_comp[i][2*j][2], + 0, pre->g_pre_comp[i][1][0], pre->g_pre_comp[i][1][1], + pre->g_pre_comp[i][1][2]); + } + } + make_points_affine(31, &(pre->g_pre_comp[0][1]), tmp_felems); + + if (!EC_EX_DATA_set_data(&group->extra_data, pre, nistp224_pre_comp_dup, + nistp224_pre_comp_free, nistp224_pre_comp_clear_free)) + goto err; + ret = 1; + pre = NULL; + err: + BN_CTX_end(ctx); + if (generator != NULL) + EC_POINT_free(generator); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + if (pre) + nistp224_pre_comp_free(pre); + return ret; + } + +int ec_GFp_nistp224_have_precompute_mult(const EC_GROUP *group) + { + if (EC_EX_DATA_get_data(group->extra_data, nistp224_pre_comp_dup, + nistp224_pre_comp_free, nistp224_pre_comp_clear_free) + != NULL) + return 1; + else + return 0; + } + +#else +static void *dummy=&dummy; +#endif diff --git a/libs/openssl/crypto/ec/ecp_nistp256.c b/libs/openssl/crypto/ec/ecp_nistp256.c new file mode 100644 index 00000000..4bc0f5dc --- /dev/null +++ b/libs/openssl/crypto/ec/ecp_nistp256.c @@ -0,0 +1,2171 @@ +/* crypto/ec/ecp_nistp256.c */ +/* + * Written by Adam Langley (Google) for the OpenSSL project + */ +/* Copyright 2011 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * A 64-bit implementation of the NIST P-256 elliptic curve point multiplication + * + * OpenSSL integration was taken from Emilia Kasper's work in ecp_nistp224.c. + * Otherwise based on Emilia's P224 work, which was inspired by my curve25519 + * work which got its smarts from Daniel J. Bernstein's work on the same. + */ + +#include +#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 + +#ifndef OPENSSL_SYS_VMS +#include +#else +#include +#endif + +#include +#include +#include "ec_lcl.h" + +#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) + /* even with gcc, the typedef won't work for 32-bit platforms */ + typedef __uint128_t uint128_t; /* nonstandard; implemented by gcc on 64-bit platforms */ + typedef __int128_t int128_t; +#else + #error "Need GCC 3.1 or later to define type uint128_t" +#endif + +typedef uint8_t u8; +typedef uint32_t u32; +typedef uint64_t u64; +typedef int64_t s64; + +/* The underlying field. + * + * P256 operates over GF(2^256-2^224+2^192+2^96-1). We can serialise an element + * of this field into 32 bytes. We call this an felem_bytearray. */ + +typedef u8 felem_bytearray[32]; + +/* These are the parameters of P256, taken from FIPS 186-3, page 86. These + * values are big-endian. */ +static const felem_bytearray nistp256_curve_params[5] = { + {0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, /* p */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, + {0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, /* a = -3 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc}, /* b */ + {0x5a, 0xc6, 0x35, 0xd8, 0xaa, 0x3a, 0x93, 0xe7, + 0xb3, 0xeb, 0xbd, 0x55, 0x76, 0x98, 0x86, 0xbc, + 0x65, 0x1d, 0x06, 0xb0, 0xcc, 0x53, 0xb0, 0xf6, + 0x3b, 0xce, 0x3c, 0x3e, 0x27, 0xd2, 0x60, 0x4b}, + {0x6b, 0x17, 0xd1, 0xf2, 0xe1, 0x2c, 0x42, 0x47, /* x */ + 0xf8, 0xbc, 0xe6, 0xe5, 0x63, 0xa4, 0x40, 0xf2, + 0x77, 0x03, 0x7d, 0x81, 0x2d, 0xeb, 0x33, 0xa0, + 0xf4, 0xa1, 0x39, 0x45, 0xd8, 0x98, 0xc2, 0x96}, + {0x4f, 0xe3, 0x42, 0xe2, 0xfe, 0x1a, 0x7f, 0x9b, /* y */ + 0x8e, 0xe7, 0xeb, 0x4a, 0x7c, 0x0f, 0x9e, 0x16, + 0x2b, 0xce, 0x33, 0x57, 0x6b, 0x31, 0x5e, 0xce, + 0xcb, 0xb6, 0x40, 0x68, 0x37, 0xbf, 0x51, 0xf5} +}; + +/* The representation of field elements. + * ------------------------------------ + * + * We represent field elements with either four 128-bit values, eight 128-bit + * values, or four 64-bit values. The field element represented is: + * v[0]*2^0 + v[1]*2^64 + v[2]*2^128 + v[3]*2^192 (mod p) + * or: + * v[0]*2^0 + v[1]*2^64 + v[2]*2^128 + ... + v[8]*2^512 (mod p) + * + * 128-bit values are called 'limbs'. Since the limbs are spaced only 64 bits + * apart, but are 128-bits wide, the most significant bits of each limb overlap + * with the least significant bits of the next. + * + * A field element with four limbs is an 'felem'. One with eight limbs is a + * 'longfelem' + * + * A field element with four, 64-bit values is called a 'smallfelem'. Small + * values are used as intermediate values before multiplication. + */ + +#define NLIMBS 4 + +typedef uint128_t limb; +typedef limb felem[NLIMBS]; +typedef limb longfelem[NLIMBS * 2]; +typedef u64 smallfelem[NLIMBS]; + +/* This is the value of the prime as four 64-bit words, little-endian. */ +static const u64 kPrime[4] = { 0xfffffffffffffffful, 0xffffffff, 0, 0xffffffff00000001ul }; +static const limb bottom32bits = 0xffffffff; +static const u64 bottom63bits = 0x7ffffffffffffffful; + +/* bin32_to_felem takes a little-endian byte array and converts it into felem + * form. This assumes that the CPU is little-endian. */ +static void bin32_to_felem(felem out, const u8 in[32]) + { + out[0] = *((u64*) &in[0]); + out[1] = *((u64*) &in[8]); + out[2] = *((u64*) &in[16]); + out[3] = *((u64*) &in[24]); + } + +/* smallfelem_to_bin32 takes a smallfelem and serialises into a little endian, + * 32 byte array. This assumes that the CPU is little-endian. */ +static void smallfelem_to_bin32(u8 out[32], const smallfelem in) + { + *((u64*) &out[0]) = in[0]; + *((u64*) &out[8]) = in[1]; + *((u64*) &out[16]) = in[2]; + *((u64*) &out[24]) = in[3]; + } + +/* To preserve endianness when using BN_bn2bin and BN_bin2bn */ +static void flip_endian(u8 *out, const u8 *in, unsigned len) + { + unsigned i; + for (i = 0; i < len; ++i) + out[i] = in[len-1-i]; + } + +/* BN_to_felem converts an OpenSSL BIGNUM into an felem */ +static int BN_to_felem(felem out, const BIGNUM *bn) + { + felem_bytearray b_in; + felem_bytearray b_out; + unsigned num_bytes; + + /* BN_bn2bin eats leading zeroes */ + memset(b_out, 0, sizeof b_out); + num_bytes = BN_num_bytes(bn); + if (num_bytes > sizeof b_out) + { + ECerr(EC_F_BN_TO_FELEM, EC_R_BIGNUM_OUT_OF_RANGE); + return 0; + } + if (BN_is_negative(bn)) + { + ECerr(EC_F_BN_TO_FELEM, EC_R_BIGNUM_OUT_OF_RANGE); + return 0; + } + num_bytes = BN_bn2bin(bn, b_in); + flip_endian(b_out, b_in, num_bytes); + bin32_to_felem(out, b_out); + return 1; + } + +/* felem_to_BN converts an felem into an OpenSSL BIGNUM */ +static BIGNUM *smallfelem_to_BN(BIGNUM *out, const smallfelem in) + { + felem_bytearray b_in, b_out; + smallfelem_to_bin32(b_in, in); + flip_endian(b_out, b_in, sizeof b_out); + return BN_bin2bn(b_out, sizeof b_out, out); + } + + +/* Field operations + * ---------------- */ + +static void smallfelem_one(smallfelem out) + { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + } + +static void smallfelem_assign(smallfelem out, const smallfelem in) + { + out[0] = in[0]; + out[1] = in[1]; + out[2] = in[2]; + out[3] = in[3]; + } + +static void felem_assign(felem out, const felem in) + { + out[0] = in[0]; + out[1] = in[1]; + out[2] = in[2]; + out[3] = in[3]; + } + +/* felem_sum sets out = out + in. */ +static void felem_sum(felem out, const felem in) + { + out[0] += in[0]; + out[1] += in[1]; + out[2] += in[2]; + out[3] += in[3]; + } + +/* felem_small_sum sets out = out + in. */ +static void felem_small_sum(felem out, const smallfelem in) + { + out[0] += in[0]; + out[1] += in[1]; + out[2] += in[2]; + out[3] += in[3]; + } + +/* felem_scalar sets out = out * scalar */ +static void felem_scalar(felem out, const u64 scalar) + { + out[0] *= scalar; + out[1] *= scalar; + out[2] *= scalar; + out[3] *= scalar; + } + +/* longfelem_scalar sets out = out * scalar */ +static void longfelem_scalar(longfelem out, const u64 scalar) + { + out[0] *= scalar; + out[1] *= scalar; + out[2] *= scalar; + out[3] *= scalar; + out[4] *= scalar; + out[5] *= scalar; + out[6] *= scalar; + out[7] *= scalar; + } + +#define two105m41m9 (((limb)1) << 105) - (((limb)1) << 41) - (((limb)1) << 9) +#define two105 (((limb)1) << 105) +#define two105m41p9 (((limb)1) << 105) - (((limb)1) << 41) + (((limb)1) << 9) + +/* zero105 is 0 mod p */ +static const felem zero105 = { two105m41m9, two105, two105m41p9, two105m41p9 }; + +/* smallfelem_neg sets |out| to |-small| + * On exit: + * out[i] < out[i] + 2^105 + */ +static void smallfelem_neg(felem out, const smallfelem small) + { + /* In order to prevent underflow, we subtract from 0 mod p. */ + out[0] = zero105[0] - small[0]; + out[1] = zero105[1] - small[1]; + out[2] = zero105[2] - small[2]; + out[3] = zero105[3] - small[3]; + } + +/* felem_diff subtracts |in| from |out| + * On entry: + * in[i] < 2^104 + * On exit: + * out[i] < out[i] + 2^105 + */ +static void felem_diff(felem out, const felem in) + { + /* In order to prevent underflow, we add 0 mod p before subtracting. */ + out[0] += zero105[0]; + out[1] += zero105[1]; + out[2] += zero105[2]; + out[3] += zero105[3]; + + out[0] -= in[0]; + out[1] -= in[1]; + out[2] -= in[2]; + out[3] -= in[3]; + } + +#define two107m43m11 (((limb)1) << 107) - (((limb)1) << 43) - (((limb)1) << 11) +#define two107 (((limb)1) << 107) +#define two107m43p11 (((limb)1) << 107) - (((limb)1) << 43) + (((limb)1) << 11) + +/* zero107 is 0 mod p */ +static const felem zero107 = { two107m43m11, two107, two107m43p11, two107m43p11 }; + +/* An alternative felem_diff for larger inputs |in| + * felem_diff_zero107 subtracts |in| from |out| + * On entry: + * in[i] < 2^106 + * On exit: + * out[i] < out[i] + 2^107 + */ +static void felem_diff_zero107(felem out, const felem in) + { + /* In order to prevent underflow, we add 0 mod p before subtracting. */ + out[0] += zero107[0]; + out[1] += zero107[1]; + out[2] += zero107[2]; + out[3] += zero107[3]; + + out[0] -= in[0]; + out[1] -= in[1]; + out[2] -= in[2]; + out[3] -= in[3]; + } + +/* longfelem_diff subtracts |in| from |out| + * On entry: + * in[i] < 7*2^67 + * On exit: + * out[i] < out[i] + 2^70 + 2^40 + */ +static void longfelem_diff(longfelem out, const longfelem in) + { + static const limb two70m8p6 = (((limb)1) << 70) - (((limb)1) << 8) + (((limb)1) << 6); + static const limb two70p40 = (((limb)1) << 70) + (((limb)1) << 40); + static const limb two70 = (((limb)1) << 70); + static const limb two70m40m38p6 = (((limb)1) << 70) - (((limb)1) << 40) - (((limb)1) << 38) + (((limb)1) << 6); + static const limb two70m6 = (((limb)1) << 70) - (((limb)1) << 6); + + /* add 0 mod p to avoid underflow */ + out[0] += two70m8p6; + out[1] += two70p40; + out[2] += two70; + out[3] += two70m40m38p6; + out[4] += two70m6; + out[5] += two70m6; + out[6] += two70m6; + out[7] += two70m6; + + /* in[i] < 7*2^67 < 2^70 - 2^40 - 2^38 + 2^6 */ + out[0] -= in[0]; + out[1] -= in[1]; + out[2] -= in[2]; + out[3] -= in[3]; + out[4] -= in[4]; + out[5] -= in[5]; + out[6] -= in[6]; + out[7] -= in[7]; + } + +#define two64m0 (((limb)1) << 64) - 1 +#define two110p32m0 (((limb)1) << 110) + (((limb)1) << 32) - 1 +#define two64m46 (((limb)1) << 64) - (((limb)1) << 46) +#define two64m32 (((limb)1) << 64) - (((limb)1) << 32) + +/* zero110 is 0 mod p */ +static const felem zero110 = { two64m0, two110p32m0, two64m46, two64m32 }; + +/* felem_shrink converts an felem into a smallfelem. The result isn't quite + * minimal as the value may be greater than p. + * + * On entry: + * in[i] < 2^109 + * On exit: + * out[i] < 2^64 + */ +static void felem_shrink(smallfelem out, const felem in) + { + felem tmp; + u64 a, b, mask; + s64 high, low; + static const u64 kPrime3Test = 0x7fffffff00000001ul; /* 2^63 - 2^32 + 1 */ + + /* Carry 2->3 */ + tmp[3] = zero110[3] + in[3] + ((u64) (in[2] >> 64)); + /* tmp[3] < 2^110 */ + + tmp[2] = zero110[2] + (u64) in[2]; + tmp[0] = zero110[0] + in[0]; + tmp[1] = zero110[1] + in[1]; + /* tmp[0] < 2**110, tmp[1] < 2^111, tmp[2] < 2**65 */ + + /* We perform two partial reductions where we eliminate the + * high-word of tmp[3]. We don't update the other words till the end. + */ + a = tmp[3] >> 64; /* a < 2^46 */ + tmp[3] = (u64) tmp[3]; + tmp[3] -= a; + tmp[3] += ((limb)a) << 32; + /* tmp[3] < 2^79 */ + + b = a; + a = tmp[3] >> 64; /* a < 2^15 */ + b += a; /* b < 2^46 + 2^15 < 2^47 */ + tmp[3] = (u64) tmp[3]; + tmp[3] -= a; + tmp[3] += ((limb)a) << 32; + /* tmp[3] < 2^64 + 2^47 */ + + /* This adjusts the other two words to complete the two partial + * reductions. */ + tmp[0] += b; + tmp[1] -= (((limb)b) << 32); + + /* In order to make space in tmp[3] for the carry from 2 -> 3, we + * conditionally subtract kPrime if tmp[3] is large enough. */ + high = tmp[3] >> 64; + /* As tmp[3] < 2^65, high is either 1 or 0 */ + high <<= 63; + high >>= 63; + /* high is: + * all ones if the high word of tmp[3] is 1 + * all zeros if the high word of tmp[3] if 0 */ + low = tmp[3]; + mask = low >> 63; + /* mask is: + * all ones if the MSB of low is 1 + * all zeros if the MSB of low if 0 */ + low &= bottom63bits; + low -= kPrime3Test; + /* if low was greater than kPrime3Test then the MSB is zero */ + low = ~low; + low >>= 63; + /* low is: + * all ones if low was > kPrime3Test + * all zeros if low was <= kPrime3Test */ + mask = (mask & low) | high; + tmp[0] -= mask & kPrime[0]; + tmp[1] -= mask & kPrime[1]; + /* kPrime[2] is zero, so omitted */ + tmp[3] -= mask & kPrime[3]; + /* tmp[3] < 2**64 - 2**32 + 1 */ + + tmp[1] += ((u64) (tmp[0] >> 64)); tmp[0] = (u64) tmp[0]; + tmp[2] += ((u64) (tmp[1] >> 64)); tmp[1] = (u64) tmp[1]; + tmp[3] += ((u64) (tmp[2] >> 64)); tmp[2] = (u64) tmp[2]; + /* tmp[i] < 2^64 */ + + out[0] = tmp[0]; + out[1] = tmp[1]; + out[2] = tmp[2]; + out[3] = tmp[3]; + } + +/* smallfelem_expand converts a smallfelem to an felem */ +static void smallfelem_expand(felem out, const smallfelem in) + { + out[0] = in[0]; + out[1] = in[1]; + out[2] = in[2]; + out[3] = in[3]; + } + +/* smallfelem_square sets |out| = |small|^2 + * On entry: + * small[i] < 2^64 + * On exit: + * out[i] < 7 * 2^64 < 2^67 + */ +static void smallfelem_square(longfelem out, const smallfelem small) + { + limb a; + u64 high, low; + + a = ((uint128_t) small[0]) * small[0]; + low = a; + high = a >> 64; + out[0] = low; + out[1] = high; + + a = ((uint128_t) small[0]) * small[1]; + low = a; + high = a >> 64; + out[1] += low; + out[1] += low; + out[2] = high; + + a = ((uint128_t) small[0]) * small[2]; + low = a; + high = a >> 64; + out[2] += low; + out[2] *= 2; + out[3] = high; + + a = ((uint128_t) small[0]) * small[3]; + low = a; + high = a >> 64; + out[3] += low; + out[4] = high; + + a = ((uint128_t) small[1]) * small[2]; + low = a; + high = a >> 64; + out[3] += low; + out[3] *= 2; + out[4] += high; + + a = ((uint128_t) small[1]) * small[1]; + low = a; + high = a >> 64; + out[2] += low; + out[3] += high; + + a = ((uint128_t) small[1]) * small[3]; + low = a; + high = a >> 64; + out[4] += low; + out[4] *= 2; + out[5] = high; + + a = ((uint128_t) small[2]) * small[3]; + low = a; + high = a >> 64; + out[5] += low; + out[5] *= 2; + out[6] = high; + out[6] += high; + + a = ((uint128_t) small[2]) * small[2]; + low = a; + high = a >> 64; + out[4] += low; + out[5] += high; + + a = ((uint128_t) small[3]) * small[3]; + low = a; + high = a >> 64; + out[6] += low; + out[7] = high; + } + +/* felem_square sets |out| = |in|^2 + * On entry: + * in[i] < 2^109 + * On exit: + * out[i] < 7 * 2^64 < 2^67 + */ +static void felem_square(longfelem out, const felem in) + { + u64 small[4]; + felem_shrink(small, in); + smallfelem_square(out, small); + } + +/* smallfelem_mul sets |out| = |small1| * |small2| + * On entry: + * small1[i] < 2^64 + * small2[i] < 2^64 + * On exit: + * out[i] < 7 * 2^64 < 2^67 + */ +static void smallfelem_mul(longfelem out, const smallfelem small1, const smallfelem small2) + { + limb a; + u64 high, low; + + a = ((uint128_t) small1[0]) * small2[0]; + low = a; + high = a >> 64; + out[0] = low; + out[1] = high; + + + a = ((uint128_t) small1[0]) * small2[1]; + low = a; + high = a >> 64; + out[1] += low; + out[2] = high; + + a = ((uint128_t) small1[1]) * small2[0]; + low = a; + high = a >> 64; + out[1] += low; + out[2] += high; + + + a = ((uint128_t) small1[0]) * small2[2]; + low = a; + high = a >> 64; + out[2] += low; + out[3] = high; + + a = ((uint128_t) small1[1]) * small2[1]; + low = a; + high = a >> 64; + out[2] += low; + out[3] += high; + + a = ((uint128_t) small1[2]) * small2[0]; + low = a; + high = a >> 64; + out[2] += low; + out[3] += high; + + + a = ((uint128_t) small1[0]) * small2[3]; + low = a; + high = a >> 64; + out[3] += low; + out[4] = high; + + a = ((uint128_t) small1[1]) * small2[2]; + low = a; + high = a >> 64; + out[3] += low; + out[4] += high; + + a = ((uint128_t) small1[2]) * small2[1]; + low = a; + high = a >> 64; + out[3] += low; + out[4] += high; + + a = ((uint128_t) small1[3]) * small2[0]; + low = a; + high = a >> 64; + out[3] += low; + out[4] += high; + + + a = ((uint128_t) small1[1]) * small2[3]; + low = a; + high = a >> 64; + out[4] += low; + out[5] = high; + + a = ((uint128_t) small1[2]) * small2[2]; + low = a; + high = a >> 64; + out[4] += low; + out[5] += high; + + a = ((uint128_t) small1[3]) * small2[1]; + low = a; + high = a >> 64; + out[4] += low; + out[5] += high; + + + a = ((uint128_t) small1[2]) * small2[3]; + low = a; + high = a >> 64; + out[5] += low; + out[6] = high; + + a = ((uint128_t) small1[3]) * small2[2]; + low = a; + high = a >> 64; + out[5] += low; + out[6] += high; + + + a = ((uint128_t) small1[3]) * small2[3]; + low = a; + high = a >> 64; + out[6] += low; + out[7] = high; + } + +/* felem_mul sets |out| = |in1| * |in2| + * On entry: + * in1[i] < 2^109 + * in2[i] < 2^109 + * On exit: + * out[i] < 7 * 2^64 < 2^67 + */ +static void felem_mul(longfelem out, const felem in1, const felem in2) + { + smallfelem small1, small2; + felem_shrink(small1, in1); + felem_shrink(small2, in2); + smallfelem_mul(out, small1, small2); + } + +/* felem_small_mul sets |out| = |small1| * |in2| + * On entry: + * small1[i] < 2^64 + * in2[i] < 2^109 + * On exit: + * out[i] < 7 * 2^64 < 2^67 + */ +static void felem_small_mul(longfelem out, const smallfelem small1, const felem in2) + { + smallfelem small2; + felem_shrink(small2, in2); + smallfelem_mul(out, small1, small2); + } + +#define two100m36m4 (((limb)1) << 100) - (((limb)1) << 36) - (((limb)1) << 4) +#define two100 (((limb)1) << 100) +#define two100m36p4 (((limb)1) << 100) - (((limb)1) << 36) + (((limb)1) << 4) +/* zero100 is 0 mod p */ +static const felem zero100 = { two100m36m4, two100, two100m36p4, two100m36p4 }; + +/* Internal function for the different flavours of felem_reduce. + * felem_reduce_ reduces the higher coefficients in[4]-in[7]. + * On entry: + * out[0] >= in[6] + 2^32*in[6] + in[7] + 2^32*in[7] + * out[1] >= in[7] + 2^32*in[4] + * out[2] >= in[5] + 2^32*in[5] + * out[3] >= in[4] + 2^32*in[5] + 2^32*in[6] + * On exit: + * out[0] <= out[0] + in[4] + 2^32*in[5] + * out[1] <= out[1] + in[5] + 2^33*in[6] + * out[2] <= out[2] + in[7] + 2*in[6] + 2^33*in[7] + * out[3] <= out[3] + 2^32*in[4] + 3*in[7] + */ +static void felem_reduce_(felem out, const longfelem in) + { + int128_t c; + /* combine common terms from below */ + c = in[4] + (in[5] << 32); + out[0] += c; + out[3] -= c; + + c = in[5] - in[7]; + out[1] += c; + out[2] -= c; + + /* the remaining terms */ + /* 256: [(0,1),(96,-1),(192,-1),(224,1)] */ + out[1] -= (in[4] << 32); + out[3] += (in[4] << 32); + + /* 320: [(32,1),(64,1),(128,-1),(160,-1),(224,-1)] */ + out[2] -= (in[5] << 32); + + /* 384: [(0,-1),(32,-1),(96,2),(128,2),(224,-1)] */ + out[0] -= in[6]; + out[0] -= (in[6] << 32); + out[1] += (in[6] << 33); + out[2] += (in[6] * 2); + out[3] -= (in[6] << 32); + + /* 448: [(0,-1),(32,-1),(64,-1),(128,1),(160,2),(192,3)] */ + out[0] -= in[7]; + out[0] -= (in[7] << 32); + out[2] += (in[7] << 33); + out[3] += (in[7] * 3); + } + +/* felem_reduce converts a longfelem into an felem. + * To be called directly after felem_square or felem_mul. + * On entry: + * in[0] < 2^64, in[1] < 3*2^64, in[2] < 5*2^64, in[3] < 7*2^64 + * in[4] < 7*2^64, in[5] < 5*2^64, in[6] < 3*2^64, in[7] < 2*64 + * On exit: + * out[i] < 2^101 + */ +static void felem_reduce(felem out, const longfelem in) + { + out[0] = zero100[0] + in[0]; + out[1] = zero100[1] + in[1]; + out[2] = zero100[2] + in[2]; + out[3] = zero100[3] + in[3]; + + felem_reduce_(out, in); + + /* out[0] > 2^100 - 2^36 - 2^4 - 3*2^64 - 3*2^96 - 2^64 - 2^96 > 0 + * out[1] > 2^100 - 2^64 - 7*2^96 > 0 + * out[2] > 2^100 - 2^36 + 2^4 - 5*2^64 - 5*2^96 > 0 + * out[3] > 2^100 - 2^36 + 2^4 - 7*2^64 - 5*2^96 - 3*2^96 > 0 + * + * out[0] < 2^100 + 2^64 + 7*2^64 + 5*2^96 < 2^101 + * out[1] < 2^100 + 3*2^64 + 5*2^64 + 3*2^97 < 2^101 + * out[2] < 2^100 + 5*2^64 + 2^64 + 3*2^65 + 2^97 < 2^101 + * out[3] < 2^100 + 7*2^64 + 7*2^96 + 3*2^64 < 2^101 + */ + } + +/* felem_reduce_zero105 converts a larger longfelem into an felem. + * On entry: + * in[0] < 2^71 + * On exit: + * out[i] < 2^106 + */ +static void felem_reduce_zero105(felem out, const longfelem in) + { + out[0] = zero105[0] + in[0]; + out[1] = zero105[1] + in[1]; + out[2] = zero105[2] + in[2]; + out[3] = zero105[3] + in[3]; + + felem_reduce_(out, in); + + /* out[0] > 2^105 - 2^41 - 2^9 - 2^71 - 2^103 - 2^71 - 2^103 > 0 + * out[1] > 2^105 - 2^71 - 2^103 > 0 + * out[2] > 2^105 - 2^41 + 2^9 - 2^71 - 2^103 > 0 + * out[3] > 2^105 - 2^41 + 2^9 - 2^71 - 2^103 - 2^103 > 0 + * + * out[0] < 2^105 + 2^71 + 2^71 + 2^103 < 2^106 + * out[1] < 2^105 + 2^71 + 2^71 + 2^103 < 2^106 + * out[2] < 2^105 + 2^71 + 2^71 + 2^71 + 2^103 < 2^106 + * out[3] < 2^105 + 2^71 + 2^103 + 2^71 < 2^106 + */ + } + +/* subtract_u64 sets *result = *result - v and *carry to one if the subtraction + * underflowed. */ +static void subtract_u64(u64* result, u64* carry, u64 v) + { + uint128_t r = *result; + r -= v; + *carry = (r >> 64) & 1; + *result = (u64) r; + } + +/* felem_contract converts |in| to its unique, minimal representation. + * On entry: + * in[i] < 2^109 + */ +static void felem_contract(smallfelem out, const felem in) + { + unsigned i; + u64 all_equal_so_far = 0, result = 0, carry; + + felem_shrink(out, in); + /* small is minimal except that the value might be > p */ + + all_equal_so_far--; + /* We are doing a constant time test if out >= kPrime. We need to + * compare each u64, from most-significant to least significant. For + * each one, if all words so far have been equal (m is all ones) then a + * non-equal result is the answer. Otherwise we continue. */ + for (i = 3; i < 4; i--) + { + u64 equal; + uint128_t a = ((uint128_t) kPrime[i]) - out[i]; + /* if out[i] > kPrime[i] then a will underflow and the high + * 64-bits will all be set. */ + result |= all_equal_so_far & ((u64) (a >> 64)); + + /* if kPrime[i] == out[i] then |equal| will be all zeros and + * the decrement will make it all ones. */ + equal = kPrime[i] ^ out[i]; + equal--; + equal &= equal << 32; + equal &= equal << 16; + equal &= equal << 8; + equal &= equal << 4; + equal &= equal << 2; + equal &= equal << 1; + equal = ((s64) equal) >> 63; + + all_equal_so_far &= equal; + } + + /* if all_equal_so_far is still all ones then the two values are equal + * and so out >= kPrime is true. */ + result |= all_equal_so_far; + + /* if out >= kPrime then we subtract kPrime. */ + subtract_u64(&out[0], &carry, result & kPrime[0]); + subtract_u64(&out[1], &carry, carry); + subtract_u64(&out[2], &carry, carry); + subtract_u64(&out[3], &carry, carry); + + subtract_u64(&out[1], &carry, result & kPrime[1]); + subtract_u64(&out[2], &carry, carry); + subtract_u64(&out[3], &carry, carry); + + subtract_u64(&out[2], &carry, result & kPrime[2]); + subtract_u64(&out[3], &carry, carry); + + subtract_u64(&out[3], &carry, result & kPrime[3]); + } + +static void smallfelem_square_contract(smallfelem out, const smallfelem in) + { + longfelem longtmp; + felem tmp; + + smallfelem_square(longtmp, in); + felem_reduce(tmp, longtmp); + felem_contract(out, tmp); + } + +static void smallfelem_mul_contract(smallfelem out, const smallfelem in1, const smallfelem in2) + { + longfelem longtmp; + felem tmp; + + smallfelem_mul(longtmp, in1, in2); + felem_reduce(tmp, longtmp); + felem_contract(out, tmp); + } + +/* felem_is_zero returns a limb with all bits set if |in| == 0 (mod p) and 0 + * otherwise. + * On entry: + * small[i] < 2^64 + */ +static limb smallfelem_is_zero(const smallfelem small) + { + limb result; + u64 is_p; + + u64 is_zero = small[0] | small[1] | small[2] | small[3]; + is_zero--; + is_zero &= is_zero << 32; + is_zero &= is_zero << 16; + is_zero &= is_zero << 8; + is_zero &= is_zero << 4; + is_zero &= is_zero << 2; + is_zero &= is_zero << 1; + is_zero = ((s64) is_zero) >> 63; + + is_p = (small[0] ^ kPrime[0]) | + (small[1] ^ kPrime[1]) | + (small[2] ^ kPrime[2]) | + (small[3] ^ kPrime[3]); + is_p--; + is_p &= is_p << 32; + is_p &= is_p << 16; + is_p &= is_p << 8; + is_p &= is_p << 4; + is_p &= is_p << 2; + is_p &= is_p << 1; + is_p = ((s64) is_p) >> 63; + + is_zero |= is_p; + + result = is_zero; + result |= ((limb) is_zero) << 64; + return result; + } + +static int smallfelem_is_zero_int(const smallfelem small) + { + return (int) (smallfelem_is_zero(small) & ((limb)1)); + } + +/* felem_inv calculates |out| = |in|^{-1} + * + * Based on Fermat's Little Theorem: + * a^p = a (mod p) + * a^{p-1} = 1 (mod p) + * a^{p-2} = a^{-1} (mod p) + */ +static void felem_inv(felem out, const felem in) + { + felem ftmp, ftmp2; + /* each e_I will hold |in|^{2^I - 1} */ + felem e2, e4, e8, e16, e32, e64; + longfelem tmp; + unsigned i; + + felem_square(tmp, in); felem_reduce(ftmp, tmp); /* 2^1 */ + felem_mul(tmp, in, ftmp); felem_reduce(ftmp, tmp); /* 2^2 - 2^0 */ + felem_assign(e2, ftmp); + felem_square(tmp, ftmp); felem_reduce(ftmp, tmp); /* 2^3 - 2^1 */ + felem_square(tmp, ftmp); felem_reduce(ftmp, tmp); /* 2^4 - 2^2 */ + felem_mul(tmp, ftmp, e2); felem_reduce(ftmp, tmp); /* 2^4 - 2^0 */ + felem_assign(e4, ftmp); + felem_square(tmp, ftmp); felem_reduce(ftmp, tmp); /* 2^5 - 2^1 */ + felem_square(tmp, ftmp); felem_reduce(ftmp, tmp); /* 2^6 - 2^2 */ + felem_square(tmp, ftmp); felem_reduce(ftmp, tmp); /* 2^7 - 2^3 */ + felem_square(tmp, ftmp); felem_reduce(ftmp, tmp); /* 2^8 - 2^4 */ + felem_mul(tmp, ftmp, e4); felem_reduce(ftmp, tmp); /* 2^8 - 2^0 */ + felem_assign(e8, ftmp); + for (i = 0; i < 8; i++) { + felem_square(tmp, ftmp); felem_reduce(ftmp, tmp); + } /* 2^16 - 2^8 */ + felem_mul(tmp, ftmp, e8); felem_reduce(ftmp, tmp); /* 2^16 - 2^0 */ + felem_assign(e16, ftmp); + for (i = 0; i < 16; i++) { + felem_square(tmp, ftmp); felem_reduce(ftmp, tmp); + } /* 2^32 - 2^16 */ + felem_mul(tmp, ftmp, e16); felem_reduce(ftmp, tmp); /* 2^32 - 2^0 */ + felem_assign(e32, ftmp); + for (i = 0; i < 32; i++) { + felem_square(tmp, ftmp); felem_reduce(ftmp, tmp); + } /* 2^64 - 2^32 */ + felem_assign(e64, ftmp); + felem_mul(tmp, ftmp, in); felem_reduce(ftmp, tmp); /* 2^64 - 2^32 + 2^0 */ + for (i = 0; i < 192; i++) { + felem_square(tmp, ftmp); felem_reduce(ftmp, tmp); + } /* 2^256 - 2^224 + 2^192 */ + + felem_mul(tmp, e64, e32); felem_reduce(ftmp2, tmp); /* 2^64 - 2^0 */ + for (i = 0; i < 16; i++) { + felem_square(tmp, ftmp2); felem_reduce(ftmp2, tmp); + } /* 2^80 - 2^16 */ + felem_mul(tmp, ftmp2, e16); felem_reduce(ftmp2, tmp); /* 2^80 - 2^0 */ + for (i = 0; i < 8; i++) { + felem_square(tmp, ftmp2); felem_reduce(ftmp2, tmp); + } /* 2^88 - 2^8 */ + felem_mul(tmp, ftmp2, e8); felem_reduce(ftmp2, tmp); /* 2^88 - 2^0 */ + for (i = 0; i < 4; i++) { + felem_square(tmp, ftmp2); felem_reduce(ftmp2, tmp); + } /* 2^92 - 2^4 */ + felem_mul(tmp, ftmp2, e4); felem_reduce(ftmp2, tmp); /* 2^92 - 2^0 */ + felem_square(tmp, ftmp2); felem_reduce(ftmp2, tmp); /* 2^93 - 2^1 */ + felem_square(tmp, ftmp2); felem_reduce(ftmp2, tmp); /* 2^94 - 2^2 */ + felem_mul(tmp, ftmp2, e2); felem_reduce(ftmp2, tmp); /* 2^94 - 2^0 */ + felem_square(tmp, ftmp2); felem_reduce(ftmp2, tmp); /* 2^95 - 2^1 */ + felem_square(tmp, ftmp2); felem_reduce(ftmp2, tmp); /* 2^96 - 2^2 */ + felem_mul(tmp, ftmp2, in); felem_reduce(ftmp2, tmp); /* 2^96 - 3 */ + + felem_mul(tmp, ftmp2, ftmp); felem_reduce(out, tmp); /* 2^256 - 2^224 + 2^192 + 2^96 - 3 */ + } + +static void smallfelem_inv_contract(smallfelem out, const smallfelem in) + { + felem tmp; + + smallfelem_expand(tmp, in); + felem_inv(tmp, tmp); + felem_contract(out, tmp); + } + +/* Group operations + * ---------------- + * + * Building on top of the field operations we have the operations on the + * elliptic curve group itself. Points on the curve are represented in Jacobian + * coordinates */ + +/* point_double calculates 2*(x_in, y_in, z_in) + * + * The method is taken from: + * http://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b + * + * Outputs can equal corresponding inputs, i.e., x_out == x_in is allowed. + * while x_out == y_in is not (maybe this works, but it's not tested). */ +static void +point_double(felem x_out, felem y_out, felem z_out, + const felem x_in, const felem y_in, const felem z_in) + { + longfelem tmp, tmp2; + felem delta, gamma, beta, alpha, ftmp, ftmp2; + smallfelem small1, small2; + + felem_assign(ftmp, x_in); + /* ftmp[i] < 2^106 */ + felem_assign(ftmp2, x_in); + /* ftmp2[i] < 2^106 */ + + /* delta = z^2 */ + felem_square(tmp, z_in); + felem_reduce(delta, tmp); + /* delta[i] < 2^101 */ + + /* gamma = y^2 */ + felem_square(tmp, y_in); + felem_reduce(gamma, tmp); + /* gamma[i] < 2^101 */ + felem_shrink(small1, gamma); + + /* beta = x*gamma */ + felem_small_mul(tmp, small1, x_in); + felem_reduce(beta, tmp); + /* beta[i] < 2^101 */ + + /* alpha = 3*(x-delta)*(x+delta) */ + felem_diff(ftmp, delta); + /* ftmp[i] < 2^105 + 2^106 < 2^107 */ + felem_sum(ftmp2, delta); + /* ftmp2[i] < 2^105 + 2^106 < 2^107 */ + felem_scalar(ftmp2, 3); + /* ftmp2[i] < 3 * 2^107 < 2^109 */ + felem_mul(tmp, ftmp, ftmp2); + felem_reduce(alpha, tmp); + /* alpha[i] < 2^101 */ + felem_shrink(small2, alpha); + + /* x' = alpha^2 - 8*beta */ + smallfelem_square(tmp, small2); + felem_reduce(x_out, tmp); + felem_assign(ftmp, beta); + felem_scalar(ftmp, 8); + /* ftmp[i] < 8 * 2^101 = 2^104 */ + felem_diff(x_out, ftmp); + /* x_out[i] < 2^105 + 2^101 < 2^106 */ + + /* z' = (y + z)^2 - gamma - delta */ + felem_sum(delta, gamma); + /* delta[i] < 2^101 + 2^101 = 2^102 */ + felem_assign(ftmp, y_in); + felem_sum(ftmp, z_in); + /* ftmp[i] < 2^106 + 2^106 = 2^107 */ + felem_square(tmp, ftmp); + felem_reduce(z_out, tmp); + felem_diff(z_out, delta); + /* z_out[i] < 2^105 + 2^101 < 2^106 */ + + /* y' = alpha*(4*beta - x') - 8*gamma^2 */ + felem_scalar(beta, 4); + /* beta[i] < 4 * 2^101 = 2^103 */ + felem_diff_zero107(beta, x_out); + /* beta[i] < 2^107 + 2^103 < 2^108 */ + felem_small_mul(tmp, small2, beta); + /* tmp[i] < 7 * 2^64 < 2^67 */ + smallfelem_square(tmp2, small1); + /* tmp2[i] < 7 * 2^64 */ + longfelem_scalar(tmp2, 8); + /* tmp2[i] < 8 * 7 * 2^64 = 7 * 2^67 */ + longfelem_diff(tmp, tmp2); + /* tmp[i] < 2^67 + 2^70 + 2^40 < 2^71 */ + felem_reduce_zero105(y_out, tmp); + /* y_out[i] < 2^106 */ + } + +/* point_double_small is the same as point_double, except that it operates on + * smallfelems */ +static void +point_double_small(smallfelem x_out, smallfelem y_out, smallfelem z_out, + const smallfelem x_in, const smallfelem y_in, const smallfelem z_in) + { + felem felem_x_out, felem_y_out, felem_z_out; + felem felem_x_in, felem_y_in, felem_z_in; + + smallfelem_expand(felem_x_in, x_in); + smallfelem_expand(felem_y_in, y_in); + smallfelem_expand(felem_z_in, z_in); + point_double(felem_x_out, felem_y_out, felem_z_out, + felem_x_in, felem_y_in, felem_z_in); + felem_shrink(x_out, felem_x_out); + felem_shrink(y_out, felem_y_out); + felem_shrink(z_out, felem_z_out); + } + +/* copy_conditional copies in to out iff mask is all ones. */ +static void +copy_conditional(felem out, const felem in, limb mask) + { + unsigned i; + for (i = 0; i < NLIMBS; ++i) + { + const limb tmp = mask & (in[i] ^ out[i]); + out[i] ^= tmp; + } + } + +/* copy_small_conditional copies in to out iff mask is all ones. */ +static void +copy_small_conditional(felem out, const smallfelem in, limb mask) + { + unsigned i; + const u64 mask64 = mask; + for (i = 0; i < NLIMBS; ++i) + { + out[i] = ((limb) (in[i] & mask64)) | (out[i] & ~mask); + } + } + +/* point_add calcuates (x1, y1, z1) + (x2, y2, z2) + * + * The method is taken from: + * http://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#addition-add-2007-bl, + * adapted for mixed addition (z2 = 1, or z2 = 0 for the point at infinity). + * + * This function includes a branch for checking whether the two input points + * are equal, (while not equal to the point at infinity). This case never + * happens during single point multiplication, so there is no timing leak for + * ECDH or ECDSA signing. */ +static void point_add(felem x3, felem y3, felem z3, + const felem x1, const felem y1, const felem z1, + const int mixed, const smallfelem x2, const smallfelem y2, const smallfelem z2) + { + felem ftmp, ftmp2, ftmp3, ftmp4, ftmp5, ftmp6, x_out, y_out, z_out; + longfelem tmp, tmp2; + smallfelem small1, small2, small3, small4, small5; + limb x_equal, y_equal, z1_is_zero, z2_is_zero; + + felem_shrink(small3, z1); + + z1_is_zero = smallfelem_is_zero(small3); + z2_is_zero = smallfelem_is_zero(z2); + + /* ftmp = z1z1 = z1**2 */ + smallfelem_square(tmp, small3); + felem_reduce(ftmp, tmp); + /* ftmp[i] < 2^101 */ + felem_shrink(small1, ftmp); + + if(!mixed) + { + /* ftmp2 = z2z2 = z2**2 */ + smallfelem_square(tmp, z2); + felem_reduce(ftmp2, tmp); + /* ftmp2[i] < 2^101 */ + felem_shrink(small2, ftmp2); + + felem_shrink(small5, x1); + + /* u1 = ftmp3 = x1*z2z2 */ + smallfelem_mul(tmp, small5, small2); + felem_reduce(ftmp3, tmp); + /* ftmp3[i] < 2^101 */ + + /* ftmp5 = z1 + z2 */ + felem_assign(ftmp5, z1); + felem_small_sum(ftmp5, z2); + /* ftmp5[i] < 2^107 */ + + /* ftmp5 = (z1 + z2)**2 - (z1z1 + z2z2) = 2z1z2 */ + felem_square(tmp, ftmp5); + felem_reduce(ftmp5, tmp); + /* ftmp2 = z2z2 + z1z1 */ + felem_sum(ftmp2, ftmp); + /* ftmp2[i] < 2^101 + 2^101 = 2^102 */ + felem_diff(ftmp5, ftmp2); + /* ftmp5[i] < 2^105 + 2^101 < 2^106 */ + + /* ftmp2 = z2 * z2z2 */ + smallfelem_mul(tmp, small2, z2); + felem_reduce(ftmp2, tmp); + + /* s1 = ftmp2 = y1 * z2**3 */ + felem_mul(tmp, y1, ftmp2); + felem_reduce(ftmp6, tmp); + /* ftmp6[i] < 2^101 */ + } + else + { + /* We'll assume z2 = 1 (special case z2 = 0 is handled later) */ + + /* u1 = ftmp3 = x1*z2z2 */ + felem_assign(ftmp3, x1); + /* ftmp3[i] < 2^106 */ + + /* ftmp5 = 2z1z2 */ + felem_assign(ftmp5, z1); + felem_scalar(ftmp5, 2); + /* ftmp5[i] < 2*2^106 = 2^107 */ + + /* s1 = ftmp2 = y1 * z2**3 */ + felem_assign(ftmp6, y1); + /* ftmp6[i] < 2^106 */ + } + + /* u2 = x2*z1z1 */ + smallfelem_mul(tmp, x2, small1); + felem_reduce(ftmp4, tmp); + + /* h = ftmp4 = u2 - u1 */ + felem_diff_zero107(ftmp4, ftmp3); + /* ftmp4[i] < 2^107 + 2^101 < 2^108 */ + felem_shrink(small4, ftmp4); + + x_equal = smallfelem_is_zero(small4); + + /* z_out = ftmp5 * h */ + felem_small_mul(tmp, small4, ftmp5); + felem_reduce(z_out, tmp); + /* z_out[i] < 2^101 */ + + /* ftmp = z1 * z1z1 */ + smallfelem_mul(tmp, small1, small3); + felem_reduce(ftmp, tmp); + + /* s2 = tmp = y2 * z1**3 */ + felem_small_mul(tmp, y2, ftmp); + felem_reduce(ftmp5, tmp); + + /* r = ftmp5 = (s2 - s1)*2 */ + felem_diff_zero107(ftmp5, ftmp6); + /* ftmp5[i] < 2^107 + 2^107 = 2^108*/ + felem_scalar(ftmp5, 2); + /* ftmp5[i] < 2^109 */ + felem_shrink(small1, ftmp5); + y_equal = smallfelem_is_zero(small1); + + if (x_equal && y_equal && !z1_is_zero && !z2_is_zero) + { + point_double(x3, y3, z3, x1, y1, z1); + return; + } + + /* I = ftmp = (2h)**2 */ + felem_assign(ftmp, ftmp4); + felem_scalar(ftmp, 2); + /* ftmp[i] < 2*2^108 = 2^109 */ + felem_square(tmp, ftmp); + felem_reduce(ftmp, tmp); + + /* J = ftmp2 = h * I */ + felem_mul(tmp, ftmp4, ftmp); + felem_reduce(ftmp2, tmp); + + /* V = ftmp4 = U1 * I */ + felem_mul(tmp, ftmp3, ftmp); + felem_reduce(ftmp4, tmp); + + /* x_out = r**2 - J - 2V */ + smallfelem_square(tmp, small1); + felem_reduce(x_out, tmp); + felem_assign(ftmp3, ftmp4); + felem_scalar(ftmp4, 2); + felem_sum(ftmp4, ftmp2); + /* ftmp4[i] < 2*2^101 + 2^101 < 2^103 */ + felem_diff(x_out, ftmp4); + /* x_out[i] < 2^105 + 2^101 */ + + /* y_out = r(V-x_out) - 2 * s1 * J */ + felem_diff_zero107(ftmp3, x_out); + /* ftmp3[i] < 2^107 + 2^101 < 2^108 */ + felem_small_mul(tmp, small1, ftmp3); + felem_mul(tmp2, ftmp6, ftmp2); + longfelem_scalar(tmp2, 2); + /* tmp2[i] < 2*2^67 = 2^68 */ + longfelem_diff(tmp, tmp2); + /* tmp[i] < 2^67 + 2^70 + 2^40 < 2^71 */ + felem_reduce_zero105(y_out, tmp); + /* y_out[i] < 2^106 */ + + copy_small_conditional(x_out, x2, z1_is_zero); + copy_conditional(x_out, x1, z2_is_zero); + copy_small_conditional(y_out, y2, z1_is_zero); + copy_conditional(y_out, y1, z2_is_zero); + copy_small_conditional(z_out, z2, z1_is_zero); + copy_conditional(z_out, z1, z2_is_zero); + felem_assign(x3, x_out); + felem_assign(y3, y_out); + felem_assign(z3, z_out); + } + +/* point_add_small is the same as point_add, except that it operates on + * smallfelems */ +static void point_add_small(smallfelem x3, smallfelem y3, smallfelem z3, + smallfelem x1, smallfelem y1, smallfelem z1, + smallfelem x2, smallfelem y2, smallfelem z2) + { + felem felem_x3, felem_y3, felem_z3; + felem felem_x1, felem_y1, felem_z1; + smallfelem_expand(felem_x1, x1); + smallfelem_expand(felem_y1, y1); + smallfelem_expand(felem_z1, z1); + point_add(felem_x3, felem_y3, felem_z3, felem_x1, felem_y1, felem_z1, 0, x2, y2, z2); + felem_shrink(x3, felem_x3); + felem_shrink(y3, felem_y3); + felem_shrink(z3, felem_z3); + } + +/* Base point pre computation + * -------------------------- + * + * Two different sorts of precomputed tables are used in the following code. + * Each contain various points on the curve, where each point is three field + * elements (x, y, z). + * + * For the base point table, z is usually 1 (0 for the point at infinity). + * This table has 2 * 16 elements, starting with the following: + * index | bits | point + * ------+---------+------------------------------ + * 0 | 0 0 0 0 | 0G + * 1 | 0 0 0 1 | 1G + * 2 | 0 0 1 0 | 2^64G + * 3 | 0 0 1 1 | (2^64 + 1)G + * 4 | 0 1 0 0 | 2^128G + * 5 | 0 1 0 1 | (2^128 + 1)G + * 6 | 0 1 1 0 | (2^128 + 2^64)G + * 7 | 0 1 1 1 | (2^128 + 2^64 + 1)G + * 8 | 1 0 0 0 | 2^192G + * 9 | 1 0 0 1 | (2^192 + 1)G + * 10 | 1 0 1 0 | (2^192 + 2^64)G + * 11 | 1 0 1 1 | (2^192 + 2^64 + 1)G + * 12 | 1 1 0 0 | (2^192 + 2^128)G + * 13 | 1 1 0 1 | (2^192 + 2^128 + 1)G + * 14 | 1 1 1 0 | (2^192 + 2^128 + 2^64)G + * 15 | 1 1 1 1 | (2^192 + 2^128 + 2^64 + 1)G + * followed by a copy of this with each element multiplied by 2^32. + * + * The reason for this is so that we can clock bits into four different + * locations when doing simple scalar multiplies against the base point, + * and then another four locations using the second 16 elements. + * + * Tables for other points have table[i] = iG for i in 0 .. 16. */ + +/* gmul is the table of precomputed base points */ +static const smallfelem gmul[2][16][3] = +{{{{0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}}, + {{0xf4a13945d898c296, 0x77037d812deb33a0, 0xf8bce6e563a440f2, 0x6b17d1f2e12c4247}, + {0xcbb6406837bf51f5, 0x2bce33576b315ece, 0x8ee7eb4a7c0f9e16, 0x4fe342e2fe1a7f9b}, + {1, 0, 0, 0}}, + {{0x90e75cb48e14db63, 0x29493baaad651f7e, 0x8492592e326e25de, 0x0fa822bc2811aaa5}, + {0xe41124545f462ee7, 0x34b1a65050fe82f5, 0x6f4ad4bcb3df188b, 0xbff44ae8f5dba80d}, + {1, 0, 0, 0}}, + {{0x93391ce2097992af, 0xe96c98fd0d35f1fa, 0xb257c0de95e02789, 0x300a4bbc89d6726f}, + {0xaa54a291c08127a0, 0x5bb1eeada9d806a5, 0x7f1ddb25ff1e3c6f, 0x72aac7e0d09b4644}, + {1, 0, 0, 0}}, + {{0x57c84fc9d789bd85, 0xfc35ff7dc297eac3, 0xfb982fd588c6766e, 0x447d739beedb5e67}, + {0x0c7e33c972e25b32, 0x3d349b95a7fae500, 0xe12e9d953a4aaff7, 0x2d4825ab834131ee}, + {1, 0, 0, 0}}, + {{0x13949c932a1d367f, 0xef7fbd2b1a0a11b7, 0xddc6068bb91dfc60, 0xef9519328a9c72ff}, + {0x196035a77376d8a8, 0x23183b0895ca1740, 0xc1ee9807022c219c, 0x611e9fc37dbb2c9b}, + {1, 0, 0, 0}}, + {{0xcae2b1920b57f4bc, 0x2936df5ec6c9bc36, 0x7dea6482e11238bf, 0x550663797b51f5d8}, + {0x44ffe216348a964c, 0x9fb3d576dbdefbe1, 0x0afa40018d9d50e5, 0x157164848aecb851}, + {1, 0, 0, 0}}, + {{0xe48ecafffc5cde01, 0x7ccd84e70d715f26, 0xa2e8f483f43e4391, 0xeb5d7745b21141ea}, + {0xcac917e2731a3479, 0x85f22cfe2844b645, 0x0990e6a158006cee, 0xeafd72ebdbecc17b}, + {1, 0, 0, 0}}, + {{0x6cf20ffb313728be, 0x96439591a3c6b94a, 0x2736ff8344315fc5, 0xa6d39677a7849276}, + {0xf2bab833c357f5f4, 0x824a920c2284059b, 0x66b8babd2d27ecdf, 0x674f84749b0b8816}, + {1, 0, 0, 0}}, + {{0x2df48c04677c8a3e, 0x74e02f080203a56b, 0x31855f7db8c7fedb, 0x4e769e7672c9ddad}, + {0xa4c36165b824bbb0, 0xfb9ae16f3b9122a5, 0x1ec0057206947281, 0x42b99082de830663}, + {1, 0, 0, 0}}, + {{0x6ef95150dda868b9, 0xd1f89e799c0ce131, 0x7fdc1ca008a1c478, 0x78878ef61c6ce04d}, + {0x9c62b9121fe0d976, 0x6ace570ebde08d4f, 0xde53142c12309def, 0xb6cb3f5d7b72c321}, + {1, 0, 0, 0}}, + {{0x7f991ed2c31a3573, 0x5b82dd5bd54fb496, 0x595c5220812ffcae, 0x0c88bc4d716b1287}, + {0x3a57bf635f48aca8, 0x7c8181f4df2564f3, 0x18d1b5b39c04e6aa, 0xdd5ddea3f3901dc6}, + {1, 0, 0, 0}}, + {{0xe96a79fb3e72ad0c, 0x43a0a28c42ba792f, 0xefe0a423083e49f3, 0x68f344af6b317466}, + {0xcdfe17db3fb24d4a, 0x668bfc2271f5c626, 0x604ed93c24d67ff3, 0x31b9c405f8540a20}, + {1, 0, 0, 0}}, + {{0xd36b4789a2582e7f, 0x0d1a10144ec39c28, 0x663c62c3edbad7a0, 0x4052bf4b6f461db9}, + {0x235a27c3188d25eb, 0xe724f33999bfcc5b, 0x862be6bd71d70cc8, 0xfecf4d5190b0fc61}, + {1, 0, 0, 0}}, + {{0x74346c10a1d4cfac, 0xafdf5cc08526a7a4, 0x123202a8f62bff7a, 0x1eddbae2c802e41a}, + {0x8fa0af2dd603f844, 0x36e06b7e4c701917, 0x0c45f45273db33a0, 0x43104d86560ebcfc}, + {1, 0, 0, 0}}, + {{0x9615b5110d1d78e5, 0x66b0de3225c4744b, 0x0a4a46fb6aaf363a, 0xb48e26b484f7a21c}, + {0x06ebb0f621a01b2d, 0xc004e4048b7b0f98, 0x64131bcdfed6f668, 0xfac015404d4d3dab}, + {1, 0, 0, 0}}}, + {{{0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}}, + {{0x3a5a9e22185a5943, 0x1ab919365c65dfb6, 0x21656b32262c71da, 0x7fe36b40af22af89}, + {0xd50d152c699ca101, 0x74b3d5867b8af212, 0x9f09f40407dca6f1, 0xe697d45825b63624}, + {1, 0, 0, 0}}, + {{0xa84aa9397512218e, 0xe9a521b074ca0141, 0x57880b3a18a2e902, 0x4a5b506612a677a6}, + {0x0beada7a4c4f3840, 0x626db15419e26d9d, 0xc42604fbe1627d40, 0xeb13461ceac089f1}, + {1, 0, 0, 0}}, + {{0xf9faed0927a43281, 0x5e52c4144103ecbc, 0xc342967aa815c857, 0x0781b8291c6a220a}, + {0x5a8343ceeac55f80, 0x88f80eeee54a05e3, 0x97b2a14f12916434, 0x690cde8df0151593}, + {1, 0, 0, 0}}, + {{0xaee9c75df7f82f2a, 0x9e4c35874afdf43a, 0xf5622df437371326, 0x8a535f566ec73617}, + {0xc5f9a0ac223094b7, 0xcde533864c8c7669, 0x37e02819085a92bf, 0x0455c08468b08bd7}, + {1, 0, 0, 0}}, + {{0x0c0a6e2c9477b5d9, 0xf9a4bf62876dc444, 0x5050a949b6cdc279, 0x06bada7ab77f8276}, + {0xc8b4aed1ea48dac9, 0xdebd8a4b7ea1070f, 0x427d49101366eb70, 0x5b476dfd0e6cb18a}, + {1, 0, 0, 0}}, + {{0x7c5c3e44278c340a, 0x4d54606812d66f3b, 0x29a751b1ae23c5d8, 0x3e29864e8a2ec908}, + {0x142d2a6626dbb850, 0xad1744c4765bd780, 0x1f150e68e322d1ed, 0x239b90ea3dc31e7e}, + {1, 0, 0, 0}}, + {{0x78c416527a53322a, 0x305dde6709776f8e, 0xdbcab759f8862ed4, 0x820f4dd949f72ff7}, + {0x6cc544a62b5debd4, 0x75be5d937b4e8cc4, 0x1b481b1b215c14d3, 0x140406ec783a05ec}, + {1, 0, 0, 0}}, + {{0x6a703f10e895df07, 0xfd75f3fa01876bd8, 0xeb5b06e70ce08ffe, 0x68f6b8542783dfee}, + {0x90c76f8a78712655, 0xcf5293d2f310bf7f, 0xfbc8044dfda45028, 0xcbe1feba92e40ce6}, + {1, 0, 0, 0}}, + {{0xe998ceea4396e4c1, 0xfc82ef0b6acea274, 0x230f729f2250e927, 0xd0b2f94d2f420109}, + {0x4305adddb38d4966, 0x10b838f8624c3b45, 0x7db2636658954e7a, 0x971459828b0719e5}, + {1, 0, 0, 0}}, + {{0x4bd6b72623369fc9, 0x57f2929e53d0b876, 0xc2d5cba4f2340687, 0x961610004a866aba}, + {0x49997bcd2e407a5e, 0x69ab197d92ddcb24, 0x2cf1f2438fe5131c, 0x7acb9fadcee75e44}, + {1, 0, 0, 0}}, + {{0x254e839423d2d4c0, 0xf57f0c917aea685b, 0xa60d880f6f75aaea, 0x24eb9acca333bf5b}, + {0xe3de4ccb1cda5dea, 0xfeef9341c51a6b4f, 0x743125f88bac4c4d, 0x69f891c5acd079cc}, + {1, 0, 0, 0}}, + {{0xeee44b35702476b5, 0x7ed031a0e45c2258, 0xb422d1e7bd6f8514, 0xe51f547c5972a107}, + {0xa25bcd6fc9cf343d, 0x8ca922ee097c184e, 0xa62f98b3a9fe9a06, 0x1c309a2b25bb1387}, + {1, 0, 0, 0}}, + {{0x9295dbeb1967c459, 0xb00148833472c98e, 0xc504977708011828, 0x20b87b8aa2c4e503}, + {0x3063175de057c277, 0x1bd539338fe582dd, 0x0d11adef5f69a044, 0xf5c6fa49919776be}, + {1, 0, 0, 0}}, + {{0x8c944e760fd59e11, 0x3876cba1102fad5f, 0xa454c3fad83faa56, 0x1ed7d1b9332010b9}, + {0xa1011a270024b889, 0x05e4d0dcac0cd344, 0x52b520f0eb6a2a24, 0x3a2b03f03217257a}, + {1, 0, 0, 0}}, + {{0xf20fc2afdf1d043d, 0xf330240db58d5a62, 0xfc7d229ca0058c3b, 0x15fee545c78dd9f6}, + {0x501e82885bc98cda, 0x41ef80e5d046ac04, 0x557d9f49461210fb, 0x4ab5b6b2b8753f81}, + {1, 0, 0, 0}}}}; + +/* select_point selects the |idx|th point from a precomputation table and + * copies it to out. */ +static void select_point(const u64 idx, unsigned int size, const smallfelem pre_comp[16][3], smallfelem out[3]) + { + unsigned i, j; + u64 *outlimbs = &out[0][0]; + memset(outlimbs, 0, 3 * sizeof(smallfelem)); + + for (i = 0; i < size; i++) + { + const u64 *inlimbs = (u64*) &pre_comp[i][0][0]; + u64 mask = i ^ idx; + mask |= mask >> 4; + mask |= mask >> 2; + mask |= mask >> 1; + mask &= 1; + mask--; + for (j = 0; j < NLIMBS * 3; j++) + outlimbs[j] |= inlimbs[j] & mask; + } + } + +/* get_bit returns the |i|th bit in |in| */ +static char get_bit(const felem_bytearray in, int i) + { + if ((i < 0) || (i >= 256)) + return 0; + return (in[i >> 3] >> (i & 7)) & 1; + } + +/* Interleaved point multiplication using precomputed point multiples: + * The small point multiples 0*P, 1*P, ..., 17*P are in pre_comp[], + * the scalars in scalars[]. If g_scalar is non-NULL, we also add this multiple + * of the generator, using certain (large) precomputed multiples in g_pre_comp. + * Output point (X, Y, Z) is stored in x_out, y_out, z_out */ +static void batch_mul(felem x_out, felem y_out, felem z_out, + const felem_bytearray scalars[], const unsigned num_points, const u8 *g_scalar, + const int mixed, const smallfelem pre_comp[][17][3], const smallfelem g_pre_comp[2][16][3]) + { + int i, skip; + unsigned num, gen_mul = (g_scalar != NULL); + felem nq[3], ftmp; + smallfelem tmp[3]; + u64 bits; + u8 sign, digit; + + /* set nq to the point at infinity */ + memset(nq, 0, 3 * sizeof(felem)); + + /* Loop over all scalars msb-to-lsb, interleaving additions + * of multiples of the generator (two in each of the last 32 rounds) + * and additions of other points multiples (every 5th round). + */ + skip = 1; /* save two point operations in the first round */ + for (i = (num_points ? 255 : 31); i >= 0; --i) + { + /* double */ + if (!skip) + point_double(nq[0], nq[1], nq[2], nq[0], nq[1], nq[2]); + + /* add multiples of the generator */ + if (gen_mul && (i <= 31)) + { + /* first, look 32 bits upwards */ + bits = get_bit(g_scalar, i + 224) << 3; + bits |= get_bit(g_scalar, i + 160) << 2; + bits |= get_bit(g_scalar, i + 96) << 1; + bits |= get_bit(g_scalar, i + 32); + /* select the point to add, in constant time */ + select_point(bits, 16, g_pre_comp[1], tmp); + + if (!skip) + { + point_add(nq[0], nq[1], nq[2], + nq[0], nq[1], nq[2], + 1 /* mixed */, tmp[0], tmp[1], tmp[2]); + } + else + { + smallfelem_expand(nq[0], tmp[0]); + smallfelem_expand(nq[1], tmp[1]); + smallfelem_expand(nq[2], tmp[2]); + skip = 0; + } + + /* second, look at the current position */ + bits = get_bit(g_scalar, i + 192) << 3; + bits |= get_bit(g_scalar, i + 128) << 2; + bits |= get_bit(g_scalar, i + 64) << 1; + bits |= get_bit(g_scalar, i); + /* select the point to add, in constant time */ + select_point(bits, 16, g_pre_comp[0], tmp); + point_add(nq[0], nq[1], nq[2], + nq[0], nq[1], nq[2], + 1 /* mixed */, tmp[0], tmp[1], tmp[2]); + } + + /* do other additions every 5 doublings */ + if (num_points && (i % 5 == 0)) + { + /* loop over all scalars */ + for (num = 0; num < num_points; ++num) + { + bits = get_bit(scalars[num], i + 4) << 5; + bits |= get_bit(scalars[num], i + 3) << 4; + bits |= get_bit(scalars[num], i + 2) << 3; + bits |= get_bit(scalars[num], i + 1) << 2; + bits |= get_bit(scalars[num], i) << 1; + bits |= get_bit(scalars[num], i - 1); + ec_GFp_nistp_recode_scalar_bits(&sign, &digit, bits); + + /* select the point to add or subtract, in constant time */ + select_point(digit, 17, pre_comp[num], tmp); + smallfelem_neg(ftmp, tmp[1]); /* (X, -Y, Z) is the negative point */ + copy_small_conditional(ftmp, tmp[1], (((limb) sign) - 1)); + felem_contract(tmp[1], ftmp); + + if (!skip) + { + point_add(nq[0], nq[1], nq[2], + nq[0], nq[1], nq[2], + mixed, tmp[0], tmp[1], tmp[2]); + } + else + { + smallfelem_expand(nq[0], tmp[0]); + smallfelem_expand(nq[1], tmp[1]); + smallfelem_expand(nq[2], tmp[2]); + skip = 0; + } + } + } + } + felem_assign(x_out, nq[0]); + felem_assign(y_out, nq[1]); + felem_assign(z_out, nq[2]); + } + +/* Precomputation for the group generator. */ +typedef struct { + smallfelem g_pre_comp[2][16][3]; + int references; +} NISTP256_PRE_COMP; + +const EC_METHOD *EC_GFp_nistp256_method(void) + { + static const EC_METHOD ret = { + EC_FLAGS_DEFAULT_OCT, + NID_X9_62_prime_field, + ec_GFp_nistp256_group_init, + ec_GFp_simple_group_finish, + ec_GFp_simple_group_clear_finish, + ec_GFp_nist_group_copy, + ec_GFp_nistp256_group_set_curve, + ec_GFp_simple_group_get_curve, + ec_GFp_simple_group_get_degree, + ec_GFp_simple_group_check_discriminant, + ec_GFp_simple_point_init, + ec_GFp_simple_point_finish, + ec_GFp_simple_point_clear_finish, + ec_GFp_simple_point_copy, + ec_GFp_simple_point_set_to_infinity, + ec_GFp_simple_set_Jprojective_coordinates_GFp, + ec_GFp_simple_get_Jprojective_coordinates_GFp, + ec_GFp_simple_point_set_affine_coordinates, + ec_GFp_nistp256_point_get_affine_coordinates, + 0 /* point_set_compressed_coordinates */, + 0 /* point2oct */, + 0 /* oct2point */, + ec_GFp_simple_add, + ec_GFp_simple_dbl, + ec_GFp_simple_invert, + ec_GFp_simple_is_at_infinity, + ec_GFp_simple_is_on_curve, + ec_GFp_simple_cmp, + ec_GFp_simple_make_affine, + ec_GFp_simple_points_make_affine, + ec_GFp_nistp256_points_mul, + ec_GFp_nistp256_precompute_mult, + ec_GFp_nistp256_have_precompute_mult, + ec_GFp_nist_field_mul, + ec_GFp_nist_field_sqr, + 0 /* field_div */, + 0 /* field_encode */, + 0 /* field_decode */, + 0 /* field_set_to_one */ }; + + return &ret; + } + +/******************************************************************************/ +/* FUNCTIONS TO MANAGE PRECOMPUTATION + */ + +static NISTP256_PRE_COMP *nistp256_pre_comp_new() + { + NISTP256_PRE_COMP *ret = NULL; + ret = (NISTP256_PRE_COMP *) OPENSSL_malloc(sizeof *ret); + if (!ret) + { + ECerr(EC_F_NISTP256_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE); + return ret; + } + memset(ret->g_pre_comp, 0, sizeof(ret->g_pre_comp)); + ret->references = 1; + return ret; + } + +static void *nistp256_pre_comp_dup(void *src_) + { + NISTP256_PRE_COMP *src = src_; + + /* no need to actually copy, these objects never change! */ + CRYPTO_add(&src->references, 1, CRYPTO_LOCK_EC_PRE_COMP); + + return src_; + } + +static void nistp256_pre_comp_free(void *pre_) + { + int i; + NISTP256_PRE_COMP *pre = pre_; + + if (!pre) + return; + + i = CRYPTO_add(&pre->references, -1, CRYPTO_LOCK_EC_PRE_COMP); + if (i > 0) + return; + + OPENSSL_free(pre); + } + +static void nistp256_pre_comp_clear_free(void *pre_) + { + int i; + NISTP256_PRE_COMP *pre = pre_; + + if (!pre) + return; + + i = CRYPTO_add(&pre->references, -1, CRYPTO_LOCK_EC_PRE_COMP); + if (i > 0) + return; + + OPENSSL_cleanse(pre, sizeof *pre); + OPENSSL_free(pre); + } + +/******************************************************************************/ +/* OPENSSL EC_METHOD FUNCTIONS + */ + +int ec_GFp_nistp256_group_init(EC_GROUP *group) + { + int ret; + ret = ec_GFp_simple_group_init(group); + group->a_is_minus3 = 1; + return ret; + } + +int ec_GFp_nistp256_group_set_curve(EC_GROUP *group, const BIGNUM *p, + const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) + { + int ret = 0; + BN_CTX *new_ctx = NULL; + BIGNUM *curve_p, *curve_a, *curve_b; + + if (ctx == NULL) + if ((ctx = new_ctx = BN_CTX_new()) == NULL) return 0; + BN_CTX_start(ctx); + if (((curve_p = BN_CTX_get(ctx)) == NULL) || + ((curve_a = BN_CTX_get(ctx)) == NULL) || + ((curve_b = BN_CTX_get(ctx)) == NULL)) goto err; + BN_bin2bn(nistp256_curve_params[0], sizeof(felem_bytearray), curve_p); + BN_bin2bn(nistp256_curve_params[1], sizeof(felem_bytearray), curve_a); + BN_bin2bn(nistp256_curve_params[2], sizeof(felem_bytearray), curve_b); + if ((BN_cmp(curve_p, p)) || (BN_cmp(curve_a, a)) || + (BN_cmp(curve_b, b))) + { + ECerr(EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE, + EC_R_WRONG_CURVE_PARAMETERS); + goto err; + } + group->field_mod_func = BN_nist_mod_256; + ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx); +err: + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return ret; + } + +/* Takes the Jacobian coordinates (X, Y, Z) of a point and returns + * (X', Y') = (X/Z^2, Y/Z^3) */ +int ec_GFp_nistp256_point_get_affine_coordinates(const EC_GROUP *group, + const EC_POINT *point, BIGNUM *x, BIGNUM *y, BN_CTX *ctx) + { + felem z1, z2, x_in, y_in; + smallfelem x_out, y_out; + longfelem tmp; + + if (EC_POINT_is_at_infinity(group, point)) + { + ECerr(EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES, + EC_R_POINT_AT_INFINITY); + return 0; + } + if ((!BN_to_felem(x_in, &point->X)) || (!BN_to_felem(y_in, &point->Y)) || + (!BN_to_felem(z1, &point->Z))) return 0; + felem_inv(z2, z1); + felem_square(tmp, z2); felem_reduce(z1, tmp); + felem_mul(tmp, x_in, z1); felem_reduce(x_in, tmp); + felem_contract(x_out, x_in); + if (x != NULL) + { + if (!smallfelem_to_BN(x, x_out)) { + ECerr(EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES, + ERR_R_BN_LIB); + return 0; + } + } + felem_mul(tmp, z1, z2); felem_reduce(z1, tmp); + felem_mul(tmp, y_in, z1); felem_reduce(y_in, tmp); + felem_contract(y_out, y_in); + if (y != NULL) + { + if (!smallfelem_to_BN(y, y_out)) + { + ECerr(EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES, + ERR_R_BN_LIB); + return 0; + } + } + return 1; + } + +static void make_points_affine(size_t num, smallfelem points[/* num */][3], smallfelem tmp_smallfelems[/* num+1 */]) + { + /* Runs in constant time, unless an input is the point at infinity + * (which normally shouldn't happen). */ + ec_GFp_nistp_points_make_affine_internal( + num, + points, + sizeof(smallfelem), + tmp_smallfelems, + (void (*)(void *)) smallfelem_one, + (int (*)(const void *)) smallfelem_is_zero_int, + (void (*)(void *, const void *)) smallfelem_assign, + (void (*)(void *, const void *)) smallfelem_square_contract, + (void (*)(void *, const void *, const void *)) smallfelem_mul_contract, + (void (*)(void *, const void *)) smallfelem_inv_contract, + (void (*)(void *, const void *)) smallfelem_assign /* nothing to contract */); + } + +/* Computes scalar*generator + \sum scalars[i]*points[i], ignoring NULL values + * Result is stored in r (r can equal one of the inputs). */ +int ec_GFp_nistp256_points_mul(const EC_GROUP *group, EC_POINT *r, + const BIGNUM *scalar, size_t num, const EC_POINT *points[], + const BIGNUM *scalars[], BN_CTX *ctx) + { + int ret = 0; + int j; + int mixed = 0; + BN_CTX *new_ctx = NULL; + BIGNUM *x, *y, *z, *tmp_scalar; + felem_bytearray g_secret; + felem_bytearray *secrets = NULL; + smallfelem (*pre_comp)[17][3] = NULL; + smallfelem *tmp_smallfelems = NULL; + felem_bytearray tmp; + unsigned i, num_bytes; + int have_pre_comp = 0; + size_t num_points = num; + smallfelem x_in, y_in, z_in; + felem x_out, y_out, z_out; + NISTP256_PRE_COMP *pre = NULL; + const smallfelem (*g_pre_comp)[16][3] = NULL; + EC_POINT *generator = NULL; + const EC_POINT *p = NULL; + const BIGNUM *p_scalar = NULL; + + if (ctx == NULL) + if ((ctx = new_ctx = BN_CTX_new()) == NULL) return 0; + BN_CTX_start(ctx); + if (((x = BN_CTX_get(ctx)) == NULL) || + ((y = BN_CTX_get(ctx)) == NULL) || + ((z = BN_CTX_get(ctx)) == NULL) || + ((tmp_scalar = BN_CTX_get(ctx)) == NULL)) + goto err; + + if (scalar != NULL) + { + pre = EC_EX_DATA_get_data(group->extra_data, + nistp256_pre_comp_dup, nistp256_pre_comp_free, + nistp256_pre_comp_clear_free); + if (pre) + /* we have precomputation, try to use it */ + g_pre_comp = (const smallfelem (*)[16][3]) pre->g_pre_comp; + else + /* try to use the standard precomputation */ + g_pre_comp = &gmul[0]; + generator = EC_POINT_new(group); + if (generator == NULL) + goto err; + /* get the generator from precomputation */ + if (!smallfelem_to_BN(x, g_pre_comp[0][1][0]) || + !smallfelem_to_BN(y, g_pre_comp[0][1][1]) || + !smallfelem_to_BN(z, g_pre_comp[0][1][2])) + { + ECerr(EC_F_EC_GFP_NISTP256_POINTS_MUL, ERR_R_BN_LIB); + goto err; + } + if (!EC_POINT_set_Jprojective_coordinates_GFp(group, + generator, x, y, z, ctx)) + goto err; + if (0 == EC_POINT_cmp(group, generator, group->generator, ctx)) + /* precomputation matches generator */ + have_pre_comp = 1; + else + /* we don't have valid precomputation: + * treat the generator as a random point */ + num_points++; + } + if (num_points > 0) + { + if (num_points >= 3) + { + /* unless we precompute multiples for just one or two points, + * converting those into affine form is time well spent */ + mixed = 1; + } + secrets = OPENSSL_malloc(num_points * sizeof(felem_bytearray)); + pre_comp = OPENSSL_malloc(num_points * 17 * 3 * sizeof(smallfelem)); + if (mixed) + tmp_smallfelems = OPENSSL_malloc((num_points * 17 + 1) * sizeof(smallfelem)); + if ((secrets == NULL) || (pre_comp == NULL) || (mixed && (tmp_smallfelems == NULL))) + { + ECerr(EC_F_EC_GFP_NISTP256_POINTS_MUL, ERR_R_MALLOC_FAILURE); + goto err; + } + + /* we treat NULL scalars as 0, and NULL points as points at infinity, + * i.e., they contribute nothing to the linear combination */ + memset(secrets, 0, num_points * sizeof(felem_bytearray)); + memset(pre_comp, 0, num_points * 17 * 3 * sizeof(smallfelem)); + for (i = 0; i < num_points; ++i) + { + if (i == num) + /* we didn't have a valid precomputation, so we pick + * the generator */ + { + p = EC_GROUP_get0_generator(group); + p_scalar = scalar; + } + else + /* the i^th point */ + { + p = points[i]; + p_scalar = scalars[i]; + } + if ((p_scalar != NULL) && (p != NULL)) + { + /* reduce scalar to 0 <= scalar < 2^256 */ + if ((BN_num_bits(p_scalar) > 256) || (BN_is_negative(p_scalar))) + { + /* this is an unusual input, and we don't guarantee + * constant-timeness */ + if (!BN_nnmod(tmp_scalar, p_scalar, &group->order, ctx)) + { + ECerr(EC_F_EC_GFP_NISTP256_POINTS_MUL, ERR_R_BN_LIB); + goto err; + } + num_bytes = BN_bn2bin(tmp_scalar, tmp); + } + else + num_bytes = BN_bn2bin(p_scalar, tmp); + flip_endian(secrets[i], tmp, num_bytes); + /* precompute multiples */ + if ((!BN_to_felem(x_out, &p->X)) || + (!BN_to_felem(y_out, &p->Y)) || + (!BN_to_felem(z_out, &p->Z))) goto err; + felem_shrink(pre_comp[i][1][0], x_out); + felem_shrink(pre_comp[i][1][1], y_out); + felem_shrink(pre_comp[i][1][2], z_out); + for (j = 2; j <= 16; ++j) + { + if (j & 1) + { + point_add_small( + pre_comp[i][j][0], pre_comp[i][j][1], pre_comp[i][j][2], + pre_comp[i][1][0], pre_comp[i][1][1], pre_comp[i][1][2], + pre_comp[i][j-1][0], pre_comp[i][j-1][1], pre_comp[i][j-1][2]); + } + else + { + point_double_small( + pre_comp[i][j][0], pre_comp[i][j][1], pre_comp[i][j][2], + pre_comp[i][j/2][0], pre_comp[i][j/2][1], pre_comp[i][j/2][2]); + } + } + } + } + if (mixed) + make_points_affine(num_points * 17, pre_comp[0], tmp_smallfelems); + } + + /* the scalar for the generator */ + if ((scalar != NULL) && (have_pre_comp)) + { + memset(g_secret, 0, sizeof(g_secret)); + /* reduce scalar to 0 <= scalar < 2^256 */ + if ((BN_num_bits(scalar) > 256) || (BN_is_negative(scalar))) + { + /* this is an unusual input, and we don't guarantee + * constant-timeness */ + if (!BN_nnmod(tmp_scalar, scalar, &group->order, ctx)) + { + ECerr(EC_F_EC_GFP_NISTP256_POINTS_MUL, ERR_R_BN_LIB); + goto err; + } + num_bytes = BN_bn2bin(tmp_scalar, tmp); + } + else + num_bytes = BN_bn2bin(scalar, tmp); + flip_endian(g_secret, tmp, num_bytes); + /* do the multiplication with generator precomputation*/ + batch_mul(x_out, y_out, z_out, + (const felem_bytearray (*)) secrets, num_points, + g_secret, + mixed, (const smallfelem (*)[17][3]) pre_comp, + g_pre_comp); + } + else + /* do the multiplication without generator precomputation */ + batch_mul(x_out, y_out, z_out, + (const felem_bytearray (*)) secrets, num_points, + NULL, mixed, (const smallfelem (*)[17][3]) pre_comp, NULL); + /* reduce the output to its unique minimal representation */ + felem_contract(x_in, x_out); + felem_contract(y_in, y_out); + felem_contract(z_in, z_out); + if ((!smallfelem_to_BN(x, x_in)) || (!smallfelem_to_BN(y, y_in)) || + (!smallfelem_to_BN(z, z_in))) + { + ECerr(EC_F_EC_GFP_NISTP256_POINTS_MUL, ERR_R_BN_LIB); + goto err; + } + ret = EC_POINT_set_Jprojective_coordinates_GFp(group, r, x, y, z, ctx); + +err: + BN_CTX_end(ctx); + if (generator != NULL) + EC_POINT_free(generator); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + if (secrets != NULL) + OPENSSL_free(secrets); + if (pre_comp != NULL) + OPENSSL_free(pre_comp); + if (tmp_smallfelems != NULL) + OPENSSL_free(tmp_smallfelems); + return ret; + } + +int ec_GFp_nistp256_precompute_mult(EC_GROUP *group, BN_CTX *ctx) + { + int ret = 0; + NISTP256_PRE_COMP *pre = NULL; + int i, j; + BN_CTX *new_ctx = NULL; + BIGNUM *x, *y; + EC_POINT *generator = NULL; + smallfelem tmp_smallfelems[32]; + felem x_tmp, y_tmp, z_tmp; + + /* throw away old precomputation */ + EC_EX_DATA_free_data(&group->extra_data, nistp256_pre_comp_dup, + nistp256_pre_comp_free, nistp256_pre_comp_clear_free); + if (ctx == NULL) + if ((ctx = new_ctx = BN_CTX_new()) == NULL) return 0; + BN_CTX_start(ctx); + if (((x = BN_CTX_get(ctx)) == NULL) || + ((y = BN_CTX_get(ctx)) == NULL)) + goto err; + /* get the generator */ + if (group->generator == NULL) goto err; + generator = EC_POINT_new(group); + if (generator == NULL) + goto err; + BN_bin2bn(nistp256_curve_params[3], sizeof (felem_bytearray), x); + BN_bin2bn(nistp256_curve_params[4], sizeof (felem_bytearray), y); + if (!EC_POINT_set_affine_coordinates_GFp(group, generator, x, y, ctx)) + goto err; + if ((pre = nistp256_pre_comp_new()) == NULL) + goto err; + /* if the generator is the standard one, use built-in precomputation */ + if (0 == EC_POINT_cmp(group, generator, group->generator, ctx)) + { + memcpy(pre->g_pre_comp, gmul, sizeof(pre->g_pre_comp)); + ret = 1; + goto err; + } + if ((!BN_to_felem(x_tmp, &group->generator->X)) || + (!BN_to_felem(y_tmp, &group->generator->Y)) || + (!BN_to_felem(z_tmp, &group->generator->Z))) + goto err; + felem_shrink(pre->g_pre_comp[0][1][0], x_tmp); + felem_shrink(pre->g_pre_comp[0][1][1], y_tmp); + felem_shrink(pre->g_pre_comp[0][1][2], z_tmp); + /* compute 2^64*G, 2^128*G, 2^192*G for the first table, + * 2^32*G, 2^96*G, 2^160*G, 2^224*G for the second one + */ + for (i = 1; i <= 8; i <<= 1) + { + point_double_small( + pre->g_pre_comp[1][i][0], pre->g_pre_comp[1][i][1], pre->g_pre_comp[1][i][2], + pre->g_pre_comp[0][i][0], pre->g_pre_comp[0][i][1], pre->g_pre_comp[0][i][2]); + for (j = 0; j < 31; ++j) + { + point_double_small( + pre->g_pre_comp[1][i][0], pre->g_pre_comp[1][i][1], pre->g_pre_comp[1][i][2], + pre->g_pre_comp[1][i][0], pre->g_pre_comp[1][i][1], pre->g_pre_comp[1][i][2]); + } + if (i == 8) + break; + point_double_small( + pre->g_pre_comp[0][2*i][0], pre->g_pre_comp[0][2*i][1], pre->g_pre_comp[0][2*i][2], + pre->g_pre_comp[1][i][0], pre->g_pre_comp[1][i][1], pre->g_pre_comp[1][i][2]); + for (j = 0; j < 31; ++j) + { + point_double_small( + pre->g_pre_comp[0][2*i][0], pre->g_pre_comp[0][2*i][1], pre->g_pre_comp[0][2*i][2], + pre->g_pre_comp[0][2*i][0], pre->g_pre_comp[0][2*i][1], pre->g_pre_comp[0][2*i][2]); + } + } + for (i = 0; i < 2; i++) + { + /* g_pre_comp[i][0] is the point at infinity */ + memset(pre->g_pre_comp[i][0], 0, sizeof(pre->g_pre_comp[i][0])); + /* the remaining multiples */ + /* 2^64*G + 2^128*G resp. 2^96*G + 2^160*G */ + point_add_small( + pre->g_pre_comp[i][6][0], pre->g_pre_comp[i][6][1], pre->g_pre_comp[i][6][2], + pre->g_pre_comp[i][4][0], pre->g_pre_comp[i][4][1], pre->g_pre_comp[i][4][2], + pre->g_pre_comp[i][2][0], pre->g_pre_comp[i][2][1], pre->g_pre_comp[i][2][2]); + /* 2^64*G + 2^192*G resp. 2^96*G + 2^224*G */ + point_add_small( + pre->g_pre_comp[i][10][0], pre->g_pre_comp[i][10][1], pre->g_pre_comp[i][10][2], + pre->g_pre_comp[i][8][0], pre->g_pre_comp[i][8][1], pre->g_pre_comp[i][8][2], + pre->g_pre_comp[i][2][0], pre->g_pre_comp[i][2][1], pre->g_pre_comp[i][2][2]); + /* 2^128*G + 2^192*G resp. 2^160*G + 2^224*G */ + point_add_small( + pre->g_pre_comp[i][12][0], pre->g_pre_comp[i][12][1], pre->g_pre_comp[i][12][2], + pre->g_pre_comp[i][8][0], pre->g_pre_comp[i][8][1], pre->g_pre_comp[i][8][2], + pre->g_pre_comp[i][4][0], pre->g_pre_comp[i][4][1], pre->g_pre_comp[i][4][2]); + /* 2^64*G + 2^128*G + 2^192*G resp. 2^96*G + 2^160*G + 2^224*G */ + point_add_small( + pre->g_pre_comp[i][14][0], pre->g_pre_comp[i][14][1], pre->g_pre_comp[i][14][2], + pre->g_pre_comp[i][12][0], pre->g_pre_comp[i][12][1], pre->g_pre_comp[i][12][2], + pre->g_pre_comp[i][2][0], pre->g_pre_comp[i][2][1], pre->g_pre_comp[i][2][2]); + for (j = 1; j < 8; ++j) + { + /* odd multiples: add G resp. 2^32*G */ + point_add_small( + pre->g_pre_comp[i][2*j+1][0], pre->g_pre_comp[i][2*j+1][1], pre->g_pre_comp[i][2*j+1][2], + pre->g_pre_comp[i][2*j][0], pre->g_pre_comp[i][2*j][1], pre->g_pre_comp[i][2*j][2], + pre->g_pre_comp[i][1][0], pre->g_pre_comp[i][1][1], pre->g_pre_comp[i][1][2]); + } + } + make_points_affine(31, &(pre->g_pre_comp[0][1]), tmp_smallfelems); + + if (!EC_EX_DATA_set_data(&group->extra_data, pre, nistp256_pre_comp_dup, + nistp256_pre_comp_free, nistp256_pre_comp_clear_free)) + goto err; + ret = 1; + pre = NULL; + err: + BN_CTX_end(ctx); + if (generator != NULL) + EC_POINT_free(generator); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + if (pre) + nistp256_pre_comp_free(pre); + return ret; + } + +int ec_GFp_nistp256_have_precompute_mult(const EC_GROUP *group) + { + if (EC_EX_DATA_get_data(group->extra_data, nistp256_pre_comp_dup, + nistp256_pre_comp_free, nistp256_pre_comp_clear_free) + != NULL) + return 1; + else + return 0; + } +#else +static void *dummy=&dummy; +#endif diff --git a/libs/openssl/crypto/ec/ecp_nistp521.c b/libs/openssl/crypto/ec/ecp_nistp521.c new file mode 100644 index 00000000..178b655f --- /dev/null +++ b/libs/openssl/crypto/ec/ecp_nistp521.c @@ -0,0 +1,2025 @@ +/* crypto/ec/ecp_nistp521.c */ +/* + * Written by Adam Langley (Google) for the OpenSSL project + */ +/* Copyright 2011 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * A 64-bit implementation of the NIST P-521 elliptic curve point multiplication + * + * OpenSSL integration was taken from Emilia Kasper's work in ecp_nistp224.c. + * Otherwise based on Emilia's P224 work, which was inspired by my curve25519 + * work which got its smarts from Daniel J. Bernstein's work on the same. + */ + +#include +#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 + +#ifndef OPENSSL_SYS_VMS +#include +#else +#include +#endif + +#include +#include +#include "ec_lcl.h" + +#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) + /* even with gcc, the typedef won't work for 32-bit platforms */ + typedef __uint128_t uint128_t; /* nonstandard; implemented by gcc on 64-bit platforms */ +#else + #error "Need GCC 3.1 or later to define type uint128_t" +#endif + +typedef uint8_t u8; +typedef uint64_t u64; +typedef int64_t s64; + +/* The underlying field. + * + * P521 operates over GF(2^521-1). We can serialise an element of this field + * into 66 bytes where the most significant byte contains only a single bit. We + * call this an felem_bytearray. */ + +typedef u8 felem_bytearray[66]; + +/* These are the parameters of P521, taken from FIPS 186-3, section D.1.2.5. + * These values are big-endian. */ +static const felem_bytearray nistp521_curve_params[5] = + { + {0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* p */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff}, + {0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* a = -3 */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xfc}, + {0x00, 0x51, 0x95, 0x3e, 0xb9, 0x61, 0x8e, 0x1c, /* b */ + 0x9a, 0x1f, 0x92, 0x9a, 0x21, 0xa0, 0xb6, 0x85, + 0x40, 0xee, 0xa2, 0xda, 0x72, 0x5b, 0x99, 0xb3, + 0x15, 0xf3, 0xb8, 0xb4, 0x89, 0x91, 0x8e, 0xf1, + 0x09, 0xe1, 0x56, 0x19, 0x39, 0x51, 0xec, 0x7e, + 0x93, 0x7b, 0x16, 0x52, 0xc0, 0xbd, 0x3b, 0xb1, + 0xbf, 0x07, 0x35, 0x73, 0xdf, 0x88, 0x3d, 0x2c, + 0x34, 0xf1, 0xef, 0x45, 0x1f, 0xd4, 0x6b, 0x50, + 0x3f, 0x00}, + {0x00, 0xc6, 0x85, 0x8e, 0x06, 0xb7, 0x04, 0x04, /* x */ + 0xe9, 0xcd, 0x9e, 0x3e, 0xcb, 0x66, 0x23, 0x95, + 0xb4, 0x42, 0x9c, 0x64, 0x81, 0x39, 0x05, 0x3f, + 0xb5, 0x21, 0xf8, 0x28, 0xaf, 0x60, 0x6b, 0x4d, + 0x3d, 0xba, 0xa1, 0x4b, 0x5e, 0x77, 0xef, 0xe7, + 0x59, 0x28, 0xfe, 0x1d, 0xc1, 0x27, 0xa2, 0xff, + 0xa8, 0xde, 0x33, 0x48, 0xb3, 0xc1, 0x85, 0x6a, + 0x42, 0x9b, 0xf9, 0x7e, 0x7e, 0x31, 0xc2, 0xe5, + 0xbd, 0x66}, + {0x01, 0x18, 0x39, 0x29, 0x6a, 0x78, 0x9a, 0x3b, /* y */ + 0xc0, 0x04, 0x5c, 0x8a, 0x5f, 0xb4, 0x2c, 0x7d, + 0x1b, 0xd9, 0x98, 0xf5, 0x44, 0x49, 0x57, 0x9b, + 0x44, 0x68, 0x17, 0xaf, 0xbd, 0x17, 0x27, 0x3e, + 0x66, 0x2c, 0x97, 0xee, 0x72, 0x99, 0x5e, 0xf4, + 0x26, 0x40, 0xc5, 0x50, 0xb9, 0x01, 0x3f, 0xad, + 0x07, 0x61, 0x35, 0x3c, 0x70, 0x86, 0xa2, 0x72, + 0xc2, 0x40, 0x88, 0xbe, 0x94, 0x76, 0x9f, 0xd1, + 0x66, 0x50} + }; + +/* The representation of field elements. + * ------------------------------------ + * + * We represent field elements with nine values. These values are either 64 or + * 128 bits and the field element represented is: + * v[0]*2^0 + v[1]*2^58 + v[2]*2^116 + ... + v[8]*2^464 (mod p) + * Each of the nine values is called a 'limb'. Since the limbs are spaced only + * 58 bits apart, but are greater than 58 bits in length, the most significant + * bits of each limb overlap with the least significant bits of the next. + * + * A field element with 64-bit limbs is an 'felem'. One with 128-bit limbs is a + * 'largefelem' */ + +#define NLIMBS 9 + +typedef uint64_t limb; +typedef limb felem[NLIMBS]; +typedef uint128_t largefelem[NLIMBS]; + +static const limb bottom57bits = 0x1ffffffffffffff; +static const limb bottom58bits = 0x3ffffffffffffff; + +/* bin66_to_felem takes a little-endian byte array and converts it into felem + * form. This assumes that the CPU is little-endian. */ +static void bin66_to_felem(felem out, const u8 in[66]) + { + out[0] = (*((limb*) &in[0])) & bottom58bits; + out[1] = (*((limb*) &in[7]) >> 2) & bottom58bits; + out[2] = (*((limb*) &in[14]) >> 4) & bottom58bits; + out[3] = (*((limb*) &in[21]) >> 6) & bottom58bits; + out[4] = (*((limb*) &in[29])) & bottom58bits; + out[5] = (*((limb*) &in[36]) >> 2) & bottom58bits; + out[6] = (*((limb*) &in[43]) >> 4) & bottom58bits; + out[7] = (*((limb*) &in[50]) >> 6) & bottom58bits; + out[8] = (*((limb*) &in[58])) & bottom57bits; + } + +/* felem_to_bin66 takes an felem and serialises into a little endian, 66 byte + * array. This assumes that the CPU is little-endian. */ +static void felem_to_bin66(u8 out[66], const felem in) + { + memset(out, 0, 66); + (*((limb*) &out[0])) = in[0]; + (*((limb*) &out[7])) |= in[1] << 2; + (*((limb*) &out[14])) |= in[2] << 4; + (*((limb*) &out[21])) |= in[3] << 6; + (*((limb*) &out[29])) = in[4]; + (*((limb*) &out[36])) |= in[5] << 2; + (*((limb*) &out[43])) |= in[6] << 4; + (*((limb*) &out[50])) |= in[7] << 6; + (*((limb*) &out[58])) = in[8]; + } + +/* To preserve endianness when using BN_bn2bin and BN_bin2bn */ +static void flip_endian(u8 *out, const u8 *in, unsigned len) + { + unsigned i; + for (i = 0; i < len; ++i) + out[i] = in[len-1-i]; + } + +/* BN_to_felem converts an OpenSSL BIGNUM into an felem */ +static int BN_to_felem(felem out, const BIGNUM *bn) + { + felem_bytearray b_in; + felem_bytearray b_out; + unsigned num_bytes; + + /* BN_bn2bin eats leading zeroes */ + memset(b_out, 0, sizeof b_out); + num_bytes = BN_num_bytes(bn); + if (num_bytes > sizeof b_out) + { + ECerr(EC_F_BN_TO_FELEM, EC_R_BIGNUM_OUT_OF_RANGE); + return 0; + } + if (BN_is_negative(bn)) + { + ECerr(EC_F_BN_TO_FELEM, EC_R_BIGNUM_OUT_OF_RANGE); + return 0; + } + num_bytes = BN_bn2bin(bn, b_in); + flip_endian(b_out, b_in, num_bytes); + bin66_to_felem(out, b_out); + return 1; + } + +/* felem_to_BN converts an felem into an OpenSSL BIGNUM */ +static BIGNUM *felem_to_BN(BIGNUM *out, const felem in) + { + felem_bytearray b_in, b_out; + felem_to_bin66(b_in, in); + flip_endian(b_out, b_in, sizeof b_out); + return BN_bin2bn(b_out, sizeof b_out, out); + } + + +/* Field operations + * ---------------- */ + +static void felem_one(felem out) + { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 0; + } + +static void felem_assign(felem out, const felem in) + { + out[0] = in[0]; + out[1] = in[1]; + out[2] = in[2]; + out[3] = in[3]; + out[4] = in[4]; + out[5] = in[5]; + out[6] = in[6]; + out[7] = in[7]; + out[8] = in[8]; + } + +/* felem_sum64 sets out = out + in. */ +static void felem_sum64(felem out, const felem in) + { + out[0] += in[0]; + out[1] += in[1]; + out[2] += in[2]; + out[3] += in[3]; + out[4] += in[4]; + out[5] += in[5]; + out[6] += in[6]; + out[7] += in[7]; + out[8] += in[8]; + } + +/* felem_scalar sets out = in * scalar */ +static void felem_scalar(felem out, const felem in, limb scalar) + { + out[0] = in[0] * scalar; + out[1] = in[1] * scalar; + out[2] = in[2] * scalar; + out[3] = in[3] * scalar; + out[4] = in[4] * scalar; + out[5] = in[5] * scalar; + out[6] = in[6] * scalar; + out[7] = in[7] * scalar; + out[8] = in[8] * scalar; + } + +/* felem_scalar64 sets out = out * scalar */ +static void felem_scalar64(felem out, limb scalar) + { + out[0] *= scalar; + out[1] *= scalar; + out[2] *= scalar; + out[3] *= scalar; + out[4] *= scalar; + out[5] *= scalar; + out[6] *= scalar; + out[7] *= scalar; + out[8] *= scalar; + } + +/* felem_scalar128 sets out = out * scalar */ +static void felem_scalar128(largefelem out, limb scalar) + { + out[0] *= scalar; + out[1] *= scalar; + out[2] *= scalar; + out[3] *= scalar; + out[4] *= scalar; + out[5] *= scalar; + out[6] *= scalar; + out[7] *= scalar; + out[8] *= scalar; + } + +/* felem_neg sets |out| to |-in| + * On entry: + * in[i] < 2^59 + 2^14 + * On exit: + * out[i] < 2^62 + */ +static void felem_neg(felem out, const felem in) + { + /* In order to prevent underflow, we subtract from 0 mod p. */ + static const limb two62m3 = (((limb)1) << 62) - (((limb)1) << 5); + static const limb two62m2 = (((limb)1) << 62) - (((limb)1) << 4); + + out[0] = two62m3 - in[0]; + out[1] = two62m2 - in[1]; + out[2] = two62m2 - in[2]; + out[3] = two62m2 - in[3]; + out[4] = two62m2 - in[4]; + out[5] = two62m2 - in[5]; + out[6] = two62m2 - in[6]; + out[7] = two62m2 - in[7]; + out[8] = two62m2 - in[8]; + } + +/* felem_diff64 subtracts |in| from |out| + * On entry: + * in[i] < 2^59 + 2^14 + * On exit: + * out[i] < out[i] + 2^62 + */ +static void felem_diff64(felem out, const felem in) + { + /* In order to prevent underflow, we add 0 mod p before subtracting. */ + static const limb two62m3 = (((limb)1) << 62) - (((limb)1) << 5); + static const limb two62m2 = (((limb)1) << 62) - (((limb)1) << 4); + + out[0] += two62m3 - in[0]; + out[1] += two62m2 - in[1]; + out[2] += two62m2 - in[2]; + out[3] += two62m2 - in[3]; + out[4] += two62m2 - in[4]; + out[5] += two62m2 - in[5]; + out[6] += two62m2 - in[6]; + out[7] += two62m2 - in[7]; + out[8] += two62m2 - in[8]; + } + +/* felem_diff_128_64 subtracts |in| from |out| + * On entry: + * in[i] < 2^62 + 2^17 + * On exit: + * out[i] < out[i] + 2^63 + */ +static void felem_diff_128_64(largefelem out, const felem in) + { + /* In order to prevent underflow, we add 0 mod p before subtracting. */ + static const limb two63m6 = (((limb)1) << 62) - (((limb)1) << 5); + static const limb two63m5 = (((limb)1) << 62) - (((limb)1) << 4); + + out[0] += two63m6 - in[0]; + out[1] += two63m5 - in[1]; + out[2] += two63m5 - in[2]; + out[3] += two63m5 - in[3]; + out[4] += two63m5 - in[4]; + out[5] += two63m5 - in[5]; + out[6] += two63m5 - in[6]; + out[7] += two63m5 - in[7]; + out[8] += two63m5 - in[8]; + } + +/* felem_diff_128_64 subtracts |in| from |out| + * On entry: + * in[i] < 2^126 + * On exit: + * out[i] < out[i] + 2^127 - 2^69 + */ +static void felem_diff128(largefelem out, const largefelem in) + { + /* In order to prevent underflow, we add 0 mod p before subtracting. */ + static const uint128_t two127m70 = (((uint128_t)1) << 127) - (((uint128_t)1) << 70); + static const uint128_t two127m69 = (((uint128_t)1) << 127) - (((uint128_t)1) << 69); + + out[0] += (two127m70 - in[0]); + out[1] += (two127m69 - in[1]); + out[2] += (two127m69 - in[2]); + out[3] += (two127m69 - in[3]); + out[4] += (two127m69 - in[4]); + out[5] += (two127m69 - in[5]); + out[6] += (two127m69 - in[6]); + out[7] += (two127m69 - in[7]); + out[8] += (two127m69 - in[8]); + } + +/* felem_square sets |out| = |in|^2 + * On entry: + * in[i] < 2^62 + * On exit: + * out[i] < 17 * max(in[i]) * max(in[i]) + */ +static void felem_square(largefelem out, const felem in) + { + felem inx2, inx4; + felem_scalar(inx2, in, 2); + felem_scalar(inx4, in, 4); + + /* We have many cases were we want to do + * in[x] * in[y] + + * in[y] * in[x] + * This is obviously just + * 2 * in[x] * in[y] + * However, rather than do the doubling on the 128 bit result, we + * double one of the inputs to the multiplication by reading from + * |inx2| */ + + out[0] = ((uint128_t) in[0]) * in[0]; + out[1] = ((uint128_t) in[0]) * inx2[1]; + out[2] = ((uint128_t) in[0]) * inx2[2] + + ((uint128_t) in[1]) * in[1]; + out[3] = ((uint128_t) in[0]) * inx2[3] + + ((uint128_t) in[1]) * inx2[2]; + out[4] = ((uint128_t) in[0]) * inx2[4] + + ((uint128_t) in[1]) * inx2[3] + + ((uint128_t) in[2]) * in[2]; + out[5] = ((uint128_t) in[0]) * inx2[5] + + ((uint128_t) in[1]) * inx2[4] + + ((uint128_t) in[2]) * inx2[3]; + out[6] = ((uint128_t) in[0]) * inx2[6] + + ((uint128_t) in[1]) * inx2[5] + + ((uint128_t) in[2]) * inx2[4] + + ((uint128_t) in[3]) * in[3]; + out[7] = ((uint128_t) in[0]) * inx2[7] + + ((uint128_t) in[1]) * inx2[6] + + ((uint128_t) in[2]) * inx2[5] + + ((uint128_t) in[3]) * inx2[4]; + out[8] = ((uint128_t) in[0]) * inx2[8] + + ((uint128_t) in[1]) * inx2[7] + + ((uint128_t) in[2]) * inx2[6] + + ((uint128_t) in[3]) * inx2[5] + + ((uint128_t) in[4]) * in[4]; + + /* The remaining limbs fall above 2^521, with the first falling at + * 2^522. They correspond to locations one bit up from the limbs + * produced above so we would have to multiply by two to align them. + * Again, rather than operate on the 128-bit result, we double one of + * the inputs to the multiplication. If we want to double for both this + * reason, and the reason above, then we end up multiplying by four. */ + + /* 9 */ + out[0] += ((uint128_t) in[1]) * inx4[8] + + ((uint128_t) in[2]) * inx4[7] + + ((uint128_t) in[3]) * inx4[6] + + ((uint128_t) in[4]) * inx4[5]; + + /* 10 */ + out[1] += ((uint128_t) in[2]) * inx4[8] + + ((uint128_t) in[3]) * inx4[7] + + ((uint128_t) in[4]) * inx4[6] + + ((uint128_t) in[5]) * inx2[5]; + + /* 11 */ + out[2] += ((uint128_t) in[3]) * inx4[8] + + ((uint128_t) in[4]) * inx4[7] + + ((uint128_t) in[5]) * inx4[6]; + + /* 12 */ + out[3] += ((uint128_t) in[4]) * inx4[8] + + ((uint128_t) in[5]) * inx4[7] + + ((uint128_t) in[6]) * inx2[6]; + + /* 13 */ + out[4] += ((uint128_t) in[5]) * inx4[8] + + ((uint128_t) in[6]) * inx4[7]; + + /* 14 */ + out[5] += ((uint128_t) in[6]) * inx4[8] + + ((uint128_t) in[7]) * inx2[7]; + + /* 15 */ + out[6] += ((uint128_t) in[7]) * inx4[8]; + + /* 16 */ + out[7] += ((uint128_t) in[8]) * inx2[8]; + } + +/* felem_mul sets |out| = |in1| * |in2| + * On entry: + * in1[i] < 2^64 + * in2[i] < 2^63 + * On exit: + * out[i] < 17 * max(in1[i]) * max(in2[i]) + */ +static void felem_mul(largefelem out, const felem in1, const felem in2) + { + felem in2x2; + felem_scalar(in2x2, in2, 2); + + out[0] = ((uint128_t) in1[0]) * in2[0]; + + out[1] = ((uint128_t) in1[0]) * in2[1] + + ((uint128_t) in1[1]) * in2[0]; + + out[2] = ((uint128_t) in1[0]) * in2[2] + + ((uint128_t) in1[1]) * in2[1] + + ((uint128_t) in1[2]) * in2[0]; + + out[3] = ((uint128_t) in1[0]) * in2[3] + + ((uint128_t) in1[1]) * in2[2] + + ((uint128_t) in1[2]) * in2[1] + + ((uint128_t) in1[3]) * in2[0]; + + out[4] = ((uint128_t) in1[0]) * in2[4] + + ((uint128_t) in1[1]) * in2[3] + + ((uint128_t) in1[2]) * in2[2] + + ((uint128_t) in1[3]) * in2[1] + + ((uint128_t) in1[4]) * in2[0]; + + out[5] = ((uint128_t) in1[0]) * in2[5] + + ((uint128_t) in1[1]) * in2[4] + + ((uint128_t) in1[2]) * in2[3] + + ((uint128_t) in1[3]) * in2[2] + + ((uint128_t) in1[4]) * in2[1] + + ((uint128_t) in1[5]) * in2[0]; + + out[6] = ((uint128_t) in1[0]) * in2[6] + + ((uint128_t) in1[1]) * in2[5] + + ((uint128_t) in1[2]) * in2[4] + + ((uint128_t) in1[3]) * in2[3] + + ((uint128_t) in1[4]) * in2[2] + + ((uint128_t) in1[5]) * in2[1] + + ((uint128_t) in1[6]) * in2[0]; + + out[7] = ((uint128_t) in1[0]) * in2[7] + + ((uint128_t) in1[1]) * in2[6] + + ((uint128_t) in1[2]) * in2[5] + + ((uint128_t) in1[3]) * in2[4] + + ((uint128_t) in1[4]) * in2[3] + + ((uint128_t) in1[5]) * in2[2] + + ((uint128_t) in1[6]) * in2[1] + + ((uint128_t) in1[7]) * in2[0]; + + out[8] = ((uint128_t) in1[0]) * in2[8] + + ((uint128_t) in1[1]) * in2[7] + + ((uint128_t) in1[2]) * in2[6] + + ((uint128_t) in1[3]) * in2[5] + + ((uint128_t) in1[4]) * in2[4] + + ((uint128_t) in1[5]) * in2[3] + + ((uint128_t) in1[6]) * in2[2] + + ((uint128_t) in1[7]) * in2[1] + + ((uint128_t) in1[8]) * in2[0]; + + /* See comment in felem_square about the use of in2x2 here */ + + out[0] += ((uint128_t) in1[1]) * in2x2[8] + + ((uint128_t) in1[2]) * in2x2[7] + + ((uint128_t) in1[3]) * in2x2[6] + + ((uint128_t) in1[4]) * in2x2[5] + + ((uint128_t) in1[5]) * in2x2[4] + + ((uint128_t) in1[6]) * in2x2[3] + + ((uint128_t) in1[7]) * in2x2[2] + + ((uint128_t) in1[8]) * in2x2[1]; + + out[1] += ((uint128_t) in1[2]) * in2x2[8] + + ((uint128_t) in1[3]) * in2x2[7] + + ((uint128_t) in1[4]) * in2x2[6] + + ((uint128_t) in1[5]) * in2x2[5] + + ((uint128_t) in1[6]) * in2x2[4] + + ((uint128_t) in1[7]) * in2x2[3] + + ((uint128_t) in1[8]) * in2x2[2]; + + out[2] += ((uint128_t) in1[3]) * in2x2[8] + + ((uint128_t) in1[4]) * in2x2[7] + + ((uint128_t) in1[5]) * in2x2[6] + + ((uint128_t) in1[6]) * in2x2[5] + + ((uint128_t) in1[7]) * in2x2[4] + + ((uint128_t) in1[8]) * in2x2[3]; + + out[3] += ((uint128_t) in1[4]) * in2x2[8] + + ((uint128_t) in1[5]) * in2x2[7] + + ((uint128_t) in1[6]) * in2x2[6] + + ((uint128_t) in1[7]) * in2x2[5] + + ((uint128_t) in1[8]) * in2x2[4]; + + out[4] += ((uint128_t) in1[5]) * in2x2[8] + + ((uint128_t) in1[6]) * in2x2[7] + + ((uint128_t) in1[7]) * in2x2[6] + + ((uint128_t) in1[8]) * in2x2[5]; + + out[5] += ((uint128_t) in1[6]) * in2x2[8] + + ((uint128_t) in1[7]) * in2x2[7] + + ((uint128_t) in1[8]) * in2x2[6]; + + out[6] += ((uint128_t) in1[7]) * in2x2[8] + + ((uint128_t) in1[8]) * in2x2[7]; + + out[7] += ((uint128_t) in1[8]) * in2x2[8]; + } + +static const limb bottom52bits = 0xfffffffffffff; + +/* felem_reduce converts a largefelem to an felem. + * On entry: + * in[i] < 2^128 + * On exit: + * out[i] < 2^59 + 2^14 + */ +static void felem_reduce(felem out, const largefelem in) + { + u64 overflow1, overflow2; + + out[0] = ((limb) in[0]) & bottom58bits; + out[1] = ((limb) in[1]) & bottom58bits; + out[2] = ((limb) in[2]) & bottom58bits; + out[3] = ((limb) in[3]) & bottom58bits; + out[4] = ((limb) in[4]) & bottom58bits; + out[5] = ((limb) in[5]) & bottom58bits; + out[6] = ((limb) in[6]) & bottom58bits; + out[7] = ((limb) in[7]) & bottom58bits; + out[8] = ((limb) in[8]) & bottom58bits; + + /* out[i] < 2^58 */ + + out[1] += ((limb) in[0]) >> 58; + out[1] += (((limb) (in[0] >> 64)) & bottom52bits) << 6; + /* out[1] < 2^58 + 2^6 + 2^58 + * = 2^59 + 2^6 */ + out[2] += ((limb) (in[0] >> 64)) >> 52; + + out[2] += ((limb) in[1]) >> 58; + out[2] += (((limb) (in[1] >> 64)) & bottom52bits) << 6; + out[3] += ((limb) (in[1] >> 64)) >> 52; + + out[3] += ((limb) in[2]) >> 58; + out[3] += (((limb) (in[2] >> 64)) & bottom52bits) << 6; + out[4] += ((limb) (in[2] >> 64)) >> 52; + + out[4] += ((limb) in[3]) >> 58; + out[4] += (((limb) (in[3] >> 64)) & bottom52bits) << 6; + out[5] += ((limb) (in[3] >> 64)) >> 52; + + out[5] += ((limb) in[4]) >> 58; + out[5] += (((limb) (in[4] >> 64)) & bottom52bits) << 6; + out[6] += ((limb) (in[4] >> 64)) >> 52; + + out[6] += ((limb) in[5]) >> 58; + out[6] += (((limb) (in[5] >> 64)) & bottom52bits) << 6; + out[7] += ((limb) (in[5] >> 64)) >> 52; + + out[7] += ((limb) in[6]) >> 58; + out[7] += (((limb) (in[6] >> 64)) & bottom52bits) << 6; + out[8] += ((limb) (in[6] >> 64)) >> 52; + + out[8] += ((limb) in[7]) >> 58; + out[8] += (((limb) (in[7] >> 64)) & bottom52bits) << 6; + /* out[x > 1] < 2^58 + 2^6 + 2^58 + 2^12 + * < 2^59 + 2^13 */ + overflow1 = ((limb) (in[7] >> 64)) >> 52; + + overflow1 += ((limb) in[8]) >> 58; + overflow1 += (((limb) (in[8] >> 64)) & bottom52bits) << 6; + overflow2 = ((limb) (in[8] >> 64)) >> 52; + + overflow1 <<= 1; /* overflow1 < 2^13 + 2^7 + 2^59 */ + overflow2 <<= 1; /* overflow2 < 2^13 */ + + out[0] += overflow1; /* out[0] < 2^60 */ + out[1] += overflow2; /* out[1] < 2^59 + 2^6 + 2^13 */ + + out[1] += out[0] >> 58; out[0] &= bottom58bits; + /* out[0] < 2^58 + * out[1] < 2^59 + 2^6 + 2^13 + 2^2 + * < 2^59 + 2^14 */ + } + +static void felem_square_reduce(felem out, const felem in) + { + largefelem tmp; + felem_square(tmp, in); + felem_reduce(out, tmp); + } + +static void felem_mul_reduce(felem out, const felem in1, const felem in2) + { + largefelem tmp; + felem_mul(tmp, in1, in2); + felem_reduce(out, tmp); + } + +/* felem_inv calculates |out| = |in|^{-1} + * + * Based on Fermat's Little Theorem: + * a^p = a (mod p) + * a^{p-1} = 1 (mod p) + * a^{p-2} = a^{-1} (mod p) + */ +static void felem_inv(felem out, const felem in) + { + felem ftmp, ftmp2, ftmp3, ftmp4; + largefelem tmp; + unsigned i; + + felem_square(tmp, in); felem_reduce(ftmp, tmp); /* 2^1 */ + felem_mul(tmp, in, ftmp); felem_reduce(ftmp, tmp); /* 2^2 - 2^0 */ + felem_assign(ftmp2, ftmp); + felem_square(tmp, ftmp); felem_reduce(ftmp, tmp); /* 2^3 - 2^1 */ + felem_mul(tmp, in, ftmp); felem_reduce(ftmp, tmp); /* 2^3 - 2^0 */ + felem_square(tmp, ftmp); felem_reduce(ftmp, tmp); /* 2^4 - 2^1 */ + + felem_square(tmp, ftmp2); felem_reduce(ftmp3, tmp); /* 2^3 - 2^1 */ + felem_square(tmp, ftmp3); felem_reduce(ftmp3, tmp); /* 2^4 - 2^2 */ + felem_mul(tmp, ftmp3, ftmp2); felem_reduce(ftmp3, tmp); /* 2^4 - 2^0 */ + + felem_assign(ftmp2, ftmp3); + felem_square(tmp, ftmp3); felem_reduce(ftmp3, tmp); /* 2^5 - 2^1 */ + felem_square(tmp, ftmp3); felem_reduce(ftmp3, tmp); /* 2^6 - 2^2 */ + felem_square(tmp, ftmp3); felem_reduce(ftmp3, tmp); /* 2^7 - 2^3 */ + felem_square(tmp, ftmp3); felem_reduce(ftmp3, tmp); /* 2^8 - 2^4 */ + felem_assign(ftmp4, ftmp3); + felem_mul(tmp, ftmp3, ftmp); felem_reduce(ftmp4, tmp); /* 2^8 - 2^1 */ + felem_square(tmp, ftmp4); felem_reduce(ftmp4, tmp); /* 2^9 - 2^2 */ + felem_mul(tmp, ftmp3, ftmp2); felem_reduce(ftmp3, tmp); /* 2^8 - 2^0 */ + felem_assign(ftmp2, ftmp3); + + for (i = 0; i < 8; i++) + { + felem_square(tmp, ftmp3); felem_reduce(ftmp3, tmp); /* 2^16 - 2^8 */ + } + felem_mul(tmp, ftmp3, ftmp2); felem_reduce(ftmp3, tmp); /* 2^16 - 2^0 */ + felem_assign(ftmp2, ftmp3); + + for (i = 0; i < 16; i++) + { + felem_square(tmp, ftmp3); felem_reduce(ftmp3, tmp); /* 2^32 - 2^16 */ + } + felem_mul(tmp, ftmp3, ftmp2); felem_reduce(ftmp3, tmp); /* 2^32 - 2^0 */ + felem_assign(ftmp2, ftmp3); + + for (i = 0; i < 32; i++) + { + felem_square(tmp, ftmp3); felem_reduce(ftmp3, tmp); /* 2^64 - 2^32 */ + } + felem_mul(tmp, ftmp3, ftmp2); felem_reduce(ftmp3, tmp); /* 2^64 - 2^0 */ + felem_assign(ftmp2, ftmp3); + + for (i = 0; i < 64; i++) + { + felem_square(tmp, ftmp3); felem_reduce(ftmp3, tmp); /* 2^128 - 2^64 */ + } + felem_mul(tmp, ftmp3, ftmp2); felem_reduce(ftmp3, tmp); /* 2^128 - 2^0 */ + felem_assign(ftmp2, ftmp3); + + for (i = 0; i < 128; i++) + { + felem_square(tmp, ftmp3); felem_reduce(ftmp3, tmp); /* 2^256 - 2^128 */ + } + felem_mul(tmp, ftmp3, ftmp2); felem_reduce(ftmp3, tmp); /* 2^256 - 2^0 */ + felem_assign(ftmp2, ftmp3); + + for (i = 0; i < 256; i++) + { + felem_square(tmp, ftmp3); felem_reduce(ftmp3, tmp); /* 2^512 - 2^256 */ + } + felem_mul(tmp, ftmp3, ftmp2); felem_reduce(ftmp3, tmp); /* 2^512 - 2^0 */ + + for (i = 0; i < 9; i++) + { + felem_square(tmp, ftmp3); felem_reduce(ftmp3, tmp); /* 2^521 - 2^9 */ + } + felem_mul(tmp, ftmp3, ftmp4); felem_reduce(ftmp3, tmp); /* 2^512 - 2^2 */ + felem_mul(tmp, ftmp3, in); felem_reduce(out, tmp); /* 2^512 - 3 */ +} + +/* This is 2^521-1, expressed as an felem */ +static const felem kPrime = + { + 0x03ffffffffffffff, 0x03ffffffffffffff, 0x03ffffffffffffff, + 0x03ffffffffffffff, 0x03ffffffffffffff, 0x03ffffffffffffff, + 0x03ffffffffffffff, 0x03ffffffffffffff, 0x01ffffffffffffff + }; + +/* felem_is_zero returns a limb with all bits set if |in| == 0 (mod p) and 0 + * otherwise. + * On entry: + * in[i] < 2^59 + 2^14 + */ +static limb felem_is_zero(const felem in) + { + felem ftmp; + limb is_zero, is_p; + felem_assign(ftmp, in); + + ftmp[0] += ftmp[8] >> 57; ftmp[8] &= bottom57bits; + /* ftmp[8] < 2^57 */ + ftmp[1] += ftmp[0] >> 58; ftmp[0] &= bottom58bits; + ftmp[2] += ftmp[1] >> 58; ftmp[1] &= bottom58bits; + ftmp[3] += ftmp[2] >> 58; ftmp[2] &= bottom58bits; + ftmp[4] += ftmp[3] >> 58; ftmp[3] &= bottom58bits; + ftmp[5] += ftmp[4] >> 58; ftmp[4] &= bottom58bits; + ftmp[6] += ftmp[5] >> 58; ftmp[5] &= bottom58bits; + ftmp[7] += ftmp[6] >> 58; ftmp[6] &= bottom58bits; + ftmp[8] += ftmp[7] >> 58; ftmp[7] &= bottom58bits; + /* ftmp[8] < 2^57 + 4 */ + + /* The ninth limb of 2*(2^521-1) is 0x03ffffffffffffff, which is + * greater than our bound for ftmp[8]. Therefore we only have to check + * if the zero is zero or 2^521-1. */ + + is_zero = 0; + is_zero |= ftmp[0]; + is_zero |= ftmp[1]; + is_zero |= ftmp[2]; + is_zero |= ftmp[3]; + is_zero |= ftmp[4]; + is_zero |= ftmp[5]; + is_zero |= ftmp[6]; + is_zero |= ftmp[7]; + is_zero |= ftmp[8]; + + is_zero--; + /* We know that ftmp[i] < 2^63, therefore the only way that the top bit + * can be set is if is_zero was 0 before the decrement. */ + is_zero = ((s64) is_zero) >> 63; + + is_p = ftmp[0] ^ kPrime[0]; + is_p |= ftmp[1] ^ kPrime[1]; + is_p |= ftmp[2] ^ kPrime[2]; + is_p |= ftmp[3] ^ kPrime[3]; + is_p |= ftmp[4] ^ kPrime[4]; + is_p |= ftmp[5] ^ kPrime[5]; + is_p |= ftmp[6] ^ kPrime[6]; + is_p |= ftmp[7] ^ kPrime[7]; + is_p |= ftmp[8] ^ kPrime[8]; + + is_p--; + is_p = ((s64) is_p) >> 63; + + is_zero |= is_p; + return is_zero; + } + +static int felem_is_zero_int(const felem in) + { + return (int) (felem_is_zero(in) & ((limb)1)); + } + +/* felem_contract converts |in| to its unique, minimal representation. + * On entry: + * in[i] < 2^59 + 2^14 + */ +static void felem_contract(felem out, const felem in) + { + limb is_p, is_greater, sign; + static const limb two58 = ((limb)1) << 58; + + felem_assign(out, in); + + out[0] += out[8] >> 57; out[8] &= bottom57bits; + /* out[8] < 2^57 */ + out[1] += out[0] >> 58; out[0] &= bottom58bits; + out[2] += out[1] >> 58; out[1] &= bottom58bits; + out[3] += out[2] >> 58; out[2] &= bottom58bits; + out[4] += out[3] >> 58; out[3] &= bottom58bits; + out[5] += out[4] >> 58; out[4] &= bottom58bits; + out[6] += out[5] >> 58; out[5] &= bottom58bits; + out[7] += out[6] >> 58; out[6] &= bottom58bits; + out[8] += out[7] >> 58; out[7] &= bottom58bits; + /* out[8] < 2^57 + 4 */ + + /* If the value is greater than 2^521-1 then we have to subtract + * 2^521-1 out. See the comments in felem_is_zero regarding why we + * don't test for other multiples of the prime. */ + + /* First, if |out| is equal to 2^521-1, we subtract it out to get zero. */ + + is_p = out[0] ^ kPrime[0]; + is_p |= out[1] ^ kPrime[1]; + is_p |= out[2] ^ kPrime[2]; + is_p |= out[3] ^ kPrime[3]; + is_p |= out[4] ^ kPrime[4]; + is_p |= out[5] ^ kPrime[5]; + is_p |= out[6] ^ kPrime[6]; + is_p |= out[7] ^ kPrime[7]; + is_p |= out[8] ^ kPrime[8]; + + is_p--; + is_p &= is_p << 32; + is_p &= is_p << 16; + is_p &= is_p << 8; + is_p &= is_p << 4; + is_p &= is_p << 2; + is_p &= is_p << 1; + is_p = ((s64) is_p) >> 63; + is_p = ~is_p; + + /* is_p is 0 iff |out| == 2^521-1 and all ones otherwise */ + + out[0] &= is_p; + out[1] &= is_p; + out[2] &= is_p; + out[3] &= is_p; + out[4] &= is_p; + out[5] &= is_p; + out[6] &= is_p; + out[7] &= is_p; + out[8] &= is_p; + + /* In order to test that |out| >= 2^521-1 we need only test if out[8] + * >> 57 is greater than zero as (2^521-1) + x >= 2^522 */ + is_greater = out[8] >> 57; + is_greater |= is_greater << 32; + is_greater |= is_greater << 16; + is_greater |= is_greater << 8; + is_greater |= is_greater << 4; + is_greater |= is_greater << 2; + is_greater |= is_greater << 1; + is_greater = ((s64) is_greater) >> 63; + + out[0] -= kPrime[0] & is_greater; + out[1] -= kPrime[1] & is_greater; + out[2] -= kPrime[2] & is_greater; + out[3] -= kPrime[3] & is_greater; + out[4] -= kPrime[4] & is_greater; + out[5] -= kPrime[5] & is_greater; + out[6] -= kPrime[6] & is_greater; + out[7] -= kPrime[7] & is_greater; + out[8] -= kPrime[8] & is_greater; + + /* Eliminate negative coefficients */ + sign = -(out[0] >> 63); out[0] += (two58 & sign); out[1] -= (1 & sign); + sign = -(out[1] >> 63); out[1] += (two58 & sign); out[2] -= (1 & sign); + sign = -(out[2] >> 63); out[2] += (two58 & sign); out[3] -= (1 & sign); + sign = -(out[3] >> 63); out[3] += (two58 & sign); out[4] -= (1 & sign); + sign = -(out[4] >> 63); out[4] += (two58 & sign); out[5] -= (1 & sign); + sign = -(out[0] >> 63); out[5] += (two58 & sign); out[6] -= (1 & sign); + sign = -(out[6] >> 63); out[6] += (two58 & sign); out[7] -= (1 & sign); + sign = -(out[7] >> 63); out[7] += (two58 & sign); out[8] -= (1 & sign); + sign = -(out[5] >> 63); out[5] += (two58 & sign); out[6] -= (1 & sign); + sign = -(out[6] >> 63); out[6] += (two58 & sign); out[7] -= (1 & sign); + sign = -(out[7] >> 63); out[7] += (two58 & sign); out[8] -= (1 & sign); + } + +/* Group operations + * ---------------- + * + * Building on top of the field operations we have the operations on the + * elliptic curve group itself. Points on the curve are represented in Jacobian + * coordinates */ + +/* point_double calcuates 2*(x_in, y_in, z_in) + * + * The method is taken from: + * http://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b + * + * Outputs can equal corresponding inputs, i.e., x_out == x_in is allowed. + * while x_out == y_in is not (maybe this works, but it's not tested). */ +static void +point_double(felem x_out, felem y_out, felem z_out, + const felem x_in, const felem y_in, const felem z_in) + { + largefelem tmp, tmp2; + felem delta, gamma, beta, alpha, ftmp, ftmp2; + + felem_assign(ftmp, x_in); + felem_assign(ftmp2, x_in); + + /* delta = z^2 */ + felem_square(tmp, z_in); + felem_reduce(delta, tmp); /* delta[i] < 2^59 + 2^14 */ + + /* gamma = y^2 */ + felem_square(tmp, y_in); + felem_reduce(gamma, tmp); /* gamma[i] < 2^59 + 2^14 */ + + /* beta = x*gamma */ + felem_mul(tmp, x_in, gamma); + felem_reduce(beta, tmp); /* beta[i] < 2^59 + 2^14 */ + + /* alpha = 3*(x-delta)*(x+delta) */ + felem_diff64(ftmp, delta); + /* ftmp[i] < 2^61 */ + felem_sum64(ftmp2, delta); + /* ftmp2[i] < 2^60 + 2^15 */ + felem_scalar64(ftmp2, 3); + /* ftmp2[i] < 3*2^60 + 3*2^15 */ + felem_mul(tmp, ftmp, ftmp2); + /* tmp[i] < 17(3*2^121 + 3*2^76) + * = 61*2^121 + 61*2^76 + * < 64*2^121 + 64*2^76 + * = 2^127 + 2^82 + * < 2^128 */ + felem_reduce(alpha, tmp); + + /* x' = alpha^2 - 8*beta */ + felem_square(tmp, alpha); + /* tmp[i] < 17*2^120 + * < 2^125 */ + felem_assign(ftmp, beta); + felem_scalar64(ftmp, 8); + /* ftmp[i] < 2^62 + 2^17 */ + felem_diff_128_64(tmp, ftmp); + /* tmp[i] < 2^125 + 2^63 + 2^62 + 2^17 */ + felem_reduce(x_out, tmp); + + /* z' = (y + z)^2 - gamma - delta */ + felem_sum64(delta, gamma); + /* delta[i] < 2^60 + 2^15 */ + felem_assign(ftmp, y_in); + felem_sum64(ftmp, z_in); + /* ftmp[i] < 2^60 + 2^15 */ + felem_square(tmp, ftmp); + /* tmp[i] < 17(2^122) + * < 2^127 */ + felem_diff_128_64(tmp, delta); + /* tmp[i] < 2^127 + 2^63 */ + felem_reduce(z_out, tmp); + + /* y' = alpha*(4*beta - x') - 8*gamma^2 */ + felem_scalar64(beta, 4); + /* beta[i] < 2^61 + 2^16 */ + felem_diff64(beta, x_out); + /* beta[i] < 2^61 + 2^60 + 2^16 */ + felem_mul(tmp, alpha, beta); + /* tmp[i] < 17*((2^59 + 2^14)(2^61 + 2^60 + 2^16)) + * = 17*(2^120 + 2^75 + 2^119 + 2^74 + 2^75 + 2^30) + * = 17*(2^120 + 2^119 + 2^76 + 2^74 + 2^30) + * < 2^128 */ + felem_square(tmp2, gamma); + /* tmp2[i] < 17*(2^59 + 2^14)^2 + * = 17*(2^118 + 2^74 + 2^28) */ + felem_scalar128(tmp2, 8); + /* tmp2[i] < 8*17*(2^118 + 2^74 + 2^28) + * = 2^125 + 2^121 + 2^81 + 2^77 + 2^35 + 2^31 + * < 2^126 */ + felem_diff128(tmp, tmp2); + /* tmp[i] < 2^127 - 2^69 + 17(2^120 + 2^119 + 2^76 + 2^74 + 2^30) + * = 2^127 + 2^124 + 2^122 + 2^120 + 2^118 + 2^80 + 2^78 + 2^76 + + * 2^74 + 2^69 + 2^34 + 2^30 + * < 2^128 */ + felem_reduce(y_out, tmp); + } + +/* copy_conditional copies in to out iff mask is all ones. */ +static void +copy_conditional(felem out, const felem in, limb mask) + { + unsigned i; + for (i = 0; i < NLIMBS; ++i) + { + const limb tmp = mask & (in[i] ^ out[i]); + out[i] ^= tmp; + } + } + +/* point_add calcuates (x1, y1, z1) + (x2, y2, z2) + * + * The method is taken from + * http://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#addition-add-2007-bl, + * adapted for mixed addition (z2 = 1, or z2 = 0 for the point at infinity). + * + * This function includes a branch for checking whether the two input points + * are equal (while not equal to the point at infinity). This case never + * happens during single point multiplication, so there is no timing leak for + * ECDH or ECDSA signing. */ +static void point_add(felem x3, felem y3, felem z3, + const felem x1, const felem y1, const felem z1, + const int mixed, const felem x2, const felem y2, const felem z2) + { + felem ftmp, ftmp2, ftmp3, ftmp4, ftmp5, ftmp6, x_out, y_out, z_out; + largefelem tmp, tmp2; + limb x_equal, y_equal, z1_is_zero, z2_is_zero; + + z1_is_zero = felem_is_zero(z1); + z2_is_zero = felem_is_zero(z2); + + /* ftmp = z1z1 = z1**2 */ + felem_square(tmp, z1); + felem_reduce(ftmp, tmp); + + if (!mixed) + { + /* ftmp2 = z2z2 = z2**2 */ + felem_square(tmp, z2); + felem_reduce(ftmp2, tmp); + + /* u1 = ftmp3 = x1*z2z2 */ + felem_mul(tmp, x1, ftmp2); + felem_reduce(ftmp3, tmp); + + /* ftmp5 = z1 + z2 */ + felem_assign(ftmp5, z1); + felem_sum64(ftmp5, z2); + /* ftmp5[i] < 2^61 */ + + /* ftmp5 = (z1 + z2)**2 - z1z1 - z2z2 = 2*z1z2 */ + felem_square(tmp, ftmp5); + /* tmp[i] < 17*2^122 */ + felem_diff_128_64(tmp, ftmp); + /* tmp[i] < 17*2^122 + 2^63 */ + felem_diff_128_64(tmp, ftmp2); + /* tmp[i] < 17*2^122 + 2^64 */ + felem_reduce(ftmp5, tmp); + + /* ftmp2 = z2 * z2z2 */ + felem_mul(tmp, ftmp2, z2); + felem_reduce(ftmp2, tmp); + + /* s1 = ftmp6 = y1 * z2**3 */ + felem_mul(tmp, y1, ftmp2); + felem_reduce(ftmp6, tmp); + } + else + { + /* We'll assume z2 = 1 (special case z2 = 0 is handled later) */ + + /* u1 = ftmp3 = x1*z2z2 */ + felem_assign(ftmp3, x1); + + /* ftmp5 = 2*z1z2 */ + felem_scalar(ftmp5, z1, 2); + + /* s1 = ftmp6 = y1 * z2**3 */ + felem_assign(ftmp6, y1); + } + + /* u2 = x2*z1z1 */ + felem_mul(tmp, x2, ftmp); + /* tmp[i] < 17*2^120 */ + + /* h = ftmp4 = u2 - u1 */ + felem_diff_128_64(tmp, ftmp3); + /* tmp[i] < 17*2^120 + 2^63 */ + felem_reduce(ftmp4, tmp); + + x_equal = felem_is_zero(ftmp4); + + /* z_out = ftmp5 * h */ + felem_mul(tmp, ftmp5, ftmp4); + felem_reduce(z_out, tmp); + + /* ftmp = z1 * z1z1 */ + felem_mul(tmp, ftmp, z1); + felem_reduce(ftmp, tmp); + + /* s2 = tmp = y2 * z1**3 */ + felem_mul(tmp, y2, ftmp); + /* tmp[i] < 17*2^120 */ + + /* r = ftmp5 = (s2 - s1)*2 */ + felem_diff_128_64(tmp, ftmp6); + /* tmp[i] < 17*2^120 + 2^63 */ + felem_reduce(ftmp5, tmp); + y_equal = felem_is_zero(ftmp5); + felem_scalar64(ftmp5, 2); + /* ftmp5[i] < 2^61 */ + + if (x_equal && y_equal && !z1_is_zero && !z2_is_zero) + { + point_double(x3, y3, z3, x1, y1, z1); + return; + } + + /* I = ftmp = (2h)**2 */ + felem_assign(ftmp, ftmp4); + felem_scalar64(ftmp, 2); + /* ftmp[i] < 2^61 */ + felem_square(tmp, ftmp); + /* tmp[i] < 17*2^122 */ + felem_reduce(ftmp, tmp); + + /* J = ftmp2 = h * I */ + felem_mul(tmp, ftmp4, ftmp); + felem_reduce(ftmp2, tmp); + + /* V = ftmp4 = U1 * I */ + felem_mul(tmp, ftmp3, ftmp); + felem_reduce(ftmp4, tmp); + + /* x_out = r**2 - J - 2V */ + felem_square(tmp, ftmp5); + /* tmp[i] < 17*2^122 */ + felem_diff_128_64(tmp, ftmp2); + /* tmp[i] < 17*2^122 + 2^63 */ + felem_assign(ftmp3, ftmp4); + felem_scalar64(ftmp4, 2); + /* ftmp4[i] < 2^61 */ + felem_diff_128_64(tmp, ftmp4); + /* tmp[i] < 17*2^122 + 2^64 */ + felem_reduce(x_out, tmp); + + /* y_out = r(V-x_out) - 2 * s1 * J */ + felem_diff64(ftmp3, x_out); + /* ftmp3[i] < 2^60 + 2^60 + * = 2^61 */ + felem_mul(tmp, ftmp5, ftmp3); + /* tmp[i] < 17*2^122 */ + felem_mul(tmp2, ftmp6, ftmp2); + /* tmp2[i] < 17*2^120 */ + felem_scalar128(tmp2, 2); + /* tmp2[i] < 17*2^121 */ + felem_diff128(tmp, tmp2); + /* tmp[i] < 2^127 - 2^69 + 17*2^122 + * = 2^126 - 2^122 - 2^6 - 2^2 - 1 + * < 2^127 */ + felem_reduce(y_out, tmp); + + copy_conditional(x_out, x2, z1_is_zero); + copy_conditional(x_out, x1, z2_is_zero); + copy_conditional(y_out, y2, z1_is_zero); + copy_conditional(y_out, y1, z2_is_zero); + copy_conditional(z_out, z2, z1_is_zero); + copy_conditional(z_out, z1, z2_is_zero); + felem_assign(x3, x_out); + felem_assign(y3, y_out); + felem_assign(z3, z_out); + } + +/* Base point pre computation + * -------------------------- + * + * Two different sorts of precomputed tables are used in the following code. + * Each contain various points on the curve, where each point is three field + * elements (x, y, z). + * + * For the base point table, z is usually 1 (0 for the point at infinity). + * This table has 16 elements: + * index | bits | point + * ------+---------+------------------------------ + * 0 | 0 0 0 0 | 0G + * 1 | 0 0 0 1 | 1G + * 2 | 0 0 1 0 | 2^130G + * 3 | 0 0 1 1 | (2^130 + 1)G + * 4 | 0 1 0 0 | 2^260G + * 5 | 0 1 0 1 | (2^260 + 1)G + * 6 | 0 1 1 0 | (2^260 + 2^130)G + * 7 | 0 1 1 1 | (2^260 + 2^130 + 1)G + * 8 | 1 0 0 0 | 2^390G + * 9 | 1 0 0 1 | (2^390 + 1)G + * 10 | 1 0 1 0 | (2^390 + 2^130)G + * 11 | 1 0 1 1 | (2^390 + 2^130 + 1)G + * 12 | 1 1 0 0 | (2^390 + 2^260)G + * 13 | 1 1 0 1 | (2^390 + 2^260 + 1)G + * 14 | 1 1 1 0 | (2^390 + 2^260 + 2^130)G + * 15 | 1 1 1 1 | (2^390 + 2^260 + 2^130 + 1)G + * + * The reason for this is so that we can clock bits into four different + * locations when doing simple scalar multiplies against the base point. + * + * Tables for other points have table[i] = iG for i in 0 .. 16. */ + +/* gmul is the table of precomputed base points */ +static const felem gmul[16][3] = + {{{0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}}, + {{0x017e7e31c2e5bd66, 0x022cf0615a90a6fe, 0x00127a2ffa8de334, + 0x01dfbf9d64a3f877, 0x006b4d3dbaa14b5e, 0x014fed487e0a2bd8, + 0x015b4429c6481390, 0x03a73678fb2d988e, 0x00c6858e06b70404}, + {0x00be94769fd16650, 0x031c21a89cb09022, 0x039013fad0761353, + 0x02657bd099031542, 0x03273e662c97ee72, 0x01e6d11a05ebef45, + 0x03d1bd998f544495, 0x03001172297ed0b1, 0x011839296a789a3b}, + {1, 0, 0, 0, 0, 0, 0, 0, 0}}, + {{0x0373faacbc875bae, 0x00f325023721c671, 0x00f666fd3dbde5ad, + 0x01a6932363f88ea7, 0x01fc6d9e13f9c47b, 0x03bcbffc2bbf734e, + 0x013ee3c3647f3a92, 0x029409fefe75d07d, 0x00ef9199963d85e5}, + {0x011173743ad5b178, 0x02499c7c21bf7d46, 0x035beaeabb8b1a58, + 0x00f989c4752ea0a3, 0x0101e1de48a9c1a3, 0x01a20076be28ba6c, + 0x02f8052e5eb2de95, 0x01bfe8f82dea117c, 0x0160074d3c36ddb7}, + {1, 0, 0, 0, 0, 0, 0, 0, 0}}, + {{0x012f3fc373393b3b, 0x03d3d6172f1419fa, 0x02adc943c0b86873, + 0x00d475584177952b, 0x012a4d1673750ee2, 0x00512517a0f13b0c, + 0x02b184671a7b1734, 0x0315b84236f1a50a, 0x00a4afc472edbdb9}, + {0x00152a7077f385c4, 0x03044007d8d1c2ee, 0x0065829d61d52b52, + 0x00494ff6b6631d0d, 0x00a11d94d5f06bcf, 0x02d2f89474d9282e, + 0x0241c5727c06eeb9, 0x0386928710fbdb9d, 0x01f883f727b0dfbe}, + {1, 0, 0, 0, 0, 0, 0, 0, 0}}, + {{0x019b0c3c9185544d, 0x006243a37c9d97db, 0x02ee3cbe030a2ad2, + 0x00cfdd946bb51e0d, 0x0271c00932606b91, 0x03f817d1ec68c561, + 0x03f37009806a369c, 0x03c1f30baf184fd5, 0x01091022d6d2f065}, + {0x0292c583514c45ed, 0x0316fca51f9a286c, 0x00300af507c1489a, + 0x0295f69008298cf1, 0x02c0ed8274943d7b, 0x016509b9b47a431e, + 0x02bc9de9634868ce, 0x005b34929bffcb09, 0x000c1a0121681524}, + {1, 0, 0, 0, 0, 0, 0, 0, 0}}, + {{0x0286abc0292fb9f2, 0x02665eee9805b3f7, 0x01ed7455f17f26d6, + 0x0346355b83175d13, 0x006284944cd0a097, 0x0191895bcdec5e51, + 0x02e288370afda7d9, 0x03b22312bfefa67a, 0x01d104d3fc0613fe}, + {0x0092421a12f7e47f, 0x0077a83fa373c501, 0x03bd25c5f696bd0d, + 0x035c41e4d5459761, 0x01ca0d1742b24f53, 0x00aaab27863a509c, + 0x018b6de47df73917, 0x025c0b771705cd01, 0x01fd51d566d760a7}, + {1, 0, 0, 0, 0, 0, 0, 0, 0}}, + {{0x01dd92ff6b0d1dbd, 0x039c5e2e8f8afa69, 0x0261ed13242c3b27, + 0x0382c6e67026e6a0, 0x01d60b10be2089f9, 0x03c15f3dce86723f, + 0x03c764a32d2a062d, 0x017307eac0fad056, 0x018207c0b96c5256}, + {0x0196a16d60e13154, 0x03e6ce74c0267030, 0x00ddbf2b4e52a5aa, + 0x012738241bbf31c8, 0x00ebe8dc04685a28, 0x024c2ad6d380d4a2, + 0x035ee062a6e62d0e, 0x0029ed74af7d3a0f, 0x00eef32aec142ebd}, + {1, 0, 0, 0, 0, 0, 0, 0, 0}}, + {{0x00c31ec398993b39, 0x03a9f45bcda68253, 0x00ac733c24c70890, + 0x00872b111401ff01, 0x01d178c23195eafb, 0x03bca2c816b87f74, + 0x0261a9af46fbad7a, 0x0324b2a8dd3d28f9, 0x00918121d8f24e23}, + {0x032bc8c1ca983cd7, 0x00d869dfb08fc8c6, 0x01693cb61fce1516, + 0x012a5ea68f4e88a8, 0x010869cab88d7ae3, 0x009081ad277ceee1, + 0x033a77166d064cdc, 0x03955235a1fb3a95, 0x01251a4a9b25b65e}, + {1, 0, 0, 0, 0, 0, 0, 0, 0}}, + {{0x00148a3a1b27f40b, 0x0123186df1b31fdc, 0x00026e7beaad34ce, + 0x01db446ac1d3dbba, 0x0299c1a33437eaec, 0x024540610183cbb7, + 0x0173bb0e9ce92e46, 0x02b937e43921214b, 0x01ab0436a9bf01b5}, + {0x0383381640d46948, 0x008dacbf0e7f330f, 0x03602122bcc3f318, + 0x01ee596b200620d6, 0x03bd0585fda430b3, 0x014aed77fd123a83, + 0x005ace749e52f742, 0x0390fe041da2b842, 0x0189a8ceb3299242}, + {1, 0, 0, 0, 0, 0, 0, 0, 0}}, + {{0x012a19d6b3282473, 0x00c0915918b423ce, 0x023a954eb94405ae, + 0x00529f692be26158, 0x0289fa1b6fa4b2aa, 0x0198ae4ceea346ef, + 0x0047d8cdfbdedd49, 0x00cc8c8953f0f6b8, 0x001424abbff49203}, + {0x0256732a1115a03a, 0x0351bc38665c6733, 0x03f7b950fb4a6447, + 0x000afffa94c22155, 0x025763d0a4dab540, 0x000511e92d4fc283, + 0x030a7e9eda0ee96c, 0x004c3cd93a28bf0a, 0x017edb3a8719217f}, + {1, 0, 0, 0, 0, 0, 0, 0, 0}}, + {{0x011de5675a88e673, 0x031d7d0f5e567fbe, 0x0016b2062c970ae5, + 0x03f4a2be49d90aa7, 0x03cef0bd13822866, 0x03f0923dcf774a6c, + 0x0284bebc4f322f72, 0x016ab2645302bb2c, 0x01793f95dace0e2a}, + {0x010646e13527a28f, 0x01ca1babd59dc5e7, 0x01afedfd9a5595df, + 0x01f15785212ea6b1, 0x0324e5d64f6ae3f4, 0x02d680f526d00645, + 0x0127920fadf627a7, 0x03b383f75df4f684, 0x0089e0057e783b0a}, + {1, 0, 0, 0, 0, 0, 0, 0, 0}}, + {{0x00f334b9eb3c26c6, 0x0298fdaa98568dce, 0x01c2d24843a82292, + 0x020bcb24fa1b0711, 0x02cbdb3d2b1875e6, 0x0014907598f89422, + 0x03abe3aa43b26664, 0x02cbf47f720bc168, 0x0133b5e73014b79b}, + {0x034aab5dab05779d, 0x00cdc5d71fee9abb, 0x0399f16bd4bd9d30, + 0x03582fa592d82647, 0x02be1cdfb775b0e9, 0x0034f7cea32e94cb, + 0x0335a7f08f56f286, 0x03b707e9565d1c8b, 0x0015c946ea5b614f}, + {1, 0, 0, 0, 0, 0, 0, 0, 0}}, + {{0x024676f6cff72255, 0x00d14625cac96378, 0x00532b6008bc3767, + 0x01fc16721b985322, 0x023355ea1b091668, 0x029de7afdc0317c3, + 0x02fc8a7ca2da037c, 0x02de1217d74a6f30, 0x013f7173175b73bf}, + {0x0344913f441490b5, 0x0200f9e272b61eca, 0x0258a246b1dd55d2, + 0x03753db9ea496f36, 0x025e02937a09c5ef, 0x030cbd3d14012692, + 0x01793a67e70dc72a, 0x03ec1d37048a662e, 0x006550f700c32a8d}, + {1, 0, 0, 0, 0, 0, 0, 0, 0}}, + {{0x00d3f48a347eba27, 0x008e636649b61bd8, 0x00d3b93716778fb3, + 0x004d1915757bd209, 0x019d5311a3da44e0, 0x016d1afcbbe6aade, + 0x0241bf5f73265616, 0x0384672e5d50d39b, 0x005009fee522b684}, + {0x029b4fab064435fe, 0x018868ee095bbb07, 0x01ea3d6936cc92b8, + 0x000608b00f78a2f3, 0x02db911073d1c20f, 0x018205938470100a, + 0x01f1e4964cbe6ff2, 0x021a19a29eed4663, 0x01414485f42afa81}, + {1, 0, 0, 0, 0, 0, 0, 0, 0}}, + {{0x01612b3a17f63e34, 0x03813992885428e6, 0x022b3c215b5a9608, + 0x029b4057e19f2fcb, 0x0384059a587af7e6, 0x02d6400ace6fe610, + 0x029354d896e8e331, 0x00c047ee6dfba65e, 0x0037720542e9d49d}, + {0x02ce9eed7c5e9278, 0x0374ed703e79643b, 0x01316c54c4072006, + 0x005aaa09054b2ee8, 0x002824000c840d57, 0x03d4eba24771ed86, + 0x0189c50aabc3bdae, 0x0338c01541e15510, 0x00466d56e38eed42}, + {1, 0, 0, 0, 0, 0, 0, 0, 0}}, + {{0x007efd8330ad8bd6, 0x02465ed48047710b, 0x0034c6606b215e0c, + 0x016ae30c53cbf839, 0x01fa17bd37161216, 0x018ead4e61ce8ab9, + 0x005482ed5f5dee46, 0x037543755bba1d7f, 0x005e5ac7e70a9d0f}, + {0x0117e1bb2fdcb2a2, 0x03deea36249f40c4, 0x028d09b4a6246cb7, + 0x03524b8855bcf756, 0x023d7d109d5ceb58, 0x0178e43e3223ef9c, + 0x0154536a0c6e966a, 0x037964d1286ee9fe, 0x0199bcd90e125055}, + {1, 0, 0, 0, 0, 0, 0, 0, 0}}}; + +/* select_point selects the |idx|th point from a precomputation table and + * copies it to out. */ +static void select_point(const limb idx, unsigned int size, const felem pre_comp[/* size */][3], + felem out[3]) + { + unsigned i, j; + limb *outlimbs = &out[0][0]; + memset(outlimbs, 0, 3 * sizeof(felem)); + + for (i = 0; i < size; i++) + { + const limb *inlimbs = &pre_comp[i][0][0]; + limb mask = i ^ idx; + mask |= mask >> 4; + mask |= mask >> 2; + mask |= mask >> 1; + mask &= 1; + mask--; + for (j = 0; j < NLIMBS * 3; j++) + outlimbs[j] |= inlimbs[j] & mask; + } + } + +/* get_bit returns the |i|th bit in |in| */ +static char get_bit(const felem_bytearray in, int i) + { + if (i < 0) + return 0; + return (in[i >> 3] >> (i & 7)) & 1; + } + +/* Interleaved point multiplication using precomputed point multiples: + * The small point multiples 0*P, 1*P, ..., 16*P are in pre_comp[], + * the scalars in scalars[]. If g_scalar is non-NULL, we also add this multiple + * of the generator, using certain (large) precomputed multiples in g_pre_comp. + * Output point (X, Y, Z) is stored in x_out, y_out, z_out */ +static void batch_mul(felem x_out, felem y_out, felem z_out, + const felem_bytearray scalars[], const unsigned num_points, const u8 *g_scalar, + const int mixed, const felem pre_comp[][17][3], const felem g_pre_comp[16][3]) + { + int i, skip; + unsigned num, gen_mul = (g_scalar != NULL); + felem nq[3], tmp[4]; + limb bits; + u8 sign, digit; + + /* set nq to the point at infinity */ + memset(nq, 0, 3 * sizeof(felem)); + + /* Loop over all scalars msb-to-lsb, interleaving additions + * of multiples of the generator (last quarter of rounds) + * and additions of other points multiples (every 5th round). + */ + skip = 1; /* save two point operations in the first round */ + for (i = (num_points ? 520 : 130); i >= 0; --i) + { + /* double */ + if (!skip) + point_double(nq[0], nq[1], nq[2], nq[0], nq[1], nq[2]); + + /* add multiples of the generator */ + if (gen_mul && (i <= 130)) + { + bits = get_bit(g_scalar, i + 390) << 3; + if (i < 130) + { + bits |= get_bit(g_scalar, i + 260) << 2; + bits |= get_bit(g_scalar, i + 130) << 1; + bits |= get_bit(g_scalar, i); + } + /* select the point to add, in constant time */ + select_point(bits, 16, g_pre_comp, tmp); + if (!skip) + { + point_add(nq[0], nq[1], nq[2], + nq[0], nq[1], nq[2], + 1 /* mixed */, tmp[0], tmp[1], tmp[2]); + } + else + { + memcpy(nq, tmp, 3 * sizeof(felem)); + skip = 0; + } + } + + /* do other additions every 5 doublings */ + if (num_points && (i % 5 == 0)) + { + /* loop over all scalars */ + for (num = 0; num < num_points; ++num) + { + bits = get_bit(scalars[num], i + 4) << 5; + bits |= get_bit(scalars[num], i + 3) << 4; + bits |= get_bit(scalars[num], i + 2) << 3; + bits |= get_bit(scalars[num], i + 1) << 2; + bits |= get_bit(scalars[num], i) << 1; + bits |= get_bit(scalars[num], i - 1); + ec_GFp_nistp_recode_scalar_bits(&sign, &digit, bits); + + /* select the point to add or subtract, in constant time */ + select_point(digit, 17, pre_comp[num], tmp); + felem_neg(tmp[3], tmp[1]); /* (X, -Y, Z) is the negative point */ + copy_conditional(tmp[1], tmp[3], (-(limb) sign)); + + if (!skip) + { + point_add(nq[0], nq[1], nq[2], + nq[0], nq[1], nq[2], + mixed, tmp[0], tmp[1], tmp[2]); + } + else + { + memcpy(nq, tmp, 3 * sizeof(felem)); + skip = 0; + } + } + } + } + felem_assign(x_out, nq[0]); + felem_assign(y_out, nq[1]); + felem_assign(z_out, nq[2]); + } + + +/* Precomputation for the group generator. */ +typedef struct { + felem g_pre_comp[16][3]; + int references; +} NISTP521_PRE_COMP; + +const EC_METHOD *EC_GFp_nistp521_method(void) + { + static const EC_METHOD ret = { + EC_FLAGS_DEFAULT_OCT, + NID_X9_62_prime_field, + ec_GFp_nistp521_group_init, + ec_GFp_simple_group_finish, + ec_GFp_simple_group_clear_finish, + ec_GFp_nist_group_copy, + ec_GFp_nistp521_group_set_curve, + ec_GFp_simple_group_get_curve, + ec_GFp_simple_group_get_degree, + ec_GFp_simple_group_check_discriminant, + ec_GFp_simple_point_init, + ec_GFp_simple_point_finish, + ec_GFp_simple_point_clear_finish, + ec_GFp_simple_point_copy, + ec_GFp_simple_point_set_to_infinity, + ec_GFp_simple_set_Jprojective_coordinates_GFp, + ec_GFp_simple_get_Jprojective_coordinates_GFp, + ec_GFp_simple_point_set_affine_coordinates, + ec_GFp_nistp521_point_get_affine_coordinates, + 0 /* point_set_compressed_coordinates */, + 0 /* point2oct */, + 0 /* oct2point */, + ec_GFp_simple_add, + ec_GFp_simple_dbl, + ec_GFp_simple_invert, + ec_GFp_simple_is_at_infinity, + ec_GFp_simple_is_on_curve, + ec_GFp_simple_cmp, + ec_GFp_simple_make_affine, + ec_GFp_simple_points_make_affine, + ec_GFp_nistp521_points_mul, + ec_GFp_nistp521_precompute_mult, + ec_GFp_nistp521_have_precompute_mult, + ec_GFp_nist_field_mul, + ec_GFp_nist_field_sqr, + 0 /* field_div */, + 0 /* field_encode */, + 0 /* field_decode */, + 0 /* field_set_to_one */ }; + + return &ret; + } + + +/******************************************************************************/ +/* FUNCTIONS TO MANAGE PRECOMPUTATION + */ + +static NISTP521_PRE_COMP *nistp521_pre_comp_new() + { + NISTP521_PRE_COMP *ret = NULL; + ret = (NISTP521_PRE_COMP *)OPENSSL_malloc(sizeof(NISTP521_PRE_COMP)); + if (!ret) + { + ECerr(EC_F_NISTP521_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE); + return ret; + } + memset(ret->g_pre_comp, 0, sizeof(ret->g_pre_comp)); + ret->references = 1; + return ret; + } + +static void *nistp521_pre_comp_dup(void *src_) + { + NISTP521_PRE_COMP *src = src_; + + /* no need to actually copy, these objects never change! */ + CRYPTO_add(&src->references, 1, CRYPTO_LOCK_EC_PRE_COMP); + + return src_; + } + +static void nistp521_pre_comp_free(void *pre_) + { + int i; + NISTP521_PRE_COMP *pre = pre_; + + if (!pre) + return; + + i = CRYPTO_add(&pre->references, -1, CRYPTO_LOCK_EC_PRE_COMP); + if (i > 0) + return; + + OPENSSL_free(pre); + } + +static void nistp521_pre_comp_clear_free(void *pre_) + { + int i; + NISTP521_PRE_COMP *pre = pre_; + + if (!pre) + return; + + i = CRYPTO_add(&pre->references, -1, CRYPTO_LOCK_EC_PRE_COMP); + if (i > 0) + return; + + OPENSSL_cleanse(pre, sizeof(*pre)); + OPENSSL_free(pre); + } + +/******************************************************************************/ +/* OPENSSL EC_METHOD FUNCTIONS + */ + +int ec_GFp_nistp521_group_init(EC_GROUP *group) + { + int ret; + ret = ec_GFp_simple_group_init(group); + group->a_is_minus3 = 1; + return ret; + } + +int ec_GFp_nistp521_group_set_curve(EC_GROUP *group, const BIGNUM *p, + const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) + { + int ret = 0; + BN_CTX *new_ctx = NULL; + BIGNUM *curve_p, *curve_a, *curve_b; + + if (ctx == NULL) + if ((ctx = new_ctx = BN_CTX_new()) == NULL) return 0; + BN_CTX_start(ctx); + if (((curve_p = BN_CTX_get(ctx)) == NULL) || + ((curve_a = BN_CTX_get(ctx)) == NULL) || + ((curve_b = BN_CTX_get(ctx)) == NULL)) goto err; + BN_bin2bn(nistp521_curve_params[0], sizeof(felem_bytearray), curve_p); + BN_bin2bn(nistp521_curve_params[1], sizeof(felem_bytearray), curve_a); + BN_bin2bn(nistp521_curve_params[2], sizeof(felem_bytearray), curve_b); + if ((BN_cmp(curve_p, p)) || (BN_cmp(curve_a, a)) || + (BN_cmp(curve_b, b))) + { + ECerr(EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE, + EC_R_WRONG_CURVE_PARAMETERS); + goto err; + } + group->field_mod_func = BN_nist_mod_521; + ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx); +err: + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return ret; + } + +/* Takes the Jacobian coordinates (X, Y, Z) of a point and returns + * (X', Y') = (X/Z^2, Y/Z^3) */ +int ec_GFp_nistp521_point_get_affine_coordinates(const EC_GROUP *group, + const EC_POINT *point, BIGNUM *x, BIGNUM *y, BN_CTX *ctx) + { + felem z1, z2, x_in, y_in, x_out, y_out; + largefelem tmp; + + if (EC_POINT_is_at_infinity(group, point)) + { + ECerr(EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES, + EC_R_POINT_AT_INFINITY); + return 0; + } + if ((!BN_to_felem(x_in, &point->X)) || (!BN_to_felem(y_in, &point->Y)) || + (!BN_to_felem(z1, &point->Z))) return 0; + felem_inv(z2, z1); + felem_square(tmp, z2); felem_reduce(z1, tmp); + felem_mul(tmp, x_in, z1); felem_reduce(x_in, tmp); + felem_contract(x_out, x_in); + if (x != NULL) + { + if (!felem_to_BN(x, x_out)) + { + ECerr(EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES, ERR_R_BN_LIB); + return 0; + } + } + felem_mul(tmp, z1, z2); felem_reduce(z1, tmp); + felem_mul(tmp, y_in, z1); felem_reduce(y_in, tmp); + felem_contract(y_out, y_in); + if (y != NULL) + { + if (!felem_to_BN(y, y_out)) + { + ECerr(EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES, ERR_R_BN_LIB); + return 0; + } + } + return 1; + } + +static void make_points_affine(size_t num, felem points[/* num */][3], felem tmp_felems[/* num+1 */]) + { + /* Runs in constant time, unless an input is the point at infinity + * (which normally shouldn't happen). */ + ec_GFp_nistp_points_make_affine_internal( + num, + points, + sizeof(felem), + tmp_felems, + (void (*)(void *)) felem_one, + (int (*)(const void *)) felem_is_zero_int, + (void (*)(void *, const void *)) felem_assign, + (void (*)(void *, const void *)) felem_square_reduce, + (void (*)(void *, const void *, const void *)) felem_mul_reduce, + (void (*)(void *, const void *)) felem_inv, + (void (*)(void *, const void *)) felem_contract); + } + +/* Computes scalar*generator + \sum scalars[i]*points[i], ignoring NULL values + * Result is stored in r (r can equal one of the inputs). */ +int ec_GFp_nistp521_points_mul(const EC_GROUP *group, EC_POINT *r, + const BIGNUM *scalar, size_t num, const EC_POINT *points[], + const BIGNUM *scalars[], BN_CTX *ctx) + { + int ret = 0; + int j; + int mixed = 0; + BN_CTX *new_ctx = NULL; + BIGNUM *x, *y, *z, *tmp_scalar; + felem_bytearray g_secret; + felem_bytearray *secrets = NULL; + felem (*pre_comp)[17][3] = NULL; + felem *tmp_felems = NULL; + felem_bytearray tmp; + unsigned i, num_bytes; + int have_pre_comp = 0; + size_t num_points = num; + felem x_in, y_in, z_in, x_out, y_out, z_out; + NISTP521_PRE_COMP *pre = NULL; + felem (*g_pre_comp)[3] = NULL; + EC_POINT *generator = NULL; + const EC_POINT *p = NULL; + const BIGNUM *p_scalar = NULL; + + if (ctx == NULL) + if ((ctx = new_ctx = BN_CTX_new()) == NULL) return 0; + BN_CTX_start(ctx); + if (((x = BN_CTX_get(ctx)) == NULL) || + ((y = BN_CTX_get(ctx)) == NULL) || + ((z = BN_CTX_get(ctx)) == NULL) || + ((tmp_scalar = BN_CTX_get(ctx)) == NULL)) + goto err; + + if (scalar != NULL) + { + pre = EC_EX_DATA_get_data(group->extra_data, + nistp521_pre_comp_dup, nistp521_pre_comp_free, + nistp521_pre_comp_clear_free); + if (pre) + /* we have precomputation, try to use it */ + g_pre_comp = &pre->g_pre_comp[0]; + else + /* try to use the standard precomputation */ + g_pre_comp = (felem (*)[3]) gmul; + generator = EC_POINT_new(group); + if (generator == NULL) + goto err; + /* get the generator from precomputation */ + if (!felem_to_BN(x, g_pre_comp[1][0]) || + !felem_to_BN(y, g_pre_comp[1][1]) || + !felem_to_BN(z, g_pre_comp[1][2])) + { + ECerr(EC_F_EC_GFP_NISTP521_POINTS_MUL, ERR_R_BN_LIB); + goto err; + } + if (!EC_POINT_set_Jprojective_coordinates_GFp(group, + generator, x, y, z, ctx)) + goto err; + if (0 == EC_POINT_cmp(group, generator, group->generator, ctx)) + /* precomputation matches generator */ + have_pre_comp = 1; + else + /* we don't have valid precomputation: + * treat the generator as a random point */ + num_points++; + } + + if (num_points > 0) + { + if (num_points >= 2) + { + /* unless we precompute multiples for just one point, + * converting those into affine form is time well spent */ + mixed = 1; + } + secrets = OPENSSL_malloc(num_points * sizeof(felem_bytearray)); + pre_comp = OPENSSL_malloc(num_points * 17 * 3 * sizeof(felem)); + if (mixed) + tmp_felems = OPENSSL_malloc((num_points * 17 + 1) * sizeof(felem)); + if ((secrets == NULL) || (pre_comp == NULL) || (mixed && (tmp_felems == NULL))) + { + ECerr(EC_F_EC_GFP_NISTP521_POINTS_MUL, ERR_R_MALLOC_FAILURE); + goto err; + } + + /* we treat NULL scalars as 0, and NULL points as points at infinity, + * i.e., they contribute nothing to the linear combination */ + memset(secrets, 0, num_points * sizeof(felem_bytearray)); + memset(pre_comp, 0, num_points * 17 * 3 * sizeof(felem)); + for (i = 0; i < num_points; ++i) + { + if (i == num) + /* we didn't have a valid precomputation, so we pick + * the generator */ + { + p = EC_GROUP_get0_generator(group); + p_scalar = scalar; + } + else + /* the i^th point */ + { + p = points[i]; + p_scalar = scalars[i]; + } + if ((p_scalar != NULL) && (p != NULL)) + { + /* reduce scalar to 0 <= scalar < 2^521 */ + if ((BN_num_bits(p_scalar) > 521) || (BN_is_negative(p_scalar))) + { + /* this is an unusual input, and we don't guarantee + * constant-timeness */ + if (!BN_nnmod(tmp_scalar, p_scalar, &group->order, ctx)) + { + ECerr(EC_F_EC_GFP_NISTP521_POINTS_MUL, ERR_R_BN_LIB); + goto err; + } + num_bytes = BN_bn2bin(tmp_scalar, tmp); + } + else + num_bytes = BN_bn2bin(p_scalar, tmp); + flip_endian(secrets[i], tmp, num_bytes); + /* precompute multiples */ + if ((!BN_to_felem(x_out, &p->X)) || + (!BN_to_felem(y_out, &p->Y)) || + (!BN_to_felem(z_out, &p->Z))) goto err; + memcpy(pre_comp[i][1][0], x_out, sizeof(felem)); + memcpy(pre_comp[i][1][1], y_out, sizeof(felem)); + memcpy(pre_comp[i][1][2], z_out, sizeof(felem)); + for (j = 2; j <= 16; ++j) + { + if (j & 1) + { + point_add( + pre_comp[i][j][0], pre_comp[i][j][1], pre_comp[i][j][2], + pre_comp[i][1][0], pre_comp[i][1][1], pre_comp[i][1][2], + 0, pre_comp[i][j-1][0], pre_comp[i][j-1][1], pre_comp[i][j-1][2]); + } + else + { + point_double( + pre_comp[i][j][0], pre_comp[i][j][1], pre_comp[i][j][2], + pre_comp[i][j/2][0], pre_comp[i][j/2][1], pre_comp[i][j/2][2]); + } + } + } + } + if (mixed) + make_points_affine(num_points * 17, pre_comp[0], tmp_felems); + } + + /* the scalar for the generator */ + if ((scalar != NULL) && (have_pre_comp)) + { + memset(g_secret, 0, sizeof(g_secret)); + /* reduce scalar to 0 <= scalar < 2^521 */ + if ((BN_num_bits(scalar) > 521) || (BN_is_negative(scalar))) + { + /* this is an unusual input, and we don't guarantee + * constant-timeness */ + if (!BN_nnmod(tmp_scalar, scalar, &group->order, ctx)) + { + ECerr(EC_F_EC_GFP_NISTP521_POINTS_MUL, ERR_R_BN_LIB); + goto err; + } + num_bytes = BN_bn2bin(tmp_scalar, tmp); + } + else + num_bytes = BN_bn2bin(scalar, tmp); + flip_endian(g_secret, tmp, num_bytes); + /* do the multiplication with generator precomputation*/ + batch_mul(x_out, y_out, z_out, + (const felem_bytearray (*)) secrets, num_points, + g_secret, + mixed, (const felem (*)[17][3]) pre_comp, + (const felem (*)[3]) g_pre_comp); + } + else + /* do the multiplication without generator precomputation */ + batch_mul(x_out, y_out, z_out, + (const felem_bytearray (*)) secrets, num_points, + NULL, mixed, (const felem (*)[17][3]) pre_comp, NULL); + /* reduce the output to its unique minimal representation */ + felem_contract(x_in, x_out); + felem_contract(y_in, y_out); + felem_contract(z_in, z_out); + if ((!felem_to_BN(x, x_in)) || (!felem_to_BN(y, y_in)) || + (!felem_to_BN(z, z_in))) + { + ECerr(EC_F_EC_GFP_NISTP521_POINTS_MUL, ERR_R_BN_LIB); + goto err; + } + ret = EC_POINT_set_Jprojective_coordinates_GFp(group, r, x, y, z, ctx); + +err: + BN_CTX_end(ctx); + if (generator != NULL) + EC_POINT_free(generator); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + if (secrets != NULL) + OPENSSL_free(secrets); + if (pre_comp != NULL) + OPENSSL_free(pre_comp); + if (tmp_felems != NULL) + OPENSSL_free(tmp_felems); + return ret; + } + +int ec_GFp_nistp521_precompute_mult(EC_GROUP *group, BN_CTX *ctx) + { + int ret = 0; + NISTP521_PRE_COMP *pre = NULL; + int i, j; + BN_CTX *new_ctx = NULL; + BIGNUM *x, *y; + EC_POINT *generator = NULL; + felem tmp_felems[16]; + + /* throw away old precomputation */ + EC_EX_DATA_free_data(&group->extra_data, nistp521_pre_comp_dup, + nistp521_pre_comp_free, nistp521_pre_comp_clear_free); + if (ctx == NULL) + if ((ctx = new_ctx = BN_CTX_new()) == NULL) return 0; + BN_CTX_start(ctx); + if (((x = BN_CTX_get(ctx)) == NULL) || + ((y = BN_CTX_get(ctx)) == NULL)) + goto err; + /* get the generator */ + if (group->generator == NULL) goto err; + generator = EC_POINT_new(group); + if (generator == NULL) + goto err; + BN_bin2bn(nistp521_curve_params[3], sizeof (felem_bytearray), x); + BN_bin2bn(nistp521_curve_params[4], sizeof (felem_bytearray), y); + if (!EC_POINT_set_affine_coordinates_GFp(group, generator, x, y, ctx)) + goto err; + if ((pre = nistp521_pre_comp_new()) == NULL) + goto err; + /* if the generator is the standard one, use built-in precomputation */ + if (0 == EC_POINT_cmp(group, generator, group->generator, ctx)) + { + memcpy(pre->g_pre_comp, gmul, sizeof(pre->g_pre_comp)); + ret = 1; + goto err; + } + if ((!BN_to_felem(pre->g_pre_comp[1][0], &group->generator->X)) || + (!BN_to_felem(pre->g_pre_comp[1][1], &group->generator->Y)) || + (!BN_to_felem(pre->g_pre_comp[1][2], &group->generator->Z))) + goto err; + /* compute 2^130*G, 2^260*G, 2^390*G */ + for (i = 1; i <= 4; i <<= 1) + { + point_double(pre->g_pre_comp[2*i][0], pre->g_pre_comp[2*i][1], + pre->g_pre_comp[2*i][2], pre->g_pre_comp[i][0], + pre->g_pre_comp[i][1], pre->g_pre_comp[i][2]); + for (j = 0; j < 129; ++j) + { + point_double(pre->g_pre_comp[2*i][0], + pre->g_pre_comp[2*i][1], + pre->g_pre_comp[2*i][2], + pre->g_pre_comp[2*i][0], + pre->g_pre_comp[2*i][1], + pre->g_pre_comp[2*i][2]); + } + } + /* g_pre_comp[0] is the point at infinity */ + memset(pre->g_pre_comp[0], 0, sizeof(pre->g_pre_comp[0])); + /* the remaining multiples */ + /* 2^130*G + 2^260*G */ + point_add(pre->g_pre_comp[6][0], pre->g_pre_comp[6][1], + pre->g_pre_comp[6][2], pre->g_pre_comp[4][0], + pre->g_pre_comp[4][1], pre->g_pre_comp[4][2], + 0, pre->g_pre_comp[2][0], pre->g_pre_comp[2][1], + pre->g_pre_comp[2][2]); + /* 2^130*G + 2^390*G */ + point_add(pre->g_pre_comp[10][0], pre->g_pre_comp[10][1], + pre->g_pre_comp[10][2], pre->g_pre_comp[8][0], + pre->g_pre_comp[8][1], pre->g_pre_comp[8][2], + 0, pre->g_pre_comp[2][0], pre->g_pre_comp[2][1], + pre->g_pre_comp[2][2]); + /* 2^260*G + 2^390*G */ + point_add(pre->g_pre_comp[12][0], pre->g_pre_comp[12][1], + pre->g_pre_comp[12][2], pre->g_pre_comp[8][0], + pre->g_pre_comp[8][1], pre->g_pre_comp[8][2], + 0, pre->g_pre_comp[4][0], pre->g_pre_comp[4][1], + pre->g_pre_comp[4][2]); + /* 2^130*G + 2^260*G + 2^390*G */ + point_add(pre->g_pre_comp[14][0], pre->g_pre_comp[14][1], + pre->g_pre_comp[14][2], pre->g_pre_comp[12][0], + pre->g_pre_comp[12][1], pre->g_pre_comp[12][2], + 0, pre->g_pre_comp[2][0], pre->g_pre_comp[2][1], + pre->g_pre_comp[2][2]); + for (i = 1; i < 8; ++i) + { + /* odd multiples: add G */ + point_add(pre->g_pre_comp[2*i+1][0], pre->g_pre_comp[2*i+1][1], + pre->g_pre_comp[2*i+1][2], pre->g_pre_comp[2*i][0], + pre->g_pre_comp[2*i][1], pre->g_pre_comp[2*i][2], + 0, pre->g_pre_comp[1][0], pre->g_pre_comp[1][1], + pre->g_pre_comp[1][2]); + } + make_points_affine(15, &(pre->g_pre_comp[1]), tmp_felems); + + if (!EC_EX_DATA_set_data(&group->extra_data, pre, nistp521_pre_comp_dup, + nistp521_pre_comp_free, nistp521_pre_comp_clear_free)) + goto err; + ret = 1; + pre = NULL; + err: + BN_CTX_end(ctx); + if (generator != NULL) + EC_POINT_free(generator); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + if (pre) + nistp521_pre_comp_free(pre); + return ret; + } + +int ec_GFp_nistp521_have_precompute_mult(const EC_GROUP *group) + { + if (EC_EX_DATA_get_data(group->extra_data, nistp521_pre_comp_dup, + nistp521_pre_comp_free, nistp521_pre_comp_clear_free) + != NULL) + return 1; + else + return 0; + } + +#else +static void *dummy=&dummy; +#endif diff --git a/libs/openssl/crypto/ec/ecp_nistputil.c b/libs/openssl/crypto/ec/ecp_nistputil.c new file mode 100644 index 00000000..c8140c80 --- /dev/null +++ b/libs/openssl/crypto/ec/ecp_nistputil.c @@ -0,0 +1,197 @@ +/* crypto/ec/ecp_nistputil.c */ +/* + * Written by Bodo Moeller for the OpenSSL project. + */ +/* Copyright 2011 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 + +/* + * Common utility functions for ecp_nistp224.c, ecp_nistp256.c, ecp_nistp521.c. + */ + +#include +#include "ec_lcl.h" + +/* Convert an array of points into affine coordinates. + * (If the point at infinity is found (Z = 0), it remains unchanged.) + * This function is essentially an equivalent to EC_POINTs_make_affine(), but + * works with the internal representation of points as used by ecp_nistp###.c + * rather than with (BIGNUM-based) EC_POINT data structures. + * + * point_array is the input/output buffer ('num' points in projective form, + * i.e. three coordinates each), based on an internal representation of + * field elements of size 'felem_size'. + * + * tmp_felems needs to point to a temporary array of 'num'+1 field elements + * for storage of intermediate values. + */ +void ec_GFp_nistp_points_make_affine_internal(size_t num, void *point_array, + size_t felem_size, void *tmp_felems, + void (*felem_one)(void *out), + int (*felem_is_zero)(const void *in), + void (*felem_assign)(void *out, const void *in), + void (*felem_square)(void *out, const void *in), + void (*felem_mul)(void *out, const void *in1, const void *in2), + void (*felem_inv)(void *out, const void *in), + void (*felem_contract)(void *out, const void *in)) + { + int i = 0; + +#define tmp_felem(I) (&((char *)tmp_felems)[(I) * felem_size]) +#define X(I) (&((char *)point_array)[3*(I) * felem_size]) +#define Y(I) (&((char *)point_array)[(3*(I) + 1) * felem_size]) +#define Z(I) (&((char *)point_array)[(3*(I) + 2) * felem_size]) + + if (!felem_is_zero(Z(0))) + felem_assign(tmp_felem(0), Z(0)); + else + felem_one(tmp_felem(0)); + for (i = 1; i < (int)num; i++) + { + if (!felem_is_zero(Z(i))) + felem_mul(tmp_felem(i), tmp_felem(i-1), Z(i)); + else + felem_assign(tmp_felem(i), tmp_felem(i-1)); + } + /* Now each tmp_felem(i) is the product of Z(0) .. Z(i), skipping any zero-valued factors: + * if Z(i) = 0, we essentially pretend that Z(i) = 1 */ + + felem_inv(tmp_felem(num-1), tmp_felem(num-1)); + for (i = num - 1; i >= 0; i--) + { + if (i > 0) + /* tmp_felem(i-1) is the product of Z(0) .. Z(i-1), + * tmp_felem(i) is the inverse of the product of Z(0) .. Z(i) + */ + felem_mul(tmp_felem(num), tmp_felem(i-1), tmp_felem(i)); /* 1/Z(i) */ + else + felem_assign(tmp_felem(num), tmp_felem(0)); /* 1/Z(0) */ + + if (!felem_is_zero(Z(i))) + { + if (i > 0) + /* For next iteration, replace tmp_felem(i-1) by its inverse */ + felem_mul(tmp_felem(i-1), tmp_felem(i), Z(i)); + + /* Convert point (X, Y, Z) into affine form (X/(Z^2), Y/(Z^3), 1) */ + felem_square(Z(i), tmp_felem(num)); /* 1/(Z^2) */ + felem_mul(X(i), X(i), Z(i)); /* X/(Z^2) */ + felem_mul(Z(i), Z(i), tmp_felem(num)); /* 1/(Z^3) */ + felem_mul(Y(i), Y(i), Z(i)); /* Y/(Z^3) */ + felem_contract(X(i), X(i)); + felem_contract(Y(i), Y(i)); + felem_one(Z(i)); + } + else + { + if (i > 0) + /* For next iteration, replace tmp_felem(i-1) by its inverse */ + felem_assign(tmp_felem(i-1), tmp_felem(i)); + } + } + } + +/* + * This function looks at 5+1 scalar bits (5 current, 1 adjacent less + * significant bit), and recodes them into a signed digit for use in fast point + * multiplication: the use of signed rather than unsigned digits means that + * fewer points need to be precomputed, given that point inversion is easy + * (a precomputed point dP makes -dP available as well). + * + * BACKGROUND: + * + * Signed digits for multiplication were introduced by Booth ("A signed binary + * multiplication technique", Quart. Journ. Mech. and Applied Math., vol. IV, + * pt. 2 (1951), pp. 236-240), in that case for multiplication of integers. + * Booth's original encoding did not generally improve the density of nonzero + * digits over the binary representation, and was merely meant to simplify the + * handling of signed factors given in two's complement; but it has since been + * shown to be the basis of various signed-digit representations that do have + * further advantages, including the wNAF, using the following general approach: + * + * (1) Given a binary representation + * + * b_k ... b_2 b_1 b_0, + * + * of a nonnegative integer (b_k in {0, 1}), rewrite it in digits 0, 1, -1 + * by using bit-wise subtraction as follows: + * + * b_k b_(k-1) ... b_2 b_1 b_0 + * - b_k ... b_3 b_2 b_1 b_0 + * ------------------------------------- + * s_k b_(k-1) ... s_3 s_2 s_1 s_0 + * + * A left-shift followed by subtraction of the original value yields a new + * representation of the same value, using signed bits s_i = b_(i+1) - b_i. + * This representation from Booth's paper has since appeared in the + * literature under a variety of different names including "reversed binary + * form", "alternating greedy expansion", "mutual opposite form", and + * "sign-alternating {+-1}-representation". + * + * An interesting property is that among the nonzero bits, values 1 and -1 + * strictly alternate. + * + * (2) Various window schemes can be applied to the Booth representation of + * integers: for example, right-to-left sliding windows yield the wNAF + * (a signed-digit encoding independently discovered by various researchers + * in the 1990s), and left-to-right sliding windows yield a left-to-right + * equivalent of the wNAF (independently discovered by various researchers + * around 2004). + * + * To prevent leaking information through side channels in point multiplication, + * we need to recode the given integer into a regular pattern: sliding windows + * as in wNAFs won't do, we need their fixed-window equivalent -- which is a few + * decades older: we'll be using the so-called "modified Booth encoding" due to + * MacSorley ("High-speed arithmetic in binary computers", Proc. IRE, vol. 49 + * (1961), pp. 67-91), in a radix-2^5 setting. That is, we always combine five + * signed bits into a signed digit: + * + * s_(4j + 4) s_(4j + 3) s_(4j + 2) s_(4j + 1) s_(4j) + * + * The sign-alternating property implies that the resulting digit values are + * integers from -16 to 16. + * + * Of course, we don't actually need to compute the signed digits s_i as an + * intermediate step (that's just a nice way to see how this scheme relates + * to the wNAF): a direct computation obtains the recoded digit from the + * six bits b_(4j + 4) ... b_(4j - 1). + * + * This function takes those five bits as an integer (0 .. 63), writing the + * recoded digit to *sign (0 for positive, 1 for negative) and *digit (absolute + * value, in the range 0 .. 8). Note that this integer essentially provides the + * input bits "shifted to the left" by one position: for example, the input to + * compute the least significant recoded digit, given that there's no bit b_-1, + * has to be b_4 b_3 b_2 b_1 b_0 0. + * + */ +void ec_GFp_nistp_recode_scalar_bits(unsigned char *sign, unsigned char *digit, unsigned char in) + { + unsigned char s, d; + + s = ~((in >> 5) - 1); /* sets all bits to MSB(in), 'in' seen as 6-bit value */ + d = (1 << 6) - in - 1; + d = (d & s) | (in & ~s); + d = (d >> 1) + (d & 1); + + *sign = s & 1; + *digit = d; + } +#else +static void *dummy=&dummy; +#endif diff --git a/libs/openssl/crypto/ec/ecp_oct.c b/libs/openssl/crypto/ec/ecp_oct.c new file mode 100644 index 00000000..374a0ee7 --- /dev/null +++ b/libs/openssl/crypto/ec/ecp_oct.c @@ -0,0 +1,433 @@ +/* crypto/ec/ecp_oct.c */ +/* Includes code written by Lenka Fibikova + * for the OpenSSL project. + * Includes code written by Bodo Moeller for the OpenSSL project. +*/ +/* ==================================================================== + * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * Portions of this software developed by SUN MICROSYSTEMS, INC., + * and contributed to the OpenSSL project. + */ + +#include +#include + +#include "ec_lcl.h" + +int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point, + const BIGNUM *x_, int y_bit, BN_CTX *ctx) + { + BN_CTX *new_ctx = NULL; + BIGNUM *tmp1, *tmp2, *x, *y; + int ret = 0; + + /* clear error queue*/ + ERR_clear_error(); + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return 0; + } + + y_bit = (y_bit != 0); + + BN_CTX_start(ctx); + tmp1 = BN_CTX_get(ctx); + tmp2 = BN_CTX_get(ctx); + x = BN_CTX_get(ctx); + y = BN_CTX_get(ctx); + if (y == NULL) goto err; + + /* Recover y. We have a Weierstrass equation + * y^2 = x^3 + a*x + b, + * so y is one of the square roots of x^3 + a*x + b. + */ + + /* tmp1 := x^3 */ + if (!BN_nnmod(x, x_, &group->field,ctx)) goto err; + if (group->meth->field_decode == 0) + { + /* field_{sqr,mul} work on standard representation */ + if (!group->meth->field_sqr(group, tmp2, x_, ctx)) goto err; + if (!group->meth->field_mul(group, tmp1, tmp2, x_, ctx)) goto err; + } + else + { + if (!BN_mod_sqr(tmp2, x_, &group->field, ctx)) goto err; + if (!BN_mod_mul(tmp1, tmp2, x_, &group->field, ctx)) goto err; + } + + /* tmp1 := tmp1 + a*x */ + if (group->a_is_minus3) + { + if (!BN_mod_lshift1_quick(tmp2, x, &group->field)) goto err; + if (!BN_mod_add_quick(tmp2, tmp2, x, &group->field)) goto err; + if (!BN_mod_sub_quick(tmp1, tmp1, tmp2, &group->field)) goto err; + } + else + { + if (group->meth->field_decode) + { + if (!group->meth->field_decode(group, tmp2, &group->a, ctx)) goto err; + if (!BN_mod_mul(tmp2, tmp2, x, &group->field, ctx)) goto err; + } + else + { + /* field_mul works on standard representation */ + if (!group->meth->field_mul(group, tmp2, &group->a, x, ctx)) goto err; + } + + if (!BN_mod_add_quick(tmp1, tmp1, tmp2, &group->field)) goto err; + } + + /* tmp1 := tmp1 + b */ + if (group->meth->field_decode) + { + if (!group->meth->field_decode(group, tmp2, &group->b, ctx)) goto err; + if (!BN_mod_add_quick(tmp1, tmp1, tmp2, &group->field)) goto err; + } + else + { + if (!BN_mod_add_quick(tmp1, tmp1, &group->b, &group->field)) goto err; + } + + if (!BN_mod_sqrt(y, tmp1, &group->field, ctx)) + { + unsigned long err = ERR_peek_last_error(); + + if (ERR_GET_LIB(err) == ERR_LIB_BN && ERR_GET_REASON(err) == BN_R_NOT_A_SQUARE) + { + ERR_clear_error(); + ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES, EC_R_INVALID_COMPRESSED_POINT); + } + else + ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES, ERR_R_BN_LIB); + goto err; + } + + if (y_bit != BN_is_odd(y)) + { + if (BN_is_zero(y)) + { + int kron; + + kron = BN_kronecker(x, &group->field, ctx); + if (kron == -2) goto err; + + if (kron == 1) + ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES, EC_R_INVALID_COMPRESSION_BIT); + else + /* BN_mod_sqrt() should have cought this error (not a square) */ + ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES, EC_R_INVALID_COMPRESSED_POINT); + goto err; + } + if (!BN_usub(y, &group->field, y)) goto err; + } + if (y_bit != BN_is_odd(y)) + { + ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES, ERR_R_INTERNAL_ERROR); + goto err; + } + + if (!EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx)) goto err; + + ret = 1; + + err: + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return ret; + } + + +size_t ec_GFp_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form, + unsigned char *buf, size_t len, BN_CTX *ctx) + { + size_t ret; + BN_CTX *new_ctx = NULL; + int used_ctx = 0; + BIGNUM *x, *y; + size_t field_len, i, skip; + + if ((form != POINT_CONVERSION_COMPRESSED) + && (form != POINT_CONVERSION_UNCOMPRESSED) + && (form != POINT_CONVERSION_HYBRID)) + { + ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, EC_R_INVALID_FORM); + goto err; + } + + if (EC_POINT_is_at_infinity(group, point)) + { + /* encodes to a single 0 octet */ + if (buf != NULL) + { + if (len < 1) + { + ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, EC_R_BUFFER_TOO_SMALL); + return 0; + } + buf[0] = 0; + } + return 1; + } + + + /* ret := required output buffer length */ + field_len = BN_num_bytes(&group->field); + ret = (form == POINT_CONVERSION_COMPRESSED) ? 1 + field_len : 1 + 2*field_len; + + /* if 'buf' is NULL, just return required length */ + if (buf != NULL) + { + if (len < ret) + { + ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, EC_R_BUFFER_TOO_SMALL); + goto err; + } + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return 0; + } + + BN_CTX_start(ctx); + used_ctx = 1; + x = BN_CTX_get(ctx); + y = BN_CTX_get(ctx); + if (y == NULL) goto err; + + if (!EC_POINT_get_affine_coordinates_GFp(group, point, x, y, ctx)) goto err; + + if ((form == POINT_CONVERSION_COMPRESSED || form == POINT_CONVERSION_HYBRID) && BN_is_odd(y)) + buf[0] = form + 1; + else + buf[0] = form; + + i = 1; + + skip = field_len - BN_num_bytes(x); + if (skip > field_len) + { + ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR); + goto err; + } + while (skip > 0) + { + buf[i++] = 0; + skip--; + } + skip = BN_bn2bin(x, buf + i); + i += skip; + if (i != 1 + field_len) + { + ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR); + goto err; + } + + if (form == POINT_CONVERSION_UNCOMPRESSED || form == POINT_CONVERSION_HYBRID) + { + skip = field_len - BN_num_bytes(y); + if (skip > field_len) + { + ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR); + goto err; + } + while (skip > 0) + { + buf[i++] = 0; + skip--; + } + skip = BN_bn2bin(y, buf + i); + i += skip; + } + + if (i != ret) + { + ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR); + goto err; + } + } + + if (used_ctx) + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return ret; + + err: + if (used_ctx) + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return 0; + } + + +int ec_GFp_simple_oct2point(const EC_GROUP *group, EC_POINT *point, + const unsigned char *buf, size_t len, BN_CTX *ctx) + { + point_conversion_form_t form; + int y_bit; + BN_CTX *new_ctx = NULL; + BIGNUM *x, *y; + size_t field_len, enc_len; + int ret = 0; + + if (len == 0) + { + ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_BUFFER_TOO_SMALL); + return 0; + } + form = buf[0]; + y_bit = form & 1; + form = form & ~1U; + if ((form != 0) && (form != POINT_CONVERSION_COMPRESSED) + && (form != POINT_CONVERSION_UNCOMPRESSED) + && (form != POINT_CONVERSION_HYBRID)) + { + ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); + return 0; + } + if ((form == 0 || form == POINT_CONVERSION_UNCOMPRESSED) && y_bit) + { + ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); + return 0; + } + + if (form == 0) + { + if (len != 1) + { + ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); + return 0; + } + + return EC_POINT_set_to_infinity(group, point); + } + + field_len = BN_num_bytes(&group->field); + enc_len = (form == POINT_CONVERSION_COMPRESSED) ? 1 + field_len : 1 + 2*field_len; + + if (len != enc_len) + { + ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); + return 0; + } + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return 0; + } + + BN_CTX_start(ctx); + x = BN_CTX_get(ctx); + y = BN_CTX_get(ctx); + if (y == NULL) goto err; + + if (!BN_bin2bn(buf + 1, field_len, x)) goto err; + if (BN_ucmp(x, &group->field) >= 0) + { + ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); + goto err; + } + + if (form == POINT_CONVERSION_COMPRESSED) + { + if (!EC_POINT_set_compressed_coordinates_GFp(group, point, x, y_bit, ctx)) goto err; + } + else + { + if (!BN_bin2bn(buf + 1 + field_len, field_len, y)) goto err; + if (BN_ucmp(y, &group->field) >= 0) + { + ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); + goto err; + } + if (form == POINT_CONVERSION_HYBRID) + { + if (y_bit != BN_is_odd(y)) + { + ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); + goto err; + } + } + + if (!EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx)) goto err; + } + + if (!EC_POINT_is_on_curve(group, point, ctx)) /* test required by X9.62 */ + { + ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_POINT_IS_NOT_ON_CURVE); + goto err; + } + + ret = 1; + + err: + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return ret; + } + diff --git a/libs/openssl/crypto/ec/ecp_smpl.c b/libs/openssl/crypto/ec/ecp_smpl.c new file mode 100644 index 00000000..7cbb321f --- /dev/null +++ b/libs/openssl/crypto/ec/ecp_smpl.c @@ -0,0 +1,1360 @@ +/* crypto/ec/ecp_smpl.c */ +/* Includes code written by Lenka Fibikova + * for the OpenSSL project. + * Includes code written by Bodo Moeller for the OpenSSL project. +*/ +/* ==================================================================== + * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * Portions of this software developed by SUN MICROSYSTEMS, INC., + * and contributed to the OpenSSL project. + */ + +#include +#include + +#ifdef OPENSSL_FIPS +#include +#endif + +#include "ec_lcl.h" + +const EC_METHOD *EC_GFp_simple_method(void) + { +#ifdef OPENSSL_FIPS + return fips_ec_gfp_simple_method(); +#else + static const EC_METHOD ret = { + EC_FLAGS_DEFAULT_OCT, + NID_X9_62_prime_field, + ec_GFp_simple_group_init, + ec_GFp_simple_group_finish, + ec_GFp_simple_group_clear_finish, + ec_GFp_simple_group_copy, + ec_GFp_simple_group_set_curve, + ec_GFp_simple_group_get_curve, + ec_GFp_simple_group_get_degree, + ec_GFp_simple_group_check_discriminant, + ec_GFp_simple_point_init, + ec_GFp_simple_point_finish, + ec_GFp_simple_point_clear_finish, + ec_GFp_simple_point_copy, + ec_GFp_simple_point_set_to_infinity, + ec_GFp_simple_set_Jprojective_coordinates_GFp, + ec_GFp_simple_get_Jprojective_coordinates_GFp, + ec_GFp_simple_point_set_affine_coordinates, + ec_GFp_simple_point_get_affine_coordinates, + 0,0,0, + ec_GFp_simple_add, + ec_GFp_simple_dbl, + ec_GFp_simple_invert, + ec_GFp_simple_is_at_infinity, + ec_GFp_simple_is_on_curve, + ec_GFp_simple_cmp, + ec_GFp_simple_make_affine, + ec_GFp_simple_points_make_affine, + 0 /* mul */, + 0 /* precompute_mult */, + 0 /* have_precompute_mult */, + ec_GFp_simple_field_mul, + ec_GFp_simple_field_sqr, + 0 /* field_div */, + 0 /* field_encode */, + 0 /* field_decode */, + 0 /* field_set_to_one */ }; + + return &ret; +#endif + } + + +/* Most method functions in this file are designed to work with + * non-trivial representations of field elements if necessary + * (see ecp_mont.c): while standard modular addition and subtraction + * are used, the field_mul and field_sqr methods will be used for + * multiplication, and field_encode and field_decode (if defined) + * will be used for converting between representations. + + * Functions ec_GFp_simple_points_make_affine() and + * ec_GFp_simple_point_get_affine_coordinates() specifically assume + * that if a non-trivial representation is used, it is a Montgomery + * representation (i.e. 'encoding' means multiplying by some factor R). + */ + + +int ec_GFp_simple_group_init(EC_GROUP *group) + { + BN_init(&group->field); + BN_init(&group->a); + BN_init(&group->b); + group->a_is_minus3 = 0; + return 1; + } + + +void ec_GFp_simple_group_finish(EC_GROUP *group) + { + BN_free(&group->field); + BN_free(&group->a); + BN_free(&group->b); + } + + +void ec_GFp_simple_group_clear_finish(EC_GROUP *group) + { + BN_clear_free(&group->field); + BN_clear_free(&group->a); + BN_clear_free(&group->b); + } + + +int ec_GFp_simple_group_copy(EC_GROUP *dest, const EC_GROUP *src) + { + if (!BN_copy(&dest->field, &src->field)) return 0; + if (!BN_copy(&dest->a, &src->a)) return 0; + if (!BN_copy(&dest->b, &src->b)) return 0; + + dest->a_is_minus3 = src->a_is_minus3; + + return 1; + } + + +int ec_GFp_simple_group_set_curve(EC_GROUP *group, + const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) + { + int ret = 0; + BN_CTX *new_ctx = NULL; + BIGNUM *tmp_a; + + /* p must be a prime > 3 */ + if (BN_num_bits(p) <= 2 || !BN_is_odd(p)) + { + ECerr(EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE, EC_R_INVALID_FIELD); + return 0; + } + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return 0; + } + + BN_CTX_start(ctx); + tmp_a = BN_CTX_get(ctx); + if (tmp_a == NULL) goto err; + + /* group->field */ + if (!BN_copy(&group->field, p)) goto err; + BN_set_negative(&group->field, 0); + + /* group->a */ + if (!BN_nnmod(tmp_a, a, p, ctx)) goto err; + if (group->meth->field_encode) + { if (!group->meth->field_encode(group, &group->a, tmp_a, ctx)) goto err; } + else + if (!BN_copy(&group->a, tmp_a)) goto err; + + /* group->b */ + if (!BN_nnmod(&group->b, b, p, ctx)) goto err; + if (group->meth->field_encode) + if (!group->meth->field_encode(group, &group->b, &group->b, ctx)) goto err; + + /* group->a_is_minus3 */ + if (!BN_add_word(tmp_a, 3)) goto err; + group->a_is_minus3 = (0 == BN_cmp(tmp_a, &group->field)); + + ret = 1; + + err: + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return ret; + } + + +int ec_GFp_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx) + { + int ret = 0; + BN_CTX *new_ctx = NULL; + + if (p != NULL) + { + if (!BN_copy(p, &group->field)) return 0; + } + + if (a != NULL || b != NULL) + { + if (group->meth->field_decode) + { + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return 0; + } + if (a != NULL) + { + if (!group->meth->field_decode(group, a, &group->a, ctx)) goto err; + } + if (b != NULL) + { + if (!group->meth->field_decode(group, b, &group->b, ctx)) goto err; + } + } + else + { + if (a != NULL) + { + if (!BN_copy(a, &group->a)) goto err; + } + if (b != NULL) + { + if (!BN_copy(b, &group->b)) goto err; + } + } + } + + ret = 1; + + err: + if (new_ctx) + BN_CTX_free(new_ctx); + return ret; + } + + +int ec_GFp_simple_group_get_degree(const EC_GROUP *group) + { + return BN_num_bits(&group->field); + } + + +int ec_GFp_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx) + { + int ret = 0; + BIGNUM *a,*b,*order,*tmp_1,*tmp_2; + const BIGNUM *p = &group->field; + BN_CTX *new_ctx = NULL; + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + { + ECerr(EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT, ERR_R_MALLOC_FAILURE); + goto err; + } + } + BN_CTX_start(ctx); + a = BN_CTX_get(ctx); + b = BN_CTX_get(ctx); + tmp_1 = BN_CTX_get(ctx); + tmp_2 = BN_CTX_get(ctx); + order = BN_CTX_get(ctx); + if (order == NULL) goto err; + + if (group->meth->field_decode) + { + if (!group->meth->field_decode(group, a, &group->a, ctx)) goto err; + if (!group->meth->field_decode(group, b, &group->b, ctx)) goto err; + } + else + { + if (!BN_copy(a, &group->a)) goto err; + if (!BN_copy(b, &group->b)) goto err; + } + + /* check the discriminant: + * y^2 = x^3 + a*x + b is an elliptic curve <=> 4*a^3 + 27*b^2 != 0 (mod p) + * 0 =< a, b < p */ + if (BN_is_zero(a)) + { + if (BN_is_zero(b)) goto err; + } + else if (!BN_is_zero(b)) + { + if (!BN_mod_sqr(tmp_1, a, p, ctx)) goto err; + if (!BN_mod_mul(tmp_2, tmp_1, a, p, ctx)) goto err; + if (!BN_lshift(tmp_1, tmp_2, 2)) goto err; + /* tmp_1 = 4*a^3 */ + + if (!BN_mod_sqr(tmp_2, b, p, ctx)) goto err; + if (!BN_mul_word(tmp_2, 27)) goto err; + /* tmp_2 = 27*b^2 */ + + if (!BN_mod_add(a, tmp_1, tmp_2, p, ctx)) goto err; + if (BN_is_zero(a)) goto err; + } + ret = 1; + +err: + if (ctx != NULL) + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return ret; + } + + +int ec_GFp_simple_point_init(EC_POINT *point) + { + BN_init(&point->X); + BN_init(&point->Y); + BN_init(&point->Z); + point->Z_is_one = 0; + + return 1; + } + + +void ec_GFp_simple_point_finish(EC_POINT *point) + { + BN_free(&point->X); + BN_free(&point->Y); + BN_free(&point->Z); + } + + +void ec_GFp_simple_point_clear_finish(EC_POINT *point) + { + BN_clear_free(&point->X); + BN_clear_free(&point->Y); + BN_clear_free(&point->Z); + point->Z_is_one = 0; + } + + +int ec_GFp_simple_point_copy(EC_POINT *dest, const EC_POINT *src) + { + if (!BN_copy(&dest->X, &src->X)) return 0; + if (!BN_copy(&dest->Y, &src->Y)) return 0; + if (!BN_copy(&dest->Z, &src->Z)) return 0; + dest->Z_is_one = src->Z_is_one; + + return 1; + } + + +int ec_GFp_simple_point_set_to_infinity(const EC_GROUP *group, EC_POINT *point) + { + point->Z_is_one = 0; + BN_zero(&point->Z); + return 1; + } + + +int ec_GFp_simple_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *point, + const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx) + { + BN_CTX *new_ctx = NULL; + int ret = 0; + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return 0; + } + + if (x != NULL) + { + if (!BN_nnmod(&point->X, x, &group->field, ctx)) goto err; + if (group->meth->field_encode) + { + if (!group->meth->field_encode(group, &point->X, &point->X, ctx)) goto err; + } + } + + if (y != NULL) + { + if (!BN_nnmod(&point->Y, y, &group->field, ctx)) goto err; + if (group->meth->field_encode) + { + if (!group->meth->field_encode(group, &point->Y, &point->Y, ctx)) goto err; + } + } + + if (z != NULL) + { + int Z_is_one; + + if (!BN_nnmod(&point->Z, z, &group->field, ctx)) goto err; + Z_is_one = BN_is_one(&point->Z); + if (group->meth->field_encode) + { + if (Z_is_one && (group->meth->field_set_to_one != 0)) + { + if (!group->meth->field_set_to_one(group, &point->Z, ctx)) goto err; + } + else + { + if (!group->meth->field_encode(group, &point->Z, &point->Z, ctx)) goto err; + } + } + point->Z_is_one = Z_is_one; + } + + ret = 1; + + err: + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return ret; + } + + +int ec_GFp_simple_get_Jprojective_coordinates_GFp(const EC_GROUP *group, const EC_POINT *point, + BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx) + { + BN_CTX *new_ctx = NULL; + int ret = 0; + + if (group->meth->field_decode != 0) + { + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return 0; + } + + if (x != NULL) + { + if (!group->meth->field_decode(group, x, &point->X, ctx)) goto err; + } + if (y != NULL) + { + if (!group->meth->field_decode(group, y, &point->Y, ctx)) goto err; + } + if (z != NULL) + { + if (!group->meth->field_decode(group, z, &point->Z, ctx)) goto err; + } + } + else + { + if (x != NULL) + { + if (!BN_copy(x, &point->X)) goto err; + } + if (y != NULL) + { + if (!BN_copy(y, &point->Y)) goto err; + } + if (z != NULL) + { + if (!BN_copy(z, &point->Z)) goto err; + } + } + + ret = 1; + + err: + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return ret; + } + + +int ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP *group, EC_POINT *point, + const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx) + { + if (x == NULL || y == NULL) + { + /* unlike for projective coordinates, we do not tolerate this */ + ECerr(EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES, ERR_R_PASSED_NULL_PARAMETER); + return 0; + } + + return EC_POINT_set_Jprojective_coordinates_GFp(group, point, x, y, BN_value_one(), ctx); + } + + +int ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point, + BIGNUM *x, BIGNUM *y, BN_CTX *ctx) + { + BN_CTX *new_ctx = NULL; + BIGNUM *Z, *Z_1, *Z_2, *Z_3; + const BIGNUM *Z_; + int ret = 0; + + if (EC_POINT_is_at_infinity(group, point)) + { + ECerr(EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES, EC_R_POINT_AT_INFINITY); + return 0; + } + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return 0; + } + + BN_CTX_start(ctx); + Z = BN_CTX_get(ctx); + Z_1 = BN_CTX_get(ctx); + Z_2 = BN_CTX_get(ctx); + Z_3 = BN_CTX_get(ctx); + if (Z_3 == NULL) goto err; + + /* transform (X, Y, Z) into (x, y) := (X/Z^2, Y/Z^3) */ + + if (group->meth->field_decode) + { + if (!group->meth->field_decode(group, Z, &point->Z, ctx)) goto err; + Z_ = Z; + } + else + { + Z_ = &point->Z; + } + + if (BN_is_one(Z_)) + { + if (group->meth->field_decode) + { + if (x != NULL) + { + if (!group->meth->field_decode(group, x, &point->X, ctx)) goto err; + } + if (y != NULL) + { + if (!group->meth->field_decode(group, y, &point->Y, ctx)) goto err; + } + } + else + { + if (x != NULL) + { + if (!BN_copy(x, &point->X)) goto err; + } + if (y != NULL) + { + if (!BN_copy(y, &point->Y)) goto err; + } + } + } + else + { + if (!BN_mod_inverse(Z_1, Z_, &group->field, ctx)) + { + ECerr(EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES, ERR_R_BN_LIB); + goto err; + } + + if (group->meth->field_encode == 0) + { + /* field_sqr works on standard representation */ + if (!group->meth->field_sqr(group, Z_2, Z_1, ctx)) goto err; + } + else + { + if (!BN_mod_sqr(Z_2, Z_1, &group->field, ctx)) goto err; + } + + if (x != NULL) + { + /* in the Montgomery case, field_mul will cancel out Montgomery factor in X: */ + if (!group->meth->field_mul(group, x, &point->X, Z_2, ctx)) goto err; + } + + if (y != NULL) + { + if (group->meth->field_encode == 0) + { + /* field_mul works on standard representation */ + if (!group->meth->field_mul(group, Z_3, Z_2, Z_1, ctx)) goto err; + } + else + { + if (!BN_mod_mul(Z_3, Z_2, Z_1, &group->field, ctx)) goto err; + } + + /* in the Montgomery case, field_mul will cancel out Montgomery factor in Y: */ + if (!group->meth->field_mul(group, y, &point->Y, Z_3, ctx)) goto err; + } + } + + ret = 1; + + err: + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return ret; + } + +int ec_GFp_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx) + { + int (*field_mul)(const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); + int (*field_sqr)(const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); + const BIGNUM *p; + BN_CTX *new_ctx = NULL; + BIGNUM *n0, *n1, *n2, *n3, *n4, *n5, *n6; + int ret = 0; + + if (a == b) + return EC_POINT_dbl(group, r, a, ctx); + if (EC_POINT_is_at_infinity(group, a)) + return EC_POINT_copy(r, b); + if (EC_POINT_is_at_infinity(group, b)) + return EC_POINT_copy(r, a); + + field_mul = group->meth->field_mul; + field_sqr = group->meth->field_sqr; + p = &group->field; + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return 0; + } + + BN_CTX_start(ctx); + n0 = BN_CTX_get(ctx); + n1 = BN_CTX_get(ctx); + n2 = BN_CTX_get(ctx); + n3 = BN_CTX_get(ctx); + n4 = BN_CTX_get(ctx); + n5 = BN_CTX_get(ctx); + n6 = BN_CTX_get(ctx); + if (n6 == NULL) goto end; + + /* Note that in this function we must not read components of 'a' or 'b' + * once we have written the corresponding components of 'r'. + * ('r' might be one of 'a' or 'b'.) + */ + + /* n1, n2 */ + if (b->Z_is_one) + { + if (!BN_copy(n1, &a->X)) goto end; + if (!BN_copy(n2, &a->Y)) goto end; + /* n1 = X_a */ + /* n2 = Y_a */ + } + else + { + if (!field_sqr(group, n0, &b->Z, ctx)) goto end; + if (!field_mul(group, n1, &a->X, n0, ctx)) goto end; + /* n1 = X_a * Z_b^2 */ + + if (!field_mul(group, n0, n0, &b->Z, ctx)) goto end; + if (!field_mul(group, n2, &a->Y, n0, ctx)) goto end; + /* n2 = Y_a * Z_b^3 */ + } + + /* n3, n4 */ + if (a->Z_is_one) + { + if (!BN_copy(n3, &b->X)) goto end; + if (!BN_copy(n4, &b->Y)) goto end; + /* n3 = X_b */ + /* n4 = Y_b */ + } + else + { + if (!field_sqr(group, n0, &a->Z, ctx)) goto end; + if (!field_mul(group, n3, &b->X, n0, ctx)) goto end; + /* n3 = X_b * Z_a^2 */ + + if (!field_mul(group, n0, n0, &a->Z, ctx)) goto end; + if (!field_mul(group, n4, &b->Y, n0, ctx)) goto end; + /* n4 = Y_b * Z_a^3 */ + } + + /* n5, n6 */ + if (!BN_mod_sub_quick(n5, n1, n3, p)) goto end; + if (!BN_mod_sub_quick(n6, n2, n4, p)) goto end; + /* n5 = n1 - n3 */ + /* n6 = n2 - n4 */ + + if (BN_is_zero(n5)) + { + if (BN_is_zero(n6)) + { + /* a is the same point as b */ + BN_CTX_end(ctx); + ret = EC_POINT_dbl(group, r, a, ctx); + ctx = NULL; + goto end; + } + else + { + /* a is the inverse of b */ + BN_zero(&r->Z); + r->Z_is_one = 0; + ret = 1; + goto end; + } + } + + /* 'n7', 'n8' */ + if (!BN_mod_add_quick(n1, n1, n3, p)) goto end; + if (!BN_mod_add_quick(n2, n2, n4, p)) goto end; + /* 'n7' = n1 + n3 */ + /* 'n8' = n2 + n4 */ + + /* Z_r */ + if (a->Z_is_one && b->Z_is_one) + { + if (!BN_copy(&r->Z, n5)) goto end; + } + else + { + if (a->Z_is_one) + { if (!BN_copy(n0, &b->Z)) goto end; } + else if (b->Z_is_one) + { if (!BN_copy(n0, &a->Z)) goto end; } + else + { if (!field_mul(group, n0, &a->Z, &b->Z, ctx)) goto end; } + if (!field_mul(group, &r->Z, n0, n5, ctx)) goto end; + } + r->Z_is_one = 0; + /* Z_r = Z_a * Z_b * n5 */ + + /* X_r */ + if (!field_sqr(group, n0, n6, ctx)) goto end; + if (!field_sqr(group, n4, n5, ctx)) goto end; + if (!field_mul(group, n3, n1, n4, ctx)) goto end; + if (!BN_mod_sub_quick(&r->X, n0, n3, p)) goto end; + /* X_r = n6^2 - n5^2 * 'n7' */ + + /* 'n9' */ + if (!BN_mod_lshift1_quick(n0, &r->X, p)) goto end; + if (!BN_mod_sub_quick(n0, n3, n0, p)) goto end; + /* n9 = n5^2 * 'n7' - 2 * X_r */ + + /* Y_r */ + if (!field_mul(group, n0, n0, n6, ctx)) goto end; + if (!field_mul(group, n5, n4, n5, ctx)) goto end; /* now n5 is n5^3 */ + if (!field_mul(group, n1, n2, n5, ctx)) goto end; + if (!BN_mod_sub_quick(n0, n0, n1, p)) goto end; + if (BN_is_odd(n0)) + if (!BN_add(n0, n0, p)) goto end; + /* now 0 <= n0 < 2*p, and n0 is even */ + if (!BN_rshift1(&r->Y, n0)) goto end; + /* Y_r = (n6 * 'n9' - 'n8' * 'n5^3') / 2 */ + + ret = 1; + + end: + if (ctx) /* otherwise we already called BN_CTX_end */ + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return ret; + } + + +int ec_GFp_simple_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx) + { + int (*field_mul)(const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); + int (*field_sqr)(const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); + const BIGNUM *p; + BN_CTX *new_ctx = NULL; + BIGNUM *n0, *n1, *n2, *n3; + int ret = 0; + + if (EC_POINT_is_at_infinity(group, a)) + { + BN_zero(&r->Z); + r->Z_is_one = 0; + return 1; + } + + field_mul = group->meth->field_mul; + field_sqr = group->meth->field_sqr; + p = &group->field; + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return 0; + } + + BN_CTX_start(ctx); + n0 = BN_CTX_get(ctx); + n1 = BN_CTX_get(ctx); + n2 = BN_CTX_get(ctx); + n3 = BN_CTX_get(ctx); + if (n3 == NULL) goto err; + + /* Note that in this function we must not read components of 'a' + * once we have written the corresponding components of 'r'. + * ('r' might the same as 'a'.) + */ + + /* n1 */ + if (a->Z_is_one) + { + if (!field_sqr(group, n0, &a->X, ctx)) goto err; + if (!BN_mod_lshift1_quick(n1, n0, p)) goto err; + if (!BN_mod_add_quick(n0, n0, n1, p)) goto err; + if (!BN_mod_add_quick(n1, n0, &group->a, p)) goto err; + /* n1 = 3 * X_a^2 + a_curve */ + } + else if (group->a_is_minus3) + { + if (!field_sqr(group, n1, &a->Z, ctx)) goto err; + if (!BN_mod_add_quick(n0, &a->X, n1, p)) goto err; + if (!BN_mod_sub_quick(n2, &a->X, n1, p)) goto err; + if (!field_mul(group, n1, n0, n2, ctx)) goto err; + if (!BN_mod_lshift1_quick(n0, n1, p)) goto err; + if (!BN_mod_add_quick(n1, n0, n1, p)) goto err; + /* n1 = 3 * (X_a + Z_a^2) * (X_a - Z_a^2) + * = 3 * X_a^2 - 3 * Z_a^4 */ + } + else + { + if (!field_sqr(group, n0, &a->X, ctx)) goto err; + if (!BN_mod_lshift1_quick(n1, n0, p)) goto err; + if (!BN_mod_add_quick(n0, n0, n1, p)) goto err; + if (!field_sqr(group, n1, &a->Z, ctx)) goto err; + if (!field_sqr(group, n1, n1, ctx)) goto err; + if (!field_mul(group, n1, n1, &group->a, ctx)) goto err; + if (!BN_mod_add_quick(n1, n1, n0, p)) goto err; + /* n1 = 3 * X_a^2 + a_curve * Z_a^4 */ + } + + /* Z_r */ + if (a->Z_is_one) + { + if (!BN_copy(n0, &a->Y)) goto err; + } + else + { + if (!field_mul(group, n0, &a->Y, &a->Z, ctx)) goto err; + } + if (!BN_mod_lshift1_quick(&r->Z, n0, p)) goto err; + r->Z_is_one = 0; + /* Z_r = 2 * Y_a * Z_a */ + + /* n2 */ + if (!field_sqr(group, n3, &a->Y, ctx)) goto err; + if (!field_mul(group, n2, &a->X, n3, ctx)) goto err; + if (!BN_mod_lshift_quick(n2, n2, 2, p)) goto err; + /* n2 = 4 * X_a * Y_a^2 */ + + /* X_r */ + if (!BN_mod_lshift1_quick(n0, n2, p)) goto err; + if (!field_sqr(group, &r->X, n1, ctx)) goto err; + if (!BN_mod_sub_quick(&r->X, &r->X, n0, p)) goto err; + /* X_r = n1^2 - 2 * n2 */ + + /* n3 */ + if (!field_sqr(group, n0, n3, ctx)) goto err; + if (!BN_mod_lshift_quick(n3, n0, 3, p)) goto err; + /* n3 = 8 * Y_a^4 */ + + /* Y_r */ + if (!BN_mod_sub_quick(n0, n2, &r->X, p)) goto err; + if (!field_mul(group, n0, n1, n0, ctx)) goto err; + if (!BN_mod_sub_quick(&r->Y, n0, n3, p)) goto err; + /* Y_r = n1 * (n2 - X_r) - n3 */ + + ret = 1; + + err: + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return ret; + } + + +int ec_GFp_simple_invert(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx) + { + if (EC_POINT_is_at_infinity(group, point) || BN_is_zero(&point->Y)) + /* point is its own inverse */ + return 1; + + return BN_usub(&point->Y, &group->field, &point->Y); + } + + +int ec_GFp_simple_is_at_infinity(const EC_GROUP *group, const EC_POINT *point) + { + return BN_is_zero(&point->Z); + } + + +int ec_GFp_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx) + { + int (*field_mul)(const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); + int (*field_sqr)(const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); + const BIGNUM *p; + BN_CTX *new_ctx = NULL; + BIGNUM *rh, *tmp, *Z4, *Z6; + int ret = -1; + + if (EC_POINT_is_at_infinity(group, point)) + return 1; + + field_mul = group->meth->field_mul; + field_sqr = group->meth->field_sqr; + p = &group->field; + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return -1; + } + + BN_CTX_start(ctx); + rh = BN_CTX_get(ctx); + tmp = BN_CTX_get(ctx); + Z4 = BN_CTX_get(ctx); + Z6 = BN_CTX_get(ctx); + if (Z6 == NULL) goto err; + + /* We have a curve defined by a Weierstrass equation + * y^2 = x^3 + a*x + b. + * The point to consider is given in Jacobian projective coordinates + * where (X, Y, Z) represents (x, y) = (X/Z^2, Y/Z^3). + * Substituting this and multiplying by Z^6 transforms the above equation into + * Y^2 = X^3 + a*X*Z^4 + b*Z^6. + * To test this, we add up the right-hand side in 'rh'. + */ + + /* rh := X^2 */ + if (!field_sqr(group, rh, &point->X, ctx)) goto err; + + if (!point->Z_is_one) + { + if (!field_sqr(group, tmp, &point->Z, ctx)) goto err; + if (!field_sqr(group, Z4, tmp, ctx)) goto err; + if (!field_mul(group, Z6, Z4, tmp, ctx)) goto err; + + /* rh := (rh + a*Z^4)*X */ + if (group->a_is_minus3) + { + if (!BN_mod_lshift1_quick(tmp, Z4, p)) goto err; + if (!BN_mod_add_quick(tmp, tmp, Z4, p)) goto err; + if (!BN_mod_sub_quick(rh, rh, tmp, p)) goto err; + if (!field_mul(group, rh, rh, &point->X, ctx)) goto err; + } + else + { + if (!field_mul(group, tmp, Z4, &group->a, ctx)) goto err; + if (!BN_mod_add_quick(rh, rh, tmp, p)) goto err; + if (!field_mul(group, rh, rh, &point->X, ctx)) goto err; + } + + /* rh := rh + b*Z^6 */ + if (!field_mul(group, tmp, &group->b, Z6, ctx)) goto err; + if (!BN_mod_add_quick(rh, rh, tmp, p)) goto err; + } + else + { + /* point->Z_is_one */ + + /* rh := (rh + a)*X */ + if (!BN_mod_add_quick(rh, rh, &group->a, p)) goto err; + if (!field_mul(group, rh, rh, &point->X, ctx)) goto err; + /* rh := rh + b */ + if (!BN_mod_add_quick(rh, rh, &group->b, p)) goto err; + } + + /* 'lh' := Y^2 */ + if (!field_sqr(group, tmp, &point->Y, ctx)) goto err; + + ret = (0 == BN_ucmp(tmp, rh)); + + err: + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return ret; + } + + +int ec_GFp_simple_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx) + { + /* return values: + * -1 error + * 0 equal (in affine coordinates) + * 1 not equal + */ + + int (*field_mul)(const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); + int (*field_sqr)(const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); + BN_CTX *new_ctx = NULL; + BIGNUM *tmp1, *tmp2, *Za23, *Zb23; + const BIGNUM *tmp1_, *tmp2_; + int ret = -1; + + if (EC_POINT_is_at_infinity(group, a)) + { + return EC_POINT_is_at_infinity(group, b) ? 0 : 1; + } + + if (EC_POINT_is_at_infinity(group, b)) + return 1; + + if (a->Z_is_one && b->Z_is_one) + { + return ((BN_cmp(&a->X, &b->X) == 0) && BN_cmp(&a->Y, &b->Y) == 0) ? 0 : 1; + } + + field_mul = group->meth->field_mul; + field_sqr = group->meth->field_sqr; + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return -1; + } + + BN_CTX_start(ctx); + tmp1 = BN_CTX_get(ctx); + tmp2 = BN_CTX_get(ctx); + Za23 = BN_CTX_get(ctx); + Zb23 = BN_CTX_get(ctx); + if (Zb23 == NULL) goto end; + + /* We have to decide whether + * (X_a/Z_a^2, Y_a/Z_a^3) = (X_b/Z_b^2, Y_b/Z_b^3), + * or equivalently, whether + * (X_a*Z_b^2, Y_a*Z_b^3) = (X_b*Z_a^2, Y_b*Z_a^3). + */ + + if (!b->Z_is_one) + { + if (!field_sqr(group, Zb23, &b->Z, ctx)) goto end; + if (!field_mul(group, tmp1, &a->X, Zb23, ctx)) goto end; + tmp1_ = tmp1; + } + else + tmp1_ = &a->X; + if (!a->Z_is_one) + { + if (!field_sqr(group, Za23, &a->Z, ctx)) goto end; + if (!field_mul(group, tmp2, &b->X, Za23, ctx)) goto end; + tmp2_ = tmp2; + } + else + tmp2_ = &b->X; + + /* compare X_a*Z_b^2 with X_b*Z_a^2 */ + if (BN_cmp(tmp1_, tmp2_) != 0) + { + ret = 1; /* points differ */ + goto end; + } + + + if (!b->Z_is_one) + { + if (!field_mul(group, Zb23, Zb23, &b->Z, ctx)) goto end; + if (!field_mul(group, tmp1, &a->Y, Zb23, ctx)) goto end; + /* tmp1_ = tmp1 */ + } + else + tmp1_ = &a->Y; + if (!a->Z_is_one) + { + if (!field_mul(group, Za23, Za23, &a->Z, ctx)) goto end; + if (!field_mul(group, tmp2, &b->Y, Za23, ctx)) goto end; + /* tmp2_ = tmp2 */ + } + else + tmp2_ = &b->Y; + + /* compare Y_a*Z_b^3 with Y_b*Z_a^3 */ + if (BN_cmp(tmp1_, tmp2_) != 0) + { + ret = 1; /* points differ */ + goto end; + } + + /* points are equal */ + ret = 0; + + end: + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return ret; + } + + +int ec_GFp_simple_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx) + { + BN_CTX *new_ctx = NULL; + BIGNUM *x, *y; + int ret = 0; + + if (point->Z_is_one || EC_POINT_is_at_infinity(group, point)) + return 1; + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return 0; + } + + BN_CTX_start(ctx); + x = BN_CTX_get(ctx); + y = BN_CTX_get(ctx); + if (y == NULL) goto err; + + if (!EC_POINT_get_affine_coordinates_GFp(group, point, x, y, ctx)) goto err; + if (!EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx)) goto err; + if (!point->Z_is_one) + { + ECerr(EC_F_EC_GFP_SIMPLE_MAKE_AFFINE, ERR_R_INTERNAL_ERROR); + goto err; + } + + ret = 1; + + err: + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + return ret; + } + + +int ec_GFp_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx) + { + BN_CTX *new_ctx = NULL; + BIGNUM *tmp0, *tmp1; + size_t pow2 = 0; + BIGNUM **heap = NULL; + size_t i; + int ret = 0; + + if (num == 0) + return 1; + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return 0; + } + + BN_CTX_start(ctx); + tmp0 = BN_CTX_get(ctx); + tmp1 = BN_CTX_get(ctx); + if (tmp0 == NULL || tmp1 == NULL) goto err; + + /* Before converting the individual points, compute inverses of all Z values. + * Modular inversion is rather slow, but luckily we can do with a single + * explicit inversion, plus about 3 multiplications per input value. + */ + + pow2 = 1; + while (num > pow2) + pow2 <<= 1; + /* Now pow2 is the smallest power of 2 satifsying pow2 >= num. + * We need twice that. */ + pow2 <<= 1; + + heap = OPENSSL_malloc(pow2 * sizeof heap[0]); + if (heap == NULL) goto err; + + /* The array is used as a binary tree, exactly as in heapsort: + * + * heap[1] + * heap[2] heap[3] + * heap[4] heap[5] heap[6] heap[7] + * heap[8]heap[9] heap[10]heap[11] heap[12]heap[13] heap[14] heap[15] + * + * We put the Z's in the last line; + * then we set each other node to the product of its two child-nodes (where + * empty or 0 entries are treated as ones); + * then we invert heap[1]; + * then we invert each other node by replacing it by the product of its + * parent (after inversion) and its sibling (before inversion). + */ + heap[0] = NULL; + for (i = pow2/2 - 1; i > 0; i--) + heap[i] = NULL; + for (i = 0; i < num; i++) + heap[pow2/2 + i] = &points[i]->Z; + for (i = pow2/2 + num; i < pow2; i++) + heap[i] = NULL; + + /* set each node to the product of its children */ + for (i = pow2/2 - 1; i > 0; i--) + { + heap[i] = BN_new(); + if (heap[i] == NULL) goto err; + + if (heap[2*i] != NULL) + { + if ((heap[2*i + 1] == NULL) || BN_is_zero(heap[2*i + 1])) + { + if (!BN_copy(heap[i], heap[2*i])) goto err; + } + else + { + if (BN_is_zero(heap[2*i])) + { + if (!BN_copy(heap[i], heap[2*i + 1])) goto err; + } + else + { + if (!group->meth->field_mul(group, heap[i], + heap[2*i], heap[2*i + 1], ctx)) goto err; + } + } + } + } + + /* invert heap[1] */ + if (!BN_is_zero(heap[1])) + { + if (!BN_mod_inverse(heap[1], heap[1], &group->field, ctx)) + { + ECerr(EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE, ERR_R_BN_LIB); + goto err; + } + } + if (group->meth->field_encode != 0) + { + /* in the Montgomery case, we just turned R*H (representing H) + * into 1/(R*H), but we need R*(1/H) (representing 1/H); + * i.e. we have need to multiply by the Montgomery factor twice */ + if (!group->meth->field_encode(group, heap[1], heap[1], ctx)) goto err; + if (!group->meth->field_encode(group, heap[1], heap[1], ctx)) goto err; + } + + /* set other heap[i]'s to their inverses */ + for (i = 2; i < pow2/2 + num; i += 2) + { + /* i is even */ + if ((heap[i + 1] != NULL) && !BN_is_zero(heap[i + 1])) + { + if (!group->meth->field_mul(group, tmp0, heap[i/2], heap[i + 1], ctx)) goto err; + if (!group->meth->field_mul(group, tmp1, heap[i/2], heap[i], ctx)) goto err; + if (!BN_copy(heap[i], tmp0)) goto err; + if (!BN_copy(heap[i + 1], tmp1)) goto err; + } + else + { + if (!BN_copy(heap[i], heap[i/2])) goto err; + } + } + + /* we have replaced all non-zero Z's by their inverses, now fix up all the points */ + for (i = 0; i < num; i++) + { + EC_POINT *p = points[i]; + + if (!BN_is_zero(&p->Z)) + { + /* turn (X, Y, 1/Z) into (X/Z^2, Y/Z^3, 1) */ + + if (!group->meth->field_sqr(group, tmp1, &p->Z, ctx)) goto err; + if (!group->meth->field_mul(group, &p->X, &p->X, tmp1, ctx)) goto err; + + if (!group->meth->field_mul(group, tmp1, tmp1, &p->Z, ctx)) goto err; + if (!group->meth->field_mul(group, &p->Y, &p->Y, tmp1, ctx)) goto err; + + if (group->meth->field_set_to_one != 0) + { + if (!group->meth->field_set_to_one(group, &p->Z, ctx)) goto err; + } + else + { + if (!BN_one(&p->Z)) goto err; + } + p->Z_is_one = 1; + } + } + + ret = 1; + + err: + BN_CTX_end(ctx); + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + if (heap != NULL) + { + /* heap[pow2/2] .. heap[pow2-1] have not been allocated locally! */ + for (i = pow2/2 - 1; i > 0; i--) + { + if (heap[i] != NULL) + BN_clear_free(heap[i]); + } + OPENSSL_free(heap); + } + return ret; + } + + +int ec_GFp_simple_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) + { + return BN_mod_mul(r, a, b, &group->field, ctx); + } + + +int ec_GFp_simple_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) + { + return BN_mod_sqr(r, a, &group->field, ctx); + } diff --git a/libs/openssl/crypto/ecdh/ecdh.h b/libs/openssl/crypto/ecdh/ecdh.h new file mode 100644 index 00000000..8887102c --- /dev/null +++ b/libs/openssl/crypto/ecdh/ecdh.h @@ -0,0 +1,125 @@ +/* crypto/ecdh/ecdh.h */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * The Elliptic Curve Public-Key Crypto Library (ECC Code) included + * herein is developed by SUN MICROSYSTEMS, INC., and is contributed + * to the OpenSSL project. + * + * The ECC Code is licensed pursuant to the OpenSSL open source + * license provided below. + * + * The ECDH software is originally written by Douglas Stebila of + * Sun Microsystems Laboratories. + * + */ +/* ==================================================================== + * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +#ifndef HEADER_ECDH_H +#define HEADER_ECDH_H + +#include + +#ifdef OPENSSL_NO_ECDH +#error ECDH is disabled. +#endif + +#include +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +const ECDH_METHOD *ECDH_OpenSSL(void); + +void ECDH_set_default_method(const ECDH_METHOD *); +const ECDH_METHOD *ECDH_get_default_method(void); +int ECDH_set_method(EC_KEY *, const ECDH_METHOD *); + +int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh, + void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)); + +int ECDH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new + *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int ECDH_set_ex_data(EC_KEY *d, int idx, void *arg); +void *ECDH_get_ex_data(EC_KEY *d, int idx); + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_ECDH_strings(void); + +/* Error codes for the ECDH functions. */ + +/* Function codes. */ +#define ECDH_F_ECDH_CHECK 102 +#define ECDH_F_ECDH_COMPUTE_KEY 100 +#define ECDH_F_ECDH_DATA_NEW_METHOD 101 + +/* Reason codes. */ +#define ECDH_R_KDF_FAILED 102 +#define ECDH_R_NON_FIPS_METHOD 103 +#define ECDH_R_NO_PRIVATE_VALUE 100 +#define ECDH_R_POINT_ARITHMETIC_FAILURE 101 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libs/openssl/crypto/ecdh/ech_err.c b/libs/openssl/crypto/ecdh/ech_err.c new file mode 100644 index 00000000..3bd24739 --- /dev/null +++ b/libs/openssl/crypto/ecdh/ech_err.c @@ -0,0 +1,100 @@ +/* crypto/ecdh/ech_err.c */ +/* ==================================================================== + * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +/* NOTE: this file was auto generated by the mkerr.pl script: any changes + * made to it will be overwritten when the script next updates this file, + * only reason strings will be preserved. + */ + +#include +#include +#include + +/* BEGIN ERROR CODES */ +#ifndef OPENSSL_NO_ERR + +#define ERR_FUNC(func) ERR_PACK(ERR_LIB_ECDH,func,0) +#define ERR_REASON(reason) ERR_PACK(ERR_LIB_ECDH,0,reason) + +static ERR_STRING_DATA ECDH_str_functs[]= + { +{ERR_FUNC(ECDH_F_ECDH_CHECK), "ECDH_CHECK"}, +{ERR_FUNC(ECDH_F_ECDH_COMPUTE_KEY), "ECDH_compute_key"}, +{ERR_FUNC(ECDH_F_ECDH_DATA_NEW_METHOD), "ECDH_DATA_new_method"}, +{0,NULL} + }; + +static ERR_STRING_DATA ECDH_str_reasons[]= + { +{ERR_REASON(ECDH_R_KDF_FAILED) ,"KDF failed"}, +{ERR_REASON(ECDH_R_NON_FIPS_METHOD) ,"non fips method"}, +{ERR_REASON(ECDH_R_NO_PRIVATE_VALUE) ,"no private value"}, +{ERR_REASON(ECDH_R_POINT_ARITHMETIC_FAILURE),"point arithmetic failure"}, +{0,NULL} + }; + +#endif + +void ERR_load_ECDH_strings(void) + { +#ifndef OPENSSL_NO_ERR + + if (ERR_func_error_string(ECDH_str_functs[0].error) == NULL) + { + ERR_load_strings(0,ECDH_str_functs); + ERR_load_strings(0,ECDH_str_reasons); + } +#endif + } diff --git a/libs/openssl/crypto/ecdh/ech_key.c b/libs/openssl/crypto/ecdh/ech_key.c new file mode 100644 index 00000000..2988899e --- /dev/null +++ b/libs/openssl/crypto/ecdh/ech_key.c @@ -0,0 +1,80 @@ +/* crypto/ecdh/ecdh_key.c */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * The Elliptic Curve Public-Key Crypto Library (ECC Code) included + * herein is developed by SUN MICROSYSTEMS, INC., and is contributed + * to the OpenSSL project. + * + * The ECC Code is licensed pursuant to the OpenSSL open source + * license provided below. + * + * The ECDH software is originally written by Douglas Stebila of + * Sun Microsystems Laboratories. + * + */ +/* ==================================================================== + * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include "ech_locl.h" + +int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, + EC_KEY *eckey, + void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)) +{ + ECDH_DATA *ecdh = ecdh_check(eckey); + if (ecdh == NULL) + return 0; + return ecdh->meth->compute_key(out, outlen, pub_key, eckey, KDF); +} diff --git a/libs/openssl/crypto/ecdh/ech_lib.c b/libs/openssl/crypto/ecdh/ech_lib.c new file mode 100644 index 00000000..0644431b --- /dev/null +++ b/libs/openssl/crypto/ecdh/ech_lib.c @@ -0,0 +1,273 @@ +/* crypto/ecdh/ech_lib.c */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * The Elliptic Curve Public-Key Crypto Library (ECC Code) included + * herein is developed by SUN MICROSYSTEMS, INC., and is contributed + * to the OpenSSL project. + * + * The ECC Code is licensed pursuant to the OpenSSL open source + * license provided below. + * + * The ECDH software is originally written by Douglas Stebila of + * Sun Microsystems Laboratories. + * + */ +/* ==================================================================== + * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include "ech_locl.h" +#include +#ifndef OPENSSL_NO_ENGINE +#include +#endif +#include +#ifdef OPENSSL_FIPS +#include +#endif + +const char ECDH_version[]="ECDH" OPENSSL_VERSION_PTEXT; + +static const ECDH_METHOD *default_ECDH_method = NULL; + +static void *ecdh_data_new(void); +static void *ecdh_data_dup(void *); +static void ecdh_data_free(void *); + +void ECDH_set_default_method(const ECDH_METHOD *meth) + { + default_ECDH_method = meth; + } + +const ECDH_METHOD *ECDH_get_default_method(void) + { + if(!default_ECDH_method) + { +#ifdef OPENSSL_FIPS + if (FIPS_mode()) + return FIPS_ecdh_openssl(); + else + return ECDH_OpenSSL(); +#else + default_ECDH_method = ECDH_OpenSSL(); +#endif + } + return default_ECDH_method; + } + +int ECDH_set_method(EC_KEY *eckey, const ECDH_METHOD *meth) + { + ECDH_DATA *ecdh; + + ecdh = ecdh_check(eckey); + + if (ecdh == NULL) + return 0; + +#if 0 + mtmp = ecdh->meth; + if (mtmp->finish) + mtmp->finish(eckey); +#endif +#ifndef OPENSSL_NO_ENGINE + if (ecdh->engine) + { + ENGINE_finish(ecdh->engine); + ecdh->engine = NULL; + } +#endif + ecdh->meth = meth; +#if 0 + if (meth->init) + meth->init(eckey); +#endif + return 1; + } + +static ECDH_DATA *ECDH_DATA_new_method(ENGINE *engine) + { + ECDH_DATA *ret; + + ret=(ECDH_DATA *)OPENSSL_malloc(sizeof(ECDH_DATA)); + if (ret == NULL) + { + ECDHerr(ECDH_F_ECDH_DATA_NEW_METHOD, ERR_R_MALLOC_FAILURE); + return(NULL); + } + + ret->init = NULL; + + ret->meth = ECDH_get_default_method(); + ret->engine = engine; +#ifndef OPENSSL_NO_ENGINE + if (!ret->engine) + ret->engine = ENGINE_get_default_ECDH(); + if (ret->engine) + { + ret->meth = ENGINE_get_ECDH(ret->engine); + if (!ret->meth) + { + ECDHerr(ECDH_F_ECDH_DATA_NEW_METHOD, ERR_R_ENGINE_LIB); + ENGINE_finish(ret->engine); + OPENSSL_free(ret); + return NULL; + } + } +#endif + + ret->flags = ret->meth->flags; + CRYPTO_new_ex_data(CRYPTO_EX_INDEX_ECDH, ret, &ret->ex_data); +#if 0 + if ((ret->meth->init != NULL) && !ret->meth->init(ret)) + { + CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ECDH, ret, &ret->ex_data); + OPENSSL_free(ret); + ret=NULL; + } +#endif + return(ret); + } + +static void *ecdh_data_new(void) + { + return (void *)ECDH_DATA_new_method(NULL); + } + +static void *ecdh_data_dup(void *data) +{ + ECDH_DATA *r = (ECDH_DATA *)data; + + /* XXX: dummy operation */ + if (r == NULL) + return NULL; + + return (void *)ecdh_data_new(); +} + +void ecdh_data_free(void *data) + { + ECDH_DATA *r = (ECDH_DATA *)data; + +#ifndef OPENSSL_NO_ENGINE + if (r->engine) + ENGINE_finish(r->engine); +#endif + + CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ECDH, r, &r->ex_data); + + OPENSSL_cleanse((void *)r, sizeof(ECDH_DATA)); + + OPENSSL_free(r); + } + +ECDH_DATA *ecdh_check(EC_KEY *key) + { + ECDH_DATA *ecdh_data; + + void *data = EC_KEY_get_key_method_data(key, ecdh_data_dup, + ecdh_data_free, ecdh_data_free); + if (data == NULL) + { + ecdh_data = (ECDH_DATA *)ecdh_data_new(); + if (ecdh_data == NULL) + return NULL; + data = EC_KEY_insert_key_method_data(key, (void *)ecdh_data, + ecdh_data_dup, ecdh_data_free, ecdh_data_free); + if (data != NULL) + { + /* Another thread raced us to install the key_method + * data and won. */ + ecdh_data_free(ecdh_data); + ecdh_data = (ECDH_DATA *)data; + } + } + else + ecdh_data = (ECDH_DATA *)data; +#ifdef OPENSSL_FIPS + if (FIPS_mode() && !(ecdh_data->flags & ECDH_FLAG_FIPS_METHOD) + && !(EC_KEY_get_flags(key) & EC_FLAG_NON_FIPS_ALLOW)) + { + ECDHerr(ECDH_F_ECDH_CHECK, ECDH_R_NON_FIPS_METHOD); + return NULL; + } +#endif + + + return ecdh_data; + } + +int ECDH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) + { + return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_ECDH, argl, argp, + new_func, dup_func, free_func); + } + +int ECDH_set_ex_data(EC_KEY *d, int idx, void *arg) + { + ECDH_DATA *ecdh; + ecdh = ecdh_check(d); + if (ecdh == NULL) + return 0; + return(CRYPTO_set_ex_data(&ecdh->ex_data,idx,arg)); + } + +void *ECDH_get_ex_data(EC_KEY *d, int idx) + { + ECDH_DATA *ecdh; + ecdh = ecdh_check(d); + if (ecdh == NULL) + return NULL; + return(CRYPTO_get_ex_data(&ecdh->ex_data,idx)); + } diff --git a/libs/openssl/crypto/ecdh/ech_locl.h b/libs/openssl/crypto/ecdh/ech_locl.h new file mode 100644 index 00000000..f6cad6a8 --- /dev/null +++ b/libs/openssl/crypto/ecdh/ech_locl.h @@ -0,0 +1,102 @@ +/* crypto/ecdh/ech_locl.h */ +/* ==================================================================== + * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_ECH_LOCL_H +#define HEADER_ECH_LOCL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct ecdh_method + { + const char *name; + int (*compute_key)(void *key, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh, + void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)); +#if 0 + int (*init)(EC_KEY *eckey); + int (*finish)(EC_KEY *eckey); +#endif + int flags; + char *app_data; + }; + +/* If this flag is set the ECDH method is FIPS compliant and can be used + * in FIPS mode. This is set in the validated module method. If an + * application sets this flag in its own methods it is its responsibility + * to ensure the result is compliant. + */ + +#define ECDH_FLAG_FIPS_METHOD 0x1 + +typedef struct ecdh_data_st { + /* EC_KEY_METH_DATA part */ + int (*init)(EC_KEY *); + /* method specific part */ + ENGINE *engine; + int flags; + const ECDH_METHOD *meth; + CRYPTO_EX_DATA ex_data; +} ECDH_DATA; + +ECDH_DATA *ecdh_check(EC_KEY *); + +#ifdef __cplusplus +} +#endif + +#endif /* HEADER_ECH_LOCL_H */ diff --git a/libs/openssl/crypto/ecdh/ech_ossl.c b/libs/openssl/crypto/ecdh/ech_ossl.c new file mode 100644 index 00000000..4a30628f --- /dev/null +++ b/libs/openssl/crypto/ecdh/ech_ossl.c @@ -0,0 +1,215 @@ +/* crypto/ecdh/ech_ossl.c */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * The Elliptic Curve Public-Key Crypto Library (ECC Code) included + * herein is developed by SUN MICROSYSTEMS, INC., and is contributed + * to the OpenSSL project. + * + * The ECC Code is licensed pursuant to the OpenSSL open source + * license provided below. + * + * The ECDH software is originally written by Douglas Stebila of + * Sun Microsystems Laboratories. + * + */ +/* ==================================================================== + * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + + +#include +#include + +#include "cryptlib.h" + +#include "ech_locl.h" +#include +#include +#include +#include + +static int ecdh_compute_key(void *out, size_t len, const EC_POINT *pub_key, + EC_KEY *ecdh, + void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)); + +static ECDH_METHOD openssl_ecdh_meth = { + "OpenSSL ECDH method", + ecdh_compute_key, +#if 0 + NULL, /* init */ + NULL, /* finish */ +#endif + 0, /* flags */ + NULL /* app_data */ +}; + +const ECDH_METHOD *ECDH_OpenSSL(void) + { + return &openssl_ecdh_meth; + } + + +/* This implementation is based on the following primitives in the IEEE 1363 standard: + * - ECKAS-DH1 + * - ECSVDP-DH + * Finally an optional KDF is applied. + */ +static int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, + EC_KEY *ecdh, + void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)) + { + BN_CTX *ctx; + EC_POINT *tmp=NULL; + BIGNUM *x=NULL, *y=NULL; + const BIGNUM *priv_key; + const EC_GROUP* group; + int ret= -1; + size_t buflen, len; + unsigned char *buf=NULL; + + if (outlen > INT_MAX) + { + ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ERR_R_MALLOC_FAILURE); /* sort of, anyway */ + return -1; + } + + if ((ctx = BN_CTX_new()) == NULL) goto err; + BN_CTX_start(ctx); + x = BN_CTX_get(ctx); + y = BN_CTX_get(ctx); + + priv_key = EC_KEY_get0_private_key(ecdh); + if (priv_key == NULL) + { + ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ECDH_R_NO_PRIVATE_VALUE); + goto err; + } + + group = EC_KEY_get0_group(ecdh); + if ((tmp=EC_POINT_new(group)) == NULL) + { + ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ERR_R_MALLOC_FAILURE); + goto err; + } + + if (!EC_POINT_mul(group, tmp, NULL, pub_key, priv_key, ctx)) + { + ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ECDH_R_POINT_ARITHMETIC_FAILURE); + goto err; + } + + if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) == NID_X9_62_prime_field) + { + if (!EC_POINT_get_affine_coordinates_GFp(group, tmp, x, y, ctx)) + { + ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ECDH_R_POINT_ARITHMETIC_FAILURE); + goto err; + } + } +#ifndef OPENSSL_NO_EC2M + else + { + if (!EC_POINT_get_affine_coordinates_GF2m(group, tmp, x, y, ctx)) + { + ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ECDH_R_POINT_ARITHMETIC_FAILURE); + goto err; + } + } +#endif + + buflen = (EC_GROUP_get_degree(group) + 7)/8; + len = BN_num_bytes(x); + if (len > buflen) + { + ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ERR_R_INTERNAL_ERROR); + goto err; + } + if ((buf = OPENSSL_malloc(buflen)) == NULL) + { + ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ERR_R_MALLOC_FAILURE); + goto err; + } + + memset(buf, 0, buflen - len); + if (len != (size_t)BN_bn2bin(x, buf + buflen - len)) + { + ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ERR_R_BN_LIB); + goto err; + } + + if (KDF != 0) + { + if (KDF(buf, buflen, out, &outlen) == NULL) + { + ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ECDH_R_KDF_FAILED); + goto err; + } + ret = outlen; + } + else + { + /* no KDF, just copy as much as we can */ + if (outlen > buflen) + outlen = buflen; + memcpy(out, buf, outlen); + ret = outlen; + } + +err: + if (tmp) EC_POINT_free(tmp); + if (ctx) BN_CTX_end(ctx); + if (ctx) BN_CTX_free(ctx); + if (buf) OPENSSL_free(buf); + return(ret); + } diff --git a/libs/openssl/crypto/ecdsa/ecdsa.h b/libs/openssl/crypto/ecdsa/ecdsa.h new file mode 100644 index 00000000..7fb5254b --- /dev/null +++ b/libs/openssl/crypto/ecdsa/ecdsa.h @@ -0,0 +1,260 @@ +/* crypto/ecdsa/ecdsa.h */ +/** + * \file crypto/ecdsa/ecdsa.h Include file for the OpenSSL ECDSA functions + * \author Written by Nils Larsch for the OpenSSL project + */ +/* ==================================================================== + * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +#ifndef HEADER_ECDSA_H +#define HEADER_ECDSA_H + +#include + +#ifdef OPENSSL_NO_ECDSA +#error ECDSA is disabled. +#endif + +#include +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ECDSA_SIG_st + { + BIGNUM *r; + BIGNUM *s; + } ECDSA_SIG; + +/** Allocates and initialize a ECDSA_SIG structure + * \return pointer to a ECDSA_SIG structure or NULL if an error occurred + */ +ECDSA_SIG *ECDSA_SIG_new(void); + +/** frees a ECDSA_SIG structure + * \param sig pointer to the ECDSA_SIG structure + */ +void ECDSA_SIG_free(ECDSA_SIG *sig); + +/** DER encode content of ECDSA_SIG object (note: this function modifies *pp + * (*pp += length of the DER encoded signature)). + * \param sig pointer to the ECDSA_SIG object + * \param pp pointer to a unsigned char pointer for the output or NULL + * \return the length of the DER encoded ECDSA_SIG object or 0 + */ +int i2d_ECDSA_SIG(const ECDSA_SIG *sig, unsigned char **pp); + +/** Decodes a DER encoded ECDSA signature (note: this function changes *pp + * (*pp += len)). + * \param sig pointer to ECDSA_SIG pointer (may be NULL) + * \param pp memory buffer with the DER encoded signature + * \param len length of the buffer + * \return pointer to the decoded ECDSA_SIG structure (or NULL) + */ +ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **sig, const unsigned char **pp, long len); + +/** Computes the ECDSA signature of the given hash value using + * the supplied private key and returns the created signature. + * \param dgst pointer to the hash value + * \param dgst_len length of the hash value + * \param eckey EC_KEY object containing a private EC key + * \return pointer to a ECDSA_SIG structure or NULL if an error occurred + */ +ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst,int dgst_len,EC_KEY *eckey); + +/** Computes ECDSA signature of a given hash value using the supplied + * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). + * \param dgst pointer to the hash value to sign + * \param dgstlen length of the hash value + * \param kinv BIGNUM with a pre-computed inverse k (optional) + * \param rp BIGNUM with a pre-computed rp value (optioanl), + * see ECDSA_sign_setup + * \param eckey EC_KEY object containing a private EC key + * \return pointer to a ECDSA_SIG structure or NULL if an error occurred + */ +ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen, + const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey); + +/** Verifies that the supplied signature is a valid ECDSA + * signature of the supplied hash value using the supplied public key. + * \param dgst pointer to the hash value + * \param dgst_len length of the hash value + * \param sig ECDSA_SIG structure + * \param eckey EC_KEY object containing a public EC key + * \return 1 if the signature is valid, 0 if the signature is invalid + * and -1 on error + */ +int ECDSA_do_verify(const unsigned char *dgst, int dgst_len, + const ECDSA_SIG *sig, EC_KEY* eckey); + +const ECDSA_METHOD *ECDSA_OpenSSL(void); + +/** Sets the default ECDSA method + * \param meth new default ECDSA_METHOD + */ +void ECDSA_set_default_method(const ECDSA_METHOD *meth); + +/** Returns the default ECDSA method + * \return pointer to ECDSA_METHOD structure containing the default method + */ +const ECDSA_METHOD *ECDSA_get_default_method(void); + +/** Sets method to be used for the ECDSA operations + * \param eckey EC_KEY object + * \param meth new method + * \return 1 on success and 0 otherwise + */ +int ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth); + +/** Returns the maximum length of the DER encoded signature + * \param eckey EC_KEY object + * \return numbers of bytes required for the DER encoded signature + */ +int ECDSA_size(const EC_KEY *eckey); + +/** Precompute parts of the signing operation + * \param eckey EC_KEY object containing a private EC key + * \param ctx BN_CTX object (optional) + * \param kinv BIGNUM pointer for the inverse of k + * \param rp BIGNUM pointer for x coordinate of k * generator + * \return 1 on success and 0 otherwise + */ +int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, + BIGNUM **rp); + +/** Computes ECDSA signature of a given hash value using the supplied + * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). + * \param type this parameter is ignored + * \param dgst pointer to the hash value to sign + * \param dgstlen length of the hash value + * \param sig memory for the DER encoded created signature + * \param siglen pointer to the length of the returned signature + * \param eckey EC_KEY object containing a private EC key + * \return 1 on success and 0 otherwise + */ +int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen, + unsigned char *sig, unsigned int *siglen, EC_KEY *eckey); + + +/** Computes ECDSA signature of a given hash value using the supplied + * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). + * \param type this parameter is ignored + * \param dgst pointer to the hash value to sign + * \param dgstlen length of the hash value + * \param sig buffer to hold the DER encoded signature + * \param siglen pointer to the length of the returned signature + * \param kinv BIGNUM with a pre-computed inverse k (optional) + * \param rp BIGNUM with a pre-computed rp value (optioanl), + * see ECDSA_sign_setup + * \param eckey EC_KEY object containing a private EC key + * \return 1 on success and 0 otherwise + */ +int ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen, + unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv, + const BIGNUM *rp, EC_KEY *eckey); + +/** Verifies that the given signature is valid ECDSA signature + * of the supplied hash value using the specified public key. + * \param type this parameter is ignored + * \param dgst pointer to the hash value + * \param dgstlen length of the hash value + * \param sig pointer to the DER encoded signature + * \param siglen length of the DER encoded signature + * \param eckey EC_KEY object containing a public EC key + * \return 1 if the signature is valid, 0 if the signature is invalid + * and -1 on error + */ +int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen, + const unsigned char *sig, int siglen, EC_KEY *eckey); + +/* the standard ex_data functions */ +int ECDSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new + *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int ECDSA_set_ex_data(EC_KEY *d, int idx, void *arg); +void *ECDSA_get_ex_data(EC_KEY *d, int idx); + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_ECDSA_strings(void); + +/* Error codes for the ECDSA functions. */ + +/* Function codes. */ +#define ECDSA_F_ECDSA_CHECK 104 +#define ECDSA_F_ECDSA_DATA_NEW_METHOD 100 +#define ECDSA_F_ECDSA_DO_SIGN 101 +#define ECDSA_F_ECDSA_DO_VERIFY 102 +#define ECDSA_F_ECDSA_SIGN_SETUP 103 + +/* Reason codes. */ +#define ECDSA_R_BAD_SIGNATURE 100 +#define ECDSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 101 +#define ECDSA_R_ERR_EC_LIB 102 +#define ECDSA_R_MISSING_PARAMETERS 103 +#define ECDSA_R_NEED_NEW_SETUP_VALUES 106 +#define ECDSA_R_NON_FIPS_METHOD 107 +#define ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED 104 +#define ECDSA_R_SIGNATURE_MALLOC_FAILED 105 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libs/openssl/crypto/ecdsa/ecs_asn1.c b/libs/openssl/crypto/ecdsa/ecs_asn1.c new file mode 100644 index 00000000..b2954894 --- /dev/null +++ b/libs/openssl/crypto/ecdsa/ecs_asn1.c @@ -0,0 +1,67 @@ +/* crypto/ecdsa/ecs_asn1.c */ +/* ==================================================================== + * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include "ecs_locl.h" +#include +#include + +ASN1_SEQUENCE(ECDSA_SIG) = { + ASN1_SIMPLE(ECDSA_SIG, r, CBIGNUM), + ASN1_SIMPLE(ECDSA_SIG, s, CBIGNUM) +} ASN1_SEQUENCE_END(ECDSA_SIG) + +DECLARE_ASN1_FUNCTIONS_const(ECDSA_SIG) +DECLARE_ASN1_ENCODE_FUNCTIONS_const(ECDSA_SIG, ECDSA_SIG) +IMPLEMENT_ASN1_FUNCTIONS_const(ECDSA_SIG) diff --git a/libs/openssl/crypto/ecdsa/ecs_err.c b/libs/openssl/crypto/ecdsa/ecs_err.c new file mode 100644 index 00000000..81542e6d --- /dev/null +++ b/libs/openssl/crypto/ecdsa/ecs_err.c @@ -0,0 +1,106 @@ +/* crypto/ecdsa/ecs_err.c */ +/* ==================================================================== + * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +/* NOTE: this file was auto generated by the mkerr.pl script: any changes + * made to it will be overwritten when the script next updates this file, + * only reason strings will be preserved. + */ + +#include +#include +#include + +/* BEGIN ERROR CODES */ +#ifndef OPENSSL_NO_ERR + +#define ERR_FUNC(func) ERR_PACK(ERR_LIB_ECDSA,func,0) +#define ERR_REASON(reason) ERR_PACK(ERR_LIB_ECDSA,0,reason) + +static ERR_STRING_DATA ECDSA_str_functs[]= + { +{ERR_FUNC(ECDSA_F_ECDSA_CHECK), "ECDSA_CHECK"}, +{ERR_FUNC(ECDSA_F_ECDSA_DATA_NEW_METHOD), "ECDSA_DATA_NEW_METHOD"}, +{ERR_FUNC(ECDSA_F_ECDSA_DO_SIGN), "ECDSA_do_sign"}, +{ERR_FUNC(ECDSA_F_ECDSA_DO_VERIFY), "ECDSA_do_verify"}, +{ERR_FUNC(ECDSA_F_ECDSA_SIGN_SETUP), "ECDSA_sign_setup"}, +{0,NULL} + }; + +static ERR_STRING_DATA ECDSA_str_reasons[]= + { +{ERR_REASON(ECDSA_R_BAD_SIGNATURE) ,"bad signature"}, +{ERR_REASON(ECDSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE),"data too large for key size"}, +{ERR_REASON(ECDSA_R_ERR_EC_LIB) ,"err ec lib"}, +{ERR_REASON(ECDSA_R_MISSING_PARAMETERS) ,"missing parameters"}, +{ERR_REASON(ECDSA_R_NEED_NEW_SETUP_VALUES),"need new setup values"}, +{ERR_REASON(ECDSA_R_NON_FIPS_METHOD) ,"non fips method"}, +{ERR_REASON(ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED),"random number generation failed"}, +{ERR_REASON(ECDSA_R_SIGNATURE_MALLOC_FAILED),"signature malloc failed"}, +{0,NULL} + }; + +#endif + +void ERR_load_ECDSA_strings(void) + { +#ifndef OPENSSL_NO_ERR + + if (ERR_func_error_string(ECDSA_str_functs[0].error) == NULL) + { + ERR_load_strings(0,ECDSA_str_functs); + ERR_load_strings(0,ECDSA_str_reasons); + } +#endif + } diff --git a/libs/openssl/crypto/ecdsa/ecs_lib.c b/libs/openssl/crypto/ecdsa/ecs_lib.c new file mode 100644 index 00000000..814a6bf4 --- /dev/null +++ b/libs/openssl/crypto/ecdsa/ecs_lib.c @@ -0,0 +1,285 @@ +/* crypto/ecdsa/ecs_lib.c */ +/* ==================================================================== + * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include +#include "ecs_locl.h" +#ifndef OPENSSL_NO_ENGINE +#include +#endif +#include +#include +#ifdef OPENSSL_FIPS +#include +#endif + +const char ECDSA_version[]="ECDSA" OPENSSL_VERSION_PTEXT; + +static const ECDSA_METHOD *default_ECDSA_method = NULL; + +static void *ecdsa_data_new(void); +static void *ecdsa_data_dup(void *); +static void ecdsa_data_free(void *); + +void ECDSA_set_default_method(const ECDSA_METHOD *meth) +{ + default_ECDSA_method = meth; +} + +const ECDSA_METHOD *ECDSA_get_default_method(void) +{ + if(!default_ECDSA_method) + { +#ifdef OPENSSL_FIPS + if (FIPS_mode()) + return FIPS_ecdsa_openssl(); + else + return ECDSA_OpenSSL(); +#else + default_ECDSA_method = ECDSA_OpenSSL(); +#endif + } + return default_ECDSA_method; +} + +int ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth) +{ + ECDSA_DATA *ecdsa; + + ecdsa = ecdsa_check(eckey); + + if (ecdsa == NULL) + return 0; + +#ifndef OPENSSL_NO_ENGINE + if (ecdsa->engine) + { + ENGINE_finish(ecdsa->engine); + ecdsa->engine = NULL; + } +#endif + ecdsa->meth = meth; + + return 1; +} + +static ECDSA_DATA *ECDSA_DATA_new_method(ENGINE *engine) +{ + ECDSA_DATA *ret; + + ret=(ECDSA_DATA *)OPENSSL_malloc(sizeof(ECDSA_DATA)); + if (ret == NULL) + { + ECDSAerr(ECDSA_F_ECDSA_DATA_NEW_METHOD, ERR_R_MALLOC_FAILURE); + return(NULL); + } + + ret->init = NULL; + + ret->meth = ECDSA_get_default_method(); + ret->engine = engine; +#ifndef OPENSSL_NO_ENGINE + if (!ret->engine) + ret->engine = ENGINE_get_default_ECDSA(); + if (ret->engine) + { + ret->meth = ENGINE_get_ECDSA(ret->engine); + if (!ret->meth) + { + ECDSAerr(ECDSA_F_ECDSA_DATA_NEW_METHOD, ERR_R_ENGINE_LIB); + ENGINE_finish(ret->engine); + OPENSSL_free(ret); + return NULL; + } + } +#endif + + ret->flags = ret->meth->flags; + CRYPTO_new_ex_data(CRYPTO_EX_INDEX_ECDSA, ret, &ret->ex_data); +#if 0 + if ((ret->meth->init != NULL) && !ret->meth->init(ret)) + { + CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ECDSA, ret, &ret->ex_data); + OPENSSL_free(ret); + ret=NULL; + } +#endif + return(ret); +} + +static void *ecdsa_data_new(void) +{ + return (void *)ECDSA_DATA_new_method(NULL); +} + +static void *ecdsa_data_dup(void *data) +{ + ECDSA_DATA *r = (ECDSA_DATA *)data; + + /* XXX: dummy operation */ + if (r == NULL) + return NULL; + + return ecdsa_data_new(); +} + +static void ecdsa_data_free(void *data) +{ + ECDSA_DATA *r = (ECDSA_DATA *)data; + +#ifndef OPENSSL_NO_ENGINE + if (r->engine) + ENGINE_finish(r->engine); +#endif + CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ECDSA, r, &r->ex_data); + + OPENSSL_cleanse((void *)r, sizeof(ECDSA_DATA)); + + OPENSSL_free(r); +} + +ECDSA_DATA *ecdsa_check(EC_KEY *key) +{ + ECDSA_DATA *ecdsa_data; + + void *data = EC_KEY_get_key_method_data(key, ecdsa_data_dup, + ecdsa_data_free, ecdsa_data_free); + if (data == NULL) + { + ecdsa_data = (ECDSA_DATA *)ecdsa_data_new(); + if (ecdsa_data == NULL) + return NULL; + data = EC_KEY_insert_key_method_data(key, (void *)ecdsa_data, + ecdsa_data_dup, ecdsa_data_free, ecdsa_data_free); + if (data != NULL) + { + /* Another thread raced us to install the key_method + * data and won. */ + ecdsa_data_free(ecdsa_data); + ecdsa_data = (ECDSA_DATA *)data; + } + } + else + ecdsa_data = (ECDSA_DATA *)data; +#ifdef OPENSSL_FIPS + if (FIPS_mode() && !(ecdsa_data->flags & ECDSA_FLAG_FIPS_METHOD) + && !(EC_KEY_get_flags(key) & EC_FLAG_NON_FIPS_ALLOW)) + { + ECDSAerr(ECDSA_F_ECDSA_CHECK, ECDSA_R_NON_FIPS_METHOD); + return NULL; + } +#endif + + return ecdsa_data; +} + +int ECDSA_size(const EC_KEY *r) +{ + int ret,i; + ASN1_INTEGER bs; + BIGNUM *order=NULL; + unsigned char buf[4]; + const EC_GROUP *group; + + if (r == NULL) + return 0; + group = EC_KEY_get0_group(r); + if (group == NULL) + return 0; + + if ((order = BN_new()) == NULL) return 0; + if (!EC_GROUP_get_order(group,order,NULL)) + { + BN_clear_free(order); + return 0; + } + i=BN_num_bits(order); + bs.length=(i+7)/8; + bs.data=buf; + bs.type=V_ASN1_INTEGER; + /* If the top bit is set the asn1 encoding is 1 larger. */ + buf[0]=0xff; + + i=i2d_ASN1_INTEGER(&bs,NULL); + i+=i; /* r and s */ + ret=ASN1_object_size(1,i,V_ASN1_SEQUENCE); + BN_clear_free(order); + return(ret); +} + + +int ECDSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) +{ + return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_ECDSA, argl, argp, + new_func, dup_func, free_func); +} + +int ECDSA_set_ex_data(EC_KEY *d, int idx, void *arg) +{ + ECDSA_DATA *ecdsa; + ecdsa = ecdsa_check(d); + if (ecdsa == NULL) + return 0; + return(CRYPTO_set_ex_data(&ecdsa->ex_data,idx,arg)); +} + +void *ECDSA_get_ex_data(EC_KEY *d, int idx) +{ + ECDSA_DATA *ecdsa; + ecdsa = ecdsa_check(d); + if (ecdsa == NULL) + return NULL; + return(CRYPTO_get_ex_data(&ecdsa->ex_data,idx)); +} diff --git a/libs/openssl/crypto/ecdsa/ecs_locl.h b/libs/openssl/crypto/ecdsa/ecs_locl.h new file mode 100644 index 00000000..cb3be13c --- /dev/null +++ b/libs/openssl/crypto/ecdsa/ecs_locl.h @@ -0,0 +1,115 @@ +/* crypto/ecdsa/ecs_locl.h */ +/* + * Written by Nils Larsch for the OpenSSL project + */ +/* ==================================================================== + * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_ECS_LOCL_H +#define HEADER_ECS_LOCL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct ecdsa_method + { + const char *name; + ECDSA_SIG *(*ecdsa_do_sign)(const unsigned char *dgst, int dgst_len, + const BIGNUM *inv, const BIGNUM *rp, EC_KEY *eckey); + int (*ecdsa_sign_setup)(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, + BIGNUM **r); + int (*ecdsa_do_verify)(const unsigned char *dgst, int dgst_len, + const ECDSA_SIG *sig, EC_KEY *eckey); +#if 0 + int (*init)(EC_KEY *eckey); + int (*finish)(EC_KEY *eckey); +#endif + int flags; + char *app_data; + }; + +/* If this flag is set the ECDSA method is FIPS compliant and can be used + * in FIPS mode. This is set in the validated module method. If an + * application sets this flag in its own methods it is its responsibility + * to ensure the result is compliant. + */ + +#define ECDSA_FLAG_FIPS_METHOD 0x1 + +typedef struct ecdsa_data_st { + /* EC_KEY_METH_DATA part */ + int (*init)(EC_KEY *); + /* method (ECDSA) specific part */ + ENGINE *engine; + int flags; + const ECDSA_METHOD *meth; + CRYPTO_EX_DATA ex_data; +} ECDSA_DATA; + +/** ecdsa_check + * checks whether ECKEY->meth_data is a pointer to a ECDSA_DATA structure + * and if not it removes the old meth_data and creates a ECDSA_DATA structure. + * \param eckey pointer to a EC_KEY object + * \return pointer to a ECDSA_DATA structure + */ +ECDSA_DATA *ecdsa_check(EC_KEY *eckey); + +#ifdef __cplusplus +} +#endif + +#endif /* HEADER_ECS_LOCL_H */ diff --git a/libs/openssl/crypto/ecdsa/ecs_ossl.c b/libs/openssl/crypto/ecdsa/ecs_ossl.c new file mode 100644 index 00000000..77259356 --- /dev/null +++ b/libs/openssl/crypto/ecdsa/ecs_ossl.c @@ -0,0 +1,483 @@ +/* crypto/ecdsa/ecs_ossl.c */ +/* + * Written by Nils Larsch for the OpenSSL project + */ +/* ==================================================================== + * Copyright (c) 1998-2004 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include "ecs_locl.h" +#include +#include +#include + +static ECDSA_SIG *ecdsa_do_sign(const unsigned char *dgst, int dlen, + const BIGNUM *, const BIGNUM *, EC_KEY *eckey); +static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, + BIGNUM **rp); +static int ecdsa_do_verify(const unsigned char *dgst, int dgst_len, + const ECDSA_SIG *sig, EC_KEY *eckey); + +static ECDSA_METHOD openssl_ecdsa_meth = { + "OpenSSL ECDSA method", + ecdsa_do_sign, + ecdsa_sign_setup, + ecdsa_do_verify, +#if 0 + NULL, /* init */ + NULL, /* finish */ +#endif + 0, /* flags */ + NULL /* app_data */ +}; + +const ECDSA_METHOD *ECDSA_OpenSSL(void) +{ + return &openssl_ecdsa_meth; +} + +static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, + BIGNUM **rp) +{ + BN_CTX *ctx = NULL; + BIGNUM *k = NULL, *r = NULL, *order = NULL, *X = NULL; + EC_POINT *tmp_point=NULL; + const EC_GROUP *group; + int ret = 0; + + if (eckey == NULL || (group = EC_KEY_get0_group(eckey)) == NULL) + { + ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_PASSED_NULL_PARAMETER); + return 0; + } + + if (ctx_in == NULL) + { + if ((ctx = BN_CTX_new()) == NULL) + { + ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP,ERR_R_MALLOC_FAILURE); + return 0; + } + } + else + ctx = ctx_in; + + k = BN_new(); /* this value is later returned in *kinvp */ + r = BN_new(); /* this value is later returned in *rp */ + order = BN_new(); + X = BN_new(); + if (!k || !r || !order || !X) + { + ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_MALLOC_FAILURE); + goto err; + } + if ((tmp_point = EC_POINT_new(group)) == NULL) + { + ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB); + goto err; + } + if (!EC_GROUP_get_order(group, order, ctx)) + { + ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB); + goto err; + } + + do + { + /* get random k */ + do + if (!BN_rand_range(k, order)) + { + ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, + ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED); + goto err; + } + while (BN_is_zero(k)); + + /* We do not want timing information to leak the length of k, + * so we compute G*k using an equivalent scalar of fixed + * bit-length. */ + + if (!BN_add(k, k, order)) goto err; + if (BN_num_bits(k) <= BN_num_bits(order)) + if (!BN_add(k, k, order)) goto err; + + /* compute r the x-coordinate of generator * k */ + if (!EC_POINT_mul(group, tmp_point, k, NULL, NULL, ctx)) + { + ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB); + goto err; + } + if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) == NID_X9_62_prime_field) + { + if (!EC_POINT_get_affine_coordinates_GFp(group, + tmp_point, X, NULL, ctx)) + { + ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP,ERR_R_EC_LIB); + goto err; + } + } +#ifndef OPENSSL_NO_EC2M + else /* NID_X9_62_characteristic_two_field */ + { + if (!EC_POINT_get_affine_coordinates_GF2m(group, + tmp_point, X, NULL, ctx)) + { + ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP,ERR_R_EC_LIB); + goto err; + } + } +#endif + if (!BN_nnmod(r, X, order, ctx)) + { + ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB); + goto err; + } + } + while (BN_is_zero(r)); + + /* compute the inverse of k */ + if (!BN_mod_inverse(k, k, order, ctx)) + { + ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB); + goto err; + } + /* clear old values if necessary */ + if (*rp != NULL) + BN_clear_free(*rp); + if (*kinvp != NULL) + BN_clear_free(*kinvp); + /* save the pre-computed values */ + *rp = r; + *kinvp = k; + ret = 1; +err: + if (!ret) + { + if (k != NULL) BN_clear_free(k); + if (r != NULL) BN_clear_free(r); + } + if (ctx_in == NULL) + BN_CTX_free(ctx); + if (order != NULL) + BN_free(order); + if (tmp_point != NULL) + EC_POINT_free(tmp_point); + if (X) + BN_clear_free(X); + return(ret); +} + + +static ECDSA_SIG *ecdsa_do_sign(const unsigned char *dgst, int dgst_len, + const BIGNUM *in_kinv, const BIGNUM *in_r, EC_KEY *eckey) +{ + int ok = 0, i; + BIGNUM *kinv=NULL, *s, *m=NULL,*tmp=NULL,*order=NULL; + const BIGNUM *ckinv; + BN_CTX *ctx = NULL; + const EC_GROUP *group; + ECDSA_SIG *ret; + ECDSA_DATA *ecdsa; + const BIGNUM *priv_key; + + ecdsa = ecdsa_check(eckey); + group = EC_KEY_get0_group(eckey); + priv_key = EC_KEY_get0_private_key(eckey); + + if (group == NULL || priv_key == NULL || ecdsa == NULL) + { + ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_PASSED_NULL_PARAMETER); + return NULL; + } + + ret = ECDSA_SIG_new(); + if (!ret) + { + ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_MALLOC_FAILURE); + return NULL; + } + s = ret->s; + + if ((ctx = BN_CTX_new()) == NULL || (order = BN_new()) == NULL || + (tmp = BN_new()) == NULL || (m = BN_new()) == NULL) + { + ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_MALLOC_FAILURE); + goto err; + } + + if (!EC_GROUP_get_order(group, order, ctx)) + { + ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_EC_LIB); + goto err; + } + i = BN_num_bits(order); + /* Need to truncate digest if it is too long: first truncate whole + * bytes. + */ + if (8 * dgst_len > i) + dgst_len = (i + 7)/8; + if (!BN_bin2bn(dgst, dgst_len, m)) + { + ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_BN_LIB); + goto err; + } + /* If still too long truncate remaining bits with a shift */ + if ((8 * dgst_len > i) && !BN_rshift(m, m, 8 - (i & 0x7))) + { + ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_BN_LIB); + goto err; + } + do + { + if (in_kinv == NULL || in_r == NULL) + { + if (!ECDSA_sign_setup(eckey, ctx, &kinv, &ret->r)) + { + ECDSAerr(ECDSA_F_ECDSA_DO_SIGN,ERR_R_ECDSA_LIB); + goto err; + } + ckinv = kinv; + } + else + { + ckinv = in_kinv; + if (BN_copy(ret->r, in_r) == NULL) + { + ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_MALLOC_FAILURE); + goto err; + } + } + + if (!BN_mod_mul(tmp, priv_key, ret->r, order, ctx)) + { + ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_BN_LIB); + goto err; + } + if (!BN_mod_add_quick(s, tmp, m, order)) + { + ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_BN_LIB); + goto err; + } + if (!BN_mod_mul(s, s, ckinv, order, ctx)) + { + ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_BN_LIB); + goto err; + } + if (BN_is_zero(s)) + { + /* if kinv and r have been supplied by the caller + * don't to generate new kinv and r values */ + if (in_kinv != NULL && in_r != NULL) + { + ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ECDSA_R_NEED_NEW_SETUP_VALUES); + goto err; + } + } + else + /* s != 0 => we have a valid signature */ + break; + } + while (1); + + ok = 1; +err: + if (!ok) + { + ECDSA_SIG_free(ret); + ret = NULL; + } + if (ctx) + BN_CTX_free(ctx); + if (m) + BN_clear_free(m); + if (tmp) + BN_clear_free(tmp); + if (order) + BN_free(order); + if (kinv) + BN_clear_free(kinv); + return ret; +} + +static int ecdsa_do_verify(const unsigned char *dgst, int dgst_len, + const ECDSA_SIG *sig, EC_KEY *eckey) +{ + int ret = -1, i; + BN_CTX *ctx; + BIGNUM *order, *u1, *u2, *m, *X; + EC_POINT *point = NULL; + const EC_GROUP *group; + const EC_POINT *pub_key; + + /* check input values */ + if (eckey == NULL || (group = EC_KEY_get0_group(eckey)) == NULL || + (pub_key = EC_KEY_get0_public_key(eckey)) == NULL || sig == NULL) + { + ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ECDSA_R_MISSING_PARAMETERS); + return -1; + } + + ctx = BN_CTX_new(); + if (!ctx) + { + ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_MALLOC_FAILURE); + return -1; + } + BN_CTX_start(ctx); + order = BN_CTX_get(ctx); + u1 = BN_CTX_get(ctx); + u2 = BN_CTX_get(ctx); + m = BN_CTX_get(ctx); + X = BN_CTX_get(ctx); + if (!X) + { + ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB); + goto err; + } + + if (!EC_GROUP_get_order(group, order, ctx)) + { + ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_EC_LIB); + goto err; + } + + if (BN_is_zero(sig->r) || BN_is_negative(sig->r) || + BN_ucmp(sig->r, order) >= 0 || BN_is_zero(sig->s) || + BN_is_negative(sig->s) || BN_ucmp(sig->s, order) >= 0) + { + ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ECDSA_R_BAD_SIGNATURE); + ret = 0; /* signature is invalid */ + goto err; + } + /* calculate tmp1 = inv(S) mod order */ + if (!BN_mod_inverse(u2, sig->s, order, ctx)) + { + ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB); + goto err; + } + /* digest -> m */ + i = BN_num_bits(order); + /* Need to truncate digest if it is too long: first truncate whole + * bytes. + */ + if (8 * dgst_len > i) + dgst_len = (i + 7)/8; + if (!BN_bin2bn(dgst, dgst_len, m)) + { + ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB); + goto err; + } + /* If still too long truncate remaining bits with a shift */ + if ((8 * dgst_len > i) && !BN_rshift(m, m, 8 - (i & 0x7))) + { + ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB); + goto err; + } + /* u1 = m * tmp mod order */ + if (!BN_mod_mul(u1, m, u2, order, ctx)) + { + ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB); + goto err; + } + /* u2 = r * w mod q */ + if (!BN_mod_mul(u2, sig->r, u2, order, ctx)) + { + ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB); + goto err; + } + + if ((point = EC_POINT_new(group)) == NULL) + { + ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_MALLOC_FAILURE); + goto err; + } + if (!EC_POINT_mul(group, point, u1, pub_key, u2, ctx)) + { + ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_EC_LIB); + goto err; + } + if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) == NID_X9_62_prime_field) + { + if (!EC_POINT_get_affine_coordinates_GFp(group, + point, X, NULL, ctx)) + { + ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_EC_LIB); + goto err; + } + } +#ifndef OPENSSL_NO_EC2M + else /* NID_X9_62_characteristic_two_field */ + { + if (!EC_POINT_get_affine_coordinates_GF2m(group, + point, X, NULL, ctx)) + { + ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_EC_LIB); + goto err; + } + } +#endif + if (!BN_nnmod(u1, X, order, ctx)) + { + ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB); + goto err; + } + /* if the signature is correct u1 is equal to sig->r */ + ret = (BN_ucmp(u1, sig->r) == 0); +err: + BN_CTX_end(ctx); + BN_CTX_free(ctx); + if (point) + EC_POINT_free(point); + return ret; +} diff --git a/libs/openssl/crypto/ecdsa/ecs_sign.c b/libs/openssl/crypto/ecdsa/ecs_sign.c new file mode 100644 index 00000000..353d5af5 --- /dev/null +++ b/libs/openssl/crypto/ecdsa/ecs_sign.c @@ -0,0 +1,106 @@ +/* crypto/ecdsa/ecdsa_sign.c */ +/* ==================================================================== + * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include "ecs_locl.h" +#ifndef OPENSSL_NO_ENGINE +#include +#endif +#include + +ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) +{ + return ECDSA_do_sign_ex(dgst, dlen, NULL, NULL, eckey); +} + +ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dlen, + const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey) +{ + ECDSA_DATA *ecdsa = ecdsa_check(eckey); + if (ecdsa == NULL) + return NULL; + return ecdsa->meth->ecdsa_do_sign(dgst, dlen, kinv, rp, eckey); +} + +int ECDSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char + *sig, unsigned int *siglen, EC_KEY *eckey) +{ + return ECDSA_sign_ex(type, dgst, dlen, sig, siglen, NULL, NULL, eckey); +} + +int ECDSA_sign_ex(int type, const unsigned char *dgst, int dlen, unsigned char + *sig, unsigned int *siglen, const BIGNUM *kinv, const BIGNUM *r, + EC_KEY *eckey) +{ + ECDSA_SIG *s; + RAND_seed(dgst, dlen); + s = ECDSA_do_sign_ex(dgst, dlen, kinv, r, eckey); + if (s == NULL) + { + *siglen=0; + return 0; + } + *siglen = i2d_ECDSA_SIG(s, &sig); + ECDSA_SIG_free(s); + return 1; +} + +int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, + BIGNUM **rp) +{ + ECDSA_DATA *ecdsa = ecdsa_check(eckey); + if (ecdsa == NULL) + return 0; + return ecdsa->meth->ecdsa_sign_setup(eckey, ctx_in, kinvp, rp); +} diff --git a/libs/openssl/crypto/ecdsa/ecs_vrf.c b/libs/openssl/crypto/ecdsa/ecs_vrf.c new file mode 100644 index 00000000..ef9acf7b --- /dev/null +++ b/libs/openssl/crypto/ecdsa/ecs_vrf.c @@ -0,0 +1,96 @@ +/* crypto/ecdsa/ecdsa_vrf.c */ +/* + * Written by Nils Larsch for the OpenSSL project + */ +/* ==================================================================== + * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include "ecs_locl.h" +#ifndef OPENSSL_NO_ENGINE +#include +#endif + +/* returns + * 1: correct signature + * 0: incorrect signature + * -1: error + */ +int ECDSA_do_verify(const unsigned char *dgst, int dgst_len, + const ECDSA_SIG *sig, EC_KEY *eckey) + { + ECDSA_DATA *ecdsa = ecdsa_check(eckey); + if (ecdsa == NULL) + return 0; + return ecdsa->meth->ecdsa_do_verify(dgst, dgst_len, sig, eckey); + } + +/* returns + * 1: correct signature + * 0: incorrect signature + * -1: error + */ +int ECDSA_verify(int type, const unsigned char *dgst, int dgst_len, + const unsigned char *sigbuf, int sig_len, EC_KEY *eckey) + { + ECDSA_SIG *s; + int ret=-1; + + s = ECDSA_SIG_new(); + if (s == NULL) return(ret); + if (d2i_ECDSA_SIG(&s, &sigbuf, sig_len) == NULL) goto err; + ret=ECDSA_do_verify(dgst, dgst_len, s, eckey); +err: + ECDSA_SIG_free(s); + return(ret); + } diff --git a/libs/zlib/Makefile.bcb b/libs/zlib/Makefile.bcb deleted file mode 100644 index 4986f83f..00000000 --- a/libs/zlib/Makefile.bcb +++ /dev/null @@ -1,118 +0,0 @@ -# Set your compiler options -CC=bcc32 -CFLAG=-DWIN32 -DWIN32_LEAN_AND_MEAN -q -w-ccc -w-rch -w-pia -w-aus -w-par -w-inl -w-eff -w-sus -w-dup -w-spa -w-csu -w-rvl -c -tWC -tWM -D_stricmp=stricmp -D_strnicmp=strnicmp -O2 -ff -fp -DNE_HAVE_SSL;HAVE_OPENSSL;HAVE_EXPAT;HAVE_EXPAT_H;NE_HAVE_DAV;NE_HAVE_ZLIB;USE_GETADDRINFO;NOUSER;NOGDI;COMPILED_FROM_DSP;XML_STATIC;_RTLDLL; -D__STDC__ -LIB_CFLAG= - -# zlib directory -SRC_D=. - -# The output directory for everything intersting -OUT_D=..\lib -# The output directory for all the temporary muck -TMP_D=tmp - -CP=copy -RM=del -MKDIR=mkdir -MKLIB=tlib /P64 /C -ASM=nasm -f obj -d__omf__ - -###################################################### -# You should not need to touch anything below this point -###################################################### - -# INCL_D - local library directory -# OBJ_D - temp object file directory -OBJ_D=$(TMP_D) -INCL_D=src -INCL=$(INCL_D); - -O_ZLIB=$(OUT_D)\zlib.lib - -###################################################### -# Don't touch anything below this point -###################################################### - -INC=-I$(INCL) -I. -LIB_CFLAGS=$(INC) $(CFLAG) $(LIB_CFLAG) -LIBS_DEP=$(O_ZLIB) - -############################################# -HEADER=$(INCL_D)\zlib.h - -ZLIBOBJS=\ - $(OBJ_D)\adler32.obj \ - $(OBJ_D)\compress.obj \ - $(OBJ_D)\crc32.obj \ - $(OBJ_D)\deflate.obj \ - $(OBJ_D)\gzclose.obj \ - $(OBJ_D)\gzlib.obj \ - $(OBJ_D)\gzread.obj \ - $(OBJ_D)\gzwrite.obj \ - $(OBJ_D)\infback.obj \ - $(OBJ_D)\inffast.obj \ - $(OBJ_D)\inflate.obj \ - $(OBJ_D)\inftrees.obj \ - $(OBJ_D)\trees.obj \ - $(OBJ_D)\uncompr.obj \ - $(OBJ_D)\zutil.obj - -$(OBJ_D)\adler32.obj: $(SRC_D)/src/adler32.c - $(CC) -o$(OBJ_D)\adler32.obj $(LIB_CFLAGS) -c $(SRC_D)/src/adler32.c -$(OBJ_D)\compress.obj: $(SRC_D)/src/compress.c - $(CC) -o$(OBJ_D)\compress.obj $(LIB_CFLAGS) -c $(SRC_D)/src/compress.c -$(OBJ_D)\crc32.obj: $(SRC_D)/src/crc32.c - $(CC) -o$(OBJ_D)\crc32.obj $(LIB_CFLAGS) -c $(SRC_D)/src/crc32.c -$(OBJ_D)\deflate.obj: $(SRC_D)/src/deflate.c - $(CC) -o$(OBJ_D)\deflate.obj $(LIB_CFLAGS) -c $(SRC_D)/src/deflate.c -$(OBJ_D)\gzclose.obj: $(SRC_D)/src/gzclose.c - $(CC) -o$(OBJ_D)\gzclose.obj $(LIB_CFLAGS) -c $(SRC_D)/src/gzclose.c -$(OBJ_D)\gzlib.obj: $(SRC_D)/src/gzlib.c - $(CC) -o$(OBJ_D)\gzlib.obj $(LIB_CFLAGS) -c $(SRC_D)/src/gzlib.c -$(OBJ_D)\gzread.obj: $(SRC_D)/src/gzread.c - $(CC) -o$(OBJ_D)\gzread.obj $(LIB_CFLAGS) -c $(SRC_D)/src/gzread.c -$(OBJ_D)\gzwrite.obj: $(SRC_D)/src/gzwrite.c - $(CC) -o$(OBJ_D)\gzwrite.obj $(LIB_CFLAGS) -c $(SRC_D)/src/gzwrite.c -$(OBJ_D)\infback.obj: $(SRC_D)/src/infback.c - $(CC) -o$(OBJ_D)\infback.obj $(LIB_CFLAGS) -c $(SRC_D)/src/infback.c -$(OBJ_D)\inffast.obj: $(SRC_D)/src/inffast.c - $(CC) -o$(OBJ_D)\inffast.obj $(LIB_CFLAGS) -c $(SRC_D)/src/inffast.c -$(OBJ_D)\inflate.obj: $(SRC_D)/src/inflate.c - $(CC) -o$(OBJ_D)\inflate.obj $(LIB_CFLAGS) -c $(SRC_D)/src/inflate.c -$(OBJ_D)\inftrees.obj: $(SRC_D)/src/inftrees.c - $(CC) -o$(OBJ_D)\inftrees.obj $(LIB_CFLAGS) -c $(SRC_D)/src/inftrees.c -$(OBJ_D)\trees.obj: $(SRC_D)/src/trees.c - $(CC) -o$(OBJ_D)\trees.obj $(LIB_CFLAGS) -c $(SRC_D)/src/trees.c -$(OBJ_D)\uncompr.obj: $(SRC_D)/src/uncompr.c - $(CC) -o$(OBJ_D)\uncompr.obj $(LIB_CFLAGS) -c $(SRC_D)/src/uncompr.c -$(OBJ_D)\zutil.obj: $(SRC_D)/src/zutil.c - $(CC) -o$(OBJ_D)\zutil.obj $(LIB_CFLAGS) -c $(SRC_D)/src/zutil.c - -$(O_ZLIB): $(ZLIBOBJS) - if exist $(O_ZLIB) $(RM) $(O_ZLIB) - $(MKLIB) $(O_ZLIB) @&&! -+$(**: = &^ -+) -! - -################################################################### -all: banner clean_lib $(TMP_D) $(OUT_D) headers lib - -banner: - @echo Building zlib - @echo $(ZLIBOBJS) - -clean_lib: - if exist $(O_ZLIB) $(RM) $(O_ZLIB) - -$(TMP_D): - if not exist "$(TMP_D)" ( $(MKDIR) "$(TMP_D)" ) - -$(OUT_D): - if not exist "$(OUT_D)" ( $(MKDIR) "$(OUT_D)" ) - -headers: $(HEADER) - @ - -lib: $(LIBS_DEP) - diff --git a/libs/zlib/src/README b/libs/zlib/src/README deleted file mode 100644 index 5ca9d127..00000000 --- a/libs/zlib/src/README +++ /dev/null @@ -1,115 +0,0 @@ -ZLIB DATA COMPRESSION LIBRARY - -zlib 1.2.8 is a general purpose data compression library. All the code is -thread safe. The data format used by the zlib library is described by RFCs -(Request for Comments) 1950 to 1952 in the files -http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and -rfc1952 (gzip format). - -All functions of the compression library are documented in the file zlib.h -(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example -of the library is given in the file test/example.c which also tests that -the library is working correctly. Another example is given in the file -test/minigzip.c. The compression library itself is composed of all source -files in the root directory. - -To compile all files and run the test program, follow the instructions given at -the top of Makefile.in. In short "./configure; make test", and if that goes -well, "make install" should work for most flavors of Unix. For Windows, use -one of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use -make_vms.com. - -Questions about zlib should be sent to , or to Gilles Vollant - for the Windows DLL version. The zlib home page is -http://zlib.net/ . Before reporting a problem, please check this site to -verify that you have the latest version of zlib; otherwise get the latest -version and check whether the problem still exists or not. - -PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help. - -Mark Nelson wrote an article about zlib for the Jan. 1997 -issue of Dr. Dobb's Journal; a copy of the article is available at -http://marknelson.us/1997/01/01/zlib-engine/ . - -The changes made in version 1.2.8 are documented in the file ChangeLog. - -Unsupported third party contributions are provided in directory contrib/ . - -zlib is available in Java using the java.util.zip package, documented at -http://java.sun.com/developer/technicalArticles/Programming/compression/ . - -A Perl interface to zlib written by Paul Marquess is available -at CPAN (Comprehensive Perl Archive Network) sites, including -http://search.cpan.org/~pmqs/IO-Compress-Zlib/ . - -A Python interface to zlib written by A.M. Kuchling is -available in Python 1.5 and later versions, see -http://docs.python.org/library/zlib.html . - -zlib is built into tcl: http://wiki.tcl.tk/4610 . - -An experimental package to read and write files in .zip format, written on top -of zlib by Gilles Vollant , is available in the -contrib/minizip directory of zlib. - - -Notes for some targets: - -- For Windows DLL versions, please see win32/DLL_FAQ.txt - -- For 64-bit Irix, deflate.c must be compiled without any optimization. With - -O, one libpng test fails. The test works in 32 bit mode (with the -n32 - compiler flag). The compiler bug has been reported to SGI. - -- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works - when compiled with cc. - -- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is - necessary to get gzprintf working correctly. This is done by configure. - -- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with - other compilers. Use "make test" to check your compiler. - -- gzdopen is not supported on RISCOS or BEOS. - -- For PalmOs, see http://palmzlib.sourceforge.net/ - - -Acknowledgments: - - The deflate format used by zlib was defined by Phil Katz. The deflate and - zlib specifications were written by L. Peter Deutsch. Thanks to all the - people who reported problems and suggested various improvements in zlib; they - are too numerous to cite here. - -Copyright notice: - - (C) 1995-2013 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - -If you use the zlib library in a product, we would appreciate *not* receiving -lengthy legal documents to sign. The sources are provided for free but without -warranty of any kind. The library has been entirely written by Jean-loup -Gailly and Mark Adler; it does not include third-party code. - -If you redistribute modified sources, we would appreciate that you include in -the file ChangeLog history information documenting your changes. Please read -the FAQ for more information on the distribution of modified source versions. diff --git a/libs/zlib/src/adler32.c b/libs/zlib/src/adler32.c deleted file mode 100644 index 674ec76b..00000000 --- a/libs/zlib/src/adler32.c +++ /dev/null @@ -1,179 +0,0 @@ -/* adler32.c -- compute the Adler-32 checksum of a data stream - * Copyright (C) 1995-2011 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id: adler32.c,v 1.2 2013/08/12 09:54:03 martinprikryl Exp $ */ - -#include "zutil.h" - -#define local static - -local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); - -#define BASE 65521 /* largest prime smaller than 65536 */ -#define NMAX 5552 -/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ - -#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} -#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); -#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); -#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); -#define DO16(buf) DO8(buf,0); DO8(buf,8); - -/* use NO_DIVIDE if your processor does not do division in hardware -- - try it both ways to see which is faster */ -#ifdef NO_DIVIDE -/* note that this assumes BASE is 65521, where 65536 % 65521 == 15 - (thank you to John Reiser for pointing this out) */ -# define CHOP(a) \ - do { \ - unsigned long tmp = a >> 16; \ - a &= 0xffffUL; \ - a += (tmp << 4) - tmp; \ - } while (0) -# define MOD28(a) \ - do { \ - CHOP(a); \ - if (a >= BASE) a -= BASE; \ - } while (0) -# define MOD(a) \ - do { \ - CHOP(a); \ - MOD28(a); \ - } while (0) -# define MOD63(a) \ - do { /* this assumes a is not negative */ \ - z_off64_t tmp = a >> 32; \ - a &= 0xffffffffL; \ - a += (tmp << 8) - (tmp << 5) + tmp; \ - tmp = a >> 16; \ - a &= 0xffffL; \ - a += (tmp << 4) - tmp; \ - tmp = a >> 16; \ - a &= 0xffffL; \ - a += (tmp << 4) - tmp; \ - if (a >= BASE) a -= BASE; \ - } while (0) -#else -# define MOD(a) a %= BASE -# define MOD28(a) a %= BASE -# define MOD63(a) a %= BASE -#endif - -/* ========================================================================= */ -uLong ZEXPORT adler32(adler, buf, len) - uLong adler; - const Bytef *buf; - uInt len; -{ - unsigned long sum2; - unsigned n; - - /* split Adler-32 into component sums */ - sum2 = (adler >> 16) & 0xffff; - adler &= 0xffff; - - /* in case user likes doing a byte at a time, keep it fast */ - if (len == 1) { - adler += buf[0]; - if (adler >= BASE) - adler -= BASE; - sum2 += adler; - if (sum2 >= BASE) - sum2 -= BASE; - return adler | (sum2 << 16); - } - - /* initial Adler-32 value (deferred check for len == 1 speed) */ - if (buf == Z_NULL) - return 1L; - - /* in case short lengths are provided, keep it somewhat fast */ - if (len < 16) { - while (len--) { - adler += *buf++; - sum2 += adler; - } - if (adler >= BASE) - adler -= BASE; - MOD28(sum2); /* only added so many BASE's */ - return adler | (sum2 << 16); - } - - /* do length NMAX blocks -- requires just one modulo operation */ - while (len >= NMAX) { - len -= NMAX; - n = NMAX / 16; /* NMAX is divisible by 16 */ - do { - DO16(buf); /* 16 sums unrolled */ - buf += 16; - } while (--n); - MOD(adler); - MOD(sum2); - } - - /* do remaining bytes (less than NMAX, still just one modulo) */ - if (len) { /* avoid modulos if none remaining */ - while (len >= 16) { - len -= 16; - DO16(buf); - buf += 16; - } - while (len--) { - adler += *buf++; - sum2 += adler; - } - MOD(adler); - MOD(sum2); - } - - /* return recombined sums */ - return adler | (sum2 << 16); -} - -/* ========================================================================= */ -local uLong adler32_combine_(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off64_t len2; -{ - unsigned long sum1; - unsigned long sum2; - unsigned rem; - - /* for negative len, return invalid adler32 as a clue for debugging */ - if (len2 < 0) - return 0xffffffffUL; - - /* the derivation of this formula is left as an exercise for the reader */ - MOD63(len2); /* assumes len2 >= 0 */ - rem = (unsigned)len2; - sum1 = adler1 & 0xffff; - sum2 = rem * sum1; - MOD(sum2); - sum1 += (adler2 & 0xffff) + BASE - 1; - sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; - if (sum1 >= BASE) sum1 -= BASE; - if (sum1 >= BASE) sum1 -= BASE; - if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1); - if (sum2 >= BASE) sum2 -= BASE; - return sum1 | (sum2 << 16); -} - -/* ========================================================================= */ -uLong ZEXPORT adler32_combine(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off_t len2; -{ - return adler32_combine_(adler1, adler2, len2); -} - -uLong ZEXPORT adler32_combine64(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off64_t len2; -{ - return adler32_combine_(adler1, adler2, len2); -} diff --git a/libs/zlib/src/compress.c b/libs/zlib/src/compress.c deleted file mode 100644 index 2bcd1e1b..00000000 --- a/libs/zlib/src/compress.c +++ /dev/null @@ -1,80 +0,0 @@ -/* compress.c -- compress a memory buffer - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id: compress.c,v 1.2 2013/08/12 09:54:03 martinprikryl Exp $ */ - -#define ZLIB_INTERNAL -#include "zlib.h" - -/* =========================================================================== - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least 0.1% larger than sourceLen plus - 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ -int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; - int level; -{ - z_stream stream; - int err; - - stream.next_in = (z_const Bytef *)source; - stream.avail_in = (uInt)sourceLen; -#ifdef MAXSEG_64K - /* Check for source > 64K on 16-bit machine: */ - if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; -#endif - stream.next_out = dest; - stream.avail_out = (uInt)*destLen; - if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; - - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - stream.opaque = (voidpf)0; - - err = deflateInit(&stream, level); - if (err != Z_OK) return err; - - err = deflate(&stream, Z_FINISH); - if (err != Z_STREAM_END) { - deflateEnd(&stream); - return err == Z_OK ? Z_BUF_ERROR : err; - } - *destLen = stream.total_out; - - err = deflateEnd(&stream); - return err; -} - -/* =========================================================================== - */ -int ZEXPORT compress (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ - return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); -} - -/* =========================================================================== - If the default memLevel or windowBits for deflateInit() is changed, then - this function needs to be updated. - */ -uLong ZEXPORT compressBound (sourceLen) - uLong sourceLen; -{ - return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + - (sourceLen >> 25) + 13; -} diff --git a/libs/zlib/src/crc32.c b/libs/zlib/src/crc32.c deleted file mode 100644 index 7690b3a7..00000000 --- a/libs/zlib/src/crc32.c +++ /dev/null @@ -1,425 +0,0 @@ -/* crc32.c -- compute the CRC-32 of a data stream - * Copyright (C) 1995-2006, 2010, 2011, 2012 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - * - * Thanks to Rodney Brown for his contribution of faster - * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing - * tables for updating the shift register in one step with three exclusive-ors - * instead of four steps with four exclusive-ors. This results in about a - * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. - */ - -/* @(#) $Id: crc32.c,v 1.2 2013/08/12 09:54:03 martinprikryl Exp $ */ - -/* - Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore - protection on the static variables used to control the first-use generation - of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should - first call get_crc_table() to initialize the tables before allowing more than - one thread to use crc32(). - - DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h. - */ - -#ifdef MAKECRCH -# include -# ifndef DYNAMIC_CRC_TABLE -# define DYNAMIC_CRC_TABLE -# endif /* !DYNAMIC_CRC_TABLE */ -#endif /* MAKECRCH */ - -#include "zutil.h" /* for STDC and FAR definitions */ - -#define local static - -/* Definitions for doing the crc four data bytes at a time. */ -#if !defined(NOBYFOUR) && defined(Z_U4) -# define BYFOUR -#endif -#ifdef BYFOUR - local unsigned long crc32_little OF((unsigned long, - const unsigned char FAR *, unsigned)); - local unsigned long crc32_big OF((unsigned long, - const unsigned char FAR *, unsigned)); -# define TBLS 8 -#else -# define TBLS 1 -#endif /* BYFOUR */ - -/* Local functions for crc concatenation */ -local unsigned long gf2_matrix_times OF((unsigned long *mat, - unsigned long vec)); -local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); -local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2)); - - -#ifdef DYNAMIC_CRC_TABLE - -local volatile int crc_table_empty = 1; -local z_crc_t FAR crc_table[TBLS][256]; -local void make_crc_table OF((void)); -#ifdef MAKECRCH - local void write_table OF((FILE *, const z_crc_t FAR *)); -#endif /* MAKECRCH */ -/* - Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: - x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. - - Polynomials over GF(2) are represented in binary, one bit per coefficient, - with the lowest powers in the most significant bit. Then adding polynomials - is just exclusive-or, and multiplying a polynomial by x is a right shift by - one. If we call the above polynomial p, and represent a byte as the - polynomial q, also with the lowest power in the most significant bit (so the - byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, - where a mod b means the remainder after dividing a by b. - - This calculation is done using the shift-register method of multiplying and - taking the remainder. The register is initialized to zero, and for each - incoming bit, x^32 is added mod p to the register if the bit is a one (where - x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by - x (which is shifting right by one and adding x^32 mod p if the bit shifted - out is a one). We start with the highest power (least significant bit) of - q and repeat for all eight bits of q. - - The first table is simply the CRC of all possible eight bit values. This is - all the information needed to generate CRCs on data a byte at a time for all - combinations of CRC register values and incoming bytes. The remaining tables - allow for word-at-a-time CRC calculation for both big-endian and little- - endian machines, where a word is four bytes. -*/ -local void make_crc_table() -{ - z_crc_t c; - int n, k; - z_crc_t poly; /* polynomial exclusive-or pattern */ - /* terms of polynomial defining this crc (except x^32): */ - static volatile int first = 1; /* flag to limit concurrent making */ - static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; - - /* See if another task is already doing this (not thread-safe, but better - than nothing -- significantly reduces duration of vulnerability in - case the advice about DYNAMIC_CRC_TABLE is ignored) */ - if (first) { - first = 0; - - /* make exclusive-or pattern from polynomial (0xedb88320UL) */ - poly = 0; - for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++) - poly |= (z_crc_t)1 << (31 - p[n]); - - /* generate a crc for every 8-bit value */ - for (n = 0; n < 256; n++) { - c = (z_crc_t)n; - for (k = 0; k < 8; k++) - c = c & 1 ? poly ^ (c >> 1) : c >> 1; - crc_table[0][n] = c; - } - -#ifdef BYFOUR - /* generate crc for each value followed by one, two, and three zeros, - and then the byte reversal of those as well as the first table */ - for (n = 0; n < 256; n++) { - c = crc_table[0][n]; - crc_table[4][n] = ZSWAP32(c); - for (k = 1; k < 4; k++) { - c = crc_table[0][c & 0xff] ^ (c >> 8); - crc_table[k][n] = c; - crc_table[k + 4][n] = ZSWAP32(c); - } - } -#endif /* BYFOUR */ - - crc_table_empty = 0; - } - else { /* not first */ - /* wait for the other guy to finish (not efficient, but rare) */ - while (crc_table_empty) - ; - } - -#ifdef MAKECRCH - /* write out CRC tables to crc32.h */ - { - FILE *out; - - out = fopen("crc32.h", "w"); - if (out == NULL) return; - fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); - fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); - fprintf(out, "local const z_crc_t FAR "); - fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); - write_table(out, crc_table[0]); -# ifdef BYFOUR - fprintf(out, "#ifdef BYFOUR\n"); - for (k = 1; k < 8; k++) { - fprintf(out, " },\n {\n"); - write_table(out, crc_table[k]); - } - fprintf(out, "#endif\n"); -# endif /* BYFOUR */ - fprintf(out, " }\n};\n"); - fclose(out); - } -#endif /* MAKECRCH */ -} - -#ifdef MAKECRCH -local void write_table(out, table) - FILE *out; - const z_crc_t FAR *table; -{ - int n; - - for (n = 0; n < 256; n++) - fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", - (unsigned long)(table[n]), - n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); -} -#endif /* MAKECRCH */ - -#else /* !DYNAMIC_CRC_TABLE */ -/* ======================================================================== - * Tables of CRC-32s of all single-byte values, made by make_crc_table(). - */ -#include "crc32.h" -#endif /* DYNAMIC_CRC_TABLE */ - -/* ========================================================================= - * This function can be used by asm versions of crc32() - */ -const z_crc_t FAR * ZEXPORT get_crc_table() -{ -#ifdef DYNAMIC_CRC_TABLE - if (crc_table_empty) - make_crc_table(); -#endif /* DYNAMIC_CRC_TABLE */ - return (const z_crc_t FAR *)crc_table; -} - -/* ========================================================================= */ -#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8) -#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 - -/* ========================================================================= */ -unsigned long ZEXPORT crc32(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - uInt len; -{ - if (buf == Z_NULL) return 0UL; - -#ifdef DYNAMIC_CRC_TABLE - if (crc_table_empty) - make_crc_table(); -#endif /* DYNAMIC_CRC_TABLE */ - -#ifdef BYFOUR - if (sizeof(void *) == sizeof(ptrdiff_t)) { - z_crc_t endian; - - endian = 1; - if (*((unsigned char *)(&endian))) - return crc32_little(crc, buf, len); - else - return crc32_big(crc, buf, len); - } -#endif /* BYFOUR */ - crc = crc ^ 0xffffffffUL; - while (len >= 8) { - DO8; - len -= 8; - } - if (len) do { - DO1; - } while (--len); - return crc ^ 0xffffffffUL; -} - -#ifdef BYFOUR - -/* ========================================================================= */ -#define DOLIT4 c ^= *buf4++; \ - c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \ - crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24] -#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4 - -/* ========================================================================= */ -local unsigned long crc32_little(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - unsigned len; -{ - register z_crc_t c; - register const z_crc_t FAR *buf4; - - c = (z_crc_t)crc; - c = ~c; - while (len && ((ptrdiff_t)buf & 3)) { - c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); - len--; - } - - buf4 = (const z_crc_t FAR *)(const void FAR *)buf; - while (len >= 32) { - DOLIT32; - len -= 32; - } - while (len >= 4) { - DOLIT4; - len -= 4; - } - buf = (const unsigned char FAR *)buf4; - - if (len) do { - c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); - } while (--len); - c = ~c; - return (unsigned long)c; -} - -/* ========================================================================= */ -#define DOBIG4 c ^= *++buf4; \ - c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \ - crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24] -#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4 - -/* ========================================================================= */ -local unsigned long crc32_big(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - unsigned len; -{ - register z_crc_t c; - register const z_crc_t FAR *buf4; - - c = ZSWAP32((z_crc_t)crc); - c = ~c; - while (len && ((ptrdiff_t)buf & 3)) { - c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); - len--; - } - - buf4 = (const z_crc_t FAR *)(const void FAR *)buf; - buf4--; - while (len >= 32) { - DOBIG32; - len -= 32; - } - while (len >= 4) { - DOBIG4; - len -= 4; - } - buf4++; - buf = (const unsigned char FAR *)buf4; - - if (len) do { - c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); - } while (--len); - c = ~c; - return (unsigned long)(ZSWAP32(c)); -} - -#endif /* BYFOUR */ - -#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */ - -/* ========================================================================= */ -local unsigned long gf2_matrix_times(mat, vec) - unsigned long *mat; - unsigned long vec; -{ - unsigned long sum; - - sum = 0; - while (vec) { - if (vec & 1) - sum ^= *mat; - vec >>= 1; - mat++; - } - return sum; -} - -/* ========================================================================= */ -local void gf2_matrix_square(square, mat) - unsigned long *square; - unsigned long *mat; -{ - int n; - - for (n = 0; n < GF2_DIM; n++) - square[n] = gf2_matrix_times(mat, mat[n]); -} - -/* ========================================================================= */ -local uLong crc32_combine_(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off64_t len2; -{ - int n; - unsigned long row; - unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */ - unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */ - - /* degenerate case (also disallow negative lengths) */ - if (len2 <= 0) - return crc1; - - /* put operator for one zero bit in odd */ - odd[0] = 0xedb88320UL; /* CRC-32 polynomial */ - row = 1; - for (n = 1; n < GF2_DIM; n++) { - odd[n] = row; - row <<= 1; - } - - /* put operator for two zero bits in even */ - gf2_matrix_square(even, odd); - - /* put operator for four zero bits in odd */ - gf2_matrix_square(odd, even); - - /* apply len2 zeros to crc1 (first square will put the operator for one - zero byte, eight zero bits, in even) */ - do { - /* apply zeros operator for this bit of len2 */ - gf2_matrix_square(even, odd); - if (len2 & 1) - crc1 = gf2_matrix_times(even, crc1); - len2 >>= 1; - - /* if no more bits set, then done */ - if (len2 == 0) - break; - - /* another iteration of the loop with odd and even swapped */ - gf2_matrix_square(odd, even); - if (len2 & 1) - crc1 = gf2_matrix_times(odd, crc1); - len2 >>= 1; - - /* if no more bits set, then done */ - } while (len2 != 0); - - /* return combined crc */ - crc1 ^= crc2; - return crc1; -} - -/* ========================================================================= */ -uLong ZEXPORT crc32_combine(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off_t len2; -{ - return crc32_combine_(crc1, crc2, len2); -} - -uLong ZEXPORT crc32_combine64(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off64_t len2; -{ - return crc32_combine_(crc1, crc2, len2); -} diff --git a/libs/zlib/src/crc32.h b/libs/zlib/src/crc32.h deleted file mode 100644 index 9e0c7781..00000000 --- a/libs/zlib/src/crc32.h +++ /dev/null @@ -1,441 +0,0 @@ -/* crc32.h -- tables for rapid CRC calculation - * Generated automatically by crc32.c - */ - -local const z_crc_t FAR crc_table[TBLS][256] = -{ - { - 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, - 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, - 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, - 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL, - 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL, - 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL, - 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL, - 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL, - 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL, - 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL, - 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL, - 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL, - 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL, - 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL, - 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL, - 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL, - 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL, - 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL, - 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL, - 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL, - 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL, - 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL, - 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL, - 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL, - 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL, - 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL, - 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL, - 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL, - 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL, - 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL, - 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL, - 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL, - 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL, - 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL, - 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL, - 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL, - 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL, - 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL, - 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL, - 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL, - 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL, - 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL, - 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL, - 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL, - 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL, - 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL, - 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL, - 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL, - 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL, - 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, - 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, - 0x2d02ef8dUL -#ifdef BYFOUR - }, - { - 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL, - 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL, - 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL, - 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL, - 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL, - 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL, - 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL, - 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL, - 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL, - 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL, - 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL, - 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL, - 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL, - 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL, - 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL, - 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL, - 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL, - 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL, - 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL, - 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL, - 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL, - 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL, - 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL, - 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL, - 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL, - 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL, - 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL, - 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL, - 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL, - 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL, - 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL, - 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL, - 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL, - 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL, - 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL, - 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL, - 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL, - 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL, - 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL, - 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL, - 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL, - 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL, - 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL, - 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL, - 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL, - 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL, - 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL, - 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL, - 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL, - 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL, - 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL, - 0x9324fd72UL - }, - { - 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL, - 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL, - 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL, - 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL, - 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL, - 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL, - 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL, - 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL, - 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL, - 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL, - 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL, - 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL, - 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL, - 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL, - 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL, - 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL, - 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL, - 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL, - 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL, - 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL, - 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL, - 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL, - 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL, - 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL, - 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL, - 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL, - 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL, - 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL, - 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL, - 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL, - 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL, - 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL, - 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL, - 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL, - 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL, - 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL, - 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL, - 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL, - 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL, - 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL, - 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL, - 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL, - 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL, - 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL, - 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL, - 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL, - 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL, - 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL, - 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL, - 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL, - 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL, - 0xbe9834edUL - }, - { - 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL, - 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL, - 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL, - 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL, - 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL, - 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL, - 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL, - 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL, - 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL, - 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL, - 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL, - 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL, - 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL, - 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL, - 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL, - 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL, - 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL, - 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL, - 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL, - 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL, - 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL, - 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL, - 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL, - 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL, - 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL, - 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL, - 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL, - 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL, - 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL, - 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL, - 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL, - 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL, - 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL, - 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL, - 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL, - 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL, - 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL, - 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL, - 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL, - 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL, - 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL, - 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL, - 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL, - 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL, - 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL, - 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL, - 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL, - 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL, - 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL, - 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL, - 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL, - 0xde0506f1UL - }, - { - 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL, - 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL, - 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL, - 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL, - 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL, - 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL, - 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL, - 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL, - 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL, - 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL, - 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL, - 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL, - 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL, - 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL, - 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL, - 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL, - 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL, - 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL, - 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL, - 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL, - 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL, - 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL, - 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL, - 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL, - 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL, - 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL, - 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL, - 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL, - 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL, - 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL, - 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL, - 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL, - 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL, - 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL, - 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL, - 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL, - 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL, - 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL, - 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL, - 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL, - 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL, - 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL, - 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL, - 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL, - 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL, - 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL, - 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL, - 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL, - 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL, - 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL, - 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL, - 0x8def022dUL - }, - { - 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL, - 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL, - 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL, - 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL, - 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL, - 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL, - 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL, - 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL, - 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL, - 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL, - 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL, - 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL, - 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL, - 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL, - 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL, - 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL, - 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL, - 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL, - 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL, - 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL, - 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL, - 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL, - 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL, - 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL, - 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL, - 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL, - 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL, - 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL, - 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL, - 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL, - 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL, - 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL, - 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL, - 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL, - 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL, - 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL, - 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL, - 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL, - 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL, - 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL, - 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL, - 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL, - 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL, - 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL, - 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL, - 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL, - 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL, - 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL, - 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL, - 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL, - 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL, - 0x72fd2493UL - }, - { - 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL, - 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL, - 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL, - 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL, - 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL, - 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL, - 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL, - 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL, - 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL, - 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL, - 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL, - 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL, - 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL, - 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL, - 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL, - 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL, - 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL, - 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL, - 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL, - 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL, - 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL, - 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL, - 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL, - 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL, - 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL, - 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL, - 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL, - 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL, - 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL, - 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL, - 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL, - 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL, - 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL, - 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL, - 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL, - 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL, - 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL, - 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL, - 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL, - 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL, - 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL, - 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL, - 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL, - 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL, - 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL, - 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL, - 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL, - 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL, - 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL, - 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL, - 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL, - 0xed3498beUL - }, - { - 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL, - 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL, - 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL, - 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL, - 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL, - 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL, - 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL, - 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL, - 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL, - 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL, - 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL, - 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL, - 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL, - 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL, - 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL, - 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL, - 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL, - 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL, - 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL, - 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL, - 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL, - 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL, - 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL, - 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL, - 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL, - 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL, - 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL, - 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL, - 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL, - 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL, - 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL, - 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL, - 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL, - 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL, - 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL, - 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL, - 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL, - 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL, - 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL, - 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL, - 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL, - 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL, - 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL, - 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL, - 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL, - 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL, - 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL, - 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL, - 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL, - 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL, - 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL, - 0xf10605deUL -#endif - } -}; diff --git a/libs/zlib/src/deflate.c b/libs/zlib/src/deflate.c deleted file mode 100644 index f9cfeb5d..00000000 --- a/libs/zlib/src/deflate.c +++ /dev/null @@ -1,1967 +0,0 @@ -/* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * ALGORITHM - * - * The "deflation" process depends on being able to identify portions - * of the input text which are identical to earlier input (within a - * sliding window trailing behind the input currently being processed). - * - * The most straightforward technique turns out to be the fastest for - * most input files: try all possible matches and select the longest. - * The key feature of this algorithm is that insertions into the string - * dictionary are very simple and thus fast, and deletions are avoided - * completely. Insertions are performed at each input character, whereas - * string matches are performed only when the previous match ends. So it - * is preferable to spend more time in matches to allow very fast string - * insertions and avoid deletions. The matching algorithm for small - * strings is inspired from that of Rabin & Karp. A brute force approach - * is used to find longer strings when a small match has been found. - * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze - * (by Leonid Broukhis). - * A previous version of this file used a more sophisticated algorithm - * (by Fiala and Greene) which is guaranteed to run in linear amortized - * time, but has a larger average cost, uses more memory and is patented. - * However the F&G algorithm may be faster for some highly redundant - * files if the parameter max_chain_length (described below) is too large. - * - * ACKNOWLEDGEMENTS - * - * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and - * I found it in 'freeze' written by Leonid Broukhis. - * Thanks to many people for bug reports and testing. - * - * REFERENCES - * - * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". - * Available in http://tools.ietf.org/html/rfc1951 - * - * A description of the Rabin and Karp algorithm is given in the book - * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. - * - * Fiala,E.R., and Greene,D.H. - * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595 - * - */ - -/* @(#) $Id: deflate.c,v 1.2 2013/08/12 09:54:03 martinprikryl Exp $ */ - -#include "deflate.h" - -const char deflate_copyright[] = - " deflate 1.2.8 Copyright 1995-2013 Jean-loup Gailly and Mark Adler "; -/* - If you use the zlib library in a product, an acknowledgment is welcome - in the documentation of your product. If for some reason you cannot - include such an acknowledgment, I would appreciate that you keep this - copyright string in the executable of your product. - */ - -/* =========================================================================== - * Function prototypes. - */ -typedef enum { - need_more, /* block not completed, need more input or more output */ - block_done, /* block flush performed */ - finish_started, /* finish started, need only more output at next deflate */ - finish_done /* finish done, accept no more input or output */ -} block_state; - -typedef block_state (*compress_func) OF((deflate_state *s, int flush)); -/* Compression function. Returns the block state after the call. */ - -local void fill_window OF((deflate_state *s)); -local block_state deflate_stored OF((deflate_state *s, int flush)); -local block_state deflate_fast OF((deflate_state *s, int flush)); -#ifndef FASTEST -local block_state deflate_slow OF((deflate_state *s, int flush)); -#endif -local block_state deflate_rle OF((deflate_state *s, int flush)); -local block_state deflate_huff OF((deflate_state *s, int flush)); -local void lm_init OF((deflate_state *s)); -local void putShortMSB OF((deflate_state *s, uInt b)); -local void flush_pending OF((z_streamp strm)); -local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); -#ifdef ASMV - void match_init OF((void)); /* asm code initialization */ - uInt longest_match OF((deflate_state *s, IPos cur_match)); -#else -local uInt longest_match OF((deflate_state *s, IPos cur_match)); -#endif - -#ifdef DEBUG -local void check_match OF((deflate_state *s, IPos start, IPos match, - int length)); -#endif - -/* =========================================================================== - * Local data - */ - -#define NIL 0 -/* Tail of hash chains */ - -#ifndef TOO_FAR -# define TOO_FAR 4096 -#endif -/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */ - -/* Values for max_lazy_match, good_match and max_chain_length, depending on - * the desired pack level (0..9). The values given below have been tuned to - * exclude worst case performance for pathological files. Better values may be - * found for specific files. - */ -typedef struct config_s { - ush good_length; /* reduce lazy search above this match length */ - ush max_lazy; /* do not perform lazy search above this match length */ - ush nice_length; /* quit search above this match length */ - ush max_chain; - compress_func func; -} config; - -#ifdef FASTEST -local const config configuration_table[2] = { -/* good lazy nice chain */ -/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ -/* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */ -#else -local const config configuration_table[10] = { -/* good lazy nice chain */ -/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ -/* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */ -/* 2 */ {4, 5, 16, 8, deflate_fast}, -/* 3 */ {4, 6, 32, 32, deflate_fast}, - -/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */ -/* 5 */ {8, 16, 32, 32, deflate_slow}, -/* 6 */ {8, 16, 128, 128, deflate_slow}, -/* 7 */ {8, 32, 128, 256, deflate_slow}, -/* 8 */ {32, 128, 258, 1024, deflate_slow}, -/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */ -#endif - -/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 - * For deflate_fast() (levels <= 3) good is ignored and lazy has a different - * meaning. - */ - -#define EQUAL 0 -/* result of memcmp for equal strings */ - -#ifndef NO_DUMMY_DECL -struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ -#endif - -/* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */ -#define RANK(f) (((f) << 1) - ((f) > 4 ? 9 : 0)) - -/* =========================================================================== - * Update a hash value with the given input byte - * IN assertion: all calls to to UPDATE_HASH are made with consecutive - * input characters, so that a running hash key can be computed from the - * previous key instead of complete recalculation each time. - */ -#define UPDATE_HASH(s,h,c) (h = (((h)<hash_shift) ^ (c)) & s->hash_mask) - - -/* =========================================================================== - * Insert string str in the dictionary and set match_head to the previous head - * of the hash chain (the most recent string with same hash key). Return - * the previous length of the hash chain. - * If this file is compiled with -DFASTEST, the compression level is forced - * to 1, and no hash chains are maintained. - * IN assertion: all calls to to INSERT_STRING are made with consecutive - * input characters and the first MIN_MATCH bytes of str are valid - * (except for the last MIN_MATCH-1 bytes of the input file). - */ -#ifdef FASTEST -#define INSERT_STRING(s, str, match_head) \ - (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ - match_head = s->head[s->ins_h], \ - s->head[s->ins_h] = (Pos)(str)) -#else -#define INSERT_STRING(s, str, match_head) \ - (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ - match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \ - s->head[s->ins_h] = (Pos)(str)) -#endif - -/* =========================================================================== - * Initialize the hash table (avoiding 64K overflow for 16 bit systems). - * prev[] will be initialized on the fly. - */ -#define CLEAR_HASH(s) \ - s->head[s->hash_size-1] = NIL; \ - zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); - -/* ========================================================================= */ -int ZEXPORT deflateInit_(strm, level, version, stream_size) - z_streamp strm; - int level; - const char *version; - int stream_size; -{ - return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, - Z_DEFAULT_STRATEGY, version, stream_size); - /* To do: ignore strm->next_in if we use it as window */ -} - -/* ========================================================================= */ -int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, - version, stream_size) - z_streamp strm; - int level; - int method; - int windowBits; - int memLevel; - int strategy; - const char *version; - int stream_size; -{ - deflate_state *s; - int wrap = 1; - static const char my_version[] = ZLIB_VERSION; - - ushf *overlay; - /* We overlay pending_buf and d_buf+l_buf. This works since the average - * output size for (length,distance) codes is <= 24 bits. - */ - - if (version == Z_NULL || version[0] != my_version[0] || - stream_size != sizeof(z_stream)) { - return Z_VERSION_ERROR; - } - if (strm == Z_NULL) return Z_STREAM_ERROR; - - strm->msg = Z_NULL; - if (strm->zalloc == (alloc_func)0) { -#ifdef Z_SOLO - return Z_STREAM_ERROR; -#else - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; -#endif - } - if (strm->zfree == (free_func)0) -#ifdef Z_SOLO - return Z_STREAM_ERROR; -#else - strm->zfree = zcfree; -#endif - -#ifdef FASTEST - if (level != 0) level = 1; -#else - if (level == Z_DEFAULT_COMPRESSION) level = 6; -#endif - - if (windowBits < 0) { /* suppress zlib wrapper */ - wrap = 0; - windowBits = -windowBits; - } -#ifdef GZIP - else if (windowBits > 15) { - wrap = 2; /* write gzip wrapper instead */ - windowBits -= 16; - } -#endif - if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || - windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || - strategy < 0 || strategy > Z_FIXED) { - return Z_STREAM_ERROR; - } - if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */ - s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); - if (s == Z_NULL) return Z_MEM_ERROR; - strm->state = (struct internal_state FAR *)s; - s->strm = strm; - - s->wrap = wrap; - s->gzhead = Z_NULL; - s->w_bits = windowBits; - s->w_size = 1 << s->w_bits; - s->w_mask = s->w_size - 1; - - s->hash_bits = memLevel + 7; - s->hash_size = 1 << s->hash_bits; - s->hash_mask = s->hash_size - 1; - s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); - - s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); - s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); - s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); - - s->high_water = 0; /* nothing written to s->window yet */ - - s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ - - overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); - s->pending_buf = (uchf *) overlay; - s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L); - - if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || - s->pending_buf == Z_NULL) { - s->status = FINISH_STATE; - strm->msg = ERR_MSG(Z_MEM_ERROR); - deflateEnd (strm); - return Z_MEM_ERROR; - } - s->d_buf = overlay + s->lit_bufsize/sizeof(ush); - s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; - - s->level = level; - s->strategy = strategy; - s->method = (Byte)method; - - return deflateReset(strm); -} - -/* ========================================================================= */ -int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) - z_streamp strm; - const Bytef *dictionary; - uInt dictLength; -{ - deflate_state *s; - uInt str, n; - int wrap; - unsigned avail; - z_const unsigned char *next; - - if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL) - return Z_STREAM_ERROR; - s = strm->state; - wrap = s->wrap; - if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead) - return Z_STREAM_ERROR; - - /* when using zlib wrappers, compute Adler-32 for provided dictionary */ - if (wrap == 1) - strm->adler = adler32(strm->adler, dictionary, dictLength); - s->wrap = 0; /* avoid computing Adler-32 in read_buf */ - - /* if dictionary would fill window, just replace the history */ - if (dictLength >= s->w_size) { - if (wrap == 0) { /* already empty otherwise */ - CLEAR_HASH(s); - s->strstart = 0; - s->block_start = 0L; - s->insert = 0; - } - dictionary += dictLength - s->w_size; /* use the tail */ - dictLength = s->w_size; - } - - /* insert dictionary into window and hash */ - avail = strm->avail_in; - next = strm->next_in; - strm->avail_in = dictLength; - strm->next_in = (z_const Bytef *)dictionary; - fill_window(s); - while (s->lookahead >= MIN_MATCH) { - str = s->strstart; - n = s->lookahead - (MIN_MATCH-1); - do { - UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); -#ifndef FASTEST - s->prev[str & s->w_mask] = s->head[s->ins_h]; -#endif - s->head[s->ins_h] = (Pos)str; - str++; - } while (--n); - s->strstart = str; - s->lookahead = MIN_MATCH-1; - fill_window(s); - } - s->strstart += s->lookahead; - s->block_start = (long)s->strstart; - s->insert = s->lookahead; - s->lookahead = 0; - s->match_length = s->prev_length = MIN_MATCH-1; - s->match_available = 0; - strm->next_in = next; - strm->avail_in = avail; - s->wrap = wrap; - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateResetKeep (strm) - z_streamp strm; -{ - deflate_state *s; - - if (strm == Z_NULL || strm->state == Z_NULL || - strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) { - return Z_STREAM_ERROR; - } - - strm->total_in = strm->total_out = 0; - strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */ - strm->data_type = Z_UNKNOWN; - - s = (deflate_state *)strm->state; - s->pending = 0; - s->pending_out = s->pending_buf; - - if (s->wrap < 0) { - s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */ - } - s->status = s->wrap ? INIT_STATE : BUSY_STATE; - strm->adler = -#ifdef GZIP - s->wrap == 2 ? crc32(0L, Z_NULL, 0) : -#endif - adler32(0L, Z_NULL, 0); - s->last_flush = Z_NO_FLUSH; - - _tr_init(s); - - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateReset (strm) - z_streamp strm; -{ - int ret; - - ret = deflateResetKeep(strm); - if (ret == Z_OK) - lm_init(strm->state); - return ret; -} - -/* ========================================================================= */ -int ZEXPORT deflateSetHeader (strm, head) - z_streamp strm; - gz_headerp head; -{ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - if (strm->state->wrap != 2) return Z_STREAM_ERROR; - strm->state->gzhead = head; - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflatePending (strm, pending, bits) - unsigned *pending; - int *bits; - z_streamp strm; -{ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - if (pending != Z_NULL) - *pending = strm->state->pending; - if (bits != Z_NULL) - *bits = strm->state->bi_valid; - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflatePrime (strm, bits, value) - z_streamp strm; - int bits; - int value; -{ - deflate_state *s; - int put; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - s = strm->state; - if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3)) - return Z_BUF_ERROR; - do { - put = Buf_size - s->bi_valid; - if (put > bits) - put = bits; - s->bi_buf |= (ush)((value & ((1 << put) - 1)) << s->bi_valid); - s->bi_valid += put; - _tr_flush_bits(s); - value >>= put; - bits -= put; - } while (bits); - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateParams(strm, level, strategy) - z_streamp strm; - int level; - int strategy; -{ - deflate_state *s; - compress_func func; - int err = Z_OK; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - s = strm->state; - -#ifdef FASTEST - if (level != 0) level = 1; -#else - if (level == Z_DEFAULT_COMPRESSION) level = 6; -#endif - if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) { - return Z_STREAM_ERROR; - } - func = configuration_table[s->level].func; - - if ((strategy != s->strategy || func != configuration_table[level].func) && - strm->total_in != 0) { - /* Flush the last buffer: */ - err = deflate(strm, Z_BLOCK); - if (err == Z_BUF_ERROR && s->pending == 0) - err = Z_OK; - } - if (s->level != level) { - s->level = level; - s->max_lazy_match = configuration_table[level].max_lazy; - s->good_match = configuration_table[level].good_length; - s->nice_match = configuration_table[level].nice_length; - s->max_chain_length = configuration_table[level].max_chain; - } - s->strategy = strategy; - return err; -} - -/* ========================================================================= */ -int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) - z_streamp strm; - int good_length; - int max_lazy; - int nice_length; - int max_chain; -{ - deflate_state *s; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - s = strm->state; - s->good_match = good_length; - s->max_lazy_match = max_lazy; - s->nice_match = nice_length; - s->max_chain_length = max_chain; - return Z_OK; -} - -/* ========================================================================= - * For the default windowBits of 15 and memLevel of 8, this function returns - * a close to exact, as well as small, upper bound on the compressed size. - * They are coded as constants here for a reason--if the #define's are - * changed, then this function needs to be changed as well. The return - * value for 15 and 8 only works for those exact settings. - * - * For any setting other than those defaults for windowBits and memLevel, - * the value returned is a conservative worst case for the maximum expansion - * resulting from using fixed blocks instead of stored blocks, which deflate - * can emit on compressed data for some combinations of the parameters. - * - * This function could be more sophisticated to provide closer upper bounds for - * every combination of windowBits and memLevel. But even the conservative - * upper bound of about 14% expansion does not seem onerous for output buffer - * allocation. - */ -uLong ZEXPORT deflateBound(strm, sourceLen) - z_streamp strm; - uLong sourceLen; -{ - deflate_state *s; - uLong complen, wraplen; - Bytef *str; - - /* conservative upper bound for compressed data */ - complen = sourceLen + - ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5; - - /* if can't get parameters, return conservative bound plus zlib wrapper */ - if (strm == Z_NULL || strm->state == Z_NULL) - return complen + 6; - - /* compute wrapper length */ - s = strm->state; - switch (s->wrap) { - case 0: /* raw deflate */ - wraplen = 0; - break; - case 1: /* zlib wrapper */ - wraplen = 6 + (s->strstart ? 4 : 0); - break; - case 2: /* gzip wrapper */ - wraplen = 18; - if (s->gzhead != Z_NULL) { /* user-supplied gzip header */ - if (s->gzhead->extra != Z_NULL) - wraplen += 2 + s->gzhead->extra_len; - str = s->gzhead->name; - if (str != Z_NULL) - do { - wraplen++; - } while (*str++); - str = s->gzhead->comment; - if (str != Z_NULL) - do { - wraplen++; - } while (*str++); - if (s->gzhead->hcrc) - wraplen += 2; - } - break; - default: /* for compiler happiness */ - wraplen = 6; - } - - /* if not default parameters, return conservative bound */ - if (s->w_bits != 15 || s->hash_bits != 8 + 7) - return complen + wraplen; - - /* default settings: return tight bound for that case */ - return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + - (sourceLen >> 25) + 13 - 6 + wraplen; -} - -/* ========================================================================= - * Put a short in the pending buffer. The 16-bit value is put in MSB order. - * IN assertion: the stream state is correct and there is enough room in - * pending_buf. - */ -local void putShortMSB (s, b) - deflate_state *s; - uInt b; -{ - put_byte(s, (Byte)(b >> 8)); - put_byte(s, (Byte)(b & 0xff)); -} - -/* ========================================================================= - * Flush as much pending output as possible. All deflate() output goes - * through this function so some applications may wish to modify it - * to avoid allocating a large strm->next_out buffer and copying into it. - * (See also read_buf()). - */ -local void flush_pending(strm) - z_streamp strm; -{ - unsigned len; - deflate_state *s = strm->state; - - _tr_flush_bits(s); - len = s->pending; - if (len > strm->avail_out) len = strm->avail_out; - if (len == 0) return; - - zmemcpy(strm->next_out, s->pending_out, len); - strm->next_out += len; - s->pending_out += len; - strm->total_out += len; - strm->avail_out -= len; - s->pending -= len; - if (s->pending == 0) { - s->pending_out = s->pending_buf; - } -} - -/* ========================================================================= */ -int ZEXPORT deflate (strm, flush) - z_streamp strm; - int flush; -{ - int old_flush; /* value of flush param for previous deflate call */ - deflate_state *s; - - if (strm == Z_NULL || strm->state == Z_NULL || - flush > Z_BLOCK || flush < 0) { - return Z_STREAM_ERROR; - } - s = strm->state; - - if (strm->next_out == Z_NULL || - (strm->next_in == Z_NULL && strm->avail_in != 0) || - (s->status == FINISH_STATE && flush != Z_FINISH)) { - ERR_RETURN(strm, Z_STREAM_ERROR); - } - if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); - - s->strm = strm; /* just in case */ - old_flush = s->last_flush; - s->last_flush = flush; - - /* Write the header */ - if (s->status == INIT_STATE) { -#ifdef GZIP - if (s->wrap == 2) { - strm->adler = crc32(0L, Z_NULL, 0); - put_byte(s, 31); - put_byte(s, 139); - put_byte(s, 8); - if (s->gzhead == Z_NULL) { - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, s->level == 9 ? 2 : - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? - 4 : 0)); - put_byte(s, OS_CODE); - s->status = BUSY_STATE; - } - else { - put_byte(s, (s->gzhead->text ? 1 : 0) + - (s->gzhead->hcrc ? 2 : 0) + - (s->gzhead->extra == Z_NULL ? 0 : 4) + - (s->gzhead->name == Z_NULL ? 0 : 8) + - (s->gzhead->comment == Z_NULL ? 0 : 16) - ); - put_byte(s, (Byte)(s->gzhead->time & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff)); - put_byte(s, s->level == 9 ? 2 : - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? - 4 : 0)); - put_byte(s, s->gzhead->os & 0xff); - if (s->gzhead->extra != Z_NULL) { - put_byte(s, s->gzhead->extra_len & 0xff); - put_byte(s, (s->gzhead->extra_len >> 8) & 0xff); - } - if (s->gzhead->hcrc) - strm->adler = crc32(strm->adler, s->pending_buf, - s->pending); - s->gzindex = 0; - s->status = EXTRA_STATE; - } - } - else -#endif - { - uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; - uInt level_flags; - - if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) - level_flags = 0; - else if (s->level < 6) - level_flags = 1; - else if (s->level == 6) - level_flags = 2; - else - level_flags = 3; - header |= (level_flags << 6); - if (s->strstart != 0) header |= PRESET_DICT; - header += 31 - (header % 31); - - s->status = BUSY_STATE; - putShortMSB(s, header); - - /* Save the adler32 of the preset dictionary: */ - if (s->strstart != 0) { - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); - } - strm->adler = adler32(0L, Z_NULL, 0); - } - } -#ifdef GZIP - if (s->status == EXTRA_STATE) { - if (s->gzhead->extra != Z_NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ - - while (s->gzindex < (s->gzhead->extra_len & 0xffff)) { - if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) - break; - } - put_byte(s, s->gzhead->extra[s->gzindex]); - s->gzindex++; - } - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (s->gzindex == s->gzhead->extra_len) { - s->gzindex = 0; - s->status = NAME_STATE; - } - } - else - s->status = NAME_STATE; - } - if (s->status == NAME_STATE) { - if (s->gzhead->name != Z_NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ - int val; - - do { - if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) { - val = 1; - break; - } - } - val = s->gzhead->name[s->gzindex++]; - put_byte(s, val); - } while (val != 0); - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (val == 0) { - s->gzindex = 0; - s->status = COMMENT_STATE; - } - } - else - s->status = COMMENT_STATE; - } - if (s->status == COMMENT_STATE) { - if (s->gzhead->comment != Z_NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ - int val; - - do { - if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) { - val = 1; - break; - } - } - val = s->gzhead->comment[s->gzindex++]; - put_byte(s, val); - } while (val != 0); - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (val == 0) - s->status = HCRC_STATE; - } - else - s->status = HCRC_STATE; - } - if (s->status == HCRC_STATE) { - if (s->gzhead->hcrc) { - if (s->pending + 2 > s->pending_buf_size) - flush_pending(strm); - if (s->pending + 2 <= s->pending_buf_size) { - put_byte(s, (Byte)(strm->adler & 0xff)); - put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); - strm->adler = crc32(0L, Z_NULL, 0); - s->status = BUSY_STATE; - } - } - else - s->status = BUSY_STATE; - } -#endif - - /* Flush as much pending output as possible */ - if (s->pending != 0) { - flush_pending(strm); - if (strm->avail_out == 0) { - /* Since avail_out is 0, deflate will be called again with - * more output space, but possibly with both pending and - * avail_in equal to zero. There won't be anything to do, - * but this is not an error situation so make sure we - * return OK instead of BUF_ERROR at next call of deflate: - */ - s->last_flush = -1; - return Z_OK; - } - - /* Make sure there is something to do and avoid duplicate consecutive - * flushes. For repeated and useless calls with Z_FINISH, we keep - * returning Z_STREAM_END instead of Z_BUF_ERROR. - */ - } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) && - flush != Z_FINISH) { - ERR_RETURN(strm, Z_BUF_ERROR); - } - - /* User must not provide more input after the first FINISH: */ - if (s->status == FINISH_STATE && strm->avail_in != 0) { - ERR_RETURN(strm, Z_BUF_ERROR); - } - - /* Start a new block or continue the current one. - */ - if (strm->avail_in != 0 || s->lookahead != 0 || - (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { - block_state bstate; - - bstate = s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : - (s->strategy == Z_RLE ? deflate_rle(s, flush) : - (*(configuration_table[s->level].func))(s, flush)); - - if (bstate == finish_started || bstate == finish_done) { - s->status = FINISH_STATE; - } - if (bstate == need_more || bstate == finish_started) { - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ - } - return Z_OK; - /* If flush != Z_NO_FLUSH && avail_out == 0, the next call - * of deflate should use the same flush parameter to make sure - * that the flush is complete. So we don't have to output an - * empty block here, this will be done at next call. This also - * ensures that for a very small output buffer, we emit at most - * one empty block. - */ - } - if (bstate == block_done) { - if (flush == Z_PARTIAL_FLUSH) { - _tr_align(s); - } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */ - _tr_stored_block(s, (char*)0, 0L, 0); - /* For a full flush, this empty block will be recognized - * as a special marker by inflate_sync(). - */ - if (flush == Z_FULL_FLUSH) { - CLEAR_HASH(s); /* forget history */ - if (s->lookahead == 0) { - s->strstart = 0; - s->block_start = 0L; - s->insert = 0; - } - } - } - flush_pending(strm); - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ - return Z_OK; - } - } - } - Assert(strm->avail_out > 0, "bug2"); - - if (flush != Z_FINISH) return Z_OK; - if (s->wrap <= 0) return Z_STREAM_END; - - /* Write the trailer */ -#ifdef GZIP - if (s->wrap == 2) { - put_byte(s, (Byte)(strm->adler & 0xff)); - put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); - put_byte(s, (Byte)((strm->adler >> 16) & 0xff)); - put_byte(s, (Byte)((strm->adler >> 24) & 0xff)); - put_byte(s, (Byte)(strm->total_in & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 8) & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 16) & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 24) & 0xff)); - } - else -#endif - { - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); - } - flush_pending(strm); - /* If avail_out is zero, the application will call deflate again - * to flush the rest. - */ - if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */ - return s->pending != 0 ? Z_OK : Z_STREAM_END; -} - -/* ========================================================================= */ -int ZEXPORT deflateEnd (strm) - z_streamp strm; -{ - int status; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - - status = strm->state->status; - if (status != INIT_STATE && - status != EXTRA_STATE && - status != NAME_STATE && - status != COMMENT_STATE && - status != HCRC_STATE && - status != BUSY_STATE && - status != FINISH_STATE) { - return Z_STREAM_ERROR; - } - - /* Deallocate in reverse order of allocations: */ - TRY_FREE(strm, strm->state->pending_buf); - TRY_FREE(strm, strm->state->head); - TRY_FREE(strm, strm->state->prev); - TRY_FREE(strm, strm->state->window); - - ZFREE(strm, strm->state); - strm->state = Z_NULL; - - return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; -} - -/* ========================================================================= - * Copy the source state to the destination state. - * To simplify the source, this is not supported for 16-bit MSDOS (which - * doesn't have enough memory anyway to duplicate compression states). - */ -int ZEXPORT deflateCopy (dest, source) - z_streamp dest; - z_streamp source; -{ -#ifdef MAXSEG_64K - return Z_STREAM_ERROR; -#else - deflate_state *ds; - deflate_state *ss; - ushf *overlay; - - - if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { - return Z_STREAM_ERROR; - } - - ss = source->state; - - zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream)); - - ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); - if (ds == Z_NULL) return Z_MEM_ERROR; - dest->state = (struct internal_state FAR *) ds; - zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state)); - ds->strm = dest; - - ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); - ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); - ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); - overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2); - ds->pending_buf = (uchf *) overlay; - - if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || - ds->pending_buf == Z_NULL) { - deflateEnd (dest); - return Z_MEM_ERROR; - } - /* following zmemcpy do not work for 16-bit MSDOS */ - zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); - zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos)); - zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos)); - zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); - - ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); - ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush); - ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize; - - ds->l_desc.dyn_tree = ds->dyn_ltree; - ds->d_desc.dyn_tree = ds->dyn_dtree; - ds->bl_desc.dyn_tree = ds->bl_tree; - - return Z_OK; -#endif /* MAXSEG_64K */ -} - -/* =========================================================================== - * Read a new buffer from the current input stream, update the adler32 - * and total number of bytes read. All deflate() input goes through - * this function so some applications may wish to modify it to avoid - * allocating a large strm->next_in buffer and copying from it. - * (See also flush_pending()). - */ -local int read_buf(strm, buf, size) - z_streamp strm; - Bytef *buf; - unsigned size; -{ - unsigned len = strm->avail_in; - - if (len > size) len = size; - if (len == 0) return 0; - - strm->avail_in -= len; - - zmemcpy(buf, strm->next_in, len); - if (strm->state->wrap == 1) { - strm->adler = adler32(strm->adler, buf, len); - } -#ifdef GZIP - else if (strm->state->wrap == 2) { - strm->adler = crc32(strm->adler, buf, len); - } -#endif - strm->next_in += len; - strm->total_in += len; - - return (int)len; -} - -/* =========================================================================== - * Initialize the "longest match" routines for a new zlib stream - */ -local void lm_init (s) - deflate_state *s; -{ - s->window_size = (ulg)2L*s->w_size; - - CLEAR_HASH(s); - - /* Set the default configuration parameters: - */ - s->max_lazy_match = configuration_table[s->level].max_lazy; - s->good_match = configuration_table[s->level].good_length; - s->nice_match = configuration_table[s->level].nice_length; - s->max_chain_length = configuration_table[s->level].max_chain; - - s->strstart = 0; - s->block_start = 0L; - s->lookahead = 0; - s->insert = 0; - s->match_length = s->prev_length = MIN_MATCH-1; - s->match_available = 0; - s->ins_h = 0; -#ifndef FASTEST -#ifdef ASMV - match_init(); /* initialize the asm code */ -#endif -#endif -} - -#ifndef FASTEST -/* =========================================================================== - * Set match_start to the longest match starting at the given string and - * return its length. Matches shorter or equal to prev_length are discarded, - * in which case the result is equal to prev_length and match_start is - * garbage. - * IN assertions: cur_match is the head of the hash chain for the current - * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 - * OUT assertion: the match length is not greater than s->lookahead. - */ -#ifndef ASMV -/* For 80x86 and 680x0, an optimized version will be provided in match.asm or - * match.S. The code will be functionally equivalent. - */ -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ - unsigned chain_length = s->max_chain_length;/* max hash chain length */ - register Bytef *scan = s->window + s->strstart; /* current string */ - register Bytef *match; /* matched string */ - register int len; /* length of current match */ - int best_len = s->prev_length; /* best match length so far */ - int nice_match = s->nice_match; /* stop if match long enough */ - IPos limit = s->strstart > (IPos)MAX_DIST(s) ? - s->strstart - (IPos)MAX_DIST(s) : NIL; - /* Stop when cur_match becomes <= limit. To simplify the code, - * we prevent matches with the string of window index 0. - */ - Posf *prev = s->prev; - uInt wmask = s->w_mask; - -#ifdef UNALIGNED_OK - /* Compare two bytes at a time. Note: this is not always beneficial. - * Try with and without -DUNALIGNED_OK to check. - */ - register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; - register ush scan_start = *(ushf*)scan; - register ush scan_end = *(ushf*)(scan+best_len-1); -#else - register Bytef *strend = s->window + s->strstart + MAX_MATCH; - register Byte scan_end1 = scan[best_len-1]; - register Byte scan_end = scan[best_len]; -#endif - - /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. - * It is easy to get rid of this optimization if necessary. - */ - Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); - - /* Do not waste too much time if we already have a good match: */ - if (s->prev_length >= s->good_match) { - chain_length >>= 2; - } - /* Do not look for matches beyond the end of the input. This is necessary - * to make deflate deterministic. - */ - if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; - - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); - - do { - Assert(cur_match < s->strstart, "no future"); - match = s->window + cur_match; - - /* Skip to next match if the match length cannot increase - * or if the match length is less than 2. Note that the checks below - * for insufficient lookahead only occur occasionally for performance - * reasons. Therefore uninitialized memory will be accessed, and - * conditional jumps will be made that depend on those values. - * However the length of the match is limited to the lookahead, so - * the output of deflate is not affected by the uninitialized values. - */ -#if (defined(UNALIGNED_OK) && MAX_MATCH == 258) - /* This code assumes sizeof(unsigned short) == 2. Do not use - * UNALIGNED_OK if your compiler uses a different size. - */ - if (*(ushf*)(match+best_len-1) != scan_end || - *(ushf*)match != scan_start) continue; - - /* It is not necessary to compare scan[2] and match[2] since they are - * always equal when the other bytes match, given that the hash keys - * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at - * strstart+3, +5, ... up to strstart+257. We check for insufficient - * lookahead only every 4th comparison; the 128th check will be made - * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is - * necessary to put more guard bytes at the end of the window, or - * to check more often for insufficient lookahead. - */ - Assert(scan[2] == match[2], "scan[2]?"); - scan++, match++; - do { - } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - scan < strend); - /* The funny "do {}" generates better code on most compilers */ - - /* Here, scan <= window+strstart+257 */ - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - if (*scan == *match) scan++; - - len = (MAX_MATCH - 1) - (int)(strend-scan); - scan = strend - (MAX_MATCH-1); - -#else /* UNALIGNED_OK */ - - if (match[best_len] != scan_end || - match[best_len-1] != scan_end1 || - *match != *scan || - *++match != scan[1]) continue; - - /* The check at best_len-1 can be removed because it will be made - * again later. (This heuristic is not always a win.) - * It is not necessary to compare scan[2] and match[2] since they - * are always equal when the other bytes match, given that - * the hash keys are equal and that HASH_BITS >= 8. - */ - scan += 2, match++; - Assert(*scan == *match, "match[2]?"); - - /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. - */ - do { - } while (*++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - scan < strend); - - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - - len = MAX_MATCH - (int)(strend - scan); - scan = strend - MAX_MATCH; - -#endif /* UNALIGNED_OK */ - - if (len > best_len) { - s->match_start = cur_match; - best_len = len; - if (len >= nice_match) break; -#ifdef UNALIGNED_OK - scan_end = *(ushf*)(scan+best_len-1); -#else - scan_end1 = scan[best_len-1]; - scan_end = scan[best_len]; -#endif - } - } while ((cur_match = prev[cur_match & wmask]) > limit - && --chain_length != 0); - - if ((uInt)best_len <= s->lookahead) return (uInt)best_len; - return s->lookahead; -} -#endif /* ASMV */ - -#else /* FASTEST */ - -/* --------------------------------------------------------------------------- - * Optimized version for FASTEST only - */ -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ - register Bytef *scan = s->window + s->strstart; /* current string */ - register Bytef *match; /* matched string */ - register int len; /* length of current match */ - register Bytef *strend = s->window + s->strstart + MAX_MATCH; - - /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. - * It is easy to get rid of this optimization if necessary. - */ - Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); - - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); - - Assert(cur_match < s->strstart, "no future"); - - match = s->window + cur_match; - - /* Return failure if the match length is less than 2: - */ - if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1; - - /* The check at best_len-1 can be removed because it will be made - * again later. (This heuristic is not always a win.) - * It is not necessary to compare scan[2] and match[2] since they - * are always equal when the other bytes match, given that - * the hash keys are equal and that HASH_BITS >= 8. - */ - scan += 2, match += 2; - Assert(*scan == *match, "match[2]?"); - - /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. - */ - do { - } while (*++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - scan < strend); - - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - - len = MAX_MATCH - (int)(strend - scan); - - if (len < MIN_MATCH) return MIN_MATCH - 1; - - s->match_start = cur_match; - return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead; -} - -#endif /* FASTEST */ - -#ifdef DEBUG -/* =========================================================================== - * Check that the match at match_start is indeed a match. - */ -local void check_match(s, start, match, length) - deflate_state *s; - IPos start, match; - int length; -{ - /* check that the match is indeed a match */ - if (zmemcmp(s->window + match, - s->window + start, length) != EQUAL) { - fprintf(stderr, " start %u, match %u, length %d\n", - start, match, length); - do { - fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); - } while (--length != 0); - z_error("invalid match"); - } - if (z_verbose > 1) { - fprintf(stderr,"\\[%d,%d]", start-match, length); - do { putc(s->window[start++], stderr); } while (--length != 0); - } -} -#else -# define check_match(s, start, match, length) -#endif /* DEBUG */ - -/* =========================================================================== - * Fill the window when the lookahead becomes insufficient. - * Updates strstart and lookahead. - * - * IN assertion: lookahead < MIN_LOOKAHEAD - * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD - * At least one byte has been read, or avail_in == 0; reads are - * performed for at least two bytes (required for the zip translate_eol - * option -- not supported here). - */ -local void fill_window(s) - deflate_state *s; -{ - register unsigned n, m; - register Posf *p; - unsigned more; /* Amount of free space at the end of the window. */ - uInt wsize = s->w_size; - - Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); - - do { - more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); - - /* Deal with !@#$% 64K limit: */ - if (sizeof(int) <= 2) { - if (more == 0 && s->strstart == 0 && s->lookahead == 0) { - more = wsize; - - } else if (more == (unsigned)(-1)) { - /* Very unlikely, but possible on 16 bit machine if - * strstart == 0 && lookahead == 1 (input done a byte at time) - */ - more--; - } - } - - /* If the window is almost full and there is insufficient lookahead, - * move the upper half to the lower one to make room in the upper half. - */ - if (s->strstart >= wsize+MAX_DIST(s)) { - - zmemcpy(s->window, s->window+wsize, (unsigned)wsize); - s->match_start -= wsize; - s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ - s->block_start -= (long) wsize; - - /* Slide the hash table (could be avoided with 32 bit values - at the expense of memory usage). We slide even when level == 0 - to keep the hash table consistent if we switch back to level > 0 - later. (Using level 0 permanently is not an optimal usage of - zlib, so we don't care about this pathological case.) - */ - n = s->hash_size; - p = &s->head[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - } while (--n); - - n = wsize; -#ifndef FASTEST - p = &s->prev[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - /* If n is not on any hash chain, prev[n] is garbage but - * its value will never be used. - */ - } while (--n); -#endif - more += wsize; - } - if (s->strm->avail_in == 0) break; - - /* If there was no sliding: - * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && - * more == window_size - lookahead - strstart - * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) - * => more >= window_size - 2*WSIZE + 2 - * In the BIG_MEM or MMAP case (not yet supported), - * window_size == input_size + MIN_LOOKAHEAD && - * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. - * Otherwise, window_size == 2*WSIZE so more >= 2. - * If there was sliding, more >= WSIZE. So in all cases, more >= 2. - */ - Assert(more >= 2, "more < 2"); - - n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); - s->lookahead += n; - - /* Initialize the hash value now that we have some input: */ - if (s->lookahead + s->insert >= MIN_MATCH) { - uInt str = s->strstart - s->insert; - s->ins_h = s->window[str]; - UPDATE_HASH(s, s->ins_h, s->window[str + 1]); -#if MIN_MATCH != 3 - Call UPDATE_HASH() MIN_MATCH-3 more times -#endif - while (s->insert) { - UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); -#ifndef FASTEST - s->prev[str & s->w_mask] = s->head[s->ins_h]; -#endif - s->head[s->ins_h] = (Pos)str; - str++; - s->insert--; - if (s->lookahead + s->insert < MIN_MATCH) - break; - } - } - /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, - * but this is not important since only literal bytes will be emitted. - */ - - } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); - - /* If the WIN_INIT bytes after the end of the current data have never been - * written, then zero those bytes in order to avoid memory check reports of - * the use of uninitialized (or uninitialised as Julian writes) bytes by - * the longest match routines. Update the high water mark for the next - * time through here. WIN_INIT is set to MAX_MATCH since the longest match - * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. - */ - if (s->high_water < s->window_size) { - ulg curr = s->strstart + (ulg)(s->lookahead); - ulg init; - - if (s->high_water < curr) { - /* Previous high water mark below current data -- zero WIN_INIT - * bytes or up to end of window, whichever is less. - */ - init = s->window_size - curr; - if (init > WIN_INIT) - init = WIN_INIT; - zmemzero(s->window + curr, (unsigned)init); - s->high_water = curr + init; - } - else if (s->high_water < (ulg)curr + WIN_INIT) { - /* High water mark at or above current data, but below current data - * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up - * to end of window, whichever is less. - */ - init = (ulg)curr + WIN_INIT - s->high_water; - if (init > s->window_size - s->high_water) - init = s->window_size - s->high_water; - zmemzero(s->window + s->high_water, (unsigned)init); - s->high_water += init; - } - } - - Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, - "not enough room for search"); -} - -/* =========================================================================== - * Flush the current block, with given end-of-file flag. - * IN assertion: strstart is set to the end of the current match. - */ -#define FLUSH_BLOCK_ONLY(s, last) { \ - _tr_flush_block(s, (s->block_start >= 0L ? \ - (charf *)&s->window[(unsigned)s->block_start] : \ - (charf *)Z_NULL), \ - (ulg)((long)s->strstart - s->block_start), \ - (last)); \ - s->block_start = s->strstart; \ - flush_pending(s->strm); \ - Tracev((stderr,"[FLUSH]")); \ -} - -/* Same but force premature exit if necessary. */ -#define FLUSH_BLOCK(s, last) { \ - FLUSH_BLOCK_ONLY(s, last); \ - if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \ -} - -/* =========================================================================== - * Copy without compression as much as possible from the input stream, return - * the current block state. - * This function does not insert new strings in the dictionary since - * uncompressible data is probably not useful. This function is used - * only for the level=0 compression option. - * NOTE: this function should be optimized to avoid extra copying from - * window to pending_buf. - */ -local block_state deflate_stored(s, flush) - deflate_state *s; - int flush; -{ - /* Stored blocks are limited to 0xffff bytes, pending_buf is limited - * to pending_buf_size, and each stored block has a 5 byte header: - */ - ulg max_block_size = 0xffff; - ulg max_start; - - if (max_block_size > s->pending_buf_size - 5) { - max_block_size = s->pending_buf_size - 5; - } - - /* Copy as much as possible from input to output: */ - for (;;) { - /* Fill the window as much as possible: */ - if (s->lookahead <= 1) { - - Assert(s->strstart < s->w_size+MAX_DIST(s) || - s->block_start >= (long)s->w_size, "slide too late"); - - fill_window(s); - if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more; - - if (s->lookahead == 0) break; /* flush the current block */ - } - Assert(s->block_start >= 0L, "block gone"); - - s->strstart += s->lookahead; - s->lookahead = 0; - - /* Emit a stored block if pending_buf will be full: */ - max_start = s->block_start + max_block_size; - if (s->strstart == 0 || (ulg)s->strstart >= max_start) { - /* strstart == 0 is possible when wraparound on 16-bit machine */ - s->lookahead = (uInt)(s->strstart - max_start); - s->strstart = (uInt)max_start; - FLUSH_BLOCK(s, 0); - } - /* Flush if we may have to slide, otherwise block_start may become - * negative and the data will be gone: - */ - if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) { - FLUSH_BLOCK(s, 0); - } - } - s->insert = 0; - if (flush == Z_FINISH) { - FLUSH_BLOCK(s, 1); - return finish_done; - } - if ((long)s->strstart > s->block_start) - FLUSH_BLOCK(s, 0); - return block_done; -} - -/* =========================================================================== - * Compress as much as possible from the input stream, return the current - * block state. - * This function does not perform lazy evaluation of matches and inserts - * new strings in the dictionary only for unmatched strings or for short - * matches. It is used only for the fast compression options. - */ -local block_state deflate_fast(s, flush) - deflate_state *s; - int flush; -{ - IPos hash_head; /* head of the hash chain */ - int bflush; /* set if current block must be flushed */ - - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - if (s->lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - hash_head = NIL; - if (s->lookahead >= MIN_MATCH) { - INSERT_STRING(s, s->strstart, hash_head); - } - - /* Find the longest match, discarding those <= prev_length. - * At this point we have always match_length < MIN_MATCH - */ - if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ - s->match_length = longest_match (s, hash_head); - /* longest_match() sets match_start */ - } - if (s->match_length >= MIN_MATCH) { - check_match(s, s->strstart, s->match_start, s->match_length); - - _tr_tally_dist(s, s->strstart - s->match_start, - s->match_length - MIN_MATCH, bflush); - - s->lookahead -= s->match_length; - - /* Insert new strings in the hash table only if the match length - * is not too large. This saves time but degrades compression. - */ -#ifndef FASTEST - if (s->match_length <= s->max_insert_length && - s->lookahead >= MIN_MATCH) { - s->match_length--; /* string at strstart already in table */ - do { - s->strstart++; - INSERT_STRING(s, s->strstart, hash_head); - /* strstart never exceeds WSIZE-MAX_MATCH, so there are - * always MIN_MATCH bytes ahead. - */ - } while (--s->match_length != 0); - s->strstart++; - } else -#endif - { - s->strstart += s->match_length; - s->match_length = 0; - s->ins_h = s->window[s->strstart]; - UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); -#if MIN_MATCH != 3 - Call UPDATE_HASH() MIN_MATCH-3 more times -#endif - /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not - * matter since it will be recomputed at next deflate call. - */ - } - } else { - /* No match, output a literal byte */ - Tracevv((stderr,"%c", s->window[s->strstart])); - _tr_tally_lit (s, s->window[s->strstart], bflush); - s->lookahead--; - s->strstart++; - } - if (bflush) FLUSH_BLOCK(s, 0); - } - s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1; - if (flush == Z_FINISH) { - FLUSH_BLOCK(s, 1); - return finish_done; - } - if (s->last_lit) - FLUSH_BLOCK(s, 0); - return block_done; -} - -#ifndef FASTEST -/* =========================================================================== - * Same as above, but achieves better compression. We use a lazy - * evaluation for matches: a match is finally adopted only if there is - * no better match at the next window position. - */ -local block_state deflate_slow(s, flush) - deflate_state *s; - int flush; -{ - IPos hash_head; /* head of hash chain */ - int bflush; /* set if current block must be flushed */ - - /* Process the input block. */ - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - if (s->lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - hash_head = NIL; - if (s->lookahead >= MIN_MATCH) { - INSERT_STRING(s, s->strstart, hash_head); - } - - /* Find the longest match, discarding those <= prev_length. - */ - s->prev_length = s->match_length, s->prev_match = s->match_start; - s->match_length = MIN_MATCH-1; - - if (hash_head != NIL && s->prev_length < s->max_lazy_match && - s->strstart - hash_head <= MAX_DIST(s)) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ - s->match_length = longest_match (s, hash_head); - /* longest_match() sets match_start */ - - if (s->match_length <= 5 && (s->strategy == Z_FILTERED -#if TOO_FAR <= 32767 - || (s->match_length == MIN_MATCH && - s->strstart - s->match_start > TOO_FAR) -#endif - )) { - - /* If prev_match is also MIN_MATCH, match_start is garbage - * but we will ignore the current match anyway. - */ - s->match_length = MIN_MATCH-1; - } - } - /* If there was a match at the previous step and the current - * match is not better, output the previous match: - */ - if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) { - uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; - /* Do not insert strings in hash table beyond this. */ - - check_match(s, s->strstart-1, s->prev_match, s->prev_length); - - _tr_tally_dist(s, s->strstart -1 - s->prev_match, - s->prev_length - MIN_MATCH, bflush); - - /* Insert in hash table all strings up to the end of the match. - * strstart-1 and strstart are already inserted. If there is not - * enough lookahead, the last two strings are not inserted in - * the hash table. - */ - s->lookahead -= s->prev_length-1; - s->prev_length -= 2; - do { - if (++s->strstart <= max_insert) { - INSERT_STRING(s, s->strstart, hash_head); - } - } while (--s->prev_length != 0); - s->match_available = 0; - s->match_length = MIN_MATCH-1; - s->strstart++; - - if (bflush) FLUSH_BLOCK(s, 0); - - } else if (s->match_available) { - /* If there was no match at the previous position, output a - * single literal. If there was a match but the current match - * is longer, truncate the previous match to a single literal. - */ - Tracevv((stderr,"%c", s->window[s->strstart-1])); - _tr_tally_lit(s, s->window[s->strstart-1], bflush); - if (bflush) { - FLUSH_BLOCK_ONLY(s, 0); - } - s->strstart++; - s->lookahead--; - if (s->strm->avail_out == 0) return need_more; - } else { - /* There is no previous match to compare with, wait for - * the next step to decide. - */ - s->match_available = 1; - s->strstart++; - s->lookahead--; - } - } - Assert (flush != Z_NO_FLUSH, "no flush?"); - if (s->match_available) { - Tracevv((stderr,"%c", s->window[s->strstart-1])); - _tr_tally_lit(s, s->window[s->strstart-1], bflush); - s->match_available = 0; - } - s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1; - if (flush == Z_FINISH) { - FLUSH_BLOCK(s, 1); - return finish_done; - } - if (s->last_lit) - FLUSH_BLOCK(s, 0); - return block_done; -} -#endif /* FASTEST */ - -/* =========================================================================== - * For Z_RLE, simply look for runs of bytes, generate matches only of distance - * one. Do not maintain a hash table. (It will be regenerated if this run of - * deflate switches away from Z_RLE.) - */ -local block_state deflate_rle(s, flush) - deflate_state *s; - int flush; -{ - int bflush; /* set if current block must be flushed */ - uInt prev; /* byte at distance one to match */ - Bytef *scan, *strend; /* scan goes up to strend for length of run */ - - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the longest run, plus one for the unrolled loop. - */ - if (s->lookahead <= MAX_MATCH) { - fill_window(s); - if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* See how many times the previous byte repeats */ - s->match_length = 0; - if (s->lookahead >= MIN_MATCH && s->strstart > 0) { - scan = s->window + s->strstart - 1; - prev = *scan; - if (prev == *++scan && prev == *++scan && prev == *++scan) { - strend = s->window + s->strstart + MAX_MATCH; - do { - } while (prev == *++scan && prev == *++scan && - prev == *++scan && prev == *++scan && - prev == *++scan && prev == *++scan && - prev == *++scan && prev == *++scan && - scan < strend); - s->match_length = MAX_MATCH - (int)(strend - scan); - if (s->match_length > s->lookahead) - s->match_length = s->lookahead; - } - Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan"); - } - - /* Emit match if have run of MIN_MATCH or longer, else emit literal */ - if (s->match_length >= MIN_MATCH) { - check_match(s, s->strstart, s->strstart - 1, s->match_length); - - _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush); - - s->lookahead -= s->match_length; - s->strstart += s->match_length; - s->match_length = 0; - } else { - /* No match, output a literal byte */ - Tracevv((stderr,"%c", s->window[s->strstart])); - _tr_tally_lit (s, s->window[s->strstart], bflush); - s->lookahead--; - s->strstart++; - } - if (bflush) FLUSH_BLOCK(s, 0); - } - s->insert = 0; - if (flush == Z_FINISH) { - FLUSH_BLOCK(s, 1); - return finish_done; - } - if (s->last_lit) - FLUSH_BLOCK(s, 0); - return block_done; -} - -/* =========================================================================== - * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table. - * (It will be regenerated if this run of deflate switches away from Huffman.) - */ -local block_state deflate_huff(s, flush) - deflate_state *s; - int flush; -{ - int bflush; /* set if current block must be flushed */ - - for (;;) { - /* Make sure that we have a literal to write. */ - if (s->lookahead == 0) { - fill_window(s); - if (s->lookahead == 0) { - if (flush == Z_NO_FLUSH) - return need_more; - break; /* flush the current block */ - } - } - - /* Output a literal byte */ - s->match_length = 0; - Tracevv((stderr,"%c", s->window[s->strstart])); - _tr_tally_lit (s, s->window[s->strstart], bflush); - s->lookahead--; - s->strstart++; - if (bflush) FLUSH_BLOCK(s, 0); - } - s->insert = 0; - if (flush == Z_FINISH) { - FLUSH_BLOCK(s, 1); - return finish_done; - } - if (s->last_lit) - FLUSH_BLOCK(s, 0); - return block_done; -} diff --git a/libs/zlib/src/deflate.h b/libs/zlib/src/deflate.h deleted file mode 100644 index 57a8d376..00000000 --- a/libs/zlib/src/deflate.h +++ /dev/null @@ -1,346 +0,0 @@ -/* deflate.h -- internal compression state - * Copyright (C) 1995-2012 Jean-loup Gailly - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* @(#) $Id: deflate.h,v 1.2 2013/08/12 09:54:03 martinprikryl Exp $ */ - -#ifndef DEFLATE_H -#define DEFLATE_H - -#include "zutil.h" - -/* define NO_GZIP when compiling if you want to disable gzip header and - trailer creation by deflate(). NO_GZIP would be used to avoid linking in - the crc code when it is not needed. For shared libraries, gzip encoding - should be left enabled. */ -#ifndef NO_GZIP -# define GZIP -#endif - -/* =========================================================================== - * Internal compression state. - */ - -#define LENGTH_CODES 29 -/* number of length codes, not counting the special END_BLOCK code */ - -#define LITERALS 256 -/* number of literal bytes 0..255 */ - -#define L_CODES (LITERALS+1+LENGTH_CODES) -/* number of Literal or Length codes, including the END_BLOCK code */ - -#define D_CODES 30 -/* number of distance codes */ - -#define BL_CODES 19 -/* number of codes used to transfer the bit lengths */ - -#define HEAP_SIZE (2*L_CODES+1) -/* maximum heap size */ - -#define MAX_BITS 15 -/* All codes must not exceed MAX_BITS bits */ - -#define Buf_size 16 -/* size of bit buffer in bi_buf */ - -#define INIT_STATE 42 -#define EXTRA_STATE 69 -#define NAME_STATE 73 -#define COMMENT_STATE 91 -#define HCRC_STATE 103 -#define BUSY_STATE 113 -#define FINISH_STATE 666 -/* Stream status */ - - -/* Data structure describing a single value and its code string. */ -typedef struct ct_data_s { - union { - ush freq; /* frequency count */ - ush code; /* bit string */ - } fc; - union { - ush dad; /* father node in Huffman tree */ - ush len; /* length of bit string */ - } dl; -} FAR ct_data; - -#define Freq fc.freq -#define Code fc.code -#define Dad dl.dad -#define Len dl.len - -typedef struct static_tree_desc_s static_tree_desc; - -typedef struct tree_desc_s { - ct_data *dyn_tree; /* the dynamic tree */ - int max_code; /* largest code with non zero frequency */ - static_tree_desc *stat_desc; /* the corresponding static tree */ -} FAR tree_desc; - -typedef ush Pos; -typedef Pos FAR Posf; -typedef unsigned IPos; - -/* A Pos is an index in the character window. We use short instead of int to - * save space in the various tables. IPos is used only for parameter passing. - */ - -typedef struct internal_state { - z_streamp strm; /* pointer back to this zlib stream */ - int status; /* as the name implies */ - Bytef *pending_buf; /* output still pending */ - ulg pending_buf_size; /* size of pending_buf */ - Bytef *pending_out; /* next pending byte to output to the stream */ - uInt pending; /* nb of bytes in the pending buffer */ - int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ - gz_headerp gzhead; /* gzip header information to write */ - uInt gzindex; /* where in extra, name, or comment */ - Byte method; /* can only be DEFLATED */ - int last_flush; /* value of flush param for previous deflate call */ - - /* used by deflate.c: */ - - uInt w_size; /* LZ77 window size (32K by default) */ - uInt w_bits; /* log2(w_size) (8..16) */ - uInt w_mask; /* w_size - 1 */ - - Bytef *window; - /* Sliding window. Input bytes are read into the second half of the window, - * and move to the first half later to keep a dictionary of at least wSize - * bytes. With this organization, matches are limited to a distance of - * wSize-MAX_MATCH bytes, but this ensures that IO is always - * performed with a length multiple of the block size. Also, it limits - * the window size to 64K, which is quite useful on MSDOS. - * To do: use the user input buffer as sliding window. - */ - - ulg window_size; - /* Actual size of window: 2*wSize, except when the user input buffer - * is directly used as sliding window. - */ - - Posf *prev; - /* Link to older string with same hash index. To limit the size of this - * array to 64K, this link is maintained only for the last 32K strings. - * An index in this array is thus a window index modulo 32K. - */ - - Posf *head; /* Heads of the hash chains or NIL. */ - - uInt ins_h; /* hash index of string to be inserted */ - uInt hash_size; /* number of elements in hash table */ - uInt hash_bits; /* log2(hash_size) */ - uInt hash_mask; /* hash_size-1 */ - - uInt hash_shift; - /* Number of bits by which ins_h must be shifted at each input - * step. It must be such that after MIN_MATCH steps, the oldest - * byte no longer takes part in the hash key, that is: - * hash_shift * MIN_MATCH >= hash_bits - */ - - long block_start; - /* Window position at the beginning of the current output block. Gets - * negative when the window is moved backwards. - */ - - uInt match_length; /* length of best match */ - IPos prev_match; /* previous match */ - int match_available; /* set if previous match exists */ - uInt strstart; /* start of string to insert */ - uInt match_start; /* start of matching string */ - uInt lookahead; /* number of valid bytes ahead in window */ - - uInt prev_length; - /* Length of the best match at previous step. Matches not greater than this - * are discarded. This is used in the lazy match evaluation. - */ - - uInt max_chain_length; - /* To speed up deflation, hash chains are never searched beyond this - * length. A higher limit improves compression ratio but degrades the - * speed. - */ - - uInt max_lazy_match; - /* Attempt to find a better match only when the current match is strictly - * smaller than this value. This mechanism is used only for compression - * levels >= 4. - */ -# define max_insert_length max_lazy_match - /* Insert new strings in the hash table only if the match length is not - * greater than this length. This saves time but degrades compression. - * max_insert_length is used only for compression levels <= 3. - */ - - int level; /* compression level (1..9) */ - int strategy; /* favor or force Huffman coding*/ - - uInt good_match; - /* Use a faster search when the previous match is longer than this */ - - int nice_match; /* Stop searching when current match exceeds this */ - - /* used by trees.c: */ - /* Didn't use ct_data typedef below to suppress compiler warning */ - struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ - struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ - struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ - - struct tree_desc_s l_desc; /* desc. for literal tree */ - struct tree_desc_s d_desc; /* desc. for distance tree */ - struct tree_desc_s bl_desc; /* desc. for bit length tree */ - - ush bl_count[MAX_BITS+1]; - /* number of codes at each bit length for an optimal tree */ - - int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ - int heap_len; /* number of elements in the heap */ - int heap_max; /* element of largest frequency */ - /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. - * The same heap array is used to build all trees. - */ - - uch depth[2*L_CODES+1]; - /* Depth of each subtree used as tie breaker for trees of equal frequency - */ - - uchf *l_buf; /* buffer for literals or lengths */ - - uInt lit_bufsize; - /* Size of match buffer for literals/lengths. There are 4 reasons for - * limiting lit_bufsize to 64K: - * - frequencies can be kept in 16 bit counters - * - if compression is not successful for the first block, all input - * data is still in the window so we can still emit a stored block even - * when input comes from standard input. (This can also be done for - * all blocks if lit_bufsize is not greater than 32K.) - * - if compression is not successful for a file smaller than 64K, we can - * even emit a stored file instead of a stored block (saving 5 bytes). - * This is applicable only for zip (not gzip or zlib). - * - creating new Huffman trees less frequently may not provide fast - * adaptation to changes in the input data statistics. (Take for - * example a binary file with poorly compressible code followed by - * a highly compressible string table.) Smaller buffer sizes give - * fast adaptation but have of course the overhead of transmitting - * trees more frequently. - * - I can't count above 4 - */ - - uInt last_lit; /* running index in l_buf */ - - ushf *d_buf; - /* Buffer for distances. To simplify the code, d_buf and l_buf have - * the same number of elements. To use different lengths, an extra flag - * array would be necessary. - */ - - ulg opt_len; /* bit length of current block with optimal trees */ - ulg static_len; /* bit length of current block with static trees */ - uInt matches; /* number of string matches in current block */ - uInt insert; /* bytes at end of window left to insert */ - -#ifdef DEBUG - ulg compressed_len; /* total bit length of compressed file mod 2^32 */ - ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ -#endif - - ush bi_buf; - /* Output buffer. bits are inserted starting at the bottom (least - * significant bits). - */ - int bi_valid; - /* Number of valid bits in bi_buf. All bits above the last valid bit - * are always zero. - */ - - ulg high_water; - /* High water mark offset in window for initialized bytes -- bytes above - * this are set to zero in order to avoid memory check warnings when - * longest match routines access bytes past the input. This is then - * updated to the new high water mark. - */ - -} FAR deflate_state; - -/* Output a byte on the stream. - * IN assertion: there is enough room in pending_buf. - */ -#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} - - -#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) -/* Minimum amount of lookahead, except at the end of the input file. - * See deflate.c for comments about the MIN_MATCH+1. - */ - -#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) -/* In order to simplify the code, particularly on 16 bit machines, match - * distances are limited to MAX_DIST instead of WSIZE. - */ - -#define WIN_INIT MAX_MATCH -/* Number of bytes after end of data in window to initialize in order to avoid - memory checker errors from longest match routines */ - - /* in trees.c */ -void ZLIB_INTERNAL _tr_init OF((deflate_state *s)); -int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); -void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, - ulg stored_len, int last)); -void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s)); -void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); -void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, - ulg stored_len, int last)); - -#define d_code(dist) \ - ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) -/* Mapping from a distance to a distance code. dist is the distance - 1 and - * must not have side effects. _dist_code[256] and _dist_code[257] are never - * used. - */ - -#ifndef DEBUG -/* Inline versions of _tr_tally for speed: */ - -#if defined(GEN_TREES_H) || !defined(STDC) - extern uch ZLIB_INTERNAL _length_code[]; - extern uch ZLIB_INTERNAL _dist_code[]; -#else - extern const uch ZLIB_INTERNAL _length_code[]; - extern const uch ZLIB_INTERNAL _dist_code[]; -#endif - -# define _tr_tally_lit(s, c, flush) \ - { uch cc = (c); \ - s->d_buf[s->last_lit] = 0; \ - s->l_buf[s->last_lit++] = cc; \ - s->dyn_ltree[cc].Freq++; \ - flush = (s->last_lit == s->lit_bufsize-1); \ - } -# define _tr_tally_dist(s, distance, length, flush) \ - { uch len = (length); \ - ush dist = (distance); \ - s->d_buf[s->last_lit] = dist; \ - s->l_buf[s->last_lit++] = len; \ - dist--; \ - s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ - s->dyn_dtree[d_code(dist)].Freq++; \ - flush = (s->last_lit == s->lit_bufsize-1); \ - } -#else -# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) -# define _tr_tally_dist(s, distance, length, flush) \ - flush = _tr_tally(s, distance, length) -#endif - -#endif /* DEFLATE_H */ diff --git a/libs/zlib/src/gzclose.c b/libs/zlib/src/gzclose.c deleted file mode 100644 index caeb99a3..00000000 --- a/libs/zlib/src/gzclose.c +++ /dev/null @@ -1,25 +0,0 @@ -/* gzclose.c -- zlib gzclose() function - * Copyright (C) 2004, 2010 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "gzguts.h" - -/* gzclose() is in a separate file so that it is linked in only if it is used. - That way the other gzclose functions can be used instead to avoid linking in - unneeded compression or decompression routines. */ -int ZEXPORT gzclose(file) - gzFile file; -{ -#ifndef NO_GZCOMPRESS - gz_statep state; - - if (file == NULL) - return Z_STREAM_ERROR; - state = (gz_statep)file; - - return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); -#else - return gzclose_r(file); -#endif -} diff --git a/libs/zlib/src/gzguts.h b/libs/zlib/src/gzguts.h deleted file mode 100644 index d87659d0..00000000 --- a/libs/zlib/src/gzguts.h +++ /dev/null @@ -1,209 +0,0 @@ -/* gzguts.h -- zlib internal header definitions for gz* operations - * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#ifdef _LARGEFILE64_SOURCE -# ifndef _LARGEFILE_SOURCE -# define _LARGEFILE_SOURCE 1 -# endif -# ifdef _FILE_OFFSET_BITS -# undef _FILE_OFFSET_BITS -# endif -#endif - -#ifdef HAVE_HIDDEN -# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) -#else -# define ZLIB_INTERNAL -#endif - -#include -#include "zlib.h" -#ifdef STDC -# include -# include -# include -#endif -#include - -#ifdef _WIN32 -# include -#endif - -#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32) -# include -#endif - -#ifdef WINAPI_FAMILY -# define open _open -# define read _read -# define write _write -# define close _close -#endif - -#ifdef NO_DEFLATE /* for compatibility with old definition */ -# define NO_GZCOMPRESS -#endif - -#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif - -#if defined(__CYGWIN__) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif - -#if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif - -#ifndef HAVE_VSNPRINTF -# ifdef MSDOS -/* vsnprintf may exist on some MS-DOS compilers (DJGPP?), - but for now we just assume it doesn't. */ -# define NO_vsnprintf -# endif -# ifdef __TURBOC__ -# define NO_vsnprintf -# endif -# ifdef WIN32 -/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ -# if !defined(vsnprintf) && !defined(NO_vsnprintf) -# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) -# define vsnprintf _vsnprintf -# endif -# endif -# endif -# ifdef __SASC -# define NO_vsnprintf -# endif -# ifdef VMS -# define NO_vsnprintf -# endif -# ifdef __OS400__ -# define NO_vsnprintf -# endif -# ifdef __MVS__ -# define NO_vsnprintf -# endif -#endif - -/* unlike snprintf (which is required in C99, yet still not supported by - Microsoft more than a decade later!), _snprintf does not guarantee null - termination of the result -- however this is only used in gzlib.c where - the result is assured to fit in the space provided */ -#ifdef _MSC_VER -# define snprintf _snprintf -#endif - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - -/* gz* functions always use library allocation functions */ -#ifndef STDC - extern voidp malloc OF((uInt size)); - extern void free OF((voidpf ptr)); -#endif - -/* get errno and strerror definition */ -#if defined UNDER_CE -# include -# define zstrerror() gz_strwinerror((DWORD)GetLastError()) -#else -# ifndef NO_STRERROR -# include -# define zstrerror() strerror(errno) -# else -# define zstrerror() "stdio error (consult errno)" -# endif -#endif - -/* provide prototypes for these when building zlib without LFS */ -#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); - ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); -#endif - -/* default memLevel */ -#if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -#else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif - -/* default i/o buffer size -- double this for output when reading (this and - twice this must be able to fit in an unsigned type) */ -#define GZBUFSIZE 8192 - -/* gzip modes, also provide a little integrity check on the passed structure */ -#define GZ_NONE 0 -#define GZ_READ 7247 -#define GZ_WRITE 31153 -#define GZ_APPEND 1 /* mode set to GZ_WRITE after the file is opened */ - -/* values for gz_state how */ -#define LOOK 0 /* look for a gzip header */ -#define COPY 1 /* copy input directly */ -#define GZIP 2 /* decompress a gzip stream */ - -/* internal gzip file state data structure */ -typedef struct { - /* exposed contents for gzgetc() macro */ - struct gzFile_s x; /* "x" for exposed */ - /* x.have: number of bytes available at x.next */ - /* x.next: next output data to deliver or write */ - /* x.pos: current position in uncompressed data */ - /* used for both reading and writing */ - int mode; /* see gzip modes above */ - int fd; /* file descriptor */ - char *path; /* path or fd for error messages */ - unsigned size; /* buffer size, zero if not allocated yet */ - unsigned want; /* requested buffer size, default is GZBUFSIZE */ - unsigned char *in; /* input buffer */ - unsigned char *out; /* output buffer (double-sized when reading) */ - int direct; /* 0 if processing gzip, 1 if transparent */ - /* just for reading */ - int how; /* 0: get header, 1: copy, 2: decompress */ - z_off64_t start; /* where the gzip data started, for rewinding */ - int eof; /* true if end of input file reached */ - int past; /* true if read requested past end */ - /* just for writing */ - int level; /* compression level */ - int strategy; /* compression strategy */ - /* seek request */ - z_off64_t skip; /* amount to skip (already rewound if backwards) */ - int seek; /* true if seek request pending */ - /* error information */ - int err; /* error code */ - char *msg; /* error message */ - /* zlib inflate or deflate stream */ - z_stream strm; /* stream structure in-place (not a pointer) */ -} gz_state; -typedef gz_state FAR *gz_statep; - -/* shared functions */ -void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *)); -#if defined UNDER_CE -char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); -#endif - -/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t - value -- needed when comparing unsigned to z_off64_t, which is signed - (possible z_off64_t types off_t, off64_t, and long are all signed) */ -#ifdef INT_MAX -# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) -#else -unsigned ZLIB_INTERNAL gz_intmax OF((void)); -# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) -#endif diff --git a/libs/zlib/src/gzlib.c b/libs/zlib/src/gzlib.c deleted file mode 100644 index fae202ef..00000000 --- a/libs/zlib/src/gzlib.c +++ /dev/null @@ -1,634 +0,0 @@ -/* gzlib.c -- zlib functions common to reading and writing gzip files - * Copyright (C) 2004, 2010, 2011, 2012, 2013 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "gzguts.h" - -#if defined(_WIN32) && !defined(__BORLANDC__) -# define LSEEK _lseeki64 -#else -#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 -# define LSEEK lseek64 -#else -# define LSEEK lseek -#endif -#endif - -/* Local functions */ -local void gz_reset OF((gz_statep)); -local gzFile gz_open OF((const void *, int, const char *)); - -#if defined UNDER_CE - -/* Map the Windows error number in ERROR to a locale-dependent error message - string and return a pointer to it. Typically, the values for ERROR come - from GetLastError. - - The string pointed to shall not be modified by the application, but may be - overwritten by a subsequent call to gz_strwinerror - - The gz_strwinerror function does not change the current setting of - GetLastError. */ -char ZLIB_INTERNAL *gz_strwinerror (error) - DWORD error; -{ - static char buf[1024]; - - wchar_t *msgbuf; - DWORD lasterr = GetLastError(); - DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM - | FORMAT_MESSAGE_ALLOCATE_BUFFER, - NULL, - error, - 0, /* Default language */ - (LPVOID)&msgbuf, - 0, - NULL); - if (chars != 0) { - /* If there is an \r\n appended, zap it. */ - if (chars >= 2 - && msgbuf[chars - 2] == '\r' && msgbuf[chars - 1] == '\n') { - chars -= 2; - msgbuf[chars] = 0; - } - - if (chars > sizeof (buf) - 1) { - chars = sizeof (buf) - 1; - msgbuf[chars] = 0; - } - - wcstombs(buf, msgbuf, chars + 1); - LocalFree(msgbuf); - } - else { - sprintf(buf, "unknown win32 error (%ld)", error); - } - - SetLastError(lasterr); - return buf; -} - -#endif /* UNDER_CE */ - -/* Reset gzip file state */ -local void gz_reset(state) - gz_statep state; -{ - state->x.have = 0; /* no output data available */ - if (state->mode == GZ_READ) { /* for reading ... */ - state->eof = 0; /* not at end of file */ - state->past = 0; /* have not read past end yet */ - state->how = LOOK; /* look for gzip header */ - } - state->seek = 0; /* no seek request pending */ - gz_error(state, Z_OK, NULL); /* clear error */ - state->x.pos = 0; /* no uncompressed data yet */ - state->strm.avail_in = 0; /* no input data yet */ -} - -/* Open a gzip file either by name or file descriptor. */ -local gzFile gz_open(path, fd, mode) - const void *path; - int fd; - const char *mode; -{ - gz_statep state; - size_t len; - int oflag; -#ifdef O_CLOEXEC - int cloexec = 0; -#endif -#ifdef O_EXCL - int exclusive = 0; -#endif - - /* check input */ - if (path == NULL) - return NULL; - - /* allocate gzFile structure to return */ - state = (gz_statep)malloc(sizeof(gz_state)); - if (state == NULL) - return NULL; - state->size = 0; /* no buffers allocated yet */ - state->want = GZBUFSIZE; /* requested buffer size */ - state->msg = NULL; /* no error message yet */ - - /* interpret mode */ - state->mode = GZ_NONE; - state->level = Z_DEFAULT_COMPRESSION; - state->strategy = Z_DEFAULT_STRATEGY; - state->direct = 0; - while (*mode) { - if (*mode >= '0' && *mode <= '9') - state->level = *mode - '0'; - else - switch (*mode) { - case 'r': - state->mode = GZ_READ; - break; -#ifndef NO_GZCOMPRESS - case 'w': - state->mode = GZ_WRITE; - break; - case 'a': - state->mode = GZ_APPEND; - break; -#endif - case '+': /* can't read and write at the same time */ - free(state); - return NULL; - case 'b': /* ignore -- will request binary anyway */ - break; -#ifdef O_CLOEXEC - case 'e': - cloexec = 1; - break; -#endif -#ifdef O_EXCL - case 'x': - exclusive = 1; - break; -#endif - case 'f': - state->strategy = Z_FILTERED; - break; - case 'h': - state->strategy = Z_HUFFMAN_ONLY; - break; - case 'R': - state->strategy = Z_RLE; - break; - case 'F': - state->strategy = Z_FIXED; - break; - case 'T': - state->direct = 1; - break; - default: /* could consider as an error, but just ignore */ - ; - } - mode++; - } - - /* must provide an "r", "w", or "a" */ - if (state->mode == GZ_NONE) { - free(state); - return NULL; - } - - /* can't force transparent read */ - if (state->mode == GZ_READ) { - if (state->direct) { - free(state); - return NULL; - } - state->direct = 1; /* for empty file */ - } - - /* save the path name for error messages */ -#ifdef _WIN32 - if (fd == -2) { - len = wcstombs(NULL, path, 0); - if (len == (size_t)-1) - len = 0; - } - else -#endif - len = strlen((const char *)path); - state->path = (char *)malloc(len + 1); - if (state->path == NULL) { - free(state); - return NULL; - } -#ifdef _WIN32 - if (fd == -2) - if (len) - wcstombs(state->path, path, len + 1); - else - *(state->path) = 0; - else -#endif -#if !defined(NO_snprintf) && !defined(NO_vsnprintf) - snprintf(state->path, len + 1, "%s", (const char *)path); -#else - strcpy(state->path, path); -#endif - - /* compute the flags for open() */ - oflag = -#ifdef O_LARGEFILE - O_LARGEFILE | -#endif -#ifdef O_BINARY - O_BINARY | -#endif -#ifdef O_CLOEXEC - (cloexec ? O_CLOEXEC : 0) | -#endif - (state->mode == GZ_READ ? - O_RDONLY : - (O_WRONLY | O_CREAT | -#ifdef O_EXCL - (exclusive ? O_EXCL : 0) | -#endif - (state->mode == GZ_WRITE ? - O_TRUNC : - O_APPEND))); - - /* open the file with the appropriate flags (or just use fd) */ - state->fd = fd > -1 ? fd : ( -#ifdef _WIN32 - fd == -2 ? _wopen(path, oflag, 0666) : -#endif - open((const char *)path, oflag, 0666)); - if (state->fd == -1) { - free(state->path); - free(state); - return NULL; - } - if (state->mode == GZ_APPEND) - state->mode = GZ_WRITE; /* simplify later checks */ - - /* save the current position for rewinding (only if reading) */ - if (state->mode == GZ_READ) { - state->start = LSEEK(state->fd, 0, SEEK_CUR); - if (state->start == -1) state->start = 0; - } - - /* initialize stream */ - gz_reset(state); - - /* return stream */ - return (gzFile)state; -} - -/* -- see zlib.h -- */ -gzFile ZEXPORT gzopen(path, mode) - const char *path; - const char *mode; -{ - return gz_open(path, -1, mode); -} - -/* -- see zlib.h -- */ -gzFile ZEXPORT gzopen64(path, mode) - const char *path; - const char *mode; -{ - return gz_open(path, -1, mode); -} - -/* -- see zlib.h -- */ -gzFile ZEXPORT gzdopen(fd, mode) - int fd; - const char *mode; -{ - char *path; /* identifier for error messages */ - gzFile gz; - - if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL) - return NULL; -#if !defined(NO_snprintf) && !defined(NO_vsnprintf) - snprintf(path, 7 + 3 * sizeof(int), "", fd); /* for debugging */ -#else - sprintf(path, "", fd); /* for debugging */ -#endif - gz = gz_open(path, fd, mode); - free(path); - return gz; -} - -/* -- see zlib.h -- */ -#ifdef _WIN32 -gzFile ZEXPORT gzopen_w(path, mode) - const wchar_t *path; - const char *mode; -{ - return gz_open(path, -2, mode); -} -#endif - -/* -- see zlib.h -- */ -int ZEXPORT gzbuffer(file, size) - gzFile file; - unsigned size; -{ - gz_statep state; - - /* get internal structure and check integrity */ - if (file == NULL) - return -1; - state = (gz_statep)file; - if (state->mode != GZ_READ && state->mode != GZ_WRITE) - return -1; - - /* make sure we haven't already allocated memory */ - if (state->size != 0) - return -1; - - /* check and set requested size */ - if (size < 2) - size = 2; /* need two bytes to check magic header */ - state->want = size; - return 0; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzrewind(file) - gzFile file; -{ - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return -1; - state = (gz_statep)file; - - /* check that we're reading and that there's no error */ - if (state->mode != GZ_READ || - (state->err != Z_OK && state->err != Z_BUF_ERROR)) - return -1; - - /* back up and start over */ - if (LSEEK(state->fd, state->start, SEEK_SET) == -1) - return -1; - gz_reset(state); - return 0; -} - -/* -- see zlib.h -- */ -z_off64_t ZEXPORT gzseek64(file, offset, whence) - gzFile file; - z_off64_t offset; - int whence; -{ - unsigned n; - z_off64_t ret; - gz_statep state; - - /* get internal structure and check integrity */ - if (file == NULL) - return -1; - state = (gz_statep)file; - if (state->mode != GZ_READ && state->mode != GZ_WRITE) - return -1; - - /* check that there's no error */ - if (state->err != Z_OK && state->err != Z_BUF_ERROR) - return -1; - - /* can only seek from start or relative to current position */ - if (whence != SEEK_SET && whence != SEEK_CUR) - return -1; - - /* normalize offset to a SEEK_CUR specification */ - if (whence == SEEK_SET) - offset -= state->x.pos; - else if (state->seek) - offset += state->skip; - state->seek = 0; - - /* if within raw area while reading, just go there */ - if (state->mode == GZ_READ && state->how == COPY && - state->x.pos + offset >= 0) { - ret = LSEEK(state->fd, offset - state->x.have, SEEK_CUR); - if (ret == -1) - return -1; - state->x.have = 0; - state->eof = 0; - state->past = 0; - state->seek = 0; - gz_error(state, Z_OK, NULL); - state->strm.avail_in = 0; - state->x.pos += offset; - return state->x.pos; - } - - /* calculate skip amount, rewinding if needed for back seek when reading */ - if (offset < 0) { - if (state->mode != GZ_READ) /* writing -- can't go backwards */ - return -1; - offset += state->x.pos; - if (offset < 0) /* before start of file! */ - return -1; - if (gzrewind(file) == -1) /* rewind, then skip to offset */ - return -1; - } - - /* if reading, skip what's in output buffer (one less gzgetc() check) */ - if (state->mode == GZ_READ) { - n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > offset ? - (unsigned)offset : state->x.have; - state->x.have -= n; - state->x.next += n; - state->x.pos += n; - offset -= n; - } - - /* request skip (if not zero) */ - if (offset) { - state->seek = 1; - state->skip = offset; - } - return state->x.pos + offset; -} - -/* -- see zlib.h -- */ -z_off_t ZEXPORT gzseek(file, offset, whence) - gzFile file; - z_off_t offset; - int whence; -{ - z_off64_t ret; - - ret = gzseek64(file, (z_off64_t)offset, whence); - return ret == (z_off_t)ret ? (z_off_t)ret : -1; -} - -/* -- see zlib.h -- */ -z_off64_t ZEXPORT gztell64(file) - gzFile file; -{ - gz_statep state; - - /* get internal structure and check integrity */ - if (file == NULL) - return -1; - state = (gz_statep)file; - if (state->mode != GZ_READ && state->mode != GZ_WRITE) - return -1; - - /* return position */ - return state->x.pos + (state->seek ? state->skip : 0); -} - -/* -- see zlib.h -- */ -z_off_t ZEXPORT gztell(file) - gzFile file; -{ - z_off64_t ret; - - ret = gztell64(file); - return ret == (z_off_t)ret ? (z_off_t)ret : -1; -} - -/* -- see zlib.h -- */ -z_off64_t ZEXPORT gzoffset64(file) - gzFile file; -{ - z_off64_t offset; - gz_statep state; - - /* get internal structure and check integrity */ - if (file == NULL) - return -1; - state = (gz_statep)file; - if (state->mode != GZ_READ && state->mode != GZ_WRITE) - return -1; - - /* compute and return effective offset in file */ - offset = LSEEK(state->fd, 0, SEEK_CUR); - if (offset == -1) - return -1; - if (state->mode == GZ_READ) /* reading */ - offset -= state->strm.avail_in; /* don't count buffered input */ - return offset; -} - -/* -- see zlib.h -- */ -z_off_t ZEXPORT gzoffset(file) - gzFile file; -{ - z_off64_t ret; - - ret = gzoffset64(file); - return ret == (z_off_t)ret ? (z_off_t)ret : -1; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzeof(file) - gzFile file; -{ - gz_statep state; - - /* get internal structure and check integrity */ - if (file == NULL) - return 0; - state = (gz_statep)file; - if (state->mode != GZ_READ && state->mode != GZ_WRITE) - return 0; - - /* return end-of-file state */ - return state->mode == GZ_READ ? state->past : 0; -} - -/* -- see zlib.h -- */ -const char * ZEXPORT gzerror(file, errnum) - gzFile file; - int *errnum; -{ - gz_statep state; - - /* get internal structure and check integrity */ - if (file == NULL) - return NULL; - state = (gz_statep)file; - if (state->mode != GZ_READ && state->mode != GZ_WRITE) - return NULL; - - /* return error information */ - if (errnum != NULL) - *errnum = state->err; - return state->err == Z_MEM_ERROR ? "out of memory" : - (state->msg == NULL ? "" : state->msg); -} - -/* -- see zlib.h -- */ -void ZEXPORT gzclearerr(file) - gzFile file; -{ - gz_statep state; - - /* get internal structure and check integrity */ - if (file == NULL) - return; - state = (gz_statep)file; - if (state->mode != GZ_READ && state->mode != GZ_WRITE) - return; - - /* clear error and end-of-file */ - if (state->mode == GZ_READ) { - state->eof = 0; - state->past = 0; - } - gz_error(state, Z_OK, NULL); -} - -/* Create an error message in allocated memory and set state->err and - state->msg accordingly. Free any previous error message already there. Do - not try to free or allocate space if the error is Z_MEM_ERROR (out of - memory). Simply save the error message as a static string. If there is an - allocation failure constructing the error message, then convert the error to - out of memory. */ -void ZLIB_INTERNAL gz_error(state, err, msg) - gz_statep state; - int err; - const char *msg; -{ - /* free previously allocated message and clear */ - if (state->msg != NULL) { - if (state->err != Z_MEM_ERROR) - free(state->msg); - state->msg = NULL; - } - - /* if fatal, set state->x.have to 0 so that the gzgetc() macro fails */ - if (err != Z_OK && err != Z_BUF_ERROR) - state->x.have = 0; - - /* set error code, and if no message, then done */ - state->err = err; - if (msg == NULL) - return; - - /* for an out of memory error, return literal string when requested */ - if (err == Z_MEM_ERROR) - return; - - /* construct error message with path */ - if ((state->msg = (char *)malloc(strlen(state->path) + strlen(msg) + 3)) == - NULL) { - state->err = Z_MEM_ERROR; - return; - } -#if !defined(NO_snprintf) && !defined(NO_vsnprintf) - snprintf(state->msg, strlen(state->path) + strlen(msg) + 3, - "%s%s%s", state->path, ": ", msg); -#else - strcpy(state->msg, state->path); - strcat(state->msg, ": "); - strcat(state->msg, msg); -#endif - return; -} - -#ifndef INT_MAX -/* portably return maximum value for an int (when limits.h presumed not - available) -- we need to do this to cover cases where 2's complement not - used, since C standard permits 1's complement and sign-bit representations, - otherwise we could just use ((unsigned)-1) >> 1 */ -unsigned ZLIB_INTERNAL gz_intmax() -{ - unsigned p, q; - - p = 1; - do { - q = p; - p <<= 1; - p++; - } while (p > q); - return q >> 1; -} -#endif diff --git a/libs/zlib/src/gzread.c b/libs/zlib/src/gzread.c deleted file mode 100644 index bf4538eb..00000000 --- a/libs/zlib/src/gzread.c +++ /dev/null @@ -1,594 +0,0 @@ -/* gzread.c -- zlib functions for reading gzip files - * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "gzguts.h" - -/* Local functions */ -local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *)); -local int gz_avail OF((gz_statep)); -local int gz_look OF((gz_statep)); -local int gz_decomp OF((gz_statep)); -local int gz_fetch OF((gz_statep)); -local int gz_skip OF((gz_statep, z_off64_t)); - -/* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from - state->fd, and update state->eof, state->err, and state->msg as appropriate. - This function needs to loop on read(), since read() is not guaranteed to - read the number of bytes requested, depending on the type of descriptor. */ -local int gz_load(state, buf, len, have) - gz_statep state; - unsigned char *buf; - unsigned len; - unsigned *have; -{ - int ret; - - *have = 0; - do { - ret = read(state->fd, buf + *have, len - *have); - if (ret <= 0) - break; - *have += ret; - } while (*have < len); - if (ret < 0) { - gz_error(state, Z_ERRNO, zstrerror()); - return -1; - } - if (ret == 0) - state->eof = 1; - return 0; -} - -/* Load up input buffer and set eof flag if last data loaded -- return -1 on - error, 0 otherwise. Note that the eof flag is set when the end of the input - file is reached, even though there may be unused data in the buffer. Once - that data has been used, no more attempts will be made to read the file. - If strm->avail_in != 0, then the current data is moved to the beginning of - the input buffer, and then the remainder of the buffer is loaded with the - available data from the input file. */ -local int gz_avail(state) - gz_statep state; -{ - unsigned got; - z_streamp strm = &(state->strm); - - if (state->err != Z_OK && state->err != Z_BUF_ERROR) - return -1; - if (state->eof == 0) { - if (strm->avail_in) { /* copy what's there to the start */ - unsigned char *p = state->in; - unsigned const char *q = strm->next_in; - unsigned n = strm->avail_in; - do { - *p++ = *q++; - } while (--n); - } - if (gz_load(state, state->in + strm->avail_in, - state->size - strm->avail_in, &got) == -1) - return -1; - strm->avail_in += got; - strm->next_in = state->in; - } - return 0; -} - -/* Look for gzip header, set up for inflate or copy. state->x.have must be 0. - If this is the first time in, allocate required memory. state->how will be - left unchanged if there is no more input data available, will be set to COPY - if there is no gzip header and direct copying will be performed, or it will - be set to GZIP for decompression. If direct copying, then leftover input - data from the input buffer will be copied to the output buffer. In that - case, all further file reads will be directly to either the output buffer or - a user buffer. If decompressing, the inflate state will be initialized. - gz_look() will return 0 on success or -1 on failure. */ -local int gz_look(state) - gz_statep state; -{ - z_streamp strm = &(state->strm); - - /* allocate read buffers and inflate memory */ - if (state->size == 0) { - /* allocate buffers */ - state->in = (unsigned char *)malloc(state->want); - state->out = (unsigned char *)malloc(state->want << 1); - if (state->in == NULL || state->out == NULL) { - if (state->out != NULL) - free(state->out); - if (state->in != NULL) - free(state->in); - gz_error(state, Z_MEM_ERROR, "out of memory"); - return -1; - } - state->size = state->want; - - /* allocate inflate memory */ - state->strm.zalloc = Z_NULL; - state->strm.zfree = Z_NULL; - state->strm.opaque = Z_NULL; - state->strm.avail_in = 0; - state->strm.next_in = Z_NULL; - if (inflateInit2(&(state->strm), 15 + 16) != Z_OK) { /* gunzip */ - free(state->out); - free(state->in); - state->size = 0; - gz_error(state, Z_MEM_ERROR, "out of memory"); - return -1; - } - } - - /* get at least the magic bytes in the input buffer */ - if (strm->avail_in < 2) { - if (gz_avail(state) == -1) - return -1; - if (strm->avail_in == 0) - return 0; - } - - /* look for gzip magic bytes -- if there, do gzip decoding (note: there is - a logical dilemma here when considering the case of a partially written - gzip file, to wit, if a single 31 byte is written, then we cannot tell - whether this is a single-byte file, or just a partially written gzip - file -- for here we assume that if a gzip file is being written, then - the header will be written in a single operation, so that reading a - single byte is sufficient indication that it is not a gzip file) */ - if (strm->avail_in > 1 && - strm->next_in[0] == 31 && strm->next_in[1] == 139) { - inflateReset(strm); - state->how = GZIP; - state->direct = 0; - return 0; - } - - /* no gzip header -- if we were decoding gzip before, then this is trailing - garbage. Ignore the trailing garbage and finish. */ - if (state->direct == 0) { - strm->avail_in = 0; - state->eof = 1; - state->x.have = 0; - return 0; - } - - /* doing raw i/o, copy any leftover input to output -- this assumes that - the output buffer is larger than the input buffer, which also assures - space for gzungetc() */ - state->x.next = state->out; - if (strm->avail_in) { - memcpy(state->x.next, strm->next_in, strm->avail_in); - state->x.have = strm->avail_in; - strm->avail_in = 0; - } - state->how = COPY; - state->direct = 1; - return 0; -} - -/* Decompress from input to the provided next_out and avail_out in the state. - On return, state->x.have and state->x.next point to the just decompressed - data. If the gzip stream completes, state->how is reset to LOOK to look for - the next gzip stream or raw data, once state->x.have is depleted. Returns 0 - on success, -1 on failure. */ -local int gz_decomp(state) - gz_statep state; -{ - int ret = Z_OK; - unsigned had; - z_streamp strm = &(state->strm); - - /* fill output buffer up to end of deflate stream */ - had = strm->avail_out; - do { - /* get more input for inflate() */ - if (strm->avail_in == 0 && gz_avail(state) == -1) - return -1; - if (strm->avail_in == 0) { - gz_error(state, Z_BUF_ERROR, "unexpected end of file"); - break; - } - - /* decompress and handle errors */ - ret = inflate(strm, Z_NO_FLUSH); - if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) { - gz_error(state, Z_STREAM_ERROR, - "internal error: inflate stream corrupt"); - return -1; - } - if (ret == Z_MEM_ERROR) { - gz_error(state, Z_MEM_ERROR, "out of memory"); - return -1; - } - if (ret == Z_DATA_ERROR) { /* deflate stream invalid */ - gz_error(state, Z_DATA_ERROR, - strm->msg == NULL ? "compressed data error" : strm->msg); - return -1; - } - } while (strm->avail_out && ret != Z_STREAM_END); - - /* update available output */ - state->x.have = had - strm->avail_out; - state->x.next = strm->next_out - state->x.have; - - /* if the gzip stream completed successfully, look for another */ - if (ret == Z_STREAM_END) - state->how = LOOK; - - /* good decompression */ - return 0; -} - -/* Fetch data and put it in the output buffer. Assumes state->x.have is 0. - Data is either copied from the input file or decompressed from the input - file depending on state->how. If state->how is LOOK, then a gzip header is - looked for to determine whether to copy or decompress. Returns -1 on error, - otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the - end of the input file has been reached and all data has been processed. */ -local int gz_fetch(state) - gz_statep state; -{ - z_streamp strm = &(state->strm); - - do { - switch(state->how) { - case LOOK: /* -> LOOK, COPY (only if never GZIP), or GZIP */ - if (gz_look(state) == -1) - return -1; - if (state->how == LOOK) - return 0; - break; - case COPY: /* -> COPY */ - if (gz_load(state, state->out, state->size << 1, &(state->x.have)) - == -1) - return -1; - state->x.next = state->out; - return 0; - case GZIP: /* -> GZIP or LOOK (if end of gzip stream) */ - strm->avail_out = state->size << 1; - strm->next_out = state->out; - if (gz_decomp(state) == -1) - return -1; - } - } while (state->x.have == 0 && (!state->eof || strm->avail_in)); - return 0; -} - -/* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */ -local int gz_skip(state, len) - gz_statep state; - z_off64_t len; -{ - unsigned n; - - /* skip over len bytes or reach end-of-file, whichever comes first */ - while (len) - /* skip over whatever is in output buffer */ - if (state->x.have) { - n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > len ? - (unsigned)len : state->x.have; - state->x.have -= n; - state->x.next += n; - state->x.pos += n; - len -= n; - } - - /* output buffer empty -- return if we're at the end of the input */ - else if (state->eof && state->strm.avail_in == 0) - break; - - /* need more data to skip -- load up output buffer */ - else { - /* get more output, looking for header if required */ - if (gz_fetch(state) == -1) - return -1; - } - return 0; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzread(file, buf, len) - gzFile file; - voidp buf; - unsigned len; -{ - unsigned got, n; - gz_statep state; - z_streamp strm; - - /* get internal structure */ - if (file == NULL) - return -1; - state = (gz_statep)file; - strm = &(state->strm); - - /* check that we're reading and that there's no (serious) error */ - if (state->mode != GZ_READ || - (state->err != Z_OK && state->err != Z_BUF_ERROR)) - return -1; - - /* since an int is returned, make sure len fits in one, otherwise return - with an error (this avoids the flaw in the interface) */ - if ((int)len < 0) { - gz_error(state, Z_DATA_ERROR, "requested length does not fit in int"); - return -1; - } - - /* if len is zero, avoid unnecessary operations */ - if (len == 0) - return 0; - - /* process a skip request */ - if (state->seek) { - state->seek = 0; - if (gz_skip(state, state->skip) == -1) - return -1; - } - - /* get len bytes to buf, or less than len if at the end */ - got = 0; - do { - /* first just try copying data from the output buffer */ - if (state->x.have) { - n = state->x.have > len ? len : state->x.have; - memcpy(buf, state->x.next, n); - state->x.next += n; - state->x.have -= n; - } - - /* output buffer empty -- return if we're at the end of the input */ - else if (state->eof && strm->avail_in == 0) { - state->past = 1; /* tried to read past end */ - break; - } - - /* need output data -- for small len or new stream load up our output - buffer */ - else if (state->how == LOOK || len < (state->size << 1)) { - /* get more output, looking for header if required */ - if (gz_fetch(state) == -1) - return -1; - continue; /* no progress yet -- go back to copy above */ - /* the copy above assures that we will leave with space in the - output buffer, allowing at least one gzungetc() to succeed */ - } - - /* large len -- read directly into user buffer */ - else if (state->how == COPY) { /* read directly */ - if (gz_load(state, (unsigned char *)buf, len, &n) == -1) - return -1; - } - - /* large len -- decompress directly into user buffer */ - else { /* state->how == GZIP */ - strm->avail_out = len; - strm->next_out = (unsigned char *)buf; - if (gz_decomp(state) == -1) - return -1; - n = state->x.have; - state->x.have = 0; - } - - /* update progress */ - len -= n; - buf = (char *)buf + n; - got += n; - state->x.pos += n; - } while (len); - - /* return number of bytes read into user buffer (will fit in int) */ - return (int)got; -} - -/* -- see zlib.h -- */ -#ifdef Z_PREFIX_SET -# undef z_gzgetc -#else -# undef gzgetc -#endif -int ZEXPORT gzgetc(file) - gzFile file; -{ - int ret; - unsigned char buf[1]; - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return -1; - state = (gz_statep)file; - - /* check that we're reading and that there's no (serious) error */ - if (state->mode != GZ_READ || - (state->err != Z_OK && state->err != Z_BUF_ERROR)) - return -1; - - /* try output buffer (no need to check for skip request) */ - if (state->x.have) { - state->x.have--; - state->x.pos++; - return *(state->x.next)++; - } - - /* nothing there -- try gzread() */ - ret = gzread(file, buf, 1); - return ret < 1 ? -1 : buf[0]; -} - -int ZEXPORT gzgetc_(file) -gzFile file; -{ - return gzgetc(file); -} - -/* -- see zlib.h -- */ -int ZEXPORT gzungetc(c, file) - int c; - gzFile file; -{ - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return -1; - state = (gz_statep)file; - - /* check that we're reading and that there's no (serious) error */ - if (state->mode != GZ_READ || - (state->err != Z_OK && state->err != Z_BUF_ERROR)) - return -1; - - /* process a skip request */ - if (state->seek) { - state->seek = 0; - if (gz_skip(state, state->skip) == -1) - return -1; - } - - /* can't push EOF */ - if (c < 0) - return -1; - - /* if output buffer empty, put byte at end (allows more pushing) */ - if (state->x.have == 0) { - state->x.have = 1; - state->x.next = state->out + (state->size << 1) - 1; - state->x.next[0] = c; - state->x.pos--; - state->past = 0; - return c; - } - - /* if no room, give up (must have already done a gzungetc()) */ - if (state->x.have == (state->size << 1)) { - gz_error(state, Z_DATA_ERROR, "out of room to push characters"); - return -1; - } - - /* slide output data if needed and insert byte before existing data */ - if (state->x.next == state->out) { - unsigned char *src = state->out + state->x.have; - unsigned char *dest = state->out + (state->size << 1); - while (src > state->out) - *--dest = *--src; - state->x.next = dest; - } - state->x.have++; - state->x.next--; - state->x.next[0] = c; - state->x.pos--; - state->past = 0; - return c; -} - -/* -- see zlib.h -- */ -char * ZEXPORT gzgets(file, buf, len) - gzFile file; - char *buf; - int len; -{ - unsigned left, n; - char *str; - unsigned char *eol; - gz_statep state; - - /* check parameters and get internal structure */ - if (file == NULL || buf == NULL || len < 1) - return NULL; - state = (gz_statep)file; - - /* check that we're reading and that there's no (serious) error */ - if (state->mode != GZ_READ || - (state->err != Z_OK && state->err != Z_BUF_ERROR)) - return NULL; - - /* process a skip request */ - if (state->seek) { - state->seek = 0; - if (gz_skip(state, state->skip) == -1) - return NULL; - } - - /* copy output bytes up to new line or len - 1, whichever comes first -- - append a terminating zero to the string (we don't check for a zero in - the contents, let the user worry about that) */ - str = buf; - left = (unsigned)len - 1; - if (left) do { - /* assure that something is in the output buffer */ - if (state->x.have == 0 && gz_fetch(state) == -1) - return NULL; /* error */ - if (state->x.have == 0) { /* end of file */ - state->past = 1; /* read past end */ - break; /* return what we have */ - } - - /* look for end-of-line in current output buffer */ - n = state->x.have > left ? left : state->x.have; - eol = (unsigned char *)memchr(state->x.next, '\n', n); - if (eol != NULL) - n = (unsigned)(eol - state->x.next) + 1; - - /* copy through end-of-line, or remainder if not found */ - memcpy(buf, state->x.next, n); - state->x.have -= n; - state->x.next += n; - state->x.pos += n; - left -= n; - buf += n; - } while (left && eol == NULL); - - /* return terminated string, or if nothing, end of file */ - if (buf == str) - return NULL; - buf[0] = 0; - return str; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzdirect(file) - gzFile file; -{ - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return 0; - state = (gz_statep)file; - - /* if the state is not known, but we can find out, then do so (this is - mainly for right after a gzopen() or gzdopen()) */ - if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0) - (void)gz_look(state); - - /* return 1 if transparent, 0 if processing a gzip stream */ - return state->direct; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzclose_r(file) - gzFile file; -{ - int ret, err; - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return Z_STREAM_ERROR; - state = (gz_statep)file; - - /* check that we're reading */ - if (state->mode != GZ_READ) - return Z_STREAM_ERROR; - - /* free memory and close file */ - if (state->size) { - inflateEnd(&(state->strm)); - free(state->out); - free(state->in); - } - err = state->err == Z_BUF_ERROR ? Z_BUF_ERROR : Z_OK; - gz_error(state, Z_OK, NULL); - free(state->path); - ret = close(state->fd); - free(state); - return ret ? Z_ERRNO : err; -} diff --git a/libs/zlib/src/gzwrite.c b/libs/zlib/src/gzwrite.c deleted file mode 100644 index aa767fbf..00000000 --- a/libs/zlib/src/gzwrite.c +++ /dev/null @@ -1,577 +0,0 @@ -/* gzwrite.c -- zlib functions for writing gzip files - * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "gzguts.h" - -/* Local functions */ -local int gz_init OF((gz_statep)); -local int gz_comp OF((gz_statep, int)); -local int gz_zero OF((gz_statep, z_off64_t)); - -/* Initialize state for writing a gzip file. Mark initialization by setting - state->size to non-zero. Return -1 on failure or 0 on success. */ -local int gz_init(state) - gz_statep state; -{ - int ret; - z_streamp strm = &(state->strm); - - /* allocate input buffer */ - state->in = (unsigned char *)malloc(state->want); - if (state->in == NULL) { - gz_error(state, Z_MEM_ERROR, "out of memory"); - return -1; - } - - /* only need output buffer and deflate state if compressing */ - if (!state->direct) { - /* allocate output buffer */ - state->out = (unsigned char *)malloc(state->want); - if (state->out == NULL) { - free(state->in); - gz_error(state, Z_MEM_ERROR, "out of memory"); - return -1; - } - - /* allocate deflate memory, set up for gzip compression */ - strm->zalloc = Z_NULL; - strm->zfree = Z_NULL; - strm->opaque = Z_NULL; - ret = deflateInit2(strm, state->level, Z_DEFLATED, - MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy); - if (ret != Z_OK) { - free(state->out); - free(state->in); - gz_error(state, Z_MEM_ERROR, "out of memory"); - return -1; - } - } - - /* mark state as initialized */ - state->size = state->want; - - /* initialize write buffer if compressing */ - if (!state->direct) { - strm->avail_out = state->size; - strm->next_out = state->out; - state->x.next = strm->next_out; - } - return 0; -} - -/* Compress whatever is at avail_in and next_in and write to the output file. - Return -1 if there is an error writing to the output file, otherwise 0. - flush is assumed to be a valid deflate() flush value. If flush is Z_FINISH, - then the deflate() state is reset to start a new gzip stream. If gz->direct - is true, then simply write to the output file without compressing, and - ignore flush. */ -local int gz_comp(state, flush) - gz_statep state; - int flush; -{ - int ret, got; - unsigned have; - z_streamp strm = &(state->strm); - - /* allocate memory if this is the first time through */ - if (state->size == 0 && gz_init(state) == -1) - return -1; - - /* write directly if requested */ - if (state->direct) { - got = write(state->fd, strm->next_in, strm->avail_in); - if (got < 0 || (unsigned)got != strm->avail_in) { - gz_error(state, Z_ERRNO, zstrerror()); - return -1; - } - strm->avail_in = 0; - return 0; - } - - /* run deflate() on provided input until it produces no more output */ - ret = Z_OK; - do { - /* write out current buffer contents if full, or if flushing, but if - doing Z_FINISH then don't write until we get to Z_STREAM_END */ - if (strm->avail_out == 0 || (flush != Z_NO_FLUSH && - (flush != Z_FINISH || ret == Z_STREAM_END))) { - have = (unsigned)(strm->next_out - state->x.next); - if (have && ((got = write(state->fd, state->x.next, have)) < 0 || - (unsigned)got != have)) { - gz_error(state, Z_ERRNO, zstrerror()); - return -1; - } - if (strm->avail_out == 0) { - strm->avail_out = state->size; - strm->next_out = state->out; - } - state->x.next = strm->next_out; - } - - /* compress */ - have = strm->avail_out; - ret = deflate(strm, flush); - if (ret == Z_STREAM_ERROR) { - gz_error(state, Z_STREAM_ERROR, - "internal error: deflate stream corrupt"); - return -1; - } - have -= strm->avail_out; - } while (have); - - /* if that completed a deflate stream, allow another to start */ - if (flush == Z_FINISH) - deflateReset(strm); - - /* all done, no errors */ - return 0; -} - -/* Compress len zeros to output. Return -1 on error, 0 on success. */ -local int gz_zero(state, len) - gz_statep state; - z_off64_t len; -{ - int first; - unsigned n; - z_streamp strm = &(state->strm); - - /* consume whatever's left in the input buffer */ - if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) - return -1; - - /* compress len zeros (len guaranteed > 0) */ - first = 1; - while (len) { - n = GT_OFF(state->size) || (z_off64_t)state->size > len ? - (unsigned)len : state->size; - if (first) { - memset(state->in, 0, n); - first = 0; - } - strm->avail_in = n; - strm->next_in = state->in; - state->x.pos += n; - if (gz_comp(state, Z_NO_FLUSH) == -1) - return -1; - len -= n; - } - return 0; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzwrite(file, buf, len) - gzFile file; - voidpc buf; - unsigned len; -{ - unsigned put = len; - gz_statep state; - z_streamp strm; - - /* get internal structure */ - if (file == NULL) - return 0; - state = (gz_statep)file; - strm = &(state->strm); - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) - return 0; - - /* since an int is returned, make sure len fits in one, otherwise return - with an error (this avoids the flaw in the interface) */ - if ((int)len < 0) { - gz_error(state, Z_DATA_ERROR, "requested length does not fit in int"); - return 0; - } - - /* if len is zero, avoid unnecessary operations */ - if (len == 0) - return 0; - - /* allocate memory if this is the first time through */ - if (state->size == 0 && gz_init(state) == -1) - return 0; - - /* check for seek request */ - if (state->seek) { - state->seek = 0; - if (gz_zero(state, state->skip) == -1) - return 0; - } - - /* for small len, copy to input buffer, otherwise compress directly */ - if (len < state->size) { - /* copy to input buffer, compress when full */ - do { - unsigned have, copy; - - if (strm->avail_in == 0) - strm->next_in = state->in; - have = (unsigned)((strm->next_in + strm->avail_in) - state->in); - copy = state->size - have; - if (copy > len) - copy = len; - memcpy(state->in + have, buf, copy); - strm->avail_in += copy; - state->x.pos += copy; - buf = (const char *)buf + copy; - len -= copy; - if (len && gz_comp(state, Z_NO_FLUSH) == -1) - return 0; - } while (len); - } - else { - /* consume whatever's left in the input buffer */ - if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) - return 0; - - /* directly compress user buffer to file */ - strm->avail_in = len; - strm->next_in = (z_const Bytef *)buf; - state->x.pos += len; - if (gz_comp(state, Z_NO_FLUSH) == -1) - return 0; - } - - /* input was all buffered or compressed (put will fit in int) */ - return (int)put; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzputc(file, c) - gzFile file; - int c; -{ - unsigned have; - unsigned char buf[1]; - gz_statep state; - z_streamp strm; - - /* get internal structure */ - if (file == NULL) - return -1; - state = (gz_statep)file; - strm = &(state->strm); - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) - return -1; - - /* check for seek request */ - if (state->seek) { - state->seek = 0; - if (gz_zero(state, state->skip) == -1) - return -1; - } - - /* try writing to input buffer for speed (state->size == 0 if buffer not - initialized) */ - if (state->size) { - if (strm->avail_in == 0) - strm->next_in = state->in; - have = (unsigned)((strm->next_in + strm->avail_in) - state->in); - if (have < state->size) { - state->in[have] = c; - strm->avail_in++; - state->x.pos++; - return c & 0xff; - } - } - - /* no room in buffer or not initialized, use gz_write() */ - buf[0] = c; - if (gzwrite(file, buf, 1) != 1) - return -1; - return c & 0xff; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzputs(file, str) - gzFile file; - const char *str; -{ - int ret; - unsigned len; - - /* write string */ - len = (unsigned)strlen(str); - ret = gzwrite(file, str, len); - return ret == 0 && len != 0 ? -1 : ret; -} - -#if defined(STDC) || defined(Z_HAVE_STDARG_H) -#include - -/* -- see zlib.h -- */ -int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) -{ - int size, len; - gz_statep state; - z_streamp strm; - - /* get internal structure */ - if (file == NULL) - return -1; - state = (gz_statep)file; - strm = &(state->strm); - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) - return 0; - - /* make sure we have some buffer space */ - if (state->size == 0 && gz_init(state) == -1) - return 0; - - /* check for seek request */ - if (state->seek) { - state->seek = 0; - if (gz_zero(state, state->skip) == -1) - return 0; - } - - /* consume whatever's left in the input buffer */ - if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) - return 0; - - /* do the printf() into the input buffer, put length in len */ - size = (int)(state->size); - state->in[size - 1] = 0; -#ifdef NO_vsnprintf -# ifdef HAS_vsprintf_void - (void)vsprintf((char *)(state->in), format, va); - for (len = 0; len < size; len++) - if (state->in[len] == 0) break; -# else - len = vsprintf((char *)(state->in), format, va); -# endif -#else -# ifdef HAS_vsnprintf_void - (void)vsnprintf((char *)(state->in), size, format, va); - len = strlen((char *)(state->in)); -# else - len = vsnprintf((char *)(state->in), size, format, va); -# endif -#endif - - /* check that printf() results fit in buffer */ - if (len <= 0 || len >= (int)size || state->in[size - 1] != 0) - return 0; - - /* update buffer and position, defer compression until needed */ - strm->avail_in = (unsigned)len; - strm->next_in = state->in; - state->x.pos += len; - return len; -} - -int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) -{ - va_list va; - int ret; - - va_start(va, format); - ret = gzvprintf(file, format, va); - va_end(va); - return ret; -} - -#else /* !STDC && !Z_HAVE_STDARG_H */ - -/* -- see zlib.h -- */ -int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) - gzFile file; - const char *format; - int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; -{ - int size, len; - gz_statep state; - z_streamp strm; - - /* get internal structure */ - if (file == NULL) - return -1; - state = (gz_statep)file; - strm = &(state->strm); - - /* check that can really pass pointer in ints */ - if (sizeof(int) != sizeof(void *)) - return 0; - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) - return 0; - - /* make sure we have some buffer space */ - if (state->size == 0 && gz_init(state) == -1) - return 0; - - /* check for seek request */ - if (state->seek) { - state->seek = 0; - if (gz_zero(state, state->skip) == -1) - return 0; - } - - /* consume whatever's left in the input buffer */ - if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) - return 0; - - /* do the printf() into the input buffer, put length in len */ - size = (int)(state->size); - state->in[size - 1] = 0; -#ifdef NO_snprintf -# ifdef HAS_sprintf_void - sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); - for (len = 0; len < size; len++) - if (state->in[len] == 0) break; -# else - len = sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); -# endif -#else -# ifdef HAS_snprintf_void - snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); - len = strlen((char *)(state->in)); -# else - len = snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6, - a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, - a19, a20); -# endif -#endif - - /* check that printf() results fit in buffer */ - if (len <= 0 || len >= (int)size || state->in[size - 1] != 0) - return 0; - - /* update buffer and position, defer compression until needed */ - strm->avail_in = (unsigned)len; - strm->next_in = state->in; - state->x.pos += len; - return len; -} - -#endif - -/* -- see zlib.h -- */ -int ZEXPORT gzflush(file, flush) - gzFile file; - int flush; -{ - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return -1; - state = (gz_statep)file; - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) - return Z_STREAM_ERROR; - - /* check flush parameter */ - if (flush < 0 || flush > Z_FINISH) - return Z_STREAM_ERROR; - - /* check for seek request */ - if (state->seek) { - state->seek = 0; - if (gz_zero(state, state->skip) == -1) - return -1; - } - - /* compress remaining data with requested flush */ - gz_comp(state, flush); - return state->err; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzsetparams(file, level, strategy) - gzFile file; - int level; - int strategy; -{ - gz_statep state; - z_streamp strm; - - /* get internal structure */ - if (file == NULL) - return Z_STREAM_ERROR; - state = (gz_statep)file; - strm = &(state->strm); - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) - return Z_STREAM_ERROR; - - /* if no change is requested, then do nothing */ - if (level == state->level && strategy == state->strategy) - return Z_OK; - - /* check for seek request */ - if (state->seek) { - state->seek = 0; - if (gz_zero(state, state->skip) == -1) - return -1; - } - - /* change compression parameters for subsequent input */ - if (state->size) { - /* flush previous input with previous parameters before changing */ - if (strm->avail_in && gz_comp(state, Z_PARTIAL_FLUSH) == -1) - return state->err; - deflateParams(strm, level, strategy); - } - state->level = level; - state->strategy = strategy; - return Z_OK; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzclose_w(file) - gzFile file; -{ - int ret = Z_OK; - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return Z_STREAM_ERROR; - state = (gz_statep)file; - - /* check that we're writing */ - if (state->mode != GZ_WRITE) - return Z_STREAM_ERROR; - - /* check for seek request */ - if (state->seek) { - state->seek = 0; - if (gz_zero(state, state->skip) == -1) - ret = state->err; - } - - /* flush, free memory, and close file */ - if (gz_comp(state, Z_FINISH) == -1) - ret = state->err; - if (state->size) { - if (!state->direct) { - (void)deflateEnd(&(state->strm)); - free(state->out); - } - free(state->in); - } - gz_error(state, Z_OK, NULL); - free(state->path); - if (close(state->fd) == -1) - ret = Z_ERRNO; - free(state); - return ret; -} diff --git a/libs/zlib/src/infback.c b/libs/zlib/src/infback.c deleted file mode 100644 index f3833c2e..00000000 --- a/libs/zlib/src/infback.c +++ /dev/null @@ -1,640 +0,0 @@ -/* infback.c -- inflate using a call-back interface - * Copyright (C) 1995-2011 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - This code is largely copied from inflate.c. Normally either infback.o or - inflate.o would be linked into an application--not both. The interface - with inffast.c is retained so that optimized assembler-coded versions of - inflate_fast() can be used with either inflate.c or infback.c. - */ - -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -/* function prototypes */ -local void fixedtables OF((struct inflate_state FAR *state)); - -/* - strm provides memory allocation functions in zalloc and zfree, or - Z_NULL to use the library memory allocation functions. - - windowBits is in the range 8..15, and window is a user-supplied - window and output buffer that is 2**windowBits bytes. - */ -int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size) -z_streamp strm; -int windowBits; -unsigned char FAR *window; -const char *version; -int stream_size; -{ - struct inflate_state FAR *state; - - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || - stream_size != (int)(sizeof(z_stream))) - return Z_VERSION_ERROR; - if (strm == Z_NULL || window == Z_NULL || - windowBits < 8 || windowBits > 15) - return Z_STREAM_ERROR; - strm->msg = Z_NULL; /* in case we return an error */ - if (strm->zalloc == (alloc_func)0) { -#ifdef Z_SOLO - return Z_STREAM_ERROR; -#else - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; -#endif - } - if (strm->zfree == (free_func)0) -#ifdef Z_SOLO - return Z_STREAM_ERROR; -#else - strm->zfree = zcfree; -#endif - state = (struct inflate_state FAR *)ZALLOC(strm, 1, - sizeof(struct inflate_state)); - if (state == Z_NULL) return Z_MEM_ERROR; - Tracev((stderr, "inflate: allocated\n")); - strm->state = (struct internal_state FAR *)state; - state->dmax = 32768U; - state->wbits = windowBits; - state->wsize = 1U << windowBits; - state->window = window; - state->wnext = 0; - state->whave = 0; - return Z_OK; -} - -/* - Return state with length and distance decoding tables and index sizes set to - fixed code decoding. Normally this returns fixed tables from inffixed.h. - If BUILDFIXED is defined, then instead this routine builds the tables the - first time it's called, and returns those tables the first time and - thereafter. This reduces the size of the code by about 2K bytes, in - exchange for a little execution time. However, BUILDFIXED should not be - used for threaded applications, since the rewriting of the tables and virgin - may not be thread-safe. - */ -local void fixedtables(state) -struct inflate_state FAR *state; -{ -#ifdef BUILDFIXED - static int virgin = 1; - static code *lenfix, *distfix; - static code fixed[544]; - - /* build fixed huffman tables if first call (may not be thread safe) */ - if (virgin) { - unsigned sym, bits; - static code *next; - - /* literal/length table */ - sym = 0; - while (sym < 144) state->lens[sym++] = 8; - while (sym < 256) state->lens[sym++] = 9; - while (sym < 280) state->lens[sym++] = 7; - while (sym < 288) state->lens[sym++] = 8; - next = fixed; - lenfix = next; - bits = 9; - inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); - - /* distance table */ - sym = 0; - while (sym < 32) state->lens[sym++] = 5; - distfix = next; - bits = 5; - inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); - - /* do this just once */ - virgin = 0; - } -#else /* !BUILDFIXED */ -# include "inffixed.h" -#endif /* BUILDFIXED */ - state->lencode = lenfix; - state->lenbits = 9; - state->distcode = distfix; - state->distbits = 5; -} - -/* Macros for inflateBack(): */ - -/* Load returned state from inflate_fast() */ -#define LOAD() \ - do { \ - put = strm->next_out; \ - left = strm->avail_out; \ - next = strm->next_in; \ - have = strm->avail_in; \ - hold = state->hold; \ - bits = state->bits; \ - } while (0) - -/* Set state from registers for inflate_fast() */ -#define RESTORE() \ - do { \ - strm->next_out = put; \ - strm->avail_out = left; \ - strm->next_in = next; \ - strm->avail_in = have; \ - state->hold = hold; \ - state->bits = bits; \ - } while (0) - -/* Clear the input bit accumulator */ -#define INITBITS() \ - do { \ - hold = 0; \ - bits = 0; \ - } while (0) - -/* Assure that some input is available. If input is requested, but denied, - then return a Z_BUF_ERROR from inflateBack(). */ -#define PULL() \ - do { \ - if (have == 0) { \ - have = in(in_desc, &next); \ - if (have == 0) { \ - next = Z_NULL; \ - ret = Z_BUF_ERROR; \ - goto inf_leave; \ - } \ - } \ - } while (0) - -/* Get a byte of input into the bit accumulator, or return from inflateBack() - with an error if there is no input available. */ -#define PULLBYTE() \ - do { \ - PULL(); \ - have--; \ - hold += (unsigned long)(*next++) << bits; \ - bits += 8; \ - } while (0) - -/* Assure that there are at least n bits in the bit accumulator. If there is - not enough available input to do that, then return from inflateBack() with - an error. */ -#define NEEDBITS(n) \ - do { \ - while (bits < (unsigned)(n)) \ - PULLBYTE(); \ - } while (0) - -/* Return the low n bits of the bit accumulator (n < 16) */ -#define BITS(n) \ - ((unsigned)hold & ((1U << (n)) - 1)) - -/* Remove n bits from the bit accumulator */ -#define DROPBITS(n) \ - do { \ - hold >>= (n); \ - bits -= (unsigned)(n); \ - } while (0) - -/* Remove zero to seven bits as needed to go to a byte boundary */ -#define BYTEBITS() \ - do { \ - hold >>= bits & 7; \ - bits -= bits & 7; \ - } while (0) - -/* Assure that some output space is available, by writing out the window - if it's full. If the write fails, return from inflateBack() with a - Z_BUF_ERROR. */ -#define ROOM() \ - do { \ - if (left == 0) { \ - put = state->window; \ - left = state->wsize; \ - state->whave = left; \ - if (out(out_desc, put, left)) { \ - ret = Z_BUF_ERROR; \ - goto inf_leave; \ - } \ - } \ - } while (0) - -/* - strm provides the memory allocation functions and window buffer on input, - and provides information on the unused input on return. For Z_DATA_ERROR - returns, strm will also provide an error message. - - in() and out() are the call-back input and output functions. When - inflateBack() needs more input, it calls in(). When inflateBack() has - filled the window with output, or when it completes with data in the - window, it calls out() to write out the data. The application must not - change the provided input until in() is called again or inflateBack() - returns. The application must not change the window/output buffer until - inflateBack() returns. - - in() and out() are called with a descriptor parameter provided in the - inflateBack() call. This parameter can be a structure that provides the - information required to do the read or write, as well as accumulated - information on the input and output such as totals and check values. - - in() should return zero on failure. out() should return non-zero on - failure. If either in() or out() fails, than inflateBack() returns a - Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it - was in() or out() that caused in the error. Otherwise, inflateBack() - returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format - error, or Z_MEM_ERROR if it could not allocate memory for the state. - inflateBack() can also return Z_STREAM_ERROR if the input parameters - are not correct, i.e. strm is Z_NULL or the state was not initialized. - */ -int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) -z_streamp strm; -in_func in; -void FAR *in_desc; -out_func out; -void FAR *out_desc; -{ - struct inflate_state FAR *state; - z_const unsigned char FAR *next; /* next input */ - unsigned char FAR *put; /* next output */ - unsigned have, left; /* available input and output */ - unsigned long hold; /* bit buffer */ - unsigned bits; /* bits in bit buffer */ - unsigned copy; /* number of stored or match bytes to copy */ - unsigned char FAR *from; /* where to copy match bytes from */ - code here; /* current decoding table entry */ - code last; /* parent table entry */ - unsigned len; /* length to copy for repeats, bits to drop */ - int ret; /* return code */ - static const unsigned short order[19] = /* permutation of code lengths */ - {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - - /* Check that the strm exists and that the state was initialized */ - if (strm == Z_NULL || strm->state == Z_NULL) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - - /* Reset the state */ - strm->msg = Z_NULL; - state->mode = TYPE; - state->last = 0; - state->whave = 0; - next = strm->next_in; - have = next != Z_NULL ? strm->avail_in : 0; - hold = 0; - bits = 0; - put = state->window; - left = state->wsize; - - /* Inflate until end of block marked as last */ - for (;;) - switch (state->mode) { - case TYPE: - /* determine and dispatch block type */ - if (state->last) { - BYTEBITS(); - state->mode = DONE; - break; - } - NEEDBITS(3); - state->last = BITS(1); - DROPBITS(1); - switch (BITS(2)) { - case 0: /* stored block */ - Tracev((stderr, "inflate: stored block%s\n", - state->last ? " (last)" : "")); - state->mode = STORED; - break; - case 1: /* fixed block */ - fixedtables(state); - Tracev((stderr, "inflate: fixed codes block%s\n", - state->last ? " (last)" : "")); - state->mode = LEN; /* decode codes */ - break; - case 2: /* dynamic block */ - Tracev((stderr, "inflate: dynamic codes block%s\n", - state->last ? " (last)" : "")); - state->mode = TABLE; - break; - case 3: - strm->msg = (char *)"invalid block type"; - state->mode = BAD; - } - DROPBITS(2); - break; - - case STORED: - /* get and verify stored block length */ - BYTEBITS(); /* go to byte boundary */ - NEEDBITS(32); - if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { - strm->msg = (char *)"invalid stored block lengths"; - state->mode = BAD; - break; - } - state->length = (unsigned)hold & 0xffff; - Tracev((stderr, "inflate: stored length %u\n", - state->length)); - INITBITS(); - - /* copy stored block from input to output */ - while (state->length != 0) { - copy = state->length; - PULL(); - ROOM(); - if (copy > have) copy = have; - if (copy > left) copy = left; - zmemcpy(put, next, copy); - have -= copy; - next += copy; - left -= copy; - put += copy; - state->length -= copy; - } - Tracev((stderr, "inflate: stored end\n")); - state->mode = TYPE; - break; - - case TABLE: - /* get dynamic table entries descriptor */ - NEEDBITS(14); - state->nlen = BITS(5) + 257; - DROPBITS(5); - state->ndist = BITS(5) + 1; - DROPBITS(5); - state->ncode = BITS(4) + 4; - DROPBITS(4); -#ifndef PKZIP_BUG_WORKAROUND - if (state->nlen > 286 || state->ndist > 30) { - strm->msg = (char *)"too many length or distance symbols"; - state->mode = BAD; - break; - } -#endif - Tracev((stderr, "inflate: table sizes ok\n")); - - /* get code length code lengths (not a typo) */ - state->have = 0; - while (state->have < state->ncode) { - NEEDBITS(3); - state->lens[order[state->have++]] = (unsigned short)BITS(3); - DROPBITS(3); - } - while (state->have < 19) - state->lens[order[state->have++]] = 0; - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 7; - ret = inflate_table(CODES, state->lens, 19, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid code lengths set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: code lengths ok\n")); - - /* get length and distance code code lengths */ - state->have = 0; - while (state->have < state->nlen + state->ndist) { - for (;;) { - here = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if (here.val < 16) { - DROPBITS(here.bits); - state->lens[state->have++] = here.val; - } - else { - if (here.val == 16) { - NEEDBITS(here.bits + 2); - DROPBITS(here.bits); - if (state->have == 0) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - len = (unsigned)(state->lens[state->have - 1]); - copy = 3 + BITS(2); - DROPBITS(2); - } - else if (here.val == 17) { - NEEDBITS(here.bits + 3); - DROPBITS(here.bits); - len = 0; - copy = 3 + BITS(3); - DROPBITS(3); - } - else { - NEEDBITS(here.bits + 7); - DROPBITS(here.bits); - len = 0; - copy = 11 + BITS(7); - DROPBITS(7); - } - if (state->have + copy > state->nlen + state->ndist) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - while (copy--) - state->lens[state->have++] = (unsigned short)len; - } - } - - /* handle error breaks in while */ - if (state->mode == BAD) break; - - /* check for end-of-block code (better have one) */ - if (state->lens[256] == 0) { - strm->msg = (char *)"invalid code -- missing end-of-block"; - state->mode = BAD; - break; - } - - /* build code tables -- note: do not change the lenbits or distbits - values here (9 and 6) without reading the comments in inftrees.h - concerning the ENOUGH constants, which depend on those values */ - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 9; - ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid literal/lengths set"; - state->mode = BAD; - break; - } - state->distcode = (code const FAR *)(state->next); - state->distbits = 6; - ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, - &(state->next), &(state->distbits), state->work); - if (ret) { - strm->msg = (char *)"invalid distances set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: codes ok\n")); - state->mode = LEN; - - case LEN: - /* use inflate_fast() if we have enough input and output */ - if (have >= 6 && left >= 258) { - RESTORE(); - if (state->whave < state->wsize) - state->whave = state->wsize - left; - inflate_fast(strm, state->wsize); - LOAD(); - break; - } - - /* get a literal, length, or end-of-block code */ - for (;;) { - here = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if (here.op && (here.op & 0xf0) == 0) { - last = here; - for (;;) { - here = state->lencode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + here.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(here.bits); - state->length = (unsigned)here.val; - - /* process literal */ - if (here.op == 0) { - Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", here.val)); - ROOM(); - *put++ = (unsigned char)(state->length); - left--; - state->mode = LEN; - break; - } - - /* process end of block */ - if (here.op & 32) { - Tracevv((stderr, "inflate: end of block\n")); - state->mode = TYPE; - break; - } - - /* invalid code */ - if (here.op & 64) { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - - /* length code -- get extra bits, if any */ - state->extra = (unsigned)(here.op) & 15; - if (state->extra != 0) { - NEEDBITS(state->extra); - state->length += BITS(state->extra); - DROPBITS(state->extra); - } - Tracevv((stderr, "inflate: length %u\n", state->length)); - - /* get distance code */ - for (;;) { - here = state->distcode[BITS(state->distbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if ((here.op & 0xf0) == 0) { - last = here; - for (;;) { - here = state->distcode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + here.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(here.bits); - if (here.op & 64) { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - state->offset = (unsigned)here.val; - - /* get distance extra bits, if any */ - state->extra = (unsigned)(here.op) & 15; - if (state->extra != 0) { - NEEDBITS(state->extra); - state->offset += BITS(state->extra); - DROPBITS(state->extra); - } - if (state->offset > state->wsize - (state->whave < state->wsize ? - left : 0)) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } - Tracevv((stderr, "inflate: distance %u\n", state->offset)); - - /* copy match from window to output */ - do { - ROOM(); - copy = state->wsize - state->offset; - if (copy < left) { - from = put + copy; - copy = left - copy; - } - else { - from = put - state->offset; - copy = left; - } - if (copy > state->length) copy = state->length; - state->length -= copy; - left -= copy; - do { - *put++ = *from++; - } while (--copy); - } while (state->length != 0); - break; - - case DONE: - /* inflate stream terminated properly -- write leftover output */ - ret = Z_STREAM_END; - if (left < state->wsize) { - if (out(out_desc, state->window, state->wsize - left)) - ret = Z_BUF_ERROR; - } - goto inf_leave; - - case BAD: - ret = Z_DATA_ERROR; - goto inf_leave; - - default: /* can't happen, but makes compilers happy */ - ret = Z_STREAM_ERROR; - goto inf_leave; - } - - /* Return unused input */ - inf_leave: - strm->next_in = next; - strm->avail_in = have; - return ret; -} - -int ZEXPORT inflateBackEnd(strm) -z_streamp strm; -{ - if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) - return Z_STREAM_ERROR; - ZFREE(strm, strm->state); - strm->state = Z_NULL; - Tracev((stderr, "inflate: end\n")); - return Z_OK; -} diff --git a/libs/zlib/src/inffast.c b/libs/zlib/src/inffast.c deleted file mode 100644 index bda59ceb..00000000 --- a/libs/zlib/src/inffast.c +++ /dev/null @@ -1,340 +0,0 @@ -/* inffast.c -- fast decoding - * Copyright (C) 1995-2008, 2010, 2013 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -#ifndef ASMINF - -/* Allow machine dependent optimization for post-increment or pre-increment. - Based on testing to date, - Pre-increment preferred for: - - PowerPC G3 (Adler) - - MIPS R5000 (Randers-Pehrson) - Post-increment preferred for: - - none - No measurable difference: - - Pentium III (Anderson) - - M68060 (Nikl) - */ -#ifdef POSTINC -# define OFF 0 -# define PUP(a) *(a)++ -#else -# define OFF 1 -# define PUP(a) *++(a) -#endif - -/* - Decode literal, length, and distance codes and write out the resulting - literal and match bytes until either not enough input or output is - available, an end-of-block is encountered, or a data error is encountered. - When large enough input and output buffers are supplied to inflate(), for - example, a 16K input buffer and a 64K output buffer, more than 95% of the - inflate execution time is spent in this routine. - - Entry assumptions: - - state->mode == LEN - strm->avail_in >= 6 - strm->avail_out >= 258 - start >= strm->avail_out - state->bits < 8 - - On return, state->mode is one of: - - LEN -- ran out of enough output space or enough available input - TYPE -- reached end of block code, inflate() to interpret next block - BAD -- error in block data - - Notes: - - - The maximum input bits used by a length/distance pair is 15 bits for the - length code, 5 bits for the length extra, 15 bits for the distance code, - and 13 bits for the distance extra. This totals 48 bits, or six bytes. - Therefore if strm->avail_in >= 6, then there is enough input to avoid - checking for available input while decoding. - - - The maximum bytes that a single length/distance pair can output is 258 - bytes, which is the maximum length that can be coded. inflate_fast() - requires strm->avail_out >= 258 for each loop to avoid checking for - output space. - */ -void ZLIB_INTERNAL inflate_fast(strm, start) -z_streamp strm; -unsigned start; /* inflate()'s starting value for strm->avail_out */ -{ - struct inflate_state FAR *state; - z_const unsigned char FAR *in; /* local strm->next_in */ - z_const unsigned char FAR *last; /* have enough input while in < last */ - unsigned char FAR *out; /* local strm->next_out */ - unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ - unsigned char FAR *end; /* while out < end, enough space available */ -#ifdef INFLATE_STRICT - unsigned dmax; /* maximum distance from zlib header */ -#endif - unsigned wsize; /* window size or zero if not using window */ - unsigned whave; /* valid bytes in the window */ - unsigned wnext; /* window write index */ - unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ - unsigned long hold; /* local strm->hold */ - unsigned bits; /* local strm->bits */ - code const FAR *lcode; /* local strm->lencode */ - code const FAR *dcode; /* local strm->distcode */ - unsigned lmask; /* mask for first level of length codes */ - unsigned dmask; /* mask for first level of distance codes */ - code here; /* retrieved table entry */ - unsigned op; /* code bits, operation, extra bits, or */ - /* window position, window bytes to copy */ - unsigned len; /* match length, unused bytes */ - unsigned dist; /* match distance */ - unsigned char FAR *from; /* where to copy match from */ - - /* copy state to local variables */ - state = (struct inflate_state FAR *)strm->state; - in = strm->next_in - OFF; - last = in + (strm->avail_in - 5); - out = strm->next_out - OFF; - beg = out - (start - strm->avail_out); - end = out + (strm->avail_out - 257); -#ifdef INFLATE_STRICT - dmax = state->dmax; -#endif - wsize = state->wsize; - whave = state->whave; - wnext = state->wnext; - window = state->window; - hold = state->hold; - bits = state->bits; - lcode = state->lencode; - dcode = state->distcode; - lmask = (1U << state->lenbits) - 1; - dmask = (1U << state->distbits) - 1; - - /* decode literals and length/distances until end-of-block or not enough - input data or output space */ - do { - if (bits < 15) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - here = lcode[hold & lmask]; - dolen: - op = (unsigned)(here.bits); - hold >>= op; - bits -= op; - op = (unsigned)(here.op); - if (op == 0) { /* literal */ - Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", here.val)); - PUP(out) = (unsigned char)(here.val); - } - else if (op & 16) { /* length base */ - len = (unsigned)(here.val); - op &= 15; /* number of extra bits */ - if (op) { - if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - len += (unsigned)hold & ((1U << op) - 1); - hold >>= op; - bits -= op; - } - Tracevv((stderr, "inflate: length %u\n", len)); - if (bits < 15) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - here = dcode[hold & dmask]; - dodist: - op = (unsigned)(here.bits); - hold >>= op; - bits -= op; - op = (unsigned)(here.op); - if (op & 16) { /* distance base */ - dist = (unsigned)(here.val); - op &= 15; /* number of extra bits */ - if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - } - dist += (unsigned)hold & ((1U << op) - 1); -#ifdef INFLATE_STRICT - if (dist > dmax) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#endif - hold >>= op; - bits -= op; - Tracevv((stderr, "inflate: distance %u\n", dist)); - op = (unsigned)(out - beg); /* max distance in output */ - if (dist > op) { /* see if copy from window */ - op = dist - op; /* distance back in window */ - if (op > whave) { - if (state->sane) { - strm->msg = - (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR - if (len <= op - whave) { - do { - PUP(out) = 0; - } while (--len); - continue; - } - len -= op - whave; - do { - PUP(out) = 0; - } while (--op > whave); - if (op == 0) { - from = out - dist; - do { - PUP(out) = PUP(from); - } while (--len); - continue; - } -#endif - } - from = window - OFF; - if (wnext == 0) { /* very common case */ - from += wsize - op; - if (op < len) { /* some from window */ - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = out - dist; /* rest from output */ - } - } - else if (wnext < op) { /* wrap around window */ - from += wsize + wnext - op; - op -= wnext; - if (op < len) { /* some from end of window */ - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = window - OFF; - if (wnext < len) { /* some from start of window */ - op = wnext; - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = out - dist; /* rest from output */ - } - } - } - else { /* contiguous in window */ - from += wnext - op; - if (op < len) { /* some from window */ - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = out - dist; /* rest from output */ - } - } - while (len > 2) { - PUP(out) = PUP(from); - PUP(out) = PUP(from); - PUP(out) = PUP(from); - len -= 3; - } - if (len) { - PUP(out) = PUP(from); - if (len > 1) - PUP(out) = PUP(from); - } - } - else { - from = out - dist; /* copy direct from output */ - do { /* minimum length is three */ - PUP(out) = PUP(from); - PUP(out) = PUP(from); - PUP(out) = PUP(from); - len -= 3; - } while (len > 2); - if (len) { - PUP(out) = PUP(from); - if (len > 1) - PUP(out) = PUP(from); - } - } - } - else if ((op & 64) == 0) { /* 2nd level distance code */ - here = dcode[here.val + (hold & ((1U << op) - 1))]; - goto dodist; - } - else { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - } - else if ((op & 64) == 0) { /* 2nd level length code */ - here = lcode[here.val + (hold & ((1U << op) - 1))]; - goto dolen; - } - else if (op & 32) { /* end-of-block */ - Tracevv((stderr, "inflate: end of block\n")); - state->mode = TYPE; - break; - } - else { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - } while (in < last && out < end); - - /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ - len = bits >> 3; - in -= len; - bits -= len << 3; - hold &= (1U << bits) - 1; - - /* update state and return */ - strm->next_in = in + OFF; - strm->next_out = out + OFF; - strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); - strm->avail_out = (unsigned)(out < end ? - 257 + (end - out) : 257 - (out - end)); - state->hold = hold; - state->bits = bits; - return; -} - -/* - inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe): - - Using bit fields for code structure - - Different op definition to avoid & for extra bits (do & for table bits) - - Three separate decoding do-loops for direct, window, and wnext == 0 - - Special case for distance > 1 copies to do overlapped load and store copy - - Explicit branch predictions (based on measured branch probabilities) - - Deferring match copy and interspersed it with decoding subsequent codes - - Swapping literal/length else - - Swapping window/direct else - - Larger unrolled copy loops (three is about right) - - Moving len -= 3 statement into middle of loop - */ - -#endif /* !ASMINF */ diff --git a/libs/zlib/src/inffast.h b/libs/zlib/src/inffast.h deleted file mode 100644 index e5c1aa4c..00000000 --- a/libs/zlib/src/inffast.h +++ /dev/null @@ -1,11 +0,0 @@ -/* inffast.h -- header to use inffast.c - * Copyright (C) 1995-2003, 2010 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); diff --git a/libs/zlib/src/inffixed.h b/libs/zlib/src/inffixed.h deleted file mode 100644 index d6283277..00000000 --- a/libs/zlib/src/inffixed.h +++ /dev/null @@ -1,94 +0,0 @@ - /* inffixed.h -- table for decoding fixed codes - * Generated automatically by makefixed(). - */ - - /* WARNING: this file should *not* be used by applications. - It is part of the implementation of this library and is - subject to change. Applications should only use zlib.h. - */ - - static const code lenfix[512] = { - {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, - {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, - {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, - {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, - {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, - {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, - {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, - {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, - {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, - {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, - {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, - {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, - {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, - {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, - {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, - {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, - {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, - {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, - {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, - {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, - {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, - {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, - {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, - {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, - {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, - {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, - {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, - {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, - {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, - {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, - {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, - {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, - {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, - {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, - {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, - {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, - {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, - {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, - {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, - {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, - {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, - {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, - {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, - {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, - {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, - {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, - {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, - {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, - {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, - {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, - {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, - {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, - {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, - {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, - {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, - {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, - {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, - {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, - {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, - {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, - {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, - {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, - {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, - {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, - {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, - {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, - {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, - {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, - {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, - {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, - {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, - {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, - {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, - {0,9,255} - }; - - static const code distfix[32] = { - {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, - {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, - {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, - {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, - {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, - {22,5,193},{64,5,0} - }; diff --git a/libs/zlib/src/inflate.c b/libs/zlib/src/inflate.c deleted file mode 100644 index 870f89bb..00000000 --- a/libs/zlib/src/inflate.c +++ /dev/null @@ -1,1512 +0,0 @@ -/* inflate.c -- zlib decompression - * Copyright (C) 1995-2012 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * Change history: - * - * 1.2.beta0 24 Nov 2002 - * - First version -- complete rewrite of inflate to simplify code, avoid - * creation of window when not needed, minimize use of window when it is - * needed, make inffast.c even faster, implement gzip decoding, and to - * improve code readability and style over the previous zlib inflate code - * - * 1.2.beta1 25 Nov 2002 - * - Use pointers for available input and output checking in inffast.c - * - Remove input and output counters in inffast.c - * - Change inffast.c entry and loop from avail_in >= 7 to >= 6 - * - Remove unnecessary second byte pull from length extra in inffast.c - * - Unroll direct copy to three copies per loop in inffast.c - * - * 1.2.beta2 4 Dec 2002 - * - Change external routine names to reduce potential conflicts - * - Correct filename to inffixed.h for fixed tables in inflate.c - * - Make hbuf[] unsigned char to match parameter type in inflate.c - * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset) - * to avoid negation problem on Alphas (64 bit) in inflate.c - * - * 1.2.beta3 22 Dec 2002 - * - Add comments on state->bits assertion in inffast.c - * - Add comments on op field in inftrees.h - * - Fix bug in reuse of allocated window after inflateReset() - * - Remove bit fields--back to byte structure for speed - * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths - * - Change post-increments to pre-increments in inflate_fast(), PPC biased? - * - Add compile time option, POSTINC, to use post-increments instead (Intel?) - * - Make MATCH copy in inflate() much faster for when inflate_fast() not used - * - Use local copies of stream next and avail values, as well as local bit - * buffer and bit count in inflate()--for speed when inflate_fast() not used - * - * 1.2.beta4 1 Jan 2003 - * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings - * - Move a comment on output buffer sizes from inffast.c to inflate.c - * - Add comments in inffast.c to introduce the inflate_fast() routine - * - Rearrange window copies in inflate_fast() for speed and simplification - * - Unroll last copy for window match in inflate_fast() - * - Use local copies of window variables in inflate_fast() for speed - * - Pull out common wnext == 0 case for speed in inflate_fast() - * - Make op and len in inflate_fast() unsigned for consistency - * - Add FAR to lcode and dcode declarations in inflate_fast() - * - Simplified bad distance check in inflate_fast() - * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new - * source file infback.c to provide a call-back interface to inflate for - * programs like gzip and unzip -- uses window as output buffer to avoid - * window copying - * - * 1.2.beta5 1 Jan 2003 - * - Improved inflateBack() interface to allow the caller to provide initial - * input in strm. - * - Fixed stored blocks bug in inflateBack() - * - * 1.2.beta6 4 Jan 2003 - * - Added comments in inffast.c on effectiveness of POSTINC - * - Typecasting all around to reduce compiler warnings - * - Changed loops from while (1) or do {} while (1) to for (;;), again to - * make compilers happy - * - Changed type of window in inflateBackInit() to unsigned char * - * - * 1.2.beta7 27 Jan 2003 - * - Changed many types to unsigned or unsigned short to avoid warnings - * - Added inflateCopy() function - * - * 1.2.0 9 Mar 2003 - * - Changed inflateBack() interface to provide separate opaque descriptors - * for the in() and out() functions - * - Changed inflateBack() argument and in_func typedef to swap the length - * and buffer address return values for the input function - * - Check next_in and next_out for Z_NULL on entry to inflate() - * - * The history for versions after 1.2.0 are in ChangeLog in zlib distribution. - */ - -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -#ifdef MAKEFIXED -# ifndef BUILDFIXED -# define BUILDFIXED -# endif -#endif - -/* function prototypes */ -local void fixedtables OF((struct inflate_state FAR *state)); -local int updatewindow OF((z_streamp strm, const unsigned char FAR *end, - unsigned copy)); -#ifdef BUILDFIXED - void makefixed OF((void)); -#endif -local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf, - unsigned len)); - -int ZEXPORT inflateResetKeep(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - strm->total_in = strm->total_out = state->total = 0; - strm->msg = Z_NULL; - if (state->wrap) /* to support ill-conceived Java test suite */ - strm->adler = state->wrap & 1; - state->mode = HEAD; - state->last = 0; - state->havedict = 0; - state->dmax = 32768U; - state->head = Z_NULL; - state->hold = 0; - state->bits = 0; - state->lencode = state->distcode = state->next = state->codes; - state->sane = 1; - state->back = -1; - Tracev((stderr, "inflate: reset\n")); - return Z_OK; -} - -int ZEXPORT inflateReset(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - state->wsize = 0; - state->whave = 0; - state->wnext = 0; - return inflateResetKeep(strm); -} - -int ZEXPORT inflateReset2(strm, windowBits) -z_streamp strm; -int windowBits; -{ - int wrap; - struct inflate_state FAR *state; - - /* get the state */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - - /* extract wrap request from windowBits parameter */ - if (windowBits < 0) { - wrap = 0; - windowBits = -windowBits; - } - else { - wrap = (windowBits >> 4) + 1; -#ifdef GUNZIP - if (windowBits < 48) - windowBits &= 15; -#endif - } - - /* set number of window bits, free window if different */ - if (windowBits && (windowBits < 8 || windowBits > 15)) - return Z_STREAM_ERROR; - if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) { - ZFREE(strm, state->window); - state->window = Z_NULL; - } - - /* update state and reset the rest of it */ - state->wrap = wrap; - state->wbits = (unsigned)windowBits; - return inflateReset(strm); -} - -int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) -z_streamp strm; -int windowBits; -const char *version; -int stream_size; -{ - int ret; - struct inflate_state FAR *state; - - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || - stream_size != (int)(sizeof(z_stream))) - return Z_VERSION_ERROR; - if (strm == Z_NULL) return Z_STREAM_ERROR; - strm->msg = Z_NULL; /* in case we return an error */ - if (strm->zalloc == (alloc_func)0) { -#ifdef Z_SOLO - return Z_STREAM_ERROR; -#else - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; -#endif - } - if (strm->zfree == (free_func)0) -#ifdef Z_SOLO - return Z_STREAM_ERROR; -#else - strm->zfree = zcfree; -#endif - state = (struct inflate_state FAR *) - ZALLOC(strm, 1, sizeof(struct inflate_state)); - if (state == Z_NULL) return Z_MEM_ERROR; - Tracev((stderr, "inflate: allocated\n")); - strm->state = (struct internal_state FAR *)state; - state->window = Z_NULL; - ret = inflateReset2(strm, windowBits); - if (ret != Z_OK) { - ZFREE(strm, state); - strm->state = Z_NULL; - } - return ret; -} - -int ZEXPORT inflateInit_(strm, version, stream_size) -z_streamp strm; -const char *version; -int stream_size; -{ - return inflateInit2_(strm, DEF_WBITS, version, stream_size); -} - -int ZEXPORT inflatePrime(strm, bits, value) -z_streamp strm; -int bits; -int value; -{ - struct inflate_state FAR *state; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (bits < 0) { - state->hold = 0; - state->bits = 0; - return Z_OK; - } - if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR; - value &= (1L << bits) - 1; - state->hold += value << state->bits; - state->bits += bits; - return Z_OK; -} - -/* - Return state with length and distance decoding tables and index sizes set to - fixed code decoding. Normally this returns fixed tables from inffixed.h. - If BUILDFIXED is defined, then instead this routine builds the tables the - first time it's called, and returns those tables the first time and - thereafter. This reduces the size of the code by about 2K bytes, in - exchange for a little execution time. However, BUILDFIXED should not be - used for threaded applications, since the rewriting of the tables and virgin - may not be thread-safe. - */ -local void fixedtables(state) -struct inflate_state FAR *state; -{ -#ifdef BUILDFIXED - static int virgin = 1; - static code *lenfix, *distfix; - static code fixed[544]; - - /* build fixed huffman tables if first call (may not be thread safe) */ - if (virgin) { - unsigned sym, bits; - static code *next; - - /* literal/length table */ - sym = 0; - while (sym < 144) state->lens[sym++] = 8; - while (sym < 256) state->lens[sym++] = 9; - while (sym < 280) state->lens[sym++] = 7; - while (sym < 288) state->lens[sym++] = 8; - next = fixed; - lenfix = next; - bits = 9; - inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); - - /* distance table */ - sym = 0; - while (sym < 32) state->lens[sym++] = 5; - distfix = next; - bits = 5; - inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); - - /* do this just once */ - virgin = 0; - } -#else /* !BUILDFIXED */ -# include "inffixed.h" -#endif /* BUILDFIXED */ - state->lencode = lenfix; - state->lenbits = 9; - state->distcode = distfix; - state->distbits = 5; -} - -#ifdef MAKEFIXED -#include - -/* - Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also - defines BUILDFIXED, so the tables are built on the fly. makefixed() writes - those tables to stdout, which would be piped to inffixed.h. A small program - can simply call makefixed to do this: - - void makefixed(void); - - int main(void) - { - makefixed(); - return 0; - } - - Then that can be linked with zlib built with MAKEFIXED defined and run: - - a.out > inffixed.h - */ -void makefixed() -{ - unsigned low, size; - struct inflate_state state; - - fixedtables(&state); - puts(" /* inffixed.h -- table for decoding fixed codes"); - puts(" * Generated automatically by makefixed()."); - puts(" */"); - puts(""); - puts(" /* WARNING: this file should *not* be used by applications."); - puts(" It is part of the implementation of this library and is"); - puts(" subject to change. Applications should only use zlib.h."); - puts(" */"); - puts(""); - size = 1U << 9; - printf(" static const code lenfix[%u] = {", size); - low = 0; - for (;;) { - if ((low % 7) == 0) printf("\n "); - printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op, - state.lencode[low].bits, state.lencode[low].val); - if (++low == size) break; - putchar(','); - } - puts("\n };"); - size = 1U << 5; - printf("\n static const code distfix[%u] = {", size); - low = 0; - for (;;) { - if ((low % 6) == 0) printf("\n "); - printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, - state.distcode[low].val); - if (++low == size) break; - putchar(','); - } - puts("\n };"); -} -#endif /* MAKEFIXED */ - -/* - Update the window with the last wsize (normally 32K) bytes written before - returning. If window does not exist yet, create it. This is only called - when a window is already in use, or when output has been written during this - inflate call, but the end of the deflate stream has not been reached yet. - It is also called to create a window for dictionary data when a dictionary - is loaded. - - Providing output buffers larger than 32K to inflate() should provide a speed - advantage, since only the last 32K of output is copied to the sliding window - upon return from inflate(), and since all distances after the first 32K of - output will fall in the output data, making match copies simpler and faster. - The advantage may be dependent on the size of the processor's data caches. - */ -local int updatewindow(strm, end, copy) -z_streamp strm; -const Bytef *end; -unsigned copy; -{ - struct inflate_state FAR *state; - unsigned dist; - - state = (struct inflate_state FAR *)strm->state; - - /* if it hasn't been done already, allocate space for the window */ - if (state->window == Z_NULL) { - state->window = (unsigned char FAR *) - ZALLOC(strm, 1U << state->wbits, - sizeof(unsigned char)); - if (state->window == Z_NULL) return 1; - } - - /* if window not in use yet, initialize */ - if (state->wsize == 0) { - state->wsize = 1U << state->wbits; - state->wnext = 0; - state->whave = 0; - } - - /* copy state->wsize or less output bytes into the circular window */ - if (copy >= state->wsize) { - zmemcpy(state->window, end - state->wsize, state->wsize); - state->wnext = 0; - state->whave = state->wsize; - } - else { - dist = state->wsize - state->wnext; - if (dist > copy) dist = copy; - zmemcpy(state->window + state->wnext, end - copy, dist); - copy -= dist; - if (copy) { - zmemcpy(state->window, end - copy, copy); - state->wnext = copy; - state->whave = state->wsize; - } - else { - state->wnext += dist; - if (state->wnext == state->wsize) state->wnext = 0; - if (state->whave < state->wsize) state->whave += dist; - } - } - return 0; -} - -/* Macros for inflate(): */ - -/* check function to use adler32() for zlib or crc32() for gzip */ -#ifdef GUNZIP -# define UPDATE(check, buf, len) \ - (state->flags ? crc32(check, buf, len) : adler32(check, buf, len)) -#else -# define UPDATE(check, buf, len) adler32(check, buf, len) -#endif - -/* check macros for header crc */ -#ifdef GUNZIP -# define CRC2(check, word) \ - do { \ - hbuf[0] = (unsigned char)(word); \ - hbuf[1] = (unsigned char)((word) >> 8); \ - check = crc32(check, hbuf, 2); \ - } while (0) - -# define CRC4(check, word) \ - do { \ - hbuf[0] = (unsigned char)(word); \ - hbuf[1] = (unsigned char)((word) >> 8); \ - hbuf[2] = (unsigned char)((word) >> 16); \ - hbuf[3] = (unsigned char)((word) >> 24); \ - check = crc32(check, hbuf, 4); \ - } while (0) -#endif - -/* Load registers with state in inflate() for speed */ -#define LOAD() \ - do { \ - put = strm->next_out; \ - left = strm->avail_out; \ - next = strm->next_in; \ - have = strm->avail_in; \ - hold = state->hold; \ - bits = state->bits; \ - } while (0) - -/* Restore state from registers in inflate() */ -#define RESTORE() \ - do { \ - strm->next_out = put; \ - strm->avail_out = left; \ - strm->next_in = next; \ - strm->avail_in = have; \ - state->hold = hold; \ - state->bits = bits; \ - } while (0) - -/* Clear the input bit accumulator */ -#define INITBITS() \ - do { \ - hold = 0; \ - bits = 0; \ - } while (0) - -/* Get a byte of input into the bit accumulator, or return from inflate() - if there is no input available. */ -#define PULLBYTE() \ - do { \ - if (have == 0) goto inf_leave; \ - have--; \ - hold += (unsigned long)(*next++) << bits; \ - bits += 8; \ - } while (0) - -/* Assure that there are at least n bits in the bit accumulator. If there is - not enough available input to do that, then return from inflate(). */ -#define NEEDBITS(n) \ - do { \ - while (bits < (unsigned)(n)) \ - PULLBYTE(); \ - } while (0) - -/* Return the low n bits of the bit accumulator (n < 16) */ -#define BITS(n) \ - ((unsigned)hold & ((1U << (n)) - 1)) - -/* Remove n bits from the bit accumulator */ -#define DROPBITS(n) \ - do { \ - hold >>= (n); \ - bits -= (unsigned)(n); \ - } while (0) - -/* Remove zero to seven bits as needed to go to a byte boundary */ -#define BYTEBITS() \ - do { \ - hold >>= bits & 7; \ - bits -= bits & 7; \ - } while (0) - -/* - inflate() uses a state machine to process as much input data and generate as - much output data as possible before returning. The state machine is - structured roughly as follows: - - for (;;) switch (state) { - ... - case STATEn: - if (not enough input data or output space to make progress) - return; - ... make progress ... - state = STATEm; - break; - ... - } - - so when inflate() is called again, the same case is attempted again, and - if the appropriate resources are provided, the machine proceeds to the - next state. The NEEDBITS() macro is usually the way the state evaluates - whether it can proceed or should return. NEEDBITS() does the return if - the requested bits are not available. The typical use of the BITS macros - is: - - NEEDBITS(n); - ... do something with BITS(n) ... - DROPBITS(n); - - where NEEDBITS(n) either returns from inflate() if there isn't enough - input left to load n bits into the accumulator, or it continues. BITS(n) - gives the low n bits in the accumulator. When done, DROPBITS(n) drops - the low n bits off the accumulator. INITBITS() clears the accumulator - and sets the number of available bits to zero. BYTEBITS() discards just - enough bits to put the accumulator on a byte boundary. After BYTEBITS() - and a NEEDBITS(8), then BITS(8) would return the next byte in the stream. - - NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return - if there is no input available. The decoding of variable length codes uses - PULLBYTE() directly in order to pull just enough bytes to decode the next - code, and no more. - - Some states loop until they get enough input, making sure that enough - state information is maintained to continue the loop where it left off - if NEEDBITS() returns in the loop. For example, want, need, and keep - would all have to actually be part of the saved state in case NEEDBITS() - returns: - - case STATEw: - while (want < need) { - NEEDBITS(n); - keep[want++] = BITS(n); - DROPBITS(n); - } - state = STATEx; - case STATEx: - - As shown above, if the next state is also the next case, then the break - is omitted. - - A state may also return if there is not enough output space available to - complete that state. Those states are copying stored data, writing a - literal byte, and copying a matching string. - - When returning, a "goto inf_leave" is used to update the total counters, - update the check value, and determine whether any progress has been made - during that inflate() call in order to return the proper return code. - Progress is defined as a change in either strm->avail_in or strm->avail_out. - When there is a window, goto inf_leave will update the window with the last - output written. If a goto inf_leave occurs in the middle of decompression - and there is no window currently, goto inf_leave will create one and copy - output to the window for the next call of inflate(). - - In this implementation, the flush parameter of inflate() only affects the - return code (per zlib.h). inflate() always writes as much as possible to - strm->next_out, given the space available and the provided input--the effect - documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers - the allocation of and copying into a sliding window until necessary, which - provides the effect documented in zlib.h for Z_FINISH when the entire input - stream available. So the only thing the flush parameter actually does is: - when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it - will return Z_BUF_ERROR if it has not reached the end of the stream. - */ - -int ZEXPORT inflate(strm, flush) -z_streamp strm; -int flush; -{ - struct inflate_state FAR *state; - z_const unsigned char FAR *next; /* next input */ - unsigned char FAR *put; /* next output */ - unsigned have, left; /* available input and output */ - unsigned long hold; /* bit buffer */ - unsigned bits; /* bits in bit buffer */ - unsigned in, out; /* save starting available input and output */ - unsigned copy; /* number of stored or match bytes to copy */ - unsigned char FAR *from; /* where to copy match bytes from */ - code here; /* current decoding table entry */ - code last; /* parent table entry */ - unsigned len; /* length to copy for repeats, bits to drop */ - int ret; /* return code */ -#ifdef GUNZIP - unsigned char hbuf[4]; /* buffer for gzip header crc calculation */ -#endif - static const unsigned short order[19] = /* permutation of code lengths */ - {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - - if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL || - (strm->next_in == Z_NULL && strm->avail_in != 0)) - return Z_STREAM_ERROR; - - state = (struct inflate_state FAR *)strm->state; - if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */ - LOAD(); - in = have; - out = left; - ret = Z_OK; - for (;;) - switch (state->mode) { - case HEAD: - if (state->wrap == 0) { - state->mode = TYPEDO; - break; - } - NEEDBITS(16); -#ifdef GUNZIP - if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */ - state->check = crc32(0L, Z_NULL, 0); - CRC2(state->check, hold); - INITBITS(); - state->mode = FLAGS; - break; - } - state->flags = 0; /* expect zlib header */ - if (state->head != Z_NULL) - state->head->done = -1; - if (!(state->wrap & 1) || /* check if zlib header allowed */ -#else - if ( -#endif - ((BITS(8) << 8) + (hold >> 8)) % 31) { - strm->msg = (char *)"incorrect header check"; - state->mode = BAD; - break; - } - if (BITS(4) != Z_DEFLATED) { - strm->msg = (char *)"unknown compression method"; - state->mode = BAD; - break; - } - DROPBITS(4); - len = BITS(4) + 8; - if (state->wbits == 0) - state->wbits = len; - else if (len > state->wbits) { - strm->msg = (char *)"invalid window size"; - state->mode = BAD; - break; - } - state->dmax = 1U << len; - Tracev((stderr, "inflate: zlib header ok\n")); - strm->adler = state->check = adler32(0L, Z_NULL, 0); - state->mode = hold & 0x200 ? DICTID : TYPE; - INITBITS(); - break; -#ifdef GUNZIP - case FLAGS: - NEEDBITS(16); - state->flags = (int)(hold); - if ((state->flags & 0xff) != Z_DEFLATED) { - strm->msg = (char *)"unknown compression method"; - state->mode = BAD; - break; - } - if (state->flags & 0xe000) { - strm->msg = (char *)"unknown header flags set"; - state->mode = BAD; - break; - } - if (state->head != Z_NULL) - state->head->text = (int)((hold >> 8) & 1); - if (state->flags & 0x0200) CRC2(state->check, hold); - INITBITS(); - state->mode = TIME; - case TIME: - NEEDBITS(32); - if (state->head != Z_NULL) - state->head->time = hold; - if (state->flags & 0x0200) CRC4(state->check, hold); - INITBITS(); - state->mode = OS; - case OS: - NEEDBITS(16); - if (state->head != Z_NULL) { - state->head->xflags = (int)(hold & 0xff); - state->head->os = (int)(hold >> 8); - } - if (state->flags & 0x0200) CRC2(state->check, hold); - INITBITS(); - state->mode = EXLEN; - case EXLEN: - if (state->flags & 0x0400) { - NEEDBITS(16); - state->length = (unsigned)(hold); - if (state->head != Z_NULL) - state->head->extra_len = (unsigned)hold; - if (state->flags & 0x0200) CRC2(state->check, hold); - INITBITS(); - } - else if (state->head != Z_NULL) - state->head->extra = Z_NULL; - state->mode = EXTRA; - case EXTRA: - if (state->flags & 0x0400) { - copy = state->length; - if (copy > have) copy = have; - if (copy) { - if (state->head != Z_NULL && - state->head->extra != Z_NULL) { - len = state->head->extra_len - state->length; - zmemcpy(state->head->extra + len, next, - len + copy > state->head->extra_max ? - state->head->extra_max - len : copy); - } - if (state->flags & 0x0200) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - state->length -= copy; - } - if (state->length) goto inf_leave; - } - state->length = 0; - state->mode = NAME; - case NAME: - if (state->flags & 0x0800) { - if (have == 0) goto inf_leave; - copy = 0; - do { - len = (unsigned)(next[copy++]); - if (state->head != Z_NULL && - state->head->name != Z_NULL && - state->length < state->head->name_max) - state->head->name[state->length++] = len; - } while (len && copy < have); - if (state->flags & 0x0200) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - if (len) goto inf_leave; - } - else if (state->head != Z_NULL) - state->head->name = Z_NULL; - state->length = 0; - state->mode = COMMENT; - case COMMENT: - if (state->flags & 0x1000) { - if (have == 0) goto inf_leave; - copy = 0; - do { - len = (unsigned)(next[copy++]); - if (state->head != Z_NULL && - state->head->comment != Z_NULL && - state->length < state->head->comm_max) - state->head->comment[state->length++] = len; - } while (len && copy < have); - if (state->flags & 0x0200) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - if (len) goto inf_leave; - } - else if (state->head != Z_NULL) - state->head->comment = Z_NULL; - state->mode = HCRC; - case HCRC: - if (state->flags & 0x0200) { - NEEDBITS(16); - if (hold != (state->check & 0xffff)) { - strm->msg = (char *)"header crc mismatch"; - state->mode = BAD; - break; - } - INITBITS(); - } - if (state->head != Z_NULL) { - state->head->hcrc = (int)((state->flags >> 9) & 1); - state->head->done = 1; - } - strm->adler = state->check = crc32(0L, Z_NULL, 0); - state->mode = TYPE; - break; -#endif - case DICTID: - NEEDBITS(32); - strm->adler = state->check = ZSWAP32(hold); - INITBITS(); - state->mode = DICT; - case DICT: - if (state->havedict == 0) { - RESTORE(); - return Z_NEED_DICT; - } - strm->adler = state->check = adler32(0L, Z_NULL, 0); - state->mode = TYPE; - case TYPE: - if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave; - case TYPEDO: - if (state->last) { - BYTEBITS(); - state->mode = CHECK; - break; - } - NEEDBITS(3); - state->last = BITS(1); - DROPBITS(1); - switch (BITS(2)) { - case 0: /* stored block */ - Tracev((stderr, "inflate: stored block%s\n", - state->last ? " (last)" : "")); - state->mode = STORED; - break; - case 1: /* fixed block */ - fixedtables(state); - Tracev((stderr, "inflate: fixed codes block%s\n", - state->last ? " (last)" : "")); - state->mode = LEN_; /* decode codes */ - if (flush == Z_TREES) { - DROPBITS(2); - goto inf_leave; - } - break; - case 2: /* dynamic block */ - Tracev((stderr, "inflate: dynamic codes block%s\n", - state->last ? " (last)" : "")); - state->mode = TABLE; - break; - case 3: - strm->msg = (char *)"invalid block type"; - state->mode = BAD; - } - DROPBITS(2); - break; - case STORED: - BYTEBITS(); /* go to byte boundary */ - NEEDBITS(32); - if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { - strm->msg = (char *)"invalid stored block lengths"; - state->mode = BAD; - break; - } - state->length = (unsigned)hold & 0xffff; - Tracev((stderr, "inflate: stored length %u\n", - state->length)); - INITBITS(); - state->mode = COPY_; - if (flush == Z_TREES) goto inf_leave; - case COPY_: - state->mode = COPY; - case COPY: - copy = state->length; - if (copy) { - if (copy > have) copy = have; - if (copy > left) copy = left; - if (copy == 0) goto inf_leave; - zmemcpy(put, next, copy); - have -= copy; - next += copy; - left -= copy; - put += copy; - state->length -= copy; - break; - } - Tracev((stderr, "inflate: stored end\n")); - state->mode = TYPE; - break; - case TABLE: - NEEDBITS(14); - state->nlen = BITS(5) + 257; - DROPBITS(5); - state->ndist = BITS(5) + 1; - DROPBITS(5); - state->ncode = BITS(4) + 4; - DROPBITS(4); -#ifndef PKZIP_BUG_WORKAROUND - if (state->nlen > 286 || state->ndist > 30) { - strm->msg = (char *)"too many length or distance symbols"; - state->mode = BAD; - break; - } -#endif - Tracev((stderr, "inflate: table sizes ok\n")); - state->have = 0; - state->mode = LENLENS; - case LENLENS: - while (state->have < state->ncode) { - NEEDBITS(3); - state->lens[order[state->have++]] = (unsigned short)BITS(3); - DROPBITS(3); - } - while (state->have < 19) - state->lens[order[state->have++]] = 0; - state->next = state->codes; - state->lencode = (const code FAR *)(state->next); - state->lenbits = 7; - ret = inflate_table(CODES, state->lens, 19, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid code lengths set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: code lengths ok\n")); - state->have = 0; - state->mode = CODELENS; - case CODELENS: - while (state->have < state->nlen + state->ndist) { - for (;;) { - here = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if (here.val < 16) { - DROPBITS(here.bits); - state->lens[state->have++] = here.val; - } - else { - if (here.val == 16) { - NEEDBITS(here.bits + 2); - DROPBITS(here.bits); - if (state->have == 0) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - len = state->lens[state->have - 1]; - copy = 3 + BITS(2); - DROPBITS(2); - } - else if (here.val == 17) { - NEEDBITS(here.bits + 3); - DROPBITS(here.bits); - len = 0; - copy = 3 + BITS(3); - DROPBITS(3); - } - else { - NEEDBITS(here.bits + 7); - DROPBITS(here.bits); - len = 0; - copy = 11 + BITS(7); - DROPBITS(7); - } - if (state->have + copy > state->nlen + state->ndist) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - while (copy--) - state->lens[state->have++] = (unsigned short)len; - } - } - - /* handle error breaks in while */ - if (state->mode == BAD) break; - - /* check for end-of-block code (better have one) */ - if (state->lens[256] == 0) { - strm->msg = (char *)"invalid code -- missing end-of-block"; - state->mode = BAD; - break; - } - - /* build code tables -- note: do not change the lenbits or distbits - values here (9 and 6) without reading the comments in inftrees.h - concerning the ENOUGH constants, which depend on those values */ - state->next = state->codes; - state->lencode = (const code FAR *)(state->next); - state->lenbits = 9; - ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid literal/lengths set"; - state->mode = BAD; - break; - } - state->distcode = (const code FAR *)(state->next); - state->distbits = 6; - ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, - &(state->next), &(state->distbits), state->work); - if (ret) { - strm->msg = (char *)"invalid distances set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: codes ok\n")); - state->mode = LEN_; - if (flush == Z_TREES) goto inf_leave; - case LEN_: - state->mode = LEN; - case LEN: - if (have >= 6 && left >= 258) { - RESTORE(); - inflate_fast(strm, out); - LOAD(); - if (state->mode == TYPE) - state->back = -1; - break; - } - state->back = 0; - for (;;) { - here = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if (here.op && (here.op & 0xf0) == 0) { - last = here; - for (;;) { - here = state->lencode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + here.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - state->back += last.bits; - } - DROPBITS(here.bits); - state->back += here.bits; - state->length = (unsigned)here.val; - if ((int)(here.op) == 0) { - Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", here.val)); - state->mode = LIT; - break; - } - if (here.op & 32) { - Tracevv((stderr, "inflate: end of block\n")); - state->back = -1; - state->mode = TYPE; - break; - } - if (here.op & 64) { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - state->extra = (unsigned)(here.op) & 15; - state->mode = LENEXT; - case LENEXT: - if (state->extra) { - NEEDBITS(state->extra); - state->length += BITS(state->extra); - DROPBITS(state->extra); - state->back += state->extra; - } - Tracevv((stderr, "inflate: length %u\n", state->length)); - state->was = state->length; - state->mode = DIST; - case DIST: - for (;;) { - here = state->distcode[BITS(state->distbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if ((here.op & 0xf0) == 0) { - last = here; - for (;;) { - here = state->distcode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + here.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - state->back += last.bits; - } - DROPBITS(here.bits); - state->back += here.bits; - if (here.op & 64) { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - state->offset = (unsigned)here.val; - state->extra = (unsigned)(here.op) & 15; - state->mode = DISTEXT; - case DISTEXT: - if (state->extra) { - NEEDBITS(state->extra); - state->offset += BITS(state->extra); - DROPBITS(state->extra); - state->back += state->extra; - } -#ifdef INFLATE_STRICT - if (state->offset > state->dmax) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#endif - Tracevv((stderr, "inflate: distance %u\n", state->offset)); - state->mode = MATCH; - case MATCH: - if (left == 0) goto inf_leave; - copy = out - left; - if (state->offset > copy) { /* copy from window */ - copy = state->offset - copy; - if (copy > state->whave) { - if (state->sane) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR - Trace((stderr, "inflate.c too far\n")); - copy -= state->whave; - if (copy > state->length) copy = state->length; - if (copy > left) copy = left; - left -= copy; - state->length -= copy; - do { - *put++ = 0; - } while (--copy); - if (state->length == 0) state->mode = LEN; - break; -#endif - } - if (copy > state->wnext) { - copy -= state->wnext; - from = state->window + (state->wsize - copy); - } - else - from = state->window + (state->wnext - copy); - if (copy > state->length) copy = state->length; - } - else { /* copy from output */ - from = put - state->offset; - copy = state->length; - } - if (copy > left) copy = left; - left -= copy; - state->length -= copy; - do { - *put++ = *from++; - } while (--copy); - if (state->length == 0) state->mode = LEN; - break; - case LIT: - if (left == 0) goto inf_leave; - *put++ = (unsigned char)(state->length); - left--; - state->mode = LEN; - break; - case CHECK: - if (state->wrap) { - NEEDBITS(32); - out -= left; - strm->total_out += out; - state->total += out; - if (out) - strm->adler = state->check = - UPDATE(state->check, put - out, out); - out = left; - if (( -#ifdef GUNZIP - state->flags ? hold : -#endif - ZSWAP32(hold)) != state->check) { - strm->msg = (char *)"incorrect data check"; - state->mode = BAD; - break; - } - INITBITS(); - Tracev((stderr, "inflate: check matches trailer\n")); - } -#ifdef GUNZIP - state->mode = LENGTH; - case LENGTH: - if (state->wrap && state->flags) { - NEEDBITS(32); - if (hold != (state->total & 0xffffffffUL)) { - strm->msg = (char *)"incorrect length check"; - state->mode = BAD; - break; - } - INITBITS(); - Tracev((stderr, "inflate: length matches trailer\n")); - } -#endif - state->mode = DONE; - case DONE: - ret = Z_STREAM_END; - goto inf_leave; - case BAD: - ret = Z_DATA_ERROR; - goto inf_leave; - case MEM: - return Z_MEM_ERROR; - case SYNC: - default: - return Z_STREAM_ERROR; - } - - /* - Return from inflate(), updating the total counts and the check value. - If there was no progress during the inflate() call, return a buffer - error. Call updatewindow() to create and/or update the window state. - Note: a memory error from inflate() is non-recoverable. - */ - inf_leave: - RESTORE(); - if (state->wsize || (out != strm->avail_out && state->mode < BAD && - (state->mode < CHECK || flush != Z_FINISH))) - if (updatewindow(strm, strm->next_out, out - strm->avail_out)) { - state->mode = MEM; - return Z_MEM_ERROR; - } - in -= strm->avail_in; - out -= strm->avail_out; - strm->total_in += in; - strm->total_out += out; - state->total += out; - if (state->wrap && out) - strm->adler = state->check = - UPDATE(state->check, strm->next_out - out, out); - strm->data_type = state->bits + (state->last ? 64 : 0) + - (state->mode == TYPE ? 128 : 0) + - (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0); - if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) - ret = Z_BUF_ERROR; - return ret; -} - -int ZEXPORT inflateEnd(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (state->window != Z_NULL) ZFREE(strm, state->window); - ZFREE(strm, strm->state); - strm->state = Z_NULL; - Tracev((stderr, "inflate: end\n")); - return Z_OK; -} - -int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength) -z_streamp strm; -Bytef *dictionary; -uInt *dictLength; -{ - struct inflate_state FAR *state; - - /* check state */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - - /* copy dictionary */ - if (state->whave && dictionary != Z_NULL) { - zmemcpy(dictionary, state->window + state->wnext, - state->whave - state->wnext); - zmemcpy(dictionary + state->whave - state->wnext, - state->window, state->wnext); - } - if (dictLength != Z_NULL) - *dictLength = state->whave; - return Z_OK; -} - -int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) -z_streamp strm; -const Bytef *dictionary; -uInt dictLength; -{ - struct inflate_state FAR *state; - unsigned long dictid; - int ret; - - /* check state */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (state->wrap != 0 && state->mode != DICT) - return Z_STREAM_ERROR; - - /* check for correct dictionary identifier */ - if (state->mode == DICT) { - dictid = adler32(0L, Z_NULL, 0); - dictid = adler32(dictid, dictionary, dictLength); - if (dictid != state->check) - return Z_DATA_ERROR; - } - - /* copy dictionary to window using updatewindow(), which will amend the - existing dictionary if appropriate */ - ret = updatewindow(strm, dictionary + dictLength, dictLength); - if (ret) { - state->mode = MEM; - return Z_MEM_ERROR; - } - state->havedict = 1; - Tracev((stderr, "inflate: dictionary set\n")); - return Z_OK; -} - -int ZEXPORT inflateGetHeader(strm, head) -z_streamp strm; -gz_headerp head; -{ - struct inflate_state FAR *state; - - /* check state */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if ((state->wrap & 2) == 0) return Z_STREAM_ERROR; - - /* save header structure */ - state->head = head; - head->done = 0; - return Z_OK; -} - -/* - Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found - or when out of input. When called, *have is the number of pattern bytes - found in order so far, in 0..3. On return *have is updated to the new - state. If on return *have equals four, then the pattern was found and the - return value is how many bytes were read including the last byte of the - pattern. If *have is less than four, then the pattern has not been found - yet and the return value is len. In the latter case, syncsearch() can be - called again with more data and the *have state. *have is initialized to - zero for the first call. - */ -local unsigned syncsearch(have, buf, len) -unsigned FAR *have; -const unsigned char FAR *buf; -unsigned len; -{ - unsigned got; - unsigned next; - - got = *have; - next = 0; - while (next < len && got < 4) { - if ((int)(buf[next]) == (got < 2 ? 0 : 0xff)) - got++; - else if (buf[next]) - got = 0; - else - got = 4 - got; - next++; - } - *have = got; - return next; -} - -int ZEXPORT inflateSync(strm) -z_streamp strm; -{ - unsigned len; /* number of bytes to look at or looked at */ - unsigned long in, out; /* temporary to save total_in and total_out */ - unsigned char buf[4]; /* to restore bit buffer to byte string */ - struct inflate_state FAR *state; - - /* check parameters */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR; - - /* if first time, start search in bit buffer */ - if (state->mode != SYNC) { - state->mode = SYNC; - state->hold <<= state->bits & 7; - state->bits -= state->bits & 7; - len = 0; - while (state->bits >= 8) { - buf[len++] = (unsigned char)(state->hold); - state->hold >>= 8; - state->bits -= 8; - } - state->have = 0; - syncsearch(&(state->have), buf, len); - } - - /* search available input */ - len = syncsearch(&(state->have), strm->next_in, strm->avail_in); - strm->avail_in -= len; - strm->next_in += len; - strm->total_in += len; - - /* return no joy or set up to restart inflate() on a new block */ - if (state->have != 4) return Z_DATA_ERROR; - in = strm->total_in; out = strm->total_out; - inflateReset(strm); - strm->total_in = in; strm->total_out = out; - state->mode = TYPE; - return Z_OK; -} - -/* - Returns true if inflate is currently at the end of a block generated by - Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP - implementation to provide an additional safety check. PPP uses - Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored - block. When decompressing, PPP checks that at the end of input packet, - inflate is waiting for these length bytes. - */ -int ZEXPORT inflateSyncPoint(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - return state->mode == STORED && state->bits == 0; -} - -int ZEXPORT inflateCopy(dest, source) -z_streamp dest; -z_streamp source; -{ - struct inflate_state FAR *state; - struct inflate_state FAR *copy; - unsigned char FAR *window; - unsigned wsize; - - /* check input */ - if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL || - source->zalloc == (alloc_func)0 || source->zfree == (free_func)0) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)source->state; - - /* allocate space */ - copy = (struct inflate_state FAR *) - ZALLOC(source, 1, sizeof(struct inflate_state)); - if (copy == Z_NULL) return Z_MEM_ERROR; - window = Z_NULL; - if (state->window != Z_NULL) { - window = (unsigned char FAR *) - ZALLOC(source, 1U << state->wbits, sizeof(unsigned char)); - if (window == Z_NULL) { - ZFREE(source, copy); - return Z_MEM_ERROR; - } - } - - /* copy state */ - zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream)); - zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state)); - if (state->lencode >= state->codes && - state->lencode <= state->codes + ENOUGH - 1) { - copy->lencode = copy->codes + (state->lencode - state->codes); - copy->distcode = copy->codes + (state->distcode - state->codes); - } - copy->next = copy->codes + (state->next - state->codes); - if (window != Z_NULL) { - wsize = 1U << state->wbits; - zmemcpy(window, state->window, wsize); - } - copy->window = window; - dest->state = (struct internal_state FAR *)copy; - return Z_OK; -} - -int ZEXPORT inflateUndermine(strm, subvert) -z_streamp strm; -int subvert; -{ - struct inflate_state FAR *state; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - state->sane = !subvert; -#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR - return Z_OK; -#else - state->sane = 1; - return Z_DATA_ERROR; -#endif -} - -long ZEXPORT inflateMark(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - - if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16; - state = (struct inflate_state FAR *)strm->state; - return ((long)(state->back) << 16) + - (state->mode == COPY ? state->length : - (state->mode == MATCH ? state->was - state->length : 0)); -} diff --git a/libs/zlib/src/inflate.h b/libs/zlib/src/inflate.h deleted file mode 100644 index 95f4986d..00000000 --- a/libs/zlib/src/inflate.h +++ /dev/null @@ -1,122 +0,0 @@ -/* inflate.h -- internal inflate state definition - * Copyright (C) 1995-2009 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* define NO_GZIP when compiling if you want to disable gzip header and - trailer decoding by inflate(). NO_GZIP would be used to avoid linking in - the crc code when it is not needed. For shared libraries, gzip decoding - should be left enabled. */ -#ifndef NO_GZIP -# define GUNZIP -#endif - -/* Possible inflate modes between inflate() calls */ -typedef enum { - HEAD, /* i: waiting for magic header */ - FLAGS, /* i: waiting for method and flags (gzip) */ - TIME, /* i: waiting for modification time (gzip) */ - OS, /* i: waiting for extra flags and operating system (gzip) */ - EXLEN, /* i: waiting for extra length (gzip) */ - EXTRA, /* i: waiting for extra bytes (gzip) */ - NAME, /* i: waiting for end of file name (gzip) */ - COMMENT, /* i: waiting for end of comment (gzip) */ - HCRC, /* i: waiting for header crc (gzip) */ - DICTID, /* i: waiting for dictionary check value */ - DICT, /* waiting for inflateSetDictionary() call */ - TYPE, /* i: waiting for type bits, including last-flag bit */ - TYPEDO, /* i: same, but skip check to exit inflate on new block */ - STORED, /* i: waiting for stored size (length and complement) */ - COPY_, /* i/o: same as COPY below, but only first time in */ - COPY, /* i/o: waiting for input or output to copy stored block */ - TABLE, /* i: waiting for dynamic block table lengths */ - LENLENS, /* i: waiting for code length code lengths */ - CODELENS, /* i: waiting for length/lit and distance code lengths */ - LEN_, /* i: same as LEN below, but only first time in */ - LEN, /* i: waiting for length/lit/eob code */ - LENEXT, /* i: waiting for length extra bits */ - DIST, /* i: waiting for distance code */ - DISTEXT, /* i: waiting for distance extra bits */ - MATCH, /* o: waiting for output space to copy string */ - LIT, /* o: waiting for output space to write literal */ - CHECK, /* i: waiting for 32-bit check value */ - LENGTH, /* i: waiting for 32-bit length (gzip) */ - DONE, /* finished check, done -- remain here until reset */ - BAD, /* got a data error -- remain here until reset */ - MEM, /* got an inflate() memory error -- remain here until reset */ - SYNC /* looking for synchronization bytes to restart inflate() */ -} inflate_mode; - -/* - State transitions between above modes - - - (most modes can go to BAD or MEM on error -- not shown for clarity) - - Process header: - HEAD -> (gzip) or (zlib) or (raw) - (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT -> - HCRC -> TYPE - (zlib) -> DICTID or TYPE - DICTID -> DICT -> TYPE - (raw) -> TYPEDO - Read deflate blocks: - TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK - STORED -> COPY_ -> COPY -> TYPE - TABLE -> LENLENS -> CODELENS -> LEN_ - LEN_ -> LEN - Read deflate codes in fixed or dynamic block: - LEN -> LENEXT or LIT or TYPE - LENEXT -> DIST -> DISTEXT -> MATCH -> LEN - LIT -> LEN - Process trailer: - CHECK -> LENGTH -> DONE - */ - -/* state maintained between inflate() calls. Approximately 10K bytes. */ -struct inflate_state { - inflate_mode mode; /* current inflate mode */ - int last; /* true if processing last block */ - int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ - int havedict; /* true if dictionary provided */ - int flags; /* gzip header method and flags (0 if zlib) */ - unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ - unsigned long check; /* protected copy of check value */ - unsigned long total; /* protected copy of output count */ - gz_headerp head; /* where to save gzip header information */ - /* sliding window */ - unsigned wbits; /* log base 2 of requested window size */ - unsigned wsize; /* window size or zero if not using window */ - unsigned whave; /* valid bytes in the window */ - unsigned wnext; /* window write index */ - unsigned char FAR *window; /* allocated sliding window, if needed */ - /* bit accumulator */ - unsigned long hold; /* input bit accumulator */ - unsigned bits; /* number of bits in "in" */ - /* for string and stored block copying */ - unsigned length; /* literal or length of data to copy */ - unsigned offset; /* distance back to copy string from */ - /* for table and code decoding */ - unsigned extra; /* extra bits needed */ - /* fixed and dynamic code tables */ - code const FAR *lencode; /* starting table for length/literal codes */ - code const FAR *distcode; /* starting table for distance codes */ - unsigned lenbits; /* index bits for lencode */ - unsigned distbits; /* index bits for distcode */ - /* dynamic table building */ - unsigned ncode; /* number of code length code lengths */ - unsigned nlen; /* number of length code lengths */ - unsigned ndist; /* number of distance code lengths */ - unsigned have; /* number of code lengths in lens[] */ - code FAR *next; /* next available space in codes[] */ - unsigned short lens[320]; /* temporary storage for code lengths */ - unsigned short work[288]; /* work area for code table building */ - code codes[ENOUGH]; /* space for code tables */ - int sane; /* if false, allow invalid distance too far */ - int back; /* bits back of last unprocessed length/lit */ - unsigned was; /* initial length of match */ -}; diff --git a/libs/zlib/src/inftrees.c b/libs/zlib/src/inftrees.c deleted file mode 100644 index 44d89cf2..00000000 --- a/libs/zlib/src/inftrees.c +++ /dev/null @@ -1,306 +0,0 @@ -/* inftrees.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-2013 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "inftrees.h" - -#define MAXBITS 15 - -const char inflate_copyright[] = - " inflate 1.2.8 Copyright 1995-2013 Mark Adler "; -/* - If you use the zlib library in a product, an acknowledgment is welcome - in the documentation of your product. If for some reason you cannot - include such an acknowledgment, I would appreciate that you keep this - copyright string in the executable of your product. - */ - -/* - Build a set of tables to decode the provided canonical Huffman code. - The code lengths are lens[0..codes-1]. The result starts at *table, - whose indices are 0..2^bits-1. work is a writable array of at least - lens shorts, which is used as a work area. type is the type of code - to be generated, CODES, LENS, or DISTS. On return, zero is success, - -1 is an invalid code, and +1 means that ENOUGH isn't enough. table - on return points to the next available entry's address. bits is the - requested root table index bits, and on return it is the actual root - table index bits. It will differ if the request is greater than the - longest code or if it is less than the shortest code. - */ -int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work) -codetype type; -unsigned short FAR *lens; -unsigned codes; -code FAR * FAR *table; -unsigned FAR *bits; -unsigned short FAR *work; -{ - unsigned len; /* a code's length in bits */ - unsigned sym; /* index of code symbols */ - unsigned min, max; /* minimum and maximum code lengths */ - unsigned root; /* number of index bits for root table */ - unsigned curr; /* number of index bits for current table */ - unsigned drop; /* code bits to drop for sub-table */ - int left; /* number of prefix codes available */ - unsigned used; /* code entries in table used */ - unsigned huff; /* Huffman code */ - unsigned incr; /* for incrementing code, index */ - unsigned fill; /* index for replicating entries */ - unsigned low; /* low bits for current root entry */ - unsigned mask; /* mask for low root bits */ - code here; /* table entry for duplication */ - code FAR *next; /* next available space in table */ - const unsigned short FAR *base; /* base value table to use */ - const unsigned short FAR *extra; /* extra bits table to use */ - int end; /* use base and extra for symbol > end */ - unsigned short count[MAXBITS+1]; /* number of codes of each length */ - unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ - static const unsigned short lbase[31] = { /* Length codes 257..285 base */ - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, - 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; - static const unsigned short lext[31] = { /* Length codes 257..285 extra */ - 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78}; - static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, - 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, - 8193, 12289, 16385, 24577, 0, 0}; - static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ - 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, - 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, - 28, 28, 29, 29, 64, 64}; - - /* - Process a set of code lengths to create a canonical Huffman code. The - code lengths are lens[0..codes-1]. Each length corresponds to the - symbols 0..codes-1. The Huffman code is generated by first sorting the - symbols by length from short to long, and retaining the symbol order - for codes with equal lengths. Then the code starts with all zero bits - for the first code of the shortest length, and the codes are integer - increments for the same length, and zeros are appended as the length - increases. For the deflate format, these bits are stored backwards - from their more natural integer increment ordering, and so when the - decoding tables are built in the large loop below, the integer codes - are incremented backwards. - - This routine assumes, but does not check, that all of the entries in - lens[] are in the range 0..MAXBITS. The caller must assure this. - 1..MAXBITS is interpreted as that code length. zero means that that - symbol does not occur in this code. - - The codes are sorted by computing a count of codes for each length, - creating from that a table of starting indices for each length in the - sorted table, and then entering the symbols in order in the sorted - table. The sorted table is work[], with that space being provided by - the caller. - - The length counts are used for other purposes as well, i.e. finding - the minimum and maximum length codes, determining if there are any - codes at all, checking for a valid set of lengths, and looking ahead - at length counts to determine sub-table sizes when building the - decoding tables. - */ - - /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ - for (len = 0; len <= MAXBITS; len++) - count[len] = 0; - for (sym = 0; sym < codes; sym++) - count[lens[sym]]++; - - /* bound code lengths, force root to be within code lengths */ - root = *bits; - for (max = MAXBITS; max >= 1; max--) - if (count[max] != 0) break; - if (root > max) root = max; - if (max == 0) { /* no symbols to code at all */ - here.op = (unsigned char)64; /* invalid code marker */ - here.bits = (unsigned char)1; - here.val = (unsigned short)0; - *(*table)++ = here; /* make a table to force an error */ - *(*table)++ = here; - *bits = 1; - return 0; /* no symbols, but wait for decoding to report error */ - } - for (min = 1; min < max; min++) - if (count[min] != 0) break; - if (root < min) root = min; - - /* check for an over-subscribed or incomplete set of lengths */ - left = 1; - for (len = 1; len <= MAXBITS; len++) { - left <<= 1; - left -= count[len]; - if (left < 0) return -1; /* over-subscribed */ - } - if (left > 0 && (type == CODES || max != 1)) - return -1; /* incomplete set */ - - /* generate offsets into symbol table for each length for sorting */ - offs[1] = 0; - for (len = 1; len < MAXBITS; len++) - offs[len + 1] = offs[len] + count[len]; - - /* sort symbols by length, by symbol order within each length */ - for (sym = 0; sym < codes; sym++) - if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym; - - /* - Create and fill in decoding tables. In this loop, the table being - filled is at next and has curr index bits. The code being used is huff - with length len. That code is converted to an index by dropping drop - bits off of the bottom. For codes where len is less than drop + curr, - those top drop + curr - len bits are incremented through all values to - fill the table with replicated entries. - - root is the number of index bits for the root table. When len exceeds - root, sub-tables are created pointed to by the root entry with an index - of the low root bits of huff. This is saved in low to check for when a - new sub-table should be started. drop is zero when the root table is - being filled, and drop is root when sub-tables are being filled. - - When a new sub-table is needed, it is necessary to look ahead in the - code lengths to determine what size sub-table is needed. The length - counts are used for this, and so count[] is decremented as codes are - entered in the tables. - - used keeps track of how many table entries have been allocated from the - provided *table space. It is checked for LENS and DIST tables against - the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in - the initial root table size constants. See the comments in inftrees.h - for more information. - - sym increments through all symbols, and the loop terminates when - all codes of length max, i.e. all codes, have been processed. This - routine permits incomplete codes, so another loop after this one fills - in the rest of the decoding tables with invalid code markers. - */ - - /* set up for code type */ - switch (type) { - case CODES: - base = extra = work; /* dummy value--not used */ - end = 19; - break; - case LENS: - base = lbase; - base -= 257; - extra = lext; - extra -= 257; - end = 256; - break; - default: /* DISTS */ - base = dbase; - extra = dext; - end = -1; - } - - /* initialize state for loop */ - huff = 0; /* starting code */ - sym = 0; /* starting code symbol */ - len = min; /* starting code length */ - next = *table; /* current table to fill in */ - curr = root; /* current table index bits */ - drop = 0; /* current bits to drop from code for index */ - low = (unsigned)(-1); /* trigger new sub-table when len > root */ - used = 1U << root; /* use root table entries */ - mask = used - 1; /* mask for comparing low */ - - /* check available table space */ - if ((type == LENS && used > ENOUGH_LENS) || - (type == DISTS && used > ENOUGH_DISTS)) - return 1; - - /* process all codes and make table entries */ - for (;;) { - /* create table entry */ - here.bits = (unsigned char)(len - drop); - if ((int)(work[sym]) < end) { - here.op = (unsigned char)0; - here.val = work[sym]; - } - else if ((int)(work[sym]) > end) { - here.op = (unsigned char)(extra[work[sym]]); - here.val = base[work[sym]]; - } - else { - here.op = (unsigned char)(32 + 64); /* end of block */ - here.val = 0; - } - - /* replicate for those indices with low len bits equal to huff */ - incr = 1U << (len - drop); - fill = 1U << curr; - min = fill; /* save offset to next table */ - do { - fill -= incr; - next[(huff >> drop) + fill] = here; - } while (fill != 0); - - /* backwards increment the len-bit code huff */ - incr = 1U << (len - 1); - while (huff & incr) - incr >>= 1; - if (incr != 0) { - huff &= incr - 1; - huff += incr; - } - else - huff = 0; - - /* go to next symbol, update count, len */ - sym++; - if (--(count[len]) == 0) { - if (len == max) break; - len = lens[work[sym]]; - } - - /* create new sub-table if needed */ - if (len > root && (huff & mask) != low) { - /* if first time, transition to sub-tables */ - if (drop == 0) - drop = root; - - /* increment past last table */ - next += min; /* here min is 1 << curr */ - - /* determine length of next table */ - curr = len - drop; - left = (int)(1 << curr); - while (curr + drop < max) { - left -= count[curr + drop]; - if (left <= 0) break; - curr++; - left <<= 1; - } - - /* check for enough space */ - used += 1U << curr; - if ((type == LENS && used > ENOUGH_LENS) || - (type == DISTS && used > ENOUGH_DISTS)) - return 1; - - /* point entry in root table to sub-table */ - low = huff & mask; - (*table)[low].op = (unsigned char)curr; - (*table)[low].bits = (unsigned char)root; - (*table)[low].val = (unsigned short)(next - *table); - } - } - - /* fill in remaining table entry if code is incomplete (guaranteed to have - at most one remaining entry, since if the code is incomplete, the - maximum code length that was allowed to get this far is one bit) */ - if (huff != 0) { - here.op = (unsigned char)64; /* invalid code marker */ - here.bits = (unsigned char)(len - drop); - here.val = (unsigned short)0; - next[huff] = here; - } - - /* set return parameters */ - *table += used; - *bits = root; - return 0; -} diff --git a/libs/zlib/src/inftrees.h b/libs/zlib/src/inftrees.h deleted file mode 100644 index baa53a0b..00000000 --- a/libs/zlib/src/inftrees.h +++ /dev/null @@ -1,62 +0,0 @@ -/* inftrees.h -- header to use inftrees.c - * Copyright (C) 1995-2005, 2010 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* Structure for decoding tables. Each entry provides either the - information needed to do the operation requested by the code that - indexed that table entry, or it provides a pointer to another - table that indexes more bits of the code. op indicates whether - the entry is a pointer to another table, a literal, a length or - distance, an end-of-block, or an invalid code. For a table - pointer, the low four bits of op is the number of index bits of - that table. For a length or distance, the low four bits of op - is the number of extra bits to get after the code. bits is - the number of bits in this code or part of the code to drop off - of the bit buffer. val is the actual byte to output in the case - of a literal, the base length or distance, or the offset from - the current table to the next table. Each entry is four bytes. */ -typedef struct { - unsigned char op; /* operation, extra bits, table bits */ - unsigned char bits; /* bits in this part of the code */ - unsigned short val; /* offset in table or code value */ -} code; - -/* op values as set by inflate_table(): - 00000000 - literal - 0000tttt - table link, tttt != 0 is the number of table index bits - 0001eeee - length or distance, eeee is the number of extra bits - 01100000 - end of block - 01000000 - invalid code - */ - -/* Maximum size of the dynamic table. The maximum number of code structures is - 1444, which is the sum of 852 for literal/length codes and 592 for distance - codes. These values were found by exhaustive searches using the program - examples/enough.c found in the zlib distribtution. The arguments to that - program are the number of symbols, the initial root table size, and the - maximum bit length of a code. "enough 286 9 15" for literal/length codes - returns returns 852, and "enough 30 6 15" for distance codes returns 592. - The initial root table size (9 or 6) is found in the fifth argument of the - inflate_table() calls in inflate.c and infback.c. If the root table size is - changed, then these maximum sizes would be need to be recalculated and - updated. */ -#define ENOUGH_LENS 852 -#define ENOUGH_DISTS 592 -#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) - -/* Type of code to build for inflate_table() */ -typedef enum { - CODES, - LENS, - DISTS -} codetype; - -int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, - unsigned codes, code FAR * FAR *table, - unsigned FAR *bits, unsigned short FAR *work)); diff --git a/libs/zlib/src/trees.c b/libs/zlib/src/trees.c deleted file mode 100644 index 4805e34a..00000000 --- a/libs/zlib/src/trees.c +++ /dev/null @@ -1,1226 +0,0 @@ -/* trees.c -- output deflated data using Huffman coding - * Copyright (C) 1995-2012 Jean-loup Gailly - * detect_data_type() function provided freely by Cosmin Truta, 2006 - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * ALGORITHM - * - * The "deflation" process uses several Huffman trees. The more - * common source values are represented by shorter bit sequences. - * - * Each code tree is stored in a compressed form which is itself - * a Huffman encoding of the lengths of all the code strings (in - * ascending order by source values). The actual code strings are - * reconstructed from the lengths in the inflate process, as described - * in the deflate specification. - * - * REFERENCES - * - * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification". - * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc - * - * Storer, James A. - * Data Compression: Methods and Theory, pp. 49-50. - * Computer Science Press, 1988. ISBN 0-7167-8156-5. - * - * Sedgewick, R. - * Algorithms, p290. - * Addison-Wesley, 1983. ISBN 0-201-06672-6. - */ - -/* @(#) $Id: trees.c,v 1.2 2013/08/12 09:54:03 martinprikryl Exp $ */ - -/* #define GEN_TREES_H */ - -#include "deflate.h" - -#ifdef DEBUG -# include -#endif - -/* =========================================================================== - * Constants - */ - -#define MAX_BL_BITS 7 -/* Bit length codes must not exceed MAX_BL_BITS bits */ - -#define END_BLOCK 256 -/* end of block literal code */ - -#define REP_3_6 16 -/* repeat previous bit length 3-6 times (2 bits of repeat count) */ - -#define REPZ_3_10 17 -/* repeat a zero length 3-10 times (3 bits of repeat count) */ - -#define REPZ_11_138 18 -/* repeat a zero length 11-138 times (7 bits of repeat count) */ - -local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */ - = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; - -local const int extra_dbits[D_CODES] /* extra bits for each distance code */ - = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; - -local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */ - = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; - -local const uch bl_order[BL_CODES] - = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; -/* The lengths of the bit length codes are sent in order of decreasing - * probability, to avoid transmitting the lengths for unused bit length codes. - */ - -/* =========================================================================== - * Local data. These are initialized only once. - */ - -#define DIST_CODE_LEN 512 /* see definition of array dist_code below */ - -#if defined(GEN_TREES_H) || !defined(STDC) -/* non ANSI compilers may not accept trees.h */ - -local ct_data static_ltree[L_CODES+2]; -/* The static literal tree. Since the bit lengths are imposed, there is no - * need for the L_CODES extra codes used during heap construction. However - * The codes 286 and 287 are needed to build a canonical tree (see _tr_init - * below). - */ - -local ct_data static_dtree[D_CODES]; -/* The static distance tree. (Actually a trivial tree since all codes use - * 5 bits.) - */ - -uch _dist_code[DIST_CODE_LEN]; -/* Distance codes. The first 256 values correspond to the distances - * 3 .. 258, the last 256 values correspond to the top 8 bits of - * the 15 bit distances. - */ - -uch _length_code[MAX_MATCH-MIN_MATCH+1]; -/* length code for each normalized match length (0 == MIN_MATCH) */ - -local int base_length[LENGTH_CODES]; -/* First normalized length for each code (0 = MIN_MATCH) */ - -local int base_dist[D_CODES]; -/* First normalized distance for each code (0 = distance of 1) */ - -#else -# include "trees.h" -#endif /* GEN_TREES_H */ - -struct static_tree_desc_s { - const ct_data *static_tree; /* static tree or NULL */ - const intf *extra_bits; /* extra bits for each code or NULL */ - int extra_base; /* base index for extra_bits */ - int elems; /* max number of elements in the tree */ - int max_length; /* max bit length for the codes */ -}; - -local static_tree_desc static_l_desc = -{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; - -local static_tree_desc static_d_desc = -{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; - -local static_tree_desc static_bl_desc = -{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; - -/* =========================================================================== - * Local (static) routines in this file. - */ - -local void tr_static_init OF((void)); -local void init_block OF((deflate_state *s)); -local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); -local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); -local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); -local void build_tree OF((deflate_state *s, tree_desc *desc)); -local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local int build_bl_tree OF((deflate_state *s)); -local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, - int blcodes)); -local void compress_block OF((deflate_state *s, const ct_data *ltree, - const ct_data *dtree)); -local int detect_data_type OF((deflate_state *s)); -local unsigned bi_reverse OF((unsigned value, int length)); -local void bi_windup OF((deflate_state *s)); -local void bi_flush OF((deflate_state *s)); -local void copy_block OF((deflate_state *s, charf *buf, unsigned len, - int header)); - -#ifdef GEN_TREES_H -local void gen_trees_header OF((void)); -#endif - -#ifndef DEBUG -# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) - /* Send a code of the given tree. c and tree must not have side effects */ - -#else /* DEBUG */ -# define send_code(s, c, tree) \ - { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ - send_bits(s, tree[c].Code, tree[c].Len); } -#endif - -/* =========================================================================== - * Output a short LSB first on the stream. - * IN assertion: there is enough room in pendingBuf. - */ -#define put_short(s, w) { \ - put_byte(s, (uch)((w) & 0xff)); \ - put_byte(s, (uch)((ush)(w) >> 8)); \ -} - -/* =========================================================================== - * Send a value on a given number of bits. - * IN assertion: length <= 16 and value fits in length bits. - */ -#ifdef DEBUG -local void send_bits OF((deflate_state *s, int value, int length)); - -local void send_bits(s, value, length) - deflate_state *s; - int value; /* value to send */ - int length; /* number of bits */ -{ - Tracevv((stderr," l %2d v %4x ", length, value)); - Assert(length > 0 && length <= 15, "invalid length"); - s->bits_sent += (ulg)length; - - /* If not enough room in bi_buf, use (valid) bits from bi_buf and - * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) - * unused bits in value. - */ - if (s->bi_valid > (int)Buf_size - length) { - s->bi_buf |= (ush)value << s->bi_valid; - put_short(s, s->bi_buf); - s->bi_buf = (ush)value >> (Buf_size - s->bi_valid); - s->bi_valid += length - Buf_size; - } else { - s->bi_buf |= (ush)value << s->bi_valid; - s->bi_valid += length; - } -} -#else /* !DEBUG */ - -#define send_bits(s, value, length) \ -{ int len = length;\ - if (s->bi_valid > (int)Buf_size - len) {\ - int val = value;\ - s->bi_buf |= (ush)val << s->bi_valid;\ - put_short(s, s->bi_buf);\ - s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\ - s->bi_valid += len - Buf_size;\ - } else {\ - s->bi_buf |= (ush)(value) << s->bi_valid;\ - s->bi_valid += len;\ - }\ -} -#endif /* DEBUG */ - - -/* the arguments must not have side effects */ - -/* =========================================================================== - * Initialize the various 'constant' tables. - */ -local void tr_static_init() -{ -#if defined(GEN_TREES_H) || !defined(STDC) - static int static_init_done = 0; - int n; /* iterates over tree elements */ - int bits; /* bit counter */ - int length; /* length value */ - int code; /* code value */ - int dist; /* distance index */ - ush bl_count[MAX_BITS+1]; - /* number of codes at each bit length for an optimal tree */ - - if (static_init_done) return; - - /* For some embedded targets, global variables are not initialized: */ -#ifdef NO_INIT_GLOBAL_POINTERS - static_l_desc.static_tree = static_ltree; - static_l_desc.extra_bits = extra_lbits; - static_d_desc.static_tree = static_dtree; - static_d_desc.extra_bits = extra_dbits; - static_bl_desc.extra_bits = extra_blbits; -#endif - - /* Initialize the mapping length (0..255) -> length code (0..28) */ - length = 0; - for (code = 0; code < LENGTH_CODES-1; code++) { - base_length[code] = length; - for (n = 0; n < (1< dist code (0..29) */ - dist = 0; - for (code = 0 ; code < 16; code++) { - base_dist[code] = dist; - for (n = 0; n < (1<>= 7; /* from now on, all distances are divided by 128 */ - for ( ; code < D_CODES; code++) { - base_dist[code] = dist << 7; - for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { - _dist_code[256 + dist++] = (uch)code; - } - } - Assert (dist == 256, "tr_static_init: 256+dist != 512"); - - /* Construct the codes of the static literal tree */ - for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; - n = 0; - while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++; - while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++; - while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++; - while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++; - /* Codes 286 and 287 do not exist, but we must include them in the - * tree construction to get a canonical Huffman tree (longest code - * all ones) - */ - gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count); - - /* The static distance tree is trivial: */ - for (n = 0; n < D_CODES; n++) { - static_dtree[n].Len = 5; - static_dtree[n].Code = bi_reverse((unsigned)n, 5); - } - static_init_done = 1; - -# ifdef GEN_TREES_H - gen_trees_header(); -# endif -#endif /* defined(GEN_TREES_H) || !defined(STDC) */ -} - -/* =========================================================================== - * Genererate the file trees.h describing the static trees. - */ -#ifdef GEN_TREES_H -# ifndef DEBUG -# include -# endif - -# define SEPARATOR(i, last, width) \ - ((i) == (last)? "\n};\n\n" : \ - ((i) % (width) == (width)-1 ? ",\n" : ", ")) - -void gen_trees_header() -{ - FILE *header = fopen("trees.h", "w"); - int i; - - Assert (header != NULL, "Can't open trees.h"); - fprintf(header, - "/* header created automatically with -DGEN_TREES_H */\n\n"); - - fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n"); - for (i = 0; i < L_CODES+2; i++) { - fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, - static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); - } - - fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n"); - for (i = 0; i < D_CODES; i++) { - fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, - static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); - } - - fprintf(header, "const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {\n"); - for (i = 0; i < DIST_CODE_LEN; i++) { - fprintf(header, "%2u%s", _dist_code[i], - SEPARATOR(i, DIST_CODE_LEN-1, 20)); - } - - fprintf(header, - "const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {\n"); - for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) { - fprintf(header, "%2u%s", _length_code[i], - SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); - } - - fprintf(header, "local const int base_length[LENGTH_CODES] = {\n"); - for (i = 0; i < LENGTH_CODES; i++) { - fprintf(header, "%1u%s", base_length[i], - SEPARATOR(i, LENGTH_CODES-1, 20)); - } - - fprintf(header, "local const int base_dist[D_CODES] = {\n"); - for (i = 0; i < D_CODES; i++) { - fprintf(header, "%5u%s", base_dist[i], - SEPARATOR(i, D_CODES-1, 10)); - } - - fclose(header); -} -#endif /* GEN_TREES_H */ - -/* =========================================================================== - * Initialize the tree data structures for a new zlib stream. - */ -void ZLIB_INTERNAL _tr_init(s) - deflate_state *s; -{ - tr_static_init(); - - s->l_desc.dyn_tree = s->dyn_ltree; - s->l_desc.stat_desc = &static_l_desc; - - s->d_desc.dyn_tree = s->dyn_dtree; - s->d_desc.stat_desc = &static_d_desc; - - s->bl_desc.dyn_tree = s->bl_tree; - s->bl_desc.stat_desc = &static_bl_desc; - - s->bi_buf = 0; - s->bi_valid = 0; -#ifdef DEBUG - s->compressed_len = 0L; - s->bits_sent = 0L; -#endif - - /* Initialize the first block of the first file: */ - init_block(s); -} - -/* =========================================================================== - * Initialize a new block. - */ -local void init_block(s) - deflate_state *s; -{ - int n; /* iterates over tree elements */ - - /* Initialize the trees. */ - for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; - for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; - for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; - - s->dyn_ltree[END_BLOCK].Freq = 1; - s->opt_len = s->static_len = 0L; - s->last_lit = s->matches = 0; -} - -#define SMALLEST 1 -/* Index within the heap array of least frequent node in the Huffman tree */ - - -/* =========================================================================== - * Remove the smallest element from the heap and recreate the heap with - * one less element. Updates heap and heap_len. - */ -#define pqremove(s, tree, top) \ -{\ - top = s->heap[SMALLEST]; \ - s->heap[SMALLEST] = s->heap[s->heap_len--]; \ - pqdownheap(s, tree, SMALLEST); \ -} - -/* =========================================================================== - * Compares to subtrees, using the tree depth as tie breaker when - * the subtrees have equal frequency. This minimizes the worst case length. - */ -#define smaller(tree, n, m, depth) \ - (tree[n].Freq < tree[m].Freq || \ - (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m])) - -/* =========================================================================== - * Restore the heap property by moving down the tree starting at node k, - * exchanging a node with the smallest of its two sons if necessary, stopping - * when the heap property is re-established (each father smaller than its - * two sons). - */ -local void pqdownheap(s, tree, k) - deflate_state *s; - ct_data *tree; /* the tree to restore */ - int k; /* node to move down */ -{ - int v = s->heap[k]; - int j = k << 1; /* left son of k */ - while (j <= s->heap_len) { - /* Set j to the smallest of the two sons: */ - if (j < s->heap_len && - smaller(tree, s->heap[j+1], s->heap[j], s->depth)) { - j++; - } - /* Exit if v is smaller than both sons */ - if (smaller(tree, v, s->heap[j], s->depth)) break; - - /* Exchange v with the smallest son */ - s->heap[k] = s->heap[j]; k = j; - - /* And continue down the tree, setting j to the left son of k */ - j <<= 1; - } - s->heap[k] = v; -} - -/* =========================================================================== - * Compute the optimal bit lengths for a tree and update the total bit length - * for the current block. - * IN assertion: the fields freq and dad are set, heap[heap_max] and - * above are the tree nodes sorted by increasing frequency. - * OUT assertions: the field len is set to the optimal bit length, the - * array bl_count contains the frequencies for each bit length. - * The length opt_len is updated; static_len is also updated if stree is - * not null. - */ -local void gen_bitlen(s, desc) - deflate_state *s; - tree_desc *desc; /* the tree descriptor */ -{ - ct_data *tree = desc->dyn_tree; - int max_code = desc->max_code; - const ct_data *stree = desc->stat_desc->static_tree; - const intf *extra = desc->stat_desc->extra_bits; - int base = desc->stat_desc->extra_base; - int max_length = desc->stat_desc->max_length; - int h; /* heap index */ - int n, m; /* iterate over the tree elements */ - int bits; /* bit length */ - int xbits; /* extra bits */ - ush f; /* frequency */ - int overflow = 0; /* number of elements with bit length too large */ - - for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0; - - /* In a first pass, compute the optimal bit lengths (which may - * overflow in the case of the bit length tree). - */ - tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */ - - for (h = s->heap_max+1; h < HEAP_SIZE; h++) { - n = s->heap[h]; - bits = tree[tree[n].Dad].Len + 1; - if (bits > max_length) bits = max_length, overflow++; - tree[n].Len = (ush)bits; - /* We overwrite tree[n].Dad which is no longer needed */ - - if (n > max_code) continue; /* not a leaf node */ - - s->bl_count[bits]++; - xbits = 0; - if (n >= base) xbits = extra[n-base]; - f = tree[n].Freq; - s->opt_len += (ulg)f * (bits + xbits); - if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits); - } - if (overflow == 0) return; - - Trace((stderr,"\nbit length overflow\n")); - /* This happens for example on obj2 and pic of the Calgary corpus */ - - /* Find the first bit length which could increase: */ - do { - bits = max_length-1; - while (s->bl_count[bits] == 0) bits--; - s->bl_count[bits]--; /* move one leaf down the tree */ - s->bl_count[bits+1] += 2; /* move one overflow item as its brother */ - s->bl_count[max_length]--; - /* The brother of the overflow item also moves one step up, - * but this does not affect bl_count[max_length] - */ - overflow -= 2; - } while (overflow > 0); - - /* Now recompute all bit lengths, scanning in increasing frequency. - * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all - * lengths instead of fixing only the wrong ones. This idea is taken - * from 'ar' written by Haruhiko Okumura.) - */ - for (bits = max_length; bits != 0; bits--) { - n = s->bl_count[bits]; - while (n != 0) { - m = s->heap[--h]; - if (m > max_code) continue; - if ((unsigned) tree[m].Len != (unsigned) bits) { - Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); - s->opt_len += ((long)bits - (long)tree[m].Len) - *(long)tree[m].Freq; - tree[m].Len = (ush)bits; - } - n--; - } - } -} - -/* =========================================================================== - * Generate the codes for a given tree and bit counts (which need not be - * optimal). - * IN assertion: the array bl_count contains the bit length statistics for - * the given tree and the field len is set for all tree elements. - * OUT assertion: the field code is set for all tree elements of non - * zero code length. - */ -local void gen_codes (tree, max_code, bl_count) - ct_data *tree; /* the tree to decorate */ - int max_code; /* largest code with non zero frequency */ - ushf *bl_count; /* number of codes at each bit length */ -{ - ush next_code[MAX_BITS+1]; /* next code value for each bit length */ - ush code = 0; /* running code value */ - int bits; /* bit index */ - int n; /* code index */ - - /* The distribution counts are first used to generate the code values - * without bit reversal. - */ - for (bits = 1; bits <= MAX_BITS; bits++) { - next_code[bits] = code = (code + bl_count[bits-1]) << 1; - } - /* Check that the bit counts in bl_count are consistent. The last code - * must be all ones. - */ - Assert (code + bl_count[MAX_BITS]-1 == (1<dyn_tree; - const ct_data *stree = desc->stat_desc->static_tree; - int elems = desc->stat_desc->elems; - int n, m; /* iterate over heap elements */ - int max_code = -1; /* largest code with non zero frequency */ - int node; /* new node being created */ - - /* Construct the initial heap, with least frequent element in - * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. - * heap[0] is not used. - */ - s->heap_len = 0, s->heap_max = HEAP_SIZE; - - for (n = 0; n < elems; n++) { - if (tree[n].Freq != 0) { - s->heap[++(s->heap_len)] = max_code = n; - s->depth[n] = 0; - } else { - tree[n].Len = 0; - } - } - - /* The pkzip format requires that at least one distance code exists, - * and that at least one bit should be sent even if there is only one - * possible code. So to avoid special checks later on we force at least - * two codes of non zero frequency. - */ - while (s->heap_len < 2) { - node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0); - tree[node].Freq = 1; - s->depth[node] = 0; - s->opt_len--; if (stree) s->static_len -= stree[node].Len; - /* node is 0 or 1 so it does not have extra bits */ - } - desc->max_code = max_code; - - /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, - * establish sub-heaps of increasing lengths: - */ - for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n); - - /* Construct the Huffman tree by repeatedly combining the least two - * frequent nodes. - */ - node = elems; /* next internal node of the tree */ - do { - pqremove(s, tree, n); /* n = node of least frequency */ - m = s->heap[SMALLEST]; /* m = node of next least frequency */ - - s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */ - s->heap[--(s->heap_max)] = m; - - /* Create a new node father of n and m */ - tree[node].Freq = tree[n].Freq + tree[m].Freq; - s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ? - s->depth[n] : s->depth[m]) + 1); - tree[n].Dad = tree[m].Dad = (ush)node; -#ifdef DUMP_BL_TREE - if (tree == s->bl_tree) { - fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)", - node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); - } -#endif - /* and insert the new node in the heap */ - s->heap[SMALLEST] = node++; - pqdownheap(s, tree, SMALLEST); - - } while (s->heap_len >= 2); - - s->heap[--(s->heap_max)] = s->heap[SMALLEST]; - - /* At this point, the fields freq and dad are set. We can now - * generate the bit lengths. - */ - gen_bitlen(s, (tree_desc *)desc); - - /* The field len is now set, we can generate the bit codes */ - gen_codes ((ct_data *)tree, max_code, s->bl_count); -} - -/* =========================================================================== - * Scan a literal or distance tree to determine the frequencies of the codes - * in the bit length tree. - */ -local void scan_tree (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - int n; /* iterates over all tree elements */ - int prevlen = -1; /* last emitted length */ - int curlen; /* length of current code */ - int nextlen = tree[0].Len; /* length of next code */ - int count = 0; /* repeat count of the current code */ - int max_count = 7; /* max repeat count */ - int min_count = 4; /* min repeat count */ - - if (nextlen == 0) max_count = 138, min_count = 3; - tree[max_code+1].Len = (ush)0xffff; /* guard */ - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; - if (++count < max_count && curlen == nextlen) { - continue; - } else if (count < min_count) { - s->bl_tree[curlen].Freq += count; - } else if (curlen != 0) { - if (curlen != prevlen) s->bl_tree[curlen].Freq++; - s->bl_tree[REP_3_6].Freq++; - } else if (count <= 10) { - s->bl_tree[REPZ_3_10].Freq++; - } else { - s->bl_tree[REPZ_11_138].Freq++; - } - count = 0; prevlen = curlen; - if (nextlen == 0) { - max_count = 138, min_count = 3; - } else if (curlen == nextlen) { - max_count = 6, min_count = 3; - } else { - max_count = 7, min_count = 4; - } - } -} - -/* =========================================================================== - * Send a literal or distance tree in compressed form, using the codes in - * bl_tree. - */ -local void send_tree (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - int n; /* iterates over all tree elements */ - int prevlen = -1; /* last emitted length */ - int curlen; /* length of current code */ - int nextlen = tree[0].Len; /* length of next code */ - int count = 0; /* repeat count of the current code */ - int max_count = 7; /* max repeat count */ - int min_count = 4; /* min repeat count */ - - /* tree[max_code+1].Len = -1; */ /* guard already set */ - if (nextlen == 0) max_count = 138, min_count = 3; - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; - if (++count < max_count && curlen == nextlen) { - continue; - } else if (count < min_count) { - do { send_code(s, curlen, s->bl_tree); } while (--count != 0); - - } else if (curlen != 0) { - if (curlen != prevlen) { - send_code(s, curlen, s->bl_tree); count--; - } - Assert(count >= 3 && count <= 6, " 3_6?"); - send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2); - - } else if (count <= 10) { - send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3); - - } else { - send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7); - } - count = 0; prevlen = curlen; - if (nextlen == 0) { - max_count = 138, min_count = 3; - } else if (curlen == nextlen) { - max_count = 6, min_count = 3; - } else { - max_count = 7, min_count = 4; - } - } -} - -/* =========================================================================== - * Construct the Huffman tree for the bit lengths and return the index in - * bl_order of the last bit length code to send. - */ -local int build_bl_tree(s) - deflate_state *s; -{ - int max_blindex; /* index of last bit length code of non zero freq */ - - /* Determine the bit length frequencies for literal and distance trees */ - scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); - scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); - - /* Build the bit length tree: */ - build_tree(s, (tree_desc *)(&(s->bl_desc))); - /* opt_len now includes the length of the tree representations, except - * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. - */ - - /* Determine the number of bit length codes to send. The pkzip format - * requires that at least 4 bit length codes be sent. (appnote.txt says - * 3 but the actual value used is 4.) - */ - for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { - if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; - } - /* Update opt_len to include the bit length tree and counts */ - s->opt_len += 3*(max_blindex+1) + 5+5+4; - Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", - s->opt_len, s->static_len)); - - return max_blindex; -} - -/* =========================================================================== - * Send the header for a block using dynamic Huffman trees: the counts, the - * lengths of the bit length codes, the literal tree and the distance tree. - * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. - */ -local void send_all_trees(s, lcodes, dcodes, blcodes) - deflate_state *s; - int lcodes, dcodes, blcodes; /* number of codes for each tree */ -{ - int rank; /* index in bl_order */ - - Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); - Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, - "too many codes"); - Tracev((stderr, "\nbl counts: ")); - send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */ - send_bits(s, dcodes-1, 5); - send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */ - for (rank = 0; rank < blcodes; rank++) { - Tracev((stderr, "\nbl code %2d ", bl_order[rank])); - send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); - } - Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); - - send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */ - Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); - - send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */ - Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); -} - -/* =========================================================================== - * Send a stored block - */ -void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) - deflate_state *s; - charf *buf; /* input block */ - ulg stored_len; /* length of input block */ - int last; /* one if this is the last block for a file */ -{ - send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */ -#ifdef DEBUG - s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; - s->compressed_len += (stored_len + 4) << 3; -#endif - copy_block(s, buf, (unsigned)stored_len, 1); /* with header */ -} - -/* =========================================================================== - * Flush the bits in the bit buffer to pending output (leaves at most 7 bits) - */ -void ZLIB_INTERNAL _tr_flush_bits(s) - deflate_state *s; -{ - bi_flush(s); -} - -/* =========================================================================== - * Send one empty static block to give enough lookahead for inflate. - * This takes 10 bits, of which 7 may remain in the bit buffer. - */ -void ZLIB_INTERNAL _tr_align(s) - deflate_state *s; -{ - send_bits(s, STATIC_TREES<<1, 3); - send_code(s, END_BLOCK, static_ltree); -#ifdef DEBUG - s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ -#endif - bi_flush(s); -} - -/* =========================================================================== - * Determine the best encoding for the current block: dynamic trees, static - * trees or store, and output the encoded block to the zip file. - */ -void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) - deflate_state *s; - charf *buf; /* input block, or NULL if too old */ - ulg stored_len; /* length of input block */ - int last; /* one if this is the last block for a file */ -{ - ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ - int max_blindex = 0; /* index of last bit length code of non zero freq */ - - /* Build the Huffman trees unless a stored block is forced */ - if (s->level > 0) { - - /* Check if the file is binary or text */ - if (s->strm->data_type == Z_UNKNOWN) - s->strm->data_type = detect_data_type(s); - - /* Construct the literal and distance trees */ - build_tree(s, (tree_desc *)(&(s->l_desc))); - Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, - s->static_len)); - - build_tree(s, (tree_desc *)(&(s->d_desc))); - Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, - s->static_len)); - /* At this point, opt_len and static_len are the total bit lengths of - * the compressed block data, excluding the tree representations. - */ - - /* Build the bit length tree for the above two trees, and get the index - * in bl_order of the last bit length code to send. - */ - max_blindex = build_bl_tree(s); - - /* Determine the best encoding. Compute the block lengths in bytes. */ - opt_lenb = (s->opt_len+3+7)>>3; - static_lenb = (s->static_len+3+7)>>3; - - Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", - opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, - s->last_lit)); - - if (static_lenb <= opt_lenb) opt_lenb = static_lenb; - - } else { - Assert(buf != (char*)0, "lost buf"); - opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ - } - -#ifdef FORCE_STORED - if (buf != (char*)0) { /* force stored block */ -#else - if (stored_len+4 <= opt_lenb && buf != (char*)0) { - /* 4: two words for the lengths */ -#endif - /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. - * Otherwise we can't have processed more than WSIZE input bytes since - * the last block flush, because compression would have been - * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to - * transform a block into a stored block. - */ - _tr_stored_block(s, buf, stored_len, last); - -#ifdef FORCE_STATIC - } else if (static_lenb >= 0) { /* force static trees */ -#else - } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) { -#endif - send_bits(s, (STATIC_TREES<<1)+last, 3); - compress_block(s, (const ct_data *)static_ltree, - (const ct_data *)static_dtree); -#ifdef DEBUG - s->compressed_len += 3 + s->static_len; -#endif - } else { - send_bits(s, (DYN_TREES<<1)+last, 3); - send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, - max_blindex+1); - compress_block(s, (const ct_data *)s->dyn_ltree, - (const ct_data *)s->dyn_dtree); -#ifdef DEBUG - s->compressed_len += 3 + s->opt_len; -#endif - } - Assert (s->compressed_len == s->bits_sent, "bad compressed size"); - /* The above check is made mod 2^32, for files larger than 512 MB - * and uLong implemented on 32 bits. - */ - init_block(s); - - if (last) { - bi_windup(s); -#ifdef DEBUG - s->compressed_len += 7; /* align on byte boundary */ -#endif - } - Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, - s->compressed_len-7*last)); -} - -/* =========================================================================== - * Save the match info and tally the frequency counts. Return true if - * the current block must be flushed. - */ -int ZLIB_INTERNAL _tr_tally (s, dist, lc) - deflate_state *s; - unsigned dist; /* distance of matched string */ - unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ -{ - s->d_buf[s->last_lit] = (ush)dist; - s->l_buf[s->last_lit++] = (uch)lc; - if (dist == 0) { - /* lc is the unmatched char */ - s->dyn_ltree[lc].Freq++; - } else { - s->matches++; - /* Here, lc is the match length - MIN_MATCH */ - dist--; /* dist = match distance - 1 */ - Assert((ush)dist < (ush)MAX_DIST(s) && - (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && - (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); - - s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++; - s->dyn_dtree[d_code(dist)].Freq++; - } - -#ifdef TRUNCATE_BLOCK - /* Try to guess if it is profitable to stop the current block here */ - if ((s->last_lit & 0x1fff) == 0 && s->level > 2) { - /* Compute an upper bound for the compressed length */ - ulg out_length = (ulg)s->last_lit*8L; - ulg in_length = (ulg)((long)s->strstart - s->block_start); - int dcode; - for (dcode = 0; dcode < D_CODES; dcode++) { - out_length += (ulg)s->dyn_dtree[dcode].Freq * - (5L+extra_dbits[dcode]); - } - out_length >>= 3; - Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ", - s->last_lit, in_length, out_length, - 100L - out_length*100L/in_length)); - if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1; - } -#endif - return (s->last_lit == s->lit_bufsize-1); - /* We avoid equality with lit_bufsize because of wraparound at 64K - * on 16 bit machines and because stored blocks are restricted to - * 64K-1 bytes. - */ -} - -/* =========================================================================== - * Send the block data compressed using the given Huffman trees - */ -local void compress_block(s, ltree, dtree) - deflate_state *s; - const ct_data *ltree; /* literal tree */ - const ct_data *dtree; /* distance tree */ -{ - unsigned dist; /* distance of matched string */ - int lc; /* match length or unmatched char (if dist == 0) */ - unsigned lx = 0; /* running index in l_buf */ - unsigned code; /* the code to send */ - int extra; /* number of extra bits to send */ - - if (s->last_lit != 0) do { - dist = s->d_buf[lx]; - lc = s->l_buf[lx++]; - if (dist == 0) { - send_code(s, lc, ltree); /* send a literal byte */ - Tracecv(isgraph(lc), (stderr," '%c' ", lc)); - } else { - /* Here, lc is the match length - MIN_MATCH */ - code = _length_code[lc]; - send_code(s, code+LITERALS+1, ltree); /* send the length code */ - extra = extra_lbits[code]; - if (extra != 0) { - lc -= base_length[code]; - send_bits(s, lc, extra); /* send the extra length bits */ - } - dist--; /* dist is now the match distance - 1 */ - code = d_code(dist); - Assert (code < D_CODES, "bad d_code"); - - send_code(s, code, dtree); /* send the distance code */ - extra = extra_dbits[code]; - if (extra != 0) { - dist -= base_dist[code]; - send_bits(s, dist, extra); /* send the extra distance bits */ - } - } /* literal or match pair ? */ - - /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */ - Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx, - "pendingBuf overflow"); - - } while (lx < s->last_lit); - - send_code(s, END_BLOCK, ltree); -} - -/* =========================================================================== - * Check if the data type is TEXT or BINARY, using the following algorithm: - * - TEXT if the two conditions below are satisfied: - * a) There are no non-portable control characters belonging to the - * "black list" (0..6, 14..25, 28..31). - * b) There is at least one printable character belonging to the - * "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255). - * - BINARY otherwise. - * - The following partially-portable control characters form a - * "gray list" that is ignored in this detection algorithm: - * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}). - * IN assertion: the fields Freq of dyn_ltree are set. - */ -local int detect_data_type(s) - deflate_state *s; -{ - /* black_mask is the bit mask of black-listed bytes - * set bits 0..6, 14..25, and 28..31 - * 0xf3ffc07f = binary 11110011111111111100000001111111 - */ - unsigned long black_mask = 0xf3ffc07fUL; - int n; - - /* Check for non-textual ("black-listed") bytes. */ - for (n = 0; n <= 31; n++, black_mask >>= 1) - if ((black_mask & 1) && (s->dyn_ltree[n].Freq != 0)) - return Z_BINARY; - - /* Check for textual ("white-listed") bytes. */ - if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 - || s->dyn_ltree[13].Freq != 0) - return Z_TEXT; - for (n = 32; n < LITERALS; n++) - if (s->dyn_ltree[n].Freq != 0) - return Z_TEXT; - - /* There are no "black-listed" or "white-listed" bytes: - * this stream either is empty or has tolerated ("gray-listed") bytes only. - */ - return Z_BINARY; -} - -/* =========================================================================== - * Reverse the first len bits of a code, using straightforward code (a faster - * method would use a table) - * IN assertion: 1 <= len <= 15 - */ -local unsigned bi_reverse(code, len) - unsigned code; /* the value to invert */ - int len; /* its bit length */ -{ - register unsigned res = 0; - do { - res |= code & 1; - code >>= 1, res <<= 1; - } while (--len > 0); - return res >> 1; -} - -/* =========================================================================== - * Flush the bit buffer, keeping at most 7 bits in it. - */ -local void bi_flush(s) - deflate_state *s; -{ - if (s->bi_valid == 16) { - put_short(s, s->bi_buf); - s->bi_buf = 0; - s->bi_valid = 0; - } else if (s->bi_valid >= 8) { - put_byte(s, (Byte)s->bi_buf); - s->bi_buf >>= 8; - s->bi_valid -= 8; - } -} - -/* =========================================================================== - * Flush the bit buffer and align the output on a byte boundary - */ -local void bi_windup(s) - deflate_state *s; -{ - if (s->bi_valid > 8) { - put_short(s, s->bi_buf); - } else if (s->bi_valid > 0) { - put_byte(s, (Byte)s->bi_buf); - } - s->bi_buf = 0; - s->bi_valid = 0; -#ifdef DEBUG - s->bits_sent = (s->bits_sent+7) & ~7; -#endif -} - -/* =========================================================================== - * Copy a stored block, storing first the length and its - * one's complement if requested. - */ -local void copy_block(s, buf, len, header) - deflate_state *s; - charf *buf; /* the input data */ - unsigned len; /* its length */ - int header; /* true if block header must be written */ -{ - bi_windup(s); /* align on byte boundary */ - - if (header) { - put_short(s, (ush)len); - put_short(s, (ush)~len); -#ifdef DEBUG - s->bits_sent += 2*16; -#endif - } -#ifdef DEBUG - s->bits_sent += (ulg)len<<3; -#endif - while (len--) { - put_byte(s, *buf++); - } -} diff --git a/libs/zlib/src/trees.h b/libs/zlib/src/trees.h deleted file mode 100644 index d35639d8..00000000 --- a/libs/zlib/src/trees.h +++ /dev/null @@ -1,128 +0,0 @@ -/* header created automatically with -DGEN_TREES_H */ - -local const ct_data static_ltree[L_CODES+2] = { -{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, -{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, -{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, -{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, -{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, -{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, -{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, -{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, -{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, -{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, -{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, -{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, -{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, -{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, -{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, -{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, -{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, -{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, -{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, -{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, -{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, -{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, -{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, -{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, -{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, -{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, -{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, -{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, -{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, -{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, -{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, -{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, -{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, -{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, -{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, -{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, -{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, -{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, -{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, -{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, -{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, -{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, -{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, -{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, -{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, -{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, -{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, -{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, -{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, -{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, -{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, -{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, -{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, -{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, -{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, -{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, -{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, -{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} -}; - -local const ct_data static_dtree[D_CODES] = { -{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, -{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, -{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, -{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, -{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, -{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} -}; - -const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = { - 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, - 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, -10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, -11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, -12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, -13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, -13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, -18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 -}; - -const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, -13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, -17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, -19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, -21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, -22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 -}; - -local const int base_length[LENGTH_CODES] = { -0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, -64, 80, 96, 112, 128, 160, 192, 224, 0 -}; - -local const int base_dist[D_CODES] = { - 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, - 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, - 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 -}; - diff --git a/libs/zlib/src/uncompr.c b/libs/zlib/src/uncompr.c deleted file mode 100644 index cd28f67d..00000000 --- a/libs/zlib/src/uncompr.c +++ /dev/null @@ -1,59 +0,0 @@ -/* uncompr.c -- decompress a memory buffer - * Copyright (C) 1995-2003, 2010 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id: uncompr.c,v 1.2 2013/08/12 09:54:03 martinprikryl Exp $ */ - -#define ZLIB_INTERNAL -#include "zlib.h" - -/* =========================================================================== - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be large enough to hold the - entire uncompressed data. (The size of the uncompressed data must have - been saved previously by the compressor and transmitted to the decompressor - by some mechanism outside the scope of this compression library.) - Upon exit, destLen is the actual size of the compressed buffer. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted. -*/ -int ZEXPORT uncompress (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ - z_stream stream; - int err; - - stream.next_in = (z_const Bytef *)source; - stream.avail_in = (uInt)sourceLen; - /* Check for source > 64K on 16-bit machine: */ - if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; - - stream.next_out = dest; - stream.avail_out = (uInt)*destLen; - if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; - - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - - err = inflateInit(&stream); - if (err != Z_OK) return err; - - err = inflate(&stream, Z_FINISH); - if (err != Z_STREAM_END) { - inflateEnd(&stream); - if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) - return Z_DATA_ERROR; - return err; - } - *destLen = stream.total_out; - - err = inflateEnd(&stream); - return err; -} diff --git a/libs/zlib/src/zconf.h b/libs/zlib/src/zconf.h deleted file mode 100644 index e91dda01..00000000 --- a/libs/zlib/src/zconf.h +++ /dev/null @@ -1,511 +0,0 @@ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2013 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id: zconf.h,v 1.2 2013/08/12 09:54:03 martinprikryl Exp $ */ - -#ifndef ZCONF_H -#define ZCONF_H - -/* - * If you *really* need a unique prefix for all types and library functions, - * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. - * Even better than compiling with -DZ_PREFIX would be to use configure to set - * this permanently in zconf.h using "./configure --zprefix". - */ -#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ -# define Z_PREFIX_SET - -/* all linked symbols */ -# define _dist_code z__dist_code -# define _length_code z__length_code -# define _tr_align z__tr_align -# define _tr_flush_bits z__tr_flush_bits -# define _tr_flush_block z__tr_flush_block -# define _tr_init z__tr_init -# define _tr_stored_block z__tr_stored_block -# define _tr_tally z__tr_tally -# define adler32 z_adler32 -# define adler32_combine z_adler32_combine -# define adler32_combine64 z_adler32_combine64 -# ifndef Z_SOLO -# define compress z_compress -# define compress2 z_compress2 -# define compressBound z_compressBound -# endif -# define crc32 z_crc32 -# define crc32_combine z_crc32_combine -# define crc32_combine64 z_crc32_combine64 -# define deflate z_deflate -# define deflateBound z_deflateBound -# define deflateCopy z_deflateCopy -# define deflateEnd z_deflateEnd -# define deflateInit2_ z_deflateInit2_ -# define deflateInit_ z_deflateInit_ -# define deflateParams z_deflateParams -# define deflatePending z_deflatePending -# define deflatePrime z_deflatePrime -# define deflateReset z_deflateReset -# define deflateResetKeep z_deflateResetKeep -# define deflateSetDictionary z_deflateSetDictionary -# define deflateSetHeader z_deflateSetHeader -# define deflateTune z_deflateTune -# define deflate_copyright z_deflate_copyright -# define get_crc_table z_get_crc_table -# ifndef Z_SOLO -# define gz_error z_gz_error -# define gz_intmax z_gz_intmax -# define gz_strwinerror z_gz_strwinerror -# define gzbuffer z_gzbuffer -# define gzclearerr z_gzclearerr -# define gzclose z_gzclose -# define gzclose_r z_gzclose_r -# define gzclose_w z_gzclose_w -# define gzdirect z_gzdirect -# define gzdopen z_gzdopen -# define gzeof z_gzeof -# define gzerror z_gzerror -# define gzflush z_gzflush -# define gzgetc z_gzgetc -# define gzgetc_ z_gzgetc_ -# define gzgets z_gzgets -# define gzoffset z_gzoffset -# define gzoffset64 z_gzoffset64 -# define gzopen z_gzopen -# define gzopen64 z_gzopen64 -# ifdef _WIN32 -# define gzopen_w z_gzopen_w -# endif -# define gzprintf z_gzprintf -# define gzvprintf z_gzvprintf -# define gzputc z_gzputc -# define gzputs z_gzputs -# define gzread z_gzread -# define gzrewind z_gzrewind -# define gzseek z_gzseek -# define gzseek64 z_gzseek64 -# define gzsetparams z_gzsetparams -# define gztell z_gztell -# define gztell64 z_gztell64 -# define gzungetc z_gzungetc -# define gzwrite z_gzwrite -# endif -# define inflate z_inflate -# define inflateBack z_inflateBack -# define inflateBackEnd z_inflateBackEnd -# define inflateBackInit_ z_inflateBackInit_ -# define inflateCopy z_inflateCopy -# define inflateEnd z_inflateEnd -# define inflateGetHeader z_inflateGetHeader -# define inflateInit2_ z_inflateInit2_ -# define inflateInit_ z_inflateInit_ -# define inflateMark z_inflateMark -# define inflatePrime z_inflatePrime -# define inflateReset z_inflateReset -# define inflateReset2 z_inflateReset2 -# define inflateSetDictionary z_inflateSetDictionary -# define inflateGetDictionary z_inflateGetDictionary -# define inflateSync z_inflateSync -# define inflateSyncPoint z_inflateSyncPoint -# define inflateUndermine z_inflateUndermine -# define inflateResetKeep z_inflateResetKeep -# define inflate_copyright z_inflate_copyright -# define inflate_fast z_inflate_fast -# define inflate_table z_inflate_table -# ifndef Z_SOLO -# define uncompress z_uncompress -# endif -# define zError z_zError -# ifndef Z_SOLO -# define zcalloc z_zcalloc -# define zcfree z_zcfree -# endif -# define zlibCompileFlags z_zlibCompileFlags -# define zlibVersion z_zlibVersion - -/* all zlib typedefs in zlib.h and zconf.h */ -# define Byte z_Byte -# define Bytef z_Bytef -# define alloc_func z_alloc_func -# define charf z_charf -# define free_func z_free_func -# ifndef Z_SOLO -# define gzFile z_gzFile -# endif -# define gz_header z_gz_header -# define gz_headerp z_gz_headerp -# define in_func z_in_func -# define intf z_intf -# define out_func z_out_func -# define uInt z_uInt -# define uIntf z_uIntf -# define uLong z_uLong -# define uLongf z_uLongf -# define voidp z_voidp -# define voidpc z_voidpc -# define voidpf z_voidpf - -/* all zlib structs in zlib.h and zconf.h */ -# define gz_header_s z_gz_header_s -# define internal_state z_internal_state - -#endif - -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) -# define OS2 -#endif -#if defined(_WINDOWS) && !defined(WINDOWS) -# define WINDOWS -#endif -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) -# ifndef WIN32 -# define WIN32 -# endif -#endif -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) -# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) -# ifndef SYS16BIT -# define SYS16BIT -# endif -# endif -#endif - -/* - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more - * than 64k bytes at a time (needed on systems with 16-bit int). - */ -#ifdef SYS16BIT -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#ifdef __STDC_VERSION__ -# ifndef STDC -# define STDC -# endif -# if __STDC_VERSION__ >= 199901L -# ifndef STDC99 -# define STDC99 -# endif -# endif -#endif -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) -# define STDC -#endif -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) -# define STDC -#endif -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) -# define STDC -#endif -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) -# define STDC -#endif - -#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ -# define STDC -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const /* note: need a more gentle solution here */ -# endif -#endif - -#if defined(ZLIB_CONST) && !defined(z_const) -# define z_const const -#else -# define z_const -#endif - -/* Some Mac compilers merge all .h files incorrectly: */ -#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) -# define NO_DUMMY_DECL -#endif - -/* Maximum value for memLevel in deflateInit2 */ -#ifndef MAX_MEM_LEVEL -# ifdef MAXSEG_64K -# define MAX_MEM_LEVEL 8 -# else -# define MAX_MEM_LEVEL 9 -# endif -#endif - -/* Maximum value for windowBits in deflateInit2 and inflateInit2. - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files - * created by gzip. (Files created by minigzip can still be extracted by - * gzip.) - */ -#ifndef MAX_WBITS -# define MAX_WBITS 15 /* 32K LZ77 window */ -#endif - -/* The memory requirements for deflate are (in bytes): - (1 << (windowBits+2)) + (1 << (memLevel+9)) - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) - plus a few kilobytes for small objects. For example, if you want to reduce - the default memory requirements from 256K to 128K, compile with - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" - Of course this will generally degrade compression (there's no free lunch). - - The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus a few kilobytes - for small objects. -*/ - - /* Type declarations */ - -#ifndef OF /* function prototypes */ -# ifdef STDC -# define OF(args) args -# else -# define OF(args) () -# endif -#endif - -#ifndef Z_ARG /* function prototypes for stdarg */ -# if defined(STDC) || defined(Z_HAVE_STDARG_H) -# define Z_ARG(args) args -# else -# define Z_ARG(args) () -# endif -#endif - -/* The following definitions for FAR are needed only for MSDOS mixed - * model programming (small or medium model with some far allocations). - * This was tested only with MSC; for other MSDOS compilers you may have - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, - * just define FAR to be empty. - */ -#ifdef SYS16BIT -# if defined(M_I86SM) || defined(M_I86MM) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -# endif -# if (defined(__SMALL__) || defined(__MEDIUM__)) - /* Turbo C small or medium model */ -# define SMALL_MEDIUM -# ifdef __BORLANDC__ -# define FAR _far -# else -# define FAR far -# endif -# endif -#endif - -#if defined(WINDOWS) || defined(WIN32) - /* If building or using zlib as a DLL, define ZLIB_DLL. - * This is not mandatory, but it offers a little performance increase. - */ -# ifdef ZLIB_DLL -# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) -# ifdef ZLIB_INTERNAL -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -# endif -# endif /* ZLIB_DLL */ - /* If building or using zlib with the WINAPI/WINAPIV calling convention, - * define ZLIB_WINAPI. - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. - */ -# ifdef ZLIB_WINAPI -# ifdef FAR -# undef FAR -# endif -# include - /* No need for _export, use ZLIB.DEF instead. */ - /* For complete Windows compatibility, use WINAPI, not __stdcall. */ -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR CDECL -# endif -# endif -#endif - -#if defined (__BEOS__) -# ifdef ZLIB_DLL -# ifdef ZLIB_INTERNAL -# define ZEXPORT __declspec(dllexport) -# define ZEXPORTVA __declspec(dllexport) -# else -# define ZEXPORT __declspec(dllimport) -# define ZEXPORTVA __declspec(dllimport) -# endif -# endif -#endif - -#ifndef ZEXTERN -# define ZEXTERN extern -#endif -#ifndef ZEXPORT -# define ZEXPORT -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif - -#ifndef FAR -# define FAR -#endif - -#if !defined(__MACTYPES__) -typedef unsigned char Byte; /* 8 bits */ -#endif -typedef unsigned int uInt; /* 16 bits or more */ -typedef unsigned long uLong; /* 32 bits or more */ - -#ifdef SMALL_MEDIUM - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ -# define Bytef Byte FAR -#else - typedef Byte FAR Bytef; -#endif -typedef char FAR charf; -typedef int FAR intf; -typedef uInt FAR uIntf; -typedef uLong FAR uLongf; - -#ifdef STDC - typedef void const *voidpc; - typedef void FAR *voidpf; - typedef void *voidp; -#else - typedef Byte const *voidpc; - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - -#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) -# include -# if (UINT_MAX == 0xffffffffUL) -# define Z_U4 unsigned -# elif (ULONG_MAX == 0xffffffffUL) -# define Z_U4 unsigned long -# elif (USHRT_MAX == 0xffffffffUL) -# define Z_U4 unsigned short -# endif -#endif - -#ifdef Z_U4 - typedef Z_U4 z_crc_t; -#else - typedef unsigned long z_crc_t; -#endif - -#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ -# define Z_HAVE_UNISTD_H -#endif - -#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ -# define Z_HAVE_STDARG_H -#endif - -#ifdef STDC -# ifndef Z_SOLO -# include /* for off_t */ -# endif -#endif - -#if defined(STDC) || defined(Z_HAVE_STDARG_H) -# ifndef Z_SOLO -# include /* for va_list */ -# endif -#endif - -#ifdef _WIN32 -# ifndef Z_SOLO -# include /* for wchar_t */ -# endif -#endif - -/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and - * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even - * though the former does not conform to the LFS document), but considering - * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as - * equivalently requesting no 64-bit operations - */ -#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 -# undef _LARGEFILE64_SOURCE -#endif - -#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H) -# define Z_HAVE_UNISTD_H -#endif -#ifndef Z_SOLO -# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) -# include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ -# ifdef VMS -# include /* for off_t */ -# endif -# ifndef z_off_t -# define z_off_t off_t -# endif -# endif -#endif - -#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 -# define Z_LFS64 -#endif - -#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) -# define Z_LARGE64 -#endif - -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) -# define Z_WANT64 -#endif - -#if !defined(SEEK_SET) && !defined(Z_SOLO) -# define SEEK_SET 0 /* Seek from beginning of file. */ -# define SEEK_CUR 1 /* Seek from current position. */ -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ -#endif - -#ifndef z_off_t -# define z_off_t long -#endif - -#if !defined(_WIN32) && defined(Z_LARGE64) -# define z_off64_t off64_t -#else -# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) -# define z_off64_t __int64 -# else -# define z_off64_t z_off_t -# endif -#endif - -/* MVS linker does not support external names larger than 8 bytes */ -#if defined(__MVS__) - #pragma map(deflateInit_,"DEIN") - #pragma map(deflateInit2_,"DEIN2") - #pragma map(deflateEnd,"DEEND") - #pragma map(deflateBound,"DEBND") - #pragma map(inflateInit_,"ININ") - #pragma map(inflateInit2_,"ININ2") - #pragma map(inflateEnd,"INEND") - #pragma map(inflateSync,"INSY") - #pragma map(inflateSetDictionary,"INSEDI") - #pragma map(compressBound,"CMBND") - #pragma map(inflate_table,"INTABL") - #pragma map(inflate_fast,"INFA") - #pragma map(inflate_copyright,"INCOPY") -#endif - -#endif /* ZCONF_H */ diff --git a/libs/zlib/src/zlib.h b/libs/zlib/src/zlib.h deleted file mode 100644 index 3e0c7672..00000000 --- a/libs/zlib/src/zlib.h +++ /dev/null @@ -1,1768 +0,0 @@ -/* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.8, April 28th, 2013 - - Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - - - The data format used by the zlib library is described by RFCs (Request for - Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 - (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). -*/ - -#ifndef ZLIB_H -#define ZLIB_H - -#include "zconf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ZLIB_VERSION "1.2.8" -#define ZLIB_VERNUM 0x1280 -#define ZLIB_VER_MAJOR 1 -#define ZLIB_VER_MINOR 2 -#define ZLIB_VER_REVISION 8 -#define ZLIB_VER_SUBREVISION 0 - -/* - The 'zlib' compression library provides in-memory compression and - decompression functions, including integrity checks of the uncompressed data. - This version of the library supports only one compression method (deflation) - but other algorithms will be added later and will have the same stream - interface. - - Compression can be done in a single step if the buffers are large enough, - or can be done by repeated calls of the compression function. In the latter - case, the application must provide more input and/or consume the output - (providing more output space) before each call. - - The compressed data format used by default by the in-memory functions is - the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped - around a deflate stream, which is itself documented in RFC 1951. - - The library also supports reading and writing files in gzip (.gz) format - with an interface similar to that of stdio using the functions that start - with "gz". The gzip format is different from the zlib format. gzip is a - gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. - - This library can optionally read and write gzip streams in memory as well. - - The zlib format was designed to be compact and fast for use in memory - and on communications channels. The gzip format was designed for single- - file compression on file systems, has a larger header than zlib to maintain - directory information, and uses a different, slower check method than zlib. - - The library does not install any signal handler. The decoder checks - the consistency of the compressed data, so the library should never crash - even in case of corrupted input. -*/ - -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); - -struct internal_state; - -typedef struct z_stream_s { - z_const Bytef *next_in; /* next input byte */ - uInt avail_in; /* number of bytes available at next_in */ - uLong total_in; /* total number of input bytes read so far */ - - Bytef *next_out; /* next output byte should be put there */ - uInt avail_out; /* remaining free space at next_out */ - uLong total_out; /* total number of bytes output so far */ - - z_const char *msg; /* last error message, NULL if no error */ - struct internal_state FAR *state; /* not visible by applications */ - - alloc_func zalloc; /* used to allocate the internal state */ - free_func zfree; /* used to free the internal state */ - voidpf opaque; /* private data object passed to zalloc and zfree */ - - int data_type; /* best guess about the data type: binary or text */ - uLong adler; /* adler32 value of the uncompressed data */ - uLong reserved; /* reserved for future use */ -} z_stream; - -typedef z_stream FAR *z_streamp; - -/* - gzip header information passed to and from zlib routines. See RFC 1952 - for more details on the meanings of these fields. -*/ -typedef struct gz_header_s { - int text; /* true if compressed data believed to be text */ - uLong time; /* modification time */ - int xflags; /* extra flags (not used when writing a gzip file) */ - int os; /* operating system */ - Bytef *extra; /* pointer to extra field or Z_NULL if none */ - uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ - uInt extra_max; /* space at extra (only when reading header) */ - Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ - uInt name_max; /* space at name (only when reading header) */ - Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ - uInt comm_max; /* space at comment (only when reading header) */ - int hcrc; /* true if there was or will be a header crc */ - int done; /* true when done reading gzip header (not used - when writing a gzip file) */ -} gz_header; - -typedef gz_header FAR *gz_headerp; - -/* - The application must update next_in and avail_in when avail_in has dropped - to zero. It must update next_out and avail_out when avail_out has dropped - to zero. The application must initialize zalloc, zfree and opaque before - calling the init function. All other fields are set by the compression - library and must not be updated by the application. - - The opaque value provided by the application will be passed as the first - parameter for calls of zalloc and zfree. This can be useful for custom - memory management. The compression library attaches no meaning to the - opaque value. - - zalloc must return Z_NULL if there is not enough memory for the object. - If zlib is used in a multi-threaded application, zalloc and zfree must be - thread safe. - - On 16-bit systems, the functions zalloc and zfree must be able to allocate - exactly 65536 bytes, but will not be required to allocate more than this if - the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers - returned by zalloc for objects of exactly 65536 bytes *must* have their - offset normalized to zero. The default allocation function provided by this - library ensures this (see zutil.c). To reduce memory requirements and avoid - any allocation of 64K objects, at the expense of compression ratio, compile - the library with -DMAX_WBITS=14 (see zconf.h). - - The fields total_in and total_out can be used for statistics or progress - reports. After compression, total_in holds the total size of the - uncompressed data and may be saved for use in the decompressor (particularly - if the decompressor wants to decompress everything in a single step). -*/ - - /* constants */ - -#define Z_NO_FLUSH 0 -#define Z_PARTIAL_FLUSH 1 -#define Z_SYNC_FLUSH 2 -#define Z_FULL_FLUSH 3 -#define Z_FINISH 4 -#define Z_BLOCK 5 -#define Z_TREES 6 -/* Allowed flush values; see deflate() and inflate() below for details */ - -#define Z_OK 0 -#define Z_STREAM_END 1 -#define Z_NEED_DICT 2 -#define Z_ERRNO (-1) -#define Z_STREAM_ERROR (-2) -#define Z_DATA_ERROR (-3) -#define Z_MEM_ERROR (-4) -#define Z_BUF_ERROR (-5) -#define Z_VERSION_ERROR (-6) -/* Return codes for the compression/decompression functions. Negative values - * are errors, positive values are used for special but normal events. - */ - -#define Z_NO_COMPRESSION 0 -#define Z_BEST_SPEED 1 -#define Z_BEST_COMPRESSION 9 -#define Z_DEFAULT_COMPRESSION (-1) -/* compression levels */ - -#define Z_FILTERED 1 -#define Z_HUFFMAN_ONLY 2 -#define Z_RLE 3 -#define Z_FIXED 4 -#define Z_DEFAULT_STRATEGY 0 -/* compression strategy; see deflateInit2() below for details */ - -#define Z_BINARY 0 -#define Z_TEXT 1 -#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ -#define Z_UNKNOWN 2 -/* Possible values of the data_type field (though see inflate()) */ - -#define Z_DEFLATED 8 -/* The deflate compression method (the only one supported in this version) */ - -#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ - -#define zlib_version zlibVersion() -/* for compatibility with versions < 1.0.2 */ - - - /* basic functions */ - -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); -/* The application can compare zlibVersion and ZLIB_VERSION for consistency. - If the first character differs, the library code actually used is not - compatible with the zlib.h header file used by the application. This check - is automatically made by deflateInit and inflateInit. - */ - -/* -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); - - Initializes the internal stream state for compression. The fields - zalloc, zfree and opaque must be initialized before by the caller. If - zalloc and zfree are set to Z_NULL, deflateInit updates them to use default - allocation functions. - - The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: - 1 gives best speed, 9 gives best compression, 0 gives no compression at all - (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION - requests a default compromise between speed and compression (currently - equivalent to level 6). - - deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if level is not a valid compression level, or - Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible - with the version assumed by the caller (ZLIB_VERSION). msg is set to null - if there is no error message. deflateInit does not perform any compression: - this will be done by deflate(). -*/ - - -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); -/* - deflate compresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. deflate performs one or both of the - following actions: - - - Compress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in and avail_in are updated and - processing will resume at this point for the next call of deflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. This action is forced if the parameter flush is non zero. - Forcing flush frequently degrades the compression ratio, so this parameter - should be set only when necessary (in interactive applications). Some - output may be provided even if flush is not set. - - Before the call of deflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming more - output, and updating avail_in or avail_out accordingly; avail_out should - never be zero before the call. The application can consume the compressed - output when it wants, for example when the output buffer is full (avail_out - == 0), or after each call of deflate(). If deflate returns Z_OK and with - zero avail_out, it must be called again after making room in the output - buffer because there might be more output pending. - - Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to - decide how much data to accumulate before producing output, in order to - maximize compression. - - If the parameter flush is set to Z_SYNC_FLUSH, all pending output is - flushed to the output buffer and the output is aligned on a byte boundary, so - that the decompressor can get all input data available so far. (In - particular avail_in is zero after the call if enough output space has been - provided before the call.) Flushing may degrade compression for some - compression algorithms and so it should be used only when necessary. This - completes the current deflate block and follows it with an empty stored block - that is three bits plus filler bits to the next byte, followed by four bytes - (00 00 ff ff). - - If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the - output buffer, but the output is not aligned to a byte boundary. All of the - input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. - This completes the current deflate block and follows it with an empty fixed - codes block that is 10 bits long. This assures that enough bytes are output - in order for the decompressor to finish the block before the empty fixed code - block. - - If flush is set to Z_BLOCK, a deflate block is completed and emitted, as - for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to - seven bits of the current block are held to be written as the next byte after - the next deflate block is completed. In this case, the decompressor may not - be provided enough bits at this point in order to complete decompression of - the data provided so far to the compressor. It may need to wait for the next - block to be emitted. This is for advanced applications that need to control - the emission of deflate blocks. - - If flush is set to Z_FULL_FLUSH, all output is flushed as with - Z_SYNC_FLUSH, and the compression state is reset so that decompression can - restart from this point if previous compressed data has been damaged or if - random access is desired. Using Z_FULL_FLUSH too often can seriously degrade - compression. - - If deflate returns with avail_out == 0, this function must be called again - with the same value of the flush parameter and more output space (updated - avail_out), until the flush is complete (deflate returns with non-zero - avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that - avail_out is greater than six to avoid repeated flush markers due to - avail_out == 0 on return. - - If the parameter flush is set to Z_FINISH, pending input is processed, - pending output is flushed and deflate returns with Z_STREAM_END if there was - enough output space; if deflate returns with Z_OK, this function must be - called again with Z_FINISH and more output space (updated avail_out) but no - more input data, until it returns with Z_STREAM_END or an error. After - deflate has returned Z_STREAM_END, the only possible operations on the stream - are deflateReset or deflateEnd. - - Z_FINISH can be used immediately after deflateInit if all the compression - is to be done in a single step. In this case, avail_out must be at least the - value returned by deflateBound (see below). Then deflate is guaranteed to - return Z_STREAM_END. If not enough output space is provided, deflate will - not return Z_STREAM_END, and it must be called again as described above. - - deflate() sets strm->adler to the adler32 checksum of all input read - so far (that is, total_in bytes). - - deflate() may update strm->data_type if it can make a good guess about - the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered - binary. This field is only for information purposes and does not affect the - compression algorithm in any manner. - - deflate() returns Z_OK if some progress has been made (more input - processed or more output produced), Z_STREAM_END if all input has been - consumed and all output has been produced (only when flush is set to - Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example - if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible - (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not - fatal, and deflate() can be called again with more input and more output - space to continue compressing. -*/ - - -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any pending - output. - - deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the - stream state was inconsistent, Z_DATA_ERROR if the stream was freed - prematurely (some input or output was discarded). In the error case, msg - may be set but then points to a static string (which must not be - deallocated). -*/ - - -/* -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); - - Initializes the internal stream state for decompression. The fields - next_in, avail_in, zalloc, zfree and opaque must be initialized before by - the caller. If next_in is not Z_NULL and avail_in is large enough (the - exact value depends on the compression method), inflateInit determines the - compression method from the zlib header and allocates all data structures - accordingly; otherwise the allocation will be deferred to the first call of - inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to - use default allocation functions. - - inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller, or Z_STREAM_ERROR if the parameters are - invalid, such as a null pointer to the structure. msg is set to null if - there is no error message. inflateInit does not perform any decompression - apart from possibly reading the zlib header if present: actual decompression - will be done by inflate(). (So next_in and avail_in may be modified, but - next_out and avail_out are unused and unchanged.) The current implementation - of inflateInit() does not process any header information -- that is deferred - until inflate() is called. -*/ - - -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); -/* - inflate decompresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. inflate performs one or both of the - following actions: - - - Decompress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in is updated and processing will - resume at this point for the next call of inflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. inflate() provides as much output as possible, until there is - no more input data or no more space in the output buffer (see below about - the flush parameter). - - Before the call of inflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming more - output, and updating the next_* and avail_* values accordingly. The - application can consume the uncompressed output when it wants, for example - when the output buffer is full (avail_out == 0), or after each call of - inflate(). If inflate returns Z_OK and with zero avail_out, it must be - called again after making room in the output buffer because there might be - more output pending. - - The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, - Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much - output as possible to the output buffer. Z_BLOCK requests that inflate() - stop if and when it gets to the next deflate block boundary. When decoding - the zlib or gzip format, this will cause inflate() to return immediately - after the header and before the first block. When doing a raw inflate, - inflate() will go ahead and process the first block, and will return when it - gets to the end of that block, or when it runs out of data. - - The Z_BLOCK option assists in appending to or combining deflate streams. - Also to assist in this, on return inflate() will set strm->data_type to the - number of unused bits in the last byte taken from strm->next_in, plus 64 if - inflate() is currently decoding the last block in the deflate stream, plus - 128 if inflate() returned immediately after decoding an end-of-block code or - decoding the complete header up to just before the first byte of the deflate - stream. The end-of-block will not be indicated until all of the uncompressed - data from that block has been written to strm->next_out. The number of - unused bits may in general be greater than seven, except when bit 7 of - data_type is set, in which case the number of unused bits will be less than - eight. data_type is set as noted here every time inflate() returns for all - flush options, and so can be used to determine the amount of currently - consumed input in bits. - - The Z_TREES option behaves as Z_BLOCK does, but it also returns when the - end of each deflate block header is reached, before any actual data in that - block is decoded. This allows the caller to determine the length of the - deflate block header for later use in random access within a deflate block. - 256 is added to the value of strm->data_type when inflate() returns - immediately after reaching the end of the deflate block header. - - inflate() should normally be called until it returns Z_STREAM_END or an - error. However if all decompression is to be performed in a single step (a - single call of inflate), the parameter flush should be set to Z_FINISH. In - this case all pending input is processed and all pending output is flushed; - avail_out must be large enough to hold all of the uncompressed data for the - operation to complete. (The size of the uncompressed data may have been - saved by the compressor for this purpose.) The use of Z_FINISH is not - required to perform an inflation in one step. However it may be used to - inform inflate that a faster approach can be used for the single inflate() - call. Z_FINISH also informs inflate to not maintain a sliding window if the - stream completes, which reduces inflate's memory footprint. If the stream - does not complete, either because not all of the stream is provided or not - enough output space is provided, then a sliding window will be allocated and - inflate() can be called again to continue the operation as if Z_NO_FLUSH had - been used. - - In this implementation, inflate() always flushes as much output as - possible to the output buffer, and always uses the faster approach on the - first call. So the effects of the flush parameter in this implementation are - on the return value of inflate() as noted below, when inflate() returns early - when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of - memory for a sliding window when Z_FINISH is used. - - If a preset dictionary is needed after this call (see inflateSetDictionary - below), inflate sets strm->adler to the Adler-32 checksum of the dictionary - chosen by the compressor and returns Z_NEED_DICT; otherwise it sets - strm->adler to the Adler-32 checksum of all output produced so far (that is, - total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described - below. At the end of the stream, inflate() checks that its computed adler32 - checksum is equal to that saved by the compressor and returns Z_STREAM_END - only if the checksum is correct. - - inflate() can decompress and check either zlib-wrapped or gzip-wrapped - deflate data. The header type is detected automatically, if requested when - initializing with inflateInit2(). Any information contained in the gzip - header is not retained, so applications that need that information should - instead use raw inflate, see inflateInit2() below, or inflateBack() and - perform their own processing of the gzip header and trailer. When processing - gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output - producted so far. The CRC-32 is checked against the gzip trailer. - - inflate() returns Z_OK if some progress has been made (more input processed - or more output produced), Z_STREAM_END if the end of the compressed data has - been reached and all uncompressed output has been produced, Z_NEED_DICT if a - preset dictionary is needed at this point, Z_DATA_ERROR if the input data was - corrupted (input stream not conforming to the zlib format or incorrect check - value), Z_STREAM_ERROR if the stream structure was inconsistent (for example - next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory, - Z_BUF_ERROR if no progress is possible or if there was not enough room in the - output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and - inflate() can be called again with more input and more output space to - continue decompressing. If Z_DATA_ERROR is returned, the application may - then call inflateSync() to look for a good compression block if a partial - recovery of the data is desired. -*/ - - -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any pending - output. - - inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state - was inconsistent. In the error case, msg may be set but then points to a - static string (which must not be deallocated). -*/ - - - /* Advanced functions */ - -/* - The following functions are needed only in some special applications. -*/ - -/* -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); - - This is another version of deflateInit with more compression options. The - fields next_in, zalloc, zfree and opaque must be initialized before by the - caller. - - The method parameter is the compression method. It must be Z_DEFLATED in - this version of the library. - - The windowBits parameter is the base two logarithm of the window size - (the size of the history buffer). It should be in the range 8..15 for this - version of the library. Larger values of this parameter result in better - compression at the expense of memory usage. The default value is 15 if - deflateInit is used instead. - - windowBits can also be -8..-15 for raw deflate. In this case, -windowBits - determines the window size. deflate() will then generate raw deflate data - with no zlib header or trailer, and will not compute an adler32 check value. - - windowBits can also be greater than 15 for optional gzip encoding. Add - 16 to windowBits to write a simple gzip header and trailer around the - compressed data instead of a zlib wrapper. The gzip header will have no - file name, no extra data, no comment, no modification time (set to zero), no - header crc, and the operating system will be set to 255 (unknown). If a - gzip stream is being written, strm->adler is a crc32 instead of an adler32. - - The memLevel parameter specifies how much memory should be allocated - for the internal compression state. memLevel=1 uses minimum memory but is - slow and reduces compression ratio; memLevel=9 uses maximum memory for - optimal speed. The default value is 8. See zconf.h for total memory usage - as a function of windowBits and memLevel. - - The strategy parameter is used to tune the compression algorithm. Use the - value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a - filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match), or Z_RLE to limit match distances to one (run-length - encoding). Filtered data consists mostly of small values with a somewhat - random distribution. In this case, the compression algorithm is tuned to - compress them better. The effect of Z_FILTERED is to force more Huffman - coding and less string matching; it is somewhat intermediate between - Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as - fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The - strategy parameter only affects the compression ratio but not the - correctness of the compressed output even if it is not set appropriately. - Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler - decoder for special applications. - - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid - method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is - incompatible with the version assumed by the caller (ZLIB_VERSION). msg is - set to null if there is no error message. deflateInit2 does not perform any - compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the compression dictionary from the given byte sequence - without producing any compressed output. When using the zlib format, this - function must be called immediately after deflateInit, deflateInit2 or - deflateReset, and before any call of deflate. When doing raw deflate, this - function must be called either before any call of deflate, or immediately - after the completion of a deflate block, i.e. after all input has been - consumed and all output has been delivered when using any of the flush - options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The - compressor and decompressor must use exactly the same dictionary (see - inflateSetDictionary). - - The dictionary should consist of strings (byte sequences) that are likely - to be encountered later in the data to be compressed, with the most commonly - used strings preferably put towards the end of the dictionary. Using a - dictionary is most useful when the data to be compressed is short and can be - predicted with good accuracy; the data can then be compressed better than - with the default empty dictionary. - - Depending on the size of the compression data structures selected by - deflateInit or deflateInit2, a part of the dictionary may in effect be - discarded, for example if the dictionary is larger than the window size - provided in deflateInit or deflateInit2. Thus the strings most likely to be - useful should be put at the end of the dictionary, not at the front. In - addition, the current implementation of deflate will use at most the window - size minus 262 bytes of the provided dictionary. - - Upon return of this function, strm->adler is set to the adler32 value - of the dictionary; the decompressor may later use this value to determine - which dictionary has been used by the compressor. (The adler32 value - applies to the whole dictionary even if only a subset of the dictionary is - actually used by the compressor.) If a raw deflate was requested, then the - adler32 value is not computed and strm->adler is not set. - - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is - inconsistent (for example if deflate has already been called for this stream - or if not at a block boundary for raw deflate). deflateSetDictionary does - not perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when several compression strategies will be - tried, for example when there are several ways of pre-processing the input - data with a filter. The streams that will be discarded should then be freed - by calling deflateEnd. Note that deflateCopy duplicates the internal - compression state which can be quite large, so this strategy is slow and can - consume lots of memory. - - deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being Z_NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); -/* - This function is equivalent to deflateEnd followed by deflateInit, - but does not free and reallocate all the internal compression state. The - stream will keep the same compression level and any other attributes that - may have been set by deflateInit2. - - deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL). -*/ - -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); -/* - Dynamically update the compression level and compression strategy. The - interpretation of level and strategy is as in deflateInit2. This can be - used to switch between compression and straight copy of the input data, or - to switch to a different kind of input data requiring a different strategy. - If the compression level is changed, the input available so far is - compressed with the old level (and may be flushed); the new level will take - effect only at the next call of deflate(). - - Before the call of deflateParams, the stream state must be set as for - a call of deflate(), since the currently available input may have to be - compressed and flushed. In particular, strm->avail_out must be non-zero. - - deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source - stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if - strm->avail_out was zero. -*/ - -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, - int good_length, - int max_lazy, - int nice_length, - int max_chain)); -/* - Fine tune deflate's internal compression parameters. This should only be - used by someone who understands the algorithm used by zlib's deflate for - searching for the best matching string, and even then only by the most - fanatic optimizer trying to squeeze out the last compressed bit for their - specific input data. Read the deflate.c source code for the meaning of the - max_lazy, good_length, nice_length, and max_chain parameters. - - deflateTune() can be called after deflateInit() or deflateInit2(), and - returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. - */ - -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, - uLong sourceLen)); -/* - deflateBound() returns an upper bound on the compressed size after - deflation of sourceLen bytes. It must be called after deflateInit() or - deflateInit2(), and after deflateSetHeader(), if used. This would be used - to allocate an output buffer for deflation in a single pass, and so would be - called before deflate(). If that first deflate() call is provided the - sourceLen input bytes, an output buffer allocated to the size returned by - deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed - to return Z_STREAM_END. Note that it is possible for the compressed size to - be larger than the value returned by deflateBound() if flush options other - than Z_FINISH or Z_NO_FLUSH are used. -*/ - -ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, - unsigned *pending, - int *bits)); -/* - deflatePending() returns the number of bytes and bits of output that have - been generated, but not yet provided in the available output. The bytes not - provided would be due to the available output space having being consumed. - The number of bits of output not provided are between 0 and 7, where they - await more bits to join them in order to fill out a full byte. If pending - or bits are Z_NULL, then those values are not set. - - deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. - */ - -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - deflatePrime() inserts bits in the deflate output stream. The intent - is that this function is used to start off the deflate output with the bits - leftover from a previous deflate stream when appending to it. As such, this - function can only be used for raw deflate, and must be used before the first - deflate() call after a deflateInit2() or deflateReset(). bits must be less - than or equal to 16, and that many of the least significant bits of value - will be inserted in the output. - - deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough - room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the - source stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, - gz_headerp head)); -/* - deflateSetHeader() provides gzip header information for when a gzip - stream is requested by deflateInit2(). deflateSetHeader() may be called - after deflateInit2() or deflateReset() and before the first call of - deflate(). The text, time, os, extra field, name, and comment information - in the provided gz_header structure are written to the gzip header (xflag is - ignored -- the extra flags are set according to the compression level). The - caller must assure that, if not Z_NULL, name and comment are terminated with - a zero byte, and that if extra is not Z_NULL, that extra_len bytes are - available there. If hcrc is true, a gzip header crc is included. Note that - the current versions of the command-line version of gzip (up through version - 1.3.x) do not support header crc's, and will report that it is a "multi-part - gzip file" and give up. - - If deflateSetHeader is not used, the default gzip header has text false, - the time set to zero, and os set to 255, with no extra, name, or comment - fields. The gzip header is returned to the default state by deflateReset(). - - deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); - - This is another version of inflateInit with an extra parameter. The - fields next_in, avail_in, zalloc, zfree and opaque must be initialized - before by the caller. - - The windowBits parameter is the base two logarithm of the maximum window - size (the size of the history buffer). It should be in the range 8..15 for - this version of the library. The default value is 15 if inflateInit is used - instead. windowBits must be greater than or equal to the windowBits value - provided to deflateInit2() while compressing, or it must be equal to 15 if - deflateInit2() was not used. If a compressed stream with a larger window - size is given as input, inflate() will return with the error code - Z_DATA_ERROR instead of trying to allocate a larger window. - - windowBits can also be zero to request that inflate use the window size in - the zlib header of the compressed stream. - - windowBits can also be -8..-15 for raw inflate. In this case, -windowBits - determines the window size. inflate() will then process raw deflate data, - not looking for a zlib or gzip header, not generating a check value, and not - looking for any check values for comparison at the end of the stream. This - is for use with other formats that use the deflate compressed data format - such as zip. Those formats provide their own check values. If a custom - format is developed using the raw deflate format for compressed data, it is - recommended that a check value such as an adler32 or a crc32 be applied to - the uncompressed data as is done in the zlib, gzip, and zip formats. For - most applications, the zlib format should be used as is. Note that comments - above on the use in deflateInit2() applies to the magnitude of windowBits. - - windowBits can also be greater than 15 for optional gzip decoding. Add - 32 to windowBits to enable zlib and gzip decoding with automatic header - detection, or add 16 to decode only the gzip format (the zlib format will - return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a - crc32 instead of an adler32. - - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller, or Z_STREAM_ERROR if the parameters are - invalid, such as a null pointer to the structure. msg is set to null if - there is no error message. inflateInit2 does not perform any decompression - apart from possibly reading the zlib header if present: actual decompression - will be done by inflate(). (So next_in and avail_in may be modified, but - next_out and avail_out are unused and unchanged.) The current implementation - of inflateInit2() does not process any header information -- that is - deferred until inflate() is called. -*/ - -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the decompression dictionary from the given uncompressed byte - sequence. This function must be called immediately after a call of inflate, - if that call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the adler32 value returned by that call of inflate. - The compressor and decompressor must use exactly the same dictionary (see - deflateSetDictionary). For raw inflate, this function can be called at any - time to set the dictionary. If the provided dictionary is smaller than the - window and there is already data in the window, then the provided dictionary - will amend what's there. The application must insure that the dictionary - that was used for compression is provided. - - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a - parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is - inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the - expected one (incorrect adler32 value). inflateSetDictionary does not - perform any decompression: this will be done by subsequent calls of - inflate(). -*/ - -ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, - Bytef *dictionary, - uInt *dictLength)); -/* - Returns the sliding dictionary being maintained by inflate. dictLength is - set to the number of bytes in the dictionary, and that many bytes are copied - to dictionary. dictionary must have enough space, where 32768 bytes is - always enough. If inflateGetDictionary() is called with dictionary equal to - Z_NULL, then only the dictionary length is returned, and nothing is copied. - Similary, if dictLength is Z_NULL, then it is not set. - - inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the - stream state is inconsistent. -*/ - -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); -/* - Skips invalid compressed data until a possible full flush point (see above - for the description of deflate with Z_FULL_FLUSH) can be found, or until all - available input is skipped. No output is provided. - - inflateSync searches for a 00 00 FF FF pattern in the compressed data. - All full flush points have this pattern, but not all occurrences of this - pattern are full flush points. - - inflateSync returns Z_OK if a possible full flush point has been found, - Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point - has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. - In the success case, the application may save the current current value of - total_in which indicates where valid compressed data was found. In the - error case, the application may repeatedly call inflateSync, providing more - input each time, until success or end of the input data. -*/ - -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when randomly accessing a large stream. The - first pass through the stream can periodically record the inflate state, - allowing restarting inflate at those points when randomly accessing the - stream. - - inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being Z_NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); -/* - This function is equivalent to inflateEnd followed by inflateInit, - but does not free and reallocate all the internal decompression state. The - stream will keep attributes that may have been set by inflateInit2. - - inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL). -*/ - -ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, - int windowBits)); -/* - This function is the same as inflateReset, but it also permits changing - the wrap and window size requests. The windowBits parameter is interpreted - the same as it is for inflateInit2. - - inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL), or if - the windowBits parameter is invalid. -*/ - -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - This function inserts bits in the inflate input stream. The intent is - that this function is used to start inflating at a bit position in the - middle of a byte. The provided bits will be used before any bytes are used - from next_in. This function should only be used with raw inflate, and - should be used before the first inflate() call after inflateInit2() or - inflateReset(). bits must be less than or equal to 16, and that many of the - least significant bits of value will be inserted in the input. - - If bits is negative, then the input stream bit buffer is emptied. Then - inflatePrime() can be called again to put bits in the buffer. This is used - to clear out bits leftover after feeding inflate a block description prior - to feeding inflate codes. - - inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); -/* - This function returns two values, one in the lower 16 bits of the return - value, and the other in the remaining upper bits, obtained by shifting the - return value down 16 bits. If the upper value is -1 and the lower value is - zero, then inflate() is currently decoding information outside of a block. - If the upper value is -1 and the lower value is non-zero, then inflate is in - the middle of a stored block, with the lower value equaling the number of - bytes from the input remaining to copy. If the upper value is not -1, then - it is the number of bits back from the current bit position in the input of - the code (literal or length/distance pair) currently being processed. In - that case the lower value is the number of bytes already emitted for that - code. - - A code is being processed if inflate is waiting for more input to complete - decoding of the code, or if it has completed decoding but is waiting for - more output space to write the literal or match data. - - inflateMark() is used to mark locations in the input data for random - access, which may be at bit positions, and to note those cases where the - output of a code may span boundaries of random access blocks. The current - location in the input stream can be determined from avail_in and data_type - as noted in the description for the Z_BLOCK flush parameter for inflate. - - inflateMark returns the value noted above or -1 << 16 if the provided - source stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, - gz_headerp head)); -/* - inflateGetHeader() requests that gzip header information be stored in the - provided gz_header structure. inflateGetHeader() may be called after - inflateInit2() or inflateReset(), and before the first call of inflate(). - As inflate() processes the gzip stream, head->done is zero until the header - is completed, at which time head->done is set to one. If a zlib stream is - being decoded, then head->done is set to -1 to indicate that there will be - no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be - used to force inflate() to return immediately after header processing is - complete and before any actual data is decompressed. - - The text, time, xflags, and os fields are filled in with the gzip header - contents. hcrc is set to true if there is a header CRC. (The header CRC - was valid if done is set to one.) If extra is not Z_NULL, then extra_max - contains the maximum number of bytes to write to extra. Once done is true, - extra_len contains the actual extra field length, and extra contains the - extra field, or that field truncated if extra_max is less than extra_len. - If name is not Z_NULL, then up to name_max characters are written there, - terminated with a zero unless the length is greater than name_max. If - comment is not Z_NULL, then up to comm_max characters are written there, - terminated with a zero unless the length is greater than comm_max. When any - of extra, name, or comment are not Z_NULL and the respective field is not - present in the header, then that field is set to Z_NULL to signal its - absence. This allows the use of deflateSetHeader() with the returned - structure to duplicate the header. However if those fields are set to - allocated memory, then the application will need to save those pointers - elsewhere so that they can be eventually freed. - - If inflateGetHeader is not used, then the header information is simply - discarded. The header is always checked for validity, including the header - CRC if present. inflateReset() will reset the process to discard the header - information. The application would need to call inflateGetHeader() again to - retrieve the header from the next gzip stream. - - inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, - unsigned char FAR *window)); - - Initialize the internal stream state for decompression using inflateBack() - calls. The fields zalloc, zfree and opaque in strm must be initialized - before the call. If zalloc and zfree are Z_NULL, then the default library- - derived memory allocation routines are used. windowBits is the base two - logarithm of the window size, in the range 8..15. window is a caller - supplied buffer of that size. Except for special applications where it is - assured that deflate was used with small window sizes, windowBits must be 15 - and a 32K byte window must be supplied to be able to decompress general - deflate streams. - - See inflateBack() for the usage of these routines. - - inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of - the parameters are invalid, Z_MEM_ERROR if the internal state could not be - allocated, or Z_VERSION_ERROR if the version of the library does not match - the version of the header file. -*/ - -typedef unsigned (*in_func) OF((void FAR *, - z_const unsigned char FAR * FAR *)); -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); - -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, - in_func in, void FAR *in_desc, - out_func out, void FAR *out_desc)); -/* - inflateBack() does a raw inflate with a single call using a call-back - interface for input and output. This is potentially more efficient than - inflate() for file i/o applications, in that it avoids copying between the - output and the sliding window by simply making the window itself the output - buffer. inflate() can be faster on modern CPUs when used with large - buffers. inflateBack() trusts the application to not change the output - buffer passed by the output function, at least until inflateBack() returns. - - inflateBackInit() must be called first to allocate the internal state - and to initialize the state with the user-provided window buffer. - inflateBack() may then be used multiple times to inflate a complete, raw - deflate stream with each call. inflateBackEnd() is then called to free the - allocated state. - - A raw deflate stream is one with no zlib or gzip header or trailer. - This routine would normally be used in a utility that reads zip or gzip - files and writes out uncompressed files. The utility would decode the - header and process the trailer on its own, hence this routine expects only - the raw deflate stream to decompress. This is different from the normal - behavior of inflate(), which expects either a zlib or gzip header and - trailer around the deflate stream. - - inflateBack() uses two subroutines supplied by the caller that are then - called by inflateBack() for input and output. inflateBack() calls those - routines until it reads a complete deflate stream and writes out all of the - uncompressed data, or until it encounters an error. The function's - parameters and return types are defined above in the in_func and out_func - typedefs. inflateBack() will call in(in_desc, &buf) which should return the - number of bytes of provided input, and a pointer to that input in buf. If - there is no input available, in() must return zero--buf is ignored in that - case--and inflateBack() will return a buffer error. inflateBack() will call - out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() - should return zero on success, or non-zero on failure. If out() returns - non-zero, inflateBack() will return with an error. Neither in() nor out() - are permitted to change the contents of the window provided to - inflateBackInit(), which is also the buffer that out() uses to write from. - The length written by out() will be at most the window size. Any non-zero - amount of input may be provided by in(). - - For convenience, inflateBack() can be provided input on the first call by - setting strm->next_in and strm->avail_in. If that input is exhausted, then - in() will be called. Therefore strm->next_in must be initialized before - calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called - immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in - must also be initialized, and then if strm->avail_in is not zero, input will - initially be taken from strm->next_in[0 .. strm->avail_in - 1]. - - The in_desc and out_desc parameters of inflateBack() is passed as the - first parameter of in() and out() respectively when they are called. These - descriptors can be optionally used to pass any information that the caller- - supplied in() and out() functions need to do their job. - - On return, inflateBack() will set strm->next_in and strm->avail_in to - pass back any unused input that was provided by the last in() call. The - return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR - if in() or out() returned an error, Z_DATA_ERROR if there was a format error - in the deflate stream (in which case strm->msg is set to indicate the nature - of the error), or Z_STREAM_ERROR if the stream was not properly initialized. - In the case of Z_BUF_ERROR, an input or output error can be distinguished - using strm->next_in which will be Z_NULL only if in() returned an error. If - strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning - non-zero. (in() will always be called before out(), so strm->next_in is - assured to be defined if out() returns non-zero.) Note that inflateBack() - cannot return Z_OK. -*/ - -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); -/* - All memory allocated by inflateBackInit() is freed. - - inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream - state was inconsistent. -*/ - -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); -/* Return flags indicating compile-time options. - - Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: - 1.0: size of uInt - 3.2: size of uLong - 5.4: size of voidpf (pointer) - 7.6: size of z_off_t - - Compiler, assembler, and debug options: - 8: DEBUG - 9: ASMV or ASMINF -- use ASM code - 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention - 11: 0 (reserved) - - One-time table building (smaller code, but not thread-safe if true): - 12: BUILDFIXED -- build static block decoding tables when needed - 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed - 14,15: 0 (reserved) - - Library content (indicates missing functionality): - 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking - deflate code when not needed) - 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect - and decode gzip streams (to avoid linking crc code) - 18-19: 0 (reserved) - - Operation variations (changes in library functionality): - 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate - 21: FASTEST -- deflate algorithm with only one, lowest compression level - 22,23: 0 (reserved) - - The sprintf variant used by gzprintf (zero is best): - 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format - 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! - 26: 0 = returns value, 1 = void -- 1 means inferred string length returned - - Remainder: - 27-31: 0 (reserved) - */ - -#ifndef Z_SOLO - - /* utility functions */ - -/* - The following utility functions are implemented on top of the basic - stream-oriented functions. To simplify the interface, some default options - are assumed (compression level and memory usage, standard memory allocation - functions). The source code of these utility functions can be modified if - you need special options. -*/ - -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Compresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total size - of the destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - - compress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer. -*/ - -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level)); -/* - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ - -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); -/* - compressBound() returns an upper bound on the compressed size after - compress() or compress2() on sourceLen bytes. It would be used before a - compress() or compress2() call to allocate the destination buffer. -*/ - -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total size - of the destination buffer, which must be large enough to hold the entire - uncompressed data. (The size of the uncompressed data must have been saved - previously by the compressor and transmitted to the decompressor by some - mechanism outside the scope of this compression library.) Upon exit, destLen - is the actual size of the uncompressed buffer. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In - the case where there is not enough room, uncompress() will fill the output - buffer with the uncompressed data up to that point. -*/ - - /* gzip file access functions */ - -/* - This library supports reading and writing files in gzip (.gz) format with - an interface similar to that of stdio, using the functions that start with - "gz". The gzip format is different from the zlib format. gzip is a gzip - wrapper, documented in RFC 1952, wrapped around a deflate stream. -*/ - -typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ - -/* -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); - - Opens a gzip (.gz) file for reading or writing. The mode parameter is as - in fopen ("rb" or "wb") but can also include a compression level ("wb9") or - a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only - compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F' - for fixed code compression as in "wb9F". (See the description of - deflateInit2 for more information about the strategy parameter.) 'T' will - request transparent writing or appending with no compression and not using - the gzip format. - - "a" can be used instead of "w" to request that the gzip stream that will - be written be appended to the file. "+" will result in an error, since - reading and writing to the same gzip file is not supported. The addition of - "x" when writing will create the file exclusively, which fails if the file - already exists. On systems that support it, the addition of "e" when - reading or writing will set the flag to close the file on an execve() call. - - These functions, as well as gzip, will read and decode a sequence of gzip - streams in a file. The append function of gzopen() can be used to create - such a file. (Also see gzflush() for another way to do this.) When - appending, gzopen does not test whether the file begins with a gzip stream, - nor does it look for the end of the gzip streams to begin appending. gzopen - will simply append a gzip stream to the existing file. - - gzopen can be used to read a file which is not in gzip format; in this - case gzread will directly read from the file without decompression. When - reading, this will be detected automatically by looking for the magic two- - byte gzip header. - - gzopen returns NULL if the file could not be opened, if there was - insufficient memory to allocate the gzFile state, or if an invalid mode was - specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). - errno can be checked to determine if the reason gzopen failed was that the - file could not be opened. -*/ - -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); -/* - gzdopen associates a gzFile with the file descriptor fd. File descriptors - are obtained from calls like open, dup, creat, pipe or fileno (if the file - has been previously opened with fopen). The mode parameter is as in gzopen. - - The next call of gzclose on the returned gzFile will also close the file - descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor - fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, - mode);. The duplicated descriptor should be saved to avoid a leak, since - gzdopen does not close fd if it fails. If you are using fileno() to get the - file descriptor from a FILE *, then you will have to use dup() to avoid - double-close()ing the file descriptor. Both gzclose() and fclose() will - close the associated file descriptor, so they need to have different file - descriptors. - - gzdopen returns NULL if there was insufficient memory to allocate the - gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not - provided, or '+' was provided), or if fd is -1. The file descriptor is not - used until the next gz* read, write, seek, or close operation, so gzdopen - will not detect if fd is invalid (unless fd is -1). -*/ - -ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); -/* - Set the internal buffer size used by this library's functions. The - default buffer size is 8192 bytes. This function must be called after - gzopen() or gzdopen(), and before any other calls that read or write the - file. The buffer memory allocation is always deferred to the first read or - write. Two buffers are allocated, either both of the specified size when - writing, or one of the specified size and the other twice that size when - reading. A larger buffer size of, for example, 64K or 128K bytes will - noticeably increase the speed of decompression (reading). - - The new buffer size also affects the maximum length for gzprintf(). - - gzbuffer() returns 0 on success, or -1 on failure, such as being called - too late. -*/ - -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); -/* - Dynamically update the compression level or strategy. See the description - of deflateInit2 for the meaning of these parameters. - - gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not - opened for writing. -*/ - -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); -/* - Reads the given number of uncompressed bytes from the compressed file. If - the input file is not in gzip format, gzread copies the given number of - bytes into the buffer directly from the file. - - After reaching the end of a gzip stream in the input, gzread will continue - to read, looking for another gzip stream. Any number of gzip streams may be - concatenated in the input file, and will all be decompressed by gzread(). - If something other than a gzip stream is encountered after a gzip stream, - that remaining trailing garbage is ignored (and no error is returned). - - gzread can be used to read a gzip file that is being concurrently written. - Upon reaching the end of the input, gzread will return with the available - data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then - gzclearerr can be used to clear the end of file indicator in order to permit - gzread to be tried again. Z_OK indicates that a gzip stream was completed - on the last gzread. Z_BUF_ERROR indicates that the input file ended in the - middle of a gzip stream. Note that gzread does not return -1 in the event - of an incomplete gzip stream. This error is deferred until gzclose(), which - will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip - stream. Alternatively, gzerror can be used before gzclose to detect this - case. - - gzread returns the number of uncompressed bytes actually read, less than - len for end of file, or -1 for error. -*/ - -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, - voidpc buf, unsigned len)); -/* - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of uncompressed bytes written or 0 in case of - error. -*/ - -ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); -/* - Converts, formats, and writes the arguments to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written, or 0 in case of error. The number of - uncompressed bytes written is limited to 8191, or one less than the buffer - size given to gzbuffer(). The caller should assure that this limit is not - exceeded. If it is exceeded, then gzprintf() will return an error (0) with - nothing written. In this case, there may also be a buffer overflow with - unpredictable consequences, which is possible only if zlib was compiled with - the insecure functions sprintf() or vsprintf() because the secure snprintf() - or vsnprintf() functions were not available. This can be determined using - zlibCompileFlags(). -*/ - -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); -/* - Writes the given null-terminated string to the compressed file, excluding - the terminating null character. - - gzputs returns the number of characters written, or -1 in case of error. -*/ - -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); -/* - Reads bytes from the compressed file until len-1 characters are read, or a - newline character is read and transferred to buf, or an end-of-file - condition is encountered. If any characters are read or if len == 1, the - string is terminated with a null character. If no characters are read due - to an end-of-file or len < 1, then the buffer is left untouched. - - gzgets returns buf which is a null-terminated string, or it returns NULL - for end-of-file or in case of error. If there was an error, the contents at - buf are indeterminate. -*/ - -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); -/* - Writes c, converted to an unsigned char, into the compressed file. gzputc - returns the value that was written, or -1 in case of error. -*/ - -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); -/* - Reads one byte from the compressed file. gzgetc returns this byte or -1 - in case of end of file or error. This is implemented as a macro for speed. - As such, it does not do all of the checking the other functions do. I.e. - it does not check to see if file is NULL, nor whether the structure file - points to has been clobbered or not. -*/ - -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); -/* - Push one character back onto the stream to be read as the first character - on the next read. At least one character of push-back is allowed. - gzungetc() returns the character pushed, or -1 on failure. gzungetc() will - fail if c is -1, and may fail if a character has been pushed but not read - yet. If gzungetc is used immediately after gzopen or gzdopen, at least the - output buffer size of pushed characters is allowed. (See gzbuffer above.) - The pushed character will be discarded if the stream is repositioned with - gzseek() or gzrewind(). -*/ - -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); -/* - Flushes all pending output into the compressed file. The parameter flush - is as in the deflate() function. The return value is the zlib error number - (see function gzerror below). gzflush is only permitted when writing. - - If the flush parameter is Z_FINISH, the remaining data is written and the - gzip stream is completed in the output. If gzwrite() is called again, a new - gzip stream will be started in the output. gzread() is able to read such - concatented gzip streams. - - gzflush should be called only when strictly necessary because it will - degrade compression if called too often. -*/ - -/* -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); - - Sets the starting position for the next gzread or gzwrite on the given - compressed file. The offset represents a number of bytes in the - uncompressed data stream. The whence parameter is defined as in lseek(2); - the value SEEK_END is not supported. - - If the file is opened for reading, this function is emulated but can be - extremely slow. If the file is opened for writing, only forward seeks are - supported; gzseek then compresses a sequence of zeroes up to the new - starting position. - - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error, in - particular if the file is opened for writing and the new starting position - would be before the current position. -*/ - -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); -/* - Rewinds the given file. This function is supported only for reading. - - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) -*/ - -/* -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); - - Returns the starting position for the next gzread or gzwrite on the given - compressed file. This position represents a number of bytes in the - uncompressed data stream, and is zero when starting, even if appending or - reading a gzip stream from the middle of a file using gzdopen(). - - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) -*/ - -/* -ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); - - Returns the current offset in the file being read or written. This offset - includes the count of bytes that precede the gzip stream, for example when - appending or when using gzdopen() for reading. When reading, the offset - does not include as yet unused buffered input. This information can be used - for a progress indicator. On error, gzoffset() returns -1. -*/ - -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); -/* - Returns true (1) if the end-of-file indicator has been set while reading, - false (0) otherwise. Note that the end-of-file indicator is set only if the - read tried to go past the end of the input, but came up short. Therefore, - just like feof(), gzeof() may return false even if there is no more data to - read, in the event that the last read request was for the exact number of - bytes remaining in the input file. This will happen if the input file size - is an exact multiple of the buffer size. - - If gzeof() returns true, then the read functions will return no more data, - unless the end-of-file indicator is reset by gzclearerr() and the input file - has grown since the previous end of file was detected. -*/ - -ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); -/* - Returns true (1) if file is being copied directly while reading, or false - (0) if file is a gzip stream being decompressed. - - If the input file is empty, gzdirect() will return true, since the input - does not contain a gzip stream. - - If gzdirect() is used immediately after gzopen() or gzdopen() it will - cause buffers to be allocated to allow reading the file to determine if it - is a gzip file. Therefore if gzbuffer() is used, it should be called before - gzdirect(). - - When writing, gzdirect() returns true (1) if transparent writing was - requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note: - gzdirect() is not needed when writing. Transparent writing must be - explicitly requested, so the application already knows the answer. When - linking statically, using gzdirect() will include all of the zlib code for - gzip file reading and decompression, which may not be desired.) -*/ - -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); -/* - Flushes all pending output if necessary, closes the compressed file and - deallocates the (de)compression state. Note that once file is closed, you - cannot call gzerror with file, since its structures have been deallocated. - gzclose must not be called more than once on the same file, just as free - must not be called more than once on the same allocation. - - gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a - file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the - last read ended in the middle of a gzip stream, or Z_OK on success. -*/ - -ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); -ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); -/* - Same as gzclose(), but gzclose_r() is only for use when reading, and - gzclose_w() is only for use when writing or appending. The advantage to - using these instead of gzclose() is that they avoid linking in zlib - compression or decompression code that is not used when only reading or only - writing respectively. If gzclose() is used, then both compression and - decompression code will be included the application when linking to a static - zlib library. -*/ - -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); -/* - Returns the error message for the last error which occurred on the given - compressed file. errnum is set to zlib error number. If an error occurred - in the file system and not in the compression library, errnum is set to - Z_ERRNO and the application may consult errno to get the exact error code. - - The application must not modify the returned string. Future calls to - this function may invalidate the previously returned string. If file is - closed, then the string previously returned by gzerror will no longer be - available. - - gzerror() should be used to distinguish errors from end-of-file for those - functions above that do not distinguish those cases in their return values. -*/ - -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); -/* - Clears the error and end-of-file flags for file. This is analogous to the - clearerr() function in stdio. This is useful for continuing to read a gzip - file that is being written concurrently. -*/ - -#endif /* !Z_SOLO */ - - /* checksum functions */ - -/* - These functions are not related to compression but are exported - anyway because they might be useful in applications using the compression - library. -*/ - -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); -/* - Update a running Adler-32 checksum with the bytes buf[0..len-1] and - return the updated checksum. If buf is Z_NULL, this function returns the - required initial value for the checksum. - - An Adler-32 checksum is almost as reliable as a CRC32 but can be computed - much faster. - - Usage example: - - uLong adler = adler32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - adler = adler32(adler, buffer, length); - } - if (adler != original_adler) error(); -*/ - -/* -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, - z_off_t len2)); - - Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 - and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for - each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of - seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note - that the z_off_t type (like off_t) is a signed integer. If len2 is - negative, the result has no meaning or utility. -*/ - -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); -/* - Update a running CRC-32 with the bytes buf[0..len-1] and return the - updated CRC-32. If buf is Z_NULL, this function returns the required - initial value for the crc. Pre- and post-conditioning (one's complement) is - performed within this function so it shouldn't be done by the application. - - Usage example: - - uLong crc = crc32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - crc = crc32(crc, buffer, length); - } - if (crc != original_crc) error(); -*/ - -/* -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); - - Combine two CRC-32 check values into one. For two sequences of bytes, - seq1 and seq2 with lengths len1 and len2, CRC-32 check values were - calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 - check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and - len2. -*/ - - - /* various hacks, don't look :) */ - -/* deflateInit and inflateInit are macros to allow checking the zlib version - * and the compiler's view of z_stream: - */ -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size)); -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, - unsigned char FAR *window, - const char *version, - int stream_size)); -#define deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) -#define inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) -#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) -#define inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ - (int)sizeof(z_stream)) -#define inflateBackInit(strm, windowBits, window) \ - inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, (int)sizeof(z_stream)) - -#ifndef Z_SOLO - -/* gzgetc() macro and its supporting function and exposed data structure. Note - * that the real internal state is much larger than the exposed structure. - * This abbreviated structure exposes just enough for the gzgetc() macro. The - * user should not mess with these exposed elements, since their names or - * behavior could change in the future, perhaps even capriciously. They can - * only be used by the gzgetc() macro. You have been warned. - */ -struct gzFile_s { - unsigned have; - unsigned char *next; - z_off64_t pos; -}; -ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ -#ifdef Z_PREFIX_SET -# undef z_gzgetc -# define z_gzgetc(g) \ - ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g)) -#else -# define gzgetc(g) \ - ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g)) -#endif - -/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or - * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if - * both are true, the application gets the *64 functions, and the regular - * functions are changed to 64 bits) -- in case these are set on systems - * without large file support, _LFS64_LARGEFILE must also be true - */ -#ifdef Z_LARGE64 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); - ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); -#endif - -#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) -# ifdef Z_PREFIX_SET -# define z_gzopen z_gzopen64 -# define z_gzseek z_gzseek64 -# define z_gztell z_gztell64 -# define z_gzoffset z_gzoffset64 -# define z_adler32_combine z_adler32_combine64 -# define z_crc32_combine z_crc32_combine64 -# else -# define gzopen gzopen64 -# define gzseek gzseek64 -# define gztell gztell64 -# define gzoffset gzoffset64 -# define adler32_combine adler32_combine64 -# define crc32_combine crc32_combine64 -# endif -# ifndef Z_LARGE64 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); -# endif -#else - ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); -#endif - -#else /* Z_SOLO */ - - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); - -#endif /* !Z_SOLO */ - -/* hack for buggy compilers */ -#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) - struct internal_state {int dummy;}; -#endif - -/* undocumented functions */ -ZEXTERN const char * ZEXPORT zError OF((int)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); -ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); -ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); -ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); -ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); -#if defined(_WIN32) && !defined(Z_SOLO) -ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, - const char *mode)); -#endif -#if defined(STDC) || defined(Z_HAVE_STDARG_H) -# ifndef Z_SOLO -ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, - const char *format, - va_list va)); -# endif -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ZLIB_H */ diff --git a/libs/zlib/src/zutil.c b/libs/zlib/src/zutil.c deleted file mode 100644 index b00497df..00000000 --- a/libs/zlib/src/zutil.c +++ /dev/null @@ -1,324 +0,0 @@ -/* zutil.c -- target dependent utility functions for the compression library - * Copyright (C) 1995-2005, 2010, 2011, 2012 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id: zutil.c,v 1.2 2013/08/12 09:54:03 martinprikryl Exp $ */ - -#include "zutil.h" -#ifndef Z_SOLO -# include "gzguts.h" -#endif - -#ifndef NO_DUMMY_DECL -struct internal_state {int dummy;}; /* for buggy compilers */ -#endif - -z_const char * const z_errmsg[10] = { -"need dictionary", /* Z_NEED_DICT 2 */ -"stream end", /* Z_STREAM_END 1 */ -"", /* Z_OK 0 */ -"file error", /* Z_ERRNO (-1) */ -"stream error", /* Z_STREAM_ERROR (-2) */ -"data error", /* Z_DATA_ERROR (-3) */ -"insufficient memory", /* Z_MEM_ERROR (-4) */ -"buffer error", /* Z_BUF_ERROR (-5) */ -"incompatible version",/* Z_VERSION_ERROR (-6) */ -""}; - - -const char * ZEXPORT zlibVersion() -{ - return ZLIB_VERSION; -} - -uLong ZEXPORT zlibCompileFlags() -{ - uLong flags; - - flags = 0; - switch ((int)(sizeof(uInt))) { - case 2: break; - case 4: flags += 1; break; - case 8: flags += 2; break; - default: flags += 3; - } - switch ((int)(sizeof(uLong))) { - case 2: break; - case 4: flags += 1 << 2; break; - case 8: flags += 2 << 2; break; - default: flags += 3 << 2; - } - switch ((int)(sizeof(voidpf))) { - case 2: break; - case 4: flags += 1 << 4; break; - case 8: flags += 2 << 4; break; - default: flags += 3 << 4; - } - switch ((int)(sizeof(z_off_t))) { - case 2: break; - case 4: flags += 1 << 6; break; - case 8: flags += 2 << 6; break; - default: flags += 3 << 6; - } -#ifdef DEBUG - flags += 1 << 8; -#endif -#if defined(ASMV) || defined(ASMINF) - flags += 1 << 9; -#endif -#ifdef ZLIB_WINAPI - flags += 1 << 10; -#endif -#ifdef BUILDFIXED - flags += 1 << 12; -#endif -#ifdef DYNAMIC_CRC_TABLE - flags += 1 << 13; -#endif -#ifdef NO_GZCOMPRESS - flags += 1L << 16; -#endif -#ifdef NO_GZIP - flags += 1L << 17; -#endif -#ifdef PKZIP_BUG_WORKAROUND - flags += 1L << 20; -#endif -#ifdef FASTEST - flags += 1L << 21; -#endif -#if defined(STDC) || defined(Z_HAVE_STDARG_H) -# ifdef NO_vsnprintf - flags += 1L << 25; -# ifdef HAS_vsprintf_void - flags += 1L << 26; -# endif -# else -# ifdef HAS_vsnprintf_void - flags += 1L << 26; -# endif -# endif -#else - flags += 1L << 24; -# ifdef NO_snprintf - flags += 1L << 25; -# ifdef HAS_sprintf_void - flags += 1L << 26; -# endif -# else -# ifdef HAS_snprintf_void - flags += 1L << 26; -# endif -# endif -#endif - return flags; -} - -#ifdef DEBUG - -# ifndef verbose -# define verbose 0 -# endif -int ZLIB_INTERNAL z_verbose = verbose; - -void ZLIB_INTERNAL z_error (m) - char *m; -{ - fprintf(stderr, "%s\n", m); - exit(1); -} -#endif - -/* exported to allow conversion of error code to string for compress() and - * uncompress() - */ -const char * ZEXPORT zError(err) - int err; -{ - return ERR_MSG(err); -} - -#if defined(_WIN32_WCE) - /* The Microsoft C Run-Time Library for Windows CE doesn't have - * errno. We define it as a global variable to simplify porting. - * Its value is always 0 and should not be used. - */ - int errno = 0; -#endif - -#ifndef HAVE_MEMCPY - -void ZLIB_INTERNAL zmemcpy(dest, source, len) - Bytef* dest; - const Bytef* source; - uInt len; -{ - if (len == 0) return; - do { - *dest++ = *source++; /* ??? to be unrolled */ - } while (--len != 0); -} - -int ZLIB_INTERNAL zmemcmp(s1, s2, len) - const Bytef* s1; - const Bytef* s2; - uInt len; -{ - uInt j; - - for (j = 0; j < len; j++) { - if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; - } - return 0; -} - -void ZLIB_INTERNAL zmemzero(dest, len) - Bytef* dest; - uInt len; -{ - if (len == 0) return; - do { - *dest++ = 0; /* ??? to be unrolled */ - } while (--len != 0); -} -#endif - -#ifndef Z_SOLO - -#ifdef SYS16BIT - -#ifdef __TURBOC__ -/* Turbo C in 16-bit mode */ - -# define MY_ZCALLOC - -/* Turbo C malloc() does not allow dynamic allocation of 64K bytes - * and farmalloc(64K) returns a pointer with an offset of 8, so we - * must fix the pointer. Warning: the pointer must be put back to its - * original form in order to free it, use zcfree(). - */ - -#define MAX_PTR 10 -/* 10*64K = 640K */ - -local int next_ptr = 0; - -typedef struct ptr_table_s { - voidpf org_ptr; - voidpf new_ptr; -} ptr_table; - -local ptr_table table[MAX_PTR]; -/* This table is used to remember the original form of pointers - * to large buffers (64K). Such pointers are normalized with a zero offset. - * Since MSDOS is not a preemptive multitasking OS, this table is not - * protected from concurrent access. This hack doesn't work anyway on - * a protected system like OS/2. Use Microsoft C instead. - */ - -voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) -{ - voidpf buf = opaque; /* just to make some compilers happy */ - ulg bsize = (ulg)items*size; - - /* If we allocate less than 65520 bytes, we assume that farmalloc - * will return a usable pointer which doesn't have to be normalized. - */ - if (bsize < 65520L) { - buf = farmalloc(bsize); - if (*(ush*)&buf != 0) return buf; - } else { - buf = farmalloc(bsize + 16L); - } - if (buf == NULL || next_ptr >= MAX_PTR) return NULL; - table[next_ptr].org_ptr = buf; - - /* Normalize the pointer to seg:0 */ - *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; - *(ush*)&buf = 0; - table[next_ptr++].new_ptr = buf; - return buf; -} - -void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) -{ - int n; - if (*(ush*)&ptr != 0) { /* object < 64K */ - farfree(ptr); - return; - } - /* Find the original pointer */ - for (n = 0; n < next_ptr; n++) { - if (ptr != table[n].new_ptr) continue; - - farfree(table[n].org_ptr); - while (++n < next_ptr) { - table[n-1] = table[n]; - } - next_ptr--; - return; - } - ptr = opaque; /* just to make some compilers happy */ - Assert(0, "zcfree: ptr not found"); -} - -#endif /* __TURBOC__ */ - - -#ifdef M_I86 -/* Microsoft C in 16-bit mode */ - -# define MY_ZCALLOC - -#if (!defined(_MSC_VER) || (_MSC_VER <= 600)) -# define _halloc halloc -# define _hfree hfree -#endif - -voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size) -{ - if (opaque) opaque = 0; /* to make compiler happy */ - return _halloc((long)items, size); -} - -void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) -{ - if (opaque) opaque = 0; /* to make compiler happy */ - _hfree(ptr); -} - -#endif /* M_I86 */ - -#endif /* SYS16BIT */ - - -#ifndef MY_ZCALLOC /* Any system without a special alloc function */ - -#ifndef STDC -extern voidp malloc OF((uInt size)); -extern voidp calloc OF((uInt items, uInt size)); -extern void free OF((voidpf ptr)); -#endif - -voidpf ZLIB_INTERNAL zcalloc (opaque, items, size) - voidpf opaque; - unsigned items; - unsigned size; -{ - if (opaque) items += size - size; /* make compiler happy */ - return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : - (voidpf)calloc(items, size); -} - -void ZLIB_INTERNAL zcfree (opaque, ptr) - voidpf opaque; - voidpf ptr; -{ - free(ptr); - if (opaque) return; /* make compiler happy */ -} - -#endif /* MY_ZCALLOC */ - -#endif /* !Z_SOLO */ diff --git a/libs/zlib/src/zutil.h b/libs/zlib/src/zutil.h deleted file mode 100644 index af606c5a..00000000 --- a/libs/zlib/src/zutil.h +++ /dev/null @@ -1,253 +0,0 @@ -/* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-2013 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* @(#) $Id: zutil.h,v 1.2 2013/08/12 09:54:03 martinprikryl Exp $ */ - -#ifndef ZUTIL_H -#define ZUTIL_H - -#ifdef HAVE_HIDDEN -# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) -#else -# define ZLIB_INTERNAL -#endif - -#include "zlib.h" - -#if defined(STDC) && !defined(Z_SOLO) -# if !(defined(_WIN32_WCE) && defined(_MSC_VER)) -# include -# endif -# include -# include -#endif - -#ifdef Z_SOLO - typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ -#endif - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - -typedef unsigned char uch; -typedef uch FAR uchf; -typedef unsigned short ush; -typedef ush FAR ushf; -typedef unsigned long ulg; - -extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ -/* (size given to avoid silly warnings with Visual C++) */ - -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] - -#define ERR_RETURN(strm,err) \ - return (strm->msg = ERR_MSG(err), (err)) -/* To be used only when the state is known to be valid */ - - /* common constants */ - -#ifndef DEF_WBITS -# define DEF_WBITS MAX_WBITS -#endif -/* default windowBits for decompression. MAX_WBITS is for compression only */ - -#if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -#else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif -/* default memLevel */ - -#define STORED_BLOCK 0 -#define STATIC_TREES 1 -#define DYN_TREES 2 -/* The three kinds of block type */ - -#define MIN_MATCH 3 -#define MAX_MATCH 258 -/* The minimum and maximum match lengths */ - -#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ - - /* target dependencies */ - -#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) -# define OS_CODE 0x00 -# ifndef Z_SOLO -# if defined(__TURBOC__) || defined(__BORLANDC__) -# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) - /* Allow compilation with ANSI keywords only enabled */ - void _Cdecl farfree( void *block ); - void *_Cdecl farmalloc( unsigned long nbytes ); -# else -# include -# endif -# else /* MSC or DJGPP */ -# include -# endif -# endif -#endif - -#ifdef AMIGA -# define OS_CODE 0x01 -#endif - -#if defined(VAXC) || defined(VMS) -# define OS_CODE 0x02 -# define F_OPEN(name, mode) \ - fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") -#endif - -#if defined(ATARI) || defined(atarist) -# define OS_CODE 0x05 -#endif - -#ifdef OS2 -# define OS_CODE 0x06 -# if defined(M_I86) && !defined(Z_SOLO) -# include -# endif -#endif - -#if defined(MACOS) || defined(TARGET_OS_MAC) -# define OS_CODE 0x07 -# ifndef Z_SOLO -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include /* for fdopen */ -# else -# ifndef fdopen -# define fdopen(fd,mode) NULL /* No fdopen() */ -# endif -# endif -# endif -#endif - -#ifdef TOPS20 -# define OS_CODE 0x0a -#endif - -#ifdef WIN32 -# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ -# define OS_CODE 0x0b -# endif -#endif - -#ifdef __50SERIES /* Prime/PRIMOS */ -# define OS_CODE 0x0f -#endif - -#if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ -#endif - -#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX -# if defined(_WIN32_WCE) -# define fdopen(fd,mode) NULL /* No fdopen() */ -# ifndef _PTRDIFF_T_DEFINED - typedef int ptrdiff_t; -# define _PTRDIFF_T_DEFINED -# endif -# else -# define fdopen(fd,type) _fdopen(fd,type) -# endif -#endif - -#if defined(__BORLANDC__) && !defined(MSDOS) - #pragma warn -8004 - #pragma warn -8008 - #pragma warn -8066 -#endif - -/* provide prototypes for these when building zlib without LFS */ -#if !defined(_WIN32) && \ - (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); -#endif - - /* common defaults */ - -#ifndef OS_CODE -# define OS_CODE 0x03 /* assume Unix */ -#endif - -#ifndef F_OPEN -# define F_OPEN(name, mode) fopen((name), (mode)) -#endif - - /* functions */ - -#if defined(pyr) || defined(Z_SOLO) -# define NO_MEMCPY -#endif -#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) - /* Use our own functions for small and medium model with MSC <= 5.0. - * You may have to use the same strategy for Borland C (untested). - * The __SC__ check is for Symantec. - */ -# define NO_MEMCPY -#endif -#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) -# define HAVE_MEMCPY -#endif -#ifdef HAVE_MEMCPY -# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ -# define zmemcpy _fmemcpy -# define zmemcmp _fmemcmp -# define zmemzero(dest, len) _fmemset(dest, 0, len) -# else -# define zmemcpy memcpy -# define zmemcmp memcmp -# define zmemzero(dest, len) memset(dest, 0, len) -# endif -#else - void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); - int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); - void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); -#endif - -/* Diagnostic functions */ -#ifdef DEBUG -# include - extern int ZLIB_INTERNAL z_verbose; - extern void ZLIB_INTERNAL z_error OF((char *m)); -# define Assert(cond,msg) {if(!(cond)) z_error(msg);} -# define Trace(x) {if (z_verbose>=0) fprintf x ;} -# define Tracev(x) {if (z_verbose>0) fprintf x ;} -# define Tracevv(x) {if (z_verbose>1) fprintf x ;} -# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} -# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} -#else -# define Assert(cond,msg) -# define Trace(x) -# define Tracev(x) -# define Tracevv(x) -# define Tracec(c,x) -# define Tracecv(c,x) -#endif - -#ifndef Z_SOLO - voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, - unsigned size)); - void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); -#endif - -#define ZALLOC(strm, items, size) \ - (*((strm)->zalloc))((strm)->opaque, (items), (size)) -#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) -#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} - -/* Reverse the bytes in a 32-bit value */ -#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ - (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) - -#endif /* ZUTIL_H */ diff --git a/readme_mfc.txt b/readme_mfc.txt index f4f99181..f06b5ce2 100644 --- a/readme_mfc.txt +++ b/readme_mfc.txt @@ -1,137 +1,12 @@ -The following is a copy of post at -https://forums.embarcadero.com/message.jspa?messageID=175480#175480 - 1) copy libs\mfc\source to $(BDS)\source\mfc 2) copy libs\mfc\include to $(BDS)\include\mfc -3) make following changes to files in $(BDS)\source\mfc - - - change line 64 of borland.mak to read: - UNICODE=1 - - - change line 140 of borland.mak to read: - MODEL=U - - - add the following line to borland.mak at line 141 - TARGDEFS=/D_UNICODE /DUNICODE /D_AFX_NO_OLEDB_SUPPORT /D_AFX_NO_OCC_SUPPORT - - - replace lines 305-310 of borland.mak with: - WINDOWS=winhand.obj - - - replace lines 307-312 of borland.mak with: - DIALOG= - - - replace lines 309-311 of borland.mak with: - WINMISC=afxcrit.obj winstr.obj winutil.obj auxdata.obj wingdi.obj - - - replace lines 311-316 of borland.mak with: - DOCVIEW= - - - comment out line 315 of borland.mak to read: - #INTERNET=$(INTERNET) isapimix.obj - - - replace lines 318-322 of borland.mak with: - APPLICATION=appterm.obj appui1.obj appinit.obj apphelp.obj thrdcore.obj - - - comment out lines 321-322 of borland.mak to read: - #APPLICATION=$(APPLICATION) app3ds.obj \ - # nolib.obj appmodul.obj dllmodul.obj oleexp.obj dumpstak.obj - - - comment out lines 326-328 of borland.mak to read: - #DB=\ - # dbcore.obj dbrfx.obj dbview.obj dbflt.obj \ - # dblong.obj dbvar.obj - - - replace lines 357-367 of borland.mak with: - OLECTL= - - - change line 516 of borland.mak to read: - $(LIBDIR)\$(GOAL).lib: $(D)\$(OBJS) - - - change line 517 of borland.mak to read: - # @-if exist $@ erase $@ +3) compile the mfc library using the command: + make -fborland.mak NO_WARNINGS=1 + (warnings about missing object in library are ok, for the first build) - - change line 775 of arccore.cpp to read: - AfxThrowArchiveException(CArchiveException::generic); - - - change line 781 of arccore.cpp to read: - AfxThrowArchiveException(CArchiveException::generic); - - - change code of following methods in inet.cpp - CInternetSession::SetCookie - CInternetSession::GetCookie (both overloads) - to read - AfxThrowInternetException(GetLastError()); - return false; - - - change code of following method in inet.cpp - CInternetSession::GetCookieLength - to read - AfxThrowInternetException(GetLastError()); - return 0; - - - change line 281 of olecli1.cpp to read: - LPCTSTR pstrIndex = _tcsinc(pstrSource); - - - add the following line to strex.cpp at line 431 - #define _tclen(__a) (1) - - - comment out line 37 in afxinl1.cpp to read: - //#include "afxdlgs.inl" - - - comment out line 44 in afxinl1.cpp to read: - //#include "afxext.inl" - - - comment out lines 64-68 in afxstate.cpp to read: - /*if (m_pToolTip != NULL) - { - m_pToolTip->DestroyWindow(); - delete m_pToolTip; - }*/ - - - comment out lines 144-148 in afxstate.cpp to read: - /*if (m_pTypeLibCacheMap != NULL) - { - m_pTypeLibCacheMap->RemoveAll(&m_typeLibCache); - delete m_pTypeLibCacheMap; - } - - - comment out lines 260-277 in afxstate.cpp to read: - /*void CTypeLibCache::Unlock() - { - ASSERT(m_cRef > 0); - .... - }*/ - - - comment out lines 37-41 in appui1.cpp to read: - /*// check if notify hook installed - ASSERT_KINDOF(CFrameWnd, pMainWnd); - CFrameWnd* pFrameWnd = (CFrameWnd*)pMainWnd; - if (pFrameWnd->m_pNotifyHook != NULL) - pFrameWnd->m_pNotifyHook->OnEnableModeless(bEnable);*/ - - - comment out lines 157-164 in appui1.cpp to read: - /*if (hWnd == NULL) - { - CFrameWnd* pFrame = CCmdTarget::GetRoutingFrame_(); - if (pFrame != NULL) - hWnd = pFrame->GetSafeHwnd(); - else - hWnd = AfxGetMainWnd()->GetSafeHwnd(); - }*/ - - - comment out lines 213-216 in appui1.cpp to read: - /* CFrameWnd* pFrame = AfxGetThreadState()->m_pRoutingFrame; - if (pFrame != NULL) - ASSERT_VALID(pFrame); - return pFrame;*/ - return NULL; - -4) compile the mfc library using the command: -MAKE -fborland.mak NO_WARNINGS=1 +4) compile the debug mfc library using the command: + make -fborland.mak NO_WARNINGS=1 -DDEBUG By default the library will be at $(BDS)\lib\UafxcW.lib - -See also: -https://forums.embarcadero.com/thread.jspa?messageID=175481&tstart=0 diff --git a/source/Console.cbproj b/source/Console.cbproj index fdaf7e4f..6e4cdb66 100644 --- a/source/Console.cbproj +++ b/source/Console.cbproj @@ -1,28 +1,52 @@ - - {838C77E9-8237-4097-964C-EBB952D2E9A8} - 13.4 - Release - None - True - Win32 - 1 - Console - - - true - - - true - Base - true - - - true - Base - true - - + + {838C77E9-8237-4097-964C-EBB952D2E9A8} + 15.4 + Release + None + True + Win32 + 1 + Console + + + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + <_TCHARMapping>wchar_t rtl.lib true @@ -30,9 +54,8 @@ true JPHNE System;Xml;Data;Datasnap;Web;Soap;Vcl;$(DCC_Namespace) - NO_STRICT;$(Defines) console\;$(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk;$(ILINK_LibraryPath) - console\;$(BDS)\include;$(BDS)\include\windows\vcl;$(BDS)\include\dinkumware;$(IncludePath) + console\;$(BDS)\include;$(BDS)\include\windows\vcl;$(IncludePath) rtl.lib None true @@ -40,13 +63,14 @@ com rtl.bpi;$(PackageImports) CppConsoleApplication + Console true - CompanyName=Martin Prikryl;FileDescription=Console interface for WinSCP;FileVersion=4.0.3.0;InternalName=console;LegalCopyright=(c) 2000-2014 Martin Prikryl;LegalTrademarks=;OriginalFilename=winscp.com;ProductName=WinSCP;ProductVersion=5.5.4.0;ReleaseType=stable;WWW=http://winscp.net/ + CompanyName=Martin Prikryl;FileDescription=Console interface for WinSCP;FileVersion=4.1.0.0;InternalName=console;LegalCopyright=(c) 2000-2014 Martin Prikryl;LegalTrademarks=;OriginalFilename=winscp.com;ProductName=WinSCP;ProductVersion=5.6.0.0;ReleaseType=stable;WWW=http://winscp.net/ 1033 4 - 3 + 1 - + true true false @@ -57,7 +81,6 @@ true DEBUG false - _DEBUG;$(Defines) $(FINAL_PATH)\Debug true $(BDS)\lib\debug;$(ILINK_LibraryPath) @@ -65,33 +88,44 @@ Full true - - NDEBUG;$(Defines) + + _DEBUG;$(Defines) + + + _DEBUG;$(Defines) + + $(FINAL_PATH)\Release $(BDS)\lib\release;$(ILINK_LibraryPath) $(INTERM_PATH)\Release None - + + NDEBUG;$(Defines) + + + NDEBUG;$(Defines) + + - 8 - 0 - + 8 + 0 + - Base - + Base + - Cfg_1 - Base - + Cfg_1 + Base + - Cfg_2 - Base - + Cfg_2 + Base + - - + + if exist "$(FinalOutputDir)\Console.com" ( copy /y "$(FinalOutputDir)\Console.com" "$(FinalOutputDir)\WinSCP.com" ) else ( @@ -99,21 +133,23 @@ exit 0 ) - CPlusPlusBuilder.Personality.12 - CppConsoleApplication - - - - False - True - True - - - - True - - - 12 - - - \ No newline at end of file + CPlusPlusBuilder.Personality.12 + CppConsoleApplication + + + + False + True + True + False + + + + True + False + + + 12 + + + \ No newline at end of file diff --git a/source/DScpComp.cbproj b/source/DScpComp.cbproj index 51ad594a..961f1328 100644 --- a/source/DScpComp.cbproj +++ b/source/DScpComp.cbproj @@ -1,34 +1,63 @@ - - {EE6BA6C0-E60A-47E4-95EA-87E1EB520276} - 13.4 - DScpComp.cpp - Release - VCL - True - Win32 - 1 - Package - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - + + {EE6BA6C0-E60A-47E4-95EA-87E1EB520276} + 15.4 + DScpComp.cpp + Release + VCL + True + Win32 + 1 + Package + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + <_TCHARMapping>wchar_t rtl.lib;vcl.lib;vclx.lib true @@ -36,7 +65,6 @@ true JPHNE Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Vcl;$(DCC_Namespace) - OLD_DND;DESIGN_ONLY;$(Defines) true WinSCP components true @@ -47,16 +75,20 @@ true bpl CppPackage + DScpComp 64 CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= 1033 - + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + DESIGN_ONLY;$(Defines) true - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - + + DESIGN_ONLY;$(Defines) + + true true false @@ -67,7 +99,6 @@ $(INTERM_PATH)\Debug true false - NDEBUG;$(Defines) $(INTERM_PATH)\Debug true $(BDS)\lib\debug;$(ILINK_LibraryPath) @@ -75,92 +106,106 @@ Full true - - $(INTERM_PATH)\Release + + NDEBUG;$(Defines) + $(BDS)\lib\win32\release\;$(ILINK_LibraryPath) + + NDEBUG;$(Defines) + + + $(INTERM_PATH)\Release $(INTERM_PATH)\Release $(BDS)\lib\release;$(ILINK_LibraryPath) $(INTERM_PATH)\Release None - + + NDEBUG;$(Defines) + + + NDEBUG;$(Defines) + + - 4 - components\LogMemo.h - 29 - + 4 + components\LogMemo.h + 29 + - components\ThemePageControl.h - 11 - + components\ThemePageControl.h + 11 + - 5 - components\UnixDirView.h - 17 - + 5 + components\UnixDirView.h + 17 + - 32 - components\UnixDriveView.h - 3 - + 32 + components\UnixDriveView.h + 3 + - 7 - 2 - + 7 + 2 + - 8 - + 8 + - 9 - + 9 + - 10 - + 10 + - 20 - 1 - + 20 + 1 + - 23 - 0 - + 23 + 0 + - 26 - 2 - + 26 + 2 + - Base - + Base + - Cfg_1 - Base - + Cfg_1 + Base + - Cfg_2 - Base - + Cfg_2 + Base + - - - CPlusPlusBuilder.Personality.12 - CppPackage - - - - DScpComp.cpp - - - False - True - True - - - - True - - - 12 - - - \ No newline at end of file + + + CPlusPlusBuilder.Personality.12 + CppPackage + + + + DScpComp.cpp + + + False + True + True + False + + + + True + False + + + 12 + + + \ No newline at end of file diff --git a/source/DragDropP.cbproj b/source/DragDropP.cbproj index 9e8658ea..94264d92 100644 --- a/source/DragDropP.cbproj +++ b/source/DragDropP.cbproj @@ -1,34 +1,63 @@ - - {FC08225B-2B31-4129-939D-B75C1F099FFB} - 13.4 - DragDropP.cpp - Release - None - True - Win32 - 1 - Package - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - + + {FC08225B-2B31-4129-939D-B75C1F099FFB} + 15.4 + DragDropP.cpp + Release + None + True + Win32 + 1 + Package + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + <_TCHARMapping>wchar_t true true @@ -39,7 +68,6 @@ true System;Xml;Data;Datasnap;Web;Soap;Vcl;$(DCC_Namespace) true - IDE;$(Defines) Drag and Drop Components true true @@ -48,16 +76,20 @@ true bpl CppPackage + DragDropP CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= 1033 - + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + IDE;$(Defines) $(BDS)\bin\default_app.manifest true - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - + + IDE;$(Defines) + + true true false @@ -69,7 +101,6 @@ true DEBUG false - _DEBUG;$(Defines) $(INTERM_PATH)\Debug true $(BDS)\lib\debug;$(ILINK_LibraryPath) @@ -77,72 +108,85 @@ Full true - + + _DEBUG;$(Defines) + + + _DEBUG;$(Defines) + + $(INTERM_PATH)\Release - NDEBUG;$(Defines) $(INTERM_PATH)\Release $(BDS)\lib\release;$(ILINK_LibraryPath) $(INTERM_PATH)\Release None - + + NDEBUG;$(Defines) + + + NDEBUG;$(Defines) + + - 0 - + 0 + - 4 - + 4 + - 3 - + 3 + - 6 - + 6 + - 5 - + 5 + - 7 - + 7 + - 1 - + 1 + - 8 - + 8 + - Base - + Base + - Cfg_1 - Base - + Cfg_1 + Base + - Cfg_2 - Base - + Cfg_2 + Base + - - - CPlusPlusBuilder.Personality.12 - CppPackage - - - - DragDropP.cpp - - - False - True - True - - - - True - - - 12 - - - \ No newline at end of file + + + CPlusPlusBuilder.Personality.12 + CppPackage + + + + DragDropP.cpp + + + False + True + True + False + + + + True + False + + + 12 + + + \ No newline at end of file diff --git a/source/DragExt.cbproj b/source/DragExt.cbproj index 05ad90d0..184972a1 100644 --- a/source/DragExt.cbproj +++ b/source/DragExt.cbproj @@ -1,28 +1,52 @@ - - {414309A3-9B7C-4261-9989-4BC118D3A1C0} - 13.4 - Release - None - True - Win32 - 1 - Library - - - true - - - true - Base - true - - - true - Base - true - - + + {414309A3-9B7C-4261-9989-4BC118D3A1C0} + 15.4 + Release + None + True + Win32 + 1 + Library + + + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + <_TCHARMapping>wchar_t true true @@ -30,7 +54,6 @@ false JPHNE System;Xml;Data;Datasnap;Web;Soap;Vcl;$(DCC_Namespace) - NO_STRICT;$(Defines) true dragext\;$(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk;$(ILINK_LibraryPath) dragext\;$(BDS)\include;$(BDS)\include\windows\vcl;$(IncludePath) @@ -40,14 +63,15 @@ dll rtl.bpi;$(PackageImports) CppDynamicLibrary + DragExt true true - CompanyName=Martin Prikryl;FileDescription=Drag&Drop shell extension for WinSCP (32-bit);FileVersion=1.2.1.0;InternalName=dragext32;LegalCopyright=(c) 2000-2014 Martin Prikryl;LegalTrademarks=;OriginalFilename=dragext.dll;ProductName=WinSCP;ProductVersion=5.5.4.0;ReleaseType=stable;WWW=http://winscp.net/ + CompanyName=Martin Prikryl;FileDescription=Drag&Drop shell extension for WinSCP (32-bit);FileVersion=1.2.1.0;InternalName=dragext32;LegalCopyright=(c) 2000-2014 Martin Prikryl;LegalTrademarks=;OriginalFilename=dragext.dll;ProductName=WinSCP;ProductVersion=5.6.0.0;ReleaseType=stable;WWW=http://winscp.net/ 1033 2 1 - + true true false @@ -58,7 +82,6 @@ true DEBUG false - _DEBUG;$(Defines) $(FINAL_PATH)\Debug true $(BDS)\lib\debug;$(ILINK_LibraryPath) @@ -66,53 +89,66 @@ Full true - - NDEBUG;$(Defines) + + _DEBUG;$(Defines) + + + _DEBUG;$(Defines) + + $(FINAL_PATH)\Release $(BDS)\lib\release;$(ILINK_LibraryPath) $(INTERM_PATH)\Release None - + + NDEBUG;$(Defines) + + + NDEBUG;$(Defines) + + - 5 - 1 - + 5 + 1 + - Base - + Base + - Cfg_1 - Base - + Cfg_1 + Base + - Cfg_2 - Base - + Cfg_2 + Base + - - + + if "1"=="$(WITH_DRAGEXT64)" ( if exist "$(FinalOutputDir)\DragExt.dll" "$(BDS)\Bin\make.exe" -fmakefile.dragext64 -DDRAGEXT64OUTPUTPATH=$(FinalOutputDir) ) - CPlusPlusBuilder.Personality.12 - CppDynamicLibrary - - - - False - True - True - - - - True - - - 12 - - - \ No newline at end of file + CPlusPlusBuilder.Personality.12 + CppDynamicLibrary + + + + False + True + True + False + + + + True + False + + + 12 + + + \ No newline at end of file diff --git a/source/DragExt64.rc b/source/DragExt64.rc index a63106b1..ae8ccfd1 100644 --- a/source/DragExt64.rc +++ b/source/DragExt64.rc @@ -1,6 +1,6 @@ 1 VERSIONINFO FILEVERSION 1,2,1,0 -PRODUCTVERSION 5,5,4,0 +PRODUCTVERSION 5,6,0,0 FILEOS 0x4 FILETYPE 0x2 { @@ -16,7 +16,7 @@ FILETYPE 0x2 VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "dragext64.dll\0" VALUE "ProductName", "WinSCP\0" - VALUE "ProductVersion", "5.5.4.0\0" + VALUE "ProductVersion", "5.6.0.0\0" VALUE "ReleaseType", "stable\0" VALUE "WWW", "http://winscp.net/\0" } diff --git a/source/DriveDir.cbproj b/source/DriveDir.cbproj index 3c519514..d38d051f 100644 --- a/source/DriveDir.cbproj +++ b/source/DriveDir.cbproj @@ -1,46 +1,63 @@ - - {7AE7C7E2-1A28-4AC5-B8CF-15D1B12AEB41} - 13.4 - DriveDir.cpp - Release - VCL - True - Win32 - 1 - Package - - - true - - - true - Base - true - - - true - Base - true - - - true - Cfg_1 - true - true - - - true - Base - true - - - true - Cfg_2 - true - true - - + + {7AE7C7E2-1A28-4AC5-B8CF-15D1B12AEB41} + 15.4 + DriveDir.cpp + Release + VCL + True + Win32 + 1 + Package + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + <_TCHARMapping>wchar_t true true @@ -53,7 +70,6 @@ false packages\my;packages\dragndrop;$(DCC_UnitSearchPath) true - OLD_DND;$(Defines) Filemanager Toolset true true @@ -62,14 +78,18 @@ true bpl CppPackage + DriveDir CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= 1033 - + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + IDE;$(Defines) - + + IDE;$(Defines) + + true true false @@ -81,7 +101,6 @@ true DEBUG false - _DEBUG;$(Defines) $(INTERM_PATH)\Debug true $(BDS)\lib\debug;$(ILINK_LibraryPath) @@ -89,151 +108,160 @@ Full true - + + _DEBUG;$(Defines) true - + + _DEBUG;$(Defines) + + $(INTERM_PATH)\Release - NDEBUG;$(Defines) $(INTERM_PATH)\Release $(BDS)\lib\release;$(ILINK_LibraryPath) $(INTERM_PATH)\Release None - + + NDEBUG;$(Defines) true - + + NDEBUG;$(Defines) + + - 2 - 16 - + 2 + 16 + - 32 - 20 - + 32 + 20 + - 5 - 47 - + 5 + 47 + - 9 - 77 - + 9 + 77 + - 50 - 0 - + 50 + 0 + - -1 - 11 - + -1 + 11 + - 8 - 18 - + 8 + 18 + - 44 - 4 - + 44 + 4 + - -1 - 17 - + -1 + 17 + - 14 - + 14 + - 35 - 21 - + 35 + 21 + - -1 - 23 - + -1 + 23 + - 20 - 19 - + 20 + 19 + - -1 - 29 - + -1 + 29 + - 26 - 24 - + 26 + 24 + - 38 - 22 - + 38 + 22 + - 56 - 2 - + 56 + 2 + - 41 - 3 - + 41 + 3 + - 53 - 1 - + 53 + 1 + - 68 - 12 - + 68 + 12 + - 25 - + 25 + - 24 - + 24 + - 6 - 59 - + 6 + 59 + - 62 - 10 - + 62 + 10 + - 65 - 11 - + 65 + 11 + - Base - + Base + - Cfg_1 - Base - + Cfg_1 + Base + - Cfg_2 - Base - + Cfg_2 + Base + - - - CPlusPlusBuilder.Personality.12 - CppPackage - - - - DriveDir.cpp - - - False - True - True - - - - True - - - 12 - - - \ No newline at end of file + + + CPlusPlusBuilder.Personality.12 + CppPackage + + + + DriveDir.cpp + + + False + True + True + False + + + + True + False + + + 12 + + + \ No newline at end of file diff --git a/source/FileZilla.cbproj b/source/FileZilla.cbproj index d2f28d52..9fcf4768 100644 --- a/source/FileZilla.cbproj +++ b/source/FileZilla.cbproj @@ -1,33 +1,62 @@ - - {152D1B4E-7546-4C2B-80C5-F0D9D5F6D9D7} - 13.4 - Release - None - True - Win32 - 1 - StaticLibrary - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - + + {152D1B4E-7546-4C2B-80C5-F0D9D5F6D9D7} + 15.4 + Release + None + True + Win32 + 1 + StaticLibrary + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + <_TCHARMapping>wchar_t true true @@ -43,21 +72,25 @@ false JPHNE System;Xml;Data;Datasnap;Web;Soap;Vcl;$(DCC_Namespace) - NO_STRICT;_WIN32;$(Defines) $(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk;$(ILINK_LibraryPath) - filezilla\misc\;filezilla\;resource;..\libs\openssl;$(BDS)\include;$(BDS)\include\windows\vcl;$(BDS)\include\mfc;$(BDS)\include\dinkumware;$(IncludePath) + filezilla\misc\;filezilla\;resource;..\libs\openssl;$(BDS)\include;$(BDS)\include\windows\vcl;$(BDS)\include\mfc;$(IncludePath) None true lib CppStaticLibrary + FileZilla 64 CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= 1033 - + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + _WIN32;$(Defines) + + + _WIN32;$(Defines) - + true true false @@ -71,7 +104,6 @@ true DEBUG false - _DEBUG;$(Defines) $(INTERM_PATH)\Debug true $(BDS)\lib\debug;$(ILINK_LibraryPath) @@ -79,112 +111,125 @@ Full true - - NDEBUG;$(Defines) + + _DEBUG;$(Defines) + + + _DEBUG;$(Defines) + + $(INTERM_PATH)\Release $(BDS)\lib\release;$(ILINK_LibraryPath) $(INTERM_PATH)\Release None - + + NDEBUG;$(Defines) + + + NDEBUG;$(Defines) + + - 0 - + 0 + - 1 - + 1 + - 2 - + 2 + - 3 - + 3 + - 4 - + 4 + - 5 - + 5 + - 6 - + 6 + - 7 - + 7 + - filezilla\FileZillaIntern.h - 8 - + filezilla\FileZillaIntern.h + 8 + - filezilla\FileZillaIntf.h - 9 - + filezilla\FileZillaIntf.h + 9 + - 10 - + 10 + - 11 - + 11 + - 12 - + 12 + - 13 - + 13 + - 14 - + 14 + - 20 - + 20 + - 21 - + 21 + - filezilla\Options.h - 15 - + filezilla\Options.h + 15 + - 16 - + 16 + - 17 - + 17 + - 18 - + 18 + - 19 - + 19 + - Base - + Base + - Cfg_1 - Base - + Cfg_1 + Base + - Cfg_2 - Base - + Cfg_2 + Base + - - - CPlusPlusBuilder.Personality.12 - CppStaticLibrary - - - - False - True - True - - - - True - - - 12 - - - \ No newline at end of file + + + CPlusPlusBuilder.Personality.12 + CppStaticLibrary + + + + False + True + True + False + + + + True + False + + + 12 + + + \ No newline at end of file diff --git a/source/Jcl.cbproj b/source/Jcl.cbproj new file mode 100644 index 00000000..473b289b --- /dev/null +++ b/source/Jcl.cbproj @@ -0,0 +1,213 @@ + + + {BABF1FFA-834C-44BA-8CE2-BA19AAC5C459} + 15.4 + None + Jcl.cpp + True + Release + Win32 + 1 + Package + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + + <_TCHARMapping>char + true + true + false + JPHNE + System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) + packages\jcl;$(DCC_UnitSearchPath) + true + true + true + packages\jcl\;$(ILINK_LibraryPath) + $(BDSLIB)\$(PLATFORM)\release\$(LANGDIR);$(ILINK_TranslatedLibraryPath) + packages\jcl\;$(IncludePath) + true + CppPackage + true + Jcl + 64 + true + + + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + WINSCP;$(Defines) + vcldbx;vclib;inetdbbde;tbxp;ibxpress;vclimg;vclactnband;vcldb;vcldsnap;bindcompvcl;vclie;vcltouch;bcbsmp;websnap;vclribbon;Moje;vcl;DriveDir;CloudService;CodeSiteExpressPkg;dsnapcon;vclx;webdsnap;tb2k;bdertl;DragDropP;bcbie;adortl;$(PackageImports) + true + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + + + WINSCP;$(Defines) + vcldbx;vclib;inetdbbde;tbxp;ibxpress;vclimg;vclactnband;vcldb;vcldsnap;bindcompvcl;vclie;vcltouch;bcbsmp;websnap;vclribbon;Moje;vcl;DriveDir;CloudService;CodeSiteExpressPkg;dsnapcon;vclx;webdsnap;tb2k;bdertl;DragDropP;bcbie;adortl;$(PackageImports) + + + true + true + false + false + true + true + None + $(INTERM_PATH)\Debug + true + DEBUG + false + $(INTERM_PATH)\Debug + true + $(BDSLIB)\$(PLATFORM)\debug;$(ILINK_LibraryPath) + $(BDSLIB)\$(PLATFORM)\debug\$(LANGDIR);$(ILINK_TranslatedLibraryPath) + $(INTERM_PATH)\Debug + Full + true + + + _DEBUG;$(Defines) + true + 1029 + + + _DEBUG;$(Defines) + + + $(INTERM_PATH)\Release + $(INTERM_PATH)\Release + $(BDS)\lib\release;$(ILINK_LibraryPath) + $(INTERM_PATH)\Release + None + + + NDEBUG;$(Defines) + + + NDEBUG;$(Defines) + + + + 0 + + + 3 + + + 3 + + + 4 + + + 5 + + + 6 + + + 7 + + + 8 + + + 9 + + + 10 + + + 11 + + + 12 + + + 13 + + + 1 + + + Base + + + Cfg_1 + Base + + + Cfg_2 + Base + + + + CPlusPlusBuilder.Personality.12 + CppPackage + + + + Jcl.cpp + + + False + True + True + False + + + + + True + False + + + 12 + + + + \ No newline at end of file diff --git a/source/Jcl.cpp b/source/Jcl.cpp new file mode 100644 index 00000000..ce850851 --- /dev/null +++ b/source/Jcl.cpp @@ -0,0 +1,13 @@ +//--------------------------------------------------------------------------- +#include +#pragma hdrstop +#pragma package(smart_init) +//--------------------------------------------------------------------------- +// Package source. +//--------------------------------------------------------------------------- +#pragma argsused +extern "C" int _libmain(unsigned long reason) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/source/Moje.cbproj b/source/Moje.cbproj index af258352..bee5c45a 100644 --- a/source/Moje.cbproj +++ b/source/Moje.cbproj @@ -1,34 +1,58 @@ - - {BA755114-5DC2-43F1-88A1-D52A7E4100A8} - 13.4 - Moje.cpp - Release - None - True - Win32 - 1 - Package - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - + + {BA755114-5DC2-43F1-88A1-D52A7E4100A8} + 15.4 + Moje.cpp + Release + None + True + Win32 + 1 + Package + + + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + <_TCHARMapping>wchar_t true true @@ -47,15 +71,16 @@ true bpl CppPackage + Moje CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= 1033 - + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) $(BDS)\bin\default_app.manifest true - + true true false @@ -67,7 +92,6 @@ true DEBUG false - _DEBUG;$(Defines) $(INTERM_PATH)\Debug true $(BDS)\lib\debug;$(ILINK_LibraryPath) @@ -75,118 +99,131 @@ Full true - + + _DEBUG;$(Defines) + + + _DEBUG;$(Defines) + + $(INTERM_PATH)\Release - NDEBUG;$(Defines) $(INTERM_PATH)\Release $(BDS)\lib\release;$(ILINK_LibraryPath) $(INTERM_PATH)\Release None - + + NDEBUG;$(Defines) + + + NDEBUG;$(Defines) + + - 0 - + 0 + - 3 - + 3 + - 4 - + 4 + - 6 - + 6 + - 5 - + 5 + - 7 - + 7 + - 9 - + 9 + - 8 - + 8 + - 10 - + 10 + - 12 - + 12 + - 14 - + 14 + - 13 - + 13 + - 15 - + 15 + - 16 - + 16 + - 18 - + 18 + - 17 - + 17 + - 20 - + 20 + - 23 - + 23 + - 22 - + 22 + - 24 - + 24 + - 1 - + 1 + - 26 - + 26 + - 27 - + 27 + - Base - + Base + - Cfg_1 - Base - + Cfg_1 + Base + - Cfg_2 - Base - + Cfg_2 + Base + - - - CPlusPlusBuilder.Personality.12 - CppPackage - - - - Moje.cpp - - - False - True - True - - - - True - - - 12 - - - \ No newline at end of file + + + CPlusPlusBuilder.Personality.12 + CppPackage + + + + Moje.cpp + + + False + True + True + False + + + + True + False + + + 12 + + + \ No newline at end of file diff --git a/source/PngComponents.cbproj b/source/PngComponents.cbproj index 591dcc5c..426df85b 100644 --- a/source/PngComponents.cbproj +++ b/source/PngComponents.cbproj @@ -1,40 +1,63 @@ - - {FDCD9EE5-6451-4405-ADEF-8E997ADEE3F0} - 13.4 - VCL - PngComponents.cpp - True - Release - Win32 - 1 - Package - - - true - - - true - Base - true - - - true - Base - true - - - true - Cfg_1 - true - true - - - true - Base - true - - + + {FDCD9EE5-6451-4405-ADEF-8E997ADEE3F0} + 15.4 + VCL + PngComponents.cpp + True + Release + Win32 + 1 + Package + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + <_TCHARMapping>char true true @@ -52,15 +75,19 @@ packages\png\;packages\my;$(IncludePath) true CppPackage + PngComponents true - + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) vcldbx;vclib;inetdbbde;tbxp;ibxpress;vclimg;vclactnband;vcldb;vcldsnap;bindcompvcl;vclie;vcltouch;bcbsmp;websnap;vclribbon;Moje;vcl;DriveDir;CloudService;CodeSiteExpressPkg;dsnapcon;vclx;webdsnap;tb2k;bdertl;DragDropP;bcbie;adortl;$(PackageImports) true - CompanyName=;FileDescription=Png Components Runtime;FileVersion=1.2.0.0;InternalName=PngComponents;LegalCopyright=;LegalTrademarks=;OriginalFilename=PngComponents;ProductName=Png Components;ProductVersion=1;Comments= + CompanyName=;FileDescription=Png Components Runtime;FileVersion=1.2.0.0;InternalName=PngComponents;LegalCopyright=;LegalTrademarks=;OriginalFilename=PngComponents;ProductName=Png Components;ProductVersion=1.0;Comments= + + + vcldbx;vclib;inetdbbde;tbxp;ibxpress;vclimg;vclactnband;vcldb;vcldsnap;bindcompvcl;vclie;vcltouch;bcbsmp;websnap;vclribbon;Moje;vcl;DriveDir;CloudService;CodeSiteExpressPkg;dsnapcon;vclx;webdsnap;tb2k;bdertl;DragDropP;bcbie;adortl;$(PackageImports) - + true true false @@ -72,7 +99,6 @@ true DEBUG false - _DEBUG;$(Defines) $(INTERM_PATH)\Debug true $(BDSLIB)\$(PLATFORM)\debug;$(ILINK_LibraryPath) @@ -81,103 +107,114 @@ Full true - + + _DEBUG;$(Defines) true 1029 - + + _DEBUG;$(Defines) + + $(INTERM_PATH)\Release - NDEBUG;$(Defines) $(INTERM_PATH)\Release $(BDS)\lib\release;$(ILINK_LibraryPath) $(INTERM_PATH)\Release None - + + NDEBUG;$(Defines) + + + NDEBUG;$(Defines) + + - 2 - + 2 + - 3 - + 3 + - 7 - + 7 + - 4 - + 4 + - 5 - + 5 + - 6 - + 6 + - 8 - + 8 + - 9 - + 9 + - 10 - + 10 + - 0 - + 0 + - 11 - + 11 + - 1 - + 1 + - 15 - + 15 + - 13 - + 13 + - 16 - + 16 + - 14 - + 14 + - 12 - + 12 + - Base - + Base + - Cfg_1 - Base - + Cfg_1 + Base + - Cfg_2 - Base - + Cfg_2 + Base + - - CPlusPlusBuilder.Personality.12 - CppPackage - - - - PngComponents.cpp - - - False - True - True - - - - - True - - - 12 - - - - \ No newline at end of file + + CPlusPlusBuilder.Personality.12 + CppPackage + + + + PngComponents.cpp + + + False + True + True + False + + + + + True + False + + + 12 + + + + \ No newline at end of file diff --git a/source/Putty.cbproj b/source/Putty.cbproj index f7d82d39..2abf6094 100644 --- a/source/Putty.cbproj +++ b/source/Putty.cbproj @@ -1,33 +1,62 @@ - - {E82E93A5-709F-4C7A-918F-811A5F660941} - 13.4 - Release - None - True - Win32 - 1 - StaticLibrary - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - + + {E82E93A5-709F-4C7A-918F-811A5F660941} + 15.4 + Release + None + True + Win32 + 1 + StaticLibrary + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + rtl.lib true true @@ -57,21 +86,25 @@ false JPHNE System;Xml;Data;Datasnap;Web;Soap;Vcl;$(DCC_Namespace) - NO_STRICT;SECURITY_WIN32;MPEXT;_WINDOWS;$(Defines) $(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk;$(ILINK_LibraryPath) putty\;putty\CHARSET\;putty\WINDOWS\;$(BDS)\include;$(IncludePath) None true lib CppStaticLibrary + Putty 64 CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= 1033 - + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + SECURITY_WIN32;MPEXT;_WINDOWS;$(Defines) + + + SECURITY_WIN32;MPEXT;_WINDOWS;$(Defines) - + true true false @@ -82,7 +115,6 @@ true DEBUG false - _DEBUG;$(Defines) $(INTERM_PATH)\Debug true $(BDS)\lib\debug;$(ILINK_LibraryPath) @@ -90,207 +122,220 @@ Full true - - NDEBUG;$(Defines) + + _DEBUG;$(Defines) + + + _DEBUG;$(Defines) + + $(INTERM_PATH)\Release $(BDS)\lib\release;$(ILINK_LibraryPath) $(INTERM_PATH)\Release None - + + NDEBUG;$(Defines) + + + NDEBUG;$(Defines) + + - 5 - 25 - + 5 + 25 + - 80 - 0 - + 80 + 0 + - 5 - 25 - + 5 + 25 + - 5 - 25 - + 5 + 25 + - 8 - 24 - + 8 + 24 + - 27 - 11 - + 27 + 11 + - 26 - 14 - + 26 + 14 + - 37 - + 37 + - 23 - 17 - + 23 + 17 + - 20 - + 20 + - 23 - 19 - + 23 + 19 + - 26 - 22 - + 26 + 22 + - 29 - 21 - + 29 + 21 + - 34 - 32 - + 34 + 32 + - 35 - 33 - + 35 + 33 + - 38 - 36 - + 38 + 36 + - 41 - 35 - + 41 + 35 + - 44 - 32 - + 44 + 32 + - 47 - 29 - + 47 + 29 + - 50 - 28 - + 50 + 28 + - 38 - + 38 + - 53 - 31 - + 53 + 31 + - 56 - 30 - + 56 + 30 + - 59 - 18 - + 59 + 18 + - 62 - 6 - + 62 + 6 + - 65 - 5 - + 65 + 5 + - 8 - 68 - + 8 + 68 + - 71 - 7 - + 71 + 7 + - 74 - 4 - + 74 + 4 + - 77 - 1 - + 77 + 1 + - 83 - 3 - + 83 + 3 + - 86 - 2 - + 86 + 2 + - 89 - 15 - + 89 + 15 + - 92 - 14 - + 92 + 14 + - 95 - 17 - + 95 + 17 + - 98 - 16 - + 98 + 16 + - 39 - + 39 + - 13 - 101 - + 13 + 101 + - 104 - 10 - + 104 + 10 + - 9 - 107 - + 9 + 107 + - 12 - 110 - + 12 + 110 + - 113 - 11 - + 113 + 11 + - Base - + Base + - Cfg_1 - Base - + Cfg_1 + Base + - Cfg_2 - Base - + Cfg_2 + Base + - - - CPlusPlusBuilder.Personality.12 - CppStaticLibrary - - - - False - True - True - - - - True - - - 12 - - - \ No newline at end of file + + + CPlusPlusBuilder.Personality.12 + CppStaticLibrary + + + + False + True + True + False + + + + True + False + + + 12 + + + \ No newline at end of file diff --git a/source/RScpComp.cbproj b/source/RScpComp.cbproj index e1beca2c..358baed6 100644 --- a/source/RScpComp.cbproj +++ b/source/RScpComp.cbproj @@ -1,33 +1,57 @@ - - {D87E3096-EFE3-47F7-A35B-04FE6FB138CC} - 13.4 - Release - None - True - Win32 - 1 - StaticLibrary - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - + + {D87E3096-EFE3-47F7-A35B-04FE6FB138CC} + 15.4 + Release + None + True + Win32 + 1 + StaticLibrary + + + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + <_TCHARMapping>wchar_t vclx.lib;vcl.lib;rtl.lib;DriveDir.lib;Moje.lib;DragDropP.lib true @@ -36,22 +60,22 @@ false JPHNE System;Xml;Data;Datasnap;Web;Soap;Vcl;$(DCC_Namespace) - OLD_DND;$(Defines) $(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk;$(ILINK_LibraryPath) - components\;core;windows;packages\filemng;packages\dragndrop;packages\my;$(BDS)\include;$(BDS)\include\windows\vcl;$(BDS)\include\dinkumware;$(IncludePath) + components\;core;windows;packages\filemng;packages\dragndrop;packages\my;$(BDS)\include;$(BDS)\include\windows\vcl;$(IncludePath) None true lib CppStaticLibrary + RScpComp 64 true CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= 1033 - + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) - + true true false @@ -65,7 +89,6 @@ true DEBUG false - _DEBUG;$(Defines) $(INTERM_PATH)\Debug true $(BDS)\lib\debug;$(ILINK_LibraryPath) @@ -73,62 +96,75 @@ Full true - - NDEBUG;$(BCC_Defines) + + _DEBUG;$(Defines) + + + _DEBUG;$(Defines) + + $(INTERM_PATH)\Release $(BDS)\lib\release;$(ILINK_LibraryPath) $(INTERM_PATH)\Release None - + + NDEBUG;$(BCC_Defines);$(Defines) + + + NDEBUG;$(BCC_Defines);$(Defines) + + - components\LogMemo.h - 5 - 2 - + 5 + components\LogMemo.h + 2 + - components\ThemePageControl.h - 3 - + components\ThemePageControl.h + 3 + - components\UnixDirView.h - 8 - 1 - + 8 + components\UnixDirView.h + 1 + - components\UnixDriveView.h - 11 - 0 - + 11 + components\UnixDriveView.h + 0 + - Base - + Base + - Cfg_1 - Base - + Cfg_1 + Base + - Cfg_2 - Base - + Cfg_2 + Base + - - - CPlusPlusBuilder.Personality.12 - CppStaticLibrary - - - - False - True - True - - - - True - - - 12 - - - \ No newline at end of file + + + CPlusPlusBuilder.Personality.12 + CppStaticLibrary + + + + False + True + True + False + + + + True + False + + + 12 + + + \ No newline at end of file diff --git a/source/ScpCore.cbproj b/source/ScpCore.cbproj index e337d200..5ffc2bba 100644 --- a/source/ScpCore.cbproj +++ b/source/ScpCore.cbproj @@ -1,33 +1,62 @@ - - {E0BF1CDA-E75F-4F22-8190-70A30CBE74EE} - 13.4 - Release - None - True - Win32 - 1 - StaticLibrary - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - + + {E0BF1CDA-E75F-4F22-8190-70A30CBE74EE} + 15.4 + Release + None + True + Win32 + 1 + StaticLibrary + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + <_TCHARMapping>wchar_t rtl.lib;vclx.lib;vcl.lib;xmlrtl.lib true @@ -36,24 +65,28 @@ false JPHNE System;Xml;Data;Datasnap;Web;Soap;Vcl;$(DCC_Namespace) - USE_COMPATIBLE_THREAD;_WINDOWS;WIN32;_WIN32;WINNT;_CRTIMP=;_LIB;APR_DECLARE_STATIC;APR_HAS_UNICODE_FS=1;APR_HAS_LARGE_FILES=1;$(Defines) $(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk;$(ILINK_LibraryPath) - core\;putty;putty\windows;filezilla;resource;..\libs\openssl;..\libs\apr\include;..\libs\apr\include\arch\win32;..\libs\apr\include\arch\unix;..\libs\expat\lib;..\libs\neon\src;..\libs\zlib\src;$(BDS)\include;$(BDS)\include\windows\vcl;$(BDS)\include\dinkumware;$(BDS)\include\Mfc;$(IncludePath) + core\;putty;putty\windows;filezilla;resource;..\libs\openssl;..\libs\expat\lib;..\libs\neon\src;$(BDS)\include;$(BDS)\include\windows\vcl;$(BDS)\include\Mfc;$(IncludePath) None true lib CppStaticLibrary - 256 + ScpCore + 512 true CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= 1033 - + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) C:\Misto\bin\final\Debug\WinSCP.exe /console + USE_COMPATIBLE_THREAD;_WINDOWS;WIN32;WINNT;_CRTIMP=;_LIB;$(BUILD_TYPE);$(Defines) + + + USE_COMPATIBLE_THREAD;_WINDOWS;WIN32;WINNT;_CRTIMP=;_LIB;$(BUILD_TYPE);$(Defines) - + true true false @@ -67,7 +100,6 @@ true DEBUG false - _DEBUG;$(Defines) $(INTERM_PATH)\Debug true $(BDS)\lib\debug;$(ILINK_LibraryPath) @@ -75,158 +107,171 @@ Full true - - NDEBUG;$(Defines) + + _DEBUG;$(Defines) + + + _DEBUG;$(Defines) + + $(INTERM_PATH)\Release $(BDS)\lib\release;$(ILINK_LibraryPath) $(INTERM_PATH)\Release None - + + NDEBUG;$(Defines) + + + NDEBUG;$(Defines) + + - 5 - 17 - + 5 + 17 + - 8 - 18 - + 8 + 18 + - 19 - 11 - + 19 + 11 + - 14 - + 14 + - 17 - 15 - + 17 + 15 + - 20 - 16 - + 20 + 16 + - 23 - 20 - + 23 + 20 + - 26 - 24 - + 26 + 24 + - 29 - 25 - + 29 + 25 + - 32 - 26 - + 32 + 26 + - 35 - 21 - + 35 + 21 + - 38 - 22 - + 38 + 22 + - 41 - 23 - + 41 + 23 + - 44 - 13 - + 44 + 13 + - 47 - 3 - + 47 + 3 + - 50 - 4 - + 50 + 4 + - 53 - 5 - + 53 + 5 + - 56 - 0 - + 56 + 0 + - 59 - 1 - + 59 + 1 + - 62 - 2 - + 62 + 2 + - 65 - 6 - + 65 + 6 + - 68 - 10 - + 68 + 10 + - 71 - 11 - + 71 + 11 + - 74 - 12 - + 74 + 12 + - 77 - 7 - + 77 + 7 + - 80 - 8 - + 80 + 8 + - 9 - 83 - + 9 + 83 + - core\Usage.h - 27 - + core\Usage.h + 27 + - 42 - 23 - + 42 + 23 + - Base - + Base + - Cfg_1 - Base - + Cfg_1 + Base + - Cfg_2 - Base - + Cfg_2 + Base + - - - CPlusPlusBuilder.Personality.12 - CppStaticLibrary - - - - False - True - True - - - - True - - - 12 - - - \ No newline at end of file + + + CPlusPlusBuilder.Personality.12 + CppStaticLibrary + + + + False + True + True + False + + + + True + False + + + 12 + + + \ No newline at end of file diff --git a/source/ScpForms.cbproj b/source/ScpForms.cbproj index 1fa97b51..d8e8ab9e 100644 --- a/source/ScpForms.cbproj +++ b/source/ScpForms.cbproj @@ -1,50 +1,74 @@ - - {58677B04-A1B8-4709-A590-464869E7397E} - 13.4 - Release - None - True - Win32 - 1 - StaticLibrary - - - true - - - true - Base - true - - - true - Base - true - - + + {58677B04-A1B8-4709-A590-464869E7397E} + 15.4 + Release + None + True + Win32 + 1 + StaticLibrary + + + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + <_TCHARMapping>wchar_t - vcl.lib;rtl.lib;Moje.lib;vclx.lib;DriveDir.lib;DragDropP.lib;tb2k.lib;tbxp.lib;bcbie.lib;PngComponents.lib;xmlrtl.lib;vclactnband.lib;vclimg.lib + vcl.lib;rtl.lib;Moje.lib;vclx.lib;DriveDir.lib;DragDropP.lib;tb2k.lib;tbxp.lib;bcbie.lib;PngComponents.lib;xmlrtl.lib;vclactnband.lib;vclimg.lib;vclie.lib true true true false JPHNE System;Xml;Data;Datasnap;Web;Soap;Vcl;$(DCC_Namespace) - OLD_DND;$(Defines) $(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk;$(ILINK_LibraryPath) - windows\;forms\;core;components;resource;packages\filemng;packages\dragndrop;packages\my;packages\tb2k;packages\tbx;packages\png;$(BDS)\include\windows;$(BDS)\include\windows\vcl;$(BDS)\include\dinkumware;$(IncludePath) + windows\;forms\;core;components;resource;packages\filemng;packages\dragndrop;packages\my;packages\tb2k;packages\tbx;packages\png;packages\jcl;$(BDS)\include\windows;$(BDS)\include\windows\vcl;$(IncludePath) None true lib vcl.bpi;rtl.bpi;vclx.bpi;DragDrop.bpi;Moje.bpi;DriveDir.bpi;$(PackageImports) CppStaticLibrary + ScpForms 512 true CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= 1033 - + true true false @@ -58,7 +82,6 @@ true DEBUG false - _DEBUG;$(Defines) $(INTERM_PATH)\Debug true $(BDS)\lib\debug;$(ILINK_LibraryPath) @@ -66,302 +89,322 @@ Full true - - NDEBUG;$(Defines) + + _DEBUG;$(Defines) + + + _DEBUG;$(Defines) + + $(INTERM_PATH)\Release $(BDS)\lib\release;$(ILINK_LibraryPath) $(INTERM_PATH)\Release None - + + NDEBUG;$(Defines) + + + NDEBUG;$(Defines) + + - 27 -

            AboutDialog
            - forms\About.h - 14 - + 27 +
            AboutDialog
            + forms\About.h + 14 + - 24 -
            AuthenticateForm
            - forms\Authenticate.h - 17 -
            + 24 +
            AuthenticateForm
            + forms\Authenticate.h + 17 + - 21 -
            CleanupDialog
            - forms\Cleanup.h - 20 -
            + 21 +
            CleanupDialog
            + forms\Cleanup.h + 20 + - 23 -
            ConsoleDialog
            - forms\Console.h - 20 -
            + 23 +
            ConsoleDialog
            + forms\Console.h + 20 + - 26 -
            CopyDialog
            - forms\Copy.h - 23 -
            + 26 +
            CopyDialog
            + forms\Copy.h + 23 + - 32 -
            CopyParamCustomDialog
            - forms\CopyParamCustom.h - 29 -
            + 32 +
            CopyParamCustomDialog
            + forms\CopyParamCustom.h + 29 + - 36 -
            CopyParamPresetDialog
            - forms\CopyParamPreset.h - 35 -
            + 36 +
            CopyParamPresetDialog
            + forms\CopyParamPreset.h + 35 + - 29 -
            CopyParamsFrame
            - TFrame - forms\CopyParams.h - 22 -
            + 29 +
            CopyParamsFrame
            + TFrame + forms\CopyParams.h + 22 + - 38 -
            CreateDirectoryDialog
            - forms\CreateDirectory.h - 35 -
            + 38 +
            CreateDirectoryDialog
            + forms\CreateDirectory.h + 35 + - 44 -
            CustomDialog
            - forms\Custom.h - 37 -
            + 44 +
            CustomDialog
            + forms\Custom.h + 37 + - 41 -
            CustomCommandDialog
            - forms\CustomCommand.h - 38 -
            + 41 +
            CustomCommandDialog
            + forms\CustomCommand.h + 38 + -
            EditMaskDialog
            - forms\EditMask.h - 39 -
            +
            EditMaskDialog
            + forms\EditMask.h + 39 + - 47 -
            EditorForm
            - forms\Editor.h - 34 -
            + 47 +
            EditorForm
            + forms\Editor.h + 34 + - 50 -
            EditorPreferencesDialog
            - forms\EditorPreferences.h - 31 -
            + 50 +
            EditorPreferencesDialog
            + forms\EditorPreferences.h + 31 + - 56 -
            FileFindDialog
            - forms\FileFind.h - 33 -
            + 56 +
            FileFindDialog
            + forms\FileFind.h + 33 + - 53 -
            FileSystemInfoDialog
            - forms\FileSystemInfo.h - 30 -
            + 53 +
            FileSystemInfoDialog
            + forms\FileSystemInfo.h + 30 + - 59 -
            FullSynchronizeDialog
            - forms\FullSynchronize.h - 32 -
            + 59 +
            FullSynchronizeDialog
            + forms\FullSynchronize.h + 32 + + +
            GenerateUrlDialog
            + dfm + forms\GenerateUrl.h + 38 +
            + - 68 -
            ImportSessionsDialog
            - forms\ImportSessions.h - 5 -
            + 68 +
            ImportSessionsDialog
            + forms\ImportSessions.h + 5 + - 5 - 26 - + 5 + 26 + - 8 -
            LicenseDialog
            - forms\License.h - 71 -
            + 8 +
            LicenseDialog
            + forms\License.h + 71 + - 74 -
            LocationProfilesDialog
            - forms\LocationProfiles.h - 7 -
            + 74 +
            LocationProfilesDialog
            + forms\LocationProfiles.h + 7 + - 77 -
            LogForm
            - forms\Log.h - 4 -
            + 77 +
            LogForm
            + forms\Log.h + 4 + - 80 -
            LoginDialog
            - forms\Login.h - 1 -
            + 80 +
            LoginDialog
            + forms\Login.h + 1 + - 8 - 25 - + 8 + 25 + - 86 -
            OpenDirectoryDialog
            - forms\OpenDirectory.h - 3 -
            + 86 +
            OpenDirectoryDialog
            + forms\OpenDirectory.h + 3 + - 89 -
            PreferencesDialog
            - forms\Preferences.h - 2 -
            + 89 +
            PreferencesDialog
            + forms\Preferences.h + 2 + - 92 -
            ProgressForm
            - forms\Progress.h - 9 -
            + 92 +
            ProgressForm
            + forms\Progress.h + 9 + - 95 -
            PropertiesDialog
            - forms\Properties.h - 16 -
            + 95 +
            PropertiesDialog
            + forms\Properties.h + 16 + - 98 -
            RemoteTransferDialog
            - forms\RemoteTransfer.h - 15 -
            + 98 +
            RemoteTransferDialog
            + forms\RemoteTransfer.h + 15 + - 18 -
            RightsFrame
            - TFrame - forms\Rights.h - 101 -
            + 18 +
            RightsFrame
            + TFrame + forms\Rights.h + 101 + - 17 -
            RightsExtFrame
            - TFrame - forms\RightsExt.h - 104 -
            + 17 +
            RightsExtFrame
            + TFrame + forms\RightsExt.h + 104 + - 14 -
            SelectMaskDialog
            - forms\SelectMask.h - 107 -
            + 14 +
            SelectMaskDialog
            + forms\SelectMask.h + 107 + - 80 -
            SiteAdvancedDialog
            - forms\SiteAdvanced.h - 1 -
            + 80 +
            SiteAdvancedDialog
            + forms\SiteAdvanced.h + 1 + - 110 -
            SymlinkDialog
            - forms\Symlink.h - 11 -
            + 110 +
            SymlinkDialog
            + forms\Symlink.h + 11 + - 113 -
            SynchronizeDialog
            - forms\Synchronize.h - 10 -
            + 113 +
            SynchronizeDialog
            + forms\Synchronize.h + 10 + - 13 -
            SynchronizeChecklistDialog
            - forms\SynchronizeChecklist.h - 116 -
            + 13 +
            SynchronizeChecklistDialog
            + forms\SynchronizeChecklist.h + 116 + - 12 -
            SynchronizeProgressForm
            - forms\SynchronizeProgress.h - 119 -
            + 12 +
            SynchronizeProgressForm
            + forms\SynchronizeProgress.h + 119 + - 28 - 11 - + 28 + 11 + - Base - + Base + - Cfg_1 - Base - + Cfg_1 + Base + - Cfg_2 - Base - + Cfg_2 + Base + - - - CPlusPlusBuilder.Personality.12 - CppStaticLibrary - - - - False - True - True - - - - True - - - 12 - - - \ No newline at end of file + + + CPlusPlusBuilder.Personality.12 + CppStaticLibrary + + + + False + True + True + False + + + + True + False + + + 12 + + + \ No newline at end of file diff --git a/source/WinSCP.cbproj b/source/WinSCP.cbproj index 1474065a..edf1ad9a 100644 --- a/source/WinSCP.cbproj +++ b/source/WinSCP.cbproj @@ -1,37 +1,65 @@ - - {0B0C5EC6-5DCB-4F16-9504-1E6D37FFBB77} - 13.4 - WinSCP.cpp - Release - VCL - True - Win32 - 1 - Application - - - true - - - true - Base - true - - - true - Cfg_1 - true - true - - - true - Base - true - - + + {0B0C5EC6-5DCB-4F16-9504-1E6D37FFBB77} + 15.4 + WinSCP.cpp + Release + VCL + True + Win32 + 1 + Application + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + <_TCHARMapping>wchar_t - vcl.lib;rtl.lib;vclx.lib;ws2_32.lib;secur32.lib;Moje.lib;DriveDir.lib;DragDropP.lib;tb2k.lib;tbxp.lib;bcbie.lib;Crypt32.lib;PngComponents.lib;xmlrtl.lib;vclactnband.lib;vclimg.lib;winhttp.lib + vcl.lib;rtl.lib;vclx.lib;ws2_32.lib;secur32.lib;Moje.lib;DriveDir.lib;DragDropP.lib;tb2k.lib;tbxp.lib;bcbie.lib;Crypt32.lib;PngComponents.lib;xmlrtl.lib;vclactnband.lib;vclimg.lib;winhttp.lib;jcl.lib;vclie.lib;urlmon.lib;shlwapi.lib true true true @@ -42,25 +70,31 @@ false false false - OLD_DND;STRICT;$(Defines) resource\Icon256.ico true - windows\;forms\;packages\filemng;packages\tbx;packages\png;..\libs\lib;$(LIB_PATH);$(ILINK_LibraryPath) - console;windows\;forms\;core;resource;components;dragext;packages\filemng;packages\dragndrop;packages\my;packages\tb2k;packages\tbx;packages\png;$(BDS)\include\mfc;$(BDS)\include\windows;$(BDS)\include\windows\vcl;$(BDS)\include\dinkumware;$(IncludePath) - vcl.lib;rtl.lib;vclx.lib;ws2_32.lib;secur32.lib;Moje.lib;DriveDir.lib;DragDropP.lib;tb2k.lib;tbxp.lib;bcbie.lib;Crypt32.lib;PngComponents.lib;xmlrtl.lib;vclactnband.lib;vclimg.lib;winhttp.lib + windows\;forms\;packages\filemng;packages\tbx;packages\png;..\libs\lib;$(BDS)\lib\win32\release\psdk\;$(BDS)\lib\win32\release\;$(LIB_PATH);$(ILINK_LibraryPath) + DetailedSegments + console;windows\;forms\;core;resource;components;dragext;packages\filemng;packages\dragndrop;packages\my;packages\tb2k;packages\tbx;packages\png;packages\jcl;$(BDS)\include\mfc;$(BDS)\include\windows;$(BDS)\include\windows\sdk;$(BDS)\include\windows\vcl;$(IncludePath) + vcl.lib;rtl.lib;vclx.lib;ws2_32.lib;secur32.lib;Moje.lib;DriveDir.lib;DragDropP.lib;tb2k.lib;tbxp.lib;bcbie.lib;Crypt32.lib;PngComponents.lib;xmlrtl.lib;vclactnband.lib;vclimg.lib;winhttp.lib;jcl.lib;vclie.lib;urlmon.lib;shlwapi.lib windows\WinSCP.exe.manifest true exe CppVCLApplication + WinSCP true true - CompanyName=Martin Prikryl;FileDescription=WinSCP: SFTP, FTP and SCP client;FileVersion=5.5.4.0;InternalName=winscp;LegalCopyright=(c) 2000-2014 Martin Prikryl;LegalTrademarks=;OriginalFilename=winscp.exe;ProductName=WinSCP;ProductVersion=5.5.4.0;ReleaseType=stable;WWW=http://winscp.net/ + CompanyName=Martin Prikryl;FileDescription=WinSCP: SFTP, FTP and SCP client;FileVersion=5.6.0.0;InternalName=winscp;LegalCopyright=(c) 2000-2014 Martin Prikryl;LegalTrademarks=;OriginalFilename=winscp.exe;ProductName=WinSCP;ProductVersion=5.6.0.0;ReleaseType=stable;WWW=http://winscp.net/ 1033 5 - 5 - 4 + 6 + + + IDE;STRICT;$(Defines) - + + IDE;STRICT;$(Defines) + + true true false @@ -71,218 +105,217 @@ true DEBUG false - _DEBUG;$(Defines) $(FINAL_PATH)\Debug true - $(INTERM_PATH)\Debug;$(BDS)\lib\win32\debug;$(ILINK_LibraryPath) + $(INTERM_PATH)\Debug\;$(BDS)\lib\win32\debug\;$(ILINK_LibraryPath) $(INTERM_PATH)\Debug Full true - + true true true true true - packages\my; packages\filemng;..\libs\openssl\crypto\bio;..\libs\openssl\ssl;..\libs\openssl\crypto\stack;..\libs\openssl\crypto\x509;$(Debugger_DebugSourcePath) + packages\my;packages\filemng;packages\jcl;..\libs\openssl\crypto\bio;..\libs\openssl\ssl;..\libs\openssl\crypto\stack;..\libs\openssl\crypto\x509;..\libs\neon\src;$(Debugger_DebugSourcePath) + _DEBUG;$(Defines) - - NDEBUG;$(Defines) + + _DEBUG;$(Defines) + + $(FINAL_PATH)\Release $(INTERM_PATH)\Release;$(BDS)\lib\win32\release;$(ILINK_LibraryPath) $(INTERM_PATH)\Release None - + + NDEBUG;$(Defines) + + + NDEBUG;$(Defines) + + - 8 -
            CustomScpExplorerForm
            - forms\CustomScpExplorer.h - 21 -
            + 8 +
            CustomScpExplorerForm
            + forms\CustomScpExplorer.h + 21 + -
            GlyphsModule
            - TDataModule - forms\Glyphs.h - 30 -
            +
            GlyphsModule
            + TDataModule + forms\Glyphs.h + 30 + - 23 -
            NonVisualDataModule
            - TDataModule - forms\NonVisual.h - 22 -
            + 23 +
            NonVisualDataModule
            + TDataModule + forms\NonVisual.h + 22 + - 38 -
            ScpCommanderForm
            - forms\ScpCommander.h - 23 -
            + 38 +
            ScpCommanderForm
            + forms\ScpCommander.h + 23 + - 41 -
            ScpExplorerForm
            - forms\ScpExplorer.h - 24 -
            + 41 +
            ScpExplorerForm
            + forms\ScpExplorer.h + 24 + - 27 - 26 - + 27 + 26 + - 18 - 11 - + 18 + 11 + - 15 - 14 - + 15 + 14 + - 17 - 16 - + 17 + 16 + - 20 - 17 - + 20 + 17 + - 29 - 28 - + 29 + 28 + - 32 - 29 - + 32 + 29 + - 35 - 26 - + 35 + 26 + - 44 - 25 - + 44 + 25 + - 47 - 4 - + 47 + 4 + - 50 - 5 - + 50 + 5 + - 6 - 53 - - - 35 - + 6 + 53 + - 56 - 3 - + 56 + 3 + - 5 - 20 - + 5 + 20 + - 59 - 0 - + 59 + 0 + - 62 - 1 - + 62 + 1 + - 65 - 2 - + 65 + 2 + - 2 - 19 - + 2 + 19 + - - 32 - true - - 27 - true - + 27 + true + - 28 - true - + 28 + true + - 31 - true - + 31 + true + - 33 - true - + 33 + true + - 23 - true - + 23 + true + - 24 - true - + 24 + true + - 25 - true - + 25 + true + - 26 - true - + 26 + true + - 29 - true - - - 30 - true - + 29 + true + - Base - + Base + - Cfg_1 - Base - + Cfg_1 + Base + - Cfg_2 - Base - + Cfg_2 + Base +
            - - - CPlusPlusBuilder.Personality.12 - CppVCLApplication - - - - WinSCP.cpp - - - False - True - True - - - - True - - - 12 - - -
            \ No newline at end of file + + + CPlusPlusBuilder.Personality.12 + CppVCLApplication + + + + WinSCP.cpp + + + False + True + True + False + + + + True + False + + + 12 + + + \ No newline at end of file diff --git a/source/WinSCP.cpp b/source/WinSCP.cpp index 341509dc..668c5926 100644 --- a/source/WinSCP.cpp +++ b/source/WinSCP.cpp @@ -55,6 +55,7 @@ WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int) FinalizeSystemSettings(); FinalizeWinHelp(); CoreFinalize(); + WinFinalize(); } } catch (Exception &E) diff --git a/source/WinSCP.drc b/source/WinSCP.drc index 2869cc57..ce8f296b 100644 --- a/source/WinSCP.drc +++ b/source/WinSCP.drc @@ -7,458 +7,744 @@ produced executable. */ -#define Vcl_Imaging_Pnglang_EPNGCannotChangeTransparentText 65008 -#define Vcl_Imaging_Pnglang_EPNGHeaderNotPresentText 65009 -#define Vcl_Imaging_Pnglang_EInvalidNewSize 65010 -#define Vcl_Imaging_Pnglang_EInvalidSpec 65011 -#define Vcl_Imaging_Pnglang_EPNGZLIBErrorText 65024 -#define Vcl_Imaging_Pnglang_EPNGInvalidPaletteText 65025 -#define Vcl_Imaging_Pnglang_EPNGInvalidFileHeaderText 65026 -#define Vcl_Imaging_Pnglang_EPNGIHDRNotFirstText 65027 -#define Vcl_Imaging_Pnglang_EPNGSizeExceedsText 65028 -#define Vcl_Imaging_Pnglang_EPNGUnknownPalEntryText 65029 -#define Vcl_Imaging_Pnglang_EPNGUnknownCriticalChunkText 65030 -#define Vcl_Imaging_Pnglang_EPNGUnknownCompressionText 65031 -#define Vcl_Imaging_Pnglang_EPNGUnknownInterlaceText 65032 -#define Vcl_Imaging_Pnglang_EPNGCannotAssignChunkText 65033 -#define Vcl_Imaging_Pnglang_EPNGUnexpectedEndText 65034 -#define Vcl_Imaging_Pnglang_EPNGNoImageDataText 65035 -#define Vcl_Imaging_Pnglang_EPNGCannotAddChunkText 65036 -#define Vcl_Imaging_Pnglang_EPNGCannotAddInvalidImageText 65037 -#define Vcl_Imaging_Pnglang_EPNGCouldNotLoadResourceText 65038 -#define Vcl_Imaging_Pnglang_EPNGOutMemoryText 65039 -#define Xml_Xmlconst_SNotActive 65040 -#define Xml_Xmlconst_SNodeNotFound 65041 -#define Xml_Xmlconst_SMissingNode 65042 -#define Xml_Xmlconst_SNoAttributes 65043 -#define Xml_Xmlconst_SInvalidNodeType 65044 -#define Xml_Xmlconst_SMismatchedRegItems 65045 -#define Xml_Xmlconst_SNotSingleTextNode 65046 -#define Xml_Xmlconst_SNoDOMParseOptions 65047 -#define Xml_Xmlconst_SMissingItemTag 65048 -#define Xml_Xmlconst_SNodeReadOnly 65049 -#define Xml_Xmlconst_SNoRefresh 65050 -#define Xml_Xmlconst_SMissingFileName 65051 -#define Xml_Xmlconst_SLine 65052 -#define Vcl_Imaging_Pnglang_EPngInvalidCRCText 65053 -#define Vcl_Imaging_Pnglang_EPNGInvalidIHDRText 65054 -#define Vcl_Imaging_Pnglang_EPNGMissingMultipleIDATText 65055 -#define Dragdrop_MILinkStr 65056 -#define Dragdrop_MIAbortStr 65057 -#define Tb2consts_STBToolbarIndexOutOfBounds 65058 -#define Tb2consts_STBToolbarItemReinserted 65059 -#define Tb2consts_STBViewerNotFound 65060 -#define Tb2consts_STBChevronItemMoreButtonsHint 65061 -#define Tb2consts_STBDockParentNotAllowed 65062 -#define Tb2consts_STBDockCannotChangePosition 65063 -#define Tb2consts_STBToolwinNameNotSet 65064 -#define Tb2consts_STBToolwinDockedToNameNotSet 65065 -#define Xml_Xmlconst_SDuplicateRegistration 65066 -#define Xml_Xmlconst_SNoMatchingDOMVendor 65067 -#define Xml_Xmlconst_SNoDOMNodeEx 65068 -#define Xml_Xmlconst_SDOMNotSupported 65069 -#define Xml_Xmlconst_SNodeExpected 65070 -#define Xml_Xmlconst_SMSDOMNotInstalled 65071 -#define Dirviewcolproperties_SDirViewChangedCol 65072 -#define Dirviewcolproperties_SDirViewAttrCol 65073 -#define Dirviewcolproperties_SDirViewExtCol 65074 -#define Driveview_coFileOperatorTitle 65075 -#define Driveview_coInvalidDosChars 65076 -#define Driveview_Space 65077 -#define Driveview_16411 65078 -#define Fileoperator_SFileOperation 65079 -#define Iedriveinfo_ErrorInvalidDrive 65080 -#define Unixdirviewcolproperties_SUnixDirViewRightsCol 65081 -#define Unixdirviewcolproperties_SUnixDirViewOwnerCol 65082 -#define Unixdirviewcolproperties_SUnixDirViewGroupCol 65083 -#define Unixdirviewcolproperties_SUnixDirViewLinkTargetCol 65084 -#define Unixdirviewcolproperties_SUnixDirViewTypeCol 65085 -#define Dragdrop_MICopyStr 65086 -#define Dragdrop_MIMoveStr 65087 -#define Customdirview_SErrorRenameFileExists 65088 -#define Customdirview_SErrorInvalidName 65089 -#define Customdirview_STextFileExt 65090 -#define Customdirview_STextFiles 65091 -#define Customdirview_STextDirectories 65092 -#define Customdirview_SParentDir 65093 -#define Customdirview_SIconUpdateThreadTerminationError 65094 -#define Customdirview_SDragDropError 65095 -#define Customdirview_SDriveNotReady 65096 -#define Customdirview_SDirNotExists 65097 -#define Customdriveview_SDragDropError 65098 -#define Customunixdirview_SUnixDefaultRootName 65099 -#define Dirview_coFileOperatorTitle 65100 -#define Dirviewcolproperties_SDirViewNameCol 65101 -#define Dirviewcolproperties_SDirViewSizeCol 65102 -#define Dirviewcolproperties_SDirViewTypeCol 65103 -#define System_Sysconst_SByteIndexOutOfBounds 65104 -#define System_Sysconst_SInvalidCharCount 65105 -#define System_Sysconst_SInvalidDestinationIndex 65106 -#define System_Sysconst_SInvalidCodePage 65107 -#define System_Sysconst_SInvalidEncodingName 65108 -#define Comboedit_SBrowse 65109 -#define Comboedit_SDefaultFilter 65110 -#define Comboedit_SInvalidFileName 65111 -#define Tcpip_SSocketError2 65112 -#define Tcpip_STimeout 65113 -#define Tcpip_SUnknownSockError 65114 -#define Tcpip_SHttpError 65115 -#define Tcpip_SRedirectLimitError 65116 -#define Baseutils_SNoValidPath 65117 -#define Baseutils_SUcpPathsNotSupported 65118 -#define Customdirview_SErrorRenameFile 65119 -#define System_Sysconst_SShortDayNameTue 65120 -#define System_Sysconst_SShortDayNameWed 65121 -#define System_Sysconst_SShortDayNameThu 65122 -#define System_Sysconst_SShortDayNameFri 65123 -#define System_Sysconst_SShortDayNameSat 65124 -#define System_Sysconst_SLongDayNameSun 65125 -#define System_Sysconst_SLongDayNameMon 65126 -#define System_Sysconst_SLongDayNameTue 65127 -#define System_Sysconst_SLongDayNameWed 65128 -#define System_Sysconst_SLongDayNameThu 65129 -#define System_Sysconst_SLongDayNameFri 65130 -#define System_Sysconst_SLongDayNameSat 65131 -#define System_Sysconst_SCannotCreateDir 65132 -#define System_Sysconst_SInvalidSourceArray 65133 -#define System_Sysconst_SInvalidDestinationArray 65134 -#define System_Sysconst_SCharIndexOutOfBounds 65135 -#define System_Sysconst_SShortMonthNameNov 65136 -#define System_Sysconst_SShortMonthNameDec 65137 -#define System_Sysconst_SLongMonthNameJan 65138 -#define System_Sysconst_SLongMonthNameFeb 65139 -#define System_Sysconst_SLongMonthNameMar 65140 -#define System_Sysconst_SLongMonthNameApr 65141 -#define System_Sysconst_SLongMonthNameMay 65142 -#define System_Sysconst_SLongMonthNameJun 65143 -#define System_Sysconst_SLongMonthNameJul 65144 -#define System_Sysconst_SLongMonthNameAug 65145 -#define System_Sysconst_SLongMonthNameSep 65146 -#define System_Sysconst_SLongMonthNameOct 65147 -#define System_Sysconst_SLongMonthNameNov 65148 -#define System_Sysconst_SLongMonthNameDec 65149 -#define System_Sysconst_SShortDayNameSun 65150 -#define System_Sysconst_SShortDayNameMon 65151 -#define System_Sysconst_SNotImplemented 65152 -#define System_Sysconst_SAssertError 65153 -#define System_Sysconst_SAbstractError 65154 -#define System_Sysconst_SModuleAccessViolation 65155 -#define System_Sysconst_SOSError 65156 -#define System_Sysconst_SUnkOSError 65157 -#define System_Sysconst_SShortMonthNameJan 65158 -#define System_Sysconst_SShortMonthNameFeb 65159 -#define System_Sysconst_SShortMonthNameMar 65160 -#define System_Sysconst_SShortMonthNameApr 65161 -#define System_Sysconst_SShortMonthNameMay 65162 -#define System_Sysconst_SShortMonthNameJun 65163 -#define System_Sysconst_SShortMonthNameJul 65164 -#define System_Sysconst_SShortMonthNameAug 65165 -#define System_Sysconst_SShortMonthNameSep 65166 -#define System_Sysconst_SShortMonthNameOct 65167 -#define System_Sysconst_SVarTypeAlreadyUsedWithPrefix 65168 -#define System_Sysconst_SVarTypeNotUsableWithPrefix 65169 -#define System_Sysconst_SVarTypeTooManyCustom 65170 -#define System_Sysconst_SVarTypeCouldNotConvert 65171 -#define System_Sysconst_SVarTypeConvertOverflow 65172 -#define System_Sysconst_SVarOverflow 65173 -#define System_Sysconst_SVarInvalid 65174 -#define System_Sysconst_SVarBadType 65175 -#define System_Sysconst_SVarNotImplemented 65176 -#define System_Sysconst_SVarUnexpected 65177 -#define System_Sysconst_SExternalException 65178 -#define System_Sysconst_SAssertionFailed 65179 -#define System_Sysconst_SIntfCastError 65180 -#define System_Sysconst_SSafecallException 65181 -#define System_Sysconst_SMonitorLockException 65182 -#define System_Sysconst_SNoMonitorSupportException 65183 -#define System_Sysconst_SException 65184 -#define System_Sysconst_SExceptTitle 65185 -#define System_Sysconst_SInvalidFormat 65186 -#define System_Sysconst_SArgumentMissing 65187 -#define System_Sysconst_SDispatchError 65188 -#define System_Sysconst_SReadAccess 65189 -#define System_Sysconst_SWriteAccess 65190 -#define System_Sysconst_SFormatTooLong 65191 -#define System_Sysconst_SVarArrayCreate 65192 -#define System_Sysconst_SVarArrayBounds 65193 -#define System_Sysconst_SVarArrayLocked 65194 -#define System_Sysconst_SInvalidVarCast 65195 -#define System_Sysconst_SInvalidVarOp 65196 -#define System_Sysconst_SInvalidVarNullOp 65197 -#define System_Sysconst_SInvalidVarOpWithHResultWithPrefix 65198 -#define System_Sysconst_SVarTypeOutOfRangeWithPrefix 65199 -#define System_Sysconst_SInvalidInput 65200 -#define System_Sysconst_SDivByZero 65201 -#define System_Sysconst_SRangeError 65202 -#define System_Sysconst_SIntOverflow 65203 -#define System_Sysconst_SInvalidOp 65204 -#define System_Sysconst_SZeroDivide 65205 -#define System_Sysconst_SOverflow 65206 -#define System_Sysconst_SUnderflow 65207 -#define System_Sysconst_SInvalidPointer 65208 -#define System_Sysconst_SInvalidCast 65209 -#define System_Sysconst_SAccessViolationArg3 65210 -#define System_Sysconst_SAccessViolationNoArg 65211 -#define System_Sysconst_SStackOverflow 65212 -#define System_Sysconst_SControlC 65213 -#define System_Sysconst_SPrivilege 65214 -#define System_Sysconst_SOperationAborted 65215 -#define System_Rtlconsts_sObserverMultipleSingleCast 65216 -#define System_Rtlconsts_sObserverNoInterface 65217 -#define System_Rtlconsts_sObserverNoSinglecastFound 65218 -#define System_Rtlconsts_sObserverNoMulticastFound 65219 -#define System_Rtlconsts_sObserverNotAvailable 65220 -#define System_Sysconst_SUnknown 65221 -#define System_Sysconst_SInvalidFloat 65222 -#define System_Sysconst_SInvalidTimeStamp 65223 -#define System_Sysconst_SInvalidGUID 65224 -#define System_Sysconst_SDateEncodeError 65225 -#define System_Sysconst_SOutOfMemory 65226 -#define System_Sysconst_SInOutError 65227 -#define System_Sysconst_STooManyOpenFiles 65228 -#define System_Sysconst_SAccessDenied 65229 -#define System_Sysconst_SEndOfFile 65230 -#define System_Sysconst_SDiskFull 65231 -#define System_Rtlconsts_SGenericDuplicateItem 65232 -#define System_Rtlconsts_SServiceNotFound 65233 -#define System_Rtlconsts_SVersionStr 65234 -#define System_Rtlconsts_SSPVersionStr 65235 -#define System_Rtlconsts_SVersion32 65236 -#define System_Rtlconsts_SVersion64 65237 -#define System_Rtlconsts_SWindows 65238 -#define System_Rtlconsts_SWindowsVista 65239 -#define System_Rtlconsts_SWindowsServer2008 65240 -#define System_Rtlconsts_SWindows7 65241 -#define System_Rtlconsts_SWindowsServer2008R2 65242 -#define System_Rtlconsts_SWindows2000 65243 -#define System_Rtlconsts_SWindowsXP 65244 -#define System_Rtlconsts_SWindowsServer2003 65245 -#define System_Rtlconsts_SWindowsServer2003R2 65246 -#define System_Rtlconsts_sObserverUnsupported 65247 -#define System_Rtlconsts_sInvalidTimespanFormat 65248 -#define System_Rtlconsts_sTimespanElementTooLong 65249 -#define System_Rtlconsts_SInvalidDate 65250 -#define System_Rtlconsts_SInvalidDateTime 65251 -#define System_Rtlconsts_SInvalidInteger 65252 -#define System_Rtlconsts_SInvalidTime 65253 -#define System_Rtlconsts_STimeEncodeError 65254 -#define System_Rtlconsts_SNoContext 65255 -#define System_Rtlconsts_SNoContextFound 65256 -#define System_Rtlconsts_SNoIndex 65257 -#define System_Rtlconsts_SNoSearch 65258 -#define System_Rtlconsts_SNoTableOfContents 65259 -#define System_Rtlconsts_SNoTopics 65260 -#define System_Rtlconsts_SNothingFound 65261 -#define System_Rtlconsts_SArgumentOutOfRange 65262 -#define System_Rtlconsts_SGenericItemNotFound 65263 -#define System_Rtlconsts_SPathNotFound 65264 -#define System_Rtlconsts_SPathFormatNotSupported 65265 -#define System_Rtlconsts_SDriveNotFound 65266 -#define System_Rtlconsts_SFileNotFound 65267 -#define System_Rtlconsts_SLocalTimeInvalid 65268 -#define System_Rtlconsts_hNoFilterViewer 65269 -#define System_Rtlconsts_sArgumentOutOfRange_StringIndex 65270 -#define System_Rtlconsts_sArgumentOutOfRange_InvalidUTF32 65271 -#define System_Rtlconsts_sArgument_InvalidHighSurrogate 65272 -#define System_Rtlconsts_sArgument_InvalidLowSurrogate 65273 -#define System_Rtlconsts_sInvalidStringAndObjectArrays 65274 -#define System_Rtlconsts_sInvalidTimeoutValue 65275 -#define System_Rtlconsts_sTimespanTooLong 65276 -#define System_Rtlconsts_sInvalidTimespanDuration 65277 -#define System_Rtlconsts_sTimespanValueCannotBeNan 65278 -#define System_Rtlconsts_sCannotNegateTimespan 65279 -#define System_Rtlconsts_SStringExpected 65280 -#define System_Rtlconsts_SSymbolExpected 65281 -#define System_Rtlconsts_SUnknownGroup 65282 -#define System_Rtlconsts_SUnknownProperty 65283 -#define System_Rtlconsts_SWriteError 65284 -#define System_Rtlconsts_SThreadCreateError 65285 -#define System_Rtlconsts_SThreadError 65286 -#define System_Rtlconsts_SThreadExternalTerminate 65287 -#define System_Rtlconsts_SThreadExternalWait 65288 -#define System_Rtlconsts_SThreadStartError 65289 -#define System_Rtlconsts_SThreadExternalCheckTerminated 65290 -#define System_Rtlconsts_SThreadExternalSetReturnValue 65291 -#define System_Rtlconsts_SParamIsNegative 65292 -#define System_Rtlconsts_SInputBufferExceed 65293 -#define System_Rtlconsts_SInvalidCharsInPath 65294 -#define System_Rtlconsts_SPathTooLong 65295 -#define System_Rtlconsts_SListIndexError 65296 -#define System_Rtlconsts_SMemoryStreamError 65297 -#define System_Rtlconsts_SNoComSupport 65298 -#define System_Rtlconsts_SNumberExpected 65299 -#define System_Rtlconsts_SAnsiUTF8Expected 65300 -#define System_Rtlconsts_SParseError 65301 -#define System_Rtlconsts_SPropertyException 65302 -#define System_Rtlconsts_SReadError 65303 -#define System_Rtlconsts_SReadOnlyProperty 65304 -#define System_Rtlconsts_SRegCreateFailed 65305 -#define System_Rtlconsts_SRegGetDataFailed 65306 -#define System_Rtlconsts_SRegisterError 65307 -#define System_Rtlconsts_SRegSetDataFailed 65308 -#define System_Rtlconsts_SResNotFound 65309 -#define System_Rtlconsts_SSeekNotImplemented 65310 -#define System_Rtlconsts_SSortedListError 65311 -#define System_Rtlconsts_SFOpenErrorEx 65312 -#define System_Rtlconsts_SIdentifierExpected 65313 -#define System_Rtlconsts_SIniFileWriteError 65314 -#define System_Rtlconsts_SInvalidBinary 65315 -#define System_Rtlconsts_SInvalidFileName 65316 -#define System_Rtlconsts_SInvalidImage 65317 -#define System_Rtlconsts_SInvalidMask 65318 -#define System_Rtlconsts_SInvalidName 65319 -#define System_Rtlconsts_SInvalidProperty 65320 -#define System_Rtlconsts_SInvalidPropertyPath 65321 -#define System_Rtlconsts_SInvalidPropertyValue 65322 -#define System_Rtlconsts_SInvalidRegType 65323 -#define System_Rtlconsts_SInvalidString 65324 -#define System_Rtlconsts_SLineTooLong 65325 -#define System_Rtlconsts_SListCapacityError 65326 -#define System_Rtlconsts_SListCountError 65327 -#define System_Win_Comconst_SOleError 65328 -#define System_Win_Comconst_SNoMethod 65329 -#define System_Win_Comconst_SVarNotObject 65330 -#define System_Win_Comconst_STooManyParams 65331 -#define System_Rtlconsts_SAncestorNotFound 65332 -#define System_Rtlconsts_SAssignError 65333 -#define System_Rtlconsts_SBitsIndexError 65334 -#define System_Rtlconsts_SCantWriteResourceStreamError 65335 -#define System_Rtlconsts_SCharExpected 65336 -#define System_Rtlconsts_SCheckSynchronizeError 65337 -#define System_Rtlconsts_SClassNotFound 65338 -#define System_Rtlconsts_SDuplicateClass 65339 -#define System_Rtlconsts_SDuplicateItem 65340 -#define System_Rtlconsts_SDuplicateName 65341 -#define System_Rtlconsts_SDuplicateString 65342 -#define System_Rtlconsts_SFCreateErrorEx 65343 -#define Vcl_Comstrs_sInvalidIndex 65344 -#define Vcl_Comstrs_sInsertError 65345 -#define Vcl_Comstrs_sInvalidOwner 65346 -#define Vcl_Comstrs_sRichEditInsertError 65347 -#define Vcl_Comstrs_sRichEditLoadFail 65348 -#define Vcl_Comstrs_sRichEditSaveFail 65349 -#define Vcl_Comstrs_sUDAssociated 65350 -#define Vcl_Comstrs_sPageIndexError 65351 -#define Vcl_Comstrs_sInvalidComCtl32 65352 -#define Vcl_Comstrs_sDateTimeMax 65353 -#define Vcl_Comstrs_sDateTimeMin 65354 -#define Vcl_Comstrs_sNeedAllowNone 65355 -#define Vcl_Comstrs_sFailSetCalDateTime 65356 -#define Vcl_Comstrs_sFailSetCalMaxSelRange 65357 -#define Vcl_Comstrs_sFailSetCalMinMaxRange 65358 -#define Vcl_Comstrs_sFailsetCalSelRange 65359 -#define Vcl_Consts_SStyleInvalidHandle 65360 -#define Vcl_Consts_SStyleFormatError 65361 -#define Vcl_Consts_SStyleFileDescription 65362 -#define Vcl_Consts_SStyleHookClassNotRegistered 65363 -#define Vcl_Consts_SStyleInvalidParameter 65364 -#define Vcl_Consts_SStyleHookClassNotFound 65365 -#define Vcl_Consts_SStyleFeatureNotSupported 65366 -#define Vcl_Comstrs_sTabFailClear 65367 -#define Vcl_Comstrs_sTabFailDelete 65368 -#define Vcl_Comstrs_sTabFailRetrieve 65369 -#define Vcl_Comstrs_sTabFailGetObject 65370 -#define Vcl_Comstrs_sTabFailSet 65371 -#define Vcl_Comstrs_sTabFailSetObject 65372 -#define Vcl_Comstrs_sTabMustBeMultiLine 65373 -#define Vcl_Comstrs_sInvalidLevel 65374 -#define Vcl_Comstrs_sInvalidLevelEx 65375 -#define Vcl_Consts_SUTF7Encoding 65376 -#define Vcl_Consts_STrayIconRemoveError 65377 -#define Vcl_Consts_SPageControlNotSet 65378 -#define Vcl_Consts_SWindowsVistaRequired 65379 -#define Vcl_Consts_STaskDlgButtonCaption 65380 -#define Vcl_Consts_STaskDlgRadioButtonCaption 65381 -#define Vcl_Consts_SInvalidTaskDlgButtonCaption 65382 -#define Vcl_Consts_SInvalidCategoryPanelParent 65383 -#define Vcl_Consts_SInvalidCategoryPanelGroupChild 65384 -#define Vcl_Consts_SNoKeyword 65385 -#define Vcl_Consts_SStyleLoadError 65386 -#define Vcl_Consts_SStyleLoadErrors 65387 -#define Vcl_Consts_SStyleRegisterError 65388 -#define Vcl_Consts_SStyleClassRegisterError 65389 -#define Vcl_Consts_SStyleNotFound 65390 -#define Vcl_Consts_SStyleClassNotFound 65391 -#define Vcl_Consts_SPromptArrayTooShort 65392 -#define Vcl_Consts_SPromptArrayEmpty 65393 -#define Vcl_Consts_SUsername 65394 -#define Vcl_Consts_SPassword 65395 -#define Vcl_Consts_SDomain 65396 -#define Vcl_Consts_SLogin 65397 -#define Vcl_Consts_SSeparator 65398 -#define Vcl_Consts_SErrorSettingCount 65399 -#define Vcl_Consts_SListBoxMustBeVirtual 65400 -#define Vcl_Consts_SNoGetItemEventHandler 65401 -#define Vcl_Consts_SInvalidPath 65402 -#define Vcl_Consts_SANSIEncoding 65403 -#define Vcl_Consts_SASCIIEncoding 65404 -#define Vcl_Consts_SUnicodeEncoding 65405 -#define Vcl_Consts_SBigEndianEncoding 65406 -#define Vcl_Consts_SUTF8Encoding 65407 -#define Vcl_Consts_SIconToClipboard 65408 -#define Vcl_Consts_SCannotOpenClipboard 65409 -#define Vcl_Consts_SInvalidMemoSize 65410 -#define Vcl_Consts_SInvalidPrinterOp 65411 -#define Vcl_Consts_SNoDefaultPrinter 65412 -#define Vcl_Consts_SDuplicateMenus 65413 -#define Vcl_Consts_SPictureLabel 65414 -#define Vcl_Consts_SPictureDesc 65415 -#define Vcl_Consts_SPreviewLabel 65416 -#define Vcl_Consts_SCannotOpenAVI 65417 -#define Vcl_Consts_SDockedCtlNeedsName 65418 -#define Vcl_Consts_SDockTreeRemoveError 65419 -#define Vcl_Consts_SDockZoneNotFound 65420 -#define Vcl_Consts_SDockZoneHasNoCtl 65421 -#define Vcl_Consts_SDockZoneVersionConflict 65422 -#define Vcl_Consts_SMultiSelectRequired 65423 -#define Vcl_Consts_SmkcEnd 65424 -#define Vcl_Consts_SmkcHome 65425 -#define Vcl_Consts_SmkcLeft 65426 -#define Vcl_Consts_SmkcUp 65427 -#define Vcl_Consts_SmkcRight 65428 -#define Vcl_Consts_SmkcDown 65429 -#define Vcl_Consts_SmkcIns 65430 -#define Vcl_Consts_SmkcDel 65431 -#define Vcl_Consts_SmkcShift 65432 -#define Vcl_Consts_SmkcCtrl 65433 -#define Vcl_Consts_SmkcAlt 65434 -#define Vcl_Consts_srNone 65435 -#define Vcl_Consts_SOutOfRange 65436 -#define Vcl_Consts_sAllFilter 65437 -#define Vcl_Consts_SInsertLineError 65438 -#define Vcl_Consts_SInvalidClipFmt 65439 -#define Vcl_Consts_SMsgDlgCancel 65440 -#define Vcl_Consts_SMsgDlgHelp 65441 -#define Vcl_Consts_SMsgDlgAbort 65442 -#define Vcl_Consts_SMsgDlgRetry 65443 -#define Vcl_Consts_SMsgDlgIgnore 65444 -#define Vcl_Consts_SMsgDlgAll 65445 -#define Vcl_Consts_SMsgDlgNoToAll 65446 -#define Vcl_Consts_SMsgDlgYesToAll 65447 -#define Vcl_Consts_SMsgDlgClose 65448 -#define Vcl_Consts_SmkcBkSp 65449 -#define Vcl_Consts_SmkcTab 65450 -#define Vcl_Consts_SmkcEsc 65451 -#define Vcl_Consts_SmkcEnter 65452 -#define Vcl_Consts_SmkcSpace 65453 -#define Vcl_Consts_SmkcPgUp 65454 -#define Vcl_Consts_SmkcPgDn 65455 -#define Vcl_Consts_SVTIFFImages 65456 -#define Vcl_Consts_SGridTooLarge 65457 -#define Vcl_Consts_STooManyDeleted 65458 -#define Vcl_Consts_SIndexOutOfRange 65459 -#define Vcl_Consts_SFixedColTooBig 65460 -#define Vcl_Consts_SFixedRowTooBig 65461 -#define Vcl_Consts_SInvalidStringGridOp 65462 -#define Vcl_Consts_SMaskErr 65463 -#define Vcl_Consts_SMaskEditErr 65464 -#define Vcl_Consts_SMsgDlgWarning 65465 -#define Vcl_Consts_SMsgDlgError 65466 -#define Vcl_Consts_SMsgDlgInformation 65467 -#define Vcl_Consts_SMsgDlgConfirm 65468 -#define Vcl_Consts_SMsgDlgYes 65469 -#define Vcl_Consts_SMsgDlgNo 65470 -#define Vcl_Consts_SMsgDlgOK 65471 +#define Ieconst_sChildWindowsAlreadyHooked 64720 +#define Ieconst_sSaveCurrentFile 64721 +#define Jclresources_RsIntelCacheDescrE4 64736 +#define Jclresources_RsIntelCacheDescrEA 64737 +#define Jclresources_RsIntelCacheDescrEB 64738 +#define Jclresources_RsIntelCacheDescrEC 64739 +#define Jclresources_RsIntelCacheDescrF0 64740 +#define Jclresources_RsIntelCacheDescrF1 64741 +#define Jclresources_RsIntelCacheDescrFF 64742 +#define Jclresources_RsOSVersionWin81 64743 +#define Jclresources_RsOSVersionWinServer2012R2 64744 +#define Jclresources_RsWin32Error 64745 +#define Jclresources_RsELibraryNotFound 64746 +#define Jclresources_RsEFunctionNotFound 64747 +#define Ieconst_sNoPageLoaded 64748 +#define Ieconst_sNilProvider 64749 +#define Ieconst_sInvalidServiceProviderGUID 64750 +#define Ieconst_sClassSinkingError 64751 +#define Jclresources_RsIntelCacheDescrB3 64752 +#define Jclresources_RsIntelCacheDescrB4 64753 +#define Jclresources_RsIntelCacheDescrBA 64754 +#define Jclresources_RsIntelCacheDescrC0 64755 +#define Jclresources_RsIntelCacheDescrCA 64756 +#define Jclresources_RsIntelCacheDescrD0 64757 +#define Jclresources_RsIntelCacheDescrD1 64758 +#define Jclresources_RsIntelCacheDescrD2 64759 +#define Jclresources_RsIntelCacheDescrD6 64760 +#define Jclresources_RsIntelCacheDescrD7 64761 +#define Jclresources_RsIntelCacheDescrD8 64762 +#define Jclresources_RsIntelCacheDescrDC 64763 +#define Jclresources_RsIntelCacheDescrDD 64764 +#define Jclresources_RsIntelCacheDescrDE 64765 +#define Jclresources_RsIntelCacheDescrE2 64766 +#define Jclresources_RsIntelCacheDescrE3 64767 +#define Jclresources_RsIntelCacheDescr79 64768 +#define Jclresources_RsIntelCacheDescr7A 64769 +#define Jclresources_RsIntelCacheDescr7B 64770 +#define Jclresources_RsIntelCacheDescr7C 64771 +#define Jclresources_RsIntelCacheDescr7D 64772 +#define Jclresources_RsIntelCacheDescr7F 64773 +#define Jclresources_RsIntelCacheDescr80 64774 +#define Jclresources_RsIntelCacheDescr82 64775 +#define Jclresources_RsIntelCacheDescr83 64776 +#define Jclresources_RsIntelCacheDescr84 64777 +#define Jclresources_RsIntelCacheDescr85 64778 +#define Jclresources_RsIntelCacheDescr86 64779 +#define Jclresources_RsIntelCacheDescr87 64780 +#define Jclresources_RsIntelCacheDescrB0 64781 +#define Jclresources_RsIntelCacheDescrB1 64782 +#define Jclresources_RsIntelCacheDescrB2 64783 +#define Jclresources_RsIntelCacheDescr57 64784 +#define Jclresources_RsIntelCacheDescr59 64785 +#define Jclresources_RsIntelCacheDescr5A 64786 +#define Jclresources_RsIntelCacheDescr5B 64787 +#define Jclresources_RsIntelCacheDescr5C 64788 +#define Jclresources_RsIntelCacheDescr5D 64789 +#define Jclresources_RsIntelCacheDescr60 64790 +#define Jclresources_RsIntelCacheDescr66 64791 +#define Jclresources_RsIntelCacheDescr67 64792 +#define Jclresources_RsIntelCacheDescr68 64793 +#define Jclresources_RsIntelCacheDescr70 64794 +#define Jclresources_RsIntelCacheDescr71 64795 +#define Jclresources_RsIntelCacheDescr72 64796 +#define Jclresources_RsIntelCacheDescr73 64797 +#define Jclresources_RsIntelCacheDescr76 64798 +#define Jclresources_RsIntelCacheDescr78 64799 +#define Jclresources_RsIntelCacheDescr45 64800 +#define Jclresources_RsIntelCacheDescr46 64801 +#define Jclresources_RsIntelCacheDescr47 64802 +#define Jclresources_RsIntelCacheDescr48 64803 +#define Jclresources_RsIntelCacheDescr49 64804 +#define Jclresources_RsIntelCacheDescr4A 64805 +#define Jclresources_RsIntelCacheDescr4B 64806 +#define Jclresources_RsIntelCacheDescr4C 64807 +#define Jclresources_RsIntelCacheDescr4D 64808 +#define Jclresources_RsIntelCacheDescr4E 64809 +#define Jclresources_RsIntelCacheDescr4F 64810 +#define Jclresources_RsIntelCacheDescr50 64811 +#define Jclresources_RsIntelCacheDescr51 64812 +#define Jclresources_RsIntelCacheDescr52 64813 +#define Jclresources_RsIntelCacheDescr55 64814 +#define Jclresources_RsIntelCacheDescr56 64815 +#define Jclresources_RsIntelCacheDescr23 64816 +#define Jclresources_RsIntelCacheDescr25 64817 +#define Jclresources_RsIntelCacheDescr29 64818 +#define Jclresources_RsIntelCacheDescr2C 64819 +#define Jclresources_RsIntelCacheDescr30 64820 +#define Jclresources_RsIntelCacheDescr39 64821 +#define Jclresources_RsIntelCacheDescr3A 64822 +#define Jclresources_RsIntelCacheDescr3B 64823 +#define Jclresources_RsIntelCacheDescr3C 64824 +#define Jclresources_RsIntelCacheDescr3D 64825 +#define Jclresources_RsIntelCacheDescr3E 64826 +#define Jclresources_RsIntelCacheDescr40 64827 +#define Jclresources_RsIntelCacheDescr41 64828 +#define Jclresources_RsIntelCacheDescr42 64829 +#define Jclresources_RsIntelCacheDescr43 64830 +#define Jclresources_RsIntelCacheDescr44 64831 +#define Jclresources_RsIntelCacheDescr00 64832 +#define Jclresources_RsIntelCacheDescr01 64833 +#define Jclresources_RsIntelCacheDescr02 64834 +#define Jclresources_RsIntelCacheDescr03 64835 +#define Jclresources_RsIntelCacheDescr04 64836 +#define Jclresources_RsIntelCacheDescr05 64837 +#define Jclresources_RsIntelCacheDescr06 64838 +#define Jclresources_RsIntelCacheDescr08 64839 +#define Jclresources_RsIntelCacheDescr09 64840 +#define Jclresources_RsIntelCacheDescr0A 64841 +#define Jclresources_RsIntelCacheDescr0B 64842 +#define Jclresources_RsIntelCacheDescr0C 64843 +#define Jclresources_RsIntelCacheDescr0D 64844 +#define Jclresources_RsIntelCacheDescr0E 64845 +#define Jclresources_RsIntelCacheDescr21 64846 +#define Jclresources_RsIntelCacheDescr22 64847 +#define Jclresources_RsPeDEBUG_OMAP_FROM_SRC 64848 +#define Jclresources_RsPePkgExecutable 64849 +#define Jclresources_RsPePkgPackage 64850 +#define Jclresources_PsPePkgLibrary 64851 +#define Jclresources_RsPePkgNeverBuild 64852 +#define Jclresources_RsPePkgDesignOnly 64853 +#define Jclresources_RsPePkgRunOnly 64854 +#define Jclresources_RsPePkgIgnoreDupUnits 64855 +#define Jclresources_RsPePkgV3Produced 64856 +#define Jclresources_RsPePkgProducerUndefined 64857 +#define Jclresources_RsPePkgBCB4Produced 64858 +#define Jclresources_RsPePkgDelphi4Produced 64859 +#define Jclresources_RsPePkgMain 64860 +#define Jclresources_RsPePkgWeak 64861 +#define Jclresources_RsPePkgOrgWeak 64862 +#define Jclresources_RsPePkgImplicit 64863 +#define Jclresources_RsPeMACHINE_CEE 64864 +#define Jclresources_RsPeSUBSYSTEM_UNKNOWN 64865 +#define Jclresources_RsPeSUBSYSTEM_NATIVE 64866 +#define Jclresources_RsPeSUBSYSTEM_WINDOWS_GUI 64867 +#define Jclresources_RsPeSUBSYSTEM_WINDOWS_CUI 64868 +#define Jclresources_RsPeSUBSYSTEM_OS2_CUI 64869 +#define Jclresources_RsPeSUBSYSTEM_POSIX_CUI 64870 +#define Jclresources_RsPeSUBSYSTEM_RESERVED8 64871 +#define Jclresources_RsPeDEBUG_UNKNOWN 64872 +#define Jclresources_RsPeDEBUG_COFF 64873 +#define Jclresources_RsPeDEBUG_CODEVIEW 64874 +#define Jclresources_RsPeDEBUG_FPO 64875 +#define Jclresources_RsPeDEBUG_MISC 64876 +#define Jclresources_RsPeDEBUG_EXCEPTION 64877 +#define Jclresources_RsPeDEBUG_FIXUP 64878 +#define Jclresources_RsPeDEBUG_OMAP_TO_SRC 64879 +#define Jclresources_RsPeMACHINE_SH5 64880 +#define Jclresources_RsPeMACHINE_ARM 64881 +#define Jclresources_RsPeMACHINE_THUMB 64882 +#define Jclresources_RsPeMACHINE_AM33 64883 +#define Jclresources_RsPeMACHINE_POWERPC 64884 +#define Jclresources_RsPeMACHINE_POWERPCFP 64885 +#define Jclresources_RsPeMACHINE_IA64 64886 +#define Jclresources_RsPeMACHINE_MIPS16 64887 +#define Jclresources_RsPeMACHINE_AMPHA64 64888 +#define Jclresources_RsPeMACHINE_MIPSFPU 64889 +#define Jclresources_RsPeMACHINE_MIPSFPU16 64890 +#define Jclresources_RsPeMACHINE_TRICORE 64891 +#define Jclresources_RsPeMACHINE_CEF 64892 +#define Jclresources_RsPeMACHINE_EBC 64893 +#define Jclresources_RsPeMACHINE_AMD64 64894 +#define Jclresources_RsPeMACHINE_M32R 64895 +#define Jclresources_RsPeProcessHeapFlags 64896 +#define Jclresources_RsPeProcessAffinityMask 64897 +#define Jclresources_RsPeCSDVersion 64898 +#define Jclresources_RsPeReserved 64899 +#define Jclresources_RsPeEditList 64900 +#define Jclresources_RsPeMACHINE_UNKNOWN 64901 +#define Jclresources_RsPeMACHINE_I386 64902 +#define Jclresources_RsPeMACHINE_R3000 64903 +#define Jclresources_RsPeMACHINE_R4000 64904 +#define Jclresources_RsPeMACHINE_R10000 64905 +#define Jclresources_RsPeMACHINE_WCEMIPSV2 64906 +#define Jclresources_RsPeMACHINE_ALPHA 64907 +#define Jclresources_RsPeMACHINE_SH3 64908 +#define Jclresources_RsPeMACHINE_SH3DSP 64909 +#define Jclresources_RsPeMACHINE_SH3E 64910 +#define Jclresources_RsPeMACHINE_SH4 64911 +#define Jclresources_RsPeDllCharacteristics 64912 +#define Jclresources_RsPeSizeOfStackReserve 64913 +#define Jclresources_RsPeSizeOfStackCommit 64914 +#define Jclresources_RsPeSizeOfHeapReserve 64915 +#define Jclresources_RsPeSizeOfHeapCommit 64916 +#define Jclresources_RsPeLoaderFlags 64917 +#define Jclresources_RsPeNumberOfRvaAndSizes 64918 +#define Jclresources_RsPeVersion 64919 +#define Jclresources_RsPeGlobalFlagsClear 64920 +#define Jclresources_RsPeGlobalFlagsSet 64921 +#define Jclresources_RsPeCriticalSectionDefaultTimeout 64922 +#define Jclresources_RsPeDeCommitFreeBlockThreshold 64923 +#define Jclresources_RsPeDeCommitTotalFreeThreshold 64924 +#define Jclresources_RsPeLockPrefixTable 64925 +#define Jclresources_RsPeMaximumAllocationSize 64926 +#define Jclresources_RsPeVirtualMemoryThreshold 64927 +#define Jclresources_RsPeSizeOfInitializedData 64928 +#define Jclresources_RsPeSizeOfUninitializedData 64929 +#define Jclresources_RsPeAddressOfEntryPoint 64930 +#define Jclresources_RsPeBaseOfCode 64931 +#define Jclresources_RsPeBaseOfData 64932 +#define Jclresources_RsPeImageBase 64933 +#define Jclresources_RsPeSectionAlignment 64934 +#define Jclresources_RsPeFileAlignment 64935 +#define Jclresources_RsPeOperatingSystemVersion 64936 +#define Jclresources_RsPeImageVersion 64937 +#define Jclresources_RsPeSubsystemVersion 64938 +#define Jclresources_RsPeWin32VersionValue 64939 +#define Jclresources_RsPeSizeOfImage 64940 +#define Jclresources_RsPeSizeOfHeaders 64941 +#define Jclresources_RsPeCheckSum 64942 +#define Jclresources_RsPeSubsystem 64943 +#define Jclresources_RsPeImg_11 64944 +#define Jclresources_RsPeImg_12 64945 +#define Jclresources_RsPeImg_13 64946 +#define Jclresources_RsPeImg_14 64947 +#define Jclresources_RsPeImg_Reserved 64948 +#define Jclresources_RsPeSignature 64949 +#define Jclresources_RsPeMachine 64950 +#define Jclresources_RsPeNumberOfSections 64951 +#define Jclresources_RsPeTimeDateStamp 64952 +#define Jclresources_RsPePointerToSymbolTable 64953 +#define Jclresources_RsPeNumberOfSymbols 64954 +#define Jclresources_RsPeSizeOfOptionalHeader 64955 +#define Jclresources_RsPeCharacteristics 64956 +#define Jclresources_RsPeMagic 64957 +#define Jclresources_RsPeLinkerVersion 64958 +#define Jclresources_RsPeSizeOfCode 64959 +#define Jclresources_RsPeNotPE 64960 +#define Jclresources_RsPeUnknownTarget 64961 +#define Jclresources_RsPeNotResDir 64962 +#define Jclresources_RsPeNotAvailableForAttached 64963 +#define Jclresources_RsPeSectionNotFound 64964 +#define Jclresources_RsPeImg_00 64965 +#define Jclresources_RsPeImg_01 64966 +#define Jclresources_RsPeImg_02 64967 +#define Jclresources_RsPeImg_03 64968 +#define Jclresources_RsPeImg_04 64969 +#define Jclresources_RsPeImg_05 64970 +#define Jclresources_RsPeImg_06 64971 +#define Jclresources_RsPeImg_07 64972 +#define Jclresources_RsPeImg_08 64973 +#define Jclresources_RsPeImg_09 64974 +#define Jclresources_RsPeImg_10 64975 +#define Vcl_Imaging_Pnglang_EInvalidSpec 64976 +#define Jclresources_RsEReplacementChar 64977 +#define Jclresources_RsEWindowsVersionNotSupported 64978 +#define Jclresources_RsEWindowNotValid 64979 +#define Jclresources_RsEProcessNotValid 64980 +#define Jclresources_RsEModuleNotValid 64981 +#define Jclresources_RsFileUtilsNoVersionInfo 64982 +#define Jclresources_RsFileUtilsFileDoesNotExist 64983 +#define Jclresources_RsFileUtilsLanguageIndex 64984 +#define Jclresources_RsFileUtilsEmptyValue 64985 +#define Jclresources_RsFileUtilsValueNotFound 64986 +#define Jclresources_RsCreateFileMapping 64987 +#define Jclresources_RsCreateFileMappingView 64988 +#define Jclresources_RsFailedToObtainSize 64989 +#define Jclresources_RsPeReadOnlyStream 64990 +#define Jclresources_RsPeCantOpen 64991 +#define Vcl_Imaging_Pnglang_EPNGIHDRNotFirstText 64992 +#define Vcl_Imaging_Pnglang_EPNGSizeExceedsText 64993 +#define Vcl_Imaging_Pnglang_EPNGUnknownPalEntryText 64994 +#define Vcl_Imaging_Pnglang_EPNGUnknownCriticalChunkText 64995 +#define Vcl_Imaging_Pnglang_EPNGUnknownCompressionText 64996 +#define Vcl_Imaging_Pnglang_EPNGUnknownInterlaceText 64997 +#define Vcl_Imaging_Pnglang_EPNGCannotAssignChunkText 64998 +#define Vcl_Imaging_Pnglang_EPNGUnexpectedEndText 64999 +#define Vcl_Imaging_Pnglang_EPNGNoImageDataText 65000 +#define Vcl_Imaging_Pnglang_EPNGCannotAddChunkText 65001 +#define Vcl_Imaging_Pnglang_EPNGCannotAddInvalidImageText 65002 +#define Vcl_Imaging_Pnglang_EPNGCouldNotLoadResourceText 65003 +#define Vcl_Imaging_Pnglang_EPNGOutMemoryText 65004 +#define Vcl_Imaging_Pnglang_EPNGCannotChangeTransparentText 65005 +#define Vcl_Imaging_Pnglang_EPNGHeaderNotPresentText 65006 +#define Vcl_Imaging_Pnglang_EInvalidNewSize 65007 +#define Xml_Xmlconst_SNoAttributes 65008 +#define Xml_Xmlconst_SInvalidNodeType 65009 +#define Xml_Xmlconst_SMismatchedRegItems 65010 +#define Xml_Xmlconst_SNotSingleTextNode 65011 +#define Xml_Xmlconst_SNoDOMParseOptions 65012 +#define Xml_Xmlconst_SMissingItemTag 65013 +#define Xml_Xmlconst_SNodeReadOnly 65014 +#define Xml_Xmlconst_SNoRefresh 65015 +#define Xml_Xmlconst_SMissingFileName 65016 +#define Xml_Xmlconst_SLine 65017 +#define Vcl_Imaging_Pnglang_EPngInvalidCRCText 65018 +#define Vcl_Imaging_Pnglang_EPNGInvalidIHDRText 65019 +#define Vcl_Imaging_Pnglang_EPNGMissingMultipleIDATText 65020 +#define Vcl_Imaging_Pnglang_EPNGZLIBErrorText 65021 +#define Vcl_Imaging_Pnglang_EPNGInvalidPaletteText 65022 +#define Vcl_Imaging_Pnglang_EPNGInvalidFileHeaderText 65023 +#define Tb2consts_STBToolbarItemReinserted 65024 +#define Tb2consts_STBViewerNotFound 65025 +#define Tb2consts_STBChevronItemMoreButtonsHint 65026 +#define Tb2consts_STBDockParentNotAllowed 65027 +#define Tb2consts_STBDockCannotChangePosition 65028 +#define Tb2consts_STBToolwinNameNotSet 65029 +#define Tb2consts_STBToolwinDockedToNameNotSet 65030 +#define Xml_Xmlconst_SDuplicateRegistration 65031 +#define Xml_Xmlconst_SNoMatchingDOMVendor 65032 +#define Xml_Xmlconst_SNoDOMNodeEx 65033 +#define Xml_Xmlconst_SDOMNotSupported 65034 +#define Xml_Xmlconst_SNodeExpected 65035 +#define Xml_Xmlconst_SMSDOMNotInstalled 65036 +#define Xml_Xmlconst_SNotActive 65037 +#define Xml_Xmlconst_SNodeNotFound 65038 +#define Xml_Xmlconst_SMissingNode 65039 +#define Driveview_coFileOperatorTitle 65040 +#define Driveview_coInvalidDosChars 65041 +#define Driveview_Space 65042 +#define Driveview_16405 65043 +#define Fileoperator_SFileOperation 65044 +#define Iedriveinfo_ErrorInvalidDrive 65045 +#define Unixdirviewcolproperties_SUnixDirViewRightsCol 65046 +#define Unixdirviewcolproperties_SUnixDirViewOwnerCol 65047 +#define Unixdirviewcolproperties_SUnixDirViewGroupCol 65048 +#define Unixdirviewcolproperties_SUnixDirViewLinkTargetCol 65049 +#define Unixdirviewcolproperties_SUnixDirViewTypeCol 65050 +#define Dragdrop_MICopyStr 65051 +#define Dragdrop_MIMoveStr 65052 +#define Dragdrop_MILinkStr 65053 +#define Dragdrop_MIAbortStr 65054 +#define Tb2consts_STBToolbarIndexOutOfBounds 65055 +#define Customdirview_STextFileExt 65056 +#define Customdirview_STextFiles 65057 +#define Customdirview_STextDirectories 65058 +#define Customdirview_SParentDir 65059 +#define Customdirview_SIconUpdateThreadTerminationError 65060 +#define Customdirview_SDriveNotReady 65061 +#define Customdirview_SDirNotExists 65062 +#define Customdriveview_SDragDropError 65063 +#define Customunixdirview_SUnixDefaultRootName 65064 +#define Dirview_coFileOperatorTitle 65065 +#define Dirviewcolproperties_SDirViewNameCol 65066 +#define Dirviewcolproperties_SDirViewSizeCol 65067 +#define Dirviewcolproperties_SDirViewTypeCol 65068 +#define Dirviewcolproperties_SDirViewChangedCol 65069 +#define Dirviewcolproperties_SDirViewAttrCol 65070 +#define Dirviewcolproperties_SDirViewExtCol 65071 +#define Comboedit_SDefaultFilter 65072 +#define Comboedit_SInvalidFileName 65073 +#define Tcpip_SSocketError2 65074 +#define Tcpip_STimeout 65075 +#define Tcpip_SUnknownSockError 65076 +#define Tcpip_SHttpError 65077 +#define Tcpip_SRedirectLimitError 65078 +#define Baseutils_SNoValidPath 65079 +#define Baseutils_SUcpPathsNotSupported 65080 +#define Baseutils_SByte 65081 +#define Baseutils_SKiloByte 65082 +#define Baseutils_SMegaByte 65083 +#define Baseutils_SGigaByte 65084 +#define Customdirview_SErrorRenameFile 65085 +#define Customdirview_SErrorRenameFileExists 65086 +#define Customdirview_SErrorInvalidName 65087 +#define System_Sysconst_SLongDayNameTue 65088 +#define System_Sysconst_SLongDayNameWed 65089 +#define System_Sysconst_SLongDayNameThu 65090 +#define System_Sysconst_SLongDayNameFri 65091 +#define System_Sysconst_SLongDayNameSat 65092 +#define System_Sysconst_SCannotCreateDir 65093 +#define System_Sysconst_SInvalidSourceArray 65094 +#define System_Sysconst_SInvalidDestinationArray 65095 +#define System_Sysconst_SCharIndexOutOfBounds 65096 +#define System_Sysconst_SByteIndexOutOfBounds 65097 +#define System_Sysconst_SInvalidCharCount 65098 +#define System_Sysconst_SInvalidDestinationIndex 65099 +#define System_Sysconst_SInvalidCodePage 65100 +#define System_Sysconst_SInvalidEncodingName 65101 +#define System_Sysconst_SNoMappingForUnicodeCharacter 65102 +#define Comboedit_SBrowse 65103 +#define System_Sysconst_SLongMonthNameJun 65104 +#define System_Sysconst_SLongMonthNameJul 65105 +#define System_Sysconst_SLongMonthNameAug 65106 +#define System_Sysconst_SLongMonthNameSep 65107 +#define System_Sysconst_SLongMonthNameOct 65108 +#define System_Sysconst_SLongMonthNameNov 65109 +#define System_Sysconst_SLongMonthNameDec 65110 +#define System_Sysconst_SShortDayNameSun 65111 +#define System_Sysconst_SShortDayNameMon 65112 +#define System_Sysconst_SShortDayNameTue 65113 +#define System_Sysconst_SShortDayNameWed 65114 +#define System_Sysconst_SShortDayNameThu 65115 +#define System_Sysconst_SShortDayNameFri 65116 +#define System_Sysconst_SShortDayNameSat 65117 +#define System_Sysconst_SLongDayNameSun 65118 +#define System_Sysconst_SLongDayNameMon 65119 +#define System_Sysconst_SShortMonthNameFeb 65120 +#define System_Sysconst_SShortMonthNameMar 65121 +#define System_Sysconst_SShortMonthNameApr 65122 +#define System_Sysconst_SShortMonthNameMay 65123 +#define System_Sysconst_SShortMonthNameJun 65124 +#define System_Sysconst_SShortMonthNameJul 65125 +#define System_Sysconst_SShortMonthNameAug 65126 +#define System_Sysconst_SShortMonthNameSep 65127 +#define System_Sysconst_SShortMonthNameOct 65128 +#define System_Sysconst_SShortMonthNameNov 65129 +#define System_Sysconst_SShortMonthNameDec 65130 +#define System_Sysconst_SLongMonthNameJan 65131 +#define System_Sysconst_SLongMonthNameFeb 65132 +#define System_Sysconst_SLongMonthNameMar 65133 +#define System_Sysconst_SLongMonthNameApr 65134 +#define System_Sysconst_SLongMonthNameMay 65135 +#define System_Sysconst_SExternalException 65136 +#define System_Sysconst_SAssertionFailed 65137 +#define System_Sysconst_SIntfCastError 65138 +#define System_Sysconst_SSafecallException 65139 +#define System_Sysconst_SMonitorLockException 65140 +#define System_Sysconst_SNoMonitorSupportException 65141 +#define System_Sysconst_SNotImplemented 65142 +#define System_Sysconst_SObjectDisposed 65143 +#define System_Sysconst_SAssertError 65144 +#define System_Sysconst_SAbstractError 65145 +#define System_Sysconst_SModuleAccessViolation 65146 +#define System_Sysconst_SCannotReadPackageInfo 65147 +#define System_Sysconst_sErrorLoadingPackage 65148 +#define System_Sysconst_SOSError 65149 +#define System_Sysconst_SUnkOSError 65150 +#define System_Sysconst_SShortMonthNameJan 65151 +#define System_Sysconst_SVarArrayLocked 65152 +#define System_Sysconst_SInvalidVarCast 65153 +#define System_Sysconst_SInvalidVarOp 65154 +#define System_Sysconst_SInvalidVarNullOp 65155 +#define System_Sysconst_SInvalidVarOpWithHResultWithPrefix 65156 +#define System_Sysconst_SVarTypeOutOfRangeWithPrefix 65157 +#define System_Sysconst_SVarTypeAlreadyUsedWithPrefix 65158 +#define System_Sysconst_SVarTypeNotUsableWithPrefix 65159 +#define System_Sysconst_SVarTypeTooManyCustom 65160 +#define System_Sysconst_SVarTypeCouldNotConvert 65161 +#define System_Sysconst_SVarTypeConvertOverflow 65162 +#define System_Sysconst_SVarOverflow 65163 +#define System_Sysconst_SVarInvalid 65164 +#define System_Sysconst_SVarBadType 65165 +#define System_Sysconst_SVarNotImplemented 65166 +#define System_Sysconst_SVarUnexpected 65167 +#define System_Sysconst_SStackOverflow 65168 +#define System_Sysconst_SControlC 65169 +#define System_Sysconst_SPrivilege 65170 +#define System_Sysconst_SOperationAborted 65171 +#define System_Sysconst_SException 65172 +#define System_Sysconst_SExceptTitle 65173 +#define System_Sysconst_SInvalidFormat 65174 +#define System_Sysconst_SArgumentMissing 65175 +#define System_Sysconst_SDispatchError 65176 +#define System_Sysconst_SReadAccess 65177 +#define System_Sysconst_SWriteAccess 65178 +#define System_Sysconst_SExecuteAccess 65179 +#define System_Sysconst_SInvalidAccess 65180 +#define System_Sysconst_SFormatTooLong 65181 +#define System_Sysconst_SVarArrayCreate 65182 +#define System_Sysconst_SVarArrayBounds 65183 +#define System_Sysconst_STooManyOpenFiles 65184 +#define System_Sysconst_SAccessDenied 65185 +#define System_Sysconst_SEndOfFile 65186 +#define System_Sysconst_SDiskFull 65187 +#define System_Sysconst_SInvalidInput 65188 +#define System_Sysconst_SDivByZero 65189 +#define System_Sysconst_SRangeError 65190 +#define System_Sysconst_SIntOverflow 65191 +#define System_Sysconst_SInvalidOp 65192 +#define System_Sysconst_SZeroDivide 65193 +#define System_Sysconst_SOverflow 65194 +#define System_Sysconst_SUnderflow 65195 +#define System_Sysconst_SInvalidPointer 65196 +#define System_Sysconst_SInvalidCast 65197 +#define System_Sysconst_SAccessViolationArg3 65198 +#define System_Sysconst_SAccessViolationNoArg 65199 +#define System_Rtlconsts_SLocationSensorStarted 65200 +#define System_Rtlconsts_SInvalidDateString 65201 +#define System_Rtlconsts_SInvalidTimeString 65202 +#define System_Rtlconsts_SInvalidOffsetString 65203 +#define System_Sysconst_SUnknown 65204 +#define System_Sysconst_SInvalidInteger 65205 +#define System_Sysconst_SInvalidFloat 65206 +#define System_Sysconst_SInvalidDate 65207 +#define System_Sysconst_SInvalidTime 65208 +#define System_Sysconst_SInvalidDateTime 65209 +#define System_Sysconst_SInvalidTimeStamp 65210 +#define System_Sysconst_SInvalidGUID 65211 +#define System_Sysconst_STimeEncodeError 65212 +#define System_Sysconst_SDateEncodeError 65213 +#define System_Sysconst_SOutOfMemory 65214 +#define System_Sysconst_SInOutError 65215 +#define System_Rtlconsts_SWindows7 65216 +#define System_Rtlconsts_SWindowsServer2008R2 65217 +#define System_Rtlconsts_SWindows2000 65218 +#define System_Rtlconsts_SWindowsXP 65219 +#define System_Rtlconsts_SWindowsServer2003 65220 +#define System_Rtlconsts_SWindowsServer2003R2 65221 +#define System_Rtlconsts_SWindowsServer2012 65222 +#define System_Rtlconsts_SWindowsServer2012R2 65223 +#define System_Rtlconsts_SWindows8 65224 +#define System_Rtlconsts_SWindows8Point1 65225 +#define System_Rtlconsts_sObserverUnsupported 65226 +#define System_Rtlconsts_sObserverMultipleSingleCast 65227 +#define System_Rtlconsts_sObserverNoInterface 65228 +#define System_Rtlconsts_sObserverNoSinglecastFound 65229 +#define System_Rtlconsts_sObserverNoMulticastFound 65230 +#define System_Rtlconsts_sObserverNotAvailable 65231 +#define System_Rtlconsts_SNothingFound 65232 +#define System_Rtlconsts_SArgumentOutOfRange 65233 +#define System_Rtlconsts_SGenericItemNotFound 65234 +#define System_Rtlconsts_SGenericDuplicateItem 65235 +#define System_Rtlconsts_SInsufficientRtti 65236 +#define System_Rtlconsts_SParameterCountMismatch 65237 +#define System_Rtlconsts_SNonPublicType 65238 +#define System_Rtlconsts_SByRefArgMismatch 65239 +#define System_Rtlconsts_SServiceNotFound 65240 +#define System_Rtlconsts_SVersionStr 65241 +#define System_Rtlconsts_SSPVersionStr 65242 +#define System_Rtlconsts_SVersion32 65243 +#define System_Rtlconsts_SVersion64 65244 +#define System_Rtlconsts_SWindows 65245 +#define System_Rtlconsts_SWindowsVista 65246 +#define System_Rtlconsts_SWindowsServer2008 65247 +#define System_Rtlconsts_sArgument_InvalidHighSurrogate 65248 +#define System_Rtlconsts_sArgument_InvalidLowSurrogate 65249 +#define System_Rtlconsts_sInvalidStringAndObjectArrays 65250 +#define System_Rtlconsts_sInvalidTimeoutValue 65251 +#define System_Rtlconsts_sTimespanTooLong 65252 +#define System_Rtlconsts_sInvalidTimespanDuration 65253 +#define System_Rtlconsts_sTimespanValueCannotBeNan 65254 +#define System_Rtlconsts_sCannotNegateTimespan 65255 +#define System_Rtlconsts_sInvalidTimespanFormat 65256 +#define System_Rtlconsts_sTimespanElementTooLong 65257 +#define System_Rtlconsts_SNoContext 65258 +#define System_Rtlconsts_SNoContextFound 65259 +#define System_Rtlconsts_SNoIndex 65260 +#define System_Rtlconsts_SNoSearch 65261 +#define System_Rtlconsts_SNoTableOfContents 65262 +#define System_Rtlconsts_SNoTopics 65263 +#define System_Rtlconsts_SThreadStartError 65264 +#define System_Rtlconsts_SThreadExternalCheckTerminated 65265 +#define System_Rtlconsts_SThreadExternalSetReturnValue 65266 +#define System_Rtlconsts_SParamIsNil 65267 +#define System_Rtlconsts_SParamIsNegative 65268 +#define System_Rtlconsts_SInputBufferExceed 65269 +#define System_Rtlconsts_SInvalidCharsInPath 65270 +#define System_Rtlconsts_SPathTooLong 65271 +#define System_Rtlconsts_SPathNotFound 65272 +#define System_Rtlconsts_SPathFormatNotSupported 65273 +#define System_Rtlconsts_SDriveNotFound 65274 +#define System_Rtlconsts_SFileNotFound 65275 +#define System_Rtlconsts_SLocalTimeInvalid 65276 +#define System_Rtlconsts_hNoFilterViewer 65277 +#define System_Rtlconsts_sArgumentOutOfRange_StringIndex 65278 +#define System_Rtlconsts_sArgumentOutOfRange_InvalidUTF32 65279 +#define System_Rtlconsts_SRegCreateFailed 65280 +#define System_Rtlconsts_SRegGetDataFailed 65281 +#define System_Rtlconsts_SRegisterError 65282 +#define System_Rtlconsts_SRegSetDataFailed 65283 +#define System_Rtlconsts_SResNotFound 65284 +#define System_Rtlconsts_SSeekNotImplemented 65285 +#define System_Rtlconsts_SSortedListError 65286 +#define System_Rtlconsts_SStringExpected 65287 +#define System_Rtlconsts_SSymbolExpected 65288 +#define System_Rtlconsts_SUnknownGroup 65289 +#define System_Rtlconsts_SUnknownProperty 65290 +#define System_Rtlconsts_SWriteError 65291 +#define System_Rtlconsts_SThreadCreateError 65292 +#define System_Rtlconsts_SThreadError 65293 +#define System_Rtlconsts_SThreadExternalTerminate 65294 +#define System_Rtlconsts_SThreadExternalWait 65295 +#define System_Rtlconsts_SInvalidPropertyPath 65296 +#define System_Rtlconsts_SInvalidPropertyValue 65297 +#define System_Rtlconsts_SInvalidRegType 65298 +#define System_Rtlconsts_SInvalidString 65299 +#define System_Rtlconsts_SLineTooLong 65300 +#define System_Rtlconsts_SListCapacityError 65301 +#define System_Rtlconsts_SListCountError 65302 +#define System_Rtlconsts_SListIndexError 65303 +#define System_Rtlconsts_SMemoryStreamError 65304 +#define System_Rtlconsts_SNoComSupport 65305 +#define System_Rtlconsts_SNumberExpected 65306 +#define System_Rtlconsts_SAnsiUTF8Expected 65307 +#define System_Rtlconsts_SParseError 65308 +#define System_Rtlconsts_SPropertyException 65309 +#define System_Rtlconsts_SReadError 65310 +#define System_Rtlconsts_SReadOnlyProperty 65311 +#define System_Rtlconsts_SCheckSynchronizeError 65312 +#define System_Rtlconsts_SClassNotFound 65313 +#define System_Rtlconsts_SDuplicateClass 65314 +#define System_Rtlconsts_SDuplicateItem 65315 +#define System_Rtlconsts_SDuplicateName 65316 +#define System_Rtlconsts_SDuplicateString 65317 +#define System_Rtlconsts_SFCreateErrorEx 65318 +#define System_Rtlconsts_SFOpenErrorEx 65319 +#define System_Rtlconsts_SIdentifierExpected 65320 +#define System_Rtlconsts_SIniFileWriteError 65321 +#define System_Rtlconsts_SInvalidBinary 65322 +#define System_Rtlconsts_SInvalidFileName 65323 +#define System_Rtlconsts_SInvalidImage 65324 +#define System_Rtlconsts_SInvalidMask 65325 +#define System_Rtlconsts_SInvalidName 65326 +#define System_Rtlconsts_SInvalidProperty 65327 +#define Vcl_Comstrs_sDateTimeMin 65328 +#define Vcl_Comstrs_sNeedAllowNone 65329 +#define Vcl_Comstrs_sFailSetCalDateTime 65330 +#define Vcl_Comstrs_sFailSetCalMaxSelRange 65331 +#define Vcl_Comstrs_sFailSetCalMinMaxRange 65332 +#define Vcl_Comstrs_sFailsetCalSelRange 65333 +#define System_Win_Comconst_SOleError 65334 +#define System_Win_Comconst_SNoMethod 65335 +#define System_Win_Comconst_SVarNotObject 65336 +#define System_Win_Comconst_STooManyParams 65337 +#define System_Win_Comconst_SDCOMNotInstalled 65338 +#define System_Rtlconsts_SAncestorNotFound 65339 +#define System_Rtlconsts_SAssignError 65340 +#define System_Rtlconsts_SBitsIndexError 65341 +#define System_Rtlconsts_SCantWriteResourceStreamError 65342 +#define System_Rtlconsts_SCharExpected 65343 +#define Vcl_Comstrs_sTabFailGetObject 65344 +#define Vcl_Comstrs_sTabFailSet 65345 +#define Vcl_Comstrs_sTabFailSetObject 65346 +#define Vcl_Comstrs_sTabMustBeMultiLine 65347 +#define Vcl_Comstrs_sInvalidLevel 65348 +#define Vcl_Comstrs_sInvalidLevelEx 65349 +#define Vcl_Comstrs_sInvalidIndex 65350 +#define Vcl_Comstrs_sInsertError 65351 +#define Vcl_Comstrs_sInvalidOwner 65352 +#define Vcl_Comstrs_sRichEditInsertError 65353 +#define Vcl_Comstrs_sRichEditLoadFail 65354 +#define Vcl_Comstrs_sRichEditSaveFail 65355 +#define Vcl_Comstrs_sUDAssociated 65356 +#define Vcl_Comstrs_sPageIndexError 65357 +#define Vcl_Comstrs_sInvalidComCtl32 65358 +#define Vcl_Comstrs_sDateTimeMax 65359 +#define Vcl_Consts_SStyleHookClassNotRegistered 65360 +#define Vcl_Consts_SStyleInvalidParameter 65361 +#define Vcl_Consts_SStyleHookClassNotFound 65362 +#define Vcl_Consts_SStyleFeatureNotSupported 65363 +#define Vcl_Consts_SStyleNotRegistered 65364 +#define Vcl_Consts_SStyleUnregisterError 65365 +#define Vcl_Consts_SStyleNotRegisteredNoName 65366 +#define Vcl_Oleconst_SBadPropValue 65367 +#define Vcl_Oleconst_SCannotActivate 65368 +#define Vcl_Oleconst_SNoWindowHandle 65369 +#define Vcl_Oleconst_SInvalidLicense 65370 +#define Vcl_Oleconst_SNotLicensed 65371 +#define Vcl_Oleconst_sNoRunningObject 65372 +#define Vcl_Comstrs_sTabFailClear 65373 +#define Vcl_Comstrs_sTabFailDelete 65374 +#define Vcl_Comstrs_sTabFailRetrieve 65375 +#define Vcl_Consts_STaskDlgButtonCaption 65376 +#define Vcl_Consts_STaskDlgRadioButtonCaption 65377 +#define Vcl_Consts_SInvalidTaskDlgButtonCaption 65378 +#define Vcl_Consts_SInvalidCategoryPanelParent 65379 +#define Vcl_Consts_SInvalidCategoryPanelGroupChild 65380 +#define Vcl_Consts_SNoKeyword 65381 +#define Vcl_Consts_SStyleLoadError 65382 +#define Vcl_Consts_SStyleLoadErrors 65383 +#define Vcl_Consts_SStyleRegisterError 65384 +#define Vcl_Consts_SStyleClassRegisterError 65385 +#define Vcl_Consts_SStyleNotFound 65386 +#define Vcl_Consts_SStyleClassNotFound 65387 +#define Vcl_Consts_SStyleInvalidHandle 65388 +#define Vcl_Consts_SStyleFormatError 65389 +#define Vcl_Consts_SStyleFileDescription 65390 +#define Vcl_Consts_SStyleHookClassRegistered 65391 +#define Vcl_Consts_SDomain 65392 +#define Vcl_Consts_SLogin 65393 +#define Vcl_Consts_SSeparator 65394 +#define Vcl_Consts_SErrorSettingCount 65395 +#define Vcl_Consts_SListBoxMustBeVirtual 65396 +#define Vcl_Consts_SNoGetItemEventHandler 65397 +#define Vcl_Consts_SInvalidPath 65398 +#define Vcl_Consts_SANSIEncoding 65399 +#define Vcl_Consts_SASCIIEncoding 65400 +#define Vcl_Consts_SUnicodeEncoding 65401 +#define Vcl_Consts_SBigEndianEncoding 65402 +#define Vcl_Consts_SUTF8Encoding 65403 +#define Vcl_Consts_SUTF7Encoding 65404 +#define Vcl_Consts_STrayIconRemoveError 65405 +#define Vcl_Consts_SPageControlNotSet 65406 +#define Vcl_Consts_SWindowsVistaRequired 65407 +#define Vcl_Consts_SNoDefaultPrinter 65408 +#define Vcl_Consts_SDuplicateMenus 65409 +#define Vcl_Consts_SPictureLabel 65410 +#define Vcl_Consts_SPictureDesc 65411 +#define Vcl_Consts_SPreviewLabel 65412 +#define Vcl_Consts_SCannotOpenAVI 65413 +#define Vcl_Consts_SDockedCtlNeedsName 65414 +#define Vcl_Consts_SDockTreeRemoveError 65415 +#define Vcl_Consts_SDockZoneNotFound 65416 +#define Vcl_Consts_SDockZoneHasNoCtl 65417 +#define Vcl_Consts_SDockZoneVersionConflict 65418 +#define Vcl_Consts_SMultiSelectRequired 65419 +#define Vcl_Consts_SPromptArrayTooShort 65420 +#define Vcl_Consts_SPromptArrayEmpty 65421 +#define Vcl_Consts_SUsername 65422 +#define Vcl_Consts_SPassword 65423 +#define Vcl_Consts_SmkcRight 65424 +#define Vcl_Consts_SmkcDown 65425 +#define Vcl_Consts_SmkcIns 65426 +#define Vcl_Consts_SmkcDel 65427 +#define Vcl_Consts_SmkcShift 65428 +#define Vcl_Consts_SmkcCtrl 65429 +#define Vcl_Consts_SmkcAlt 65430 +#define Vcl_Consts_srNone 65431 +#define Vcl_Consts_SOutOfRange 65432 +#define Vcl_Consts_sAllFilter 65433 +#define Vcl_Consts_SInsertLineError 65434 +#define Vcl_Consts_SInvalidClipFmt 65435 +#define Vcl_Consts_SIconToClipboard 65436 +#define Vcl_Consts_SCannotOpenClipboard 65437 +#define Vcl_Consts_SInvalidMemoSize 65438 +#define Vcl_Consts_SInvalidPrinterOp 65439 +#define Vcl_Consts_SMsgDlgIgnore 65440 +#define Vcl_Consts_SMsgDlgAll 65441 +#define Vcl_Consts_SMsgDlgNoToAll 65442 +#define Vcl_Consts_SMsgDlgYesToAll 65443 +#define Vcl_Consts_SMsgDlgClose 65444 +#define Vcl_Consts_SmkcBkSp 65445 +#define Vcl_Consts_SmkcTab 65446 +#define Vcl_Consts_SmkcEsc 65447 +#define Vcl_Consts_SmkcEnter 65448 +#define Vcl_Consts_SmkcSpace 65449 +#define Vcl_Consts_SmkcPgUp 65450 +#define Vcl_Consts_SmkcPgDn 65451 +#define Vcl_Consts_SmkcEnd 65452 +#define Vcl_Consts_SmkcHome 65453 +#define Vcl_Consts_SmkcLeft 65454 +#define Vcl_Consts_SmkcUp 65455 +#define Vcl_Consts_SFixedColTooBig 65456 +#define Vcl_Consts_SFixedRowTooBig 65457 +#define Vcl_Consts_SInvalidStringGridOp 65458 +#define Vcl_Consts_SMaskErr 65459 +#define Vcl_Consts_SMaskEditErr 65460 +#define Vcl_Consts_SMsgDlgWarning 65461 +#define Vcl_Consts_SMsgDlgError 65462 +#define Vcl_Consts_SMsgDlgInformation 65463 +#define Vcl_Consts_SMsgDlgConfirm 65464 +#define Vcl_Consts_SMsgDlgYes 65465 +#define Vcl_Consts_SMsgDlgNo 65466 +#define Vcl_Consts_SMsgDlgOK 65467 +#define Vcl_Consts_SMsgDlgCancel 65468 +#define Vcl_Consts_SMsgDlgHelp 65469 +#define Vcl_Consts_SMsgDlgAbort 65470 +#define Vcl_Consts_SMsgDlgRetry 65471 #define Vcl_Consts_SNoButton 65472 #define Vcl_Consts_SHelpButton 65473 #define Vcl_Consts_SCloseButton 65474 @@ -467,14 +753,14 @@ #define Vcl_Consts_SAbortButton 65477 #define Vcl_Consts_SAllButton 65478 #define Vcl_Consts_SCannotDragForm 65479 -#define Vcl_Consts_SDdeErr 65480 -#define Vcl_Consts_SDdeConvErr 65481 -#define Vcl_Consts_SDdeMemErr 65482 -#define Vcl_Consts_SDdeNoConnect 65483 -#define Vcl_Consts_SVMetafiles 65484 -#define Vcl_Consts_SVEnhMetafiles 65485 -#define Vcl_Consts_SVIcons 65486 -#define Vcl_Consts_SVBitmaps 65487 +#define Vcl_Consts_SVMetafiles 65480 +#define Vcl_Consts_SVEnhMetafiles 65481 +#define Vcl_Consts_SVIcons 65482 +#define Vcl_Consts_SVBitmaps 65483 +#define Vcl_Consts_SVTIFFImages 65484 +#define Vcl_Consts_SGridTooLarge 65485 +#define Vcl_Consts_STooManyDeleted 65486 +#define Vcl_Consts_SIndexOutOfRange 65487 #define Vcl_Consts_SMenuIndexError 65488 #define Vcl_Consts_SMenuReinserted 65489 #define Vcl_Consts_SMenuNotFound 65490 @@ -525,13 +811,264 @@ #define Vcl_Consts_SInvalidTextFormatFlag 65535 STRINGTABLE BEGIN - Vcl_Imaging_Pnglang_EPNGCannotChangeTransparentText, "Setting bit transparency color is not allowed for png images containing alpha value for each pixel (COLOR_RGBALPHA and COLOR_GRAYSCALEALPHA)" - Vcl_Imaging_Pnglang_EPNGHeaderNotPresentText, "This operation is not valid because the current image contains no valid header." - Vcl_Imaging_Pnglang_EInvalidNewSize, "The new size provided for image resizing is invalid." + Ieconst_sChildWindowsAlreadyHooked, "Attempting to hook child windows twice" + Ieconst_sSaveCurrentFile, "Save the current file?" + Jclresources_RsIntelCacheDescrE4, "3rd-level cache: 8 MByte, 16-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescrEA, "3rd-level cache: 12 MByte, 24-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescrEB, "3rd-level cache: 18 MByte, 24-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescrEC, "3rd-level cache: 24 MByte, 24-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescrF0, "64-Byte Prefetching" + Jclresources_RsIntelCacheDescrF1, "128-Byte Prefetching" + Jclresources_RsIntelCacheDescrFF, "CPUID leaf 2 does not report cache descriptor information, use CPUID leaf 4 to query cache parameters" + Jclresources_RsOSVersionWin81, "Windows 8.1" + Jclresources_RsOSVersionWinServer2012R2, "Windows Server 2012 R2" + Jclresources_RsWin32Error, "Win32 error: %s (%u)%s%s" + Jclresources_RsELibraryNotFound, "Library not found: %s" + Jclresources_RsEFunctionNotFound, "Function not found: %s.%s" + Ieconst_sNoPageLoaded, "No page loaded" + Ieconst_sNilProvider, "Cannot register a nil provider" + Ieconst_sInvalidServiceProviderGUID, "Invalid service provider GUID" + Ieconst_sClassSinkingError, "%s only supports sinking of method calls!" + Jclresources_RsIntelCacheDescrB3, "Data TLB: 4 KByte pages, 4-way set associative, 128 entries" + Jclresources_RsIntelCacheDescrB4, "Data TLB1: 4 KByte pages, 4-way set associative, 256 entries" + Jclresources_RsIntelCacheDescrBA, "Data TLB1: 4 KByte pages, 4-way set associative, 64 entries" + Jclresources_RsIntelCacheDescrC0, "Data TLB: 4 KByte and 4 MByte pages, 4-way set associative, 8 entries" + Jclresources_RsIntelCacheDescrCA, "Shared 2nd-Level TLB: 4 KByte pages, 4-way associative, 512 entries" + Jclresources_RsIntelCacheDescrD0, "3rd-level cache: 512 KByte, 4-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescrD1, "3rd-level cache: 1 MByte, 4-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescrD2, "3rd-level cache: 2 MByte, 4-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescrD6, "3rd-level cache: 1 MByte, 8-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescrD7, "3rd-level cache: 2 MByte, 8-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescrD8, "3rd-level cache: 4 MByte, 8-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescrDC, "3rd-level cache: 1.5 MByte, 12-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescrDD, "3rd-level cache: 3 MByte, 12-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescrDE, "3rd-level cache: 6 MByte, 12-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescrE2, "3rd-level cache: 2 MByte, 16-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescrE3, "3rd-level cache: 4 MByte, 16-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr79, "2nd-level cache: 128 KBytes, 8-way set associative, 64 bytes line size, 2 lines per sector" + Jclresources_RsIntelCacheDescr7A, "2nd-level cache: 256 KBytes, 8-way set associative, 64 bytes line size, 2 lines per sector" + Jclresources_RsIntelCacheDescr7B, "2nd-level cache: 512 KBytes, 8-way set associative, 64 bytes line size, 2 lines per sector" + Jclresources_RsIntelCacheDescr7C, "2nd-level cache: 1 MBytes, 8-way set associative, 64 bytes line size, 2 lines per sector" + Jclresources_RsIntelCacheDescr7D, "2nd-level cache: 2 MBytes, 8-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr7F, "2nd-level cache: 512 KBytes, 2-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr80, "2nd-level cache: 512 KBytes, 8-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr82, "2nd-level cache: 256 KBytes, 8-way associative, 32 byte line size" + Jclresources_RsIntelCacheDescr83, "2nd-level cache: 512 KBytes, 8-way associative, 32 byte line size" + Jclresources_RsIntelCacheDescr84, "2nd-level cache: 1 MBytes, 8-way associative, 32 byte line size" + Jclresources_RsIntelCacheDescr85, "2nd-level cache: 2 MBytes, 8-way associative, 32 byte line size" + Jclresources_RsIntelCacheDescr86, "2nd-level cache: 512 KByte, 4-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr87, "2nd-level cache: 1 MByte, 8-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescrB0, "Instruction TLB: 4 KByte pages, 4-way set associative, 128 entries" + Jclresources_RsIntelCacheDescrB1, "Instruction TLB: 2 MByte pages, 4-way, 8 entries or 4 MByte pages, 4-way, 4 entries" + Jclresources_RsIntelCacheDescrB2, "Instruction TLB: 4 KByte pages, 4-way set associative, 64 entries" + Jclresources_RsIntelCacheDescr57, "Data TLB0: 4 KByte pages, 4-way associative, 16 entries" + Jclresources_RsIntelCacheDescr59, "Data TLB0: 4 KByte pages, fully associative, 16 entries" + Jclresources_RsIntelCacheDescr5A, "Data TLB0: 2 MByte or 4 MByte pages, 4-way set associative, 32 entries" + Jclresources_RsIntelCacheDescr5B, "Data TLB: 4 KByte and 4 MByte pages, 64 Entries" + Jclresources_RsIntelCacheDescr5C, "Data TLB: 4 KByte and 4 MByte pages, 128 Entries" + Jclresources_RsIntelCacheDescr5D, "Data TLB: 4 KByte and 4 MByte pages, 256 Entries" + Jclresources_RsIntelCacheDescr60, "1st-level data cache: 16 KByte, 8-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr66, "1st-level data cache: 8 KBytes, 4-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr67, "1st-level data cache: 16 KBytes, 4-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr68, "1st-level data cache: 32 KBytes, 4-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr70, "Trace cache: 12 K-Ops, 8-way set associative" + Jclresources_RsIntelCacheDescr71, "Trace cache: 16 K-Ops, 8-way set associative" + Jclresources_RsIntelCacheDescr72, "Trace cache: 32 K-Ops, 8-way set associative" + Jclresources_RsIntelCacheDescr73, "Trace cache: 64 K-Ops, 8-way set associative" + Jclresources_RsIntelCacheDescr76, "Instruction TLB: 2M/4M pages, fully associative, 8 entries" + Jclresources_RsIntelCacheDescr78, "2nd-level cache: 1 MBytes, 4-way set associative, 64 bytes line size" + Jclresources_RsIntelCacheDescr45, "2nd-level cache: 2 MBytes, 4-way set associative, 32 byte line size" + Jclresources_RsIntelCacheDescr46, "3rd-level cache: 4 MBytes, 4-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr47, "3rd-level cache: 8 MBytes, 4-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr48, "3rd-level cache: 8 MByte, 8-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr49, "2nd-level cache: 4 MBytes, 16-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr4A, "3rd-level cache: 6MByte, 12-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr4B, "3rd-level cache: 8MByte, 16-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr4C, "3rd-level cache: 12MByte, 12-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr4D, "3rd-level cache: 16MByte, 16-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr4E, "2nd-level cache: 6MByte, 24-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr4F, "Instruction TLB: 4 KByte pages, 32 Entries" + Jclresources_RsIntelCacheDescr50, "Instruction TLB: 4 KByte and 2 MByte or 4 MByte pages, 64 Entries" + Jclresources_RsIntelCacheDescr51, "Instruction TLB: 4 KByte and 2 MByte or 4 MByte pages, 128 Entries" + Jclresources_RsIntelCacheDescr52, "Instruction TLB: 4 KByte and 2 MByte or 4 MByte pages, 256 Entries" + Jclresources_RsIntelCacheDescr55, "Instruction TLB: 2-MByte or 4-MByte pages, fully associative, 7 entries" + Jclresources_RsIntelCacheDescr56, "Data TLB0: 4 MByte pages, 4-way set associative, 16 entries" + Jclresources_RsIntelCacheDescr23, "3rd level cache: 1 MBytes, 8-way set associative, 64 byte line size, 2 lines per sector" + Jclresources_RsIntelCacheDescr25, "3rd level cache: 2 MBytes, 8-way set associative, 64 byte line size, 2 lines per sector" + Jclresources_RsIntelCacheDescr29, "3rd level cache: 4 MBytes, 8-way set associative, 64 byte line size, 2 lines per sector" + Jclresources_RsIntelCacheDescr2C, "1st level data cache: 32 KBytes, 8-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr30, "1st level instruction cache: 32 KBytes, 8-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr39, "2nd-level cache: 128 KBytes, 4-way set associative, sectored cache, 64-byte line size" + Jclresources_RsIntelCacheDescr3A, "2nd-level cache: 192 KBytes, 6-way set associative, sectored cache, 64-byte line size" + Jclresources_RsIntelCacheDescr3B, "2nd-level cache: 128 KBytes, 2-way set associative, sectored cache, 64-byte line size" + Jclresources_RsIntelCacheDescr3C, "2nd-level cache: 256 KBytes, 4-way set associative, sectored cache, 64-byte line size" + Jclresources_RsIntelCacheDescr3D, "2nd-level cache: 384 KBytes, 6-way set associative, sectored cache, 64-byte line size" + Jclresources_RsIntelCacheDescr3E, "2nd-level cache: 512 KBytes, 4-way set associative, sectored cache, 64-byte line size" + Jclresources_RsIntelCacheDescr40, "No 2nd-level cache or, if processor contains a valid 2nd-level cache, no 3rd-level cache" + Jclresources_RsIntelCacheDescr41, "2nd-level cache: 128 KBytes, 4-way set associative, 32 byte line size" + Jclresources_RsIntelCacheDescr42, "2nd-level cache: 256 KBytes, 4-way set associative, 32 byte line size" + Jclresources_RsIntelCacheDescr43, "2nd-level cache: 512 KBytes, 4-way set associative, 32 byte line size" + Jclresources_RsIntelCacheDescr44, "2nd-level cache: 1 MBytes, 4-way set associative, 32 byte line size" + Jclresources_RsIntelCacheDescr00, "Null descriptor" + Jclresources_RsIntelCacheDescr01, "Instruction TLB: 4 KByte pages, 4-way set associative, 32 entries" + Jclresources_RsIntelCacheDescr02, "Instruction TLB: 4 MByte pages, 4-way set associative, 2 entries" + Jclresources_RsIntelCacheDescr03, "Data TLB: 4 KByte pages, 4-way set associative, 64 entries" + Jclresources_RsIntelCacheDescr04, "Data TLB: 4 MByte pages, 4-way set associative, 8 entries" + Jclresources_RsIntelCacheDescr05, "Data TLB1: 4 MByte pages, 4-way set associative, 32 entries" + Jclresources_RsIntelCacheDescr06, "1st level instruction cache: 8 KBytes, 4-way set associative, 32 byte line size" + Jclresources_RsIntelCacheDescr08, "1st level instruction cache: 16 KBytes, 4-way set associative, 32 byte line size" + Jclresources_RsIntelCacheDescr09, "1st level instruction cache: 32 KBytes, 4-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr0A, "1st level data cache: 8 KBytes, 2-way set associative, 32 byte line size" + Jclresources_RsIntelCacheDescr0B, "Instruction TLB: 4 MByte pages, 4-way set associative, 4 entries" + Jclresources_RsIntelCacheDescr0C, "1st level data cache: 16 KBytes, 4-way set associative, 32 byte line size" + Jclresources_RsIntelCacheDescr0D, "1st level data cache: 16 KBytes, 4-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr0E, "1st level data cache: 24 KBytes, 6-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr21, "2nd level cache: 256 KBytes, 8-way set associative, 64 byte line size" + Jclresources_RsIntelCacheDescr22, "3rd level cache: 512 KBytes, 4-way set associative, 64 byte line size, 2 lines per sector" + Jclresources_RsPeDEBUG_OMAP_FROM_SRC, "OMAP_FROM_SRC" + Jclresources_RsPePkgExecutable, "Executable" + Jclresources_RsPePkgPackage, "Package" + Jclresources_PsPePkgLibrary, "Library" + Jclresources_RsPePkgNeverBuild, "NeverBuild" + Jclresources_RsPePkgDesignOnly, "DesignOnly" + Jclresources_RsPePkgRunOnly, "RunOnly" + Jclresources_RsPePkgIgnoreDupUnits, "IgnoreDupUnits" + Jclresources_RsPePkgV3Produced, "Delphi 3 or C++ Builder 3" + Jclresources_RsPePkgProducerUndefined, "Undefined" + Jclresources_RsPePkgBCB4Produced, "C++ Builder 4 or later" + Jclresources_RsPePkgDelphi4Produced, "Delphi 4 or later" + Jclresources_RsPePkgMain, "Main" + Jclresources_RsPePkgWeak, "Weak" + Jclresources_RsPePkgOrgWeak, "OrgWeak" + Jclresources_RsPePkgImplicit, "Implicit" + Jclresources_RsPeMACHINE_CEE, "CEE" + Jclresources_RsPeSUBSYSTEM_UNKNOWN, "Unknown" + Jclresources_RsPeSUBSYSTEM_NATIVE, "Native" + Jclresources_RsPeSUBSYSTEM_WINDOWS_GUI, "GUI" + Jclresources_RsPeSUBSYSTEM_WINDOWS_CUI, "Console" + Jclresources_RsPeSUBSYSTEM_OS2_CUI, "OS/2" + Jclresources_RsPeSUBSYSTEM_POSIX_CUI, "Posix" + Jclresources_RsPeSUBSYSTEM_RESERVED8, "Reserved 8" + Jclresources_RsPeDEBUG_UNKNOWN, "UNKNOWN" + Jclresources_RsPeDEBUG_COFF, "COFF" + Jclresources_RsPeDEBUG_CODEVIEW, "CODEVIEW" + Jclresources_RsPeDEBUG_FPO, "FPO" + Jclresources_RsPeDEBUG_MISC, "MISC" + Jclresources_RsPeDEBUG_EXCEPTION, "EXCEPTION" + Jclresources_RsPeDEBUG_FIXUP, "FIXUP" + Jclresources_RsPeDEBUG_OMAP_TO_SRC, "OMAP_TO_SRC" + Jclresources_RsPeMACHINE_SH5, "SH5" + Jclresources_RsPeMACHINE_ARM, "ARM Little-Endian" + Jclresources_RsPeMACHINE_THUMB, "THUMB" + Jclresources_RsPeMACHINE_AM33, "AM33" + Jclresources_RsPeMACHINE_POWERPC, "IBM PowerPC Little-Endian" + Jclresources_RsPeMACHINE_POWERPCFP, "IBM PowerPC FP" + Jclresources_RsPeMACHINE_IA64, "Intel 64" + Jclresources_RsPeMACHINE_MIPS16, "MIPS16" + Jclresources_RsPeMACHINE_AMPHA64, "ALPHA64" + Jclresources_RsPeMACHINE_MIPSFPU, "MIPSFPU" + Jclresources_RsPeMACHINE_MIPSFPU16, "MIPSFPU16" + Jclresources_RsPeMACHINE_TRICORE, "Infineon" + Jclresources_RsPeMACHINE_CEF, "CEF" + Jclresources_RsPeMACHINE_EBC, "EFI Byte Code" + Jclresources_RsPeMACHINE_AMD64, "AMD64 (K8)" + Jclresources_RsPeMACHINE_M32R, "M32R little-endian" + Jclresources_RsPeProcessHeapFlags, "ProcessHeapFlags" + Jclresources_RsPeProcessAffinityMask, "ProcessAffinityMask" + Jclresources_RsPeCSDVersion, "CSDVersion" + Jclresources_RsPeReserved, "Reserved" + Jclresources_RsPeEditList, "EditList" + Jclresources_RsPeMACHINE_UNKNOWN, "Unknown" + Jclresources_RsPeMACHINE_I386, "Intel 386" + Jclresources_RsPeMACHINE_R3000, "MIPS little-endian R3000" + Jclresources_RsPeMACHINE_R4000, "MIPS little-endian R4000" + Jclresources_RsPeMACHINE_R10000, "MIPS little-endian R10000" + Jclresources_RsPeMACHINE_WCEMIPSV2, "MIPS little-endian WCE v2" + Jclresources_RsPeMACHINE_ALPHA, "Alpha_AXP" + Jclresources_RsPeMACHINE_SH3, "SH3 little-endian" + Jclresources_RsPeMACHINE_SH3DSP, "SH3 DSP" + Jclresources_RsPeMACHINE_SH3E, "SH3E little-endian" + Jclresources_RsPeMACHINE_SH4, "SH4 little-endian" + Jclresources_RsPeDllCharacteristics, "Dll Characteristics" + Jclresources_RsPeSizeOfStackReserve, "Size of Stack Reserve" + Jclresources_RsPeSizeOfStackCommit, "Size of Stack Commit" + Jclresources_RsPeSizeOfHeapReserve, "Size of Heap Reserve" + Jclresources_RsPeSizeOfHeapCommit, "Size of Heap Commit" + Jclresources_RsPeLoaderFlags, "Loader Flags" + Jclresources_RsPeNumberOfRvaAndSizes, "Number of RVA" + Jclresources_RsPeVersion, "Version" + Jclresources_RsPeGlobalFlagsClear, "GlobalFlagsClear" + Jclresources_RsPeGlobalFlagsSet, "GlobalFlagsSet" + Jclresources_RsPeCriticalSectionDefaultTimeout, "CriticalSectionDefaultTimeout" + Jclresources_RsPeDeCommitFreeBlockThreshold, "DeCommitFreeBlockThreshold" + Jclresources_RsPeDeCommitTotalFreeThreshold, "DeCommitTotalFreeThreshold" + Jclresources_RsPeLockPrefixTable, "LockPrefixTable" + Jclresources_RsPeMaximumAllocationSize, "MaximumAllocationSize" + Jclresources_RsPeVirtualMemoryThreshold, "VirtualMemoryThreshold" + Jclresources_RsPeSizeOfInitializedData, "Size of Initialized Data" + Jclresources_RsPeSizeOfUninitializedData, "Size of Uninitialized Data" + Jclresources_RsPeAddressOfEntryPoint, "Address of Entry Point" + Jclresources_RsPeBaseOfCode, "Base of Code" + Jclresources_RsPeBaseOfData, "Base of Data" + Jclresources_RsPeImageBase, "Image Base" + Jclresources_RsPeSectionAlignment, "Section Alignment" + Jclresources_RsPeFileAlignment, "File Alignment" + Jclresources_RsPeOperatingSystemVersion, "Operating System Version" + Jclresources_RsPeImageVersion, "Image Version" + Jclresources_RsPeSubsystemVersion, "Subsystem Version" + Jclresources_RsPeWin32VersionValue, "Win32 Version" + Jclresources_RsPeSizeOfImage, "Size of Image" + Jclresources_RsPeSizeOfHeaders, "Size of Headers" + Jclresources_RsPeCheckSum, "CheckSum" + Jclresources_RsPeSubsystem, "Subsystem" + Jclresources_RsPeImg_11, "Bound Import" + Jclresources_RsPeImg_12, "IAT" + Jclresources_RsPeImg_13, "Delay load import" + Jclresources_RsPeImg_14, "COM run-time" + Jclresources_RsPeImg_Reserved, "reserved [%.2d]" + Jclresources_RsPeSignature, "Signature" + Jclresources_RsPeMachine, "Machine" + Jclresources_RsPeNumberOfSections, "Number of Sections" + Jclresources_RsPeTimeDateStamp, "Time Date Stamp" + Jclresources_RsPePointerToSymbolTable, "Symbols Pointer" + Jclresources_RsPeNumberOfSymbols, "Number of Symbols" + Jclresources_RsPeSizeOfOptionalHeader, "Size of Optional Header" + Jclresources_RsPeCharacteristics, "Characteristics" + Jclresources_RsPeMagic, "Magic" + Jclresources_RsPeLinkerVersion, "Linker Version" + Jclresources_RsPeSizeOfCode, "Size of Code" + Jclresources_RsPeNotPE, "This is not a PE format" + Jclresources_RsPeUnknownTarget, "Unknown PE target" + Jclresources_RsPeNotResDir, "Not a resource directory" + Jclresources_RsPeNotAvailableForAttached, "Feature is not available for attached images" + Jclresources_RsPeSectionNotFound, "Section \"%s\" not found" + Jclresources_RsPeImg_00, "Exports" + Jclresources_RsPeImg_01, "Imports" + Jclresources_RsPeImg_02, "Resources" + Jclresources_RsPeImg_03, "Exceptions" + Jclresources_RsPeImg_04, "Security" + Jclresources_RsPeImg_05, "Base Relocations" + Jclresources_RsPeImg_06, "Debug" + Jclresources_RsPeImg_07, "Description" + Jclresources_RsPeImg_08, "Machine Value" + Jclresources_RsPeImg_09, "TLS" + Jclresources_RsPeImg_10, "Load configuration" Vcl_Imaging_Pnglang_EInvalidSpec, "The \"Portable Network Graphics\" could not be created because invalid image type parameters have being provided." - Vcl_Imaging_Pnglang_EPNGZLIBErrorText, "Could not decompress the image because it contains invalid compressed data.\r\n Description: " - Vcl_Imaging_Pnglang_EPNGInvalidPaletteText, "The \"Portable Network Graphics\" image contains an invalid palette." - Vcl_Imaging_Pnglang_EPNGInvalidFileHeaderText, "The file being read is not a valid \"Portable Network Graphics\" image because it contains an invalid header. This file may be corrupted, try obtaining it again" + Jclresources_RsEReplacementChar, "Failed to get ANSI replacement character" + Jclresources_RsEWindowsVersionNotSupported, "This windows version is not supported" + Jclresources_RsEWindowNotValid, "The window with handle %d is not valid" + Jclresources_RsEProcessNotValid, "The process with ID %d is not valid" + Jclresources_RsEModuleNotValid, "The Module with handle %d is not valid" + Jclresources_RsFileUtilsNoVersionInfo, "File contains no version information" + Jclresources_RsFileUtilsFileDoesNotExist, "The file %s does not exist" + Jclresources_RsFileUtilsLanguageIndex, "Illegal language index" + Jclresources_RsFileUtilsEmptyValue, "No value was supplied" + Jclresources_RsFileUtilsValueNotFound, "The value %s was not found." + Jclresources_RsCreateFileMapping, "Failed to create FileMapping" + Jclresources_RsCreateFileMappingView, "Failed to create FileMappingView" + Jclresources_RsFailedToObtainSize, "Failed to obtain size of file" + Jclresources_RsPeReadOnlyStream, "Stream is read-only" + Jclresources_RsPeCantOpen, "Cannot open file \"%s\"" Vcl_Imaging_Pnglang_EPNGIHDRNotFirstText, "This \"Portable Network Graphics\" image is not supported or it might be invalid.\r\n(IHDR chunk is not the first)" Vcl_Imaging_Pnglang_EPNGSizeExceedsText, "This \"Portable Network Graphics\" image is not supported because either its width or height exceeds the maximum size of 65535 pixels." Vcl_Imaging_Pnglang_EPNGUnknownPalEntryText, "There is no such palette entry." @@ -545,9 +1082,9 @@ BEGIN Vcl_Imaging_Pnglang_EPNGCannotAddInvalidImageText, "It's not allowed to add a new chunk because the current image is invalid." Vcl_Imaging_Pnglang_EPNGCouldNotLoadResourceText, "The png image could not be loaded from the resource ID." Vcl_Imaging_Pnglang_EPNGOutMemoryText, "Some operation could not be performed because the system is out of resources. Close some windows and try again." - Xml_Xmlconst_SNotActive, "No active document" - Xml_Xmlconst_SNodeNotFound, "Node \"%s\" not found" - Xml_Xmlconst_SMissingNode, "IDOMNode required" + Vcl_Imaging_Pnglang_EPNGCannotChangeTransparentText, "Setting bit transparency color is not allowed for png images containing alpha value for each pixel (COLOR_RGBALPHA and COLOR_GRAYSCALEALPHA)" + Vcl_Imaging_Pnglang_EPNGHeaderNotPresentText, "This operation is not valid because the current image contains no valid header." + Vcl_Imaging_Pnglang_EInvalidNewSize, "The new size provided for image resizing is invalid." Xml_Xmlconst_SNoAttributes, "Attributes are not supported on this node type" Xml_Xmlconst_SInvalidNodeType, "Invalid node type" Xml_Xmlconst_SMismatchedRegItems, "Mismatched paramaters to RegisterChildNodes" @@ -561,9 +1098,9 @@ BEGIN Vcl_Imaging_Pnglang_EPngInvalidCRCText, "This \"Portable Network Graphics\" image is not valid because it contains invalid pieces of data (crc error)" Vcl_Imaging_Pnglang_EPNGInvalidIHDRText, "The \"Portable Network Graphics\" image could not be loaded because one of its main piece of data (ihdr) might be corrupted" Vcl_Imaging_Pnglang_EPNGMissingMultipleIDATText, "This \"Portable Network Graphics\" image is invalid because it has missing image parts." - Dragdrop_MILinkStr, "&Shortcut(s) Create Here" - Dragdrop_MIAbortStr, "&Abort" - Tb2consts_STBToolbarIndexOutOfBounds, "Toolbar item index out of range" + Vcl_Imaging_Pnglang_EPNGZLIBErrorText, "Could not decompress the image because it contains invalid compressed data.\r\n Description: " + Vcl_Imaging_Pnglang_EPNGInvalidPaletteText, "The \"Portable Network Graphics\" image contains an invalid palette." + Vcl_Imaging_Pnglang_EPNGInvalidFileHeaderText, "The file being read is not a valid \"Portable Network Graphics\" image because it contains an invalid header. This file may be corrupted, try obtaining it again" Tb2consts_STBToolbarItemReinserted, "Toolbar item already inserted" Tb2consts_STBViewerNotFound, "An item viewer associated the specified item could not be found" Tb2consts_STBChevronItemMoreButtonsHint, "More Buttons|" @@ -577,13 +1114,13 @@ BEGIN Xml_Xmlconst_SDOMNotSupported, "Property or Method \"%s\" is not supported by DOM Vendor \"%s\"" Xml_Xmlconst_SNodeExpected, "Node cannot be null" Xml_Xmlconst_SMSDOMNotInstalled, "Microsoft MSXML is not installed" - Dirviewcolproperties_SDirViewChangedCol, "Changed" - Dirviewcolproperties_SDirViewAttrCol, "Attr" - Dirviewcolproperties_SDirViewExtCol, "Ext" + Xml_Xmlconst_SNotActive, "No active document" + Xml_Xmlconst_SNodeNotFound, "Node \"%s\" not found" + Xml_Xmlconst_SMissingNode, "IDOMNode required" Driveview_coFileOperatorTitle, "Filesystem Operation" Driveview_coInvalidDosChars, "\\/:*?\"<>|" Driveview_Space, " " - Driveview_16411, "New name contains invalid characters %s" + Driveview_16405, "New name contains invalid characters %s" Fileoperator_SFileOperation, "File Operation" Iedriveinfo_ErrorInvalidDrive, "%s is a invalid drive letter." Unixdirviewcolproperties_SUnixDirViewRightsCol, "Rights" @@ -593,14 +1130,14 @@ BEGIN Unixdirviewcolproperties_SUnixDirViewTypeCol, "Type" Dragdrop_MICopyStr, "&Copy Here" Dragdrop_MIMoveStr, "&Move Here" - Customdirview_SErrorRenameFileExists, "File already exists: " - Customdirview_SErrorInvalidName, "Filename contains invalid characters:" + Dragdrop_MILinkStr, "&Shortcut(s) Create Here" + Dragdrop_MIAbortStr, "&Abort" + Tb2consts_STBToolbarIndexOutOfBounds, "Toolbar item index out of range" Customdirview_STextFileExt, "File %s" Customdirview_STextFiles, "%u Files" Customdirview_STextDirectories, "%u Directories" Customdirview_SParentDir, "Parent directory" Customdirview_SIconUpdateThreadTerminationError, "Can't terminate icon update thread." - Customdirview_SDragDropError, "DragDrop Error: %d" Customdirview_SDriveNotReady, "Drive '%s:' is not ready." Customdirview_SDirNotExists, "Directory '%s' doesn't exist." Customdriveview_SDragDropError, "Drag&drop error: %d" @@ -609,12 +1146,9 @@ BEGIN Dirviewcolproperties_SDirViewNameCol, "Name" Dirviewcolproperties_SDirViewSizeCol, "Size" Dirviewcolproperties_SDirViewTypeCol, "Type" - System_Sysconst_SByteIndexOutOfBounds, "Start index out of bounds (%d)" - System_Sysconst_SInvalidCharCount, "Invalid count (%d)" - System_Sysconst_SInvalidDestinationIndex, "Invalid destination index (%d)" - System_Sysconst_SInvalidCodePage, "Invalid code page" - System_Sysconst_SInvalidEncodingName, "Invalid encoding name" - Comboedit_SBrowse, "Browse" + Dirviewcolproperties_SDirViewChangedCol, "Changed" + Dirviewcolproperties_SDirViewAttrCol, "Attr" + Dirviewcolproperties_SDirViewExtCol, "Ext" Comboedit_SDefaultFilter, "All files (*.*)|*.*" Comboedit_SInvalidFileName, "Invalid file name - %s" Tcpip_SSocketError2, "Socket error (%s)" @@ -624,14 +1158,13 @@ BEGIN Tcpip_SRedirectLimitError, "Exceeded maximal redirect limie %d" Baseutils_SNoValidPath, "Can't find any valid path." Baseutils_SUcpPathsNotSupported, "UNC paths are not supported." + Baseutils_SByte, "B" + Baseutils_SKiloByte, "KB" + Baseutils_SMegaByte, "MB" + Baseutils_SGigaByte, "GB" Customdirview_SErrorRenameFile, "Can't rename file or directory: " - System_Sysconst_SShortDayNameTue, "Tue" - System_Sysconst_SShortDayNameWed, "Wed" - System_Sysconst_SShortDayNameThu, "Thu" - System_Sysconst_SShortDayNameFri, "Fri" - System_Sysconst_SShortDayNameSat, "Sat" - System_Sysconst_SLongDayNameSun, "Sunday" - System_Sysconst_SLongDayNameMon, "Monday" + Customdirview_SErrorRenameFileExists, "File already exists: " + Customdirview_SErrorInvalidName, "Filename contains invalid characters:" System_Sysconst_SLongDayNameTue, "Tuesday" System_Sysconst_SLongDayNameWed, "Wednesday" System_Sysconst_SLongDayNameThu, "Thursday" @@ -641,13 +1174,13 @@ BEGIN System_Sysconst_SInvalidSourceArray, "Invalid source array" System_Sysconst_SInvalidDestinationArray, "Invalid destination array" System_Sysconst_SCharIndexOutOfBounds, "Character index out of bounds (%d)" - System_Sysconst_SShortMonthNameNov, "Nov" - System_Sysconst_SShortMonthNameDec, "Dec" - System_Sysconst_SLongMonthNameJan, "January" - System_Sysconst_SLongMonthNameFeb, "February" - System_Sysconst_SLongMonthNameMar, "March" - System_Sysconst_SLongMonthNameApr, "April" - System_Sysconst_SLongMonthNameMay, "May" + System_Sysconst_SByteIndexOutOfBounds, "Start index out of bounds (%d)" + System_Sysconst_SInvalidCharCount, "Invalid count (%d)" + System_Sysconst_SInvalidDestinationIndex, "Invalid destination index (%d)" + System_Sysconst_SInvalidCodePage, "Invalid code page" + System_Sysconst_SInvalidEncodingName, "Invalid encoding name" + System_Sysconst_SNoMappingForUnicodeCharacter, "No mapping for the Unicode character exists in the target multi-byte code page" + Comboedit_SBrowse, "Browse" System_Sysconst_SLongMonthNameJun, "June" System_Sysconst_SLongMonthNameJul, "July" System_Sysconst_SLongMonthNameAug, "August" @@ -657,13 +1190,13 @@ BEGIN System_Sysconst_SLongMonthNameDec, "December" System_Sysconst_SShortDayNameSun, "Sun" System_Sysconst_SShortDayNameMon, "Mon" - System_Sysconst_SNotImplemented, "Feature not implemented" - System_Sysconst_SAssertError, "%s (%s, line %d)" - System_Sysconst_SAbstractError, "Abstract Error" - System_Sysconst_SModuleAccessViolation, "Access violation at address %p in module '%s'. %s of address %p" - System_Sysconst_SOSError, "System Error. Code: %d.\r\n%s" - System_Sysconst_SUnkOSError, "A call to an OS function failed" - System_Sysconst_SShortMonthNameJan, "Jan" + System_Sysconst_SShortDayNameTue, "Tue" + System_Sysconst_SShortDayNameWed, "Wed" + System_Sysconst_SShortDayNameThu, "Thu" + System_Sysconst_SShortDayNameFri, "Fri" + System_Sysconst_SShortDayNameSat, "Sat" + System_Sysconst_SLongDayNameSun, "Sunday" + System_Sysconst_SLongDayNameMon, "Monday" System_Sysconst_SShortMonthNameFeb, "Feb" System_Sysconst_SShortMonthNameMar, "Mar" System_Sysconst_SShortMonthNameApr, "Apr" @@ -673,6 +1206,35 @@ BEGIN System_Sysconst_SShortMonthNameAug, "Aug" System_Sysconst_SShortMonthNameSep, "Sep" System_Sysconst_SShortMonthNameOct, "Oct" + System_Sysconst_SShortMonthNameNov, "Nov" + System_Sysconst_SShortMonthNameDec, "Dec" + System_Sysconst_SLongMonthNameJan, "January" + System_Sysconst_SLongMonthNameFeb, "February" + System_Sysconst_SLongMonthNameMar, "March" + System_Sysconst_SLongMonthNameApr, "April" + System_Sysconst_SLongMonthNameMay, "May" + System_Sysconst_SExternalException, "External exception %x" + System_Sysconst_SAssertionFailed, "Assertion failed" + System_Sysconst_SIntfCastError, "Interface not supported" + System_Sysconst_SSafecallException, "Exception in safecall method" + System_Sysconst_SMonitorLockException, "Object lock not owned" + System_Sysconst_SNoMonitorSupportException, "Monitor support function not initialized" + System_Sysconst_SNotImplemented, "Feature not implemented" + System_Sysconst_SObjectDisposed, "Method called on disposed object" + System_Sysconst_SAssertError, "%s (%s, line %d)" + System_Sysconst_SAbstractError, "Abstract Error" + System_Sysconst_SModuleAccessViolation, "Access violation at address %p in module '%s'. %s of address %p" + System_Sysconst_SCannotReadPackageInfo, "Cannot access package information for package '%s'" + System_Sysconst_sErrorLoadingPackage, "Can't load package %s.\r\n%s" + System_Sysconst_SOSError, "System Error. Code: %d.\r\n%s%s" + System_Sysconst_SUnkOSError, "A call to an OS function failed" + System_Sysconst_SShortMonthNameJan, "Jan" + System_Sysconst_SVarArrayLocked, "Variant or safe array is locked" + System_Sysconst_SInvalidVarCast, "Invalid variant type conversion" + System_Sysconst_SInvalidVarOp, "Invalid variant operation" + System_Sysconst_SInvalidVarNullOp, "Invalid NULL variant operation" + System_Sysconst_SInvalidVarOpWithHResultWithPrefix, "Invalid variant operation (%s%.8x)\n%s" + System_Sysconst_SVarTypeOutOfRangeWithPrefix, "Custom variant type (%s%.4x) is out of range" System_Sysconst_SVarTypeAlreadyUsedWithPrefix, "Custom variant type (%s%.4x) already used by %s" System_Sysconst_SVarTypeNotUsableWithPrefix, "Custom variant type (%s%.4x) is not usable" System_Sysconst_SVarTypeTooManyCustom, "Too many custom variant types have been registered" @@ -683,12 +1245,10 @@ BEGIN System_Sysconst_SVarBadType, "Invalid variant type" System_Sysconst_SVarNotImplemented, "Operation not supported" System_Sysconst_SVarUnexpected, "Unexpected variant error" - System_Sysconst_SExternalException, "External exception %x" - System_Sysconst_SAssertionFailed, "Assertion failed" - System_Sysconst_SIntfCastError, "Interface not supported" - System_Sysconst_SSafecallException, "Exception in safecall method" - System_Sysconst_SMonitorLockException, "Object lock not owned" - System_Sysconst_SNoMonitorSupportException, "Monitor support function not initialized" + System_Sysconst_SStackOverflow, "Stack overflow" + System_Sysconst_SControlC, "Control-C hit" + System_Sysconst_SPrivilege, "Privileged instruction" + System_Sysconst_SOperationAborted, "Operation aborted" System_Sysconst_SException, "Exception %s in module %s at %p.\r\n%s%s\r\n" System_Sysconst_SExceptTitle, "Application Error" System_Sysconst_SInvalidFormat, "Format '%s' invalid or incompatible with argument" @@ -696,15 +1256,15 @@ BEGIN System_Sysconst_SDispatchError, "Variant method calls not supported" System_Sysconst_SReadAccess, "Read" System_Sysconst_SWriteAccess, "Write" + System_Sysconst_SExecuteAccess, "Execution" + System_Sysconst_SInvalidAccess, "Invalid access" System_Sysconst_SFormatTooLong, "Format string too long" System_Sysconst_SVarArrayCreate, "Error creating variant or safe array" System_Sysconst_SVarArrayBounds, "Variant or safe array index out of bounds" - System_Sysconst_SVarArrayLocked, "Variant or safe array is locked" - System_Sysconst_SInvalidVarCast, "Invalid variant type conversion" - System_Sysconst_SInvalidVarOp, "Invalid variant operation" - System_Sysconst_SInvalidVarNullOp, "Invalid NULL variant operation" - System_Sysconst_SInvalidVarOpWithHResultWithPrefix, "Invalid variant operation (%s%.8x)\n%s" - System_Sysconst_SVarTypeOutOfRangeWithPrefix, "Custom variant type (%s%.4x) is out of range" + System_Sysconst_STooManyOpenFiles, "Too many open files" + System_Sysconst_SAccessDenied, "File access denied" + System_Sysconst_SEndOfFile, "Read beyond end of file" + System_Sysconst_SDiskFull, "Disk full" System_Sysconst_SInvalidInput, "Invalid numeric input" System_Sysconst_SDivByZero, "Division by zero" System_Sysconst_SRangeError, "Range check error" @@ -717,27 +1277,46 @@ BEGIN System_Sysconst_SInvalidCast, "Invalid class typecast" System_Sysconst_SAccessViolationArg3, "Access violation at address %p. %s of address %p" System_Sysconst_SAccessViolationNoArg, "Access violation" - System_Sysconst_SStackOverflow, "Stack overflow" - System_Sysconst_SControlC, "Control-C hit" - System_Sysconst_SPrivilege, "Privileged instruction" - System_Sysconst_SOperationAborted, "Operation aborted" - System_Rtlconsts_sObserverMultipleSingleCast, "Cannot have multiple single cast observers added to the observers collection" - System_Rtlconsts_sObserverNoInterface, "The object does not implement the observer interface" - System_Rtlconsts_sObserverNoSinglecastFound, "No single cast observer with ID %s was added to the observer collection" - System_Rtlconsts_sObserverNoMulticastFound, "No multi cast observer with ID %s was added to the observer collection" - System_Rtlconsts_sObserverNotAvailable, "Observer is not available" + System_Rtlconsts_SLocationSensorStarted, "The location sensor is started" + System_Rtlconsts_SInvalidDateString, "Invalid date string: %s" + System_Rtlconsts_SInvalidTimeString, "Invalid time string: %s" + System_Rtlconsts_SInvalidOffsetString, "Invalid time Offset string: %s" System_Sysconst_SUnknown, "" + System_Sysconst_SInvalidInteger, "'%s' is not a valid integer value" System_Sysconst_SInvalidFloat, "'%s' is not a valid floating point value" + System_Sysconst_SInvalidDate, "'%s' is not a valid date" + System_Sysconst_SInvalidTime, "'%s' is not a valid time" + System_Sysconst_SInvalidDateTime, "'%s' is not a valid date and time" System_Sysconst_SInvalidTimeStamp, "'%d.%d' is not a valid timestamp" System_Sysconst_SInvalidGUID, "'%s' is not a valid GUID value" + System_Sysconst_STimeEncodeError, "Invalid argument to time encode" System_Sysconst_SDateEncodeError, "Invalid argument to date encode" System_Sysconst_SOutOfMemory, "Out of memory" System_Sysconst_SInOutError, "I/O error %d" - System_Sysconst_STooManyOpenFiles, "Too many open files" - System_Sysconst_SAccessDenied, "File access denied" - System_Sysconst_SEndOfFile, "Read beyond end of file" - System_Sysconst_SDiskFull, "Disk full" + System_Rtlconsts_SWindows7, "Windows 7" + System_Rtlconsts_SWindowsServer2008R2, "Windows Server 2008 R2" + System_Rtlconsts_SWindows2000, "Windows 2000" + System_Rtlconsts_SWindowsXP, "Windows XP" + System_Rtlconsts_SWindowsServer2003, "Windows Server 2003" + System_Rtlconsts_SWindowsServer2003R2, "Windows Server 2003 R2" + System_Rtlconsts_SWindowsServer2012, "Windows Server 2012" + System_Rtlconsts_SWindowsServer2012R2, "Windows Server 2012 R2" + System_Rtlconsts_SWindows8, "Windows 8" + System_Rtlconsts_SWindows8Point1, "Windows 8.1" + System_Rtlconsts_sObserverUnsupported, "Observer is not supported" + System_Rtlconsts_sObserverMultipleSingleCast, "Cannot have multiple single cast observers added to the observers collection" + System_Rtlconsts_sObserverNoInterface, "The object does not implement the observer interface" + System_Rtlconsts_sObserverNoSinglecastFound, "No single cast observer with ID %d was added to the observer collection" + System_Rtlconsts_sObserverNoMulticastFound, "No multi cast observer with ID %d was added to the observer collection" + System_Rtlconsts_sObserverNotAvailable, "Observer is not available" + System_Rtlconsts_SNothingFound, "No help found for %s" + System_Rtlconsts_SArgumentOutOfRange, "Argument out of range" + System_Rtlconsts_SGenericItemNotFound, "Item not found" System_Rtlconsts_SGenericDuplicateItem, "Duplicates not allowed" + System_Rtlconsts_SInsufficientRtti, "Insufficient RTTI available to support this operation" + System_Rtlconsts_SParameterCountMismatch, "Parameter count mismatch" + System_Rtlconsts_SNonPublicType, "Type '%s' is not declared in the interface section of a unit" + System_Rtlconsts_SByRefArgMismatch, "VAR and OUT arguments must match parameter type exactly" System_Rtlconsts_SServiceNotFound, "Specified Login Credential Service not found" System_Rtlconsts_SVersionStr, "%s (Version %d.%d, Build %d, %5:s)" System_Rtlconsts_SSPVersionStr, "%s Service Pack %4:d (Version %1:d.%2:d, Build %3:d, %5:s)" @@ -746,45 +1325,45 @@ BEGIN System_Rtlconsts_SWindows, "Windows" System_Rtlconsts_SWindowsVista, "Windows Vista" System_Rtlconsts_SWindowsServer2008, "Windows Server 2008" - System_Rtlconsts_SWindows7, "Windows 7" - System_Rtlconsts_SWindowsServer2008R2, "Windows Server 2008 R2" - System_Rtlconsts_SWindows2000, "Windows 2000" - System_Rtlconsts_SWindowsXP, "Windows XP" - System_Rtlconsts_SWindowsServer2003, "Windows Server 2003" - System_Rtlconsts_SWindowsServer2003R2, "Windows Server 2003 R2" - System_Rtlconsts_sObserverUnsupported, "Observer is not supported" + System_Rtlconsts_sArgument_InvalidHighSurrogate, "High surrogate char without a following low surrogate char at index: %d. Check that the string is encoded properly" + System_Rtlconsts_sArgument_InvalidLowSurrogate, "Low surrogate char without a preceding high surrogate char at index: %d. Check that the string is encoded properly" + System_Rtlconsts_sInvalidStringAndObjectArrays, "Length of Strings and Objects arrays must be equal" + System_Rtlconsts_sInvalidTimeoutValue, "Invalid Timeout value: %s" + System_Rtlconsts_sTimespanTooLong, "Timespan too long" + System_Rtlconsts_sInvalidTimespanDuration, "The duration cannot be returned because the absolute value exceeds the value of TTimeSpan.MaxValue" + System_Rtlconsts_sTimespanValueCannotBeNan, "Value cannot be NaN" + System_Rtlconsts_sCannotNegateTimespan, "Negating the minimum value of a Timespan is invalid" System_Rtlconsts_sInvalidTimespanFormat, "Invalid Timespan format" System_Rtlconsts_sTimespanElementTooLong, "Timespan element too long" - System_Rtlconsts_SInvalidDate, "''%s'' is not a valid date" - System_Rtlconsts_SInvalidDateTime, "''%s'' is not a valid date and time" - System_Rtlconsts_SInvalidInteger, "''%s'' is not a valid integer value" - System_Rtlconsts_SInvalidTime, "''%s'' is not a valid time" - System_Rtlconsts_STimeEncodeError, "Invalid argument to time encode" System_Rtlconsts_SNoContext, "No context-sensitive help installed" System_Rtlconsts_SNoContextFound, "No help found for context %d" System_Rtlconsts_SNoIndex, "Unable to open Index" System_Rtlconsts_SNoSearch, "Unable to open Search" System_Rtlconsts_SNoTableOfContents, "Unable to find a Table of Contents" System_Rtlconsts_SNoTopics, "No topic-based help system installed" - System_Rtlconsts_SNothingFound, "No help found for %s" - System_Rtlconsts_SArgumentOutOfRange, "Argument out of range" - System_Rtlconsts_SGenericItemNotFound, "Item not found" + System_Rtlconsts_SThreadStartError, "Cannot call Start on a running or suspended thread" + System_Rtlconsts_SThreadExternalCheckTerminated, "Cannot call CheckTerminated on an externally created thread" + System_Rtlconsts_SThreadExternalSetReturnValue, "Cannot call SetReturnValue on an externally create thread" + System_Rtlconsts_SParamIsNil, "Parameter %s cannot be nil" + System_Rtlconsts_SParamIsNegative, "Parameter %s cannot be a negative value" + System_Rtlconsts_SInputBufferExceed, "Input buffer exceeded for %s = %d, %s = %d" + System_Rtlconsts_SInvalidCharsInPath, "Invalid characters in path" + System_Rtlconsts_SPathTooLong, "The specified path is too long" System_Rtlconsts_SPathNotFound, "The specified path was not found" System_Rtlconsts_SPathFormatNotSupported, "The path format is not supported" System_Rtlconsts_SDriveNotFound, "The drive cannot be found" System_Rtlconsts_SFileNotFound, "The specified file was not found" System_Rtlconsts_SLocalTimeInvalid, "The given \"%s\" local time is invalid (situated within the missing period prior to DST)." System_Rtlconsts_hNoFilterViewer, "No help viewer that supports filters" - System_Rtlconsts_sArgumentOutOfRange_StringIndex, "String index out of range (%d). Must be >= 1 and <= %d" + System_Rtlconsts_sArgumentOutOfRange_StringIndex, "String index out of range (%d). Must be >= %d and <= %d" System_Rtlconsts_sArgumentOutOfRange_InvalidUTF32, "Invalid UTF32 character value. Must be >= 0 and <= $10FFFF, excluding surrogate pair ranges" - System_Rtlconsts_sArgument_InvalidHighSurrogate, "High surrogate char without a following low surrogate char at index: %d. Check that the string is encoded properly" - System_Rtlconsts_sArgument_InvalidLowSurrogate, "Low surrogate char without a preceding high surrogate char at index: %d. Check that the string is encoded properly" - System_Rtlconsts_sInvalidStringAndObjectArrays, "Length of Strings and Objects arrays must be equal" - System_Rtlconsts_sInvalidTimeoutValue, "Invalid Timeout value: %s" - System_Rtlconsts_sTimespanTooLong, "Timespan too long" - System_Rtlconsts_sInvalidTimespanDuration, "The duration cannot be returned because the absolute value exceeds the value of TTimeSpan.MaxValue" - System_Rtlconsts_sTimespanValueCannotBeNan, "Value cannot be NaN" - System_Rtlconsts_sCannotNegateTimespan, "Negating the minimum value of a Timespan is invalid" + System_Rtlconsts_SRegCreateFailed, "Failed to create key %s" + System_Rtlconsts_SRegGetDataFailed, "Failed to get data for '%s'" + System_Rtlconsts_SRegisterError, "Invalid component registration" + System_Rtlconsts_SRegSetDataFailed, "Failed to set data for '%s'" + System_Rtlconsts_SResNotFound, "Resource %s not found" + System_Rtlconsts_SSeekNotImplemented, "%s.Seek not implemented" + System_Rtlconsts_SSortedListError, "Operation not allowed on sorted list" System_Rtlconsts_SStringExpected, "String expected" System_Rtlconsts_SSymbolExpected, "%s expected" System_Rtlconsts_SUnknownGroup, "%s not in a class registration group" @@ -794,13 +1373,13 @@ BEGIN System_Rtlconsts_SThreadError, "Thread Error: %s (%d)" System_Rtlconsts_SThreadExternalTerminate, "Cannot terminate an externally created thread" System_Rtlconsts_SThreadExternalWait, "Cannot wait for an externally created thread" - System_Rtlconsts_SThreadStartError, "Cannot call Start on a running or suspended thread" - System_Rtlconsts_SThreadExternalCheckTerminated, "Cannot call CheckTerminated on an externally created thread" - System_Rtlconsts_SThreadExternalSetReturnValue, "Cannot call SetReturnValue on an externally create thread" - System_Rtlconsts_SParamIsNegative, "Parameter %s cannot be a negative value" - System_Rtlconsts_SInputBufferExceed, "Input buffer exceeded for %s = %d, %s = %d" - System_Rtlconsts_SInvalidCharsInPath, "Invalid characters in path" - System_Rtlconsts_SPathTooLong, "The specified path is too long" + System_Rtlconsts_SInvalidPropertyPath, "Invalid property path" + System_Rtlconsts_SInvalidPropertyValue, "Invalid property value" + System_Rtlconsts_SInvalidRegType, "Invalid data type for '%s'" + System_Rtlconsts_SInvalidString, "Invalid string constant" + System_Rtlconsts_SLineTooLong, "Line too long" + System_Rtlconsts_SListCapacityError, "List capacity out of bounds (%d)" + System_Rtlconsts_SListCountError, "List count out of bounds (%d)" System_Rtlconsts_SListIndexError, "List index out of bounds (%d)" System_Rtlconsts_SMemoryStreamError, "Out of memory while expanding memory stream" System_Rtlconsts_SNoComSupport, "%s has not been registered as a COM class" @@ -810,13 +1389,13 @@ BEGIN System_Rtlconsts_SPropertyException, "Error reading %s%s%s: %s" System_Rtlconsts_SReadError, "Stream read error" System_Rtlconsts_SReadOnlyProperty, "Property is read-only" - System_Rtlconsts_SRegCreateFailed, "Failed to create key %s" - System_Rtlconsts_SRegGetDataFailed, "Failed to get data for '%s'" - System_Rtlconsts_SRegisterError, "Invalid component registration" - System_Rtlconsts_SRegSetDataFailed, "Failed to set data for '%s'" - System_Rtlconsts_SResNotFound, "Resource %s not found" - System_Rtlconsts_SSeekNotImplemented, "%s.Seek not implemented" - System_Rtlconsts_SSortedListError, "Operation not allowed on sorted list" + System_Rtlconsts_SCheckSynchronizeError, "CheckSynchronize called from thread $%x, which is NOT the main thread" + System_Rtlconsts_SClassNotFound, "Class %s not found" + System_Rtlconsts_SDuplicateClass, "A class named %s already exists" + System_Rtlconsts_SDuplicateItem, "List does not allow duplicates ($0%x)" + System_Rtlconsts_SDuplicateName, "A component named %s already exists" + System_Rtlconsts_SDuplicateString, "String list does not allow duplicates" + System_Rtlconsts_SFCreateErrorEx, "Cannot create file \"%s\". %s" System_Rtlconsts_SFOpenErrorEx, "Cannot open file \"%s\". %s" System_Rtlconsts_SIdentifierExpected, "Identifier expected" System_Rtlconsts_SIniFileWriteError, "Unable to write to %s" @@ -826,29 +1405,28 @@ BEGIN System_Rtlconsts_SInvalidMask, "'%s' is an invalid mask at (%d)" System_Rtlconsts_SInvalidName, "''%s'' is not a valid component name" System_Rtlconsts_SInvalidProperty, "Invalid property value" - System_Rtlconsts_SInvalidPropertyPath, "Invalid property path" - System_Rtlconsts_SInvalidPropertyValue, "Invalid property value" - System_Rtlconsts_SInvalidRegType, "Invalid data type for '%s'" - System_Rtlconsts_SInvalidString, "Invalid string constant" - System_Rtlconsts_SLineTooLong, "Line too long" - System_Rtlconsts_SListCapacityError, "List capacity out of bounds (%d)" - System_Rtlconsts_SListCountError, "List count out of bounds (%d)" + Vcl_Comstrs_sDateTimeMin, "Date is less than minimum of %s" + Vcl_Comstrs_sNeedAllowNone, "You must be in ShowCheckbox mode to set to this date" + Vcl_Comstrs_sFailSetCalDateTime, "Failed to set calendar date or time" + Vcl_Comstrs_sFailSetCalMaxSelRange, "Failed to set maximum selection range" + Vcl_Comstrs_sFailSetCalMinMaxRange, "Failed to set calendar min/max range" + Vcl_Comstrs_sFailsetCalSelRange, "Failed to set calendar selected range" System_Win_Comconst_SOleError, "OLE error %.8x" System_Win_Comconst_SNoMethod, "Method '%s' not supported by automation object" System_Win_Comconst_SVarNotObject, "Variant does not reference an automation object" System_Win_Comconst_STooManyParams, "Dispatch methods do not support more than 64 parameters" + System_Win_Comconst_SDCOMNotInstalled, "DCOM not installed" System_Rtlconsts_SAncestorNotFound, "Ancestor for '%s' not found" System_Rtlconsts_SAssignError, "Cannot assign a %s to a %s" System_Rtlconsts_SBitsIndexError, "Bits index out of range" System_Rtlconsts_SCantWriteResourceStreamError, "Can't write to a read-only resource stream" System_Rtlconsts_SCharExpected, "''%s'' expected" - System_Rtlconsts_SCheckSynchronizeError, "CheckSynchronize called from thread $%x, which is NOT the main thread" - System_Rtlconsts_SClassNotFound, "Class %s not found" - System_Rtlconsts_SDuplicateClass, "A class named %s already exists" - System_Rtlconsts_SDuplicateItem, "List does not allow duplicates ($0%x)" - System_Rtlconsts_SDuplicateName, "A component named %s already exists" - System_Rtlconsts_SDuplicateString, "String list does not allow duplicates" - System_Rtlconsts_SFCreateErrorEx, "Cannot create file \"%s\". %s" + Vcl_Comstrs_sTabFailGetObject, "Failed to get object at index %d" + Vcl_Comstrs_sTabFailSet, "Failed to set tab \"%s\" at index %d" + Vcl_Comstrs_sTabFailSetObject, "Failed to set object at index %d" + Vcl_Comstrs_sTabMustBeMultiLine, "MultiLine must be True when TabPosition is tpLeft or tpRight" + Vcl_Comstrs_sInvalidLevel, "Invalid item level assignment" + Vcl_Comstrs_sInvalidLevelEx, "Invalid level (%d) for item \"%s\"" Vcl_Comstrs_sInvalidIndex, "Invalid index" Vcl_Comstrs_sInsertError, "Unable to insert an item" Vcl_Comstrs_sInvalidOwner, "Invalid owner" @@ -859,32 +1437,22 @@ BEGIN Vcl_Comstrs_sPageIndexError, "%d is an invalid PageIndex value. PageIndex must be between 0 and %d" Vcl_Comstrs_sInvalidComCtl32, "This control requires version 4.70 or greater of COMCTL32.DLL" Vcl_Comstrs_sDateTimeMax, "Date exceeds maximum of %s" - Vcl_Comstrs_sDateTimeMin, "Date is less than minimum of %s" - Vcl_Comstrs_sNeedAllowNone, "You must be in ShowCheckbox mode to set to this date" - Vcl_Comstrs_sFailSetCalDateTime, "Failed to set calendar date or time" - Vcl_Comstrs_sFailSetCalMaxSelRange, "Failed to set maximum selection range" - Vcl_Comstrs_sFailSetCalMinMaxRange, "Failed to set calendar min/max range" - Vcl_Comstrs_sFailsetCalSelRange, "Failed to set calendar selected range" - Vcl_Consts_SStyleInvalidHandle, "Invalid style handle" - Vcl_Consts_SStyleFormatError, "Invalid style format" - Vcl_Consts_SStyleFileDescription, "VCL Style File" Vcl_Consts_SStyleHookClassNotRegistered, "Class '%s' is not registered for '%s'" Vcl_Consts_SStyleInvalidParameter, "%s parameter cannot be nil" Vcl_Consts_SStyleHookClassNotFound, "A StyleHook class has not been registered for %s" Vcl_Consts_SStyleFeatureNotSupported, "Feature not supported by this style" + Vcl_Consts_SStyleNotRegistered, "Style '%s' is not registered" + Vcl_Consts_SStyleUnregisterError, "Cannot unregister the system style" + Vcl_Consts_SStyleNotRegisteredNoName, "Style not registered" + Vcl_Oleconst_SBadPropValue, "'%s' is not a valid property value" + Vcl_Oleconst_SCannotActivate, "OLE control activation failed" + Vcl_Oleconst_SNoWindowHandle, "Could not obtain OLE control window handle" + Vcl_Oleconst_SInvalidLicense, "License information for %s is invalid" + Vcl_Oleconst_SNotLicensed, "License information for %s not found. You cannot use this control in design mode" + Vcl_Oleconst_sNoRunningObject, "Unable to retrieve a pointer to a running object registered with OLE for %s/%s" Vcl_Comstrs_sTabFailClear, "Failed to clear tab control" Vcl_Comstrs_sTabFailDelete, "Failed to delete tab at index %d" Vcl_Comstrs_sTabFailRetrieve, "Failed to retrieve tab at index %d" - Vcl_Comstrs_sTabFailGetObject, "Failed to get object at index %d" - Vcl_Comstrs_sTabFailSet, "Failed to set tab \"%s\" at index %d" - Vcl_Comstrs_sTabFailSetObject, "Failed to set object at index %d" - Vcl_Comstrs_sTabMustBeMultiLine, "MultiLine must be True when TabPosition is tpLeft or tpRight" - Vcl_Comstrs_sInvalidLevel, "Invalid item level assignment" - Vcl_Comstrs_sInvalidLevelEx, "Invalid level (%d) for item \"%s\"" - Vcl_Consts_SUTF7Encoding, "UTF-7" - Vcl_Consts_STrayIconRemoveError, "Cannot remove shell notification icon" - Vcl_Consts_SPageControlNotSet, "PageControl must first be assigned" - Vcl_Consts_SWindowsVistaRequired, "%s requires Windows Vista or later" Vcl_Consts_STaskDlgButtonCaption, "Button%d" Vcl_Consts_STaskDlgRadioButtonCaption, "RadioButton%d" Vcl_Consts_SInvalidTaskDlgButtonCaption, "Caption cannot be empty" @@ -897,10 +1465,10 @@ BEGIN Vcl_Consts_SStyleClassRegisterError, "Style class '%s' already registered" Vcl_Consts_SStyleNotFound, "Style '%s' not found" Vcl_Consts_SStyleClassNotFound, "Style class '%s' not found" - Vcl_Consts_SPromptArrayTooShort, "Length of value array must be >= length of prompt array" - Vcl_Consts_SPromptArrayEmpty, "Prompt array must not be empty" - Vcl_Consts_SUsername, "&Username" - Vcl_Consts_SPassword, "&Password" + Vcl_Consts_SStyleInvalidHandle, "Invalid style handle" + Vcl_Consts_SStyleFormatError, "Invalid style format" + Vcl_Consts_SStyleFileDescription, "VCL Style File" + Vcl_Consts_SStyleHookClassRegistered, "Class '%s' is already registered for '%s'" Vcl_Consts_SDomain, "&Domain" Vcl_Consts_SLogin, "Login" Vcl_Consts_SSeparator, "Separator" @@ -913,10 +1481,10 @@ BEGIN Vcl_Consts_SUnicodeEncoding, "Unicode" Vcl_Consts_SBigEndianEncoding, "Big Endian Unicode" Vcl_Consts_SUTF8Encoding, "UTF-8" - Vcl_Consts_SIconToClipboard, "Clipboard does not support Icons" - Vcl_Consts_SCannotOpenClipboard, "Cannot open clipboard: %s" - Vcl_Consts_SInvalidMemoSize, "Text exceeds memo capacity" - Vcl_Consts_SInvalidPrinterOp, "Operation not supported on selected printer" + Vcl_Consts_SUTF7Encoding, "UTF-7" + Vcl_Consts_STrayIconRemoveError, "Cannot remove shell notification icon" + Vcl_Consts_SPageControlNotSet, "PageControl must first be assigned" + Vcl_Consts_SWindowsVistaRequired, "%s requires Windows Vista or later" Vcl_Consts_SNoDefaultPrinter, "There is no default printer currently selected" Vcl_Consts_SDuplicateMenus, "Menu '%s' is already being used by another form" Vcl_Consts_SPictureLabel, "Picture:" @@ -929,10 +1497,10 @@ BEGIN Vcl_Consts_SDockZoneHasNoCtl, " - Dock zone has no control" Vcl_Consts_SDockZoneVersionConflict, "Error loading dock zone from the stream. Expecting version %d, but found %d." Vcl_Consts_SMultiSelectRequired, "Multiselect mode must be on for this feature" - Vcl_Consts_SmkcEnd, "End" - Vcl_Consts_SmkcHome, "Home" - Vcl_Consts_SmkcLeft, "Left" - Vcl_Consts_SmkcUp, "Up" + Vcl_Consts_SPromptArrayTooShort, "Length of value array must be >= length of prompt array" + Vcl_Consts_SPromptArrayEmpty, "Prompt array must not be empty" + Vcl_Consts_SUsername, "&Username" + Vcl_Consts_SPassword, "&Password" Vcl_Consts_SmkcRight, "Right" Vcl_Consts_SmkcDown, "Down" Vcl_Consts_SmkcIns, "Ins" @@ -945,10 +1513,10 @@ BEGIN Vcl_Consts_sAllFilter, "All" Vcl_Consts_SInsertLineError, "Unable to insert a line" Vcl_Consts_SInvalidClipFmt, "Invalid clipboard format" - Vcl_Consts_SMsgDlgCancel, "Cancel" - Vcl_Consts_SMsgDlgHelp, "&Help" - Vcl_Consts_SMsgDlgAbort, "&Abort" - Vcl_Consts_SMsgDlgRetry, "&Retry" + Vcl_Consts_SIconToClipboard, "Clipboard does not support Icons" + Vcl_Consts_SCannotOpenClipboard, "Cannot open clipboard: %s" + Vcl_Consts_SInvalidMemoSize, "Text exceeds memo capacity" + Vcl_Consts_SInvalidPrinterOp, "Operation not supported on selected printer" Vcl_Consts_SMsgDlgIgnore, "&Ignore" Vcl_Consts_SMsgDlgAll, "&All" Vcl_Consts_SMsgDlgNoToAll, "N&o to All" @@ -961,10 +1529,10 @@ BEGIN Vcl_Consts_SmkcSpace, "Space" Vcl_Consts_SmkcPgUp, "PgUp" Vcl_Consts_SmkcPgDn, "PgDn" - Vcl_Consts_SVTIFFImages, "TIFF Images" - Vcl_Consts_SGridTooLarge, "Grid too large for operation" - Vcl_Consts_STooManyDeleted, "Too many rows or columns deleted" - Vcl_Consts_SIndexOutOfRange, "Grid index out of range" + Vcl_Consts_SmkcEnd, "End" + Vcl_Consts_SmkcHome, "Home" + Vcl_Consts_SmkcLeft, "Left" + Vcl_Consts_SmkcUp, "Up" Vcl_Consts_SFixedColTooBig, "Fixed column count must be less than column count" Vcl_Consts_SFixedRowTooBig, "Fixed row count must be less than row count" Vcl_Consts_SInvalidStringGridOp, "Cannot insert or delete rows from grid" @@ -977,6 +1545,10 @@ BEGIN Vcl_Consts_SMsgDlgYes, "&Yes" Vcl_Consts_SMsgDlgNo, "&No" Vcl_Consts_SMsgDlgOK, "OK" + Vcl_Consts_SMsgDlgCancel, "Cancel" + Vcl_Consts_SMsgDlgHelp, "&Help" + Vcl_Consts_SMsgDlgAbort, "&Abort" + Vcl_Consts_SMsgDlgRetry, "&Retry" Vcl_Consts_SNoButton, "&No" Vcl_Consts_SHelpButton, "&Help" Vcl_Consts_SCloseButton, "&Close" @@ -985,14 +1557,14 @@ BEGIN Vcl_Consts_SAbortButton, "Abort" Vcl_Consts_SAllButton, "&All" Vcl_Consts_SCannotDragForm, "Cannot drag a form" - Vcl_Consts_SDdeErr, "An error returned from DDE ($0%x)" - Vcl_Consts_SDdeConvErr, "DDE Error - conversation not established ($0%x)" - Vcl_Consts_SDdeMemErr, "Error occurred when DDE ran out of memory ($0%x)" - Vcl_Consts_SDdeNoConnect, "Unable to connect DDE conversation" Vcl_Consts_SVMetafiles, "Metafiles" Vcl_Consts_SVEnhMetafiles, "Enhanced Metafiles" Vcl_Consts_SVIcons, "Icons" Vcl_Consts_SVBitmaps, "Bitmaps" + Vcl_Consts_SVTIFFImages, "TIFF Images" + Vcl_Consts_SGridTooLarge, "Grid too large for operation" + Vcl_Consts_STooManyDeleted, "Too many rows or columns deleted" + Vcl_Consts_SIndexOutOfRange, "Grid index out of range" Vcl_Consts_SMenuIndexError, "Menu index out of range" Vcl_Consts_SMenuReinserted, "Menu inserted twice" Vcl_Consts_SMenuNotFound, "Sub-menu is not in menu" diff --git a/source/WinSCP.groupproj b/source/WinSCP.groupproj index 183d20f5..8b11deb2 100644 --- a/source/WinSCP.groupproj +++ b/source/WinSCP.groupproj @@ -18,6 +18,9 @@ + + + @@ -98,6 +101,15 @@ + + + + + + + + + @@ -180,13 +192,13 @@ - + - + - + diff --git a/source/components/UnixDirView.cpp b/source/components/UnixDirView.cpp index c51048cc..4b0c76cd 100644 --- a/source/components/UnixDirView.cpp +++ b/source/components/UnixDirView.cpp @@ -415,7 +415,7 @@ void __fastcall TUnixDirView::LoadFiles() // this is out of date // (missing columns and does not update then file properties are loaded) Item->ImageIndex = File->IconIndex; - Item->SubItems->Add(!File->IsDirectory ? FormatBytes(File->Size, FormatSizeBytes, FormatSizeBytes) : UnicodeString()); + Item->SubItems->Add(!File->IsDirectory ? FormatPanelBytes(File->Size, FormatSizeBytes) : UnicodeString()); Item->SubItems->Add(File->UserModificationStr); Item->SubItems->Add(File->RightsStr); Item->SubItems->Add(File->Owner.DisplayText); @@ -448,7 +448,7 @@ void __fastcall TUnixDirView::GetDisplayInfo(TListItem * Item, tagLVITEMW &DispI // expanded from ?: to avoid memory leaks if (!File->IsDirectory) { - Value = FormatBytes(File->Size, FormatSizeBytes, FormatSizeBytes); + Value = FormatPanelBytes(File->Size, FormatSizeBytes); } break; case uvChanged: Value = File->UserModificationStr; break; @@ -458,7 +458,7 @@ void __fastcall TUnixDirView::GetDisplayInfo(TListItem * Item, tagLVITEMW &DispI case uvExt: Value = File->Extension; break; case uvLinkTarget: Value = File->LinkTo; break; case uvType: Value = File->TypeName; break; - default: assert(false); + default: FAIL; } StrPLCopy(DispInfo.pszText, Value, DispInfo.cchTextMax); } @@ -715,7 +715,7 @@ void __fastcall TUnixDirView::SortItems() case uvExt: SortProc = (PFNLVCOMPARE)CompareExtension; break; case uvLinkTarget: SortProc = (PFNLVCOMPARE)CompareLinkTo; break; case uvType: SortProc = (PFNLVCOMPARE)CompareTypeName; break; - default: assert(false); + default: FAIL; } CustomSortItems(SortProc); } @@ -794,24 +794,20 @@ void __fastcall TUnixDirView::ChangeDirectory(UnicodeString Path) try { FDirLoadedAfterChangeDir = false; - APPLICATION_EXCEPTION_HACK_BEGIN + if (Path == HOMEDIRECTORY) { - if (Path == HOMEDIRECTORY) - { - Terminal->HomeDirectory(); - } - else - // this works even with LockInHome - if (Path == ROOTDIRECTORY) - { - Terminal->CurrentDirectory = ROOTDIRECTORY; - } - else - { - Terminal->ChangeDirectory(Path); - } + Terminal->HomeDirectory(); + } + else + // this works even with LockInHome + if (Path == ROOTDIRECTORY) + { + Terminal->CurrentDirectory = ROOTDIRECTORY; + } + else + { + Terminal->ChangeDirectory(Path); } - APPLICATION_EXCEPTION_HACK_END; } __finally { diff --git a/source/components/UnixDirView.h b/source/components/UnixDirView.h index cf962826..ff1e2b80 100644 --- a/source/components/UnixDirView.h +++ b/source/components/UnixDirView.h @@ -116,10 +116,7 @@ friend class TCustomUnixDriveView; __property AddParentDir; __property DimmHiddenFiles; - __property ShowDirectories; - __property ShowSubDirSize; __property ShowHiddenFiles; - __property SingleClickToExec; __property WantUseDragImages; __property TargetPopupMenu; __property OnSelectItem; @@ -148,8 +145,6 @@ friend class TCustomUnixDriveView; __property OnDDMenuPopup; __property OnContextPopup; - __property OnBeginRename; - __property OnEndRename; __property OnHistoryChange; __property OnHistoryGo; __property OnPathChange; diff --git a/source/components/UnixDriveView.cpp b/source/components/UnixDriveView.cpp index 18fd9f2f..cfbe5127 100644 --- a/source/components/UnixDriveView.cpp +++ b/source/components/UnixDriveView.cpp @@ -176,7 +176,7 @@ void __fastcall TCustomUnixDriveView::UpdatePath(TTreeNode * Node, bool Force, TStringList * ChildrenDirs = new TStringList(); try { - ChildrenDirs->Duplicates = dupAccept; + ChildrenDirs->Duplicates = Types::dupAccept; ChildrenDirs->CaseSensitive = true; TTreeNode * ChildNode = Node->getFirstChild(); @@ -472,11 +472,7 @@ void __fastcall TCustomUnixDriveView::Change(TTreeNode * Node) FDirectoryLoaded = false; try { - APPLICATION_EXCEPTION_HACK_BEGIN - { - Terminal->ChangeDirectory(NodePathName(Node)); - } - APPLICATION_EXCEPTION_HACK_END; + Terminal->ChangeDirectory(NodePathName(Node)); TCustomDriveView::Change(Node); } __finally diff --git a/source/core/Bookmarks.cpp b/source/core/Bookmarks.cpp index 6acbc827..a638c509 100644 --- a/source/core/Bookmarks.cpp +++ b/source/core/Bookmarks.cpp @@ -16,7 +16,7 @@ __fastcall TBookmarks::TBookmarks(): TObject() FBookmarkLists = new TStringList(); FBookmarkLists->Sorted = true; FBookmarkLists->CaseSensitive = false; - FBookmarkLists->Duplicates = dupError; + FBookmarkLists->Duplicates = Types::dupError; } //--------------------------------------------------------------------------- __fastcall TBookmarks::~TBookmarks() diff --git a/source/core/Common.cpp b/source/core/Common.cpp index 40ce7771..a2fbb4af 100644 --- a/source/core/Common.cpp +++ b/source/core/Common.cpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include //--------------------------------------------------------------------------- #pragma package(smart_init) //--------------------------------------------------------------------------- @@ -53,6 +55,7 @@ const wchar_t TokenPrefix = L'%'; const wchar_t NoReplacement = wchar_t(false); const wchar_t TokenReplacement = wchar_t(true); const UnicodeString LocalInvalidChars = L"/\\:*?\"<>|"; +const UnicodeString PasswordMask = L"***"; //--------------------------------------------------------------------------- UnicodeString ReplaceChar(UnicodeString Str, wchar_t A, wchar_t B) { @@ -678,6 +681,267 @@ bool __fastcall IsReservedName(UnicodeString FileName) return false; } //--------------------------------------------------------------------------- +// ApiPath support functions +// Inspired by +// http://stackoverflow.com/questions/18580945/need-clarification-for-converting-paths-into-long-unicode-paths-or-the-ones-star +// This can be reimplemented using PathCchCanonicalizeEx on Windows 8 and later +enum PATH_PREFIX_TYPE +{ + PPT_UNKNOWN, + PPT_ABSOLUTE, //Found absolute path that is none of the other types + PPT_UNC, //Found \\server\share\ prefix + PPT_LONG_UNICODE, //Found \\?\ prefix + PPT_LONG_UNICODE_UNC, //Found \\?\UNC\ prefix +}; +//--------------------------------------------------------------------------- +static int __fastcall PathRootLength(UnicodeString Path) +{ + // Correction for PathSkipRoot API + + // Replace all /'s with \'s because PathSkipRoot can't handle /'s + UnicodeString Result = ReplaceChar(Path, L'/', L'\\'); + + // Now call the API + LPCTSTR Buffer = PathSkipRoot(Result.c_str()); + + return (Buffer != NULL) ? (Buffer - Result.c_str()) : -1; +} +//--------------------------------------------------------------------------- +static bool __fastcall PathIsRelative_CorrectedForMicrosoftStupidity(UnicodeString Path) +{ + // Correction for PathIsRelative API + + // Replace all /'s with \'s because PathIsRelative can't handle /'s + UnicodeString Result = ReplaceChar(Path, L'/', L'\\'); + + //Now call the API + return PathIsRelative(Result.c_str()); +} +//--------------------------------------------------------------------------- +static int __fastcall GetOffsetAfterPathRoot(UnicodeString Path, PATH_PREFIX_TYPE & PrefixType) +{ + // Checks if 'pPath' begins with the drive, share, prefix, etc + // EXAMPLES: + // Path Return: Points at: PrefixType: + // Relative\Folder\File.txt 0 Relative\Folder\File.txt PPT_UNKNOWN + // \RelativeToRoot\Folder 1 RelativeToRoot\Folder PPT_ABSOLUTE + // C:\Windows\Folder 3 Windows\Folder PPT_ABSOLUTE + // \\server\share\Desktop 15 Desktop PPT_UNC + // \\?\C:\Windows\Folder 7 Windows\Folder PPT_LONG_UNICODE + // \\?\UNC\server\share\Desktop 21 Desktop PPT_LONG_UNICODE_UNC + // RETURN: + // = Index in 'pPath' after the root, or + // = 0 if no root was found + int Result = 0; + + PrefixType = PPT_UNKNOWN; + + if (!Path.IsEmpty()) + { + int Len = Path.Length(); + + bool WinXPOnly = !IsWinVista(); + + // The PathSkipRoot() API doesn't work correctly on Windows XP + if (!WinXPOnly) + { + // Works since Vista and up, but still needs correction :) + int RootLength = PathRootLength(Path); + if (RootLength >= 0) + { + Result = RootLength + 1; + } + } + + // Now determine the type of prefix + int IndCheckUNC = -1; + + if ((Len >= 8) && + (Path[1] == L'\\' || Path[1] == L'/') && + (Path[2] == L'\\' || Path[2] == L'/') && + (Path[3] == L'?') && + (Path[4] == L'\\' || Path[4] == L'/') && + (Path[5] == L'U' || Path[5] == L'u') && + (Path[6] == L'N' || Path[6] == L'n') && + (Path[7] == L'C' || Path[7] == L'c') && + (Path[8] == L'\\' || Path[8] == L'/')) + { + // Found \\?\UNC\ prefix + PrefixType = PPT_LONG_UNICODE_UNC; + + if (WinXPOnly) + { + //For older OS + Result += 8; + } + + //Check for UNC share later + IndCheckUNC = 8; + } + else if ((Len >= 4) && + (Path[1] == L'\\' || Path[1] == L'/') && + (Path[2] == L'\\' || Path[2] == L'/') && + (Path[3] == L'?') && + (Path[4] == L'\\' || Path[4] == L'/')) + { + // Found \\?\ prefix + PrefixType = PPT_LONG_UNICODE; + + if (WinXPOnly) + { + //For older OS + Result += 4; + } + } + else if ((Len >= 2) && + (Path[1] == L'\\' || Path[1] == L'/') && + (Path[2] == L'\\' || Path[2] == L'/')) + { + // Check for UNC share later + IndCheckUNC = 2; + } + + if (IndCheckUNC >= 0) + { + // Check for UNC, i.e. \\server\share\ part + int Index = IndCheckUNC; + for (int SkipSlashes = 2; SkipSlashes > 0; SkipSlashes--) + { + for(; Index <= Len; Index++) + { + TCHAR z = Path[Index]; + if ((z == L'\\') || (z == L'/') || (Index >= Len)) + { + Index++; + if (SkipSlashes == 1) + { + if (PrefixType == PPT_UNKNOWN) + { + PrefixType = PPT_UNC; + } + + if (WinXPOnly) + { + //For older OS + Result = Index; + } + } + + break; + } + } + } + } + + if (WinXPOnly) + { + // Only if we didn't determine any other type + if (PrefixType == PPT_UNKNOWN) + { + if (!PathIsRelative_CorrectedForMicrosoftStupidity(Path.SubString(Result, Path.Length() - Result + 1))) + { + PrefixType = PPT_ABSOLUTE; + } + } + + // For older OS only + int RootLength = PathRootLength(Path.SubString(Result, Path.Length() - Result + 1)); + if (RootLength >= 0) + { + Result = RootLength + 1; + } + } + else + { + // Only if we didn't determine any other type + if (PrefixType == PPT_UNKNOWN) + { + if (!PathIsRelative_CorrectedForMicrosoftStupidity(Path)) + { + PrefixType = PPT_ABSOLUTE; + } + } + } + } + + return Result; +} +//--------------------------------------------------------------------------- +UnicodeString __fastcall MakeUnicodeLargePath(UnicodeString Path) +{ + // Convert path from 'into a larger Unicode path, that allows up to 32,767 character length + UnicodeString Result; + + if (!Path.IsEmpty()) + { + // Determine the type of the existing prefix + PATH_PREFIX_TYPE PrefixType; + GetOffsetAfterPathRoot(Path, PrefixType); + + // Assume path to be without change + Result = Path; + + switch (PrefixType) + { + case PPT_ABSOLUTE: + { + // First we need to check if its an absolute path relative to the root + bool AddPrefix = true; + if ((Path.Length() >= 1) && + ((Path[1] == L'\\') || (Path[1] == L'/'))) + { + AddPrefix = FALSE; + + // Get current root path + UnicodeString CurrentDir = GetCurrentDir(); + PATH_PREFIX_TYPE PrefixType2; // unused + int Following = GetOffsetAfterPathRoot(CurrentDir, PrefixType2); + if (Following > 0) + { + AddPrefix = true; + Result = CurrentDir.SubString(1, Following - 1) + Result.SubString(2, Result.Length() - 1); + } + } + + if (AddPrefix) + { + // Add \\?\ prefix + Result = L"\\\\?\\" + Result; + } + } + break; + + case PPT_UNC: + // First we need to remove the opening slashes for UNC share + if ((Result.Length() >= 2) && + ((Result[1] == L'\\') || (Result[1] == L'/')) && + ((Result[2] == L'\\') || (Result[2] == L'/'))) + { + Result = Result.SubString(3, Result.Length() - 2); + } + + // Add \\?\UNC\ prefix + Result = L"\\\\?\\UNC\\" + Result; + break; + } + } + + return Result; +} +//--------------------------------------------------------------------------- +UnicodeString __fastcall ApiPath(UnicodeString Path) +{ + if (Path.Length() >= MAX_PATH) + { + if (Configuration != NULL) + { + Configuration->Usage->Inc(L"LongPath"); + } + Path = MakeUnicodeLargePath(Path); + } + return Path; +} +//--------------------------------------------------------------------------- UnicodeString __fastcall DisplayableStr(const RawByteString & Str) { bool Displayable = true; @@ -854,7 +1118,7 @@ int __fastcall FindCheck(int Result, const UnicodeString & Path) int __fastcall FindFirstUnchecked(const UnicodeString & Path, int Attr, TSearchRecChecked & F) { F.Path = Path; - return FindFirst(Path, Attr, F); + return FindFirst(ApiPath(Path), Attr, F); } //--------------------------------------------------------------------------- int __fastcall FindFirstChecked(const UnicodeString & Path, int Attr, TSearchRecChecked & F) @@ -874,7 +1138,7 @@ int __fastcall FindNextChecked(TSearchRecChecked & F) bool __fastcall FileSearchRec(const UnicodeString FileName, TSearchRec & Rec) { int FindAttrs = faReadOnly | faHidden | faSysFile | faDirectory | faArchive; - bool Result = (FindFirst(FileName, FindAttrs, Rec) == 0); + bool Result = (FindFirst(ApiPath(FileName), FindAttrs, Rec) == 0); if (Result) { FindClose(Rec); @@ -958,7 +1222,8 @@ struct TDateTimeParams TDateTime UnixEpoch; double BaseDifference; long BaseDifferenceSec; - // All Current* are actually global, not per-year + // All Current* are actually global, not per-year and + // are valid for Year 0 (current) only double CurrentDaylightDifference; long CurrentDaylightDifferenceSec; double CurrentDifference; @@ -1104,6 +1369,7 @@ static void __fastcall EncodeDSTMargin(const SYSTEMTIME & Date, unsigned short Y TDateTime Temp = EncodeDateVerbose(Year, Date.wMonth, 1); Result = Temp + ((Date.wDayOfWeek - DayOfWeek(Temp) + 8) % 7) + (7 * (Date.wDay - 1)); + // Day 5 means, the last occurence of day-of-week in month if (Date.wDay == 5) { unsigned short Month = static_cast(Date.wMonth + 1); @@ -1656,7 +1922,8 @@ bool __fastcall RecursiveDeleteFile(const UnicodeString FileName, bool ToRecycle memset(&Data, 0, sizeof(Data)); Data.hwnd = NULL; Data.wFunc = FO_DELETE; - UnicodeString FileList(FileName); + // SHFileOperation does not support long paths anyway + UnicodeString FileList(ApiPath(FileName)); FileList.SetLength(FileList.Length() + 2); FileList[FileList.Length() - 1] = L'\0'; FileList[FileList.Length()] = L'\0'; @@ -1687,7 +1954,7 @@ bool __fastcall RecursiveDeleteFile(const UnicodeString FileName, bool ToRecycle //--------------------------------------------------------------------------- void __fastcall DeleteFileChecked(const UnicodeString & FileName) { - if (!DeleteFile(FileName)) + if (!DeleteFile(ApiPath(FileName))) { throw EOSExtException(FMTLOAD(DELETE_LOCAL_FILE_ERROR, (FileName))); } @@ -1714,7 +1981,7 @@ unsigned int __fastcall CancelAnswer(unsigned int Answers) } else { - assert(false); + FAIL; Result = qaCancel; } return Result; @@ -1863,18 +2130,10 @@ UnicodeString __fastcall DoEncodeUrl(UnicodeString S, UnicodeString Chars) return S; } //--------------------------------------------------------------------------- -UnicodeString __fastcall EncodeUrlChars(UnicodeString S, UnicodeString Ignore) +// we should probably replace all uses with EncodeUrlString +UnicodeString __fastcall EncodeUrlChars(UnicodeString S) { - UnicodeString Chars; - if (Ignore.Pos(L' ') == 0) - { - Chars += L' '; - } - if (Ignore.Pos(L'/') == 0) - { - Chars += L'/'; - } - return DoEncodeUrl(S, Chars); + return DoEncodeUrl(S, L" /"); } //--------------------------------------------------------------------------- UnicodeString __fastcall NonUrlChars() @@ -1902,6 +2161,17 @@ UnicodeString __fastcall EncodeUrlString(UnicodeString S) return DoEncodeUrl(S, NonUrlChars()); } //--------------------------------------------------------------------------- +UnicodeString __fastcall EncodeUrlPath(UnicodeString S) +{ + UnicodeString Ignore = NonUrlChars(); + int P = Ignore.Pos(L"/"); + if (ALWAYS_TRUE(P > 0)) + { + Ignore.Delete(P, 1); + } + return DoEncodeUrl(S, Ignore); +} +//--------------------------------------------------------------------------- UnicodeString __fastcall AppendUrlParams(UnicodeString AURL, UnicodeString Params) { // see also TWebHelpSystem::ShowHelp @@ -2095,7 +2365,7 @@ bool __fastcall IsDirectoryWriteable(const UnicodeString & Path) UnicodeString FileName = IncludeTrailingPathDelimiter(Path) + FORMAT(L"wscp_%s_%d.tmp", (FormatDateTime(L"nnzzz", Now()), int(GetCurrentProcessId()))); - HANDLE Handle = CreateFile(FileName.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, + HANDLE Handle = CreateFile(ApiPath(FileName).c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE, 0); bool Result = (Handle != INVALID_HANDLE_VALUE); if (Result) @@ -2121,5 +2391,38 @@ UnicodeString __fastcall ExtractFileBaseName(const UnicodeString & Path) return ChangeFileExt(ExtractFileName(Path), L""); } //--------------------------------------------------------------------------- -// Suppress warning about unused constants in DateUtils.hpp -#pragma warn -8080 +TStringList * __fastcall TextToStringList(const UnicodeString & Text) +{ + std::unique_ptr List(new TStringList()); + List->Text = Text; + return List.release(); +} +//--------------------------------------------------------------------------- +UnicodeString __fastcall TrimVersion(UnicodeString Version) +{ + while ((Version.Pos(L".") != Version.LastDelimiter(L".")) && + (Version.SubString(Version.Length() - 1, 2) == L".0")) + { + Version.SetLength(Version.Length() - 2); + } + return Version; +} +//--------------------------------------------------------------------------- +UnicodeString __fastcall FormatVersion(int MajovVersion, int MinorVersion, int Release) +{ + return + TrimVersion(FORMAT(L"%d.%d.%d", + (MajovVersion, MinorVersion, Release))); +} +//--------------------------------------------------------------------------- +TFormatSettings __fastcall GetEngFormatSettings() +{ + return TFormatSettings::Create((TLocaleID)1033); +} +//--------------------------------------------------------------------------- +int __fastcall ParseShortEngMonthName(const UnicodeString & MonthStr) +{ + TFormatSettings FormatSettings = GetEngFormatSettings(); + return IndexStr(MonthStr, FormatSettings.ShortMonthNames, FormatSettings.ShortMonthNames.Size()) + 1; +} +//--------------------------------------------------------------------------- diff --git a/source/core/Common.h b/source/core/Common.h index ac47ff36..ce6ada92 100644 --- a/source/core/Common.h +++ b/source/core/Common.h @@ -28,6 +28,7 @@ extern const wchar_t TokenPrefix; extern const wchar_t NoReplacement; extern const wchar_t TokenReplacement; extern const UnicodeString LocalInvalidChars; +extern const UnicodeString PasswordMask; //--------------------------------------------------------------------------- UnicodeString ReplaceChar(UnicodeString Str, wchar_t A, wchar_t B); UnicodeString DeleteChar(UnicodeString Str, wchar_t C); @@ -71,6 +72,7 @@ UnicodeString __fastcall ExpandEnvironmentVariables(const UnicodeString & Str); bool __fastcall ComparePaths(const UnicodeString & Path1, const UnicodeString & Path2); bool __fastcall CompareFileName(const UnicodeString & Path1, const UnicodeString & Path2); bool __fastcall IsReservedName(UnicodeString FileName); +UnicodeString __fastcall ApiPath(UnicodeString Path); UnicodeString __fastcall DisplayableStr(const RawByteString & Str); UnicodeString __fastcall ByteToHex(unsigned char B, bool UpperCase = true); UnicodeString __fastcall BytesToHex(const unsigned char * B, size_t Length, bool UpperCase = true, wchar_t Separator = L'\0'); @@ -84,9 +86,10 @@ bool __fastcall IsLetter(wchar_t Ch); bool __fastcall IsDigit(wchar_t Ch); bool __fastcall IsHex(wchar_t Ch); UnicodeString __fastcall DecodeUrlChars(UnicodeString S); -UnicodeString __fastcall EncodeUrlChars(UnicodeString S, UnicodeString Ignore = L""); +UnicodeString __fastcall EncodeUrlChars(UnicodeString S); UnicodeString __fastcall EncodeUrlString(UnicodeString S); -UnicodeString __fastcall AppendUrlParams(UnicodeString AURL, UnicodeString Params); +UnicodeString __fastcall EncodeUrlPath(UnicodeString S); +UnicodeString __fastcall AppendUrlParams(UnicodeString URL, UnicodeString Params); bool __fastcall RecursiveDeleteFile(const UnicodeString FileName, bool ToRecycleBin); void __fastcall DeleteFileChecked(const UnicodeString & FileName); unsigned int __fastcall CancelAnswer(unsigned int Answers); @@ -112,6 +115,11 @@ bool __fastcall IsDirectoryWriteable(const UnicodeString & Path); UnicodeString __fastcall FormatNumber(__int64 Size); UnicodeString __fastcall FormatSize(__int64 Size); UnicodeString __fastcall ExtractFileBaseName(const UnicodeString & Path); +TStringList * __fastcall TextToStringList(const UnicodeString & Text); +UnicodeString __fastcall TrimVersion(UnicodeString Version); +UnicodeString __fastcall FormatVersion(int MajovVersion, int MinorVersion, int Release); +TFormatSettings __fastcall GetEngFormatSettings(); +int __fastcall ParseShortEngMonthName(const UnicodeString & MonthStr); //--------------------------------------------------------------------------- typedef void __fastcall (__closure* TProcessLocalFileEvent) (const UnicodeString FileName, const TSearchRec Rec, void * Param); diff --git a/source/core/Configuration.cpp b/source/core/Configuration.cpp index 41648898..7b370ce1 100644 --- a/source/core/Configuration.cpp +++ b/source/core/Configuration.cpp @@ -14,6 +14,7 @@ #include "Security.h" #include #include +#include //--------------------------------------------------------------------------- #pragma package(smart_init) //--------------------------------------------------------------------------- @@ -113,6 +114,7 @@ __fastcall TConfiguration::~TConfiguration() void __fastcall TConfiguration::UpdateStaticUsage() { Usage->Set(L"ConfigurationIniFile", (Storage == stIniFile)); + Usage->Set("Unofficial", IsUnofficial); // this is called from here, because we are guarded from calling into // master password handler here, see TWinConfiguration::UpdateStaticUsage @@ -605,7 +607,7 @@ void __fastcall TConfiguration::CleanupRandomSeedFile() try { DontSaveRandomSeed(); - if (FileExists(RandomSeedFileName)) + if (FileExists(ApiPath(RandomSeedFileName))) { DeleteFileChecked(RandomSeedFileName); } @@ -620,7 +622,7 @@ void __fastcall TConfiguration::CleanupIniFile() { try { - if (FileExists(IniFileStorageNameForReading)) + if (FileExists(ApiPath(IniFileStorageNameForReading))) { DeleteFileChecked(IniFileStorageNameForReading); } @@ -735,7 +737,8 @@ UnicodeString __fastcall TConfiguration::GetFileProductName(const UnicodeString //--------------------------------------------------------------------------- UnicodeString __fastcall TConfiguration::GetFileCompanyName(const UnicodeString FileName) { - return GetFileFileInfoString(L"CompanyName", FileName); + // particularly in IDE build, company name is empty + return GetFileFileInfoString(L"CompanyName", FileName, true); } //--------------------------------------------------------------------------- UnicodeString __fastcall TConfiguration::GetProductName() @@ -763,14 +766,13 @@ UnicodeString __fastcall TConfiguration::GetProductVersion() return GetFileProductVersion(L""); } //--------------------------------------------------------------------------- -UnicodeString __fastcall TConfiguration::TrimVersion(UnicodeString Version) +bool __fastcall TConfiguration::GetIsUnofficial() { - while ((Version.Pos(L".") != Version.LastDelimiter(L".")) && - (Version.SubString(Version.Length() - 1, 2) == L".0")) - { - Version.SetLength(Version.Length() - 2); - } - return Version; + #ifdef BUILD_OFFICIAL + return false; + #else + return true; + #endif } //--------------------------------------------------------------------------- UnicodeString __fastcall TConfiguration::GetVersionStr() @@ -778,12 +780,43 @@ UnicodeString __fastcall TConfiguration::GetVersionStr() TGuard Guard(FCriticalSection); try { - TVSFixedFileInfo * Info = FixedApplicationInfo; - return FMTLOAD(VERSION, ( - HIWORD(Info->dwFileVersionMS), - LOWORD(Info->dwFileVersionMS), - HIWORD(Info->dwFileVersionLS), - LOWORD(Info->dwFileVersionLS))); + UnicodeString BuildStr; + if (!IsUnofficial) + { + BuildStr = LoadStr(VERSION_BUILD); + } + else + { + #ifdef _DEBUG + BuildStr = LoadStr(VERSION_DEBUG_BUILD); + #else + BuildStr = LoadStr(VERSION_DEV_BUILD); + #endif + } + + int Build = LOWORD(FixedApplicationInfo->dwFileVersionLS); + if (Build > 0) + { + BuildStr += L" " + IntToStr(Build); + } + + #ifndef BUILD_OFFICIAL + UnicodeString BuildDate = __DATE__; + UnicodeString MonthStr = CutToChar(BuildDate, L' ', true); + int Month = ParseShortEngMonthName(MonthStr); + int Day = StrToInt(CutToChar(BuildDate, L' ', true)); + int Year = StrToInt(Trim(BuildDate)); + UnicodeString DateStr = FORMAT(L"%d-%2.2d-%2.2d", (Year, Month, Day)); + AddToList(BuildStr, DateStr, L" "); + #endif + + UnicodeString Result = FMTLOAD(VERSION2, (Version, BuildStr)); + + #ifndef BUILD_OFFICIAL + Result += L" " + LoadStr(VERSION_DONT_DISTRIBUTE); + #endif + + return Result; } catch (Exception &E) { @@ -797,11 +830,11 @@ UnicodeString __fastcall TConfiguration::GetVersion() try { TVSFixedFileInfo * Info = FixedApplicationInfo; - UnicodeString Result; - Result = TrimVersion(FORMAT(L"%d.%d.%d", ( - HIWORD(Info->dwFileVersionMS), - LOWORD(Info->dwFileVersionMS), - HIWORD(Info->dwFileVersionLS)))); + UnicodeString Result = + FormatVersion( + HIWORD(Info->dwFileVersionMS), + LOWORD(Info->dwFileVersionMS), + HIWORD(Info->dwFileVersionLS)); return Result; } catch (Exception &E) @@ -811,7 +844,7 @@ UnicodeString __fastcall TConfiguration::GetVersion() } //--------------------------------------------------------------------------- UnicodeString __fastcall TConfiguration::GetFileFileInfoString(const UnicodeString Key, - const UnicodeString FileName) + const UnicodeString FileName, bool AllowEmpty) { TGuard Guard(FCriticalSection); @@ -823,7 +856,7 @@ UnicodeString __fastcall TConfiguration::GetFileFileInfoString(const UnicodeStri { TTranslation Translation; Translation = GetTranslation(Info, 0); - Result = ::GetFileInfoString(Info, Translation, Key); + Result = ::GetFileInfoString(Info, Translation, Key, AllowEmpty); } else { @@ -871,7 +904,7 @@ UnicodeString __fastcall TConfiguration::GetIniFileStorageNameForReading() return GetIniFileStorageName(true); } //--------------------------------------------------------------------------- -UnicodeString __fastcall TConfiguration::GetIniFileStorageNameForReadingWritting() +UnicodeString __fastcall TConfiguration::GetIniFileStorageNameForReadingWriting() { return GetIniFileStorageName(false); } @@ -885,7 +918,7 @@ UnicodeString __fastcall TConfiguration::GetIniFileStorageName(bool ReadingOnly) UnicodeString ProgramIniPath = ChangeFileExt(ProgramPath, L".ini"); UnicodeString IniPath; - if (FileExists(ProgramIniPath)) + if (FileExists(ApiPath(ProgramIniPath))) { IniPath = ProgramIniPath; } @@ -894,7 +927,7 @@ UnicodeString __fastcall TConfiguration::GetIniFileStorageName(bool ReadingOnly) UnicodeString AppDataIniPath = IncludeTrailingBackslash(GetShellFolderPath(CSIDL_APPDATA)) + ExtractFileName(ProgramIniPath); - if (FileExists(AppDataIniPath)) + if (FileExists(ApiPath(AppDataIniPath))) { IniPath = AppDataIniPath; } @@ -930,7 +963,7 @@ UnicodeString __fastcall TConfiguration::GetIniFileStorageName(bool ReadingOnly) } if (!FVirtualIniFileStorageName.IsEmpty() && - FileExists(FVirtualIniFileStorageName)) + FileExists(ApiPath(FVirtualIniFileStorageName))) { return FVirtualIniFileStorageName; } @@ -1009,7 +1042,7 @@ void __fastcall TConfiguration::SetStorage(TStorage value) { // If this fails, do not pretend that storage was switched. // For instance: - // - When writting to an INI file fails (unlikely, as we fallback to user profile) + // - When writing to an INI file fails (unlikely, as we fallback to user profile) // - When removing INI file fails, when switching to registry // (possible, when the INI file is in Program Files folder) FStorage = StorageBak; @@ -1027,7 +1060,7 @@ TStorage __fastcall TConfiguration::GetStorage() { if (FStorage == stDetect) { - if (FileExists(IniFileStorageNameForReading)) + if (FileExists(ApiPath(IniFileStorageNameForReading))) { FStorage = stIniFile; } @@ -1055,10 +1088,10 @@ void __fastcall TConfiguration::SetRandomSeedFile(UnicodeString value) if (!PrevRandomSeedFileName.IsEmpty() && (PrevRandomSeedFileName != RandomSeedFileName) && - FileExists(PrevRandomSeedFileName)) + FileExists(ApiPath(PrevRandomSeedFileName))) { // ignore any error - DeleteFile(PrevRandomSeedFileName); + DeleteFile(ApiPath(PrevRandomSeedFileName)); } } } diff --git a/source/core/Configuration.h b/source/core/Configuration.h index 8588b77e..752014b1 100644 --- a/source/core/Configuration.h +++ b/source/core/Configuration.h @@ -70,7 +70,6 @@ class TConfiguration : public TObject UnicodeString __fastcall GetProductVersion(); UnicodeString __fastcall GetProductName(); UnicodeString __fastcall GetCompanyName(); - UnicodeString __fastcall TrimVersion(UnicodeString Version); UnicodeString __fastcall GetStoredSessionsSubKey(); UnicodeString __fastcall GetPuttySessionsKey(); void __fastcall SetRandomSeedFile(UnicodeString value); @@ -94,7 +93,7 @@ class TConfiguration : public TObject UnicodeString __fastcall GetTimeFormat(); void __fastcall SetStorage(TStorage value); UnicodeString __fastcall GetRegistryStorageKey(); - UnicodeString __fastcall GetIniFileStorageNameForReadingWritting(); + UnicodeString __fastcall GetIniFileStorageNameForReadingWriting(); UnicodeString __fastcall GetIniFileStorageNameForReading(); UnicodeString __fastcall GetIniFileStorageName(bool ReadingOnly); void __fastcall SetIniFileStorageName(UnicodeString value); @@ -114,6 +113,7 @@ class TConfiguration : public TObject void __fastcall SetTryFtpWhenSshFails(bool value); bool __fastcall GetCollectUsage(); void __fastcall SetCollectUsage(bool value); + bool __fastcall GetIsUnofficial(); protected: TStorage FStorage; @@ -144,7 +144,7 @@ class TConfiguration : public TObject virtual UnicodeString __fastcall ModuleFileName(); UnicodeString __fastcall GetFileFileInfoString(const UnicodeString Key, - const UnicodeString FileName); + const UnicodeString FileName, bool AllowEmpty = false); void * __fastcall GetFileApplicationInfo(const UnicodeString FileName); UnicodeString __fastcall GetFileProductVersion(const UnicodeString FileName); UnicodeString __fastcall GetFileProductName(const UnicodeString FileName); @@ -208,6 +208,7 @@ class TConfiguration : public TObject __property UnicodeString CompanyName = { read=GetCompanyName }; __property UnicodeString FileInfoString[UnicodeString Key] = { read = GetFileInfoString }; __property UnicodeString OSVersionStr = { read = GetOSVersionStr }; + __property bool IsUnofficial = { read = GetIsUnofficial }; __property bool Logging = { read=FLogging, write=SetLogging }; __property UnicodeString LogFileName = { read=FLogFileName, write=SetLogFileName }; __property bool LogToFile = { read=GetLogToFile }; @@ -239,7 +240,7 @@ class TConfiguration : public TObject __property UnicodeString TimeFormat = { read = GetTimeFormat }; __property TStorage Storage = { read=GetStorage, write=SetStorage }; __property UnicodeString RegistryStorageKey = { read=GetRegistryStorageKey }; - __property UnicodeString IniFileStorageName = { read=GetIniFileStorageNameForReadingWritting, write=SetIniFileStorageName }; + __property UnicodeString IniFileStorageName = { read=GetIniFileStorageNameForReadingWriting, write=SetIniFileStorageName }; __property UnicodeString IniFileStorageNameForReading = { read=GetIniFileStorageNameForReading }; __property UnicodeString DefaultKeyFile = { read = GetDefaultKeyFile }; diff --git a/source/core/CopyParam.cpp b/source/core/CopyParam.cpp index a8241349..a93e3c13 100644 --- a/source/core/CopyParam.cpp +++ b/source/core/CopyParam.cpp @@ -36,12 +36,14 @@ void __fastcall TCopyParamType::Default() TransferMode = tmBinary; AddXToDirectories = true; ResumeSupport = rsSmart; - ResumeThreshold = 100 * 1024; // (100 KiB) + ResumeThreshold = 100 * 1024; // (100 KB) InvalidCharsReplacement = TokenReplacement; LocalInvalidChars = ::LocalInvalidChars; CalculateSize = true; FileMask = L"*.*"; IncludeFileMask.Masks = L""; + TransferSkipList = NULL; + TransferResumeFile = L""; ClearArchive = false; RemoveCtrlZ = false; RemoveBOM = false; @@ -240,9 +242,12 @@ void __fastcall TCopyParamType::DoGetInfoStr( cpaNoIncludeMask); } + assert(FTransferSkipList.get() == NULL); + assert(FTransferResumeFile.IsEmpty()); + if (CPSLimit > 0) { - ADD(FMTLOAD(COPY_INFO_CPS_LIMIT, (int(CPSLimit / 1024))), cpaIncludeMaskOnly); + ADD(FMTLOAD(COPY_INFO_CPS_LIMIT2, (int(CPSLimit / 1024))), cpaIncludeMaskOnly); } if (NewerOnly != Defaults.NewerOnly) @@ -286,6 +291,8 @@ void __fastcall TCopyParamType::Assign(const TCopyParamType * Source) COPY(CalculateSize); COPY(FileMask); COPY(IncludeFileMask); + COPY(TransferSkipList); + COPY(TransferResumeFile); COPY(ClearArchive); COPY(RemoveCtrlZ); COPY(RemoveBOM); @@ -426,7 +433,7 @@ bool __fastcall TCopyParamType::UseAsciiTransfer(UnicodeString FileName, case tmAscii: return true; case tmAutomatic: return AsciiFileMask.Matches(FileName, (Side == osLocal), false, &Params); - default: assert(false); return false; + default: FAIL; return false; } } //--------------------------------------------------------------------------- @@ -443,30 +450,34 @@ UnicodeString __fastcall TCopyParamType::GetLogStr() const wchar_t CaseC[] = L"NULFS"; wchar_t ModeC[] = L"BAM"; wchar_t ResumeC[] = L"YSN"; - return FORMAT( - L" PrTime: %s; PrRO: %s; Rght: %s; PrR: %s (%s); FnCs: %s; RIC: %s; " - "Resume: %s (%d); CalcS: %s; Mask: %s\n" - " TM: %s; ClAr: %s; RemEOF: %s; RemBOM: %s; CPS: %u; NewerOnly: %s; InclM: %s\n" - " AscM: %s\n", - (BooleanToEngStr(PreserveTime), - BooleanToEngStr(PreserveReadOnly), - Rights.Text, - BooleanToEngStr(PreserveRights), - BooleanToEngStr(IgnorePermErrors), - CaseC[FileNameCase], - CharToHex(InvalidCharsReplacement), - ResumeC[ResumeSupport], - (int)ResumeThreshold, - BooleanToEngStr(CalculateSize), - FileMask, - ModeC[TransferMode], - BooleanToEngStr(ClearArchive), - BooleanToEngStr(RemoveCtrlZ), - BooleanToEngStr(RemoveBOM), - int(CPSLimit), - BooleanToEngStr(NewerOnly), - IncludeFileMask.Masks, - AsciiFileMask.Masks)); + // OpenArray (ARRAYOFCONST) supports only up to 19 arguments, so we had to split it + return + FORMAT( + L" PrTime: %s; PrRO: %s; Rght: %s; PrR: %s (%s); FnCs: %s; RIC: %s; " + "Resume: %s (%d); CalcS: %s; Mask: %s\n", + (BooleanToEngStr(PreserveTime), + BooleanToEngStr(PreserveReadOnly), + Rights.Text, + BooleanToEngStr(PreserveRights), + BooleanToEngStr(IgnorePermErrors), + CaseC[FileNameCase], + CharToHex(InvalidCharsReplacement), + ResumeC[ResumeSupport], + (int)ResumeThreshold, + BooleanToEngStr(CalculateSize), + FileMask)) + + FORMAT( + L" TM: %s; ClAr: %s; RemEOF: %s; RemBOM: %s; CPS: %u; NewerOnly: %s; InclM: %s; ResumeL: %d\n" + " AscM: %s\n", + (ModeC[TransferMode], + BooleanToEngStr(ClearArchive), + BooleanToEngStr(RemoveCtrlZ), + BooleanToEngStr(RemoveBOM), + int(CPSLimit), + BooleanToEngStr(NewerOnly), + IncludeFileMask.Masks, + ((FTransferSkipList.get() != NULL) ? FTransferSkipList->Count : 0) + (!FTransferResumeFile.IsEmpty() ? 1 : 0), + AsciiFileMask.Masks)); } //--------------------------------------------------------------------------- int __fastcall TCopyParamType::LocalFileAttrs(const TRights & Rights) const @@ -486,13 +497,16 @@ bool __fastcall TCopyParamType::AllowResume(__int64 Size) const case rsOn: return true; case rsOff: return false; case rsSmart: return (Size >= ResumeThreshold); - default: assert(false); return false; + default: FAIL; return false; } } //--------------------------------------------------------------------------- bool __fastcall TCopyParamType::AllowAnyTransfer() const { - return IncludeFileMask.Masks.IsEmpty(); + return + IncludeFileMask.Masks.IsEmpty() && + ((FTransferSkipList.get() == NULL) || (FTransferSkipList->Count == 0)) && + FTransferResumeFile.IsEmpty(); } //--------------------------------------------------------------------------- bool __fastcall TCopyParamType::AllowTransfer(UnicodeString FileName, @@ -507,6 +521,47 @@ bool __fastcall TCopyParamType::AllowTransfer(UnicodeString FileName, return Result; } //--------------------------------------------------------------------------- +bool __fastcall TCopyParamType::SkipTransfer( + UnicodeString FileName, bool Directory) const +{ + bool Result = false; + // we deliberatelly do not filter directories, as path is added to resume list + // when a transfer of file or directory is started, + // so for directories we need to recurse and check every single file + if (!Directory && (FTransferSkipList.get() != NULL)) + { + Result = (FTransferSkipList->IndexOf(FileName) >= 0); + } + return Result; +} +//--------------------------------------------------------------------------- +bool __fastcall TCopyParamType::ResumeTransfer(UnicodeString FileName) const +{ + // Returning true has the same effect as cpResume + return + (FileName == FTransferResumeFile) && + ALWAYS_TRUE(!FTransferResumeFile.IsEmpty()); +} +//--------------------------------------------------------------------------- +TStrings * __fastcall TCopyParamType::GetTransferSkipList() const +{ + return FTransferSkipList.get(); +} +//--------------------------------------------------------------------------- +void __fastcall TCopyParamType::SetTransferSkipList(TStrings * value) +{ + if ((value == NULL) || (value->Count == 0)) + { + FTransferSkipList.reset(NULL); + } + else + { + FTransferSkipList.reset(new TStringList()); + FTransferSkipList->AddStrings(value); + FTransferSkipList->Sorted = true; + } +} +//--------------------------------------------------------------------------- void __fastcall TCopyParamType::Load(THierarchicalStorage * Storage) { AddXToDirectories = Storage->ReadBool(L"AddXToDirectories", AddXToDirectories); @@ -545,6 +600,8 @@ void __fastcall TCopyParamType::Load(THierarchicalStorage * Storage) } } } + TransferSkipList = NULL; + TransferResumeFile = L""; ClearArchive = Storage->ReadBool(L"ClearArchive", ClearArchive); RemoveCtrlZ = Storage->ReadBool(L"RemoveCtrlZ", RemoveCtrlZ); RemoveBOM = Storage->ReadBool(L"RemoveBOM", RemoveBOM); @@ -571,6 +628,8 @@ void __fastcall TCopyParamType::Save(THierarchicalStorage * Storage) const Storage->WriteString(L"IncludeFileMask", IncludeFileMask.Masks); Storage->DeleteValue(L"ExcludeFileMask"); // obsolete Storage->DeleteValue(L"NegativeExclude"); // obsolete + assert(FTransferSkipList.get() == NULL); + assert(FTransferResumeFile.IsEmpty()); Storage->WriteBool(L"ClearArchive", ClearArchive); Storage->WriteBool(L"RemoveCtrlZ", RemoveCtrlZ); Storage->WriteBool(L"RemoveBOM", RemoveBOM); @@ -581,6 +640,10 @@ void __fastcall TCopyParamType::Save(THierarchicalStorage * Storage) const #define C(Property) (Property == rhp.Property) bool __fastcall TCopyParamType::operator==(const TCopyParamType & rhp) const { + assert(FTransferSkipList.get() == NULL); + assert(FTransferResumeFile.IsEmpty()); + assert(rhp.FTransferSkipList.get() == NULL); + assert(rhp.FTransferResumeFile.IsEmpty()); return C(AddXToDirectories) && C(AsciiFileMask) && diff --git a/source/core/CopyParam.h b/source/core/CopyParam.h index 6121f704..45e65eb9 100644 --- a/source/core/CopyParam.h +++ b/source/core/CopyParam.h @@ -52,6 +52,8 @@ class TCopyParamType bool FCalculateSize; UnicodeString FFileMask; TFileMasks FIncludeFileMask; + std::unique_ptr FTransferSkipList; + UnicodeString FTransferResumeFile; bool FClearArchive; bool FRemoveCtrlZ; bool FRemoveBOM; @@ -67,6 +69,8 @@ class TCopyParamType UnicodeString __fastcall RestoreChars(UnicodeString FileName) const; void __fastcall DoGetInfoStr(UnicodeString Separator, int Attrs, UnicodeString & Result, bool & SomeAttrIncluded) const; + TStrings * __fastcall GetTransferSkipList() const; + void __fastcall SetTransferSkipList(TStrings * value); public: __fastcall TCopyParamType(); @@ -82,11 +86,13 @@ class TCopyParamType bool __fastcall UseAsciiTransfer(UnicodeString FileName, TOperationSide Side, const TFileMasks::TParams & Params) const; bool __fastcall AllowResume(__int64 Size) const; + bool __fastcall ResumeTransfer(UnicodeString FileName) const; UnicodeString __fastcall ValidLocalFileName(UnicodeString FileName) const; UnicodeString __fastcall ValidLocalPath(UnicodeString Path) const; bool __fastcall AllowAnyTransfer() const; bool __fastcall AllowTransfer(UnicodeString FileName, TOperationSide Side, bool Directory, const TFileMasks::TParams & Params) const; + bool __fastcall SkipTransfer(UnicodeString FileName, bool Directory) const; void __fastcall Load(THierarchicalStorage * Storage); void __fastcall Save(THierarchicalStorage * Storage) const; @@ -113,6 +119,8 @@ class TCopyParamType __property bool CalculateSize = { read = FCalculateSize, write = FCalculateSize }; __property UnicodeString FileMask = { read = FFileMask, write = FFileMask }; __property TFileMasks IncludeFileMask = { read = FIncludeFileMask, write = FIncludeFileMask }; + __property TStrings * TransferSkipList = { read = GetTransferSkipList, write = SetTransferSkipList }; + __property UnicodeString TransferResumeFile = { read = FTransferResumeFile, write = FTransferResumeFile }; __property bool ClearArchive = { read = FClearArchive, write = FClearArchive }; __property bool RemoveCtrlZ = { read = FRemoveCtrlZ, write = FRemoveCtrlZ }; __property bool RemoveBOM = { read = FRemoveBOM, write = FRemoveBOM }; diff --git a/source/core/CoreMain.cpp b/source/core/CoreMain.cpp index 76cb8476..b0e9a292 100644 --- a/source/core/CoreMain.cpp +++ b/source/core/CoreMain.cpp @@ -13,6 +13,7 @@ #ifndef NO_FILEZILLA #include "FileZillaIntf.h" #endif +#include "WebDAVFileSystem.h" //--------------------------------------------------------------------------- #pragma package(smart_init) //--------------------------------------------------------------------------- @@ -59,7 +60,7 @@ bool __fastcall IsAuthenticationPrompt(TPromptKind Kind) (Kind == pkPassword) || (Kind == pkNewPassword); } //--------------------------------------------------------------------------- -bool __fastcall IsPasswordPrompt(TPromptKind Kind, TStrings * Prompts) +bool __fastcall IsPasswordOrPassphrasePrompt(TPromptKind Kind, TStrings * Prompts) { return (Prompts->Count == 1) && FLAGCLEAR(int(Prompts->Objects[0]), pupEcho) && @@ -67,11 +68,20 @@ bool __fastcall IsPasswordPrompt(TPromptKind Kind, TStrings * Prompts) (Kind == pkTIS) || (Kind == pkCryptoCard)); } //--------------------------------------------------------------------------- +bool __fastcall IsPasswordPrompt(TPromptKind Kind, TStrings * Prompts) +{ + return + IsPasswordOrPassphrasePrompt(Kind, Prompts) && + (Kind != pkPassphrase); +} +//--------------------------------------------------------------------------- void CoreInitialize() { Randomize(); CryptographyInitialize(); + // we do not expect configuration re-creation + assert(Configuration == NULL); // configuration needs to be created and loaded before putty is initialized, // so that random seed path is known Configuration = CreateConfiguration(); @@ -89,6 +99,7 @@ void CoreInitialize() #ifndef NO_FILEZILLA TFileZillaIntf::Initialize(); #endif + NeonInitialize(); StoredSessions = new TStoredSessionList(); @@ -113,6 +124,7 @@ void CoreFinalize() ShowExtendedException(&E); } + NeonFinalize(); #ifndef NO_FILEZILLA TFileZillaIntf::Finalize(); #endif @@ -175,5 +187,3 @@ __fastcall TInstantOperationVisualizer::~TInstantOperationVisualizer() } } //--------------------------------------------------------------------------- -// WORKAROUND, suppress warning about unused constants in DateUtils.hpp -#pragma warn -8080 diff --git a/source/core/CoreMain.h b/source/core/CoreMain.h index aed985d2..6da9465f 100644 --- a/source/core/CoreMain.h +++ b/source/core/CoreMain.h @@ -14,4 +14,7 @@ void CoreFinalize(); void CoreSetResourceModule(void * ResourceHandle); void CoreMaintenanceTask(); //--------------------------------------------------------------------------- +UnicodeString __fastcall NeonVersion(); +UnicodeString __fastcall ExpatVersion(); +//--------------------------------------------------------------------------- #endif diff --git a/source/core/Cryptography.cpp b/source/core/Cryptography.cpp index f1eca19c..89b5dea7 100644 --- a/source/core/Cryptography.cpp +++ b/source/core/Cryptography.cpp @@ -571,7 +571,7 @@ bool __fastcall UnscramblePassword(RawByteString Scrambled, UnicodeString & Pass } else { - Password = ""; + Password = L""; } return Result; } diff --git a/source/core/Exceptions.cpp b/source/core/Exceptions.cpp index 2664ac04..862e7677 100644 --- a/source/core/Exceptions.cpp +++ b/source/core/Exceptions.cpp @@ -36,7 +36,8 @@ static bool __fastcall WellKnownException( (dynamic_cast(E) != NULL) || (dynamic_cast(E) != NULL) || (dynamic_cast(E) != NULL) || - (dynamic_cast(E) != NULL)) + (dynamic_cast(E) != NULL) || + (dynamic_cast(E) != NULL)) { if (Rethrow) { @@ -95,7 +96,7 @@ static bool __fastcall ExceptionMessage(Exception * E, bool Count, { bool Result = true; const wchar_t * CounterName = NULL; - InternalError = false; + InternalError = false; // see also IsInternalException // this list has to be in sync with CloneException if (dynamic_cast(E) != NULL) @@ -133,6 +134,12 @@ static bool __fastcall ExceptionMessage(Exception * E, bool Count, return Result; } //--------------------------------------------------------------------------- +bool __fastcall IsInternalException(Exception * E) +{ + // see also InternalError in ExceptionMessage + return WellKnownException(E, NULL, NULL, NULL, false); +} +//--------------------------------------------------------------------------- bool __fastcall ExceptionMessage(Exception * E, UnicodeString & Message) { bool InternalError; @@ -252,8 +259,7 @@ __fastcall ExtException::ExtException(UnicodeString Msg, UnicodeString MoreMessa { if (!MoreMessages.IsEmpty()) { - FMoreMessages = new TStringList(); - FMoreMessages->Text = MoreMessages; + FMoreMessages = TextToStringList(MoreMessages); } } //--------------------------------------------------------------------------- diff --git a/source/core/Exceptions.h b/source/core/Exceptions.h index 340f8ccc..02e01b7c 100644 --- a/source/core/Exceptions.h +++ b/source/core/Exceptions.h @@ -12,6 +12,7 @@ bool __fastcall ExceptionMessage(Exception * E, UnicodeString & Message); bool __fastcall ExceptionMessageFormatted(Exception * E, UnicodeString & Message); UnicodeString __fastcall LastSysErrorMessage(); TStrings * __fastcall ExceptionToMoreMessages(Exception * E); +bool __fastcall IsInternalException(Exception * E); //--------------------------------------------------------------------------- enum TOnceDoneOperation { odoIdle, odoDisconnect, odoShutDown }; //--------------------------------------------------------------------------- @@ -22,8 +23,8 @@ class ExtException : public Sysutils::Exception __fastcall ExtException(Exception* E, UnicodeString Msg, UnicodeString HelpKeyword = L""); // "copy the exception", just append message to the end __fastcall ExtException(UnicodeString Msg, Exception* E, UnicodeString HelpKeyword = L""); - __fastcall ExtException(UnicodeString Msg, UnicodeString MoreMessages, UnicodeString HelpKeyword = ""); - __fastcall ExtException(UnicodeString Msg, TStrings* MoreMessages, bool Own, UnicodeString HelpKeyword = ""); + __fastcall ExtException(UnicodeString Msg, UnicodeString MoreMessages, UnicodeString HelpKeyword = L""); + __fastcall ExtException(UnicodeString Msg, TStrings* MoreMessages, bool Own, UnicodeString HelpKeyword = L""); __fastcall virtual ~ExtException(void); __property TStrings* MoreMessages = {read=FMoreMessages}; __property UnicodeString HelpKeyword = {read=FHelpKeyword}; @@ -127,7 +128,7 @@ class EFatal : public ExtException { public: // fatal errors are always copied, new message is only appended - __fastcall EFatal(Exception* E, UnicodeString Msg, UnicodeString HelpKeyword = ""); + __fastcall EFatal(Exception* E, UnicodeString Msg, UnicodeString HelpKeyword = L""); __property bool ReopenQueried = { read = FReopenQueried, write = FReopenQueried }; @@ -141,7 +142,7 @@ class EFatal : public ExtException class NAME : public BASE \ { \ public: \ - inline __fastcall NAME(Exception* E, UnicodeString Msg, UnicodeString HelpKeyword = "") : \ + inline __fastcall NAME(Exception* E, UnicodeString Msg, UnicodeString HelpKeyword = L"") : \ BASE(E, Msg, HelpKeyword) \ { \ } \ diff --git a/source/core/FileBuffer.cpp b/source/core/FileBuffer.cpp index 1db26ad9..b027d4b7 100644 --- a/source/core/FileBuffer.cpp +++ b/source/core/FileBuffer.cpp @@ -13,7 +13,7 @@ char * __fastcall EOLToStr(TEOLType EOLType) case eolLF: return "\n"; case eolCRLF: return "\r\n"; case eolCR: return "\r"; - default: assert(false); return ""; + default: FAIL; return ""; } } //--------------------------------------------------------------------------- @@ -77,7 +77,7 @@ DWORD __fastcall TFileBuffer::ReadStream(TStream * Stream, const DWORD Len, bool { Size = Size - Len + Result; } - FMemory->Seek(Len, soFromCurrent); + FMemory->Seek(Len, soCurrent); } catch(EReadError &) { @@ -224,7 +224,7 @@ void __fastcall TFileBuffer::WriteToStream(TStream * Stream, const DWORD Len) try { Stream->WriteBuffer(Data + Position, Len); - FMemory->Seek(Len, soFromCurrent); + FMemory->Seek(Len, soCurrent); } catch(EWriteError &) { @@ -257,3 +257,25 @@ int __fastcall TSafeHandleStream::Write(const void * Buffer, int Count) } return Result; } +//--------------------------------------------------------------------------- +int __fastcall TSafeHandleStream::Read(System::DynamicArray Buffer, int Offset, int Count) +{ + FAIL; // untested + int Result = FileRead(FHandle, Buffer, Offset, Count); + if (Result == -1) + { + RaiseLastOSError(); + } + return Result; +} +//--------------------------------------------------------------------------- +int __fastcall TSafeHandleStream::Write(const System::DynamicArray Buffer, int Offset, int Count) +{ + FAIL; // untested + int Result = FileWrite(FHandle, Buffer, Offset, Count); + if (Result == -1) + { + RaiseLastOSError(); + } + return Result; +} diff --git a/source/core/FileBuffer.h b/source/core/FileBuffer.h index c5de4a2c..8572733d 100644 --- a/source/core/FileBuffer.h +++ b/source/core/FileBuffer.h @@ -44,6 +44,8 @@ class TSafeHandleStream : public THandleStream __fastcall TSafeHandleStream(int AHandle); virtual int __fastcall Read(void * Buffer, int Count); virtual int __fastcall Write(const void * Buffer, int Count); + virtual int __fastcall Read(System::DynamicArray Buffer, int Offset, int Count); + virtual int __fastcall Write(const System::DynamicArray Buffer, int Offset, int Count); }; //--------------------------------------------------------------------------- char * __fastcall EOLToStr(TEOLType EOLType); diff --git a/source/core/FileInfo.cpp b/source/core/FileInfo.cpp index ee6fb68b..1d2debe9 100644 --- a/source/core/FileInfo.cpp +++ b/source/core/FileInfo.cpp @@ -236,8 +236,9 @@ UnicodeString __fastcall GetLanguage(Word Language) // Return the value of the specified file version info string using the // specified translation UnicodeString __fastcall GetFileInfoString(void * FileInfo, - TTranslation Translation, UnicodeString StringName) + TTranslation Translation, UnicodeString StringName, bool AllowEmpty) { + UnicodeString Result; wchar_t * P; UINT Len; @@ -246,10 +247,16 @@ UnicodeString __fastcall GetFileInfoString(void * FileInfo, IntToHex(Translation.CharSet, 4) + L"\\" + StringName).c_str(), (void**)&P, &Len)) { - throw Exception("Specified file info string not available"); + if (!AllowEmpty) + { + throw Exception("Specified file info string not available"); + } + } + else + { + Result = UnicodeString(P, Len); + PackStr(Result); } - UnicodeString Result = UnicodeString(P, Len); - PackStr(Result); return Result; } //--------------------------------------------------------------------------- diff --git a/source/core/FileInfo.h b/source/core/FileInfo.h index d7772df3..2bbd9224 100644 --- a/source/core/FileInfo.h +++ b/source/core/FileInfo.h @@ -26,7 +26,7 @@ UnicodeString __fastcall GetLanguage(Word Language); // Return the value of the specified file version info string using the // specified translation UnicodeString __fastcall GetFileInfoString(void * FileInfo, - TTranslation Translation, UnicodeString StringName); + TTranslation Translation, UnicodeString StringName, bool AllowEmpty = false); int __fastcall CalculateCompoundVersion(int MajorVer, int MinorVer, int Release, int Build); diff --git a/source/core/FileMasks.h b/source/core/FileMasks.h index aebcb885..2ffe0f90 100644 --- a/source/core/FileMasks.h +++ b/source/core/FileMasks.h @@ -29,7 +29,7 @@ class TFileMasks }; static bool __fastcall IsMask(const UnicodeString Mask); - static UnicodeString __fastcall NormalizeMask(const UnicodeString & Mask, const UnicodeString & AnyMask = ""); + static UnicodeString __fastcall NormalizeMask(const UnicodeString & Mask, const UnicodeString & AnyMask = L""); static UnicodeString __fastcall ComposeMaskStr( TStrings * IncludeFileMasksStr, TStrings * ExcludeFileMasksStr, TStrings * IncludeDirectoryMasksStr, TStrings * ExcludeDirectoryMasksStr); @@ -48,7 +48,7 @@ class TFileMasks void __fastcall SetMask(const UnicodeString & Mask); bool __fastcall Matches(const UnicodeString FileName, bool Directory = false, - const UnicodeString Path = "", const TParams * Params = NULL) const; + const UnicodeString Path = L"", const TParams * Params = NULL) const; bool __fastcall Matches(const UnicodeString FileName, bool Directory, const UnicodeString Path, const TParams * Params, bool & ImplicitMatch) const; diff --git a/source/core/FileOperationProgress.cpp b/source/core/FileOperationProgress.cpp index caa5e7f3..a07751f1 100644 --- a/source/core/FileOperationProgress.cpp +++ b/source/core/FileOperationProgress.cpp @@ -192,7 +192,7 @@ int __fastcall TFileOperationProgressType::OverallProgress() void __fastcall TFileOperationProgressType::DoProgress() { SetThreadExecutionState(ES_SYSTEM_REQUIRED); - FOnProgress(*this, Cancel); + FOnProgress(*this); } //--------------------------------------------------------------------------- void __fastcall TFileOperationProgressType::Finish(UnicodeString FileName, @@ -209,6 +209,14 @@ void __fastcall TFileOperationProgressType::Finish(UnicodeString FileName, //--------------------------------------------------------------------------- void __fastcall TFileOperationProgressType::SetFile(UnicodeString AFileName, bool AFileInProgress) { + FullFileName = AFileName; + if (Side == osRemote) + { + // historically set were passing filename-only for remote site operations, + // now we need to collect a full paths, so we pass in full path, + // but still want to have filename-only in FileName + AFileName = UnixExtractFileName(AFileName); + } FileName = AFileName; FileInProgress = AFileInProgress; ClearTransfer(); @@ -254,6 +262,16 @@ void __fastcall TFileOperationProgressType::SetSpeedCounters() } } //--------------------------------------------------------------------------- +void __fastcall TFileOperationProgressType::ThrottleToCPSLimit( + unsigned long Size) +{ + unsigned long Remaining = Size; + while (Remaining > 0) + { + Remaining -= AdjustToCPSLimit(Remaining); + } +} +//--------------------------------------------------------------------------- unsigned long __fastcall TFileOperationProgressType::AdjustToCPSLimit( unsigned long Size) { @@ -356,6 +374,7 @@ void __fastcall TFileOperationProgressType::AddTransfered(__int64 ASize, // grows while being downloaded if (TotalSizeSet) { + // we should probably guard this with AddToTotals TotalSize += (TransferedSize - TransferSize); } TransferSize = TransferedSize; @@ -389,6 +408,12 @@ void __fastcall TFileOperationProgressType::AddResumed(__int64 ASize) AddLocallyUsed(ASize); } //--------------------------------------------------------------------------- +void __fastcall TFileOperationProgressType::AddSkippedFileSize(__int64 ASize) +{ + TotalSkipped += ASize; + DoProgress(); +} +//--------------------------------------------------------------------------- unsigned long __fastcall TFileOperationProgressType::TransferBlockSize() { unsigned long Result = TRANSFER_BUF_SIZE; diff --git a/source/core/FileOperationProgress.h b/source/core/FileOperationProgress.h index 3a2bb9f5..af6e0831 100644 --- a/source/core/FileOperationProgress.h +++ b/source/core/FileOperationProgress.h @@ -11,11 +11,12 @@ class TFileOperationProgressType; enum TFileOperation { foNone, foCopy, foMove, foDelete, foSetProperties, foRename, foCustomCommand, foCalculateSize, foRemoteMove, foRemoteCopy, foGetProperties, foCalculateChecksum }; +// csCancelTransfer and csRemoteAbort are used with SCP only enum TCancelStatus { csContinue = 0, csCancel, csCancelTransfer, csRemoteAbort }; enum TResumeStatus { rsNotAvailable, rsEnabled, rsDisabled }; enum TBatchOverwrite { boNo, boAll, boNone, boOlder, boAlternateResume, boAppend, boResume }; typedef void __fastcall (__closure *TFileOperationProgressEvent) - (TFileOperationProgressType & ProgressData, TCancelStatus & Cancel); + (TFileOperationProgressType & ProgressData); typedef void __fastcall (__closure *TFileOperationFinished) (TFileOperation Operation, TOperationSide Side, bool Temp, const UnicodeString & FileName, bool Success, TOnceDoneOperation & OnceDoneOperation); @@ -47,8 +48,10 @@ class TFileOperationProgressType // on what side if operation being processed (local/remote), source of copy TOperationSide Side; UnicodeString FileName; + UnicodeString FullFileName; UnicodeString Directory; bool AsciiTransfer; + // Can be true with SCP protocol only bool TransferingFile; bool Temp; @@ -85,6 +88,7 @@ class TFileOperationProgressType void __fastcall AddLocallyUsed(__int64 ASize); void __fastcall AddTransfered(__int64 ASize, bool AddToTotals = true); void __fastcall AddResumed(__int64 ASize); + void __fastcall AddSkippedFileSize(__int64 ASize); void __fastcall Clear(); unsigned int __fastcall CPS(); void __fastcall Finish(UnicodeString FileName, bool Success, @@ -97,6 +101,7 @@ class TFileOperationProgressType int __fastcall OperationProgress(); unsigned long __fastcall TransferBlockSize(); unsigned long __fastcall AdjustToCPSLimit(unsigned long Size); + void __fastcall ThrottleToCPSLimit(unsigned long Size); static unsigned long __fastcall StaticBlockSize(); void __fastcall Reset(); void __fastcall Resume(); diff --git a/source/core/FileSystems.h b/source/core/FileSystems.h index 2b02d70e..23c1e39a 100644 --- a/source/core/FileSystems.h +++ b/source/core/FileSystems.h @@ -77,7 +77,6 @@ class TCustomFileSystem const UnicodeString NewName) = 0; virtual void __fastcall CopyFile(const UnicodeString FileName, const UnicodeString NewName) = 0; - virtual UnicodeString __fastcall FileUrl(const UnicodeString FileName) = 0; virtual TStrings * __fastcall GetFixedPaths() = 0; virtual void __fastcall SpaceAvailable(const UnicodeString Path, TSpaceAvailable & ASpaceAvailable) = 0; diff --git a/source/core/FtpFileSystem.cpp b/source/core/FtpFileSystem.cpp index 1ac9dcb2..7983777b 100644 --- a/source/core/FtpFileSystem.cpp +++ b/source/core/FtpFileSystem.cpp @@ -15,15 +15,12 @@ #include "TextsCore.h" #include "TextsFileZilla.h" #include "HelpCore.h" -#define OPENSSL_NO_EC -#define OPENSSL_NO_ECDSA -#define OPENSSL_NO_ECDH +#include "Security.h" #include //--------------------------------------------------------------------------- #pragma package(smart_init) //--------------------------------------------------------------------------- -#define FILE_OPERATION_LOOP_EX(ALLOW_SKIP, MESSAGE, OPERATION) \ - FILE_OPERATION_LOOP_CUSTOM(FTerminal, ALLOW_SKIP, MESSAGE, OPERATION, L"") +#define FILE_OPERATION_LOOP_TERMINAL FTerminal //--------------------------------------------------------------------------- const int DummyCodeClass = 8; const int DummyTimeoutCode = 801; @@ -494,6 +491,7 @@ void __fastcall TFTPFileSystem::Open() } while (FPasswordFailed); + // see also TWebDAVFileSystem::CollectTLSSessionInfo() FSessionInfo.CSCipher = FFileZillaIntf->GetCipherName().c_str(); FSessionInfo.SCCipher = FSessionInfo.CSCipher; UnicodeString TlsVersionStr = FFileZillaIntf->GetTlsVersionStr().c_str(); @@ -644,7 +642,7 @@ void __fastcall TFTPFileSystem::EnsureLocation() // 1) We did cached directory change // 2) Listing was requested for non-current directory, which // makes FZAPI change its current directory (and not restoring it back afterwards) - if (!UnixComparePaths(ActualCurrentDirectory(), FCurrentDirectory)) + if (!UnixSamePath(ActualCurrentDirectory(), FCurrentDirectory)) { FTerminal->LogEvent(FORMAT(L"Synchronizing current directory \"%s\".", (FCurrentDirectory))); @@ -804,7 +802,7 @@ void __fastcall TFTPFileSystem::ChangeFileProperties(const UnicodeString AFileNa //--------------------------------------------------------------------------- bool __fastcall TFTPFileSystem::LoadFilesProperties(TStrings * /*FileList*/) { - assert(false); + FAIL; return false; } //--------------------------------------------------------------------------- @@ -812,10 +810,11 @@ void __fastcall TFTPFileSystem::CalculateFilesChecksum(const UnicodeString & /*A TStrings * /*FileList*/, TStrings * /*Checksums*/, TCalculatedChecksumEvent /*OnCalculatedChecksum*/) { - assert(false); + FAIL; } //--------------------------------------------------------------------------- -bool __fastcall TFTPFileSystem::ConfirmOverwrite(UnicodeString & FileName, +bool __fastcall TFTPFileSystem::ConfirmOverwrite( + const UnicodeString & FullFileName, UnicodeString & FileName, TOverwriteMode & OverwriteMode, TFileOperationProgressType * OperationProgress, const TOverwriteFileParams * FileParams, const TCopyParamType * CopyParam, int Params, bool AutoResume) @@ -877,13 +876,14 @@ bool __fastcall TFTPFileSystem::ConfirmOverwrite(UnicodeString & FileName, TQueryParams QueryParams(qpNeverAskAgainCheck); QueryParams.Aliases = Aliases; QueryParams.AliasesCount = LENOF(Aliases); - SUSPEND_OPERATION - ( - Answer = FTerminal->ConfirmFileOverwrite(FileName, FileParams, + + { + TSuspendFileOperationProgress Suspend(OperationProgress); + Answer = FTerminal->ConfirmFileOverwrite(FullFileName, FileParams, Answers, &QueryParams, OperationProgress->Side == osLocal ? osRemote : osLocal, CopyParam, Params, OperationProgress); - ) + } } Result = true; @@ -939,7 +939,7 @@ bool __fastcall TFTPFileSystem::ConfirmOverwrite(UnicodeString & FileName, break; default: - assert(false); + FAIL; Result = false; break; } @@ -963,10 +963,10 @@ void __fastcall TFTPFileSystem::ReadDirectoryProgress(__int64 Bytes) { bool Cancel = false; FLastReadDirectoryProgress = Progress; - FTerminal->DoReadDirectoryProgress(Progress, Cancel); + FTerminal->DoReadDirectoryProgress(Progress, 0, Cancel); if (Cancel) { - FTerminal->DoReadDirectoryProgress(-2, Cancel); + FTerminal->DoReadDirectoryProgress(-2, 0, Cancel); FFileZillaIntf->Cancel(); } } @@ -1025,14 +1025,16 @@ void __fastcall TFTPFileSystem::FileTransfer(const UnicodeString & FileName, const UnicodeString & RemotePath, bool Get, __int64 Size, int Type, TFileTransferData & UserData, TFileOperationProgressType * OperationProgress) { - FILE_OPERATION_LOOP(FMTLOAD(TRANSFER_ERROR, (FileName)), + FILE_OPERATION_LOOP_BEGIN + { FFileZillaIntf->FileTransfer(LocalFile.c_str(), RemoteFile.c_str(), RemotePath.c_str(), Get, Size, Type, &UserData); // we may actually catch response code of the listing // command (when checking for existence of the remote file) unsigned int Reply = WaitForCommandReply(); GotReply(Reply, FLAGMASK(FFileTransferCancelled, REPLY_ALLOW_CANCEL)); - ); + } + FILE_OPERATION_LOOP_END(FMTLOAD(TRANSFER_ERROR, (FileName))); switch (FFileTransferAbort) { @@ -1079,9 +1081,11 @@ void __fastcall TFTPFileSystem::CopyToLocal(TStrings * FilesToCopy, } catch(EScpSkipFile & E) { - SUSPEND_OPERATION ( - if (!FTerminal->HandleException(&E)) throw; - ); + TSuspendFileOperationProgress Suspend(OperationProgress); + if (!FTerminal->HandleException(&E)) + { + throw; + } } } __finally @@ -1158,9 +1162,15 @@ void __fastcall TFTPFileSystem::Sink(const UnicodeString FileName, THROW_SKIP_FILE_NULL; } + if (CopyParam->SkipTransfer(FileName, File->IsDirectory)) + { + OperationProgress->AddSkippedFileSize(File->Size); + THROW_SKIP_FILE_NULL; + } + FTerminal->LogFileDetails(FileName, File->Modification, File->Size); - OperationProgress->SetFile(OnlyFileName); + OperationProgress->SetFile(FileName); UnicodeString DestFileName = CopyParam->ChangeFileName(OnlyFileName, osRemote, FLAGSET(Flags, tfFirstLevel)); @@ -1171,17 +1181,21 @@ void __fastcall TFTPFileSystem::Sink(const UnicodeString FileName, Action.Cancel(); if (!File->IsSymLink) { - FILE_OPERATION_LOOP (FMTLOAD(NOT_DIRECTORY_ERROR, (DestFullName)), - int Attrs = FileGetAttr(DestFullName); + FILE_OPERATION_LOOP_BEGIN + { + int Attrs = FileGetAttr(ApiPath(DestFullName)); if (FLAGCLEAR(Attrs, faDirectory)) { EXCEPTION; } - ); + } + FILE_OPERATION_LOOP_END(FMTLOAD(NOT_DIRECTORY_ERROR, (DestFullName))); - FILE_OPERATION_LOOP (FMTLOAD(CREATE_DIR_ERROR, (DestFullName)), - THROWOSIFFALSE(ForceDirectories(DestFullName)); - ); + FILE_OPERATION_LOOP_BEGIN + { + THROWOSIFFALSE(ForceDirectories(ApiPath(DestFullName))); + } + FILE_OPERATION_LOOP_END(FMTLOAD(CREATE_DIR_ERROR, (DestFullName))); TSinkFileParams SinkFileParams; SinkFileParams.TargetDir = IncludeTrailingBackslash(DestFullName); @@ -1222,13 +1236,15 @@ void __fastcall TFTPFileSystem::Sink(const UnicodeString FileName, OperationProgress->SetLocalSize(OperationProgress->TransferSize); int Attrs; - FILE_OPERATION_LOOP (FMTLOAD(NOT_FILE_ERROR, (DestFullName)), - Attrs = FileGetAttr(DestFullName); + FILE_OPERATION_LOOP_BEGIN + { + Attrs = FileGetAttr(ApiPath(DestFullName)); if ((Attrs >= 0) && FLAGSET(Attrs, faDirectory)) { EXCEPTION; } - ); + } + FILE_OPERATION_LOOP_END(FMTLOAD(NOT_FILE_ERROR, (DestFullName))); OperationProgress->TransferingFile = false; // not set with FTP protocol @@ -1260,7 +1276,7 @@ void __fastcall TFTPFileSystem::Sink(const UnicodeString FileName, if (DestFileName != UserData.FileName) { DestFullName = TargetDir + UserData.FileName; - Attrs = FileGetAttr(DestFullName); + Attrs = FileGetAttr(ApiPath(DestFullName)); } Action.Destination(ExpandUNCFileName(DestFullName)); @@ -1272,9 +1288,11 @@ void __fastcall TFTPFileSystem::Sink(const UnicodeString FileName, int NewAttrs = CopyParam->LocalFileAttrs(*File->Rights); if ((NewAttrs & Attrs) != NewAttrs) { - FILE_OPERATION_LOOP (FMTLOAD(CANT_SET_ATTRS, (DestFullName)), - THROWOSIFFALSE(FileSetAttr(DestFullName, Attrs | NewAttrs) == 0); - ); + FILE_OPERATION_LOOP_BEGIN + { + THROWOSIFFALSE(FileSetAttr(ApiPath(DestFullName), Attrs | NewAttrs) == 0); + } + FILE_OPERATION_LOOP_END(FMTLOAD(CANT_SET_ATTRS, (DestFullName))); } } @@ -1304,12 +1322,13 @@ void __fastcall TFTPFileSystem::SinkFile(UnicodeString FileName, Params->Skipped = true; - SUSPEND_OPERATION ( + { + TSuspendFileOperationProgress Suspend(OperationProgress); if (!FTerminal->HandleException(&E)) { throw; } - ); + } if (OperationProgress->Cancel) { @@ -1344,7 +1363,7 @@ void __fastcall TFTPFileSystem::CopyToRemote(TStrings * FilesToCopy, { FTerminal->DirectoryModified(TargetDir, false); - if (DirectoryExists(FileName)) + if (DirectoryExists(ApiPath(FileName))) { FTerminal->DirectoryModified(FullTargetDir + FileNameOnly, true); } @@ -1356,9 +1375,11 @@ void __fastcall TFTPFileSystem::CopyToRemote(TStrings * FilesToCopy, } catch(EScpSkipFile & E) { - SUSPEND_OPERATION ( - if (!FTerminal->HandleException(&E)) throw; - ); + TSuspendFileOperationProgress Suspend(OperationProgress); + if (!FTerminal->HandleException(&E)) + { + throw; + } } } __finally @@ -1419,9 +1440,8 @@ void __fastcall TFTPFileSystem::Source(const UnicodeString FileName, OperationProgress->SetFile(FileName, false); - if (!FTerminal->AllowLocalFileTransfer(FileName, CopyParam)) + if (!FTerminal->AllowLocalFileTransfer(FileName, CopyParam, OperationProgress)) { - FTerminal->LogEvent(FORMAT(L"File \"%s\" excluded from transfer", (FileName))); THROW_SKIP_FILE_NULL; } @@ -1519,16 +1539,20 @@ void __fastcall TFTPFileSystem::Source(const UnicodeString FileName, { if (!Dir) { - FILE_OPERATION_LOOP (FMTLOAD(DELETE_LOCAL_FILE_ERROR, (FileName)), - THROWOSIFFALSE(Sysutils::DeleteFile(FileName)); - ) + FILE_OPERATION_LOOP_BEGIN + { + THROWOSIFFALSE(Sysutils::DeleteFile(ApiPath(FileName))); + } + FILE_OPERATION_LOOP_END(FMTLOAD(DELETE_LOCAL_FILE_ERROR, (FileName))); } } else if (CopyParam->ClearArchive && FLAGSET(Attrs, faArchive)) { - FILE_OPERATION_LOOP (FMTLOAD(CANT_SET_ATTRS, (FileName)), - THROWOSIFFALSE(FileSetAttr(FileName, Attrs & ~faArchive) == 0); - ) + FILE_OPERATION_LOOP_BEGIN + { + THROWOSIFFALSE(FileSetAttr(ApiPath(FileName), Attrs & ~faArchive) == 0); + } + FILE_OPERATION_LOOP_END(FMTLOAD(CANT_SET_ATTRS, (FileName))); } } //--------------------------------------------------------------------------- @@ -1547,10 +1571,12 @@ void __fastcall TFTPFileSystem::DirectorySource(const UnicodeString DirectoryNam TSearchRecChecked SearchRec; bool FindOK; - FILE_OPERATION_LOOP (FMTLOAD(LIST_DIR_ERROR, (DirectoryName)), - FindOK = (bool)(FindFirstChecked(DirectoryName + L"*.*", - FindAttrs, SearchRec) == 0); - ); + FILE_OPERATION_LOOP_BEGIN + { + FindOK = + (FindFirstChecked(DirectoryName + L"*.*", FindAttrs, SearchRec) == 0); + } + FILE_OPERATION_LOOP_END(FMTLOAD(LIST_DIR_ERROR, (DirectoryName))); bool CreateDir = true; @@ -1575,17 +1601,21 @@ void __fastcall TFTPFileSystem::DirectorySource(const UnicodeString DirectoryNam catch (EScpSkipFile &E) { // If ESkipFile occurs, just log it and continue with next file - SUSPEND_OPERATION ( - // here a message to user was displayed, which was not appropriate - // when user refused to overwrite the file in subdirectory. - // hopefuly it won't be missing in other situations. - if (!FTerminal->HandleException(&E)) throw; - ); + TSuspendFileOperationProgress Suspend(OperationProgress); + // here a message to user was displayed, which was not appropriate + // when user refused to overwrite the file in subdirectory. + // hopefully it won't be missing in other situations. + if (!FTerminal->HandleException(&E)) + { + throw; + } } - FILE_OPERATION_LOOP (FMTLOAD(LIST_DIR_ERROR, (DirectoryName)), + FILE_OPERATION_LOOP_BEGIN + { FindOK = (FindNextChecked(SearchRec) == 0); - ); + } + FILE_OPERATION_LOOP_END(FMTLOAD(LIST_DIR_ERROR, (DirectoryName))); } } __finally @@ -1636,13 +1666,15 @@ void __fastcall TFTPFileSystem::DirectorySource(const UnicodeString DirectoryNam { if (FLAGSET(Params, cpDelete)) { - RemoveDir(DirectoryName); + RemoveDir(ApiPath(DirectoryName)); } else if (CopyParam->ClearArchive && FLAGSET(Attrs, faArchive)) { - FILE_OPERATION_LOOP (FMTLOAD(CANT_SET_ATTRS, (DirectoryName)), - THROWOSIFFALSE(FileSetAttr(DirectoryName, Attrs & ~faArchive) == 0); - ) + FILE_OPERATION_LOOP_BEGIN + { + THROWOSIFFALSE(FileSetAttr(ApiPath(DirectoryName), Attrs & ~faArchive) == 0); + } + FILE_OPERATION_LOOP_END(FMTLOAD(CANT_SET_ATTRS, (DirectoryName))); } } } @@ -1664,7 +1696,7 @@ void __fastcall TFTPFileSystem::CreateDirectory(const UnicodeString ADirName) void __fastcall TFTPFileSystem::CreateLink(const UnicodeString /*FileName*/, const UnicodeString /*PointTo*/, bool /*Symbolic*/) { - assert(false); + FAIL; } //--------------------------------------------------------------------------- void __fastcall TFTPFileSystem::DeleteFile(const UnicodeString AFileName, @@ -1722,7 +1754,7 @@ void __fastcall TFTPFileSystem::CustomCommandOnFile(const UnicodeString /*FileNa { // if ever implemented, do not forget to add EnsureLocation, // see AnyCommand for a reason why - assert(false); + FAIL; } //--------------------------------------------------------------------------- void __fastcall TFTPFileSystem::DoStartup() @@ -1775,6 +1807,7 @@ bool __fastcall TFTPFileSystem::IsCapable(int Capability) const case fcRename: case fcRemoteMove: case fcRemoveBOMUpload: + case fcMoveToQueue: return true; case fcPreservingTimestampUpload: @@ -1800,14 +1833,14 @@ bool __fastcall TFTPFileSystem::IsCapable(int Capability) const return false; default: - assert(false); + FAIL; return false; } } //--------------------------------------------------------------------------- void __fastcall TFTPFileSystem::LookupUsersGroups() { - assert(false); + FAIL; } //--------------------------------------------------------------------------- void __fastcall TFTPFileSystem::ReadCurrentDirectory() @@ -2003,7 +2036,7 @@ void __fastcall TFTPFileSystem::ReadFile(const UnicodeString FileName, UnicodeString NameOnly = UnixExtractFileName(FileName); TRemoteFile *AFile = NULL; bool Own; - if (FServerCapabilities->GetCapability(mlsd_command) == yes) + if (FFileZillaIntf->UsingMlsd()) { DoReadFile(FileName, AFile); Own = true; @@ -2014,7 +2047,7 @@ void __fastcall TFTPFileSystem::ReadFile(const UnicodeString FileName, // In case we need properties of set of files from the same directory, // cache the file list for future if ((FFileListCache != NULL) && - UnixComparePaths(Path, FFileListCache->Directory) && + UnixSamePath(Path, FFileListCache->Directory) && (UnixIsAbsolutePath(FFileListCache->Directory) || (FFileListCachePath == CurrentDirectory))) { @@ -2063,10 +2096,7 @@ void __fastcall TFTPFileSystem::ReadSymlink(TRemoteFile * SymlinkFile, // Resolving symlinks over FTP is big overhead // (involves opening TCPIP connection for retrieving "directory listing"). // Moreover FZAPI does not support that anyway. - // Note that while we could use MLST to read the symlink, - // it's hardly of any use as, if MLST is supported, we use MLSD to - // retrieve directory listing and from MLSD we cannot atm detect that - // the file is symlink anyway. + // Though nowadays we could use MLST to read the symlink. File = new TRemoteFile(SymlinkFile); try { @@ -2108,13 +2138,7 @@ void __fastcall TFTPFileSystem::RenameFile(const UnicodeString AFileName, void __fastcall TFTPFileSystem::CopyFile(const UnicodeString FileName, const UnicodeString NewName) { - assert(false); -} -//--------------------------------------------------------------------------- -UnicodeString __fastcall TFTPFileSystem::FileUrl(const UnicodeString FileName) -{ - UnicodeString Protocol = (FTerminal->SessionData->Ftps == ftpsImplicit) ? FtpsProtocol : FtpProtocol; - return FTerminal->FileUrl(Protocol, FileName); + FAIL; } //--------------------------------------------------------------------------- TStrings * __fastcall TFTPFileSystem::GetFixedPaths() @@ -2125,7 +2149,7 @@ TStrings * __fastcall TFTPFileSystem::GetFixedPaths() void __fastcall TFTPFileSystem::SpaceAvailable(const UnicodeString /*Path*/, TSpaceAvailable & /*ASpaceAvailable*/) { - assert(false); + FAIL; } //--------------------------------------------------------------------------- const TSessionInfo & __fastcall TFTPFileSystem::GetSessionInfo() @@ -2154,10 +2178,7 @@ const TFileSystemInfo & __fastcall TFTPFileSystem::GetFileSystemInfo(bool /*Retr } } - for (int Index = 0; Index < fcCount; Index++) - { - FFileSystemInfo.IsCapable[Index] = IsCapable((TFSCapability)Index); - } + FTerminal->SaveCapabilities(FFileSystemInfo); FFileSystemInfoValid = true; } @@ -2215,7 +2236,7 @@ const wchar_t * __fastcall TFTPFileSystem::GetOption(int OptionID) const break; default: - assert(false); + FAIL; FOptionScratch = L""; } @@ -2251,7 +2272,7 @@ int __fastcall TFTPFileSystem::GetOptionVal(int OptionID) const case pmTelnet: case pmCmd: default: - assert(false); + FAIL; Result = 0; // PROXYTYPE_NOPROXY; break; } @@ -2280,7 +2301,7 @@ int __fastcall TFTPFileSystem::GetOptionVal(int OptionID) const case OPTION_PASV: // should never get here t_server.nPasv being nonzero - assert(false); + FAIL; Result = FALSE; break; @@ -2296,7 +2317,7 @@ int __fastcall TFTPFileSystem::GetOptionVal(int OptionID) const case OPTION_PORTRANGELOW: case OPTION_PORTRANGEHIGH: // should never get here OPTION_LIMITPORTRANGE being zero - assert(false); + FAIL; Result = 0; break; @@ -2324,7 +2345,7 @@ int __fastcall TFTPFileSystem::GetOptionVal(int OptionID) const case OPTION_SPEEDLIMIT_DOWNLOAD_VALUE: case OPTION_SPEEDLIMIT_UPLOAD_VALUE: - Result = (FFileTransferCPSLimit / 1024); // FZAPI expects KiB/s + Result = (FFileTransferCPSLimit / 1024); // FZAPI expects KB/s break; case OPTION_MPEXT_SHOWHIDDEN: @@ -2347,8 +2368,8 @@ int __fastcall TFTPFileSystem::GetOptionVal(int OptionID) const Result = Data->SendBuf; break; - case OPTION_MPEXT_TRANSFER_ACTIVE_IMMEDIATELLY: - Result = Data->FtpTransferActiveImmediatelly; + case OPTION_MPEXT_TRANSFER_ACTIVE_IMMEDIATELY: + Result = Data->FtpTransferActiveImmediately; break; case OPTION_MPEXT_REMOVE_BOM: @@ -2356,7 +2377,7 @@ int __fastcall TFTPFileSystem::GetOptionVal(int OptionID) const break; default: - assert(false); + FAIL; Result = FALSE; break; } @@ -2549,7 +2570,7 @@ unsigned int __fastcall TFTPFileSystem::WaitForCommandReply(bool WantLastCode) void __fastcall TFTPFileSystem::WaitForFatalNonCommandReply() { WaitForReply(false, false); - assert(false); + FAIL; } //--------------------------------------------------------------------------- void __fastcall TFTPFileSystem::ResetReply() @@ -2569,7 +2590,7 @@ void __fastcall TFTPFileSystem::GotNonCommandReply(unsigned int Reply) assert(FLAGSET(Reply, TFileZillaIntf::REPLY_DISCONNECTED)); GotReply(Reply); // should never get here as GotReply should raise fatal exception - assert(false); + FAIL; } //--------------------------------------------------------------------------- void __fastcall TFTPFileSystem::GotReply(unsigned int Reply, unsigned int Flags, @@ -2983,7 +3004,7 @@ bool __fastcall TFTPFileSystem::HandleStatus(const wchar_t * AStatus, int Type) break; default: - assert(false); + FAIL; break; } @@ -3030,7 +3051,7 @@ TDateTime __fastcall TFTPFileSystem::ConvertLocalTimestamp(time_t Time) //--------------------------------------------------------------------------- bool __fastcall TFTPFileSystem::HandleAsynchRequestOverwrite( wchar_t * FileName1, size_t FileName1Len, const wchar_t * /*FileName2*/, - const wchar_t * /*Path1*/, const wchar_t * /*Path2*/, + const wchar_t * /*Path1*/, const wchar_t * Path2, __int64 Size1, __int64 Size2, time_t LocalTime, bool /*HasLocalTime*/, const TRemoteFileTime & RemoteTime, void * AUserData, int & RequestResult) { @@ -3073,7 +3094,18 @@ bool __fastcall TFTPFileSystem::HandleAsynchRequestOverwrite( } } - if (ConfirmOverwrite(FileName, OverwriteMode, OperationProgress, + UnicodeString FullFileName = Path2; + if (OperationProgress->Side == osLocal) + { + FullFileName = IncludeTrailingBackslash(FullFileName); + } + else + { + FullFileName = UnixIncludeTrailingBackslash(FullFileName); + } + FullFileName += FileName; + + if (ConfirmOverwrite(FullFileName, FileName, OverwriteMode, OperationProgress, (NoFileParams ? NULL : &FileParams), UserData.CopyParam, UserData.Params, UserData.AutoResume && UserData.CopyParam->AllowResume(FileParams.SourceSize))) { @@ -3103,7 +3135,7 @@ bool __fastcall TFTPFileSystem::HandleAsynchRequestOverwrite( break; default: - assert(false); + FAIL; RequestResult = TFileZillaIntf::FILEEXISTS_OVERWRITE; break; } @@ -3128,17 +3160,6 @@ bool __fastcall TFTPFileSystem::HandleAsynchRequestOverwrite( } } //--------------------------------------------------------------------------- -struct TClipboardHandler -{ - UnicodeString Text; - - void __fastcall Copy(TObject * /*Sender*/) - { - TInstantOperationVisualizer Visualizer; - CopyToClipboard(Text); - } -}; -//--------------------------------------------------------------------------- UnicodeString __fastcall FormatContactList(UnicodeString Entry1, UnicodeString Entry2) { if (!Entry1.IsEmpty() && !Entry2.IsEmpty()) @@ -3278,87 +3299,114 @@ bool __fastcall TFTPFileSystem::HandleAsynchRequestVerifyCertificate( BytesToHex(RawByteString((const char*)Data.Hash, Data.HashLen), false, L':'); UnicodeString CertificateSubject = Data.Subject.Organization; - FTerminal->LogEvent(FORMAT(L"Verifying certificate for \"%s\" with fingerprint %s", (CertificateSubject, FSessionInfo.CertificateFingerprint))); + FTerminal->LogEvent(FORMAT(L"Verifying certificate for \"%s\" with fingerprint %s and %d failures", (CertificateSubject, FSessionInfo.CertificateFingerprint, Data.VerificationResult))); - int VerificationResultStr; + bool VerificationResult = false; + bool TryWindowsSystemCertificateStore = false; + UnicodeString VerificationResultStr; switch (Data.VerificationResult) { case X509_V_OK: - VerificationResultStr = -1; + VerificationResult = true; break; case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: - VerificationResultStr = CERT_ERR_UNABLE_TO_GET_ISSUER_CERT; + VerificationResultStr = LoadStr(CERT_ERR_UNABLE_TO_GET_ISSUER_CERT); + TryWindowsSystemCertificateStore = true; break; case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: - VerificationResultStr = CERT_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE; + VerificationResultStr = LoadStr(CERT_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE); break; case X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: - VerificationResultStr = CERT_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY; + VerificationResultStr = LoadStr(CERT_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY); break; case X509_V_ERR_CERT_SIGNATURE_FAILURE: - VerificationResultStr = CERT_ERR_CERT_SIGNATURE_FAILURE; + VerificationResultStr = LoadStr(CERT_ERR_CERT_SIGNATURE_FAILURE); break; case X509_V_ERR_CERT_NOT_YET_VALID: - VerificationResultStr = CERT_ERR_CERT_NOT_YET_VALID; + VerificationResultStr = LoadStr(CERT_ERR_CERT_NOT_YET_VALID); break; case X509_V_ERR_CERT_HAS_EXPIRED: - VerificationResultStr = CERT_ERR_CERT_HAS_EXPIRED; + VerificationResultStr = LoadStr(CERT_ERR_CERT_HAS_EXPIRED); break; case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: - VerificationResultStr = CERT_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD; + VerificationResultStr = LoadStr(CERT_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD); break; case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: - VerificationResultStr = CERT_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD; + VerificationResultStr = LoadStr(CERT_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD); break; case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: - VerificationResultStr = CERT_ERR_DEPTH_ZERO_SELF_SIGNED_CERT; + VerificationResultStr = LoadStr(CERT_ERR_DEPTH_ZERO_SELF_SIGNED_CERT); + TryWindowsSystemCertificateStore = true; break; case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: - VerificationResultStr = CERT_ERR_SELF_SIGNED_CERT_IN_CHAIN; + VerificationResultStr = LoadStr(CERT_ERR_SELF_SIGNED_CERT_IN_CHAIN); + TryWindowsSystemCertificateStore = true; break; case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: - VerificationResultStr = CERT_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY; + VerificationResultStr = LoadStr(CERT_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY); + TryWindowsSystemCertificateStore = true; break; case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: - VerificationResultStr = CERT_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE; + VerificationResultStr = LoadStr(CERT_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE); + TryWindowsSystemCertificateStore = true; break; case X509_V_ERR_INVALID_CA: - VerificationResultStr = CERT_ERR_INVALID_CA; + VerificationResultStr = LoadStr(CERT_ERR_INVALID_CA); break; case X509_V_ERR_PATH_LENGTH_EXCEEDED: - VerificationResultStr = CERT_ERR_PATH_LENGTH_EXCEEDED; + VerificationResultStr = LoadStr(CERT_ERR_PATH_LENGTH_EXCEEDED); break; case X509_V_ERR_INVALID_PURPOSE: - VerificationResultStr = CERT_ERR_INVALID_PURPOSE; + VerificationResultStr = LoadStr(CERT_ERR_INVALID_PURPOSE); break; case X509_V_ERR_CERT_UNTRUSTED: - VerificationResultStr = CERT_ERR_CERT_UNTRUSTED; + VerificationResultStr = LoadStr(CERT_ERR_CERT_UNTRUSTED); + TryWindowsSystemCertificateStore = true; break; case X509_V_ERR_CERT_REJECTED: - VerificationResultStr = CERT_ERR_CERT_REJECTED; + VerificationResultStr = LoadStr(CERT_ERR_CERT_REJECTED); break; case X509_V_ERR_KEYUSAGE_NO_CERTSIGN: - VerificationResultStr = CERT_ERR_KEYUSAGE_NO_CERTSIGN; + VerificationResultStr = LoadStr(CERT_ERR_KEYUSAGE_NO_CERTSIGN); break; case X509_V_ERR_CERT_CHAIN_TOO_LONG: - VerificationResultStr = CERT_ERR_CERT_CHAIN_TOO_LONG; + VerificationResultStr = LoadStr(CERT_ERR_CERT_CHAIN_TOO_LONG); break; default: - VerificationResultStr = CERT_ERR_UNKNOWN; + VerificationResultStr = + FORMAT(L"%s (%s)", + (LoadStr(CERT_ERR_UNKNOWN), X509_verify_cert_error_string(Data.VerificationResult))); break; } + // TryWindowsSystemCertificateStore is set for the same set of failures + // as trigger NE_SSL_UNTRUSTED flag in ne_openssl.c's verify_callback() + if (!VerificationResult && TryWindowsSystemCertificateStore) + { + if (WindowsValidateCertificate(Data.Certificate, Data.CertificateLen)) + { + FTerminal->LogEvent(L"Certificate verified against Windows certificate store"); + VerificationResult = true; + } + } + UnicodeString Summary; - if (VerificationResultStr >= 0) + if (!VerificationResult) { - Summary = LoadStr(VerificationResultStr) + L" " + FMTLOAD(CERT_ERRDEPTH, (Data.VerificationDepth + 1)); + Summary = VerificationResultStr + L" " + FMTLOAD(CERT_ERRDEPTH, (Data.VerificationDepth + 1)); } if (!VerifyCertificateHostName(Data)) { + VerificationResult = false; AddToList(Summary, FMTLOAD(CERT_NAME_MISMATCH, (FTerminal->SessionData->HostNameExpanded)), L"\n\n"); } + if (VerificationResult) + { + Summary = LoadStr(CERT_OK); + } + FSessionInfo.Certificate = FMTLOAD(CERT_TEXT, ( FormatContact(Data.Issuer), @@ -3370,50 +3418,17 @@ bool __fastcall TFTPFileSystem::HandleAsynchRequestVerifyCertificate( RequestResult = 0; - if (Summary.IsEmpty()) + if (VerificationResult) { RequestResult = 1; } if (RequestResult == 0) { - THierarchicalStorage * Storage = - FTerminal->Configuration->CreateScpStorage(false); - try - { - Storage->AccessMode = smRead; - - if (Storage->OpenSubKey(CertificateStorageKey, false) && - Storage->ValueExists(FSessionInfo.CertificateFingerprint)) - { - FTerminal->LogEvent(FORMAT(L"Certificate for \"%s\" matches cached fingerprint", (CertificateSubject))); - RequestResult = 1; - } - } - __finally - { - delete Storage; - } - } - - if (RequestResult == 0) - { - UnicodeString Buf = FTerminal->SessionData->HostKey; - while ((RequestResult == 0) && !Buf.IsEmpty()) + if (FTerminal->VerifyCertificate(CertificateStorageKey, + FSessionInfo.CertificateFingerprint, CertificateSubject, Data.VerificationResult)) { - UnicodeString ExpectedKey = CutToChar(Buf, L';', false); - if (ExpectedKey == L"*") - { - UnicodeString Message = LoadStr(ANY_CERTIFICATE); - FTerminal->Information(Message, true); - FTerminal->Log->Add(llException, Message); - RequestResult = 1; - } - else if (ExpectedKey == FSessionInfo.CertificateFingerprint) - { - FTerminal->LogEvent(FORMAT(L"Certificate for \"%s\" matches configured fingerprint", (CertificateSubject))); - RequestResult = 1; - } + RequestResult = 1; } } @@ -3454,28 +3469,15 @@ bool __fastcall TFTPFileSystem::HandleAsynchRequestVerifyCertificate( break; default: - assert(false); + FAIL; RequestResult = 0; break; } if (RequestResult == 2) { - THierarchicalStorage * Storage = - FTerminal->Configuration->CreateScpStorage(false); - try - { - Storage->AccessMode = smReadWrite; - - if (Storage->OpenSubKey(CertificateStorageKey, true)) - { - Storage->WriteString(FSessionInfo.CertificateFingerprint, L""); - } - } - __finally - { - delete Storage; - } + FTerminal->CacheCertificate( + CertificateStorageKey, FSessionInfo.CertificateFingerprint, Data.VerificationResult); } } @@ -3562,7 +3564,7 @@ bool __fastcall TFTPFileSystem::HandleListData(const wchar_t * Path, assert(FFileList != NULL); // this can actually fail in real life, // when connected to server with case insensitive paths - assert(UnixComparePaths(AbsolutePath(FFileList->Directory, false), Path)); + assert(UnixSamePath(AbsolutePath(FFileList->Directory, false), Path)); USEDPARAM(Path); for (unsigned int Index = 0; Index < Count; Index++) @@ -3614,7 +3616,7 @@ bool __fastcall TFTPFileSystem::HandleListData(const wchar_t * Path, } else { - File->Type = L'-'; + File->Type = FILETYPE_DEFAULT; } TDateTime Modification; @@ -3731,7 +3733,7 @@ bool __fastcall TFTPFileSystem::CheckError(int ReturnCode, const wchar_t * Conte { FTerminal->FatalError(NULL, FMTLOAD(INTERNAL_ERROR, (FORMAT(L"fz#%s", (Context)), IntToHex(ReturnCode, 4)))); - assert(false); + FAIL; } return false; @@ -3765,7 +3767,7 @@ bool __fastcall TFTPFileSystem::Unquote(UnicodeString & Str) } else { - assert(false); + FAIL; // no quoted string Str.SetLength(0); } @@ -3814,7 +3816,7 @@ bool __fastcall TFTPFileSystem::GetFileModificationTimeInUtc(const wchar_t * Fil try { // error-handling-free and DST-mode-inaware copy of TTerminal::OpenLocalFile - HANDLE Handle = CreateFile(FileName, GENERIC_READ, + HANDLE Handle = CreateFile(ApiPath(FileName).c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0); if (Handle == INVALID_HANDLE_VALUE) { @@ -3861,4 +3863,9 @@ bool __fastcall TFTPFileSystem::GetFileModificationTimeInUtc(const wchar_t * Fil return Result; } //--------------------------------------------------------------------------- +UnicodeString __fastcall GetOpenSSLVersionText() +{ + return OPENSSL_VERSION_TEXT; +} +//--------------------------------------------------------------------------- #endif NO_FILEZILLA diff --git a/source/core/FtpFileSystem.h b/source/core/FtpFileSystem.h index 922beb51..079305a0 100644 --- a/source/core/FtpFileSystem.h +++ b/source/core/FtpFileSystem.h @@ -72,7 +72,6 @@ friend class TFileListHelper; const UnicodeString NewName); virtual void __fastcall CopyFile(const UnicodeString FileName, const UnicodeString NewName); - virtual UnicodeString __fastcall FileUrl(const UnicodeString FileName); virtual TStrings * __fastcall GetFixedPaths(); virtual void __fastcall SpaceAvailable(const UnicodeString Path, TSpaceAvailable & ASpaceAvailable); @@ -108,7 +107,7 @@ friend class TFileListHelper; void __fastcall PoolForFatalNonCommandReply(); void __fastcall GotNonCommandReply(unsigned int Reply); void __fastcall GotReply(unsigned int Reply, unsigned int Flags = 0, - UnicodeString Error = "", unsigned int * Code = NULL, + UnicodeString Error = L"", unsigned int * Code = NULL, TStrings ** Response = NULL); void __fastcall ResetReply(); void __fastcall HandleReplyStatus(UnicodeString Response); @@ -161,7 +160,7 @@ friend class TFileListHelper; void __fastcall DirectorySource(const UnicodeString DirectoryName, const UnicodeString TargetDir, int Attrs, const TCopyParamType * CopyParam, int Params, TFileOperationProgressType * OperationProgress, unsigned int Flags); - bool __fastcall ConfirmOverwrite(UnicodeString & FileName, + bool __fastcall ConfirmOverwrite(const UnicodeString & FullFileName, UnicodeString & FileName, TOverwriteMode & OverwriteMode, TFileOperationProgressType * OperationProgress, const TOverwriteFileParams * FileParams, const TCopyParamType * CopyParam, int Params, bool AutoResume); @@ -245,6 +244,8 @@ friend class TFileListHelper; mutable UnicodeString FOptionScratch; }; //--------------------------------------------------------------------------- +UnicodeString __fastcall GetOpenSSLVersionText(); +//--------------------------------------------------------------------------- #endif NO_FILEZILLA //--------------------------------------------------------------------------- #endif // FtpFileSystemH diff --git a/source/core/HierarchicalStorage.cpp b/source/core/HierarchicalStorage.cpp index 7a94f810..e3257383 100644 --- a/source/core/HierarchicalStorage.cpp +++ b/source/core/HierarchicalStorage.cpp @@ -6,6 +6,7 @@ #include "Exceptions.h" #include "PuttyIntf.h" #include "HierarchicalStorage.h" +#include #include #include #include @@ -709,8 +710,8 @@ bool __fastcall TCustomIniFileStorage::DoOpenSubKey(const UnicodeString SubKey, TStringList * Sections = new TStringList(); try { - Sections->Sorted = true; FIniFile->ReadSections(Sections); + Sections->Sorted = true; // has to set only after reading as ReadSections reset it to false UnicodeString NewKey = ExcludeTrailingBackslash(CurrentSubKey+SubKey); if (Sections->Count) { @@ -971,17 +972,17 @@ void __fastcall TIniFileStorage::Flush() { int Attr; // preserve attributes (especially hidden) - bool Exists = FileExists(Storage); + bool Exists = FileExists(ApiPath(Storage)); if (Exists) { - Attr = GetFileAttributes(UnicodeString(Storage).c_str()); + Attr = GetFileAttributes(ApiPath(Storage).c_str()); } else { Attr = FILE_ATTRIBUTE_NORMAL; } - HANDLE Handle = CreateFile(UnicodeString(Storage).c_str(), GENERIC_READ | GENERIC_WRITE, + HANDLE Handle = CreateFile(ApiPath(Storage).c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, Attr, 0); if (Handle == INVALID_HANDLE_VALUE) diff --git a/source/core/Interface.h b/source/core/Interface.h index d4e90c3c..5a241eff 100644 --- a/source/core/Interface.h +++ b/source/core/Interface.h @@ -9,6 +9,7 @@ TConfiguration * __fastcall CreateConfiguration(); void __fastcall ShowExtendedException(Exception * E); +bool __fastcall AppendExceptionStackTrace(TStrings *& MoreMessages); UnicodeString __fastcall GetCompanyRegistryKey(); UnicodeString __fastcall GetRegistryKey(); @@ -99,6 +100,7 @@ enum TPromptKind enum TPromptUserParam { pupEcho = 0x01, pupRemember = 0x02 }; bool __fastcall IsAuthenticationPrompt(TPromptKind Kind); +bool __fastcall IsPasswordOrPassphrasePrompt(TPromptKind Kind, TStrings * Prompts); bool __fastcall IsPasswordPrompt(TPromptKind Kind, TStrings * Prompts); //--------------------------------------------------------------------------- typedef void __fastcall (__closure *TFileFoundEvent) @@ -128,4 +130,15 @@ class TInstantOperationVisualizer : public TOperationVisualizer TDateTime FStart; }; //--------------------------------------------------------------------------- +struct TClipboardHandler +{ + UnicodeString Text; + + void __fastcall Copy(TObject * /*Sender*/) + { + TInstantOperationVisualizer Visualizer; + CopyToClipboard(Text); + } +}; +//--------------------------------------------------------------------------- #endif diff --git a/source/core/KeyGen.cpp b/source/core/KeyGen.cpp index 0fcce790..8fd7c108 100644 --- a/source/core/KeyGen.cpp +++ b/source/core/KeyGen.cpp @@ -379,7 +379,7 @@ void __fastcall TKeyGenerator::SaveKey(const AnsiString FileName, break; default: - assert(false); + FAIL; } } else diff --git a/source/core/PuttyIntf.cpp b/source/core/PuttyIntf.cpp index a0cf6510..e744a19c 100644 --- a/source/core/PuttyIntf.cpp +++ b/source/core/PuttyIntf.cpp @@ -175,7 +175,7 @@ int get_userpass_input(prompts_t * p, unsigned char * /*in*/, int /*inlen*/) char * get_ttymode(void * /*frontend*/, const char * /*mode*/) { // should never happen when Config.nopty == TRUE - assert(false); + FAIL; return NULL; } //--------------------------------------------------------------------------- @@ -279,7 +279,7 @@ int askappend(void * /*frontend*/, Filename * /*filename*/, void (*/*callback*/)(void * ctx, int result), void * /*ctx*/) { // this is called from logging.c of putty, which is never used with WinSCP - assert(false); + FAIL; return 0; } //--------------------------------------------------------------------------- @@ -296,7 +296,7 @@ void ldisc_send(void * /*handle*/, char * /*buf*/, int len, int /*interactive*/) void agent_schedule_callback(void (* /*callback*/)(void *, void *, int), void * /*callback_ctx*/, void * /*data*/, int /*len*/) { - assert(false); + FAIL; } //--------------------------------------------------------------------------- void notify_remote_exit(void * /*frontend*/) @@ -432,7 +432,7 @@ long reg_query_winscp_value_ex(HKEY Key, const char * ValueName, unsigned long * } else { - assert(false); + FAIL; R = ERROR_READ_FAULT; } } diff --git a/source/core/Queue.cpp b/source/core/Queue.cpp index 4e5a1537..fefb410c 100644 --- a/source/core/Queue.cpp +++ b/source/core/Queue.cpp @@ -205,13 +205,14 @@ class TReadDirectoryProgressAction : public TUserAction { if (OnReadDirectoryProgress != NULL) { - OnReadDirectoryProgress(Sender, Progress, Cancel); + OnReadDirectoryProgress(Sender, Progress, ResolvedLinks, Cancel); } } TReadDirectoryProgressEvent OnReadDirectoryProgress; TObject * Sender; int Progress; + int ResolvedLinks; bool Cancel; }; //--------------------------------------------------------------------------- @@ -256,8 +257,7 @@ friend class TBackgroundTerminal; void __fastcall OperationFinished(TFileOperation Operation, TOperationSide Side, bool Temp, const UnicodeString & FileName, bool Success, TOnceDoneOperation & OnceDoneOperation); - void __fastcall OperationProgress(TFileOperationProgressType & ProgressData, - TCancelStatus & Cancel); + void __fastcall OperationProgress(TFileOperationProgressType & ProgressData); }; //--------------------------------------------------------------------------- // TSignalThread @@ -273,7 +273,7 @@ int __fastcall TSimpleThread::ThreadProc(void * Thread) catch(...) { // we do not expect thread to be terminated with exception - assert(false); + FAIL; } SimpleThread->FFinished = true; SimpleThread->Finished(); @@ -575,6 +575,7 @@ void __fastcall TTerminalQueue::DeleteItem(TQueueItem * Item, bool CanKeep) if (!FTerminated) { bool Empty; + bool EmptyButMonitored; bool Monitored; { TGuard Guard(FItemsSection); @@ -599,19 +600,24 @@ void __fastcall TTerminalQueue::DeleteItem(TQueueItem * Item, bool CanKeep) delete Item; } - Empty = true; + EmptyButMonitored = true; Index = 0; - while (Empty && (Index < FItems->Count)) + while (EmptyButMonitored && (Index < FItems->Count)) { - Empty = (GetItem(FItems, Index)->CompleteEvent != INVALID_HANDLE_VALUE); + EmptyButMonitored = (GetItem(FItems, Index)->CompleteEvent != INVALID_HANDLE_VALUE); Index++; } + Empty = (FItems->Count == 0); } DoListUpdate(); - // report empty, if queue is empty or only monitored items are pending. + // report empty but/except for monitored, if queue is empty or only monitored items are pending. // do not report if current item was the last, but was monitored. - if (!Monitored && Empty) + if (!Monitored && EmptyButMonitored) + { + DoEvent(qeEmptyButMonitored); + } + if (Empty) { DoEvent(qeEmpty); } @@ -1428,7 +1434,7 @@ void __fastcall TTerminalItem::TerminalPromptUser(TTerminal * Terminal, if (FItem == NULL) { // sanity, should not occur - assert(false); + FAIL; Result = false; } else @@ -1478,7 +1484,7 @@ void __fastcall TTerminalItem::OperationFinished(TFileOperation /*Operation*/, } //--------------------------------------------------------------------------- void __fastcall TTerminalItem::OperationProgress( - TFileOperationProgressType & ProgressData, TCancelStatus & Cancel) + TFileOperationProgressType & ProgressData) { if (FPause && !FTerminated && !FCancel) { @@ -1507,11 +1513,11 @@ void __fastcall TTerminalItem::OperationProgress( { if (ProgressData.TransferingFile) { - Cancel = csCancelTransfer; + ProgressData.Cancel = csCancelTransfer; } else { - Cancel = csCancel; + ProgressData.Cancel = csCancel; } } @@ -1978,8 +1984,8 @@ __fastcall TUploadQueueItem::TUploadQueueItem(TTerminal * Terminal, { if (FLAGSET(Params, cpTemporary)) { - FInfo->Source = ""; - FInfo->ModifiedLocal = ""; + FInfo->Source = L""; + FInfo->ModifiedLocal = L""; } else { @@ -2545,11 +2551,12 @@ void __fastcall TTerminalThread::TerminalStartReadDirectory(TObject * Sender) } //--------------------------------------------------------------------------- void __fastcall TTerminalThread::TerminalReadDirectoryProgress( - TObject * Sender, int Progress, bool & Cancel) + TObject * Sender, int Progress, int ResolvedLinks, bool & Cancel) { TReadDirectoryProgressAction Action(FOnReadDirectoryProgress); Action.Sender = Sender; Action.Progress = Progress; + Action.ResolvedLinks = ResolvedLinks; Action.Cancel = Cancel; WaitForUserAction(&Action); @@ -2557,4 +2564,3 @@ void __fastcall TTerminalThread::TerminalReadDirectoryProgress( Cancel = Action.Cancel; } //--------------------------------------------------------------------------- -#pragma warn -8080 diff --git a/source/core/Queue.h b/source/core/Queue.h index b8a3fc82..ba45562c 100644 --- a/source/core/Queue.h +++ b/source/core/Queue.h @@ -58,7 +58,7 @@ typedef void __fastcall (__closure * TQueueListUpdate) (TTerminalQueue * Queue); typedef void __fastcall (__closure * TQueueItemUpdateEvent) (TTerminalQueue * Queue, TQueueItem * Item); -enum TQueueEvent { qeEmpty, qePendingUserAction }; +enum TQueueEvent { qeEmpty, qeEmptyButMonitored, qePendingUserAction }; typedef void __fastcall (__closure * TQueueEventEvent) (TTerminalQueue * Queue, TQueueEvent Event); //--------------------------------------------------------------------------- @@ -407,7 +407,7 @@ class TTerminalThread : public TSignalThread void __fastcall TerminalChangeDirectory(TObject * Sender); void __fastcall TerminalReadDirectory(TObject * Sender, Boolean ReloadOnly); void __fastcall TerminalStartReadDirectory(TObject * Sender); - void __fastcall TerminalReadDirectoryProgress(TObject * Sender, int Progress, bool & Cancel); + void __fastcall TerminalReadDirectoryProgress(TObject * Sender, int Progress, int ResolvedLinks, bool & Cancel); void __fastcall TerminalInitializeLog(TObject * Sender); }; //--------------------------------------------------------------------------- diff --git a/source/core/RemoteFiles.cpp b/source/core/RemoteFiles.cpp index 44d00d95..a2735c5c 100644 --- a/source/core/RemoteFiles.cpp +++ b/source/core/RemoteFiles.cpp @@ -62,7 +62,7 @@ UnicodeString __fastcall SimpleUnixExcludeTrailingBackslash(const UnicodeString return UnixExcludeTrailingBackslash(Path, true); } //--------------------------------------------------------------------------- -Boolean __fastcall UnixComparePaths(const UnicodeString Path1, const UnicodeString Path2) +Boolean __fastcall UnixSamePath(const UnicodeString Path1, const UnicodeString Path2) { return (UnixIncludeTrailingBackslash(Path1) == UnixIncludeTrailingBackslash(Path2)); } @@ -214,9 +214,17 @@ UnicodeString __fastcall AbsolutePath(const UnicodeString & Base, const UnicodeS int P; while ((P = Result.Pos(L"/../")) > 0) { - int P2 = Result.SubString(1, P-1).LastDelimiter(L"/"); - assert(P2 > 0); - Result.Delete(P2, P - P2 + 3); + // special case, "/../" => "/" + if (P == 1) + { + Result = L"/"; + } + else + { + int P2 = Result.SubString(1, P-1).LastDelimiter(L"/"); + assert(P2 > 0); + Result.Delete(P2, P - P2 + 3); + } } while ((P = Result.Pos(L"/./")) > 0) { @@ -387,7 +395,7 @@ TDateTime __fastcall ReduceDateTimePrecision(TDateTime DateTime, break; default: - assert(false); + FAIL; } DateTime = EncodeDateVerbose(Y, M, D) + EncodeTimeVerbose(H, N, S, MS); @@ -437,7 +445,7 @@ UnicodeString __fastcall ModificationStr(TDateTime DateTime, (EngShortMonthNames[Month-1], Day, Hour, Min)); default: - assert(false); + FAIL; // fall thru case mfFull: @@ -1603,7 +1611,7 @@ __fastcall TRemoteDirectoryCache::TRemoteDirectoryCache(): TStringList() { FSection = new TCriticalSection(); Sorted = true; - Duplicates = dupError; + Duplicates = Types::dupError; CaseSensitive = true; } //--------------------------------------------------------------------------- diff --git a/source/core/RemoteFiles.h b/source/core/RemoteFiles.h index be4843c0..32b8f9ff 100644 --- a/source/core/RemoteFiles.h +++ b/source/core/RemoteFiles.h @@ -11,6 +11,7 @@ enum TModificationFmt { mfNone, mfMDHM, mfMDY, mfFull }; #define PARENTDIRECTORY L".." #define THISDIRECTORY L"." #define ROOTDIRECTORY L"/" +#define FILETYPE_DEFAULT L'-' #define FILETYPE_SYMLINK L'L' #define FILETYPE_DIRECTORY L'D' #define PARTIAL_EXT L".filepart" @@ -434,7 +435,7 @@ UnicodeString __fastcall UnixExtractFileDir(const UnicodeString Path); UnicodeString __fastcall UnixExtractFilePath(const UnicodeString Path); UnicodeString __fastcall UnixExtractFileName(const UnicodeString Path); UnicodeString __fastcall UnixExtractFileExt(const UnicodeString Path); -Boolean __fastcall UnixComparePaths(const UnicodeString Path1, const UnicodeString Path2); +Boolean __fastcall UnixSamePath(const UnicodeString Path1, const UnicodeString Path2); bool __fastcall UnixIsChildPath(UnicodeString Parent, UnicodeString Child); bool __fastcall ExtractCommonPath(TStrings * Files, UnicodeString & Path); bool __fastcall UnixExtractCommonPath(TStrings * Files, UnicodeString & Path); diff --git a/source/core/ScpFileSystem.cpp b/source/core/ScpFileSystem.cpp index 012e005c..025af61d 100644 --- a/source/core/ScpFileSystem.cpp +++ b/source/core/ScpFileSystem.cpp @@ -16,8 +16,7 @@ //--------------------------------------------------------------------------- #pragma package(smart_init) //--------------------------------------------------------------------------- -#define FILE_OPERATION_LOOP_EX(ALLOW_SKIP, MESSAGE, OPERATION) \ - FILE_OPERATION_LOOP_CUSTOM(FTerminal, ALLOW_SKIP, MESSAGE, OPERATION, L"") +#define FILE_OPERATION_LOOP_TERMINAL FTerminal //--------------------------------------------------------------------------- const int coRaiseExcept = 1; const int coExpectNoOutput = 2; @@ -300,10 +299,7 @@ __fastcall TSCPFileSystem::TSCPFileSystem(TTerminal * ATerminal, TSecureShell * FFileSystemInfo.ProtocolBaseName = L"SCP"; FFileSystemInfo.ProtocolName = FFileSystemInfo.ProtocolBaseName; // capabilities of SCP protocol are fixed - for (int Index = 0; Index < fcCount; Index++) - { - FFileSystemInfo.IsCapable[Index] = IsCapable((TFSCapability)Index); - } + FTerminal->SaveCapabilities(FFileSystemInfo); } //--------------------------------------------------------------------------- __fastcall TSCPFileSystem::~TSCPFileSystem() @@ -462,10 +458,11 @@ bool __fastcall TSCPFileSystem::IsCapable(int Capability) const case fcCalculatingChecksum: case fcSecondaryShell: // has fcShellAnyCommand case fcGroupOwnerChangingByID: // by name + case fcMoveToQueue: return false; default: - assert(false); + FAIL; return false; } } @@ -601,7 +598,7 @@ void __fastcall TSCPFileSystem::ReadCommandOutput(int Params, const UnicodeStrin if (Total % 10 == 0) { bool Cancel; //dummy - FTerminal->DoReadDirectoryProgress(Total, Cancel); + FTerminal->DoReadDirectoryProgress(Total, 0, Cancel); } } } @@ -1195,7 +1192,7 @@ void __fastcall TSCPFileSystem::ChangeFileProperties(const UnicodeString FileNam //--------------------------------------------------------------------------- bool __fastcall TSCPFileSystem::LoadFilesProperties(TStrings * /*FileList*/ ) { - assert(false); + FAIL; return false; } //--------------------------------------------------------------------------- @@ -1203,7 +1200,7 @@ void __fastcall TSCPFileSystem::CalculateFilesChecksum(const UnicodeString & /*A TStrings * /*FileList*/, TStrings * /*Checksums*/, TCalculatedChecksumEvent /*OnCalculatedChecksum*/) { - assert(false); + FAIL; } //--------------------------------------------------------------------------- void __fastcall TSCPFileSystem::CustomCommandOnFile(const UnicodeString FileName, @@ -1268,11 +1265,6 @@ void __fastcall TSCPFileSystem::AnyCommand(const UnicodeString Command, } } //--------------------------------------------------------------------------- -UnicodeString __fastcall TSCPFileSystem::FileUrl(const UnicodeString FileName) -{ - return FTerminal->FileUrl(ScpProtocol, FileName); -} -//--------------------------------------------------------------------------- TStrings * __fastcall TSCPFileSystem::GetFixedPaths() { return NULL; @@ -1281,16 +1273,18 @@ TStrings * __fastcall TSCPFileSystem::GetFixedPaths() void __fastcall TSCPFileSystem::SpaceAvailable(const UnicodeString Path, TSpaceAvailable & /*ASpaceAvailable*/) { - assert(false); + FAIL; } //--------------------------------------------------------------------------- // transfer protocol //--------------------------------------------------------------------------- unsigned int __fastcall TSCPFileSystem::ConfirmOverwrite( - UnicodeString & FileName, TOperationSide Side, + const UnicodeString & FileName, TOperationSide Side, const TOverwriteFileParams * FileParams, const TCopyParamType * CopyParam, int Params, TFileOperationProgressType * OperationProgress) { + TSuspendFileOperationProgress Suspend(OperationProgress); + TQueryButtonAlias Aliases[3]; Aliases[0].Button = qaAll; Aliases[0].Alias = LoadStr(YES_TO_NEWER_BUTTON); @@ -1305,14 +1299,11 @@ unsigned int __fastcall TSCPFileSystem::ConfirmOverwrite( TQueryParams QueryParams(qpNeverAskAgainCheck); QueryParams.Aliases = Aliases; QueryParams.AliasesCount = LENOF(Aliases); - unsigned int Answer; - SUSPEND_OPERATION - ( - Answer = FTerminal->ConfirmFileOverwrite( + unsigned int Answer = + FTerminal->ConfirmFileOverwrite( FileName, FileParams, qaYes | qaNo | qaCancel | qaYesToAll | qaNoToAll | qaAll, &QueryParams, Side, CopyParam, Params, OperationProgress); - ); return Answer; } //--------------------------------------------------------------------------- @@ -1390,7 +1381,7 @@ void __fastcall TSCPFileSystem::CopyToRemote(TStrings * FilesToCopy, Params &= ~(cpAppend | cpResume); UnicodeString Options = L""; - bool CheckExistence = UnixComparePaths(TargetDir, FTerminal->CurrentDirectory) && + bool CheckExistence = UnixSamePath(TargetDir, FTerminal->CurrentDirectory) && (FTerminal->FFiles != NULL) && FTerminal->FFiles->Loaded; bool CopyBatchStarted = false; bool Failed = true; @@ -1454,13 +1445,12 @@ void __fastcall TSCPFileSystem::CopyToRemote(TStrings * FilesToCopy, { UnicodeString Message = FMTLOAD(DIRECTORY_OVERWRITE, (FileNameOnly)); TQueryParams QueryParams(qpNeverAskAgainCheck); - SUSPEND_OPERATION - ( - Answer = FTerminal->ConfirmFileOverwrite( - FileNameOnly /*not used*/, NULL, - qaYes | qaNo | qaCancel | qaYesToAll | qaNoToAll, - &QueryParams, osRemote, CopyParam, Params, OperationProgress, Message); - ); + + TSuspendFileOperationProgress Suspend(OperationProgress); + Answer = FTerminal->ConfirmFileOverwrite( + FileNameOnly /*not used*/, NULL, + qaYes | qaNo | qaCancel | qaYesToAll | qaNoToAll, + &QueryParams, osRemote, CopyParam, Params, OperationProgress, Message); } else { @@ -1474,7 +1464,7 @@ void __fastcall TSCPFileSystem::CopyToRemote(TStrings * FilesToCopy, FileParams.DestSize = File->Size; FileParams.DestTimestamp = File->Modification; - Answer = ConfirmOverwrite(FileNameOnly, osRemote, + Answer = ConfirmOverwrite(FileName, osRemote, &FileParams, CopyParam, Params, OperationProgress); } @@ -1491,7 +1481,7 @@ void __fastcall TSCPFileSystem::CopyToRemote(TStrings * FilesToCopy, break; default: - assert(false); + FAIL; break; } } @@ -1511,7 +1501,7 @@ void __fastcall TSCPFileSystem::CopyToRemote(TStrings * FilesToCopy, { FTerminal->DirectoryModified(TargetDir, false); - if (DirectoryExists(FileName)) + if (DirectoryExists(ApiPath(FileName))) { FTerminal->DirectoryModified(UnixIncludeTrailingBackslash(TargetDir)+ FileNameOnly, true); @@ -1527,23 +1517,32 @@ void __fastcall TSCPFileSystem::CopyToRemote(TStrings * FilesToCopy, catch (EScpFileSkipped &E) { TQueryParams Params(qpAllowContinueOnError); - SUSPEND_OPERATION ( - if (FTerminal->QueryUserException(FMTLOAD(COPY_ERROR, (FileName)), &E, - qaOK | qaAbort, &Params, qtError) == qaAbort) - { - OperationProgress->Cancel = csCancel; - } - OperationProgress->Finish(FileName, false, OnceDoneOperation); - if (!FTerminal->HandleException(&E)) throw; - ); + + TSuspendFileOperationProgress Suspend(OperationProgress); + + if (FTerminal->QueryUserException(FMTLOAD(COPY_ERROR, (FileName)), &E, + qaOK | qaAbort, &Params, qtError) == qaAbort) + { + OperationProgress->Cancel = csCancel; + } + OperationProgress->Finish(FileName, false, OnceDoneOperation); + if (!FTerminal->HandleException(&E)) + { + throw; + } } catch (EScpSkipFile &E) { OperationProgress->Finish(FileName, false, OnceDoneOperation); - // If ESkipFile occurs, just log it and continue with next file - SUSPEND_OPERATION ( - if (!FTerminal->HandleException(&E)) throw; - ); + + { + TSuspendFileOperationProgress Suspend(OperationProgress); + // If ESkipFile occurs, just log it and continue with next file + if (!FTerminal->HandleException(&E)) + { + throw; + } + } } catch (...) { @@ -1598,9 +1597,8 @@ void __fastcall TSCPFileSystem::SCPSource(const UnicodeString FileName, OperationProgress->SetFile(FileName, false); - if (!FTerminal->AllowLocalFileTransfer(FileName, CopyParam)) + if (!FTerminal->AllowLocalFileTransfer(FileName, CopyParam, OperationProgress)) { - FTerminal->LogEvent(FORMAT(L"File \"%s\" excluded from transfer", (FileName))); THROW_SKIP_FILE_NULL; } @@ -1669,10 +1667,13 @@ void __fastcall TSCPFileSystem::SCPSource(const UnicodeString FileName, TFileBuffer BlockBuf; // This is crucial, if it fails during file transfer, it's fatal error - FILE_OPERATION_LOOP_EX (!OperationProgress->TransferingFile, - FMTLOAD(READ_ERROR, (FileName)), + FILE_OPERATION_LOOP_BEGIN + { BlockBuf.LoadStream(Stream, OperationProgress->LocalBlockSize(), true); - ); + } + FILE_OPERATION_LOOP_END_EX( + FMTLOAD(READ_ERROR, (FileName)), + !OperationProgress->TransferingFile); OperationProgress->AddLocallyUsed(BlockBuf.Size); @@ -1869,16 +1870,20 @@ void __fastcall TSCPFileSystem::SCPSource(const UnicodeString FileName, { if (!Dir) { - FILE_OPERATION_LOOP (FMTLOAD(DELETE_LOCAL_FILE_ERROR, (FileName)), - THROWOSIFFALSE(Sysutils::DeleteFile(FileName)); - ) + FILE_OPERATION_LOOP_BEGIN + { + THROWOSIFFALSE(Sysutils::DeleteFile(ApiPath(FileName))); + } + FILE_OPERATION_LOOP_END(FMTLOAD(DELETE_LOCAL_FILE_ERROR, (FileName))); } } else if (CopyParam->ClearArchive && FLAGSET(Attrs, faArchive)) { - FILE_OPERATION_LOOP (FMTLOAD(CANT_SET_ATTRS, (FileName)), - THROWOSIFFALSE(FileSetAttr(FileName, Attrs & ~faArchive) == 0); - ) + FILE_OPERATION_LOOP_BEGIN + { + THROWOSIFFALSE(FileSetAttr(ApiPath(FileName), Attrs & ~faArchive) == 0); + } + FILE_OPERATION_LOOP_END(FMTLOAD(CANT_SET_ATTRS, (FileName))); } FTerminal->LogEvent(FORMAT(L"Copying \"%s\" to remote directory finished.", (FileName))); @@ -1897,10 +1902,12 @@ void __fastcall TSCPFileSystem::SCPDirectorySource(const UnicodeString Directory ExtractFileName(DirectoryName), osLocal, Level == 0); // Get directory attributes - FILE_OPERATION_LOOP (FMTLOAD(CANT_GET_ATTRS, (DirectoryName)), - Attrs = FileGetAttr(DirectoryName); - if (Attrs == -1) RaiseLastOSError(); - ) + FILE_OPERATION_LOOP_BEGIN + { + Attrs = FileGetAttr(ApiPath(DirectoryName)); + if (Attrs < 0) RaiseLastOSError(); + } + FILE_OPERATION_LOOP_END(FMTLOAD(CANT_GET_ATTRS, (DirectoryName))); UnicodeString TargetDirFull = UnixIncludeTrailingBackslash(TargetDir + DestFileName); @@ -1920,10 +1927,13 @@ void __fastcall TSCPFileSystem::SCPDirectorySource(const UnicodeString Directory TSearchRecChecked SearchRec; bool FindOK; - FILE_OPERATION_LOOP (FMTLOAD(LIST_DIR_ERROR, (DirectoryName)), - FindOK = (bool)(FindFirstChecked(IncludeTrailingBackslash(DirectoryName) + L"*.*", - FindAttrs, SearchRec) == 0); - ); + FILE_OPERATION_LOOP_BEGIN + { + FindOK = + (FindFirstChecked(IncludeTrailingBackslash(DirectoryName) + L"*.*", + FindAttrs, SearchRec) == 0); + } + FILE_OPERATION_LOOP_END(FMTLOAD(LIST_DIR_ERROR, (DirectoryName))); try { @@ -1943,26 +1953,33 @@ void __fastcall TSCPFileSystem::SCPDirectorySource(const UnicodeString Directory catch (EScpFileSkipped &E) { TQueryParams Params(qpAllowContinueOnError); - SUSPEND_OPERATION ( - if (FTerminal->QueryUserException(FMTLOAD(COPY_ERROR, (FileName)), &E, - qaOK | qaAbort, &Params, qtError) == qaAbort) - { - OperationProgress->Cancel = csCancel; - } - if (!FTerminal->HandleException(&E)) throw; - ); + TSuspendFileOperationProgress Suspend(OperationProgress); + + if (FTerminal->QueryUserException(FMTLOAD(COPY_ERROR, (FileName)), &E, + qaOK | qaAbort, &Params, qtError) == qaAbort) + { + OperationProgress->Cancel = csCancel; + } + if (!FTerminal->HandleException(&E)) + { + throw; + } } catch (EScpSkipFile &E) { // If ESkipFile occurs, just log it and continue with next file - SUSPEND_OPERATION ( - if (!FTerminal->HandleException(&E)) throw; - ); + TSuspendFileOperationProgress Suspend(OperationProgress); + if (!FTerminal->HandleException(&E)) + { + throw; + } } - FILE_OPERATION_LOOP (FMTLOAD(LIST_DIR_ERROR, (DirectoryName)), + FILE_OPERATION_LOOP_BEGIN + { FindOK = (FindNextChecked(SearchRec) == 0); - ); + } + FILE_OPERATION_LOOP_END(FMTLOAD(LIST_DIR_ERROR, (DirectoryName))); } } __finally @@ -1976,13 +1993,15 @@ void __fastcall TSCPFileSystem::SCPDirectorySource(const UnicodeString Directory { if (FLAGSET(Params, cpDelete)) { - RemoveDir(DirectoryName); + RemoveDir(ApiPath(DirectoryName)); } else if (CopyParam->ClearArchive && FLAGSET(Attrs, faArchive)) { - FILE_OPERATION_LOOP (FMTLOAD(CANT_SET_ATTRS, (DirectoryName)), - THROWOSIFFALSE(FileSetAttr(DirectoryName, Attrs & ~faArchive) == 0); - ) + FILE_OPERATION_LOOP_BEGIN + { + THROWOSIFFALSE(FileSetAttr(ApiPath(DirectoryName), Attrs & ~faArchive) == 0); + } + FILE_OPERATION_LOOP_END(FMTLOAD(CANT_SET_ATTRS, (DirectoryName))); } } } @@ -2050,11 +2069,13 @@ void __fastcall TSCPFileSystem::CopyToLocal(TStrings * FilesToCopy, FTerminal->ExceptionOnFail = true; try { - FILE_OPERATION_LOOP(FMTLOAD(DELETE_FILE_ERROR, (FileName)), + FILE_OPERATION_LOOP_BEGIN + { // pass full file name in FileName, in case we are not moving // from current directory - FTerminal->DeleteFile(FileName, File) - ); + FTerminal->DeleteFile(FileName, File); + } + FILE_OPERATION_LOOP_END(FMTLOAD(DELETE_FILE_ERROR, (FileName))); } __finally { @@ -2281,15 +2302,16 @@ void __fastcall TSCPFileSystem::SCPSink(const UnicodeString TargetDir, FTerminal->LogEvent(FORMAT(L"Warning: Remote host set a compound pathname '%s'", (Line))); } - OperationProgress->SetFile(OnlyFileName); AbsoluteFileName = SourceDir + OnlyFileName; + OperationProgress->SetFile(AbsoluteFileName); OperationProgress->SetTransferSize(TSize); } catch (Exception &E) { - SUSPEND_OPERATION ( + { + TSuspendFileOperationProgress Suspend(OperationProgress); FTerminal->Log->AddException(&E); - ); + } SCPError(LoadStr(SCP_ILLEGAL_FILE_DESCRIPTOR), false); } @@ -2300,8 +2322,7 @@ void __fastcall TSCPFileSystem::SCPSink(const UnicodeString TargetDir, } bool Dir = (Ctrl == L'D'); - UnicodeString SourceFullName = SourceDir + OperationProgress->FileName; - if (!CopyParam->AllowTransfer(SourceFullName, osRemote, Dir, MaskParams)) + if (!CopyParam->AllowTransfer(AbsoluteFileName, osRemote, Dir, MaskParams)) { FTerminal->LogEvent(FORMAT(L"File \"%s\" excluded from transfer", (AbsoluteFileName))); @@ -2309,6 +2330,13 @@ void __fastcall TSCPFileSystem::SCPSink(const UnicodeString TargetDir, SCPError(L"", false); } + if (CopyParam->SkipTransfer(AbsoluteFileName, Dir)) + { + SkipConfirmed = true; + SCPError(L"", false); + OperationProgress->AddSkippedFileSize(MaskParams.Size); + } + FTerminal->LogFileDetails(FileName, SourceTimestamp, MaskParams.Size); UnicodeString DestFileName = @@ -2316,7 +2344,7 @@ void __fastcall TSCPFileSystem::SCPSink(const UnicodeString TargetDir, CopyParam->ChangeFileName(OperationProgress->FileName, osRemote, Level == 0); - FileData.Attrs = FileGetAttr(DestFileName); + FileData.Attrs = FileGetAttr(ApiPath(DestFileName)); // If getting attrs fails, we suppose, that file/folder doesn't exists FileData.Exists = (FileData.Attrs != -1); if (Dir) @@ -2328,9 +2356,11 @@ void __fastcall TSCPFileSystem::SCPSink(const UnicodeString TargetDir, if (!FileData.Exists) { - FILE_OPERATION_LOOP (FMTLOAD(CREATE_DIR_ERROR, (DestFileName)), - THROWOSIFFALSE(ForceDirectories(DestFileName)); - ); + FILE_OPERATION_LOOP_BEGIN + { + THROWOSIFFALSE(ForceDirectories(ApiPath(DestFileName))); + } + FILE_OPERATION_LOOP_END(FMTLOAD(CREATE_DIR_ERROR, (DestFileName))); /* SCP: can we set the timestamp for directories ? */ } UnicodeString FullFileName = SourceDir + OperationProgress->FileName; @@ -2354,7 +2384,7 @@ void __fastcall TSCPFileSystem::SCPSink(const UnicodeString TargetDir, { try { - if (FileExists(DestFileName)) + if (FileExists(ApiPath(DestFileName))) { __int64 MTime; TOverwriteFileParams FileParams; @@ -2409,7 +2439,7 @@ void __fastcall TSCPFileSystem::SCPSink(const UnicodeString TargetDir, // Will we use ASCII of BINARY file transfer? OperationProgress->SetAsciiTransfer( - CopyParam->UseAsciiTransfer(SourceFullName, osRemote, MaskParams)); + CopyParam->UseAsciiTransfer(AbsoluteFileName, osRemote, MaskParams)); FTerminal->LogEvent(UnicodeString((OperationProgress->AsciiTransfer ? L"Ascii" : L"Binary")) + L" transfer mode selected."); @@ -2437,9 +2467,12 @@ void __fastcall TSCPFileSystem::SCPSink(const UnicodeString TargetDir, } // This is crucial, if it fails during file transfer, it's fatal error - FILE_OPERATION_LOOP_EX (false, FMTLOAD(WRITE_ERROR, (DestFileName)), + FILE_OPERATION_LOOP_BEGIN + { BlockBuf.WriteToStream(FileStream, BlockBuf.Size); - ); + } + FILE_OPERATION_LOOP_END_EX( + FMTLOAD(WRITE_ERROR, (DestFileName)), false); OperationProgress->AddLocallyUsed(BlockBuf.Size); @@ -2507,9 +2540,11 @@ void __fastcall TSCPFileSystem::SCPSink(const UnicodeString TargetDir, int NewAttrs = CopyParam->LocalFileAttrs(FileData.RemoteRights); if ((NewAttrs & FileData.Attrs) != NewAttrs) { - FILE_OPERATION_LOOP (FMTLOAD(CANT_SET_ATTRS, (DestFileName)), - THROWOSIFFALSE(FileSetAttr(DestFileName, FileData.Attrs | NewAttrs) == 0); - ); + FILE_OPERATION_LOOP_BEGIN + { + THROWOSIFFALSE(FileSetAttr(ApiPath(DestFileName), FileData.Attrs | NewAttrs) == 0); + } + FILE_OPERATION_LOOP_END(FMTLOAD(CANT_SET_ATTRS, (DestFileName))); } } } @@ -2518,15 +2553,14 @@ void __fastcall TSCPFileSystem::SCPSink(const UnicodeString TargetDir, { if (!SkipConfirmed) { - SUSPEND_OPERATION ( - TQueryParams Params(qpAllowContinueOnError); - if (FTerminal->QueryUserException(FMTLOAD(COPY_ERROR, (AbsoluteFileName)), - &E, qaOK | qaAbort, &Params, qtError) == qaAbort) - { - OperationProgress->Cancel = csCancel; - } - FTerminal->Log->AddException(&E); - ); + TSuspendFileOperationProgress Suspend(OperationProgress); + TQueryParams Params(qpAllowContinueOnError); + if (FTerminal->QueryUserException(FMTLOAD(COPY_ERROR, (AbsoluteFileName)), + &E, qaOK | qaAbort, &Params, qtError) == qaAbort) + { + OperationProgress->Cancel = csCancel; + } + FTerminal->Log->AddException(&E); } // this was inside above condition, but then transfer was considered // successful, even when for example user refused to overwrite file diff --git a/source/core/ScpFileSystem.h b/source/core/ScpFileSystem.h index 6239112e..475fdd84 100644 --- a/source/core/ScpFileSystem.h +++ b/source/core/ScpFileSystem.h @@ -61,7 +61,6 @@ class TSCPFileSystem : public TCustomFileSystem const UnicodeString NewName); virtual void __fastcall CopyFile(const UnicodeString FileName, const UnicodeString NewName); - virtual UnicodeString __fastcall FileUrl(const UnicodeString FileName); virtual TStrings * __fastcall GetFixedPaths(); virtual void __fastcall SpaceAvailable(const UnicodeString Path, TSpaceAvailable & ASpaceAvailable); @@ -126,7 +125,7 @@ class TSCPFileSystem : public TCustomFileSystem void __fastcall ChangeFileToken(const UnicodeString & DelimitedName, const TRemoteToken & Token, TFSCommand Cmd, const UnicodeString & RecursiveStr); unsigned int __fastcall ConfirmOverwrite( - UnicodeString & FileName, TOperationSide Side, + const UnicodeString & FileName, TOperationSide Side, const TOverwriteFileParams * FileParams, const TCopyParamType * CopyParam, int Params, TFileOperationProgressType * OperationProgress); diff --git a/source/core/Script.cpp b/source/core/Script.cpp index ce234e43..e44e25ab 100644 --- a/source/core/Script.cpp +++ b/source/core/Script.cpp @@ -329,15 +329,20 @@ __fastcall TScript::~TScript() //--------------------------------------------------------------------------- void __fastcall TScript::Init() { - FBatch = BatchOff; - FConfirm = true; + FBatch = BatchAbort; + FInteractiveBatch = BatchOff; + FConfirm = false; + FInteractiveConfirm = true; FEcho = false; + FFailOnNoMatch = false; FSynchronizeParams = 0; FOnPrint = NULL; FOnTerminalSynchronizeDirectory = NULL; FOnSynchronizeStartStop = NULL; FSynchronizeMode = -1; FKeepingUpToDate = false; + FWarnNonDefaultCopyParam = false; + FWarnNonDefaultSynchronizeParams = false; FCommands = new TScriptCommands(this); FCommands->Register(L"help", SCRIPT_HELP_DESC, SCRIPT_HELP_HELP, &HelpProc, 0, -1, false); @@ -357,15 +362,15 @@ void __fastcall TScript::Init() FCommands->Register(L"ln", SCRIPT_LN_DESC, SCRIPT_LN_HELP, &LnProc, 2, 2, false); FCommands->Register(L"symlink", 0, SCRIPT_LN_HELP, &LnProc, 2, 2, false); FCommands->Register(L"mkdir", SCRIPT_MKDIR_DESC, SCRIPT_MKDIR_HELP, &MkDirProc, 1, 1, false); - FCommands->Register(L"get", SCRIPT_GET_DESC, SCRIPT_GET_HELP6, &GetProc, 1, -1, true); - FCommands->Register(L"recv", 0, SCRIPT_GET_HELP6, &GetProc, 1, -1, false); - FCommands->Register(L"mget", 0, SCRIPT_GET_HELP6, &GetProc, 1, -1, false); - FCommands->Register(L"put", SCRIPT_PUT_DESC, SCRIPT_PUT_HELP6, &PutProc, 1, -1, true); - FCommands->Register(L"send", 0, SCRIPT_PUT_HELP6, &PutProc, 1, -1, false); - FCommands->Register(L"mput", 0, SCRIPT_PUT_HELP6, &PutProc, 1, -1, false); - FCommands->Register(L"option", SCRIPT_OPTION_DESC, SCRIPT_OPTION_HELP6, &OptionProc, -1, 2, false); - FCommands->Register(L"ascii", 0, SCRIPT_OPTION_HELP6, &AsciiProc, 0, 0, false); - FCommands->Register(L"binary", 0, SCRIPT_OPTION_HELP6, &BinaryProc, 0, 0, false); + FCommands->Register(L"get", SCRIPT_GET_DESC, SCRIPT_GET_HELP7, &GetProc, 1, -1, true); + FCommands->Register(L"recv", 0, SCRIPT_GET_HELP7, &GetProc, 1, -1, false); + FCommands->Register(L"mget", 0, SCRIPT_GET_HELP7, &GetProc, 1, -1, false); + FCommands->Register(L"put", SCRIPT_PUT_DESC, SCRIPT_PUT_HELP7, &PutProc, 1, -1, true); + FCommands->Register(L"send", 0, SCRIPT_PUT_HELP7, &PutProc, 1, -1, false); + FCommands->Register(L"mput", 0, SCRIPT_PUT_HELP7, &PutProc, 1, -1, false); + FCommands->Register(L"option", SCRIPT_OPTION_DESC, SCRIPT_OPTION_HELP7, &OptionProc, -1, 2, false); + FCommands->Register(L"ascii", 0, SCRIPT_OPTION_HELP7, &AsciiProc, 0, 0, false); + FCommands->Register(L"binary", 0, SCRIPT_OPTION_HELP7, &BinaryProc, 0, 0, false); FCommands->Register(L"synchronize", SCRIPT_SYNCHRONIZE_DESC, SCRIPT_SYNCHRONIZE_HELP7, &SynchronizeProc, 1, 3, true); FCommands->Register(L"keepuptodate", SCRIPT_KEEPUPTODATE_DESC, SCRIPT_KEEPUPTODATE_HELP4, &KeepUpToDateProc, 0, 2, true); // the echo command does not have switches actually, but it must handle dashes in its arguments @@ -373,16 +378,49 @@ void __fastcall TScript::Init() FCommands->Register(L"stat", SCRIPT_STAT_DESC, SCRIPT_STAT_HELP, &StatProc, 1, 1, false); } //--------------------------------------------------------------------------- +void __fastcall TScript::CheckDefaultCopyParam() +{ + if (FWarnNonDefaultCopyParam) + { + // started with non-factory settings and still have them, warn + if (HasNonDefaultCopyParams()) + { + PrintLine(LoadStr(SCRIPT_NON_DEFAULT_COPY_PARAM)); + } + FWarnNonDefaultCopyParam = false; + } +} +//--------------------------------------------------------------------------- +bool __fastcall TScript::HasNonDefaultCopyParams() +{ + return !(FCopyParam == TCopyParamType()); +} +//--------------------------------------------------------------------------- void __fastcall TScript::SetCopyParam(const TCopyParamType & value) { FCopyParam.Assign(&value); + FWarnNonDefaultCopyParam = HasNonDefaultCopyParams(); +} +//--------------------------------------------------------------------------- +void __fastcall TScript::CheckDefaultSynchronizeParams() +{ + if (FWarnNonDefaultSynchronizeParams) + { + // as opposite to CheckDefaultCopyParam(), not checking + // current params as we cannot override any of those we accept anyway + PrintLine(LoadStr(SCRIPT_NON_DEFAULT_SYNC_PARAM)); + FWarnNonDefaultSynchronizeParams = false; + } } //--------------------------------------------------------------------------- void __fastcall TScript::SetSynchronizeParams(int value) { - FSynchronizeParams = (value & - (TTerminal::spExistingOnly | TTerminal::spTimestamp | - TTerminal::spNotByTime | TTerminal::spBySize)); + const int AcceptedParams = + TTerminal::spExistingOnly | TTerminal::spTimestamp | + TTerminal::spNotByTime | TTerminal::spBySize; + FSynchronizeParams = (value & AcceptedParams); + FWarnNonDefaultSynchronizeParams = + (FSynchronizeParams != (TTerminal::spDefault & AcceptedParams)); } //--------------------------------------------------------------------------- bool __fastcall TScript::IsTerminalLogging(TTerminal * ATerminal) @@ -429,6 +467,12 @@ UnicodeString __fastcall TScript::GetLogCmd(const UnicodeString & FullCommand, return FullCommand; } //--------------------------------------------------------------------------- +void __fastcall TScript::StartInteractive() +{ + FBatch = FInteractiveBatch; + FConfirm = FInteractiveConfirm; +} +//--------------------------------------------------------------------------- void __fastcall TScript::Command(UnicodeString Cmd) { try @@ -462,7 +506,7 @@ void __fastcall TScript::Command(UnicodeString Cmd) } catch(Exception & E) { - // seemingly duplicate (to the method-level one) catch clausule, + // seemingly duplicate (to the method-level one) catch clause, // ensures the tag is enclosed in tag if (!HandleExtendedException(&E)) { @@ -558,6 +602,11 @@ TStrings * __fastcall TScript::CreateFileList(TScriptProcParams * Parameters, in FLAGSET(ListType, fltQueryServer) ? File->Duplicate() : NULL); } } + + if ((Result->Count == 0) && FFailOnNoMatch) + { + throw Exception(FMTLOAD(SCRIPT_MATCH_NO_MATCH, (Mask.Masks))); + } } else { @@ -610,7 +659,10 @@ TStrings * __fastcall TScript::CreateLocalFileList(TScriptProcParams * Parameter { for (int i = Start; i <= End; i++) { - UnicodeString FileName = Parameters->Param[i]; + // FindFirstFile called (indirectly) below fails if path ends with slash. + // (it actually won't make a difference functionally as we fall back to adding + // the path as is in "else" branch, but the comment "let it fail later" won't stand) + UnicodeString FileName = ExcludeTrailingBackslash(Parameters->Param[i]); if (FLAGSET(ListType, fltMask)) { TSearchRecChecked SearchRec; @@ -642,6 +694,11 @@ TStrings * __fastcall TScript::CreateLocalFileList(TScriptProcParams * Parameter Result->Add(FileName); } } + + if ((Result->Count == 0) && FFailOnNoMatch) + { + throw Exception(FMTLOAD(SCRIPT_MATCH_NO_MATCH, (ExtractFileName(FileName)))); + } } else { @@ -833,6 +890,16 @@ void __fastcall TScript::CopyParamParams(TCopyParamType & CopyParam, TScriptProc CopyParam.ResumeThreshold = ThresholdValue * 1024; } } + + if (Parameters->FindSwitch(L"noneweronly")) + { + CopyParam.NewerOnly = false; + } + + if (Parameters->FindSwitch(L"neweronly")) + { + CopyParam.NewerOnly = true; + } } //--------------------------------------------------------------------------- void __fastcall TScript::ResetTransfer() @@ -1105,6 +1172,7 @@ void __fastcall TScript::GetProc(TScriptProcParams * Parameters) (TFileListType)(fltQueryServer | fltMask)); try { + CheckDefaultCopyParam(); TCopyParamType CopyParam = FCopyParam; UnicodeString TargetDirectory; @@ -1146,6 +1214,7 @@ void __fastcall TScript::PutProc(TScriptProcParams * Parameters) TStrings * FileList = CreateLocalFileList(Parameters, 1, LastFileParam, fltMask); try { + CheckDefaultCopyParam(); TCopyParamType CopyParam = FCopyParam; UnicodeString TargetDirectory; @@ -1194,9 +1263,9 @@ TTransferMode __fastcall TScript::ParseTransferModeName(UnicodeString Name) //--------------------------------------------------------------------------- void __fastcall TScript::OptionImpl(UnicodeString OptionName, UnicodeString ValueName) { - enum { Echo, Batch, Confirm, Transfer, SynchDelete, Exclude, Include, ReconnectTime }; + enum { Echo, Batch, Confirm, Transfer, SynchDelete, Exclude, Include, ReconnectTime, FailOnNoMatch }; static const wchar_t * Names[] = { L"echo", L"batch", L"confirm", L"transfer", - L"synchdelete", L"exclude", L"include", L"reconnecttime" }; + L"synchdelete", L"exclude", L"include", L"reconnecttime", L"failonnomatch" }; assert((BatchOff == 0) && (BatchOn == 1) && (BatchAbort == 2) && (BatchContinue == 3)); static const wchar_t * BatchModeNames[] = { L"off", L"on", L"abort", L"continue" }; @@ -1218,6 +1287,7 @@ void __fastcall TScript::OptionImpl(UnicodeString OptionName, UnicodeString Valu #define OPT(OPT) ((Option < 0) || (Option == OPT)) const wchar_t * ListFormat = L"%-15s %-10s"; bool SetValue = !ValueName.IsEmpty(); + bool PrintReconnectTime = false; if (OPT(Echo)) { @@ -1244,6 +1314,13 @@ void __fastcall TScript::OptionImpl(UnicodeString OptionName, UnicodeString Valu throw Exception(FMTLOAD(SCRIPT_VALUE_UNKNOWN, (ValueName, OptionName))); } FBatch = (TBatchMode)Value; + FInteractiveBatch = FBatch; + + if (SetValue && (FBatch != BatchOff) && (FSessionReopenTimeout == 0)) + { + FSessionReopenTimeout = 2 * MSecsPerSec * SecsPerMin; // 2 mins + PrintReconnectTime = true; + } } PrintLine(FORMAT(ListFormat, (Names[Batch], BatchModeNames[FBatch]))); @@ -1259,6 +1336,7 @@ void __fastcall TScript::OptionImpl(UnicodeString OptionName, UnicodeString Valu throw Exception(FMTLOAD(SCRIPT_VALUE_UNKNOWN, (ValueName, OptionName))); } FConfirm = (Value == On); + FInteractiveConfirm = FConfirm; } PrintLine(FORMAT(ListFormat, (Names[Confirm], ToggleNames[FConfirm ? On : Off]))); @@ -1325,9 +1403,9 @@ void __fastcall TScript::OptionImpl(UnicodeString OptionName, UnicodeString Valu PrintLine(FORMAT(ListFormat, (Names[Include], FCopyParam.IncludeFileMask.Masks))); } - if (OPT(ReconnectTime)) + if (OPT(ReconnectTime) || PrintReconnectTime) { - if (SetValue) + if (SetValue && !PrintReconnectTime) { int Value; if (AnsiSameText(ValueName, ToggleNames[Off])) @@ -1359,6 +1437,21 @@ void __fastcall TScript::OptionImpl(UnicodeString OptionName, UnicodeString Valu PrintLine(FORMAT(ListFormat, (Names[ReconnectTime], ValueName))); } + if (OPT(FailOnNoMatch)) + { + if (SetValue) + { + int Value = TScriptCommands::FindCommand(ToggleNames, LENOF(ToggleNames), ValueName); + if (Value < 0) + { + throw Exception(FMTLOAD(SCRIPT_VALUE_UNKNOWN, (ValueName, OptionName))); + } + FFailOnNoMatch = (Value == On); + } + + PrintLine(FORMAT(ListFormat, (Names[FailOnNoMatch], ToggleNames[FFailOnNoMatch ? On : Off]))); + } + #undef OPT } //--------------------------------------------------------------------------- @@ -1537,9 +1630,11 @@ void __fastcall TScript::SynchronizeProc(TScriptProcParams * Parameters) SynchronizeDirectories(Parameters, LocalDirectory, RemoteDirectory, 2); + CheckDefaultCopyParam(); TCopyParamType CopyParam = FCopyParam; CopyParamParams(CopyParam, Parameters); + CheckDefaultSynchronizeParams(); int SynchronizeParams = FSynchronizeParams | TTerminal::spNoConfirmation; UnicodeString Value; @@ -1693,6 +1788,7 @@ void __fastcall TScript::KeepUpToDateProc(TScriptProcParams * Parameters) SynchronizeDirectories(Parameters, LocalDirectory, RemoteDirectory, 1); + CheckDefaultSynchronizeParams(); int SynchronizeParams = FSynchronizeParams | TTerminal::spNoConfirmation | TTerminal::spNoRecurse | TTerminal::spUseCache | TTerminal::spDelayProgress | TTerminal::spSubDirs; @@ -1702,6 +1798,7 @@ void __fastcall TScript::KeepUpToDateProc(TScriptProcParams * Parameters) SynchronizeParams |= TTerminal::spDelete; } + CheckDefaultCopyParam(); TCopyParamType CopyParam = FCopyParam; CopyParamParams(CopyParam, Parameters); @@ -1731,7 +1828,7 @@ __fastcall TManagementScript::TManagementScript(TStoredSessionList * StoredSessi FCommands->Register(L"exit", SCRIPT_EXIT_DESC, SCRIPT_EXIT_HELP, &ExitProc, 0, 0, false); FCommands->Register(L"bye", 0, SCRIPT_EXIT_HELP, &ExitProc, 0, 0, false); - FCommands->Register(L"open", SCRIPT_OPEN_DESC, SCRIPT_OPEN_HELP5, &OpenProc, 0, -1, true); + FCommands->Register(L"open", SCRIPT_OPEN_DESC, SCRIPT_OPEN_HELP6, &OpenProc, 0, -1, true); FCommands->Register(L"close", SCRIPT_CLOSE_DESC, SCRIPT_CLOSE_HELP, &CloseProc, 0, 1, false); FCommands->Register(L"session", SCRIPT_SESSION_DESC, SCRIPT_SESSION_HELP, &SessionProc, 0, 1, false); FCommands->Register(L"lpwd", SCRIPT_LPWD_DESC, SCRIPT_LPWD_HELP, &LPwdProc, 0, 0, false); @@ -1863,7 +1960,7 @@ void __fastcall TManagementScript::ShowPendingProgress() } //--------------------------------------------------------------------------- void __fastcall TManagementScript::TerminalOperationProgress( - TFileOperationProgressType & ProgressData, TCancelStatus & Cancel) + TFileOperationProgressType & ProgressData) { if ((ProgressData.Operation == foCopy) || (ProgressData.Operation == foMove)) @@ -1933,10 +2030,10 @@ void __fastcall TManagementScript::TerminalOperationProgress( } else { - TransferedSizeStr = FORMAT("%d KiB", (static_cast(ProgressData.TransferedSize / 1024))); + TransferedSizeStr = FORMAT("%d KB", (static_cast(ProgressData.TransferedSize / 1024))); } - UnicodeString ProgressMessage = FORMAT(L"%-*s | %14s | %6.1f KiB/s | %-6.6s | %3d%%", + UnicodeString ProgressMessage = FORMAT(L"%-*s | %14s | %6.1f KB/s | %-6.6s | %3d%%", (WidthFileName, FileName, TransferedSizeStr, static_cast(ProgressData.CPS()) / 1024, @@ -1959,7 +2056,7 @@ void __fastcall TManagementScript::TerminalOperationProgress( if (QueryCancel()) { - Cancel = csCancel; + ProgressData.Cancel = csCancel; } } //--------------------------------------------------------------------------- @@ -2279,7 +2376,7 @@ void __fastcall TManagementScript::DoClose(TTerminal * ATerminal) //--------------------------------------------------------------------------- void __fastcall TManagementScript::DoChangeLocalDirectory(UnicodeString Directory) { - if (!SetCurrentDir(Directory)) + if (!SetCurrentDir(ApiPath(Directory))) { throw EOSExtException(FMTLOAD(CHANGE_DIR_ERROR, (Directory))); } diff --git a/source/core/Script.h b/source/core/Script.h index 02a71779..bc5facad 100644 --- a/source/core/Script.h +++ b/source/core/Script.h @@ -55,6 +55,7 @@ class TScript void __fastcall Command(UnicodeString Cmd); void __fastcall Log(TLogLineType Type, AnsiString Str); void __fastcall PrintLine(const UnicodeString Str); + void __fastcall StartInteractive(); void __fastcall Synchronize(const UnicodeString LocalDirectory, const UnicodeString RemoteDirectory, const TCopyParamType & CopyParam, @@ -83,8 +84,11 @@ class TScript TCopyParamType FCopyParam; bool FIncludeFileMaskOptionUsed; TBatchMode FBatch; + TBatchMode FInteractiveBatch; bool FConfirm; + bool FInteractiveConfirm; bool FEcho; + bool FFailOnNoMatch; int FSynchronizeParams; int FSynchronizeMode; bool FKeepingUpToDate; @@ -94,6 +98,8 @@ class TScript bool FGroups; bool FWantsProgress; TStrings * FPendingLogLines; + bool FWarnNonDefaultCopyParam; + bool FWarnNonDefaultSynchronizeParams; virtual void __fastcall ResetTransfer(); virtual void __fastcall ConnectTerminal(TTerminal * ATerminal); @@ -160,6 +166,9 @@ class TScript void __fastcall SetSynchronizeParams(int value); TTransferMode __fastcall ParseTransferModeName(UnicodeString Name); inline bool __fastcall IsTerminalLogging(TTerminal * ATerminal); + void __fastcall CheckDefaultCopyParam(); + bool __fastcall HasNonDefaultCopyParams(); + void __fastcall CheckDefaultSynchronizeParams(); }; //--------------------------------------------------------------------------- typedef void __fastcall (__closure *TScriptInputEvent)(TScript * Script, const UnicodeString Prompt, UnicodeString & Str); @@ -200,8 +209,7 @@ class TManagementScript : public TScript void __fastcall Input(const UnicodeString Prompt, UnicodeString & Str, bool AllowEmpty); void __fastcall TerminalInformation(TTerminal * Terminal, const UnicodeString & Str, bool Status, int Phase); - void __fastcall TerminalOperationProgress(TFileOperationProgressType & ProgressData, - TCancelStatus & Cancel); + void __fastcall TerminalOperationProgress(TFileOperationProgressType & ProgressData); void __fastcall TerminalOperationFinished(TFileOperation Operation, TOperationSide Side, bool Temp, const UnicodeString & FileName, Boolean Success, TOnceDoneOperation & OnceDoneOperation); diff --git a/source/core/SecureShell.cpp b/source/core/SecureShell.cpp index 4aaaa709..fde1b246 100644 --- a/source/core/SecureShell.cpp +++ b/source/core/SecureShell.cpp @@ -51,6 +51,7 @@ __fastcall TSecureShell::TSecureShell(TSessionUI* UI, FWaiting = 0; FOpened = false; FOpenSSH = false; + FProFTPD = false; OutPtr = NULL; Pending = NULL; FBackendHandle = NULL; @@ -87,6 +88,7 @@ void __fastcall TSecureShell::ResetConnection() FAuthenticated = false; FStoredPasswordTried = false; FStoredPasswordTriedForKI = false; + FStoredPassphraseTried = false; } //--------------------------------------------------------------------------- void __fastcall TSecureShell::ResetSessionInfo() @@ -138,6 +140,11 @@ bool __fastcall TSecureShell::IsOpenSSH() { return FOpenSSH; } +//--------------------------------------------------------------------------- +bool __fastcall TSecureShell::IsProFTPD() +{ + return FProFTPD; +} //--------------------------------------------------------------------- Conf * __fastcall TSecureShell::StoreToConfig(TSessionData * Data, bool Simple) { @@ -195,7 +202,7 @@ Conf * __fastcall TSecureShell::StoreToConfig(TSessionData * Data, bool Simple) case cipAES: pcipher = CIPHER_AES; break; case cipDES: pcipher = CIPHER_DES; break; case cipArcfour: pcipher = CIPHER_ARCFOUR; break; - default: assert(false); + default: FAIL; } conf_set_int_int(conf, CONF_ssh_cipherlist, c, pcipher); } @@ -209,7 +216,7 @@ Conf * __fastcall TSecureShell::StoreToConfig(TSessionData * Data, bool Simple) case kexDHGroup14: pkex = KEX_DHGROUP14; break; case kexDHGEx: pkex = KEX_DHGEX; break; case kexRSA: pkex = KEX_RSA; break; - default: assert(false); + default: FAIL; } conf_set_int_int(conf, CONF_ssh_kexlist, k, pkex); } @@ -256,7 +263,7 @@ Conf * __fastcall TSecureShell::StoreToConfig(TSessionData * Data, bool Simple) conf_set_int(conf, CONF_sshbug_pksessid2, Data->Bug[sbPKSessID2]); conf_set_int(conf, CONF_sshbug_maxpkt2, Data->Bug[sbMaxPkt2]); conf_set_int(conf, CONF_sshbug_ignore2, Data->Bug[sbIgnore2]); - conf_set_int(conf, CONF_sshbug_winadj, FORCE_OFF); + conf_set_int(conf, CONF_sshbug_winadj, Data->Bug[sbWinAdj]); if (!Data->TunnelPortFwd.IsEmpty()) { @@ -395,7 +402,9 @@ void __fastcall TSecureShell::Open() if (FNoConnectionResponse && TryFtp()) { Configuration->Usage->Inc(L"ProtocolSuggestions"); - FUI->FatalError(&E, LoadStr(FTP_SUGGESTION)); + // HELP_FTP_SUGGESTION won't be used as all errors that set + // FNoConnectionResponse have already their own help keyword + FUI->FatalError(&E, LoadStr(FTP_SUGGESTION), HELP_FTP_SUGGESTION); } else { @@ -415,10 +424,13 @@ void __fastcall TSecureShell::Open() assert(!FSessionInfo.SshImplementation.IsEmpty()); FOpened = true; + UnicodeString SshImplementation = GetSessionInfo().SshImplementation; FOpenSSH = // Sun SSH is based on OpenSSH (suffers the same bugs) - (GetSessionInfo().SshImplementation.Pos(L"OpenSSH") == 1) || - (GetSessionInfo().SshImplementation.Pos(L"Sun_SSH") == 1); + (SshImplementation.Pos(L"OpenSSH") == 1) || + (SshImplementation.Pos(L"Sun_SSH") == 1); + FProFTPD = + (SshImplementation.Pos(L"mod_sftp") == 1); } //--------------------------------------------------------------------------- bool __fastcall TSecureShell::TryFtp() @@ -594,6 +606,7 @@ bool __fastcall TSecureShell::PromptUser(bool /*ToServer*/, const TPuttyTranslation * InstructionTranslation = NULL; const TPuttyTranslation * PromptTranslation = NULL; size_t PromptTranslationCount = 1; + UnicodeString PromptDesc; if (Index == 0) // username { @@ -603,6 +616,7 @@ bool __fastcall TSecureShell::PromptUser(bool /*ToServer*/, PromptTranslation = UsernamePromptTranslation; PromptKind = pkUserName; + PromptDesc = L"username"; } else if (Index == 1) // passphrase { @@ -612,6 +626,7 @@ bool __fastcall TSecureShell::PromptUser(bool /*ToServer*/, PromptTranslation = PassphrasePromptTranslation; PromptKind = pkPassphrase; + PromptDesc = L"passphrase"; } else if (Index == 2) // TIS { @@ -625,6 +640,7 @@ bool __fastcall TSecureShell::PromptUser(bool /*ToServer*/, InstructionTranslation = TISInstructionTranslation; PromptTranslation = TISPromptTranslation; PromptKind = pkTIS; + PromptDesc = L"tis"; } else if (Index == 3) // CryptoCard { @@ -638,21 +654,30 @@ bool __fastcall TSecureShell::PromptUser(bool /*ToServer*/, InstructionTranslation = CryptoCardInstructionTranslation; PromptTranslation = CryptoCardPromptTranslation; PromptKind = pkCryptoCard; + PromptDesc = L"cryptocard"; } else if ((Index == 4) || (Index == 5)) { static const TPuttyTranslation KeybInteractiveInstructionTranslation[] = { { L"Using keyboard-interactive authentication.%", KEYBINTER_INSTRUCTION }, }; + static const TPuttyTranslation KeybInteractivePromptTranslation[] = { + // as used by Linux-PAM (pam_exec/pam_exec.c, libpam/pam_get_authtok.c, + // pam_unix/pam_unix_auth.c, pam_userdb/pam_userdb.c) + { L"Password: ", PASSWORD_PROMPT }, + }; InstructionTranslation = KeybInteractiveInstructionTranslation; + PromptTranslation = KeybInteractivePromptTranslation; PromptKind = pkKeybInteractive; + PromptDesc = L"keyboard interactive"; } else if (Index == 6) { assert(Prompts->Count == 1); Prompts->Strings[0] = LoadStr(PASSWORD_PROMPT); PromptKind = pkPassword; + PromptDesc = L"password"; } else if (Index == 7) { @@ -664,14 +689,21 @@ bool __fastcall TSecureShell::PromptUser(bool /*ToServer*/, PromptTranslation = NewPasswordPromptTranslation; PromptTranslationCount = LENOF(NewPasswordPromptTranslation); PromptKind = pkNewPassword; + PromptDesc = L"new password"; } else { PromptKind = pkPrompt; - assert(false); + PromptDesc = L"unknown"; + FAIL; } - LogEvent(FORMAT(L"Prompt (%d, %s, %s, %s)", (PromptKind, AName, Instructions, (Prompts->Count > 0 ? Prompts->Strings[0] : UnicodeString(L""))))); + UnicodeString InstructionsLog = + (Instructions.IsEmpty() ? UnicodeString(L"") : FORMAT(L"\"%s\"", (Instructions))); + UnicodeString PromptsLog = + (Prompts->Count > 0 ? FORMAT(L"\"%s\"", (Prompts->Strings[0])) : UnicodeString(L"")) + + (Prompts->Count > 1 ? FORMAT(L"%d more", (Prompts->Count - 1)) : UnicodeString()); + LogEvent(FORMAT(L"Prompt (%s, \"%s\", %s, %s)", (PromptDesc, AName, InstructionsLog, PromptsLog))); Name = Name.Trim(); @@ -738,6 +770,16 @@ bool __fastcall TSecureShell::PromptUser(bool /*ToServer*/, FStoredPasswordTried = true; } } + else if (PromptKind == pkPassphrase) + { + if (!FSessionData->Passphrase.IsEmpty() && !FStoredPassphraseTried) + { + LogEvent(L"Using configured passphrase."); + Result = true; + Results->Strings[0] = FSessionData->Passphrase; + FStoredPassphraseTried = true; + } + } if (!Result) { @@ -746,6 +788,11 @@ bool __fastcall TSecureShell::PromptUser(bool /*ToServer*/, if (Result) { + if ((Prompts->Count >= 1) && FLAGSET(int(Prompts->Objects[0]), pupEcho)) + { + LogEvent(FORMAT(L"Response: \"%s\"", (Results->Strings[0]))); + } + if ((PromptKind == pkUserName) && (Prompts->Count == 1)) { FUserName = Results->Strings[0]; @@ -1095,7 +1142,7 @@ void __fastcall TSecureShell::DispatchSendBuffer(int BufSize) break; default: - assert(false); + FAIL; // fallthru case qaAbort: @@ -1588,7 +1635,7 @@ void __fastcall TSecureShell::WaitForData() break; default: - assert(false); + FAIL; // fallthru case qaAbort: @@ -1908,17 +1955,6 @@ TCipher __fastcall TSecureShell::FuncToSsh2Cipher(const void * Cipher) return Result; } //--------------------------------------------------------------------------- -struct TClipboardHandler -{ - UnicodeString Text; - - void __fastcall Copy(TObject * /*Sender*/) - { - TInstantOperationVisualizer Visualizer; - CopyToClipboard(Text); - } -}; -//--------------------------------------------------------------------------- UnicodeString __fastcall TSecureShell::FormatKeyStr(UnicodeString KeyStr) { int Index = 1; @@ -1997,7 +2033,10 @@ void __fastcall TSecureShell::VerifyHostKey(UnicodeString Host, int Port, } } - if (!Result && (StoredKeys.IsEmpty() || FSessionData->OverrideCachedHostKey)) + bool ConfiguredKeyNotMatch = false; + + if (!Result && !FSessionData->HostKey.IsEmpty() && + (StoredKeys.IsEmpty() || FSessionData->OverrideCachedHostKey)) { UnicodeString Buf = FSessionData->HostKey; while (!Result && !Buf.IsEmpty()) @@ -2021,12 +2060,17 @@ void __fastcall TSecureShell::VerifyHostKey(UnicodeString Host, int Port, LogEvent(FORMAT(L"Host key does not match configured key %s", (ExpectedKey))); } } + + if (!Result) + { + ConfiguredKeyNotMatch = true; + } } if (!Result) { bool Verified; - if (Configuration->DisableAcceptingHostKeys) + if (ConfiguredKeyNotMatch || Configuration->DisableAcceptingHostKeys) { Verified = false; } @@ -2092,7 +2136,9 @@ void __fastcall TSecureShell::VerifyHostKey(UnicodeString Host, int Port, { Configuration->Usage->Inc(L"HostNotVerified"); - Exception * E = new Exception(MainInstructions(LoadStr(KEY_NOT_VERIFIED))); + UnicodeString Message = + ConfiguredKeyNotMatch ? FMTLOAD(CONFIGURED_KEY_NOT_MATCH, (FSessionData->HostKey)) : LoadStr(KEY_NOT_VERIFIED); + Exception * E = new Exception(MainInstructions(Message)); try { FUI->FatalError(E, FMTLOAD(HOSTKEY, (Fingerprint))); @@ -2130,7 +2176,7 @@ void __fastcall TSecureShell::AskAlg(const UnicodeString AlgType, } else { - assert(false); + FAIL; } Msg = FMTLOAD(CIPHER_BELOW_TRESHOLD, (LoadStr(CipherType), AlgName)); @@ -2155,7 +2201,7 @@ void __fastcall TSecureShell::OldKeyfileWarning() //--------------------------------------------------------------------------- bool __fastcall TSecureShell::GetStoredCredentialsTried() { - return FStoredPasswordTried || FStoredPasswordTriedForKI; + return FStoredPasswordTried || FStoredPasswordTriedForKI || FStoredPassphraseTried; } //--------------------------------------------------------------------------- bool __fastcall TSecureShell::GetReady() @@ -2183,6 +2229,10 @@ void __fastcall TSecureShell::CollectUsage() { Configuration->Usage->Inc(L"OpenedSessionsSSHOpenSSH"); } + else if (FProFTPD) + { + Configuration->Usage->Inc(L"OpenedSessionsSSHProFTPD"); + } else { Configuration->Usage->Inc(L"OpenedSessionsSSHOther"); diff --git a/source/core/SecureShell.h b/source/core/SecureShell.h index 985f8300..680b1b50 100644 --- a/source/core/SecureShell.h +++ b/source/core/SecureShell.h @@ -40,6 +40,7 @@ friend class TPoolForDataEvent; bool FDataWhileFrozen; bool FStoredPasswordTried; bool FStoredPasswordTriedForKI; + bool FStoredPassphraseTried; int FSshVersion; bool FOpened; int FWaiting; @@ -48,6 +49,7 @@ friend class TPoolForDataEvent; bool FCollectPrivateKeyUsage; int FWaitingForData; bool FOpenSSH; + bool FProFTPD; unsigned PendLen; unsigned PendSize; @@ -132,6 +134,7 @@ friend class TPoolForDataEvent; bool __fastcall GetStoredCredentialsTried(); void __fastcall CollectUsage(); bool __fastcall IsOpenSSH(); + bool __fastcall IsProFTPD(); void __fastcall RegisterReceiveHandler(TNotifyEvent Handler); void __fastcall UnregisterReceiveHandler(TNotifyEvent Handler); diff --git a/source/core/Security.cpp b/source/core/Security.cpp index 831e6c20..936eed2e 100644 --- a/source/core/Security.cpp +++ b/source/core/Security.cpp @@ -102,3 +102,68 @@ bool GetExternalEncryptedPassword(RawByteString Encrypted, RawByteString & Passw return Result; } //--------------------------------------------------------------------------- +bool WindowsValidateCertificate(const unsigned char * Certificate, size_t Len) +{ + bool Result = false; + + // Parse the certificate into a context. + const CERT_CONTEXT * CertContext = + CertCreateCertificateContext( + X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, Certificate, Len); + + if (CertContext != NULL) + { + CERT_CHAIN_PARA ChainPara; + // Retrieve the certificate chain of the certificate + // (a certificate without a valid root does not have a chain). + memset(&ChainPara, 0, sizeof(ChainPara)); + ChainPara.cbSize = sizeof(ChainPara); + + CERT_CHAIN_ENGINE_CONFIG ChainConfig; + + memset(&ChainConfig, 0, sizeof(ChainConfig)); + ChainConfig.cbSize = sizeof(CERT_CHAIN_ENGINE_CONFIG); + ChainConfig.hRestrictedRoot = NULL; + ChainConfig.hRestrictedTrust = NULL; + ChainConfig.hRestrictedOther = NULL; + ChainConfig.cAdditionalStore = 0; + ChainConfig.rghAdditionalStore = NULL; + ChainConfig.dwFlags = CERT_CHAIN_CACHE_END_CERT; + ChainConfig.dwUrlRetrievalTimeout = 0; + ChainConfig.MaximumCachedCertificates =0; + ChainConfig.CycleDetectionModulus = 0; + + HCERTCHAINENGINE ChainEngine; + if (CertCreateCertificateChainEngine(&ChainConfig, &ChainEngine)) + { + const CERT_CHAIN_CONTEXT * ChainContext = NULL; + if (CertGetCertificateChain(ChainEngine, CertContext, NULL, NULL, &ChainPara, + CERT_CHAIN_CACHE_END_CERT | + CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT, + NULL, &ChainContext)) + { + CERT_CHAIN_POLICY_PARA PolicyPara; + + PolicyPara.cbSize = sizeof(PolicyPara); + PolicyPara.dwFlags = 0; + PolicyPara.pvExtraPolicyPara = NULL; + + CERT_CHAIN_POLICY_STATUS PolicyStatus; + PolicyStatus.cbSize = sizeof(PolicyStatus); + + if (CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_SSL, + ChainContext, &PolicyPara, &PolicyStatus)) + { + // Windows thinks the certificate is valid. + Result = (PolicyStatus.dwError == S_OK); + } + + CertFreeCertificateChain(ChainContext); + } + CertFreeCertificateChainEngine(ChainEngine); + } + CertFreeCertificateContext(CertContext); + } + return Result; +} +//--------------------------------------------------------------------------- diff --git a/source/core/Security.h b/source/core/Security.h index d2e75be4..ec855449 100644 --- a/source/core/Security.h +++ b/source/core/Security.h @@ -12,4 +12,6 @@ UnicodeString DecryptPassword(RawByteString Password, UnicodeString Key, Integer RawByteString SetExternalEncryptedPassword(RawByteString Password); bool GetExternalEncryptedPassword(RawByteString Encrypted, RawByteString & Password); //--------------------------------------------------------------------------- +bool WindowsValidateCertificate(const unsigned char * Certificate, size_t Len); +//--------------------------------------------------------------------------- #endif diff --git a/source/core/SessionData.cpp b/source/core/SessionData.cpp index 0bde3a19..0a8cb424 100644 --- a/source/core/SessionData.cpp +++ b/source/core/SessionData.cpp @@ -13,6 +13,7 @@ #include "RemoteFiles.h" #include #include +#include //--------------------------------------------------------------------------- #pragma package(smart_init) //--------------------------------------------------------------------------- @@ -34,6 +35,7 @@ const int HTTPPortNumber = 80; const int HTTPSPortNumber = 443; const int TelnetPortNumber = 23; const int DefaultSendBuf = 262144; +const int ProxyPortNumber = 80; const UnicodeString AnonymousUserName(L"anonymous"); const UnicodeString AnonymousPassword(L"anonymous@example.com"); const UnicodeString PuttySshProtocol(L"ssh"); @@ -46,6 +48,10 @@ const UnicodeString WebDAVProtocol(L"http"); const UnicodeString WebDAVSProtocol(L"https"); const UnicodeString ProtocolSeparator(L"://"); const UnicodeString WinSCPProtocolPrefix(L"winscp-"); +const wchar_t UrlParamSeparator = L';'; +const wchar_t UrlParamValueSeparator = L'='; +const UnicodeString UrlHostKeyParamName(L"fingerprint"); +const UnicodeString UrlSaveParamName(L"save"); //--------------------------------------------------------------------- TDateTime __fastcall SecToDateTime(int Sec) { @@ -95,16 +101,18 @@ void __fastcall TSessionData::Default() Kex[Index] = DefaultKexList[Index]; } PublicKeyFile = L""; + Passphrase = L""; FPuttyProtocol = PuttySshProtocol; TcpNoDelay = true; SendBuf = DefaultSendBuf; SshSimple = true; HostKey = L""; FOverrideCachedHostKey = true; + Note = L""; ProxyMethod = ::pmNone; ProxyHost = L"proxy"; - ProxyPort = 80; + ProxyPort = ProxyPortNumber; ProxyUsername = L""; ProxyPassword = L""; ProxyTelnetCommand = L"connect %host %port\\n"; @@ -185,7 +193,7 @@ void __fastcall TSessionData::Default() FtpAccount = L""; FtpPingInterval = 30; FtpPingType = ptDummyCommand; - FtpTransferActiveImmediatelly = false; + FtpTransferActiveImmediately = false; Ftps = ftpsNone; MinTlsVersion = ssl2; MaxTlsVersion = tls12; @@ -220,12 +228,14 @@ void __fastcall TSessionData::NonPersistant() PROPERTY(UserName); \ PROPERTY(Password); \ PROPERTY(PublicKeyFile); \ + PROPERTY(Passphrase); \ PROPERTY(FSProtocol); \ PROPERTY(Ftps); \ PROPERTY(LocalDirectory); \ PROPERTY(RemoteDirectory); \ PROPERTY(Color); \ - PROPERTY(SynchronizeBrowsing); + PROPERTY(SynchronizeBrowsing); \ + PROPERTY(Note); //--------------------------------------------------------------------- #define ADVANCED_PROPERTIES \ PROPERTY(PingInterval); \ @@ -325,7 +335,7 @@ void __fastcall TSessionData::NonPersistant() PROPERTY(FtpAccount); \ PROPERTY(FtpPingInterval); \ PROPERTY(FtpPingType); \ - PROPERTY(FtpTransferActiveImmediatelly); \ + PROPERTY(FtpTransferActiveImmediately); \ PROPERTY(FtpListAll); \ PROPERTY(SslSessionReuse); \ \ @@ -428,6 +438,7 @@ void __fastcall TSessionData::DoLoad(THierarchicalStorage * Storage, bool & Rewr } } HostKey = Storage->ReadString(L"HostKey", HostKey); + Note = Storage->ReadString(L"Note", Note); // Putty uses PingIntervalSecs int PingIntervalSecs = Storage->ReadInteger(L"PingIntervalSecs", -1); if (PingIntervalSecs < 0) @@ -441,21 +452,7 @@ void __fastcall TSessionData::DoLoad(THierarchicalStorage * Storage, bool & Rewr { PingInterval = 30; } - // PingType has not existed before 3.5, where PingInterval > 0 meant today's ptNullPacket - // Since 3.5, until 4.1 PingType was stored unconditionally. - // Since 4.1 PingType is stored when it is not ptOff (default) or - // when PingInterval is stored. - if (!Storage->ValueExists(L"PingType")) - { - if (Storage->ReadInteger(L"PingInterval", 0) > 0) - { - PingType = ptNullPacket; - } - } - else - { - PingType = static_cast(Storage->ReadInteger(L"PingType", ptOff)); - } + PingType = static_cast(Storage->ReadInteger(L"PingType", ptOff)); Timeout = Storage->ReadInteger(L"Timeout", Timeout); TryAgent = Storage->ReadBool(L"TryAgent", TryAgent); AgentFwd = Storage->ReadBool(L"AgentFwd", AgentFwd); @@ -577,6 +574,7 @@ void __fastcall TSessionData::DoLoad(THierarchicalStorage * Storage, bool & Rewr READ_BUG(Rekey2); READ_BUG(MaxPkt2); READ_BUG(Ignore2); + READ_BUG(WinAdj); #undef READ_BUG if ((Bug[sbHMAC2] == asAuto) && @@ -628,7 +626,7 @@ void __fastcall TSessionData::DoLoad(THierarchicalStorage * Storage, bool & Rewr FtpAccount = Storage->ReadString(L"FtpAccount", FtpAccount); FtpPingInterval = Storage->ReadInteger(L"FtpPingInterval", FtpPingInterval); FtpPingType = static_cast(Storage->ReadInteger(L"FtpPingType", FtpPingType)); - FtpTransferActiveImmediatelly = Storage->ReadBool(L"FtpTransferActiveImmediatelly", FtpTransferActiveImmediatelly); + FtpTransferActiveImmediately = Storage->ReadBool(L"FtpTransferActiveImmediately", FtpTransferActiveImmediately); Ftps = static_cast(Storage->ReadInteger(L"Ftps", Ftps)); FtpListAll = TAutoSwitch(Storage->ReadInteger(L"FtpListAll", FtpListAll)); SslSessionReuse = Storage->ReadBool(L"SslSessionReuse", SslSessionReuse); @@ -655,9 +653,8 @@ void __fastcall TSessionData::Load(THierarchicalStorage * Storage) // the password is wrongly encrypted (using a different master password), // this breaks sites reload and consequently an overal operation, // such as opening Sites menu - FPassword = L""; + ClearSessionPasswords(); FProxyPassword = L""; - FTunnelPassword = L""; DoLoad(Storage, RewritePassword); @@ -720,23 +717,14 @@ void __fastcall TSessionData::Save(THierarchicalStorage * Storage, WRITE_DATA_EX(Integer, L"PingInterval", PingInterval / SecsPerMin, ); WRITE_DATA_EX(Integer, L"PingIntervalSecs", PingInterval % SecsPerMin, ); Storage->DeleteValue(L"PingIntervalSec"); // obsolete - // when PingInterval is stored always store PingType not to attempt to - // deduce PingType from PingInterval (backward compatibility with pre 3.5) - if (((Default != NULL) && (PingType != Default->PingType)) || - Storage->ValueExists(L"PingInterval")) - { - Storage->WriteInteger(L"PingType", PingType); - } - else - { - Storage->DeleteValue(L"PingType"); - } + WRITE_DATA(Integer, PingType); WRITE_DATA(Integer, Timeout); WRITE_DATA(Bool, TryAgent); WRITE_DATA(Bool, AgentFwd); WRITE_DATA(Bool, AuthTIS); WRITE_DATA(Bool, AuthKI); WRITE_DATA(Bool, AuthKIPassword); + WRITE_DATA(String, Note); WRITE_DATA(Bool, AuthGSSAPI); WRITE_DATA(Bool, GSSAPIFwdTGT); @@ -877,6 +865,7 @@ void __fastcall TSessionData::Save(THierarchicalStorage * Storage, WRITE_BUG(Rekey2); WRITE_BUG(MaxPkt2); WRITE_BUG(Ignore2); + WRITE_BUG(WinAdj); #undef WRITE_BUG #undef WRITE_DATA_CONV_FUNC @@ -915,7 +904,7 @@ void __fastcall TSessionData::Save(THierarchicalStorage * Storage, WRITE_DATA(String, FtpAccount); WRITE_DATA(Integer, FtpPingInterval); WRITE_DATA(Integer, FtpPingType); - WRITE_DATA(Bool, FtpTransferActiveImmediatelly); + WRITE_DATA(Bool, FtpTransferActiveImmediately); WRITE_DATA(Integer, Ftps); WRITE_DATA(Integer, FtpListAll); WRITE_DATA(Bool, SslSessionReuse); @@ -973,7 +962,7 @@ int __fastcall TSessionData::ReadXmlNode(_di_IXMLNode Node, const UnicodeString //--------------------------------------------------------------------- void __fastcall TSessionData::ImportFromFilezilla(_di_IXMLNode Node, const UnicodeString & Path) { - Name = UnixIncludeTrailingBackslash(Path) + ReadXmlNode(Node, L"Name", Name); + Name = UnixIncludeTrailingBackslash(Path) + MakeValidName(ReadXmlNode(Node, L"Name", Name)); HostName = ReadXmlNode(Node, L"Host", HostName); PortNumber = ReadXmlNode(Node, L"Port", PortNumber); @@ -1041,6 +1030,8 @@ void __fastcall TSessionData::ImportFromFilezilla(_di_IXMLNode Node, const Unico // todo PostLoginCommands + Note = ReadXmlNode(Node, L"Comments", Note); + LocalDirectory = ReadXmlNode(Node, L"LocalDir", LocalDirectory); UnicodeString RemoteDir = ReadXmlNode(Node, L"RemoteDir", L""); @@ -1112,6 +1103,7 @@ void __fastcall TSessionData::RecryptPasswords() Password = Password; ProxyPassword = ProxyPassword; TunnelPassword = TunnelPassword; + Passphrase = Passphrase; } //--------------------------------------------------------------------- bool __fastcall TSessionData::HasPassword() @@ -1119,9 +1111,20 @@ bool __fastcall TSessionData::HasPassword() return !FPassword.IsEmpty(); } //--------------------------------------------------------------------- +bool __fastcall TSessionData::HasAnySessionPassword() +{ + return HasPassword() || !FTunnelPassword.IsEmpty(); +} +//--------------------------------------------------------------------- bool __fastcall TSessionData::HasAnyPassword() { - return HasPassword() || !FProxyPassword.IsEmpty() || !FTunnelPassword.IsEmpty(); + return HasAnySessionPassword() || !FProxyPassword.IsEmpty(); +} +//--------------------------------------------------------------------- +void __fastcall TSessionData::ClearSessionPasswords() +{ + FPassword = L""; + FTunnelPassword = L""; } //--------------------------------------------------------------------- void __fastcall TSessionData::Modify() @@ -1147,7 +1150,7 @@ UnicodeString __fastcall TSessionData::GetSource() return L"Modified site"; default: - assert(false); + FAIL; return L""; } } @@ -1198,7 +1201,7 @@ void __fastcall TSessionData::CacheHostKeyIfNotCached() UnicodeString HostKeyName = PuttyMungeStr(FORMAT(L"%s@%d:%s", (KeyType, PortNumber, HostName))); if (!Storage->ValueExists(HostKeyName)) { - // we do not want to implement translating fingerprint to formatted key, + // fingerprint is MD5 of host key, so it cannot be translate back to host key, // so we store fingerprint and TSecureShell::VerifyHostKey was // modified to accept also fingerprint Storage->WriteString(HostKeyName, HostKey); @@ -1309,15 +1312,19 @@ bool __fastcall TSessionData::ParseUrl(UnicodeString Url, TOptions * Options, // (this allows setting for example default username for host // by creating stored session named by host) TSessionData * Data = NULL; - for (Integer Index = 0; Index < StoredSessions->Count + StoredSessions->HiddenCount; Index++) + // When using to paste URL on Login dialog, we do not want to lookup the stored sites + if (StoredSessions != NULL) { - TSessionData * AData = (TSessionData *)StoredSessions->Items[Index]; - if (!AData->IsWorkspace && - (AnsiSameText(AData->Name, DecodedUrl) || - AnsiSameText(AData->Name + L"/", DecodedUrl.SubString(1, AData->Name.Length() + 1)))) + for (Integer Index = 0; Index < StoredSessions->Count + StoredSessions->HiddenCount; Index++) { - Data = AData; - break; + TSessionData * AData = (TSessionData *)StoredSessions->Items[Index]; + if (!AData->IsWorkspace && + (AnsiSameText(AData->Name, DecodedUrl) || + AnsiSameText(AData->Name + L"/", DecodedUrl.SubString(1, AData->Name.Length() + 1)))) + { + Data = AData; + break; + } } } @@ -1349,7 +1356,11 @@ bool __fastcall TSessionData::ParseUrl(UnicodeString Url, TOptions * Options, } else { - Assign(StoredSessions->DefaultSettings); + // This happens when pasting URL on Login dialog + if (StoredSessions != NULL) + { + Assign(StoredSessions->DefaultSettings); + } Name = L""; int PSlash = Url.Pos(L"/"); @@ -1406,15 +1417,15 @@ bool __fastcall TSessionData::ParseUrl(UnicodeString Url, TOptions * Options, Ftps = AFtps; } - UnicodeString UserInfoWithoutConnectionParams = CutToChar(UserInfo, L';', false); + UnicodeString UserInfoWithoutConnectionParams = CutToChar(UserInfo, UrlParamSeparator, false); UnicodeString ConnectionParams = UserInfo; UserInfo = UserInfoWithoutConnectionParams; while (!ConnectionParams.IsEmpty()) { - UnicodeString ConnectionParam = CutToChar(ConnectionParams, L';', false); - UnicodeString ConnectionParamName = CutToChar(ConnectionParam, L'=', false); - if (AnsiSameText(ConnectionParamName, L"fingerprint")) + UnicodeString ConnectionParam = CutToChar(ConnectionParams, UrlParamSeparator, false); + UnicodeString ConnectionParamName = CutToChar(ConnectionParam, UrlParamValueSeparator, false); + if (AnsiSameText(ConnectionParamName, UrlHostKeyParamName)) { HostKey = ConnectionParam; FOverrideCachedHostKey = false; @@ -1427,14 +1438,14 @@ bool __fastcall TSessionData::ParseUrl(UnicodeString Url, TOptions * Options, Password = DecodeUrlChars(UserInfo); UnicodeString RemoteDirectoryWithSessionParams = Url.SubString(PSlash, Url.Length() - PSlash + 1); - ARemoteDirectory = CutToChar(RemoteDirectoryWithSessionParams, L';', false); + ARemoteDirectory = CutToChar(RemoteDirectoryWithSessionParams, UrlParamSeparator, false); UnicodeString SessionParams = RemoteDirectoryWithSessionParams; while (!SessionParams.IsEmpty()) { - UnicodeString SessionParam = CutToChar(SessionParams, L';', false); - UnicodeString SessionParamName = CutToChar(SessionParam, L'=', false); - if (AnsiSameText(SessionParamName, L"save")) + UnicodeString SessionParam = CutToChar(SessionParams, UrlParamSeparator, false); + UnicodeString SessionParamName = CutToChar(SessionParam, UrlParamValueSeparator, false); + if (AnsiSameText(SessionParamName, UrlSaveParamName)) { FSaveOnly = (StrToIntDef(SessionParam, 1) != 0); } @@ -1445,9 +1456,13 @@ bool __fastcall TSessionData::ParseUrl(UnicodeString Url, TOptions * Options, (*MaskedUrl) += RawUserName; if (!UserInfo.IsEmpty()) { - (*MaskedUrl) += L":***"; + (*MaskedUrl) += L":" + PasswordMask; } - (*MaskedUrl) += L"@" + OrigHostInfo + ARemoteDirectory; + if (!RawUserName.IsEmpty() || !UserInfo.IsEmpty()) + { + (*MaskedUrl) += L"@"; + } + (*MaskedUrl) += OrigHostInfo + ARemoteDirectory; } } @@ -1466,7 +1481,11 @@ bool __fastcall TSessionData::ParseUrl(UnicodeString Url, TOptions * Options, } else { - Assign(StoredSessions->DefaultSettings); + // This happens when pasting URL on Login dialog + if (StoredSessions != NULL) + { + Assign(StoredSessions->DefaultSettings); + } DefaultsOnly = true; } @@ -1486,6 +1505,10 @@ bool __fastcall TSessionData::ParseUrl(UnicodeString Url, TOptions * Options, { PublicKeyFile = Value; } + if (Options->FindSwitch(L"passphrase", Value)) + { + Passphrase = Value; + } if (Options->FindSwitch(L"timeout", Value)) { Timeout = StrToInt(Value); @@ -1584,12 +1607,19 @@ void __fastcall TSessionData::ValidatePath(const UnicodeString Path) //--------------------------------------------------------------------- void __fastcall TSessionData::ValidateName(const UnicodeString Name) { + // keep consistent with MakeValidName if (Name.LastDelimiter(L"/") > 0) { throw Exception(FMTLOAD(ITEM_NAME_INVALID, (Name, L"/"))); } } //--------------------------------------------------------------------- +UnicodeString __fastcall TSessionData::MakeValidName(const UnicodeString & Name) +{ + // keep consistent with ValidateName + return ReplaceStr(Name, L"/", L"\\"); +} +//--------------------------------------------------------------------- RawByteString __fastcall TSessionData::EncryptPassword(const UnicodeString & Password, UnicodeString Key) { return Configuration->EncryptPassword(Password, Key); @@ -1641,6 +1671,11 @@ UnicodeString __fastcall TSessionData::GetStorageKey() return SessionName; } //--------------------------------------------------------------------- +UnicodeString __fastcall TSessionData::GetSiteKey() +{ + return FORMAT(L"%s:%d", (HostNameExpanded, PortNumber)); +} +//--------------------------------------------------------------------- void __fastcall TSessionData::SetHostName(UnicodeString value) { if (FHostName != value) @@ -1648,6 +1683,8 @@ void __fastcall TSessionData::SetHostName(UnicodeString value) // HostName is key for password encryption UnicodeString XPassword = Password; + // This is now hardly used as hostname is parsed directly on login dialog. + // But can be used when importing sites from PuTTY, as it allows same format too. int P = value.LastDelimiter(L"@"); if (P > 0) { @@ -1915,11 +1952,28 @@ void __fastcall TSessionData::SetPublicKeyFile(UnicodeString value) { if (FPublicKeyFile != value) { + // PublicKeyFile is key for Passphrase encryption + UnicodeString XPassphrase = Passphrase; + FPublicKeyFile = StripPathQuotes(value); Modify(); + + Passphrase = XPassphrase; + Shred(XPassphrase); } } //--------------------------------------------------------------------- +void __fastcall TSessionData::SetPassphrase(UnicodeString avalue) +{ + RawByteString value = EncryptPassword(avalue, PublicKeyFile); + SET_SESSION_PROPERTY(Passphrase); +} +//--------------------------------------------------------------------- +UnicodeString __fastcall TSessionData::GetPassphrase() const +{ + return DecryptPassword(FPassphrase, PublicKeyFile); +} +//--------------------------------------------------------------------- void __fastcall TSessionData::SetReturnVar(UnicodeString value) { SET_SESSION_PROPERTY(ReturnVar); @@ -2059,6 +2113,51 @@ UnicodeString __fastcall TSessionData::GetSessionName() return Result; } //--------------------------------------------------------------------- +UnicodeString __fastcall TSessionData::GetProtocolUrl() +{ + UnicodeString Url; + switch (FSProtocol) + { + case fsSCPonly: + Url = ScpProtocol; + break; + + default: + FAIL; + // fallback + case fsSFTP: + case fsSFTPonly: + Url = SftpProtocol; + break; + + case fsFTP: + if (Ftps == ftpsImplicit) + { + Url = FtpsProtocol; + } + else + { + Url = FtpProtocol; + } + break; + + case fsWebDAV: + if (Ftps == ftpsImplicit) + { + Url = WebDAVSProtocol; + } + else + { + Url = WebDAVProtocol; + } + break; + } + + Url += ProtocolSeparator; + + return Url; +} +//--------------------------------------------------------------------- UnicodeString __fastcall TSessionData::GetSessionUrl() { UnicodeString Url; @@ -2068,43 +2167,7 @@ UnicodeString __fastcall TSessionData::GetSessionUrl() } else { - switch (FSProtocol) - { - case fsSCPonly: - Url = ScpProtocol; - break; - - default: - assert(false); - // fallback - case fsSFTP: - case fsSFTPonly: - Url = SftpProtocol; - break; - - case fsFTP: - if (Ftps == ftpsImplicit) - { - Url = FtpsProtocol; - } - else - { - Url = FtpProtocol; - } - break; - case fsWebDAV: - if (Ftps == ftpsImplicit) - { - Url = WebDAVSProtocol; - } - else - { - Url = WebDAVProtocol; - } - break; - } - - Url += ProtocolSeparator; + Url = ProtocolUrl; if (!HostName.IsEmpty() && !UserName.IsEmpty()) { @@ -2466,9 +2529,9 @@ void __fastcall TSessionData::SetFtpPingType(TPingType value) SET_SESSION_PROPERTY(FtpPingType); } //--------------------------------------------------------------------------- -void __fastcall TSessionData::SetFtpTransferActiveImmediatelly(bool value) +void __fastcall TSessionData::SetFtpTransferActiveImmediately(bool value) { - SET_SESSION_PROPERTY(FtpTransferActiveImmediatelly); + SET_SESSION_PROPERTY(FtpTransferActiveImmediately); } //--------------------------------------------------------------------------- void __fastcall TSessionData::SetFtps(TFtps value) @@ -2516,6 +2579,11 @@ void __fastcall TSessionData::SetHostKey(UnicodeString value) SET_SESSION_PROPERTY(HostKey); } //--------------------------------------------------------------------- +void __fastcall TSessionData::SetNote(UnicodeString value) +{ + SET_SESSION_PROPERTY(Note); +} +//--------------------------------------------------------------------- UnicodeString __fastcall TSessionData::GetInfoTip() { if (UsesSsh) @@ -2801,7 +2869,9 @@ void __fastcall TStoredSessionList::ImportLevelFromFilezilla(_di_IXMLNode Node, } } - ImportLevelFromFilezilla(ChildNode, UnixIncludeTrailingBackslash(Path) + Name.Trim()); + Name = TSessionData::MakeValidName(Name).Trim(); + + ImportLevelFromFilezilla(ChildNode, TSessionData::ComposePath(Path, Name)); } } } @@ -2845,7 +2915,7 @@ void __fastcall TStoredSessionList::SelectAll(bool Select) } //--------------------------------------------------------------------- void __fastcall TStoredSessionList::Import(TStoredSessionList * From, - bool OnlySelected) + bool OnlySelected, TList * Imported) { for (int Index = 0; Index < From->Count; Index++) { @@ -2856,6 +2926,10 @@ void __fastcall TStoredSessionList::Import(TStoredSessionList * From, Session->Modified = true; Session->MakeUniqueIn(this); Add(Session); + if (Imported != NULL) + { + Imported->Add(Session); + } } } // only modified, explicit @@ -2907,12 +2981,13 @@ void __fastcall TStoredSessionList::UpdateStaticUsage() int Password = 0; int Advanced = 0; int Color = 0; + int Note = 0; bool Folders = false; bool Workspaces = false; std::unique_ptr FactoryDefaults(new TSessionData(L"")); std::unique_ptr DifferentAdvancedProperties(new TStringList(L"")); DifferentAdvancedProperties->Sorted = true; - DifferentAdvancedProperties->Duplicates = dupIgnore; + DifferentAdvancedProperties->Duplicates = Types::dupIgnore; for (int Index = 0; Index < Count; Index++) { TSessionData * Data = Sessions[Index]; @@ -2956,7 +3031,7 @@ void __fastcall TStoredSessionList::UpdateStaticUsage() break; } - if (Data->HasAnyPassword()) + if (Data->HasAnySessionPassword()) { Password++; } @@ -2966,6 +3041,11 @@ void __fastcall TStoredSessionList::UpdateStaticUsage() Color++; } + if (!Data->Note.IsEmpty()) + { + Note++; + } + // this effectively does not take passwords (proxy + tunnel) into account, // when master password is set, as master password handler in not set up yet if (!Data->IsSame(FactoryDefaults.get(), true, DifferentAdvancedProperties.get())) @@ -2988,6 +3068,7 @@ void __fastcall TStoredSessionList::UpdateStaticUsage() Configuration->Usage->Set(L"StoredSessionsCountWebDAVS", WebDAVS); Configuration->Usage->Set(L"StoredSessionsCountPassword", Password); Configuration->Usage->Set(L"StoredSessionsCountColor", Color); + Configuration->Usage->Set(L"StoredSessionsCountNote", Note); Configuration->Usage->Set(L"StoredSessionsCountAdvanced", Advanced); DifferentAdvancedProperties->Delimiter = L','; Configuration->Usage->Set(L"StoredSessionsAdvancedSettings", DifferentAdvancedProperties->DelimitedText); @@ -3212,7 +3293,7 @@ TStrings * __fastcall TStoredSessionList::GetWorkspaces() { std::unique_ptr Result(new TStringList()); Result->Sorted = true; - Result->Duplicates = dupIgnore; + Result->Duplicates = Types::dupIgnore; Result->CaseSensitive = false; for (int Index = 0; (Index < Count); Index++) @@ -3283,6 +3364,15 @@ TSessionData * __fastcall TStoredSessionList::ParseUrl(UnicodeString Url, return Data; } //--------------------------------------------------------------------- +bool __fastcall TStoredSessionList::IsUrl(UnicodeString Url) +{ + bool DefaultsOnly; + bool ProtocolDefined = false; + std::unique_ptr ParsedData(ParseUrl(Url, NULL, DefaultsOnly, NULL, &ProtocolDefined)); + bool Result = ProtocolDefined; + return Result; +} +//--------------------------------------------------------------------- TSessionData * __fastcall TStoredSessionList::ResolveSessionData(TSessionData * Data) { if (!Data->Link.IsEmpty()) @@ -3364,4 +3454,46 @@ bool __fastcall IsSshProtocol(TFSProtocol FSProtocol) (FSProtocol == fsSFTPonly) || (FSProtocol == fsSFTP) || (FSProtocol == fsSCPonly); } +//--------------------------------------------------------------------------- +int __fastcall DefaultPort(TFSProtocol FSProtocol, TFtps Ftps) +{ + int Result; + switch (FSProtocol) + { + case fsFTP: + if (Ftps == ftpsImplicit) + { + Result = FtpsImplicitPortNumber; + } + else + { + Result = FtpPortNumber; + } + break; + + case fsWebDAV: + if (Ftps == ftpsNone) + { + Result = HTTPPortNumber; + } + else + { + Result = HTTPSPortNumber; + } + break; + + default: + if (IsSshProtocol(FSProtocol)) + { + Result = SshPortNumber; + } + else + { + FAIL; + Result = -1; + } + break; + } + return Result; +} //--------------------------------------------------------------------- diff --git a/source/core/SessionData.h b/source/core/SessionData.h index e0a132de..cb2b939c 100644 --- a/source/core/SessionData.h +++ b/source/core/SessionData.h @@ -23,8 +23,8 @@ enum TSshProt { ssh1only, ssh1, ssh2, ssh2only }; enum TKex { kexWarn, kexDHGroup1, kexDHGroup14, kexDHGEx, kexRSA }; #define KEX_COUNT (kexRSA+1) enum TSshBug { sbIgnore1, sbPlainPW1, sbRSA1, sbHMAC2, sbDeriveKey2, sbRSAPad2, - sbPKSessID2, sbRekey2, sbMaxPkt2, sbIgnore2 }; -#define BUG_COUNT (sbIgnore2+1) + sbPKSessID2, sbRekey2, sbMaxPkt2, sbIgnore2, sbWinAdj }; +#define BUG_COUNT (sbWinAdj+1) enum TSftpBug { sbSymlink, sbSignedTS }; #define SFTP_BUG_COUNT (sbSignedTS+1) enum TPingType { ptOff, ptNullPacket, ptDummyCommand }; @@ -50,6 +50,7 @@ extern const int FtpsImplicitPortNumber; extern const int HTTPPortNumber; extern const int HTTPSPortNumber; extern const int TelnetPortNumber; +extern const int ProxyPortNumber; extern const UnicodeString PuttySshProtocol; extern const UnicodeString PuttyTelnetProtocol; extern const UnicodeString SftpProtocol; @@ -60,6 +61,10 @@ extern const UnicodeString WebDAVProtocol; extern const UnicodeString WebDAVSProtocol; extern const UnicodeString ProtocolSeparator; extern const UnicodeString WinSCPProtocolPrefix; +extern const wchar_t UrlParamSeparator; +extern const wchar_t UrlParamValueSeparator; +extern const UnicodeString UrlHostKeyParamName; +extern const UnicodeString UrlSaveParamName; //--------------------------------------------------------------------------- class TStoredSessionList; //--------------------------------------------------------------------------- @@ -93,6 +98,7 @@ friend class TStoredSessionList; bool FClearAliases; TEOLType FEOLType; UnicodeString FPublicKeyFile; + UnicodeString FPassphrase; UnicodeString FPuttyProtocol; TFSProtocol FFSProtocol; bool FModified; @@ -165,7 +171,7 @@ friend class TStoredSessionList; UnicodeString FFtpAccount; int FFtpPingInterval; TPingType FFtpPingType; - bool FFtpTransferActiveImmediatelly; + bool FFtpTransferActiveImmediately; TFtps FFtps; TTlsVersion FMinTlsVersion; TTlsVersion FMaxTlsVersion; @@ -174,6 +180,7 @@ friend class TStoredSessionList; UnicodeString FLink; UnicodeString FHostKey; bool FOverrideCachedHostKey; + UnicodeString FNote; UnicodeString FOrigHostName; int FOrigPortNumber; @@ -208,6 +215,8 @@ friend class TStoredSessionList; void __fastcall SetKex(int Index, TKex value); TKex __fastcall GetKex(int Index) const; void __fastcall SetPublicKeyFile(UnicodeString value); + UnicodeString __fastcall GetPassphrase() const; + void __fastcall SetPassphrase(UnicodeString value); void __fastcall SetPuttyProtocol(UnicodeString value); bool __fastcall GetCanLogin(); @@ -220,6 +229,7 @@ friend class TStoredSessionList; bool __fastcall HasSessionName(); UnicodeString __fastcall GetDefaultSessionName(); UnicodeString __fastcall GetSessionUrl(); + UnicodeString __fastcall GetProtocolUrl(); void __fastcall SetFSProtocol(TFSProtocol value); UnicodeString __fastcall GetFSProtocolStr(); void __fastcall SetLocalDirectory(UnicodeString value); @@ -285,6 +295,7 @@ friend class TStoredSessionList; void __fastcall SetSslSessionReuse(bool value); UnicodeString __fastcall GetStorageKey(); UnicodeString __fastcall GetInternalStorageKey(); + UnicodeString __fastcall GetSiteKey(); void __fastcall SetDSTMode(TDSTMode value); void __fastcall SetDeleteToRecycleBin(bool value); void __fastcall SetOverwrittenToRecycleBin(bool value); @@ -311,7 +322,7 @@ friend class TStoredSessionList; void __fastcall SetFtpAccount(UnicodeString value); void __fastcall SetFtpPingInterval(int value); void __fastcall SetFtpPingType(TPingType value); - void __fastcall SetFtpTransferActiveImmediatelly(bool value); + void __fastcall SetFtpTransferActiveImmediately(bool value); void __fastcall SetFtps(TFtps value); void __fastcall SetMinTlsVersion(TTlsVersion value); void __fastcall SetMaxTlsVersion(TTlsVersion value); @@ -319,6 +330,7 @@ friend class TStoredSessionList; void __fastcall SetIsWorkspace(bool value); void __fastcall SetLink(UnicodeString value); void __fastcall SetHostKey(UnicodeString value); + void __fastcall SetNote(UnicodeString value); TDateTime __fastcall GetTimeoutDT(); void __fastcall SavePasswords(THierarchicalStorage * Storage, bool PuttyExport); UnicodeString __fastcall GetLocalName(); @@ -349,7 +361,9 @@ friend class TStoredSessionList; void __fastcall SaveRecryptedPasswords(THierarchicalStorage * Storage); void __fastcall RecryptPasswords(); bool __fastcall HasPassword(); + bool __fastcall HasAnySessionPassword(); bool __fastcall HasAnyPassword(); + void __fastcall ClearSessionPasswords(); void __fastcall Remove(); void __fastcall CacheHostKeyIfNotCached(); virtual void __fastcall Assign(TPersistent * Source); @@ -365,6 +379,7 @@ friend class TStoredSessionList; bool __fastcall IsInFolderOrWorkspace(UnicodeString Name); static void __fastcall ValidatePath(const UnicodeString Path); static void __fastcall ValidateName(const UnicodeString Name); + static UnicodeString __fastcall MakeValidName(const UnicodeString & Name); static UnicodeString __fastcall ExtractLocalName(const UnicodeString & Name); static UnicodeString __fastcall ExtractFolderName(const UnicodeString & Name); static UnicodeString __fastcall ComposePath(const UnicodeString & Path, const UnicodeString & Name); @@ -394,6 +409,7 @@ friend class TStoredSessionList; __property TCipher Cipher[int Index] = { read=GetCipher, write=SetCipher }; __property TKex Kex[int Index] = { read=GetKex, write=SetKex }; __property UnicodeString PublicKeyFile = { read=FPublicKeyFile, write=SetPublicKeyFile }; + __property UnicodeString Passphrase = { read=GetPassphrase, write=SetPassphrase }; __property UnicodeString PuttyProtocol = { read=FPuttyProtocol, write=SetPuttyProtocol }; __property TFSProtocol FSProtocol = { read=FFSProtocol, write=SetFSProtocol }; __property UnicodeString FSProtocolStr = { read=GetFSProtocolStr }; @@ -406,6 +422,7 @@ friend class TStoredSessionList; __property UnicodeString SessionName = { read=GetSessionName }; __property UnicodeString DefaultSessionName = { read=GetDefaultSessionName }; __property UnicodeString SessionUrl = { read=GetSessionUrl }; + __property UnicodeString ProtocolUrl = { read=GetProtocolUrl }; __property UnicodeString LocalDirectory = { read=FLocalDirectory, write=SetLocalDirectory }; __property UnicodeString RemoteDirectory = { read=FRemoteDirectory, write=SetRemoteDirectory }; __property bool SynchronizeBrowsing = { read=FSynchronizeBrowsing, write=SetSynchronizeBrowsing }; @@ -485,7 +502,7 @@ friend class TStoredSessionList; __property int FtpPingInterval = { read=FFtpPingInterval, write=SetFtpPingInterval }; __property TDateTime FtpPingIntervalDT = { read=GetFtpPingIntervalDT }; __property TPingType FtpPingType = { read = FFtpPingType, write = SetFtpPingType }; - __property bool FtpTransferActiveImmediatelly = { read = FFtpTransferActiveImmediatelly, write = SetFtpTransferActiveImmediatelly }; + __property bool FtpTransferActiveImmediately = { read = FFtpTransferActiveImmediately, write = SetFtpTransferActiveImmediately }; __property TFtps Ftps = { read = FFtps, write = SetFtps }; __property TTlsVersion MinTlsVersion = { read = FMinTlsVersion, write = SetMinTlsVersion }; __property TTlsVersion MaxTlsVersion = { read = FMaxTlsVersion, write = SetMaxTlsVersion }; @@ -494,7 +511,9 @@ friend class TStoredSessionList; __property UnicodeString Link = { read = FLink, write = SetLink }; __property UnicodeString HostKey = { read = FHostKey, write = SetHostKey }; __property bool OverrideCachedHostKey = { read = FOverrideCachedHostKey }; + __property UnicodeString Note = { read = FNote, write = SetNote }; __property UnicodeString StorageKey = { read = GetStorageKey }; + __property UnicodeString SiteKey = { read = GetSiteKey }; __property UnicodeString OrigHostName = { read = FOrigHostName }; __property int OrigPortNumber = { read = FOrigPortNumber }; __property UnicodeString LocalName = { read = GetLocalName }; @@ -516,7 +535,7 @@ class TStoredSessionList : public TNamedObjectList bool UseDefaults = false); void __fastcall Save(THierarchicalStorage * Storage, bool All = false); void __fastcall SelectAll(bool Select); - void __fastcall Import(TStoredSessionList * From, bool OnlySelected); + void __fastcall Import(TStoredSessionList * From, bool OnlySelected, TList * Imported); void __fastcall RecryptPasswords(TStrings * RecryptPasswordErrors); TSessionData * __fastcall AtSession(int Index) { return (TSessionData*)AtObject(Index); } @@ -531,6 +550,7 @@ class TStoredSessionList : public TNamedObjectList bool __fastcall IsWorkspace(const UnicodeString & Name); TSessionData * __fastcall ParseUrl(UnicodeString Url, TOptions * Options, bool & DefaultsOnly, UnicodeString * FileName = NULL, bool * ProtocolDefined = NULL, UnicodeString * MaskedUrl = NULL); + bool __fastcall IsUrl(UnicodeString Url); bool __fastcall CanLogin(TSessionData * Data); void __fastcall GetFolderOrWorkspace(const UnicodeString & Name, TList * List); TStrings * __fastcall GetFolderOrWorkspaceList(const UnicodeString & Name); @@ -564,5 +584,6 @@ class TStoredSessionList : public TNamedObjectList //--------------------------------------------------------------------------- UnicodeString GetExpandedLogFileName(UnicodeString LogFileName, TSessionData * SessionData); bool __fastcall IsSshProtocol(TFSProtocol FSProtocol); +int __fastcall DefaultPort(TFSProtocol FSProtocol, TFtps Ftps); //--------------------------------------------------------------------------- #endif diff --git a/source/core/SessionInfo.cpp b/source/core/SessionInfo.cpp index 58de7f95..0e66d183 100644 --- a/source/core/SessionInfo.cpp +++ b/source/core/SessionInfo.cpp @@ -299,7 +299,7 @@ class TSessionActionRecord case laCall: return L"call"; case laLs: return L"ls"; case laStat: return L"stat"; - default: assert(false); return L""; + default: FAIL; return L""; } } @@ -569,7 +569,7 @@ FILE * __fastcall OpenFile(UnicodeString LogFileName, TSessionData * SessionData { FILE * Result; UnicodeString ANewFileName = GetExpandedLogFileName(LogFileName, SessionData); - Result = _wfopen(ANewFileName.c_str(), (Append ? L"a" : L"w")); + Result = _wfopen(ApiPath(ANewFileName).c_str(), (Append ? L"a" : L"w")); if (Result != NULL) { setvbuf(Result, NULL, _IONBF, BUFSIZ); @@ -934,31 +934,37 @@ void __fastcall TSessionLog::DoAddStartupInfo(TSessionData * Data) ADF(L"User name: %s (Password: %s, Key file: %s)", (Data->UserNameExpanded, BooleanToEngStr(!Data->Password.IsEmpty()), BooleanToEngStr(!Data->PublicKeyFile.IsEmpty()))) - ADF(L"Tunnel: %s", (BooleanToEngStr(Data->Tunnel))); - if (Data->Tunnel) + if (Data->UsesSsh) { - ADF(L"Tunnel: Host name: %s (Port: %d)", (Data->TunnelHostName, Data->TunnelPortNumber)); - ADF(L"Tunnel: User name: %s (Password: %s, Key file: %s)", - (Data->TunnelUserName, BooleanToEngStr(!Data->TunnelPassword.IsEmpty()), - BooleanToEngStr(!Data->TunnelPublicKeyFile.IsEmpty()))) - ADF(L"Tunnel: Local port number: %d", (Data->TunnelLocalPortNumber)); + ADF(L"Tunnel: %s", (BooleanToEngStr(Data->Tunnel))); + if (Data->Tunnel) + { + ADF(L"Tunnel: Host name: %s (Port: %d)", (Data->TunnelHostName, Data->TunnelPortNumber)); + ADF(L"Tunnel: User name: %s (Password: %s, Key file: %s)", + (Data->TunnelUserName, BooleanToEngStr(!Data->TunnelPassword.IsEmpty()), + BooleanToEngStr(!Data->TunnelPublicKeyFile.IsEmpty()))) + ADF(L"Tunnel: Local port number: %d", (Data->TunnelLocalPortNumber)); + } } ADF(L"Transfer Protocol: %s", (Data->FSProtocolStr)); wchar_t * PingTypes = L"-NC"; - TPingType PingType; - int PingInterval; - if (Data->FSProtocol == fsFTP) + if (Data->UsesSsh || (Data->FSProtocol == fsFTP)) { - PingType = Data->FtpPingType; - PingInterval = Data->FtpPingInterval; - } - else - { - PingType = Data->PingType; - PingInterval = Data->PingInterval; + TPingType PingType; + int PingInterval; + if (Data->FSProtocol == fsFTP) + { + PingType = Data->FtpPingType; + PingInterval = Data->FtpPingInterval; + } + else + { + PingType = Data->PingType; + PingInterval = Data->PingInterval; + } + ADF(L"Ping type: %s, Ping interval: %d sec; Timeout: %d sec", + (UnicodeString(PingTypes[PingType]), PingInterval, Data->Timeout)); } - ADF(L"Ping type: %s, Ping interval: %d sec; Timeout: %d sec", - (UnicodeString(PingTypes[PingType]), PingInterval, Data->Timeout)); ADF(L"Proxy: %s", ((Data->FtpProxyLogonType != 0) ? FORMAT(L"FTP proxy %d", (Data->FtpProxyLogonType)) : @@ -977,7 +983,10 @@ void __fastcall TSessionLog::DoAddStartupInfo(TSessionData * Data) ADF(L"Local command: %s", (Data->ProxyLocalCommand)); } } - ADF(L"Send buffer: %d", (Data->SendBuf)); + if (Data->UsesSsh || (Data->FSProtocol == fsFTP)) + { + ADF(L"Send buffer: %d", (Data->SendBuf)); + } wchar_t const * BugFlags = L"+-A"; if (Data->UsesSsh) { @@ -1015,7 +1024,7 @@ void __fastcall TSessionLog::DoAddStartupInfo(TSessionData * Data) BooleanToEngStr(Data->IgnoreLsWarnings), BooleanToEngStr(Data->Scp1Compatibility))); } - if (Data->FSProtocol == fsSFTP) + if ((Data->FSProtocol == fsSFTP) || (Data->FSProtocol == fsSFTPonly)) { UnicodeString Bugs; for (int Index = 0; Index < SFTP_BUG_COUNT; Index++) @@ -1059,9 +1068,9 @@ void __fastcall TSessionLog::DoAddStartupInfo(TSessionData * Data) ADF(L"TLS/SSL versions: %s-%s", (GetTlsVersionName(Data->MinTlsVersion), GetTlsVersionName(Data->MaxTlsVersion))); } // kind of hidden option, so do not reveal it unless it is set - if (Data->FtpTransferActiveImmediatelly) + if (Data->FtpTransferActiveImmediately) { - ADF(L"Transfer active immediatelly: %s", (BooleanToEngStr(Data->FtpTransferActiveImmediatelly))); + ADF(L"Transfer active immediately: %s", (BooleanToEngStr(Data->FtpTransferActiveImmediately))); } } ADF(L"Local directory: %s, Remote directory: %s, Update: %s, Cache: %s", @@ -1072,8 +1081,17 @@ void __fastcall TSessionLog::DoAddStartupInfo(TSessionData * Data) ADF(L"Cache directory changes: %s, Permanent: %s", (BooleanToEngStr(Data->CacheDirectoryChanges), BooleanToEngStr(Data->PreserveDirectoryChanges))); - int TimeDifferenceMin = TimeToMinutes(Data->TimeDifference); - ADF(L"DST mode: %d; Timezone offset: %dh %dm", (int(Data->DSTMode), (TimeDifferenceMin / MinsPerHour), (TimeDifferenceMin % MinsPerHour))); + UnicodeString TimeInfo; + if ((Data->FSProtocol == fsSFTP) || (Data->FSProtocol == fsSFTPonly) || (Data->FSProtocol == fsSCPonly) || (Data->FSProtocol == fsWebDAV)) + { + AddToList(TimeInfo, FORMAT("DST mode: %d", (int(Data->DSTMode))), L";"); + } + if ((Data->FSProtocol == fsSCPonly) || (Data->FSProtocol == fsFTP)) + { + int TimeDifferenceMin = TimeToMinutes(Data->TimeDifference); + AddToList(TimeInfo, FORMAT("Timezone offset: %dh %dm", ((TimeDifferenceMin / MinsPerHour), (TimeDifferenceMin % MinsPerHour))), L";"); + } + ADSTR(TimeInfo); if (Data->FSProtocol == fsWebDAV) { diff --git a/source/core/SessionInfo.h b/source/core/SessionInfo.h index 39f9ee9f..67ceaada 100644 --- a/source/core/SessionInfo.h +++ b/source/core/SessionInfo.h @@ -31,12 +31,17 @@ struct TSessionInfo //--------------------------------------------------------------------------- enum TFSCapability { fcUserGroupListing, fcModeChanging, fcGroupChanging, fcOwnerChanging, fcGroupOwnerChangingByID, fcAnyCommand, fcHardLink, - fcSymbolicLink, fcResolveSymlink, + fcSymbolicLink, + // With WebDAV this is always true, to avoid double-click on + // file try to open the file as directory. It does no harm atm as + // WebDAV never produce a symlink in listing. + fcResolveSymlink, fcTextMode, fcRename, fcNativeTextMode, fcNewerOnlyUpload, fcRemoteCopy, fcTimestampChanging, fcRemoteMove, fcLoadingAdditionalProperties, fcCheckingSpaceAvailable, fcIgnorePermErrors, fcCalculatingChecksum, fcModeChangingUpload, fcPreservingTimestampUpload, fcShellAnyCommand, - fcSecondaryShell, fcRemoveCtrlZUpload, fcRemoveBOMUpload, fcCount }; + fcSecondaryShell, fcRemoveCtrlZUpload, fcRemoveBOMUpload, fcMoveToQueue, + fcCount }; //--------------------------------------------------------------------------- struct TFileSystemInfo { diff --git a/source/core/SftpFileSystem.cpp b/source/core/SftpFileSystem.cpp index 1277f6c1..4f3172a1 100644 --- a/source/core/SftpFileSystem.cpp +++ b/source/core/SftpFileSystem.cpp @@ -18,8 +18,7 @@ //--------------------------------------------------------------------------- #pragma package(smart_init) //--------------------------------------------------------------------------- -#define FILE_OPERATION_LOOP_EX(ALLOW_SKIP, MESSAGE, OPERATION) \ - FILE_OPERATION_LOOP_CUSTOM(FTerminal, ALLOW_SKIP, MESSAGE, OPERATION, L"") +#define FILE_OPERATION_LOOP_TERMINAL FTerminal //--------------------------------------------------------------------------- #define SSH_FX_OK 0 #define SSH_FX_EOF 1 @@ -140,6 +139,7 @@ #define SFTP_EXT_STATVFS_VALUE_V2 L"2" #define SFTP_EXT_STATVFS_ST_RDONLY 0x1 #define SFTP_EXT_STATVFS_ST_NOSUID 0x2 +#define SFTP_EXT_COPY_FILE "copy-file" //--------------------------------------------------------------------------- #define OGQ_LIST_OWNERS 0x01 #define OGQ_LIST_GROUPS 0x02 @@ -726,7 +726,7 @@ class TSFTPPacket if (Type == SSH_FXP_ATTRS || Version >= 4 || ParsingFailed) { - wchar_t Type = L'-'; + wchar_t Type = FILETYPE_DEFAULT; if (FLAGSET(Flags, SSH_FILEXFER_ATTR_PERMISSIONS)) { File->Rights->Number = (unsigned short)(Permissions & TRights::rfAllSpecials); @@ -1402,9 +1402,11 @@ class TSFTPUploadQueue : public TSFTPAsynchronousQueue if (Result) { - FILE_OPERATION_LOOP(FMTLOAD(READ_ERROR, (FFileName)), + FILE_OPERATION_LOOP_BEGIN + { BlockBuf.LoadStream(FStream, BlockSize, false); - ); + } + FILE_OPERATION_LOOP_END(FMTLOAD(READ_ERROR, (FFileName))); FEnd = (BlockBuf.Size == 0); Result = !FEnd; @@ -1666,6 +1668,7 @@ class TSFTPBusy struct TOpenRemoteFileParams { int LocalFileAttrs; + UnicodeString FileName; UnicodeString RemoteFileName; TFileOperationProgressType * OperationProgress; const TCopyParamType * CopyParam; @@ -1808,10 +1811,7 @@ const TFileSystemInfo & __fastcall TSFTPFileSystem::GetFileSystemInfo(bool /*Ret FFileSystemInfo.ProtocolBaseName = L"SFTP"; FFileSystemInfo.ProtocolName = FMTLOAD(SFTP_PROTOCOL_NAME2, (FVersion)); - for (int Index = 0; Index < fcCount; Index++) - { - FFileSystemInfo.IsCapable[Index] = IsCapable((TFSCapability)Index); - } + FTerminal->SaveCapabilities(FFileSystemInfo); FFileSystemInfoValid = true; } @@ -1875,7 +1875,6 @@ bool __fastcall TSFTPFileSystem::IsCapable(int Capability) const case fcAnyCommand: case fcShellAnyCommand: case fcHardLink: - case fcRemoteCopy: return false; case fcNewerOnlyUpload: @@ -1885,6 +1884,7 @@ bool __fastcall TSFTPFileSystem::IsCapable(int Capability) const case fcSecondaryShell: case fcRemoveCtrlZUpload: case fcRemoveBOMUpload: + case fcMoveToQueue: return true; case fcRename: @@ -1941,8 +1941,11 @@ bool __fastcall TSFTPFileSystem::IsCapable(int Capability) const case fcCalculatingChecksum: return SupportsExtension(SFTP_EXT_CHECK_FILE); + case fcRemoteCopy: + return SupportsExtension(SFTP_EXT_COPY_FILE); + default: - assert(false); + FAIL; return false; } } @@ -2511,7 +2514,7 @@ UnicodeString __fastcall TSFTPFileSystem::LocalCanonify(const UnicodeString & Pa { // TODO: improve (handle .. etc.) if (UnixIsAbsolutePath(Path) || - (!FCurrentDirectory.IsEmpty() && UnixComparePaths(FCurrentDirectory, Path))) + (!FCurrentDirectory.IsEmpty() && UnixSamePath(FCurrentDirectory, Path))) { return Path; } @@ -3094,6 +3097,7 @@ void __fastcall TSFTPFileSystem::ReadDirectory(TRemoteFileList * FileList) unsigned int Count = ListingPacket.GetCardinal(); + int ResolvedLinks = 0; for (unsigned long Index = 0; !isEOF && (Index < Count); Index++) { File = LoadFile(&ListingPacket, NULL, L"", FileList); @@ -3101,15 +3105,19 @@ void __fastcall TSFTPFileSystem::ReadDirectory(TRemoteFileList * FileList) { FTerminal->LogEvent(FORMAT(L"Read file '%s' from listing", (File->FileName))); } + if (File->LinkedFile != NULL) + { + ResolvedLinks++; + } FileList->AddFile(File); Total++; if (Total % 10 == 0) { - FTerminal->DoReadDirectoryProgress(Total, isEOF); + FTerminal->DoReadDirectoryProgress(Total, ResolvedLinks, isEOF); if (isEOF) { - FTerminal->DoReadDirectoryProgress(-2, isEOF); + FTerminal->DoReadDirectoryProgress(-2, 0, isEOF); } } } @@ -3375,10 +3383,17 @@ void __fastcall TSFTPFileSystem::RenameFile(const UnicodeString FileName, SendPacketAndReceiveResponse(&Packet, &Packet, SSH_FXP_STATUS); } //--------------------------------------------------------------------------- -void __fastcall TSFTPFileSystem::CopyFile(const UnicodeString /*FileName*/, - const UnicodeString /*NewName*/) +void __fastcall TSFTPFileSystem::CopyFile(const UnicodeString FileName, + const UnicodeString NewName) { - assert(false); + // Implemented by ProFTPD/mod_sftp + assert(SupportsExtension(SFTP_EXT_COPY_FILE)); + TSFTPPacket Packet(SSH_FXP_EXTENDED); + Packet.AddString(SFTP_EXT_COPY_FILE); + Packet.AddPathString(Canonify(FileName), FUtfStrings); + Packet.AddPathString(Canonify(NewName), FUtfStrings); + Packet.AddByte(0); + SendPacketAndReceiveResponse(&Packet, &Packet, SSH_FXP_STATUS); } //--------------------------------------------------------------------------- void __fastcall TSFTPFileSystem::CreateDirectory(const UnicodeString DirName) @@ -3398,8 +3413,10 @@ void __fastcall TSFTPFileSystem::CreateLink(const UnicodeString FileName, assert(FVersion >= 3); // symlinks are supported with SFTP version 3 and later TSFTPPacket Packet(SSH_FXP_SYMLINK); - bool Buggy = (FTerminal->SessionData->SFTPBug[sbSymlink] == asOn) || - ((FTerminal->SessionData->SFTPBug[sbSymlink] == asAuto) && FSecureShell->IsOpenSSH()); + bool Buggy = + (FTerminal->SessionData->SFTPBug[sbSymlink] == asOn) || + ((FTerminal->SessionData->SFTPBug[sbSymlink] == asAuto) && + (FSecureShell->IsOpenSSH() || FSecureShell->IsProFTPD())); if (!Buggy) { @@ -3674,18 +3691,13 @@ void __fastcall TSFTPFileSystem::CustomCommandOnFile(const UnicodeString /*FileN const TRemoteFile * /*File*/, UnicodeString /*Command*/, int /*Params*/, TCaptureOutputEvent /*OutputEvent*/) { - assert(false); + FAIL; } //--------------------------------------------------------------------------- void __fastcall TSFTPFileSystem::AnyCommand(const UnicodeString /*Command*/, TCaptureOutputEvent /*OutputEvent*/) { - assert(false); -} -//--------------------------------------------------------------------------- -UnicodeString __fastcall TSFTPFileSystem::FileUrl(const UnicodeString FileName) -{ - return FTerminal->FileUrl(SftpProtocol, FileName); + FAIL; } //--------------------------------------------------------------------------- TStrings * __fastcall TSFTPFileSystem::GetFixedPaths() @@ -3708,7 +3720,16 @@ void __fastcall TSFTPFileSystem::SpaceAvailable(const UnicodeString Path, ASpaceAvailable.UnusedBytesOnDevice = Packet.GetInt64(); ASpaceAvailable.BytesAvailableToUser = Packet.GetInt64(); ASpaceAvailable.UnusedBytesAvailableToUser = Packet.GetInt64(); - ASpaceAvailable.BytesPerAllocationUnit = Packet.GetCardinal(); + if (Packet.RemainingLength == 2) + { + // See http://bugs.proftpd.org/show_bug.cgi?id=4079 + FTerminal->LogEvent(L"Assuming ProFTPD/mod_sftp bug of 2-byte bytes-per-allocation-unit field"); + ASpaceAvailable.BytesPerAllocationUnit = Packet.GetSmallCardinal(); + } + else + { + ASpaceAvailable.BytesPerAllocationUnit = Packet.GetCardinal(); + } } else if (ALWAYS_TRUE(FSupportsStatVfsV2)) { @@ -3799,7 +3820,7 @@ void __fastcall TSFTPFileSystem::CopyToRemote(TStrings * FilesToCopy, { FTerminal->DirectoryModified(TargetDir, false); - if (DirectoryExists(FileName)) + if (DirectoryExists(ApiPath(FileName))) { FTerminal->DirectoryModified(UnixIncludeTrailingBackslash(TargetDir)+ FileNameOnly, true); @@ -3811,12 +3832,11 @@ void __fastcall TSFTPFileSystem::CopyToRemote(TStrings * FilesToCopy, } catch(EScpSkipFile & E) { - SUSPEND_OPERATION ( - if (!FTerminal->HandleException(&E)) - { - throw; - } - ); + TSuspendFileOperationProgress Suspend(OperationProgress); + if (!FTerminal->HandleException(&E)) + { + throw; + } } } __finally @@ -3828,14 +3848,15 @@ void __fastcall TSFTPFileSystem::CopyToRemote(TStrings * FilesToCopy, } } //--------------------------------------------------------------------------- -void __fastcall TSFTPFileSystem::SFTPConfirmOverwrite(UnicodeString & FileName, +void __fastcall TSFTPFileSystem::SFTPConfirmOverwrite(const UnicodeString & FullFileName, UnicodeString & FileName, const TCopyParamType * CopyParam, int Params, TFileOperationProgressType * OperationProgress, TSFTPOverwriteMode & OverwriteMode, const TOverwriteFileParams * FileParams) { bool CanAppend = (FVersion < 4) || !OperationProgress->AsciiTransfer; unsigned int Answer; - SUSPEND_OPERATION - ( + + { + TSuspendFileOperationProgress Suspend(OperationProgress); int Answers = qaYes | qaNo | qaCancel | qaYesToAll | qaNoToAll | qaAll | qaIgnore; // possibly we can allow alternate resume at least in some cases @@ -3866,11 +3887,11 @@ void __fastcall TSFTPFileSystem::SFTPConfirmOverwrite(UnicodeString & FileName, QueryParams.NoBatchAnswers = qaIgnore | qaRetry | qaAll; QueryParams.Aliases = Aliases; QueryParams.AliasesCount = LENOF(Aliases); - Answer = FTerminal->ConfirmFileOverwrite(FileName, FileParams, + Answer = FTerminal->ConfirmFileOverwrite(FullFileName, FileParams, Answers, &QueryParams, OperationProgress->Side == osLocal ? osRemote : osLocal, CopyParam, Params, OperationProgress); - ); + } if (CanAppend && ((Answer == qaRetry) || (Answer == qaSkip))) @@ -3879,7 +3900,7 @@ void __fastcall TSFTPFileSystem::SFTPConfirmOverwrite(UnicodeString & FileName, bool CanAlternateResume = (FileParams->DestSize < FileParams->SourceSize) && !OperationProgress->AsciiTransfer; TBatchOverwrite BatchOverwrite = - FTerminal->EffectiveBatchOverwrite(CopyParam, Params, OperationProgress, true); + FTerminal->EffectiveBatchOverwrite(FileName, CopyParam, Params, OperationProgress, true); // when mode is forced by batch, never query user if (BatchOverwrite == boAppend) { @@ -3898,11 +3919,12 @@ void __fastcall TSFTPFileSystem::SFTPConfirmOverwrite(UnicodeString & FileName, else { TQueryParams Params(0, HELP_APPEND_OR_RESUME); - SUSPEND_OPERATION - ( + + { + TSuspendFileOperationProgress Suspend(OperationProgress); Answer = FTerminal->QueryUser(FORMAT(LoadStr(APPEND_OR_RESUME2), (FileName)), NULL, qaYes | qaNo | qaNoToAll | qaCancel, &Params); - ); + } switch (Answer) { @@ -3919,7 +3941,7 @@ void __fastcall TSFTPFileSystem::SFTPConfirmOverwrite(UnicodeString & FileName, OperationProgress->BatchOverwrite = boAlternateResume; break; - default: assert(false); //fallthru + default: FAIL; //fallthru case qaCancel: if (!OperationProgress->Cancel) { @@ -3973,13 +3995,13 @@ bool TSFTPFileSystem::SFTPConfirmResume(const UnicodeString DestFileName, if (PartialBiggerThanSource) { unsigned int Answer; - SUSPEND_OPERATION - ( + { + TSuspendFileOperationProgress Suspend(OperationProgress); TQueryParams Params(qpAllowContinueOnError, HELP_PARTIAL_BIGGER_THAN_SOURCE); Answer = FTerminal->QueryUser( FMTLOAD(PARTIAL_BIGGER_THAN_SOURCE, (DestFileName)), NULL, qaOK | qaAbort, &Params, qtWarning); - ) + } if (Answer == qaAbort) { @@ -3994,15 +4016,16 @@ bool TSFTPFileSystem::SFTPConfirmResume(const UnicodeString DestFileName, else if (FTerminal->Configuration->ConfirmResume) { unsigned int Answer; - SUSPEND_OPERATION - ( + + { + TSuspendFileOperationProgress Suspend(OperationProgress); TQueryParams Params(qpAllowContinueOnError | qpNeverAskAgainCheck, HELP_RESUME_TRANSFER); // "abort" replaced with "cancel" to unify with "append/resume" query Answer = FTerminal->QueryUser( FMTLOAD(RESUME_TRANSFER2, (DestFileName)), NULL, qaYes | qaNo | qaCancel, &Params); - ); + } switch (Answer) { case qaNeverAskAgain: @@ -4086,9 +4109,8 @@ void __fastcall TSFTPFileSystem::SFTPSource(const UnicodeString FileName, OperationProgress->SetFile(FileName, false); - if (!FTerminal->AllowLocalFileTransfer(FileName, CopyParam)) + if (!FTerminal->AllowLocalFileTransfer(FileName, CopyParam, OperationProgress)) { - FTerminal->LogEvent(FORMAT(L"File \"%s\" excluded from transfer", (FileName))); THROW_SKIP_FILE_NULL; } @@ -4207,7 +4229,8 @@ void __fastcall TSFTPFileSystem::SFTPSource(const UnicodeString FileName, bool PartialBiggerThanSource = (ResumeOffset > OperationProgress->LocalSize); if (FLAGCLEAR(Params, cpNoConfirmation) && - FLAGCLEAR(Params, cpResume)) + FLAGCLEAR(Params, cpResume) && + !CopyParam->ResumeTransfer(FileName)) { ResumeTransfer = SFTPConfirmResume(DestFileName, PartialBiggerThanSource, OperationProgress); @@ -4232,7 +4255,7 @@ void __fastcall TSFTPFileSystem::SFTPSource(const UnicodeString FileName, if (DestFileExists) { UnicodeString PrevDestFileName = DestFileName; - SFTPConfirmOverwrite(DestFileName, + SFTPConfirmOverwrite(FileName, DestFileName, CopyParam, Params, OperationProgress, OpenParams.OverwriteMode, &FileParams); if (PrevDestFileName != DestFileName) { @@ -4252,6 +4275,7 @@ void __fastcall TSFTPFileSystem::SFTPSource(const UnicodeString FileName, bool DoResume = (ResumeAllowed && (OpenParams.OverwriteMode == omOverwrite)); UnicodeString RemoteFileName = DoResume ? DestPartialFullName : DestFullName; + OpenParams.FileName = FileName; OpenParams.RemoteFileName = RemoteFileName; OpenParams.Resume = DoResume; OpenParams.Resuming = ResumeTransfer; @@ -4396,9 +4420,8 @@ void __fastcall TSFTPFileSystem::SFTPSource(const UnicodeString FileName, { if (DestFileExists) { - FILE_OPERATION_LOOP(FMTLOAD(DELETE_ON_RESUME_ERROR, - (UnixExtractFileName(DestFullName), DestFullName)), - + FILE_OPERATION_LOOP_BEGIN + { if (FTerminal->SessionData->OverwrittenToRecycleBin && !FTerminal->SessionData->RecycleBinPath.IsEmpty()) { @@ -4408,17 +4431,22 @@ void __fastcall TSFTPFileSystem::SFTPSource(const UnicodeString FileName, { DoDeleteFile(DestFullName, SSH_FXP_REMOVE); } - ); + } + FILE_OPERATION_LOOP_END( + FMTLOAD(DELETE_ON_RESUME_ERROR, + (UnixExtractFileName(DestFullName), DestFullName))); } // originally this was before CLOSE (last __finally statement), // on VShell it failed - FILE_OPERATION_LOOP_CUSTOM(FTerminal, true, + FILE_OPERATION_LOOP_BEGIN + { + RenameFile(OpenParams.RemoteFileName, DestFileName); + } + FILE_OPERATION_LOOP_END_CUSTOM( FMTLOAD(RENAME_AFTER_RESUME_ERROR, (UnixExtractFileName(OpenParams.RemoteFileName), DestFileName)), - RenameFile(OpenParams.RemoteFileName, DestFileName), - HELP_RENAME_AFTER_RESUME_ERROR - ); + true, HELP_RENAME_AFTER_RESUME_ERROR); } if (SetProperties) @@ -4448,7 +4476,8 @@ void __fastcall TSFTPFileSystem::SFTPSource(const UnicodeString FileName, SendPacket(&PropertiesRequest); } bool Resend = false; - FILE_OPERATION_LOOP_CUSTOM(FTerminal, true, FMTLOAD(PRESERVE_TIME_PERM_ERROR3, (DestFileName)), + FILE_OPERATION_LOOP_BEGIN + { try { TSFTPPacket DummyResponse; @@ -4478,9 +4507,10 @@ void __fastcall TSFTPFileSystem::SFTPSource(const UnicodeString FileName, throw; } } - , - HELP_PRESERVE_TIME_PERM_ERROR - ); + } + FILE_OPERATION_LOOP_END_CUSTOM( + FMTLOAD(PRESERVE_TIME_PERM_ERROR3, (DestFileName)), + true, HELP_PRESERVE_TIME_PERM_ERROR); } catch(Exception & E) { @@ -4511,16 +4541,20 @@ void __fastcall TSFTPFileSystem::SFTPSource(const UnicodeString FileName, { if (!Dir) { - FILE_OPERATION_LOOP (FMTLOAD(DELETE_LOCAL_FILE_ERROR, (FileName)), - THROWOSIFFALSE(Sysutils::DeleteFile(FileName)); - ) + FILE_OPERATION_LOOP_BEGIN + { + THROWOSIFFALSE(Sysutils::DeleteFile(ApiPath(FileName))); + } + FILE_OPERATION_LOOP_END(FMTLOAD(DELETE_LOCAL_FILE_ERROR, (FileName))); } } else if (CopyParam->ClearArchive && FLAGSET(OpenParams.LocalFileAttrs, faArchive)) { - FILE_OPERATION_LOOP (FMTLOAD(CANT_SET_ATTRS, (FileName)), - THROWOSIFFALSE(FileSetAttr(FileName, OpenParams.LocalFileAttrs & ~faArchive) == 0); - ) + FILE_OPERATION_LOOP_BEGIN + { + THROWOSIFFALSE(FileSetAttr(ApiPath(FileName), OpenParams.LocalFileAttrs & ~faArchive) == 0); + } + FILE_OPERATION_LOOP_END(FMTLOAD(CANT_SET_ATTRS, (FileName))); } } //--------------------------------------------------------------------------- @@ -4594,7 +4628,7 @@ int __fastcall TSFTPFileSystem::SFTPOpenRemote(void * AOpenParams, void * /*Para { ConfirmOverwriting = !OpenParams->Confirmed && !OpenParams->Resume && - FTerminal->CheckRemoteFile(OpenParams->CopyParam, OpenParams->Params, OperationProgress); + FTerminal->CheckRemoteFile(OpenParams->FileName, OpenParams->CopyParam, OpenParams->Params, OperationProgress); OpenType = SSH_FXF_WRITE | SSH_FXF_CREAT; // when we want to preserve overwritten files, we need to find out that // they exist first... even if overwrite confirmation is disabled. @@ -4667,7 +4701,7 @@ int __fastcall TSFTPFileSystem::SFTPOpenRemote(void * AOpenParams, void * /*Para { // confirmation duplicated in SFTPSource for resumable file transfers. UnicodeString RemoteFileNameOnly = UnixExtractFileName(OpenParams->RemoteFileName); - SFTPConfirmOverwrite(RemoteFileNameOnly, + SFTPConfirmOverwrite(OpenParams->FileName, RemoteFileNameOnly, OpenParams->CopyParam, OpenParams->Params, OperationProgress, OpenParams->OverwriteMode, OpenParams->FileParams); if (RemoteFileNameOnly != UnixExtractFileName(OpenParams->RemoteFileName)) { @@ -4749,7 +4783,8 @@ void __fastcall TSFTPFileSystem::SFTPCloseRemote(const RawByteString Handle, bool TransferFinished, bool Request, TSFTPPacket * Packet) { // Moving this out of SFTPSource() fixed external exception 0xC0000029 error - FILE_OPERATION_LOOP(FMTLOAD(SFTP_CLOSE_FILE_ERROR, (FileName)), + FILE_OPERATION_LOOP_BEGIN + { try { TSFTPPacket CloseRequest; @@ -4775,7 +4810,8 @@ void __fastcall TSFTPFileSystem::SFTPCloseRemote(const RawByteString Handle, throw; } } - ); + } + FILE_OPERATION_LOOP_END(FMTLOAD(SFTP_CLOSE_FILE_ERROR, (FileName))); } //--------------------------------------------------------------------------- void __fastcall TSFTPFileSystem::SFTPDirectorySource(const UnicodeString DirectoryName, @@ -4824,10 +4860,12 @@ void __fastcall TSFTPFileSystem::SFTPDirectorySource(const UnicodeString Directo TSearchRecChecked SearchRec; bool FindOK; - FILE_OPERATION_LOOP (FMTLOAD(LIST_DIR_ERROR, (DirectoryName)), - FindOK = (bool)(FindFirstChecked(DirectoryName + L"*.*", - FindAttrs, SearchRec) == 0); - ); + FILE_OPERATION_LOOP_BEGIN + { + FindOK = + (FindFirstChecked(DirectoryName + L"*.*", FindAttrs, SearchRec) == 0); + } + FILE_OPERATION_LOOP_END(FMTLOAD(LIST_DIR_ERROR, (DirectoryName))); try { @@ -4845,17 +4883,21 @@ void __fastcall TSFTPFileSystem::SFTPDirectorySource(const UnicodeString Directo catch (EScpSkipFile &E) { // If ESkipFile occurs, just log it and continue with next file - SUSPEND_OPERATION ( - // here a message to user was displayed, which was not appropriate - // when user refused to overwrite the file in subdirectory. - // hopefully it won't be missing in other situations. - if (!FTerminal->HandleException(&E)) throw; - ); + TSuspendFileOperationProgress Suspend(OperationProgress); + // here a message to user was displayed, which was not appropriate + // when user refused to overwrite the file in subdirectory. + // hopefully it won't be missing in other situations. + if (!FTerminal->HandleException(&E)) + { + throw; + } } - FILE_OPERATION_LOOP (FMTLOAD(LIST_DIR_ERROR, (DirectoryName)), + FILE_OPERATION_LOOP_BEGIN + { FindOK = (FindNextChecked(SearchRec) == 0); - ); + } + FILE_OPERATION_LOOP_END(FMTLOAD(LIST_DIR_ERROR, (DirectoryName))); }; } __finally @@ -4869,13 +4911,15 @@ void __fastcall TSFTPFileSystem::SFTPDirectorySource(const UnicodeString Directo { if (FLAGSET(Params, cpDelete)) { - RemoveDir(DirectoryName); + RemoveDir(ApiPath(DirectoryName)); } else if (CopyParam->ClearArchive && FLAGSET(Attrs, faArchive)) { - FILE_OPERATION_LOOP (FMTLOAD(CANT_SET_ATTRS, (DirectoryName)), - THROWOSIFFALSE(FileSetAttr(DirectoryName, Attrs & ~faArchive) == 0); - ) + FILE_OPERATION_LOOP_BEGIN + { + THROWOSIFFALSE(FileSetAttr(ApiPath(DirectoryName), Attrs & ~faArchive) == 0); + } + FILE_OPERATION_LOOP_END(FMTLOAD(CANT_SET_ATTRS, (DirectoryName))); } } } @@ -4911,9 +4955,11 @@ void __fastcall TSFTPFileSystem::CopyToLocal(TStrings * FilesToCopy, } catch(EScpSkipFile & E) { - SUSPEND_OPERATION ( - if (!FTerminal->HandleException(&E)) throw; - ); + TSuspendFileOperationProgress Suspend(OperationProgress); + if (!FTerminal->HandleException(&E)) + { + throw; + } } catch(...) { @@ -5000,9 +5046,15 @@ void __fastcall TSFTPFileSystem::SFTPSink(const UnicodeString FileName, THROW_SKIP_FILE_NULL; } + if (CopyParam->SkipTransfer(FileName, File->IsDirectory)) + { + OperationProgress->AddSkippedFileSize(File->Size); + THROW_SKIP_FILE_NULL; + } + FTerminal->LogFileDetails(FileName, File->Modification, File->Size); - OperationProgress->SetFile(OnlyFileName); + OperationProgress->SetFile(FileName); UnicodeString DestFileName = CopyParam->ChangeFileName(OnlyFileName, osRemote, FLAGSET(Flags, tfFirstLevel)); @@ -5013,14 +5065,18 @@ void __fastcall TSFTPFileSystem::SFTPSink(const UnicodeString FileName, Action.Cancel(); if (!File->IsSymLink) { - FILE_OPERATION_LOOP (FMTLOAD(NOT_DIRECTORY_ERROR, (DestFullName)), - int Attrs = FileGetAttr(DestFullName); + FILE_OPERATION_LOOP_BEGIN + { + int Attrs = FileGetAttr(ApiPath(DestFullName)); if ((Attrs & faDirectory) == 0) EXCEPTION; - ); + } + FILE_OPERATION_LOOP_END(FMTLOAD(NOT_DIRECTORY_ERROR, (DestFullName))); - FILE_OPERATION_LOOP (FMTLOAD(CREATE_DIR_ERROR, (DestFullName)), - THROWOSIFFALSE(ForceDirectories(DestFullName)); - ); + FILE_OPERATION_LOOP_BEGIN + { + THROWOSIFFALSE(ForceDirectories(ApiPath(DestFullName))); + } + FILE_OPERATION_LOOP_END(FMTLOAD(CREATE_DIR_ERROR, (DestFullName))); TSinkFileParams SinkFileParams; SinkFileParams.TargetDir = IncludeTrailingBackslash(DestFullName); @@ -5073,10 +5129,12 @@ void __fastcall TSFTPFileSystem::SFTPSink(const UnicodeString FileName, OperationProgress->SetResumeStatus(ResumeAllowed ? rsEnabled : rsDisabled); int Attrs; - FILE_OPERATION_LOOP (FMTLOAD(NOT_FILE_ERROR, (DestFullName)), - Attrs = FileGetAttr(DestFullName); + FILE_OPERATION_LOOP_BEGIN + { + Attrs = FileGetAttr(ApiPath(DestFullName)); if ((Attrs >= 0) && (Attrs & faDirectory)) EXCEPTION; - ); + } + FILE_OPERATION_LOOP_END(FMTLOAD(NOT_FILE_ERROR, (DestFullName))); OperationProgress->TransferingFile = false; // not set with SFTP protocol @@ -5095,7 +5153,7 @@ void __fastcall TSFTPFileSystem::SFTPSink(const UnicodeString FileName, LocalFileName = DestPartialFullName; FTerminal->LogEvent(L"Checking existence of partially transfered file."); - if (FileExists(DestPartialFullName)) + if (FileExists(ApiPath(DestPartialFullName))) { FTerminal->LogEvent(L"Partially transfered file exists."); FTerminal->OpenLocalFile(DestPartialFullName, GENERIC_WRITE, @@ -5120,9 +5178,11 @@ void __fastcall TSFTPFileSystem::SFTPSink(const UnicodeString FileName, { CloseHandle(LocalHandle); LocalHandle = NULL; - FILE_OPERATION_LOOP (FMTLOAD(DELETE_LOCAL_FILE_ERROR, (DestPartialFullName)), - THROWOSIFFALSE(Sysutils::DeleteFile(DestPartialFullName)); - ) + FILE_OPERATION_LOOP_BEGIN + { + THROWOSIFFALSE(Sysutils::DeleteFile(ApiPath(DestPartialFullName))); + } + FILE_OPERATION_LOOP_END(FMTLOAD(DELETE_LOCAL_FILE_ERROR, (DestPartialFullName))); } else { @@ -5136,14 +5196,16 @@ void __fastcall TSFTPFileSystem::SFTPSink(const UnicodeString FileName, // first open source file, not to loose the destination file, // if we cannot open the source one in the first place FTerminal->LogEvent(L"Opening remote file."); - FILE_OPERATION_LOOP (FMTLOAD(SFTP_OPEN_FILE_ERROR, (FileName)), + FILE_OPERATION_LOOP_BEGIN + { int OpenType = SSH_FXF_READ; if ((FVersion >= 4) && OperationProgress->AsciiTransfer) { OpenType |= SSH_FXF_TEXT; } RemoteHandle = SFTPOpenRemoteFile(FileName, OpenType); - ); + } + FILE_OPERATION_LOOP_END(FMTLOAD(SFTP_OPEN_FILE_ERROR, (FileName))); TDateTime Modification; FILETIME AcTime; @@ -5169,7 +5231,7 @@ void __fastcall TSFTPFileSystem::SFTPSink(const UnicodeString FileName, Modification = AFile->Modification; AcTime = DateTimeToFileTime(AFile->LastAccess, FTerminal->SessionData->DSTMode); - WrTime = DateTimeToFileTime(AFile->Modification, + WrTime = DateTimeToFileTime(Modification, FTerminal->SessionData->DSTMode); } __finally @@ -5195,18 +5257,20 @@ void __fastcall TSFTPFileSystem::SFTPSink(const UnicodeString FileName, FTerminal->SessionData->DSTMode); FileParams.DestSize = DestFileSize; UnicodeString PrevDestFileName = DestFileName; - SFTPConfirmOverwrite(DestFileName, CopyParam, Params, OperationProgress, OverwriteMode, &FileParams); + SFTPConfirmOverwrite(FileName, DestFileName, CopyParam, Params, OperationProgress, OverwriteMode, &FileParams); if (PrevDestFileName != DestFileName) { DestFullName = TargetDir + DestFileName; DestPartialFullName = DestFullName + FTerminal->Configuration->PartialExt; if (ResumeAllowed) { - if (FileExists(DestPartialFullName)) + if (FileExists(ApiPath(DestPartialFullName))) { - FILE_OPERATION_LOOP (FMTLOAD(DELETE_LOCAL_FILE_ERROR, (DestPartialFullName)), - THROWOSIFFALSE(Sysutils::DeleteFile(DestPartialFullName)); - ) + FILE_OPERATION_LOOP_BEGIN + { + THROWOSIFFALSE(Sysutils::DeleteFile(ApiPath(DestPartialFullName))); + } + FILE_OPERATION_LOOP_END(FMTLOAD(DELETE_LOCAL_FILE_ERROR, (DestPartialFullName))); } LocalFileName = DestPartialFullName; } @@ -5382,9 +5446,11 @@ void __fastcall TSFTPFileSystem::SFTPSink(const UnicodeString FileName, OperationProgress->LocalSize - PrevBlockSize + BlockBuf.Size); } - FILE_OPERATION_LOOP (FMTLOAD(WRITE_ERROR, (LocalFileName)), + FILE_OPERATION_LOOP_BEGIN + { BlockBuf.WriteToStream(FileStream, BlockBuf.Size); - ); + } + FILE_OPERATION_LOOP_END(FMTLOAD(WRITE_ERROR, (LocalFileName))); OperationProgress->AddLocallyUsed(BlockBuf.Size); } @@ -5421,15 +5487,17 @@ void __fastcall TSFTPFileSystem::SFTPSink(const UnicodeString FileName, if (ResumeAllowed) { - FILE_OPERATION_LOOP(FMTLOAD(RENAME_AFTER_RESUME_ERROR, - (ExtractFileName(DestPartialFullName), DestFileName)), - - if (FileExists(DestFullName)) + FILE_OPERATION_LOOP_BEGIN + { + if (FileExists(ApiPath(DestFullName))) { DeleteFileChecked(DestFullName); } THROWOSIFFALSE(Sysutils::RenameFile(DestPartialFullName, DestFullName)); - ); + } + FILE_OPERATION_LOOP_END( + FMTLOAD(RENAME_AFTER_RESUME_ERROR, + (ExtractFileName(DestPartialFullName), DestFileName))); } DeleteLocalFile = false; @@ -5441,9 +5509,11 @@ void __fastcall TSFTPFileSystem::SFTPSink(const UnicodeString FileName, int NewAttrs = CopyParam->LocalFileAttrs(*File->Rights); if ((NewAttrs & Attrs) != NewAttrs) { - FILE_OPERATION_LOOP (FMTLOAD(CANT_SET_ATTRS, (DestFullName)), - THROWOSIFFALSE(FileSetAttr(DestFullName, Attrs | NewAttrs) == 0); - ); + FILE_OPERATION_LOOP_BEGIN + { + THROWOSIFFALSE(FileSetAttr(ApiPath(DestFullName), Attrs | NewAttrs) == 0); + } + FILE_OPERATION_LOOP_END(FMTLOAD(CANT_SET_ATTRS, (DestFullName))); } } @@ -5454,9 +5524,11 @@ void __fastcall TSFTPFileSystem::SFTPSink(const UnicodeString FileName, if (DeleteLocalFile && (!ResumeAllowed || OperationProgress->LocallyUsed == 0) && (OverwriteMode == omOverwrite)) { - FILE_OPERATION_LOOP (FMTLOAD(DELETE_LOCAL_FILE_ERROR, (LocalFileName)), - THROWOSIFFALSE(Sysutils::DeleteFile(LocalFileName)); - ) + FILE_OPERATION_LOOP_BEGIN + { + THROWOSIFFALSE(Sysutils::DeleteFile(ApiPath(LocalFileName))); + } + FILE_OPERATION_LOOP_END(FMTLOAD(DELETE_LOCAL_FILE_ERROR, (LocalFileName))); } // if the transfer was finished, the file is closed already @@ -5497,9 +5569,13 @@ void __fastcall TSFTPFileSystem::SFTPSinkFile(UnicodeString FileName, Params->Skipped = true; - SUSPEND_OPERATION ( - if (!FTerminal->HandleException(&E)) throw; - ); + { + TSuspendFileOperationProgress Suspend(OperationProgress); + if (!FTerminal->HandleException(&E)) + { + throw; + } + } if (OperationProgress->Cancel) { diff --git a/source/core/SftpFileSystem.h b/source/core/SftpFileSystem.h index 21fb8dc6..acf87b07 100644 --- a/source/core/SftpFileSystem.h +++ b/source/core/SftpFileSystem.h @@ -71,7 +71,6 @@ friend class TSFTPBusy; const UnicodeString NewName); virtual void __fastcall CopyFile(const UnicodeString FileName, const UnicodeString NewName); - virtual UnicodeString __fastcall FileUrl(const UnicodeString FileName); virtual TStrings * __fastcall GetFixedPaths(); virtual void __fastcall SpaceAvailable(const UnicodeString Path, TSpaceAvailable & ASpaceAvailable); @@ -160,7 +159,7 @@ friend class TSFTPBusy; void __fastcall SFTPDirectorySource(const UnicodeString DirectoryName, const UnicodeString TargetDir, int Attrs, const TCopyParamType * CopyParam, int Params, TFileOperationProgressType * OperationProgress, unsigned int Flags); - void __fastcall SFTPConfirmOverwrite(UnicodeString & FileName, + void __fastcall SFTPConfirmOverwrite(const UnicodeString & FullFileName, UnicodeString & FileName, const TCopyParamType * CopyParam, int Params, TFileOperationProgressType * OperationProgress, TSFTPOverwriteMode & Mode, const TOverwriteFileParams * FileParams); bool SFTPConfirmResume(const UnicodeString DestFileName, bool PartialBiggerThanSource, diff --git a/source/core/Terminal.cpp b/source/core/Terminal.cpp index 6dd36fbf..4f16c7b3 100644 --- a/source/core/Terminal.cpp +++ b/source/core/Terminal.cpp @@ -56,12 +56,11 @@ case qaRetry: ACTION.Cancel(); { REPEAT; } break; \ case qaAbort: RollbackAction(ACTION, NULL, &E); Abort(); \ case qaSkip: ACTION.Cancel(); break; \ - default: assert(false); \ + default: FAIL; \ } \ } -#define FILE_OPERATION_LOOP_EX(ALLOW_SKIP, MESSAGE, OPERATION) \ - FILE_OPERATION_LOOP_CUSTOM(this, ALLOW_SKIP, MESSAGE, OPERATION, L"") +#define FILE_OPERATION_LOOP_TERMINAL this //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- class TLoopDetector @@ -72,7 +71,7 @@ class TLoopDetector bool __fastcall IsUnvisitedDirectory(const TRemoteFile * File); private: - std::auto_ptr FVisitedDirectories; + std::unique_ptr FVisitedDirectories; }; //--------------------------------------------------------------------------- __fastcall TLoopDetector::TLoopDetector() @@ -991,7 +990,7 @@ void __fastcall TTerminal::Closed() { if (FTunnel != NULL) { - CloseTunnel(); + CloseTunnel(); } if (OnClose) @@ -1107,8 +1106,8 @@ bool __fastcall TTerminal::DoPromptUser(TSessionData * /*Data*/, TPromptKind Kin bool AResult = false; - bool PasswordPrompt = IsPasswordPrompt(Kind, Prompts); - if (PasswordPrompt) + bool PasswordOrPassphrasePrompt = IsPasswordOrPassphrasePrompt(Kind, Prompts); + if (PasswordOrPassphrasePrompt) { bool & PasswordTried = FTunnelOpening ? FRememberedTunnelPasswordTried : FRememberedPasswordTried; @@ -1138,7 +1137,7 @@ bool __fastcall TTerminal::DoPromptUser(TSessionData * /*Data*/, TPromptKind Kin if (!AResult) { - if (PasswordPrompt && !Configuration->RememberPassword) + if (PasswordOrPassphrasePrompt && !Configuration->RememberPassword) { Prompts->Objects[0] = (TObject*)(int(Prompts->Objects[0]) | pupRemember); } @@ -1150,7 +1149,7 @@ bool __fastcall TTerminal::DoPromptUser(TSessionData * /*Data*/, TPromptKind Kin Guard.Verify(); } - if (AResult && PasswordPrompt && + if (AResult && PasswordOrPassphrasePrompt && (Configuration->RememberPassword || FLAGSET(int(Prompts->Objects[0]), pupRemember))) { RawByteString EncryptedPassword = EncryptPassword(Results->Strings[0]); @@ -1205,6 +1204,11 @@ unsigned int __fastcall TTerminal::QueryUserException(const UnicodeString Query, MoreMessages->AddStrings(EE->MoreMessages); } + // We know MoreMessages not to be NULL here, + // AppendExceptionStackTrace should never return true + // (indicating it had to create the string list) + ALWAYS_FALSE(AppendExceptionStackTrace(MoreMessages)); + TQueryParams HelpKeywordOverrideParams; if (Params != NULL) { @@ -1285,13 +1289,12 @@ void __fastcall TTerminal::Information(const UnicodeString & Str, bool Status) DoInformation(Str, Status); } //--------------------------------------------------------------------------- -void __fastcall TTerminal::DoProgress(TFileOperationProgressType & ProgressData, - TCancelStatus & Cancel) +void __fastcall TTerminal::DoProgress(TFileOperationProgressType & ProgressData) { if (OnProgress != NULL) { TCallbackGuard Guard(this); - OnProgress(ProgressData, Cancel); + OnProgress(ProgressData); Guard.Verify(); } } @@ -1307,6 +1310,14 @@ void __fastcall TTerminal::DoFinished(TFileOperation Operation, TOperationSide S } } //--------------------------------------------------------------------------- +void __fastcall TTerminal::SaveCapabilities(TFileSystemInfo & FileSystemInfo) +{ + for (int Index = 0; Index < fcCount; Index++) + { + FileSystemInfo.IsCapable[Index] = IsCapable[(TFSCapability)Index]; + } +} +//--------------------------------------------------------------------------- bool __fastcall TTerminal::GetIsCapable(TFSCapability Capability) const { assert(FFileSystem); @@ -1502,9 +1513,10 @@ bool __fastcall TTerminal::FileOperationLoopQuery(Exception & E, Params.AliasesCount = AliasCount; } - SUSPEND_OPERATION ( + { + TSuspendFileOperationProgress Suspend(OperationProgress); Answer = QueryUserException(Message, &E, Answers, &Params, qtError); - ); + } if (Answer == qaAll) { @@ -1546,11 +1558,11 @@ int __fastcall TTerminal::FileOperationLoop(TFileOperationEvent CallBackFunc, { assert(CallBackFunc); int Result; - FILE_OPERATION_LOOP_EX - ( - AllowSkip, Message, + FILE_OPERATION_LOOP_BEGIN + { Result = CallBackFunc(Param1, Param2); - ); + } + FILE_OPERATION_LOOP_END_EX(Message, AllowSkip); return Result; } @@ -1603,7 +1615,7 @@ bool __fastcall TTerminal::DirectoryFileList(const UnicodeString Path, TRemoteFileList *& FileList, bool CanLoad) { bool Result = false; - if (UnixComparePaths(FFiles->Directory, Path)) + if (UnixSamePath(FFiles->Directory, Path)) { Result = (FileList == NULL) || (FileList->Timestamp < FFiles->Timestamp); if (Result) @@ -1783,12 +1795,12 @@ void __fastcall TTerminal::DoStartReadDirectory() } } //--------------------------------------------------------------------------- -void __fastcall TTerminal::DoReadDirectoryProgress(int Progress, bool & Cancel) +void __fastcall TTerminal::DoReadDirectoryProgress(int Progress, int ResolvedLinks, bool & Cancel) { if (FReadingCurrentDirectory && (FOnReadDirectoryProgress != NULL)) { TCallbackGuard Guard(this); - FOnReadDirectoryProgress(this, Progress, Cancel); + FOnReadDirectoryProgress(this, Progress, ResolvedLinks, Cancel); Guard.Verify(); } if (FOnFindingFile != NULL) @@ -1820,6 +1832,11 @@ void __fastcall TTerminal::BeginTransaction() } //--------------------------------------------------------------------------- void __fastcall TTerminal::EndTransaction() +{ + DoEndTransaction(false); +} +//--------------------------------------------------------------------------- +void __fastcall TTerminal::DoEndTransaction(bool Inform) { if (FInTransaction == 0) TerminalError(L"Can't end transaction, not in transaction"); @@ -1833,8 +1850,19 @@ void __fastcall TTerminal::EndTransaction() { try { - if (FReadCurrentDirectoryPending) ReadCurrentDirectory(); - if (FReadDirectoryPending) ReadDirectory(!FReadCurrentDirectoryPending); + if (FReadCurrentDirectoryPending) + { + ReadCurrentDirectory(); + } + + if (FReadDirectoryPending) + { + if (Inform) + { + DoInformation(LoadStr(STATUS_OPEN_DIRECTORY), true); + } + ReadDirectory(!FReadCurrentDirectoryPending); + } } __finally { @@ -2007,10 +2035,11 @@ void __fastcall TTerminal::CloseOnCompletion(TOnceDoneOperation Operation, const } //--------------------------------------------------------------------------- TBatchOverwrite __fastcall TTerminal::EffectiveBatchOverwrite( - const TCopyParamType * CopyParam, int Params, TFileOperationProgressType * OperationProgress, bool Special) + const UnicodeString & FileName, const TCopyParamType * CopyParam, int Params, TFileOperationProgressType * OperationProgress, bool Special) { TBatchOverwrite Result; - if (Special && FLAGSET(Params, cpResume)) + if (Special && + (FLAGSET(Params, cpResume) || CopyParam->ResumeTransfer(FileName))) { Result = boResume; } @@ -2044,9 +2073,9 @@ TBatchOverwrite __fastcall TTerminal::EffectiveBatchOverwrite( } //--------------------------------------------------------------------------- bool __fastcall TTerminal::CheckRemoteFile( - const TCopyParamType * CopyParam, int Params, TFileOperationProgressType * OperationProgress) + const UnicodeString & FileName, const TCopyParamType * CopyParam, int Params, TFileOperationProgressType * OperationProgress) { - return (EffectiveBatchOverwrite(CopyParam, Params, OperationProgress, true) != boAll); + return (EffectiveBatchOverwrite(FileName, CopyParam, Params, OperationProgress, true) != boAll); } //--------------------------------------------------------------------------- unsigned int __fastcall TTerminal::ConfirmFileOverwrite(const UnicodeString FileName, @@ -2060,7 +2089,7 @@ unsigned int __fastcall TTerminal::ConfirmFileOverwrite(const UnicodeString File (FileParams != NULL) && (FileParams->DestSize < FileParams->SourceSize) && !OperationProgress->AsciiTransfer; - TBatchOverwrite BatchOverwrite = EffectiveBatchOverwrite(CopyParam, Params, OperationProgress, true); + TBatchOverwrite BatchOverwrite = EffectiveBatchOverwrite(FileName, CopyParam, Params, OperationProgress, true); bool Applicable = true; switch (BatchOverwrite) { @@ -2079,7 +2108,7 @@ unsigned int __fastcall TTerminal::ConfirmFileOverwrite(const UnicodeString File if (!Applicable) { - TBatchOverwrite ABatchOverwrite = EffectiveBatchOverwrite(CopyParam, Params, OperationProgress, false); + TBatchOverwrite ABatchOverwrite = EffectiveBatchOverwrite(FileName, CopyParam, Params, OperationProgress, false); assert(BatchOverwrite != ABatchOverwrite); BatchOverwrite = ABatchOverwrite; } @@ -2088,8 +2117,10 @@ unsigned int __fastcall TTerminal::ConfirmFileOverwrite(const UnicodeString File { if (Message.IsEmpty()) { + // Side refers to destination side here + UnicodeString FileNameOnly = (Side == osRemote) ? ExtractFileName(FileName) : UnixExtractFileName(FileName); Message = FMTLOAD((Side == osLocal ? LOCAL_FILE_OVERWRITE2 : - REMOTE_FILE_OVERWRITE2), (FileName, FileName)); + REMOTE_FILE_OVERWRITE2), (FileNameOnly, FileNameOnly)); } if (FileParams != NULL) { @@ -2298,7 +2329,7 @@ void __fastcall TTerminal::EnsureNonExistence(const UnicodeString FileName) { // if filename doesn't contain path, we check for existence of file if ((UnixExtractFileDir(FileName).IsEmpty()) && - UnixComparePaths(CurrentDirectory, FFiles->Directory)) + UnixSamePath(CurrentDirectory, FFiles->Directory)) { TRemoteFile *File = FFiles->FindFile(FileName); if (File) @@ -2352,16 +2383,14 @@ void __fastcall TTerminal::DoStartup() LookupUsersGroups(); - DoInformation(LoadStr(STATUS_OPEN_DIRECTORY), true); if (!SessionData->RemoteDirectory.IsEmpty()) { ChangeDirectory(SessionData->RemoteDirectory); } - } __finally { - EndTransaction(); + DoEndTransaction(true); } LogEvent(L"Startup conversation with host finished."); } @@ -2445,7 +2474,7 @@ void __fastcall TTerminal::ReadDirectory(bool ReloadOnly, bool ForceCache) DoStartReadDirectory(); FReadingCurrentDirectory = true; bool Cancel = false; // dummy - DoReadDirectoryProgress(0, Cancel); + DoReadDirectoryProgress(0, 0, Cancel); try { @@ -2457,7 +2486,7 @@ void __fastcall TTerminal::ReadDirectory(bool ReloadOnly, bool ForceCache) } __finally { - DoReadDirectoryProgress(-1, Cancel); + DoReadDirectoryProgress(-1, 0, Cancel); FReadingCurrentDirectory = false; TRemoteDirectory * OldFiles = FFiles; FFiles = Files; @@ -2707,6 +2736,8 @@ void __fastcall TTerminal::ProcessDirectory(const UnicodeString DirName, if (!File->IsParentDirectory && !File->IsThisDirectory) { CallBackFunc(Directory + File->FileName, File, Param); + // We should catch EScpSkipFile here as we do in ProcessFiles. + // Now we have to handle EScpSkipFile in every callback implementation. } } } @@ -2865,9 +2896,11 @@ bool __fastcall TTerminal::ProcessFiles(TStrings * FileList, } catch(EScpSkipFile & E) { - SUSPEND_OPERATION ( - if (!HandleException(&E)) throw; - ); + TSuspendFileOperationProgress Suspend(OperationProgress); + if (!HandleException(&E)) + { + throw; + } } Index++; } @@ -2961,7 +2994,7 @@ bool __fastcall TTerminal::IsRecycledFile(UnicodeString FileName) { Path = CurrentDirectory; } - Result = UnixComparePaths(Path, SessionData->RecycleBinPath); + Result = UnixSamePath(Path, SessionData->RecycleBinPath); } return Result; } @@ -3401,7 +3434,7 @@ void __fastcall TTerminal::RenameFile(const TRemoteFile * File, // if filename doesn't contain path, we check for existence of file if ((File->FileName != NewName) && CheckExistence && Configuration->ConfirmOverwriting && - UnixComparePaths(CurrentDirectory, FFiles->Directory)) + UnixSamePath(CurrentDirectory, FFiles->Directory)) { TRemoteFile * DuplicateFile = FFiles->FindFile(NewName); if (DuplicateFile) @@ -3881,7 +3914,7 @@ bool __fastcall TTerminal::DoCreateLocalFile(const UnicodeString FileName, unsigned int CreateAttr = FILE_ATTRIBUTE_NORMAL; do { - *AHandle = CreateFile(FileName.c_str(), GENERIC_WRITE, FILE_SHARE_READ, + *AHandle = CreateFile(ApiPath(FileName).c_str(), GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, CreateAttr, 0); Done = (*AHandle != INVALID_HANDLE_VALUE); if (!Done) @@ -3889,8 +3922,8 @@ bool __fastcall TTerminal::DoCreateLocalFile(const UnicodeString FileName, // save the error, otherwise it gets overwritten by call to FileExists int LastError = GetLastError(); int FileAttr; - if (::FileExists(FileName) && - (((FileAttr = FileGetAttr(FileName)) & (faReadOnly | faHidden)) != 0)) + if (::FileExists(ApiPath(FileName)) && + (((FileAttr = FileGetAttr(ApiPath(FileName))) & (faReadOnly | faHidden)) != 0)) { if (FLAGSET(FileAttr, faReadOnly)) { @@ -3901,12 +3934,14 @@ bool __fastcall TTerminal::DoCreateLocalFile(const UnicodeString FileName, else if ((OperationProgress->BatchOverwrite != boAll) && !NoConfirmation) { unsigned int Answer; - SUSPEND_OPERATION - ( + + { + TSuspendFileOperationProgress Suspend(OperationProgress); Answer = QueryUser( MainInstructions(FMTLOAD(READ_ONLY_OVERWRITE, (FileName))), NULL, qaYes | qaNo | qaCancel | qaYesToAll | qaNoToAll, 0); - ); + } + switch (Answer) { case qaYesToAll: OperationProgress->BatchOverwrite = boAll; break; case qaCancel: OperationProgress->Cancel = csCancel; // continue on next case @@ -3927,12 +3962,14 @@ bool __fastcall TTerminal::DoCreateLocalFile(const UnicodeString FileName, FLAGMASK(FLAGSET(FileAttr, faHidden), FILE_ATTRIBUTE_HIDDEN) | FLAGMASK(FLAGSET(FileAttr, faReadOnly), FILE_ATTRIBUTE_READONLY); - FILE_OPERATION_LOOP (FMTLOAD(CANT_SET_ATTRS, (FileName)), - if (FileSetAttr(FileName, FileAttr & ~(faReadOnly | faHidden)) != 0) + FILE_OPERATION_LOOP_BEGIN + { + if (FileSetAttr(ApiPath(FileName), FileAttr & ~(faReadOnly | faHidden)) != 0) { RaiseLastOSError(); } - ); + } + FILE_OPERATION_LOOP_END(FMTLOAD(CANT_SET_ATTRS, (FileName))); } else { @@ -3957,9 +3994,11 @@ bool __fastcall TTerminal::CreateLocalFile(const UnicodeString FileName, assert(AHandle); bool Result = true; - FILE_OPERATION_LOOP (FMTLOAD(CREATE_FILE_ERROR, (FileName)), + FILE_OPERATION_LOOP_BEGIN + { Result = DoCreateLocalFile(FileName, OperationProgress, AHandle, NoConfirmation); - ); + } + FILE_OPERATION_LOOP_END(FMTLOAD(CREATE_FILE_ERROR, (FileName))); return Result; } @@ -3972,10 +4011,13 @@ void __fastcall TTerminal::OpenLocalFile(const UnicodeString FileName, int Attrs = 0; HANDLE Handle = 0; - FILE_OPERATION_LOOP (FMTLOAD(FILE_NOT_EXISTS, (FileName)), - Attrs = FileGetAttr(FileName); - if (Attrs == -1) RaiseLastOSError(); - ) + FILE_OPERATION_LOOP_BEGIN + { + Attrs = FileGetAttr(ApiPath(FileName)); + if (Attrs < 0) RaiseLastOSError(); + } + FILE_OPERATION_LOOP_END(FMTLOAD(FILE_NOT_EXISTS, (FileName))); + if ((Attrs & faDirectory) == 0) { @@ -3987,8 +4029,9 @@ void __fastcall TTerminal::OpenLocalFile(const UnicodeString FileName, NoHandle = true; } - FILE_OPERATION_LOOP (FMTLOAD(OPENFILE_ERROR, (FileName)), - Handle = CreateFile(FileName.c_str(), Access, + FILE_OPERATION_LOOP_BEGIN + { + Handle = CreateFile(ApiPath(FileName).c_str(), Access, Access == GENERIC_READ ? FILE_SHARE_READ | FILE_SHARE_WRITE : FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); if (Handle == INVALID_HANDLE_VALUE) @@ -3996,7 +4039,8 @@ void __fastcall TTerminal::OpenLocalFile(const UnicodeString FileName, Handle = 0; RaiseLastOSError(); } - ); + } + FILE_OPERATION_LOOP_END(FMTLOAD(OPENFILE_ERROR, (FileName))); try { @@ -4005,10 +4049,14 @@ void __fastcall TTerminal::OpenLocalFile(const UnicodeString FileName, FILETIME ATime; FILETIME MTime; FILETIME CTime; + // Get last file access and modification time - FILE_OPERATION_LOOP (FMTLOAD(CANT_GET_ATTRS, (FileName)), + FILE_OPERATION_LOOP_BEGIN + { THROWOSIFFALSE(GetFileTime(Handle, &CTime, &ATime, &MTime)); - ); + } + FILE_OPERATION_LOOP_END(FMTLOAD(CANT_GET_ATTRS, (FileName))); + if (ACTime) { *ACTime = ConvertTimestampToUnixSafe(CTime, SessionData->DSTMode); @@ -4026,13 +4074,15 @@ void __fastcall TTerminal::OpenLocalFile(const UnicodeString FileName, if (ASize) { // Get file size - FILE_OPERATION_LOOP (FMTLOAD(CANT_GET_ATTRS, (FileName)), + FILE_OPERATION_LOOP_BEGIN + { unsigned long LSize; unsigned long HSize; LSize = GetFileSize(Handle, &HSize); if ((LSize == 0xFFFFFFFF) && (GetLastError() != NO_ERROR)) RaiseLastOSError(); *ASize = (__int64(HSize) << 32) + LSize; - ); + } + FILE_OPERATION_LOOP_END(FMTLOAD(CANT_GET_ATTRS, (FileName))); } if ((AHandle == NULL) || NoHandle) @@ -4053,7 +4103,7 @@ void __fastcall TTerminal::OpenLocalFile(const UnicodeString FileName, } //--------------------------------------------------------------------------- bool __fastcall TTerminal::AllowLocalFileTransfer(UnicodeString FileName, - const TCopyParamType * CopyParam) + const TCopyParamType * CopyParam, TFileOperationProgressType * OperationProgress) { bool Result = true; // optimization @@ -4061,13 +4111,15 @@ bool __fastcall TTerminal::AllowLocalFileTransfer(UnicodeString FileName, { WIN32_FIND_DATA FindData; HANDLE Handle; - FILE_OPERATION_LOOP (FMTLOAD(FILE_NOT_EXISTS, (FileName)), - Handle = FindFirstFile(ExcludeTrailingBackslash(FileName).c_str(), &FindData); + FILE_OPERATION_LOOP_BEGIN + { + Handle = FindFirstFile(ApiPath(ExcludeTrailingBackslash(FileName)).c_str(), &FindData); if (Handle == INVALID_HANDLE_VALUE) { RaiseLastOSError(); } - ) + } + FILE_OPERATION_LOOP_END(FMTLOAD(FILE_NOT_EXISTS, (FileName))); ::FindClose(Handle); bool Directory = FLAGSET(FindData.dwFileAttributes, FILE_ATTRIBUTE_DIRECTORY); TFileMasks::TParams Params; @@ -4077,7 +4129,17 @@ bool __fastcall TTerminal::AllowLocalFileTransfer(UnicodeString FileName, (static_cast<__int64>(FindData.nFileSizeHigh) << 32) + FindData.nFileSizeLow; Params.Modification = FileTimeToDateTime(FindData.ftLastWriteTime); - Result = CopyParam->AllowTransfer(FileName, osLocal, Directory, Params); + if (!CopyParam->AllowTransfer(FileName, osLocal, Directory, Params)) + { + LogEvent(FORMAT(L"File \"%s\" excluded from transfer", (FileName))); + Result = false; + } + else if (CopyParam->SkipTransfer(FileName, Directory)) + { + OperationProgress->AddSkippedFileSize(Params.Size); + Result = false; + } + if (Result) { LogFileDetails(FileName, Params.Modification, Params.Size); @@ -4086,19 +4148,6 @@ bool __fastcall TTerminal::AllowLocalFileTransfer(UnicodeString FileName, return Result; } //--------------------------------------------------------------------------- -UnicodeString __fastcall TTerminal::FileUrl(const UnicodeString Protocol, - const UnicodeString FileName) -{ - assert(FileName.Length() > 0); - return Protocol + ProtocolSeparator + EncodeUrlChars(SessionData->SessionName) + - (FileName[1] == L'/' ? L"" : L"/") + EncodeUrlChars(FileName, L"/"); -} -//--------------------------------------------------------------------------- -UnicodeString __fastcall TTerminal::FileUrl(const UnicodeString FileName) -{ - return FFileSystem->FileUrl(FileName); -} -//--------------------------------------------------------------------------- void __fastcall TTerminal::MakeLocalFileList(const UnicodeString FileName, const TSearchRec Rec, void * Param) { @@ -4344,10 +4393,12 @@ void __fastcall TTerminal::DoSynchronizeCollectDirectory(const UnicodeString Loc Data.LocalFileList->Sorted = true; Data.LocalFileList->CaseSensitive = false; - FILE_OPERATION_LOOP (FMTLOAD(LIST_DIR_ERROR, (LocalDirectory)), + FILE_OPERATION_LOOP_BEGIN + { int FindAttrs = faReadOnly | faHidden | faSysFile | faDirectory | faArchive; Found = (FindFirstChecked(Data.LocalDirectory + L"*.*", FindAttrs, SearchRec) == 0); - ); + } + FILE_OPERATION_LOOP_END(FMTLOAD(LIST_DIR_ERROR, (LocalDirectory))); if (Found) { @@ -4402,9 +4453,11 @@ void __fastcall TTerminal::DoSynchronizeCollectDirectory(const UnicodeString Loc (FormatFileDetailsForLog(FullLocalFileName, Modification, Size)))); } - FILE_OPERATION_LOOP (FMTLOAD(LIST_DIR_ERROR, (LocalDirectory)), + FILE_OPERATION_LOOP_BEGIN + { Found = (FindNextChecked(SearchRec) == 0); - ); + } + FILE_OPERATION_LOOP_END(FMTLOAD(LIST_DIR_ERROR, (LocalDirectory))); } } __finally @@ -4523,6 +4576,23 @@ void __fastcall TTerminal::DoSynchronizeCollectDirectory(const UnicodeString Loc //--------------------------------------------------------------------------- void __fastcall TTerminal::SynchronizeCollectFile(const UnicodeString FileName, const TRemoteFile * File, /*TSynchronizeData*/ void * Param) +{ + try + { + DoSynchronizeCollectFile(FileName, File, Param); + } + catch(EScpSkipFile & E) + { + TSuspendFileOperationProgress Suspend(OperationProgress); + if (!HandleException(&E)) + { + throw; + } + } +} +//--------------------------------------------------------------------------- +void __fastcall TTerminal::DoSynchronizeCollectFile(const UnicodeString FileName, + const TRemoteFile * File, /*TSynchronizeData*/ void * Param) { TSynchronizeData * Data = static_cast(Param); @@ -4791,7 +4861,7 @@ void __fastcall TTerminal::SynchronizeApply(TSynchronizeChecklist * Checklist, break; default: - assert(false); + FAIL; break; } } @@ -4828,7 +4898,7 @@ void __fastcall TTerminal::SynchronizeApply(TSynchronizeChecklist * Checklist, break; default: - assert(false); + FAIL; break; } } @@ -4923,19 +4993,22 @@ void __fastcall TTerminal::SynchronizeLocalTimestamp(const UnicodeString /*FileN IncludeTrailingBackslash(ChecklistItem->Local.Directory) + ChecklistItem->Local.FileName; - FILE_OPERATION_LOOP (FMTLOAD(CANT_SET_ATTRS, (LocalFile)), + FILE_OPERATION_LOOP_BEGIN + { HANDLE Handle; OpenLocalFile(LocalFile, GENERIC_WRITE, NULL, &Handle, NULL, NULL, NULL, NULL); FILETIME WrTime = DateTimeToFileTime(ChecklistItem->Remote.Modification, SessionData->DSTMode); bool Result = SetFileTime(Handle, NULL, NULL, &WrTime); + int Error = GetLastError(); CloseHandle(Handle); if (!Result) { - Abort(); + RaiseLastOSError(Error); } - ); + } + FILE_OPERATION_LOOP_END(FMTLOAD(CANT_SET_ATTRS, (LocalFile))); } //--------------------------------------------------------------------------- void __fastcall TTerminal::SynchronizeRemoteTimestamp(const UnicodeString /*FileName*/, @@ -5396,6 +5469,78 @@ void __fastcall TTerminal::CollectUsage() FCollectFileSystemUsage = true; } //--------------------------------------------------------------------------- +static UnicodeString __fastcall FormatCertificateData(const UnicodeString & Fingerprint, int Failures) +{ + return FORMAT(L"%s;%2.2X", (Fingerprint, Failures)); +} +//--------------------------------------------------------------------------- +bool __fastcall TTerminal::VerifyCertificate( + const UnicodeString & CertificateStorageKey, const UnicodeString & Fingerprint, + const UnicodeString & CertificateSubject, int Failures) +{ + bool Result = false; + + UnicodeString CertificateData = FormatCertificateData(Fingerprint, Failures); + + std::unique_ptr Storage(Configuration->CreateScpStorage(false)); + Storage->AccessMode = smRead; + + if (Storage->OpenSubKey(CertificateStorageKey, false)) + { + if (Storage->ValueExists(SessionData->SiteKey)) + { + UnicodeString CachedCertificateData = Storage->ReadString(SessionData->SiteKey, L""); + if (CertificateData == CachedCertificateData) + { + LogEvent(FORMAT(L"Certificate for \"%s\" matches cached fingerprint and failures", (CertificateSubject))); + Result = true; + } + } + else if (Storage->ValueExists(Fingerprint)) + { + LogEvent(FORMAT(L"Certificate for \"%s\" matches legacy cached fingerprint", (CertificateSubject))); + Result = true; + } + } + + if (!Result) + { + UnicodeString Buf = SessionData->HostKey; + while (!Result && !Buf.IsEmpty()) + { + UnicodeString ExpectedKey = CutToChar(Buf, L';', false); + if (ExpectedKey == L"*") + { + UnicodeString Message = LoadStr(ANY_CERTIFICATE); + Information(Message, true); + Log->Add(llException, Message); + Result = true; + } + else if (ExpectedKey == Fingerprint) + { + LogEvent(FORMAT(L"Certificate for \"%s\" matches configured fingerprint", (CertificateSubject))); + Result = true; + } + } + } + + return Result; +} +//--------------------------------------------------------------------------- +void __fastcall TTerminal::CacheCertificate(const UnicodeString & CertificateStorageKey, + const UnicodeString & Fingerprint, int Failures) +{ + UnicodeString CertificateData = FormatCertificateData(Fingerprint, Failures); + + std::unique_ptr Storage(Configuration->CreateScpStorage(false)); + Storage->AccessMode = smReadWrite; + + if (Storage->OpenSubKey(CertificateStorageKey, true)) + { + Storage->WriteString(SessionData->SiteKey, CertificateData); + } +} +//--------------------------------------------------------------------------- __fastcall TSecondaryTerminal::TSecondaryTerminal(TTerminal * MainTerminal, TSessionData * ASessionData, TConfiguration * Configuration, const UnicodeString & Name) : TTerminal(ASessionData, Configuration), diff --git a/source/core/Terminal.h b/source/core/Terminal.h index 951aee58..8aa9293f 100644 --- a/source/core/Terminal.h +++ b/source/core/Terminal.h @@ -42,7 +42,7 @@ typedef void __fastcall (__closure *TExtendedExceptionEvent) (TTerminal * Terminal, Exception * E, void * Arg); typedef void __fastcall (__closure *TReadDirectoryEvent)(System::TObject * Sender, Boolean ReloadOnly); typedef void __fastcall (__closure *TReadDirectoryProgressEvent)( - System::TObject* Sender, int Progress, bool & Cancel); + System::TObject* Sender, int Progress, int ResolvedLinks, bool & Cancel); typedef void __fastcall (__closure *TProcessFileEvent) (const UnicodeString FileName, const TRemoteFile * File, void * Param); typedef void __fastcall (__closure *TProcessFileEventEx) @@ -59,46 +59,44 @@ typedef int __fastcall (__closure *TDirectoryModifiedEvent) typedef void __fastcall (__closure *TInformationEvent) (TTerminal * Terminal, const UnicodeString & Str, bool Status, int Phase); //--------------------------------------------------------------------------- -#define SUSPEND_OPERATION(Command) \ - { \ - TSuspendFileOperationProgress Suspend(OperationProgress); \ - Command \ - } - #define THROW_SKIP_FILE(EXCEPTION, MESSAGE) \ throw EScpSkipFile(EXCEPTION, MESSAGE) #define THROW_SKIP_FILE_NULL THROW_SKIP_FILE(NULL, L"") /* TODO : Better user interface (query to user) */ -#define FILE_OPERATION_LOOP_CUSTOM(TERMINAL, ALLOW_SKIP, MESSAGE, OPERATION, HELPKEYWORD) { \ - bool DoRepeat; \ - do { \ - DoRepeat = false; \ - try { \ - OPERATION; \ - } \ - catch (EAbort & E) \ - { \ - throw; \ - } \ - catch (EScpSkipFile & E) \ - { \ - throw; \ - } \ - catch (EFatal & E) \ - { \ - throw; \ - } \ - catch (Exception & E) \ - { \ - TERMINAL->FileOperationLoopQuery( \ - E, OperationProgress, MESSAGE, ALLOW_SKIP, L"", HELPKEYWORD); \ - DoRepeat = true; \ - } \ - } while (DoRepeat); } - -#define FILE_OPERATION_LOOP(MESSAGE, OPERATION) \ - FILE_OPERATION_LOOP_EX(True, MESSAGE, OPERATION) +#define FILE_OPERATION_LOOP_BEGIN \ + { \ + bool DoRepeat; \ + do { \ + DoRepeat = false; \ + try \ + +#define FILE_OPERATION_LOOP_END_CUSTOM(MESSAGE, ALLOW_SKIP, HELPKEYWORD) \ + catch (EAbort & E) \ + { \ + throw; \ + } \ + catch (EScpSkipFile & E) \ + { \ + throw; \ + } \ + catch (EFatal & E) \ + { \ + throw; \ + } \ + catch (Exception & E) \ + { \ + FILE_OPERATION_LOOP_TERMINAL->FileOperationLoopQuery( \ + E, OperationProgress, MESSAGE, ALLOW_SKIP, L"", HELPKEYWORD); \ + DoRepeat = true; \ + } \ + } while (DoRepeat); \ + } + +#define FILE_OPERATION_LOOP_END_EX(MESSAGE, ALLOW_SKIP) \ + FILE_OPERATION_LOOP_END_CUSTOM(MESSAGE, ALLOW_SKIP, L"") +#define FILE_OPERATION_LOOP_END(MESSAGE) \ + FILE_OPERATION_LOOP_END_EX(MESSAGE, true) //--------------------------------------------------------------------------- enum TCurrentFSProtocol { cfsUnknown, cfsSCP, cfsSFTP, cfsFTP, cfsWebDAV }; //--------------------------------------------------------------------------- @@ -136,6 +134,7 @@ class TTerminal : public TObject, public TSessionUI static const int spBySize = 0x400; // cannot be combined with smBoth, has opposite meaning for spTimestamp static const int spSelectedOnly = 0x800; // not used by core static const int spMirror = 0x1000; + static const int spDefault = TTerminal::spNoConfirmation | TTerminal::spPreviewChanges; // for TranslateLockedPath() friend class TRemoteFile; @@ -229,6 +228,7 @@ friend class TCallbackGuard; UnicodeString __fastcall GetRememberedTunnelPassword(); bool __fastcall GetStoredCredentialsTried(); inline bool __fastcall InTransaction(); + void __fastcall SaveCapabilities(TFileSystemInfo & FileSystemInfo); static UnicodeString __fastcall SynchronizeModeStr(TSynchronizeMode Mode); static UnicodeString __fastcall SynchronizeParamsStr(int Params); @@ -238,7 +238,7 @@ friend class TCallbackGuard; bool FTunnelOpening; void __fastcall DoStartReadDirectory(); - void __fastcall DoReadDirectoryProgress(int Progress, bool & Cancel); + void __fastcall DoReadDirectoryProgress(int Progress, int ResolvedLinks, bool & Cancel); void __fastcall DoReadDirectory(bool ReloadOnly); void __fastcall DoCreateDirectory(const UnicodeString DirName); void __fastcall DoDeleteFile(const UnicodeString FileName, const TRemoteFile * File, @@ -279,7 +279,8 @@ friend class TCallbackGuard; void __fastcall OpenLocalFile(const UnicodeString FileName, unsigned int Access, int * Attrs, HANDLE * Handle, __int64 * ACTime, __int64 * MTime, __int64 * ATime, __int64 * Size, bool TryWriteReadOnly = true); - bool __fastcall AllowLocalFileTransfer(UnicodeString FileName, const TCopyParamType * CopyParam); + bool __fastcall AllowLocalFileTransfer(UnicodeString FileName, + const TCopyParamType * CopyParam, TFileOperationProgressType * OperationProgress); bool __fastcall HandleException(Exception * E); void __fastcall CalculateFileSize(UnicodeString FileName, const TRemoteFile * File, /*TCalculateSizeParams*/ void * Size); @@ -290,10 +291,11 @@ friend class TCallbackGuard; bool __fastcall CalculateLocalFilesSize(TStrings * FileList, __int64 & Size, const TCopyParamType * CopyParam, bool AllowDirs); TBatchOverwrite __fastcall EffectiveBatchOverwrite( - const TCopyParamType * CopyParam, int Params, + const UnicodeString & FileName, const TCopyParamType * CopyParam, int Params, TFileOperationProgressType * OperationProgress, bool Special); bool __fastcall CheckRemoteFile( - const TCopyParamType * CopyParam, int Params, TFileOperationProgressType * OperationProgress); + const UnicodeString & FileName, const TCopyParamType * CopyParam, + int Params, TFileOperationProgressType * OperationProgress); unsigned int __fastcall ConfirmFileOverwrite(const UnicodeString FileName, const TOverwriteFileParams * FileParams, unsigned int Answers, TQueryParams * QueryParams, TOperationSide Side, const TCopyParamType * CopyParam, int Params, @@ -303,6 +305,8 @@ friend class TCallbackGuard; const TCopyParamType * CopyParam, int Params, TSynchronizeDirectory OnSynchronizeDirectory, TSynchronizeOptions * Options, int Level, TSynchronizeChecklist * Checklist); + void __fastcall DoSynchronizeCollectFile(const UnicodeString FileName, + const TRemoteFile * File, /*TSynchronizeData*/ void * Param); void __fastcall SynchronizeCollectFile(const UnicodeString FileName, const TRemoteFile * File, /*TSynchronizeData*/ void * Param); void __fastcall SynchronizeRemoteTimestamp(const UnicodeString FileName, @@ -324,7 +328,6 @@ friend class TCallbackGuard; void __fastcall OpenTunnel(); void __fastcall CloseTunnel(); void __fastcall DoInformation(const UnicodeString & Str, bool Status, int Phase = -1); - UnicodeString __fastcall FileUrl(const UnicodeString Protocol, const UnicodeString FileName); bool __fastcall PromptUser(TSessionData * Data, TPromptKind Kind, UnicodeString Name, UnicodeString Instructions, UnicodeString Prompt, bool Echo, int MaxLen, UnicodeString & Result); @@ -347,7 +350,7 @@ friend class TCallbackGuard; virtual void __fastcall Closed(); virtual void __fastcall HandleExtendedException(Exception * E); bool __fastcall IsListenerFree(unsigned int PortNumber); - void __fastcall DoProgress(TFileOperationProgressType & ProgressData, TCancelStatus & Cancel); + void __fastcall DoProgress(TFileOperationProgressType & ProgressData); void __fastcall DoFinished(TFileOperation Operation, TOperationSide Side, bool Temp, const UnicodeString & FileName, bool Success, TOnceDoneOperation & OnceDoneOperation); void __fastcall RollbackAction(TSessionAction & Action, @@ -361,6 +364,12 @@ friend class TCallbackGuard; UnicodeString __fastcall FormatFileDetailsForLog(const UnicodeString & FileName, TDateTime Modification, __int64 Size); void __fastcall LogFileDetails(const UnicodeString & FileName, TDateTime Modification, __int64 Size); virtual TTerminal * __fastcall GetPasswordSource(); + void __fastcall DoEndTransaction(bool Inform); + bool __fastcall VerifyCertificate( + const UnicodeString & CertificateStorageKey, const UnicodeString & Fingerprint, + const UnicodeString & CertificateSubject, int Failures); + void __fastcall TTerminal::CacheCertificate(const UnicodeString & CertificateStorageKey, + const UnicodeString & Fingerprint, int Failures); __property TFileOperationProgressType * OperationProgress = { read=FOperationProgress }; @@ -447,7 +456,6 @@ friend class TCallbackGuard; TRemoteFileList *& FileList, bool CanLoad); void __fastcall MakeLocalFileList(const UnicodeString FileName, const TSearchRec Rec, void * Param); - UnicodeString __fastcall FileUrl(const UnicodeString FileName); bool __fastcall FileOperationLoopQuery(Exception & E, TFileOperationProgressType * OperationProgress, const UnicodeString Message, bool AllowSkip, UnicodeString SpecialRetry = L"", UnicodeString HelpKeyword = L""); diff --git a/source/core/WebDAVFileSystem.cpp b/source/core/WebDAVFileSystem.cpp index da2a2fd9..775a4086 100644 --- a/source/core/WebDAVFileSystem.cpp +++ b/source/core/WebDAVFileSystem.cpp @@ -2,27 +2,22 @@ #include #pragma hdrstop -#include -#include +#include +#include #include -#include -#include -#include -#include -#include -#include - +#define NE_LFS +#define WINSCP #include #include -#include #include -#include #include #include #include #include -#include +#include +#include +#include #include "WebDAVFileSystem.h" @@ -32,14 +27,17 @@ #include "Terminal.h" #include "TextsCore.h" #include "SecureShell.h" -#include "FileZillaIntf.h" #include "HelpCore.h" - +#include "CoreMain.h" +#include "Security.h" +#include +#include //--------------------------------------------------------------------------- #pragma package(smart_init) //--------------------------------------------------------------------------- +#define FILE_OPERATION_LOOP_TERMINAL FTerminal +//--------------------------------------------------------------------------- const int tfFirstLevel = 0x01; -const int tfAutoResume = 0x02; //--------------------------------------------------------------------------- struct TSinkFileParams { @@ -51,12194 +49,461 @@ struct TSinkFileParams unsigned int Flags; }; //--------------------------------------------------------------------------- -struct TFileTransferData +struct TWebDAVCertificateData { - TFileTransferData() - { - Params = 0; - AutoResume = false; - OverwriteResult = -1; - CopyParam = NULL; - } + UnicodeString Subject; + UnicodeString Issuer; - UnicodeString FileName; - int Params; - bool AutoResume; - int OverwriteResult; - const TCopyParamType * CopyParam; -}; -//--------------------------------------------------------------------------- -struct TClipboardHandler -{ - UnicodeString Text; + TDateTime ValidFrom; + TDateTime ValidUntil; - void __fastcall Copy(TObject * /*Sender*/) - { - TInstantOperationVisualizer Visualizer; - CopyToClipboard(Text); - } + UnicodeString Fingerprint; + AnsiString AsciiCert; + + int Failures; }; //--------------------------------------------------------------------------- - -namespace webdav { - -#pragma warn -8004 - -const AnsiString __cdecl Format(const char * format, va_list args) -{ - int len = AnsiString().vprintf(format, args); - AnsiString Result; - Result.SetLength(len + 1); - vsprintf(&Result[1], format, args); - return Result.c_str(); -} - -const AnsiString __cdecl Format(const char * format, ...) -{ - va_list args; - va_start(args, format); - AnsiString Result = Format(format, args); - va_end(args); - return Result; -} - +#define SESSION_FS_KEY "filesystem" +#define MAX_REDIRECT_ATTEMPTS 3 +static const char CertificateStorageKey[] = "HttpsCertificates"; +static const UnicodeString CONST_WEBDAV_PROTOCOL_BASE_NAME = L"WebDAV"; //--------------------------------------------------------------------------- -struct auth_baton_t; -struct vtable_t; -struct stream_t; -struct client_ctx_t; -struct auth_iterstate_t; +#define DAV_PROP_NAMESPACE "DAV:" +#define PROP_CONTENT_LENGTH "getcontentlength" +#define PROP_LAST_MODIFIED "getlastmodified" +#define PROP_RESOURCE_TYPE "resourcetype" +#define PROP_HIDDEN "ishidden" +#define PROP_QUOTA_AVAILABLE "quota-available-bytes" +#define PROP_QUOTA_USED "quota-used-bytes" //--------------------------------------------------------------------------- - -typedef enum tristate_t -{ - tristate_false = 2, - tristate_true, - tristate_unknown -} tristate_t; - -//------------------------------------------------------------------------------ -// Userdata for the `proxy_auth' function. -struct proxy_auth_baton_t +static std::unique_ptr DebugSection(new TCriticalSection); +static std::set FileSystems; +//--------------------------------------------------------------------------- +extern "C" { - const char * username; // Cannot be NULL, but "" is okay. - const char * password; // Cannot be NULL, but "" is okay. -}; - -//------------------------------------------------------------------------------ -// from svn_types.h - -typedef error_t (*cancel_func_t)(void * cancel_baton); - -//------------------------------------------------------------------------------ -// from svn_ra.h -typedef void (*progress_notify_func_t)( - apr_off_t progress, - apr_off_t total, - void * baton, - apr_pool_t * pool); - -typedef error_t (*get_client_string_func_t)(void * baton, - const char ** name, - apr_pool_t * pool); - -typedef struct callbacks2_t +void ne_debug(void * Context, int Channel, const char * Format, ...) { - auth_baton_t * auth_baton; - - progress_notify_func_t progress_func; - void * progress_baton; - - cancel_func_t cancel_func; - get_client_string_func_t get_client_string; -} callbacks2_t; + bool DoLog; -typedef struct callback_baton_t -{ - client_ctx_t * ctx; - apr_pool_t * pool; -} callback_baton_t; + if (FLAGSET(Channel, NE_DBG_SOCKET) || + FLAGSET(Channel, NE_DBG_HTTP) || + FLAGSET(Channel, NE_DBG_HTTPAUTH) || + FLAGSET(Channel, NE_DBG_SSL)) + { + DoLog = true; + } + else if (FLAGSET(Channel, NE_DBG_XML) || + FLAGSET(Channel, NE_DBG_WINSCP_HTTP_DETAIL)) + { + DoLog = (Configuration->ActualLogProtocol >= 1); + } + else if (FLAGSET(Channel, NE_DBG_LOCKS) || + FLAGSET(Channel, NE_DBG_XMLPARSE) || + FLAGSET(Channel, NE_DBG_HTTPBODY)) + { + DoLog = (Configuration->ActualLogProtocol >= 2); + } + else + { + DoLog = false; + FAIL; + } -//------------------------------------------------------------------------------ -// from ra_loader.h + if (DoLog) + { + TWebDAVFileSystem * FileSystem = NULL; + if (Context != NULL) + { + ne_session * Session = static_cast(Context); -typedef error_t (*init_func_t)(const vtable_t ** vtable, - apr_pool_t * pool); + FileSystem = + static_cast(ne_get_session_private(Session, SESSION_FS_KEY)); + } + else + { + TGuard Guard(DebugSection.get()); -//------------------------------------------------------------------------------ -// from svn_string.h + if (FileSystems.size() == 1) + { + FileSystem = *FileSystems.begin(); + } + } -// A simple counted string. -typedef struct string_t -{ - const char * data; //< pointer to the bytestring - apr_size_t len; //< length of bytestring -} string_t; + if (FileSystem != NULL) + { + va_list Args; + va_start(Args, Format); + UTF8String Message; + Message.vprintf(Format, Args); + FileSystem->NeonDebug(UnicodeString(Message)); + va_end(Args); + } + } +} -// A buffered string, capable of appending without an allocation and copy -// for each append. -typedef struct stringbuf_t +void ne_init_ssl_session(struct ssl_st * Ssl, ne_session * Session) { - apr_pool_t * pool; - char * data; - apr_size_t len; - apr_size_t blocksize; -} stringbuf_t; + TWebDAVFileSystem * FileSystem = + static_cast(ne_get_session_private(Session, SESSION_FS_KEY)); + FileSystem->InitSslSession(Ssl); +} +} // extern "C" //------------------------------------------------------------------------------ -// from ra_neon.h - -// Rename these types and constants to abstract from Neon - -#define NEON_XML_DECLINE NE_XML_DECLINE -#define NEON_XML_INVALID NE_XML_ABORT - -#define NEON_XML_CDATA (1<<1) -#define NEON_XML_COLLECT ((1<<2) | NEON_XML_CDATA) - -// Related to anonymous enum below? -typedef int neon_xml_elmid; - -typedef struct neon_xml_elm_t -{ - const char * nspace; - const char * name; - neon_xml_elmid id; - - // Processing flags for this namespace:tag. - // 0 (zero) - regular element, may have children, - // NEON_XML_CDATA - child-less element, - // NEON_XML_COLLECT - complete contents of such element must be - // collected as CDATA, includes *_CDATA flag. - unsigned int flags; - -} neon_xml_elm_t; - -typedef struct neon_session_t -{ - apr_pool_t * pool; - stringbuf_t * url; // original, unparsed session url - ne_uri root; // parsed version of above - const char * webdav_root; // URL for WebDAV resource root - - ne_session * ne_sess; // HTTP session to server - - const callbacks2_t * callbacks; // callbacks to get auth data - void * callback_baton; - - auth_iterstate_t * auth_iterstate; // state of authentication retries - bool auth_used; // Save authorization state after - // successful usage - - auth_iterstate_t * p11pin_iterstate; // state of PKCS#11 pin retries - - bool compression; // should we use http compression? - - progress_notify_func_t progress_func; - void * progress_baton; - - apr_off_t total_progress; // Total number of bytes sent in this - // session with a -1 total marker - apr_hash_t * capabilities; -} neon_session_t; - -typedef struct neon_request_t +//--------------------------------------------------------------------------- +// ne_path_escape returns 7-bit string, so it does not really matter if we use +// AnsiString or UTF8String here, though UTF8String might be more safe +static AnsiString PathEscape(const char * Path) { - ne_request * ne_req; // neon request structure - ne_session * ne_sess; // neon session structure - neon_session_t * sess; // DAV session structure - const char * method; - const char * url; - int rv; // Return value from - // ne_request_dispatch() or -1 if - // not dispatched yet. - int code; // HTTP return code, or 0 if none - const char * code_desc; // Textual description of CODE - error_t err; // error encountered while executing - // the request - bool marshalled_error; // TRUE if the error was server-side - apr_pool_t * pool; // where this struct is allocated - apr_pool_t * iterpool; // iteration pool - // for use within callbacks -} neon_request_t; - -// Related to neon_xml_elmid? -// add WEBDAV_NEON_ to these to prefix conflicts with (sys) headers? -enum + char * EscapedPath = ne_path_escape(Path); + AnsiString Result = EscapedPath; + ne_free(EscapedPath); + return Result; +} +//--------------------------------------------------------------------------- +static UTF8String PathUnescape(const char * Path) { - // Redefine Neon elements - // With the new API, we need to be able to use element id also as a return - // value from the new `startelm' callback, hence all element ids must be - // positive. Root element id is the only id that is not positive, it's zero. - // `Root state' is never returned by a callback, it's only passed into it. - // Therefore, negative element ids are forbidden from now on. - ELEM_unknown = 1, // was (-1), see above why it's (1) now - ELEM_root = NE_XML_STATEROOT, // (0) - ELEM_UNUSED = 100, - ELEM_207_first = ELEM_UNUSED, - ELEM_multistatus = ELEM_207_first, - ELEM_response = ELEM_207_first + 1, - ELEM_responsedescription = ELEM_207_first + 2, - ELEM_href = ELEM_207_first + 3, - ELEM_propstat = ELEM_207_first + 4, - ELEM_prop = ELEM_207_first + 5, // `prop' tag in the DAV namespace - ELEM_status = ELEM_207_first + 6, - ELEM_207_UNUSED = ELEM_UNUSED + 100, - ELEM_PROPS_UNUSED = ELEM_207_UNUSED + 100, - - // DAV elements - ELEM_collection = ELEM_207_UNUSED, - ELEM_comment, - ELEM_creationdate, - ELEM_creator_displayname, - ELEM_options_response, - ELEM_set_prop, - ELEM_remove_prop, - ELEM_resourcetype, - ELEM_get_content_length, - ELEM_get_last_modified, - ELEM_updated_set, - ELEM_error, - - ELEM_human_readable, -}; - -// The session object. -struct session_t + char * UnescapedPath = ne_path_unescape(Path); + UTF8String Result = UnescapedPath; + ne_free(UnescapedPath); + return Result; +} +//--------------------------------------------------------------------------- +#define StrToNeon(S) UTF8String(S).c_str() +#define StrFromNeon(S) UnicodeString(UTF8String(S)) +#define AbsolutePathToNeon(P) PathEscape(StrToNeon(P)).c_str() +#define PathToNeon(P) AbsolutePathToNeon(AbsolutePath(P, false)) +//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- +void __fastcall NeonInitialize() { - const vtable_t * vtable; - - // Pool used to manage this session. - apr_pool_t * pool; - - // Private data for the RA implementation. - void * priv; -}; - -typedef std::vector listdataentry_vector_t; - -// Baton used when listing directory entries. -typedef struct list_func_baton_t + // Even if this fails, we do not want to interrupt WinSCP starting for that. + // We may possibly remember that and fail opening session later. + // Anyway, it can hardly fail. + ALWAYS_TRUE(ne_sock_init() == 0); +} +//--------------------------------------------------------------------------- +void __fastcall NeonFinalize() { - bool verbose; - listdataentry_vector_t * entries; - session_t * session; - apr_pool_t * pool; -} list_func_baton_t; - -//------------------------------------------------------------------------------ - -// timeout (in seconds) -#define DEFAULT_HTTP_TIMEOUT 10 - -#define WEBDAV_ERR_DAV_SOCK_INIT 1000 -#define WEBDAV_ERR_XML_MALFORMED 1001 -#define WEBDAV_ERR_DAV_OPTIONS_REQ_FAILED 1002 -#define WEBDAV_ERR_DAV_REQUEST_FAILED 1003 -#define WEBDAV_ERR_INCORRECT_PARAMS 1004 -#define WEBDAV_ERR_FS_NOT_FOUND 1005 -#define WEBDAV_ERR_FS_PROP_BASEVALUE_MISMATCH 1006 -#define WEBDAV_ERR_DAV_FORBIDDEN 1010 -#define WEBDAV_ERR_DAV_RELOCATED 1011 -#define WEBDAV_ERR_NOT_AUTHORIZED 1012 -#define WEBDAV_ERR_ILLEGAL_URL 1013 -#define WEBDAV_ERR_DAV_NOT_IMPLEMENTED 1014 -#define WEBDAV_ERR_NOT_IMPLEMENTED 1015 - -#define WEBDAV_ERR_AUTHN_NO_PROVIDER 1020 -#define WEBDAV_ERR_CLIENT_CYCLE_DETECTED 1021 -#define WEBDAV_ERR_DAV_MALFORMED_DATA 1022 -#define WEBDAV_ERR_IO_PIPE_WRITE_ERROR 1023 -#define WEBDAV_ERR_BAD_DATE 1024 -#define WEBDAV_ERR_CLIENT_UNRELATED_RESOURCES 1025 -#define WEBDAV_ERR_ROOT_URL_MISMATCH 1027 -#define WEBDAV_ERR_BAD_FILENAME 1028 -#define WEBDAV_ERR_ENTRY_MISSING_URL 1029 -#define WEBDAV_ERR_FS_NOT_FILE 1030 -#define WEBDAV_ERR_ATOMIC_INIT_FAILURE 1033 -#define WEBDAV_ERR_IO_UNIQUE_NAMES_EXHAUSTED 1034 -#define WEBDAV_ERR_STREAM_SEEK_NOT_SUPPORTED 1035 -#define WEBDAV_ERR_BAD_CONFIG_VALUE 1040 -#define WEBDAV_ERR_CANCELLED 1050 -#define WEBDAV_ERR_DAV_INVALID_CONFIG_VALUE 1051 -#define WEBDAV_ERR_DAV_PROPPATCH_FAILED 1060 -#define WEBDAV_ERR_CANNOT_PUT_FILE 1061 -#define WEBDAV_ERR_CANNOT_DELETE_FILE 1062 -#define WEBDAV_ERR_CANNOT_MKCOL 1063 -#define WEBDAV_ERR_CANNOT_MOVE 1064 -#define WEBDAV_ERR_CANNOT_PROPFIND 1065 -#define WEBDAV_ERR_BAD_PARAM 1070 - -// The application doesn't want any providers to save credentials -// to disk. Property value is irrelevant; only property's existence -// matters. -#define AUTH_PARAM_NO_AUTH_CACHE AUTH_PARAM_PREFIX "no-auth-cache" -// #define HASH_KEY_STRING "" - -#define MAX_REDIRECT_ATTEMPTS 3 // TODO: Make configurable. + ne_sock_exit(); +} //--------------------------------------------------------------------------- -// #define WEBDAV_ARRAY_IDX(ary,i,type) ((type)(ary)[i]) -#define WEBDAV_NO_ERROR 0 -#define WEBDAV_UNKNOWN_ERROR 1 -#define WEBDAV_ERR(expr) \ - do { \ - webdav::error_t err__temp = (expr); \ - if (err__temp) \ - return err__temp; \ - } while (0) - -// A statement macro, very similar to WEBDAV_ERR. -// This macro will wrap the error with the specified text before -// returning the error. - -#define WEBDAV_ERR_W(expr, wrap_msg) \ - do { \ - webdav::error_t err__temp = (expr); \ - if (err__temp) \ - return webdav::error_create(err__temp, NULL, wrap_msg); \ - } while (0) - -#define WEBDAV_ERR_ASSERT(expr) \ - do { \ - if (!(expr)) \ - WEBDAV_ERR(WEBDAV_UNKNOWN_ERROR); \ - } while (0) - -#define error_trace(expr) (expr) - -// Create a pool as a subpool of parent_pool -#define webdav_pool_create(parent_pool) webdav::pool_create_ex(parent_pool, NULL) -#define webdav_pool_clear apr_pool_clear -// Destroy a pool and all of its children. -// This define for webdav_pool_destroy exists for symmetry and -// completeness. - -#define webdav_pool_destroy apr_pool_destroy - -// Destroy request REQ and any associated resources -#define neon_request_destroy(req) webdav_pool_destroy((req)->pool) - -// Statement macro to set the request error, -// making sure we don't leak any in case we encounter more than one error. -// Sets the 'err' field of REQ to the value obtained by evaluating NEW_ERR. - -#define NEON_REQ_ERR(req, new_err) \ - do { \ - error_t err__tmp = (new_err); \ - if ((req)->err && !(req)->marshalled_error) \ - error_clear(&err__tmp); \ - else if (err__tmp) \ - { \ - error_clear(&(req)->err); \ - (req)->err = err__tmp; \ - (req)->marshalled_error = false; \ - } \ - } while (0) - -//=========================================================================== - -//------------------------------------------------------------------------------ -// from error.c - -static void -error_clear(error_t * err) +UnicodeString __fastcall NeonVersion() { - if (err) *err = 0; + UnicodeString Str = StrFromNeon(ne_version_string()); + CutToChar(Str, L' ', true); // "neon" + UnicodeString Result = CutToChar(Str, L':', true); + return Result; } - -static error_t -make_error_internal( - apr_status_t apr_err, - error_t * child) +//--------------------------------------------------------------------------- +UnicodeString __fastcall ExpatVersion() { - error_t new_error = apr_err; - return new_error; + return FORMAT(L"%d.%d.%d", (XML_MAJOR_VERSION, XML_MINOR_VERSION, XML_MICRO_VERSION)); } - -static error_t -error_create( - apr_status_t apr_err, - error_t * child, - const char * message) +//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- +TWebDAVFileSystem::TWebDAVFileSystem(TTerminal * ATerminal) : + TCustomFileSystem(ATerminal), + FActive(false), + FHasTrailingSlash(false), + FNeonSession(NULL), + FUploading(false), + FDownloading(false), + FUploadBodyProvider(NULL), + FInitialHandshake(false), + FIgnoreAuthenticationFailure(iafNo) { - return apr_err; + FFileSystemInfo.ProtocolBaseName = CONST_WEBDAV_PROTOCOL_BASE_NAME; + FFileSystemInfo.ProtocolName = FFileSystemInfo.ProtocolBaseName; } - -static error_t -error_createf( - apr_status_t apr_err, - error_t * child, - const char * fmt, - ...) +//--------------------------------------------------------------------------- +__fastcall TWebDAVFileSystem::~TWebDAVFileSystem() { - va_list args; - - va_start(args, fmt); - AnsiString Message = Format(fmt, args); - va_end(args); - - AnsiString Message2 = Format("Error, code: %d, message: %s", apr_err, Message.c_str()); - throw ExtException(UnicodeString(Message2), NULL); + UnregisterFromDebug(); } - -static error_t -error_wrap_apr( - apr_status_t status, - const char * fmt, - ...) +//--------------------------------------------------------------------------- +void __fastcall TWebDAVFileSystem::Open() { - error_t err = 0; - va_list args; + RegisterForDebug(); - err = make_error_internal(status, NULL); - - va_start(args, fmt); - AnsiString Message = Format(fmt, args); - va_end(args); + FCurrentDirectory = L""; + FHasTrailingSlash = true; + FStoredPasswordTried = false; - err = error_create(err, NULL, Message.c_str()); + TSessionData * Data = FTerminal->SessionData; - return err; -} + FSessionInfo.LoginTime = Now(); -//------------------------------------------------------------------------------ -// from utils.c + bool Ssl = (FTerminal->SessionData->Ftps != ftpsNone); + if (Ssl) + { + FSessionInfo.SecurityProtocolName = LoadStr(FTPS_IMPLICIT); + } -// a cleanup routine attached to the pool that contains the RA session -// root URI. -static apr_status_t -cleanup_uri(void * uri) -{ - ne_uri_free(static_cast(uri)); - return APR_SUCCESS; -} + UnicodeString HostName = Data->HostNameExpanded; + size_t Port = Data->PortNumber; + UnicodeString ProtocolName = !Ssl ? WebDAVProtocol : WebDAVSProtocol; + UnicodeString Path = Data->RemoteDirectory; + // PathToNeon is not used as we cannot call AbsolutePath here + UnicodeString EscapedPath = UnicodeString(UTF8String(PathEscape(StrToNeon(Path)).c_str())); + UnicodeString Url = FORMAT(L"%s://%s:%d%s", (ProtocolName, HostName, Port, EscapedPath)); -static error_t -parse_url( - const char * url, ne_uri * uri) -{ - if (ne_uri_parse(url, uri) || - (uri->host == NULL) || (uri->path == NULL) || (uri->scheme == NULL)) + FTerminal->Information(LoadStr(STATUS_CONNECT), true); + FActive = false; + try { - ne_uri_free(uri); - return 0; + OpenUrl(Url); } - if (uri->port == 0) - uri->port = ne_uri_defaultport(uri->scheme); - - return 1; + catch (Exception & E) + { + CloseNeonSession(); + FTerminal->Closed(); + FTerminal->FatalError(&E, LoadStr(CONNECTION_FAILED)); + } + FActive = true; } - -static error_t -parse_ne_uri( - ne_uri ** uri, - const char * webdav_url, - apr_pool_t * pool) +//--------------------------------------------------------------------------- +UnicodeString __fastcall TWebDAVFileSystem::ParsePathFromUrl(const UnicodeString & Url) { - // Sanity check the URI - *uri = static_cast(apr_pcalloc(pool, sizeof(**uri))); - if (!parse_url(webdav_url, *uri)) + UnicodeString Result; + ne_uri ParsedUri; + if (ne_uri_parse(StrToNeon(Url), &ParsedUri) == 0) { - return error_createf(WEBDAV_ERR_ILLEGAL_URL, NULL, - "URL '%s' is malformed or the " - "scheme or host or path is missing", webdav_url); + Result = StrFromNeon(PathUnescape(ParsedUri.path)); + ne_uri_free(&ParsedUri); } - // make sure we eventually destroy the uri - apr_pool_cleanup_register(pool, *uri, cleanup_uri, apr_pool_cleanup_null); - return WEBDAV_NO_ERROR; + return Result; } - -//------------------------------------------------------------------------------ -// from svn_types.h - -#define atoui64(X) ((apr_uint64_t) apr_atoi64(X)) - -// An indication that you are interested in the kind field -#define WEBDAV_DIRENT_KIND 0x00001 - -// An indication that you are interested in the size field -#define WEBDAV_DIRENT_SIZE 0x00002 - -// An indication that you are interested in the time field -#define WEBDAV_DIRENT_TIME 0x00010 - -// A combination of all the dirent fields -#define WEBDAV_DIRENT_ALL ~((apr_uint32_t ) 0) - -// The various types of nodes in filesystem. -typedef enum node_kind_t -{ - // absent - node_none, - - // regular file - node_file, - - // directory - node_dir, - - // something's here, but we don't know what - node_unknown -} node_kind_t; - -// A general directory entry. -typedef struct dirent_t -{ - // node kind - node_kind_t kind; - - // length of file text, or 0 for directories - apr_int64_t size; - - // time of mod-time - apr_time_t time; -} dirent_t; - -typedef enum depth_t -{ - // Just the named directory D, no entries. Updates will not pull in - // any files or subdirectories not already present. - depth_empty = 0, - - // D + its file children, but not subdirs. Updates will pull in any - // files not already present, but not subdirectories. - depth_files = 1, - - // D + immediate children (D and its entries). Updates will pull in - // any files or subdirectories not already present; those - // subdirectories' this_dir entries will have depth-empty. - depth_immediates = 2, - - // D + all descendants (full recursion from D). Updates will pull - // in any files or subdirectories not already present; those - // subdirectories' this_dir entries will have depth-infinity. - // Equivalent to the pre-1.5 default update behavior. - depth_infinity = 3 - -} depth_t; - -//------------------------------------------------------------------------------ -// from utf.h - -static error_t -utf_cstring_to_utf8( - const char ** dest, - const char * src, - apr_pool_t * pool); - -static error_t -utf_cstring_from_utf8( - const char ** dest, - const char * src, - apr_pool_t * pool); - -// Local wrapper of path_cstring_from_utf8() that does no copying on -// operating systems where APR always uses utf-8 as native path format -static error_t -cstring_from_utf8( - const char ** path_apr, - const char * path_utf8, - apr_pool_t * pool); - -//------------------------------------------------------------------------------ -// from ra_neon.h - -#ifdef WEBDAV_DEBUG -#define DEBUG_CR "\n" -#else -#define DEBUG_CR "" -#endif - -#define NEON_DEPTH_ZERO 0 -#define NEON_DEPTH_ONE 1 -#define NEON_DEPTH_INFINITE -1 - -// NEON_PROP_*: properties that we fetch from the server -// These are simply symbolic names for some standard properties that we fetch. - -#define NEON_PROP_CREATIONDATE "DAV:creationdate" -#define NEON_PROP_GETCONTENTLENGTH "DAV:getcontentlength" - -typedef struct neon_resource_t -{ - // what is the URL for this resource - const char * url; - - // is this resource a collection? (from the DAV:resourcetype element) - int is_collection; - - // PROPSET: NAME -> VALUE (const char * -> const string_t *) - apr_hash_t * propset; - - // --- only used during response processing --- - // when we see a DAV:href element, what element is the parent? - int href_parent; - - apr_pool_t * pool; - -} neon_resource_t; - -// Our equivalent of ne_xml_startelm_cb, the difference being that it -// returns errors in a error_t, and returns the element type via -// ELEM. To ignore the element *ELEM should be set to -// NEON_XML_DECLINE and WEBDAV_NO_ERROR should be returned. -// *ELEM can be set to NEON_XML_INVALID to indicate invalid XML -// (and abort the parse). - -typedef error_t (*neon_startelm_cb_t)(int * elem, - void * baton, - int parent, - const char * nspace, - const char * name, - const char ** atts); - -// Our equivalent of ne_xml_cdata_cb, the difference being that it returns -// errors in a error_t. - -typedef error_t (*neon_cdata_cb_t)(void * baton, - int state, - const char * cdata, - size_t len); - -// Our equivalent of ne_xml_endelm_cb, the difference being that it returns -// errors in a error_t. - -typedef error_t (*neon_endelm_cb_t)(void * baton, - int state, - const char * nspace, - const char * name); - -static ne_xml_parser * -neon_xml_parser_create( - neon_request_t * req, - ne_accept_response accpt, - neon_startelm_cb_t startelm_cb, - neon_cdata_cb_t cdata_cb, - neon_endelm_cb_t endelm_cb, - void * baton); - -static error_t -neon_request_dispatch( - int * code_p, - neon_request_t * req, - apr_hash_t * extra_headers, - const char * body, - int okay_1, - int okay_2, - bool check_errors, - apr_pool_t * pool); - -static error_t -neon_check_parse_error( - const char * method, - ne_xml_parser * xml_parser, - const char * url); - -static error_t -neon_request_create( - neon_request_t ** request, - neon_session_t * sess, - const char * method, const char * url, - apr_pool_t * pool); - -static const neon_xml_elm_t * -neon_lookup_xml_elem( - const neon_xml_elm_t * table, - const char * nspace, - const char * name); - -static error_t -neon_xml_collect_cdata( - void * baton, int state, - const char * cdata, size_t len); - -static const char * -neon_request_get_location( - neon_request_t * request, - apr_pool_t * pool); - -// Our version of ne_block_reader, which returns an -// error_t instead of an int. -typedef error_t (*neon_block_reader)( - void * baton, - const char * data, - size_t len); - -//------------------------------------------------------------------------------ -// from dirent_uri.h - -static bool -dirent_is_root( - const char * dirent, - apr_size_t len); - -//------------------------------------------------------------------------------ -// from svn_props.h - -static error_t -neon_get_props_resource( - neon_resource_t ** rsrc, - neon_session_t * sess, - const char * url, - const ne_propname * which_props, - bool check_errors, - apr_pool_t * pool); - -//------------------------------------------------------------------------------ -// from ra_loader.h - -// The RA layer vtable. -typedef struct vtable_t +//--------------------------------------------------------------------------- +void TWebDAVFileSystem::OpenUrl(const UnicodeString & Url) { - // Return a short description of the RA implementation, as a localized - // string. - const char * (*get_description)(void); - - // Return a list of actual URI schemes supported by this implementation. - // The returned array is NULL-terminated. - const char * const * (*get_schemes)(apr_pool_t * pool); - - // Implementations of the public API functions. - - // See session_open(). - // All fields in SESSION, except priv, have been initialized by the - // time this is called. SESSION->priv may be set by this function. - error_t (*open_session)(session_t * session, - const char ** corrected_url, - const char * session_URL, - const callbacks2_t * callbacks, - void * callback_baton, - apr_pool_t * pool); - // See reparent(). - // URL is guaranteed to have what get_webdav_resource_root() returns as a prefix. - error_t (*reparent)(session_t * session, - const char * url, - apr_pool_t * pool); - // See get_session_url(). - error_t (*get_session_url)(session_t * session, - const char ** url, - apr_pool_t * pool); - - // See get_file(). - error_t (*get_file)(session_t * session, - const char * path, - stream_t * stream, - apr_hash_t ** props, - apr_pool_t * pool); - // See get_dir2(). - error_t (*get_dir)(session_t * session, - apr_hash_t ** dirents, - const char * path, - apr_uint32_t dirent_fields, - apr_pool_t * pool); - // See check_path(). - error_t (*check_path)(session_t * session, - const char * path, - node_kind_t * kind, - apr_pool_t * pool); - // See stat(). - error_t (*stat)(session_t * session, - const char * path, - dirent_t ** dirent, - apr_pool_t * pool); - // See get_webdav_resource_root2(). - error_t (*get_webdav_resource_root)(session_t * session, - const char ** url, - apr_pool_t * pool); - // See has_capability(). - // error_t (*has_capability)(session_t *session, - // bool *has, - // const char *capability, - // apr_pool_t *pool); -} vtable_t; - -static error_t -get_path_relative_to_root( - session_t * session, - const char ** rel_path, - const char * url, - apr_pool_t * pool); - -static error_t -neon_init( - const vtable_t ** vtable, - apr_pool_t * pool); - -//------------------------------------------------------------------------------ -// from svn_ctype.h -// Table of flags for character classification. -extern const apr_uint32_t * const ctype_table; - -// Check if c is in the character class described by flags. -// The flags is a bitwise-or combination of WEBDAV_CTYPE_* -// constants. Uses #ctype_table. - -#define ctype_test(c, flags) \ - (0 != (ctype_table[(unsigned char)(c)] & (flags))) - -// Basic character classes -#define WEBDAV_CTYPE_CNTRL 0x0001 //< Control character -#define WEBDAV_CTYPE_SPACE 0x0002 //< Whitespace -#define WEBDAV_CTYPE_DIGIT 0x0004 //< Decimal digit -#define WEBDAV_CTYPE_UPPER 0x0008 //< Uppercase letter -#define WEBDAV_CTYPE_LOWER 0x0010 //< Lowercase letter -#define WEBDAV_CTYPE_PUNCT 0x0020 //< Punctuation mark -#define WEBDAV_CTYPE_XALPHA 0x0040 //< Hexadecimal digits A to F -#define WEBDAV_CTYPE_ASCII 0x0080 //< ASCII subset*/ - -// Derived character classes -// ASCII letter -#define WEBDAV_CTYPE_ALPHA (WEBDAV_CTYPE_LOWER | WEBDAV_CTYPE_UPPER) -// ASCII letter or decimal digit -#define WEBDAV_CTYPE_ALNUM (WEBDAV_CTYPE_ALPHA | WEBDAV_CTYPE_DIGIT) -// ASCII hexadecimal digit -#define WEBDAV_CTYPE_XDIGIT (WEBDAV_CTYPE_DIGIT | WEBDAV_CTYPE_XALPHA) -// Printable ASCII except space -#define WEBDAV_CTYPE_GRAPH (WEBDAV_CTYPE_PUNCT | WEBDAV_CTYPE_ALNUM) -// All printable ASCII -#define WEBDAV_CTYPE_PRINT (WEBDAV_CTYPE_GRAPH | WEBDAV_CTYPE_SPACE) - -// Check if c is an ASCII control character. -#define ctype_iscntrl(c) ctype_test((c), WEBDAV_CTYPE_CNTRL) - -// Check if c is an ASCII whitespace character. -#define ctype_isspace(c) ctype_test((c), WEBDAV_CTYPE_SPACE) - -// Check if c is an ASCII digit. -#define ctype_isdigit(c) ctype_test((c), WEBDAV_CTYPE_DIGIT) - -// Check if c is an ASCII uppercase letter. -#define ctype_isupper(c) ctype_test((c), WEBDAV_CTYPE_UPPER) - -// Check if c is an ASCII lowercase letter. -#define ctype_islower(c) ctype_test((c), WEBDAV_CTYPE_LOWER) - -// Check if c is an ASCII punctuation mark. -#define ctype_ispunct(c) ctype_test((c), WEBDAV_CTYPE_PUNCT) - -// Check if c is an ASCII character. -#define ctype_isascii(c) ctype_test((c), WEBDAV_CTYPE_ASCII) - -// Check if c is an ASCII letter. -#define ctype_isalpha(c) ctype_test((c), WEBDAV_CTYPE_ALPHA) - -// Check if c is an ASCII letter or decimal digit. -#define ctype_isalnum(c) ctype_test((c), WEBDAV_CTYPE_ALNUM) - -// Check if c is an ASCII hexadecimal digit. -#define ctype_isxdigit(c) ctype_test((c), WEBDAV_CTYPE_XDIGIT) - -// Check if c is an ASCII graphical (visible printable) character. -#define ctype_isgraph(c) ctype_test((c), WEBDAV_CTYPE_GRAPH) - -// Check if c is an ASCII printable character. -#define ctype_isprint(c) ctype_test((c), WEBDAV_CTYPE_PRINT) - -// Basic extended character classes -#define WEBDAV_CTYPE_UTF8LEAD 0x0100 //< UTF-8 multibyte lead byte -#define WEBDAV_CTYPE_UTF8CONT 0x0200 //< UTF-8 multibyte non-lead byte -#define WEBDAV_CTYPE_XMLNAME 0x0400 -#define WEBDAV_CTYPE_URISAFE 0x0800 - -// Derived extended character classes -// Part of a UTF-8 multibyte character. -#define WEBDAV_CTYPE_UTF8MBC (WEBDAV_CTYPE_UTF8LEAD | WEBDAV_CTYPE_UTF8CONT) -// All valid UTF-8 bytes. -#define WEBDAV_CTYPE_UTF8 (WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UTF8MBC) - -// Check if c is a UTF-8 multibyte lead byte. -#define ctype_isutf8lead(c) ctype_test((c), WEBDAV_CTYPE_UTF8LEAD) - -// Check if c is a UTF-8 multibyte continuation (non-lead) byte. -#define ctype_isutf8cont(c) ctype_test((c), WEBDAV_CTYLE_UTF8CONT) - -// Check if c is part of a UTF-8 multibyte character. -#define ctype_isutf8mbc(c) ctype_test((c), WEBDAV_CTYPE_UTF8MBC) - -// Check if c is valid in UTF-8. -#define ctype_isutf8(c) ctype_test((c), WEBDAV_CTYPE_UTF8) - -#define WEBDAV_CTYPE_ASCII_MINUS 45 //< ASCII value of '-' -#define WEBDAV_CTYPE_ASCII_DOT 46 //< ASCII value of '.' -#define WEBDAV_CTYPE_ASCII_COLON 58 //< ASCII value of ':' -#define WEBDAV_CTYPE_ASCII_UNDERSCORE 95 //< ASCII value of '_' -#define WEBDAV_CTYPE_ASCII_TAB 9 //< ASCII value of a tab -#define WEBDAV_CTYPE_ASCII_LINEFEED 10 //< ASCII value of a line feed -#define WEBDAV_CTYPE_ASCII_CARRIAGERETURN 13 -//< ASCII value of a carriage return -#define WEBDAV_CTYPE_ASCII_DELETE 127 -//< ASCII value of a delete character - -/* - * Compare two characters a and b, treating case-equivalent - * unaccented Latin (ASCII subset) letters as equal. - * - * Returns in integer greater than, equal to, or less than 0, - * according to whether a is considered greater than, equal to, - * or less than b. - */ - -static int -ctype_casecmp(int a, int b); + UnicodeString CorrectedUrl; + NeonClientOpenSessionInternal(CorrectedUrl, Url); -//------------------------------------------------------------------------------ -// from svn_string.c - -static APR_INLINE bool -string_compare( - const char * str1, - const char * str2, - apr_size_t len1, - apr_size_t len2) + if (CorrectedUrl.IsEmpty()) + { + CorrectedUrl = Url; + } + AnsiString ParsedPath = ParsePathFromUrl(CorrectedUrl); + if (!ParsedPath.IsEmpty()) + { + // this is most likely pointless as it get overwritten by + // call to ChangeDirectory() from TTerminal::DoStartup + FCurrentDirectory = ParsedPath; + } +} +//--------------------------------------------------------------------------- +void TWebDAVFileSystem::NeonClientOpenSessionInternal(UnicodeString & CorrectedUrl, UnicodeString Url) { - // easy way out :) - if (len1 != len2) - return FALSE; - - // now the strings must have identical lengths + std::unique_ptr AttemptedUrls(new TStringList()); + AttemptedUrls->Sorted = true; + int AttemptsLeft = MAX_REDIRECT_ATTEMPTS; + while (true) + { + CorrectedUrl = L""; + NeonOpen(CorrectedUrl, Url); + // No error and no corrected URL? We're done here. + if (CorrectedUrl.IsEmpty()) + { + break; + } + if (AttemptsLeft == 0) + { + throw Exception(LoadStr(TOO_MANY_REDIRECTS)); + } + else + { + CloseNeonSession(); + AttemptsLeft--; + // Our caller will want to know what our final corrected URL was. + // Make sure we've not attempted this URL before. + if (AttemptedUrls->IndexOf(CorrectedUrl) >= 0) + { + throw Exception(LoadStr(REDIRECT_LOOP)); + } + AttemptedUrls->Add(CorrectedUrl); + Url = CorrectedUrl; + } + } - if ((memcmp(str1, str2, len1)) == 0) - return TRUE; - else - return FALSE; + CorrectedUrl = Url; } - -// Our own realloc, since APR doesn't have one. Note: this is a -// generic realloc for memory pools, *not* for strings. -static void * -my_realloc( - char * data, - apr_size_t oldsize, - apr_size_t request, - apr_pool_t * pool) +//--------------------------------------------------------------------------- +void TWebDAVFileSystem::NeonOpen(UnicodeString & CorrectedUrl, const UnicodeString & Url) { - void * new_area = NULL; + ne_uri uri; + if (ne_uri_parse(StrToNeon(Url), &uri) != 0) + { + // should never happen + throw Exception(FMTLOAD(INVALID_URL, (Url))); + } - // todo: it's a pity APR doesn't give us this -- sometimes it - // could realloc the block merely by extending in place, sparing us - // a memcpy(), but only the pool would know enough to be able to do - // this. We should add a realloc() to APR if someone hasn't - // already. + // Will never happen for initial URL, but may happen for redirect URLs + if (uri.port == 0) + { + uri.port = ne_uri_defaultport(uri.scheme); + } - // malloc new area - new_area = apr_pcalloc(pool, request); + TSessionData * Data = FTerminal->SessionData; - // copy data to new area - memcpy(new_area, data, oldsize); + assert(FNeonSession == NULL); + FNeonSession = ne_session_create(uri.scheme, uri.host, uri.port); + UTF8String Path = uri.path; + ne_uri_free(&uri); + ne_set_session_private(FNeonSession, SESSION_FS_KEY, this); - // I'm NOT freeing old area here -- cuz we're using pools, ugh. + // Other flags: + // NE_DBG_FLUSH - used only in native implementation of ne_debug + // NE_DBG_HTTPPLAIN - log credentials in HTTP authentication - // return new area - return new_area; -} + ne_debug_mask = + NE_DBG_SOCKET | + NE_DBG_HTTP | + NE_DBG_XML | // detail + NE_DBG_HTTPAUTH | + NE_DBG_LOCKS | // very details + NE_DBG_XMLPARSE | // very details + NE_DBG_HTTPBODY | // very details + NE_DBG_SSL; -// string functions + if (Data->ProxyMethod != ::pmNone) + { + if ((Data->ProxyMethod == pmSocks4) || (Data->ProxyMethod == pmSocks5)) + { + enum ne_sock_sversion vers = (Data->ProxyMethod == pmSocks4) ? NE_SOCK_SOCKSV4A : NE_SOCK_SOCKSV5; + ne_session_socks_proxy(FNeonSession, vers, StrToNeon(Data->ProxyHost), Data->ProxyPort, StrToNeon(Data->ProxyUsername), StrToNeon(Data->ProxyPassword)); + } + else if (!Data->ProxyHost.IsEmpty()) + { + ne_session_proxy(FNeonSession, StrToNeon(Data->ProxyHost), Data->ProxyPort); -static stringbuf_t * -stringbuf_create_ensure( - apr_size_t blocksize, - apr_pool_t * pool) -{ - void * mem = NULL; - stringbuf_t * new_string = NULL; + if (!Data->ProxyUsername.IsEmpty()) + { + ne_set_proxy_auth(FNeonSession, NeonProxyAuth, this); + } + else + { + // Enable (only) the Negotiate scheme for proxy + // authentication, if no username/password is + // configured. + ne_add_proxy_auth(FNeonSession, NE_AUTH_NEGOTIATE, NULL, NULL); + } + } + } - // apr_pcalloc will allocate multiples of 8. - // Thus, we would waste some of that memory if we stuck to the - // smaller size. Note that this is safe even if apr_pcalloc would - // use some other alignment or none at all. + ne_set_read_timeout(FNeonSession, Data->Timeout); - ++blocksize; // + space for '\0' - blocksize = APR_ALIGN_DEFAULT(blocksize); + ne_set_connect_timeout(FNeonSession, Data->Timeout); - // Allocate memory for string_t and data in one chunk. - mem = apr_pcalloc(pool, sizeof(*new_string) + blocksize); + ne_redirect_register(FNeonSession); - // Initialize header and string - new_string = static_cast(mem); + ne_set_useragent(FNeonSession, StrToNeon(FORMAT(L"%s/%s", (AppNameString(), Configuration->Version)))); - new_string->data = (char *)mem + sizeof(*new_string); - new_string->data[0] = '\0'; - new_string->len = 0; - new_string->blocksize = blocksize; - new_string->pool = pool; + unsigned int NeonAuthTypes = NE_AUTH_BASIC | NE_AUTH_DIGEST; + if (Data->Ftps != ftpsNone) + { + NeonAuthTypes |= NE_AUTH_NEGOTIATE; + } + ne_add_server_auth(FNeonSession, NeonAuthTypes, NeonRequestAuth, this); - return new_string; -} + if (Data->Ftps != ftpsNone) + { + // When the CA certificate or server certificate has + // verification problems, neon will call our verify function before + // outright rejection of the connection. + ne_ssl_set_verify(FNeonSession, NeonServerSSLCallback, this); -static stringbuf_t * -stringbuf_ncreate( - const char * bytes, - apr_size_t size, - apr_pool_t * pool) -{ - stringbuf_t * strbuf = stringbuf_create_ensure(size, pool); - memcpy(strbuf->data, bytes, size); + ne_ssl_trust_default_ca(FNeonSession); + } - // Null termination is the convention -- even if we suspect the data - // to be binary, it's not up to us to decide, it's the caller's - // call. Heck, that's why they call it the caller! - strbuf->data[size] = '\0'; - strbuf->len = size; + ne_set_notifier(FNeonSession, NeonNotifier, this); + ne_hook_create_request(FNeonSession, NeonCreateRequest, this); + ne_hook_pre_send(FNeonSession, NeonPreSend, this); + ne_hook_post_send(FNeonSession, NeonPostSend, this); - return strbuf; + TValueRestorer Restorer(FInitialHandshake); + FInitialHandshake = true; + FAuthenticationRequested = false; + ExchangeCapabilities(Path.c_str(), CorrectedUrl); } - -static stringbuf_t * -stringbuf_create( - const char * cstring, - apr_pool_t * pool) +//--------------------------------------------------------------------------- +UnicodeString __fastcall TWebDAVFileSystem::GetRedirectUrl() { - return stringbuf_ncreate(cstring, strlen(cstring), pool); -} - -static void -stringbuf_ensure( - stringbuf_t * str, - apr_size_t minimum_size) -{ - // Keep doubling capacity until have enough. - if (str->blocksize < minimum_size) - { - if (str->blocksize == 0) - // APR will increase odd allocation sizes to the next - // multiple for 8, for instance. Take advantage of that - // knowledge and allow for the extra size to be used. - str->blocksize = APR_ALIGN_DEFAULT(minimum_size); - else - while (str->blocksize < minimum_size) - { - // str->blocksize is aligned; - // doubling it should keep it aligned - apr_size_t prev_size = str->blocksize; - str->blocksize *= 2; - - // check for apr_size_t overflow - if (prev_size > str->blocksize) - { - str->blocksize = minimum_size; - break; - } - } - - str->data = (char *) my_realloc(str->data, - str->len + 1, - // We need to maintain (and thus copy) - // the trailing null - str->blocksize, - str->pool); - } -} - -static void -stringbuf_set( - stringbuf_t * str, - const char * value) -{ - apr_size_t amt = strlen(value); - - stringbuf_ensure(str, amt + 1); - memcpy(str->data, value, amt + 1); - str->len = amt; -} - -static void -stringbuf_setempty( - stringbuf_t * str) -{ - if (str->len > 0) - str->data[0] = '\0'; - - str->len = 0; -} - -static bool -stringbuf_isempty( - const stringbuf_t * str) -{ - return (str->len == 0); -} - -// Return a new string_t object, allocated in POOL, initialized with -// DATA and SIZE. Do not copy the contents of DATA, just store the pointer. -// SIZE is the length in bytes of DATA, excluding the required NUL -// terminator. -static string_t * -create_string( - const char * data, - apr_size_t size, - apr_pool_t * pool) -{ - string_t * new_string; - - new_string = static_cast(apr_pcalloc(pool, sizeof(*new_string))); - - new_string->data = data; - new_string->len = size; - - return new_string; -} - -static string_t * -string_ncreate( - const char * bytes, - apr_size_t size, - apr_pool_t * pool) -{ - void * mem = NULL; - char * data = NULL; - string_t * new_string; - - // Allocate memory for string_t and data in one chunk. - mem = apr_pcalloc(pool, sizeof(*new_string) + size + 1); - data = (char *)mem + sizeof(*new_string); - - new_string = static_cast(mem); - new_string->data = data; - new_string->len = size; - - memcpy(data, bytes, size); - - // Null termination is the convention -- even if we suspect the data - // to be binary, it's not up to us to decide, it's the caller's - // call. Heck, that's why they call it the caller! - data[size] = '\0'; - - return new_string; -} - -static string_t * -string_create( - const char * cstring, - apr_pool_t * pool) -{ - return string_ncreate(cstring, strlen(cstring), pool); -} - -static string_t * -string_createv( - apr_pool_t * pool, - const char * fmt, - va_list ap) -{ - char * data = apr_pvsprintf(pool, fmt, ap); - - // wrap an string_t around the new data - return create_string(data, strlen(data), pool); -} - -static string_t * -string_createf( - apr_pool_t * pool, - const char * fmt, - ...) -{ - string_t * str = NULL; - - va_list ap; - va_start(ap, fmt); - str = string_createv(pool, fmt, ap); - va_end(ap); - - return str; -} - -static bool -string_compare( - const string_t * str1, - const string_t * str2) -{ - return - string_compare(str1->data, str2->data, str1->len, str2->len); -} - -static void -stringbuf_appendbytes( - stringbuf_t * str, - const char * bytes, - apr_size_t count) -{ - apr_size_t total_len = 0; - void * start_address = NULL; - - total_len = str->len + count; // total size needed - - // +1 for null terminator. - stringbuf_ensure(str, (total_len + 1)); - - // get address 1 byte beyond end of original bytestring - start_address = (str->data + str->len); - - memcpy(start_address, bytes, count); - str->len = total_len; - - str->data[str->len] = '\0'; // We don't know if this is binary - // data or not, but convention is - // to null-terminate. -} - -static void -stringbuf_appendstr( - stringbuf_t * targetstr, - const stringbuf_t * appendstr) -{ - stringbuf_appendbytes(targetstr, appendstr->data, appendstr->len); -} - -static void -stringbuf_appendcstr( - stringbuf_t * targetstr, - const char * cstr) -{ - stringbuf_appendbytes(targetstr, cstr, strlen(cstr)); -} - -static error_t -cstring_strtoi64( - apr_int64_t * n, - const char * str, - apr_int64_t minval, - apr_int64_t maxval, - int base) -{ - apr_int64_t val = 0; - char * endptr = NULL; - - // We assume errno is thread-safe. - errno = 0; // APR-0.9 doesn't always set errno - - val = apr_strtoi64(str, &endptr, base); - if (errno == EINVAL || endptr == str || str[0] == '\0' || *endptr != '\0') - return error_createf(WEBDAV_ERR_INCORRECT_PARAMS, NULL, - "Could not convert '%s' into a number", - str); - if ((errno == ERANGE && (val == APR_INT64_MIN || val == APR_INT64_MAX)) || - val < minval || val > maxval) - // Mark this for translation when gettext doesn't choke on macros. - return error_createf(WEBDAV_ERR_INCORRECT_PARAMS, NULL, - "Number '%s' is out of range " - "'[%" APR_INT64_T_FMT ", %" APR_INT64_T_FMT "]'", - str, minval, maxval); - *n = val; - return WEBDAV_NO_ERROR; -} - -static error_t -cstring_atoi64( - apr_int64_t * n, - const char * str) -{ - return error_trace(cstring_strtoi64(n, str, APR_INT64_MIN, - APR_INT64_MAX, 10)); -} - -static int -cstring_casecmp( - const char * str1, - const char * str2) -{ - for (;;) - { - const int a = *str1++; - const int b = *str2++; - const int cmp = ctype_casecmp(a, b); - if (cmp || !a || !b) - return cmp; - } -} - -static stringbuf_t * -create_stringbuf( - char * data, - apr_size_t size, - apr_size_t blocksize, - apr_pool_t * pool) -{ - stringbuf_t * new_string; - - new_string = static_cast(apr_pcalloc(pool, sizeof(*new_string))); - - new_string->data = data; - new_string->len = size; - new_string->blocksize = blocksize; - new_string->pool = pool; - - return new_string; -} - -static stringbuf_t * -stringbuf_createv( - apr_pool_t * pool, - const char * fmt, - va_list ap) -{ - char * data = apr_pvsprintf(pool, fmt, ap); - apr_size_t size = strlen(data); - - // wrap an stringbuf_t around the new data - return create_stringbuf(data, size, size + 1, pool); -} - -static stringbuf_t * -stringbuf_createf( - apr_pool_t * pool, - const char * fmt, - ...) -{ - stringbuf_t * str = NULL; - - va_list ap; - va_start(ap, fmt); - str = stringbuf_createv(pool, fmt, ap); - va_end(ap); - - return str; -} - -static void -cstring_split_append( - apr_array_header_t * array, - const char * input, - const char * sep_chars, - bool chop_whitespace, - apr_pool_t * pool) -{ - char * last = NULL; - - char * pats = apr_pstrdup(pool, input); // strtok wants non-const data - char * p = apr_strtok(pats, sep_chars, &last); - - while (p) - { - if (chop_whitespace) - { - while (ctype_isspace(*p)) - p++; - - { - char * e = p + (strlen(p) - 1); - while ((e >= p) && (ctype_isspace(*e))) - e--; - *(++e) = '\0'; - } - } - - if (p[0] != '\0') - APR_ARRAY_PUSH(array, const char *) = p; - - p = apr_strtok(NULL, sep_chars, &last); - } - - return; -} - -static apr_array_header_t * -cstring_split( - const char * input, - const char * sep_chars, - bool chop_whitespace, - apr_pool_t * pool) -{ - apr_array_header_t * a = apr_array_make(pool, 5, sizeof(input)); - cstring_split_append(a, input, sep_chars, chop_whitespace, pool); - return a; -} - -//------------------------------------------------------------------------------ -// from ctype.c -static const apr_uint32_t ctype_table_internal[256] = -{ - // **** DO NOT EDIT! **** - // This table was generated by genctype.py, make changes there. - /* nul */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* soh */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* stx */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* etx */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* eot */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* enq */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* ack */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* bel */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* bs */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* ht */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL | WEBDAV_CTYPE_SPACE, - /* nl */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL | WEBDAV_CTYPE_SPACE, - /* vt */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL | WEBDAV_CTYPE_SPACE, - /* np */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL | WEBDAV_CTYPE_SPACE, - /* cr */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL | WEBDAV_CTYPE_SPACE, - /* so */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* si */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* dle */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* dc1 */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* dc2 */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* dc3 */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* dc4 */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* nak */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* syn */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* etb */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* can */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* em */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* sub */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* esc */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* fs */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* gs */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* rs */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* us */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* sp */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_SPACE, - /* ! */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* " */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* # */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* $ */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* % */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* & */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* ' */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* ( */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* ) */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* * */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* + */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* , */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* - */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* . */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* / */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* 0 */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_DIGIT, - /* 1 */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_DIGIT, - /* 2 */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_DIGIT, - /* 3 */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_DIGIT, - /* 4 */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_DIGIT, - /* 5 */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_DIGIT, - /* 6 */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_DIGIT, - /* 7 */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_DIGIT, - /* 8 */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_DIGIT, - /* 9 */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_DIGIT, - /* : */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* ; */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* < */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* = */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* > */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* ? */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* @ */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* A */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER | WEBDAV_CTYPE_XALPHA, - /* B */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER | WEBDAV_CTYPE_XALPHA, - /* C */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER | WEBDAV_CTYPE_XALPHA, - /* D */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER | WEBDAV_CTYPE_XALPHA, - /* E */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER | WEBDAV_CTYPE_XALPHA, - /* F */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER | WEBDAV_CTYPE_XALPHA, - /* G */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER, - /* H */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER, - /* I */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER, - /* J */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER, - /* K */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER, - /* L */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER, - /* M */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER, - /* N */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER, - /* O */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER, - /* P */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER, - /* Q */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER, - /* R */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER, - /* S */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER, - /* T */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER, - /* U */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER, - /* V */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER, - /* W */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER, - /* X */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER, - /* Y */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER, - /* Z */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_UPPER, - /* [ */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* \ */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* ] */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* ^ */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* _ */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* ` */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* a */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER | WEBDAV_CTYPE_XALPHA, - /* b */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER | WEBDAV_CTYPE_XALPHA, - /* c */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER | WEBDAV_CTYPE_XALPHA, - /* d */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER | WEBDAV_CTYPE_XALPHA, - /* e */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER | WEBDAV_CTYPE_XALPHA, - /* f */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER | WEBDAV_CTYPE_XALPHA, - /* g */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER, - /* h */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER, - /* i */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER, - /* j */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER, - /* k */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER, - /* l */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER, - /* m */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER, - /* n */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER, - /* o */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER, - /* p */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER, - /* q */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER, - /* r */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER, - /* s */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER, - /* t */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER, - /* u */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER, - /* v */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER, - /* w */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER, - /* x */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER, - /* y */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER, - /* z */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_LOWER, - /* { */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* | */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* } */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* ~ */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_PUNCT, - /* del */ WEBDAV_CTYPE_ASCII | WEBDAV_CTYPE_CNTRL, - /* x80 */ WEBDAV_CTYPE_UTF8CONT, - /* x81 */ WEBDAV_CTYPE_UTF8CONT, - /* x82 */ WEBDAV_CTYPE_UTF8CONT, - /* x83 */ WEBDAV_CTYPE_UTF8CONT, - /* x84 */ WEBDAV_CTYPE_UTF8CONT, - /* x85 */ WEBDAV_CTYPE_UTF8CONT, - /* x86 */ WEBDAV_CTYPE_UTF8CONT, - /* x87 */ WEBDAV_CTYPE_UTF8CONT, - /* x88 */ WEBDAV_CTYPE_UTF8CONT, - /* x89 */ WEBDAV_CTYPE_UTF8CONT, - /* x8a */ WEBDAV_CTYPE_UTF8CONT, - /* x8b */ WEBDAV_CTYPE_UTF8CONT, - /* x8c */ WEBDAV_CTYPE_UTF8CONT, - /* x8d */ WEBDAV_CTYPE_UTF8CONT, - /* x8e */ WEBDAV_CTYPE_UTF8CONT, - /* x8f */ WEBDAV_CTYPE_UTF8CONT, - /* x90 */ WEBDAV_CTYPE_UTF8CONT, - /* x91 */ WEBDAV_CTYPE_UTF8CONT, - /* x92 */ WEBDAV_CTYPE_UTF8CONT, - /* x93 */ WEBDAV_CTYPE_UTF8CONT, - /* x94 */ WEBDAV_CTYPE_UTF8CONT, - /* x95 */ WEBDAV_CTYPE_UTF8CONT, - /* x96 */ WEBDAV_CTYPE_UTF8CONT, - /* x97 */ WEBDAV_CTYPE_UTF8CONT, - /* x98 */ WEBDAV_CTYPE_UTF8CONT, - /* x99 */ WEBDAV_CTYPE_UTF8CONT, - /* x9a */ WEBDAV_CTYPE_UTF8CONT, - /* x9b */ WEBDAV_CTYPE_UTF8CONT, - /* x9c */ WEBDAV_CTYPE_UTF8CONT, - /* x9d */ WEBDAV_CTYPE_UTF8CONT, - /* x9e */ WEBDAV_CTYPE_UTF8CONT, - /* x9f */ WEBDAV_CTYPE_UTF8CONT, - /* xa0 */ WEBDAV_CTYPE_UTF8CONT, - /* xa1 */ WEBDAV_CTYPE_UTF8CONT, - /* xa2 */ WEBDAV_CTYPE_UTF8CONT, - /* xa3 */ WEBDAV_CTYPE_UTF8CONT, - /* xa4 */ WEBDAV_CTYPE_UTF8CONT, - /* xa5 */ WEBDAV_CTYPE_UTF8CONT, - /* xa6 */ WEBDAV_CTYPE_UTF8CONT, - /* xa7 */ WEBDAV_CTYPE_UTF8CONT, - /* xa8 */ WEBDAV_CTYPE_UTF8CONT, - /* xa9 */ WEBDAV_CTYPE_UTF8CONT, - /* xaa */ WEBDAV_CTYPE_UTF8CONT, - /* xab */ WEBDAV_CTYPE_UTF8CONT, - /* xac */ WEBDAV_CTYPE_UTF8CONT, - /* xad */ WEBDAV_CTYPE_UTF8CONT, - /* xae */ WEBDAV_CTYPE_UTF8CONT, - /* xaf */ WEBDAV_CTYPE_UTF8CONT, - /* xb0 */ WEBDAV_CTYPE_UTF8CONT, - /* xb1 */ WEBDAV_CTYPE_UTF8CONT, - /* xb2 */ WEBDAV_CTYPE_UTF8CONT, - /* xb3 */ WEBDAV_CTYPE_UTF8CONT, - /* xb4 */ WEBDAV_CTYPE_UTF8CONT, - /* xb5 */ WEBDAV_CTYPE_UTF8CONT, - /* xb6 */ WEBDAV_CTYPE_UTF8CONT, - /* xb7 */ WEBDAV_CTYPE_UTF8CONT, - /* xb8 */ WEBDAV_CTYPE_UTF8CONT, - /* xb9 */ WEBDAV_CTYPE_UTF8CONT, - /* xba */ WEBDAV_CTYPE_UTF8CONT, - /* xbb */ WEBDAV_CTYPE_UTF8CONT, - /* xbc */ WEBDAV_CTYPE_UTF8CONT, - /* xbd */ WEBDAV_CTYPE_UTF8CONT, - /* xbe */ WEBDAV_CTYPE_UTF8CONT, - /* xbf */ WEBDAV_CTYPE_UTF8CONT, - /* xc0 */ 0, - /* xc1 */ WEBDAV_CTYPE_UTF8LEAD, - /* xc2 */ WEBDAV_CTYPE_UTF8LEAD, - /* xc3 */ WEBDAV_CTYPE_UTF8LEAD, - /* xc4 */ WEBDAV_CTYPE_UTF8LEAD, - /* xc5 */ WEBDAV_CTYPE_UTF8LEAD, - /* xc6 */ WEBDAV_CTYPE_UTF8LEAD, - /* xc7 */ WEBDAV_CTYPE_UTF8LEAD, - /* xc8 */ WEBDAV_CTYPE_UTF8LEAD, - /* xc9 */ WEBDAV_CTYPE_UTF8LEAD, - /* xca */ WEBDAV_CTYPE_UTF8LEAD, - /* xcb */ WEBDAV_CTYPE_UTF8LEAD, - /* xcc */ WEBDAV_CTYPE_UTF8LEAD, - /* xcd */ WEBDAV_CTYPE_UTF8LEAD, - /* xce */ WEBDAV_CTYPE_UTF8LEAD, - /* xcf */ WEBDAV_CTYPE_UTF8LEAD, - /* xd0 */ WEBDAV_CTYPE_UTF8LEAD, - /* xd1 */ WEBDAV_CTYPE_UTF8LEAD, - /* xd2 */ WEBDAV_CTYPE_UTF8LEAD, - /* xd3 */ WEBDAV_CTYPE_UTF8LEAD, - /* xd4 */ WEBDAV_CTYPE_UTF8LEAD, - /* xd5 */ WEBDAV_CTYPE_UTF8LEAD, - /* xd6 */ WEBDAV_CTYPE_UTF8LEAD, - /* xd7 */ WEBDAV_CTYPE_UTF8LEAD, - /* xd8 */ WEBDAV_CTYPE_UTF8LEAD, - /* xd9 */ WEBDAV_CTYPE_UTF8LEAD, - /* xda */ WEBDAV_CTYPE_UTF8LEAD, - /* xdb */ WEBDAV_CTYPE_UTF8LEAD, - /* xdc */ WEBDAV_CTYPE_UTF8LEAD, - /* xdd */ WEBDAV_CTYPE_UTF8LEAD, - /* xde */ WEBDAV_CTYPE_UTF8LEAD, - /* xdf */ WEBDAV_CTYPE_UTF8LEAD, - /* xe0 */ 0, - /* xe1 */ WEBDAV_CTYPE_UTF8LEAD, - /* xe2 */ WEBDAV_CTYPE_UTF8LEAD, - /* xe3 */ WEBDAV_CTYPE_UTF8LEAD, - /* xe4 */ WEBDAV_CTYPE_UTF8LEAD, - /* xe5 */ WEBDAV_CTYPE_UTF8LEAD, - /* xe6 */ WEBDAV_CTYPE_UTF8LEAD, - /* xe7 */ WEBDAV_CTYPE_UTF8LEAD, - /* xe8 */ WEBDAV_CTYPE_UTF8LEAD, - /* xe9 */ WEBDAV_CTYPE_UTF8LEAD, - /* xea */ WEBDAV_CTYPE_UTF8LEAD, - /* xeb */ WEBDAV_CTYPE_UTF8LEAD, - /* xec */ WEBDAV_CTYPE_UTF8LEAD, - /* xed */ WEBDAV_CTYPE_UTF8LEAD, - /* xee */ WEBDAV_CTYPE_UTF8LEAD, - /* xef */ WEBDAV_CTYPE_UTF8LEAD, - /* xf0 */ 0, - /* xf1 */ WEBDAV_CTYPE_UTF8LEAD, - /* xf2 */ WEBDAV_CTYPE_UTF8LEAD, - /* xf3 */ WEBDAV_CTYPE_UTF8LEAD, - /* xf4 */ WEBDAV_CTYPE_UTF8LEAD, - /* xf5 */ WEBDAV_CTYPE_UTF8LEAD, - /* xf6 */ WEBDAV_CTYPE_UTF8LEAD, - /* xf7 */ WEBDAV_CTYPE_UTF8LEAD, - /* xf8 */ 0, - /* xf9 */ WEBDAV_CTYPE_UTF8LEAD, - /* xfa */ WEBDAV_CTYPE_UTF8LEAD, - /* xfb */ WEBDAV_CTYPE_UTF8LEAD, - /* xfc */ 0, - /* xfd */ WEBDAV_CTYPE_UTF8LEAD, - /* xfe */ 0, - /* xff */ 0 -}; - -const apr_uint32_t * const ctype_table = ctype_table_internal; - -static const unsigned char casefold_table[256] = -{ - // Identity, except {97:122} => {65:90} - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, - 96, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,123,124,125,126,127, - 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, - 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, - 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175, - 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, - 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207, - 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223, - 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, - 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255 -}; - -static int -ctype_casecmp(int a, int b) -{ - const int A = casefold_table[(unsigned char)a]; - const int B = casefold_table[(unsigned char)b]; - return A - B; -} - -//------------------------------------------------------------------------------ -// from svn_pool.c - -// Pool allocation handler which just aborts, since we aren't generally -// prepared to deal with out-of-memory errors. - -static int -abort_on_pool_failure(int retcode) -{ - // Don't translate this string! It requires memory allocation to do so! - // And we don't have any of it... - printf("Out of memory - terminating application.\n"); - abort(); -} - -static apr_pool_t * -pool_create_ex( - apr_pool_t * parent_pool, - apr_allocator_t * allocator) -{ - apr_pool_t * pool; - apr_pool_create_ex(&pool, parent_pool, abort_on_pool_failure, allocator); - return pool; -} - -//------------------------------------------------------------------------------ -// from time.c - -#define OLD_TIMESTAMP_FORMAT \ - "%3s %d %3s %d %02d:%02d:%02d.%06d (day %03d, dst %d, gmt_off %06d)" - -static apr_size_t -find_matching_string( - char * str, - apr_size_t size, - const char strings[][4]) -{ - for (apr_size_t i = 0; i < size; i++) - if (strings[i] && (strcmp(str, strings[i]) == 0)) - return i; - - return (apr_size_t)-1; -} - -static error_t -time_from_cstring( - apr_time_t * when, - const char * data, - apr_pool_t * pool) -{ - apr_time_exp_t exploded_time; - apr_status_t apr_err = 0; - char wday[4] = {0}, month[4] = {0}; - char * c = NULL; - - // Open-code parsing of the new timestamp format, as this - // is a hot path for reading the entries file. This format looks - // like: "2001-08-31T04:24:14.966996Z" - exploded_time.tm_year = strtol(data, &c, 10); - if (*c++ != '-') goto fail; - exploded_time.tm_mon = strtol(c, &c, 10); - if (*c++ != '-') goto fail; - exploded_time.tm_mday = strtol(c, &c, 10); - if (*c++ != 'T') goto fail; - exploded_time.tm_hour = strtol(c, &c, 10); - if (*c++ != ':') goto fail; - exploded_time.tm_min = strtol(c, &c, 10); - if (*c++ != ':') goto fail; - exploded_time.tm_sec = strtol(c, &c, 10); - if (*c != 'Z') - { - if (*c++ != '.') goto fail; - exploded_time.tm_usec = strtol(c, &c, 10); - if (*c++ != 'Z') goto fail; - } - - exploded_time.tm_year -= 1900; - exploded_time.tm_mon -= 1; - exploded_time.tm_wday = 0; - exploded_time.tm_yday = 0; - exploded_time.tm_isdst = 0; - exploded_time.tm_gmtoff = 0; - - apr_err = apr_time_exp_gmt_get(when, &exploded_time); - if (apr_err == APR_SUCCESS) - return WEBDAV_NO_ERROR; - - return error_createf(WEBDAV_ERR_BAD_DATE, NULL, "error parsing date: %s", data); - -fail: - - // 2012-09-11T14:18:40+07:00 - char gmt_shift = 0; - int gmt_hour = 0; - int gmt_min = 0; - if (sscanf(data, - "%04d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d", - &exploded_time.tm_year, - &exploded_time.tm_mon, - &exploded_time.tm_mday, - &exploded_time.tm_hour, - &exploded_time.tm_min, - &exploded_time.tm_sec, - &gmt_shift, - &gmt_hour, - &gmt_min) == 9) - { - exploded_time.tm_year -= 1900; - exploded_time.tm_mon -= 1; - exploded_time.tm_wday = 0; - exploded_time.tm_yday = 0; - exploded_time.tm_isdst = 0; - exploded_time.tm_gmtoff = (gmt_shift == '-' ? -1 : 1) * gmt_hour * SecsPerHour + gmt_min * SecsPerMin; - exploded_time.tm_usec = 0; - - apr_err = apr_time_exp_gmt_get(when, &exploded_time); - if (apr_err != APR_SUCCESS) - return error_createf(WEBDAV_ERR_BAD_DATE, NULL, "error parsing date: %s", data); - - return WEBDAV_NO_ERROR; - } - - // 2012-09-11T03:56:20 - if (sscanf(data, - "%04d-%02d-%02dT%02d:%02d:%02d", - &exploded_time.tm_year, - &exploded_time.tm_mon, - &exploded_time.tm_mday, - &exploded_time.tm_hour, - &exploded_time.tm_min, - &exploded_time.tm_sec) == 6) - { - exploded_time.tm_year -= 1900; - exploded_time.tm_mon -= 1; - exploded_time.tm_wday = 0; - exploded_time.tm_yday = 0; - exploded_time.tm_isdst = 0; - exploded_time.tm_gmtoff = 0; - exploded_time.tm_usec = 0; - - apr_err = apr_time_exp_gmt_get(when, &exploded_time); - if (apr_err != APR_SUCCESS) - return error_createf(WEBDAV_ERR_BAD_DATE, NULL, "error parsing date: %s", data); - - return WEBDAV_NO_ERROR; - } - - // Try the compatibility option. This does not need to be fast, - // as this format is no longer generated and the client will convert - // an old-format entries file the first time it reads it. - if (sscanf(data, - OLD_TIMESTAMP_FORMAT, - wday, - &exploded_time.tm_mday, - month, - &exploded_time.tm_year, - &exploded_time.tm_hour, - &exploded_time.tm_min, - &exploded_time.tm_sec, - &exploded_time.tm_usec, - &exploded_time.tm_yday, - &exploded_time.tm_isdst, - &exploded_time.tm_gmtoff) == 11) - { - exploded_time.tm_year -= 1900; - exploded_time.tm_yday -= 1; - // Using hard coded limits for the arrays - they are going away - // soon in any case. - exploded_time.tm_wday = (apr_int32_t)find_matching_string(wday, 7, apr_day_snames); - exploded_time.tm_mon = (apr_int32_t)find_matching_string(month, 12, apr_month_snames); - - apr_err = apr_time_exp_gmt_get(when, &exploded_time); - if (apr_err != APR_SUCCESS) - return error_createf(WEBDAV_ERR_BAD_DATE, NULL, "error parsing date: %s", data); - - return WEBDAV_NO_ERROR; - } - - // Timestamp is something we do not recognize. - // return error_createf(WEBDAV_ERR_BAD_DATE, NULL, "error parsing date: %s", data); - *when = apr_time_now(); - return WEBDAV_NO_ERROR; -} - -//------------------------------------------------------------------------------ -// from path.c - -// TRUE if s is the canonical empty path, FALSE otherwise -#define WEBDAV_PATH_IS_EMPTY(s) ((s)[0] == '\0') - -// TRUE if s,n is the platform's empty path ("."), FALSE otherwise. Can -// this be changed? Well, the path library will work, not so sure about -// the OS! -#define WEBDAV_PATH_IS_PLATFORM_EMPTY(s,n) ((n) == 1 && (s)[0] == '.') - -/* Here is the BNF for path components in a URI. "pchar" is a - character in a path component. - - pchar = unreserved | escaped | - ":" | "@" | "&" | "=" | "+" | "$" | "," - unreserved = alphanum | mark - mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")" - - Note that "escaped" doesn't really apply to what users can put in - their paths, so that really means the set of characters is: - - alphanum | mark | ":" | "@" | "&" | "=" | "+" | "$" | "," -*/ -static const char uri_char_validity[256] = -{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, - - // 64 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, - - // 128 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - // 192 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; - -// URI-encode each character c in PATH for which TABLE[c] is 0. -// If no encoding was needed, return PATH, else return a new string allocated -// in POOL. -static const char * -uri_escape( - const char * path, - const char table[], - apr_pool_t * pool) -{ - stringbuf_t * retstr = NULL; - size_t i = 0, copied = 0; - int c = 0; - - retstr = stringbuf_create_ensure(strlen(path), pool); - for (i = 0; path[i]; i++) - { - c = (unsigned char)path[i]; - if (table[c]) - continue; - - // If we got here, we're looking at a character that isn't - // supported by the (or at least, our) URI encoding scheme. We - // need to escape this character. - - // First things first, copy all the good stuff that we haven't - // yet copied into our output buffer. - if (i - copied) - stringbuf_appendbytes(retstr, path + copied, - i - copied); - - // Now, write in our escaped character, consisting of the - // '%' and two digits. We cast the C to unsigned char here because - // the 'X' format character will be tempted to treat it as an unsigned - // int...which causes problem when messing with 0x80-0xFF chars. - // We also need space for a null as apr_snprintf will write one. - stringbuf_ensure(retstr, retstr->len + 4); - apr_snprintf(retstr->data + retstr->len, 4, "%%%02X", (unsigned char)c); - retstr->len += 3; - - // Finally, update our copy counter. - copied = i + 1; - } - - // If we didn't encode anything, we don't need to duplicate the string. - if (retstr->len == 0) - return path; - - // Anything left to copy? - if (i - copied) - stringbuf_appendbytes(retstr, path + copied, i - copied); - - // retstr is null-terminated either by apr_snprintf or the stringbuf - // functions. - - return retstr->data; -} - -static const char * -path_uri_decode( - const char * path, - apr_pool_t * pool) -{ - stringbuf_t * retstr = NULL; - size_t i = 0; - bool query_start = FALSE; - - // avoid repeated realloc - retstr = stringbuf_create_ensure(strlen(path) + 1, pool); - - retstr->len = 0; - for (i = 0; path[i]; i++) - { - char c = path[i]; - - if (c == '?') - { - // Mark the start of the query string, if it exists. - query_start = TRUE; - } - else if (c == '+' && query_start) - { - // Only do this if we are into the query string. - // RFC 2396, section 3.3 - c = ' '; - } - else if (c == '%' && ctype_isxdigit(path[i + 1]) && ctype_isxdigit(path[i+2])) - { - char digitz[3]; - digitz[0] = path[++i]; - digitz[1] = path[++i]; - digitz[2] = '\0'; - c = (char)(strtol(digitz, NULL, 16)); - } - - retstr->data[retstr->len++] = c; - } - - // Null-terminate this bad-boy. - retstr->data[retstr->len] = 0; - - return retstr->data; -} - -static const char * -path_uri_encode( - const char * path, - apr_pool_t * pool) -{ - const char * ret = uri_escape(path, uri_char_validity, pool); - - // Our interface guarantees a copy. - if (ret == path) - return apr_pstrdup(pool, path); - else - return ret; -} - -static char * -path_join( - const char * base, - const char * component, - apr_pool_t * pool) -{ - apr_size_t blen = strlen(base); - apr_size_t clen = strlen(component); - char * path = NULL; - - // assert(path_is_canonical(base, pool)); - // assert(path_is_canonical(component, pool)); - - // If the component is absolute, then return it. - if (*component == '/') - return (char *)apr_pmemdup(pool, component, clen + 1); - - // If either is empty return the other - if (WEBDAV_PATH_IS_EMPTY(base)) - return (char *)apr_pmemdup(pool, component, clen + 1); - if (WEBDAV_PATH_IS_EMPTY(component)) - return (char *)apr_pmemdup(pool, base, blen + 1); - - if ((blen == 1) && (base[0] == '/')) - blen = 0; // Ignore base, just return separator + component - - // Construct the new, combined path. - path = (char *)apr_pcalloc(pool, blen + 1 + clen + 1); - memcpy(path, base, blen); - path[blen] = '/'; - memcpy(path + blen + 1, component, clen + 1); - - return path; -} - -static const char * -path_url_add_component2( - const char * url, - const char * component, - apr_pool_t * pool) -{ - // = path_uri_encode() but without always copying - component = uri_escape(component, uri_char_validity, pool); - - return path_join(url, component, pool); -} - -// Get APR's internal path encoding. -static error_t -get_path_encoding( - bool * path_is_utf8, - apr_pool_t * pool) -{ - apr_status_t apr_err = 0; - int encoding_style = 0; - - apr_err = apr_filepath_encoding(&encoding_style, pool); - if (apr_err) - return error_wrap_apr(apr_err, - "Can't determine the native path encoding"); - - // What to do about APR_FILEPATH_ENCODING_UNKNOWN? - // Well, for now we'll just punt to the utf_ functions; - // those will at least do the ASCII-subset check. - *path_is_utf8 = (encoding_style == APR_FILEPATH_ENCODING_UTF8); - return WEBDAV_NO_ERROR; -} - -static error_t -path_cstring_to_utf8( - const char ** path_utf8, - const char * path_apr, - apr_pool_t * pool) -{ - bool path_is_utf8 = FALSE; - WEBDAV_ERR(get_path_encoding(&path_is_utf8, pool)); - if (path_is_utf8) - { - *path_utf8 = apr_pstrdup(pool, path_apr); - return WEBDAV_NO_ERROR; - } - else - return utf_cstring_to_utf8(path_utf8, path_apr, pool); -} - -static apr_size_t -path_component_count( - const char * path) -{ - if (!path) return 0; - apr_size_t count = 0; - - while (*path) - { - const char * start; - - while (*path == '/') - ++path; - - start = path; - - while (*path && (*path != '/')) - ++path; - - if (path != start) - ++count; - } - - return count; -} - -// Return the length of substring necessary to encompass the entire -// previous path segment in PATH, which should be a LEN byte string. -// A trailing slash will not be included in the returned length except -// in the case in which PATH is absolute and there are no more -// previous segments. - -static apr_size_t -previous_segment( - const char * path, - apr_size_t len) -{ - if (len == 0) - return 0; - - while ((len > 0) && (path[--len] != '/')) - ; - - if ((len == 0) && (path[0] == '/')) - return 1; - else - return len; -} - -static void -path_remove_component( - stringbuf_t * path) -{ - path->len = previous_segment(path->data, path->len); - path->data[path->len] = '\0'; -} - -static void -path_remove_components( - stringbuf_t * path, - apr_size_t n) -{ - while (n > 0) - { - path_remove_component(path); - n--; - } -} - -static error_t -path_cstring_from_utf8( - const char ** path_apr, - const char * path_utf8, - apr_pool_t * pool) -{ - bool path_is_utf8 = FALSE; - WEBDAV_ERR(get_path_encoding(&path_is_utf8, pool)); - if (path_is_utf8) - { - *path_apr = apr_pstrdup(pool, path_utf8); - return WEBDAV_NO_ERROR; - } - else - return utf_cstring_from_utf8(path_apr, path_utf8, pool); -} - -static bool -path_is_backpath_present( - const char * path) -{ - size_t len; - - // 0 and 1-length paths do not have a backpath - if ((path[0] == '\0') || (path[1] == '\0')) - return FALSE; - - // Handle ".." or a leading "../" - if ((path[0] == '.') && (path[1] == '.') && ((path[2] == '\0') || (path[2] == '/'))) - return TRUE; - - // Paths of length 2 (at this point) have no backpath present. - if (path[2] == '\0') - return FALSE; - - // If any segment is "..", then a backpath is present. - if (strstr(path, "/../") != NULL) - return TRUE; - - // Does the path end in "/.." ? - len = strlen(path); - return (path[len - 3] == '/') && (path[len - 2] == '.') && (path[len - 1] == '.'); -} - -//------------------------------------------------------------------------------ -// from svn_client.h - -typedef error_t (*client_list_func_t)( - void * baton, - const char * path, - const dirent_t * dirent, - const char * abs_path, - apr_pool_t * pool); - -typedef struct client_ctx_t -{ - auth_baton_t * auth_baton; - - cancel_func_t cancel_func; - void * cancel_baton; - - progress_notify_func_t progress_func; - void * progress_baton; - const char * client_name; -} client_ctx_t; - -//------------------------------------------------------------------------------ -// from win32_xlate.c - -static apr_status_t -subr_win32_xlate_to_stringbuf(// win32_xlate_t *handle, - const char * src_data, - apr_size_t src_length, - stringbuf_t ** dest, - apr_pool_t * pool) -{ - WCHAR * wide_str = NULL; - int retval = 0, wide_size = 0; - - if (src_length == 0) - { - *dest = stringbuf_create("", pool); - return APR_SUCCESS; - } - int from_page_id = CP_ACP; - retval = MultiByteToWideChar(from_page_id, // CP_UTF8, // handle->from_page_id, - 0, src_data, (int)src_length, NULL, 0); - if (retval == 0) - return apr_get_os_error(); - - wide_size = retval; - - // Allocate temporary buffer for small strings on stack instead of heap. - if (wide_size <= MAX_PATH) - { - wide_str = static_cast(alloca(wide_size * sizeof(WCHAR))); - } - else - { - wide_str = static_cast(apr_pcalloc(pool, wide_size * sizeof(WCHAR))); - } - - retval = MultiByteToWideChar(from_page_id, // handle->from_page_id, - 0, src_data, (int)src_length, wide_str, wide_size); - - if (retval == 0) - return apr_get_os_error(); - - int to_page_id = CP_UTF8; - retval = WideCharToMultiByte(to_page_id, // handle->to_page_id, - 0, wide_str, wide_size, NULL, 0, NULL, NULL); - - if (retval == 0) - return apr_get_os_error(); - - // Ensure that buffer is enough to hold result string and termination - // character. - *dest = stringbuf_create_ensure(retval + 1, pool); - (*dest)->len = retval; - - retval = WideCharToMultiByte(to_page_id, // handle->to_page_id, - 0, wide_str, wide_size, (*dest)->data, (int)(*dest)->len, NULL, NULL); - if (retval == 0) - return apr_get_os_error(); - - (*dest)->len = retval; - return APR_SUCCESS; -} - -static apr_status_t -utf8_to_unicode( - WCHAR ** retstr, - const char * srcstr, - apr_pool_t * pool) -{ - /*apr_size_t retlen = 0; - apr_size_t srcremains = strlen(srcstr) + 1; - *retstr = static_cast(apr_pcalloc(pool, srcremains * 4)); - apr_status_t rv; - if (rv = apr_conv_utf8_to_ucs2(srcstr, &srcremains, *retstr, &retlen)) { - return (rv == APR_INCOMPLETE) ? APR_EINVAL : rv; - } - if (srcremains) { - return APR_ENAMETOOLONG; - }*/ - WCHAR * wide_str = NULL; - int retval = 0, wide_size = 0; - apr_size_t src_length = strlen(srcstr); - - if (src_length == 0) - { - *retstr = L""; - return APR_SUCCESS; - } - - retval = MultiByteToWideChar(CP_UTF8, // handle->from_page_id, - 0, srcstr, (int)src_length, NULL, 0); - if (retval == 0) - return apr_get_os_error(); - - wide_size = retval; - - wide_str = static_cast(apr_pcalloc(pool, (wide_size + 1) * sizeof(WCHAR))); - - retval = MultiByteToWideChar(CP_UTF8, // handle->from_page_id, - 0, srcstr, (int)src_length, wide_str, wide_size); - - if (retval == 0) - return apr_get_os_error(); - - *retstr = wide_str; - (*retstr)[wide_size] = L'\0'; - return APR_SUCCESS; -} - -//------------------------------------------------------------------------------ -// from utf.c - -// Verify that the sequence DATA of length LEN is valid UTF-8. -// If it is not, return an error with code APR_EINVAL. -static error_t -check_utf8( - const char * data, - apr_size_t len, - apr_pool_t * pool) -{ - // TODO: if (!utf_is_valid(data, len))) - // return invalid_utf8(data, len, pool); - return WEBDAV_NO_ERROR; -} - -// Convert SRC_LENGTH bytes of SRC_DATA in NODE->handle, store the result -// in *DEST, which is allocated in POOL. -static error_t -convert_to_stringbuf(// xlate_handle_node_t *node, - const char * src_data, - apr_size_t src_length, - stringbuf_t ** dest, - apr_pool_t * pool) -{ - apr_status_t apr_err = 0; - - apr_err = subr_win32_xlate_to_stringbuf(// (win32_xlate_t *) node->handle, - src_data, src_length, - dest, pool); - - // If we exited the loop with an error, return the error. - if (apr_err) - { - const char * errstr = NULL; - error_t err = 0; - - // Can't use error_wrap_apr here because it calls functions in - // this file, leading to infinite recursion. - errstr = apr_psprintf(pool, "Can't convert string"); // from native encoding to '%s':"), - - err = error_create(apr_err, NULL, ""); - return error_create(apr_err, &err, errstr); - } - // Else, exited due to success. Trim the result buffer down to the - // right length. - (*dest)->data[(*dest)->len] = '\0'; - - return WEBDAV_NO_ERROR; -} - -// Common implementation for utf_cstring_to_utf8, -// utf_cstring_to_utf8_ex, utf_cstring_from_utf8 and -// utf_cstring_from_utf8_ex. Convert SRC to DEST using NODE->handle as -// the translator and allocating from POOL. -static error_t -convert_cstring( - const char ** dest, - const char * src, - apr_pool_t * pool) -{ - stringbuf_t * destbuf; - WEBDAV_ERR(convert_to_stringbuf(// node, - src, strlen(src), &destbuf, pool)); - *dest = destbuf->data; - return WEBDAV_NO_ERROR; -} - -// Verify that the NULL terminated sequence DATA is valid UTF-8. -// If it is not, return an error with code APR_EINVAL. -static error_t -check_cstring_utf8( - const char * data, - apr_pool_t * pool) -{ - - // TODO: if (!utf_cstring_is_valid(data)) - // return invalid_utf8(data, strlen(data), pool); - return WEBDAV_NO_ERROR; -} - -static error_t -utf_cstring_to_utf8( - const char ** dest, - const char * src, - apr_pool_t * pool) -{ - // TODO: implement - error_t err = convert_cstring(dest, src, // node, - pool); - WEBDAV_ERR(err); - return check_cstring_utf8(*dest, pool); -} - -static error_t -utf_cstring_from_utf8( - const char ** dest, - const char * src, - apr_pool_t * pool) -{ - WEBDAV_ERR(check_utf8(src, strlen(src), pool)); - - error_t err = convert_cstring(dest, src, pool); - return err; -} - -//------------------------------------------------------------------------------ -// from xml.c - -static const char * -xml_get_attr_value( - const char * name, - const char ** atts) -{ - while (atts && (*atts)) - { - if (strcmp(atts[0], name) == 0) - return atts[1]; - else - atts += 2; // continue looping - } - - // Else no such attribute name seen. - return NULL; -} - -//------------------------------------------------------------------------------ -// from apr_base64.c - -static const char basis_64[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -// This is the same as apr_base64_encode() except on EBCDIC machines, where -// the conversion of the input to ascii is left out. - -static int -apr_base64_encode_binary( - char * encoded, - const unsigned char * string, - int len) -{ - int i; - char * p; - - p = encoded; - for (i = 0; i < len - 2; i += 3) - { - *p++ = basis_64[(string[i] >> 2) & 0x3F]; - *p++ = basis_64[((string[i] & 0x3) << 4) | - ((int)(string[i + 1] & 0xF0) >> 4)]; - *p++ = basis_64[((string[i + 1] & 0xF) << 2) | - ((int)(string[i + 2] & 0xC0) >> 6)]; - *p++ = basis_64[string[i + 2] & 0x3F]; - } - if (i < len) - { - *p++ = basis_64[(string[i] >> 2) & 0x3F]; - if (i == (len - 1)) - { - *p++ = basis_64[((string[i] & 0x3) << 4)]; - *p++ = '='; - } - else - { - *p++ = basis_64[((string[i] & 0x3) << 4) | - ((int)(string[i + 1] & 0xF0) >> 4)]; - *p++ = basis_64[((string[i + 1] & 0xF) << 2)]; - } - *p++ = '='; - } - - *p++ = '\0'; - return (int)(p - encoded); -} - -static int -apr_base64_encode( - char * encoded, - const char * string, - int len) -{ - return apr_base64_encode_binary(encoded, (const unsigned char *) string, len); -} - -static int -apr_base64_encode_len(int len) -{ - return ((len + 2) / 3 * 4) + 1; -} - -// aaaack but it's fast and const should make it shared text page. -static const unsigned char pr2six[256] = -{ - // ASCII table - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64, - 64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 64, - 64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 -}; - -static int -apr_base64_decode_len( - const char * bufcoded) -{ - int nbytesdecoded; - register const unsigned char * bufin; - register apr_size_t nprbytes; - - bufin = (const unsigned char *) bufcoded; - while (pr2six[*(bufin++)] <= 63); - - nprbytes = (bufin - (const unsigned char *) bufcoded) - 1; - nbytesdecoded = (((int)nprbytes + 3) / 4) * 3; - - return nbytesdecoded + 1; -} - -// This is the same as apr_base64_decode() except on EBCDIC machines, where -// the conversion of the output to ebcdic is left out. - -static int -apr_base64_decode_binary( - unsigned char * bufplain, - const char * bufcoded) -{ - int nbytesdecoded; - register const unsigned char * bufin; - register unsigned char * bufout; - register apr_size_t nprbytes; - - bufin = (const unsigned char *) bufcoded; - while (pr2six[*(bufin++)] <= 63); - nprbytes = (bufin - (const unsigned char *) bufcoded) - 1; - nbytesdecoded = (((int)nprbytes + 3) / 4) * 3; - - bufout = (unsigned char *) bufplain; - bufin = (const unsigned char *) bufcoded; - - while (nprbytes > 4) - { - *(bufout++) = - (unsigned char)((pr2six[*bufin] << 2) | (pr2six[bufin[1]] >> 4)); - *(bufout++) = - (unsigned char)((pr2six[bufin[1]] << 4) | (pr2six[bufin[2]] >> 2)); - *(bufout++) = - (unsigned char)((pr2six[bufin[2]] << 6) | pr2six[bufin[3]]); - bufin += 4; - nprbytes -= 4; - } - - // Note: (nprbytes == 1) would be an error, so just ignore that case - if (nprbytes > 1) - { - *(bufout++) = - (unsigned char)((pr2six[*bufin] << 2) | (pr2six[bufin[1]] >> 4)); - } - if (nprbytes > 2) - { - *(bufout++) = - (unsigned char)((pr2six[bufin[1]] << 4) | (pr2six[bufin[2]] >> 2)); - } - if (nprbytes > 3) - { - *(bufout++) = - (unsigned char)((pr2six[bufin[2]] << 6) | pr2six[bufin[3]]); - } - - nbytesdecoded -= (4 - (int)nprbytes) & 3; - return nbytesdecoded; -} - -static int -apr_base64_decode( - char * bufplain, - const char * bufcoded) -{ - int len = apr_base64_decode_binary((unsigned char *) bufplain, bufcoded); - bufplain[len] = '\0'; - return len; -} - -//--------------------------------------------------------------------------- -// from user.c - -// Get the current user's name from the OS -static const char * -get_os_username( - apr_pool_t * pool) -{ -#if APR_HAS_USER - char * username; - apr_uid_t uid; - apr_gid_t gid; - - if (apr_uid_current(&uid, &gid, pool) == APR_SUCCESS && - apr_uid_name_get(&username, uid, pool) == APR_SUCCESS) - return username; -#endif - - return NULL; -} - -// Return a UTF8 version of STR, or NULL on error. -// Use POOL for any necessary allocation. -static const char * -utf8_or_nothing( - const char * str, - apr_pool_t * pool) -{ - if (str) - { - const char * utf8_str; - error_t err = utf_cstring_to_utf8(&utf8_str, str, pool); - if (!err) - return utf8_str; - error_clear(&err); - } - return NULL; -} - -static const char * -user_get_name( - apr_pool_t * pool) -{ - const char * username = get_os_username(pool); - return utf8_or_nothing(username, pool); -} - -//--------------------------------------------------------------------------- -// from sorts.c - -typedef struct sort_item_t -{ - const void * key; - apr_ssize_t klen; - void * value; -} sort_item_t; - -static int -sort_compare_items_lexically( - const sort_item_t * a, - const sort_item_t * b) -{ - // Compare bytes of a's key and b's key up to the common length. - apr_size_t len = (a->klen < b->klen) ? a->klen : b->klen; - int val = memcmp(a->key, b->key, len); - if (val != 0) - return val; - - // They match up until one of them ends; whichever is longer is greater. - return (a->klen < b->klen) ? -1 : (a->klen > b->klen) ? 1 : 0; -} - -static apr_array_header_t * -sort_hash(apr_hash_t * ht, - int (*comparison_func)(const sort_item_t *, - const sort_item_t *), - apr_pool_t * pool) -{ - apr_array_header_t * ary = NULL; - bool sorted = FALSE; - sort_item_t * prev_item = NULL; - - // allocate an array with enough elements to hold all the keys. - ary = apr_array_make(pool, apr_hash_count(ht), sizeof(sort_item_t)); - - // loop over hash table and push all keys into the array - sorted = TRUE; - prev_item = NULL; - for (apr_hash_index_t * hi = apr_hash_first(pool, ht); hi; - hi = apr_hash_next(hi)) - { - sort_item_t * item = static_cast(apr_array_push(ary)); - - apr_hash_this(hi, &item->key, &item->klen, &item->value); - - if (prev_item == NULL) - { - prev_item = item; - continue; - } - - if (sorted) - { - sorted = (comparison_func(prev_item, item) < 0); - prev_item = item; - } - } - - // quicksort the array if it isn't already sorted. - if (!sorted) - qsort(ary->elts, ary->nelts, ary->elt_size, - (int ( *)(const void *, const void *))comparison_func); - - return ary; -} - -//--------------------------------------------------------------------------- -// from svn_config.h - -#define WEBDAV_CONFIG_TRUE "TRUE" -#define WEBDAV_CONFIG_FALSE "FALSE" -#define WEBDAV_CONFIG_ASK "ASK" - -// Default values for some options. Should be passed as default values -// to config_get and friends, instead of hard-coding the defaults in -// multiple places. -#define WEBDAV_CONFIG_DEFAULT_OPTION_STORE_PASSWORDS TRUE -#define WEBDAV_CONFIG_DEFAULT_OPTION_STORE_PLAINTEXT_PASSWORDS WEBDAV_CONFIG_ASK -#define WEBDAV_CONFIG_DEFAULT_OPTION_STORE_AUTH_CREDS TRUE -#define WEBDAV_CONFIG_DEFAULT_OPTION_STORE_SSL_CLIENT_CERT_PP TRUE -#define WEBDAV_CONFIG_DEFAULT_OPTION_STORE_SSL_CLIENT_CERT_PP_PLAINTEXT \ - WEBDAV_CONFIG_ASK - -//--------------------------------------------------------------------------- -// from svn_auth.h - -// Certificate is not yet valid. -#define WEBDAV_AUTH_SSL_NOTYETVALID 0x00000001 -// Certificate has expired. -#define WEBDAV_AUTH_SSL_EXPIRED 0x00000002 -// Certificate's CN (hostname) does not match the remote hostname. -#define WEBDAV_AUTH_SSL_CNMISMATCH 0x00000004 -// Certificate authority is unknown (i.e. not trusted) -#define WEBDAV_AUTH_SSL_UNKNOWNCA 0x00000008 -// Other failure. This can happen if neon has introduced a new -// failure bit that we do not handle yet. -#define WEBDAV_AUTH_SSL_OTHER 0x40000000 - -#define AUTH_CRED_SSL_CLIENT_CERT_PW "ssl.client-passphrase" -#define AUTH_CRED_SSL_CLIENT_CERT "ssl.client-cert" - -// The auth-hash prefix indicating that the parameter is global. -#define AUTH_PARAM_PREFIX "webdav:auth:" - -// The following property is for SSL server cert providers. This -// provides a pointer to an apr_uint32_t containing the failures -// detected by the certificate validator. -#define AUTH_PARAM_SSL_SERVER_FAILURES AUTH_PARAM_PREFIX \ - "ssl:failures" - -// The following property is for SSL server cert providers. This -// provides the cert info (auth_ssl_server_cert_info_t). -#define AUTH_PARAM_SSL_SERVER_CERT_INFO AUTH_PARAM_PREFIX \ - "ssl:cert-info" - -#define AUTH_CRED_SSL_SERVER_TRUST "webdav.ssl.server" - -#define AUTH_CRED_SIMPLE "webdav.simple" -#define WEBDAV_AUTH_CRED_USERNAME "webdav.username" - -#define WEBDAV_AUTH_PARAM_DEFAULT_USERNAME AUTH_PARAM_PREFIX "username" -#define WEBDAV_AUTH_PARAM_DEFAULT_PASSWORD AUTH_PARAM_PREFIX "password" -#define WEBDAV_AUTH_PARAM_NON_INTERACTIVE AUTH_PARAM_PREFIX "non-interactive" -#define WEBDAV_AUTH_PARAM_DONT_STORE_PASSWORDS AUTH_PARAM_PREFIX \ - "dont-store-passwords" -#define WEBDAV_AUTH_PARAM_STORE_PLAINTEXT_PASSWORDS AUTH_PARAM_PREFIX \ - "store-plaintext-passwords" -#define WEBDAV_AUTH_PARAM_DONT_STORE_SSL_CLIENT_CERT_PP \ - AUTH_PARAM_PREFIX "dont-store-ssl-client-cert-pp" -#define WEBDAV_AUTH_PARAM_STORE_SSL_CLIENT_CERT_PP_PLAINTEXT \ - AUTH_PARAM_PREFIX "store-ssl-client-cert-pp-plaintext" -#define WEBDAV_AUTH_PARAM_NO_AUTH_CACHE AUTH_PARAM_PREFIX "no-auth-cache" - -#define WEBDAV_AUTH_SIMPLE_PASSWORD_TYPE "simple" -#define WEBDAV_AUTH_WINCRYPT_PASSWORD_TYPE "wincrypt" - -// This effectively defines a single table. Every provider in this -// array returns the same kind of credentials. -typedef struct provider_set_t -{ - // ordered array of auth_provider_object_t - apr_array_header_t * providers; - -} provider_set_t; - -// Abstracted iteration baton -struct auth_iterstate_t -{ - provider_set_t * table; // the table being searched - int provider_idx; // the current provider (row) - bool got_first; // did we get the provider's first creds? - void * provider_iter_baton; // the provider's own iteration context - const char * realmstring; // The original realmstring passed in - const char * cache_key; // key to use in auth_baton's creds_cache - auth_baton_t * auth_baton; // the original auth_baton. -}; - -// The main auth baton. -typedef struct auth_baton_t -{ - // a collection of tables. maps cred_kind -> provider_set - apr_hash_t * tables; - - // the pool I'm allocated in. - apr_pool_t * pool; - - // run-time parameters needed by providers. - apr_hash_t * parameters; - - // run-time credentials cache. - apr_hash_t * creds_cache; -} auth_baton_t; - -// The main authentication "provider" vtable. -typedef struct auth_provider_t -{ - // The kind of credentials this provider knows how to retrieve. - const char * cred_kind; - - error_t (*first_credentials)(void ** credentials, - void ** iter_baton, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool); - - error_t (*next_credentials)(void ** credentials, - void * iter_baton, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool); - - error_t (*save_credentials)(bool * saved, - void * credentials, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool); - -} auth_provider_t; - -// A provider object, ready to be put into an array and given to -// create_baton_open(). -typedef struct auth_provider_object_t -{ - const auth_provider_t * vtable; - void * provider_baton; - -} auth_provider_object_t; - -typedef error_t (*auth_plaintext_prompt_func_t)( - bool * may_save_plaintext, - const char * realmstring, - void * baton, - apr_pool_t * pool); - -typedef error_t (*auth_password_get_t)( - bool * done, - const char ** password, - apr_hash_t * creds, - const char * realmstring, - const char * username, - apr_hash_t * parameters, - bool non_interactive, - apr_pool_t * pool); - -typedef struct auth_cred_simple_t -{ - // Username - const char * username; - // Password - const char * password; - bool may_save; -} auth_cred_simple_t; - -typedef struct auth_cred_username_t -{ - // Username - const char * username; - bool may_save; -} auth_cred_username_t; - -typedef error_t (*auth_password_set_t)( - bool * done, - apr_hash_t * creds, - const char * realmstring, - const char * username, - const char * password, - apr_hash_t * parameters, - bool non_interactive, - apr_pool_t * pool); - -// AUTH_CRED_SSL_CLIENT_CERT credentials. -typedef struct auth_cred_ssl_client_cert_t -{ - // Absolute path to the certificate file - const char * cert_file; - bool may_save; -} auth_cred_ssl_client_cert_t; - -typedef error_t (*auth_ssl_client_cert_prompt_func_t)( - auth_cred_ssl_client_cert_t ** cred, - void * baton, - const char * realm, - bool may_save, - apr_pool_t * pool); - -typedef error_t (*auth_plaintext_passphrase_prompt_func_t)( - bool * may_save_plaintext, - const char * realmstring, - void * baton, - apr_pool_t * pool); - -// AUTH_CRED_SSL_CLIENT_CERT_PW credentials. -typedef struct auth_cred_ssl_client_cert_pw_t -{ - // Certificate password - const char * password; - bool may_save; -} auth_cred_ssl_client_cert_pw_t; - -// AUTH_CRED_SSL_SERVER_TRUST credentials. -typedef struct auth_cred_ssl_server_trust_t -{ - bool may_save; - // Bit mask of the accepted failures - apr_uint32_t accepted_failures; -} auth_cred_ssl_server_trust_t; - -// SSL server certificate information used by -// AUTH_CRED_SSL_SERVER_TRUST providers. - -typedef struct auth_ssl_server_cert_info_t -{ - // Primary CN - const char * hostname; - // ASCII fingerprint - const char * fingerprint; - // ASCII date from which the certificate is valid - const char * valid_from; - // ASCII date until which the certificate is valid - const char * valid_until; - // DN of the certificate issuer - const char * issuer_dname; - // Base-64 encoded DER certificate representation - const char * ascii_cert; -} auth_ssl_server_cert_info_t; - -typedef error_t (*auth_ssl_client_cert_pw_prompt_func_t)( - auth_cred_ssl_client_cert_pw_t ** cred, - void * baton, - const char * realm, - bool may_save, - apr_pool_t * pool); - -typedef error_t (*auth_ssl_server_trust_prompt_func_t)( - auth_cred_ssl_server_trust_t ** cred, - void * baton, - const char * realm, - apr_uint32_t failures, - const auth_ssl_server_cert_info_t * cert_info, - bool may_save, - apr_pool_t * pool); - -typedef error_t (*auth_simple_prompt_func_t)( - auth_cred_simple_t ** cred, - void * baton, - const char * realm, - const char * username, - bool may_save, - apr_pool_t * pool); - -typedef error_t (*auth_username_prompt_func_t)( - auth_cred_username_t ** cred, - void * baton, - const char * realm, - bool may_save, - apr_pool_t * pool); - -//--------------------------------------------------------------------------- -// from config_auth.c - -#define CONST_FS_KEY "fs" -#define CONST_FINGERPRINT_KEY "fingerprint" - -// The keys that will be stored on disk. These serve the same role as -// similar constants in other providers. -#define AUTHN_ASCII_CERT_KEY "ascii_cert" -#define AUTHN_FAILURES_KEY "failures" - -static const char CertificateStorageKey[] = "HttpsCertificates"; - -static error_t -config_read_auth_data( - apr_hash_t ** hash, - const char * cred_kind, - const char * realmstring, - TWebDAVFileSystem * fs, - apr_pool_t * pool) -{ - const char * subkey = CertificateStorageKey; - THierarchicalStorage * Storage = NULL; - WEBDAV_ERR(fs->CreateStorage(Storage)); - assert(Storage); - std::unique_ptr StoragePtr; - StoragePtr.reset(Storage); - Storage->AccessMode = smRead; - if (!Storage->OpenSubKey(UnicodeString(subkey), false)) - return WEBDAV_ERR_BAD_PARAM; - - *hash = apr_hash_make(pool); - TStrings * Keys = new TStringList(); - try - { - Storage->GetValueNames(Keys); - for (int Index = 0; Index < Keys->Count; ++Index) - { - UnicodeString Key = Keys->Strings[Index]; - UnicodeString Value = Storage->ReadStringRaw(Key, L""); - apr_hash_set(*hash, AUTHN_ASCII_CERT_KEY, APR_HASH_KEY_STRING, - string_create(AnsiString(Key).c_str(), pool)); - apr_hash_set(*hash, AUTHN_FAILURES_KEY, APR_HASH_KEY_STRING, - string_createf(pool, "%lu", (unsigned long) - StrToIntDef(Value, 0))); - } - } - __finally - { - delete Keys; - } - return WEBDAV_NO_ERROR; -} - -static error_t -config_write_auth_data( - apr_hash_t * hash, - const char * cred_kind, - const char * realmstring, - TWebDAVFileSystem * fs, - apr_pool_t * pool) -{ - const char * subkey = CertificateStorageKey; - assert(fs); - THierarchicalStorage * Storage = NULL; - WEBDAV_ERR(fs->CreateStorage(Storage)); - assert(Storage); - std::unique_ptr StoragePtr; - StoragePtr.reset(Storage); - Storage->AccessMode = smReadWrite; - - if (!Storage->OpenSubKey(UnicodeString(subkey), true)) - return WEBDAV_ERR_BAD_PARAM; - string_t * trusted_cert = static_cast(apr_hash_get(hash, AUTHN_ASCII_CERT_KEY, - APR_HASH_KEY_STRING)); - string_t * failstr = static_cast(apr_hash_get(hash, AUTHN_FAILURES_KEY, - APR_HASH_KEY_STRING)); - if (trusted_cert && failstr) - Storage->WriteString(UnicodeString(trusted_cert->data), UnicodeString(failstr->data)); - return WEBDAV_NO_ERROR; -} - -//--------------------------------------------------------------------------- -// from simple_providers.c - -// The keys that will be stored on disk. These serve the same role as -// similar constants in other providers. -#define AUTHN_USERNAME_KEY "username" -#define AUTHN_PASSWORD_KEY "password" -#define AUTHN_PASSTYPE_KEY "passtype" - -// Baton type for the simple provider. -typedef struct simple_provider_baton_t -{ - auth_plaintext_prompt_func_t plaintext_prompt_func; - void * prompt_baton; - // We cache the user's answer to the plaintext prompt, keyed - // by realm, in case we'll be called multiple times for the - // same realm. - apr_hash_t * plaintext_answers; -} simple_provider_baton_t; - -// Implementation of auth_password_get_t that retrieves -// the plaintext password from CREDS. -static error_t -auth_simple_password_get( - bool * done, - const char ** password, - apr_hash_t * creds, - const char * realmstring, - const char * username, - apr_hash_t * parameters, - bool non_interactive, - apr_pool_t * pool) -{ - *done = FALSE; - - string_t * str = static_cast(apr_hash_get(creds, AUTHN_USERNAME_KEY, APR_HASH_KEY_STRING)); - if (str && username && strcmp(str->data, username) == 0) - { - str = static_cast(apr_hash_get(creds, AUTHN_PASSWORD_KEY, APR_HASH_KEY_STRING)); - if (str && str->data) - { - *password = str->data; - *done = TRUE; - } - } - return WEBDAV_NO_ERROR; -} - -// Implementation of auth_password_set_t that stores -// the plaintext password in CREDS. -static error_t -auth_simple_password_set( - bool * done, - apr_hash_t * creds, - const char * realmstring, - const char * username, - const char * password, - apr_hash_t * parameters, - bool non_interactive, - apr_pool_t * pool) -{ - apr_hash_set(creds, AUTHN_PASSWORD_KEY, APR_HASH_KEY_STRING, - string_create(password, pool)); - *done = TRUE; - return WEBDAV_NO_ERROR; -} - -// Set **USERNAME to the username retrieved from CREDS; ignore -// other parameters. *USERNAME will have the same lifetime as CREDS. -static bool -simple_username_get( - const char ** username, - apr_hash_t * creds, - const char * realmstring, - bool non_interactive) -{ - string_t * str = static_cast(apr_hash_get(creds, AUTHN_USERNAME_KEY, APR_HASH_KEY_STRING)); - if (str && str->data) - { - *username = str->data; - return TRUE; - } - return FALSE; -} - -// Common implementation for simple_first_creds. Uses PARAMETERS, REALMSTRING -// and the simple auth provider's username and password cache to fill a set of -// CREDENTIALS. PASSWORD_GET is used to obtain the password value. -// PASSTYPE identifies the type of the cached password. CREDENTIALS are -// allocated from POOL. -static error_t -auth_simple_first_creds_helper( - void ** credentials, - void ** iter_baton, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - auth_password_get_t password_get, - const char * passtype, - apr_pool_t * pool) -{ - const char * username = static_cast(apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_DEFAULT_USERNAME, - APR_HASH_KEY_STRING)); - const char * password = static_cast(apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_DEFAULT_PASSWORD, - APR_HASH_KEY_STRING)); - bool non_interactive = apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_NON_INTERACTIVE, - APR_HASH_KEY_STRING) != NULL; - const char * default_username = NULL; // Default username from cache. - const char * default_password = NULL; // Default password from cache. - - // This checks if we should save the CREDS, if saving the credentials is - // allowed by the run-time configuration. - bool need_to_save = FALSE; - apr_hash_t * creds_hash = NULL; - error_t err = 0; - - // Try to load credentials from a file on disk, based on the - // realmstring. Don't throw an error, though: if something went - // wrong reading the file, no big deal. What really matters is that - // we failed to get the creds, so allow the auth system to try the - // next provider. - TWebDAVFileSystem * fs = static_cast(apr_hash_get(parameters, - CONST_FS_KEY, - APR_HASH_KEY_STRING)); - assert(fs); - err = config_read_auth_data(&creds_hash, AUTH_CRED_SIMPLE, - realmstring, fs, pool); - if (err) - { - error_clear(&err); - err = NULL; - } - else if (creds_hash) - { - // We have something in the auth cache for this realm. - bool have_passtype = FALSE; - - // The password type in the auth data must match the - // mangler's type, otherwise the password must be - // interpreted by another provider. - string_t * str = static_cast(apr_hash_get(creds_hash, AUTHN_PASSTYPE_KEY, APR_HASH_KEY_STRING)); - if (str && str->data) - if (passtype && (0 == strcmp(str->data, passtype))) - have_passtype = TRUE; - - // See if we need to save this username if it is not present in - // auth cache. - if (username) - { - if (!simple_username_get(&default_username, creds_hash, realmstring, - non_interactive)) - { - need_to_save = TRUE; - } - else - { - if (0 == strcmp(default_username, username)) - need_to_save = FALSE; - else - need_to_save = TRUE; - } - } - - // See if we need to save this password if it is not present in - // auth cache. - if (password) - { - if (have_passtype) - { - bool done; - WEBDAV_ERR(password_get(&done, &default_password, creds_hash, realmstring, - username, parameters, non_interactive, pool)); - if (!done) - { - need_to_save = TRUE; - } - else - { - if (0 == strcmp(default_password, password)) - need_to_save = FALSE; - else - need_to_save = TRUE; - } - } - } - - // If we don't have a username and a password yet, we try the - // auth cache - if (!(username && password)) - { - if (!username) - if (!simple_username_get(&username, creds_hash, realmstring, - non_interactive)) - username = NULL; - - if (username && !password) - { - if (!have_passtype) - password = NULL; - else - { - bool done; - WEBDAV_ERR(password_get(&done, &password, creds_hash, realmstring, - username, parameters, non_interactive, - pool)); - if (!done) - password = NULL; - - // If the auth data didn't contain a password type, - // force a write to upgrade the format of the auth - // data file. - if (password && !have_passtype) - need_to_save = TRUE; - } - } - } - } - else - { - // Nothing was present in the auth cache, so indicate that these - // credentials should be saved. - need_to_save = TRUE; - } - - // Ask the OS for the username if we have a password but no username. - if (password && !username) - username = user_get_name(pool); - - if (username && password) - { - auth_cred_simple_t * creds = static_cast(apr_pcalloc(pool, sizeof(*creds))); - creds->username = username; - creds->password = password; - creds->may_save = need_to_save; - *credentials = creds; - } - else - *credentials = NULL; - - *iter_baton = NULL; - - return WEBDAV_NO_ERROR; -} - -// Common implementation for simple_save_creds. Uses PARAMETERS and -// REALMSTRING to save a set of CREDENTIALS to the simple auth provider's -// username and password cache. PASSWORD_SET is used to store the password. -// PASSTYPE identifies the type of the cached password. Allocates from POOL. -static error_t -auth_simple_save_creds_helper( - bool * saved, - void * credentials, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - auth_password_set_t password_set, - const char * passtype, - apr_pool_t * pool) -{ - auth_cred_simple_t * creds = static_cast(credentials); - apr_hash_t * creds_hash = NULL; - error_t err = 0; - bool dont_store_passwords = - apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_DONT_STORE_PASSWORDS, - APR_HASH_KEY_STRING) != NULL; - const char * store_plaintext_passwords = static_cast( - apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_STORE_PLAINTEXT_PASSWORDS, - APR_HASH_KEY_STRING)); - bool non_interactive = apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_NON_INTERACTIVE, - APR_HASH_KEY_STRING) != NULL; - simple_provider_baton_t * b = (simple_provider_baton_t *)provider_baton; - - bool no_auth_cache = (!creds->may_save) || - (apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_NO_AUTH_CACHE, - APR_HASH_KEY_STRING) != NULL); - - // Make sure we've been passed a passtype. - WEBDAV_ERR_ASSERT(passtype != NULL); - - *saved = FALSE; - - if (no_auth_cache) - return WEBDAV_NO_ERROR; - - // Put the username into the credentials hash. - creds_hash = apr_hash_make(pool); - apr_hash_set(creds_hash, AUTHN_USERNAME_KEY, APR_HASH_KEY_STRING, - string_create(creds->username, pool)); - - // Don't store passwords in any form if the user has told - // us not to do so. - if (!dont_store_passwords) - { - bool may_save_password = FALSE; - - // If the password is going to be stored encrypted, go right - // ahead and store it to disk. Else determine whether saving - // in plaintext is OK. - if (passtype && - (strcmp(passtype, WEBDAV_AUTH_WINCRYPT_PASSWORD_TYPE) == 0)) - { - may_save_password = TRUE; - } - else - { - if (store_plaintext_passwords && cstring_casecmp(store_plaintext_passwords, - WEBDAV_CONFIG_ASK) == 0) - { - if (non_interactive) - // In non-interactive mode, the default behaviour is - // to not store the password, because it is usually - // passed on the command line. - may_save_password = FALSE; - else if (b && b->plaintext_prompt_func) - { - // We're interactive, and the client provided a - // prompt callback. So we can ask the user. - // Check for a cached answer before prompting. - bool * cached_answer; - cached_answer = static_cast(apr_hash_get(b->plaintext_answers, - realmstring, - APR_HASH_KEY_STRING)); - if (cached_answer != NULL) - may_save_password = *cached_answer; - else - { - apr_pool_t * cached_answer_pool; - - // Nothing cached for this realm, prompt the user. - WEBDAV_ERR((*b->plaintext_prompt_func)(&may_save_password, - realmstring, - b->prompt_baton, - pool)); - - cached_answer_pool = apr_hash_pool_get(b->plaintext_answers); - cached_answer = static_cast(apr_pcalloc(cached_answer_pool, - sizeof(bool))); - *cached_answer = may_save_password; - apr_hash_set(b->plaintext_answers, realmstring, - APR_HASH_KEY_STRING, cached_answer); - } - } - else - { - may_save_password = TRUE; - } - } - else if (store_plaintext_passwords && cstring_casecmp(store_plaintext_passwords, - WEBDAV_CONFIG_FALSE) == 0) - { - may_save_password = FALSE; - } - else if (store_plaintext_passwords && cstring_casecmp(store_plaintext_passwords, - WEBDAV_CONFIG_TRUE) == 0) - { - may_save_password = TRUE; - } - else - { - /*return error_createf - (WEBDAV_ERR_BAD_CONFIG_VALUE, NULL, - "Config error: invalid value '%s' for option '%s'", - store_plaintext_passwords, - WEBDAV_AUTH_PARAM_STORE_PLAINTEXT_PASSWORDS);*/ - may_save_password = FALSE; - } - } - - if (may_save_password) - { - WEBDAV_ERR(password_set(saved, creds_hash, realmstring, - creds->username, creds->password, - parameters, non_interactive, pool)); - if (*saved && passtype) - // Store the password type with the auth data, so that we - // know which provider owns the password. - apr_hash_set(creds_hash, AUTHN_PASSTYPE_KEY, APR_HASH_KEY_STRING, - string_create(passtype, pool)); - } - } - - TWebDAVFileSystem * fs = static_cast(apr_hash_get(parameters, - CONST_FS_KEY, - APR_HASH_KEY_STRING)); - assert(fs); - // Save credentials to disk. - err = config_write_auth_data(creds_hash, AUTH_CRED_SIMPLE, - realmstring, fs, pool); - error_clear(&err); - - return WEBDAV_NO_ERROR; -} - -// Get cached (unencrypted) credentials from the simple provider's cache. -static error_t -simple_first_creds( - void ** credentials, - void ** iter_baton, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool) -{ - return auth_simple_first_creds_helper(credentials, - iter_baton, - provider_baton, - parameters, - realmstring, - auth_simple_password_get, - WEBDAV_AUTH_SIMPLE_PASSWORD_TYPE, - pool); -} - -// Save (unencrypted) credentials to the simple provider's cache. -static error_t -simple_save_creds( - bool * saved, - void * credentials, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool) -{ - return auth_simple_save_creds_helper(saved, credentials, - provider_baton, - parameters, - realmstring, - auth_simple_password_set, - WEBDAV_AUTH_SIMPLE_PASSWORD_TYPE, - pool); -} - -static const auth_provider_t simple_provider = -{ - AUTH_CRED_SIMPLE, - simple_first_creds, - NULL, - simple_save_creds -}; - -// Public API -static void -auth_get_simple_provider2( - auth_provider_object_t ** provider, - auth_plaintext_prompt_func_t plaintext_prompt_func, - void * prompt_baton, - apr_pool_t * pool) -{ - auth_provider_object_t * po = static_cast(apr_pcalloc(pool, sizeof(*po))); - simple_provider_baton_t * pb = static_cast(apr_pcalloc(pool, sizeof(*pb))); - - pb->plaintext_prompt_func = plaintext_prompt_func; - pb->prompt_baton = prompt_baton; - pb->plaintext_answers = apr_hash_make(pool); - - po->vtable = &simple_provider; - po->provider_baton = pb; - *provider = po; -} - -// Baton type for username/password prompting. -typedef struct simple_prompt_provider_baton_t -{ - auth_simple_prompt_func_t prompt_func; - void * prompt_baton; - - // how many times to re-prompt after the first one fails - int retry_limit; -} simple_prompt_provider_baton_t; - -// Iteration baton type for username/password prompting. -typedef struct simple_prompt_iter_baton_t -{ - // how many times we've reprompted - int retries; -} simple_prompt_iter_baton_t; - -// Helper Functions -static error_t -prompt_for_simple_creds( - auth_cred_simple_t ** cred_p, - simple_prompt_provider_baton_t * pb, - apr_hash_t * parameters, - const char * realmstring, - bool first_time, - bool may_save, - apr_pool_t * pool) -{ - const char * default_username = NULL; - const char * default_password = NULL; - - *cred_p = NULL; - - // If we're allowed to check for default usernames and passwords, do so. - if (first_time) - { - default_username = static_cast(apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_DEFAULT_USERNAME, - APR_HASH_KEY_STRING)); - - // No default username? Try the auth cache. - if (!default_username) - { - apr_hash_t * creds_hash = NULL; - string_t * str; - error_t err; - - TWebDAVFileSystem * fs = static_cast(apr_hash_get(parameters, - CONST_FS_KEY, - APR_HASH_KEY_STRING)); - assert(fs); - err = config_read_auth_data(&creds_hash, AUTH_CRED_SIMPLE, - realmstring, fs, pool); - error_clear(&err); - if (!err && creds_hash) - { - str = static_cast(apr_hash_get(creds_hash, AUTHN_USERNAME_KEY, - APR_HASH_KEY_STRING)); - if (str && str->data) - default_username = str->data; - } - } - - // Still no default username? Try the 'servers' file. - if (!default_username) - { - default_username = NULL; - } - - // Still no default username? Try the UID. - if (!default_username) - default_username = user_get_name(pool); - - default_password = static_cast(apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_DEFAULT_PASSWORD, - APR_HASH_KEY_STRING)); - } - - // If we have defaults, just build the cred here and return it. - // I do wonder why this is here instead of in a separate - // 'defaults' provider that would run before the prompt - // provider... Hmmm. - - if (default_username && default_password) - { - *cred_p = static_cast(apr_pcalloc(pool, sizeof(**cred_p))); - (*cred_p)->username = apr_pstrdup(pool, default_username); - (*cred_p)->password = apr_pstrdup(pool, default_password); - (*cred_p)->may_save = TRUE; - } - else - { - WEBDAV_ERR(pb->prompt_func(cred_p, pb->prompt_baton, realmstring, - default_username, may_save, pool)); - } - - return WEBDAV_NO_ERROR; -} - -// Our first attempt will use any default username/password passed -// in, and prompt for the remaining stuff. -static error_t -simple_prompt_first_creds( - void ** credentials_p, - void ** iter_baton, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool) -{ - simple_prompt_provider_baton_t * pb = - static_cast(provider_baton); - simple_prompt_iter_baton_t * ibaton = - static_cast(apr_pcalloc(pool, sizeof(*ibaton))); - const char * no_auth_cache = static_cast(apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_NO_AUTH_CACHE, - APR_HASH_KEY_STRING)); - - WEBDAV_ERR(prompt_for_simple_creds((auth_cred_simple_t **) credentials_p, - pb, parameters, realmstring, TRUE, - !no_auth_cache, pool)); - - ibaton->retries = 0; - *iter_baton = ibaton; - - return WEBDAV_NO_ERROR; -} - -// Subsequent attempts to fetch will ignore the default values, and -// simply re-prompt for both, up to a maximum of ib->pb->retry_limit. -static error_t -simple_prompt_next_creds( - void ** credentials_p, - void * iter_baton, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool) -{ - simple_prompt_iter_baton_t * ib = - static_cast(iter_baton); - simple_prompt_provider_baton_t * pb = - static_cast(provider_baton); - const char * no_auth_cache = static_cast(apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_NO_AUTH_CACHE, - APR_HASH_KEY_STRING)); - - if ((pb->retry_limit >= 0) && (ib->retries >= pb->retry_limit)) - { - // give up, go on to next provider. - *credentials_p = NULL; - return WEBDAV_NO_ERROR; - } - ib->retries++; - - return prompt_for_simple_creds((auth_cred_simple_t **) credentials_p, - pb, parameters, realmstring, FALSE, - !no_auth_cache, pool); -} - -static const auth_provider_t simple_prompt_provider = -{ - AUTH_CRED_SIMPLE, - simple_prompt_first_creds, - simple_prompt_next_creds, - NULL, -}; - -// Public API -static void -auth_get_simple_prompt_provider( - auth_provider_object_t ** provider, - auth_simple_prompt_func_t prompt_func, - void * prompt_baton, - int retry_limit, - apr_pool_t * pool) -{ - auth_provider_object_t * po = - static_cast(apr_pcalloc(pool, sizeof(*po))); - simple_prompt_provider_baton_t * pb = - static_cast(apr_pcalloc(pool, sizeof(*pb))); - - pb->prompt_func = prompt_func; - pb->prompt_baton = prompt_baton; - pb->retry_limit = retry_limit; - - po->vtable = &simple_prompt_provider; - po->provider_baton = pb; - *provider = po; -} - -//--------------------------------------------------------------------------- -// from ssl_client_cert_pw_providers.c - -// The keys that will be stored on disk. These serve the same role as -// similar constants in other providers. -// AUTHN_PASSTYPE_KEY just records the passphrase type next to the -// passphrase, so that anyone who is manually editing their authn -// files can know which provider owns the password. - -#define AUTHN_PASSPHRASE_KEY "passphrase" -#define AUTHN_PASSTYPE_KEY "passtype" - -// Baton type for the ssl client cert passphrase provider. -typedef struct ssl_client_cert_pw_file_provider_baton_t -{ - auth_plaintext_passphrase_prompt_func_t plaintext_passphrase_prompt_func; - void * prompt_baton; - // We cache the user's answer to the plaintext prompt, keyed - // by realm, in case we'll be called multiple times for the - // same realm. So: keys are 'const char *' realm strings, and - // values are 'bool *'. - apr_hash_t * plaintext_answers; -} ssl_client_cert_pw_file_provider_baton_t; - -// This implements the auth_password_get_t interface. -// Set **PASSPHRASE to the plaintext passphrase retrieved from CREDS; -// ignore other parameters. -static error_t -auth_ssl_client_cert_pw_get( - bool * done, - const char ** passphrase, - apr_hash_t * creds, - const char * realmstring, - const char * username, - apr_hash_t * parameters, - bool non_interactive, - apr_pool_t * pool) -{ - string_t * str = static_cast(apr_hash_get(creds, AUTHN_PASSPHRASE_KEY, APR_HASH_KEY_STRING)); - if (str && str->data) - { - *passphrase = str->data; - *done = TRUE; - return WEBDAV_NO_ERROR; - } - *done = FALSE; - return WEBDAV_NO_ERROR; -} - -// This implements the auth_password_set_t interface. -// Store PASSPHRASE in CREDS; ignore other parameters. -static error_t -auth_ssl_client_cert_pw_set( - bool * done, - apr_hash_t * creds, - const char * realmstring, - const char * username, - const char * passphrase, - apr_hash_t * parameters, - bool non_interactive, - apr_pool_t * pool) -{ - apr_hash_set(creds, AUTHN_PASSPHRASE_KEY, APR_HASH_KEY_STRING, - string_create(passphrase, pool)); - *done = TRUE; - return WEBDAV_NO_ERROR; -} - -static error_t -auth_ssl_client_cert_pw_file_first_creds_helper( - void ** credentials_p, - void ** iter_baton, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - auth_password_get_t passphrase_get, - const char * passtype, - apr_pool_t * pool) -{ - bool non_interactive = apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_NON_INTERACTIVE, - APR_HASH_KEY_STRING) != NULL; - const char * password = NULL; - if (!password) - { - error_t err; - apr_hash_t * creds_hash = NULL; - - TWebDAVFileSystem * fs = static_cast(apr_hash_get(parameters, - CONST_FS_KEY, - APR_HASH_KEY_STRING)); - assert(fs); - // Try to load passphrase from the auth/ cache. - err = config_read_auth_data(&creds_hash, - AUTH_CRED_SSL_CLIENT_CERT_PW, - realmstring, fs, pool); - error_clear(&err); - if (!err && creds_hash) - { - bool done; - WEBDAV_ERR(passphrase_get(&done, &password, creds_hash, realmstring, - NULL, parameters, non_interactive, pool)); - if (!done) - password = NULL; - } - } - - if (password) - { - auth_cred_ssl_client_cert_pw_t * cred = - static_cast(apr_pcalloc(pool, sizeof(*cred))); - cred->password = password; - cred->may_save = FALSE; - *credentials_p = cred; - } - else *credentials_p = NULL; - *iter_baton = NULL; - return WEBDAV_NO_ERROR; -} - -static error_t -auth_ssl_client_cert_pw_file_save_creds_helper( - bool * saved, - void * credentials, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - auth_password_set_t passphrase_set, - const char * passtype, - apr_pool_t * pool) -{ - auth_cred_ssl_client_cert_pw_t * creds = - static_cast(credentials); - apr_hash_t * creds_hash = NULL; - error_t err = 0; - bool dont_store_passphrase = - apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_DONT_STORE_SSL_CLIENT_CERT_PP, - APR_HASH_KEY_STRING) != NULL; - const char * store_ssl_client_cert_pp_plaintext = - static_cast(apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_STORE_SSL_CLIENT_CERT_PP_PLAINTEXT, - APR_HASH_KEY_STRING)); - bool non_interactive = apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_NON_INTERACTIVE, - APR_HASH_KEY_STRING) != NULL; - ssl_client_cert_pw_file_provider_baton_t * b = - (ssl_client_cert_pw_file_provider_baton_t *)provider_baton; - - bool no_auth_cache = (!creds->may_save) || - (apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_NO_AUTH_CACHE, - APR_HASH_KEY_STRING) != NULL); - - *saved = FALSE; - - if (no_auth_cache) - return WEBDAV_NO_ERROR; - - creds_hash = apr_hash_make(pool); - - // Don't store passphrase in any form if the user has told - // us not to do so. - if (!dont_store_passphrase) - { - bool may_save_passphrase = FALSE; - - // If the passphrase is going to be stored encrypted, go right - // ahead and store it to disk. Else determine whether saving - // in plaintext is OK. - if (strcmp(passtype, WEBDAV_AUTH_WINCRYPT_PASSWORD_TYPE) == 0) - { - may_save_passphrase = TRUE; - } - else - { - if (cstring_casecmp(store_ssl_client_cert_pp_plaintext, - WEBDAV_CONFIG_ASK) == 0) - { - if (non_interactive) - { - // In non-interactive mode, the default behaviour is - // to not store the passphrase - may_save_passphrase = FALSE; - } - else if (b->plaintext_passphrase_prompt_func) - { - bool * cached_answer = - static_cast(apr_hash_get(b->plaintext_answers, realmstring, - APR_HASH_KEY_STRING)); - - if (cached_answer != NULL) - { - may_save_passphrase = *cached_answer; - } - else - { - apr_pool_t * cached_answer_pool; - - // Nothing cached for this realm, prompt the user. - WEBDAV_ERR((*b->plaintext_passphrase_prompt_func)( - &may_save_passphrase, - realmstring, - b->prompt_baton, - pool)); - - cached_answer_pool = apr_hash_pool_get(b->plaintext_answers); - cached_answer = static_cast(apr_pcalloc(cached_answer_pool, - sizeof(*cached_answer))); - *cached_answer = may_save_passphrase; - apr_hash_set(b->plaintext_answers, realmstring, - APR_HASH_KEY_STRING, cached_answer); - } - } - else - { - may_save_passphrase = FALSE; - } - } - else if (cstring_casecmp(store_ssl_client_cert_pp_plaintext, - WEBDAV_CONFIG_FALSE) == 0) - { - may_save_passphrase = FALSE; - } - else if (cstring_casecmp(store_ssl_client_cert_pp_plaintext, - WEBDAV_CONFIG_TRUE) == 0) - { - may_save_passphrase = TRUE; - } - else - { - return error_createf(WEBDAV_ERR_DAV_INVALID_CONFIG_VALUE, NULL, - "Config error: invalid value '%s' for option '%s'", - store_ssl_client_cert_pp_plaintext, - WEBDAV_AUTH_PARAM_STORE_SSL_CLIENT_CERT_PP_PLAINTEXT); - } - } - - if (may_save_passphrase) - { - WEBDAV_ERR(passphrase_set(saved, creds_hash, realmstring, - NULL, creds->password, parameters, - non_interactive, pool)); - - if (*saved && passtype) - { - apr_hash_set(creds_hash, AUTHN_PASSTYPE_KEY, - APR_HASH_KEY_STRING, - string_create(passtype, pool)); - } - - TWebDAVFileSystem * fs = static_cast(apr_hash_get(parameters, - CONST_FS_KEY, - APR_HASH_KEY_STRING)); - assert(fs); - // Save credentials to disk. - err = config_write_auth_data(creds_hash, - AUTH_CRED_SSL_CLIENT_CERT_PW, - realmstring, fs, pool); - error_clear(&err); - *saved = !err; - } - } - - return WEBDAV_NO_ERROR; -} - -// This implements the auth_provider_t.first_credentials API. -// It gets cached (unencrypted) credentials from the ssl client cert -// password provider's cache. -static error_t -ssl_client_cert_pw_file_first_credentials( - void ** credentials_p, - void ** iter_baton, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool) -{ - return auth_ssl_client_cert_pw_file_first_creds_helper( - credentials_p, - iter_baton, - provider_baton, - parameters, - realmstring, - auth_ssl_client_cert_pw_get, - WEBDAV_AUTH_SIMPLE_PASSWORD_TYPE, - pool); -} - -// This implements the auth_provider_t.save_credentials API. -// It saves the credentials unencrypted. -static error_t -ssl_client_cert_pw_file_save_credentials( - bool * saved, - void * credentials, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool) -{ - return auth_ssl_client_cert_pw_file_save_creds_helper( - saved, credentials, - provider_baton, - parameters, - realmstring, - auth_ssl_client_cert_pw_set, - WEBDAV_AUTH_SIMPLE_PASSWORD_TYPE, - pool); -} - -static const auth_provider_t ssl_client_cert_pw_file_provider = -{ - AUTH_CRED_SSL_CLIENT_CERT_PW, - ssl_client_cert_pw_file_first_credentials, - NULL, - ssl_client_cert_pw_file_save_credentials -}; - -// Public API to SSL file providers. -static void -auth_get_ssl_client_cert_pw_file_provider2( - auth_provider_object_t ** provider, - auth_plaintext_passphrase_prompt_func_t plaintext_passphrase_prompt_func, - void * prompt_baton, - apr_pool_t * pool) -{ - auth_provider_object_t * po = - static_cast(apr_pcalloc(pool, sizeof(*po))); - ssl_client_cert_pw_file_provider_baton_t * pb = - static_cast(apr_pcalloc(pool, - sizeof(*pb))); - - pb->plaintext_passphrase_prompt_func = plaintext_passphrase_prompt_func; - pb->prompt_baton = prompt_baton; - pb->plaintext_answers = apr_hash_make(pool); - - po->vtable = &ssl_client_cert_pw_file_provider; - po->provider_baton = pb; - *provider = po; -} - -/*-----------------------------------------------------------------------*/ -// Prompt provider -/*-----------------------------------------------------------------------*/ - -// Baton type for client passphrase prompting. -// There is no iteration baton type. -typedef struct ssl_client_cert_pw_prompt_provider_baton_t -{ - auth_ssl_client_cert_pw_prompt_func_t prompt_func; - void * prompt_baton; - - // how many times to re-prompt after the first one fails - int retry_limit; -} ssl_client_cert_pw_prompt_provider_baton_t; - -// Iteration baton. -typedef struct ssl_client_cert_pw_prompt_iter_baton_t -{ - // The original provider baton - ssl_client_cert_pw_prompt_provider_baton_t * pb; - - // The original realmstring - const char * realmstring; - - // how many times we've reprompted - int retries; -} ssl_client_cert_pw_prompt_iter_baton_t; - -static error_t -ssl_client_cert_pw_prompt_first_cred( - void ** credentials_p, - void ** iter_baton, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool) -{ - ssl_client_cert_pw_prompt_provider_baton_t * pb = - static_cast(provider_baton); - ssl_client_cert_pw_prompt_iter_baton_t * ib = - static_cast(apr_pcalloc(pool, sizeof(*ib))); - const char * no_auth_cache = static_cast(apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_NO_AUTH_CACHE, - APR_HASH_KEY_STRING)); - - WEBDAV_ERR(pb->prompt_func((auth_cred_ssl_client_cert_pw_t **) - credentials_p, pb->prompt_baton, realmstring, - !no_auth_cache, pool)); - - ib->pb = pb; - ib->realmstring = apr_pstrdup(pool, realmstring); - ib->retries = 0; - *iter_baton = ib; - - return WEBDAV_NO_ERROR; -} - -static error_t -ssl_client_cert_pw_prompt_next_cred( - void ** credentials_p, - void * iter_baton, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool) -{ - ssl_client_cert_pw_prompt_iter_baton_t * ib = - static_cast(iter_baton); - const char * no_auth_cache = static_cast(apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_NO_AUTH_CACHE, - APR_HASH_KEY_STRING)); - - if ((ib->pb->retry_limit >= 0) && (ib->retries >= ib->pb->retry_limit)) - { - // give up, go on to next provider. - *credentials_p = NULL; - return WEBDAV_NO_ERROR; - } - ib->retries++; - - return ib->pb->prompt_func((auth_cred_ssl_client_cert_pw_t **) - credentials_p, ib->pb->prompt_baton, - ib->realmstring, !no_auth_cache, pool); -} - -static const auth_provider_t client_cert_pw_prompt_provider = -{ - AUTH_CRED_SSL_CLIENT_CERT_PW, - ssl_client_cert_pw_prompt_first_cred, - ssl_client_cert_pw_prompt_next_cred, - NULL -}; - -static void -auth_get_ssl_client_cert_pw_prompt_provider( - auth_provider_object_t ** provider, - auth_ssl_client_cert_pw_prompt_func_t prompt_func, - void * prompt_baton, - int retry_limit, - apr_pool_t * pool) -{ - auth_provider_object_t * po = - static_cast(apr_pcalloc(pool, sizeof(*po))); - ssl_client_cert_pw_prompt_provider_baton_t * pb = - static_cast(apr_pcalloc(pool, sizeof(*pb))); - - pb->prompt_func = prompt_func; - pb->prompt_baton = prompt_baton; - pb->retry_limit = retry_limit; - - po->vtable = &client_cert_pw_prompt_provider; - po->provider_baton = pb; - *provider = po; -} - -//------------------------------------------------------------------------------ -// from win32_crypto.c - -// The description string that's combined with unencrypted data by the -// Windows CryptoAPI. Used during decryption to verify that the -// encrypted data were valid. -static const WCHAR description[] = L"auth.simple.wincrypt"; - -// Implementation of auth_password_set_t that encrypts -// the incoming password using the Windows CryptoAPI. -static error_t -windows_password_encrypter( - bool * done, - apr_hash_t * creds, - const char * realmstring, - const char * username, - const char * in, - apr_hash_t * parameters, - bool non_interactive, - apr_pool_t * pool) -{ - DATA_BLOB blobin; - DATA_BLOB blobout; - BOOL crypted = FALSE; - - blobin.cbData = (DWORD)strlen(in); - blobin.pbData = (BYTE *) in; - crypted = CryptProtectData(&blobin, description, NULL, NULL, NULL, - CRYPTPROTECT_UI_FORBIDDEN, &blobout); - if (crypted) - { - char * coded = static_cast(apr_pcalloc(pool, apr_base64_encode_len(blobout.cbData))); - apr_base64_encode(coded, (const char *)blobout.pbData, blobout.cbData); - WEBDAV_ERR(auth_simple_password_set(done, creds, realmstring, username, - coded, parameters, - non_interactive, pool)); - LocalFree(blobout.pbData); - } - - return WEBDAV_NO_ERROR; -} - -// Implementation of auth_password_get_t that decrypts -// the incoming password using the Windows CryptoAPI and verifies its -// validity. -static error_t -windows_password_decrypter( - bool * done, - const char ** out, - apr_hash_t * creds, - const char * realmstring, - const char * username, - apr_hash_t * parameters, - bool non_interactive, - apr_pool_t * pool) -{ - DATA_BLOB blobin; - DATA_BLOB blobout; - LPWSTR descr; - BOOL decrypted = FALSE; - const char * in = NULL; - - WEBDAV_ERR(auth_simple_password_get(done, &in, creds, realmstring, username, - parameters, non_interactive, pool)); - if (!*done) - return WEBDAV_NO_ERROR; - - blobin.cbData = (DWORD)strlen(in); - blobin.pbData = static_cast(apr_pcalloc(pool, apr_base64_decode_len(in))); - apr_base64_decode((char *)blobin.pbData, in); - decrypted = CryptUnprotectData(&blobin, &descr, NULL, NULL, NULL, - CRYPTPROTECT_UI_FORBIDDEN, &blobout); - if (decrypted) - { - if (0 == lstrcmpW(descr, description)) - *out = apr_pstrndup(pool, (const char *)blobout.pbData, blobout.cbData); - else - decrypted = FALSE; - LocalFree(blobout.pbData); - LocalFree(descr); - } - - *done = decrypted != 0; - return WEBDAV_NO_ERROR; -} - -// Get cached encrypted credentials from the simple provider's cache. -static error_t -windows_simple_first_creds( - void ** credentials, - void ** iter_baton, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool) -{ - return auth_simple_first_creds_helper(credentials, - iter_baton, - provider_baton, - parameters, - realmstring, - windows_password_decrypter, - WEBDAV_AUTH_WINCRYPT_PASSWORD_TYPE, - pool); -} - -// Save encrypted credentials to the simple provider's cache. -static error_t -windows_simple_save_creds( - bool * saved, - void * credentials, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool) -{ - return auth_simple_save_creds_helper(saved, credentials, - provider_baton, - parameters, - realmstring, - windows_password_encrypter, - WEBDAV_AUTH_WINCRYPT_PASSWORD_TYPE, - pool); -} - -static const auth_provider_t windows_simple_provider = -{ - AUTH_CRED_SIMPLE, - windows_simple_first_creds, - NULL, - windows_simple_save_creds -}; - -// Public API -static void -auth_get_windows_simple_provider( - auth_provider_object_t ** provider, - apr_pool_t * pool) -{ - auth_provider_object_t * po = - static_cast(apr_pcalloc(pool, sizeof(*po))); - - po->vtable = &windows_simple_provider; - *provider = po; -} - -/*-----------------------------------------------------------------------*/ -// Windows SSL server trust provider, validates ssl certificate using -// CryptoApi. -/*-----------------------------------------------------------------------*/ - -// Implementation of auth_password_set_t that encrypts -// the incoming password using the Windows CryptoAPI. -static error_t -windows_ssl_client_cert_pw_encrypter( - bool * done, - apr_hash_t * creds, - const char * realmstring, - const char * username, - const char * in, - apr_hash_t * parameters, - bool non_interactive, - apr_pool_t * pool) -{ - DATA_BLOB blobin; - DATA_BLOB blobout; - BOOL crypted; - - blobin.cbData = (DWORD)strlen(in); - blobin.pbData = (BYTE *) in; - crypted = CryptProtectData(&blobin, description, NULL, NULL, NULL, - CRYPTPROTECT_UI_FORBIDDEN, &blobout); - if (crypted) - { - char * coded = static_cast(apr_pcalloc(pool, apr_base64_encode_len(blobout.cbData))); - apr_base64_encode(coded, (const char *)blobout.pbData, blobout.cbData); - WEBDAV_ERR(auth_ssl_client_cert_pw_set(done, creds, realmstring, username, - coded, parameters, - non_interactive, pool)); - LocalFree(blobout.pbData); - } - - return WEBDAV_NO_ERROR; -} - -// Implementation of auth_password_get_t that decrypts -// the incoming password using the Windows CryptoAPI and verifies its -// validity. -static error_t -windows_ssl_client_cert_pw_decrypter( - bool * done, - const char ** out, - apr_hash_t * creds, - const char * realmstring, - const char * username, - apr_hash_t * parameters, - bool non_interactive, - apr_pool_t * pool) -{ - DATA_BLOB blobin; - DATA_BLOB blobout; - LPWSTR descr; - BOOL decrypted; - const char * in = NULL; - - WEBDAV_ERR(auth_ssl_client_cert_pw_get(done, &in, creds, realmstring, username, - parameters, non_interactive, pool)); - if (!*done) - return WEBDAV_NO_ERROR; - - blobin.cbData = (DWORD)strlen(in); - blobin.pbData = static_cast(apr_pcalloc(pool, apr_base64_decode_len(in))); - apr_base64_decode((char *)blobin.pbData, in); - decrypted = CryptUnprotectData(&blobin, &descr, NULL, NULL, NULL, - CRYPTPROTECT_UI_FORBIDDEN, &blobout); - if (decrypted) - { - if (0 == lstrcmpW(descr, description)) - *out = apr_pstrndup(pool, (const char *)blobout.pbData, blobout.cbData); - else - decrypted = FALSE; - LocalFree(blobout.pbData); - LocalFree(descr); - } - - *done = decrypted != 0; - return WEBDAV_NO_ERROR; -} - -// Get cached encrypted credentials from the simple provider's cache. -static error_t -windows_ssl_client_cert_pw_first_creds( - void ** credentials, - void ** iter_baton, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool) -{ - return auth_ssl_client_cert_pw_file_first_creds_helper( - credentials, - iter_baton, - provider_baton, - parameters, - realmstring, - windows_ssl_client_cert_pw_decrypter, - WEBDAV_AUTH_WINCRYPT_PASSWORD_TYPE, - pool); -} - -// Save encrypted credentials to the simple provider's cache. -static error_t -windows_ssl_client_cert_pw_save_creds( - bool * saved, - void * credentials, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool) -{ - return auth_ssl_client_cert_pw_file_save_creds_helper( - saved, - credentials, - provider_baton, - parameters, - realmstring, - windows_ssl_client_cert_pw_encrypter, - WEBDAV_AUTH_WINCRYPT_PASSWORD_TYPE, - pool); -} - -static const auth_provider_t windows_ssl_client_cert_pw_provider = -{ - AUTH_CRED_SSL_CLIENT_CERT_PW, - windows_ssl_client_cert_pw_first_creds, - NULL, - windows_ssl_client_cert_pw_save_creds -}; - -// Public API -static void -auth_get_windows_ssl_client_cert_pw_provider( - auth_provider_object_t ** provider, - apr_pool_t * pool) -{ - auth_provider_object_t * po = - static_cast(apr_pcalloc(pool, sizeof(*po))); - - po->vtable = &windows_ssl_client_cert_pw_provider; - *provider = po; -} - -/*-----------------------------------------------------------------------*/ -// Windows SSL server trust provider, validates ssl certificate using -// CryptoApi. -/*-----------------------------------------------------------------------*/ - -// Helper to create CryptoAPI CERT_CONTEXT from base64 encoded BASE64_CERT. -// Returns NULL on error. - -static PCCERT_CONTEXT -certcontext_from_base64( - const char * base64_cert, - apr_pool_t * pool) -{ - PCCERT_CONTEXT cert_context = NULL; - int cert_len = 0; - BYTE * binary_cert = NULL; - - // Use apr-util as CryptStringToBinaryA is available only on XP+. - binary_cert = static_cast(apr_pcalloc(pool, - apr_base64_decode_len(base64_cert))); - cert_len = apr_base64_decode((char *)binary_cert, base64_cert); - - // Parse the certificate into a context. - cert_context = CertCreateCertificateContext(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, - binary_cert, cert_len); - - return cert_context; -} - -// Helper for windows_ssl_server_trust_first_credentials for validating -// certificate using CryptoApi. Sets *OK_P to TRUE if base64 encoded ASCII_CERT -// certificate considered as valid. - -static error_t -windows_validate_certificate( - bool * ok_p, - const char * ascii_cert, - apr_pool_t * pool) -{ - PCCERT_CONTEXT cert_context = NULL; - CERT_CHAIN_PARA chain_para; - PCCERT_CHAIN_CONTEXT chain_context = NULL; - - *ok_p = FALSE; - - // Parse the certificate into a context. - cert_context = certcontext_from_base64(ascii_cert, pool); - - if (cert_context) - { - // Retrieve the certificate chain of the certificate - // (a certificate without a valid root does not have a chain). - memset(&chain_para, 0, sizeof(chain_para)); - chain_para.cbSize = sizeof(chain_para); - - HCERTCHAINENGINE chain_engine; - CERT_CHAIN_ENGINE_CONFIG chain_config; - - chain_config.cbSize = sizeof(CERT_CHAIN_ENGINE_CONFIG); - chain_config.hRestrictedRoot = NULL; - chain_config.hRestrictedTrust = NULL; - chain_config.hRestrictedOther = NULL; - chain_config.cAdditionalStore = 0; - chain_config.rghAdditionalStore = NULL; - chain_config.dwFlags = CERT_CHAIN_CACHE_END_CERT; - chain_config.dwUrlRetrievalTimeout = 0; - chain_config.MaximumCachedCertificates =0; - chain_config.CycleDetectionModulus = 0; - - CertCreateCertificateChainEngine( - &chain_config, - &chain_engine); - - if (CertGetCertificateChain(chain_engine, cert_context, NULL, NULL, &chain_para, - CERT_CHAIN_CACHE_END_CERT | - CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT, - NULL, &chain_context)) - { - CERT_CHAIN_POLICY_PARA policy_para; - CERT_CHAIN_POLICY_STATUS policy_status; - - policy_para.cbSize = sizeof(policy_para); - policy_para.dwFlags = 0; - policy_para.pvExtraPolicyPara = NULL; - - policy_status.cbSize = sizeof(policy_status); - - if (CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_SSL, - chain_context, &policy_para, - &policy_status)) - { - if (policy_status.dwError == S_OK) - { - // Windows thinks the certificate is valid. - *ok_p = TRUE; - } - } - - CertFreeCertificateChain(chain_context); - } - CertFreeCertificateContext(cert_context); - CertFreeCertificateChainEngine(chain_engine); - } - - return WEBDAV_NO_ERROR; -} - -// Retrieve ssl server CA failure overrides (if any) from CryptoApi. -static error_t -windows_ssl_server_trust_first_credentials( - void ** credentials, - void ** iter_baton, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool) -{ - apr_uint32_t * failures = static_cast(apr_hash_get(parameters, - AUTH_PARAM_SSL_SERVER_FAILURES, - APR_HASH_KEY_STRING)); - const auth_ssl_server_cert_info_t * cert_info = - static_cast(apr_hash_get(parameters, - AUTH_PARAM_SSL_SERVER_CERT_INFO, - APR_HASH_KEY_STRING)); - - *credentials = NULL; - *iter_baton = NULL; - - // We can accept only unknown certificate authority. - if (*failures & WEBDAV_AUTH_SSL_UNKNOWNCA) - { - bool ok; - - WEBDAV_ERR(windows_validate_certificate(&ok, cert_info->ascii_cert, pool)); - - // Windows thinks that certificate is ok. - if (ok) - { - // Clear failure flag. - *failures &= ~WEBDAV_AUTH_SSL_UNKNOWNCA; - } - } - - // If all failures are cleared now, we return the creds - if (!*failures) - { - auth_cred_ssl_server_trust_t * creds = - static_cast(apr_pcalloc(pool, sizeof(*creds))); - creds->may_save = FALSE; // No need to save it. - *credentials = creds; - } - - return WEBDAV_NO_ERROR; -} - -static const auth_provider_t windows_server_trust_provider = -{ - AUTH_CRED_SSL_SERVER_TRUST, - windows_ssl_server_trust_first_credentials, - NULL, - NULL, -}; - -// Public API -static void -auth_get_windows_ssl_server_trust_provider( - auth_provider_object_t ** provider, - apr_pool_t * pool) -{ - auth_provider_object_t * po = - static_cast(apr_pcalloc(pool, sizeof(*po))); - - po->vtable = &windows_server_trust_provider; - *provider = po; -} - -//------------------------------------------------------------------------------ -// from username_providers.c - -// Username-only Provider -static error_t -username_first_creds( - void ** credentials, - void ** iter_baton, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool) -{ - const char * username = static_cast(apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_DEFAULT_USERNAME, - APR_HASH_KEY_STRING)); - bool may_save = !!username; - error_t err = 0; - - // If we don't have a usename yet, try the auth cache - if (!username) - { - apr_hash_t * creds_hash = NULL; - - TWebDAVFileSystem * fs = static_cast(apr_hash_get(parameters, - CONST_FS_KEY, - APR_HASH_KEY_STRING)); - assert(fs); - // Try to load credentials from a file on disk, based on the - // realmstring. Don't throw an error, though: if something went - // wrong reading the file, no big deal. What really matters is that - // we failed to get the creds, so allow the auth system to try the - // next provider. - err = config_read_auth_data(&creds_hash, WEBDAV_AUTH_CRED_USERNAME, - realmstring, fs, - pool); - error_clear(&err); - if (!err && creds_hash) - { - string_t * str = static_cast(apr_hash_get(creds_hash, AUTHN_USERNAME_KEY, - APR_HASH_KEY_STRING)); - if (str && str->data) - username = str->data; - } - } - - // If that failed, ask the OS for the username - if (!username) - username = user_get_name(pool); - - if (username) - { - auth_cred_simple_t * creds = - static_cast(apr_pcalloc(pool, sizeof(*creds))); - creds->username = username; - creds->may_save = may_save; - *credentials = creds; - } - else - *credentials = NULL; - - *iter_baton = NULL; - - return WEBDAV_NO_ERROR; -} - -static error_t -username_save_creds( - bool * saved, - void * credentials, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool) -{ - auth_cred_simple_t * creds = - static_cast(credentials); - apr_hash_t * creds_hash = NULL; - error_t err; - - *saved = FALSE; - - if (!creds->may_save) - return WEBDAV_NO_ERROR; - - // Put the credentials in a hash and save it to disk - creds_hash = apr_hash_make(pool); - apr_hash_set(creds_hash, AUTHN_USERNAME_KEY, APR_HASH_KEY_STRING, - string_create(creds->username, pool)); - - TWebDAVFileSystem * fs = static_cast(apr_hash_get(parameters, - CONST_FS_KEY, - APR_HASH_KEY_STRING)); - assert(fs); - err = config_write_auth_data(creds_hash, WEBDAV_AUTH_CRED_USERNAME, - realmstring, - fs, - pool); - error_clear(&err); - *saved = !err; - - return WEBDAV_NO_ERROR; -} - -static const auth_provider_t username_provider = -{ - WEBDAV_AUTH_CRED_USERNAME, - username_first_creds, - NULL, - username_save_creds -}; - -// Public API -static void -auth_get_username_provider( - auth_provider_object_t ** provider, - apr_pool_t * pool) -{ - auth_provider_object_t * po = - static_cast(apr_pcalloc(pool, sizeof(*po))); - - po->vtable = &username_provider; - *provider = po; -} - -// Baton type for username-only prompting. -typedef struct username_prompt_provider_baton_t -{ - auth_username_prompt_func_t prompt_func; - void * prompt_baton; - - // how many times to re-prompt after the first one fails - int retry_limit; -} username_prompt_provider_baton_t; - -// Iteration baton type for username-only prompting. -typedef struct username_prompt_iter_baton_t -{ - // how many times we've reprompted - int retries; - -} username_prompt_iter_baton_t; - -// Helper Functions -static error_t -prompt_for_username_creds( - auth_cred_username_t ** cred_p, - username_prompt_provider_baton_t * pb, - apr_hash_t * parameters, - const char * realmstring, - bool first_time, - bool may_save, - apr_pool_t * pool) -{ - const char * def_username = NULL; - - *cred_p = NULL; - - // If we're allowed to check for default usernames, do so. - if (first_time) - def_username = static_cast(apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_DEFAULT_USERNAME, - APR_HASH_KEY_STRING)); - - // If we have defaults, just build the cred here and return it. - // I do wonder why this is here instead of in a separate - // 'defaults' provider that would run before the prompt - // provider... Hmmm. - - if (def_username) - { - *cred_p = static_cast(apr_pcalloc(pool, sizeof(**cred_p))); - (*cred_p)->username = apr_pstrdup(pool, def_username); - (*cred_p)->may_save = TRUE; - } - else - { - WEBDAV_ERR(pb->prompt_func(cred_p, pb->prompt_baton, realmstring, - may_save, pool)); - } - - return WEBDAV_NO_ERROR; -} - -// Our first attempt will use any default username passed -// in, and prompt for the remaining stuff. -static error_t -username_prompt_first_creds( - void ** credentials_p, - void ** iter_baton, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool) -{ - username_prompt_provider_baton_t * pb = - static_cast(provider_baton); - username_prompt_iter_baton_t * ibaton = - static_cast(apr_pcalloc(pool, sizeof(*ibaton))); - const char * no_auth_cache = static_cast(apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_NO_AUTH_CACHE, - APR_HASH_KEY_STRING)); - - WEBDAV_ERR(prompt_for_username_creds((auth_cred_username_t **) credentials_p, pb, - parameters, realmstring, TRUE, !no_auth_cache, pool)); - - ibaton->retries = 0; - *iter_baton = ibaton; - - return WEBDAV_NO_ERROR; -} - -// Subsequent attempts to fetch will ignore the default username -// value, and simply re-prompt for the username, up to a maximum of -// ib->pb->retry_limit. -static error_t -username_prompt_next_creds( - void ** credentials_p, - void * iter_baton, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool) -{ - username_prompt_iter_baton_t * ib = - static_cast(iter_baton); - username_prompt_provider_baton_t * pb = - static_cast(provider_baton); - const char * no_auth_cache = static_cast(apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_NO_AUTH_CACHE, - APR_HASH_KEY_STRING)); - - if ((pb->retry_limit >= 0) && (ib->retries >= pb->retry_limit)) - { - // give up, go on to next provider. - *credentials_p = NULL; - return WEBDAV_NO_ERROR; - } - ib->retries++; - - return prompt_for_username_creds((auth_cred_username_t **) credentials_p, pb, - parameters, realmstring, FALSE, !no_auth_cache, pool); -} - -static const auth_provider_t username_prompt_provider = -{ - WEBDAV_AUTH_CRED_USERNAME, - username_prompt_first_creds, - username_prompt_next_creds, - NULL, -}; - -// Public API -static void -auth_get_username_prompt_provider( - auth_provider_object_t ** provider, - auth_username_prompt_func_t prompt_func, - void * prompt_baton, - int retry_limit, - apr_pool_t * pool) -{ - auth_provider_object_t * po = - static_cast(apr_pcalloc(pool, sizeof(*po))); - username_prompt_provider_baton_t * pb = - static_cast(apr_pcalloc(pool, sizeof(*pb))); - - pb->prompt_func = prompt_func; - pb->prompt_baton = prompt_baton; - pb->retry_limit = retry_limit; - - po->vtable = &username_prompt_provider; - po->provider_baton = pb; - *provider = po; -} - -//------------------------------------------------------------------------------ -// from auth.c - -static void -auth_baton_set_parameter( - auth_baton_t * auth_baton, - const char * name, - const void * value) -{ - apr_hash_set(auth_baton->parameters, name, APR_HASH_KEY_STRING, value); -} - -static const void * -auth_baton_get_parameter( - auth_baton_t * auth_baton, - const char * name) -{ - return apr_hash_get(auth_baton->parameters, name, APR_HASH_KEY_STRING); -} - -static error_t -auth_first_credentials( - void ** credentials, - auth_iterstate_t ** state, - const char * cred_kind, - const char * realmstring, - auth_baton_t * auth_baton, - apr_pool_t * pool) -{ - int i = 0; - provider_set_t * table = NULL; - auth_provider_object_t * provider = NULL; - void * creds = NULL; - void * iter_baton = NULL; - bool got_first = FALSE; - auth_iterstate_t * iterstate = NULL; - const char * cache_key = NULL; - - // Get the appropriate table of providers for CRED_KIND. - table = static_cast(apr_hash_get(auth_baton->tables, cred_kind, APR_HASH_KEY_STRING)); - if (!table) - return error_createf(WEBDAV_ERR_AUTHN_NO_PROVIDER, NULL, - "No provider registered for '%s' credentials", - cred_kind); - - // First, see if we have cached creds in the auth_baton. - cache_key = apr_pstrcat(pool, cred_kind, ":", realmstring, (char *)NULL); - creds = static_cast(apr_hash_get(auth_baton->creds_cache, - cache_key, APR_HASH_KEY_STRING)); - if (creds) - { - got_first = false; - } - else - // If not, find a provider that can give "first" credentials. - { - // Find a provider that can give "first" credentials. - for (i = 0; i < table->providers->nelts; i++) - { - provider = APR_ARRAY_IDX(table->providers, i, - auth_provider_object_t *); - WEBDAV_ERR(provider->vtable->first_credentials( - &creds, &iter_baton, provider->provider_baton, - auth_baton->parameters, realmstring, auth_baton->pool)); - - if (creds != NULL) - { - got_first = true; - break; - } - } - } - - if (!creds) - *state = NULL; - else - { - // Build an abstract iteration state. - iterstate = static_cast(apr_pcalloc(pool, sizeof(*iterstate))); - iterstate->table = table; - iterstate->provider_idx = i; - iterstate->got_first = got_first; - iterstate->provider_iter_baton = iter_baton; - iterstate->realmstring = apr_pstrdup(pool, realmstring); - iterstate->cache_key = cache_key; - iterstate->auth_baton = auth_baton; - *state = iterstate; - - // Put the creds in the cache - apr_hash_set(auth_baton->creds_cache, - apr_pstrdup(auth_baton->pool, cache_key), - APR_HASH_KEY_STRING, - creds); - } - - *credentials = creds; - - return WEBDAV_NO_ERROR; -} - -static error_t -auth_next_credentials( - void ** credentials, - auth_iterstate_t * state, - apr_pool_t * pool) -{ - auth_baton_t * auth_baton = state->auth_baton; - auth_provider_object_t * provider = NULL; - provider_set_t * table = state->table; - void * creds = NULL; - - // Continue traversing the table from where we left off. - for (/* no init */; - state->provider_idx < table->providers->nelts; - state->provider_idx++) - { - provider = APR_ARRAY_IDX(table->providers, - state->provider_idx, - auth_provider_object_t *); - if (!state->got_first) - { - WEBDAV_ERR(provider->vtable->first_credentials( - &creds, &(state->provider_iter_baton), - provider->provider_baton, auth_baton->parameters, - state->realmstring, auth_baton->pool)); - state->got_first = TRUE; - } - else - { - if (provider->vtable->next_credentials) - WEBDAV_ERR(provider->vtable->next_credentials( - &creds, state->provider_iter_baton, - provider->provider_baton, auth_baton->parameters, - state->realmstring, auth_baton->pool)); - } - - if (creds != NULL) - { - // Put the creds in the cache - apr_hash_set(auth_baton->creds_cache, - state->cache_key, APR_HASH_KEY_STRING, - creds); - break; - } - - state->got_first = FALSE; - } - - *credentials = creds; - - return WEBDAV_NO_ERROR; -} - -static error_t -auth_save_credentials( - auth_iterstate_t * state, - apr_pool_t * pool) -{ - int i = 0; - auth_provider_object_t * provider = NULL; - bool save_succeeded = FALSE; - const char * no_auth_cache = NULL; - auth_baton_t * auth_baton = NULL; - void * creds = NULL; - - if (!state || state->table->providers->nelts <= state->provider_idx) - return WEBDAV_NO_ERROR; - - auth_baton = state->auth_baton; - creds = apr_hash_get(state->auth_baton->creds_cache, - state->cache_key, APR_HASH_KEY_STRING); - if (!creds) - return WEBDAV_NO_ERROR; - - // Do not save the creds if AUTH_PARAM_NO_AUTH_CACHE is set - no_auth_cache = static_cast(apr_hash_get(auth_baton->parameters, - AUTH_PARAM_NO_AUTH_CACHE, - APR_HASH_KEY_STRING)); - if (no_auth_cache) - return WEBDAV_NO_ERROR; - - // First, try to save the creds using the provider that produced them. - provider = APR_ARRAY_IDX(state->table->providers, - state->provider_idx, - auth_provider_object_t *); - if (provider->vtable->save_credentials) - WEBDAV_ERR(provider->vtable->save_credentials(&save_succeeded, - creds, - provider->provider_baton, - auth_baton->parameters, - state->realmstring, - pool)); - if (save_succeeded) - return WEBDAV_NO_ERROR; - - // Otherwise, loop from the top of the list, asking every provider - // to attempt a save. todo: someday optimize so we don't - // necessarily start from the top of the list. - for (i = 0; i < state->table->providers->nelts; i++) - { - provider = APR_ARRAY_IDX(state->table->providers, i, - auth_provider_object_t *); - if (provider->vtable->save_credentials) - WEBDAV_ERR(provider->vtable->save_credentials( - &save_succeeded, creds, - provider->provider_baton, - auth_baton->parameters, - state->realmstring, - pool)); - - if (save_succeeded) - break; - } - - // notice that at the moment, if no provider can save, there's - // no way the caller will know. - - return WEBDAV_NO_ERROR; -} - -static error_t -auth_get_platform_specific_provider( - auth_provider_object_t ** provider, - const char * provider_name, - const char * provider_type, - apr_pool_t * pool) -{ - *provider = NULL; - - { - if (strcmp(provider_name, "windows") == 0 && - strcmp(provider_type, "simple") == 0) - { - auth_get_windows_simple_provider(provider, pool); - } - else if (strcmp(provider_name, "windows") == 0 && - strcmp(provider_type, "ssl_client_cert_pw") == 0) - { - auth_get_windows_ssl_client_cert_pw_provider(provider, pool); - } - else if (strcmp(provider_name, "windows") == 0 && - strcmp(provider_type, "ssl_server_trust") == 0) - { - auth_get_windows_ssl_server_trust_provider(provider, pool); - } - } - - return WEBDAV_NO_ERROR; -} - -#define WEBDAV_MAYBE_ADD_PROVIDER(list, p) \ - { if (p) APR_ARRAY_PUSH(list, auth_provider_object_t *) = p; } - -static error_t -auth_get_platform_specific_client_providers( - apr_array_header_t ** providers, - apr_pool_t * pool) -{ - auth_provider_object_t * provider; - const char * password_stores_config_option; - apr_array_header_t * password_stores; - int i; - - password_stores_config_option = "windows-cryptoapi"; - - *providers = apr_array_make(pool, 12, sizeof(auth_provider_object_t *)); - - password_stores = cstring_split(password_stores_config_option, " ,", TRUE, pool); - - for (i = 0; i < password_stores->nelts; i++) - { - const char * password_store = APR_ARRAY_IDX(password_stores, i, - const char *); - - // Windows - if (apr_strnatcmp(password_store, "windows-cryptoapi") == 0) - { - WEBDAV_ERR(auth_get_platform_specific_provider(&provider, - "windows", - "simple", - pool)); - - WEBDAV_MAYBE_ADD_PROVIDER(*providers, provider); - - WEBDAV_ERR(auth_get_platform_specific_provider(&provider, - "windows", - "ssl_client_cert_pw", - pool)); - - WEBDAV_MAYBE_ADD_PROVIDER(*providers, provider); - - continue; - } - - return error_createf(WEBDAV_ERR_BAD_CONFIG_VALUE, NULL, - "Invalid config: unknown password store " - "'%s'", - password_store); - } - - return WEBDAV_NO_ERROR; -} - -//------------------------------------------------------------------------------ -// from dirent_uri.c - -// TRUE if s is the canonical empty path, FALSE otherwise -#define PATH_IS_EMPTY(s) ((s)[0] == '\0') - -// Path separator for local filesystem -#define WEBDAV_PATH_LOCAL_SEPARATOR '\\' - -// Path type definition. Used only by internal functions. -typedef enum path_type_t -{ - type_uri, - type_dirent, - type_relpath -} path_type_t; - -// Locale insensitive tolower() for converting parts of dirents and urls -// while canonicalizing -static char -canonicalize_to_lower(char c) -{ - if (!IsUpperCaseLetter(c)) - return c; - else - return c - 'A' + 'a'; -} - -// Locale insensitive toupper() for converting parts of dirents and urls -// while canonicalizing -static char -canonicalize_to_upper(char c) -{ - if (!IsLowerCaseLetter(c)) - return c; - else - return c - 'a' + 'A'; -} - -// Return the canonicalized version of PATH, of type TYPE, allocated in POOL. - -static const char * -canonicalize( - path_type_t type, - const char * path, - apr_pool_t * pool) -{ - char * canon = NULL, *dst = NULL; - const char * src = NULL; - size_t seglen = 0; - size_t schemelen = 0; - size_t canon_segments = 0; - bool url = FALSE; - char * schema_data = NULL; - - // "" is already canonical, so just return it; note that later code - // depends on path not being zero-length. - if (PATH_IS_EMPTY(path)) - { - assert(type != type_uri); - return ""; - } - - dst = canon = static_cast(apr_pcalloc(pool, strlen(path) + 1)); - - // If this is supposed to be an URI, it should start with - // "scheme://". We'll copy the scheme, host name, etc. to DST and - // set URL = TRUE. - src = path; - if (type == type_uri) - { - assert(*src != '/'); - - while (*src && (*src != '/') && (*src != ':')) - src++; - - if ((*src == ':') && (*(src+1) == '/') && (*(src+2) == '/')) - { - const char * seg; - - url = TRUE; - - // Found a scheme, convert to lowercase and copy to dst. - src = path; - while (*src != ':') - { - *(dst++) = canonicalize_to_lower((*src++)); - schemelen++; - } - *(dst++) = ':'; - *(dst++) = '/'; - *(dst++) = '/'; - src += 3; - schemelen += 3; - - // This might be the hostname - seg = src; - while (*src && (*src != '/') && (*src != '@')) - src++; - - if (*src == '@') - { - // Copy the username & password. - seglen = src - seg + 1; - memcpy(dst, seg, seglen); - dst += seglen; - src++; - } - else - src = seg; - - // Found a hostname, convert to lowercase and copy to dst. - while (*src && (*src != '/') && (*src != ':')) - *(dst++) = canonicalize_to_lower((*src++)); - - if (*src == ':') - { - // We probably have a port number: Is it a default portnumber - // which doesn't belong in a canonical url? - if ((src[1] == '8') && (src[2] == '0') && - ((src[3] == '/') || !src[3]) && - !strncmp(canon, "http:", 5)) - { - src += 3; - } - else if ((src[1] == '4') && (src[2] == '4') && (src[3] == '3') && - ((src[4] == '/') || !src[4]) && - !strncmp(canon, "https:", 6)) - { - src += 4; - } - else if ((src[1] == '/') || !src[1]) - { - src += 1; - } - - while (*src && (*src != '/')) - *(dst++) = canonicalize_to_lower((*src++)); - } - - // Copy trailing slash, or null-terminator. - *(dst) = *(src); - - // Move src and dst forward only if we are not - // at null-terminator yet. - if (*src) - { - src++; - dst++; - schema_data = dst; - } - - canon_segments = 1; - } - } - - // Copy to DST any separator or drive letter that must come before the - // first regular path segment. - if (!url && type != type_relpath) - { - src = path; - // If this is an absolute path, then just copy over the initial - // separator character. - if (*src == '/') - { - *(dst++) = *(src++); - - // On Windows permit two leading separator characters which means an - // UNC path. - if ((type == type_dirent) && (*src == '/')) - *(dst++) = *(src++); - } - // On Windows the first segment can be a drive letter, which we normalize - // to upper case. - else if ((type == type_dirent) && - IsLetter(*src) && - (src[1] == ':')) - { - *(dst++) = canonicalize_to_upper(*(src++)); - // Leave the ':' to be processed as (or as part of) a path segment - // by the following code block, so we need not care whether it has - // a slash after it. - } - } - - while (*src) - { - // Parse each segment, finding the closing '/' (which might look - // like '%2F' for URIs). - const char * next = src; - size_t slash_len = 0; - - while (*next && - (next[0] != '/') && - (!((type == type_uri) && (next[0] == '%') && (next[1] == '2') && - (canonicalize_to_upper(next[2]) == 'F')))) - { - ++next; - } - - // Record how long our "slash" is. - if (next[0] == '/') - slash_len = 1; - else if ((type == type_uri) && (next[0] == '%')) - slash_len = 3; - - seglen = next - src; - - if ((seglen == 0) || - ((seglen == 1) && (src[0] == '.')) || - ((type == type_uri) && (seglen == 3) && (src[0] == '%') && (src[1] == '2') && - (canonicalize_to_upper(src[2]) == 'E'))) - { - // Empty or noop segment, so do nothing. (For URIs, '%2E' - // is equivalent to '.'). - } - // If this is the first path segment of a file:// URI and it contains a - // windows drive letter, convert the drive letter to upper case. - else if (url && (canon_segments == 1) && (seglen == 2) && - (strncmp(canon, "file:", 5) == 0) && - IsLowerCaseLetter(src[0]) && (src[1] == ':')) - { - *(dst++) = canonicalize_to_upper(src[0]); - *(dst++) = ':'; - if (*next) - *(dst++) = *next; - canon_segments++; - } - else - { - // An actual segment, append it to the destination path - memcpy(dst, src, seglen); - dst += seglen; - if (slash_len) - { - *(dst++) = '/'; - } - canon_segments++; - } - - // Skip over trailing slash to the next segment. - src = next + slash_len; - } - - *dst = '\0'; - - // Skip leading double slashes when there are less than 2 - // canon segments. UNC paths *MUST* have two segments. - if ((type == type_dirent) && (canon[0] == '/') && (canon[1] == '/')) - { - if (canon_segments < 2) - return canon + 1; - else - { - // Now we're sure this is a valid UNC path, convert the server name - // (the first path segment) to lowercase as Windows treats it as case - // insensitive. - // Note: normally the share name is treated as case insensitive too, - // but it seems to be possible to configure Samba to treat those as - // case sensitive, so better leave that alone. - for (dst = canon + 2; *dst && (*dst != '/'); dst++) - *dst = canonicalize_to_lower(*dst); - } - } - - // Check the normalization of characters in a uri - if (schema_data) - { - int need_extra = 0; - src = schema_data; - - while (*src) - { - switch (*src) - { - case '/': - break; - case '%': - if (!ctype_isxdigit(*(src+1)) || - !ctype_isxdigit(*(src+2))) - need_extra += 2; - else - src += 2; - break; - default: - if (!uri_char_validity[(unsigned char)*src]) - need_extra += 2; - break; - } - src++; - } - - if (need_extra > 0) - { - size_t pre_schema_size = (size_t)(schema_data - canon); - - dst = static_cast(apr_pcalloc(pool, (size_t)(src - canon) + need_extra + 1)); - memcpy(dst, canon, pre_schema_size); - canon = dst; - - dst += pre_schema_size; - } - else - dst = schema_data; - - src = schema_data; - - while (*src) - { - switch (*src) - { - case '/': - *(dst++) = '/'; - break; - case '%': - if (!ctype_isxdigit(*(src+1)) || - !ctype_isxdigit(*(src+2))) - { - *(dst++) = '%'; - *(dst++) = '2'; - *(dst++) = '5'; - } - else - { - char digitz[3]; - int val; - - digitz[0] = *(++src); - digitz[1] = *(++src); - digitz[2] = 0; - - val = (int)strtol(digitz, NULL, 16); - - if (uri_char_validity[(unsigned char)val]) - *(dst++) = (char)val; - else - { - *(dst++) = '%'; - *(dst++) = canonicalize_to_upper(digitz[0]); - *(dst++) = canonicalize_to_upper(digitz[1]); - } - } - break; - default: - if (!uri_char_validity[(unsigned char)*src]) - { - apr_snprintf(dst, 4, "%%%02X", (unsigned char)*src); - dst += 3; - } - else - *(dst++) = *src; - break; - } - src++; - } - *dst = '\0'; - } - - return canon; -} - -static const char * -uri_canonicalize( - const char * uri, - apr_pool_t * pool) -{ - return canonicalize(type_uri, uri, pool); -} - -static const char * -relpath_canonicalize( - const char * relpath, - apr_pool_t * pool) -{ - return canonicalize(type_relpath, relpath, pool); -} - -static const char * -fspath_canonicalize( - const char * fspath, - apr_pool_t * pool) -{ - if ((fspath[0] == '/') && (fspath[1] == '\0')) - return "/"; - - return apr_pstrcat(pool, "/", relpath_canonicalize(fspath, pool), - (char *)NULL); -} - -// Examine PATH as a potential URI, and return a substring of PATH -// that immediately follows the (scheme):// portion of the URI, or -// NULL if PATH doesn't appear to be a valid URI. The returned value -// is not allocated -- it shares memory with PATH. -static const char * -skip_uri_scheme( - const char * path) -{ - size_t j = 0; - - // A scheme is terminated by a : and cannot contain any /'s. - for (j = 0; path[j] && (path[j] != ':'); ++j) - if (path[j] == '/') - return NULL; - - if ((j > 0) && (path[j] == ':') && (path[j+1] == '/') && (path[j+2] == '/')) - return path + j + 3; - - return NULL; -} - -static bool -path_is_url( - const char * path) -{ - // This function is reaaaaaaaaaaaaaally stupid right now. - // We're just going to look for: - // (scheme)://(optional_stuff) - // Where (scheme) has no ':' or '/' characters. - // Someday it might be nice to have an actual URI parser here. - - return skip_uri_scheme(path) != NULL; -} - -static const char * -urlpath_canonicalize( - const char * uri, - apr_pool_t * pool) -{ - if (path_is_url(uri)) - { - uri = uri_canonicalize(uri, pool); - } - else - { - uri = fspath_canonicalize(uri, pool); - // Do a little dance to normalize hex encoding. - uri = path_uri_decode(uri, pool); - uri = path_uri_encode(uri, pool); - } - return uri; -} - -// We decided against using apr_filepath_root here because of the negative -// performance impact (creating a pool and converting strings ). -static bool -dirent_is_root( - const char * dirent, - apr_size_t len) -{ - // On Windows and Cygwin, 'H:' or 'H:/' (where 'H' is any letter) - // are also root directories - if ((len == 2 || ((len == 3) && (dirent[2] == '/'))) && - (dirent[1] == ':') && - IsLetter(dirent[0])) - return TRUE; - - // On Windows and Cygwin //server/share is a root directory, - // and on Cygwin //drive is a drive alias - if ((len >= 2) && (dirent[0] == '/') && (dirent[1] == '/') && - (dirent[len - 1] != '/')) - { - int segments = 0; - for (size_t i = len; i >= 2; i--) - { - if (dirent[i] == '/') - { - segments++; - if (segments > 1) - return FALSE; - } - } - return (segments == 1); // //drive is invalid on plain Windows - } - - // directory is root if it's equal to '/' - if ((len == 1) && (dirent[0] == '/')) - return TRUE; - - return FALSE; -} - -static bool -relpath_is_canonical( - const char * relpath) -{ - const char * ptr = relpath, *seg = relpath; - - // RELPATH is canonical if it has: - // - no '.' segments - // - no start and closing '/' - // - no '//' - - if (*relpath == '\0') - return TRUE; - - if (*ptr == '/') - return FALSE; - - // Now validate the rest of the path. - while (1) - { - apr_size_t seglen = ptr - seg; - - if ((seglen == 1) && (*seg == '.')) - return FALSE; // /./ - - if ((*ptr == '/') && (*(ptr+1) == '/')) - return FALSE; // // - - if (!*ptr && (*(ptr - 1) == '/')) - return FALSE; // foo/ - - if (!*ptr) - break; - - if (*ptr == '/') - ptr++; - seg = ptr; - - while (*ptr && (*ptr != '/')) - ptr++; - } - - return TRUE; -} - -static const char * -relpath_basename( - const char * relpath, - apr_pool_t * pool) -{ - apr_size_t len = strlen(relpath); - apr_size_t start = 0; - - assert(relpath_is_canonical(relpath)); - - start = len; - while ((start > 0) && (relpath[start - 1] != '/')) - --start; - - if (pool) - return apr_pstrmemdup(pool, relpath + start, len - start); - else - return relpath + start; -} - -static char * -relpath_join( - const char * base, - const char * component, - apr_pool_t * pool) -{ - apr_size_t blen = strlen(base); - apr_size_t clen = strlen(component); - char * path = NULL; - - assert(relpath_is_canonical(base)); - assert(relpath_is_canonical(component)); - - // If either is empty return the other - if (blen == 0) - return static_cast(apr_pmemdup(pool, component, clen + 1)); - if (clen == 0) - return static_cast(apr_pmemdup(pool, base, blen + 1)); - - path = static_cast(apr_pcalloc(pool, blen + 1 + clen + 1)); - memcpy(path, base, blen); - path[blen] = '/'; - memcpy(path + blen + 1, component, clen + 1); - - return path; -} - -static const char * -dirent_canonicalize( - const char * dirent, - apr_pool_t * pool) -{ - const char * dst = canonicalize(type_dirent, dirent, pool); - - // Handle a specific case on Windows where path == "X:/". Here we have to - // append the final '/', as path_canonicalize will chop this of. - if (IsLetter(dirent[0]) && - (dirent[1] == ':') && (dirent[2] == '/') && - (dst[3] == '\0')) - { - char * dst_slash = static_cast(apr_pcalloc(pool, 4)); - dst_slash[0] = canonicalize_to_upper(dirent[0]); - dst_slash[1] = ':'; - dst_slash[2] = '/'; - dst_slash[3] = '\0'; - - return dst_slash; - } - - return dst; -} - -static bool -dirent_is_canonical( - const char * dirent, - apr_pool_t * pool) -{ - const char * ptr = dirent; - if (*ptr == '/') - { - ptr++; - // Check for UNC paths - if (*ptr == '/') - { - // TODO: Scan hostname and sharename and fall back to part code - - // Fall back to old implementation - return (strcmp(dirent, dirent_canonicalize(dirent, pool)) == 0); - } - } - else if (IsLetter(*ptr) && - (ptr[1] == ':')) - { - // The only canonical drive names are "A:"..."Z:", no lower case - if (!IsUpperCaseLetter(*ptr)) - return FALSE; - - ptr += 2; - - if (*ptr == '/') - ptr++; - } - - return relpath_is_canonical(ptr); -} - -static const char * -dirent_basename( - const char * dirent, - apr_pool_t * pool) -{ - apr_size_t len = strlen(dirent); - apr_size_t start = 0; - - assert(!pool || dirent_is_canonical(dirent, pool)); - - if (dirent_is_root(dirent, len)) - { - return ""; - } - else - { - start = len; - while ((start > 0) && (dirent[start - 1] != '/') && - (dirent[start - 1] != ':')) - { - --start; - } - } - - if (pool) - return apr_pstrmemdup(pool, dirent + start, len - start); - else - return dirent + start; -} - -static const char * -uri_skip_ancestor( - const char * parent_uri, - const char * child_uri) -{ - apr_size_t len = strlen(parent_uri); - - if (0 != strncmp(parent_uri, child_uri, len)) - return NULL; // parent_uri is no ancestor of child_uri - - if (child_uri[len] == 0) - return ""; // parent_uri == child_uri - - if (child_uri[len] == '/') - return child_uri + len + 1; - - return NULL; -} - -static const char * -uri_skip_ancestor( - const char * parent_uri, - const char * child_uri, - apr_pool_t * result_pool) -{ - const char * result = uri_skip_ancestor(parent_uri, child_uri); - - return result ? path_uri_decode(result, result_pool) : NULL; -} - -static bool -dirent_is_rooted( - const char * dirent) -{ - if (!dirent) - return FALSE; - - // Root on all systems - if (dirent[0] == '/') - return TRUE; - - // On Windows, dirent is also absolute when it starts with 'H:' or 'H:/' - // where 'H' is any letter. - if (IsLetter(dirent[0]) && - (dirent[1] == ':')) - { - return TRUE; - } - - return FALSE; -} - -static const char * -is_child( - path_type_t type, - const char * path1, - const char * path2, - apr_pool_t * pool) -{ - apr_size_t i = 0; - - // Allow "" and "foo" or "H:foo" to be parent/child - if (WEBDAV_PATH_IS_EMPTY(path1)) // "" is the parent - { - if (WEBDAV_PATH_IS_EMPTY(path2)) // "" not a child - { - return NULL; - } - - // check if this is an absolute path - if ((type == type_uri) || - (type == type_dirent && dirent_is_rooted(path2))) - { - return NULL; - } - else - { - // everything else is child - return pool ? apr_pstrdup(pool, path2) : path2; - } - } - - for (i = 0; path1[i] && path2[i]; i++) - if (path1[i] != path2[i]) - { - return NULL; - } - - /* FIXME: This comment does not really match - the checks made in the code it refers to: - There are two cases that are parent/child - ... path1[i] == '\0' - .../foo path2[i] == '/' - or - / path1[i] == '\0' - /foo path2[i] != '/' - - Other root paths (like X:/) fall under the former case: - X:/ path1[i] == '\0' - X:/foo path2[i] != '/' - - Check for '//' to avoid matching '/' and '//srv'. - */ - if ((path1[i] == '\0') && path2[i]) - { - if ((path1[i - 1] == '/') || - ((type == type_dirent) && path1[i - 1] == ':')) - { - if (path2[i] == '/') - /* .../ - * ..../ - * i */ - return NULL; - else - /* .../ - * .../foo - * i */ - return pool ? apr_pstrdup(pool, path2 + i) : path2 + i; - } - else if (path2[i] == '/') - { - if (path2[i + 1]) - /* ... - * .../foo - * i */ - return pool ? apr_pstrdup(pool, path2 + i + 1) : path2 + i + 1; - else - /* ... - * .../ - * i */ - return NULL; - } - } - - // Otherwise, path2 isn't a child. - return NULL; -} - -static const char * -uri_is_child( - const char * parent_uri, - const char * child_uri, - apr_pool_t * pool) -{ - const char * relpath = NULL; - - assert(pool); // hysterical raisins. - - relpath = is_child(type_uri, parent_uri, child_uri, pool); - if (relpath) - relpath = path_uri_decode(relpath, pool); - return relpath; -} - -static bool -dirent_is_absolute( - const char * dirent) -{ - if (!dirent) - return FALSE; - - // dirent is absolute if it starts with '/' on non-Windows platforms - // or with '//' on Windows platforms - if ((dirent[0] == '/') && - (dirent[1] == '/')) // Single '/' depends on current drive - { - return TRUE; - } - // On Windows, dirent is also absolute when it starts with 'H:/' - // where 'H' is any letter. - if (IsUpperCaseLetter(dirent[0]) && - (dirent[1] == ':') && (dirent[2] == '/')) - { - return TRUE; - } - - return FALSE; -} - -static error_t -dirent_get_absolute( - const char ** pabsolute, - const char * relative, - apr_pool_t * pool) -{ - char * buffer = NULL; - apr_status_t apr_err = 0; - const char * path_apr = NULL; - - WEBDAV_ERR_ASSERT(!path_is_url(relative)); - - // Merge the current working directory with the relative dirent. - WEBDAV_ERR(path_cstring_from_utf8(&path_apr, relative, pool)); - - apr_err = apr_filepath_merge(&buffer, NULL, - path_apr, - APR_FILEPATH_NOTRELATIVE, - pool); - if (apr_err) - { - // In some cases when the passed path or its ancestor(s) do not exist - // or no longer exist apr returns an error. - - // In many of these cases we would like to return a path anyway, when the - // passed path was already a safe absolute path. So check for that now to - // avoid an error. - - // dirent_is_absolute() doesn't perform the necessary checks to see - // if the path doesn't need post processing to be in the canonical absolute - // format. - - if (dirent_is_absolute(relative) && - dirent_is_canonical(relative, pool) && - !path_is_backpath_present(relative)) - { - *pabsolute = apr_pstrdup(pool, relative); - return WEBDAV_NO_ERROR; - } - - return error_createf(WEBDAV_ERR_BAD_FILENAME, - NULL, - "Couldn't determine absolute path of '%s'", relative); - } - - WEBDAV_ERR(path_cstring_to_utf8(pabsolute, buffer, pool)); - *pabsolute = dirent_canonicalize(*pabsolute, pool); - return WEBDAV_NO_ERROR; -} - -//------------------------------------------------------------------------------ -// from atomic.c - -#define atomic_t apr_uint32_t - -// Magic values for atomic initialization - -#define WEBDAV_ATOMIC_UNINITIALIZED 0 -#define WEBDAV_ATOMIC_START_INIT 1 -#define WEBDAV_ATOMIC_INIT_FAILED 2 -#define WEBDAV_ATOMIC_INITIALIZED 3 - -static error_t -atomic_init_once( - volatile atomic_t * global_status, - error_t (*init_func)(void *,apr_pool_t *), - void * baton, - apr_pool_t * pool) -{ - // We have to call init_func exactly once. Because APR - // doesn't have statically-initialized mutexes, we implement a poor - // man's spinlock using atomic_cas. - atomic_t status = apr_atomic_cas32(global_status, - WEBDAV_ATOMIC_START_INIT, - WEBDAV_ATOMIC_UNINITIALIZED); - - if (status == WEBDAV_ATOMIC_UNINITIALIZED) - { - error_t err = init_func(baton, pool); - if (err) - { -#if APR_HAS_THREADS - // Tell other threads that the initialization failed. - apr_atomic_cas32(global_status, - WEBDAV_ATOMIC_INIT_FAILED, - WEBDAV_ATOMIC_START_INIT); -#endif - return error_create(WEBDAV_ERR_ATOMIC_INIT_FAILURE, &err, - "Couldn't perform atomic initialization"); - } - apr_atomic_cas32(global_status, - WEBDAV_ATOMIC_INITIALIZED, - WEBDAV_ATOMIC_START_INIT); - } -#if APR_HAS_THREADS - // Wait for whichever thread is performing initialization to finish. - // XXX FIXME: Should we have a maximum wait here, like we have in - // the Windows file IO spinner? - else while (status != WEBDAV_ATOMIC_INITIALIZED) - { - if (status == WEBDAV_ATOMIC_INIT_FAILED) - return error_create(WEBDAV_ERR_ATOMIC_INIT_FAILURE, NULL, - "Couldn't perform atomic initialization"); - - apr_sleep(APR_USEC_PER_SEC / 1000); - status = apr_atomic_cas32(global_status, - WEBDAV_ATOMIC_UNINITIALIZED, - WEBDAV_ATOMIC_UNINITIALIZED); - } -#endif // APR_HAS_THREADS - - return WEBDAV_NO_ERROR; -} - -//------------------------------------------------------------------------------ -// from io.c - -#define RETRY_MAX_ATTEMPTS 2 -#define RETRY_INITIAL_SLEEP 1000 -#define RETRY_MAX_SLEEP 128000 - -// Suppress warning: Condition is always true -#pragma warn -8008 -#define RETRY_LOOP(err, expr, retry_test, sleep_test) \ - do \ - { \ - apr_status_t os_err = APR_TO_OS_ERROR(err); \ - int sleep_count = RETRY_INITIAL_SLEEP; \ - int retries; \ - for (retries = 0; \ - retries < RETRY_MAX_ATTEMPTS && (retry_test); \ - os_err = APR_TO_OS_ERROR(err)) \ - { \ - if (sleep_test) \ - { \ - ++retries; \ - apr_sleep(sleep_count); \ - if (sleep_count < RETRY_MAX_SLEEP) \ - sleep_count *= 2; \ - } \ - (err) = (expr); \ - } \ - } \ - while (0) - -#if defined(EDEADLK) && APR_HAS_THREADS -#define FILE_LOCK_RETRY_LOOP(err, expr) \ - RETRY_LOOP(err, \ - expr, \ - (APR_STATUS_IS_EINTR(err) || os_err == EDEADLK), \ - (!APR_STATUS_IS_EINTR(err))) -#else -#define FILE_LOCK_RETRY_LOOP(err, expr) \ - RETRY_LOOP(err, \ - expr, \ - (APR_STATUS_IS_EINTR(err)), \ - 0) -#endif - -#ifndef WIN32_RETRY_LOOP -#if !defined(WEBDAV_NO_WIN32_RETRY_LOOP) -#define WIN32_RETRY_LOOP(err, expr) \ - RETRY_LOOP(err, expr, (os_err == ERROR_ACCESS_DENIED || \ - os_err == ERROR_SHARING_VIOLATION || \ - os_err == ERROR_DIR_NOT_EMPTY), \ - 1) -#else -#define WIN32_RETRY_LOOP(err, expr) ((void)0) -#endif -#endif - -// Not specifying any of these means no removal at all. -typedef enum io_file_del_t -{ - // No deletion ever - io_file_del_none = 0, - // Remove when the file is closed - io_file_del_on_close, - // Remove when the associated pool is cleared - io_file_del_on_pool_cleanup -} io_file_del_t; - -// Wrapper for apr_file_open(), taking an APR-encoded filename. -static apr_status_t -file_open( - apr_file_t ** file, - const char * fname_apr, - apr_int32_t flags, - apr_fileperms_t perm, - bool retry_on_failure, - apr_pool_t * pool) -{ - apr_status_t status = apr_file_open(file, fname_apr, flags, perm, pool); - - if (retry_on_failure) - { - WIN32_RETRY_LOOP(status, apr_file_open(file, fname_apr, flags, perm, pool)); - } - return status; -} -#pragma warn +8008 - -static error_t -io_file_open( - apr_file_t ** new_file, - const char * fname, - apr_int32_t flags, - apr_fileperms_t perms, - apr_pool_t * pool) -{ - const char * fname_apr = NULL; - apr_status_t status = 0; - - WEBDAV_ERR(cstring_from_utf8(&fname_apr, fname, pool)); - status = file_open(new_file, fname_apr, flags | APR_BINARY, perms, - /* retry_on_failure */ FALSE, - pool); - - if (status) - return error_wrap_apr(status, "Can't open file '%s'", fname); - else - return WEBDAV_NO_ERROR; -} - -static error_t -io_file_open_writable( - apr_file_t ** new_file, - apr_os_file_t * thefile, - apr_int32_t flags, - apr_pool_t * pool) -{ - apr_status_t status = 0; - - status = apr_os_file_put(new_file, thefile, - flags | APR_BINARY, - pool); - - if (status) - return error_wrap_apr(status, "Can't open file"); - else - return WEBDAV_NO_ERROR; -} - -// Wrapper for apr_file_name_get(), passing out a UTF8-encoded filename. -static error_t -io_file_name_get( - const char ** filename, - apr_file_t * file, - apr_pool_t * pool) -{ - const char * fname_apr = NULL; - apr_status_t status = 0; - - status = apr_file_name_get(&fname_apr, file); - if (status) - return error_wrap_apr(status, "Can't get file name"); - - if (fname_apr) - WEBDAV_ERR(path_cstring_to_utf8(filename, fname_apr, pool)); - else - *filename = NULL; - - return WEBDAV_NO_ERROR; -} - -static APR_INLINE error_t -do_io_file_wrapper_cleanup( - apr_file_t * file, - apr_status_t status, - const char * msg, - const char * msg_no_name, - apr_pool_t * pool) -{ - const char * name = NULL; - error_t err = 0; - - if (!status) - return WEBDAV_NO_ERROR; - - err = io_file_name_get(&name, file, pool); - if (err) - name = NULL; - error_clear(&err); - - // Issue #3014: Return a specific error for broken pipes, - // with a single element in the error chain. - if (APR_STATUS_IS_EPIPE(status)) - return error_create(WEBDAV_ERR_IO_PIPE_WRITE_ERROR, NULL, NULL); - - if (name) - return error_wrap_apr(status, msg, name); - else - return error_wrap_apr(status, "%s", msg_no_name); -} - -static error_t -io_file_close( - apr_file_t * file, - apr_pool_t * pool) -{ - return do_io_file_wrapper_cleanup(file, apr_file_close(file), - "Can't close file '%s'", - "Can't close stream", - pool); -} - -static error_t -io_file_getc( - char * ch, - apr_file_t * file, - apr_pool_t * pool) -{ - return do_io_file_wrapper_cleanup(file, apr_file_getc(ch, file), - "Can't read file '%s'", - "Can't read stream", - pool); -} - -static error_t -io_file_write_full( - apr_file_t * file, - const void * buf, - apr_size_t nbytes, - apr_size_t * bytes_written, - apr_pool_t * pool) -{ - // We cannot simply call apr_file_write_full on Win32 as it may fail - // for larger values of NBYTES. In that case, we have to emulate the - // "_full" part here. Thus, always call apr_file_write directly on - // Win32 as this minimizes overhead for small data buffers. -#define MAXBUFSIZE 64*1024 - apr_size_t bw = nbytes; - apr_size_t to_write = nbytes; - - // try a simple "write everything at once" first - apr_status_t rv = apr_file_write(file, buf, &bw); - buf = (char *)buf + bw; - to_write -= bw; - - // if the OS cannot handle that, use smaller chunks - if ((rv == APR_FROM_OS_ERROR(ERROR_NOT_ENOUGH_MEMORY)) && - (nbytes > MAXBUFSIZE)) - { - do - { - bw = to_write > MAXBUFSIZE ? MAXBUFSIZE : to_write; - rv = apr_file_write(file, buf, &bw); - buf = (char *)buf + bw; - to_write -= bw; - } - while (rv == APR_SUCCESS && to_write > 0); - } - - // bytes_written may actually be NULL - if (bytes_written) - *bytes_written = nbytes - to_write; -#undef MAXBUFSIZE - - return error_trace(do_io_file_wrapper_cleanup(file, rv, - "Can't write to file '%s'", - "Can't write to stream", - pool)); -} - -static error_t -io_file_seek( - apr_file_t * file, - apr_seek_where_t where, - apr_off_t * offset, - apr_pool_t * pool) -{ - return do_io_file_wrapper_cleanup(file, apr_file_seek(file, where, offset), - "Can't set position pointer in file '%s'", - "Can't set position pointer in stream", - pool); -} - -static error_t -io_file_putc( - char ch, - apr_file_t * file, - apr_pool_t * pool) -{ - return do_io_file_wrapper_cleanup(file, apr_file_putc(ch, file), - "Can't write file '%s'", - "Can't write stream", - pool); -} - -static error_t -io_file_read( - apr_file_t * file, - void * buf, - apr_size_t * nbytes, - apr_pool_t * pool) -{ - return do_io_file_wrapper_cleanup(file, apr_file_read(file, buf, nbytes), - "Can't read file '%s'", - "Can't read stream", - pool); -} - -// Local wrapper of path_cstring_from_utf8() that does no copying on -// operating systems where APR always uses utf-8 as native path format -static error_t -cstring_from_utf8( - const char ** path_apr, - const char * path_utf8, - apr_pool_t * pool) -{ - *path_apr = path_utf8; - return WEBDAV_NO_ERROR; -} - -static error_t -io_file_read_full2( - apr_file_t * file, - void * buf, - apr_size_t nbytes, - apr_size_t * bytes_read, - bool * hit_eof, - apr_pool_t * pool) -{ - apr_status_t status = apr_file_read_full(file, buf, nbytes, bytes_read); - if (hit_eof) - { - if (APR_STATUS_IS_EOF(status)) - { - *hit_eof = TRUE; - return WEBDAV_NO_ERROR; - } - else - *hit_eof = FALSE; - } - - return do_io_file_wrapper_cleanup(file, status, - "Can't read file '%s'", - "Can't read stream", - pool); -} - -//------------------------------------------------------------------------------ -// from svn_io.h - -// Read handler function for a generic stream. see stream_t. -typedef error_t (*read_fn_t)( - void * baton, - char * buffer, - apr_size_t * len); - -// Skip data handler function for a generic stream. see stream_t -// and stream_skip(). - -typedef error_t (*stream_skip_fn_t)( - void * baton, - apr_size_t len); - -// Write handler function for a generic stream. see stream_t. -typedef error_t (*write_fn_t)( - void * baton, - const char * data, - apr_size_t * len); - -// Close handler function for a generic stream. see stream_t. -typedef error_t (*close_fn_t)(void * baton); - -typedef struct stream_mark_t stream_mark_t; - -typedef error_t (*stream_mark_fn_t)( - void * baton, - stream_mark_t ** mark, - apr_pool_t * pool); - -typedef error_t (*stream_seek_fn_t)( - void * baton, - const stream_mark_t * mark); - -typedef bool (*stream_is_buffered_fn_t)(void * baton); - -//------------------------------------------------------------------------------ -// from stream.c - -typedef struct stream_t -{ - void * baton; - read_fn_t read_fn; - stream_skip_fn_t skip_fn; - write_fn_t write_fn; - close_fn_t close_fn; - stream_mark_fn_t mark_fn; - stream_seek_fn_t seek_fn; - stream_is_buffered_fn_t is_buffered_fn; -} stream_t; - -// Generic stream for APR files -struct baton_apr_t -{ - apr_file_t * file; - apr_pool_t * pool; -}; - -// stream_mark_t for streams backed by APR files. -struct mark_apr_t -{ - apr_off_t off; -}; - -static error_t -read_handler_apr( - void * baton, - char * buffer, - apr_size_t * len) -{ - struct baton_apr_t * btn = static_cast(baton); - error_t err = 0; - bool eof = FALSE; - - if (*len == 1) - { - err = io_file_getc(buffer, btn->file, btn->pool); - if (err) - { - *len = 0; - if (APR_STATUS_IS_EOF(err)) - { - error_clear(&err); - err = WEBDAV_NO_ERROR; - } - } - } - else - err = io_file_read_full2(btn->file, buffer, *len, len, - &eof, btn->pool); - - return err; -} - -static error_t -skip_handler_apr( - void * baton, - apr_size_t len) -{ - struct baton_apr_t * btn = static_cast(baton); - apr_off_t offset = len; - - return io_file_seek(btn->file, APR_CUR, &offset, btn->pool); -} - -static error_t -write_handler_apr( - void * baton, - const char * data, - apr_size_t * len) -{ - struct baton_apr_t * btn = static_cast(baton); - error_t err = 0; - - if (*len == 1) - { - err = io_file_putc(*data, btn->file, btn->pool); - if (err) - *len = 0; - } - else - err = io_file_write_full(btn->file, data, *len, len, btn->pool); - - return err; -} - -static error_t -close_handler_apr( - void * baton) -{ - struct baton_apr_t * btn = static_cast(baton); - - return io_file_close(btn->file, btn->pool); -} - -static error_t -mark_handler_apr( - void * baton, - stream_mark_t ** mark, - apr_pool_t * pool) -{ - struct baton_apr_t * btn = static_cast(baton); - struct mark_apr_t * mark_apr = 0; - - mark_apr = static_cast(apr_pcalloc(pool, sizeof(*mark_apr))); - mark_apr->off = 0; - WEBDAV_ERR(io_file_seek(btn->file, APR_CUR, &mark_apr->off, btn->pool)); - *mark = (stream_mark_t *)mark_apr; - return WEBDAV_NO_ERROR; -} - -static error_t -seek_handler_apr( - void * baton, - const stream_mark_t * mark) -{ - struct baton_apr_t * btn = static_cast(baton); - apr_off_t offset = (mark != NULL) ? ((const struct mark_apr_t *)mark)->off : 0; - - WEBDAV_ERR(io_file_seek(btn->file, APR_SET, &offset, btn->pool)); - - return WEBDAV_NO_ERROR; -} - -static bool -is_buffered_handler_apr( - void * baton) -{ - struct baton_apr_t * btn = static_cast(baton); - return (apr_file_flags_get(btn->file) & APR_BUFFERED) != 0; -} - -static stream_t * -stream_create( - void * baton, - apr_pool_t * pool) -{ - stream_t * stream = static_cast(apr_pcalloc(pool, sizeof(*stream))); - stream->baton = baton; - stream->read_fn = NULL; - stream->skip_fn = NULL; - stream->write_fn = NULL; - stream->close_fn = NULL; - stream->mark_fn = NULL; - stream->seek_fn = NULL; - stream->is_buffered_fn = NULL; - return stream; -} - -static void -stream_set_read( - stream_t * stream, - read_fn_t read_fn) -{ - stream->read_fn = read_fn; -} - -static void -stream_set_skip( - stream_t * stream, - stream_skip_fn_t skip_fn) -{ - stream->skip_fn = skip_fn; -} - -static void -stream_set_write( - stream_t * stream, - write_fn_t write_fn) -{ - stream->write_fn = write_fn; -} - -static void -stream_set_close( - stream_t * stream, - close_fn_t close_fn) -{ - stream->close_fn = close_fn; -} - -static void -stream_set_mark( - stream_t * stream, - stream_mark_fn_t mark_fn) -{ - stream->mark_fn = mark_fn; -} - -static void -stream_set_seek( - stream_t * stream, - stream_seek_fn_t seek_fn) -{ - stream->seek_fn = seek_fn; -} - -static void -stream_set_is_buffered( - stream_t * stream, - stream_is_buffered_fn_t is_buffered_fn) -{ - stream->is_buffered_fn = is_buffered_fn; -} - -static error_t -read_handler_empty( - void * baton, - char * buffer, - apr_size_t * len) -{ - *len = 0; - return WEBDAV_NO_ERROR; -} - -static error_t -write_handler_empty( - void * baton, - const char * data, - apr_size_t * len) -{ - return WEBDAV_NO_ERROR; -} - -static error_t -mark_handler_empty( - void * baton, - stream_mark_t ** mark, - apr_pool_t * pool) -{ - *mark = NULL; // Seek to start of stream marker - return WEBDAV_NO_ERROR; -} - -static error_t -seek_handler_empty( - void * baton, - const stream_mark_t * mark) -{ - return WEBDAV_NO_ERROR; -} - -static bool -is_buffered_handler_empty(void * baton) -{ - return FALSE; -} - -static stream_t * -stream_empty( - apr_pool_t * pool) -{ - stream_t * stream = stream_create(NULL, pool); - stream_set_read(stream, read_handler_empty); - stream_set_write(stream, write_handler_empty); - stream_set_mark(stream, mark_handler_empty); - stream_set_seek(stream, seek_handler_empty); - stream_set_is_buffered(stream, is_buffered_handler_empty); - return stream; -} - -static stream_t * -stream_from_aprfile2( - apr_file_t * file, - bool disown, - apr_pool_t * pool) -{ - stream_t * stream = NULL; - - if (file == NULL) - return stream_empty(pool); - - baton_apr_t * baton = static_cast(apr_pcalloc(pool, sizeof(*baton))); - baton->file = file; - baton->pool = pool; - stream = stream_create(baton, pool); - stream_set_read(stream, read_handler_apr); - stream_set_write(stream, write_handler_apr); - stream_set_skip(stream, skip_handler_apr); - stream_set_mark(stream, mark_handler_apr); - stream_set_seek(stream, seek_handler_apr); - stream_set_is_buffered(stream, is_buffered_handler_apr); - - if (!disown) - stream_set_close(stream, close_handler_apr); - - return stream; -} - -static error_t -stream_open_writable( - stream_t ** stream, - apr_os_file_t * thefile, - apr_pool_t * result_pool, - apr_pool_t * scratch_pool) -{ - apr_file_t * file = NULL; - WEBDAV_ERR(io_file_open_writable(&file, - thefile, - APR_WRITE - | APR_BUFFERED - | APR_BINARY - | APR_CREATE, - // | APR_EXCL, - result_pool)); - *stream = stream_from_aprfile2(file, FALSE, result_pool); - - return WEBDAV_NO_ERROR; -} - -static error_t -stream_write( - stream_t * stream, - const char * data, - apr_size_t * len) -{ - WEBDAV_ERR_ASSERT(stream->write_fn != NULL); - return stream->write_fn(stream->baton, data, len); -} - -static error_t -stream_close( - stream_t * stream) -{ - if (stream->close_fn == NULL) - return WEBDAV_NO_ERROR; - return stream->close_fn(stream->baton); -} - -//------------------------------------------------------------------------------ -// from util.c - -static apr_status_t -dav_request_cleanup( - void * baton); - -static apr_status_t -dav_request_sess_cleanup( - void * baton) -{ - neon_request_t * req = static_cast(baton); - - // Make sure we don't run the 'child' cleanup anymore: - // the pool it refers to probably doesn't exist anymore when it - // finally does get run if it hasn't by now. - apr_pool_cleanup_kill(req->pool, req, dav_request_cleanup); - - if (req->ne_req) - ne_request_destroy(req->ne_req); - - return APR_SUCCESS; -} - -static apr_status_t -dav_request_cleanup( - void * baton) -{ - neon_request_t * req = static_cast(baton); - apr_pool_cleanup_run(req->sess->pool, req, dav_request_sess_cleanup); - - return APR_SUCCESS; -} - -// Return a path-absolute relative URL, given a URL reference (which may -// be absolute or relative). -static const char * -path_from_url( - const char * url) -{ - const char * p = NULL; - - // Look for the scheme/authority separator. Stop if we see a path - // separator - that indicates that this definitely isn't an absolute URL. - for (p = url; *p; p++) - { - if ((*p == ':') || (*p == '/')) - break; - } - - // Check whether we found the scheme/authority separator. - if ((*p++ != ':') || (*p++ != '/') || (*p++ != '/')) - { - // No separator, so it must already be relative. - return url; - } - - // Find the end of the authority section, indicated by the start of - // a path, query, or fragment section. - for (; *p; p++) - { - if ((*p == '/') || (*p == '?') || (*p == '#')) - break; - } - - // Return a pointer to the rest of the URL, or to "/" if there - // was no next section. - return *p == '\0' ? "/" : p; -} - -// Simple multi-status parser -// For the purpose of 'simple' requests which - if it weren't -// for our custom error parser - could use the ne_basic.h interfaces. - -// List of XML elements expected in 207 Multi-Status responses. -static const neon_xml_elm_t multistatus_elements[] = -{ - { "DAV:", "multistatus", ELEM_multistatus, 0 }, - { "DAV:", "response", ELEM_response, 0 }, - { - "DAV:", "responsedescription", ELEM_responsedescription, - NEON_XML_CDATA - }, - { "DAV:", "status", ELEM_status, NEON_XML_CDATA }, - { "DAV:", "href", ELEM_href, NEON_XML_CDATA }, - { "DAV:", "propstat", ELEM_propstat, NEON_XML_CDATA }, - { "DAV:", "prop", ELEM_prop, NEON_XML_CDATA }, - - // We start out basic and are not interested in other elements - { "", "", ELEM_unknown, 0 }, - - { NULL } -}; - -static const int multistatus_nesting_table[][5] = -{ - { ELEM_root, ELEM_multistatus, NEON_XML_INVALID }, - { - ELEM_multistatus, ELEM_response, ELEM_responsedescription, - NEON_XML_DECLINE - }, - { ELEM_responsedescription, NEON_XML_INVALID }, - { - ELEM_response, ELEM_href, ELEM_status, ELEM_propstat, - NEON_XML_DECLINE - }, - { ELEM_status, NEON_XML_INVALID }, - { ELEM_href, NEON_XML_INVALID }, - { - ELEM_propstat, ELEM_prop, ELEM_status, ELEM_responsedescription, - NEON_XML_INVALID - }, - { ELEM_prop, NEON_XML_DECLINE }, - { NEON_XML_DECLINE }, -}; - -static int -multistatus_validate_element( - int parent, - int child) -{ - int i = 0; - int j = 0; - - while ((parent != multistatus_nesting_table[i][0]) && - (multistatus_nesting_table[i][0] > 0 || i == 0)) - i++; - - if (parent == multistatus_nesting_table[i][0]) - while ((multistatus_nesting_table[i][++j] != child) && - (multistatus_nesting_table[i][j] > 0)) - ; - - return multistatus_nesting_table[i][j]; -} - -typedef struct multistatus_baton_t -{ - stringbuf_t * want_cdata; - stringbuf_t * cdata; - - bool in_propstat; - bool propstat_has_error; - stringbuf_t * propname; - stringbuf_t * propstat_description; - - neon_request_t * req; - stringbuf_t * description; - bool contains_error; - bool contains_precondition_error; -} multistatus_baton_t; - -// Implements neon_startelm_cb_t. -static error_t -start_207_element( - int * elem, - void * baton, - int parent, - const char * nspace, - const char * name, - const char ** atts) -{ - multistatus_baton_t * b = static_cast(baton); - const neon_xml_elm_t * elm = - neon_lookup_xml_elem(multistatus_elements, nspace, name); - *elem = elm ? multistatus_validate_element(parent, elm->id) : NEON_XML_DECLINE; - - if (parent == ELEM_prop) - { - stringbuf_setempty(b->propname); - if (strcmp(nspace, "DAV:") == 0) - stringbuf_set(b->propname, "DAV:"); - - stringbuf_appendcstr(b->propname, name); - } - - if (*elem < 1) // ! > 0 - return WEBDAV_NO_ERROR; - - switch (*elem) - { - case ELEM_propstat: - b->in_propstat = TRUE; - b->propstat_has_error = FALSE; - break; - - default: - break; - } - - // We're guaranteed to have ELM now: NEON_XML_DECLINE < 1 - if (elm->flags & NEON_XML_CDATA) - { - stringbuf_setempty(b->cdata); - b->want_cdata = b->cdata; - } - - return WEBDAV_NO_ERROR; -} - -// Implements neon_endelm_cb_t -static error_t -end_207_element( - void * baton, - int state, - const char * nspace, - const char * name) -{ - multistatus_baton_t * b = static_cast(baton); - - switch (state) - { - case ELEM_multistatus: - if (b->contains_error) - { - if (stringbuf_isempty(b->description)) - return error_create(WEBDAV_ERR_DAV_REQUEST_FAILED, NULL, - "The request response contained at least one error"); - else if (b->contains_precondition_error) - return error_create(WEBDAV_ERR_FS_PROP_BASEVALUE_MISMATCH, NULL, - b->description->data); - else - return error_create(WEBDAV_ERR_DAV_REQUEST_FAILED, NULL, - b->description->data); - } - break; - - case ELEM_responsedescription: - if (b->in_propstat) - stringbuf_set(b->propstat_description, b->cdata->data); - else - { - if (!stringbuf_isempty(b->description)) - stringbuf_appendcstr(b->description, "\n"); - stringbuf_appendstr(b->description, b->cdata); - } - break; - - case ELEM_status: - { - ne_status status; - - if (ne_parse_statusline(b->cdata->data, &status) == 0) - { - // I wanted ||=, but I guess the end result is the same - if (!b->in_propstat) - b->contains_error |= (status.klass != 2); - else - b->propstat_has_error = (status.klass != 2); - - // Handle "412 Precondition Failed" specially - if (status.code == 412) - b->contains_precondition_error = TRUE; - - ne_free(status.reason_phrase); - } - else - return error_create(WEBDAV_ERR_DAV_REQUEST_FAILED, NULL, - "The response contains a non-conforming HTTP status line"); - } - break; - - case ELEM_propstat: - b->in_propstat = FALSE; - b->contains_error |= b->propstat_has_error; - stringbuf_appendcstr(b->description, - apr_psprintf(b->req->pool, - "Error setting property '%s': ", - b->propname->data)); - stringbuf_appendstr(b->description, - b->propstat_description); - - default: - // do nothing - break; - } - - // When we have an element which wants cdata, - // we'll set it all up in start_207_element() again - b->want_cdata = NULL; - - return WEBDAV_NO_ERROR; -} - -// Create a status parser attached to the request REQ. Detected errors -// will be returned there. -static void -multistatus_parser_create( - neon_request_t * req) -{ - multistatus_baton_t * b = static_cast(apr_pcalloc(req->pool, sizeof(*b))); - - // Create a parser, attached to REQ. (Ignore the return value.) - neon_xml_parser_create(req, ne_accept_207, - start_207_element, - neon_xml_collect_cdata, - end_207_element, b); - b->cdata = stringbuf_create("", req->pool); - b->description = stringbuf_create("", req->pool); - b->req = req; - - b->propname = stringbuf_create("", req->pool); - b->propstat_description = stringbuf_create("", req->pool); -} - -static apr_status_t -compressed_body_reader_cleanup( - void * baton) -{ - if (baton) - ne_decompress_destroy(static_cast(baton)); - - return APR_SUCCESS; -} - -// Attach READER as a response reader for the request REQ, with the -// acceptance function ACCPT. The response body data will be decompressed, -// if compressed, before being passed to READER. USERDATA will be passed as -// the first argument to the acceptance and reader callbacks. -static void -attach_ne_body_reader( - neon_request_t * req, - ne_accept_response accpt, - ne_block_reader reader, - void * userdata) -{ - if (req->sess->compression) - { - ne_decompress * decompress = - ne_decompress_reader(req->ne_req, accpt, reader, userdata); - - apr_pool_cleanup_register(req->pool, - decompress, - compressed_body_reader_cleanup, - apr_pool_cleanup_null); - } - else - ne_add_response_body_reader(req->ne_req, accpt, reader, userdata); -} - -typedef struct cancellation_baton_t -{ - ne_block_reader real_cb; - void * real_userdata; - neon_request_t * req; -} cancellation_baton_t; - -static int -cancellation_callback( - void * userdata, - const char * block, - size_t len) -{ - cancellation_baton_t * b = static_cast(userdata); - neon_session_t * ras = b->req->sess; - - if (ras->callbacks->cancel_func) - { - NEON_REQ_ERR(b->req, (ras->callbacks->cancel_func)(ras->callback_baton)); - } - if (b->req->err) - return 1; - else - return (b->real_cb)(b->real_userdata, block, len); -} - -static cancellation_baton_t * -get_cancellation_baton( - neon_request_t * req, - ne_block_reader real_cb, - void * real_userdata, - apr_pool_t * pool) -{ - cancellation_baton_t * b = static_cast(apr_pcalloc(pool, sizeof(*b))); - - b->real_cb = real_cb; - b->real_userdata = real_userdata; - b->req = req; - - return b; -} - -typedef struct body_provider_baton_t -{ - neon_request_t * req; - apr_file_t * body_file; -} body_provider_baton_t; - -static ssize_t -ra_neon_body_provider( - void * userdata, - char * buffer, - size_t buflen) -{ - body_provider_baton_t * b = static_cast(userdata); - neon_request_t * req = b->req; - apr_file_t * body_file = b->body_file; - - if (req->sess->callbacks && - req->sess->callbacks->cancel_func) - { - NEON_REQ_ERR(req, (req->sess->callbacks->cancel_func)( - req->sess->callback_baton)); - } - - if (req->err) - return -1; - - webdav_pool_clear(req->iterpool); - if (buflen == 0) - { - // This is the beginning of a new body pull. Rewind the file. - apr_off_t offset = 0; - NEON_REQ_ERR(b->req, io_file_seek(body_file, APR_SET, &offset, req->iterpool)); - return (req->err ? -1 : 0); - } - else - { - callback_baton_t * cb = static_cast(req->sess->callback_baton); - - TWebDAVFileSystem * fs = static_cast(apr_hash_get(cb->ctx->auth_baton->parameters, - CONST_FS_KEY, - APR_HASH_KEY_STRING)); - assert(fs); - fs->AdjustToCPSLimit(buflen); - - apr_size_t nbytes = buflen; - error_t err = io_file_read(body_file, buffer, &nbytes, - req->iterpool); - if (err) - { - if (APR_STATUS_IS_EOF(err)) - { - error_clear(&err); - return 0; - } - - NEON_REQ_ERR(req, err); - return -1; - } - else - return (ssize_t)nbytes; - } -} - -static error_t -neon_set_neon_body_provider( - neon_request_t * req, - apr_file_t * body_file) -{ - apr_status_t status = 0; - apr_finfo_t finfo = {0}; - body_provider_baton_t * b = static_cast(apr_pcalloc(req->pool, sizeof(*b))); - - status = apr_file_info_get(&finfo, APR_FINFO_SIZE, body_file); - if (status) - return error_wrap_apr(status, - "Can't calculate the request body size"); - - b->body_file = body_file; - b->req = req; - - ne_set_request_body_provider(req->ne_req, (ne_off_t)finfo.size, - ra_neon_body_provider, b); - - return WEBDAV_NO_ERROR; -} - -// See doc string for neon_parsed_request. -static error_t -parsed_request( - neon_request_t * req, - neon_session_t * ras, - const char * method, - const char * url, - const char * body, - apr_file_t * body_file, - void set_parser(ne_xml_parser * parser, void * baton), - neon_startelm_cb_t startelm_cb, - neon_cdata_cb_t cdata_cb, - neon_endelm_cb_t endelm_cb, - void * baton, - apr_hash_t * extra_headers, - int * status_code, - bool check_errors, - apr_pool_t * pool) -{ - ne_xml_parser * success_parser = NULL; - - if (body == NULL) - WEBDAV_ERR(neon_set_neon_body_provider(req, body_file)); - - // use a symbolic name somewhere for this MIME type? - ne_add_request_header(req->ne_req, "Content-Type", "text/xml"); - - // create a parser to read the normal response body - success_parser = neon_xml_parser_create(req, NULL, - startelm_cb, cdata_cb, - endelm_cb, baton); - - // if our caller is interested in having access to this parser, call - // the SET_PARSER callback with BATON. - if (set_parser != NULL) - set_parser(success_parser, baton); - - // Register the "main" accepter and body-reader with the request -- - // the one to use when the HTTP status is 2XX. - attach_ne_body_reader(req, ne_accept_2xx, cancellation_callback, - get_cancellation_baton(req, ne_xml_parse_v, - success_parser, pool)); - - // run the request and get the resulting status code. - WEBDAV_ERR(neon_request_dispatch( - status_code, req, extra_headers, body, - (strcmp(method, "PROPFIND") == 0) ? 207 : 200, - 0, - check_errors, - pool)); - - WEBDAV_ERR(neon_check_parse_error(method, success_parser, url)); - - return WEBDAV_NO_ERROR; -} - -static error_t -neon_parsed_request( - neon_session_t * sess, - const char * method, - const char * url, - const char * body, - apr_file_t * body_file, - void set_parser(ne_xml_parser * parser, void * baton), - neon_startelm_cb_t startelm_cb, - neon_cdata_cb_t cdata_cb, - neon_endelm_cb_t endelm_cb, - void * baton, - apr_hash_t * extra_headers, - int * status_code, - bool check_errors, - apr_pool_t * pool) -{ - // create/prep the request - neon_request_t * req = NULL; - error_t err = 0; - - WEBDAV_ERR(neon_request_create(&req, sess, method, url, pool)); - - err = parsed_request(req, sess, method, url, body, body_file, - set_parser, startelm_cb, cdata_cb, endelm_cb, - baton, extra_headers, status_code, - check_errors, - pool); - - neon_request_destroy(req); - return err; -} - -static error_t -neon_simple_request( - int * code, - neon_session_t * ras, - const char * method, - const char * url, - apr_hash_t * extra_headers, - const char * body, - int okay_1, int okay_2, apr_pool_t * pool) -{ - neon_request_t * req = NULL; - error_t err = 0; - - WEBDAV_ERR(neon_request_create(&req, ras, method, url, pool)); - - multistatus_parser_create(req); - - // neon_request_dispatch() adds the custom error response - // reader. Neon will take care of the Content-Length calculation - err = neon_request_dispatch(code, req, extra_headers, - body ? body : "", - okay_1, okay_2, false, pool); - neon_request_destroy(req); - - return err; -} - -static void -neon_add_depth_header( - apr_hash_t * extra_headers, - int depth) -{ - assert(extra_headers != NULL); - assert(depth == NEON_DEPTH_ZERO || - depth == NEON_DEPTH_ONE || - depth == NEON_DEPTH_INFINITE); - apr_hash_set(extra_headers, "Depth", APR_HASH_KEY_STRING, - (depth == NEON_DEPTH_INFINITE) ? - "infinity" : (depth == NEON_DEPTH_ZERO) ? "0" : "1"); - - return; -} - -static const neon_xml_elm_t * -neon_lookup_xml_elem( - const neon_xml_elm_t * table, - const char * nspace, - const char * name) -{ - // placeholder for `unknown' element if it's present - const neon_xml_elm_t * elem_unknown = NULL; - const neon_xml_elm_t * elem = NULL; - - for (elem = table; elem->nspace; ++elem) - { - if ((strcmp(elem->nspace, nspace) == 0) && - (strcmp(elem->name, name) == 0)) - return elem; - - // Use a single loop to save CPU cycles. - // Maybe this element is defined as `unknown'? - if (elem->id == ELEM_unknown) - elem_unknown = elem; - } - - // ELEM_unknown position in the table or NULL - return elem_unknown; -} - -static error_t -neon_xml_collect_cdata( - void * baton, - int state, - const char * cdata, - size_t len) -{ - stringbuf_t ** b = static_cast(baton); - - if (*b) - stringbuf_appendbytes(*b, cdata, len); - - return WEBDAV_NO_ERROR; -} - -// Custom function of type ne_accept_response. -static int -ra_neon_error_accepter( - void * userdata, - ne_request * req, - const ne_status * st) -{ - // Before, this function was being run for *all* responses including - // the 401 auth challenge. In neon 0.24.x that was harmless. But - // in neon 0.25.0, trying to parse a 401 response as XML using - // ne_xml_parse_v aborts the response; so the auth hooks never got a - // chance. - ne_content_type ctype = {0}; - - // Only accept non-2xx responses with text/xml content-type - if (st->klass != 2 && ne_get_content_type(req, &ctype) == 0) - { - int is_xml = (strcmp(ctype.type, "text") == 0) && - (strcmp(ctype.subtype, "xml") == 0); - ne_free(ctype.value); - return is_xml; - } - else - return 0; -} - -static const neon_xml_elm_t error_elements[] = -{ - { "DAV:", "error", ELEM_error, 0 }, - { - "http://apache.org/dav/xmlns", "human-readable", - ELEM_human_readable, NEON_XML_CDATA - }, - - // our validator doesn't yet recognize the rich, specific - // objects as defined by DeltaV. - - { NULL } -}; - -static error_t -xml_parser_cleanup(void * baton) -{ - ne_xml_destroy(static_cast(baton)); - - return WEBDAV_NO_ERROR; -} - -static ne_xml_parser * -xml_parser_create( - neon_request_t * req) -{ - ne_xml_parser * p = ne_xml_create(); - - // HACK: Set the parser's error to the empty string. Someday we - // hope neon will let us have an easy way to tell the difference - // between XML parsing errors, and errors that occur while handling - // the XML tags that we get. Until then, trust that whenever neon - // has an error somewhere below the API, it sets its own error to - // something non-empty (the API promises non-NULL, at least). - ne_xml_set_error(p, ""); - - apr_pool_cleanup_register(req->pool, p, - xml_parser_cleanup, - apr_pool_cleanup_null); - - return p; -} - -static int -validate_error_elements( - neon_xml_elmid parent, - neon_xml_elmid child) -{ - switch (parent) - { - case ELEM_root: - if (child == ELEM_error) - return child; - else - return NEON_XML_INVALID; - - case ELEM_error: - if ((child == ELEM_error) || - (child == ELEM_human_readable)) - return child; - else - return NEON_XML_DECLINE; // ignore if something else - // was in there - default: - return NEON_XML_DECLINE; - } - - // NOTREACHED -} - -static error_t -generate_error( - neon_request_t * req, - apr_pool_t * pool) -{ - int errcode = WEBDAV_ERR_DAV_REQUEST_FAILED; - const char * context = - apr_psprintf(req->pool, "%s of '%s'", req->method, req->url); - const char * msg = NULL; - const char * hostport = NULL; - - // Convert the return codes. - switch (req->rv) - { - case NE_OK: - switch (req->code) - { - case 404: - return error_create(WEBDAV_ERR_FS_NOT_FOUND, NULL, - apr_psprintf(pool, "'%s' path not found", req->url)); - case 403: - return error_create(WEBDAV_ERR_DAV_FORBIDDEN, NULL, - apr_psprintf(pool, "Access to '%s' forbidden", - req->url)); - - case 301: - case 302: - case 307: - return error_create(WEBDAV_ERR_DAV_RELOCATED, NULL, - apr_psprintf(pool, (req->code == 301) ? - "WebDAV resource moved permanently to '%s';" - " please relocate" - : "WebDAV resource moved temporarily to '%s';" - " please relocate", - neon_request_get_location(req, pool))); - - default: - return error_create(errcode, NULL, - apr_psprintf(pool, - "Server sent unexpected return value (%d %s) " - "in response to %s request for '%s'", req->code, - req->code_desc, req->method, req->url)); - } - case NE_AUTH: - case NE_PROXYAUTH: - errcode = WEBDAV_ERR_NOT_AUTHORIZED; - // neon >= 0.27 gives a descriptive error message after auth - // failure; expose this since it's a useful diagnostic e.g. for - // an unsupported challenge scheme, or a local GSSAPI error due - // to an expired ticket. - WEBDAV_ERR(utf_cstring_to_utf8(&msg, ne_get_error(req->ne_sess), pool)); - msg = apr_psprintf(pool, "authorization failed: %s", msg); - break; - - case NE_CONNECT: - msg = "could not connect to server"; - break; - - case NE_TIMEOUT: - msg = "timed out waiting for server"; - break; - - default: - // Get the error string from neon and convert to UTF-8. - WEBDAV_ERR(utf_cstring_to_utf8(&msg, ne_get_error(req->ne_sess), pool)); - break; - } - - // The hostname may contain non-ASCII characters, so convert it to UTF-8. - WEBDAV_ERR(utf_cstring_to_utf8(&hostport, - ne_get_server_hostport(req->ne_sess), pool)); - - // This is a translation nightmare. Make sure to compose full strings - // and mark those for translation. - return error_createf(errcode, NULL, "%s: %s (%s://%s)", - context, msg, ne_get_scheme(req->ne_sess), - hostport); -} - -typedef struct error_parser_baton -{ - stringbuf_t * want_cdata; - stringbuf_t * cdata; - - error_t * dst_err; - error_t tmp_err; - bool * marshalled_error; -} error_parser_baton_t; - -static int -start_err_element( - void * baton, - int parent, - const char * nspace, - const char * name, - const char ** atts) -{ - const neon_xml_elm_t * elm = neon_lookup_xml_elem(error_elements, nspace, name); - int acc = elm ? validate_error_elements(parent, elm->id) : NEON_XML_DECLINE; - error_parser_baton_t * b = static_cast(baton); - error_t * err = &(b->tmp_err); - - if (acc < 1) // ! > 0 - return acc; - - switch (elm->id) - { - case ELEM_error: - { - // allocate the error_t. Hopefully the value will be - // overwritten by the tag, or even someday by - // a tag. - *err = error_create(APR_EGENERAL, NULL, - "General svn error from server"); - break; - } - case ELEM_human_readable: - { - // get the errorcode attribute if present - const char * errcode_str = - xml_get_attr_value("errcode", // make constant in - // some mod_dav header? - atts); - - if (errcode_str && *err) - { - apr_int64_t val; - error_t err2; - - err2 = cstring_atoi64(&val, errcode_str); - if (err2) - { - error_clear(&err2); - break; - } - } - - break; - } - - default: - break; - } - - switch (elm->id) - { - case ELEM_human_readable: - b->want_cdata = b->cdata; - stringbuf_setempty(b->want_cdata); - break; - - default: - b->want_cdata = NULL; - break; - } - - return elm->id; -} - -static int -end_err_element( - void * baton, - int state, - const char * nspace, - const char * name) -{ - error_parser_baton_t * b = static_cast(baton); - error_t * err = &(b->tmp_err); - - switch (state) - { - case ELEM_human_readable: - { - if (b->cdata->data && err) - { - // On the server dav_error_response_tag() will add a leading - // and trailing newline if DEBUG_CR is defined in mod_dav.h, - // so remove any such characters here. - apr_size_t len; - const char * cd = b->cdata->data; - if (*cd == '\n') - ++cd; - len = strlen(cd); - if (len > 0 && cd[len - 1] == '\n') - --len; - } - break; - } - - case ELEM_error: - { - if (b->dst_err) - error_clear(&b->tmp_err); - else if (b->tmp_err) - { - b->dst_err = &b->tmp_err; - if (b->marshalled_error) - *(b->marshalled_error) = TRUE; - } - b->tmp_err = NULL; - break; - } - - default: - break; - } - - return 0; -} - -static int -collect_error_cdata( - void * baton, - int state, - const char * cdata, - size_t len) -{ - stringbuf_t ** b = static_cast(baton); - - if (*b) - stringbuf_appendbytes(*b, cdata, len); - - return 0; -} - -static apr_status_t -error_parser_baton_cleanup( - void * baton) -{ - error_parser_baton_t * b = static_cast(baton); - - if (b->tmp_err) - error_clear(&b->tmp_err); - - return APR_SUCCESS; -} - -static ne_xml_parser * -error_parser_create( - neon_request_t * req) -{ - error_parser_baton_t * b = static_cast(apr_pcalloc(req->pool, sizeof(*b))); - ne_xml_parser * error_parser = NULL; - - b->dst_err = &(req->err); - b->marshalled_error = &(req->marshalled_error); - b->tmp_err = NULL; - - b->want_cdata = NULL; - b->cdata = stringbuf_create("", req->pool); - - // attach a standard body parser to the request - error_parser = xml_parser_create(req); - ne_xml_push_handler(error_parser, - start_err_element, - collect_error_cdata, - end_err_element, b); - - apr_pool_cleanup_register(req->pool, b, - error_parser_baton_cleanup, - apr_pool_cleanup_null); - - // Register the "error" accepter and body-reader with the request -- - // the one to use when HTTP status is *not* 2XX - attach_ne_body_reader(req, ra_neon_error_accepter, - ne_xml_parse_v, error_parser); - - return error_parser; -} - -static error_t -neon_maybe_store_auth_info( - neon_session_t * ras, - apr_pool_t * pool) -{ - // No auth_baton? Never mind. - if (!ras->callbacks->auth_baton) - return WEBDAV_NO_ERROR; - - // If we ever got credentials, ask the iter_baton to save them. - return auth_save_credentials(ras->auth_iterstate, pool); -} - -// A baton that is used along with a set of Neon ne_startelm_cb, -// ne_cdata_cb, and ne_endelm_cb callbacks to handle conversion -// from our style errors to Neon style errors. -// The underlying callbacks are called, and if errors -// are returned they are stored in this baton and a Neon level -// error code is returned to the parser. - -typedef struct parser_wrapper_baton_t -{ - neon_request_t * req; - ne_xml_parser * parser; - - void * baton; - neon_startelm_cb_t startelm_cb; - neon_cdata_cb_t cdata_cb; - neon_endelm_cb_t endelm_cb; -} parser_wrapper_baton_t; - -static int -wrapper_startelm_cb( - void * baton, - int parent, - const char * nspace, - const char * name, - const char ** atts) -{ - parser_wrapper_baton_t * pwb = static_cast(baton); - int elem = NEON_XML_DECLINE; - - if (pwb->startelm_cb) - { - NEON_REQ_ERR(pwb->req, pwb->startelm_cb(&elem, pwb->baton, parent, nspace, - name, atts)); - } - - if (elem == NEON_XML_INVALID) - { - NEON_REQ_ERR(pwb->req, error_create(WEBDAV_ERR_XML_MALFORMED, NULL, NULL)); - } - - if (pwb->req->err) - return NE_XML_ABORT; - - return elem; -} - -static int -wrapper_cdata_cb( - void * baton, - int state, - const char * cdata, - size_t len) -{ - parser_wrapper_baton_t * pwb = static_cast(baton); - - if (pwb->cdata_cb) - { - NEON_REQ_ERR(pwb->req, pwb->cdata_cb(pwb->baton, state, cdata, len)); - } - - if (pwb->req->err) - return NE_XML_ABORT; - - return 0; -} - -static int -wrapper_endelm_cb( - void * baton, - int state, - const char * nspace, - const char * name) -{ - parser_wrapper_baton_t * pwb = static_cast(baton); - - if (pwb->endelm_cb) - { - NEON_REQ_ERR(pwb->req, pwb->endelm_cb(pwb->baton, state, nspace, name)); - } - - if (pwb->req->err) - return NE_XML_ABORT; - - return 0; -} - -static error_t -neon_check_parse_error( - const char * method, - ne_xml_parser * xml_parser, - const char * url) -{ - const char * msg = ne_xml_get_error(xml_parser); - if (msg != NULL && *msg != '\0') - return error_createf(WEBDAV_ERR_DAV_REQUEST_FAILED, NULL, - "The %s request returned invalid XML " - "in the response: %s (%s)", - method, msg, url); - return WEBDAV_NO_ERROR; -} - -static int -wrapper_reader_cb( - void * baton, - const char * data, - size_t len) -{ - parser_wrapper_baton_t * pwb = static_cast(baton); - neon_session_t * sess = pwb->req->sess; - int parser_status = 0; - - if (pwb->req->err) - return 1; - - if (sess->callbacks->cancel_func) - { - NEON_REQ_ERR(pwb->req, (sess->callbacks->cancel_func)(sess->callback_baton)); - } - - if (pwb->req->err) - return 1; - if (len) - parser_status = ne_xml_parse(pwb->parser, data, len); - if (parser_status) - { - // Pass XML parser error. - NEON_REQ_ERR(pwb->req, neon_check_parse_error(pwb->req->method, - pwb->parser, - pwb->req->url)); - } - - return parser_status; -} - -// Create a Neon xml parser with callbacks STARTELM_CB, ENDELM_CB and -// CDATA_CB. The created parser wraps the Neon callbacks and marshals any -// errors returned by the callbacks through the Neon layer. Any errors -// raised will be returned by neon_request_dispatch() unless -// an earlier error occurred. - -// Register a pool cleanup on the pool of REQ to clean up any allocated -// Neon resources. - -// Return the new parser. Also attach it to REQ if ACCPT is non-null. -// ACCPT indicates whether the parser wants to read the response body -// or not. Pass NULL for ACCPT when you don't want the returned parser -// to be attached to REQ. - -static ne_xml_parser * -neon_xml_parser_create( - neon_request_t * req, - ne_accept_response accpt, - neon_startelm_cb_t startelm_cb, - neon_cdata_cb_t cdata_cb, - neon_endelm_cb_t endelm_cb, - void * baton) -{ - ne_xml_parser * p = xml_parser_create(req); - parser_wrapper_baton_t * pwb = static_cast(apr_pcalloc(req->pool, sizeof(*pwb))); - - pwb->req = req; - pwb->parser = p; - pwb->baton = baton; - pwb->startelm_cb = startelm_cb; - pwb->cdata_cb = cdata_cb; - pwb->endelm_cb = endelm_cb; - - ne_xml_push_handler(p, - wrapper_startelm_cb, - wrapper_cdata_cb, - wrapper_endelm_cb, pwb); - - if (accpt) - attach_ne_body_reader(req, accpt, wrapper_reader_cb, pwb); - - return p; -} - -static error_t -neon_request_dispatch( - int * code_p, - neon_request_t * req, - apr_hash_t * extra_headers, - const char * body, - int okay_1, - int okay_2, - bool check_errors, - apr_pool_t * pool) -{ - // add any extra headers passed in by caller. - if (extra_headers != NULL) - { - for (apr_hash_index_t * hi = apr_hash_first(pool, extra_headers); hi; - hi = apr_hash_next(hi)) - { - const void * key; - void * val; - apr_hash_this(hi, &key, NULL, &val); - ne_add_request_header(req->ne_req, - static_cast(key), static_cast(val)); - } - } - - if (body) - ne_set_request_body_buffer(req->ne_req, body, strlen(body)); - - // attach a standard body parser to the request - ne_xml_parser * error_parser = error_parser_create(req); - - if (check_errors) - multistatus_parser_create(req); - // run the request, see what comes back. - req->rv = ne_request_dispatch(req->ne_req); - - // Save values from the request - const ne_status * statstruct = ne_get_status(req->ne_req); - req->code_desc = apr_pstrdup(pool, statstruct->reason_phrase); - req->code = statstruct->code; - - // If we see a successful request that used authentication, we should store - // the credentials for future use. - if ((req->sess->auth_used) && (statstruct->code < 400)) - { - req->sess->auth_used = FALSE; - WEBDAV_ERR(neon_maybe_store_auth_info(req->sess, pool)); - } - - if (code_p) - *code_p = req->code; - - if (!req->marshalled_error && req->err) - WEBDAV_ERR(req->err); - - // If the status code was one of the two that we expected, then go - // ahead and return now. IGNORE any marshalled error. - if ((req->rv == NE_OK) && (req->code == okay_1 || req->code == okay_2)) - return WEBDAV_NO_ERROR; - - // Any other errors? Report them - if (req->err) - WEBDAV_ERR(req->err); - - WEBDAV_ERR(neon_check_parse_error(req->method, error_parser, req->url)); - - // We either have a neon error, or some other error - // that we didn't expect. - return generate_error(req, pool); -} - -static const char * -neon_request_get_location( - neon_request_t * request, - apr_pool_t * pool) -{ - const char * val = ne_get_response_header(request->ne_req, "Location"); - return val ? urlpath_canonicalize(val, pool) : NULL; -} - -static error_t -neon_request_create( - neon_request_t ** request, - neon_session_t * sess, - const char * method, const char * url, - apr_pool_t * pool) -{ - apr_pool_t * reqpool = webdav_pool_create(pool); - neon_request_t * req = NULL; - const char * path = NULL; - - // We never want to send Neon an absolute URL, since that can cause - // problems with some servers (for example, those that may be accessed - // using different server names from different locations, or those that - // want to rewrite the incoming URL). If the URL passed in is absolute, - // convert it to a path-absolute relative URL. - path = path_from_url(url); - - req = static_cast(apr_pcalloc(reqpool, sizeof(*req))); - req->ne_sess = sess->ne_sess; - req->ne_req = ne_request_create(req->ne_sess, method, path); - req->sess = sess; - req->pool = reqpool; - req->iterpool = webdav_pool_create(req->pool); - req->method = apr_pstrdup(req->pool, method); - req->url = apr_pstrdup(req->pool, url); - req->rv = -1; - - // Neon resources may be NULL on out-of-memory - assert(req->ne_req != NULL); - apr_pool_cleanup_register(sess->pool, req, - dav_request_sess_cleanup, - apr_pool_cleanup_null); - apr_pool_cleanup_register(reqpool, req, - dav_request_cleanup, - apr_pool_cleanup_null); - *request = req; - return WEBDAV_NO_ERROR; -} - -static error_t -get_path_relative_to_session( - session_t * session, - const char ** rel_path, - const char * url, - apr_pool_t * pool) -{ - const char * sess_url = NULL; - WEBDAV_ERR(session->vtable->get_session_url(session, &sess_url, pool)); - if (strcmp(sess_url, url) == 0) - { - *rel_path = ""; - } - else - { - *rel_path = uri_is_child(sess_url, url, pool); - if (!*rel_path) - { - return error_createf(WEBDAV_ERR_ILLEGAL_URL, NULL, - "'%s' isn't a child of session URL '%s'", url, sess_url); - } - } - return WEBDAV_NO_ERROR; -} - -static error_t -client_path_relative_to_root( - const char ** rel_path, - const char * abspath_or_url, - const char * webdav_root, - bool include_leading_slash, - session_t * ra_session, - apr_pool_t * result_pool, - apr_pool_t * scratch_pool) -{ - const char * webdav_relpath = NULL; - - if (!path_is_url(abspath_or_url)) - { - error_createf(WEBDAV_ERR_DAV_NOT_IMPLEMENTED, NULL, - "not implemented: 'client_path_relative_to_root'"); - } - // Merge handling passes a root that is not WebDAV resource root - else if (webdav_root != NULL) - { - /*if (!uri_is_ancestor(webdav_root, abspath_or_url)) - return error_createf(WEBDAV_ERR_CLIENT_UNRELATED_RESOURCES, NULL, - "URL '%s' is not a child of " - "root URL '%s'", - abspath_or_url, webdav_root);*/ - - webdav_relpath = uri_skip_ancestor(webdav_root, abspath_or_url, - result_pool); - } - else - { - error_t err = 0; - - WEBDAV_ERR_ASSERT(ra_session != NULL); - - // Ask the RA layer to create a relative path for us - err = get_path_relative_to_root(ra_session, &webdav_relpath, - abspath_or_url, scratch_pool); - - if (err) - { - if (err == WEBDAV_ERR_ILLEGAL_URL) - { - return error_createf(WEBDAV_ERR_CLIENT_UNRELATED_RESOURCES, &err, - "URL '%s' is not inside WebDAV resource root", abspath_or_url); - } - - return error_trace(err); - } - } - - if (include_leading_slash) - *rel_path = apr_pstrcat(result_pool, "/", webdav_relpath, NULL); - else - *rel_path = webdav_relpath; - - return WEBDAV_NO_ERROR; -} - -static const char * -neon_uri_unparse( - const ne_uri * uri, - apr_pool_t * pool) -{ - char * unparsed_uri = NULL; - const char * result = NULL; - - // Unparse uri. - unparsed_uri = ne_uri_unparse(uri); - - result = uri_canonicalize(unparsed_uri, pool); - - // Free neon's allocated copy. - ne_free(unparsed_uri); - - // Return string allocated in result pool. - return result; -} - -typedef struct body_reader_wrapper_baton_t -{ - neon_request_t * req; - neon_block_reader real_reader; - void * real_baton; -} body_reader_wrapper_baton_t; - -static int -body_reader_wrapper( - void * userdata, - const char * data, - size_t len) -{ - body_reader_wrapper_baton_t * b = static_cast(userdata); - - if (b->req->err) - // We already had an error? Bail out. - return 1; - - NEON_REQ_ERR(b->req, b->real_reader(b->real_baton, data, len)); - - if (b->req->err) - return 1; - - return 0; -} - -static void -neon_add_response_body_reader( - neon_request_t * req, - ne_accept_response accpt, - neon_block_reader reader, - void * userdata) -{ - body_reader_wrapper_baton_t * b = static_cast(apr_pcalloc(req->pool, sizeof(*b))); - - b->req = req; - b->real_baton = userdata; - b->real_reader = reader; - - attach_ne_body_reader(req, accpt, body_reader_wrapper, b); -} - -//------------------------------------------------------------------------------ -// from fetch.c - -typedef struct file_read_ctx_t -{ - apr_pool_t * pool; - - // these two are the handler that the editor gave us - void * handler_baton; - - // if we're receiving an svndiff, this is a parser which places the - // resulting windows into the above handler/baton. - stream_t * stream; - -} file_read_ctx_t; - -typedef struct file_write_ctx_t -{ - stream_t * stream; // stream to write file contents to -} file_write_ctx_t; - -typedef struct custom_get_ctx_t -{ - neon_request_t * req; // Used to propagate errors out of the reader - int checked_type; // have we processed ctype yet? - - void * subctx; - void * callback_baton; -} custom_get_ctx_t; - -// Helper for neon_get_file. This implements -// the neon_block_reader() callback interface. -static error_t -get_file_reader( - void * userdata, - const char * buf, - size_t len) -{ - custom_get_ctx_t * cgc = static_cast(userdata); - - if (cgc->req->sess->callbacks && - cgc->req->sess->callbacks->cancel_func) - { - NEON_REQ_ERR(cgc->req, (cgc->req->sess->callbacks->cancel_func)( - cgc->req->sess->callback_baton)); - } - - assert(cgc->callback_baton); - callback_baton_t * cb = static_cast(cgc->callback_baton); - - TWebDAVFileSystem * fs = static_cast(apr_hash_get(cb->ctx->auth_baton->parameters, - CONST_FS_KEY, - APR_HASH_KEY_STRING)); - assert(fs); - fs->AdjustToCPSLimit(len); - - // The stream we want to push data at. - file_write_ctx_t * fwc = static_cast(cgc->subctx); - stream_t * stream = fwc->stream; - - // Write however many bytes were passed in by neon. - WEBDAV_ERR(stream_write(stream, buf, &len)); - return WEBDAV_NO_ERROR; -} - -static error_t -custom_get_request( - neon_session_t * ras, - const char * url, - const char * editor_relpath, - neon_block_reader reader, - void * subctx, - void * cb_baton, - apr_pool_t * pool) -{ - custom_get_ctx_t cgc = { 0 }; - neon_request_t * request = NULL; - error_t err = 0; - - WEBDAV_ERR(neon_request_create(&request, ras, "GET", url, pool)); - - neon_add_response_body_reader(request, ne_accept_2xx, reader, &cgc); - - // complete initialization of the body reading context - cgc.req = request; - cgc.subctx = subctx; - cgc.callback_baton = cb_baton; - - // run the request - err = neon_request_dispatch(NULL, request, NULL, NULL, - 200 /* OK */, - 226 /* IM Used */, - false, - pool); - neon_request_destroy(request); - - // The request runner raises internal errors before Neon errors, - // pass a returned error to our callers - - return err; -} - -//------------------------------------------------------------------------------ - -static error_t -get_file( - session_t * session, - const char * path, - stream_t * stream, - apr_hash_t ** props, - apr_pool_t * pool) -{ - WEBDAV_ERR_ASSERT(*path != '/'); - return session->vtable->get_file(session, path, - stream, - props, pool); -} - -static error_t -get_dir2( - session_t * session, - apr_hash_t ** dirents, - const char * path, - apr_uint32_t dirent_fields, - apr_pool_t * pool) -{ - WEBDAV_ERR_ASSERT(*path != '/'); - return session->vtable->get_dir(session, dirents, - path, - dirent_fields, pool); -} - -static error_t -get_webdav_resource_root2( - session_t * session, - const char ** url, - apr_pool_t * pool) -{ - WEBDAV_ERR(session->vtable->get_webdav_resource_root(session, url, pool)); - *url = *url ? apr_pstrdup(pool, *url) : NULL; - return WEBDAV_NO_ERROR; -} - -static error_t -stat( - session_t * session, - const char * path, - dirent_t ** dirent, - apr_pool_t * pool) -{ - WEBDAV_ERR_ASSERT(*path != '/'); - return session->vtable->stat(session, path, - dirent, pool); -} - -static error_t -get_path_relative_to_root( - session_t * session, - const char ** rel_path, - const char * url, - apr_pool_t * pool) -{ - const char * root_url = NULL; - WEBDAV_ERR(session->vtable->get_webdav_resource_root(session, &root_url, pool)); - if (strcmp(root_url, url) == 0) - { - *rel_path = ""; - } - else - { - *rel_path = uri_is_child(root_url, url, pool); - if (!*rel_path) - { - return error_createf(WEBDAV_ERR_ILLEGAL_URL, NULL, - "'%s' isn't a child of root URL '%s'", url, root_url); - } - } - - return WEBDAV_NO_ERROR; -} - -static error_t -check_path( - session_t * session, - const char * path, - node_kind_t * kind, - apr_pool_t * pool) -{ - WEBDAV_ERR_ASSERT(*path != '/'); - return session->vtable->check_path(session, path, - kind, pool); -} - -static error_t -reparent( - session_t * session, - const char * url, - apr_pool_t * pool) -{ - return session->vtable->reparent(session, url, pool); -} - -static error_t -session_open( - session_t ** session_p, - const char ** corrected_url_p, - const char * session_URL, - const callbacks2_t * callbacks, - void * callback_baton, - apr_pool_t * pool) -{ - assert(callback_baton); - // check options, url, prepare parameters, callbacks, auth etc - apr_pool_t * sesspool = webdav_pool_create(pool); - - // Initialize the return variable. - *session_p = NULL; - - ne_uri * webdav_URI = NULL; - error_t err = parse_ne_uri(&webdav_URI, session_URL, sesspool); - if ((err != WEBDAV_NO_ERROR) || (webdav_URI->host == NULL)) - { - return error_createf(WEBDAV_ERR_ILLEGAL_URL, NULL, - "Illegal URL '%s'", session_URL); - } - - // Auth caching parameters. - bool store_passwords = WEBDAV_CONFIG_DEFAULT_OPTION_STORE_PASSWORDS; - bool store_auth_creds = WEBDAV_CONFIG_DEFAULT_OPTION_STORE_AUTH_CREDS; - const char * store_plaintext_passwords = WEBDAV_CONFIG_DEFAULT_OPTION_STORE_PLAINTEXT_PASSWORDS; - bool store_pp = WEBDAV_CONFIG_DEFAULT_OPTION_STORE_SSL_CLIENT_CERT_PP; - const char * store_pp_plaintext = WEBDAV_CONFIG_DEFAULT_OPTION_STORE_SSL_CLIENT_CERT_PP_PLAINTEXT; - - if (callbacks->auth_baton) - { - if (auth_baton_get_parameter(callbacks->auth_baton, - WEBDAV_AUTH_PARAM_DONT_STORE_PASSWORDS) != NULL) - { - store_passwords = FALSE; - } - - if (auth_baton_get_parameter(callbacks->auth_baton, - WEBDAV_AUTH_PARAM_NO_AUTH_CACHE) != NULL) - { - store_auth_creds = FALSE; - } - } - if (callbacks->auth_baton) - { - // Save auth caching parameters in the auth parameter hash. - if (!store_passwords) - auth_baton_set_parameter(callbacks->auth_baton, - WEBDAV_AUTH_PARAM_DONT_STORE_PASSWORDS, ""); - - auth_baton_set_parameter(callbacks->auth_baton, - WEBDAV_AUTH_PARAM_STORE_PLAINTEXT_PASSWORDS, - store_plaintext_passwords); - - if (!store_pp) - auth_baton_set_parameter(callbacks->auth_baton, - WEBDAV_AUTH_PARAM_DONT_STORE_SSL_CLIENT_CERT_PP, - ""); - - auth_baton_set_parameter(callbacks->auth_baton, - WEBDAV_AUTH_PARAM_STORE_SSL_CLIENT_CERT_PP_PLAINTEXT, - store_pp_plaintext); - - if (!store_auth_creds) - auth_baton_set_parameter(callbacks->auth_baton, - WEBDAV_AUTH_PARAM_NO_AUTH_CACHE, ""); - } - - const vtable_t * vtable = NULL; - WEBDAV_ERR(neon_init(&vtable, sesspool)); - - // Create the session object. - session_t * session = static_cast(apr_pcalloc(sesspool, sizeof(*session))); - - session->vtable = vtable; - session->pool = sesspool; - - const char * corrected_url = NULL; - // Ask the library to open the session. - WEBDAV_ERR_W(vtable->open_session( - session, - &corrected_url, - session_URL, - callbacks, callback_baton, sesspool), - apr_psprintf(pool, "Unable to connect to a WebDAV resource at URL '%s'", - session_URL)); - - if (corrected_url_p && corrected_url) - { - if (!path_is_url(corrected_url)) - { - ne_uri * corrected_URI = NULL; - WEBDAV_ERR(parse_ne_uri(&corrected_URI, session_URL, sesspool)); - if (corrected_URI->path) ne_free(corrected_URI->path); - corrected_URI->path = ne_strdup(corrected_url); - corrected_url = neon_uri_unparse(corrected_URI, pool); - } - *corrected_url_p = uri_canonicalize(corrected_url, pool); - webdav_pool_destroy(sesspool); - return WEBDAV_NO_ERROR; - } - *session_p = session; - return WEBDAV_NO_ERROR; -} - -//--------------------------------------------------------------------------- - -// This implements the client_list_func_t API -static error_t -list_func( - void * baton, - const char * path, - const dirent_t * dirent, - const char * abs_path, - apr_pool_t * pool) -{ - list_func_baton_t * pb = static_cast(baton); - assert(pb); - assert(pb->entries); - const char * entryname = NULL; - - neon_session_t * ras = static_cast(pb->session->priv); - assert(ras); - if (ras->callbacks->cancel_func) - WEBDAV_ERR(ras->callbacks->cancel_func(ras->callback_baton)); - - if (strcmp(path, "") == 0) - { - if (dirent->kind == node_file) - entryname = dirent_basename(abs_path, pool); - else if (pb->verbose) - entryname = "."; - else - // Don't bother to list if no useful information will be shown. - return WEBDAV_NO_ERROR; - } - else - entryname = path; - - if (pb->verbose) - { - apr_time_t now = apr_time_now(); - apr_time_exp_t exp_time; - apr_status_t apr_err; - apr_size_t size; - char timestr[20]; - const char * utf8_timestr; - - // time_to_human_cstring gives us something *way* too long - // to use for this, so we have to roll our own. We include - // the year if the entry's time is not within half a year. - apr_time_exp_lt(&exp_time, dirent->time); - if (apr_time_sec(now - dirent->time) < (365 * 86400 / 2) && - apr_time_sec(dirent->time - now) < (365 * 86400 / 2)) - { - apr_err = apr_strftime(timestr, &size, sizeof(timestr), - "%b %d %H:%M", &exp_time); - } - else - { - apr_err = apr_strftime(timestr, &size, sizeof(timestr), - "%b %d %Y", &exp_time); - } - - // if that failed, just zero out the string and print nothing - if (apr_err) - timestr[0] = '\0'; - - // we need it in UTF-8. - WEBDAV_ERR(utf_cstring_to_utf8(&utf8_timestr, timestr, pool)); - - TListDataEntry entry = {NULL, NULL, NULL, 0, false, false, {0}, NULL}; - if (APR_SUCCESS != utf8_to_unicode(const_cast(&entry.Name), entryname, pb->pool)) - { - return error_create(WEBDAV_ERR_DAV_MALFORMED_DATA, NULL, NULL); - } - entry.Permissions = L""; - entry.OwnerGroup = L""; - int dir = dirent->kind == node_dir; - entry.Size = dir == 0 ? dirent->size : 0; - entry.Dir = dir != 0; - entry.Link = false; - entry.Time.Year = exp_time.tm_year + 1900; - entry.Time.Month = exp_time.tm_mon + 1; - entry.Time.Day = exp_time.tm_mday; - entry.Time.Hour = exp_time.tm_hour; - entry.Time.Minute = exp_time.tm_min; - entry.Time.Second = exp_time.tm_sec; - entry.Time.HasTime = true; - entry.Time.HasSeconds = true; - entry.Time.HasDate = true; - entry.LinkTarget = L""; - pb->entries->push_back(entry); - } - return WEBDAV_NO_ERROR; -} - -//--------------------------------------------------------------------------- -// from url.c - -static error_t -client_url_from_path2( - const char ** url, - const char * path_or_url, - stringbuf_t * session_url, - apr_pool_t * result_pool, - apr_pool_t * scratch_pool) -{ - if (!path_is_url(path_or_url)) - { - ne_uri * uri = NULL; - WEBDAV_ERR(parse_ne_uri(&uri, session_url->data, result_pool)); - if (uri->path) ne_free(uri->path); - uri->path = ne_strdup(path_or_url); - const char * corrected_url = neon_uri_unparse(uri, result_pool); - *url = uri_canonicalize(corrected_url, result_pool); - } - else - *url = uri_canonicalize(path_or_url, result_pool); - - return WEBDAV_NO_ERROR; -} - -//--------------------------------------------------------------------------- -// from ctx.c - -static error_t -client_create_context( - client_ctx_t ** ctx, - apr_pool_t * pool) -{ - *ctx = static_cast(apr_pcalloc(pool, sizeof(client_ctx_t))); - return WEBDAV_NO_ERROR; -} - -//------------------------------------------------------------------------------ -// from auth.c - -static void -auth_baton_create( - auth_baton_t ** auth_baton, - apr_pool_t * pool) -{ - auth_baton_t * ab = NULL; - - // Build the auth_baton. - ab = static_cast(apr_pcalloc(pool, sizeof(*ab))); - ab->tables = apr_hash_make(pool); - ab->parameters = apr_hash_make(pool); - ab->creds_cache = apr_hash_make(pool); - ab->pool = pool; - - *auth_baton = ab; -} - -static void -create_baton_open( - auth_baton_t * auth_baton, - const apr_array_header_t * providers, - apr_pool_t * pool) -{ - auth_provider_object_t * provider = NULL; - - // Register each provider in order. Providers of different - // credentials will be automatically sorted into different tables by - // register_provider(). - if (providers) - { - for (int i = 0; i < providers->nelts; i++) - { - provider_set_t * table = NULL; - provider = APR_ARRAY_IDX(providers, i, auth_provider_object_t *); - - // Add it to the appropriate table in the auth_baton - table = static_cast(apr_hash_get(auth_baton->tables, - provider->vtable->cred_kind, APR_HASH_KEY_STRING)); - if (!table) - { - table = static_cast(apr_pcalloc(pool, sizeof(*table))); - table->providers = apr_array_make(pool, 1, sizeof(auth_provider_object_t *)); - - apr_hash_set(auth_baton->tables, - provider->vtable->cred_kind, APR_HASH_KEY_STRING, - table); - } - APR_ARRAY_PUSH(table->providers, auth_provider_object_t *) = provider; - } - } -} - -//--------------------------------------------------------------------------- -// from ssl_client_cert_providers.c - -// A function returning an SSL client certificate passphrase provider. -typedef void (*auth_ssl_client_cert_pw_provider_func_t)( - auth_provider_object_t ** provider, - apr_pool_t * pool); - -// retrieve and load the ssl client certificate file from servers config -static error_t -ssl_client_cert_file_first_credentials( - void ** credentials_p, - void ** iter_baton, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool) -{ - const char * cert_file; - - cert_file = NULL; - - if (cert_file != NULL) - { - auth_cred_ssl_client_cert_t * cred = - static_cast(apr_pcalloc(pool, sizeof(*cred))); - - cred->cert_file = cert_file; - cred->may_save = FALSE; - *credentials_p = cred; - } - else - { - *credentials_p = NULL; - } - - *iter_baton = NULL; - return WEBDAV_NO_ERROR; -} - -static const auth_provider_t ssl_client_cert_file_provider = -{ - AUTH_CRED_SSL_CLIENT_CERT, - ssl_client_cert_file_first_credentials, - NULL, - NULL -}; - -// Public API to SSL file providers. -static void -auth_get_ssl_client_cert_file_provider( - auth_provider_object_t ** provider, - apr_pool_t * pool) -{ - auth_provider_object_t * po = - static_cast(apr_pcalloc(pool, sizeof(*po))); - po->vtable = &ssl_client_cert_file_provider; - *provider = po; -} - -/*-----------------------------------------------------------------------*/ -// Prompt provider -/*-----------------------------------------------------------------------*/ - -// Baton type for prompting to send client ssl creds. -// There is no iteration baton type. -typedef struct ssl_client_cert_prompt_provider_baton_t -{ - auth_ssl_client_cert_prompt_func_t prompt_func; - void * prompt_baton; - - // how many times to re-prompt after the first one fails - int retry_limit; -} ssl_client_cert_prompt_provider_baton_t; - -// Iteration baton. -typedef struct ssl_client_cert_prompt_iter_baton_t -{ - // The original provider baton - ssl_client_cert_prompt_provider_baton_t * pb; - - // The original realmstring - const char * realmstring; - - // how many times we've reprompted - int retries; -} ssl_client_cert_prompt_iter_baton_t; - -static error_t -ssl_client_cert_prompt_first_cred( - void ** credentials_p, - void ** iter_baton, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool) -{ - ssl_client_cert_prompt_provider_baton_t * pb = - static_cast(provider_baton); - ssl_client_cert_prompt_iter_baton_t * ib = - static_cast(apr_pcalloc(pool, sizeof(*ib))); - const char * no_auth_cache = static_cast(apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_NO_AUTH_CACHE, - APR_HASH_KEY_STRING)); - - WEBDAV_ERR(pb->prompt_func((auth_cred_ssl_client_cert_t **) credentials_p, - pb->prompt_baton, realmstring, !no_auth_cache, - pool)); - - ib->pb = pb; - ib->realmstring = apr_pstrdup(pool, realmstring); - ib->retries = 0; - *iter_baton = ib; - - return WEBDAV_NO_ERROR; -} - -static error_t -ssl_client_cert_prompt_next_cred( - void ** credentials_p, - void * iter_baton, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool) -{ - ssl_client_cert_prompt_iter_baton_t * ib = - static_cast(iter_baton); - const char * no_auth_cache = static_cast(apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_NO_AUTH_CACHE, - APR_HASH_KEY_STRING)); - - if ((ib->pb->retry_limit >= 0) && (ib->retries >= ib->pb->retry_limit)) - { - // give up, go on to next provider. - *credentials_p = NULL; - return WEBDAV_NO_ERROR; - } - ib->retries++; - - return ib->pb->prompt_func((auth_cred_ssl_client_cert_t **) - credentials_p, ib->pb->prompt_baton, - ib->realmstring, !no_auth_cache, pool); -} - -static const auth_provider_t ssl_client_cert_prompt_provider = -{ - AUTH_CRED_SSL_CLIENT_CERT, - ssl_client_cert_prompt_first_cred, - ssl_client_cert_prompt_next_cred, - NULL -}; - -// Public API to SSL prompting providers. -static void -auth_get_ssl_client_cert_prompt_provider( - auth_provider_object_t ** provider, - auth_ssl_client_cert_prompt_func_t prompt_func, - void * prompt_baton, - int retry_limit, - apr_pool_t * pool) -{ - auth_provider_object_t * po = - static_cast(apr_pcalloc(pool, sizeof(*po))); - ssl_client_cert_prompt_provider_baton_t * pb = - static_cast(apr_pcalloc(pool, sizeof(*pb))); - - pb->prompt_func = prompt_func; - pb->prompt_baton = prompt_baton; - pb->retry_limit = retry_limit; - - po->vtable = &ssl_client_cert_prompt_provider; - po->provider_baton = pb; - *provider = po; -} - -//--------------------------------------------------------------------------- -// from ssl_server_trust_providers.c - -// retrieve ssl server CA failure overrides (if any) from servers config -static error_t -ssl_server_trust_file_first_credentials( - void ** credentials, - void ** iter_baton, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool) -{ - apr_uint32_t * failures = static_cast(apr_hash_get(parameters, - AUTH_PARAM_SSL_SERVER_FAILURES, - APR_HASH_KEY_STRING)); - const auth_ssl_server_cert_info_t * cert_info = - static_cast(apr_hash_get(parameters, - AUTH_PARAM_SSL_SERVER_CERT_INFO, - APR_HASH_KEY_STRING)); - TWebDAVFileSystem * fs = static_cast(apr_hash_get(parameters, - CONST_FS_KEY, - APR_HASH_KEY_STRING)); - assert(fs); - apr_hash_t * creds_hash = NULL; - error_t error = WEBDAV_NO_ERROR; - - *credentials = NULL; - *iter_baton = NULL; - - // Check if this is a permanently accepted certificate - error = config_read_auth_data(&creds_hash, AUTH_CRED_SSL_SERVER_TRUST, - realmstring, fs, pool); - error_clear(&error); - if (!error && creds_hash) - { - string_t * trusted_cert, *this_cert, *failstr; - apr_uint32_t last_failures = 0; - - trusted_cert = static_cast(apr_hash_get(creds_hash, AUTHN_ASCII_CERT_KEY, - APR_HASH_KEY_STRING)); - this_cert = string_create(cert_info->fingerprint, pool); - failstr = static_cast(apr_hash_get(creds_hash, AUTHN_FAILURES_KEY, - APR_HASH_KEY_STRING)); - - if (failstr) - { - char * endptr; - unsigned long tmp_ulong = strtoul(failstr->data, &endptr, 10); - - if (*endptr == '\0') - last_failures = (apr_uint32_t) tmp_ulong; - } - - // If the cert is trusted and there are no new failures, we - // accept it by clearing all failures. - if (trusted_cert && - string_compare(this_cert, trusted_cert) && - (*failures & ~last_failures) == 0) - { - *failures = 0; - } - } - - // If all failures are cleared now, we return the creds - if (!*failures) - { - auth_cred_ssl_server_trust_t * creds = - static_cast(apr_pcalloc(pool, sizeof(*creds))); - creds->may_save = FALSE; // No need to save it again... - *credentials = creds; - } - - return WEBDAV_NO_ERROR; -} - -static error_t -ssl_server_trust_file_save_credentials( - bool * saved, - void * credentials, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool) -{ - auth_cred_ssl_server_trust_t * creds = - static_cast(credentials); - const auth_ssl_server_cert_info_t * cert_info; - apr_hash_t * creds_hash = NULL; - - if (!creds->may_save) - return WEBDAV_NO_ERROR; - - cert_info = static_cast(apr_hash_get(parameters, - AUTH_PARAM_SSL_SERVER_CERT_INFO, - APR_HASH_KEY_STRING)); - TWebDAVFileSystem * fs = static_cast(apr_hash_get(parameters, - CONST_FS_KEY, - APR_HASH_KEY_STRING)); - assert(fs); - - creds_hash = apr_hash_make(pool); - apr_hash_set(creds_hash, AUTHN_ASCII_CERT_KEY, APR_HASH_KEY_STRING, - string_create(cert_info->fingerprint, pool)); - apr_hash_set(creds_hash, AUTHN_FAILURES_KEY, APR_HASH_KEY_STRING, - string_createf(pool, "%lu", (unsigned long) - creds->accepted_failures)); - - WEBDAV_ERR(config_write_auth_data(creds_hash, - AUTH_CRED_SSL_SERVER_TRUST, - realmstring, - fs, - pool)); - *saved = TRUE; - return WEBDAV_NO_ERROR; -} - -static const auth_provider_t ssl_server_trust_file_provider = -{ - AUTH_CRED_SSL_SERVER_TRUST, - &ssl_server_trust_file_first_credentials, - NULL, - &ssl_server_trust_file_save_credentials, -}; - -// Public API to SSL file providers. -static void -auth_get_ssl_server_trust_file_provider( - auth_provider_object_t ** provider, - apr_pool_t * pool) -{ - auth_provider_object_t * po = - static_cast(apr_pcalloc(pool, sizeof(*po))); - - po->vtable = &ssl_server_trust_file_provider; - *provider = po; -} - -/*-----------------------------------------------------------------------*/ -// Prompt provider -/*-----------------------------------------------------------------------*/ - -// Baton type for prompting to verify server ssl creds. -// There is no iteration baton type. -typedef struct ssl_server_trust_prompt_provider_baton_t -{ - auth_ssl_server_trust_prompt_func_t prompt_func; - void * prompt_baton; -} ssl_server_trust_prompt_provider_baton_t; - -static error_t -ssl_server_trust_prompt_first_cred( - void ** credentials_p, - void ** iter_baton, - void * provider_baton, - apr_hash_t * parameters, - const char * realmstring, - apr_pool_t * pool) -{ - ssl_server_trust_prompt_provider_baton_t * pb = - static_cast(provider_baton); - apr_uint32_t * failures = static_cast(apr_hash_get(parameters, - AUTH_PARAM_SSL_SERVER_FAILURES, - APR_HASH_KEY_STRING)); - const char * no_auth_cache = static_cast(apr_hash_get(parameters, - WEBDAV_AUTH_PARAM_NO_AUTH_CACHE, - APR_HASH_KEY_STRING)); - const auth_ssl_server_cert_info_t * cert_info = - static_cast(apr_hash_get(parameters, - AUTH_PARAM_SSL_SERVER_CERT_INFO, - APR_HASH_KEY_STRING)); - - WEBDAV_ERR(pb->prompt_func((auth_cred_ssl_server_trust_t **) - credentials_p, pb->prompt_baton, realmstring, - *failures, cert_info, !no_auth_cache && - !(*failures & WEBDAV_AUTH_SSL_OTHER), pool)); - - *iter_baton = NULL; - return WEBDAV_NO_ERROR; -} - -static const auth_provider_t ssl_server_trust_prompt_provider = -{ - AUTH_CRED_SSL_SERVER_TRUST, - ssl_server_trust_prompt_first_cred, - NULL, - NULL -}; - -// Public API to SSL prompting providers. -static void -auth_get_ssl_server_trust_prompt_provider( - auth_provider_object_t ** provider, - auth_ssl_server_trust_prompt_func_t prompt_func, - void * prompt_baton, - apr_pool_t * pool) -{ - auth_provider_object_t * po = - static_cast(apr_pcalloc(pool, sizeof(*po))); - ssl_server_trust_prompt_provider_baton_t * pb = - static_cast(apr_pcalloc(pool, sizeof(*pb))); - pb->prompt_func = prompt_func; - pb->prompt_baton = prompt_baton; - po->vtable = &ssl_server_trust_prompt_provider; - po->provider_baton = pb; - *provider = po; -} - -//--------------------------------------------------------------------------- -// from cmdline.h - -typedef struct cmdline_prompt_baton2_t -{ - cancel_func_t cancel_func; - void * cancel_baton; -} cmdline_prompt_baton2_t; - -//--------------------------------------------------------------------------- -// from prompt.c - -// This is a helper for plaintext prompt functions. -static error_t -plaintext_prompt_helper( - bool * may_save_plaintext, - const char * realmstring, - const char * prompt_string, - const char * prompt_text, - void * baton, - apr_pool_t * pool) -{ - cmdline_prompt_baton2_t * pb = static_cast(baton); - - auth_baton_t * ab = static_cast(pb->cancel_baton); - assert(ab); - TWebDAVFileSystem * fs = static_cast(apr_hash_get(ab->parameters, - CONST_FS_KEY, - APR_HASH_KEY_STRING)); - assert(fs); - - unsigned int RequestResult = 0; - error_t err = fs->SimplePrompt(prompt_text, prompt_string, RequestResult); - if (err) - { - if (err == WEBDAV_ERR_CANCELLED) - { - error_clear(&err); - *may_save_plaintext = FALSE; - return WEBDAV_NO_ERROR; - } - else - return err; - } - if (RequestResult == qaYes) - { - *may_save_plaintext = TRUE; - } - else if (RequestResult == qaNo) - { - *may_save_plaintext = FALSE; - } - - return WEBDAV_NO_ERROR; -} - -// This implements 'auth_plaintext_prompt_func_t'. -static error_t -cmdline_auth_plaintext_prompt( - bool * may_save_plaintext, - const char * realmstring, - void * baton, - apr_pool_t * pool) -{ - const char * prompt_string = "Store password unencrypted (yes/no)? "; - const char * prompt_text = - "\n-----------------------------------------------------------------------" - "\nATTENTION! Your password for authentication realm:\n" - "\n" - " %s\n" - "\n" - "can only be stored to disk unencrypted! You are advised to configure\n" - "your system so that system can store passwords encrypted, if\n" - "possible. See the documentation for details.\n" - "\n" - "You can avoid future appearances of this warning by setting the value\n" - "of the 'store-plaintext-passwords' option to either 'yes' or 'no' in\n" - "'%s'.\n" - "-----------------------------------------------------------------------\n" - ; - return plaintext_prompt_helper(may_save_plaintext, realmstring, - prompt_string, prompt_text, baton, - pool); -} - -// This implements 'auth_plaintext_passphrase_prompt_func_t'. -static error_t -cmdline_auth_plaintext_passphrase_prompt( - bool * may_save_plaintext, - const char * realmstring, - void * baton, - apr_pool_t * pool) -{ - const char * prompt_string = "Store passphrase unencrypted (yes/no)? "; - const char * prompt_text = - "\n-----------------------------------------------------------------------\n" - "ATTENTION! Your passphrase for client certificate:\n" - "\n" - " %s\n" - "\n" - "can only be stored to disk unencrypted! You are advised to configure\n" - "your system so that system can store passphrase encrypted, if\n" - "possible. See the documentation for details.\n" - "\n" - "You can avoid future appearances of this warning by setting the value\n" - "of the 'store-ssl-client-cert-pp-plaintext' option to either 'yes' or\n" - "'no' in '%s'.\n" - "-----------------------------------------------------------------------\n" - ; - return plaintext_prompt_helper(may_save_plaintext, realmstring, - prompt_string, prompt_text, baton, - pool); -} - -// This implements 'auth_ssl_server_trust_prompt_func_t'. -static error_t -cmdline_auth_ssl_server_trust_prompt( - auth_cred_ssl_server_trust_t ** cred_p, - void * baton, - const char * realm, - apr_uint32_t failures, - const auth_ssl_server_cert_info_t * cert_info, - bool may_save, - apr_pool_t * pool) -{ - cmdline_prompt_baton2_t * pb = - static_cast(baton); - stringbuf_t * buf = stringbuf_create("", pool); - - /*if (failures & WEBDAV_AUTH_SSL_UNKNOWNCA) - { - stringbuf_appendcstr(buf, - " - The certificate is not issued by a trusted authority. Use the\n" - " fingerprint to validate the certificate manually!\n"); - }*/ - - if (failures & WEBDAV_AUTH_SSL_CNMISMATCH) - { - stringbuf_appendcstr(buf, "- The certificate hostname does not match.\n"); - } - - if (failures & WEBDAV_AUTH_SSL_NOTYETVALID) - { - stringbuf_appendcstr(buf, "- The certificate is not yet valid.\n"); - } - - if (failures & WEBDAV_AUTH_SSL_EXPIRED) - { - stringbuf_appendcstr(buf, "- The certificate has expired.\n"); - } - - if (failures & WEBDAV_AUTH_SSL_OTHER) - { - stringbuf_appendcstr(buf, "- The certificate has an unknown error.\n"); - } - - stringbuf_t * msg = stringbuf_createf(pool, - // "Certificate information:\n" - " - Hostname: %s\n" - " - Valid: from %s until %s\n" - " - Issuer: %s\n" - " - Fingerprint: %s", - cert_info->hostname, - cert_info->valid_from, - cert_info->valid_until, - cert_info->issuer_dname, - cert_info->fingerprint); - stringbuf_appendstr(buf, msg); - - auth_baton_t * ab = static_cast(pb->cancel_baton); - assert(ab); - TWebDAVFileSystem * fs = static_cast(apr_hash_get(ab->parameters, - CONST_FS_KEY, - APR_HASH_KEY_STRING)); - assert(fs); - - unsigned int RequestResult = 0; - WEBDAV_ERR(fs->VerifyCertificate(buf->data, cert_info->fingerprint, RequestResult)); - - if (RequestResult == qaYes) - { - *cred_p = static_cast(apr_pcalloc(pool, sizeof(**cred_p))); - (*cred_p)->may_save = TRUE; - (*cred_p)->accepted_failures = failures; - } - else if (RequestResult == qaNo) - { - *cred_p = static_cast(apr_pcalloc(pool, sizeof(**cred_p))); - (*cred_p)->may_save = FALSE; - (*cred_p)->accepted_failures = failures; - } - else - { - *cred_p = NULL; - } - - return WEBDAV_NO_ERROR; -} - -// This implements 'auth_ssl_client_cert_prompt_func_t'. -static error_t -cmdline_auth_ssl_client_cert_prompt( - auth_cred_ssl_client_cert_t ** cred_p, - void * baton, - const char * realm, - bool may_save, - apr_pool_t * pool) -{ - auth_cred_ssl_client_cert_t * cred = NULL; - const char * cert_file = NULL; - const char * abs_cert_file = NULL; - cmdline_prompt_baton2_t * pb = - static_cast(baton); - - auth_baton_t * ab = static_cast(pb->cancel_baton); - assert(ab); - TWebDAVFileSystem * fs = static_cast(apr_hash_get(ab->parameters, - CONST_FS_KEY, - APR_HASH_KEY_STRING)); - assert(fs); - - unsigned int RequestResult = 0; - WEBDAV_ERR(fs->AskForClientCertificateFilename(&cert_file, RequestResult, pool)); - if (RequestResult != qaOK) return WEBDAV_NO_ERROR; - - WEBDAV_ERR(dirent_get_absolute(&abs_cert_file, cert_file, pool)); - - cred = static_cast(apr_pcalloc(pool, sizeof(*cred))); - cred->cert_file = abs_cert_file; - cred->may_save = may_save; - *cred_p = cred; - - return WEBDAV_NO_ERROR; -} - -// This implements 'auth_ssl_client_cert_pw_prompt_func_t'. -static error_t -cmdline_auth_ssl_client_cert_pw_prompt( - auth_cred_ssl_client_cert_pw_t ** cred_p, - void * baton, - const char * realm, - bool may_save, - apr_pool_t * pool) -{ - auth_cred_ssl_client_cert_pw_t * cred = NULL; - cmdline_prompt_baton2_t * pb = - static_cast(baton); - - auth_baton_t * ab = static_cast(pb->cancel_baton); - assert(ab); - TWebDAVFileSystem * fs = static_cast(apr_hash_get(ab->parameters, - CONST_FS_KEY, - APR_HASH_KEY_STRING)); - assert(fs); - - unsigned int RequestResult = 0; - const char * result = NULL; - WEBDAV_ERR(fs->AskForPassphrase(&result, realm, RequestResult, pool)); - if (RequestResult != qaOK) return WEBDAV_NO_ERROR; - - cred = static_cast(apr_pcalloc(pool, sizeof(*cred))); - cred->password = result; - cred->may_save = may_save; - *cred_p = cred; - - return WEBDAV_NO_ERROR; -} - -// This implements 'auth_simple_prompt_func_t'. -static error_t -cmdline_auth_simple_prompt( - auth_cred_simple_t ** cred_p, - void * baton, - const char * realm, - const char * username, - bool may_save, - apr_pool_t * pool) -{ - auth_cred_simple_t * ret = - static_cast(apr_pcalloc(pool, sizeof(*ret))); - cmdline_prompt_baton2_t * pb = - static_cast(baton); - - auth_baton_t * ab = static_cast(pb->cancel_baton); - assert(ab); - TWebDAVFileSystem * fs = static_cast(apr_hash_get(ab->parameters, - CONST_FS_KEY, - APR_HASH_KEY_STRING)); - assert(fs); - unsigned int RequestResult = 0; - - if (username) - ret->username = apr_pstrdup(pool, username); - else - { - WEBDAV_ERR(fs->AskForUsername(&ret->username, RequestResult, pool)); - if (RequestResult != qaOK) return WEBDAV_NO_ERROR; - } - - WEBDAV_ERR(fs->AskForUserPassword(&ret->password, RequestResult, pool)); - if (RequestResult != qaOK) return WEBDAV_NO_ERROR; - - ret->may_save = may_save; - *cred_p = ret; - return WEBDAV_NO_ERROR; -} - -// This implements 'auth_username_prompt_func_t'. -static error_t -cmdline_auth_username_prompt( - auth_cred_username_t ** cred_p, - void * baton, - const char * realm, - bool may_save, - apr_pool_t * pool) -{ - auth_cred_username_t * ret = - static_cast(apr_pcalloc(pool, sizeof(*ret))); - cmdline_prompt_baton2_t * pb = - static_cast(baton); - - auth_baton_t * ab = static_cast(pb->cancel_baton); - assert(ab); - TWebDAVFileSystem * fs = static_cast(apr_hash_get(ab->parameters, - CONST_FS_KEY, - APR_HASH_KEY_STRING)); - assert(fs); - - unsigned int RequestResult = 0; - WEBDAV_ERR(fs->AskForUsername(&ret->username, RequestResult, pool)); - if (RequestResult != qaOK) return WEBDAV_NO_ERROR; - - ret->may_save = may_save; - *cred_p = ret; - return WEBDAV_NO_ERROR; -} - -//--------------------------------------------------------------------------- -// from cmdline.c - -static error_t -ssl_trust_unknown_server_cert( - auth_cred_ssl_server_trust_t ** cred_p, - void * baton, - const char * realm, - apr_uint32_t failures, - const auth_ssl_server_cert_info_t * cert_info, - bool may_save, - apr_pool_t * pool) -{ - *cred_p = NULL; - - if (failures == 0 || failures == WEBDAV_AUTH_SSL_UNKNOWNCA) - { - *cred_p = static_cast(apr_pcalloc(pool, sizeof(**cred_p))); - (*cred_p)->may_save = FALSE; - (*cred_p)->accepted_failures = failures; - } - - return WEBDAV_NO_ERROR; -} - -static error_t -auth_baton_init( - auth_baton_t * ab, - bool non_interactive, - const char * auth_username, - const char * auth_password, - bool no_auth_cache, - bool trust_server_cert, - TWebDAVFileSystem * fs, - cancel_func_t cancel_func, - void * cancel_baton, - apr_pool_t * pool) -{ - bool store_password_val = TRUE; - bool store_auth_creds_val = TRUE; - auth_provider_object_t * provider = NULL; - cmdline_prompt_baton2_t * pb = NULL; - - // The whole list of registered providers - apr_array_header_t * providers = NULL; - - // Populate the registered providers with the platform-specific providers - WEBDAV_ERR(auth_get_platform_specific_client_providers(&providers, - pool)); - - // If we have a cancellation function, cram it and the stuff it - // needs into the prompt baton. - if (cancel_func) - { - pb = static_cast(apr_pcalloc(pool, sizeof(*pb))); - pb->cancel_func = cancel_func; - pb->cancel_baton = cancel_baton; - } - - if (non_interactive == FALSE) - { - // This provider doesn't prompt the user in order to get creds; - // it prompts the user regarding the caching of creds. - auth_get_simple_provider2(&provider, - cmdline_auth_plaintext_prompt, - pb, pool); - } - else - { - auth_get_simple_provider2(&provider, NULL, NULL, pool); - } - APR_ARRAY_PUSH(providers, auth_provider_object_t *) = provider; - - auth_get_username_provider(&provider, pool); - APR_ARRAY_PUSH(providers, auth_provider_object_t *) = provider; - - // The server-cert, client-cert, and client-cert-password providers. - WEBDAV_ERR(auth_get_platform_specific_provider(&provider, - "windows", - "ssl_server_trust", - pool)); - APR_ARRAY_PUSH(providers, auth_provider_object_t *) = provider; - - auth_get_ssl_server_trust_file_provider(&provider, pool); - APR_ARRAY_PUSH(providers, auth_provider_object_t *) = provider; - - auth_get_ssl_client_cert_file_provider(&provider, pool); - APR_ARRAY_PUSH(providers, auth_provider_object_t *) = provider; - - if (non_interactive == FALSE) - { - // This provider doesn't prompt the user in order to get creds; - // it prompts the user regarding the caching of creds. - auth_get_ssl_client_cert_pw_file_provider2(&provider, cmdline_auth_plaintext_passphrase_prompt, - pb, pool); - } - else - { - auth_get_ssl_client_cert_pw_file_provider2(&provider, NULL, NULL, - pool); - } - APR_ARRAY_PUSH(providers, auth_provider_object_t *) = provider; - - if (non_interactive == FALSE) - { - // Two basic prompt providers: username/password, and just username. - auth_get_simple_prompt_provider(&provider, - cmdline_auth_simple_prompt, - pb, - 2, // retry limit - pool); - APR_ARRAY_PUSH(providers, auth_provider_object_t *) = provider; - - auth_get_username_prompt_provider(&provider, cmdline_auth_username_prompt, pb, - 2, /* retry limit */ pool); - APR_ARRAY_PUSH(providers, auth_provider_object_t *) = provider; - - // Three ssl prompt providers, for server-certs, client-certs, - // and client-cert-passphrases. - auth_get_ssl_server_trust_prompt_provider(&provider, cmdline_auth_ssl_server_trust_prompt, pb, pool); - APR_ARRAY_PUSH(providers, auth_provider_object_t *) = provider; - - auth_get_ssl_client_cert_prompt_provider(&provider, cmdline_auth_ssl_client_cert_prompt, pb, 2, pool); - APR_ARRAY_PUSH(providers, auth_provider_object_t *) = provider; - - auth_get_ssl_client_cert_pw_prompt_provider(&provider, cmdline_auth_ssl_client_cert_pw_prompt, pb, 2, pool); - APR_ARRAY_PUSH(providers, auth_provider_object_t *) = provider; - } - else if (trust_server_cert) - { - // Remember, only register this provider if non_interactive. - auth_get_ssl_server_trust_prompt_provider(&provider, ssl_trust_unknown_server_cert, NULL, pool); - APR_ARRAY_PUSH(providers, auth_provider_object_t *) = provider; - } - - // Build an authentication baton to give to libclient. - create_baton_open(ab, providers, pool); - auth_baton_set_parameter(ab, CONST_FS_KEY, fs); - - // Place any default username or password credentials into the - // auth_baton's run-time parameter hash. - if (auth_username) - auth_baton_set_parameter(ab, WEBDAV_AUTH_PARAM_DEFAULT_USERNAME, - auth_username); - if (auth_password) - auth_baton_set_parameter(ab, WEBDAV_AUTH_PARAM_DEFAULT_PASSWORD, - auth_password); - - // Same with the non-interactive option. - if (non_interactive) - auth_baton_set_parameter(ab, WEBDAV_AUTH_PARAM_NON_INTERACTIVE, ""); - - if (!store_password_val) - auth_baton_set_parameter(ab, WEBDAV_AUTH_PARAM_DONT_STORE_PASSWORDS, ""); - - if (no_auth_cache || !store_auth_creds_val) - auth_baton_set_parameter(ab, WEBDAV_AUTH_PARAM_NO_AUTH_CACHE, ""); - - return WEBDAV_NO_ERROR; -} - -//--------------------------------------------------------------------------- -// from main.c - -// A flag to see if we've been canceled by the client or not. -static volatile atomic_t cancelled = FALSE; - -// Our cancellation callback. -static error_t -check_cancel(void * baton) -{ - if (cancelled) - return error_create(WEBDAV_ERR_CANCELLED, NULL, "Cancelled"); - else - return WEBDAV_NO_ERROR; -} - -//--------------------------------------------------------------------------- -// from ra.c - -static error_t -cancel_callback(void * baton) -{ - callback_baton_t * cb = static_cast(baton); - TWebDAVFileSystem * fs = static_cast(apr_hash_get(cb->ctx->auth_baton->parameters, - CONST_FS_KEY, - APR_HASH_KEY_STRING)); - assert(fs); - cancelled = static_cast(fs->GetIsCancelled()); - return error_trace((cb->ctx->cancel_func)(cb->ctx->cancel_baton)); -} - -static error_t -get_client_string( - void * baton, - const char ** name, - apr_pool_t * pool) -{ - callback_baton_t * b = static_cast(baton); - *name = apr_pstrdup(pool, b->ctx->client_name); - return WEBDAV_NO_ERROR; -} - -// see ra.c::client_session_from_path -static error_t -init_session_from_path( - session_t * session, - const char ** url_p, - const char * path_or_url, - apr_pool_t * pool) -{ - const char * initial_url, *url; - - neon_session_t * ras = static_cast(session->priv); - assert(ras); - - WEBDAV_ERR(client_url_from_path2(&initial_url, path_or_url, - ras->url, pool, pool)); - if (!initial_url) - return error_createf(WEBDAV_ERR_ENTRY_MISSING_URL, NULL, - "'%s' has no URL", path_or_url); - - url = initial_url; - // Make the session point to the real URL. - WEBDAV_ERR(reparent(session, url, pool)); - - *url_p = url; - - return WEBDAV_NO_ERROR; -} - -static error_t -client_open_session_internal( - session_t ** ra_session, - const char ** corrected_url, - const char * base_url, - client_ctx_t * ctx, - apr_pool_t * pool) -{ - // prepare callbacks, contexts - callbacks2_t * cbtable = static_cast(apr_pcalloc(pool, sizeof(*cbtable))); - callback_baton_t * cb = static_cast(apr_pcalloc(pool, sizeof(*cb))); - - cbtable->auth_baton = ctx->auth_baton; - cbtable->progress_func = ctx->progress_func; - cbtable->progress_baton = ctx->progress_baton; - cbtable->cancel_func = ctx->cancel_func ? cancel_callback : NULL; - cbtable->get_client_string = get_client_string; - - cb->pool = pool; - cb->ctx = ctx; - - if (corrected_url) - { - apr_hash_t * attempted = apr_hash_make(pool); - int attempts_left = MAX_REDIRECT_ATTEMPTS; - while (attempts_left--) - { - const char * corrected = NULL; - WEBDAV_ERR(session_open( - ra_session, - attempts_left == 0 ? NULL : &corrected, - base_url, cbtable, cb, - pool)); - // No error and no corrected URL? We're done here. - if (!corrected) - break; - // Our caller will want to know what our final corrected URL was. - *corrected_url = corrected; - // Make sure we've not attempted this URL before. - if (apr_hash_get(attempted, corrected, APR_HASH_KEY_STRING)) - return WEBDAV_ERR_CLIENT_CYCLE_DETECTED; - // Remember this CORRECTED_URL so we don't wind up in a loop. - apr_hash_set(attempted, apr_pstrdup(pool, corrected), APR_HASH_KEY_STRING, (void *)1); - base_url = corrected; - } - } - else - { - WEBDAV_ERR(session_open(ra_session, NULL, base_url, - cbtable, cb, - pool)); - } - return WEBDAV_NO_ERROR; -} - -//--------------------------------------------------------------------------- -// from list.c - -static error_t -get_dir_contents( - apr_uint32_t dirent_fields, - const char * dir, - session_t * ra_session, - const char * fs_path, - depth_t depth, - client_list_func_t list_func, - void * baton, - apr_pool_t * pool) -{ - apr_hash_t * tmpdirents = NULL; - apr_pool_t * iterpool = webdav_pool_create(pool); - apr_array_header_t * array = NULL; - error_t err = 0; - - if (depth == depth_empty) - return WEBDAV_NO_ERROR; - - // Get the directory's entries, but not its props. Ignore any - // not-authorized errors. - err = get_dir2(ra_session, &tmpdirents, - dir, - dirent_fields, pool); - if (err && ((err == WEBDAV_ERR_NOT_AUTHORIZED) || - (err == WEBDAV_ERR_DAV_FORBIDDEN))) - { - error_clear(&err); - return WEBDAV_NO_ERROR; - } - WEBDAV_ERR(err); - - neon_session_t * ras = static_cast(ra_session->priv); - assert(ras); - if (ras->callbacks->cancel_func) - WEBDAV_ERR(ras->callbacks->cancel_func(ras->callback_baton)); - - // Sort the hash, so we can call the callback in a "deterministic" order. - array = sort_hash(tmpdirents, sort_compare_items_lexically, pool); - for (int i = 0; i < array->nelts; ++i) - { - sort_item_t * item = &APR_ARRAY_IDX(array, i, sort_item_t); - dirent_t * the_ent = static_cast(apr_hash_get(tmpdirents, item->key, item->klen)); - - webdav_pool_clear(iterpool); - - const char * path = relpath_join(dir, static_cast(item->key), iterpool); - - if ((the_ent->kind == node_file) || - (depth == depth_immediates) || - (depth == depth_infinity)) - WEBDAV_ERR(list_func(baton, path, - the_ent, - fs_path, iterpool)); - - if (depth == depth_infinity && the_ent->kind == node_dir) - WEBDAV_ERR(get_dir_contents(dirent_fields, path, - ra_session, - fs_path, depth, - list_func, baton, iterpool)); - } - - webdav_pool_destroy(iterpool); - return WEBDAV_NO_ERROR; -} - -//------------------------------------------------------------------------------ -// from options.c - -static const neon_xml_elm_t options_elements[] = -{ - { "DAV:", "href", ELEM_href, NEON_XML_CDATA }, - { "DAV:", "options-response", ELEM_options_response, 0 }, - - { NULL } -}; - -typedef struct options_ctx_t -{ - // WARNING: WANT_CDATA should stay the first element in the baton: - // neon_xml_collect_cdata() assumes the baton starts with a stringbuf. - - stringbuf_t * want_cdata; - stringbuf_t * cdata; - apr_pool_t * pool; -} options_ctx_t; - -static int -options_validate_element( - neon_xml_elmid parent, - neon_xml_elmid child) -{ - switch (parent) - { - case ELEM_root: - if (child == ELEM_options_response) - return child; - else - return NEON_XML_INVALID; - - case ELEM_options_response: - return NEON_XML_DECLINE; // not concerned with other response - - default: - return NEON_XML_DECLINE; - } - - // NOTREACHED -} - -static error_t -options_start_element( - int * elem, - void * baton, - int parent, - const char * nspace, - const char * name, - const char ** atts) -{ - options_ctx_t * oc = static_cast(baton); - const neon_xml_elm_t * elm = neon_lookup_xml_elem(options_elements, nspace, name); - - *elem = elm ? options_validate_element(parent, elm->id) : NEON_XML_DECLINE; - if (*elem < 1) // Not a valid element - return WEBDAV_NO_ERROR; - - if (elm->id == ELEM_href) - oc->want_cdata = oc->cdata; - else - oc->want_cdata = NULL; - - return WEBDAV_NO_ERROR; -} - -static error_t -options_end_element( - void * baton, - int state, - const char * nspace, - const char * name) -{ - return WEBDAV_NO_ERROR; -} - -static error_t -neon_exchange_capabilities( - neon_session_t * ras, - const char ** relocation_location, - apr_pool_t * pool) -{ - neon_request_t * req = NULL; - error_t err = WEBDAV_NO_ERROR; - ne_xml_parser * parser = NULL; - options_ctx_t oc = { 0 }; - int status_code = 0; - - oc.pool = pool; - oc.cdata = stringbuf_create("", pool); - - if (relocation_location) - *relocation_location = NULL; - - WEBDAV_ERR(neon_request_create(&req, ras, - "OPTIONS", ras->url->data, pool)); - - // Use a symbolic name somewhere for this MIME type? - ne_add_request_header(req->ne_req, "Content-Type", "text/xml"); - apr_hash_t * extra_headers = apr_hash_make(pool); - neon_add_depth_header(extra_headers, NEON_DEPTH_ZERO); - - // Create a parser to read the normal response body - parser = neon_xml_parser_create(req, ne_accept_2xx, options_start_element, - neon_xml_collect_cdata, - options_end_element, &oc); - - // Run the request and get the resulting status code. - if ((err = neon_request_dispatch(&status_code, req, extra_headers, - "" - "" - "" - "", - 200, - relocation_location ? 301 : 0, - false, - pool)) != WEBDAV_NO_ERROR) - goto cleanup; - if (req->code == 301) - { - *relocation_location = neon_request_get_location(req, pool); - goto cleanup; - } - - // Was there an XML parse error somewhere? - err = neon_check_parse_error("OPTIONS", parser, ras->url->data); - if (err) - goto cleanup; - -cleanup: - neon_request_destroy(req); - - return err; -} - -//------------------------------------------------------------------------------ -// from props.c - -typedef struct propfind_ctx_t -{ - // WARNING: WANT_CDATA should stay the first element in the baton: - // neon_xml_collect_cdata() assumes the baton starts with a stringbuf. - stringbuf_t * cdata; - apr_hash_t * props; // const char *URL-PATH -> neon_resource_t - - neon_resource_t * rsrc; // the current resource. - const char * encoding; // property encoding (or NULL) - int status; // status for the current (or 0 if unknown). - apr_hash_t * propbuffer; // holds properties until their status is known. - neon_xml_elmid last_open_id; // the id of the last opened tag. - ne_xml_parser * parser; // xml parser handling the PROPSET request. - - apr_pool_t * pool; - -} propfind_ctx_t; - -// When we begin a checkout, we fetch these from the "public" resources. -// We fetch the resourcetype to -// verify that we're accessing a collection. -static const ne_propname starting_props[] = -{ - { "DAV:", "resourcetype" }, - { "DAV:", "creationdate" }, - { "DAV:", "getlastmodified" }, - { "DAV:", "getcontentlength" }, - { NULL } -}; - -static error_t -neon_get_starting_props( - neon_resource_t ** rsrc, - neon_session_t * sess, - const char * url, - bool check_errors, - apr_pool_t * pool) -{ - WEBDAV_ERR(neon_get_props_resource(rsrc, sess, url, - starting_props, check_errors, pool)); - - // Cache some of the resource information. - - if (!sess->webdav_root) - { - string_t * propval = NULL; - - if (propval) - { - ne_uri uri = {0}; - stringbuf_t * urlbuf = stringbuf_create(url, pool); - - path_remove_components(urlbuf, - path_component_count(propval->data)); - - uri = sess->root; - uri.path = urlbuf->data; - - sess->webdav_root = neon_uri_unparse(&uri, sess->pool); - } - } - - return WEBDAV_NO_ERROR; -} - -// Propfind Implementation - -typedef struct elem_defn -{ - neon_xml_elmid id; - const char * name; - int is_property; // is it a property, or part of some structure? -} elem_defn; - -static const elem_defn elem_definitions[] = -{ - // NOTE: Make sure that every item in here is also represented in - // propfind_elements[] - - // DAV elements - { ELEM_multistatus, "DAV:multistatus", 0 }, - { ELEM_response, "DAV:response", 0 }, - { ELEM_href, "DAV:href", NEON_XML_CDATA }, - { ELEM_propstat, "DAV:propstat", 0 }, - { ELEM_prop, "DAV:prop", 0 }, - { ELEM_status, "DAV:status", NEON_XML_CDATA }, - { ELEM_collection, "DAV:collection", NEON_XML_CDATA }, - { ELEM_resourcetype, "DAV:resourcetype", 0 }, - { ELEM_get_content_length, NEON_PROP_GETCONTENTLENGTH, 1 }, - { ELEM_creationdate, NEON_PROP_CREATIONDATE, 1 }, - - { 0 } -}; - -static const neon_xml_elm_t propfind_elements[] = -{ - // NOTE: Make sure that every item in here is also represented in - // elem_definitions[] - - // DAV elements - { "DAV:", "multistatus", ELEM_multistatus, 0 }, - { "DAV:", "response", ELEM_response, 0 }, - { "DAV:", "href", ELEM_href, NEON_XML_CDATA }, - { "DAV:", "propstat", ELEM_propstat, 0 }, - { "DAV:", "prop", ELEM_prop, 0 }, - { "DAV:", "status", ELEM_status, NEON_XML_CDATA }, - { "DAV:", "collection", ELEM_collection, NEON_XML_CDATA }, - { "DAV:", "resourcetype", ELEM_resourcetype, 0 }, - { "DAV:", "getcontentlength", ELEM_get_content_length, NEON_XML_CDATA }, - { "DAV:", "getlastmodified", ELEM_get_last_modified, NEON_XML_CDATA }, - { - "DAV:", "creator-displayname", ELEM_creator_displayname, - NEON_XML_CDATA - }, - - // Unknowns - { "", "", ELEM_unknown, NEON_XML_COLLECT }, - - { NULL } -}; - -// Look up an element definition ID. May return NULL if the elem is -// not recognized. -static const elem_defn * -defn_from_id( - neon_xml_elmid id) -{ - for (const elem_defn * defn = elem_definitions; defn->name != NULL; ++defn) - { - if (id == defn->id) - return defn; - } - - return NULL; -} - -// Assign URL to RSRC. Use POOL for any allocations. -static error_t -assign_rsrc_url( - neon_resource_t * rsrc, - const char * url, - apr_pool_t * pool) -{ - char * url_path = NULL; - apr_size_t len = 0; - ne_uri parsed_url = {0}; - - // Parse the PATH element out of the URL. - // NOTE: mod_dav does not (currently) use an absolute URL, but simply a - // server-relative path (i.e. this uri_parse is effectively a no-op). - - if (ne_uri_parse(url, &parsed_url) != 0) - { - ne_uri_free(&parsed_url); - return error_createf(WEBDAV_ERR_DAV_MALFORMED_DATA, NULL, - "Unable to parse URL '%s'", url); - } - - url_path = apr_pstrdup(pool, parsed_url.path); - ne_uri_free(&parsed_url); - - // Clean up trailing slashes from the URL. - len = strlen(url_path); - if ((len > 1) && (url_path[len - 1] == '/')) - url_path[len - 1] = '\0'; - rsrc->url = url_path; - - return WEBDAV_NO_ERROR; -} - -// Determine whether we're receiving the expected XML response. -// Return CHILD when interested in receiving the child's contents -// or one of NEON_XML_INVALID and NEON_XML_DECLINE -// when respectively this is the incorrect response or -// the element (and its children) are uninteresting -static int -props_validate_element( - neon_xml_elmid parent, - neon_xml_elmid child) -{ - switch (parent) - { - case ELEM_root: - if (child == ELEM_multistatus) - return child; - else - return NEON_XML_INVALID; - - case ELEM_multistatus: - if (child == ELEM_response) - return child; - else - return NEON_XML_DECLINE; - - case ELEM_response: - if ((child == ELEM_href) || (child == ELEM_propstat)) - return child; - else - return NEON_XML_DECLINE; - - case ELEM_propstat: - if ((child == ELEM_prop) || (child == ELEM_status)) - return child; - else - return NEON_XML_DECLINE; - - case ELEM_prop: - return child; // handle all children of - - case ELEM_resourcetype: - if (child == ELEM_collection) - return child; - else - return NEON_XML_DECLINE; // not concerned with other types (now) - - default: - return NEON_XML_DECLINE; - } - - // NOTREACHED -} - -static error_t -props_start_element( - int * elem, - void * baton, - int parent, - const char * nspace, - const char * name, - const char ** atts) -{ - propfind_ctx_t * pc = static_cast(baton); - const neon_xml_elm_t * elm = neon_lookup_xml_elem(propfind_elements, nspace, name); - - *elem = elm ? props_validate_element(parent, elm->id) : NEON_XML_DECLINE; - if (*elem < 1) // not a valid element - return WEBDAV_NO_ERROR; - - stringbuf_setempty(pc->cdata); - *elem = elm ? elm->id : ELEM_unknown; - switch (*elem) - { - case ELEM_response: - if (pc->rsrc) - return error_create(WEBDAV_ERR_XML_MALFORMED, NULL, NULL); - // Create a new resource. - pc->rsrc = static_cast(apr_pcalloc(pc->pool, sizeof(*(pc->rsrc)))); - pc->rsrc->pool = pc->pool; - pc->rsrc->propset = apr_hash_make(pc->pool); - pc->status = 0; - break; - - case ELEM_propstat: - pc->status = 0; - break; - - case ELEM_href: - pc->rsrc->href_parent = pc->last_open_id; - break; - - case ELEM_collection: - pc->rsrc->is_collection = 1; - break; - - case ELEM_unknown: - // these are our user-visible properties, presumably. - if (pc->encoding) - pc->encoding = apr_pstrdup(pc->pool, pc->encoding); - break; - - default: - // nothing to do for these - break; - } - - // Remember the last tag we opened. - pc->last_open_id = *elem; - return WEBDAV_NO_ERROR; -} - -static error_t -props_end_element( - void * baton, - int state, - const char * nspace, - const char * name) -{ - propfind_ctx_t * pc = static_cast(baton); - neon_resource_t * rsrc = pc->rsrc; - const string_t * value = NULL; - const elem_defn * parent_defn = NULL; - const elem_defn * defn = NULL; - ne_status status = {0}; - const char * cdata = pc->cdata->data; - - switch (state) - { - case ELEM_response: - // Verify that we've received a URL for this resource. - if (!pc->rsrc->url) - return error_create(WEBDAV_ERR_XML_MALFORMED, NULL, NULL); - - // Store the resource in the top-level hash table. - apr_hash_set(pc->props, pc->rsrc->url, APR_HASH_KEY_STRING, pc->rsrc); - pc->rsrc = NULL; - return WEBDAV_NO_ERROR; - - case ELEM_propstat: - // We're at the end of a set of properties. Do the right thing status-wise. - if (pc->status) - { - for (apr_hash_index_t * hi = apr_hash_first(pc->pool, pc->propbuffer); hi; - hi = apr_hash_next(hi)) - { - const void * key; - apr_ssize_t klen; - void * val; - apr_hash_this(hi, &key, &klen, &val); - if (pc->status == 200) - apr_hash_set(rsrc->propset, key, klen, val); - apr_hash_set(pc->propbuffer, key, klen, NULL); - } - } - else if (!pc->status) - { - // No status at all? Bogosity. - return error_create(WEBDAV_ERR_XML_MALFORMED, NULL, NULL); - } - return WEBDAV_NO_ERROR; - - case ELEM_status: - // Parse the tag's CDATA for a status code. - if (ne_parse_statusline(cdata, &status)) - return error_create(WEBDAV_ERR_XML_MALFORMED, NULL, NULL); - ne_free(status.reason_phrase); - pc->status = status.code; - return WEBDAV_NO_ERROR; - - case ELEM_href: - // Special handling for that belongs to the tag. - if (rsrc->href_parent == ELEM_response) - return assign_rsrc_url(pc->rsrc, - urlpath_canonicalize(cdata, pc->pool), - pc->pool); - - // Use the parent element's name, not the href. - parent_defn = defn_from_id(rsrc->href_parent); - - // No known parent? Get outta here. - if (!parent_defn) - return WEBDAV_NO_ERROR; - - // All other href's we'll treat as property values. - name = parent_defn->name; - value = string_create(urlpath_canonicalize(cdata, pc->pool), - pc->pool); - break; - - default: - if (state == ELEM_unknown) - { - name = apr_pstrcat(pc->pool, nspace, name, (char *)NULL); - } - else - { - defn = defn_from_id(state); - if (!(defn && defn->is_property)) - return WEBDAV_NO_ERROR; - name = defn->name; - } - - // Check for encoding attribute. - if (pc->encoding == NULL) - { - // Handle the property value by converting it to string. - value = string_create(cdata, pc->pool); - break; - } - - // Check for known encoding type - if (strcmp(pc->encoding, "base64") != 0) - return error_create(WEBDAV_ERR_XML_MALFORMED, NULL, NULL); - - pc->encoding = NULL; // Reset encoding for future attribute(s). - } - - // Handling resource properties from here out. - - // Add properties to the temporary propbuffer. At the end of the - // , we'll either dump the props as invalid or move them - // into the resource's property hash. - apr_hash_set(pc->propbuffer, name, APR_HASH_KEY_STRING, value); - return WEBDAV_NO_ERROR; -} - -static void -props_set_parser( - ne_xml_parser * parser, - void * baton) -{ - propfind_ctx_t * pc = static_cast(baton); - pc->parser = parser; -} - -static error_t -neon_get_props( - apr_hash_t ** results, - neon_session_t * sess, - const char * url, - int depth, - const ne_propname * which_props, - bool check_errors, - apr_pool_t * pool) -{ - apr_hash_t * extra_headers = apr_hash_make(pool); - - neon_add_depth_header(extra_headers, depth); - - // It's easier to roll our own PROPFIND here than use neon's current interfaces. - // The start of the request body is fixed: - stringbuf_t * body = stringbuf_create("" DEBUG_CR - "" DEBUG_CR, pool); - - // Are we asking for specific propert(y/ies), or just all of them? - if (which_props) - { - apr_pool_t * iterpool = webdav_pool_create(pool); - - stringbuf_appendcstr(body, "" DEBUG_CR); - for (int n = 0; which_props[n].name != NULL; n++) - { - webdav_pool_clear(iterpool); - stringbuf_appendcstr(body, apr_pstrcat(iterpool, "<", which_props[n].name, - " xmlns=\"", which_props[n].nspace, "\"/>" DEBUG_CR, - (char *)NULL)); - } - stringbuf_appendcstr(body, "" DEBUG_CR); - webdav_pool_destroy(iterpool); - } - else - { - stringbuf_appendcstr(body, "" DEBUG_CR); - } - - // Initialize our baton. - propfind_ctx_t pc; - memset(&pc, 0, sizeof(pc)); - pc.pool = pool; - pc.propbuffer = apr_hash_make(pool); - pc.props = apr_hash_make(pool); - pc.cdata = stringbuf_create("", pool); - - // Create and dispatch the request! - WEBDAV_ERR(neon_parsed_request(sess, "PROPFIND", url, - body->data, 0, - props_set_parser, - props_start_element, - neon_xml_collect_cdata, - props_end_element, - &pc, extra_headers, NULL, - check_errors, - pool)); - - *results = pc.props; - return WEBDAV_NO_ERROR; -} - -static error_t -neon_get_props_resource( - neon_resource_t ** rsrc, - neon_session_t * sess, - const char * url, - const ne_propname * which_props, - bool check_errors, - apr_pool_t * pool) -{ - apr_hash_t * props = NULL; - char * url_path = apr_pstrdup(pool, url); - apr_size_t len = strlen(url); - // Clean up any trailing slashes. - if ((len > 1) && (url[len - 1] == '/')) - url_path[len - 1] = '\0'; - - WEBDAV_ERR(neon_get_props(&props, sess, url_path, NEON_DEPTH_ZERO, - which_props, check_errors, pool)); - - // HACK. We need to have the client canonicalize paths, get rid - // of double slashes and such. This check is just a check against - // non-SVN servers; in the long run we want to re-enable this. - { - // pick out the first response: the URL requested will not match - // the response href. - apr_hash_index_t * hi = apr_hash_first(pool, props); - if (hi) - { - void * ent; - apr_hash_this(hi, NULL, NULL, &ent); - *rsrc = static_cast(ent); - } - else - *rsrc = NULL; - } - - if (*rsrc == NULL) - { - // hmmm, should have been in there... - return error_createf(APR_EGENERAL, NULL, - "Failed to find label '%s' for URL '%s'", - "NULL", url_path); - } - - return WEBDAV_NO_ERROR; -} - -//------------------------------------------------------------------------------ - -static error_t -client_list2( - session_t * session, - const char * path_or_url, - depth_t depth, - apr_uint32_t dirent_fields, - client_list_func_t list_func, - void * baton, - apr_pool_t * pool) -{ - dirent_t * dirent = NULL; - const char * url = NULL; - const char * webdav_root = NULL; - const char * fs_path = NULL; - error_t err = 0; - - assert(session); - - // We use the kind field to determine if we should recurse, so we - // always need it. - dirent_fields |= WEBDAV_DIRENT_KIND; - - WEBDAV_ERR(init_session_from_path(session, - &url, path_or_url, - pool)); - - WEBDAV_ERR(get_webdav_resource_root2(session, &webdav_root, pool)); - - WEBDAV_ERR(client_path_relative_to_root(&fs_path, - url, - webdav_root, TRUE, session, - pool, pool)); - - err = stat(session, "", &dirent, pool); - - if (err) - return error_trace(err); - - if (!dirent) - return error_createf(WEBDAV_ERR_FS_NOT_FOUND, NULL, - "URL '%s' non-existent", - url); - - // Report the dirent for the target. - WEBDAV_ERR(list_func(baton, "", dirent, fs_path, pool)); - - if (dirent->kind == node_dir && (depth == depth_files || - depth == depth_immediates || - depth == depth_infinity)) - { - WEBDAV_ERR(get_dir_contents(dirent_fields, "", - session, - fs_path, depth, - list_func, baton, pool)); - } - return WEBDAV_NO_ERROR; -} - -static error_t -client_get_file( - session_t * session, - const char * remote_path, - apr_os_file_t * thefile, - apr_pool_t * pool) -{ - const char * remote_url = NULL; - WEBDAV_ERR(init_session_from_path(session, - &remote_url, path_uri_encode(remote_path, pool), - pool)); - - stream_t * fstream = NULL; - WEBDAV_ERR(stream_open_writable(&fstream, thefile, - pool, pool)); - const char * src_rel = NULL; - WEBDAV_ERR(get_path_relative_to_session(session, &src_rel, - remote_url, - pool)); - WEBDAV_ERR(get_file(session, src_rel, fstream, NULL, pool)); - WEBDAV_ERR(stream_close(fstream)); - return WEBDAV_NO_ERROR; -} - -static error_t -client_put_file( - session_t * session, - const char * remote_path, - const char * local_path, - apr_pool_t * pool) -{ - neon_session_t * ras = static_cast(session->priv); - assert(ras); - - error_t err = 0; - int code = 0; - apr_hash_t * extra_headers = NULL; // apr_hash_make(pool); - - neon_request_t * request = NULL; - const char * put_target = path_uri_encode(remote_path, pool); - - apr_file_t * body_file = NULL; - WEBDAV_ERR(io_file_open(&body_file, local_path, APR_READ | APR_BUFFERED | APR_BINARY, - APR_OS_DEFAULT, pool)); - // create/prep the request - WEBDAV_ERR(neon_request_create(&request, ras, "PUT", - put_target, pool)); - // Give the file to neon. The provider will rewind the file. - err = neon_set_neon_body_provider(request, body_file); - if (err) - goto cleanup; - // run the request and get the resulting status code (and error_t) - err = neon_request_dispatch(&code, request, extra_headers, NULL, - 201 /* Created */, - 204 /* No Content */, - false, - pool); - if (err && (err == WEBDAV_ERR_DAV_REQUEST_FAILED)) - { - err = error_createf(WEBDAV_ERR_CANNOT_PUT_FILE, NULL, - "Cannot create '%s'" - " (Status %d on PUT Request)", - put_target, code); - } - -cleanup: - neon_request_destroy(request); - WEBDAV_ERR(err); - return WEBDAV_NO_ERROR; -} - -static error_t -client_move_file_or_directory( - session_t * session, - const char * remote_path_from, - const char * remote_path_to, - void * baton, - apr_pool_t * pool) -{ - neon_session_t * ras = static_cast(session->priv); - assert(ras); - - error_t err = 0; - const char * target_from = path_uri_encode(remote_path_from, pool); - const char * target_to = path_uri_encode(remote_path_to, pool); - int code = 0; - - apr_hash_t * extra_headers = apr_hash_make(pool); - apr_hash_set(extra_headers, "Destination", APR_HASH_KEY_STRING, target_to); - neon_add_depth_header(extra_headers, NEON_DEPTH_INFINITE); - err = neon_simple_request(&code, ras, "MOVE", target_from, - extra_headers, NULL, - 201 /* Created */, - 204 /* No Content */, - pool); - if (err && (err == WEBDAV_ERR_DAV_REQUEST_FAILED)) - { - err = error_createf(WEBDAV_ERR_CANNOT_MOVE, NULL, - "Cannot move '%s' to '%s'" - " (Status %d on MOVE Request)", - target_from, target_to, code); - } - - return err; -} - -static error_t -client_delete_file( - session_t * session, - const char * remote_path, - void * baton, - apr_pool_t * pool) -{ - neon_session_t * ras = static_cast(session->priv); - assert(ras); - - error_t err = 0; - const char * target = path_uri_encode(remote_path, pool); - int code = 0; - - err = neon_simple_request(&code, ras, "DELETE", target, - NULL, NULL, - 200, - 204, // No Content - pool); - if (err && (err == WEBDAV_ERR_DAV_REQUEST_FAILED)) - { - err = error_createf(WEBDAV_ERR_CANNOT_DELETE_FILE, NULL, - "Cannot delete '%s'" - " (Status %d on DELETE Request)", - target, code); - } - - return err; -} - -static error_t -client_check_path( - session_t * session, - const char * remote_path, - node_kind_t * kind, - apr_pool_t * pool) -{ - neon_session_t * ras = static_cast(session->priv); - assert(ras); - - *kind = node_none; - - error_t err = 0; - char * target = apr_pstrdup(pool, path_uri_encode(remote_path, pool)); - - const char * rel_path = NULL; - apr_size_t len = strlen(target); - if ((len > 1) && ((target)[len - 1] == '/')) - { - (target)[len - 1] = '\0'; - } - if (*target == '/') - { - // check if root has trailing slash - apr_size_t len = strlen(ras->webdav_root); - if ((len > 1) && ((ras->webdav_root)[len - 1] == '/')) - { - target++; - } - const char * abs_path = apr_pstrcat(pool, ras->webdav_root, target, NULL); - - err = get_path_relative_to_root( - session, - &rel_path, - abs_path, - pool); - WEBDAV_ERR(err); - } - else - { - rel_path = target; - } - err = check_path( - session, - rel_path, - kind, - pool - ); - - return err; -} - -static error_t -client_make_directory( - session_t * session, - const char * remote_path, - void * baton, - apr_pool_t * pool) -{ - neon_session_t * ras = static_cast(session->priv); - assert(ras); - - error_t err = 0; - const char * target = path_uri_encode(remote_path, pool); - int code = 0; - - err = neon_simple_request( - &code, ras, "MKCOL", target, - NULL, NULL, - 201, 207, pool); - if (err && (err == WEBDAV_ERR_DAV_REQUEST_FAILED)) - { - err = error_createf(WEBDAV_ERR_CANNOT_MKCOL, NULL, - "Cannot create directory '%s'" - " (Status %d on MKCOL Request)", - target, code); - } - - return err; -} - -static error_t -client_send_propfind_request( - session_t * session, - const char * remote_path, - int * response_code, - apr_pool_t * pool) -{ - neon_session_t * ras = static_cast(session->priv); - assert(ras); - - error_t err = 0; - int code = 0; - - apr_hash_t * props = NULL; - const char * target = path_uri_encode(remote_path, pool); - char * url_path = apr_pstrdup(pool, target); - - WEBDAV_ERR(neon_get_props(&props, ras, url_path, NEON_DEPTH_ZERO, - starting_props, - false, - pool)); - - if (err && (err == WEBDAV_ERR_DAV_REQUEST_FAILED)) - { - err = error_createf(WEBDAV_ERR_CANNOT_PROPFIND, NULL, - "Cannot execute PROPFIND on '%s'" - " (Status %d on PROPFIND Request)", - target, code); - } - if (response_code) - *response_code = code; - return err; -} - -//------------------------------------------------------------------------------ -// from session.c - -typedef struct neonprogress_baton_t -{ - neon_session_t * ras; - apr_off_t last_progress; - apr_time_t last_progress_time; - apr_pool_t * pool; -} neonprogress_baton_t; - -// Callback invoked to enter PKCS#11 PIN code. -static int -client_ssl_pkcs11_pin_entry( - void * userdata, - int attempt, - const char * slot_descr, - const char * token_label, - unsigned int flags, - char * pin) -{ - neon_session_t * ras = static_cast(userdata); - void * creds = NULL; - auth_cred_ssl_client_cert_pw_t * pw_creds = NULL; - - // Always prevent PIN caching. - auth_baton_set_parameter(ras->callbacks->auth_baton, - AUTH_PARAM_NO_AUTH_CACHE, ""); - error_t err = 0; - if (attempt == 0) - { - const char * realmstring; - - realmstring = apr_psprintf(ras->pool, - "PIN for token \"%s\" in slot \"%s\"", - token_label, slot_descr); - - err = auth_first_credentials(&creds, - &(ras->auth_iterstate), - AUTH_CRED_SSL_CLIENT_CERT_PW, - realmstring, - ras->callbacks->auth_baton, - ras->pool); - } - else - { - err = auth_next_credentials(&creds, ras->auth_iterstate, ras->pool); - } - - if (err || !creds) - { - error_clear(&err); - return -1; - } - - pw_creds = static_cast(creds); - - strncpy(pin, pw_creds->password, NE_SSL_P11PINLEN); - - return 0; -} - -static bool -client_ssl_decrypt_cert( - neon_session_t * ras, - const char * cert_file, - ne_ssl_client_cert * clicert) -{ - auth_iterstate_t * state = NULL; - error_t error = 0; - apr_pool_t * pool = NULL; - bool ok = false; - void * creds = NULL; - int try_count = 0; - - apr_pool_create(&pool, ras->pool); - for (try_count = 0; TRUE; ++try_count) - { - if (try_count == 0) - { - error = auth_first_credentials(&creds, &state, - AUTH_CRED_SSL_CLIENT_CERT_PW, - cert_file, - ras->callbacks->auth_baton, - pool); - } - else - { - error = auth_next_credentials(&creds, state, pool); - } - - if (error || !creds) - { - // Failure or too many attempts - error_clear(&error); - break; - } - else - { - auth_cred_ssl_client_cert_pw_t * pw_creds = static_cast(creds); - - if (ne_ssl_clicert_decrypt(clicert, pw_creds->password) == 0) - { - error = auth_save_credentials(state, pool); - if (error) - error_clear(&error); - - // Success - ok = TRUE; - break; - } - } - } - webdav_pool_destroy(pool); - - return ok; -} - -static void -client_ssl_callback( - void * userdata, - ne_session * sess, - const ne_ssl_dname * const * dnames, - int dncount) -{ - neon_session_t * ras = static_cast(userdata); - ne_ssl_client_cert * clicert = NULL; - void * creds = NULL; - auth_iterstate_t * state = NULL; - const char * realmstring = NULL; - apr_pool_t * pool = NULL; - error_t error = 0; - int try_count = 0; - - apr_pool_create(&pool, ras->pool); - - realmstring = apr_psprintf(pool, "%s://%s:%d", ras->root.scheme, - ras->root.host, ras->root.port); - - for (try_count = 0; TRUE; ++try_count) - { - if (try_count == 0) - { - error = auth_first_credentials(&creds, &state, - AUTH_CRED_SSL_CLIENT_CERT, - realmstring, - ras->callbacks->auth_baton, - pool); - } - else - { - error = auth_next_credentials(&creds, state, pool); - } - - if (error || !creds) - { - // Failure or too many attempts - error_clear(&error); - break; - } - else - { - auth_cred_ssl_client_cert_t * client_creds = static_cast(creds); - - clicert = ne_ssl_clicert_read(client_creds->cert_file); - if (clicert) - { - if (!ne_ssl_clicert_encrypted(clicert) || - client_ssl_decrypt_cert(ras, client_creds->cert_file, - clicert)) - { - ne_ssl_set_clicert(sess, clicert); - } - ne_ssl_clicert_free(clicert); - clicert = NULL; - break; - } - } - } - - webdav_pool_destroy(pool); -} - -static const apr_uint32_t neon_failure_map[][2] = -{ - { NE_SSL_NOTYETVALID, WEBDAV_AUTH_SSL_NOTYETVALID }, - { NE_SSL_EXPIRED, WEBDAV_AUTH_SSL_EXPIRED }, - { NE_SSL_IDMISMATCH, WEBDAV_AUTH_SSL_CNMISMATCH }, - { NE_SSL_UNTRUSTED, WEBDAV_AUTH_SSL_UNKNOWNCA } -}; - -// Convert neon's SSL failure mask to our own failure mask. -static apr_uint32_t -convert_neon_failures( - int neon_failures) -{ - apr_uint32_t failures = 0; - - for (apr_size_t i = 0; i < sizeof(neon_failure_map) / (2 * sizeof(int)); ++i) - { - if (neon_failures & neon_failure_map[i][0]) - { - failures |= neon_failure_map[i][1]; - neon_failures &= ~neon_failure_map[i][0]; - } - } - - // Map any remaining neon failure bits to our OTHER bit. - if (neon_failures) - { - failures |= WEBDAV_AUTH_SSL_OTHER; - } - - return failures; -} - -// A neon-session callback to validate the SSL certificate when the CA -// is unknown (e.g. a self-signed cert), or there are other SSL -// certificate problems. -static int -server_ssl_callback( - void * userdata, - int failures, - const ne_ssl_certificate * cert) -{ - neon_session_t * ras = static_cast(userdata); - auth_cred_ssl_server_trust_t * server_creds = NULL; - void * creds = NULL; - auth_iterstate_t * state = NULL; - apr_pool_t * pool = NULL; - error_t error = 0; - char * ascii_cert = ne_ssl_cert_export(cert); - char * issuer_dname = ne_ssl_readable_dname(ne_ssl_cert_issuer(cert)); - auth_ssl_server_cert_info_t cert_info = {0}; - char fingerprint[NE_SSL_DIGESTLEN] = {0}; - char valid_from[NE_SSL_VDATELEN] = {0}, valid_until[NE_SSL_VDATELEN] = {0}; - apr_uint32_t * webdav_failures = static_cast(apr_pcalloc(ras->pool, sizeof(*webdav_failures))); - - // Construct the realmstring, e.g. https://svn.collab.net:80 - const char * realmstring = apr_pstrdup(ras->pool, Format("%s://%s:%d", ras->root.scheme, - ras->root.host, ras->root.port).c_str()); - - *webdav_failures = convert_neon_failures(failures); - auth_baton_set_parameter(ras->callbacks->auth_baton, - AUTH_PARAM_SSL_SERVER_FAILURES, - webdav_failures); - - // Extract the info from the certificate - cert_info.hostname = ne_ssl_cert_identity(cert); - if (ne_ssl_cert_digest(cert, fingerprint) != 0) - { - strcpy(fingerprint, ""); - } - cert_info.fingerprint = fingerprint; - ne_ssl_cert_validity(cert, valid_from, valid_until); - cert_info.valid_from = valid_from; - cert_info.valid_until = valid_until; - cert_info.issuer_dname = issuer_dname; - cert_info.ascii_cert = ascii_cert; - - auth_baton_set_parameter(ras->callbacks->auth_baton, - AUTH_PARAM_SSL_SERVER_CERT_INFO, - &cert_info); - - apr_pool_create(&pool, ras->pool); - error = auth_first_credentials(&creds, &state, - AUTH_CRED_SSL_SERVER_TRUST, - realmstring, - ras->callbacks->auth_baton, - pool); - if (error || !creds) - { - error_clear(&error); - } - else - { - server_creds = static_cast(creds); - error = auth_save_credentials(state, pool); - if (error) - { - // It would be nice to show the error to the user somehow... - error_clear(&error); - } - } - - free(issuer_dname); - free(ascii_cert); - auth_baton_set_parameter(ras->callbacks->auth_baton, - AUTH_PARAM_SSL_SERVER_CERT_INFO, NULL); - - webdav_pool_destroy(pool); - return !server_creds; -} - -// An `ne_request_auth' callback, see ne_auth.h. USERDATA is a struct proxy_auth_baton_t * - -// If ATTEMPT < 10, copy USERDATA->username and USERDATA->password -// into USERNAME and PASSWORD respectively (but do not copy more than -// NE_ABUFSIZ bytes of either), and return zero to indicate to Neon -// that authentication should be attempted. - -// If ATTEMPT >= 10, copy nothing into USERNAME and PASSWORD and -// return 1, to cancel further authentication attempts. - -// Ignore REALM. - -static int -proxy_auth( - void * userdata, - const char * realm, - int attempt, - char * username, - char * password) -{ - proxy_auth_baton_t * pab = static_cast(userdata); - - if (attempt >= 10) - return 1; - - // Else. - - strncpy(username, pab->username, NE_ABUFSIZ); - strncpy(password, pab->password, NE_ABUFSIZ); - - return 0; -} - -// A neon-session callback to 'pull' authentication data when -// challenged. In turn, this routine 'pulls' the data from the client -// callbacks if needed. -static int -request_auth( - void * userdata, - const char * realm, - int attempt, - char * username, - char * password) -{ - error_t err = 0; - neon_session_t * ras = static_cast(userdata); - void * creds = NULL; - auth_cred_simple_t * simple_creds = NULL; - - // Start by marking the current credentials invalid. - ras->auth_used = false; - - // No auth_baton? Give up. - if (!ras->callbacks->auth_baton) - return -1; - - // Neon automatically tries some auth protocols and bumps the attempt - // count without using our callbacks, so we can't depend - // on attempt == 0 the first time we are called -- we need to check - // if the auth state has been initted as well. - if (attempt == 0 || ras->auth_iterstate == NULL) - { - const char * realmstring = apr_psprintf(ras->pool, "<%s://%s:%d> %s", - ras->root.scheme, ras->root.host, - ras->root.port, realm); - - err = auth_first_credentials(&creds, - &(ras->auth_iterstate), - AUTH_CRED_SIMPLE, - realmstring, - ras->callbacks->auth_baton, - ras->pool); - } - else // attempt > 0 - // TODO: if the http realm changed this time around, we - // should be calling first_creds(), not next_creds(). - err = auth_next_credentials(&creds, - ras->auth_iterstate, - ras->pool); - if (err || !creds) - { - error_clear(&err); - return -1; - } - simple_creds = static_cast(creds); - - // Make neon_request_dispatch store the credentials after it - // sees a successful response - ras->auth_used = true; - - // silently truncates username/password to 256 chars. - if (simple_creds->username) strncpy(username, simple_creds->username, NE_ABUFSIZ); - if (simple_creds->password) strncpy(password, simple_creds->password, NE_ABUFSIZ); - - return 0; -} - -// a cleanup routine attached to the pool that contains the RA session baton. -static apr_status_t -cleanup_session( - void * sess) -{ - ne_session_destroy(static_cast(sess)); - return APR_SUCCESS; -} - -// a cleanup routine attached to the pool that contains the PKCS#11 -// provider object. -static apr_status_t -cleanup_p11provider( - void * provider) -{ - ne_ssl_pkcs11_provider * prov = static_cast(provider); - ne_ssl_pkcs11_provider_destroy(prov); - return APR_SUCCESS; -} - -#ifdef NETBOX_DEBUG - -typedef struct debug_file_baton_t -{ - FILE * file; -} debug_file_baton_t; - -// a cleanup routine -static apr_status_t -cleanup_neon_debug_file( - void * debug_file_baton) -{ - debug_file_baton_t * baton = static_cast(debug_file_baton); - if (baton->file) fclose(baton->file); - return APR_SUCCESS; -} -#endif - -static void -progress_func( - apr_off_t progress, - apr_off_t total, - void * baton, - apr_pool_t * pool) -{ - client_ctx_t * ctx = static_cast(baton); - TWebDAVFileSystem * fs = static_cast(apr_hash_get(ctx->auth_baton->parameters, - CONST_FS_KEY, - APR_HASH_KEY_STRING)); - assert(fs); - if (total == -1) - fs->ReadDirectoryProgress(progress); - else - fs->FileTransferProgress(total, progress); -} - -static void -ra_neon_neonprogress( - void * baton, - apr_off_t progress, - apr_off_t total) -{ - neonprogress_baton_t * pb = static_cast(baton); - neon_session_t * ras = pb->ras; - - if (ras->progress_func) - { - apr_time_t now = apr_time_now(); - if (now - pb->last_progress_time > 200000) // 0.2 sec - { - if (total < 0) - { - // Neon sends the total number of bytes sent for this specific - // session and there are two sessions active at once. - // For this case we combine the totals to allow clients to provide - // a better progress indicator. - - if (progress >= pb->last_progress) - ras->total_progress += (progress - pb->last_progress); - else - // Session total has been reset. A new stream started - ras->total_progress += pb->last_progress; - - pb->last_progress = progress; - - ras->progress_func(ras->total_progress, -1, ras->progress_baton, pb->pool); - } - else - { - // Neon provides total bytes to receive information. Pass literally - // to allow providing a percentage. - ras->progress_func(progress, total, ras->progress_baton, pb->pool); - } - pb->last_progress_time = now; - } - } -} - -static atomic_t neon_initialized = 0; - -static error_t -initialize_neon( - void * baton, - apr_pool_t * scratch_pool) -{ - if (ne_sock_init() != 0) - return error_create(WEBDAV_ERR_DAV_SOCK_INIT, NULL, - "Network socket initialization failed"); - - return WEBDAV_NO_ERROR; -} - -static error_t -ensure_neon_initialized() -{ - return atomic_init_once(&neon_initialized, initialize_neon, NULL, NULL); -} - -static const char * const * -ra_neon_get_schemes(apr_pool_t * pool) -{ - static const char * schemes_no_ssl[] = { "http", NULL }; - static const char * schemes_ssl[] = { "http", "https", NULL }; - - return ne_has_support(NE_FEATURE_SSL) ? schemes_ssl : schemes_no_ssl; -} - -static error_t -neon_open( - session_t * session, - const char ** corrected_url, - const char * session_URL, - const callbacks2_t * callbacks, - void * callback_baton, - apr_pool_t * pool) -{ - assert(callback_baton); - callback_baton_t * cb = static_cast(callback_baton); - - *corrected_url = NULL; - - ne_uri * uri = NULL; - WEBDAV_ERR(parse_ne_uri(&uri, session_URL, pool)); - - // Initialize neon if required - WEBDAV_ERR(ensure_neon_initialized()); - - int is_ssl_session = (strcmp(uri->scheme, "https") == 0); - if (is_ssl_session) - { - if (ne_has_support(NE_FEATURE_SSL) == 0) - return error_create(WEBDAV_ERR_DAV_SOCK_INIT, NULL, - "TLS is not supported"); - } - - ne_session * sess = ne_session_create(uri->scheme, uri->host, uri->port); - apr_pool_cleanup_register(pool, sess, cleanup_session, apr_pool_cleanup_null); - bool compression = FALSE; - unsigned int neon_auth_types = 0; - const char * pkcs11_provider = NULL; - const char * ssl_authority_file = NULL; - { - int proxy_method = 0; - const char * proxy_host = NULL; - unsigned int proxy_port = 0; - const char * proxy_username = NULL; - const char * proxy_password = NULL; - int timeout = 0; - int debug = 0; - const char * neon_debug_file_name = NULL; - - TWebDAVFileSystem * fs = static_cast(apr_hash_get(cb->ctx->auth_baton->parameters, - CONST_FS_KEY, - APR_HASH_KEY_STRING)); - assert(fs); - WEBDAV_ERR(fs->GetServerSettings( - &proxy_method, - &proxy_host, - &proxy_port, - &proxy_username, - &proxy_password, - &timeout, - &debug, - &neon_debug_file_name, - &compression, - &pkcs11_provider, - &ssl_authority_file, - pool)); - if (neon_auth_types == 0) - { - // If there were no auth types specified in the configuration - // file, provide the appropriate defaults. - neon_auth_types = NE_AUTH_BASIC | NE_AUTH_DIGEST; - if (is_ssl_session) - neon_auth_types |= NE_AUTH_NEGOTIATE; - } - - if (debug && neon_debug_file_name) - { -#ifdef NETBOX_DEBUG - debug_file_baton_t * baton = static_cast(apr_pcalloc(pool, sizeof(*baton))); - neon_debug_file_name = apr_pstrcat(pool, neon_debug_file_name, ".neondebug.log", NULL); - baton->file = _fsopen(neon_debug_file_name, "w", SH_DENYWR); - if (baton->file) - { - debug = NE_DBG_HTTP | - // NE_DBG_XML | NE_DBG_HTTPAUTH | - NE_DBG_HTTPPLAIN | - // NE_DBG_XMLPARSE | - NE_DBG_HTTPBODY | - // NE_DBG_SSL | - NE_DBG_FLUSH; - ne_debug_init(baton->file, debug); - } - apr_pool_cleanup_register(pool, baton, - cleanup_neon_debug_file, - apr_pool_cleanup_null); -#else - ne_debug_init(NULL, 0); -#endif // #ifdef NETBOX_DEBUG - } - - TProxyMethod method = (TProxyMethod)proxy_method; - if (method != ::pmNone) - { - if ((method == pmSocks4) || (method == pmSocks5)) - { - enum ne_sock_sversion vers = method == pmSocks4 ? NE_SOCK_SOCKSV4A : NE_SOCK_SOCKSV5; - ne_session_socks_proxy(sess, vers, proxy_host, proxy_port, proxy_username, proxy_password); - } - else if (proxy_host) - { - ne_session_proxy(sess, proxy_host, proxy_port); - - if (proxy_username) - { - proxy_auth_baton_t * pab = static_cast(apr_pcalloc(pool, sizeof(*pab))); - pab->username = proxy_username; - pab->password = proxy_password ? proxy_password : ""; - - ne_set_proxy_auth(sess, proxy_auth, pab); - } - else - { - // Enable (only) the Negotiate scheme for proxy - // authentication, if no username/password is - // configured. - ne_add_proxy_auth(sess, NE_AUTH_NEGOTIATE, NULL, NULL); - } - } - } - - if (!timeout) - timeout = DEFAULT_HTTP_TIMEOUT; - ne_set_read_timeout(sess, timeout); - - ne_set_connect_timeout(sess, timeout); - } - - { - static std::string useragent = "WinSCP"; - ne_set_useragent(sess, useragent.c_str()); - } - - // Create and fill a session_baton. - neon_session_t * ras = static_cast(apr_pcalloc(pool, sizeof(*ras))); - ras->pool = pool; - { - // canonicalize url - const char * remote_url = urlpath_canonicalize(session_URL, pool); - ras->url = stringbuf_create(remote_url, pool); - } - // copies uri pointer members, they get free'd in __close. - ras->root = *uri; - ras->ne_sess = sess; - ras->callbacks = callbacks; - ras->callback_baton = callback_baton; - ras->compression = compression; - ras->progress_baton = callbacks->progress_baton; - ras->progress_func = callbacks->progress_func; - ras->capabilities = apr_hash_make(ras->pool); - - // note that ras->username and ras->password are still NULL at this point. - // Register an authentication 'pull' callback with the neon sessions - ne_add_server_auth(sess, neon_auth_types, request_auth, ras); - - if (is_ssl_session) - { - bool trust_default_ca = false; - // PEM-encoded Certificate Authority (CA) SSL certificate - const char * authorities = ssl_authority_file; - - if (authorities != NULL && *authorities) - { - const char * file = authorities; - ne_ssl_certificate * ca_cert = NULL; - ca_cert = ne_ssl_cert_read(file); - if (ca_cert == NULL) - { - return error_createf( - WEBDAV_ERR_BAD_CONFIG_VALUE, NULL, - "Invalid config: unable to load certificate file '%s'", file); - } - ne_ssl_trust_cert(sess, ca_cert); - ne_ssl_cert_free(ca_cert); - ca_cert = NULL; - } - - // When the CA certificate or server certificate has - // verification problems, neon will call our verify function before - // outright rejection of the connection.*/ - ne_ssl_set_verify(sess, server_ssl_callback, ras); - // For client connections, we register a callback for if the server - // wants to authenticate the client via client certificate. - - if (pkcs11_provider && *pkcs11_provider) - { - ne_ssl_pkcs11_provider * provider; - int rv; - - // Initialize the PKCS#11 provider. - rv = ne_ssl_pkcs11_provider_init(&provider, pkcs11_provider); - if (rv != NE_PK11_OK) - { - return error_createf(WEBDAV_ERR_BAD_CONFIG_VALUE, NULL, - "Invalid config: unable to load PKCS#11 provider '%s'", - pkcs11_provider); - } - - // Share the provider between the two sessions. - ne_ssl_set_pkcs11_provider(sess, provider); - - ne_ssl_pkcs11_provider_pin(provider, client_ssl_pkcs11_pin_entry, ras); - - apr_pool_cleanup_register(pool, provider, cleanup_p11provider, - apr_pool_cleanup_null); - } - // Note the "else"; if a PKCS#11 provider is set up, a client - // cert callback is already configured, so don't displace it - // with the normal one here. - else - { - ne_ssl_provide_clicert(sess, client_ssl_callback, ras); - } - - // See if the user wants us to trust "default" openssl CAs. - // TODO: option "trust default CA" - trust_default_ca = true; - - if (trust_default_ca) - { - ne_ssl_trust_default_ca(sess); - } - } - - if (ras->progress_func) - { - neonprogress_baton_t * progress1 = static_cast(apr_pcalloc(pool, sizeof(*progress1))); - neonprogress_baton_t * progress2 = static_cast(apr_pcalloc(pool, sizeof(*progress2))); - - progress1->pool = pool; - progress1->ras = ras; - progress1->last_progress = 0; - - progress2->pool = pool; - progress2->ras = ras; - progress2->last_progress = 0; - - ne_set_progress(sess, ra_neon_neonprogress, progress1); - } - - session->priv = ras; - - const char * corrected = NULL; - error_t err = neon_exchange_capabilities(ras, &corrected, pool); - if (corrected) - *corrected_url = corrected; - return err; -} - -static error_t -neon_reparent( - session_t * session, - const char * url, - apr_pool_t * pool) -{ - neon_session_t * ras = static_cast(session->priv); - ne_uri * uri = NULL; - - WEBDAV_ERR(parse_ne_uri(&uri, url, session->pool)); - - ras->root = *uri; - stringbuf_set(ras->url, url); - ras->webdav_root = neon_uri_unparse(uri, session->pool); - return WEBDAV_NO_ERROR; -} - -static error_t -neon_get_session_url( - session_t * session, - const char ** url, - apr_pool_t * pool) -{ - neon_session_t * ras = static_cast(session->priv); - assert(ras); - *url = apr_pstrmemdup(pool, ras->url->data, ras->url->len); - return WEBDAV_NO_ERROR; -} - -static const ne_propname restype_props[] = -{ - { "DAV:", "resourcetype" }, - { NULL } -}; - -static error_t -neon_get_file( - session_t * session, - const char * path, - stream_t * stream, - apr_hash_t ** props, - apr_pool_t * pool) -{ - neon_session_t * ras = static_cast(session->priv); - assert(ras); - const char * url = path_url_add_component2(ras->url->data, path, pool); - const ne_propname * which_props = NULL; - - const char * final_url = url; - - if (props) - { - // Request all properties if caller requested them. - which_props = starting_props; - } - else - { - // Request only resource type on other cases. - which_props = restype_props; - } - - neon_resource_t * rsrc = NULL; - WEBDAV_ERR(neon_get_props_resource(&rsrc, ras, final_url, - which_props, - false, - pool)); - if (rsrc->is_collection) - { - return error_create(WEBDAV_ERR_FS_NOT_FILE, NULL, - "Can't get text contents of a directory"); - } - - if (stream) - { - file_write_ctx_t fwc = {0}; - fwc.stream = stream; - - // Fetch the file, shoving it at the provided stream. - WEBDAV_ERR(custom_get_request(ras, final_url, path, - get_file_reader, &fwc, - ras->callback_baton, - pool)); - } - return WEBDAV_NO_ERROR; -} - -static error_t -neon_get_dir( - session_t * session, - apr_hash_t ** dirents, - const char * path, - apr_uint32_t dirent_fields, - apr_pool_t * pool) -{ - neon_session_t * ras = static_cast(session->priv); - const char * url = path_url_add_component2(ras->url->data, path, pool); - - const char * final_url = url; - if (dirents) - { - // Just like Nautilus, Cadaver, or any other browser, we do a - // PROPFIND on the directory of depth 1. - apr_hash_t * resources = NULL; - WEBDAV_ERR(neon_get_props(&resources, ras, - final_url, NEON_DEPTH_ONE, - starting_props, - false, - pool)); - - // Count the number of path components in final_url. - apr_size_t final_url_n_components = path_component_count(final_url); - - // Now we have a hash that maps a bunch of url children to resource - // objects. Each resource object contains the properties of the - // child. Parse these resources into dirent_t structs. - *dirents = apr_hash_make(pool); - for (apr_hash_index_t * hi = apr_hash_first(pool, resources); hi; - hi = apr_hash_next(hi)) - { - const void * key = NULL; - void * val = NULL; - const char * childname = NULL; - neon_resource_t * resource = NULL; - const string_t * propval = NULL; - dirent_t * entry = NULL; - - apr_hash_this(hi, &key, NULL, &val); - childname = relpath_canonicalize(static_cast(key), pool); - resource = static_cast(val); - - // Skip the effective '.' entry that comes back from - // NEON_DEPTH_ONE. The children must have one more - // component then final_url. - // Note that we can't just strcmp the URLs because of URL encoding - // differences (i.e. %3c vs. %3C etc.) - if (path_component_count(childname) < final_url_n_components - 1) - continue; - - entry = static_cast(apr_pcalloc(pool, sizeof(*entry))); - - if (dirent_fields & WEBDAV_DIRENT_KIND) - { - // node kind - entry->kind = resource->is_collection ? node_dir : node_file; - } - - if (dirent_fields & WEBDAV_DIRENT_SIZE) - { - // size - propval = static_cast(apr_hash_get(resource->propset, - NEON_PROP_GETCONTENTLENGTH, - APR_HASH_KEY_STRING)); - if (propval == NULL) - entry->size = 0; - else - entry->size = atoui64(propval->data); - } - - if (dirent_fields & WEBDAV_DIRENT_TIME) - { - propval = static_cast(apr_hash_get(resource->propset, - NEON_PROP_CREATIONDATE, - APR_HASH_KEY_STRING)); - if (propval != NULL) - WEBDAV_ERR(time_from_cstring(&(entry->time), - propval->data, pool)); - } - - apr_hash_set(*dirents, - path_uri_decode(relpath_basename(childname, - pool), - pool), - APR_HASH_KEY_STRING, entry); - } - } - - return WEBDAV_NO_ERROR; -} - -static error_t -neon_check_path( - session_t * session, - const char * path, - node_kind_t * kind, - apr_pool_t * pool) -{ - neon_session_t * ras = static_cast(session->priv); - assert(ras); - - const char * url = ras->url->data; - error_t err = 0; - bool is_dir = FALSE; - - // If we were given a relative path to append, append it. - if (path) - url = path_url_add_component2(url, path, pool); - - if (!err) - { - neon_resource_t * rsrc; - const char * full_bc_url = url; - - // query the DAV:resourcetype of the full, assembled URL. - err = neon_get_starting_props(&rsrc, ras, full_bc_url, true, pool); - if (!err) - is_dir = rsrc->is_collection != 0; - } - - if (err == WEBDAV_NO_ERROR) - { - if (is_dir) - *kind = node_dir; - else - *kind = node_file; - } - else if (err == WEBDAV_ERR_FS_NOT_FOUND) - { - error_clear(&err); - err = WEBDAV_NO_ERROR; - *kind = node_none; - } - - return err; -} - -static error_t -neon_stat( - session_t * session, - const char * path, - dirent_t ** dirent, - apr_pool_t * pool) -{ - neon_session_t * ras = static_cast(session->priv); - assert(ras); - const char * url = ras->url->data; - - // If we were given a relative path to append, append it. - if (path) - url = path_url_add_component2(url, path, pool); - - const char * final_url = url; - - // Depth-zero PROPFIND is the One True DAV Way. - apr_hash_t * resources = NULL; - error_t err = neon_get_props(&resources, ras, final_url, - NEON_DEPTH_ZERO, - starting_props, - false, - pool); - if (err) - { - if (err == WEBDAV_ERR_FS_NOT_FOUND) - { - // easy out: - error_clear(&err); - *dirent = NULL; - return WEBDAV_NO_ERROR; - } - else - return err; - } - - // Copying parsing code from neon_get_dir() here. The hash - // of resources only contains one item, but there's no other way to - // get the item. - for (apr_hash_index_t * hi = apr_hash_first(pool, resources); hi; - hi = apr_hash_next(hi)) - { - void * val = NULL; - apr_hash_this(hi, NULL, NULL, &val); - neon_resource_t * resource = static_cast(val); - - dirent_t * entry = static_cast(apr_pcalloc(pool, sizeof(*entry))); - - entry->kind = resource->is_collection ? node_dir : node_file; - - const string_t * propval = NULL; - // entry->size is already 0 by virtue of pcalloc(). - if (entry->kind == node_file) - { - propval = static_cast(apr_hash_get(resource->propset, - NEON_PROP_GETCONTENTLENGTH, - APR_HASH_KEY_STRING)); - if (propval) - entry->size = atoui64(propval->data); - } - - propval = static_cast(apr_hash_get(resource->propset, - NEON_PROP_CREATIONDATE, - APR_HASH_KEY_STRING)); - if (propval != NULL) - WEBDAV_ERR(time_from_cstring(&(entry->time), - propval->data, pool)); - - *dirent = entry; - } - - return WEBDAV_NO_ERROR; -} - -static error_t -neon_get_webdav_resource_root( - session_t * session, - const char ** url, - apr_pool_t * pool) -{ - neon_session_t * ras = static_cast(session->priv); - assert(ras); - - *url = ras->webdav_root; - return WEBDAV_NO_ERROR; -} - -static const vtable_t neon_vtable = -{ - NULL, // get_description - ra_neon_get_schemes, // get_schemes - neon_open, // open_session - neon_reparent, // reparent - neon_get_session_url, // get_session_url - neon_get_file, // get_file - neon_get_dir, // get_dir - neon_check_path, // check_path - neon_stat, // stat - neon_get_webdav_resource_root, // get_webdav_resource_root -}; - -static error_t -neon_init( - const vtable_t ** vtable, - apr_pool_t * pool) -{ - *vtable = &neon_vtable; - - return WEBDAV_NO_ERROR; -} - -} // namespace webdav - -//--------------------------------------------------------------------------- -class TSessionData; -//--------------------------------------------------------------------------- -class TWebDAVFileListHelper -{ -public: - explicit TWebDAVFileListHelper(TWebDAVFileSystem * FileSystem, TRemoteFileList * FileList, - bool IgnoreFileList) : - FFileSystem(FileSystem), - FFileList(FFileSystem->FFileList), - FIgnoreFileList(FFileSystem->FIgnoreFileList) - { - FFileSystem->FFileList = FileList; - FFileSystem->FIgnoreFileList = IgnoreFileList; - } - - ~TWebDAVFileListHelper() - { - FFileSystem->FFileList = FFileList; - FFileSystem->FIgnoreFileList = FIgnoreFileList; - } - -private: - TWebDAVFileSystem * FFileSystem; - TRemoteFileList * FFileList; - bool FIgnoreFileList; -}; - -//--------------------------------------------------------------------------- -#undef FILE_OPERATION_LOOP_EX -#define FILE_OPERATION_LOOP_EX(ALLOW_SKIP, MESSAGE, OPERATION) \ - FILE_OPERATION_LOOP_CUSTOM(FTerminal, ALLOW_SKIP, MESSAGE, OPERATION, L"") -//--------------------------------------------------------------------------- -static const UnicodeString CONST_WEBDAV_PROTOCOL_BASE_NAME = L"WebDAV"; - -//=========================================================================== - -TWebDAVFileSystem::TWebDAVFileSystem(TTerminal * ATerminal) : - TCustomFileSystem(ATerminal), - FFileList(NULL), - FOnCaptureOutput(NULL), - FPasswordFailed(false), - FActive(false), - FFileTransferAbort(ftaNone), - FIgnoreFileList(false), - FFileTransferCancelled(false), - FFileTransferResumed(0), - FFileTransferPreserveTime(false), - FHasTrailingSlash(false), - FFileTransferCPSLimit(0), - FLastReadDirectoryProgress(0), - FCurrentOperationProgress(NULL), - FTransferStatusCriticalSection(new TCriticalSection()), - webdav_pool(NULL), - FSession(NULL) -{ - FFileSystemInfo.ProtocolBaseName = CONST_WEBDAV_PROTOCOL_BASE_NAME; - FFileSystemInfo.ProtocolName = FFileSystemInfo.ProtocolBaseName; - - if (apr_initialize() != APR_SUCCESS) - throw ExtException(UnicodeString(L"Cannot init APR"), NULL); - apr_pool_create(&webdav_pool, NULL); + const ne_uri * RedirectUri = ne_redirect_location(FNeonSession); + char * RedirectUriStr = ne_uri_unparse(RedirectUri); + UnicodeString Result = StrFromNeon(RedirectUriStr); + ne_free(RedirectUriStr); + FTerminal->LogEvent(FORMAT(L"Redirected to \"%s\".", (Result))); + return Result; } //--------------------------------------------------------------------------- -__fastcall TWebDAVFileSystem::~TWebDAVFileSystem() -{ - delete FTransferStatusCriticalSection; - FTransferStatusCriticalSection = NULL; - - webdav_pool_destroy(webdav_pool); - apr_terminate(); - webdav_pool = NULL; - ne_sock_exit(); -} -//--------------------------------------------------------------------------- -void __fastcall TWebDAVFileSystem::Open() +void TWebDAVFileSystem::ExchangeCapabilities(const char * Path, UnicodeString & CorrectedUrl) { - FCurrentDirectory = L""; - FHasTrailingSlash = false; - - TSessionData * Data = FTerminal->SessionData; - - FSessionInfo.LoginTime = Now(); - - bool Ssl = (FTerminal->SessionData->Ftps != ftpsNone); - if (Ssl) + unsigned int Capabilities = 0; + ClearNeonError(); + int NeonStatus = ne_options2(FNeonSession, Path, &Capabilities); + if (NeonStatus == NE_REDIRECT) { - FSessionInfo.SecurityProtocolName = LoadStr(FTPS_IMPLICIT); + CorrectedUrl = GetRedirectUrl(); } - - UnicodeString HostName = Data->HostNameExpanded; - size_t Port = Data->PortNumber; - UnicodeString ProtocolName = !Ssl ? L"http" : L"https"; - UnicodeString UserName = Data->UserNameExpanded; - UnicodeString Path = Data->RemoteDirectory; - UnicodeString Url = FORMAT(L"%s://%s:%d%s", (ProtocolName.c_str(), HostName.c_str(), Port, Path.c_str())); - - FPasswordFailed = false; - - FTerminal->Information(LoadStr(STATUS_CONNECT), true); - for (int I = 0; I < 5; I++) + else if (NeonStatus == NE_OK) { - FActive = false; - try + if (Capabilities > 0) { - FActive = (WEBDAV_NO_ERROR == OpenURL(Url, webdav_pool)); - if (FActive) + UnicodeString Str; + unsigned int Capability = 0x01; + while (Capabilities > 0) { - break; + if (FLAGSET(Capabilities, Capability)) + { + AddToList(Str, StrFromNeon(ne_capability_name(Capability)), L", "); + Capabilities -= Capability; + } + Capability <<= 1; } - } - catch (...) - { - if (FFileTransferCancelled) - break; - apr_sleep(200000); // 0.2 sec + FTerminal->LogEvent(FORMAT(L"Server capabilities: %s", (Str))); + FFileSystemInfo.AdditionalInfo += + LoadStr(WEBDAV_EXTENSION_INFO) + sLineBreak + + L" " + Str + sLineBreak; } } - if (!FActive) + else { - FTerminal->Closed(); - throw Exception(LoadStr(CONNECTION_FAILED)); + CheckStatus(NeonStatus); + } + + FTerminal->SaveCapabilities(FFileSystemInfo); +} +//--------------------------------------------------------------------------- +void __fastcall TWebDAVFileSystem::CloseNeonSession() +{ + if (FNeonSession != NULL) + { + ne_session_destroy(FNeonSession); + FNeonSession = NULL; } } //--------------------------------------------------------------------------- void __fastcall TWebDAVFileSystem::Close() { assert(FActive); + CloseNeonSession(); FTerminal->Closed(); FActive = false; + UnregisterFromDebug(); +} +//--------------------------------------------------------------------------- +void __fastcall TWebDAVFileSystem::RegisterForDebug() +{ + TGuard Guard(DebugSection.get()); + FileSystems.insert(this); +} +//--------------------------------------------------------------------------- +void __fastcall TWebDAVFileSystem::UnregisterFromDebug() +{ + TGuard Guard(DebugSection.get()); + FileSystems.erase(this); } //--------------------------------------------------------------------------- bool __fastcall TWebDAVFileSystem::GetActive() @@ -12255,7 +520,7 @@ const TSessionInfo & __fastcall TWebDAVFileSystem::GetSessionInfo() return FSessionInfo; } //--------------------------------------------------------------------------- -const TFileSystemInfo & __fastcall TWebDAVFileSystem::GetFileSystemInfo(bool Retrieve) +const TFileSystemInfo & __fastcall TWebDAVFileSystem::GetFileSystemInfo(bool /*Retrieve*/) { return FFileSystemInfo; } @@ -12267,7 +532,7 @@ bool __fastcall TWebDAVFileSystem::TemporaryTransferFile(const UnicodeString & / //--------------------------------------------------------------------------- bool __fastcall TWebDAVFileSystem::GetStoredCredentialsTried() { - return false; + return FStoredPasswordTried; } //--------------------------------------------------------------------------- UnicodeString __fastcall TWebDAVFileSystem::GetUserName() @@ -12277,13 +542,33 @@ UnicodeString __fastcall TWebDAVFileSystem::GetUserName() //--------------------------------------------------------------------------- void __fastcall TWebDAVFileSystem::Idle() { - // TODO: Keep session alive - return; + // noop } //--------------------------------------------------------------------------- UnicodeString __fastcall TWebDAVFileSystem::AbsolutePath(const UnicodeString Path, bool /*Local*/) { - return ::AbsolutePath(GetCurrentDirectory(), Path); + bool AddTrailingBackslash; + + if (Path == L"/") + { + // does not really matter as path "/" is still "/" when absolute, + // no slash needed + AddTrailingBackslash = FHasTrailingSlash; + } + else + { + AddTrailingBackslash = (Path[Path.Length()] == L'/'); + } + + UnicodeString Result = ::AbsolutePath(GetCurrentDirectory(), Path); + // We must preserve trailing slash, because particularly for mod_dav, + // it really matters if the slash in there or not + if (AddTrailingBackslash) + { + Result = UnixIncludeTrailingBackslash(Result); + } + + return Result; } //--------------------------------------------------------------------------- bool __fastcall TWebDAVFileSystem::IsCapable(int Capability) const @@ -12291,72 +576,44 @@ bool __fastcall TWebDAVFileSystem::IsCapable(int Capability) const assert(FTerminal); switch (Capability) { + case fcRename: + case fcRemoteMove: + case fcMoveToQueue: + case fcPreservingTimestampUpload: + case fcCheckingSpaceAvailable: + // Only to make double-click on file edit/open the file, + // instead of trying to open it as directory + case fcResolveSymlink: + return true; + case fcUserGroupListing: case fcModeChanging: case fcModeChangingUpload: - case fcPreservingTimestampUpload: case fcGroupChanging: case fcOwnerChanging: case fcAnyCommand: case fcShellAnyCommand: case fcHardLink: case fcSymbolicLink: - case fcResolveSymlink: - return false; - case fcRename: - case fcRemoteMove: - case fcRemoteCopy: - return true; - case fcTextMode: case fcNativeTextMode: case fcNewerOnlyUpload: case fcTimestampChanging: case fcLoadingAdditionalProperties: - case fcCheckingSpaceAvailable: case fcIgnorePermErrors: case fcCalculatingChecksum: - case fcSecondaryShell: // has fcShellAnyCommand - case fcGroupOwnerChangingByID: // by name + case fcSecondaryShell: + case fcGroupOwnerChangingByID: case fcRemoveCtrlZUpload: case fcRemoveBOMUpload: + case fcRemoteCopy: return false; default: - assert(false); + FAIL; return false; } } - -//--------------------------------------------------------------------------- -void __fastcall TWebDAVFileSystem::EnsureLocation() -{ - if (!FCachedDirectoryChange.IsEmpty()) - { - FTerminal->LogEvent(FORMAT(L"Locating to cached directory \"%s\".", - (FCachedDirectoryChange.c_str()))); - UnicodeString Directory = FCachedDirectoryChange; - FCachedDirectoryChange = L""; - try - { - ChangeDirectory(Directory); - } - catch (...) - { - // when location to cached directory fails, pretend again - // location in cached directory - // here used to be check (CurrentDirectory != Directory), but it is - // false always (currentdirectory is already set to cached directory), - // making the condition below useless. check removed. - if (FTerminal->GetActive()) - { - FCachedDirectoryChange = Directory; - } - throw; - } - } -} - //--------------------------------------------------------------------------- UnicodeString __fastcall TWebDAVFileSystem::GetCurrentDirectory() { @@ -12371,9 +628,84 @@ void __fastcall TWebDAVFileSystem::DoStartup() FTerminal->SetExceptionOnFail(false); } //--------------------------------------------------------------------------- +void __fastcall TWebDAVFileSystem::ClearNeonError() +{ + FCancelled = false; + ne_set_error(FNeonSession, ""); +} +//--------------------------------------------------------------------------- +UnicodeString __fastcall TWebDAVFileSystem::GetNeonError() +{ + return StrFromNeon(ne_get_error(FNeonSession)); +} +//--------------------------------------------------------------------------- +void __fastcall TWebDAVFileSystem::CheckStatus(int NeonStatus) +{ + if (NeonStatus == NE_OK) + { + // noop + } + else if ((NeonStatus == NE_ERROR) && FCancelled) + { + FCancelled = false; + Abort(); + } + else + { + UnicodeString NeonError = GetNeonError(); + UnicodeString Error; + switch (NeonStatus) + { + case NE_ERROR: + // noop + assert(!NeonError.IsEmpty()); + Error = NeonError; + NeonError = L""; + break; + + case NE_LOOKUP: + Error = ReplaceStr(LoadStr(NET_TRANSL_HOST_NOT_EXIST2), L"%HOST%", FTerminal->SessionData->HostNameExpanded); + break; + + case NE_AUTH: + Error = LoadStr(AUTHENTICATION_FAILED); + break; + + case NE_PROXYAUTH: + Error = LoadStr(PROXY_AUTHENTICATION_FAILED); + break; + + case NE_CONNECT: + Error = LoadStr(CONNECTION_FAILED); + break; + + case NE_TIMEOUT: + Error = ReplaceStr(LoadStr(NET_TRANSL_TIMEOUT2), L"%HOST%", FTerminal->SessionData->HostNameExpanded); + break; + + case NE_REDIRECT: + { + char * Uri = ne_uri_unparse(ne_redirect_location(FNeonSession)); + Error = FMTLOAD(REQUEST_REDIRECTED, (Uri)); + ne_free(Uri); + } + break; + + case NE_FAILED: // never used by neon as of 0.30.0 + case NE_RETRY: // not sure if this is a public API + default: + FAIL; + Error = FORMAT(L"Unexpected neon error %d", (NeonStatus)); + break; + } + + throw ExtException(Error, NeonError); + } +} //--------------------------------------------------------------------------- void __fastcall TWebDAVFileSystem::LookupUsersGroups() { + FAIL; } //--------------------------------------------------------------------------- void __fastcall TWebDAVFileSystem::ReadCurrentDirectory() @@ -12385,209 +717,304 @@ void __fastcall TWebDAVFileSystem::ReadCurrentDirectory() else { FCurrentDirectory = FCachedDirectoryChange; + FCachedDirectoryChange = L""; } } //--------------------------------------------------------------------------- void __fastcall TWebDAVFileSystem::HomeDirectory() { + ChangeDirectory(L"/"); } //--------------------------------------------------------------------------- -void __fastcall TWebDAVFileSystem::AnnounceFileListOperation() +UnicodeString __fastcall TWebDAVFileSystem::DirectoryPath(UnicodeString Path) { - // noop + if (FHasTrailingSlash) + { + Path = ::UnixIncludeTrailingBackslash(Path); + } + return Path; +} +//--------------------------------------------------------------------------- +void __fastcall TWebDAVFileSystem::TryOpenDirectory(UnicodeString Directory) +{ + Directory = DirectoryPath(Directory); + FTerminal->LogEvent(FORMAT(L"Trying to open directory \"%s\".", (Directory))); + TRemoteFile * File; + ReadFile(Directory, File); + delete File; } //--------------------------------------------------------------------------- -void __fastcall TWebDAVFileSystem::DoChangeDirectory(const UnicodeString Directory) +void __fastcall TWebDAVFileSystem::AnnounceFileListOperation() { + // noop } //--------------------------------------------------------------------------- void __fastcall TWebDAVFileSystem::ChangeDirectory(const UnicodeString ADirectory) { - UnicodeString Directory = ADirectory; - bool HasTrailingSlash = (Directory.Length() > 0) && (Directory[Directory.Length()] == L'/'); - try - { - // For changing directory, we do not make paths absolute, instead we - // delegate this to the server, hence we synchronize current working - // directory with the server and only then we ask for the change with - // relative path. - // But if synchronization fails, typically because current working directory - // no longer exists, we fall back to out own resolution, to give - // user chance to leave the non-existing directory. - EnsureLocation(); - } - catch (...) - { - if (FTerminal->GetActive()) - { - Directory = AbsolutePath(Directory, false); - if (HasTrailingSlash) - Directory = ::UnixIncludeTrailingBackslash(Directory); - } - else - { - throw; - } - } + UnicodeString Path = AbsolutePath(ADirectory, false); - FCurrentDirectory = AbsolutePath(Directory, false); - if (HasTrailingSlash) - FCurrentDirectory = ::UnixIncludeTrailingBackslash(FCurrentDirectory); + // to verify existence of directory try to open it (SSH_FXP_REALPATH succeeds + // for invalid paths on some systems, like CygWin) + TryOpenDirectory(Path); - // make next ReadCurrentDirectory retrieve actual server-side current directory - FCachedDirectoryChange = L""; + // if open dir did not fail, directory exists -> success. + FCachedDirectoryChange = Path; } //--------------------------------------------------------------------------- void __fastcall TWebDAVFileSystem::CachedChangeDirectory(const UnicodeString Directory) { FCachedDirectoryChange = UnixExcludeTrailingBackslash(Directory); } - -void __fastcall TWebDAVFileSystem::DoReadDirectory(TRemoteFileList * FileList) +//--------------------------------------------------------------------------- +struct TReadFileData { - FileList->Reset(); - // add parent directory - FileList->AddFile(new TRemoteParentDirectory(FTerminal)); - - FLastReadDirectoryProgress = 0; + TWebDAVFileSystem * FileSystem; + TRemoteFile * File; + TRemoteFileList * FileList; +}; +//--------------------------------------------------------------------------- +int __fastcall TWebDAVFileSystem::ReadDirectoryInternal( + const UnicodeString & Path, TRemoteFileList * FileList) +{ + TReadFileData Data; + Data.FileSystem = this; + Data.File = NULL; + Data.FileList = FileList; + ClearNeonError(); + return + ne_simple_propfind(FNeonSession, PathToNeon(Path), NE_DEPTH_ONE, NULL, + NeonPropsResult, &Data); +} +//--------------------------------------------------------------------------- +bool __fastcall TWebDAVFileSystem::IsValidRedirect(int NeonStatus, UnicodeString & Path) +{ + bool Result = (NeonStatus == NE_REDIRECT); + if (Result) + { + // What PathToNeon does + UnicodeString OriginalPath = AbsolutePath(Path, false); + // Handle one-step redirect + // (for more steps we would have to implement loop detection). + // This is mainly to handle "folder" => "folder/" redirects of Apache/mod_dav. + UnicodeString RedirectUrl = GetRedirectUrl(); + // We should test if the redirect is not for another server, + // though not sure how to do this reliably (domain aliases, IP vs. domain, etc.) + UnicodeString RedirectPath = ParsePathFromUrl(RedirectUrl); + Result = + !RedirectPath.IsEmpty() && + (RedirectPath != OriginalPath); - TWebDAVFileListHelper Helper(this, FileList, false); + if (Result) + { + Path = RedirectPath; + } + } - // always specify path to list, do not attempt to - // list "current" dir as: - // 1) List() lists again the last listed directory, not the current working directory - // 2) we handle this way the cached directory change - UnicodeString Directory = AbsolutePath(FileList->Directory, false); - if (FHasTrailingSlash) - Directory = ::UnixIncludeTrailingBackslash(Directory); - WebDAVGetList(Directory); + return Result; } //--------------------------------------------------------------------------- void __fastcall TWebDAVFileSystem::ReadDirectory(TRemoteFileList * FileList) { - assert(FileList); - bool Repeat = false; + UnicodeString Path = DirectoryPath(FileList->Directory); + TOperationVisualizer Visualizer(FTerminal->UseBusyCursor); - do + int NeonStatus = ReadDirectoryInternal(Path, FileList); + if (IsValidRedirect(NeonStatus, Path)) { - Repeat = false; - try - { - DoReadDirectory(FileList); - } - catch (Exception &) - { - if (!FTerminal->GetActive()) - { - FTerminal->Reopen(ropNoReadDirectory); - Repeat = true; - } - else - { - throw; - } - } + NeonStatus = ReadDirectoryInternal(Path, FileList); } - while (Repeat); + CheckStatus(NeonStatus); } //--------------------------------------------------------------------------- -void __fastcall TWebDAVFileSystem::ReadSymlink(TRemoteFile * SymlinkFile, - TRemoteFile *& File) +void __fastcall TWebDAVFileSystem::ReadSymlink(TRemoteFile * /*SymlinkFile*/, + TRemoteFile *& /*File*/) { - CustomReadFile(SymlinkFile->LinkTo, File, SymlinkFile); + // we never set SymLink flag, so we should never get here + FAIL; } //--------------------------------------------------------------------------- void __fastcall TWebDAVFileSystem::ReadFile(const UnicodeString FileName, - TRemoteFile *& File) + TRemoteFile *& File) { CustomReadFile(FileName, File, NULL); } //--------------------------------------------------------------------------- -void __fastcall TWebDAVFileSystem::CustomReadFile(const UnicodeString FileName, - TRemoteFile *& File, TRemoteFile * ALinkedByFile) +void TWebDAVFileSystem::NeonPropsResult( + void * UserData, const ne_uri * Uri, const ne_prop_result_set * Results) { - File = NULL; - bool isExist = false; - int is_dir = 0; - isExist = WebDAVCheckExisting(FileName.c_str(), is_dir); - if (isExist) + UTF8String UnescapedUri = PathUnescape(Uri->path).c_str(); + UnicodeString Path = StrFromNeon(UnescapedUri); + + Path = UnixExcludeTrailingBackslash(Path); + + TReadFileData & Data = *static_cast(UserData); + if (Data.FileList != NULL) + { + if (UnixSamePath(Path, Data.FileList->Directory)) + { + Path = UnixIncludeTrailingBackslash(Path) + L".."; + } + std::unique_ptr File(new TRemoteFile(NULL)); + File->Terminal = Data.FileSystem->FTerminal; + Data.FileSystem->ParsePropResultSet(File.get(), Path, Results); + Data.FileList->AddFile(File.release()); + } + else { - File = new TRemoteFile(); - if (is_dir) - File->Type = FILETYPE_DIRECTORY; + Data.FileSystem->ParsePropResultSet(Data.File, Path, Results); } } //--------------------------------------------------------------------------- -void __fastcall TWebDAVFileSystem::DeleteFile(const UnicodeString FileName, - const TRemoteFile * File, int Params, TRmSessionAction & Action) +const char * __fastcall TWebDAVFileSystem::GetProp(const ne_prop_result_set * Results, const char * Name) +{ + ne_propname Prop; + Prop.nspace = DAV_PROP_NAMESPACE; + Prop.name = Name; + return ne_propset_value(Results, &Prop); +} +//--------------------------------------------------------------------------- +void __fastcall TWebDAVFileSystem::ParsePropResultSet(TRemoteFile * File, + const UnicodeString & Path, const ne_prop_result_set * Results) { - USEDPARAM(File); - USEDPARAM(Params); - UnicodeString FullFileName = File->FullFileName; - bool res = WebDAVDeleteFile(FullFileName.c_str()); - if (!res) + File->FullFileName = Path; + File->FileName = UnixExtractFileName(File->FullFileName); + const char * ContentLength = GetProp(Results, PROP_CONTENT_LENGTH); + // some servers, for example iFiles, do not provide "getcontentlength" for folders + if (ContentLength != NULL) { - THROW_SKIP_FILE(NULL, L""); + File->Size = StrToInt64Def(ContentLength, 0); + } + const char * LastModified = GetProp(Results, PROP_LAST_MODIFIED); + if (ALWAYS_TRUE(LastModified != NULL)) + { + char WeekDay[4]; + int Year; + char MonthStr[4]; + int Day; + int Hour; + int Min; + int Sec; + #define RFC1123_FORMAT "%3s, %02d %3s %4d %02d:%02d:%02d GMT" + if (sscanf(LastModified, RFC1123_FORMAT, + WeekDay, &Day, MonthStr, &Year, &Hour, &Min, &Sec) > 0) + { + int Month = ParseShortEngMonthName(MonthStr); + TDateTime Modification = + EncodeDateVerbose((unsigned short)Year, (unsigned short)Month, (unsigned short)Day) + + EncodeTimeVerbose((unsigned short)Hour, (unsigned short)Min, (unsigned short)Sec, 0); + File->Modification = ConvertTimestampFromUTC(Modification); + File->ModificationFmt = mfFull; + } + } + bool Collection = false; + const char * ResourceType = GetProp(Results, PROP_RESOURCE_TYPE); + if (ResourceType != NULL) + { + // property has XML value + UnicodeString AResourceType = ResourceType; + // this is very poor parsing + if (ContainsText(ResourceType, L"Type = Collection ? FILETYPE_DIRECTORY : FILETYPE_DEFAULT; + // this is MS extension (draft-hopmann-collection-props-00) + const char * IsHidden = GetProp(Results, PROP_HIDDEN); + if (IsHidden != NULL) + { + File->IsHidden = (StrToIntDef(IsHidden, 0) != 0); } } //--------------------------------------------------------------------------- -void __fastcall TWebDAVFileSystem::RenameFile(const UnicodeString FileName, - const UnicodeString NewName) +int __fastcall TWebDAVFileSystem::CustomReadFileInternal(const UnicodeString FileName, + TRemoteFile *& File, TRemoteFile * ALinkedByFile) +{ + std::unique_ptr AFile(new TRemoteFile(ALinkedByFile)); + TReadFileData Data; + Data.FileSystem = this; + Data.File = AFile.get(); + Data.FileList = NULL; + ClearNeonError(); + int Result = + ne_simple_propfind(FNeonSession, PathToNeon(FileName), NE_DEPTH_ZERO, NULL, + NeonPropsResult, &Data); + if (Result == NE_OK) + { + File = AFile.release(); + } + return Result; +} +//--------------------------------------------------------------------------- +void __fastcall TWebDAVFileSystem::CustomReadFile(UnicodeString FileName, + TRemoteFile *& File, TRemoteFile * ALinkedByFile) +{ + TOperationVisualizer Visualizer(FTerminal->UseBusyCursor); + + int NeonStatus = CustomReadFileInternal(FileName, File, ALinkedByFile); + if (IsValidRedirect(NeonStatus, FileName)) + { + NeonStatus = CustomReadFileInternal(FileName, File, ALinkedByFile); + } + CheckStatus(NeonStatus); +} +//--------------------------------------------------------------------------- +void __fastcall TWebDAVFileSystem::DeleteFile(const UnicodeString FileName, + const TRemoteFile * File, int /*Params*/, TRmSessionAction & Action) { - UnicodeString FullFileName = ::UnixIncludeTrailingBackslash(FCurrentDirectory) + FileName; - bool res = WebDAVRenameFile(FullFileName.c_str(), NewName.c_str()); - if (!res) + Action.Recursive(); + ClearNeonError(); + TOperationVisualizer Visualizer(FTerminal->UseBusyCursor); + UnicodeString Path = File->FullFileName; + if (File->IsDirectory) { - THROW_SKIP_FILE(NULL, L""); + Path = DirectoryPath(Path); } + // WebDAV does not allow non-recursive delete: + // RFC 4918, section 9.6.1: + // "A client MUST NOT submit a Depth header with a DELETE on a collection with any value but infinity." + // We should check that folder is empty when called with FLAGSET(Params, dfNoRecursive) + CheckStatus(ne_delete(FNeonSession, PathToNeon(Path))); +} +//--------------------------------------------------------------------------- +void __fastcall TWebDAVFileSystem::RenameFile(const UnicodeString FileName, + const UnicodeString NewName) +{ + ClearNeonError(); + TOperationVisualizer Visualizer(FTerminal->UseBusyCursor); + // 0 = no overwrite + CheckStatus(ne_move(FNeonSession, 0, PathToNeon(FileName), PathToNeon(NewName))); } //--------------------------------------------------------------------------- void __fastcall TWebDAVFileSystem::CopyFile(const UnicodeString FileName, const UnicodeString NewName) { + FAIL; } //--------------------------------------------------------------------------- void __fastcall TWebDAVFileSystem::CreateDirectory(const UnicodeString DirName) { - UnicodeString FullDirName = AbsolutePath(DirName, true); - bool res = WebDAVMakeDirectory(FullDirName.c_str()); - if (!res) - { - TStringList * Strings = new TStringList(); - Strings->Delimiter = L'/'; - Strings->DelimitedText = DirName; - UnicodeString CurDir; - for (int i = 0; i < Strings->Count; i++) - { - if (Strings->Strings[i].IsEmpty()) - { - continue; - } - CurDir += L"/" + Strings->Strings[i]; - res = WebDAVMakeDirectory(CurDir.c_str()); - } - if (!res) - { - THROW_SKIP_FILE(NULL, L""); - } - } + ClearNeonError(); + TOperationVisualizer Visualizer(FTerminal->UseBusyCursor); + CheckStatus(ne_mkcol(FNeonSession, PathToNeon(DirName))); } //--------------------------------------------------------------------------- void __fastcall TWebDAVFileSystem::CreateLink(const UnicodeString FileName, - const UnicodeString PointTo, bool Symbolic) + const UnicodeString PointTo, bool /*Symbolic*/) { + FAIL; } //--------------------------------------------------------------------------- void __fastcall TWebDAVFileSystem::ChangeFileProperties(const UnicodeString FileName, - const TRemoteFile * File, const TRemoteProperties * Properties, - TChmodSessionAction & Action) + const TRemoteFile * /*File*/, const TRemoteProperties * /*Properties*/, + TChmodSessionAction & /*Action*/) { - assert(Properties); + FAIL; } //--------------------------------------------------------------------------- bool __fastcall TWebDAVFileSystem::LoadFilesProperties(TStrings * /*FileList*/) { - assert(false); + FAIL; return false; } //--------------------------------------------------------------------------- @@ -12595,165 +1022,151 @@ void __fastcall TWebDAVFileSystem::CalculateFilesChecksum(const UnicodeString & TStrings * /*FileList*/, TStrings * /*Checksums*/, TCalculatedChecksumEvent /*OnCalculatedChecksum*/) { - assert(false); + FAIL; } //--------------------------------------------------------------------------- -bool __fastcall TWebDAVFileSystem::ConfirmOverwrite(UnicodeString & FileName, - TOverwriteMode & OverwriteMode, TFileOperationProgressType * OperationProgress, - const TOverwriteFileParams * FileParams, const TCopyParamType * CopyParam, - int Params, bool AutoResume, unsigned int &Answer) +void __fastcall TWebDAVFileSystem::ConfirmOverwrite( + const UnicodeString & FullFileName, UnicodeString & /*FileName*/, + TFileOperationProgressType * OperationProgress, + const TOverwriteFileParams * FileParams, const TCopyParamType * CopyParam, + int Params) { - bool Result; - bool CanAutoResume = FLAGSET(Params, cpNoConfirmation) && AutoResume; - bool CanResume = false; // disable resume + // all = "yes to newer" + int Answers = qaYes | qaNo | qaCancel | qaYesToAll | qaNoToAll | qaAll; + TQueryButtonAlias Aliases[3]; + Aliases[0].Button = qaAll; + Aliases[0].Alias = LoadStr(YES_TO_NEWER_BUTTON); + Aliases[0].GroupWith = qaYes; + Aliases[0].GrouppedShiftState = TShiftState() << ssCtrl; + Aliases[1].Button = qaYesToAll; + Aliases[1].GroupWith = qaYes; + Aliases[1].GrouppedShiftState = TShiftState() << ssShift; + Aliases[2].Button = qaNoToAll; + Aliases[2].GroupWith = qaNo; + Aliases[2].GrouppedShiftState = TShiftState() << ssShift; + TQueryParams QueryParams(qpNeverAskAgainCheck); + QueryParams.Aliases = Aliases; + QueryParams.AliasesCount = LENOF(Aliases); + + unsigned int Answer; - Answer = 0; - if (CanAutoResume && CanResume) - { - Answer = qaRetry; - } - else { - // retry = "resume" - // all = "yes to newer" - // ignore = "rename" - int Answers = qaYes | qaNo | qaCancel | qaYesToAll | qaNoToAll | qaAll | qaIgnore; - if (CanResume) - { - Answers |= qaRetry; - } - TQueryButtonAlias Aliases[3]; - Aliases[0].Button = qaRetry; - Aliases[0].Alias = LoadStr(RESUME_BUTTON); - Aliases[1].Button = qaAll; - Aliases[1].Alias = LoadStr(YES_TO_NEWER_BUTTON); - Aliases[2].Button = qaIgnore; - Aliases[2].Alias = LoadStr(RENAME_BUTTON); - TQueryParams QueryParams(qpNeverAskAgainCheck); - QueryParams.Aliases = Aliases; - QueryParams.AliasesCount = LENOF(Aliases); - SUSPEND_OPERATION ( - Answer = FTerminal->ConfirmFileOverwrite(FileName, FileParams, - Answers, &QueryParams, - OperationProgress->Side == osLocal ? osRemote : osLocal, - CopyParam, Params, OperationProgress); - ) + TSuspendFileOperationProgress Suspend(OperationProgress); + Answer = + FTerminal->ConfirmFileOverwrite( + FullFileName, FileParams, Answers, &QueryParams, + (OperationProgress->Side == osLocal) ? osRemote : osLocal, + CopyParam, Params, OperationProgress); } - Result = true; - switch (Answer) { - // resume - case qaRetry: - OverwriteMode = omResume; - assert(FileParams != NULL); - assert(CanResume); - FFileTransferResumed = FileParams->DestSize; - break; - - // rename - case qaIgnore: - if (FTerminal->PromptUser(FTerminal->SessionData, pkFileName, - LoadStr(RENAME_TITLE), L"", LoadStr(RENAME_PROMPT2), true, 0, FileName)) - { - OverwriteMode = omOverwrite; - } - else - { - if (!OperationProgress->Cancel) - { - OperationProgress->Cancel = csCancel; - } - FFileTransferAbort = ftaCancel; - Result = false; - } - break; - case qaYes: - OverwriteMode = omOverwrite; + // noop break; case qaNo: - FFileTransferAbort = ftaSkip; - Result = false; - break; + THROW_SKIP_FILE_NULL; + default: + FAIL; case qaCancel: if (!OperationProgress->Cancel) { OperationProgress->Cancel = csCancel; } - FFileTransferAbort = ftaCancel; - Result = false; - break; - - default: - assert(false); - Result = false; + Abort(); break; } - return Result; } - //--------------------------------------------------------------------------- void __fastcall TWebDAVFileSystem::CustomCommandOnFile(const UnicodeString FileName, - const TRemoteFile * File, UnicodeString Command, int Params, TCaptureOutputEvent OutputEvent) + const TRemoteFile * /*File*/, UnicodeString Command, int /*Params*/, TCaptureOutputEvent /*OutputEvent*/) { - assert(File); - bool Dir = File->IsDirectory && !File->IsSymLink; - if (Dir && (Params & ccRecursive)) - { - TCustomCommandParams AParams; - AParams.Command = Command; - AParams.Params = Params; - AParams.OutputEvent = OutputEvent; - FTerminal->ProcessDirectory(FileName, FTerminal->CustomCommandOnFile, &AParams); - } - - if (!Dir || (Params & ccApplyToDirectories)) - { - TCustomCommandData Data(FTerminal); - UnicodeString Cmd = TRemoteCustomCommand( - Data, FTerminal->GetCurrentDirectory(), FileName, L""). - Complete(Command, true); - } + FAIL; } //--------------------------------------------------------------------------- void __fastcall TWebDAVFileSystem::AnyCommand(const UnicodeString Command, - TCaptureOutputEvent OutputEvent) + TCaptureOutputEvent /*OutputEvent*/) { + FAIL; } - //--------------------------------------------------------------------------- -UnicodeString __fastcall TWebDAVFileSystem::FileUrl(const UnicodeString FileName) +TStrings * __fastcall TWebDAVFileSystem::GetFixedPaths() { - return FTerminal->FileUrl(FTerminal->SessionData->Ftps == ftpsNone ? - L"http" : L"https", FileName); + return NULL; } //--------------------------------------------------------------------------- -TStrings * __fastcall TWebDAVFileSystem::GetFixedPaths() +void TWebDAVFileSystem::NeonQuotaResult( + void * UserData, const ne_uri * /*Uri*/, const ne_prop_result_set * Results) { - return NULL; + TSpaceAvailable & SpaceAvailable = *static_cast(UserData); + + const char * Value = GetProp(Results, PROP_QUOTA_AVAILABLE); + if (Value != NULL) + { + SpaceAvailable.UnusedBytesAvailableToUser = StrToInt64(StrFromNeon(Value)); + + const char * Value = GetProp(Results, PROP_QUOTA_USED); + if (Value != NULL) + { + SpaceAvailable.BytesAvailableToUser = + StrToInt64(StrFromNeon(Value)) + SpaceAvailable.UnusedBytesAvailableToUser; + } + } } //--------------------------------------------------------------------------- void __fastcall TWebDAVFileSystem::SpaceAvailable(const UnicodeString Path, - TSpaceAvailable & /*ASpaceAvailable*/) + TSpaceAvailable & ASpaceAvailable) { - assert(false); + // RFC4331: http://tools.ietf.org/html/rfc4331 + + // This is known to be supported by: + + // OpenDrive: for a root drive only (and contrary to the spec, it sends the properties + // unconditionally, even when not explicitly requested) + // Server: Apache/2.2.17 (Fedora) + // X-Powered-By: PHP/5.5.7 + // X-DAV-Powered-By: OpenDrive + // WWW-Authenticate: Basic realm="PHP WebDAV" + + // IT Hit WebDAV Server: + // Server: Microsoft-HTTPAPI/1.0 + // X-Engine: IT Hit WebDAV Server .Net v3.8.1877.0 (Evaluation License) + + // Yandex disk: + // WWW-Authenticate: Basic realm="Yandex.Disk" + // Server: MochiWeb/1.0 + + UnicodeString APath = DirectoryPath(Path); + + ne_propname QuotaProps[3]; + memset(QuotaProps, 0, sizeof(QuotaProps)); + QuotaProps[0].nspace = DAV_PROP_NAMESPACE; + QuotaProps[0].name = PROP_QUOTA_AVAILABLE; + QuotaProps[1].nspace = DAV_PROP_NAMESPACE; + QuotaProps[1].name = PROP_QUOTA_USED; + QuotaProps[2].nspace = NULL; + QuotaProps[2].name = NULL; + + TOperationVisualizer Visualizer(FTerminal->UseBusyCursor); + + CheckStatus( + ne_simple_propfind(FNeonSession, PathToNeon(APath), NE_DEPTH_ZERO, QuotaProps, + NeonQuotaResult, &ASpaceAvailable)); } //--------------------------------------------------------------------------- void __fastcall TWebDAVFileSystem::CopyToRemote(TStrings * FilesToCopy, - const UnicodeString ATargetDir, const TCopyParamType * CopyParam, - int Params, TFileOperationProgressType * OperationProgress, - TOnceDoneOperation & OnceDoneOperation) + const UnicodeString ATargetDir, const TCopyParamType * CopyParam, + int Params, TFileOperationProgressType * OperationProgress, + TOnceDoneOperation & OnceDoneOperation) { assert((FilesToCopy != NULL) && (OperationProgress != NULL)); Params &= ~cpAppend; UnicodeString FileName, FileNameOnly; UnicodeString TargetDir = AbsolutePath(ATargetDir, false); - UnicodeString FullTargetDir = ::UnixIncludeTrailingBackslash(TargetDir); + UnicodeString FullTargetDir = UnixIncludeTrailingBackslash(TargetDir); intptr_t Index = 0; while ((Index < FilesToCopy->Count) && !OperationProgress->Cancel) { @@ -12769,23 +1182,22 @@ void __fastcall TWebDAVFileSystem::CopyToRemote(TStrings * FilesToCopy, { FTerminal->DirectoryModified(TargetDir, false); - if (::DirectoryExists(::ExtractFilePath(FileName))) + if (::DirectoryExists(ApiPath(::ExtractFilePath(FileName)))) { FTerminal->DirectoryModified(FullTargetDir + FileNameOnly, true); } } - WebDAVSourceRobust(FileName, FullTargetDir, CopyParam, Params, OperationProgress, + SourceRobust(FileName, FullTargetDir, CopyParam, Params, OperationProgress, tfFirstLevel); Success = true; } catch (EScpSkipFile & E) { - SUSPEND_OPERATION ( - if (!FTerminal->HandleException(&E)) - { - throw; - } - ); + TSuspendFileOperationProgress Suspend(OperationProgress); + if (!FTerminal->HandleException(&E)) + { + throw; + } } } __finally @@ -12795,31 +1207,35 @@ void __fastcall TWebDAVFileSystem::CopyToRemote(TStrings * FilesToCopy, Index++; } } - //--------------------------------------------------------------------------- -void __fastcall TWebDAVFileSystem::WebDAVSourceRobust(const UnicodeString FileName, +void __fastcall TWebDAVFileSystem::SourceRobust(const UnicodeString FileName, const UnicodeString TargetDir, const TCopyParamType * CopyParam, int Params, TFileOperationProgressType * OperationProgress, unsigned int Flags) { - bool Retry = false; + // the same in TSFTPFileSystem + bool Retry; TUploadSessionAction Action(FTerminal->ActionLog); do { Retry = false; + bool ChildError = false; try { - WebDAVSource(FileName, TargetDir, CopyParam, Params, OperationProgress, - Flags, Action); + Source(FileName, TargetDir, CopyParam, Params, OperationProgress, + Flags, Action, ChildError); } catch (Exception & E) { Retry = true; - if (FTerminal->GetActive() || + if (FTerminal->Active || !FTerminal->QueryReopen(&E, ropNoReadDirectory, OperationProgress)) { - FTerminal->RollbackAction(Action, OperationProgress, &E); + if (!ChildError) + { + FTerminal->RollbackAction(Action, OperationProgress, &E); + } throw; } } @@ -12831,133 +1247,52 @@ void __fastcall TWebDAVFileSystem::WebDAVSourceRobust(const UnicodeString FileNa // prevent overwrite confirmations // (should not be set for directories!) Params |= cpNoConfirmation; - Flags |= tfAutoResume; } } while (Retry); } //--------------------------------------------------------------------------- -void __fastcall TWebDAVFileSystem::WebDAVSource(const UnicodeString FileName, +void __fastcall TWebDAVFileSystem::Source(const UnicodeString FileName, const UnicodeString TargetDir, const TCopyParamType * CopyParam, int Params, TFileOperationProgressType * OperationProgress, unsigned int Flags, - TUploadSessionAction & Action) + TUploadSessionAction & Action, bool & ChildError) { - bool CheckExistence = UnixComparePaths(TargetDir, FTerminal->GetCurrentDirectory()) && - (FTerminal->FFiles != NULL) && FTerminal->FFiles->Loaded; - bool CanProceed = false; - UnicodeString FileNameOnly = - CopyParam->ChangeFileName(ExtractFileName(FileName, false), osLocal, true); - if (CheckExistence) - { - TRemoteFile * File = FTerminal->FFiles->FindFile(FileNameOnly); - if (File != NULL) - { - unsigned int Answer = 0; - if (File->IsDirectory) - { - UnicodeString Message = FMTLOAD(DIRECTORY_OVERWRITE, (FileNameOnly.c_str())); - TQueryParams QueryParams(qpNeverAskAgainCheck); - SUSPEND_OPERATION ( - Answer = FTerminal->ConfirmFileOverwrite( - FileNameOnly /*not used*/, NULL, - qaYes | qaNo | qaCancel | qaYesToAll | qaNoToAll, - &QueryParams, osRemote, CopyParam, Params, OperationProgress, Message); - ); - switch (Answer) - { - case qaYes: - CanProceed = true; - break; - - case qaCancel: - OperationProgress->Cancel = csCancel; // continue on next case - // FALLTHROUGH - case qaNo: - CanProceed = false; - break; - - default: - break; - } - } - else - { - __int64 Size; - __int64 MTime; - TOverwriteFileParams FileParams; - FTerminal->OpenLocalFile(FileName, GENERIC_READ, - NULL, NULL, NULL, &MTime, NULL, - &Size); - FileParams.SourceSize = Size; - FileParams.SourceTimestamp = UnixToDateTime(MTime, - FTerminal->SessionData->DSTMode); - FileParams.DestSize = File->Size; - FileParams.DestTimestamp = File->Modification; - - TOverwriteMode OverwriteMode = omOverwrite; - bool AutoResume = false; - ConfirmOverwrite(FileNameOnly, OverwriteMode, OperationProgress, - &FileParams, CopyParam, Params, AutoResume, Answer); - switch (Answer) - { - case qaYes: - CanProceed = true; - break; - - case qaCancel: - OperationProgress->Cancel = csCancel; // continue on next case - // FALLTHROUGH - case qaNo: - CanProceed = false; - break; - - default: - break; - } - } - } - else - { - CanProceed = true; - } - } - else + Action.FileName(ExpandUNCFileName(FileName)); + + OperationProgress->SetFile(FileName, false); + + if (!FTerminal->AllowLocalFileTransfer(FileName, CopyParam, OperationProgress)) { - CanProceed = true; + THROW_SKIP_FILE_NULL; } - if (CanProceed) - { - Action.FileName(ExpandUNCFileName(FileName)); - - OperationProgress->SetFile(FileName, false); - if (!FTerminal->AllowLocalFileTransfer(FileName, CopyParam)) - { - FTerminal->LogEvent(FORMAT(L"File \"%s\" excluded from transfer", (FileName.c_str()))); - THROW_SKIP_FILE_NULL; - } + HANDLE File; + __int64 MTime; + __int64 Size; + int Attrs; - __int64 Size; - int Attrs; + FTerminal->OpenLocalFile(FileName, GENERIC_READ, &Attrs, + &File, NULL, &MTime, NULL, &Size); - FTerminal->OpenLocalFile(FileName, GENERIC_READ, &Attrs, - NULL, NULL, NULL, NULL, &Size); + bool Dir = FLAGSET(Attrs, faDirectory); + int FD = -1; + try + { OperationProgress->SetFileInProgress(); - bool Dir = FLAGSET(Attrs, faDirectory); if (Dir) { Action.Cancel(); - WebDAVDirectorySource(IncludeTrailingBackslash(FileName), TargetDir, + DirectorySource(IncludeTrailingBackslash(FileName), TargetDir, Attrs, CopyParam, Params, OperationProgress, Flags); } else { - UnicodeString DestFileName = CopyParam->ChangeFileName(ExtractFileName(FileName, false), + UnicodeString DestFileName = CopyParam->ChangeFileName(ExtractFileName(FileName), osLocal, FLAGSET(Flags, tfFirstLevel)); - FTerminal->LogEvent(FORMAT(L"Copying \"%s\" to remote directory started.", (FileName.c_str()))); + FTerminal->LogEvent(FORMAT(L"Copying \"%s\" to remote directory started.", (FileName))); OperationProgress->SetLocalSize(Size); @@ -12966,177 +1301,222 @@ void __fastcall TWebDAVFileSystem::WebDAVSource(const UnicodeString FileName, OperationProgress->SetTransferSize(OperationProgress->LocalSize); OperationProgress->TransferingFile = false; - // Will we use ASCII of BINARY file transfer? - TFileMasks::TParams MaskParams; - MaskParams.Size = Size; + UnicodeString DestFullName = TargetDir + DestFileName; + + TRemoteFile * RemoteFile = NULL; + try + { + TValueRestorer IgnoreAuthenticationFailureRestorer(FIgnoreAuthenticationFailure); + FIgnoreAuthenticationFailure = iafWaiting; - ResetFileTransfer(); + // this should not throw + CustomReadFileInternal(DestFullName, RemoteFile, NULL); + } + catch (...) + { + if (!FTerminal->Active) + { + throw; + } + } - TFileTransferData UserData; + TDateTime Modification = UnixToDateTime(MTime, FTerminal->SessionData->DSTMode); + if (RemoteFile != NULL) { - unsigned int TransferType = 2; - // ignore file list - TWebDAVFileListHelper Helper(this, NULL, true); - - FFileTransferCPSLimit = OperationProgress->CPSLimit; - // not used for uploads anyway - FFileTransferPreserveTime = CopyParam->PreserveTime; - // not used for uploads, but we get new name (if any) back in this field - UserData.FileName = DestFileName; - UserData.Params = Params; - UserData.AutoResume = FLAGSET(Flags, tfAutoResume); - UserData.CopyParam = CopyParam; - FileTransfer(FileName, FileName, DestFileName, - TargetDir, false, Size, TransferType, UserData, OperationProgress); + TOverwriteFileParams FileParams; + + FileParams.SourceSize = Size; + FileParams.SourceTimestamp = Modification; + FileParams.DestSize = RemoteFile->Size; + FileParams.DestTimestamp = RemoteFile->Modification; + delete RemoteFile; + + ConfirmOverwrite(FileName, DestFullName, OperationProgress, + &FileParams, CopyParam, Params); } - UnicodeString DestFullName = TargetDir + UserData.FileName; + DestFullName = TargetDir + DestFileName; // only now, we know the final destination + // (not really true as we do not support changing file name on overwrite dialog) Action.Destination(DestFullName); + + FILE_OPERATION_LOOP_BEGIN + { + SetFilePointer(File, 0, NULL, FILE_BEGIN); + + FD = _open_osfhandle((intptr_t)File, O_BINARY); + if (FD < 0) + { + THROW_SKIP_FILE_NULL; + } + + { + TValueRestorer TransferringRestorer(FUploading); + FUploading = true; + + ClearNeonError(); + CheckStatus(ne_put(FNeonSession, PathToNeon(DestFullName), FD)); + } + } + FILE_OPERATION_LOOP_END(FMTLOAD(TRANSFER_ERROR, (FileName))); + + if (CopyParam->PreserveTime) + { + FTerminal->LogEvent(FORMAT(L"Preserving timestamp [%s]", + (StandardTimestamp(Modification)))); + + TTouchSessionAction TouchAction(FTerminal->ActionLog, DestFullName, Modification); + try + { + TDateTime ModificationUTC = ConvertTimestampToUTC(Modification); + TFormatSettings FormatSettings = GetEngFormatSettings(); + UnicodeString LastModified = + FormatDateTime(L"ddd, d mmm yyyy hh:nn:ss 'GMT'", ModificationUTC, FormatSettings); + UTF8String NeonLastModified(LastModified); + // second element is "NULL-terminating" + ne_proppatch_operation Operations[2]; + memset(Operations, 0, sizeof(Operations)); + ne_propname LastModifiedProp; + LastModifiedProp.nspace = DAV_PROP_NAMESPACE; + LastModifiedProp.name = PROP_LAST_MODIFIED; + Operations[0].name = &LastModifiedProp; + Operations[0].type = ne_propset; + Operations[0].value = NeonLastModified.c_str(); + int Status = ne_proppatch(FNeonSession, PathToNeon(DestFullName), Operations); + if (Status == NE_ERROR) + { + FTerminal->LogEvent(FORMAT(L"Preserving timestamp failed, ignoring: %s", + (GetNeonError()))); + // Ignore errors as major WebDAV servers (like IIS), do not support + // changing getlastmodified. + // The only server we found that supports this is TradeMicro SafeSync. + // But it announces itself as "Server: Apache", + // so it's not reliably autodetect the support. + TouchAction.Cancel(); + } + else + { + CheckStatus(Status); + } + } + catch (Exception & E) + { + TouchAction.Rollback(&E); + ChildError = true; + throw; + } + } } + } + __finally + { + FUploadBodyProvider = NULL; - // TODO : Delete also read-only files. - if (FLAGSET(Params, cpDelete)) + if (FD >= 0) + { + // _close calls CloseHandle internally (even doc states, we should not call CloseHandle), + // but it crashes code guard + _close(FD); + } + else if (File != NULL) + { + CloseHandle(File); + } + } + + // TODO : Delete also read-only files. + if (FLAGSET(Params, cpDelete)) + { + if (!Dir) { - if (!Dir) + FILE_OPERATION_LOOP_BEGIN { - FILE_OPERATION_LOOP (FMTLOAD(DELETE_LOCAL_FILE_ERROR, (FileName.c_str())), - THROWOSIFFALSE(::DeleteFile(FileName.c_str())); - ) + THROWOSIFFALSE(::DeleteFile(ApiPath(FileName).c_str())); } + FILE_OPERATION_LOOP_END(FMTLOAD(DELETE_LOCAL_FILE_ERROR, (FileName))); } - else if (CopyParam->ClearArchive && FLAGSET(Attrs, faArchive)) + } + else if (CopyParam->ClearArchive && FLAGSET(Attrs, faArchive)) + { + FILE_OPERATION_LOOP_BEGIN { - FILE_OPERATION_LOOP (FMTLOAD(CANT_SET_ATTRS, (FileName.c_str())), - THROWOSIFFALSE(FileSetAttr(FileName, Attrs & ~faArchive) == 0); - ) + THROWOSIFFALSE(FileSetAttr(ApiPath(FileName), Attrs & ~faArchive) == 0); } + FILE_OPERATION_LOOP_END(FMTLOAD(CANT_SET_ATTRS, (FileName))); } } //--------------------------------------------------------------------------- -void __fastcall TWebDAVFileSystem::WebDAVDirectorySource(const UnicodeString DirectoryName, - const UnicodeString TargetDir, int Attrs, const TCopyParamType * CopyParam, - int Params, TFileOperationProgressType * OperationProgress, unsigned int Flags) +void __fastcall TWebDAVFileSystem::DirectorySource(const UnicodeString DirectoryName, + const UnicodeString TargetDir, int Attrs, const TCopyParamType * CopyParam, + int Params, TFileOperationProgressType * OperationProgress, unsigned int Flags) { UnicodeString DestDirectoryName = CopyParam->ChangeFileName( - ExtractFileName(ExcludeTrailingBackslash(DirectoryName), false), osLocal, + ExtractFileName(ExcludeTrailingBackslash(DirectoryName)), osLocal, FLAGSET(Flags, tfFirstLevel)); UnicodeString DestFullName = UnixIncludeTrailingBackslash(TargetDir + DestDirectoryName); // create DestFullName if it does not exist - int IsDir = 0; - bool Exists = WebDAVCheckExisting(DestFullName.c_str(), IsDir); - if (!Exists) + if (!FTerminal->FileExists(DestFullName)) { - CreateDirectory(DestFullName); + TRemoteProperties Properties; + if (CopyParam->PreserveRights) + { + Properties.Valid = TValidProperties() << vpRights; + Properties.Rights = CopyParam->RemoteFileRights(Attrs); + } + FTerminal->CreateDirectory(DestFullName, &Properties); } OperationProgress->SetFile(DirectoryName); - WIN32_FIND_DATA SearchRec; - bool FindOK = false; - HANDLE findHandle = 0; - - UnicodeString FindPath = DirectoryName + L"*.*"; - - FILE_OPERATION_LOOP (FMTLOAD(LIST_DIR_ERROR, (DirectoryName.c_str())), - findHandle = FindFirstFile(FindPath.c_str(), &SearchRec); - FindOK = (findHandle != 0); - if (!FindOK) - { - FindCheck(GetLastError(), FindPath); - } - ); + int FindAttrs = faReadOnly | faHidden | faSysFile | faDirectory | faArchive; + TSearchRecChecked SearchRec; + bool FindOK; - bool CreateDir = true; + FILE_OPERATION_LOOP_BEGIN + { + FindOK = + (FindFirstChecked(DirectoryName + L"*.*", FindAttrs, SearchRec) == 0); + } + FILE_OPERATION_LOOP_END(FMTLOAD(LIST_DIR_ERROR, (DirectoryName))); try { while (FindOK && !OperationProgress->Cancel) { - UnicodeString FileName = DirectoryName + SearchRec.cFileName; + UnicodeString FileName = DirectoryName + SearchRec.Name; try { - if ((wcscmp(SearchRec.cFileName, THISDIRECTORY) != 0) && (wcscmp(SearchRec.cFileName, PARENTDIRECTORY) != 0)) + if ((SearchRec.Name != L".") && (SearchRec.Name != L"..")) { - WebDAVSourceRobust(FileName, DestFullName, CopyParam, Params, OperationProgress, - Flags & ~(tfFirstLevel | tfAutoResume)); - // if any file got uploaded (i.e. there were any file in the - // directory and at least one was not skipped), - // do not try to create the directory, - // as it should be already created by FZAPI during upload - CreateDir = false; + SourceRobust(FileName, DestFullName, CopyParam, Params, OperationProgress, + Flags & ~(tfFirstLevel)); } } catch (EScpSkipFile & E) { // If ESkipFile occurs, just log it and continue with next file - SUSPEND_OPERATION ( - // here a message to user was displayed, which was not appropriate - // when user refused to overwrite the file in subdirectory. - // hopefully it won't be missing in other situations. - if (!FTerminal->HandleException(&E)) - { - throw; - } - ); - } - - FILE_OPERATION_LOOP (FMTLOAD(LIST_DIR_ERROR, (DirectoryName.c_str())), - FindOK = (::FindNextFile(findHandle, &SearchRec) != 0); - if (!FindOK) + TSuspendFileOperationProgress Suspend(OperationProgress); + // here a message to user was displayed, which was not appropriate + // when user refused to overwrite the file in subdirectory. + // hopefully it won't be missing in other situations. + if (!FTerminal->HandleException(&E)) { - FindCheck(GetLastError(), FindPath); + throw; } - ); - } - } - __finally - { - ::FindClose(findHandle); - } - - if (CreateDir) - { - TRemoteProperties Properties; - if (CopyParam->PreserveRights) - { - Properties.Valid = TValidProperties() << vpRights; - Properties.Rights = CopyParam->RemoteFileRights(Attrs); - } - - try - { - FTerminal->SetExceptionOnFail(true); - try - { - FTerminal->CreateDirectory(DestFullName, &Properties); - } - __finally - { - FTerminal->SetExceptionOnFail(false); - } - } - catch (...) - { - TRemoteFile * File = NULL; - // ignore non-fatal error when the directory already exists - UnicodeString fn = UnixExcludeTrailingBackslash(DestFullName); - if (fn.IsEmpty()) - { - fn = L"/"; } - bool Rethrow = - !FTerminal->GetActive() || - !FTerminal->FileExists(fn, &File) || - (File && !File->IsDirectory); - delete File; - if (Rethrow) + + FILE_OPERATION_LOOP_BEGIN { - throw; + FindOK = (FindNextChecked(SearchRec) == 0); } + FILE_OPERATION_LOOP_END(FMTLOAD(LIST_DIR_ERROR, (DirectoryName))); } } + __finally + { + FindClose(SearchRec); + } // TODO : Delete also read-only directories. // TODO : Show error message on failure. @@ -13144,22 +1524,23 @@ void __fastcall TWebDAVFileSystem::WebDAVDirectorySource(const UnicodeString Dir { if (FLAGSET(Params, cpDelete)) { - RemoveDir(DirectoryName); + RemoveDir(ApiPath(DirectoryName)); } else if (CopyParam->ClearArchive && FLAGSET(Attrs, faArchive)) { - FILE_OPERATION_LOOP (FMTLOAD(CANT_SET_ATTRS, (DirectoryName.c_str())), - THROWOSIFFALSE(FileSetAttr(DirectoryName, Attrs & ~faArchive) == 0); - ) + FILE_OPERATION_LOOP_BEGIN + { + THROWOSIFFALSE(FileSetAttr(ApiPath(DirectoryName), Attrs & ~faArchive) == 0); + } + FILE_OPERATION_LOOP_END(FMTLOAD(CANT_SET_ATTRS, (DirectoryName))); } } } - //--------------------------------------------------------------------------- void __fastcall TWebDAVFileSystem::CopyToLocal(TStrings * FilesToCopy, - const UnicodeString TargetDir, const TCopyParamType * CopyParam, - int Params, TFileOperationProgressType * OperationProgress, - TOnceDoneOperation & OnceDoneOperation) + const UnicodeString TargetDir, const TCopyParamType * CopyParam, + int Params, TFileOperationProgressType * OperationProgress, + TOnceDoneOperation & OnceDoneOperation) { Params &= ~cpAppend; UnicodeString FullTargetDir = ::IncludeTrailingBackslash(TargetDir); @@ -13170,7 +1551,6 @@ void __fastcall TWebDAVFileSystem::CopyToLocal(TStrings * FilesToCopy, UnicodeString FileName = FilesToCopy->Strings[Index]; const TRemoteFile * File = dynamic_cast(FilesToCopy->Objects[Index]); bool Success = false; - FTerminal->SetExceptionOnFail(true); try { try @@ -13181,27 +1561,25 @@ void __fastcall TWebDAVFileSystem::CopyToLocal(TStrings * FilesToCopy, } catch (EScpSkipFile & E) { - SUSPEND_OPERATION ( - if (!FTerminal->HandleException(&E)) - { - throw; - } - ); + TSuspendFileOperationProgress Suspend(OperationProgress); + if (!FTerminal->HandleException(&E)) + { + throw; + } } } __finally { OperationProgress->Finish(FileName, Success, OnceDoneOperation); - FTerminal->SetExceptionOnFail(false); } Index++; } } //--------------------------------------------------------------------------- void __fastcall TWebDAVFileSystem::SinkRobust(const UnicodeString FileName, - const TRemoteFile * File, const UnicodeString TargetDir, - const TCopyParamType * CopyParam, int Params, - TFileOperationProgressType * OperationProgress, unsigned int Flags) + const TRemoteFile * File, const UnicodeString TargetDir, + const TCopyParamType * CopyParam, int Params, + TFileOperationProgressType * OperationProgress, unsigned int Flags) { // the same in TSFTPFileSystem bool Retry; @@ -13211,10 +1589,11 @@ void __fastcall TWebDAVFileSystem::SinkRobust(const UnicodeString FileName, do { Retry = false; + bool ChildError = false; try { Sink(FileName, File, TargetDir, CopyParam, Params, OperationProgress, - Flags, Action); + Flags, Action, ChildError); } catch (Exception & E) { @@ -13222,7 +1601,10 @@ void __fastcall TWebDAVFileSystem::SinkRobust(const UnicodeString FileName, if (FTerminal->GetActive() || !FTerminal->QueryReopen(&E, ropNoReadDirectory, OperationProgress)) { - FTerminal->RollbackAction(Action, OperationProgress, &E); + if (!ChildError) + { + FTerminal->RollbackAction(Action, OperationProgress, &E); + } throw; } } @@ -13236,18 +1618,191 @@ void __fastcall TWebDAVFileSystem::SinkRobust(const UnicodeString FileName, { // prevent overwrite confirmations Params |= cpNoConfirmation; - Flags |= tfAutoResume; } } } while (Retry); } //--------------------------------------------------------------------------- +void TWebDAVFileSystem::NeonCreateRequest( + ne_request * Request, void * UserData, const char * /*Method*/, const char * /*Uri*/) +{ + TWebDAVFileSystem * FileSystem = static_cast(UserData); + ne_set_request_private(Request, SESSION_FS_KEY, FileSystem); + ne_add_response_body_reader(Request, NeonBodyAccepter, NeonBodyReader, Request); +} +//--------------------------------------------------------------------------- +void TWebDAVFileSystem::NeonPreSend( + ne_request * Request, void * UserData, ne_buffer * Header) +{ + TWebDAVFileSystem * FileSystem = static_cast(UserData); + + if (FileSystem->FTerminal->Log->Logging) + { + const char * Buffer; + size_t Size; + if (ne_get_request_body_buffer(Request, &Buffer, &Size)) + { + // all neon request types that use ne_add_request_header + // use XML content-type, so it's text-based + USEDPARAM(Header); + assert(ContainsStr(AnsiString(Header->data, Header->used), "Content-Type: " NE_XML_MEDIA_TYPE)); + FileSystem->FTerminal->Log->Add(llInput, UnicodeString(UTF8String(Buffer, Size))); + } + } + + if (FileSystem->FUploading) + { + // this may get called multiple times per request, + // for example when authentication fails + ne_set_request_body_provider_proxy(Request, + FileSystem->NeonUploadBodyProvider, FileSystem, + &FileSystem->FUploadBodyProvider, + &FileSystem->FUploadBodyProviderUserData); + + assert(FileSystem->FUploadBodyProvider != NULL); + } + + FileSystem->FResponse = L""; +} +//--------------------------------------------------------------------------- +int TWebDAVFileSystem::NeonPostSend(ne_request * /*Req*/, void * UserData, + const ne_status * /*Status*/) +{ + TWebDAVFileSystem * FileSystem = static_cast(UserData); + if (!FileSystem->FResponse.IsEmpty()) + { + FileSystem->FTerminal->Log->Add(llOutput, FileSystem->FResponse); + } + return NE_OK; +} +//--------------------------------------------------------------------------- +ssize_t TWebDAVFileSystem::NeonUploadBodyProvider(void * UserData, char * Buffer, size_t BufLen) +{ + TWebDAVFileSystem * FileSystem = static_cast(UserData); + assert(FileSystem->FUploadBodyProvider != NULL); + ssize_t Result; + if (FileSystem->CancelTransfer()) + { + Result = -1; + } + else + { + Result = FileSystem->FUploadBodyProvider(FileSystem->FUploadBodyProviderUserData, Buffer, BufLen); + } + return Result; +} +//--------------------------------------------------------------------------- +static void __fastcall AddHeaderValueToList(UnicodeString & List, ne_request * Request, const char * Name) +{ + const char * Value; + Value = ne_get_response_header(Request, Name); + if (Value != NULL) + { + AddToList(List, StrFromNeon(Value), L"; "); + } +} +//--------------------------------------------------------------------------- +int TWebDAVFileSystem::NeonBodyAccepter(void * UserData, ne_request * Request, const ne_status * Status) +{ + assert(UserData == Request); + TWebDAVFileSystem * FileSystem = + static_cast(ne_get_request_private(Request, SESSION_FS_KEY)); + + if (FileSystem->FInitialHandshake) + { + UnicodeString Line; + if (Status->code == 401) + { + if (!FileSystem->FAuthenticationRequested) + { + Line = LoadStr(STATUS_AUTHENTICATE); + } + else + { + Line = LoadStr(FTP_ACCESS_DENIED); + } + } + else if (Status->klass == 2) + { + Line = LoadStr(STATUS_AUTHENTICATED); + } + + if (!Line.IsEmpty()) + { + FileSystem->FTerminal->Information(Line, true); + } + + UnicodeString RemoteSystem; + // Used by IT Hit WebDAV Server: + // Server: Microsoft-HTTPAPI/1.0 + // X-Engine: IT Hit WebDAV Server .Net v3.8.1877.0 (Evaluation License) + AddHeaderValueToList(RemoteSystem, Request, "X-Engine"); + // Used by OpenDrive: + // Server: Apache/2.2.17 (Fedora) + // X-Powered-By: PHP/5.5.7 + // X-DAV-Powered-By: OpenDrive + AddHeaderValueToList(RemoteSystem, Request, "X-DAV-Powered-By"); + // Used by IIS: + // Server: Microsoft-IIS/8.5 + AddHeaderValueToList(RemoteSystem, Request, "Server"); + // Not really useful. + // Can be e.g. "PleskLin" + AddHeaderValueToList(RemoteSystem, Request, "X-Powered-By"); + FileSystem->FFileSystemInfo.RemoteSystem = RemoteSystem; + } + + return ne_accept_2xx(UserData, Request, Status); +} +//--------------------------------------------------------------------------- +bool __fastcall TWebDAVFileSystem::CancelTransfer() +{ + bool Result = false; + if ((FUploading || FDownloading) && + (FTerminal->OperationProgress != NULL) && + (FTerminal->OperationProgress->Cancel != csContinue)) + { + FCancelled = true; + Result = true; + } + return Result; +} +//--------------------------------------------------------------------------- +int TWebDAVFileSystem::NeonBodyReader(void * UserData, const char * Buf, size_t Len) +{ + ne_request * Request = static_cast(UserData); + TWebDAVFileSystem * FileSystem = + static_cast(ne_get_request_private(Request, SESSION_FS_KEY)); + + if (FileSystem->FTerminal->Log->Logging) + { + ne_content_type ContentType; + if (ne_get_content_type(Request, &ContentType) == 0) + { + // The main point of the content-type check was to exclude + // GET responses (with file contents). + // But this won't work when downloading text files that have text + // content type on their own, hence the additional not-downloading test. + if (!FileSystem->FDownloading && + ((ne_strcasecmp(ContentType.type, "text") == 0) || + media_type_is_xml(&ContentType))) + { + UnicodeString Content = UnicodeString(UTF8String(Buf, Len)).Trim(); + FileSystem->FResponse += Content; + } + ne_free(ContentType.value); + } + } + + int Result = FileSystem->CancelTransfer() ? 1 : 0; + return Result; +} +//--------------------------------------------------------------------------- void __fastcall TWebDAVFileSystem::Sink(const UnicodeString FileName, const TRemoteFile * File, const UnicodeString TargetDir, const TCopyParamType * CopyParam, int Params, TFileOperationProgressType * OperationProgress, unsigned int Flags, - TDownloadSessionAction & Action) + TDownloadSessionAction & Action, bool & ChildError) { UnicodeString FileNameOnly = UnixExtractFileName(FileName); @@ -13259,13 +1814,19 @@ void __fastcall TWebDAVFileSystem::Sink(const UnicodeString FileName, if (!CopyParam->AllowTransfer(FileName, osRemote, File->IsDirectory, MaskParams)) { - FTerminal->LogEvent(FORMAT(L"File \"%s\" excluded from transfer", (FileName.c_str()))); + FTerminal->LogEvent(FORMAT(L"File \"%s\" excluded from transfer", (FileName))); + THROW_SKIP_FILE_NULL; + } + + if (CopyParam->SkipTransfer(FileName, File->IsDirectory)) + { + OperationProgress->AddSkippedFileSize(File->Size); THROW_SKIP_FILE_NULL; } FTerminal->LogFileDetails(FileName, TDateTime(), File->Size); - OperationProgress->SetFile(FileNameOnly); + OperationProgress->SetFile(FileName); UnicodeString DestFileName = CopyParam->ChangeFileName(FileNameOnly, osRemote, FLAGSET(Flags, tfFirstLevel)); @@ -13273,73 +1834,50 @@ void __fastcall TWebDAVFileSystem::Sink(const UnicodeString FileName, if (File->IsDirectory) { - bool CanProceed = true; - if (::DirectoryExists(DestFullName)) + Action.Cancel(); + if (ALWAYS_TRUE(!File->IsSymLink)) { - unsigned int Answer = 0; - UnicodeString Message = FMTLOAD(DIRECTORY_OVERWRITE, (FileNameOnly.c_str())); - TQueryParams QueryParams(qpNeverAskAgainCheck); - SUSPEND_OPERATION ( - Answer = FTerminal->ConfirmFileOverwrite( - FileNameOnly /*not used*/, NULL, - qaYes | qaNo | qaCancel | qaYesToAll | qaNoToAll, - &QueryParams, osRemote, CopyParam, Params, OperationProgress, Message); - ); - switch (Answer) + FILE_OPERATION_LOOP_BEGIN { - case qaCancel: - OperationProgress->Cancel = csCancel; // continue on next case - // FALLTHROUGH - case qaNo: - CanProceed = false; - default: - break; + int Attrs = FileGetAttr(ApiPath(DestFullName)); + if (FLAGCLEAR(Attrs, faDirectory)) { EXCEPTION; } } - } - if (CanProceed) - { - Action.Cancel(); - if (!File->IsSymLink) + FILE_OPERATION_LOOP_END(FMTLOAD(NOT_DIRECTORY_ERROR, (DestFullName))); + + FILE_OPERATION_LOOP_BEGIN { - FILE_OPERATION_LOOP (FMTLOAD(NOT_DIRECTORY_ERROR, (DestFullName.c_str())), - int Attrs = FileGetAttr(DestFullName); - if (FLAGCLEAR(Attrs, faDirectory)) { EXCEPTION; } - ); - - FILE_OPERATION_LOOP (FMTLOAD(CREATE_DIR_ERROR, (DestFullName.c_str())), - THROWOSIFFALSE(ForceDirectories(DestFullName)); - ); - - TSinkFileParams SinkFileParams; - SinkFileParams.TargetDir = ::IncludeTrailingBackslash(DestFullName); - SinkFileParams.CopyParam = CopyParam; - SinkFileParams.Params = Params; - SinkFileParams.OperationProgress = OperationProgress; - SinkFileParams.Skipped = false; - SinkFileParams.Flags = Flags & ~(tfFirstLevel | tfAutoResume); - - FTerminal->ProcessDirectory(FileName, SinkFile, &SinkFileParams); - - // Do not delete directory if some of its files were skip. - // Throw "skip file" for the directory to avoid attempt to deletion - // of any parent directory - if (FLAGSET(Params, cpDelete) && SinkFileParams.Skipped) - { - THROW_SKIP_FILE_NULL; - } + THROWOSIFFALSE(ForceDirectories(ApiPath(DestFullName))); } - else + FILE_OPERATION_LOOP_END(FMTLOAD(CREATE_DIR_ERROR, (DestFullName))); + + TSinkFileParams SinkFileParams; + SinkFileParams.TargetDir = IncludeTrailingBackslash(DestFullName); + SinkFileParams.CopyParam = CopyParam; + SinkFileParams.Params = Params; + SinkFileParams.OperationProgress = OperationProgress; + SinkFileParams.Skipped = false; + SinkFileParams.Flags = Flags & ~tfFirstLevel; + + FTerminal->ProcessDirectory(FileName, SinkFile, &SinkFileParams); + + // Do not delete directory if some of its files were skip. + // Throw "skip file" for the directory to avoid attempt to deletion + // of any parent directory + if (FLAGSET(Params, cpDelete) && SinkFileParams.Skipped) { - // file is symlink to directory, currently do nothing, but it should be - // reported to user + THROW_SKIP_FILE_NULL; } } + else + { + // file is symlink to directory, currently do nothing, but it should be + // reported to user + } } else { - FTerminal->LogEvent(FORMAT(L"Copying \"%s\" to local directory started.", (FileName.c_str()))); - bool CanProceed = true; - if (FileExists(DestFullName)) + FTerminal->LogEvent(FORMAT(L"Copying \"%s\" to local directory started.", (FileName))); + if (FileExists(ApiPath(DestFullName))) { __int64 Size; __int64 MTime; @@ -13353,112 +1891,122 @@ void __fastcall TWebDAVFileSystem::Sink(const UnicodeString FileName, FileParams.DestTimestamp = UnixToDateTime(MTime, FTerminal->SessionData->DSTMode); - unsigned int Answer = 0; - TOverwriteMode OverwriteMode = omOverwrite; - bool AutoResume = false; - ConfirmOverwrite(DestFullName, OverwriteMode, OperationProgress, - &FileParams, CopyParam, Params, AutoResume, Answer); - switch (Answer) - { - case qaCancel: - OperationProgress->Cancel = csCancel; // continue on next case - // FALLTHROUGH - case qaNo: - CanProceed = false; - default: - break; - } + ConfirmOverwrite(FileName, DestFileName, OperationProgress, + &FileParams, CopyParam, Params); } - if (CanProceed) - { - // Suppose same data size to transfer as to write - OperationProgress->SetTransferSize(File->Size); - OperationProgress->SetLocalSize(OperationProgress->TransferSize); - int Attrs = -1; - FILE_OPERATION_LOOP (FMTLOAD(NOT_FILE_ERROR, (DestFullName.c_str())), - Attrs = FileGetAttr(DestFullName); - if ((Attrs >= 0) && FLAGSET(Attrs, faDirectory)) { EXCEPTION; } - ); + // Suppose same data size to transfer as to write + OperationProgress->SetTransferSize(File->Size); + OperationProgress->SetLocalSize(OperationProgress->TransferSize); - OperationProgress->TransferingFile = false; // not set with FTP protocol + int Attrs = -1; + FILE_OPERATION_LOOP_BEGIN + { + Attrs = FileGetAttr(ApiPath(DestFullName)); + if ((Attrs >= 0) && FLAGSET(Attrs, faDirectory)) { EXCEPTION; } + } + FILE_OPERATION_LOOP_END(FMTLOAD(NOT_FILE_ERROR, (DestFullName))); - ResetFileTransfer(); + OperationProgress->TransferingFile = false; // not set with WebDAV protocol - TFileTransferData UserData; + UnicodeString FilePath = ::UnixExtractFilePath(FileName); + if (FilePath.IsEmpty()) + { + FilePath = L"/"; + } - UnicodeString FilePath = ::UnixExtractFilePath(FileName); - if (FilePath.IsEmpty()) - { - FilePath = L"/"; - } + Action.Destination(ExpandUNCFileName(DestFullName)); + FILE_OPERATION_LOOP_BEGIN + { + HANDLE LocalHandle; + if (!FTerminal->CreateLocalFile(DestFullName, OperationProgress, + &LocalHandle, FLAGSET(Params, cpNoConfirmation))) { - unsigned int TransferType = 2; - // ignore file list - TWebDAVFileListHelper Helper(this, NULL, true); - - FFileTransferCPSLimit = OperationProgress->CPSLimit; - FFileTransferPreserveTime = CopyParam->PreserveTime; - UserData.FileName = DestFileName; - UserData.Params = Params; - UserData.AutoResume = FLAGSET(Flags, tfAutoResume); - UserData.CopyParam = CopyParam; - FileTransfer(FileName, DestFullName, FileNameOnly, - FilePath, true, File->Size, TransferType, UserData, OperationProgress); + THROW_SKIP_FILE_NULL; } - // in case dest filename is changed from overwrite dialog - if (DestFileName != UserData.FileName) + bool DeleteLocalFile = true; + + int FD = -1; + try { - DestFullName = TargetDir + UserData.FileName; - Attrs = FileGetAttr(DestFullName); - } + FD = _open_osfhandle((intptr_t)LocalHandle, O_BINARY); + if (FD < 0) + { + THROW_SKIP_FILE_NULL; + } - Action.Destination(ExpandUNCFileName(DestFullName)); + TValueRestorer TransferringRestorer(FDownloading); + FDownloading = true; - if (Attrs == -1) - { - Attrs = faArchive; - } - int NewAttrs = CopyParam->LocalFileAttrs(*File->Rights); - if ((NewAttrs & Attrs) != NewAttrs) - { - FILE_OPERATION_LOOP (FMTLOAD(CANT_SET_ATTRS, (DestFullName.c_str())), - THROWOSIFFALSE(FileSetAttr(DestFullName, Attrs | NewAttrs) == 0); - ); + ClearNeonError(); + CheckStatus(ne_get(FNeonSession, PathToNeon(FileName), FD)); + DeleteLocalFile = false; + + if (CopyParam->PreserveTime) + { + TDateTime Modification = File->Modification; + FILETIME WrTime = DateTimeToFileTime(Modification, FTerminal->SessionData->DSTMode); + FTerminal->LogEvent(FORMAT(L"Preserving timestamp [%s]", + (StandardTimestamp(Modification)))); + SetFileTime(LocalHandle, NULL, NULL, &WrTime); + } } - // set time + __finally { - FILE_OPERATION_LOOP (FMTLOAD(CANT_SET_ATTRS, (DestFullName.c_str())), - HANDLE Handle; - Handle = CreateFile(DestFullName.c_str(), GENERIC_WRITE, - FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); - FILETIME WrTime = DateTimeToFileTime(File->Modification, - FTerminal->SessionData->DSTMode); - bool Result = SetFileTime(Handle, &WrTime, &WrTime, &WrTime) > 0; - CloseHandle(Handle); - if (!Result) + if (FD >= 0) + { + // _close calls CloseHandle internally (even doc states, we should not call CloseHandle), + // but it crashes code guard + _close(FD); + } + else + { + CloseHandle(LocalHandle); + } + + if (DeleteLocalFile) + { + FILE_OPERATION_LOOP_BEGIN { - Abort(); + THROWOSIFFALSE(Sysutils::DeleteFile(ApiPath(DestFullName))); } - ); + FILE_OPERATION_LOOP_END(FMTLOAD(DELETE_LOCAL_FILE_ERROR, (DestFullName))); + } + } + } + FILE_OPERATION_LOOP_END(FMTLOAD(TRANSFER_ERROR, (FileName))); + + if (Attrs == -1) + { + Attrs = faArchive; + } + int NewAttrs = CopyParam->LocalFileAttrs(*File->Rights); + if ((NewAttrs & Attrs) != NewAttrs) + { + FILE_OPERATION_LOOP_BEGIN + { + THROWOSIFFALSE(FileSetAttr(ApiPath(DestFullName), Attrs | NewAttrs) == 0); } + FILE_OPERATION_LOOP_END(FMTLOAD(CANT_SET_ATTRS, (DestFullName))); } } if (FLAGSET(Params, cpDelete)) { + ChildError = true; // If file is directory, do not delete it recursively, because it should be // empty already. If not, it should not be deleted (some files were // skipped or some new files were copied to it, while we were downloading) int Params = dfNoRecursive; FTerminal->DeleteFile(FileName, File, &Params); + ChildError = false; } } //--------------------------------------------------------------------------- void __fastcall TWebDAVFileSystem::SinkFile(const UnicodeString FileName, - const TRemoteFile * File, void * Param) + const TRemoteFile * File, void * Param) { TSinkFileParams * Params = static_cast(Param); assert(Params->OperationProgress); @@ -13472,12 +2020,14 @@ void __fastcall TWebDAVFileSystem::SinkFile(const UnicodeString FileName, TFileOperationProgressType * OperationProgress = Params->OperationProgress; Params->Skipped = true; - SUSPEND_OPERATION ( + + { + TSuspendFileOperationProgress Suspend(OperationProgress); if (!FTerminal->HandleException(&E)) { throw; } - ); + } if (OperationProgress->Cancel) { @@ -13486,745 +2036,368 @@ void __fastcall TWebDAVFileSystem::SinkFile(const UnicodeString FileName, } } //--------------------------------------------------------------------------- -bool __fastcall TWebDAVFileSystem::HandleListData(const wchar_t * Path, - const TListDataEntry * Entries, unsigned int Count) +bool TWebDAVFileSystem::VerifyCertificate(const TWebDAVCertificateData & Data) { - if (!FActive) - { - return false; - } - else if (FIgnoreFileList) - { - // directory listing provided implicitly by FZAPI during certain operations is ignored - assert(FFileList == NULL); - return false; - } - else + FTerminal->LogEvent( + FORMAT(L"Verifying certificate for \"%s\" with fingerprint %s and %2.2X failures", + (Data.Subject, Data.Fingerprint, Data.Failures))); + + int Failures = Data.Failures; + // We can accept only unknown certificate authority. + if (FLAGSET(Data.Failures, NE_SSL_UNTRUSTED)) { - assert(FFileList != NULL); - // this can actually fail in real life, - // when connected to server with case insensitive paths - assert(UnixComparePaths(AbsolutePath(FFileList->Directory, false), Path)); - USEDPARAM(Path); + unsigned char * Certificate; + size_t CertificateLen = ne_unbase64(Data.AsciiCert.c_str(), &Certificate); - for (size_t Index = 0; Index < Count; Index++) + if (CertificateLen > 0) { - const TListDataEntry * Entry = &Entries[Index]; - TRemoteFile * File = new TRemoteFile(); - try - { - File->Terminal = FTerminal; - - File->FileName = UnicodeString(Entry->Name); - if (wcslen(Entry->Permissions) >= 10) - { - try - { - File->Rights->Text = Entry->Permissions + 1; - } - catch (...) - { - // ignore permissions errors with WebDAV - } - } - // FIXME - UnicodeString own = Entry->OwnerGroup; - const wchar_t * Space = wcschr(own.c_str(), ' '); - if (Space != NULL) - { - File->Owner.Name = UnicodeString(own.c_str(), Space - own.c_str()); - File->Group.Name = Space + 1; - } - else - { - File->Owner.Name = Entry->OwnerGroup; - } - - File->Size = Entry->Size; - - if (Entry->Link) - { - File->Type = FILETYPE_SYMLINK; - } - else if (Entry->Dir) - { - File->Type = FILETYPE_DIRECTORY; - } - else - { - File->Type = L'-'; - } - - // ModificationFmt must be set after Modification - if (Entry->Time.HasDate) - { - // should be the same as ConvertRemoteTimestamp - TDateTime Modification = - EncodeDateVerbose(static_cast(Entry->Time.Year), static_cast(Entry->Time.Month), - static_cast(Entry->Time.Day)); - if (Entry->Time.HasTime) - { - unsigned short seconds = 0; - if (Entry->Time.HasSeconds) - seconds = static_cast(Entry->Time.Second); - File->Modification = Modification + - EncodeTimeVerbose(static_cast(Entry->Time.Hour), - static_cast(Entry->Time.Minute), - seconds, 0); - // not exact as we got year as well, but it is most probably - // guessed by FZAPI anyway - File->ModificationFmt = mfMDHM; - } - else - { - File->Modification = Modification; - File->ModificationFmt = mfMDY; - } - } - else - { - // We estimate date to be today, if we have at least time - File->Modification = TDateTime(0.0); - File->ModificationFmt = mfNone; - } - File->LastAccess = File->Modification; - - File->LinkTo = Entry->LinkTarget; - - File->Complete(); - } - catch (Exception & E) + if (WindowsValidateCertificate(Certificate, CertificateLen)) { - delete File; - UnicodeString EntryData = - FORMAT(L"%s/%s/%s/%lld/%d/%d/%d/%d/%d/%d/%d/%d/%d", - (Entry->Name, - Entry->Permissions, - Entry->OwnerGroup, - Entry->Size, - int(Entry->Dir), int(Entry->Link), Entry->Time.Year, Entry->Time.Month, Entry->Time.Day, - Entry->Time.Hour, Entry->Time.Minute, int(Entry->Time.HasTime), int(Entry->Time.HasDate))); - throw ETerminal(&E, FMTLOAD(LIST_LINE_ERROR, (EntryData.c_str())), HELP_LIST_LINE_ERROR); + FTerminal->LogEvent(L"Certificate verified against Windows certificate store"); + Failures &= ~NE_SSL_UNTRUSTED; } - - FFileList->AddFile(File); - } - return true; - } -} -//--------------------------------------------------------------------------- -void __fastcall TWebDAVFileSystem::ResetFileTransfer() -{ - FFileTransferAbort = ftaNone; - FFileTransferCancelled = false; - FFileTransferResumed = 0; - webdav::cancelled = FALSE; -} -//--------------------------------------------------------------------------- -void __fastcall TWebDAVFileSystem::ReadDirectoryProgress(__int64 Bytes) -{ - // with WebDAV we do not know exactly how many entries we have received, - // instead we know number of bytes received only. - // so we report approximation based on average size of entry. - size_t Progress = static_cast(Bytes / 80); - if (Progress - FLastReadDirectoryProgress >= 10) - { - bool Cancel = false; - FLastReadDirectoryProgress = Progress; - FTerminal->DoReadDirectoryProgress(Progress, Cancel); - if (Cancel) - { - FTerminal->DoReadDirectoryProgress(-2, Cancel); + ne_free(Certificate); } } -} -//--------------------------------------------------------------------------- -void __fastcall TWebDAVFileSystem::DoFileTransferProgress(__int64 TransferSize, - __int64 Bytes) -{ - TFileOperationProgressType * OperationProgress = FTerminal->OperationProgress; - if (!OperationProgress) return; - OperationProgress->SetTransferSize(TransferSize); + UnicodeString Summary; - if (FFileTransferResumed > 0) + if (Failures == 0) { - OperationProgress->AddResumed(FFileTransferResumed); - FFileTransferResumed = 0; + Summary = LoadStr(CERT_OK); } - - __int64 Diff = Bytes - OperationProgress->TransferedSize; - if (Diff >= 0) + else { - OperationProgress->AddTransfered(Diff); - } + int FailuresToList = Failures; - if (OperationProgress->Cancel == csCancel) - { - FFileTransferCancelled = true; - FFileTransferAbort = ftaCancel; + if (FLAGSET(FailuresToList, NE_SSL_NOTYETVALID)) + { + AddToList(Summary, LoadStr(CERT_ERR_CERT_NOT_YET_VALID), L" "); + FailuresToList &= ~NE_SSL_NOTYETVALID; + } + if (FLAGSET(FailuresToList, NE_SSL_EXPIRED)) + { + AddToList(Summary, LoadStr(CERT_ERR_CERT_HAS_EXPIRED), L" "); + FailuresToList &= ~NE_SSL_EXPIRED; + } + // NEON checks certificate host name on its own + if (FLAGSET(FailuresToList, NE_SSL_IDMISMATCH)) + { + AddToList(Summary, FMTLOAD(CERT_NAME_MISMATCH, (FTerminal->SessionData->HostNameExpanded)), L" "); + FailuresToList &= ~NE_SSL_IDMISMATCH; + } + if (FLAGSET(FailuresToList, NE_SSL_UNTRUSTED)) + { + AddToList(Summary, LoadStr(CERT_ERR_CERT_UNTRUSTED), L" "); + FailuresToList &= ~NE_SSL_UNTRUSTED; + } + if (FLAGSET(FailuresToList, NE_SSL_BADCHAIN)) + { + AddToList(Summary, LoadStr(CERT_ERR_BAD_CHAIN), L" "); + FailuresToList &= ~NE_SSL_BADCHAIN; + } + // nb, NE_SSL_REVOKED is never used by OpenSSL implementation + if (FailuresToList != 0) + { + AddToList(Summary, LoadStr(CERT_ERR_UNKNOWN), L" "); + } } - if (FFileTransferCPSLimit != OperationProgress->CPSLimit) - { - FFileTransferCPSLimit = OperationProgress->CPSLimit; - } -} -//--------------------------------------------------------------------------- -void __fastcall TWebDAVFileSystem::FileTransferProgress(__int64 TransferSize, - __int64 Bytes) -{ - TGuard Guard(FTransferStatusCriticalSection); + UnicodeString ValidityTimeFormat = L"ddddd tt"; + FSessionInfo.CertificateFingerprint = Data.Fingerprint; + FSessionInfo.Certificate = + FMTLOAD(CERT_TEXT, ( + Data.Issuer + L"\n", + Data.Subject + L"\n", + FormatDateTime(ValidityTimeFormat, Data.ValidFrom), + FormatDateTime(ValidityTimeFormat, Data.ValidUntil), + Data.Fingerprint, + Summary)); - DoFileTransferProgress(TransferSize, Bytes); -} + bool Result = (Failures == 0); -//--------------------------------------------------------------------------- -void __fastcall TWebDAVFileSystem::FileTransfer(const UnicodeString FileName, - const UnicodeString LocalFile, const UnicodeString RemoteFile, - const UnicodeString RemotePath, bool Get, __int64 Size, int Type, - TFileTransferData & UserData, TFileOperationProgressType * OperationProgress) -{ - FCurrentOperationProgress = OperationProgress; - FILE_OPERATION_LOOP (FMTLOAD(TRANSFER_ERROR, (FileName.c_str())), - UnicodeString FullRemoteFileName = RemotePath + RemoteFile; - bool Result = false; - if (Get) - { - HANDLE LocalFileHandle = 0; - FTerminal->CreateLocalFile(LocalFile, - OperationProgress, &LocalFileHandle, true); - Result = WebDAVGetFile(FullRemoteFileName.c_str(), &LocalFileHandle); - if (!Result) - { - ::CloseHandle(LocalFileHandle); - } - } - else + if (!Result) + { + if (!Result) { - Result = WebDAVPutFile(FullRemoteFileName.c_str(), LocalFile.c_str(), Size); + Result = FTerminal->VerifyCertificate( + CertificateStorageKey, Data.Fingerprint, Data.Subject, Failures); } + if (!Result) - EXCEPTION; - ); + { + TClipboardHandler ClipboardHandler; + ClipboardHandler.Text = Data.Fingerprint; + + TQueryButtonAlias Aliases[1]; + Aliases[0].Button = qaRetry; + Aliases[0].Alias = LoadStr(COPY_KEY_BUTTON); + Aliases[0].OnClick = &ClipboardHandler.Copy; + + TQueryParams Params; + Params.HelpKeyword = HELP_VERIFY_CERTIFICATE; + Params.NoBatchAnswers = qaYes | qaRetry; + Params.Aliases = Aliases; + Params.AliasesCount = LENOF(Aliases); + unsigned int Answer = FTerminal->QueryUser( + FMTLOAD(VERIFY_CERT_PROMPT3, (FSessionInfo.Certificate)), + NULL, qaYes | qaNo | qaCancel | qaRetry, &Params, qtWarning); + switch (Answer) + { + case qaYes: + FTerminal->CacheCertificate(CertificateStorageKey, Data.Fingerprint, Failures); + Result = true; + break; - switch (FFileTransferAbort) - { - case ftaSkip: - THROW_SKIP_FILE(NULL, L""); + case qaNo: + Result = true; + break; - case ftaCancel: - Abort(); - break; + default: + FAIL; + case qaCancel: + FTerminal->Configuration->Usage->Inc(L"HostNotVerified"); + Result = false; + break; + } + } } - if (!FFileTransferCancelled) + if (Result) { - // show completion of transfer - // call non-guarded variant to avoid deadlock with keepalives - // (we are not waiting for reply anymore so keepalives are free to proceed) - DoFileTransferProgress(OperationProgress->TransferSize, OperationProgress->TransferSize); + CollectTLSSessionInfo(); } -} - -bool TWebDAVFileSystem::SendPropFindRequest(const wchar_t * path, int & responseCode) -{ - assert(path); - - assert(FSession); - apr_pool_t * pool = webdav_pool_create(webdav_pool); - webdav::error_t err = 0; - const char * remote_path = NULL; - err = webdav::path_cstring_to_utf8(&remote_path, AnsiString(path).c_str(), pool); - if (err) return false; - err = webdav::client_send_propfind_request( - FSession, - remote_path, - &responseCode, - pool - ); - - webdav_pool_destroy(pool); - return err == WEBDAV_NO_ERROR; -} - -bool TWebDAVFileSystem::WebDAVCheckExisting(const wchar_t * path, int & is_dir) -{ - assert(path); - is_dir = 0; - assert(FSession); - apr_pool_t * pool = webdav_pool_create(webdav_pool); - webdav::error_t err = 0; - webdav::node_kind_t kind = webdav::node_none; - const char * remote_path = NULL; - err = webdav::path_cstring_to_utf8(&remote_path, AnsiString(path).c_str(), pool); - if (err) return false; - err = webdav::client_check_path( - FSession, - remote_path, - &kind, - pool - ); - - if (kind != webdav::node_none) - is_dir = kind == webdav::node_dir; - webdav_pool_destroy(pool); - return (err == WEBDAV_NO_ERROR) && (kind != webdav::node_none); -} - -bool TWebDAVFileSystem::WebDAVMakeDirectory(const wchar_t * path) -{ - assert(path); - - assert(FSession); - apr_pool_t * pool = webdav_pool_create(webdav_pool); - webdav::error_t err = 0; - const char * remote_path = NULL; - err = webdav::path_cstring_to_utf8(&remote_path, AnsiString(path).c_str(), pool); - if (err) return false; - err = webdav::client_make_directory( - FSession, - remote_path, - NULL, - pool - ); - webdav_pool_destroy(pool); - return err == WEBDAV_NO_ERROR; -} -bool TWebDAVFileSystem::WebDAVGetList(const UnicodeString Directory) -{ - webdav::listdataentry_vector_t Entries; - - assert(FSession); - webdav::list_func_baton_t baton = {0}; - baton.verbose = true; - baton.entries = &Entries; - baton.session = FSession; - baton.pool = webdav_pool_create(webdav_pool); - webdav::error_t err = 0; - const char * remote_path = NULL; - err = webdav::path_cstring_to_utf8(&remote_path, AnsiString(Directory).c_str(), baton.pool); - if (err) return false; - err = webdav::client_list2( - FSession, - remote_path, - webdav::depth_immediates, - WEBDAV_DIRENT_ALL, - webdav::list_func, - &baton, - baton.pool - ); - - TListDataEntry * pEntries = !Entries.empty() ? &Entries[0] : NULL; - HandleListData(Directory.c_str(), pEntries, Entries.size()); - webdav_pool_destroy(baton.pool); - return err == WEBDAV_NO_ERROR; + return Result; } - -bool TWebDAVFileSystem::WebDAVGetFile(const wchar_t * remotePath, - HANDLE * LocalFileHandle) +//------------------------------------------------------------------------------ +void __fastcall TWebDAVFileSystem::CollectTLSSessionInfo() { - assert(remotePath && *remotePath); - assert(LocalFileHandle); - - assert(FSession); - apr_pool_t * pool = webdav_pool_create(webdav_pool); - webdav::error_t err = 0; - const char * remote_path = NULL; - err = webdav::path_cstring_to_utf8(&remote_path, AnsiString(remotePath).c_str(), pool); - if (err) return false; - err = webdav::client_get_file( - FSession, - remote_path, - LocalFileHandle, - pool); - - webdav_pool_destroy(pool); - return err == WEBDAV_NO_ERROR; -} + // see also TFTPFileSystem::Open() + UnicodeString TlsVersionStr = StrFromNeon(ne_ssl_get_version(FNeonSession)); + AddToList(FSessionInfo.SecurityProtocolName, TlsVersionStr, L", "); -bool TWebDAVFileSystem::WebDAVPutFile(const wchar_t * remotePath, const wchar_t * localPath, const unsigned __int64 /*fileSize*/) -{ - assert(remotePath && *remotePath); - assert(localPath && *localPath); - - assert(FSession); - apr_pool_t * pool = webdav_pool_create(webdav_pool); - webdav::error_t err = 0; - const char * remote_path = NULL; - const char * local_path = NULL; - err = webdav::path_cstring_to_utf8(&remote_path, AnsiString(remotePath).c_str(), pool); - if (err) return false; - err = webdav::path_cstring_to_utf8(&local_path, AnsiString(localPath).c_str(), pool); - if (err) return false; - err = webdav::client_put_file( - FSession, - remote_path, - local_path, - pool - ); - - webdav_pool_destroy(pool); - return err == WEBDAV_NO_ERROR; -} + UnicodeString Cipher = StrFromNeon(ne_ssl_get_cipher(FNeonSession)); + FSessionInfo.CSCipher = Cipher; + FSessionInfo.SCCipher = Cipher; -bool TWebDAVFileSystem::WebDAVRenameFile(const wchar_t * srcPath, const wchar_t * dstPath) -{ - assert(srcPath && *srcPath); - assert(dstPath && *dstPath); - - assert(FSession); - apr_pool_t * pool = webdav_pool_create(webdav_pool); - webdav::error_t err = 0; - const char * src_path = NULL; - const char * dst_path = NULL; - err = webdav::path_cstring_to_utf8(&src_path, AnsiString(srcPath).c_str(), pool); - if (err) return false; - err = webdav::path_cstring_to_utf8(&dst_path, AnsiString(dstPath).c_str(), pool); - if (err) return false; - err = webdav::client_move_file_or_directory( - FSession, - src_path, - dst_path, - NULL, - pool - ); - - webdav_pool_destroy(pool); - return err == WEBDAV_NO_ERROR; + // see CAsyncSslSocketLayer::PrintSessionInfo() + FTerminal->LogEvent(FORMAT("Using %s, cipher %s", (TlsVersionStr, Cipher))); } - -bool TWebDAVFileSystem::WebDAVDeleteFile(const wchar_t * path) +//------------------------------------------------------------------------------ +// A neon-session callback to validate the SSL certificate when the CA +// is unknown (e.g. a self-signed cert), or there are other SSL +// certificate problems. +int TWebDAVFileSystem::NeonServerSSLCallback(void * UserData, int Failures, const ne_ssl_certificate * Certificate) { - assert(path); - - assert(FSession); - apr_pool_t * pool = webdav_pool_create(webdav_pool); - webdav::error_t err = 0; - const char * remote_path = NULL; - err = webdav::path_cstring_to_utf8(&remote_path, AnsiString(path).c_str(), pool); - if (err) return false; - err = webdav::client_delete_file( - FSession, - remote_path, - NULL, - pool - ); - - webdav_pool_destroy(pool); - return err == WEBDAV_NO_ERROR; -} + TWebDAVCertificateData Data; -webdav::error_t TWebDAVFileSystem::OpenURL(const UnicodeString & session_URL, - apr_pool_t * pool) -{ - webdav::client_ctx_t * ctx = NULL; - WEBDAV_ERR(client_create_context(&ctx, pool)); - - const char * auth_username = NULL; - const char * auth_password = NULL; - WEBDAV_ERR(webdav::utf_cstring_to_utf8(&auth_username, - AnsiString(FTerminal->SessionData->UserNameExpanded).c_str(), pool)); - WEBDAV_ERR(webdav::utf_cstring_to_utf8(&auth_password, - AnsiString(FTerminal->SessionData->Password).c_str(), pool)); - webdav::auth_baton_t * ab = NULL; - webdav::auth_baton_create(&ab, pool); - webdav::auth_baton_init(ab, - FALSE, // non_interactive - auth_username, - auth_password, - FALSE, // no_auth_cache - TRUE, // trust_server_cert - this, - webdav::check_cancel, ab, - pool); - ctx->auth_baton = ab; - - // Set up our cancellation support. - ctx->cancel_func = webdav::check_cancel; - ctx->cancel_baton = ab; - - ctx->progress_func = webdav::progress_func; - ctx->progress_baton = ctx; - - webdav::session_t * session_p = NULL; - const char * corrected_url = NULL; - AnsiString base_url = AnsiString(session_URL).c_str(); - const char * base_url_encoded = webdav::path_uri_encode(base_url.c_str(), pool); - WEBDAV_ERR(webdav::client_open_session_internal( - &session_p, - &corrected_url, - base_url_encoded, - ctx, - pool)); - - const char * url = NULL; - if (corrected_url) - { - url = apr_pstrdup(pool, corrected_url); - } - else + char Fingerprint[NE_SSL_DIGESTLEN] = {0}; + if (ne_ssl_cert_digest(Certificate, Fingerprint) != 0) { - url = apr_pstrdup(pool, base_url_encoded); + strcpy(Fingerprint, ""); } - ne_uri * uri = NULL; - if (WEBDAV_NO_ERROR == webdav::parse_ne_uri(&uri, url, pool)) - { - FCurrentDirectory = uri->path; - FHasTrailingSlash = (FCurrentDirectory.Length() > 0) && (FCurrentDirectory[FCurrentDirectory.Length()] == L'/'); - } - FSession = session_p; - return WEBDAV_NO_ERROR; -} + Data.Fingerprint = StrFromNeon(Fingerprint); + char * AsciiCert = ne_ssl_cert_export(Certificate); + Data.AsciiCert = StrFromNeon(AsciiCert); + ne_free(AsciiCert); -//--------------------------------------------------------------------------- + char * Subject = ne_ssl_readable_dname(ne_ssl_cert_subject(Certificate)); + Data.Subject = StrFromNeon(Subject); + ne_free(Subject); + char * Issuer = ne_ssl_readable_dname(ne_ssl_cert_issuer(Certificate)); + Data.Issuer = StrFromNeon(Issuer); + ne_free(Issuer); -webdav::error_t TWebDAVFileSystem::GetServerSettings( - int * proxy_method, - const char ** proxy_host, - unsigned int * proxy_port, - const char ** proxy_username, - const char ** proxy_password, - int * timeout_seconds, - int * neon_debug, - const char ** neon_debug_file_name, - bool * compression, - const char ** pk11_provider, - const char ** ssl_authority_file, - apr_pool_t * pool) -{ - // If we find nothing, default to nulls. - *proxy_method = 0; - *proxy_host = NULL; - *proxy_port = (unsigned int)-1; - *proxy_username = NULL; - *proxy_password = NULL; - *pk11_provider = NULL; - *ssl_authority_file = NULL; + Data.Failures = Failures; - TSessionData * Data = FTerminal->SessionData; - TConfiguration * Configuration = FTerminal->Configuration; - { - TProxyMethod ProxyMethod = Data->ProxyMethod; - *proxy_method = (int)ProxyMethod; - if (ProxyMethod != (TProxyMethod)::pmNone) - { - WEBDAV_ERR(webdav::path_cstring_to_utf8(proxy_host, AnsiString(Data->ProxyHost).c_str(), pool)); - WEBDAV_ERR(webdav::path_cstring_to_utf8(proxy_username, AnsiString(Data->ProxyUsername).c_str(), pool)); - WEBDAV_ERR(webdav::path_cstring_to_utf8(proxy_password, AnsiString(Data->ProxyPassword).c_str(), pool)); - } - } + time_t ValidFrom; + time_t ValidUntil; + ne_ssl_cert_validity_time(Certificate, &ValidFrom, &ValidUntil); + Data.ValidFrom = UnixToDateTime(ValidFrom, dstmWin); + Data.ValidUntil = UnixToDateTime(ValidUntil, dstmWin); - // Apply non-proxy-specific settings regardless of exceptions: - if (compression) - *compression = Data->Compression; + TWebDAVFileSystem * FileSystem = static_cast(UserData); + + return FileSystem->VerifyCertificate(Data) ? NE_OK : NE_ERROR; +} +//------------------------------------------------------------------------------ +int TWebDAVFileSystem::NeonRequestAuth( + void * UserData, const char * /*Realm*/, int /*Attempt*/, char * UserName, char * Password) +{ + TWebDAVFileSystem * FileSystem = static_cast(UserData); - int l_debug = Configuration->ActualLogProtocol >= 1 ? 1 : 0; - *pk11_provider = ""; + TTerminal * Terminal = FileSystem->FTerminal; + TSessionData * SessionData = Terminal->SessionData; - *ssl_authority_file = apr_pstrdup(pool, AnsiString(Data->PublicKeyFile).c_str()); + bool Result = true; + // will ask for username only once + if (FileSystem->FUserName.IsEmpty()) { - int l_proxy_port = Data->ProxyPort; - if (l_proxy_port < 0) + if (!SessionData->UserName.IsEmpty()) { - return webdav::error_create(WEBDAV_ERR_ILLEGAL_URL, NULL, - "Invalid URL: negative proxy port number"); + FileSystem->FUserName = SessionData->UserNameExpanded; } - if (l_proxy_port > 65535) + else { - return webdav::error_create(WEBDAV_ERR_ILLEGAL_URL, NULL, - "Invalid URL: proxy port number greater " - "than maximum TCP port number 65535"); + if (!Terminal->PromptUser(SessionData, pkUserName, LoadStr(USERNAME_TITLE), L"", + LoadStr(USERNAME_PROMPT2), true, NE_ABUFSIZ, FileSystem->FUserName)) + { + // note that we never get here actually + Result = false; + } } - *proxy_port = l_proxy_port; } + UnicodeString APassword; + if (Result) { - int l_timeout = Data->Timeout; - if (l_timeout < 0) - return webdav::error_create(WEBDAV_ERR_BAD_CONFIG_VALUE, NULL, - "Invalid config: negative timeout value"); - *timeout_seconds = l_timeout; - } + // Some servers (Gallery2 on https://g2.pixi.me/w/webdav/) + // return authentication error (401) on PROPFIND request for + // non-existing files. + // When we already tried stored password before, do not try anymore. + // When we did not try stored password before (possible only when + // server does not require authentication for any previous request, + // such as when read access is not authenticated), try it now, + // but use special flag for the try, because when it fails + // we still want to try password for future requests (such as PUT). - if (l_debug) - { - *neon_debug = l_debug; - if (Configuration->LogToFile) + if (!SessionData->Password.IsEmpty() && !FileSystem->FStoredPasswordTried && + (FileSystem->FIgnoreAuthenticationFailure != iafPasswordTried)) { - WEBDAV_ERR(webdav::path_cstring_to_utf8(neon_debug_file_name, - AnsiString(GetExpandedLogFileName( - Configuration->LogFileName, - Data)).c_str(), pool)); + APassword = SessionData->Password; + if (FileSystem->FIgnoreAuthenticationFailure == iafNo) + { + FileSystem->FStoredPasswordTried = true; + } + else + { + FileSystem->FIgnoreAuthenticationFailure = iafPasswordTried; + } + } + else if (((FileSystem->FIgnoreAuthenticationFailure == iafWaiting) && + FileSystem->FStoredPasswordTried) || + (FileSystem->FIgnoreAuthenticationFailure == iafPasswordTried)) + { + // Fail PROPFIND /nonexising request... + Result = false; + // .... but that resets neon internal password store, so we need to make sure + // we provide the password again the next time. + FileSystem->FStoredPasswordTried = false; } else { - *neon_debug_file_name = NULL; + // asking for password everytime + if (Terminal->PromptUser(SessionData, pkPassword, LoadStr(PASSWORD_TITLE), L"", + LoadStr(PASSWORD_PROMPT), false, NE_ABUFSIZ, APassword)) + { + if (FileSystem->FIgnoreAuthenticationFailure != iafNo) + { + FileSystem->FIgnoreAuthenticationFailure = iafPasswordTried; + } + } + else + { + // note that we never get here actually + Result = false; + } } } - else + + if (Result) { - *neon_debug = 0; - *neon_debug_file_name = NULL; + strncpy(UserName, StrToNeon(FileSystem->FUserName), NE_ABUFSIZ); + strncpy(Password, StrToNeon(APassword), NE_ABUFSIZ); } - return WEBDAV_NO_ERROR; -} + FileSystem->FAuthenticationRequested = true; -webdav::error_t TWebDAVFileSystem::VerifyCertificate( - const char * Prompt, const char * fingerprint, - unsigned int & RequestResult) -{ - RequestResult = 0; - TClipboardHandler ClipboardHandler; - ClipboardHandler.Text = fingerprint; - - TQueryButtonAlias Aliases[1]; - Aliases[0].Button = qaRetry; - Aliases[0].Alias = LoadStr(COPY_KEY_BUTTON); - Aliases[0].OnClick = &ClipboardHandler.Copy; - - TQueryParams Params; - Params.HelpKeyword = HELP_VERIFY_CERTIFICATE; - Params.NoBatchAnswers = qaYes | qaRetry; - Params.Aliases = Aliases; - Params.AliasesCount = LENOF(Aliases); - unsigned int Answer = FTerminal->QueryUser( - FMTLOAD(VERIFY_CERT_PROMPT3, (UnicodeString(Prompt).c_str())), - NULL, qaYes | qaNo | qaCancel | qaRetry, &Params, qtWarning); - RequestResult = Answer; - switch (RequestResult) - { - case qaCancel: - FTerminal->Configuration->Usage->Inc(L"HostNotVerified"); - FFileTransferCancelled = true; - FFileTransferAbort = ftaCancel; - break; - } - return WEBDAV_NO_ERROR; + return Result ? 0 : -1; } - -webdav::error_t TWebDAVFileSystem::AskForClientCertificateFilename( - const char ** cert_file, unsigned int & RequestResult, - apr_pool_t * pool) +//------------------------------------------------------------------------------ +int TWebDAVFileSystem::NeonProxyAuth( + void * UserData, const char * /*Realm*/, int Attempt, char * UserName, char * Password) { - RequestResult = 0; - TSessionData * Data = FTerminal->SessionData; - UnicodeString FileName; - if (!FTerminal->PromptUser(Data, pkFileName, LoadStr(CERT_FILENAME_PROMPT_TITLE), L"", - LoadStr(CERT_FILENAME_PROMPT), true, 0, FileName)) - { - FFileTransferCancelled = true; - FFileTransferAbort = ftaCancel; - return WEBDAV_ERR_CANCELLED; - } - WEBDAV_ERR(webdav::path_cstring_to_utf8(cert_file, AnsiString(FileName).c_str(), pool)); - RequestResult = qaOK; - return WEBDAV_NO_ERROR; -} + TWebDAVFileSystem * FileSystem = static_cast(UserData); + TSessionData * SessionData = FileSystem->FTerminal->SessionData; -webdav::error_t TWebDAVFileSystem::AskForUsername( - const char ** user_name, unsigned int & RequestResult, - apr_pool_t * pool) -{ - RequestResult = 0; - TSessionData * Data = FTerminal->SessionData; - UnicodeString UserName = Data->UserNameExpanded; - if (!FTerminal->PromptUser(Data, pkUserName, LoadStr(USERNAME_TITLE), L"", - LoadStr(USERNAME_PROMPT2), true, 0, UserName)) + int Result; + // no point trying too many times as we always return the same credentials + // (maybe just one would be enough) + if (Attempt >= 2) { - FFileTransferCancelled = true; - FFileTransferAbort = ftaCancel; - return WEBDAV_ERR_CANCELLED; + Result = 1; } - WEBDAV_ERR(webdav::path_cstring_to_utf8(user_name, AnsiString(UserName).c_str(), pool)); - RequestResult = qaOK; - return WEBDAV_NO_ERROR; -} - -webdav::error_t TWebDAVFileSystem::AskForUserPassword( - const char ** password, - unsigned int & RequestResult, - apr_pool_t * pool) -{ - RequestResult = 0; - TSessionData * Data = FTerminal->SessionData; - UnicodeString Password = Data->Password; - if (!FTerminal->PromptUser(Data, pkPassword, LoadStr(PASSWORD_TITLE), L"", - LoadStr(PASSWORD_PROMPT), false, 0, Password)) + else { - FFileTransferCancelled = true; - FFileTransferAbort = ftaCancel; - return WEBDAV_ERR_CANCELLED; + strncpy(UserName, StrToNeon(SessionData->ProxyUsername), NE_ABUFSIZ); + strncpy(Password, StrToNeon(SessionData->ProxyPassword), NE_ABUFSIZ); + Result = 0; } - WEBDAV_ERR(webdav::path_cstring_to_utf8(password, AnsiString(Password).c_str(), pool)); - RequestResult = qaOK; - return WEBDAV_NO_ERROR; -} + return Result; +} //------------------------------------------------------------------------------ -webdav::error_t TWebDAVFileSystem::AskForPassphrase( - const char ** passphrase, - const char * realm, - unsigned int & RequestResult, - apr_pool_t * pool) +void TWebDAVFileSystem::NeonNotifier(void * UserData, ne_session_status Status, const ne_session_status_info * StatusInfo) { - RequestResult = 0; - TSessionData * Data = FTerminal->SessionData; - UnicodeString Passphrase = Data->UserNameExpanded; - UnicodeString Prompt = FORMAT(LoadStr(PROMPT_KEY_PASSPHRASE), (UnicodeString(realm))); - if (!FTerminal->PromptUser(Data, pkPassphrase, LoadStr(PASSPHRASE_TITLE), L"", - Prompt, false, 0, Passphrase)) - { - FFileTransferCancelled = true; - FFileTransferAbort = ftaCancel; - return WEBDAV_ERR_CANCELLED; - } - WEBDAV_ERR(webdav::path_cstring_to_utf8(passphrase, AnsiString(Passphrase).c_str(), pool)); - RequestResult = qaOK; - return WEBDAV_NO_ERROR; -} + TWebDAVFileSystem * FileSystem = static_cast(UserData); + TFileOperationProgressType * OperationProgress = FileSystem->FTerminal->OperationProgress; -webdav::error_t TWebDAVFileSystem::SimplePrompt( - const char * prompt_text, - const char * prompt_string, - unsigned int & RequestResult) -{ - RequestResult = 0; - TStrings * MoreMessages = new TStringList(); - try - { - MoreMessages->Add(UnicodeString(prompt_string)); - unsigned int Answer = FTerminal->QueryUser( - UnicodeString(prompt_text), - MoreMessages, qaYes | qaNo | qaCancel, NULL, qtConfirmation); - RequestResult = Answer; - } - __finally + // We particularly have to filter out response to "put" request, + // handling that would reset the upload progress back to low number (response is small). + if (((FileSystem->FUploading && (Status == ne_status_sending)) || + (FileSystem->FDownloading && (Status == ne_status_recving))) && + ALWAYS_TRUE(OperationProgress != NULL)) { - delete MoreMessages; - } - return RequestResult == qaCancel ? WEBDAV_ERR_CANCELLED : WEBDAV_NO_ERROR; -} + __int64 Progress = StatusInfo->sr.progress; + __int64 Diff = Progress - OperationProgress->TransferedSize; -webdav::error_t TWebDAVFileSystem::CreateStorage( - THierarchicalStorage *& Storage) -{ - Storage = - FTerminal->Configuration->CreateScpStorage(false); - return WEBDAV_NO_ERROR; -} + if (Diff > 0) + { + OperationProgress->ThrottleToCPSLimit(static_cast(Diff)); + } + + __int64 Total = StatusInfo->sr.total; -unsigned long TWebDAVFileSystem::AdjustToCPSLimit(unsigned long len) + // Total size unknown + if (Total < 0) + { + if (Diff >= 0) + { + OperationProgress->AddTransfered(Diff); + } + else + { + // Session total has been reset. A new stream started + OperationProgress->AddTransfered(Progress); + } + } + else + { + OperationProgress->SetTransferSize(Total); + OperationProgress->AddTransfered(Diff); + } + } +} +//------------------------------------------------------------------------------ +void __fastcall TWebDAVFileSystem::NeonDebug(const UnicodeString & Message) { - return FCurrentOperationProgress ? FCurrentOperationProgress->AdjustToCPSLimit(len) : len; + FTerminal->LogEvent(Message); } - -bool TWebDAVFileSystem::GetIsCancelled() +//------------------------------------------------------------------------------ +void __fastcall TWebDAVFileSystem::InitSslSession(ssl_st * Ssl) { - TFileOperationProgressType * OperationProgress = FCurrentOperationProgress; - return (OperationProgress && OperationProgress->Cancel == csCancel); + // See also CAsyncSslSocketLayer::InitSSLConnection + TSessionData * Data = FTerminal->SessionData; + #define MASK_TLS_VERSION(VERSION, FLAG) ((Data->MinTlsVersion > VERSION) || (Data->MaxTlsVersion < VERSION) ? FLAG : 0) + int Options = + MASK_TLS_VERSION(ssl2, SSL_OP_NO_SSLv2) | + MASK_TLS_VERSION(ssl3, SSL_OP_NO_SSLv3) | + MASK_TLS_VERSION(tls10, SSL_OP_NO_TLSv1) | + MASK_TLS_VERSION(tls11, SSL_OP_NO_TLSv1_1) | + MASK_TLS_VERSION(tls12, SSL_OP_NO_TLSv1_2); + // SSL_ctrl() with SSL_CTRL_OPTIONS adds flags (not sets) + SSL_ctrl(Ssl, SSL_CTRL_OPTIONS, Options, NULL); } //------------------------------------------------------------------------------ diff --git a/source/core/WebDAVFileSystem.h b/source/core/WebDAVFileSystem.h index f6d7f691..7a4342db 100644 --- a/source/core/WebDAVFileSystem.h +++ b/source/core/WebDAVFileSystem.h @@ -1,25 +1,23 @@ +//------------------------------------------------------------------------------ #ifndef WebDavFileSystemH #define WebDavFileSystemH -#include - -#include -#include "Terminal.h" - -//------------------------------------------------------------------------------ -struct TListDataEntry; -struct TFileTransferData; //------------------------------------------------------------------------------ -namespace webdav { - struct session_t; - typedef int error_t; -} // namespace webdav +#include +#include +#include +#include +#include //------------------------------------------------------------------------------ +struct TWebDAVCertificateData; +struct ne_ssl_certificate_s; +struct ne_session_s; +struct ne_prop_result_set_s; +struct TOverwriteFileParams; +struct ssl_st; //------------------------------------------------------------------------------ class TWebDAVFileSystem : public TCustomFileSystem { - friend class TWebDAVFileListHelper; - public: explicit TWebDAVFileSystem(TTerminal * ATerminal); virtual __fastcall ~TWebDAVFileSystem(); @@ -70,7 +68,6 @@ class TWebDAVFileSystem : public TCustomFileSystem const UnicodeString NewName); virtual void __fastcall CopyFile(const UnicodeString FileName, const UnicodeString NewName); - virtual UnicodeString __fastcall FileUrl(const UnicodeString FileName); virtual TStrings * __fastcall GetFixedPaths(); virtual void __fastcall SpaceAvailable(const UnicodeString Path, TSpaceAvailable & ASpaceAvailable); @@ -80,136 +77,101 @@ class TWebDAVFileSystem : public TCustomFileSystem virtual bool __fastcall GetStoredCredentialsTried(); virtual UnicodeString __fastcall GetUserName(); -public: - virtual void __fastcall ReadDirectoryProgress(__int64 Bytes); - virtual void __fastcall FileTransferProgress(__int64 TransferSize, __int64 Bytes); + void __fastcall NeonDebug(const UnicodeString & Message); + void __fastcall InitSslSession(ssl_st * Ssl); protected: - enum TOverwriteMode { omOverwrite, omResume }; - virtual UnicodeString __fastcall GetCurrentDirectory(); - bool __fastcall HandleListData(const wchar_t * Path, const TListDataEntry * Entries, - unsigned int Count); - void __fastcall EnsureLocation(); - void __fastcall DoChangeDirectory(const UnicodeString Directory); - void __fastcall Sink(const UnicodeString FileName, const TRemoteFile * File, const UnicodeString TargetDir, const TCopyParamType * CopyParam, int Params, TFileOperationProgressType * OperationProgress, unsigned int Flags, - TDownloadSessionAction & Action); + TDownloadSessionAction & Action, bool & ChildError); void __fastcall SinkRobust(const UnicodeString FileName, const TRemoteFile * File, const UnicodeString TargetDir, const TCopyParamType * CopyParam, int Params, TFileOperationProgressType * OperationProgress, unsigned int Flags); void __fastcall SinkFile(const UnicodeString FileName, const TRemoteFile * File, void * Param); - void __fastcall WebDAVSourceRobust(const UnicodeString FileName, + void __fastcall SourceRobust(const UnicodeString FileName, const UnicodeString TargetDir, const TCopyParamType * CopyParam, int Params, TFileOperationProgressType * OperationProgress, unsigned int Flags); - void __fastcall WebDAVSource(const UnicodeString FileName, + void __fastcall Source(const UnicodeString FileName, const UnicodeString TargetDir, const TCopyParamType * CopyParam, int Params, TFileOperationProgressType * OperationProgress, unsigned int Flags, - TUploadSessionAction & Action); - void __fastcall WebDAVDirectorySource(const UnicodeString DirectoryName, + TUploadSessionAction & Action, bool & ChildError); + void __fastcall DirectorySource(const UnicodeString DirectoryName, const UnicodeString TargetDir, int Attrs, const TCopyParamType * CopyParam, int Params, TFileOperationProgressType * OperationProgress, unsigned int Flags); - bool __fastcall ConfirmOverwrite(UnicodeString & FileName, - TOverwriteMode & OverwriteMode, TFileOperationProgressType * OperationProgress, + void __fastcall ConfirmOverwrite(const UnicodeString & FullFileName, UnicodeString & FileName, + TFileOperationProgressType * OperationProgress, const TOverwriteFileParams * FileParams, const TCopyParamType * CopyParam, - int Params, bool AutoResume, unsigned int &Answer); - void __fastcall ResetFileTransfer(); - void __fastcall DoFileTransferProgress(__int64 TransferSize, __int64 Bytes); - void __fastcall DoReadDirectory(TRemoteFileList * FileList); - void __fastcall FileTransfer(const UnicodeString FileName, const UnicodeString LocalFile, - const UnicodeString RemoteFile, const UnicodeString RemotePath, bool Get, - __int64 Size, int Type, TFileTransferData & UserData, - TFileOperationProgressType * OperationProgress); + int Params); + void __fastcall CheckStatus(int NeonStatus); + void __fastcall ClearNeonError(); + static void NeonPropsResult( + void * UserData, const ne_uri * Uri, const ne_prop_result_set_s * Results); + void __fastcall ParsePropResultSet(TRemoteFile * File, + const UnicodeString & Path, const ne_prop_result_set_s * Results); + void __fastcall TryOpenDirectory(UnicodeString Directory); + static int NeonBodyReader(void * UserData, const char * Buf, size_t Len); + static void NeonPreSend(ne_request * Request, void * UserData, ne_buffer * Header); + static int NeonBodyAccepter(void * UserData, ne_request * Request, const ne_status * Status); + static void NeonCreateRequest(ne_request * Request, void * UserData, const char * Method, const char * Uri); + static int NeonRequestAuth(void * UserData, const char * Realm, int Attempt, char * UserName, char * Password); + void NeonOpen(UnicodeString & CorrectedUrl, const UnicodeString & Url); + void NeonClientOpenSessionInternal(UnicodeString & CorrectedUrl, UnicodeString Url); + static int NeonProxyAuth( + void * UserData, const char * Realm, int Attempt, char * UserName, char * Password); + static void NeonNotifier(void * UserData, ne_session_status Status, const ne_session_status_info * StatusInfo); + static ssize_t NeonUploadBodyProvider(void * UserData, char * Buffer, size_t BufLen); + static int NeonPostSend(ne_request * Req, void * UserData, const ne_status * Status); + void ExchangeCapabilities(const char * Path, UnicodeString & CorrectedUrl); + static int NeonServerSSLCallback(void * UserData, int Failures, const struct ne_ssl_certificate_s * Certificate); + void __fastcall CloseNeonSession(); + bool __fastcall CancelTransfer(); + UnicodeString __fastcall GetNeonError(); + static void NeonQuotaResult(void * UserData, const ne_uri * Uri, const ne_prop_result_set_s * Results); + static const char * __fastcall GetProp(const ne_prop_result_set_s * Results, const char * Name); private: TFileSystemInfo FFileSystemInfo; UnicodeString FCurrentDirectory; - TRemoteFileList * FFileList; UnicodeString FCachedDirectoryChange; - TCaptureOutputEvent FOnCaptureOutput; TSessionInfo FSessionInfo; UnicodeString FUserName; - bool FPasswordFailed; bool FActive; - enum { ftaNone, ftaSkip, ftaCancel } FFileTransferAbort; - bool FIgnoreFileList; - bool FFileTransferCancelled; - __int64 FFileTransferResumed; - bool FFileTransferPreserveTime; bool FHasTrailingSlash; - size_t FFileTransferCPSLimit; - size_t FLastReadDirectoryProgress; - TFileOperationProgressType * FCurrentOperationProgress; - TCriticalSection * FTransferStatusCriticalSection; + bool FCancelled; + bool FStoredPasswordTried; + bool FUploading; + bool FDownloading; + ne_session_s * FNeonSession; + bool FInitialHandshake; + bool FAuthenticationRequested; + ne_provide_body FUploadBodyProvider; + void * FUploadBodyProviderUserData; + UnicodeString FResponse; + enum TIgnoreAuthenticationFailure { iafNo, iafWaiting, iafPasswordTried } FIgnoreAuthenticationFailure; -private: - void __fastcall CustomReadFile(const UnicodeString FileName, + void __fastcall CustomReadFile(UnicodeString FileName, TRemoteFile *& File, TRemoteFile * ALinkedByFile); - bool SendPropFindRequest(const wchar_t * dir, int & responseCode); - -private: - bool WebDAVCheckExisting(const wchar_t * path, int & is_dir); - bool WebDAVMakeDirectory(const wchar_t * path); - bool WebDAVGetList(const UnicodeString Directory); - bool WebDAVGetFile(const wchar_t * remotePath, HANDLE * LocalFileHandle); - bool WebDAVPutFile(const wchar_t * remotePath, const wchar_t * localPath, const unsigned __int64 fileSize); - bool WebDAVRenameFile(const wchar_t * srcPath, const wchar_t * dstPath); - bool WebDAVDeleteFile(const wchar_t * path); - -public: - webdav::error_t GetServerSettings( - int * proxy_method, - const char **proxy_host, - unsigned int *proxy_port, - const char **proxy_username, - const char **proxy_password, - int *timeout_seconds, - int *neon_debug, - const char **neon_debug_file_name, - bool *compression, - const char **pk11_provider, - const char **ssl_authority_file, - apr_pool_t *pool); - webdav::error_t VerifyCertificate( - const char * Prompt, const char *fingerprint, - unsigned int & RequestResult); - webdav::error_t AskForClientCertificateFilename( - const char **cert_file, unsigned int & RequestResult, - apr_pool_t *pool); - webdav::error_t AskForUsername( - const char **user_name, - unsigned int & RequestResult, - apr_pool_t *pool); - webdav::error_t AskForUserPassword( - const char **password, - unsigned int & RequestResult, - apr_pool_t *pool); - webdav::error_t AskForPassphrase( - const char **passphrase, - const char *realm, - unsigned int & RequestResult, - apr_pool_t *pool); - webdav::error_t SimplePrompt( - const char *prompt_text, - const char *prompt_string, - unsigned int & RequestResult); - webdav::error_t CreateStorage(THierarchicalStorage *& Storage); - unsigned long AdjustToCPSLimit(unsigned long len); - bool GetIsCancelled(); -private: - webdav::error_t OpenURL(const UnicodeString & repos_URL, - apr_pool_t *pool); -private: - apr_pool_t *webdav_pool; - webdav::session_t *FSession; -private: - TWebDAVFileSystem(const TWebDAVFileSystem &); - TWebDAVFileSystem & operator=(const TWebDAVFileSystem &); + int __fastcall CustomReadFileInternal(const UnicodeString FileName, + TRemoteFile *& File, TRemoteFile * ALinkedByFile); + void __fastcall RegisterForDebug(); + void __fastcall UnregisterFromDebug(); + bool VerifyCertificate( + const TWebDAVCertificateData & Data); + void OpenUrl(const UnicodeString & Url); + void __fastcall CollectTLSSessionInfo(); + UnicodeString __fastcall GetRedirectUrl(); + UnicodeString __fastcall ParsePathFromUrl(const UnicodeString & Url); + int __fastcall ReadDirectoryInternal(const UnicodeString & Path, TRemoteFileList * FileList); + bool __fastcall IsValidRedirect(int NeonStatus, UnicodeString & Path); + UnicodeString __fastcall DirectoryPath(UnicodeString Path); }; - +//------------------------------------------------------------------------------ +void __fastcall NeonInitialize(); +void __fastcall NeonFinalize(); +//------------------------------------------------------------------------------ #endif diff --git a/source/filezilla/AsyncProxySocketLayer.cpp b/source/filezilla/AsyncProxySocketLayer.cpp index 6f4546c5..9bb2b2c3 100644 --- a/source/filezilla/AsyncProxySocketLayer.cpp +++ b/source/filezilla/AsyncProxySocketLayer.cpp @@ -849,8 +849,10 @@ BOOL CAsyncProxySocketLayer::Connect( LPCTSTR lpszHostAddress, UINT nHostPort ) BOOL CAsyncProxySocketLayer::Connect( const SOCKADDR* lpSockAddr, int nSockAddrLen ) { if (!m_ProxyData.nProxyType) + { //Connect normally because there is no proxy return ConnectNext(lpSockAddr, nSockAddrLen ); + } LPSOCKADDR_IN sockAddr=(LPSOCKADDR_IN)lpSockAddr; diff --git a/source/filezilla/AsyncSocketEx.cpp b/source/filezilla/AsyncSocketEx.cpp index da86ba23..3019fae9 100644 --- a/source/filezilla/AsyncSocketEx.cpp +++ b/source/filezilla/AsyncSocketEx.cpp @@ -285,7 +285,9 @@ class CAsyncSocketExHelperWindow } for (std::list::iterator iter = msgList.begin(); iter != msgList.end(); iter++) + { PostMessage(m_hWnd, iter->message, iter->wParam, iter->lParam); + } } //Processes event notifications sent by the sockets or the layers @@ -331,7 +333,9 @@ class CAsyncSocketExHelperWindow break; } else if (pSocket->GetState() == attached) + { pSocket->SetState(connected); + } if (pSocket->GetState() != connected) break; @@ -348,7 +352,9 @@ class CAsyncSocketExHelperWindow nErrorCode = WSAGetLastError(); #ifndef NOSOCKETSTATES if (nErrorCode) + { pSocket->SetState(aborted); + } #endif //NOSOCKETSTATES if (nBytes != 0 || nErrorCode != 0) pSocket->OnReceive(nErrorCode); @@ -362,7 +368,9 @@ class CAsyncSocketExHelperWindow break; } else if (pSocket->GetState() == attached) + { pSocket->SetState(connected); + } if (pSocket->GetState() != connected) break; #endif //NOSOCKETSTATES @@ -370,7 +378,9 @@ class CAsyncSocketExHelperWindow { #ifndef NOSOCKETSTATES if (nErrorCode) + { pSocket->SetState(aborted); + } #endif //NOSOCKETSTATES pSocket->OnReceive(nErrorCode); } @@ -383,7 +393,9 @@ class CAsyncSocketExHelperWindow break; } else if (pSocket->GetState() == attached && !nErrorCode) + { pSocket->SetState(connected); + } if (pSocket->GetState() != connected) break; #endif //NOSOCKETSTATES @@ -391,7 +403,9 @@ class CAsyncSocketExHelperWindow { #ifndef NOSOCKETSTATES if (nErrorCode) + { pSocket->SetState(aborted); + } #endif //NOSOCKETSTATES pSocket->OnSend(nErrorCode); } @@ -408,7 +422,9 @@ class CAsyncSocketExHelperWindow pSocket->SetState(connected); } else if (pSocket->GetState() == attached && !nErrorCode) + { pSocket->SetState(connected); + } #endif //NOSOCKETSTATES if (pSocket->m_lEvent & FD_CONNECT) pSocket->OnConnect(nErrorCode); @@ -539,7 +555,9 @@ class CAsyncSocketExHelperWindow break; } else if (pSocket->GetState() == attached && !nErrorCode) + { pSocket->SetState(connected); + } if (pSocket->GetState() != connected) break; #endif //NOSOCKETSTATES @@ -547,7 +565,9 @@ class CAsyncSocketExHelperWindow { #ifndef NOSOCKETSTATES if (nErrorCode) + { pSocket->SetState(aborted); + } #endif //NOSOCKETSTATES pSocket->OnReceive(nErrorCode); } @@ -560,7 +580,9 @@ class CAsyncSocketExHelperWindow break; } else if (pSocket->GetState() == attached && !nErrorCode) + { pSocket->SetState(connected); + } if (pSocket->GetState() != connected) break; #endif //NOSOCKETSTATES @@ -568,7 +590,9 @@ class CAsyncSocketExHelperWindow { #ifndef NOSOCKETSTATES if (nErrorCode) + { pSocket->SetState(aborted); + } #endif //NOSOCKETSTATES pSocket->OnReceive(nErrorCode); } @@ -581,7 +605,9 @@ class CAsyncSocketExHelperWindow break; } else if (pSocket->GetState() == attached && !nErrorCode) + { pSocket->SetState(connected); + } if (pSocket->GetState() != connected) break; #endif //NOSOCKETSTATES @@ -589,7 +615,9 @@ class CAsyncSocketExHelperWindow { #ifndef NOSOCKETSTATES if (nErrorCode) + { pSocket->SetState(aborted); + } #endif //NOSOCKETSTATES pSocket->OnSend(nErrorCode); } @@ -597,9 +625,13 @@ class CAsyncSocketExHelperWindow case FD_CONNECT: #ifndef NOSOCKETSTATES if (pSocket->GetState() == connecting) + { pSocket->SetState(connected); + } else if (pSocket->GetState() == attached && !nErrorCode) + { pSocket->SetState(connected); + } #endif //NOSOCKETSTATES if (pSocket->m_lEvent & FD_CONNECT) pSocket->OnConnect(nErrorCode); @@ -806,7 +838,9 @@ BOOL CAsyncSocketEx::Create(UINT nSocketPort /*=0*/, int nSocketType /*=SOCK_STR BOOL res = m_pFirstLayer->Create(nSocketPort, nSocketType, lEvent, lpszSocketAddress, nFamily); #ifndef NOSOCKETSTATES if (res) + { SetState(unconnected); + } #endif //NOSOCKETSTATES return res; } @@ -1179,7 +1213,9 @@ BOOL CAsyncSocketEx::Connect(LPCTSTR lpszHostAddress, UINT nHostPort) BOOL res = m_pFirstLayer->Connect(lpszHostAddress, nHostPort); #ifndef NOSOCKETSTATES if (res || GetLastError()==WSAEWOULDBLOCK) + { SetState(connecting); + } #endif //NOSOCKETSTATES return res; } else @@ -1347,7 +1383,9 @@ BOOL CAsyncSocketEx::Connect(const SOCKADDR* lpSockAddr, int nSockAddrLen) #ifndef NOSOCKETSTATES if (res || GetLastError()==WSAEWOULDBLOCK) + { SetState(connecting); + } #endif //NOSOCKETSTATES return res; } @@ -1622,7 +1660,9 @@ BOOL CAsyncSocketEx::TriggerEvent(long lEvent) } else #endif //NOLAYERS + { return PostMessage(GetHelperWindowHandle(), m_SocketData.nSocketIndex+WM_SOCKETEX_NOTIFY, m_SocketData.hSocket, lEvent%0xFFFF); + } } @@ -1845,7 +1885,9 @@ void CAsyncSocketEx::AddCallbackNotification(const t_callbackMsg& msg) m_pendingCallbacks.push_back(msg); if(m_pendingCallbacks.size() == 1 && m_SocketData.nSocketIndex != -1) + { PostMessage(GetHelperWindowHandle(), WM_USER + 2, (WPARAM)m_SocketData.nSocketIndex, 0); + } } #endif //NOLAYERS diff --git a/source/filezilla/AsyncSocketExLayer.cpp b/source/filezilla/AsyncSocketExLayer.cpp index c9b1f534..b3a56a1e 100644 --- a/source/filezilla/AsyncSocketExLayer.cpp +++ b/source/filezilla/AsyncSocketExLayer.cpp @@ -191,12 +191,16 @@ BOOL CAsyncSocketExLayer::TriggerEvent(long lEvent, int nErrorCode, BOOL bPassTh { ASSERT(m_pOwnerSocket); if (m_pOwnerSocket->m_SocketData.hSocket==INVALID_SOCKET) + { return FALSE; + } if (!bPassThrough) { if (m_nPendingEvents & lEvent) + { return TRUE; + } m_nPendingEvents |= lEvent; } @@ -205,7 +209,9 @@ BOOL CAsyncSocketExLayer::TriggerEvent(long lEvent, int nErrorCode, BOOL bPassTh { ASSERT(bPassThrough); if (!nErrorCode) + { ASSERT(bPassThrough && (GetLayerState()==connected || GetLayerState()==attached)); + } else if (nErrorCode) { SetLayerState(aborted); @@ -215,7 +221,9 @@ BOOL CAsyncSocketExLayer::TriggerEvent(long lEvent, int nErrorCode, BOOL bPassTh else if (lEvent & FD_CLOSE) { if (!nErrorCode) + { SetLayerState(closed); + } else { SetLayerState(aborted); @@ -231,7 +239,9 @@ BOOL CAsyncSocketExLayer::TriggerEvent(long lEvent, int nErrorCode, BOOL bPassTh pMsg->pLayer=bPassThrough?m_pPrevLayer:this; BOOL res=PostMessage(m_pOwnerSocket->GetHelperWindowHandle(), WM_USER, (WPARAM)m_pOwnerSocket->m_SocketData.nSocketIndex, (LPARAM)pMsg); if (!res) + { delete pMsg; + } return res; } @@ -285,7 +295,8 @@ int CAsyncSocketExLayer::SendNext(const void *lpBuf, int nBufLen, int nFlags /*= if (!m_pNextLayer) { ASSERT(m_pOwnerSocket); - return send(m_pOwnerSocket->GetSocketHandle(), (LPSTR)lpBuf, nBufLen, nFlags); + int sent = send(m_pOwnerSocket->GetSocketHandle(), (LPSTR)lpBuf, nBufLen, nFlags); + return sent; } else { @@ -925,7 +936,7 @@ BOOL CAsyncSocketExLayer::ShutDownNext(int nHow /*=sends*/) if (!m_pNextLayer) { ASSERT(m_pOwnerSocket); - return shutdown(m_pOwnerSocket->GetSocketHandle(), nHow); + return (shutdown(m_pOwnerSocket->GetSocketHandle(), nHow) == 0); } else { diff --git a/source/filezilla/AsyncSslSocketLayer.cpp b/source/filezilla/AsyncSslSocketLayer.cpp index 138a921d..cef3a4a0 100644 --- a/source/filezilla/AsyncSslSocketLayer.cpp +++ b/source/filezilla/AsyncSslSocketLayer.cpp @@ -17,7 +17,7 @@ CAsyncSslSocketLayer to your socket and call InitClientSsl after creation of the This class only has a couple of public functions: - InitSSLConnection(bool clientMode); - This functions establishes an SSL connection. The clientMode parameter specifies wether the SSL connection + This functions establishes an SSL connection. The clientMode parameter specifies whether the SSL connection is in server or in client mode. Most likely you want to call this function right after calling Create for the socket. But sometimes, you'll need to call this function later. One example is for an FTP connection @@ -43,7 +43,6 @@ Valid notification IDs are: connection failed. Valid values for param2 are: - SSL_FAILURE_UNKNOWN 0 - Details may have been sent with a SSL_VERBOSE_* notification. - SSL_FAILURE_ESTABLISH 1 - Problem during SSL negotiation - - SSL_FAILURE_LOADDLLS 2 - SSL_FAILURE_INITSSL 4 - SSL_FAILURE_VERIFYCERT 8 - The remote SSL certificate was invalid - SSL_FAILURE_CERTREJECTED 16 - The remote SSL certificate was rejected by user @@ -90,145 +89,8 @@ Version 2.0: static char THIS_FILE[] = __FILE__; #endif -// Simple macro to declare function type and function pointer based on the -// three given parametrs: -// r - return type, -// n - function name -// a - argument list -// -// Example: -// def(int, foo, (int x)) becomes the following: -// typedef int (*tfoo)(int x); -// static tfoo pfoo; - -#define def(r, n, a) \ - typedef r (*t##n) a; \ - static t##n p##n; - -// Macro to load the given macro from a dll: -#ifdef MPEXT_NO_SSLDLL -#include -#define load(dll, n) \ - p##n = n; -#else -#define load(dll, n) \ - p##n = (t##n) GetProcAddress(dll, #n); \ - if (!p##n) \ - bError = true; -#endif #include - -//The following functions from the SSL libraries are used: -def(int, SSL_state, (const SSL *s)); -def(const char*, SSL_state_string_long, (const SSL *s)); -def(void, SSL_set_info_callback, (SSL *ssl, void (*cb)(const SSL *ssl,int type,int val))); -def(void, SSL_set_bio, (SSL *s, BIO *rbio, BIO *wbio)); -def(void, SSL_set_connect_state, (SSL *s)); -def(int, SSL_set_session, (SSL *to, SSL_SESSION *session)); -def(BIO_METHOD*, BIO_f_ssl, (void)); -def(SSL*, SSL_new, (SSL_CTX *ctx)); -#ifdef MPEXT -def(SSL_CTX*, SSL_CTX_new, (const SSL_METHOD *meth)); -def(const SSL_METHOD*, SSLv23_method, (void)); -#else -def(SSL_CTX*, SSL_CTX_new, (SSL_METHOD *meth)); -def(SSL_METHOD*, SSLv23_method, (void)); -#endif -def(void, SSL_load_error_strings, (void)); -def(int, SSL_library_init, (void)); -def(void, SSL_CTX_free, (SSL_CTX *)); -def(void, SSL_free, (SSL *ssl)); -def(int, SSL_get_error, (const SSL *s, int retcode)); -def(int, SSL_shutdown, (SSL *s)); -def(int, SSL_get_shutdown, (const SSL *ssl)); -def(const char*, SSL_alert_type_string_long, (int value)); -def(const char*, SSL_alert_desc_string_long, (int value)); -def(void, SSL_CTX_set_verify, (SSL_CTX *ctx, int mode, int (*callback)(int, X509_STORE_CTX *))); -def(X509_STORE*, SSL_CTX_get_cert_store, (const SSL_CTX *)); -def(long, SSL_get_verify_result, (const SSL *ssl)); -def(X509*, SSL_get_peer_certificate, (const SSL *s)); -def(const char*, SSL_get_version, (const SSL *ssl)); -#ifdef MPEXT -def(const SSL_CIPHER*, SSL_get_current_cipher, (const SSL *ssl)); -#else -def(SSL_CIPHER*, SSL_get_current_cipher, (const SSL *ssl)); -#endif -def(const char*, SSL_CIPHER_get_name, (const SSL_CIPHER *cipher)); -def(char*, SSL_CIPHER_get_version, (const SSL_CIPHER *cipher)); -def(int, SSL_get_ex_data_X509_STORE_CTX_idx, (void)); -def(int, SSL_CTX_load_verify_locations, (SSL_CTX *ctx, const char *CAfile, const char *CApath)); -def(long, SSL_ctrl, (SSL *ssl, int cmd, long larg, void *parg)); -def(void, SSL_set_accept_state, (SSL *ssl)); -def(int, SSL_CTX_use_PrivateKey_file, (SSL_CTX *ctx, const char *file, int type)); -def(int, SSL_CTX_use_certificate_file, (SSL_CTX *ctx, const char *file, int type)); -def(int, SSL_CTX_check_private_key, (const SSL_CTX *ctx)); -def(void, SSL_CTX_set_default_passwd_cb, (SSL_CTX *ctx, pem_password_cb *cb)); -def(void, SSL_CTX_set_default_passwd_cb_userdata, (SSL_CTX *ctx, void *u)); -def(int, SSL_CTX_use_certificate_chain_file, (SSL_CTX *ctx, const char *file)); - -def(size_t, BIO_ctrl_pending, (BIO *b)); -def(int, BIO_read, (BIO *b, void *data, int len)); -def(long, BIO_ctrl, (BIO *bp, int cmd, long larg, void *parg)); -def(int, BIO_write, (BIO *b, const void *data, int len)); -def(size_t, BIO_ctrl_get_write_guarantee, (BIO *b)); -def(int, BIO_new_bio_pair, (BIO **bio1, size_t writebuf1, BIO **bio2, size_t writebuf2)); -def(BIO*, BIO_new, (BIO_METHOD *type)); -def(int, BIO_free, (BIO *a)); -def(int, i2t_ASN1_OBJECT, (char *buf, int buf_len, ASN1_OBJECT *a)); -def(int, OBJ_obj2nid, (const ASN1_OBJECT *o)); -def(ASN1_OBJECT*, X509_NAME_ENTRY_get_object, (X509_NAME_ENTRY *ne)); -def(X509_NAME_ENTRY*, X509_NAME_get_entry, (X509_NAME *name, int loc)); -def(int, X509_NAME_entry_count, (X509_NAME *name)); -def(X509_NAME*, X509_get_subject_name, (X509 *a)); -def(X509_NAME*, X509_get_issuer_name, (X509 *a)); -def(const char*, OBJ_nid2sn, (int n)); -def(ASN1_STRING*, X509_NAME_ENTRY_get_data, (X509_NAME_ENTRY *ne)); -def(void, X509_STORE_CTX_set_error, (X509_STORE_CTX *ctx, int s)); -def(int, X509_digest, (const X509 *data, const EVP_MD *type, unsigned char *md, unsigned int *len)); -def(const EVP_MD*, EVP_sha1, (void)); -def(X509*, X509_STORE_CTX_get_current_cert, (X509_STORE_CTX *ctx)); -def(int, X509_STORE_CTX_get_error, (X509_STORE_CTX *ctx)); -def(void, X509_free, (X509 *a)); -def(EVP_PKEY*, X509_get_pubkey, (X509 *x)); -def(int, BN_num_bits, (const BIGNUM *a)); -def(void, EVP_PKEY_free, (EVP_PKEY *pkey)); -def(void*, X509_STORE_CTX_get_ex_data, (X509_STORE_CTX *ctx, int idx)); -def(char*, X509_NAME_oneline, (X509_NAME *a, char *buf, int size)); -def(const char*, X509_verify_cert_error_string, (long n)); -def(int, X509_STORE_CTX_get_error_depth, (X509_STORE_CTX *ctx)); -def(unsigned long, ERR_get_error, (void)); -#ifdef MPEXT -def(char*, ERR_error_string, (unsigned long e, char *buf)); -#else -def(const char*, ERR_error_string, (unsigned long e, char *buf)); -#endif -def(int, ASN1_STRING_to_UTF8, (unsigned char **out, ASN1_STRING *in)); -def(void, CRYPTO_free, (void *p)); -def(RSA*, RSA_generate_key, (int bits, unsigned long e, void (*callback)(int,int,void *), void *cb_arg)); -def(int, X509_set_version, (X509 *x,long version)); -def(ASN1_TIME*, X509_gmtime_adj, (ASN1_TIME *s, long adj)); -def(int, X509_set_pubkey, (X509 *x, EVP_PKEY *pkey)); -def(int, X509_NAME_add_entry_by_txt, (X509_NAME *name, const char *field, int type, const unsigned char *bytes, int len, int loc, int set)); -def(int, X509_NAME_add_entry_by_NID, (X509_NAME *name, int nid, int type, unsigned char *bytes, int len, int loc, int set)); -def(int, X509_set_issuer_name, (X509 *x, X509_NAME *name)); -def(int, X509_sign, (X509 *x, EVP_PKEY *pkey, const EVP_MD *md)); -def(EVP_PKEY*, EVP_PKEY_new, (void)); -#ifdef MPEXT -def(int, EVP_PKEY_assign, (EVP_PKEY *pkey, int type, void *key)); -#else -def(int, EVP_PKEY_assign, (EVP_PKEY *pkey, int type, char *key)); -#endif -def(X509*, X509_new, (void)); -def(int, ASN1_INTEGER_set, (ASN1_INTEGER *a, long v)); -def(ASN1_INTEGER*, X509_get_serialNumber, (X509 *x)); -#ifdef MPEXT -def(int, PEM_ASN1_write_bio, (i2d_of_void *i2d,const char *name,BIO *bp,void *x, const EVP_CIPHER *enc,unsigned char *kstr,int klen, pem_password_cb *callback, void *u)); -#else -def(int, PEM_ASN1_write_bio, (int (*i2d)(),const char *name,BIO *bp,char *x, const EVP_CIPHER *enc,unsigned char *kstr,int klen, pem_password_cb *callback, void *u)); -#endif -def(int, i2d_X509, (X509 *x, unsigned char **out)); -def(BIO_METHOD *, BIO_s_mem, (void)); -def(int, i2d_PrivateKey, (EVP_PKEY *a, unsigned char **pp)); +#include // Critical section wrapper class #ifndef CCRITICALSECTIONWRAPPERINCLUDED @@ -271,10 +133,6 @@ CCriticalSectionWrapper CAsyncSslSocketLayer::m_sCriticalSection; CAsyncSslSocketLayer::t_SslLayerList* CAsyncSslSocketLayer::m_pSslLayerList = 0; int CAsyncSslSocketLayer::m_nSslRefCount = 0; -#ifndef MPEXT_NO_SSLDLL -HMODULE CAsyncSslSocketLayer::m_hSslDll1 = 0; -HMODULE CAsyncSslSocketLayer::m_hSslDll2 = 0; -#endif std::map CAsyncSslSocketLayer::m_contextRefCount; CAsyncSslSocketLayer::CAsyncSslSocketLayer() @@ -330,160 +188,9 @@ int CAsyncSslSocketLayer::InitSSL() if (!m_nSslRefCount) { -#ifndef MPEXT_NO_SSLDLL - m_hSslDll2= - LoadLibrary(_T("libeay32.dll")); - if (!m_hSslDll2) - { - if (m_hSslDll1) - FreeLibrary(m_hSslDll1); - m_hSslDll1=0; - - m_sCriticalSection.Unlock(); - return SSL_FAILURE_LOADDLLS; - } - - bool bError = false; -#endif - load(m_hSslDll2, BIO_ctrl_pending); - load(m_hSslDll2, BIO_ctrl_pending); - load(m_hSslDll2, BIO_read); - load(m_hSslDll2, BIO_ctrl); - load(m_hSslDll2, BIO_write); - load(m_hSslDll2, BIO_ctrl_get_write_guarantee); - load(m_hSslDll2, BIO_new_bio_pair); - load(m_hSslDll2, BIO_new); - load(m_hSslDll2, BIO_free); - load(m_hSslDll2, i2t_ASN1_OBJECT); - load(m_hSslDll2, OBJ_obj2nid); - load(m_hSslDll2, X509_NAME_ENTRY_get_object); - load(m_hSslDll2, X509_NAME_get_entry); - load(m_hSslDll2, X509_NAME_entry_count); - load(m_hSslDll2, X509_get_subject_name); - load(m_hSslDll2, X509_get_issuer_name); - load(m_hSslDll2, OBJ_nid2sn); - load(m_hSslDll2, X509_NAME_ENTRY_get_data); - load(m_hSslDll2, X509_STORE_CTX_set_error); - load(m_hSslDll2, X509_digest); - load(m_hSslDll2, EVP_sha1); - load(m_hSslDll2, X509_STORE_CTX_get_current_cert); - load(m_hSslDll2, X509_STORE_CTX_get_error); - load(m_hSslDll2, X509_free); - load(m_hSslDll2, X509_get_pubkey); - load(m_hSslDll2, BN_num_bits); - load(m_hSslDll2, EVP_PKEY_free); - load(m_hSslDll2, X509_STORE_CTX_get_ex_data); - load(m_hSslDll2, X509_NAME_oneline); - load(m_hSslDll2, X509_verify_cert_error_string); - load(m_hSslDll2, X509_STORE_CTX_get_error_depth); - load(m_hSslDll2, ERR_get_error); - load(m_hSslDll2, ERR_error_string); - load(m_hSslDll2, ASN1_STRING_to_UTF8); - load(m_hSslDll2, CRYPTO_free); - load(m_hSslDll2, RSA_generate_key); - load(m_hSslDll2, X509_set_version); - load(m_hSslDll2, X509_gmtime_adj); - load(m_hSslDll2, X509_set_pubkey); - load(m_hSslDll2, X509_NAME_add_entry_by_txt); - load(m_hSslDll2, X509_NAME_add_entry_by_NID); - load(m_hSslDll2, X509_set_issuer_name); - load(m_hSslDll2, X509_sign); - load(m_hSslDll2, EVP_PKEY_new); - load(m_hSslDll2, EVP_PKEY_assign); - load(m_hSslDll2, X509_new); - load(m_hSslDll2, ASN1_INTEGER_set); - load(m_hSslDll2, X509_get_serialNumber); - load(m_hSslDll2, PEM_ASN1_write_bio); - load(m_hSslDll2, i2d_X509); - load(m_hSslDll2, BIO_s_mem); - load(m_hSslDll2, i2d_PrivateKey); - -#ifndef MPEXT_NO_SSLDLL - if (bError) - { - FreeLibrary(m_hSslDll1); - m_hSslDll1 = 0; - FreeLibrary(m_hSslDll2); - m_hSslDll2 = 0; - - m_sCriticalSection.Unlock(); - return SSL_FAILURE_LOADDLLS; - } - - m_hSslDll1 = LoadLibrary(_T("ssleay32.dll")); - if (!m_hSslDll1) - { - if (m_hSslDll2) - FreeLibrary(m_hSslDll2); - m_hSslDll2 = NULL; - - m_sCriticalSection.Unlock(); - return SSL_FAILURE_LOADDLLS; - } -#endif - load(m_hSslDll1, SSL_state_string_long); - load(m_hSslDll1, SSL_state); - load(m_hSslDll1, SSL_set_info_callback); - load(m_hSslDll1, SSL_set_bio); - load(m_hSslDll1, SSL_set_connect_state); - load(m_hSslDll1, SSL_set_session); - load(m_hSslDll1, BIO_f_ssl); - load(m_hSslDll1, SSL_new); - load(m_hSslDll1, SSL_CTX_new); - load(m_hSslDll1, SSLv23_method); - load(m_hSslDll1, SSL_load_error_strings); - load(m_hSslDll1, SSL_library_init); - load(m_hSslDll1, SSL_CTX_free); - load(m_hSslDll1, SSL_free); - load(m_hSslDll1, SSL_get_error); - load(m_hSslDll1, SSL_shutdown); - load(m_hSslDll1, SSL_get_shutdown); - load(m_hSslDll1, SSL_alert_type_string_long); - load(m_hSslDll1, SSL_alert_desc_string_long); - load(m_hSslDll1, SSL_CTX_set_verify); - load(m_hSslDll1, SSL_CTX_get_cert_store); - load(m_hSslDll1, SSL_get_verify_result); - load(m_hSslDll1, SSL_get_peer_certificate); - load(m_hSslDll1, SSL_get_version); - load(m_hSslDll1, SSL_get_current_cipher); - load(m_hSslDll1, SSL_CIPHER_get_name); - load(m_hSslDll1, SSL_CIPHER_get_version); - load(m_hSslDll1, SSL_get_ex_data_X509_STORE_CTX_idx); - load(m_hSslDll1, SSL_CTX_load_verify_locations); - load(m_hSslDll1, SSL_ctrl); - load(m_hSslDll1, SSL_set_accept_state); - load(m_hSslDll1, SSL_CTX_use_PrivateKey_file); - load(m_hSslDll1, SSL_CTX_use_certificate_file); - load(m_hSslDll1, SSL_CTX_check_private_key); - load(m_hSslDll1, SSL_CTX_set_default_passwd_cb_userdata); - load(m_hSslDll1, SSL_CTX_set_default_passwd_cb); - load(m_hSslDll1, SSL_CTX_use_certificate_chain_file); - -#ifndef MPEXT_NO_SSLDLL - if (bError) - { - FreeLibrary(m_hSslDll1); - m_hSslDll1=0; - if (m_hSslDll2) - FreeLibrary(m_hSslDll2); - m_hSslDll2=0; - - m_sCriticalSection.Unlock(); - return SSL_FAILURE_LOADDLLS; - } - -#endif - pSSL_load_error_strings(); - if (!pSSL_library_init()) + SSL_load_error_strings(); + if (!SSL_library_init()) { -#ifndef MPEXT_NO_SSLDLL - FreeLibrary(m_hSslDll1); - m_hSslDll1=0; - FreeLibrary(m_hSslDll2); - m_hSslDll2=0; - - m_sCriticalSection.Unlock(); -#endif return SSL_FAILURE_INITSSL; } } @@ -515,7 +222,7 @@ void CAsyncSslSocketLayer::OnReceive(int nErrorCode) m_mayTriggerRead = false; //Get number of bytes we can receive and store in the network input bio - int len = pBIO_ctrl_get_write_guarantee(m_nbio); + int len = BIO_ctrl_get_write_guarantee(m_nbio); if (len > 16384) len = 16384; else if (!len) @@ -532,15 +239,15 @@ void CAsyncSslSocketLayer::OnReceive(int nErrorCode) if (numread > 0) { //Store it in the network input bio and process data - int numwritten = pBIO_write(m_nbio, buffer, numread); - pBIO_ctrl(m_nbio, BIO_CTRL_FLUSH, 0, NULL); + int numwritten = BIO_write(m_nbio, buffer, numread); + BIO_ctrl(m_nbio, BIO_CTRL_FLUSH, 0, NULL); // I have no idea why this call is needed, but without it, connections // will stall. Perhaps it triggers some internal processing. // Also, ignore return value, don't do any error checking. This function // can report errors, even though a later call can succeed. char buffer; - pBIO_read(m_sslbio, &buffer, 0); + BIO_read(m_sslbio, &buffer, 0); } if (!numread) { @@ -560,10 +267,10 @@ void CAsyncSslSocketLayer::OnReceive(int nErrorCode) if (m_pRetrySendBuffer) { - int numwrite = pBIO_write(m_sslbio, m_pRetrySendBuffer, m_nRetrySendBufferLen); + int numwrite = BIO_write(m_sslbio, m_pRetrySendBuffer, m_nRetrySendBufferLen); if (numwrite >= 0) { - pBIO_ctrl(m_sslbio, BIO_CTRL_FLUSH, 0, NULL); + BIO_ctrl(m_sslbio, BIO_CTRL_FLUSH, 0, NULL); delete [] m_pRetrySendBuffer; m_pRetrySendBuffer = 0; } @@ -581,9 +288,9 @@ void CAsyncSslSocketLayer::OnReceive(int nErrorCode) } } - if (!m_nShutDown && pSSL_get_shutdown(m_ssl)) + if (!m_nShutDown && SSL_get_shutdown(m_ssl)) { - size_t pending = pBIO_ctrl_pending(m_sslbio); + size_t pending = BIO_ctrl_pending(m_sslbio); if (pending <= 0) { if (ShutDown() || GetLastError() == WSAEWOULDBLOCK) @@ -647,7 +354,9 @@ void CAsyncSslSocketLayer::OnSend(int nErrorCode) TriggerEvent(FD_CLOSE, nErrorCode, TRUE); } if (numsent == m_nNetworkSendBufferLen) + { m_nNetworkSendBufferLen = 0; + } else { memmove(m_pNetworkSendBuffer, m_pNetworkSendBuffer + numsent, m_nNetworkSendBufferLen - numsent); @@ -657,8 +366,8 @@ void CAsyncSslSocketLayer::OnSend(int nErrorCode) //Send the data waiting in the network bio char buffer[16384]; - size_t len = pBIO_ctrl_pending(m_nbio); - int numread = pBIO_read(m_nbio, buffer, len); + size_t len = BIO_ctrl_pending(m_nbio); + int numread = BIO_read(m_nbio, buffer, len); if (numread <= 0) m_mayTriggerWrite = true; while (numread > 0) @@ -698,24 +407,28 @@ void CAsyncSslSocketLayer::OnSend(int nErrorCode) m_nNetworkSendBufferLen += numread - numsent; } if (!numsent) + { break; - len = pBIO_ctrl_pending(m_nbio); + } + len = BIO_ctrl_pending(m_nbio); if (!len) { m_mayTriggerWrite = true; break; } - numread = pBIO_read(m_nbio, buffer, len); + numread = BIO_read(m_nbio, buffer, len); if (numread <= 0) + { m_mayTriggerWrite = true; + } } if (m_pRetrySendBuffer) { - int numwrite = pBIO_write(m_sslbio, m_pRetrySendBuffer, m_nRetrySendBufferLen); + int numwrite = BIO_write(m_sslbio, m_pRetrySendBuffer, m_nRetrySendBufferLen); if (numwrite >= 0) { - pBIO_ctrl(m_sslbio, BIO_CTRL_FLUSH, 0, NULL); + BIO_ctrl(m_sslbio, BIO_CTRL_FLUSH, 0, NULL); delete [] m_pRetrySendBuffer; m_pRetrySendBuffer = 0; } @@ -738,12 +451,15 @@ void CAsyncSslSocketLayer::OnSend(int nErrorCode) if (m_nShutDown == 1 && ShutDownComplete()) { //Send shutdown notification if all pending data has been sent + // FileZilla3 calls ShutDownNext() here DoLayerCallback(LAYERCALLBACK_LAYERSPECIFIC, SSL_INFO, SSL_INFO_SHUTDOWNCOMPLETE); m_nShutDown++; } } else + { TriggerEvent(FD_WRITE, nErrorCode, TRUE); + } } int CAsyncSslSocketLayer::Send(const void* lpBuf, int nBufLen, int nFlags) @@ -787,7 +503,7 @@ int CAsyncSslSocketLayer::Send(const void* lpBuf, int nBufLen, int nFlags) return 0; } - int len = pBIO_ctrl_get_write_guarantee(m_sslbio); + int len = BIO_ctrl_get_write_guarantee(m_sslbio); if (nBufLen > len) nBufLen = len; if (!len) @@ -801,10 +517,10 @@ int CAsyncSslSocketLayer::Send(const void* lpBuf, int nBufLen, int nFlags) m_nRetrySendBufferLen = nBufLen; memcpy(m_pRetrySendBuffer, lpBuf, nBufLen); - int numwrite = pBIO_write(m_sslbio, m_pRetrySendBuffer, m_nRetrySendBufferLen); + int numwrite = BIO_write(m_sslbio, m_pRetrySendBuffer, m_nRetrySendBufferLen); if (numwrite >= 0) { - pBIO_ctrl(m_sslbio, BIO_CTRL_FLUSH, 0, NULL); + BIO_ctrl(m_sslbio, BIO_CTRL_FLUSH, 0, NULL); delete [] m_pRetrySendBuffer; m_pRetrySendBuffer = 0; } @@ -859,12 +575,12 @@ int CAsyncSslSocketLayer::Receive(void* lpBuf, int nBufLen, int nFlags) } if (m_nNetworkError) { - size_t pending = pBIO_ctrl_pending(m_sslbio); + size_t pending = BIO_ctrl_pending(m_sslbio); if (pending && !m_nShutDown) { m_mayTriggerReadUp = true; TriggerEvents(); - return pBIO_read(m_sslbio, lpBuf,nBufLen); + return BIO_read(m_sslbio, lpBuf,nBufLen); } WSASetLastError(m_nNetworkError); return SOCKET_ERROR; @@ -878,7 +594,7 @@ int CAsyncSslSocketLayer::Receive(void* lpBuf, int nBufLen, int nFlags) { return 0; } - size_t pending = pBIO_ctrl_pending(m_sslbio); + size_t pending = BIO_ctrl_pending(m_sslbio); if (!pending) { if (GetLayerState() == closed) @@ -897,7 +613,7 @@ int CAsyncSslSocketLayer::Receive(void* lpBuf, int nBufLen, int nFlags) } else { - if (pSSL_get_shutdown(m_ssl)) + if (SSL_get_shutdown(m_ssl)) { if (ShutDown() || GetLastError() == WSAEWOULDBLOCK) { @@ -923,10 +639,10 @@ int CAsyncSslSocketLayer::Receive(void* lpBuf, int nBufLen, int nFlags) SetLastError(WSAEWOULDBLOCK); return SOCKET_ERROR; } - int numread = pBIO_read(m_sslbio, lpBuf, nBufLen); + int numread = BIO_read(m_sslbio, lpBuf, nBufLen); if (!numread) { - if (pSSL_get_shutdown(m_ssl)) + if (SSL_get_shutdown(m_ssl)) { if (ShutDown() || GetLastError() == WSAEWOULDBLOCK) { @@ -963,7 +679,7 @@ int CAsyncSslSocketLayer::Receive(void* lpBuf, int nBufLen, int nFlags) } else { - if (pSSL_get_shutdown(m_ssl)) + if (SSL_get_shutdown(m_ssl)) { if (ShutDown() || GetLastError() == WSAEWOULDBLOCK) { @@ -1012,8 +728,12 @@ BOOL CAsyncSslSocketLayer::Connect(const SOCKADDR *lpSockAddr, int nSockAddrLen) { BOOL res = ConnectNext(lpSockAddr, nSockAddrLen); if (!res) + { if (GetLastError() != WSAEWOULDBLOCK) + { ResetSslSession(); + } + } return res; } @@ -1021,8 +741,12 @@ BOOL CAsyncSslSocketLayer::Connect(LPCTSTR lpszHostAddress, UINT nHostPort) { BOOL res = ConnectNext(lpszHostAddress, nHostPort); if (!res) + { if (GetLastError()!=WSAEWOULDBLOCK) + { ResetSslSession(); + } + } return res; } @@ -1064,7 +788,7 @@ int CAsyncSslSocketLayer::InitSSLConnection(bool clientMode, else if (!m_ssl_ctx) { // Create new context if none given - if (!(m_ssl_ctx = pSSL_CTX_new( pSSLv23_method()))) + if (!(m_ssl_ctx = SSL_CTX_new( SSLv23_method()))) { m_sCriticalSection.Unlock(); ResetSslSession(); @@ -1075,17 +799,17 @@ int CAsyncSslSocketLayer::InitSSLConnection(bool clientMode, if (clientMode) { USES_CONVERSION; - pSSL_CTX_set_verify(m_ssl_ctx, SSL_VERIFY_PEER, verify_callback); + SSL_CTX_set_verify(m_ssl_ctx, SSL_VERIFY_PEER, verify_callback); CFileStatus Dummy; if (CFile::GetStatus((LPCTSTR)m_CertStorage, Dummy)) { - pSSL_CTX_load_verify_locations(m_ssl_ctx, T2CA(m_CertStorage), 0); + SSL_CTX_load_verify_locations(m_ssl_ctx, T2CA(m_CertStorage), 0); } } } //Create new SSL session - if (!(m_ssl = pSSL_new(m_ssl_ctx))) + if (!(m_ssl = SSL_new(m_ssl_ctx))) { m_sCriticalSection.Unlock(); ResetSslSession(); @@ -1099,11 +823,11 @@ int CAsyncSslSocketLayer::InitSSLConnection(bool clientMode, m_pSslLayerList->pLayer = this; m_sCriticalSection.Unlock(); - pSSL_set_info_callback(m_ssl, apps_ssl_info_callback); + SSL_set_info_callback(m_ssl, apps_ssl_info_callback); //Create bios - m_sslbio = pBIO_new(pBIO_f_ssl()); - pBIO_new_bio_pair(&m_ibio, 4096, &m_nbio, 4096); + m_sslbio = BIO_new(BIO_f_ssl()); + BIO_new_bio_pair(&m_ibio, 4096, &m_nbio, 4096); if (!m_sslbio || !m_nbio || !m_ibio) { @@ -1111,19 +835,17 @@ int CAsyncSslSocketLayer::InitSSLConnection(bool clientMode, return SSL_FAILURE_INITSSL; } - long options = pSSL_ctrl(m_ssl, SSL_CTRL_OPTIONS, 0, NULL); + // See also TWebDAVFileSystem::InitSslSession #define MASK_TLS_VERSION(VERSION, FLAG) ((minTlsVersion > VERSION) || (maxTlsVersion < VERSION) ? FLAG : 0) - options |= + long options = SSL_OP_ALL | MASK_TLS_VERSION(SSL_VERSION_SSL2, SSL_OP_NO_SSLv2) | MASK_TLS_VERSION(SSL_VERSION_SSL3, SSL_OP_NO_SSLv3) | MASK_TLS_VERSION(SSL_VERSION_TLS10, SSL_OP_NO_TLSv1) | MASK_TLS_VERSION(SSL_VERSION_TLS11, SSL_OP_NO_TLSv1_1) | MASK_TLS_VERSION(SSL_VERSION_TLS12, SSL_OP_NO_TLSv1_2); - pSSL_ctrl(m_ssl, SSL_CTRL_OPTIONS, options, NULL); - - LogSocketMessage(FZ_LOG_INFO, _T("Loading system certificates")); - LoadSslWindowsSystemCertificateStore(m_ssl_ctx); + // SSL_ctrl() with SSL_CTRL_OPTIONS adds flags (not sets) + SSL_ctrl(m_ssl, SSL_CTRL_OPTIONS, options, NULL); //Init SSL connection void *ssl_sessionid = NULL; @@ -1136,7 +858,7 @@ int CAsyncSslSocketLayer::InitSSLConnection(bool clientMode, { if (m_Main->m_sessionid != NULL) { - if (!pSSL_set_session(m_ssl, m_Main->m_sessionid)) + if (!SSL_set_session(m_ssl, m_Main->m_sessionid)) { LogSocketMessage(FZ_LOG_INFO, _T("SSL_set_session failed")); return SSL_FAILURE_INITSSL; @@ -1146,24 +868,24 @@ int CAsyncSslSocketLayer::InitSSLConnection(bool clientMode, else { LogSocketMessage(FZ_LOG_INFO, _T("Main TLS session ID was not reused previously, not trying again")); - pSSL_set_session(m_ssl, NULL); + SSL_set_session(m_ssl, NULL); } } else { - pSSL_set_session(m_ssl, NULL); + SSL_set_session(m_ssl, NULL); } if (clientMode) { - pSSL_set_connect_state(m_ssl); + SSL_set_connect_state(m_ssl); } else { - pSSL_set_accept_state(m_ssl); + SSL_set_accept_state(m_ssl); } - pSSL_set_bio(m_ssl, m_ibio, m_ibio); - pBIO_ctrl(m_sslbio, BIO_C_SET_SSL, BIO_NOCLOSE, m_ssl); - pBIO_read(m_sslbio, (void *)1, 0); + SSL_set_bio(m_ssl, m_ibio, m_ibio); + BIO_ctrl(m_sslbio, BIO_C_SET_SSL, BIO_NOCLOSE, m_ssl); + BIO_read(m_sslbio, (void *)1, 0); // Trigger FD_WRITE so that we can initialize SSL negotiation if (GetLayerState() == connected || GetLayerState() == attached) @@ -1198,19 +920,19 @@ void CAsyncSslSocketLayer::ResetSslSession() m_bSslEstablished = FALSE; if (m_sslbio) { - pBIO_free(m_sslbio); + BIO_free(m_sslbio); } if (m_ssl) { - pSSL_set_session(m_ssl,NULL); + SSL_set_session(m_ssl,NULL); } if (m_nbio) { - pBIO_free(m_nbio); + BIO_free(m_nbio); } if (m_ibio) { - pBIO_free(m_ibio); + BIO_free(m_ibio); } m_nNetworkSendBufferLen = 0; @@ -1221,7 +943,7 @@ void CAsyncSslSocketLayer::ResetSslSession() if (m_ssl) { - pSSL_free(m_ssl); + SSL_free(m_ssl); } m_sCriticalSection.Lock(); @@ -1237,7 +959,7 @@ void CAsyncSslSocketLayer::ResetSslSession() { if (iter->second <= 1) { - pSSL_CTX_free(m_ssl_ctx); + SSL_CTX_free(m_ssl_ctx); m_contextRefCount.erase(iter); } else @@ -1325,12 +1047,12 @@ BOOL CAsyncSslSocketLayer::ShutDown(int nHow /*=sends*/) } } - int res = pSSL_shutdown(m_ssl); + int res = SSL_shutdown(m_ssl); if (res != -1) { if (!res) { - pSSL_shutdown(m_ssl); + SSL_shutdown(m_ssl); } if (ShutDownComplete()) return ShutDownNext(); @@ -1343,7 +1065,7 @@ BOOL CAsyncSslSocketLayer::ShutDown(int nHow /*=sends*/) } else { - int error = pSSL_get_error(m_ssl, -1); + int error = SSL_get_error(m_ssl, -1); if (error == SSL_ERROR_WANT_READ || error == SSL_ERROR_WANT_WRITE) { #ifdef MPEXT @@ -1389,10 +1111,10 @@ BOOL CAsyncSslSocketLayer::ShutDownComplete() int numread; do { - numread = pBIO_read(m_sslbio, buffer, 1000); + numread = BIO_read(m_sslbio, buffer, 1000); } while (numread > 0); - size_t pending = pBIO_ctrl_pending(m_nbio); + size_t pending = BIO_ctrl_pending(m_nbio); if (pending) { return FALSE; @@ -1488,7 +1210,7 @@ void CAsyncSslSocketLayer::apps_ssl_info_callback(const SSL *s, int where, int r char *buffer = new char[4096 + ((debug != NULL) ? strlen(debug) : 0)]; sprintf(buffer, "%s: %s", str, - pSSL_state_string_long(s)); + SSL_state_string_long(s)); if (debug != NULL) { sprintf(buffer + strlen(buffer), " [%s]", debug); @@ -1499,7 +1221,7 @@ void CAsyncSslSocketLayer::apps_ssl_info_callback(const SSL *s, int where, int r else if (where & SSL_CB_ALERT) { str=(where & SSL_CB_READ)? "read" : "write"; - const char* desc = pSSL_alert_desc_string_long(ret); + const char* desc = SSL_alert_desc_string_long(ret); // Don't send close notify warning if (desc) @@ -1509,7 +1231,7 @@ void CAsyncSslSocketLayer::apps_ssl_info_callback(const SSL *s, int where, int r char *buffer = new char[4096]; sprintf(buffer, "SSL3 alert %s: %s: %s", str, - pSSL_alert_type_string_long(ret), + SSL_alert_type_string_long(ret), desc); pLayer->DoLayerCallback(LAYERCALLBACK_LAYERSPECIFIC, SSL_VERBOSE_WARNING, 0, buffer); } @@ -1523,7 +1245,7 @@ void CAsyncSslSocketLayer::apps_ssl_info_callback(const SSL *s, int where, int r char *buffer = new char[4096]; sprintf(buffer, "%s: failed in %s", str, - pSSL_state_string_long(s)); + SSL_state_string_long(s)); pLayer->DoLayerCallback(LAYERCALLBACK_LAYERSPECIFIC, SSL_VERBOSE_WARNING, 0, buffer); if (!pLayer->m_bFailureSent) { @@ -1533,13 +1255,13 @@ void CAsyncSslSocketLayer::apps_ssl_info_callback(const SSL *s, int where, int r } else if (ret < 0) { - int error = pSSL_get_error(s,ret); + int error = SSL_get_error(s,ret); if (error != SSL_ERROR_WANT_READ && error != SSL_ERROR_WANT_WRITE) { char *buffer = new char[4096]; sprintf(buffer, "%s: error in %s", str, - pSSL_state_string_long(s)); + SSL_state_string_long(s)); pLayer->DoLayerCallback(LAYERCALLBACK_LAYERSPECIFIC, SSL_VERBOSE_WARNING, 0, buffer); if (!pLayer->m_bFailureSent) { @@ -1551,7 +1273,7 @@ void CAsyncSslSocketLayer::apps_ssl_info_callback(const SSL *s, int where, int r } if (where & SSL_CB_HANDSHAKE_DONE) { - int error = pSSL_get_verify_result(pLayer->m_ssl); + int error = SSL_get_verify_result(pLayer->m_ssl); pLayer->DoLayerCallback(LAYERCALLBACK_LAYERSPECIFIC, SSL_VERIFY_CERT, error); pLayer->m_bBlocking = TRUE; } @@ -1574,16 +1296,6 @@ void CAsyncSslSocketLayer::UnloadSSL() return; } -#ifndef MPEXT_NO_SSLDLL - if (m_hSslDll1) - FreeLibrary(m_hSslDll1); - if (m_hSslDll2) - { - FreeLibrary(m_hSslDll2); - } - m_hSslDll1 = NULL; - m_hSslDll2 = NULL; -#endif m_sCriticalSection.Unlock(); } @@ -1654,7 +1366,7 @@ bool AsnTimeToValidTime(ASN1_TIME * AsnTime, t_SslCertData::t_validTime & ValidT BOOL CAsyncSslSocketLayer::GetPeerCertificateData(t_SslCertData &SslCertData, LPCTSTR & Error) { - X509 *pX509=pSSL_get_peer_certificate(m_ssl); + X509 *pX509=SSL_get_peer_certificate(m_ssl); if (!pX509) { Error = _T("Cannot get certificate"); @@ -1665,22 +1377,22 @@ BOOL CAsyncSslSocketLayer::GetPeerCertificateData(t_SslCertData &SslCertData, LP memset(&SslCertData, 0, sizeof(t_SslCertData)); //Set subject data fields - X509_NAME *pX509Name=pX509_get_subject_name(pX509); + X509_NAME *pX509Name=X509_get_subject_name(pX509); if (pX509Name) { - int count=pX509_NAME_entry_count(pX509Name); + int count=X509_NAME_entry_count(pX509Name); for (int i=0;i 0) { // Keep it huge @@ -1702,10 +1414,10 @@ BOOL CAsyncSslSocketLayer::GetPeerCertificateData(t_SslCertData &SslCertData, LP #endif } delete [] unicode; - pCRYPTO_free(out); + CRYPTO_free(out); } - switch(pOBJ_obj2nid(pObject)) + switch(OBJ_obj2nid(pObject)) { case NID_organizationName: _tcsncpy(SslCertData.subject.Organization, str, 255); @@ -1736,10 +1448,10 @@ BOOL CAsyncSslSocketLayer::GetPeerCertificateData(t_SslCertData &SslCertData, LP SslCertData.subject.Town[255] = 0; break; default: - if ( !pOBJ_nid2sn(pOBJ_obj2nid(pObject)) ) + if ( !OBJ_nid2sn(OBJ_obj2nid(pObject)) ) { TCHAR tmp[20]; - _stprintf(tmp, _T("%d"), pOBJ_obj2nid(pObject)); + _stprintf(tmp, _T("%d"), OBJ_obj2nid(pObject)); int maxlen = 1024 - _tcslen(SslCertData.subject.Other)-1; _tcsncpy(SslCertData.subject.Other+_tcslen(SslCertData.subject.Other), tmp, maxlen); @@ -1757,7 +1469,7 @@ BOOL CAsyncSslSocketLayer::GetPeerCertificateData(t_SslCertData &SslCertData, LP int maxlen = 1024 - _tcslen(SslCertData.subject.Other)-1; USES_CONVERSION; - _tcsncpy(SslCertData.subject.Other+_tcslen(SslCertData.subject.Other), A2CT(pOBJ_nid2sn(pOBJ_obj2nid(pObject))), maxlen); + _tcsncpy(SslCertData.subject.Other+_tcslen(SslCertData.subject.Other), A2CT(OBJ_nid2sn(OBJ_obj2nid(pObject))), maxlen); maxlen = 1024 - _tcslen(SslCertData.subject.Other)-1; _tcsncpy(SslCertData.subject.Other+_tcslen(SslCertData.subject.Other), _T("="), maxlen); @@ -1774,22 +1486,22 @@ BOOL CAsyncSslSocketLayer::GetPeerCertificateData(t_SslCertData &SslCertData, LP } //Set issuer data fields - pX509Name=pX509_get_issuer_name(pX509); + pX509Name=X509_get_issuer_name(pX509); if (pX509Name) { - int count=pX509_NAME_entry_count(pX509Name); + int count=X509_NAME_entry_count(pX509Name); for (int i=0;i 0) { // Keep it huge @@ -1811,10 +1523,10 @@ BOOL CAsyncSslSocketLayer::GetPeerCertificateData(t_SslCertData &SslCertData, LP #endif } delete [] unicode; - pCRYPTO_free(out); + CRYPTO_free(out); } - switch(pOBJ_obj2nid(pObject)) + switch(OBJ_obj2nid(pObject)) { case NID_organizationName: _tcsncpy(SslCertData.issuer.Organization, str, 255); @@ -1845,10 +1557,10 @@ BOOL CAsyncSslSocketLayer::GetPeerCertificateData(t_SslCertData &SslCertData, LP SslCertData.issuer.Town[255] = 0; break; default: - if ( !pOBJ_nid2sn(pOBJ_obj2nid(pObject)) ) + if ( !OBJ_nid2sn(OBJ_obj2nid(pObject)) ) { TCHAR tmp[20]; - _stprintf(tmp, _T("%d"), pOBJ_obj2nid(pObject)); + _stprintf(tmp, _T("%d"), OBJ_obj2nid(pObject)); int maxlen = 1024 - _tcslen(SslCertData.issuer.Other)-1; _tcsncpy(SslCertData.issuer.Other+_tcslen(SslCertData.issuer.Other), tmp, maxlen); @@ -1866,7 +1578,7 @@ BOOL CAsyncSslSocketLayer::GetPeerCertificateData(t_SslCertData &SslCertData, LP int maxlen = 1024 - _tcslen(SslCertData.issuer.Other)-1; USES_CONVERSION; - _tcsncpy(SslCertData.issuer.Other+_tcslen(SslCertData.issuer.Other), A2CT(pOBJ_nid2sn(pOBJ_obj2nid(pObject))), maxlen); + _tcsncpy(SslCertData.issuer.Other+_tcslen(SslCertData.issuer.Other), A2CT(OBJ_nid2sn(OBJ_obj2nid(pObject))), maxlen); maxlen = 1024 - _tcslen(SslCertData.issuer.Other)-1; _tcsncpy(SslCertData.issuer.Other+_tcslen(SslCertData.issuer.Other), _T("="), maxlen); @@ -1888,14 +1600,14 @@ BOOL CAsyncSslSocketLayer::GetPeerCertificateData(t_SslCertData &SslCertData, LP ASN1_TIME *pTime=X509_get_notBefore(pX509); if (!pTime) { - pX509_free(pX509); + X509_free(pX509); Error = _T("Cannot get start time"); return FALSE; } if (!AsnTimeToValidTime(pTime, SslCertData.validFrom)) { - pX509_free(pX509); + X509_free(pX509); Error = _T("Invalid start time"); return FALSE; } @@ -1904,14 +1616,14 @@ BOOL CAsyncSslSocketLayer::GetPeerCertificateData(t_SslCertData &SslCertData, LP pTime = X509_get_notAfter(pX509); if (!pTime) { - pX509_free(pX509); + X509_free(pX509); Error = _T("Cannot get end time"); return FALSE; } if (!AsnTimeToValidTime(pTime, SslCertData.validUntil)) { - pX509_free(pX509); + X509_free(pX509); Error = _T("Invalid end time"); return FALSE; } @@ -1938,11 +1650,18 @@ BOOL CAsyncSslSocketLayer::GetPeerCertificateData(t_SslCertData &SslCertData, LP } unsigned int length = 20; - pX509_digest(pX509, pEVP_sha1(), SslCertData.hash, &length); + X509_digest(pX509, EVP_sha1(), SslCertData.hash, &length); + + // Inspired by ne_ssl_cert_export() + // Find the length of the DER encoding. + SslCertData.certificateLen = i2d_X509(pX509, NULL); + SslCertData.certificate = new unsigned char[SslCertData.certificateLen]; + unsigned char * p = SslCertData.certificate; + i2d_X509(pX509, &p); SslCertData.priv_data = m_nSslAsyncNotifyId; - pX509_free(pX509); + X509_free(pX509); SslCertData.verificationResult = m_nVerificationResult; SslCertData.verificationDepth = m_nVerificationDepth; @@ -1998,13 +1717,13 @@ void CAsyncSslSocketLayer::PrintSessionInfo() SSL_CIPHER *ciph; X509 *cert; - ciph = pSSL_get_current_cipher(m_ssl); + ciph = SSL_get_current_cipher(m_ssl); char enc[4096] = {0}; - cert=pSSL_get_peer_certificate(m_ssl); + cert=SSL_get_peer_certificate(m_ssl); if (cert != NULL) { - EVP_PKEY *pkey = pX509_get_pubkey(cert); + EVP_PKEY *pkey = X509_get_pubkey(cert); if (pkey != NULL) { if (0) @@ -2012,27 +1731,29 @@ void CAsyncSslSocketLayer::PrintSessionInfo() #ifndef NO_RSA else if (pkey->type == EVP_PKEY_RSA && pkey->pkey.rsa != NULL && pkey->pkey.rsa->n != NULL) - sprintf(enc, "%d bit RSA", pBN_num_bits(pkey->pkey.rsa->n)); + sprintf(enc, "%d bit RSA", BN_num_bits(pkey->pkey.rsa->n)); #endif #ifndef NO_DSA else if (pkey->type == EVP_PKEY_DSA && pkey->pkey.dsa != NULL && pkey->pkey.dsa->p != NULL) - sprintf(enc, "%d bit DSA", pBN_num_bits(pkey->pkey.dsa->p)); + sprintf(enc, "%d bit DSA", BN_num_bits(pkey->pkey.dsa->p)); #endif - pEVP_PKEY_free(pkey); + EVP_PKEY_free(pkey); } - pX509_free(cert); + X509_free(cert); /* The SSL API does not allow us to look at temporary RSA/DH keys, * otherwise we should print their lengths too */ } char *buffer = new char[4096]; - m_TlsVersionStr = pSSL_get_version(m_ssl); + // see also ne_ssl_get_version and ne_ssl_get_cipher + m_TlsVersionStr = SSL_get_version(m_ssl); sprintf(buffer, "%s: %s, %s", - pSSL_CIPHER_get_version(ciph), - pSSL_CIPHER_get_name(ciph), + SSL_CIPHER_get_version(ciph), + SSL_CIPHER_get_name(ciph), enc); m_CipherName = buffer; + // see TWebDAVFileSystem::CollectTLSSessionInfo() sprintf(buffer, "Using %s, cipher %s", m_TlsVersionStr.c_str(), m_CipherName.c_str()); @@ -2052,15 +1773,15 @@ int CAsyncSslSocketLayer::verify_callback(int preverify_ok, X509_STORE_CTX *ctx) int err, depth; SSL *ssl; - err_cert = pX509_STORE_CTX_get_current_cert(ctx); - err = pX509_STORE_CTX_get_error(ctx); - depth = pX509_STORE_CTX_get_error_depth(ctx); + err_cert = X509_STORE_CTX_get_current_cert(ctx); + err = X509_STORE_CTX_get_error(ctx); + depth = X509_STORE_CTX_get_error_depth(ctx); /* * Retrieve the pointer to the SSL of the connection currently treated * and the application specific data stored into the SSL object. */ - ssl = (SSL *)pX509_STORE_CTX_get_ex_data(ctx, pSSL_get_ex_data_X509_STORE_CTX_idx()); + ssl = (SSL *)X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx()); // Lookup CAsyncSslSocketLayer instance CAsyncSslSocketLayer *pLayer = 0; @@ -2094,7 +1815,7 @@ int CAsyncSslSocketLayer::verify_callback(int preverify_ok, X509_STORE_CTX *ctx) if (depth > 10) {//mydata->verify_depth) { preverify_ok = 0; err = X509_V_ERR_CERT_CHAIN_TOO_LONG; - pX509_STORE_CTX_set_error(ctx, err); + X509_STORE_CTX_set_error(ctx, err); } if (!preverify_ok) @@ -2117,9 +1838,9 @@ BOOL CAsyncSslSocketLayer::SetCertStorage(CString file) void CAsyncSslSocketLayer::OnClose(int nErrorCode) { m_onCloseCalled = true; - if (m_bUseSSL && pBIO_ctrl) + if (m_bUseSSL && BIO_ctrl) { - size_t pending = pBIO_ctrl_pending(m_sslbio); + size_t pending = BIO_ctrl_pending(m_sslbio); if (pending > 0) { TriggerEvents(); @@ -2132,19 +1853,19 @@ void CAsyncSslSocketLayer::OnClose(int nErrorCode) void CAsyncSslSocketLayer::PrintLastErrorMsg() { - int err = pERR_get_error(); + int err = ERR_get_error(); while (err) { char *buffer = new char[512]; - pERR_error_string(err, buffer); - err = pERR_get_error(); + ERR_error_string(err, buffer); + err = ERR_get_error(); DoLayerCallback(LAYERCALLBACK_LAYERSPECIFIC, SSL_VERBOSE_WARNING, 0, buffer); } } void CAsyncSslSocketLayer::TriggerEvents() { - size_t pending = pBIO_ctrl_pending(m_nbio); + size_t pending = BIO_ctrl_pending(m_nbio); if (pending > 0) { if (m_mayTriggerWrite) @@ -2155,14 +1876,14 @@ void CAsyncSslSocketLayer::TriggerEvents() } else if (!m_nNetworkSendBufferLen && m_bSslEstablished && !m_pRetrySendBuffer) { - if (pBIO_ctrl_get_write_guarantee(m_sslbio) > 0 && m_mayTriggerWriteUp) + if (BIO_ctrl_get_write_guarantee(m_sslbio) > 0 && m_mayTriggerWriteUp) { m_mayTriggerWriteUp = false; TriggerEvent(FD_WRITE, 0, TRUE); } } - if (m_bSslEstablished && pBIO_ctrl_pending(m_sslbio) > 0) + if (m_bSslEstablished && BIO_ctrl_pending(m_sslbio) > 0) { if (m_mayTriggerReadUp && !m_bBlocking) { @@ -2172,7 +1893,7 @@ void CAsyncSslSocketLayer::TriggerEvents() } else { - int len = pBIO_ctrl_get_write_guarantee(m_nbio); + int len = BIO_ctrl_get_write_guarantee(m_nbio); if (len > 0 && m_mayTriggerRead) { m_mayTriggerRead = false; @@ -2182,7 +1903,7 @@ void CAsyncSslSocketLayer::TriggerEvents() if (m_onCloseCalled && m_bSslEstablished) { - if (pBIO_ctrl_pending(m_sslbio) <= 0) + if (BIO_ctrl_pending(m_sslbio) <= 0) { TriggerEvent(FD_CLOSE, 0, TRUE); } @@ -2206,38 +1927,4 @@ int CAsyncSslSocketLayer::pem_passwd_cb(char *buf, int size, int rwflag, void *u return len; } //--------------------------------------------------------------------------- -#include -//--------------------------------------------------------------------------- -// Taken from -// http://openssl.6102.n7.nabble.com/Get-root-certificates-from-System-Store-of-Windows-td40959.html -void __fastcall LoadSslWindowsSystemCertificateStore(SSL_CTX * Ctx) -{ - HCERTSTORE CertStore = CertStore = CertOpenSystemStore(0, L"ROOT"); - if (CertStore != NULL) - { - PCCERT_CONTEXT CertContext = NULL; - while ((CertContext = CertEnumCertificatesInStore(CertStore, CertContext)) != NULL) - { - #ifdef _DEBUG - wchar_t Buf[1024]; - CertNameToStr(X509_ASN_ENCODING, &CertContext->pCertInfo->Subject, CERT_X500_NAME_STR, Buf, LENOF(Buf)); - Buf[LENOF(Buf) - 1] = L'\0'; - CertNameToStr(X509_ASN_ENCODING, &CertContext->pCertInfo->Issuer, CERT_X500_NAME_STR, Buf, LENOF(Buf)); - Buf[LENOF(Buf) - 1] = L'\0'; - #endif - X509 * x509 = d2i_X509(NULL, const_cast(&CertContext->pbCertEncoded), CertContext->cbCertEncoded); - if (x509 != NULL) - { - #ifdef _DEBUG - int AddCertResult = - #endif - X509_STORE_add_cert(Ctx->cert_store, x509); - X509_free(x509); - } - } - - CertFreeCertificateContext(CertContext); - CertCloseStore(CertStore, 0); - } -} diff --git a/source/filezilla/AsyncSslSocketLayer.h b/source/filezilla/AsyncSslSocketLayer.h index b2311e89..ce4fde49 100644 --- a/source/filezilla/AsyncSslSocketLayer.h +++ b/source/filezilla/AsyncSslSocketLayer.h @@ -17,7 +17,7 @@ CAsyncSslSocketLayer to your socket and call InitClientSsl after creation of the This class only has a couple of public functions: - int InitSSLConnection(bool clientMode); - This functions establishes an SSL connection. The clientMode parameter specifies wether the SSL connection + This functions establishes an SSL connection. The clientMode parameter specifies whether the SSL connection is in server or in client mode. Most likely you want to call this function right after calling Create for the socket. But sometimes, you'll need to call this function later. One example is for an FTP connection @@ -45,7 +45,6 @@ Valid notification IDs are: - SSL_FAILURE_NONE 0 - Everything OK - SSL_FAILURE_UNKNOWN 1 - Details may have been sent with a SSL_VERBOSE_* notification. - SSL_FAILURE_ESTABLISH 2 - Problem during SSL negotiation - - SSL_FAILURE_LOADDLLS 4 - SSL_FAILURE_INITSSL 8 - SSL_FAILURE_VERIFYCERT 16 - The remote SSL certificate was invalid - SSL_FAILURE_CERTREJECTED 32 - The remote SSL certificate was rejected by user @@ -91,16 +90,16 @@ Version 2.0: #endif #include "AsyncSocketExLayer.h" -#ifdef MPEXT -#define OPENSSL_NO_EC -#define OPENSSL_NO_ECDSA -#define OPENSSL_NO_ECDH -#endif #include // Details of SSL certificate, can be used by app to verify if certificate is valid struct t_SslCertData { + ~t_SslCertData() + { + delete [] certificate; + } + struct t_Contact { TCHAR Organization[256]; @@ -123,6 +122,9 @@ struct t_SslCertData unsigned char hash[20]; + unsigned char * certificate; + size_t certificateLen; + int verificationResult; int verificationDepth; @@ -204,12 +206,6 @@ class CAsyncSslSocketLayer : public CAsyncSocketExLayer t_SslLayerList *pNext; } *m_pSslLayerList; -#ifndef MPEXT_NO_SSLDLL - // Handles to the SLL libraries - static HMODULE m_hSslDll1; - static HMODULE m_hSslDll2; -#endif - // SSL data SSL_CTX* m_ssl_ctx; // SSL context static std::map m_contextRefCount; @@ -255,9 +251,6 @@ class CAsyncSslSocketLayer : public CAsyncSocketExLayer #define SSL_FAILURE_UNKNOWN 0 #define SSL_FAILURE_ESTABLISH 1 -#ifndef MPEXT_NO_SSLDLL -#define SSL_FAILURE_LOADDLLS 2 -#endif #define SSL_FAILURE_INITSSL 4 #define SSL_FAILURE_VERIFYCERT 8 #define SSL_FAILURE_CERTREJECTED 0x10 @@ -268,6 +261,4 @@ class CAsyncSslSocketLayer : public CAsyncSocketExLayer #define SSL_VERSION_TLS11 11 #define SSL_VERSION_TLS12 12 -void __fastcall LoadSslWindowsSystemCertificateStore(SSL_CTX * Ctx); - #endif // ASYNCSSLSOCKETLEAYER_INCLUDED diff --git a/source/filezilla/FileZillaIntf.cpp b/source/filezilla/FileZillaIntf.cpp index 38811039..30e4c35d 100644 --- a/source/filezilla/FileZillaIntf.cpp +++ b/source/filezilla/FileZillaIntf.cpp @@ -377,6 +377,8 @@ bool __fastcall TFileZillaIntf::HandleMessage(WPARAM wParam, LPARAM lParam) CopyValidityTime(Data.ValidUntil, AData->pCertData->validUntil); Data.SubjectAltName = AData->pCertData->subjectAltName; Data.Hash = AData->pCertData->hash; + Data.Certificate = AData->pCertData->certificate; + Data.CertificateLen = AData->pCertData->certificateLen; Data.VerificationResult = AData->pCertData->verificationResult; Data.VerificationDepth = AData->pCertData->verificationDepth; diff --git a/source/filezilla/FileZillaIntf.h b/source/filezilla/FileZillaIntf.h index 16c308ab..932b7e0c 100644 --- a/source/filezilla/FileZillaIntf.h +++ b/source/filezilla/FileZillaIntf.h @@ -72,6 +72,9 @@ struct TFtpsCertificateData const unsigned char * Hash; static const size_t HashLen = 20; + const unsigned char * Certificate; + size_t CertificateLen; + int VerificationResult; int VerificationDepth; }; diff --git a/source/filezilla/FileZillaOpt.h b/source/filezilla/FileZillaOpt.h index f05c0ca0..f795faa0 100644 --- a/source/filezilla/FileZillaOpt.h +++ b/source/filezilla/FileZillaOpt.h @@ -164,7 +164,7 @@ #define OPTION_MPEXT_SNDBUF 1003 #define OPTION_MPEXT_MIN_TLS_VERSION 1004 #define OPTION_MPEXT_MAX_TLS_VERSION 1005 -#define OPTION_MPEXT_TRANSFER_ACTIVE_IMMEDIATELLY 1006 +#define OPTION_MPEXT_TRANSFER_ACTIVE_IMMEDIATELY 1006 #define OPTION_MPEXT_REMOVE_BOM 1007 //--------------------------------------------------------------------------- #endif // FileZillaOptH diff --git a/source/filezilla/FtpControlSocket.cpp b/source/filezilla/FtpControlSocket.cpp index 535139f0..c9116f26 100644 --- a/source/filezilla/FtpControlSocket.cpp +++ b/source/filezilla/FtpControlSocket.cpp @@ -427,11 +427,6 @@ void CFtpControlSocket::Connect(t_server &server) COptions::GetOptionVal(OPTION_MPEXT_SSLSESSIONREUSE), COptions::GetOptionVal(OPTION_MPEXT_MIN_TLS_VERSION), COptions::GetOptionVal(OPTION_MPEXT_MAX_TLS_VERSION)); -#ifndef MPEXT_NO_SSLDLL - if (res == SSL_FAILURE_LOADDLLS) - ShowStatus(IDS_ERRORMSG_CANTLOADSSLDLLS, FZ_LOG_ERROR); - else -#endif if (res == SSL_FAILURE_INITSSL) ShowStatus(IDS_ERRORMSG_CANTINITSSL, FZ_LOG_ERROR); if (!res) @@ -558,11 +553,6 @@ void CFtpControlSocket::LogOnToServer(BOOL bSkipReply /*=FALSE*/) COptions::GetOptionVal(OPTION_MPEXT_SSLSESSIONREUSE), COptions::GetOptionVal(OPTION_MPEXT_MIN_TLS_VERSION), COptions::GetOptionVal(OPTION_MPEXT_MAX_TLS_VERSION)); -#ifndef MPEXT_NO_SSLDLL - if (res == SSL_FAILURE_LOADDLLS) - ShowStatus(IDS_ERRORMSG_CANTLOADSSLDLLS, FZ_LOG_ERROR); - else -#endif if (res == SSL_FAILURE_INITSSL) ShowStatus(IDS_ERRORMSG_CANTINITSSL, FZ_LOG_ERROR); if (res) @@ -907,8 +897,10 @@ void CFtpControlSocket::LogOnToServer(BOOL bSkipReply /*=FALSE*/) return; } else + { //GSS authentication complete but we still have to go through the standard logon procedure m_Operation.nOpState = CONNECT_INIT; + } } #endif @@ -916,7 +908,6 @@ void CFtpControlSocket::LogOnToServer(BOOL bSkipReply /*=FALSE*/) { if (logontype) { - CString str; str.Format(IDS_STATUSMSG_FWCONNECT,hostname); ShowStatus(str,FZ_LOG_STATUS); @@ -1165,7 +1156,9 @@ void CFtpControlSocket::OnReceive(int nErrorCode) } } else + { ShowStatus(A2CT(m_RecvBuffer.back()), FZ_LOG_REPLY); + } //Check for multi-line responses if (m_RecvBuffer.back().GetLength() > 3) { @@ -1190,10 +1183,14 @@ void CFtpControlSocket::OnReceive(int nErrorCode) m_RecvBuffer.pop_back(); } else + { m_pOwner->PostThreadMessage(m_pOwner->m_nInternalMessageID, FZAPI_THREADMSG_PROCESSREPLY, 0); + } } else + { m_RecvBuffer.pop_back(); + } m_RecvBuffer.push_back(""); } } @@ -1416,7 +1413,7 @@ BOOL CFtpControlSocket::Send(CString str) m_awaitsReply = true; m_LastSendTime = CTime::GetCurrentTime(); // Count timeout since the last request, not only since the last received data - // otherwise we may happen to timeout immediatelly after sending request if + // otherwise we may happen to timeout immediately after sending request if // CheckForTimeout occurs in between and we haven't received any data for a while m_LastRecvTime = m_LastSendTime; PostMessage(m_pOwner->m_hOwnerWnd, m_pOwner->m_nReplyMessageID, FZ_MSG_MAKEMSG(FZ_MSG_SOCKETSTATUS, FZ_SOCKETSTATUS_SEND), 0); @@ -3974,12 +3971,12 @@ void CFtpControlSocket::FileTransfer(t_transferfile *transferfile/*=0*/,BOOL bFi } } } - if (!nReplyError && !COptions::GetOptionVal(OPTION_MPEXT_TRANSFER_ACTIVE_IMMEDIATELLY)) + if (!nReplyError && !COptions::GetOptionVal(OPTION_MPEXT_TRANSFER_ACTIVE_IMMEDIATELY)) { m_pTransferSocket->SetActive(); } } - else if (pData->bPasv && !COptions::GetOptionVal(OPTION_MPEXT_TRANSFER_ACTIVE_IMMEDIATELLY)) + else if (pData->bPasv && !COptions::GetOptionVal(OPTION_MPEXT_TRANSFER_ACTIVE_IMMEDIATELY)) { m_pTransferSocket->SetActive(); } @@ -4511,9 +4508,9 @@ void CFtpControlSocket::FileTransfer(t_transferfile *transferfile/*=0*/,BOOL bFi return; } m_pTransferSocket->m_transferdata=pData->transferdata; - // not sure what happens when we active transfer socket immediatelly while resuming + // not sure what happens when we active transfer socket immediately while resuming // it can possibly make transfer socket start reading from a file before a file pointer is advanced - if (COptions::GetOptionVal(OPTION_MPEXT_TRANSFER_ACTIVE_IMMEDIATELLY) || + if (COptions::GetOptionVal(OPTION_MPEXT_TRANSFER_ACTIVE_IMMEDIATELY) || ((pData->transferfile.get || !pData->transferdata.bResume) && !pData->bPasv)) { m_pTransferSocket->SetActive(); @@ -5962,11 +5959,6 @@ int CFtpControlSocket::OnLayerCallback(std::list& callbacks) case SSL_FAILURE_ESTABLISH: ShowStatus(IDS_ERRORMSG_CANTESTABLISHSSLCONNECTION, FZ_LOG_ERROR); break; -#ifndef MPEXT_NO_SSLDLL - case SSL_FAILURE_LOADDLLS: - ShowStatus(IDS_ERRORMSG_CANTLOADSSLDLLS, FZ_LOG_ERROR); - break; -#endif case SSL_FAILURE_INITSSL: ShowStatus(IDS_ERRORMSG_CANTINITSSL, FZ_LOG_ERROR); break; diff --git a/source/filezilla/FtpListResult.cpp b/source/filezilla/FtpListResult.cpp index ae51ae1a..5f2acbd5 100644 --- a/source/filezilla/FtpListResult.cpp +++ b/source/filezilla/FtpListResult.cpp @@ -1456,7 +1456,6 @@ bool CFtpListResult::parseMlsdDateTime(const CString value, t_directory::t_diren { try { - CTime dateTime(Year, Month, Day, Hours, Minutes, Seconds); direntry.date.year = Year; direntry.date.month = Month; direntry.date.day = Day; @@ -1464,7 +1463,6 @@ bool CFtpListResult::parseMlsdDateTime(const CString value, t_directory::t_diren direntry.date.minute = Minutes; direntry.date.second = Seconds; direntry.date.utc = TRUE; - direntry.EntryTime = dateTime; } // Does not really seem to ever throw in our version of MFC/ATL catch (CException &) diff --git a/source/filezilla/TransferSocket.cpp b/source/filezilla/TransferSocket.cpp index d48504de..1de3763b 100644 --- a/source/filezilla/TransferSocket.cpp +++ b/source/filezilla/TransferSocket.cpp @@ -404,11 +404,6 @@ void CTransferSocket::OnAccept(int nErrorCode) COptions::GetOptionVal(OPTION_MPEXT_SSLSESSIONREUSE), COptions::GetOptionVal(OPTION_MPEXT_MIN_TLS_VERSION), COptions::GetOptionVal(OPTION_MPEXT_MAX_TLS_VERSION)); -#ifndef MPEXT_NO_SSLDLL - if (res == SSL_FAILURE_LOADDLLS) - m_pOwner->ShowStatus(IDS_ERRORMSG_CANTLOADSSLDLLS, FZ_LOG_ERROR); - else -#endif if (res == SSL_FAILURE_INITSSL) m_pOwner->ShowStatus(IDS_ERRORMSG_CANTINITSSL, FZ_LOG_ERROR); @@ -490,13 +485,10 @@ void CTransferSocket::OnConnect(int nErrorCode) COptions::GetOptionVal(OPTION_MPEXT_SSLSESSIONREUSE), COptions::GetOptionVal(OPTION_MPEXT_MIN_TLS_VERSION), COptions::GetOptionVal(OPTION_MPEXT_MAX_TLS_VERSION)); -#ifndef MPEXT_NO_SSLDLL - if (res == SSL_FAILURE_LOADDLLS) - m_pOwner->ShowStatus(IDS_ERRORMSG_CANTLOADSSLDLLS, FZ_LOG_ERROR); - else -#endif if (res == SSL_FAILURE_INITSSL) + { m_pOwner->ShowStatus(IDS_ERRORMSG_CANTINITSSL, FZ_LOG_ERROR); + } if (res) { @@ -1164,11 +1156,6 @@ int CTransferSocket::OnLayerCallback(std::list& callbacks) case SSL_FAILURE_ESTABLISH: m_pOwner->ShowStatus(IDS_ERRORMSG_CANTESTABLISHSSLCONNECTION, FZ_LOG_ERROR); break; -#ifndef MPEXT_NO_SSLDLL - case SSL_FAILURE_LOADDLLS: - m_pOwner->ShowStatus(IDS_ERRORMSG_CANTLOADSSLDLLS, FZ_LOG_ERROR); - break; -#endif case SSL_FAILURE_INITSSL: m_pOwner->ShowStatus(IDS_ERRORMSG_CANTINITSSL, FZ_LOG_ERROR); break; diff --git a/source/filezilla/stdafx.h b/source/filezilla/stdafx.h index 2c980306..23173497 100644 --- a/source/filezilla/stdafx.h +++ b/source/filezilla/stdafx.h @@ -11,7 +11,7 @@ #define MPEXT_NO_IDENT #define MPEXT_NO_CACHE #define MPEXT_NO_SPEED_LIM_RULES -#define MPEXT_NO_SSLDLL +#define _AFX_ENABLE_INLINES #define _AFX_NOFORCE_LIBS #define _MPT(T) _T(T) #define _MPAT(T) T diff --git a/source/forms/About.cpp b/source/forms/About.cpp index 431f235f..044ec8ac 100644 --- a/source/forms/About.cpp +++ b/source/forms/About.cpp @@ -7,11 +7,25 @@ #include #include #include +#include +#include #include "WinInterface.h" #include "About.h" #include "TextsCore.h" #include "TextsWin.h" +#ifndef NO_COMPONENTS +// must be included before WebBrowserEx.hpp to avoid ambiguity of tagLOGFONTW +#include +#include +#endif +#include +#include +#include +#ifndef NO_FILEZILLA +#include +#endif //--------------------------------------------------------------------- +#pragma link "SHDocVw_OCX" #ifndef NO_RESOURCES #pragma resource "*.dfm" #endif @@ -37,25 +51,12 @@ __fastcall TAboutDialog::TAboutDialog(TComponent * AOwner, : TForm(AOwner) { FConfiguration = Configuration; - ThirdPartyBox->VertScrollBar->Position = 0; UseSystemSettings(this); LinkLabel(HomepageLabel, LoadStr(HOMEPAGE_URL)); LinkLabel(ForumUrlLabel, LoadStr(FORUM_URL)); - LinkLabel(PuttyLicenseLabel, L"", FirstScrollingControlEnter); - LinkLabel(PuttyHomepageLabel, LoadStr(PUTTY_URL)); - LinkLabel(FileZillaHomepageLabel, LoadStr(FILEZILLA_URL)); - LinkLabel(OpenSSLHomepageLabel, LoadStr(OPENSSL_URL)); - LinkLabel(Toolbar2000HomepageLabel); - LinkLabel(TBXHomepageLabel, L"", LastScrollingControlEnter); ApplicationLabel->ParentFont = true; ApplicationLabel->Font->Style = ApplicationLabel->Font->Style << fsBold; ApplicationLabel->Caption = AppName; - PuttyVersionLabel->Caption = FMTLOAD(PUTTY_BASED_ON, (LoadStr(PUTTY_VERSION))); - PuttyCopyrightLabel->Caption = LoadStr(PUTTY_COPYRIGHT); - FileZillaVersionLabel->Caption = LoadStr(FILEZILLA_BASED_ON2); - FileZillaCopyrightLabel->Caption = LoadStr(FILEZILLA_COPYRIGHT2); - OpenSSLVersionLabel->Caption = FMTLOAD(OPENSSL_BASED_ON, (LoadStr(OPENSSL_VERSION))); - OpenSSLCopyrightLabel->Caption = LoadStr(OPENSSL_COPYRIGHT); WinSCPCopyrightLabel->Caption = LoadStr(WINSCP_COPYRIGHT); UnicodeString Translator = LoadStr(TRANSLATOR_INFO); @@ -64,7 +65,7 @@ __fastcall TAboutDialog::TAboutDialog(TComponent * AOwner, RegistrationLabel->Visible = false; RegistrationBox->Visible = false; ClientHeight = ClientHeight - - (ThirdPartyBox->Top - RegistrationBox->Top); + (ThirdPartyPanel->Top - RegistrationBox->Top); } else { @@ -120,62 +121,13 @@ __fastcall TAboutDialog::TAboutDialog(TComponent * AOwner, } } - #ifdef NO_FILEZILLA - int FileZillaHeight = Label1->Top - FileZillaVersionLabel->Top; - FileZillaVersionLabel->Visible = false; - FileZillaCopyrightLabel->Visible = false; - FileZillaHomepageLabel->Visible = false; - OpenSSLVersionLabel->Visible = false; - OpenSSLCopyrightLabel->Visible = false; - OpenSSLHomepageLabel->Visible = false; - - for (int Index = 0; Index < ThirdPartyBox->ControlCount; Index++) - { - TControl * Control = ThirdPartyBox->Controls[Index]; - if (Control->Top > FileZillaHomepageLabel->Top) - { - Control->Top = Control->Top - FileZillaHeight; - } - } + LicenseButton->Visible = AllowLicense; - ThirdPartyBox->VertScrollBar->Range = ThirdPartyBox->VertScrollBar->Range - FileZillaHeight; - #endif - - #ifdef NO_COMPONENTS - int ComponentsHeight = ThirdPartyBox->VertScrollBar->Range - Label1->Top; - Label1->Visible = false; - Label2->Visible = false; - Toolbar2000HomepageLabel->Visible = false; - Label5->Visible = false; - Label6->Visible = false; - TBXHomepageLabel->Visible = false; - Label8->Visible = false; - Label10->Visible = false; - - ThirdPartyBox->VertScrollBar->Range = ThirdPartyBox->VertScrollBar->Range - ComponentsHeight; - #endif - - #ifdef NO_FILEZILLA - #ifdef NO_COMPONENTS - ThirdPartyBox->VertScrollBar->Range = ThirdPartyBox->ClientHeight; - #endif - #endif - - // VCL wrongly autosize these, even when AutoSize is off - // WORKAROUND - FixWrappedLabelSize(Label7); - FixWrappedLabelSize(RegistrationSubjectLabel); - FixWrappedLabelSize(OpenSSLVersionLabel); + FThirdPartyWebBrowser = CreateBrowserViewer(ThirdPartyPanel, L""); - LicenseButton->Visible = AllowLicense; LoadData(); } //--------------------------------------------------------------------------- -void __fastcall TAboutDialog::FixWrappedLabelSize(TLabel * Label) -{ - Label->Width = Label->Parent->ClientWidth - (2 * Label->Left); -} -//--------------------------------------------------------------------------- void __fastcall TAboutDialog::LoadData() { UnicodeString Version = FConfiguration->VersionStr; @@ -186,32 +138,171 @@ void __fastcall TAboutDialog::LoadData() (Version, FConfiguration->ProductName, FConfiguration->ProductVersion)); } VersionLabel->Caption = Version; + + LoadThirdParty(); } //--------------------------------------------------------------------------- -void __fastcall TAboutDialog::PuttyLicenseLabelClick(TObject * /*Sender*/) +void __fastcall TAboutDialog::LoadThirdParty() { - OpenBrowser(LoadStr(PUTTY_LICENSE_URL)); + reinterpret_cast(FThirdPartyWebBrowser)->Color = clBtnFace; + + FThirdPartyWebBrowser->Navigate(L"about:blank"); + while (FThirdPartyWebBrowser->ReadyState < ::READYSTATE_INTERACTIVE) + { + Application->ProcessMessages(); + } + + std::unique_ptr DefaultFont(new TFont()); + + UnicodeString ThirdParty; + + ThirdParty += + L"\n" + L"\n" + L"\n" + L"\n" + L"\n" + L"\n" + L"\n"; + + UnicodeString Br = "
            \n"; + AddPara(ThirdParty, LoadStr(ABOUT_THIRDPARTY_HEADER)); + + AddPara(ThirdParty, + FMTLOAD(PUTTY_BASED_ON, (LoadStr(PUTTY_VERSION))) + Br + + LoadStr(PUTTY_COPYRIGHT) + Br + + CreateLink(LoadStr(PUTTY_LICENSE_URL), LoadStr(ABOUT_THIRDPARTY_LICENSE)) + Br + + CreateLink(LoadStr(PUTTY_URL))); + +#ifndef NO_FILEZILLA + + UnicodeString OpenSSLVersionText = GetOpenSSLVersionText(); + CutToChar(OpenSSLVersionText, L' ', true); // "OpenSSL" + UnicodeString OpenSSLVersion = CutToChar(OpenSSLVersionText, L' ', true); + CutToChar(OpenSSLVersionText, L' ', true); // day + CutToChar(OpenSSLVersionText, L' ', true); // month + UnicodeString OpenSSLYear = CutToChar(OpenSSLVersionText, L' ', true); + + AddPara(ThirdParty, + FMTLOAD(OPENSSL_BASED_ON, (OpenSSLVersion)) + Br + + FMTLOAD(OPENSSL_COPYRIGHT2, (OpenSSLYear)) + Br + + CreateLink(LoadStr(OPENSSL_URL))); + + AddPara(ThirdParty, + LoadStr(FILEZILLA_BASED_ON2) + Br + + LoadStr(FILEZILLA_COPYRIGHT2) + Br + + CreateLink(LoadStr(FILEZILLA_URL))); + +#endif + + AddPara(ThirdParty, + FMTLOAD(NEON_BASED_ON, (NeonVersion())) + Br + + LoadStr(NEON_COPYRIGHT) + Br + + CreateLink(LoadStr(NEON_URL))); + + #define EXPAT_LICENSE_URL L"license:expat" + + AddPara(ThirdParty, + FMTLOAD(EXPAT_BASED_ON, (ExpatVersion())) + Br + + CreateLink(EXPAT_LICENSE_URL, LoadStr(ABOUT_THIRDPARTY_LICENSE)) + Br + + CreateLink(LoadStr(EXPAT_URL))); + + AddBrowserLinkHandler(FThirdPartyWebBrowser, EXPAT_LICENSE_URL, ExpatLicenceHandler); + +#ifndef NO_COMPONENTS + + AddPara(ThirdParty, + FMTLOAD(ABOUT_TOOLBAR2000, (Toolbar2000Version)) + Br + + LoadStr(ABOUT_TOOLBAR2000_COPYRIGHT) + Br + + CreateLink(LoadStr(ABOUT_TOOLBAR2000_URL))); + + AddPara(ThirdParty, + FMTLOAD(ABOUT_TBX, (TBXVersionString)) + Br + + LoadStr(ABOUT_TBX_COPYRIGHT) + Br + + CreateLink(LoadStr(ABOUT_TBX_URL))); + + AddPara(ThirdParty, + LoadStr(ABOUT_FILEMANAGER) + Br + + LoadStr(ABOUT_FILEMANAGER_COPYRIGHT)); + +#endif + + UnicodeString JclVersion = + FormatVersion(JclVersionMajor, JclVersionMinor, JclVersionRelease); + AddPara(ThirdParty, + FMTLOAD(ABOUT_JCL, (JclVersion)) + Br + + CreateLink(LoadStr(ABOUT_JCL_URL))); + + AddPara(ThirdParty, + LoadStr(ABOUT_PNG) + Br + + LoadStr(ABOUT_PNG_COPYRIGHT) + Br + + CreateLink(LoadStr(ABOUT_PNG_URL))); + + ThirdParty += + L"\n" + L"\n"; + + std::unique_ptr ThirdPartyStream(new TMemoryStream()); + UTF8String ThirdPartyUTF8 = UTF8String(ThirdParty); + ThirdPartyStream->Write(ThirdPartyUTF8.c_str(), ThirdPartyUTF8.Length()); + ThirdPartyStream->Seek(0, 0); + + // For steam-loaded document, when set only after loading from OnDocumentComplete, + // browser stops working + SetBrowserDesignModeOff(FThirdPartyWebBrowser); + + TStreamAdapter * ThirdPartyStreamAdapter = new TStreamAdapter(ThirdPartyStream.get(), soReference); + IPersistStreamInit * PersistStreamInit = NULL; + if (ALWAYS_TRUE(FThirdPartyWebBrowser->Document != NULL) && + SUCCEEDED(FThirdPartyWebBrowser->Document->QueryInterface(IID_IPersistStreamInit, (void **)&PersistStreamInit)) && + ALWAYS_TRUE(PersistStreamInit != NULL)) + { + PersistStreamInit->Load(static_cast<_di_IStream>(*ThirdPartyStreamAdapter)); + } } //--------------------------------------------------------------------------- -void __fastcall TAboutDialog::LicenseButtonClick(TObject * /*Sender*/) +void __fastcall TAboutDialog::AddPara(UnicodeString & Text, const UnicodeString & S) { - DoProductLicense(); + Text += L"

            " + S + L"

            \n"; } //--------------------------------------------------------------------------- -void __fastcall TAboutDialog::HelpButtonClick(TObject * /*Sender*/) +UnicodeString __fastcall TAboutDialog::CreateLink(const UnicodeString & URL, const UnicodeString & Title) { - FormHelp(this); + return FORMAT(L"%s", (URL, Title.IsEmpty() ? URL : Title)); } //--------------------------------------------------------------------------- -void __fastcall TAboutDialog::FirstScrollingControlEnter(TObject * /*Sender*/) +void __fastcall TAboutDialog::LicenseButtonClick(TObject * /*Sender*/) { - ThirdPartyBox->VertScrollBar->Position = 0; + DoProductLicense(); } //--------------------------------------------------------------------------- -void __fastcall TAboutDialog::LastScrollingControlEnter(TObject * /*Sender*/) +void __fastcall TAboutDialog::HelpButtonClick(TObject * /*Sender*/) { - ThirdPartyBox->VertScrollBar->Position = - ThirdPartyBox->VertScrollBar->Range - ThirdPartyBox->ClientHeight; + FormHelp(this); } //--------------------------------------------------------------------------- void __fastcall TAboutDialog::RegistrationProductIdLabelClick( @@ -239,3 +330,8 @@ void __fastcall TAboutDialog::OKButtonMouseDown(TObject * /*Sender*/, } } //--------------------------------------------------------------------------- +void __fastcall TAboutDialog::ExpatLicenceHandler(TObject * /*Sender*/) +{ + DoLicenseDialog(lcExpat); +} +//--------------------------------------------------------------------------- diff --git a/source/forms/About.dfm b/source/forms/About.dfm index a510c11f..f16ac812 100644 --- a/source/forms/About.dfm +++ b/source/forms/About.dfm @@ -6,15 +6,15 @@ object AboutDialog: TAboutDialog BorderIcons = [biSystemMenu, biMinimize, biMaximize, biHelp] BorderStyle = bsDialog Caption = 'About application' - ClientHeight = 484 - ClientWidth = 388 + ClientHeight = 531 + ClientWidth = 394 Color = clBtnFace ParentFont = True OldCreateOrder = True Position = poOwnerFormCenter DesignSize = ( - 388 - 484) + 394 + 531) PixelsPerInch = 96 TextHeight = 13 object ApplicationLabel: TLabel @@ -3529,182 +3529,19 @@ object AboutDialog: TAboutDialog TabOrder = 4 TabStop = True end - object ThirdPartyBox: TScrollBox + object ThirdPartyPanel: TPanel Left = 72 Top = 321 - Width = 306 - Height = 121 - HorzScrollBar.Range = 289 - HorzScrollBar.Visible = False - VertScrollBar.Range = 410 - VertScrollBar.Smooth = True - VertScrollBar.Tracking = True + Width = 312 + Height = 168 Anchors = [akLeft, akRight, akBottom] - AutoScroll = False - TabOrder = 6 - DesignSize = ( - 285 - 117) - object Label7: TLabel - Left = 8 - Top = 8 - Width = 232 - Height = 41 - Anchors = [akLeft, akTop, akRight] - AutoSize = False - Caption = - 'License agreements of all following programs (libraries) are par' + - 't of application license agreement.' - WordWrap = True - end - object PuttyVersionLabel: TLabel - Left = 8 - Top = 48 - Width = 189 - Height = 13 - Caption = 'SSH and SCP code based on PuTTY xxx' - end - object PuttyCopyrightLabel: TLabel - Left = 8 - Top = 64 - Width = 151 - Height = 13 - Caption = 'Copyright '#169' xxx Simon Tatham' - end - object Label8: TLabel - Left = 8 - Top = 365 - Width = 186 - Height = 13 - Caption = 'Filemanager Toolset library Version 2.6' - end - object Label10: TLabel - Left = 8 - Top = 381 - Width = 139 - Height = 13 - Caption = 'Copyright '#169' 1999 Ingo Eckel' - end - object Label1: TLabel - Left = 8 - Top = 253 - Width = 122 - Height = 13 - Caption = 'Toolbar2000 library 2.1.6' - end - object Label2: TLabel - Left = 8 - Top = 269 - Width = 187 - Height = 13 - Caption = 'Copyright '#169' 1998-2005 Jordan Russell' - end - object Label5: TLabel - Left = 8 - Top = 309 - Width = 70 - Height = 13 - Caption = 'TBX library 2.1' - end - object Label6: TLabel - Left = 8 - Top = 325 - Width = 194 - Height = 13 - Caption = 'Copyright '#169' 2001-2005 Alex A. Denisov and contributors' - end - object FileZillaVersionLabel: TLabel - Left = 8 - Top = 128 - Width = 148 - Height = 13 - Caption = 'FTP code based on Filezilla xxx' - end - object FileZillaCopyrightLabel: TLabel - Left = 8 - Top = 144 - Width = 131 - Height = 13 - Caption = 'Copyright '#169' xxx Tim Kosse' - end - object OpenSSLVersionLabel: TLabel - Left = 8 - Top = 184 - Width = 273 - Height = 29 - AutoSize = False - Caption = - 'This product includes software developed by the OpenSSL Project ' + - 'for use in the OpenSSL Toolkit xxx.' - WordWrap = True - end - object OpenSSLCopyrightLabel: TLabel - Left = 8 - Top = 213 - Width = 191 - Height = 13 - Caption = 'Copyright '#169' xxxx The OpenSSL Project' - end - object PuttyLicenseLabel: TStaticText - Tag = 1 - Left = 8 - Top = 80 - Width = 73 - Height = 17 - Caption = 'Display license' - TabOrder = 0 - TabStop = True - OnClick = PuttyLicenseLabelClick - end - object PuttyHomepageLabel: TStaticText - Left = 8 - Top = 96 - Width = 286 - Height = 17 - Caption = 'http://XXXwww.chiark.greenend.org.uk/~sgtatham/putty/' - TabOrder = 1 - TabStop = True - end - object Toolbar2000HomepageLabel: TStaticText - Left = 8 - Top = 285 - Width = 189 - Height = 17 - Caption = 'http://www.jrsoftware.org/tb2kdl.php' - TabOrder = 4 - TabStop = True - end - object TBXHomepageLabel: TStaticText - Left = 8 - Top = 341 - Width = 146 - Height = 17 - Caption = 'https://github.com/plashenkov/TBX' - TabOrder = 5 - TabStop = True - end - object FileZillaHomepageLabel: TStaticText - Left = 8 - Top = 160 - Width = 171 - Height = 17 - Caption = 'http://XXXfilezilla.sourceforge.net/' - TabOrder = 2 - TabStop = True - end - object OpenSSLHomepageLabel: TStaticText - Left = 8 - Top = 229 - Width = 118 - Height = 17 - Caption = 'http://XXX.openssl.org/' - TabOrder = 3 - TabStop = True - end + BevelKind = bkTile + BevelOuter = bvNone + TabOrder = 7 end object OKButton: TButton - Left = 221 - Top = 451 + Left = 227 + Top = 498 Width = 75 Height = 25 Anchors = [akRight, akBottom] @@ -3717,17 +3554,17 @@ object AboutDialog: TAboutDialog end object LicenseButton: TButton Left = 72 - Top = 451 + Top = 498 Width = 75 Height = 25 Anchors = [akLeft, akBottom] Caption = '&License...' - TabOrder = 7 + TabOrder = 6 OnClick = LicenseButtonClick end object HelpButton: TButton - Left = 303 - Top = 451 + Left = 309 + Top = 498 Width = 75 Height = 25 Anchors = [akRight, akBottom] @@ -3735,23 +3572,22 @@ object AboutDialog: TAboutDialog TabOrder = 1 OnClick = HelpButtonClick end - object RegistrationBox: TScrollBox + object RegistrationBox: TPanel Left = 72 Top = 206 - Width = 306 + Width = 312 Height = 89 - HorzScrollBar.Visible = False - VertScrollBar.Smooth = True - VertScrollBar.Tracking = True - Anchors = [akLeft, akRight, akBottom] + Anchors = [akLeft, akTop, akRight] + BevelKind = bkTile + BevelOuter = bvNone TabOrder = 5 DesignSize = ( - 302 + 308 85) object RegistrationSubjectLabel: TLabel Left = 8 Top = 8 - Width = 277 + Width = 239 Height = 65 Anchors = [akLeft, akTop, akRight] AutoSize = False diff --git a/source/forms/About.h b/source/forms/About.h index 9c9122f9..1785531d 100644 --- a/source/forms/About.h +++ b/source/forms/About.h @@ -10,6 +10,7 @@ #include //---------------------------------------------------------------------------- #include +#include //---------------------------------------------------------------------------- class TAboutDialog : public TForm { @@ -20,39 +21,19 @@ class TAboutDialog : public TForm TStaticText *HomepageLabel; TLabel *ProductSpecificMessageLabel; TStaticText *ForumUrlLabel; - TScrollBox *ThirdPartyBox; - TLabel *PuttyVersionLabel; - TLabel *PuttyCopyrightLabel; - TStaticText *PuttyHomepageLabel; - TLabel *Label7; - TLabel *Label8; - TLabel *Label10; TButton *OKButton; TButton *LicenseButton; - TStaticText *PuttyLicenseLabel; TLabel *TranslatorLabel; - TLabel *Label1; - TLabel *Label2; - TStaticText *Toolbar2000HomepageLabel; - TLabel *Label5; - TLabel *Label6; - TStaticText *TBXHomepageLabel; TButton *HelpButton; TImage *Image; TStaticText *TranslatorUrlLabel; TLabel *Label3; TLabel *RegistrationLabel; - TScrollBox *RegistrationBox; + TPanel *RegistrationBox; TLabel *RegistrationLicensesLabel; TStaticText *RegistrationProductIdLabel; TLabel *RegistrationSubjectLabel; - TLabel *FileZillaVersionLabel; - TLabel *FileZillaCopyrightLabel; - TStaticText *FileZillaHomepageLabel; - TLabel *OpenSSLVersionLabel; - TStaticText *OpenSSLHomepageLabel; - TLabel *OpenSSLCopyrightLabel; - void __fastcall PuttyLicenseLabelClick(TObject *Sender); + TPanel *ThirdPartyPanel; void __fastcall LicenseButtonClick(TObject *Sender); void __fastcall HelpButtonClick(TObject *Sender); void __fastcall RegistrationProductIdLabelClick(TObject *Sender); @@ -61,13 +42,17 @@ class TAboutDialog : public TForm private: TConfiguration * FConfiguration; TNotifyEvent FOnRegistrationLink; - void __fastcall FirstScrollingControlEnter(TObject * Sender); - void __fastcall LastScrollingControlEnter(TObject * Sender); - void __fastcall FixWrappedLabelSize(TLabel * Label); + TWebBrowserEx * FThirdPartyWebBrowser; + + void __fastcall LoadData(); + void __fastcall LoadThirdParty(); + void __fastcall AddPara(UnicodeString & Text, const UnicodeString & S); + UnicodeString __fastcall CreateLink(const UnicodeString & URL, const UnicodeString & Title = L""); + void __fastcall ExpatLicenceHandler(TObject * Sender); + public: virtual __fastcall TAboutDialog(TComponent * AOwner, TConfiguration * Configuration, bool AllowLicense, TRegistration * Registration); - void __fastcall LoadData(); }; //---------------------------------------------------------------------------- #endif diff --git a/source/forms/Authenticate.cpp b/source/forms/Authenticate.cpp index 584edd54..56b12e98 100644 --- a/source/forms/Authenticate.cpp +++ b/source/forms/Authenticate.cpp @@ -11,6 +11,7 @@ #include #include #include +#include //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "PasswordEdit" @@ -87,6 +88,11 @@ void __fastcall TAuthenticateForm::Dispatch(void * AMessage) DoCancel(); TForm::Dispatch(AMessage); } + else if (Message.Msg == WM_MANAGES_CAPTION) + { + // caption managed in TAuthenticateForm::AdjustControls() + Message.Result = 1; + } else { TForm::Dispatch(AMessage); @@ -132,14 +138,16 @@ void __fastcall TAuthenticateForm::Log(const UnicodeString Message) //--------------------------------------------------------------------------- void __fastcall TAuthenticateForm::AdjustControls() { + UnicodeString ACaption; if (FStatus.IsEmpty()) { - Caption = FSessionData->SessionName; + ACaption = FSessionData->SessionName; } else { - Caption = FORMAT(L"%s - %s", (FStatus, FSessionData->SessionName)); + ACaption = FORMAT(L"%s - %s", (FStatus, FSessionData->SessionName)); } + Caption = FormatFormCaption(this, ACaption); } //--------------------------------------------------------------------------- TLabel * __fastcall TAuthenticateForm::GenerateLabel(int Current, UnicodeString Caption) @@ -227,18 +235,17 @@ bool __fastcall TAuthenticateForm::PromptUser(TPromptKind Kind, UnicodeString Na bool ShowSessionRememberPasswordPanel = false; bool ShowSavePasswordPanel = false; TSessionData * Data = NULL; - bool PasswordPrompt = IsPasswordPrompt(Kind, Prompts); - if (PasswordPrompt && StoredCredentialsTried) + if (IsPasswordPrompt(Kind, Prompts) && StoredCredentialsTried) { Data = StoredSessions->FindSame(FSessionData); ShowSavePasswordPanel = (Data != NULL) && !Data->Password.IsEmpty(); } - // do not offer to rememeber password, - // if we are offering to save the password to stored session + // do not offer to remember password, + // if we are offering to save the password to stored site if (!ShowSavePasswordPanel && (Prompts->Count == 1) && FLAGSET(int(Prompts->Objects[0]), pupRemember) && - ALWAYS_TRUE(PasswordPrompt)) + ALWAYS_TRUE(IsPasswordOrPassphrasePrompt(Kind, Prompts))) { ShowSessionRememberPasswordPanel = true; } @@ -433,6 +440,11 @@ bool __fastcall TAuthenticateForm::Execute(UnicodeString Status, TPanel * Panel, if (!Result) { + // This is not nice as it may untimately route to + // TTerminalThread::Cancel() and throw fatal exception, + // what actually means that any PromptUser call during authentication never + // return false and their fall back/alternative code never occurs. + // It probably needs fixing. DoCancel(); } diff --git a/source/forms/Copy.cpp b/source/forms/Copy.cpp index 8c9a6dc1..70d9fe78 100644 --- a/source/forms/Copy.cpp +++ b/source/forms/Copy.cpp @@ -133,23 +133,24 @@ void __fastcall TCopyDialog::AdjustTransferControls() } TImage * Image; + UnicodeString ACaption; if (!FMove) { if (!FToRemote && FLAGSET(FOutputOptions, cooRemoteTransfer)) { - Caption = LoadStr(REMOTE_COPY_TITLE); + ACaption = LoadStr(REMOTE_COPY_TITLE); Image = CopyImage; } else { if (RemotePaths()) { - Caption = LoadStr(COPY_COPY_TOREMOTE_CAPTION); + ACaption = LoadStr(COPY_COPY_TOREMOTE_CAPTION); Image = CopyUploadImage; } else { - Caption = LoadStr(COPY_COPY_TOLOCAL_CAPTION); + ACaption = LoadStr(COPY_COPY_TOLOCAL_CAPTION); Image = CopyDownloadImage; } } @@ -158,24 +159,26 @@ void __fastcall TCopyDialog::AdjustTransferControls() { if (!FToRemote && FLAGSET(FOutputOptions, cooRemoteTransfer)) { - Caption = LoadStr(COPY_MOVE_CAPTION); + ACaption = LoadStr(COPY_MOVE_CAPTION); Image = MoveImage; } else { if (RemotePaths()) { - Caption = LoadStr(COPY_MOVE_TOREMOTE_CAPTION); + ACaption = LoadStr(COPY_MOVE_TOREMOTE_CAPTION); Image = MoveUploadImage; } else { - Caption = LoadStr(COPY_MOVE_TOLOCAL_CAPTION); + ACaption = LoadStr(COPY_MOVE_TOLOCAL_CAPTION); Image = MoveDownloadImage; } } } + Caption = FormatFormCaption(this, ACaption); + CopyImage->Visible = (Image == CopyImage) || (Image == NULL); MoveImage->Visible = (Image == MoveImage); CopyUploadImage->Visible = (Image == CopyUploadImage); @@ -396,12 +399,12 @@ void __fastcall TCopyDialog::FormCloseQuery(TObject * /*Sender*/, { UnicodeString Dir = Directory; UnicodeString Drive = ExtractFileDrive(Dir); - if (!DirectoryExists(Dir)) + if (!DirectoryExists(ApiPath(Dir))) { if (MessageDialog(MainInstructions(FMTLOAD(CREATE_LOCAL_DIRECTORY, (Dir))), qtConfirmation, qaOK | qaCancel, HELP_NONE) != qaCancel) { - if (!ForceDirectories(Dir)) + if (!ForceDirectories(ApiPath(Dir))) { SimpleErrorDialog(FMTLOAD(CREATE_LOCAL_DIR_ERROR, (Dir))); CanClose = false; diff --git a/source/forms/CopyParamPreset.cpp b/source/forms/CopyParamPreset.cpp index 1c58056c..41964431 100644 --- a/source/forms/CopyParamPreset.cpp +++ b/source/forms/CopyParamPreset.cpp @@ -50,7 +50,10 @@ void __fastcall TCopyParamPresetDialog::UpdateControls() { EnableControl(OkButton, !DescriptionEdit->Text.IsEmpty()); EnableControl(RuleGroup, HasRuleCheck->Checked); - CurrentRuleButton->Visible = (FCurrentRuleData != NULL); + CurrentRuleButton->Visible = + (FCurrentRuleData != NULL) && + // current rule data are loaded implicitly + (FMode != cpmAddCurrent); } //--------------------------------------------------------------------------- void __fastcall TCopyParamPresetDialog::ControlChange(TObject * /*Sender*/) @@ -99,7 +102,15 @@ bool __fastcall TCopyParamPresetDialog::Execute(TCopyParamList * CopyParamList, DescriptionEdit->Text = L""; TCopyParamType Default; CopyParamsFrame->Params = Default; - HasRuleCheck->Checked = false; + if (FMode == cpmAddCurrent) + { + SetRuleData(*FCurrentRuleData); + HasRuleCheck->Checked = true; + } + else + { + HasRuleCheck->Checked = false; + } FIndex = -1; // never used if (Index < 0) { @@ -202,7 +213,7 @@ void __fastcall TCopyParamPresetDialog::FormCloseQuery(TObject * /*Sender*/, int Index = FCopyParamList->IndexOfName(Description); if (((FMode == cpmEdit) && (Index >= 0) && (Index != FIndex)) || - (((FMode == cpmAdd) || (FMode == cpmDuplicate)) && (Index >= 0))) + (((FMode == cpmAdd) || (FMode == cpmAddCurrent) || (FMode == cpmDuplicate)) && (Index >= 0))) { DescriptionEdit->SetFocus(); throw Exception(FMTLOAD(COPY_PARAM_DUPLICATE, (Description))); diff --git a/source/forms/CopyParams.cpp b/source/forms/CopyParams.cpp index eb51c784..8e6cefce 100644 --- a/source/forms/CopyParams.cpp +++ b/source/forms/CopyParams.cpp @@ -85,8 +85,16 @@ void __fastcall TCopyParamsFrame::SetParams(TCopyParamType value) IncludeFileMaskCombo->Text = value.IncludeFileMask.Masks; ClearArchiveCheck->Checked = value.ClearArchive; - assert(value.RemoveCtrlZ == value.RemoveBOM); - RemoveCtrlZAndBOMCheck->Checked = value.RemoveCtrlZ && value.RemoveBOM; + if (FLAGSET(CopyParamAttrs, cpaNoRemoveCtrlZ)) + { + FRemoveCtrlZ = value.RemoveCtrlZ; + RemoveCtrlZAndBOMCheck->Checked = value.RemoveBOM; + } + else + { + assert(FLAGCLEAR(CopyParamAttrs, cpaNoRemoveBOM)); + RemoveCtrlZAndBOMCheck->Checked = value.RemoveCtrlZ && value.RemoveBOM; + } SpeedCombo->Text = SetSpeedLimit(value.CPSLimit); @@ -131,7 +139,14 @@ TCopyParamType __fastcall TCopyParamsFrame::GetParams() Result.IncludeFileMask.Masks = IncludeFileMaskCombo->Text; Result.ClearArchive = ClearArchiveCheck->Checked; - Result.RemoveCtrlZ = RemoveCtrlZAndBOMCheck->Checked; + if (FLAGSET(CopyParamAttrs, cpaNoRemoveCtrlZ)) + { + Result.RemoveCtrlZ = FRemoveCtrlZ; + } + else + { + Result.RemoveCtrlZ = RemoveCtrlZAndBOMCheck->Checked; + } Result.RemoveBOM = RemoveCtrlZAndBOMCheck->Checked; Result.CPSLimit = GetSpeedLimit(SpeedCombo->Text); @@ -167,8 +182,15 @@ void __fastcall TCopyParamsFrame::UpdateControls() EnableControl(IncludeFileMaskLabel, IncludeFileMaskCombo->Enabled); EnableControl(ClearArchiveCheck, FLAGCLEAR(CopyParamAttrs, cpaNoClearArchive) && FLAGCLEAR(CopyParamAttrs, cpaIncludeMaskOnly) && Enabled); - // TODO: Change RemoveCtrlZAndBOMCheck caption when only cpaNoRemoveBOM is set - // (FTP protocol) + // Do not mention EOF when not supported, but only when at least BOM is supported. + // This is not ideal as it shows both BOM and EOF for FTP downloads + // (when EOF is never supported for FTP). + // But as the option is disabled for FTP download, it's not that bad. + // We do not have enough information here to implement this correctly. + RemoveCtrlZAndBOMCheck->Caption = + LoadStr( + FLAGSET(CopyParamAttrs, cpaNoRemoveCtrlZ) && FLAGCLEAR(CopyParamAttrs, cpaNoRemoveBOM) ? + COPY_PARAM_REMOVE_BOM : COPY_PARAM_REMOVE_BOM_EOF); EnableControl(RemoveCtrlZAndBOMCheck, (FLAGCLEAR(CopyParamAttrs, cpaNoRemoveCtrlZ) || FLAGCLEAR(CopyParamAttrs, cpaNoRemoveBOM)) && FLAGCLEAR(CopyParamAttrs, cpaIncludeMaskOnly) && diff --git a/source/forms/CopyParams.dfm b/source/forms/CopyParams.dfm index 9f346ea3..ea0b6f70 100644 --- a/source/forms/CopyParams.dfm +++ b/source/forms/CopyParams.dfm @@ -15,12 +15,12 @@ object CopyParamsFrame: TCopyParamsFrame DesignSize = ( 201 98) - object SpeedLabel2: TLabel + object SpeedLabel3: TLabel Left = 15 Top = 71 Width = 68 Height = 13 - Caption = '&Speed (KiB/s):' + Caption = '&Speed (KB/s):' FocusControl = SpeedCombo end object PreserveTimeCheck: TCheckBox @@ -147,7 +147,7 @@ object CopyParamsFrame: TCopyParamsFrame Top = 124 Width = 173 Height = 17 - Caption = 'Remo&ve BOM and EOF marks' + Caption = 'Remo&ve BOM and EOF marks X' TabOrder = 4 OnClick = ControlChange end diff --git a/source/forms/CopyParams.h b/source/forms/CopyParams.h index f5c4f9e2..c6b4c852 100644 --- a/source/forms/CopyParams.h +++ b/source/forms/CopyParams.h @@ -44,7 +44,7 @@ class TCopyParamsFrame : public TFrame TCheckBox *IgnorePermErrorsCheck; TCheckBox *ClearArchiveCheck; TStaticText *IncludeFileMaskHintText; - TLabel *SpeedLabel2; + TLabel *SpeedLabel3; THistoryComboBox *SpeedCombo; TButton *IncludeFileMaskButton; TCheckBox *NewerOnlyCheck; @@ -62,6 +62,7 @@ class TCopyParamsFrame : public TFrame TCopyParamType * FParams; int FCopyParamAttrs; TRightsExtFrame * FRightsFrame; + bool FRemoveCtrlZ; void __fastcall SetParams(TCopyParamType value); TCopyParamType __fastcall GetParams(); void __fastcall SetCopyParamAttrs(int value); diff --git a/source/forms/Custom.cpp b/source/forms/Custom.cpp index 944e389f..76203931 100644 --- a/source/forms/Custom.cpp +++ b/source/forms/Custom.cpp @@ -118,6 +118,14 @@ void __fastcall TCustomDialog::AddWinControl(TWinControl * Control) FCount++; } //--------------------------------------------------------------------------- +TCheckBox * __fastcall TCustomDialog::CreateAndAddCheckBox(const UnicodeString & Caption) +{ + TCheckBox * CheckBox = new TCheckBox(this); + CheckBox->Caption = Caption; + AddButtonControl(CheckBox); + return CheckBox; +} +//--------------------------------------------------------------------------- TLabel * __fastcall TCustomDialog::CreateLabel(UnicodeString Label) { TLabel * Result = new TLabel(this); @@ -241,8 +249,8 @@ void __fastcall TSaveSessionDialog::Init(bool CanSavePassword, SessionNameEdit = new TEdit(this); AddEdit(SessionNameEdit, CreateLabel(LoadStr(SAVE_SESSION_PROMPT))); - FRootFolder = LoadStr(SAVE_SESSION_ROOT_FOLDER); - std::auto_ptr Folders(new TStringList()); + FRootFolder = LoadStr(SAVE_SESSION_ROOT_FOLDER2); + std::unique_ptr Folders(new TStringList()); if (AdditionalFolders != NULL) { @@ -271,15 +279,11 @@ void __fastcall TSaveSessionDialog::Init(bool CanSavePassword, FolderCombo->Items->Add(FRootFolder); FolderCombo->Items->AddStrings(Folders.get()); - SavePasswordCheck = new TCheckBox(this); - SavePasswordCheck->Caption = LoadStr( - NotRecommendedSavingPassword ? SAVE_SESSION_PASSWORD : - (CustomWinConfiguration->UseMasterPassword ? SAVE_SESSION_PASSWORD_MASTER : SAVE_SESSION_PASSWORD_RECOMMENDED)); - AddButtonControl(SavePasswordCheck); + SavePasswordCheck = CreateAndAddCheckBox( + LoadStr(NotRecommendedSavingPassword ? SAVE_SESSION_PASSWORD : + (CustomWinConfiguration->UseMasterPassword ? SAVE_SESSION_PASSWORD_MASTER : SAVE_SESSION_PASSWORD_RECOMMENDED))); - CreateShortcutCheck = new TCheckBox(this); - CreateShortcutCheck->Caption = LoadStr(SAVE_SITE_WORKSPACE_SHORTCUT); - AddButtonControl(CreateShortcutCheck); + CreateShortcutCheck = CreateAndAddCheckBox(LoadStr(SAVE_SITE_WORKSPACE_SHORTCUT)); EnableControl(SavePasswordCheck, CanSavePassword); } @@ -358,7 +362,7 @@ TSessionData * __fastcall DoSaveSession(TSessionData * SessionData, !SameText(SessionData->UserName, AnonymousUserName); if (Configuration->DisablePasswordStoring || - !SessionData->HasAnyPassword()) + !SessionData->HasAnySessionPassword()) { PSavePassword = NULL; } @@ -366,8 +370,7 @@ TSessionData * __fastcall DoSaveSession(TSessionData * SessionData, { PSavePassword = &SavePassword; SavePassword = - ((OriginalSession != NULL) && - !OriginalSession->Password.IsEmpty()) || + ((OriginalSession != NULL) && OriginalSession->HasAnySessionPassword()) || !NotRecommendedSavingPassword; } @@ -400,7 +403,7 @@ TSessionData * __fastcall DoSaveSession(TSessionData * SessionData, { if ((PSavePassword != NULL) && !SavePassword) { - SessionData->Password = L""; + SessionData->ClearSessionPasswords(); } NewSession = @@ -482,22 +485,16 @@ __fastcall TSaveWorkspaceDialog::TSaveWorkspaceDialog( std::unique_ptr Workspaces(StoredSessions->GetWorkspaces()); WorkspaceNameCombo->Items->AddStrings(Workspaces.get()); - SavePasswordsCheck = new TCheckBox(this); - SavePasswordsCheck->Caption = LoadStr( - NotRecommendedSavingPasswords ? SAVE_WORKSPACE_PASSWORDS : + SavePasswordsCheck = CreateAndAddCheckBox( + LoadStr(NotRecommendedSavingPasswords ? SAVE_WORKSPACE_PASSWORDS : (CustomWinConfiguration->UseMasterPassword ? - SAVE_WORKSPACE_PASSWORDS_MASTER : SAVE_WORKSPACE_PASSWORDS_RECOMMENDED)); - AddButtonControl(SavePasswordsCheck); + SAVE_WORKSPACE_PASSWORDS_MASTER : SAVE_WORKSPACE_PASSWORDS_RECOMMENDED))); EnableControl(SavePasswordsCheck, CanSavePasswords); - CreateShortcutCheck = new TCheckBox(this); - CreateShortcutCheck->Caption = LoadStr(SAVE_SITE_WORKSPACE_SHORTCUT); - AddButtonControl(CreateShortcutCheck); + CreateShortcutCheck = CreateAndAddCheckBox(LoadStr(SAVE_SITE_WORKSPACE_SHORTCUT)); - EnableAutoSaveCheck = new TCheckBox(this); - EnableAutoSaveCheck->Caption = LoadStr(SAVE_WORKSPACE_AUTO); - AddButtonControl(EnableAutoSaveCheck); + EnableAutoSaveCheck = CreateAndAddCheckBox(LoadStr(SAVE_WORKSPACE_AUTO)); } //--------------------------------------------------------------------------- bool __fastcall TSaveWorkspaceDialog::Execute( @@ -629,12 +626,14 @@ __fastcall TRemoteMoveDialog::TRemoteMoveDialog() : TCustomDialog(HELP_REMOTE_MOVE) { Caption = LoadStr(REMOTE_MOVE_TITLE); + // The same as TRemoteTransferDialog + ClientWidth = ScaleByTextHeight(this, 420); AddImage(L"REMOTE_MOVE_FILE"); Combo = new THistoryComboBox(this); Combo->AutoComplete = false; - AddComboBox(Combo, CreateLabel(LoadStr(REMOTE_TRANSFER_PROMPT))); + AddComboBox(Combo, CreateLabel(LoadStr(REMOTE_TRANSFER_PROMPT2))); } //--------------------------------------------------------------------------- bool __fastcall TRemoteMoveDialog::Execute(UnicodeString & Target, UnicodeString & FileMask) @@ -660,6 +659,6 @@ void __fastcall TRemoteMoveDialog::DoShow() //--------------------------------------------------------------------------- bool __fastcall DoRemoteMoveDialog(UnicodeString & Target, UnicodeString & FileMask) { - std::auto_ptr Dialog(new TRemoteMoveDialog()); + std::unique_ptr Dialog(new TRemoteMoveDialog()); return Dialog->Execute(Target, FileMask); } diff --git a/source/forms/Custom.h b/source/forms/Custom.h index 77b0f494..e6b3f659 100644 --- a/source/forms/Custom.h +++ b/source/forms/Custom.h @@ -37,6 +37,7 @@ class TCustomDialog : public TForm __fastcall TCustomDialog(UnicodeString HelpKeyword); TLabel * __fastcall CreateLabel(UnicodeString Label); + TCheckBox * __fastcall CreateAndAddCheckBox(const UnicodeString & Caption); void __fastcall AddEditLikeControl(TWinControl * Edit, TLabel * Label); void __fastcall AddEdit(TCustomEdit * Edit, TLabel * Label); void __fastcall AddComboBox(TCustomCombo * Combo, TLabel * Label); diff --git a/source/forms/CustomScpExplorer.cpp b/source/forms/CustomScpExplorer.cpp index 06b16da7..560304e9 100644 --- a/source/forms/CustomScpExplorer.cpp +++ b/source/forms/CustomScpExplorer.cpp @@ -75,6 +75,7 @@ } //--------------------------------------------------------------------------- #define WM_COMPONENT_HIDE (WM_WINSCP_USER + 4) +static const int SessionPanelCount = 4; //--------------------------------------------------------------------------- class TMutexGuard { @@ -181,11 +182,16 @@ __fastcall TCustomScpExplorerForm::TCustomScpExplorerForm(TComponent* Owner): FTrayIcon->OnClick = TrayIconClick; FMaxQueueLength = 0; FLastContextPopupScreenPoint = TPoint(-1, -1); + FTransferResumeList = NULL; + FMoveToQueue = false; + FStandaloneEditing = false; + FOnFeedSynchronizeError = NULL; FEditorManager = new TEditorManager(); FEditorManager->OnFileChange = ExecutedFileChanged; FEditorManager->OnFileReload = ExecutedFileReload; FEditorManager->OnFileEarlyClosed = ExecutedFileEarlyClosed; + FEditorManager->OnFileUploadComplete = ExecutedFileUploadComplete; FLocalEditors = new TList(); @@ -220,24 +226,8 @@ __fastcall TCustomScpExplorerForm::TCustomScpExplorerForm(TComponent* Owner): TransferList->OnChange = TransferListChange; TransferList->OnDrawItem = TransferListDrawItem; - class TTBXPublicItem : public TTBXCustomItem - { - public: - __property ItemStyle; - }; - TTBXPublicItem * ColorMenu; - ColorMenu = - reinterpret_cast( - dynamic_cast( - static_cast(GetComponent(fcColorMenu)))); - assert(ColorMenu != NULL); - ColorMenu->ItemStyle = ColorMenu->ItemStyle << tbisSubmenu; - ColorMenu = - reinterpret_cast( - dynamic_cast( - static_cast(NonVisualDataModule->ColorMenuItem))); - assert(ColorMenu != NULL); - ColorMenu->ItemStyle = ColorMenu->ItemStyle << tbisSubmenu; + SetSubmenu(dynamic_cast(static_cast(GetComponent(fcColorMenu)))); + SetSubmenu(NonVisualDataModule->ColorMenuItem); UseDesktopFont(SessionsPageControl); SessionsPageControl->Height =SessionsPageControl->GetTabsHeight(); @@ -714,12 +704,20 @@ void __fastcall TCustomScpExplorerForm::QueueItemUpdate(TTerminalQueue * Queue, } } //--------------------------------------------------------------------------- +bool __fastcall TCustomScpExplorerForm::IsQueueAutoPopup() +{ + // during standalone editing, we have no way to see/control queue, + // so we have to always popup prompts automatically + return FStandaloneEditing || GUIConfiguration->QueueAutoPopup; +} +//--------------------------------------------------------------------------- void __fastcall TCustomScpExplorerForm::RefreshQueueItems() { if (FQueueStatus != NULL) { - bool QueueAutoPopup = GUIConfiguration->QueueAutoPopup; - bool Refresh = FQueueItemInvalidated; + bool QueueAutoPopup = IsQueueAutoPopup(); + bool NeedRefresh = FQueueController->NeedRefresh(); + bool Refresh = FQueueItemInvalidated || NeedRefresh; FQueueItemInvalidated = false; int Limit = Refresh ? FQueueStatus->Count : FQueueStatus->DoneAndActiveCount; @@ -746,7 +744,7 @@ void __fastcall TCustomScpExplorerForm::RefreshQueueItems() Updated = true; Update = true; } - else if (FQueueController->QueueItemNeedsFrequentRefresh(QueueItem)) + else if (FQueueController->QueueItemNeedsFrequentRefresh(QueueItem) || NeedRefresh) { Update = true; } @@ -1007,7 +1005,7 @@ bool __fastcall TCustomScpExplorerForm::CopyParamDialog( { if (WinConfiguration->DDTransferConfirmation == asAuto) { - PopupTrayBalloon(NULL, LoadStr(DD_TRANSFER_CONFIRM_OFF), qtInformation, + PopupTrayBalloon(NULL, LoadStr(DD_TRANSFER_CONFIRM_OFF2), qtInformation, NULL, 0, EnableDDTransferConfirmation, NULL); } WinConfiguration->DDTransferConfirmation = asOff; @@ -1060,16 +1058,21 @@ bool __fastcall TCustomScpExplorerForm::CopyParamDialog( } Result = false; - TOperationSide Side = ((Direction == tdToRemote) ? osLocal : osRemote); - if (HasDirView[Side]) - { - DirView(Side)->SelectAll(smNone); - } + ClearTransferSourceSelection(Direction); } return Result; } //--------------------------------------------------------------------------- +void __fastcall TCustomScpExplorerForm::ClearTransferSourceSelection(TTransferDirection Direction) +{ + TOperationSide Side = ((Direction == tdToRemote) ? osLocal : osRemote); + if (HasDirView[Side]) + { + DirView(Side)->SelectAll(smNone); + } +} +//--------------------------------------------------------------------------- void __fastcall TCustomScpExplorerForm::AddQueueItem( TTransferDirection Direction, TStrings * FileList, const UnicodeString TargetDirectory, const TCopyParamType & CopyParam, @@ -1083,7 +1086,7 @@ void __fastcall TCustomScpExplorerForm::AddQueueItem( if (Direction == tdToRemote) { UnicodeString FileName = FileList->Strings[0]; - SingleFile = FileExists(FileName); + SingleFile = FileExists(::ApiPath(FileName)); } else { @@ -1103,6 +1106,16 @@ void __fastcall TCustomScpExplorerForm::AddQueueItem( QueueItem = new TDownloadQueueItem(Terminal, FileList, TargetDirectory, &CopyParam, Params, SingleFile); } + AddQueueItem(QueueItem); +} +//--------------------------------------------------------------------------- +void __fastcall TCustomScpExplorerForm::AddQueueItem(TQueueItem * QueueItem) +{ + if (Queue->IsEmpty) + { + TManagedTerminal * ManagedTerminal = NOT_NULL(dynamic_cast(Terminal)); + ManagedTerminal->QueueOperationStart = Now(); + } Queue->AddItem(QueueItem); } //--------------------------------------------------------------------------- @@ -1180,7 +1193,7 @@ UnicodeString __fastcall TCustomScpExplorerForm::GetToolbarsLayoutStr() } //--------------------------------------------------------------------------- void __fastcall TCustomScpExplorerForm::FileOperationProgress( - TFileOperationProgressType & ProgressData, TCancelStatus & /*Cancel*/) + TFileOperationProgressType & ProgressData) { // Download to temporary local directory if (FPendingTempSpaceWarn && ProgressData.InProgress && ProgressData.TotalSizeSet) @@ -1197,7 +1210,7 @@ void __fastcall TCustomScpExplorerForm::FileOperationProgress( // operation is being executed and we still didn't show up progress form if (ProgressData.InProgress && !FProgressForm) { - FProgressForm = new TProgressForm(Application); + FProgressForm = new TProgressForm(Application, (FTransferResumeList != NULL)); // As progress window has delayed show now, we need to lock ourselves, // (at least) until then LockWindow(); @@ -1209,7 +1222,8 @@ void __fastcall TCustomScpExplorerForm::FileOperationProgress( // we suppose "/upload" or URL download mode if (!Visible && (ProgressData.Operation != foCalculateSize) && (ProgressData.Operation != foCalculateChecksum) && - (FSynchronizeProgressForm == NULL)) + (FSynchronizeProgressForm == NULL) && + !FStandaloneEditing) { FProgressForm->OnceDoneOperation = odoDisconnect; } @@ -1258,6 +1272,28 @@ void __fastcall TCustomScpExplorerForm::FileOperationProgress( { ProgressData.Cancel = FProgressForm->Cancel; } + + if (FProgressForm->MoveToQueue) + { + FMoveToQueue = true; + if (ProgressData.Cancel < csCancel) + { + ProgressData.Cancel = csCancel; + } + } + + if ((FTransferResumeList != NULL) && + ProgressData.InProgress && + ((ProgressData.Operation == foCopy) || (ProgressData.Operation == foMove)) && + !ProgressData.FullFileName.IsEmpty()) + { + if ((FTransferResumeList->Count == 0) || + (FTransferResumeList->Strings[FTransferResumeList->Count - 1] != ProgressData.FullFileName)) + { + // note that we do not recognise directories from files here + FTransferResumeList->Add(ProgressData.FullFileName); + } + } } } //--------------------------------------------------------------------------- @@ -1272,9 +1308,9 @@ void __fastcall TCustomScpExplorerForm::OperationComplete( } //--------------------------------------------------------------------------- void __fastcall TCustomScpExplorerForm::OperationProgress( - TFileOperationProgressType & ProgressData, TCancelStatus & Cancel) + TFileOperationProgressType & ProgressData) { - FileOperationProgress(ProgressData, Cancel); + FileOperationProgress(ProgressData); } //--------------------------------------------------------------------------- bool __fastcall TCustomScpExplorerForm::PanelOperation(TOperationSide /*Side*/, @@ -1891,6 +1927,7 @@ void __fastcall TCustomScpExplorerForm::BatchStart(void *& /*Storage*/) if (WinConfiguration->ContinueOnError) { FErrorList = new TStringList(); + Configuration->Usage->Inc(L"ContinuationsOnError"); } NonVisualDataModule->StartBusy(); } @@ -1958,46 +1995,82 @@ bool __fastcall TCustomScpExplorerForm::ExecuteFileOperation(TFileOperation Oper UpdateCopyParamCounters(CopyParam); + std::unique_ptr TransferResumeList(new TStringList()); + assert(FTransferResumeList == NULL); + FTransferResumeList = + Terminal->IsCapable[fcMoveToQueue] ? TransferResumeList.get() : NULL; + FMoveToQueue = false; + + int Params = FLAGMASK(Operation == foMove, cpDelete); + try { - if (Side == osLocal) - { - int Params = - FLAGMASK(Operation == foMove, cpDelete) | - FLAGMASK(Temp, cpTemporary); - Terminal->CopyToRemote(FileList, TargetDirectory, &CopyParam, Params); - if (Operation == foMove) - { - ReloadLocalDirectory(); - if (DView != NULL) - { - DView->RestoreSelection(); - } - SelectionRestored = true; - } - } - else + try { - try - { - int Params = - (Operation == foMove ? cpDelete : 0); - Terminal->CopyToLocal(FileList, TargetDirectory, &CopyParam, - Params); - } - __finally + if (Side == osLocal) { + Params |= FLAGMASK(Temp, cpTemporary); + Terminal->CopyToRemote(FileList, TargetDirectory, &CopyParam, Params); if (Operation == foMove) { + ReloadLocalDirectory(); if (DView != NULL) { DView->RestoreSelection(); } SelectionRestored = true; } - ReloadLocalDirectory(TargetDirectory); + } + else + { + try + { + Terminal->CopyToLocal(FileList, TargetDirectory, &CopyParam, + Params); + } + __finally + { + if (Operation == foMove) + { + if (DView != NULL) + { + DView->RestoreSelection(); + } + SelectionRestored = true; + } + ReloadLocalDirectory(TargetDirectory); + } } } + catch (EAbort &) + { + if (FMoveToQueue) + { + Params |= + (CopyParam.QueueNoConfirmation ? cpNoConfirmation : 0); + + assert(CopyParam.TransferSkipList == NULL); + assert(CopyParam.TransferResumeFile.IsEmpty()); + if (TransferResumeList->Count > 0) + { + CopyParam.TransferResumeFile = TransferResumeList->Strings[TransferResumeList->Count - 1]; + TransferResumeList->Delete(TransferResumeList->Count - 1); + } + + CopyParam.TransferSkipList = TransferResumeList.release(); + + // not really needed, just to keep it consistent with TransferResumeList + FTransferResumeList = NULL; + FMoveToQueue = false; + + Configuration->Usage->Inc("MovesToBackground"); + + AddQueueItem(Direction, FileList, TargetDirectory, CopyParam, Params); + ClearTransferSourceSelection(Direction); + } + + throw; + } } __finally { @@ -2005,6 +2078,7 @@ bool __fastcall TCustomScpExplorerForm::ExecuteFileOperation(TFileOperation Oper { DView->DiscardSavedSelection(); } + FTransferResumeList = NULL; } } } @@ -2108,7 +2182,7 @@ bool __fastcall TCustomScpExplorerForm::ExecuteFileOperation(TFileOperation Oper } else { - assert(false); + FAIL; } } __finally @@ -2221,6 +2295,20 @@ void __fastcall TCustomScpExplorerForm::HandleErrorList(TStringList *& ErrorList } } //--------------------------------------------------------------------------- +void __fastcall TCustomScpExplorerForm::ExecuteRemoteFile( + const UnicodeString & FullFileName, TRemoteFile * File, TExecuteFileBy ExecuteFileBy) +{ + // needed for checking filemasks, as there's no directory object + // associated with the file object + File->FullFileName = FullFileName; + + TFileMasks::TParams MaskParams; + MaskParams.Size = File->Size; + MaskParams.Modification = File->Modification; + + ExecuteFile(osRemote, ExecuteFileBy, NULL, FullFileName, File, MaskParams); +} +//--------------------------------------------------------------------------- void __fastcall TCustomScpExplorerForm::EditNew(TOperationSide Side) { assert(!WinConfiguration->DisableOpenEdit); @@ -2257,16 +2345,7 @@ void __fastcall TCustomScpExplorerForm::EditNew(TOperationSide Side) { try { - // needed for checking filemasks, as there's no directory object - // associated with the file object - File->FullFileName = Name; - - TFileMasks::TParams MaskParams; - MaskParams.Size = File->Size; - MaskParams.Modification = File->Modification; - - ExecuteFile(Side, efDefaultEditor, NULL, Name, File, MaskParams); - + ExecuteRemoteFile(Name, File, efDefaultEditor); return; } __finally @@ -2297,9 +2376,9 @@ void __fastcall TCustomScpExplorerForm::EditNew(TOperationSide Side) TargetFileName = ExtractFileName(Name); } - if (!FileExists(LocalFileName)) + if (!FileExists(::ApiPath(LocalFileName))) { - int File = FileCreate(LocalFileName); + int File = FileCreate(::ApiPath(LocalFileName)); if (File < 0) { if (!RootTempDir.IsEmpty()) @@ -2373,7 +2452,8 @@ void __fastcall TCustomScpExplorerForm::CustomExecuteFile(TOperationSide Side, try { Editor = ShowEditorForm(FileName, this, FEditorManager->FileChanged, - FEditorManager->FileReload, FEditorManager->FileClosed, Caption); + FEditorManager->FileReload, FEditorManager->FileClosed, Caption, + FStandaloneEditing, SessionColor); } catch(...) { @@ -2391,7 +2471,11 @@ void __fastcall TCustomScpExplorerForm::CustomExecuteFile(TOperationSide Side, } else { - FLocalEditors->Add(ShowEditorForm(FileName, this, NULL, NULL, LocalEditorClosed, L"")); + assert(!FStandaloneEditing); + TForm * Editor = + ShowEditorForm(FileName, this, NULL, NULL, LocalEditorClosed, + L"", false, SessionColor); + FLocalEditors->Add(Editor); } } else @@ -2474,7 +2558,7 @@ void __fastcall TCustomScpExplorerForm::TemporaryDirectoryForRemoteFiles( Result = IncludeTrailingBackslash(Result + CopyParam.ValidLocalPath(FromUnixPath(RemoteDirectory))); } - if (!ForceDirectories(Result)) + if (!ForceDirectories(::ApiPath(Result))) { throw EOSExtException(FMTLOAD(CREATE_TEMP_DIR_ERROR, (Result))); } @@ -2559,14 +2643,14 @@ void __fastcall TCustomScpExplorerForm::EditorAutoConfig() else { UnicodeString TempName = ExcludeTrailingBackslash(WinConfiguration->TemporaryDir()) + L".txt"; - if (FileExists(TempName)) + if (FileExists(::ApiPath(TempName))) { TryNextTime = true; UsageState = "F"; } else { - unsigned int File = FileCreate(TempName); + unsigned int File = FileCreate(::ApiPath(TempName)); if (File == (unsigned int)INVALID_HANDLE_VALUE) { TryNextTime = true; @@ -2587,7 +2671,7 @@ void __fastcall TCustomScpExplorerForm::EditorAutoConfig() { UnicodeString Executable = ExecutableBuf; if (Executable.IsEmpty() || - !FileExists(Executable)) + !FileExists(::ApiPath(Executable))) { UsageState = "N"; } @@ -2615,8 +2699,7 @@ void __fastcall TCustomScpExplorerForm::EditorAutoConfig() } UnicodeString Message = - MainInstructions( - FMTLOAD(EDITOR_AUTO_CONFIG, (ExecutableDescription, ExecutableDescription))); + FMTLOAD(EDITOR_AUTO_CONFIG2, (ExecutableDescription, ExecutableDescription)); unsigned int Answer = MessageDialog(Message, qtConfirmation, qaOK | qaCancel, HELP_EDITOR_AUTO_CONFIG); @@ -2642,7 +2725,7 @@ void __fastcall TCustomScpExplorerForm::EditorAutoConfig() } __finally { - DeleteFile(TempName); + DeleteFile(::ApiPath(TempName)); } } } @@ -2754,7 +2837,7 @@ void __fastcall TCustomScpExplorerForm::ExecuteFile(TOperationSide Side, break; default: - assert(false); + FAIL; } } else @@ -2777,7 +2860,7 @@ void __fastcall TCustomScpExplorerForm::ExecuteFile(TOperationSide Side, break; default: - assert(false); + FAIL; } } @@ -2933,7 +3016,7 @@ void __fastcall TCustomScpExplorerForm::ExecutedFileChanged(const UnicodeString TQueueItem * QueueItem = new TUploadQueueItem(Data->Terminal, FileList, Data->RemoteDirectory, &CopyParam, Params, true); QueueItem->CompleteEvent = UploadCompleteEvent; - Data->Queue->AddItem(QueueItem); + AddQueueItem(QueueItem); } __finally { @@ -3118,6 +3201,11 @@ void __fastcall TCustomScpExplorerForm::ExecutedFileEarlyClosed( } } //--------------------------------------------------------------------------- +void __fastcall TCustomScpExplorerForm::ExecutedFileUploadComplete(TObject * Sender) +{ + EditorFormFileUploadComplete(NOT_NULL(dynamic_cast(Sender))); +} +//--------------------------------------------------------------------------- void __fastcall TCustomScpExplorerForm::RemoteDirViewEnter(TObject * /*Sender*/) { SideEnter(osRemote); @@ -3177,7 +3265,7 @@ void __fastcall TCustomScpExplorerForm::DeleteFiles(TOperationSide Side, } //--------------------------------------------------------------------------- bool __fastcall TCustomScpExplorerForm::RemoteTransferDialog(TTerminal *& Session, - UnicodeString & Target, UnicodeString & FileMask, bool & DirectCopy, + TStrings * FileList, UnicodeString & Target, UnicodeString & FileMask, bool & DirectCopy, bool NoConfirmation, bool Move) { if (RemoteDriveView->DropTarget != NULL) @@ -3199,7 +3287,14 @@ bool __fastcall TCustomScpExplorerForm::RemoteTransferDialog(TTerminal *& Sessio Session = TTerminalManager::Instance()->ActiveTerminal; } Target = UnixIncludeTrailingBackslash(Target); - FileMask = L"*.*"; + if (FileList->Count == 1) + { + FileMask = DelimitFileNameMask(UnixExtractFileName(FileList->Strings[0])); + } + else + { + FileMask = L"*.*"; + } DirectCopy = FTerminal->IsCapable[fcRemoteCopy] || FTerminal->IsCapable[fcSecondaryShell]; bool Result = true; if (!NoConfirmation) @@ -3259,11 +3354,13 @@ bool __fastcall TCustomScpExplorerForm::RemoteTransferFiles( { bool DirectCopy; UnicodeString Target, FileMask; - bool Result = RemoteTransferDialog(Session, Target, FileMask, DirectCopy, NoConfirmation, Move); + bool Result = RemoteTransferDialog(Session, FileList, Target, FileMask, DirectCopy, NoConfirmation, Move); if (Result) { if (!Move && !DirectCopy) { + Configuration->Usage->Inc("RemoteCopyTemp"); + UnicodeString RootTempDir; UnicodeString TempDir; @@ -3305,10 +3402,14 @@ bool __fastcall TCustomScpExplorerForm::RemoteTransferFiles( { if (Move) { + Configuration->Usage->Inc("RemoteMove"); + Terminal->MoveFiles(FileList, Target, FileMask); } else { + Configuration->Usage->Inc("RemoteCopyDirect"); + assert(DirectCopy); assert(Session == FTerminal); @@ -3618,44 +3719,46 @@ void __fastcall TCustomScpExplorerForm::InitStatusBar() TTBXStatusBar * SessionStatusBar = (TTBXStatusBar *)GetComponent(fcStatusBar); assert(Terminal); + int Offset = SessionStatusBar->Panels->Count - SessionPanelCount; + bool SecurityEnabled = !SessionInfo.SecurityProtocolName.IsEmpty(); - SessionStatusBar->Panels->Items[1]->Enabled = SecurityEnabled; + SessionStatusBar->Panels->Items[Offset + 0]->Enabled = SecurityEnabled; // expanded from ?: to avoid memory leaks if (SecurityEnabled) { - SessionStatusBar->Panels->Items[1]->Hint = + SessionStatusBar->Panels->Items[Offset + 0]->Hint = FMTLOAD(STATUS_SECURE, (SessionInfo.SecurityProtocolName)); } else { - SessionStatusBar->Panels->Items[1]->Hint = LoadStr(STATUS_INSECURE); + SessionStatusBar->Panels->Items[Offset + 0]->Hint = LoadStr(STATUS_INSECURE); } if (FileSystemInfo.ProtocolName.IsEmpty()) { - SessionStatusBar->Panels->Items[2]->Caption = SessionInfo.ProtocolName; + SessionStatusBar->Panels->Items[Offset + 1]->Caption = SessionInfo.ProtocolName; } else { - SessionStatusBar->Panels->Items[2]->Caption = FileSystemInfo.ProtocolName; + SessionStatusBar->Panels->Items[Offset + 1]->Caption = FileSystemInfo.ProtocolName; } - SessionStatusBar->Panels->Items[2]->Hint = LoadStr(STATUS_PROTOCOL_HINT); + SessionStatusBar->Panels->Items[Offset + 1]->Hint = LoadStr(STATUS_PROTOCOL_HINT); - SessionStatusBar->Panels->Items[3]->Enabled = + SessionStatusBar->Panels->Items[Offset + 2]->Enabled = (!SessionInfo.CSCompression.IsEmpty() || !SessionInfo.SCCompression.IsEmpty()); if (SessionInfo.CSCompression == SessionInfo.SCCompression) { - SessionStatusBar->Panels->Items[3]->Hint = + SessionStatusBar->Panels->Items[Offset + 2]->Hint = FMTLOAD(STATUS_COMPRESSION_HINT, (DefaultStr(SessionInfo.CSCompression, LoadStr(NO_STR)))); } else { - SessionStatusBar->Panels->Items[3]->Hint = FMTLOAD(STATUS_COMPRESSION2_HINT, + SessionStatusBar->Panels->Items[Offset + 2]->Hint = FMTLOAD(STATUS_COMPRESSION2_HINT, (DefaultStr(SessionInfo.CSCompression, LoadStr(NO_STR)), DefaultStr(SessionInfo.SCCompression, LoadStr(NO_STR)))); } - SessionStatusBar->Panels->Items[4]->Hint = LoadStr(STATUS_DURATION_HINT); + SessionStatusBar->Panels->Items[Offset + 3]->Hint = LoadStr(STATUS_DURATION_HINT); UpdateStatusBar(); } @@ -3694,7 +3797,7 @@ void __fastcall TCustomScpExplorerForm::UpdateStatusBar() SessionStatusBar->Panels->Items[0]->Hint = FNoteHints; - SessionStatusBar->Panels->Items[4]->Caption = + SessionStatusBar->Panels->Items[SessionStatusBar->Panels->Count - 1]->Caption = FormatDateTimeSpan(Configuration->TimeFormat, Now() - SessionInfo.LoginTime); } } @@ -3707,14 +3810,17 @@ void __fastcall TCustomScpExplorerForm::UpdateStatusPanelText(TTBXStatusPanel * void __fastcall TCustomScpExplorerForm::Idle() { - if (FShowing) + if (FShowing || FStandaloneEditing) { FEditorManager->Check(); // make sure that Idle is called before update queue, as it may invoke QueueEvent // that needs to know if queue view is visible (and it may be closed after queue update) TTerminalManager::Instance()->Idle(); + } + if (FShowing) + { if (!NonVisualDataModule->Busy) { if (FRefreshRemoteDirectory) @@ -3743,14 +3849,20 @@ void __fastcall TCustomScpExplorerForm::Idle() } } } + } + if (FShowing || FStandaloneEditing) + { if (FQueueStatusInvalidated) { UpdateQueueStatus(false); } RefreshQueueItems(); + } + if (FShowing) + { UpdateStatusBar(); } @@ -3763,7 +3875,7 @@ void __fastcall TCustomScpExplorerForm::UserActionTimer(TObject * /*Sender*/) try { FUserActionTimer->Enabled = false; - if (GUIConfiguration->QueueAutoPopup && (FPendingQueueActionItem != NULL)) + if (IsQueueAutoPopup() && (FPendingQueueActionItem != NULL)) { if (TQueueItem::IsUserActionStatus(FPendingQueueActionItem->Status)) { @@ -3852,16 +3964,16 @@ void __fastcall TCustomScpExplorerForm::TrayIconClick(TObject * /*Sender*/) RestoreApp(); } //--------------------------------------------------------------------------- -void __fastcall TCustomScpExplorerForm::NewSession(bool FromSite) +void __fastcall TCustomScpExplorerForm::NewSession(bool FromSite, const UnicodeString & SessionUrl) { if (OpenInNewWindow()) { // todo: Pass FromSite - ExecuteNewInstance(L""); + ExecuteNewInstance(SessionUrl); } else { - TTerminalManager::Instance()->NewSession(FromSite); + TTerminalManager::Instance()->NewSession(FromSite, SessionUrl); } } //--------------------------------------------------------------------------- @@ -4049,19 +4161,15 @@ void __fastcall TCustomScpExplorerForm::ForceCloseLocalEditors() void __fastcall TCustomScpExplorerForm::RemoteDirViewDisplayProperties( TObject *Sender) { - APPLICATION_EXCEPTION_HACK_BEGIN + TStrings *FileList = ((TUnixDirView*)Sender)->CreateFileList(True, False, NULL); + try { - TStrings *FileList = ((TUnixDirView*)Sender)->CreateFileList(True, False, NULL); - try - { - SetProperties(osRemote, FileList); - } - __finally - { - delete FileList; - } + SetProperties(osRemote, FileList); + } + __finally + { + delete FileList; } - APPLICATION_EXCEPTION_HACK_END; } //--------------------------------------------------------------------------- void __fastcall TCustomScpExplorerForm::ComponentShowing(Byte Component, bool value) @@ -4237,7 +4345,7 @@ void __fastcall TCustomScpExplorerForm::DoDirViewExecFile(TObject * Sender, } else { - assert(false); + FAIL; } } @@ -4260,12 +4368,12 @@ bool __fastcall TCustomScpExplorerForm::GetHasDirView(TOperationSide Side) //--------------------------------------------------------------------------- void __fastcall TCustomScpExplorerForm::CompareDirectories() { - assert(false); + FAIL; } //--------------------------------------------------------------------------- void __fastcall TCustomScpExplorerForm::SynchronizeDirectories() { - assert(false); + FAIL; } //--------------------------------------------------------------------------- bool __fastcall TCustomScpExplorerForm::DoSynchronizeDirectories( @@ -4291,8 +4399,10 @@ bool __fastcall TCustomScpExplorerForm::DoSynchronizeDirectories( int CopyParamAttrs = Terminal->UsableCopyParamAttrs(0).Upload; int Options = FLAGMASK(SynchronizeAllowSelectedOnly(), soAllowSelectedOnly); + assert(FOnFeedSynchronizeError == NULL); Result = DoSynchronizeDialog(Params, &CopyParam, Controller.StartStop, - SaveSettings, Options, CopyParamAttrs, GetSynchronizeOptions, UseDefaults); + SaveSettings, Options, CopyParamAttrs, GetSynchronizeOptions, + FOnFeedSynchronizeError, UseDefaults); if (Result) { if (SaveSettings) @@ -4318,6 +4428,8 @@ bool __fastcall TCustomScpExplorerForm::DoSynchronizeDirectories( __finally { FSynchronizeController = NULL; + assert(FOnFeedSynchronizeError == NULL); + FOnFeedSynchronizeError = NULL; } return Result; } @@ -4469,7 +4581,7 @@ void __fastcall TCustomScpExplorerForm::GetSynchronizeOptions( { Options.Filter = new TStringList(); Options.Filter->CaseSensitive = false; - Options.Filter->Duplicates = dupAccept; + Options.Filter->Duplicates = Types::dupAccept; if (DirView(osRemote)->SelCount > 0) { @@ -4600,9 +4712,29 @@ void __fastcall TCustomScpExplorerForm::TerminalSynchronizeDirectory( FSynchronizeProgressForm->SetData(LocalDirectory, RemoteDirectory, Continue); } //--------------------------------------------------------------------------- +void __fastcall TCustomScpExplorerForm::StandaloneEdit(const UnicodeString & FileName) +{ + UnicodeString FullFileName = AbsolutePath(FTerminal->CurrentDirectory, FileName); + + TRemoteFile * File = NULL; + Terminal->ReadFile(FullFileName, File); + if (File != NULL) + { + std::unique_ptr FileOwner(File); + TValueRestorer Restorer(FStandaloneEditing); + FStandaloneEditing = true; + + ExecuteRemoteFile(FullFileName, File, efInternalEditor); + + Application->ShowMainForm = false; + + Application->Run(); + } +} +//--------------------------------------------------------------------------- void __fastcall TCustomScpExplorerForm::ExploreLocalDirectory() { - assert(false); + FAIL; } //--------------------------------------------------------------------------- TSessionData * __fastcall TCustomScpExplorerForm::CloneCurrentSessionData() @@ -4610,6 +4742,7 @@ TSessionData * __fastcall TCustomScpExplorerForm::CloneCurrentSessionData() std::unique_ptr SessionData(new TSessionData(L"")); SessionData->Assign(Terminal->SessionData); UpdateSessionData(SessionData.get()); + TTerminalManager::Instance()->UpdateSessionCredentials(SessionData.get()); SessionData->IsWorkspace = false; return SessionData.release(); } @@ -4659,7 +4792,7 @@ void __fastcall TCustomScpExplorerForm::DoSaveWorkspace( if (SessionData->Link.IsEmpty()) { - SessionData->Password = L""; + SessionData->ClearSessionPasswords(); } } } @@ -4692,7 +4825,7 @@ bool __fastcall TCustomScpExplorerForm::SaveWorkspace(bool EnableAutoSave) if (SessionData->Link.IsEmpty()) { - if (SessionData->HasAnyPassword()) + if (SessionData->HasAnySessionPassword()) { AnyNonStoredSessionWithPassword = true; if (!Manager->Terminals[Index]->SessionData->IsWorkspace) @@ -4886,7 +5019,7 @@ TStrings * __fastcall TCustomScpExplorerForm::CreateVisitedDirectories(TOperatio { TCustomDirView * DView = DirView(Side); - VisitedDirectories->Duplicates = dupIgnore; + VisitedDirectories->Duplicates = Types::dupIgnore; // we should better use TCustomDirView::FCaseSensitive, but it is private VisitedDirectories->CaseSensitive = (Side == osRemote); VisitedDirectories->Sorted = true; @@ -5201,7 +5334,7 @@ void __fastcall TCustomScpExplorerForm::LastTerminalClosed(TObject * /*Sender*/) { try { - TTerminalManager::Instance()->NewSession(false); + TTerminalManager::Instance()->NewSession(false, L""); } __finally { @@ -5516,11 +5649,9 @@ void __fastcall TCustomScpExplorerForm::WMEndSession(TWMEndSession & Message) // but that sometimes (particularly when application is minimized) cause crashes. // Crash popups message that blocks log off. // Obviously application cannot shutdown cleanly after WM_ENDSESSION, - // so we call ExitProcess() immediatelly, not even trying to cleanup. + // so we call ExitProcess() immediately, not even trying to cleanup. // It still causes beep, so there's likely some popup, but it does not block // log off. - // Still needs testing on Windows 8 final. On Windows 8 preview it still blocks. - // Works on Windows XP and 7. ExitProcess(0); } TForm::Dispatch(&Message); @@ -5568,15 +5699,22 @@ void __fastcall TCustomScpExplorerForm::PopupTrayBalloon(TTerminal * Terminal, if (Do && WinConfiguration->BalloonNotifications) { - Message = UnformatMessage(Message); - - const ResourceString * Captions[] = { &_SMsgDlgConfirm, &_SMsgDlgWarning, - &_SMsgDlgError, &_SMsgDlgInformation, NULL }; - UnicodeString Title = LoadResourceString(Captions[Type]); - if (Terminal != NULL) + UnicodeString Title; + if ((Terminal == NULL) && (Type == qtInformation) && ExtractMainInstructions(Message, Title)) + { + Message = TrimLeft(Message); + } + else { - Title = FORMAT(L"%s - %s", - (TTerminalManager::Instance()->TerminalTitle(Terminal), Title)); + Message = UnformatMessage(Message); + const ResourceString * Captions[] = { &_SMsgDlgConfirm, &_SMsgDlgWarning, + &_SMsgDlgError, &_SMsgDlgInformation, NULL }; + Title = LoadResourceString(Captions[Type]); + if (Terminal != NULL) + { + Title = FORMAT(L"%s - %s", + (TTerminalManager::Instance()->TerminalTitle(Terminal), Title)); + } } if (Seconds == 0) @@ -5592,17 +5730,28 @@ unsigned int __fastcall TCustomScpExplorerForm::MoreMessageDialog(const UnicodeS UnicodeString HelpKeyword, const TMessageParams * Params, TTerminal * Terminal) { - if (WinConfiguration->ContinueOnError && - (Params != NULL) && (Params->Params & mpAllowContinueOnError) && - FErrorList) + if (((WinConfiguration->ContinueOnError && (FErrorList != NULL)) || + (FOnFeedSynchronizeError != NULL)) && + (Params != NULL) && (Params->Params & mpAllowContinueOnError) ) { - TStringList * MoreMessagesCopy = NULL; - if (MoreMessages) + if (FOnFeedSynchronizeError != NULL) { - MoreMessagesCopy = new TStringList(); - MoreMessagesCopy->Assign(MoreMessages); + FOnFeedSynchronizeError(Message, MoreMessages, Type, HelpKeyword); } - FErrorList->AddObject(Message, MoreMessagesCopy); + else + { + assert(FErrorList != NULL); + TStringList * MoreMessagesCopy = NULL; + if (MoreMessages) + { + MoreMessagesCopy = new TStringList(); + MoreMessagesCopy->Assign(MoreMessages); + } + FErrorList->AddObject(Message, MoreMessagesCopy); + } + + PopupTrayBalloon(Terminal, Message, Type); + return ContinueAnswer(Answers); } else @@ -5691,7 +5840,7 @@ void __fastcall TCustomScpExplorerForm::Notify(TTerminal * Terminal, Seconds *= 5; } - UnicodeString NoteMessage(Message); + UnicodeString NoteMessage(UnformatMessage(Message)); if (Terminal != NULL) { NoteMessage = FORMAT(L"%s: %s", @@ -5732,13 +5881,15 @@ void __fastcall TCustomScpExplorerForm::QueueEmptyNoteClicked(TObject * Sender) void __fastcall TCustomScpExplorerForm::QueueEvent(TTerminal * ATerminal, TTerminalQueue * /*Queue*/, TQueueEvent Event) { + TManagedTerminal * ManagedTerminal = NOT_NULL(dynamic_cast(ATerminal)); UnicodeString Message; TNotifyEvent OnClick = NULL; TObject * UserData = NULL; + bool QueueInvisible = !ComponentVisible[fcQueueView] || IsApplicationMinimized(); switch (Event) { - case qeEmpty: - if ((ATerminal != Terminal) || !ComponentVisible[fcQueueView]) + case qeEmptyButMonitored: + if ((ATerminal != Terminal) || QueueInvisible) { Message = LoadStr(BALLOON_QUEUE_EMPTY); OnClick = QueueEmptyNoteClicked; @@ -5748,16 +5899,20 @@ void __fastcall TCustomScpExplorerForm::QueueEvent(TTerminal * ATerminal, } break; + case qeEmpty: + OperationComplete(ManagedTerminal->QueueOperationStart); + break; + case qePendingUserAction: if ((ATerminal != Terminal) || - (!ComponentVisible[fcQueueView] && !GUIConfiguration->QueueAutoPopup)) + (QueueInvisible && !IsQueueAutoPopup())) { Message = LoadStr(BALLOON_QUEUE_USER_ACTION); } break; default: - assert(false); + FAIL; } if (!Message.IsEmpty()) @@ -5791,7 +5946,7 @@ void __fastcall TCustomScpExplorerForm::DDExtInitDrag(TFileList * FileList, { FDragExtFakeDirectory = ExcludeTrailingBackslash(WinConfiguration->TemporaryDir()); - if (!ForceDirectories(FDragExtFakeDirectory)) + if (!ForceDirectories(::ApiPath(FDragExtFakeDirectory))) { throw Exception(FMTLOAD(CREATE_TEMP_DIR_ERROR, (FDragExtFakeDirectory))); } @@ -5859,84 +6014,80 @@ bool __fastcall TCustomScpExplorerForm::RemoteFileControlFileOperation( //--------------------------------------------------------------------------- void __fastcall TCustomScpExplorerForm::RemoteFileControlDDEnd(TObject * Sender) { - APPLICATION_EXCEPTION_HACK_BEGIN - { - SAFE_DESTROY(FDDFileList); + SAFE_DESTROY(FDDFileList); - if (FDDExtMapFile != NULL) + if (FDDExtMapFile != NULL) + { + try { - try + TDragResult DDResult = (Sender == RemoteDirView) ? + RemoteDirView->LastDDResult : RemoteDriveView->LastDDResult; + + // Focus is moved to the target application, + // but as we are going to present the UI, we need to steal the focus back. + // This most likely won't work though (windows does not allow application + // to steal focus most of the time) + Application->BringToFront(); + + // note that we seem to never get drMove here, see also comment below + if ((DDResult == drCopy) || (DDResult == drMove) || (DDResult == drInvalid)) { - TDragResult DDResult = (Sender == RemoteDirView) ? - RemoteDirView->LastDDResult : RemoteDriveView->LastDDResult; + UnicodeString TargetDirectory; + TFileOperation Operation; - // Focus is moved to the target application, - // but as we are going to present the UI, we need to steal the focus back. - // This most likely won't work though (windows does not allow application - // to steal focus most of the time) - Application->BringToFront(); + // drInvalid may mean drMove, see comment below + Operation = (DDResult == drCopy) ? foCopy : foMove; - // note that we seem to never get drMove here, see also comment below - if ((DDResult == drCopy) || (DDResult == drMove) || (DDResult == drInvalid)) + if (FDDMoveSlipped) { - UnicodeString TargetDirectory; - TFileOperation Operation; - - // drInvalid may mean drMove, see comment below - Operation = (DDResult == drCopy) ? foCopy : foMove; + Operation = foMove; + } - if (FDDMoveSlipped) + TTransferOperationParam Param; + bool Internal; + if (!DDGetTarget(Param.TargetDirectory, Internal)) + { + // we get drInvalid both if move-d&d was intercepted by ddext, + // and when users drops on no-drop location. + // we tell the difference by existence of response from ddext, + // so we ignore absence of response in this case + if (DDResult != drInvalid) { - Operation = foMove; + // here we know that the extension is installed, + // as it is checked as soon as drag&drop starts from + // RemoteFileControlDDCreateDragFileList + Configuration->Usage->Inc(L"DownloadsDragDropExternalExtTargetUnknown"); + throw ExtException(NULL, LoadStr(DRAGEXT_TARGET_UNKNOWN2), HELP_DRAGEXT_TARGET_UNKNOWN); } + } + else + { + // download using ddext + Param.Temp = false; + Param.DragDrop = true; - TTransferOperationParam Param; - bool Internal; - if (!DDGetTarget(Param.TargetDirectory, Internal)) + if (RemoteFileControlFileOperation(Sender, Operation, + (WinConfiguration->DDTransferConfirmation == asOff), &Param)) { - // we get drInvalid both if move-d&d was intercepted by ddext, - // and when users drops on no-drop location. - // we tell the difference by existence of response from ddext, - // so we ignore absence of response in this case - if (DDResult != drInvalid) - { - // here we know that the extension is installed, - // as it is checked as soon as drag&drop starts from - // RemoteFileControlDDCreateDragFileList - Configuration->Usage->Inc(L"DownloadsDragDropExternalExtTargetUnknown"); - throw ExtException(NULL, LoadStr(DRAGEXT_TARGET_UNKNOWN2), HELP_DRAGEXT_TARGET_UNKNOWN); - } - } - else - { - // download using ddext - Param.Temp = false; - Param.DragDrop = true; - - if (RemoteFileControlFileOperation(Sender, Operation, - (WinConfiguration->DDTransferConfirmation == asOff), &Param)) - { - Configuration->Usage->Inc( - Internal ? L"DownloadsDragDropInternal" : L"DownloadsDragDropExternalExt"); - } + Configuration->Usage->Inc( + Internal ? L"DownloadsDragDropInternal" : L"DownloadsDragDropExternalExt"); } } } - __finally - { - CloseHandle(FDDExtMapFile); - FDDExtMapFile = NULL; - RemoveDir(FDragExtFakeDirectory); - FDragExtFakeDirectory = L""; - } } - - if (!FDragDropSshTerminate.IsEmpty()) + __finally { - throw ESshTerminate(NULL, FDragDropSshTerminate, FDragDropOnceDoneOperation); + CloseHandle(FDDExtMapFile); + FDDExtMapFile = NULL; + RemoveDir(::ApiPath(FDragExtFakeDirectory)); + FDragExtFakeDirectory = L""; } } - APPLICATION_EXCEPTION_HACK_END; + + if (!FDragDropSshTerminate.IsEmpty()) + { + throw ESshTerminate(NULL, FDragDropSshTerminate, FDragDropOnceDoneOperation); + } } //--------------------------------------------------------------------------- void __fastcall TCustomScpExplorerForm::RemoteFileControlDDGiveFeedback( @@ -6122,7 +6273,7 @@ void __fastcall TCustomScpExplorerForm::RemoteFileControlDDTargetDrop() { TargetDir = TempDir; - if (ForceDirectories(TargetDir)) + if (ForceDirectories(::ApiPath(TargetDir))) { assert(Terminal && !TargetDir.IsEmpty()); FPendingTempSpaceWarn = true; @@ -6203,7 +6354,7 @@ void __fastcall TCustomScpExplorerForm::RemoteFileControlDDCreateDataObject( //--------------------------------------------------------------------------- void __fastcall TCustomScpExplorerForm::GoToCommandLine() { - assert(false); + FAIL; } //--------------------------------------------------------------------------- void __fastcall TCustomScpExplorerForm::GoToTree() @@ -6212,64 +6363,50 @@ void __fastcall TCustomScpExplorerForm::GoToTree() RemoteDriveView->SetFocus(); } //--------------------------------------------------------------------------- -void __fastcall TCustomScpExplorerForm::PanelExport(TOperationSide Side, - TPanelExport Export, TPanelExportDestination Destination, bool OnFocused) +TStrings * __fastcall TCustomScpExplorerForm::PanelExport(TOperationSide Side, + TPanelExport Export) { - Side = GetSide(Side); TCustomDirView * DirView = this->DirView(Side); - TStringList * ExportData = new TStringList(); - try + std::unique_ptr ExportData(new TStringList()); + switch (Export) { - switch (Export) - { - case pePath: - ExportData->Add(DirView->PathName); - break; - - case peFileList: - case peFullFileList: - { - bool FullPath = (Export == peFullFileList); - DirView->CreateFileList(OnFocused, FullPath, ExportData); - UnicodeString FileName; - for (int Index = 0; Index < ExportData->Count; Index++) - { - if (ExportData->Strings[Index].Pos(L" ") > 0) - { - ExportData->Strings[Index] = FORMAT(L"\"%s\"", (ExportData->Strings[Index])); - } - } - } - break; + case pePath: + ExportData->Add(DirView->PathName); + break; - case peUrl: + case peFileList: + case peFullFileList: + { + bool FullPath = (Export == peFullFileList); + DirView->CreateFileList(false, FullPath, ExportData.get()); + UnicodeString FileName; + for (int Index = 0; Index < ExportData->Count; Index++) { - assert(DirView == RemoteDirView); - DirView->CreateFileList(OnFocused, true, ExportData); - for (int Index = 0; Index < ExportData->Count; Index++) + if (ExportData->Strings[Index].Pos(L" ") > 0) { - ExportData->Strings[Index] = - FTerminal->FileUrl(ExportData->Strings[Index]); + ExportData->Strings[Index] = FORMAT(L"\"%s\"", (ExportData->Strings[Index])); } } - break; - - default: - assert(false); - } + } + break; - PanelExportStore(Side, Export, Destination, ExportData); - } - __finally - { - delete ExportData; + default: + FAIL; } + return ExportData.release(); +} +//--------------------------------------------------------------------------- +void __fastcall TCustomScpExplorerForm::PanelExport(TOperationSide Side, + TPanelExport Export, TPanelExportDestination Destination) +{ + std::unique_ptr ExportData(PanelExport(Side, Export)); + PanelExportStore(Side, Export, Destination, ExportData.get()); } //--------------------------------------------------------------------------- void __fastcall TCustomScpExplorerForm::PanelExportStore(TOperationSide /*Side*/, TPanelExport /*Export*/, TPanelExportDestination Destination, - TStringList * ExportData) + TStrings * ExportData) { if (Destination == pedClipboard) { @@ -6278,7 +6415,7 @@ void __fastcall TCustomScpExplorerForm::PanelExportStore(TOperationSide /*Side*/ } else { - assert(false); + FAIL; } } //--------------------------------------------------------------------------- @@ -6546,11 +6683,7 @@ void __fastcall TCustomScpExplorerForm::RemoteFileControlDDFileOperation( TObject * Sender, int Effect, UnicodeString /*SourcePath*/, UnicodeString TargetPath, bool & /*DoOperation*/) { - APPLICATION_EXCEPTION_HACK_BEGIN - { - RemoteFileControlDragDropFileOperation(Sender, Effect, TargetPath); - } - APPLICATION_EXCEPTION_HACK_END; + RemoteFileControlDragDropFileOperation(Sender, Effect, TargetPath); } //--------------------------------------------------------------------------- void __fastcall TCustomScpExplorerForm::RemoteFileContolDDChooseEffect( @@ -6652,38 +6785,34 @@ void __fastcall TCustomScpExplorerForm::RemoteFileControlDDQueryContinueDrag( TObject * /*Sender*/, BOOL /*FEscapePressed*/, int /*grfKeyState*/, HRESULT & Result) { - APPLICATION_EXCEPTION_HACK_BEGIN + if (Result == DRAGDROP_S_DROP) { - if (Result == DRAGDROP_S_DROP) + try { + GlobalDragImageList->HideDragImage(); try { - GlobalDragImageList->HideDragImage(); - try - { - RemoteFileControlDDTargetDrop(); - } - catch(ESshTerminate & E) - { - assert(E.MoreMessages == NULL); // not supported - assert(!E.Message.IsEmpty()); - FDragDropSshTerminate = E.Message; - FDragDropOnceDoneOperation = E.Operation; - } + RemoteFileControlDDTargetDrop(); } - catch (Exception &E) + catch(ESshTerminate & E) { - // If downloading fails we need to cancel drag&drop, otherwise - // Explorer shows error - // But by the way exception probably never reach this point as - // it's catched on way - Result = DRAGDROP_S_CANCEL; - assert(Terminal != NULL); - Terminal->ShowExtendedException(&E); + assert(E.MoreMessages == NULL); // not supported + assert(!E.Message.IsEmpty()); + FDragDropSshTerminate = E.Message; + FDragDropOnceDoneOperation = E.Operation; } } + catch (Exception &E) + { + // If downloading fails we need to cancel drag&drop, otherwise + // Explorer shows error + // But by the way exception probably never reach this point as + // it's catched on way + Result = DRAGDROP_S_CANCEL; + assert(Terminal != NULL); + Terminal->ShowExtendedException(&E); + } } - APPLICATION_EXCEPTION_HACK_END } //--------------------------------------------------------------------------- void __fastcall TCustomScpExplorerForm::DirViewMatchMask( @@ -6736,10 +6865,17 @@ void __fastcall TCustomScpExplorerForm::PasteFromClipBoard() } else { - UnicodeString Path; - if (TextFromClipboard(Path) && !Path.IsEmpty()) + UnicodeString ClipboardText; + if (TextFromClipboard(ClipboardText, true) && !ClipboardText.IsEmpty()) { - DirView(osCurrent)->Path = Path; + if (StoredSessions->IsUrl(ClipboardText)) + { + NewSession(false, ClipboardText); + } + else + { + DirView(osCurrent)->Path = ClipboardText; + } } } } @@ -6759,39 +6895,59 @@ UnicodeString __fastcall TCustomScpExplorerForm::FileStatusBarText( FormatNumber(FileInfo.SelectedCount), FormatNumber(FileInfo.FilesCount))); - if ((FileInfo.HiddenCount > 0) || (FileInfo.FilteredCount > 0)) + return Result; +} +//--------------------------------------------------------------------------- +void __fastcall TCustomScpExplorerForm::FileStatusBarPanelClick( + TTBXStatusPanel * Panel, TOperationSide Side) +{ + if (Panel->Index == 1) { - UnicodeString Ex; - if (FileInfo.HiddenCount > 0) - { - Ex = FMTLOAD(FILE_INFO_HIDDEN, (FileInfo.HiddenCount)); - } - if (FileInfo.FilteredCount > 0) - { - if (!Ex.IsEmpty()) - { - Ex += L" + "; - } - Ex += FMTLOAD(FILE_INFO_FILTERED, (FileInfo.FilteredCount)); - } - Result = FMTLOAD(FILE_INFO_FORMAT_EX, (Result, Ex)); + ToggleShowHiddenFiles(); + } + else if (Panel->Index == 2) + { + Filter(Side); } - - return Result; } //--------------------------------------------------------------------------- void __fastcall TCustomScpExplorerForm::UpdateFileStatusBar( - TTBXStatusBar * StatusBar, const TStatusFileInfo & FileInfo, int Panel) + TTBXStatusBar * StatusBar, const TStatusFileInfo & FileInfo) +{ + assert(!StatusBar->SimplePanel); + StatusBar->Panels->Items[0]->Caption = FileStatusBarText(FileInfo); + UpdateFileStatusExtendedPanels(StatusBar, FileInfo); +} +//--------------------------------------------------------------------------- +void __fastcall TCustomScpExplorerForm::UpdateFileStatusExtendedPanels( + TTBXStatusBar * StatusBar, const TStatusFileInfo & FileInfo) { - UnicodeString Text = FileStatusBarText(FileInfo); - if (StatusBar->SimplePanel) + assert(StatusBar->Panels->Count >= 3); + + TTBXStatusPanel * HiddenFilesPanel = StatusBar->Panels->Items[1]; + if (FileInfo.HiddenCount > 0) + { + HiddenFilesPanel->Caption = FMTLOAD(FILE_INFO_HIDDEN2, (FormatNumber(FileInfo.HiddenCount))); + HiddenFilesPanel->ViewPriority = 90; // <100 allows hiding panel when it does not fit + } + else { - assert(Panel == 0); - StatusBar->SimpleText = Text; + HiddenFilesPanel->ViewPriority = 0; + // not really necessary, just to cleanup no-longer-valid data + HiddenFilesPanel->Caption = L""; + } + + TTBXStatusPanel * FilteredFilesPanel = StatusBar->Panels->Items[2]; + if (FileInfo.FilteredCount > 0) + { + FilteredFilesPanel->Caption = FMTLOAD(FILE_INFO_FILTERED2, (FormatNumber(FileInfo.FilteredCount))); + FilteredFilesPanel->ViewPriority = 90; // <100 allows hiding panel when it does not fit } else { - StatusBar->Panels->Items[Panel]->Caption = Text; + FilteredFilesPanel->ViewPriority = 0; + // not really necessary, just to cleanup no-longer-valid data + FilteredFilesPanel->Caption = L""; } } //--------------------------------------------------------------------------- @@ -6909,10 +7065,13 @@ void __fastcall TCustomScpExplorerForm::UpdatesChecked() GetUpdatesMessage(Message, New, Type, false); if (!Message.IsEmpty()) { - Message = UnformatMessage(Message); + if (New) + { + Message = FMTLOAD(NEW_VERSION_CLICK, (Message)); + } if (!New && (Type != qtWarning)) { - PostNote(Message, 0, UpdatesNoteClicked, NULL); + PostNote(UnformatMessage(Message), 0, UpdatesNoteClicked, NULL); } else { @@ -7222,6 +7381,11 @@ void __fastcall TCustomScpExplorerForm::Dispatch(void * Message) WMCopyData(*M); break; + case WM_MANAGES_CAPTION: + // caption managed in TTerminalManager::UpdateAppTitle() + M->Result = 1; + break; + default: TForm::Dispatch(Message); break; @@ -7233,7 +7397,7 @@ void __fastcall TCustomScpExplorerForm::FormConstrainedResize( int & MaxHeight) { // workaround for bug in TWinControl.CalcConstraints - // Check for empty rect (restore from iconinc state) is done there only after + // Check for empty rect (restore from iconic state) is done there only after // call to AdjustClientRect, which enlarges the rect (for forms). TRect R = GetClientRect(); // when restoring from iconic state, place no restrictions @@ -7282,6 +7446,25 @@ void __fastcall TCustomScpExplorerForm::FileSystemInfo() OnGetSpaceAvailable); } //--------------------------------------------------------------------------- +void __fastcall TCustomScpExplorerForm::GenerateUrl(TStrings * Paths) +{ + std::unique_ptr Data(CloneCurrentSessionData()); + const TSessionInfo & SessionInfo = Terminal->GetSessionInfo(); + Data->HostKey = SessionInfo.HostKeyFingerprint; + DoGenerateUrlDialog(Data.get(), Paths); +} +//--------------------------------------------------------------------------- +void __fastcall TCustomScpExplorerForm::SessionGenerateUrl() +{ + GenerateUrl(NULL); +} +//--------------------------------------------------------------------------- +void __fastcall TCustomScpExplorerForm::FileGenerateUrl() +{ + std::unique_ptr Paths(PanelExport(osCurrent, peFullFileList)); + GenerateUrl(Paths.get()); +} +//--------------------------------------------------------------------------- void __fastcall TCustomScpExplorerForm::SetSessionColor(TColor value) { if (value != FSessionColor) @@ -7315,7 +7498,7 @@ bool __fastcall TCustomScpExplorerForm::CancelNote(bool Force) if (Force || NotEarly) { FNoteTimer->Enabled = false; - FNote = ""; + FNote = L""; SAFE_DESTROY(FNoteData); FOnNoteClick = NULL; FNoteHints = FNotes->Text; @@ -7408,9 +7591,9 @@ void __fastcall TCustomScpExplorerForm::ToggleShowHiddenFiles() (WinConfiguration->ShowHiddenFiles ? 2 : 3)))), 0, NULL, NULL); } //--------------------------------------------------------------------------- -void __fastcall TCustomScpExplorerForm::ToggleFormatSizeBytes() +void __fastcall TCustomScpExplorerForm::SetFormatSizeBytes(TFormatBytesStyle Style) { - WinConfiguration->FormatSizeBytes = !WinConfiguration->FormatSizeBytes; + WinConfiguration->FormatSizeBytes = Style; } //--------------------------------------------------------------------------- void __fastcall TCustomScpExplorerForm::ToggleAutoReadDirectoryAfterOp() @@ -7422,7 +7605,7 @@ void __fastcall TCustomScpExplorerForm::ToggleAutoReadDirectoryAfterOp() } //--------------------------------------------------------------------------- void __fastcall TCustomScpExplorerForm::StatusBarPanelDblClick( - TTBXCustomStatusBar * /*Sender*/, TTBXStatusPanel * Panel) + TTBXCustomStatusBar * Sender, TTBXStatusPanel * Panel) { if (Panel->Index == 0) { @@ -7438,7 +7621,7 @@ void __fastcall TCustomScpExplorerForm::StatusBarPanelDblClick( OnNoteClick(NoteData.get()); } } - else + if (Panel->Index >= Sender->Panels->Count - SessionPanelCount) { FileSystemInfo(); } @@ -7451,6 +7634,7 @@ void __fastcall TCustomScpExplorerForm::LockWindow() // prevents it from restoring, even if it was enabled again meanwhile // 2) when disabling the main window, while another has focus // minimize is no longer possible ("keep up to date" dialog) + // Whouldn't we use IsApplicationMinimized() here? if ((FLockSuspendLevel == 0) && !IsIconic(Application->Handle) && (Screen->ActiveForm == this)) { Enabled = false; @@ -7617,7 +7801,7 @@ void __fastcall TCustomScpExplorerForm::ClickToolbarItem(TTBCustomItem * Item, if (PositionCursor) { - Mouse->CursorPos = Toolbar->ClientToScreen(P); + Mouse->CursorPos = Toolbar->ClientToScreen(TPoint(P.x, P.y)); } PostMessage(Toolbar->Handle, WM_LBUTTONDOWN, MK_LBUTTON, @@ -7756,6 +7940,20 @@ void __fastcall TCustomScpExplorerForm::SessionsPageControlMouseDown( } } } + else if (Button == mbMiddle) + { + // ignore middle-click for "New session tab" + TTerminal * Terminal = GetSessionTabTerminal(SessionsPageControl->Pages[Index]); + if (Terminal != NULL) + { + SessionsPageControl->ActivePageIndex = Index; + // Switch to session tab (has to be session tab, due to previous check) + if (ALWAYS_TRUE(SessionTabSwitched())) + { + CloseSession(); + } + } + } } } //--------------------------------------------------------------------------- @@ -7813,23 +8011,19 @@ void __fastcall TCustomScpExplorerForm::SessionsDDDragOver(int /*KeyState*/, void __fastcall TCustomScpExplorerForm::SessionsDDProcessDropped( TObject * /*Sender*/, int /*KeyState*/, const TPoint & Point, int Effect) { - APPLICATION_EXCEPTION_HACK_BEGIN + int Index = SessionsPageControl->IndexOfTabAt(Point.X, Point.Y); + // do not allow dropping on the "+" tab + TTerminal * TargetTerminal = GetSessionTabTerminal(SessionsPageControl->Pages[Index]); + if (TargetTerminal != NULL) { - int Index = SessionsPageControl->IndexOfTabAt(Point.X, Point.Y); - // do not allow dropping on the "+" tab - TTerminal * TargetTerminal = GetSessionTabTerminal(SessionsPageControl->Pages[Index]); - if (TargetTerminal != NULL) + assert(!IsFileControl(DropSourceControl, osRemote)); + if (!IsFileControl(DropSourceControl, osRemote)) { - assert(!IsFileControl(DropSourceControl, osRemote)); - if (!IsFileControl(DropSourceControl, osRemote)) - { - TTerminalManager::Instance()->ActiveTerminal = TargetTerminal; - RemoteFileControlDragDropFileOperation(SessionsPageControl, Effect, - TTerminalManager::Instance()->ActiveTerminal->CurrentDirectory); - } + TTerminalManager::Instance()->ActiveTerminal = TargetTerminal; + RemoteFileControlDragDropFileOperation(SessionsPageControl, Effect, + TTerminalManager::Instance()->ActiveTerminal->CurrentDirectory); } } - APPLICATION_EXCEPTION_HACK_END; } //--------------------------------------------------------------------------- void __fastcall TCustomScpExplorerForm::FormClose(TObject * /*Sender*/, TCloseAction & /*Action*/) @@ -8012,4 +8206,3 @@ bool __fastcall TCustomScpExplorerForm::HandleMouseWheel(WPARAM WParam, LPARAM L return Result; } //--------------------------------------------------------------------------- -#pragma warn -8080 diff --git a/source/forms/CustomScpExplorer.h b/source/forms/CustomScpExplorer.h index d5c059aa..23fae453 100644 --- a/source/forms/CustomScpExplorer.h +++ b/source/forms/CustomScpExplorer.h @@ -50,7 +50,7 @@ class ITaskbarList3; enum TActionAllowed { aaShortCut, aaUpdate, aaExecute }; enum TActionFlag { afLocal = 1, afRemote = 2, afExplorer = 4 , afCommander = 8 }; enum TExecuteFileBy { efShell = 1, efInternalEditor = 2, efExternalEditor = 3, efDefaultEditor = 100 }; -enum TPanelExport { pePath, peFileList, peFullFileList, peUrl }; +enum TPanelExport { pePath, peFileList, peFullFileList }; enum TPanelExportDestination { pedClipboard, pedCommandLine }; //--------------------------------------------------------------------------- class TCustomScpExplorerForm : public TForm @@ -240,6 +240,10 @@ class TCustomScpExplorerForm : public TForm typedef std::set TItemsWithTextDisplayMode; TItemsWithTextDisplayMode FItemsWithTextDisplayMode; HWND FHiddenWindow; + TStrings * FTransferResumeList; + bool FMoveToQueue; + bool FStandaloneEditing; + TFeedSynchronizeError FOnFeedSynchronizeError; bool __fastcall GetEnableFocusedOperation(TOperationSide Side, int FilesOnly); bool __fastcall GetEnableSelectedOperation(TOperationSide Side, int FilesOnly); @@ -262,6 +266,8 @@ class TCustomScpExplorerForm : public TForm void __fastcall AddQueueItem(TTransferDirection Direction, TStrings * FileList, const UnicodeString TargetDirectory, const TCopyParamType & CopyParam, int Params); + void __fastcall AddQueueItem(TQueueItem * QueueItem); + void __fastcall ClearTransferSourceSelection(TTransferDirection Direction); void __fastcall SessionsDDDragOver(int KeyState, const TPoint & Point, int & Effect); void __fastcall SessionsDDProcessDropped(TObject * Sender, int KeyState, const TPoint & Point, int Effect); void __fastcall RemoteFileControlDragDropFileOperation( @@ -273,6 +279,7 @@ class TCustomScpExplorerForm : public TForm void __fastcall CollectItemsWithTextDisplayMode(TWinControl * Control); void __fastcall CreateHiddenWindow(); static LRESULT WINAPI HiddenWindowProc(HWND HWnd, UINT Message, WPARAM WParam, LPARAM LParam); + bool __fastcall IsQueueAutoPopup(); protected: TOperationSide FCurrentSide; @@ -306,7 +313,7 @@ class TCustomScpExplorerForm : public TForm UnicodeString & TargetDirectory, TGUICopyParamType & CopyParam, bool Confirm, bool DragDrop); virtual bool __fastcall RemoteTransferDialog(TTerminal *& Session, - UnicodeString & Target, UnicodeString & FileMask, bool & DirectCopy, + TStrings * FileList, UnicodeString & Target, UnicodeString & FileMask, bool & DirectCopy, bool NoConfirmation, bool Move); virtual void __fastcall CreateParams(TCreateParams & Params); void __fastcall DeleteFiles(TOperationSide Side, TStrings * FileList, bool Alternative); @@ -335,8 +342,7 @@ class TCustomScpExplorerForm : public TForm TOperationSide Side, bool Temp, const UnicodeString & FileName, bool Success, TOnceDoneOperation & OnceDoneOperation); virtual void __fastcall DoOpenDirectoryDialog(TOpenDirectoryMode Mode, TOperationSide Side); - virtual void __fastcall FileOperationProgress( - TFileOperationProgressType & ProgressData, TCancelStatus & Cancel); + virtual void __fastcall FileOperationProgress(TFileOperationProgressType & ProgressData); void __fastcall OperationComplete(const TDateTime & StartTime); void __fastcall ExecutedFileChanged(const UnicodeString FileName, TEditedFileData * Data, HANDLE UploadCompleteEvent); @@ -344,6 +350,7 @@ class TCustomScpExplorerForm : public TForm const TEditedFileData * Data); void __fastcall ExecutedFileEarlyClosed(const TEditedFileData * Data, bool & KeepOpen); + void __fastcall ExecutedFileUploadComplete(TObject * Sender); inline void __fastcall CMAppSysCommand(TMessage & Message); inline void __fastcall WMAppCommand(TMessage & Message); inline void __fastcall WMSysCommand(TMessage & Message); @@ -378,9 +385,11 @@ class TCustomScpExplorerForm : public TForm virtual void __fastcall DDExtInitDrag(TFileList * FileList, bool & Created); virtual void __fastcall SideEnter(TOperationSide Side); virtual TOperationSide __fastcall GetSide(TOperationSide Side); + TStrings * __fastcall PanelExport(TOperationSide Side, TPanelExport Export); virtual void __fastcall PanelExportStore(TOperationSide Side, TPanelExport Export, TPanelExportDestination Destination, - TStringList * ExportData); + TStrings * ExportData); + void __fastcall GenerateUrl(TStrings * Paths); void __fastcall QueueListUpdate(TTerminalQueue * Queue); void __fastcall QueueItemUpdate(TTerminalQueue * Queue, TQueueItem * Item); void __fastcall UpdateQueueStatus(bool QueueChanging); @@ -424,6 +433,8 @@ class TCustomScpExplorerForm : public TForm void __fastcall ExecuteFileNormalize(TExecuteFileBy & ExecuteFileBy, const TEditorData *& ExternalEditor, const UnicodeString & FileName, bool Local, const TFileMasks::TParams & MaskParams); + void __fastcall ExecuteRemoteFile( + const UnicodeString & FullFileName, TRemoteFile * File, TExecuteFileBy ExecuteFileBy); void __fastcall TemporaryDirectoryForRemoteFiles( UnicodeString RemoteDirectory, TCopyParamType CopyParam, UnicodeString & Result, UnicodeString & RootDirectory); @@ -434,7 +445,10 @@ class TCustomScpExplorerForm : public TForm TTBXPopupMenu * __fastcall HistoryMenu(TOperationSide Side, bool Back); UnicodeString __fastcall FileStatusBarText(const TStatusFileInfo & FileInfo); void __fastcall UpdateFileStatusBar(TTBXStatusBar * StatusBar, - const TStatusFileInfo & FileInfo, int Panel); + const TStatusFileInfo & FileInfo); + void __fastcall UpdateFileStatusExtendedPanels( + TTBXStatusBar * StatusBar, const TStatusFileInfo & FileInfo); + void __fastcall FileStatusBarPanelClick(TTBXStatusPanel * Panel, TOperationSide Side); virtual void __fastcall DoDirViewLoaded(TCustomDirView * Sender); virtual void __fastcall UpdateControls(); void __fastcall UpdateTransferList(); @@ -539,7 +553,7 @@ class TCustomScpExplorerForm : public TForm void __fastcall SuspendWindowLock(); void __fastcall ResumeWindowLock(); - void __fastcall NewSession(bool FromSite); + void __fastcall NewSession(bool FromSite, const UnicodeString & SessionUrl = L""); void __fastcall DuplicateSession(); void __fastcall CloseSession(); void __fastcall OpenDirectory(TOperationSide Side); @@ -560,8 +574,8 @@ class TCustomScpExplorerForm : public TForm virtual void __fastcall ExploreLocalDirectory(); virtual void __fastcall GoToCommandLine(); virtual void __fastcall GoToTree(); - virtual void __fastcall PanelExport(TOperationSide Side, TPanelExport Export, - TPanelExportDestination Destination, bool OnFocused = false); + void __fastcall PanelExport(TOperationSide Side, TPanelExport Export, + TPanelExportDestination Destination); void __fastcall Filter(TOperationSide Side); void __fastcall ExecuteFile(TOperationSide Side, TExecuteFileBy ExecuteFileBy, const TEditorData * ExternalEditor = NULL, bool AllSelected = false, @@ -584,7 +598,7 @@ class TCustomScpExplorerForm : public TForm TTerminal * Terminal = NULL); void __fastcall OperationFinished(TFileOperation Operation, TOperationSide Side, bool Temp, const UnicodeString & FileName, bool Success, TOnceDoneOperation & OnceDoneOperation); - void __fastcall OperationProgress(TFileOperationProgressType & ProgressData, TCancelStatus & Cancel); + void __fastcall OperationProgress(TFileOperationProgressType & ProgressData); void __fastcall ShowExtendedException(TTerminal * Terminal, Exception * E); void __fastcall InactiveTerminalException(TTerminal * Terminal, Exception * E); void __fastcall TerminalReady(); @@ -595,6 +609,7 @@ class TCustomScpExplorerForm : public TForm bool __fastcall DoFullSynchronizeDirectories(UnicodeString & LocalDirectory, UnicodeString & RemoteDirectory, TSynchronizeMode & Mode, bool & SaveMode, bool UseDefaults); + void __fastcall StandaloneEdit(const UnicodeString & FileName); bool __fastcall CanPasteFromClipBoard(); void __fastcall PasteFromClipBoard(); void __fastcall ToggleQueueVisibility(); @@ -604,10 +619,12 @@ class TCustomScpExplorerForm : public TForm void __fastcall WhatsThis(); virtual void __fastcall BeforeAction(); void __fastcall FileSystemInfo(); + void __fastcall SessionGenerateUrl(); + void __fastcall FileGenerateUrl(); void __fastcall ReadDirectoryCancelled(); void __fastcall SynchronizeBrowsingChanged(); void __fastcall ToggleShowHiddenFiles(); - void __fastcall ToggleFormatSizeBytes(); + void __fastcall SetFormatSizeBytes(TFormatBytesStyle Style); void __fastcall ToggleAutoReadDirectoryAfterOp(); void __fastcall PopupTrayBalloon(TTerminal * Terminal, const UnicodeString & Str, TQueryType Type, Exception * E = NULL, unsigned int Seconds = 0, diff --git a/source/forms/EditMask.cpp b/source/forms/EditMask.cpp index 04663568..478639af 100644 --- a/source/forms/EditMask.cpp +++ b/source/forms/EditMask.cpp @@ -146,18 +146,9 @@ void __fastcall TEditMaskDialog::UpdateControls() } //--------------------------------------------------------------------------- void __fastcall TEditMaskDialog::FormKeyDown( - TObject * /*Sender*/, WORD & Key, TShiftState Shift) + TObject * Sender, WORD & Key, TShiftState Shift) { - if ((Key == VK_ESCAPE) && Shift.Empty()) - { - ModalResult = mrCancel; - Key = 0; - } - else if ((Key == VK_RETURN) && Shift.Contains(ssCtrl)) - { - ModalResult = DefaultResult(this); - Key = 0; - } + MemoKeyDown(Sender, Key, Shift); } //--------------------------------------------------------------------------- void __fastcall TEditMaskDialog::FormShow(TObject * /*Sender*/) diff --git a/source/forms/Editor.cpp b/source/forms/Editor.cpp index b329b634..5075261c 100644 --- a/source/forms/Editor.cpp +++ b/source/forms/Editor.cpp @@ -10,6 +10,8 @@ #include "VCLCommon.h" #include "WinConfiguration.h" #include "HelpWin.h" +#include +#include //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TB2Dock" @@ -18,13 +20,14 @@ #pragma link "TB2Toolbar" #pragma link "TBXStatusBars" #pragma link "PngImageList" +#pragma link "TBXExtItems" #ifndef NO_RESOURCES #pragma resource "*.dfm" #endif //--------------------------------------------------------------------------- TForm * __fastcall ShowEditorForm(const UnicodeString FileName, TCustomForm * ParentForm, TNotifyEvent OnFileChanged, TNotifyEvent OnFileReload, TFileClosedEvent OnClose, - const UnicodeString Caption) + const UnicodeString Caption, bool StandaloneEditor, TColor Color) { TEditorForm * Dialog = new TEditorForm(Application); try @@ -35,6 +38,8 @@ TForm * __fastcall ShowEditorForm(const UnicodeString FileName, TCustomForm * Pa Dialog->Caption = ACaption + L" - " + LoadStr(EDITOR_CAPTION) + L" - " + AppName; Dialog->OnFileChanged = OnFileChanged; Dialog->OnFileReload = OnFileReload; + Dialog->StandaloneEditor = StandaloneEditor; + Dialog->BackgroundColor = Color; // load before showing, so when loading failes, // we do not show an empty editor Dialog->LoadFile(); @@ -59,12 +64,18 @@ void __fastcall ReconfigureEditorForm(TForm * Form) Editor->ApplyConfiguration(); } //--------------------------------------------------------------------------- +void __fastcall EditorFormFileUploadComplete(TForm * Form) +{ + NOT_NULL(dynamic_cast(Form))->FileUploadComplete(); +} +//--------------------------------------------------------------------------- class TPreambleFilteringFileStream : public TFileStream { public: __fastcall TPreambleFilteringFileStream(const UnicodeString AFileName, System::Word Mode, TEncoding * Encoding, bool AllowPreamble); virtual int __fastcall Write(const void * Buffer, int Count); + virtual int __fastcall Write(const System::DynamicArray Buffer, int Offset, int Count); private: TBytes FPreamble; bool FDisallowPreamble; @@ -112,6 +123,13 @@ int __fastcall TPreambleFilteringFileStream::Write(const void * Buffer, int Coun return Result; } //--------------------------------------------------------------------------- +int __fastcall TPreambleFilteringFileStream::Write( + const System::DynamicArray /*Buffer*/, int /*Offset*/, int /*Count*/) +{ + FAIL; + EXCEPTION; +} +//--------------------------------------------------------------------------- class TRichEdit20 : public TRichEdit { public: @@ -376,7 +394,7 @@ struct TStreamLoadInfo }; //--------------------------------------------------------------------------- // Copy from Vcl.ComCtrls.pas, -// WORKAROUND for bug in BCB XE2 VCL +// WORKAROUND for bug in BCB XE2-XE6 VCL // Fixes conversion from UTF-8, when read buffer ends in the middle of UTF-8 char static unsigned long __stdcall StreamLoad(DWORD_PTR Cookie, unsigned char * Buff, long Read, long * WasRead) { @@ -658,6 +676,10 @@ __fastcall TEditorForm::TEditorForm(TComponent* Owner) FReplaceDialog->OnFind = FindDialogFind; FReplaceDialog->OnReplace = FindDialogFind; FEncoding = NULL; + FSaving = false; + FStandaloneEditor = false; + FClosePending = false; + SetSubmenu(ColorItem); InitCodePage(); @@ -694,6 +716,11 @@ __fastcall TEditorForm::~TEditorForm() { Application->OnHint = NULL; } + + if (FStandaloneEditor) + { + Application->Terminate(); + } } //--------------------------------------------------------------------------- UnicodeString __fastcall TEditorForm::GetCodePageName(TEncoding * Encoding) @@ -758,7 +785,7 @@ void __fastcall TEditorForm::EditorActionsUpdate(TBasicAction *Action, } else if (Action == PreferencesAction || Action == FindAction || Action == ReplaceAction || Action == GoToLineAction || - Action == HelpAction || Action == ReloadAction) + Action == HelpAction || Action == ReloadAction || Action == ColorAction) { ((TAction *)Action)->Enabled = true; } @@ -780,9 +807,9 @@ void __fastcall TEditorForm::EditorActionsUpdate(TBasicAction *Action, //--------------------------------------------------------------------------- void __fastcall TEditorForm::SaveToFile() { - std::auto_ptr Stream( + std::unique_ptr Stream( new TPreambleFilteringFileStream( - FFileName, fmCreate, FEncoding, EditorMemo->LoadedWithPreamble)); + ::ApiPath(FFileName), fmCreate, FEncoding, EditorMemo->LoadedWithPreamble)); EditorMemo->Lines->SaveToStream(Stream.get(), FEncoding); } //--------------------------------------------------------------------------- @@ -798,6 +825,7 @@ void __fastcall TEditorForm::EditorActionsExecute(TBasicAction *Action, { FOnFileChanged(this); } + FSaving = true; EditorMemo->Modified = false; UpdateControls(); } @@ -841,6 +869,14 @@ void __fastcall TEditorForm::EditorActionsExecute(TBasicAction *Action, { ChangeEncoding(TEncoding::UTF8); } + else if (Action == ColorAction) + { + if (ALWAYS_TRUE(Action->ActionComponent != NULL)) + { + ::CreateSessionColorMenu(Action->ActionComponent, BackgroundColor, + SetBackgroundColor); + } + } else { Handled = false; @@ -855,9 +891,10 @@ void __fastcall TEditorForm::BackupSave() while (true) { UnicodeString FileName = FFileName + L".bak" + (Uniq == 0 ? UnicodeString() : IntToStr(Uniq)); - if (!FileExists(FileName)) + UnicodeString ApiFileName = ::ApiPath(FileName); + if (!FileExists(ApiFileName)) { - EditorMemo->Lines->SaveToFile(FileName, FEncoding); + EditorMemo->Lines->SaveToFile(ApiFileName, FEncoding); break; } Uniq++; @@ -903,6 +940,11 @@ void __fastcall TEditorForm::FormCloseQuery(TObject * /*Sender*/, if (Answer == qaYes) { SaveAction->Execute(); + if (FStandaloneEditor) + { + CanClose = false; + FClosePending = true; + } } } } @@ -920,6 +962,17 @@ void __fastcall TEditorForm::ApplyConfiguration() UpdateControls(); } //--------------------------------------------------------------------------- +void __fastcall TEditorForm::FileUploadComplete() +{ + assert(FSaving); + FSaving = false; + UpdateControls(); + if (FClosePending && ALWAYS_TRUE(FStandaloneEditor)) + { + Close(); + } +} +//--------------------------------------------------------------------------- void __fastcall TEditorForm::UpdateControls() { if (FShowStatusBarHint) @@ -995,7 +1048,8 @@ void __fastcall TEditorForm::UpdateControls() } StatusBar->Panels->Items[3]->Caption = FMTLOAD(EDITOR_ENCODING_STATUS, (FEncodingName)); StatusBar->Panels->Items[4]->Caption = - (EditorMemo->Modified ? LoadStr(EDITOR_MODIFIED) : UnicodeString(L"")); + (FSaving ? LoadStr(EDITOR_SAVING) : + (EditorMemo->Modified ? LoadStr(EDITOR_MODIFIED) : UnicodeString(L""))); StatusBar->SimplePanel = false; } @@ -1161,7 +1215,7 @@ bool __fastcall TEditorForm::ContainsPreamble(TStream * Stream, const TBytes & S //--------------------------------------------------------------------------- void __fastcall TEditorForm::LoadFromFile(bool PrimaryEncoding) { - TStream * Stream = new TFileStream(FFileName, fmOpenRead | fmShareDenyWrite); + TStream * Stream = new TFileStream(::ApiPath(FFileName), fmOpenRead | fmShareDenyWrite); try { bool CanTrySecondary; @@ -1261,8 +1315,52 @@ void __fastcall TEditorForm::LoadFromFile(bool PrimaryEncoding) SendMessage(EditorMemo->Handle, EM_EXLIMITTEXT, 0, 0x7FFFFFF0); } //--------------------------------------------------------------------------- +void __fastcall TEditorForm::CheckFileSize() +{ + TEditorConfiguration EditorConfiguration = WinConfiguration->Editor; + + if (EditorConfiguration.WarnOrLargeFileSize) + { + TWin32FileAttributeData FileAttributeData; + if (GetFileAttributesEx(::ApiPath(FFileName).c_str(), GetFileExInfoStandard, &FileAttributeData)) + { + const __int64 MaxSize = 100 * 1024 * 1024; + __int64 Size = + (static_cast<__int64>(FileAttributeData.nFileSizeHigh) << 32) + + FileAttributeData.nFileSizeLow; + if (Size > MaxSize) + { + TMessageParams Params(mpNeverAskAgainCheck); + unsigned int Answer = + MoreMessageDialog( + FMTLOAD(INTERNAL_EDITOR_LARGE_FILE, (FormatBytes(Size))), NULL, + qtConfirmation, qaOK | qaCancel, HELP_NONE, &Params); + switch (Answer) + { + case qaOK: + // noop; + break; + + case qaCancel: + Abort(); + break; + + case qaNeverAskAgain: + EditorConfiguration.WarnOrLargeFileSize = false; + WinConfiguration->Editor = EditorConfiguration; + break; + + default: + FAIL; + } + } + } + } +} +//--------------------------------------------------------------------------- void __fastcall TEditorForm::LoadFile() { + CheckFileSize(); HandleNeeded(); LoadFromFile(true); EditorMemo->ResetFormat(); @@ -1472,3 +1570,20 @@ void __fastcall TEditorForm::FormKeyDown(TObject * /*Sender*/, WORD & Key, TShif } } //--------------------------------------------------------------------------- +void __fastcall TEditorForm::SetBackgroundColor(TColor Color) +{ + if (BackgroundColor != Color) + { + FBackgroundColor = Color; + TColor ItemColor = (Color != 0 ? Color : Vcl::Graphics::clNone); + ColorItem->Color = ItemColor; + TColor EditorColor = (Color != 0 ? Color : clWindow); + if (EditorMemo->Color != EditorColor) + { + EditorMemo->Color = EditorColor; + // does not seem to have any effect (nor is needed), but just in case + ForceColorChange(EditorMemo); + } + } +} +//--------------------------------------------------------------------------- diff --git a/source/forms/Editor.dfm b/source/forms/Editor.dfm index 4492e6bd..baf651f4 100644 --- a/source/forms/Editor.dfm +++ b/source/forms/Editor.dfm @@ -82,6 +82,7 @@ object EditorForm: TEditorForm object Encoding: TTBXSubmenuItem Caption = 'Encoding' Hint = 'Change file encoding' + Options = [tboDropdownArrow] object DefaultEncoding: TTBXItem Action = DefaultEncodingAction RadioItem = True @@ -91,6 +92,10 @@ object EditorForm: TEditorForm RadioItem = True end end + object ColorItem: TTBXColorItem + Action = ColorAction + Options = [tboDropdownArrow] + end object TBXItem13: TTBXItem Action = PreferencesAction end @@ -146,9 +151,9 @@ object EditorForm: TEditorForm Caption = '&Save' Hint = 'Save|Save file' ImageIndex = 0 - ShortCut = 16467 SecondaryShortCuts.Strings = ( 'F2') + ShortCut = 16467 end object EditCut: TEditCut Caption = 'Cu&t' @@ -166,10 +171,10 @@ object EditorForm: TEditorForm Caption = '&Paste' Hint = 'Paste|Inserts Clipboard contents' ImageIndex = 3 - ShortCut = 16470 SecondaryShortCuts.Strings = ( 'Shift+Ins' 'Ctrl+Shift+Ins') + ShortCut = 16470 end object EditSelectAll: TEditSelectAll Caption = 'Select &All' @@ -203,33 +208,33 @@ object EditorForm: TEditorForm Caption = '&Find...' Hint = 'Find|Find the specified text' ImageIndex = 8 - ShortCut = 16454 SecondaryShortCuts.Strings = ( 'F7') + ShortCut = 16454 end object ReplaceAction: TAction Caption = '&Replace...' Hint = 'Replace|Replace the specified text with different text' ImageIndex = 9 - ShortCut = 16456 SecondaryShortCuts.Strings = ( 'Ctrl+F7') + ShortCut = 16456 end object FindNextAction: TAction Caption = 'Find &Next' Hint = 'Find next|Find the next occurrence of the specified text' ImageIndex = 10 - ShortCut = 114 SecondaryShortCuts.Strings = ( 'Shift+F7') + ShortCut = 114 end object GoToLineAction: TAction Caption = '&Go to Line Number...' Hint = 'Go to line|Go to specific line number' ImageIndex = 11 - ShortCut = 16455 SecondaryShortCuts.Strings = ( 'Alt+F8') + ShortCut = 16455 end object HelpAction: TAction Caption = '&Help' @@ -240,9 +245,9 @@ object EditorForm: TEditorForm Caption = '&Reload' Hint = 'Reload|Reload file' ImageIndex = 13 - ShortCut = 16466 SecondaryShortCuts.Strings = ( 'F5') + ShortCut = 16466 end object DefaultEncodingAction: TAction Caption = 'AnsiX' @@ -252,6 +257,10 @@ object EditorForm: TEditorForm Caption = 'UTF-8' Hint = 'UTF-8|UTF-8 encoding' end + object ColorAction: TAction + Caption = 'C&olor' + Hint = 'Change color of editor' + end end object EditorImages: TPngImageList PngImages = < diff --git a/source/forms/Editor.h b/source/forms/Editor.h index 41dfaa6b..219b4736 100644 --- a/source/forms/Editor.h +++ b/source/forms/Editor.h @@ -22,6 +22,8 @@ #include "WinConfiguration.h" #include "WinInterface.h" #include "PngImageList.hpp" +#include +#include "TBXExtItems.hpp" //--------------------------------------------------------------------------- class TRichEdit20; //--------------------------------------------------------------------------- @@ -70,6 +72,8 @@ class TEditorForm : public TForm TTBXItem *UTF8Encoding; TAction *DefaultEncodingAction; TAction *UTF8EncodingAction; + TTBXColorItem *ColorItem; + TAction *ColorAction; void __fastcall EditorActionsUpdate(TBasicAction *Action, bool &Handled); void __fastcall EditorActionsExecute(TBasicAction *Action, bool &Handled); @@ -103,21 +107,29 @@ class TEditorForm : public TForm unsigned int FInstance; TEncoding * FEncoding; UnicodeString FEncodingName; + bool FSaving; + bool FStandaloneEditor; + bool FClosePending; + TColor FBackgroundColor; static unsigned int FInstances; void __fastcall SetFileName(const UnicodeString value); void __fastcall SetParentForm(TCustomForm * value); void __fastcall ApplicationHint(TObject * Sender); + void __fastcall SetBackgroundColor(TColor Color); public: __fastcall TEditorForm(TComponent* Owner); virtual __fastcall ~TEditorForm(); void __fastcall ApplyConfiguration(); + void __fastcall FileUploadComplete(); void __fastcall LoadFile(); __property UnicodeString FileName = { read = FFileName, write = SetFileName }; + __property bool StandaloneEditor = { read = FStandaloneEditor, write = FStandaloneEditor }; __property TNotifyEvent OnFileChanged = { read = FOnFileChanged, write = FOnFileChanged }; __property TNotifyEvent OnFileReload = { read = FOnFileReload, write = FOnFileReload }; __property TFileClosedEvent OnWindowClose = { read = FOnWindowClose, write = FOnWindowClose }; __property TCustomForm * ParentForm = { read = FParentForm, write = SetParentForm }; + __property TColor BackgroundColor = { read = FBackgroundColor, write = SetBackgroundColor }; protected: bool __fastcall CursorInUpperPart(); void __fastcall Find(); @@ -135,6 +147,7 @@ class TEditorForm : public TForm UnicodeString __fastcall GetCodePageName(TEncoding * Encoding); void __fastcall SaveToFile(); void __fastcall BackupSave(); + void __fastcall CheckFileSize(); }; //--------------------------------------------------------------------------- #endif diff --git a/source/forms/FileFind.cpp b/source/forms/FileFind.cpp index f51854d0..f6654ddf 100644 --- a/source/forms/FileFind.cpp +++ b/source/forms/FileFind.cpp @@ -121,7 +121,7 @@ void __fastcall TFileFindDialog::UpdateControls() break; default: - assert(false); + FAIL; break; } } @@ -207,7 +207,9 @@ void __fastcall TFileFindDialog::Start() } if (IsApplicationMinimized() && FMinimizedByMe) { - ShowNotification(NULL, LoadStr(BALLOON_OPERATION_COMPLETE), qtInformation); + ShowNotification( + NULL, MainInstructions(LoadStr(BALLOON_OPERATION_COMPLETE)), + qtInformation); FMinimizedByMe = false; } UpdateControls(); @@ -237,7 +239,7 @@ void __fastcall TFileFindDialog::FileFound(TTerminal * /*Terminal*/, } else { - assert(false); + FAIL; } Item->SubItems->Add(Directory); @@ -248,8 +250,7 @@ void __fastcall TFileFindDialog::FileFound(TTerminal * /*Terminal*/, else { Item->SubItems->Add( - FormatBytes(File->Size, - WinConfiguration->FormatSizeBytes, WinConfiguration->FormatSizeBytes)); + FormatPanelBytes(File->Size, WinConfiguration->FormatSizeBytes)); } Item->SubItems->Add(UserModificationStr(File->Modification, File->ModificationFmt)); diff --git a/source/forms/FileSystemInfo.cpp b/source/forms/FileSystemInfo.cpp index 54821c0a..7f91a389 100644 --- a/source/forms/FileSystemInfo.cpp +++ b/source/forms/FileSystemInfo.cpp @@ -80,7 +80,7 @@ UnicodeString __fastcall TFileSystemInfoDialog::SpaceStr(__int64 Bytes) else { Result = FormatBytes(Bytes); - UnicodeString SizeUnorderedStr = FormatBytes(Bytes, false); + UnicodeString SizeUnorderedStr = FormatBytes(Bytes, fbNone); if (Result != SizeUnorderedStr) { Result = FORMAT(L"%s (%s)", (Result, SizeUnorderedStr)); diff --git a/source/forms/FullSynchronize.cpp b/source/forms/FullSynchronize.cpp index 957cb6c1..feb80d13 100644 --- a/source/forms/FullSynchronize.cpp +++ b/source/forms/FullSynchronize.cpp @@ -27,7 +27,7 @@ bool __fastcall DoFullSynchronizeDialog(TSynchronizeMode & Mode, int & Params, const TUsableCopyParamAttrs & CopyParamAttrs) { bool Result; - TFullSynchronizeDialog * Dialog = new TFullSynchronizeDialog(Application); + TFullSynchronizeDialog * Dialog = SafeFormCreate(); try { Dialog->Mode = Mode; @@ -139,7 +139,7 @@ int __fastcall TFullSynchronizeDialog::ActualCopyParamAttrs() break; default: - assert(false); + FAIL; //fallthru case smBoth: Result = CopyParamAttrs.General; @@ -212,7 +212,7 @@ void __fastcall TFullSynchronizeDialog::SetMode(TSynchronizeMode value) break; default: - assert(false); + FAIL; } } //--------------------------------------------------------------------------- diff --git a/source/forms/GenerateUrl.cpp b/source/forms/GenerateUrl.cpp new file mode 100644 index 00000000..9d270de2 --- /dev/null +++ b/source/forms/GenerateUrl.cpp @@ -0,0 +1,172 @@ +//--------------------------------------------------------------------------- +#include +#pragma hdrstop + +#include "VCLCommon.h" +#include "GenerateUrl.h" +#include "CoreMain.h" +#include "WinConfiguration.h" +#include +#include +#include +//--------------------------------------------------------------------------- +#pragma package(smart_init) +#ifndef NO_RESOURCES +#pragma resource "*.dfm" +#endif +//--------------------------------------------------------------------------- +void __fastcall DoGenerateUrlDialog(TSessionData * Data, TStrings * Paths) +{ + std::unique_ptr Dialog(new TGenerateUrlDialog(GetFormOwner(), Data, Paths)); + Dialog->Execute(); +} +//--------------------------------------------------------------------------- +__fastcall TGenerateUrlDialog::TGenerateUrlDialog( + TComponent * Owner, TSessionData * Data, TStrings * Paths) + : TForm(Owner) +{ + UseSystemSettings(this); + FData = Data; + FPaths = Paths; + ReadOnlyControl(UrlMemo); +} +//--------------------------------------------------------------------------- +UnicodeString __fastcall TGenerateUrlDialog::GenerateUrl(UnicodeString Path) +{ + UnicodeString Url; + + if (WinSCPSpecificCheck->Checked) + { + Url += WinSCPProtocolPrefix; + } + + Url += FData->ProtocolUrl; + + if (UserNameCheck->Enabled && UserNameCheck->Checked) + { + Url += EncodeUrlString(FData->UserNameExpanded); + + if (PasswordCheck->Enabled && PasswordCheck->Checked) + { + Url += L":" + EncodeUrlString(FData->Password); + } + + if (HostKeyCheck->Enabled && HostKeyCheck->Checked) + { + Url += + UnicodeString(UrlParamSeparator) + UrlHostKeyParamName + + UnicodeString(UrlParamValueSeparator) + NormalizeFingerprint(FData->HostKey); + } + + Url += L"@"; + } + + Url += EncodeUrlString(FData->HostNameExpanded); + if (FData->PortNumber != DefaultPort(FData->FSProtocol, FData->Ftps)) + { + Url += L":" + IntToStr(FData->PortNumber); + } + Url += L"/"; + + if ((RemoteDirectoryCheck->Enabled && RemoteDirectoryCheck->Checked) || + (FPaths != NULL)) + { + if (StartsStr(L"/", Path)); + { + Path.Delete(1, 1); + } + + Url += EncodeUrlPath(Path); + } + + if (SaveExtensionCheck->Enabled && SaveExtensionCheck->Checked) + { + Url += UnicodeString(UrlParamSeparator) + UrlSaveParamName; + } + + return Url; +} +//--------------------------------------------------------------------------- +void __fastcall TGenerateUrlDialog::UpdateControls() +{ + EnableControl(UserNameCheck, !FData->UserNameExpanded.IsEmpty()); + bool UserNameIncluded = UserNameCheck->Enabled && UserNameCheck->Checked; + EnableControl(PasswordCheck, UserNameIncluded && !FData->Password.IsEmpty()); + EnableControl(HostKeyCheck, UserNameIncluded && !FData->HostKey.IsEmpty()); + EnableControl(RemoteDirectoryCheck, !FData->RemoteDirectory.IsEmpty() && (FPaths == NULL)); + EnableControl(SaveExtensionCheck, (FPaths == NULL)); + + UnicodeString Urls; + + if (FPaths == NULL) + { + UnicodeString Path = FData->RemoteDirectory; + if (!Path.IsEmpty() && !EndsStr(L"/", Path)) + { + Path += L"/"; + } + Urls = GenerateUrl(Path); + } + else + { + for (int Index = 0; Index < FPaths->Count; Index++) + { + Urls += GenerateUrl(FPaths->Strings[Index]) + L"\n"; + } + } + + UrlMemo->Lines->Text = Urls; +} +//--------------------------------------------------------------------------- +void __fastcall TGenerateUrlDialog::Execute() +{ + int Components = WinConfiguration->GenerateUrlComponents; + if (Components < 0) + { + Components = UserNameCheck->Tag | RemoteDirectoryCheck->Tag; + } + + for (int Index = 0; Index < OptionsGroup->ControlCount; Index++) + { + TCheckBox * CheckBox = dynamic_cast(OptionsGroup->Controls[Index]); + + if (ALWAYS_TRUE((CheckBox != NULL) && (CheckBox->Tag != 0))) + { + CheckBox->Checked = FLAGSET(Components, CheckBox->Tag); + } + } + + UpdateControls(); + + ShowModal(); + + Components = 0; + for (int Index = 0; Index < OptionsGroup->ControlCount; Index++) + { + TCheckBox * CheckBox = dynamic_cast(OptionsGroup->Controls[Index]); + + if (ALWAYS_TRUE((CheckBox != NULL) && (CheckBox->Tag != 0)) && + CheckBox->Checked) + { + Components |= CheckBox->Tag; + } + } + WinConfiguration->GenerateUrlComponents = Components; +} +//--------------------------------------------------------------------------- +void __fastcall TGenerateUrlDialog::ControlChange(TObject * /*Sender*/) +{ + UpdateControls(); +} +//--------------------------------------------------------------------------- +void __fastcall TGenerateUrlDialog::ClipboardButtonClick(TObject * /*Sender*/) +{ + TInstantOperationVisualizer Visualizer; + CopyToClipboard(UrlMemo->Lines); +} +//--------------------------------------------------------------------------- +void __fastcall TGenerateUrlDialog::HelpButtonClick(TObject * /*Sender*/) +{ + FormHelp(this); +} +//--------------------------------------------------------------------------- diff --git a/source/forms/GenerateUrl.dfm b/source/forms/GenerateUrl.dfm new file mode 100644 index 00000000..9d2dd71b --- /dev/null +++ b/source/forms/GenerateUrl.dfm @@ -0,0 +1,149 @@ +object GenerateUrlDialog: TGenerateUrlDialog + Left = 369 + Top = 257 + HelpType = htKeyword + HelpKeyword = 'ui_generateurl' + BorderIcons = [biSystemMenu, biMinimize, biMaximize, biHelp] + BorderStyle = bsDialog + Caption = 'Generate URL' + ClientHeight = 251 + ClientWidth = 484 + Color = clBtnFace + ParentFont = True + OldCreateOrder = True + Position = poOwnerFormCenter + DesignSize = ( + 484 + 251) + PixelsPerInch = 96 + TextHeight = 13 + object OptionsGroup: TGroupBox + Left = 8 + Top = 6 + Width = 468 + Height = 95 + Anchors = [akLeft, akTop, akRight] + Caption = 'URL options' + TabOrder = 0 + object UserNameCheck: TCheckBox + Tag = 1 + Left = 11 + Top = 20 + Width = 97 + Height = 17 + Caption = '&User name' + TabOrder = 0 + OnClick = ControlChange + end + object PasswordCheck: TCheckBox + Tag = 2 + Left = 235 + Top = 20 + Width = 97 + Height = 17 + HelpType = htKeyword + HelpKeyword = 'ui_generate_url' + Caption = '&Password' + TabOrder = 1 + OnClick = ControlChange + end + object HostKeyCheck: TCheckBox + Tag = 4 + Left = 11 + Top = 43 + Width = 97 + Height = 17 + Caption = 'SSH &host Key' + TabOrder = 2 + OnClick = ControlChange + end + object RemoteDirectoryCheck: TCheckBox + Tag = 8 + Left = 235 + Top = 43 + Width = 97 + Height = 17 + Caption = 'Initial &directory' + TabOrder = 3 + OnClick = ControlChange + end + object WinSCPSpecificCheck: TCheckBox + Tag = 16 + Left = 11 + Top = 66 + Width = 97 + Height = 17 + Caption = '&WinSCP-specific' + TabOrder = 4 + OnClick = ControlChange + end + object SaveExtensionCheck: TCheckBox + Tag = 32 + Left = 235 + Top = 66 + Width = 97 + Height = 17 + Caption = '&Save extension' + TabOrder = 5 + OnClick = ControlChange + end + end + object UrlGroup: TGroupBox + Left = 8 + Top = 107 + Width = 468 + Height = 105 + Anchors = [akLeft, akTop, akRight, akBottom] + Caption = 'URL' + TabOrder = 1 + DesignSize = ( + 468 + 105) + object UrlMemo: TMemo + Left = 7 + Top = 15 + Width = 454 + Height = 81 + TabStop = False + Anchors = [akLeft, akTop, akRight, akBottom] + BevelInner = bvNone + BevelOuter = bvNone + BorderStyle = bsNone + Lines.Strings = ( + 'UrlMemo') + ScrollBars = ssVertical + TabOrder = 0 + end + end + object CancelBtn: TButton + Left = 318 + Top = 218 + Width = 75 + Height = 25 + Anchors = [akRight, akBottom] + Cancel = True + Caption = 'Close' + ModalResult = 2 + TabOrder = 3 + end + object HelpButton: TButton + Left = 401 + Top = 218 + Width = 75 + Height = 25 + Anchors = [akRight, akBottom] + Caption = '&Help' + TabOrder = 4 + OnClick = HelpButtonClick + end + object ClipboardButton: TButton + Left = 8 + Top = 218 + Width = 145 + Height = 25 + Anchors = [akLeft, akBottom] + Caption = '&Copy to Clipboard' + TabOrder = 2 + OnClick = ClipboardButtonClick + end +end diff --git a/source/forms/GenerateUrl.h b/source/forms/GenerateUrl.h new file mode 100644 index 00000000..8ab8108f --- /dev/null +++ b/source/forms/GenerateUrl.h @@ -0,0 +1,44 @@ +//--------------------------------------------------------------------------- +#ifndef GenerateUrlH +#define GenerateUrlH +//--------------------------------------------------------------------------- +#include +#include +#include +#include + +#include "SessionData.h" +//--------------------------------------------------------------------------- +class TGenerateUrlDialog : public TForm +{ +__published: + TGroupBox *OptionsGroup; + TGroupBox *UrlGroup; + TMemo *UrlMemo; + TButton *CancelBtn; + TButton *HelpButton; + TButton *ClipboardButton; + TCheckBox *UserNameCheck; + TCheckBox *PasswordCheck; + TCheckBox *HostKeyCheck; + TCheckBox *RemoteDirectoryCheck; + TCheckBox *WinSCPSpecificCheck; + TCheckBox *SaveExtensionCheck; + void __fastcall ControlChange(TObject *Sender); + void __fastcall ClipboardButtonClick(TObject *Sender); + void __fastcall HelpButtonClick(TObject *Sender); + +private: + TSessionData * FData; + TStrings * FPaths; + +protected: + void __fastcall UpdateControls(); + UnicodeString __fastcall GenerateUrl(UnicodeString Path); + +public: + __fastcall TGenerateUrlDialog(TComponent * Owner, TSessionData * Data, TStrings * Paths); + void __fastcall Execute(); +}; +//--------------------------------------------------------------------------- +#endif diff --git a/source/forms/ImportSessions.cpp b/source/forms/ImportSessions.cpp index ca329686..e8e06c5b 100644 --- a/source/forms/ImportSessions.cpp +++ b/source/forms/ImportSessions.cpp @@ -18,7 +18,7 @@ #pragma resource "*.dfm" #endif //--------------------------------------------------------------------- -bool __fastcall DoImportSessionsDialog() +bool __fastcall DoImportSessionsDialog(TList * Imported) { std::unique_ptr PuttyImportSessionList( GUIConfiguration->SelectPuttySessionsForImport(StoredSessions)); @@ -30,15 +30,18 @@ bool __fastcall DoImportSessionsDialog() SessionListsList->Add(FilezillaImportSessionList.get()); bool ImportKeys = true; + std::unique_ptr ImportSessionsDialog( - new TImportSessionsDialog(Application, SessionListsList.get())); + SafeFormCreate(Application)); + + ImportSessionsDialog->Init(SessionListsList.get()); bool Result = ImportSessionsDialog->Execute(ImportKeys); if (Result) { - StoredSessions->Import(PuttyImportSessionList.get(), true); - StoredSessions->Import(FilezillaImportSessionList.get(), true); + StoredSessions->Import(PuttyImportSessionList.get(), true, Imported); + StoredSessions->Import(FilezillaImportSessionList.get(), true, Imported); if (ImportKeys) { @@ -54,14 +57,16 @@ bool __fastcall DoImportSessionsDialog() return Result; } //--------------------------------------------------------------------- -__fastcall TImportSessionsDialog::TImportSessionsDialog(TComponent * AOwner, - TList * SessionListsList) - : TForm(AOwner) +__fastcall TImportSessionsDialog::TImportSessionsDialog(TComponent * AOwner) : + TForm(AOwner) { UseSystemSettings(this); // this is loaded from res string to force translation Caption = LoadStr(IMPORT_CAPTION); - +} +//--------------------------------------------------------------------- +void __fastcall TImportSessionsDialog::Init(TList * SessionListsList) +{ for (int Index = 0; Index < SessionListsList->Count; Index++) { SourceComboBox->Items->Objects[Index] = static_cast(SessionListsList->Items[Index]); diff --git a/source/forms/ImportSessions.h b/source/forms/ImportSessions.h index eeacb939..cecf0a56 100644 --- a/source/forms/ImportSessions.h +++ b/source/forms/ImportSessions.h @@ -39,8 +39,8 @@ class TImportSessionsDialog : public TForm TStoredSessionList * __fastcall GetSessionList(int Index); public: - virtual __fastcall TImportSessionsDialog(TComponent * AOwner, - TList * SessionListsList); + virtual __fastcall TImportSessionsDialog(TComponent * AOwner); + void __fastcall Init(TList * SessionListsList); bool __fastcall Execute(bool & ImportKeys); }; //---------------------------------------------------------------------------- diff --git a/source/forms/License.cpp b/source/forms/License.cpp index aec83ee2..97ca2925 100644 --- a/source/forms/License.cpp +++ b/source/forms/License.cpp @@ -15,8 +15,8 @@ #pragma resource "*.dfm" #endif //--------------------------------------------------------------------------- -UnicodeString LicenseStr[4] = - { L"LICENSE", L"LICENSE_EXPAT", L"LICENSE_ZLIB" }; +UnicodeString LicenseStr[2] = + { L"LICENSE", L"LICENSE_EXPAT" }; //--------------------------------------------------------------------------- void __fastcall DoLicenseDialog(TLicense License) { diff --git a/source/forms/LocationProfiles.cpp b/source/forms/LocationProfiles.cpp index 8868c95b..fb444e82 100644 --- a/source/forms/LocationProfiles.cpp +++ b/source/forms/LocationProfiles.cpp @@ -194,11 +194,11 @@ __fastcall TLocationProfilesDialog::TLocationProfilesDialog(TComponent * AOwner) FSessionFolders = new TStringList; FSessionFolders->CaseSensitive = false; FSessionFolders->Sorted = true; - FSessionFolders->Duplicates = dupIgnore; + FSessionFolders->Duplicates = Types::dupIgnore; FSharedFolders = new TStringList; FSharedFolders->CaseSensitive = false; FSharedFolders->Sorted = true; - FSharedFolders->Duplicates = dupIgnore; + FSharedFolders->Duplicates = Types::dupIgnore; FSessionScrollOnDragOver = new TTreeViewScrollOnDragOver(SessionProfilesView, true); FSharedScrollOnDragOver = new TTreeViewScrollOnDragOver(SharedProfilesView, true); @@ -440,7 +440,7 @@ typename T * GetProfilesObject(TObject * Sender, T * SessionObject, T * SharedOb { case 1: return SessionObject; case 2: return SharedObject; - default: assert(false); return NULL; + default: FAIL; return NULL; } } //--------------------------------------------------------------------------- diff --git a/source/forms/Login.cpp b/source/forms/Login.cpp index 99c64c6b..157391d2 100644 --- a/source/forms/Login.cpp +++ b/source/forms/Login.cpp @@ -69,6 +69,7 @@ __fastcall TLoginDialog::TLoginDialog(TComponent* AOwner) FEditing = false; FRenaming = false; FNewSiteKeepName = false; + FForceNewSite = false; // we need to make sure that window procedure is set asap // (so that CM_SHOWINGCHANGED handling is applied) @@ -76,6 +77,7 @@ __fastcall TLoginDialog::TLoginDialog(TComponent* AOwner) FOriginalSize = BoundsRect.GetSize(); FBasicGroupBaseHeight = BasicGroup->Height - BasicSshPanel->Height - BasicFtpPanel->Height; + FNoteGroupOffset = NoteGroup->Top - (BasicGroup->Top + BasicGroup->Height); InitControls(); } //--------------------------------------------------------------------- @@ -136,6 +138,7 @@ void __fastcall TLoginDialog::InitControls() ReadOnlyControl(TransferProtocolView); ReadOnlyControl(EncryptionView); + ReadOnlyControl(NoteMemo); MenuButton(ToolsMenuButton); MenuButton(ManageButton); @@ -168,7 +171,7 @@ void __fastcall TLoginDialog::Init() } FInitialized = true; - Caption = FORMAT(L"%s %s", (AppName, Caption)); + Caption = FormatFormCaption(this, Caption); InitControls(); @@ -182,7 +185,8 @@ void __fastcall TLoginDialog::Init() if (ALWAYS_FALSE(SessionTree->Items->Count == 0) || ((SessionTree->Items->Count == 1) && - ALWAYS_TRUE(IsNewSiteNode(SessionTree->Items->GetFirstNode())))) + ALWAYS_TRUE(IsNewSiteNode(SessionTree->Items->GetFirstNode()))) || + FForceNewSite) { ActiveControl = HostNameEdit; } @@ -462,6 +466,9 @@ void __fastcall TLoginDialog::LoadSession(TSessionData * SessionData) TransferProtocolCombo->ItemIndex = FSProtocolToIndex(SessionData->FSProtocol, AllowScpFallback); TransferProtocolView->Text = TransferProtocolCombo->Text; + NoteGroup->Visible = !Trim(SessionData->Note).IsEmpty(); + NoteMemo->Lines->Text = SessionData->Note; + // just in case TransferProtocolComboChange is not triggered FDefaultPort = DefaultPort(); FUpdatePortWithProtocol = true; @@ -550,6 +557,10 @@ void __fastcall TLoginDialog::UpdateControls() FBasicGroupBaseHeight + (BasicSshPanel->Visible ? BasicSshPanel->Height : 0) + (BasicFtpPanel->Visible ? BasicFtpPanel->Height : 0); + int NoteGroupTop = (BasicGroup->Top + BasicGroup->Height) + FNoteGroupOffset; + NoteGroup->SetBounds( + NoteGroup->Left, (BasicGroup->Top + BasicGroup->Height) + FNoteGroupOffset, + NoteGroup->Width, NoteGroup->Top + NoteGroup->Height - NoteGroupTop); AnonymousLoginCheck->Checked = SameText(UserNameEdit->Text, AnonymousUserName) && SameText(PasswordEdit->Text, AnonymousPassword); @@ -845,13 +856,18 @@ TSessionData * __fastcall TLoginDialog::GetEditingSessionData() //--------------------------------------------------------------------------- void __fastcall TLoginDialog::SaveAsSession(bool ForceDialog) { + // Parse hostname before saving + // (HostNameEditExit is not triggered when child dialog pops up when it is invoked by accelerator) + // We should better handle this automaticaly when focus is moved to another dialog. + ParseHostName(); + std::unique_ptr SessionData(new TSessionData(L"")); SaveSession(SessionData.get()); TSessionData * EditingSessionData = GetEditingSessionData(); // collect list of empty folders (these are not persistent and known to login dialog only) - std::auto_ptr NewFolders(new TStringList()); + std::unique_ptr NewFolders(new TStringList()); TTreeNode * Node = SessionTree->Items->GetFirstNode(); while (Node != NULL) { @@ -1010,22 +1026,34 @@ void __fastcall TLoginDialog::DeleteSessionActionExecute(TObject * /*Sender*/) } } //--------------------------------------------------------------------------- -void __fastcall TLoginDialog::ReloadSessions() +void __fastcall TLoginDialog::ReloadSessions(const UnicodeString & SelectSite) { SaveState(); - LoadSessions(); - LoadState(); - if (SessionTree->Items->Count > 0) + if (!SelectSite.IsEmpty()) { - SessionTree->Items->GetFirstNode()->MakeVisible(); + WinConfiguration->LastStoredSession = SelectSite; } + LoadSessions(); + LoadState(); } //--------------------------------------------------------------------------- void __fastcall TLoginDialog::ImportSessionsActionExecute(TObject * /*Sender*/) { - if (DoImportSessionsDialog()) + std::unique_ptr Imported(new TList()); + if (DoImportSessionsDialog(Imported.get())) { - ReloadSessions(); + UnicodeString SelectSite; + if (ALWAYS_TRUE(Imported->Count > 0)) + { + // Focus the first imported session. + // We should also consider expanding all newly created folders + SelectSite = static_cast(Imported->Items[0])->Name; + } + + ReloadSessions(SelectSite); + + // Focus the tree with focused imported session(s). + SessionTree->SetFocus(); } } //--------------------------------------------------------------------------- @@ -1053,6 +1081,7 @@ void __fastcall TLoginDialog::ActionListUpdate(TBasicAction * BasicAction, TAction * Action = NOT_NULL(dynamic_cast(BasicAction)); bool PrevEnabled = Action->Enabled; + bool Editable = IsEditable(); if ((Action == EditSessionAction) || (Action == CloneToNewSiteAction)) @@ -1095,16 +1124,16 @@ void __fastcall TLoginDialog::ActionListUpdate(TBasicAction * BasicAction, } else if (Action == SaveSessionAction) { - SaveSessionAction->Enabled = NewSiteSelected || FEditing; + SaveSessionAction->Enabled = Editable; } else if (Action == SessionAdvancedAction) { - SessionAdvancedAction->Enabled = NewSiteSelected || FEditing; + SessionAdvancedAction->Enabled = Editable; } else if (Action == SaveAsSessionAction) { // Save as is needed for new site only when !SupportsSplitButton() - SaveAsSessionAction->Enabled = NewSiteSelected || FEditing; + SaveAsSessionAction->Enabled = Editable; } else if (Action == NewSessionFolderAction) { @@ -1122,6 +1151,26 @@ void __fastcall TLoginDialog::ActionListUpdate(TBasicAction * BasicAction, { Action->Visible = FLAGSET(FOptions, loExternalTools); } + else if (Action == PasteUrlAction) + { + UnicodeString ClipboardUrl; + Action->Enabled = + TextFromClipboard(ClipboardUrl, true) && + !ClipboardUrl.IsEmpty() && + StoredSessions->IsUrl(ClipboardUrl); + } + else if (Action == GenerateUrlAction) + { + TSessionData * Data = GetSessionData(); + // URL without hostname is pointless + Action->Enabled = (Data != NULL) && !Data->HostName.IsEmpty() && !FEditing; + } + else if (Action == CopyParamRuleAction) + { + TSessionData * Data = GetSessionData(); + // without hostname it's pointless + Action->Enabled = (Data != NULL) && !Data->HostName.IsEmpty(); + } Handled = true; // to update buttons visibility @@ -1169,11 +1218,20 @@ bool __fastcall TLoginDialog::Execute(TList * DataList) } else { + FNewSiteData->Assign(SessionData); + FNewSiteData->Special = false; + // This is actualy bit pointless, as we focus the last selected site anyway // in LoadState(). As of now, we hardly get any useful data // in ad-hoc DataList anyway, so it is not a big deal - FNewSiteData->Assign(SessionData); - FNewSiteData->Special = false; + // (this was implemented for support taking session url from clipboard instead + // of command-line, but without autoconnect, but this functionality was cancelled) + if (!FNewSiteData->IsSame(StoredSessions->DefaultSettings, false)) + { + // we want to start with new site page + FForceNewSite = true; + } + LoadContents(); } } @@ -1360,7 +1418,8 @@ void __fastcall TLoginDialog::LoadState() // (seems like it happens for sites that are at the same level // as site folders, e.g. for the very last root-level site, at long as // there are any folders) - if (!WinConfiguration->LastStoredSession.IsEmpty() && ALWAYS_TRUE(Visible)) + if (!FForceNewSite && + !WinConfiguration->LastStoredSession.IsEmpty() && ALWAYS_TRUE(Visible)) { UnicodeString Path = WinConfiguration->LastStoredSession; @@ -1515,6 +1574,11 @@ void __fastcall TLoginDialog::Dispatch(void * Message) } } } + else if (M->Msg == WM_MANAGES_CAPTION) + { + // caption managed in TLoginDialog::Init() + M->Result = 1; + } else { TForm::Dispatch(Message); @@ -1656,14 +1720,19 @@ void __fastcall TLoginDialog::HelpButtonClick(TObject * /*Sender*/) //--------------------------------------------------------------------------- bool __fastcall TLoginDialog::IsDefaultResult(TModalResult Result) { - // When editing, there's no default button, so make sure we do not call DefaultResult - return !FEditing && (Result == DefaultResult(this)); + return + // When editing or when hostname-less site is selected, + // there's no default button, so make sure we do not call DefaultResult + (FindDefaultButton(this) != NULL) && + (FindDefaultButton(this)->ModalResult != mrNone) && + (Result == DefaultResult(this)); } //--------------------------------------------------------------------------- void __fastcall TLoginDialog::FormCloseQuery(TObject * /*Sender*/, - bool & /*CanClose*/) + bool & CanClose) { - if (IsDefaultResult(ModalResult)) + CanClose = EnsureNotEditing(); + if (CanClose && IsDefaultResult(ModalResult)) { SaveDataList(FDataList); } @@ -1925,46 +1994,7 @@ TFSProtocol __fastcall TLoginDialog::GetFSProtocol(bool RequireScpFallbackDistin //--------------------------------------------------------------------------- int __fastcall TLoginDialog::DefaultPort() { - TFSProtocol FSProtocol = GetFSProtocol(false); - TFtps Ftps = GetFtps(); - int Result; - switch (FSProtocol) - { - case fsFTP: - if (Ftps == ftpsImplicit) - { - Result = FtpsImplicitPortNumber; - } - else - { - Result = FtpPortNumber; - } - break; - - case fsWebDAV: - if (Ftps == ftpsNone) - { - Result = HTTPPortNumber; - } - else - { - Result = HTTPSPortNumber; - } - break; - - default: - if (IsSshProtocol(FSProtocol)) - { - Result = SshPortNumber; - } - else - { - FAIL; - Result = -1; - } - break; - } - return Result; + return ::DefaultPort(GetFSProtocol(false), GetFtps()); } //--------------------------------------------------------------------------- void __fastcall TLoginDialog::TransferProtocolComboChange(TObject * Sender) @@ -2464,7 +2494,12 @@ void __fastcall TLoginDialog::ImportActionExecute(TObject * /*Sender*/) // before the session list gets destroyed SessionTree->Items->Clear(); Configuration->Import(OpenDialog->FileName); - ReloadSessions(); + ReloadSessions(L""); + + if (SessionTree->Items->Count > 0) + { + SessionTree->Items->GetFirstNode()->MakeVisible(); + } } } } @@ -2636,13 +2671,25 @@ bool __fastcall TLoginDialog::EnsureNotEditing() bool Result = !FEditing; if (!Result) { - UnicodeString Message = MainInstructions(LoadStr(LOGIN_CANCEL_EDITING)); - Result = (MessageDialog(Message, qtConfirmation, qaOK | qaCancel) == qaOK); - if (Result) + UnicodeString Message = MainInstructions(LoadStr(LOGIN_SAVE_EDITING)); + unsigned int Answer = MessageDialog(Message, qtConfirmation, qaYes |qaNo | qaCancel); + switch (Answer) { - CancelEditing(); - // Make sure OK button gets enabled - UpdateControls(); + case qaYes: + SaveAsSession(false); + Result = true; + break; + + case qaNo: + CancelEditing(); + // Make sure OK button gets enabled + UpdateControls(); + Result = true; + break; + + default: + // noop; + break; } } return Result; @@ -2675,17 +2722,23 @@ void __fastcall TLoginDialog::SessionAdvancedActionExecute(TObject * /*Sender*/) { // If we ever allow showing advanced settings, while read-only, // we must make sure that FSessionData actually holds the advanced settings, - // what is currently does not, in order to avoid master password prompt, + // what it currently does not, in order to avoid master password prompt, // while cloning the session data in LoadSession. // To implement this, we may delegate the cloning to TWinConfiguration and // make use of FDontDecryptPasswords if (ALWAYS_TRUE(FSessionData != NULL)) { + // parse hostname (it may change protocol particularly) before opening advanced settings + // (HostNameEditExit is not triggered when child dialog pops up when it is invoked by accelerator) + // We should better handle this automaticaly when focus is moved to another dialog. + ParseHostName(); + SaveSession(FSessionData); DoSiteAdvancedDialog(FSessionData, FOptions); - // not really needed as advanced site dialog can only change between - // fsSFTP and fsSFTPonly, difference of the two not being visible on - // login dialog. + // Needed only for Note. + // The only other property visible on Login dialog that Advanced site dialog + // can change is protocol (between fsSFTP and fsSFTPonly), + // difference of the two not being visible on Login dialog anyway. LoadSession(FSessionData); if (ALWAYS_TRUE(SessionTree->Selected != NULL) && IsSiteNode(SessionTree->Selected)) @@ -2738,6 +2791,7 @@ void __fastcall TLoginDialog::SessionTreeMouseDown(TObject * /*Sender*/, void __fastcall TLoginDialog::SessionTreeContextPopup(TObject * /*Sender*/, TPoint & MousePos, bool & Handled) { + ResetSitesIncrementalSearch(); TTreeNode * Node = SessionTree->GetNodeAt(MousePos.X, MousePos.Y); // This is mostly to prevent context menu from poping up, // while there is prompt to confirm cancelling session edit, @@ -2826,9 +2880,7 @@ void __fastcall TLoginDialog::PuttyActionExecute(TObject * /*Sender*/) std::unique_ptr Data(CloneSelectedSession()); // putty does not support resolving environment variables in session settings Data->ExpandEnvironmentVariables(); - OpenSessionInPutty(GUIConfiguration->PuttyPath, Data.get(), - Data->UserNameExpanded, - GUIConfiguration->PuttyPassword ? Data->Password : UnicodeString()); + OpenSessionInPutty(GUIConfiguration->PuttyPath, Data.get()); if (Close) { @@ -2841,3 +2893,104 @@ void __fastcall TLoginDialog::LoginButtonDropDownClick(TObject * /*Sender*/) MenuPopup(LoginDropDownMenu, LoginButton); } //--------------------------------------------------------------------------- +void __fastcall TLoginDialog::ParseUrl(const UnicodeString & Url) +{ + std::unique_ptr SessionData(new TSessionData(L"")); + + SaveSession(SessionData.get()); + + // We do not want to pass in StoredSessions as we do not want the URL be + // parsed as pointing to a stored site. + // It also prevents resetting to defaults (do we want this?) + bool DefaultsOnly; // unused + SessionData->ParseUrl(Url, NULL, NULL, DefaultsOnly, NULL, NULL, NULL); + + LoadSession(SessionData.get()); +} +//--------------------------------------------------------------------------- +void __fastcall TLoginDialog::PasteUrlActionExecute(TObject * /*Sender*/) +{ + UnicodeString ClipboardUrl; + if (ALWAYS_TRUE(TextFromClipboard(ClipboardUrl, true) && !ClipboardUrl.IsEmpty())) + { + if (!IsEditable()) + { + // select new site node, when other node is selected and not in editing mode + SessionTree->Selected = GetNewSiteNode(); + } + + // sanity check + if (ALWAYS_TRUE(IsEditable())) + { + ParseUrl(ClipboardUrl); + } + + // visualize the pasting + HostNameEdit->SetFocus(); + HostNameEdit->SelectAll(); + } +} +//--------------------------------------------------------------------------- +void __fastcall TLoginDialog::ParseHostName() +{ + UnicodeString HostName = HostNameEdit->Text; + if (!HostName.IsEmpty() && + (StoredSessions->IsUrl(HostName) || (HostName.Pos(L"@") > 0))) + { + ParseUrl(HostName); + } +} +//--------------------------------------------------------------------------- +void __fastcall TLoginDialog::HostNameEditExit(TObject * /*Sender*/) +{ + ParseHostName(); +} +//--------------------------------------------------------------------------- +void __fastcall TLoginDialog::GenerateUrlActionExecute(TObject * /*Sender*/) +{ + if (ALWAYS_TRUE(SelectedSession != NULL)) + { + PersistNewSiteIfNeeded(); + DoGenerateUrlDialog(SelectedSession, NULL); + } +} +//--------------------------------------------------------------------------- +void __fastcall TLoginDialog::CopyParamRuleActionExecute(TObject * /*Sender*/) +{ + TSessionData * Data = GetSessionData(); + std::unique_ptr CopyParamList(new TCopyParamList()); + (*CopyParamList) = *GUIConfiguration->CopyParamList; + + TCopyParamRuleData RuleData; + RuleData.HostName = Data->HostNameExpanded; + RuleData.UserName = Data->UserNameExpanded; + int CopyParamIndex = CopyParamList->Find(RuleData); + if (CopyParamIndex < 0) + { + TCopyParamRuleData RuleDataHostNameOnly; + RuleDataHostNameOnly.HostName = Data->HostNameExpanded; + CopyParamIndex = CopyParamList->Find(RuleDataHostNameOnly); + } + + TCopyParamPresetMode Mode; + TCopyParamRuleData * CurrentRuleData = NULL; + + if (CopyParamIndex < 0) + { + Mode = cpmAddCurrent; + CurrentRuleData = &RuleData; + } + else + { + Mode = cpmEdit; + } + + TCopyParamType DummyDefaultCopyParams; + + if (DoCopyParamPresetDialog( + CopyParamList.get(), CopyParamIndex, Mode, CurrentRuleData, DummyDefaultCopyParams)) + { + GUIConfiguration->CopyParamList = CopyParamList.get(); + } +} +//--------------------------------------------------------------------------- diff --git a/source/forms/Login.dfm b/source/forms/Login.dfm index 2324e4d4..d9ac4a32 100644 --- a/source/forms/Login.dfm +++ b/source/forms/Login.dfm @@ -8,7 +8,7 @@ object LoginDialog: TLoginDialog ClientHeight = 432 ClientWidth = 630 Color = clBtnFace - Constraints.MinHeight = 350 + Constraints.MinHeight = 375 Constraints.MinWidth = 600 ParentFont = True KeyPreview = True @@ -183,6 +183,7 @@ object LoginDialog: TLoginDialog TabOrder = 5 Text = 'HostNameEdit' OnChange = DataChange + OnExit = HostNameEditExit end object UserNameEdit: TEdit Left = 12 @@ -229,7 +230,8 @@ object LoginDialog: TLoginDialog Items.Strings = ( 'SFTP' 'SCP' - 'FTP') + 'FTP' + 'WebDAV') end object FtpsCombo: TComboBox Left = 163 @@ -327,6 +329,33 @@ object LoginDialog: TLoginDialog OnDropDownClick = SaveButtonDropDownClick end end + object NoteGroup: TGroupBox + Left = 2 + Top = 247 + Width = 347 + Height = 141 + Anchors = [akLeft, akTop, akRight, akBottom] + Caption = 'Note' + TabOrder = 1 + DesignSize = ( + 347 + 141) + object NoteMemo: TMemo + Left = 7 + Top = 15 + Width = 333 + Height = 117 + TabStop = False + Anchors = [akLeft, akTop, akRight, akBottom] + BevelInner = bvNone + BevelOuter = bvNone + BorderStyle = bsNone + Lines.Strings = ( + 'NoteMemo') + ScrollBars = ssVertical + TabOrder = 0 + end + end end object ButtonPanel: TPanel Left = 0 @@ -600,6 +629,22 @@ object LoginDialog: TLoginDialog 'Shift+Ctrl+P') OnExecute = PuttyActionExecute end + object PasteUrlAction: TAction + Category = 'Sessions' + Caption = 'Paste Session &URL' + ShortCut = 16470 + OnExecute = PasteUrlActionExecute + end + object GenerateUrlAction: TAction + Category = 'Sessions' + Caption = '&Generate Session URL...' + OnExecute = GenerateUrlActionExecute + end + object CopyParamRuleAction: TAction + Category = 'Sessions' + Caption = 'Transfer Settings &Rule...' + OnExecute = CopyParamRuleActionExecute + end end object ToolsPopupMenu: TPopupMenu Left = 176 @@ -1074,6 +1119,9 @@ object LoginDialog: TLoginDialog object SiteClonetoNewSiteMenuItem: TMenuItem Action = CloneToNewSiteAction end + object GenerateSessionURL1: TMenuItem + Action = GenerateUrlAction + end object N5: TMenuItem Caption = '-' end @@ -1160,6 +1208,12 @@ object LoginDialog: TLoginDialog object Reset1: TMenuItem Action = ResetNewSessionAction end + object Paste1: TMenuItem + Action = PasteUrlAction + end + object GenerateSessionURL2: TMenuItem + Action = GenerateUrlAction + end object MenuItem21: TMenuItem Caption = '-' end @@ -1216,6 +1270,9 @@ object LoginDialog: TLoginDialog Action = SessionAdvancedAction Default = True end + object TransferSettingsRule1: TMenuItem + Action = CopyParamRuleAction + end object MenuItem14: TMenuItem Caption = 'Global Preferences' Enabled = False diff --git a/source/forms/Login.h b/source/forms/Login.h index 9c239a4b..df07d75e 100644 --- a/source/forms/Login.h +++ b/source/forms/Login.h @@ -164,6 +164,15 @@ class TLoginDialog : public TForm TMenuItem *N11; TMenuItem *OpeninPuTTY2; TMenuItem *OpeninPuTTY3; + TAction *PasteUrlAction; + TMenuItem *Paste1; + TAction *GenerateUrlAction; + TMenuItem *GenerateSessionURL1; + TMenuItem *GenerateSessionURL2; + TAction *CopyParamRuleAction; + TMenuItem *TransferSettingsRule1; + TGroupBox *NoteGroup; + TMemo *NoteMemo; void __fastcall DataChange(TObject *Sender); void __fastcall FormShow(TObject *Sender); void __fastcall SessionTreeDblClick(TObject *Sender); @@ -233,6 +242,10 @@ class TLoginDialog : public TForm void __fastcall LoginActionExecute(TObject *Sender); void __fastcall PuttyActionExecute(TObject *Sender); void __fastcall LoginButtonDropDownClick(TObject *Sender); + void __fastcall PasteUrlActionExecute(TObject *Sender); + void __fastcall HostNameEditExit(TObject *Sender); + void __fastcall GenerateUrlActionExecute(TObject *Sender); + void __fastcall CopyParamRuleActionExecute(TObject *Sender); private: int NoUpdate; @@ -254,10 +267,12 @@ class TLoginDialog : public TForm int FIncrementalSearching; bool FSitesIncrementalSearchHaveNext; int FBasicGroupBaseHeight; + int FNoteGroupOffset; TRect FSavedBounds; bool FEditing; bool FRenaming; TSize FOriginalSize; + bool FForceNewSite; void __fastcall LoadSession(TSessionData * SessionData); void __fastcall LoadContents(); @@ -308,7 +323,7 @@ class TLoginDialog : public TForm inline TSessionData * __fastcall GetNodeSession(TTreeNode * Node); void __fastcall ExecuteTool(const UnicodeString & Name); UnicodeString __fastcall ImportExportIniFilePath(); - void __fastcall ReloadSessions(); + void __fastcall ReloadSessions(const UnicodeString & SelectSite); void __fastcall ResetSitesIncrementalSearch(); bool __fastcall SitesIncrementalSearch(const UnicodeString & Text, bool SkipCurrent, bool Reverse); @@ -337,6 +352,8 @@ class TLoginDialog : public TForm bool __fastcall IsEditable(); TSessionData * __fastcall CloneSelectedSession(); void __fastcall CloneToNewSite(); + void __fastcall ParseUrl(const UnicodeString & Url); + void __fastcall ParseHostName(); void __fastcall ResetNewSiteData(); protected: diff --git a/source/forms/MessageDlg.cpp b/source/forms/MessageDlg.cpp index 7fc29466..50ddac19 100644 --- a/source/forms/MessageDlg.cpp +++ b/source/forms/MessageDlg.cpp @@ -17,6 +17,8 @@ #include #include #include +#include +#include //--------------------------------------------------------------------------- #pragma package(smart_init) //--------------------------------------------------------------------------- @@ -66,7 +68,8 @@ class TMessageForm : public TForm TMsgDlgType DlgType, unsigned int Answers, const TQueryButtonAlias * Aliases, unsigned int AliasesCount, unsigned int TimeoutAnswer, TButton ** TimeoutButton, const UnicodeString & ImageName, - const UnicodeString & NeverAskAgainCaption); + const UnicodeString & NeverAskAgainCaption, const UnicodeString & MoreMessagesUrl, + TSize MoreMessagesSize); virtual int __fastcall ShowModal(); @@ -92,6 +95,9 @@ class TMessageForm : public TForm UnicodeString MessageText; TMemo * MessageMemo; + TPanel * MessageBrowserPanel; + TWebBrowserEx * MessageBrowser; + UnicodeString MessageBrowserUrl; TShiftState FShiftState; TTimer * FUpdateForShiftStateTimer; TForm * FDummyForm; @@ -106,7 +112,7 @@ class TMessageForm : public TForm UnicodeString Name, UnicodeString Caption, unsigned int Answer, TNotifyEvent OnClick, bool IsTimeoutButton, int GroupWith, TShiftState GrouppedShiftState, - TAnswerButtons & AnswerButtons, bool HasMoreMessages, int & ButtonWidth); + TAnswerButtons & AnswerButtons, bool HasMoreMessages, int & ButtonWidths); bool __fastcall ApplicationHook(TMessage & Message); }; //--------------------------------------------------------------------------- @@ -114,6 +120,8 @@ __fastcall TMessageForm::TMessageForm(TComponent * AOwner) : TForm(AOwner, 0) { FShowNoActivate = false; MessageMemo = NULL; + MessageBrowserPanel = NULL; + MessageBrowser = NULL; FUpdateForShiftStateTimer = NULL; Position = poOwnerFormCenter; UseSystemSettingsPre(this); @@ -263,6 +271,21 @@ UnicodeString __fastcall TMessageForm::GetFormText() { MoreMessages = MessageMemo->Text + DividerLine; } + else if (MessageBrowser != NULL) + { + MessageBrowser->SelectAll(); + MessageBrowser->CopyToClipBoard(); + if (TextFromClipboard(MoreMessages, true)) + { + if (!EndsStr(sLineBreak, MoreMessages)) + { + MoreMessages += sLineBreak; + } + MoreMessages += DividerLine; + } + // http://www.ssicom.org/js/x277333.htm + MessageBrowser->DoCommand(L"UNSELECT"); + } UnicodeString MessageCaption = NormalizeNewLines(MessageText); UnicodeString Result = FORMAT(L"%s%s%s%s%s%s%s%s%s%s%s", (DividerLine, Caption, sLineBreak, DividerLine, MessageCaption, sLineBreak, DividerLine, MoreMessages, @@ -277,6 +300,9 @@ UnicodeString __fastcall TMessageForm::GetReportText() { Text += L"\n" + MessageMemo->Text; } + // Currently we use browser for updates box only and it has help context, + // and does not have Report button, so we cannot get here. + assert(MessageBrowser == NULL); Text = NormalizeNewLines(Text); UnicodeString ReportErrorText = NormalizeNewLines(FMTLOAD(REPORT_ERROR, (L""))); Text = ReplaceStr(Text, ReportErrorText, L""); @@ -471,6 +497,20 @@ void __fastcall TMessageForm::DoShow() UseSystemSettingsPost(this); TForm::DoShow(); + + if (!MessageBrowserUrl.IsEmpty() && + // Guard against repeated calls to DoOpen() + (MessageBrowser == NULL)) + { + // Web Browser component does not seem to work, + // when created before any window is shown. + // I.e. when the message dialog is the first window (like when /update is used). + // So we have to delay its creation until at least the dialog box is shown. + MessageBrowser = CreateBrowserViewer(MessageBrowserPanel, LoadStr(MESSAGE_LOADING)); + MessageBrowser->SendToBack(); + + MessageBrowser->Navigate(MessageBrowserUrl.c_str()); + } } //--------------------------------------------------------------------------- void __fastcall TMessageForm::MenuItemClick(TObject * Sender) @@ -536,7 +576,7 @@ TButton * __fastcall TMessageForm::CreateButton( UnicodeString Name, UnicodeString Caption, unsigned int Answer, TNotifyEvent OnClick, bool IsTimeoutButton, int GroupWith, TShiftState GrouppedShiftState, - TAnswerButtons & AnswerButtons, bool HasMoreMessages, int & ButtonWidth) + TAnswerButtons & AnswerButtons, bool HasMoreMessages, int & ButtonWidths) { UnicodeString MeasureCaption = Caption; if (IsTimeoutButton) @@ -618,6 +658,13 @@ TButton * __fastcall TMessageForm::CreateButton( // button caption. We just blindly hope that captions of advanced commands // are always longer than the caption of simple default command CurButtonWidth += ScaleByTextHeightRunTime(this, 15); + + // never shrink buttons below their default width + if (GroupWithButton->Width < CurButtonWidth) + { + ButtonWidths += CurButtonWidth - GroupWithButton->Width; + GroupWithButton->Width = CurButtonWidth; + } } else { @@ -647,15 +694,11 @@ TButton * __fastcall TMessageForm::CreateButton( } // never shrink buttons below their default width - if (Button->Width > CurButtonWidth) + if (Button->Width < CurButtonWidth) { - CurButtonWidth = Button->Width; + Button->Width = CurButtonWidth; } - } - - if (CurButtonWidth > ButtonWidth) - { - ButtonWidth = CurButtonWidth; + ButtonWidths += Button->Width; } return Button; @@ -751,7 +794,8 @@ TForm * __fastcall TMessageForm::Create(const UnicodeString & Msg, TStrings * MoreMessages, TMsgDlgType DlgType, unsigned int Answers, const TQueryButtonAlias * Aliases, unsigned int AliasesCount, unsigned int TimeoutAnswer, TButton ** TimeoutButton, const UnicodeString & ImageName, - const UnicodeString & NeverAskAgainCaption) + const UnicodeString & NeverAskAgainCaption, const UnicodeString & MoreMessagesUrl, + TSize MoreMessagesSize) { unsigned int DefaultAnswer; if (FLAGSET(Answers, qaOK)) @@ -818,6 +862,8 @@ TForm * __fastcall TMessageForm::Create(const UnicodeString & Msg, // that is set in DoFormWindowProc(CM_SHOWINGCHANGED) later. Forms::TMonitor * Monitor = FormMonitor(Result); + bool HasMoreMessages = (MoreMessages != NULL) || !MoreMessagesUrl.IsEmpty(); + Result->BiDiMode = Application->BiDiMode; Result->BorderStyle = bsDialog; Result->Canvas->Font = Result->Font; @@ -826,7 +872,7 @@ TForm * __fastcall TMessageForm::Create(const UnicodeString & Msg, int VertMargin = ScaleByTextHeightRunTime(Result, mcVertMargin); int HorzSpacing = ScaleByTextHeightRunTime(Result, mcHorzSpacing); int ButtonVertMargin = ScaleByTextHeightRunTime(Result, mcButtonVertMargin); - int ButtonWidth = -1; + int ButtonWidths = 0; int ButtonHeight = -1; std::vector ButtonControls; TAnswerButtons AnswerButtons; @@ -892,7 +938,7 @@ TForm * __fastcall TMessageForm::Create(const UnicodeString & Msg, TButton * Button = Result->CreateButton( Name, Caption, Answer, OnClick, IsTimeoutButton, GroupWith, GrouppedShiftState, - AnswerButtons, (MoreMessages != NULL), ButtonWidth); + AnswerButtons, HasMoreMessages, ButtonWidths); if (Button != NULL) { @@ -929,7 +975,7 @@ TForm * __fastcall TMessageForm::Create(const UnicodeString & Msg, int ButtonGroupWidth = NeverAskAgainWidth; if (!ButtonControls.empty()) { - ButtonGroupWidth += ButtonWidth * ButtonControls.size() + + ButtonGroupWidth += ButtonWidths + ButtonSpacing * (ButtonControls.size() - 1); } @@ -941,7 +987,7 @@ TForm * __fastcall TMessageForm::Create(const UnicodeString & Msg, IconWidth = 32 + HorzSpacing; } - assert((ButtonHeight > 0) && (ButtonWidth > 0)); + assert((ButtonHeight > 0) && (ButtonWidths > 0)); int MaxTextWidth = ScaleByTextHeightRunTime(Result, mcMaxDialogWidth); // if the dialog would be wide anyway (overwrite confirmation on Windows XP), @@ -1073,28 +1119,52 @@ TForm * __fastcall TMessageForm::Create(const UnicodeString & Msg, IconTextHeight = 32; } - int MoreMessageHeight = (MoreMessages != NULL ? - ScaleByTextHeightRunTime(Result, mcMoreMessageHeight) : 0); + int MoreMessageHeight = + (HasMoreMessages ? + ScaleByTextHeightRunTime(Result, (MoreMessagesSize.Height > 0 ? MoreMessagesSize.Height : mcMoreMessageHeight)) : 0); Panel->SetBounds(0, 0, Result->ClientWidth, VertMargin + IconTextHeight + VertMargin + MoreMessageHeight); - if (MoreMessages != NULL) + TControl * MoreMessagesControl = NULL; + if (HasMoreMessages) { - TMemo * MessageMemo = new TMemo(Panel); - MessageMemo->Name = L"MessageMemo"; - MessageMemo->Parent = Panel; - MessageMemo->ReadOnly = true; - MessageMemo->WantReturns = False; - MessageMemo->ScrollBars = ssVertical; - MessageMemo->Anchors = TAnchors() << akLeft << akRight << akTop; - MessageMemo->Lines->Text = MoreMessages->Text; - - Result->MessageMemo = MessageMemo; + if (MoreMessages != NULL) + { + assert(MoreMessagesUrl.IsEmpty()); + + TMemo * MessageMemo = new TMemo(Panel); + MoreMessagesControl = MessageMemo; + MessageMemo->Name = L"MessageMemo"; + MessageMemo->Parent = Panel; + MessageMemo->ReadOnly = true; + MessageMemo->WantReturns = False; + MessageMemo->ScrollBars = ssVertical; + MessageMemo->Anchors = TAnchors() << akLeft << akRight << akTop; + MessageMemo->Lines->Text = MoreMessages->Text; + + Result->MessageMemo = MessageMemo; + } + else if (ALWAYS_TRUE(!MoreMessagesUrl.IsEmpty())) + { + TPanel * MessageBrowserPanel = new TPanel(Panel); + MessageBrowserPanel->Parent = Panel; + MessageBrowserPanel->Anchors = TAnchors() << akLeft << akRight << akTop; + MessageBrowserPanel->BevelOuter = bvNone; + MessageBrowserPanel->BevelInner = bvNone; // default + MessageBrowserPanel->BevelKind = bkTile; + Result->MessageBrowserPanel = MessageBrowserPanel; + + MoreMessagesControl = Result->MessageBrowserPanel; + + UnicodeString FontSizeParam = FORMAT(L"fontsize=%d", (Result->Font->Size)); + UnicodeString Url = AppendUrlParams(CampaignUrl(MoreMessagesUrl), FontSizeParam); + Result->MessageBrowserUrl = Url; + } } int MinClientWidth = ScaleByTextHeightRunTime(Result, - (MoreMessages != NULL) ? mcMinDialogwithMoreMessagesWidth : mcMinDialogWidth); + HasMoreMessages ? (MoreMessagesSize.Width > 0 ? MoreMessagesSize.Width : mcMinDialogwithMoreMessagesWidth) : mcMinDialogWidth); int AClientWidth = Max( (IconTextWidth > ButtonGroupWidth ? IconTextWidth : ButtonGroupWidth) + @@ -1131,9 +1201,9 @@ TForm * __fastcall TMessageForm::Create(const UnicodeString & Msg, Image->SetBounds(HorzMargin, VertMargin, 32, 32); } - if (Result->MessageMemo != NULL) + if (MoreMessagesControl != NULL) { - Result->MessageMemo->SetBounds( + MoreMessagesControl->SetBounds( ALeft, Panel->Height - MoreMessageHeight, Result->ClientWidth - ALeft - HorzMargin, @@ -1145,8 +1215,8 @@ TForm * __fastcall TMessageForm::Create(const UnicodeString & Msg, for (unsigned int i = 0; i < ButtonControls.size(); i++) { ButtonControls[i]->SetBounds( - X, ButtonTop, ButtonWidth, ButtonControls[i]->Height); - X += ButtonWidth + ButtonSpacing; + X, ButtonTop, ButtonControls[i]->Width, ButtonControls[i]->Height); + X += ButtonControls[i]->Width + ButtonSpacing; } if (!NeverAskAgainCaption.IsEmpty() && @@ -1174,9 +1244,10 @@ TForm * __fastcall CreateMoreMessageDialog(const UnicodeString & Msg, TStrings * MoreMessages, TMsgDlgType DlgType, unsigned int Answers, const TQueryButtonAlias * Aliases, unsigned int AliasesCount, unsigned int TimeoutAnswer, TButton ** TimeoutButton, const UnicodeString & ImageName, - const UnicodeString & NeverAskAgainCaption) + const UnicodeString & NeverAskAgainCaption, const UnicodeString & MoreMessagesUrl, + TSize MoreMessagesSize) { return TMessageForm::Create(Msg, MoreMessages, DlgType, Answers, Aliases, AliasesCount, TimeoutAnswer, TimeoutButton, ImageName, - NeverAskAgainCaption); + NeverAskAgainCaption, MoreMessagesUrl, MoreMessagesSize); } diff --git a/source/forms/NonVisual.cpp b/source/forms/NonVisual.cpp index a53541f3..61ea1894 100644 --- a/source/forms/NonVisual.cpp +++ b/source/forms/NonVisual.cpp @@ -187,7 +187,7 @@ void __fastcall TNonVisualDataModule::ExplorerActionsUpdate( UPD(FileListToCommandLineAction, EnabledSelectedOperation) UPD(FileListToClipboardAction, EnabledSelectedOperation) UPD(FullFileListToClipboardAction, EnabledSelectedOperation) - UPD(UrlToClipboardAction, EnabledSelectedOperation && (DirView(osRemote) == DirView(osCurrent))) + UPD(FileGenerateUrlAction, EnabledSelectedOperation && (DirView(osRemote) == DirView(osCurrent))) UPD(FileListFromClipboardAction, IsFormatInClipboard(CF_TEXT)); UPD(CurrentAddEditLinkAction, ScpExplorer->CanAddEditLink(osCurrent)) // local selected operation @@ -232,7 +232,7 @@ void __fastcall TNonVisualDataModule::ExplorerActionsUpdate( UPD(InvertSelectionAction, DirView(osCurrent)->FilesCount) UPD(ClearSelectionAction, DirView(osCurrent)->SelCount) UPD(RestoreSelectionAction, DirView(osCurrent)->SelectedNamesSaved) - UPD(PasteAction, ScpExplorer->CanPasteFromClipBoard()) + UPD(PasteAction2, ScpExplorer->CanPasteFromClipBoard()) UPD(LocalSelectAction, ScpExplorer->HasDirView[osLocal] && DirView(osLocal)->FilesCount) UPD(LocalUnselectAction, ScpExplorer->HasDirView[osLocal] && DirView(osLocal)->SelCount) UPD(LocalSelectAllAction, ScpExplorer->HasDirView[osLocal] && DirView(osLocal)->FilesCount) @@ -283,8 +283,7 @@ void __fastcall TNonVisualDataModule::ExplorerActionsUpdate( UPD(HistoryPageAction, true) UPD(TableOfContentsAction, true) UPD(ForumPageAction, true) - UPD(CheckForUpdatesAction, true) - UPDACT(ShowUpdatesAction, ShowUpdatesUpdate()) + UPDACT(CheckForUpdatesAction, ShowUpdatesUpdate()) UPD(UpdatesPreferencesAction, true) UPD(DonatePageAction, true) UPD(DownloadPageAction, true) @@ -332,8 +331,12 @@ void __fastcall TNonVisualDataModule::ExplorerActionsUpdate( ViewLogAction->Checked = false ) UPDEX(ShowHiddenFilesAction, true, ShowHiddenFilesAction->Checked = WinConfiguration->ShowHiddenFiles, ) - UPDEX(FormatSizeBytesAction, true, - FormatSizeBytesAction->Checked = WinConfiguration->FormatSizeBytes, ) + UPDEX(FormatSizeBytesNoneAction, true, + FormatSizeBytesNoneAction->Checked = (WinConfiguration->FormatSizeBytes == fbNone), ) + UPDEX(FormatSizeBytesKilobytesAction, true, + FormatSizeBytesKilobytesAction->Checked = (WinConfiguration->FormatSizeBytes == fbKilobytes), ) + UPDEX(FormatSizeBytesShortAction, true, + FormatSizeBytesShortAction->Checked = (WinConfiguration->FormatSizeBytes == fbShort), ) UPDEX(AutoReadDirectoryAfterOpAction, true, AutoReadDirectoryAfterOpAction->Checked = Configuration->AutoReadDirectoryAfterOp, ) UPD(PreferencesAction, true) @@ -417,6 +420,7 @@ void __fastcall TNonVisualDataModule::ExplorerActionsUpdate( UPD(SynchronizeBrowsingAction, true) UPD(CloseApplicationAction, true) UPD(FileSystemInfoAction, true) + UPD(SessionGenerateUrlAction, true) UPD(ClearCachesAction, (ScpExplorer->Terminal != NULL) && !ScpExplorer->Terminal->AreCachesEmpty) UPD(NewFileAction, !WinConfiguration->DisableOpenEdit) UPD(EditorListCustomizeAction, true) @@ -483,308 +487,306 @@ void __fastcall TNonVisualDataModule::ExplorerActionsUpdate( void __fastcall TNonVisualDataModule::ExplorerActionsExecute( TBasicAction *Action, bool &Handled) { - APPLICATION_EXCEPTION_HACK_BEGIN + assert(ScpExplorer); + if (!ScpExplorer->AllowedAction((TAction *)Action, aaExecute)) { - assert(ScpExplorer); - if (!ScpExplorer->AllowedAction((TAction *)Action, aaExecute)) - { - Handled = true; - return; - } - ScpExplorer->BeforeAction(); - + Handled = true; + return; + } + ScpExplorer->BeforeAction(); - { - TAutoNestingCounter Counter(FBusy); - // focused operation - EXE(CurrentDeleteFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osCurrent, true)) - EXE(CurrentPropertiesFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osCurrent, true)) - EXE(CurrentEditFocusedAction, ScpExplorer->ExecuteFile(osCurrent, efDefaultEditor, NULL, true, true)) - EXE(CurrentSystemMenuFocusedAction, ScpExplorer->DisplaySystemContextMenu()) - // operation - EXE(CurrentEditAction, ScpExplorer->ExecuteFile(osCurrent, efDefaultEditor, NULL, true, false)) - EXE(CurrentEditAlternativeAction, CreateEditorListMenu(CurrentEditAlternativeAction)) - EXE(CurrentEditInternalAction, ScpExplorer->ExecuteFile(osCurrent, efInternalEditor, NULL, true, false)) - EXE(CurrentEditWithAction, ScpExplorer->ExecuteCurrentFileWith()) - EXE(CurrentOpenAction, ScpExplorer->ExecuteCurrentFile()) - EXE(CurrentAddEditLinkAction, ScpExplorer->AddEditLink(osCurrent, false)) - EXE(CurrentAddEditLinkContextAction, ScpExplorer->AddEditLink(osCurrent, false)) - EXE(NewLinkAction, ScpExplorer->AddEditLink(osCurrent, true)) - EXE(CurrentRenameAction, ScpExplorer->ExecuteFileOperationCommand(foRename, osCurrent, false)) - EXE(CurrentDeleteAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osCurrent, false)) - EXE(CurrentDeleteAlternativeAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osCurrent, false, false, (void*)true)) - EXE(CurrentPropertiesAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osCurrent, false)) - EXE(FileListToCommandLineAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedCommandLine)) - EXE(FileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedClipboard)) - EXE(FullFileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFullFileList, pedClipboard)) - EXE(UrlToClipboardAction, ScpExplorer->PanelExport(osCurrent, peUrl, pedClipboard)) - EXE(FileListFromClipboardAction, ScpExplorer->FileListFromClipboard()) - // local selected operation - EXE(LocalCopyAction, ScpExplorer->ExecuteFileOperationCommand(foCopy, osLocal, false)) - EXE(LocalRenameAction, ScpExplorer->ExecuteFileOperationCommand(foRename, osLocal, false)) - EXE(LocalEditAction, ScpExplorer->ExecuteFile(osLocal, efDefaultEditor, NULL, true, false)) - EXE(LocalMoveAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osLocal, false)) - EXE(LocalCreateDirAction, ScpExplorer->CreateDirectory(osLocal)) - EXE(LocalDeleteAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osLocal, false)) - EXE(LocalPropertiesAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osLocal, false)) - EXE(LocalAddEditLinkAction, ScpExplorer->AddEditLink(osLocal, false)) - // local focused operation - EXE(LocalCopyFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foCopy, osLocal, true)) - EXE(LocalMoveFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osLocal, true)) - // remote selected operation - EXE(RemoteCopyAction, ScpExplorer->ExecuteFileOperationCommand(foCopy, osRemote, false)) - EXE(RemoteRenameAction, ScpExplorer->ExecuteFileOperationCommand(foRename, osRemote, false)) - EXE(RemoteEditAction, ScpExplorer->ExecuteFile(osRemote, efDefaultEditor, NULL, true, false)) - EXE(RemoteMoveAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osRemote, false)) - EXE(RemoteCreateDirAction, ScpExplorer->CreateDirectory(osRemote)) - EXE(RemoteDeleteAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osRemote, false)) - EXE(RemotePropertiesAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osRemote, false)) - EXE(RemoteMoveToAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteMove, osCurrent, false)) - EXE(RemoteCopyToAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteCopy, osCurrent, false)) - EXE(RemoteAddEditLinkAction, ScpExplorer->AddEditLink(osRemote, false)) - // remote focused operation - EXE(RemoteCopyFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foCopy, osRemote, true)) - EXE(RemoteMoveFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osRemote, true)) - EXE(RemoteMoveToFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteMove, osCurrent, true)) - EXE(RemoteCopyToFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteCopy, osCurrent, true)) - // directory - EXE(CurrentCreateDirAction, ScpExplorer->CreateDirectory(osCurrent)) - EXE(NewDirAction, ScpExplorer->CreateDirectory(osCurrent)) - EXE(RemoteFindFilesAction, ScpExplorer->RemoteFindFiles()) - //selection - EXE(SelectOneAction, DirView(osCurrent)->SelectCurrentItem(DirView(osCurrent)->NortonLike)) - EXE(SelectAction, DirView(osCurrent)->DoSelectByMask(true)) - EXE(UnselectAction, DirView(osCurrent)->DoSelectByMask(false)) - EXE(SelectAllAction, DirView(osCurrent)->SelectAll(smAll)) - EXE(InvertSelectionAction, DirView(osCurrent)->SelectAll(smInvert)) - EXE(ClearSelectionAction, DirView(osCurrent)->SelectAll(smNone)) - EXE(RestoreSelectionAction, DirView(osCurrent)->RestoreSelectedNames()) - EXE(LocalSelectAction, DirView(osLocal)->DoSelectByMask(true)) - EXE(LocalUnselectAction, DirView(osLocal)->DoSelectByMask(false)) - EXE(LocalSelectAllAction, DirView(osLocal)->SelectAll(smAll)) - EXE(RemoteSelectAction, DirView(osRemote)->DoSelectByMask(true)) - EXE(RemoteUnselectAction, DirView(osRemote)->DoSelectByMask(false)) - EXE(RemoteSelectAllAction, DirView(osRemote)->SelectAll(smAll)) - EXE(PasteAction, ScpExplorer->PasteFromClipBoard()) - - // style - EXE(CurrentCycleStyleAction, - if (DirView(osCurrent)->ViewStyle == vsReport) DirView(osCurrent)->ViewStyle = vsIcon; - else DirView(osCurrent)->ViewStyle = (TViewStyle)(DirView(osCurrent)->ViewStyle + 1); - ) - #define STYLEACTION(Style) EXE(Current ## Style ## Action, \ - DirView(osCurrent)->ViewStyle = vs ## Style) - STYLEACTION(Icon) - STYLEACTION(SmallIcon) - STYLEACTION(List) - STYLEACTION(Report) - #undef STYLEACTION - - #define PANEL_ACTIONS(SIDE) \ - EXE(SIDE ## BackAction, ScpExplorer->HistoryGo(os ## SIDE, -1)) \ - EXE(SIDE ## ForwardAction, ScpExplorer->HistoryGo(os ## SIDE, 1)) \ - EXE(SIDE ## ParentDirAction, DirView(os ## SIDE)->ExecuteParentDirectory()) \ - EXE(SIDE ## RootDirAction, DirView(os ## SIDE)->ExecuteRootDirectory()) \ - EXE(SIDE ## HomeDirAction, ScpExplorer->HomeDirectory(os ## SIDE)) \ - EXE(SIDE ## RefreshAction, DirView(os ## SIDE)->ReloadDirectory()) \ - EXE(SIDE ## OpenDirAction, ScpExplorer->OpenDirectory(os ## SIDE)) \ - EXE(SIDE ## ChangePathAction, ScpExplorer->ChangePath(os ## SIDE)) \ - EXE(SIDE ## AddBookmarkAction, ScpExplorer->AddBookmark(os ## SIDE)) \ - EXE(SIDE ## PathToClipboardAction, ScpExplorer->PanelExport(os ## SIDE, pePath, pedClipboard)) \ - EXE(SIDE ## FilterAction, ScpExplorer->Filter(os ## SIDE)) - PANEL_ACTIONS(Local) - PANEL_ACTIONS(Remote) - #undef PANEL_ACTIONS - EXE(LocalExploreDirectoryAction, ScpExplorer->ExploreLocalDirectory()) - - //HELP - EXE(AboutAction, DoAboutDialog(Configuration)) - EXE(HomepageAction, OpenBrowser(LoadStr(HOMEPAGE_URL))) - EXE(HistoryPageAction, OpenBrowser(LoadStr(HISTORY_URL))) - EXE(TableOfContentsAction, Application->HelpSystem->ShowTableOfContents()) - EXE(ForumPageAction, OpenBrowser(LoadStr(FORUM_URL))) - EXE(CheckForUpdatesAction, CheckForUpdates(false)) - EXE(ShowUpdatesAction, CheckForUpdates(true)) - EXE(UpdatesPreferencesAction, PreferencesDialog(pmUpdates)) - EXE(DonatePageAction, OpenBrowser(LoadStr(DONATE_URL))) - EXE(DownloadPageAction, OpenBrowser(LoadStr(DOWNLOAD_URL))) - - // VIEW - EXECOMP(SessionsTabs) - EXECOMP(StatusBar) - EXECOMP(ToolBar2) - EXECOMP(LocalStatusBar) - EXECOMP(RemoteStatusBar) - EXECOMP(ExplorerMenuBand) - EXECOMP(ExplorerAddressBand) - EXECOMP(ExplorerToolbarBand) - EXECOMP(ExplorerSelectionBand) - EXECOMP(ExplorerSessionBand) - EXECOMP(ExplorerPreferencesBand) - EXECOMP(ExplorerSortBand) - EXECOMP(ExplorerUpdatesBand) - EXECOMP(ExplorerTransferBand) - EXECOMP(ExplorerCustomCommandsBand) - EXECOMP(CommanderMenuBand) - EXECOMP(CommanderSessionBand) - EXECOMP(CommanderPreferencesBand) - EXECOMP(CommanderSortBand) - EXECOMP(CommanderCommandsBand) - EXECOMP(CommanderUpdatesBand) - EXECOMP(CommanderTransferBand) - EXECOMP(CommanderCustomCommandsBand) - EXECOMP(CommanderLocalHistoryBand) - EXECOMP(CommanderLocalNavigationBand) - EXECOMP(CommanderLocalFileBand) - EXECOMP(CommanderLocalSelectionBand) - EXECOMP(CommanderRemoteHistoryBand) - EXECOMP(CommanderRemoteNavigationBand) - EXECOMP(CommanderRemoteFileBand) - EXECOMP(CommanderRemoteSelectionBand) - EXECOMP(CommandLinePanel) - EXECOMP(RemoteTree) - EXECOMP(LocalTree) - EXE(GoToCommandLineAction, ScpExplorer->GoToCommandLine()) - EXE(GoToTreeAction, ScpExplorer->GoToTree()) - - EXE(ViewLogAction, WinConfiguration->LogView = - (WinConfiguration->LogView == lvNone ? lvWindow : lvNone) ) - EXE(ShowHiddenFilesAction, ScpExplorer->ToggleShowHiddenFiles()) - EXE(FormatSizeBytesAction, ScpExplorer->ToggleFormatSizeBytes()) - EXE(AutoReadDirectoryAfterOpAction, ScpExplorer->ToggleAutoReadDirectoryAfterOp()) - EXE(PreferencesAction, PreferencesDialog(::pmDefault) ) - EXE(PresetsPreferencesAction, PreferencesDialog(pmPresets) ) - EXE(LockToolbarsAction, WinConfiguration->LockToolbars = !WinConfiguration->LockToolbars) - EXE(SelectiveToolbarTextAction, WinConfiguration->SelectiveToolbarText = !WinConfiguration->SelectiveToolbarText) - EXECOMP(CustomCommandsBand) - EXE(ColorMenuAction, CreateSessionColorMenu(ColorMenuAction)); - - #define COLVIEWPROPS ((TCustomDirViewColProperties*)(((TCustomDirView*)(((TListColumns*)(ListColumn->Collection))->Owner()))->ColProperties)) - // SORT - EXESORTA(Local) - EXESORT(Local, dv, Name) - EXESORT(Local, dv, Ext) - EXESORT(Local, dv, Size) - EXESORT(Local, dv, Type) - EXESORT(Local, dv, Changed) - EXESORT(Local, dv, Attr) - EXESORTA(Remote) - EXESORT(Remote, uv, Name) - EXESORT(Remote, uv, Ext) - EXESORT(Remote, uv, Size) - EXESORT(Remote, uv, Changed) - EXESORT(Remote, uv, Rights) - EXESORT(Remote, uv, Owner) - EXESORT(Remote, uv, Group) - EXESORT(Remote, uv, Type) - EXESORTA(Current) - EXESORTC(Name, dvName, uvName) - EXESORTC(Ext, dvExt, uvExt) - EXESORTC(Size, dvSize, uvSize) - EXESORTC(Type, dvType, uvType) - EXESORTC(Changed, dvChanged, uvChanged) - EXESORTC(Rights, dvAttr, uvRights) - EXESORTC(Owner, dvName, uvOwner) - EXESORTC(Group, dvName, uvGroup) - EXE(SortColumnAscendingAction, assert(ListColumn); - COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = true; ListColumn = NULL ) - EXE(SortColumnDescendingAction, assert(ListColumn); - COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = false; ListColumn = NULL ) - - // SHOW/HIDE COLUMN - EXESHCOL(Local, dv, Name) - EXESHCOL(Local, dv, Ext) - EXESHCOL(Local, dv, Size) - EXESHCOL(Local, dv, Type) - EXESHCOL(Local, dv, Changed) - EXESHCOL(Local, dv, Attr) - EXESHCOL(Remote, uv, Name) - EXESHCOL(Remote, uv, Ext) - EXESHCOL(Remote, uv, Size) - EXESHCOL(Remote, uv, Changed) - EXESHCOL(Remote, uv, Rights) - EXESHCOL(Remote, uv, Owner) - EXESHCOL(Remote, uv, Group) - EXESHCOL(Remote, uv, LinkTarget) - EXESHCOL(Remote, uv, Type) - EXE(HideColumnAction, assert(ListColumn); - COLVIEWPROPS->Visible[ListColumn->Index] = false; ListColumn = NULL ) - EXE(BestFitColumnAction, assert(ListColumn); ListColumn = NULL ) // TODO - #undef COLVIEWPROPS - - // SESSION - EXE(NewSessionAction, ScpExplorer->NewSession(false)) - EXE(SiteManagerAction, ScpExplorer->NewSession(true)) - EXE(DuplicateSessionAction, ScpExplorer->DuplicateSession()) - EXE(CloseSessionAction, ScpExplorer->CloseSession()) - EXE(SavedSessionsAction2, CreateSessionListMenu(SavedSessionsAction2)) - EXE(WorkspacesAction, CreateWorkspacesMenu(WorkspacesAction)) - EXE(OpenedSessionsAction, CreateOpenedSessionListMenu(OpenedSessionsAction)) - EXE(SaveCurrentSessionAction2, ScpExplorer->SaveCurrentSession()) - EXE(SaveWorkspaceAction, ScpExplorer->SaveWorkspace(false)) - - // COMMAND - EXE(CompareDirectoriesAction, ScpExplorer->CompareDirectories()) - EXE(SynchronizeAction, ScpExplorer->SynchronizeDirectories()) - EXE(FullSynchronizeAction, ScpExplorer->FullSynchronizeDirectories()) - EXE(ConsoleAction, ScpExplorer->OpenConsole()) - EXE(PuttyAction, TTerminalManager::Instance()->OpenInPutty()) - EXE(SynchronizeBrowsingAction, ScpExplorer->SynchronizeBrowsingChanged()) - EXE(CloseApplicationAction, ScpExplorer->Close()) - EXE(FileSystemInfoAction, ScpExplorer->FileSystemInfo()) - EXE(ClearCachesAction, ScpExplorer->Terminal->ClearCaches()) - EXE(NewFileAction, ScpExplorer->EditNew(osCurrent)) - EXE(EditorListCustomizeAction, PreferencesDialog(pmEditor)) - - // CUSTOM COMMANDS - EXE(CustomCommandsAction, CreateCustomCommandsMenu(CustomCommandsAction)) - EXE(CustomCommandsEnterAction, ScpExplorer->AdHocCustomCommand(false)) - EXE(CustomCommandsEnterFocusedAction, ScpExplorer->AdHocCustomCommand(true)) - EXE(CustomCommandsLastAction, ScpExplorer->LastCustomCommand(false)) - EXE(CustomCommandsLastFocusedAction, ScpExplorer->LastCustomCommand(true)) - EXE(CustomCommandsCustomizeAction, PreferencesDialog(pmCustomCommands)) - - // QUEUE - EXE(QueueEnableAction, ScpExplorer->ToggleQueueEnabled()) - #define EXEQUEUE(OPERATION) EXE(Queue ## OPERATION ## Action, \ - ScpExplorer->ExecuteQueueOperation(qo ## OPERATION)) - EXEQUEUE(GoTo) - EXEQUEUE(Preferences) - EXEQUEUE(ItemQuery) - EXEQUEUE(ItemError) - EXEQUEUE(ItemPrompt) - EXEQUEUE(ItemDelete) - EXEQUEUE(ItemExecute) - EXEQUEUE(ItemPause) - EXEQUEUE(ItemResume) - EXEQUEUE(ItemUp) - EXEQUEUE(ItemDown) - EXEQUEUE(PauseAll) - EXEQUEUE(ResumeAll) - EXEQUEUE(DeleteAllDone) - #undef EXEQUEUE - EXE(QueueToggleShowAction, ScpExplorer->ToggleQueueVisibility()) - #define QUEUEACTION(SHOW) EXE(Queue ## SHOW ## Action, \ - TQueueViewConfiguration Config = WinConfiguration->QueueView; \ - if (Config.Show != qvShow) Config.LastHideShow = Config.Show; \ - Config.Show = qv ## SHOW; \ - WinConfiguration->QueueView = Config) - QUEUEACTION(Show) - QUEUEACTION(HideWhenEmpty) - QUEUEACTION(Hide) - #undef QUEUEACTION - EXE(QueueCycleOnceEmptyAction, CycleQueueOnceEmptyAction()); - EXE(QueueIdleOnceEmptyAction, SetQueueOnceEmptyAction(QueueIdleOnceEmptyAction)) - EXE(QueueDisconnectOnceEmptyAction, SetQueueOnceEmptyAction(QueueDisconnectOnceEmptyAction)) - EXE(QueueShutDownOnceEmptyAction, SetQueueOnceEmptyAction(QueueShutDownOnceEmptyAction)) - EXECOMP(QueueToolbar); - EXE(QueueItemSpeedAction, ) - ; - } - DoIdle(); + { + TAutoNestingCounter Counter(FBusy); + // focused operation + EXE(CurrentDeleteFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osCurrent, true)) + EXE(CurrentPropertiesFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osCurrent, true)) + EXE(CurrentEditFocusedAction, ScpExplorer->ExecuteFile(osCurrent, efDefaultEditor, NULL, true, true)) + EXE(CurrentSystemMenuFocusedAction, ScpExplorer->DisplaySystemContextMenu()) + // operation + EXE(CurrentEditAction, ScpExplorer->ExecuteFile(osCurrent, efDefaultEditor, NULL, true, false)) + EXE(CurrentEditAlternativeAction, CreateEditorListMenu(CurrentEditAlternativeAction)) + EXE(CurrentEditInternalAction, ScpExplorer->ExecuteFile(osCurrent, efInternalEditor, NULL, true, false)) + EXE(CurrentEditWithAction, ScpExplorer->ExecuteCurrentFileWith()) + EXE(CurrentOpenAction, ScpExplorer->ExecuteCurrentFile()) + EXE(CurrentAddEditLinkAction, ScpExplorer->AddEditLink(osCurrent, false)) + EXE(CurrentAddEditLinkContextAction, ScpExplorer->AddEditLink(osCurrent, false)) + EXE(NewLinkAction, ScpExplorer->AddEditLink(osCurrent, true)) + EXE(CurrentRenameAction, ScpExplorer->ExecuteFileOperationCommand(foRename, osCurrent, false)) + EXE(CurrentDeleteAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osCurrent, false)) + EXE(CurrentDeleteAlternativeAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osCurrent, false, false, (void*)true)) + EXE(CurrentPropertiesAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osCurrent, false)) + EXE(FileListToCommandLineAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedCommandLine)) + EXE(FileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedClipboard)) + EXE(FullFileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFullFileList, pedClipboard)) + EXE(FileGenerateUrlAction, ScpExplorer->FileGenerateUrl()) + EXE(FileListFromClipboardAction, ScpExplorer->FileListFromClipboard()) + // local selected operation + EXE(LocalCopyAction, ScpExplorer->ExecuteFileOperationCommand(foCopy, osLocal, false)) + EXE(LocalRenameAction, ScpExplorer->ExecuteFileOperationCommand(foRename, osLocal, false)) + EXE(LocalEditAction, ScpExplorer->ExecuteFile(osLocal, efDefaultEditor, NULL, true, false)) + EXE(LocalMoveAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osLocal, false)) + EXE(LocalCreateDirAction, ScpExplorer->CreateDirectory(osLocal)) + EXE(LocalDeleteAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osLocal, false)) + EXE(LocalPropertiesAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osLocal, false)) + EXE(LocalAddEditLinkAction, ScpExplorer->AddEditLink(osLocal, false)) + // local focused operation + EXE(LocalCopyFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foCopy, osLocal, true)) + EXE(LocalMoveFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osLocal, true)) + // remote selected operation + EXE(RemoteCopyAction, ScpExplorer->ExecuteFileOperationCommand(foCopy, osRemote, false)) + EXE(RemoteRenameAction, ScpExplorer->ExecuteFileOperationCommand(foRename, osRemote, false)) + EXE(RemoteEditAction, ScpExplorer->ExecuteFile(osRemote, efDefaultEditor, NULL, true, false)) + EXE(RemoteMoveAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osRemote, false)) + EXE(RemoteCreateDirAction, ScpExplorer->CreateDirectory(osRemote)) + EXE(RemoteDeleteAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osRemote, false)) + EXE(RemotePropertiesAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osRemote, false)) + EXE(RemoteMoveToAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteMove, osCurrent, false)) + EXE(RemoteCopyToAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteCopy, osCurrent, false)) + EXE(RemoteAddEditLinkAction, ScpExplorer->AddEditLink(osRemote, false)) + // remote focused operation + EXE(RemoteCopyFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foCopy, osRemote, true)) + EXE(RemoteMoveFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osRemote, true)) + EXE(RemoteMoveToFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteMove, osCurrent, true)) + EXE(RemoteCopyToFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteCopy, osCurrent, true)) + // directory + EXE(CurrentCreateDirAction, ScpExplorer->CreateDirectory(osCurrent)) + EXE(NewDirAction, ScpExplorer->CreateDirectory(osCurrent)) + EXE(RemoteFindFilesAction, ScpExplorer->RemoteFindFiles()) + //selection + EXE(SelectOneAction, DirView(osCurrent)->SelectCurrentItem(DirView(osCurrent)->NortonLike)) + EXE(SelectAction, DirView(osCurrent)->DoSelectByMask(true)) + EXE(UnselectAction, DirView(osCurrent)->DoSelectByMask(false)) + EXE(SelectAllAction, DirView(osCurrent)->SelectAll(smAll)) + EXE(InvertSelectionAction, DirView(osCurrent)->SelectAll(smInvert)) + EXE(ClearSelectionAction, DirView(osCurrent)->SelectAll(smNone)) + EXE(RestoreSelectionAction, DirView(osCurrent)->RestoreSelectedNames()) + EXE(LocalSelectAction, DirView(osLocal)->DoSelectByMask(true)) + EXE(LocalUnselectAction, DirView(osLocal)->DoSelectByMask(false)) + EXE(LocalSelectAllAction, DirView(osLocal)->SelectAll(smAll)) + EXE(RemoteSelectAction, DirView(osRemote)->DoSelectByMask(true)) + EXE(RemoteUnselectAction, DirView(osRemote)->DoSelectByMask(false)) + EXE(RemoteSelectAllAction, DirView(osRemote)->SelectAll(smAll)) + EXE(PasteAction2, ScpExplorer->PasteFromClipBoard()) + + // style + EXE(CurrentCycleStyleAction, + if (DirView(osCurrent)->ViewStyle == vsReport) DirView(osCurrent)->ViewStyle = vsIcon; + else DirView(osCurrent)->ViewStyle = (TViewStyle)(DirView(osCurrent)->ViewStyle + 1); + ) + #define STYLEACTION(Style) EXE(Current ## Style ## Action, \ + DirView(osCurrent)->ViewStyle = vs ## Style) + STYLEACTION(Icon) + STYLEACTION(SmallIcon) + STYLEACTION(List) + STYLEACTION(Report) + #undef STYLEACTION + + #define PANEL_ACTIONS(SIDE) \ + EXE(SIDE ## BackAction, ScpExplorer->HistoryGo(os ## SIDE, -1)) \ + EXE(SIDE ## ForwardAction, ScpExplorer->HistoryGo(os ## SIDE, 1)) \ + EXE(SIDE ## ParentDirAction, DirView(os ## SIDE)->ExecuteParentDirectory()) \ + EXE(SIDE ## RootDirAction, DirView(os ## SIDE)->ExecuteRootDirectory()) \ + EXE(SIDE ## HomeDirAction, ScpExplorer->HomeDirectory(os ## SIDE)) \ + EXE(SIDE ## RefreshAction, DirView(os ## SIDE)->ReloadDirectory()) \ + EXE(SIDE ## OpenDirAction, ScpExplorer->OpenDirectory(os ## SIDE)) \ + EXE(SIDE ## ChangePathAction, ScpExplorer->ChangePath(os ## SIDE)) \ + EXE(SIDE ## AddBookmarkAction, ScpExplorer->AddBookmark(os ## SIDE)) \ + EXE(SIDE ## PathToClipboardAction, ScpExplorer->PanelExport(os ## SIDE, pePath, pedClipboard)) \ + EXE(SIDE ## FilterAction, ScpExplorer->Filter(os ## SIDE)) + PANEL_ACTIONS(Local) + PANEL_ACTIONS(Remote) + #undef PANEL_ACTIONS + EXE(LocalExploreDirectoryAction, ScpExplorer->ExploreLocalDirectory()) + + //HELP + EXE(AboutAction, DoAboutDialog(Configuration)) + EXE(HomepageAction, OpenBrowser(LoadStr(HOMEPAGE_URL))) + EXE(HistoryPageAction, OpenBrowser(LoadStr(HISTORY_URL))) + EXE(TableOfContentsAction, Application->HelpSystem->ShowTableOfContents()) + EXE(ForumPageAction, OpenBrowser(LoadStr(FORUM_URL))) + EXE(CheckForUpdatesAction, CheckForUpdates(false)) + EXE(UpdatesPreferencesAction, PreferencesDialog(pmUpdates)) + EXE(DonatePageAction, OpenBrowser(LoadStr(DONATE_URL))) + EXE(DownloadPageAction, OpenBrowser(LoadStr(DOWNLOAD_URL))) + + // VIEW + EXECOMP(SessionsTabs) + EXECOMP(StatusBar) + EXECOMP(ToolBar2) + EXECOMP(LocalStatusBar) + EXECOMP(RemoteStatusBar) + EXECOMP(ExplorerMenuBand) + EXECOMP(ExplorerAddressBand) + EXECOMP(ExplorerToolbarBand) + EXECOMP(ExplorerSelectionBand) + EXECOMP(ExplorerSessionBand) + EXECOMP(ExplorerPreferencesBand) + EXECOMP(ExplorerSortBand) + EXECOMP(ExplorerUpdatesBand) + EXECOMP(ExplorerTransferBand) + EXECOMP(ExplorerCustomCommandsBand) + EXECOMP(CommanderMenuBand) + EXECOMP(CommanderSessionBand) + EXECOMP(CommanderPreferencesBand) + EXECOMP(CommanderSortBand) + EXECOMP(CommanderCommandsBand) + EXECOMP(CommanderUpdatesBand) + EXECOMP(CommanderTransferBand) + EXECOMP(CommanderCustomCommandsBand) + EXECOMP(CommanderLocalHistoryBand) + EXECOMP(CommanderLocalNavigationBand) + EXECOMP(CommanderLocalFileBand) + EXECOMP(CommanderLocalSelectionBand) + EXECOMP(CommanderRemoteHistoryBand) + EXECOMP(CommanderRemoteNavigationBand) + EXECOMP(CommanderRemoteFileBand) + EXECOMP(CommanderRemoteSelectionBand) + EXECOMP(CommandLinePanel) + EXECOMP(RemoteTree) + EXECOMP(LocalTree) + EXE(GoToCommandLineAction, ScpExplorer->GoToCommandLine()) + EXE(GoToTreeAction, ScpExplorer->GoToTree()) + + EXE(ViewLogAction, WinConfiguration->LogView = + (WinConfiguration->LogView == lvNone ? lvWindow : lvNone) ) + EXE(ShowHiddenFilesAction, ScpExplorer->ToggleShowHiddenFiles()) + EXE(FormatSizeBytesNoneAction, ScpExplorer->SetFormatSizeBytes(fbNone)) + EXE(FormatSizeBytesKilobytesAction, ScpExplorer->SetFormatSizeBytes(fbKilobytes)) + EXE(FormatSizeBytesShortAction, ScpExplorer->SetFormatSizeBytes(fbShort)) + EXE(AutoReadDirectoryAfterOpAction, ScpExplorer->ToggleAutoReadDirectoryAfterOp()) + EXE(PreferencesAction, PreferencesDialog(::pmDefault) ) + EXE(PresetsPreferencesAction, PreferencesDialog(pmPresets) ) + EXE(LockToolbarsAction, WinConfiguration->LockToolbars = !WinConfiguration->LockToolbars) + EXE(SelectiveToolbarTextAction, WinConfiguration->SelectiveToolbarText = !WinConfiguration->SelectiveToolbarText) + EXECOMP(CustomCommandsBand) + EXE(ColorMenuAction, CreateSessionColorMenu(ColorMenuAction)); + + #define COLVIEWPROPS ((TCustomDirViewColProperties*)(((TCustomDirView*)(((TListColumns*)(ListColumn->Collection))->Owner()))->ColProperties)) + // SORT + EXESORTA(Local) + EXESORT(Local, dv, Name) + EXESORT(Local, dv, Ext) + EXESORT(Local, dv, Size) + EXESORT(Local, dv, Type) + EXESORT(Local, dv, Changed) + EXESORT(Local, dv, Attr) + EXESORTA(Remote) + EXESORT(Remote, uv, Name) + EXESORT(Remote, uv, Ext) + EXESORT(Remote, uv, Size) + EXESORT(Remote, uv, Changed) + EXESORT(Remote, uv, Rights) + EXESORT(Remote, uv, Owner) + EXESORT(Remote, uv, Group) + EXESORT(Remote, uv, Type) + EXESORTA(Current) + EXESORTC(Name, dvName, uvName) + EXESORTC(Ext, dvExt, uvExt) + EXESORTC(Size, dvSize, uvSize) + EXESORTC(Type, dvType, uvType) + EXESORTC(Changed, dvChanged, uvChanged) + EXESORTC(Rights, dvAttr, uvRights) + EXESORTC(Owner, dvName, uvOwner) + EXESORTC(Group, dvName, uvGroup) + EXE(SortColumnAscendingAction, assert(ListColumn); + COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = true; ListColumn = NULL ) + EXE(SortColumnDescendingAction, assert(ListColumn); + COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = false; ListColumn = NULL ) + + // SHOW/HIDE COLUMN + EXESHCOL(Local, dv, Name) + EXESHCOL(Local, dv, Ext) + EXESHCOL(Local, dv, Size) + EXESHCOL(Local, dv, Type) + EXESHCOL(Local, dv, Changed) + EXESHCOL(Local, dv, Attr) + EXESHCOL(Remote, uv, Name) + EXESHCOL(Remote, uv, Ext) + EXESHCOL(Remote, uv, Size) + EXESHCOL(Remote, uv, Changed) + EXESHCOL(Remote, uv, Rights) + EXESHCOL(Remote, uv, Owner) + EXESHCOL(Remote, uv, Group) + EXESHCOL(Remote, uv, LinkTarget) + EXESHCOL(Remote, uv, Type) + EXE(HideColumnAction, assert(ListColumn); + COLVIEWPROPS->Visible[ListColumn->Index] = false; ListColumn = NULL ) + EXE(BestFitColumnAction, assert(ListColumn); ListColumn = NULL ) // TODO + #undef COLVIEWPROPS + + // SESSION + EXE(NewSessionAction, ScpExplorer->NewSession(false)) + EXE(SiteManagerAction, ScpExplorer->NewSession(true)) + EXE(DuplicateSessionAction, ScpExplorer->DuplicateSession()) + EXE(CloseSessionAction, ScpExplorer->CloseSession()) + EXE(SavedSessionsAction2, CreateSessionListMenu(SavedSessionsAction2)) + EXE(WorkspacesAction, CreateWorkspacesMenu(WorkspacesAction)) + EXE(OpenedSessionsAction, CreateOpenedSessionListMenu(OpenedSessionsAction)) + EXE(SaveCurrentSessionAction2, ScpExplorer->SaveCurrentSession()) + EXE(SaveWorkspaceAction, ScpExplorer->SaveWorkspace(false)) + + // COMMAND + EXE(CompareDirectoriesAction, ScpExplorer->CompareDirectories()) + EXE(SynchronizeAction, ScpExplorer->SynchronizeDirectories()) + EXE(FullSynchronizeAction, ScpExplorer->FullSynchronizeDirectories()) + EXE(ConsoleAction, ScpExplorer->OpenConsole()) + EXE(PuttyAction, TTerminalManager::Instance()->OpenInPutty()) + EXE(SynchronizeBrowsingAction, ScpExplorer->SynchronizeBrowsingChanged()) + EXE(CloseApplicationAction, ScpExplorer->Close()) + EXE(FileSystemInfoAction, ScpExplorer->FileSystemInfo()) + EXE(SessionGenerateUrlAction, ScpExplorer->SessionGenerateUrl()) + EXE(ClearCachesAction, ScpExplorer->Terminal->ClearCaches()) + EXE(NewFileAction, ScpExplorer->EditNew(osCurrent)) + EXE(EditorListCustomizeAction, PreferencesDialog(pmEditor)) + + // CUSTOM COMMANDS + EXE(CustomCommandsAction, CreateCustomCommandsMenu(CustomCommandsAction)) + EXE(CustomCommandsEnterAction, ScpExplorer->AdHocCustomCommand(false)) + EXE(CustomCommandsEnterFocusedAction, ScpExplorer->AdHocCustomCommand(true)) + EXE(CustomCommandsLastAction, ScpExplorer->LastCustomCommand(false)) + EXE(CustomCommandsLastFocusedAction, ScpExplorer->LastCustomCommand(true)) + EXE(CustomCommandsCustomizeAction, PreferencesDialog(pmCustomCommands)) + + // QUEUE + EXE(QueueEnableAction, ScpExplorer->ToggleQueueEnabled()) + #define EXEQUEUE(OPERATION) EXE(Queue ## OPERATION ## Action, \ + ScpExplorer->ExecuteQueueOperation(qo ## OPERATION)) + EXEQUEUE(GoTo) + EXEQUEUE(Preferences) + EXEQUEUE(ItemQuery) + EXEQUEUE(ItemError) + EXEQUEUE(ItemPrompt) + EXEQUEUE(ItemDelete) + EXEQUEUE(ItemExecute) + EXEQUEUE(ItemPause) + EXEQUEUE(ItemResume) + EXEQUEUE(ItemUp) + EXEQUEUE(ItemDown) + EXEQUEUE(PauseAll) + EXEQUEUE(ResumeAll) + EXEQUEUE(DeleteAllDone) + #undef EXEQUEUE + EXE(QueueToggleShowAction, ScpExplorer->ToggleQueueVisibility()) + #define QUEUEACTION(SHOW) EXE(Queue ## SHOW ## Action, \ + TQueueViewConfiguration Config = WinConfiguration->QueueView; \ + if (Config.Show != qvShow) Config.LastHideShow = Config.Show; \ + Config.Show = qv ## SHOW; \ + WinConfiguration->QueueView = Config) + QUEUEACTION(Show) + QUEUEACTION(HideWhenEmpty) + QUEUEACTION(Hide) + #undef QUEUEACTION + EXE(QueueCycleOnceEmptyAction, CycleQueueOnceEmptyAction()); + EXE(QueueIdleOnceEmptyAction, SetQueueOnceEmptyAction(QueueIdleOnceEmptyAction)) + EXE(QueueDisconnectOnceEmptyAction, SetQueueOnceEmptyAction(QueueDisconnectOnceEmptyAction)) + EXE(QueueShutDownOnceEmptyAction, SetQueueOnceEmptyAction(QueueShutDownOnceEmptyAction)) + EXECOMP(QueueToolbar); + EXE(QueueItemSpeedAction, ) + ; } - APPLICATION_EXCEPTION_HACK_END; + + DoIdle(); } //--------------------------------------------------------------------------- void __fastcall TNonVisualDataModule::UpdateNonVisibleActions() @@ -951,11 +953,7 @@ void __fastcall TNonVisualDataModule::SetScpExplorer(TCustomScpExplorerForm * va void __fastcall TNonVisualDataModule::SessionIdleTimerTimer( TObject */*Sender*/) { - APPLICATION_EXCEPTION_HACK_BEGIN - { - DoIdle(); - } - APPLICATION_EXCEPTION_HACK_END; + DoIdle(); } //--------------------------------------------------------------------------- void __fastcall TNonVisualDataModule::DoIdle() @@ -1486,7 +1484,7 @@ void __fastcall TNonVisualDataModule::ShowUpdatesUpdate() unsigned short H, M, S, MS; DecodeTime(Now(), H, M, S, MS); int CurrentCompoundVer = Configuration->CompoundVersion; - ShowUpdatesAction->ImageIndex = + CheckForUpdatesAction->ImageIndex = ((Updates.HaveResults && (Updates.Results.ForVersion == CurrentCompoundVer) && !Updates.Results.Disabled && ((Updates.Results.Critical && !Updates.ShownResults && (MS >= 500)) || @@ -1597,7 +1595,7 @@ void __fastcall TNonVisualDataModule::CycleQueueOnceEmptyAction() } else { - assert(false); + FAIL; } } //--------------------------------------------------------------------------- @@ -1618,7 +1616,7 @@ TAction * __fastcall TNonVisualDataModule::CurrentQueueOnceEmptyAction() } else { - assert(false); + FAIL; } return Result; } @@ -1641,7 +1639,7 @@ TOnceDoneOperation __fastcall TNonVisualDataModule::CurrentQueueOnceEmptyOperati } else { - assert(false); + FAIL; } return Result; } diff --git a/source/forms/NonVisual.dfm b/source/forms/NonVisual.dfm index d15545c8..ebe025a3 100644 --- a/source/forms/NonVisual.dfm +++ b/source/forms/NonVisual.dfm @@ -102,7 +102,7 @@ object NonVisualDataModule: TNonVisualDataModule Action = FullFileListToClipboardAction end object CopyURLtoClipboard3: TTBXItem - Action = UrlToClipboardAction + Action = FileGenerateUrlAction end end object N1: TTBXSeparatorItem @@ -585,9 +585,9 @@ object NonVisualDataModule: TNonVisualDataModule 'New session|Opens new session (hold down Shift to open session i' + 'n new window)' ImageIndex = 25 - ShortCut = 16462 SecondaryShortCuts.Strings = ( 'Ctrl+Shift+N') + ShortCut = 16462 end object SiteManagerAction: TAction Tag = 15 @@ -604,9 +604,9 @@ object NonVisualDataModule: TNonVisualDataModule Caption = '&Disconnect' Hint = 'Close session|Terminate current session' ImageIndex = 26 - ShortCut = 24644 SecondaryShortCuts.Strings = ( 'Ctrl+W') + ShortCut = 24644 end object SavedSessionsAction2: TAction Tag = 15 @@ -1467,12 +1467,12 @@ object NonVisualDataModule: TNonVisualDataModule Hint = 'Toggle showing hidden files in panel(s)' ShortCut = 49224 end - object FormatSizeBytesAction: TAction + object FormatSizeBytesNoneAction: TAction Tag = 15 Category = 'View' - Caption = 'Short &Files Sizes' - HelpKeyword = 'ui_file_panel#short_format' - Hint = 'Show files sizes in short format (KiB, MiB, etc)' + Caption = '&Bytes' + HelpKeyword = 'ui_file_panel#size_format' + Hint = 'Show files sizes in bytes' end object LocalPathToClipboardAction: TAction Tag = 15 @@ -1579,12 +1579,15 @@ object NonVisualDataModule: TNonVisualDataModule Hint = 'Customize queue list' ImageIndex = 28 end - object PasteAction: TAction + object PasteAction2: TAction Tag = 15 Category = 'Command' Caption = '&Paste' HelpKeyword = 'task_upload#using_copy_amp:paste' - Hint = 'Paste files from clipboard to current directory in active panel' + Hint = + 'Paste files from clipboard to current directory in active panel;' + + ' or opens path from clipboard in active panel; or opens session ' + + 'URL from clipboard' ImageIndex = 75 ShortCut = 16470 end @@ -1624,12 +1627,12 @@ object NonVisualDataModule: TNonVisualDataModule 'rectory or another name' ImageIndex = 78 end - object UrlToClipboardAction: TAction + object FileGenerateUrlAction: TAction Tag = 15 Category = 'Selected Operation' - Caption = 'Copy &URL to Clipboard' - HelpKeyword = 'filenames#file_url' - Hint = 'Copy URL'#39's of selected file(s) to clipboard' + Caption = 'Generate &URL...' + HelpKeyword = 'ui_generateurl' + Hint = 'Generate URL'#39's of selected file(s)' end object TableOfContentsAction: TAction Tag = 12 @@ -1693,16 +1696,19 @@ object NonVisualDataModule: TNonVisualDataModule Hint = 'Configure automatic check for application updates' ImageIndex = 28 end - object ShowUpdatesAction: TAction + object FormatSizeBytesKilobytesAction: TAction Tag = 15 - Category = 'Help' - Caption = '&Show Updates' - HelpKeyword = 'updates' - Hint = - 'Shows information about application updates|Shows information ab' + - 'out application updates (queries application homepage if the inf' + - 'ormation is not available at the moment)' - ImageIndex = 81 + Category = 'View' + Caption = '&Kilobytes' + HelpKeyword = 'ui_file_panel#size_format' + Hint = 'Show files sizes in kilobytes' + end + object FormatSizeBytesShortAction: TAction + Tag = 15 + Category = 'View' + Caption = '&Short format' + HelpKeyword = 'ui_file_panel#size_format' + Hint = 'Show files sizes in short format' end object PresetsPreferencesAction: TAction Tag = 15 @@ -1893,6 +1899,7 @@ object NonVisualDataModule: TNonVisualDataModule HelpKeyword = 'ui_file_panel#filter' Hint = 'Filter|Filter displayed files' ImageIndex = 92 + ShortCut = 49222 end object RemoteFilterAction: TAction Tag = 14 @@ -1901,6 +1908,7 @@ object NonVisualDataModule: TNonVisualDataModule HelpKeyword = 'ui_file_panel#filter' Hint = 'Filter|Filter displayed files' ImageIndex = 92 + ShortCut = 49222 end object RemoteFindFilesAction: TAction Tag = 15 @@ -2087,6 +2095,12 @@ object NonVisualDataModule: TNonVisualDataModule 'Display system file context menu (in Properties you can opt to d' + 'isplay it by default instead of built-in menu)' end + object SessionGenerateUrlAction: TAction + Tag = 15 + Category = 'Session' + Caption = 'Generate &URL...' + HelpKeyword = 'ui_generateurl' + end end object ExplorerBarPopup: TTBXPopupMenu Images = GlyphsModule.ExplorerImages @@ -2415,14 +2429,27 @@ object NonVisualDataModule: TNonVisualDataModule object LocalSortByExtColumnPopupItem: TTBXItem Action = LocalSortByExtAction end - object LocalFormatSizeBytesPopupItem: TTBXItem - Action = FormatSizeBytesAction - end object Hidecolumn1: TTBXItem Action = HideColumnAction end object N37: TTBXSeparatorItem end + object LocalFormatSizeBytesPopupItem: TTBXSubmenuItem + Caption = 'Show File Si&zes In' + HelpKeyword = 'ui_file_panel#size_format' + Hint = 'Select files sizes display format' + object TBXItem64: TTBXItem + Action = FormatSizeBytesNoneAction + end + object TBXItem65: TTBXItem + Action = FormatSizeBytesKilobytesAction + end + object TBXItem66: TTBXItem + Action = FormatSizeBytesShortAction + end + end + object TBXSeparatorItem8: TTBXSeparatorItem + end object Showcolumns3: TTBXSubmenuItem Caption = 'Show &Columns' HelpKeyword = 'ui_file_panel#selecting_columns' @@ -2459,14 +2486,27 @@ object NonVisualDataModule: TNonVisualDataModule object RemoteSortByExtColumnPopupItem: TTBXItem Action = RemoteSortByExtAction end - object RemoteFormatSizeBytesPopupItem: TTBXItem - Action = FormatSizeBytesAction - end object Hidecolumn2: TTBXItem Action = HideColumnAction end object N38: TTBXSeparatorItem end + object RemoteFormatSizeBytesPopupItem: TTBXSubmenuItem + Caption = 'Show File Si&zes In' + HelpKeyword = 'ui_file_panel#size_format' + Hint = 'Select files sizes display format' + object TBXItem67: TTBXItem + Action = FormatSizeBytesNoneAction + end + object TBXItem53: TTBXItem + Action = FormatSizeBytesKilobytesAction + end + object TBXItem55: TTBXItem + Action = FormatSizeBytesShortAction + end + end + object TBXSeparatorItem7: TTBXSeparatorItem + end object Showcolumns4: TTBXSubmenuItem Caption = 'Show &Columns' HelpKeyword = 'ui_file_panel#selecting_columns' @@ -2769,6 +2809,14 @@ object NonVisualDataModule: TNonVisualDataModule object TBXItem125: TTBXItem Action = SaveCurrentSessionAction2 end + object TBXSeparatorItem6: TTBXSeparatorItem + end + object TBXItem56: TTBXItem + Action = FileSystemInfoAction + end + object TBXItem52: TTBXItem + Action = SessionGenerateUrlAction + end object TBXSeparatorItem34: TTBXSeparatorItem end object TBXItem123: TTBXItem @@ -2837,7 +2885,7 @@ object NonVisualDataModule: TNonVisualDataModule Action = FullFileListToClipboardAction end object TBXItem62: TTBXItem - Action = UrlToClipboardAction + Action = FileGenerateUrlAction end end object TBXSeparatorItem4: TTBXSeparatorItem diff --git a/source/forms/NonVisual.h b/source/forms/NonVisual.h index c332e21c..af15c7fd 100644 --- a/source/forms/NonVisual.h +++ b/source/forms/NonVisual.h @@ -19,6 +19,7 @@ #include "TBXExtItems.hpp" #include #include "TBXToolPals.hpp" +#include //--------------------------------------------------------------------------- #define fcStatusBar 0x01 #define fcToolBar2 0x02 @@ -212,7 +213,7 @@ class TNonVisualDataModule : public TDataModule TAction *RemoteMoveToFocusedAction; TAction *SelectOneAction; TAction *ShowHiddenFilesAction; - TAction *FormatSizeBytesAction; + TAction *FormatSizeBytesNoneAction; TAction *CommandLinePanelAction; TAction *LocalPathToClipboardAction; TAction *RemotePathToClipboardAction; @@ -234,14 +235,14 @@ class TNonVisualDataModule : public TDataModule TAction *QueueHideAction; TAction *QueueToolbarAction; TAction *QueuePreferencesAction; - TAction *PasteAction; + TAction *PasteAction2; TAction *RemoteTreeAction; TAction *LocalTreeAction; TAction *GoToTreeAction; TAction *NewFileAction; TAction *RemoteCopyToFocusedAction; TAction *RemoteCopyToAction; - TAction *UrlToClipboardAction; + TAction *FileGenerateUrlAction; TAction *TableOfContentsAction; TTBXPopupMenu *CommanderBarPopup; TTBXItem *SessionButtons5; @@ -407,9 +408,8 @@ class TNonVisualDataModule : public TDataModule TTBXItem *Customize5; TTBXItem *Tree4; TTBXItem *RemoteSortByExtColumnPopupItem; - TTBXItem *RemoteFormatSizeBytesPopupItem; + TTBXItem *TBXItem67; TTBXItem *LocalSortByExtColumnPopupItem; - TTBXItem *LocalFormatSizeBytesPopupItem; TAction *FileListFromClipboardAction; TAction *ShowHideRemoteLinkTargetColumnAction; TTBXItem *TBXItem1; @@ -417,7 +417,6 @@ class TNonVisualDataModule : public TDataModule TAction *CommanderUpdatesBandAction; TTBXItem *TBXItem2; TAction *UpdatesPreferencesAction; - TAction *ShowUpdatesAction; TAction *ExplorerUpdatesBandAction; TTBXItem *TBXItem3; TAction *ExplorerTransferBandAction; @@ -571,6 +570,21 @@ class TNonVisualDataModule : public TDataModule TAction *CurrentSystemMenuFocusedAction; TTBXItem *TBXItem51; TTBXSeparatorItem *TBXSeparatorItem5; + TTBXSeparatorItem *TBXSeparatorItem6; + TTBXItem *TBXItem56; + TAction *SessionGenerateUrlAction; + TTBXItem *TBXItem52; + TAction *FormatSizeBytesKilobytesAction; + TAction *FormatSizeBytesShortAction; + TTBXSubmenuItem *RemoteFormatSizeBytesPopupItem; + TTBXItem *TBXItem53; + TTBXItem *TBXItem55; + TTBXSeparatorItem *TBXSeparatorItem7; + TTBXSeparatorItem *TBXSeparatorItem8; + TTBXSubmenuItem *LocalFormatSizeBytesPopupItem; + TTBXItem *TBXItem64; + TTBXItem *TBXItem65; + TTBXItem *TBXItem66; void __fastcall LogActionsUpdate(TBasicAction *Action, bool &Handled); void __fastcall LogActionsExecute(TBasicAction *Action, bool &Handled); void __fastcall ExplorerActionsUpdate(TBasicAction *Action, bool &Handled); diff --git a/source/forms/OpenDirectory.cpp b/source/forms/OpenDirectory.cpp index c2c33b95..2d7652eb 100644 --- a/source/forms/OpenDirectory.cpp +++ b/source/forms/OpenDirectory.cpp @@ -268,7 +268,7 @@ typename T * GetBookmarkObject(TObject * Sender, T * SessionObject, T * SharedOb { case 1: return SessionObject; case 2: return SharedObject; - default: assert(false); return NULL; + default: FAIL; return NULL; } } //--------------------------------------------------------------------------- diff --git a/source/forms/Preferences.cpp b/source/forms/Preferences.cpp index 5b3c8cb4..149563ba 100644 --- a/source/forms/Preferences.cpp +++ b/source/forms/Preferences.cpp @@ -205,7 +205,6 @@ void __fastcall TPreferencesDialog::LoadConfiguration() BOOLPROP(DDTransferConfirmation); BOOLPROP(DDWarnLackOfTempSpace); BOOLPROP(ShowHiddenFiles); - BOOLPROP(FormatSizeBytes); BOOLPROP(RenameWholeName); BOOLPROP(ShowInaccesibleDirectories); BOOLPROP(CopyOnDoubleClickConfirmation); @@ -413,6 +412,7 @@ void __fastcall TPreferencesDialog::LoadConfiguration() PathInCaptionNoneButton->Checked = true; } BOOLPROP(MinimizeToTray); + BOOLPROP(ExternalSessionInExistingInstance); // panels DoubleClickActionCombo->ItemIndex = WinConfiguration->DoubleClickAction; @@ -421,6 +421,21 @@ void __fastcall TPreferencesDialog::LoadConfiguration() RefreshRemotePanelIntervalEdit->Value = int(static_cast(WinConfiguration->RefreshRemotePanelInterval) * SecsPerDay); + switch (WinConfiguration->FormatSizeBytes) + { + case fbNone: + FormatSizeBytesCombo->ItemIndex = 0; + break; + case fbKilobytes: + FormatSizeBytesCombo->ItemIndex = 1; + break; + case fbShort: + FormatSizeBytesCombo->ItemIndex = 2; + break; + default: + FAIL; + } + // updates TUpdatesConfiguration Updates = WinConfiguration->Updates; if (int(Updates.Period) <= 0) @@ -440,6 +455,8 @@ void __fastcall TPreferencesDialog::LoadConfiguration() UpdatesPeriodCombo->ItemIndex = 3; } + UpdatesShowOnStartup->Checked = Updates.ShowOnStartup; + CollectUsageCheck->Checked = Configuration->CollectUsage; ComboAutoSwitchLoad(UpdatesBetaVersionsCombo, Updates.BetaVersions); @@ -567,7 +584,6 @@ void __fastcall TPreferencesDialog::SaveConfiguration() BOOLPROP(DeleteToRecycleBin); BOOLPROP(DDWarnLackOfTempSpace); BOOLPROP(ShowHiddenFiles); - BOOLPROP(FormatSizeBytes); BOOLPROP(RenameWholeName); BOOLPROP(ShowInaccesibleDirectories); BOOLPROP(CopyOnDoubleClickConfirmation); @@ -756,6 +772,7 @@ void __fastcall TPreferencesDialog::SaveConfiguration() WinConfiguration->PathInCaption = picNone; } BOOLPROP(MinimizeToTray); + BOOLPROP(ExternalSessionInExistingInstance); // panels WinConfiguration->DoubleClickAction = (TDoubleClickAction)DoubleClickActionCombo->ItemIndex; @@ -764,6 +781,21 @@ void __fastcall TPreferencesDialog::SaveConfiguration() WinConfiguration->RefreshRemotePanelInterval = static_cast(RefreshRemotePanelIntervalEdit->Value / SecsPerDay); + switch (FormatSizeBytesCombo->ItemIndex) + { + case 0: + WinConfiguration->FormatSizeBytes = fbNone; + break; + case 1: + WinConfiguration->FormatSizeBytes = fbKilobytes; + break; + case 2: + WinConfiguration->FormatSizeBytes = fbShort; + break; + default: + FAIL; + } + // updates TUpdatesConfiguration Updates = WinConfiguration->Updates; if (UpdatesPeriodCombo->ItemIndex == 0) @@ -783,6 +815,8 @@ void __fastcall TPreferencesDialog::SaveConfiguration() Updates.Period = 30; } + Updates.ShowOnStartup = UpdatesShowOnStartup->Checked; + Configuration->CollectUsage = CollectUsageCheck->Checked; Updates.BetaVersions = ComboAutoSwitchSave(UpdatesBetaVersionsCombo); @@ -947,7 +981,7 @@ void __fastcall TPreferencesDialog::UpdateControls() EnableControl(BeepOnFinishAfterText, BeepOnFinishCheck->Checked); EnableControl(ResumeThresholdEdit, ResumeSmartButton->Checked); - EnableControl(ResumeThresholdUnitLabel, ResumeThresholdEdit->Enabled); + EnableControl(ResumeThresholdUnitLabel2, ResumeThresholdEdit->Enabled); EnableControl(SessionReopenAutoEdit, SessionReopenAutoCheck->Checked); EnableControl(SessionReopenAutoLabel, SessionReopenAutoEdit->Enabled); EnableControl(SessionReopenAutoSecLabel, SessionReopenAutoEdit->Enabled); @@ -1029,8 +1063,8 @@ void __fastcall TPreferencesDialog::UpdateControls() // as that would destroy the stored configuration EnableControl(StorageGroup, RegistryStorageButton->Checked || IniFileStorageButton2->Checked); IniFileStorageButton2->Caption = - AnsiReplaceStr(IniFileStorageButton2->Caption, L"winscp.ini", - ExpandEnvironmentVariables(Configuration->IniFileStorageName)); + AnsiReplaceStr(IniFileStorageButton2->Caption, L"(winscp.ini)", + FORMAT(L"(%s)", (ExpandEnvironmentVariables(Configuration->IniFileStorageName)))); EditorFontLabel->WordWrap = EditorWordWrapCheck->Checked; bool EditorSelected = (EditorListView3->Selected != NULL); @@ -1350,7 +1384,7 @@ TListViewScrollOnDragOver * __fastcall TPreferencesDialog::ScrollOnDragOver(TObj } else { - assert(false); + FAIL; return NULL; } } @@ -1968,7 +2002,7 @@ void __fastcall TPreferencesDialog::MasterPasswordChanged( { // Save master password. // This is unlikely to fail, as storage is written explicitly already - // when writting the recrypted passwords + // when writing the recrypted passwords Configuration->SaveExplicit(); TQueryType QueryType = qtInformation; @@ -2035,18 +2069,10 @@ void __fastcall TPreferencesDialog::SetMasterPasswordButtonClick( //--------------------------------------------------------------------------- void __fastcall TPreferencesDialog::UsageViewButtonClick(TObject * /*Sender*/) { - TStrings * Data = new TStringList(); - try - { - Data->Text = GetUsageData(); - UnicodeString Message = - Data->Text.IsEmpty() ? MainInstructions(LoadStr(USAGE_DATA_NONE)) : LoadStr(USAGE_DATA2); - MoreMessageDialog(Message, Data, qtInformation, qaOK, HELP_USAGE); - } - __finally - { - delete Data; - } + std::unique_ptr Data(TextToStringList(GetUsageData())); + UnicodeString Message = + Data->Text.IsEmpty() ? MainInstructions(LoadStr(USAGE_DATA_NONE)) : LoadStr(USAGE_DATA2); + MoreMessageDialog(Message, Data.get(), qtInformation, qaOK, HELP_USAGE); } //--------------------------------------------------------------------------- void __fastcall TPreferencesDialog::CopyParamLabelClick(TObject * /*Sender*/) diff --git a/source/forms/Preferences.dfm b/source/forms/Preferences.dfm index f0b1b345..6ae1906b 100644 --- a/source/forms/Preferences.dfm +++ b/source/forms/Preferences.dfm @@ -814,13 +814,22 @@ object PreferencesDialog: TPreferencesDialog Left = 8 Top = 8 Width = 389 - Height = 195 + Height = 171 Anchors = [akLeft, akTop, akRight] Caption = 'Common' TabOrder = 0 DesignSize = ( 389 - 195) + 171) + object Label1: TLabel + Left = 16 + Top = 143 + Width = 84 + Height = 13 + Caption = 'Show file si&zes in:' + FocusControl = FormatSizeBytesCombo + OnClick = ControlChange + end object ShowHiddenFilesCheck: TCheckBox Left = 16 Top = 21 @@ -832,69 +841,64 @@ object PreferencesDialog: TPreferencesDialog OnClick = ControlChange end object DefaultDirIsHomeCheck: TCheckBox - Left = 16 - Top = 69 - Width = 357 - Height = 17 - Anchors = [akLeft, akTop, akRight] - Caption = 'Default directory is &home directory' - TabOrder = 2 - OnClick = ControlChange - end - object DeleteToRecycleBinCheck: TCheckBox Left = 16 Top = 45 Width = 357 Height = 17 Anchors = [akLeft, akTop, akRight] - Caption = '&Delete local files to recycle bin' + Caption = 'Default directory is &home directory' TabOrder = 1 OnClick = ControlChange end object PreservePanelStateCheck: TCheckBox Left = 16 - Top = 93 + Top = 69 Width = 357 Height = 17 Anchors = [akLeft, akTop, akRight] Caption = '&Remember panels'#39' state when switching sessions' - TabOrder = 3 + TabOrder = 2 OnClick = ControlChange end object RenameWholeNameCheck: TCheckBox Left = 16 - Top = 117 + Top = 93 Width = 357 Height = 17 Anchors = [akLeft, akTop, akRight] Caption = 'Select &whole name when renaming file' - TabOrder = 4 - OnClick = ControlChange - end - object FormatSizeBytesCheck: TCheckBox - Left = 16 - Top = 141 - Width = 357 - Height = 17 - Anchors = [akLeft, akTop, akRight] - Caption = 'Show file sizes in short &format' - TabOrder = 5 + TabOrder = 3 OnClick = ControlChange end object FullRowSelectCheck: TCheckBox Left = 16 - Top = 165 + Top = 117 Width = 357 Height = 17 Anchors = [akLeft, akTop, akRight] Caption = '&Full row select' - TabOrder = 6 + TabOrder = 4 OnClick = ControlChange end + object FormatSizeBytesCombo: TComboBox + Left = 264 + Top = 140 + Width = 108 + Height = 21 + Style = csDropDownList + Anchors = [akTop, akRight] + MaxLength = 1 + TabOrder = 5 + OnChange = ControlChange + Items.Strings = ( + 'Bytes' + 'Kilobytes' + 'Short format') + end end object DoubleClickGroup: TGroupBox Left = 8 - Top = 208 + Top = 184 Width = 389 Height = 74 Anchors = [akLeft, akTop, akRight] @@ -1997,12 +2001,12 @@ object PreferencesDialog: TPreferencesDialog Anchors = [akLeft, akTop, akRight] Caption = 'Enable transfer resume/transfer to temporary filename for' TabOrder = 0 - object ResumeThresholdUnitLabel: TLabel + object ResumeThresholdUnitLabel2: TLabel Left = 136 Top = 71 - Width = 14 + Width = 12 Height = 13 - Caption = 'KiB' + Caption = 'KB' FocusControl = ResumeThresholdEdit end object ResumeOnButton: TRadioButton @@ -2211,13 +2215,13 @@ object PreferencesDialog: TPreferencesDialog Left = 8 Top = 8 Width = 389 - Height = 51 + Height = 81 Anchors = [akLeft, akTop, akRight] Caption = 'Automatic check for application updates' TabOrder = 0 DesignSize = ( 389 - 51) + 81) object Label12: TLabel Left = 16 Top = 23 @@ -2240,10 +2244,20 @@ object PreferencesDialog: TPreferencesDialog 'Weekly' 'Monthly') end + object UpdatesShowOnStartup: TCheckBox + Left = 16 + Top = 49 + Width = 262 + Height = 17 + Anchors = [akLeft, akTop, akRight] + Caption = '&Display information about update on startup' + TabOrder = 1 + OnClick = ControlChange + end end object UpdatesProxyGroup: TGroupBox Left = 8 - Top = 152 + Top = 182 Width = 389 Height = 142 Anchors = [akLeft, akTop, akRight] @@ -2324,7 +2338,7 @@ object PreferencesDialog: TPreferencesDialog end object UpdatesOptionsGroup: TGroupBox Left = 8 - Top = 65 + Top = 95 Width = 389 Height = 81 Anchors = [akLeft, akTop, akRight] @@ -2565,13 +2579,13 @@ object PreferencesDialog: TPreferencesDialog Left = 8 Top = 231 Width = 389 - Height = 53 + Height = 77 Anchors = [akLeft, akTop, akRight] Caption = 'Miscellaneous' TabOrder = 2 DesignSize = ( 389 - 53) + 77) object MinimizeToTrayCheck: TCheckBox Left = 16 Top = 21 @@ -2582,6 +2596,16 @@ object PreferencesDialog: TPreferencesDialog TabOrder = 0 OnClick = ControlChange end + object ExternalSessionInExistingInstanceCheck: TCheckBox + Left = 16 + Top = 45 + Width = 361 + Height = 17 + Anchors = [akLeft, akTop, akRight] + Caption = 'Open new externally initiated sessions in &existing window' + TabOrder = 1 + OnClick = ControlChange + end end object WorkspacesGroup: TGroupBox Left = 8 @@ -2964,31 +2988,41 @@ object PreferencesDialog: TPreferencesDialog Left = 8 Top = 8 Width = 389 - Height = 75 + Height = 99 Anchors = [akLeft, akTop, akRight] Caption = 'Local panel' TabOrder = 0 DesignSize = ( 389 - 75) + 99) object PreserveLocalDirectoryCheck: TCheckBox Left = 16 - Top = 21 + Top = 45 Width = 357 Height = 17 Anchors = [akLeft, akTop, akRight] Caption = 'Do not &change state when switching sessions' - TabOrder = 0 + TabOrder = 1 OnClick = ControlChange end object SystemContextMenuCheck: TCheckBox Left = 16 - Top = 44 + Top = 69 Width = 357 Height = 17 Anchors = [akLeft, akTop, akRight] Caption = 'Use &system file context menu' - TabOrder = 1 + TabOrder = 2 + OnClick = ControlChange + end + object DeleteToRecycleBinCheck: TCheckBox + Left = 16 + Top = 21 + Width = 357 + Height = 17 + Anchors = [akLeft, akTop, akRight] + Caption = '&Delete files to recycle bin' + TabOrder = 0 OnClick = ControlChange end end diff --git a/source/forms/Preferences.h b/source/forms/Preferences.h index b6aed248..1b52cbdc 100644 --- a/source/forms/Preferences.h +++ b/source/forms/Preferences.h @@ -113,7 +113,7 @@ class TPreferencesDialog : public TForm TLabel *BeepOnFinishAfterText; TTabSheet *TransferEnduranceSheet; TGroupBox *ResumeBox; - TLabel *ResumeThresholdUnitLabel; + TLabel *ResumeThresholdUnitLabel2; TRadioButton *ResumeOnButton; TRadioButton *ResumeSmartButton; TRadioButton *ResumeOffButton; @@ -217,7 +217,6 @@ class TPreferencesDialog : public TForm TRadioButton *RetrieveExternalIpAddressButton; TRadioButton *CustomExternalIpAddressButton; TEdit *CustomExternalIpAddressEdit; - TCheckBox *FormatSizeBytesCheck; TCheckBox *SessionReopenAutoStallCheck; TLabel *SessionReopenAutoStallLabel; TUpDownEdit *SessionReopenAutoStallEdit; @@ -292,6 +291,10 @@ class TPreferencesDialog : public TForm TMenuItem *RegisterAsUrlHandlerItem; TMenuItem *UnregisterForDefaultProtocolsItem; TMenuItem *MakeDefaultHandlerItem; + TLabel *Label1; + TComboBox *FormatSizeBytesCombo; + TCheckBox *UpdatesShowOnStartup; + TCheckBox *ExternalSessionInExistingInstanceCheck; void __fastcall FormShow(TObject *Sender); void __fastcall ControlChange(TObject *Sender); void __fastcall EditorFontButtonClick(TObject *Sender); diff --git a/source/forms/Progress.cpp b/source/forms/Progress.cpp index d40cdcdf..a4fb2eee 100644 --- a/source/forms/Progress.cpp +++ b/source/forms/Progress.cpp @@ -41,7 +41,7 @@ UnicodeString __fastcall TProgressForm::OperationName(TFileOperation Operation, return LoadStr(Id); } //--------------------------------------------------------------------- -__fastcall TProgressForm::TProgressForm(TComponent* AOwner) +__fastcall TProgressForm::TProgressForm(TComponent * AOwner, bool AllowMoveToQueue) : FData(), TForm(AOwner) { FLastOperation = foNone; @@ -51,6 +51,7 @@ __fastcall TProgressForm::TProgressForm(TComponent* AOwner) FAsciiTransferChanged = false; FResumeStatusChanged = false; FCancel = csContinue; + FMoveToQueue = false; FMinimizedByMe = false; FUpdateCounter = 0; FLastUpdate = 0; @@ -61,6 +62,7 @@ __fastcall TProgressForm::TProgressForm(TComponent* AOwner) FModalBeginHooked = false; FPrevApplicationModalBegin = NULL; FModalLevel = -1; + FAllowMoveToQueue = AllowMoveToQueue; UseSystemSettings(this); ResetOnceDoneOperation(); @@ -76,6 +78,10 @@ __fastcall TProgressForm::TProgressForm(TComponent* AOwner) } SetGlobalMinimizeHandler(this, GlobalMinimize); + if (FAllowMoveToQueue) + { + MenuButton(MinimizeButton); + } } //--------------------------------------------------------------------------- __fastcall TProgressForm::~TProgressForm() @@ -87,7 +93,9 @@ __fastcall TProgressForm::~TProgressForm() if (IsApplicationMinimized() && FMinimizedByMe) { - ShowNotification(NULL, LoadStr(BALLOON_OPERATION_COMPLETE), qtInformation); + ShowNotification( + NULL, MainInstructions(LoadStr(BALLOON_OPERATION_COMPLETE)), + qtInformation); } if (FModalBeginHooked) @@ -126,6 +134,7 @@ void __fastcall TProgressForm::UpdateControls() { THandle ShellModule; AVisible = true; + TProgressBarStyle Style = pbstNormal; switch (FData.Operation) { case foCopy: case foMove: @@ -156,13 +165,19 @@ void __fastcall TProgressForm::UpdateControls() Animate->Active = true; break; + case foCalculateSize: + Animate->CommonAVI = aviNone; + AVisible = false; + Style = pbstMarquee; + break; + default: assert(FData.Operation == foCustomCommand || - FData.Operation == foCalculateSize || FData.Operation == foCalculateChecksum); Animate->CommonAVI = aviNone; AVisible = false; } + TopProgress->Style = Style; } catch (...) { @@ -195,8 +210,6 @@ void __fastcall TProgressForm::UpdateControls() ClientHeight = ClientHeight + Delta; - Caption = OperationName(FData.Operation, FData.Side); - TargetLabel->Visible = TransferOperation; TargetPathLabel->Visible = TransferOperation; TargetPathLabel->UnixPath = (FData.Side == osLocal); @@ -227,7 +240,7 @@ void __fastcall TProgressForm::UpdateControls() int OverallProgress = FData.OverallProgress(); FOperationProgress->Position = OverallProgress; FOperationProgress->Hint = FORMAT(L"%d%%", (OverallProgress)); - Caption = FORMAT(L"%d%% %s", (OverallProgress, OperationName(FData.Operation, FData.Side))); + Caption = FormatFormCaption(this, FORMAT(L"%d%% %s", (OverallProgress, OperationName(FData.Operation, FData.Side)))); if (TransferOperation) { @@ -321,7 +334,7 @@ void __fastcall TProgressForm::SetProgressData(TFileOperationProgressType & ADat TDateTime N = Now(); bool InstantUpdate = false; - // workaround: to force displaing first file data immediatelly, + // workaround: to force displaing first file data immediately, // otherwise form dialog uses to be blank for first second // (until UpdateTimerTimer) if (FileLabel->Caption.IsEmpty() && !AData.FileName.IsEmpty()) @@ -418,10 +431,27 @@ void __fastcall TProgressForm::CancelButtonClick(TObject * /*Sender*/) } //--------------------------------------------------------------------------- void __fastcall TProgressForm::MinimizeButtonClick(TObject * Sender) +{ + if (FAllowMoveToQueue) + { + MenuPopup(MinimizeMenu, MinimizeButton); + } + else + { + Minimize(Sender); + } +} +//--------------------------------------------------------------------------- +void __fastcall TProgressForm::Minimize(TObject * Sender) { CallGlobalMinimizeHandler(Sender); } //--------------------------------------------------------------------------- +void __fastcall TProgressForm::MinimizeMenuItemClick(TObject * Sender) +{ + Minimize(Sender); +} +//--------------------------------------------------------------------------- void __fastcall TProgressForm::CancelOperation() { assert(FDataReceived); @@ -433,26 +463,32 @@ void __fastcall TProgressForm::CancelOperation() try { TCancelStatus ACancel; - int Result; if (FData.TransferingFile && (FData.TimeExpected() > GUIConfiguration->IgnoreCancelBeforeFinish)) { - Result = MessageDialog(LoadStr(CANCEL_OPERATION_FATAL2), qtWarning, + int Result = MessageDialog(LoadStr(CANCEL_OPERATION_FATAL2), qtWarning, qaYes | qaNo | qaCancel, HELP_PROGRESS_CANCEL); + switch (Result) + { + case qaYes: + ACancel = csCancelTransfer; break; + case qaNo: + ACancel = csCancel; break; + default: + ACancel = csContinue; break; + } } else { - Result = MessageDialog(LoadStr(CANCEL_OPERATION2), qtConfirmation, - qaOK | qaCancel, HELP_PROGRESS_CANCEL); - } - switch (Result) { - case qaYes: - ACancel = csCancelTransfer; break; - case qaOK: - case qaNo: - ACancel = csCancel; break; - default: - ACancel = csContinue; break; + int Result = MessageDialog(LoadStr(CANCEL_OPERATION2), qtConfirmation, + qaYes | qaNo, HELP_PROGRESS_CANCEL); + switch (Result) + { + case qaYes: + ACancel = csCancel; break; + default: + ACancel = csContinue; break; + } } if (FCancel < ACancel) @@ -491,7 +527,7 @@ void __fastcall TProgressForm::SetOnceDoneOperation(TOnceDoneOperation value) break; default: - assert(false); + FAIL; } OnceDoneOperationCombo->ItemIndex = Index; OnceDoneOperationComboSelect(NULL); @@ -583,7 +619,7 @@ void __fastcall TProgressForm::OnceDoneOperationComboSelect(TObject * /*Sender*/ break; default: - assert(false); + FAIL; } } //--------------------------------------------------------------------------- @@ -592,4 +628,21 @@ void __fastcall TProgressForm::OnceDoneOperationComboCloseUp(TObject * /*Sender* CancelButton->SetFocus(); } //--------------------------------------------------------------------------- -#pragma warn -8080 +void __fastcall TProgressForm::Dispatch(void * AMessage) +{ + TMessage & Message = *reinterpret_cast(AMessage); + if (Message.Msg == WM_CLOSE) + { + CancelOperation(); + } + else + { + TForm::Dispatch(AMessage); + } +} +//--------------------------------------------------------------------------- +void __fastcall TProgressForm::MoveToQueueMenuItemClick(TObject * /*Sender*/) +{ + FMoveToQueue = true; +} +//--------------------------------------------------------------------------- diff --git a/source/forms/Progress.dfm b/source/forms/Progress.dfm index 771699ce..7c23c1ac 100644 --- a/source/forms/Progress.dfm +++ b/source/forms/Progress.dfm @@ -7,7 +7,7 @@ object ProgressForm: TProgressForm BorderStyle = bsDialog Caption = 'Operation' ClientHeight = 196 - ClientWidth = 405 + ClientWidth = 425 Color = clBtnFace ParentFont = True OldCreateOrder = False @@ -15,7 +15,7 @@ object ProgressForm: TProgressForm OnHide = FormHide OnShow = FormShow DesignSize = ( - 405 + 425 196) PixelsPerInch = 96 TextHeight = 13 @@ -24,6 +24,7 @@ object ProgressForm: TProgressForm Top = 88 Width = 69 Height = 13 + Anchors = [akTop, akRight] Caption = 'Once &finished:' FocusControl = OnceDoneOperationCombo end @@ -39,7 +40,7 @@ object ProgressForm: TProgressForm object CancelButton: TButton Left = 320 Top = 8 - Width = 80 + Width = 100 Height = 25 Anchors = [akTop, akRight] Cancel = True @@ -50,7 +51,7 @@ object ProgressForm: TProgressForm object MinimizeButton: TButton Left = 320 Top = 40 - Width = 80 + Width = 100 Height = 25 Anchors = [akTop, akRight] Caption = '&Minimize' @@ -118,13 +119,13 @@ object ProgressForm: TProgressForm object TransferPanel: TPanel Left = 10 Top = 133 - Width = 301 + Width = 321 Height = 63 Anchors = [akLeft, akTop, akRight] BevelOuter = bvNone TabOrder = 4 DesignSize = ( - 301 + 321 63) object StartTimeLabel: TLabel Left = 88 @@ -159,7 +160,7 @@ object ProgressForm: TProgressForm Alignment = taRightJustify Anchors = [akTop, akRight] AutoSize = False - Caption = '0 KiB/s' + Caption = '0 KB/s' end object TimeElapsedLabel: TLabel Left = 236 @@ -178,7 +179,7 @@ object ProgressForm: TProgressForm Height = 13 Alignment = taRightJustify AutoSize = False - Caption = '0 KiB' + Caption = '0 KB' end object Label3: TLabel Left = 164 @@ -224,25 +225,29 @@ object ProgressForm: TProgressForm object SpeedPanel: TPanel Left = 314 Top = 151 - Width = 92 + Width = 112 Height = 41 Anchors = [akTop, akRight] BevelOuter = bvNone TabOrder = 6 - object SpeedLabel2: TLabel + DesignSize = ( + 112 + 41) + object SpeedLabel3: TLabel Left = 8 Top = 0 - Width = 68 + Width = 66 Height = 13 - Caption = '&Speed (KiB/s):' + Caption = '&Speed (KB/s):' FocusControl = SpeedCombo end object SpeedCombo: THistoryComboBox Left = 6 Top = 16 - Width = 80 + Width = 100 Height = 21 AutoComplete = False + Anchors = [akLeft, akTop, akRight] TabOrder = 0 Text = 'SpeedCombo' OnExit = SpeedComboExit @@ -263,10 +268,11 @@ object ProgressForm: TProgressForm object OnceDoneOperationCombo: TComboBox Left = 320 Top = 104 - Width = 80 + Width = 100 Height = 21 AutoComplete = False Style = csDropDownList + Anchors = [akTop, akRight] TabOrder = 5 OnCloseUp = OnceDoneOperationComboCloseUp OnSelect = OnceDoneOperationComboSelect @@ -281,4 +287,16 @@ object ProgressForm: TProgressForm Left = 336 Top = 168 end + object MinimizeMenu: TPopupMenu + Left = 384 + Top = 48 + object MoveToQueueMenuItem: TMenuItem + Caption = 'Proceed in &Background' + OnClick = MoveToQueueMenuItemClick + end + object MinimizeMenuItem: TMenuItem + Caption = '&Minimize' + OnClick = MinimizeMenuItemClick + end + end end diff --git a/source/forms/Progress.h b/source/forms/Progress.h index 18691d7a..68b89b55 100644 --- a/source/forms/Progress.h +++ b/source/forms/Progress.h @@ -11,6 +11,7 @@ #include //---------------------------------------------------------------------------- #include +#include //---------------------------------------------------------------------------- class TProgressForm : public TForm { @@ -36,12 +37,15 @@ class TProgressForm : public TForm TProgressBar *BottomProgress; TTimer *UpdateTimer; TPanel *SpeedPanel; - TLabel *SpeedLabel2; + TLabel *SpeedLabel3; TLabel *TimeLeftLabelLabel; TLabel *TimeLeftLabel; THistoryComboBox *SpeedCombo; TLabel *OnceDoneOperationLabel; TComboBox *OnceDoneOperationCombo; + TPopupMenu *MinimizeMenu; + TMenuItem *MoveToQueueMenuItem; + TMenuItem *MinimizeMenuItem; void __fastcall UpdateTimerTimer(TObject *Sender); void __fastcall FormShow(TObject *Sender); void __fastcall FormHide(TObject *Sender); @@ -52,9 +56,12 @@ class TProgressForm : public TForm void __fastcall SpeedComboKeyPress(TObject *Sender, wchar_t &Key); void __fastcall OnceDoneOperationComboSelect(TObject *Sender); void __fastcall OnceDoneOperationComboCloseUp(TObject *Sender); + void __fastcall MinimizeMenuItemClick(TObject *Sender); + void __fastcall MoveToQueueMenuItemClick(TObject *Sender); private: TCancelStatus FCancel; + bool FMoveToQueue; TFileOperationProgressType FData; bool FDataGot; bool FDataReceived; @@ -77,6 +84,7 @@ class TProgressForm : public TForm bool FModalBeginHooked; TNotifyEvent FPrevApplicationModalBegin; int FModalLevel; + bool FAllowMoveToQueue; void __fastcall SetOnceDoneOperation(TOnceDoneOperation value); void __fastcall SetAllowMinimize(bool value); @@ -91,14 +99,17 @@ class TProgressForm : public TForm void __fastcall ApplyCPSLimit(); void __fastcall ResetOnceDoneOperation(); bool __fastcall ReceiveData(bool Force, int ModalLevelOffset); + void __fastcall Minimize(TObject * Sender); + virtual void __fastcall Dispatch(void * Message); public: static UnicodeString __fastcall OperationName(TFileOperation Operation, TOperationSide Side); + virtual __fastcall TProgressForm(TComponent * AOwner, bool AllowMoveToQueue); virtual __fastcall ~TProgressForm(); void __fastcall SetProgressData(TFileOperationProgressType & AData); - virtual __fastcall TProgressForm(TComponent * AOwner); __property TCancelStatus Cancel = { read = FCancel }; + __property bool MoveToQueue = { read = FMoveToQueue }; __property TOnceDoneOperation OnceDoneOperation = { read=FOnceDoneOperation, write=SetOnceDoneOperation }; __property bool AllowMinimize = { read=GetAllowMinimize, write=SetAllowMinimize }; __property bool DeleteToRecycleBin = { read=FDeleteToRecycleBin, write=FDeleteToRecycleBin }; diff --git a/source/forms/Properties.cpp b/source/forms/Properties.cpp index f62fc9d1..9c449acd 100644 --- a/source/forms/Properties.cpp +++ b/source/forms/Properties.cpp @@ -291,7 +291,7 @@ void __fastcall TPropertiesDialog::LoadStats(__int64 FilesSize, else { SizeStr = FormatBytes(FilesSize); - UnicodeString SizeUnorderedStr = FormatBytes(FilesSize, false); + UnicodeString SizeUnorderedStr = FormatBytes(FilesSize, fbNone); if (SizeStr != SizeUnorderedStr) { SizeStr = FORMAT(L"%s (%s)", (SizeStr, SizeUnorderedStr)); @@ -481,12 +481,16 @@ void __fastcall TPropertiesDialog::ControlChange(TObject * /*Sender*/) //--------------------------------------------------------------------------- void __fastcall TPropertiesDialog::UpdateControls() { + // No point enabling recursive check if there's no change allowed (supported), + // i.e. with WebDAV. + EnableControl(RecursiveCheck, ((FAllowedChanges & (cpGroup | cpOwner | cpMode)) != 0)); + bool Allow; try { Allow = !TRemoteProperties::ChangedProperties(FOrigProperties, GetFileProperties()).Valid.Empty() || - RecursiveCheck->Checked; + (RecursiveCheck->Enabled && RecursiveCheck->Checked); } catch(...) { diff --git a/source/forms/RemoteTransfer.dfm b/source/forms/RemoteTransfer.dfm index a93cc75a..aa74c8eb 100644 --- a/source/forms/RemoteTransfer.dfm +++ b/source/forms/RemoteTransfer.dfm @@ -7,7 +7,7 @@ object RemoteTransferDialog: TRemoteTransferDialog BorderStyle = bsDialog Caption = 'RemoteTransferDialog' ClientHeight = 179 - ClientWidth = 368 + ClientWidth = 420 Color = clBtnFace ParentFont = True OldCreateOrder = False @@ -15,19 +15,19 @@ object RemoteTransferDialog: TRemoteTransferDialog OnCloseQuery = FormCloseQuery OnShow = FormShow DesignSize = ( - 368 + 420 179) PixelsPerInch = 96 TextHeight = 13 object SymlinkGroup: TGroupBox Left = 8 Top = 6 - Width = 352 + Width = 404 Height = 131 Anchors = [akLeft, akTop, akRight, akBottom] TabOrder = 0 DesignSize = ( - 352 + 404 131) object SessionLabel: TLabel Left = 49 @@ -37,12 +37,12 @@ object RemoteTransferDialog: TRemoteTransferDialog Caption = 'Target &session:' FocusControl = SessionCombo end - object Label2: TLabel + object Label3: TLabel Left = 49 Top = 60 - Width = 119 + Width = 98 Height = 13 - Caption = 'Target remote &directory:' + Caption = 'Target remote &path:' FocusControl = DirectoryEdit end object Image: TImage @@ -95,7 +95,7 @@ object RemoteTransferDialog: TRemoteTransferDialog object SessionCombo: TComboBox Left = 49 Top = 28 - Width = 292 + Width = 344 Height = 21 Style = csDropDownList Anchors = [akLeft, akTop, akRight] @@ -107,7 +107,7 @@ object RemoteTransferDialog: TRemoteTransferDialog object DirectoryEdit: THistoryComboBox Left = 49 Top = 76 - Width = 292 + Width = 344 Height = 21 AutoComplete = False Anchors = [akLeft, akTop, akRight] @@ -118,7 +118,7 @@ object RemoteTransferDialog: TRemoteTransferDialog object NotDirectCopyCheck: TCheckBox Left = 55 Top = 105 - Width = 288 + Width = 340 Height = 17 Anchors = [akLeft, akTop, akRight] Caption = 'Duplicate via local &temporary copy' @@ -127,7 +127,7 @@ object RemoteTransferDialog: TRemoteTransferDialog end end object OkButton: TButton - Left = 116 + Left = 168 Top = 146 Width = 75 Height = 25 @@ -138,7 +138,7 @@ object RemoteTransferDialog: TRemoteTransferDialog TabOrder = 1 end object CancelButton: TButton - Left = 200 + Left = 252 Top = 146 Width = 75 Height = 25 @@ -149,7 +149,7 @@ object RemoteTransferDialog: TRemoteTransferDialog TabOrder = 2 end object HelpButton: TButton - Left = 284 + Left = 336 Top = 146 Width = 75 Height = 25 diff --git a/source/forms/RemoteTransfer.h b/source/forms/RemoteTransfer.h index f0efc464..3b923a2e 100644 --- a/source/forms/RemoteTransfer.h +++ b/source/forms/RemoteTransfer.h @@ -15,7 +15,7 @@ class TRemoteTransferDialog : public TForm __published: TGroupBox *SymlinkGroup; TLabel *SessionLabel; - TLabel *Label2; + TLabel *Label3; TComboBox *SessionCombo; THistoryComboBox *DirectoryEdit; TButton *OkButton; diff --git a/source/forms/Rights.cpp b/source/forms/Rights.cpp index 7fc8793a..dbbcfc82 100644 --- a/source/forms/Rights.cpp +++ b/source/forms/Rights.cpp @@ -140,7 +140,7 @@ bool __fastcall TRightsFrame::GetAllowUndef() } else if (Result != Check->AllowGrayed) { - assert(false); + FAIL; } } } @@ -320,11 +320,11 @@ void __fastcall TRightsFrame::RightsActionsExecute(TBasicAction * Action, else if (Action == PasteAction) { UnicodeString S; - if (TextFromClipboard(S)) + if (TextFromClipboard(S, true)) { Text = S; } - // trigger on change event, even if no change actually occured to + // trigger on change event, even if no change actually occurred to // allow parent form to visualize feedback of an action DoChange(); Changed = false; diff --git a/source/forms/ScpCommander.cpp b/source/forms/ScpCommander.cpp index 4070b118..582ba130 100644 --- a/source/forms/ScpCommander.cpp +++ b/source/forms/ScpCommander.cpp @@ -293,7 +293,7 @@ bool __fastcall TScpCommanderForm::InternalDDDownload(UnicodeString & TargetDire } else { - assert(false); + FAIL; Abort(); } @@ -881,7 +881,7 @@ void __fastcall TScpCommanderForm::LocalDirViewExecFile(TObject *Sender, { assert(Item); if ((UpperCase(PFileRec(Item->Data)->FileExt) == L"LNK") && - DirectoryExists(ResolveFileShortCut(LocalDirView->ItemFullFileName(Item), true))) + DirectoryExists(::ApiPath(ResolveFileShortCut(LocalDirView->ItemFullFileName(Item), true)))) { AllowExec = true; } @@ -909,7 +909,7 @@ bool __fastcall TScpCommanderForm::PanelOperation(TOperationSide Side, } //--------------------------------------------------------------------------- void __fastcall TScpCommanderForm::FileOperationProgress( - TFileOperationProgressType & ProgressData, TCancelStatus & Cancel) + TFileOperationProgressType & ProgressData) { // Heuristic: When operation finishes and DD targed is local dir view, // we suppose that drag&drop download finished, so local dir view should be @@ -920,7 +920,7 @@ void __fastcall TScpCommanderForm::FileOperationProgress( { ReloadLocalDirectory(); } - TCustomScpExplorerForm::FileOperationProgress(ProgressData, Cancel); + TCustomScpExplorerForm::FileOperationProgress(ProgressData); } //--------------------------------------------------------------------------- UnicodeString __fastcall TScpCommanderForm::ChangeFilePath(UnicodeString Path, TOperationSide Side) @@ -1012,7 +1012,7 @@ void __fastcall TScpCommanderForm::SynchronizeBrowsingRemote( UnicodeString NewLocalPath; NewPath = ExcludeTrailingBackslash(LocalDirView->Path); - while (!UnixComparePaths(PrevPath, CommonPath)) + while (!UnixSamePath(PrevPath, CommonPath)) { NewLocalPath = ExcludeTrailingBackslash(ExtractFileDir(NewPath)); if (NewLocalPath == NewPath) @@ -1549,7 +1549,7 @@ void __fastcall TScpCommanderForm::GoToTree() //--------------------------------------------------------------------------- void __fastcall TScpCommanderForm::PanelExportStore(TOperationSide Side, TPanelExport Export, TPanelExportDestination Destination, - TStringList * ExportData) + TStrings * ExportData) { if (Destination == pedCommandLine) { @@ -1673,7 +1673,7 @@ void __fastcall TScpCommanderForm::LocalPathLabelPathClick( void __fastcall TScpCommanderForm::RemotePathLabelPathClick( TCustomPathLabel * /*Sender*/, UnicodeString Path) { - if (UnixComparePaths(Path, RemoteDirView->Path)) + if (UnixSamePath(Path, RemoteDirView->Path)) { OpenDirectory(osRemote); } @@ -1696,13 +1696,13 @@ void __fastcall TScpCommanderForm::LocalDirViewFileIconForName( void __fastcall TScpCommanderForm::LocalDirViewUpdateStatusBar( TObject * /*Sender*/, const TStatusFileInfo & FileInfo) { - UpdateFileStatusBar(LocalStatusBar, FileInfo, 0); + UpdateFileStatusBar(LocalStatusBar, FileInfo); } //--------------------------------------------------------------------------- void __fastcall TScpCommanderForm::RemoteDirViewUpdateStatusBar( TObject * /*Sender*/, const TStatusFileInfo & FileInfo) { - UpdateFileStatusBar(RemoteStatusBar, FileInfo, 0); + UpdateFileStatusBar(RemoteStatusBar, FileInfo); } //--------------------------------------------------------------------------- void __fastcall TScpCommanderForm::LocalStatusBarClick(TObject * /*Sender*/) @@ -2041,3 +2041,15 @@ void __fastcall TScpCommanderForm::DisplaySystemContextMenu() } } //--------------------------------------------------------------------------- +void __fastcall TScpCommanderForm::LocalStatusBarPanelClick(TTBXCustomStatusBar * /*Sender*/, + TTBXStatusPanel * Panel) +{ + FileStatusBarPanelClick(Panel, osLocal); +} +//--------------------------------------------------------------------------- +void __fastcall TScpCommanderForm::RemoteStatusBarPanelClick(TTBXCustomStatusBar * /*Sender*/, + TTBXStatusPanel *Panel) +{ + FileStatusBarPanelClick(Panel, osRemote); +} +//--------------------------------------------------------------------------- diff --git a/source/forms/ScpCommander.dfm b/source/forms/ScpCommander.dfm index 09ae694c..27a3b9b7 100644 --- a/source/forms/ScpCommander.dfm +++ b/source/forms/ScpCommander.dfm @@ -232,7 +232,7 @@ inherited ScpCommanderForm: TScpCommanderForm Action = NonVisualDataModule.CurrentRenameAction end object TBXItem36: TTBXItem - Action = NonVisualDataModule.PasteAction + Action = NonVisualDataModule.PasteAction2 end object TBXSeparatorItem8: TTBXSeparatorItem end @@ -253,7 +253,7 @@ inherited ScpCommanderForm: TScpCommanderForm Action = NonVisualDataModule.FullFileListToClipboardAction end object TBXItem40: TTBXItem - Action = NonVisualDataModule.UrlToClipboardAction + Action = NonVisualDataModule.FileGenerateUrlAction end end object TBXSeparatorItem9: TTBXSeparatorItem @@ -357,9 +357,6 @@ inherited ScpCommanderForm: TScpCommanderForm end object TBXSeparatorItem14: TTBXSeparatorItem end - object TBXItem56: TTBXItem - Action = NonVisualDataModule.FileSystemInfoAction - end object TBXItem57: TTBXItem Action = NonVisualDataModule.ClearCachesAction end @@ -385,6 +382,14 @@ inherited ScpCommanderForm: TScpCommanderForm object TBXItem114: TTBXItem Action = NonVisualDataModule.SaveCurrentSessionAction2 end + object TBXSeparatorItem50: TTBXSeparatorItem + end + object TBXItem56: TTBXItem + Action = NonVisualDataModule.FileSystemInfoAction + end + object TBXItem135: TTBXItem + Action = NonVisualDataModule.SessionGenerateUrlAction + end object TBXSeparatorItem29: TTBXSeparatorItem end object TBXSubmenuItem21: TTBXSubmenuItem @@ -884,10 +889,11 @@ inherited ScpCommanderForm: TScpCommanderForm ShowHint = True TabOrder = 5 object TBXSubmenuItem1: TTBXSubmenuItem - Action = NonVisualDataModule.ShowUpdatesAction + Action = NonVisualDataModule.CheckForUpdatesAction DropdownCombo = True object TBXItem184: TTBXItem Action = NonVisualDataModule.CheckForUpdatesAction + Options = [tboDefault] end object TBXSeparatorItem46: TTBXSeparatorItem end @@ -997,7 +1003,35 @@ inherited ScpCommanderForm: TScpCommanderForm inherited RemoteStatusBar: TTBXStatusBar Top = 279 Width = 429 - SimplePanel = True + Panels = < + item + Framed = False + Size = 170 + StretchPriority = 1 + Tag = 0 + TextTruncation = twEndEllipsis + end + item + Alignment = taCenter + Framed = False + Hint = 'Click to show hidden files' + MaxSize = 100 + Size = 80 + StretchPriority = 2 + Tag = 0 + TextTruncation = twEndEllipsis + end + item + Alignment = taCenter + Framed = False + Hint = 'Click to modify or clear the filter' + MaxSize = 100 + Size = 80 + StretchPriority = 2 + Tag = 0 + TextTruncation = twEndEllipsis + end> + OnPanelClick = RemoteStatusBarPanelClick end inherited RemoteDirView: TUnixDirView Left = 0 @@ -1256,12 +1290,39 @@ inherited ScpCommanderForm: TScpCommanderForm Top = 279 Width = 395 Height = 19 - Panels = <> + Panels = < + item + Framed = False + Size = 170 + StretchPriority = 1 + Tag = 0 + TextTruncation = twEndEllipsis + end + item + Alignment = taCenter + Framed = False + Hint = 'Click to show hidden files' + MaxSize = 100 + Size = 80 + StretchPriority = 2 + Tag = 0 + TextTruncation = twEndEllipsis + end + item + Alignment = taCenter + Framed = False + Hint = 'Click to modify or clear the filter' + MaxSize = 100 + Size = 80 + StretchPriority = 2 + Tag = 0 + TextTruncation = twEndEllipsis + end> ParentShowHint = False - SimplePanel = True ShowHint = True UseSystemFont = False OnClick = LocalStatusBarClick + OnPanelClick = LocalStatusBarPanelClick end object LocalDirView: TDirView Left = 0 diff --git a/source/forms/ScpCommander.h b/source/forms/ScpCommander.h index b6736e12..619b1e90 100644 --- a/source/forms/ScpCommander.h +++ b/source/forms/ScpCommander.h @@ -166,7 +166,6 @@ class TScpCommanderForm : public TCustomScpExplorerForm TTBXItem *TBXItem54; TTBXItem *TBXItem55; TTBXSeparatorItem *TBXSeparatorItem14; - TTBXItem *TBXItem56; TTBXItem *TBXItem57; TTBXSeparatorItem *TBXSeparatorItem15; TTBXItem *TBXItem58; @@ -398,6 +397,9 @@ class TScpCommanderForm : public TCustomScpExplorerForm TPanel *QueueSeparatorPanel; TTBXSeparatorItem *TBXSeparatorItem39; TTBXItem *TBXItem134; + TTBXItem *TBXItem56; + TTBXSeparatorItem *TBXSeparatorItem50; + TTBXItem *TBXItem135; void __fastcall SplitterMoved(TObject *Sender); void __fastcall SplitterCanResize(TObject *Sender, int &NewSize, bool &Accept); @@ -453,6 +455,8 @@ class TScpCommanderForm : public TCustomScpExplorerForm void __fastcall DirViewHistoryGo(TCustomDirView *Sender, int Index, bool &Cancel); void __fastcall LocalDirViewContextPopup(TObject *Sender, TPoint &MousePos, bool &Handled); + void __fastcall LocalStatusBarPanelClick(TTBXCustomStatusBar *Sender, TTBXStatusPanel *Panel); + void __fastcall RemoteStatusBarPanelClick(TTBXCustomStatusBar *Sender, TTBXStatusPanel *Panel); private: bool FConstructed; @@ -499,7 +503,7 @@ class TScpCommanderForm : public TCustomScpExplorerForm virtual bool __fastcall GetHasDirView(TOperationSide Side); virtual void __fastcall UpdateControls(); virtual void __fastcall FileOperationProgress( - TFileOperationProgressType & ProgressData, TCancelStatus & Cancel); + TFileOperationProgressType & ProgressData); virtual void __fastcall DoOpenDirectoryDialog(TOpenDirectoryMode Mode, TOperationSide Side); bool __fastcall InternalDDDownload(UnicodeString & TargetDirectory); @@ -510,7 +514,7 @@ class TScpCommanderForm : public TCustomScpExplorerForm bool __fastcall ExecuteCommandLine(); virtual void __fastcall PanelExportStore(TOperationSide Side, TPanelExport Export, TPanelExportDestination Destination, - TStringList * ExportData); + TStrings * ExportData); void __fastcall CommandLinePopulate(); virtual int __fastcall GetStaticComponentsHeight(); DYNAMIC void __fastcall Resize(); diff --git a/source/forms/ScpExplorer.cpp b/source/forms/ScpExplorer.cpp index 8765e696..dfcba313 100644 --- a/source/forms/ScpExplorer.cpp +++ b/source/forms/ScpExplorer.cpp @@ -249,6 +249,7 @@ void __fastcall TScpExplorerForm::RemoteDirViewUpdateStatusBar( // if there's no note to cancel, we need to update status bar explicitly UpdateStatusBar(); } + UpdateFileStatusExtendedPanels(RemoteStatusBar, FileInfo); } //--------------------------------------------------------------------------- void __fastcall TScpExplorerForm::RemotePanelSplitterDblClick(TObject * /*Sender*/) @@ -329,7 +330,7 @@ void __fastcall TScpExplorerForm::QueueSubmenuItemPopup( //--------------------------------------------------------------------------- void __fastcall TScpExplorerForm::ChangePath(TOperationSide /*Side*/) { - assert(false); + FAIL; } //--------------------------------------------------------------------------- bool __fastcall TScpExplorerForm::UpdateToolbarDisplayMode() @@ -343,3 +344,9 @@ bool __fastcall TScpExplorerForm::UpdateToolbarDisplayMode() return Result; } //--------------------------------------------------------------------------- +void __fastcall TScpExplorerForm::RemoteStatusBarPanelClick(TTBXCustomStatusBar * /*Sender*/, + TTBXStatusPanel *Panel) +{ + FileStatusBarPanelClick(Panel, osRemote); +} +//--------------------------------------------------------------------------- diff --git a/source/forms/ScpExplorer.dfm b/source/forms/ScpExplorer.dfm index 3f385ca9..0ade8e31 100644 --- a/source/forms/ScpExplorer.dfm +++ b/source/forms/ScpExplorer.dfm @@ -85,7 +85,7 @@ inherited ScpExplorerForm: TScpExplorerForm Action = NonVisualDataModule.RemoteMoveToAction end object TBXItem36: TTBXItem - Action = NonVisualDataModule.PasteAction + Action = NonVisualDataModule.PasteAction2 end object TBXSeparatorItem9: TTBXSeparatorItem end @@ -103,7 +103,7 @@ inherited ScpExplorerForm: TScpExplorerForm Action = NonVisualDataModule.FullFileListToClipboardAction end object TBXItem40: TTBXItem - Action = NonVisualDataModule.UrlToClipboardAction + Action = NonVisualDataModule.FileGenerateUrlAction end end object TBXSeparatorItem1: TTBXSeparatorItem @@ -212,9 +212,6 @@ inherited ScpExplorerForm: TScpExplorerForm end object TBXSeparatorItem14: TTBXSeparatorItem end - object TBXItem56: TTBXItem - Action = NonVisualDataModule.FileSystemInfoAction - end object TBXItem57: TTBXItem Action = NonVisualDataModule.ClearCachesAction end @@ -261,6 +258,14 @@ inherited ScpExplorerForm: TScpExplorerForm object TBXItem114: TTBXItem Action = NonVisualDataModule.SaveCurrentSessionAction2 end + object TBXSeparatorItem37: TTBXSeparatorItem + end + object TBXItem56: TTBXItem + Action = NonVisualDataModule.FileSystemInfoAction + end + object TBXItem144: TTBXItem + Action = NonVisualDataModule.SessionGenerateUrlAction + end object TBXSeparatorItem29: TTBXSeparatorItem end object TBXSubmenuItem21: TTBXSubmenuItem @@ -844,10 +849,11 @@ inherited ScpExplorerForm: TScpExplorerForm ShowHint = True TabOrder = 7 object TBXSubmenuItem4: TTBXSubmenuItem - Action = NonVisualDataModule.ShowUpdatesAction + Action = NonVisualDataModule.CheckForUpdatesAction DropdownCombo = True object TBXItem184: TTBXItem Action = NonVisualDataModule.CheckForUpdatesAction + Options = [tboDefault] end object TBXSeparatorItem46: TTBXSeparatorItem end @@ -940,11 +946,25 @@ inherited ScpExplorerForm: TScpExplorerForm Images = GlyphsModule.SessionImages Panels = < item - Size = 100 + Size = 170 StretchPriority = 1 Tag = 0 TextTruncation = twEndEllipsis end + item + Alignment = taCenter + Hint = 'Click to show hidden files' + Size = 100 + Tag = 0 + TextTruncation = twEndEllipsis + end + item + Alignment = taCenter + Hint = 'Click to modify or clear the filter' + Size = 100 + Tag = 0 + TextTruncation = twEndEllipsis + end item Alignment = taCenter ImageIndex = 1 @@ -975,6 +995,7 @@ inherited ScpExplorerForm: TScpExplorerForm Tag = 0 TextTruncation = twEndEllipsis end> + OnPanelClick = RemoteStatusBarPanelClick OnPanelDblClick = StatusBarPanelDblClick end inherited RemoteDirView: TUnixDirView diff --git a/source/forms/ScpExplorer.h b/source/forms/ScpExplorer.h index 24f23be9..6d7aea80 100644 --- a/source/forms/ScpExplorer.h +++ b/source/forms/ScpExplorer.h @@ -81,7 +81,6 @@ class TScpExplorerForm : public TCustomScpExplorerForm TTBXItem *TBXItem54; TTBXItem *TBXItem55; TTBXSeparatorItem *TBXSeparatorItem14; - TTBXItem *TBXItem56; TTBXItem *TBXItem57; TTBXSubmenuItem *TBXSubmenuItem19; TTBXItem *TBXItem113; @@ -293,6 +292,9 @@ class TScpExplorerForm : public TCustomScpExplorerForm TTBXSeparatorItem *TBXSeparatorItem27; TTBXItem *TBXItem143; TTBXSeparatorItem *TBXSeparatorItem35; + TTBXItem *TBXItem56; + TTBXSeparatorItem *TBXSeparatorItem37; + TTBXItem *TBXItem144; void __fastcall RemoteDirViewUpdateStatusBar(TObject *Sender, const TStatusFileInfo &FileInfo); void __fastcall UnixPathComboBoxBeginEdit(TTBEditItem *Sender, @@ -302,6 +304,8 @@ class TScpExplorerForm : public TCustomScpExplorerForm void __fastcall RemoteDirViewPathChange(TCustomDirView *Sender); void __fastcall QueueSubmenuItemPopup(TTBCustomItem *Sender, bool FromLink); + void __fastcall RemoteStatusBarPanelClick(TTBXCustomStatusBar *Sender, TTBXStatusPanel *Panel); + private: UnicodeString FStatusBarFileText; diff --git a/source/forms/SelectMask.cpp b/source/forms/SelectMask.cpp index a53fb54a..7f30f838 100644 --- a/source/forms/SelectMask.cpp +++ b/source/forms/SelectMask.cpp @@ -28,6 +28,7 @@ bool __fastcall DoSelectMaskDialog(TCustomDirView * Parent, bool Select, CenterFormOn(Dialog, Parent); Dialog->Init(Select ? TSelectMaskDialog::smSelect : TSelectMaskDialog::smDeselect); DefaultFileFilter(*Filter); + TWinConfiguration * WinConfiguration = NOT_NULL(dynamic_cast(Configuration)); Filter->Masks = WinConfiguration->SelectMask; Filter->Directories = WinConfiguration->SelectDirectories; Dialog->FileFilter = *Filter; diff --git a/source/forms/SiteAdvanced.cpp b/source/forms/SiteAdvanced.cpp index ef063bef..46a1ec86 100644 --- a/source/forms/SiteAdvanced.cpp +++ b/source/forms/SiteAdvanced.cpp @@ -72,6 +72,7 @@ void __fastcall TSiteAdvancedDialog::InitControls() ComboAutoSwitchInitialize(BugRekey2Combo); ComboAutoSwitchInitialize(BugMaxPkt2Combo); ComboAutoSwitchInitialize(BugIgnore2Combo); + ComboAutoSwitchInitialize(BugWinAdjCombo); ComboAutoSwitchInitialize(SFTPBugSymlinkCombo); ComboAutoSwitchInitialize(SFTPBugSignedTSCombo); @@ -368,6 +369,7 @@ void __fastcall TSiteAdvancedDialog::LoadSession() LOAD_BUG_COMBO(Rekey2); LOAD_BUG_COMBO(MaxPkt2); LOAD_BUG_COMBO(Ignore2); + LOAD_BUG_COMBO(WinAdj); #undef LOAD_BUG_COMBO // Tunnel page @@ -393,6 +395,9 @@ void __fastcall TSiteAdvancedDialog::LoadSession() MaxTlsVersionCombo->ItemIndex = TlsVersionToIndex(FSessionData->MaxTlsVersion); SslSessionReuseCheck->Checked = FSessionData->SslSessionReuse; + // Note page + NoteMemo->Lines->Text = FSessionData->Note; + // color SetSessionColor((TColor)FSessionData->Color); } @@ -616,6 +621,7 @@ void __fastcall TSiteAdvancedDialog::SaveSession() SAVE_BUG_COMBO(Rekey2); SAVE_BUG_COMBO(MaxPkt2); SAVE_BUG_COMBO(Ignore2); + SAVE_BUG_COMBO(WinAdj); #undef SAVE_BUG_COMBO // Tunnel page @@ -639,6 +645,9 @@ void __fastcall TSiteAdvancedDialog::SaveSession() FSessionData->MaxTlsVersion = IndexToTlsVersion(MaxTlsVersionCombo->ItemIndex); FSessionData->SslSessionReuse = SslSessionReuseCheck->Checked; + // Note page + FSessionData->Note = NoteMemo->Lines->Text; + // color FSessionData->Color = FColor; } @@ -834,8 +843,12 @@ void __fastcall TSiteAdvancedDialog::UpdateControls() EnableControl(BugMaxPkt2Label, BugMaxPkt2Combo->Enabled); EnableControl(BugIgnore2Combo, !SshProt1onlyButton->Checked); EnableControl(BugIgnore2Label, BugIgnore2Combo->Enabled); + EnableControl(BugWinAdjCombo, !SshProt1onlyButton->Checked); + EnableControl(BugWinAdjLabel, BugWinAdjCombo->Enabled); // connection/proxy sheet + // this is probaqbly overkill, now we do not allow changing protocol on + // the same window as changing proxy TComboBox * ProxyMethodCombo = (SshProtocol ? SshProxyMethodCombo : (FtpProtocol ? FtpProxyMethodCombo : WebDavProxyMethodCombo)); TProxyMethod ProxyMethod = GetProxyMethod(); @@ -912,6 +925,7 @@ void __fastcall TSiteAdvancedDialog::UpdateControls() // environment/directories sheet EnableControl(SynchronizeBrowsingCheck, + (CustomWinConfiguration->Interface == ifCommander) && WinConfiguration->PreservePanelState && !WinConfiguration->ScpCommander.PreserveLocalDirectory); EnableControl(CacheDirectoryChangesCheck, @@ -978,6 +992,8 @@ void __fastcall TSiteAdvancedDialog::UpdateControls() // connection/ssl/tls SslSheet->Enabled = Ssl; + // TLS/SSL session reuse is not configurable for WebDAV yet + SslSessionReuseCheck->Enabled = SslSheet->Enabled && FtpProtocol; UpdateNavigationTree(); @@ -1364,7 +1380,7 @@ void __fastcall TSiteAdvancedDialog::ProxyLocalCommandBrowseButtonClick( //--------------------------------------------------------------------------- void __fastcall TSiteAdvancedDialog::ColorButtonClick(TObject * /*Sender*/) { - // popup menu has to survive the popup as TBX calls click handler asynchronously (post) + // Popup menu has to survive the popup as TBX calls click handler asynchronously (post). FColorPopupMenu.reset(CreateSessionColorPopupMenu(FColor, SessionColorChange)); MenuPopup(FColorPopupMenu.get(), ColorButton); } @@ -1448,3 +1464,26 @@ void __fastcall TSiteAdvancedDialog::MaxTlsVersionComboChange(TObject * /*Sender } } //--------------------------------------------------------------------------- +void __fastcall TSiteAdvancedDialog::ProxyAutodetectButtonClick(TObject * /*Sender*/) +{ + TInstantOperationVisualizer Visualizer; + UnicodeString Proxy; + if (AutodetectProxyUrl(Proxy) && !Proxy.IsEmpty()) + { + ProxyHostEdit->Text = ::CutToChar(Proxy, L':', true); + ProxyPortEdit->AsInteger = StrToIntDef(Proxy, ProxyPortNumber); + + SshProxyMethodCombo->ItemIndex = pmHTTP; + FtpProxyMethodCombo->ItemIndex = pmHTTP; + WebDavProxyMethodCombo->ItemIndex = pmHTTP; + + UpdateControls(); + } +} +//--------------------------------------------------------------------------- +void __fastcall TSiteAdvancedDialog::NoteMemoKeyDown( + TObject * Sender, WORD & Key, TShiftState Shift) +{ + MemoKeyDown(Sender, Key, Shift); +} +//--------------------------------------------------------------------------- diff --git a/source/forms/SiteAdvanced.dfm b/source/forms/SiteAdvanced.dfm index 7cb766f4..b59121de 100644 --- a/source/forms/SiteAdvanced.dfm +++ b/source/forms/SiteAdvanced.dfm @@ -349,16 +349,16 @@ object SiteAdvancedDialog: TSiteAdvancedDialog Left = 0 Top = 6 Width = 393 - Height = 114 + Height = 116 Anchors = [akLeft, akTop, akRight] Caption = 'Recycle bin' TabOrder = 0 DesignSize = ( 393 - 114) + 116) object RecycleBinPathLabel: TLabel Left = 12 - Top = 64 + Top = 66 Width = 95 Height = 13 Caption = '&Remote recycle bin:' @@ -386,7 +386,7 @@ object SiteAdvancedDialog: TSiteAdvancedDialog end object RecycleBinPathEdit: TEdit Left = 12 - Top = 81 + Top = 83 Width = 370 Height = 21 Anchors = [akLeft, akTop, akRight] @@ -1075,13 +1075,13 @@ object SiteAdvancedDialog: TSiteAdvancedDialog Left = 0 Top = 6 Width = 393 - Height = 136 + Height = 164 Anchors = [akLeft, akTop, akRight] Caption = 'Proxy' TabOrder = 0 DesignSize = ( 393 - 136) + 164) object ProxyMethodLabel: TLabel Left = 12 Top = 20 @@ -1222,10 +1222,19 @@ object SiteAdvancedDialog: TSiteAdvancedDialog 'SOCKS5' 'HTTP') end + object ProxyAutodetectButton: TButton + Left = 12 + Top = 129 + Width = 100 + Height = 25 + Caption = '&Autodetect' + TabOrder = 7 + OnClick = ProxyAutodetectButtonClick + end end object ProxySettingsGroup: TGroupBox Left = 0 - Top = 147 + Top = 176 Width = 393 Height = 128 Anchors = [akLeft, akTop, akRight] @@ -1407,7 +1416,7 @@ object SiteAdvancedDialog: TSiteAdvancedDialog Width = 182 Height = 21 MaxLength = 50 - TabOrder = 1 + TabOrder = 2 Text = 'TunnelUserNameEdit' OnChange = DataChange end @@ -1418,7 +1427,7 @@ object SiteAdvancedDialog: TSiteAdvancedDialog Height = 21 Anchors = [akLeft, akTop, akRight] MaxLength = 50 - TabOrder = 2 + TabOrder = 3 Text = 'TunnelPasswordEdit' OnChange = DataChange end @@ -1432,7 +1441,7 @@ object SiteAdvancedDialog: TSiteAdvancedDialog MinValue = 1.000000000000000000 Value = 1.000000000000000000 Anchors = [akTop, akRight] - TabOrder = 3 + TabOrder = 1 OnChange = DataChange end end @@ -2026,13 +2035,13 @@ object SiteAdvancedDialog: TSiteAdvancedDialog Left = 0 Top = 6 Width = 393 - Height = 265 + Height = 289 Anchors = [akLeft, akTop, akRight] Caption = 'Detection of known bugs in SSH servers' TabOrder = 0 DesignSize = ( 393 - 265) + 289) object BugIgnore1Label: TLabel Left = 12 Top = 20 @@ -2059,7 +2068,7 @@ object SiteAdvancedDialog: TSiteAdvancedDialog end object BugHMAC2Label: TLabel Left = 12 - Top = 116 + Top = 140 Width = 154 Height = 13 Caption = 'Miscomputes SSH-2 H&MAC keys:' @@ -2067,7 +2076,7 @@ object SiteAdvancedDialog: TSiteAdvancedDialog end object BugDeriveKey2Label: TLabel Left = 12 - Top = 140 + Top = 164 Width = 176 Height = 13 Caption = 'Miscomputes SSH-2 &encryption keys:' @@ -2075,7 +2084,7 @@ object SiteAdvancedDialog: TSiteAdvancedDialog end object BugRSAPad2Label: TLabel Left = 12 - Top = 164 + Top = 188 Width = 210 Height = 13 Caption = 'Requires &padding on SSH-2 RSA signatures:' @@ -2083,7 +2092,7 @@ object SiteAdvancedDialog: TSiteAdvancedDialog end object BugPKSessID2Label: TLabel Left = 12 - Top = 188 + Top = 212 Width = 195 Height = 13 Caption = 'Misuses the sessio&n ID in SSH-2 PK auth:' @@ -2091,7 +2100,7 @@ object SiteAdvancedDialog: TSiteAdvancedDialog end object BugRekey2Label: TLabel Left = 12 - Top = 212 + Top = 236 Width = 187 Height = 13 Caption = 'Handles SSH-2 &key re-exchange badly:' @@ -2099,7 +2108,7 @@ object SiteAdvancedDialog: TSiteAdvancedDialog end object BugMaxPkt2Label: TLabel Left = 12 - Top = 236 + Top = 260 Width = 176 Height = 13 Caption = 'Ignores SSH-2 ma&ximum packet size:' @@ -2113,6 +2122,14 @@ object SiteAdvancedDialog: TSiteAdvancedDialog Caption = 'Chokes on SSH-&2 ignore messages:' FocusControl = BugIgnore2Combo end + object BugWinAdjLabel: TLabel + Left = 12 + Top = 116 + Width = 212 + Height = 13 + Caption = 'Chokes on WinSCP'#39's SSH-2 '#39'winadj'#39' requests' + FocusControl = BugWinAdjCombo + end object BugIgnore1Combo: TComboBox Left = 320 Top = 15 @@ -2145,62 +2162,62 @@ object SiteAdvancedDialog: TSiteAdvancedDialog end object BugHMAC2Combo: TComboBox Left = 320 - Top = 111 + Top = 135 Width = 61 Height = 21 Style = csDropDownList Anchors = [akTop, akRight] - TabOrder = 4 + TabOrder = 5 OnChange = DataChange end object BugDeriveKey2Combo: TComboBox Left = 320 - Top = 135 + Top = 159 Width = 61 Height = 21 Style = csDropDownList Anchors = [akTop, akRight] - TabOrder = 5 + TabOrder = 6 OnChange = DataChange end object BugRSAPad2Combo: TComboBox Left = 320 - Top = 159 + Top = 183 Width = 61 Height = 21 Style = csDropDownList Anchors = [akTop, akRight] - TabOrder = 6 + TabOrder = 7 OnChange = DataChange end object BugPKSessID2Combo: TComboBox Left = 320 - Top = 183 + Top = 207 Width = 61 Height = 21 Style = csDropDownList Anchors = [akTop, akRight] - TabOrder = 7 + TabOrder = 8 OnChange = DataChange end object BugRekey2Combo: TComboBox Left = 320 - Top = 207 + Top = 231 Width = 61 Height = 21 Style = csDropDownList Anchors = [akTop, akRight] - TabOrder = 8 + TabOrder = 9 OnChange = DataChange end object BugMaxPkt2Combo: TComboBox Left = 320 - Top = 231 + Top = 255 Width = 61 Height = 21 Style = csDropDownList Anchors = [akTop, akRight] - TabOrder = 9 + TabOrder = 10 OnChange = DataChange end object BugIgnore2Combo: TComboBox @@ -2213,6 +2230,47 @@ object SiteAdvancedDialog: TSiteAdvancedDialog TabOrder = 3 OnChange = DataChange end + object BugWinAdjCombo: TComboBox + Left = 320 + Top = 111 + Width = 61 + Height = 21 + Style = csDropDownList + Anchors = [akTop, akRight] + TabOrder = 4 + OnChange = DataChange + end + end + end + object NoteSheet: TTabSheet + Caption = 'Note' + ImageIndex = 14 + TabVisible = False + DesignSize = ( + 401 + 382) + object NoteGroup: TGroupBox + Left = 0 + Top = 6 + Width = 393 + Height = 367 + Anchors = [akLeft, akTop, akRight, akBottom] + Caption = 'Note' + TabOrder = 0 + DesignSize = ( + 393 + 367) + object NoteMemo: TMemo + Left = 12 + Top = 21 + Width = 371 + Height = 332 + Anchors = [akLeft, akTop, akRight, akBottom] + MaxLength = 1000 + TabOrder = 0 + OnChange = DataChange + OnKeyDown = NoteMemoKeyDown + end end end end @@ -2245,7 +2303,7 @@ object SiteAdvancedDialog: TSiteAdvancedDialog OnChange = NavigationTreeChange OnCollapsing = NavigationTreeCollapsing Items.NodeData = { - 030300000036000000000000000000000000000000FFFFFFFF00000000000000 + 030400000036000000000000000000000000000000FFFFFFFF00000000000000 0005000000010C45006E007600690072006F006E006D0065006E007400580036 000000000000000000000000000000FFFFFFFF00000000000000000000000001 0C4400690072006500630074006F007200690065007300580036000000000000 @@ -2265,7 +2323,9 @@ object SiteAdvancedDialog: TSiteAdvancedDialog 006300680061006E006700650058003C000000000000000000000000000000FF FFFFFF000000000000000000000000010F410075007400680065006E00740069 0063006100740069006F006E00580028000000000000000000000000000000FF - FFFFFF000000000000000000000000010542007500670073005800} + FFFFFF0000000000000000000000000105420075006700730058002800000000 + 0000000000000000000000FFFFFFFF00000000000000000000000001054E006F + 00740065005800} end end end diff --git a/source/forms/SiteAdvanced.h b/source/forms/SiteAdvanced.h index cc207c4b..d14834c7 100644 --- a/source/forms/SiteAdvanced.h +++ b/source/forms/SiteAdvanced.h @@ -243,6 +243,12 @@ class TSiteAdvancedDialog : public TForm TLabel *Label2; TComboBox *MaxTlsVersionCombo; TCheckBox *SslSessionReuseCheck; + TLabel *BugWinAdjLabel; + TComboBox *BugWinAdjCombo; + TButton *ProxyAutodetectButton; + TTabSheet *NoteSheet; + TGroupBox *NoteGroup; + TMemo *NoteMemo; void __fastcall DataChange(TObject *Sender); void __fastcall FormShow(TObject *Sender); void __fastcall PageControlChange(TObject *Sender); @@ -269,6 +275,9 @@ class TSiteAdvancedDialog : public TForm void __fastcall ColorButtonClick(TObject *Sender); void __fastcall MinTlsVersionComboChange(TObject *Sender); void __fastcall MaxTlsVersionComboChange(TObject *Sender); + void __fastcall ProxyAutodetectButtonClick(TObject *Sender); + void __fastcall NoteMemoKeyDown(TObject *Sender, WORD &Key, TShiftState Shift); + public: virtual __fastcall TSiteAdvancedDialog(TComponent * AOwner, int Options); diff --git a/source/forms/Symlink.cpp b/source/forms/Symlink.cpp index 92e70314..1a003bbf 100644 --- a/source/forms/Symlink.cpp +++ b/source/forms/Symlink.cpp @@ -15,7 +15,7 @@ #endif //--------------------------------------------------------------------------- bool __fastcall DoSymlinkDialog(UnicodeString & FileName, UnicodeString & PointTo, - TOperationSide Side, bool & SymbolicLink, bool Edit, bool AllowSymbolic) + TOperationSide Side, bool & SymbolicLink, bool Edit, bool AllowHardLink) { bool Result; TSymlinkDialog * Dialog = new TSymlinkDialog(Application); @@ -26,7 +26,7 @@ bool __fastcall DoSymlinkDialog(UnicodeString & FileName, UnicodeString & PointT Dialog->Side = Side; Dialog->SymbolicLink = SymbolicLink; Dialog->Edit = Edit; - Dialog->AllowSymbolic = AllowSymbolic; + Dialog->AllowHardLink = AllowHardLink; Result = Dialog->Execute(); if (Result) { @@ -55,7 +55,7 @@ void __fastcall TSymlinkDialog::UpdateControls() FileNameEdit->Color = !Edit ? clWindow : clBtnFace; FileNameEdit->ReadOnly = Edit; FileNameEdit->TabStop = !Edit; - EnableControl(SymbolicCheck, Side == osRemote && !Edit && AllowSymbolic); + EnableControl(HardLinkCheck, (Side == osRemote) && !Edit && AllowHardLink); EnableControl(OkButton, !FileName.IsEmpty() && !PointTo.IsEmpty()); } //--------------------------------------------------------------------------- @@ -81,12 +81,12 @@ UnicodeString __fastcall TSymlinkDialog::GetPointTo() //--------------------------------------------------------------------------- void __fastcall TSymlinkDialog::SetSymbolicLink(bool value) { - SymbolicCheck->Checked = value; + HardLinkCheck->Checked = !value; } //--------------------------------------------------------------------------- bool __fastcall TSymlinkDialog::GetSymbolicLink() { - return SymbolicCheck->Checked; + return !HardLinkCheck->Checked; } //--------------------------------------------------------------------------- void __fastcall TSymlinkDialog::SetSide(TOperationSide value) @@ -106,9 +106,9 @@ void __fastcall TSymlinkDialog::ControlChange(TObject * /*Sender*/) UpdateControls(); } //--------------------------------------------------------------------------- -void __fastcall TSymlinkDialog::SetAllowSymbolic(bool value) +void __fastcall TSymlinkDialog::SetAllowHardLink(bool value) { - FAllowSymbolic = value; + FAllowHardLink = value; UpdateControls(); } //--------------------------------------------------------------------------- diff --git a/source/forms/Symlink.dfm b/source/forms/Symlink.dfm index 404a3254..7e1c5ab8 100644 --- a/source/forms/Symlink.dfm +++ b/source/forms/Symlink.dfm @@ -64,12 +64,12 @@ object SymlinkDialog: TSymlinkDialog TabOrder = 1 OnChange = ControlChange end - object SymbolicCheck: TCheckBox + object HardLinkCheck: TCheckBox Left = 17 Top = 109 Width = 238 Height = 17 - Caption = 'Sy&mbolic link' + Caption = '&Hard link' TabOrder = 2 OnClick = ControlChange end diff --git a/source/forms/Symlink.h b/source/forms/Symlink.h index b9d6abce..07b8608b 100644 --- a/source/forms/Symlink.h +++ b/source/forms/Symlink.h @@ -18,13 +18,13 @@ class TSymlinkDialog : public TForm TEdit *FileNameEdit; TLabel *Label1; TEdit *PointToEdit; - TCheckBox *SymbolicCheck; + TCheckBox *HardLinkCheck; TButton *HelpButton; void __fastcall ControlChange(TObject *Sender); void __fastcall FormShow(TObject *Sender); void __fastcall HelpButtonClick(TObject *Sender); private: - bool FAllowSymbolic; + bool FAllowHardLink; bool FEdit; TOperationSide FSide; void __fastcall SetFileName(UnicodeString value); @@ -33,13 +33,13 @@ class TSymlinkDialog : public TForm UnicodeString __fastcall GetPointTo(); void __fastcall SetSymbolicLink(bool value); bool __fastcall GetSymbolicLink(); - void __fastcall SetAllowSymbolic(bool value); + void __fastcall SetAllowHardLink(bool value); void __fastcall SetEdit(bool value); void __fastcall SetSide(TOperationSide value); public: bool __fastcall Execute(); __fastcall TSymlinkDialog(TComponent* Owner); - __property bool AllowSymbolic = { read = FAllowSymbolic, write = SetAllowSymbolic }; + __property bool AllowHardLink = { read = FAllowHardLink, write = SetAllowHardLink }; __property bool Edit = { read = FEdit, write = SetEdit }; __property UnicodeString FileName = { read = GetFileName, write = SetFileName }; __property UnicodeString PointTo = { read = GetPointTo, write = SetPointTo }; diff --git a/source/forms/Synchronize.cpp b/source/forms/Synchronize.cpp index 70fd7598..be22a895 100644 --- a/source/forms/Synchronize.cpp +++ b/source/forms/Synchronize.cpp @@ -16,6 +16,7 @@ #include #include #include +#include //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "HistoryComboBox" @@ -29,11 +30,15 @@ const int WM_USER_STOP = WM_WINSCP_USER + 2; bool __fastcall DoSynchronizeDialog(TSynchronizeParamType & Params, const TCopyParamType * CopyParams, TSynchronizeStartStopEvent OnStartStop, bool & SaveSettings, int Options, int CopyParamAttrs, - TGetSynchronizeOptionsEvent OnGetOptions, bool Start) + TGetSynchronizeOptionsEvent OnGetOptions, + TFeedSynchronizeError & OnFeedSynchronizeError, + bool Start) { bool Result; - TSynchronizeDialog * Dialog = new TSynchronizeDialog(Application, - OnStartStop, OnGetOptions, Start); + TSynchronizeDialog * Dialog = SafeFormCreate(Application); + + Dialog->Init(OnStartStop, OnGetOptions, OnFeedSynchronizeError, Start); + try { Dialog->Options = Options; @@ -58,9 +63,16 @@ bool __fastcall DoSynchronizeDialog(TSynchronizeParamType & Params, //--------------------------------------------------------------------------- const TSynchronizeDialog::MaxLogItems = 1000; //--------------------------------------------------------------------------- -__fastcall TSynchronizeDialog::TSynchronizeDialog(TComponent * Owner, - TSynchronizeStartStopEvent OnStartStop, TGetSynchronizeOptionsEvent OnGetOptions, - bool StartImmediatelly) +struct TLogItemData +{ + TSynchronizeLogEntry Entry; + UnicodeString Message; + std::unique_ptr MoreMessages; + TQueryType Type; + UnicodeString HelpKeyword; +}; +//--------------------------------------------------------------------------- +__fastcall TSynchronizeDialog::TSynchronizeDialog(TComponent * Owner) : TForm(Owner) { UseSystemSettings(this); @@ -68,10 +80,7 @@ __fastcall TSynchronizeDialog::TSynchronizeDialog(TComponent * Owner, FSynchronizing = false; FMinimizedByMe = false; FPresetsMenu = new TPopupMenu(this); - FOnStartStop = OnStartStop; - FOnGetOptions = OnGetOptions; FSynchronizeOptions = NULL; - FStartImmediatelly = StartImmediatelly; HotTrackLabel(CopyParamLabel); CopyParamListButton(TransferSettingsButton); @@ -79,6 +88,17 @@ __fastcall TSynchronizeDialog::TSynchronizeDialog(TComponent * Owner, SetGlobalMinimizeHandler(this, GlobalMinimize); } //--------------------------------------------------------------------------- +void __fastcall TSynchronizeDialog::Init(TSynchronizeStartStopEvent OnStartStop, + TGetSynchronizeOptionsEvent OnGetOptions, + TFeedSynchronizeError & OnFeedSynchronizeError, + bool StartImmediately) +{ + FOnStartStop = OnStartStop; + FOnGetOptions = OnGetOptions; + FOnFeedSynchronizeError = &OnFeedSynchronizeError; + FStartImmediately = StartImmediately; +} +//--------------------------------------------------------------------------- __fastcall TSynchronizeDialog::~TSynchronizeDialog() { // if application is closing OnCloseQuery might not get called @@ -95,6 +115,16 @@ __fastcall TSynchronizeDialog::~TSynchronizeDialog() delete FPresetsMenu; } //--------------------------------------------------------------------------- +void __fastcall TSynchronizeDialog::FeedSynchronizeError( + const UnicodeString & Message, TStrings * MoreMessages, TQueryType Type, + const UnicodeString & HelpKeyword) +{ + UnicodeString AMessage = Message; + AMessage = ReplaceStr(AMessage, L"\r", L""); + AMessage = ReplaceStr(AMessage, L"\n", L" "); + DoLogInternal(slContinuedError, AMessage, MoreMessages, Type, HelpKeyword); +} +//--------------------------------------------------------------------------- void __fastcall TSynchronizeDialog::UpdateControls() { EnableControl(StartButton, !LocalDirectoryEdit->Text.IsEmpty() && @@ -114,7 +144,7 @@ void __fastcall TSynchronizeDialog::UpdateControls() // some of the above steps hides accelerators when start button is pressed with mouse ResetSystemSettings(this); } - Caption = LoadStr(FSynchronizing ? SYNCHRONIZE_SYCHRONIZING : SYNCHRONIZE_TITLE); + Caption = FormatFormCaption(this, LoadStr(FSynchronizing ? SYNCHRONIZE_SYCHRONIZING : SYNCHRONIZE_TITLE)); EnableControl(TransferSettingsButton, !FSynchronizing); CancelButton->Visible = !FSynchronizing || FLAGSET(FOptions, soNoMinimize); EnableControl(CancelButton, !FSynchronizing); @@ -179,6 +209,7 @@ void __fastcall TSynchronizeDialog::SetParams(const TSynchronizeParamType& value SynchronizeSynchronizeCheck->State = FLAGSET(value.Options, soSynchronizeAsk) ? cbGrayed : (FLAGSET(value.Options, soSynchronize) ? cbChecked : cbUnchecked); + ContinueOnErrorCheck->Checked = FLAGSET(value.Options, soContinueOnError); } //--------------------------------------------------------------------------- TSynchronizeParamType __fastcall TSynchronizeDialog::GetParams() @@ -192,10 +223,11 @@ TSynchronizeParamType __fastcall TSynchronizeDialog::GetParams() FLAGMASK(SynchronizeExistingOnlyCheck->Checked, spExistingOnly) | FLAGMASK(SynchronizeSelectedOnlyCheck->Checked, spSelectedOnly); Result.Options = - (Result.Options & ~(soRecurse | soSynchronize | soSynchronizeAsk)) | + (Result.Options & ~(soRecurse | soSynchronize | soSynchronizeAsk | soContinueOnError)) | FLAGMASK(SynchronizeRecursiveCheck->Checked, soRecurse) | FLAGMASK(SynchronizeSynchronizeCheck->State == cbChecked, soSynchronize) | - FLAGMASK(SynchronizeSynchronizeCheck->State == cbGrayed, soSynchronizeAsk); + FLAGMASK(SynchronizeSynchronizeCheck->State == cbGrayed, soSynchronizeAsk) | + FLAGMASK(ContinueOnErrorCheck->Checked, soContinueOnError); return Result; } //--------------------------------------------------------------------------- @@ -251,19 +283,27 @@ void __fastcall TSynchronizeDialog::DoStartStop(bool Start, bool Synchronize) FLAGMASK(Synchronize, soSynchronize); if (Start) { + assert(*FOnFeedSynchronizeError == NULL); + *FOnFeedSynchronizeError = + (FLAGSET(SParams.Options, soContinueOnError) ? &FeedSynchronizeError : TFeedSynchronizeError(NULL)); delete FSynchronizeOptions; FSynchronizeOptions = new TSynchronizeOptions; FOnGetOptions(SParams.Params, *FSynchronizeOptions); } + else + { + *FOnFeedSynchronizeError = NULL; + } FOnStartStop(this, Start, SParams, CopyParams, FSynchronizeOptions, DoAbort, NULL, DoLog); } } //--------------------------------------------------------------------------- -void __fastcall TSynchronizeDialog::Dispatch(void * Message) +void __fastcall TSynchronizeDialog::Dispatch(void * AMessage) { - assert(Message); - if ((reinterpret_cast(Message)->Msg == WM_USER_STOP) && FAbort) + assert(AMessage != NULL); + TMessage & Message = *reinterpret_cast(AMessage); + if ((Message.Msg == WM_USER_STOP) && FAbort) { if (FSynchronizing) { @@ -275,9 +315,14 @@ void __fastcall TSynchronizeDialog::Dispatch(void * Message) ModalResult = mrCancel; } } + else if (Message.Msg == WM_MANAGES_CAPTION) + { + // caption managed in UpdateControls() + Message.Result = 1; + } else { - TForm::Dispatch(Message); + TForm::Dispatch(AMessage); } } //--------------------------------------------------------------------------- @@ -288,13 +333,27 @@ void __fastcall TSynchronizeDialog::DoAbort(TObject * /*Sender*/, bool Close) PostMessage(Handle, WM_USER_STOP, 0, 0); } //--------------------------------------------------------------------------- -void __fastcall TSynchronizeDialog::DoLog(TSynchronizeController * /*Controller*/, - TSynchronizeLogEntry Entry, const UnicodeString Message) +void __fastcall TSynchronizeDialog::DoLogInternal( + TSynchronizeLogEntry Entry, const UnicodeString & Message, + TStrings * MoreMessages, TQueryType Type, const UnicodeString & HelpKeyword) { LogView->Items->BeginUpdate(); try { TListItem * Item = LogView->Items->Add(); + + TLogItemData * LogItemData = new TLogItemData(); + Item->Data = LogItemData; + LogItemData->Entry = Entry; + LogItemData->Message = Message; + if (MoreMessages != NULL) + { + LogItemData->MoreMessages.reset(new TStringList()); + LogItemData->MoreMessages->Assign(MoreMessages); + } + LogItemData->Type = Type; + LogItemData->HelpKeyword = HelpKeyword; + Item->Caption = Now().TimeString(); Item->SubItems->Add(Message); Item->MakeVisible(false); @@ -314,6 +373,14 @@ void __fastcall TSynchronizeDialog::DoLog(TSynchronizeController * /*Controller* } } //--------------------------------------------------------------------------- +void __fastcall TSynchronizeDialog::DoLog(TSynchronizeController * /*Controller*/, + TSynchronizeLogEntry Entry, const UnicodeString Message) +{ + DoLogInternal(Entry, Message, + // these are unused (as Entry is not slContinuedError here) + NULL, qtInformation, UnicodeString()); +} +//--------------------------------------------------------------------------- void __fastcall TSynchronizeDialog::StartButtonClick(TObject * /*Sender*/) { bool Synchronize; @@ -430,12 +497,12 @@ void __fastcall TSynchronizeDialog::FormShow(TObject * /*Sender*/) { ClearLog(); UpdateControls(); - if (FStartImmediatelly) + if (FStartImmediately) { // if starting get cancelled (from SYNCHRONISE_BEFORE_KEEPUPTODATE2 prompt), // and OnShow gets called again (FSynchronizing is false), // we do not want to try to start again - FStartImmediatelly = false; + FStartImmediately = false; StartButtonClick(NULL); } } @@ -560,3 +627,38 @@ void __fastcall TSynchronizeDialog::TransferSettingsButtonDropDownClick(TObject CopyParamListPopup(CalculatePopupRect(TransferSettingsButton), cplCustomizeDefault); } //--------------------------------------------------------------------------- +void __fastcall TSynchronizeDialog::LogViewCustomDrawItem(TCustomListView * Sender, + TListItem * Item, TCustomDrawState /*State*/, bool & /*DefaultDraw*/) +{ + TLogItemData * LogItemData = GetLogItemData(Item); + if (LogItemData->Entry == slContinuedError) + { + Sender->Canvas->Font->Color = clRed; + } +} +//--------------------------------------------------------------------------- +TLogItemData * __fastcall TSynchronizeDialog::GetLogItemData(TListItem * Item) +{ + return reinterpret_cast(Item->Data); +} +//--------------------------------------------------------------------------- +void __fastcall TSynchronizeDialog::LogViewDeletion(TObject * /*Sender*/, TListItem * Item) +{ + delete GetLogItemData(Item); + Item->Data = NULL; +} +//--------------------------------------------------------------------------- +void __fastcall TSynchronizeDialog::LogViewDblClick(TObject * /*Sender*/) +{ + if (LogView->ItemFocused != NULL) + { + TLogItemData * LogItemData = GetLogItemData(LogView->ItemFocused); + if (LogItemData->Entry == slContinuedError) + { + MoreMessageDialog( + LogItemData->Message, LogItemData->MoreMessages.get(), LogItemData->Type, + qaOK, LogItemData->HelpKeyword); + } + } +} +//--------------------------------------------------------------------------- diff --git a/source/forms/Synchronize.dfm b/source/forms/Synchronize.dfm index 95cd2d30..352a4983 100644 --- a/source/forms/Synchronize.dfm +++ b/source/forms/Synchronize.dfm @@ -6,7 +6,7 @@ object SynchronizeDialog: TSynchronizeDialog BorderIcons = [biSystemMenu, biMinimize, biMaximize, biHelp] BorderStyle = bsDialog Caption = 'Keep remote directory up to date X' - ClientHeight = 421 + ClientHeight = 445 ClientWidth = 436 Color = clBtnFace ParentFont = True @@ -18,7 +18,7 @@ object SynchronizeDialog: TSynchronizeDialog OnShow = FormShow DesignSize = ( 436 - 421) + 445) PixelsPerInch = 96 TextHeight = 13 object DirectoriesGroup: TGroupBox @@ -138,7 +138,7 @@ object SynchronizeDialog: TSynchronizeDialog end object StopButton: TButton Left = 192 - Top = 288 + Top = 312 Width = 74 Height = 25 Anchors = [akTop, akRight] @@ -148,7 +148,7 @@ object SynchronizeDialog: TSynchronizeDialog end object CancelButton: TButton Left = 272 - Top = 288 + Top = 312 Width = 74 Height = 25 Anchors = [akTop, akRight] @@ -161,13 +161,13 @@ object SynchronizeDialog: TSynchronizeDialog Left = 8 Top = 130 Width = 421 - Height = 95 + Height = 119 Anchors = [akLeft, akTop, akRight] Caption = 'Synchronize options' TabOrder = 1 DesignSize = ( 421 - 95) + 119) object SynchronizeDeleteCheck: TCheckBox Left = 11 Top = 20 @@ -179,11 +179,11 @@ object SynchronizeDialog: TSynchronizeDialog end object SaveSettingsCheck: TCheckBox Left = 11 - Top = 68 + Top = 92 Width = 196 Height = 17 Caption = 'Use same &options next time' - TabOrder = 4 + TabOrder = 6 OnClick = ControlChange end object SynchronizeExistingOnlyCheck: TCheckBox @@ -225,10 +225,19 @@ object SynchronizeDialog: TSynchronizeDialog TabOrder = 3 OnClick = ControlChange end + object ContinueOnErrorCheck: TCheckBox + Left = 11 + Top = 68 + Width = 196 + Height = 17 + Caption = 'Continue on &error' + TabOrder = 4 + OnClick = ControlChange + end end object StartButton: TButton Left = 192 - Top = 288 + Top = 312 Width = 74 Height = 25 Anchors = [akTop, akRight] @@ -239,7 +248,7 @@ object SynchronizeDialog: TSynchronizeDialog end object MinimizeButton: TButton Left = 273 - Top = 288 + Top = 312 Width = 74 Height = 25 Anchors = [akTop, akRight] @@ -249,7 +258,7 @@ object SynchronizeDialog: TSynchronizeDialog end object TransferSettingsButton: TButton Left = 8 - Top = 288 + Top = 312 Width = 161 Height = 25 Caption = 'Transfer settin&gs...' @@ -259,7 +268,7 @@ object SynchronizeDialog: TSynchronizeDialog end object CopyParamGroup: TGroupBox Left = 8 - Top = 230 + Top = 254 Width = 421 Height = 50 Anchors = [akLeft, akTop, akRight] @@ -284,7 +293,7 @@ object SynchronizeDialog: TSynchronizeDialog end object HelpButton: TButton Left = 353 - Top = 288 + Top = 312 Width = 75 Height = 25 Anchors = [akTop, akRight] @@ -294,7 +303,7 @@ object SynchronizeDialog: TSynchronizeDialog end object LogPanel: TPanel Left = 0 - Top = 321 + Top = 345 Width = 436 Height = 100 Align = alBottom @@ -327,6 +336,9 @@ object SynchronizeDialog: TSynchronizeDialog ShowColumnHeaders = False TabOrder = 0 ViewStyle = vsReport + OnCustomDrawItem = LogViewCustomDrawItem + OnDblClick = LogViewDblClick + OnDeletion = LogViewDeletion OnKeyDown = LogViewKeyDown end end diff --git a/source/forms/Synchronize.h b/source/forms/Synchronize.h index 6a9a0f0c..1c3f0ab6 100644 --- a/source/forms/Synchronize.h +++ b/source/forms/Synchronize.h @@ -14,6 +14,8 @@ #include #include //--------------------------------------------------------------------------- +struct TLogItemData; +//--------------------------------------------------------------------------- class TSynchronizeDialog : public TForm { __published: @@ -41,6 +43,7 @@ class TSynchronizeDialog : public TForm TPanel *LogPanel; TListView *LogView; TImage *Image; + TCheckBox *ContinueOnErrorCheck; void __fastcall ControlChange(TObject *Sender); void __fastcall LocalDirectoryBrowseButtonClick(TObject *Sender); void __fastcall TransferSettingsButtonClick(TObject *Sender); @@ -58,6 +61,10 @@ class TSynchronizeDialog : public TForm void __fastcall FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift); void __fastcall TransferSettingsButtonDropDownClick(TObject *Sender); + void __fastcall LogViewCustomDrawItem(TCustomListView *Sender, TListItem *Item, + TCustomDrawState State, bool &DefaultDraw); + void __fastcall LogViewDeletion(TObject *Sender, TListItem *Item); + void __fastcall LogViewDblClick(TObject *Sender); private: TSynchronizeParamType FParams; @@ -69,11 +76,12 @@ class TSynchronizeDialog : public TForm bool FMinimizedByMe; bool FAbort; bool FClose; - bool FStartImmediatelly; + bool FStartImmediately; TCopyParamType FCopyParams; TPopupMenu * FPresetsMenu; UnicodeString FPreset; TSynchronizeOptions * FSynchronizeOptions; + TFeedSynchronizeError * FOnFeedSynchronizeError; static const MaxLogItems; void __fastcall SetParams(const TSynchronizeParamType& value); @@ -87,6 +95,8 @@ class TSynchronizeDialog : public TForm protected: void __fastcall DoStartStop(bool Start, bool Synchronize); void __fastcall DoAbort(TObject * Sender, bool Close); + void __fastcall DoLogInternal(TSynchronizeLogEntry Entry, const UnicodeString & Message, + TStrings * MoreMessages, TQueryType Type, const UnicodeString & HelpKeyword); void __fastcall DoLog(TSynchronizeController * Controller, TSynchronizeLogEntry Entry, const UnicodeString Message); void __fastcall OnlyStop(); @@ -98,11 +108,16 @@ class TSynchronizeDialog : public TForm int __fastcall ActualCopyParamAttrs(); void __fastcall GlobalMinimize(TObject * Sender); void __fastcall CopyParamListPopup(TRect R, int AdditionalOptions); + void __fastcall FeedSynchronizeError( + const UnicodeString & Message, TStrings * MoreMessages, TQueryType Type, + const UnicodeString & HelpKeyword); + TLogItemData * __fastcall GetLogItemData(TListItem * Item); public: - __fastcall TSynchronizeDialog(TComponent * Owner, - TSynchronizeStartStopEvent OnStartStop, TGetSynchronizeOptionsEvent OnGetOptions, - bool StartImmediatelly); + __fastcall TSynchronizeDialog(TComponent * Owner); + void __fastcall Init(TSynchronizeStartStopEvent OnStartStop, + TGetSynchronizeOptionsEvent OnGetOptions, + TFeedSynchronizeError & OnFeedSynchronizeError, bool StartImmediately); virtual __fastcall ~TSynchronizeDialog(); bool __fastcall Execute(); diff --git a/source/forms/SynchronizeChecklist.cpp b/source/forms/SynchronizeChecklist.cpp index 634196b7..603f365c 100644 --- a/source/forms/SynchronizeChecklist.cpp +++ b/source/forms/SynchronizeChecklist.cpp @@ -230,7 +230,7 @@ void __fastcall TSynchronizeChecklistDialog::LoadItem(TListItem * Item) } else { - assert(false); + FAIL; } Item->SubItems->Add(S); if (ChecklistItem->Action == TSynchronizeChecklist::saDownloadNew) @@ -247,8 +247,7 @@ void __fastcall TSynchronizeChecklistDialog::LoadItem(TListItem * Item) else { Item->SubItems->Add( - FormatBytes(ChecklistItem->Local.Size, - WinConfiguration->FormatSizeBytes, WinConfiguration->FormatSizeBytes)); + FormatPanelBytes(ChecklistItem->Local.Size, WinConfiguration->FormatSizeBytes)); } Item->SubItems->Add(UserModificationStr(ChecklistItem->Local.Modification, ChecklistItem->Local.ModificationFmt)); @@ -273,7 +272,7 @@ void __fastcall TSynchronizeChecklistDialog::LoadItem(TListItem * Item) } else { - assert(false); + FAIL; } Item->SubItems->Add(S); if (ChecklistItem->Action == TSynchronizeChecklist::saUploadNew) @@ -290,8 +289,7 @@ void __fastcall TSynchronizeChecklistDialog::LoadItem(TListItem * Item) else { Item->SubItems->Add( - FormatBytes(ChecklistItem->Remote.Size, - WinConfiguration->FormatSizeBytes, WinConfiguration->FormatSizeBytes)); + FormatPanelBytes(ChecklistItem->Remote.Size, WinConfiguration->FormatSizeBytes)); } Item->SubItems->Add(UserModificationStr(ChecklistItem->Remote.Modification, ChecklistItem->Remote.ModificationFmt)); @@ -436,7 +434,7 @@ void __fastcall TSynchronizeChecklistDialog::StatusBarDrawPanel( break; default: - assert(false); + FAIL; Possible = false; break; } diff --git a/source/forms/SynchronizeProgress.cpp b/source/forms/SynchronizeProgress.cpp index 2ff8d451..8f2de716 100644 --- a/source/forms/SynchronizeProgress.cpp +++ b/source/forms/SynchronizeProgress.cpp @@ -48,7 +48,9 @@ __fastcall TSynchronizeProgressForm::~TSynchronizeProgressForm() if (IsApplicationMinimized() && FMinimizedByMe) { - ShowNotification(NULL, LoadStr(BALLOON_OPERATION_COMPLETE), qtInformation); + ShowNotification( + NULL, MainInstructions(LoadStr(BALLOON_OPERATION_COMPLETE)), + qtInformation); } } //--------------------------------------------------------------------------- @@ -58,12 +60,12 @@ void __fastcall TSynchronizeProgressForm::Start() FStartTime = Now(); UpdateTimer->Enabled = true; StartTimeLabel->Caption = FStartTime.TimeString(); - Caption = LoadStr(FCompareOnly ? SYNCHRONIZE_PROGRESS_COMPARE : SYNCHRONIZE_PROGRESS_SYNCHRONIZE); + Caption = FormatFormCaption(this, LoadStr(FCompareOnly ? SYNCHRONIZE_PROGRESS_COMPARE : SYNCHRONIZE_PROGRESS_SYNCHRONIZE2)); if (!IsApplicationMinimized()) { // Do not showing the progress when the application is minimized, // otherwise the form popups up unminimized. - // Quick as dirty hack: with this form, we do not support showing it + // Quick and dirty hack: with this form, we do not support showing it // once the application restores, // otherwise we would have to synchronize it somehow with the TProgressForm, // not to show it over the TProgressForm @@ -92,15 +94,20 @@ void __fastcall TSynchronizeProgressForm::UpdateControls() TimeElapsedLabel->Caption = FormatDateTimeSpan(Configuration->TimeFormat, FElapsed); } //--------------------------------------------------------------------------- -void __fastcall TSynchronizeProgressForm::CancelButtonClick(TObject * /*Sender*/) +void __fastcall TSynchronizeProgressForm::CancelOperation() { if (!FCanceled && (MessageDialog(LoadStr(CANCEL_OPERATION2), qtConfirmation, - qaOK | qaCancel, HELP_NONE) == qaOK)) + qaYes | qaNo, HELP_NONE) == qaYes)) { FCanceled = true; } } //--------------------------------------------------------------------------- +void __fastcall TSynchronizeProgressForm::CancelButtonClick(TObject * /*Sender*/) +{ + CancelOperation(); +} +//--------------------------------------------------------------------------- void __fastcall TSynchronizeProgressForm::UpdateTimerTimer(TObject * /*Sender*/) { UpdateControls(); @@ -118,3 +125,16 @@ void __fastcall TSynchronizeProgressForm::GlobalMinimize(TObject * /*Sender*/) FMinimizedByMe = true; } //--------------------------------------------------------------------------- +void __fastcall TSynchronizeProgressForm::Dispatch(void * AMessage) +{ + TMessage & Message = *reinterpret_cast(AMessage); + if (Message.Msg == WM_CLOSE) + { + CancelOperation(); + } + else + { + TForm::Dispatch(AMessage); + } +} +//--------------------------------------------------------------------------- diff --git a/source/forms/SynchronizeProgress.h b/source/forms/SynchronizeProgress.h index e6038d12..5691f668 100644 --- a/source/forms/SynchronizeProgress.h +++ b/source/forms/SynchronizeProgress.h @@ -38,6 +38,9 @@ class TSynchronizeProgressForm : public TForm __property bool Started = { read = FStarted }; +protected: + virtual void __fastcall Dispatch(void * Message); + private: TDateTime FStartTime; TDateTime FElapsed; @@ -49,6 +52,7 @@ class TSynchronizeProgressForm : public TForm void __fastcall UpdateControls(); void __fastcall GlobalMinimize(TObject * Sender); + void __fastcall CancelOperation(); }; //--------------------------------------------------------------------------- #endif diff --git a/source/packages/dragndrop/DragDropFilesEx.pas b/source/packages/dragndrop/DragDropFilesEx.pas index cd65c30f..cafdf293 100644 --- a/source/packages/dragndrop/DragDropFilesEx.pas +++ b/source/packages/dragndrop/DragDropFilesEx.pas @@ -181,6 +181,9 @@ procedure Register; implementation +uses + Types; + const {$EXTERNALSYM IID_IDropTarget} IID_IDropTarget: TGUID = ( @@ -213,7 +216,7 @@ procedure CopyHDropToFilelist(var List: TFileList; HDropPtr: PAnsiChar; HDropSiz begin while HDropPtr^<>#0 do begin - s:=string(StrPas(HDropPtr)); + s:=string(HDropPtr); inc(HDropPtr, Length(s)+1); List.AddItem(nil,s); end; @@ -490,7 +493,7 @@ constructor TDataObjectFilesEx.Create(AFileList: TFileList; RenderPIDL, RenderFi end; pos:=pidlStream.Position; pidlStream.Write(pidlItem^,PIDL_GetSize(pidlItem)); - pidlStream.seek(8+4*i,0); + pidlStream.seek(8+4*i,soBeginning); pidlStream.Write(pos,4); pidlStream.Seek(0,2); PIDL_Free(pidlRoot); diff --git a/source/packages/dragndrop/PIDL.pas b/source/packages/dragndrop/PIDL.pas index 27885164..94b0ad52 100644 --- a/source/packages/dragndrop/PIDL.pas +++ b/source/packages/dragndrop/PIDL.pas @@ -208,6 +208,7 @@ function Pidl_GetFullyQualified(const PiParentFolder: IShellFolder; if PIDL_GetDisplayName(piParentFolder, pidl, SHGDN_FORPARSING, @szBuffer, sizeof(szBuffer))=false then exit; MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, @szBuffer, -1, @szOleChar, sizeof(szOleChar)); + ulAttribs := 0; if Failed(piDesktopFolder.ParseDisplayName(0, nil, @szOleChar, ulEaten, Result, ulAttribs)) then Result:=nil; // piDesktopFolder._Release; automaticly done by D4 @@ -259,6 +260,7 @@ function PIDL_GetFromPath(pszFile: PChar): PItemIDList; Result:=nil; if Failed(SHGetDesktopFolder(piDesktop)) then exit; piDesktop._AddRef; + ulAttribs := 0; if Failed(piDesktop.ParseDisplayName(0, nil, pszFile, ulEaten, Result, ulAttribs)) then Result:=nil; // piDesktop._Release; -> automaticly done by D4 @@ -298,6 +300,7 @@ function PIDL_GetFromParentFolder(pParentFolder: IShellFolder; pszFile: PChar): begin ErrorMode := SetErrorMode(SEM_FAILCRITICALERRORS or SEM_NOOPENFILEERRORBOX); try + dwAttributes := 0; NotResult := Failed(pParentFolder.ParseDisplayName(0, nil, pszFile, chEaten, Result, dwAttributes)); finally diff --git a/source/packages/filemng/BaseUtils.pas b/source/packages/filemng/BaseUtils.pas index 88f19a31..5af11a33 100644 --- a/source/packages/filemng/BaseUtils.pas +++ b/source/packages/filemng/BaseUtils.pas @@ -31,13 +31,17 @@ interface type TDateTimePrecision = (tpNone, tpDay, tpMinute, tpSecond, tpMillisecond); + // order choosen so that for previous bool value, false maps to fbNone, + // and true maps to new default fbKilobytes, although functionaly it is fbShort + TFormatBytesStyle = (fbNone, fbKilobytes, fbShort); function CheckFileExists(FileName: string): Boolean; function DirExists(Dir: string): Boolean; overload; function DirExists(Dir: string; var Attrs: Integer): Boolean; overload; function ExtractFileNameOnly(Name: string): string; function FileOrDirExists(FileName: string): Boolean; -function FormatBytes(Bytes: Int64; UseOrders: Boolean = True; UseUnitsForBytes: Boolean = True): string; +function FormatBytes(Bytes: Int64; Style: TFormatBytesStyle = fbShort; UseUnitsForBytes: Boolean = True): string; +function FormatPanelBytes(Bytes: Int64; Style: TFormatBytesStyle): string; procedure FreePIDL(var PIDL: PItemIDList); function StrContains(Str1, Str2: string): Boolean; procedure StrTranslate(var Str: string; Code: string); @@ -56,11 +60,15 @@ function FormatLastOSError(Message: string): string; resourcestring SNoValidPath = 'Can''t find any valid path.'; SUcpPathsNotSupported = 'UNC paths are not supported.'; + SByte = 'B'; + SKiloByte = 'KB'; + SMegaByte = 'MB'; + SGigaByte = 'GB'; implementation uses - IEDriveInfo, DateUtils, ShellApi, SysConst; + IEDriveInfo, DateUtils, ShellApi, SysConst, PasTools; function AnyValidPath: string; var @@ -68,14 +76,14 @@ function AnyValidPath: string; begin for Drive := 'C' to 'Z' do if (DriveInfo[Drive].DriveType = DRIVE_FIXED) and - DirectoryExists(Drive + ':\') then + DirectoryExists(ApiPath(Drive + ':\')) then begin Result := Drive + ':\'; Exit; end; for Drive := 'C' to 'Z' do if (DriveInfo[Drive].DriveType = DRIVE_REMOTE) and - DirectoryExists(Drive + ':\') then + DirectoryExists(ApiPath(Drive + ':\')) then begin Result := Drive + ':\'; Exit; @@ -118,7 +126,7 @@ function FileOrDirExists(FileName: string): Boolean; if Length(FileName) = 0 then Result := False else begin - Result := (FindFirst(FileName, faAnyFile, SRec) = 0); + Result := (FindFirst(ApiPath(FileName), faAnyFile, SRec) = 0); SysUtils.FindCLose(SRec); end; end; {FileOrDirExists} @@ -131,7 +139,7 @@ function CheckFileExists(FileName: string): Boolean; SaveFileMode := System.FileMode; System.FileMode := 0; try - AssignFile(F, FileName); + AssignFile(F, ApiPath(FileName)); Reset(F, 1); Result := IOResult = 0; if Result then @@ -149,7 +157,7 @@ function DirExists(Dir: string; var Attrs: Integer): Boolean; if Result then Attrs := 0 else begin - if FindFirst(Dir, faAnyFile, SRec) = 0 then + if FindFirst(ApiPath(Dir), faAnyFile, SRec) = 0 then begin Result := (SRec.Attr and faDirectory <> 0); Attrs := SRec.Attr; @@ -175,23 +183,43 @@ function ExtractFileNameOnly(Name: string): string; Delete(Result, Length(Result)-Length(Ext)+1, Length(Ext)); end; {ExtractFileNameOnly} -function FormatBytes(Bytes: Int64; UseOrders: Boolean; UseUnitsForBytes: Boolean): string; +function FormatBytes(Bytes: Int64; Style: TFormatBytesStyle; UseUnitsForBytes: Boolean): string; +var + SizeUnit: string; + Value: Extended; begin - if (not UseOrders) or (Bytes < Int64(100*1024)) then + if (Style = fbNone) or ((Style = fbShort) and (Bytes < Int64(100*1024))) then begin + Value := Bytes; if UseUnitsForBytes then - Result := FormatFloat('#,##0 "B"', Bytes) - else - Result := FormatFloat('#,##0', Bytes) + SizeUnit := SByte; end else - if Bytes < Int64(100*1024*1024) then - Result := FormatFloat('#,##0 "KiB"', Bytes / 1024) + if (Style = fbKilobytes) or (Bytes < Int64(100*1024*1024)) then + begin + Value := Bytes / 1024; + SizeUnit := SKiloByte; + end else if Bytes < Int64(Int64(100)*1024*1024*1024) then - Result := FormatFloat('#,##0 "MiB"', Bytes / (1024*1024)) - else - Result := FormatFloat('#,##0 "GiB"', Bytes / Int64(1024*1024*1024)); + begin + Value := Bytes / (1024*1024); + SizeUnit := SMegaByte; + end + else + begin + Value := Bytes / Int64(1024*1024*1024); + SizeUnit := SGigaByte; + end; + + Result := FormatFloat('#,##0', Value); + if SizeUnit <> '' then + Result := Result + ' ' + SizeUnit; +end; + +function FormatPanelBytes(Bytes: Int64; Style: TFormatBytesStyle): string; +begin + Result := FormatBytes(Bytes, Style, (Style <> fbNone)); end; procedure FreePIDL(var PIDL: PItemIDList); diff --git a/source/packages/filemng/CustomDirView.pas b/source/packages/filemng/CustomDirView.pas index 6366bd8c..3ecf3cda 100644 --- a/source/packages/filemng/CustomDirView.pas +++ b/source/packages/filemng/CustomDirView.pas @@ -90,7 +90,6 @@ TStatusFileInfo = record TDDFileOperationExecutedEvent = procedure(Sender: TObject; dwEffect: LongInt; SourcePath, TargetPath: string) of object; TDirViewExecFileEvent = procedure(Sender: TObject; Item: TListItem; var AllowExec: Boolean) of object; - TRenameEvent = procedure(Sender: TObject; Item: TListItem; NewName: string) of object; TMatchMaskEvent = procedure(Sender: TObject; FileName: string; Directory: Boolean; Size: Int64; Modification: TDateTime; Masks: string; var Matches: Boolean; AllowImplicitMatches: Boolean) of object; TDirViewGetOverlayEvent = procedure(Sender: TObject; Item: TListItem; var Indexes: Word) of object; TDirViewUpdateStatusBarEvent = procedure(Sender: TObject; const FileInfo: TStatusFileInfo) of object; @@ -132,19 +131,13 @@ TCustomDirView = class(TCustomIEListView) private FAddParentDir: Boolean; FDimmHiddenFiles: Boolean; - FShowDirectories: Boolean; - FShowSubDirSize: Boolean; - FFormatSizeBytes: Boolean; - FSortByExtension: Boolean; + FFormatSizeBytes: TFormatBytesStyle; FWantUseDragImages: Boolean; FDragDropFilesEx: TCustomizableDragDropFilesEx; - FSingleClickToExec: Boolean; FUseSystemContextMenu: Boolean; FOnGetSelectFilter: TDVGetFilterEvent; FOnStartLoading: TNotifyEvent; FOnLoaded: TNotifyEvent; - FOnDirUpdated: TNotifyEvent; - FReloadTime: TSystemTime; FDragDrive: TDrive; FExeDrag: Boolean; FDDLinkOnExeDrag: Boolean; @@ -189,8 +182,6 @@ TCustomDirView = class(TCustomIEListView) FMaxHistoryCount: Integer; FPathLabel: TCustomPathLabel; FOnUpdateStatusBar: TDirViewUpdateStatusBarEvent; - FOnBeginRename: TRenameEvent; - FOnEndRename: TRenameEvent; FOnHistoryChange: TDirViewNotifyEvent; FOnHistoryGo: TDVHistoryGoEvent; FOnPathChange: TDirViewNotifyEvent; @@ -316,7 +307,6 @@ TCustomDirView = class(TCustomIEListView) procedure SelectFiles(Filter: TFileFilter; Select: Boolean); procedure SetAddParentDir(Value: Boolean); virtual; procedure SetDimmHiddenFiles(Value: Boolean); virtual; - procedure SetShowDirectories(Value: Boolean); virtual; procedure SetItemImageIndex(Item: TListItem; Index: Integer); virtual; abstract; procedure SetLoadEnabled(Enabled : Boolean); virtual; procedure SetMultiSelect(Value: Boolean); override; @@ -331,10 +321,8 @@ TCustomDirView = class(TCustomIEListView) procedure PathChanged; virtual; procedure PathChanging(Relative: Boolean); procedure SetPath(Value: string); virtual; abstract; - procedure SetSortByExtension(Value: Boolean); procedure SetShowHiddenFiles(Value: Boolean); virtual; - procedure SetShowSubDirSize(Value: Boolean); virtual; - procedure SetFormatSizeBytes(Value: Boolean); + procedure SetFormatSizeBytes(Value: TFormatBytesStyle); procedure SetViewStyle(Value: TViewStyle); override; procedure SetWatchForChanges(Value: Boolean); virtual; function TargetHasDropHandler(Item: TListItem; Effect: Integer): Boolean; virtual; @@ -355,20 +343,20 @@ TCustomDirView = class(TCustomIEListView) property ImageList16: TImageList read FImageList16; property ImageList32: TImageList read FImageList32; public - function AnyFileSelected(OnlyFocused: Boolean; FilesOnly: Boolean; - FocusedFileOnlyWhenFocused: Boolean): Boolean; constructor Create(AOwner: TComponent); override; - procedure CreateDirectory(DirName: string); virtual; abstract; destructor Destroy; override; procedure Load; virtual; procedure Reload(CacheIcons: Boolean); virtual; function CreateFocusedFileList(FullPath: Boolean; FileList: TStrings = nil): TStrings; function CreateFileList(Focused: Boolean; FullPath: Boolean; FileList: TStrings = nil): TStrings; + function AnyFileSelected(OnlyFocused: Boolean; FilesOnly: Boolean; + FocusedFileOnlyWhenFocused: Boolean): Boolean; function DoSelectByMask(Select: Boolean): Boolean; override; procedure ExecuteHomeDirectory; virtual; abstract; procedure ExecuteParentDirectory; virtual; abstract; procedure ExecuteRootDirectory; virtual; abstract; procedure ExecuteCurrentFile(); + procedure CreateDirectory(DirName: string); virtual; abstract; function FindFileItem(FileName: string): TListItem; procedure HistoryGo(Index: Integer); function ItemIsDirectory(Item: TListItem): Boolean; virtual; abstract; @@ -399,11 +387,8 @@ TCustomDirView = class(TCustomIEListView) property AddParentDir: Boolean read FAddParentDir write SetAddParentDir default False; property DimmHiddenFiles: Boolean read FDimmHiddenFiles write SetDimmHiddenFiles default True; - property ShowDirectories: Boolean read FShowDirectories write SetShowDirectories default True; property DragDropFilesEx: TCustomizableDragDropFilesEx read FDragDropFilesEx; - property ShowSubDirSize: Boolean read FShowSubDirSize write SetShowSubDirSize default False; - property FormatSizeBytes: Boolean read FFormatSizeBytes write SetFormatSizeBytes default False; - property SortByExtension: Boolean read FSortByExtension write SetSortByExtension default False; + property FormatSizeBytes: TFormatBytesStyle read FFormatSizeBytes write SetFormatSizeBytes default fbNone; property WantUseDragImages: Boolean read FWantUseDragImages write FWantUseDragImages default True; property UseDragImages: Boolean read GetUseDragImages stored False; property FullDrag default True; @@ -416,8 +401,6 @@ TCustomDirView = class(TCustomIEListView) property HasParentDir: Boolean read FHasParentDir; property Path: string read GetPath write SetPath; property PathName: string read GetPathName; - property ReloadTime: TSystemTime read FReloadTime; - property SingleClickToExec: Boolean read FSingleClickToExec write FSingleClickToExec default False; property UseSystemContextMenu: Boolean read FUseSystemContextMenu write FUseSystemContextMenu default True; property Loading: Boolean read FLoading; @@ -449,13 +432,9 @@ TCustomDirView = class(TCustomIEListView) property Mask: string read FMask write SetMask; property OnContextPopup; - property OnBeginRename: TRenameEvent read FOnBeginRename write FOnBeginRename; - property OnEndRename: TRenameEvent read FOnEndRename write FOnEndRename; property OnGetSelectFilter: TDVGetFilterEvent read FOnGetSelectFilter write FOnGetSelectFilter; property OnStartLoading: TNotifyEvent read FOnStartLoading write FOnStartLoading; property OnLoaded: TNotifyEvent read FOnLoaded write FOnLoaded; - {This event is fired, when any update has made to the listview} - property OnDirUpdated: TNotifyEvent read FOnDirUpdated write FOnDirUpdated; {The mouse has entered the component window as a target of a drag&drop operation:} property OnDDDragEnter: TDDOnDragEnter read FOnDDDragEnter write FOnDDDragEnter; {The mouse has leaved the component window as a target of a drag&drop operation:} @@ -485,7 +464,7 @@ TCustomDirView = class(TCustomIEListView) {The component window is the target of a drag&drop operation:} property OnDDProcessDropped: TOnProcessDropped read FOnDDProcessDropped write FOnDDProcessDropped; - {An error has occured during a drag&drop operation:} + {An error has occurred during a drag&drop operation:} property OnDDError: TDDErrorEvent read FOnDDError write FOnDDError; {The drag&drop operation has been executed:} property OnDDExecuted: TDDExecutedEvent @@ -558,7 +537,6 @@ function OverlayImageList(Size: Integer): TImageList; StdDirSelIcon: Integer; DropSourceControl: TObject; UnknownFileIcon: Integer = 0; - HasExtendedCOMCTL32: Boolean; StdDirTypeName: string; DefaultExeIcon: Integer; UserDocumentDirectory: string; @@ -566,7 +544,7 @@ function OverlayImageList(Size: Integer): TImageList; implementation uses - Math, DirViewColProperties; + Math, DirViewColProperties, UITypes, Types; const Space = ' '; @@ -586,6 +564,10 @@ procedure InitGlobals; begin GlobalsInitialized := True; + // Calling GetshFileInfo in Windows Session 0 sometime cause crash + // (not immediately, but very shortly afterwards [few ms]). + // So this code was moved from initialization section to avoid it + // being used for non-GUI runs. UnknownFileIcon := GetshFileInfo('$#)(.#$)', FILE_ATTRIBUTE_NORMAL, SHGFI_SYSICONINDEX or SHGFI_USEFILEATTRIBUTES).iIcon; DefaultExeIcon := GetshFileInfo('.COM', @@ -615,9 +597,6 @@ TDirViewState = class(TObject) FocusedItem: string; end; -var - COMCTL32Version: DWORD; - destructor TDirViewState.Destroy; begin HistoryPaths.Free; @@ -715,7 +694,7 @@ function CreateFileShortCut(SourceFile, Target, DisplayName: string; ShellLink := IUnk as IShellLink; IPFile := IUnk as IPersistFile; - if FileExists(TargetFile) and UpdateIfExists then + if FileExists(ApiPath(TargetFile)) and UpdateIfExists then begin HRes := IPFile.Load(PChar(TargetFile), 0); if not Succeeded(HRes) then Exit; @@ -778,40 +757,6 @@ function GetShellDisplayName(const ShellFolder: IShellFolder; IDList: PItemIDLis else Result := False; end; {GetShellDisplayName} -function COMCTL32OK: Boolean; -{Returs, whether COMCTL32 supports the extended display properties: - COMCTL32.DLL version 4.70 or higher is required. Version 4.70 is - included in Internet Explorer 4 with Active Desktop. - Updates of COMCTL32.DLL are available at: - http://msdn.microsoft.com/developer/downloads/files/40Comupd.htm } -var - VerInfoSize: DWORD; - Dummy: DWORD; - VerInfo: Pointer; - FileInfo: PVSFixedFileInfo; - FileInfoSize: UINT; -begin - Result := False; - VerInfoSize := GetFileVersionInfoSize('COMCTL32.DLL', Dummy); - if VerInfoSize > 0 then - begin - GetMem(VerInfo, VerInfoSize); - try - if GetFileVersionInfo(PChar('COMCTL32.DLL'), 0, VerInfoSize, VerInfo) then - begin - if VerQueryValue(VerInfo, '\', Pointer(FileInfo), FileInfoSize) then - begin - ComCTL32Version := FileInfo.dwFileVersionMS; - Result := (ComCTL32Version >= $40046); { COMCTL32 Version >= 4.70 required } - end - else ComCTL32Version := 0; - end; - finally - FreeMem(VerInfo, VerInfoSize); - end; - end; -end; {COMCTL32OK} - function OverlayImageList(Size: Integer): TImageList; procedure GetOverlayBitmap(ImageList: TImageList; BitmapName: string); @@ -892,13 +837,10 @@ constructor TCustomDirView.Create(AOwner: TComponent); FFilesSelSize := 0; FDimmHiddenFiles := True; FShowHiddenFiles := True; - FShowDirectories := True; - FShowSubDirSize := False; - FFormatSizeBytes := False; + FFormatSizeBytes := fbNone; FWantUseDragImages := True; FAddParentDir := False; FullDrag := True; - FSingleClickToExec := False; FInvalidNameChars := '\/:*?"<>|'; FHasParentDir := False; FDragOnDriveIsMove := False; @@ -951,14 +893,8 @@ constructor TCustomDirView.Create(AOwner: TComponent); FDragDropFilesEx := TCustomizableDragDropFilesEx.Create(Self); with FDragDropFilesEx do begin - {$IFDEF OLD_DND} AutoDetectDnD := False; DragDetectDelta := 4; - {$ELSE} - DragDetect.Automatic := False; - DragDetect.DeltaX := 4; - DragDetect.DeltaY := 4; - {$ENDIF} AcceptOwnDnD := True; BringToFront := True; CompleteFileList := True; @@ -1103,7 +1039,7 @@ procedure TCustomDirView.CNNotify(var Message: TWMNotify); end; if (Message.NMHdr.code = NM_CUSTOMDRAW) and - HasExtendedCOMCTL32 and Valid and (not Loading) then + Valid and (not Loading) then with PNMLVCustomDraw(Message.NMHdr)^ do try Message.Result := Message.Result or CDRF_NOTIFYPOSTPAINT; @@ -1174,16 +1110,6 @@ procedure TCustomDirView.SetPathLabel(Value: TCustomPathLabel); end; end; { SetPathLabel } -procedure TCustomDirView.SetShowDirectories(Value: Boolean); -begin - if Value <> FShowDirectories then - begin - FShowDirectories := Value; - if DirOK then Reload(True); - Self.Repaint; - end; -end; {SetShowDirectories} - procedure TCustomDirView.SetShowHiddenFiles(Value: Boolean); begin if ShowHiddenFiles <> Value then @@ -1193,29 +1119,14 @@ procedure TCustomDirView.SetShowHiddenFiles(Value: Boolean); end; end; -procedure TCustomDirView.SetShowSubDirSize(Value: Boolean); -begin - if Value <> FShowSubDirSize then - FShowSubDirSize := Value; -end; {SetShowSubDirSize} - -procedure TCustomDirView.SetFormatSizeBytes(Value: Boolean); +procedure TCustomDirView.SetFormatSizeBytes(Value: TFormatBytesStyle); begin if Value <> FFormatSizeBytes then begin FFormatSizeBytes := Value; Self.Repaint; end; -end; {SetShowSubDirSize} - -procedure TCustomDirView.SetSortByExtension(Value: Boolean); -Begin - if Value <> FSortByExtension then - begin - FSortByExtension := Value; - SortItems; - end; -end; {SetSortByExtension} +end; {SetFormatSizeBytes} function TCustomDirView.GetDragSourceEffects: TDropEffectSet; begin @@ -1721,7 +1632,7 @@ procedure TCustomDirView.WMRButtonDown(var Message: TWMRButtonDown); procedure TCustomDirView.WMLButtonDblClk(var Message: TWMLButtonDblClk); begin inherited; - if (not SingleClickToExec) and Assigned(ItemFocused) and (not Loading) and + if Assigned(ItemFocused) and (not Loading) and (GetItemAt(Message.XPos, Message.YPos) = ItemFocused) then begin if GetKeyState(VK_MENU) < 0 then DisplayPropertiesMenu @@ -1731,13 +1642,6 @@ procedure TCustomDirView.WMLButtonDblClk(var Message: TWMLButtonDblClk); procedure TCustomDirView.WMLButtonUp(var Message: TWMLButtonUp); begin - if SingleClickToExec and FDragEnabled and Assigned(ItemFocused) and (not Loading) and - (GetItemAt(Message.XPos, Message.YPos) = ItemFocused) and - (GetKeyState(VK_SHIFT) >= 0) and (GetKeyState(VK_CONTROL) >= 0) then - begin - if GetKeyState(VK_MENU) < 0 then DisplayPropertiesMenu - else Execute(ItemFocused); - end; FDragEnabled := False; inherited; end; @@ -1956,8 +1860,6 @@ procedure TCustomDirView.Load; FNotifyEnabled := False; ClearItems; - GetSystemTime(FReloadTime); - FFilesSize := 0; FFilesSelSize := 0; SortType := stNone; @@ -2003,9 +1905,6 @@ procedure TCustomDirView.Load; FNotifyEnabled := True; - if DirOK and not FAbortLoading and Assigned(FOnDirUpdated) then - FOnDirUpdated(Self); - FocusSomething; if Assigned(FOnLoaded) then @@ -2478,15 +2377,12 @@ function TCustomDirView.CanChangeSelection(Item: TListItem; procedure TCustomDirView.Edit(const HItem: TLVItem); var - Item: TListItem; Info: string; Index: Integer; begin if Length(HItem.pszText) = 0 then LoadEnabled := True else begin - Item := GetItemFromHItem(HItem); - {Does the changed filename contains invalid characters?} if StrContains(FInvalidNameChars, HItem.pszText) then begin @@ -2500,13 +2396,7 @@ procedure TCustomDirView.Edit(const HItem: TLVItem); end else begin - if Assigned(FOnBeginRename) then - FOnBeginRename(Self, Item, string(HItem.pszText)); - InternalEdit(HItem); - - if Assigned(FOnEndRename) then - FOnEndRename(Self, Item, string(HItem.pszText)); end; end; end; {Edit} @@ -2801,11 +2691,7 @@ procedure TCustomDirView.WMAppCommand(var Message: TMessage); procedure TCustomDirView.CMColorChanged(var Message: TMessage); begin inherited; - // particularly when changing color back to default (clWindow), - // non-client area (border line) is not redrawn, - // keeping previous color. force redraw here - if HandleAllocated then - RedrawWindow(Handle, nil, 0, RDW_INVALIDATE or RDW_FRAME); + ForceColorChange(Self); end; procedure TCustomDirView.WndProc(var Message: TMessage); @@ -3285,7 +3171,7 @@ procedure TCustomDirView.EnsureSelectionRedrawn; // when receiving/losing focus, selection is not redrawn in report view // (except for focus item selection), // probably when double buffering is enabled (LVS_EX_DOUBLEBUFFER). - // But even without LVS_EX_DOUBLEBUFFER, selection behing file icon is not updated. + // But even without LVS_EX_DOUBLEBUFFER, selection behind file icon is not updated. if ViewStyle = vsReport then begin if (SelCount >= 2) or ((SelCount >= 1) and ((not Assigned(ItemFocused)) or (not ItemFocused.Selected))) then @@ -3302,8 +3188,6 @@ procedure TCustomDirView.EnsureSelectionRedrawn; end; initialization - HasExtendedCOMCTL32 := COMCTL32OK; - DropSourceControl := nil; SetLength(WinDir, MAX_PATH); diff --git a/source/packages/filemng/CustomDriveView.pas b/source/packages/filemng/CustomDriveView.pas index 50fd4818..67d19156 100644 --- a/source/packages/filemng/CustomDriveView.pas +++ b/source/packages/filemng/CustomDriveView.pas @@ -11,10 +11,8 @@ interface {Types uses by the function IterateSubTree:} {TRecursiveScan: determines, wich nodes are scanned by the function IterateSubTree: rsNoRecursive: Scan startnode only. - rsRecursive: Scan all subnodes of the startnode. - rsRecursiveExisting: Scan all subnodes of the startnode but not new created subnodes. - rsRecursiveExpanded: Scan all expanded subnodes of the startnode.} - TRecursiveScan = (rsNoRecursive, rsRecursive, rsRecursiveExisting, rsRecursiveExpanded); + rsRecursiveExisting: Scan all subnodes of the startnode but not new created subnodes.} + TRecursiveScan = (rsNoRecursive, rsRecursiveExisting); {TScanStartnode: determines, wether the startnode should also be scanned:} TScanStartNode = (coNoScanStartNode, coScanStartNode); @@ -136,8 +134,6 @@ TCustomDriveView = class(TCustomTreeView) procedure ValidateDirectoryEx(Node: TTreeNode; Recurse: TRecursiveScan; NewDirs: Boolean); virtual; abstract; - procedure ValidateVisibleDirectories(Node: TTreeNode); - procedure ValidateAllDirectories(Node: TTreeNode); procedure RebuildTree; virtual; abstract; procedure DisplayContextMenu(Node: TTreeNode; ScreenPos: TPoint); virtual; abstract; @@ -185,7 +181,7 @@ TCustomDriveView = class(TCustomTreeView) property OnDDDragDetect: TDDOnDragDetect read FOnDDDragDetect write FOnDDDragDetect; {The component window is the target of a drag&drop operation:} property OnDDProcessDropped: TOnProcessDropped read FOnDDProcessDropped write FOnDDProcessDropped; - {An error has occured during a drag&drop operation:} + {An error has occurred during a drag&drop operation:} property OnDDError: TDDErrorEvent read FOnDDError write FOnDDError; {The drag&drop operation has been executed:} property OnDDExecuted: TDDExecutedEvent read FOnDDExecuted write FOnDDExecuted; @@ -242,11 +238,7 @@ constructor TCustomDriveView.Create(AOwner: TComponent); begin AcceptOwnDnd := True; {MP} - {$IFDEF OLD_DND} AutoDetectDnD := False; - {$ELSE} - DragDetect.Automatic := False; - {$ENDIF} {/MP} BringToFront := True; CompleteFileList := True; @@ -785,7 +777,7 @@ function TCustomDriveView.CustomDrawItem(Node: TTreeNode; State: TCustomDrawStat begin Result := inherited CustomDrawItem(Node, State, Stage, PaintImages); - if Result and (Stage = cdPostPaint) and HasExtendedCOMCTL32 then + if Result and (Stage = cdPostPaint) then begin Assert(Assigned(Node)); OverlayIndexes := NodeOverlayIndexes(Node); @@ -832,11 +824,7 @@ procedure TCustomDriveView.CMColorChanged(var Msg: TMessage); Images.BkColor := Color; if Assigned(StateImages) then StateImages.BkColor := Color; - // sometimes when changing color, - // non-client area (border line) is not redrawn, - // keeping previous color. force redraw here - if HandleAllocated then - RedrawWindow(Handle, nil, 0, RDW_INVALIDATE or RDW_FRAME); + ForceColorChange(Self); end; procedure TCustomDriveView.WMLButtonDown(var Msg: TWMLButtonDown); @@ -983,16 +971,6 @@ procedure TCustomDriveView.ValidateDirectory(Node: TTreeNode); ValidateDirectoryEx(Node, rsRecursiveExisting, False); end; {ValidateDirectory} -procedure TCustomDriveView.ValidateVisibleDirectories(Node: TTreeNode); -begin - ValidateDirectoryEx(Node, rsRecursiveExpanded, False); -end; {ValidateVisibleDirectories} - -procedure TCustomDriveView.ValidateAllDirectories(Node: TTreeNode); -begin - ValidateDirectoryEx(Node, rsRecursive, True); -end; {ValidateAllDirectories} - procedure TCustomDriveView.CenterNode(Node: TTreeNode); var NodePos: TRect; @@ -1092,9 +1070,8 @@ function TCustomDriveView.IterateSubTree(var StartNode : TTreeNode; if (not FContinue) or (not CallBackFunc(Node, Data)) then Exit; - if Assigned(Node) and ((Recurse = rsRecursive) or - ((Recurse = rsRecursiveExpanded) and Node.Expanded) or - ((Recurse = rsRecursiveExisting) and NodeHasChilds)) then + if Assigned(Node) and + (Recurse = rsRecursiveExisting) and NodeHasChilds then begin if (not ScanSubTree(Node)) or (not FContinue) then Exit; end; diff --git a/source/packages/filemng/DirView.pas b/source/packages/filemng/DirView.pas index fe840c3f..ffb3ab31 100644 --- a/source/packages/filemng/DirView.pas +++ b/source/packages/filemng/DirView.pas @@ -23,7 +23,6 @@ V2.6: - Shows "shared"-symbol with directories - - New property ShowSubDirSize. Displays subdirectories sizes. - Delphi5 compatible For detailed documentation and history see TDirView.htm. @@ -37,39 +36,30 @@ interface {$WARN UNIT_PLATFORM OFF} {$WARN SYMBOL_PLATFORM OFF} -{$DEFINE USE_DRIVEVIEW} uses Windows, ShlObj, ComCtrls, CompThread, CustomDirView, ListExt, ExtCtrls, Graphics, FileOperator, DiscMon, Classes, DirViewColProperties, DragDrop, Messages, ListViewColProperties, CommCtrl, DragDropFilesEx, - FileCtrl, SysUtils, BaseUtils, Controls; + FileCtrl, SysUtils, BaseUtils, Controls, CustomDriveView; {$I ResStrings.pas } type - TVolumeDisplayStyle = (doPrettyName, doDisplayName, doLongPrettyName); {Diplaytext of drive node} + TVolumeDisplayStyle = (doPrettyName, doDisplayName); {Diplaytext of drive node} const -{$IFNDEF NO_THREADS} msThreadChangeDelay = 10; {TDiscMonitor: change delay} MaxWaitTimeOut = 10; {TFileDeleteThread: wait nn seconds for deleting files or directories} -{$ENDIF} {$WARN SYMBOL_DEPRECATED OFF} FileAttr = SysUtils.faAnyFile and (not SysUtils.faVolumeID); {$WARN SYMBOL_DEPRECATED ON} SpecialExtensions = 'EXE,LNK,ICO,ANI,CUR,PIF,JOB,CPL'; ExeExtension = 'EXE'; - MinDate = $21; {01.01.1980} - MaxDate = $EF9F; {31.12.2099} - MinTime = 0; {00:00:00} - MaxTime = $C000; {24:00:00} type {Exceptions:} -{$IFNDEF NO_THREADS} EIUThread = class(Exception); -{$ENDIF} EDragDrop = class(Exception); EInvalidFileName = class(Exception); ERenameFileFailed = class(Exception); @@ -77,7 +67,6 @@ ERenameFileFailed = class(Exception); TDriveLetter = 'A'..'Z'; TClipboardOperation = (cboNone, cboCut, cboCopy); - TFileNameDisplay = (fndStored, fndCap, fndNoCap, fndNice); {Record for each file item:} PFileRec = ^TFileRec; @@ -106,19 +95,6 @@ TInfoCache = record ImageIndex: Integer; end; -{$IFDEF VER120} -type - TWMContextMenu = packed record - Msg: Cardinal; - hWnd: HWND; - case Integer of - 0: (XPos: Smallint; - YPos: Smallint); - 1: (Pos: TSmallPoint; - Result: Longint); - end; -{$ENDIF} - {Additional events:} type TDirViewFileSizeChanged = procedure(Sender: TObject; Item: TListItem) of object; @@ -127,22 +103,6 @@ TInfoCache = record type TDirView = class; -{$IFNDEF NO_THREADS} - TSubDirScanner = class(TCompThread) - private - FOwner: TDirView; - FStartPath: string; - FDirName: string; - FTotalSize: Int64; - - procedure ThreadTerminated(Sender: TObject); - - protected - constructor Create(Owner: TDirView; Item: TListItem); - procedure DoUpdateItem; - procedure Execute; override; - end; - { TIconUpdateThread (Fetch shell icons via thread) } TIconUpdateThread = class(TCompThread) private @@ -171,7 +131,6 @@ TIconUpdateThread = class(TCompThread) public procedure Terminate; override; end; -{$ENDIF} { TDirView } TDirView = class(TCustomDirView) @@ -180,58 +139,30 @@ TDirView = class(TCustomDirView) FConfirmOverwrite: Boolean; FUseIconCache: Boolean; FInfoCacheList: TListExt; - {$IFDEF USE_DRIVEVIEW} - FDriveView: TObject; - {$ENDIF} + FDriveView: TCustomDriveView; FChangeTimer: TTimer; FChangeInterval: Cardinal; FUseIconUpdateThread: Boolean; - {$IFNDEF NO_THREADS} FIUThreadFinished: Boolean; - {$ENDIF} FDriveType: Integer; - FAttrSpace: string; - FNoCheckDrives: string; - FSortAfterUpdate: Boolean; FCompressedColor: TColor; - FFileNameDisplay: TFileNameDisplay; FParentFolder: IShellFolder; FDesktopFolder: IShellFolder; FDirOK: Boolean; FPath: string; - FDrawLinkOverlay: Boolean; SelectNewFiles: Boolean; - FSelfDropDuplicates: Boolean; FHiddenCount: Integer; FFilteredCount: Integer; - {File selection properties:} - FSelArchive: TSelAttr; - FSelHidden: TSelAttr; - FSelSysFile: TSelAttr; - FSelReadOnly: TSelAttr; - FSelFileSizeFrom: Int64; - FSelFileSizeTo: Int64; - FSelFileDateFrom: Word; - FSelFileDateTo: Word; - FSelFileTimeFrom: Word; - FSelFileTimeTo: Word; - {shFileOperation-shell component TFileOperator:} FFileOperator: TFileOperator; {Additional thread components:} - {$IFNDEF NO_THREADS} FIconUpdateThread: TIconUpdateThread; - {$ENDIF} FDiscMonitor: TDiscMonitor; FHomeDirectory: string; - FSubDirScanner: TList; {Additional events:} - FOnFileSizeChanged: TDirViewFileSizeChanged; FOnFileIconForName: TDirViewFileIconForName; - FOnChangeDetected: TNotifyEvent; - FOnChangeInvalid: TNotifyEvent; iRecycleFolder: iShellFolder; PIDLRecycle: PItemIDList; @@ -243,9 +174,7 @@ TDirView = class(TCustomDirView) function GetHomeDirectory: string; {Drag&drop helper functions:} - {$IFNDEF NO_THREADS} procedure SignalFileDelete(Sender: TObject; Files: TStringList); - {$ENDIF} procedure PerformDragDropFileOperation(TargetPath: string; dwEffect: Integer; RenameOnCollision: Boolean); procedure SetDirColProperties(Value: TDirViewColProperties); @@ -253,10 +182,7 @@ TDirView = class(TCustomDirView) protected function NewColProperties: TCustomListViewColProperties; override; function SortAscendingByDefault(Index: Integer): Boolean; override; - procedure SetShowSubDirSize(Value: Boolean); override; - {$IFDEF USE_DRIVEVIEW} procedure Notification(AComponent: TComponent; Operation: TOperation); override; - {$ENDIF} procedure Delete(Item: TListItem); override; procedure DDError(ErrorNo: TDDError); @@ -289,32 +215,26 @@ TDirView = class(TCustomDirView) procedure ChangeInvalid(Sender: TObject; const Directory: string; const ErrorStr: string); procedure TimerOnTimer(Sender: TObject); procedure ResetItemImage(Index: Integer); - procedure SetAttrSpace(Value: string); - procedure SetNoCheckDrives(Value: string); procedure SetWatchForChanges(Value: Boolean); override; procedure AddParentDirItem; procedure AddToDragFileList(FileList: TFileList; Item: TListItem); override; - procedure SetFileNameDisplay(Value: TFileNameDisplay); virtual; function DragCompleteFileList: Boolean; override; procedure ExecuteFile(Item: TListItem); override; function GetIsRoot: Boolean; override; procedure InternalEdit(const HItem: TLVItem); override; function ItemColor(Item: TListItem): TColor; override; - function ItemDisplayName(FileName: string): string; virtual; function ItemFileExt(Item: TListItem): string; function ItemFileNameOnly(Item: TListItem): string; function ItemImageIndex(Item: TListItem; Cache: Boolean): Integer; override; function ItemIsFile(Item: TListItem): Boolean; override; function ItemIsRecycleBin(Item: TListItem): Boolean; override; function ItemMatchesFilter(Item: TListItem; const Filter: TFileFilter): Boolean; override; + function FileMatches(FileName: string; const SearchRec: TSearchRec): Boolean; function ItemOverlayIndexes(Item: TListItem): Word; override; procedure LoadFiles; override; procedure PerformItemDragDropOperation(Item: TListItem; Effect: Integer); override; procedure SortItems; override; - {$IFNDEF NO_THREADS} procedure StartFileDeleteThread; - {$ENDIF} - procedure SetShowHiddenFiles(Value: Boolean); override; procedure WMDestroy(var Msg: TWMDestroy); message WM_DESTROY; procedure CMRecreateWnd(var Message: TMessage); message CM_RECREATEWND; function SecondaryColumnHeader(Index: Integer; var AliasOnly: Boolean): Integer; override; @@ -324,10 +244,8 @@ TDirView = class(TCustomDirView) public {Runtime, readonly properties:} property DriveType: Integer read FDriveType; - {$IFDEF USE_DRIVEVIEW} {Linked component TDriveView:} - property DriveView: TObject read FDriveView write FDriveView; - {$ENDIF} + property DriveView: TCustomDriveView read FDriveView write FDriveView; { required, otherwise AV generated, when dragging columns} property Columns stored False; property ParentFolder: IShellFolder read FParentFolder; @@ -354,17 +272,13 @@ TDirView = class(TCustomDirView) function ItemFileSize(Item: TListItem): Int64; override; function ItemFileTime(Item: TListItem; var Precision: TDateTimePrecision): TDateTime; override; - {$IFNDEF NO_THREADS} {Thread handling: } procedure StartWatchThread; procedure StopWatchThread; function WatchThreadActive: Boolean; procedure StartIconUpdateThread; procedure StopIconUpdateThread; - procedure StartSubDirScanner; - procedure StopSubDirScanner; procedure TerminateThreads; - {$ENDIF} {Other additional functions: } procedure ClearIconCache; @@ -402,30 +316,6 @@ TDirView = class(TCustomDirView) procedure ExecuteDrive(Drive: TDriveLetter); property HomeDirectory: string read GetHomeDirectory write FHomeDirectory; - {Redefined functions: } - {Properties for filtering files:} - - property SelArchive: TSelAttr - read FSelArchive write FSelArchive default selDontCare; - property SelHidden: TSelAttr - read FSelHidden write FSelHidden default selDontCare; - property SelSysFile: TSelAttr - read FSelSysFile write FSelSysFile default selDontCare; - property SelReadOnly: TSelAttr - read FSelReadOnly write FSelReadOnly default selDontCare; - property SelFileSizeFrom: Int64 - read FSelFileSizeFrom write FSelFileSizeFrom; - property SelFileSizeTo: Int64 - read FSelFileSizeTo write FSelFileSizeTo default 0; - property SelFileDateFrom: Word - read FSelFileDateFrom write FSelFileDateFrom default MinDate; {01.01.1980} - property SelFileDateTo: Word - read FSelFileDateTo write FSelFileDateTo default MaxDate; {31.12.2099} - property SelFileTimeFrom: Word - read FSelFileTimeFrom write FSelFileTimeFrom; - property SelFileTimeTo: Word - read FSelFileTimeTo write FSelFileTimeTo default MaxTime; - published property DirColProperties: TDirViewColProperties read GetDirColProperties write SetDirColProperties; property PathLabel; @@ -435,10 +325,7 @@ TDirView = class(TCustomDirView) property LoadAnimation; property DimmHiddenFiles; - property ShowDirectories; property ShowHiddenFiles; - property ShowSubDirSize; - property SingleClickToExec; property WantUseDragImages; property TargetPopupMenu; property AddParentDir; @@ -477,8 +364,6 @@ TDirView = class(TCustomDirView) {Confirm overwriting files} property ConfirmOverwrite: Boolean read FConfirmOverwrite write fConfirmOverwrite default True; - property SortAfterUpdate: Boolean - read FSortAfterUpdate write FSortAfterUpdate default True; {Reload the directory after only the interval:} property ChangeInterval: Cardinal read FChangeInterval write SetChangeInterval default MSecsPerSec; @@ -491,36 +376,14 @@ TDirView = class(TCustomDirView) icon itself:} property UseIconCache: Boolean read FUseIconCache write FUseIconCache default False; - property FileNameDisplay: TFileNameDisplay - read FFileNameDisplay write SetFileNameDisplay default fndStored; - {Use this string as whitespace in the attribute column:} - property AttrSpace: string read FAttrSpace write SetAttrSpace; - {Don't watch these drives for changes:} - property NoCheckDrives: string read FNoCheckDrives write SetNoCheckDrives; {Watch current directory for filename changes (create, rename, delete files)} property WatchForChanges; - property SelfDropDuplicates: Boolean - read FSelfDropDuplicates write FSelfDropDuplicates default False; {Additional events:} - {The watchthread has detected new, renamed or deleted files} -{$IFNDEF NO_THREADS} - property OnChangeDetected: TNotifyEvent - read FOnChangeDetected write FOnChangeDetected; - {The watchthread can't watch the current directory. Occurs on novell - network drives.} - property OnChangeInvalid: TNotifyEvent - read FOnChangeInvalid write FOnChangeInvalid; -{$ENDIF} - {Set AddFile to false, if actual file should not be added to the filelist:} - property OnFileSizeChanged: TDirViewFileSizeChanged - read FOnFileSizeChanged write FOnFileSizeChanged; property OnFileIconForName: TDirViewFileIconForName read FOnFileIconForName write FOnFileIconForName; property UseSystemContextMenu; property OnContextPopup; - property OnBeginRename; - property OnEndRename; property OnHistoryChange; property OnHistoryGo; property OnPathChange; @@ -546,14 +409,12 @@ function MatchesFileExt(Ext: string; const FileExtList: string): Boolean; implementation uses -{$IFDEF USE_DRIVEVIEW} DriveView, -{$ENDIF} PIDL, Forms, Dialogs, ShellAPI, ComObj, ActiveX, ImgList, ShellDialogs, IEDriveInfo, - FileChanges, Math, PasTools, StrUtils; + FileChanges, Math, PasTools, StrUtils, Types, UITypes; var DaylightHack: Boolean; @@ -619,134 +480,6 @@ function SizeFromSRec(const SRec: SysUtils.TSearchRec): Int64; end; end; -{$IFNDEF NO_THREADS} - -{ TSubDirScanner } - -constructor TSubDirScanner.Create(Owner: TDirView; Item: TListItem); -begin - inherited Create(True); - FOwner := Owner; - FTotalSize := 0; - FStartPath := FOwner.ItemFullFileName(Item); - FDirName := Item.Caption; - FreeOnTerminate := False; - OnTerminate := ThreadTerminated; - Priority := tpLower; - Resume; -end; {Create} - -procedure TSubDirScanner.Execute; - - function ScanSubDir(Path: string): Boolean; - var - SRec: SysUtils.TSearchRec; - DosError: Integer; - SubDirs: TStringList; - Index: Integer; - FSize: Int64; - begin - Result := True; - DosError := FindFirst(Path + '*.*', faAnyFile, SRec); - if DosError = 0 then - begin - SubDirs := TStringList.Create; - try - while DosError = 0 do - begin - if Terminated then - Break; - - if (SRec.Name <> '.') and (SRec.name <> '..') then - begin - FSize := SizeFromSRec(SRec); - if FSize > 0 then - Inc(FTotalSize, FSize); - - if SRec.Attr and faDirectory <> 0 then - SubDirs.Add(IncludeTrailingPathDelimiter(Path + Srec.Name)); - end; - if not Terminated then DosError := FindNext(SRec) - else Break; - end; {While} - FindClose(SRec); - finally - try - for Index := 0 to SubDirs.Count - 1 do - begin - Result := ScanSubDir(SubDirs[Index]); - if not Result then Break; - end; - finally - SubDirs.Free; - if Result then - Result := (DosError = ERROR_NO_MORE_FILES); - end; - end; - end; - end; {ScanSubDir} - -begin {Execute} - if ScanSubDir(IncludeTrailingPathDelimiter(FStartPath)) and not Terminated then - Synchronize(DoUpdateItem); -end; {Execute} - -procedure TSubDirScanner.DoUpdateItem; -var - Item: TListItem; - StartPos: Integer; -begin - if not Terminated then - begin - StartPos := 0; - Item := nil; - while StartPos < FOwner.Items.Count do - begin - Item := FOwner.FindCaption(StartPos, FDirName, False, True, False); - if Assigned(Item) and (FOwner.ItemFullFileName(Item) = FStartPath) then - Break - else - if not Assigned(Item) then Break - else StartPos := Item.Index + 1; - end; - - if Assigned(Item) and not Terminated then - begin - PFileRec(Item.Data)^.Size := FTotalSize; - Inc(FOwner.FFilesSize, FTotalSize); - if Item.Selected then - Inc(FOwner.FFilesSelSize, FTotalSize); - FOwner.UpdateItems(Item.Index, Item.Index); - if Assigned(FOwner.OnFileSizeChanged) then - FOwner.OnFileSizeChanged(FOwner, Item); - end; - end; -end; {DoUpdateItem} - -procedure TSubDirScanner.ThreadTerminated(Sender: TObject); -var - Index: Integer; -begin - Assert(Assigned(FOwner)); - with FOwner do - for Index := 0 to FSubDirScanner.Count - 1 do - if FSubDirScanner[Index] = Self then - begin - try - FSubDirScanner.Delete(Index); - if (FSubDirScanner.Count = 0) and - (FOwner.SortColumn = Integer(dvSize)) and - not Loading then FOwner.SortItems; - finally - inherited Destroy; - end; - Exit; - end; - - Assert(False, 'TSubDirScanner failed: ' + FStartPath); - inherited Destroy; -end; {ThreadTerminated} - { TIconUpdateThread } constructor TIconUpdateThread.Create(Owner: TDirView); @@ -836,6 +569,7 @@ procedure TIconUpdateThread.Execute; if not Assigned(CurrentItemData.PIDL) then begin + ShAttr := 0; FOwner.FDesktopFolder.ParseDisplayName(FOwner.ParentForm.Handle, nil, PChar(CurrentFilePath), Eaten, CurrentItemData.PIDL, ShAttr); end; @@ -920,8 +654,6 @@ procedure TIconUpdateThread.Terminate; inherited; end; {TIconUpdateThread.Terminate} -{$ENDIF} // NO_THREADS - { TDirView } constructor TDirView.Create(AOwner: TComponent); @@ -934,16 +666,11 @@ constructor TDirView.Create(AOwner: TComponent); FDriveType := DRIVE_UNKNOWN; FUseIconCache := False; FConfirmDelete := True; - FAttrSpace := EmptyStr; - FSortAfterUpdate := True; FCompressedColor := clBlue; - FFileNameDisplay := fndStored; FParentFolder := nil; FDesktopFolder := nil; SelectNewFiles := False; - FDrawLinkOverlay := False; DragOnDriveIsMove := True; - FSelfDropDuplicates := False; FHiddenCount := 0; FFilteredCount := 0; @@ -954,7 +681,6 @@ constructor TDirView.Create(AOwner: TComponent); FPath := ''; FDiscMonitor := nil; - FSubDirScanner := TList.Create; {ChangeTimer: } if FChangeInterval = 0 then FChangeInterval := MSecsPerSec; @@ -963,15 +689,6 @@ constructor TDirView.Create(AOwner: TComponent); FChangeTimer.Enabled := False; FChangeTimer.OnTimer := TimerOnTimer; - FSelArchive := selDontCare; - FSelHidden := selDontCare; - FSelReadOnly := selDontCare; - FSelSysFile := selDontCare; - FSelFileSizeTo := 0; - FSelFileDateFrom := MinDate; - FSelFileDateTo := MaxDate; - FSelFileTimeTo := MaxTime; - {Drag&drop:} FConfirmOverwrite := True; DDLinkOnExeDrag := True; @@ -991,8 +708,6 @@ constructor TDirView.Create(AOwner: TComponent); destructor TDirView.Destroy; begin - FSubDirScanner.Free; - if Assigned(PIDLRecycle) then FreePIDL(PIDLRecycle); FInfoCacheList.Free; @@ -1007,26 +722,21 @@ procedure TDirView.WMDestroy(var Msg: TWMDestroy); begin Selected := nil; ClearItems; -{$IFNDEF NO_THREADS} TerminateThreads; -{$ENDIF} inherited; end; {WMDestroy} procedure TDirView.CMRecreateWnd(var Message: TMessage); begin - // see comment in TDirView.StopSubDirScanner + // see comment in TDirView.StopIconUpdateThread if not (csRecreating in ControlState) then begin inherited; end; end; -{$IFNDEF NO_THREADS} - procedure TDirView.TerminateThreads; begin - StopSubDirScanner; StopIconUpdateThread; StopWatchThread; if Assigned(FDiscMonitor) then @@ -1036,8 +746,6 @@ procedure TDirView.TerminateThreads; end; end; {TerminateThreads} -{$ENDIF} - function TDirView.GetHomeDirectory: string; begin if FHomeDirectory <> '' then Result := FHomeDirectory @@ -1081,13 +789,13 @@ procedure TDirView.SetPath(Value: string); if IsUncPath(Value) then raise Exception.CreateFmt(SUcpPathsNotSupported, [Value]); - if not DirectoryExists(Value) then + if not DirectoryExists(ApiPath(Value)) then raise Exception.CreateFmt(SDirNotExists, [Value]); if Assigned(FDriveView) and - (TDriveView(FDriveView).Directory <> Value) then + (FDriveView.Directory <> Value) then begin - TDriveView(FDriveView).Directory := Value; + FDriveView.Directory := Value; end else if FPath <> Value then @@ -1115,16 +823,6 @@ procedure TDirView.SetLoadEnabled(Value: Boolean); end; end; {SetLoadEnabled} -procedure TDirView.SetShowHiddenFiles(Value: Boolean); -begin - if Value <> ShowHiddenFiles then - begin - if Value then FSelHidden := selDontCare - else FSelHidden := selNo; - inherited; - end; -end; - procedure TDirView.SetCompressedColor(Value: TColor); begin if Value <> CompressedColor then @@ -1146,24 +844,6 @@ function TDirView.GetFileRec(Index: Integer): PFileRec; else Result := Items[index].Data; end; {GetFileRec} -function TDirView.ItemDisplayName(FileName: string): string; -begin - case FFileNameDisplay of - fndCap: Result := UpperCase(FileName); - fndNoCap: Result := LowerCase(FileName); - fndNice: - if (Length(FileName) > 12) or (Pos(' ', FileName) <> 0) then - Result := FileName - else - begin - Result := LowerCase(FileName); - Result[1] := Upcase(Result[1]); - end; - else - Result := FileName; - end; {Case} -end; {ItemDisplayName} - function TDirView.SecondaryColumnHeader(Index: Integer; var AliasOnly: Boolean): Integer; begin if Index = Integer(dvName) then Result := Integer(dvExt) @@ -1197,7 +877,7 @@ function TDirView.AddItem(SRec: SysUtils.TSearchRec): TListItem; FileName := SRec.Name; FileExt := UpperCase(ExtractFileExt(Srec.Name)); FileExt := Copy(FileExt, 2, Length(FileExt) - 1); - DisplayName := ItemDisplayName(FileName); + DisplayName := FileName; {$WARNINGS OFF} Attr := SRec.FindData.dwFileAttributes; {$WARNINGS ON} @@ -1239,7 +919,7 @@ procedure TDirView.AddParentDirItem; FHasParentDir := True; Item := Items.Add; New(PItem); - if FindFirst(FPath, faAnyFile, SRec) = 0 then + if FindFirst(ApiPath(FPath), faAnyFile, SRec) = 0 then FindClose(SRec); with PItem^ do begin @@ -1262,8 +942,7 @@ procedure TDirView.AddParentDirItem; IconEmpty := False; PIDL := nil; - if HasExtendedCOMCTL32 then ImageIndex := StdDirIcon - else ImageIndex := StdDirSelIcon; + ImageIndex := StdDirIcon; TypeName := SParentDir; Empty := False; @@ -1283,21 +962,7 @@ procedure TDirView.LoadFromRecycleBin(Dir: string); NewItem: TListItem; FileRec: PFileRec; FileInfo: TSHFileInfo; - FileSel: Boolean; DosError: Integer; - AttrIncludeMask: Integer; - AttrExcludeMask: Integer; - FileTimeFrom: LongWord; - FileTimeTo: LongWord; - FSize: Int64; - - procedure AddToMasks(Attr: TSelAttr; Mask: Word); - begin - case Attr of - selYes: AttrIncludeMask := AttrIncludeMask or Mask; - selNo: AttrExcludeMask := AttrExcludeMask or Mask; - end; - end; begin if not Assigned(iRecycleFolder) then @@ -1322,16 +987,6 @@ procedure TDirView.LoadFromRecycleBin(Dir: string); FHiddenCount := 0; FFilteredCount := 0; - AttrIncludeMask := 0; - AttrExcludeMask := 0; - AddToMasks(FSelArchive, SysUtils.faArchive); - AddToMasks(FSelHidden, SysUtils.faHidden); - AddToMasks(FSelReadOnly, SysUtils.faReadOnly); - AddToMasks(FSelSysFile, SysUtils.faSysFile); - - FileTimeFrom := LongWord(FSelFileDateFrom) shl 16 or FSelFileTimeFrom; - FileTimeTo := LongWord(FSelFileDateTo) shl 16 or FSelFileTimeTo; - if SUCCEEDED(iRecycleFolder.EnumObjects(Self.Handle, SHCONTF_FOLDERS or SHCONTF_NONFOLDERS or SHCONTF_INCLUDEHIDDEN, EnumList)) then begin @@ -1347,39 +1002,16 @@ procedure TDirView.LoadFromRecycleBin(Dir: string); SetLength(FullPath, StrLen(PChar(FullPath))); {Filesize, attributes and -date:} - DosError := FindFirst(FullPath, faAnyFile, SRec); + DosError := FindFirst(ApiPath(FullPath), faAnyFile, SRec); FindClose(Srec); SRec.Name := ExtractFilePath(FullPath) + SRec.Name; {Displayname:} GetShellDisplayName(iRecycleFolder, PCurrList, SHGDN_FORPARSING, DisplayName); - FileSel := (DosError = 0); - if FileSel and not (Bool(SRec.Attr and faDirectory)) then - begin - if (AttrIncludeMask <> 0) then - FileSel := Srec.Attr and AttrIncludeMask >= AttrIncludeMask; - if FileSel and (AttrExcludeMask <> 0) then - FileSel := AttrExcludeMask and Srec.Attr = 0; - - FSize := SizeFromSRec(SRec); - FileSel := - FileSel and - ((Mask = '') or - FileNameMatchesMasks( - DisplayName, False, FSize, - FileTimeToDateTime(SRec.FindData.ftLastWriteTime), - Mask, True)) and - (FSize >= FSelFileSizeFrom) and - ((FSelFileSizeTo = 0) or - (FSize <= FSelFileSizeTo)) and -{$WARN SYMBOL_DEPRECATED OFF} - (LongWord(SRec.Time) >= FileTimeFrom) and - (LongWord(SRec.Time) <= FileTimeTo); -{$WARN SYMBOL_DEPRECATED ON} - end; - - if FileSel then + if (DosError = 0) and + (((SRec.Attr and faDirectory) <> 0) or + FileMatches(DisplayName, SRec)) then begin {Filetype and icon:} SHGetFileInfo(PChar(FQPIDL), 0, FileInfo, SizeOf(FileInfo), @@ -1396,18 +1028,9 @@ procedure TDirView.LoadFromRecycleBin(Dir: string); if FileRec^.Typename = EmptyStr then FileRec^.TypeName := Format(STextFileExt, [FileRec.FileExt]); FileRec^.ImageIndex := FileInfo.iIcon; - -{$IFNDEF NO_THREADS} - if ShowSubDirSize and FileRec^.isDirectory then - FSubDirScanner.Add(TSubDirScanner.Create(Self, NewItem)); -{$ENDIF} end else begin - if (AttrExcludeMask and Srec.Attr and SysUtils.faHidden) <> 0 then - Inc(FHiddenCount) - else - Inc(FFilteredCount); FreePIDL(FQPIDL); end; @@ -1435,6 +1058,7 @@ function TDirView.GetShellFolder(Dir: string): iShellFolder; if Assigned(FDesktopFolder) then begin + Attr := 0; if Succeeded(FDesktopFolder.ParseDisplayName( ParentForm.Handle, nil, PChar(Dir), Eaten, NewPIDL, Attr)) then begin @@ -1503,6 +1127,38 @@ function TDirView.ItemMatchesFilter(Item: TListItem; const Filter: TFileFilter): FileRec^.Size, FileTimeToDateTime(FileRec^.FileTime), Filter.Masks, False))); end; +function TDirView.FileMatches(FileName: string; const SearchRec: TSearchRec): Boolean; +var + Directory: Boolean; + FileSize: Int64; +begin + Result := (ShowHiddenFiles or ((SearchRec.Attr and SysUtils.faHidden) = 0)); + if not Result then + begin + Inc(FHiddenCount); + end + else + if Mask <> '' then + begin + Directory := ((SearchRec.Attr and faDirectory) <> 0); + if Directory then FileSize := 0 + else FileSize := SizeFromSRec(SearchRec); + + Result := + FileNameMatchesMasks( + FileName, + Directory, + FileSize, + FileTimeToDateTime(SearchRec.FindData.ftLastWriteTime), + Mask, True); + + if not Result then + begin + Inc(FFilteredCount); + end; + end; +end; + function TDirView.ItemOverlayIndexes(Item: TListItem): Word; begin Result := inherited ItemOverlayIndexes(Item); @@ -1510,20 +1166,14 @@ function TDirView.ItemOverlayIndexes(Item: TListItem): Word; begin if PFileRec(Item.Data)^.IsParentDir then Inc(Result, oiDirUp); - if FDrawLinkOverlay and - (UpperCase(ItemFileExt(Item)) = '.LNK') then - Inc(Result, oiLink); end; end; procedure TDirView.Load; begin try -{$IFNDEF NO_THREADS} - StopSubDirScanner; StopIconUpdateThread; StopWatchThread; -{$ENDIF} FChangeTimer.Enabled := False; FChangeTimer.Interval := 0; @@ -1532,11 +1182,9 @@ procedure TDirView.Load; finally if DirOK and not AbortLoading then begin -{$IFNDEF NO_THREADS} if FUseIconUpdateThread and (not IsRecycleBin) then StartIconUpdateThread; StartWatchThread; -{$ENDIF} end; end; end; @@ -1545,43 +1193,13 @@ procedure TDirView.LoadFiles; var SRec: SysUtils.TSearchRec; DosError: Integer; - FileSel: Boolean; - FSize: Int64; - {$IFNDEF NO_THREADS} - NewItem: TListItem; - {$ENDIF} - AttrIncludeMask: Integer; - AttrExcludeMask: Integer; - FileTimeFrom: LongWord; - FileTimeTo: LongWord; - {$IFDEF USE_DRIVEVIEW} DirsCount: Integer; SelTreeNode: TTreeNode; Node: TTreeNode; - {$ENDIF} - - procedure AddToMasks(Attr: TSelAttr; Mask: Word); - begin - case Attr of - selYes: AttrIncludeMask := AttrIncludeMask or Mask; - selNo: AttrExcludeMask := AttrExcludeMask or Mask; - end; - end; - begin FHiddenCount := 0; FFilteredCount := 0; - AttrIncludeMask := 0; - AttrExcludeMask := 0; - AddToMasks(FSelArchive, SysUtils.faArchive); - AddToMasks(FSelHidden, SysUtils.faHidden); - AddToMasks(FSelReadOnly, SysUtils.faReadOnly); - AddToMasks(FSelSysFile, SysUtils.faSysFile); - - FileTimeFrom := LongWord(fSelFileDateFrom) shl 16 or fSelFileTimeFrom; - FileTimeTo := LongWord(fSelFileDateTo) shl 16 or fSelFileTimeTo; - try if Length(FPath) > 0 then begin @@ -1595,17 +1213,13 @@ procedure TDirView.LoadFiles; if DirOK then begin - {$IFDEF USE_DRIVEVIEW} if Assigned(FDriveView) then SelTreeNode := TDriveView(FDriveView).FindNodeToPath(FPath) else SelTreeNode := nil; - {$ENDIF} - {$IFDEF USE_DRIVEVIEW} if Assigned(FDriveView) and Assigned(SelTreeNode) then FIsRecycleBin := TNodeData(SelTreeNode.Data).IsRecycleBin else - {$ENDIF} FIsRecycleBin := (Uppercase(Copy(FPath, 2, 10)) = ':\RECYCLED') or (Uppercase(Copy(FPath, 2, 10)) = ':\RECYCLER'); @@ -1613,49 +1227,20 @@ procedure TDirView.LoadFiles; if not Assigned(FDesktopFolder) then shGetDesktopFolder(FDesktopFolder); - {$IFNDEF PHYSICALRECYCLEBIN} if IsRecycleBin then LoadFromRecycleBin(Path) else - {$ENDIF} begin FParentFolder := GetShellFolder(PathName); - DosError := SysUtils.FindFirst(IncludeTrailingPathDelimiter(FPath) + '*.*', + DosError := SysUtils.FindFirst(ApiPath(IncludeTrailingPathDelimiter(FPath) + '*.*'), FileAttr, SRec); while (DosError = 0) and (not AbortLoading) do begin if (SRec.Attr and faDirectory) = 0 then begin - FileSel := True; - FSize := SizeFromSRec(SRec); - if AttrIncludeMask <> 0 then - FileSel := (SRec.Attr and AttrIncludeMask) >= AttrIncludeMask; - if FileSel and (AttrExcludeMask <> 0) then - FileSel := ((AttrExcludeMask and Srec.Attr) = 0); - - if FileSel and - ((Mask = '') or - FileNameMatchesMasks( - SRec.Name, False, FSize, - FileTimeToDateTime(SRec.FindData.ftLastWriteTime), Mask, True)) and - (FSize >= FSelFileSizeFrom) and - ((FSelFileSizeTo = 0) or (FSize <= FSelFileSizeTo)) and -{$WARN SYMBOL_DEPRECATED OFF} - (LongWord(SRec.Time) >= FileTimeFrom) and - (LongWord(SRec.Time) <= FileTimeTo) then -{$WARN SYMBOL_DEPRECATED ON} + if FileMatches(SRec.Name, SRec) then begin - if FileSel then - begin - AddItem(SRec); - end; - end - else - begin - if (AttrExcludeMask and Srec.Attr and SysUtils.faHidden) <> 0 then - Inc(FHiddenCount) - else - Inc(FFilteredCount); + AddItem(SRec); end; end; DosError := FindNext(SRec); @@ -1668,73 +1253,40 @@ procedure TDirView.LoadFiles; end; {Search for directories:} - {$IFDEF USE_DRIVEVIEW} DirsCount := 0; - {$ENDIF} - if ShowDirectories then + DosError := SysUtils.FindFirst(ApiPath(IncludeTrailingPathDelimiter(FPath) + '*.*'), + DirAttrMask, SRec); + while (DosError = 0) and (not AbortLoading) do begin - DosError := SysUtils.FindFirst(IncludeTrailingPathDelimiter(FPath) + '*.*', - DirAttrMask, SRec); - while (DosError = 0) and (not AbortLoading) do + if (SRec.Name <> '.') and (SRec.Name <> '..') and + ((Srec.Attr and faDirectory) <> 0) then begin - FileSel := True; - if AttrIncludeMask <> 0 then - FileSel := ((SRec.Attr and AttrIncludeMask) = AttrIncludeMask); - if FileSel and (AttrExcludeMask <> 0) then - FileSel := ((AttrExcludeMask and SRec.Attr) = 0); - - if (SRec.Name <> '.') and (SRec.Name <> '..') and - ((Srec.Attr and faDirectory) <> 0) then + Inc(DirsCount); + + if FileMatches(SRec.Name, SRec) then begin - {$IFDEF USE_DRIVEVIEW} - Inc(DirsCount); - {$ENDIF} - - if FileSel and - ((Mask = '') or - FileNameMatchesMasks( - SRec.Name, True, 0, - FileTimeToDateTime(SRec.FindData.ftLastWriteTime), Mask, True)) then - begin - {$IFNDEF NO_THREADS} - NewItem := - {$ENDIF} - AddItem(Srec); - {$IFNDEF NO_THREADS} - if ShowSubDirSize then - FSubDirScanner.Add(TSubDirScanner.Create(Self, NewItem)); - {$ENDIF} - end - else - begin - if (AttrExcludeMask and Srec.Attr and SysUtils.faHidden) <> 0 then - Inc(FHiddenCount) - else - Inc(FFilteredCount); - end; + AddItem(Srec); end; - DosError := FindNext(SRec); end; - SysUtils.FindClose(SRec); + DosError := FindNext(SRec); + end; + SysUtils.FindClose(SRec); - {$IFDEF USE_DRIVEVIEW} - {Update TDriveView's subdir indicator:} - if Assigned(FDriveView) and (FDriveType = DRIVE_REMOTE) then - with FDriveView as TDriveView do + {Update TDriveView's subdir indicator:} + if Assigned(FDriveView) and (FDriveType = DRIVE_REMOTE) then + with TDriveView(FDriveView) do + begin + Node := FindNodeToPath(PathName); + if Assigned(Node) and Assigned(Node.Data) and + not TNodeData(Node.Data).Scanned then begin - Node := FindNodeToPath(PathName); - if Assigned(Node) and Assigned(Node.Data) and - not TNodeData(Node.Data).Scanned then + if DirsCount = 0 then begin - if DirsCount = 0 then - begin - Node.HasChildren := False; - TNodeData(Node.Data).Scanned := True; - end; + Node.HasChildren := False; + TNodeData(Node.Data).Scanned := True; end; end; - {$ENDIF} - end; {If FShowDirectories} + end; end; {not isRecycleBin} end else FIsRecycleBin := False; @@ -1759,9 +1311,6 @@ TEFileRec = record EItems: TStringList; FItems: TStringList; NewItems: TStringList; - {$IFNDEF NO_THREADS} - NewItem: TListItem; - {$ENDIF} Srec: SysUtils.TSearchRec; DosError: Integer; PSrec: ^SysUtils.TSearchRec; @@ -1771,23 +1320,9 @@ TEFileRec = record PUpdate: Boolean; PEFile: PEFileRec; SaveCursor: TCursor; - FileTimeFrom: LongWord; - FileTimeTo: LongWord; - AttrIncludeMask: Integer; - AttrExcludeMask: Integer; - FileSel: Boolean; FSize: Int64; FocusedIsVisible: Boolean; R: TRect; - - procedure AddToMasks(Attr: TSelAttr; Mask: Word); - begin - case Attr of - selYes: AttrIncludeMask := AttrIncludeMask or Mask; - selNo: AttrExcludeMask := AttrExcludeMask or Mask; - end; - end; - begin if (not Loading) and LoadEnabled then begin @@ -1819,7 +1354,7 @@ TEFileRec = record else // vsIcon and vsSmallIcon FocusedIsVisible := IntersectRect(R, - Rect(ViewOrigin, Point(ViewOrigin.X + ClientWidth, ViewOrigin.Y + ClientHeight)), + Classes.Rect(ViewOrigin, Point(ViewOrigin.X + ClientWidth, ViewOrigin.Y + ClientHeight)), ItemFocused.DisplayRect(drBounds)); end; end @@ -1840,16 +1375,6 @@ TEFileRec = record FHiddenCount := 0; FFilteredCount := 0; - AttrIncludeMask := 0; - AttrExcludeMask := 0; - AddToMasks(FSelArchive, SysUtils.faArchive); - AddToMasks(FSelHidden, SysUtils.faHidden); - AddToMasks(FSelReadOnly, SysUtils.faReadOnly); - AddToMasks(FSelSysFile, SysUtils.faSysFile); - - FileTimeFrom := LongWord(fSelFileDateFrom) shl 16 or fSelFileTimeFrom; - FileTimeTo := LongWord(fSelFileDateTo) shl 16 or fSelFileTimeTo; - try {Store existing files and directories:} for Index := 0 to Items.Count - 1 do @@ -1866,33 +1391,13 @@ TEFileRec = record end; EItems.Sort; - DosError := SysUtils.FindFirst(IncludeTrailingPathDelimiter(FPath) + '*.*', + DosError := SysUtils.FindFirst(ApiPath(IncludeTrailingPathDelimiter(FPath) + '*.*'), FileAttr, SRec); while DosError = 0 do begin if (SRec.Attr and faDirectory) = 0 then begin - FileSel := True; - if (AttrIncludeMask <> 0) then - FileSel := ((SRec.Attr and AttrIncludeMask) = AttrIncludeMask); - if FileSel and (AttrExcludeMask <> 0) then - FileSel := ((AttrExcludeMask and Srec.Attr) = 0); - - FSize := SizeFromSRec(SRec); - FileSel := - FileSel and - ((Mask = '') or - FileNameMatchesMasks( - SRec.Name, False, FSize, - FileTimeToDateTime(SRec.FindData.ftLastWriteTime), Mask, True)) and - (FSize >= FSelFileSizeFrom) and - ((FSelFileSizeTo = 0) or (FSize <= FSelFileSizeTo)) and -{$WARN SYMBOL_DEPRECATED OFF} - (LongWord(SRec.Time) >= FileTimeFrom) and - (LongWord(SRec.Time) <= FileTimeTo); -{$WARN SYMBOL_DEPRECATED ON} - - if FileSel then + if FileMatches(SRec.Name, SRec) then begin ItemIndex := -1; if not EItems.Find(SRec.Name, ItemIndex) then @@ -1904,6 +1409,7 @@ TEFileRec = record end else begin + FSize := SizeFromSRec(SRec); with PEFileRec(EItems.Objects[ItemIndex])^ do {$WARNINGS OFF} if (iSize <> FSize) or (iAttr <> SRec.Attr) or @@ -1926,8 +1432,6 @@ TEFileRec = record {$WARNINGS OFF} FileTime := SRec.FindData.ftLastWriteTime; {$WARNINGS ON} - if (iSize <> FSize) and Assigned(OnFileSizeChanged) then - OnFileSizeChanged(Self, Items[iIndex]); end; // alternative to TListItem.Update (which causes flicker) R := Items[iIndex].DisplayRect(drBounds); @@ -1937,58 +1441,26 @@ TEFileRec = record FItems.Add(Srec.Name); end; end; - - if not FileSel then - begin - if ((AttrExcludeMask and Srec.Attr and SysUtils.faHidden) <> 0) then - Inc(FHiddenCount) - else - Inc(FFilteredCount); - end; end; DosError := FindNext(Srec); end; SysUtils.FindClose(Srec); {Search new directories:} - if ShowDirectories then + DosError := SysUtils.FindFirst(ApiPath(FPath + '\*.*'), DirAttrMask, SRec); + while DosError = 0 do begin - DosError := SysUtils.FindFirst(FPath + '\*.*', DirAttrMask, SRec); - while DosError = 0 do + if (Srec.Attr and faDirectory) <> 0 then begin - if (Srec.Attr and faDirectory) <> 0 then + if (SRec.Name <> '.') and (SRec.Name <> '..') then begin - FileSel := True; - if AttrIncludeMask <> 0 then - FileSel := ((SRec.Attr and AttrIncludeMask) = AttrIncludeMask); - if FileSel and (AttrExcludeMask <> 0) then - FileSel := ((AttrExcludeMask and SRec.Attr) = 0); - - if (SRec.Name <> '.') and (SRec.Name <> '..') then + if not EItems.Find(SRec.Name, ItemIndex) then begin - if not EItems.Find(SRec.Name, ItemIndex) then - begin - if FileSel and - ((Mask = '') or - FileNameMatchesMasks( - SRec.Name, True, 0, - FileTimeToDateTime(SRec.FindData.ftLastWriteTime), Mask, True)) then - begin - New(PSrec); - PSrec^ := SRec; - NewItems.AddObject(Srec.Name, Pointer(PSrec)); - FItems.Add(SRec.Name); - end - else - begin - if (AttrExcludeMask and Srec.Attr and SysUtils.faHidden) <> 0 then - Inc(FHiddenCount) - else - Inc(FFilteredCount); - end; - end - else + if FileMatches(SRec.Name, SRec) then begin + New(PSrec); + PSrec^ := SRec; + NewItems.AddObject(Srec.Name, Pointer(PSrec)); FItems.Add(SRec.Name); end; end @@ -1996,12 +1468,15 @@ TEFileRec = record begin FItems.Add(SRec.Name); end; + end + else + begin + FItems.Add(SRec.Name); end; - DosError := FindNext(SRec); end; - SysUtils.FindClose(SRec); - end; {If FShowDirectories} - + DosError := FindNext(SRec); + end; + SysUtils.FindClose(SRec); {Check wether displayed Items still exists:} FItems.Sort; @@ -2042,22 +1517,14 @@ TEFileRec = record end; AnyUpdate := True; PSrec := Pointer(NewItems.Objects[Index]); - {$IFNDEF NO_THREADS} - NewItem := - {$ENDIF} AddItem(PSrec^); - {$IFNDEF NO_THREADS} - if ShowSubDirSize and ((PSrec^.Attr and faDirectory) <> 0) then - FSubDirScanner.Add(TSubDirScanner.Create(Self, NewItem)); - {$ENDIF} Dispose(PSrec); end; NewItems.Free; // if we are sorted by name and there were only updates to existing // items, there is no need for sorting - if SortAfterUpdate and - (PUpdate or - (AnyUpdate and (DirColProperties.SortDirColumn <> dvName))) then + if PUpdate or + (AnyUpdate and (DirColProperties.SortDirColumn <> dvName)) then begin SortItems; end; @@ -2066,16 +1533,12 @@ TEFileRec = record finally FDirOK := True; FDirty := false; -{$IFNDEF NO_THREADS} if FUseIconUpdateThread and (not FisRecycleBin) then StartIconUpdateThread; StartWatchThread; -{$ENDIF} // make focused item visible, only if it was before if FocusedIsVisible and Assigned(ItemFocused) then ItemFocused.MakeVisible(False); - if AnyUpdate and Assigned(OnDirUpdated) then - OnDirUpdated(Self); UpdateStatusBar; @@ -2084,7 +1547,7 @@ TEFileRec = record end; {Finally} end; - if Assigned(FDriveView) and Assigned(TDriveView(FDriveView).Selected) then + if Assigned(FDriveView) then begin TDriveView(FDriveView).ValidateCurrentDirectoryIfNotMonitoring; end; @@ -2149,7 +1612,7 @@ function TDirView.GetAttrString(Attr: Integer): string; if (Attr and Attrs[Index] <> 0) then Result := Result + AttrChars[Index] else - Result := Result + FAttrSpace; + Result := Result; end; end; {GetAttrString} @@ -2192,6 +1655,7 @@ procedure TDirView.GetDisplayData(Item: TListItem; FetchIcon: Boolean); if not Assigned(PIDL) and IsSpecialExt then begin try + ShAttr := 0; FDesktopFolder.ParseDisplayName(ParentForm.Handle, nil, PChar(FPath + '\' + FileName), Eaten, PIDL, ShAttr); @@ -2378,18 +1842,12 @@ function TDirView.DeleteSelectedFiles(AllowUndo: Boolean): Boolean; UpdateEnabled: Boolean; WatchDir: Boolean; Updating: Boolean; - {$IFDEF USE_DRIVEVIEW} DirDeleted: Boolean; - {$ENDIF} begin AllowUndo := AllowUndo and (not IsRecycleBin); - {$IFDEF USE_DRIVEVIEW} DirDeleted := False; -{$IFNDEF NO_THREADS} if Assigned(FDriveView) then TDriveView(FDriveView).StopWatchThread; -{$ENDIF} - {$ENDIF} WatchDir := WatchForChanges; WatchForChanges := False; UpdateEnabled := (SelCount < MaxSel); @@ -2409,10 +1867,7 @@ function TDirView.DeleteSelectedFiles(AllowUndo: Boolean): Boolean; if AllowUndo then FileOperator.Flags := FileOperator.Flags + [foAllowUndo]; -{$IFNDEF NO_THREADS} StopIconUpdateThread; - StopSubDirScanner; -{$ENDIF} Result := FileOperator.Execute; Result := Result and (not FileOperator.OperationAborted); Sleep(0); @@ -2426,9 +1881,7 @@ function TDirView.DeleteSelectedFiles(AllowUndo: Boolean): Boolean; True: if not DirExists(ItemFullFileName(Item)) then begin - {$IFDEF USE_DRIVEVIEW} DirDeleted := True; - {$ENDIF} Item.Delete; end; False: @@ -2451,26 +1904,17 @@ function TDirView.DeleteSelectedFiles(AllowUndo: Boolean): Boolean; if not UpdateEnabled then Items.EndUpdate; FileOperator.Free; - if Assigned(OnDirUpdated) then - OnDirUpdated(Self); end; - {$IFDEF USE_DRIVEVIEW} if Assigned(DriveView) then - with TDriveView(DriveView) do + with DriveView do begin if DirDeleted and Assigned(Selected) then ValidateDirectory(Selected); -{$IFNDEF NO_THREADS} - TDriveView(fDriveView).StartWatchThread; -{$ENDIF} + TDriveView(FDriveView).StartWatchThread; end; - {$ENDIF} -{$IFNDEF NO_THREADS} if UseIconUpdateThread then StartIconUpdateThread; - if ShowSubDirSize then StartSubDirScanner; -{$ENDIF} WatchForChanges := WatchDir; @@ -2792,15 +2236,12 @@ procedure TDirView.SortItems; begin if HandleAllocated then begin -{$IFNDEF NO_THREADS} StopIconUpdateThread; -{$ENDIF} try case DirColProperties.SortDirColumn of dvName: SortProc := @CompareFilename; dvSize: SortProc := @CompareFileSize; - dvType: if not SortByExtension then SortProc := @CompareFileType - else SortProc := @CompareFileExt; + dvType: SortProc := @CompareFileType; dvChanged: SortProc := @CompareFileTime; dvAttr: SortProc := @CompareFileAttr; dvExt: SortProc := @CompareFileExt; @@ -2808,10 +2249,8 @@ procedure TDirView.SortItems; end; CustomSortItems(Pointer(@SortProc)); finally -{$IFNDEF NO_THREADS} if (not Loading) and FUseIconUpdateThread then StartIconUpdateThread; -{$ENDIF} end; end end; @@ -2823,11 +2262,9 @@ procedure TDirView.ValidateFile(Item : TListItem); if Assigned(Item) and Assigned(Item.Data) then begin Index := Item.Index; - if not FileExists(ItemFullFileName(Items[Index])) then + if not FileExists(ApiPath(ItemFullFileName(Items[Index]))) then begin Item.Delete; - if Assigned(OnDirUpdated) then - OnDirUpdated(Self); end; end; end; {ValidateFile} @@ -2849,23 +2286,21 @@ procedure TDirView.ValidateSelectedFiles; i: Integer; ToDelete: Boolean; Updating: Boolean; - Deleted: Boolean; Item: TListItem; begin if SelCount > 50 then Reload2 else begin Updating := False; - Deleted := False; FileList := CustomCreateFileList(True, False, True, nil, True); try for i := 0 to FileList.Count - 1 do begin Item := TListItem(FileList.Objects[i]); if ItemIsDirectory(Item) then - ToDelete := not DirectoryExists(FileList[i]) + ToDelete := not DirectoryExists(ApiPath(FileList[i])) else - ToDelete := not FileExists(FileList[i]); + ToDelete := not FileExists(ApiPath(FileList[i])); if ToDelete then begin @@ -2875,15 +2310,12 @@ procedure TDirView.ValidateSelectedFiles; Updating := True; end; Item.Delete; - Deleted := True; end; end; finally if Updating then Items.EndUpdate; FileList.Free; - if Deleted and Assigned(OnDirUpdated) then - OnDirUpdated(Self); end; end; end; {ValidateSelectedFiles} @@ -2898,17 +2330,15 @@ function TDirView.CreateFile(NewName: string): TListItem; NewName := Path + '\' + NewName; {Ermitteln des neuen Dateinamens:} - if not FileExists(NewName) then + if not FileExists(ApiPath(NewName)) then begin -{$IFNDEF NO_THREADS} if FWatchForChanges then StopWatchThread; StopIconUpdateThread; -{$ENDIF} try {Create the desired file as empty file:} - AssignFile(F, NewName); + AssignFile(F, ApiPath(NewName)); Rewrite(F); LastIOResult := IOResult; if LastIOResult = 0 then @@ -2916,24 +2346,20 @@ function TDirView.CreateFile(NewName: string): TListItem; CloseFile(F); {Anlegen der Datei als TListItem:} - if FindFirst(NewName, faAnyFile, SRec) = 0 then + if FindFirst(ApiPath(NewName), faAnyFile, SRec) = 0 then begin Result := AddItem(SRec); ItemFocused := FindFileItem(GetFileRec(Result.Index)^.FileName); if Assigned(ItemFocused) then ItemFocused.MakeVisible(False); - if Assigned(OnDirUpdated) then - OnDirUpdated(Self); end; FindClose(Srec); end; finally -{$IFNDEF NO_THREADS} if FUseIconUpdateThread then StartIconUpdateThread; if WatchForChanges then StartWatchThread; -{$ENDIF} end; end else LastIOResult := 183; @@ -2948,25 +2374,21 @@ procedure TDirView.CreateDirectory(DirName: string); if Copy(DirName, 2, 1) <> ':' then DirName := Path + '\' + DirName; -{$IFNDEF NO_THREADS} if WatchForChanges then StopWatchThread; - {$IFDEF USE_DRIVEVIEW} if Assigned(FDriveView) then TDriveView(FDriveView).StopWatchThread; - {$ENDIF} StopIconUpdateThread; -{$ENDIF} try {create the phyical directory:} - Win32Check(Windows.CreateDirectory(PChar(DirName), nil)); + Win32Check(Windows.CreateDirectory(PChar(ApiPath(DirName)), nil)); if IncludeTrailingBackslash(ExtractFilePath(ExpandFileName(DirName))) = IncludeTrailingBackslash(Path) then begin {Create the TListItem:} - if FindFirst(DirName, faAnyFile, SRec) = 0 then + if FindFirst(ApiPath(DirName), faAnyFile, SRec) = 0 then begin Item := AddItem(SRec); ItemFocused := FindFileItem(GetFileRec(Item.Index)^.FileName); @@ -2975,25 +2397,19 @@ procedure TDirView.CreateDirectory(DirName: string); begin ItemFocused.MakeVisible(False); end; - if Assigned(OnDirUpdated) then - OnDirUpdated(Self); end; FindClose(SRec); end; finally -{$IFNDEF NO_THREADS} if FUseIconUpdateThread then StartIconUpdateThread; if WatchForChanges then StartWatchThread; -{$ENDIF} - {$IFDEF USE_DRIVEVIEW} if Assigned(FDriveView) then - with FDriveView as TDriveView do + with FDriveView do if not WatchThreadActive and Assigned(Selected) then ValidateDirectory(Selected); - {$ENDIF} end; end; {CreateDirectory} @@ -3015,9 +2431,7 @@ procedure TDirView.DisplayContextMenu(Where: TPoint); GetDir(0, DefDir); ChDir(PathName); Verb := EmptyStr; -{$IFNDEF NO_THREADS} StopWatchThread; -{$ENDIF} try if Assigned(OnContextPopup) then begin @@ -3160,9 +2574,7 @@ procedure TDirView.DisplayContextMenu(Where: TPoint); if DiffSelectedPath then begin -{$IFNDEF NO_THREADS} StartFileDeleteThread; -{$ENDIF} Exit; end; end; @@ -3171,9 +2583,7 @@ procedure TDirView.DisplayContextMenu(Where: TPoint); ValidateSelectedFiles; finally -{$IFNDEF NO_THREADS} StartWatchThread; -{$ENDIF} end; end; @@ -3196,7 +2606,6 @@ procedure TDirView.GetDisplayInfo(ListItem: TListItem; GetDisplayData(ListItem, True); {Set IconUpdatethread :} -{$IFNDEF NO_THREADS} if IconEmpty and Assigned(FIconUpdateThread) then begin if Assigned(TopItem) then @@ -3209,7 +2618,6 @@ procedure TDirView.GetDisplayInfo(ListItem: TListItem; if FIconUpdateThread.Suspended and not FIsRecycleBin then FIconUpdateThread.Resume; end; -{$ENDIF} if (DispInfo.Mask and LVIF_TEXT) <> 0 then begin @@ -3219,25 +2627,14 @@ procedure TDirView.GetDisplayInfo(ListItem: TListItem; begin case TDirViewCol(iSubItem) of dvSize: {Size: } - if not IsDirectory or - (IsDirectory and ShowSubDirSize and (Size >= 0)) then - StrPLCopy(pszText, FormatBytes(Size, FormatSizeBytes, FormatSizeBytes), cchTextMax); + if not IsDirectory then + StrPLCopy(pszText, FormatPanelBytes(Size, FormatSizeBytes), cchTextMax); dvType: {FileType: } - if SortByExtension and (not IsDirectory) then - begin - case FFileNameDisplay of - fndNoCap, fndNice: StrPLCopy(pszText, LowerCase(FileExt), cchTextMax); - else StrPLCopy(pszText, FileExt, cchTextMax); - end; {Case} - end - else StrPLCopy(pszText, TypeName, cchTextMax); + StrPLCopy(pszText, TypeName, cchTextMax); dvChanged: {Date} StrPLCopy(pszText, FormatFileTime(FileTime), cchTextMax); dvAttr: {Attrs:} - if FFileNameDisplay = fndCap then - StrPLCopy(pszText, UpperCase(GetAttrString(Attr)), cchTextMax) - else - StrPLCopy(pszText, GetAttrString(Attr), cchTextMax); + StrPLCopy(pszText, GetAttrString(Attr), cchTextMax); dvExt: StrPLCopy(pszText, FileExt, cchTextMax); end {Case} @@ -3267,8 +2664,6 @@ function TDirView.ItemColor(Item: TListItem): TColor; Result := clDefaultItemColor; end; -{$IFNDEF NO_THREADS} - procedure TDirView.StartFileDeleteThread; var Files: TStringList; @@ -3301,40 +2696,6 @@ procedure TDirView.StartIconUpdateThread; end; end; {StartIconUpdateThread} -procedure TDirView.StartSubDirScanner; -var - Index: Integer; -begin - if not (csDesigning in ComponentState) and - DirOk and ShowDirectories and ShowSubDirSize then - for Index := 0 to Items.Count - 1 do - with PFileRec(Items[Index].Data)^ do - if IsDirectory and not isParentDir then - FSubDirScanner.Add(TSubDirScanner.Create(Self, Items[Index])); -end; {StartSubDirScanner} - -procedure TDirView.StopSubDirScanner; -var - Index: Integer; -begin - for Index := 0 To FSubDirScanner.Count - 1 do - if Assigned(FSubDirScanner[Index]) then - with TSubDirScanner(FSubDirScanner[Index]) do - begin - Priority := tpHigher; - Resume; - Terminate; - end; - - // Not really sure why this is here, but definitelly, when recreating - // the dir view, it may cause recursion calls back to destroyed dir view, - // causing AVs. - // May not be necessary anymore after the recursion check in - // TDirView.CMRecreateWnd - if not (csRecreating in ControlState) then - Application.ProcessMessages; -end; {StopSubDirScanner} - procedure TDirView.StopIconUpdateThread; var Counter: Integer; @@ -3353,7 +2714,11 @@ procedure TDirView.StopIconUpdateThread; while not FIUThreadFinished do begin Sleep(10); - // See comment in StopSubDirScanner + // Not really sure why this is here, but definitelly, when recreating + // the dir view, it may cause recursion calls back to destryed dir view, + // causing AVs + // May not be necessary anymore after the recursion check in + // TDirView.CMRecreateWnd if not (csRecreating in ControlState) then Application.ProcessMessages; Inc(Counter); @@ -3381,8 +2746,7 @@ procedure TDirView.StopWatchThread; procedure TDirView.StartWatchThread; begin - if (Length(Path) > 0) and WatchForChanges and DirOK and - (Pos(Path[1], NoCheckDrives) = 0) then + if (Length(Path) > 0) and WatchForChanges and DirOK then begin if not Assigned(FDiscMonitor) then begin @@ -3406,8 +2770,6 @@ procedure TDirView.StartWatchThread; end; end; {StartWatchThread} -{$ENDIF} - procedure TDirView.TimerOnTimer(Sender: TObject); begin if not Loading then @@ -3416,9 +2778,7 @@ procedure TDirView.TimerOnTimer(Sender: TObject); FChangeTimer.Enabled := False; FChangeTimer.Interval := 0; Reload2; - if Assigned(FOnChangeDetected) then - FOnChangeDetected(Self); - end + end; end; {TimerOnTimer} procedure TDirView.ChangeDetected(Sender: TObject; const Directory: string; @@ -3438,20 +2798,14 @@ procedure TDirView.ChangeInvalid(Sender: TObject; const Directory: string; const ErrorStr: string); begin FDiscMonitor.Close; - if Assigned(FOnChangeInvalid) then - FOnChangeInvalid(Self); end; {ChangeInvalid} -{$IFNDEF NO_THREADS} - function TDirView.WatchThreadActive: Boolean; begin Result := WatchForChanges and Assigned(FDiscMonitor) and FDiscMonitor.Active and FDiscMonitor.Enabled; end; {WatchThreadActive} -{$ENDIF} - procedure TDirView.SetChangeInterval(Value: Cardinal); begin if Value > 0 then @@ -3461,15 +2815,6 @@ procedure TDirView.SetChangeInterval(Value: Cardinal); end; end; {SetChangeInterval} -procedure TDirView.SetFileNameDisplay(Value: TFileNameDisplay); -begin - if Value <> FileNameDisplay then - begin - FFileNameDisplay := Value; - if DirOK then Reload(True); - end; -end; {SetFileNameDisplay} - procedure TDirView.SetDirColProperties(Value: TDirViewColProperties); begin if Value <> ColProperties then @@ -3481,28 +2826,6 @@ function TDirView.GetDirColProperties: TDirViewColProperties; Result := TDirViewColProperties(ColProperties); end; -procedure TDirView.SetShowSubDirSize(Value: Boolean); -begin - if Value <> ShowSubDirSize then - begin - inherited; - if Value then - begin - {$IFNDEF NO_THREADS} - if ShowDirectories then - StartSubDirScanner; - {$ENDIF} - end - else - begin - {$IFNDEF NO_THREADS} - StopSubDirScanner; - {$ENDIF} - Invalidate; - end; - end; -end; {SetShowSubDirSize} - procedure TDirView.SetWatchForChanges(Value: Boolean); begin if WatchForChanges <> Value then @@ -3510,10 +2833,8 @@ procedure TDirView.SetWatchForChanges(Value: Boolean); FWatchForChanges := Value; if not (csDesigning in ComponentState) then begin -{$IFNDEF NO_THREADS} if Value then StartWatchThread else StopWatchThread; -{$ENDIF} end; end; end; {SetWatchForChanges} @@ -3564,9 +2885,7 @@ procedure TDirView.ExecuteFile(Item: TListItem); var DefDir: string; FileName: string; - {$IFDEF USE_DRIVEVIEW} Node: TTreeNode; - {$ENDIF} begin if (UpperCase(PFileRec(Item.Data)^.FileExt) = 'LNK') or PFileRec(Item.Data)^.IsDirectory then @@ -3577,11 +2896,9 @@ procedure TDirView.ExecuteFile(Item: TListItem); if not DirExists(FileName) then begin Reload2; - {$IFDEF USE_DRIVEVIEW} - if Assigned(FDriveView) and Assigned(TDriveView(FDriveView).Selected) then - with FDriveView as TDriveView do + if Assigned(FDriveView) and Assigned(FDriveView.Selected) then + with FDriveView do ValidateDirectory(Selected); - {$ENDIF} Exit; end; end @@ -3590,9 +2907,8 @@ procedure TDirView.ExecuteFile(Item: TListItem); if DirExists(FileName) then begin - {$IFDEF USE_DRIVEVIEW} if Assigned(FDriveView) then - with (FDriveView as TDriveView) do + with TDriveView(FDriveView) do begin Node := FindNodeToPath(FileName); if not Assigned(Node) then @@ -3608,14 +2924,13 @@ procedure TDirView.ExecuteFile(Item: TListItem); Exit; end else - {$ENDIF} begin Path := FileName; Exit; end; end else - if not FileExists(FileName) then + if not FileExists(ApiPath(FileName)) then begin Exit; end; @@ -3639,7 +2954,7 @@ procedure TDirView.ExecuteDrive(Drive: TDriveLetter); if FLastPath[Drive] <> '' then begin APath := FLastPath[Drive]; - if not DirectoryExists(APath) then + if not DirectoryExists(ApiPath(APath)) then APath := Format('%s:', [Drive]); end else @@ -3661,13 +2976,11 @@ procedure TDirView.ExecuteParentDirectory; begin if Valid then begin - {$IFDEF USE_DRIVEVIEW} - if Assigned(DriveView) and Assigned(TDriveView(DriveView).Selected) then + if Assigned(DriveView) and Assigned(DriveView.Selected) then begin - TDriveView(DriveView).Selected := TDriveView(DriveView).Selected.Parent + DriveView.Selected := DriveView.Selected.Parent end else - {$ENDIF} begin Path := ExtractFilePath(Path); end; @@ -3706,23 +3019,15 @@ procedure TDirView.InternalEdit(const HItem: TLVItem); Item: TListItem; Info: string; NewCaption: string; - {$IFDEF USE_DRIVEVIEW} IsDirectory: Boolean; - {$ENDIF} begin Item := GetItemFromHItem(HItem); - {$IFDEF USE_DRIVEVIEW} IsDirectory := DirExists(ItemFullFileName(Item)); - {$ENDIF} NewCaption := HItem.pszText; -{$IFNDEF NO_THREADS} StopWatchThread; - {$IFDEF USE_DRIVEVIEW} if IsDirectory and Assigned(FDriveView) then TDriveView(FDriveView).StopWatchThread; - {$ENDIF} -{$ENDIF} with FFileOperator do begin @@ -3737,12 +3042,10 @@ procedure TDirView.InternalEdit(const HItem: TLVItem); try if FFileOperator.Execute then begin - {$IFDEF USE_DRIVEVIEW} if IsDirectory and Assigned(FDriveView) then - with (FDriveView as TDriveView) do + with FDriveView do if Assigned(Selected) then ValidateDirectory(Selected); - {$ENDIF} with GetFileRec(Item.Index)^ do begin @@ -3781,14 +3084,10 @@ procedure TDirView.InternalEdit(const HItem: TLVItem); finally Sleep(0); LoadEnabled := True; -{$IFNDEF NO_THREADS} if FWatchForChanges and (not WatchThreadActive) then StartWatchThread; - {$IFDEF USE_DRIVEVIEW} if Assigned(FDriveView) then TDriveView(FDriveView).StartWatchThread; - {$ENDIF} -{$ENDIF} end; end; @@ -3836,14 +3135,12 @@ function TDirView.ItemImageIndex(Item: TListItem; else Result := -1; end; -{$IFDEF USE_DRIVEVIEW} procedure TDirView.Notification(AComponent: TComponent; Operation: TOperation); begin inherited Notification(AComponent, Operation); if (Operation = opRemove) and (AComponent = FDriveView) then FDriveView := nil; end; {Notification} -{$ENDIF} procedure TDirView.ReloadDirectory; begin @@ -3869,23 +3166,8 @@ procedure TDirView.ResetItemImage(Index: Integer); end; {With} end; {ResetItemImage} -procedure TDirView.SetAttrSpace(Value: string); -begin - if Value <> FAttrSpace then - begin - FAttrSpace := Value; - Invalidate; - end; -end; {SetAttrSpace} - -procedure TDirView.SetNoCheckDrives(Value: string); -begin - FNoCheckDrives := UpperCase(Value); -end; {SetNoCheckDrives} - { Drag&Drop handling } -{$IFNDEF NO_THREADS} procedure TDirView.SignalFileDelete(Sender: TObject; Files: TStringList); {Called by TFileDeleteThread, when a file was deleted by the Drag&Drop target window:} var @@ -3895,13 +3177,10 @@ procedure TDirView.SignalFileDelete(Sender: TObject; Files: TStringList); for Index := 0 to Files.Count - 1 do ValidateFile(Files[Index]); end; -{$ENDIF} procedure TDirView.DDMenuPopup(Sender: TObject; AMenu: HMenu; DataObj: IDataObject; AMinCustCmd: Integer; grfKeyState: Longint; pt: TPoint); begin -{$IFNDEF NO_THREADS} - {$IFDEF USE_DRIVEVIEW} if Assigned(FDriveView) then begin // When a change is detected while menu is popped up @@ -3912,28 +3191,22 @@ procedure TDirView.DDMenuPopup(Sender: TObject; AMenu: HMenu; DataObj: IDataObje // This is HACK, we should implement some uniform watch disabling/enabling TDriveView(FDriveView).SuspendChangeTimer; end; - {$ENDIF} -{$ENDIF} inherited; end; procedure TDirView.DDMenuDone(Sender: TObject; AMenu: HMenu); begin -{$IFNDEF NO_THREADS} if not WatchThreadActive then begin FChangeTimer.Interval := Min(FChangeInterval * 2, 3000); FChangeTimer.Enabled := True; end; - {$IFDEF USE_DRIVEVIEW} if Assigned(FDriveView) then begin TDriveView(FDriveView).ResumeChangeTimer; end; - {$ENDIF} -{$ENDIF} inherited; end; @@ -3941,19 +3214,15 @@ procedure TDirView.DDMenuDone(Sender: TObject; AMenu: HMenu); procedure TDirView.DDDropHandlerSucceeded(Sender: TObject; grfKeyState: Longint; Point: TPoint; dwEffect: Longint); begin -{$IFNDEF NO_THREADS} if not WatchThreadActive then begin FChangeTimer.Interval := FChangeInterval; FChangeTimer.Enabled := True; end; - {$IFDEF USE_DRIVEVIEW} if Assigned(FDriveView) then begin TDriveView(FDriveView).ResumeChangeTimer; end; - {$ENDIF} -{$ENDIF} inherited; end; @@ -3980,29 +3249,23 @@ procedure TDirView.AddToDragFileList(FileList: TFileList; Item: TListItem); procedure TDirView.DDDragDetect(grfKeyState: Longint; DetectStart, Point: TPoint; DragStatus: TDragDetectStatus); -{$IFNDEF NO_THREADS} var WasWatchThreadActive: Boolean; -{$ENDIF} begin if (DragStatus = ddsDrag) and (MarkedCount > 0) then begin -{$IFNDEF NO_THREADS} WasWatchThreadActive := WatchThreadActive; -{$ENDIF} inherited; -{$IFNDEF NO_THREADS} if (LastDDResult = drMove) and (not WasWatchThreadActive) then StartFileDeleteThread; -{$ENDIF} end; end; {DDDragDetect} procedure TDirView.DDChooseEffect(grfKeyState: Integer; var dwEffect: Integer); begin - if (not SelfDropDuplicates) and DragDropFilesEx.OwnerIsSource and + if DragDropFilesEx.OwnerIsSource and (dwEffect = DropEffect_Copy) and (not Assigned(DropTarget)) then dwEffect := DropEffect_None else @@ -4031,10 +3294,8 @@ procedure TDirView.PerformDragDropFileOperation(TargetPath: string; OldWatchForChanges: Boolean; DoFileOperation: Boolean; IsRecycleBin: Boolean; - {$IFDEF USE_DRIVEVIEW} SourceIsDirectory: Boolean; Node: TTreeNode; - {$ENDIF} begin if DragDropFilesEx.FileList.Count > 0 then begin @@ -4051,9 +3312,7 @@ procedure TDirView.PerformDragDropFileOperation(TargetPath: string; begin OldCursor := Screen.Cursor; OldWatchForChanges := WatchForChanges; - {$IFDEF USE_DRIVEVIEW} SourceIsDirectory := True; - {$ENDIF} SourcePath := EmptyStr; try @@ -4062,18 +3321,14 @@ procedure TDirView.PerformDragDropFileOperation(TargetPath: string; if (dwEffect in [DropEffect_Copy, DropEffect_Move]) then begin -{$IFNDEF NO_THREADS} StopWatchThread; - {$IFDEF USE_DRIVEVIEW} if Assigned(DriveView) then TDriveView(DriveView).StopWatchThread; - {$ENDIF} if (DropSourceControl <> Self) and (DropSourceControl is TDirView) then TDirView(DropSourceControl).StopWatchThread; -{$ENDIF} SourcePath := ''; @@ -4091,16 +3346,12 @@ procedure TDirView.PerformDragDropFileOperation(TargetPath: string; if DirExists(TFDDListItem(DragDropFilesEx.FileList[Index]^).Name) then begin SourcePath := TFDDListItem(DragDropFilesEx.FileList[Index]^).Name; - {$IFDEF USE_DRIVEVIEW} SourceIsDirectory := True; - {$ENDIF} end else begin SourcePath := ExtractFilePath(TFDDListItem(DragDropFilesEx.FileList[Index]^).Name); - {$IFDEF USE_DRIVEVIEW} SourceIsDirectory := False; - {$ENDIF} end; end; end; @@ -4170,9 +3421,7 @@ procedure TDirView.PerformDragDropFileOperation(TargetPath: string; if dwEffect = DropEffect_Link then (* Create Link requested: *) begin -{$IFNDEF NO_THREADS} StopWatchThread; -{$ENDIF} for Index := 0 to DragDropFilesEx.FileList.Count - 1 do begin SourceFile := TFDDListItem(DragDropFilesEx.FileList[Index]^).Name; @@ -4198,7 +3447,6 @@ procedure TDirView.PerformDragDropFileOperation(TargetPath: string; (dwEffect = DropEffect_Move) then TDirView(DropSourceControl).ValidateSelectedFiles; - {$IFDEF USE_DRIVEVIEW} if Assigned(FDriveView) and SourceIsDirectory then with TDriveView(FDriveView) do begin @@ -4216,22 +3464,15 @@ procedure TDirView.PerformDragDropFileOperation(TargetPath: string; except end; end; - {$ENDIF} finally FFileOperator.OperandFrom.Clear; FFileOperator.OperandTo.Clear; - {$IFDEF USE_DRIVEVIEW} -{$IFNDEF NO_THREADS} if Assigned(FDriveView) then TDriveView(FDriveView).StartWatchThread; -{$ENDIF} - {$ENDIF} Sleep(0); WatchForChanges := OldWatchForChanges; -{$IFNDEF NO_THREADS} if (DropSourceControl <> Self) and (DropSourceControl is TDirView) then TDirView(DropSourceControl).StartWatchThread; -{$ENDIF} Screen.Cursor := OldCursor; end; end; @@ -4261,31 +3502,21 @@ function TDirView.UndoCopyMove : Boolean; begin Lasttarget := FFileOperator.LastOperandTo[0]; LastSource := FFileOperator.LastOperandFrom[0]; -{$IFNDEF NO_THREADS} - {$IFDEF USE_DRIVEVIEW} if Assigned(FDriveView) then TDriveView(FDriveView).StopAllWatchThreads; - {$ENDIF} -{$ENDIF} Result := FFileOperator.UndoExecute; -{$IFNDEF NO_THREADS} if not WatchthreadActive then -{$ENDIF} Reload2; - {$IFDEF USE_DRIVEVIEW} if Assigned(FDriveView) then with TDriveView(FDriveView) do begin ValidateDirectory(FindNodeToPath(ExtractFilePath(LastTarget))); ValidateDirectory(FindNodeToPath(ExtractFilePath(LastSource))); -{$IFNDEF NO_THREADS} StartAllWatchThreads; -{$ENDIF} end; - {$ENDIF} end; end; {UndoCopyMove} @@ -4307,10 +3538,8 @@ procedure TDirView.EmptyClipboard; end; end; LastClipBoardOperation := cboNone; - {$IFDEF USE_DRIVEVIEW} if Assigned(FDriveView) then TDriveView(FDriveView).LastPathCut := ''; - {$ENDIF} end; end; {EmptyClipBoard} @@ -4368,8 +3597,7 @@ function TDirView.PasteFromClipBoard(TargetPath: string): Boolean; begin DragDropFilesEx.FileList.Clear; Result := False; - if CanPasteFromClipBoard and - {MP}{$IFDEF OLD_DND} DragDropFilesEx.GetFromClipBoard {$ELSE} DragDropFilesEx.PasteFromClipboard {$ENDIF}{/MP} + if CanPasteFromClipBoard and {MP}DragDropFilesEx.GetFromClipBoard{/MP} then begin if TargetPath = '' then diff --git a/source/packages/filemng/DirViewColProperties.pas b/source/packages/filemng/DirViewColProperties.pas index 3b58cef7..8ba77e7a 100644 --- a/source/packages/filemng/DirViewColProperties.pas +++ b/source/packages/filemng/DirViewColProperties.pas @@ -6,15 +6,7 @@ interface Classes, ComCtrls, IEListView; type - TCustomDirViewColProperties = class(TIEListViewColProperties) - protected - function GetSortByExtension: Boolean; - procedure SetSortByExtension(Value: Boolean); - function GetSortStr: string; override; - procedure SetSortStr(Value: string); override; - public - property SortByExtension: Boolean read GetSortByExtension write SetSortByExtension default False; - end; + TCustomDirViewColProperties = class(TIEListViewColProperties); resourcestring SDirViewNameCol = 'Name'; @@ -53,7 +45,6 @@ TDirViewColProperties = class(TCustomDirViewColProperties) property MaxWidth; property MinWidth; property SortAscending; - property SortByExtension; property SortDirColumn: TDirViewCol read GetSortDirColumn write SetSortDirColumn default dvName; @@ -94,31 +85,6 @@ implementation uses SysUtils, CommCtrl, ListViewColProperties, CustomDirView, PasTools; - { TCustomDirViewColProperties } - -procedure TCustomDirViewColProperties.SetSortByExtension(Value: Boolean); -begin - TCustomDirView(FListView).SortByExtension := Value; -end; - -function TCustomDirViewColProperties.GetSortByExtension: Boolean; -begin - Result := TCustomDirView(FListView).SortByExtension; -end; - -procedure TCustomDirViewColProperties.SetSortStr(Value: string); -begin - inherited; - CutToChar(Value, ';', True); - CutToChar(Value, ';', True); - SortByExtension := Boolean(StrToIntDef(CutToChar(Value, ';', True), Integer(SortByExtension))); -end; - -function TCustomDirViewColProperties.GetSortStr: string; -begin - Result := Format('%s;%d', [inherited GetSortStr, Integer(SortByExtension)]); -end; - { TDirViewColProperties } constructor TDirViewColProperties.Create(DirView: TCustomListView); diff --git a/source/packages/filemng/DriveView.pas b/source/packages/filemng/DriveView.pas index df891d27..125e925e 100644 --- a/source/packages/filemng/DriveView.pas +++ b/source/packages/filemng/DriveView.pas @@ -50,10 +50,7 @@ interface {$I ResStrings.pas} const -{$IFNDEF NO_THREADS} msThreadChangeDelay = 50; -{$ENDIF} - CInvalidSize = $FFFFFFFF; ErrorNodeNA = '%s: Node not assigned'; @@ -62,9 +59,7 @@ interface dvdsRereadAllways = 16; {Refresh drivestatus in any case} type - ECreateShortCut = class(Exception); EInvalidDirName = class(Exception); - EInvalidPath = class(Exception); ENodeNotAssigned = class(Exception); TDriveStatus = record @@ -72,9 +67,7 @@ TDriveStatus = record Verified: Boolean; {Drive completly scanned?} RootNode: TTreeNode; {Rootnode to drive} RootNodeIndex: Integer; - {$IFNDEF NO_THREADS} DiscMonitor: TDiscMonitor; {Monitor thread} - {$ENDIF} ChangeTimer: TTimer; {Change timer for the monitor thread} DefaultDir: string; {Current directory} end; @@ -87,10 +80,6 @@ TScanDirInfo = record PScanDirInfo = ^TScanDirInfo; - TDriveViewScanDirEvent = procedure(Sender: TObject; Node: TTreeNode; - var DoScanDir: Boolean) of object; - TDriveViewDiskChangeEvent = procedure(Sender: TObject; Drive: TDrive) of object; - TDriveView = class; TNodeData = class @@ -100,8 +89,6 @@ TNodeData = class FAttr: Integer; FScanned: Boolean; FData: Pointer; - FExpanded: Boolean; - FDirSize: Cardinal; FIsRecycleBin: Boolean; FIconEmpty: Boolean; @@ -118,8 +105,6 @@ TNodeData = class property Attr: Integer read FAttr write FAttr; property Scanned: Boolean read FScanned write FScanned; property Data: Pointer read FData write FData; - property Expanded: Boolean read FExpanded write FExpanded; - property DirSize: Cardinal read FDirSize write FDirSize; property IsRecycleBin: Boolean read FIsRecycleBin; property IconEmpty: Boolean read FIconEmpty write FIconEmpty; end; @@ -137,7 +122,6 @@ TDriveView = class(TCustomDriveView) FWatchDirectory: Boolean; FDirectory: string; FFullDriveScan: Boolean; - FShowDirSize: Boolean; FShowVolLabel: Boolean; FVolDisplayStyle: TVolumeDisplayStyle; FShowAnimation: Boolean; @@ -157,13 +141,6 @@ TDriveView = class(TCustomDriveView) FWorkPlace: IShellFolder; {Additional events:} - FOnStartScan: TNotifyEvent; - FOnEndScan: TNotifyEvent; - FOnScanDir: TDriveViewScanDirEvent; - FOnDiskChange: TDriveViewDiskChangeEvent; - FOnInsertedDiskChange: TDriveViewDiskChangeEvent; - FOnChangeDetected: TDriveViewDiskChangeEvent; - FOnChangeInvalid: TDriveViewDiskChangeEvent; FOnDisplayContextMenu: TNotifyEvent; FOnRefreshDrives: TNotifyEvent; @@ -173,9 +150,7 @@ TDriveView = class(TCustomDriveView) FChangeInterval: Cardinal; - FNoCheckDrives: string; FCompressedColor: TColor; - FFileNameDisplay: TFileNameDisplay; {Drag&drop:} FLastPathCut: string; @@ -188,11 +163,6 @@ TDriveView = class(TCustomDriveView) {Callback-functions used by iteratesubtree:} function CallBackValidateDir(var Node: TTreeNode; Data: Pointer): Boolean; - function CallBackSaveNodeState(var Node: TTreeNode; Data: Pointer): Boolean; - function CallBackRestoreNodeState(var Node: TTreeNode; Data: Pointer): Boolean; - function CallBackDisplayName(var Node: TTreeNode; Data: Pointer): Boolean; - function CallBackSetDirSize(var Node: TTreeNode; Data: Pointer): Boolean; - function CallBackExpandLevel(var Node: TTreeNode; Data: Pointer): Boolean; { Notification procedures used by component TDiscMonitor: } procedure ChangeDetected(Sender: TObject; const Directory: string; @@ -206,14 +176,11 @@ TDriveView = class(TCustomDriveView) procedure SetSelected(Node: TTreeNode); procedure SetFullDriveScan(DoFullDriveScan: Boolean); procedure SetWatchDirectory(Value: Boolean); - procedure SetShowDirSize(ShowIt: Boolean); procedure SetShowVolLabel(ShowIt: Boolean); procedure SetVolDisplayStyle(DoStyle: TVolumeDisplayStyle); procedure SetDirView(Value: TDirView); procedure SetChangeInterval(Value: Cardinal); - procedure SetNoCheckDrives(Value: string); procedure SetCompressedColor(Value: TColor); - procedure SetFileNameDisplay(Value: TFileNameDisplay); procedure SetDirectory(Value: string); override; procedure SetDrive(Drive: TDrive); function GetDrive: TDrive; @@ -221,16 +188,13 @@ TDriveView = class(TCustomDriveView) Path: string; ContentMask: Boolean = True); function DoScanDir(FromNode: TTreeNode): Boolean; virtual; function AddChildNode(ParentNode: TTreeNode; SRec: TSearchRec): TTreeNode; virtual; -{$IFNDEF NO_THREADS} procedure CreateWatchThread(Drive: TDrive); virtual; -{$ENDIF} procedure InternalWndProc(var Msg: TMessage); function DirAttrMask: Integer; procedure ValidateDirectoryEx(Node: TTreeNode; Recurse: TRecursiveScan; NewDirs: Boolean); override; - procedure ValidateDirectoryEasy(Node: TTreeNode); procedure RebuildTree; override; procedure SetLastPathCut(Path: string); @@ -288,48 +252,30 @@ TDriveView = class(TCustomDriveView) function GetDriveToNode(Node: TTreeNode): Char; function GetDriveText(Drive: TDrive): string; procedure ScanDrive(Drive: TDrive); - procedure RefreshRootNodes(ScanDirectory: Boolean; dsFlags: Integer); - function GetValidDrivesStr: string; - procedure RefreshDirSize(Node: TTreeNode); - procedure RefreshDriveDirSize(Drive: TDrive); + procedure RefreshRootNodes(dsFlags: Integer); {Node handling:} procedure SetImageIndex(Node: TTreeNode); virtual; function FindNodeToPath(Path: string): TTreeNode; - function NodeVerified(Node: TTreeNode): Boolean; - function NodeAttr(Node: TTreeNode): Integer; function RootNode(Node: TTreeNode): TTreeNode; function GetDirName(Node: TTreeNode): string; - function GetDirSize(Node: TTreeNode): Cardinal; virtual; - procedure SetDirSize(Node: TTreeNode); virtual; function GetDisplayName(Node: TTreeNode): string; - function NodeUpdateAble(Node: TTreeNode): Boolean; virtual; - procedure ExpandLevel(Node: TTreeNode; Level: Integer); virtual; function NodePathName(Node: TTreeNode): string; override; function GetFQPIDL(Node: TTreeNode): PItemIDList; - function GetSubTreeSize(Node: TTreeNode): Integer; dynamic; - {Directory update:} function CreateDirectory(ParentNode: TTreeNode; NewName: string): TTreeNode; dynamic; function DeleteDirectory(Node: TTreeNode; AllowUndo: Boolean): Boolean; dynamic; - procedure DeleteSubNodes(Node: TTreeNode); dynamic; - constructor Create(AOwner: TComponent); override; destructor Destroy; override; - {Save and restore the subnodes expanded state:} - procedure SaveNodesState(Node: TTreeNode); - procedure RestoreNodesState(Node: TTreeNode); - {Menu-handling:} procedure DisplayContextMenu(Node: TTreeNode; Point: TPoint); override; procedure DisplayPropertiesMenu(Node: TTreeNode); override; -{$IFNDEF NO_THREADS} {Watchthread handling:} procedure StartWatchThread; virtual; procedure StopWatchThread; virtual; @@ -341,7 +287,6 @@ TDriveView = class(TCustomDriveView) function WatchThreadActive: Boolean; overload; function WatchThreadActive(Drive: TDrive): Boolean; overload; function NodeWatched(Node: TTreeNode): Boolean; virtual; -{$ENDIF} procedure ValidateCurrentDirectoryIfNotMonitoring; (* Modified Events: *) @@ -372,28 +317,14 @@ TDriveView = class(TCustomDriveView) property ChangeInterval: Cardinal read FChangeInterval write SetChangeInterval default MSecsPerSec; {Linked component TDirView:} property DirView: TDirView read FDirView write SetDirView; - property ShowDirSize: Boolean read FShowDirSize write SetShowDirSize default False; {Show the volume labels of drives:} property ShowVolLabel: Boolean read FShowVolLabel write SetShowVolLabel default True; {How to display the drives volume labels:} property VolDisplayStyle: TVolumeDisplayStyle read FVolDisplayStyle write SetVolDisplayStyle default doPrettyName; {Show AVI-animation when performing a full drive scan:} property ShowAnimation: Boolean read FShowAnimation write FShowAnimation default False; - {Don't watch these drives for changes:} - property NoCheckDrives: string read FNoCheckDrives write SetNoCheckDrives; property CompressedColor: TColor read FCompressedColor write SetCompressedColor default clBlue; - property FileNameDisplay: TFileNameDisplay read FFileNameDisplay write SetFileNameDisplay default fndStored; {Additional events:} - property OnStartScan: TNotifyEvent read FOnStartScan write FOnStartScan; - property OnEndScan: TNotifyEvent read FOnEndScan write FOnEndScan; - property OnScanDir: TDriveViewScanDirEvent read FOnScanDir write FOnScanDir; - property OnDiskChange: TDriveViewDiskChangeEvent read FOnDiskChange write FOnDiskChange; - property OnInsertedDiskChange: TDriveViewDiskChangeEvent read FOnInsertedDiskChange - write FOnInsertedDiskChange; - property OnChangeDetected: TDriveViewDiskChangeEvent read FOnChangeDetected - write FOnChangeDetected; - property OnChangeInvalid: TDriveViewDiskChangeEvent read FOnChangeInvalid - write FOnChangeInvalid; property OnDisplayContextMenu: TNotifyEvent read FOnDisplayContextMenu write FOnDisplayContextMenu; property OnRefreshDrives: TNotifyEvent read FOnRefreshDrives @@ -489,7 +420,7 @@ procedure Register; implementation uses - CompThread; + CompThread, PasTools, UITypes, Types; resourcestring SErrorInvalidDirName = 'New name contains invalid characters %s'; @@ -507,11 +438,9 @@ constructor TNodeData.Create; inherited; FAttr := 0; - FExpanded := False; FScanned := False; FDirName := ''; FShortName := ''; - FDirSize := CInvalidSize; FIsRecycleBin := False; FIconEmpty := True; shAttr := 0; @@ -547,7 +476,6 @@ procedure TDriveTreeNode.Assign(Source: TPersistent); NewData.Attr := SourceData.Attr; NewData.Scanned := SourceData.Scanned; NewData.Data := SourceData.Data; - NewData.Expanded := SourceData.Expanded; NewData.FIsRecycleBin := SourceData.FIsRecycleBin; NewData.IconEmpty := SourceData.IconEmpty; TTreeNode(Source).Data := NewData; @@ -596,7 +524,6 @@ constructor TDriveView.Create(AOwner: TComponent); FConfirmDelete := True; FShowAnimation := False; FDirectory := EmptyStr; - FFileNameDisplay := fndStored; FForceRename := False; FLastRenameName := ''; FRenameNode := nil; @@ -647,14 +574,25 @@ procedure TDriveView.InternalWndProc(var Msg: TMessage); ((wParam = {DBT_CONFIGCHANGED} $0018) or (wParam = {DBT_DEVICEARRIVAL} $8000) or (wParam = {DBT_DEVICEREMOVECOMPLETE} $8004)) then begin + // Delay refresing drives for a sec. + // Particularly with CD/DVD drives, if we query display name + // immediately after receiving DBT_DEVICEARRIVAL, we do not get media label. + // Actually one sec does not help usually, but we do not want to wait any longer, + // because we want to add USB drives asap. + SetTimer(FInternalWindowHandle, 1, MSecsPerSec, nil); + end + else + if Msg = WM_TIMER then + begin + KillTimer(FInternalWindowHandle, 1); try //DriveInfo.Load; - RefreshRootNodes(False, dsAll); + RefreshRootNodes(dsAll or dvdsRereadAllways); if Assigned(OnRefreshDrives) then OnRefreshDrives(Self); except Application.HandleException(Self); - end + end; end; Result := DefWindowProc(FInternalWindowHandle, Msg, wParam, lParam); @@ -731,6 +669,7 @@ function TDriveView.GetFQPIDL(Node: TTreeNode): PItemIDList; Result := nil; if Assigned(Node) then begin + shAttr := 0; FDesktop.ParseDisplayName(FParentForm.Handle, nil, PChar(NodePathName(Node)), Eaten, Result, shAttr); end; @@ -847,11 +786,9 @@ procedure TDriveView.Edit(const Item: TTVItem); Exit; end; -{$IFNDEF NO_THREADS} StopWatchThread; if Assigned(DirView) then DirView.StopWatchThread; -{$ENDIF} with FFileOperator do begin @@ -868,7 +805,7 @@ procedure TDriveView.Edit(const Item: TTVItem); begin Node.Text := Item.pszText; TNodeData(Node.Data).DirName := Item.pszText; - if FindFirst(IncludeTrailingBackslash(NodePath(Node.Parent)) + Item.pszText, + if FindFirst(ApiPath(IncludeTrailingBackslash(NodePath(Node.Parent)) + Item.pszText), faAnyFile, SRec) = 0 then begin TNodeData(Node.Data).ShortName := string(SRec.FindData.cAlternateFileName); @@ -894,15 +831,11 @@ procedure TDriveView.Edit(const Item: TTVItem); end; end; finally -{$IFNDEF NO_THREADS} StartWatchThread; -{$ENDIF} if Assigned(DirView) then begin DirView.Reload2; -{$IFNDEF NO_THREADS} DirView.StartWatchThread; -{$ENDIF} end; end; end; @@ -940,10 +873,8 @@ function TDriveView.CanExpand(Node: TTreeNode): Boolean; SubNode := Node.GetFirstChild; Node.HasChildren := Assigned(SubNode); Result := Node.HasChildren; -{$IFNDEF NO_THREADS} if not Assigned(DriveStatus[Drive].DiscMonitor) then CreateWatchThread(Drive); -{$ENDIF} end; end else @@ -973,7 +904,7 @@ procedure TDriveView.Loaded; begin inherited; {Create the drive nodes:} - RefreshRootNodes(False, dsDisplayName or dvdsFloppy); + RefreshRootNodes(dsDisplayName or dvdsFloppy); {Set the initial directory:} if (Length(FDirectory) > 0) and DirExists(FDirectory) then Directory := FDirectory; @@ -1044,7 +975,7 @@ function TDriveView.CanChange(Node: TTreeNode): Boolean; Result := False; end else - if not DirectoryExists(Path) then + if not DirectoryExists(ApiPath(Path)) then begin MessageDlg(Format(SDirNotExists, [Path]), mtError, [mbOK], 0); Result := False; @@ -1112,39 +1043,23 @@ procedure TDriveView.Change(Node: TTreeNode); if LastDrive <> Drive then begin -{$IFNDEF NO_THREADS} if (LastDrive >= FirstDrive) and (DriveInfo[LastDrive].DriveType = DRIVE_REMOVABLE) then TerminateWatchThread(LastDrive); -{$ENDIF} {Drive serial has changed or is missing: allways reread the drive:} if (DriveSerial <> OldSerial) or (DriveSerial = 0) then begin if TNodeData(DriveStatus[Drive].RootNode.Data).Scanned then ScanDrive(Drive); - if Assigned(FOnInsertedDiskChange) then - FOnInsertedDiskChange(Self, Drive); end; - - if Assigned(FOnDiskChange) then - FOnDiskChange(Self, Drive); end; -{$IFNDEF NO_THREADS} StartWatchThread; -{$ENDIF} end else {Drive not ready:} begin DriveStatus[Drive].RootNode.DeleteChildren; DriveStatus[Drive].DefaultDir := EmptyStr; - if LastDrive <> Drive then - begin - if Assigned(FOnInsertedDiskChange) then - FOnInsertedDiskChange(Self, Drive); - if Assigned(FOnDiskChange) then - FOnDiskChange(Self, Drive); - end; end; end; end; @@ -1223,40 +1138,31 @@ function TDriveView.GetDriveText(Drive: TDrive): string; case FVolDisplayStyle of doPrettyName: Result := DriveInfo.GetPrettyName(Drive); doDisplayName: Result := DriveInfo.GetDisplayName(Drive); - doLongPrettyName: Result := DriveInfo.GetLongPrettyName(Drive); end; {Case} end else Result := Drive + ':'; end; {GetDriveText} -function TDriveView.GetValidDrivesStr: String; -var - Drive: TDrive; -begin - Result := ''; - for Drive := FirstDrive to LastDrive do - if DriveInfo[Drive].Valid then - Result := Result + Drive; -end; {GetValidDriveStr} - type TFolderAttributesGetterThread = class(TCompThread) private FParentFolder: iShellFolder; FPIDL: PItemIDList; - FshAttr: PUINT; + FshAttr: UINT; protected procedure Execute; override; public - constructor Create(ParentFolder: iShellFolder; PIDL: PItemIDList; shAttr: PUINT); + constructor Create(ParentFolder: iShellFolder; PIDL: PItemIDList; shAttr: UINT); + + property shAttr: UINT read FshAttr; - class procedure GetFolderAttributes(ParentFolder: iShellFolder; PIDL: PItemIDList; shAttr: PUINT); + class procedure GetFolderAttributes(ParentFolder: iShellFolder; PIDL: PItemIDList; var shAttr: UINT); end; class procedure TFolderAttributesGetterThread.GetFolderAttributes( - ParentFolder: iShellFolder; PIDL: PItemIDList; shAttr: PUINT); + ParentFolder: iShellFolder; PIDL: PItemIDList; var shAttr: UINT); var NotResult: Boolean; ErrorMode: Word; @@ -1264,17 +1170,17 @@ class procedure TFolderAttributesGetterThread.GetFolderAttributes( ErrorMode := SetErrorMode(SEM_FAILCRITICALERRORS or SEM_NOOPENFILEERRORBOX); try try - NotResult := not Succeeded(ParentFolder.GetAttributesOf(1, PIDL, shAttr^)); + NotResult := not Succeeded(ParentFolder.GetAttributesOf(1, PIDL, shAttr)); finally SetErrorMode(ErrorMode); end; - if NotResult then shAttr^ := 0; + if NotResult then shAttr := 0; except - shAttr^ := 0; + shAttr := 0; end; end; -constructor TFolderAttributesGetterThread.Create(ParentFolder: iShellFolder; PIDL: PItemIDList; shAttr: PUINT); +constructor TFolderAttributesGetterThread.Create(ParentFolder: iShellFolder; PIDL: PItemIDList; shAttr: UINT); begin inherited Create(True); FParentFolder := ParentFolder; @@ -1312,18 +1218,21 @@ procedure TDriveView.GetNodeShellAttr(ParentFolder: IShellFolder; // But when running from IDE, it triggers starting/exiting the thread, // again taking ages. So in IDE we revert to single-thread approach {$IFDEF IDE} - TFolderAttributesGetterThread.GetFolderAttributes(ParentFolder, NodeData.PIDL, @shAttr); + TFolderAttributesGetterThread.GetFolderAttributes(ParentFolder, NodeData.PIDL, shAttr); NodeData.shAttr := shAttr; {$ELSE} - Thread := TFolderAttributesGetterThread.Create(ParentFolder, NodeData.PIDL, @shAttr); - Thread.FreeOnTerminate := True; + Thread := TFolderAttributesGetterThread.Create(ParentFolder, NodeData.PIDL, shAttr); Thread.Resume; if Thread.WaitFor(MSecsPerSec) then begin - NodeData.shAttr := shAttr; + NodeData.shAttr := Thread.shAttr; + Thread.Free; end else begin + // There's a chance for memory leak, if thread is terminated + // between WaitFor() and this line + Thread.FreeOnTerminate := True; NodeData.shAttr := 0; end; {$ENDIF} @@ -1339,7 +1248,7 @@ procedure TDriveView.GetNodeShellAttr(ParentFolder: IShellFolder; end; end; {GetNodeAttr} -procedure TDriveView.RefreshRootNodes(ScanDirectory: Boolean; dsFlags: Integer); +procedure TDriveView.RefreshRootNodes(dsFlags: Integer); var Drive: Char; NewText: string; @@ -1347,7 +1256,6 @@ procedure TDriveView.RefreshRootNodes(ScanDirectory: Boolean; dsFlags: Integer); D: TDrive; SaveCursor: TCursor; WasValid: Boolean; - OldSerial: DWORD; WFirstDrive: TDrive; NodeData: TNodeData; begin @@ -1366,7 +1274,6 @@ procedure TDriveView.RefreshRootNodes(ScanDirectory: Boolean; dsFlags: Integer); with DriveInfo[Drive]^ do begin WasValid := Assigned(DriveStatus[Drive].RootNode); - OldSerial := DriveSerial; end; if ((dsFlags and dvdsReReadAllways) = 0) and (Length(DriveInfo[Drive].DisplayName) > 0) then @@ -1427,13 +1334,6 @@ procedure TDriveView.RefreshRootNodes(ScanDirectory: Boolean; dsFlags: Integer); RootNode.SelectedIndex := DriveInfo[Drive].ImageIndex; end; - if (Drive >= FirstFixedDrive) and Scanned then - begin - if ScanDirectory and (DriveSerial <> OldSerial) then - begin - ScanDrive(Drive); - end; - end; if Assigned(RootNode) then begin @@ -1505,10 +1405,7 @@ function TDriveView.GetDriveStatus(Drive: TDrive): TDriveStatus; function TDriveView.DoScanDir(FromNode: TTreeNode): Boolean; begin - with TNodeData(FromNode.Data) do - Result := not IsRecycleBin; - if Assigned(FOnScanDir) then - FOnScanDir(Self, FromNode, Result); + Result := not TNodeData(FromNode.Data).IsRecycleBin; end; {DoScanDir} function TDriveView.DirAttrMask: Integer; @@ -1533,7 +1430,7 @@ procedure TDriveView.ScanDrive(Drive: TDrive); if not DoScanDir(ParentNode) then Exit; - DosError := FindFirst(Path, DirAttrMask, Srec); + DosError := FindFirst(ApiPath(Path), DirAttrMask, Srec); while DosError = 0 do begin if (SRec.Name <> '.') and @@ -1585,9 +1482,6 @@ procedure TDriveView.ScanDrive(Drive: TDrive); FAnimate.Active := True; end; - if Assigned(FOnStartScan) then - FOnStartScan(Self); - try RootNode := DriveStatus[Drive].RootNode; if not Assigned(RootNode) then Exit; @@ -1609,8 +1503,6 @@ procedure TDriveView.ScanDrive(Drive: TDrive); RootNode.Expand(False); Screen.Cursor := SaveCursor; - if Assigned(FOnEndScan) then - FOnEndScan(Self); end; end; end; {ScanDrive} @@ -1722,7 +1614,7 @@ function TDriveView.CheckForSubDirs(Path: string): Boolean; begin Result := False; - DosError := FindFirst(IncludeTrailingBackslash(Path) + '*.', DirAttrMask, SRec); + DosError := FindFirst(ApiPath(IncludeTrailingBackslash(Path) + '*.'), DirAttrMask, SRec); while DosError = 0 do begin if (SRec.Name <> '.' ) and @@ -1744,7 +1636,7 @@ function TDriveView.ReadSubDirs(Node: TTreeNode; DriveType: Integer): Boolean; NewNode: TTreeNode; begin Result := False; - DosError := FindFirst(IncludeTrailingBackslash(NodePath(Node)) + '*.*', DirAttrMask, SRec); + DosError := FindFirst(ApiPath(IncludeTrailingBackslash(NodePath(Node)) + '*.*'), DirAttrMask, SRec); while DosError = 0 do begin if (SRec.Name <> '.' ) and @@ -1754,9 +1646,9 @@ function TDriveView.ReadSubDirs(Node: TTreeNode; DriveType: Integer): Boolean; NewNode := AddChildNode(Node, SRec); if DoScanDir(NewNode) then begin - NewNode.HasChildren := Bool(TNodeData(NewNode.Data).shAttr and SFGAO_HASSUBFOLDER); + NewNode.HasChildren := Bool(TNodeData(NewNode.Data).shAttr and SFGAO_HASSUBFOLDER); - TNodeData(NewNode.Data).Scanned := not NewNode.HasChildren; + TNodeData(NewNode.Data).Scanned := not NewNode.HasChildren; end else begin @@ -1821,68 +1713,68 @@ function TDriveView.CallBackValidateDir(Var Node: TTreeNode; Data: Pointer): Boo begin if DoScanDir(Node) then begin - ParentDir := IncludeTrailingBackslash(NodePath(Node)); - {Build list of existing subnodes:} - SubDirList := TStringList.Create; - while Assigned(WorkNode) do - begin - SubDirList.Add(TNodeData(WorkNode.Data).DirName); - WorkNode := Node.GetNextChild(WorkNode); - end; - {Sorting not required, because the subnodes are already sorted!} + ParentDir := IncludeTrailingBackslash(NodePath(Node)); + {Build list of existing subnodes:} + SubDirList := TStringList.Create; + while Assigned(WorkNode) do + begin + SubDirList.Add(TNodeData(WorkNode.Data).DirName); + WorkNode := Node.GetNextChild(WorkNode); + end; + {Sorting not required, because the subnodes are already sorted!} - SRecList := TStringList.Create; - DosError := FindFirst(ParentDir + '*.*', DirAttrMask, SRec); - while DosError = 0 do + SRecList := TStringList.Create; + DosError := FindFirst(ApiPath(ParentDir + '*.*'), DirAttrMask, SRec); + while DosError = 0 do + begin + if (Srec.Name <> '.' ) and + (Srec.Name <> '..') and + (Srec.Attr and faDirectory <> 0) then begin - if (Srec.Name <> '.' ) and - (Srec.Name <> '..') and - (Srec.Attr and faDirectory <> 0) then + SrecList.Add(Srec.Name); + if not SubDirList.Find(Srec.Name, Index) then + {Subnode does not exists: add it:} begin - SrecList.Add(Srec.Name); - if not SubDirList.Find(Srec.Name, Index) then - {Subnode does not exists: add it:} - begin - NewNode := AddChildNode(Node, SRec); - NewNode.HasChildren := CheckForSubDirs(ParentDir + Srec.Name); - TNodeData(NewNode.Data).Scanned := Not NewNode.HasChildren; - NewDirFound := True; - end; + NewNode := AddChildNode(Node, SRec); + NewNode.HasChildren := CheckForSubDirs(ParentDir + Srec.Name); + TNodeData(NewNode.Data).Scanned := Not NewNode.HasChildren; + NewDirFound := True; end; - DosError := FindNext(Srec); end; - FindClose(Srec); - Sreclist.Sort; + DosError := FindNext(Srec); + end; + FindClose(Srec); + Sreclist.Sort; - {Remove not existing subnodes:} - WorkNode := Node.GetFirstChild; - while Assigned(WorkNode) do + {Remove not existing subnodes:} + WorkNode := Node.GetFirstChild; + while Assigned(WorkNode) do + begin + if not Assigned(WorkNode.Data) or + not SrecList.Find(TNodeData(WorkNode.Data).DirName, Index) then begin - if not Assigned(WorkNode.Data) or - not SrecList.Find(TNodeData(WorkNode.Data).DirName, Index) then - begin - DelNode := WorkNode; - WorkNode := Node.GetNextChild(WorkNode); - DelNode.Delete; - end - else + DelNode := WorkNode; + WorkNode := Node.GetNextChild(WorkNode); + DelNode.Delete; + end + else + begin + if (SrecList[Index] <> TNodeData(WorkNode.Data).DirName) then begin - if (SrecList[Index] <> TNodeData(WorkNode.Data).DirName) then - begin - {Case of directory letters has changed:} - TNodeData(WorkNode.Data).DirName := SrecList[Index]; - TNodeData(WorkNode.Data).ShortName := ExtractShortPathName(NodePathName(WorkNode)); - WorkNode.Text := SrecList[Index]; - end; - SrecList.Delete(Index); - WorkNode := Node.GetNextChild(WorkNode); + {Case of directory letters has changed:} + TNodeData(WorkNode.Data).DirName := SrecList[Index]; + TNodeData(WorkNode.Data).ShortName := ExtractShortPathName(NodePathName(WorkNode)); + WorkNode.Text := SrecList[Index]; end; + SrecList.Delete(Index); + WorkNode := Node.GetNextChild(WorkNode); end; - SrecList.Free; - SubDirList.Free; - {Sort subnodes:} - if NewDirFound then - SortChildren(Node, False); + end; + SrecList.Free; + SubDirList.Free; + {Sort subnodes:} + if NewDirFound then + SortChildren(Node, False); end; end else @@ -1919,9 +1811,7 @@ procedure TDriveView.ValidateDirectoryEx(Node: TTreeNode; Recurse: TRecursiveSca Info: PScanDirInfo; SelDir: string; SaveCursor: TCursor; -{$IFNDEF NO_THREADS} RestartWatchThread: Boolean; -{$ENDIF} SaveCanChange: Boolean; CurrentPath: string; begin @@ -1938,14 +1828,10 @@ procedure TDriveView.ValidateDirectoryEx(Node: TTreeNode; Recurse: TRecursiveSca if Node.Level = 0 then DriveStatus[CurrentPath[1]].ChangeTimer.Enabled := False; - {$IFNDEF NO_THREADS} RestartWatchThread := WatchThreadActive; - {$ENDIF} try - {$IFNDEF NO_THREADS} if WatchThreadActive then StopWatchThread; - {$ENDIF} FValidateFlag := True; @@ -1967,10 +1853,8 @@ procedure TDriveView.ValidateDirectoryEx(Node: TTreeNode; Recurse: TRecursiveSca Dispose(Info); finally - {$IFNDEF NO_THREADS} if RestartWatchThread and FWatchDirectory and not WatchThreadActive then StartWatchThread; - {$ENDIF} if Screen.Cursor <> SaveCursor then Screen.Cursor := SaveCursor; @@ -1978,34 +1862,6 @@ procedure TDriveView.ValidateDirectoryEx(Node: TTreeNode; Recurse: TRecursiveSca end; end; {ValidateDirectoryEx} -procedure TDriveView.ValidateDirectoryEasy(Node: TTreeNode); -begin - if Assigned(Node) then - begin - if not Assigned(Node.Data) or (not TNodeData(Node.Data).Scanned) then - ValidateDirectoryEx(Node, rsRecursiveExpanded, False); - end; -end; {ValidateDirectoryEasy} - -function TDriveView.GetSubTreeSize(Node: TTreeNode): Integer; -var - PSubSize: PInt; - SaveCursor: TCursor; -begin - Assert(Assigned(Node)); - - SaveCursor := Screen.Cursor; - Screen.Cursor := crHourGlass; - ValidateAllDirectories(Node); - RefreshDirSize(Node); - New(PSubSize); - PSubSize^ := 0; - IterateSubTree(Node, CallBackSetDirSize, rsRecursive, coScanStartNode, PSubSize); - Result := PSubSize^; - Dispose(PSubSize); - Screen.Cursor := SaveCursor; -end; {GetSubTreeSize} - function TDriveView.GetDriveTypeToNode(Node: TTreeNode): Integer; begin Assert(Assigned(Node)); @@ -2018,35 +1874,6 @@ function TDriveView.GetDriveType(Drive: TDrive): Integer; {Returns DRI Result := DriveInfo[UpCase(Drive)].DriveType; end; {GetDriveType} -function TDriveView.NodeUpdateAble(Node: TTreeNode): Boolean; -begin - Result := Assigned(Node) and Assigned(Node.Data) and (Node.Level > 0); -end; {NodeUpdateAble} - -function TDriveView.CallBackSaveNodeState(var Node: TTreeNode; Data: Pointer): Boolean; -begin - Result := True; - TNodeData(Node.Data).Expanded := Node.Expanded; -end; {CallBackSaveNodeState} - -function TDriveView.CallBackRestoreNodeState(Var Node: TTreeNode; Data: Pointer): Boolean; -begin - Result := True; - Node.Expanded := TNodeData(Node.Data).Expanded; -end; {CallBackRestoreNodeState} - -procedure TDriveView.SaveNodesState(Node: TTreeNode); -begin - IterateSubTree(Node, CallbackSaveNodeState, rsRecursive, coScanStartNode, nil); -end; {SaveNodesState} - -procedure TDriveView.RestoreNodesState(Node: TTreeNode); -begin - Items.BeginUpdate; - IterateSubTree(Node, CallbackRestoreNodeState, rsRecursive, coScanStartNode, nil); - Items.EndUpdate; -end; {RestoreNodesState} - function TDriveView.CreateDirectory(ParentNode: TTreeNode; NewName: string): TTreeNode; var SRec: TSearchRec; @@ -2057,15 +1884,11 @@ function TDriveView.CreateDirectory(ParentNode: TTreeNode; NewName: string): TTr if not TNodeData(ParentNode.Data).Scanned then ValidateDirectory(ParentNode); -{$IFNDEF NO_THREADS} StopWatchThread; -{$ENDIF} try -{$IFNDEF NO_THREADS} if Assigned(FDirView) then FDirView.StopWatchThread; -{$ENDIF} {create phyical directory:} LastIOResult := 0; @@ -2074,7 +1897,7 @@ function TDriveView.CreateDirectory(ParentNode: TTreeNode; NewName: string): TTr if LastIOResult = 0 then begin {Create treenode:} - FindFirst(NodePath(ParentNode) + '\' + NewName, faAnyFile, SRec); + FindFirst(ApiPath(NodePath(ParentNode) + '\' + NewName), faAnyFile, SRec); Result := AddChildNode(ParentNode, Srec); FindClose(Srec); TNodeData(Result.Data).Scanned := True; @@ -2082,14 +1905,10 @@ function TDriveView.CreateDirectory(ParentNode: TTreeNode; NewName: string): TTr ParentNode.Expand(False); end; finally -{$IFNDEF NO_THREADS} StartWatchThread; -{$ENDIF} if Assigned(FDirView) then begin -{$IFNDEF NO_THREADS} FDirView.StartWatchThread; -{$ENDIF} FDirView.Reload2; end; @@ -2125,9 +1944,7 @@ function TDriveView.DeleteDirectory(Node: TTreeNode; AllowUndo: Boolean): Boolea try if DirExists(DelDir) then begin -{$IFNDEF NO_THREADS} StopWatchThread; -{$ENDIF} OperatorResult := FileOperator.Execute; if OperatorResult and (not FileOperator.OperationAborted) and @@ -2154,9 +1971,7 @@ function TDriveView.DeleteDirectory(Node: TTreeNode; AllowUndo: Boolean): Boolea Result := True; end; finally -{$IFNDEF NO_THREADS} StartWatchThread; -{$ENDIF} if Assigned(DirView) and Assigned(Selected) then DirView.Path := NodePathName(Selected); FileOperator.Free; @@ -2165,7 +1980,6 @@ function TDriveView.DeleteDirectory(Node: TTreeNode; AllowUndo: Boolean): Boolea end; end; {DeleteDirectory} -{$IFNDEF NO_THREADS} procedure TDriveView.CreateWatchThread(Drive: TDrive); begin if csDesigning in ComponentState then @@ -2173,8 +1987,7 @@ procedure TDriveView.CreateWatchThread(Drive: TDrive); if (not Assigned(DriveStatus[Drive].DiscMonitor)) and FWatchDirectory and - (DriveInfo[Drive].DriveType <> DRIVE_REMOTE) and - (Pos(Drive, FNoCheckDrives) = 0) then + (DriveInfo[Drive].DriveType <> DRIVE_REMOTE) then begin with DriveStatus[Drive] do begin @@ -2189,19 +2002,16 @@ procedure TDriveView.CreateWatchThread(Drive: TDrive); end; end; end; {CreateWatchThread} -{$ENDIF} procedure TDriveView.SetWatchDirectory(Value: Boolean); begin if FWatchDirectory <> Value then begin FWatchDirectory := Value; -{$IFNDEF NO_THREADS} if (not (csDesigning in ComponentState)) and Value then StartAllWatchThreads else StopAllWatchThreads; -{$ENDIF} end; end; {SetAutoScan} @@ -2230,22 +2040,6 @@ procedure TDriveView.SetChangeInterval(Value: Cardinal); end; end; {SetChangeInterval} -procedure TDriveView.SetNoCheckDrives(Value: string); -begin - FNoCheckDrives := UpperCase(Value); -end; {SetNoCheckDrives} - -procedure TDriveView.DeleteSubNodes(Node: TTreeNode); -begin - if Assigned(Node) then - begin - Node.DeleteChildren; - if Node.Level = 0 then - DriveStatus[GetDriveToNode(Node)].Scanned := False; - Node.HasChildren := False; - end; -end; {DeleteSubNodes} - function TDriveView.NodeWatched(Node: TTreeNode): Boolean; var Drive: TDrive; @@ -2263,8 +2057,6 @@ procedure TDriveView.ChangeInvalid(Sender: TObject; const Directory: string; with DriveStatus[Dir[1]] do begin DiscMonitor.Close; - if Assigned(FOnChangeInvalid) then - FOnChangeInvalid(Self, Dir[1]); end; end; {DirWatchChangeInvalid} @@ -2305,13 +2097,10 @@ procedure TDriveView.ChangeTimerOnTimer(Sender: TObject); begin {Check also collapsed (invisible) subdirectories:} ValidateDirectory(Node); - if Assigned(FOnChangeDetected) then - FOnChangeDetected(Self, Drive); end; end; end; {ChangeTimerOnTimer} -{$IFNDEF NO_THREADS} procedure TDriveView.StartWatchThread; var NewWatchedDir: string; @@ -2418,7 +2207,6 @@ function TDriveView.WatchThreadActive: Boolean; Result := WatchThreadActive(Drive); end; {WatchThreadActive} -{$ENDIF} procedure TDriveView.SetFullDriveScan(DoFullDriveScan: Boolean); begin @@ -2504,145 +2292,7 @@ function TDriveView.RootNode(Node: TTreeNode): TTreeNode; Result := Result.Parent; end; {RootNode} -{NodeAttr: Returns the directory attributes to the node:} -function TDriveView.NodeAttr(Node: TTreeNode): Integer; -begin - if not Assigned(Node) then - raise ENodeNotAssigned.Create(Format(ErrorNodeNA, ['NodeAttr'])); - Result := TNodeData(Node.Data).Attr; -end; {NodeAttr} - -function TDriveView.NodeVerified(Node: TTreeNode): Boolean; -begin - if (not Assigned(Node)) or (not Assigned(Node.Data)) then - raise ENodeNotAssigned.Create(Format(ErrorNodeNA, ['NodeVerified'])); - Result := TNodeData(Node.Data).Scanned; -end; {NodeVerified} - -function TDriveView.CallBackExpandLevel(var Node: TTreeNode; Data: Pointer): Boolean; -begin - Result := True; - if not Assigned(Node) then - raise ENodeNotAssigned.Create(Format(ErrorNodeNA, ['CallBackExpandLevel'])); - if (Node.Level <= Integer(Data)) and (not Node.Expanded) then - Node.Expand(False) - else if (Node.Level > Integer(Data)) and Node.Expanded then - Node.Collapse(True); -end; {CallBackExpandLevel} - -procedure TDriveView.ExpandLevel(Node: TTreeNode; Level: Integer); -{Purpose: Expands all subnodes of node up to the given level} -begin - if (not Assigned(Node)) or (not Assigned(Node.Data)) then - raise ENodeNotAssigned.Create(Format(ErrorNodeNA, ['ExpandLevel'])); - Items.BeginUpdate; - IterateSubTree(Node, CallBackExpandLevel, rsRecursive, coScanStartNode, Pointer(Level)); - Items.EndUpdate; -end; {ExpandLevel} - -function TDriveView.CallBackDisplayName(var Node: TTreeNode; Data: Pointer): Boolean; -begin - Result := True; - if not Assigned(Node) then - raise ENodeNotAssigned.Create(Format(ErrorNodeNA, ['CallBackDisplayName'])); - Node.Text := GetDisplayName(Node); -end; {CallBackDisplayName} - -function TDriveView.CallBackSetDirSize(var Node: TTreeNode; Data: Pointer): Boolean; -begin - Result := True; - if Assigned(Node) then - begin - SetDirSize(Node); - if FShowDirSize then - Node.Text := GetDisplayName(Node); - if Assigned(Data) then - Inc(PInt(Data)^, TNodeData(Node.Data).DirSize); - end; - Application.ProcessMessages; - if not FContinue then - Exit; -end; {CallBackSetDirSize} - -procedure TDriveView.SetShowDirSize(ShowIt: Boolean); -var - Drive: Char; - RootNode: TTreeNode; - SaveCursor: TCursor; -begin - if ShowIt = FShowDirSize then - Exit; - FShowDirSize := ShowIt; - SaveCursor := Screen.Cursor; - Screen.Cursor := crHourGlass; - Items.BeginUpdate; - for Drive := FirstFixedDrive to LastDrive do - begin - if DriveInfo[Drive].Valid then - begin - RootNode := DriveStatus[Drive].RootNode; - if Assigned(RootNode) then - IterateSubTree(RootNode, CallBackDisplayName, rsRecursive, coScanStartNode, nil); - end; - end; - Items.EndUpdate; - Screen.Cursor := SaveCursor; -end; {SetShowDirSize} - -procedure TDriveView.RefreshDirSize(Node: TTreeNode); -begin - if not Assigned(Node) then - raise ENodeNotAssigned.Create(Format(ErrorNodeNA, ['RefreshDirSize'])); - CallBackSetDirSize(Node, nil); -end; {RefreshDirSize} - -procedure TDriveView.RefreshDriveDirSize(Drive: TDrive); -var - SaveCursor: TCursor; -begin - SaveCursor := Screen.Cursor; - Screen.Cursor := crHourGlass; - Items.BeginUpdate; - with DriveStatus[Drive] do - begin - if Assigned(RootNode) then - IterateSubTree(RootNode, CallBackSetDirSize, rsRecursive, coScanStartNode, nil); - end; - Items.EndUpdate; - Screen.Cursor := SaveCursor; -end; {RefreshDriveDirSize} - -function TDriveView.GetDirSize(Node: TTreeNode): Cardinal; -begin - if (not Assigned(Node)) or (not Assigned(Node.Data)) then - raise ENodeNotAssigned.Create(Format(ErrorNodeNA, ['GetDirSize'])); - if TNodeData(Node.Data).DirSize = CInvalidSize then - SetDirSize(Node); - Result := TNodeData(Node.Data).DirSize; -end; {GetDirSize} - -procedure TDriveView.SetDirSize(Node: TTreeNode); -var - SRec: TSearchRec; - Size: Cardinal; -begin - if (not Assigned(Node)) or (not Assigned(Node.Data)) then - raise ENodeNotAssigned.Create(Format(ErrorNodeNA, ['SetDirSize'])); - Size := 0; - if FindFirst(IncludeTrailingBackslash(NodePath(Node)) + '*.*', faAnyFile, SRec) = 0 then - begin - repeat - if (SRec.Attr and faDirectory) = 0 then - Inc(Size, SRec.Size); - until FindNext(SRec) <> 0; - end; - FindClose(Srec); - TNodeData(Node.Data).DirSize := Size; -end; {SetDirSize} - function TDriveView.GetDisplayName(Node: TTreeNode): string; -var - DirName: string; begin Result := ''; if (not Assigned(Node)) or (not Assigned(Node.Data)) then @@ -2651,33 +2301,17 @@ function TDriveView.GetDisplayName(Node: TTreeNode): string; if Node.Level = 0 then Result := GetDriveText(GetDriveToNode(Node)) else begin - DirName := GetDirName(Node); - case FFileNameDisplay of - fndCap: Result := UpperCase(DirName); - fndNoCap: Result := LowerCase(DirName); - fndNice: if Length(DirName) <= 8 then - begin - Result := LowerCase(DirName); - Result[1] := Upcase(Result[1]); - end - else Result := DirName; - else - Result := DirName; - end; {Case} + Result := GetDirName(Node); end; - - if FShowDirSize then - Result := Result + ' = ' + FormatBytes(GetDirSize(Node), True, False); end; {GetDisplayName} procedure TDriveView.SetShowVolLabel(ShowIt: Boolean); begin - IF ShowIt = fShowVolLabel Then - Exit; - fShowVolLabel := ShowIt; - RefreshRootNodes(False, dvdsFloppy); -End; {SetShowVolLabel} - + if ShowIt = FShowVolLabel then + Exit; + FShowVolLabel := ShowIt; + RefreshRootNodes(dvdsFloppy); +end; {SetShowVolLabel} procedure TDriveView.SetVolDisplayStyle(DoStyle: TVolumeDisplayStyle); var @@ -2704,30 +2338,12 @@ procedure TDriveView.SetCompressedColor(Value: TColor); end; end; {SetCompressedColor} -procedure TDriveView.SetFileNameDisplay(Value: TFileNameDisplay); -var - Drive: TDrive; -begin - if Value <> FFileNameDisplay then - begin - FFileNameDisplay := Value; - for Drive := FirstDrive to LastDrive do - with DriveStatus[Drive] do - if Assigned(RootNode) and DriveStatus[Drive].Scanned then - IterateSubTree(RootNode, CallBackDisplayName, rsRecursive, coNoScanStartNode, nil); - end; -end; {SetFileNameDisplay} - procedure TDriveView.DisplayContextMenu(Node: TTreeNode; Point: TPoint); var Verb: string; DirWatched: Boolean; begin -{$IFNDEF NO_THREADS} DirWatched := NodeWatched(Node) and WatchThreadActive; -{$ELSE} - DirWatched := False; -{$ENDIF} Assert(Node <> nil); @@ -2825,20 +2441,15 @@ function TDriveView.DragCompleteFileList: Boolean; end; function TDriveView.DDExecute: TDragResult; -{$IFNDEF NO_THREADS} var WatchThreadOK: Boolean; DragParentPath: string; DragPath: string; -{$ENDIF} begin -{$IFNDEF NO_THREADS} WatchThreadOK := WatchThreadActive; -{$ENDIF} Result := FDragDropFilesEx.Execute(nil); - {$IFNDEF NO_THREADS} if (Result = drMove) and (not WatchThreadOK) then begin DragPath := NodePathName(FDragNode); @@ -2858,7 +2469,6 @@ function TDriveView.DDExecute: TDragResult; end; end; end; -{$ENDIF} end; procedure TDriveView.PerformDragDropFileOperation(Node: TTreeNode; Effect: Integer); @@ -2887,7 +2497,6 @@ procedure TDriveView.PerformDragDropFileOperation(Node: TTreeNode; Effect: Integ try if (Effect = DropEffect_Copy) or (Effect = DropEffect_Move) then begin -{$IFNDEF NO_THREADS} StopAllWatchThreads; if Assigned(FDirView) then FDirView.StopWatchThread; @@ -2898,7 +2507,6 @@ procedure TDriveView.PerformDragDropFileOperation(Node: TTreeNode; Effect: Integ begin TDirView(DropSourceControl).StopWatchThread; end; -{$ENDIF} FileNamesAreMapped := (TFDDListItem(FDragDropFilesEx.FileList[0]^).MappedName <> ''); @@ -3001,9 +2609,7 @@ procedure TDriveView.PerformDragDropFileOperation(Node: TTreeNode; Effect: Integ {Update linked component TDirView:} if Assigned(FDirView) -{$IFNDEF NO_THREADS} and not FDirView.WatchThreadActive -{$ENDIF} then begin case Effect of @@ -3028,7 +2634,6 @@ procedure TDriveView.PerformDragDropFileOperation(Node: TTreeNode; Effect: Integ finally FFileOperator.OperandFrom.Clear; FFileOperator.OperandTo.Clear; -{$IFNDEF NO_THREADS} StartAllWatchThreads; if Assigned(FDirView) and (not FDirView.WatchThreadActive) then @@ -3036,7 +2641,6 @@ procedure TDriveView.PerformDragDropFileOperation(Node: TTreeNode; Effect: Integ if Assigned(DropSourceControl) and (DropSourceControl is TDirView) and (not TDirView(DropSourceControl).WatchThreadActive) then TDirView(DropSourceControl).StartWatchThread; -{$ENDIF} Screen.Cursor := SaveCursor; end; end; {PerformDragDropFileOperation} @@ -3056,22 +2660,16 @@ function TDriveView.UndoCopyMove: Boolean; begin Lasttarget := FFileOperator.LastOperandTo[0]; LastSource := FFileOperator.LastOperandFrom[0]; -{$IFNDEF NO_THREADS} StopAllWatchThreads; -{$ENDIF} Result := FFileOperator.UndoExecute; ValidateDirectory(FindNodeToPath(ExtractFilePath(LastTarget))); ValidateDirectory(FindNodeToPath(ExtractFilePath(LastSource))); -{$IFNDEF NO_THREADS} StartAllWatchThreads; -{$ENDIF} if Assigned(FDirView) then with FDirView do -{$IFNDEF NO_THREADS} if not WatchThreadActive then -{$ENDIF} begin if (IncludeTrailingBackslash(ExtractFilePath(LastTarget)) = IncludeTrailingBackslash(Path)) or (IncludeTrailingBackslash(ExtractFilePath(LastSource)) = IncludeTrailingBackslash(Path)) then @@ -3152,8 +2750,7 @@ function TDriveView.PasteFromClipBoard(TargetPath: String = ''): Boolean; begin ClearDragFileList(FDragDropFilesEx.FileList); Result := False; - if CanPasteFromClipBoard and - {MP}{$IFDEF OLD_DND} FDragDropFilesEx.GetFromClipBoard {$ELSE} FDragDropFilesEx.PasteFromClipboard {$ENDIF}{/MP} + if CanPasteFromClipBoard and {MP}FDragDropFilesEx.GetFromClipBoard{/MP} then begin if TargetPath = '' then diff --git a/source/packages/filemng/FileChanges.pas b/source/packages/filemng/FileChanges.pas index 901d5a02..d8700591 100644 --- a/source/packages/filemng/FileChanges.pas +++ b/source/packages/filemng/FileChanges.pas @@ -60,6 +60,8 @@ TFileDeleteThread = class(TCompThread) implementation {==============================================================} +uses + PasTools; {==============================================================} @@ -95,7 +97,7 @@ procedure TFileDeleteThread.Execute; i := 0; While i <= Pred(fFiles.Count) Do Begin - DosError := SysUtils.FindFirst(fFiles[i], faAnyFile, SRec); + DosError := SysUtils.FindFirst(ApiPath(fFiles[i]), faAnyFile, SRec); IF DosError <> 0 Then Begin ChangeDetected := True; diff --git a/source/packages/filemng/FileOperator.pas b/source/packages/filemng/FileOperator.pas index 8db4bba1..e6c7eaab 100644 --- a/source/packages/filemng/FileOperator.pas +++ b/source/packages/filemng/FileOperator.pas @@ -185,6 +185,8 @@ procedure Register; implementation {==============================================================} +uses + PasTools; { TFileOperator } @@ -311,7 +313,8 @@ function TFileOperator.Execute : Boolean; Result := ''; For i := 0 to Pred(List.Count) Do Begin - Result := Result + List[i]; + // SHFileOperation does not support long paths anyway + Result := Result + ApiPath(List[i]); SetLength(Result, Succ(Length(Result))); Result[Length(Result)] := #0; End; diff --git a/source/packages/filemng/IEDriveInfo.pas b/source/packages/filemng/IEDriveInfo.pas index dbe4117b..16df3dcc 100644 --- a/source/packages/filemng/IEDriveInfo.pas +++ b/source/packages/filemng/IEDriveInfo.pas @@ -55,14 +55,10 @@ TDriveInfoRec = record DriveReady : Boolean; {Drive is ready} DriveType : Integer; {DRIVE_REMOVABLE, DRIVE_FIXED, DRIVE_CDROM, DRIVE_RAMDISK, DRIVE_REMOTE} DisplayName : string; {Windows displayname} - Prettyname : string; {Prettyfied displayname} - LongPrettyName : string; {UNC-Network name on Network drives or same as PrettyName} + PrettyName : string; {Prettyfied displayname} DriveSerial : DWORD; {Serial number of the drive} Size : Int64; {Drivesize} ImageIndex : Integer; {Drive imageIndex} - FileSystemName : string; {Filesystemname as returned by GetVolumeInformation} - MaxFileNameLength : DWORD; {Maximum length of filenames} - FileSystemFlags : DWORD; {Filesystem flags as returned by GetVolumeInformation} end; TSpecialFolder = FirstSpecialFolder..LastSpecialFolder; @@ -83,6 +79,8 @@ TDriveInfo = class(TObject) FFolders: array[TSpecialFolder] of TSpecialFolderRec; function GetData(Drive: TDrive): PDriveInfoRec; function GetFolder(Folder: TSpecialFolder): PSpecialFolderRec; + procedure ReadDriveBasicStatus(Drive: TDrive); + procedure ResetDrive(Drive: TDrive); public property Data[Drive: TDrive]: PDriveInfoRec read GetData; default; @@ -91,7 +89,6 @@ TDriveInfo = class(TObject) function GetImageIndex(Drive: TDrive): Integer; function GetDisplayName(Drive: TDrive): string; function GetPrettyName(Drive: TDrive): string; - function GetLongPrettyName(Drive: TDrive): string; function ReadDriveStatus(Drive: TDrive; Flags: Integer): Boolean; constructor Create; destructor Destroy; override; @@ -113,7 +110,7 @@ function GetNetWorkConnected(Drive: Char): Boolean; implementation uses - Math; + Math, CompThread; constructor TDriveInfo.Create; begin @@ -131,8 +128,6 @@ destructor TDriveInfo.Destroy; begin SetLength(DisplayName, 0); SetLength(PrettyName, 0); - SetLength(LongPrettyName, 0); - SetLength(FileSystemName, 0); // This causes access violation // FreePIDL(PIDL); end; @@ -174,6 +169,29 @@ function TDriveInfo.GetFolder(Folder: TSpecialFolder): PSpecialFolderRec; Result := @FFolders[Folder]; end; +procedure TDriveInfo.ReadDriveBasicStatus(Drive: TDrive); +begin + with FData[Drive] do + begin + DriveType := Windows.GetDriveType(PChar(Drive + ':\')); + Valid := not Bool((1 shl (Ord(Drive) - 65)) and FNoDrives) and + (DriveType in [DRIVE_REMOVABLE, DRIVE_FIXED, DRIVE_CDROM, DRIVE_RAMDISK, DRIVE_REMOTE]); + end; +end; + +procedure TDriveInfo.ResetDrive(Drive: TDrive); +begin + with FData[Drive] do + begin + DriveReady := False; + DisplayName := ''; + PrettyName := ''; + DriveSerial := 0; + Size := -1; + ImageIndex := 0; + end; +end; + procedure TDriveInfo.Load; var Drive: TDrive; @@ -196,25 +214,15 @@ procedure TDriveInfo.Load; FDesktop := nil; for Drive := FirstDrive to LastDrive do + begin with FData[Drive] do - begin - PIDL := nil; - Init := False; - DriveType := Windows.GetDriveType(PChar(Drive + ':\')); - Valid := not Bool((1 shl (Ord(Drive) - 65)) and FNoDrives) and - (DriveType in [DRIVE_REMOVABLE, DRIVE_FIXED, DRIVE_CDROM, DRIVE_RAMDISK, DRIVE_REMOTE]); - Init := False; - DriveReady := False; - DisplayName := ''; - PrettyName := ''; - LongPrettyName := ''; - FileSystemName := ''; - DriveSerial := 0; - Size := -1; - ImageIndex := 0; - FileSystemFlags := 0; - MaxFileNameLength := 0; - end; + begin + ReadDriveBasicStatus(Drive); + Init := False; + PIDL := nil; + ResetDrive(Drive); + end; + end; for Folder := Low(FFolders) to High(FFolders) do FFolders[Folder].Valid := False; @@ -265,59 +273,95 @@ function TDriveInfo.GetPrettyName(Drive: TDrive): string; end; end; {TDriveInfo.GetPrettyName} -function TDriveInfo.GetLongPrettyName(Drive: TDrive): String; +function TDriveInfo.GetData(Drive: TDrive): PDriveInfoRec; begin - if (Drive < FirstDrive) or (Drive > LastDrive) then + if not CharInSet(Upcase(Drive), ['A'..'Z']) then raise EConvertError.Create(Format(ErrorInvalidDrive, [Drive])); - Result := Drive + ':'; + Result := @FData[Upcase(Drive)]; +end; {TDriveInfo.GetData} - if FData[Drive].Valid then - begin - if Length(FData[Drive].PrettyName) = 0 then - ReadDriveStatus(Drive, dsDisplayName); - Result := FData[Drive].LongPrettyName; +type + TParseDisplayNameThread = class(TCompThread) + private + FDesktop: IShellFolder; + FDrive: TDrive; + FPIDL: PItemIDList; + + protected + procedure Execute; override; + + public + constructor Create(Desktop: IShellFolder; Drive: TDrive); + + property PIDL: PItemIDList read FPIDL; end; -end; {TDriveInfo.GetLongPrettyName} -function TDriveInfo.GetData(Drive: TDrive): PDriveInfoRec; +constructor TParseDisplayNameThread.Create(Desktop: IShellFolder; Drive: TDrive); begin - if not CharInSet(Upcase(Drive), ['A'..'Z']) then - raise EConvertError.Create(Format(ErrorInvalidDrive, [Drive])); + inherited Create(True); + FDesktop := Desktop; + FDrive := Drive; +end; - Result := @FData[Upcase(Drive)]; -end; {TDriveInfo.GetData} +procedure TParseDisplayNameThread.Execute; +var + Eaten: ULONG; + ShAttr: ULONG; +begin + ShAttr := 0; + FDesktop.ParseDisplayName(Application.Handle, nil, PChar(FDrive + ':\'), Eaten, FPIDL, ShAttr); +end; function TDriveInfo.ReadDriveStatus(Drive: TDrive; Flags: Integer): Boolean; var ErrorMode: Word; FileInfo: TShFileInfo; - FileSystemNameBuffer: string; DriveID: string; CPos: Integer; + Thread: TParseDisplayNameThread; Eaten: ULONG; ShAttr: ULONG; + MaxFileNameLength: DWORD; + FileSystemFlags: DWORD; begin if not Assigned(FDesktop) then SHGetDesktopFolder(FDesktop); Drive := Upcase(Drive); - DriveID := ''; if (Drive < FirstDrive) or (Drive > LastDrive) then raise EConvertError.Create(Format(ErrorInvalidDrive, [Drive])); with FData[Drive] do begin Init := True; - DriveType := Windows.GetDriveType(PChar(Drive + ':\')); - Valid := not Bool((1 shl (Ord(Drive) - 65)) and FNoDrives) and - (DriveType in [DRIVE_REMOVABLE, DRIVE_FIXED, DRIVE_CDROM, DRIVE_RAMDISK, DRIVE_REMOTE]); + ReadDriveBasicStatus(Drive); if Valid then begin if (not Assigned(PIDL)) and (Drive >= FirstFixedDrive) then begin - FDesktop.ParseDisplayName(Application.Handle, nil, PChar(Drive + ':\'), Eaten, PIDL, ShAttr); + if DriveType = DRIVE_REMOTE then + begin + Thread := TParseDisplayNameThread.Create(FDesktop, Drive); + Thread.Resume; + if Thread.WaitFor(2 * MSecsPerSec) then + begin + PIDL := Thread.PIDL; + Thread.Free; + end + else + begin + // There's a chance for memory leak, if thread is terminated + // between WaitFor() and this line + Thread.FreeOnTerminate := True; + end; + end + else + begin + ShAttr := 0; + FDesktop.ParseDisplayName(Application.Handle, nil, PChar(Drive + ':\'), Eaten, PIDL, ShAttr); + end; end; {Read driveStatus:} @@ -332,22 +376,16 @@ function TDriveInfo.ReadDriveStatus(Drive: TDrive; Flags: Integer): Boolean; DriveReady := (Size >= 0); if DriveReady then begin - SetLength(FileSystemNameBuffer, 500) ; - SetLength(DriveID, 24); {Access the physical drive:} - if GetVolumeInformation(PChar(Drive + ':\'), PChar(DriveID), 24, + if GetVolumeInformation(PChar(Drive + ':\'), nil, 0, @DriveSerial, MaxFileNameLength, FileSystemFlags, - PChar(FileSystemNameBuffer), 499) then + nil, 0) then begin - FileSystemName := StrPas(PChar(FileSystemNameBuffer)); - DriveID := StrPas(PChar(DriveID)); end else begin DriveSerial := 0; - FileSystemName := ''; end; - SetLength(FileSystemNameBuffer, 0); end else begin @@ -362,46 +400,28 @@ function TDriveInfo.ReadDriveStatus(Drive: TDrive; Flags: Integer): Boolean; {DisplayName:} if (Flags and dsDisplayName <> 0) then begin - if DriveReady or (Flags and dsSize = 0) then + {Fetch drives displayname:} + if Assigned(PIDL) then DisplayName := GetShellFileName(PIDL) + else + if Drive < FirstFixedDrive then DisplayName := GetShellFileName(Drive + ':\') + // typical reason we do not have PIDL is that it took too long to + // call ParseDisplayName, in what case calling SHGetFileInfo with + // path (instead of PIDL) will take long too, avoiding that and using + // fallback + else DisplayName := '(' + Drive + ':)'; + + if DriveType <> DRIVE_REMOTE then begin - {Fetch drives displayname:} - {Due to a bug in shGetFileInfo, this function returns allways the displayname of - the first inserted disk, even if a disk change has occured. So, better use the - Volume ID to build the drives displayname:} - if (DriveType = DRIVE_CDROM) and (Length(DriveID) > 0) then - DisplayName := DriveID[1] + LowerCase(Copy(DriveID, 2, 24)) + ' ('+ Drive + ':)' - else - begin - if Assigned(PIDL) then DisplayName := GetShellFileName(PIDL) - else DisplayName := GetShellFileName(Drive + ':\') - end; - PrettyName := Drive + ': ' + DisplayName; - CPos := Pos('(' + Drive, PrettyName); + CPos := Pos(' (' + Drive + ':)', PrettyName); if CPos > 0 then - SetLength(PrettyName, Pred(CPos)); - - if DriveType = DRIVE_REMOTE then - begin - DriveID := GetNetWorkName(Drive); - PrettyName := Drive + ': ' + ExtractFileName(DriveID); - LongPrettyName := Drive + ': ' + DriveID; - end - else - begin - LongPrettyName := Copy(PrettyName, 1, 3) + DisplayName; - CPos := Pos('(' + Drive, LongPrettyName); - if CPos > 0 then - SetLength(LongPrettyName, Pred(CPos)); - end; + Delete(PrettyName, CPos, 5); end else begin - DisplayName := Drive + ':'; - PrettyName := DisplayName; - LongPrettyName := DisplayName; - FreePIDL(PIDL); + DriveID := GetNetWorkName(Drive); + PrettyName := Drive + ': ' + ExtractFileName(DriveID); end; end; @@ -417,15 +437,9 @@ function TDriveInfo.ReadDriveStatus(Drive: TDrive; Flags: Integer): Boolean; end else begin - Size := 0; - DriveReady := False; - DisplayName := ''; - PrettyName := ''; - LongPrettyName := ''; - DriveSerial := 0; - ImageIndex := 0; if Assigned(PIDL) then FreePIDL(PIDL); + ResetDrive(Drive); end; Result := Valid and DriveReady; end; diff --git a/source/packages/filemng/UnixDirViewColProperties.pas b/source/packages/filemng/UnixDirViewColProperties.pas index 62bf56ef..4a707e52 100644 --- a/source/packages/filemng/UnixDirViewColProperties.pas +++ b/source/packages/filemng/UnixDirViewColProperties.pas @@ -44,7 +44,6 @@ TUnixDirViewColProperties = class(TCustomDirViewColProperties) property MaxWidth; property MinWidth; property SortAscending; - property SortByExtension; property SortDirColumn: TUnixDirViewCol read GetSortDirColumn write SetSortDirColumn default uvName; diff --git a/source/packages/jcl/JclBase.pas b/source/packages/jcl/JclBase.pas new file mode 100644 index 00000000..9326883b --- /dev/null +++ b/source/packages/jcl/JclBase.pas @@ -0,0 +1,638 @@ +{**************************************************************************************************} +{ } +{ Project JEDI Code Library (JCL) } +{ } +{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); } +{ you may not use this file except in compliance with the License. You may obtain a copy of the } +{ License at http://www.mozilla.org/MPL/ } +{ } +{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF } +{ ANY KIND, either express or implied. See the License for the specific language governing rights } +{ and limitations under the License. } +{ } +{ The Original Code is JclBase.pas. } +{ } +{ The Initial Developer of the Original Code is Marcel van Brakel. } +{ Portions created by Marcel van Brakel are Copyright Marcel van Brakel. All rights reserved. } +{ } +{ Contributors: } +{ Marcel van Brakel, } +{ Peter Friese, } +{ Robert Marquardt (marquardt) } +{ Robert Rossmair (rrossmair) } +{ Petr Vones (pvones) } +{ Florent Ouchet (outchy) } +{ } +{**************************************************************************************************} +{ } +{ This unit contains generic JCL base classes and routines to support earlier } +{ versions of Delphi as well as FPC. } +{ } +{**************************************************************************************************} +{ } +{ Last modified: $Date:: $ } +{ Revision: $Rev:: $ } +{ Author: $Author:: $ } +{ } +{**************************************************************************************************} + +unit JclBase; + +{$I jcl.inc} + +interface + +uses + {$IFDEF UNITVERSIONING} + JclUnitVersioning, + {$ENDIF UNITVERSIONING} + {$IFDEF HAS_UNITSCOPE} + {$IFDEF MSWINDOWS} + Winapi.Windows, + {$ENDIF MSWINDOWS} + System.SysUtils; + {$ELSE ~HAS_UNITSCOPE} + {$IFDEF MSWINDOWS} + Windows, + {$ENDIF MSWINDOWS} + SysUtils; + {$ENDIF ~HAS_UNITSCOPE} + +// Version +const + JclVersionMajor = 2; // 0=pre-release|beta/1, 2, ...=final + JclVersionMinor = 6; // Fifth minor release since JCL 1.90 + JclVersionRelease = 0; // 0: pre-release|beta/ 1: release + JclVersionBuild = 5178; // build number, days since march 1, 2000 + JclVersion = (JclVersionMajor shl 24) or (JclVersionMinor shl 16) or + (JclVersionRelease shl 15) or (JclVersionBuild shl 0); + +// EJclError +type + EJclError = class(Exception); + +// EJclInternalError +type + EJclInternalError = class(EJclError); + +// Types +type + {$IFDEF MATH_EXTENDED_PRECISION} + Float = Extended; + {$ENDIF MATH_EXTENDED_PRECISION} + {$IFDEF MATH_DOUBLE_PRECISION} + Float = Double; + {$ENDIF MATH_DOUBLE_PRECISION} + {$IFDEF MATH_SINGLE_PRECISION} + Float = Single; + {$ENDIF MATH_SINGLE_PRECISION} + + PFloat = ^Float; + +type + {$IFDEF FPC} + Largeint = Int64; + {$ELSE ~FPC} + {$IFDEF CPU32} + SizeInt = Integer; + {$ENDIF CPU32} + {$IFDEF CPU64} + SizeInt = NativeInt; + {$ENDIF CPU64} + PSizeInt = ^SizeInt; + PPointer = ^Pointer; + PByte = System.PByte; + Int8 = ShortInt; + Int16 = Smallint; + Int32 = Integer; + UInt8 = Byte; + UInt16 = Word; + UInt32 = LongWord; + PCardinal = ^Cardinal; + {$IFNDEF COMPILER7_UP} + UInt64 = Int64; + {$ENDIF ~COMPILER7_UP} + PWideChar = System.PWideChar; + PPWideChar = ^JclBase.PWideChar; + PPAnsiChar = ^PAnsiChar; + PInt64 = type System.PInt64; + {$ENDIF ~FPC} + PPInt64 = ^PInt64; + PPPAnsiChar = ^PPAnsiChar; + +// Int64 support +procedure I64ToCardinals(I: Int64; out LowPart, HighPart: Cardinal); +procedure CardinalsToI64(out I: Int64; const LowPart, HighPart: Cardinal); + +// Redefinition of TLargeInteger to relieve dependency on Windows.pas + +{$IFNDEF FPC} +type + PLargeInteger = ^TLargeInteger; + TLargeInteger = Int64; +{$ENDIF ~FPC} + +{$IFNDEF COMPILER11_UP} +type + TBytes = array of Byte; +{$ENDIF ~COMPILER11_UP} + +// Redefinition of PByteArray to avoid range check exceptions. +type + TJclByteArray = array [0..MaxInt div SizeOf(Byte) - 1] of Byte; + PJclByteArray = ^TJclByteArray; + TJclBytes = Pointer; // under .NET System.pas: TBytes = array of Byte; + +// Redefinition of ULARGE_INTEGER to relieve dependency on Windows.pas +type + {$IFNDEF FPC} + PULARGE_INTEGER = ^ULARGE_INTEGER; + {$EXTERNALSYM PULARGE_INTEGER} + ULARGE_INTEGER = record + case Integer of + 0: + (LowPart: LongWord; + HighPart: LongWord); + 1: + (QuadPart: Int64); + end; + {$EXTERNALSYM ULARGE_INTEGER} + {$ENDIF ~FPC} + TJclULargeInteger = ULARGE_INTEGER; + PJclULargeInteger = PULARGE_INTEGER; + +// Dynamic Array support +type + TDynByteArray = array of Byte; + TDynShortIntArray = array of Shortint; + TDynWordArray = array of Word; + TDynSmallIntArray = array of Smallint; + TDynLongIntArray = array of Longint; + TDynInt64Array = array of Int64; + TDynCardinalArray = array of Cardinal; + TDynIntegerArray = array of Integer; + TDynSizeIntArray = array of SizeInt; + TDynExtendedArray = array of Extended; + TDynDoubleArray = array of Double; + TDynSingleArray = array of Single; + TDynFloatArray = array of Float; + TDynPointerArray = array of Pointer; + TDynStringArray = array of string; + TDynAnsiStringArray = array of AnsiString; + TDynWideStringArray = array of WideString; + {$IFDEF SUPPORTS_UNICODE_STRING} + TDynUnicodeStringArray = array of UnicodeString; + {$ENDIF SUPPORTS_UNICODE_STRING} + TDynIInterfaceArray = array of IInterface; + TDynObjectArray = array of TObject; + TDynCharArray = array of Char; + TDynAnsiCharArray = array of AnsiChar; + TDynWideCharArray = array of WideChar; + +// Cross-Platform Compatibility +const + // line delimiters for a version of Delphi/C++Builder + NativeLineFeed = Char(#10); + NativeCarriageReturn = Char(#13); + NativeCrLf = string(#13#10); + // default line break for a version of Delphi on a platform + {$IFDEF MSWINDOWS} + NativeLineBreak = NativeCrLf; + {$ENDIF MSWINDOWS} + {$IFDEF UNIX} + NativeLineBreak = NativeLineFeed; + {$ENDIF UNIX} + + HexPrefixPascal = string('$'); + HexPrefixC = string('0x'); + HexDigitFmt32 = string('%.8x'); + HexDigitFmt64 = string('%.16x'); + + {$IFDEF BCB} + HexPrefix = HexPrefixC; + {$ELSE ~BCB} + HexPrefix = HexPrefixPascal; + {$ENDIF ~BCB} + + {$IFDEF CPU32} + HexDigitFmt = HexDigitFmt32; + {$ENDIF CPU32} + {$IFDEF CPU64} + HexDigitFmt = HexDigitFmt64; + {$ENDIF CPU64} + + HexFmt = HexPrefix + HexDigitFmt; + +const + BOM_UTF16_LSB: array [0..1] of Byte = ($FF,$FE); + BOM_UTF16_MSB: array [0..1] of Byte = ($FE,$FF); + BOM_UTF8: array [0..2] of Byte = ($EF,$BB,$BF); + BOM_UTF32_LSB: array [0..3] of Byte = ($FF,$FE,$00,$00); + BOM_UTF32_MSB: array [0..3] of Byte = ($00,$00,$FE,$FF); +// BOM_UTF7_1: array [0..3] of Byte = ($2B,$2F,$76,$38); +// BOM_UTF7_2: array [0..3] of Byte = ($2B,$2F,$76,$39); +// BOM_UTF7_3: array [0..3] of Byte = ($2B,$2F,$76,$2B); +// BOM_UTF7_4: array [0..3] of Byte = ($2B,$2F,$76,$2F); +// BOM_UTF7_5: array [0..3] of Byte = ($2B,$2F,$76,$38,$2D); + +type + // Unicode transformation formats (UTF) data types + PUTF7 = ^UTF7; + UTF7 = AnsiChar; + PUTF8 = ^UTF8; + UTF8 = AnsiChar; + PUTF16 = ^UTF16; + UTF16 = WideChar; + PUTF32 = ^UTF32; + UTF32 = Cardinal; + + // UTF conversion schemes (UCS) data types + PUCS4 = ^UCS4; + UCS4 = Cardinal; + PUCS2 = PWideChar; + UCS2 = WideChar; + + TUCS2Array = array of UCS2; + TUCS4Array = array of UCS4; + + // string types + TUTF8String = AnsiString; + {$IFDEF SUPPORTS_UNICODE_STRING} + TUTF16String = UnicodeString; + TUCS2String = UnicodeString; + {$ELSE} + TUTF16String = WideString; + TUCS2String = WideString; + {$ENDIF SUPPORTS_UNICODE_STRING} + +var + AnsiReplacementCharacter: AnsiChar; + +const + UCS4ReplacementCharacter: UCS4 = $0000FFFD; + MaximumUCS2: UCS4 = $0000FFFF; + MaximumUTF16: UCS4 = $0010FFFF; + MaximumUCS4: UCS4 = $7FFFFFFF; + + SurrogateHighStart = UCS4($D800); + SurrogateHighEnd = UCS4($DBFF); + SurrogateLowStart = UCS4($DC00); + SurrogateLowEnd = UCS4($DFFF); + +// basic set types +type + TSetOfAnsiChar = set of AnsiChar; + +{$IFNDEF XPLATFORM_RTL} +procedure RaiseLastOSError; +{$ENDIF ~XPLATFORM_RTL} + +{$IFNDEF RTL230_UP} +procedure CheckOSError(ErrorCode: Cardinal); +{$ENDIF RTL230_UP} + +procedure MoveChar(const Source: string; FromIndex: SizeInt; + var Dest: string; ToIndex, Count: SizeInt); overload; // Index: 0..n-1 + +function AnsiByteArrayStringLen(Data: TBytes): SizeInt; +function StringToAnsiByteArray(const S: string): TBytes; +function AnsiByteArrayToString(const Data: TBytes; Count: SizeInt): string; + +function BytesOf(const Value: AnsiString): TBytes; overload; +function BytesOf(const Value: WideString): TBytes; overload; +function BytesOf(const Value: WideChar): TBytes; overload; +function BytesOf(const Value: AnsiChar): TBytes; overload; +function StringOf(const Bytes: array of Byte): AnsiString; overload; +function StringOf(const Bytes: Pointer; Size: Cardinal): AnsiString; overload; + +{$IFNDEF FPC} +{$IFNDEF COMPILER11_UP} +type // Definitions for 32 Bit Compilers + // From BaseTsd.h + INT_PTR = Integer; + {$EXTERNALSYM INT_PTR} + LONG_PTR = Longint; + {$EXTERNALSYM LONG_PTR} + UINT_PTR = Cardinal; + {$EXTERNALSYM UINT_PTR} + ULONG_PTR = LongWord; + {$EXTERNALSYM ULONG_PTR} + DWORD_PTR = ULONG_PTR; + {$EXTERNALSYM DWORD_PTR} +{$ENDIF ~COMPILER11_UP} + +type + PDWORD_PTR = ^DWORD_PTR; + {$EXTERNALSYM PDWORD_PTR} +{$ENDIF ~FPC} + +type + TJclAddr32 = Cardinal; + {$IFDEF FPC} + TJclAddr64 = QWord; + {$IFDEF CPU64} + TJclAddr = QWord; + {$ENDIF CPU64} + {$IFDEF CPU32} + TJclAddr = Cardinal; + {$ENDIF CPU32} + {$ENDIF FPC} + {$IFDEF BORLAND} + TJclAddr64 = Int64; + {$IFDEF CPU64} + TJclAddr = TJclAddr64; + {$ENDIF CPU64} + {$IFDEF CPU32} + TJclAddr = TJclAddr32; + {$ENDIF CPU32} + {$ENDIF BORLAND} + PJclAddr = ^TJclAddr; + + EJclAddr64Exception = class(EJclError); + +function Addr64ToAddr32(const Value: TJclAddr64): TJclAddr32; +function Addr32ToAddr64(const Value: TJclAddr32): TJclAddr64; + +{$IFDEF FPC} +type + HWND = type Windows.HWND; +{$ENDIF FPC} + + {$IFDEF SUPPORTS_GENERICS} +//DOM-IGNORE-BEGIN + +type + TCompare = function(const Obj1, Obj2: T): Integer; + TEqualityCompare = function(const Obj1, Obj2: T): Boolean; + THashConvert = function(const AItem: T): Integer; + + IEqualityComparer = interface + function Equals(A, B: T): Boolean; + function GetHashCode(Obj: T): Integer; + end; + + TEquatable = class(TInterfacedObject, IEquatable, IEqualityComparer) + public + { IEquatable } + function TestEquals(Other: T): Boolean; overload; + function IEquatable.Equals = TestEquals; + { IEqualityComparer } + function TestEquals(A, B: T): Boolean; overload; + function IEqualityComparer.Equals = TestEquals; + function GetHashCode2(Obj: T): Integer; + function IEqualityComparer.GetHashCode = GetHashCode2; + end; + +//DOM-IGNORE-END +{$ENDIF SUPPORTS_GENERICS} + +const + {$IFDEF SUPPORTS_UNICODE} + AWSuffix = 'W'; + {$ELSE ~SUPPORTS_UNICODE} + AWSuffix = 'A'; + {$ENDIF ~SUPPORTS_UNICODE} + +{$IFDEF FPC} +// FPC emits a lot of warning because the first parameter of its internal +// GetMem is a var parameter, which is not initialized before the call to GetMem +procedure GetMem(out P; Size: Longint); +{$ENDIF FPC} + +{$IFDEF UNITVERSIONING} +const + UnitVersioning: TUnitVersionInfo = ( + RCSfile: '$URL$'; + Revision: '$Revision$'; + Date: '$Date$'; + LogPath: 'JCL\source\common'; + Extra: ''; + Data: nil + ); +{$ENDIF UNITVERSIONING} + +implementation + +uses + JclResources; + +procedure MoveChar(const Source: string; FromIndex: SizeInt; + var Dest: string; ToIndex, Count: SizeInt); +begin + Move(Source[FromIndex + 1], Dest[ToIndex + 1], Count * SizeOf(Char)); +end; + +function AnsiByteArrayStringLen(Data: TBytes): SizeInt; +var + I: SizeInt; +begin + Result := Length(Data); + for I := 0 to Result - 1 do + if Data[I] = 0 then + begin + Result := I + 1; + Break; + end; +end; + +function StringToAnsiByteArray(const S: string): TBytes; +var + I: SizeInt; + AnsiS: AnsiString; +begin + AnsiS := AnsiString(S); // convert to AnsiString + SetLength(Result, Length(AnsiS)); + for I := 0 to High(Result) do + Result[I] := Byte(AnsiS[I + 1]); +end; + +function AnsiByteArrayToString(const Data: TBytes; Count: SizeInt): string; +var + I: SizeInt; + AnsiS: AnsiString; +begin + if Length(Data) < Count then + Count := Length(Data); + SetLength(AnsiS, Count); + for I := 0 to Length(AnsiS) - 1 do + AnsiS[I + 1] := AnsiChar(Data[I]); + Result := string(AnsiS); // convert to System.String +end; + +function BytesOf(const Value: AnsiString): TBytes; +begin + SetLength(Result, Length(Value)); + if Value <> '' then + Move(Pointer(Value)^, Result[0], Length(Value)); +end; + +function BytesOf(const Value: WideString): TBytes; +begin + if Value <> '' then + Result := JclBase.BytesOf(AnsiString(Value)) + else + SetLength(Result, 0); +end; + +function BytesOf(const Value: WideChar): TBytes; +begin + Result := JclBase.BytesOf(WideString(Value)); +end; + +function BytesOf(const Value: AnsiChar): TBytes; +begin + SetLength(Result, 1); + Result[0] := Byte(Value); +end; + +function StringOf(const Bytes: array of Byte): AnsiString; +begin + if Length(Bytes) > 0 then + begin + SetLength(Result, Length(Bytes)); + Move(Bytes[0], Pointer(Result)^, Length(Bytes)); + end + else + Result := ''; +end; + +function StringOf(const Bytes: Pointer; Size: Cardinal): AnsiString; +begin + if (Bytes <> nil) and (Size > 0) then + begin + SetLength(Result, Size); + Move(Bytes^, Pointer(Result)^, Size); + end + else + Result := ''; +end; + +// Int64 support + +procedure I64ToCardinals(I: Int64; out LowPart, HighPart: Cardinal); +begin + LowPart := TJclULargeInteger(I).LowPart; + HighPart := TJclULargeInteger(I).HighPart; +end; + +procedure CardinalsToI64(out I: Int64; const LowPart, HighPart: Cardinal); +begin + TJclULargeInteger(I).LowPart := LowPart; + TJclULargeInteger(I).HighPart := HighPart; +end; + +// Cross Platform Compatibility + +{$IFNDEF XPLATFORM_RTL} +procedure RaiseLastOSError; +begin + RaiseLastWin32Error; +end; +{$ENDIF ~XPLATFORM_RTL} + +{$IFNDEF RTL230_UP} +procedure CheckOSError(ErrorCode: Cardinal); +begin + if ErrorCode <> ERROR_SUCCESS then + {$IFDEF RTL170_UP} + RaiseLastOSError(ErrorCode); + {$ELSE ~RTL170_UP} + RaiseLastOSError; + {$ENDIF ~RTL170_UP} +end; +{$ENDIF RTL230_UP} + +{$OVERFLOWCHECKS OFF} + +function Addr64ToAddr32(const Value: TJclAddr64): TJclAddr32; +begin + if (Value shr 32) = 0 then + Result := Value + else + raise EJclAddr64Exception.CreateResFmt(@RsCantConvertAddr64, [HexPrefix, Value]); +end; + +function Addr32ToAddr64(const Value: TJclAddr32): TJclAddr64; +begin + Result := Value; +end; + +{$IFDEF OVERFLOWCHECKS_ON} +{$OVERFLOWCHECKS ON} +{$ENDIF OVERFLOWCHECKS_ON} + +{$IFDEF SUPPORTS_GENERICS} +//DOM-IGNORE-BEGIN + +//=== { TEquatable } ====================================================== + +function TEquatable.TestEquals(Other: T): Boolean; +begin + if Other = nil then + Result := False + else + Result := GetHashCode = Other.GetHashCode; +end; + +function TEquatable.TestEquals(A, B: T): Boolean; +begin + if A = nil then + Result := B = nil + else + if B = nil then + Result := False + else + Result := A.GetHashCode = B.GetHashCode; +end; + +function TEquatable.GetHashCode2(Obj: T): Integer; +begin + if Obj = nil then + Result := 0 + else + Result := Obj.GetHashCode; +end; + +//DOM-IGNORE-END +{$ENDIF SUPPORTS_GENERICS} + +procedure LoadAnsiReplacementCharacter; +{$IFDEF MSWINDOWS} +var + CpInfo: TCpInfo; +begin + CpInfo.MaxCharSize := 0; + if GetCPInfo(CP_ACP, CpInfo) then + AnsiReplacementCharacter := AnsiChar(Chr(CpInfo.DefaultChar[0])) + else + raise EJclInternalError.CreateRes(@RsEReplacementChar); +end; +{$ELSE ~MSWINDOWS} +begin + AnsiReplacementCharacter := '?'; +end; +{$ENDIF ~MSWINDOWS} + +{$IFDEF FPC} +// FPC emits a lot of warning because the first parameter of its internal +// GetMem is a var parameter, which is not initialized before the call to GetMem +procedure GetMem(out P; Size: Longint); +begin + Pointer(P) := nil; + GetMem(Pointer(P), Size); +end; +{$ENDIF FPC} + +initialization + + LoadAnsiReplacementCharacter; + {$IFDEF UNITVERSIONING} + RegisterUnitVersion(HInstance, UnitVersioning); + {$ENDIF UNITVERSIONING} + +finalization + {$IFDEF UNITVERSIONING} + UnregisterUnitVersion(HInstance); + {$ENDIF UNITVERSIONING} + +end. diff --git a/source/packages/jcl/JclDebug.pas b/source/packages/jcl/JclDebug.pas new file mode 100644 index 00000000..f8d7b863 --- /dev/null +++ b/source/packages/jcl/JclDebug.pas @@ -0,0 +1,6839 @@ +{**************************************************************************************************} +{ } +{ Project JEDI Code Library (JCL) } +{ } +{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); } +{ you may not use this file except in compliance with the License. You may obtain a copy of the } +{ License at http://www.mozilla.org/MPL/ } +{ } +{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF } +{ ANY KIND, either express or implied. See the License for the specific language governing rights } +{ and limitations under the License. } +{ } +{ The Original Code is JclDebug.pas. } +{ } +{ The Initial Developers of the Original Code are Petr Vones and Marcel van Brakel. } +{ Portions created by these individuals are Copyright (C) of these individuals. } +{ All Rights Reserved. } +{ } +{ Contributor(s): } +{ Marcel van Brakel } +{ Flier Lu (flier) } +{ Florent Ouchet (outchy) } +{ Robert Marquardt (marquardt) } +{ Robert Rossmair (rrossmair) } +{ Andreas Hausladen (ahuser) } +{ Petr Vones (pvones) } +{ Soeren Muehlbauer } +{ Uwe Schuster (uschuster) } +{ } +{**************************************************************************************************} +{ } +{ Various debugging support routines and classes. This includes: Diagnostics routines, Trace } +{ routines, Stack tracing and Source Locations a la the C/C++ __FILE__ and __LINE__ macros. } +{ } +{**************************************************************************************************} +{ } +{ Last modified: $Date:: $ } +{ Revision: $Rev:: $ } +{ Author: $Author:: $ } +{ } +{**************************************************************************************************} + +unit JclDebug; + +interface + +{$I jcl.inc} +{$I windowsonly.inc} + +uses + {$IFDEF UNITVERSIONING} + JclUnitVersioning, + {$ENDIF UNITVERSIONING} + {$IFDEF HAS_UNITSCOPE} + {$IFDEF MSWINDOWS} + Winapi.Windows, + {$ENDIF MSWINDOWS} + System.Classes, System.SysUtils, System.Contnrs, + {$ELSE ~HAS_UNITSCOPE} + {$IFDEF MSWINDOWS} + Windows, + {$ENDIF MSWINDOWS} + Classes, SysUtils, Contnrs, + {$ENDIF ~HAS_UNITSCOPE} + JclBase, JclFileUtils, JclPeImage, + {$IFDEF BORLAND} + {$IFNDEF WINSCP} + JclTD32, + {$ENDIF ~WINSCP} + {$ENDIF BORLAND} + JclSynch; + +// Diagnostics +procedure AssertKindOf(const ClassName: string; const Obj: TObject); overload; +procedure AssertKindOf(const ClassType: TClass; const Obj: TObject); overload; + +// use TraceMsg +// procedure Trace(const Msg: string); +procedure TraceMsg(const Msg: string); +procedure TraceFmt(const Fmt: string; const Args: array of const); +procedure TraceLoc(const Msg: string); +procedure TraceLocFmt(const Fmt: string; const Args: array of const); + +// Optimized functionality of JclSysInfo functions ModuleFromAddr and IsSystemModule +type + TJclModuleInfo = class(TObject) + private + FSize: Cardinal; + FEndAddr: Pointer; + FStartAddr: Pointer; + FSystemModule: Boolean; + public + property EndAddr: Pointer read FEndAddr; + property Size: Cardinal read FSize; + property StartAddr: Pointer read FStartAddr; + property SystemModule: Boolean read FSystemModule; + end; + + TJclModuleInfoList = class(TObjectList) + private + FDynamicBuild: Boolean; + FSystemModulesOnly: Boolean; + function GetItems(Index: Integer): TJclModuleInfo; + function GetModuleFromAddress(Addr: Pointer): TJclModuleInfo; + protected + procedure BuildModulesList; + function CreateItemForAddress(Addr: Pointer; SystemModule: Boolean): TJclModuleInfo; + public + constructor Create(ADynamicBuild, ASystemModulesOnly: Boolean); + function AddModule(Module: HMODULE; SystemModule: Boolean): Boolean; + function IsSystemModuleAddress(Addr: Pointer): Boolean; + function IsValidModuleAddress(Addr: Pointer): Boolean; + property DynamicBuild: Boolean read FDynamicBuild; + property Items[Index: Integer]: TJclModuleInfo read GetItems; + property ModuleFromAddress[Addr: Pointer]: TJclModuleInfo read GetModuleFromAddress; + end; + +function JclValidateModuleAddress(Addr: Pointer): Boolean; + +// MAP file abstract parser +type + PJclMapAddress = ^TJclMapAddress; + TJclMapAddress = packed record + Segment: Word; + Offset: TJclAddr; + end; + + PJclMapString = PAnsiChar; + + TJclAbstractMapParser = class(TObject) + private + FLinkerBug: Boolean; + FLinkerBugUnitName: PJclMapString; + FStream: TJclFileMappingStream; + function GetLinkerBugUnitName: string; + protected + FModule: HMODULE; + FLastUnitName: PJclMapString; + FLastUnitFileName: PJclMapString; + procedure ClassTableItem(const Address: TJclMapAddress; Len: Integer; SectionName, GroupName: PJclMapString); virtual; abstract; + procedure SegmentItem(const Address: TJclMapAddress; Len: Integer; GroupName, UnitName: PJclMapString); virtual; abstract; + procedure PublicsByNameItem(const Address: TJclMapAddress; Name: PJclMapString); virtual; abstract; + procedure PublicsByValueItem(const Address: TJclMapAddress; Name: PJclMapString); virtual; abstract; + procedure LineNumberUnitItem(UnitName, UnitFileName: PJclMapString); virtual; abstract; + procedure LineNumbersItem(LineNumber: Integer; const Address: TJclMapAddress); virtual; abstract; + public + constructor Create(const MapFileName: TFileName; Module: HMODULE); overload; virtual; + constructor Create(const MapFileName: TFileName); overload; + destructor Destroy; override; + procedure Parse; + class function MapStringToFileName(MapString: PJclMapString): string; + class function MapStringToModuleName(MapString: PJclMapString): string; + class function MapStringToStr(MapString: PJclMapString; IgnoreSpaces: Boolean = False): string; + property LinkerBug: Boolean read FLinkerBug; + property LinkerBugUnitName: string read GetLinkerBugUnitName; + property Stream: TJclFileMappingStream read FStream; + end; + + // MAP file parser + TJclMapClassTableEvent = procedure(Sender: TObject; const Address: TJclMapAddress; Len: Integer; const SectionName, GroupName: string) of object; + TJclMapSegmentEvent = procedure(Sender: TObject; const Address: TJclMapAddress; Len: Integer; const GroupName, UnitName: string) of object; + TJclMapPublicsEvent = procedure(Sender: TObject; const Address: TJclMapAddress; const Name: string) of object; + TJclMapLineNumberUnitEvent = procedure(Sender: TObject; const UnitName, UnitFileName: string) of object; + TJclMapLineNumbersEvent = procedure(Sender: TObject; LineNumber: Integer; const Address: TJclMapAddress) of object; + + TJclMapParser = class(TJclAbstractMapParser) + private + FOnClassTable: TJclMapClassTableEvent; + FOnLineNumbers: TJclMapLineNumbersEvent; + FOnLineNumberUnit: TJclMapLineNumberUnitEvent; + FOnPublicsByValue: TJclMapPublicsEvent; + FOnPublicsByName: TJclMapPublicsEvent; + FOnSegmentItem: TJclMapSegmentEvent; + protected + procedure ClassTableItem(const Address: TJclMapAddress; Len: Integer; SectionName, GroupName: PJclMapString); override; + procedure SegmentItem(const Address: TJclMapAddress; Len: Integer; GroupName, UnitName: PJclMapString); override; + procedure PublicsByNameItem(const Address: TJclMapAddress; Name: PJclMapString); override; + procedure PublicsByValueItem(const Address: TJclMapAddress; Name: PJclMapString); override; + procedure LineNumberUnitItem(UnitName, UnitFileName: PJclMapString); override; + procedure LineNumbersItem(LineNumber: Integer; const Address: TJclMapAddress); override; + public + property OnClassTable: TJclMapClassTableEvent read FOnClassTable write FOnClassTable; + property OnSegment: TJclMapSegmentEvent read FOnSegmentItem write FOnSegmentItem; + property OnPublicsByName: TJclMapPublicsEvent read FOnPublicsByName write FOnPublicsByName; + property OnPublicsByValue: TJclMapPublicsEvent read FOnPublicsByValue write FOnPublicsByValue; + property OnLineNumberUnit: TJclMapLineNumberUnitEvent read FOnLineNumberUnit write FOnLineNumberUnit; + property OnLineNumbers: TJclMapLineNumbersEvent read FOnLineNumbers write FOnLineNumbers; + end; + + TJclMapStringCache = record + CachedValue: string; + RawValue: PJclMapString; + end; + + // MAP file scanner + PJclMapSegmentClass = ^TJclMapSegmentClass; + TJclMapSegmentClass = record + Segment: Word; // segment ID + Start: DWORD; // start as in the map file + Addr: DWORD; // start as in process memory + VA: DWORD; // position relative to module base adress + Len: DWORD; // segment length + SectionName: TJclMapStringCache; + GroupName: TJclMapStringCache; + end; + + PJclMapSegment = ^TJclMapSegment; + TJclMapSegment = record + Segment: Word; + StartVA: DWORD; // VA relative to (module base address + $10000) + EndVA: DWORD; + UnitName: TJclMapStringCache; + end; + + PJclMapProcName = ^TJclMapProcName; + TJclMapProcName = record + Segment: Word; + VA: DWORD; // VA relative to (module base address + $10000) + ProcName: TJclMapStringCache; + end; + + PJclMapLineNumber = ^TJclMapLineNumber; + TJclMapLineNumber = record + Segment: Word; + VA: DWORD; // VA relative to (module base address + $10000) + LineNumber: Integer; + end; + + TJclMapScanner = class(TJclAbstractMapParser) + private + FSegmentClasses: array of TJclMapSegmentClass; + FLineNumbers: array of TJclMapLineNumber; + FProcNames: array of TJclMapProcName; + FSegments: array of TJclMapSegment; + FSourceNames: array of TJclMapProcName; + FLineNumbersCnt: Integer; + FLineNumberErrors: Integer; + FNewUnitFileName: PJclMapString; + FProcNamesCnt: Integer; + FSegmentCnt: Integer; + FLastAccessedSegementIndex: Integer; + function IndexOfSegment(Addr: DWORD): Integer; + protected + function MAPAddrToVA(const Addr: DWORD): DWORD; + procedure ClassTableItem(const Address: TJclMapAddress; Len: Integer; SectionName, GroupName: PJclMapString); override; + procedure SegmentItem(const Address: TJclMapAddress; Len: Integer; GroupName, UnitName: PJclMapString); override; + procedure PublicsByNameItem(const Address: TJclMapAddress; Name: PJclMapString); override; + procedure PublicsByValueItem(const Address: TJclMapAddress; Name: PJclMapString); override; + procedure LineNumbersItem(LineNumber: Integer; const Address: TJclMapAddress); override; + procedure LineNumberUnitItem(UnitName, UnitFileName: PJclMapString); override; + procedure Scan; + public + constructor Create(const MapFileName: TFileName; Module: HMODULE); override; + + class function MapStringCacheToFileName(var MapString: TJclMapStringCache): string; + class function MapStringCacheToModuleName(var MapString: TJclMapStringCache): string; + class function MapStringCacheToStr(var MapString: TJclMapStringCache; IgnoreSpaces: Boolean = False): string; + + // Addr are virtual addresses relative to (module base address + $10000) + function LineNumberFromAddr(Addr: DWORD): Integer; overload; + function LineNumberFromAddr(Addr: DWORD; out Offset: Integer): Integer; overload; + function ModuleNameFromAddr(Addr: DWORD): string; + function ModuleStartFromAddr(Addr: DWORD): DWORD; + function ProcNameFromAddr(Addr: DWORD): string; overload; + function ProcNameFromAddr(Addr: DWORD; out Offset: Integer): string; overload; + function SourceNameFromAddr(Addr: DWORD): string; + property LineNumberErrors: Integer read FLineNumberErrors; + end; + +type + PJclDbgHeader = ^TJclDbgHeader; + TJclDbgHeader = packed record + Signature: DWORD; + Version: Byte; + Units: Integer; + SourceNames: Integer; + Symbols: Integer; + LineNumbers: Integer; + Words: Integer; + ModuleName: Integer; + CheckSum: Integer; + CheckSumValid: Boolean; + end; + + TJclBinDebugGenerator = class(TJclMapScanner) + private + FDataStream: TMemoryStream; + FMapFileName: TFileName; + protected + procedure CreateData; + public + constructor Create(const MapFileName: TFileName; Module: HMODULE); override; + destructor Destroy; override; + function CalculateCheckSum: Boolean; + property DataStream: TMemoryStream read FDataStream; + end; + + TJclBinDbgNameCache = record + Addr: DWORD; + FirstWord: Integer; + SecondWord: Integer; + end; + + TJclBinDebugScanner = class(TObject) + private + FCacheData: Boolean; + FStream: TCustomMemoryStream; + FValidFormat: Boolean; + FLineNumbers: array of TJclMapLineNumber; + FProcNames: array of TJclBinDbgNameCache; + function GetModuleName: string; + protected + procedure CacheLineNumbers; + procedure CacheProcNames; + procedure CheckFormat; + function DataToStr(A: Integer): string; + function MakePtr(A: Integer): Pointer; + function ReadValue(var P: Pointer; var Value: Integer): Boolean; + public + constructor Create(AStream: TCustomMemoryStream; CacheData: Boolean); + function IsModuleNameValid(const Name: TFileName): Boolean; + function LineNumberFromAddr(Addr: DWORD): Integer; overload; + function LineNumberFromAddr(Addr: DWORD; out Offset: Integer): Integer; overload; + function ProcNameFromAddr(Addr: DWORD): string; overload; + function ProcNameFromAddr(Addr: DWORD; out Offset: Integer): string; overload; + function ModuleNameFromAddr(Addr: DWORD): string; + function ModuleStartFromAddr(Addr: DWORD): DWORD; + function SourceNameFromAddr(Addr: DWORD): string; + property ModuleName: string read GetModuleName; + property ValidFormat: Boolean read FValidFormat; + end; + +function ConvertMapFileToJdbgFile(const MapFileName: TFileName): Boolean; overload; +function ConvertMapFileToJdbgFile(const MapFileName: TFileName; out LinkerBugUnit: string; + out LineNumberErrors: Integer): Boolean; overload; +function ConvertMapFileToJdbgFile(const MapFileName: TFileName; out LinkerBugUnit: string; + out LineNumberErrors, MapFileSize, JdbgFileSize: Integer): Boolean; overload; + +function InsertDebugDataIntoExecutableFile(const ExecutableFileName, + MapFileName: TFileName; out LinkerBugUnit: string; + out MapFileSize, JclDebugDataSize: Integer): Boolean; overload; +function InsertDebugDataIntoExecutableFile(const ExecutableFileName, + MapFileName: TFileName; out LinkerBugUnit: string; + out MapFileSize, JclDebugDataSize, LineNumberErrors: Integer): Boolean; overload; + +function InsertDebugDataIntoExecutableFile(const ExecutableFileName: TFileName; + BinDebug: TJclBinDebugGenerator; out LinkerBugUnit: string; + out MapFileSize, JclDebugDataSize: Integer): Boolean; overload; +function InsertDebugDataIntoExecutableFile(const ExecutableFileName: TFileName; + BinDebug: TJclBinDebugGenerator; out LinkerBugUnit: string; + out MapFileSize, JclDebugDataSize, LineNumberErrors: Integer): Boolean; overload; + +// Source Locations +type + TJclDebugInfoSource = class; + + PJclLocationInfo = ^TJclLocationInfo; + TJclLocationInfo = record + Address: Pointer; // Error address + UnitName: string; // Name of Delphi unit + ProcedureName: string; // Procedure name + OffsetFromProcName: Integer; // Offset from Address to ProcedureName symbol location + LineNumber: Integer; // Line number + OffsetFromLineNumber: Integer; // Offset from Address to LineNumber symbol location + SourceName: string; // Module file name + DebugInfo: TJclDebugInfoSource; // Location object + BinaryFileName: string; // Name of the binary file containing the symbol + end; + + TJclLocationInfoExValues = set of (lievLocationInfo, lievProcedureStartLocationInfo, lievUnitVersionInfo); + + TJclCustomLocationInfoList = class; + + TJclLocationInfoListOptions = set of (liloAutoGetAddressInfo, liloAutoGetLocationInfo, liloAutoGetUnitVersionInfo); + + TJclLocationInfoEx = class(TPersistent) + private + FAddress: Pointer; + FBinaryFileName: string; + FDebugInfo: TJclDebugInfoSource; + FLineNumber: Integer; + FLineNumberOffsetFromProcedureStart: Integer; + FModuleName: string; + FOffsetFromLineNumber: Integer; + FOffsetFromProcName: Integer; + FParent: TJclCustomLocationInfoList; + FProcedureName: string; + FSourceName: string; + FSourceUnitName: string; + FUnitVersionDateTime: TDateTime; + FUnitVersionExtra: string; + FUnitVersionLogPath: string; + FUnitVersionRCSfile: string; + FUnitVersionRevision: string; + FVAddress: Pointer; + FValues: TJclLocationInfoExValues; + procedure Fill(AOptions: TJclLocationInfoListOptions); + function GetAsString: string; + protected + procedure AssignTo(Dest: TPersistent); override; + public + constructor Create(AParent: TJclCustomLocationInfoList; Address: Pointer); + procedure Clear; virtual; + property Address: Pointer read FAddress write FAddress; + property AsString: string read GetAsString; + property BinaryFileName: string read FBinaryFileName write FBinaryFileName; + property DebugInfo: TJclDebugInfoSource read FDebugInfo write FDebugInfo; + property LineNumber: Integer read FLineNumber write FLineNumber; + property LineNumberOffsetFromProcedureStart: Integer read FLineNumberOffsetFromProcedureStart write FLineNumberOffsetFromProcedureStart; + property ModuleName: string read FModuleName write FModuleName; + property OffsetFromLineNumber: Integer read FOffsetFromLineNumber write FOffsetFromLineNumber; + property OffsetFromProcName: Integer read FOffsetFromProcName write FOffsetFromProcName; + property ProcedureName: string read FProcedureName write FProcedureName; + property SourceName: string read FSourceName write FSourceName; + { this is equal to TJclLocationInfo.UnitName, but has been renamed because + UnitName is a class function in TObject since Delphi 2009 } + property SourceUnitName: string read FSourceUnitName write FSourceUnitName; + property UnitVersionDateTime: TDateTime read FUnitVersionDateTime write FUnitVersionDateTime; + property UnitVersionExtra: string read FUnitVersionExtra write FUnitVersionExtra; + property UnitVersionLogPath: string read FUnitVersionLogPath write FUnitVersionLogPath; + property UnitVersionRCSfile: string read FUnitVersionRCSfile write FUnitVersionRCSfile; + property UnitVersionRevision: string read FUnitVersionRevision write FUnitVersionRevision; + property VAddress: Pointer read FVAddress write FVAddress; + property Values: TJclLocationInfoExValues read FValues write FValues; + end; + + TJclLocationInfoClass = class of TJclLocationInfoEx; + + TJclCustomLocationInfoListClass = class of TJclCustomLocationInfoList; + + TJclCustomLocationInfoList = class(TPersistent) + protected + FItemClass: TJclLocationInfoClass; + FItems: TObjectList; + FOptions: TJclLocationInfoListOptions; + function GetAsString: string; + function GetCount: Integer; + function InternalAdd(Addr: Pointer): TJclLocationInfoEx; + protected + procedure AssignTo(Dest: TPersistent); override; + public + constructor Create; virtual; + destructor Destroy; override; + procedure AddStackInfoList(AStackInfoList: TObject); + procedure Clear; + property AsString: string read GetAsString; + property Count: Integer read GetCount; + property Options: TJclLocationInfoListOptions read FOptions write FOptions; + end; + + TJclLocationInfoList = class(TJclCustomLocationInfoList) + private + function GetItems(AIndex: Integer): TJclLocationInfoEx; + public + constructor Create; override; + function Add(Addr: Pointer): TJclLocationInfoEx; + property Items[AIndex: Integer]: TJclLocationInfoEx read GetItems; default; + end; + + TJclDebugInfoSource = class(TObject) + private + FModule: HMODULE; + function GetFileName: TFileName; + protected + function VAFromAddr(const Addr: Pointer): DWORD; virtual; + public + constructor Create(AModule: HMODULE); virtual; + function InitializeSource: Boolean; virtual; abstract; + function GetLocationInfo(const Addr: Pointer; out Info: TJclLocationInfo): Boolean; virtual; abstract; + property Module: HMODULE read FModule; + property FileName: TFileName read GetFileName; + end; + + TJclDebugInfoSourceClass = class of TJclDebugInfoSource; + + TJclDebugInfoList = class(TObjectList) + private + function GetItemFromModule(const Module: HMODULE): TJclDebugInfoSource; + function GetItems(Index: Integer): TJclDebugInfoSource; + protected + function CreateDebugInfo(const Module: HMODULE): TJclDebugInfoSource; + public + class procedure RegisterDebugInfoSource( + const InfoSourceClass: TJclDebugInfoSourceClass); + class procedure UnRegisterDebugInfoSource( + const InfoSourceClass: TJclDebugInfoSourceClass); + class procedure RegisterDebugInfoSourceFirst( + const InfoSourceClass: TJclDebugInfoSourceClass); + class procedure NeedInfoSourceClassList; + function GetLocationInfo(const Addr: Pointer; out Info: TJclLocationInfo): Boolean; + property ItemFromModule[const Module: HMODULE]: TJclDebugInfoSource read GetItemFromModule; + property Items[Index: Integer]: TJclDebugInfoSource read GetItems; + end; + + // Various source location implementations + TJclDebugInfoMap = class(TJclDebugInfoSource) + private + FScanner: TJclMapScanner; + public + destructor Destroy; override; + function InitializeSource: Boolean; override; + function GetLocationInfo(const Addr: Pointer; out Info: TJclLocationInfo): Boolean; override; + end; + + TJclDebugInfoBinary = class(TJclDebugInfoSource) + private + FScanner: TJclBinDebugScanner; + FStream: TCustomMemoryStream; + public + destructor Destroy; override; + function InitializeSource: Boolean; override; + function GetLocationInfo(const Addr: Pointer; out Info: TJclLocationInfo): Boolean; override; + end; + + TJclDebugInfoExports = class(TJclDebugInfoSource) + private + {$IFDEF BORLAND} + FImage: TJclPeBorImage; + {$ENDIF BORLAND} + {$IFDEF FPC} + FImage: TJclPeImage; + {$ENDIF FPC} + function IsAddressInThisExportedFunction(Addr: PByteArray; FunctionStartAddr: TJclAddr): Boolean; + public + destructor Destroy; override; + function InitializeSource: Boolean; override; + function GetLocationInfo(const Addr: Pointer; out Info: TJclLocationInfo): Boolean; override; + end; + + {$IFDEF BORLAND} + {$IFNDEF WINSCP} + TJclDebugInfoTD32 = class(TJclDebugInfoSource) + private + FImage: TJclPeBorTD32Image; + public + destructor Destroy; override; + function InitializeSource: Boolean; override; + function GetLocationInfo(const Addr: Pointer; out Info: TJclLocationInfo): Boolean; override; + end; + {$ENDIF ~WINSCP} + {$ENDIF BORLAND} + + TJclDebugInfoSymbols = class(TJclDebugInfoSource) + public + class function LoadDebugFunctions: Boolean; + class function UnloadDebugFunctions: Boolean; + class function InitializeDebugSymbols: Boolean; + class function CleanupDebugSymbols: Boolean; + function InitializeSource: Boolean; override; + function GetLocationInfo(const Addr: Pointer; out Info: TJclLocationInfo): Boolean; override; + end; + +// Source location functions +function Caller(Level: Integer = 0; FastStackWalk: Boolean = False): Pointer; + +function GetLocationInfo(const Addr: Pointer): TJclLocationInfo; overload; +function GetLocationInfo(const Addr: Pointer; out Info: TJclLocationInfo): Boolean; overload; +function GetLocationInfoStr(const Addr: Pointer; IncludeModuleName: Boolean = False; + IncludeAddressOffset: Boolean = False; IncludeStartProcLineOffset: Boolean = False; + IncludeVAddress: Boolean = False): string; +function DebugInfoAvailable(const Module: HMODULE): Boolean; +procedure ClearLocationData; + +function FileByLevel(const Level: Integer = 0): string; +function ModuleByLevel(const Level: Integer = 0): string; +function ProcByLevel(const Level: Integer = 0; OnlyProcedureName: boolean =false): string; +function LineByLevel(const Level: Integer = 0): Integer; +function MapByLevel(const Level: Integer; var File_, Module_, Proc_: string; var Line_: Integer): Boolean; + +function FileOfAddr(const Addr: Pointer): string; +function ModuleOfAddr(const Addr: Pointer): string; +function ProcOfAddr(const Addr: Pointer): string; +function LineOfAddr(const Addr: Pointer): Integer; +function MapOfAddr(const Addr: Pointer; var File_, Module_, Proc_: string; var Line_: Integer): Boolean; + +function ExtractClassName(const ProcedureName: string): string; +function ExtractMethodName(const ProcedureName: string): string; + +// Original function names, deprecated will be removed in V2.0; do not use! + +function __FILE__(const Level: Integer = 0): string; {$IFDEF SUPPORTS_DEPRECATED} deprecated; {$ENDIF} +function __MODULE__(const Level: Integer = 0): string; {$IFDEF SUPPORTS_DEPRECATED} deprecated; {$ENDIF} +function __PROC__(const Level: Integer = 0): string; {$IFDEF SUPPORTS_DEPRECATED} deprecated; {$ENDIF} +function __LINE__(const Level: Integer = 0): Integer; {$IFDEF SUPPORTS_DEPRECATED} deprecated; {$ENDIF} +function __MAP__(const Level: Integer; var _File, _Module, _Proc: string; var _Line: Integer): Boolean; {$IFDEF SUPPORTS_DEPRECATED} deprecated; {$ENDIF} +function __FILE_OF_ADDR__(const Addr: Pointer): string; {$IFDEF SUPPORTS_DEPRECATED} deprecated; {$ENDIF} +function __MODULE_OF_ADDR__(const Addr: Pointer): string; {$IFDEF SUPPORTS_DEPRECATED} deprecated; {$ENDIF} +function __PROC_OF_ADDR__(const Addr: Pointer): string; {$IFDEF SUPPORTS_DEPRECATED} deprecated; {$ENDIF} +function __LINE_OF_ADDR__(const Addr: Pointer): Integer; {$IFDEF SUPPORTS_DEPRECATED} deprecated; {$ENDIF} +function __MAP_OF_ADDR__(const Addr: Pointer; var _File, _Module, _Proc: string; + var _Line: Integer): Boolean; {$IFDEF SUPPORTS_DEPRECATED} deprecated; {$ENDIF} + +// Stack info routines base list +type + TJclStackBaseList = class(TObjectList) + private + FThreadID: DWORD; + FTimeStamp: TDateTime; + protected + FOnDestroy: TNotifyEvent; + public + constructor Create; + destructor Destroy; override; + property ThreadID: DWORD read FThreadID; + property TimeStamp: TDateTime read FTimeStamp; + end; + +// Stack info routines +type + PDWORD_PTRArray = ^TDWORD_PTRArray; + TDWORD_PTRArray = array [0..(MaxInt - $F) div SizeOf(DWORD_PTR)] of DWORD_PTR; + {$IFNDEF FPC} + PDWORD_PTR = ^DWORD_PTR; + {$ENDIF ~FPC} + + PStackFrame = ^TStackFrame; + TStackFrame = record + CallerFrame: TJclAddr; + CallerAddr: TJclAddr; + end; + + PStackInfo = ^TStackInfo; + TStackInfo = record + CallerAddr: TJclAddr; + Level: Integer; + CallerFrame: TJclAddr; + DumpSize: DWORD; + ParamSize: DWORD; + ParamPtr: PDWORD_PTRArray; + case Integer of + 0: + (StackFrame: PStackFrame); + 1: + (DumpPtr: PJclByteArray); + end; + + TJclStackInfoItem = class(TObject) + private + FStackInfo: TStackInfo; + function GetCallerAddr: Pointer; + function GetLogicalAddress: TJclAddr; + public + property CallerAddr: Pointer read GetCallerAddr; + property LogicalAddress: TJclAddr read GetLogicalAddress; + property StackInfo: TStackInfo read FStackInfo; + end; + + TJclStackInfoList = class(TJclStackBaseList) + private + FIgnoreLevels: Integer; + TopOfStack: TJclAddr; + BaseOfStack: TJclAddr; + FStackData: PPointer; + FFramePointer: Pointer; + FModuleInfoList: TJclModuleInfoList; + FCorrectOnAccess: Boolean; + FSkipFirstItem: Boolean; + FDelayedTrace: Boolean; + FInStackTracing: Boolean; + FRaw: Boolean; + FStackOffset: Int64; + {$IFDEF CPU64} + procedure CaptureBackTrace; + {$ENDIF CPU64} + function GetItems(Index: Integer): TJclStackInfoItem; + function NextStackFrame(var StackFrame: PStackFrame; var StackInfo: TStackInfo): Boolean; + procedure StoreToList(const StackInfo: TStackInfo); + procedure TraceStackFrames; + procedure TraceStackRaw; + {$IFDEF CPU32} + procedure DelayStoreStack; + {$ENDIF CPU32} + function ValidCallSite(CodeAddr: TJclAddr; out CallInstructionSize: Cardinal): Boolean; + function ValidStackAddr(StackAddr: TJclAddr): Boolean; + function GetCount: Integer; + procedure CorrectOnAccess(ASkipFirstItem: Boolean); + public + constructor Create(ARaw: Boolean; AIgnoreLevels: Integer; + AFirstCaller: Pointer); overload; + constructor Create(ARaw: Boolean; AIgnoreLevels: Integer; + AFirstCaller: Pointer; ADelayedTrace: Boolean); overload; + constructor Create(ARaw: Boolean; AIgnoreLevels: Integer; + AFirstCaller: Pointer; ADelayedTrace: Boolean; ABaseOfStack: Pointer); overload; + constructor Create(ARaw: Boolean; AIgnoreLevels: Integer; + AFirstCaller: Pointer; ADelayedTrace: Boolean; ABaseOfStack, ATopOfStack: Pointer); overload; + destructor Destroy; override; + procedure ForceStackTracing; + procedure AddToStrings(Strings: TStrings; IncludeModuleName: Boolean = False; + IncludeAddressOffset: Boolean = False; IncludeStartProcLineOffset: Boolean = False; + IncludeVAddress: Boolean = False); + property DelayedTrace: Boolean read FDelayedTrace; + property Items[Index: Integer]: TJclStackInfoItem read GetItems; default; + property IgnoreLevels: Integer read FIgnoreLevels; + property Count: Integer read GetCount; + property Raw: Boolean read FRaw; + end; + +{$IFDEF WINSCP} +procedure DoExceptionStackTrace(ExceptObj: TObject; ExceptAddr: Pointer; OSException: Boolean; + BaseOfStack: Pointer); +procedure DoExceptFrameTrace; +{$ENDIF} + +function JclCreateStackList(Raw: Boolean; AIgnoreLevels: Integer; FirstCaller: Pointer): TJclStackInfoList; overload; +function JclCreateStackList(Raw: Boolean; AIgnoreLevels: Integer; FirstCaller: Pointer; + DelayedTrace: Boolean): TJclStackInfoList; overload; +function JclCreateStackList(Raw: Boolean; AIgnoreLevels: Integer; FirstCaller: Pointer; + DelayedTrace: Boolean; BaseOfStack: Pointer): TJclStackInfoList; overload; +function JclCreateStackList(Raw: Boolean; AIgnoreLevels: Integer; FirstCaller: Pointer; + DelayedTrace: Boolean; BaseOfStack, TopOfStack: Pointer): TJclStackInfoList; overload; + +function JclCreateThreadStackTrace(Raw: Boolean; const ThreadHandle: THandle): TJclStackInfoList; +function JclCreateThreadStackTraceFromID(Raw: Boolean; ThreadID: DWORD): TJclStackInfoList; + +function JclLastExceptStackList: TJclStackInfoList; +function JclLastExceptStackListToStrings(Strings: TStrings; IncludeModuleName: Boolean = False; + IncludeAddressOffset: Boolean = False; IncludeStartProcLineOffset: Boolean = False; + IncludeVAddress: Boolean = False): Boolean; + +function JclGetExceptStackList(ThreadID: DWORD): TJclStackInfoList; +function JclGetExceptStackListToStrings(ThreadID: DWORD; Strings: TStrings; + IncludeModuleName: Boolean = False; IncludeAddressOffset: Boolean = False; + IncludeStartProcLineOffset: Boolean = False; IncludeVAddress: Boolean = False): Boolean; + +// helper function for DUnit runtime memory leak check +procedure JclClearGlobalStackData; + +// Exception frame info routines +type + PJmpInstruction = ^TJmpInstruction; + TJmpInstruction = packed record // from System.pas + OpCode: Byte; + Distance: Longint; + end; + + TExcDescEntry = record // from System.pas + VTable: Pointer; + Handler: Pointer; + end; + + PExcDesc = ^TExcDesc; + TExcDesc = packed record // from System.pas + JMP: TJmpInstruction; + case Integer of + 0: + (Instructions: array [0..0] of Byte); + 1: + (Cnt: Integer; + ExcTab: array [0..0] of TExcDescEntry); + end; + + PExcFrame = ^TExcFrame; + TExcFrame = record // from System.pas + Next: PExcFrame; + Desc: PExcDesc; + FramePointer: Pointer; + case Integer of + 0: + (); + 1: + (ConstructedObject: Pointer); + 2: + (SelfOfMethod: Pointer); + end; + + PJmpTable = ^TJmpTable; + TJmpTable = packed record + OPCode: Word; // FF 25 = JMP DWORD PTR [$xxxxxxxx], encoded as $25FF + Ptr: Pointer; + end; + + TExceptFrameKind = + (efkUnknown, efkFinally, efkAnyException, efkOnException, efkAutoException); + + TJclExceptFrame = class(TObject) + private + FFrameKind: TExceptFrameKind; + FFrameLocation: Pointer; + FCodeLocation: Pointer; + FExcTab: array of TExcDescEntry; + protected + procedure AnalyseExceptFrame(AExcDesc: PExcDesc); + public + constructor Create(AFrameLocation: Pointer; AExcDesc: PExcDesc); + function Handles(ExceptObj: TObject): Boolean; + function HandlerInfo(ExceptObj: TObject; out HandlerAt: Pointer): Boolean; + property CodeLocation: Pointer read FCodeLocation; + property FrameLocation: Pointer read FFrameLocation; + property FrameKind: TExceptFrameKind read FFrameKind; + end; + + TJclExceptFrameList = class(TJclStackBaseList) + private + FIgnoreLevels: Integer; + function GetItems(Index: Integer): TJclExceptFrame; + protected + function AddFrame(AFrame: PExcFrame): TJclExceptFrame; + public + constructor Create(AIgnoreLevels: Integer); + procedure TraceExceptionFrames; + property Items[Index: Integer]: TJclExceptFrame read GetItems; + property IgnoreLevels: Integer read FIgnoreLevels write FIgnoreLevels; + end; + +function JclCreateExceptFrameList(AIgnoreLevels: Integer): TJclExceptFrameList; +function JclLastExceptFrameList: TJclExceptFrameList; +function JclGetExceptFrameList(ThreadID: DWORD): TJclExceptFrameList; + +function JclStartExceptionTracking: Boolean; +function JclStopExceptionTracking: Boolean; +function JclExceptionTrackingActive: Boolean; + +function JclTrackExceptionsFromLibraries: Boolean; + +// Thread exception tracking support +type + TJclDebugThread = class(TThread) + private + FSyncException: TObject; + FThreadName: string; + procedure DoHandleException; + function GetThreadInfo: string; + protected + procedure DoNotify; + procedure DoSyncHandleException; dynamic; + procedure HandleException(Sender: TObject = nil); + public + constructor Create(ASuspended: Boolean; const AThreadName: string = ''); + destructor Destroy; override; + property SyncException: TObject read FSyncException; + property ThreadInfo: string read GetThreadInfo; + property ThreadName: string read FThreadName; + end; + + TJclDebugThreadNotifyEvent = procedure(Thread: TJclDebugThread) of object; + TJclThreadIDNotifyEvent = procedure(ThreadID: DWORD) of object; + + TJclDebugThreadList = class(TObject) + private + FList: TObjectList; + FLock: TJclCriticalSection; + FReadLock: TJclCriticalSection; + FRegSyncThreadID: DWORD; + FSaveCreationStack: Boolean; + FUnregSyncThreadID: DWORD; + FOnSyncException: TJclDebugThreadNotifyEvent; + FOnThreadRegistered: TJclThreadIDNotifyEvent; + FOnThreadUnregistered: TJclThreadIDNotifyEvent; + function GetThreadClassNames(ThreadID: DWORD): string; + function GetThreadInfos(ThreadID: DWORD): string; + function GetThreadNames(ThreadID: DWORD): string; + procedure DoSyncThreadRegistered; + procedure DoSyncThreadUnregistered; + function GetThreadCreationTime(ThreadID: DWORD): TDateTime; + function GetThreadHandle(Index: Integer): THandle; + function GetThreadID(Index: Integer): DWORD; + function GetThreadIDCount: Integer; + function GetThreadParentID(ThreadID: DWORD): DWORD; + function GetThreadValues(ThreadID: DWORD; Index: Integer): string; + function IndexOfThreadID(ThreadID: DWORD): Integer; + protected + procedure DoSyncException(Thread: TJclDebugThread); + procedure DoThreadRegistered(Thread: TThread); + procedure DoThreadUnregistered(Thread: TThread); + procedure InternalRegisterThread(Thread: TThread; ThreadID: DWORD; const ThreadName: string); + procedure InternalUnregisterThread(Thread: TThread; ThreadID: DWORD); + public + constructor Create; + destructor Destroy; override; + function AddStackListToLocationInfoList(ThreadID: DWORD; AList: TJclLocationInfoList): Boolean; + procedure RegisterThread(Thread: TThread; const ThreadName: string); + procedure RegisterThreadID(AThreadID: DWORD); + procedure UnregisterThread(Thread: TThread); + procedure UnregisterThreadID(AThreadID: DWORD); + property Lock: TJclCriticalSection read FLock; + //property ThreadClassNames[ThreadID: DWORD]: string index 1 read GetThreadValues; + property SaveCreationStack: Boolean read FSaveCreationStack write FSaveCreationStack; + property ThreadClassNames[ThreadID: DWORD]: string read GetThreadClassNames; + property ThreadCreationTime[ThreadID: DWORD]: TDateTime read GetThreadCreationTime; + property ThreadHandles[Index: Integer]: THandle read GetThreadHandle; + property ThreadIDs[Index: Integer]: DWORD read GetThreadID; + property ThreadIDCount: Integer read GetThreadIDCount; + //property ThreadInfos[ThreadID: DWORD]: string index 2 read GetThreadValues; + property ThreadInfos[ThreadID: DWORD]: string read GetThreadInfos; + //property ThreadNames[ThreadID: DWORD]: string index 0 read GetThreadValues; + property ThreadNames[ThreadID: DWORD]: string read GetThreadNames; + property ThreadParentIDs[ThreadID: DWORD]: DWORD read GetThreadParentID; + property OnSyncException: TJclDebugThreadNotifyEvent read FOnSyncException write FOnSyncException; + property OnThreadRegistered: TJclThreadIDNotifyEvent read FOnThreadRegistered write FOnThreadRegistered; + property OnThreadUnregistered: TJclThreadIDNotifyEvent read FOnThreadUnregistered write FOnThreadUnregistered; + end; + + TJclDebugThreadInfo = class(TObject) + private + FCreationTime: TDateTime; + FParentThreadID: DWORD; + FStackList: TJclStackInfoList; + FThreadClassName: string; + FThreadID: DWORD; + FThreadHandle: THandle; + FThreadName: string; + public + constructor Create(AParentThreadID, AThreadID: DWORD; AStack: Boolean); + destructor Destroy; override; + property CreationTime: TDateTime read FCreationTime; + property ParentThreadID: DWORD read FParentThreadID; + property StackList: TJclStackInfoList read FStackList; + property ThreadClassName: string read FThreadClassName write FThreadClassName; + property ThreadID: DWORD read FThreadID; + property ThreadHandle: THandle read FThreadHandle write FThreadHandle; + property ThreadName: string read FThreadName write FThreadName; + end; + + TJclThreadInfoOptions = set of (tioIsMainThread, tioName, tioCreationTime, tioParentThreadID, tioStack, tioCreationStack); + + TJclCustomThreadInfo = class(TPersistent) + protected + FCreationTime: TDateTime; + FCreationStack: TJclCustomLocationInfoList; + FName: string; + FParentThreadID: DWORD; + FStack: TJclCustomLocationInfoList; + FThreadID: DWORD; + FValues: TJclThreadInfoOptions; + procedure AssignTo(Dest: TPersistent); override; + function GetStackClass: TJclCustomLocationInfoListClass; virtual; + public + constructor Create; + destructor Destroy; override; + property CreationTime: TDateTime read FCreationTime write FCreationTime; + property Name: string read FName write FName; + property ParentThreadID: DWORD read FParentThreadID write FParentThreadID; + property ThreadID: DWORD read FThreadID write FThreadID; + property Values: TJclThreadInfoOptions read FValues write FValues; + end; + + TJclThreadInfo = class(TJclCustomThreadInfo) + private + function GetAsString: string; + procedure InternalFill(AThreadHandle: THandle; AThreadID: DWORD; AGatherOptions: TJclThreadInfoOptions; AExceptThread: Boolean); + function GetStack(const AIndex: Integer): TJclLocationInfoList; + protected + function GetStackClass: TJclCustomLocationInfoListClass; override; + public + procedure Fill(AThreadHandle: THandle; AThreadID: DWORD; AGatherOptions: TJclThreadInfoOptions); + procedure FillFromExceptThread(AGatherOptions: TJclThreadInfoOptions); + property AsString: string read GetAsString; + property CreationStack: TJclLocationInfoList index 1 read GetStack; + property Stack: TJclLocationInfoList index 2 read GetStack; + end; + + TJclThreadInfoList = class(TPersistent) + private + FGatherOptions: TJclThreadInfoOptions; + FItems: TObjectList; + function GetAsString: string; + function GetCount: Integer; + function GetItems(AIndex: Integer): TJclThreadInfo; + procedure InternalGather(AIncludeThreadIDs, AExcludeThreadIDs: array of DWORD); + protected + procedure AssignTo(Dest: TPersistent); override; + public + constructor Create; + destructor Destroy; override; + function Add: TJclThreadInfo; + procedure Clear; + procedure Gather(AExceptThreadID: DWORD); + procedure GatherExclude(AThreadIDs: array of DWORD); + procedure GatherInclude(AThreadIDs: array of DWORD); + property AsString: string read GetAsString; + property Count: Integer read GetCount; + property GatherOptions: TJclThreadInfoOptions read FGatherOptions write FGatherOptions; + property Items[AIndex: Integer]: TJclThreadInfo read GetItems; default; + end; + +function JclDebugThreadList: TJclDebugThreadList; + +function JclHookThreads: Boolean; +function JclUnhookThreads: Boolean; +function JclThreadsHooked: Boolean; + +// Miscellanuous +{$IFDEF MSWINDOWS} +{$IFNDEF WINSCP} +function EnableCrashOnCtrlScroll(const Enable: Boolean): Boolean; +{$ENDIF ~WINSCP} +function IsDebuggerAttached: Boolean; +function IsHandleValid(Handle: THandle): Boolean; +{$ENDIF MSWINDOWS} + +{$IFDEF SUPPORTS_EXTSYM} +{$EXTERNALSYM __FILE__} +{$EXTERNALSYM __LINE__} +{$ENDIF SUPPORTS_EXTSYM} + +const + EnvironmentVarNtSymbolPath = '_NT_SYMBOL_PATH'; // do not localize + EnvironmentVarAlternateNtSymbolPath = '_NT_ALTERNATE_SYMBOL_PATH'; // do not localize + MaxStackTraceItems = 4096; + +// JCL binary debug data generator and scanner +const + JclDbgDataSignature = $4742444A; // JDBG + JclDbgDataResName = AnsiString('JCLDEBUG'); // do not localize + JclDbgHeaderVersion = 1; // JCL 1.11 and 1.20 + + JclDbgFileExtension = '.jdbg'; // do not localize + JclMapFileExtension = '.map'; // do not localize + DrcFileExtension = '.drc'; // do not localize + +// Global exceptional stack tracker enable routines and variables +type + TJclStackTrackingOption = + (stStack, stExceptFrame, stRawMode, stAllModules, stStaticModuleList, + stDelayedTrace, stTraceAllExceptions, stMainThreadOnly, stDisableIfDebuggerAttached); + TJclStackTrackingOptions = set of TJclStackTrackingOption; + +//const + // replaced by RemoveIgnoredException(EAbort) + // stTraceEAbort = stTraceAllExceptions; + +var + JclStackTrackingOptions: TJclStackTrackingOptions = [stStack]; + + { JclDebugInfoSymbolPaths specifies a list of paths, separated by ';', in + which the DebugInfoSymbol scanner should look for symbol information. } + JclDebugInfoSymbolPaths: string = ''; + +// functions to add/remove exception classes to be ignored if StTraceAllExceptions is not set +procedure AddIgnoredException(const ExceptionClass: TClass); +procedure AddIgnoredExceptionByName(const AExceptionClassName: string); +procedure RemoveIgnoredException(const ExceptionClass: TClass); +procedure RemoveIgnoredExceptionByName(const AExceptionClassName: string); +function IsIgnoredException(const ExceptionClass: TClass): Boolean; +// function to add additional system modules to be included in the stack trace +procedure AddModule(const ModuleName: string); + +{$IFDEF UNITVERSIONING} +const + UnitVersioning: TUnitVersionInfo = ( + RCSfile: '$URL$'; + Revision: '$Revision$'; + Date: '$Date$'; + LogPath: 'JCL\source\windows'; + Extra: ''; + Data: nil + ); +{$ENDIF UNITVERSIONING} + +implementation + +uses + {$IFDEF HAS_UNITSCOPE} + System.RTLConsts, + System.Types, // for inlining TList.Remove + {$IFDEF HAS_UNIT_CHARACTER} + System.Character, + {$ENDIF HAS_UNIT_CHARACTER} + {$IFDEF SUPPORTS_GENERICS} + System.Generics.Collections, + {$ENDIF SUPPORTS_GENERICS} + {$ELSE ~HAS_UNITSCOPE} + RTLConsts, + {$IFDEF HAS_UNIT_CHARACTER} + Character, + {$ENDIF HAS_UNIT_CHARACTER} + {$IFDEF SUPPORTS_GENERICS} + Generics.Collections, + {$ENDIF SUPPORTS_GENERICS} + {$ENDIF ~HAS_UNITSCOPE} + {$IFDEF MSWINDOWS} + {$IFNDEF WINSCP} + JclRegistry, + {$ELSE} + System.AnsiStrings, + {$ENDIF ~WINSCP} + {$ENDIF MSWINDOWS} + JclHookExcept, {$IFNDEF WINSCP}JclAnsiStrings,{$ENDIF ~WINSCP} JclStrings, JclSysInfo, JclSysUtils, JclWin32, + {$IFNDEF WINSCP}JclStringConversions,{$ENDIF ~WINSCP} JclResources; + +{$IFDEF WINSCP} + +// from JclAnsiStrings.pas + +function StrLICompA(const Str1, Str2: PAnsiChar; MaxLen: Cardinal): Integer; +begin + Result := {$IFDEF DEPRECATED_SYSUTILS_ANSISTRINGS}System.AnsiStrings.{$ENDIF}StrIComp(Str1, Str2); +end; + +function StrPLCopyA(Dest: PAnsiChar; const Source: AnsiString; MaxLen: Cardinal): PAnsiChar; +begin + Result := {$IFDEF DEPRECATED_SYSUTILS_ANSISTRINGS}System.AnsiStrings.{$ENDIF}StrPLCopy(Dest, Source, MaxLen); +end; + +{$ENDIF} + +//=== Helper assembler routines ============================================== + +const + ModuleCodeOffset = $1000; + +{$STACKFRAMES OFF} + +function GetFramePointer: Pointer; +asm + {$IFDEF CPU32} + MOV EAX, EBP + {$ENDIF CPU32} + {$IFDEF CPU64} + MOV RAX, RBP + {$ENDIF CPU64} +end; + +function GetStackPointer: Pointer; +asm + {$IFDEF CPU32} + MOV EAX, ESP + {$ENDIF CPU32} + {$IFDEF CPU64} + MOV RAX, RSP + {$ENDIF CPU64} +end; + +{$IFDEF CPU32} +function GetExceptionPointer: Pointer; +asm + XOR EAX, EAX + MOV EAX, FS:[EAX] +end; +{$ENDIF CPU32} + +// Reference: Matt Pietrek, MSJ, Under the hood, on TIBs: +// http://www.microsoft.com/MSJ/archive/S2CE.HTM + +function GetStackTop: TJclAddr; +asm + {$IFDEF CPU32} + MOV EAX, FS:[0].NT_TIB32.StackBase + {$ENDIF CPU32} + {$IFDEF CPU64} + {$IFDEF DELPHI64_TEMPORARY} + //TODO: check if the FS version doesn't work in general in 64-bit mode + MOV RAX, GS:[ABS 8] + {$ELSE ~DELPHI64_TEMPORARY} + MOV RAX, FS:[0].NT_TIB64.StackBase + {$ENDIF ~DELPHI64_TEMPORARY} + {$ENDIF CPU64} +end; + +{$IFDEF STACKFRAMES_ON} +{$STACKFRAMES ON} +{$ENDIF STACKFRAMES_ON} + +//=== Diagnostics =========================================================== + +procedure AssertKindOf(const ClassName: string; const Obj: TObject); +var + C: TClass; +begin + if not Obj.ClassNameIs(ClassName) then + begin + C := Obj.ClassParent; + while (C <> nil) and (not C.ClassNameIs(ClassName)) do + C := C.ClassParent; + Assert(C <> nil); + end; +end; + +procedure AssertKindOf(const ClassType: TClass; const Obj: TObject); +begin + Assert(Obj.InheritsFrom(ClassType)); +end; + +procedure TraceMsg(const Msg: string); +begin + OutputDebugString(PChar(StrDoubleQuote(Msg))); +end; + +procedure TraceFmt(const Fmt: string; const Args: array of const); +begin + OutputDebugString(PChar(Format(StrDoubleQuote(Fmt), Args))); +end; + +procedure TraceLoc(const Msg: string); +begin + OutputDebugString(PChar(Format('%s:%u (%s) "%s"', + [FileByLevel(1), LineByLevel(1), ProcByLevel(1), Msg]))); +end; + +procedure TraceLocFmt(const Fmt: string; const Args: array of const); +var + S: string; +begin + S := Format('%s:%u (%s) ', [FileByLevel(1), LineByLevel(1), ProcByLevel(1)]) + + Format(StrDoubleQuote(Fmt), Args); + OutputDebugString(PChar(S)); +end; + +//=== { TJclModuleInfoList } ================================================= + +constructor TJclModuleInfoList.Create(ADynamicBuild, ASystemModulesOnly: Boolean); +begin + inherited Create(True); + FDynamicBuild := ADynamicBuild; + FSystemModulesOnly := ASystemModulesOnly; + if not FDynamicBuild then + BuildModulesList; +end; + +function TJclModuleInfoList.AddModule(Module: HMODULE; SystemModule: Boolean): Boolean; +begin + Result := not IsValidModuleAddress(Pointer(Module)) and + (CreateItemForAddress(Pointer(Module), SystemModule) <> nil); +end; + +{function SortByStartAddress(Item1, Item2: Pointer): Integer; +begin + Result := INT_PTR(TJclModuleInfo(Item2).StartAddr) - INT_PTR(TJclModuleInfo(Item1).StartAddr); +end;} + +procedure TJclModuleInfoList.BuildModulesList; +var + List: TStringList; + I: Integer; + CurModule: PLibModule; +begin + if FSystemModulesOnly then + begin + CurModule := LibModuleList; + while CurModule <> nil do + begin + CreateItemForAddress(Pointer(CurModule.Instance), True); + CurModule := CurModule.Next; + end; + end + else + begin + List := TStringList.Create; + try + LoadedModulesList(List, GetCurrentProcessId, True); + for I := 0 to List.Count - 1 do + CreateItemForAddress(List.Objects[I], False); + finally + List.Free; + end; + end; + //Sort(SortByStartAddress); +end; + +function TJclModuleInfoList.CreateItemForAddress(Addr: Pointer; SystemModule: Boolean): TJclModuleInfo; +var + Module: HMODULE; + ModuleSize: DWORD; +begin + Result := nil; + Module := ModuleFromAddr(Addr); + if Module > 0 then + begin + ModuleSize := PeMapImgSize(Pointer(Module)); + if ModuleSize <> 0 then + begin + Result := TJclModuleInfo.Create; + Result.FStartAddr := Pointer(Module); + Result.FSize := ModuleSize; + Result.FEndAddr := Pointer(Module + ModuleSize - 1); + if SystemModule then + Result.FSystemModule := True + else + Result.FSystemModule := IsSystemModule(Module); + end; + end; + if Result <> nil then + Add(Result); +end; + +function TJclModuleInfoList.GetItems(Index: Integer): TJclModuleInfo; +begin + Result := TJclModuleInfo(Get(Index)); +end; + +function TJclModuleInfoList.GetModuleFromAddress(Addr: Pointer): TJclModuleInfo; +var + I: Integer; + Item: TJclModuleInfo; +begin + Result := nil; + for I := 0 to Count - 1 do + begin + Item := Items[I]; + if (TJclAddr(Item.StartAddr) <= TJclAddr(Addr)) and (TJclAddr(Item.EndAddr) > TJclAddr(Addr)) then + begin + Result := Item; + Break; + end; + end; + if DynamicBuild and (Result = nil) then + Result := CreateItemForAddress(Addr, False); +end; + +function TJclModuleInfoList.IsSystemModuleAddress(Addr: Pointer): Boolean; +var + Item: TJclModuleInfo; +begin + Item := ModuleFromAddress[Addr]; + Result := (Item <> nil) and Item.SystemModule; +end; + +function TJclModuleInfoList.IsValidModuleAddress(Addr: Pointer): Boolean; +begin + Result := ModuleFromAddress[Addr] <> nil; +end; + +//=== { TJclAbstractMapParser } ============================================== + +constructor TJclAbstractMapParser.Create(const MapFileName: TFileName; Module: HMODULE); +begin + inherited Create; + FModule := Module; + if FileExists(MapFileName) then + FStream := TJclFileMappingStream.Create(MapFileName, fmOpenRead or fmShareDenyWrite); +end; + +constructor TJclAbstractMapParser.Create(const MapFileName: TFileName); +begin + Create(MapFileName, 0); +end; + +destructor TJclAbstractMapParser.Destroy; +begin + FreeAndNil(FStream); + inherited Destroy; +end; + +function TJclAbstractMapParser.GetLinkerBugUnitName: string; +begin + Result := MapStringToStr(FLinkerBugUnitName); +end; + +class function TJclAbstractMapParser.MapStringToFileName(MapString: PJclMapString): string; +var + PEnd: PJclMapString; +begin + if MapString = nil then + begin + Result := ''; + Exit; + end; + PEnd := MapString; + while (PEnd^ <> #0) and not (PEnd^ in ['=', #10, #13]) do + Inc(PEnd); + if (PEnd^ = '=') then + begin + while (PEnd >= MapString) and (PEnd^ <> ' ') do + Dec(PEnd); + while (PEnd >= MapString) and ((PEnd-1)^ = ' ') do + Dec(PEnd); + end; + SetString(Result, MapString, PEnd - MapString); +end; + +class function TJclAbstractMapParser.MapStringToModuleName(MapString: PJclMapString): string; +var + PStart, PEnd, PExtension: PJclMapString; +begin + if MapString = nil then + begin + Result := ''; + Exit; + end; + PEnd := MapString; + while (PEnd^ <> #0) and not (PEnd^ in ['=', #10, #13]) do + Inc(PEnd); + if (PEnd^ = '=') then + begin + while (PEnd >= MapString) and (PEnd^ <> ' ') do + Dec(PEnd); + while (PEnd >= MapString) and ((PEnd-1)^ = ' ') do + Dec(PEnd); + end; + PExtension := PEnd; + while (PExtension >= MapString) and (PExtension^ <> '.') and (PExtension^ <> '|') do + Dec(PExtension); + if (StrLICompA(PExtension, '.pas ', 5) = 0) or + (StrLICompA(PExtension, '.obj ', 5) = 0) then + PEnd := PExtension; + PExtension := PEnd; + while (PExtension >= MapString) and (PExtension^ <> '|') and (PExtension^ <> '\') do + Dec(PExtension); + if PExtension >= MapString then + PStart := PExtension + 1 + else + PStart := MapString; + SetString(Result, PStart, PEnd - PStart); +end; + +class function TJclAbstractMapParser.MapStringToStr(MapString: PJclMapString; + IgnoreSpaces: Boolean): string; +var + P: PJclMapString; +begin + if MapString = nil then + begin + Result := ''; + Exit; + end; + if MapString^ = '(' then + begin + Inc(MapString); + P := MapString; + while (P^ <> #0) and not (P^ in [')', #10, #13]) do + Inc(P); + end + else + begin + P := MapString; + if IgnoreSpaces then + while (P^ <> #0) and not (P^ in ['(', #10, #13]) do + Inc(P) + else + while (P^ <> #0) and (P^ <> '(') and (P^ > ' ') do + Inc(P); + end; + SetString(Result, MapString, P - MapString); +end; + +procedure TJclAbstractMapParser.Parse; +const + TableHeader : array [0..3] of string = ('Start', 'Length', 'Name', 'Class'); + SegmentsHeader : array [0..3] of string = ('Detailed', 'map', 'of', 'segments'); + PublicsByNameHeader : array [0..3] of string = ('Address', 'Publics', 'by', 'Name'); + PublicsByValueHeader : array [0..3] of string = ('Address', 'Publics', 'by', 'Value'); + LineNumbersPrefix : string = 'Line numbers for'; +var + CurrPos, EndPos: PJclMapString; +{$IFNDEF COMPILER9_UP} + PreviousA, +{$ENDIF COMPILER9_UP} + A: TJclMapAddress; + L: Integer; + P1, P2: PJclMapString; + + function Eof: Boolean; + begin + Result := CurrPos >= EndPos; + end; + + procedure SkipWhiteSpace; + var + LCurrPos, LEndPos: PJclMapString; + begin + LCurrPos := CurrPos; + LEndPos := EndPos; + while (LCurrPos < LEndPos) and (LCurrPos^ <= ' ') do + Inc(LCurrPos); + CurrPos := LCurrPos; + end; + + procedure SkipEndLine; + begin + while not Eof and not CharIsReturn(Char(CurrPos^)) do + Inc(CurrPos); + SkipWhiteSpace; + end; + + function IsDecDigit: Boolean; + begin + Result := CharIsDigit(Char(CurrPos^)); + end; + + function ReadTextLine: string; + var + P: PJclMapString; + begin + P := CurrPos; + while (P^ <> #0) and not (P^ in [#10, #13]) do + Inc(P); + SetString(Result, CurrPos, P - CurrPos); + CurrPos := P; + end; + + + function ReadDecValue: Integer; + var + P: PJclMapString; + begin + P := CurrPos; + Result := 0; + while P^ in ['0'..'9'] do + begin + Result := Result * 10 + (Ord(P^) - Ord('0')); + Inc(P); + end; + CurrPos := P; + end; + + function ReadHexValue: DWORD; + var + C: AnsiChar; + begin + Result := 0; + repeat + C := CurrPos^; + case C of + '0'..'9': + Result := (Result shl 4) or DWORD(Ord(C) - Ord('0')); + 'A'..'F': + Result := (Result shl 4) or DWORD(Ord(C) - Ord('A') + 10); + 'a'..'f': + Result := (Result shl 4) or DWORD(Ord(C) - Ord('a') + 10); + 'H', 'h': + begin + Inc(CurrPos); + Break; + end; + else + Break; + end; + Inc(CurrPos); + until False; + end; + + function ReadAddress: TJclMapAddress; + begin + Result.Segment := ReadHexValue; + if CurrPos^ = ':' then + begin + Inc(CurrPos); + Result.Offset := ReadHexValue; + end + else + Result.Offset := 0; + end; + + function ReadString: PJclMapString; + begin + SkipWhiteSpace; + Result := CurrPos; + while {(CurrPos^ <> #0) and} (CurrPos^ > ' ') do + Inc(CurrPos); + end; + + procedure FindParam(Param: AnsiChar); + begin + while not ((CurrPos^ = Param) and ((CurrPos + 1)^ = '=')) do + Inc(CurrPos); + Inc(CurrPos, 2); + end; + + function SyncToHeader(const Header: array of string): Boolean; + var + S: string; + TokenIndex, OldPosition, CurrentPosition: Integer; + begin + Result := False; + while not Eof do + begin + S := Trim(ReadTextLine); + TokenIndex := Low(Header); + CurrentPosition := 0; + OldPosition := 0; + while (TokenIndex <= High(Header)) do + begin + CurrentPosition := Pos(Header[TokenIndex],S); + if (CurrentPosition <= OldPosition) then + begin + CurrentPosition := 0; + Break; + end; + OldPosition := CurrentPosition; + Inc(TokenIndex); + end; + Result := CurrentPosition <> 0; + if Result then + Break; + SkipEndLine; + end; + if not Eof then + SkipWhiteSpace; + end; + + function SyncToPrefix(const Prefix: string): Boolean; + var + I: Integer; + P: PJclMapString; + S: string; + begin + if Eof then + begin + Result := False; + Exit; + end; + SkipWhiteSpace; + I := Length(Prefix); + P := CurrPos; + while not Eof and (P^ <> #13) and (P^ <> #0) and (I > 0) do + begin + Inc(P); + Dec(I); + end; + SetString(S, CurrPos, Length(Prefix)); + Result := (S = Prefix); + if Result then + CurrPos := P; + SkipWhiteSpace; + end; + +begin + if FStream <> nil then + begin + FLinkerBug := False; +{$IFNDEF COMPILER9_UP} + PreviousA.Segment := 0; + PreviousA.Offset := 0; +{$ENDIF COMPILER9_UP} + CurrPos := FStream.Memory; + EndPos := CurrPos + FStream.Size; + if SyncToHeader(TableHeader) then + while IsDecDigit do + begin + A := ReadAddress; + SkipWhiteSpace; + L := ReadHexValue; + P1 := ReadString; + P2 := ReadString; + SkipEndLine; + ClassTableItem(A, L, P1, P2); + end; + if SyncToHeader(SegmentsHeader) then + while IsDecDigit do + begin + A := ReadAddress; + SkipWhiteSpace; + L := ReadHexValue; + FindParam('C'); + P1 := ReadString; + FindParam('M'); + P2 := ReadString; + SkipEndLine; + SegmentItem(A, L, P1, P2); + end; + if SyncToHeader(PublicsByNameHeader) then + while IsDecDigit do + begin + A := ReadAddress; + P1 := ReadString; + SkipEndLine; // compatibility with C++Builder MAP files + PublicsByNameItem(A, P1); + end; + if SyncToHeader(PublicsByValueHeader) then + while not Eof and IsDecDigit do + begin + A := ReadAddress; + P1 := ReadString; + SkipEndLine; // compatibility with C++Builder MAP files + PublicsByValueItem(A, P1); + end; + while SyncToPrefix(LineNumbersPrefix) do + begin + FLastUnitName := CurrPos; + FLastUnitFileName := CurrPos; + while FLastUnitFileName^ <> '(' do + Inc(FLastUnitFileName); + SkipEndLine; + LineNumberUnitItem(FLastUnitName, FLastUnitFileName); + repeat + SkipWhiteSpace; + L := ReadDecValue; + SkipWhiteSpace; + A := ReadAddress; + SkipWhiteSpace; + LineNumbersItem(L, A); +{$IFNDEF COMPILER9_UP} + if (not FLinkerBug) and (A.Offset < PreviousA.Offset) then + begin + FLinkerBugUnitName := FLastUnitName; + FLinkerBug := True; + end; + PreviousA := A; +{$ENDIF COMPILER9_UP} + until not IsDecDigit; + end; + end; +end; + +//=== { TJclMapParser 0 ====================================================== + +procedure TJclMapParser.ClassTableItem(const Address: TJclMapAddress; + Len: Integer; SectionName, GroupName: PJclMapString); +begin + if Assigned(FOnClassTable) then + FOnClassTable(Self, Address, Len, MapStringToStr(SectionName), MapStringToStr(GroupName)); +end; + +procedure TJclMapParser.LineNumbersItem(LineNumber: Integer; const Address: TJclMapAddress); +begin + if Assigned(FOnLineNumbers) then + FOnLineNumbers(Self, LineNumber, Address); +end; + +procedure TJclMapParser.LineNumberUnitItem(UnitName, UnitFileName: PJclMapString); +begin + if Assigned(FOnLineNumberUnit) then + FOnLineNumberUnit(Self, MapStringToStr(UnitName), MapStringToStr(UnitFileName)); +end; + +procedure TJclMapParser.PublicsByNameItem(const Address: TJclMapAddress; + Name: PJclMapString); +begin + if Assigned(FOnPublicsByName) then + // MAP files generated by C++Builder have spaces in their identifier names + FOnPublicsByName(Self, Address, MapStringToStr(Name, True)); +end; + +procedure TJclMapParser.PublicsByValueItem(const Address: TJclMapAddress; + Name: PJclMapString); +begin + if Assigned(FOnPublicsByValue) then + // MAP files generated by C++Builder have spaces in their identifier names + FOnPublicsByValue(Self, Address, MapStringToStr(Name, True)); +end; + +procedure TJclMapParser.SegmentItem(const Address: TJclMapAddress; + Len: Integer; GroupName, UnitName: PJclMapString); +begin + if Assigned(FOnSegmentItem) then + FOnSegmentItem(Self, Address, Len, MapStringToStr(GroupName), MapStringToModuleName(UnitName)); +end; + +//=== { TJclMapScanner } ===================================================== + +constructor TJclMapScanner.Create(const MapFileName: TFileName; Module: HMODULE); +begin + inherited Create(MapFileName, Module); + Scan; +end; + +function TJclMapScanner.MAPAddrToVA(const Addr: DWORD): DWORD; +begin + // MAP file format was changed in Delphi 2005 + // before Delphi 2005: segments started at offset 0 + // only one segment of code + // after Delphi 2005: segments started at code base address (module base address + $10000) + // 2 segments of code + if (Length(FSegmentClasses) > 0) and (FSegmentClasses[0].Start > 0) and (Addr >= FSegmentClasses[0].Start) then + // Delphi 2005 and later + // The first segment should be code starting at module base address + $10000 + Result := Addr - FSegmentClasses[0].Start + else + // before Delphi 2005 + Result := Addr; +end; + +class function TJclMapScanner.MapStringCacheToFileName( + var MapString: TJclMapStringCache): string; +begin + Result := MapString.CachedValue; + if Result = '' then + begin + Result := MapStringToFileName(MapString.RawValue); + MapString.CachedValue := Result; + end; +end; + +class function TJclMapScanner.MapStringCacheToModuleName( + var MapString: TJclMapStringCache): string; +begin + Result := MapString.CachedValue; + if Result = '' then + begin + Result := MapStringToModuleName(MapString.RawValue); + MapString.CachedValue := Result; + end; +end; + +class function TJclMapScanner.MapStringCacheToStr(var MapString: TJclMapStringCache; + IgnoreSpaces: Boolean): string; +begin + Result := MapString.CachedValue; + if Result = '' then + begin + Result := MapStringToStr(MapString.RawValue, IgnoreSpaces); + MapString.CachedValue := Result; + end; +end; + +procedure TJclMapScanner.ClassTableItem(const Address: TJclMapAddress; Len: Integer; + SectionName, GroupName: PJclMapString); +var + C: Integer; + SectionHeader: PImageSectionHeader; +begin + C := Length(FSegmentClasses); + SetLength(FSegmentClasses, C + 1); + FSegmentClasses[C].Segment := Address.Segment; + FSegmentClasses[C].Start := Address.Offset; + FSegmentClasses[C].Addr := Address.Offset; // will be fixed below while considering module mapped address + // test GroupName because SectionName = '.tls' in Delphi and '_tls' in BCB + if StrLICompA(GroupName, 'TLS', 3) = 0 then + FSegmentClasses[C].VA := FSegmentClasses[C].Start + else + FSegmentClasses[C].VA := MAPAddrToVA(FSegmentClasses[C].Start); + FSegmentClasses[C].Len := Len; + FSegmentClasses[C].SectionName.RawValue := SectionName; + FSegmentClasses[C].GroupName.RawValue := GroupName; + + if FModule <> 0 then + begin + { Fix the section addresses } + SectionHeader := PeMapImgFindSectionFromModule(Pointer(FModule), MapStringToStr(SectionName)); + if SectionHeader = nil then + { before Delphi 2005 the class names where used for the section names } + SectionHeader := PeMapImgFindSectionFromModule(Pointer(FModule), MapStringToStr(GroupName)); + + if SectionHeader <> nil then + begin + FSegmentClasses[C].Addr := TJclAddr(FModule) + SectionHeader.VirtualAddress; + FSegmentClasses[C].VA := SectionHeader.VirtualAddress; + end; + end; +end; + +function TJclMapScanner.LineNumberFromAddr(Addr: DWORD): Integer; +var + Dummy: Integer; +begin + Result := LineNumberFromAddr(Addr, Dummy); +end; + +function Search_MapLineNumber(Item1, Item2: Pointer): Integer; +begin + Result := Integer(PJclMapLineNumber(Item1)^.VA) - PInteger(Item2)^; +end; + +function TJclMapScanner.LineNumberFromAddr(Addr: DWORD; out Offset: Integer): Integer; +var + I: Integer; + ModuleStartAddr: DWORD; +begin + ModuleStartAddr := ModuleStartFromAddr(Addr); + Result := 0; + Offset := 0; + I := SearchDynArray(FLineNumbers, SizeOf(FLineNumbers[0]), Search_MapLineNumber, @Addr, True); + if (I <> -1) and (FLineNumbers[I].VA >= ModuleStartAddr) then + begin + Result := FLineNumbers[I].LineNumber; + Offset := Addr - FLineNumbers[I].VA; + end; +end; + +procedure TJclMapScanner.LineNumbersItem(LineNumber: Integer; const Address: TJclMapAddress); +var + SegIndex, C: Integer; + VA: DWORD; + Added: Boolean; +begin + Added := False; + for SegIndex := Low(FSegmentClasses) to High(FSegmentClasses) do + if (FSegmentClasses[SegIndex].Segment = Address.Segment) + and (DWORD(Address.Offset) < FSegmentClasses[SegIndex].Len) then + begin + if StrLICompA(FSegmentClasses[SegIndex].GroupName.RawValue, 'TLS', 3) = 0 then + Va := Address.Offset + else + VA := MAPAddrToVA(Address.Offset + FSegmentClasses[SegIndex].Start); + { Starting with Delphi 2005, "empty" units are listes with the last line and + the VA 0001:00000000. When we would accept 0 VAs here, System.pas functions + could be mapped to other units and line numbers. Discaring such items should + have no impact on the correct information, because there can't be a function + that starts at VA 0. } + if VA = 0 then + Continue; + if FLineNumbersCnt = Length(FLineNumbers) then + begin + if FLineNumbersCnt < 512 then + SetLength(FLineNumbers, FLineNumbersCnt + 512) + else + SetLength(FLineNumbers, FLineNumbersCnt * 2); + end; + FLineNumbers[FLineNumbersCnt].Segment := FSegmentClasses[SegIndex].Segment; + FLineNumbers[FLineNumbersCnt].VA := VA; + FLineNumbers[FLineNumbersCnt].LineNumber := LineNumber; + Inc(FLineNumbersCnt); + Added := True; + if FNewUnitFileName <> nil then + begin + C := Length(FSourceNames); + SetLength(FSourceNames, C + 1); + FSourceNames[C].Segment := FSegmentClasses[SegIndex].Segment; + FSourceNames[C].VA := VA; + FSourceNames[C].ProcName.RawValue := FNewUnitFileName; + FNewUnitFileName := nil; + end; + Break; + end; + if not Added then + Inc(FLineNumberErrors); +end; + +procedure TJclMapScanner.LineNumberUnitItem(UnitName, UnitFileName: PJclMapString); +begin + FNewUnitFileName := UnitFileName; +end; + +function TJclMapScanner.IndexOfSegment(Addr: DWORD): Integer; +var + L, R: Integer; + S: PJclMapSegment; +begin + R := Length(FSegments) - 1; + Result := FLastAccessedSegementIndex; + if Result <= R then + begin + S := @FSegments[Result]; + if (S.StartVA <= Addr) and (Addr < S.EndVA) then + Exit; + end; + + // binary search + L := 0; + while L <= R do + begin + Result := L + (R - L) div 2; + S := @FSegments[Result]; + if Addr >= S.EndVA then + L := Result + 1 + else + begin + R := Result - 1; + if (S.StartVA <= Addr) and (Addr < S.EndVA) then + begin + FLastAccessedSegementIndex := Result; + Exit; + end; + end; + end; + Result := -1; +end; + +function TJclMapScanner.ModuleNameFromAddr(Addr: DWORD): string; +var + I: Integer; +begin + I := IndexOfSegment(Addr); + if I <> -1 then + Result := MapStringCacheToModuleName(FSegments[I].UnitName) + else + Result := ''; +end; + +function TJclMapScanner.ModuleStartFromAddr(Addr: DWORD): DWORD; +var + I: Integer; +begin + I := IndexOfSegment(Addr); + Result := DWORD(-1); + if I <> -1 then + Result := FSegments[I].StartVA; +end; + +function TJclMapScanner.ProcNameFromAddr(Addr: DWORD): string; +var + Dummy: Integer; +begin + Result := ProcNameFromAddr(Addr, Dummy); +end; + +function Search_MapProcName(Item1, Item2: Pointer): Integer; +begin + Result := Integer(PJclMapProcName(Item1)^.VA) - PInteger(Item2)^; +end; + +function TJclMapScanner.ProcNameFromAddr(Addr: DWORD; out Offset: Integer): string; +var + I: Integer; + ModuleStartAddr: DWORD; +begin + ModuleStartAddr := ModuleStartFromAddr(Addr); + Result := ''; + Offset := 0; + I := SearchDynArray(FProcNames, SizeOf(FProcNames[0]), Search_MapProcName, @Addr, True); + if (I <> -1) and (FProcNames[I].VA >= ModuleStartAddr) then + begin + Result := MapStringCacheToStr(FProcNames[I].ProcName, True); + Offset := Addr - FProcNames[I].VA; + end; +end; + +procedure TJclMapScanner.PublicsByNameItem(const Address: TJclMapAddress; Name: PJclMapString); +begin + { TODO : What to do? } +end; + +procedure TJclMapScanner.PublicsByValueItem(const Address: TJclMapAddress; Name: PJclMapString); +var + SegIndex: Integer; +begin + for SegIndex := Low(FSegmentClasses) to High(FSegmentClasses) do + if (FSegmentClasses[SegIndex].Segment = Address.Segment) + and (DWORD(Address.Offset) < FSegmentClasses[SegIndex].Len) then + begin + if FProcNamesCnt = Length(FProcNames) then + begin + if FProcNamesCnt < 512 then + SetLength(FProcNames, FProcNamesCnt + 512) + else + SetLength(FProcNames, FProcNamesCnt * 2); + end; + FProcNames[FProcNamesCnt].Segment := FSegmentClasses[SegIndex].Segment; + if StrLICompA(FSegmentClasses[SegIndex].GroupName.RawValue, 'TLS', 3) = 0 then + FProcNames[FProcNamesCnt].VA := Address.Offset + else + FProcNames[FProcNamesCnt].VA := MAPAddrToVA(Address.Offset + FSegmentClasses[SegIndex].Start); + FProcNames[FProcNamesCnt].ProcName.RawValue := Name; + Inc(FProcNamesCnt); + Break; + end; +end; + +function Sort_MapLineNumber(Item1, Item2: Pointer): Integer; +begin + Result := Integer(PJclMapLineNumber(Item1)^.VA) - Integer(PJclMapLineNumber(Item2)^.VA); +end; + +function Sort_MapProcName(Item1, Item2: Pointer): Integer; +begin + Result := Integer(PJclMapProcName(Item1)^.VA) - Integer(PJclMapProcName(Item2)^.VA); +end; + +function Sort_MapSegment(Item1, Item2: Pointer): Integer; +begin + Result := Integer(PJclMapSegment(Item1)^.StartVA) - Integer(PJclMapSegment(Item2)^.StartVA); +end; + +procedure TJclMapScanner.Scan; +begin + FLineNumberErrors := 0; + FSegmentCnt := 0; + FProcNamesCnt := 0; + FLastAccessedSegementIndex := 0; + Parse; + SetLength(FLineNumbers, FLineNumbersCnt); + SetLength(FProcNames, FProcNamesCnt); + SetLength(FSegments, FSegmentCnt); + SortDynArray(FLineNumbers, SizeOf(FLineNumbers[0]), Sort_MapLineNumber); + SortDynArray(FProcNames, SizeOf(FProcNames[0]), Sort_MapProcName); + SortDynArray(FSegments, SizeOf(FSegments[0]), Sort_MapSegment); + SortDynArray(FSourceNames, SizeOf(FSourceNames[0]), Sort_MapProcName); +end; + +procedure TJclMapScanner.SegmentItem(const Address: TJclMapAddress; Len: Integer; + GroupName, UnitName: PJclMapString); +var + SegIndex: Integer; + VA: DWORD; +begin + for SegIndex := Low(FSegmentClasses) to High(FSegmentClasses) do + if (FSegmentClasses[SegIndex].Segment = Address.Segment) + and (DWORD(Address.Offset) < FSegmentClasses[SegIndex].Len) then + begin + if StrLICompA(FSegmentClasses[SegIndex].GroupName.RawValue, 'TLS', 3) = 0 then + VA := Address.Offset + else + VA := MAPAddrToVA(Address.Offset + FSegmentClasses[SegIndex].Start); + if FSegmentCnt mod 16 = 0 then + SetLength(FSegments, FSegmentCnt + 16); + FSegments[FSegmentCnt].Segment := FSegmentClasses[SegIndex].Segment; + FSegments[FSegmentCnt].StartVA := VA; + FSegments[FSegmentCnt].EndVA := VA + DWORD(Len); + FSegments[FSegmentCnt].UnitName.RawValue := UnitName; + Inc(FSegmentCnt); + Break; + end; +end; + +function TJclMapScanner.SourceNameFromAddr(Addr: DWORD): string; +var + I: Integer; + ModuleStartVA: DWORD; +begin + // try with line numbers first (Delphi compliance) + ModuleStartVA := ModuleStartFromAddr(Addr); + Result := ''; + I := SearchDynArray(FSourceNames, SizeOf(FSourceNames[0]), Search_MapProcName, @Addr, True); + if (I <> -1) and (FSourceNames[I].VA >= ModuleStartVA) then + Result := MapStringCacheToStr(FSourceNames[I].ProcName); + if Result = '' then + begin + // try with module names (C++Builder compliance) + I := IndexOfSegment(Addr); + if I <> -1 then + Result := MapStringCacheToFileName(FSegments[I].UnitName); + end; +end; + +// JCL binary debug format string encoding/decoding routines +{ Strings are compressed to following 6bit format (A..D represents characters) and terminated with } +{ 6bit #0 char. First char = #1 indicates non compressed text, #2 indicates compressed text with } +{ leading '@' character } +{ } +{ 7 6 5 4 3 2 1 0 | } +{--------------------------------- } +{ B1 B0 A5 A4 A3 A2 A1 A0 | Data byte 0 } +{--------------------------------- } +{ C3 C2 C1 C0 B5 B4 B3 B2 | Data byte 1 } +{--------------------------------- } +{ D5 D4 D3 D2 D1 D0 C5 C4 | Data byte 2 } +{--------------------------------- } + +function SimpleCryptString(const S: TUTF8String): TUTF8String; +var + I: Integer; + C: Byte; + P: PByte; +begin + SetLength(Result, Length(S)); + P := PByte(Result); + for I := 1 to Length(S) do + begin + C := Ord(S[I]); + if C <> $AA then + C := C xor $AA; + P^ := C; + Inc(P); + end; +end; + +function DecodeNameString(const S: PAnsiChar): string; +var + I, B: Integer; + C: Byte; + P: PByte; + Buffer: array [0..255] of AnsiChar; +begin + Result := ''; + B := 0; + P := PByte(S); + case P^ of + 1: + begin + Inc(P); + Result := UTF8ToString(SimpleCryptString(PAnsiChar(P))); + Exit; + end; + 2: + begin + Inc(P); + Buffer[B] := '@'; + Inc(B); + end; + end; + I := 0; + C := 0; + repeat + case I and $03 of + 0: + C := P^ and $3F; + 1: + begin + C := (P^ shr 6) and $03; + Inc(P); + Inc(C, (P^ and $0F) shl 2); + end; + 2: + begin + C := (P^ shr 4) and $0F; + Inc(P); + Inc(C, (P^ and $03) shl 4); + end; + 3: + begin + C := (P^ shr 2) and $3F; + Inc(P); + end; + end; + case C of + $00: + Break; + $01..$0A: + Inc(C, Ord('0') - $01); + $0B..$24: + Inc(C, Ord('A') - $0B); + $25..$3E: + Inc(C, Ord('a') - $25); + $3F: + C := Ord('_'); + end; + Buffer[B] := AnsiChar(C); + Inc(B); + Inc(I); + until B >= SizeOf(Buffer) - 1; + Buffer[B] := #0; + Result := UTF8ToString(Buffer); +end; + +function EncodeNameString(const S: string): AnsiString; +var + I, StartIndex, EndIndex: Integer; + C: Byte; + P: PByte; +begin + if (Length(S) > 1) and (S[1] = '@') then + StartIndex := 1 + else + StartIndex := 0; + for I := StartIndex + 1 to Length(S) do + if not CharIsValidIdentifierLetter(Char(S[I])) then + begin + {$IFDEF SUPPORTS_UNICODE} + Result := #1 + SimpleCryptString(UTF8Encode(S)) + #0; // UTF8Encode is much faster than StringToUTF8 + {$ELSE} + Result := #1 + SimpleCryptString(StringToUTF8(S)) + #0; + {$ENDIF SUPPORTS_UNICODE} + Exit; + end; + SetLength(Result, Length(S) + StartIndex); + P := Pointer(Result); + if StartIndex = 1 then + P^ := 2 // store '@' leading char information + else + Dec(P); + EndIndex := Length(S) - StartIndex; + for I := 0 to EndIndex do // including null char + begin + if I = EndIndex then + C := 0 + else + C := Byte(S[I + 1 + StartIndex]); + case AnsiChar(C) of + #0: + C := 0; + '0'..'9': + Dec(C, Ord('0') - $01); + 'A'..'Z': + Dec(C, Ord('A') - $0B); + 'a'..'z': + Dec(C, Ord('a') - $25); + '_': + C := $3F; + else + C := $3F; + end; + case I and $03 of + 0: + begin + Inc(P); + P^ := C; + end; + 1: + begin + P^ := P^ or (C and $03) shl 6; + Inc(P); + P^ := (C shr 2) and $0F; + end; + 2: + begin + P^ := P^ or Byte(C shl 4); + Inc(P); + P^ := (C shr 4) and $03; + end; + 3: + P^ := P^ or (C shl 2); + end; + end; + SetLength(Result, TJclAddr(P) - TJclAddr(Pointer(Result)) + 1); +end; + +function ConvertMapFileToJdbgFile(const MapFileName: TFileName): Boolean; +var + Dummy1: string; + Dummy2, Dummy3, Dummy4: Integer; +begin + Result := ConvertMapFileToJdbgFile(MapFileName, Dummy1, Dummy2, Dummy3, Dummy4); +end; + +function ConvertMapFileToJdbgFile(const MapFileName: TFileName; out LinkerBugUnit: string; + out LineNumberErrors: Integer): Boolean; +var + Dummy1, Dummy2: Integer; +begin + Result := ConvertMapFileToJdbgFile(MapFileName, LinkerBugUnit, LineNumberErrors, + Dummy1, Dummy2); +end; + +function ConvertMapFileToJdbgFile(const MapFileName: TFileName; out LinkerBugUnit: string; + out LineNumberErrors, MapFileSize, JdbgFileSize: Integer): Boolean; +var + JDbgFileName: TFileName; + Generator: TJclBinDebugGenerator; +begin + JDbgFileName := ChangeFileExt(MapFileName, JclDbgFileExtension); + Generator := TJclBinDebugGenerator.Create(MapFileName, 0); + try + MapFileSize := Generator.Stream.Size; + JdbgFileSize := Generator.DataStream.Size; + Result := (Generator.DataStream.Size > 0) and Generator.CalculateCheckSum; + if Result then + Generator.DataStream.SaveToFile(JDbgFileName); + LinkerBugUnit := Generator.LinkerBugUnitName; + LineNumberErrors := Generator.LineNumberErrors; + finally + Generator.Free; + end; +end; + +function InsertDebugDataIntoExecutableFile(const ExecutableFileName, MapFileName: TFileName; + out LinkerBugUnit: string; out MapFileSize, JclDebugDataSize: Integer): Boolean; +var + Dummy: Integer; +begin + Result := InsertDebugDataIntoExecutableFile(ExecutableFileName, MapFileName, LinkerBugUnit, + MapFileSize, JclDebugDataSize, Dummy); +end; + +function InsertDebugDataIntoExecutableFile(const ExecutableFileName, MapFileName: TFileName; + out LinkerBugUnit: string; out MapFileSize, JclDebugDataSize, LineNumberErrors: Integer): Boolean; +var + BinDebug: TJclBinDebugGenerator; +begin + BinDebug := TJclBinDebugGenerator.Create(MapFileName, 0); + try + Result := InsertDebugDataIntoExecutableFile(ExecutableFileName, BinDebug, + LinkerBugUnit, MapFileSize, JclDebugDataSize, LineNumberErrors); + finally + BinDebug.Free; + end; +end; + +function InsertDebugDataIntoExecutableFile(const ExecutableFileName: TFileName; + BinDebug: TJclBinDebugGenerator; out LinkerBugUnit: string; + out MapFileSize, JclDebugDataSize: Integer): Boolean; +var + Dummy: Integer; +begin + Result := InsertDebugDataIntoExecutableFile(ExecutableFileName, BinDebug, LinkerBugUnit, + MapFileSize, JclDebugDataSize, Dummy); +end; + +// TODO 64 bit version +function InsertDebugDataIntoExecutableFile(const ExecutableFileName: TFileName; + BinDebug: TJclBinDebugGenerator; out LinkerBugUnit: string; + out MapFileSize, JclDebugDataSize, LineNumberErrors: Integer): Boolean; +var + ImageStream: TStream; + NtHeaders32: TImageNtHeaders32; + ImageSectionHeaders: TImageSectionHeaderArray; + NtHeaders32Position, ImageSectionHeadersPosition, JclDebugSectionPosition: Int64; + JclDebugSection: TImageSectionHeader; + LastSection: PImageSectionHeader; + VirtualAlignedSize: DWORD; + I, X, NeedFill: Integer; + + procedure RoundUpToAlignment(var Value: DWORD; Alignment: DWORD); + begin + if (Value mod Alignment) <> 0 then + Value := ((Value div Alignment) + 1) * Alignment; + end; + +begin + MapFileSize := 0; + JclDebugDataSize := 0; + LineNumberErrors := 0; + LinkerBugUnit := ''; + if BinDebug.Stream <> nil then + begin + Result := True; + if BinDebug.LinkerBug then + begin + LinkerBugUnit := BinDebug.LinkerBugUnitName; + LineNumberErrors := BinDebug.LineNumberErrors; + end; + end + else + Result := False; + if not Result then + Exit; + + ImageStream := TFileStream.Create(ExecutableFileName, fmOpenReadWrite or fmShareExclusive); + try + try + if PeMapImgTarget(ImageStream, 0) = taWin32 then + begin + MapFileSize := BinDebug.Stream.Size; + JclDebugDataSize := BinDebug.DataStream.Size; + NtHeaders32Position := PeMapImgNtHeaders32(ImageStream, 0, NtHeaders32); + Assert(NtHeaders32Position <> -1); + ImageSectionHeadersPosition := PeMapImgSections32(ImageStream, NtHeaders32Position, NtHeaders32, ImageSectionHeaders); + Assert(ImageSectionHeadersPosition <> -1); + // Check whether there is not a section with the name already. If so, return True (#0000069) + if PeMapImgFindSection(ImageSectionHeaders, JclDbgDataResName) <> -1 then + begin + Result := True; + Exit; + end; + + JclDebugSectionPosition := ImageSectionHeadersPosition + (SizeOf(ImageSectionHeaders[0]) * Length(ImageSectionHeaders)); + LastSection := @ImageSectionHeaders[High(ImageSectionHeaders)]; + + // Increase the number of sections + Inc(NtHeaders32.FileHeader.NumberOfSections); + + ResetMemory(JclDebugSection, SizeOf(JclDebugSection)); + // JCLDEBUG Virtual Address + JclDebugSection.VirtualAddress := LastSection^.VirtualAddress + LastSection^.Misc.VirtualSize; + RoundUpToAlignment(JclDebugSection.VirtualAddress, NtHeaders32.OptionalHeader.SectionAlignment); + // JCLDEBUG Physical Offset + JclDebugSection.PointerToRawData := LastSection^.PointerToRawData + LastSection^.SizeOfRawData; + RoundUpToAlignment(JclDebugSection.PointerToRawData, NtHeaders32.OptionalHeader.FileAlignment); + // JCLDEBUG Section name + StrPLCopyA(PAnsiChar(@JclDebugSection.Name), JclDbgDataResName, IMAGE_SIZEOF_SHORT_NAME); + // JCLDEBUG Characteristics flags + JclDebugSection.Characteristics := IMAGE_SCN_MEM_READ or IMAGE_SCN_CNT_INITIALIZED_DATA; + + // Size of virtual data area + JclDebugSection.Misc.VirtualSize := JclDebugDataSize; + VirtualAlignedSize := JclDebugDataSize; + RoundUpToAlignment(VirtualAlignedSize, NtHeaders32.OptionalHeader.SectionAlignment); + // Update Size of Image + Inc(NtHeaders32.OptionalHeader.SizeOfImage, VirtualAlignedSize); + // Raw data size + JclDebugSection.SizeOfRawData := JclDebugDataSize; + RoundUpToAlignment(JclDebugSection.SizeOfRawData, NtHeaders32.OptionalHeader.FileAlignment); + // Update Initialized data size + Inc(NtHeaders32.OptionalHeader.SizeOfInitializedData, JclDebugSection.SizeOfRawData); + + // write NT Headers 32 + if (ImageStream.Seek(NtHeaders32Position, soBeginning) <> NtHeaders32Position) or + (ImageStream.Write(NtHeaders32, SizeOf(NtHeaders32)) <> SizeOf(NtHeaders32)) then + raise EJclPeImageError.CreateRes(@SWriteError); + + // write section header + if (ImageStream.Seek(JclDebugSectionPosition, soBeginning) <> JclDebugSectionPosition) or + (ImageStream.Write(JclDebugSection, SizeOf(JclDebugSection)) <> SizeOf(JclDebugSection)) then + raise EJclPeImageError.CreateRes(@SWriteError); + + // Fill data to alignment + NeedFill := INT_PTR(JclDebugSection.SizeOfRawData) - JclDebugDataSize; + + // Note: Delphi linker seems to generate incorrect (unaligned) size of + // the executable when adding TD32 debug data so the position could be + // behind the size of the file then. + ImageStream.Seek({0 +} JclDebugSection.PointerToRawData, soBeginning); + ImageStream.CopyFrom(BinDebug.DataStream, 0); + X := 0; + for I := 1 to NeedFill do + ImageStream.WriteBuffer(X, 1); + end + else + Result := False; + except + Result := False; + end; + finally + ImageStream.Free; + end; +end; + +//=== { TJclBinDebugGenerator } ============================================== + +constructor TJclBinDebugGenerator.Create(const MapFileName: TFileName; Module: HMODULE); +begin + inherited Create(MapFileName, Module); + FDataStream := TMemoryStream.Create; + FMapFileName := MapFileName; + if FStream <> nil then + CreateData; +end; + +destructor TJclBinDebugGenerator.Destroy; +begin + FreeAndNil(FDataStream); + inherited Destroy; +end; + +{$OVERFLOWCHECKS OFF} + +function TJclBinDebugGenerator.CalculateCheckSum: Boolean; +var + Header: PJclDbgHeader; + P, EndData: PAnsiChar; + CheckSum: Integer; +begin + Result := DataStream.Size >= SizeOf(TJclDbgHeader); + if Result then + begin + P := DataStream.Memory; + EndData := P + DataStream.Size; + Header := PJclDbgHeader(P); + CheckSum := 0; + Header^.CheckSum := 0; + Header^.CheckSumValid := True; + while P < EndData do + begin + Inc(CheckSum, PInteger(P)^); + Inc(PInteger(P)); + end; + Header^.CheckSum := CheckSum; + end; +end; + +{$IFDEF OVERFLOWCHECKS_ON} +{$OVERFLOWCHECKS ON} +{$ENDIF OVERFLOWCHECKS_ON} + +procedure TJclBinDebugGenerator.CreateData; +var + {$IFDEF SUPPORTS_GENERICS} + WordList: TDictionary; + {$ELSE} + WordList: TStringList; + {$ENDIF SUPPORTS_GENERICS} + WordStream: TMemoryStream; + LastSegmentID: Word; + LastSegmentStored: Boolean; + + function AddWord(const S: string): Integer; + var + {$IFDEF SUPPORTS_GENERICS} + LowerS: string; + {$ELSE} + N: Integer; + {$ENDIF SUPPORTS_GENERICS} + E: AnsiString; + begin + if S = '' then + begin + Result := 0; + Exit; + end; + {$IFDEF SUPPORTS_GENERICS} + LowerS := AnsiLowerCase(S); + if not WordList.TryGetValue(LowerS, Result) then + begin + Result := WordStream.Position; + E := EncodeNameString(S); + WordStream.WriteBuffer(E[1], Length(E)); + WordList.Add(LowerS, Result); + end; + {$ELSE} // for large map files this is very slow + N := WordList.IndexOf(S); + if N = -1 then + begin + Result := WordStream.Position; + E := EncodeNameString(S); + WordStream.WriteBuffer(E[1], Length(E)); + WordList.AddObject(S, TObject(Result)); + end + else + Result := DWORD(WordList.Objects[N]); + {$ENDIF SUPPORTS_GENERICS} + Inc(Result); + end; + + procedure WriteValue(Value: Integer); + var + L: Integer; + D: DWORD; + P: array [1..5] of Byte; + begin + D := Value and $FFFFFFFF; + L := 0; + while D > $7F do + begin + Inc(L); + P[L] := (D and $7F) or $80; + D := D shr 7; + end; + Inc(L); + P[L] := (D and $7F); + FDataStream.WriteBuffer(P, L); + end; + + procedure WriteValueOfs(Value: Integer; var LastValue: Integer); + begin + WriteValue(Value - LastValue); + LastValue := Value; + end; + + function IsSegmentStored(SegID: Word): Boolean; + var + SegIndex: Integer; + GroupName: string; + begin + if (SegID <> LastSegmentID) then + begin + LastSegmentID := $FFFF; + LastSegmentStored := False; + for SegIndex := Low(FSegmentClasses) to High(FSegmentClasses) do + if FSegmentClasses[SegIndex].Segment = SegID then + begin + LastSegmentID := FSegmentClasses[SegIndex].Segment; + GroupName := MapStringCacheToStr(FSegmentClasses[SegIndex].GroupName); + LastSegmentStored := (GroupName = 'CODE') or (GroupName = 'ICODE'); + Break; + end; + end; + Result := LastSegmentStored; + end; + +const + AlignBytes: array[0..2] of Byte = (0, 0, 0); +var + FileHeader: TJclDbgHeader; + I, D: Integer; + S: string; + L1, L2, L3: Integer; + FirstWord, SecondWord: Integer; + WordStreamSize, DataStreamSize: Int64; +begin + LastSegmentID := $FFFF; + WordStream := TMemoryStream.Create; + {$IFDEF SUPPORTS_GENERICS} + WordList := TDictionary.Create(Length(FSourceNames) + Length(FProcNames)); + {$ELSE} + WordList := TStringList.Create; + {$ENDIF SUPPORTS_GENERICS} + try + {$IFNDEF SUPPORTS_GENERICS} + WordList.Sorted := True; + WordList.Duplicates := dupError; + {$ENDIF ~SUPPORTS_GENERICS} + WordStream.SetSize((Length(FSourceNames) + Length(FProcNames)) * 40); // take an average of 40 chars per identifier + + FileHeader.Signature := JclDbgDataSignature; + FileHeader.Version := JclDbgHeaderVersion; + FileHeader.CheckSum := 0; + FileHeader.CheckSumValid := False; + FileHeader.ModuleName := AddWord(PathExtractFileNameNoExt(FMapFileName)); + FDataStream.WriteBuffer(FileHeader, SizeOf(FileHeader)); + + FileHeader.Units := FDataStream.Position; + L1 := 0; + L2 := 0; + for I := 0 to Length(FSegments) - 1 do + if IsSegmentStored(FSegments[I].Segment) then + begin + WriteValueOfs(FSegments[I].StartVA, L1); + WriteValueOfs(AddWord(MapStringCacheToModuleName(FSegments[I].UnitName)), L2); + end; + WriteValue(MaxInt); + + FileHeader.SourceNames := FDataStream.Position; + L1 := 0; + L2 := 0; + for I := 0 to Length(FSourceNames) - 1 do + if IsSegmentStored(FSourceNames[I].Segment) then + begin + WriteValueOfs(FSourceNames[I].VA, L1); + WriteValueOfs(AddWord(MapStringCacheToStr(FSourceNames[I].ProcName)), L2); + end; + WriteValue(MaxInt); + + FileHeader.Symbols := FDataStream.Position; + L1 := 0; + L2 := 0; + L3 := 0; + for I := 0 to Length(FProcNames) - 1 do + if IsSegmentStored(FProcNames[I].Segment) then + begin + WriteValueOfs(FProcNames[I].VA, L1); + // MAP files generated by C++Builder have spaces in their names + S := MapStringCacheToStr(FProcNames[I].ProcName, True); + D := Pos('.', S); + if D = 1 then + begin + FirstWord := 0; + SecondWord := 0; + end + else + if D = 0 then + begin + FirstWord := AddWord(S); + SecondWord := 0; + end + else + begin + FirstWord := AddWord(Copy(S, 1, D - 1)); + SecondWord := AddWord(Copy(S, D + 1, Length(S))); + end; + WriteValueOfs(FirstWord, L2); + WriteValueOfs(SecondWord, L3); + end; + WriteValue(MaxInt); + + FileHeader.LineNumbers := FDataStream.Position; + L1 := 0; + L2 := 0; + for I := 0 to Length(FLineNumbers) - 1 do + if IsSegmentStored(FLineNumbers[I].Segment) then + begin + WriteValueOfs(FLineNumbers[I].VA, L1); + WriteValueOfs(FLineNumbers[I].LineNumber, L2); + end; + WriteValue(MaxInt); + + FileHeader.Words := FDataStream.Position; + + // Calculate and allocate the required size in advance instead of reallocating on the fly. + WordStreamSize := WordStream.Position; + DataStreamSize := FDataStream.Position + WordStreamSize; + DataStreamSize := DataStreamSize + (4 - (DataStreamSize and $3)); + FDataStream.Size := DataStreamSize; // set capacity + + WordStream.Position := 0; + FDataStream.CopyFrom(WordStream, WordStreamSize); + + // Align to 4 bytes + FDataStream.WriteBuffer(AlignBytes, 4 - (FDataStream.Position and $3)); + if FDataStream.Size <> FDataStream.Position then // just in case something changed without adjusting the size calculation + FDataStream.Size := FDataStream.Position; + + // Update the file header + FDataStream.Seek(0, soFromBeginning); + FDataStream.WriteBuffer(FileHeader, SizeOf(FileHeader)); + finally + WordStream.Free; + WordList.Free; + end; +end; + +//=== { TJclBinDebugScanner } ================================================ + +constructor TJclBinDebugScanner.Create(AStream: TCustomMemoryStream; CacheData: Boolean); +begin + inherited Create; + FCacheData := CacheData; + FStream := AStream; + CheckFormat; +end; + +procedure TJclBinDebugScanner.CacheLineNumbers; +var + P: Pointer; + Value, LineNumber, C, Ln: Integer; + CurrVA: DWORD; +begin + if FLineNumbers = nil then + begin + LineNumber := 0; + CurrVA := 0; + C := 0; + Ln := 0; + P := MakePtr(PJclDbgHeader(FStream.Memory)^.LineNumbers); + Value := 0; + while ReadValue(P, Value) do + begin + Inc(CurrVA, Value); + ReadValue(P, Value); + Inc(LineNumber, Value); + if C = Ln then + begin + if Ln < 64 then + Ln := 64 + else + Ln := Ln + Ln div 4; + SetLength(FLineNumbers, Ln); + end; + FLineNumbers[C].VA := CurrVA; + FLineNumbers[C].LineNumber := LineNumber; + Inc(C); + end; + SetLength(FLineNumbers, C); + end; +end; + +procedure TJclBinDebugScanner.CacheProcNames; +var + P: Pointer; + Value, FirstWord, SecondWord, C, Ln: Integer; + CurrAddr: DWORD; +begin + if FProcNames = nil then + begin + FirstWord := 0; + SecondWord := 0; + CurrAddr := 0; + C := 0; + Ln := 0; + P := MakePtr(PJclDbgHeader(FStream.Memory)^.Symbols); + Value := 0; + while ReadValue(P, Value) do + begin + Inc(CurrAddr, Value); + ReadValue(P, Value); + Inc(FirstWord, Value); + ReadValue(P, Value); + Inc(SecondWord, Value); + if C = Ln then + begin + if Ln < 64 then + Ln := 64 + else + Ln := Ln + Ln div 4; + SetLength(FProcNames, Ln); + end; + FProcNames[C].Addr := CurrAddr; + FProcNames[C].FirstWord := FirstWord; + FProcNames[C].SecondWord := SecondWord; + Inc(C); + end; + SetLength(FProcNames, C); + end; +end; + +{$OVERFLOWCHECKS OFF} + +procedure TJclBinDebugScanner.CheckFormat; +var + CheckSum: Integer; + Data, EndData: PAnsiChar; + Header: PJclDbgHeader; +begin + Data := FStream.Memory; + Header := PJclDbgHeader(Data); + FValidFormat := (Data <> nil) and (FStream.Size > SizeOf(TJclDbgHeader)) and + (FStream.Size mod 4 = 0) and + (Header^.Signature = JclDbgDataSignature) and (Header^.Version = JclDbgHeaderVersion); + if FValidFormat and Header^.CheckSumValid then + begin + CheckSum := -Header^.CheckSum; + EndData := Data + FStream.Size; + while Data < EndData do + begin + Inc(CheckSum, PInteger(Data)^); + Inc(PInteger(Data)); + end; + CheckSum := (CheckSum shr 8) or (CheckSum shl 24); + FValidFormat := (CheckSum = Header^.CheckSum); + end; +end; + +{$IFDEF OVERFLOWCHECKS_ON} +{$OVERFLOWCHECKS ON} +{$ENDIF OVERFLOWCHECKS_ON} + +function TJclBinDebugScanner.DataToStr(A: Integer): string; +var + P: PAnsiChar; +begin + if A = 0 then + Result := '' + else + begin + P := PAnsiChar(TJclAddr(FStream.Memory) + TJclAddr(A) + TJclAddr(PJclDbgHeader(FStream.Memory)^.Words) - 1); + Result := DecodeNameString(P); + end; +end; + +function TJclBinDebugScanner.GetModuleName: string; +begin + Result := DataToStr(PJclDbgHeader(FStream.Memory)^.ModuleName); +end; + +function TJclBinDebugScanner.IsModuleNameValid(const Name: TFileName): Boolean; +begin + Result := AnsiSameText(ModuleName, PathExtractFileNameNoExt(Name)); +end; + +function TJclBinDebugScanner.LineNumberFromAddr(Addr: DWORD): Integer; +var + Dummy: Integer; +begin + Result := LineNumberFromAddr(Addr, Dummy); +end; + +function TJclBinDebugScanner.LineNumberFromAddr(Addr: DWORD; out Offset: Integer): Integer; +var + P: Pointer; + Value, LineNumber: Integer; + CurrVA, ModuleStartVA, ItemVA: DWORD; +begin + ModuleStartVA := ModuleStartFromAddr(Addr); + LineNumber := 0; + Offset := 0; + if FCacheData then + begin + CacheLineNumbers; + for Value := Length(FLineNumbers) - 1 downto 0 do + if FLineNumbers[Value].VA <= Addr then + begin + if FLineNumbers[Value].VA >= ModuleStartVA then + begin + LineNumber := FLineNumbers[Value].LineNumber; + Offset := Addr - FLineNumbers[Value].VA; + end; + Break; + end; + end + else + begin + P := MakePtr(PJclDbgHeader(FStream.Memory)^.LineNumbers); + CurrVA := 0; + ItemVA := 0; + while ReadValue(P, Value) do + begin + Inc(CurrVA, Value); + if Addr < CurrVA then + begin + if ItemVA < ModuleStartVA then + begin + LineNumber := 0; + Offset := 0; + end; + Break; + end + else + begin + ItemVA := CurrVA; + ReadValue(P, Value); + Inc(LineNumber, Value); + Offset := Addr - CurrVA; + end; + end; + end; + Result := LineNumber; +end; + +function TJclBinDebugScanner.MakePtr(A: Integer): Pointer; +begin + Result := Pointer(TJclAddr(FStream.Memory) + TJclAddr(A)); +end; + +function TJclBinDebugScanner.ModuleNameFromAddr(Addr: DWORD): string; +var + Value, Name: Integer; + StartAddr: DWORD; + P: Pointer; +begin + P := MakePtr(PJclDbgHeader(FStream.Memory)^.Units); + Name := 0; + StartAddr := 0; + Value := 0; + while ReadValue(P, Value) do + begin + Inc(StartAddr, Value); + if Addr < StartAddr then + Break + else + begin + ReadValue(P, Value); + Inc(Name, Value); + end; + end; + Result := DataToStr(Name); +end; + +function TJclBinDebugScanner.ModuleStartFromAddr(Addr: DWORD): DWORD; +var + Value: Integer; + StartAddr, ModuleStartAddr: DWORD; + P: Pointer; +begin + P := MakePtr(PJclDbgHeader(FStream.Memory)^.Units); + StartAddr := 0; + ModuleStartAddr := DWORD(-1); + Value := 0; + while ReadValue(P, Value) do + begin + Inc(StartAddr, Value); + if Addr < StartAddr then + Break + else + begin + ReadValue(P, Value); + ModuleStartAddr := StartAddr; + end; + end; + Result := ModuleStartAddr; +end; + +function TJclBinDebugScanner.ProcNameFromAddr(Addr: DWORD): string; +var + Dummy: Integer; +begin + Result := ProcNameFromAddr(Addr, Dummy); +end; + +function TJclBinDebugScanner.ProcNameFromAddr(Addr: DWORD; out Offset: Integer): string; +var + P: Pointer; + Value, FirstWord, SecondWord: Integer; + CurrAddr, ModuleStartAddr, ItemAddr: DWORD; +begin + ModuleStartAddr := ModuleStartFromAddr(Addr); + FirstWord := 0; + SecondWord := 0; + Offset := 0; + if FCacheData then + begin + CacheProcNames; + for Value := Length(FProcNames) - 1 downto 0 do + if FProcNames[Value].Addr <= Addr then + begin + if FProcNames[Value].Addr >= ModuleStartAddr then + begin + FirstWord := FProcNames[Value].FirstWord; + SecondWord := FProcNames[Value].SecondWord; + Offset := Addr - FProcNames[Value].Addr; + end; + Break; + end; + end + else + begin + P := MakePtr(PJclDbgHeader(FStream.Memory)^.Symbols); + CurrAddr := 0; + ItemAddr := 0; + while ReadValue(P, Value) do + begin + Inc(CurrAddr, Value); + if Addr < CurrAddr then + begin + if ItemAddr < ModuleStartAddr then + begin + FirstWord := 0; + SecondWord := 0; + Offset := 0; + end; + Break; + end + else + begin + ItemAddr := CurrAddr; + ReadValue(P, Value); + Inc(FirstWord, Value); + ReadValue(P, Value); + Inc(SecondWord, Value); + Offset := Addr - CurrAddr; + end; + end; + end; + if FirstWord <> 0 then + begin + Result := DataToStr(FirstWord); + if SecondWord <> 0 then + Result := Result + '.' + DataToStr(SecondWord) + end + else + Result := ''; +end; + +function TJclBinDebugScanner.ReadValue(var P: Pointer; var Value: Integer): Boolean; +var + N: Integer; + I: Integer; + B: Byte; +begin + N := 0; + I := 0; + repeat + B := PByte(P)^; + Inc(PByte(P)); + Inc(N, (B and $7F) shl I); + Inc(I, 7); + until B and $80 = 0; + Value := N; + Result := (Value <> MaxInt); +end; + +function TJclBinDebugScanner.SourceNameFromAddr(Addr: DWORD): string; +var + Value, Name: Integer; + StartAddr, ModuleStartAddr, ItemAddr: DWORD; + P: Pointer; + Found: Boolean; +begin + ModuleStartAddr := ModuleStartFromAddr(Addr); + P := MakePtr(PJclDbgHeader(FStream.Memory)^.SourceNames); + Name := 0; + StartAddr := 0; + ItemAddr := 0; + Found := False; + Value := 0; + while ReadValue(P, Value) do + begin + Inc(StartAddr, Value); + if Addr < StartAddr then + begin + if ItemAddr < ModuleStartAddr then + Name := 0 + else + Found := True; + Break; + end + else + begin + ItemAddr := StartAddr; + ReadValue(P, Value); + Inc(Name, Value); + end; + end; + if Found then + Result := DataToStr(Name) + else + Result := ''; +end; + +//=== { TJclLocationInfoEx } ================================================= + +constructor TJclLocationInfoEx.Create(AParent: TJclCustomLocationInfoList; Address: Pointer); +var + Options: TJclLocationInfoListOptions; +begin + inherited Create; + FAddress := Address; + FParent := AParent; + if Assigned(FParent) then + Options := FParent.Options + else + Options := []; + Fill(Options); +end; + +procedure TJclLocationInfoEx.AssignTo(Dest: TPersistent); +begin + if Dest is TJclLocationInfoEx then + begin + TJclLocationInfoEx(Dest).FAddress := FAddress; + TJclLocationInfoEx(Dest).FBinaryFileName := FBinaryFileName; + TJclLocationInfoEx(Dest).FDebugInfo := FDebugInfo; + TJclLocationInfoEx(Dest).FLineNumber := FLineNumber; + TJclLocationInfoEx(Dest).FLineNumberOffsetFromProcedureStart := FLineNumberOffsetFromProcedureStart; + TJclLocationInfoEx(Dest).FModuleName := FModuleName; + TJclLocationInfoEx(Dest).FOffsetFromLineNumber := FOffsetFromLineNumber; + TJclLocationInfoEx(Dest).FOffsetFromProcName := FOffsetFromProcName; + TJclLocationInfoEx(Dest).FProcedureName := FProcedureName; + TJclLocationInfoEx(Dest).FSourceName := FSourceName; + TJclLocationInfoEx(Dest).FSourceUnitName := FSourceUnitName; + TJclLocationInfoEx(Dest).FUnitVersionDateTime := FUnitVersionDateTime; + TJclLocationInfoEx(Dest).FUnitVersionExtra := FUnitVersionExtra; + TJclLocationInfoEx(Dest).FUnitVersionLogPath := FUnitVersionLogPath; + TJclLocationInfoEx(Dest).FUnitVersionRCSfile := FUnitVersionRCSfile; + TJclLocationInfoEx(Dest).FUnitVersionRevision := FUnitVersionRevision; + TJclLocationInfoEx(Dest).FVAddress := FVAddress; + TJclLocationInfoEx(Dest).FValues := FValues; + end + else + inherited AssignTo(Dest); +end; + +procedure TJclLocationInfoEx.Clear; +begin + FAddress := nil; + Fill([]); +end; + +procedure TJclLocationInfoEx.Fill(AOptions: TJclLocationInfoListOptions); +var + Info, StartProcInfo: TJclLocationInfo; + FixedProcedureName: string; + Module: HMODULE; + {$IFDEF UNITVERSIONING} + I: Integer; + UnitVersion: TUnitVersion; + UnitVersioning: TUnitVersioning; + UnitVersioningModule: TUnitVersioningModule; + {$ENDIF UNITVERSIONING} +begin + FValues := []; + if liloAutoGetAddressInfo in AOptions then + begin + Module := ModuleFromAddr(FAddress); + FVAddress := Pointer(TJclAddr(FAddress) - Module - ModuleCodeOffset); + FModuleName := ExtractFileName(GetModulePath(Module)); + end + else + begin + {$IFDEF UNITVERSIONING} + Module := 0; + {$ENDIF UNITVERSIONING} + FVAddress := nil; + FModuleName := ''; + end; + if (liloAutoGetLocationInfo in AOptions) and GetLocationInfo(FAddress, Info) then + begin + FValues := FValues + [lievLocationInfo]; + FOffsetFromProcName := Info.OffsetFromProcName; + FSourceUnitName := Info.UnitName; + FixedProcedureName := Info.ProcedureName; + if Pos(Info.UnitName + '.', FixedProcedureName) = 1 then + FixedProcedureName := Copy(FixedProcedureName, Length(Info.UnitName) + 2, Length(FixedProcedureName) - Length(Info.UnitName) - 1); + FProcedureName := FixedProcedureName; + FSourceName := Info.SourceName; + FLineNumber := Info.LineNumber; + if FLineNumber > 0 then + FOffsetFromLineNumber := Info.OffsetFromLineNumber + else + FOffsetFromLineNumber := 0; + if GetLocationInfo(Pointer(TJclAddr(Info.Address) - + Cardinal(Info.OffsetFromProcName)), StartProcInfo) and (StartProcInfo.LineNumber > 0) then + begin + FLineNumberOffsetFromProcedureStart := Info.LineNumber - StartProcInfo.LineNumber; + FValues := FValues + [lievProcedureStartLocationInfo]; + end + else + FLineNumberOffsetFromProcedureStart := 0; + FDebugInfo := Info.DebugInfo; + FBinaryFileName := Info.BinaryFileName; + end + else + begin + FOffsetFromProcName := 0; + FSourceUnitName := ''; + FProcedureName := ''; + FSourceName := ''; + FLineNumber := 0; + FOffsetFromLineNumber := 0; + FLineNumberOffsetFromProcedureStart := 0; + FDebugInfo := nil; + FBinaryFileName := ''; + end; + FUnitVersionDateTime := 0; + FUnitVersionLogPath := ''; + FUnitVersionRCSfile := ''; + FUnitVersionRevision := ''; + {$IFDEF UNITVERSIONING} + if (liloAutoGetUnitVersionInfo in AOptions) and (FSourceName <> '') then + begin + if not (liloAutoGetAddressInfo in AOptions) then + Module := ModuleFromAddr(FAddress); + UnitVersioning := GetUnitVersioning; + for I := 0 to UnitVersioning.ModuleCount - 1 do + begin + UnitVersioningModule := UnitVersioning.Modules[I]; + if UnitVersioningModule.Instance = Module then + begin + UnitVersion := UnitVersioningModule.FindUnit(FSourceName); + if Assigned(UnitVersion) then + begin + FUnitVersionDateTime := UnitVersion.DateTime; + FUnitVersionLogPath := UnitVersion.LogPath; + FUnitVersionRCSfile := UnitVersion.RCSfile; + FUnitVersionRevision := UnitVersion.Revision; + FValues := FValues + [lievUnitVersionInfo]; + Break; + end; + end; + if lievUnitVersionInfo in FValues then + Break; + end; + end; + {$ENDIF UNITVERSIONING} +end; + +{ TODO -oUSc : Include... better as function than property? } +function TJclLocationInfoEx.GetAsString: string; +const + IncludeStartProcLineOffset = True; + IncludeAddressOffset = True; + IncludeModuleName = True; +var + IncludeVAddress: Boolean; + OffsetStr, StartProcOffsetStr: string; +begin + IncludeVAddress := True; + OffsetStr := ''; + if lievLocationInfo in FValues then + begin + if LineNumber > 0 then + begin + if IncludeStartProcLineOffset and (lievProcedureStartLocationInfo in FValues) then + StartProcOffsetStr := Format(' + %d', [LineNumberOffsetFromProcedureStart]) + else + StartProcOffsetStr := ''; + if IncludeAddressOffset then + begin + if OffsetFromLineNumber >= 0 then + OffsetStr := Format(' + $%x', [OffsetFromLineNumber]) + else + OffsetStr := Format(' - $%x', [-OffsetFromLineNumber]) + end; + Result := Format('[%p] %s.%s (Line %u, "%s"%s)%s', [Address, SourceUnitName, ProcedureName, LineNumber, + SourceName, StartProcOffsetStr, OffsetStr]); + end + else + begin + if IncludeAddressOffset then + OffsetStr := Format(' + $%x', [OffsetFromProcName]); + if SourceUnitName <> '' then + Result := Format('[%p] %s.%s%s', [Address, SourceUnitName, ProcedureName, OffsetStr]) + else + Result := Format('[%p] %s%s', [Address, ProcedureName, OffsetStr]); + end; + end + else + begin + Result := Format('[%p]', [Address]); + IncludeVAddress := True; + end; + if IncludeVAddress or IncludeModuleName then + begin + if IncludeVAddress then + begin + OffsetStr := Format('(%p) ', [VAddress]); + Result := OffsetStr + Result; + end; + if IncludeModuleName then + Insert(Format('{%-12s}', [ModuleName]), Result, 11 {$IFDEF CPUX64}+ 8{$ENDIF}); + end; +end; + +//=== { TJclCustomLocationInfoList } ========================================= + +constructor TJclCustomLocationInfoList.Create; +begin + inherited Create; + FItemClass := TJclLocationInfoEx; + FItems := TObjectList.Create; + FOptions := []; +end; + +destructor TJclCustomLocationInfoList.Destroy; +begin + FItems.Free; + inherited Destroy; +end; + +procedure TJclCustomLocationInfoList.AddStackInfoList(AStackInfoList: TObject); +var + I: Integer; +begin + TJclStackInfoList(AStackInfoList).ForceStackTracing; + for I := 0 to TJclStackInfoList(AStackInfoList).Count - 1 do + InternalAdd(TJclStackInfoList(AStackInfoList)[I].CallerAddr); +end; + +procedure TJclCustomLocationInfoList.AssignTo(Dest: TPersistent); +var + I: Integer; +begin + if Dest is TJclCustomLocationInfoList then + begin + TJclCustomLocationInfoList(Dest).Clear; + for I := 0 to Count - 1 do + TJclCustomLocationInfoList(Dest).InternalAdd(nil).Assign(TJclLocationInfoEx(FItems[I])); + end + else + inherited AssignTo(Dest); +end; + +procedure TJclCustomLocationInfoList.Clear; +begin + FItems.Clear; +end; + +function TJclCustomLocationInfoList.GetAsString: string; +var + I: Integer; + Strings: TStringList; +begin + Strings := TStringList.Create; + try + for I := 0 to Count - 1 do + Strings.Add(TJclLocationInfoEx(FItems[I]).AsString); + Result := Strings.Text; + finally + Strings.Free; + end; +end; + +function TJclCustomLocationInfoList.GetCount: Integer; +begin + Result := FItems.Count; +end; + +function TJclCustomLocationInfoList.InternalAdd(Addr: Pointer): TJclLocationInfoEx; +begin + FItems.Add(FItemClass.Create(Self, Addr)); + Result := TJclLocationInfoEx(FItems.Last); +end; + +//=== { TJclLocationInfoList } =============================================== + +function TJclLocationInfoList.Add(Addr: Pointer): TJclLocationInfoEx; +begin + Result := InternalAdd(Addr); +end; + +constructor TJclLocationInfoList.Create; +begin + inherited Create; + FOptions := [liloAutoGetAddressInfo, liloAutoGetLocationInfo, liloAutoGetUnitVersionInfo]; +end; + +function TJclLocationInfoList.GetItems(AIndex: Integer): TJclLocationInfoEx; +begin + Result := TJclLocationInfoEx(FItems[AIndex]); +end; + +//=== { TJclDebugInfoSource } ================================================ + +constructor TJclDebugInfoSource.Create(AModule: HMODULE); +begin + FModule := AModule; +end; + +function TJclDebugInfoSource.GetFileName: TFileName; +begin + Result := GetModulePath(FModule); +end; + +function TJclDebugInfoSource.VAFromAddr(const Addr: Pointer): DWORD; +begin + Result := DWORD(TJclAddr(Addr) - FModule - ModuleCodeOffset); +end; + +//=== { TJclDebugInfoList } ================================================== + +var + DebugInfoList: TJclDebugInfoList = nil; + InfoSourceClassList: TList = nil; + DebugInfoCritSect: TJclCriticalSection; + +procedure NeedDebugInfoList; +begin + if DebugInfoList = nil then + DebugInfoList := TJclDebugInfoList.Create; +end; + +function TJclDebugInfoList.CreateDebugInfo(const Module: HMODULE): TJclDebugInfoSource; +var + I: Integer; +begin + NeedInfoSourceClassList; + + Result := nil; + for I := 0 to InfoSourceClassList.Count - 1 do + begin + Result := TJclDebugInfoSourceClass(InfoSourceClassList.Items[I]).Create(Module); + try + if Result.InitializeSource then + Break + else + FreeAndNil(Result); + except + Result.Free; + raise; + end; + end; +end; + +function TJclDebugInfoList.GetItemFromModule(const Module: HMODULE): TJclDebugInfoSource; +var + I: Integer; + TempItem: TJclDebugInfoSource; +begin + Result := nil; + if Module = 0 then + Exit; + for I := 0 to Count - 1 do + begin + TempItem := Items[I]; + if TempItem.Module = Module then + begin + Result := TempItem; + Break; + end; + end; + if Result = nil then + begin + Result := CreateDebugInfo(Module); + if Result <> nil then + Add(Result); + end; +end; + +function TJclDebugInfoList.GetItems(Index: Integer): TJclDebugInfoSource; +begin + Result := TJclDebugInfoSource(Get(Index)); +end; + +function TJclDebugInfoList.GetLocationInfo(const Addr: Pointer; out Info: TJclLocationInfo): Boolean; +var + Item: TJclDebugInfoSource; +begin + ResetMemory(Info, SizeOf(Info)); + Item := ItemFromModule[ModuleFromAddr(Addr)]; + if Item <> nil then + Result := Item.GetLocationInfo(Addr, Info) + else + Result := False; +end; + +class procedure TJclDebugInfoList.NeedInfoSourceClassList; +begin + if not Assigned(InfoSourceClassList) then + begin + InfoSourceClassList := TList.Create; + {$IFNDEF DEBUG_NO_BINARY} + InfoSourceClassList.Add(Pointer(TJclDebugInfoBinary)); + {$ENDIF !DEBUG_NO_BINARY} + {$IFNDEF DEBUG_NO_TD32} + {$IFNDEF WINSCP} + InfoSourceClassList.Add(Pointer(TJclDebugInfoTD32)); + {$ENDIF ~WINSCP} + {$ENDIF !DEBUG_NO_TD32} + {$IFNDEF DEBUG_NO_MAP} + InfoSourceClassList.Add(Pointer(TJclDebugInfoMap)); + {$ENDIF !DEBUG_NO_MAP} + {$IFNDEF DEBUG_NO_SYMBOLS} + InfoSourceClassList.Add(Pointer(TJclDebugInfoSymbols)); + {$ENDIF !DEBUG_NO_SYMBOLS} + {$IFNDEF DEBUG_NO_EXPORTS} + InfoSourceClassList.Add(Pointer(TJclDebugInfoExports)); + {$ENDIF !DEBUG_NO_EXPORTS} + end; +end; + +class procedure TJclDebugInfoList.RegisterDebugInfoSource( + const InfoSourceClass: TJclDebugInfoSourceClass); +begin + NeedInfoSourceClassList; + + InfoSourceClassList.Add(Pointer(InfoSourceClass)); +end; + +class procedure TJclDebugInfoList.RegisterDebugInfoSourceFirst( + const InfoSourceClass: TJclDebugInfoSourceClass); +begin + NeedInfoSourceClassList; + + InfoSourceClassList.Insert(0, Pointer(InfoSourceClass)); +end; + +class procedure TJclDebugInfoList.UnRegisterDebugInfoSource( + const InfoSourceClass: TJclDebugInfoSourceClass); +begin + if Assigned(InfoSourceClassList) then + InfoSourceClassList.Remove(Pointer(InfoSourceClass)); +end; + +//=== { TJclDebugInfoMap } =================================================== + +destructor TJclDebugInfoMap.Destroy; +begin + FreeAndNil(FScanner); + inherited Destroy; +end; + +function TJclDebugInfoMap.GetLocationInfo(const Addr: Pointer; out Info: TJclLocationInfo): Boolean; +var + VA: DWORD; +begin + VA := VAFromAddr(Addr); + with FScanner do + begin + Info.UnitName := ModuleNameFromAddr(VA); + Result := Info.UnitName <> ''; + if Result then + begin + Info.Address := Addr; + Info.ProcedureName := ProcNameFromAddr(VA, Info.OffsetFromProcName); + Info.LineNumber := LineNumberFromAddr(VA, Info.OffsetFromLineNumber); + Info.SourceName := SourceNameFromAddr(VA); + Info.DebugInfo := Self; + Info.BinaryFileName := FileName; + end; + end; +end; + +function TJclDebugInfoMap.InitializeSource: Boolean; +var + MapFileName: TFileName; +begin + MapFileName := ChangeFileExt(FileName, JclMapFileExtension); + Result := FileExists(MapFileName); + if Result then + FScanner := TJclMapScanner.Create(MapFileName, Module); +end; + +//=== { TJclDebugInfoBinary } ================================================ + +destructor TJclDebugInfoBinary.Destroy; +begin + FreeAndNil(FScanner); + FreeAndNil(FStream); + inherited Destroy; +end; + +function TJclDebugInfoBinary.GetLocationInfo(const Addr: Pointer; out Info: TJclLocationInfo): Boolean; +var + VA: DWORD; +begin + VA := VAFromAddr(Addr); + with FScanner do + begin + Info.UnitName := ModuleNameFromAddr(VA); + Result := Info.UnitName <> ''; + if Result then + begin + Info.Address := Addr; + Info.ProcedureName := ProcNameFromAddr(VA, Info.OffsetFromProcName); + Info.LineNumber := LineNumberFromAddr(VA, Info.OffsetFromLineNumber); + Info.SourceName := SourceNameFromAddr(VA); + Info.DebugInfo := Self; + Info.BinaryFileName := FileName; + end; + end; +end; + +function TJclDebugInfoBinary.InitializeSource: Boolean; +var + JdbgFileName: TFileName; + VerifyFileName: Boolean; +begin + VerifyFileName := False; + Result := (PeMapImgFindSectionFromModule(Pointer(Module), JclDbgDataResName) <> nil); + if Result then + FStream := TJclPeSectionStream.Create(Module, JclDbgDataResName) + else + begin + JdbgFileName := ChangeFileExt(FileName, JclDbgFileExtension); + Result := FileExists(JdbgFileName); + if Result then + begin + FStream := TJclFileMappingStream.Create(JdbgFileName, fmOpenRead or fmShareDenyWrite); + VerifyFileName := True; + end; + end; + if Result then + begin + FScanner := TJclBinDebugScanner.Create(FStream, True); + Result := FScanner.ValidFormat and + (not VerifyFileName or FScanner.IsModuleNameValid(FileName)); + end; +end; + +//=== { TJclDebugInfoExports } =============================================== + +destructor TJclDebugInfoExports.Destroy; +begin + FreeAndNil(FImage); + inherited Destroy; +end; + +function TJclDebugInfoExports.IsAddressInThisExportedFunction(Addr: PByteArray; FunctionStartAddr: TJclAddr): Boolean; +begin + Dec(TJclAddr(Addr), 6); + Result := False; + + while TJclAddr(Addr) > FunctionStartAddr do + begin + if IsBadReadPtr(Addr, 6) then + Exit; + + if (Addr[0] = $C2) and // ret $xxxx + (((Addr[3] = $90) and (Addr[4] = $90) and (Addr[5] = $90)) or // nop + ((Addr[3] = $CC) and (Addr[4] = $CC) and (Addr[5] = $CC))) then // int 3 + Exit; + + if (Addr[0] = $C3) and // ret + (((Addr[1] = $90) and (Addr[2] = $90) and (Addr[3] = $90)) or // nop + ((Addr[1] = $CC) and (Addr[2] = $CC) and (Addr[3] = $CC))) then // int 3 + Exit; + + if (Addr[0] = $E9) and // jmp rel-far + (((Addr[5] = $90) and (Addr[6] = $90) and (Addr[7] = $90)) or // nop + ((Addr[5] = $CC) and (Addr[6] = $CC) and (Addr[7] = $CC))) then // int 3 + Exit; + + if (Addr[0] = $EB) and // jmp rel-near + (((Addr[2] = $90) and (Addr[3] = $90) and (Addr[4] = $90)) or // nop + ((Addr[2] = $CC) and (Addr[3] = $CC) and (Addr[4] = $CC))) then // int 3 + Exit; + + Dec(TJclAddr(Addr)); + end; + Result := True; +end; + +function TJclDebugInfoExports.GetLocationInfo(const Addr: Pointer; out Info: TJclLocationInfo): Boolean; +var + I, BasePos: Integer; + VA: DWORD; + Desc: TJclBorUmDescription; + Unmangled: string; + RawName: Boolean; +begin + Result := False; + VA := DWORD(TJclAddr(Addr) - FModule); + {$IFDEF BORLAND} + RawName := not FImage.IsPackage; + {$ENDIF BORLAND} + {$IFDEF FPC} + RawName := True; + {$ENDIF FPC} + Info.OffsetFromProcName := 0; + Info.OffsetFromLineNumber := 0; + Info.BinaryFileName := FileName; + with FImage.ExportList do + begin + SortList(esAddress, False); + for I := Count - 1 downto 0 do + if Items[I].Address <= VA then + begin + if RawName then + begin + Info.ProcedureName := Items[I].Name; + Info.OffsetFromProcName := VA - Items[I].Address; + Result := True; + end + else + begin + case PeBorUnmangleName(Items[I].Name, Unmangled, Desc, BasePos) of + urOk: + begin + Info.UnitName := Copy(Unmangled, 1, BasePos - 2); + if not (Desc.Kind in [skRTTI, skVTable]) then + begin + Info.ProcedureName := Copy(Unmangled, BasePos, Length(Unmangled)); + if smLinkProc in Desc.Modifiers then + Info.ProcedureName := '@' + Info.ProcedureName; + Info.OffsetFromProcName := VA - Items[I].Address; + end; + Result := True; + end; + urNotMangled: + begin + Info.ProcedureName := Items[I].Name; + Info.OffsetFromProcName := VA - Items[I].Address; + Result := True; + end; + end; + end; + if Result then + begin + Info.Address := Addr; + Info.DebugInfo := Self; + + { Check if we have a valid address in an exported function. } + if not IsAddressInThisExportedFunction(Addr, FModule + Items[I].Address) then + begin + //Info.UnitName := '[' + AnsiLowerCase(ExtractFileName(GetModulePath(FModule))) + ']' + {$IFNDEF WINSCP} + Info.ProcedureName := Format(LoadResString(@RsUnknownFunctionAt), [Info.ProcedureName]); + {$ELSE} + Info.ProcedureName := ''; + {$ENDIF ~WINSCP} + end; + + Break; + end; + end; + end; +end; + +function TJclDebugInfoExports.InitializeSource: Boolean; +begin + {$IFDEF BORLAND} + FImage := TJclPeBorImage.Create(True); + {$ENDIF BORLAND} + {$IFDEF FPC} + FImage := TJclPeImage.Create(True); + {$ENDIF FPC} + FImage.AttachLoadedModule(FModule); + Result := FImage.StatusOK and (FImage.ExportList.Count > 0); +end; + +{$IFDEF BORLAND} + +{$IFNDEF WINSCP} + +//=== { TJclDebugInfoTD32 } ================================================== + +destructor TJclDebugInfoTD32.Destroy; +begin + FreeAndNil(FImage); + inherited Destroy; +end; + +function TJclDebugInfoTD32.GetLocationInfo(const Addr: Pointer; out Info: TJclLocationInfo): Boolean; +var + VA: DWORD; +begin + VA := VAFromAddr(Addr); + Info.UnitName := FImage.TD32Scanner.ModuleNameFromAddr(VA); + Result := Info.UnitName <> ''; + if Result then + with Info do + begin + Address := Addr; + ProcedureName := FImage.TD32Scanner.ProcNameFromAddr(VA, OffsetFromProcName); + LineNumber := FImage.TD32Scanner.LineNumberFromAddr(VA, OffsetFromLineNumber); + SourceName := FImage.TD32Scanner.SourceNameFromAddr(VA); + DebugInfo := Self; + BinaryFileName := FileName; + end; +end; + +function TJclDebugInfoTD32.InitializeSource: Boolean; +begin + FImage := TJclPeBorTD32Image.Create(True); + try + FImage.AttachLoadedModule(Module); + Result := FImage.IsTD32DebugPresent; + except + Result := False; + end; +end; + +{$ENDIF ~WINSCP} + +{$ENDIF BORLAND} + +//=== { TJclDebugInfoSymbols } =============================================== + +type + TSymInitializeAFunc = function (hProcess: THandle; UserSearchPath: LPSTR; + fInvadeProcess: Bool): Bool; stdcall; + TSymInitializeWFunc = function (hProcess: THandle; UserSearchPath: LPWSTR; + fInvadeProcess: Bool): Bool; stdcall; + TSymGetOptionsFunc = function: DWORD; stdcall; + TSymSetOptionsFunc = function (SymOptions: DWORD): DWORD; stdcall; + TSymCleanupFunc = function (hProcess: THandle): Bool; stdcall; + {$IFDEF CPU32} + TSymGetSymFromAddrAFunc = function (hProcess: THandle; dwAddr: DWORD; + pdwDisplacement: PDWORD; var Symbol: JclWin32.TImagehlpSymbolA): Bool; stdcall; + TSymGetSymFromAddrWFunc = function (hProcess: THandle; dwAddr: DWORD; + pdwDisplacement: PDWORD; var Symbol: JclWin32.TImagehlpSymbolW): Bool; stdcall; + TSymGetModuleInfoAFunc = function (hProcess: THandle; dwAddr: DWORD; + var ModuleInfo: JclWin32.TImagehlpModuleA): Bool; stdcall; + TSymGetModuleInfoWFunc = function (hProcess: THandle; dwAddr: DWORD; + var ModuleInfo: JclWin32.TImagehlpModuleW): Bool; stdcall; + TSymLoadModuleFunc = function (hProcess: THandle; hFile: THandle; ImageName, + ModuleName: LPSTR; BaseOfDll: DWORD; SizeOfDll: DWORD): DWORD; stdcall; + TSymGetLineFromAddrAFunc = function (hProcess: THandle; dwAddr: DWORD; + pdwDisplacement: PDWORD; var Line: JclWin32.TImageHlpLineA): Bool; stdcall; + TSymGetLineFromAddrWFunc = function (hProcess: THandle; dwAddr: DWORD; + pdwDisplacement: PDWORD; var Line: JclWin32.TImageHlpLineW): Bool; stdcall; + {$ENDIF CPU32} + {$IFDEF CPU64} + TSymGetSymFromAddrAFunc = function (hProcess: THandle; dwAddr: DWORD64; + pdwDisplacement: PDWORD64; var Symbol: JclWin32.TImagehlpSymbolA64): Bool; stdcall; + TSymGetSymFromAddrWFunc = function (hProcess: THandle; dwAddr: DWORD64; + pdwDisplacement: PDWORD64; var Symbol: JclWin32.TImagehlpSymbolW64): Bool; stdcall; + TSymGetModuleInfoAFunc = function (hProcess: THandle; dwAddr: DWORD64; + var ModuleInfo: JclWin32.TImagehlpModuleA64): Bool; stdcall; + TSymGetModuleInfoWFunc = function (hProcess: THandle; dwAddr: DWORD64; + var ModuleInfo: JclWin32.TImagehlpModuleW64): Bool; stdcall; + TSymLoadModuleFunc = function (hProcess: THandle; hFile: THandle; ImageName, + ModuleName: LPSTR; BaseOfDll: DWORD64; SizeOfDll: DWORD): DWORD; stdcall; + TSymGetLineFromAddrAFunc = function (hProcess: THandle; dwAddr: DWORD64; + pdwDisplacement: PDWORD; var Line: JclWin32.TImageHlpLineA64): Bool; stdcall; + TSymGetLineFromAddrWFunc = function (hProcess: THandle; dwAddr: DWORD64; + pdwDisplacement: PDWORD; var Line: JclWin32.TImageHlpLineW64): Bool; stdcall; + {$ENDIF CPU64} + +var + DebugSymbolsInitialized: Boolean = False; + DebugSymbolsLoadFailed: Boolean = False; + ImageHlpDllHandle: THandle = 0; + SymInitializeAFunc: TSymInitializeAFunc = nil; + SymInitializeWFunc: TSymInitializeWFunc = nil; + SymGetOptionsFunc: TSymGetOptionsFunc = nil; + SymSetOptionsFunc: TSymSetOptionsFunc = nil; + SymCleanupFunc: TSymCleanupFunc = nil; + SymGetSymFromAddrAFunc: TSymGetSymFromAddrAFunc = nil; + SymGetSymFromAddrWFunc: TSymGetSymFromAddrWFunc = nil; + SymGetModuleInfoAFunc: TSymGetModuleInfoAFunc = nil; + SymGetModuleInfoWFunc: TSymGetModuleInfoWFunc = nil; + SymLoadModuleFunc: TSymLoadModuleFunc = nil; + SymGetLineFromAddrAFunc: TSymGetLineFromAddrAFunc = nil; + SymGetLineFromAddrWFunc: TSymGetLineFromAddrWFunc = nil; + +const + ImageHlpDllName = 'imagehlp.dll'; // do not localize + SymInitializeAFuncName = 'SymInitialize'; // do not localize + SymInitializeWFuncName = 'SymInitializeW'; // do not localize + SymGetOptionsFuncName = 'SymGetOptions'; // do not localize + SymSetOptionsFuncName = 'SymSetOptions'; // do not localize + SymCleanupFuncName = 'SymCleanup'; // do not localize + {$IFDEF CPU32} + SymGetSymFromAddrAFuncName = 'SymGetSymFromAddr'; // do not localize + SymGetSymFromAddrWFuncName = 'SymGetSymFromAddrW'; // do not localize + SymGetModuleInfoAFuncName = 'SymGetModuleInfo'; // do not localize + SymGetModuleInfoWFuncName = 'SymGetModuleInfoW'; // do not localize + SymLoadModuleFuncName = 'SymLoadModule'; // do not localize + SymGetLineFromAddrAFuncName = 'SymGetLineFromAddr'; // do not localize + SymGetLineFromAddrWFuncName = 'SymGetLineFromAddrW'; // do not localize + {$ENDIF CPU32} + {$IFDEF CPU64} + SymGetSymFromAddrAFuncName = 'SymGetSymFromAddr64'; // do not localize + SymGetSymFromAddrWFuncName = 'SymGetSymFromAddrW64'; // do not localize + SymGetModuleInfoAFuncName = 'SymGetModuleInfo64'; // do not localize + SymGetModuleInfoWFuncName = 'SymGetModuleInfoW64'; // do not localize + SymLoadModuleFuncName = 'SymLoadModule64'; // do not localize + SymGetLineFromAddrAFuncName = 'SymGetLineFromAddr64'; // do not localize + SymGetLineFromAddrWFuncName = 'SymGetLineFromAddrW64'; // do not localize + {$ENDIF CPU64} + +function StrRemoveEmptyPaths(const Paths: string): string; +var + List: TStrings; + I: Integer; +begin + List := TStringList.Create; + try + StrToStrings(Paths, DirSeparator, List, False); + for I := 0 to List.Count - 1 do + if Trim(List[I]) = '' then + List[I] := ''; + Result := StringsToStr(List, DirSeparator, False); + finally + List.Free; + end; +end; + +class function TJclDebugInfoSymbols.InitializeDebugSymbols: Boolean; +var + EnvironmentVarValue, SearchPath: string; + SymOptions: Cardinal; + ProcessHandle: THandle; +begin + Result := DebugSymbolsInitialized; + if not DebugSymbolsLoadFailed then + begin + Result := LoadDebugFunctions; + DebugSymbolsLoadFailed := not Result; + + if Result then + begin + if JclDebugInfoSymbolPaths <> '' then + begin + SearchPath := StrEnsureSuffix(DirSeparator, JclDebugInfoSymbolPaths); + SearchPath := StrEnsureNoSuffix(DirSeparator, SearchPath + GetCurrentFolder); + + if GetEnvironmentVar(EnvironmentVarNtSymbolPath, EnvironmentVarValue) and (EnvironmentVarValue <> '') then + SearchPath := StrEnsureNoSuffix(DirSeparator, StrEnsureSuffix(DirSeparator, EnvironmentVarValue) + SearchPath); + if GetEnvironmentVar(EnvironmentVarAlternateNtSymbolPath, EnvironmentVarValue) and (EnvironmentVarValue <> '') then + SearchPath := StrEnsureNoSuffix(DirSeparator, StrEnsureSuffix(DirSeparator, EnvironmentVarValue) + SearchPath); + + // DbgHelp.dll crashes when an empty path is specified. + // This also means that the SearchPath must not end with a DirSeparator. } + SearchPath := StrRemoveEmptyPaths(SearchPath); + end + else + // Fix crash SymLoadModuleFunc on WinXP SP3 when SearchPath='' + SearchPath := GetCurrentFolder; + + if IsWinNT then + // in Windows NT, first argument is a process handle + ProcessHandle := GetCurrentProcess + else + // in Windows 95, 98, ME first argument is a process identifier + ProcessHandle := GetCurrentProcessId; + + // Debug(WinXPSP3): SymInitializeWFunc==nil + if Assigned(SymInitializeWFunc) then + Result := SymInitializeWFunc(ProcessHandle, PWideChar(WideString(SearchPath)), False) + else + if Assigned(SymInitializeAFunc) then + Result := SymInitializeAFunc(ProcessHandle, PAnsiChar(AnsiString(SearchPath)), False) + else + Result := False; + + if Result then + begin + SymOptions := SymGetOptionsFunc or SYMOPT_DEFERRED_LOADS + or SYMOPT_FAIL_CRITICAL_ERRORS or SYMOPT_INCLUDE_32BIT_MODULES or SYMOPT_LOAD_LINES; + SymOptions := SymOptions and (not (SYMOPT_NO_UNQUALIFIED_LOADS or SYMOPT_UNDNAME)); + SymSetOptionsFunc(SymOptions); + end; + + DebugSymbolsInitialized := Result; + end + else + UnloadDebugFunctions; + end; +end; + +class function TJclDebugInfoSymbols.CleanupDebugSymbols: Boolean; +begin + Result := True; + + if DebugSymbolsInitialized then + Result := SymCleanupFunc(GetCurrentProcess); + + UnloadDebugFunctions; +end; + +function TJclDebugInfoSymbols.GetLocationInfo(const Addr: Pointer; + out Info: TJclLocationInfo): Boolean; +const + SymbolNameLength = 1000; + {$IFDEF CPU32} + SymbolSizeA = SizeOf(TImagehlpSymbolA) + SymbolNameLength * SizeOf(AnsiChar); + SymbolSizeW = SizeOf(TImagehlpSymbolW) + SymbolNameLength * SizeOf(WideChar); + {$ENDIF CPU32} + {$IFDEF CPU64} + SymbolSizeA = SizeOf(TImagehlpSymbolA64) + SymbolNameLength * SizeOf(AnsiChar); + SymbolSizeW = SizeOf(TImagehlpSymbolW64) + SymbolNameLength * SizeOf(WideChar); + {$ENDIF CPU64} +var + Displacement: DWORD; + ProcessHandle: THandle; + {$IFDEF CPU32} + SymbolA: PImagehlpSymbolA; + SymbolW: PImagehlpSymbolW; + LineA: TImageHlpLineA; + LineW: TImageHlpLineW; + {$ENDIF CPU32} + {$IFDEF CPU64} + SymbolA: PImagehlpSymbolA64; + SymbolW: PImagehlpSymbolW64; + LineA: TImageHlpLineA64; + LineW: TImageHlpLineW64; + {$ENDIF CPU64} +begin + ProcessHandle := GetCurrentProcess; + + if Assigned(SymGetSymFromAddrWFunc) then + begin + GetMem(SymbolW, SymbolSizeW); + try + ZeroMemory(SymbolW, SymbolSizeW); + SymbolW^.SizeOfStruct := SizeOf(SymbolW^); + SymbolW^.MaxNameLength := SymbolNameLength; + Displacement := 0; + + Result := SymGetSymFromAddrWFunc(ProcessHandle, TJclAddr(Addr), @Displacement, SymbolW^); + if Result then + begin + Info.DebugInfo := Self; + Info.Address := Addr; + Info.BinaryFileName := FileName; + Info.OffsetFromProcName := Displacement; + JclPeImage.UnDecorateSymbolName(string(WideString(SymbolW^.Name)), Info.ProcedureName, UNDNAME_NAME_ONLY or UNDNAME_NO_ARGUMENTS); + end; + finally + FreeMem(SymbolW); + end; + end + else + if Assigned(SymGetSymFromAddrAFunc) then + begin + GetMem(SymbolA, SymbolSizeA); + try + ZeroMemory(SymbolA, SymbolSizeA); + SymbolA^.SizeOfStruct := SizeOf(SymbolA^); + SymbolA^.MaxNameLength := SymbolNameLength; + Displacement := 0; + + Result := SymGetSymFromAddrAFunc(ProcessHandle, TJclAddr(Addr), @Displacement, SymbolA^); + if Result then + begin + Info.DebugInfo := Self; + Info.Address := Addr; + Info.BinaryFileName := FileName; + Info.OffsetFromProcName := Displacement; + JclPeImage.UnDecorateSymbolName(string(AnsiString(SymbolA^.Name)), Info.ProcedureName, UNDNAME_NAME_ONLY or UNDNAME_NO_ARGUMENTS); + end; + finally + FreeMem(SymbolA); + end; + end + else + Result := False; + + // line number is optional + if Result and Assigned(SymGetLineFromAddrWFunc) then + begin + ZeroMemory(@LineW, SizeOf(LineW)); + LineW.SizeOfStruct := SizeOf(LineW); + Displacement := 0; + + if SymGetLineFromAddrWFunc(ProcessHandle, TJclAddr(Addr), @Displacement, LineW) then + begin + Info.LineNumber := LineW.LineNumber; + Info.UnitName := string(LineW.FileName); + Info.OffsetFromLineNumber := Displacement; + end; + end + else + if Result and Assigned(SymGetLineFromAddrAFunc) then + begin + ZeroMemory(@LineA, SizeOf(LineA)); + LineA.SizeOfStruct := SizeOf(LineA); + Displacement := 0; + + if SymGetLineFromAddrAFunc(ProcessHandle, TJclAddr(Addr), @Displacement, LineA) then + begin + Info.LineNumber := LineA.LineNumber; + Info.UnitName := string(LineA.FileName); + Info.OffsetFromLineNumber := Displacement; + end; + end; +end; + +function TJclDebugInfoSymbols.InitializeSource: Boolean; +var + ModuleFileName: TFileName; + {$IFDEF CPU32} + ModuleInfoA: TImagehlpModuleA; + ModuleInfoW: TImagehlpModuleW; + {$ENDIF CPU32} + {$IFDEF CPU64} + ModuleInfoA: TImagehlpModuleA64; + ModuleInfoW: TImagehlpModuleW64; + {$ENDIF CPU64} + ProcessHandle: THandle; +begin + Result := InitializeDebugSymbols; + if Result then + begin + if IsWinNT then + // in Windows NT, first argument is a process handle + ProcessHandle := GetCurrentProcess + else + // in Windows 95, 98, ME, first argument is a process identifier + ProcessHandle := GetCurrentProcessId; + + if Assigned(SymGetModuleInfoWFunc) then + begin + ZeroMemory(@ModuleInfoW, SizeOf(ModuleInfoW)); + ModuleInfoW.SizeOfStruct := SizeOf(ModuleInfoW); + Result := SymGetModuleInfoWFunc(ProcessHandle, Module, ModuleInfoW); + if not Result then + begin + // the symbols for this module are not loaded yet: load the module and query for the symbol again + ModuleFileName := GetModulePath(Module); + ZeroMemory(@ModuleInfoW, SizeOf(ModuleInfoW)); + ModuleInfoW.SizeOfStruct := SizeOf(ModuleInfoW); + // warning: crash on WinXP SP3 when SymInitializeAFunc is called with empty SearchPath + // OF: possible loss of data + Result := (SymLoadModuleFunc(ProcessHandle, 0, PAnsiChar(AnsiString(ModuleFileName)), nil, 0, 0) <> 0) and + SymGetModuleInfoWFunc(ProcessHandle, Module, ModuleInfoW); + end; + Result := Result and (ModuleInfoW.BaseOfImage <> 0) and + not (ModuleInfoW.SymType in [SymNone, SymExport]); + end + else + if Assigned(SymGetModuleInfoAFunc) then + begin + ZeroMemory(@ModuleInfoA, SizeOf(ModuleInfoA)); + ModuleInfoA.SizeOfStruct := SizeOf(ModuleInfoA); + Result := SymGetModuleInfoAFunc(ProcessHandle, Module, ModuleInfoA); + if not Result then + begin + // the symbols for this module are not loaded yet: load the module and query for the symbol again + ModuleFileName := GetModulePath(Module); + ZeroMemory(@ModuleInfoA, SizeOf(ModuleInfoA)); + ModuleInfoA.SizeOfStruct := SizeOf(ModuleInfoA); + // warning: crash on WinXP SP3 when SymInitializeAFunc is called with empty SearchPath + // OF: possible loss of data + Result := (SymLoadModuleFunc(ProcessHandle, 0, PAnsiChar(AnsiString(ModuleFileName)), nil, 0, 0) <> 0) and + SymGetModuleInfoAFunc(ProcessHandle, Module, ModuleInfoA); + end; + Result := Result and (ModuleInfoA.BaseOfImage <> 0) and + not (ModuleInfoA.SymType in [SymNone, SymExport]); + end + else + Result := False; + end; +end; + +class function TJclDebugInfoSymbols.LoadDebugFunctions: Boolean; +begin + ImageHlpDllHandle := SafeLoadLibrary(ImageHlpDllName); + + if ImageHlpDllHandle <> 0 then + begin + SymInitializeAFunc := GetProcAddress(ImageHlpDllHandle, SymInitializeAFuncName); + SymInitializeWFunc := GetProcAddress(ImageHlpDllHandle, SymInitializeWFuncName); + SymGetOptionsFunc := GetProcAddress(ImageHlpDllHandle, SymGetOptionsFuncName); + SymSetOptionsFunc := GetProcAddress(ImageHlpDllHandle, SymSetOptionsFuncName); + SymCleanupFunc := GetProcAddress(ImageHlpDllHandle, SymCleanupFuncName); + SymGetSymFromAddrAFunc := GetProcAddress(ImageHlpDllHandle, SymGetSymFromAddrAFuncName); + SymGetSymFromAddrWFunc := GetProcAddress(ImageHlpDllHandle, SymGetSymFromAddrWFuncName); + SymGetModuleInfoAFunc := GetProcAddress(ImageHlpDllHandle, SymGetModuleInfoAFuncName); + SymGetModuleInfoWFunc := GetProcAddress(ImageHlpDllHandle, SymGetModuleInfoWFuncName); + SymLoadModuleFunc := GetProcAddress(ImageHlpDllHandle, SymLoadModuleFuncName); + SymGetLineFromAddrAFunc := GetProcAddress(ImageHlpDllHandle, SymGetLineFromAddrAFuncName); + SymGetLineFromAddrWFunc := GetProcAddress(ImageHlpDllHandle, SymGetLineFromAddrWFuncName); + end; + + // SymGetLineFromAddrFunc is optional + Result := (ImageHlpDllHandle <> 0) and + Assigned(SymGetOptionsFunc) and Assigned(SymSetOptionsFunc) and + Assigned(SymCleanupFunc) and Assigned(SymLoadModuleFunc) and + (Assigned(SymInitializeAFunc) or Assigned(SymInitializeWFunc)) and + (Assigned(SymGetSymFromAddrAFunc) or Assigned(SymGetSymFromAddrWFunc)) and + (Assigned(SymGetModuleInfoAFunc) or Assigned(SymGetModuleInfoWFunc)); +end; + +class function TJclDebugInfoSymbols.UnloadDebugFunctions: Boolean; +begin + Result := ImageHlpDllHandle <> 0; + + if Result then + FreeLibrary(ImageHlpDllHandle); + + ImageHlpDllHandle := 0; + + SymInitializeAFunc := nil; + SymInitializeWFunc := nil; + SymGetOptionsFunc := nil; + SymSetOptionsFunc := nil; + SymCleanupFunc := nil; + SymGetSymFromAddrAFunc := nil; + SymGetSymFromAddrWFunc := nil; + SymGetModuleInfoAFunc := nil; + SymGetModuleInfoWFunc := nil; + SymLoadModuleFunc := nil; + SymGetLineFromAddrAFunc := nil; + SymGetLineFromAddrWFunc := nil; +end; + +//=== Source location functions ============================================== + +{$STACKFRAMES ON} + +function Caller(Level: Integer; FastStackWalk: Boolean): Pointer; +var + TopOfStack: TJclAddr; + BaseOfStack: TJclAddr; + StackFrame: PStackFrame; +begin + Result := nil; + try + if FastStackWalk then + begin + StackFrame := GetFramePointer; + BaseOfStack := TJclAddr(StackFrame) - 1; + TopOfStack := GetStackTop; + while (BaseOfStack < TJclAddr(StackFrame)) and (TJclAddr(StackFrame) < TopOfStack) do + begin + if Level = 0 then + begin + Result := Pointer(StackFrame^.CallerAddr - 1); + Break; + end; + StackFrame := PStackFrame(StackFrame^.CallerFrame); + Dec(Level); + end; + end + else + with TJclStackInfoList.Create(False, 1, nil, False, nil, nil) do + try + if Level < Count then + Result := Items[Level].CallerAddr; + finally + Free; + end; + except + Result := nil; + end; +end; + +{$IFNDEF STACKFRAMES_ON} +{$STACKFRAMES OFF} +{$ENDIF ~STACKFRAMES_ON} + +function GetLocationInfo(const Addr: Pointer): TJclLocationInfo; +begin + try + DebugInfoCritSect.Enter; + try + NeedDebugInfoList; + DebugInfoList.GetLocationInfo(Addr, Result) + finally + DebugInfoCritSect.Leave; + end; + except + Finalize(Result); + ResetMemory(Result, SizeOf(Result)); + end; +end; + +function GetLocationInfo(const Addr: Pointer; out Info: TJclLocationInfo): Boolean; +begin + try + DebugInfoCritSect.Enter; + try + NeedDebugInfoList; + Result := DebugInfoList.GetLocationInfo(Addr, Info); + finally + DebugInfoCritSect.Leave; + end; + except + Result := False; + end; +end; + +function GetLocationInfoStr(const Addr: Pointer; IncludeModuleName, IncludeAddressOffset, + IncludeStartProcLineOffset: Boolean; IncludeVAddress: Boolean): string; +var + Info, StartProcInfo: TJclLocationInfo; + OffsetStr, StartProcOffsetStr, FixedProcedureName, UnitNameWithoutUnitscope: string; + Module : HMODULE; + {$IFDEF WINSCP} + MainModule: HMODULE; + ModuleName: string; + ModulePosition: Integer; + {$ENDIF ~WINSCP} +begin + OffsetStr := ''; + if GetLocationInfo(Addr, Info) then + with Info do + begin + FixedProcedureName := ProcedureName; + if Pos(UnitName + '.', FixedProcedureName) = 1 then + FixedProcedureName := Copy(FixedProcedureName, Length(UnitName) + 2, Length(FixedProcedureName) - Length(UnitName) - 1) + else + if Pos('.', UnitName) > 1 then + begin + UnitNameWithoutUnitscope := UnitName; + Delete(UnitNameWithoutUnitscope, 1, Pos('.', UnitNameWithoutUnitscope)); + if Pos(UnitNameWithoutUnitscope + '.', FixedProcedureName) = 1 then + FixedProcedureName := Copy(FixedProcedureName, Length(UnitNameWithoutUnitscope) + 2, Length(FixedProcedureName) - Length(UnitNameWithoutUnitscope) - 1); + end; + + if LineNumber > 0 then + begin + if IncludeStartProcLineOffset and GetLocationInfo(Pointer(TJclAddr(Info.Address) - + Cardinal(Info.OffsetFromProcName)), StartProcInfo) and (StartProcInfo.LineNumber > 0) then + StartProcOffsetStr := Format(' + %d', [LineNumber - StartProcInfo.LineNumber]) + else + StartProcOffsetStr := ''; + if IncludeAddressOffset then + begin + if OffsetFromLineNumber >= 0 then + OffsetStr := Format(' + $%x', [OffsetFromLineNumber]) + else + OffsetStr := Format(' - $%x', [-OffsetFromLineNumber]) + end; + {$IFDEF WINSCP} + Result := Format('[%p] %s (Line %u, "%s"%s)%s', [Addr, FixedProcedureName, LineNumber, + SourceName, StartProcOffsetStr, OffsetStr]); + {$ELSE} + Result := Format('[%p] %s.%s (Line %u, "%s"%s)%s', [Addr, UnitName, FixedProcedureName, LineNumber, + SourceName, StartProcOffsetStr, OffsetStr]); + {$ENDIF} + end + else + begin + if IncludeAddressOffset then + OffsetStr := Format(' + $%x', [OffsetFromProcName]); + {$IFNDEF WINSCP} + if UnitName <> '' then + Result := Format('[%p] %s.%s%s', [Addr, UnitName, FixedProcedureName, OffsetStr]) + else + {$ENDIF} + Result := Format('[%p] %s%s', [Addr, FixedProcedureName, OffsetStr]); + end; + end + else + begin + Result := Format('[%p]', [Addr]); + IncludeVAddress := True; + end; + if IncludeVAddress or IncludeModuleName then + begin + Module := ModuleFromAddr(Addr); + if IncludeVAddress then + begin + OffsetStr := Format('(%p) ', [Pointer(TJclAddr(Addr) - Module - ModuleCodeOffset)]); + Result := OffsetStr + Result; + end; + if IncludeModuleName then + {$IFDEF WINSCP} + begin + MainModule := GetModuleHandle(nil); + if MainModule <> Module then + begin + ModuleName := ExtractFileName(GetModulePath(Module)); + ModulePosition := 12 {$IFDEF CPU64}+8{$ENDIF}; + if ModulePosition < Length(Result) then + ModuleName := ModuleName + '.'; + Insert(ModuleName, Result, ModulePosition); + end; + end; + {$ELSE} + Insert(Format('{%-12s}', [ExtractFileName(GetModulePath(Module))]), Result, 11 {$IFDEF CPU64}+8{$ENDIF}); + {$ENDIF ~WINSCP} + end; +end; + +function DebugInfoAvailable(const Module: HMODULE): Boolean; +begin + DebugInfoCritSect.Enter; + try + NeedDebugInfoList; + Result := (DebugInfoList.ItemFromModule[Module] <> nil); + finally + DebugInfoCritSect.Leave; + end; +end; + +procedure ClearLocationData; +begin + DebugInfoCritSect.Enter; + try + if DebugInfoList <> nil then + DebugInfoList.Clear; + finally + DebugInfoCritSect.Leave; + end; +end; + +{$STACKFRAMES ON} + +function FileByLevel(const Level: Integer): string; +begin + Result := GetLocationInfo(Caller(Level + 1)).SourceName; +end; + +function ModuleByLevel(const Level: Integer): string; +begin + Result := GetLocationInfo(Caller(Level + 1)).UnitName; +end; + +function ProcByLevel(const Level: Integer; OnlyProcedureName: boolean): string; +begin + Result := GetLocationInfo(Caller(Level + 1)).ProcedureName; + if OnlyProcedureName = true then + begin + if StrILastPos('.', Result) > 0 then + Result :=StrRestOf(Result, StrILastPos('.', Result)+1); + end; +end; + + function LineByLevel(const Level: Integer): Integer; +begin + Result := GetLocationInfo(Caller(Level + 1)).LineNumber; +end; + +function MapByLevel(const Level: Integer; var File_, Module_, Proc_: string; + var Line_: Integer): Boolean; +begin + Result := MapOfAddr(Caller(Level + 1), File_, Module_, Proc_, Line_); +end; + +function ExtractClassName(const ProcedureName: string): string; +var + D: Integer; +begin + D := Pos('.', ProcedureName); + if D < 2 then + Result := '' + else + Result := Copy(ProcedureName, 1, D - 1); +end; + +function ExtractMethodName(const ProcedureName: string): string; +begin + Result := Copy(ProcedureName, Pos('.', ProcedureName) + 1, Length(ProcedureName)); +end; + +function __FILE__(const Level: Integer): string; +begin + Result := FileByLevel(Level + 1); +end; + +function __MODULE__(const Level: Integer): string; +begin + Result := ModuleByLevel(Level + 1); +end; + +function __PROC__(const Level: Integer): string; +begin + Result := ProcByLevel(Level + 1); +end; + +function __LINE__(const Level: Integer): Integer; +begin + Result := LineByLevel(Level + 1); +end; + +function __MAP__(const Level: Integer; var _File, _Module, _Proc: string; var _Line: Integer): Boolean; +begin + Result := MapByLevel(Level + 1, _File, _Module, _Proc, _Line); +end; + +{$IFNDEF STACKFRAMES_ON} +{$STACKFRAMES OFF} +{$ENDIF ~STACKFRAMES_ON} + +function FileOfAddr(const Addr: Pointer): string; +begin + Result := GetLocationInfo(Addr).SourceName; +end; + +function ModuleOfAddr(const Addr: Pointer): string; +begin + Result := GetLocationInfo(Addr).UnitName; +end; + +function ProcOfAddr(const Addr: Pointer): string; +begin + Result := GetLocationInfo(Addr).ProcedureName; +end; + +function LineOfAddr(const Addr: Pointer): Integer; +begin + Result := GetLocationInfo(Addr).LineNumber; +end; + +function MapOfAddr(const Addr: Pointer; var File_, Module_, Proc_: string; + var Line_: Integer): Boolean; +var + LocInfo: TJclLocationInfo; +begin + NeedDebugInfoList; + Result := DebugInfoList.GetLocationInfo(Addr, LocInfo); + if Result then + begin + File_ := LocInfo.SourceName; + Module_ := LocInfo.UnitName; + Proc_ := LocInfo.ProcedureName; + Line_ := LocInfo.LineNumber; + end; +end; + +function __FILE_OF_ADDR__(const Addr: Pointer): string; +begin + Result := FileOfAddr(Addr); +end; + +function __MODULE_OF_ADDR__(const Addr: Pointer): string; +begin + Result := ModuleOfAddr(Addr); +end; + +function __PROC_OF_ADDR__(const Addr: Pointer): string; +begin + Result := ProcOfAddr(Addr); +end; + +function __LINE_OF_ADDR__(const Addr: Pointer): Integer; +begin + Result := LineOfAddr(Addr); +end; + +function __MAP_OF_ADDR__(const Addr: Pointer; var _File, _Module, _Proc: string; + var _Line: Integer): Boolean; +begin + Result := MapOfAddr(Addr, _File, _Module, _Proc, _Line); +end; + +//=== { TJclStackBaseList } ================================================== + +constructor TJclStackBaseList.Create; +begin + inherited Create(True); + FThreadID := GetCurrentThreadId; + FTimeStamp := Now; +end; + +destructor TJclStackBaseList.Destroy; +begin + if Assigned(FOnDestroy) then + FOnDestroy(Self); + inherited Destroy; +end; + +//=== { TJclGlobalStackList } ================================================ + +type + TJclStackBaseListClass = class of TJclStackBaseList; + + TJclGlobalStackList = class(TThreadList) + private + FLockedTID: DWORD; + FTIDLocked: Boolean; + function GetExceptStackInfo(TID: DWORD): TJclStackInfoList; + function GetLastExceptFrameList(TID: DWORD): TJclExceptFrameList; + procedure ItemDestroyed(Sender: TObject); + public + destructor Destroy; override; + procedure AddObject(AObject: TJclStackBaseList); + procedure Clear; + procedure LockThreadID(TID: DWORD); + procedure UnlockThreadID; + function FindObject(TID: DWORD; AClass: TJclStackBaseListClass): TJclStackBaseList; + property ExceptStackInfo[TID: DWORD]: TJclStackInfoList read GetExceptStackInfo; + property LastExceptFrameList[TID: DWORD]: TJclExceptFrameList read GetLastExceptFrameList; + end; + +var + GlobalStackList: TJclGlobalStackList; + +destructor TJclGlobalStackList.Destroy; +begin + with LockList do + try + while Count > 0 do + TObject(Items[0]).Free; + finally + UnlockList; + end; + inherited Destroy; +end; + +procedure TJclGlobalStackList.AddObject(AObject: TJclStackBaseList); +var + ReplacedObj: TObject; +begin + AObject.FOnDestroy := ItemDestroyed; + with LockList do + try + ReplacedObj := FindObject(AObject.ThreadID, TJclStackBaseListClass(AObject.ClassType)); + if ReplacedObj <> nil then + begin + Remove(ReplacedObj); + ReplacedObj.Free; + end; + Add(AObject); + finally + UnlockList; + end; +end; + +procedure TJclGlobalStackList.Clear; +begin + with LockList do + try + while Count > 0 do + TObject(Items[0]).Free; + { The following call to Clear seems to be useless, but it deallocates memory + by setting the lists capacity back to zero. For the runtime memory leak check + within DUnit it is important that the allocated memory before and after the + test is equal. } + Clear; // do not remove + finally + UnlockList; + end; +end; + +function TJclGlobalStackList.FindObject(TID: DWORD; AClass: TJclStackBaseListClass): TJclStackBaseList; +var + I: Integer; + Item: TJclStackBaseList; +begin + Result := nil; + with LockList do + try + if FTIDLocked and (GetCurrentThreadId = MainThreadID) then + TID := FLockedTID; + for I := 0 to Count - 1 do + begin + Item := Items[I]; + if (Item.ThreadID = TID) and (Item is AClass) then + begin + Result := Item; + Break; + end; + end; + finally + UnlockList; + end; +end; + +function TJclGlobalStackList.GetExceptStackInfo(TID: DWORD): TJclStackInfoList; +begin + Result := TJclStackInfoList(FindObject(TID, TJclStackInfoList)); +end; + +function TJclGlobalStackList.GetLastExceptFrameList(TID: DWORD): TJclExceptFrameList; +begin + Result := TJclExceptFrameList(FindObject(TID, TJclExceptFrameList)); +end; + +procedure TJclGlobalStackList.ItemDestroyed(Sender: TObject); +begin + with LockList do + try + Remove(Sender); + finally + UnlockList; + end; +end; + +procedure TJclGlobalStackList.LockThreadID(TID: DWORD); +begin + with LockList do + try + if GetCurrentThreadId = MainThreadID then + begin + FTIDLocked := True; + FLockedTID := TID; + end + else + FTIDLocked := False; + finally + UnlockList; + end; +end; + +procedure TJclGlobalStackList.UnlockThreadID; +begin + with LockList do + try + FTIDLocked := False; + finally + UnlockList; + end; +end; + +//=== { TJclGlobalModulesList } ============================================== + +type + TJclGlobalModulesList = class(TObject) + private + FAddedModules: TStringList; + FHookedModules: TJclModuleArray; + FLock: TJclCriticalSection; + FModulesList: TJclModuleInfoList; + public + constructor Create; + destructor Destroy; override; + procedure AddModule(const ModuleName: string); + function CreateModulesList: TJclModuleInfoList; + procedure FreeModulesList(var ModulesList: TJclModuleInfoList); + function ValidateAddress(Addr: Pointer): Boolean; + end; + +var + GlobalModulesList: TJclGlobalModulesList; + +constructor TJclGlobalModulesList.Create; +begin + FLock := TJclCriticalSection.Create; +end; + +destructor TJclGlobalModulesList.Destroy; +begin + FreeAndNil(FLock); + FreeAndNil(FModulesList); + FreeAndNil(FAddedModules); + inherited Destroy; +end; + +procedure TJclGlobalModulesList.AddModule(const ModuleName: string); +var + IsMultiThreaded: Boolean; +begin + IsMultiThreaded := IsMultiThread; + if IsMultiThreaded then + FLock.Enter; + try + if not Assigned(FAddedModules) then + begin + FAddedModules := TStringList.Create; + FAddedModules.Sorted := True; + FAddedModules.Duplicates := dupIgnore; + end; + FAddedModules.Add(ModuleName); + finally + if IsMultiThreaded then + FLock.Leave; + end; +end; + +function TJclGlobalModulesList.CreateModulesList: TJclModuleInfoList; +var + I: Integer; + SystemModulesOnly: Boolean; + IsMultiThreaded: Boolean; + AddedModuleHandle: HMODULE; +begin + IsMultiThreaded := IsMultiThread; + if IsMultiThreaded then + FLock.Enter; + try + if FModulesList = nil then + begin + SystemModulesOnly := not (stAllModules in JclStackTrackingOptions); + Result := TJclModuleInfoList.Create(False, SystemModulesOnly); + // Add known Borland modules collected by DLL exception hooking code + if SystemModulesOnly and JclHookedExceptModulesList(FHookedModules) then + for I := Low(FHookedModules) to High(FHookedModules) do + Result.AddModule(FHookedModules[I], True); + if Assigned(FAddedModules) then + for I := 0 to FAddedModules.Count - 1 do + begin + AddedModuleHandle := GetModuleHandle(PChar(FAddedModules[I])); + if (AddedModuleHandle <> 0) and + not Assigned(Result.ModuleFromAddress[Pointer(AddedModuleHandle)]) then + Result.AddModule(AddedModuleHandle, True); + end; + if stStaticModuleList in JclStackTrackingOptions then + FModulesList := Result; + end + else + Result := FModulesList; + finally + if IsMultiThreaded then + FLock.Leave; + end; +end; + +procedure TJclGlobalModulesList.FreeModulesList(var ModulesList: TJclModuleInfoList); +var + IsMultiThreaded: Boolean; +begin + if (Self <> nil) and // happens when finalization already ran but a TJclStackInfoList is still alive + (FModulesList <> ModulesList) then + begin + IsMultiThreaded := IsMultiThread; + if IsMultiThreaded then + FLock.Enter; + try + FreeAndNil(ModulesList); + finally + if IsMultiThreaded then + FLock.Leave; + end; + end; +end; + +function TJclGlobalModulesList.ValidateAddress(Addr: Pointer): Boolean; +var + TempList: TJclModuleInfoList; +begin + TempList := CreateModulesList; + try + Result := TempList.IsValidModuleAddress(Addr); + finally + FreeModulesList(TempList); + end; +end; + +function JclValidateModuleAddress(Addr: Pointer): Boolean; +begin + Result := GlobalModulesList.ValidateAddress(Addr); +end; + +//=== Stack info routines ==================================================== + +{$STACKFRAMES OFF} + +function ValidCodeAddr(CodeAddr: DWORD; ModuleList: TJclModuleInfoList): Boolean; +begin + if stAllModules in JclStackTrackingOptions then + Result := ModuleList.IsValidModuleAddress(Pointer(CodeAddr)) + else + Result := ModuleList.IsSystemModuleAddress(Pointer(CodeAddr)); +end; + +procedure CorrectExceptStackListTop(List: TJclStackInfoList; SkipFirstItem: Boolean); +var + TopItem, I, FoundPos: Integer; +begin + FoundPos := -1; + if SkipFirstItem then + TopItem := 1 + else + TopItem := 0; + with List do + begin + for I := Count - 1 downto TopItem do + if JclBelongsHookedCode(Items[I].CallerAddr) then + begin + FoundPos := I; + Break; + end; + if FoundPos <> -1 then + for I := FoundPos downto TopItem do + Delete(I); + end; +end; + +{$STACKFRAMES ON} + +procedure DoExceptionStackTrace(ExceptObj: TObject; ExceptAddr: Pointer; OSException: Boolean; + BaseOfStack: Pointer); +var + IgnoreLevels: Integer; + FirstCaller: Pointer; + RawMode: Boolean; + Delayed: Boolean; +begin + RawMode := stRawMode in JclStackTrackingOptions; + Delayed := stDelayedTrace in JclStackTrackingOptions; + if BaseOfStack = nil then + begin + BaseOfStack := GetFramePointer; + IgnoreLevels := 1; + end + else + IgnoreLevels := -1; // because of the "IgnoreLevels + 1" in TJclStackInfoList.StoreToList() + if OSException then + begin + if IgnoreLevels = -1 then + IgnoreLevels := 0 + else + Inc(IgnoreLevels); // => HandleAnyException + FirstCaller := ExceptAddr; + end + else + FirstCaller := nil; + JclCreateStackList(RawMode, IgnoreLevels, FirstCaller, Delayed, BaseOfStack).CorrectOnAccess(OSException); +end; + +function JclLastExceptStackList: TJclStackInfoList; +begin + Result := GlobalStackList.ExceptStackInfo[GetCurrentThreadID]; +end; + +function JclLastExceptStackListToStrings(Strings: TStrings; IncludeModuleName, IncludeAddressOffset, + IncludeStartProcLineOffset, IncludeVAddress: Boolean): Boolean; +var + List: TJclStackInfoList; +begin + List := JclLastExceptStackList; + Result := Assigned(List); + if Result then + List.AddToStrings(Strings, IncludeModuleName, IncludeAddressOffset, IncludeStartProcLineOffset, + IncludeVAddress); +end; + +function JclGetExceptStackList(ThreadID: DWORD): TJclStackInfoList; +begin + Result := GlobalStackList.ExceptStackInfo[ThreadID]; +end; + +function JclGetExceptStackListToStrings(ThreadID: DWORD; Strings: TStrings; + IncludeModuleName: Boolean = False; IncludeAddressOffset: Boolean = False; + IncludeStartProcLineOffset: Boolean = False; IncludeVAddress: Boolean = False): Boolean; +var + List: TJclStackInfoList; +begin + List := JclGetExceptStackList(ThreadID); + Result := Assigned(List); + if Result then + List.AddToStrings(Strings, IncludeModuleName, IncludeAddressOffset, IncludeStartProcLineOffset, + IncludeVAddress); +end; + +procedure JclClearGlobalStackData; +begin + GlobalStackList.Clear; +end; + +function JclCreateStackList(Raw: Boolean; AIgnoreLevels: Integer; FirstCaller: Pointer): TJclStackInfoList; +begin + Result := TJclStackInfoList.Create(Raw, AIgnoreLevels, FirstCaller, False, nil, nil); + GlobalStackList.AddObject(Result); +end; + +function JclCreateStackList(Raw: Boolean; AIgnoreLevels: Integer; FirstCaller: Pointer; + DelayedTrace: Boolean): TJclStackInfoList; +begin + Result := TJclStackInfoList.Create(Raw, AIgnoreLevels, FirstCaller, DelayedTrace, nil, nil); + GlobalStackList.AddObject(Result); +end; + +function JclCreateStackList(Raw: Boolean; AIgnoreLevels: Integer; FirstCaller: Pointer; + DelayedTrace: Boolean; BaseOfStack: Pointer): TJclStackInfoList; +begin + Result := TJclStackInfoList.Create(Raw, AIgnoreLevels, FirstCaller, DelayedTrace, BaseOfStack, nil); + GlobalStackList.AddObject(Result); +end; + +function JclCreateStackList(Raw: Boolean; AIgnoreLevels: Integer; FirstCaller: Pointer; + DelayedTrace: Boolean; BaseOfStack, TopOfStack: Pointer): TJclStackInfoList; +begin + Result := TJclStackInfoList.Create(Raw, AIgnoreLevels, FirstCaller, DelayedTrace, BaseOfStack, TopOfStack); + GlobalStackList.AddObject(Result); +end; + +function GetThreadTopOfStack(ThreadHandle: THandle): TJclAddr; +var + TBI: THREAD_BASIC_INFORMATION; + ReturnedLength: ULONG; +begin + Result := 0; + ReturnedLength := 0; + if (NtQueryInformationThread(ThreadHandle, ThreadBasicInformation, @TBI, SizeOf(TBI), @ReturnedLength) < $80000000) and + (ReturnedLength = SizeOf(TBI)) then + {$IFDEF CPU32} + Result := TJclAddr(PNT_TIB32(TBI.TebBaseAddress)^.StackBase) + {$ENDIF CPU32} + {$IFDEF CPU64} + Result := TJclAddr(PNT_TIB64(TBI.TebBaseAddress)^.StackBase) + {$ENDIF CPU64} + else + RaiseLastOSError; +end; + +function JclCreateThreadStackTrace(Raw: Boolean; const ThreadHandle: THandle): TJclStackInfoList; +var + ContextMemory: Pointer; + AlignedContext: PContext; +begin + Result := nil; + GetMem(ContextMemory, SizeOf(TContext) + 15); + try + if (Cardinal(ContextMemory) and 15) <> 0 then + AlignedContext := PContext((Cardinal(ContextMemory) + 16) and $FFFFFFF0) + else + AlignedContext := ContextMemory; + ResetMemory(AlignedContext^, SizeOf(AlignedContext^)); + AlignedContext^.ContextFlags := CONTEXT_FULL; + {$IFDEF CPU32} + if GetThreadContext(ThreadHandle, AlignedContext^) then + Result := JclCreateStackList(Raw, -1, Pointer(AlignedContext^.Eip), False, Pointer(AlignedContext^.Ebp), + Pointer(GetThreadTopOfStack(ThreadHandle))); + {$ENDIF CPU32} + {$IFDEF CPU64} + if GetThreadContext(ThreadHandle, AlignedContext^) then + Result := JclCreateStackList(Raw, -1, Pointer(AlignedContext^.Rip), False, Pointer(AlignedContext^.Rbp), + Pointer(GetThreadTopOfStack(ThreadHandle))); + {$ENDIF CPU64} + finally + FreeMem(ContextMemory); + end; +end; + +function JclCreateThreadStackTraceFromID(Raw: Boolean; ThreadID: DWORD): TJclStackInfoList; +type + TOpenThreadFunc = function(DesiredAccess: DWORD; InheritHandle: BOOL; ThreadID: DWORD): THandle; stdcall; +const + THREAD_GET_CONTEXT = $0008; + THREAD_QUERY_INFORMATION = $0040; +var + Kernel32Lib, ThreadHandle: THandle; + OpenThreadFunc: TOpenThreadFunc; +begin + Result := nil; + Kernel32Lib := GetModuleHandle(kernel32); + if Kernel32Lib <> 0 then + begin + // OpenThread only exists since Windows ME + OpenThreadFunc := GetProcAddress(Kernel32Lib, 'OpenThread'); + if Assigned(OpenThreadFunc) then + begin + ThreadHandle := OpenThreadFunc(THREAD_GET_CONTEXT or THREAD_QUERY_INFORMATION, False, ThreadID); + if ThreadHandle <> 0 then + try + Result := JclCreateThreadStackTrace(Raw, ThreadHandle); + finally + CloseHandle(ThreadHandle); + end; + end; + end; +end; + +//=== { TJclStackInfoItem } ================================================== + +function TJclStackInfoItem.GetCallerAddr: Pointer; +begin + Result := Pointer(FStackInfo.CallerAddr); +end; + +function TJclStackInfoItem.GetLogicalAddress: TJclAddr; +begin + Result := FStackInfo.CallerAddr - TJclAddr(ModuleFromAddr(CallerAddr)); +end; + +//=== { TJclStackInfoList } ================================================== + +constructor TJclStackInfoList.Create(ARaw: Boolean; AIgnoreLevels: Integer; + AFirstCaller: Pointer); +begin + Create(ARaw, AIgnoreLevels, AFirstCaller, False, nil, nil); +end; + +constructor TJclStackInfoList.Create(ARaw: Boolean; AIgnoreLevels: Integer; + AFirstCaller: Pointer; ADelayedTrace: Boolean); +begin + Create(ARaw, AIgnoreLevels, AFirstCaller, ADelayedTrace, nil, nil); +end; + +constructor TJclStackInfoList.Create(ARaw: Boolean; AIgnoreLevels: Integer; + AFirstCaller: Pointer; ADelayedTrace: Boolean; ABaseOfStack: Pointer); +begin + Create(ARaw, AIgnoreLevels, AFirstCaller, ADelayedTrace, ABaseOfStack, nil); +end; + +constructor TJclStackInfoList.Create(ARaw: Boolean; AIgnoreLevels: Integer; + AFirstCaller: Pointer; ADelayedTrace: Boolean; ABaseOfStack, ATopOfStack: Pointer); +var + Item: TJclStackInfoItem; +begin + inherited Create; + FIgnoreLevels := AIgnoreLevels; + FDelayedTrace := ADelayedTrace; + FRaw := ARaw; + BaseOfStack := TJclAddr(ABaseOfStack); + FStackOffset := 0; + FFramePointer := ABaseOfStack; + + if ATopOfStack = nil then + TopOfStack := GetStackTop + else + TopOfStack := TJclAddr(ATopOfStack); + + FModuleInfoList := GlobalModulesList.CreateModulesList; + if AFirstCaller <> nil then + begin + Item := TJclStackInfoItem.Create; + Item.FStackInfo.CallerAddr := TJclAddr(AFirstCaller); + Add(Item); + end; + {$IFDEF CPU32} + if DelayedTrace then + DelayStoreStack + else + if Raw then + TraceStackRaw + else + TraceStackFrames; + {$ENDIF CPU32} + {$IFDEF CPU64} + CaptureBackTrace; + {$ENDIF CPU64} +end; + +destructor TJclStackInfoList.Destroy; +begin + if Assigned(FStackData) then + FreeMem(FStackData); + GlobalModulesList.FreeModulesList(FModuleInfoList); + inherited Destroy; +end; + +{$IFDEF CPU64} +procedure TJclStackInfoList.CaptureBackTrace; +var + CapturedFramesCount: Word; + BackTrace: array [0..62] of Pointer; + Hash: DWORD; + I: Integer; + StackInfo: TStackInfo; +begin + ResetMemory(BackTrace, SizeOf(BackTrace)); + //TODO: For XP and 2003 sum of FramesToSkip and FramesToCapture must be lower + // than 63, but we could use higher values for newer OS versions + CapturedFramesCount := CaptureStackBackTrace(10, 52, @BackTrace, Hash); + for I := 0 to CapturedFramesCount - 1 do + begin + ResetMemory(StackInfo, SizeOf(StackInfo)); + StackInfo.CallerAddr := TJclAddr(BackTrace[I]); + StackInfo.Level := I; + StoreToList(StackInfo); + end; +end; +{$ENDIF CPU64} + +procedure TJclStackInfoList.ForceStackTracing; +begin + if DelayedTrace and Assigned(FStackData) and not FInStackTracing then + begin + FInStackTracing := True; + try + if Raw then + TraceStackRaw + else + TraceStackFrames; + if FCorrectOnAccess then + CorrectExceptStackListTop(Self, FSkipFirstItem); + finally + FInStackTracing := False; + FDelayedTrace := False; + end; + end; +end; + +function TJclStackInfoList.GetCount: Integer; +begin + ForceStackTracing; + Result := inherited Count; +end; + +procedure TJclStackInfoList.CorrectOnAccess(ASkipFirstItem: Boolean); +begin + FCorrectOnAccess := True; + FSkipFirstItem := ASkipFirstItem; +end; + +procedure TJclStackInfoList.AddToStrings(Strings: TStrings; IncludeModuleName, IncludeAddressOffset, + IncludeStartProcLineOffset, IncludeVAddress: Boolean); +var + I: Integer; +begin + ForceStackTracing; + Strings.BeginUpdate; + try + for I := 0 to Count - 1 do + Strings.Add(GetLocationInfoStr(Items[I].CallerAddr, IncludeModuleName, IncludeAddressOffset, + IncludeStartProcLineOffset, IncludeVAddress)); + finally + Strings.EndUpdate; + end; +end; + +function TJclStackInfoList.GetItems(Index: Integer): TJclStackInfoItem; +begin + ForceStackTracing; + Result := TJclStackInfoItem(Get(Index)); +end; + +function TJclStackInfoList.NextStackFrame(var StackFrame: PStackFrame; var StackInfo: TStackInfo): Boolean; +var + CallInstructionSize: Cardinal; + StackFrameCallerFrame, NewFrame: TJclAddr; + StackFrameCallerAddr: TJclAddr; +begin + // Only report this stack frame into the StockInfo structure + // if the StackFrame pointer, the frame pointer and the return address on the stack + // are valid addresses + StackFrameCallerFrame := StackInfo.CallerFrame; + while ValidStackAddr(TJclAddr(StackFrame)) do + begin + // CallersEBP above the previous CallersEBP + NewFrame := StackFrame^.CallerFrame; + if NewFrame <= StackFrameCallerFrame then + Break; + StackFrameCallerFrame := NewFrame; + + // CallerAddr within current process space, code segment etc. + // CallerFrame within current thread stack. Added Mar 12 2002 per Hallvard's suggestion + StackFrameCallerAddr := StackFrame^.CallerAddr; + if ValidCodeAddr(StackFrameCallerAddr, FModuleInfoList) and ValidStackAddr(StackFrameCallerFrame + FStackOffset) then + begin + Inc(StackInfo.Level); + StackInfo.StackFrame := StackFrame; + StackInfo.ParamPtr := PDWORD_PTRArray(TJclAddr(StackFrame) + SizeOf(TStackFrame)); + + if StackFrameCallerFrame > StackInfo.CallerFrame then + StackInfo.CallerFrame := StackFrameCallerFrame + else + // the frame pointer points to an address that is below + // the last frame pointer, so it must be invalid + Break; + + // Calculate the address of caller by subtracting the CALL instruction size (if possible) + if ValidCallSite(StackFrameCallerAddr, CallInstructionSize) then + StackInfo.CallerAddr := StackFrameCallerAddr - CallInstructionSize + else + StackInfo.CallerAddr := StackFrameCallerAddr; + // the stack may be messed up in big projects, avoid overflow in arithmetics + if StackFrameCallerFrame < TJclAddr(StackFrame) then + Break; + StackInfo.DumpSize := StackFrameCallerFrame - TJclAddr(StackFrame); + StackInfo.ParamSize := (StackInfo.DumpSize - SizeOf(TStackFrame)) div 4; + if PStackFrame(StackFrame^.CallerFrame) = StackFrame then + Break; + // Step to the next stack frame by following the frame pointer + StackFrame := PStackFrame(StackFrameCallerFrame + FStackOffset); + Result := True; + Exit; + end; + // Step to the next stack frame by following the frame pointer + StackFrame := PStackFrame(StackFrameCallerFrame + FStackOffset); + end; + Result := False; +end; + +procedure TJclStackInfoList.StoreToList(const StackInfo: TStackInfo); +var + Item: TJclStackInfoItem; +begin + if ((IgnoreLevels = -1) and (StackInfo.Level > 0)) or + (StackInfo.Level > (IgnoreLevels + 1)) then + begin + Item := TJclStackInfoItem.Create; + Item.FStackInfo := StackInfo; + Add(Item); + end; +end; + +procedure TJclStackInfoList.TraceStackFrames; +var + StackFrame: PStackFrame; + StackInfo: TStackInfo; +begin + Capacity := 32; // reduce ReallocMem calls, must be > 1 because the caller's EIP register is already in the list + + // Start at level 0 + StackInfo.Level := 0; + StackInfo.CallerFrame := 0; + if DelayedTrace then + // Get the current stack frame from the frame register + StackFrame := FFramePointer + else + begin + // We define the bottom of the valid stack to be the current ESP pointer + if BaseOfStack = 0 then + BaseOfStack := TJclAddr(GetFramePointer); + // Get a pointer to the current bottom of the stack + StackFrame := PStackFrame(BaseOfStack); + end; + + // We define the bottom of the valid stack to be the current frame Pointer + // There is a TIB field called pvStackUserBase, but this includes more of the + // stack than what would define valid stack frames. + BaseOfStack := TJclAddr(StackFrame) - 1; + // Loop over and report all valid stackframes + while NextStackFrame(StackFrame, StackInfo) and (inherited Count <> MaxStackTraceItems) do + StoreToList(StackInfo); +end; + +function SearchForStackPtrManipulation(StackPtr: Pointer; Proc: Pointer): Pointer; +{$IFDEF SUPPORTS_INLINE} +inline; +{$ENDIF SUPPORTS_INLINE} +{var + Addr: PByteArray;} +begin +{ Addr := Proc; + while (Addr <> nil) and (DWORD_PTR(Addr) > DWORD_PTR(Proc) - $100) and not IsBadReadPtr(Addr, 6) do + begin + if (Addr[0] = $55) and // push ebp + (Addr[1] = $8B) and (Addr[2] = $EC) then // mov ebp,esp + begin + if (Addr[3] = $83) and (Addr[4] = $C4) then // add esp,c8 + begin + Result := Pointer(INT_PTR(StackPtr) - ShortInt(Addr[5])); + Exit; + end; + Break; + end; + + if (Addr[0] = $C2) and // ret $xxxx + (((Addr[3] = $90) and (Addr[4] = $90) and (Addr[5] = $90)) or // nop + ((Addr[3] = $CC) and (Addr[4] = $CC) and (Addr[5] = $CC))) then // int 3 + Break; + + if (Addr[0] = $C3) and // ret + (((Addr[1] = $90) and (Addr[2] = $90) and (Addr[3] = $90)) or // nop + ((Addr[1] = $CC) and (Addr[2] = $CC) and (Addr[3] = $CC))) then // int 3 + Break; + + if (Addr[0] = $E9) and // jmp rel-far + (((Addr[5] = $90) and (Addr[6] = $90) and (Addr[7] = $90)) or // nop + ((Addr[5] = $CC) and (Addr[6] = $CC) and (Addr[7] = $CC))) then // int 3 + Break; + + if (Addr[0] = $EB) and // jmp rel-near + (((Addr[2] = $90) and (Addr[3] = $90) and (Addr[4] = $90)) or // nop + ((Addr[2] = $CC) and (Addr[3] = $CC) and (Addr[4] = $CC))) then // int 3 + Break; + + Dec(DWORD_TR(Addr)); + end;} + Result := StackPtr; +end; + +procedure TJclStackInfoList.TraceStackRaw; +var + StackInfo: TStackInfo; + StackPtr: PJclAddr; + PrevCaller: TJclAddr; + CallInstructionSize: Cardinal; + StackTop: TJclAddr; +begin + Capacity := 32; // reduce ReallocMem calls, must be > 1 because the caller's EIP register is already in the list + + if DelayedTrace then + begin + if not Assigned(FStackData) then + Exit; + StackPtr := PJclAddr(FStackData); + end + else + begin + // We define the bottom of the valid stack to be the current ESP pointer + if BaseOfStack = 0 then + BaseOfStack := TJclAddr(GetStackPointer); + // Get a pointer to the current bottom of the stack + StackPtr := PJclAddr(BaseOfStack); + end; + + StackTop := TopOfStack; + + if Count > 0 then + StackPtr := SearchForStackPtrManipulation(StackPtr, Pointer(Items[0].StackInfo.CallerAddr)); + + // We will not be able to fill in all the fields in the StackInfo record, + // so just blank it all out first + ResetMemory(StackInfo, SizeOf(StackInfo)); + // Clear the previous call address + PrevCaller := 0; + // Loop through all of the valid stack space + while (TJclAddr(StackPtr) < StackTop) and (inherited Count <> MaxStackTraceItems) do + begin + // If the current DWORD on the stack refers to a valid call site... + if ValidCallSite(StackPtr^, CallInstructionSize) and (StackPtr^ <> PrevCaller) then + begin + // then pick up the callers address + StackInfo.CallerAddr := StackPtr^ - CallInstructionSize; + // remember to callers address so that we don't report it repeatedly + PrevCaller := StackPtr^; + // increase the stack level + Inc(StackInfo.Level); + // then report it back to our caller + StoreToList(StackInfo); + StackPtr := SearchForStackPtrManipulation(StackPtr, Pointer(StackInfo.CallerAddr)); + end; + // Look at the next DWORD on the stack + Inc(StackPtr); + end; + if Assigned(FStackData) then + begin + FreeMem(FStackData); + FStackData := nil; + end; +end; + +{$IFDEF CPU32} +procedure TJclStackInfoList.DelayStoreStack; +var + StackPtr: PJclAddr; + StackDataSize: Cardinal; +begin + if Assigned(FStackData) then + begin + FreeMem(FStackData); + FStackData := nil; + end; + // We define the bottom of the valid stack to be the current ESP pointer + if BaseOfStack = 0 then + begin + BaseOfStack := TJclAddr(GetStackPointer); + FFramePointer := GetFramePointer; + end; + + // Get a pointer to the current bottom of the stack + StackPtr := PJclAddr(BaseOfStack); + if TJclAddr(StackPtr) < TopOfStack then + begin + StackDataSize := TopOfStack - TJclAddr(StackPtr); + GetMem(FStackData, StackDataSize); + System.Move(StackPtr^, FStackData^, StackDataSize); + //CopyMemory(FStackData, StackPtr, StackDataSize); + end; + + FStackOffset := Int64(FStackData) - Int64(StackPtr); + FFramePointer := Pointer(TJclAddr(FFramePointer) + FStackOffset); + TopOfStack := TopOfStack + FStackOffset; +end; +{$ENDIF CPU32} + +// Validate that the code address is a valid code site +// +// Information from Intel Manual 24319102(2).pdf, Download the 6.5 MBs from: +// http://developer.intel.com/design/pentiumii/manuals/243191.htm +// Instruction format, Chapter 2 and The CALL instruction: page 3-53, 3-54 + +function TJclStackInfoList.ValidCallSite(CodeAddr: TJclAddr; out CallInstructionSize: Cardinal): Boolean; +var + CodeDWORD4: DWORD; + CodeDWORD8: DWORD; + C4P, C8P: PDWORD; + RM1, RM2, RM5: Byte; +begin + // todo: 64 bit version + + // First check that the address is within range of our code segment! + Result := CodeAddr > 8; + if Result then + begin + C8P := PDWORD(CodeAddr - 8); + C4P := PDWORD(CodeAddr - 4); + Result := ValidCodeAddr(TJclAddr(C8P), FModuleInfoList) and not IsBadReadPtr(C8P, 8); + + // Now check to see if the instruction preceding the return address + // could be a valid CALL instruction + if Result then + begin + try + CodeDWORD8 := PDWORD(C8P)^; + CodeDWORD4 := PDWORD(C4P)^; + // CodeDWORD8 = (ReturnAddr-5):(ReturnAddr-6):(ReturnAddr-7):(ReturnAddr-8) + // CodeDWORD4 = (ReturnAddr-1):(ReturnAddr-2):(ReturnAddr-3):(ReturnAddr-4) + + // ModR/M bytes contain the following bits: + // Mod = (76) + // Reg/Opcode = (543) + // R/M = (210) + RM1 := (CodeDWORD4 shr 24) and $7; + RM2 := (CodeDWORD4 shr 16) and $7; + //RM3 := (CodeDWORD4 shr 8) and $7; + //RM4 := CodeDWORD4 and $7; + RM5 := (CodeDWORD8 shr 24) and $7; + //RM6 := (CodeDWORD8 shr 16) and $7; + //RM7 := (CodeDWORD8 shr 8) and $7; + + // Check the instruction prior to the potential call site. + // We consider it a valid call site if we find a CALL instruction there + // Check the most common CALL variants first + if ((CodeDWORD8 and $FF000000) = $E8000000) then + // 5 bytes, "CALL NEAR REL32" (E8 cd) + CallInstructionSize := 5 + else + if ((CodeDWORD4 and $F8FF0000) = $10FF0000) and not (RM1 in [4, 5]) then + // 2 bytes, "CALL NEAR [EAX]" (FF /2) where Reg = 010, Mod = 00, R/M <> 100 (1 extra byte) + // and R/M <> 101 (4 extra bytes) + CallInstructionSize := 2 + else + if ((CodeDWORD4 and $F8FF0000) = $D0FF0000) then + // 2 bytes, "CALL NEAR EAX" (FF /2) where Reg = 010 and Mod = 11 + CallInstructionSize := 2 + else + if ((CodeDWORD4 and $00FFFF00) = $0014FF00) then + // 3 bytes, "CALL NEAR [EAX+EAX*i]" (FF /2) where Reg = 010, Mod = 00 and RM = 100 + // SIB byte not validated + CallInstructionSize := 3 + else + if ((CodeDWORD4 and $00F8FF00) = $0050FF00) and (RM2 <> 4) then + // 3 bytes, "CALL NEAR [EAX+$12]" (FF /2) where Reg = 010, Mod = 01 and RM <> 100 (1 extra byte) + CallInstructionSize := 3 + else + if ((CodeDWORD4 and $0000FFFF) = $000054FF) then + // 4 bytes, "CALL NEAR [EAX+EAX+$12]" (FF /2) where Reg = 010, Mod = 01 and RM = 100 + // SIB byte not validated + CallInstructionSize := 4 + else + if ((CodeDWORD8 and $FFFF0000) = $15FF0000) then + // 6 bytes, "CALL NEAR [$12345678]" (FF /2) where Reg = 010, Mod = 00 and RM = 101 + CallInstructionSize := 6 + else + if ((CodeDWORD8 and $F8FF0000) = $90FF0000) and (RM5 <> 4) then + // 6 bytes, "CALL NEAR [EAX+$12345678]" (FF /2) where Reg = 010, Mod = 10 and RM <> 100 (1 extra byte) + CallInstructionSize := 6 + else + if ((CodeDWORD8 and $00FFFF00) = $0094FF00) then + // 7 bytes, "CALL NEAR [EAX+EAX+$1234567]" (FF /2) where Reg = 010, Mod = 10 and RM = 100 + CallInstructionSize := 7 + else + if ((CodeDWORD8 and $0000FF00) = $00009A00) then + // 7 bytes, "CALL FAR $1234:12345678" (9A ptr16:32) + CallInstructionSize := 7 + else + Result := False; + // Because we're not doing a complete disassembly, we will potentially report + // false positives. If there is odd code that uses the CALL 16:32 format, we + // can also get false negatives. + except + Result := False; + end; + end; + end; +end; + +{$IFNDEF STACKFRAMES_ON} +{$STACKFRAMES OFF} +{$ENDIF ~STACKFRAMES_ON} + +function TJclStackInfoList.ValidStackAddr(StackAddr: TJclAddr): Boolean; +begin + Result := (BaseOfStack < StackAddr) and (StackAddr < TopOfStack); +end; + +//=== Exception frame info routines ========================================== + +function JclCreateExceptFrameList(AIgnoreLevels: Integer): TJclExceptFrameList; +begin + Result := TJclExceptFrameList.Create(AIgnoreLevels); + GlobalStackList.AddObject(Result); +end; + +function JclLastExceptFrameList: TJclExceptFrameList; +begin + Result := GlobalStackList.LastExceptFrameList[GetCurrentThreadID]; +end; + +function JclGetExceptFrameList(ThreadID: DWORD): TJclExceptFrameList; +begin + Result := GlobalStackList.LastExceptFrameList[ThreadID]; +end; + +procedure DoExceptFrameTrace; +begin + // Ignore first 2 levels; the First level is an undefined frame (I haven't a + // clue as to where it comes from. The second level is the try..finally block + // in DoExceptNotify. + JclCreateExceptFrameList(4); +end; + +{$OVERFLOWCHECKS OFF} + +function GetJmpDest(Jmp: PJmpInstruction): Pointer; +begin + // TODO : 64 bit version + if Jmp^.opCode = $E9 then + Result := Pointer(TJclAddr(Jmp) + TJclAddr(Jmp^.distance) + 5) + else + if Jmp.opCode = $EB then + Result := Pointer(TJclAddr(Jmp) + TJclAddr(ShortInt(Jmp^.distance)) + 2) + else + Result := nil; + if (Result <> nil) and (PJmpTable(Result).OPCode = $25FF) then + if not IsBadReadPtr(PJmpTable(Result).Ptr, SizeOf(Pointer)) then + Result := Pointer(PJclAddr(PJmpTable(Result).Ptr)^); +end; + +{$IFDEF OVERFLOWCHECKS_ON} +{$OVERFLOWCHECKS ON} +{$ENDIF OVERFLOWCHECKS_ON} + +//=== { TJclExceptFrame } ==================================================== + +constructor TJclExceptFrame.Create(AFrameLocation: Pointer; AExcDesc: PExcDesc); +begin + inherited Create; + FFrameKind := efkUnknown; + FFrameLocation := AFrameLocation; + FCodeLocation := nil; + AnalyseExceptFrame(AExcDesc); +end; + +{$RANGECHECKS OFF} + +procedure TJclExceptFrame.AnalyseExceptFrame(AExcDesc: PExcDesc); +var + Dest: Pointer; + LocInfo: TJclLocationInfo; + FixedProcedureName: string; + DotPos, I: Integer; +begin + Dest := GetJmpDest(@AExcDesc^.Jmp); + if Dest <> nil then + begin + // get frame kind + LocInfo := GetLocationInfo(Dest); + if CompareText(LocInfo.UnitName, 'system') = 0 then + begin + FixedProcedureName := LocInfo.ProcedureName; + DotPos := Pos('.', FixedProcedureName); + if DotPos > 0 then + FixedProcedureName := Copy(FixedProcedureName, DotPos + 1, Length(FixedProcedureName) - DotPos); + if CompareText(FixedProcedureName, '@HandleAnyException') = 0 then + FFrameKind := efkAnyException + else + if CompareText(FixedProcedureName, '@HandleOnException') = 0 then + FFrameKind := efkOnException + else + if CompareText(FixedProcedureName, '@HandleAutoException') = 0 then + FFrameKind := efkAutoException + else + if CompareText(FixedProcedureName, '@HandleFinally') = 0 then + FFrameKind := efkFinally; + end; + + // get location + if FFrameKind <> efkUnknown then + begin + FCodeLocation := GetJmpDest(PJmpInstruction(TJclAddr(@AExcDesc^.Instructions))); + if FCodeLocation = nil then + FCodeLocation := @AExcDesc^.Instructions; + end + else + begin + FCodeLocation := GetJmpDest(PJmpInstruction(TJclAddr(AExcDesc))); + if FCodeLocation = nil then + FCodeLocation := AExcDesc; + end; + + // get on handlers + if FFrameKind = efkOnException then + begin + SetLength(FExcTab, AExcDesc^.Cnt); + for I := 0 to AExcDesc^.Cnt - 1 do + begin + if AExcDesc^.ExcTab[I].VTable = nil then + begin + SetLength(FExcTab, I); + Break; + end + else + FExcTab[I] := AExcDesc^.ExcTab[I]; + end; + end; + end; +end; + +{$IFDEF RANGECHECKS_ON} +{$RANGECHECKS ON} +{$ENDIF RANGECHECKS_ON} + +function TJclExceptFrame.Handles(ExceptObj: TObject): Boolean; +var + Handler: Pointer; +begin + Result := HandlerInfo(ExceptObj, Handler); +end; + +{$OVERFLOWCHECKS OFF} + +function TJclExceptFrame.HandlerInfo(ExceptObj: TObject; out HandlerAt: Pointer): Boolean; +var + I: Integer; + ObjVTable, VTable, ParentVTable: Pointer; +begin + Result := FrameKind in [efkAnyException, efkAutoException]; + if not Result and (FrameKind = efkOnException) then + begin + HandlerAt := nil; + ObjVTable := Pointer(ExceptObj.ClassType); + for I := Low(FExcTab) to High(FExcTab) do + begin + VTable := ObjVTable; + Result := FExcTab[I].VTable = nil; + while (not Result) and (VTable <> nil) do + begin + Result := (FExcTab[I].VTable = VTable) or + (PShortString(PPointer(PJclAddr(FExcTab[I].VTable)^ + TJclAddr(vmtClassName))^)^ = + PShortString(PPointer(TJclAddr(VTable) + TJclAddr(vmtClassName))^)^); + if Result then + HandlerAt := FExcTab[I].Handler + else + begin + ParentVTable := TClass(VTable).ClassParent; + if ParentVTable = VTable then + VTable := nil + else + VTable := ParentVTable; + end; + end; + if Result then + Break; + end; + end + else + if Result then + HandlerAt := FCodeLocation + else + HandlerAt := nil; +end; + +{$IFDEF OVERFLOWCHECKS_ON} +{$OVERFLOWCHECKS ON} +{$ENDIF OVERFLOWCHECKS_ON} + +//=== { TJclExceptFrameList } ================================================ + +constructor TJclExceptFrameList.Create(AIgnoreLevels: Integer); +begin + inherited Create; + FIgnoreLevels := AIgnoreLevels; + TraceExceptionFrames; +end; + +function TJclExceptFrameList.AddFrame(AFrame: PExcFrame): TJclExceptFrame; +begin + Result := TJclExceptFrame.Create(AFrame, AFrame^.Desc); + Add(Result); +end; + +function TJclExceptFrameList.GetItems(Index: Integer): TJclExceptFrame; +begin + Result := TJclExceptFrame(Get(Index)); +end; + +procedure TJclExceptFrameList.TraceExceptionFrames; +{$IFDEF CPU32} +var + ExceptionPointer: PExcFrame; + Level: Integer; + ModulesList: TJclModuleInfoList; +begin + Clear; + ModulesList := GlobalModulesList.CreateModulesList; + try + Level := 0; + ExceptionPointer := GetExceptionPointer; + while TJclAddr(ExceptionPointer) <> High(TJclAddr) do + begin + if (Level >= IgnoreLevels) and ValidCodeAddr(TJclAddr(ExceptionPointer^.Desc), ModulesList) then + AddFrame(ExceptionPointer); + Inc(Level); + ExceptionPointer := ExceptionPointer^.next; + end; + finally + GlobalModulesList.FreeModulesList(ModulesList); + end; +end; +{$ENDIF CPU32} +{$IFDEF CPU64} +begin + // TODO: 64-bit version +end; +{$ENDIF CPU64} + +//=== Exception hooking ====================================================== + +var + TrackingActiveCount: Integer; + IgnoredExceptions: TThreadList = nil; + IgnoredExceptionClassNames: TStringList = nil; + IgnoredExceptionClassNamesCritSect: TJclCriticalSection = nil; + +procedure AddIgnoredException(const ExceptionClass: TClass); +begin + if Assigned(ExceptionClass) then + begin + if not Assigned(IgnoredExceptions) then + IgnoredExceptions := TThreadList.Create; + + IgnoredExceptions.Add(ExceptionClass); + end; +end; + +procedure AddIgnoredExceptionByName(const AExceptionClassName: string); +begin + if AExceptionClassName <> '' then + begin + if not Assigned(IgnoredExceptionClassNamesCritSect) then + IgnoredExceptionClassNamesCritSect := TJclCriticalSection.Create; + if not Assigned(IgnoredExceptionClassNames) then + begin + IgnoredExceptionClassNames := TStringList.Create; + IgnoredExceptionClassNames.Duplicates := dupIgnore; + IgnoredExceptionClassNames.Sorted := True; + end; + IgnoredExceptionClassNamesCritSect.Enter; + try + IgnoredExceptionClassNames.Add(AExceptionClassName); + finally + IgnoredExceptionClassNamesCritSect.Leave; + end; + end; +end; + +procedure RemoveIgnoredException(const ExceptionClass: TClass); +var + ClassList: TList; +begin + if Assigned(ExceptionClass) and Assigned(IgnoredExceptions) then + begin + ClassList := IgnoredExceptions.LockList; + try + ClassList.Remove(ExceptionClass); + finally + IgnoredExceptions.UnlockList; + end; + end; +end; + +procedure RemoveIgnoredExceptionByName(const AExceptionClassName: string); +var + Index: Integer; +begin + if Assigned(IgnoredExceptionClassNames) and (AExceptionClassName <> '') then + begin + IgnoredExceptionClassNamesCritSect.Enter; + try + Index := IgnoredExceptionClassNames.IndexOf(AExceptionClassName); + if Index <> -1 then + IgnoredExceptionClassNames.Delete(Index); + finally + IgnoredExceptionClassNamesCritSect.Leave; + end; + end; +end; + +function IsIgnoredException(const ExceptionClass: TClass): Boolean; +var + ClassList: TList; + Index: Integer; +begin + Result := False; + if Assigned(IgnoredExceptions) and not (stTraceAllExceptions in JclStackTrackingOptions) then + begin + ClassList := IgnoredExceptions.LockList; + try + for Index := 0 to ClassList.Count - 1 do + if ExceptionClass.InheritsFrom(TClass(ClassList.Items[Index])) then + begin + Result := True; + Break; + end; + finally + IgnoredExceptions.UnlockList; + end; + end; + if not Result and Assigned(IgnoredExceptionClassNames) and not (stTraceAllExceptions in JclStackTrackingOptions) then + begin + IgnoredExceptionClassNamesCritSect.Enter; + try + Result := IgnoredExceptionClassNames.IndexOf(ExceptionClass.ClassName) <> -1; + if not Result then + for Index := 0 to IgnoredExceptionClassNames.Count - 1 do + if InheritsFromByName(ExceptionClass, IgnoredExceptionClassNames[Index]) then + begin + Result := True; + Break; + end; + finally + IgnoredExceptionClassNamesCritSect.Leave; + end; + end; +end; + +procedure AddModule(const ModuleName: string); +begin + GlobalModulesList.AddModule(ModuleName); +end; + +procedure DoExceptNotify(ExceptObj: TObject; ExceptAddr: Pointer; OSException: Boolean; + BaseOfStack: Pointer); +begin + if (TrackingActiveCount > 0) and (not (stDisableIfDebuggerAttached in JclStackTrackingOptions) or (not IsDebuggerAttached)) and + Assigned(ExceptObj) and (not IsIgnoredException(ExceptObj.ClassType)) and + (not (stMainThreadOnly in JclStackTrackingOptions) or (GetCurrentThreadId = MainThreadID)) then + begin + if stStack in JclStackTrackingOptions then + DoExceptionStackTrace(ExceptObj, ExceptAddr, OSException, BaseOfStack); + if stExceptFrame in JclStackTrackingOptions then + DoExceptFrameTrace; + end; +end; + +function JclStartExceptionTracking: Boolean; +begin + {Increment the tracking count only if exceptions are already being tracked or tracking can be started + successfully.} + if TrackingActiveCount = 0 then + begin + if JclHookExceptions and JclAddExceptNotifier(DoExceptNotify, npFirstChain) then + begin + TrackingActiveCount := 1; + Result := True; + end + else + Result := False; + end + else + begin + Inc(TrackingActiveCount); + Result := False; + end; +end; + +function JclStopExceptionTracking: Boolean; +begin + {If the current tracking count is 1, an attempt is made to stop tracking exceptions. If successful the + tracking count is set back to 0. If the current tracking count is > 1 it is simply decremented.} + if TrackingActiveCount = 1 then + begin + Result := JclRemoveExceptNotifier(DoExceptNotify); + if Result then + Dec(TrackingActiveCount); + end + else + begin + if TrackingActiveCount > 0 then + Dec(TrackingActiveCount); + Result := False; + end; +end; + +function JclExceptionTrackingActive: Boolean; +begin + Result := TrackingActiveCount > 0; +end; + +function JclTrackExceptionsFromLibraries: Boolean; +begin + Result := TrackingActiveCount > 0; + if Result then + JclInitializeLibrariesHookExcept; +end; + +//=== Thread exception tracking support ====================================== + +var + RegisteredThreadList: TJclDebugThreadList; + +function JclDebugThreadList: TJclDebugThreadList; +begin + if RegisteredThreadList = nil then + RegisteredThreadList := TJclDebugThreadList.Create; + Result := RegisteredThreadList; +end; + +type + TKernel32_CreateThread = function(SecurityAttributes: Pointer; StackSize: LongWord; + ThreadFunc: TThreadFunc; Parameter: Pointer; + CreationFlags: LongWord; var ThreadId: LongWord): Integer; stdcall; + TKernel32_ExitThread = procedure(ExitCode: Integer); stdcall; + +var + ThreadsHooked: Boolean; + Kernel32_CreateThread: TKernel32_CreateThread = nil; + Kernel32_ExitThread: TKernel32_ExitThread = nil; + +function HookedCreateThread(SecurityAttributes: Pointer; StackSize: LongWord; + ThreadFunc: TThreadFunc; Parameter: Pointer; + CreationFlags: LongWord; ThreadId: PLongWord): Integer; stdcall; +var + LocalThreadId: LongWord; +begin + Result := Kernel32_CreateThread(SecurityAttributes, StackSize, ThreadFunc, Parameter, CreationFlags, LocalThreadId); + if Result <> 0 then + begin + JclDebugThreadList.RegisterThreadID(LocalThreadId); + if ThreadId <> nil then + begin + ThreadId^ := LocalThreadId; + end; + end; +end; + +procedure HookedExitThread(ExitCode: Integer); stdcall; +begin + JclDebugThreadList.UnregisterThreadID(GetCurrentThreadID); + Kernel32_ExitThread(ExitCode); +end; + +function JclHookThreads: Boolean; +var + ProcAddrCache: Pointer; +begin + if not ThreadsHooked then + begin + ProcAddrCache := GetProcAddress(GetModuleHandle(kernel32), 'CreateThread'); + with TJclPeMapImgHooks do + Result := ReplaceImport(SystemBase, kernel32, ProcAddrCache, @HookedCreateThread); + if Result then + begin + @Kernel32_CreateThread := ProcAddrCache; + + ProcAddrCache := GetProcAddress(GetModuleHandle(kernel32), 'ExitThread'); + with TJclPeMapImgHooks do + Result := ReplaceImport(SystemBase, kernel32, ProcAddrCache, @HookedExitThread); + if Result then + @Kernel32_ExitThread := ProcAddrCache + else + with TJclPeMapImgHooks do + ReplaceImport(SystemBase, kernel32, @HookedCreateThread, @Kernel32_CreateThread); + end; + ThreadsHooked := Result; + end + else + Result := True; +end; + +function JclUnhookThreads: Boolean; +begin + if ThreadsHooked then + begin + with TJclPeMapImgHooks do + begin + ReplaceImport(SystemBase, kernel32, @HookedCreateThread, @Kernel32_CreateThread); + ReplaceImport(SystemBase, kernel32, @HookedExitThread, @Kernel32_ExitThread); + end; + Result := True; + ThreadsHooked := False; + end + else + Result := True; +end; + +function JclThreadsHooked: Boolean; +begin + Result := ThreadsHooked; +end; + +//=== { TJclDebugThread } ==================================================== + +constructor TJclDebugThread.Create(ASuspended: Boolean; const AThreadName: string); +begin + FThreadName := AThreadName; + inherited Create(True); + JclDebugThreadList.RegisterThread(Self, AThreadName); + if not ASuspended then + {$IFDEF RTL210_UP} + Suspended := False; + {$ELSE ~RTL210_UP} + Resume; + {$ENDIF ~RTL210_UP} +end; + +destructor TJclDebugThread.Destroy; +begin + JclDebugThreadList.UnregisterThread(Self); + inherited Destroy; +end; + +procedure TJclDebugThread.DoHandleException; +begin + GlobalStackList.LockThreadID(ThreadID); + try + DoSyncHandleException; + finally + GlobalStackList.UnlockThreadID; + end; +end; + +procedure TJclDebugThread.DoNotify; +begin + JclDebugThreadList.DoSyncException(Self); +end; + +procedure TJclDebugThread.DoSyncHandleException; +begin + // Note: JclLastExceptStackList and JclLastExceptFrameList returns information + // for this Thread ID instead of MainThread ID here to allow use a common + // exception handling routine easily. + // Any other call of those JclLastXXX routines from another thread at the same + // time will return expected information for current Thread ID. + DoNotify; +end; + +function TJclDebugThread.GetThreadInfo: string; +begin + Result := JclDebugThreadList.ThreadInfos[ThreadID]; +end; + +procedure TJclDebugThread.HandleException(Sender: TObject); +begin + FSyncException := Sender; + try + if not Assigned(FSyncException) then + FSyncException := Exception(ExceptObject); + if Assigned(FSyncException) and not IsIgnoredException(FSyncException.ClassType) then + Synchronize(DoHandleException); + finally + FSyncException := nil; + end; +end; + +//=== { TJclDebugThreadList } ================================================ + +type + TThreadAccess = class(TThread); + +constructor TJclDebugThreadList.Create; +begin + FLock := TJclCriticalSection.Create; + FReadLock := TJclCriticalSection.Create; + FList := TObjectList.Create; + FSaveCreationStack := False; +end; + +destructor TJclDebugThreadList.Destroy; +begin + FreeAndNil(FList); + FreeAndNil(FLock); + FreeAndNil(FReadLock); + inherited Destroy; +end; + +function TJclDebugThreadList.AddStackListToLocationInfoList(ThreadID: DWORD; AList: TJclLocationInfoList): Boolean; +var + I: Integer; + List: TJclStackInfoList; +begin + Result := False; + FReadLock.Enter; + try + I := IndexOfThreadID(ThreadID); + if (I <> -1) and Assigned(TJclDebugThreadInfo(FList[I]).StackList) then + begin + List := TJclDebugThreadInfo(FList[I]).StackList; + AList.AddStackInfoList(List); + Result := True; + end; + finally + FReadLock.Leave; + end; +end; + +procedure TJclDebugThreadList.DoSyncException(Thread: TJclDebugThread); +begin + if Assigned(FOnSyncException) then + FOnSyncException(Thread); +end; + +procedure TJclDebugThreadList.DoSyncThreadRegistered; +begin + if Assigned(FOnThreadRegistered) then + FOnThreadRegistered(FRegSyncThreadID); +end; + +procedure TJclDebugThreadList.DoSyncThreadUnregistered; +begin + if Assigned(FOnThreadUnregistered) then + FOnThreadUnregistered(FUnregSyncThreadID); +end; + +procedure TJclDebugThreadList.DoThreadRegistered(Thread: TThread); +begin + if Assigned(FOnThreadRegistered) then + begin + FRegSyncThreadID := Thread.ThreadID; + TThreadAccess(Thread).Synchronize(DoSyncThreadRegistered); + end; +end; + +procedure TJclDebugThreadList.DoThreadUnregistered(Thread: TThread); +begin + if Assigned(FOnThreadUnregistered) then + begin + FUnregSyncThreadID := Thread.ThreadID; + TThreadAccess(Thread).Synchronize(DoSyncThreadUnregistered); + end; +end; + +function TJclDebugThreadList.GetThreadClassNames(ThreadID: DWORD): string; +begin + Result := GetThreadValues(ThreadID, 1); +end; + +function TJclDebugThreadList.GetThreadCreationTime(ThreadID: DWORD): TDateTime; +var + I: Integer; +begin + FReadLock.Enter; + try + I := IndexOfThreadID(ThreadID); + if I <> -1 then + Result := TJclDebugThreadInfo(FList[I]).CreationTime + else + Result := 0; + finally + FReadLock.Leave; + end; +end; + +function TJclDebugThreadList.GetThreadIDCount: Integer; +begin + FReadLock.Enter; + try + Result := FList.Count; + finally + FReadLock.Leave; + end; +end; + +function TJclDebugThreadList.GetThreadHandle(Index: Integer): THandle; +begin + FReadLock.Enter; + try + Result := TJclDebugThreadInfo(FList[Index]).ThreadHandle; + finally + FReadLock.Leave; + end; +end; + +function TJclDebugThreadList.GetThreadID(Index: Integer): DWORD; +begin + FReadLock.Enter; + try + Result := TJclDebugThreadInfo(FList[Index]).ThreadID; + finally + FReadLock.Leave; + end; +end; + +function TJclDebugThreadList.GetThreadInfos(ThreadID: DWORD): string; +begin + Result := GetThreadValues(ThreadID, 2); +end; + +function TJclDebugThreadList.GetThreadNames(ThreadID: DWORD): string; +begin + Result := GetThreadValues(ThreadID, 0); +end; + +function TJclDebugThreadList.GetThreadParentID(ThreadID: DWORD): DWORD; +var + I: Integer; +begin + FReadLock.Enter; + try + I := IndexOfThreadID(ThreadID); + if I <> -1 then + Result := TJclDebugThreadInfo(FList[I]).ParentThreadID + else + Result := 0; + finally + FReadLock.Leave; + end; +end; + +function TJclDebugThreadList.GetThreadValues(ThreadID: DWORD; Index: Integer): string; +var + I: Integer; +begin + FReadLock.Enter; + try + I := IndexOfThreadID(ThreadID); + if I <> -1 then + begin + case Index of + 0: + Result := TJclDebugThreadInfo(FList[I]).ThreadName; + 1: + Result := TJclDebugThreadInfo(FList[I]).ThreadClassName; + 2: + Result := Format('%.8x [%s] "%s"', [ThreadID, TJclDebugThreadInfo(FList[I]).ThreadClassName, + TJclDebugThreadInfo(FList[I]).ThreadName]); + end; + end + else + Result := ''; + finally + FReadLock.Leave; + end; +end; + +function TJclDebugThreadList.IndexOfThreadID(ThreadID: DWORD): Integer; +var + I: Integer; +begin + Result := -1; + for I := FList.Count - 1 downto 0 do + if TJclDebugThreadInfo(FList[I]).ThreadID = ThreadID then + begin + Result := I; + Break; + end; +end; + +procedure TJclDebugThreadList.InternalRegisterThread(Thread: TThread; ThreadID: DWORD; const ThreadName: string); +var + I: Integer; + ThreadInfo: TJclDebugThreadInfo; +begin + FLock.Enter; + try + I := IndexOfThreadID(ThreadID); + if I = -1 then + begin + FReadLock.Enter; + try + FList.Add(TJclDebugThreadInfo.Create(GetCurrentThreadId, ThreadID, FSaveCreationStack)); + ThreadInfo := TJclDebugThreadInfo(FList.Last); + if Assigned(Thread) then + begin + ThreadInfo.ThreadHandle := Thread.Handle; + ThreadInfo.ThreadClassName := Thread.ClassName; + end + else + begin + ThreadInfo.ThreadHandle := 0; + ThreadInfo.ThreadClassName := ''; + end; + ThreadInfo.ThreadName := ThreadName; + finally + FReadLock.Leave; + end; + if Assigned(Thread) then + DoThreadRegistered(Thread); + end; + finally + FLock.Leave; + end; +end; + +procedure TJclDebugThreadList.InternalUnregisterThread(Thread: TThread; ThreadID: DWORD); +var + I: Integer; +begin + FLock.Enter; + try + I := IndexOfThreadID(ThreadID); + if I <> -1 then + begin + if Assigned(Thread) then + DoThreadUnregistered(Thread); + FReadLock.Enter; + try + FList.Delete(I); + finally + FReadLock.Leave; + end; + end; + finally + FLock.Leave; + end; +end; + +procedure TJclDebugThreadList.RegisterThread(Thread: TThread; const ThreadName: string); +begin + InternalRegisterThread(Thread, Thread.ThreadID, ThreadName); +end; + +procedure TJclDebugThreadList.RegisterThreadID(AThreadID: DWORD); +begin + InternalRegisterThread(nil, AThreadID, ''); +end; + +procedure TJclDebugThreadList.UnregisterThread(Thread: TThread); +begin + InternalUnregisterThread(Thread, Thread.ThreadID); +end; + +procedure TJclDebugThreadList.UnregisterThreadID(AThreadID: DWORD); +begin + InternalUnregisterThread(nil, AThreadID); +end; + +//=== { TJclDebugThreadInfo } ================================================ + +constructor TJclDebugThreadInfo.Create(AParentThreadID, AThreadID: DWORD; AStack: Boolean); +begin + FCreationTime := Now; + FParentThreadID := AParentThreadID; + try + { TODO -oUSc : ... } +// FStackList := JclCreateStackList(True, 0, nil, True);//probably IgnoreLevels = 11 + if AStack then + FStackList := TJclStackInfoList.Create(True, 0, nil, True, nil, nil) + else + FStackList := nil; + except + FStackList := nil; + end; + FThreadID := AThreadID; +end; + +destructor TJclDebugThreadInfo.Destroy; +begin + FStackList.Free; + inherited Destroy; +end; + +//=== { TJclCustomThreadInfo } =============================================== + +constructor TJclCustomThreadInfo.Create; +var + StackClass: TJclCustomLocationInfoListClass; +begin + inherited Create; + StackClass := GetStackClass; + FCreationTime := 0; + FCreationStack := StackClass.Create; + FName := ''; + FParentThreadID := 0; + FStack := StackClass.Create; + FThreadID := 0; + FValues := []; +end; + +destructor TJclCustomThreadInfo.Destroy; +begin + FCreationStack.Free; + FStack.Free; + inherited Destroy; +end; + +procedure TJclCustomThreadInfo.AssignTo(Dest: TPersistent); +begin + if Dest is TJclCustomThreadInfo then + begin + TJclCustomThreadInfo(Dest).FCreationTime := FCreationTime; + TJclCustomThreadInfo(Dest).FCreationStack.Assign(FCreationStack); + TJclCustomThreadInfo(Dest).FName := FName; + TJclCustomThreadInfo(Dest).FParentThreadID := FParentThreadID; + TJclCustomThreadInfo(Dest).FStack.Assign(FStack); + TJclCustomThreadInfo(Dest).FThreadID := FThreadID; + TJclCustomThreadInfo(Dest).FValues := FValues; + end + else + inherited AssignTo(Dest); +end; + +function TJclCustomThreadInfo.GetStackClass: TJclCustomLocationInfoListClass; +begin + Result := TJclLocationInfoList; +end; + +//=== { TJclThreadInfo } ===================================================== + +procedure TJclThreadInfo.Fill(AThreadHandle: THandle; AThreadID: DWORD; AGatherOptions: TJclThreadInfoOptions); +begin + InternalFill(AThreadHandle, AThreadID, AGatherOptions, False); +end; + +procedure TJclThreadInfo.FillFromExceptThread(AGatherOptions: TJclThreadInfoOptions); +begin + InternalFill(0, GetCurrentThreadID, AGatherOptions, True); +end; + +function TJclThreadInfo.GetAsString: string; +var + ExceptInfo, ThreadName, ThreadInfoStr: string; +begin + if tioIsMainThread in Values then + ThreadName := ' [MainThread]' + else + if tioName in Values then + ThreadName := Name + else + ThreadName := ''; + ThreadInfoStr := ''; + if tioCreationTime in Values then + ThreadInfoStr := ThreadInfoStr + Format(' CreationTime: %s', [DateTimeToStr(CreationTime)]); + if tioParentThreadID in Values then + ThreadInfoStr := ThreadInfoStr + Format(' ParentThreadID: %d', [ParentThreadID]); + ExceptInfo := Format('ThreadID: %d%s%s', [ThreadID, ThreadName, ThreadInfoStr]) + #13#10; + if tioStack in Values then + ExceptInfo := ExceptInfo + Stack.AsString; + if tioCreationStack in Values then + ExceptInfo := ExceptInfo + 'Created at:' + #13#10 + CreationStack.AsString + #13#10; + Result := ExceptInfo + #13#10; +end; + +function TJclThreadInfo.GetStack(const AIndex: Integer): TJclLocationInfoList; +begin + case AIndex of + 1: Result := TJclLocationInfoList(FCreationStack); + 2: Result := TJclLocationInfoList(FStack); + else + Result := nil; + end; +end; + +function TJclThreadInfo.GetStackClass: TJclCustomLocationInfoListClass; +begin + Result := TJclLocationInfoList; +end; + +procedure TJclThreadInfo.InternalFill(AThreadHandle: THandle; AThreadID: DWORD; AGatherOptions: TJclThreadInfoOptions; AExceptThread: Boolean); +var + Idx: Integer; + List: TJclStackInfoList; +begin + if tioStack in AGatherOptions then + begin + if AExceptThread then + List := JclLastExceptStackList + else + List := JclCreateThreadStackTrace(True, AThreadHandle); + try + Stack.AddStackInfoList(List); + Values := Values + [tioStack]; + except + { TODO -oUSc : ... } + end; + end; + ThreadID := AThreadID; + if tioIsMainThread in AGatherOptions then + begin + if MainThreadID = AThreadID then + Values := Values + [tioIsMainThread]; + end; + if AGatherOptions * [tioName, tioCreationTime, tioParentThreadID, tioCreationStack] <> [] then + Idx := JclDebugThreadList.IndexOfThreadID(AThreadID) + else + Idx := -1; + if (tioName in AGatherOptions) and (Idx <> -1) then + begin + Name := JclDebugThreadList.ThreadNames[AThreadID]; + Values := Values + [tioName]; + end; + if (tioCreationTime in AGatherOptions) and (Idx <> -1) then + begin + CreationTime := JclDebugThreadList.ThreadCreationTime[AThreadID]; + Values := Values + [tioCreationTime]; + end; + if (tioParentThreadID in AGatherOptions) and (Idx <> -1) then + begin + ParentThreadID := JclDebugThreadList.ThreadParentIDs[AThreadID]; + Values := Values + [tioParentThreadID]; + end; + if (tioCreationStack in AGatherOptions) and (Idx <> -1) then + begin + try + if JclDebugThreadList.AddStackListToLocationInfoList(AThreadID, CreationStack) then + Values := Values + [tioCreationStack]; + except + { TODO -oUSc : ... } + end; + end; +end; + +//=== { TJclThreadInfoList } ================================================= + +constructor TJclThreadInfoList.Create; +begin + inherited Create; + FItems := TObjectList.Create; + FGatherOptions := [tioIsMainThread, tioName, tioCreationTime, tioParentThreadID, tioStack, tioCreationStack]; +end; + +destructor TJclThreadInfoList.Destroy; +begin + FItems.Free; + inherited Destroy; +end; + +function TJclThreadInfoList.Add: TJclThreadInfo; +begin + FItems.Add(TJclThreadInfo.Create); + Result := TJclThreadInfo(FItems.Last); +end; + +procedure TJclThreadInfoList.AssignTo(Dest: TPersistent); +var + I: Integer; +begin + if Dest is TJclThreadInfoList then + begin + TJclThreadInfoList(Dest).Clear; + for I := 0 to Count - 1 do + TJclThreadInfoList(Dest).Add.Assign(Items[I]); + TJclThreadInfoList(Dest).GatherOptions := FGatherOptions; + end + else + inherited AssignTo(Dest); +end; + +procedure TJclThreadInfoList.Clear; +begin + FItems.Clear; +end; + +function TJclThreadInfoList.GetAsString: string; +var + I: Integer; +begin + Result := ''; + for I := 0 to Count - 1 do + Result := Result + Items[I].AsString + #13#10; +end; + +procedure TJclThreadInfoList.Gather(AExceptThreadID: DWORD); +begin + InternalGather([], [AExceptThreadID]); +end; + +procedure TJclThreadInfoList.GatherExclude(AThreadIDs: array of DWORD); +begin + InternalGather([], AThreadIDs); +end; + +procedure TJclThreadInfoList.GatherInclude(AThreadIDs: array of DWORD); +begin + InternalGather(AThreadIDs, []); +end; + +function TJclThreadInfoList.GetCount: Integer; +begin + Result := FItems.Count; +end; + +function TJclThreadInfoList.GetItems(AIndex: Integer): TJclThreadInfo; +begin + Result := TJclThreadInfo(FItems[AIndex]); +end; + +procedure TJclThreadInfoList.InternalGather(AIncludeThreadIDs, AExcludeThreadIDs: array of DWORD); + + function OpenThread(ThreadID: DWORD): THandle; + type + TOpenThreadFunc = function(DesiredAccess: DWORD; InheritHandle: BOOL; ThreadID: DWORD): THandle; stdcall; + const + THREAD_SUSPEND_RESUME = $0002; + THREAD_GET_CONTEXT = $0008; + THREAD_QUERY_INFORMATION = $0040; + var + Kernel32Lib: THandle; + OpenThreadFunc: TOpenThreadFunc; + begin + Result := 0; + Kernel32Lib := GetModuleHandle(kernel32); + if Kernel32Lib <> 0 then + begin + // OpenThread only exists since Windows ME + OpenThreadFunc := GetProcAddress(Kernel32Lib, 'OpenThread'); + if Assigned(OpenThreadFunc) then + Result := OpenThreadFunc(THREAD_SUSPEND_RESUME or THREAD_GET_CONTEXT or THREAD_QUERY_INFORMATION, False, ThreadID); + end; + end; + + function SearchThreadInArray(AThreadIDs: array of DWORD; AThreadID: DWORD): Boolean; + var + I: Integer; + begin + Result := False; + if Length(AThreadIDs) > 0 then + for I := Low(AThreadIDs) to High(AThreadIDs) do + if AThreadIDs[I] = AThreadID then + begin + Result := True; + Break; + end; + end; + +var + SnapProcHandle: THandle; + ThreadEntry: TThreadEntry32; + NextThread: Boolean; + ThreadIDList, ThreadHandleList: TList; + I: Integer; + PID, TID: DWORD; + ThreadHandle: THandle; + ThreadInfo: TJclThreadInfo; +begin + ThreadIDList := TList.Create; + ThreadHandleList := TList.Create; + try + SnapProcHandle := CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); + if SnapProcHandle <> INVALID_HANDLE_VALUE then + try + PID := GetCurrentProcessId; + ThreadEntry.dwSize := SizeOf(ThreadEntry); + NextThread := Thread32First(SnapProcHandle, ThreadEntry); + while NextThread do + begin + if ThreadEntry.th32OwnerProcessID = PID then + begin + if SearchThreadInArray(AIncludeThreadIDs, ThreadEntry.th32ThreadID) or + not SearchThreadInArray(AExcludeThreadIDs, ThreadEntry.th32ThreadID) then + ThreadIDList.Add(Pointer(ThreadEntry.th32ThreadID)); + end; + NextThread := Thread32Next(SnapProcHandle, ThreadEntry); + end; + finally + CloseHandle(SnapProcHandle); + end; + for I := 0 to ThreadIDList.Count - 1 do + begin + ThreadHandle := OpenThread(TJclAddr(ThreadIDList[I])); + ThreadHandleList.Add(Pointer(ThreadHandle)); + if ThreadHandle <> 0 then + SuspendThread(ThreadHandle); + end; + try + for I := 0 to ThreadIDList.Count - 1 do + begin + ThreadHandle := THandle(ThreadHandleList[I]); + TID := TJclAddr(ThreadIDList[I]); + + ThreadInfo := Add; + ThreadInfo.Fill(ThreadHandle, TID, FGatherOptions); + end; + finally + for I := 0 to ThreadHandleList.Count - 1 do + if ThreadHandleList[I] <> nil then + begin + ThreadHandle := THandle(ThreadHandleList[I]); + ResumeThread(ThreadHandle); + CloseHandle(ThreadHandle); + end; + end; + finally + ThreadIDList.Free; + ThreadHandleList.Free; + end; +end; + +//== Miscellanuous =========================================================== + +{$IFDEF MSWINDOWS} + +{$IFNDEF WINSCP} +function EnableCrashOnCtrlScroll(const Enable: Boolean): Boolean; +const + CrashCtrlScrollKey = 'SYSTEM\CurrentControlSet\Services\i8042prt\Parameters'; + CrashCtrlScrollName = 'CrashOnCtrlScroll'; +var + Enabled: Integer; +begin + Enabled := 0; + if Enable then + Enabled := 1; + RegWriteInteger(HKEY_LOCAL_MACHINE, CrashCtrlScrollKey, CrashCtrlScrollName, Enabled); + Result := RegReadInteger(HKEY_LOCAL_MACHINE, CrashCtrlScrollKey, CrashCtrlScrollName) = Enabled; +end; +{$ENDIF ~WINSCP} + +function IsDebuggerAttached: Boolean; +var + IsDebuggerPresent: function: Boolean; stdcall; + KernelHandle: THandle; + P: Pointer; +begin + KernelHandle := GetModuleHandle(kernel32); + @IsDebuggerPresent := GetProcAddress(KernelHandle, 'IsDebuggerPresent'); + if @IsDebuggerPresent <> nil then + begin + // Win98+ / NT4+ + Result := IsDebuggerPresent + end + else + begin + // Win9x uses thunk pointer outside the module when under a debugger + P := GetProcAddress(KernelHandle, 'GetProcAddress'); + Result := TJclAddr(P) < KernelHandle; + end; +end; + +function IsHandleValid(Handle: THandle): Boolean; +var + Duplicate: THandle; + Flags: DWORD; +begin + if IsWinNT then + begin + Flags := 0; + Result := GetHandleInformation(Handle, Flags); + end + else + Result := False; + if not Result then + begin + // DuplicateHandle is used as an additional check for those object types not + // supported by GetHandleInformation (e.g. according to the documentation, + // GetHandleInformation doesn't support window stations and desktop although + // tests show that it does). GetHandleInformation is tried first because its + // much faster. Additionally GetHandleInformation is only supported on NT... + Result := DuplicateHandle(GetCurrentProcess, Handle, GetCurrentProcess, + @Duplicate, 0, False, DUPLICATE_SAME_ACCESS); + if Result then + Result := CloseHandle(Duplicate); + end; +end; + +{$ENDIF MSWINDOWS} + +initialization + DebugInfoCritSect := TJclCriticalSection.Create; + GlobalModulesList := TJclGlobalModulesList.Create; + GlobalStackList := TJclGlobalStackList.Create; + AddIgnoredException(EAbort); + {$IFDEF UNITVERSIONING} + RegisterUnitVersion(HInstance, UnitVersioning); + {$ENDIF UNITVERSIONING} + +finalization + {$IFDEF UNITVERSIONING} + UnregisterUnitVersion(HInstance); + {$ENDIF UNITVERSIONING} + + { TODO -oPV -cInvestigate : Calling JclStopExceptionTracking causes linking of various classes to + the code without a real need. Although there doesn't seem to be a way to unhook exceptions + safely because we need to be covered by JclHookExcept.Notifiers critical section } + JclStopExceptionTracking; + + FreeAndNil(RegisteredThreadList); + FreeAndNil(DebugInfoList); + FreeAndNil(GlobalStackList); + FreeAndNil(GlobalModulesList); + FreeAndNil(DebugInfoCritSect); + FreeAndNil(InfoSourceClassList); + FreeAndNil(IgnoredExceptions); + FreeAndNil(IgnoredExceptionClassNames); + FreeAndNil(IgnoredExceptionClassNamesCritSect); + + TJclDebugInfoSymbols.CleanupDebugSymbols; + +end. diff --git a/source/packages/jcl/JclFileUtils.pas b/source/packages/jcl/JclFileUtils.pas new file mode 100644 index 00000000..6d7a3609 --- /dev/null +++ b/source/packages/jcl/JclFileUtils.pas @@ -0,0 +1,7068 @@ +{**************************************************************************************************} +{ } +{ Project JEDI Code Library (JCL) } +{ } +{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); } +{ you may not use this file except in compliance with the License. You may obtain a copy of the } +{ License at http://www.mozilla.org/MPL/ } +{ } +{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF } +{ ANY KIND, either express or implied. See the License for the specific language governing rights } +{ and limitations under the License. } +{ } +{ The Original Code is JclFileUtils.pas. } +{ } +{ The Initial Developer of the Original Code is Marcel van Brakel. } +{ Portions created by Marcel van Brakel are Copyright (C) Marcel van Brakel. All rights reserved. } +{ } +{ Contributors: } +{ Andre Snepvangers (asnepvangers) } +{ Andreas Hausladen (ahuser) } +{ Anthony Steele } +{ Rik Barker (rikbarker) } +{ Azret Botash } +{ Charlie Calvert } +{ David Hervieux } +{ Florent Ouchet (outchy) } +{ Jean-Fabien Connault (cycocrew) } +{ Jens Fudickar (jfudickar) } +{ JohnML } +{ John Molyneux } +{ Marcel Bestebroer } +{ Marcel van Brakel } +{ Massimo Maria Ghisalberti } +{ Matthias Thoma (mthoma) } +{ Olivier Sannier (obones) } +{ Pelle F. S. Liljendal } +{ Robert Marquardt (marquardt) } +{ Robert Rossmair (rrossmair) } +{ Rudy Velthuis } +{ Scott Price } +{ Wim De Cleen } +{ } +{**************************************************************************************************} +{ } +{ This unit contains routines and classes for working with files, directories and path strings. } +{ Additionally it contains wrapper classes for file mapping objects and version resources. } +{ Generically speaking, everything that has to do with files and directories. Note that filesystem } +{ specific functionality has been extracted into external units, for example JclNTFS which } +{ contains NTFS specific utility routines, and that the JclShell unit contains some file related } +{ routines as well but they are specific to the Windows shell. } +{ } +{**************************************************************************************************} +{ } +{ Last modified: $Date:: $ } +{ Revision: $Rev:: $ } +{ Author: $Author:: $ } +{ } +{**************************************************************************************************} + +unit JclFileUtils; + +{$I jcl.inc} +{$I crossplatform.inc} + +interface + +uses + {$IFDEF UNITVERSIONING} + JclUnitVersioning, + {$ENDIF UNITVERSIONING} + {$IFDEF HAS_UNIT_LIBC} + Libc, + {$ENDIF HAS_UNIT_LIBC} + {$IFDEF HAS_UNITSCOPE} + {$IFDEF MSWINDOWS} + Winapi.Windows, JclWin32, + {$ENDIF MSWINDOWS} + System.Classes, System.SysUtils, + {$ELSE ~HAS_UNITSCOPE} + {$IFDEF MSWINDOWS} + Windows, JclWin32, + {$ENDIF MSWINDOWS} + Classes, SysUtils, + {$ENDIF ~HAS_UNITSCOPE} + JclBase, JclSysUtils; + +// Path Manipulation +// +// Various support routines for working with path strings. For example, building a path from +// elements or extracting the elements from a path, interpretation of paths and transformations of +// paths. +const + {$IFDEF UNIX} + // renamed to DirDelimiter + // PathSeparator = '/'; + DirDelimiter = '/'; + DirSeparator = ':'; + {$ENDIF UNIX} + {$IFDEF MSWINDOWS} + PathDevicePrefix = '\\.\'; + // renamed to DirDelimiter + // PathSeparator = '\'; + DirDelimiter = '\'; + DirSeparator = ';'; + PathUncPrefix = '\\'; + {$ENDIF MSWINDOWS} + + faSymLink = $00000040 {$IFDEF SUPPORTS_PLATFORM} platform {$ENDIF}; // defined since D7 + faNormalFile = $00000080; + faTemporary = $00000100 {$IFDEF SUPPORTS_PLATFORM} platform {$ENDIF}; + faSparseFile = $00000200 {$IFDEF SUPPORTS_PLATFORM} platform {$ENDIF}; + faReparsePoint = $00000400 {$IFDEF SUPPORTS_PLATFORM} platform {$ENDIF}; + faCompressed = $00000800 {$IFDEF SUPPORTS_PLATFORM} platform {$ENDIF}; + faOffline = $00001000 {$IFDEF SUPPORTS_PLATFORM} platform {$ENDIF}; + faNotContentIndexed = $00002000 {$IFDEF SUPPORTS_PLATFORM} platform {$ENDIF}; + faEncrypted = $00004000 {$IFDEF SUPPORTS_PLATFORM} platform {$ENDIF}; + + // Note: faVolumeID is potentially dangerous and its usage has been discontinued + // Please see QC report 6003 for details, available online at this URL: + // http://qc.embarcadero.com/wc/qcmain.aspx?d=6003 + faRejectedByDefault = faHidden + faSysFile + faDirectory; + faWindowsSpecific = faArchive + faTemporary + faSparseFile + faReparsePoint + + faCompressed + faOffline + faNotContentIndexed + faEncrypted; + faUnixSpecific = faSymLink; + +type + TCompactPath = ({cpBegin, }cpCenter, cpEnd); + +function CharIsDriveLetter(const C: char): Boolean; + +function PathAddSeparator(const Path: string): string; +function PathAddExtension(const Path, Extension: string): string; +function PathAppend(const Path, Append: string): string; +function PathBuildRoot(const Drive: Byte): string; +function PathCanonicalize(const Path: string): string; +function PathCommonPrefix(const Path1, Path2: string): Integer; +{$IFDEF MSWINDOWS} +function PathCompactPath(const DC: HDC; const Path: string; const Width: Integer; + CmpFmt: TCompactPath): string; +{$ENDIF MSWINDOWS} +procedure PathExtractElements(const Source: string; var Drive, Path, FileName, Ext: string); +function PathExtractFileDirFixed(const S: string): string; +function PathExtractFileNameNoExt(const Path: string): string; +function PathExtractPathDepth(const Path: string; Depth: Integer): string; +function PathGetDepth(const Path: string): Integer; +{$IFDEF MSWINDOWS} +function PathGetLongName(const Path: string): string; +function PathGetShortName(const Path: string): string; +{$ENDIF MSWINDOWS} +function PathGetRelativePath(Origin, Destination: string): string; +function PathGetTempPath: string; +function PathIsAbsolute(const Path: string): Boolean; +function PathIsChild(const Path, Base: string): Boolean; +function PathIsEqualOrChild(const Path, Base: string): Boolean; +function PathIsDiskDevice(const Path: string): Boolean; +function PathIsUNC(const Path: string): Boolean; +function PathRemoveSeparator(const Path: string): string; +function PathRemoveExtension(const Path: string): string; + +// Windows Vista uses localized path names in the Windows Explorer but these +// folders do not really exist on disk. This causes all I/O operations to fail +// if the user specifies such a localized directory like "C:\Benutzer\MyName\Bilder" +// instead of the physical folder "C:\Users\MyName\Pictures". +// These two functions allow to convert the user's input from localized to +// physical paths and vice versa. +function PathGetPhysicalPath(const LocalizedPath: string): string; +function PathGetLocalizedPath(const PhysicalPath: string): string; + +// Files and Directories +// +// Routines for working with files and directories. Includes routines to extract various file +// attributes or update them, volume locking and routines for creating temporary files. +type + TDelTreeProgress = function (const FileName: string; Attr: DWORD): Boolean; + TFileListOption = (flFullNames, flRecursive, flMaskedSubfolders); + TFileListOptions = set of TFileListOption; + TJclAttributeMatch = (amAny, amExact, amSubSetOf, amSuperSetOf, amCustom); + TFileMatchFunc = function(const Attr: Integer; const FileInfo: TSearchRec): Boolean; + TFileHandler = procedure (const FileName: string) of object; + TFileHandlerEx = procedure (const Directory: string; const FileInfo: TSearchRec) of object; + TFileInfoHandlerEx = procedure (const FileInfo: TSearchRec) of object; + +function BuildFileList(const Path: string; const Attr: Integer; const List: TStrings; IncludeDirectoryName: Boolean = + False): Boolean; +function AdvBuildFileList(const Path: string; const Attr: Integer; const Files: TStrings; + const AttributeMatch: TJclAttributeMatch = amSuperSetOf; const Options: TFileListOptions = []; + const SubfoldersMask: string = ''; const FileMatchFunc: TFileMatchFunc = nil): Boolean; +function VerifyFileAttributeMask(var RejectedAttributes, RequiredAttributes: Integer): Boolean; +function IsFileAttributeMatch(FileAttributes, RejectedAttributes, + RequiredAttributes: Integer): Boolean; +function FileAttributesStr(const FileInfo: TSearchRec): string; +function IsFileNameMatch(FileName: string; const Mask: string; + const CaseSensitive: Boolean = {$IFDEF MSWINDOWS} False {$ELSE} True {$ENDIF}): Boolean; +procedure EnumFiles(const Path: string; HandleFile: TFileHandlerEx; + RejectedAttributes: Integer = faRejectedByDefault; RequiredAttributes: Integer = 0; + Abort: PBoolean = nil); overload; +procedure EnumFiles(const Path: string; HandleFile: TFileInfoHandlerEx; + RejectedAttributes: Integer = faRejectedByDefault; RequiredAttributes: Integer = 0; + Abort: PBoolean = nil); overload; +procedure EnumDirectories(const Root: string; const HandleDirectory: TFileHandler; + const IncludeHiddenDirectories: Boolean = False; const SubDirectoriesMask: string = ''; + Abort: PBoolean = nil {$IFDEF UNIX}; ResolveSymLinks: Boolean = True {$ENDIF}); +{$IFDEF MSWINDOWS} +procedure CreateEmptyFile(const FileName: string); +function CloseVolume(var Volume: THandle): Boolean; +{$IFNDEF FPC} +{$IFNDEF WINSCP} +function DeleteDirectory(const DirectoryName: string; MoveToRecycleBin: Boolean): Boolean; +{$ENDIF ~WINSCP} +function CopyDirectory(ExistingDirectoryName, NewDirectoryName: string): Boolean; +function MoveDirectory(ExistingDirectoryName, NewDirectoryName: string): Boolean; +{$ENDIF ~FPC} +function DelTree(const Path: string): Boolean; +function DelTreeEx(const Path: string; AbortOnFailure: Boolean; Progress: TDelTreeProgress): Boolean; +function DiskInDrive(Drive: Char): Boolean; +{$ENDIF MSWINDOWS} +function DirectoryExists(const Name: string {$IFDEF UNIX}; ResolveSymLinks: Boolean = True {$ENDIF}): Boolean; +function FileCreateTemp(var Prefix: string): THandle; +{$IFNDEF WINSCP} +function FileBackup(const FileName: string; Move: Boolean = False): Boolean; +{$ENDIF ~WINSCP} +function FileCopy(const ExistingFileName, NewFileName: string; ReplaceExisting: Boolean = False): Boolean; +function FileDateTime(const FileName: string): TDateTime; +{$IFNDEF WINSCP} +function FileDelete(const FileName: string; MoveToRecycleBin: Boolean = False): Boolean; +{$ENDIF ~WINSCP} +function FileExists(const FileName: string): Boolean; +/// procedure FileHistory Creates a list of history files of a specified +/// source file. Each version of the file get's an extention .~~ The file with +/// the lowest number is the youngest file. +/// +/// (string) Name of the source file +/// (string) Folder where the history files should be +/// created. If no folder is defined the folder of the source file is used. +/// (Integer) Max number of files +/// (TDateTime) Timestamp how old the file has to be to +/// create a new history version. For example: NOW-1/24 => Only once per hour a new +/// history file is created. Default 0 means allways +/// (boolean) Flag to define that the history file +/// extention should replace the current extention or should be added at the +/// end +/// +{$IFNDEF WINSCP} +procedure FileHistory(const FileName: string; HistoryPath: string = ''; MaxHistoryCount: Integer = 100; MinFileDate: + TDateTime = 0; ReplaceExtention: Boolean = true); +function FileMove(const ExistingFileName, NewFileName: string; ReplaceExisting: Boolean = False): Boolean; +function FileRestore(const FileName: string): Boolean; +{$ENDIF ~WINSCP} +function GetBackupFileName(const FileName: string): string; +function IsBackupFileName(const FileName: string): Boolean; +function FileGetDisplayName(const FileName: string): string; +{$IFNDEF WINSCP} +function FileGetGroupName(const FileName: string {$IFDEF UNIX}; ResolveSymLinks: Boolean = True {$ENDIF}): string; +function FileGetOwnerName(const FileName: string {$IFDEF UNIX}; ResolveSymLinks: Boolean = True {$ENDIF}): string; +{$ENDIF ~WINSCP} +function FileGetSize(const FileName: string): Int64; +function FileGetTempName(const Prefix: string): string; +{$IFDEF MSWINDOWS} +function FileGetTypeName(const FileName: string): string; +{$ENDIF MSWINDOWS} +function FindUnusedFileName(FileName: string; const FileExt: string; NumberPrefix: string = ''): string; +function ForceDirectories(Name: string): Boolean; +function GetDirectorySize(const Path: string): Int64; +{$IFDEF MSWINDOWS} +function GetDriveTypeStr(const Drive: Char): string; +function GetFileAgeCoherence(const FileName: string): Boolean; +{$ENDIF MSWINDOWS} +procedure GetFileAttributeList(const Items: TStrings; const Attr: Integer); +{$IFDEF MSWINDOWS} +procedure GetFileAttributeListEx(const Items: TStrings; const Attr: Integer); +{$ENDIF MSWINDOWS} +function GetFileInformation(const FileName: string; out FileInfo: TSearchRec): Boolean; overload; +function GetFileInformation(const FileName: string): TSearchRec; overload; +{$IFDEF UNIX} +function GetFileStatus(const FileName: string; out StatBuf: TStatBuf64; + const ResolveSymLinks: Boolean): Integer; +{$ENDIF UNIX} +{$IFDEF MSWINDOWS} +function GetFileLastWrite(const FileName: string): TFileTime; overload; +{$IFNDEF WINSCP} +function GetFileLastWrite(const FileName: string; out LocalTime: TDateTime): Boolean; overload; +{$ENDIF ~WINSCP} +function GetFileLastAccess(const FileName: string): TFileTime; overload; +{$IFNDEF WINSCP} +function GetFileLastAccess(const FileName: string; out LocalTime: TDateTime): Boolean; overload; +{$ENDIF ~WINSCP} +function GetFileCreation(const FileName: string): TFileTime; overload; +{$IFNDEF WINSCP} +function GetFileCreation(const FileName: string; out LocalTime: TDateTime): Boolean; overload; +{$ENDIF ~WINSCP} +{$ENDIF MSWINDOWS} +{$IFDEF UNIX} +function GetFileLastWrite(const FileName: string; out TimeStamp: Integer; ResolveSymLinks: Boolean = True): Boolean; overload; +function GetFileLastWrite(const FileName: string; out LocalTime: TDateTime; ResolveSymLinks: Boolean = True): Boolean; overload; +function GetFileLastWrite(const FileName: string; ResolveSymLinks: Boolean = True): Integer; overload; +function GetFileLastAccess(const FileName: string; out TimeStamp: Integer; ResolveSymLinks: Boolean = True): Boolean; overload; +function GetFileLastAccess(const FileName: string; out LocalTime: TDateTime; ResolveSymLinks: Boolean = True): Boolean; overload; +function GetFileLastAccess(const FileName: string; ResolveSymLinks: Boolean = True): Integer; overload; +function GetFileLastAttrChange(const FileName: string; out TimeStamp: Integer; ResolveSymLinks: Boolean = True): Boolean; overload; +function GetFileLastAttrChange(const FileName: string; out LocalTime: TDateTime; ResolveSymLinks: Boolean = True): Boolean; overload; +function GetFileLastAttrChange(const FileName: string; ResolveSymLinks: Boolean = True): Integer; overload; +{$ENDIF UNIX} +function GetModulePath(const Module: HMODULE): string; +function GetSizeOfFile(const FileName: string): Int64; overload; +function GetSizeOfFile(const FileInfo: TSearchRec): Int64; overload; +{$IFDEF MSWINDOWS} +function GetSizeOfFile(Handle: THandle): Int64; overload; +function GetStandardFileInfo(const FileName: string): TWin32FileAttributeData; +{$ENDIF MSWINDOWS} +function IsDirectory(const FileName: string {$IFDEF UNIX}; ResolveSymLinks: Boolean = True {$ENDIF}): Boolean; +function IsRootDirectory(const CanonicFileName: string): Boolean; +{$IFDEF MSWINDOWS} +function LockVolume(const Volume: string; var Handle: THandle): Boolean; +function OpenVolume(const Drive: Char): THandle; +{$IFNDEF WINSCP} +function SetDirLastWrite(const DirName: string; const DateTime: TDateTime; RequireBackupRestorePrivileges: Boolean = True): Boolean; +function SetDirLastAccess(const DirName: string; const DateTime: TDateTime; RequireBackupRestorePrivileges: Boolean = True): Boolean; +function SetDirCreation(const DirName: string; const DateTime: TDateTime; RequireBackupRestorePrivileges: Boolean = True): Boolean; +{$ENDIF ~WINSCP} +{$ENDIF MSWINDOWS} +function SetFileLastWrite(const FileName: string; const DateTime: TDateTime): Boolean; +function SetFileLastAccess(const FileName: string; const DateTime: TDateTime): Boolean; +{$IFDEF MSWINDOWS} +function SetFileCreation(const FileName: string; const DateTime: TDateTime): Boolean; +procedure ShredFile(const FileName: string; Times: Integer = 1); +function UnlockVolume(var Handle: THandle): Boolean; +{$ENDIF MSWINDOWS} + +{$IFDEF UNIX} +function CreateSymbolicLink(const Name, Target: string): Boolean; +{ This function gets the value of the symbolic link filename. } +function SymbolicLinkTarget(const Name: string): string; +{$ENDIF UNIX} + +// TJclFileAttributeMask +// +// File search helper class, allows to specify required/rejected attributes +type + TAttributeInterest = (aiIgnored, aiRejected, aiRequired); + + TJclCustomFileAttrMask = class(TPersistent) + private + FRequiredAttr: Integer; + FRejectedAttr: Integer; + function GetAttr(Index: Integer): TAttributeInterest; + procedure SetAttr(Index: Integer; const Value: TAttributeInterest); + procedure ReadRequiredAttributes(Reader: TReader); + procedure ReadRejectedAttributes(Reader: TReader); + procedure WriteRequiredAttributes(Writer: TWriter); + procedure WriteRejectedAttributes(Writer: TWriter); + protected + procedure DefineProperties(Filer: TFiler); override; + property ReadOnly: TAttributeInterest index faReadOnly + read GetAttr write SetAttr stored False; + property Hidden: TAttributeInterest index faHidden + read GetAttr write SetAttr stored False; + property System: TAttributeInterest index faSysFile + read GetAttr write SetAttr stored False; + property Directory: TAttributeInterest index faDirectory + read GetAttr write SetAttr stored False; + property SymLink: TAttributeInterest index faSymLink + read GetAttr write SetAttr stored False; + property Normal: TAttributeInterest index faNormalFile + read GetAttr write SetAttr stored False; + property Archive: TAttributeInterest index faArchive + read GetAttr write SetAttr stored False; + property Temporary: TAttributeInterest index faTemporary + read GetAttr write SetAttr stored False; + property SparseFile: TAttributeInterest index faSparseFile + read GetAttr write SetAttr stored False; + property ReparsePoint: TAttributeInterest index faReparsePoint + read GetAttr write SetAttr stored False; + property Compressed: TAttributeInterest index faCompressed + read GetAttr write SetAttr stored False; + property OffLine: TAttributeInterest index faOffline + read GetAttr write SetAttr stored False; + property NotContentIndexed: TAttributeInterest index faNotContentIndexed + read GetAttr write SetAttr stored False; + property Encrypted: TAttributeInterest index faEncrypted + read GetAttr write SetAttr stored False; + public + constructor Create; + procedure Assign(Source: TPersistent); override; + procedure Clear; + function Match(FileAttributes: Integer): Boolean; overload; + function Match(const FileInfo: TSearchRec): Boolean; overload; + property Required: Integer read FRequiredAttr write FRequiredAttr; + property Rejected: Integer read FRejectedAttr write FRejectedAttr; + property Attribute[Index: Integer]: TAttributeInterest read GetAttr write SetAttr; default; + end; + + TJclFileAttributeMask = class(TJclCustomFileAttrMask) + private + procedure ReadVolumeID(Reader: TReader); + protected + procedure DefineProperties(Filer: TFiler); override; + published + property ReadOnly; + property Hidden; + property System; + property Directory; + property Normal; + {$IFDEF UNIX} + property SymLink; + {$ENDIF UNIX} + {$IFDEF MSWINDOWS} + property Archive; + property Temporary; + property SparseFile; + property ReparsePoint; + property Compressed; + property OffLine; + property NotContentIndexed; + property Encrypted; + {$ENDIF MSWINDOWS} + end; + +type + TFileSearchOption = (fsIncludeSubDirectories, fsIncludeHiddenSubDirectories, fsLastChangeAfter, + fsLastChangeBefore, fsMaxSize, fsMinSize); + TFileSearchOptions = set of TFileSearchOption; + TFileSearchTaskID = Integer; + TFileSearchTerminationEvent = procedure (const ID: TFileSearchTaskID; const Aborted: Boolean) of object; + TFileEnumeratorSyncMode = (smPerFile, smPerDirectory); + +// IJclFileSearchOptions +// +// Interface for file search options +type + IJclFileSearchOptions = interface + ['{B73D9E3D-34C5-4DA9-88EF-4CA730328FC9}'] + function GetAttributeMask: TJclFileAttributeMask; + function GetCaseSensitiveSearch: Boolean; + function GetRootDirectories: TStrings; + function GetRootDirectory: string; + function GetFileMask: string; + function GetFileMasks: TStrings; + function GetFileSizeMax: Int64; + function GetFileSizeMin: Int64; + function GetIncludeSubDirectories: Boolean; + function GetIncludeHiddenSubDirectories: Boolean; + function GetLastChangeAfter: TDateTime; + function GetLastChangeBefore: TDateTime; + function GetLastChangeAfterStr: string; + function GetLastChangeBeforeStr: string; + function GetSubDirectoryMask: string; + function GetOption(const Option: TFileSearchOption): Boolean; + function GetOptions: TFileSearchoptions; + procedure SetAttributeMask(const Value: TJclFileAttributeMask); + procedure SetCaseSensitiveSearch(const Value: Boolean); + procedure SetRootDirectories(const Value: TStrings); + procedure SetRootDirectory(const Value: string); + procedure SetFileMask(const Value: string); + procedure SetFileMasks(const Value: TStrings); + procedure SetFileSizeMax(const Value: Int64); + procedure SetFileSizeMin(const Value: Int64); + procedure SetIncludeSubDirectories(const Value: Boolean); + procedure SetIncludeHiddenSubDirectories(const Value: Boolean); + procedure SetLastChangeAfter(const Value: TDateTime); + procedure SetLastChangeBefore(const Value: TDateTime); + procedure SetLastChangeAfterStr(const Value: string); + procedure SetLastChangeBeforeStr(const Value: string); + procedure SetOption(const Option: TFileSearchOption; const Value: Boolean); + procedure SetOptions(const Value: TFileSearchOptions); + procedure SetSubDirectoryMask(const Value: string); + // properties + property CaseSensitiveSearch: Boolean read GetCaseSensitiveSearch write SetCaseSensitiveSearch; + property RootDirectories: TStrings read GetRootDirectories write SetRootDirectories; + property RootDirectory: string read GetRootDirectory write SetRootDirectory; + property FileMask: string read GetFileMask write SetFileMask; + property SubDirectoryMask: string read GetSubDirectoryMask write SetSubDirectoryMask; + property AttributeMask: TJclFileAttributeMask read GetAttributeMask write SetAttributeMask; + property FileSizeMin: Int64 read GetFileSizeMin write SetFileSizeMin; + property FileSizeMax: Int64 read GetFileSizeMax write SetFileSizeMax; // default InvalidFileSize; + property LastChangeAfter: TDateTime read GetLastChangeAfter write SetLastChangeAfter; + property LastChangeBefore: TDateTime read GetLastChangeBefore write SetLastChangeBefore; + property LastChangeAfterAsString: string read GetLastChangeAfterStr write SetLastChangeAfterStr; + property LastChangeBeforeAsString: string read GetLastChangeBeforeStr write SetLastChangeBeforeStr; + property IncludeSubDirectories: Boolean read GetIncludeSubDirectories + write SetIncludeSubDirectories; + property IncludeHiddenSubDirectories: Boolean read GetIncludeHiddenSubDirectories + write SetIncludeHiddenSubDirectories; + end; + +// IJclFileSearchOptions +// +// Interface for file search options +type + TJclFileSearchOptions = class(TJclInterfacedPersistent, IJclFileSearchOptions) + protected + FFileMasks: TStringList; + FRootDirectories: TStringList; + FSubDirectoryMask: string; + FAttributeMask: TJclFileAttributeMask; + FFileSizeMin: Int64; + FFileSizeMax: Int64; + FLastChangeBefore: TDateTime; + FLastChangeAfter: TDateTime; + FOptions: TFileSearchOptions; + FCaseSensitiveSearch: Boolean; + function IsLastChangeAfterStored: Boolean; + function IsLastChangeBeforeStored: Boolean; + public + constructor Create; + destructor Destroy; override; + procedure Assign(Source: TPersistent); override; + + { IJclFileSearchOptions } + function GetAttributeMask: TJclFileAttributeMask; + function GetCaseSensitiveSearch: Boolean; + function GetRootDirectories: TStrings; + function GetRootDirectory: string; + function GetFileMask: string; + function GetFileMasks: TStrings; + function GetFileSizeMax: Int64; + function GetFileSizeMin: Int64; + function GetIncludeSubDirectories: Boolean; + function GetIncludeHiddenSubDirectories: Boolean; + function GetLastChangeAfter: TDateTime; + function GetLastChangeBefore: TDateTime; + function GetLastChangeAfterStr: string; + function GetLastChangeBeforeStr: string; + function GetSubDirectoryMask: string; + function GetOption(const Option: TFileSearchOption): Boolean; + function GetOptions: TFileSearchoptions; + procedure SetAttributeMask(const Value: TJclFileAttributeMask); + procedure SetCaseSensitiveSearch(const Value: Boolean); + procedure SetRootDirectories(const Value: TStrings); + procedure SetRootDirectory(const Value: string); + procedure SetFileMask(const Value: string); + procedure SetFileMasks(const Value: TStrings); + procedure SetFileSizeMax(const Value: Int64); + procedure SetFileSizeMin(const Value: Int64); + procedure SetIncludeSubDirectories(const Value: Boolean); + procedure SetIncludeHiddenSubDirectories(const Value: Boolean); + procedure SetLastChangeAfter(const Value: TDateTime); + procedure SetLastChangeBefore(const Value: TDateTime); + procedure SetLastChangeAfterStr(const Value: string); + procedure SetLastChangeBeforeStr(const Value: string); + procedure SetOption(const Option: TFileSearchOption; const Value: Boolean); + procedure SetOptions(const Value: TFileSearchOptions); + procedure SetSubDirectoryMask(const Value: string); + published + property CaseSensitiveSearch: Boolean read GetCaseSensitiveSearch write SetCaseSensitiveSearch + default {$IFDEF MSWINDOWS} False {$ELSE} True {$ENDIF}; + property FileMasks: TStrings read GetFileMasks write SetFileMasks; + property RootDirectories: TStrings read GetRootDirectories write SetRootDirectories; + property RootDirectory: string read GetRootDirectory write SetRootDirectory; + property SubDirectoryMask: string read FSubDirectoryMask write FSubDirectoryMask; + property AttributeMask: TJclFileAttributeMask read FAttributeMask write SetAttributeMask; + property FileSizeMin: Int64 read FFileSizeMin write FFileSizeMin; + property FileSizeMax: Int64 read FFileSizeMax write FFileSizeMax; + property LastChangeAfter: TDateTime read FLastChangeAfter write FLastChangeAfter + stored IsLastChangeAfterStored; + property LastChangeBefore: TDateTime read FLastChangeBefore write FLastChangeBefore + stored IsLastChangeBeforeStored; + property Options: TFileSearchOptions read FOptions write FOptions + default [fsIncludeSubDirectories]; + end; + +// IJclFileEnumerator +// +// Interface for thread-based file search +type + IJclFileEnumerator = interface(IJclFileSearchOptions) + ['{F7E747ED-1C41-441F-B25B-BB314E00C4E9}'] + // property access methods + function GetRunningTasks: Integer; + function GetSynchronizationMode: TFileEnumeratorSyncMode; + function GetOnEnterDirectory: TFileHandler; + function GetOnTerminateTask: TFileSearchTerminationEvent; + procedure SetSynchronizationMode(const Value: TFileEnumeratorSyncMode); + procedure SetOnEnterDirectory(const Value: TFileHandler); + procedure SetOnTerminateTask(const Value: TFileSearchTerminationEvent); + // other methods + function FillList(List: TStrings): TFileSearchTaskID; + function ForEach(Handler: TFileHandler): TFileSearchTaskID; overload; + function ForEach(Handler: TFileHandlerEx): TFileSearchTaskID; overload; + procedure StopTask(ID: TFileSearchTaskID); + procedure StopAllTasks(Silently: Boolean = False); // Silently: Don't call OnTerminateTask + // properties + property RunningTasks: Integer read GetRunningTasks; + property SynchronizationMode: TFileEnumeratorSyncMode read GetSynchronizationMode + write SetSynchronizationMode; + property OnEnterDirectory: TFileHandler read GetOnEnterDirectory write SetOnEnterDirectory; + property OnTerminateTask: TFileSearchTerminationEvent read GetOnTerminateTask + write SetOnTerminateTask; + end; + +// TJclFileEnumerator +// +// Class for thread-based file search +type + TJclFileEnumerator = class(TJclFileSearchOptions, IInterface, IJclFileSearchOptions, IJclFileEnumerator) + private + FTasks: TList; + FOnEnterDirectory: TFileHandler; + FOnTerminateTask: TFileSearchTerminationEvent; + FNextTaskID: TFileSearchTaskID; + FSynchronizationMode: TFileEnumeratorSyncMode; + function GetNextTaskID: TFileSearchTaskID; + protected + function CreateTask: TThread; + procedure TaskTerminated(Sender: TObject); + property NextTaskID: TFileSearchTaskID read GetNextTaskID; + public + constructor Create; + destructor Destroy; override; + + { IJclFileEnumerator } + function GetRunningTasks: Integer; + function GetSynchronizationMode: TFileEnumeratorSyncMode; + function GetOnEnterDirectory: TFileHandler; + function GetOnTerminateTask: TFileSearchTerminationEvent; + procedure SetSynchronizationMode(const Value: TFileEnumeratorSyncMode); + procedure SetOnEnterDirectory(const Value: TFileHandler); + procedure SetOnTerminateTask(const Value: TFileSearchTerminationEvent); + + procedure Assign(Source: TPersistent); override; + function FillList(List: TStrings): TFileSearchTaskID; + function ForEach(Handler: TFileHandler): TFileSearchTaskID; overload; + function ForEach(Handler: TFileHandlerEx): TFileSearchTaskID; overload; + procedure StopTask(ID: TFileSearchTaskID); + procedure StopAllTasks(Silently: Boolean = False); // Silently: Don't call OnTerminateTask + property FileMask: string read GetFileMask write SetFileMask; + property IncludeSubDirectories: Boolean + read GetIncludeSubDirectories write SetIncludeSubDirectories; + property IncludeHiddenSubDirectories: Boolean + read GetIncludeHiddenSubDirectories write SetIncludeHiddenSubDirectories; + property SearchOption[const Option: TFileSearchOption]: Boolean read GetOption write SetOption; + property LastChangeAfterAsString: string read GetLastChangeAfterStr write SetLastChangeAfterStr; + property LastChangeBeforeAsString: string read GetLastChangeBeforeStr write SetLastChangeBeforeStr; + published + property RunningTasks: Integer read GetRunningTasks; + property SynchronizationMode: TFileEnumeratorSyncMode read FSynchronizationMode write FSynchronizationMode + default smPerDirectory; + property OnEnterDirectory: TFileHandler read FOnEnterDirectory write FOnEnterDirectory; + property OnTerminateTask: TFileSearchTerminationEvent read FOnTerminateTask write FOnTerminateTask; + end; + +function FileSearch: IJclFileEnumerator; + +{$IFDEF MSWINDOWS} + +// TFileVersionInfo +// +// Class that enables reading the version information stored in a PE file. + +type + TFileFlag = (ffDebug, ffInfoInferred, ffPatched, ffPreRelease, ffPrivateBuild, ffSpecialBuild); + TFileFlags = set of TFileFlag; + + PLangIdRec = ^TLangIdRec; + TLangIdRec = packed record + case Integer of + 0: ( + LangId: Word; + CodePage: Word); + 1: ( + Pair: DWORD); + end; + + EJclFileVersionInfoError = class(EJclError); + + TJclFileVersionInfo = class(TObject) + private + FBuffer: AnsiString; + FFixedInfo: PVSFixedFileInfo; + FFileFlags: TFileFlags; + FItemList: TStringList; + FItems: TStringList; + FLanguages: array of TLangIdRec; + FLanguageIndex: Integer; + FTranslations: array of TLangIdRec; + function GetFixedInfo: TVSFixedFileInfo; + function GetItems: TStrings; + function GetLanguageCount: Integer; + function GetLanguageIds(Index: Integer): string; + function GetLanguageNames(Index: Integer): string; + function GetLanguages(Index: Integer): TLangIdRec; + function GetTranslationCount: Integer; + function GetTranslations(Index: Integer): TLangIdRec; + procedure SetLanguageIndex(const Value: Integer); + protected + procedure CreateItemsForLanguage; + procedure CheckLanguageIndex(Value: Integer); + procedure ExtractData; + procedure ExtractFlags; + function GetBinFileVersion: string; + function GetBinProductVersion: string; + function GetFileOS: DWORD; + function GetFileSubType: DWORD; + function GetFileType: DWORD; + function GetFileVersionBuild: string; + function GetFileVersionMajor: string; + function GetFileVersionMinor: string; + function GetFileVersionRelease: string; + function GetProductVersionBuild: string; + function GetProductVersionMajor: string; + function GetProductVersionMinor: string; + function GetProductVersionRelease: string; + function GetVersionKeyValue(Index: Integer): string; + public + constructor Attach(VersionInfoData: Pointer; Size: Integer); + constructor Create(const FileName: string); overload; + {$IFDEF MSWINDOWS} + {$IFDEF FPC} + constructor Create(const Window: HWND; Dummy: Pointer = nil); overload; + {$ELSE} + constructor Create(const Window: HWND); overload; + {$ENDIF} + constructor Create(const Module: HMODULE); overload; + {$ENDIF MSWINDOWS} + destructor Destroy; override; + function GetCustomFieldValue(const FieldName: string): string; + class function VersionLanguageId(const LangIdRec: TLangIdRec): string; + class function VersionLanguageName(const LangId: Word): string; + class function FileHasVersionInfo(const FileName: string): boolean; + function TranslationMatchesLanguages(Exact: Boolean = True): Boolean; + property BinFileVersion: string read GetBinFileVersion; + property BinProductVersion: string read GetBinProductVersion; + property Comments: string index 1 read GetVersionKeyValue; + property CompanyName: string index 2 read GetVersionKeyValue; + property FileDescription: string index 3 read GetVersionKeyValue; + property FixedInfo: TVSFixedFileInfo read GetFixedInfo; + property FileFlags: TFileFlags read FFileFlags; + property FileOS: DWORD read GetFileOS; + property FileSubType: DWORD read GetFileSubType; + property FileType: DWORD read GetFileType; + property FileVersion: string index 4 read GetVersionKeyValue; + property FileVersionBuild: string read GetFileVersionBuild; + property FileVersionMajor: string read GetFileVersionMajor; + property FileVersionMinor: string read GetFileVersionMinor; + property FileVersionRelease: string read GetFileVersionRelease; + property Items: TStrings read GetItems; + property InternalName: string index 5 read GetVersionKeyValue; + property LanguageCount: Integer read GetLanguageCount; + property LanguageIds[Index: Integer]: string read GetLanguageIds; + property LanguageIndex: Integer read FLanguageIndex write SetLanguageIndex; + property Languages[Index: Integer]: TLangIdRec read GetLanguages; + property LanguageNames[Index: Integer]: string read GetLanguageNames; + property LegalCopyright: string index 6 read GetVersionKeyValue; + property LegalTradeMarks: string index 7 read GetVersionKeyValue; + property OriginalFilename: string index 8 read GetVersionKeyValue; + property PrivateBuild: string index 12 read GetVersionKeyValue; + property ProductName: string index 9 read GetVersionKeyValue; + property ProductVersion: string index 10 read GetVersionKeyValue; + property ProductVersionBuild: string read GetProductVersionBuild; + property ProductVersionMajor: string read GetProductVersionMajor; + property ProductVersionMinor: string read GetProductVersionMinor; + property ProductVersionRelease: string read GetProductVersionRelease; + property SpecialBuild: string index 11 read GetVersionKeyValue; + property TranslationCount: Integer read GetTranslationCount; + property Translations[Index: Integer]: TLangIdRec read GetTranslations; + end; + +function OSIdentToString(const OSIdent: DWORD): string; +function OSFileTypeToString(const OSFileType: DWORD; const OSFileSubType: DWORD = 0): string; + +function VersionResourceAvailable(const FileName: string): Boolean; overload; +function VersionResourceAvailable(const Window: HWND): Boolean; overload; +function VersionResourceAvailable(const Module: HMODULE): Boolean; overload; + +function WindowToModuleFileName(const Window: HWND): string; +{$ENDIF MSWINDOWS} + +// Version Info formatting +type + TFileVersionFormat = (vfMajorMinor, vfFull); + +function FormatVersionString(const HiV, LoV: Word): string; overload; +function FormatVersionString(const Major, Minor, Build, Revision: Word): string; overload; + +{$IFDEF MSWINDOWS} + +function FormatVersionString(const FixedInfo: TVSFixedFileInfo; VersionFormat: TFileVersionFormat = vfFull): string; overload; + +// Version Info extracting +procedure VersionExtractFileInfo(const FixedInfo: TVSFixedFileInfo; var Major, Minor, Build, Revision: Word); +procedure VersionExtractProductInfo(const FixedInfo: TVSFixedFileInfo; var Major, Minor, Build, Revision: Word); + +// Fixed Version Info routines +function VersionFixedFileInfo(const FileName: string; var FixedInfo: TVSFixedFileInfo): Boolean; +function VersionFixedFileInfoString(const FileName: string; VersionFormat: TFileVersionFormat = vfFull; + const NotAvailableText: string = ''): string; + +{$ENDIF MSWINDOWS} + +// Streams +// +// TStream descendent classes for dealing with temporary files and for using file mapping objects. +type + TJclTempFileStream = class(THandleStream) + private + FFileName: string; + public + constructor Create(const Prefix: string); + destructor Destroy; override; + property FileName: string read FFileName; + end; + +{$IFDEF MSWINDOWS} + + TJclCustomFileMapping = class; + + TJclFileMappingView = class(TCustomMemoryStream) + private + FFileMapping: TJclCustomFileMapping; + FOffsetHigh: Cardinal; + FOffsetLow: Cardinal; + function GetIndex: Integer; + function GetOffset: Int64; + public + constructor Create(const FileMap: TJclCustomFileMapping; + Access, Size: Cardinal; ViewOffset: Int64); + constructor CreateAt(FileMap: TJclCustomFileMapping; Access, + Size: Cardinal; ViewOffset: Int64; Address: Pointer); + destructor Destroy; override; + function Flush(const Count: Cardinal): Boolean; + procedure LoadFromStream(const Stream: TStream); + procedure LoadFromFile(const FileName: string); + function Write(const Buffer; Count: Longint): Longint; override; + property Index: Integer read GetIndex; + property FileMapping: TJclCustomFileMapping read FFileMapping; + property Offset: Int64 read GetOffset; + end; + + TJclFileMappingRoundOffset = (rvDown, rvUp); + + TJclCustomFileMapping = class(TObject) + private + FExisted: Boolean; + FHandle: THandle; + FName: string; + FRoundViewOffset: TJclFileMappingRoundOffset; + FViews: TList; + function GetCount: Integer; + function GetView(Index: Integer): TJclFileMappingView; + protected + procedure ClearViews; + procedure InternalCreate(const FileHandle: THandle; const Name: string; + const Protect: Cardinal; MaximumSize: Int64; SecAttr: PSecurityAttributes); + procedure InternalOpen(const Name: string; const InheritHandle: Boolean; + const DesiredAccess: Cardinal); + public + constructor Create; + constructor Open(const Name: string; const InheritHandle: Boolean; const DesiredAccess: Cardinal); + destructor Destroy; override; + function Add(const Access, Count: Cardinal; const Offset: Int64): Integer; + function AddAt(const Access, Count: Cardinal; const Offset: Int64; const Address: Pointer): Integer; + procedure Delete(const Index: Integer); + function IndexOf(const View: TJclFileMappingView): Integer; + property Count: Integer read GetCount; + property Existed: Boolean read FExisted; + property Handle: THandle read FHandle; + property Name: string read FName; + property RoundViewOffset: TJclFileMappingRoundOffset read FRoundViewOffset write FRoundViewOffset; + property Views[index: Integer]: TJclFileMappingView read GetView; + end; + + TJclFileMapping = class(TJclCustomFileMapping) + private + FFileHandle: THandle; + public + constructor Create(const FileName: string; FileMode: Cardinal; + const Name: string; Protect: Cardinal; const MaximumSize: Int64; + SecAttr: PSecurityAttributes); overload; + constructor Create(const FileHandle: THandle; const Name: string; + Protect: Cardinal; const MaximumSize: Int64; + SecAttr: PSecurityAttributes); overload; + destructor Destroy; override; + property FileHandle: THandle read FFileHandle; + end; + + TJclSwapFileMapping = class(TJclCustomFileMapping) + public + constructor Create(const Name: string; Protect: Cardinal; + const MaximumSize: Int64; SecAttr: PSecurityAttributes); + end; + + TJclFileMappingStream = class(TCustomMemoryStream) + private + FFileHandle: THandle; + FMapping: THandle; + protected + procedure Close; + public + constructor Create(const FileName: string; FileMode: Word = fmOpenRead or fmShareDenyWrite); + destructor Destroy; override; + function Write(const Buffer; Count: Longint): Longint; override; + end; + +{$ENDIF MSWINDOWS} + + TJclMappedTextReaderIndex = (tiNoIndex, tiFull); + + PPAnsiCharArray = ^TPAnsiCharArray; + TPAnsiCharArray = array [0..0] of PAnsiChar; + + TJclAnsiMappedTextReader = class(TPersistent) + private + FContent: PAnsiChar; + FEnd: PAnsiChar; + FIndex: PPAnsiCharArray; + FIndexOption: TJclMappedTextReaderIndex; + FFreeStream: Boolean; + FLastLineNumber: Integer; + FLastPosition: PAnsiChar; + FLineCount: Integer; + FMemoryStream: TCustomMemoryStream; + FPosition: PAnsiChar; + FSize: Integer; + function GetAsString: AnsiString; + function GetEof: Boolean; + function GetChars(Index: Integer): AnsiChar; + function GetLineCount: Integer; + function GetLines(LineNumber: Integer): AnsiString; + function GetPosition: Integer; + function GetPositionFromLine(LineNumber: Integer): Integer; + procedure SetPosition(const Value: Integer); + protected + procedure AssignTo(Dest: TPersistent); override; + procedure CreateIndex; + procedure Init; + function PtrFromLine(LineNumber: Integer): PAnsiChar; + function StringFromPosition(var StartPos: PAnsiChar): AnsiString; + public + constructor Create(MemoryStream: TCustomMemoryStream; FreeStream: Boolean = True; + const AIndexOption: TJclMappedTextReaderIndex = tiNoIndex); overload; + constructor Create(const FileName: TFileName; + const AIndexOption: TJclMappedTextReaderIndex = tiNoIndex); overload; + destructor Destroy; override; + procedure GoBegin; + function Read: AnsiChar; + function ReadLn: AnsiString; + property AsString: AnsiString read GetAsString; + property Chars[Index: Integer]: AnsiChar read GetChars; + property Content: PAnsiChar read FContent; + property Eof: Boolean read GetEof; + property IndexOption: TJclMappedTextReaderIndex read FIndexOption; + property Lines[LineNumber: Integer]: AnsiString read GetLines; + property LineCount: Integer read GetLineCount; + property PositionFromLine[LineNumber: Integer]: Integer read GetPositionFromLine; + property Position: Integer read GetPosition write SetPosition; + property Size: Integer read FSize; + end; + + PPWideCharArray = ^TPWideCharArray; + TPWideCharArray = array [0..0] of PWideChar; + + TJclWideMappedTextReader = class(TPersistent) + private + FContent: PWideChar; + FEnd: PWideChar; + FIndex: PPWideCharArray; + FIndexOption: TJclMappedTextReaderIndex; + FFreeStream: Boolean; + FLastLineNumber: Integer; + FLastPosition: PWideChar; + FLineCount: Integer; + FMemoryStream: TCustomMemoryStream; + FPosition: PWideChar; + FSize: Integer; + function GetAsString: WideString; + function GetEof: Boolean; + function GetChars(Index: Integer): WideChar; + function GetLineCount: Integer; + function GetLines(LineNumber: Integer): WideString; + function GetPosition: Integer; + function GetPositionFromLine(LineNumber: Integer): Integer; + procedure SetPosition(const Value: Integer); + protected + procedure AssignTo(Dest: TPersistent); override; + procedure CreateIndex; + procedure Init; + function PtrFromLine(LineNumber: Integer): PWideChar; + function StringFromPosition(var StartPos: PWideChar): WideString; + public + constructor Create(MemoryStream: TCustomMemoryStream; FreeStream: Boolean = True; + const AIndexOption: TJclMappedTextReaderIndex = tiNoIndex); overload; + constructor Create(const FileName: TFileName; + const AIndexOption: TJclMappedTextReaderIndex = tiNoIndex); overload; + destructor Destroy; override; + procedure GoBegin; + function Read: WideChar; + function ReadLn: WideString; + property AsString: WideString read GetAsString; + property Chars[Index: Integer]: WideChar read GetChars; + property Content: PWideChar read FContent; + property Eof: Boolean read GetEof; + property IndexOption: TJclMappedTextReaderIndex read FIndexOption; + property Lines[LineNumber: Integer]: WideString read GetLines; + property LineCount: Integer read GetLineCount; + property PositionFromLine[LineNumber: Integer]: Integer read GetPositionFromLine; + property Position: Integer read GetPosition write SetPosition; + property Size: Integer read FSize; + end; + +{ TODO : UNTESTED/UNDOCUMENTED } + +type + TJclFileMaskComparator = class(TObject) + private + FFileMask: string; + FExts: array of string; + FNames: array of string; + FWildChars: array of Byte; + FSeparator: Char; + procedure CreateMultiMasks; + function GetCount: Integer; + function GetExts(Index: Integer): string; + function GetMasks(Index: Integer): string; + function GetNames(Index: Integer): string; + procedure SetFileMask(const Value: string); + procedure SetSeparator(const Value: Char); + public + constructor Create; + function Compare(const NameExt: string): Boolean; + property Count: Integer read GetCount; + property Exts[Index: Integer]: string read GetExts; + property FileMask: string read FFileMask write SetFileMask; + property Masks[Index: Integer]: string read GetMasks; + property Names[Index: Integer]: string read GetNames; + property Separator: Char read FSeparator write SetSeparator; + end; + + EJclPathError = class(EJclError); + EJclFileUtilsError = class(EJclError); + {$IFDEF UNIX} + EJclTempFileStreamError = class(EJclFileUtilsError); + {$ENDIF UNIX} + {$IFDEF MSWINDOWS} + EJclTempFileStreamError = class(EJclWin32Error); + EJclFileMappingError = class(EJclWin32Error); + EJclFileMappingViewError = class(EJclWin32Error); + {$ENDIF MSWINDOWS} + +function SamePath(const Path1, Path2: string): Boolean; + +// functions to add/delete paths from a separated list of paths +// on windows the separator is a semi-colon ';' +// on linux the separator is a colon ':' +// add items at the end +procedure PathListAddItems(var List: string; const Items: string); +// add items at the end if they are not present +procedure PathListIncludeItems(var List: string; const Items: string); +// delete multiple items +procedure PathListDelItems(var List: string; const Items: string); +// delete one item +procedure PathListDelItem(var List: string; const Index: Integer); +// return the number of item +function PathListItemCount(const List: string): Integer; +// return the Nth item +function PathListGetItem(const List: string; const Index: Integer): string; +// set the Nth item +procedure PathListSetItem(var List: string; const Index: Integer; const Value: string); +// return the index of an item +function PathListItemIndex(const List, Item: string): Integer; + + +// additional functions to access the commandline parameters of an application + +// returns the name of the command line parameter at position index, which is +// separated by the given separator, if the first character of the name part +// is one of the AllowedPrefixCharacters, this character will be deleted. +function ParamName (Index : Integer; const Separator : string = '='; + const AllowedPrefixCharacters : string = '-/'; TrimName : Boolean = true) : string; +// returns the value of the command line parameter at position index, which is +// separated by the given separator +function ParamValue (Index : Integer; const Separator : string = '='; TrimValue : Boolean = true) : string; overload; +// seaches a command line parameter where the namepart is the searchname +// and returns the value which is which by the given separator. +// CaseSensitive defines the search type. if the first character of the name part +// is one of the AllowedPrefixCharacters, this character will be deleted. +function ParamValue (const SearchName : string; const Separator : string = '='; + CaseSensitive : Boolean = False; + const AllowedPrefixCharacters : string = '-/'; TrimValue : Boolean = true) : string; overload; +// seaches a command line parameter where the namepart is the searchname +// and returns the position index. if no separator is defined, the full paramstr is compared. +// CaseSensitive defines the search type. if the first character of the name part +// is one of the AllowedPrefixCharacters, this character will be deleted. +function ParamPos (const SearchName : string; const Separator : string = '='; + CaseSensitive : Boolean = False; + const AllowedPrefixCharacters : string = '-/'): Integer; + +{$IFDEF UNITVERSIONING} +const + UnitVersioning: TUnitVersionInfo = ( + RCSfile: '$URL$'; + Revision: '$Revision$'; + Date: '$Date$'; + LogPath: 'JCL\source\common'; + Extra: ''; + Data: nil + ); +{$ENDIF UNITVERSIONING} + +implementation + +uses + {$IFDEF HAS_UNITSCOPE} + System.Types, // inlining of TList.Remove + {$IFDEF HAS_UNIT_CHARACTER} + System.Character, + {$ENDIF HAS_UNIT_CHARACTER} + System.Math, + {$IFDEF MSWINDOWS} + Winapi.ShellApi, Winapi.ActiveX, System.Win.ComObj, Winapi.ShlObj, + {$IFNDEF WINSCP}JclShell,{$ENDIF ~WINSCP} JclSysInfo, {$IFNDEF WINSCP}JclSecurity,{$ENDIF ~WINSCP} + {$ENDIF MSWINDOWS} + {$ELSE ~HAS_UNITSCOPE} + {$IFDEF HAS_UNIT_CHARACTER} + Character, + {$ENDIF HAS_UNIT_CHARACTER} + Math, + {$IFDEF MSWINDOWS} + ShellApi, ActiveX, ComObj, ShlObj, + JclShell, JclSysInfo, JclSecurity, + {$ENDIF MSWINDOWS} + {$ENDIF ~HAS_UNITSCOPE} + {$IFNDEF WINSCP}JclDateTime,{$ENDIF ~WINSCP} JclResources, + JclStrings; + +{ Some general notes: + + This unit redeclares some functions from FileCtrl.pas to avoid a dependency on that unit in the + JCL. The problem is that FileCtrl.pas uses some units (eg Forms.pas) which have ridiculous + initialization requirements. They add 4KB (!) to the executable and roughly 1 second of startup. + That initialization is only necessary for GUI applications and is unacceptable for high + performance services or console apps. + + The routines which query files or directories for their attributes deliberately use FindFirst + even though there may be easier ways to get at the required information. This is because FindFirst + is about the only routine which doesn't cause the file's last modification/accessed time to be + changed which is usually an undesired side-effect. } + +{$IFDEF UNIX} +const + ERROR_NO_MORE_FILES = -1; + INVALID_HANDLE_VALUE = THandle(-1); +{$ENDIF UNIX} + +//=== { TJclTempFileStream } ================================================= + +constructor TJclTempFileStream.Create(const Prefix: string); +var + FileHandle: THandle; +begin + FFileName := Prefix; + FileHandle := FileCreateTemp(FFileName); + // (rom) is it really wise to throw an exception before calling inherited? + if FileHandle = INVALID_HANDLE_VALUE then + raise EJclTempFileStreamError.CreateRes(@RsFileStreamCreate); + inherited Create(FileHandle); +end; + +destructor TJclTempFileStream.Destroy; +begin + if THandle(Handle) <> INVALID_HANDLE_VALUE then + FileClose(Handle); + inherited Destroy; +end; + +//=== { TJclFileMappingView } ================================================ + +{$IFDEF MSWINDOWS} + +constructor TJclFileMappingView.Create(const FileMap: TJclCustomFileMapping; + Access, Size: Cardinal; ViewOffset: Int64); +var + BaseAddress: Pointer; + OffsetLow, OffsetHigh: Cardinal; +begin + inherited Create; + if FileMap = nil then + raise EJclFileMappingViewError.CreateRes(@RsViewNeedsMapping); + FFileMapping := FileMap; + // Offset must be a multiple of system memory allocation granularity + RoundToAllocGranularity64(ViewOffset, FFileMapping.RoundViewOffset = rvUp); + I64ToCardinals(ViewOffset, OffsetLow, OffsetHigh); + FOffsetHigh := OffsetHigh; + FOffsetLow := OffsetLow; + BaseAddress := MapViewOfFile(FFileMapping.Handle, Access, FOffsetHigh, FOffsetLow, Size); + if BaseAddress = nil then + raise EJclFileMappingViewError.CreateRes(@RsCreateFileMappingView); + // If we are mapping a file and size = 0 then MapViewOfFile has mapped the entire file. We must + // figure out the size ourselves before we can call SetPointer. Since in case of failure to + // retrieve the size we raise an exception, we also have to explicitly unmap the view which + // otherwise would have been done by the destructor. + if (Size = 0) and (FileMap is TJclFileMapping) then + begin + Size := GetFileSize(TJclFileMapping(FileMap).FFileHandle, nil); + if Size = DWORD(-1) then + begin + UnMapViewOfFile(BaseAddress); + raise EJclFileMappingViewError.CreateRes(@RsFailedToObtainSize); + end; + end; + SetPointer(BaseAddress, Size); + FFileMapping.FViews.Add(Self); +end; + +constructor TJclFileMappingView.CreateAt(FileMap: TJclCustomFileMapping; + Access, Size: Cardinal; ViewOffset: Int64; Address: Pointer); +var + BaseAddress: Pointer; + OffsetLow, OffsetHigh: Cardinal; +begin + inherited Create; + if FileMap = nil then + raise EJclFileMappingViewError.CreateRes(@RsViewNeedsMapping); + FFileMapping := FileMap; + // Offset must be a multiple of system memory allocation granularity + RoundToAllocGranularity64(ViewOffset, FFileMapping.RoundViewOffset = rvUp); + RoundToAllocGranularityPtr(Address, FFileMapping.RoundViewOffset = rvUp); + I64ToCardinals(ViewOffset, OffsetLow, OffsetHigh); + FOffsetHigh := OffsetHigh; + FOffsetLow := OffsetLow; + BaseAddress := MapViewOfFileEx(FFileMapping.Handle, Access, FOffsetHigh, + FOffsetLow, Size, Address); + if BaseAddress = nil then + raise EJclFileMappingViewError.CreateRes(@RsCreateFileMappingView); + // If we are mapping a file and size = 0 then MapViewOfFile has mapped the entire file. We must + // figure out the size ourselves before we can call SetPointer. Since in case of failure to + // retrieve the size we raise an exception, we also have to explicitly unmap the view which + // otherwise would have been done by the destructor. + if (Size = 0) and (FileMap is TJclFileMapping) then + begin + Size := GetFileSize(TJclFileMapping(FileMap).FFileHandle, nil); + if Size = DWORD(-1) then + begin + UnMapViewOfFile(BaseAddress); + raise EJclFileMappingViewError.CreateRes(@RsFailedToObtainSize); + end; + end; + SetPointer(BaseAddress, Size); + FFileMapping.FViews.Add(Self); +end; + +destructor TJclFileMappingView.Destroy; +var + IndexOfSelf: Integer; +begin + if Memory <> nil then + begin + UnMapViewOfFile(Memory); + SetPointer(nil, 0); + end; + if FFileMapping <> nil then + begin + IndexOfSelf := FFileMapping.IndexOf(Self); + if IndexOfSelf <> -1 then + FFileMapping.FViews.Delete(IndexOfSelf); + end; + inherited Destroy; +end; + +function TJclFileMappingView.Flush(const Count: Cardinal): Boolean; +begin + Result := FlushViewOfFile(Memory, Count); +end; + +function TJclFileMappingView.GetIndex: Integer; +begin + Result := FFileMapping.IndexOf(Self); +end; + +function TJclFileMappingView.GetOffset: Int64; +begin + CardinalsToI64(Result, FOffsetLow, FOffsetHigh); +end; + +procedure TJclFileMappingView.LoadFromFile(const FileName: string); +var + Stream: TFileStream; +begin + Stream := TFileStream.Create(Filename, fmOpenRead or fmShareDenyWrite); + try + LoadFromStream(Stream); + finally + FreeAndNil(Stream); + end; +end; + +procedure TJclFileMappingView.LoadFromStream(const Stream: TStream); +begin + if Stream.Size > Size then + raise EJclFileMappingViewError.CreateRes(@RsLoadFromStreamSize); + Stream.Position := 0; + Stream.ReadBuffer(Memory^, Stream.Size); +end; + +function TJclFileMappingView.Write(const Buffer; Count: Integer): Longint; +begin + Result := 0; + if (Size - Position) >= Count then + begin + System.Move(Buffer, Pointer(TJclAddr(Memory) + TJclAddr(Position))^, Count); + Position := Position + Count; + Result := Count; + end; +end; + +//=== { TJclCustomFileMapping } ============================================== + +constructor TJclCustomFileMapping.Create; +begin + inherited Create; + FViews := TList.Create; + FRoundViewOffset := rvDown; +end; + +constructor TJclCustomFileMapping.Open(const Name: string; + const InheritHandle: Boolean; const DesiredAccess: Cardinal); +begin + Create; + InternalOpen(Name, InheritHandle, DesiredAccess); +end; + +destructor TJclCustomFileMapping.Destroy; +begin + ClearViews; + if FHandle <> 0 then + CloseHandle(FHandle); + FreeAndNil(FViews); + inherited Destroy; +end; + +function TJclCustomFileMapping.Add(const Access, Count: Cardinal; const Offset: Int64): Integer; +var + View: TJclFileMappingView; +begin + // The view adds itself to the FViews list + View := TJclFileMappingView.Create(Self, Access, Count, Offset); + Result := View.Index; +end; + +function TJclCustomFileMapping.AddAt(const Access, Count: Cardinal; + const Offset: Int64; const Address: Pointer): Integer; +var + View: TJclFileMappingView; +begin + // The view adds itself to the FViews list + View := TJclFileMappingView.CreateAt(Self, Access, Count, Offset, Address); + Result := View.Index; +end; + +procedure TJclCustomFileMapping.ClearViews; +var + I: Integer; +begin + // Note that the view destructor removes the view object from the FViews list so we must loop + // downwards from count to 0 + for I := FViews.Count - 1 downto 0 do + TJclFileMappingView(FViews[I]).Free; +end; + +procedure TJclCustomFileMapping.Delete(const Index: Integer); +begin + // Note that the view destructor removes itself from FViews + TJclFileMappingView(FViews[Index]).Free; +end; + +function TJclCustomFileMapping.GetCount: Integer; +begin + Result := FViews.Count; +end; + +function TJclCustomFileMapping.GetView(Index: Integer): TJclFileMappingView; +begin + Result := TJclFileMappingView(FViews.Items[index]); +end; + +function TJclCustomFileMapping.IndexOf(const View: TJclFileMappingView): Integer; +begin + Result := FViews.IndexOf(View); +end; + +procedure TJclCustomFileMapping.InternalCreate(const FileHandle: THandle; + const Name: string; const Protect: Cardinal; MaximumSize: Int64; + SecAttr: PSecurityAttributes); +var + MaximumSizeLow, MaximumSizeHigh: Cardinal; +begin + FName := Name; + I64ToCardinals(MaximumSize, MaximumSizeLow, MaximumSizeHigh); + FHandle := CreateFileMapping(FileHandle, SecAttr, Protect, MaximumSizeHigh, + MaximumSizeLow, PChar(Name)); + if FHandle = 0 then + raise EJclFileMappingError.CreateRes(@RsCreateFileMapping); + FExisted := GetLastError = ERROR_ALREADY_EXISTS; +end; + +procedure TJclCustomFileMapping.InternalOpen(const Name: string; + const InheritHandle: Boolean; const DesiredAccess: Cardinal); +begin + FExisted := True; + FName := Name; + FHandle := OpenFileMapping(DesiredAccess, InheritHandle, PChar(Name)); + if FHandle = 0 then + raise EJclFileMappingError.CreateRes(@RsCreateFileMapping); +end; + +//=== { TJclFileMapping } ==================================================== + +constructor TJclFileMapping.Create(const FileName: string; FileMode: Cardinal; + const Name: string; Protect: Cardinal; const MaximumSize: Int64; + SecAttr: PSecurityAttributes); +begin + FFileHandle := INVALID_HANDLE_VALUE; + inherited Create; + FFileHandle := THandle(FileOpen(FileName, FileMode)); + if FFileHandle = INVALID_HANDLE_VALUE then + raise EJclFileMappingError.CreateRes(@RsFileMappingOpenFile); + InternalCreate(FFileHandle, Name, Protect, MaximumSize, SecAttr); +end; + +constructor TJclFileMapping.Create(const FileHandle: THandle; const Name: string; + Protect: Cardinal; const MaximumSize: Int64; SecAttr: PSecurityAttributes); +begin + FFileHandle := INVALID_HANDLE_VALUE; + inherited Create; + if FileHandle = INVALID_HANDLE_VALUE then + raise EJclFileMappingError.CreateRes(@RsFileMappingInvalidHandle); + InternalCreate(FileHandle, Name, Protect, MaximumSize, SecAttr); + // Duplicate the handle into FFileHandle as opposed to assigning it directly. This will cause + // FFileHandle to retrieve a unique copy which is independent of FileHandle. This makes the + // remainder of the class, especially the destructor, easier. The caller will have to close it's + // own copy of the handle explicitly. + DuplicateHandle(GetCurrentProcess, FileHandle, GetCurrentProcess, + @FFileHandle, 0, False, DUPLICATE_SAME_ACCESS); +end; + +destructor TJclFileMapping.Destroy; +begin + if FFileHandle <> INVALID_HANDLE_VALUE then + CloseHandle(FFileHandle); + inherited Destroy; +end; + +//=== { TJclSwapFileMapping } ================================================ + +constructor TJclSwapFileMapping.Create(const Name: string; Protect: Cardinal; + const MaximumSize: Int64; SecAttr: PSecurityAttributes); +begin + inherited Create; + InternalCreate(INVALID_HANDLE_VALUE, Name, Protect, MaximumSize, SecAttr); +end; + +//=== { TJclFileMappingStream } ============================================== + +constructor TJclFileMappingStream.Create(const FileName: string; FileMode: Word); +var + Protect, Access, Size: DWORD; + BaseAddress: Pointer; +begin + inherited Create; + FFileHandle := THandle(FileOpen(FileName, FileMode)); + if FFileHandle = INVALID_HANDLE_VALUE then + RaiseLastOSError; + if (FileMode and $0F) = fmOpenReadWrite then + begin + Protect := PAGE_WRITECOPY; + Access := FILE_MAP_COPY; + end + else + begin + Protect := PAGE_READONLY; + Access := FILE_MAP_READ; + end; + FMapping := CreateFileMapping(FFileHandle, nil, Protect, 0, 0, nil); + if FMapping = 0 then + begin + Close; + raise EJclFileMappingError.CreateRes(@RsCreateFileMapping); + end; + BaseAddress := MapViewOfFile(FMapping, Access, 0, 0, 0); + if BaseAddress = nil then + begin + Close; + raise EJclFileMappingViewError.CreateRes(@RsCreateFileMappingView); + end; + Size := GetFileSize(FFileHandle, nil); + if Size = DWORD(-1) then + begin + UnMapViewOfFile(BaseAddress); + Close; + raise EJclFileMappingViewError.CreateRes(@RsFailedToObtainSize); + end; + SetPointer(BaseAddress, Size); +end; + +destructor TJclFileMappingStream.Destroy; +begin + Close; + inherited Destroy; +end; + +procedure TJclFileMappingStream.Close; +begin + if Memory <> nil then + begin + UnMapViewOfFile(Memory); + SetPointer(nil, 0); + end; + if FMapping <> 0 then + begin + CloseHandle(FMapping); + FMapping := 0; + end; + if FFileHandle <> INVALID_HANDLE_VALUE then + begin + FileClose(FFileHandle); + FFileHandle := INVALID_HANDLE_VALUE; + end; +end; + +function TJclFileMappingStream.Write(const Buffer; Count: Integer): Longint; +begin + Result := 0; + if (Size - Position) >= Count then + begin + System.Move(Buffer, Pointer(TJclAddr(Memory) + TJclAddr(Position))^, Count); + Position := Position + Count; + Result := Count; + end; +end; + +{$ENDIF MSWINDOWS} + +//=== { TJclAnsiMappedTextReader } =========================================== + +constructor TJclAnsiMappedTextReader.Create(MemoryStream: TCustomMemoryStream; FreeStream: Boolean; + const AIndexOption: TJclMappedTextReaderIndex); +begin + inherited Create; + FMemoryStream := MemoryStream; + FFreeStream := FreeStream; + FIndexOption := AIndexOption; + Init; +end; + +constructor TJclAnsiMappedTextReader.Create(const FileName: TFileName; + const AIndexOption: TJclMappedTextReaderIndex); +begin + inherited Create; + {$IFDEF MSWINDOWS} + FMemoryStream := TJclFileMappingStream.Create(FileName); + {$ELSE ~ MSWINDOWS} + FMemoryStream := TMemoryStream.Create; + TMemoryStream(FMemoryStream).LoadFromFile(FileName); + {$ENDIF ~ MSWINDOWS} + FFreeStream := True; + FIndexOption := AIndexOption; + Init; +end; + +destructor TJclAnsiMappedTextReader.Destroy; +begin + if FFreeStream then + FMemoryStream.Free; + FreeMem(FIndex); + inherited Destroy; +end; + +procedure TJclAnsiMappedTextReader.AssignTo(Dest: TPersistent); +begin + if Dest is TStrings then + begin + GoBegin; + TStrings(Dest).BeginUpdate; + try + while not Eof do + TStrings(Dest).Add(string(ReadLn)); + finally + TStrings(Dest).EndUpdate; + end; + end + else + inherited AssignTo(Dest); +end; + +procedure TJclAnsiMappedTextReader.CreateIndex; +var + P, LastLineStart: PAnsiChar; + I: Integer; +begin + {$RANGECHECKS OFF} + P := FContent; + I := 0; + LastLineStart := P; + while P < FEnd do + begin + // CRLF, CR, LF and LFCR are seen as valid sets of chars for EOL marker + if CharIsReturn(Char(P^)) then + begin + if I and $FFFF = 0 then + ReallocMem(FIndex, (I + $10000) * SizeOf(Pointer)); + FIndex[I] := LastLineStart; + Inc(I); + + case P^ of + NativeLineFeed: + begin + Inc(P); + if (P < FEnd) and (P^ = NativeCarriageReturn) then + Inc(P); + end; + NativeCarriageReturn: + begin + Inc(P); + if (P < FEnd) and (P^ = NativeLineFeed) then + Inc(P); + end; + end; + LastLineStart := P; + end + else + Inc(P); + end; + if P > LastLineStart then + begin + ReallocMem(FIndex, (I + 1) * SizeOf(Pointer)); + FIndex[I] := LastLineStart; + Inc(I); + end + else + ReallocMem(FIndex, I * SizeOf(Pointer)); + FLineCount := I; + {$IFDEF RANGECHECKS_ON} + {$RANGECHECKS ON} + {$ENDIF RANGECHECKS_ON} +end; + +function TJclAnsiMappedTextReader.GetEof: Boolean; +begin + Result := FPosition >= FEnd; +end; + +function TJclAnsiMappedTextReader.GetAsString: AnsiString; +begin + SetString(Result, Content, Size); +end; + +function TJclAnsiMappedTextReader.GetChars(Index: Integer): AnsiChar; +begin + if (Index < 0) or (Index >= Size) then + raise EJclError.CreateRes(@RsFileIndexOutOfRange); + Result := AnsiChar(PByte(FContent + Index)^); +end; + +function TJclAnsiMappedTextReader.GetLineCount: Integer; +var + P: PAnsiChar; +begin + if FLineCount = -1 then + begin + FLineCount := 0; + if FContent < FEnd then + begin + P := FContent; + while P < FEnd do + begin + case P^ of + NativeLineFeed: + begin + Inc(FLineCount); + Inc(P); + if (P < FEnd) and (P^ = NativeCarriageReturn) then + Inc(P); + end; + NativeCarriageReturn: + begin + Inc(FLineCount); + Inc(P); + if (P < FEnd) and (P^ = NativeLineFeed) then + Inc(P); + end; + else + Inc(P); + end; + end; + if (P = FEnd) and (P > FContent) and not CharIsReturn(Char((P-1)^)) then + Inc(FLineCount); + end; + end; + + Result := FLineCount; +end; + +function TJclAnsiMappedTextReader.GetLines(LineNumber: Integer): AnsiString; +var + P: PAnsiChar; +begin + P := PtrFromLine(LineNumber); + Result := StringFromPosition(P); +end; + +function TJclAnsiMappedTextReader.GetPosition: Integer; +begin + Result := FPosition - FContent; +end; + +procedure TJclAnsiMappedTextReader.GoBegin; +begin + Position := 0; +end; + +procedure TJclAnsiMappedTextReader.Init; +begin + FContent := FMemoryStream.Memory; + FSize := FMemoryStream.Size; + FEnd := FContent + FSize; + FPosition := FContent; + FLineCount := -1; + FLastLineNumber := 0; + FLastPosition := FContent; + if IndexOption = tiFull then + CreateIndex; +end; + +function TJclAnsiMappedTextReader.GetPositionFromLine(LineNumber: Integer): Integer; +var + P: PAnsiChar; +begin + P := PtrFromLine(LineNumber); + if P = nil then + Result := -1 + else + Result := P - FContent; +end; + +function TJclAnsiMappedTextReader.PtrFromLine(LineNumber: Integer): PAnsiChar; +var + LineOffset: Integer; +begin + Result := nil; + {$RANGECHECKS OFF} + if (IndexOption <> tiNoIndex) and (LineNumber < FLineCount) and (FIndex[LineNumber] <> nil) then + Result := FIndex[LineNumber] + {$IFDEF RANGECHECKS_ON} + {$RANGECHECKS ON} + {$ENDIF RANGECHECKS_ON} + else + begin + LineOffset := LineNumber - FLastLineNumber; + if (FLineCount <> -1) and (LineNumber > 0) then + begin + if -LineOffset > LineNumber then + begin + FLastLineNumber := 0; + FLastPosition := FContent; + LineOffset := LineNumber; + end + else + if LineOffset > FLineCount - LineNumber then + begin + FLastLineNumber := FLineCount; + FLastPosition := FEnd; + LineOffset := LineNumber - FLineCount; + end; + end; + if LineNumber <= 0 then + Result := FContent + else + if LineOffset = 0 then + Result := FLastPosition + else + if LineOffset > 0 then + begin + Result := FLastPosition; + while (Result < FEnd) and (LineOffset > 0) do + begin + case Result^ of + NativeLineFeed: + begin + Dec(LineOffset); + Inc(Result); + if (Result < FEnd) and (Result^ = NativeCarriageReturn) then + Inc(Result); + end; + NativeCarriageReturn: + begin + Dec(LineOffset); + Inc(Result); + if (Result < FEnd) and (Result^ = NativeLineFeed) then + Inc(Result); + end; + else + Inc(Result); + end; + end; + end + else + if LineOffset < 0 then + begin + Result := FLastPosition; + while (Result > FContent) and (LineOffset < 1) do + begin + Dec(Result); + case Result^ of + NativeLineFeed: + begin + Inc(LineOffset); + if LineOffset >= 1 then + Inc(Result) + else + if (Result > FContent) and ((Result-1)^ = NativeCarriageReturn) then + Dec(Result); + end; + NativeCarriageReturn: + begin + Inc(LineOffset); + if LineOffset >= 1 then + Inc(Result) + else + if (Result > FContent) and ((Result-1)^ = NativeLineFeed) then + Dec(Result); + end; + end; + end; + end; + FLastLineNumber := LineNumber; + FLastPosition := Result; + end; +end; + +function TJclAnsiMappedTextReader.Read: AnsiChar; +begin + if FPosition >= FEnd then + Result := #0 + else + begin + Result := FPosition^; + Inc(FPosition); + end; +end; + +function TJclAnsiMappedTextReader.ReadLn: AnsiString; +begin + Result := StringFromPosition(FPosition); +end; + +procedure TJclAnsiMappedTextReader.SetPosition(const Value: Integer); +begin + FPosition := FContent + Value; +end; + +function TJclAnsiMappedTextReader.StringFromPosition(var StartPos: PAnsiChar): AnsiString; +var + P: PAnsiChar; +begin + if (StartPos = nil) or (StartPos >= FEnd) then + Result := '' + else + begin + P := StartPos; + while (P < FEnd) and (not CharIsReturn(Char(P^))) do + Inc(P); + SetString(Result, StartPos, P - StartPos); + if P < FEnd then + begin + case P^ of + NativeLineFeed: + begin + Inc(P); + if (P < FEnd) and (P^ = NativeCarriageReturn) then + Inc(P); + end; + NativeCarriageReturn: + begin + Inc(P); + if (P < FEnd) and (P^ = NativeLineFeed) then + Inc(P); + end; + end; + end; + StartPos := P; + end; +end; + +//=== { TJclWideMappedTextReader } =========================================== + +constructor TJclWideMappedTextReader.Create(MemoryStream: TCustomMemoryStream; FreeStream: Boolean; + const AIndexOption: TJclMappedTextReaderIndex); +begin + inherited Create; + FMemoryStream := MemoryStream; + FFreeStream := FreeStream; + FIndexOption := AIndexOption; + Init; +end; + +constructor TJclWideMappedTextReader.Create(const FileName: TFileName; + const AIndexOption: TJclMappedTextReaderIndex); +begin + inherited Create; + {$IFDEF MSWINDOWS} + FMemoryStream := TJclFileMappingStream.Create(FileName); + {$ELSE ~ MSWINDOWS} + FMemoryStream := TMemoryStream.Create; + TMemoryStream(FMemoryStream).LoadFromFile(FileName); + {$ENDIF ~ MSWINDOWS} + FFreeStream := True; + FIndexOption := AIndexOption; + Init; +end; + +destructor TJclWideMappedTextReader.Destroy; +begin + if FFreeStream then + FMemoryStream.Free; + FreeMem(FIndex); + inherited Destroy; +end; + +procedure TJclWideMappedTextReader.AssignTo(Dest: TPersistent); +begin + if Dest is TStrings then + begin + GoBegin; + TStrings(Dest).BeginUpdate; + try + while not Eof do + TStrings(Dest).Add(string(ReadLn)); + finally + TStrings(Dest).EndUpdate; + end; + end + else + inherited AssignTo(Dest); +end; + +procedure TJclWideMappedTextReader.CreateIndex; +var + P, LastLineStart: PWideChar; + I: Integer; +begin + {$RANGECHECKS OFF} + P := FContent; + I := 0; + LastLineStart := P; + while P < FEnd do + begin + // CRLF, CR, LF and LFCR are seen as valid sets of chars for EOL marker + if CharIsReturn(Char(P^)) then + begin + if I and $FFFF = 0 then + ReallocMem(FIndex, (I + $10000) * SizeOf(Pointer)); + FIndex[I] := LastLineStart; + Inc(I); + + case P^ of + NativeLineFeed: + begin + Inc(P); + if (P < FEnd) and (P^ = NativeCarriageReturn) then + Inc(P); + end; + NativeCarriageReturn: + begin + Inc(P); + if (P < FEnd) and (P^ = NativeLineFeed) then + Inc(P); + end; + end; + LastLineStart := P; + end + else + Inc(P); + end; + if P > LastLineStart then + begin + ReallocMem(FIndex, (I + 1) * SizeOf(Pointer)); + FIndex[I] := LastLineStart; + Inc(I); + end + else + ReallocMem(FIndex, I * SizeOf(Pointer)); + FLineCount := I; + {$IFDEF RANGECHECKS_ON} + {$RANGECHECKS ON} + {$ENDIF RANGECHECKS_ON} +end; + +function TJclWideMappedTextReader.GetEof: Boolean; +begin + Result := FPosition >= FEnd; +end; + +function TJclWideMappedTextReader.GetAsString: WideString; +begin + SetString(Result, Content, Size); +end; + +function TJclWideMappedTextReader.GetChars(Index: Integer): WideChar; +begin + if (Index < 0) or (Index >= Size) then + raise EJclError.CreateRes(@RsFileIndexOutOfRange); + Result := WideChar(PByte(FContent + Index)^); +end; + +function TJclWideMappedTextReader.GetLineCount: Integer; +var + P: PWideChar; +begin + if FLineCount = -1 then + begin + FLineCount := 0; + if FContent < FEnd then + begin + P := FContent; + while P < FEnd do + begin + case P^ of + NativeLineFeed: + begin + Inc(FLineCount); + Inc(P); + if (P < FEnd) and (P^ = NativeCarriageReturn) then + Inc(P); + end; + NativeCarriageReturn: + begin + Inc(FLineCount); + Inc(P); + if (P < FEnd) and (P^ = NativeLineFeed) then + Inc(P); + end; + else + Inc(P); + end; + end; + if (P = FEnd) and (P > FContent) and not CharIsReturn(Char((P-1)^)) then + Inc(FLineCount); + end; + end; + + Result := FLineCount; +end; + +function TJclWideMappedTextReader.GetLines(LineNumber: Integer): WideString; +var + P: PWideChar; +begin + P := PtrFromLine(LineNumber); + Result := StringFromPosition(P); +end; + +function TJclWideMappedTextReader.GetPosition: Integer; +begin + Result := FPosition - FContent; +end; + +procedure TJclWideMappedTextReader.GoBegin; +begin + Position := 0; +end; + +procedure TJclWideMappedTextReader.Init; +begin + FContent := FMemoryStream.Memory; + FSize := FMemoryStream.Size; + FEnd := FContent + FSize; + FPosition := FContent; + FLineCount := -1; + FLastLineNumber := 0; + FLastPosition := FContent; + if IndexOption = tiFull then + CreateIndex; +end; + +function TJclWideMappedTextReader.GetPositionFromLine(LineNumber: Integer): Integer; +var + P: PWideChar; +begin + P := PtrFromLine(LineNumber); + if P = nil then + Result := -1 + else + Result := P - FContent; +end; + +function TJclWideMappedTextReader.PtrFromLine(LineNumber: Integer): PWideChar; +var + LineOffset: Integer; +begin + Result := nil; + {$RANGECHECKS OFF} + if (IndexOption <> tiNoIndex) and (LineNumber < FLineCount) and (FIndex[LineNumber] <> nil) then + Result := FIndex[LineNumber] + {$IFDEF RANGECHECKS_ON} + {$RANGECHECKS ON} + {$ENDIF RANGECHECKS_ON} + else + begin + LineOffset := LineNumber - FLastLineNumber; + if (FLineCount <> -1) and (LineNumber > 0) then + begin + if -LineOffset > LineNumber then + begin + FLastLineNumber := 0; + FLastPosition := FContent; + LineOffset := LineNumber; + end + else + if LineOffset > FLineCount - LineNumber then + begin + FLastLineNumber := FLineCount; + FLastPosition := FEnd; + LineOffset := LineNumber - FLineCount; + end; + end; + if LineNumber <= 0 then + Result := FContent + else + if LineOffset = 0 then + Result := FLastPosition + else + if LineOffset > 0 then + begin + Result := FLastPosition; + while (Result < FEnd) and (LineOffset > 0) do + begin + case Result^ of + NativeLineFeed: + begin + Dec(LineOffset); + Inc(Result); + if (Result < FEnd) and (Result^ = NativeCarriageReturn) then + Inc(Result); + end; + NativeCarriageReturn: + begin + Dec(LineOffset); + Inc(Result); + if (Result < FEnd) and (Result^ = NativeLineFeed) then + Inc(Result); + end; + else + Inc(Result); + end; + end; + end + else + if LineOffset < 0 then + begin + Result := FLastPosition; + while (Result > FContent) and (LineOffset < 1) do + begin + Dec(Result); + case Result^ of + NativeLineFeed: + begin + Inc(LineOffset); + if LineOffset >= 1 then + Inc(Result) + else + if (Result > FContent) and ((Result-1)^ = NativeCarriageReturn) then + Dec(Result); + end; + NativeCarriageReturn: + begin + Inc(LineOffset); + if LineOffset >= 1 then + Inc(Result) + else + if (Result > FContent) and ((Result-1)^ = NativeLineFeed) then + Dec(Result); + end; + end; + end; + end; + FLastLineNumber := LineNumber; + FLastPosition := Result; + end; +end; + +function TJclWideMappedTextReader.Read: WideChar; +begin + if FPosition >= FEnd then + Result := #0 + else + begin + Result := FPosition^; + Inc(FPosition); + end; +end; + +function TJclWideMappedTextReader.ReadLn: WideString; +begin + Result := StringFromPosition(FPosition); +end; + +procedure TJclWideMappedTextReader.SetPosition(const Value: Integer); +begin + FPosition := FContent + Value; +end; + +function TJclWideMappedTextReader.StringFromPosition(var StartPos: PWideChar): WideString; +var + P: PWideChar; +begin + if (StartPos = nil) or (StartPos >= FEnd) then + Result := '' + else + begin + P := StartPos; + while (P < FEnd) and (not CharIsReturn(Char(P^))) do + Inc(P); + SetString(Result, StartPos, P - StartPos); + if P < FEnd then + begin + case P^ of + NativeLineFeed: + begin + Inc(P); + if (P < FEnd) and (P^ = NativeCarriageReturn) then + Inc(P); + end; + NativeCarriageReturn: + begin + Inc(P); + if (P < FEnd) and (P^ = NativeLineFeed) then + Inc(P); + end; + end; + end; + StartPos := P; + end; +end; + +function CharIsDriveLetter(const C: Char): Boolean; +begin + case C of + 'a'..'z', + 'A'..'Z': + Result := True; + else + Result := False; + end; +end; + +//=== Path manipulation ====================================================== + +function PathAddSeparator(const Path: string): string; +begin + Result := Path; + if (Path = '') or (Path[Length(Path)] <> DirDelimiter) then + Result := Path + DirDelimiter; +end; + +function PathAddExtension(const Path, Extension: string): string; +begin + Result := Path; + // (obones) Extension may not contain the leading dot while ExtractFileExt + // always returns it. Hence the need to use StrEnsurePrefix for the SameText + // test to return an accurate value. + if (Path <> '') and (Extension <> '') and + not SameText(ExtractFileExt(Path), StrEnsurePrefix('.', Extension)) then + begin + if Path[Length(Path)] = '.' then + Delete(Result, Length(Path), 1); + if Extension[1] = '.' then + Result := Result + Extension + else + Result := Result + '.' + Extension; + end; +end; + +function PathAppend(const Path, Append: string): string; +var + PathLength: Integer; + B1, B2: Boolean; +begin + if Append = '' then + Result := Path + else + begin + PathLength := Length(Path); + if PathLength = 0 then + Result := Append + else + begin + // The following code may look a bit complex but all it does is add Append to Path ensuring + // that there is one and only one path separator character between them + B1 := Path[PathLength] = DirDelimiter; + B2 := Append[1] = DirDelimiter; + if B1 and B2 then + Result := Copy(Path, 1, PathLength - 1) + Append + else + begin + if not (B1 or B2) then + Result := Path + DirDelimiter + Append + else + Result := Path + Append; + end; + end; + end; +end; + +function PathBuildRoot(const Drive: Byte): string; +begin + {$IFDEF UNIX} + Result := DirDelimiter; + {$ENDIF UNIX} + {$IFDEF MSWINDOWS} + // Remember, Win32 only allows 'a' to 'z' as drive letters (mapped to 0..25) + if Drive < 26 then + Result := Char(Drive + 65) + ':\' + else + raise EJclPathError.CreateResFmt(@RsPathInvalidDrive, [IntToStr(Drive)]); + {$ENDIF MSWINDOWS} +end; + +function PathCanonicalize(const Path: string): string; +var + List: TStringList; + S: string; + I, K: Integer; + IsAbsolute: Boolean; +begin + I := Pos(':', Path); // for Windows' sake + K := Pos(DirDelimiter, Path); + IsAbsolute := K - I = 1; + if IsAbsolute then begin + if Copy(Path, 1, Length(PathUncPrefix)) = PathUncPrefix then // UNC path + K := 2; + end else + K := I; + if K = 0 then + S := Path + else + S := Copy(Path, K + 1, Length(Path)); + List := TStringList.Create; + try + StrIToStrings(S, DirDelimiter, List, True); + I := 0; + while I < List.Count do + begin + if List[I] = '.' then + List.Delete(I) + else + if (IsAbsolute or (I > 0) and not (List[I-1] = '..')) and (List[I] = '..') then + begin + List.Delete(I); + if I > 0 then + begin + Dec(I); + List.Delete(I); + end; + end + else Inc(I); + end; + Result := StringsToStr(List, DirDelimiter, True); + finally + List.Free; + end; + if K > 0 then + Result := Copy(Path, 1, K) + Result + else + if Result = '' then + Result := '.'; +end; + +function PathCommonPrefix(const Path1, Path2: string): Integer; +var + Index1, Index2: Integer; + LastSeparator, LenS1: Integer; + S1, S2: string; +begin + Result := 0; + if (Path1 <> '') and (Path2 <> '') then + begin + // Initialize P1 to the shortest of the two paths so that the actual comparison loop below can + // use the terminating #0 of that string to terminate the loop. + if Length(Path1) <= Length(Path2) then + begin + S1 := Path1; + S2 := Path2; + end + else + begin + S1 := Path2; + S2 := Path1; + end; + Index1 := 1; + Index2 := 1; + LenS1 := Length(S1); + LastSeparator := 0; + while (S1[Index1] = S2[Index2]) and (Index1 <= LenS1) do + begin + Inc(Result); + if (S1[Index1] = DirDelimiter) or (S1[Index1] = ':') then + LastSeparator := Result; + Inc(Index1); + Inc(Index2); + end; + if (LastSeparator < Result) and (Index1 <= LenS1) then + Result := LastSeparator; + end; +end; + +{$IFDEF MSWINDOWS} +function PathCompactPath(const DC: HDC; const Path: string; + const Width: Integer; CmpFmt: TCompactPath): string; +const + Compacts: array [TCompactPath] of Cardinal = (DT_PATH_ELLIPSIS, DT_END_ELLIPSIS); +var + TextRect: TRect; + Fmt: Cardinal; +begin + Result := ''; + if (DC <> 0) and (Path <> '') and (Width > 0) then + begin + { Here's a note from the Platform SDK to explain the + 5 in the call below: + "If dwDTFormat includes DT_MODIFYSTRING, the function could add up to four additional characters + to this string. The buffer containing the string should be large enough to accommodate these + extra characters." } + SetString(Result, PChar(Path), Length(Path) + 4); + TextRect := Rect(0, 0, Width, 255); + Fmt := DT_MODIFYSTRING or DT_CALCRECT or Compacts[CmpFmt]; + if DrawTextEx(DC, PChar(Result), -1, TextRect, Fmt, nil) <> 0 then + StrResetLength(Result) + else + Result := ''; // in case of error + end; +end; +{$ENDIF MSWINDOWS} + +procedure PathExtractElements(const Source: string; var Drive, Path, FileName, Ext: string); +begin + Drive := ExtractFileDrive(Source); + Path := ExtractFilePath(Source); + // Path includes drive so remove that + if Drive <> '' then + Delete(Path, 1, Length(Drive)); + // add/remove separators + Drive := PathAddSeparator(Drive); + Path := PathRemoveSeparator(Path); + if (Path <> '') and (Path[1] = DirDelimiter) then + Delete(Path, 1, 1); + // and extract the remaining elements + FileName := PathExtractFileNameNoExt(Source); + Ext := ExtractFileExt(Source); +end; + +function PathExtractFileDirFixed(const S: string): string; +begin + Result := PathAddSeparator(ExtractFileDir(S)); +end; + +function PathExtractFileNameNoExt(const Path: string): string; +begin + Result := PathRemoveExtension(ExtractFileName(Path)); +end; + +function PathExtractPathDepth(const Path: string; Depth: Integer): string; +var + List: TStringList; + LocalPath: string; + I: Integer; +begin + List := TStringList.Create; + try + if IsDirectory(Path) then + LocalPath := Path + else + LocalPath := ExtractFilePath(Path); + StrIToStrings(LocalPath, DirDelimiter, List, True); + I := Depth + 1; + if PathIsUNC(LocalPath) then + I := I + 2; + while I < List.Count do + List.Delete(I); + Result := PathAddSeparator(StringsToStr(List, DirDelimiter, True)); + finally + List.Free; + end; +end; + +// Notes: maybe this function should first apply PathCanonicalize() ? + +function PathGetDepth(const Path: string): Integer; +var + List: TStringList; + LocalPath: string; + I, Start: Integer; +begin + Result := 0; + List := TStringList.Create; + try + if IsDirectory(Path) then + LocalPath := Path + else + LocalPath := ExtractFilePath(Path); + StrIToStrings(LocalPath, DirDelimiter, List, False); + if PathIsUNC(LocalPath) then + Start := 1 + else + Start := 0; + for I := Start to List.Count - 1 do + begin + if Pos(':', List[I]) = 0 then + Inc(Result); + end; + finally + List.Free; + end; +end; + +{$IFDEF MSWINDOWS} + +function ShellGetLongPathName(const Path: string): string; +{$IFDEF FPC} +// As of 2004-10-17, FPC's ShlObj unit is just a dummy +begin + Result := Path; +end; +{$ElSE ~FPC} +var + PIDL: PItemIDList; + Desktop: IShellFolder; + {$IFNDEF SUPPORTS_UNICODE} + AnsiName: string; + WideName: array [0..MAX_PATH] of WideChar; + {$ENDIF ~SUPPORTS_UNICODE} + Eaten, Attr: ULONG; // both unused but API requires them (incorrect translation) +begin + Result := Path; + if Path <> '' then + begin + if Succeeded(SHGetDesktopFolder(Desktop)) then + begin + {$IFDEF SUPPORTS_UNICODE} + if Succeeded(Desktop.ParseDisplayName(0, nil, PChar(Path), Eaten, PIDL, Attr)) then + try + SetLength(Result, MAX_PATH); + if SHGetPathFromIDList(PIDL, PChar(Result)) then + StrResetLength(Result); + finally + CoTaskMemFree(PIDL); + end; + {$ELSE ~SUPPORTS_UNICODE} + MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, PAnsiChar(Path), -1, WideName, MAX_PATH); + if Succeeded(Desktop.ParseDisplayName(0, nil, WideName, Eaten, PIDL, Attr)) then + try + SetLength(AnsiName, MAX_PATH); + if SHGetPathFromIDList(PIDL, PChar(AnsiName)) then + StrResetLength(AnsiName); + Result := AnsiName; + finally + CoTaskMemFree(PIDL); + end; + {$ENDIF ~SUPPORTS_UNICODE} + end; + end; +end; +{$ENDIF ~FPC} + +{ TODO : Move RTDL code over to JclWin32 when JclWin32 gets overhauled. } +var + _Kernel32Handle: TModuleHandle = INVALID_MODULEHANDLE_VALUE; + _GetLongPathName: function (lpszShortPath: PChar; lpszLongPath: PChar; + cchBuffer: DWORD): DWORD; stdcall; + +function Kernel32Handle: HMODULE; +begin + JclSysUtils.LoadModule(_Kernel32Handle, kernel32); + Result := _Kernel32Handle; +end; + +function RtdlGetLongPathName(const Path: string): string; +begin + Result := Path; + if not Assigned(_GetLongPathName) then + _GetLongPathName := GetModuleSymbol(Kernel32Handle, 'GetLongPathName' + AWSuffix); + if not Assigned(_GetLongPathName) then + Result := ShellGetLongPathName(Path) + else + begin + SetLength(Result, MAX_PATH); + SetLength(Result, _GetLongPathName(PChar(Path), PChar(Result), MAX_PATH)); + end; +end; + +function PathGetLongName(const Path: string): string; +begin + if Pos('::', Path) > 0 then // Path contains '::{}' + Result := ShellGetLongPathName(Path) + else + Result := RtdlGetLongPathName(Path); + + if Result = '' then + Result := Path; +end; + +function PathGetShortName(const Path: string): string; +var + Required: Integer; +begin + Result := Path; + Required := GetShortPathName(PChar(Path), nil, 0); + if Required <> 0 then + begin + SetLength(Result, Required); + Required := GetShortPathName(PChar(Path), PChar(Result), Required); + if (Required <> 0) and (Required = Length(Result) - 1) then + SetLength(Result, Required) + else + Result := Path; + end; +end; + +{$ENDIF MSWINDOWS} + +function PathGetRelativePath(Origin, Destination: string): string; +var + {$IFDEF MSWINDOWS} + OrigDrive: string; + DestDrive: string; + {$ENDIF MSWINDOWS} + OrigList: TStringList; + DestList: TStringList; + DiffIndex: Integer; + I: Integer; + + function StartsFromRoot(const Path: string): Boolean; + {$IFDEF MSWINDOWS} + var + I: Integer; + begin + I := Length(ExtractFileDrive(Path)); + Result := (Length(Path) > I) and (Path[I + 1] = DirDelimiter); + end; + {$ELSE ~MSWINDOWS} + begin + Result := Pos(DirDelimiter, Path) = 1; + end; + {$ENDIF ~MSWINDOWS} + + function Equal(const Path1, Path2: string): Boolean; + begin + {$IFDEF MSWINDOWS} // case insensitive + Result := StrSame(Path1, Path2); + {$ELSE ~MSWINDOWS} // case sensitive + Result := Path1 = Path2; + {$ENDIF ~MSWINDOWS} + end; + +begin + Origin := PathCanonicalize(Origin); + Destination := PathCanonicalize(Destination); + {$IFDEF MSWINDOWS} + OrigDrive := ExtractFileDrive(Origin); + DestDrive := ExtractFileDrive(Destination); + {$ENDIF MSWINDOWS} + if Equal(Origin, Destination) or (Destination = '') then + Result := '.' + else + if Origin = '' then + Result := Destination + else + {$IFDEF MSWINDOWS} + if (DestDrive <> '') and ((OrigDrive = '') or ((OrigDrive <> '') and not Equal(OrigDrive, DestDrive))) then + Result := Destination + else + if (OrigDrive <> '') and (Pos(DirDelimiter, Destination) = 1) + and not Equal(PathUncPrefix,Copy(Destination,1,Length(PathUncPrefix))) then + Result := OrigDrive + Destination // prepend drive part from Origin + else + {$ENDIF MSWINDOWS} + if StartsFromRoot(Origin) and not StartsFromRoot(Destination) then + Result := StrEnsureSuffix(DirDelimiter, Origin) + + StrEnsureNoPrefix(DirDelimiter, Destination) + else + begin + // create a list of paths as separate strings + OrigList := TStringList.Create; + DestList := TStringList.Create; + try + // NOTE: DO NOT USE DELIMITER AND DELIMITEDTEXT FROM + // TSTRINGS, THEY WILL SPLIT PATHS WITH SPACES !!!! + StrToStrings(Origin, DirDelimiter, OrigList); + StrToStrings(Destination, DirDelimiter, DestList); + begin + // find the first directory that is not the same + DiffIndex := OrigList.Count; + if DestList.Count < DiffIndex then + DiffIndex := DestList.Count; + for I := 0 to DiffIndex - 1 do + if not Equal(OrigList[I], DestList[I]) then + begin + DiffIndex := I; + Break; + end; + Result := StrRepeat('..' + DirDelimiter, OrigList.Count - DiffIndex); + Result := PathRemoveSeparator(Result); + for I := DiffIndex to DestList.Count - 1 do + begin + if Result <> '' then + Result := Result + DirDelimiter; + Result := Result + DestList[i]; + end; + end; + finally + DestList.Free; + OrigList.Free; + end; + end; +end; + +function PathGetTempPath: string; +{$IFDEF MSWINDOWS} +var + BufSize: Cardinal; +begin + BufSize := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.GetTempPath(0, nil); + SetLength(Result, BufSize); + { TODO : Check length (-1 or not) } + {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.GetTempPath(BufSize, PChar(Result)); + StrResetLength(Result); +end; +{$ENDIF MSWINDOWS} +{$IFDEF UNIX} +begin + Result := GetEnvironmentVariable('TMPDIR'); +end; +{$ENDIF UNIX} + +function PathIsAbsolute(const Path: string): Boolean; +{$IFDEF MSWINDOWS} +var + I: Integer; +{$ENDIF MSWINDOWS} +begin + Result := False; + if Path <> '' then + begin + {$IFDEF UNIX} + Result := (Path[1] = DirDelimiter); + {$ENDIF UNIX} + {$IFDEF MSWINDOWS} + if not PathIsUnc(Path) then + begin + I := 0; + if PathIsDiskDevice(Path) then + I := Length(PathDevicePrefix); + Result := (Length(Path) > I + 2) and CharIsDriveLetter(Path[I + 1]) and + (Path[I + 2] = ':') and (Path[I + 3] = DirDelimiter); + end + else + Result := True; + {$ENDIF MSWINDOWS} + end; +end; + +function PathIsChild(const Path, Base: string): Boolean; +var + L: Integer; + B, P: string; +begin + Result := False; + B := PathRemoveSeparator(Base); + P := PathRemoveSeparator(Path); + // an empty path or one that's not longer than base cannot be a subdirectory + L := Length(B); + if (P = '') or (L >= Length(P)) then + Exit; + {$IFDEF MSWINDOWS} + Result := AnsiSameText(StrLeft(P, L), B) and (P[L+1] = DirDelimiter); + {$ENDIF MSWINDOWS} + {$IFDEF UNIX} + Result := AnsiSameStr(StrLeft(P, L), B) and (P[L+1] = DirDelimiter); + {$ENDIF UNIX} +end; + +function PathIsEqualOrChild(const Path, Base: string): Boolean; +var + L: Integer; + B, P: string; +begin + B := PathRemoveSeparator(Base); + P := PathRemoveSeparator(Path); + // an empty path or one that's not longer than base cannot be a subdirectory + L := Length(B); + {$IFDEF MSWINDOWS} + Result := AnsiSameText(P, B); + {$ENDIF MSWINDOWS} + {$IFDEF UNIX} + Result := AnsiSameStr(P, B); + {$ENDIF UNIX} + if Result or (P = '') or (L >= Length(P)) then + Exit; + {$IFDEF MSWINDOWS} + Result := AnsiSameText(StrLeft(P, L), B) and (P[L+1] = DirDelimiter); + {$ENDIF MSWINDOWS} + {$IFDEF UNIX} + Result := AnsiSameStr(StrLeft(P, L), B) and (P[L+1] = DirDelimiter); + {$ENDIF UNIX} +end; + +function PathIsDiskDevice(const Path: string): Boolean; +{$IFDEF UNIX} +var + FullPath: string; + F: PIOFile; + Buffer: array [0..255] of Char; + MountEntry: TMountEntry; + FsTypes: TStringList; + + procedure GetAvailableFileSystems(const List: TStrings); + var + F: TextFile; + S: string; + begin + AssignFile(F, '/proc/filesystems'); + Reset(F); + repeat + Readln(F, S); + if Pos('nodev', S) = 0 then // how portable is this ? + List.Add(Trim(S)); + until Eof(F); + List.Add('supermount'); + CloseFile(F); + end; + +begin + Result := False; + + SetLength(FullPath, _POSIX_PATH_MAX); + if realpath(PChar(Path), PChar(FullPath)) = nil then + RaiseLastOSError; + StrResetLength(FullPath); + + FsTypes := TStringList.Create; + try + GetAvailableFileSystems(FsTypes); + F := setmntent(_PATH_MOUNTED, 'r'); // PATH_MOUNTED is deprecated, + // but PATH_MNTTAB is defective in Libc.pas + try + // get drives from mtab + while not Result and (getmntent_r(F, MountEntry, Buffer, SizeOf(Buffer)) <> nil) do + if FsTypes.IndexOf(MountEntry.mnt_type) <> -1 then + Result := MountEntry.mnt_dir = FullPath; + + finally + endmntent(F); + end; + finally + FsTypes.Free; + end; +end; +{$ENDIF UNIX} +{$IFDEF MSWINDOWS} +begin + Result := Copy(Path, 1, Length(PathDevicePrefix)) = PathDevicePrefix; +end; +{$ENDIF MSWINDOWS} + +function CharIsMachineName(const C: Char): Boolean; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +begin + case C of + 'a'..'z', + 'A'..'Z', + '-', '_', '.': + Result := True; + else + Result := False; + end; +end; + +function CharIsInvalidPathCharacter(const C: Char): Boolean; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +begin + case C of + '<', '>', '?', '/', ',', '*', '+', '=', '[', ']', '|', ':', ';', '"', '''': + Result := True; + else + Result := False; + end; +end; + +function PathIsUNC(const Path: string): Boolean; + +{$IFDEF MSWINDOWS} + +const + cUNCSuffix = '?\UNC'; + +var + P: PChar; + + function AbsorbSeparator: Boolean; + begin + Result := (P <> nil) and (P^ = DirDelimiter); + if Result then + Inc(P); + end; + + function AbsorbMachineName: Boolean; + var + NonDigitFound: Boolean; + begin + // a valid machine name is a string composed of the set [a-z, A-Z, 0-9, -, _] but it may not + // consist entirely out of numbers + Result := True; + NonDigitFound := False; + while (P^ <> #0) and (P^ <> DirDelimiter) do + begin + if CharIsMachineName(P^) then + begin + NonDigitFound := True; + Inc(P); + end + else + if CharIsDigit(P^) then + Inc(P) + else + begin + Result := False; + Break; + end; + end; + Result := Result and NonDigitFound; + end; + + function AbsorbShareName: Boolean; + begin + // a valid share name is a string composed of a set the set !InvalidCharacters note that a + // leading '$' is valid (indicates a hidden share) + Result := True; + while (P^ <> #0) and (P^ <> DirDelimiter) do + begin + if CharIsInvalidPathCharacter(P^) then + begin + Result := False; + Break; + end; + Inc(P); + end; + end; + +begin + Result := Copy(Path, 1, Length(PathUncPrefix)) = PathUncPrefix; + if Result then + begin + if Copy(Path, 1, Length(PathUncPrefix + cUNCSuffix)) = PathUncPrefix + cUNCSuffix then + P := @Path[Length(PathUncPrefix + cUNCSuffix)] + else + begin + P := @Path[Length(PathUncPrefix)]; + Result := AbsorbSeparator and AbsorbMachineName; + end; + Result := Result and AbsorbSeparator; + if Result then + begin + Result := AbsorbShareName; + // remaining, if anything, is path and or filename (optional) check those? + end; + end; +end; + +{$ENDIF MSWINDOWS} + +{$IFDEF UNIX} + +begin + Result := False; +end; + +{$ENDIF UNIX} + +function PathRemoveSeparator(const Path: string): string; +var + L: Integer; +begin + L := Length(Path); + if (L <> 0) and (Path[L] = DirDelimiter) then + Result := Copy(Path, 1, L - 1) + else + Result := Path; +end; + +function PathRemoveExtension(const Path: string): string; +var + I: Integer; +begin + I := LastDelimiter(':.' + DirDelimiter, Path); + if (I > 0) and (Path[I] = '.') then + Result := Copy(Path, 1, I - 1) + else + Result := Path; +end; + +{$IFDEF MSWINDOWS} + +function SHGetDisplayName(ShellFolder: IShellFolder; PIDL: PItemIDList; ForParsing: Boolean): string; +const + Flags: array[Boolean] of DWORD = (SHGDN_NORMAL, SHGDN_FORPARSING); +var + StrRet: TStrRet; + P: PChar; +begin + Result := ''; + StrRet.utype := 0; + + ShellFolder.GetDisplayNameOf(PIDL, Flags[ForParsing], StrRet); + case StrRet.uType of + STRRET_CSTR: + SetString(Result, StrRet.cStr, lstrlenA(StrRet.cStr)); + STRRET_OFFSET: + begin + P := @PIDL.mkid.abID[StrRet.uOffset - SizeOf(PIDL.mkid.cb)]; + SetString(Result, P, PIDL.mkid.cb - StrRet.uOffset); + end; + STRRET_WSTR: + Result := StrRet.pOleStr; + end; + Result := Copy(Result, 1, lstrlen(PChar(Result))); +end; + +function CutFirstDirectory(var Path: string): string; +var + ps: Integer; +begin + ps := AnsiPos(DirDelimiter, Path); + if ps > 0 then + begin + Result := Copy(Path, 1, ps - 1); + Path := Copy(Path, ps + 1, Length(Path)); + end + else + begin + Result := Path; + Path := ''; + end; +end; + +function PathGetPhysicalPath(const LocalizedPath: string): string; +var + Malloc: IMalloc; + DesktopFolder: IShellFolder; + RootFolder: IShellFolder; + Eaten: Cardinal; + Attributes: Cardinal; + pidl: PItemIDList; + EnumIDL: IEnumIDList; + Drive: WideString; + Featched: Cardinal; + ParsePath: WideString; + Path, Name: string; + Found: Boolean; +begin + if StrCompareRange('\\', LocalizedPath, 1, 2) = 0 then + begin + Result := LocalizedPath; + Exit; + end; + + Drive := ExtractFileDrive(LocalizedPath); + if Drive = '' then + begin + Result := LocalizedPath; + Exit; + end; + Path := Copy(LocalizedPath, Length(Drive) + 2, Length(LocalizedPath)); + ParsePath := Drive; + OLECheck( SHGetMalloc(Malloc) ); + OleCheck( SHGetDesktopFolder(DesktopFolder) ); + while Path <> '' do + begin + Name := CutFirstDirectory(Path); + Found := False; + pidl := nil; + Attributes := 0; + if Succeeded( DesktopFolder.ParseDisplayName(0, nil, PWideChar(ParsePath), Eaten, pidl, Attributes) ) then + begin + OleCheck( DesktopFolder.BindToObject(pidl, nil, IShellFolder, RootFolder) ); + Malloc.Free(pidl); + + OleCheck( RootFolder.EnumObjects(0, SHCONTF_FOLDERS or SHCONTF_NONFOLDERS or SHCONTF_INCLUDEHIDDEN, EnumIDL) ); + Featched := 0; + while EnumIDL.Next(1, pidl, Featched) = NOERROR do + begin + if AnsiCompareText(Name, SHGetDisplayName(RootFolder, pidl, False)) = 0 then + begin + ParsePath := SHGetDisplayName(RootFolder, pidl, True); + Malloc.Free(pidl); + Found := True; + Break; + end; + Malloc.Free(pidl); + end; + EnumIDL := nil; + RootFolder := nil; + end; + if not Found then + ParsePath := ParsePath + DirDelimiter + Name; + end; + Result := ParsePath; +end; + +function PathGetLocalizedPath(const PhysicalPath: string): string; +var + Malloc: IMalloc; + DesktopFolder: IShellFolder; + RootFolder: IShellFolder; + Eaten: Cardinal; + Attributes: Cardinal; + pidl: PItemIDList; + EnumIDL: IEnumIDList; + Drive: WideString; + Featched: Cardinal; + ParsePath: WideString; + Path, Name, ParseName, DisplayName: string; + Found: Boolean; +begin + if StrCompareRange('\\', PhysicalPath, 1, 2) = 0 then + begin + Result := PhysicalPath; + Exit; + end; + + Drive := ExtractFileDrive(PhysicalPath); + if Drive = '' then + begin + Result := PhysicalPath; + Exit; + end; + Path := Copy(PhysicalPath, Length(Drive) + 2, Length(PhysicalPath)); + ParsePath := Drive; + Result := Drive; + OLECheck( SHGetMalloc(Malloc) ); + OleCheck( SHGetDesktopFolder(DesktopFolder) ); + while Path <> '' do + begin + Name := CutFirstDirectory(Path); + Found := False; + pidl := nil; + Attributes := 0; + if Succeeded( DesktopFolder.ParseDisplayName(0, nil, PWideChar(ParsePath), Eaten, pidl, Attributes) ) then + begin + OleCheck( DesktopFolder.BindToObject(pidl, nil, IShellFolder, RootFolder) ); + Malloc.Free(pidl); + + OleCheck( RootFolder.EnumObjects(0, SHCONTF_FOLDERS or SHCONTF_NONFOLDERS or SHCONTF_INCLUDEHIDDEN, EnumIDL) ); + Featched := 0; + while EnumIDL.Next(1, pidl, Featched) = NOERROR do + begin + ParseName := SHGetDisplayName(RootFolder, pidl, True); + DisplayName := SHGetDisplayName(RootFolder, pidl, False); + Malloc.Free(pidl); + if (AnsiCompareText(Name, ExtractFileName(ParseName)) = 0) or + (AnsiCompareText(Name, DisplayName) = 0) then + begin + Name := DisplayName; + ParsePath := ParseName; + Found := True; + Break; + end; + end; + EnumIDL := nil; + RootFolder := nil; + end; + Result := Result + DirDelimiter + Name; + if not Found then + ParsePath := ParsePath + DirDelimiter + Name; + end; +end; + +{$ELSE ~MSWINDOWS} +function PathGetPhysicalPath(const LocalizedPath: string): string; +begin + Result := LocalizedPath; +end; + +function PathGetLocalizedPath(const PhysicalPath: string): string; +begin + Result := PhysicalPath; +end; +{$ENDIF ~MSWINDOWS} + +//=== Files and Directories ================================================== + + +{* Extended version of JclFileUtils.BuildFileList: + function parameter Path can include multiple FileMasks as: + c:\aaa\*.pas; pro*.dpr; *.d?? + FileMask Seperator = ';' + *} + +function BuildFileList(const Path: string; const Attr: Integer; const List: TStrings; IncludeDirectoryName: Boolean = + False): Boolean; +var + SearchRec: TSearchRec; + IndexMask: Integer; + MaskList: TStringList; + Masks, Directory: string; +begin + Assert(List <> nil); + MaskList := TStringList.Create; + try + {* extract the Directory *} + Directory := ExtractFileDir(Path); + + {* files can be searched in the current directory *} + if Directory <> '' then + begin + Directory := PathAddSeparator(Directory); + {* extract the FileMasks portion out of Path *} + Masks := StrAfter(Directory, Path); + end + else + Masks := Path; + + {* put the Masks into TStringlist *} + StrTokenToStrings(Masks, DirSeparator, MaskList); + + {* search all files in the directory *} + Result := FindFirst(Directory + '*', faAnyFile, SearchRec) = 0; + + List.BeginUpdate; + try + while Result do + begin + {* if the filename matches any mask then it is added to the list *} + for IndexMask := 0 to MaskList.Count - 1 do + if (SearchRec.Name <> '.') and (SearchRec.Name <> '..') + and ((SearchRec.Attr and Attr) = (SearchRec.Attr and faAnyFile)) + and IsFileNameMatch(SearchRec.Name, MaskList.Strings[IndexMask]) then + begin + if IncludeDirectoryName then + List.Add(Directory+SearchRec.Name) + else + List.Add(SearchRec.Name); + Break; + end; + + case FindNext(SearchRec) of + 0: + ; + ERROR_NO_MORE_FILES: + Break; + else + Result := False; + end; + end; + finally + {$IFDEF HAS_UNITSCOPE}System.{$ENDIF}SysUtils.FindClose(SearchRec); + List.EndUpdate; + end; + finally + MaskList.Free; + end; +end; + +{$IFDEF MSWINDOWS} + +procedure CreateEmptyFile(const FileName: string); +var + Handle: THandle; +begin + Handle := CreateFile(PChar(FileName), GENERIC_READ or GENERIC_WRITE, 0, nil, CREATE_ALWAYS, 0, 0); + if Handle <> INVALID_HANDLE_VALUE then + CloseHandle(Handle) + else + RaiseLastOSError; +end; +{$ENDIF MSWINDOWS} + +{$IFDEF MSWINDOWS} + +function CloseVolume(var Volume: THandle): Boolean; +begin + Result := False; + if Volume <> INVALID_HANDLE_VALUE then + begin + Result := CloseHandle(Volume); + if Result then + Volume := INVALID_HANDLE_VALUE; + end; +end; + +{$IFNDEF FPC} // needs JclShell + +{$IFNDEF WINSCP} +function DeleteDirectory(const DirectoryName: string; MoveToRecycleBin: Boolean): Boolean; +begin + if MoveToRecycleBin then + Result := SHDeleteFolder(0, DirectoryName, [doSilent, doAllowUndo]) + else + Result := DelTree(DirectoryName); +end; +{$ENDIF ~WINSCP} + +function CopyDirectory(ExistingDirectoryName, NewDirectoryName: string): Boolean; +var + SH: SHFILEOPSTRUCT; +begin + ResetMemory(SH, SizeOf(SH)); + SH.Wnd := 0; + SH.wFunc := FO_COPY; + SH.pFrom := PChar(PathRemoveSeparator(ExistingDirectoryName) + #0); + SH.pTo := PChar(PathRemoveSeparator(NewDirectoryName) + #0); + SH.fFlags := FOF_ALLOWUNDO or FOF_NOCONFIRMATION or FOF_NOCONFIRMMKDIR or FOF_SILENT; + Result := SHFileOperation(SH) = 0; +end; + +function MoveDirectory(ExistingDirectoryName, NewDirectoryName: string): Boolean; +var + SH: SHFILEOPSTRUCT; +begin + ResetMemory(SH, SizeOf(SH)); + SH.Wnd := 0; + SH.wFunc := FO_MOVE; + SH.pFrom := PChar(PathRemoveSeparator(ExistingDirectoryName) + #0); + SH.pTo := PChar(PathRemoveSeparator(NewDirectoryName) + #0); + SH.fFlags := FOF_ALLOWUNDO or FOF_NOCONFIRMATION or FOF_NOCONFIRMMKDIR or FOF_SILENT; + Result := SHFileOperation(SH) = 0; +end; + +{$ENDIF ~FPC} + +function DelTree(const Path: string): Boolean; +begin + Result := DelTreeEx(Path, False, nil); +end; + +function DelTreeEx(const Path: string; AbortOnFailure: Boolean; Progress: TDelTreeProgress): Boolean; +var + Files: TStringList; + LPath: string; // writable copy of Path + FileName: string; + I: Integer; + PartialResult: Boolean; + Attr: DWORD; +begin + Assert(Path <> '', LoadResString(@RsDelTreePathIsEmpty)); + {$IFNDEF ASSERTIONS_ON} + if Path = '' then + begin + Result := False; + Exit; + end; + {$ENDIF ~ASSERTIONS_ON} + Result := True; + Files := TStringList.Create; + try + LPath := PathRemoveSeparator(Path); + BuildFileList(LPath + '\*.*', faAnyFile, Files); + for I := 0 to Files.Count - 1 do + begin + FileName := LPath + DirDelimiter + Files[I]; + PartialResult := True; + // If the current file is itself a directory then recursively delete it + Attr := GetFileAttributes(PChar(FileName)); + if (Attr <> DWORD(-1)) and ((Attr and FILE_ATTRIBUTE_DIRECTORY) <> 0) then + PartialResult := DelTreeEx(FileName, AbortOnFailure, Progress) + else + begin + if Assigned(Progress) then + PartialResult := Progress(FileName, Attr); + if PartialResult then + begin + // Set attributes to normal in case it's a readonly file + PartialResult := SetFileAttributes(PChar(FileName), FILE_ATTRIBUTE_NORMAL); + if PartialResult then + PartialResult := DeleteFile(FileName); + end; + end; + if not PartialResult then + begin + Result := False; + if AbortOnFailure then + Break; + end; + end; + finally + FreeAndNil(Files); + end; + if Result then + begin + // Finally remove the directory itself + Result := SetFileAttributes(PChar(LPath), FILE_ATTRIBUTE_NORMAL); + if Result then + begin + {$IOCHECKS OFF} + RmDir(LPath); + {$IFDEF IOCHECKS_ON} + {$IOCHECKS ON} + {$ENDIF IOCHECKS_ON} + Result := IOResult = 0; + end; + end; +end; + +{$ENDIF MSWINDOWS} + +{$IFDEF MSWINDOWS} +function DirectoryExists(const Name: string): Boolean; +var + R: DWORD; +begin + R := GetFileAttributes(PChar(Name)); + Result := (R <> DWORD(-1)) and ((R and FILE_ATTRIBUTE_DIRECTORY) <> 0); +end; +{$ENDIF MSWINDOWS} + +{$IFDEF UNIX} +function DirectoryExists(const Name: string; ResolveSymLinks: Boolean): Boolean; +begin + Result := IsDirectory(Name, ResolveSymLinks); +end; +{$ENDIF UNIX} + +{$IFDEF MSWINDOWS} +function DiskInDrive(Drive: Char): Boolean; +var + ErrorMode: Cardinal; +begin + Result := False; + Assert(CharIsDriveLetter(Drive)); + if CharIsDriveLetter(Drive) then + begin + Drive := CharUpper(Drive); + { try to access the drive, it doesn't really matter how we access the drive and as such calling + DiskSize is more or less a random choice. The call to SetErrorMode supresses the system provided + error dialog if there is no disk in the drive and causes the to DiskSize to fail. } + ErrorMode := SetErrorMode(SEM_FAILCRITICALERRORS); + try + Result := DiskSize(Ord(Drive) - $40) <> -1; + finally + SetErrorMode(ErrorMode); + end; + end; +end; +{$ENDIF MSWINDOWS} + +function FileCreateTemp(var Prefix: string): THandle; +{$IFDEF MSWINDOWS} +var + TempName: string; +begin + Result := INVALID_HANDLE_VALUE; + TempName := FileGetTempName(Prefix); + if TempName <> '' then + begin + Result := CreateFile(PChar(TempName), GENERIC_READ or GENERIC_WRITE, 0, nil, + OPEN_EXISTING, FILE_ATTRIBUTE_TEMPORARY or FILE_FLAG_DELETE_ON_CLOSE, 0); + // In certain situations it's possible that CreateFile fails yet the file is actually created, + // therefore explicitly delete it upon failure. + if Result = INVALID_HANDLE_VALUE then + DeleteFile(TempName); + Prefix := TempName; + end; +end; +{$ENDIF MSWINDOWS} +{$IFDEF UNIX} +var + Template: string; +begin + // The mkstemp function generates a unique file name just as mktemp does, but + // it also opens the file for you with open. If successful, it modifies + // template in place and returns a file descriptor for that file open for + // reading and writing. If mkstemp cannot create a uniquely-named file, it + // returns -1. If template does not end with `XXXXXX', mkstemp returns -1 and + // does not modify template. + + // The file is opened using mode 0600. If the file is meant to be used by + // other users this mode must be changed explicitly. + + // Unlike mktemp, mkstemp is actually guaranteed to create a unique file that + // cannot possibly clash with any other program trying to create a temporary + // file. This is because it works by calling open with the O_EXCL flag, which + // says you want to create a new file and get an error if the file already + // exists. + Template := Prefix + 'XXXXXX'; + Result := mkstemp(PChar(Template)); + Prefix := Template; +end; +{$ENDIF UNIX} + +{$IFNDEF WINSCP} +function FileBackup(const FileName: string; Move: Boolean = False): Boolean; +begin + if Move then + Result := FileMove(FileName, GetBackupFileName(FileName), True) + else + Result := FileCopy(FileName, GetBackupFileName(FileName), True); +end; +{$ENDIF ~WINSCP} + +function FileCopy(const ExistingFileName, NewFileName: string; ReplaceExisting: Boolean = False): Boolean; +var + {$IFDEF UNIX} + SrcFile, DstFile: file; + Buf: array[0..511] of Byte; + BytesRead: Integer; + {$ENDIF UNIX} + DestFileName: string; +begin + if IsDirectory(NewFileName) then + DestFileName := PathAddSeparator(NewFileName) + ExtractFileName(ExistingFileName) + else + DestFileName := NewFileName; + {$IFDEF MSWINDOWS} + { TODO : Use CopyFileEx where available? } + Result := CopyFile(PChar(ExistingFileName), PChar(DestFileName), not ReplaceExisting); + {$ENDIF MSWINDOWS} + {$IFDEF UNIX} + Result := False; + if not FileExists(DestFileName) or ReplaceExisting then + begin + AssignFile(SrcFile, ExistingFileName); + Reset(SrcFile, 1); + AssignFile(DstFile, DestFileName); + Rewrite(DstFile, 1); + while not Eof(SrcFile) do + begin + BlockRead(SrcFile, Buf, SizeOf(Buf), BytesRead); + BlockWrite(DstFile, Buf, BytesRead); + end; + CloseFile(DstFile); + CloseFile(SrcFile); + Result := True; + end; + {$ENDIF UNIX} +end; + +function FileDateTime(const FileName: string): TDateTime; +{$IFNDEF COMPILER10_UP} +var + Age: Longint; +{$ENDIF !COMPILER10_UP} +begin + {$IFDEF COMPILER10_UP} + if not FileAge(Filename, Result) then + Result := 0; + {$ELSE} + Age := FileAge(FileName); + {$IFDEF MSWINDOWS} + // [roko] -1 is valid FileAge value on Linux + if Age = -1 then + Result := 0 + else + {$ENDIF MSWINDOWS} + Result := FileDateToDateTime(Age); + {$ENDIF COMPILER10_UP} +end; + +{$IFNDEF WINSCP} +function FileDelete(const FileName: string; MoveToRecycleBin: Boolean = False): Boolean; +{$IFDEF MSWINDOWS} +begin + if MoveToRecycleBin then + Result := SHDeleteFiles(0, FileName, [doSilent, doAllowUndo, doFilesOnly]) + else + Result := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.DeleteFile(PChar(FileName)); +end; +{$ENDIF MSWINDOWS} +{$IFDEF UNIX} + { TODO : implement MoveToRecycleBin for appropriate Desktops (e.g. KDE) } +begin + Result := remove(PChar(FileName)) <> -1; +end; +{$ENDIF UNIX} +{$ENDIF ~WINSCP} + +function FileExists(const FileName: string): Boolean; +{$IFDEF MSWINDOWS} +var + Attr: Cardinal; +{$ENDIF MSWINDOWS} +begin + if FileName <> '' then + begin + {$IFDEF MSWINDOWS} + // FileGetSize is very slow, GetFileAttributes is much faster + Attr := GetFileAttributes(Pointer(Filename)); + Result := (Attr <> $FFFFFFFF) and (Attr and FILE_ATTRIBUTE_DIRECTORY = 0); + {$ELSE ~MSWINDOWS} + // Attempt to access the file, doesn't matter how, using FileGetSize is as good as anything else. + Result := FileGetSize(FileName) <> -1; + {$ENDIF ~MSWINDOWS} + end + else + Result := False; +end; + +{$IFNDEF WINSCP} +procedure FileHistory(const FileName: string; HistoryPath: string = ''; MaxHistoryCount: Integer = 100; MinFileDate: + TDateTime = 0; ReplaceExtention: Boolean = true); + + Function Extention (Number : Integer) : String; + begin + Result := inttostr(Number); + while Length(Result) < 3 do + Result := '0' + Result; + Result := '.~'+Result+'~'; + end; + + procedure RenameToNumber(const RenameFileName: string; Number: Integer); + var + f1: string; + f2: string; + begin + f1 := ChangeFileExt(RenameFileName,Extention(Number-1)); + f2 := ChangeFileExt(RenameFileName,Extention(Number)); + if FileExists(f2) then + if Number >= MaxHistoryCount then + if not FileDelete(f2) then + Exception.Create('Unable to delete file "' + f2 + '".') + else + else + RenameToNumber(RenameFileName, Number + 1); + if FileExists(f1) then + if not FileMove(f1, f2, true) then + Exception.Create('Unable to rename file "' + f1 + '" to "' + f2 + '".') + end; + +Var FirstFile : string; +begin + // TODO -cMM: FileHistory default body inserted + if not FileExists(FileName) or (MaxHistoryCount <= 0) then + Exit; + if HistoryPath = '' then + HistoryPath := ExtractFilePath(FileName); + FirstFile := PathAppend(HistoryPath, ExtractFileName(FileName)); + if ReplaceExtention then + FirstFile := ChangeFileExt(FirstFile, Extention(1)) + else + FirstFile := FirstFile+Extention(1); + if (FileDateTime(FirstFile) > MinFileDate) and (MinFileDate <> 0) then + Exit; + RenameToNumber(FirstFile, 2); + FileCopy(FileName, FirstFile, True); +end; +{$ENDIF ~WINSCP} + + +{$IFNDEF WINSCP} +function FileMove(const ExistingFileName, NewFileName: string; ReplaceExisting: Boolean = False): Boolean; +{$IFDEF MSWINDOWS} +const + Flag: array[Boolean] of Cardinal = (0, MOVEFILE_REPLACE_EXISTING); +{$ENDIF MSWINDOWS} +begin + {$IFDEF MSWINDOWS} + Result := MoveFileEx(PChar(ExistingFileName), PChar(NewFileName), Flag[ReplaceExisting]); + {$ENDIF MSWINDOWS} + {$IFDEF UNIX} + Result := __rename(PChar(ExistingFileName), PChar(NewFileName)) = 0; + {$ENDIF UNIX} + if not Result then + begin + Result := FileCopy(ExistingFileName, NewFileName, ReplaceExisting); + if Result then + FileDelete(ExistingFileName); + end; +end; + +function FileRestore(const FileName: string): Boolean; +var + TempFileName: string; +begin + Result := False; + TempFileName := FileGetTempName(''); + + if FileMove(GetBackupFileName(FileName), TempFileName, True) then + if FileBackup(FileName, False) then + Result := FileMove(TempFileName, FileName, True); +end; +{$ENDIF ~WINSCP} + +function GetBackupFileName(const FileName: string): string; +var + NewExt: string; +begin + NewExt := ExtractFileExt(FileName); + if Length(NewExt) > 0 then + begin + NewExt[1] := '~'; + NewExt := '.' + NewExt + end + else + NewExt := '.~'; + Result := ChangeFileExt(FileName, NewExt); +end; + +function IsBackupFileName(const FileName: string): Boolean; +begin + Result := (pos('.~', ExtractFileExt(FileName)) = 1); +end; + +function FileGetDisplayName(const FileName: string): string; +{$IFDEF MSWINDOWS} +var + FileInfo: TSHFileInfo; +begin + ResetMemory(FileInfo, SizeOf(FileInfo)); + if SHGetFileInfo(PChar(FileName), 0, FileInfo, SizeOf(FileInfo), SHGFI_DISPLAYNAME) <> 0 then + Result := FileInfo.szDisplayName + else + Result := FileName; +end; +{$ELSE ~MSWINDOWS} +begin + { TODO -cHelp : mention this reduced solution } + Result := FileName; +end; +{$ENDIF ~MSWINDOWS} + +{$IFNDEF WINSCP} +function FileGetGroupName(const FileName: string {$IFDEF UNIX}; ResolveSymLinks: Boolean = True {$ENDIF}): string; +{$IFDEF MSWINDOWS} +var + DomainName: WideString; + TmpResult: WideString; + pSD: PSecurityDescriptor; + BufSize: DWORD; +begin + if IsWinNT then + begin + BufSize := 0; + GetFileSecurity(PChar(FileName), GROUP_SECURITY_INFORMATION, nil, 0, BufSize); + if BufSize > 0 then + begin + GetMem(pSD, BufSize); + GetFileSecurity(PChar(FileName), GROUP_SECURITY_INFORMATION, + pSD, BufSize, BufSize); + LookupAccountBySid(Pointer(TJclAddr(pSD) + TJclAddr(pSD^.Group)), TmpResult, DomainName, True); + FreeMem(pSD); + Result := Trim(TmpResult); + end; + end; +end; +{$ENDIF ~MSWINDOWS} +{$IFDEF UNIX} +var + Buf: TStatBuf64; + ResultBuf: TGroup; + ResultBufPtr: PGroup; + Buffer: array of Char; +begin + if GetFileStatus(FileName, Buf, ResolveSymLinks) = 0 then + begin + SetLength(Buffer, 128); + while getgrgid_r(Buf.st_gid, ResultBuf, @Buffer[0], Length(Buffer), ResultBufPtr) = ERANGE do + SetLength(Buffer, Length(Buffer) * 2); + Result := ResultBuf.gr_name; + end; +end; +{$ENDIF ~UNIX} + +function FileGetOwnerName(const FileName: string {$IFDEF UNIX}; ResolveSymLinks: Boolean = True {$ENDIF}): string; +{$IFDEF MSWINDOWS} +var + DomainName: WideString; + TmpResult: WideString; + pSD: PSecurityDescriptor; + BufSize: DWORD; +begin + if IsWinNT then + begin + BufSize := 0; + GetFileSecurity(PChar(FileName), OWNER_SECURITY_INFORMATION, nil, 0, BufSize); + if BufSize > 0 then + begin + GetMem(pSD, BufSize); + try + GetFileSecurity(PChar(FileName), OWNER_SECURITY_INFORMATION, + pSD, BufSize, BufSize); + LookupAccountBySid(Pointer(TJclAddr(pSD) + TJclAddr(pSD^.Owner)), TmpResult, DomainName, True); + finally + FreeMem(pSD); + end; + Result := Trim(TmpResult); + end; + end; +end; +{$ENDIF ~MSWINDOWS} +{$IFDEF UNIX} +var + Buf: TStatBuf64; + ResultBuf: TPasswordRecord; + ResultBufPtr: PPasswordRecord; + Buffer: array of Char; +begin + if GetFileStatus(FileName, Buf, ResolveSymLinks) = 0 then + begin + SetLength(Buffer, 128); + while getpwuid_r(Buf.st_uid, ResultBuf, @Buffer[0], Length(Buffer), ResultBufPtr) = ERANGE do + SetLength(Buffer, Length(Buffer) * 2); + Result := ResultBuf.pw_name; + end; +end; +{$ENDIF ~UNIX} +{$ENDIF ~WINSCP} + +function FileGetSize(const FileName: string): Int64; +{$IFDEF MSWINDOWS} +var + FileAttributesEx: WIN32_FILE_ATTRIBUTE_DATA; + OldMode: Cardinal; + Size: TJclULargeInteger; +begin + Result := -1; + OldMode := SetErrorMode(SEM_FAILCRITICALERRORS); + try + if GetFileAttributesEx(PChar(FileName), GetFileExInfoStandard, @FileAttributesEx) then + begin + Size.LowPart := FileAttributesEx.nFileSizeLow; + Size.HighPart := FileAttributesEx.nFileSizeHigh; + Result := Size.QuadPart; + end; + finally + SetErrorMode(OldMode); + end; +end; +{$ENDIF MSWINDOWS} +{$IFDEF UNIX} +var + Buf: TStatBuf64; +begin + Result := -1; + if GetFileStatus(FileName, Buf, False) = 0 then + Result := Buf.st_size; +end; +{$ENDIF UNIX} + +{$IFDEF MSWINDOWS} +{$IFDEF FPC} +{ TODO : Move this over to JclWin32 when JclWin32 gets overhauled. } +function GetTempFileName(lpPathName, lpPrefixString: PChar; + uUnique: UINT; lpTempFileName: PChar): UINT; stdcall; +external kernel32 name 'GetTempFileNameA'; +{$ENDIF FPC} +{$ENDIF MSWINDOWS} + +function FileGetTempName(const Prefix: string): string; +{$IFDEF MSWINDOWS} +var + TempPath, TempFile: string; + R: Cardinal; +begin + Result := ''; + TempPath := PathGetTempPath; + if TempPath <> '' then + begin + SetLength(TempFile, MAX_PATH); + R := GetTempFileName(PChar(TempPath), PChar(Prefix), 0, PChar(TempFile)); + if R <> 0 then + begin + StrResetLength(TempFile); + Result := TempFile; + end; + end; +end; +{$ENDIF MSWINDOWS} +{$IFDEF UNIX} +// Warning: Between the time the pathname is constructed and the file is created +// another process might have created a file with the same name using tmpnam, +// leading to a possible security hole. The implementation generates names which +// can hardly be predicted, but when opening the file you should use the O_EXCL +// flag. Using tmpfile or mkstemp is a safe way to avoid this problem. +var + P: PChar; +begin + P := tempnam(PChar(PathGetTempPath), PChar(Prefix)); + Result := P; + Libc.free(P); +end; +{$ENDIF UNIX} + +{$IFDEF MSWINDOWS} +function FileGetTypeName(const FileName: string): string; +var + FileInfo: TSHFileInfo; + RetVal: DWORD; +begin + ResetMemory(FileInfo, SizeOf(FileInfo)); + RetVal := SHGetFileInfo(PChar(FileName), 0, FileInfo, SizeOf(FileInfo), + SHGFI_TYPENAME or SHGFI_USEFILEATTRIBUTES); + if RetVal <> 0 then + Result := FileInfo.szTypeName; + if (RetVal = 0) or (Trim(Result) = '') then + begin + // Lookup failed so mimic explorer behaviour by returning "XYZ File" + Result := ExtractFileExt(FileName); + Delete(Result, 1, 1); + Result := TrimLeft(UpperCase(Result) + LoadResString(@RsDefaultFileTypeName)); + end; +end; +{$ENDIF MSWINDOWS} + +function FindUnusedFileName(FileName: string; const FileExt: string; NumberPrefix: string = ''): string; +var + I: Integer; +begin + Result := PathAddExtension(FileName, FileExt); + if not FileExists(Result) then + Exit; + if SameText(Result, FileName) then + Delete(FileName, Length(FileName) - Length(FileExt) + 1, Length(FileExt)); + I := 0; + repeat + Inc(I); + Result := PathAddExtension(FileName + NumberPrefix + IntToStr(I), FileExt); + until not FileExists(Result); +end; + +// This routine is copied from FileCtrl.pas to avoid dependency on that unit. +// See the remark at the top of this section + +function ForceDirectories(Name: string): Boolean; +var + ExtractPath: string; +begin + Result := True; + if Length(Name) = 0 then + raise EJclFileUtilsError.CreateRes(@RsCannotCreateDir); + Name := PathRemoveSeparator(Name); + {$IFDEF MSWINDOWS} + ExtractPath := ExtractFilePath(Name); + if ((Length(Name) = 2) and (Copy(Name, 2,1) = ':')) or DirectoryExists(Name) or (ExtractPath = Name) then + Exit; + {$ENDIF MSWINDOWS} + {$IFDEF UNIX} + if (Length(Name) = 0) or DirectoryExists(Name) then + Exit; + ExtractPath := ExtractFilePath(Name); + {$ENDIF UNIX} + Result := (ExtractPath = '') or ForceDirectories(ExtractPath); + if Result then + begin + {$IFDEF MSWINDOWS} + SetLastError(ERROR_SUCCESS); + {$ENDIF MSWINDOWS} + Result := Result and CreateDir(Name); + {$IFDEF MSWINDOWS} + Result := Result or (GetLastError = ERROR_ALREADY_EXISTS); + {$ENDIF MSWINDOWS} + end; +end; + +function GetDirectorySize(const Path: string): Int64; + + function RecurseFolder(const Path: string): Int64; + var + F: TSearchRec; + R: Integer; + {$IFDEF MSWINDOWS} + TempSize: TJclULargeInteger; + {$ENDIF MSWINDOWS} + begin + Result := 0; + R := {$IFDEF HAS_UNITSCOPE}System.{$ENDIF}SysUtils.FindFirst(Path + '*.*', faAnyFile, F); + if R = 0 then + try + while R = 0 do + begin + if (F.Name <> '.') and (F.Name <> '..') then + begin + if (F.Attr and faDirectory) = faDirectory then + Inc(Result, RecurseFolder(Path + F.Name + DirDelimiter)) + else + {$IFDEF MSWINDOWS} + begin + TempSize.LowPart := F.FindData.nFileSizeLow; + TempSize.HighPart := F.FindData.nFileSizeHigh; + Inc(Result, TempSize.QuadPart); + end; + {$ENDIF MSWINDOWS} + {$IFDEF UNIX} + // SysUtils.Find* don't perceive files >= 2 GB anyway + Inc(Result, Int64(F.Size)); + {$ENDIF UNIX} + end; + R := {$IFDEF HAS_UNITSCOPE}System.{$ENDIF}SysUtils.FindNext(F); + end; + if R <> ERROR_NO_MORE_FILES then + Abort; + finally + {$IFDEF HAS_UNITSCOPE}System.{$ENDIF}SysUtils.FindClose(F); + end; + end; + +begin + if not DirectoryExists(PathRemoveSeparator(Path)) then + Result := -1 + else + try + Result := RecurseFolder(PathAddSeparator(Path)) + except + Result := -1; + end; +end; + +{$IFDEF MSWINDOWS} + +function GetDriveTypeStr(const Drive: Char): string; +var + DriveType: Integer; + DriveStr: string; +begin + if not CharIsDriveLetter(Drive) then + raise EJclPathError.CreateResFmt(@RsPathInvalidDrive, [Drive]); + DriveStr := Drive + ':\'; + DriveType := GetDriveType(PChar(DriveStr)); + case DriveType of + DRIVE_REMOVABLE: + Result := LoadResString(@RsRemovableDrive); + DRIVE_FIXED: + Result := LoadResString(@RsHardDisk); + DRIVE_REMOTE: + Result := LoadResString(@RsRemoteDrive); + DRIVE_CDROM: + Result := LoadResString(@RsCDRomDrive); + DRIVE_RAMDISK: + Result := LoadResString(@RsRamDisk); + else + Result := LoadResString(@RsUnknownDrive); + end; +end; + +function GetFileAgeCoherence(const FileName: string): Boolean; +var + FileAttributesEx: WIN32_FILE_ATTRIBUTE_DATA; +begin + Result := False; + if GetFileAttributesEx(PChar(FileName), GetFileExInfoStandard, @FileAttributesEx) then + {$IFDEF FPC} + Result := CompareFileTime(@FileAttributesEx.ftCreationTime, @FileAttributesEx.ftLastWriteTime) <= 0; + {$ELSE ~FPC} + Result := CompareFileTime(FileAttributesEx.ftCreationTime, FileAttributesEx.ftLastWriteTime) <= 0; + {$ENDIF ~FPC} +end; + +{$ENDIF MSWINDOWS} + +procedure GetFileAttributeList(const Items: TStrings; const Attr: Integer); +begin + { TODO : clear list? } + Assert(Assigned(Items)); + if not Assigned(Items) then + Exit; + Items.BeginUpdate; + try + { TODO : differentiate Windows/UNIX idents } + if Attr and faDirectory = faDirectory then + Items.Add(LoadResString(@RsAttrDirectory)); + if Attr and faReadOnly = faReadOnly then + Items.Add(LoadResString(@RsAttrReadOnly)); + if Attr and faSysFile = faSysFile then + Items.Add(LoadResString(@RsAttrSystemFile)); + if Attr and faArchive = faArchive then + Items.Add(LoadResString(@RsAttrArchive)); + if Attr and faAnyFile = faAnyFile then + Items.Add(LoadResString(@RsAttrAnyFile)); + if Attr and faHidden = faHidden then + Items.Add(LoadResString(@RsAttrHidden)); + finally + Items.EndUpdate; + end; +end; + +{$IFDEF MSWINDOWS} + +{ TODO : GetFileAttributeListEx - Unix version } +procedure GetFileAttributeListEx(const Items: TStrings; const Attr: Integer); +begin + { TODO : clear list? } + Assert(Assigned(Items)); + if not Assigned(Items) then + Exit; + Items.BeginUpdate; + try + if Attr and FILE_ATTRIBUTE_READONLY = FILE_ATTRIBUTE_READONLY then + Items.Add(LoadResString(@RsAttrReadOnly)); + if Attr and FILE_ATTRIBUTE_HIDDEN = FILE_ATTRIBUTE_HIDDEN then + Items.Add(LoadResString(@RsAttrHidden)); + if Attr and FILE_ATTRIBUTE_SYSTEM = FILE_ATTRIBUTE_SYSTEM then + Items.Add(LoadResString(@RsAttrSystemFile)); + if Attr and FILE_ATTRIBUTE_DIRECTORY = FILE_ATTRIBUTE_DIRECTORY then + Items.Add(LoadResString(@RsAttrDirectory)); + if Attr and FILE_ATTRIBUTE_ARCHIVE = FILE_ATTRIBUTE_ARCHIVE then + Items.Add(LoadResString(@RsAttrArchive)); + if Attr and FILE_ATTRIBUTE_NORMAL = FILE_ATTRIBUTE_NORMAL then + Items.Add(LoadResString(@RsAttrNormal)); + if Attr and FILE_ATTRIBUTE_TEMPORARY = FILE_ATTRIBUTE_TEMPORARY then + Items.Add(LoadResString(@RsAttrTemporary)); + if Attr and FILE_ATTRIBUTE_COMPRESSED = FILE_ATTRIBUTE_COMPRESSED then + Items.Add(LoadResString(@RsAttrCompressed)); + if Attr and FILE_ATTRIBUTE_OFFLINE = FILE_ATTRIBUTE_OFFLINE then + Items.Add(LoadResString(@RsAttrOffline)); + if Attr and FILE_ATTRIBUTE_ENCRYPTED = FILE_ATTRIBUTE_ENCRYPTED then + Items.Add(LoadResString(@RsAttrEncrypted)); + if Attr and FILE_ATTRIBUTE_REPARSE_POINT = FILE_ATTRIBUTE_REPARSE_POINT then + Items.Add(LoadResString(@RsAttrReparsePoint)); + if Attr and FILE_ATTRIBUTE_SPARSE_FILE = FILE_ATTRIBUTE_SPARSE_FILE then + Items.Add(LoadResString(@RsAttrSparseFile)); + finally + Items.EndUpdate; + end; +end; + +{$ENDIF MSWINDOWS} + +function GetFileInformation(const FileName: string; out FileInfo: TSearchRec): Boolean; +begin + Result := FindFirst(FileName, faAnyFile, FileInfo) = 0; + if Result then + {$IFDEF HAS_UNITSCOPE}System.{$ENDIF}SysUtils.FindClose(FileInfo); +end; + +function GetFileInformation(const FileName: string): TSearchRec; +begin + if not GetFileInformation(FileName, Result) then + RaiseLastOSError; +end; + +{$IFDEF UNIX} + +{ TODO -cHelp : Author: Robert Rossmair } + +function GetFileStatus(const FileName: string; out StatBuf: TStatBuf64; + const ResolveSymLinks: Boolean): Integer; +begin + if ResolveSymLinks then + Result := stat64(PChar(FileName), StatBuf) + else + Result := lstat64(PChar(FileName), StatBuf); +end; + +{$ENDIF UNIX} + +{$IFDEF MSWINDOWS} + +function GetFileLastWrite(const FileName: string): TFileTime; +begin + Result := GetFileInformation(FileName).FindData.ftLastWriteTime; +end; + +{$IFNDEF WINSCP} +function GetFileLastWrite(const FileName: string; out LocalTime: TDateTime): Boolean; +var + FileInfo: TSearchRec; +begin + Result := GetFileInformation(FileName, FileInfo); + if Result then + LocalTime := FileTimeToLocalDateTime(FileInfo.FindData.ftLastWriteTime); +end; +{$ENDIF ~WINSCP} + +{$ENDIF MSWINDOWS} + +{$IFDEF UNIX} + +function GetFileLastWrite(const FileName: string; out TimeStamp: Integer; ResolveSymLinks: Boolean): Boolean; +var + Buf: TStatBuf64; +begin + Result := GetFileStatus(FileName, Buf, ResolveSymLinks) = 0; + if Result then + TimeStamp := Buf.st_mtime +end; + +function GetFileLastWrite(const FileName: string; out LocalTime: TDateTime; ResolveSymLinks: Boolean): Boolean; +var + Buf: TStatBuf64; +begin + Result := GetFileStatus(FileName, Buf, ResolveSymLinks) = 0; + if Result then + LocalTime := FileDateToDateTime(Buf.st_mtime); +end; + +function GetFileLastWrite(const FileName: string; ResolveSymLinks: Boolean): Integer; +var + Buf: TStatBuf64; +begin + if GetFileStatus(FileName, Buf, ResolveSymLinks) = 0 then + Result := Buf.st_mtime + else + Result := -1; +end; + +{$ENDIF UNIX} + +{$IFDEF MSWINDOWS} + +function GetFileLastAccess(const FileName: string): TFileTime; +begin + Result := GetFileInformation(FileName).FindData.ftLastAccessTime; +end; + +{$IFNDEF WINSCP} +function GetFileLastAccess(const FileName: string; out LocalTime: TDateTime): Boolean; +var + FileInfo: TSearchRec; +begin + Result := GetFileInformation(FileName, FileInfo); + if Result then + LocalTime := FileTimeToLocalDateTime(GetFileInformation(FileName).FindData.ftLastAccessTime); +end; +{$ENDIF ~WINSCP} + +{$ENDIF MSWINDOWS} + +{$IFDEF UNIX} + +function GetFileLastAccess(const FileName: string; out TimeStamp: Integer; ResolveSymLinks: Boolean): Boolean; +var + Buf: TStatBuf64; +begin + Result := GetFileStatus(FileName, Buf, ResolveSymLinks) = 0; + if Result then + TimeStamp := Buf.st_atime +end; + +function GetFileLastAccess(const FileName: string; out LocalTime: TDateTime; ResolveSymLinks: Boolean): Boolean; +var + Buf: TStatBuf64; +begin + Result := GetFileStatus(FileName, Buf, ResolveSymLinks) = 0; + if Result then + LocalTime := FileDateToDateTime(Buf.st_atime); +end; + +function GetFileLastAccess(const FileName: string; ResolveSymLinks: Boolean): Integer; +var + Buf: TStatBuf64; +begin + if GetFileStatus(FileName, Buf, ResolveSymLinks) = 0 then + Result := Buf.st_atime + else + Result := -1; +end; + +{$ENDIF UNIX} + +{$IFDEF MSWINDOWS} + +function GetFileCreation(const FileName: string): TFileTime; +begin + Result := GetFileInformation(FileName).FindData.ftCreationTime; +end; + +{$IFNDEF WINSCP} +function GetFileCreation(const FileName: string; out LocalTime: TDateTime): Boolean; +var + FileInfo: TSearchRec; +begin + Result := GetFileInformation(FileName, FileInfo); + if Result then + LocalTime := FileTimeToLocalDateTime(GetFileInformation(FileName).FindData.ftCreationTime); +end; +{$ENDIF ~WINSCP} + +{$ENDIF MSWINDOWS} + +{$IFDEF UNIX} + +function GetFileLastAttrChange(const FileName: string; out TimeStamp: Integer; ResolveSymLinks: Boolean): Boolean; +var + Buf: TStatBuf64; +begin + Result := GetFileStatus(FileName, Buf, ResolveSymLinks) = 0; + if Result then + TimeStamp := Buf.st_ctime +end; + +function GetFileLastAttrChange(const FileName: string; out LocalTime: TDateTime; ResolveSymLinks: Boolean): Boolean; +var + Buf: TStatBuf64; +begin + Result := GetFileStatus(FileName, Buf, ResolveSymLinks) = 0; + if Result then + LocalTime := FileDateToDateTime(Buf.st_ctime); +end; + +function GetFileLastAttrChange(const FileName: string; ResolveSymLinks: Boolean): Integer; +var + Buf: TStatBuf64; +begin + if GetFileStatus(FileName, Buf, ResolveSymLinks) = 0 then + Result := Buf.st_ctime + else + Result := -1; +end; + +{$ENDIF UNIX} + +function GetModulePath(const Module: HMODULE): string; +var + L: Integer; +begin + L := MAX_PATH + 1; + SetLength(Result, L); + {$IFDEF MSWINDOWS} + L := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.GetModuleFileName(Module, Pointer(Result), L); + {$ENDIF MSWINDOWS} + {$IFDEF UNIX} + {$IFDEF FPC} + L := 0; // FIXME + {$ELSE ~FPC} + L := GetModuleFileName(Module, Pointer(Result), L); + {$ENDIF ~FPC} + {$ENDIF UNIX} + SetLength(Result, L); +end; + +function GetSizeOfFile(const FileName: string): Int64; +{$IFDEF MSWINDOWS} +var + FileAttributesEx: WIN32_FILE_ATTRIBUTE_DATA; + Size: TJclULargeInteger; +begin + Result := 0; + if GetFileAttributesEx(PChar(FileName), GetFileExInfoStandard, @FileAttributesEx) then + begin + Size.LowPart := FileAttributesEx.nFileSizeLow; + Size.HighPart := FileAttributesEx.nFileSizeHigh; + Result := Size.QuadPart; + end + else + RaiseLastOSError; +end; +{$ENDIF MSWINDOWS} +{$IFDEF UNIX} +var + Buf: TStatBuf64; +begin + if GetFileStatus(FileName, Buf, False) <> 0 then + RaiseLastOSError; + Result := Buf.st_size; +end; +{$ENDIF UNIX} + +{$IFDEF MSWINDOWS} +function GetSizeOfFile(Handle: THandle): Int64; overload; +var + Size: TJclULargeInteger; +begin + Size.LowPart := GetFileSize(Handle, @Size.HighPart); + Result := Size.QuadPart; +end; +{$ENDIF MSWINDOWS} + +function GetSizeOfFile(const FileInfo: TSearchRec): Int64; +{$IFDEF MSWINDOWS} +begin + Int64Rec(Result).Lo := FileInfo.FindData.nFileSizeLow; + Int64Rec(Result).Hi := FileInfo.FindData.nFileSizeHigh; +end; +{$ENDIF MSWINDOWS} +{$IFDEF UNIX} +var + Buf: TStatBuf64; +begin + // rr: Note that SysUtils.FindFirst/Next ignore files >= 2 GB under Linux, + // thus the following code is rather pointless at the moment of this writing. + // We apparently need to write our own set of Findxxx functions to overcome this limitation. + if GetFileStatus(FileInfo.PathOnly + FileInfo.Name, Buf, True) <> 0 then + Result := -1 + else + Result := Buf.st_size +end; +{$ENDIF UNIX} + +{$IFDEF MSWINDOWS} + +{$IFDEF FPC} +{ TODO : Move this over to JclWin32 when JclWin32 gets overhauled. } +function GetFileAttributesEx(lpFileName: PChar; + fInfoLevelId: TGetFileExInfoLevels; lpFileInformation: Pointer): BOOL; stdcall; +external kernel32 name 'GetFileAttributesExA'; +{$ENDIF FPC} + +function GetStandardFileInfo(const FileName: string): TWin32FileAttributeData; +var + Handle: THandle; + FileInfo: TByHandleFileInformation; +begin + Assert(FileName <> ''); + { TODO : Use RTDL-Version of GetFileAttributesEx } + if IsWin95 or IsWin95OSR2 or IsWinNT3 then + begin + Handle := CreateFile(PChar(FileName), GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, 0, 0); + if Handle <> INVALID_HANDLE_VALUE then + try + FileInfo.dwFileAttributes := 0; + if not GetFileInformationByHandle(Handle, FileInfo) then + raise EJclFileUtilsError.CreateResFmt(@RsFileUtilsAttrUnavailable, [FileName]); + Result.dwFileAttributes := FileInfo.dwFileAttributes; + Result.ftCreationTime := FileInfo.ftCreationTime; + Result.ftLastAccessTime := FileInfo.ftLastAccessTime; + Result.ftLastWriteTime := FileInfo.ftLastWriteTime; + Result.nFileSizeHigh := FileInfo.nFileSizeHigh; + Result.nFileSizeLow := FileInfo.nFileSizeLow; + finally + CloseHandle(Handle); + end + else + raise EJclFileUtilsError.CreateResFmt(@RsFileUtilsAttrUnavailable, [FileName]); + end + else + begin + if not GetFileAttributesEx(PChar(FileName), GetFileExInfoStandard, @Result) then + raise EJclFileUtilsError.CreateResFmt(@RsFileUtilsAttrUnavailable, [FileName]); + end; +end; + +{$ENDIF MSWINDOWS} + +{$IFDEF MSWINDOWS} +function IsDirectory(const FileName: string): Boolean; +var + R: DWORD; +begin + R := GetFileAttributes(PChar(FileName)); + Result := (R <> DWORD(-1)) and ((R and FILE_ATTRIBUTE_DIRECTORY) <> 0); +end; +{$ENDIF MSWINDOWS} +{$IFDEF UNIX} +function IsDirectory(const FileName: string; ResolveSymLinks: Boolean): Boolean; +var + Buf: TStatBuf64; +begin + Result := False; + if GetFileStatus(FileName, Buf, ResolveSymLinks) = 0 then + Result := S_ISDIR(Buf.st_mode); +end; +{$ENDIF UNIX} + +function IsRootDirectory(const CanonicFileName: string): Boolean; +{$IFDEF MSWINDOWS} +var + I: Integer; +begin + I := Pos(':\', CanonicFileName); + Result := (I > 0) and (I + 1 = Length(CanonicFileName)); +end; +{$ENDIF MSWINDOWS} +{$IFDEF UNIX} +begin + Result := CanonicFileName = DirDelimiter; +end; +{$ENDIF UNIX} + +{$IFDEF MSWINDOWS} + +function LockVolume(const Volume: string; var Handle: THandle): Boolean; +var + BytesReturned: DWORD; +begin + Result := False; + Handle := CreateFile(PChar('\\.\' + Volume), GENERIC_READ or GENERIC_WRITE, + FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, + FILE_FLAG_NO_BUFFERING, 0); + if Handle <> INVALID_HANDLE_VALUE then + begin + BytesReturned := 0; + Result := DeviceIoControl(Handle, FSCTL_LOCK_VOLUME, nil, 0, nil, 0, + BytesReturned, nil); + if not Result then + begin + CloseHandle(Handle); + Handle := INVALID_HANDLE_VALUE; + end; + end; +end; + +function OpenVolume(const Drive: Char): THandle; +var + VolumeName: array [0..6] of Char; +begin + VolumeName := '\\.\A:'; + VolumeName[4] := Drive; + Result := CreateFile(VolumeName, GENERIC_READ, FILE_SHARE_READ or FILE_SHARE_WRITE, + nil, OPEN_EXISTING, 0, 0); +end; + +{$ENDIF MSWINDOWS} + +type + // indicates the file time to set, used by SetFileTimesHelper and SetDirTimesHelper + TFileTimes = (ftLastAccess, ftLastWrite {$IFDEF MSWINDOWS}, ftCreation {$ENDIF}); + +{$IFDEF MSWINDOWS} +function SetFileTimesHelper(const FileName: string; const DateTime: TDateTime; Times: TFileTimes): Boolean; +var + Handle: THandle; + FileTime: TFileTime; + SystemTime: TSystemTime; +begin + Result := False; + Handle := CreateFile(PChar(FileName), GENERIC_WRITE, FILE_SHARE_READ, nil, + OPEN_EXISTING, 0, 0); + if Handle <> INVALID_HANDLE_VALUE then + try + //SysUtils.DateTimeToSystemTime(DateTimeToLocalDateTime(DateTime), SystemTime); + {$IFDEF HAS_UNITSCOPE}System.{$ENDIF}SysUtils.DateTimeToSystemTime(DateTime, SystemTime); + FileTime.dwLowDateTime := 0; + FileTime.dwHighDateTime := 0; + if {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.SystemTimeToFileTime(SystemTime, FileTime) then + begin + case Times of + ftLastAccess: + Result := SetFileTime(Handle, nil, @FileTime, nil); + ftLastWrite: + Result := SetFileTime(Handle, nil, nil, @FileTime); + ftCreation: + Result := SetFileTime(Handle, @FileTime, nil, nil); + end; + end; + finally + CloseHandle(Handle); + end; +end; +{$ENDIF MSWINDOWS} + +{$IFDEF UNIX} +function SetFileTimesHelper(const FileName: string; const DateTime: TDateTime; Times: TFileTimes): Boolean; +var + FileTime: Integer; + StatBuf: TStatBuf64; + TimeBuf: utimbuf; +begin + Result := False; + FileTime := DateTimeToFileDate(DateTime); + if GetFileStatus(FileName, StatBuf, False) = 0 then + begin + TimeBuf.actime := StatBuf.st_atime; + TimeBuf.modtime := StatBuf.st_mtime; + case Times of + ftLastAccess: + TimeBuf.actime := FileTime; + ftLastWrite: + TimeBuf.modtime := FileTime; + end; + Result := utime(PChar(FileName), @TimeBuf) = 0; + end; +end; +{$ENDIF UNIX} + +function SetFileLastAccess(const FileName: string; const DateTime: TDateTime): Boolean; +begin + Result := SetFileTimesHelper(FileName, DateTime, ftLastAccess); +end; + +function SetFileLastWrite(const FileName: string; const DateTime: TDateTime): Boolean; +begin + Result := SetFileTimesHelper(FileName, DateTime, ftLastWrite); +end; + +{$IFDEF MSWINDOWS} + +function SetFileCreation(const FileName: string; const DateTime: TDateTime): Boolean; +begin + Result := SetFileTimesHelper(FileName, DateTime, ftCreation); +end; + +// utility function for SetDirTimesHelper + +{$IFNDEF WINSCP} +function BackupPrivilegesEnabled: Boolean; +begin + Result := IsPrivilegeEnabled(SE_BACKUP_NAME) and IsPrivilegeEnabled(SE_RESTORE_NAME); +end; + +function SetDirTimesHelper(const DirName: string; const DateTime: TDateTime; + Times: TFileTimes; RequireBackupRestorePrivileges: Boolean): Boolean; +var + Handle: THandle; + FileTime: TFileTime; + SystemTime: TSystemTime; +begin + Result := False; + if IsDirectory(DirName) and (not RequireBackupRestorePrivileges or BackupPrivilegesEnabled) then + begin + Handle := CreateFile(PChar(DirName), GENERIC_WRITE, FILE_SHARE_READ, nil, + OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); + if Handle <> INVALID_HANDLE_VALUE then + try + {$IFDEF HAS_UNITSCOPE}System.{$ENDIF}SysUtils.DateTimeToSystemTime(DateTime, SystemTime); + FileTime.dwLowDateTime := 0; + FileTime.dwHighDateTime := 0; + {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.SystemTimeToFileTime(SystemTime, FileTime); + case Times of + ftLastAccess: + Result := SetFileTime(Handle, nil, @FileTime, nil); + ftLastWrite: + Result := SetFileTime(Handle, nil, nil, @FileTime); + ftCreation: + Result := SetFileTime(Handle, @FileTime, nil, nil); + end; + finally + CloseHandle(Handle); + end; + end; +end; + +function SetDirLastWrite(const DirName: string; const DateTime: TDateTime; RequireBackupRestorePrivileges: Boolean = True): Boolean; +begin + Result := SetDirTimesHelper(DirName, DateTime, ftLastWrite, RequireBackupRestorePrivileges); +end; + +function SetDirLastAccess(const DirName: string; const DateTime: TDateTime; RequireBackupRestorePrivileges: Boolean = True): Boolean; +begin + Result := SetDirTimesHelper(DirName, DateTime, ftLastAccess, RequireBackupRestorePrivileges); +end; + +function SetDirCreation(const DirName: string; const DateTime: TDateTime; RequireBackupRestorePrivileges: Boolean = True): Boolean; +begin + Result := SetDirTimesHelper(DirName, DateTime, ftCreation, RequireBackupRestorePrivileges); +end; +{$ENDIF ~WINSCP} + +procedure FillByteArray(var Bytes: array of Byte; Count: Cardinal; B: Byte); +begin + FillMemory(@Bytes[0], Count, B); +end; + +procedure ShredFile(const FileName: string; Times: Integer); +const + BUFSIZE = 4096; + ODD_FILL = $C1; + EVEN_FILL = $3E; +var + Fs: TFileStream; + Size: Integer; + N: Integer; + ContentPtr: array of Byte; +begin + Size := FileGetSize(FileName); + if Size > 0 then + begin + if Times < 0 then + Times := 2 + else + Times := Times * 2; + ContentPtr := nil; + Fs := TFileStream.Create(FileName, fmOpenReadWrite); + try + SetLength(ContentPtr, BUFSIZE); + while Times > 0 do + begin + if Times mod 2 = 0 then + FillByteArray(ContentPtr, BUFSIZE, EVEN_FILL) + else + FillByteArray(ContentPtr, BUFSIZE, ODD_FILL); + Fs.Seek(0, soBeginning); + N := Size div BUFSIZE; + while N > 0 do + begin + Fs.Write(ContentPtr[0], BUFSIZE); + Dec(N); + end; + N := Size mod BUFSIZE; + if N > 0 then + Fs.Write(ContentPtr[0], N); + FlushFileBuffers(Fs.Handle); + Dec(Times); + end; + finally + ContentPtr := nil; + Fs.Free; + DeleteFile(FileName); + end; + end + else + DeleteFile(FileName); +end; + +function UnlockVolume(var Handle: THandle): Boolean; +var + BytesReturned: DWORD; +begin + Result := False; + if Handle <> INVALID_HANDLE_VALUE then + begin + BytesReturned := 0; + Result := DeviceIoControl(Handle, FSCTL_UNLOCK_VOLUME, nil, 0, nil, 0, + BytesReturned, nil); + if Result then + begin + CloseHandle(Handle); + Handle := INVALID_HANDLE_VALUE; + end; + end; +end; + +{$ENDIF MSWINDOWS} + +{$IFDEF UNIX} + +function CreateSymbolicLink(const Name, Target: string): Boolean; +begin + Result := symlink(PChar(Target), PChar(Name)) = 0; +end; + +function SymbolicLinkTarget(const Name: string): string; +var + N, BufLen: Integer; +begin + BufLen := 128; + repeat + Inc(BufLen, BufLen); + SetLength(Result, BufLen); + N := readlink(PChar(Name), PChar(Result), BufLen); + if N < 0 then // Error + begin + Result := ''; + Exit; + end; + until N < BufLen; + SetLength(Result, N); +end; + +{$ENDIF UNIX} + +//=== File Version info routines ============================================= + +{$IFDEF MSWINDOWS} + +const + VerKeyNames: array [1..12] of string = + ('Comments', + 'CompanyName', + 'FileDescription', + 'FileVersion', + 'InternalName', + 'LegalCopyright', + 'LegalTradeMarks', + 'OriginalFilename', + 'ProductName', + 'ProductVersion', + 'SpecialBuild', + 'PrivateBuild'); + +function OSIdentToString(const OSIdent: DWORD): string; +begin + case OSIdent of + VOS_UNKNOWN: + Result := LoadResString(@RsVosUnknown); + VOS_DOS: + Result := LoadResString(@RsVosDos); + VOS_OS216: + Result := LoadResString(@RsVosOS216); + VOS_OS232: + Result := LoadResString(@RsVosOS232); + VOS_NT: + Result := LoadResString(@RsVosNT); + VOS__WINDOWS16: + Result := LoadResString(@RsVosWindows16); + VOS__PM16: + Result := LoadResString(@RsVosPM16); + VOS__PM32: + Result := LoadResString(@RsVosPM32); + VOS__WINDOWS32: + Result := LoadResString(@RsVosWindows32); + VOS_DOS_WINDOWS16: + Result := LoadResString(@RsVosDosWindows16); + VOS_DOS_WINDOWS32: + Result := LoadResString(@RsVosDosWindows32); + VOS_OS216_PM16: + Result := LoadResString(@RsVosOS216PM16); + VOS_OS232_PM32: + Result := LoadResString(@RsVosOS232PM32); + VOS_NT_WINDOWS32: + Result := LoadResString(@RsVosNTWindows32); + else + Result := ''; + end; + if Result = '' then + Result := LoadResString(@RsVosUnknown) + else + Result := Format(LoadResString(@RsVosDesignedFor), [Result]); +end; + +function OSFileTypeToString(const OSFileType: DWORD; const OSFileSubType: DWORD): string; +begin + case OSFileType of + VFT_UNKNOWN: + Result := LoadResString(@RsVftUnknown); + VFT_APP: + Result := LoadResString(@RsVftApp); + VFT_DLL: + Result := LoadResString(@RsVftDll); + VFT_DRV: + begin + case OSFileSubType of + VFT2_DRV_PRINTER: + Result := LoadResString(@RsVft2DrvPRINTER); + VFT2_DRV_KEYBOARD: + Result := LoadResString(@RsVft2DrvKEYBOARD); + VFT2_DRV_LANGUAGE: + Result := LoadResString(@RsVft2DrvLANGUAGE); + VFT2_DRV_DISPLAY: + Result := LoadResString(@RsVft2DrvDISPLAY); + VFT2_DRV_MOUSE: + Result := LoadResString(@RsVft2DrvMOUSE); + VFT2_DRV_NETWORK: + Result := LoadResString(@RsVft2DrvNETWORK); + VFT2_DRV_SYSTEM: + Result := LoadResString(@RsVft2DrvSYSTEM); + VFT2_DRV_INSTALLABLE: + Result := LoadResString(@RsVft2DrvINSTALLABLE); + VFT2_DRV_SOUND: + Result := LoadResString(@RsVft2DrvSOUND); + VFT2_DRV_COMM: + Result := LoadResString(@RsVft2DrvCOMM); + else + Result := ''; + end; + Result := Result + ' ' + LoadResString(@RsVftDrv); + end; + VFT_FONT: + begin + case OSFileSubType of + VFT2_FONT_RASTER: + Result := LoadResString(@RsVft2FontRASTER); + VFT2_FONT_VECTOR: + Result := LoadResString(@RsVft2FontVECTOR); + VFT2_FONT_TRUETYPE: + Result := LoadResString(@RsVft2FontTRUETYPE); + else + Result := ''; + end; + Result := Result + ' ' + LoadResString(@RsVftFont); + end; + VFT_VXD: + Result := LoadResString(@RsVftVxd); + VFT_STATIC_LIB: + Result := LoadResString(@RsVftStaticLib); + else + Result := ''; + end; + Result := TrimLeft(Result); +end; + +function VersionResourceAvailable(const FileName: string): Boolean; +var + Size: DWORD; + Handle: DWORD; + Buffer: string; +begin + Result := False; + Handle := 0; + Size := GetFileVersionInfoSize(PChar(FileName), Handle); + if Size > 0 then + begin + SetLength(Buffer, Size); + Result := GetFileVersionInfo(PChar(FileName), Handle, Size, PChar(Buffer)); + end; +end; + +function VersionResourceAvailable(const Window: HWND): Boolean; +begin + Result := VersionResourceAvailable(WindowToModuleFileName(Window)); +end; + +function VersionResourceAvailable(const Module: HMODULE): Boolean; +begin + if Module <> 0 then + Result :=VersionResourceAvailable(GetModulePath(Module)) + else + raise EJclError.CreateResFmt(@RsEModuleNotValid, [Module]); +end; + +function WindowToModuleFileName(const Window: HWND): string; +type + {$IFDEF SUPPORTS_UNICODE} + TGetModuleFileNameEx = function(hProcess: THandle; hModule: HMODULE; FileName: PWideChar; nSize: DWORD): DWORD; stdcall; + TQueryFullProcessImageName = function(HProcess: THandle; dwFlags: DWORD; lpExeName: PWideChar; lpdwSize: PDWORD): integer; stdcall; + {$ELSE ~SUPPORTS_UNICODE} + TGetModuleFileNameEx = function(hProcess: THandle; hModule: HMODULE; FileName: PAnsiChar; nSize: DWORD): DWORD; stdcall; + TQueryFullProcessImageName = function(HProcess: THandle; dwFlags: DWORD; lpExeName: PAnsiChar; lpdwSize: PDWORD): integer; stdcall; + {$ENDIF ~SUPPORTS_UNICODE} +var + FileName: array[0..300] of Char; + DllHinst: HMODULE; + ProcessID: DWORD; + HProcess: THandle; + GetModuleFileNameExAddress: TGetModuleFileNameEx; + QueryFullProcessImageNameAddress: TQueryFullProcessImageName; +begin + Result := ''; + if Window <> 0 then + begin + if not JclCheckWinVersion(5, 0) then // Win2k or newer required + raise EJclWin32Error.CreateRes(@RsEWindowsVersionNotSupported); + + {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.GetWindowThreadProcessId(Window, @ProcessID); + hProcess := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, false, ProcessID); + if hProcess <> 0 then + begin + try + if JclCheckWinVersion(6, 0) then // WinVista or newer + begin + DllHinst := LoadLibrary('Kernel32.dll'); + if DllHinst < HINSTANCE_ERROR then + begin + try + {$IFDEF SUPPORTS_UNICODE} + QueryFullProcessImageNameAddress := GetProcAddress(DllHinst, 'QueryFullProcessImageNameW'); + {$ELSE ~SUPPORTS_UNICODE} + QueryFullProcessImageNameAddress := GetProcAddress(DllHinst, 'QueryFullProcessImageNameA'); + {$ENDIF ~SUPPORTS_UNICODE} + if Assigned(QueryFullProcessImageNameAddress) then + begin + QueryFullProcessImageNameAddress(hProcess, 0, FileName, PDWORD(sizeof(FileName))); + Result := FileName; + end + else + begin + raise EJclError.CreateResFmt(@RsEFunctionNotFound, ['Kernel32.dll', 'QueryFullProcessImageName']); + end + finally + FreeLibrary(DllHinst); + end; + end + else + raise EJclError.CreateResFmt(@RsELibraryNotFound, ['Kernel32.dll']); + end + else + begin + DllHinst := LoadLibrary('Psapi.dll'); + if DllHinst < HINSTANCE_ERROR then + begin + try + {$IFDEF SUPPORTS_UNICODE} + GetModuleFileNameExAddress := GetProcAddress(DllHinst, 'GetModuleFileNameExW'); + {$ELSE ~SUPPORTS_UNICODE} + GetModuleFileNameExAddress := GetProcAddress(DllHinst, 'GetModuleFileNameExA'); + {$ENDIF ~SUPPORTS_UNICODE} + if Assigned(GetModuleFileNameExAddress) then + begin + GetModuleFileNameExAddress(hProcess, 0, FileName, sizeof(FileName)); + Result := FileName; + end + else + begin + raise EJclError.CreateResFmt(@RsEFunctionNotFound, ['Psapi.dll', 'GetModuleFileNameEx']); + end + finally + FreeLibrary(DllHinst); + end; + end + else + raise EJclError.CreateResFmt(@RsELibraryNotFound, ['Psapi.dll']); + end; + finally + CloseHandle(hProcess); + end; + end + else + raise EJclError.CreateResFmt(@RsEProcessNotValid, [ProcessID]); + end + else + raise EJclError.CreateResFmt(@RsEWindowNotValid, [Window]); +end; + +{$ENDIF MSWINDOWS} + +// Version Info formatting +function FormatVersionString(const HiV, LoV: Word): string; +begin + Result := Format('%u.%.2u', [HiV, LoV]); +end; + +function FormatVersionString(const Major, Minor, Build, Revision: Word): string; +begin + Result := Format('%u.%u.%u.%u', [Major, Minor, Build, Revision]); +end; + +{$IFDEF MSWINDOWS} + +function FormatVersionString(const FixedInfo: TVSFixedFileInfo; VersionFormat: TFileVersionFormat): string; +begin + case VersionFormat of + vfMajorMinor: + Result := Format('%u.%u', [HiWord(FixedInfo.dwFileVersionMS), LoWord(FixedInfo.dwFileVersionMS)]); + vfFull: + Result := Format('%u.%u.%u.%u', [HiWord(FixedInfo.dwFileVersionMS), LoWord(FixedInfo.dwFileVersionMS), + HiWord(FixedInfo.dwFileVersionLS), LoWord(FixedInfo.dwFileVersionLS)]); + end; +end; + +// Version Info extracting +procedure VersionExtractFileInfo(const FixedInfo: TVSFixedFileInfo; var Major, Minor, Build, Revision: Word); +begin + Major := HiWord(FixedInfo.dwFileVersionMS); + Minor := LoWord(FixedInfo.dwFileVersionMS); + Build := HiWord(FixedInfo.dwFileVersionLS); + Revision := LoWord(FixedInfo.dwFileVersionLS); +end; + +procedure VersionExtractProductInfo(const FixedInfo: TVSFixedFileInfo; var Major, Minor, Build, Revision: Word); +begin + Major := HiWord(FixedInfo.dwProductVersionMS); + Minor := LoWord(FixedInfo.dwProductVersionMS); + Build := HiWord(FixedInfo.dwProductVersionLS); + Revision := LoWord(FixedInfo.dwProductVersionLS); +end; + +// Fixed Version Info routines +function VersionFixedFileInfo(const FileName: string; var FixedInfo: TVSFixedFileInfo): Boolean; +var + Size, FixInfoLen: DWORD; + Handle: DWORD; + Buffer: string; + FixInfoBuf: PVSFixedFileInfo; +begin + Result := False; + Handle := 0; + Size := GetFileVersionInfoSize(PChar(FileName), Handle); + if Size > 0 then + begin + SetLength(Buffer, Size); + FixInfoLen := 0; + FixInfoBuf := nil; + if GetFileVersionInfo(PChar(FileName), Handle, Size, Pointer(Buffer)) and + VerQueryValue(Pointer(Buffer), DirDelimiter, Pointer(FixInfoBuf), FixInfoLen) and + (FixInfoLen = SizeOf(TVSFixedFileInfo)) then + begin + Result := True; + FixedInfo := FixInfoBuf^; + end; + end; +end; + +function VersionFixedFileInfoString(const FileName: string; VersionFormat: TFileVersionFormat; + const NotAvailableText: string): string; +var + FixedInfo: TVSFixedFileInfo; +begin + FixedInfo.dwSignature := 0; + if VersionFixedFileInfo(FileName, FixedInfo) then + Result := FormatVersionString(FixedInfo, VersionFormat) + else + Result := NotAvailableText; +end; + +//=== { TJclFileVersionInfo } ================================================ + +constructor TJclFileVersionInfo.Attach(VersionInfoData: Pointer; Size: Integer); +begin + SetLength(FBuffer, Size); + CopyMemory(PAnsiChar(FBuffer), VersionInfoData, Size); + ExtractData; +end; + +constructor TJclFileVersionInfo.Create(const FileName: string); +var + Handle: DWORD; + Size: DWORD; +begin + if not FileExists(FileName) then + raise EJclFileVersionInfoError.CreateResFmt(@RsFileUtilsFileDoesNotExist, [FileName]); + Handle := 0; + Size := GetFileVersionInfoSize(PChar(FileName), Handle); + if Size = 0 then + raise EJclFileVersionInfoError.CreateRes(@RsFileUtilsNoVersionInfo); + SetLength(FBuffer, Size); + Win32Check(GetFileVersionInfo(PChar(FileName), Handle, Size, PAnsiChar(FBuffer))); + ExtractData; +end; + +{$IFDEF MSWINDOWS} +{$IFDEF FPC} +constructor TJclFileVersionInfo.Create(const Window: HWND; Dummy: Pointer = nil); +{$ELSE} +constructor TJclFileVersionInfo.Create(const Window: HWND); +{$ENDIF} +begin + Create(WindowToModuleFileName(Window)); +end; + +constructor TJclFileVersionInfo.Create(const Module: HMODULE); +begin + if Module <> 0 then + Create(GetModulePath(Module)) + else + raise EJclError.CreateResFmt(@RsEModuleNotValid, [Module]); +end; +{$ENDIF MSWINDOWS} + +destructor TJclFileVersionInfo.Destroy; +begin + FreeAndNil(FItemList); + FreeAndNil(FItems); + inherited Destroy; +end; + +class function TJclFileVersionInfo.FileHasVersionInfo(const FileName: string): boolean; +var + Dummy: DWord; +begin + Result := GetFileVersionInfoSize(PChar(FileName), Dummy) <> 0; +end; + +procedure TJclFileVersionInfo.CheckLanguageIndex(Value: Integer); +begin + if (Value < 0) or (Value >= LanguageCount) then + raise EJclFileVersionInfoError.CreateRes(@RsFileUtilsLanguageIndex); +end; + +procedure TJclFileVersionInfo.CreateItemsForLanguage; +var + I: Integer; +begin + Items.Clear; + for I := 0 to FItemList.Count - 1 do + if Integer(FItemList.Objects[I]) = FLanguageIndex then + Items.AddObject(FItemList[I], Pointer(FLanguages[FLanguageIndex].Pair)); +end; + +procedure TJclFileVersionInfo.ExtractData; +var + Data, EndOfData: PAnsiChar; + Len, ValueLen, DataType: Word; + HeaderSize: Integer; + Key: string; + Error, IsUnicode: Boolean; + + procedure Padding(var DataPtr: PAnsiChar); + begin + while TJclAddr(DataPtr) and 3 <> 0 do + Inc(DataPtr); + end; + + procedure GetHeader; + var + P: PAnsiChar; + TempKey: PWideChar; + begin + Key := ''; + P := Data; + Len := PWord(P)^; + if Len = 0 then + begin + // do not raise error in the case of resources padded with 0 + while P < EndOfData do + begin + Error := P^ <> #0; + if Error then + Break; + Inc(P); + end; + Exit; + end; + Inc(P, SizeOf(Word)); + ValueLen := PWord(P)^; + Inc(P, SizeOf(Word)); + if IsUnicode then + begin + DataType := PWord(P)^; + Inc(P, SizeOf(Word)); + TempKey := PWideChar(P); + Inc(P, (lstrlenW(TempKey) + 1) * SizeOf(WideChar)); // length + #0#0 + Key := TempKey; + end + else + begin + DataType := 1; + Key := string(PAnsiChar(P)); + Inc(P, lstrlenA(PAnsiChar(P)) + 1); + end; + Padding(P); + HeaderSize := P - Data; + Data := P; + end; + + procedure FixKeyValue; + const + HexNumberCPrefix = '0x'; + var + I: Integer; + begin // GAPI32.DLL version 5.5.2803.1 contanins '04050x04E2' value + repeat + I := Pos(HexNumberCPrefix, Key); + if I > 0 then + Delete(Key, I, Length(HexNumberCPrefix)); + until I = 0; + I := 1; + while I <= Length(Key) do + if CharIsHexDigit(Key[I]) then + Inc(I) + else + Delete(Key, I, 1); + end; + + procedure ProcessStringInfo(Size: Integer); + var + EndPtr, EndStringPtr: PAnsiChar; + LangIndex: Integer; + LangIdRec: TLangIdRec; + Value: string; + begin + EndPtr := Data + Size; + LangIndex := 0; + while not Error and (Data < EndPtr) do + begin + GetHeader; // StringTable + FixKeyValue; + if (ValueLen <> 0) or (Length(Key) <> 8) then + begin + Error := True; + Break; + end; + Padding(Data); + LangIdRec.LangId := StrToIntDef('$' + Copy(Key, 1, 4), 0); + LangIdRec.CodePage := StrToIntDef('$' + Copy(Key, 5, 4), 0); + SetLength(FLanguages, LangIndex + 1); + FLanguages[LangIndex] := LangIdRec; + EndStringPtr := Data + Len - HeaderSize; + while not Error and (Data < EndStringPtr) do + begin + GetHeader; // string + case DataType of + 0: + if ValueLen in [1..4] then + Value := Format('$%.*x', [ValueLen * 2, PInteger(Data)^]) + else + begin + if (ValueLen > 0) and IsUnicode then + Value:=PWideChar(Data) + else + Value := ''; + end; + 1: + if ValueLen = 0 then + Value := '' + else + if IsUnicode then + begin + Value := WideCharLenToString(PWideChar(Data), ValueLen); + StrResetLength(Value); + end + else + Value := string(PAnsiChar(Data)); + else + Error := True; + Break; + end; + Inc(Data, Len - HeaderSize); + Padding(Data); // String.Padding + FItemList.AddObject(Format('%s=%s', [Key, Value]), Pointer(LangIndex)); + end; + Inc(LangIndex); + end; + end; + + procedure ProcessVarInfo; + var + TranslationIndex: Integer; + begin + GetHeader; // Var + if SameText(Key, 'Translation') then + begin + SetLength(FTranslations, ValueLen div SizeOf(TLangIdRec)); + for TranslationIndex := 0 to Length(FTranslations) - 1 do + begin + FTranslations[TranslationIndex] := PLangIdRec(Data)^; + Inc(Data, SizeOf(TLangIdRec)); + end; + end; + end; + +begin + FItemList := TStringList.Create; + FItems := TStringList.Create; + Data := Pointer(FBuffer); + Assert(TJclAddr(Data) mod 4 = 0); + IsUnicode := (PWord(Data + 4)^ in [0, 1]); + Error := True; + GetHeader; + EndOfData := Data + Len - HeaderSize; + if SameText(Key, 'VS_VERSION_INFO') and (ValueLen = SizeOf(TVSFixedFileInfo)) then + begin + FFixedInfo := PVSFixedFileInfo(Data); + Error := FFixedInfo.dwSignature <> $FEEF04BD; + Inc(Data, ValueLen); // VS_FIXEDFILEINFO + Padding(Data); // VS_VERSIONINFO.Padding2 + while not Error and (Data < EndOfData) do + begin + GetHeader; + Inc(Data, ValueLen); // some files (VREDIR.VXD 4.00.1111) has non zero value of ValueLen + Dec(Len, HeaderSize + ValueLen); + if SameText(Key, 'StringFileInfo') then + ProcessStringInfo(Len) + else + if SameText(Key, 'VarFileInfo') then + ProcessVarInfo + else + Break; + end; + ExtractFlags; + CreateItemsForLanguage; + end; + if Error then + raise EJclFileVersionInfoError.CreateRes(@RsFileUtilsNoVersionInfo); +end; + +procedure TJclFileVersionInfo.ExtractFlags; +var + Masked: DWORD; +begin + FFileFlags := []; + Masked := FFixedInfo^.dwFileFlags and FFixedInfo^.dwFileFlagsMask; + if (Masked and VS_FF_DEBUG) <> 0 then + Include(FFileFlags, ffDebug); + if (Masked and VS_FF_INFOINFERRED) <> 0 then + Include(FFileFlags, ffInfoInferred); + if (Masked and VS_FF_PATCHED) <> 0 then + Include(FFileFlags, ffPatched); + if (Masked and VS_FF_PRERELEASE) <> 0 then + Include(FFileFlags, ffPreRelease); + if (Masked and VS_FF_PRIVATEBUILD) <> 0 then + Include(FFileFlags, ffPrivateBuild); + if (Masked and VS_FF_SPECIALBUILD) <> 0 then + Include(FFileFlags, ffSpecialBuild); +end; + +function TJclFileVersionInfo.GetBinFileVersion: string; +begin + Result := Format('%u.%u.%u.%u', [HiWord(FFixedInfo^.dwFileVersionMS), + LoWord(FFixedInfo^.dwFileVersionMS), HiWord(FFixedInfo^.dwFileVersionLS), + LoWord(FFixedInfo^.dwFileVersionLS)]); +end; + +function TJclFileVersionInfo.GetBinProductVersion: string; +begin + Result := Format('%u.%u.%u.%u', [HiWord(FFixedInfo^.dwProductVersionMS), + LoWord(FFixedInfo^.dwProductVersionMS), HiWord(FFixedInfo^.dwProductVersionLS), + LoWord(FFixedInfo^.dwProductVersionLS)]); +end; + +function TJclFileVersionInfo.GetCustomFieldValue(const FieldName: string): string; +var + ItemIndex: Integer; +begin + if FieldName <> '' then + begin + ItemIndex := FItems.IndexOfName(FieldName); + if ItemIndex <> -1 then + //Return the required value, the value the user passed in was found. + Result := FItems.Values[FieldName] + else + raise EJclFileVersionInfoError.CreateResFmt(@RsFileUtilsValueNotFound, [FieldName]); + end + else + raise EJclFileVersionInfoError.CreateRes(@RsFileUtilsEmptyValue); +end; + +function TJclFileVersionInfo.GetFileOS: DWORD; +begin + Result := FFixedInfo^.dwFileOS; +end; + +function TJclFileVersionInfo.GetFileSubType: DWORD; +begin + Result := FFixedInfo^.dwFileSubtype; +end; + +function TJclFileVersionInfo.GetFileType: DWORD; +begin + Result := FFixedInfo^.dwFileType; +end; + +function TJclFileVersionInfo.GetFileVersionBuild: string; +var + Left: Integer; +begin + Result := FileVersion; + StrReplaceChar(Result, ',', '.'); + Left := CharLastPos(Result, '.') + 1; + Result := StrMid(Result, Left, Length(Result) - Left + 1); + Result := Trim(Result); +end; + +function TJclFileVersionInfo.GetFileVersionMajor: string; +begin + Result := FileVersion; + StrReplaceChar(Result, ',', '.'); + Result := StrBefore('.', Result); + Result := Trim(Result); +end; + +function TJclFileVersionInfo.GetFileVersionMinor: string; +var + Left, Right: integer; +begin + Result := FileVersion; + StrReplaceChar(Result, ',', '.'); + Left := CharPos(Result, '.') + 1; // skip major + Right := CharPos(Result, '.', Left) {-1}; + Result := StrMid(Result, Left, Right - Left {+1}); + Result := Trim(Result); +end; + +function TJclFileVersionInfo.GetFileVersionRelease: string; +var + Left, Right: Integer; +begin + Result := FileVersion; + StrReplaceChar(Result, ',', '.'); + Left := CharPos(Result, '.') + 1; // skip major + Left := CharPos(Result, '.', Left) + 1; // skip minor + Right := CharPos(Result, '.', Left) {-1}; + Result := StrMid(Result, Left, Right - Left {+1}); + Result := Trim(Result); +end; + +function TJclFileVersionInfo.GetFixedInfo: TVSFixedFileInfo; +begin + Result := FFixedInfo^; +end; + +function TJclFileVersionInfo.GetItems: TStrings; +begin + Result := FItems; +end; + +function TJclFileVersionInfo.GetLanguageCount: Integer; +begin + Result := Length(FLanguages); +end; + +function TJclFileVersionInfo.GetLanguageIds(Index: Integer): string; +begin + CheckLanguageIndex(Index); + Result := VersionLanguageId(FLanguages[Index]); +end; + +function TJclFileVersionInfo.GetLanguages(Index: Integer): TLangIdRec; +begin + CheckLanguageIndex(Index); + Result := FLanguages[Index]; +end; + +function TJclFileVersionInfo.GetLanguageNames(Index: Integer): string; +begin + CheckLanguageIndex(Index); + Result := VersionLanguageName(FLanguages[Index].LangId); +end; + +function TJclFileVersionInfo.GetTranslationCount: Integer; +begin + Result := Length(FTranslations); +end; + +function TJclFileVersionInfo.GetTranslations(Index: Integer): TLangIdRec; +begin + Result := FTranslations[Index]; +end; + +function TJclFileVersionInfo.GetProductVersionBuild: string; +var + Left: Integer; +begin + Result := ProductVersion; + StrReplaceChar(Result, ',', '.'); + Left := CharLastPos(Result, '.') + 1; + Result := StrMid(Result, Left, Length(Result) - Left + 1); + Result := Trim(Result); +end; + +function TJclFileVersionInfo.GetProductVersionMajor: string; +begin + Result := ProductVersion; + StrReplaceChar(Result, ',', '.'); + Result := StrBefore('.', Result); + Result := Trim(Result); +end; + +function TJclFileVersionInfo.GetProductVersionMinor: string; +var + Left, Right: integer; +begin + Result := ProductVersion; + StrReplaceChar(Result, ',', '.'); + Left := CharPos(Result, '.') + 1; // skip major + Right := CharPos(Result, '.', Left) {-1}; + Result := StrMid(Result, Left, Right - Left {+1}); + Result := Trim(Result); +end; + +function TJclFileVersionInfo.GetProductVersionRelease: string; +var + Left, Right: Integer; +begin + Result := ProductVersion; + StrReplaceChar(Result, ',', '.'); + Left := CharPos(Result, '.') + 1; // skip major + Left := CharPos(Result, '.', Left) + 1; // skip minor + Right := CharPos(Result, '.', Left) {-1}; + Result := StrMid(Result, Left, Right - Left {+1}); + Result := Trim(Result); +end; + +function TJclFileVersionInfo.GetVersionKeyValue(Index: Integer): string; +begin + Result := Items.Values[VerKeyNames[Index]]; +end; + +procedure TJclFileVersionInfo.SetLanguageIndex(const Value: Integer); +begin + CheckLanguageIndex(Value); + if FLanguageIndex <> Value then + begin + FLanguageIndex := Value; + CreateItemsForLanguage; + end; +end; + +function TJclFileVersionInfo.TranslationMatchesLanguages(Exact: Boolean): Boolean; +var + TransIndex, LangIndex: Integer; + TranslationPair: DWORD; +begin + Result := (LanguageCount = TranslationCount) or (not Exact and (TranslationCount > 0)); + if Result then + for TransIndex := 0 to TranslationCount - 1 do + begin + TranslationPair := FTranslations[TransIndex].Pair; + LangIndex := LanguageCount - 1; + while (LangIndex >= 0) and (TranslationPair <> FLanguages[LangIndex].Pair) do + Dec(LangIndex); + if LangIndex < 0 then + begin + Result := False; + Break; + end; + end; +end; + +class function TJclFileVersionInfo.VersionLanguageId(const LangIdRec: TLangIdRec): string; +begin + with LangIdRec do + Result := Format('%.4x%.4x', [LangId, CodePage]); +end; + +class function TJclFileVersionInfo.VersionLanguageName(const LangId: Word): string; +var + R: DWORD; +begin + SetLength(Result, MAX_PATH); + R := VerLanguageName(LangId, PChar(Result), MAX_PATH); + SetLength(Result, R); +end; + +{$ENDIF MSWINDOWS} + +//=== { TJclFileMaskComparator } ============================================= + +constructor TJclFileMaskComparator.Create; +begin + inherited Create; + FSeparator := DirSeparator; +end; + +function TJclFileMaskComparator.Compare(const NameExt: string): Boolean; +var + I: Integer; + NamePart, ExtPart: string; + NameWild, ExtWild: Boolean; +begin + Result := False; + I := StrLastPos('.', NameExt); + if I = 0 then + begin + NamePart := NameExt; + ExtPart := ''; + end + else + begin + NamePart := Copy(NameExt, 1, I - 1); + ExtPart := Copy(NameExt, I + 1, Length(NameExt)); + end; + for I := 0 to Length(FNames) - 1 do + begin + NameWild := FWildChars[I] and 1 = 1; + ExtWild := FWildChars[I] and 2 = 2; + if ((not NameWild and StrSame(FNames[I], NamePart)) or + (NameWild and (StrMatches(FNames[I], NamePart, 1)))) and + ((not ExtWild and StrSame(FExts[I], ExtPart)) or + (ExtWild and (StrMatches(FExts[I], ExtPart, 1)))) then + begin + Result := True; + Break; + end; + end; +end; + +procedure TJclFileMaskComparator.CreateMultiMasks; +var + List: TStringList; + I, N: Integer; + NS, ES: string; +begin + FExts := nil; + FNames := nil; + FWildChars := nil; + List := TStringList.Create; + try + StrToStrings(FFileMask, FSeparator, List); + SetLength(FExts, List.Count); + SetLength(FNames, List.Count); + SetLength(FWildChars, List.Count); + for I := 0 to List.Count - 1 do + begin + N := StrLastPos('.', List[I]); + if N = 0 then + begin + NS := List[I]; + ES := ''; + end + else + begin + NS := Copy(List[I], 1, N - 1); + ES := Copy(List[I], N + 1, 255); + end; + FNames[I] := NS; + FExts[I] := ES; + N := 0; + if StrContainsChars(NS, CharIsWildcard, False) then + N := N or 1; + if StrContainsChars(ES, CharIsWildcard, False) then + N := N or 2; + FWildChars[I] := N; + end; + finally + List.Free; + end; +end; + +function TJclFileMaskComparator.GetCount: Integer; +begin + Result := Length(FWildChars); +end; + +function TJclFileMaskComparator.GetExts(Index: Integer): string; +begin + Result := FExts[Index]; +end; + +function TJclFileMaskComparator.GetMasks(Index: Integer): string; +begin + Result := FNames[Index] + '.' + FExts[Index]; +end; + +function TJclFileMaskComparator.GetNames(Index: Integer): string; +begin + Result := FNames[Index]; +end; + +procedure TJclFileMaskComparator.SetFileMask(const Value: string); +begin + FFileMask := Value; + CreateMultiMasks; +end; + +procedure TJclFileMaskComparator.SetSeparator(const Value: Char); +begin + if FSeparator <> Value then + begin + FSeparator := Value; + CreateMultiMasks; + end; +end; + +function AdvBuildFileList(const Path: string; const Attr: Integer; const Files: TStrings; + const AttributeMatch: TJclAttributeMatch; const Options: TFileListOptions; + const SubfoldersMask: string; const FileMatchFunc: TFileMatchFunc): Boolean; +var + FileMask: string; + RootDir: string; + Folders: TStringList; + CurrentItem: Integer; + Counter: Integer; + FindAttr: Integer; + + procedure BuildFolderList; + var + FindInfo: TSearchRec; + Rslt: Integer; + begin + Counter := Folders.Count - 1; + CurrentItem := 0; + + while CurrentItem <= Counter do + begin + // searching for subfolders (including hidden ones) + Rslt := FindFirst(Folders[CurrentItem] + '*.*', faAnyFile, FindInfo); + try + while Rslt = 0 do + begin + if (FindInfo.Name <> '.') and (FindInfo.Name <> '..') and + (FindInfo.Attr and faDirectory = faDirectory) then + Folders.Add(Folders[CurrentItem] + FindInfo.Name + DirDelimiter); + + Rslt := FindNext(FindInfo); + end; + finally + FindClose(FindInfo); + end; + Counter := Folders.Count - 1; + Inc(CurrentItem); + end; + end; + + procedure FillFileList(CurrentCounter: Integer); + var + FindInfo: TSearchRec; + Rslt: Integer; + CurrentFolder: string; + Matches: Boolean; + begin + CurrentFolder := Folders[CurrentCounter]; + + Rslt := FindFirst(CurrentFolder + FileMask, FindAttr, FindInfo); + + try + while Rslt = 0 do + begin + Matches := False; + + case AttributeMatch of + amAny: + Matches := True; + amExact: + Matches := Attr = FindInfo.Attr; + amSubSetOf: + Matches := (Attr and FindInfo.Attr) = Attr; + amSuperSetOf: + Matches := (Attr and FindInfo.Attr) = FindInfo.Attr; + amCustom: + if Assigned(FileMatchFunc) then + Matches := FileMatchFunc(Attr, FindInfo); + end; + + if Matches then + if flFullNames in Options then + Files.Add(CurrentFolder + FindInfo.Name) + else + Files.Add(FindInfo.Name); + + Rslt := FindNext(FindInfo); + end; + finally + FindClose(FindInfo); + end; + end; + +begin + Assert(Assigned(Files)); + FileMask := ExtractFileName(Path); + RootDir := ExtractFilePath(Path); + + Folders := TStringList.Create; + Files.BeginUpdate; + try + Folders.Add(RootDir); + + case AttributeMatch of + amExact, amSuperSetOf: + FindAttr := Attr; + else + FindAttr := faAnyFile; + end; + + // here's the recursive search for nested folders + + if flRecursive in Options then + BuildFolderList; + + for Counter := 0 to Folders.Count - 1 do + begin + if (((flMaskedSubfolders in Options) and (StrMatches(SubfoldersMask, + Folders[Counter], 1))) or (not (flMaskedSubfolders in Options))) then + FillFileList(Counter); + end; + finally + Folders.Free; + Files.EndUpdate; + end; + Result := True; +end; + +function VerifyFileAttributeMask(var RejectedAttributes, RequiredAttributes: Integer): Boolean; +begin + if RequiredAttributes and faNormalFile <> 0 then + RejectedAttributes := not faNormalFile or RejectedAttributes; + Result := RequiredAttributes and RejectedAttributes = 0; +end; + +function AttributeMatch(FileAttributes, RejectedAttr, RequiredAttr: Integer): Boolean; +begin + if FileAttributes = 0 then + FileAttributes := faNormalFile; + {$IFDEF MSWINDOWS} + RequiredAttr := RequiredAttr and not faUnixSpecific; + {$ENDIF MSWINDOWS} + {$IFDEF UNIX} + RequiredAttr := RequiredAttr and not faWindowsSpecific; + {$ENDIF UNIX} + Result := (FileAttributes and RejectedAttr = 0) + and (FileAttributes and RequiredAttr = RequiredAttr); +end; + +function IsFileAttributeMatch(FileAttributes, RejectedAttributes, + RequiredAttributes: Integer): Boolean; +begin + VerifyFileAttributeMask(RejectedAttributes, RequiredAttributes); + Result := AttributeMatch(FileAttributes, RejectedAttributes, RequiredAttributes); +end; + +function FileAttributesStr(const FileInfo: TSearchRec): string; +{$IFDEF MSWINDOWS} +const + SAllAttrSet = 'rahs'; // readonly, archive, hidden, system + Attributes: array [1..4] of Integer = + (faReadOnly, faArchive, faHidden, faSysFile); +var + I: Integer; +begin + Result := SAllAttrSet; + for I := Low(Attributes) to High(Attributes) do + if (FileInfo.Attr and Attributes[I]) = 0 then + Result[I] := '-'; +end; +{$ENDIF MSWINDOWS} +{$IFDEF UNIX} +const + SAllAttrSet = 'drwxrwxrwx'; +var + I: Integer; + Flag: Cardinal; +begin + Result := SAllAttrSet; + if FileInfo.Attr and faDirectory = 0 then + Result[1] := '-'; // no directory + Flag := 1 shl 8; + for I := 2 to 10 do + begin + if FileInfo.Mode and Flag = 0 then + Result[I] := '-'; + Flag := Flag shr 1; + end; +end; +{$ENDIF UNIX} + +function IsFileNameMatch(FileName: string; const Mask: string; + const CaseSensitive: Boolean): Boolean; +begin + Result := True; + {$IFDEF MSWINDOWS} + if (Mask = '') or (Mask = '*') or (Mask = '*.*') then + Exit; + if Pos('.', FileName) = 0 then + FileName := FileName + '.'; // file names w/o extension match '*.' + {$ENDIF MSWINDOWS} + {$IFDEF UNIX} + if (Mask = '') or (Mask = '*') then + Exit; + {$ENDIF UNIX} + if CaseSensitive then + Result := StrMatches(Mask, FileName) + else + Result := StrMatches(AnsiUpperCase(Mask), AnsiUpperCase(FileName)); +end; + +// author: Robert Rossmair + +function CanonicalizedSearchPath(const Directory: string): string; +begin + Result := PathCanonicalize(Directory); + {$IFDEF MSWINDOWS} + // avoid changing "X:" (current directory on drive X:) into "X:\" (root dir.) + if Result[Length(Result)] <> ':' then + {$ENDIF MSWINDOWS} + Result := PathAddSeparator(Result); + // strip leading "./" resp. ".\" + if Pos('.' + DirDelimiter, Result) = 1 then + Result := Copy(Result, 3, Length(Result) - 2); +end; + +procedure EnumFiles(const Path: string; HandleFile: TFileHandlerEx; + RejectedAttributes: Integer; RequiredAttributes: Integer; Abort: PBoolean); +var + Directory: string; + FileInfo: TSearchRec; + Attr: Integer; + Found: Boolean; +begin + Assert(Assigned(HandleFile)); + Assert(VerifyFileAttributeMask(RejectedAttributes, RequiredAttributes), + LoadResString(@RsFileSearchAttrInconsistency)); + + Directory := ExtractFilePath(Path); + + Attr := faAnyFile and not RejectedAttributes; + + Found := {$IFDEF HAS_UNITSCOPE}System.{$ENDIF}SysUtils.FindFirst(Path, Attr, FileInfo) = 0; + try + while Found do + begin + if (Abort <> nil) and LongBool(Abort^) then + Exit; + if AttributeMatch(FileInfo.Attr, RejectedAttributes, RequiredAttributes) then + if ((FileInfo.Attr and faDirectory = 0) + or ((FileInfo.Name <> '.') and (FileInfo.Name <> '..'))) then + HandleFile(Directory, FileInfo); + Found := FindNext(FileInfo) = 0; + end; + finally + FindClose(FileInfo); + end; +end; + +procedure EnumFiles(const Path: string; HandleFile: TFileInfoHandlerEx; + RejectedAttributes: Integer; RequiredAttributes: Integer; Abort: PBoolean); +var + FileInfo: TSearchRec; + Attr: Integer; + Found: Boolean; +begin + Assert(Assigned(HandleFile)); + Assert(VerifyFileAttributeMask(RejectedAttributes, RequiredAttributes), + LoadResString(@RsFileSearchAttrInconsistency)); + + Attr := faAnyFile and not RejectedAttributes; + + Found := {$IFDEF HAS_UNITSCOPE}System.{$ENDIF}SysUtils.FindFirst(Path, Attr, FileInfo) = 0; + try + while Found do + begin + if (Abort <> nil) and LongBool(Abort^) then + Exit; + if AttributeMatch(FileInfo.Attr, RejectedAttributes, RequiredAttributes) then + if ((FileInfo.Attr and faDirectory = 0) + or ((FileInfo.Name <> '.') and (FileInfo.Name <> '..'))) then + HandleFile(FileInfo); + Found := FindNext(FileInfo) = 0; + end; + finally + FindClose(FileInfo); + end; +end; + +procedure EnumDirectories(const Root: string; const HandleDirectory: TFileHandler; + const IncludeHiddenDirectories: Boolean; const SubDirectoriesMask: string; + Abort: PBoolean {$IFDEF UNIX}; ResolveSymLinks: Boolean {$ENDIF}); +var + RootDir: string; + Attr: Integer; + + procedure Process(const Directory: string); + var + DirInfo: TSearchRec; + SubDir: string; + Found: Boolean; + begin + HandleDirectory(Directory); + + Found := {$IFDEF HAS_UNITSCOPE}System.{$ENDIF}SysUtils.FindFirst(Directory + '*', Attr, DirInfo) = 0; + try + while Found do + begin + if (Abort <> nil) and LongBool(Abort^) then + Exit; + if (DirInfo.Name <> '.') and (DirInfo.Name <> '..') and + {$IFDEF UNIX} + (IncludeHiddenDirectories or (Pos('.', DirInfo.Name) <> 1)) and + ((DirInfo.Attr and faSymLink = 0) or ResolveSymLinks) and + {$ENDIF UNIX} + (DirInfo.Attr and faDirectory <> 0) then + begin + SubDir := Directory + DirInfo.Name + DirDelimiter; + if (SubDirectoriesMask = '') or StrMatches(SubDirectoriesMask, SubDir, Length(RootDir)) then + Process(SubDir); + end; + Found := FindNext(DirInfo) = 0; + end; + finally + FindClose(DirInfo); + end; + end; + +begin + Assert(Assigned(HandleDirectory)); + RootDir := CanonicalizedSearchPath(Root); + + if IncludeHiddenDirectories then + Attr := faDirectory + faHidden // no effect on Linux + else + Attr := faDirectory; + + Process(RootDir); +end; + +//=== { TJclCustomFileAttributeMask } ============================================== + +constructor TJclCustomFileAttrMask.Create; +begin + inherited Create; + FRejectedAttr := faRejectedByDefault; +end; + +procedure TJclCustomFileAttrMask.Assign(Source: TPersistent); +begin + if Source is TJclCustomFileAttrMask then + begin + Required := TJclCustomFileAttrMask(Source).Required; + Rejected := TJclCustomFileAttrMask(Source).Rejected; + end + else + inherited Assign(Source); +end; + +procedure TJclCustomFileAttrMask.Clear; +begin + Rejected := 0; + Required := 0; +end; + +procedure TJclCustomFileAttrMask.DefineProperties(Filer: TFiler); +var + Ancestor: TJclCustomFileAttrMask; + Attr: Integer; +begin + Attr := 0; + Ancestor := TJclCustomFileAttrMask(Filer.Ancestor); + if Assigned(Ancestor) then + Attr := Ancestor.FRequiredAttr; + Filer.DefineProperty('Required', ReadRequiredAttributes, WriteRequiredAttributes, + Attr <> FRequiredAttr); + if Assigned(Ancestor) then + Attr := Ancestor.FRejectedAttr; + Filer.DefineProperty('Rejected', ReadRejectedAttributes, WriteRejectedAttributes, + Attr <> FRejectedAttr); +end; + +function TJclCustomFileAttrMask.Match(FileAttributes: Integer): Boolean; +begin + Result := AttributeMatch(FileAttributes, Rejected, Required); +end; + +function TJclCustomFileAttrMask.Match(const FileInfo: TSearchRec): Boolean; +begin + Result := Match(FileInfo.Attr); +end; + +function TJclCustomFileAttrMask.GetAttr(Index: Integer): TAttributeInterest; +begin + if ((FRequiredAttr and Index) <> 0) or (Index = faNormalFile) and + (FRejectedAttr = not faNormalFile) then + Result := aiRequired + else + if (FRejectedAttr and Index) <> 0 then + Result := aiRejected + else + Result := aiIgnored; +end; + +procedure TJclCustomFileAttrMask.ReadRejectedAttributes(Reader: TReader); +begin + FRejectedAttr := Reader.ReadInteger; +end; + +procedure TJclCustomFileAttrMask.ReadRequiredAttributes(Reader: TReader); +begin + FRequiredAttr := Reader.ReadInteger; +end; + +procedure TJclCustomFileAttrMask.SetAttr(Index: Integer; const Value: TAttributeInterest); +begin + case Value of + aiIgnored: + begin + FRequiredAttr := FRequiredAttr and not Index; + FRejectedAttr := FRejectedAttr and not Index; + end; + aiRejected: + begin + FRequiredAttr := FRequiredAttr and not Index; + FRejectedAttr := FRejectedAttr or Index; + end; + aiRequired: + begin + if Index = faNormalFile then + begin + FRequiredAttr := faNormalFile; + FRejectedAttr := not faNormalFile; + end + else + begin + FRequiredAttr := FRequiredAttr or Index; + FRejectedAttr := FRejectedAttr and not Index; + end; + end; + end; +end; + +procedure TJclCustomFileAttrMask.WriteRejectedAttributes(Writer: TWriter); +begin + Writer.WriteInteger(FRejectedAttr); +end; + +procedure TJclCustomFileAttrMask.WriteRequiredAttributes(Writer: TWriter); +begin + Writer.WriteInteger(FRequiredAttr); +end; + +//=== { TJclFileAttributeMask } ============================================== + +procedure TJclFileAttributeMask.ReadVolumeID(Reader: TReader); +begin + // Nothing, we are not interested in the value of the VolumeID property, + // this procedure and the associated DefineProperty call are here only + // to allow reading legacy DFMs that have this property defined. +end; + +procedure TJclFileAttributeMask.DefineProperties(Filer: TFiler); +begin + inherited DefineProperties(Filer); + + Filer.DefineProperty('VolumeID', ReadVolumeID, nil, False); +end; + +//=== { TJclFileSearchOptions } ============================================== + +constructor TJclFileSearchOptions.Create; +begin + inherited Create; + + FAttributeMask := TJclFileAttributeMask.Create; + FRootDirectories := TStringList.Create; + FRootDirectories.Add('.'); + FFileMasks := TStringList.Create; + FFileMasks.Add('*'); + FSubDirectoryMask := '*'; + FOptions := [fsIncludeSubDirectories]; + FLastChangeAfter := MinDateTime; + FLastChangeBefore := MaxDateTime; + {$IFDEF UNIX} + FCaseSensitiveSearch := True; + {$ENDIF UNIX} +end; + +destructor TJclFileSearchOptions.Destroy; +begin + FAttributeMask.Free; + FFileMasks.Free; + FRootDirectories.Free; + + inherited Destroy; +end; + +procedure TJclFileSearchOptions.Assign(Source: TPersistent); +var + Src: TJclFileSearchOptions; +begin + if Source is TJclFileSearchOptions then + begin + Src := TJclFileSearchOptions(Source); + FCaseSensitiveSearch := Src.FCaseSensitiveSearch; + FileMasks.Assign(Src.FileMasks); + RootDirectory := Src.RootDirectory; + SubDirectoryMask := Src.SubDirectoryMask; + AttributeMask := Src.AttributeMask; + Options := Src.Options; + FileSizeMin := Src.FileSizeMin; + FileSizeMax := Src.FileSizeMax; + LastChangeAfter := Src.LastChangeAfter; + LastChangeBefore := Src.LastChangeBefore; + end + else + inherited Assign(Source); +end; + +function TJclFileSearchOptions.GetAttributeMask: TJclFileAttributeMask; +begin + Result := FAttributeMask; +end; + +function TJclFileSearchOptions.GetCaseSensitiveSearch: Boolean; +begin + Result := FCaseSensitiveSearch; +end; + +function TJclFileSearchOptions.GetFileMask: string; +begin + Result := StringsToStr(FileMasks, DirSeparator, False); +end; + +function TJclFileSearchOptions.GetFileMasks: TStrings; +begin + Result := FFileMasks; +end; + +function TJclFileSearchOptions.GetFileSizeMax: Int64; +begin + Result := FFileSizeMax; +end; + +function TJclFileSearchOptions.GetFileSizeMin: Int64; +begin + Result := FFileSizeMin; +end; + +function TJclFileSearchOptions.GetIncludeHiddenSubDirectories: Boolean; +begin + Result := fsIncludeHiddenSubDirectories in Options; +end; + +function TJclFileSearchOptions.GetIncludeSubDirectories: Boolean; +begin + Result := fsIncludeSubDirectories in Options; +end; + +function TJclFileSearchOptions.GetLastChangeAfter: TDateTime; +begin + Result := FLastChangeAfter; +end; + +function TJclFileSearchOptions.GetLastChangeAfterStr: string; +begin + Result := DateTimeToStr(LastChangeAfter); +end; + +function TJclFileSearchOptions.GetLastChangeBefore: TDateTime; +begin + Result := FLastChangeBefore; +end; + +function TJclFileSearchOptions.GetLastChangeBeforeStr: string; +begin + Result := DateTimeToStr(LastChangeBefore); +end; + +function TJclFileSearchOptions.GetOption( + const Option: TFileSearchOption): Boolean; +begin + Result := Option in FOptions; +end; + +function TJclFileSearchOptions.GetOptions: TFileSearchoptions; +begin + Result := FOptions; +end; + +function TJclFileSearchOptions.GetRootDirectories: TStrings; +begin + Result := FRootDirectories; +end; + +function TJclFileSearchOptions.GetRootDirectory: string; +begin + if FRootDirectories.Count = 1 then + Result := FRootDirectories.Strings[0] + else + Result := ''; +end; + +function TJclFileSearchOptions.GetSubDirectoryMask: string; +begin + Result := FSubDirectoryMask; +end; + +function TJclFileSearchOptions.IsLastChangeAfterStored: Boolean; +begin + Result := FLastChangeAfter <> MinDateTime; +end; + +function TJclFileSearchOptions.IsLastChangeBeforeStored: Boolean; +begin + Result := FLastChangeBefore <> MaxDateTime; +end; + +procedure TJclFileSearchOptions.SetAttributeMask( + const Value: TJclFileAttributeMask); +begin + FAttributeMask.Assign(Value); +end; + +procedure TJclFileSearchOptions.SetCaseSensitiveSearch(const Value: Boolean); +begin + FCaseSensitiveSearch := Value; +end; + +procedure TJclFileSearchOptions.SetFileMask(const Value: string); +begin + { TODO : UNIX : ? } + StrToStrings(Value, DirSeparator, FFileMasks, False); +end; + +procedure TJclFileSearchOptions.SetFileMasks(const Value: TStrings); +begin + FileMasks.Assign(Value); +end; + +procedure TJclFileSearchOptions.SetFileSizeMax(const Value: Int64); +begin + FFileSizeMax := Value; +end; + +procedure TJclFileSearchOptions.SetFileSizeMin(const Value: Int64); +begin + FFileSizeMin := Value; +end; + +procedure TJclFileSearchOptions.SetIncludeHiddenSubDirectories( + const Value: Boolean); +begin + SetOption(fsIncludeHiddenSubDirectories, Value); +end; + +procedure TJclFileSearchOptions.SetIncludeSubDirectories(const Value: Boolean); +begin + SetOption(fsIncludeSubDirectories, Value); +end; + +procedure TJclFileSearchOptions.SetLastChangeAfter(const Value: TDateTime); +begin + FLastChangeAfter := Value; +end; + +procedure TJclFileSearchOptions.SetLastChangeAfterStr(const Value: string); +begin + if Value = '' then + LastChangeAfter := MinDateTime + else + LastChangeAfter := StrToDateTime(Value); +end; + +procedure TJclFileSearchOptions.SetLastChangeBefore(const Value: TDateTime); +begin + FLastChangeBefore := Value; +end; + +procedure TJclFileSearchOptions.SetLastChangeBeforeStr(const Value: string); +begin + if Value = '' then + LastChangeBefore := MaxDateTime + else + LastChangeBefore := StrToDateTime(Value); +end; + +procedure TJclFileSearchOptions.SetOption(const Option: TFileSearchOption; + const Value: Boolean); +begin + if Value then + Include(FOptions, Option) + else + Exclude(FOptions, Option); +end; + +procedure TJclFileSearchOptions.SetOptions(const Value: TFileSearchOptions); +begin + FOptions := Value; +end; + +procedure TJclFileSearchOptions.SetRootDirectories(const Value: TStrings); +begin + FRootDirectories.Assign(Value); +end; + +procedure TJclFileSearchOptions.SetRootDirectory(const Value: string); +begin + FRootDirectories.Clear; + FRootDirectories.Add(Value); +end; + +procedure TJclFileSearchOptions.SetSubDirectoryMask(const Value: string); +begin + FSubDirectoryMask := Value; +end; + +//=== { TEnumFileThread } ==================================================== + +type + TEnumFileThread = class(TThread) + private + FID: TFileSearchTaskID; + FFileMasks: TStringList; + FDirectories: TStrings; + FCurrentDirectory: string; + FSubDirectoryMask: string; + FOnEnterDirectory: TFileHandler; + FFileHandlerEx: TFileHandlerEx; + FFileHandler: TFileHandler; + FInternalDirHandler: TFileHandler; + FInternalFileInfoHandler: TFileInfoHandlerEx; + FFileInfo: TSearchRec; + FRejectedAttr: Integer; + FRequiredAttr: Integer; + FFileSizeMin: Int64; + FFileSizeMax: Int64; + {$IFDEF RTL220_UP} + FFileTimeMin: TDateTime; + FFileTimeMax: TDateTime; + {$ELSE ~RTL220_UP} + FFileTimeMin: Integer; + FFileTimeMax: Integer; + {$ENDIF ~RTL220_UP} + FSynchronizationMode: TFileEnumeratorSyncMode; + FIncludeSubDirectories: Boolean; + FIncludeHiddenSubDirectories: Boolean; + FNotifyOnTermination: Boolean; + FCaseSensitiveSearch: Boolean; + FAllNamesMatch: Boolean; + procedure EnterDirectory; + procedure AsyncProcessDirectory(const Directory: string); + procedure SyncProcessDirectory(const Directory: string); + procedure AsyncProcessFile(const FileInfo: TSearchRec); + procedure SyncProcessFile(const FileInfo: TSearchRec); + function GetDirectories: TStrings; + function GetFileMasks: TStrings; + procedure SetDirectories(const Value: TStrings); + procedure SetFileMasks(const Value: TStrings); + protected + procedure DoTerminate; override; + procedure Execute; override; + function FileMatch: Boolean; + function FileNameMatchesMask: Boolean; + procedure ProcessDirectory; + procedure ProcessDirFiles; + procedure ProcessFile; + property AllNamesMatch: Boolean read FAllNamesMatch; + property CaseSensitiveSearch: Boolean read FCaseSensitiveSearch write FCaseSensitiveSearch; + property FileMasks: TStrings read GetFileMasks write SetFileMasks; + property FileSizeMin: Int64 read FFileSizeMin write FFileSizeMin; + property FileSizeMax: Int64 read FFileSizeMax write FFileSizeMax; + {$IFDEF RTL220_UP} + property FileTimeMin: TDateTime read FFileTimeMin write FFileTimeMin; + property FileTimeMax: TDateTime read FFileTimeMax write FFileTimeMax; + {$ELSE ~RTL220_UP} + property FileTimeMin: Integer read FFileTimeMin write FFileTimeMin; + property FileTimeMax: Integer read FFileTimeMax write FFileTimeMax; + {$ENDIF ~RTL220_UP} + property Directories: TStrings read GetDirectories write SetDirectories; + property IncludeSubDirectories: Boolean + read FIncludeSubDirectories write FIncludeSubDirectories; + property IncludeHiddenSubDirectories: Boolean + read FIncludeHiddenSubDirectories write FIncludeHiddenSubDirectories; + property RejectedAttr: Integer read FRejectedAttr write FRejectedAttr; + property RequiredAttr: Integer read FRequiredAttr write FRequiredAttr; + property SynchronizationMode: TFileEnumeratorSyncMode + read FSynchronizationMode write FSynchronizationMode; + public + constructor Create; + destructor Destroy; override; + property ID: TFileSearchTaskID read FID; + {$IFDEF FPC} // protected property + property Terminated; + {$ENDIF FPC} + end; + +constructor TEnumFileThread.Create; +begin + inherited Create(True); + FDirectories := TStringList.Create; + FFileMasks := TStringList.Create; + {$IFDEF RTL220_UP} + FFileTimeMin := -MaxDouble; + FFileTimeMax := MaxDouble; + {$ELSE ~RTL220_UP} + FFileTimeMin := Low(FFileInfo.Time); + FFileTimeMax := High(FFileInfo.Time); + {$ENDIF ~RTL220_UP} + FFileSizeMax := High(FFileSizeMax); + {$IFDEF MSWINDOWS} + Priority := tpIdle; + {$ENDIF MSWINDOWS} + {$IFDEF UNIX} + {$IFDEF FPC} + Priority := tpIdle; + {$ELSE ~FPC} + Priority := 0; + {$ENDIF ~FPC} + {$ENDIF UNIX} + FreeOnTerminate := True; + FNotifyOnTermination := True; +end; + +destructor TEnumFileThread.Destroy; +begin + FFileMasks.Free; + FDirectories.Free; + inherited Destroy; +end; + +procedure TEnumFileThread.Execute; +var + Index: Integer; +begin + if SynchronizationMode = smPerDirectory then + begin + FInternalDirHandler := SyncProcessDirectory; + FInternalFileInfoHandler := AsyncProcessFile; + end + else // SynchronizationMode = smPerFile + begin + FInternalDirHandler := AsyncProcessDirectory; + FInternalFileInfoHandler := SyncProcessFile; + end; + + if FIncludeSubDirectories then + begin + for Index := 0 to FDirectories.Count - 1 do + EnumDirectories(FDirectories.Strings[Index], FInternalDirHandler, FIncludeHiddenSubDirectories, + FSubDirectoryMask, @Terminated) + end + else + begin + for Index := 0 to FDirectories.Count - 1 do + FInternalDirHandler(CanonicalizedSearchPath(FDirectories.Strings[Index])); + end; +end; + +procedure TEnumFileThread.DoTerminate; +begin + if FNotifyOnTermination then + inherited DoTerminate; +end; + +procedure TEnumFileThread.EnterDirectory; +begin + FOnEnterDirectory(FCurrentDirectory); +end; + +procedure TEnumFileThread.ProcessDirectory; +begin + if Assigned(FOnEnterDirectory) then + EnterDirectory; + ProcessDirFiles; +end; + +procedure TEnumFileThread.AsyncProcessDirectory(const Directory: string); +begin + FCurrentDirectory := Directory; + if Assigned(FOnEnterDirectory) then + Synchronize(EnterDirectory); + ProcessDirFiles; +end; + +procedure TEnumFileThread.SyncProcessDirectory(const Directory: string); +begin + FCurrentDirectory := Directory; + Synchronize(ProcessDirectory); +end; + +procedure TEnumFileThread.ProcessDirFiles; +begin + EnumFiles(FCurrentDirectory + '*', FInternalFileInfoHandler, FRejectedAttr, FRequiredAttr, @Terminated); +end; + +function TEnumFileThread.FileMatch: Boolean; +var + FileSize: Int64; +begin + {$IFDEF RTL220_UP} + Result := FileNameMatchesMask and (FFileInfo.TimeStamp >= FFileTimeMin) and (FFileInfo.TimeStamp <= FFileTimeMax); + {$ELSE ~RTL220_UP} + Result := FileNameMatchesMask and (FFileInfo.Time >= FFileTimeMin) and (FFileInfo.Time <= FFileTimeMax); + {$ENDIF ~RTL220_UP} + if Result then + begin + FileSize := GetSizeOfFile(FFileInfo); + Result := (FileSize >= FFileSizeMin) and (FileSize <= FFileSizeMax); + end; +end; + +function TEnumFileThread.FileNameMatchesMask: Boolean; +var + I: Integer; +begin + Result := AllNamesMatch; + if not Result then + for I := 0 to FileMasks.Count - 1 do + if IsFileNameMatch(FFileInfo.Name, FileMasks[I], CaseSensitiveSearch) then + begin + Result := True; + Break; + end; +end; + +procedure TEnumFileThread.ProcessFile; +begin + if Assigned(FFileHandlerEx) then + FFileHandlerEx(FCurrentDirectory, FFileInfo) + else + FFileHandler(FCurrentDirectory + FFileInfo.Name); +end; + +procedure TEnumFileThread.AsyncProcessFile(const FileInfo: TSearchRec); +begin + FFileInfo := FileInfo; + if FileMatch then + ProcessFile; +end; + +procedure TEnumFileThread.SyncProcessFile(const FileInfo: TSearchRec); +begin + FFileInfo := FileInfo; + if FileMatch then + Synchronize(ProcessFile); +end; + +function TEnumFileThread.GetDirectories: TStrings; +begin + Result := FDirectories; +end; + +function TEnumFileThread.GetFileMasks: TStrings; +begin + Result := FFileMasks; +end; + +procedure TEnumFileThread.SetDirectories(const Value: TStrings); +begin + FDirectories.Assign(Value); +end; + +procedure TEnumFileThread.SetFileMasks(const Value: TStrings); +var + I: Integer; +begin + FAllNamesMatch := Value.Count = 0; + for I := 0 to Value.Count - 1 do + if (Value[I] = '*') {$IFDEF MSWINDOWS} or (Value[I] = '*.*') {$ENDIF} then + begin + FAllNamesMatch := True; + Break; + end; + if FAllNamesMatch then + FileMasks.Clear + else + FileMasks.Assign(Value); +end; + +//=== { TJclFileEnumerator } ================================================= + +constructor TJclFileEnumerator.Create; +begin + inherited Create; + FTasks := TList.Create; +end; + +destructor TJclFileEnumerator.Destroy; +begin + StopAllTasks(True); + FTasks.Free; + inherited Destroy; +end; + +procedure TJclFileEnumerator.Assign(Source: TPersistent); +var + Src: TJclFileEnumerator; +begin + if Source is TJclFileEnumerator then + begin + Src := TJclFileEnumerator(Source); + SynchronizationMode := Src.SynchronizationMode; + OnEnterDirectory := Src.OnEnterDirectory; + OnTerminateTask := Src.OnTerminateTask; + end; + inherited Assign(Source); +end; + +function TJclFileEnumerator.CreateTask: TThread; +var + Task: TEnumFileThread; +begin + Task := TEnumFileThread.Create; + Task.FID := NextTaskID; + Task.CaseSensitiveSearch := FCaseSensitiveSearch; + Task.FileMasks := FileMasks; + Task.Directories := RootDirectories; + Task.RejectedAttr := AttributeMask.Rejected; + Task.RequiredAttr := AttributeMask.Required; + Task.IncludeSubDirectories := IncludeSubDirectories; + Task.IncludeHiddenSubDirectories := IncludeHiddenSubDirectories; + if fsMinSize in Options then + Task.FileSizeMin := FileSizeMin; + if fsMaxSize in Options then + Task.FileSizeMax := FileSizeMax; + if fsLastChangeAfter in Options then + Task.FFileTimeMin := {$IFDEF RTL220_UP}LastChangeAfter{$ELSE}DateTimeToFileDate(LastChangeAfter){$ENDIF}; + if fsLastChangeBefore in Options then + Task.FFileTimeMax := {$IFDEF RTL220_UP}LastChangeBefore{$ELSE}DateTimeToFileDate(LastChangeBefore){$ENDIF}; + Task.SynchronizationMode := SynchronizationMode; + Task.FOnEnterDirectory := OnEnterDirectory; + Task.OnTerminate := TaskTerminated; + FTasks.Add(Task); + if FRefCount > 0 then + _AddRef; + Result := Task; +end; + +function TJclFileEnumerator.FillList(List: TStrings): TFileSearchTaskID; +begin + List.BeginUpdate; + try + Result := ForEach(List.Append); + finally + List.EndUpdate; + end; +end; + +function TJclFileEnumerator.ForEach(Handler: TFileHandlerEx): TFileSearchTaskID; +var + Task: TEnumFileThread; +begin + Task := TEnumFileThread(CreateTask); + Task.FFileHandlerEx := Handler; + Result := Task.ID; + {$IFDEF RTL210_UP} + Task.Suspended := False; + {$ELSE ~RTL210_UP} + Task.Resume; + {$ENDIF ~RTL210_UP} +end; + +function TJclFileEnumerator.ForEach(Handler: TFileHandler): TFileSearchTaskID; +var + Task: TEnumFileThread; +begin + Task := TEnumFileThread(CreateTask); + Task.FFileHandler := Handler; + Result := Task.ID; + {$IFDEF RTL210_UP} + Task.Suspended := False; + {$ELSE ~RTL210_UP} + Task.Resume; + {$ENDIF ~RTL210_UP} +end; + +function TJclFileEnumerator.GetRunningTasks: Integer; +begin + Result := FTasks.Count; +end; + +procedure TJclFileEnumerator.StopTask(ID: TFileSearchTaskID); +var + Task: TEnumFileThread; + I: Integer; +begin + for I := 0 to FTasks.Count - 1 do + begin + Task := TEnumFileThread(FTasks[I]); + if Task.ID = ID then + begin + Task.Terminate; + Break; + end; + end; +end; + +procedure TJclFileEnumerator.StopAllTasks(Silently: Boolean = False); +var + I: Integer; +begin + for I := 0 to FTasks.Count - 1 do + begin + TEnumFileThread(FTasks[I]).FNotifyOnTermination := not Silently; + TEnumFileThread(FTasks[I]).Terminate; + end; +end; + +procedure TJclFileEnumerator.TaskTerminated(Sender: TObject); +begin + FTasks.Remove(Sender); + try + if Assigned(FOnTerminateTask) then + FOnTerminateTask(TEnumFileThread(Sender).ID, TEnumFileThread(Sender).Terminated); + finally + if FRefCount > 0 then + _Release; + end; +end; + +function TJclFileEnumerator.GetNextTaskID: TFileSearchTaskID; +begin + Result := FNextTaskID; + Inc(FNextTaskID); +end; + +function TJclFileEnumerator.GetOnEnterDirectory: TFileHandler; +begin + Result := FOnEnterDirectory; +end; + +function TJclFileEnumerator.GetOnTerminateTask: TFileSearchTerminationEvent; +begin + Result := FOnTerminateTask; +end; + +function TJclFileEnumerator.GetSynchronizationMode: TFileEnumeratorSyncMode; +begin + Result := FSynchronizationMode; +end; + +procedure TJclFileEnumerator.SetOnEnterDirectory( + const Value: TFileHandler); +begin + FOnEnterDirectory := Value; +end; + +procedure TJclFileEnumerator.SetOnTerminateTask( + const Value: TFileSearchTerminationEvent); +begin + FOnTerminateTask := Value; +end; + +procedure TJclFileEnumerator.SetSynchronizationMode( + const Value: TFileEnumeratorSyncMode); +begin + FSynchronizationMode := Value; +end; + +function FileSearch: IJclFileEnumerator; +begin + Result := TJclFileEnumerator.Create; +end; + +function SamePath(const Path1, Path2: string): Boolean; +begin + {$IFDEF MSWINDOWS} + Result := AnsiSameText(PathGetLongName(Path1), PathGetLongName(Path2)); + {$ELSE ~MSWINDOWS} + Result := Path1 = Path2; + {$ENDIF ~MSWINDOWS} +end; + +// add items at the end +procedure PathListAddItems(var List: string; const Items: string); +begin + ListAddItems(List, DirSeparator, Items); +end; + +// add items at the end if they are not present +procedure PathListIncludeItems(var List: string; const Items: string); +var + StrList, NewItems: TStringList; + IndexNew, IndexList: Integer; + Item: string; + Duplicate: Boolean; +begin + StrList := TStringList.Create; + try + StrToStrings(List, DirSeparator, StrList); + + NewItems := TStringList.Create; + try + StrToStrings(Items, DirSeparator, NewItems); + + for IndexNew := 0 to NewItems.Count - 1 do + begin + Item := NewItems.Strings[IndexNew]; + + Duplicate := False; + for IndexList := 0 to StrList.Count - 1 do + if SamePath(Item, StrList.Strings[IndexList]) then + begin + Duplicate := True; + Break; + end; + + if not Duplicate then + StrList.Add(Item); + end; + + List := StringsToStr(StrList, DirSeparator); + finally + NewItems.Free; + end; + finally + StrList.Free; + end; +end; + +// delete multiple items +procedure PathListDelItems(var List: string; const Items: string); +var + StrList, RemItems: TStringList; + IndexRem, IndexList: Integer; + Item: string; +begin + StrList := TStringList.Create; + try + StrToStrings(List, DirSeparator, StrList); + + RemItems := TStringList.Create; + try + StrToStrings(Items, DirSeparator, RemItems); + + for IndexRem := 0 to RemItems.Count - 1 do + begin + Item := RemItems.Strings[IndexRem]; + + for IndexList := StrList.Count - 1 downto 0 do + if SamePath(Item, StrList.Strings[IndexList]) then + StrList.Delete(IndexList); + end; + + List := StringsToStr(StrList, DirSeparator); + finally + RemItems.Free; + end; + finally + StrList.Free; + end; +end; + +// delete one item +procedure PathListDelItem(var List: string; const Index: Integer); +begin + ListDelItem(List, DirSeparator, Index); +end; + +// return the number of item +function PathListItemCount(const List: string): Integer; +begin + Result := ListItemCount(List, DirSeparator); +end; + +// return the Nth item +function PathListGetItem(const List: string; const Index: Integer): string; +begin + Result := ListGetItem(List, DirSeparator, Index); +end; + +// set the Nth item +procedure PathListSetItem(var List: string; const Index: Integer; const Value: string); +begin + ListSetItem(List, DirSeparator, Index, Value); +end; + +// return the index of an item +function PathListItemIndex(const List, Item: string): Integer; +var + StrList: TStringList; + IndexList: Integer; +begin + StrList := TStringList.Create; + try + StrToStrings(List, DirSeparator, StrList); + + Result := -1; + + for IndexList := 0 to StrList.Count - 1 do + if SamePath(StrList.Strings[IndexList], Item) then + begin + Result := IndexList; + Break; + end; + finally + StrList.Free; + end; +end; + + +// additional functions to access the commandline parameters of an application + +// returns the name of the command line parameter at position index, which is +// separated by the given separator, if the first character of the name part +// is one of the AllowedPrefixCharacters, this character will be deleted. +function ParamName (Index : Integer; const Separator : string = '='; + const AllowedPrefixCharacters : string = '-/'; TrimName : Boolean = true) : string; +var s: string; + p: Integer; +begin + if (index > 0) and (index <= ParamCount) then + begin + s := ParamStr(index); + if Pos(Copy(s, 1, 1), AllowedPrefixCharacters) > 0 then + s := Copy (s, 2, Length(s)-1); + p := Pos(Separator, s); + if p > 0 then + s := Copy (s, 1, p-1); + if TrimName then + s := Trim(s); + Result := s; + end + else + Result := ''; +end; + +// returns the value of the command line parameter at position index, which is +// separated by the given separator +function ParamValue (Index : Integer; const Separator : string = '='; TrimValue : Boolean = true) : string; +var s: string; + p: Integer; +begin + if (index > 0) and (index <= ParamCount) then + begin + s := ParamStr(index); + p := Pos(Separator, s); + if p > 0 then + s := Copy (s, p+1, Length(s)-p); + if TrimValue then + s := Trim(s); + Result := s; + end + else + Result := ''; +end; + +// seaches a command line parameter where the namepart is the searchname +// and returns the value which is which by the given separator. +// CaseSensitive defines the search type. if the first character of the name part +// is one of the AllowedPrefixCharacters, this character will be deleted. +function ParamValue (const SearchName : string; const Separator : string = '='; + CaseSensitive : Boolean = False; + const AllowedPrefixCharacters : string = '-/'; TrimValue : Boolean = true) : string; +var pName : string; + i : Integer; +begin + Result := ''; + for i := 1 to ParamCount do + begin + pName := ParamName(i, Separator, AllowedPrefixCharacters, True); + if (CaseSensitive and (pName = Trim(SearchName))) or + (UpperCase(pName) = Trim(UpperCase(SearchName))) then + begin + Result := ParamValue (i, Separator, TrimValue); + exit; + end; + end; +end; + +// seaches a command line parameter where the namepart is the searchname +// and returns the position index. if no separator is defined, the full paramstr is compared. +// CaseSensitive defines the search type. if the first character of the name part +// is one of the AllowedPrefixCharacters, this character will be deleted. +function ParamPos (const SearchName : string; const Separator : string = '='; + CaseSensitive : Boolean = False; + const AllowedPrefixCharacters : string = '-/'): Integer; +var pName : string; + i : Integer; +begin + Result := -1; + for i := 1 to ParamCount do + begin + pName := ParamName(i, Separator, AllowedPrefixCharacters, True); + if (CaseSensitive and (pName = SearchName)) or + (UpperCase(pName) = UpperCase(SearchName)) then + begin + Result := i; + Exit; + end; + end; +end; + + +{$IFDEF UNITVERSIONING} +initialization + RegisterUnitVersion(HInstance, UnitVersioning); + +finalization + UnregisterUnitVersion(HInstance); +{$ENDIF UNITVERSIONING} + +end. diff --git a/source/packages/jcl/JclHookExcept.pas b/source/packages/jcl/JclHookExcept.pas new file mode 100644 index 00000000..b4e7112e --- /dev/null +++ b/source/packages/jcl/JclHookExcept.pas @@ -0,0 +1,855 @@ +{**************************************************************************************************} +{ } +{ Project JEDI Code Library (JCL) } +{ } +{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); } +{ you may not use this file except in compliance with the License. You may obtain a copy of the } +{ License at http://www.mozilla.org/MPL/ } +{ } +{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF } +{ ANY KIND, either express or implied. See the License for the specific language governing rights } +{ and limitations under the License. } +{ } +{ The Original Code is JclHookExcept.pas. } +{ } +{ The Initial Developer of the Original Code is Petr Vones. Portions created by Petr Vones are } +{ Copyright (C) Petr Vones. All Rights Reserved. } +{ } +{ Contributor(s): } +{ Petr Vones (pvones) } +{ Robert Marquardt (marquardt) } +{ Andreas Hausladen (ahuser) } +{ } +{**************************************************************************************************} +{ } +{ Exception hooking routines } +{ } +{**************************************************************************************************} +{ } +{ Last modified: $Date:: $ } +{ Revision: $Rev:: $ } +{ Author: $Author:: $ } +{ } +{**************************************************************************************************} + +unit JclHookExcept; + +interface + +{$I jcl.inc} +{$I windowsonly.inc} + +uses + {$IFDEF UNITVERSIONING} + JclUnitVersioning, + {$ENDIF UNITVERSIONING} + {$IFDEF HAS_UNITSCOPE} + Winapi.Windows, System.SysUtils, System.Classes; + {$ELSE ~HAS_UNITSCOPE} + Windows, SysUtils, Classes; + {$ENDIF ~HAS_UNITSCOPE} + +type + // Exception hooking notifiers routines +{$IFDEF BORLAND} + TJclExceptFilterProc = function(ExceptRecord: PExceptionRecord): Exception; +{$ENDIF BORLAND} + TJclExceptNotifyProc = procedure(ExceptObj: TObject; ExceptAddr: Pointer; OSException: Boolean); + TJclExceptNotifyProcEx = procedure(ExceptObj: TObject; ExceptAddr: Pointer; OSException: Boolean; StackPointer: Pointer); + TJclExceptNotifyMethod = procedure(ExceptObj: TObject; ExceptAddr: Pointer; OSException: Boolean) of object; + + TJclExceptNotifyPriority = (npNormal, npFirstChain); + +{$IFDEF BORLAND} +function JclAddExceptFilter(const FilterProc: TJclExceptFilterProc; Priority: TJclExceptNotifyPriority = npNormal): Boolean; +{$ENDIF BORLAND} +function JclAddExceptNotifier(const NotifyProc: TJclExceptNotifyProc; Priority: TJclExceptNotifyPriority = npNormal): Boolean; overload; +function JclAddExceptNotifier(const NotifyProc: TJclExceptNotifyProcEx; Priority: TJclExceptNotifyPriority = npNormal): Boolean; overload; +function JclAddExceptNotifier(const NotifyMethod: TJclExceptNotifyMethod; Priority: TJclExceptNotifyPriority = npNormal): Boolean; overload; + +{$IFDEF BORLAND} +function JclRemoveExceptFilter(const FilterProc: TJclExceptFilterProc): Boolean; +{$ENDIF BORLAND} +function JclRemoveExceptNotifier(const NotifyProc: TJclExceptNotifyProc): Boolean; overload; +function JclRemoveExceptNotifier(const NotifyProc: TJclExceptNotifyProcEx): Boolean; overload; +function JclRemoveExceptNotifier(const NotifyMethod: TJclExceptNotifyMethod): Boolean; overload; + +procedure JclReplaceExceptObj(NewExceptObj: Exception); + +// Exception hooking routines +function JclHookExceptions: Boolean; +function JclUnhookExceptions: Boolean; +function JclExceptionsHooked: Boolean; + +function JclHookExceptionsInModule(Module: HMODULE): Boolean; +function JclUnhookExceptionsInModule(Module: HMODULE): Boolean; + +// Exceptions hooking in libraries +type + TJclModuleArray = array of HMODULE; + +function JclInitializeLibrariesHookExcept: Boolean; +function JclHookedExceptModulesList(out ModulesList: TJclModuleArray): Boolean; + +// Hooking routines location info helper +function JclBelongsHookedCode(Address: Pointer): Boolean; + +{$IFDEF UNITVERSIONING} +const + UnitVersioning: TUnitVersionInfo = ( + RCSfile: '$URL$'; + Revision: '$Revision$'; + Date: '$Date$'; + LogPath: 'JCL\source\windows'; + Extra: ''; + Data: nil + ); +{$ENDIF UNITVERSIONING} + +implementation + +uses + JclBase, + JclPeImage, + JclSysInfo, JclSysUtils; + +type + PExceptionArguments = ^TExceptionArguments; + TExceptionArguments = record + ExceptAddr: Pointer; + ExceptObj: Exception; + end; + +{$IFDEF BORLAND} + TFilterItem = class(TObject) + private + FExceptFilterProc: TJclExceptFilterProc; + FPriority: TJclExceptNotifyPriority; + public + constructor Create(const ExceptFilterProc: TJclExceptFilterProc; APriority: TJclExceptNotifyPriority); + function DoFilterException(ExceptRecord: PExceptionRecord; out ExceptObj: Exception): Boolean; + property Priority: TJclExceptNotifyPriority read FPriority; + end; +{$ENDIF BORLAND} + + TNotifierItem = class(TObject) + private + FNotifyMethod: TJclExceptNotifyMethod; + FNotifyProc: TJclExceptNotifyProc; + FNotifyProcEx: TJclExceptNotifyProcEx; + FPriority: TJclExceptNotifyPriority; + public + constructor Create(const NotifyProc: TJclExceptNotifyProc; Priority: TJclExceptNotifyPriority); overload; + constructor Create(const NotifyProc: TJclExceptNotifyProcEx; Priority: TJclExceptNotifyPriority); overload; + constructor Create(const NotifyMethod: TJclExceptNotifyMethod; Priority: TJclExceptNotifyPriority); overload; + procedure DoNotify(ExceptObj: TObject; ExceptAddr: Pointer; OSException: Boolean; StackPointer: Pointer); + property Priority: TJclExceptNotifyPriority read FPriority; + end; + +var + ExceptionsHooked: Boolean; + Kernel32_RaiseException: procedure (dwExceptionCode, dwExceptionFlags, + nNumberOfArguments: DWORD; lpArguments: PDWORD); stdcall; + {$IFDEF BORLAND} + SysUtils_ExceptObjProc: function (P: PExceptionRecord): Exception; + {$ENDIF BORLAND} + {$IFDEF FPC} + SysUtils_ExceptProc: TExceptProc; + {$ENDIF FPC} + Notifiers: TThreadList; + {$IFDEF BORLAND} + Filters: TThreadList; + {$ENDIF BORLAND} + +{$IFDEF HOOK_DLL_EXCEPTIONS} +const + JclHookExceptDebugHookName = '__JclHookExcept'; + +type + TJclHookExceptDebugHook = procedure(Module: HMODULE; Hook: Boolean); stdcall; + + TJclHookExceptModuleList = class(TObject) + private + FModules: TThreadList; + protected + procedure HookStaticModules; + public + constructor Create; + destructor Destroy; override; + class function JclHookExceptDebugHookAddr: Pointer; + procedure HookModule(Module: HMODULE); + procedure List(out ModulesList: TJclModuleArray); + procedure UnhookModule(Module: HMODULE); + end; + +var + HookExceptModuleList: TJclHookExceptModuleList; + JclHookExceptDebugHook: Pointer; + +exports + JclHookExceptDebugHook name JclHookExceptDebugHookName; +{$ENDIF HOOK_DLL_EXCEPTIONS} + +{$STACKFRAMES OFF} + +threadvar + Recursive: Boolean; + NewResultExc: Exception; + +//=== Helper routines ======================================================== + +function RaiseExceptionAddress: Pointer; +begin + Result := GetProcAddress(GetModuleHandle(kernel32), 'RaiseException'); + Assert(Result <> nil); +end; + +procedure FreeThreadObjList(var TheList: TThreadList); +var + I: Integer; +begin + with TheList.LockList do + try + for I := 0 to Count - 1 do + TObject(Items[I]).Free; + finally + TheList.UnlockList; + end; + FreeAndNil(TheList); +end; + +//=== { TFilterItem } ======================================================== + +{$IFDEF BORLAND} +constructor TFilterItem.Create(const ExceptFilterProc: TJclExceptFilterProc; APriority: TJclExceptNotifyPriority); +begin + FExceptFilterProc := ExceptFilterProc; + FPriority := APriority; +end; + +function TFilterItem.DoFilterException(ExceptRecord: PExceptionRecord; out ExceptObj: Exception): Boolean; +begin + if Assigned(FExceptFilterProc) then + begin + ExceptObj := FExceptFilterProc(ExceptRecord); + Result := ExceptObj <> nil; + end + else + Result := False; +end; +{$ENDIF BORLAND} + +//=== { TNotifierItem } ====================================================== + +constructor TNotifierItem.Create(const NotifyProc: TJclExceptNotifyProc; Priority: TJclExceptNotifyPriority); +begin + inherited Create; + FNotifyProc := NotifyProc; + FPriority := Priority; +end; + +constructor TNotifierItem.Create(const NotifyProc: TJclExceptNotifyProcEx; Priority: TJclExceptNotifyPriority); +begin + inherited Create; + FNotifyProcEx := NotifyProc; + FPriority := Priority; +end; + +constructor TNotifierItem.Create(const NotifyMethod: TJclExceptNotifyMethod; Priority: TJclExceptNotifyPriority); +begin + inherited Create; + FNotifyMethod := NotifyMethod; + FPriority := Priority; +end; + +procedure TNotifierItem.DoNotify(ExceptObj: TObject; ExceptAddr: Pointer; + OSException: Boolean; StackPointer: Pointer); +begin + if Assigned(FNotifyProc) then + FNotifyProc(ExceptObj, ExceptAddr, OSException) + else + if Assigned(FNotifyProcEx) then + FNotifyProcEx(ExceptObj, ExceptAddr, OSException, StackPointer) + else + if Assigned(FNotifyMethod) then + FNotifyMethod(ExceptObj, ExceptAddr, OSException); +end; + +function GetFramePointer: Pointer; +asm + {$IFDEF CPU32} + MOV EAX, EBP + {$ENDIF CPU32} + {$IFDEF CPU64} + MOV RAX, RBP + {$ENDIF CPU64} +end; + +{$STACKFRAMES ON} + +{$IFDEF BORLAND} +function DoExceptFilter(ExceptRecord: PExceptionRecord): Exception; +var + Priorities: TJclExceptNotifyPriority; + I: Integer; +begin + if Recursive then + Exit; + if Assigned(Filters) then + begin + Recursive := True; + try + with Filters.LockList do + try + for Priorities := High(Priorities) downto Low(Priorities) do + for I := 0 to Count - 1 do + with TFilterItem(Items[I]) do + if Priority = Priorities then + if DoFilterException(ExceptRecord, Result) then + Exit; + finally + Filters.UnlockList; + end; + // Nobody wanted to handle the external exception. Call the default handler. + Result := SysUtils_ExceptObjProc(ExceptRecord); + finally + Recursive := False; + end; + end; +end; +{$ENDIF BORLAND} + +procedure DoExceptNotify(ExceptObj: TObject; ExceptAddr: Pointer; OSException: Boolean; StackPointer: Pointer); +var + Priorities: TJclExceptNotifyPriority; + I: Integer; +begin + if Recursive then + Exit; + if Assigned(Notifiers) then + begin + Recursive := True; + NewResultExc := nil; + try + with Notifiers.LockList do + try + if Count = 1 then + begin + with TNotifierItem(Items[0]) do + DoNotify( ExceptObj, ExceptAddr, OSException, StackPointer); + end + else + begin + for Priorities := High(Priorities) downto Low(Priorities) do + for I := 0 to Count - 1 do + with TNotifierItem(Items[I]) do + if Priority = Priorities then + DoNotify(ExceptObj, ExceptAddr, OSException, StackPointer); + end; + finally + Notifiers.UnlockList; + end; + finally + Recursive := False; + end; + end; +end; + +procedure HookedRaiseException(ExceptionCode, ExceptionFlags, NumberOfArguments: DWORD; + Arguments: PExceptionArguments); stdcall; +const + cDelphiException = $0EEDFADE; + cNonContinuable = 1; // Delphi exceptions + cNonContinuableException = $C0000025; // C++Builder exceptions (sounds like a bug) + DelphiNumberOfArguments = 7; + CBuilderNumberOfArguments = 8; +begin + if ((ExceptionFlags = cNonContinuable) or (ExceptionFlags = cNonContinuableException)) and + (ExceptionCode = cDelphiException) and + (NumberOfArguments in [DelphiNumberOfArguments,CBuilderNumberOfArguments]) + //TODO: The difference for Win64 is bigger than 100 Byte and the comment of JVCS revision 0.3 of + // JclDebug.pas, where HookedRaiseException has been added by Petr, isn't very informative + {$IFDEF CPU32} + and (TJclAddr(Arguments) = TJclAddr(@Arguments) + SizeOf(Pointer)) + {$ENDIF CPU32} + then + begin + DoExceptNotify(Arguments.ExceptObj, Arguments.ExceptAddr, False, GetFramePointer); + end; + Kernel32_RaiseException(ExceptionCode, ExceptionFlags, NumberOfArguments, PDWORD(Arguments)); +end; + +{$IFDEF BORLAND} +function HookedExceptObjProc(P: PExceptionRecord): Exception; +var + NewResultExcCache: Exception; // TLS optimization +begin + Result := DoExceptFilter(P); + DoExceptNotify(Result, P^.ExceptionAddress, True, GetFramePointer); + NewResultExcCache := NewResultExc; + if NewResultExcCache <> nil then + Result := NewResultExcCache; +end; +{$ENDIF BORLAND} + +{$IFDEF FPC} +procedure HookedExceptProc(Obj : TObject; Addr : Pointer; FrameCount:Longint; Frame: PPointer); +var + NewResultExcCache: Exception; // TLS optimization +begin + DoExceptNotify(Obj, Addr, True, GetFramePointer); + NewResultExcCache := NewResultExc; + if NewResultExcCache <> nil then + SysUtils_ExceptProc(NewResultExcCache, Addr, FrameCount, Frame) + else + SysUtils_ExceptProc(Obj, Addr, FrameCount, Frame) +end; +{$ENDIF FPC} + +{$IFNDEF STACKFRAMES_ON} +{$STACKFRAMES OFF} +{$ENDIF ~STACKFRAMES_ON} + +// Do not change ordering of HookedRaiseException, HookedExceptObjProc and JclBelongsHookedCode routines + +function JclBelongsHookedCode(Address: Pointer): Boolean; +begin + Result := (TJclAddr(@HookedRaiseException) < TJclAddr(@JclBelongsHookedCode)) and + (TJclAddr(@HookedRaiseException) <= TJclAddr(Address)) and + (TJclAddr(@JclBelongsHookedCode) > TJclAddr(Address)); +end; + +{$IFDEF BORLAND} +function JclAddExceptFilter(const FilterProc: TJclExceptFilterProc; Priority: TJclExceptNotifyPriority = npNormal): Boolean; +begin + Result := Assigned(FilterProc); + if Result then + with Filters.LockList do + try + Add(TFilterItem.Create(FilterProc, Priority)); + finally + Filters.UnlockList; + end; +end; +{$ENDIF BORLAND} + +function JclAddExceptNotifier(const NotifyProc: TJclExceptNotifyProc; Priority: TJclExceptNotifyPriority): Boolean; +begin + Result := Assigned(NotifyProc); + if Result then + with Notifiers.LockList do + try + Add(TNotifierItem.Create(NotifyProc, Priority)); + finally + Notifiers.UnlockList; + end; +end; + +function JclAddExceptNotifier(const NotifyProc: TJclExceptNotifyProcEx; Priority: TJclExceptNotifyPriority): Boolean; +begin + Result := Assigned(NotifyProc); + if Result then + with Notifiers.LockList do + try + Add(TNotifierItem.Create(NotifyProc, Priority)); + finally + Notifiers.UnlockList; + end; +end; + +function JclAddExceptNotifier(const NotifyMethod: TJclExceptNotifyMethod; Priority: TJclExceptNotifyPriority): Boolean; +begin + Result := Assigned(NotifyMethod); + if Result then + with Notifiers.LockList do + try + Add(TNotifierItem.Create(NotifyMethod, Priority)); + finally + Notifiers.UnlockList; + end; +end; + +{$IFDEF BORLAND} +function JclRemoveExceptFilter(const FilterProc: TJclExceptFilterProc): Boolean; +var + O: TFilterItem; + I: Integer; +begin + Result := Assigned(FilterProc); + if Result then + with Filters.LockList do + try + for I := 0 to Count - 1 do + begin + O := TFilterItem(Items[I]); + if @O.FExceptFilterProc = @FilterProc then + begin + O.Free; + Items[I] := nil; + end; + end; + Pack; + finally + Filters.UnlockList; + end; +end; +{$ENDIF BORLAND} + +function JclRemoveExceptNotifier(const NotifyProc: TJclExceptNotifyProc): Boolean; +var + O: TNotifierItem; + I: Integer; +begin + Result := Assigned(NotifyProc); + if Result then + with Notifiers.LockList do + try + for I := 0 to Count - 1 do + begin + O := TNotifierItem(Items[I]); + if @O.FNotifyProc = @NotifyProc then + begin + O.Free; + Items[I] := nil; + end; + end; + Pack; + finally + Notifiers.UnlockList; + end; +end; + +function JclRemoveExceptNotifier(const NotifyProc: TJclExceptNotifyProcEx): Boolean; +var + O: TNotifierItem; + I: Integer; +begin + Result := Assigned(NotifyProc); + if Result then + with Notifiers.LockList do + try + for I := 0 to Count - 1 do + begin + O := TNotifierItem(Items[I]); + if @O.FNotifyProcEx = @NotifyProc then + begin + O.Free; + Items[I] := nil; + end; + end; + Pack; + finally + Notifiers.UnlockList; + end; +end; + +function JclRemoveExceptNotifier(const NotifyMethod: TJclExceptNotifyMethod): Boolean; +var + O: TNotifierItem; + I: Integer; +begin + Result := Assigned(NotifyMethod); + if Result then + with Notifiers.LockList do + try + for I := 0 to Count - 1 do + begin + O := TNotifierItem(Items[I]); + if (TMethod(O.FNotifyMethod).Code = TMethod(NotifyMethod).Code) and + (TMethod(O.FNotifyMethod).Data = TMethod(NotifyMethod).Data) then + begin + O.Free; + Items[I] := nil; + end; + end; + Pack; + finally + Notifiers.UnlockList; + end; +end; + +procedure JclReplaceExceptObj(NewExceptObj: Exception); +begin + Assert(Recursive); + NewResultExc := NewExceptObj; +end; + +{$IFDEF BORLAND} +function GetCppRtlBase: Pointer; +const + {$IFDEF COMPILER6} { Delphi/C++Builder 6 } + CppRtlVersion = 60; + {$ELSE ~COMPILER6} + {$IFDEF RTL185} { Delphi/C++Builder 2007 were aiming for + binary compatibility with BDS2006, which + complicates things a bit } + CppRtlVersion = 80; + {$ELSE ~RTL185} + { Successive RTLDLL version numbers in the remaining cases: CB2006 has cc3270mt.dll, + CB2009 (= CB2006 + 2 releases) has cc3290mt.dll, CB2010 has cc32100mt.dll etc. } + CppRtlVersion = 70 + Trunc(RtlVersion - 18.0) * 10; + {$ENDIF ~RTL185} + {$ENDIF ~COMPILER6} +begin + Result := Pointer(GetModuleHandle(PChar(Format('cc32%dmt.dll', [CppRtlVersion])))); + { 'Result = nil' means that the C++ RTL has been linked statically or is not available at all; + in this case TJclPeMapImgHooks.ReplaceImport() is a no-op. The base module is also being + hooked separately, so we're covered. } +end; + +function HasCppRtl: Boolean; +begin + Result := GetCppRtlBase <> TJclPeMapImgHooks.SystemBase; +end; +{$ENDIF BORLAND} + +function JclHookExceptions: Boolean; +var + RaiseExceptionAddressCache: Pointer; +begin + RaiseExceptionAddressCache := RaiseExceptionAddress; + { Detect C++Builder applications and C++ packages loaded into Delphi applications. + Hook the C++ RTL regardless of ExceptionsHooked so that users can call JclHookException() after + loading a C++ package which might pull in the C++ RTL DLL. } + {$IFDEF BORLAND} + if HasCppRtl then + TJclPeMapImgHooks.ReplaceImport(GetCppRtlBase, kernel32, RaiseExceptionAddressCache, @HookedRaiseException); + {$ENDIF BORLAND} + if not ExceptionsHooked then + begin + Recursive := False; + with TJclPeMapImgHooks do + Result := ReplaceImport(SystemBase, kernel32, RaiseExceptionAddressCache, @HookedRaiseException); + if Result then + begin + @Kernel32_RaiseException := RaiseExceptionAddressCache; + {$IFDEF BORLAND} + SysUtils_ExceptObjProc := System.ExceptObjProc; + System.ExceptObjProc := @HookedExceptObjProc; + {$ENDIF BORLAND} + {$IFDEF FPC} + SysUtils_ExceptProc := System.ExceptProc; + System.ExceptProc := @HookedExceptProc; + {$ENDIF FPC} + end; + ExceptionsHooked := Result; + end + else + Result := True; +end; + +function JclUnhookExceptions: Boolean; +begin + {$IFDEF BORLAND} + if HasCppRtl then + TJclPeMapImgHooks.ReplaceImport (GetCppRtlBase, kernel32, @HookedRaiseException, @Kernel32_RaiseException); + {$ENDIF BORLAND} + if ExceptionsHooked then + begin + with TJclPeMapImgHooks do + ReplaceImport(SystemBase, kernel32, @HookedRaiseException, @Kernel32_RaiseException); + {$IFDEF BORLAND} + System.ExceptObjProc := @SysUtils_ExceptObjProc; + @SysUtils_ExceptObjProc := nil; + {$ENDIF BORLAND} + {$IFDEF FPC} + System.ExceptProc := @SysUtils_ExceptProc; + @SysUtils_ExceptProc := nil; + {$ENDIF FPC} + @Kernel32_RaiseException := nil; + Result := True; + ExceptionsHooked := False; + end + else + Result := True; +end; + +function JclExceptionsHooked: Boolean; +begin + Result := ExceptionsHooked; +end; + +function JclHookExceptionsInModule(Module: HMODULE): Boolean; +begin + Result := ExceptionsHooked and + TJclPeMapImgHooks.ReplaceImport(Pointer(Module), kernel32, RaiseExceptionAddress, @HookedRaiseException); +end; + +function JclUnhookExceptionsInModule(Module: HMODULE): Boolean; +begin + Result := ExceptionsHooked and + TJclPeMapImgHooks.ReplaceImport(Pointer(Module), kernel32, @HookedRaiseException, @Kernel32_RaiseException); +end; + +{$IFDEF HOOK_DLL_EXCEPTIONS} +// Exceptions hooking in libraries + +procedure JclHookExceptDebugHookProc(Module: HMODULE; Hook: Boolean); stdcall; +begin + if Hook then + HookExceptModuleList.HookModule(Module) + else + HookExceptModuleList.UnhookModule(Module); +end; + +function CallExportedHookExceptProc(Module: HMODULE; Hook: Boolean): Boolean; +var + HookExceptProcPtr: PPointer; + HookExceptProc: TJclHookExceptDebugHook; +begin + HookExceptProcPtr := TJclHookExceptModuleList.JclHookExceptDebugHookAddr; + Result := Assigned(HookExceptProcPtr); + if Result then + begin + @HookExceptProc := HookExceptProcPtr^; + if Assigned(HookExceptProc) then + HookExceptProc(Module, True); + end; +end; +{$ENDIF HOOK_DLL_EXCEPTIONS} + +function JclInitializeLibrariesHookExcept: Boolean; +begin + {$IFDEF HOOK_DLL_EXCEPTIONS} + if IsLibrary then + Result := CallExportedHookExceptProc(SystemTObjectInstance, True) + else + begin + if not Assigned(HookExceptModuleList) then + HookExceptModuleList := TJclHookExceptModuleList.Create; + Result := True; + end; + {$ELSE HOOK_DLL_EXCEPTIONS} + Result := True; + {$ENDIF HOOK_DLL_EXCEPTIONS} +end; + +function JclHookedExceptModulesList(out ModulesList: TJclModuleArray): Boolean; +begin + {$IFDEF HOOK_DLL_EXCEPTIONS} + Result := Assigned(HookExceptModuleList); + if Result then + HookExceptModuleList.List(ModulesList); + {$ELSE HOOK_DLL_EXCEPTIONS} + Result := False; + SetLength(ModulesList, 0); + {$ENDIF HOOK_DLL_EXCEPTIONS} +end; + +{$IFDEF HOOK_DLL_EXCEPTIONS} +procedure FinalizeLibrariesHookExcept; +begin + FreeAndNil(HookExceptModuleList); + if IsLibrary then + CallExportedHookExceptProc(SystemTObjectInstance, False); +end; + +//=== { TJclHookExceptModuleList } =========================================== + +constructor TJclHookExceptModuleList.Create; +begin + inherited Create; + FModules := TThreadList.Create; + HookStaticModules; + JclHookExceptDebugHook := @JclHookExceptDebugHookProc; +end; + +destructor TJclHookExceptModuleList.Destroy; +begin + JclHookExceptDebugHook := nil; + FreeAndNil(FModules); + inherited Destroy; +end; + +procedure TJclHookExceptModuleList.HookModule(Module: HMODULE); +begin + with FModules.LockList do + try + if IndexOf(Pointer(Module)) = -1 then + begin + Add(Pointer(Module)); + JclHookExceptionsInModule(Module); + end; + finally + FModules.UnlockList; + end; +end; + +procedure TJclHookExceptModuleList.HookStaticModules; +var + ModulesList: TStringList; + I: Integer; + Module: HMODULE; +begin + ModulesList := nil; + with FModules.LockList do + try + ModulesList := TStringList.Create; + if LoadedModulesList(ModulesList, GetCurrentProcessId, True) then + for I := 0 to ModulesList.Count - 1 do + begin + Module := HMODULE(ModulesList.Objects[I]); + if GetProcAddress(Module, JclHookExceptDebugHookName) <> nil then + HookModule(Module); + end; + finally + FModules.UnlockList; + ModulesList.Free; + end; +end; + +class function TJclHookExceptModuleList.JclHookExceptDebugHookAddr: Pointer; +var + HostModule: HMODULE; +begin + HostModule := GetModuleHandle(nil); + Result := GetProcAddress(HostModule, JclHookExceptDebugHookName); +end; + +procedure TJclHookExceptModuleList.List(out ModulesList: TJclModuleArray); +var + I: Integer; +begin + with FModules.LockList do + try + SetLength(ModulesList, Count); + for I := 0 to Count - 1 do + ModulesList[I] := HMODULE(Items[I]); + finally + FModules.UnlockList; + end; +end; + +procedure TJclHookExceptModuleList.UnhookModule(Module: HMODULE); +begin + with FModules.LockList do + try + Remove(Pointer(Module)); + finally + FModules.UnlockList; + end; +end; +{$ENDIF HOOK_DLL_EXCEPTIONS} + +initialization + Notifiers := TThreadList.Create; + {$IFDEF BORLAND} + Filters := TThreadList.Create; + {$ENDIF BORLAND} + {$IFDEF UNITVERSIONING} + RegisterUnitVersion(HInstance, UnitVersioning); + {$ENDIF UNITVERSIONING} + +finalization + {$IFDEF UNITVERSIONING} + UnregisterUnitVersion(HInstance); + {$ENDIF UNITVERSIONING} + {$IFDEF HOOK_DLL_EXCEPTIONS} + FinalizeLibrariesHookExcept; + {$ENDIF HOOK_DLL_EXCEPTIONS} + FreeThreadObjList(Notifiers); + {$IFDEF BORLAND} + FreeThreadObjList(Filters); + {$ENDIF BORLAND} + +end. diff --git a/source/packages/jcl/JclPeImage.pas b/source/packages/jcl/JclPeImage.pas new file mode 100644 index 00000000..dd500472 --- /dev/null +++ b/source/packages/jcl/JclPeImage.pas @@ -0,0 +1,6986 @@ +{**************************************************************************************************} +{ } +{ Project JEDI Code Library (JCL) } +{ } +{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); } +{ you may not use this file except in compliance with the License. You may obtain a copy of the } +{ License at http://www.mozilla.org/MPL/ } +{ } +{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF } +{ ANY KIND, either express or implied. See the License for the specific language governing rights } +{ and limitations under the License. } +{ } +{ The Original Code is JclPeImage.pas. } +{ } +{ The Initial Developer of the Original Code is Petr Vones. Portions created by Petr Vones are } +{ Copyright (C) Petr Vones. All Rights Reserved. } +{ } +{ Contributor(s): } +{ Marcel van Brakel } +{ Robert Marquardt (marquardt) } +{ Uwe Schuster (uschuster) } +{ Matthias Thoma (mthoma) } +{ Petr Vones (pvones) } +{ Hallvard Vassbotn } +{ Jean-Fabien Connault (cycocrew) } +{ } +{**************************************************************************************************} +{ } +{ This unit contains various classes and support routines to read the contents of portable } +{ executable (PE) files. You can use these classes to, for example examine the contents of the } +{ imports section of an executable. In addition the unit contains support for Borland specific } +{ structures and name unmangling. } +{ } +{**************************************************************************************************} +{ } +{ Last modified: $Date:: $ } +{ Revision: $Rev:: $ } +{ Author: $Author:: $ } +{ } +{**************************************************************************************************} + +unit JclPeImage; + +{$I jcl.inc} +{$I windowsonly.inc} + +interface + +uses + {$IFDEF UNITVERSIONING} + JclUnitVersioning, + {$ENDIF UNITVERSIONING} + {$IFDEF HAS_UNITSCOPE} + Winapi.Windows, System.Classes, System.SysUtils, System.TypInfo, System.Contnrs, + {$ELSE ~HAS_UNITSCOPE} + Windows, Classes, SysUtils, TypInfo, Contnrs, + {$ENDIF ~HAS_UNITSCOPE} + JclBase, {$IFNDEF WINSCP}JclDateTime,{$ENDIF ~WINSCP} JclFileUtils, JclWin32; + +type + // Smart name compare function + TJclSmartCompOption = (scSimpleCompare, scIgnoreCase); + TJclSmartCompOptions = set of TJclSmartCompOption; + +function PeStripFunctionAW(const FunctionName: string): string; + +function PeSmartFunctionNameSame(const ComparedName, FunctionName: string; + Options: TJclSmartCompOptions = []): Boolean; + +type + // Base list + EJclPeImageError = class(EJclError); + + TJclPeImage = class; + + TJclPeImageClass = class of TJclPeImage; + + TJclPeImageBaseList = class(TObjectList) + private + FImage: TJclPeImage; + public + constructor Create(AImage: TJclPeImage); + property Image: TJclPeImage read FImage; + end; + + // Images cache + TJclPeImagesCache = class(TObject) + private + FList: TStringList; + function GetCount: Integer; + function GetImages(const FileName: TFileName): TJclPeImage; + protected + function GetPeImageClass: TJclPeImageClass; virtual; + public + constructor Create; + destructor Destroy; override; + procedure Clear; + property Images[const FileName: TFileName]: TJclPeImage read GetImages; default; + property Count: Integer read GetCount; + end; + + // Import section related classes + TJclPeImportSort = (isName, isOrdinal, isHint, isLibImport); + TJclPeImportLibSort = (ilName, ilIndex); + TJclPeImportKind = (ikImport, ikDelayImport, ikBoundImport); + TJclPeResolveCheck = (icNotChecked, icResolved, icUnresolved); + TJclPeLinkerProducer = (lrBorland, lrMicrosoft); + // lrBorland -> Delphi PE files + // lrMicrosoft -> MSVC and BCB PE files + + TJclPeImportLibItem = class; + + // Created from a IMAGE_THUNK_DATA64 or IMAGE_THUNK_DATA32 record + TJclPeImportFuncItem = class(TObject) + private + FOrdinal: Word; // word in 32/64 + FHint: Word; + FImportLib: TJclPeImportLibItem; + FIndirectImportName: Boolean; + FName: string; + FResolveCheck: TJclPeResolveCheck; + function GetIsByOrdinal: Boolean; + protected + procedure SetName(const Value: string); + procedure SetIndirectImportName(const Value: string); + procedure SetResolveCheck(Value: TJclPeResolveCheck); + public + constructor Create(AImportLib: TJclPeImportLibItem; AOrdinal: Word; + AHint: Word; const AName: string); + property Ordinal: Word read FOrdinal; + property Hint: Word read FHint; + property ImportLib: TJclPeImportLibItem read FImportLib; + property IndirectImportName: Boolean read FIndirectImportName; + property IsByOrdinal: Boolean read GetIsByOrdinal; + property Name: string read FName; + property ResolveCheck: TJclPeResolveCheck read FResolveCheck; + end; + + // Created from a IMAGE_IMPORT_DESCRIPTOR + TJclPeImportLibItem = class(TJclPeImageBaseList) + private + FImportDescriptor: Pointer; + FImportDirectoryIndex: Integer; + FImportKind: TJclPeImportKind; + FLastSortType: TJclPeImportSort; + FLastSortDescending: Boolean; + FName: string; + FSorted: Boolean; + FTotalResolveCheck: TJclPeResolveCheck; + FThunk: Pointer; + FThunkData: Pointer; + function GetCount: Integer; + function GetFileName: TFileName; + function GetItems(Index: Integer): TJclPeImportFuncItem; + function GetName: string; + function GetThunkData32: PImageThunkData32; + function GetThunkData64: PImageThunkData64; + protected + procedure CheckImports(ExportImage: TJclPeImage); + procedure CreateList; + procedure SetImportDirectoryIndex(Value: Integer); + procedure SetImportKind(Value: TJclPeImportKind); + procedure SetSorted(Value: Boolean); + procedure SetThunk(Value: Pointer); + public + constructor Create(AImage: TJclPeImage; AImportDescriptor: Pointer; + AImportKind: TJclPeImportKind; const AName: string; AThunk: Pointer); + procedure SortList(SortType: TJclPeImportSort; Descending: Boolean = False); + property Count: Integer read GetCount; + property FileName: TFileName read GetFileName; + property ImportDescriptor: Pointer read FImportDescriptor; + property ImportDirectoryIndex: Integer read FImportDirectoryIndex; + property ImportKind: TJclPeImportKind read FImportKind; + property Items[Index: Integer]: TJclPeImportFuncItem read GetItems; default; + property Name: string read GetName; + property OriginalName: string read FName; + // use the following properties + // property ThunkData: PImageThunkData + property ThunkData32: PImageThunkData32 read GetThunkData32; + property ThunkData64: PImageThunkData64 read GetThunkData64; + property TotalResolveCheck: TJclPeResolveCheck read FTotalResolveCheck; + end; + + TJclPeImportList = class(TJclPeImageBaseList) + private + FAllItemsList: TList; + FFilterModuleName: string; + FLastAllSortType: TJclPeImportSort; + FLastAllSortDescending: Boolean; + FLinkerProducer: TJclPeLinkerProducer; + FParallelImportTable: array of Pointer; + FUniqueNamesList: TStringList; + function GetAllItemCount: Integer; + function GetAllItems(Index: Integer): TJclPeImportFuncItem; + function GetItems(Index: Integer): TJclPeImportLibItem; + function GetUniqueLibItemCount: Integer; + function GetUniqueLibItems(Index: Integer): TJclPeImportLibItem; + function GetUniqueLibNames(Index: Integer): string; + function GetUniqueLibItemFromName(const Name: string): TJclPeImportLibItem; + procedure SetFilterModuleName(const Value: string); + protected + procedure CreateList; + procedure RefreshAllItems; + public + constructor Create(AImage: TJclPeImage); + destructor Destroy; override; + procedure CheckImports(PeImageCache: TJclPeImagesCache = nil); + function MakeBorlandImportTableForMappedImage: Boolean; + function SmartFindName(const CompareName, LibName: string; Options: TJclSmartCompOptions = []): TJclPeImportFuncItem; + procedure SortAllItemsList(SortType: TJclPeImportSort; Descending: Boolean = False); + procedure SortList(SortType: TJclPeImportLibSort); + procedure TryGetNamesForOrdinalImports; + property AllItems[Index: Integer]: TJclPeImportFuncItem read GetAllItems; + property AllItemCount: Integer read GetAllItemCount; + property FilterModuleName: string read FFilterModuleName write SetFilterModuleName; + property Items[Index: Integer]: TJclPeImportLibItem read GetItems; default; + property LinkerProducer: TJclPeLinkerProducer read FLinkerProducer; + property UniqueLibItemCount: Integer read GetUniqueLibItemCount; + property UniqueLibItemFromName[const Name: string]: TJclPeImportLibItem read GetUniqueLibItemFromName; + property UniqueLibItems[Index: Integer]: TJclPeImportLibItem read GetUniqueLibItems; + property UniqueLibNames[Index: Integer]: string read GetUniqueLibNames; + end; + + // Export section related classes + TJclPeExportSort = (esName, esOrdinal, esHint, esAddress, esForwarded, esAddrOrFwd, esSection); + + TJclPeExportFuncList = class; + + // Created from a IMAGE_EXPORT_DIRECTORY + TJclPeExportFuncItem = class(TObject) + private + FAddress: DWORD; + FExportList: TJclPeExportFuncList; + FForwardedName: string; + FForwardedDotPos: string; + FHint: Word; + FName: string; + FOrdinal: Word; + FResolveCheck: TJclPeResolveCheck; + function GetAddressOrForwardStr: string; + function GetForwardedFuncName: string; + function GetForwardedLibName: string; + function GetForwardedFuncOrdinal: DWORD; + function GetIsExportedVariable: Boolean; + function GetIsForwarded: Boolean; + function GetSectionName: string; + function GetMappedAddress: Pointer; + protected + procedure SetResolveCheck(Value: TJclPeResolveCheck); + public + constructor Create(AExportList: TJclPeExportFuncList; const AName, AForwardedName: string; + AAddress: DWORD; AHint: Word; AOrdinal: Word; AResolveCheck: TJclPeResolveCheck); + property Address: DWORD read FAddress; + property AddressOrForwardStr: string read GetAddressOrForwardStr; + property IsExportedVariable: Boolean read GetIsExportedVariable; + property IsForwarded: Boolean read GetIsForwarded; + property ForwardedName: string read FForwardedName; + property ForwardedLibName: string read GetForwardedLibName; + property ForwardedFuncOrdinal: DWORD read GetForwardedFuncOrdinal; + property ForwardedFuncName: string read GetForwardedFuncName; + property Hint: Word read FHint; + property MappedAddress: Pointer read GetMappedAddress; + property Name: string read FName; + property Ordinal: Word read FOrdinal; + property ResolveCheck: TJclPeResolveCheck read FResolveCheck; + property SectionName: string read GetSectionName; + end; + + TJclPeExportFuncList = class(TJclPeImageBaseList) + private + FAnyForwards: Boolean; + FBase: DWORD; + FExportDir: PImageExportDirectory; + FForwardedLibsList: TStringList; + FFunctionCount: DWORD; + FLastSortType: TJclPeExportSort; + FLastSortDescending: Boolean; + FSorted: Boolean; + FTotalResolveCheck: TJclPeResolveCheck; + function GetForwardedLibsList: TStrings; + function GetItems(Index: Integer): TJclPeExportFuncItem; + function GetItemFromAddress(Address: DWORD): TJclPeExportFuncItem; + function GetItemFromOrdinal(Ordinal: DWORD): TJclPeExportFuncItem; + function GetItemFromName(const Name: string): TJclPeExportFuncItem; + function GetName: string; + protected + function CanPerformFastNameSearch: Boolean; + procedure CreateList; + property LastSortType: TJclPeExportSort read FLastSortType; + property LastSortDescending: Boolean read FLastSortDescending; + property Sorted: Boolean read FSorted; + public + constructor Create(AImage: TJclPeImage); + destructor Destroy; override; + procedure CheckForwards(PeImageCache: TJclPeImagesCache = nil); + class function ItemName(Item: TJclPeExportFuncItem): string; + function OrdinalValid(Ordinal: DWORD): Boolean; + procedure PrepareForFastNameSearch; + function SmartFindName(const CompareName: string; Options: TJclSmartCompOptions = []): TJclPeExportFuncItem; + procedure SortList(SortType: TJclPeExportSort; Descending: Boolean = False); + property AnyForwards: Boolean read FAnyForwards; + property Base: DWORD read FBase; + property ExportDir: PImageExportDirectory read FExportDir; + property ForwardedLibsList: TStrings read GetForwardedLibsList; + property FunctionCount: DWORD read FFunctionCount; + property Items[Index: Integer]: TJclPeExportFuncItem read GetItems; default; + property ItemFromAddress[Address: DWORD]: TJclPeExportFuncItem read GetItemFromAddress; + property ItemFromName[const Name: string]: TJclPeExportFuncItem read GetItemFromName; + property ItemFromOrdinal[Ordinal: DWORD]: TJclPeExportFuncItem read GetItemFromOrdinal; + property Name: string read GetName; + property TotalResolveCheck: TJclPeResolveCheck read FTotalResolveCheck; + end; + + // Resource section related classes + TJclPeResourceKind = ( + rtUnknown0, + rtCursorEntry, + rtBitmap, + rtIconEntry, + rtMenu, + rtDialog, + rtString, + rtFontDir, + rtFont, + rtAccelerators, + rtRCData, + rtMessageTable, + rtCursor, + rtUnknown13, + rtIcon, + rtUnknown15, + rtVersion, + rtDlgInclude, + rtUnknown18, + rtPlugPlay, + rtVxd, + rtAniCursor, + rtAniIcon, + rtHmtl, + rtManifest, + rtUserDefined); + + TJclPeResourceList = class; + TJclPeResourceItem = class; + + TJclPeResourceRawStream = class(TCustomMemoryStream) + public + constructor Create(AResourceItem: TJclPeResourceItem); + function Write(const Buffer; Count: Longint): Longint; override; + end; + + TJclPeResourceItem = class(TObject) + private + FEntry: PImageResourceDirectoryEntry; + FImage: TJclPeImage; + FList: TJclPeResourceList; + FLevel: Byte; + FParentItem: TJclPeResourceItem; + FNameCache: string; + function GetDataEntry: PImageResourceDataEntry; + function GetIsDirectory: Boolean; + function GetIsName: Boolean; + function GetLangID: LANGID; + function GetList: TJclPeResourceList; + function GetName: string; + function GetParameterName: string; + function GetRawEntryData: Pointer; + function GetRawEntryDataSize: Integer; + function GetResourceType: TJclPeResourceKind; + function GetResourceTypeStr: string; + protected + function OffsetToRawData(Ofs: DWORD): TJclAddr; + function Level1Item: TJclPeResourceItem; + function SubDirData: PImageResourceDirectory; + public + constructor Create(AImage: TJclPeImage; AParentItem: TJclPeResourceItem; + AEntry: PImageResourceDirectoryEntry); + destructor Destroy; override; + function CompareName(AName: PChar): Boolean; + property DataEntry: PImageResourceDataEntry read GetDataEntry; + property Entry: PImageResourceDirectoryEntry read FEntry; + property Image: TJclPeImage read FImage; + property IsDirectory: Boolean read GetIsDirectory; + property IsName: Boolean read GetIsName; + property LangID: LANGID read GetLangID; + property List: TJclPeResourceList read GetList; + property Level: Byte read FLevel; + property Name: string read GetName; + property ParameterName: string read GetParameterName; + property ParentItem: TJclPeResourceItem read FParentItem; + property RawEntryData: Pointer read GetRawEntryData; + property RawEntryDataSize: Integer read GetRawEntryDataSize; + property ResourceType: TJclPeResourceKind read GetResourceType; + property ResourceTypeStr: string read GetResourceTypeStr; + end; + + TJclPeResourceList = class(TJclPeImageBaseList) + private + FDirectory: PImageResourceDirectory; + FParentItem: TJclPeResourceItem; + function GetItems(Index: Integer): TJclPeResourceItem; + protected + procedure CreateList(AParentItem: TJclPeResourceItem); + public + constructor Create(AImage: TJclPeImage; AParentItem: TJclPeResourceItem; + ADirectory: PImageResourceDirectory); + function FindName(const Name: string): TJclPeResourceItem; + property Directory: PImageResourceDirectory read FDirectory; + property Items[Index: Integer]: TJclPeResourceItem read GetItems; default; + property ParentItem: TJclPeResourceItem read FParentItem; + end; + + TJclPeRootResourceList = class(TJclPeResourceList) + private + FManifestContent: TStringList; + function GetManifestContent: TStrings; + public + destructor Destroy; override; + function FindResource(ResourceType: TJclPeResourceKind; + const ResourceName: string = ''): TJclPeResourceItem; overload; + function FindResource(const ResourceType: PChar; + const ResourceName: PChar = nil): TJclPeResourceItem; overload; + function ListResourceNames(ResourceType: TJclPeResourceKind; const Strings: TStrings): Boolean; + property ManifestContent: TStrings read GetManifestContent; + end; + + // Relocation section related classes + TJclPeRelocation = record + Address: Word; + RelocType: Byte; + VirtualAddress: DWORD; + end; + + TJclPeRelocEntry = class(TObject) + private + FChunk: PImageBaseRelocation; + FCount: Integer; + function GetRelocations(Index: Integer): TJclPeRelocation; + function GetSize: DWORD; + function GetVirtualAddress: DWORD; + public + constructor Create(AChunk: PImageBaseRelocation; ACount: Integer); + property Count: Integer read FCount; + property Relocations[Index: Integer]: TJclPeRelocation read GetRelocations; default; + property Size: DWORD read GetSize; + property VirtualAddress: DWORD read GetVirtualAddress; + end; + + TJclPeRelocList = class(TJclPeImageBaseList) + private + FAllItemCount: Integer; + function GetItems(Index: Integer): TJclPeRelocEntry; + function GetAllItems(Index: Integer): TJclPeRelocation; + protected + procedure CreateList; + public + constructor Create(AImage: TJclPeImage); + property AllItems[Index: Integer]: TJclPeRelocation read GetAllItems; + property AllItemCount: Integer read FAllItemCount; + property Items[Index: Integer]: TJclPeRelocEntry read GetItems; default; + end; + + // Debug section related classes + TJclPeDebugList = class(TJclPeImageBaseList) + private + function GetItems(Index: Integer): TImageDebugDirectory; + protected + procedure CreateList; + public + constructor Create(AImage: TJclPeImage); + property Items[Index: Integer]: TImageDebugDirectory read GetItems; default; + end; + + // Certificates section related classes + TJclPeCertificate = class(TObject) + private + FData: Pointer; + FHeader: TWinCertificate; + public + constructor Create(AHeader: TWinCertificate; AData: Pointer); + property Data: Pointer read FData; + property Header: TWinCertificate read FHeader; + end; + + TJclPeCertificateList = class(TJclPeImageBaseList) + private + function GetItems(Index: Integer): TJclPeCertificate; + protected + procedure CreateList; + public + constructor Create(AImage: TJclPeImage); + property Items[Index: Integer]: TJclPeCertificate read GetItems; default; + end; + + // Common Language Runtime section related classes + TJclPeCLRHeader = class(TObject) + private + FHeader: TImageCor20Header; + FImage: TJclPeImage; + function GetVersionString: string; + function GetHasMetadata: Boolean; + protected + procedure ReadHeader; + public + constructor Create(AImage: TJclPeImage); + property HasMetadata: Boolean read GetHasMetadata; + property Header: TImageCor20Header read FHeader; + property VersionString: string read GetVersionString; + property Image: TJclPeImage read FImage; + end; + + // PE Image + TJclPeHeader = ( + JclPeHeader_Signature, + JclPeHeader_Machine, + JclPeHeader_NumberOfSections, + JclPeHeader_TimeDateStamp, + JclPeHeader_PointerToSymbolTable, + JclPeHeader_NumberOfSymbols, + JclPeHeader_SizeOfOptionalHeader, + JclPeHeader_Characteristics, + JclPeHeader_Magic, + JclPeHeader_LinkerVersion, + JclPeHeader_SizeOfCode, + JclPeHeader_SizeOfInitializedData, + JclPeHeader_SizeOfUninitializedData, + JclPeHeader_AddressOfEntryPoint, + JclPeHeader_BaseOfCode, + JclPeHeader_BaseOfData, + JclPeHeader_ImageBase, + JclPeHeader_SectionAlignment, + JclPeHeader_FileAlignment, + JclPeHeader_OperatingSystemVersion, + JclPeHeader_ImageVersion, + JclPeHeader_SubsystemVersion, + JclPeHeader_Win32VersionValue, + JclPeHeader_SizeOfImage, + JclPeHeader_SizeOfHeaders, + JclPeHeader_CheckSum, + JclPeHeader_Subsystem, + JclPeHeader_DllCharacteristics, + JclPeHeader_SizeOfStackReserve, + JclPeHeader_SizeOfStackCommit, + JclPeHeader_SizeOfHeapReserve, + JclPeHeader_SizeOfHeapCommit, + JclPeHeader_LoaderFlags, + JclPeHeader_NumberOfRvaAndSizes); + + TJclLoadConfig = ( + JclLoadConfig_Characteristics, { TODO : rename to Size? } + JclLoadConfig_TimeDateStamp, + JclLoadConfig_Version, + JclLoadConfig_GlobalFlagsClear, + JclLoadConfig_GlobalFlagsSet, + JclLoadConfig_CriticalSectionDefaultTimeout, + JclLoadConfig_DeCommitFreeBlockThreshold, + JclLoadConfig_DeCommitTotalFreeThreshold, + JclLoadConfig_LockPrefixTable, + JclLoadConfig_MaximumAllocationSize, + JclLoadConfig_VirtualMemoryThreshold, + JclLoadConfig_ProcessHeapFlags, + JclLoadConfig_ProcessAffinityMask, + JclLoadConfig_CSDVersion, + JclLoadConfig_Reserved1, + JclLoadConfig_EditList, + JclLoadConfig_Reserved { TODO : extend to the new fields? } + ); + + TJclPeFileProperties = record + Size: DWORD; + CreationTime: TDateTime; + LastAccessTime: TDateTime; + LastWriteTime: TDateTime; + Attributes: Integer; + end; + + TJclPeImageStatus = (stNotLoaded, stOk, stNotPE, stNotSupported, stNotFound, stError); + TJclPeTarget = (taUnknown, taWin32, taWin64); + + TJclPeImage = class(TObject) + private + FAttachedImage: Boolean; + FCertificateList: TJclPeCertificateList; + FCLRHeader: TJclPeCLRHeader; + FDebugList: TJclPeDebugList; + FFileName: TFileName; + FImageSections: TStringList; + FLoadedImage: TLoadedImage; + FExportList: TJclPeExportFuncList; + FImportList: TJclPeImportList; + FNoExceptions: Boolean; + FReadOnlyAccess: Boolean; + FRelocationList: TJclPeRelocList; + FResourceList: TJclPeRootResourceList; + FResourceVA: TJclAddr; + FStatus: TJclPeImageStatus; + FTarget: TJclPeTarget; + FVersionInfo: TJclFileVersionInfo; + FStringTable: TStringList; + function GetCertificateList: TJclPeCertificateList; + function GetCLRHeader: TJclPeCLRHeader; + function GetDebugList: TJclPeDebugList; + function GetDescription: string; + function GetDirectories(Directory: Word): TImageDataDirectory; + function GetDirectoryExists(Directory: Word): Boolean; + function GetExportList: TJclPeExportFuncList; + {$IFNDEF WINSCP} + function GetFileProperties: TJclPeFileProperties; + {$ENDIF ~WINSCP} + function GetImageSectionCount: Integer; + function GetImageSectionHeaders(Index: Integer): TImageSectionHeader; + function GetImageSectionNames(Index: Integer): string; + function GetImageSectionNameFromRva(const Rva: DWORD): string; + function GetImportList: TJclPeImportList; + function GetHeaderValues(Index: TJclPeHeader): string; + function GetLoadConfigValues(Index: TJclLoadConfig): string; + function GetMappedAddress: TJclAddr; + function GetOptionalHeader32: TImageOptionalHeader32; + function GetOptionalHeader64: TImageOptionalHeader64; + function GetRelocationList: TJclPeRelocList; + function GetResourceList: TJclPeRootResourceList; + function GetUnusedHeaderBytes: TImageDataDirectory; + function GetVersionInfo: TJclFileVersionInfo; + function GetVersionInfoAvailable: Boolean; + procedure ReadImageSections; + procedure ReadStringTable; + procedure SetFileName(const Value: TFileName); + function GetStringTableCount: Integer; + function GetStringTableItem(Index: Integer): string; + function GetImageSectionFullNames(Index: Integer): string; + protected + procedure AfterOpen; dynamic; + procedure CheckNotAttached; + procedure Clear; dynamic; + function ExpandModuleName(const ModuleName: string): TFileName; + procedure RaiseStatusException; + function ResourceItemCreate(AEntry: PImageResourceDirectoryEntry; + AParentItem: TJclPeResourceItem): TJclPeResourceItem; virtual; + function ResourceListCreate(ADirectory: PImageResourceDirectory; + AParentItem: TJclPeResourceItem): TJclPeResourceList; virtual; + property NoExceptions: Boolean read FNoExceptions; + public + constructor Create(ANoExceptions: Boolean = False); virtual; + destructor Destroy; override; + procedure AttachLoadedModule(const Handle: HMODULE); + function CalculateCheckSum: DWORD; + function DirectoryEntryToData(Directory: Word): Pointer; + function GetSectionHeader(const SectionName: string; out Header: PImageSectionHeader): Boolean; + function GetSectionName(Header: PImageSectionHeader): string; + function GetNameInStringTable(Offset: ULONG): string; + function IsBrokenFormat: Boolean; + function IsCLR: Boolean; + function IsSystemImage: Boolean; + // RVA are always DWORD + function RawToVa(Raw: DWORD): Pointer; overload; + function RvaToSection(Rva: DWORD): PImageSectionHeader; overload; + function RvaToVa(Rva: DWORD): Pointer; overload; + function RvaToVaEx(Rva: DWORD): Pointer; overload; + function StatusOK: Boolean; + procedure TryGetNamesForOrdinalImports; + function VerifyCheckSum: Boolean; + class function DebugTypeNames(DebugType: DWORD): string; + class function DirectoryNames(Directory: Word): string; + class function ExpandBySearchPath(const ModuleName, BasePath: string): TFileName; + class function HeaderNames(Index: TJclPeHeader): string; + class function LoadConfigNames(Index: TJclLoadConfig): string; + class function ShortSectionInfo(Characteristics: DWORD): string; + class function DateTimeToStamp(const DateTime: TDateTime): DWORD; + class function StampToDateTime(TimeDateStamp: DWORD): TDateTime; + property AttachedImage: Boolean read FAttachedImage; + property CertificateList: TJclPeCertificateList read GetCertificateList; + property CLRHeader: TJclPeCLRHeader read GetCLRHeader; + property DebugList: TJclPeDebugList read GetDebugList; + property Description: string read GetDescription; + property Directories[Directory: Word]: TImageDataDirectory read GetDirectories; + property DirectoryExists[Directory: Word]: Boolean read GetDirectoryExists; + property ExportList: TJclPeExportFuncList read GetExportList; + property FileName: TFileName read FFileName write SetFileName; + {$IFNDEF WINSCP} + property FileProperties: TJclPeFileProperties read GetFileProperties; + {$ENDIF ~WINSCP} + property HeaderValues[Index: TJclPeHeader]: string read GetHeaderValues; + property ImageSectionCount: Integer read GetImageSectionCount; + property ImageSectionHeaders[Index: Integer]: TImageSectionHeader read GetImageSectionHeaders; + property ImageSectionNames[Index: Integer]: string read GetImageSectionNames; + property ImageSectionFullNames[Index: Integer]: string read GetImageSectionFullNames; + property ImageSectionNameFromRva[const Rva: DWORD]: string read GetImageSectionNameFromRva; + property ImportList: TJclPeImportList read GetImportList; + property LoadConfigValues[Index: TJclLoadConfig]: string read GetLoadConfigValues; + property LoadedImage: TLoadedImage read FLoadedImage; + property MappedAddress: TJclAddr read GetMappedAddress; + property StringTableCount: Integer read GetStringTableCount; + property StringTable[Index: Integer]: string read GetStringTableItem; + // use the following properties + // property OptionalHeader: TImageOptionalHeader + property OptionalHeader32: TImageOptionalHeader32 read GetOptionalHeader32; + property OptionalHeader64: TImageOptionalHeader64 read GetOptionalHeader64; + property ReadOnlyAccess: Boolean read FReadOnlyAccess write FReadOnlyAccess; + property RelocationList: TJclPeRelocList read GetRelocationList; + property ResourceVA: TJclAddr read FResourceVA; + property ResourceList: TJclPeRootResourceList read GetResourceList; + property Status: TJclPeImageStatus read FStatus; + property Target: TJclPeTarget read FTarget; + property UnusedHeaderBytes: TImageDataDirectory read GetUnusedHeaderBytes; + property VersionInfo: TJclFileVersionInfo read GetVersionInfo; + property VersionInfoAvailable: Boolean read GetVersionInfoAvailable; + end; + + {$IFDEF BORLAND} + TJclPeBorImage = class; + + TJclPeBorImagesCache = class(TJclPeImagesCache) + private + function GetImages(const FileName: TFileName): TJclPeBorImage; + protected + function GetPeImageClass: TJclPeImageClass; override; + public + property Images[const FileName: TFileName]: TJclPeBorImage read GetImages; default; + end; + + // Borland Delphi PE Image specific information + TJclPePackageInfo = class(TObject) + private + FAvailable: Boolean; + FContains: TStringList; + FDcpName: string; + FRequires: TStringList; + FFlags: Integer; + FDescription: string; + FEnsureExtension: Boolean; + FSorted: Boolean; + function GetContains: TStrings; + function GetContainsCount: Integer; + function GetContainsFlags(Index: Integer): Byte; + function GetContainsNames(Index: Integer): string; + function GetRequires: TStrings; + function GetRequiresCount: Integer; + function GetRequiresNames(Index: Integer): string; + protected + procedure ReadPackageInfo(ALibHandle: THandle); + procedure SetDcpName(const Value: string); + public + constructor Create(ALibHandle: THandle); + destructor Destroy; override; + class function PackageModuleTypeToString(Flags: Cardinal): string; + class function PackageOptionsToString(Flags: Cardinal): string; + class function ProducerToString(Flags: Cardinal): string; + class function UnitInfoFlagsToString(UnitFlags: Byte): string; + property Available: Boolean read FAvailable; + property Contains: TStrings read GetContains; + property ContainsCount: Integer read GetContainsCount; + property ContainsNames[Index: Integer]: string read GetContainsNames; + property ContainsFlags[Index: Integer]: Byte read GetContainsFlags; + property Description: string read FDescription; + property DcpName: string read FDcpName; + property EnsureExtension: Boolean read FEnsureExtension write FEnsureExtension; + property Flags: Integer read FFlags; + property Requires: TStrings read GetRequires; + property RequiresCount: Integer read GetRequiresCount; + property RequiresNames[Index: Integer]: string read GetRequiresNames; + property Sorted: Boolean read FSorted write FSorted; + end; + + TJclPeBorForm = class(TObject) + private + FFormFlags: TFilerFlags; + FFormClassName: string; + FFormObjectName: string; + FFormPosition: Integer; + FResItem: TJclPeResourceItem; + function GetDisplayName: string; + public + constructor Create(AResItem: TJclPeResourceItem; AFormFlags: TFilerFlags; + AFormPosition: Integer; const AFormClassName, AFormObjectName: string); + procedure ConvertFormToText(const Stream: TStream); overload; + procedure ConvertFormToText(const Strings: TStrings); overload; + property FormClassName: string read FFormClassName; + property FormFlags: TFilerFlags read FFormFlags; + property FormObjectName: string read FFormObjectName; + property FormPosition: Integer read FFormPosition; + property DisplayName: string read GetDisplayName; + property ResItem: TJclPeResourceItem read FResItem; + end; + + TJclPeBorImage = class(TJclPeImage) + private + FForms: TObjectList; + FIsPackage: Boolean; + FIsBorlandImage: Boolean; + FLibHandle: THandle; + FPackageInfo: TJclPePackageInfo; + FPackageInfoSorted: Boolean; + FPackageCompilerVersion: Integer; + function GetFormCount: Integer; + function GetForms(Index: Integer): TJclPeBorForm; + function GetFormFromName(const FormClassName: string): TJclPeBorForm; + function GetLibHandle: THandle; + function GetPackageCompilerVersion: Integer; + function GetPackageInfo: TJclPePackageInfo; + protected + procedure AfterOpen; override; + procedure Clear; override; + procedure CreateFormsList; + public + constructor Create(ANoExceptions: Boolean = False); override; + destructor Destroy; override; + function DependedPackages(List: TStrings; FullPathName, Descriptions: Boolean): Boolean; + function FreeLibHandle: Boolean; + property Forms[Index: Integer]: TJclPeBorForm read GetForms; + property FormCount: Integer read GetFormCount; + property FormFromName[const FormClassName: string]: TJclPeBorForm read GetFormFromName; + property IsBorlandImage: Boolean read FIsBorlandImage; + property IsPackage: Boolean read FIsPackage; + property LibHandle: THandle read GetLibHandle; + property PackageCompilerVersion: Integer read GetPackageCompilerVersion; + property PackageInfo: TJclPePackageInfo read GetPackageInfo; + property PackageInfoSorted: Boolean read FPackageInfoSorted write FPackageInfoSorted; + end; + {$ENDIF BORLAND} + + // Threaded function search + TJclPeNameSearchOption = (seImports, seDelayImports, seBoundImports, seExports); + TJclPeNameSearchOptions = set of TJclPeNameSearchOption; + + TJclPeNameSearchNotifyEvent = procedure (Sender: TObject; PeImage: TJclPeImage; + var Process: Boolean) of object; + TJclPeNameSearchFoundEvent = procedure (Sender: TObject; const FileName: TFileName; + const FunctionName: string; Option: TJclPeNameSearchOption) of object; + + TJclPeNameSearch = class(TThread) + private + F_FileName: TFileName; + F_FunctionName: string; + F_Option: TJclPeNameSearchOption; + F_Process: Boolean; + FFunctionName: string; + FOptions: TJclPeNameSearchOptions; + FPath: string; + FPeImage: TJclPeImage; + FOnFound: TJclPeNameSearchFoundEvent; + FOnProcessFile: TJclPeNameSearchNotifyEvent; + protected + function CompareName(const FunctionName, ComparedName: string): Boolean; virtual; + procedure DoFound; + procedure DoProcessFile; + procedure Execute; override; + public + constructor Create(const FunctionName, Path: string; Options: TJclPeNameSearchOptions = [seImports, seExports]); + procedure Start; + property OnFound: TJclPeNameSearchFoundEvent read FOnFound write FOnFound; + property OnProcessFile: TJclPeNameSearchNotifyEvent read FOnProcessFile write FOnProcessFile; + end; + +// PE Image miscellaneous functions +type + TJclRebaseImageInfo32 = record + OldImageSize: DWORD; + OldImageBase: TJclAddr32; + NewImageSize: DWORD; + NewImageBase: TJclAddr32; + end; + TJclRebaseImageInfo64 = record + OldImageSize: DWORD; + OldImageBase: TJclAddr64; + NewImageSize: DWORD; + NewImageBase: TJclAddr64; + end; + + // renamed + // TJclRebaseImageInfo = TJclRebaseImageInfo32; + +{ Image validity } + +function IsValidPeFile(const FileName: TFileName): Boolean; + +// use PeGetNtHeaders32 for backward compatibility +// function PeGetNtHeaders(const FileName: TFileName; out NtHeaders: TImageNtHeaders): Boolean; +function PeGetNtHeaders32(const FileName: TFileName; out NtHeaders: TImageNtHeaders32): Boolean; +function PeGetNtHeaders64(const FileName: TFileName; out NtHeaders: TImageNtHeaders64): Boolean; + +{ Image modifications } + +function PeCreateNameHintTable(const FileName: TFileName): Boolean; + +// use PeRebaseImage32 +//function PeRebaseImage(const ImageName: TFileName; NewBase: DWORD = 0; TimeStamp: DWORD = 0; +// MaxNewSize: DWORD = 0): TJclRebaseImageInfo; +function PeRebaseImage32(const ImageName: TFileName; NewBase: TJclAddr32 = 0; TimeStamp: DWORD = 0; + MaxNewSize: DWORD = 0): TJclRebaseImageInfo32; +function PeRebaseImage64(const ImageName: TFileName; NewBase: TJclAddr64 = 0; TimeStamp: DWORD = 0; + MaxNewSize: DWORD = 0): TJclRebaseImageInfo64; + +function PeUpdateLinkerTimeStamp(const FileName: TFileName; const Time: TDateTime): Boolean; +function PeReadLinkerTimeStamp(const FileName: TFileName): TDateTime; + +function PeInsertSection(const FileName: TFileName; SectionStream: TStream; SectionName: string): Boolean; + +{ Image Checksum } + +function PeVerifyCheckSum(const FileName: TFileName): Boolean; +function PeClearCheckSum(const FileName: TFileName): Boolean; +function PeUpdateCheckSum(const FileName: TFileName): Boolean; + +// Various simple PE Image searching and listing routines +{ Exports searching } + +function PeDoesExportFunction(const FileName: TFileName; const FunctionName: string; + Options: TJclSmartCompOptions = []): Boolean; + +function PeIsExportFunctionForwardedEx(const FileName: TFileName; const FunctionName: string; + out ForwardedName: string; Options: TJclSmartCompOptions = []): Boolean; +function PeIsExportFunctionForwarded(const FileName: TFileName; const FunctionName: string; + Options: TJclSmartCompOptions = []): Boolean; + +{ Imports searching } + +function PeDoesImportFunction(const FileName: TFileName; const FunctionName: string; + const LibraryName: string = ''; Options: TJclSmartCompOptions = []): Boolean; + +function PeDoesImportLibrary(const FileName: TFileName; const LibraryName: string; + Recursive: Boolean = False): Boolean; + +{ Imports listing } + +function PeImportedLibraries(const FileName: TFileName; const LibrariesList: TStrings; + Recursive: Boolean = False; FullPathName: Boolean = False): Boolean; + +function PeImportedFunctions(const FileName: TFileName; const FunctionsList: TStrings; + const LibraryName: string = ''; IncludeLibNames: Boolean = False): Boolean; + +{ Exports listing } + +function PeExportedFunctions(const FileName: TFileName; const FunctionsList: TStrings): Boolean; +function PeExportedNames(const FileName: TFileName; const FunctionsList: TStrings): Boolean; +function PeExportedVariables(const FileName: TFileName; const FunctionsList: TStrings): Boolean; + +{ Resources listing } + +function PeResourceKindNames(const FileName: TFileName; ResourceType: TJclPeResourceKind; + const NamesList: TStrings): Boolean; + +{ Borland packages specific } + +{$IFDEF BORLAND} +function PeBorFormNames(const FileName: TFileName; const NamesList: TStrings): Boolean; + +function PeBorDependedPackages(const FileName: TFileName; PackagesList: TStrings; + FullPathName, Descriptions: Boolean): Boolean; +{$ENDIF BORLAND} + +// Missing imports checking routines +function PeFindMissingImports(const FileName: TFileName; MissingImportsList: TStrings): Boolean; overload; +function PeFindMissingImports(RequiredImportsList, MissingImportsList: TStrings): Boolean; overload; + +function PeCreateRequiredImportList(const FileName: TFileName; RequiredImportsList: TStrings): Boolean; + +// Mapped or loaded image related routines +// use PeMapImgNtHeaders32 +// function PeMapImgNtHeaders(const BaseAddress: Pointer): PImageNtHeaders; +function PeMapImgNtHeaders32(const BaseAddress: Pointer): PImageNtHeaders32; overload; +function PeMapImgNtHeaders32(Stream: TStream; const BasePosition: Int64; out NtHeaders32: TImageNtHeaders32): Int64; overload; +function PeMapImgNtHeaders64(const BaseAddress: Pointer): PImageNtHeaders64; overload; +function PeMapImgNtHeaders64(Stream: TStream; const BasePosition: Int64; out NtHeaders64: TImageNtHeaders64): Int64; overload; + +function PeMapImgLibraryName(const BaseAddress: Pointer): string; +function PeMapImgLibraryName32(const BaseAddress: Pointer): string; +function PeMapImgLibraryName64(const BaseAddress: Pointer): string; + +function PeMapImgSize(const BaseAddress: Pointer): DWORD; overload; +function PeMapImgSize(Stream: TStream; const BasePosition: Int64): DWORD; overload; +function PeMapImgSize32(const BaseAddress: Pointer): DWORD; overload; +function PeMapImgSize32(Stream: TStream; const BasePosition: Int64): DWORD; overload; +function PeMapImgSize64(const BaseAddress: Pointer): DWORD; overload; +function PeMapImgSize64(Stream: TStream; const BasePosition: Int64): DWORD; overload; + +function PeMapImgTarget(const BaseAddress: Pointer): TJclPeTarget; overload; +function PeMapImgTarget(Stream: TStream; const BasePosition: Int64): TJclPeTarget; overload; + +type + TImageSectionHeaderArray = array of TImageSectionHeader; + +// use PeMapImgSections32 +// function PeMapImgSections(NtHeaders: PImageNtHeaders): PImageSectionHeader; +function PeMapImgSections32(NtHeaders: PImageNtHeaders32): PImageSectionHeader; overload; +function PeMapImgSections32(Stream: TStream; const NtHeaders32Position: Int64; const NtHeaders32: TImageNtHeaders32; + out ImageSectionHeaders: TImageSectionHeaderArray): Int64; overload; +function PeMapImgSections64(NtHeaders: PImageNtHeaders64): PImageSectionHeader; overload; +function PeMapImgSections64(Stream: TStream; const NtHeaders64Position: Int64; const NtHeaders64: TImageNtHeaders64; + out ImageSectionHeaders: TImageSectionHeaderArray): Int64; overload; + +// use PeMapImgFindSection32 +// function PeMapImgFindSection(NtHeaders: PImageNtHeaders; +// const SectionName: string): PImageSectionHeader; +function PeMapImgFindSection32(NtHeaders: PImageNtHeaders32; + const SectionName: string): PImageSectionHeader; +function PeMapImgFindSection64(NtHeaders: PImageNtHeaders64; + const SectionName: string): PImageSectionHeader; +function PeMapImgFindSection(const ImageSectionHeaders: TImageSectionHeaderArray; + const SectionName: string): SizeInt; + +function PeMapImgFindSectionFromModule(const BaseAddress: Pointer; + const SectionName: string): PImageSectionHeader; + +function PeMapImgExportedVariables(const Module: HMODULE; const VariablesList: TStrings): Boolean; + +function PeMapImgResolvePackageThunk(Address: Pointer): Pointer; + +function PeMapFindResource(const Module: HMODULE; const ResourceType: PChar; + const ResourceName: string): Pointer; + +type + TJclPeSectionStream = class(TCustomMemoryStream) + private + FInstance: HMODULE; + FSectionHeader: TImageSectionHeader; + procedure Initialize(Instance: HMODULE; const ASectionName: string); + public + constructor Create(Instance: HMODULE; const ASectionName: string); + function Write(const Buffer; Count: Longint): Longint; override; + property Instance: HMODULE read FInstance; + property SectionHeader: TImageSectionHeader read FSectionHeader; + end; + +// API hooking classes +type + TJclPeMapImgHookItem = class(TObject) + private + FBaseAddress: Pointer; + FFunctionName: string; + FModuleName: string; + FNewAddress: Pointer; + FOriginalAddress: Pointer; + FList: TObjectList; + protected + function InternalUnhook: Boolean; + public + constructor Create(AList: TObjectList; const AFunctionName: string; + const AModuleName: string; ABaseAddress, ANewAddress, AOriginalAddress: Pointer); + destructor Destroy; override; + function Unhook: Boolean; + property BaseAddress: Pointer read FBaseAddress; + property FunctionName: string read FFunctionName; + property ModuleName: string read FModuleName; + property NewAddress: Pointer read FNewAddress; + property OriginalAddress: Pointer read FOriginalAddress; + end; + + TJclPeMapImgHooks = class(TObjectList) + private + function GetItems(Index: Integer): TJclPeMapImgHookItem; + function GetItemFromOriginalAddress(OriginalAddress: Pointer): TJclPeMapImgHookItem; + function GetItemFromNewAddress(NewAddress: Pointer): TJclPeMapImgHookItem; + public + function HookImport(Base: Pointer; const ModuleName: string; + const FunctionName: string; NewAddress: Pointer; var OriginalAddress: Pointer): Boolean; + class function IsWin9xDebugThunk(P: Pointer): Boolean; + class function ReplaceImport(Base: Pointer; const ModuleName: string; FromProc, ToProc: Pointer): Boolean; + class function SystemBase: Pointer; + procedure UnhookAll; + function UnhookByNewAddress(NewAddress: Pointer): Boolean; + procedure UnhookByBaseAddress(BaseAddress: Pointer); + property Items[Index: Integer]: TJclPeMapImgHookItem read GetItems; default; + property ItemFromOriginalAddress[OriginalAddress: Pointer]: TJclPeMapImgHookItem read GetItemFromOriginalAddress; + property ItemFromNewAddress[NewAddress: Pointer]: TJclPeMapImgHookItem read GetItemFromNewAddress; + end; + +// Image access under a debbuger +function PeDbgImgNtHeaders32(ProcessHandle: THandle; BaseAddress: TJclAddr32; + var NtHeaders: TImageNtHeaders32): Boolean; +// TODO 64 bit version +//function PeDbgImgNtHeaders64(ProcessHandle: THandle; BaseAddress: TJclAddr64; +// var NtHeaders: TImageNtHeaders64): Boolean; + +function PeDbgImgLibraryName32(ProcessHandle: THandle; BaseAddress: TJclAddr32; + var Name: string): Boolean; +//function PeDbgImgLibraryName64(ProcessHandle: THandle; BaseAddress: TJclAddr64; +// var Name: string): Boolean; + +// Borland BPL packages name unmangling +type + TJclBorUmSymbolKind = (skData, skFunction, skConstructor, skDestructor, skRTTI, skVTable); + TJclBorUmSymbolModifier = (smQualified, smLinkProc); + TJclBorUmSymbolModifiers = set of TJclBorUmSymbolModifier; + TJclBorUmDescription = record + Kind: TJclBorUmSymbolKind; + Modifiers: TJclBorUmSymbolModifiers; + end; + TJclBorUmResult = (urOk, urNotMangled, urMicrosoft, urError); + TJclPeUmResult = (umNotMangled, umBorland, umMicrosoft); + +function PeBorUnmangleName(const Name: string; out Unmangled: string; + out Description: TJclBorUmDescription; out BasePos: Integer): TJclBorUmResult; overload; +function PeBorUnmangleName(const Name: string; out Unmangled: string; + out Description: TJclBorUmDescription): TJclBorUmResult; overload; +function PeBorUnmangleName(const Name: string; out Unmangled: string): TJclBorUmResult; overload; +function PeBorUnmangleName(const Name: string): string; overload; + +function PeIsNameMangled(const Name: string): TJclPeUmResult; + +function UndecorateSymbolName(const DecoratedName: string; out UnMangled: string; Flags: DWORD): Boolean; +function PeUnmangleName(const Name: string; out Unmangled: string): TJclPeUmResult; + +{$IFDEF UNITVERSIONING} +const + UnitVersioning: TUnitVersionInfo = ( + RCSfile: '$URL$'; + Revision: '$Revision$'; + Date: '$Date$'; + LogPath: 'JCL\source\windows'; + Extra: ''; + Data: nil + ); +{$ENDIF UNITVERSIONING} + +implementation + +uses + {$IFDEF HAS_UNITSCOPE} + System.RTLConsts, + System.Types, // for inlining TList.Remove + {$IFDEF HAS_UNIT_CHARACTER} + System.Character, + {$ENDIF HAS_UNIT_CHARACTER} + {$ELSE ~HAS_UNITSCOPE} + RTLConsts, + {$IFDEF HAS_UNIT_CHARACTER} + Character, + {$ENDIF HAS_UNIT_CHARACTER} + {$ENDIF ~HAS_UNITSCOPE} + {$IFNDEF WINSCP}JclLogic,{$ELSE}Math, System.AnsiStrings, {$ENDIF ~WINSCP} JclResources, JclSysUtils, {$IFNDEF WINSCP}JclAnsiStrings,{$ENDIF ~WINSCP} JclStrings{$IFNDEF WINSCP}, JclStringConversions{$ENDIF ~WINSCP}; + +const + MANIFESTExtension = '.manifest'; + + DebugSectionName = '.debug'; + ReadOnlySectionName = '.rdata'; + + BinaryExtensionLibrary = '.dll'; + + {$IFDEF BORLAND} + CompilerExtensionDCP = '.dcp'; + BinaryExtensionPackage = '.bpl'; + + PackageInfoResName = 'PACKAGEINFO'; + DescriptionResName = 'DESCRIPTION'; + PackageOptionsResName = 'PACKAGEOPTIONS'; + DVclAlResName = 'DVCLAL'; + {$ENDIF BORLAND} + +{$IFDEF WINSCP} +// Stubs for JclStringConversions functions + +function TryUTF8ToString(const S: TUTF8String; out D: string): Boolean; +begin + Result := False; +end; + +function TryStringToUTF8(const S: string; out D: TUTF8String): Boolean; +begin + Result := False; +end; + +// stub for JclDateTime constant +const + UnixTimeStart = UnixDateDelta; + +// from JclAnsiStrings.pas + +function StrLCompA(const Str1, Str2: PAnsiChar; MaxLen: Cardinal): Integer; +begin + Result := {$IFDEF DEPRECATED_SYSUTILS_ANSISTRINGS}System.AnsiStrings.{$ENDIF}StrLComp(Str1, Str2, MaxLen); +end; + +function StrPLCopyA(Dest: PAnsiChar; const Source: AnsiString; MaxLen: Cardinal): PAnsiChar; +begin + Result := {$IFDEF DEPRECATED_SYSUTILS_ANSISTRINGS}System.AnsiStrings.{$ENDIF}StrPLCopy(Dest, Source, MaxLen); +end; + +function StrICompA(const Str1, Str2: PAnsiChar): Integer; +begin + Result := {$IFDEF DEPRECATED_SYSUTILS_ANSISTRINGS}System.AnsiStrings.{$ENDIF}StrIComp(Str1, Str2); +end; + +function StrLenA(S: PAnsiChar): Integer; +begin + Result := {$IFDEF DEPRECATED_SYSUTILS_ANSISTRINGS}System.AnsiStrings.{$ENDIF}StrLen(S); +end; + +{$ENDIF} + +// Helper routines +function AddFlagTextRes(var Text: string; const FlagText: PResStringRec; const Value, Mask: Cardinal): Boolean; +begin + Result := (Value and Mask <> 0); + if Result then + begin + if Length(Text) > 0 then + Text := Text + ', '; + Text := Text + LoadResString(FlagText); + end; +end; + +function CompareResourceName(T1, T2: PChar): Boolean; +var + Long1, Long2: LongRec; +begin + {$IFDEF CPU64} + Long1 := LongRec(Int64Rec(T1).Lo); + Long2 := LongRec(Int64Rec(T2).Lo); + if (Int64Rec(T1).Hi = 0) and (Int64Rec(T2).Hi = 0) and (Long1.Hi = 0) and (Long2.Hi = 0) then + {$ENDIF CPU64} + {$IFDEF CPU32} + Long1 := LongRec(T1); + Long2 := LongRec(T2); + if (Long1.Hi = 0) or (Long2.Hi = 0) then + {$ENDIF CPU32} + Result := Long1.Lo = Long2.Lo + else + Result := (StrIComp(T1, T2) = 0); +end; + +function CreatePeImage(const FileName: TFileName): TJclPeImage; +begin + Result := TJclPeImage.Create(True); + Result.FileName := FileName; +end; + +function InternalImportedLibraries(const FileName: TFileName; + Recursive, FullPathName: Boolean; ExternalCache: TJclPeImagesCache): TStringList; +var + Cache: TJclPeImagesCache; + + procedure ProcessLibraries(const AFileName: TFileName); + var + I: Integer; + S: TFileName; + ImportLib: TJclPeImportLibItem; + begin + with Cache[AFileName].ImportList do + for I := 0 to Count - 1 do + begin + ImportLib := Items[I]; + if FullPathName then + S := ImportLib.FileName + else + S := TFileName(ImportLib.Name); + if Result.IndexOf(S) = -1 then + begin + Result.Add(S); + if Recursive then + ProcessLibraries(ImportLib.FileName); + end; + end; + end; + +begin + if ExternalCache = nil then + Cache := TJclPeImagesCache.Create + else + Cache := ExternalCache; + try + Result := TStringList.Create; + try + Result.Sorted := True; + Result.Duplicates := dupIgnore; + ProcessLibraries(FileName); + except + FreeAndNil(Result); + raise; + end; + finally + if ExternalCache = nil then + Cache.Free; + end; +end; + +// Smart name compare function +function PeStripFunctionAW(const FunctionName: string): string; +var + L: Integer; +begin + Result := FunctionName; + L := Length(Result); + if (L > 1) then + case Result[L] of + 'A', 'W': + if CharIsValidIdentifierLetter(Result[L - 1]) then + Delete(Result, L, 1); + end; +end; + +function PeSmartFunctionNameSame(const ComparedName, FunctionName: string; + Options: TJclSmartCompOptions): Boolean; +var + S: string; +begin + if scIgnoreCase in Options then + Result := CompareText(FunctionName, ComparedName) = 0 + else + Result := (FunctionName = ComparedName); + if (not Result) and not (scSimpleCompare in Options) then + begin + if Length(FunctionName) > 0 then + begin + S := PeStripFunctionAW(FunctionName); + if scIgnoreCase in Options then + Result := CompareText(S, ComparedName) = 0 + else + Result := (S = ComparedName); + end + else + Result := False; + end; +end; + +//=== { TJclPeImagesCache } ================================================== + +constructor TJclPeImagesCache.Create; +begin + inherited Create; + FList := TStringList.Create; + FList.Sorted := True; + FList.Duplicates := dupIgnore; +end; + +destructor TJclPeImagesCache.Destroy; +begin + Clear; + FreeAndNil(FList); + inherited Destroy; +end; + +procedure TJclPeImagesCache.Clear; +var + I: Integer; +begin + with FList do + for I := 0 to Count - 1 do + Objects[I].Free; + FList.Clear; +end; + +function TJclPeImagesCache.GetCount: Integer; +begin + Result := FList.Count; +end; + +function TJclPeImagesCache.GetImages(const FileName: TFileName): TJclPeImage; +var + I: Integer; +begin + I := FList.IndexOf(FileName); + if I = -1 then + begin + Result := GetPeImageClass.Create(True); + Result.FileName := FileName; + FList.AddObject(FileName, Result); + end + else + Result := TJclPeImage(FList.Objects[I]); +end; + +function TJclPeImagesCache.GetPeImageClass: TJclPeImageClass; +begin + Result := TJclPeImage; +end; + +//=== { TJclPeImageBaseList } ================================================ + +constructor TJclPeImageBaseList.Create(AImage: TJclPeImage); +begin + inherited Create(True); + FImage := AImage; +end; + +// Import sort functions + +function ImportSortByName(Item1, Item2: Pointer): Integer; +begin + Result := CompareStr(TJclPeImportFuncItem(Item1).Name, TJclPeImportFuncItem(Item2).Name); + if Result = 0 then + Result := CompareStr(TJclPeImportFuncItem(Item1).ImportLib.Name, TJclPeImportFuncItem(Item2).ImportLib.Name); + if Result = 0 then + Result := TJclPeImportFuncItem(Item1).Ordinal - TJclPeImportFuncItem(Item2).Ordinal; +end; + +function ImportSortByNameDESC(Item1, Item2: Pointer): Integer; +begin + Result := ImportSortByName(Item2, Item1); +end; + +function ImportSortByHint(Item1, Item2: Pointer): Integer; +begin + Result := TJclPeImportFuncItem(Item1).Hint - TJclPeImportFuncItem(Item2).Hint; +end; + +function ImportSortByHintDESC(Item1, Item2: Pointer): Integer; +begin + Result := ImportSortByHint(Item2, Item1); +end; + +function ImportSortByDll(Item1, Item2: Pointer): Integer; +begin + Result := CompareStr(TJclPeImportFuncItem(Item1).ImportLib.Name, + TJclPeImportFuncItem(Item2).ImportLib.Name); + if Result = 0 then + Result := ImportSortByName(Item1, Item2); +end; + +function ImportSortByDllDESC(Item1, Item2: Pointer): Integer; +begin + Result := ImportSortByDll(Item2, Item1); +end; + +function ImportSortByOrdinal(Item1, Item2: Pointer): Integer; +begin + Result := CompareStr(TJclPeImportFuncItem(Item1).ImportLib.Name, + TJclPeImportFuncItem(Item2).ImportLib.Name); + if Result = 0 then + Result := TJclPeImportFuncItem(Item1).Ordinal - TJclPeImportFuncItem(Item2).Ordinal; +end; + +function ImportSortByOrdinalDESC(Item1, Item2: Pointer): Integer; +begin + Result := ImportSortByOrdinal(Item2, Item1); +end; + +function GetImportSortFunction(SortType: TJclPeImportSort; Descending: Boolean): TListSortCompare; +const + SortFunctions: array [TJclPeImportSort, Boolean] of TListSortCompare = + ((ImportSortByName, ImportSortByNameDESC), + (ImportSortByOrdinal, ImportSortByOrdinalDESC), + (ImportSortByHint, ImportSortByHintDESC), + (ImportSortByDll, ImportSortByDllDESC) + ); +begin + Result := SortFunctions[SortType, Descending]; +end; + +function ImportLibSortByIndex(Item1, Item2: Pointer): Integer; +begin + Result := TJclPeImportLibItem(Item1).ImportDirectoryIndex - + TJclPeImportLibItem(Item2).ImportDirectoryIndex; +end; + +function ImportLibSortByName(Item1, Item2: Pointer): Integer; +begin + Result := AnsiCompareStr(TJclPeImportLibItem(Item1).Name, TJclPeImportLibItem(Item2).Name); + if Result = 0 then + Result := ImportLibSortByIndex(Item1, Item2); +end; + +function GetImportLibSortFunction(SortType: TJclPeImportLibSort): TListSortCompare; +const + SortFunctions: array [TJclPeImportLibSort] of TListSortCompare = + (ImportLibSortByName, ImportLibSortByIndex); +begin + Result := SortFunctions[SortType]; +end; + +//=== { TJclPeImportFuncItem } =============================================== + +constructor TJclPeImportFuncItem.Create(AImportLib: TJclPeImportLibItem; + AOrdinal: Word; AHint: Word; const AName: string); +begin + inherited Create; + FImportLib := AImportLib; + FOrdinal := AOrdinal; + FHint := AHint; + FName := AName; + FResolveCheck := icNotChecked; + FIndirectImportName := False; +end; + +function TJclPeImportFuncItem.GetIsByOrdinal: Boolean; +begin + Result := FOrdinal <> 0; +end; + +procedure TJclPeImportFuncItem.SetIndirectImportName(const Value: string); +begin + FName := Value; + FIndirectImportName := True; +end; + +procedure TJclPeImportFuncItem.SetName(const Value: string); +begin + FName := Value; + FIndirectImportName := False; +end; + +procedure TJclPeImportFuncItem.SetResolveCheck(Value: TJclPeResolveCheck); +begin + FResolveCheck := Value; +end; + +//=== { TJclPeImportLibItem } ================================================ + +constructor TJclPeImportLibItem.Create(AImage: TJclPeImage; + AImportDescriptor: Pointer; AImportKind: TJclPeImportKind; const AName: string; + AThunk: Pointer); +begin + inherited Create(AImage); + FTotalResolveCheck := icNotChecked; + FImportDescriptor := AImportDescriptor; + FImportKind := AImportKind; + FName := AName; + FThunk := AThunk; + FThunkData := AThunk; +end; + +procedure TJclPeImportLibItem.CheckImports(ExportImage: TJclPeImage); +var + I: Integer; + ExportList: TJclPeExportFuncList; +begin + if ExportImage.StatusOK then + begin + FTotalResolveCheck := icResolved; + ExportList := ExportImage.ExportList; + for I := 0 to Count - 1 do + begin + with Items[I] do + if IsByOrdinal then + begin + if ExportList.OrdinalValid(Ordinal) then + SetResolveCheck(icResolved) + else + begin + SetResolveCheck(icUnresolved); + Self.FTotalResolveCheck := icUnresolved; + end; + end + else + begin + if ExportList.ItemFromName[Items[I].Name] <> nil then + SetResolveCheck(icResolved) + else + begin + SetResolveCheck(icUnresolved); + Self.FTotalResolveCheck := icUnresolved; + end; + end; + end; + end + else + begin + FTotalResolveCheck := icUnresolved; + for I := 0 to Count - 1 do + Items[I].SetResolveCheck(icUnresolved); + end; +end; + +procedure TJclPeImportLibItem.CreateList; + procedure CreateList32; + var + Thunk32: PImageThunkData32; + OrdinalName: PImageImportByName; + Ordinal, Hint: Word; + Name: PAnsiChar; + ImportName: string; + begin + Thunk32 := PImageThunkData32(FThunk); + while Thunk32^.Function_ <> 0 do + begin + Ordinal := 0; + Hint := 0; + Name := nil; + if Thunk32^.Ordinal and IMAGE_ORDINAL_FLAG32 = 0 then + begin + case ImportKind of + ikImport, ikBoundImport: + begin + OrdinalName := PImageImportByName(Image.RvaToVa(Thunk32^.AddressOfData)); + Hint := OrdinalName.Hint; + Name := OrdinalName.Name; + end; + ikDelayImport: + begin + OrdinalName := PImageImportByName(Image.RvaToVaEx(Thunk32^.AddressOfData)); + Hint := OrdinalName.Hint; + Name := OrdinalName.Name; + end; + end; + end + else + Ordinal := IMAGE_ORDINAL32(Thunk32^.Ordinal); + if not TryUTF8ToString(Name, ImportName) then + ImportName := string(Name); + Add(TJclPeImportFuncItem.Create(Self, Ordinal, Hint, ImportName)); + Inc(Thunk32); + end; + end; + + procedure CreateList64; + var + Thunk64: PImageThunkData64; + OrdinalName: PImageImportByName; + Ordinal, Hint: Word; + Name: PAnsiChar; + ImportName: string; + begin + Thunk64 := PImageThunkData64(FThunk); + while Thunk64^.Function_ <> 0 do + begin + Ordinal := 0; + Hint := 0; + Name := nil; + if Thunk64^.Ordinal and IMAGE_ORDINAL_FLAG64 = 0 then + begin + case ImportKind of + ikImport, ikBoundImport: + begin + OrdinalName := PImageImportByName(Image.RvaToVa(Thunk64^.AddressOfData)); + Hint := OrdinalName.Hint; + Name := OrdinalName.Name; + end; + ikDelayImport: + begin + OrdinalName := PImageImportByName(Image.RvaToVaEx(Thunk64^.AddressOfData)); + Hint := OrdinalName.Hint; + Name := OrdinalName.Name; + end; + end; + end + else + Ordinal := IMAGE_ORDINAL64(Thunk64^.Ordinal); + if not TryUTF8ToString(Name, ImportName) then + ImportName := string(Name); + Add(TJclPeImportFuncItem.Create(Self, Ordinal, Hint, ImportName)); + Inc(Thunk64); + end; + end; +begin + if FThunk = nil then + Exit; + + case Image.Target of + taWin32: + CreateList32; + taWin64: + CreateList64; + end; + + FThunk := nil; +end; + +function TJclPeImportLibItem.GetCount: Integer; +begin + if FThunk <> nil then + CreateList; + Result := inherited Count; +end; + +function TJclPeImportLibItem.GetFileName: TFileName; +begin + Result := Image.ExpandModuleName(Name); +end; + +function TJclPeImportLibItem.GetItems(Index: Integer): TJclPeImportFuncItem; +begin + Result := TJclPeImportFuncItem(Get(Index)); +end; + +function TJclPeImportLibItem.GetName: string; +begin + Result := AnsiLowerCase(OriginalName); +end; + +function TJclPeImportLibItem.GetThunkData32: PImageThunkData32; +begin + if Image.Target = taWin32 then + Result := FThunkData + else + Result := nil; +end; + +function TJclPeImportLibItem.GetThunkData64: PImageThunkData64; +begin + if Image.Target = taWin64 then + Result := FThunkData + else + Result := nil; +end; + +procedure TJclPeImportLibItem.SetImportDirectoryIndex(Value: Integer); +begin + FImportDirectoryIndex := Value; +end; + +procedure TJclPeImportLibItem.SetImportKind(Value: TJclPeImportKind); +begin + FImportKind := Value; +end; + +procedure TJclPeImportLibItem.SetSorted(Value: Boolean); +begin + FSorted := Value; +end; + +procedure TJclPeImportLibItem.SetThunk(Value: Pointer); +begin + FThunk := Value; + FThunkData := Value; +end; + +procedure TJclPeImportLibItem.SortList(SortType: TJclPeImportSort; Descending: Boolean); +begin + if not FSorted or (SortType <> FLastSortType) or (Descending <> FLastSortDescending) then + begin + GetCount; // create list if it wasn't created + Sort(GetImportSortFunction(SortType, Descending)); + FLastSortType := SortType; + FLastSortDescending := Descending; + FSorted := True; + end; +end; + +//=== { TJclPeImportList } =================================================== + +constructor TJclPeImportList.Create(AImage: TJclPeImage); +begin + inherited Create(AImage); + FAllItemsList := TList.Create; + FAllItemsList.Capacity := 256; + FUniqueNamesList := TStringList.Create; + FUniqueNamesList.Sorted := True; + FUniqueNamesList.Duplicates := dupIgnore; + FLastAllSortType := isName; + FLastAllSortDescending := False; + CreateList; +end; + +destructor TJclPeImportList.Destroy; +var + I: Integer; +begin + FreeAndNil(FAllItemsList); + FreeAndNil(FUniqueNamesList); + for I := 0 to Length(FparallelImportTable) - 1 do + FreeMem(FparallelImportTable[I]); + inherited Destroy; +end; + +procedure TJclPeImportList.CheckImports(PeImageCache: TJclPeImagesCache); +var + I: Integer; + ExportPeImage: TJclPeImage; +begin + Image.CheckNotAttached; + if PeImageCache <> nil then + ExportPeImage := nil // to make the compiler happy + else + ExportPeImage := TJclPeImage.Create(True); + try + for I := 0 to Count - 1 do + if Items[I].TotalResolveCheck = icNotChecked then + begin + if PeImageCache <> nil then + ExportPeImage := PeImageCache[Items[I].FileName] + else + ExportPeImage.FileName := Items[I].FileName; + ExportPeImage.ExportList.PrepareForFastNameSearch; + Items[I].CheckImports(ExportPeImage); + end; + finally + if PeImageCache = nil then + ExportPeImage.Free; + end; +end; + +procedure TJclPeImportList.CreateList; + procedure CreateDelayImportList32(DelayImportDesc: PImgDelayDescrV1); + var + LibItem: TJclPeImportLibItem; + UTF8Name: TUTF8String; + LibName: string; + begin + while DelayImportDesc^.szName <> nil do + begin + UTF8Name := PAnsiChar(Image.RvaToVaEx(DWORD(DelayImportDesc^.szName))); + if not TryUTF8ToString(UTF8Name, LibName) then + LibName := string(UTF8Name); + LibItem := TJclPeImportLibItem.Create(Image, DelayImportDesc, ikDelayImport, + LibName, Image.RvaToVaEx(DWORD(DelayImportDesc^.pINT))); + Add(LibItem); + FUniqueNamesList.AddObject(AnsiLowerCase(LibItem.Name), LibItem); + Inc(DelayImportDesc); + end; + end; + + procedure CreateDelayImportList64(DelayImportDesc: PImgDelayDescrV2); + var + LibItem: TJclPeImportLibItem; + UTF8Name: TUTF8String; + LibName: string; + begin + while DelayImportDesc^.rvaDLLName <> 0 do + begin + UTF8Name := PAnsiChar(Image.RvaToVa(DelayImportDesc^.rvaDLLName)); + if not TryUTF8ToString(UTF8Name, LibName) then + LibName := string(UTF8Name); + LibItem := TJclPeImportLibItem.Create(Image, DelayImportDesc, ikDelayImport, + LibName, Image.RvaToVa(DelayImportDesc^.rvaINT)); + Add(LibItem); + FUniqueNamesList.AddObject(AnsiLowerCase(LibItem.Name), LibItem); + Inc(DelayImportDesc); + end; + end; +var + ImportDesc: PImageImportDescriptor; + LibItem: TJclPeImportLibItem; + UTF8Name: TUTF8String; + LibName, ModuleName: string; + DelayImportDesc: Pointer; + BoundImports, BoundImport: PImageBoundImportDescriptor; + S: string; + I: Integer; + Thunk: Pointer; +begin + SetCapacity(100); + with Image do + begin + if not StatusOK then + Exit; + ImportDesc := DirectoryEntryToData(IMAGE_DIRECTORY_ENTRY_IMPORT); + if ImportDesc <> nil then + while ImportDesc^.Name <> 0 do + begin + if ImportDesc^.Union.Characteristics = 0 then + begin + if AttachedImage then // Borland images doesn't have two parallel arrays + Thunk := nil // see MakeBorlandImportTableForMappedImage method + else + Thunk := RvaToVa(ImportDesc^.FirstThunk); + FLinkerProducer := lrBorland; + end + else + begin + Thunk := RvaToVa(ImportDesc^.Union.Characteristics); + FLinkerProducer := lrMicrosoft; + end; + UTF8Name := PAnsiChar(RvaToVa(ImportDesc^.Name)); + if not TryUTF8ToString(UTF8Name, LibName) then + LibName := string(UTF8Name); + LibItem := TJclPeImportLibItem.Create(Image, ImportDesc, ikImport, LibName, Thunk); + Add(LibItem); + FUniqueNamesList.AddObject(AnsiLowerCase(LibItem.Name), LibItem); + Inc(ImportDesc); + end; + DelayImportDesc := DirectoryEntryToData(IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT); + if DelayImportDesc <> nil then + begin + case Target of + taWin32: + CreateDelayImportList32(DelayImportDesc); + taWin64: + CreateDelayImportList64(DelayImportDesc); + end; + end; + BoundImports := DirectoryEntryToData(IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT); + if BoundImports <> nil then + begin + BoundImport := BoundImports; + while BoundImport^.OffsetModuleName <> 0 do + begin + UTF8Name := PAnsiChar(TJclAddr(BoundImports) + BoundImport^.OffsetModuleName); + if not TryUTF8ToString(UTF8Name, ModuleName) then + ModuleName := string(UTF8Name); + S := AnsiLowerCase(ModuleName); + I := FUniqueNamesList.IndexOf(S); + if I >= 0 then + TJclPeImportLibItem(FUniqueNamesList.Objects[I]).SetImportKind(ikBoundImport); + for I := 1 to BoundImport^.NumberOfModuleForwarderRefs do + Inc(PImageBoundForwarderRef(BoundImport)); // skip forward information + Inc(BoundImport); + end; + end; + end; + for I := 0 to Count - 1 do + Items[I].SetImportDirectoryIndex(I); +end; + +function TJclPeImportList.GetAllItemCount: Integer; +begin + Result := FAllItemsList.Count; + if Result = 0 then // we haven't created the list yet -> create unsorted list + begin + RefreshAllItems; + Result := FAllItemsList.Count; + end; +end; + +function TJclPeImportList.GetAllItems(Index: Integer): TJclPeImportFuncItem; +begin + Result := TJclPeImportFuncItem(FAllItemsList[Index]); +end; + +function TJclPeImportList.GetItems(Index: Integer): TJclPeImportLibItem; +begin + Result := TJclPeImportLibItem(Get(Index)); +end; + +function TJclPeImportList.GetUniqueLibItemCount: Integer; +begin + Result := FUniqueNamesList.Count; +end; + +function TJclPeImportList.GetUniqueLibItemFromName(const Name: string): TJclPeImportLibItem; +var + I: Integer; +begin + I := FUniqueNamesList.IndexOf(Name); + if I = -1 then + Result := nil + else + Result := TJclPeImportLibItem(FUniqueNamesList.Objects[I]); +end; + +function TJclPeImportList.GetUniqueLibItems(Index: Integer): TJclPeImportLibItem; +begin + Result := TJclPeImportLibItem(FUniqueNamesList.Objects[Index]); +end; + +function TJclPeImportList.GetUniqueLibNames(Index: Integer): string; +begin + Result := FUniqueNamesList[Index]; +end; + +function TJclPeImportList.MakeBorlandImportTableForMappedImage: Boolean; +var + FileImage: TJclPeImage; + I, TableSize: Integer; +begin + if Image.AttachedImage and (LinkerProducer = lrBorland) and + (Length(FParallelImportTable) = 0) then + begin + FileImage := TJclPeImage.Create(True); + try + FileImage.FileName := Image.FileName; + Result := FileImage.StatusOK; + if Result then + begin + SetLength(FParallelImportTable, FileImage.ImportList.Count); + for I := 0 to FileImage.ImportList.Count - 1 do + begin + Assert(Items[I].ImportKind = ikImport); // Borland doesn't have Delay load or Bound imports + TableSize := (FileImage.ImportList[I].Count + 1); + case Image.Target of + taWin32: + begin + TableSize := TableSize * SizeOf(TImageThunkData32); + GetMem(FParallelImportTable[I], TableSize); + System.Move(FileImage.ImportList[I].ThunkData32^, FParallelImportTable[I]^, TableSize); + Items[I].SetThunk(FParallelImportTable[I]); + end; + taWin64: + begin + TableSize := TableSize * SizeOf(TImageThunkData64); + GetMem(FParallelImportTable[I], TableSize); + System.Move(FileImage.ImportList[I].ThunkData64^, FParallelImportTable[I]^, TableSize); + Items[I].SetThunk(FParallelImportTable[I]); + end; + end; + end; + end; + finally + FileImage.Free; + end; + end + else + Result := True; +end; + +procedure TJclPeImportList.RefreshAllItems; +var + L, I: Integer; + LibItem: TJclPeImportLibItem; +begin + FAllItemsList.Clear; + for L := 0 to Count - 1 do + begin + LibItem := Items[L]; + if (Length(FFilterModuleName) = 0) or (AnsiCompareText(LibItem.Name, FFilterModuleName) = 0) then + for I := 0 to LibItem.Count - 1 do + FAllItemsList.Add(LibItem[I]); + end; +end; + +procedure TJclPeImportList.SetFilterModuleName(const Value: string); +begin + if (FFilterModuleName <> Value) or (FAllItemsList.Count = 0) then + begin + FFilterModuleName := Value; + RefreshAllItems; + FAllItemsList.Sort(GetImportSortFunction(FLastAllSortType, FLastAllSortDescending)); + end; +end; + +function TJclPeImportList.SmartFindName(const CompareName, LibName: string; + Options: TJclSmartCompOptions): TJclPeImportFuncItem; +var + L, I: Integer; + LibItem: TJclPeImportLibItem; +begin + Result := nil; + for L := 0 to Count - 1 do + begin + LibItem := Items[L]; + if (Length(LibName) = 0) or (AnsiCompareText(LibItem.Name, LibName) = 0) then + for I := 0 to LibItem.Count - 1 do + if PeSmartFunctionNameSame(CompareName, LibItem[I].Name, Options) then + begin + Result := LibItem[I]; + Break; + end; + end; +end; + +procedure TJclPeImportList.SortAllItemsList(SortType: TJclPeImportSort; Descending: Boolean); +begin + GetAllItemCount; // create list if it wasn't created + FAllItemsList.Sort(GetImportSortFunction(SortType, Descending)); + FLastAllSortType := SortType; + FLastAllSortDescending := Descending; +end; + +procedure TJclPeImportList.SortList(SortType: TJclPeImportLibSort); +begin + Sort(GetImportLibSortFunction(SortType)); +end; + +procedure TJclPeImportList.TryGetNamesForOrdinalImports; +var + LibNamesList: TStringList; + L, I: Integer; + LibPeDump: TJclPeImage; + + procedure TryGetNames(const ModuleName: string); + var + Item: TJclPeImportFuncItem; + I, L: Integer; + ImportLibItem: TJclPeImportLibItem; + ExportItem: TJclPeExportFuncItem; + ExportList: TJclPeExportFuncList; + begin + if Image.AttachedImage then + LibPeDump.AttachLoadedModule(GetModuleHandle(PChar(ModuleName))) + else + LibPeDump.FileName := Image.ExpandModuleName(ModuleName); + if not LibPeDump.StatusOK then + Exit; + ExportList := LibPeDump.ExportList; + for L := 0 to Count - 1 do + begin + ImportLibItem := Items[L]; + if AnsiCompareText(ImportLibItem.Name, ModuleName) = 0 then + begin + for I := 0 to ImportLibItem.Count - 1 do + begin + Item := ImportLibItem[I]; + if Item.IsByOrdinal then + begin + ExportItem := ExportList.ItemFromOrdinal[Item.Ordinal]; + if (ExportItem <> nil) and (ExportItem.Name <> '') then + Item.SetIndirectImportName(ExportItem.Name); + end; + end; + ImportLibItem.SetSorted(False); + end; + end; + end; + +begin + LibNamesList := TStringList.Create; + try + LibNamesList.Sorted := True; + LibNamesList.Duplicates := dupIgnore; + for L := 0 to Count - 1 do + with Items[L] do + for I := 0 to Count - 1 do + if Items[I].IsByOrdinal then + LibNamesList.Add(AnsiUpperCase(Name)); + LibPeDump := TJclPeImage.Create(True); + try + for I := 0 to LibNamesList.Count - 1 do + TryGetNames(LibNamesList[I]); + finally + LibPeDump.Free; + end; + SortAllItemsList(FLastAllSortType, FLastAllSortDescending); + finally + LibNamesList.Free; + end; +end; + +//=== { TJclPeExportFuncItem } =============================================== + +constructor TJclPeExportFuncItem.Create(AExportList: TJclPeExportFuncList; + const AName, AForwardedName: string; AAddress: DWORD; AHint: Word; + AOrdinal: Word; AResolveCheck: TJclPeResolveCheck); +var + DotPos: Integer; +begin + inherited Create; + FExportList := AExportList; + FName := AName; + FForwardedName := AForwardedName; + FAddress := AAddress; + FHint := AHint; + FOrdinal := AOrdinal; + FResolveCheck := AResolveCheck; + + DotPos := AnsiPos('.', ForwardedName); + if DotPos > 0 then + FForwardedDotPos := Copy(ForwardedName, DotPos + 1, Length(ForwardedName) - DotPos) + else + FForwardedDotPos := ''; +end; + +function TJclPeExportFuncItem.GetAddressOrForwardStr: string; +begin + if IsForwarded then + Result := ForwardedName + else + FmtStr(Result, '%.8x', [Address]); +end; + +function TJclPeExportFuncItem.GetForwardedFuncName: string; +begin + if (Length(FForwardedDotPos) > 0) and (FForwardedDotPos[1] <> '#') then + Result := FForwardedDotPos + else + Result := ''; +end; + +function TJclPeExportFuncItem.GetForwardedFuncOrdinal: DWORD; +begin + if (Length(FForwardedDotPos) > 0) and (FForwardedDotPos[1] = '#') then + Result := StrToIntDef(FForwardedDotPos, 0) + else + Result := 0; +end; + +function TJclPeExportFuncItem.GetForwardedLibName: string; +begin + if Length(FForwardedDotPos) = 0 then + Result := '' + else + Result := AnsiLowerCase(Copy(FForwardedName, 1, Length(FForwardedName) - Length(FForwardedDotPos) - 1)) + BinaryExtensionLibrary; +end; + +function TJclPeExportFuncItem.GetIsExportedVariable: Boolean; +begin + case FExportList.Image.Target of + taWin32: + begin + {$IFDEF DELPHI64_TEMPORARY} + System.Error(rePlatformNotImplemented);//there is no BaseOfData in the 32-bit header for Win64 + Result := False; + {$ELSE ~DELPHI64_TEMPORARY} + Result := (Address >= FExportList.Image.OptionalHeader32.BaseOfData); + {$ENDIF ~DELPHI64_TEMPORARY} + end; + taWin64: + Result := False; + // TODO equivalent for 64-bit modules + //Result := (Address >= FExportList.Image.OptionalHeader64.BaseOfData); + else + Result := False; + end; +end; + +function TJclPeExportFuncItem.GetIsForwarded: Boolean; +begin + Result := Length(FForwardedName) <> 0; +end; + +function TJclPeExportFuncItem.GetMappedAddress: Pointer; +begin + Result := FExportList.Image.RvaToVa(FAddress); +end; + +function TJclPeExportFuncItem.GetSectionName: string; +begin + if IsForwarded then + Result := '' + else + with FExportList.Image do + Result := ImageSectionNameFromRva[Address]; +end; + +procedure TJclPeExportFuncItem.SetResolveCheck(Value: TJclPeResolveCheck); +begin + FResolveCheck := Value; +end; + +// Export sort functions +function ExportSortByName(Item1, Item2: Pointer): Integer; +begin + Result := CompareStr(TJclPeExportFuncItem(Item1).Name, TJclPeExportFuncItem(Item2).Name); +end; + +function ExportSortByNameDESC(Item1, Item2: Pointer): Integer; +begin + Result := ExportSortByName(Item2, Item1); +end; + +function ExportSortByOrdinal(Item1, Item2: Pointer): Integer; +begin + Result := TJclPeExportFuncItem(Item1).Ordinal - TJclPeExportFuncItem(Item2).Ordinal; +end; + +function ExportSortByOrdinalDESC(Item1, Item2: Pointer): Integer; +begin + Result := ExportSortByOrdinal(Item2, Item1); +end; + +function ExportSortByHint(Item1, Item2: Pointer): Integer; +begin + Result := TJclPeExportFuncItem(Item1).Hint - TJclPeExportFuncItem(Item2).Hint; +end; + +function ExportSortByHintDESC(Item1, Item2: Pointer): Integer; +begin + Result := ExportSortByHint(Item2, Item1); +end; + +function ExportSortByAddress(Item1, Item2: Pointer): Integer; +begin + Result := INT_PTR(TJclPeExportFuncItem(Item1).Address) - INT_PTR(TJclPeExportFuncItem(Item2).Address); + if Result = 0 then + Result := ExportSortByName(Item1, Item2); +end; + +function ExportSortByAddressDESC(Item1, Item2: Pointer): Integer; +begin + Result := ExportSortByAddress(Item2, Item1); +end; + +function ExportSortByForwarded(Item1, Item2: Pointer): Integer; +begin + Result := CompareStr(TJclPeExportFuncItem(Item1).ForwardedName, TJclPeExportFuncItem(Item2).ForwardedName); + if Result = 0 then + Result := ExportSortByName(Item1, Item2); +end; + +function ExportSortByForwardedDESC(Item1, Item2: Pointer): Integer; +begin + Result := ExportSortByForwarded(Item2, Item1); +end; + +function ExportSortByAddrOrFwd(Item1, Item2: Pointer): Integer; +begin + Result := CompareStr(TJclPeExportFuncItem(Item1).AddressOrForwardStr, TJclPeExportFuncItem(Item2).AddressOrForwardStr); +end; + +function ExportSortByAddrOrFwdDESC(Item1, Item2: Pointer): Integer; +begin + Result := ExportSortByAddrOrFwd(Item2, Item1); +end; + +function ExportSortBySection(Item1, Item2: Pointer): Integer; +begin + Result := CompareStr(TJclPeExportFuncItem(Item1).SectionName, TJclPeExportFuncItem(Item2).SectionName); + if Result = 0 then + Result := ExportSortByName(Item1, Item2); +end; + +function ExportSortBySectionDESC(Item1, Item2: Pointer): Integer; +begin + Result := ExportSortBySection(Item2, Item1); +end; + +//=== { TJclPeExportFuncList } =============================================== + +constructor TJclPeExportFuncList.Create(AImage: TJclPeImage); +begin + inherited Create(AImage); + FTotalResolveCheck := icNotChecked; + CreateList; +end; + +destructor TJclPeExportFuncList.Destroy; +begin + FreeAndNil(FForwardedLibsList); + inherited Destroy; +end; + +function TJclPeExportFuncList.CanPerformFastNameSearch: Boolean; +begin + Result := FSorted and (FLastSortType = esName) and not FLastSortDescending; +end; + +procedure TJclPeExportFuncList.CheckForwards(PeImageCache: TJclPeImagesCache); +var + I: Integer; + FullFileName: TFileName; + ForwardPeImage: TJclPeImage; + ModuleResolveCheck: TJclPeResolveCheck; + + procedure PerformCheck(const ModuleName: string); + var + I: Integer; + Item: TJclPeExportFuncItem; + EL: TJclPeExportFuncList; + begin + EL := ForwardPeImage.ExportList; + EL.PrepareForFastNameSearch; + ModuleResolveCheck := icResolved; + for I := 0 to Count - 1 do + begin + Item := Items[I]; + if (not Item.IsForwarded) or (Item.ResolveCheck <> icNotChecked) or + (Item.ForwardedLibName <> ModuleName) then + Continue; + if EL.ItemFromName[Item.ForwardedFuncName] = nil then + begin + Item.SetResolveCheck(icUnresolved); + ModuleResolveCheck := icUnresolved; + end + else + Item.SetResolveCheck(icResolved); + end; + end; + +begin + if not AnyForwards then + Exit; + FTotalResolveCheck := icResolved; + if PeImageCache <> nil then + ForwardPeImage := nil // to make the compiler happy + else + ForwardPeImage := TJclPeImage.Create(True); + try + for I := 0 to ForwardedLibsList.Count - 1 do + begin + FullFileName := Image.ExpandModuleName(ForwardedLibsList[I]); + if PeImageCache <> nil then + ForwardPeImage := PeImageCache[FullFileName] + else + ForwardPeImage.FileName := FullFileName; + if ForwardPeImage.StatusOK then + PerformCheck(ForwardedLibsList[I]) + else + ModuleResolveCheck := icUnresolved; + FForwardedLibsList.Objects[I] := Pointer(ModuleResolveCheck); + if ModuleResolveCheck = icUnresolved then + FTotalResolveCheck := icUnresolved; + end; + finally + if PeImageCache = nil then + ForwardPeImage.Free; + end; +end; + +procedure TJclPeExportFuncList.CreateList; +var + Functions: Pointer; + Address, NameCount: DWORD; + NameOrdinals: PWORD; + Names: PDWORD; + I: Integer; + ExportItem: TJclPeExportFuncItem; + ExportVABegin, ExportVAEnd: DWORD; + UTF8Name: TUTF8String; + ForwardedName, ExportName: string; +begin + with Image do + begin + if not StatusOK then + Exit; + with Directories[IMAGE_DIRECTORY_ENTRY_EXPORT] do + begin + ExportVABegin := VirtualAddress; + ExportVAEnd := VirtualAddress + TJclAddr(Size); + end; + FExportDir := DirectoryEntryToData(IMAGE_DIRECTORY_ENTRY_EXPORT); + if FExportDir <> nil then + begin + FBase := FExportDir^.Base; + FFunctionCount := FExportDir^.NumberOfFunctions; + Functions := RvaToVa(FExportDir^.AddressOfFunctions); + NameOrdinals := RvaToVa(FExportDir^.AddressOfNameOrdinals); + Names := RvaToVa(FExportDir^.AddressOfNames); + NameCount := FExportDir^.NumberOfNames; + Count := FExportDir^.NumberOfFunctions; + + for I := 0 to Count - 1 do + begin + Address := PDWORD(TJclAddr(Functions) + TJclAddr(I) * SizeOf(DWORD))^; + if (Address >= ExportVABegin) and (Address <= ExportVAEnd) then + begin + FAnyForwards := True; + UTF8Name := PAnsiChar(RvaToVa(Address)); + if not TryUTF8ToString(UTF8Name, ForwardedName) then + ForwardedName := string(UTF8Name); + end + else + ForwardedName := ''; + + ExportItem := TJclPeExportFuncItem.Create(Self, '', + ForwardedName, Address, $FFFF, TJclAddr(I) + FBase, icNotChecked); + + List{$IFNDEF RTL230_UP}^{$ENDIF !RTL230_UP}[I] := ExportItem; + end; + + for I := 0 to NameCount - 1 do + begin + // named function + UTF8Name := PAnsiChar(RvaToVa(Names^)); + if not TryUTF8ToString(UTF8Name, ExportName) then + ExportName := string(UTF8Name); + + ExportItem := TJclPeExportFuncItem(List{$IFNDEF RTL230_UP}^{$ENDIF !RTL230_UP}[NameOrdinals^]); + ExportItem.FName := ExportName; + ExportItem.FHint := I; + + Inc(NameOrdinals); + Inc(Names); + end; + end; + end; +end; + +function TJclPeExportFuncList.GetForwardedLibsList: TStrings; +var + I: Integer; +begin + if FForwardedLibsList = nil then + begin + FForwardedLibsList := TStringList.Create; + FForwardedLibsList.Sorted := True; + FForwardedLibsList.Duplicates := dupIgnore; + if FAnyForwards then + for I := 0 to Count - 1 do + with Items[I] do + if IsForwarded then + FForwardedLibsList.AddObject(ForwardedLibName, Pointer(icNotChecked)); + end; + Result := FForwardedLibsList; +end; + +function TJclPeExportFuncList.GetItemFromAddress(Address: DWORD): TJclPeExportFuncItem; +var + I: Integer; +begin + Result := nil; + for I := 0 to Count - 1 do + if Items[I].Address = Address then + begin + Result := Items[I]; + Break; + end; +end; + +function TJclPeExportFuncList.GetItemFromName(const Name: string): TJclPeExportFuncItem; +var + L, H, I, C: Integer; + B: Boolean; +begin + Result := nil; + if CanPerformFastNameSearch then + begin + L := 0; + H := Count - 1; + B := False; + while L <= H do + begin + I := (L + H) shr 1; + C := CompareStr(Items[I].Name, Name); + if C < 0 then + L := I + 1 + else + begin + H := I - 1; + if C = 0 then + begin + B := True; + L := I; + end; + end; + end; + if B then + Result := Items[L]; + end + else + for I := 0 to Count - 1 do + if Items[I].Name = Name then + begin + Result := Items[I]; + Break; + end; +end; + +function TJclPeExportFuncList.GetItemFromOrdinal(Ordinal: DWORD): TJclPeExportFuncItem; +var + I: Integer; +begin + Result := nil; + for I := 0 to Count - 1 do + if Items[I].Ordinal = Ordinal then + begin + Result := Items[I]; + Break; + end; +end; + +function TJclPeExportFuncList.GetItems(Index: Integer): TJclPeExportFuncItem; +begin + Result := TJclPeExportFuncItem(Get(Index)); +end; + +function TJclPeExportFuncList.GetName: string; +var + UTF8ExportName: TUTF8String; +begin + if (FExportDir = nil) or (FExportDir^.Name = 0) then + Result := '' + else + begin + UTF8ExportName := PAnsiChar(Image.RvaToVa(FExportDir^.Name)); + if not TryUTF8ToString(UTF8ExportName, Result) then + Result := string(UTF8ExportName); + end; +end; + +class function TJclPeExportFuncList.ItemName(Item: TJclPeExportFuncItem): string; +begin + if Item = nil then + Result := '' + else + Result := Item.Name; +end; + +function TJclPeExportFuncList.OrdinalValid(Ordinal: DWORD): Boolean; +begin + Result := (FExportDir <> nil) and (Ordinal >= Base) and + (Ordinal < FunctionCount + Base); +end; + +procedure TJclPeExportFuncList.PrepareForFastNameSearch; +begin + if not CanPerformFastNameSearch then + SortList(esName, False); +end; + +function TJclPeExportFuncList.SmartFindName(const CompareName: string; + Options: TJclSmartCompOptions): TJclPeExportFuncItem; +var + I: Integer; +begin + Result := nil; + for I := 0 to Count - 1 do + begin + if PeSmartFunctionNameSame(CompareName, Items[I].Name, Options) then + begin + Result := Items[I]; + Break; + end; + end; +end; + +procedure TJclPeExportFuncList.SortList(SortType: TJclPeExportSort; Descending: Boolean); +const + SortFunctions: array [TJclPeExportSort, Boolean] of TListSortCompare = + ((ExportSortByName, ExportSortByNameDESC), + (ExportSortByOrdinal, ExportSortByOrdinalDESC), + (ExportSortByHint, ExportSortByHintDESC), + (ExportSortByAddress, ExportSortByAddressDESC), + (ExportSortByForwarded, ExportSortByForwardedDESC), + (ExportSortByAddrOrFwd, ExportSortByAddrOrFwdDESC), + (ExportSortBySection, ExportSortBySectionDESC) + ); +begin + if not FSorted or (SortType <> FLastSortType) or (Descending <> FLastSortDescending) then + begin + Sort(SortFunctions[SortType, Descending]); + FLastSortType := SortType; + FLastSortDescending := Descending; + FSorted := True; + end; +end; + +//=== { TJclPeResourceRawStream } ============================================ + +constructor TJclPeResourceRawStream.Create(AResourceItem: TJclPeResourceItem); +begin + Assert(not AResourceItem.IsDirectory); + inherited Create; + SetPointer(AResourceItem.RawEntryData, AResourceItem.RawEntryDataSize); +end; + +function TJclPeResourceRawStream.Write(const Buffer; Count: Integer): Longint; +begin + raise EJclPeImageError.CreateRes(@RsPeReadOnlyStream); +end; + +//=== { TJclPeResourceItem } ================================================= + +constructor TJclPeResourceItem.Create(AImage: TJclPeImage; + AParentItem: TJclPeResourceItem; AEntry: PImageResourceDirectoryEntry); +begin + inherited Create; + FImage := AImage; + FEntry := AEntry; + FParentItem := AParentItem; + if AParentItem = nil then + FLevel := 1 + else + FLevel := AParentItem.Level + 1; +end; + +destructor TJclPeResourceItem.Destroy; +begin + FreeAndNil(FList); + inherited Destroy; +end; + +function TJclPeResourceItem.CompareName(AName: PChar): Boolean; +var + P: PChar; +begin + if IsName then + P := PChar(Name) + else + P := PChar(FEntry^.Name and $FFFF); // Integer encoded in a PChar + Result := CompareResourceName(AName, P); +end; + +function TJclPeResourceItem.GetDataEntry: PImageResourceDataEntry; +begin + if GetIsDirectory then + Result := nil + else + Result := PImageResourceDataEntry(OffsetToRawData(FEntry^.OffsetToData)); +end; + +function TJclPeResourceItem.GetIsDirectory: Boolean; +begin + Result := FEntry^.OffsetToData and IMAGE_RESOURCE_DATA_IS_DIRECTORY <> 0; +end; + +function TJclPeResourceItem.GetIsName: Boolean; +begin + Result := FEntry^.Name and IMAGE_RESOURCE_NAME_IS_STRING <> 0; +end; + +function TJclPeResourceItem.GetLangID: LANGID; +begin + if IsDirectory then + begin + GetList; + if FList.Count = 1 then + Result := StrToIntDef(FList[0].Name, 0) + else + Result := 0; + end + else + Result := StrToIntDef(Name, 0); +end; + +function TJclPeResourceItem.GetList: TJclPeResourceList; +begin + if not IsDirectory then + begin + if Image.NoExceptions then + begin + Result := nil; + Exit; + end + else + raise EJclPeImageError.CreateRes(@RsPeNotResDir); + end; + if FList = nil then + FList := FImage.ResourceListCreate(SubDirData, Self); + Result := FList; +end; + +function TJclPeResourceItem.GetName: string; +begin + if IsName then + begin + if FNameCache = '' then + begin + with PImageResourceDirStringU(OffsetToRawData(FEntry^.Name))^ do + FNameCache := WideCharLenToString(NameString, Length); + StrResetLength(FNameCache); + end; + Result := FNameCache; + end + else + Result := IntToStr(FEntry^.Name and $FFFF); +end; + +function TJclPeResourceItem.GetParameterName: string; +begin + if IsName then + Result := Name + else + Result := Format('#%d', [FEntry^.Name and $FFFF]); +end; + +function TJclPeResourceItem.GetRawEntryData: Pointer; +begin + if GetIsDirectory then + Result := nil + else + Result := FImage.RvaToVa(GetDataEntry^.OffsetToData); +end; + +function TJclPeResourceItem.GetRawEntryDataSize: Integer; +begin + if GetIsDirectory then + Result := -1 + else + Result := PImageResourceDataEntry(OffsetToRawData(FEntry^.OffsetToData))^.Size; +end; + +function TJclPeResourceItem.GetResourceType: TJclPeResourceKind; +begin + with Level1Item do + begin + if FEntry^.Name < Cardinal(High(TJclPeResourceKind)) then + Result := TJclPeResourceKind(FEntry^.Name) + else + Result := rtUserDefined + end; +end; + +function TJclPeResourceItem.GetResourceTypeStr: string; +begin + with Level1Item do + begin + if FEntry^.Name < Cardinal(High(TJclPeResourceKind)) then + Result := Copy(GetEnumName(TypeInfo(TJclPeResourceKind), Ord(FEntry^.Name)), 3, 30) + else + Result := Name; + end; +end; + +function TJclPeResourceItem.Level1Item: TJclPeResourceItem; +begin + Result := Self; + while Result.FParentItem <> nil do + Result := Result.FParentItem; +end; + +function TJclPeResourceItem.OffsetToRawData(Ofs: DWORD): TJclAddr; +begin + Result := (Ofs and $7FFFFFFF) + Image.ResourceVA; +end; + +function TJclPeResourceItem.SubDirData: PImageResourceDirectory; +begin + Result := Pointer(OffsetToRawData(FEntry^.OffsetToData)); +end; + +//=== { TJclPeResourceList } ================================================= + +constructor TJclPeResourceList.Create(AImage: TJclPeImage; + AParentItem: TJclPeResourceItem; ADirectory: PImageResourceDirectory); +begin + inherited Create(AImage); + FDirectory := ADirectory; + FParentItem := AParentItem; + CreateList(AParentItem); +end; + +procedure TJclPeResourceList.CreateList(AParentItem: TJclPeResourceItem); +var + Entry: PImageResourceDirectoryEntry; + DirItem: TJclPeResourceItem; + I: Integer; +begin + if FDirectory = nil then + Exit; + Entry := Pointer(TJclAddr(FDirectory) + SizeOf(TImageResourceDirectory)); + for I := 1 to DWORD(FDirectory^.NumberOfNamedEntries) + DWORD(FDirectory^.NumberOfIdEntries) do + begin + DirItem := Image.ResourceItemCreate(Entry, AParentItem); + Add(DirItem); + Inc(Entry); + end; +end; + +function TJclPeResourceList.FindName(const Name: string): TJclPeResourceItem; +var + I: Integer; +begin + Result := nil; + for I := 0 to Count - 1 do + if StrSame(Items[I].Name, Name) then + begin + Result := Items[I]; + Break; + end; +end; + +function TJclPeResourceList.GetItems(Index: Integer): TJclPeResourceItem; +begin + Result := TJclPeResourceItem(Get(Index)); +end; + +//=== { TJclPeRootResourceList } ============================================= + +destructor TJclPeRootResourceList.Destroy; +begin + FreeAndNil(FManifestContent); + inherited Destroy; +end; + +function TJclPeRootResourceList.FindResource(ResourceType: TJclPeResourceKind; + const ResourceName: string): TJclPeResourceItem; +var + I: Integer; + TypeItem: TJclPeResourceItem; +begin + Result := nil; + TypeItem := nil; + for I := 0 to Count - 1 do + begin + if Items[I].ResourceType = ResourceType then + begin + TypeItem := Items[I]; + Break; + end; + end; + if TypeItem <> nil then + if ResourceName = '' then + Result := TypeItem + else + with TypeItem.List do + for I := 0 to Count - 1 do + if Items[I].Name = ResourceName then + begin + Result := Items[I]; + Break; + end; +end; + +function TJclPeRootResourceList.FindResource(const ResourceType: PChar; + const ResourceName: PChar): TJclPeResourceItem; +var + I: Integer; + TypeItem: TJclPeResourceItem; +begin + Result := nil; + TypeItem := nil; + for I := 0 to Count - 1 do + if Items[I].CompareName(ResourceType) then + begin + TypeItem := Items[I]; + Break; + end; + if TypeItem <> nil then + if ResourceName = nil then + Result := TypeItem + else + with TypeItem.List do + for I := 0 to Count - 1 do + if Items[I].CompareName(ResourceName) then + begin + Result := Items[I]; + Break; + end; +end; + +function TJclPeRootResourceList.GetManifestContent: TStrings; +var + ManifestFileName: string; + ResItem: TJclPeResourceItem; + ResStream: TJclPeResourceRawStream; +begin + if FManifestContent = nil then + begin + FManifestContent := TStringList.Create; + ResItem := FindResource(RT_MANIFEST, CREATEPROCESS_MANIFEST_RESOURCE_ID); + if ResItem = nil then + begin + ManifestFileName := Image.FileName + MANIFESTExtension; + if FileExists(ManifestFileName) then + FManifestContent.LoadFromFile(ManifestFileName); + end + else + begin + ResStream := TJclPeResourceRawStream.Create(ResItem.List[0]); + try + FManifestContent.LoadFromStream(ResStream); + finally + ResStream.Free; + end; + end; + end; + Result := FManifestContent; +end; + +function TJclPeRootResourceList.ListResourceNames(ResourceType: TJclPeResourceKind; + const Strings: TStrings): Boolean; +var + ResTypeItem, TempItem: TJclPeResourceItem; + I: Integer; +begin + ResTypeItem := FindResource(ResourceType, ''); + Result := (ResTypeItem <> nil); + if Result then + begin + Strings.BeginUpdate; + try + with ResTypeItem.List do + for I := 0 to Count - 1 do + begin + TempItem := Items[I]; + Strings.AddObject(TempItem.Name, Pointer(TempItem.IsName)); + end; + finally + Strings.EndUpdate; + end; + end; +end; + +//=== { TJclPeRelocEntry } =================================================== + +constructor TJclPeRelocEntry.Create(AChunk: PImageBaseRelocation; ACount: Integer); +begin + inherited Create; + FChunk := AChunk; + FCount := ACount; +end; + +function TJclPeRelocEntry.GetRelocations(Index: Integer): TJclPeRelocation; +var + Temp: Word; +begin + Temp := PWord(TJclAddr(FChunk) + SizeOf(TImageBaseRelocation) + DWORD(Index) * SizeOf(Word))^; + Result.Address := Temp and $0FFF; + Result.RelocType := (Temp and $F000) shr 12; + Result.VirtualAddress := TJclAddr(Result.Address) + VirtualAddress; +end; + +function TJclPeRelocEntry.GetSize: DWORD; +begin + Result := FChunk^.SizeOfBlock; +end; + +function TJclPeRelocEntry.GetVirtualAddress: DWORD; +begin + Result := FChunk^.VirtualAddress; +end; + +//=== { TJclPeRelocList } ==================================================== + +constructor TJclPeRelocList.Create(AImage: TJclPeImage); +begin + inherited Create(AImage); + CreateList; +end; + +procedure TJclPeRelocList.CreateList; +var + Chunk: PImageBaseRelocation; + Item: TJclPeRelocEntry; + RelocCount: Integer; +begin + with Image do + begin + if not StatusOK then + Exit; + Chunk := DirectoryEntryToData(IMAGE_DIRECTORY_ENTRY_BASERELOC); + if Chunk = nil then + Exit; + FAllItemCount := 0; + while Chunk^.SizeOfBlock <> 0 do + begin + RelocCount := (Chunk^.SizeOfBlock - SizeOf(TImageBaseRelocation)) div SizeOf(Word); + Item := TJclPeRelocEntry.Create(Chunk, RelocCount); + Inc(FAllItemCount, RelocCount); + Add(Item); + Chunk := Pointer(TJclAddr(Chunk) + Chunk^.SizeOfBlock); + end; + end; +end; + +function TJclPeRelocList.GetAllItems(Index: Integer): TJclPeRelocation; +var + I, N, C: Integer; +begin + N := Index; + for I := 0 to Count - 1 do + begin + C := Items[I].Count; + Dec(N, C); + if N < 0 then + begin + Result := Items[I][N + C]; + Break; + end; + end; +end; + +function TJclPeRelocList.GetItems(Index: Integer): TJclPeRelocEntry; +begin + Result := TJclPeRelocEntry(Get(Index)); +end; + +//=== { TJclPeDebugList } ==================================================== + +constructor TJclPeDebugList.Create(AImage: TJclPeImage); +begin + inherited Create(AImage); + OwnsObjects := False; + CreateList; +end; + +procedure TJclPeDebugList.CreateList; +var + DebugImageDir: TImageDataDirectory; + DebugDir: PImageDebugDirectory; + Header: PImageSectionHeader; + FormatCount, I: Integer; +begin + with Image do + begin + if not StatusOK then + Exit; + DebugImageDir := Directories[IMAGE_DIRECTORY_ENTRY_DEBUG]; + if DebugImageDir.VirtualAddress = 0 then + Exit; + if GetSectionHeader(DebugSectionName, Header) and + (Header^.VirtualAddress = DebugImageDir.VirtualAddress) then + begin + FormatCount := DebugImageDir.Size; + DebugDir := RvaToVa(Header^.VirtualAddress); + end + else + begin + if not GetSectionHeader(ReadOnlySectionName, Header) then + Exit; + FormatCount := DebugImageDir.Size div SizeOf(TImageDebugDirectory); + DebugDir := Pointer(MappedAddress + DebugImageDir.VirtualAddress - + Header^.VirtualAddress + Header^.PointerToRawData); + end; + for I := 1 to FormatCount do + begin + Add(TObject(DebugDir)); + Inc(DebugDir); + end; + end; +end; + +function TJclPeDebugList.GetItems(Index: Integer): TImageDebugDirectory; +begin + Result := PImageDebugDirectory(Get(Index))^; +end; + +//=== { TJclPeCertificate } ================================================== + +constructor TJclPeCertificate.Create(AHeader: TWinCertificate; AData: Pointer); +begin + inherited Create; + FHeader := AHeader; + FData := AData; +end; + +//=== { TJclPeCertificateList } ============================================== + +constructor TJclPeCertificateList.Create(AImage: TJclPeImage); +begin + inherited Create(AImage); + CreateList; +end; + +procedure TJclPeCertificateList.CreateList; +var + Directory: TImageDataDirectory; + CertPtr: PChar; + TotalSize: Integer; + Item: TJclPeCertificate; +begin + Directory := Image.Directories[IMAGE_DIRECTORY_ENTRY_SECURITY]; + if Directory.VirtualAddress = 0 then + Exit; + CertPtr := Image.RawToVa(Directory.VirtualAddress); // Security directory is a raw offset + TotalSize := Directory.Size; + while TotalSize >= SizeOf(TWinCertificate) do + begin + Item := TJclPeCertificate.Create(PWinCertificate(CertPtr)^, CertPtr + SizeOf(TWinCertificate)); + Dec(TotalSize, Item.Header.dwLength); + Add(Item); + end; +end; + +function TJclPeCertificateList.GetItems(Index: Integer): TJclPeCertificate; +begin + Result := TJclPeCertificate(Get(Index)); +end; + +//=== { TJclPeCLRHeader } ==================================================== + +constructor TJclPeCLRHeader.Create(AImage: TJclPeImage); +begin + FImage := AImage; + ReadHeader; +end; + +function TJclPeCLRHeader.GetHasMetadata: Boolean; +const + METADATA_SIGNATURE = $424A5342; // Reference: Partition II Metadata.doc - 23.2.1 Metadata root +begin + with Header.MetaData do + Result := (VirtualAddress <> 0) and (PDWORD(FImage.RvaToVa(VirtualAddress))^ = METADATA_SIGNATURE); +end; +{ TODO -cDOC : "Flier Lu" } + +function TJclPeCLRHeader.GetVersionString: string; +begin + Result := FormatVersionString(Header.MajorRuntimeVersion, Header.MinorRuntimeVersion); +end; + +procedure TJclPeCLRHeader.ReadHeader; +var + HeaderPtr: PImageCor20Header; +begin + HeaderPtr := Image.DirectoryEntryToData(IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR); + if (HeaderPtr <> nil) and (HeaderPtr^.cb >= SizeOf(TImageCor20Header)) then + FHeader := HeaderPtr^; +end; + +//=== { TJclPeImage } ======================================================== + +constructor TJclPeImage.Create(ANoExceptions: Boolean); +begin + FNoExceptions := ANoExceptions; + FReadOnlyAccess := True; + FImageSections := TStringList.Create; + FStringTable := TStringList.Create; +end; + +destructor TJclPeImage.Destroy; +begin + Clear; + FreeAndNil(FImageSections); + FStringTable.Free; + + inherited Destroy; +end; + +procedure TJclPeImage.AfterOpen; +begin +end; + +procedure TJclPeImage.AttachLoadedModule(const Handle: HMODULE); + procedure AttachLoadedModule32; + var + NtHeaders: PImageNtHeaders32; + begin + NtHeaders := PeMapImgNtHeaders32(Pointer(Handle)); + if NtHeaders = nil then + FStatus := stNotPE + else + begin + FStatus := stOk; + FAttachedImage := True; + FFileName := GetModulePath(Handle); + // OF: possible loss of data + FLoadedImage.ModuleName := PAnsiChar(AnsiString(FFileName)); + FLoadedImage.hFile := INVALID_HANDLE_VALUE; + FLoadedImage.MappedAddress := Pointer(Handle); + FLoadedImage.FileHeader := PImageNtHeaders(NtHeaders); + FLoadedImage.NumberOfSections := NtHeaders^.FileHeader.NumberOfSections; + FLoadedImage.Sections := PeMapImgSections32(NtHeaders); + FLoadedImage.LastRvaSection := FLoadedImage.Sections; + FLoadedImage.Characteristics := NtHeaders^.FileHeader.Characteristics; + FLoadedImage.fSystemImage := (FLoadedImage.Characteristics and IMAGE_FILE_SYSTEM <> 0); + FLoadedImage.fDOSImage := False; + FLoadedImage.SizeOfImage := NtHeaders^.OptionalHeader.SizeOfImage; + ReadImageSections; + ReadStringTable; + AfterOpen; + end; + RaiseStatusException; + end; + + procedure AttachLoadedModule64; + var + NtHeaders: PImageNtHeaders64; + begin + NtHeaders := PeMapImgNtHeaders64(Pointer(Handle)); + if NtHeaders = nil then + FStatus := stNotPE + else + begin + FStatus := stOk; + FAttachedImage := True; + FFileName := GetModulePath(Handle); + // OF: possible loss of data + FLoadedImage.ModuleName := PAnsiChar(AnsiString(FFileName)); + FLoadedImage.hFile := INVALID_HANDLE_VALUE; + FLoadedImage.MappedAddress := Pointer(Handle); + FLoadedImage.FileHeader := PImageNtHeaders(NtHeaders); + FLoadedImage.NumberOfSections := NtHeaders^.FileHeader.NumberOfSections; + FLoadedImage.Sections := PeMapImgSections64(NtHeaders); + FLoadedImage.LastRvaSection := FLoadedImage.Sections; + FLoadedImage.Characteristics := NtHeaders^.FileHeader.Characteristics; + FLoadedImage.fSystemImage := (FLoadedImage.Characteristics and IMAGE_FILE_SYSTEM <> 0); + FLoadedImage.fDOSImage := False; + FLoadedImage.SizeOfImage := NtHeaders^.OptionalHeader.SizeOfImage; + ReadImageSections; + ReadStringTable; + AfterOpen; + end; + RaiseStatusException; + end; +begin + Clear; + if Handle = 0 then + Exit; + FTarget := PeMapImgTarget(Pointer(Handle)); + case Target of + taWin32: + AttachLoadedModule32; + taWin64: + AttachLoadedModule64; + taUnknown: + FStatus := stNotSupported; + end; +end; + +function TJclPeImage.CalculateCheckSum: DWORD; +var + C: DWORD; +begin + if StatusOK then + begin + CheckNotAttached; + if CheckSumMappedFile(FLoadedImage.MappedAddress, FLoadedImage.SizeOfImage, + C, Result) = nil then + RaiseLastOSError; + end + else + Result := 0; +end; + +procedure TJclPeImage.CheckNotAttached; +begin + if FAttachedImage then + raise EJclPeImageError.CreateRes(@RsPeNotAvailableForAttached); +end; + +procedure TJclPeImage.Clear; +begin + FImageSections.Clear; + FStringTable.Clear; + FreeAndNil(FCertificateList); + FreeAndNil(FCLRHeader); + FreeAndNil(FDebugList); + FreeAndNil(FImportList); + FreeAndNil(FExportList); + FreeAndNil(FRelocationList); + FreeAndNil(FResourceList); + FreeAndNil(FVersionInfo); + if not FAttachedImage and StatusOK then + UnMapAndLoad(FLoadedImage); + ResetMemory(FLoadedImage, SizeOf(FLoadedImage)); + FStatus := stNotLoaded; + FAttachedImage := False; +end; + +class function TJclPeImage.DateTimeToStamp(const DateTime: TDateTime): DWORD; +begin + Result := Round((DateTime - UnixTimeStart) * SecsPerDay); +end; + +class function TJclPeImage.DebugTypeNames(DebugType: DWORD): string; +begin + case DebugType of + IMAGE_DEBUG_TYPE_UNKNOWN: + Result := LoadResString(@RsPeDEBUG_UNKNOWN); + IMAGE_DEBUG_TYPE_COFF: + Result := LoadResString(@RsPeDEBUG_COFF); + IMAGE_DEBUG_TYPE_CODEVIEW: + Result := LoadResString(@RsPeDEBUG_CODEVIEW); + IMAGE_DEBUG_TYPE_FPO: + Result := LoadResString(@RsPeDEBUG_FPO); + IMAGE_DEBUG_TYPE_MISC: + Result := LoadResString(@RsPeDEBUG_MISC); + IMAGE_DEBUG_TYPE_EXCEPTION: + Result := LoadResString(@RsPeDEBUG_EXCEPTION); + IMAGE_DEBUG_TYPE_FIXUP: + Result := LoadResString(@RsPeDEBUG_FIXUP); + IMAGE_DEBUG_TYPE_OMAP_TO_SRC: + Result := LoadResString(@RsPeDEBUG_OMAP_TO_SRC); + IMAGE_DEBUG_TYPE_OMAP_FROM_SRC: + Result := LoadResString(@RsPeDEBUG_OMAP_FROM_SRC); + else + Result := LoadResString(@RsPeDEBUG_UNKNOWN); + end; +end; + +function TJclPeImage.DirectoryEntryToData(Directory: Word): Pointer; +var + Size: DWORD; +begin + Size := 0; + Result := ImageDirectoryEntryToData(FLoadedImage.MappedAddress, FAttachedImage, Directory, Size); +end; + +class function TJclPeImage.DirectoryNames(Directory: Word): string; +begin + case Directory of + IMAGE_DIRECTORY_ENTRY_EXPORT: + Result := LoadResString(@RsPeImg_00); + IMAGE_DIRECTORY_ENTRY_IMPORT: + Result := LoadResString(@RsPeImg_01); + IMAGE_DIRECTORY_ENTRY_RESOURCE: + Result := LoadResString(@RsPeImg_02); + IMAGE_DIRECTORY_ENTRY_EXCEPTION: + Result := LoadResString(@RsPeImg_03); + IMAGE_DIRECTORY_ENTRY_SECURITY: + Result := LoadResString(@RsPeImg_04); + IMAGE_DIRECTORY_ENTRY_BASERELOC: + Result := LoadResString(@RsPeImg_05); + IMAGE_DIRECTORY_ENTRY_DEBUG: + Result := LoadResString(@RsPeImg_06); + IMAGE_DIRECTORY_ENTRY_COPYRIGHT: + Result := LoadResString(@RsPeImg_07); + IMAGE_DIRECTORY_ENTRY_GLOBALPTR: + Result := LoadResString(@RsPeImg_08); + IMAGE_DIRECTORY_ENTRY_TLS: + Result := LoadResString(@RsPeImg_09); + IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG: + Result := LoadResString(@RsPeImg_10); + IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT: + Result := LoadResString(@RsPeImg_11); + IMAGE_DIRECTORY_ENTRY_IAT: + Result := LoadResString(@RsPeImg_12); + IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT: + Result := LoadResString(@RsPeImg_13); + IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR: + Result := LoadResString(@RsPeImg_14); + else + Result := Format(LoadResString(@RsPeImg_Reserved), [Directory]); + end; +end; + +class function TJclPeImage.ExpandBySearchPath(const ModuleName, BasePath: string): TFileName; +var + FullName: array [0..MAX_PATH] of Char; + FilePart: PChar; +begin + Result := PathAddSeparator(ExtractFilePath(BasePath)) + ModuleName; + if FileExists(Result) then + Exit; + FilePart := nil; + if SearchPath(nil, PChar(ModuleName), nil, Length(FullName), FullName, FilePart) = 0 then + Result := ModuleName + else + Result := FullName; +end; + +function TJclPeImage.ExpandModuleName(const ModuleName: string): TFileName; +begin + Result := ExpandBySearchPath(ModuleName, ExtractFilePath(FFileName)); +end; + +function TJclPeImage.GetCertificateList: TJclPeCertificateList; +begin + if FCertificateList = nil then + FCertificateList := TJclPeCertificateList.Create(Self); + Result := FCertificateList; +end; + +function TJclPeImage.GetCLRHeader: TJclPeCLRHeader; +begin + if FCLRHeader = nil then + FCLRHeader := TJclPeCLRHeader.Create(Self); + Result := FCLRHeader; +end; + +function TJclPeImage.GetDebugList: TJclPeDebugList; +begin + if FDebugList = nil then + FDebugList := TJclPeDebugList.Create(Self); + Result := FDebugList; +end; + +function TJclPeImage.GetDescription: string; +var + UTF8DescriptionName: TUTF8String; +begin + if DirectoryExists[IMAGE_DIRECTORY_ENTRY_COPYRIGHT] then + begin + UTF8DescriptionName := PAnsiChar(DirectoryEntryToData(IMAGE_DIRECTORY_ENTRY_COPYRIGHT)); + if not TryUTF8ToString(UTF8DescriptionName, Result) then + Result := string(UTF8DescriptionName); + end + else + Result := ''; +end; + +function TJclPeImage.GetDirectories(Directory: Word): TImageDataDirectory; +begin + if StatusOK then + begin + case Target of + taWin32: + Result := PImageNtHeaders32(FLoadedImage.FileHeader)^.OptionalHeader.DataDirectory[Directory]; + taWin64: + Result := PImageNtHeaders64(FLoadedImage.FileHeader)^.OptionalHeader.DataDirectory[Directory]; + else + Result.VirtualAddress := 0; + Result.Size := 0; + end + end + else + begin + Result.VirtualAddress := 0; + Result.Size := 0; + end; +end; + +function TJclPeImage.GetDirectoryExists(Directory: Word): Boolean; +begin + Result := (Directories[Directory].VirtualAddress <> 0); +end; + +function TJclPeImage.GetExportList: TJclPeExportFuncList; +begin + if FExportList = nil then + FExportList := TJclPeExportFuncList.Create(Self); + Result := FExportList; +end; + +{$IFNDEF WINSCP} +function TJclPeImage.GetFileProperties: TJclPeFileProperties; +var + FileAttributesEx: WIN32_FILE_ATTRIBUTE_DATA; + Size: TJclULargeInteger; +begin + ResetMemory(Result, SizeOf(Result)); + if GetFileAttributesEx(PChar(FileName), GetFileExInfoStandard, @FileAttributesEx) then + begin + Size.LowPart := FileAttributesEx.nFileSizeLow; + Size.HighPart := FileAttributesEx.nFileSizeHigh; + Result.Size := Size.QuadPart; + Result.CreationTime := FileTimeToLocalDateTime(FileAttributesEx.ftCreationTime); + Result.LastAccessTime := FileTimeToLocalDateTime(FileAttributesEx.ftLastAccessTime); + Result.LastWriteTime := FileTimeToLocalDateTime(FileAttributesEx.ftLastWriteTime); + Result.Attributes := FileAttributesEx.dwFileAttributes; + end; +end; +{$ENDIF ~WINSCP} + +function TJclPeImage.GetHeaderValues(Index: TJclPeHeader): string; + + function GetMachineString(Value: DWORD): string; + begin + case Value of + IMAGE_FILE_MACHINE_UNKNOWN: + Result := LoadResString(@RsPeMACHINE_UNKNOWN); + IMAGE_FILE_MACHINE_I386: + Result := LoadResString(@RsPeMACHINE_I386); + IMAGE_FILE_MACHINE_R3000: + Result := LoadResString(@RsPeMACHINE_R3000); + IMAGE_FILE_MACHINE_R4000: + Result := LoadResString(@RsPeMACHINE_R4000); + IMAGE_FILE_MACHINE_R10000: + Result := LoadResString(@RsPeMACHINE_R10000); + IMAGE_FILE_MACHINE_WCEMIPSV2: + Result := LoadResString(@RsPeMACHINE_WCEMIPSV2); + IMAGE_FILE_MACHINE_ALPHA: + Result := LoadResString(@RsPeMACHINE_ALPHA); + IMAGE_FILE_MACHINE_SH3: + Result := LoadResString(@RsPeMACHINE_SH3); // SH3 little-endian + IMAGE_FILE_MACHINE_SH3DSP: + Result := LoadResString(@RsPeMACHINE_SH3DSP); + IMAGE_FILE_MACHINE_SH3E: + Result := LoadResString(@RsPeMACHINE_SH3E); // SH3E little-endian + IMAGE_FILE_MACHINE_SH4: + Result := LoadResString(@RsPeMACHINE_SH4); // SH4 little-endian + IMAGE_FILE_MACHINE_SH5: + Result := LoadResString(@RsPeMACHINE_SH5); // SH5 + IMAGE_FILE_MACHINE_ARM: + Result := LoadResString(@RsPeMACHINE_ARM); // ARM Little-Endian + IMAGE_FILE_MACHINE_THUMB: + Result := LoadResString(@RsPeMACHINE_THUMB); + IMAGE_FILE_MACHINE_AM33: + Result := LoadResString(@RsPeMACHINE_AM33); + IMAGE_FILE_MACHINE_POWERPC: + Result := LoadResString(@RsPeMACHINE_POWERPC); + IMAGE_FILE_MACHINE_POWERPCFP: + Result := LoadResString(@RsPeMACHINE_POWERPCFP); + IMAGE_FILE_MACHINE_IA64: + Result := LoadResString(@RsPeMACHINE_IA64); // Intel 64 + IMAGE_FILE_MACHINE_MIPS16: + Result := LoadResString(@RsPeMACHINE_MIPS16); // MIPS + IMAGE_FILE_MACHINE_ALPHA64: + Result := LoadResString(@RsPeMACHINE_AMPHA64); // ALPHA64 + //IMAGE_FILE_MACHINE_AXP64 + IMAGE_FILE_MACHINE_MIPSFPU: + Result := LoadResString(@RsPeMACHINE_MIPSFPU); // MIPS + IMAGE_FILE_MACHINE_MIPSFPU16: + Result := LoadResString(@RsPeMACHINE_MIPSFPU16); // MIPS + IMAGE_FILE_MACHINE_TRICORE: + Result := LoadResString(@RsPeMACHINE_TRICORE); // Infineon + IMAGE_FILE_MACHINE_CEF: + Result := LoadResString(@RsPeMACHINE_CEF); + IMAGE_FILE_MACHINE_EBC: + Result := LoadResString(@RsPeMACHINE_EBC); // EFI Byte Code + IMAGE_FILE_MACHINE_AMD64: + Result := LoadResString(@RsPeMACHINE_AMD64); // AMD64 (K8) + IMAGE_FILE_MACHINE_M32R: + Result := LoadResString(@RsPeMACHINE_M32R); // M32R little-endian + IMAGE_FILE_MACHINE_CEE: + Result := LoadResString(@RsPeMACHINE_CEE); + else + Result := Format('[%.8x]', [Value]); + end; + end; + + function GetSubsystemString(Value: DWORD): string; + begin + case Value of + IMAGE_SUBSYSTEM_UNKNOWN: + Result := LoadResString(@RsPeSUBSYSTEM_UNKNOWN); + IMAGE_SUBSYSTEM_NATIVE: + Result := LoadResString(@RsPeSUBSYSTEM_NATIVE); + IMAGE_SUBSYSTEM_WINDOWS_GUI: + Result := LoadResString(@RsPeSUBSYSTEM_WINDOWS_GUI); + IMAGE_SUBSYSTEM_WINDOWS_CUI: + Result := LoadResString(@RsPeSUBSYSTEM_WINDOWS_CUI); + IMAGE_SUBSYSTEM_OS2_CUI: + Result := LoadResString(@RsPeSUBSYSTEM_OS2_CUI); + IMAGE_SUBSYSTEM_POSIX_CUI: + Result := LoadResString(@RsPeSUBSYSTEM_POSIX_CUI); + IMAGE_SUBSYSTEM_RESERVED8: + Result := LoadResString(@RsPeSUBSYSTEM_RESERVED8); + else + Result := Format('[%.8x]', [Value]); + end; + end; + + function GetHeaderValues32(Index: TJclPeHeader): string; + var + OptionalHeader: TImageOptionalHeader32; + begin + OptionalHeader := OptionalHeader32; + case Index of + JclPeHeader_Magic: + Result := IntToHex(OptionalHeader.Magic, 4); + JclPeHeader_LinkerVersion: + Result := FormatVersionString(OptionalHeader.MajorLinkerVersion, OptionalHeader.MinorLinkerVersion); + JclPeHeader_SizeOfCode: + Result := IntToHex(OptionalHeader.SizeOfCode, 8); + JclPeHeader_SizeOfInitializedData: + Result := IntToHex(OptionalHeader.SizeOfInitializedData, 8); + JclPeHeader_SizeOfUninitializedData: + Result := IntToHex(OptionalHeader.SizeOfUninitializedData, 8); + JclPeHeader_AddressOfEntryPoint: + Result := IntToHex(OptionalHeader.AddressOfEntryPoint, 8); + JclPeHeader_BaseOfCode: + Result := IntToHex(OptionalHeader.BaseOfCode, 8); + JclPeHeader_BaseOfData: + {$IFDEF DELPHI64_TEMPORARY} + System.Error(rePlatformNotImplemented); + {$ELSE ~DELPHI64_TEMPORARY} + Result := IntToHex(OptionalHeader.BaseOfData, 8); + {$ENDIF ~DELPHI64_TEMPORARY} + JclPeHeader_ImageBase: + Result := IntToHex(OptionalHeader.ImageBase, 8); + JclPeHeader_SectionAlignment: + Result := IntToHex(OptionalHeader.SectionAlignment, 8); + JclPeHeader_FileAlignment: + Result := IntToHex(OptionalHeader.FileAlignment, 8); + JclPeHeader_OperatingSystemVersion: + Result := FormatVersionString(OptionalHeader.MajorOperatingSystemVersion, OptionalHeader.MinorOperatingSystemVersion); + JclPeHeader_ImageVersion: + Result := FormatVersionString(OptionalHeader.MajorImageVersion, OptionalHeader.MinorImageVersion); + JclPeHeader_SubsystemVersion: + Result := FormatVersionString(OptionalHeader.MajorSubsystemVersion, OptionalHeader.MinorSubsystemVersion); + JclPeHeader_Win32VersionValue: + Result := IntToHex(OptionalHeader.Win32VersionValue, 8); + JclPeHeader_SizeOfImage: + Result := IntToHex(OptionalHeader.SizeOfImage, 8); + JclPeHeader_SizeOfHeaders: + Result := IntToHex(OptionalHeader.SizeOfHeaders, 8); + JclPeHeader_CheckSum: + Result := IntToHex(OptionalHeader.CheckSum, 8); + JclPeHeader_Subsystem: + Result := GetSubsystemString(OptionalHeader.Subsystem); + JclPeHeader_DllCharacteristics: + Result := IntToHex(OptionalHeader.DllCharacteristics, 4); + JclPeHeader_SizeOfStackReserve: + Result := IntToHex(OptionalHeader.SizeOfStackReserve, 8); + JclPeHeader_SizeOfStackCommit: + Result := IntToHex(OptionalHeader.SizeOfStackCommit, 8); + JclPeHeader_SizeOfHeapReserve: + Result := IntToHex(OptionalHeader.SizeOfHeapReserve, 8); + JclPeHeader_SizeOfHeapCommit: + Result := IntToHex(OptionalHeader.SizeOfHeapCommit, 8); + JclPeHeader_LoaderFlags: + Result := IntToHex(OptionalHeader.LoaderFlags, 8); + JclPeHeader_NumberOfRvaAndSizes: + Result := IntToHex(OptionalHeader.NumberOfRvaAndSizes, 8); + end; + end; + + function GetHeaderValues64(Index: TJclPeHeader): string; + var + OptionalHeader: TImageOptionalHeader64; + begin + OptionalHeader := OptionalHeader64; + case Index of + JclPeHeader_Magic: + Result := IntToHex(OptionalHeader.Magic, 4); + JclPeHeader_LinkerVersion: + Result := FormatVersionString(OptionalHeader.MajorLinkerVersion, OptionalHeader.MinorLinkerVersion); + JclPeHeader_SizeOfCode: + Result := IntToHex(OptionalHeader.SizeOfCode, 8); + JclPeHeader_SizeOfInitializedData: + Result := IntToHex(OptionalHeader.SizeOfInitializedData, 8); + JclPeHeader_SizeOfUninitializedData: + Result := IntToHex(OptionalHeader.SizeOfUninitializedData, 8); + JclPeHeader_AddressOfEntryPoint: + Result := IntToHex(OptionalHeader.AddressOfEntryPoint, 8); + JclPeHeader_BaseOfCode: + Result := IntToHex(OptionalHeader.BaseOfCode, 8); + JclPeHeader_BaseOfData: + Result := ''; // IntToHex(OptionalHeader.BaseOfData, 8); + JclPeHeader_ImageBase: + Result := IntToHex(OptionalHeader.ImageBase, 16); + JclPeHeader_SectionAlignment: + Result := IntToHex(OptionalHeader.SectionAlignment, 8); + JclPeHeader_FileAlignment: + Result := IntToHex(OptionalHeader.FileAlignment, 8); + JclPeHeader_OperatingSystemVersion: + Result := FormatVersionString(OptionalHeader.MajorOperatingSystemVersion, OptionalHeader.MinorOperatingSystemVersion); + JclPeHeader_ImageVersion: + Result := FormatVersionString(OptionalHeader.MajorImageVersion, OptionalHeader.MinorImageVersion); + JclPeHeader_SubsystemVersion: + Result := FormatVersionString(OptionalHeader.MajorSubsystemVersion, OptionalHeader.MinorSubsystemVersion); + JclPeHeader_Win32VersionValue: + Result := IntToHex(OptionalHeader.Win32VersionValue, 8); + JclPeHeader_SizeOfImage: + Result := IntToHex(OptionalHeader.SizeOfImage, 8); + JclPeHeader_SizeOfHeaders: + Result := IntToHex(OptionalHeader.SizeOfHeaders, 8); + JclPeHeader_CheckSum: + Result := IntToHex(OptionalHeader.CheckSum, 8); + JclPeHeader_Subsystem: + Result := GetSubsystemString(OptionalHeader.Subsystem); + JclPeHeader_DllCharacteristics: + Result := IntToHex(OptionalHeader.DllCharacteristics, 4); + JclPeHeader_SizeOfStackReserve: + Result := IntToHex(OptionalHeader.SizeOfStackReserve, 16); + JclPeHeader_SizeOfStackCommit: + Result := IntToHex(OptionalHeader.SizeOfStackCommit, 16); + JclPeHeader_SizeOfHeapReserve: + Result := IntToHex(OptionalHeader.SizeOfHeapReserve, 16); + JclPeHeader_SizeOfHeapCommit: + Result := IntToHex(OptionalHeader.SizeOfHeapCommit, 16); + JclPeHeader_LoaderFlags: + Result := IntToHex(OptionalHeader.LoaderFlags, 8); + JclPeHeader_NumberOfRvaAndSizes: + Result := IntToHex(OptionalHeader.NumberOfRvaAndSizes, 8); + end; + end; + +begin + if StatusOK then + with FLoadedImage.FileHeader^ do + case Index of + JclPeHeader_Signature: + Result := IntToHex(Signature, 8); + JclPeHeader_Machine: + Result := GetMachineString(FileHeader.Machine); + JclPeHeader_NumberOfSections: + Result := IntToHex(FileHeader.NumberOfSections, 4); + JclPeHeader_TimeDateStamp: + Result := IntToHex(FileHeader.TimeDateStamp, 8); + JclPeHeader_PointerToSymbolTable: + Result := IntToHex(FileHeader.PointerToSymbolTable, 8); + JclPeHeader_NumberOfSymbols: + Result := IntToHex(FileHeader.NumberOfSymbols, 8); + JclPeHeader_SizeOfOptionalHeader: + Result := IntToHex(FileHeader.SizeOfOptionalHeader, 4); + JclPeHeader_Characteristics: + Result := IntToHex(FileHeader.Characteristics, 4); + JclPeHeader_Magic..JclPeHeader_NumberOfRvaAndSizes: + case Target of + taWin32: + Result := GetHeaderValues32(Index); + taWin64: + Result := GetHeaderValues64(Index); + //taUnknown: + else + Result := ''; + end; + else + Result := ''; + end + else + Result := ''; +end; + +function TJclPeImage.GetImageSectionCount: Integer; +begin + Result := FImageSections.Count; +end; + +function TJclPeImage.GetImageSectionFullNames(Index: Integer): string; +var + Offset: Integer; +begin + Result := ImageSectionNames[Index]; + if (Length(Result) > 0) and (Result[1] = '/') and TryStrToInt(Copy(Result, 2, MaxInt), Offset) then + Result := GetNameInStringTable(Offset); +end; + +function TJclPeImage.GetImageSectionHeaders(Index: Integer): TImageSectionHeader; +begin + Result := PImageSectionHeader(FImageSections.Objects[Index])^; +end; + +function TJclPeImage.GetImageSectionNameFromRva(const Rva: DWORD): string; +begin + Result := GetSectionName(RvaToSection(Rva)); +end; + +function TJclPeImage.GetImageSectionNames(Index: Integer): string; +begin + Result := FImageSections[Index]; +end; + +function TJclPeImage.GetImportList: TJclPeImportList; +begin + if FImportList = nil then + FImportList := TJclPeImportList.Create(Self); + Result := FImportList; +end; + +function TJclPeImage.GetLoadConfigValues(Index: TJclLoadConfig): string; + function GetLoadConfigValues32(Index: TJclLoadConfig): string; + var + LoadConfig: PIMAGE_LOAD_CONFIG_DIRECTORY32; + begin + LoadConfig := DirectoryEntryToData(IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG); + if LoadConfig <> nil then + with LoadConfig^ do + case Index of + JclLoadConfig_Characteristics: + Result := IntToHex(Size, 8); + JclLoadConfig_TimeDateStamp: + Result := IntToHex(TimeDateStamp, 8); + JclLoadConfig_Version: + Result := FormatVersionString(MajorVersion, MinorVersion); + JclLoadConfig_GlobalFlagsClear: + Result := IntToHex(GlobalFlagsClear, 8); + JclLoadConfig_GlobalFlagsSet: + Result := IntToHex(GlobalFlagsSet, 8); + JclLoadConfig_CriticalSectionDefaultTimeout: + Result := IntToHex(CriticalSectionDefaultTimeout, 8); + JclLoadConfig_DeCommitFreeBlockThreshold: + Result := IntToHex(DeCommitFreeBlockThreshold, 8); + JclLoadConfig_DeCommitTotalFreeThreshold: + Result := IntToHex(DeCommitTotalFreeThreshold, 8); + JclLoadConfig_LockPrefixTable: + Result := IntToHex(LockPrefixTable, 8); + JclLoadConfig_MaximumAllocationSize: + Result := IntToHex(MaximumAllocationSize, 8); + JclLoadConfig_VirtualMemoryThreshold: + Result := IntToHex(VirtualMemoryThreshold, 8); + JclLoadConfig_ProcessHeapFlags: + Result := IntToHex(ProcessHeapFlags, 8); + JclLoadConfig_ProcessAffinityMask: + Result := IntToHex(ProcessAffinityMask, 8); + JclLoadConfig_CSDVersion: + Result := IntToHex(CSDVersion, 4); + JclLoadConfig_Reserved1: + Result := IntToHex(Reserved1, 4); + JclLoadConfig_EditList: + Result := IntToHex(EditList, 8); + JclLoadConfig_Reserved: + Result := LoadResString(@RsPeReserved); + end; + end; + function GetLoadConfigValues64(Index: TJclLoadConfig): string; + var + LoadConfig: PIMAGE_LOAD_CONFIG_DIRECTORY64; + begin + LoadConfig := DirectoryEntryToData(IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG); + if LoadConfig <> nil then + with LoadConfig^ do + case Index of + JclLoadConfig_Characteristics: + Result := IntToHex(Size, 8); + JclLoadConfig_TimeDateStamp: + Result := IntToHex(TimeDateStamp, 8); + JclLoadConfig_Version: + Result := FormatVersionString(MajorVersion, MinorVersion); + JclLoadConfig_GlobalFlagsClear: + Result := IntToHex(GlobalFlagsClear, 8); + JclLoadConfig_GlobalFlagsSet: + Result := IntToHex(GlobalFlagsSet, 8); + JclLoadConfig_CriticalSectionDefaultTimeout: + Result := IntToHex(CriticalSectionDefaultTimeout, 8); + JclLoadConfig_DeCommitFreeBlockThreshold: + Result := IntToHex(DeCommitFreeBlockThreshold, 16); + JclLoadConfig_DeCommitTotalFreeThreshold: + Result := IntToHex(DeCommitTotalFreeThreshold, 16); + JclLoadConfig_LockPrefixTable: + Result := IntToHex(LockPrefixTable, 16); + JclLoadConfig_MaximumAllocationSize: + Result := IntToHex(MaximumAllocationSize, 16); + JclLoadConfig_VirtualMemoryThreshold: + Result := IntToHex(VirtualMemoryThreshold, 16); + JclLoadConfig_ProcessHeapFlags: + Result := IntToHex(ProcessHeapFlags, 8); + JclLoadConfig_ProcessAffinityMask: + Result := IntToHex(ProcessAffinityMask, 16); + JclLoadConfig_CSDVersion: + Result := IntToHex(CSDVersion, 4); + JclLoadConfig_Reserved1: + Result := IntToHex(Reserved1, 4); + JclLoadConfig_EditList: + Result := IntToHex(EditList, 16); + JclLoadConfig_Reserved: + Result := LoadResString(@RsPeReserved); + end; + end; +begin + Result := ''; + case Target of + taWin32: + Result := GetLoadConfigValues32(Index); + taWin64: + Result := GetLoadConfigValues64(Index); + end; +end; + +function TJclPeImage.GetMappedAddress: TJclAddr; +begin + if StatusOK then + Result := TJclAddr(LoadedImage.MappedAddress) + else + Result := 0; +end; + +function TJclPeImage.GetNameInStringTable(Offset: ULONG): string; +var + Index: Integer; +begin + Dec(Offset, SizeOf(ULONG)); + Index := 0; + while (Offset > 0) and (Index < FStringTable.Count) do + begin + Dec(Offset, Length(FStringTable[Index]) + 1); + if Offset > 0 then + Inc(Index); + end; + + if Offset = 0 then + Result := FStringTable[Index] + else + Result := ''; +end; + +function TJclPeImage.GetOptionalHeader32: TImageOptionalHeader32; +begin + if Target = taWin32 then + Result := PImageNtHeaders32(FLoadedImage.FileHeader)^.OptionalHeader + else + ZeroMemory(@Result, SizeOf(Result)); +end; + +function TJclPeImage.GetOptionalHeader64: TImageOptionalHeader64; +begin + if Target = taWin64 then + Result := PImageNtHeaders64(FLoadedImage.FileHeader)^.OptionalHeader + else + ZeroMemory(@Result, SizeOf(Result)); +end; + +function TJclPeImage.GetRelocationList: TJclPeRelocList; +begin + if FRelocationList = nil then + FRelocationList := TJclPeRelocList.Create(Self); + Result := FRelocationList; +end; + +function TJclPeImage.GetResourceList: TJclPeRootResourceList; +begin + if FResourceList = nil then + begin + FResourceVA := Directories[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress; + if FResourceVA <> 0 then + FResourceVA := TJclAddr(RvaToVa(FResourceVA)); + FResourceList := TJclPeRootResourceList.Create(Self, nil, PImageResourceDirectory(FResourceVA)); + end; + Result := FResourceList; +end; + +function TJclPeImage.GetSectionHeader(const SectionName: string; + out Header: PImageSectionHeader): Boolean; +var + I: Integer; +begin + I := FImageSections.IndexOf(SectionName); + if I = -1 then + begin + Header := nil; + Result := False; + end + else + begin + Header := PImageSectionHeader(FImageSections.Objects[I]); + Result := True; + end; +end; + +function TJclPeImage.GetSectionName(Header: PImageSectionHeader): string; +var + I: Integer; +begin + I := FImageSections.IndexOfObject(TObject(Header)); + if I = -1 then + Result := '' + else + Result := FImageSections[I]; +end; + +function TJclPeImage.GetStringTableCount: Integer; +begin + Result := FStringTable.Count; +end; + +function TJclPeImage.GetStringTableItem(Index: Integer): string; +begin + Result := FStringTable[Index]; +end; + +function TJclPeImage.GetUnusedHeaderBytes: TImageDataDirectory; +begin + CheckNotAttached; + Result.Size := 0; + Result.VirtualAddress := GetImageUnusedHeaderBytes(FLoadedImage, Result.Size); + if Result.VirtualAddress = 0 then + RaiseLastOSError; +end; + +function TJclPeImage.GetVersionInfo: TJclFileVersionInfo; +var + VersionInfoResource: TJclPeResourceItem; +begin + if (FVersionInfo = nil) and VersionInfoAvailable then + begin + VersionInfoResource := ResourceList.FindResource(rtVersion, '1').List[0]; + with VersionInfoResource do + try + FVersionInfo := TJclFileVersionInfo.Attach(RawEntryData, RawEntryDataSize); + except + FreeAndNil(FVersionInfo); + end; + end; + Result := FVersionInfo; +end; + +function TJclPeImage.GetVersionInfoAvailable: Boolean; +begin + Result := StatusOK and (ResourceList.FindResource(rtVersion, '1') <> nil); +end; + +class function TJclPeImage.HeaderNames(Index: TJclPeHeader): string; +begin + case Index of + JclPeHeader_Signature: + Result := LoadResString(@RsPeSignature); + JclPeHeader_Machine: + Result := LoadResString(@RsPeMachine); + JclPeHeader_NumberOfSections: + Result := LoadResString(@RsPeNumberOfSections); + JclPeHeader_TimeDateStamp: + Result := LoadResString(@RsPeTimeDateStamp); + JclPeHeader_PointerToSymbolTable: + Result := LoadResString(@RsPePointerToSymbolTable); + JclPeHeader_NumberOfSymbols: + Result := LoadResString(@RsPeNumberOfSymbols); + JclPeHeader_SizeOfOptionalHeader: + Result := LoadResString(@RsPeSizeOfOptionalHeader); + JclPeHeader_Characteristics: + Result := LoadResString(@RsPeCharacteristics); + JclPeHeader_Magic: + Result := LoadResString(@RsPeMagic); + JclPeHeader_LinkerVersion: + Result := LoadResString(@RsPeLinkerVersion); + JclPeHeader_SizeOfCode: + Result := LoadResString(@RsPeSizeOfCode); + JclPeHeader_SizeOfInitializedData: + Result := LoadResString(@RsPeSizeOfInitializedData); + JclPeHeader_SizeOfUninitializedData: + Result := LoadResString(@RsPeSizeOfUninitializedData); + JclPeHeader_AddressOfEntryPoint: + Result := LoadResString(@RsPeAddressOfEntryPoint); + JclPeHeader_BaseOfCode: + Result := LoadResString(@RsPeBaseOfCode); + JclPeHeader_BaseOfData: + Result := LoadResString(@RsPeBaseOfData); + JclPeHeader_ImageBase: + Result := LoadResString(@RsPeImageBase); + JclPeHeader_SectionAlignment: + Result := LoadResString(@RsPeSectionAlignment); + JclPeHeader_FileAlignment: + Result := LoadResString(@RsPeFileAlignment); + JclPeHeader_OperatingSystemVersion: + Result := LoadResString(@RsPeOperatingSystemVersion); + JclPeHeader_ImageVersion: + Result := LoadResString(@RsPeImageVersion); + JclPeHeader_SubsystemVersion: + Result := LoadResString(@RsPeSubsystemVersion); + JclPeHeader_Win32VersionValue: + Result := LoadResString(@RsPeWin32VersionValue); + JclPeHeader_SizeOfImage: + Result := LoadResString(@RsPeSizeOfImage); + JclPeHeader_SizeOfHeaders: + Result := LoadResString(@RsPeSizeOfHeaders); + JclPeHeader_CheckSum: + Result := LoadResString(@RsPeCheckSum); + JclPeHeader_Subsystem: + Result := LoadResString(@RsPeSubsystem); + JclPeHeader_DllCharacteristics: + Result := LoadResString(@RsPeDllCharacteristics); + JclPeHeader_SizeOfStackReserve: + Result := LoadResString(@RsPeSizeOfStackReserve); + JclPeHeader_SizeOfStackCommit: + Result := LoadResString(@RsPeSizeOfStackCommit); + JclPeHeader_SizeOfHeapReserve: + Result := LoadResString(@RsPeSizeOfHeapReserve); + JclPeHeader_SizeOfHeapCommit: + Result := LoadResString(@RsPeSizeOfHeapCommit); + JclPeHeader_LoaderFlags: + Result := LoadResString(@RsPeLoaderFlags); + JclPeHeader_NumberOfRvaAndSizes: + Result := LoadResString(@RsPeNumberOfRvaAndSizes); + else + Result := ''; + end; +end; + +function TJclPeImage.IsBrokenFormat: Boolean; + function IsBrokenFormat32: Boolean; + var + OptionalHeader: TImageOptionalHeader32; + begin + OptionalHeader := OptionalHeader32; + Result := not ((OptionalHeader.AddressOfEntryPoint = 0) or IsCLR); + if Result then + begin + Result := (ImageSectionCount = 0); + if not Result then + with ImageSectionHeaders[0] do + Result := (VirtualAddress <> OptionalHeader.BaseOfCode) or (SizeOfRawData = 0) or + (OptionalHeader.AddressOfEntryPoint > VirtualAddress + Misc.VirtualSize) or + (Characteristics and (IMAGE_SCN_CNT_CODE or IMAGE_SCN_MEM_WRITE) <> IMAGE_SCN_CNT_CODE); + end; + end; + function IsBrokenFormat64: Boolean; + var + OptionalHeader: TImageOptionalHeader64; + begin + OptionalHeader := OptionalHeader64; + Result := not ((OptionalHeader.AddressOfEntryPoint = 0) or IsCLR); + if Result then + begin + Result := (ImageSectionCount = 0); + if not Result then + with ImageSectionHeaders[0] do + Result := (VirtualAddress <> OptionalHeader.BaseOfCode) or (SizeOfRawData = 0) or + (OptionalHeader.AddressOfEntryPoint > VirtualAddress + Misc.VirtualSize) or + (Characteristics and (IMAGE_SCN_CNT_CODE or IMAGE_SCN_MEM_WRITE) <> IMAGE_SCN_CNT_CODE); + end; + end; +begin + case Target of + taWin32: + Result := IsBrokenFormat32; + taWin64: + Result := IsBrokenFormat64; + //taUnknown: + else + Result := False; // don't know how to check it + end; +end; + +function TJclPeImage.IsCLR: Boolean; +begin + Result := DirectoryExists[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR] and CLRHeader.HasMetadata; +end; + +function TJclPeImage.IsSystemImage: Boolean; +begin + Result := StatusOK and FLoadedImage.fSystemImage; +end; + +class function TJclPeImage.LoadConfigNames(Index: TJclLoadConfig): string; +begin + case Index of + JclLoadConfig_Characteristics: + Result := LoadResString(@RsPeCharacteristics); + JclLoadConfig_TimeDateStamp: + Result := LoadResString(@RsPeTimeDateStamp); + JclLoadConfig_Version: + Result := LoadResString(@RsPeVersion); + JclLoadConfig_GlobalFlagsClear: + Result := LoadResString(@RsPeGlobalFlagsClear); + JclLoadConfig_GlobalFlagsSet: + Result := LoadResString(@RsPeGlobalFlagsSet); + JclLoadConfig_CriticalSectionDefaultTimeout: + Result := LoadResString(@RsPeCriticalSectionDefaultTimeout); + JclLoadConfig_DeCommitFreeBlockThreshold: + Result := LoadResString(@RsPeDeCommitFreeBlockThreshold); + JclLoadConfig_DeCommitTotalFreeThreshold: + Result := LoadResString(@RsPeDeCommitTotalFreeThreshold); + JclLoadConfig_LockPrefixTable: + Result := LoadResString(@RsPeLockPrefixTable); + JclLoadConfig_MaximumAllocationSize: + Result := LoadResString(@RsPeMaximumAllocationSize); + JclLoadConfig_VirtualMemoryThreshold: + Result := LoadResString(@RsPeVirtualMemoryThreshold); + JclLoadConfig_ProcessHeapFlags: + Result := LoadResString(@RsPeProcessHeapFlags); + JclLoadConfig_ProcessAffinityMask: + Result := LoadResString(@RsPeProcessAffinityMask); + JclLoadConfig_CSDVersion: + Result := LoadResString(@RsPeCSDVersion); + JclLoadConfig_Reserved1: + Result := LoadResString(@RsPeReserved); + JclLoadConfig_EditList: + Result := LoadResString(@RsPeEditList); + JclLoadConfig_Reserved: + Result := LoadResString(@RsPeReserved); + else + Result := ''; + end; +end; + +procedure TJclPeImage.RaiseStatusException; +begin + if not FNoExceptions then + case FStatus of + stNotPE: + raise EJclPeImageError.CreateRes(@RsPeNotPE); + stNotFound: + raise EJclPeImageError.CreateResFmt(@RsPeCantOpen, [FFileName]); + stNotSupported: + raise EJclPeImageError.CreateRes(@RsPeUnknownTarget); + stError: + RaiseLastOSError; + end; +end; + +function TJclPeImage.RawToVa(Raw: DWORD): Pointer; +begin + Result := Pointer(TJclAddr(FLoadedImage.MappedAddress) + Raw); +end; + +procedure TJclPeImage.ReadImageSections; +var + I: Integer; + Header: PImageSectionHeader; + UTF8Name: TUTF8String; + SectionName: string; +begin + if not StatusOK then + Exit; + Header := FLoadedImage.Sections; + for I := 0 to FLoadedImage.NumberOfSections - 1 do + begin + SetLength(UTF8Name, IMAGE_SIZEOF_SHORT_NAME); + Move(Header.Name[0], UTF8Name[1], IMAGE_SIZEOF_SHORT_NAME * SizeOf(AnsiChar)); + StrResetLength(UTF8Name); + if not TryUTF8ToString(UTF8Name, SectionName) then + SectionName := string(UTF8Name); + FImageSections.AddObject(SectionName, Pointer(Header)); + Inc(Header); + end; +end; + +procedure TJclPeImage.ReadStringTable; +var + SymbolTable: DWORD; + StringTablePtr: PAnsiChar; + Ptr: PAnsiChar; + ByteSize: ULONG; + Start: PAnsiChar; + StringEntry: AnsiString; +begin + SymbolTable := LoadedImage.FileHeader.FileHeader.PointerToSymbolTable; + if SymbolTable = 0 then + Exit; + + StringTablePtr := PAnsiChar(LoadedImage.MappedAddress) + + SymbolTable + + (LoadedImage.FileHeader.FileHeader.NumberOfSymbols * SizeOf(IMAGE_SYMBOL)); + + ByteSize := PULONG(StringTablePtr)^; + Ptr := StringTablePtr + SizeOf(ByteSize); + + while Ptr < StringTablePtr + ByteSize do + begin + Start := Ptr; + while (Ptr^ <> #0) and (Ptr < StringTablePtr + ByteSize) do + Inc(Ptr); + if Start <> Ptr then + begin + SetLength(StringEntry, Ptr - Start); + Move(Start^, StringEntry[1], Ptr - Start); + FStringTable.Add(string(StringEntry)); + end; + Inc(Ptr); // to skip the #0 character + end; +end; + +function TJclPeImage.ResourceItemCreate(AEntry: PImageResourceDirectoryEntry; + AParentItem: TJclPeResourceItem): TJclPeResourceItem; +begin + Result := TJclPeResourceItem.Create(Self, AParentItem, AEntry); +end; + +function TJclPeImage.ResourceListCreate(ADirectory: PImageResourceDirectory; + AParentItem: TJclPeResourceItem): TJclPeResourceList; +begin + Result := TJclPeResourceList.Create(Self, AParentItem, ADirectory); +end; + +function TJclPeImage.RvaToSection(Rva: DWORD): PImageSectionHeader; +var + I: Integer; + SectionHeader: PImageSectionHeader; + EndRVA: DWORD; +begin + Result := ImageRvaToSection(FLoadedImage.FileHeader, FLoadedImage.MappedAddress, Rva); + if Result = nil then + for I := 0 to FImageSections.Count - 1 do + begin + SectionHeader := PImageSectionHeader(FImageSections.Objects[I]); + if SectionHeader^.SizeOfRawData = 0 then + EndRVA := SectionHeader^.Misc.VirtualSize + else + EndRVA := SectionHeader^.SizeOfRawData; + Inc(EndRVA, SectionHeader^.VirtualAddress); + if (SectionHeader^.VirtualAddress <= Rva) and (EndRVA >= Rva) then + begin + Result := SectionHeader; + Break; + end; + end; +end; + +function TJclPeImage.RvaToVa(Rva: DWORD): Pointer; +begin + if FAttachedImage then + Result := Pointer(TJclAddr(FLoadedImage.MappedAddress) + Rva) + else + Result := ImageRvaToVa(FLoadedImage.FileHeader, FLoadedImage.MappedAddress, Rva, nil); +end; + +function TJclPeImage.RvaToVaEx(Rva: DWORD): Pointer; + function RvaToVaEx32(Rva: DWORD): Pointer; + var + OptionalHeader: TImageOptionalHeader32; + begin + OptionalHeader := OptionalHeader32; + if (Rva >= OptionalHeader.ImageBase) and (Rva < (OptionalHeader.ImageBase + FLoadedImage.SizeOfImage)) then + Dec(Rva, OptionalHeader.ImageBase); + Result := RvaToVa(Rva); + end; + function RvaToVaEx64(Rva: DWORD): Pointer; + var + OptionalHeader: TImageOptionalHeader64; + begin + OptionalHeader := OptionalHeader64; + if (Rva >= OptionalHeader.ImageBase) and (Rva < (OptionalHeader.ImageBase + FLoadedImage.SizeOfImage)) then + Dec(Rva, OptionalHeader.ImageBase); + Result := RvaToVa(Rva); + end; +begin + case Target of + taWin32: + Result := RvaToVaEx32(Rva); + taWin64: + Result := RvaToVaEx64(Rva); + //taUnknown: + else + Result := nil; + end; +end; + +procedure TJclPeImage.SetFileName(const Value: TFileName); +begin + if FFileName <> Value then + begin + Clear; + FFileName := Value; + if FFileName = '' then + Exit; + // OF: possible loss of data + if MapAndLoad(PAnsiChar(AnsiString(FFileName)), nil, FLoadedImage, True, FReadOnlyAccess) then + begin + FTarget := PeMapImgTarget(FLoadedImage.MappedAddress); + if FTarget <> taUnknown then + begin + FStatus := stOk; + ReadImageSections; + ReadStringTable; + AfterOpen; + end + else + FStatus := stNotSupported; + end + else + case GetLastError of + ERROR_SUCCESS: + FStatus := stNotPE; + ERROR_FILE_NOT_FOUND: + FStatus := stNotFound; + else + FStatus := stError; + end; + RaiseStatusException; + end; +end; + +class function TJclPeImage.ShortSectionInfo(Characteristics: DWORD): string; +type + TSectionCharacteristics = packed record + Mask: DWORD; + InfoChar: Char; + end; +const + Info: array [1..8] of TSectionCharacteristics = ( + (Mask: IMAGE_SCN_CNT_CODE; InfoChar: 'C'), + (Mask: IMAGE_SCN_MEM_EXECUTE; InfoChar: 'E'), + (Mask: IMAGE_SCN_MEM_READ; InfoChar: 'R'), + (Mask: IMAGE_SCN_MEM_WRITE; InfoChar: 'W'), + (Mask: IMAGE_SCN_CNT_INITIALIZED_DATA; InfoChar: 'I'), + (Mask: IMAGE_SCN_CNT_UNINITIALIZED_DATA; InfoChar: 'U'), + (Mask: IMAGE_SCN_MEM_SHARED; InfoChar: 'S'), + (Mask: IMAGE_SCN_MEM_DISCARDABLE; InfoChar: 'D') + ); +var + I: Integer; +begin + SetLength(Result, High(Info)); + Result := ''; + for I := Low(Info) to High(Info) do + with Info[I] do + if (Characteristics and Mask) = Mask then + Result := Result + InfoChar; +end; + +function TJclPeImage.StatusOK: Boolean; +begin + Result := (FStatus = stOk); +end; + +class function TJclPeImage.StampToDateTime(TimeDateStamp: DWORD): TDateTime; +begin + Result := TimeDateStamp / SecsPerDay + UnixTimeStart +end; + +procedure TJclPeImage.TryGetNamesForOrdinalImports; +begin + if StatusOK then + begin + GetImportList; + FImportList.TryGetNamesForOrdinalImports; + end; +end; + +function TJclPeImage.VerifyCheckSum: Boolean; + function VerifyCheckSum32: Boolean; + var + OptionalHeader: TImageOptionalHeader32; + begin + OptionalHeader := OptionalHeader32; + Result := StatusOK and ((OptionalHeader.CheckSum = 0) or (CalculateCheckSum = OptionalHeader.CheckSum)); + end; + function VerifyCheckSum64: Boolean; + var + OptionalHeader: TImageOptionalHeader64; + begin + OptionalHeader := OptionalHeader64; + Result := StatusOK and ((OptionalHeader.CheckSum = 0) or (CalculateCheckSum = OptionalHeader.CheckSum)); + end; +begin + CheckNotAttached; + case Target of + taWin32: + Result := VerifyCheckSum32; + taWin64: + Result := VerifyCheckSum64; + //taUnknown: ; + else + Result := True; + end; +end; + +{$IFDEF BORLAND} + +//=== { TJclPeBorImagesCache } =============================================== + +function TJclPeBorImagesCache.GetImages(const FileName: TFileName): TJclPeBorImage; +begin + Result := TJclPeBorImage(inherited Images[FileName]); +end; + +function TJclPeBorImagesCache.GetPeImageClass: TJclPeImageClass; +begin + Result := TJclPeBorImage; +end; + +//=== { TJclPePackageInfo } ================================================== + +constructor TJclPePackageInfo.Create(ALibHandle: THandle); +begin + FContains := TStringList.Create; + FRequires := TStringList.Create; + FEnsureExtension := True; + FSorted := True; + ReadPackageInfo(ALibHandle); +end; + +destructor TJclPePackageInfo.Destroy; +begin + FreeAndNil(FContains); + FreeAndNil(FRequires); + inherited Destroy; +end; + +function TJclPePackageInfo.GetContains: TStrings; +begin + Result := FContains; +end; + +function TJclPePackageInfo.GetContainsCount: Integer; +begin + Result := Contains.Count; +end; + +function TJclPePackageInfo.GetContainsFlags(Index: Integer): Byte; +begin + Result := Byte(Contains.Objects[Index]); +end; + +function TJclPePackageInfo.GetContainsNames(Index: Integer): string; +begin + Result := Contains[Index]; +end; + +function TJclPePackageInfo.GetRequires: TStrings; +begin + Result := FRequires; +end; + +function TJclPePackageInfo.GetRequiresCount: Integer; +begin + Result := Requires.Count; +end; + +function TJclPePackageInfo.GetRequiresNames(Index: Integer): string; +begin + Result := Requires[Index]; + if FEnsureExtension then + StrEnsureSuffix(BinaryExtensionPackage, Result); +end; + +class function TJclPePackageInfo.PackageModuleTypeToString(Flags: Cardinal): string; +begin + case Flags and pfModuleTypeMask of + pfExeModule, pfModuleTypeMask: + Result := LoadResString(@RsPePkgExecutable); + pfPackageModule: + Result := LoadResString(@RsPePkgPackage); + pfLibraryModule: + Result := LoadResString(@PsPePkgLibrary); + else + Result := ''; + end; +end; + +class function TJclPePackageInfo.PackageOptionsToString(Flags: Cardinal): string; +begin + Result := ''; + AddFlagTextRes(Result, @RsPePkgNeverBuild, Flags, pfNeverBuild); + AddFlagTextRes(Result, @RsPePkgDesignOnly, Flags, pfDesignOnly); + AddFlagTextRes(Result, @RsPePkgRunOnly, Flags, pfRunOnly); + AddFlagTextRes(Result, @RsPePkgIgnoreDupUnits, Flags, pfIgnoreDupUnits); +end; + +class function TJclPePackageInfo.ProducerToString(Flags: Cardinal): string; +begin + case Flags and pfProducerMask of + pfV3Produced: + Result := LoadResString(@RsPePkgV3Produced); + pfProducerUndefined: + Result := LoadResString(@RsPePkgProducerUndefined); + pfBCB4Produced: + Result := LoadResString(@RsPePkgBCB4Produced); + pfDelphi4Produced: + Result := LoadResString(@RsPePkgDelphi4Produced); + else + Result := ''; + end; +end; + +procedure PackageInfoProc(const Name: string; NameType: TNameType; AFlags: Byte; Param: Pointer); +begin + with TJclPePackageInfo(Param) do + case NameType of + ntContainsUnit: + Contains.AddObject(Name, Pointer(AFlags)); + ntRequiresPackage: + Requires.Add(Name); + ntDcpBpiName: + SetDcpName(Name); + end; +end; + +procedure TJclPePackageInfo.ReadPackageInfo(ALibHandle: THandle); +var + DescrResInfo: HRSRC; + DescrResData: HGLOBAL; +begin + FAvailable := FindResource(ALibHandle, PackageInfoResName, RT_RCDATA) <> 0; + if FAvailable then + begin + GetPackageInfo(ALibHandle, Self, FFlags, PackageInfoProc); + if FDcpName = '' then + FDcpName := PathExtractFileNameNoExt(GetModulePath(ALibHandle)) + CompilerExtensionDCP; + if FSorted then + begin + FContains.Sort; + FRequires.Sort; + end; + end; + DescrResInfo := FindResource(ALibHandle, DescriptionResName, RT_RCDATA); + if DescrResInfo <> 0 then + begin + DescrResData := LoadResource(ALibHandle, DescrResInfo); + if DescrResData <> 0 then + begin + FDescription := WideCharLenToString(LockResource(DescrResData), + SizeofResource(ALibHandle, DescrResInfo)); + StrResetLength(FDescription); + end; + end; +end; + +procedure TJclPePackageInfo.SetDcpName(const Value: string); +begin + FDcpName := Value; +end; + +class function TJclPePackageInfo.UnitInfoFlagsToString(UnitFlags: Byte): string; +begin + Result := ''; + AddFlagTextRes(Result, @RsPePkgMain, UnitFlags, ufMainUnit); + AddFlagTextRes(Result, @RsPePkgPackage, UnitFlags, ufPackageUnit); + AddFlagTextRes(Result, @RsPePkgWeak, UnitFlags, ufWeakUnit); + AddFlagTextRes(Result, @RsPePkgOrgWeak, UnitFlags, ufOrgWeakUnit); + AddFlagTextRes(Result, @RsPePkgImplicit, UnitFlags, ufImplicitUnit); +end; + +//=== { TJclPeBorForm } ====================================================== + +constructor TJclPeBorForm.Create(AResItem: TJclPeResourceItem; + AFormFlags: TFilerFlags; AFormPosition: Integer; + const AFormClassName, AFormObjectName: string); +begin + inherited Create; + FResItem := AResItem; + FFormFlags := AFormFlags; + FFormPosition := AFormPosition; + FFormClassName := AFormClassName; + FFormObjectName := AFormObjectName; +end; + +procedure TJclPeBorForm.ConvertFormToText(const Stream: TStream); +var + SourceStream: TJclPeResourceRawStream; +begin + SourceStream := TJclPeResourceRawStream.Create(ResItem); + try + ObjectBinaryToText(SourceStream, Stream); + finally + SourceStream.Free; + end; +end; + +procedure TJclPeBorForm.ConvertFormToText(const Strings: TStrings); +var + TempStream: TMemoryStream; +begin + TempStream := TMemoryStream.Create; + try + ConvertFormToText(TempStream); + TempStream.Seek(0, soFromBeginning); + Strings.LoadFromStream(TempStream); + finally + TempStream.Free; + end; +end; + +function TJclPeBorForm.GetDisplayName: string; +begin + if FFormObjectName <> '' then + Result := FFormObjectName + ': ' + else + Result := ''; + Result := Result + FFormClassName; +end; + +//=== { TJclPeBorImage } ===================================================== + +constructor TJclPeBorImage.Create(ANoExceptions: Boolean); +begin + FForms := TObjectList.Create(True); + FPackageInfoSorted := True; + inherited Create(ANoExceptions); +end; + +destructor TJclPeBorImage.Destroy; +begin + inherited Destroy; + FreeAndNil(FForms); +end; + +procedure TJclPeBorImage.AfterOpen; +var + HasDVCLAL, HasPACKAGEINFO, HasPACKAGEOPTIONS: Boolean; +begin + inherited AfterOpen; + if StatusOK then + with ResourceList do + begin + HasDVCLAL := (FindResource(rtRCData, DVclAlResName) <> nil); + HasPACKAGEINFO := (FindResource(rtRCData, PackageInfoResName) <> nil); + HasPACKAGEOPTIONS := (FindResource(rtRCData, PackageOptionsResName) <> nil); + FIsPackage := HasPACKAGEINFO and HasPACKAGEOPTIONS; + FIsBorlandImage := HasDVCLAL or FIsPackage; + end; +end; + +procedure TJclPeBorImage.Clear; +begin + FForms.Clear; + FreeAndNil(FPackageInfo); + FreeLibHandle; + inherited Clear; + FIsBorlandImage := False; + FIsPackage := False; + FPackageCompilerVersion := 0; +end; + +procedure TJclPeBorImage.CreateFormsList; +var + ResTypeItem: TJclPeResourceItem; + I: Integer; + + procedure ProcessListItem(DfmResItem: TJclPeResourceItem); + const + FilerSignature: array [1..4] of AnsiChar = string('TPF0'); + var + SourceStream: TJclPeResourceRawStream; + Reader: TReader; + FormFlags: TFilerFlags; + FormPosition: Integer; + ClassName, FormName: string; + begin + SourceStream := TJclPeResourceRawStream.Create(DfmResItem); + try + if (SourceStream.Size > SizeOf(FilerSignature)) and + (PInteger(SourceStream.Memory)^ = Integer(FilerSignature)) then + begin + Reader := TReader.Create(SourceStream, 4096); + try + Reader.ReadSignature; + Reader.ReadPrefix(FormFlags, FormPosition); + ClassName := Reader.ReadStr; + FormName := Reader.ReadStr; + FForms.Add(TJclPeBorForm.Create(DfmResItem, FormFlags, FormPosition, + ClassName, FormName)); + finally + Reader.Free; + end; + end; + finally + SourceStream.Free; + end; + end; + +begin + if StatusOK then + with ResourceList do + begin + ResTypeItem := FindResource(rtRCData, ''); + if ResTypeItem <> nil then + with ResTypeItem.List do + for I := 0 to Count - 1 do + ProcessListItem(Items[I].List[0]); + end; +end; + +function TJclPeBorImage.DependedPackages(List: TStrings; FullPathName, Descriptions: Boolean): Boolean; +var + ImportList: TStringList; + I: Integer; + Name: string; +begin + Result := IsBorlandImage; + if not Result then + Exit; + ImportList := InternalImportedLibraries(FileName, True, FullPathName, nil); + List.BeginUpdate; + try + for I := 0 to ImportList.Count - 1 do + begin + Name := ImportList[I]; + if StrSame(ExtractFileExt(Name), BinaryExtensionPackage) then + begin + if Descriptions then + List.Add(Name + '=' + GetPackageDescription(PChar(Name))) + else + List.Add(Name); + end; + end; + finally + ImportList.Free; + List.EndUpdate; + end; +end; + +function TJclPeBorImage.FreeLibHandle: Boolean; +begin + if FLibHandle <> 0 then + begin + Result := FreeLibrary(FLibHandle); + FLibHandle := 0; + end + else + Result := True; +end; + +function TJclPeBorImage.GetFormCount: Integer; +begin + if FForms.Count = 0 then + CreateFormsList; + Result := FForms.Count; +end; + +function TJclPeBorImage.GetFormFromName(const FormClassName: string): TJclPeBorForm; +var + I: Integer; +begin + Result := nil; + for I := 0 to FormCount - 1 do + if StrSame(FormClassName, Forms[I].FormClassName) then + begin + Result := Forms[I]; + Break; + end; +end; + +function TJclPeBorImage.GetForms(Index: Integer): TJclPeBorForm; +begin + Result := TJclPeBorForm(FForms[Index]); +end; + +function TJclPeBorImage.GetLibHandle: THandle; +begin + if StatusOK and (FLibHandle = 0) then + begin + FLibHandle := LoadLibraryEx(PChar(FileName), 0, LOAD_LIBRARY_AS_DATAFILE); + if FLibHandle = 0 then + RaiseLastOSError; + end; + Result := FLibHandle; +end; + +function TJclPeBorImage.GetPackageCompilerVersion: Integer; +var + I: Integer; + ImportName: string; + + function CheckName: Boolean; + begin + Result := False; + ImportName := AnsiUpperCase(ImportName); + if StrSame(ExtractFileExt(ImportName), BinaryExtensionPackage) then + begin + ImportName := PathExtractFileNameNoExt(ImportName); + if (Length(ImportName) = 5) and + CharIsDigit(ImportName[4]) and CharIsDigit(ImportName[5]) and + ((Pos('RTL', ImportName) = 1) or (Pos('VCL', ImportName) = 1)) then + begin + FPackageCompilerVersion := StrToIntDef(Copy(ImportName, 4, 2), 0); + Result := True; + end; + end; + end; + +begin + if (FPackageCompilerVersion = 0) and IsPackage then + begin + with ImportList do + for I := 0 to UniqueLibItemCount - 1 do + begin + ImportName := UniqueLibNames[I]; + if CheckName then + Break; + end; + if FPackageCompilerVersion = 0 then + begin + ImportName := ExtractFileName(FileName); + CheckName; + end; + end; + Result := FPackageCompilerVersion; +end; + +function TJclPeBorImage.GetPackageInfo: TJclPePackageInfo; +begin + if StatusOK and (FPackageInfo = nil) then + begin + GetLibHandle; + FPackageInfo := TJclPePackageInfo.Create(FLibHandle); + FPackageInfo.Sorted := FPackageInfoSorted; + FreeLibHandle; + end; + Result := FPackageInfo; +end; +{$ENDIF BORLAND} + +//=== { TJclPeNameSearch } =================================================== + +constructor TJclPeNameSearch.Create(const FunctionName, Path: string; Options: TJclPeNameSearchOptions); +begin + inherited Create(True); + FFunctionName := FunctionName; + FOptions := Options; + FPath := Path; + FreeOnTerminate := True; +end; + +function TJclPeNameSearch.CompareName(const FunctionName, ComparedName: string): Boolean; +begin + Result := PeSmartFunctionNameSame(ComparedName, FunctionName, [scIgnoreCase]); +end; + +procedure TJclPeNameSearch.DoFound; +begin + if Assigned(FOnFound) then + FOnFound(Self, F_FileName, F_FunctionName, F_Option); +end; + +procedure TJclPeNameSearch.DoProcessFile; +begin + if Assigned(FOnProcessFile) then + FOnProcessFile(Self, FPeImage, F_Process); +end; + +procedure TJclPeNameSearch.Execute; +var + PathList: TStringList; + I: Integer; + + function CompareNameAndNotify(const S: string): Boolean; + begin + Result := CompareName(S, FFunctionName); + if Result and not Terminated then + begin + F_FunctionName := S; + Synchronize(DoFound); + end; + end; + + procedure ProcessDirectorySearch(const DirName: string); + var + Se: TSearchRec; + SearchResult: Integer; + ImportList: TJclPeImportList; + ExportList: TJclPeExportFuncList; + I: Integer; + begin + SearchResult := FindFirst(DirName, faArchive + faReadOnly, Se); + try + while not Terminated and (SearchResult = 0) do + begin + F_FileName := PathAddSeparator(ExtractFilePath(DirName)) + Se.Name; + F_Process := True; + FPeImage.FileName := F_FileName; + if Assigned(FOnProcessFile) then + Synchronize(DoProcessFile); + if F_Process and FPeImage.StatusOK then + begin + if seExports in FOptions then + begin + ExportList := FPeImage.ExportList; + F_Option := seExports; + for I := 0 to ExportList.Count - 1 do + begin + if Terminated then + Break; + CompareNameAndNotify(ExportList[I].Name); + end; + end; + if FOptions * [seImports, seDelayImports, seBoundImports] <> [] then + begin + ImportList := FPeImage.ImportList; + FPeImage.TryGetNamesForOrdinalImports; + for I := 0 to ImportList.AllItemCount - 1 do + with ImportList.AllItems[I] do + begin + if Terminated then + Break; + case ImportLib.ImportKind of + ikImport: + if seImports in FOptions then + begin + F_Option := seImports; + CompareNameAndNotify(Name); + end; + ikDelayImport: + if seDelayImports in FOptions then + begin + F_Option := seDelayImports; + CompareNameAndNotify(Name); + end; + ikBoundImport: + if seDelayImports in FOptions then + begin + F_Option := seBoundImports; + CompareNameAndNotify(Name); + end; + end; + end; + end; + end; + SearchResult := FindNext(Se); + end; + finally + FindClose(Se); + end; + end; + +begin + FPeImage := TJclPeImage.Create(True); + PathList := TStringList.Create; + try + PathList.Sorted := True; + PathList.Duplicates := dupIgnore; + StrToStrings(FPath, ';', PathList); + for I := 0 to PathList.Count - 1 do + ProcessDirectorySearch(PathAddSeparator(Trim(PathList[I])) + '*.*'); + finally + PathList.Free; + FPeImage.Free; + end; +end; + +procedure TJclPeNameSearch.Start; +begin + {$IFDEF RTL210_UP} + Suspended := False; + {$ELSE ~RTL210_UP} + Resume; + {$ENDIF ~RTL210_UP} +end; + +//=== PE Image miscellaneous functions ======================================= + +function IsValidPeFile(const FileName: TFileName): Boolean; +var + NtHeaders: TImageNtHeaders32; +begin + Result := PeGetNtHeaders32(FileName, NtHeaders); +end; + +function InternalGetNtHeaders32(const FileName: TFileName; out NtHeaders): Boolean; +var + FileHandle: THandle; + Mapping: TJclFileMapping; + View: TJclFileMappingView; + HeadersPtr: PImageNtHeaders32; +begin + Result := False; + ResetMemory(NtHeaders, SizeOf(TImageNtHeaders32)); + FileHandle := FileOpen(FileName, fmOpenRead or fmShareDenyWrite); + if FileHandle = INVALID_HANDLE_VALUE then + Exit; + try + if GetSizeOfFile(FileHandle) >= SizeOf(TImageDosHeader) then + begin + Mapping := TJclFileMapping.Create(FileHandle, '', PAGE_READONLY, 0, nil); + try + View := TJclFileMappingView.Create(Mapping, FILE_MAP_READ, 0, 0); + HeadersPtr := PeMapImgNtHeaders32(View.Memory); + if HeadersPtr <> nil then + begin + Result := True; + TImageNtHeaders32(NtHeaders) := HeadersPtr^; + end; + finally + Mapping.Free; + end; + end; + finally + FileClose(FileHandle); + end; +end; + +function PeGetNtHeaders32(const FileName: TFileName; out NtHeaders: TImageNtHeaders32): Boolean; +begin + Result := InternalGetNtHeaders32(FileName, NtHeaders); +end; + +function PeGetNtHeaders64(const FileName: TFileName; out NtHeaders: TImageNtHeaders64): Boolean; +var + FileHandle: THandle; + Mapping: TJclFileMapping; + View: TJclFileMappingView; + HeadersPtr: PImageNtHeaders64; +begin + Result := False; + ResetMemory(NtHeaders, SizeOf(NtHeaders)); + FileHandle := FileOpen(FileName, fmOpenRead or fmShareDenyWrite); + if FileHandle = INVALID_HANDLE_VALUE then + Exit; + try + if GetSizeOfFile(FileHandle) >= SizeOf(TImageDosHeader) then + begin + Mapping := TJclFileMapping.Create(FileHandle, '', PAGE_READONLY, 0, nil); + try + View := TJclFileMappingView.Create(Mapping, FILE_MAP_READ, 0, 0); + HeadersPtr := PeMapImgNtHeaders64(View.Memory); + if HeadersPtr <> nil then + begin + Result := True; + NtHeaders := HeadersPtr^; + end; + finally + Mapping.Free; + end; + end; + finally + FileClose(FileHandle); + end; +end; + +function PeCreateNameHintTable(const FileName: TFileName): Boolean; +var + PeImage, ExportsImage: TJclPeImage; + I: Integer; + ImportItem: TJclPeImportLibItem; + Thunk32: PImageThunkData32; + Thunk64: PImageThunkData64; + OrdinalName: PImageImportByName; + ExportItem: TJclPeExportFuncItem; + Cache: TJclPeImagesCache; + ImageBase32: TJclAddr32; + ImageBase64: TJclAddr64; + UTF8Name: TUTF8String; + ExportName: string; +begin + Cache := TJclPeImagesCache.Create; + try + PeImage := TJclPeImage.Create(False); + try + PeImage.ReadOnlyAccess := False; + PeImage.FileName := FileName; + Result := PeImage.ImportList.Count > 0; + for I := 0 to PeImage.ImportList.Count - 1 do + begin + ImportItem := PeImage.ImportList[I]; + if ImportItem.ImportKind = ikBoundImport then + Continue; + ExportsImage := Cache[ImportItem.FileName]; + ExportsImage.ExportList.PrepareForFastNameSearch; + case PEImage.Target of + taWin32: + begin + Thunk32 := ImportItem.ThunkData32; + ImageBase32 := PeImage.OptionalHeader32.ImageBase; + while Thunk32^.Function_ <> 0 do + begin + if Thunk32^.Ordinal and IMAGE_ORDINAL_FLAG32 = 0 then + begin + case ImportItem.ImportKind of + ikImport: + OrdinalName := PImageImportByName(PeImage.RvaToVa(Thunk32^.AddressOfData)); + ikDelayImport: + OrdinalName := PImageImportByName(PeImage.RvaToVa(Thunk32^.AddressOfData - ImageBase32)); + else + OrdinalName := nil; + end; + UTF8Name := PAnsiChar(@OrdinalName.Name); + if not TryUTF8ToString(UTF8Name, ExportName) then + ExportName := string(UTF8Name); + ExportItem := ExportsImage.ExportList.ItemFromName[ExportName]; + if ExportItem <> nil then + OrdinalName.Hint := ExportItem.Hint + else + OrdinalName.Hint := 0; + end; + Inc(Thunk32); + end; + end; + taWin64: + begin + Thunk64 := ImportItem.ThunkData64; + ImageBase64 := PeImage.OptionalHeader64.ImageBase; + while Thunk64^.Function_ <> 0 do + begin + if Thunk64^.Ordinal and IMAGE_ORDINAL_FLAG64 = 0 then + begin + case ImportItem.ImportKind of + ikImport: + OrdinalName := PImageImportByName(PeImage.RvaToVa(Thunk64^.AddressOfData)); + ikDelayImport: + OrdinalName := PImageImportByName(PeImage.RvaToVa(Thunk64^.AddressOfData - ImageBase64)); + else + OrdinalName := nil; + end; + UTF8Name := PAnsiChar(@OrdinalName.Name); + if not TryUTF8ToString(UTF8Name, ExportName) then + ExportName := string(UTF8Name); + ExportItem := ExportsImage.ExportList.ItemFromName[ExportName]; + if ExportItem <> nil then + OrdinalName.Hint := ExportItem.Hint + else + OrdinalName.Hint := 0; + end; + Inc(Thunk64); + end; + end; + end; + end; + finally + PeImage.Free; + end; + finally + Cache.Free; + end; +end; + +function PeRebaseImage32(const ImageName: TFileName; NewBase: TJclAddr32; + TimeStamp, MaxNewSize: DWORD): TJclRebaseImageInfo32; + + function CalculateBaseAddress: TJclAddr32; + var + FirstChar: Char; + ModuleName: string; + begin + ModuleName := ExtractFileName(ImageName); + if Length(ModuleName) > 0 then + FirstChar := UpCase(ModuleName[1]) + else + FirstChar := NativeNull; + if not CharIsUpper(FirstChar) then + FirstChar := 'A'; + Result := $60000000 + (((Ord(FirstChar) - Ord('A')) div 3) * $1000000); + end; + +{$IFDEF CPU64} +{$IFNDEF DELPHI64_TEMPORARY} +var + NewIB, OldIB: QWord; +{$ENDIF CPU64} +{$ENDIF ~DELPHI64_TEMPORARY} +begin + if NewBase = 0 then + NewBase := CalculateBaseAddress; + with Result do + begin + NewImageBase := NewBase; + // OF: possible loss of data + {$IFDEF CPU32} + Win32Check(ReBaseImage(PAnsiChar(AnsiString(ImageName)), nil, True, False, False, MaxNewSize, + OldImageSize, OldImageBase, NewImageSize, NewImageBase, TimeStamp)); + {$ENDIF CPU32} + {$IFDEF CPU64} + {$IFDEF DELPHI64_TEMPORARY} + System.Error(rePlatformNotImplemented); + {$ELSE ~DELPHI64_TEMPORARY} + NewIB := NewImageBase; + OldIB := OldImageBase; + Win32Check(ReBaseImage(PAnsiChar(AnsiString(ImageName)), nil, True, False, False, MaxNewSize, + OldImageSize, OldIB, NewImageSize, NewIB, TimeStamp)); + NewImageBase := NewIB; + OldImageBase := OldIB; + {$ENDIF ~DELPHI64_TEMPORARY} + {$ENDIF CPU64} + end; +end; + +function PeRebaseImage64(const ImageName: TFileName; NewBase: TJclAddr64; + TimeStamp, MaxNewSize: DWORD): TJclRebaseImageInfo64; + + function CalculateBaseAddress: TJclAddr64; + var + FirstChar: Char; + ModuleName: string; + begin + ModuleName := ExtractFileName(ImageName); + if Length(ModuleName) > 0 then + FirstChar := UpCase(ModuleName[1]) + else + FirstChar := NativeNull; + if not CharIsUpper(FirstChar) then + FirstChar := 'A'; + Result := $60000000 + (((Ord(FirstChar) - Ord('A')) div 3) * $1000000); + Result := Result shl 32; + end; + +begin + if NewBase = 0 then + NewBase := CalculateBaseAddress; + with Result do + begin + NewImageBase := NewBase; + // OF: possible loss of data + Win32Check(ReBaseImage64(PAnsiChar(AnsiString(ImageName)), nil, True, False, False, MaxNewSize, + OldImageSize, OldImageBase, NewImageSize, NewImageBase, TimeStamp)); + end; +end; + +function PeUpdateLinkerTimeStamp(const FileName: TFileName; const Time: TDateTime): Boolean; +var + Mapping: TJclFileMapping; + View: TJclFileMappingView; + Headers: PImageNtHeaders32; // works with 64-bit binaries too + // only the optional field differs +begin + Mapping := TJclFileMapping.Create(FileName, fmOpenReadWrite, '', PAGE_READWRITE, 0, nil); + try + View := TJclFileMappingView.Create(Mapping, FILE_MAP_WRITE, 0, 0); + Headers := PeMapImgNtHeaders32(View.Memory); + Result := (Headers <> nil); + if Result then + Headers^.FileHeader.TimeDateStamp := TJclPeImage.DateTimeToStamp(Time); + finally + Mapping.Free; + end; +end; + +function PeReadLinkerTimeStamp(const FileName: TFileName): TDateTime; +var + Mapping: TJclFileMappingStream; + Headers: PImageNtHeaders32; // works with 64-bit binaries too + // only the optional field differs +begin + Mapping := TJclFileMappingStream.Create(FileName, fmOpenRead or fmShareDenyWrite); + try + Headers := PeMapImgNtHeaders32(Mapping.Memory); + if Headers <> nil then + Result := TJclPeImage.StampToDateTime(Headers^.FileHeader.TimeDateStamp) + else + Result := -1; + finally + Mapping.Free; + end; +end; + +{ TODO -cHelp : Author: Uwe Schuster(just a generic version of JclDebug.InsertDebugDataIntoExecutableFile) } +function PeInsertSection(const FileName: TFileName; SectionStream: TStream; SectionName: string): Boolean; + procedure RoundUpToAlignment(var Value: DWORD; Alignment: DWORD); + begin + if (Value mod Alignment) <> 0 then + Value := ((Value div Alignment) + 1) * Alignment; + end; + function PeInsertSection32(ImageStream: TMemoryStream): Boolean; + var + NtHeaders: PImageNtHeaders32; + Sections, LastSection, NewSection: PImageSectionHeader; + VirtualAlignedSize: DWORD; + I, X, NeedFill: Integer; + SectionDataSize: Integer; + UTF8Name: TUTF8String; + begin + Result := True; + try + SectionDataSize := SectionStream.Size; + NtHeaders := PeMapImgNtHeaders32(ImageStream.Memory); + Assert(NtHeaders <> nil); + Sections := PeMapImgSections32(NtHeaders); + Assert(Sections <> nil); + // Check whether there is not a section with the name already. If so, return True (#0000069) + if PeMapImgFindSection32(NtHeaders, SectionName) <> nil then + begin + Result := True; + Exit; + end; + + LastSection := Sections; + Inc(LastSection, NtHeaders^.FileHeader.NumberOfSections - 1); + NewSection := LastSection; + Inc(NewSection); + + // Increase the number of sections + Inc(NtHeaders^.FileHeader.NumberOfSections); + ResetMemory(NewSection^, SizeOf(TImageSectionHeader)); + // JCLDEBUG Virtual Address + NewSection^.VirtualAddress := LastSection^.VirtualAddress + LastSection^.Misc.VirtualSize; + RoundUpToAlignment(NewSection^.VirtualAddress, NtHeaders^.OptionalHeader.SectionAlignment); + // JCLDEBUG Physical Offset + NewSection^.PointerToRawData := LastSection^.PointerToRawData + LastSection^.SizeOfRawData; + RoundUpToAlignment(NewSection^.PointerToRawData, NtHeaders^.OptionalHeader.FileAlignment); + // JCLDEBUG Section name + if not TryStringToUTF8(SectionName, UTF8Name) then + UTF8Name := TUTF8String(SectionName); + StrPLCopyA(PAnsiChar(@NewSection^.Name), UTF8Name, IMAGE_SIZEOF_SHORT_NAME); + // JCLDEBUG Characteristics flags + NewSection^.Characteristics := IMAGE_SCN_MEM_READ or IMAGE_SCN_CNT_INITIALIZED_DATA; + + // Size of virtual data area + NewSection^.Misc.VirtualSize := SectionDataSize; + VirtualAlignedSize := SectionDataSize; + RoundUpToAlignment(VirtualAlignedSize, NtHeaders^.OptionalHeader.SectionAlignment); + // Update Size of Image + Inc(NtHeaders^.OptionalHeader.SizeOfImage, VirtualAlignedSize); + // Raw data size + NewSection^.SizeOfRawData := SectionDataSize; + RoundUpToAlignment(NewSection^.SizeOfRawData, NtHeaders^.OptionalHeader.FileAlignment); + // Update Initialized data size + Inc(NtHeaders^.OptionalHeader.SizeOfInitializedData, NewSection^.SizeOfRawData); + + // Fill data to alignment + NeedFill := INT_PTR(NewSection^.SizeOfRawData) - SectionDataSize; + + // Note: Delphi linker seems to generate incorrect (unaligned) size of + // the executable when adding TD32 debug data so the position could be + // behind the size of the file then. + ImageStream.Seek(NewSection^.PointerToRawData, soBeginning); + ImageStream.CopyFrom(SectionStream, 0); + X := 0; + for I := 1 to NeedFill do + ImageStream.WriteBuffer(X, 1); + except + Result := False; + end; + end; + function PeInsertSection64(ImageStream: TMemoryStream): Boolean; + var + NtHeaders: PImageNtHeaders64; + Sections, LastSection, NewSection: PImageSectionHeader; + VirtualAlignedSize: DWORD; + I, X, NeedFill: Integer; + SectionDataSize: Integer; + UTF8Name: TUTF8String; + begin + Result := True; + try + SectionDataSize := SectionStream.Size; + NtHeaders := PeMapImgNtHeaders64(ImageStream.Memory); + Assert(NtHeaders <> nil); + Sections := PeMapImgSections64(NtHeaders); + Assert(Sections <> nil); + // Check whether there is not a section with the name already. If so, return True (#0000069) + if PeMapImgFindSection64(NtHeaders, SectionName) <> nil then + begin + Result := True; + Exit; + end; + + LastSection := Sections; + Inc(LastSection, NtHeaders^.FileHeader.NumberOfSections - 1); + NewSection := LastSection; + Inc(NewSection); + + // Increase the number of sections + Inc(NtHeaders^.FileHeader.NumberOfSections); + ResetMemory(NewSection^, SizeOf(TImageSectionHeader)); + // JCLDEBUG Virtual Address + NewSection^.VirtualAddress := LastSection^.VirtualAddress + LastSection^.Misc.VirtualSize; + RoundUpToAlignment(NewSection^.VirtualAddress, NtHeaders^.OptionalHeader.SectionAlignment); + // JCLDEBUG Physical Offset + NewSection^.PointerToRawData := LastSection^.PointerToRawData + LastSection^.SizeOfRawData; + RoundUpToAlignment(NewSection^.PointerToRawData, NtHeaders^.OptionalHeader.FileAlignment); + // JCLDEBUG Section name + if not TryStringToUTF8(SectionName, UTF8Name) then + UTF8Name := TUTF8String(SectionName); + StrPLCopyA(PAnsiChar(@NewSection^.Name), UTF8Name, IMAGE_SIZEOF_SHORT_NAME); + // JCLDEBUG Characteristics flags + NewSection^.Characteristics := IMAGE_SCN_MEM_READ or IMAGE_SCN_CNT_INITIALIZED_DATA; + + // Size of virtual data area + NewSection^.Misc.VirtualSize := SectionDataSize; + VirtualAlignedSize := SectionDataSize; + RoundUpToAlignment(VirtualAlignedSize, NtHeaders^.OptionalHeader.SectionAlignment); + // Update Size of Image + Inc(NtHeaders^.OptionalHeader.SizeOfImage, VirtualAlignedSize); + // Raw data size + NewSection^.SizeOfRawData := SectionDataSize; + RoundUpToAlignment(NewSection^.SizeOfRawData, NtHeaders^.OptionalHeader.FileAlignment); + // Update Initialized data size + Inc(NtHeaders^.OptionalHeader.SizeOfInitializedData, NewSection^.SizeOfRawData); + + // Fill data to alignment + NeedFill := INT_PTR(NewSection^.SizeOfRawData) - SectionDataSize; + + // Note: Delphi linker seems to generate incorrect (unaligned) size of + // the executable when adding TD32 debug data so the position could be + // behind the size of the file then. + ImageStream.Seek(NewSection^.PointerToRawData, soBeginning); + ImageStream.CopyFrom(SectionStream, 0); + X := 0; + for I := 1 to NeedFill do + ImageStream.WriteBuffer(X, 1); + except + Result := False; + end; + end; + +var + ImageStream: TMemoryStream; +begin + Result := Assigned(SectionStream) and (SectionName <> ''); + if not Result then + Exit; + ImageStream := TMemoryStream.Create; + try + ImageStream.LoadFromFile(FileName); + case PeMapImgTarget(ImageStream.Memory) of + taWin32: + Result := PeInsertSection32(ImageStream); + taWin64: + Result := PeInsertSection64(ImageStream); + //taUnknown: + else + Result := False; + end; + + if Result then + ImageStream.SaveToFile(FileName); + finally + ImageStream.Free; + end; +end; + +function PeVerifyCheckSum(const FileName: TFileName): Boolean; +begin + with CreatePeImage(FileName) do + try + Result := VerifyCheckSum; + finally + Free; + end; +end; + +function PeClearCheckSum(const FileName: TFileName): Boolean; + function PeClearCheckSum32(ModuleAddress: Pointer): Boolean; + var + Headers: PImageNtHeaders32; + begin + Headers := PeMapImgNtHeaders32(ModuleAddress); + Result := (Headers <> nil); + if Result then + Headers^.OptionalHeader.CheckSum := 0; + end; + function PeClearCheckSum64(ModuleAddress: Pointer): Boolean; + var + Headers: PImageNtHeaders64; + begin + Headers := PeMapImgNtHeaders64(ModuleAddress); + Result := (Headers <> nil); + if Result then + Headers^.OptionalHeader.CheckSum := 0; + end; +var + Mapping: TJclFileMapping; + View: TJclFileMappingView; +begin + Mapping := TJclFileMapping.Create(FileName, fmOpenReadWrite, '', PAGE_READWRITE, 0, nil); + try + View := TJclFileMappingView.Create(Mapping, FILE_MAP_WRITE, 0, 0); + case PeMapImgTarget(View.Memory) of + taWin32: + Result := PeClearCheckSum32(View.Memory); + taWin64: + Result := PeClearCheckSum64(View.Memory); + //taUnknown: + else + Result := False; + end; + finally + Mapping.Free; + end; +end; + +function PeUpdateCheckSum(const FileName: TFileName): Boolean; +var + LI: TLoadedImage; +begin + LI.ModuleName := nil; + // OF: possible loss of data + Result := MapAndLoad(PAnsiChar(AnsiString(FileName)), nil, LI, True, False); + if Result then + Result := UnMapAndLoad(LI); +end; + +// Various simple PE Image searching and listing routines + +function PeDoesExportFunction(const FileName: TFileName; const FunctionName: string; + Options: TJclSmartCompOptions): Boolean; +begin + with CreatePeImage(FileName) do + try + Result := StatusOK and Assigned(ExportList.SmartFindName(FunctionName, Options)); + finally + Free; + end; +end; + +function PeIsExportFunctionForwardedEx(const FileName: TFileName; const FunctionName: string; + out ForwardedName: string; Options: TJclSmartCompOptions): Boolean; +var + ExportItem: TJclPeExportFuncItem; +begin + with CreatePeImage(FileName) do + try + Result := StatusOK; + if Result then + begin + ExportItem := ExportList.SmartFindName(FunctionName, Options); + if ExportItem <> nil then + begin + Result := ExportItem.IsForwarded; + ForwardedName := ExportItem.ForwardedName; + end + else + begin + Result := False; + ForwardedName := ''; + end; + end; + finally + Free; + end; +end; + +function PeIsExportFunctionForwarded(const FileName: TFileName; const FunctionName: string; + Options: TJclSmartCompOptions): Boolean; +var + Dummy: string; +begin + Result := PeIsExportFunctionForwardedEx(FileName, FunctionName, Dummy, Options); +end; + +function PeDoesImportFunction(const FileName: TFileName; const FunctionName: string; + const LibraryName: string; Options: TJclSmartCompOptions): Boolean; +begin + with CreatePeImage(FileName) do + try + Result := StatusOK; + if Result then + with ImportList do + begin + TryGetNamesForOrdinalImports; + Result := SmartFindName(FunctionName, LibraryName, Options) <> nil; + end; + finally + Free; + end; +end; + +function PeDoesImportLibrary(const FileName: TFileName; const LibraryName: string; + Recursive: Boolean): Boolean; +var + SL: TStringList; +begin + with CreatePeImage(FileName) do + try + Result := StatusOK; + if Result then + begin + SL := InternalImportedLibraries(FileName, Recursive, False, nil); + try + Result := SL.IndexOf(LibraryName) > -1; + finally + SL.Free; + end; + end; + finally + Free; + end; +end; + +function PeImportedLibraries(const FileName: TFileName; const LibrariesList: TStrings; + Recursive, FullPathName: Boolean): Boolean; +var + SL: TStringList; +begin + with CreatePeImage(FileName) do + try + Result := StatusOK; + if Result then + begin + SL := InternalImportedLibraries(FileName, Recursive, FullPathName, nil); + try + LibrariesList.Assign(SL); + finally + SL.Free; + end; + end; + finally + Free; + end; +end; + +function PeImportedFunctions(const FileName: TFileName; const FunctionsList: TStrings; + const LibraryName: string; IncludeLibNames: Boolean): Boolean; +var + I: Integer; +begin + with CreatePeImage(FileName) do + try + Result := StatusOK; + if Result then + with ImportList do + begin + TryGetNamesForOrdinalImports; + FunctionsList.BeginUpdate; + try + for I := 0 to AllItemCount - 1 do + with AllItems[I] do + if ((Length(LibraryName) = 0) or StrSame(ImportLib.Name, LibraryName)) and + (Name <> '') then + begin + if IncludeLibNames then + FunctionsList.Add(ImportLib.Name + '=' + Name) + else + FunctionsList.Add(Name); + end; + finally + FunctionsList.EndUpdate; + end; + end; + finally + Free; + end; +end; + +function PeExportedFunctions(const FileName: TFileName; const FunctionsList: TStrings): Boolean; +var + I: Integer; +begin + with CreatePeImage(FileName) do + try + Result := StatusOK; + if Result then + begin + FunctionsList.BeginUpdate; + try + with ExportList do + for I := 0 to Count - 1 do + with Items[I] do + if not IsExportedVariable then + FunctionsList.Add(Name); + finally + FunctionsList.EndUpdate; + end; + end; + finally + Free; + end; +end; + +function PeExportedNames(const FileName: TFileName; const FunctionsList: TStrings): Boolean; +var + I: Integer; +begin + with CreatePeImage(FileName) do + try + Result := StatusOK; + if Result then + begin + FunctionsList.BeginUpdate; + try + with ExportList do + for I := 0 to Count - 1 do + FunctionsList.Add(Items[I].Name); + finally + FunctionsList.EndUpdate; + end; + end; + finally + Free; + end; +end; + +function PeExportedVariables(const FileName: TFileName; const FunctionsList: TStrings): Boolean; +var + I: Integer; +begin + with CreatePeImage(FileName) do + try + Result := StatusOK; + if Result then + begin + FunctionsList.BeginUpdate; + try + with ExportList do + for I := 0 to Count - 1 do + with Items[I] do + if IsExportedVariable then + FunctionsList.AddObject(Name, Pointer(Address)); + finally + FunctionsList.EndUpdate; + end; + end; + finally + Free; + end; +end; + +function PeResourceKindNames(const FileName: TFileName; ResourceType: TJclPeResourceKind; + const NamesList: TStrings): Boolean; +begin + with CreatePeImage(FileName) do + try + Result := StatusOK and ResourceList.ListResourceNames(ResourceType, NamesList); + finally + Free; + end; +end; + +{$IFDEF BORLAND} + +function PeBorFormNames(const FileName: TFileName; const NamesList: TStrings): Boolean; +var + I: Integer; + BorImage: TJclPeBorImage; + BorForm: TJclPeBorForm; +begin + BorImage := TJclPeBorImage.Create(True); + try + BorImage.FileName := FileName; + Result := BorImage.IsBorlandImage; + if Result then + begin + NamesList.BeginUpdate; + try + for I := 0 to BorImage.FormCount - 1 do + begin + BorForm := BorImage.Forms[I]; + NamesList.AddObject(BorForm.DisplayName, Pointer(BorForm.ResItem.RawEntryDataSize)); + end; + finally + NamesList.EndUpdate; + end; + end; + finally + BorImage.Free; + end; +end; + +function PeBorDependedPackages(const FileName: TFileName; PackagesList: TStrings; + FullPathName, Descriptions: Boolean): Boolean; +var + BorImage: TJclPeBorImage; +begin + BorImage := TJclPeBorImage.Create(True); + try + BorImage.FileName := FileName; + Result := BorImage.DependedPackages(PackagesList, FullPathName, Descriptions); + finally + BorImage.Free; + end; +end; + +{$ENDIF BORLAND} + +// Missing imports checking routines + +function PeFindMissingImports(const FileName: TFileName; MissingImportsList: TStrings): Boolean; +var + Cache: TJclPeImagesCache; + FileImage, LibImage: TJclPeImage; + L, I: Integer; + LibItem: TJclPeImportLibItem; + List: TStringList; +begin + Result := False; + List := nil; + Cache := TJclPeImagesCache.Create; + try + List := TStringList.Create; + List.Duplicates := dupIgnore; + List.Sorted := True; + FileImage := Cache[FileName]; + if FileImage.StatusOK then + begin + for L := 0 to FileImage.ImportList.Count - 1 do + begin + LibItem := FileImage.ImportList[L]; + LibImage := Cache[LibItem.FileName]; + if LibImage.StatusOK then + begin + LibImage.ExportList.PrepareForFastNameSearch; + for I := 0 to LibItem.Count - 1 do + if LibImage.ExportList.ItemFromName[LibItem[I].Name] = nil then + List.Add(LibItem.Name + '=' + LibItem[I].Name); + end + else + List.Add(LibItem.Name + '='); + end; + MissingImportsList.Assign(List); + Result := List.Count > 0; + end; + finally + List.Free; + Cache.Free; + end; +end; + +function PeFindMissingImports(RequiredImportsList, MissingImportsList: TStrings): Boolean; +var + Cache: TJclPeImagesCache; + LibImage: TJclPeImage; + I, SepPos: Integer; + List: TStringList; + S, LibName, ImportName: string; +begin + List := nil; + Cache := TJclPeImagesCache.Create; + try + List := TStringList.Create; + List.Duplicates := dupIgnore; + List.Sorted := True; + for I := 0 to RequiredImportsList.Count - 1 do + begin + S := RequiredImportsList[I]; + SepPos := Pos('=', S); + if SepPos = 0 then + Continue; + LibName := StrLeft(S, SepPos - 1); + LibImage := Cache[LibName]; + if LibImage.StatusOK then + begin + LibImage.ExportList.PrepareForFastNameSearch; + ImportName := StrRestOf(S, SepPos + 1); + if LibImage.ExportList.ItemFromName[ImportName] = nil then + List.Add(LibName + '=' + ImportName); + end + else + List.Add(LibName + '='); + end; + MissingImportsList.Assign(List); + Result := List.Count > 0; + finally + List.Free; + Cache.Free; + end; +end; + +function PeCreateRequiredImportList(const FileName: TFileName; RequiredImportsList: TStrings): Boolean; +begin + Result := PeImportedFunctions(FileName, RequiredImportsList, '', True); +end; + +// Mapped or loaded image related functions + +function PeMapImgNtHeaders32(const BaseAddress: Pointer): PImageNtHeaders32; +begin + Result := nil; + if IsBadReadPtr(BaseAddress, SizeOf(TImageDosHeader)) then + Exit; + if (PImageDosHeader(BaseAddress)^.e_magic <> IMAGE_DOS_SIGNATURE) or + (PImageDosHeader(BaseAddress)^._lfanew = 0) then + Exit; + Result := PImageNtHeaders32(TJclAddr(BaseAddress) + DWORD(PImageDosHeader(BaseAddress)^._lfanew)); + if IsBadReadPtr(Result, SizeOf(TImageNtHeaders32)) or + (Result^.Signature <> IMAGE_NT_SIGNATURE) then + Result := nil +end; + +function PeMapImgNtHeaders32(Stream: TStream; const BasePosition: Int64; out NtHeaders32: TImageNtHeaders32): Int64; +var + ImageDosHeader: TImageDosHeader; +begin + ResetMemory(NtHeaders32, SizeOf(NtHeaders32)); + Result := -1; + + if (Stream.Seek(BasePosition, soBeginning) <> BasePosition) or + (Stream.Read(ImageDosHeader, SizeOf(ImageDosHeader)) <> SizeOf(ImageDosHeader)) then + raise EJclPeImageError.CreateRes(@SReadError); + + if (ImageDosHeader.e_magic <> IMAGE_DOS_SIGNATURE) or + (ImageDosHeader._lfanew = 0) then + Exit; + + Result := BasePosition + DWORD(ImageDosHeader._lfanew); + + if (Stream.Seek(Result, soBeginning) <> Result) or + (Stream.Read(NtHeaders32, SizeOf(NtHeaders32)) <> SizeOf(NtHeaders32)) then + raise EJclPeImageError.CreateRes(@SReadError); + + if NtHeaders32.Signature <> IMAGE_NT_SIGNATURE then + Result := -1; +end; + +function PeMapImgNtHeaders64(const BaseAddress: Pointer): PImageNtHeaders64; +begin + Result := nil; + if IsBadReadPtr(BaseAddress, SizeOf(TImageDosHeader)) then + Exit; + if (PImageDosHeader(BaseAddress)^.e_magic <> IMAGE_DOS_SIGNATURE) or + (PImageDosHeader(BaseAddress)^._lfanew = 0) then + Exit; + Result := PImageNtHeaders64(TJclAddr(BaseAddress) + DWORD(PImageDosHeader(BaseAddress)^._lfanew)); + if IsBadReadPtr(Result, SizeOf(TImageNtHeaders64)) or + (Result^.Signature <> IMAGE_NT_SIGNATURE) then + Result := nil +end; + +function PeMapImgNtHeaders64(Stream: TStream; const BasePosition: Int64; out NtHeaders64: TImageNtHeaders64): Int64; +var + ImageDosHeader: TImageDosHeader; +begin + ResetMemory(NtHeaders64, SizeOf(NtHeaders64)); + Result := -1; + + if (Stream.Seek(BasePosition, soBeginning) <> BasePosition) or + (Stream.Read(ImageDosHeader, SizeOf(ImageDosHeader)) <> SizeOf(ImageDosHeader)) then + raise EJclPeImageError.CreateRes(@SReadError); + + if (ImageDosHeader.e_magic <> IMAGE_DOS_SIGNATURE) or + (ImageDosHeader._lfanew = 0) then + Exit; + + Result := BasePosition + DWORD(ImageDosHeader._lfanew); + + if (Stream.Seek(Result, soBeginning) <> Result) or + (Stream.Read(NtHeaders64, SizeOf(NtHeaders64)) <> SizeOf(NtHeaders64)) then + raise EJclPeImageError.CreateRes(@SReadError); + + if NtHeaders64.Signature <> IMAGE_NT_SIGNATURE then + Result := -1; +end; + +function PeMapImgSize(const BaseAddress: Pointer): DWORD; +begin + case PeMapImgTarget(BaseAddress) of + taWin32: + Result := PeMapImgSize32(BaseAddress); + taWin64: + Result := PeMapImgSize64(BaseAddress); + //taUnknown: + else + Result := 0; + end; +end; + +function PeMapImgSize(Stream: TStream; const BasePosition: Int64): DWORD; +begin + case PeMapImgTarget(Stream, BasePosition) of + taWin32: + Result := PeMapImgSize32(Stream, BasePosition); + taWin64: + Result := PeMapImgSize64(Stream, BasePosition); + //taUnknown: + else + Result := 0; + end; +end; + +function PeMapImgSize32(const BaseAddress: Pointer): DWORD; +var + NtHeaders32: PImageNtHeaders32; +begin + Result := 0; + NtHeaders32 := PeMapImgNtHeaders32(BaseAddress); + if Assigned(NtHeaders32) then + Result := NtHeaders32^.OptionalHeader.SizeOfImage; +end; + +function PeMapImgSize32(Stream: TStream; const BasePosition: Int64): DWORD; +var + NtHeaders32: TImageNtHeaders32; +begin + Result := 0; + if PeMapImgNtHeaders32(Stream, BasePosition, NtHeaders32) <> -1 then + Result := NtHeaders32.OptionalHeader.SizeOfImage; +end; + +function PeMapImgSize64(const BaseAddress: Pointer): DWORD; +var + NtHeaders64: PImageNtHeaders64; +begin + Result := 0; + NtHeaders64 := PeMapImgNtHeaders64(BaseAddress); + if Assigned(NtHeaders64) then + Result := NtHeaders64^.OptionalHeader.SizeOfImage; +end; + +function PeMapImgSize64(Stream: TStream; const BasePosition: Int64): DWORD; +var + NtHeaders64: TImageNtHeaders64; +begin + Result := 0; + if PeMapImgNtHeaders64(Stream, BasePosition, NtHeaders64) <> -1 then + Result := NtHeaders64.OptionalHeader.SizeOfImage; +end; + +function PeMapImgLibraryName(const BaseAddress: Pointer): string; +begin + case PeMapImgTarget(BaseAddress) of + taWin32: + Result := PeMapImgLibraryName32(BaseAddress); + taWin64: + Result := PeMapImgLibraryName64(BaseAddress); + //taUnknown: + else + Result := ''; + end; +end; + +function PeMapImgLibraryName32(const BaseAddress: Pointer): string; +var + NtHeaders: PImageNtHeaders32; + DataDir: TImageDataDirectory; + ExportDir: PImageExportDirectory; + UTF8Name: TUTF8String; +begin + Result := ''; + NtHeaders := PeMapImgNtHeaders32(BaseAddress); + if NtHeaders = nil then + Exit; + DataDir := NtHeaders^.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT]; + if DataDir.Size = 0 then + Exit; + ExportDir := PImageExportDirectory(TJclAddr(BaseAddress) + DataDir.VirtualAddress); + if IsBadReadPtr(ExportDir, SizeOf(TImageExportDirectory)) or (ExportDir^.Name = 0) then + Exit; + UTF8Name := PAnsiChar(TJclAddr(BaseAddress) + ExportDir^.Name); + if not TryUTF8ToString(UTF8Name, Result) then + Result := string(UTF8Name); +end; + +function PeMapImgLibraryName64(const BaseAddress: Pointer): string; +var + NtHeaders: PImageNtHeaders64; + DataDir: TImageDataDirectory; + ExportDir: PImageExportDirectory; + UTF8Name: TUTF8String; +begin + Result := ''; + NtHeaders := PeMapImgNtHeaders64(BaseAddress); + if NtHeaders = nil then + Exit; + DataDir := NtHeaders^.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT]; + if DataDir.Size = 0 then + Exit; + ExportDir := PImageExportDirectory(TJclAddr(BaseAddress) + DataDir.VirtualAddress); + if IsBadReadPtr(ExportDir, SizeOf(TImageExportDirectory)) or (ExportDir^.Name = 0) then + Exit; + UTF8Name := PAnsiChar(TJclAddr(BaseAddress) + ExportDir^.Name); + if not TryUTF8ToString(UTF8Name, Result) then + Result := string(UTF8Name); +end; + +function PeMapImgTarget(const BaseAddress: Pointer): TJclPeTarget; +var + ImageNtHeaders: PImageNtHeaders32; +begin + Result := taUnknown; + + ImageNtHeaders := PeMapImgNtHeaders32(BaseAddress); + if Assigned(ImageNtHeaders) then + case ImageNtHeaders.FileHeader.Machine of + IMAGE_FILE_MACHINE_I386: + Result := taWin32; + IMAGE_FILE_MACHINE_AMD64: + Result := taWin64; + end; +end; + +function PeMapImgTarget(Stream: TStream; const BasePosition: Int64): TJclPeTarget; +var + ImageNtHeaders: TImageNtHeaders32; +begin + Result := taUnknown; + + if PeMapImgNtHeaders32(Stream, BasePosition, ImageNtHeaders) <> -1 then + begin + case ImageNtHeaders.FileHeader.Machine of + IMAGE_FILE_MACHINE_I386: + Result := taWin32; + IMAGE_FILE_MACHINE_AMD64: + Result := taWin64; + end; + end; +end; + +function PeMapImgSections32(NtHeaders: PImageNtHeaders32): PImageSectionHeader; +begin + if NtHeaders = nil then + Result := nil + else + Result := PImageSectionHeader(TJclAddr(@NtHeaders^.OptionalHeader) + + NtHeaders^.FileHeader.SizeOfOptionalHeader); +end; + +function PeMapImgSections32(Stream: TStream; const NtHeaders32Position: Int64; const NtHeaders32: TImageNtHeaders32; + out ImageSectionHeaders: TImageSectionHeaderArray): Int64; +var + SectionSize: Integer; +begin + if NtHeaders32Position = -1 then + begin + SetLength(ImageSectionHeaders, 0); + Result := -1; + end + else + begin + SetLength(ImageSectionHeaders, NtHeaders32.FileHeader.NumberOfSections); + Result := NtHeaders32Position + SizeOf(NtHeaders32.Signature) + SizeOf(NtHeaders32.FileHeader) + NtHeaders32.FileHeader.SizeOfOptionalHeader; + + SectionSize := SizeOf(ImageSectionHeaders[0]) * Length(ImageSectionHeaders); + if (Stream.Seek(Result, soBeginning) <> Result) or + (Stream.Read(ImageSectionHeaders[0], SectionSize) <> SectionSize) then + raise EJclPeImageError.CreateRes(@SReadError); + end; +end; + +function PeMapImgSections64(NtHeaders: PImageNtHeaders64): PImageSectionHeader; +begin + if NtHeaders = nil then + Result := nil + else + Result := PImageSectionHeader(TJclAddr(@NtHeaders^.OptionalHeader) + + NtHeaders^.FileHeader.SizeOfOptionalHeader); +end; + +function PeMapImgSections64(Stream: TStream; const NtHeaders64Position: Int64; const NtHeaders64: TImageNtHeaders64; + out ImageSectionHeaders: TImageSectionHeaderArray): Int64; +var + SectionSize: Integer; +begin + if NtHeaders64Position = -1 then + begin + SetLength(ImageSectionHeaders, 0); + Result := -1; + end + else + begin + SetLength(ImageSectionHeaders, NtHeaders64.FileHeader.NumberOfSections); + Result := NtHeaders64Position + SizeOf(NtHeaders64.Signature) + SizeOf(NtHeaders64.FileHeader) + NtHeaders64.FileHeader.SizeOfOptionalHeader; + + SectionSize := SizeOf(ImageSectionHeaders[0]) * Length(ImageSectionHeaders); + if (Stream.Seek(Result, soBeginning) <> Result) or + (Stream.Read(ImageSectionHeaders[0], SectionSize) <> SectionSize) then + raise EJclPeImageError.CreateRes(@SReadError); + end; +end; + +function PeMapImgFindSection32(NtHeaders: PImageNtHeaders32; + const SectionName: string): PImageSectionHeader; +var + Header: PImageSectionHeader; + I: Integer; + P: PAnsiChar; + UTF8Name: TUTF8String; +begin + Result := nil; + if NtHeaders <> nil then + begin + if not TryStringToUTF8(SectionName, UTF8Name) then + UTF8Name := TUTF8String(SectionName); + P := PAnsiChar(UTF8Name); + Header := PeMapImgSections32(NtHeaders); + for I := 1 to NtHeaders^.FileHeader.NumberOfSections do + if StrLCompA(PAnsiChar(@Header^.Name), P, IMAGE_SIZEOF_SHORT_NAME) = 0 then + begin + Result := Header; + Break; + end + else + Inc(Header); + end; +end; + +function PeMapImgFindSection64(NtHeaders: PImageNtHeaders64; + const SectionName: string): PImageSectionHeader; +var + Header: PImageSectionHeader; + I: Integer; + P: PAnsiChar; + UTF8Name: TUTF8String; +begin + Result := nil; + if NtHeaders <> nil then + begin + if not TryStringToUTF8(SectionName, UTF8Name) then + UTF8Name := TUTF8String(SectionName); + P := PAnsiChar(UTF8Name); + Header := PeMapImgSections64(NtHeaders); + for I := 1 to NtHeaders^.FileHeader.NumberOfSections do + if StrLCompA(PAnsiChar(@Header^.Name), P, IMAGE_SIZEOF_SHORT_NAME) = 0 then + begin + Result := Header; + Break; + end + else + Inc(Header); + end; +end; + +function PeMapImgFindSection(const ImageSectionHeaders: TImageSectionHeaderArray; + const SectionName: string): SizeInt; +var + P: PAnsiChar; + UTF8Name: TUTF8String; +begin + if Length(ImageSectionHeaders) > 0 then + begin + if not TryStringToUTF8(SectionName, UTF8Name) then + UTF8Name := TUTF8String(SectionName); + P := PAnsiChar(UTF8Name); + for Result := Low(ImageSectionHeaders) to High(ImageSectionHeaders) do + if StrLCompA(PAnsiChar(@ImageSectionHeaders[Result].Name), P, IMAGE_SIZEOF_SHORT_NAME) = 0 then + Exit; + end; + Result := -1; +end; + +function PeMapImgFindSectionFromModule(const BaseAddress: Pointer; + const SectionName: string): PImageSectionHeader; + function PeMapImgFindSectionFromModule32(const BaseAddress: Pointer; + const SectionName: string): PImageSectionHeader; + var + NtHeaders32: PImageNtHeaders32; + begin + Result := nil; + NtHeaders32 := PeMapImgNtHeaders32(BaseAddress); + if Assigned(NtHeaders32) then + Result := PeMapImgFindSection32(NtHeaders32, SectionName); + end; + function PeMapImgFindSectionFromModule64(const BaseAddress: Pointer; + const SectionName: string): PImageSectionHeader; + var + NtHeaders64: PImageNtHeaders64; + begin + Result := nil; + NtHeaders64 := PeMapImgNtHeaders64(BaseAddress); + if Assigned(NtHeaders64) then + Result := PeMapImgFindSection64(NtHeaders64, SectionName); + end; +begin + case PeMapImgTarget(BaseAddress) of + taWin32: + Result := PeMapImgFindSectionFromModule32(BaseAddress, SectionName); + taWin64: + Result := PeMapImgFindSectionFromModule64(BaseAddress, SectionName); + //taUnknown: + else + Result := nil; + end; +end; + +function PeMapImgExportedVariables(const Module: HMODULE; const VariablesList: TStrings): Boolean; +var + I: Integer; +begin + with TJclPeImage.Create(True) do + try + AttachLoadedModule(Module); + Result := StatusOK; + if Result then + begin + VariablesList.BeginUpdate; + try + with ExportList do + for I := 0 to Count - 1 do + with Items[I] do + if IsExportedVariable then + VariablesList.AddObject(Name, MappedAddress); + finally + VariablesList.EndUpdate; + end; + end; + finally + Free; + end; +end; + +function PeMapImgResolvePackageThunk(Address: Pointer): Pointer; +{$IFDEF BORLAND} +const + JmpInstructionCode = $25FF; +type + PPackageThunk = ^TPackageThunk; + TPackageThunk = packed record + JmpInstruction: Word; + JmpAddress: PPointer; + end; +begin + if not IsCompiledWithPackages then + Result := Address + else + if not IsBadReadPtr(Address, SizeOf(TPackageThunk)) and + (PPackageThunk(Address)^.JmpInstruction = JmpInstructionCode) then + Result := PPackageThunk(Address)^.JmpAddress^ + else + Result := nil; +end; +{$ENDIF BORLAND} +{$IFDEF FPC} +begin + Result := Address; +end; +{$ENDIF FPC} + +function PeMapFindResource(const Module: HMODULE; const ResourceType: PChar; + const ResourceName: string): Pointer; +var + ResItem: TJclPeResourceItem; +begin + Result := nil; + with TJclPeImage.Create(True) do + try + AttachLoadedModule(Module); + if StatusOK then + begin + ResItem := ResourceList.FindResource(ResourceType, PChar(ResourceName)); + if (ResItem <> nil) and ResItem.IsDirectory then + Result := ResItem.List[0].RawEntryData; + end; + finally + Free; + end; +end; + +//=== { TJclPeSectionStream } ================================================ + +constructor TJclPeSectionStream.Create(Instance: HMODULE; const ASectionName: string); +begin + inherited Create; + Initialize(Instance, ASectionName); +end; + +procedure TJclPeSectionStream.Initialize(Instance: HMODULE; const ASectionName: string); +var + Header: PImageSectionHeader; + NtHeaders32: PImageNtHeaders32; + NtHeaders64: PImageNtHeaders64; + DataSize: Integer; +begin + FInstance := Instance; + case PeMapImgTarget(Pointer(Instance)) of + taWin32: + begin + NtHeaders32 := PeMapImgNtHeaders32(Pointer(Instance)); + if NtHeaders32 = nil then + raise EJclPeImageError.CreateRes(@RsPeNotPE); + Header := PeMapImgFindSection32(NtHeaders32, ASectionName); + end; + taWin64: + begin + NtHeaders64 := PeMapImgNtHeaders64(Pointer(Instance)); + if NtHeaders64 = nil then + raise EJclPeImageError.CreateRes(@RsPeNotPE); + Header := PeMapImgFindSection64(NtHeaders64, ASectionName); + end; + //toUnknown: + else + raise EJclPeImageError.CreateRes(@RsPeUnknownTarget); + end; + if Header = nil then + raise EJclPeImageError.CreateResFmt(@RsPeSectionNotFound, [ASectionName]); + // Borland and Microsoft seems to have swapped the meaning of this items. + DataSize := Min(Header^.SizeOfRawData, Header^.Misc.VirtualSize); + SetPointer(Pointer(FInstance + Header^.VirtualAddress), DataSize); + FSectionHeader := Header^; +end; + +function TJclPeSectionStream.Write(const Buffer; Count: Integer): Longint; +begin + raise EJclPeImageError.CreateRes(@RsPeReadOnlyStream); +end; + +//=== { TJclPeMapImgHookItem } =============================================== + +constructor TJclPeMapImgHookItem.Create(AList: TObjectList; + const AFunctionName: string; const AModuleName: string; + ABaseAddress, ANewAddress, AOriginalAddress: Pointer); +begin + inherited Create; + FList := AList; + FFunctionName := AFunctionName; + FModuleName := AModuleName; + FBaseAddress := ABaseAddress; + FNewAddress := ANewAddress; + FOriginalAddress := AOriginalAddress; +end; + +destructor TJclPeMapImgHookItem.Destroy; +begin + if FBaseAddress <> nil then + InternalUnhook; + inherited Destroy; +end; + +function TJclPeMapImgHookItem.InternalUnhook: Boolean; +var + Buf: TMemoryBasicInformation; +begin + Buf.AllocationBase := nil; + if (VirtualQuery(FBaseAddress, Buf, SizeOf(Buf)) = SizeOf(Buf)) and (Buf.State and MEM_FREE = 0) then + Result := TJclPeMapImgHooks.ReplaceImport(FBaseAddress, ModuleName, NewAddress, OriginalAddress) + else + Result := True; // PE image is not available anymore (DLL got unloaded) + if Result then + FBaseAddress := nil; +end; + +function TJclPeMapImgHookItem.Unhook: Boolean; +begin + Result := InternalUnhook; + if Result then + FList.Remove(Self); +end; + +//=== { TJclPeMapImgHooks } ================================================== + +type + PWin9xDebugThunk32 = ^TWin9xDebugThunk32; + TWin9xDebugThunk32 = packed record + PUSH: Byte; // PUSH instruction opcode ($68) + Addr: DWORD; // The actual address of the DLL routine + JMP: Byte; // JMP instruction opcode ($E9) + Rel: DWORD; // Relative displacement (a Kernel32 address) + end; + +function TJclPeMapImgHooks.GetItemFromNewAddress(NewAddress: Pointer): TJclPeMapImgHookItem; +var + I: Integer; +begin + Result := nil; + for I := 0 to Count - 1 do + if Items[I].NewAddress = NewAddress then + begin + Result := Items[I]; + Break; + end; +end; + +function TJclPeMapImgHooks.GetItemFromOriginalAddress(OriginalAddress: Pointer): TJclPeMapImgHookItem; +var + I: Integer; +begin + Result := nil; + for I := 0 to Count - 1 do + if Items[I].OriginalAddress = OriginalAddress then + begin + Result := Items[I]; + Break; + end; +end; + +function TJclPeMapImgHooks.GetItems(Index: Integer): TJclPeMapImgHookItem; +begin + Result := TJclPeMapImgHookItem(Get(Index)); +end; + +function TJclPeMapImgHooks.HookImport(Base: Pointer; const ModuleName: string; + const FunctionName: string; NewAddress: Pointer; var OriginalAddress: Pointer): Boolean; +var + ModuleHandle: THandle; + OriginalItem: TJclPeMapImgHookItem; + UTF8Name: TUTF8String; +begin + ModuleHandle := GetModuleHandle(PChar(ModuleName)); + Result := (ModuleHandle <> 0); + if not Result then + begin + SetLastError(ERROR_MOD_NOT_FOUND); + Exit; + end; + if not TryStringToUTF8(FunctionName, UTF8Name) then + UTF8Name := TUTF8String(FunctionName); + OriginalAddress := GetProcAddress(ModuleHandle, PAnsiChar(UTF8Name)); + Result := (OriginalAddress <> nil); + if not Result then + begin + SetLastError(ERROR_PROC_NOT_FOUND); + Exit; + end; + OriginalItem := ItemFromOriginalAddress[OriginalAddress]; + Result := ((OriginalItem = nil) or (OriginalItem.ModuleName = ModuleName)) and + (NewAddress <> nil) and (OriginalAddress <> NewAddress); + if not Result then + begin + SetLastError(ERROR_ALREADY_EXISTS); + Exit; + end; + if Result then + Result := ReplaceImport(Base, ModuleName, OriginalAddress, NewAddress); + if Result then + begin + Add(TJclPeMapImgHookItem.Create(Self, FunctionName, ModuleName, Base, + NewAddress, OriginalAddress)); + end + else + SetLastError(ERROR_INVALID_PARAMETER); +end; + +class function TJclPeMapImgHooks.IsWin9xDebugThunk(P: Pointer): Boolean; +begin + with PWin9xDebugThunk32(P)^ do + Result := (PUSH = $68) and (JMP = $E9); +end; + +class function TJclPeMapImgHooks.ReplaceImport(Base: Pointer; const ModuleName: string; + FromProc, ToProc: Pointer): Boolean; +var + {$IFDEF CPU32} + FromProcDebugThunk32, ImportThunk32: PWin9xDebugThunk32; + IsThunked: Boolean; + {$ENDIF CPU32} + NtHeader32: PImageNtHeaders32; + ImportDir: TImageDataDirectory; + ImportDesc: PImageImportDescriptor; + CurrName, RefName: PAnsiChar; + {$IFDEF CPU32} + ImportEntry32: PImageThunkData32; + {$ENDIF CPU32} + {$IFDEF CPU64} + ImportEntry64: PImageThunkData64; + {$ENDIF CPU64} + FoundProc: Boolean; + WrittenBytes: Cardinal; + UTF8Name: TUTF8String; +begin + Result := False; + {$IFDEF CPU32} + FromProcDebugThunk32 := PWin9xDebugThunk32(FromProc); + IsThunked := (Win32Platform <> VER_PLATFORM_WIN32_NT) and IsWin9xDebugThunk(FromProcDebugThunk32); + {$ENDIF CPU32} + NtHeader32 := PeMapImgNtHeaders32(Base); + if NtHeader32 = nil then + Exit; + ImportDir := NtHeader32.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT]; + if ImportDir.VirtualAddress = 0 then + Exit; + ImportDesc := PImageImportDescriptor(TJclAddr(Base) + ImportDir.VirtualAddress); + if not TryStringToUTF8(ModuleName, UTF8Name) then + UTF8Name := TUTF8String(ModuleName); + RefName := PAnsiChar(UTF8Name); + while ImportDesc^.Name <> 0 do + begin + CurrName := PAnsiChar(Base) + ImportDesc^.Name; + if StrICompA(CurrName, RefName) = 0 then + begin + {$IFDEF CPU32} + ImportEntry32 := PImageThunkData32(TJclAddr(Base) + ImportDesc^.FirstThunk); + while ImportEntry32^.Function_ <> 0 do + begin + if IsThunked then + begin + ImportThunk32 := PWin9xDebugThunk32(ImportEntry32^.Function_); + FoundProc := IsWin9xDebugThunk(ImportThunk32) and (ImportThunk32^.Addr = FromProcDebugThunk32^.Addr); + end + else + FoundProc := Pointer(ImportEntry32^.Function_) = FromProc; + if FoundProc then + Result := WriteProtectedMemory(@ImportEntry32^.Function_, @ToProc, SizeOf(ToProc), WrittenBytes); + Inc(ImportEntry32); + end; + {$ENDIF CPU32} + {$IFDEF CPU64} + ImportEntry64 := PImageThunkData64(TJclAddr(Base) + ImportDesc^.FirstThunk); + while ImportEntry64^.Function_ <> 0 do + begin + FoundProc := Pointer(ImportEntry64^.Function_) = FromProc; + if FoundProc then + Result := WriteProtectedMemory(@ImportEntry64^.Function_, @ToProc, SizeOf(ToProc), WrittenBytes); + Inc(ImportEntry64); + end; + {$ENDIF CPU64} + end; + Inc(ImportDesc); + end; +end; + +class function TJclPeMapImgHooks.SystemBase: Pointer; +begin + Result := Pointer(SystemTObjectInstance); +end; + +procedure TJclPeMapImgHooks.UnhookAll; +var + I: Integer; +begin + I := 0; + while I < Count do + if not Items[I].Unhook then + Inc(I); +end; + +function TJclPeMapImgHooks.UnhookByNewAddress(NewAddress: Pointer): Boolean; +var + Item: TJclPeMapImgHookItem; +begin + Item := ItemFromNewAddress[NewAddress]; + Result := (Item <> nil) and Item.Unhook; +end; + +procedure TJclPeMapImgHooks.UnhookByBaseAddress(BaseAddress: Pointer); +var + I: Integer; +begin + for I := Count - 1 downto 0 do + if Items[I].BaseAddress = BaseAddress then + Items[I].Unhook; +end; + +// Image access under a debbuger +{$IFDEF USE_64BIT_TYPES} +function InternalReadProcMem(ProcessHandle: THandle; Address: DWORD; + Buffer: Pointer; Size: SIZE_T): Boolean; +var + BR: SIZE_T; +{$ELSE} +function InternalReadProcMem(ProcessHandle: THandle; Address: DWORD; + Buffer: Pointer; Size: Integer): Boolean; +var + BR: DWORD; +{$ENDIF} +begin + BR := 0; + Result := ReadProcessMemory(ProcessHandle, Pointer(Address), Buffer, Size, BR); +end; + +// TODO: 64 bit version +function PeDbgImgNtHeaders32(ProcessHandle: THandle; BaseAddress: TJclAddr32; + var NtHeaders: TImageNtHeaders32): Boolean; +var + DosHeader: TImageDosHeader; +begin + Result := False; + ResetMemory(NtHeaders, SizeOf(NtHeaders)); + ResetMemory(DosHeader, SizeOf(DosHeader)); + if not InternalReadProcMem(ProcessHandle, TJclAddr32(BaseAddress), @DosHeader, SizeOf(DosHeader)) then + Exit; + if DosHeader.e_magic <> IMAGE_DOS_SIGNATURE then + Exit; + Result := InternalReadProcMem(ProcessHandle, TJclAddr32(BaseAddress) + TJclAddr32(DosHeader._lfanew), + @NtHeaders, SizeOf(TImageNtHeaders32)); +end; + +// TODO: 64 bit version +function PeDbgImgLibraryName32(ProcessHandle: THandle; BaseAddress: TJclAddr32; + var Name: string): Boolean; +var + NtHeaders32: TImageNtHeaders32; + DataDir: TImageDataDirectory; + ExportDir: TImageExportDirectory; + UTF8Name: TUTF8String; +begin + Name := ''; + + NtHeaders32.Signature := 0; + Result := PeDbgImgNtHeaders32(ProcessHandle, BaseAddress, NtHeaders32); + if not Result then + Exit; + DataDir := NtHeaders32.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT]; + if DataDir.Size = 0 then + Exit; + if not InternalReadProcMem(ProcessHandle, TJclAddr(BaseAddress) + DataDir.VirtualAddress, + @ExportDir, SizeOf(ExportDir)) then + Exit; + if ExportDir.Name = 0 then + Exit; + SetLength(UTF8Name, MAX_PATH); + if InternalReadProcMem(ProcessHandle, TJclAddr(BaseAddress) + ExportDir.Name, PAnsiChar(UTF8Name), MAX_PATH) then + begin + StrResetLength(UTF8Name); + if not TryUTF8ToString(UTF8Name, Name) then + Name := string(UTF8Name); + end + else + Name := ''; +end; + +// Borland BPL packages name unmangling + +function PeBorUnmangleName(const Name: string; out Unmangled: string; + out Description: TJclBorUmDescription; out BasePos: Integer): TJclBorUmResult; +var + NameP, NameU, NameUFirst: PAnsiChar; + QualifierFound, LinkProcFound: Boolean; + UTF8Unmangled, UTF8Name: TUTF8String; + + procedure MarkQualifier; + begin + if not QualifierFound then + begin + QualifierFound := True; + BasePos := NameU - NameUFirst + 2; + end; + end; + + procedure ReadSpecialSymbol; + var + SymbolLength: Integer; + begin + SymbolLength := 0; + while CharIsDigit(Char(NameP^)) do + begin + SymbolLength := SymbolLength * 10 + Ord(NameP^) - 48; + Inc(NameP); + end; + while (SymbolLength > 0) and (NameP^ <> #0) do + begin + if NameP^ = '@' then + begin + MarkQualifier; + NameU^ := '.'; + end + else + NameU^ := NameP^; + Inc(NameP); + Inc(NameU); + Dec(SymbolLength); + end; + end; + + procedure ReadRTTI; + begin + if StrLCompA(NameP, '$xp$', 4) = 0 then + begin + Inc(NameP, 4); + Description.Kind := skRTTI; + QualifierFound := False; + ReadSpecialSymbol; + if QualifierFound then + Include(Description.Modifiers, smQualified); + end + else + Result := urError; + end; + + procedure ReadNameSymbol; + begin + if NameP^ = '@' then + begin + LinkProcFound := True; + Inc(NameP); + end; + while CharIsValidIdentifierLetter(Char(NameP^)) do + begin + NameU^ := NameP^; + Inc(NameP); + Inc(NameU); + end; + end; + + procedure ReadName; + begin + Description.Kind := skData; + QualifierFound := False; + LinkProcFound := False; + repeat + ReadNameSymbol; + if LinkProcFound and not QualifierFound then + LinkProcFound := False; + case NameP^ of + '@': + case (NameP + 1)^ of + #0: + begin + Description.Kind := skVTable; + Break; + end; + '$': + begin + if (NameP + 2)^ = 'b' then + begin + case (NameP + 3)^ of + 'c': + Description.Kind := skConstructor; + 'd': + Description.Kind := skDestructor; + end; + Inc(NameP, 6); + end + else + Description.Kind := skFunction; + Break; // no parameters unmangling yet + end; + else + MarkQualifier; + NameU^ := '.'; + Inc(NameU); + Inc(NameP); + end; + '$': + begin + Description.Kind := skFunction; + Break; // no parameters unmangling yet + end; + else + Break; + end; + until False; + if QualifierFound then + Include(Description.Modifiers, smQualified); + if LinkProcFound then + Include(Description.Modifiers, smLinkProc); + end; + +begin + if not TryStringToUTF8(Name, UTF8Name) then + UTF8Name := TUTF8String(Name); + NameP := PAnsiChar(UTF8Name); + Result := urError; + case NameP^ of + '@': + Result := urOk; + '?': + Result := urMicrosoft; + '_', 'A'..'Z', 'a'..'z': + Result := urNotMangled; + end; + if Result <> urOk then + Exit; + Inc(NameP); + SetLength(UTF8UnMangled, 1024); + NameU := PAnsiChar(UTF8UnMangled); + NameUFirst := NameU; + Description.Modifiers := []; + BasePos := 1; + case NameP^ of + '$': + ReadRTTI; + '_', 'A'..'Z', 'a'..'z': + ReadName; + else + Result := urError; + end; + NameU^ := #0; + SetLength(UTF8Unmangled, StrLenA(PAnsiChar(UTF8Unmangled))); // SysUtils prefix due to compiler bug + if not TryUTF8ToString(UTF8Unmangled, Unmangled) then + Unmangled := string(UTF8Unmangled); +end; + +function PeBorUnmangleName(const Name: string; out Unmangled: string; + out Description: TJclBorUmDescription): TJclBorUmResult; +var + BasePos: Integer; +begin + Result := PeBorUnmangleName(Name, Unmangled, Description, BasePos); +end; + +function PeBorUnmangleName(const Name: string; out Unmangled: string): TJclBorUmResult; +var + Description: TJclBorUmDescription; + BasePos: Integer; +begin + Result := PeBorUnmangleName(Name, Unmangled, Description, BasePos); +end; + +function PeBorUnmangleName(const Name: string): string; +var + Unmangled: string; + Description: TJclBorUmDescription; + BasePos: Integer; +begin + if PeBorUnmangleName(Name, Unmangled, Description, BasePos) = urOk then + Result := Unmangled + else + Result := ''; +end; + +function PeIsNameMangled(const Name: string): TJclPeUmResult; +begin + Result := umNotMangled; + if Length(Name) > 0 then + case Name[1] of + '@': + Result := umBorland; + '?': + Result := umMicrosoft; + end; +end; + +type + TUndecorateSymbolNameA = function (DecoratedName: PAnsiChar; + UnDecoratedName: PAnsiChar; UndecoratedLength: DWORD; Flags: DWORD): DWORD; stdcall; +// 'imagehlp.dll' 'UnDecorateSymbolName' + + TUndecorateSymbolNameW = function (DecoratedName: PWideChar; + UnDecoratedName: PWideChar; UndecoratedLength: DWORD; Flags: DWORD): DWORD; stdcall; +// 'imagehlp.dll' 'UnDecorateSymbolNameW' + +var + UndecorateSymbolNameA: TUndecorateSymbolNameA = nil; + UndecorateSymbolNameAFailed: Boolean = False; + UndecorateSymbolNameW: TUndecorateSymbolNameW = nil; + UndecorateSymbolNameWFailed: Boolean = False; + +function UndecorateSymbolName(const DecoratedName: string; out UnMangled: string; Flags: DWORD): Boolean; +const + ModuleName = 'imagehlp.dll'; + BufferSize = 512; +var + ModuleHandle: HMODULE; + WideBuffer: WideString; + AnsiBuffer: AnsiString; + Res: DWORD; +begin + Result := False; + if ((not Assigned(UndecorateSymbolNameA)) and (not UndecorateSymbolNameAFailed)) or + ((not Assigned(UndecorateSymbolNameW)) and (not UndecorateSymbolNameWFailed)) then + begin + ModuleHandle := GetModuleHandle(ModuleName); + if ModuleHandle = 0 then + begin + ModuleHandle := SafeLoadLibrary(ModuleName); + if ModuleHandle = 0 then + Exit; + end; + UndecorateSymbolNameA := GetProcAddress(ModuleHandle, 'UnDecorateSymbolName'); + UndecorateSymbolNameAFailed := not Assigned(UndecorateSymbolNameA); + UndecorateSymbolNameW := GetProcAddress(ModuleHandle, 'UnDecorateSymbolNameW'); + UndecorateSymbolNameWFailed := not Assigned(UndecorateSymbolNameW); + end; + if Assigned(UndecorateSymbolNameW) then + begin + SetLength(WideBuffer, BufferSize); + Res := UnDecorateSymbolNameW(PWideChar(WideString(DecoratedName)), PWideChar(WideBuffer), BufferSize, Flags); + if Res > 0 then + begin + StrResetLength(WideBuffer); + UnMangled := string(WideBuffer); + Result := True; + end; + end + else + if Assigned(UndecorateSymbolNameA) then + begin + SetLength(AnsiBuffer, BufferSize); + Res := UnDecorateSymbolNameA(PAnsiChar(AnsiString(DecoratedName)), PAnsiChar(AnsiBuffer), BufferSize, Flags); + if Res > 0 then + begin + StrResetLength(AnsiBuffer); + UnMangled := string(AnsiBuffer); + Result := True; + end; + end; +end; + +function PeUnmangleName(const Name: string; out Unmangled: string): TJclPeUmResult; +begin + Result := umNotMangled; + case PeBorUnmangleName(Name, Unmangled) of + urOk: + Result := umBorland; + urMicrosoft: + if UndecorateSymbolName(Name, Unmangled, UNDNAME_NAME_ONLY) then + Result := umMicrosoft; + end; + if Result = umNotMangled then + Unmangled := Name; +end; + +{$IFDEF UNITVERSIONING} +initialization + RegisterUnitVersion(HInstance, UnitVersioning); + +finalization + UnregisterUnitVersion(HInstance); +{$ENDIF UNITVERSIONING} + +end. diff --git a/source/packages/jcl/JclResources.pas b/source/packages/jcl/JclResources.pas new file mode 100644 index 00000000..b1a1399c --- /dev/null +++ b/source/packages/jcl/JclResources.pas @@ -0,0 +1,2078 @@ +{**************************************************************************************************} +{ } +{ Project JEDI Code Library (JCL) } +{ } +{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); } +{ you may not use this file except in compliance with the License. You may obtain a copy of the } +{ License at http://www.mozilla.org/MPL/ } +{ } +{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF } +{ ANY KIND, either express or implied. See the License for the specific language governing rights } +{ and limitations under the License. } +{ } +{ The Original Code is JclResources.pas. } +{ } +{ The Initial Developer of the Original Code is Marcel van Brakel. } +{ Portions created by Marcel van Brakel are Copyright (C) Marcel van Brakel. All rights reserved. } +{ } +{ Contributors: } +{ Alexei Koudinov } +{ Barry Kelly } +{ Flier Lu (flier) } +{ Florent Ouchet (outchy) } +{ Jean-Fabien Connault (cycocrew) } +{ Marcel Bestebroer } +{ Marcel van Brakel } +{ Matthias Thoma (mthoma) } +{ Peter Friese } +{ Petr Vones (pvones) } +{ Raymond Alexander (rayspostbox3) } +{ Robert Marquardt (marquardt) } +{ Robert Rossmair (rrossmair) } +{ Scott Price (scottprice) } +{ Uwe Schuster (uschuster) } +{ } +{**************************************************************************************************} +{ } +{ Unit which provides a central place for all resource strings used in the JCL } +{ } +{**************************************************************************************************} +{ } +{ Last modified: $Date:: $ } +{ Revision: $Rev:: $ } +{ Author: $Author:: $ } +{ } +{**************************************************************************************************} + +unit JclResources; + +{$I jcl.inc} + +interface + +{$IFDEF UNITVERSIONING} +uses + JclUnitVersioning; +{$ENDIF UNITVERSIONING} + +//=== JclBase ================================================================ +resourcestring + RsCantConvertAddr64 = 'The address %s%.16x cannot be converted to 32 bit'; + RsEReplacementChar = 'Failed to get ANSI replacement character'; + +//=== JclCharsets ============================================================ +resourcestring + RsENoCharset = 'No matching charset'; + +//=== JclCIL ================================================================= +resourcestring + RsInstructionStreamInvalid = 'Invalid IL instruction stream'; + RsCILNamenop = 'nop'; + RsCILNamebreak = 'break'; + RsCILNameldarg0 = 'ldarg.0'; + RsCILNameldarg1 = 'ldarg.1'; + RsCILNameldarg2 = 'ldarg.2'; + RsCILNameldarg3 = 'ldarg.3'; + RsCILNameldloc0 = 'ldloc.0'; + RsCILNameldloc1 = 'ldloc.1'; + RsCILNameldloc2 = 'ldloc.2'; + RsCILNameldloc3 = 'ldloc.3'; + RsCILNamestloc0 = 'stloc.0'; + RsCILNamestloc1 = 'stloc.1'; + RsCILNamestloc2 = 'stloc.2'; + RsCILNamestloc3 = 'stloc.3'; + RsCILNameldargs = 'ldarg.s'; + RsCILNameldargas = 'ldarga.s'; + RsCILNamestargs = 'starg.s'; + RsCILNameldlocs = 'ldloc.s'; + RsCILNameldlocas = 'ldloca.s'; + RsCILNamestlocs = 'stloc.s'; + RsCILNameldnull = 'ldnull'; + RsCILNameldci4m1 = 'ldc.i4.m1'; + RsCILNameldci40 = 'ldc.i4.0'; + RsCILNameldci41 = 'ldc.i4.1'; + RsCILNameldci42 = 'ldc.i4.2'; + RsCILNameldci43 = 'ldc.i4.3'; + RsCILNameldci44 = 'ldc.i4.4'; + RsCILNameldci45 = 'ldc.i4.5'; + RsCILNameldci46 = 'ldc.i4.6'; + RsCILNameldci47 = 'ldc.i4.7'; + RsCILNameldci48 = 'ldc.i4.8'; + RsCILNameldci4s = 'ldc.i4.s'; + RsCILNameldci4 = 'ldc.i4'; + RsCILNameldci8 = 'ldc.i8'; + RsCILNameldcr4 = 'ldc.r4'; + RsCILNameldcr8 = 'ldc.r8'; + RsCILNameunused1 = 'unused'; + RsCILNamedup = 'dup'; + RsCILNamepop = 'pop'; + RsCILNamejmp = 'jmp'; + RsCILNamecall = 'call'; + RsCILNamecalli = 'calli'; + RsCILNameret = 'ret'; + RsCILNamebrs = 'br.s'; + RsCILNamebrfalses = 'brfalse.s'; + RsCILNamebrtrues = 'brtrue.s'; + RsCILNamebeqs = 'beq.s'; + RsCILNamebges = 'bge.s'; + RsCILNamebgts = 'bgt.s'; + RsCILNamebles = 'ble.s'; + RsCILNameblts = 'blt.s'; + RsCILNamebneuns = 'bne.un.s'; + RsCILNamebgeuns = 'bge.un.s'; + RsCILNamebgtuns = 'bgt.un.s'; + RsCILNamebleuns = 'ble.un.s'; + RsCILNamebltuns = 'blt.un.s'; + RsCILNamebr = 'br'; + RsCILNamebrfalse = 'brfalse'; + RsCILNamebrtrue = 'brtrue'; + RsCILNamebeq = 'beq'; + RsCILNamebge = 'bge'; + RsCILNamebgt = 'bgt'; + RsCILNameble = 'ble'; + RsCILNameblt = 'blt'; + RsCILNamebneun = 'bne.un'; + RsCILNamebgeun = 'bge.un'; + RsCILNamebgtun = 'bgt.un'; + RsCILNamebleun = 'ble.un'; + RsCILNamebltun = 'blt.un'; + RsCILNameswitch = 'switch'; + RsCILNameldindi1 = 'ldind.i1'; + RsCILNameldindu1 = 'ldind.u1'; + RsCILNameldindi2 = 'ldind.i2'; + RsCILNameldindu2 = 'ldind.u2'; + RsCILNameldindi4 = 'ldind.i4'; + RsCILNameldindu4 = 'ldind.u4'; + RsCILNameldindi8 = 'ldind.i8'; + RsCILNameldindi = 'ldind.i'; + RsCILNameldindr4 = 'ldind.r4'; + RsCILNameldindr8 = 'ldind.r8'; + RsCILNameldindref = 'ldind.ref'; + RsCILNamestindref = 'stind.ref'; + RsCILNamestindi1 = 'stind.i1'; + RsCILNamestindi2 = 'stind.i2'; + RsCILNamestindi4 = 'stind.i4'; + RsCILNamestindi8 = 'stind.i8'; + RsCILNamestindr4 = 'stind.r4'; + RsCILNamestindr8 = 'stind.r8'; + RsCILNameadd = 'add'; + RsCILNamesub = 'sub'; + RsCILNamemul = 'mul'; + RsCILNamediv = 'div'; + RsCILNamedivun = 'div.un'; + RsCILNamerem = 'rem'; + RsCILNameremun = 'rem.un'; + RsCILNameand = 'and'; + RsCILNameor = 'or'; + RsCILNamexor = 'xor'; + RsCILNameshl = 'shl'; + RsCILNameshr = 'shr'; + RsCILNameshrun = 'shr.un'; + RsCILNameneg = 'neg'; + RsCILNamenot = 'not'; + RsCILNameconvi1 = 'conv.i1'; + RsCILNameconvi2 = 'conv.i2'; + RsCILNameconvi4 = 'conv.i4'; + RsCILNameconvi8 = 'conv.i8'; + RsCILNameconvr4 = 'conv.r4'; + RsCILNameconvr8 = 'conv.r8'; + RsCILNameconvu4 = 'conv.u4'; + RsCILNameconvu8 = 'conv.u8'; + RsCILNamecallvirt = 'callvirt'; + RsCILNamecpobj = 'cpobj'; + RsCILNameldobj = 'ldobj'; + RsCILNameldstr = 'ldstr'; + RsCILNamenewobj = 'newobj'; + RsCILNamecastclass = 'castclass'; + RsCILNameisinst = 'isinst'; + RsCILNameconvrun = 'conv.r.un'; + RsCILNameunused2 = 'unused'; + RsCILNameunused3 = 'unused'; + RsCILNameunbox = 'unbox'; + RsCILNamethrow = 'throw'; + RsCILNameldfld = 'ldfld'; + RsCILNameldflda = 'ldflda'; + RsCILNamestfld = 'stfld'; + RsCILNameldsfld = 'ldsfld'; + RsCILNameldsflda = 'ldsflda'; + RsCILNamestsfld = 'stsfld'; + RsCILNamestobj = 'stobj'; + RsCILNameconvovfi1un = 'conv.ovf.i1.un'; + RsCILNameconvovfi2un = 'conv.ovf.i2.un'; + RsCILNameconvovfi4un = 'conv.ovf.i4.un'; + RsCILNameconvovfi8un = 'conv.ovf.i8.un'; + RsCILNameconvovfu1un = 'conv.ovf.u1.un'; + RsCILNameconvovfu2un = 'conv.ovf.u2.un'; + RsCILNameconvovfu4un = 'conv.ovf.u4.un'; + RsCILNameconvovfu8un = 'conv.ovf.u8.un'; + RsCILNameconvovfiun = 'conv.ovf.i.un'; + RsCILNameconvovfuun = 'conv.ovf.u.un'; + RsCILNamebox = 'box'; + RsCILNamenewarr = 'newarr'; + RsCILNameldlen = 'ldlen'; + RsCILNameldelema = 'ldelema'; + RsCILNameldelemi1 = 'ldelem.i1'; + RsCILNameldelemu1 = 'ldelem.u1'; + RsCILNameldelemi2 = 'ldelem.i2'; + RsCILNameldelemu2 = 'ldelem.u2'; + RsCILNameldelemi4 = 'ldelem.i4'; + RsCILNameldelemu4 = 'ldelem.u4'; + RsCILNameldelemi8 = 'ldelem.i8'; + RsCILNameldelemi = 'ldelem.i'; + RsCILNameldelemr4 = 'ldelem.r4'; + RsCILNameldelemr8 = 'ldelem.r8'; + RsCILNameldelemref = 'ldelem.ref'; + RsCILNamestelemi = 'stelem.i'; + RsCILNamestelemi1 = 'stelem.i1'; + RsCILNamestelemi2 = 'stelem.i2'; + RsCILNamestelemi4 = 'stelem.i4'; + RsCILNamestelemi8 = 'stelem.i8'; + RsCILNamestelemr4 = 'stelem.r4'; + RsCILNamestelemr8 = 'stelem.r8'; + RsCILNamestelemref = 'stelem.ref'; + RsCILNameunused4 = 'unused'; + RsCILNameunused5 = 'unused'; + RsCILNameunused6 = 'unused'; + RsCILNameunused7 = 'unused'; + RsCILNameunused8 = 'unused'; + RsCILNameunused9 = 'unused'; + RsCILNameunused10 = 'unused'; + RsCILNameunused11 = 'unused'; + RsCILNameunused12 = 'unused'; + RsCILNameunused13 = 'unused'; + RsCILNameunused14 = 'unused'; + RsCILNameunused15 = 'unused'; + RsCILNameunused16 = 'unused'; + RsCILNameunused17 = 'unused'; + RsCILNameunused18 = 'unused'; + RsCILNameunused19 = 'unused'; + RsCILNameconvovfi1 = 'conv.ovf.i1'; + RsCILNameconvovfu1 = 'conv.ovf.u1'; + RsCILNameconvovfi2 = 'conv.ovf.i2'; + RsCILNameconvovfu2 = 'conv.ovf.u2'; + RsCILNameconvovfi4 = 'conv.ovf.i4'; + RsCILNameconvovfu4 = 'conv.ovf.u4'; + RsCILNameconvovfi8 = 'conv.ovf.i8'; + RsCILNameconvovfu8 = 'conv.ovf.u8'; + RsCILNameunused20 = 'unused'; + RsCILNameunused21 = 'unused'; + RsCILNameunused22 = 'unused'; + RsCILNameunused23 = 'unused'; + RsCILNameunused24 = 'unused'; + RsCILNameunused25 = 'unused'; + RsCILNameunused26 = 'unused'; + RsCILNamerefanyval = 'refanyval'; + RsCILNameckfinite = 'ckfinite'; + RsCILNameunused27 = 'unused'; + RsCILNameunused28 = 'unused'; + RsCILNamemkrefany = 'mkrefany'; + RsCILNameunused29 = 'unused'; + RsCILNameunused30 = 'unused'; + RsCILNameunused31 = 'unused'; + RsCILNameunused32 = 'unused'; + RsCILNameunused33 = 'unused'; + RsCILNameunused34 = 'unused'; + RsCILNameunused35 = 'unused'; + RsCILNameunused36 = 'unused'; + RsCILNameunused37 = 'unused'; + RsCILNameldtoken = 'ldtoken'; + RsCILNameconvu2 = 'conv.u2'; + RsCILNameconvu1 = 'conv.u1'; + RsCILNameconvi = 'conv.i'; + RsCILNameconvovfi = 'conv.ovf.i'; + RsCILNameconvovfu = 'conv.ovf.u'; + RsCILNameaddovf = 'add.ovf'; + RsCILNameaddovfun = 'add.ovf.un'; + RsCILNamemulovf = 'mul.ovf'; + RsCILNamemulovfun = 'mul.ovf.un'; + RsCILNamesubovf = 'sub.ovf'; + RsCILNamesubovfun = 'sub.ovf.un'; + RsCILNameendfinally = 'endfinally'; + RsCILNameleave = 'leave'; + RsCILNameleaves = 'leave.s'; + RsCILNamestindi = 'stind.i'; + RsCILNameconvu = 'conv.u'; + RsCILNameunused38 = 'unused'; + RsCILNameunused39 = 'unused'; + RsCILNameunused40 = 'unused'; + RsCILNameunused41 = 'unused'; + RsCILNameunused42 = 'unused'; + RsCILNameunused43 = 'unused'; + RsCILNameunused44 = 'unused'; + RsCILNameunused45 = 'unused'; + RsCILNameunused46 = 'unused'; + RsCILNameunused47 = 'unused'; + RsCILNameunused48 = 'unused'; + RsCILNameunused49 = 'unused'; + RsCILNameunused50 = 'unused'; + RsCILNameunused51 = 'unused'; + RsCILNameunused52 = 'unused'; + RsCILNameunused53 = 'unused'; + RsCILNameunused54 = 'unused'; + RsCILNameunused55 = 'unused'; + RsCILNameunused56 = 'unused'; + RsCILNameunused57 = 'unused'; + RsCILNameunused58 = 'unused'; + RsCILNameunused59 = 'unused'; + RsCILNameunused60 = 'unused'; + RsCILNameprefix7 = 'prefix7'; + RsCILNameprefix6 = 'prefix6'; + RsCILNameprefix5 = 'prefix5'; + RsCILNameprefix4 = 'prefix4'; + RsCILNameprefix3 = 'prefix3'; + RsCILNameprefix2 = 'prefix2'; + RsCILNameprefix1 = 'prefix1'; + RsCILNameprefixref = 'prefixref'; + RsCILNamearglist = 'arglist'; + RsCILNameceq = 'ceq'; + RsCILNamecgt = 'cgt'; + RsCILNamecgtun = 'cgt.un'; + RsCILNameclt = 'clt'; + RsCILNamecltun = 'clt.un'; + RsCILNameldftn = 'ldftn'; + RsCILNameldvirtftn = 'ldvirtftn'; + RsCILNameunused61 = 'unused'; + RsCILNameldarg = 'ldarg'; + RsCILNameldarga = 'ldarga'; + RsCILNamestarg = 'starg'; + RsCILNameldloc = 'ldloc'; + RsCILNameldloca = 'ldloca'; + RsCILNamestloc = 'stloc'; + RsCILNamelocalloc = 'localloc'; + RsCILNameunused62 = 'unused'; + RsCILNameendfilter = 'endfilter'; + RsCILNameunaligned = 'unaligned.'; + RsCILNamevolatile = 'volatile.'; + RsCILNametail = 'tail.'; + RsCILNameinitobj = 'initobj'; + RsCILNameunused63 = 'unused'; + RsCILNamecpblk = 'cpblk'; + RsCILNameinitblk = 'initblk'; + RsCILNameunused64 = 'unused'; + RsCILNamerethrow = 'rethrow'; + RsCILNameunused65 = 'unused'; + RsCILNamesizeof = 'sizeof'; + RsCILNamerefanytype = 'refanytype'; + RsCILNameunused66 = 'unused'; + RsCILNameunused67 = 'unused'; + RsCILNameunused68 = 'unused'; + RsCILNameunused69 = 'unused'; + RsCILNameunused70 = 'unused'; + + RsCILCmdnop = 'no operation'; + RsCILCmdbreak = 'breakpoint instruction'; + RsCILCmdldarg0 = 'load argument onto the stack'; + RsCILCmdldarg1 = 'load argument onto the stack'; + RsCILCmdldarg2 = 'load argument onto the stack'; + RsCILCmdldarg3 = 'load argument onto the stack'; + RsCILCmdldloc0 = 'load local variable onto the stack'; + RsCILCmdldloc1 = 'load local variable onto the stack'; + RsCILCmdldloc2 = 'load local variable onto the stack'; + RsCILCmdldloc3 = 'load local variable onto the stack'; + RsCILCmdstloc0 = 'pop value from stack to local variable'; + RsCILCmdstloc1 = 'pop value from stack to local variable'; + RsCILCmdstloc2 = 'pop value from stack to local variable'; + RsCILCmdstloc3 = 'pop value from stack to local variable'; + RsCILCmdldargs = 'load argument onto the stack'; + RsCILCmdldargas = 'load an argument address'; + RsCILCmdstargs = 'store a value in an argument slot'; + RsCILCmdldlocs = 'load local variable onto the stack'; + RsCILCmdldlocas = 'load local variable address'; + RsCILCmdstlocs = 'pop value from stack to local variable'; + RsCILCmdldnull = 'load a null pointer'; + RsCILCmdldci4m1 = 'load numeric constant'; + RsCILCmdldci40 = 'load numeric constant'; + RsCILCmdldci41 = 'load numeric constant'; + RsCILCmdldci42 = 'load numeric constant'; + RsCILCmdldci43 = 'load numeric constant'; + RsCILCmdldci44 = 'load numeric constant'; + RsCILCmdldci45 = 'load numeric constant'; + RsCILCmdldci46 = 'load numeric constant'; + RsCILCmdldci47 = 'load numeric constant'; + RsCILCmdldci48 = 'load numeric constant'; + RsCILCmdldci4s = 'load numeric constant'; + RsCILCmdldci4 = 'load numeric constant'; + RsCILCmdldci8 = 'load numeric constant'; + RsCILCmdldcr4 = 'load numeric constant'; + RsCILCmdldcr8 = 'load numeric constant'; + RsCILCmdunused1 = ''; + RsCILCmddup = 'duplicate the top value of the stack'; + RsCILCmdpop = 'remove the top element of the stack'; + RsCILCmdjmp = 'jump to method'; + RsCILCmdcall = 'call a method'; + RsCILCmdcalli = 'indirect method call'; + RsCILCmdret = 'return from method'; + RsCILCmdbrs = 'unconditional branch'; + RsCILCmdbrfalses = 'branch on false, null, or zero'; + RsCILCmdbrtrues = 'branch on non-false or non-null'; + RsCILCmdbeqs = 'branch on equal'; + RsCILCmdbges = 'branch on greater than or equal to'; + RsCILCmdbgts = 'branch on greater than'; + RsCILCmdbles = 'branch on less than or equal to'; + RsCILCmdblts = 'branch on less than'; + RsCILCmdbneuns = 'branch on not equal or unordered'; + RsCILCmdbgeuns = 'branch on greater than or equal to, unsigned or unordered'; + RsCILCmdbgtuns = 'branch on greater than, unsigned or unordered'; + RsCILCmdbleuns = 'branch on less than or equal to, unsigned or unordered'; + RsCILCmdbltuns = 'branch on less than, unsigned or unordered'; + RsCILCmdbr = 'unconditional branch'; + RsCILCmdbrfalse = 'branch on false, null, or zero'; + RsCILCmdbrtrue = 'branch on non-false or non-null'; + RsCILCmdbeq = 'branch on equal'; + RsCILCmdbge = 'branch on greater than or equal to'; + RsCILCmdbgt = 'branch on greater than'; + RsCILCmdble = 'branch on less than or equal to'; + RsCILCmdblt = 'branch on less than'; + RsCILCmdbneun = 'branch on not equal or unordered'; + RsCILCmdbgeun = 'branch on greater than or equal to, unsigned or unordered'; + RsCILCmdbgtun = 'branch on greater than, unsigned or unordered'; + RsCILCmdbleun = 'branch on less than or equal to, unsigned or unordered'; + RsCILCmdbltun = 'branch on less than, unsigned or unordered'; + RsCILCmdswitch = 'table switch on value'; + RsCILCmdldindi1 = 'load value indirect onto the stack'; + RsCILCmdldindu1 = 'load value indirect onto the stack'; + RsCILCmdldindi2 = 'load value indirect onto the stack'; + RsCILCmdldindu2 = 'load value indirect onto the stack'; + RsCILCmdldindi4 = 'load value indirect onto the stack'; + RsCILCmdldindu4 = 'load value indirect onto the stack'; + RsCILCmdldindi8 = 'load value indirect onto the stack'; + RsCILCmdldindi = 'load value indirect onto the stack'; + RsCILCmdldindr4 = 'load value indirect onto the stack'; + RsCILCmdldindr8 = 'load value indirect onto the stack'; + RsCILCmdldindref = 'load value indirect onto the stack'; + RsCILCmdstindref = 'store value indirect from stack'; + RsCILCmdstindi1 = 'store value indirect from stack'; + RsCILCmdstindi2 = 'store value indirect from stack'; + RsCILCmdstindi4 = 'store value indirect from stack'; + RsCILCmdstindi8 = 'store value indirect from stack'; + RsCILCmdstindr4 = 'store value indirect from stack'; + RsCILCmdstindr8 = 'store value indirect from stack'; + RsCILCmdadd = 'add numeric values'; + RsCILCmdsub = 'subtract numeric values'; + RsCILCmdmul = 'multiply values'; + RsCILCmddiv = 'divide values'; + RsCILCmddivun = 'divide integer values, unsigned'; + RsCILCmdrem = 'compute remainder'; + RsCILCmdremun = 'compute integer remainder, unsigned'; + RsCILCmdand = 'bitwise AND'; + RsCILCmdor = 'bitwise OR'; + RsCILCmdxor = 'bitwise XOR'; + RsCILCmdshl = 'shift integer left'; + RsCILCmdshr = 'shift integer right'; + RsCILCmdshrun = 'shift integer right, unsigned'; + RsCILCmdneg = 'negate'; + RsCILCmdnot = 'bitwise complement'; + RsCILCmdconvi1 = 'data conversion'; + RsCILCmdconvi2 = 'data conversion'; + RsCILCmdconvi4 = 'data conversion'; + RsCILCmdconvi8 = 'data conversion'; + RsCILCmdconvr4 = 'data conversion'; + RsCILCmdconvr8 = 'data conversion'; + RsCILCmdconvu4 = 'data conversion'; + RsCILCmdconvu8 = 'data conversion'; + RsCILCmdcallvirt = 'call a method associated, at runtime, with an object'; + RsCILCmdcpobj = 'copy a value type'; + RsCILCmdldobj = 'copy value type to the stack'; + RsCILCmdldstr = 'load a literal string'; + RsCILCmdnewobj = 'create a new object'; + RsCILCmdcastclass = 'cast an object to a class'; + RsCILCmdisinst = 'test if an object is an instance of a class or interface'; + RsCILCmdconvrun = 'data conversion'; + RsCILCmdunused2 = ''; + RsCILCmdunused3 = ''; + RsCILCmdunbox = 'Convert boxed value type to its raw form'; + RsCILCmdthrow = 'throw an exception'; + RsCILCmdldfld = 'load field of an object'; + RsCILCmdldflda = 'load field address'; + RsCILCmdstfld = 'store into a field of an object'; + RsCILCmdldsfld = 'load static field of a class'; + RsCILCmdldsflda = 'load static field address'; + RsCILCmdstsfld = 'store a static field of a class'; + RsCILCmdstobj = 'store a value type from the stack into memory'; + RsCILCmdconvovfi1un = 'unsigned data conversion with overflow detection'; + RsCILCmdconvovfi2un = 'unsigned data conversion with overflow detection'; + RsCILCmdconvovfi4un = 'unsigned data conversion with overflow detection'; + RsCILCmdconvovfi8un = 'unsigned data conversion with overflow detection'; + RsCILCmdconvovfu1un = 'unsigned data conversion with overflow detection'; + RsCILCmdconvovfu2un = 'unsigned data conversion with overflow detection'; + RsCILCmdconvovfu4un = 'unsigned data conversion with overflow detection'; + RsCILCmdconvovfu8un = 'unsigned data conversion with overflow detection'; + RsCILCmdconvovfiun = 'unsigned data conversion with overflow detection'; + RsCILCmdconvovfuun = 'unsigned data conversion with overflow detection'; + RsCILCmdbox = 'convert value type to object reference'; + RsCILCmdnewarr = 'create a zero-based, one-dimensional array'; + RsCILCmdldlen = 'load the length of an array'; + RsCILCmdldelema = 'load address of an element of an array'; + RsCILCmdldelemi1 = 'load an element of an array'; + RsCILCmdldelemu1 = 'load an element of an array'; + RsCILCmdldelemi2 = 'load an element of an array'; + RsCILCmdldelemu2 = 'load an element of an array'; + RsCILCmdldelemi4 = 'load an element of an array'; + RsCILCmdldelemu4 = 'load an element of an array'; + RsCILCmdldelemi8 = 'load an element of an array'; + RsCILCmdldelemi = 'load an element of an array'; + RsCILCmdldelemr4 = 'load an element of an array'; + RsCILCmdldelemr8 = 'load an element of an array'; + RsCILCmdldelemref = 'load an element of an array'; + RsCILCmdstelemi = 'store an element of an array'; + RsCILCmdstelemi1 = 'store an element of an array'; + RsCILCmdstelemi2 = 'store an element of an array'; + RsCILCmdstelemi4 = 'store an element of an array'; + RsCILCmdstelemi8 = 'store an element of an array'; + RsCILCmdstelemr4 = 'store an element of an array'; + RsCILCmdstelemr8 = 'store an element of an array'; + RsCILCmdstelemref = 'store an element of an array'; + RsCILCmdunused4 = ''; + RsCILCmdunused5 = ''; + RsCILCmdunused6 = ''; + RsCILCmdunused7 = ''; + RsCILCmdunused8 = ''; + RsCILCmdunused9 = ''; + RsCILCmdunused10 = ''; + RsCILCmdunused11 = ''; + RsCILCmdunused12 = ''; + RsCILCmdunused13 = ''; + RsCILCmdunused14 = ''; + RsCILCmdunused15 = ''; + RsCILCmdunused16 = ''; + RsCILCmdunused17 = ''; + RsCILCmdunused18 = ''; + RsCILCmdunused19 = ''; + RsCILCmdconvovfi1 = 'data conversion with overflow detection'; + RsCILCmdconvovfu1 = 'data conversion with overflow detection'; + RsCILCmdconvovfi2 = 'data conversion with overflow detection'; + RsCILCmdconvovfu2 = 'data conversion with overflow detection'; + RsCILCmdconvovfi4 = 'data conversion with overflow detection'; + RsCILCmdconvovfu4 = 'data conversion with overflow detection'; + RsCILCmdconvovfi8 = 'data conversion with overflow detection'; + RsCILCmdconvovfu8 = 'data conversion with overflow detection'; + RsCILCmdunused20 = ''; + RsCILCmdunused21 = ''; + RsCILCmdunused22 = ''; + RsCILCmdunused23 = ''; + RsCILCmdunused24 = ''; + RsCILCmdunused25 = ''; + RsCILCmdunused26 = ''; + RsCILCmdrefanyval = 'load the address out of a typed reference'; + RsCILCmdckfinite = 'check for a finite real number'; + RsCILCmdunused27 = ''; + RsCILCmdunused28 = ''; + RsCILCmdmkrefany = 'push a typed reference on the stack'; + RsCILCmdunused29 = ''; + RsCILCmdunused30 = ''; + RsCILCmdunused31 = ''; + RsCILCmdunused32 = ''; + RsCILCmdunused33 = ''; + RsCILCmdunused34 = ''; + RsCILCmdunused35 = ''; + RsCILCmdunused36 = ''; + RsCILCmdunused37 = ''; + RsCILCmdldtoken = 'load the runtime representation of a metadata token'; + RsCILCmdconvu2 = 'data conversion'; + RsCILCmdconvu1 = 'data conversion'; + RsCILCmdconvi = 'data conversion'; + RsCILCmdconvovfi = 'data conversion with overflow detection'; + RsCILCmdconvovfu = 'data conversion with overflow detection'; + RsCILCmdaddovf = 'add integer values with overflow check'; + RsCILCmdaddovfun = 'add integer values with overflow check'; + RsCILCmdmulovf = 'multiply integer values with overflow check'; + RsCILCmdmulovfun = 'multiply integer values with overflow check'; + RsCILCmdsubovf = 'subtract integer values, checking for overflow'; + RsCILCmdsubovfun = 'subtract integer values, checking for overflow'; + RsCILCmdendfinally = 'end the finally or fault clause of an exception block'; + RsCILCmdleave = 'exit a protected region of code'; + RsCILCmdleaves = 'exit a protected region of code'; + RsCILCmdstindi = 'store value indirect from stack'; + RsCILCmdconvu = 'data conversion'; + RsCILCmdunused38 = ''; + RsCILCmdunused39 = ''; + RsCILCmdunused40 = ''; + RsCILCmdunused41 = ''; + RsCILCmdunused42 = ''; + RsCILCmdunused43 = ''; + RsCILCmdunused44 = ''; + RsCILCmdunused45 = ''; + RsCILCmdunused46 = ''; + RsCILCmdunused47 = ''; + RsCILCmdunused48 = ''; + RsCILCmdunused49 = ''; + RsCILCmdunused50 = ''; + RsCILCmdunused51 = ''; + RsCILCmdunused52 = ''; + RsCILCmdunused53 = ''; + RsCILCmdunused54 = ''; + RsCILCmdunused55 = ''; + RsCILCmdunused56 = ''; + RsCILCmdunused57 = ''; + RsCILCmdunused58 = ''; + RsCILCmdunused59 = ''; + RsCILCmdunused60 = ''; + RsCILCmdprefix7 = ''; + RsCILCmdprefix6 = ''; + RsCILCmdprefix5 = ''; + RsCILCmdprefix4 = ''; + RsCILCmdprefix3 = ''; + RsCILCmdprefix2 = ''; + RsCILCmdprefix1 = ''; + RsCILCmdprefixref = ''; + RsCILCmdarglist = 'get argument list'; + RsCILCmdceq = 'compare equal'; + RsCILCmdcgt = 'compare greater than'; + RsCILCmdcgtun = 'compare greater than, unsigned or unordered'; + RsCILCmdclt = 'compare less than'; + RsCILCmdcltun = 'compare less than, unsigned or unordered'; + RsCILCmdldftn = 'load method pointer'; + RsCILCmdldvirtftn = 'load a virtual method pointer'; + RsCILCmdunused61 = ''; + RsCILCmdldarg = 'load argument onto the stack'; + RsCILCmdldarga = 'load an argument address'; + RsCILCmdstarg = 'store a value in an argument slot'; + RsCILCmdldloc = 'load local variable onto the stack'; + RsCILCmdldloca = 'load local variable address'; + RsCILCmdstloc = 'pop value from stack to local variable'; + RsCILCmdlocalloc = 'allocate space in the local dynamic memory pool'; + RsCILCmdunused62 = ''; + RsCILCmdendfilter = 'end filter clause of SEH'; + RsCILCmdunaligned = 'pointer instruction may be unaligned'; + RsCILCmdvolatile = 'pointer reference is volatile'; + RsCILCmdtail = 'call terminates current method'; + RsCILCmdinitobj = 'initialize a value type'; + RsCILCmdunused63 = ''; + RsCILCmdcpblk = 'copy data from memory to memory'; + RsCILCmdinitblk = 'initialize a block of memory to a value'; + RsCILCmdunused64 = ''; + RsCILCmdrethrow = 'rethrow the current exception'; + RsCILCmdunused65 = ''; + RsCILCmdsizeof = 'load the size in bytes of a value type'; + RsCILCmdrefanytype = 'load the type out of a typed reference'; + RsCILCmdunused66 = ''; + RsCILCmdunused67 = ''; + RsCILCmdunused68 = ''; + RsCILCmdunused69 = ''; + RsCILCmdunused70 = ''; + + RsCILDescrnop = 'Do nothing'; + RsCILDescrbreak = 'inform a debugger that a breakpoint has been reached.'; + RsCILDescrldarg0 = 'Load argument 0 onto stack'; + RsCILDescrldarg1 = 'Load argument 1 onto stack'; + RsCILDescrldarg2 = 'Load argument 2 onto stack'; + RsCILDescrldarg3 = 'Load argument 3 onto stack'; + RsCILDescrldloc0 = 'Load local variable 0 onto stack.'; + RsCILDescrldloc1 = 'Load local variable 1 onto stack.'; + RsCILDescrldloc2 = 'Load local variable 2 onto stack.'; + RsCILDescrldloc3 = 'Load local variable 3 onto stack.'; + RsCILDescrstloc0 = 'Pop value from stack into local variable 0.'; + RsCILDescrstloc1 = 'Pop value from stack into local variable 1.'; + RsCILDescrstloc2 = 'Pop value from stack into local variable 2.'; + RsCILDescrstloc3 = 'Pop value from stack into local variable 3.'; + RsCILDescrldargs = 'Load argument numbered num onto stack, short form.'; + RsCILDescrldargas = 'fetch the address of argument argNum, short form'; + RsCILDescrstargs = 'Store a value to the argument numbered num, short form'; + RsCILDescrldlocs = 'Load local variable of index indx onto stack, short form.'; + RsCILDescrldlocas = 'Load address of local variable with index indx, short form'; + RsCILDescrstlocs = 'Pop value from stack into local variable indx, short form.'; + RsCILDescrldnull = 'Push null reference on the stack'; + RsCILDescrldci4m1 = 'Push -1 onto the stack as int32.'; + RsCILDescrldci40 = 'Push 0 onto the stack as int32.'; + RsCILDescrldci41 = 'Push 1 onto the stack as int32.'; + RsCILDescrldci42 = 'Push 2 onto the stack as int32.'; + RsCILDescrldci43 = 'Push 3 onto the stack as int32.'; + RsCILDescrldci44 = 'Push 4 onto the stack as int32.'; + RsCILDescrldci45 = 'Push 5 onto the stack as int32.'; + RsCILDescrldci46 = 'Push 6 onto the stack as int32.'; + RsCILDescrldci47 = 'Push 7 onto the stack as int32.'; + RsCILDescrldci48 = 'Push 8 onto the stack as int32.'; + RsCILDescrldci4s = 'Push num onto the stack as int32, short form.'; + RsCILDescrldci4 = 'Push num of type int32 onto the stack as int32.'; + RsCILDescrldci8 = 'Push num of type int64 onto the stack as int64.'; + RsCILDescrldcr4 = 'Push num of type float32 onto the stack as F.'; + RsCILDescrldcr8 = 'Push num of type float64 onto the stack as F.'; + RsCILDescrunused1 = ''; + RsCILDescrdup = 'duplicate value on the top of the stack'; + RsCILDescrpop = 'pop a value from the stack'; + RsCILDescrjmp = 'Exit current method and jump to specified method'; + RsCILDescrcall = 'Call method described by method'; + RsCILDescrcalli = 'Call method indicated on the stack with arguments described by callsitedescr.'; + RsCILDescrret = 'Return from method, possibly returning a value'; + RsCILDescrbrs = 'branch to target, short form'; + RsCILDescrbrfalses = 'branch to target if value is zero (false), short form'; + RsCILDescrbrtrues = 'branch to target if value is non-zero (true), short form'; + RsCILDescrbeqs = 'branch to target if equal, short form'; + RsCILDescrbges = 'branch to target if greater than or equal to, short form'; + RsCILDescrbgts = 'branch to target if greater than, short form'; + RsCILDescrbles = 'branch to target if less than or equal to, short form'; + RsCILDescrblts = 'branch to target if less than'; + RsCILDescrbneuns = 'branch to target if unequal or unordered, short form'; + RsCILDescrbgeuns = 'branch to target if greater than or equal to (unsigned or unordered), short form'; + RsCILDescrbgtuns = 'branch to target if greater than (unsigned or unordered), short form'; + RsCILDescrbleuns = 'branch to target if less than or equal to (unsigned or unordered), short form'; + RsCILDescrbltuns = 'Branch to target if less than (unsigned or unordered), short form'; + RsCILDescrbr = 'branch to target '; + RsCILDescrbrfalse = 'branch to target if value is zero (false)'; + RsCILDescrbrtrue = 'branch to target if value is non-zero (true)'; + RsCILDescrbeq = 'branch to target if equal'; + RsCILDescrbge = 'branch to target if greater than or equal to'; + RsCILDescrbgt = 'branch to target if greater than'; + RsCILDescrble = 'branch to target if less than or equal to'; + RsCILDescrblt = 'branch to target if less than'; + RsCILDescrbneun = 'branch to target if unequal or unordered'; + RsCILDescrbgeun = 'branch to target if greater than or equal to (unsigned or unordered)'; + RsCILDescrbgtun = 'branch to target if greater than (unsigned or unordered)'; + RsCILDescrbleun = 'branch to target if less than or equal to (unsigned or unordered)'; + RsCILDescrbltun = 'Branch to target if less than (unsigned or unordered) '; + RsCILDescrswitch = 'jump to one of n values'; + RsCILDescrldindi1 = 'Indirect load value of type int8 as int32 on the stack.'; + RsCILDescrldindu1 = 'Indirect load value of type unsigned int8 as int32 on the stack.'; + RsCILDescrldindi2 = 'Indirect load value of type int16 as int32 on the stack.'; + RsCILDescrldindu2 = 'Indirect load value of type unsigned int16 as int32 on the stack.'; + RsCILDescrldindi4 = 'Indirect load value of type int32 as int32 on the stack.'; + RsCILDescrldindu4 = 'Indirect load value of type unsigned int32 as int32 on the stack.'; + RsCILDescrldindi8 = 'Indirect load value of type int64 as int64 on the stack.'; + RsCILDescrldindi = 'Indirect load value of type native int as native int on the stack'; + RsCILDescrldindr4 = 'Indirect load value of type float32 as F on the stack.'; + RsCILDescrldindr8 = 'Indirect load value of type float64 as F on the stack.'; + RsCILDescrldindref = 'Indirect load value of type object ref as O on the stack.'; + RsCILDescrstindref = 'Store value of type object ref (type O) into memory at address'; + RsCILDescrstindi1 = 'Store value of type int8 into memory at address'; + RsCILDescrstindi2 = 'Store value of type int16 into memory at address'; + RsCILDescrstindi4 = 'Store value of type int32 into memory at address'; + RsCILDescrstindi8 = 'Store value of type int64 into memory at address'; + RsCILDescrstindr4 = 'Store value of type float32 into memory at address'; + RsCILDescrstindr8 = 'Store value of type float64 into memory at address'; + RsCILDescradd = 'Add two values, returning a new value'; + RsCILDescrsub = 'Subtract value2 from value1, returning a new value'; + RsCILDescrmul = 'Multiply values'; + RsCILDescrdiv = 'Divide two values to return a quotient or floating-point result'; + RsCILDescrdivun = 'Divide two values, unsigned, returning a quotient'; + RsCILDescrrem = 'Remainder of dividing value1 by value2'; + RsCILDescrremun = 'Remainder of unsigned dividing value1 by value2'; + RsCILDescrand = 'Bitwise AND of two integral values, returns an integral value'; + RsCILDescror = 'Bitwise OR of two integer values, returns an integer.'; + RsCILDescrxor = 'Bitwise XOR of integer values, returns an integer'; + RsCILDescrshl = 'Shift an integer to the left (shifting in zeros)'; + RsCILDescrshr = 'Shift an integer right, (shift in sign), return an integer'; + RsCILDescrshrun = 'Shift an integer right, (shift in zero), return an integer'; + RsCILDescrneg = 'Negate value'; + RsCILDescrnot = 'Bitwise complement'; + RsCILDescrconvi1 = 'Convert to int8, pushing int32 on stack'; + RsCILDescrconvi2 = 'Convert to int16, pushing int32 on stack'; + RsCILDescrconvi4 = 'Convert to int32, pushing int32 on stack'; + RsCILDescrconvi8 = 'Convert to int64, pushing int64 on stack'; + RsCILDescrconvr4 = 'Convert to float32, pushing F on stack'; + RsCILDescrconvr8 = 'Convert to float64, pushing F on stack'; + RsCILDescrconvu4 = 'Convert to unsigned int32, pushing int32 on stack'; + RsCILDescrconvu8 = 'Convert to unsigned int64, pushing int64 on stack'; + RsCILDescrcallvirt = 'Call a method associated with obj'; + RsCILDescrcpobj = 'Copy a value type from srcValObj to destValObj'; + RsCILDescrldobj = 'Copy instance of value type classTok to the stack.'; + RsCILDescrldstr = 'push a string object for the literal string '; + RsCILDescrnewobj = 'allocate an uninitialized object or value type and call ctor '; + RsCILDescrcastclass = 'Cast obj to class'; + RsCILDescrisinst = 'test if object is an instance of class, returning NULL or an instance of that class or interface'; + RsCILDescrconvrun = 'Convert unsigned integer to floating-point, pushing F on stack'; + RsCILDescrunused2 = ''; + RsCILDescrunused3 = ''; + RsCILDescrunbox = 'Extract the value type data from obj, its boxed representation'; + RsCILDescrthrow = 'Throw an exception'; + RsCILDescrldfld = 'Push the value of field of object, or value type, obj, onto the stack'; + RsCILDescrldflda = 'Push the address of field of object obj on the stack'; + RsCILDescrstfld = 'Replace the value of field of the object obj with val'; + RsCILDescrldsfld = 'Push the value of field on the stack'; + RsCILDescrldsflda = 'Push the address of the static field, field, on the stack'; + RsCILDescrstsfld = 'Replace the value of field with val'; + RsCILDescrstobj = 'Store a value of type classTok from the stack into memory'; + RsCILDescrconvovfi1un = 'Convert unsigned to an int8 (on the stack as int32) and throw an exception on overflow'; + RsCILDescrconvovfi2un = 'Convert unsigned to an int16 (on the stack as int32) and throw an exception on overflow'; + RsCILDescrconvovfi4un = 'Convert unsigned to an int32 (on the stack as int32) and throw an exception on overflow'; + RsCILDescrconvovfi8un = 'Convert unsigned to an int64 (on the stack as int64) and throw an exception on overflow'; + RsCILDescrconvovfu1un = 'Convert unsigned to an unsigned int8 (on the stack as int32) and throw an exception on overflow'; + RsCILDescrconvovfu2un = 'Convert unsigned to an unsigned int16 (on the stack as int32) and throw an exception on overflow'; + RsCILDescrconvovfu4un = 'Convert unsigned to an unsigned int32 (on the stack as int32) and throw an exception on overflow'; + RsCILDescrconvovfu8un = 'Convert unsigned to an unsigned int64 (on the stack as int64) and throw an exception on overflow'; + RsCILDescrconvovfiun = 'Convert unsigned to a native int (on the stack as native int) and throw an exception on overflow'; + RsCILDescrconvovfuun = 'Convert unsigned to a native unsigned int (on the stack as native int) and throw an exception on overflow'; + RsCILDescrbox = 'Convert valueType to a true object reference'; + RsCILDescrnewarr = 'create a new array with elements of type etype'; + RsCILDescrldlen = 'push the length (of type native unsigned int) of array on the stack'; + RsCILDescrldelema = 'Load the address of element at index onto the top of the stack'; + RsCILDescrldelemi1 = 'Load the element with type int8 at index onto the top of the stack as an int32'; + RsCILDescrldelemu1 = 'Load the element with type unsigned int8 at index onto the top of the stack as an int32'; + RsCILDescrldelemi2 = 'Load the element with type int16 at index onto the top of the stack as an int32'; + RsCILDescrldelemu2 = 'Load the element with type unsigned int16 at index onto the top of the stack as an int32'; + RsCILDescrldelemi4 = 'Load the element with type int32 at index onto the top of the stack as an int32'; + RsCILDescrldelemu4 = 'Load the element with type unsigned int32 at index onto the top of the stack as an int32 (alias for ldelem.i4)'; + RsCILDescrldelemi8 = 'Load the element with type int64 at index onto the top of the stack as an int64'; + RsCILDescrldelemi = 'Load the element with type native int at index onto the top of the stack as an native int'; + RsCILDescrldelemr4 = 'Load the element with type float32 at index onto the top of the stack as an F'; + RsCILDescrldelemr8 = 'Load the element with type float64 at index onto the top of the stack as an F'; + RsCILDescrldelemref = 'Load the element of type object, at index onto the top of the stack as an O'; + RsCILDescrstelemi = 'Replace array element at index with the i value on the stack'; + RsCILDescrstelemi1 = 'Replace array element at index with the int8 value on the stack'; + RsCILDescrstelemi2 = 'Replace array element at index with the int16 value on the stack'; + RsCILDescrstelemi4 = 'Replace array element at index with the int32 value on the stack'; + RsCILDescrstelemi8 = 'Replace array element at index with the int64 value on the stack'; + RsCILDescrstelemr4 = 'Replace array element at index with the float32 value on the stack'; + RsCILDescrstelemr8 = 'Replace array element at index with the float64 value on the stack'; + RsCILDescrstelemref = 'Replace array element at index with the ref value on the stack'; + RsCILDescrunused4 = ''; + RsCILDescrunused5 = ''; + RsCILDescrunused6 = ''; + RsCILDescrunused7 = ''; + RsCILDescrunused8 = ''; + RsCILDescrunused9 = ''; + RsCILDescrunused10 = ''; + RsCILDescrunused11 = ''; + RsCILDescrunused12 = ''; + RsCILDescrunused13 = ''; + RsCILDescrunused14 = ''; + RsCILDescrunused15 = ''; + RsCILDescrunused16 = ''; + RsCILDescrunused17 = ''; + RsCILDescrunused18 = ''; + RsCILDescrunused19 = ''; + RsCILDescrconvovfi1 = 'Convert to an int8 (on the stack as int32) and throw an exception on overflow '; + RsCILDescrconvovfu1 = 'Convert to a unsigned int8 (on the stack as int32) and throw an exception on overflow '; + RsCILDescrconvovfi2 = 'Convert to an int16 (on the stack as int32) and throw an exception on overflow '; + RsCILDescrconvovfu2 = 'Convert to a unsigned int16 (on the stack as int32) and throw an exception on overflow '; + RsCILDescrconvovfi4 = 'Convert to an int32 (on the stack as int32) and throw an exception on overflow '; + RsCILDescrconvovfu4 = 'Convert to a unsigned int32 (on the stack as int32) and throw an exception on overflow '; + RsCILDescrconvovfi8 = 'Convert to an int64 (on the stack as int64) and throw an exception on overflow '; + RsCILDescrconvovfu8 = 'Convert to a unsigned int64 (on the stack as int64) and throw an exception on overflow '; + RsCILDescrunused20 = ''; + RsCILDescrunused21 = ''; + RsCILDescrunused22 = ''; + RsCILDescrunused23 = ''; + RsCILDescrunused24 = ''; + RsCILDescrunused25 = ''; + RsCILDescrunused26 = ''; + RsCILDescrrefanyval = 'Push the address stored in a typed reference'; + RsCILDescrckfinite = 'throw ArithmeticException if value is not a finite number'; + RsCILDescrunused27 = ''; + RsCILDescrunused28 = ''; + RsCILDescrmkrefany = 'push a typed reference to ptr of type class onto the stack'; + RsCILDescrunused29 = ''; + RsCILDescrunused30 = ''; + RsCILDescrunused31 = ''; + RsCILDescrunused32 = ''; + RsCILDescrunused33 = ''; + RsCILDescrunused34 = ''; + RsCILDescrunused35 = ''; + RsCILDescrunused36 = ''; + RsCILDescrunused37 = ''; + RsCILDescrldtoken = 'Convert metadata token to its runtime representation'; + RsCILDescrconvu2 = 'Convert to unsigned int16, pushing int32 on stack'; + RsCILDescrconvu1 = 'Convert to unsigned int8, pushing int32 on stack'; + RsCILDescrconvi = 'Convert to native int, pushing native int on stack'; + RsCILDescrconvovfi = 'Convert to an native int (on the stack as native int) and throw an exception on overflow'; + RsCILDescrconvovfu = 'Convert to a native unsigned int (on the stack as native int) and throw an exception on overflow'; + RsCILDescraddovf = 'Add signed integer values with overflow check. '; + RsCILDescraddovfun = 'Add unsigned integer values with overflow check.'; + RsCILDescrmulovf = 'Multiply signed integer values. Signed result must fit in same size'; + RsCILDescrmulovfun = 'Multiply unsigned integer values. Unsigned result must fit in same size'; + RsCILDescrsubovf = 'Subtract native int from an native int. Signed result must fit in same size'; + RsCILDescrsubovfun = 'Subtract native unsigned int from a native unsigned int. Unsigned result must fit in same size'; + RsCILDescrendfinally = 'End finally clause of an exception block'; + RsCILDescrleave = 'Exit a protected region of code.'; + RsCILDescrleaves = 'Exit a protected region of code, short form'; + RsCILDescrstindi = 'Store value of type native int into memory at address'; + RsCILDescrconvu = 'Convert to native unsigned int, pushing native int on stack'; + RsCILDescrunused38 = ''; + RsCILDescrunused39 = ''; + RsCILDescrunused40 = ''; + RsCILDescrunused41 = ''; + RsCILDescrunused42 = ''; + RsCILDescrunused43 = ''; + RsCILDescrunused44 = ''; + RsCILDescrunused45 = ''; + RsCILDescrunused46 = ''; + RsCILDescrunused47 = ''; + RsCILDescrunused48 = ''; + RsCILDescrunused49 = ''; + RsCILDescrunused50 = ''; + RsCILDescrunused51 = ''; + RsCILDescrunused52 = ''; + RsCILDescrunused53 = ''; + RsCILDescrunused54 = ''; + RsCILDescrunused55 = ''; + RsCILDescrunused56 = ''; + RsCILDescrunused57 = ''; + RsCILDescrunused58 = ''; + RsCILDescrunused59 = ''; + RsCILDescrunused60 = ''; + RsCILDescrprefix7 = ''; + RsCILDescrprefix6 = ''; + RsCILDescrprefix5 = ''; + RsCILDescrprefix4 = ''; + RsCILDescrprefix3 = ''; + RsCILDescrprefix2 = ''; + RsCILDescrprefix1 = ''; + RsCILDescrprefixref = ''; + RsCILDescrarglist = 'return argument list handle for the current method '; + RsCILDescrceq = 'push 1 (of type int32) if value1 equals value2, else 0'; + RsCILDescrcgt = 'push 1 (of type int32) if value1 > value2, else 0'; + RsCILDescrcgtun = 'push 1 (of type int32) if value1 > value2, unsigned or unordered, else 0'; + RsCILDescrclt = 'push 1 (of type int32) if value1 < value2, else 0'; + RsCILDescrcltun = 'push 1 (of type int32) if value1 < value2, unsigned or unordered, else 0'; + RsCILDescrldftn = 'Push a pointer to a method referenced by method on the stack'; + RsCILDescrldvirtftn = 'Push address of virtual method mthd on the stack'; + RsCILDescrunused61 = ''; + RsCILDescrldarg = 'Load argument numbered num onto stack.'; + RsCILDescrldarga = 'fetch the address of argument argNum.'; + RsCILDescrstarg = 'Store a value to the argument numbered num'; + RsCILDescrldloc = 'Load local variable of index indx onto stack.'; + RsCILDescrldloca = 'Load address of local variable with index indx'; + RsCILDescrstloc = 'Pop value from stack into local variable indx.'; + RsCILDescrlocalloc = 'Allocate space from the local memory pool.'; + RsCILDescrunused62 = ''; + RsCILDescrendfilter = 'End filter clause of SEH exception handling'; + RsCILDescrunaligned = 'Subsequent pointer instruction may be unaligned'; + RsCILDescrvolatile = 'Subsequent pointer reference is volatile'; + RsCILDescrtail = 'Subsequent call terminates current method'; + RsCILDescrinitobj = 'Initialize a value type'; + RsCILDescrunused63 = ''; + RsCILDescrcpblk = 'Copy data from memory to memory'; + RsCILDescrinitblk = 'Set a block of memory to a given byte'; + RsCILDescrunused64 = ''; + RsCILDescrrethrow = 'Rethrow the current exception'; + RsCILDescrunused65 = ''; + RsCILDescrsizeof = 'Push the size, in bytes, of a value type as a unsigned int32'; + RsCILDescrrefanytype = 'Push the type token stored in a typed reference'; + RsCILDescrunused66 = ''; + RsCILDescrunused67 = ''; + RsCILDescrunused68 = ''; + RsCILDescrunused69 = ''; + RsCILDescrunused70 = ''; + +//=== JclCLR ================================================================= +resourcestring + RsClrCopyright = '// Delphi-JEDI .NET Framework IL Disassembler. Version 0.1' + sLineBreak + + '// Project JEDI Code Library (JCL) Team. All rights reserved.' + sLineBreak; + RsUnknownTableFmt = '%s%s'; + RsUnknownTable = 'Unknown table - '; + +//=== JclCOM ================================================================= +resourcestring + RsComInvalidParam = 'An invalid parameter was passed to the routine. If a parameter was ' + + 'expected, it might be an unassigned item or nil pointer'; + RsComFailedStreamRead = 'Failed to read all of the data from the specified stream'; + RsComFailedStreamWrite = 'Failed to write all of the data into the specified stream'; + +//=== JclComplex ============================================================= +resourcestring + RsComplexInvalidString = 'Failed to create a complex number from the string provided'; + +//=== JclCompression ========================================================= +resourcestring + RsCompressionReadNotSupported = 'read is not an supported operation.'; + RsCompressionWriteNotSupported = 'write is not an supported operation.'; + RsCompressionResetNotSupported = 'reset is not an supported operation.'; + RsCompressionSeekNotSupported = 'seek is not an supported operation.'; + RsCompressionZLibZErrNo = 'zlib returned: ERRNO'; + RsCompressionZLibZStreamError = 'zlib returned: Stream error'; + RsCompressionZLibZDataError = 'zlib returned: data error'; + RsCompressionZLibZMemError = 'zlib returned: memory error'; + RsCompressionZLibZBufError = 'zlib returned: buffer error'; + RsCompressionZLibZVersionError = 'zlib returned: version error'; + RsCompressionZLibError = 'zLib returned: unknown error (%d)'; + RsCompressionGZIPInvalidID = 'gzip: Invalid ID (ID1=%.2x; ID2=%.2x)'; + RsCompressionGZIPUnsupportedCM = 'gzip: unsupported compression method (%d)'; + RsCompressionGZIPHeaderCRC = 'gzip: CRC failed, header is damaged'; + RsCompressionGZIPDecompressing = 'gzip: this property is not readable when the data are being decompressed'; + RsCompressionGZIPNotDecompressed = 'gzip: this property is not readable until the data are fully decompressed'; + RsCompressionGZIPDataTruncated = 'gzip: data are truncated'; + RsCompressionGZIPInternalError = 'gzip: internal error'; + RsCompressionGZIPDataCRCFailed = 'gzip: CRC failed, data are damaged'; + RsCompressionGZIPExtraFieldTooLong = 'gzip: extra field is too long'; + RsCompressionGZIPBadString = 'gzip: the string contains null chars'; + RsCompressionBZIP2SequenceError = 'bzip2 returned: sequence error'; + RsCompressionBZIP2ParameterError = 'bzip2 returned: parameter error'; + RsCompressionBZIP2MemoryError = 'bzip2 returned: memory error'; + RsCompressionBZIP2DataError = 'bzip2 returned: data error'; + RsCompressionBZIP2HeaderError = 'bzip2 returned: header error'; + RsCompressionBZIP2IOError = 'bzip2 returned: IO error'; + RsCompressionBZIP2EOFError = 'bzip2 returned: unexpected end of file'; + RsCompressionBZIP2OutBuffError = 'bzip2 returned: out buffer is too small'; + RsCompressionBZIP2ConfigError = 'bzip2 returned: configuration error'; + RsCompressionBZIP2Error = 'bzip2 returned: unknown error (%d)'; + RsCompressionUnavailableProperty = 'Property is not available'; + RsCompressionCompressingError = 'Operation is not supported while compressing'; + RsCompressionDecompressingError = 'Operation is not supported while decompressing'; + RsCompressionNoFileName = 'File name not supplied'; + RsCompressionUnsupportedMethod = 'Unsupported method'; + RsCompressionDataError = 'Data error'; + RsCompressionCRCError = 'CRC error'; + RsCompressionNoNestedArchive = 'Nested archive is not supported'; + RsCompressionUnknownError = 'Unknown error'; + RsCompression7zLoadError = 'Sevenzip: Failed to load 7z.dll'; + RsCompression7zReturnError = 'Sevenzip: Error result (%.8x) "%s"'; + RsCompression7zOutArchiveError = 'Sevenzip: Failed to get out archive interface for class %s'; + RsCompression7zInArchiveError = 'Sevenzip: Failed to get in archive interface for class %s'; + RsCompression7zUnknownValueType = 'Sevenzip: Unknown value type (%d) for property ID %d'; + RsCompression7zOnlyCurrentFile = 'Sevenzip: Only properties for current file can be retreived'; + RsCompression7zWindows = 'Windows'; + RsCompression7zUnix = 'Unix'; + RsCompressionZipName = 'Zip archive'; + RsCompressionZipExtensions = '*.zip;' + // Basic ZIP file + '*.jar;*.ear;*.war;' + // JAVA files + '*.cbz;' + //Comic reader files - ZIP version + '*.apk;' + // Android application package + '*.wsz;*.wal;' + // Winamp Skins + '*.xpi;*.crx;' + // Firefox, Chrome extensions + '*.dfsz;' + // ??? + '*.pcv;' + // MozBackup file + '*.bsz;' + // BSplayer skin + '*.mskin;' + // Maxthon skin + '*.wmz;' + // Windows Media Player skin + '*.ipa;' + // iPhone/iPad application + '*.docx;*.xlsx;*.pptx;' + // MsOffice + '*.sxw;*.sxi;*.sxt;*.sxd;*.sxc;*.sxm;*.sxg;*.stw;*.sti;*.std;*.stc;' + // OpenOffice.org 1.x documents and templates + '*.odh;*.odd;*.odt;*.odm;*.ods;*.ots;*.odg;*.otg;*.odp;*.otp;*.odf;*.odb'; // OpenOffice.org 2.x/3.x docs and templates + RsCompressionBZip2Name = 'BZip2 archive'; + RsCompressionBZip2Extensions = '*.bz2;*.bzip2;*.tbz2;*.tbz'; + RsCompressionBZip2SubExtensions = '.tbz2=.tar;.tbz=.tar'; + RsCompressionRarName = 'Rar archive'; + RsCompressionRarExtensions = '*.rar;*.r00;'+ + '*.cbr'; // Comic reader file - RAR version + RsCompressionArjName = 'Arj archive'; + RsCompressionArjExtensions = '*.arj'; + RsCompressionZName = 'Z archive'; + RsCompressionZExtensions = '*.z;*.taz'; + RsCompressionZSubExtensions = '.taz=.tar'; + RsCompressionLzhName = 'Lzh archive'; + RsCompressionLzhExtensions = '*.lzh;*.lha'; + RsCompression7zName = '7z archive'; + RsCompression7zExtensions = '*.7z'; + RsCompressionCabName = 'Cab archive'; + RsCompressionCabExtensions = '*.cab;'+ + '*.fwp'; // FrontPage Web Package + RsCompressionNsisName = 'Nsis archive'; + RsCompressionNsisExtensions = '*.nsis'; + RsCompressionLzmaName = 'Lzma archive'; + RsCompressionLzmaExtensions = '*.lzma'; + RsCompressionLzma86Name = 'Lzma86 archive'; + RsCompressionLzma86Extensions = '*.lzma86'; + RsCompressionPeName = 'Pe archive'; + RsCompressionPeExtensions = '*.exe;*.dll;*.sys;*.bpl'; + RsCompressionElfName = 'Elf archive'; + // TODO: extension might be *.*, but then TJclCompressionStreamFormats.FindDecompressFormat can fail + RsCompressionElfExtensions = '*.'; + RsCompressionMachoName = 'Mach-O archive'; + // TODO: extension might be *.*, but then TJclCompressionStreamFormats.FindDecompressFormat can fail + RsCompressionMachoExtensions = '*.'; + RsCompressionUdfName = 'Udf archive'; + RsCompressionUdfExtensions = '*.iso;*.img'; + RsCompressionXarName = 'Xar archive'; + RsCompressionXarExtensions = '*.xar;'+ + '*.safariextz'; // Safari extensions + RsCompressionMubName = 'Mub archive'; + // TODO: extension might be *.*, but then TJclCompressionStreamFormats.FindDecompressFormat can fail + RsCompressionMubExtensions = '*.'; + RsCompressionHfsName = 'Hfs archive'; + RsCompressionHfsExtensions = '*.hfs'; + RsCompressionDmgName = 'Dmg archive'; + RsCompressionDmgExtensions = '*.dmg'; + RsCompressionCompoundName = 'Compound archive'; + RsCompressionCompoundExtensions = '*.msi;*.msp;*.doc;*.xls;*.ppt'; + RsCompressionWimName = 'Wim archive'; + RsCompressionWimExtensions = '*.wim;*.swm'; + RsCompressionIsoName = 'Iso archive'; + RsCompressionIsoExtensions = '*.iso;*.img'; + RsCompressionChmName = 'Chm archive'; + RsCompressionChmExtensions = '*.chm;*.chi;*.chq;*.chw;*.hxs;*.hxi;*.hxr;*.hxq;*.hxw;*.lit'; + RsCompressionSplitName = 'Split archive'; + RsCompressionSplitExtensions = '*.001'; + RsCompressionRpmName = 'Rpm archive'; + RsCompressionRpmExtensions = '*.rpm'; + RsCompressionDebName = 'Deb archive'; + RsCompressionDebExtensions = '*.deb'; + RsCompressionCpioName = 'Cpio archive'; + RsCompressionCpioExtensions = '*.cpio'; + RsCompressionTarName = 'Tar archive'; + RsCompressionTarExtensions = '*.tar'; + RsCompressionGZipName = 'GZip archive'; + RsCompressionGZipExtensions = '*.gz;*.gzip;*.tgz;*.tpz'; + RsCompressionGZipSubExtensions = '.tgz=.tar;.tpz=.tar'; + RsCompressionXzName = 'Xz archive'; + RsCompressionXzExtensions = '*.xz;*.txz'; + RsCompressionXzSubExtensions = '.txz=.tar'; + RsCompressionNtfsName = 'Ntfs archive'; + RsCompressionNtfsExtensions = '*.ntfs;*.img'; + RsCompressionFatName = 'Fat archive'; + RsCompressionFatExtensions = '*.fat;*.img'; + RsCompressionMbrName = 'Mbr archive'; + RsCompressionMbrExtensions = '*.mbr'; + RsCompressionVhdName = 'Vhd archive'; + RsCompressionVhdExtensions = '*.vhd'; + RsCompressionVhdSubExtensions = '.vhd=.mbr'; + RsCompressionFlvName = 'Flv archive'; + RsCompressionFlvExtensions = '*.flv'; + RsCompressionMsLZName = 'MsLZ archive'; + // TODO: extension might be *.*, but then TJclCompressionStreamFormats.FindDecompressFormat can fail + RsCompressionMsLZExtensions = '*.'; + RsCompressionSwfName = 'Swf archive'; + RsCompressionSwfExtensions = '*.swf'; + RsCompressionSwfcName = 'Swf archive'; + RsCompressionSwfcExtensions = '*.swf'; + RsCompressionApmName = 'APM archive'; + RsCompressionApmExtensions = '*.'; + RsCompressionPpmdName = 'PPMD archive'; + RsCompressionPpmdExtensions = '*.pmd'; + RsCompressionTEName = 'Terse Executable'; + RsCompressionTEExtensions = '*.te'; + RsCompressionUEFIcName = 'UEFIc archive'; + RsCompressionUEFIcExtensions = '*.scap'; + RsCompressionUEFIsName = 'UEFIs archive'; + RsCompressionUEFIsExtensions = '*.'; + RsCompressionSquashFSName = 'SquashFS archive'; + RsCompressionSquashFSExtensions = '*.squashfs'; + RsCompressionCramFSName = 'CramFS archive'; + RsCompressionCramFSExtensions = '*.cramfs'; + RsCompressionDuplicate = 'The file %s already exists in the archive'; + RsCompressionReplaceError = 'At least one compression volume could not be replaced after an archive out-of-place update'; + +//=== JclConsole ============================================================= +resourcestring + RsCannotRaiseSignal = 'Cannot raise %s signal.'; + +//=== JclContainerIntf ======================================================= +resourcestring + RsEOutOfBounds = 'Out of bounds'; + RsEOperationNotSupported = 'Operation not supported'; + RsEValueNotFound = 'Value %s not found'; + RsEDuplicateElement = 'Duplicate element'; + RsENoCollection = 'Collection not assigned'; + RsEIllegalQueueCapacity = 'Illegal queue capacity'; + RsEIllegalStateOperation = 'Illegal state operation'; + RsENoEqualityComparer = 'Item equality comparer is not assigned'; + RsENoComparer = 'Item comparer is not assigned'; + RsENoHashConverter = 'Hash converter is not assigned'; + RsEAssignError = 'Assignation error'; + RsEReadOnlyError = 'Container is read-only'; + +//=== JclCounter ============================================================= +resourcestring + RsNoCounter = 'No high performance counters supported'; + +//=== JclDateTime ============================================================ +resourcestring + RsMakeUTCTime = 'Error converting to UTC time. Time zone could not be determined'; + RsDateConversion = 'Error illegal date or time format'; + +//=== JclDebug =============================================================== +resourcestring + RsUnknownFunctionAt = 'Unknown function at %s'; + +//=== JclCppException ======================================================== +resourcestring + RsCppUnhandledExceptionMsg = 'Unhandled C++ exception of type ''%s'' occurred'; + +//=== JclDotNet ============================================================== +resourcestring + RsEUnknownCLRVersion = '"%s" is not a known CLR version'; + +//=== JclExprEval ============================================================ +resourcestring + RsExprEvalRParenExpected = 'Parse error: '')'' expected'; + RsExprEvalFactorExpected = 'Parse error: Factor expected'; + RsExprEvalUnknownSymbol = 'Parse error: Unknown symbol: ''%s'''; + + RsExprEvalFirstArg = 'Parse error: ''('' and function''s first parameter expected'; + RsExprEvalNextArg = 'Parse error: '','' and another parameter expected'; + RsExprEvalEndArgs = 'Parse error: '')'' to close function''s parameters expected'; + + RsExprEvalExprNotFound = 'Expression compiler error: Expression ''%s'' not found'; + RsExprEvalExprPtrNotFound = 'Expression compiler error: Expression pointer not found'; + RsExprEvalExprRefCountAssertion = 'Expression compiler error: expression refcount < 0'; + +//=== JclFileUtils =========================================================== +resourcestring + // Path manipulation + RsPathInvalidDrive = '%s is not a valid drive'; + + // Files and directories + RsFileUtilsAttrUnavailable = 'Unable to retrieve attributes of %s'; + + RsCannotCreateDir = 'Unable to create directory'; + RsDelTreePathIsEmpty = 'DelTree: Path is empty'; + RsFileSearchAttrInconsistency = 'Some file search attributes are required AND rejected!'; + RsEWindowsVersionNotSupported = 'This windows version is not supported'; + RsEWindowNotValid = 'The window with handle %d is not valid'; + RsEProcessNotValid = 'The process with ID %d is not valid'; + RsEModuleNotValid = 'The Module with handle %d is not valid'; + + // TJclFileVersionInfo + RsFileUtilsNoVersionInfo = 'File contains no version information'; + RsFileUtilsFileDoesNotExist = 'The file %s does not exist'; + RsFileUtilsLanguageIndex = 'Illegal language index'; + RsFileUtilsEmptyValue = 'No value was supplied'; + RsFileUtilsValueNotFound = 'The value %s was not found.'; + // Strings returned from OSIdentTOString() + RsVosUnknown = 'Unknown'; + RsVosDos = 'MS-DOS'; + RsVosOS216 = '16-bit OS/2'; + RsVosOS232 = '32-bit OS/2'; + RsVosNT = 'Windows NT'; + RsVosWindows16 = '16-bit Windows'; + RsVosPM16 = '16-bit PM'; + RsVosPM32 = '32-bit PM'; + RsVosWindows32 = '32-bit Windows'; + RsVosDosWindows16 = '16-bit Windows, running on MS-DOS'; + RsVosDosWindows32 = 'Win32 API, running on MS-DOS'; + RsVosOS216PM16 = '16-bit PM, running on 16-bit OS/2'; + RsVosOS232PM32 = '32-bit PM, running on 32-bit OS/2'; + RsVosNTWindows32 = 'Win32 API, running on Windows/NT'; + RsVosDesignedFor = 'Designed for %s'; + + // Strings returned from OSFileTypeToString() + RsVftUnknown = 'Unknown'; + RsVftApp = 'Application'; + RsVftDll = 'Library'; + RsVftDrv = 'Driver'; + RsVftFont = 'Font'; + RsVftVxd = 'Virtual device'; + RsVftStaticLib = 'Static-link library'; + RsVft2DrvPRINTER = 'Printer'; + RsVft2DrvKEYBOARD = 'Keyboard'; + RsVft2DrvLANGUAGE = 'Language'; + RsVft2DrvDISPLAY = 'Display'; + RsVft2DrvMOUSE = 'Mouse'; + RsVft2DrvNETWORK = 'Network'; + RsVft2DrvSYSTEM = 'System'; + RsVft2DrvINSTALLABLE = 'Installable'; + RsVft2DrvSOUND = 'Sound'; + RsVft2DrvCOMM = 'Communications'; + RsVft2FontRASTER = 'Raster'; + RsVft2FontVECTOR = 'Vector'; + RsVft2FontTRUETYPE = 'TrueType'; + + // TJclFileStream + RsFileStreamCreate = 'Unable to create temporary file stream'; + + // TJclFileMapping + RsCreateFileMapping = 'Failed to create FileMapping'; + RsCreateFileMappingView = 'Failed to create FileMappingView'; + RsLoadFromStreamSize = 'Not enough space in View in procedure LoadFromStream'; + RsFileMappingInvalidHandle = 'Invalid file handle'; + RsViewNeedsMapping = 'FileMap argument of TJclFileMappingView constructor cannot be nil'; + RsFailedToObtainSize = 'Failed to obtain size of file'; + + // GetDriveTypeStr() + RsUnknownDrive = 'Unknown drive type'; + RsRemovableDrive = 'Removable Drive'; + RsHardDisk = 'Hard Disk'; + RsRemoteDrive = 'Remote Drive'; + RsCDRomDrive = 'CD-ROM'; + RsRamDisk = 'RAM-Disk'; + + // GetFileAttributeList() + RsAttrDirectory = 'Directory'; + RsAttrReadOnly = 'ReadOnly'; + RsAttrSystemFile = 'SystemFile'; + RsAttrVolumeID = 'Volume ID'; + RsAttrArchive = 'Archive'; + RsAttrAnyFile = 'AnyFile'; + RsAttrHidden = 'Hidden'; + + // GetFileAttributeListEx() + RsAttrNormal = 'Normal'; + RsAttrTemporary = 'Temporary'; + RsAttrCompressed = 'Compressed'; + RsAttrOffline = 'Offline'; + RsAttrEncrypted = 'Encrypted'; + RsAttrReparsePoint = 'Reparse Point'; + RsAttrSparseFile = 'Sparse'; + + // TJclFileMapping.Create + RsFileMappingOpenFile = 'Unable to open the file'; + + // TJclMappedTextReader + RsFileIndexOutOfRange = 'Index of out range'; + + // FileGetTypeName() + RsDefaultFileTypeName = ' File'; + +//=== JclMapi ================================================================ +resourcestring + RsMapiError = 'MAPI Error: (%d) "%s"'; + RsMapiMissingExport = 'Function "%s" is not exported by client'; + RsMapiInvalidIndex = 'Index is out ot range'; + RsMapiMailNoClient = 'No Simple MAPI client installed, cannot send the message'; + + RsMapiErrUSER_ABORT = 'User abort'; + RsMapiErrFAILURE = 'General MAPI failure'; + RsMapiErrLOGIN_FAILURE = 'MAPI login failure'; + RsMapiErrDISK_FULL = 'Disk full'; + RsMapiErrINSUFFICIENT_MEMORY = 'Insufficient memory'; + RsMapiErrACCESS_DENIED = 'Access denied'; + RsMapiErrTOO_MANY_SESSIONS = 'Too many sessions'; + RsMapiErrTOO_MANY_FILES = 'Too many files were specified'; + RsMapiErrTOO_MANY_RECIPIENTS = 'Too many recipients were specified'; + RsMapiErrATTACHMENT_NOT_FOUND = 'A specified attachment was not found'; + RsMapiErrATTACHMENT_OPEN_FAILURE = 'Attachment open failure'; + RsMapiErrATTACHMENT_WRITE_FAILURE = 'Attachment write failure'; + RsMapiErrUNKNOWN_RECIPIENT = 'Unknown recipient'; + RsMapiErrBAD_RECIPTYPE = 'Bad recipient type'; + RsMapiErrNO_MESSAGES = 'No messages'; + RsMapiErrINVALID_MESSAGE = 'Invalid message'; + RsMapiErrTEXT_TOO_LARGE = 'Text too large'; + RsMapiErrINVALID_SESSION = 'Invalid session'; + RsMapiErrTYPE_NOT_SUPPORTED = 'Type not supported'; + RsMapiErrAMBIGUOUS_RECIPIENT = 'A recipient was specified ambiguously'; + RsMapiErrMESSAGE_IN_USE = 'Message in use'; + RsMapiErrNETWORK_FAILURE = 'Network failure'; + RsMapiErrINVALID_EDITFIELDS = 'Invalid edit fields'; + RsMapiErrINVALID_RECIPS = 'Invalid recipients'; + RsMapiErrNOT_SUPPORTED = 'Not supported'; + + RsMapiMailORIG = 'From'; + RsMapiMailTO = 'To'; + RsMapiMailCC = 'Cc'; + RsMapiMailBCC = 'Bcc'; + RsMapiMailSubject = 'Subject'; + +//=== JclMath ================================================================ +resourcestring + RsMathDomainError = 'Domain check failure in JclMath'; + RsEmptyArray = 'Empty array is not allowed as input parameter'; + RsNonPositiveArray = 'Input array contains non-positive or zero values'; + RsUnexpectedValue = 'Unexpected data value'; + RsInvalidRational = 'Invalid rational number'; + RsDivByZero = 'Division by zero'; + RsRationalDivByZero = 'Rational division by zero'; + RsNoNaN = 'NaN expected'; + RsNaNTagError = 'NaN Tag value %d out of range'; + RsNaNSignal = 'NaN signaling %d'; + RsPowerInfinite = 'Power function: Result is infinite'; + RsPowerComplex = 'Power function: Result is complex'; + +//=== JclMetadata ============================================================ +resourcestring + RsUnknownClassLayout = 'Unknown class layout - $%.8x'; + RsUnknownStringFormatting = 'Unknown string formatting - $%.8x'; + RsInvalidSignatureData = 'Invalid compressed signature data - %.2x %.2x %.2x %.2x'; + RsUnknownManifestResource = 'Unknown manifest resource visibility - %d'; + RsNoLocalVarSig = 'Signature %s is not LocalVarSig'; + RsLocalVarSigOutOfRange = 'LocalVarSig count %d is out of range [1..$$FFFE]'; + +//=== JclMIDI ================================================================ +resourcestring + RsOctaveC = 'C'; + RsOctaveCSharp = 'C#'; + RsOctaveD = 'D'; + RsOctaveDSharp = 'D#'; + RsOctaveE = 'E'; + RsOctaveF = 'F'; + RsOctaveFSharp = 'F#'; + RsOctaveG = 'G'; + RsOctaveGSharp = 'G#'; + RsOctaveA = 'A'; + RsOctaveASharp = 'A#'; + RsOctaveB = 'B'; + + RsMidiInvalidChannelNum = 'Invalid MIDI channel number (%d)'; + {$IFDEF UNIX} + RsMidiNotImplemented = 'JclMidi: MIDI I/O for Unix not (yet) implemented'; + {$ENDIF UNIX} + +//=== JclMiscel ============================================================== +resourcestring + // CreateProcAsUser + RsCreateProcNTRequiredError = 'Windows NT required'; + RsCreateProcBuild1057Error = 'NT version 3.51 build 1057 or later required'; + + RsCreateProcPrivilegeMissing = 'This account does not have the privilege "%s" (%s)'; + RsCreateProcLogonUserError = 'LogonUser failed'; + RsCreateProcAccessDenied = 'Access denied'; + RsCreateProcLogonFailed = 'Unable to logon'; + RsCreateProcSetStationSecurityError = 'Cannot set WindowStation "%s" security.'; + RsCreateProcSetDesktopSecurityError = 'Cannot set Desktop "%s" security.'; + RsCreateProcPrivilegesMissing = 'This account does not have one (or more) of ' + + 'the following privileges: ' + '"%s"(%s)' + sLineBreak + '"%s"(%s)' + sLineBreak; + RsCreateProcCommandNotFound = 'Command or filename not found: "%s"'; + RsCreateProcFailed = 'CreateProcessAsUser failed'; + +//=== JclMultimedia ========================================================== +resourcestring + // Multimedia timer + RsMmTimerGetCaps = 'Error retrieving multimedia timer device capabilities'; + RsMmSetEvent = 'Error setting multimedia event timer'; + RsMmInconsistentId = 'Multimedia timer callback was called with inconsistent Id'; + RsMmTimerActive = 'This operation cannot be performed while the timer is active'; + + // Audio Mixer + RsMmMixerSource = 'Source'; + RsMmMixerDestination = 'Destination'; + RsMmMixerUndefined = 'Undefined'; + RsMmMixerDigital = 'Digital'; + RsMmMixerLine = 'Line'; + RsMmMixerMonitor = 'Monitor'; + RsMmMixerSpeakers = 'Speakers'; + RsMmMixerHeadphones = 'Headphones'; + RsMmMixerTelephone = 'Telephone'; + RsMmMixerWaveIn = 'Waveform-audio input'; + RsMmMixerVoiceIn = 'Voice input'; + RsMmMixerMicrophone = 'Microphone'; + RsMmMixerSynthesizer = 'Synthesizer'; + RsMmMixerCompactDisc = 'Compact disc'; + RsMmMixerPcSpeaker = 'PC speaker'; + RsMmMixerWaveOut = 'Waveform-audio output'; + RsMmMixerAuxiliary = 'Auxiliary audio line'; + RsMmMixerAnalog = 'Analog'; + RsMmMixerNoDevices = 'No mixer device found'; + RsMmMixerCtlNotFound = 'Line control (%s, %.8x) not found'; + + // EJclMciError + RsMmUnknownError = 'Unknown MCI error No. %d'; + RsMmMciErrorPrefix = 'MCI-Error: '; + + // CD audio routines + RsMmNoCdAudio = 'Cannot open CDAUDIO-Device'; + RsMmCdTrackNo = 'Track: %.2u'; + RsMMCdTimeFormat = '%2u:%.2u'; + RsMMTrackAudio = 'Audio'; + RsMMTrackOther = 'Other'; + +//=== JclNTFS ================================================================ +resourcestring + RsInvalidArgument = '%s: Invalid argument <%s>'; + RsNtfsUnableToDeleteSymbolicLink = 'Unable to delete temporary symbolic link'; + RsEUnableToCreatePropertyStorage = 'Unable to create property storage'; + RsEIncomatibleDataFormat = 'Incompatible data format'; + +//=== JclPCRE ================================================================ +resourcestring + RsErrNoMatch = 'No match'; + RsErrNull = 'Required value is null'; + RsErrBadOption = 'Bad option'; + RsErrBadMagic = 'Bad magic'; + RsErrUnknownNode = 'Unknown node'; + RsErrNoMemory = 'Out of memory'; + RsErrNoSubString = 'No substring'; + RsErrMatchLimit = 'Match limit'; + RsErrCallout = 'Callout'; + RsErrBadUTF8 = 'Bad UTF-8'; + RsErrBadUTF16 = 'Bad UTF-16'; + RsErrBadUTF8Offset = 'Bad UTF-8 offset'; + RsErrBadUTF16Offset = 'Bad UTF-16 offset'; + RsErrPartial = 'Partial'; + RsErrBadPartial = 'Bad partial'; + RsErrInternal = 'Internal'; + RsErrBadCount = 'Bad count'; + RsErrDfaUItem = 'DFA UItem'; + RsErrDfaUCond = 'DFA UCond'; + RsErrDfaUMLimit = 'DFA UMLimit'; + RsErrDfaWSSize = 'DFA WSSize'; + RsErrDfaRecurse = 'DFA Recurse'; + RsErrRecursionLimit = 'Recursion limit'; + RsErrNullWsLimit = 'Null WS limit'; + RsErrBadNewLine = 'Bad new line'; + RsErrBadOffset = 'Bad offset'; + RsErrShortUTF8 = 'Short UTF-8'; + RsErrShortUTF16 = 'Short UTF-16'; + RsErrRecurseLoop = 'Recurse loop'; + RsErrJITStackLimit = 'JIT stack limit'; + RsErrLibNotLoaded = 'PCRE library not loaded'; + RsErrMemFuncNotSet = 'PCRE memory management functions not set'; + RsErrStudyFailed = 'Study failed'; + RsErrCalloutError = 'Unhandled exception in callout'; + RsErrUnknownError = 'Unknown error'; + RsErrNoUTF8Support = 'No UTF-8 support in this version of PCRE'; + RsErrNoUTF16Support = 'No UTF-16 support in this version of PCRE'; + RsErrNoJITSupport = 'No JIT support in this version of PCRE'; + RsErrBadMode = 'Bad Mode'; + RsErrBadEndianness = 'Bad endianness'; + RsErrBadRestart = 'Bad Restart'; + +//=== JclPeImage ============================================================= +resourcestring + RsPeReadOnlyStream = 'Stream is read-only'; + + // TJclPeImage + RsPeCantOpen = 'Cannot open file "%s"'; + RsPeNotPE = 'This is not a PE format'; + RsPeUnknownTarget = 'Unknown PE target'; + RsPeNotResDir = 'Not a resource directory'; + RsPeNotAvailableForAttached = 'Feature is not available for attached images'; + RsPeSectionNotFound = 'Section "%s" not found'; + + // PE directory names + RsPeImg_00 = 'Exports'; + RsPeImg_01 = 'Imports'; + RsPeImg_02 = 'Resources'; + RsPeImg_03 = 'Exceptions'; + RsPeImg_04 = 'Security'; + RsPeImg_05 = 'Base Relocations'; + RsPeImg_06 = 'Debug'; + RsPeImg_07 = 'Description'; + RsPeImg_08 = 'Machine Value'; + RsPeImg_09 = 'TLS'; + RsPeImg_10 = 'Load configuration'; + RsPeImg_11 = 'Bound Import'; + RsPeImg_12 = 'IAT'; + RsPeImg_13 = 'Delay load import'; + RsPeImg_14 = 'COM run-time'; + RsPeImg_Reserved = 'reserved [%.2d]'; + + // NT Header names + RsPeSignature = 'Signature'; + RsPeMachine = 'Machine'; + RsPeNumberOfSections = 'Number of Sections'; + RsPeTimeDateStamp = 'Time Date Stamp'; + RsPePointerToSymbolTable = 'Symbols Pointer'; + RsPeNumberOfSymbols = 'Number of Symbols'; + RsPeSizeOfOptionalHeader = 'Size of Optional Header'; + RsPeCharacteristics = 'Characteristics'; + RsPeMagic = 'Magic'; + RsPeLinkerVersion = 'Linker Version'; + RsPeSizeOfCode = 'Size of Code'; + RsPeSizeOfInitializedData = 'Size of Initialized Data'; + RsPeSizeOfUninitializedData = 'Size of Uninitialized Data'; + RsPeAddressOfEntryPoint = 'Address of Entry Point'; + RsPeBaseOfCode = 'Base of Code'; + RsPeBaseOfData = 'Base of Data'; + RsPeImageBase = 'Image Base'; + RsPeSectionAlignment = 'Section Alignment'; + RsPeFileAlignment = 'File Alignment'; + RsPeOperatingSystemVersion = 'Operating System Version'; + RsPeImageVersion = 'Image Version'; + RsPeSubsystemVersion = 'Subsystem Version'; + RsPeWin32VersionValue = 'Win32 Version'; + RsPeSizeOfImage = 'Size of Image'; + RsPeSizeOfHeaders = 'Size of Headers'; + RsPeCheckSum = 'CheckSum'; + RsPeSubsystem = 'Subsystem'; + RsPeDllCharacteristics = 'Dll Characteristics'; + RsPeSizeOfStackReserve = 'Size of Stack Reserve'; + RsPeSizeOfStackCommit = 'Size of Stack Commit'; + RsPeSizeOfHeapReserve = 'Size of Heap Reserve'; + RsPeSizeOfHeapCommit = 'Size of Heap Commit'; + RsPeLoaderFlags = 'Loader Flags'; + RsPeNumberOfRvaAndSizes = 'Number of RVA'; + + // Load config names + RsPeVersion = 'Version'; + RsPeGlobalFlagsClear = 'GlobalFlagsClear'; + RsPeGlobalFlagsSet = 'GlobalFlagsSet'; + RsPeCriticalSectionDefaultTimeout = 'CriticalSectionDefaultTimeout'; + RsPeDeCommitFreeBlockThreshold = 'DeCommitFreeBlockThreshold'; + RsPeDeCommitTotalFreeThreshold = 'DeCommitTotalFreeThreshold'; + RsPeLockPrefixTable = 'LockPrefixTable'; + RsPeMaximumAllocationSize = 'MaximumAllocationSize'; + RsPeVirtualMemoryThreshold = 'VirtualMemoryThreshold'; + RsPeProcessHeapFlags = 'ProcessHeapFlags'; + RsPeProcessAffinityMask = 'ProcessAffinityMask'; + RsPeCSDVersion = 'CSDVersion'; + RsPeReserved = 'Reserved'; + RsPeEditList = 'EditList'; + + // Machine names + RsPeMACHINE_UNKNOWN = 'Unknown'; + RsPeMACHINE_I386 = 'Intel 386'; + RsPeMACHINE_R3000 = 'MIPS little-endian R3000'; + RsPeMACHINE_R4000 = 'MIPS little-endian R4000'; + RsPeMACHINE_R10000 = 'MIPS little-endian R10000'; + RsPeMACHINE_WCEMIPSV2 = 'MIPS little-endian WCE v2'; + RsPeMACHINE_ALPHA = 'Alpha_AXP'; + RsPeMACHINE_SH3 = 'SH3 little-endian'; + RsPeMACHINE_SH3DSP = 'SH3 DSP'; + RsPeMACHINE_SH3E = 'SH3E little-endian'; + RsPeMACHINE_SH4 = 'SH4 little-endian'; + RsPeMACHINE_SH5 = 'SH5'; + RsPeMACHINE_ARM = 'ARM Little-Endian'; + RsPeMACHINE_THUMB = 'THUMB'; + RsPeMACHINE_AM33 = 'AM33'; + RsPeMACHINE_POWERPC = 'IBM PowerPC Little-Endian'; + RsPeMACHINE_POWERPCFP = 'IBM PowerPC FP'; + RsPeMACHINE_IA64 = 'Intel 64'; + RsPeMACHINE_MIPS16 = 'MIPS16'; + RsPeMACHINE_AMPHA64 = 'ALPHA64'; + RsPeMACHINE_MIPSFPU = 'MIPSFPU'; + RsPeMACHINE_MIPSFPU16 = 'MIPSFPU16'; + RsPeMACHINE_TRICORE = 'Infineon'; + RsPeMACHINE_CEF = 'CEF'; + RsPeMACHINE_EBC = 'EFI Byte Code'; + RsPeMACHINE_AMD64 = 'AMD64 (K8)'; + RsPeMACHINE_M32R = 'M32R little-endian'; + RsPeMACHINE_CEE = 'CEE'; + + // Subsystem names + RsPeSUBSYSTEM_UNKNOWN = 'Unknown'; + RsPeSUBSYSTEM_NATIVE = 'Native'; + RsPeSUBSYSTEM_WINDOWS_GUI = 'GUI'; + RsPeSUBSYSTEM_WINDOWS_CUI = 'Console'; + RsPeSUBSYSTEM_OS2_CUI = 'OS/2'; + RsPeSUBSYSTEM_POSIX_CUI = 'Posix'; + RsPeSUBSYSTEM_RESERVED8 = 'Reserved 8'; + + // Debug symbol type names + RsPeDEBUG_UNKNOWN = 'UNKNOWN'; + RsPeDEBUG_COFF = 'COFF'; + RsPeDEBUG_CODEVIEW = 'CODEVIEW'; + RsPeDEBUG_FPO = 'FPO'; + RsPeDEBUG_MISC = 'MISC'; + RsPeDEBUG_EXCEPTION = 'EXCEPTION'; + RsPeDEBUG_FIXUP = 'FIXUP'; + RsPeDEBUG_OMAP_TO_SRC = 'OMAP_TO_SRC'; + RsPeDEBUG_OMAP_FROM_SRC = 'OMAP_FROM_SRC'; + RsPeDEBUG_BORLAND = 'BORLAND'; + + // TJclPePackageInfo.PackageModuleTypeToString + RsPePkgExecutable = 'Executable'; + RsPePkgPackage = 'Package'; + PsPePkgLibrary = 'Library'; + + // TJclPePackageInfo.PackageOptionsToString + RsPePkgNeverBuild = 'NeverBuild'; + RsPePkgDesignOnly = 'DesignOnly'; + RsPePkgRunOnly = 'RunOnly'; + RsPePkgIgnoreDupUnits = 'IgnoreDupUnits'; + + // TJclPePackageInfo.ProducerToString + RsPePkgV3Produced = 'Delphi 3 or C++ Builder 3'; + RsPePkgProducerUndefined = 'Undefined'; + RsPePkgBCB4Produced = 'C++ Builder 4 or later'; + RsPePkgDelphi4Produced = 'Delphi 4 or later'; + + // TJclPePackageInfo.UnitInfoFlagsToString + RsPePkgMain = 'Main'; + RsPePkgWeak = 'Weak'; + RsPePkgOrgWeak = 'OrgWeak'; + RsPePkgImplicit = 'Implicit'; + +//=== JclRegistry ============================================================ +resourcestring + RsUnableToOpenKeyRead = 'Unable to open key "%s\%s" for read'; + RsUnableToOpenKeyWrite = 'Unable to open key "%s\%s" for write'; + RsUnableToAccessValue = 'Unable to open key "%s\%s" and access value "%s"'; + RsWrongDataType = '"%s\%s\%s" is of wrong kind or size'; + RsInconsistentPath = '"%s" does not match RootKey'; + +//=== JclRTTI ================================================================ +resourcestring + RsRTTISetValueOutOfRange = 'Set value over %s does not fit into a 32-bit integer.'; + RsRTTIValueOutOfRange = 'Value %s out of range %s..%s.'; + RsRTTIUnknownIdentifier = 'Unknown identifier ''%s''.'; + RsRTTIInvalidBaseType = 'Invalid base type (%s is of type %s).'; + RsRTTINoStringValue = 'The property %s of type %s has no string value'; + + RsRTTIVar = 'var '; + RsRTTIConst = 'const '; + RsRTTIArrayOf = 'array of '; + RsRTTIOut = 'out '; + RsRTTIBits = 'bits'; + RsRTTIOrdinal = 'ordinal='; + RsRTTITrue = 'True'; + RsRTTIFalse = 'False'; + RsRTTITypeError = '???'; + RsRTTITypeInfoAt = 'Type info: %p'; + + RsRTTIPropRead = 'read'; + RsRTTIPropWrite = 'write'; + RsRTTIPropStored = 'stored'; + + RsRTTIField = 'field'; + RsRTTIStaticMethod = 'static method'; + RsRTTIVirtualMethod = 'virtual method'; + + RsRTTIIndex = 'index'; + RsRTTIDefault = 'default'; + + RsRTTIName = 'Name: '; + RsRTTIType = 'Type: '; + RsRTTIFlags = 'Flags: '; + RsRTTIGUID = 'GUID: '; + RsRTTITypeKind = 'Type kind: '; + RsRTTIOrdinalType = 'Ordinal type: '; + RsRTTIMinValue = 'Min value: '; + RsRTTIMaxValue = 'Max value: '; + RsRTTINameList = 'Names: '; + RsRTTIClassName = 'Class name: '; + RsRTTIParent = 'Parent: '; + RsRTTIPropCount = 'Property count: '; + RsRTTIUnitName = 'Unit name: '; + RsRTTIBasedOn = 'Based on: '; + RsRTTIFloatType = 'Float type: '; + RsRTTIMethodKind = 'Method kind: '; + RsRTTIParamCount = 'Parameter count: '; + RsRTTIReturnType = 'Return type: '; + RsRTTIMaxLen = 'Max length: '; + RsRTTIElSize = 'Element size: '; + RsRTTIElType = 'Element type: '; + RsRTTIElNeedCleanup = 'Elements need clean up: '; + RsRTTIVarType = 'Variant type: '; + + RsDeclarationFormat = '// Declaration for ''%s'' not supported.'; + +//=== JclSchedule ============================================================ +resourcestring + RsScheduleInvalidTime = 'Invalid time specification'; + RsScheduleEndBeforeStart = 'End time can not be before start time'; + RsScheduleIntervalZero = 'Interval should be larger than 0'; + RsScheduleNoDaySpecified = 'At least one day of the week should be specified'; + RsScheduleIndexValueSup = 'Property IndexValue not supported for current IndexKind'; + RsScheduleIndexValueZero = 'IndexValue can not be 0'; + RsScheduleDayNotSupported = 'Property Day not supported for current IndexKind'; + RsScheduleDayInRange = 'Day values should fall in the range 1 .. 31'; + RsScheduleMonthInRange = 'Month values should fall in the range 1 .. 12'; + +//=== JclSecurity ============================================================ +resourcestring + RsInvalidSID = 'Invalid SID'; + RsSIDBufferTooSmall = 'SID buffer too small.'; + RsLsaError = 'LSA Error: NT Status = %.8x, message: %s'; + +//=== JclSimpleXml =========================================================== +resourcestring + RsEInvalidXMLElementUnexpectedCharacte = + 'Invalid XML Element: Unexpected character in property declaration ("%s" found at position %d)'; + RsEInvalidXMLElementUnexpectedCharacte_ = + 'Invalid XML Element: Unexpected character in property declaration. Expecting " or '' but "%s" found at position %d'; + RsEUnexpectedValueForLPos = 'Unexpected value for lPos at position %d'; + RsEInvalidXMLElementExpectedBeginningO = 'Invalid XML Element: Expected beginning of tag but "%s" found at position %d'; + RsEInvalidXMLElementExpectedEndOfTagBu = 'Invalid XML Element: Expected end of tag but "%s" found at position %d'; + RsEInvalidXMLElementMalformedTagFoundn = 'Invalid XML Element: malformed tag found (no valid name) at position %d'; + RsEInvalidXMLElementErroneousEndOfTagE = + 'Invalid XML Element: Erroneous end of tag, expecting but found at position %d'; + RsEInvalidCommentExpectedsButFounds = 'Invalid Comment: expected "%0:s" but found "%1:s" at position %d'; + RsEInvalidCommentNotAllowedInsideComme = 'Invalid Comment: "--" not allowed inside comments at position %d'; + RsEInvalidCommentUnexpectedEndOfData = 'Invalid Comment: Unexpected end of data at position %d'; + RsEInvalidCDATAExpectedsButFounds = 'Invalid CDATA: expected "%0:s" but found "%1:s" at position %d'; + RsEInvalidCDATAUnexpectedEndOfData = 'Invalid CDATA: Unexpected end of data at position %d'; + RsEInvalidHeaderExpectedsButFounds = 'Invalid Header: expected "%0:s" but found "%1:s" at position %d'; + RsEInvalidStylesheetExpectedsButFounds = 'Invalid Stylesheet: expected "%0:s" but found "%1:s" at position %d'; + RsEInvalidStylesheetUnexpectedEndOfDat = 'Invalid Stylesheet: Unexpected end of data at position %d'; + RsEInvalidMSOExpectedsButFounds = 'Invalid MSO: expected "%0:s" but found "%1:s" at position %d'; + RsEInvalidMSOUnexpectedEndOfDat = 'Invalid MSO: Unexpected end of data at position %d'; + RsEInvalidDocumentUnexpectedTextInFile = 'Invalid Document: Unexpected text in file prolog at position %d'; + +//=== JclStatistics ========================================================== +resourcestring + RsInvalidSampleSize = 'Invalid sample size (%d)'; + +//=== JclStreams ============================================================= +resourcestring + RsStreamsCreateError = 'Cannot create file %s'; + RsStreamsOpenError = 'Cannot open file %s'; + RsStreamsSetSizeError = 'Error setting stream size'; + RsStreamsSeekError = 'Error seeking stream'; + RsStreamsCRCError = 'Cyclic Redundency Check (CRC) error: data are damaged'; + +//=== JclStrHashMap ========================================================== +resourcestring + RsStringHashMapMustBeEmpty = 'HashList: must be empty to set size to zero'; + RsStringHashMapDuplicate = 'Duplicate hash list entry: %s'; + RsStringHashMapInvalidNode = 'Tried to remove invalid node: %s'; + RsStringHashMapNoTraits = 'HashList must have traits'; + +//=== JclStrings ============================================================= +resourcestring + RsBlankSearchString = 'Search string cannot be blank'; + RsInvalidEmptyStringItem = 'String list passed to StringsToMultiSz cannot contain empty strings.'; + RsNumericConstantTooLarge = 'Numeric constant too large (%d) at position %d.'; + RsFormatException = 'Format exception'; + RsDotNetFormatNullFormat = 'Format string is null'; + RsArgumentIsNull = 'Argument %d is null'; + RsDotNetFormatArgumentNotSupported = 'Argument type of %d is not supported'; + RsDotNetFormatObjectArgumentNotSupported = 'Argument type (%s) of %d is not supported'; + RsArgumentOutOfRange = 'Argument out of range'; + RsTabs_DuplicatesNotAllowed = 'Duplicate tab stops are not allowed.'; + RsTabs_StopExpected = 'A tab stop was expected but not found.'; + RsTabs_CloseBracketExpected = 'Closing bracket expected.'; + RsTabs_TabWidthExpected = 'Tab width expected.'; + // Default text for the NullReferenceException in .NET + RsArg_NullReferenceException = 'Object reference not set to an instance of an object.'; + +//=== JclStructStorage ======================================================= +resourcestring + RsIStreamNil = 'IStream is nil'; + +//=== JclSynch =============================================================== +resourcestring + RsSynchAttachWin32Handle = 'Invalid handle to TJclWin32HandleObject.Attach'; + RsSynchDuplicateWin32Handle = 'Invalid handle to TJclWin32HandleObject.Duplicate'; + RsSynchInitCriticalSection = 'Failed to initalize critical section'; + RsSynchAttachDispatcher = 'Invalid handle to TJclDispatcherObject.Attach'; + RsSynchCreateEvent = 'Failed to create event'; + RsSynchOpenEvent = 'Failed to open event'; + RsSynchCreateWaitableTimer = 'Failed to create waitable timer'; + RsSynchOpenWaitableTimer = 'Failed to open waitable timer'; + RsSynchCreateSemaphore = 'Failed to create semaphore'; + RsSynchOpenSemaphore = 'Failed to open semaphore'; + RsSynchCreateMutex = 'Failed to create mutex'; + RsSynchOpenMutex = 'Failed to open mutex'; + RsMetSectInvalidParameter = 'An invalid parameter was passed to the constructor.'; + RsMetSectInitialize = 'Failed to initialize the metered section.'; + RsMetSectNameEmpty = 'Name cannot be empty when using the Open constructor.'; + +//=== JclSysInfo ============================================================= +resourcestring + RsSystemProcess = 'System Process'; + RsSystemIdleProcess = 'System Idle Process'; + + RsIntelUnknownCache = 'Unknown cache ID (%.2x)'; + RsIntelCacheDescr00 = 'Null descriptor'; + RsIntelCacheDescr01 = 'Instruction TLB: 4 KByte pages, 4-way set associative, 32 entries'; + RsIntelCacheDescr02 = 'Instruction TLB: 4 MByte pages, 4-way set associative, 2 entries'; + RsIntelCacheDescr03 = 'Data TLB: 4 KByte pages, 4-way set associative, 64 entries'; + RsIntelCacheDescr04 = 'Data TLB: 4 MByte pages, 4-way set associative, 8 entries'; + RsIntelCacheDescr05 = 'Data TLB1: 4 MByte pages, 4-way set associative, 32 entries'; + RsIntelCacheDescr06 = '1st level instruction cache: 8 KBytes, 4-way set associative, 32 byte line size'; + RsIntelCacheDescr08 = '1st level instruction cache: 16 KBytes, 4-way set associative, 32 byte line size'; + RsIntelCacheDescr09 = '1st level instruction cache: 32 KBytes, 4-way set associative, 64 byte line size'; + RsIntelCacheDescr0A = '1st level data cache: 8 KBytes, 2-way set associative, 32 byte line size'; + RsIntelCacheDescr0B = 'Instruction TLB: 4 MByte pages, 4-way set associative, 4 entries'; + RsIntelCacheDescr0C = '1st level data cache: 16 KBytes, 4-way set associative, 32 byte line size'; + RsIntelCacheDescr0D = '1st level data cache: 16 KBytes, 4-way set associative, 64 byte line size'; + RsIntelCacheDescr0E = '1st level data cache: 24 KBytes, 6-way set associative, 64 byte line size'; + RsIntelCacheDescr21 = '2nd level cache: 256 KBytes, 8-way set associative, 64 byte line size'; + RsIntelCacheDescr22 = '3rd level cache: 512 KBytes, 4-way set associative, 64 byte line size, 2 lines per sector'; + RsIntelCacheDescr23 = '3rd level cache: 1 MBytes, 8-way set associative, 64 byte line size, 2 lines per sector'; + RsIntelCacheDescr25 = '3rd level cache: 2 MBytes, 8-way set associative, 64 byte line size, 2 lines per sector'; + RsIntelCacheDescr29 = '3rd level cache: 4 MBytes, 8-way set associative, 64 byte line size, 2 lines per sector'; + RsIntelCacheDescr2C = '1st level data cache: 32 KBytes, 8-way set associative, 64 byte line size'; + RsIntelCacheDescr30 = '1st level instruction cache: 32 KBytes, 8-way set associative, 64 byte line size'; + RsIntelCacheDescr39 = '2nd-level cache: 128 KBytes, 4-way set associative, sectored cache, 64-byte line size'; + RsIntelCacheDescr3A = '2nd-level cache: 192 KBytes, 6-way set associative, sectored cache, 64-byte line size'; + RsIntelCacheDescr3B = '2nd-level cache: 128 KBytes, 2-way set associative, sectored cache, 64-byte line size'; + RsIntelCacheDescr3C = '2nd-level cache: 256 KBytes, 4-way set associative, sectored cache, 64-byte line size'; + RsIntelCacheDescr3D = '2nd-level cache: 384 KBytes, 6-way set associative, sectored cache, 64-byte line size'; + RsIntelCacheDescr3E = '2nd-level cache: 512 KBytes, 4-way set associative, sectored cache, 64-byte line size'; + RsIntelCacheDescr40 = 'No 2nd-level cache or, if processor contains a valid 2nd-level cache, no 3rd-level cache'; + RsIntelCacheDescr41 = '2nd-level cache: 128 KBytes, 4-way set associative, 32 byte line size'; + RsIntelCacheDescr42 = '2nd-level cache: 256 KBytes, 4-way set associative, 32 byte line size'; + RsIntelCacheDescr43 = '2nd-level cache: 512 KBytes, 4-way set associative, 32 byte line size'; + RsIntelCacheDescr44 = '2nd-level cache: 1 MBytes, 4-way set associative, 32 byte line size'; + RsIntelCacheDescr45 = '2nd-level cache: 2 MBytes, 4-way set associative, 32 byte line size'; + RsIntelCacheDescr46 = '3rd-level cache: 4 MBytes, 4-way set associative, 64 byte line size'; + RsIntelCacheDescr47 = '3rd-level cache: 8 MBytes, 4-way set associative, 64 byte line size'; + RsIntelCacheDescr48 = '3rd-level cache: 8 MByte, 8-way set associative, 64 byte line size'; + RsIntelCacheDescr49 = '2nd-level cache: 4 MBytes, 16-way set associative, 64 byte line size'; + RsIntelCacheDescr4A = '3rd-level cache: 6MByte, 12-way set associative, 64 byte line size'; + RsIntelCacheDescr4B = '3rd-level cache: 8MByte, 16-way set associative, 64 byte line size'; + RsIntelCacheDescr4C = '3rd-level cache: 12MByte, 12-way set associative, 64 byte line size'; + RsIntelCacheDescr4D = '3rd-level cache: 16MByte, 16-way set associative, 64 byte line size'; + RsIntelCacheDescr4E = '2nd-level cache: 6MByte, 24-way set associative, 64 byte line size'; + RsIntelCacheDescr4F = 'Instruction TLB: 4 KByte pages, 32 Entries'; + RsIntelCacheDescr50 = 'Instruction TLB: 4 KByte and 2 MByte or 4 MByte pages, 64 Entries'; + RsIntelCacheDescr51 = 'Instruction TLB: 4 KByte and 2 MByte or 4 MByte pages, 128 Entries'; + RsIntelCacheDescr52 = 'Instruction TLB: 4 KByte and 2 MByte or 4 MByte pages, 256 Entries'; + RsIntelCacheDescr55 = 'Instruction TLB: 2-MByte or 4-MByte pages, fully associative, 7 entries'; + RsIntelCacheDescr56 = 'Data TLB0: 4 MByte pages, 4-way set associative, 16 entries'; + RsIntelCacheDescr57 = 'Data TLB0: 4 KByte pages, 4-way associative, 16 entries'; + RsIntelCacheDescr59 = 'Data TLB0: 4 KByte pages, fully associative, 16 entries'; + RsIntelCacheDescr5A = 'Data TLB0: 2 MByte or 4 MByte pages, 4-way set associative, 32 entries'; + RsIntelCacheDescr5B = 'Data TLB: 4 KByte and 4 MByte pages, 64 Entries'; + RsIntelCacheDescr5C = 'Data TLB: 4 KByte and 4 MByte pages, 128 Entries'; + RsIntelCacheDescr5D = 'Data TLB: 4 KByte and 4 MByte pages, 256 Entries'; + RsIntelCacheDescr60 = '1st-level data cache: 16 KByte, 8-way set associative, 64 byte line size'; + RsIntelCacheDescr66 = '1st-level data cache: 8 KBytes, 4-way set associative, 64 byte line size'; + RsIntelCacheDescr67 = '1st-level data cache: 16 KBytes, 4-way set associative, 64 byte line size'; + RsIntelCacheDescr68 = '1st-level data cache: 32 KBytes, 4-way set associative, 64 byte line size'; + RsIntelCacheDescr70 = 'Trace cache: 12 K-Ops, 8-way set associative'; + RsIntelCacheDescr71 = 'Trace cache: 16 K-Ops, 8-way set associative'; + RsIntelCacheDescr72 = 'Trace cache: 32 K-Ops, 8-way set associative'; + RsIntelCacheDescr73 = 'Trace cache: 64 K-Ops, 8-way set associative'; + RsIntelCacheDescr76 = 'Instruction TLB: 2M/4M pages, fully associative, 8 entries'; + RsIntelCacheDescr78 = '2nd-level cache: 1 MBytes, 4-way set associative, 64 bytes line size'; + RsIntelCacheDescr79 = '2nd-level cache: 128 KBytes, 8-way set associative, 64 bytes line size, 2 lines per sector'; + RsIntelCacheDescr7A = '2nd-level cache: 256 KBytes, 8-way set associative, 64 bytes line size, 2 lines per sector'; + RsIntelCacheDescr7B = '2nd-level cache: 512 KBytes, 8-way set associative, 64 bytes line size, 2 lines per sector'; + RsIntelCacheDescr7C = '2nd-level cache: 1 MBytes, 8-way set associative, 64 bytes line size, 2 lines per sector'; + RsIntelCacheDescr7D = '2nd-level cache: 2 MBytes, 8-way set associative, 64 byte line size'; + RsIntelCacheDescr7F = '2nd-level cache: 512 KBytes, 2-way set associative, 64 byte line size'; + RsIntelCacheDescr80 = '2nd-level cache: 512 KBytes, 8-way set associative, 64 byte line size'; + RsIntelCacheDescr82 = '2nd-level cache: 256 KBytes, 8-way associative, 32 byte line size'; + RsIntelCacheDescr83 = '2nd-level cache: 512 KBytes, 8-way associative, 32 byte line size'; + RsIntelCacheDescr84 = '2nd-level cache: 1 MBytes, 8-way associative, 32 byte line size'; + RsIntelCacheDescr85 = '2nd-level cache: 2 MBytes, 8-way associative, 32 byte line size'; + RsIntelCacheDescr86 = '2nd-level cache: 512 KByte, 4-way set associative, 64 byte line size'; + RsIntelCacheDescr87 = '2nd-level cache: 1 MByte, 8-way set associative, 64 byte line size'; + RsIntelCacheDescrB0 = 'Instruction TLB: 4 KByte pages, 4-way set associative, 128 entries'; + RsIntelCacheDescrB1 = 'Instruction TLB: 2 MByte pages, 4-way, 8 entries or 4 MByte pages, 4-way, 4 entries'; + RsIntelCacheDescrB2 = 'Instruction TLB: 4 KByte pages, 4-way set associative, 64 entries'; + RsIntelCacheDescrB3 = 'Data TLB: 4 KByte pages, 4-way set associative, 128 entries'; + RsIntelCacheDescrB4 = 'Data TLB1: 4 KByte pages, 4-way set associative, 256 entries'; + RsIntelCacheDescrBA = 'Data TLB1: 4 KByte pages, 4-way set associative, 64 entries'; + RsIntelCacheDescrC0 = 'Data TLB: 4 KByte and 4 MByte pages, 4-way set associative, 8 entries'; + RsIntelCacheDescrCA = 'Shared 2nd-Level TLB: 4 KByte pages, 4-way associative, 512 entries'; + RsIntelCacheDescrD0 = '3rd-level cache: 512 KByte, 4-way set associative, 64 byte line size'; + RsIntelCacheDescrD1 = '3rd-level cache: 1 MByte, 4-way set associative, 64 byte line size'; + RsIntelCacheDescrD2 = '3rd-level cache: 2 MByte, 4-way set associative, 64 byte line size'; + RsIntelCacheDescrD6 = '3rd-level cache: 1 MByte, 8-way set associative, 64 byte line size'; + RsIntelCacheDescrD7 = '3rd-level cache: 2 MByte, 8-way set associative, 64 byte line size'; + RsIntelCacheDescrD8 = '3rd-level cache: 4 MByte, 8-way set associative, 64 byte line size'; + RsIntelCacheDescrDC = '3rd-level cache: 1.5 MByte, 12-way set associative, 64 byte line size'; + RsIntelCacheDescrDD = '3rd-level cache: 3 MByte, 12-way set associative, 64 byte line size'; + RsIntelCacheDescrDE = '3rd-level cache: 6 MByte, 12-way set associative, 64 byte line size'; + RsIntelCacheDescrE2 = '3rd-level cache: 2 MByte, 16-way set associative, 64 byte line size'; + RsIntelCacheDescrE3 = '3rd-level cache: 4 MByte, 16-way set associative, 64 byte line size'; + RsIntelCacheDescrE4 = '3rd-level cache: 8 MByte, 16-way set associative, 64 byte line size'; + RsIntelCacheDescrEA = '3rd-level cache: 12 MByte, 24-way set associative, 64 byte line size'; + RsIntelCacheDescrEB = '3rd-level cache: 18 MByte, 24-way set associative, 64 byte line size'; + RsIntelCacheDescrEC = '3rd-level cache: 24 MByte, 24-way set associative, 64 byte line size'; + RsIntelCacheDescrF0 = '64-Byte Prefetching'; + RsIntelCacheDescrF1 = '128-Byte Prefetching'; + RsIntelCacheDescrFF = 'CPUID leaf 2 does not report cache descriptor information, use CPUID leaf 4 to query cache parameters'; + + RsUnknownAMDModel = 'Unknown AMD (Model %d)'; + + RsOSVersionWin95 = 'Windows 95'; + RsOSVersionWin95OSR2 = 'Windows 95 OSR2'; + RsOSVersionWin98 = 'Windows 98'; + RsOSVersionWin98SE = 'Windows 98 SE'; + RsOSVersionWinME = 'Windows ME'; + RsOSVersionWinNT3 = 'Windows NT 3.%u'; + RsOSVersionWinNT4 = 'Windows NT 4.%u'; + RsOSVersionWin2000 = 'Windows 2000'; + RsOSVersionWinXP = 'Windows XP'; + RsOSVersionWin2003 = 'Windows Server 2003'; + RsOSVersionWin2003R2 = 'Windows Server 2003 R2'; + RsOSVersionWinXP64 = 'Windows XP x64'; + RsOSVersionWinVista = 'Windows Vista'; + RsOSVersionWinServer2008 = 'Windows Server 2008'; + RsOSVersionWin7 = 'Windows 7'; + RsOSVersionWinServer2008R2 = 'Windows Server 2008 R2'; + RsOSVersionWin8 = 'Windows 8'; + RsOSVersionWin8RT = 'Windows RT'; + RsOSVersionWinServer2012 = 'Windows Server 2012'; + RsOSVersionWin81 = 'Windows 8.1'; + RsOSVersionWin81RT = 'Windows RT 8.1'; + RsOSVersionWinServer2012R2 = 'Windows Server 2012 R2'; + + RsEditionWinXPHome = 'Home Edition'; + RsEditionWinXPPro = 'Professional'; + RsEditionWinXPHomeN = 'Home Edition N'; + RsEditionWinXPProN = 'Professional N'; + RsEditionWinXPHomeK = 'Home Edition K'; + RsEditionWinXPProK = 'Professional K'; + RsEditionWinXPHomeKN = 'Home Edition KN'; + RsEditionWinXPProKN = 'Professional KN'; + RsEditionWinXPStarter = 'Starter Edition'; + RsEditionWinXPMediaCenter = 'Media Center Edition'; + RsEditionWinXPTablet = 'Tablet PC Edition'; + RsEditionWinVistaStarter = 'Starter'; + RsEditionWinVistaHomeBasic = 'Home Basic'; + RsEditionWinVistaHomeBasicN = 'Home Basic N'; + RsEditionWinVistaHomePremium = 'Home Premium'; + RsEditionWinVistaBusiness = 'Business'; + RsEditionWinVistaBusinessN = 'Business N'; + RsEditionWinVistaEnterprise = 'Enterprise'; + RsEditionWinVistaUltimate = 'Ultimate'; + RsEditionWin7Starter = 'Starter'; + RsEditionWin7HomeBasic = 'Home Basic'; + RsEditionWin7HomePremium = 'Home Premium'; + RsEditionWin7Professional = 'Professional'; + RsEditionWin7Enterprise = 'Enterprise'; + RsEditionWin7Ultimate = 'Ultimate'; + RsEditionWin8Pro = 'Pro'; + RsEditionWin8Enterprise = 'Enterprise'; + RsEditionWin8RT = 'RT'; + RsEditionWin81Pro = 'Pro'; + RsEditionWin81Enterprise = 'Enterprise'; + RsEditionWin81RT = 'RT'; + + RsProductTypeWorkStation = 'Workstation'; + RsProductTypeServer = 'Server'; + RsProductTypeAdvancedServer = 'Advanced Server'; + RsProductTypePersonal = 'Home Edition'; + RsProductTypeProfessional = 'Professional'; + RsProductTypeDatacenterServer = 'Datacenter Server'; + RsProductTypeEnterprise = 'Enterprise'; + RsProductTypeWebEdition = 'Web Edition'; + + RsEOpenGLInfo = 'GetOpenGLVersion: %s failed'; + RsENetWkstaGetInfo = 'NetWkstaGetInfo failed'; + + {$IFDEF MSWINDOWS} + RsSPInfo = 'SP%u'; + {$ENDIF MSWINDOWS} + + {$IFDEF UNIX} + RsInvalidProcessID = 'Invalid process ID %d'; + {$ENDIF UNIX} + + RsOpenGLInfoError = 'Err'; + +//=== JclSysUtils ============================================================ +resourcestring + RsVMTMemoryWriteError = 'Error writing VMT memory (%s)'; + RsCannotWriteRefStream = 'Can not write to a read-only memory stream'; + RsStringToBoolean = 'Unable to convert the string "%s" to a boolean'; + RsInvalidDigit = 'Invalid base %d digit ''%s'' encountered.'; + RsInvalidDigitValue = 'There is no valid base %d digit for decimal value %d'; + + {$IFDEF UNIX} + RsReadKeyError = 'ReadKey: Problem waiting on stdin'; + {$ENDIF UNIX} + + RsInvalidGUIDString = 'Invalid conversion from string to GUID (%s).'; + + RsInvalidMMFName = 'Invalid MMF name "%s"'; + RsInvalidMMFEmpty = 'The MMF named "%s" cannot be created empty'; + +//=== JclTD32 ================================================================ +resourcestring + RsHasNotTD32Info = 'File [%s] has not TD32 debug information!'; + +//=== JclTimeZones =========================================================== +resourcestring + RsEDaylightSavingsNotSupported = 'Daylight Savings not supported by this timezone'; + RsEAutoAdjustNotEnabled = 'Auto adjust for Daylight Savings is not enabled. Date is not available'; + RsENoCallbackFunc = 'No callback function assigned'; + +//=== JclUnicode ============================================================= +resourcestring + RsUREErrorFmt = '%s%s%s'; + RsUREBaseString = 'Error in regular expression: %s' + sLineBreak; + RsUREUnexpectedEOS = 'Unexpected end of pattern.'; + RsURECharacterClassOpen = 'Character class not closed, '']'' is missing.'; + RsUREUnbalancedGroup = 'Unbalanced group expression, '')'' is missing.'; + RsUREInvalidCharProperty = 'A character property is invalid'; + RsUREInvalidRepeatRange = 'Invalid repetition range.'; + RsURERepeatRangeOpen = 'Repetition range not closed, ''}'' is missing.'; + RsUREExpressionEmpty = 'Expression is empty.'; + RsCategoryUnicodeChar = 'category Unicode character > $FFFFFF found'; + RsCasedUnicodeChar = 'cased Unicode character > $FFFFFF found'; + RsDecomposedUnicodeChar = 'decomposed Unicode character > $FFFFFF found'; + RsCombiningClassUnicodeChar = 'combining class for Unicode character > $FFFFFF found'; + RsEUnexpectedEOSeq = 'Unexpected end of sequence'; + +//=== JclUnitConv ============================================================ +resourcestring + RsTempConvTypeError = 'An invalid type has been provided for the %s parameter'; + RsConvTempBelowAbsoluteZero = 'Temperature can not be below Absolute Zero!'; + +//=== JclWin32 =============================================================== +resourcestring + RsWin32Error = 'Win32 error: %s (%u)%s%s'; + RsELibraryNotFound = 'Library not found: %s'; + RsEFunctionNotFound = 'Function not found: %s.%s'; + +//=== JclWinMidi ============================================================= +resourcestring + RsMidiInUnknownError = 'Unknown MIDI-In error No. %d'; + RsMidiOutUnknownError = 'Unknown MIDI-Out error No. %d'; + +{$IFDEF UNITVERSIONING} +const + UnitVersioning: TUnitVersionInfo = ( + RCSfile: '$URL$'; + Revision: '$Revision$'; + Date: '$Date$'; + LogPath: 'JCL\source\common'; + Extra: ''; + Data: nil + ); +{$ENDIF UNITVERSIONING} + +implementation + +{$IFDEF UNITVERSIONING} +initialization + RegisterUnitVersion(HInstance, UnitVersioning); + +finalization + UnregisterUnitVersion(HInstance); +{$ENDIF UNITVERSIONING} + +end. diff --git a/source/packages/jcl/JclStreams.pas b/source/packages/jcl/JclStreams.pas new file mode 100644 index 00000000..b086cb69 --- /dev/null +++ b/source/packages/jcl/JclStreams.pas @@ -0,0 +1,3149 @@ +{**************************************************************************************************} +{ } +{ Project JEDI Code Library (JCL) } +{ } +{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); } +{ you may not use this file except in compliance with the License. You may obtain a copy of the } +{ License at http://www.mozilla.org/MPL/ } +{ } +{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF } +{ ANY KIND, either express or implied. See the License for the specific language governing rights } +{ and limitations under the License. } +{ } +{ The Original Code is JclStreams.pas. } +{ } +{ The Initial Developer of the Original Code is Robert Marquardt. Portions created by } +{ Robert Marquardt are Copyright (C) Robert Marquardt (robert_marquardt att gmx dott de) } +{ All rights reserved. } +{ } +{ Contributors: } +{ Florent Ouchet (outchy) } +{ Heinz Zastrau } +{ Andreas Schmidt } +{ } +{**************************************************************************************************} +{ } +{ Stream-related functions and classes } +{ } +{**************************************************************************************************} +{ } +{ Last modified: $Date:: $ } +{ Revision: $Rev:: $ } +{ Author: $Author:: $ } +{ } +{**************************************************************************************************} + +unit JclStreams; + +{$I jcl.inc} + +interface + +uses + {$IFDEF UNITVERSIONING} + JclUnitVersioning, + {$ENDIF UNITVERSIONING} + {$IFDEF HAS_UNITSCOPE} + {$IFDEF MSWINDOWS} + Winapi.Windows, + {$ENDIF MSWINDOWS} + System.SysUtils, System.Classes, + System.Contnrs, + {$ELSE ~HAS_UNITSCOPE} + {$IFDEF MSWINDOWS} + Windows, + {$ENDIF MSWINDOWS} + SysUtils, Classes, + Contnrs, + {$ENDIF ~HAS_UNITSCOPE} + {$IFDEF HAS_UNIT_LIBC} + Libc, + {$ENDIF HAS_UNIT_LIBC} + JclBase{$IFNDEF WINSCP}, JclStringConversions{$ENDIF ~WINSCP}; + +const + StreamDefaultBufferSize = 4096; + +type + EJclStreamError = class(EJclError); + + // abstraction layer to support Delphi 5 and C++Builder 5 streams + // 64 bit version of overloaded functions are introduced + TJclStream = class(TStream) + protected + procedure SetSize(NewSize: Longint); overload; override; + procedure SetSize(const NewSize: Int64); overload; override; + public + function Seek(Offset: Longint; Origin: Word): Longint; overload; override; + function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; overload; override; + procedure LoadFromStream(Source: TStream; BufferSize: Longint = StreamDefaultBufferSize); virtual; + procedure LoadFromFile(const FileName: TFileName; BufferSize: Longint = StreamDefaultBufferSize); virtual; + procedure SaveToStream(Dest: TStream; BufferSize: Longint = StreamDefaultBufferSize); virtual; + procedure SaveToFile(const FileName: TFileName; BufferSize: Longint = StreamDefaultBufferSize); virtual; + end; + + //=== VCL stream replacements === + + TJclHandleStream = class(TJclStream) + private + FHandle: THandle; + protected + procedure SetSize(const NewSize: Int64); override; + public + constructor Create(AHandle: THandle); + function Read(var Buffer; Count: Longint): Longint; override; + function Write(const Buffer; Count: Longint): Longint; override; + function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override; + property Handle: THandle read FHandle; + end; + + TJclFileStream = class(TJclHandleStream) + public + constructor Create(const FileName: TFileName; Mode: Word; Rights: Cardinal = $666); + destructor Destroy; override; + end; + + { + TJclCustomMemoryStream = class(TJclStream) + end; + + TJclMemoryStream = class(TJclCustomMemoryStream) + end; + + TJclStringStream = class(TJclStream) + end; + + TJclResourceStream = class(TJclCustomMemoryStream) + end; + } + + //=== new stream ideas === + + TJclEmptyStream = class(TJclStream) + protected + procedure SetSize(const NewSize: Int64); override; + public + function Read(var Buffer; Count: Longint): Longint; override; + function Write(const Buffer; Count: Longint): Longint; override; + function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override; + end; + +{$IFNDEF WINSCP} + TJclNullStream = class(TJclStream) + private + FPosition: Int64; + FSize: Int64; + protected + procedure SetSize(const NewSize: Int64); override; + public + function Read(var Buffer; Count: Longint): Longint; override; + function Write(const Buffer; Count: Longint): Longint; override; + function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override; + end; + + TJclRandomStream = class(TJclNullStream) + protected + function GetRandSeed: Longint; virtual; + procedure SetRandSeed(Seed: Longint); virtual; + public + function RandomData: Byte; virtual; + procedure Randomize; dynamic; + function Read(var Buffer; Count: Longint): Longint; override; + property RandSeed: Longint read GetRandSeed write SetRandSeed; + end; + +{$ENDIF ~WINSCP} + + TJclMultiplexStream = class(TJclStream) + private + FStreams: TList; + FReadStreamIndex: Integer; + function GetStream(Index: Integer): TStream; + function GetCount: Integer; + procedure SetStream(Index: Integer; const Value: TStream); + function GetReadStream: TStream; + procedure SetReadStream(const Value: TStream); + procedure SetReadStreamIndex(const Value: Integer); + protected + procedure SetSize(const NewSize: Int64); override; + public + constructor Create; + destructor Destroy; override; + function Read(var Buffer; Count: Longint): Longint; override; + function Write(const Buffer; Count: Longint): Longint; override; + function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override; + + function Add(NewStream: TStream): Integer; + procedure Clear; + function Remove(AStream: TStream): Integer; + procedure Delete(const Index: Integer); + + property Streams[Index: Integer]: TStream read GetStream write SetStream; + property ReadStreamIndex: Integer read FReadStreamIndex write SetReadStreamIndex; + property ReadStream: TStream read GetReadStream write SetReadStream; + property Count: Integer read GetCount; + end; + + TJclStreamDecorator = class(TJclStream) + private + FAfterStreamChange: TNotifyEvent; + FBeforeStreamChange: TNotifyEvent; + FOwnsStream: Boolean; + FStream: TStream; + procedure SetStream(Value: TStream); + protected + procedure DoAfterStreamChange; virtual; + procedure DoBeforeStreamChange; virtual; + procedure SetSize(const NewSize: Int64); override; + public + constructor Create(AStream: TStream; AOwnsStream: Boolean = False); + destructor Destroy; override; + function Read(var Buffer; Count: Longint): Longint; override; + function Write(const Buffer; Count: Longint): Longint; override; + function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override; + property AfterStreamChange: TNotifyEvent read FAfterStreamChange write FAfterStreamChange; + property BeforeStreamChange: TNotifyEvent read FBeforeStreamChange write FBeforeStreamChange; + property OwnsStream: Boolean read FOwnsStream write FOwnsStream; + property Stream: TStream read FStream write SetStream; + end; + + TJclBufferedStream = class(TJclStreamDecorator) + protected + FBuffer: array of Byte; + FBufferCurrentSize: Longint; + FBufferMaxModifiedPos: Longint; + FBufferSize: Longint; + FBufferStart: Int64; // position of the first byte of the buffer in stream + FPosition: Int64; // current position in stream + function BufferHit: Boolean; + function GetCalcedSize: Int64; virtual; + function LoadBuffer: Boolean; virtual; + function ReadFromBuffer(var Buffer; Count, Start: Longint): Longint; + function WriteToBuffer(const Buffer; Count, Start: Longint): Longint; + protected + procedure DoAfterStreamChange; override; + procedure DoBeforeStreamChange; override; + procedure SetSize(const NewSize: Int64); override; + public + constructor Create(AStream: TStream; AOwnsStream: Boolean = False); + destructor Destroy; override; + procedure Flush; virtual; + function Read(var Buffer; Count: Longint): Longint; override; + function Write(const Buffer; Count: Longint): Longint; override; + function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override; + property BufferSize: Longint read FBufferSize write FBufferSize; + end; + + TStreamNotifyEvent = procedure(Sender: TObject; Position: Int64; Size: Int64) of object; + + TJclEventStream = class(TJclStreamDecorator) + private + FNotification: TStreamNotifyEvent; + procedure DoNotification; + protected + procedure DoBeforeStreamChange; override; + procedure DoAfterStreamChange; override; + procedure SetSize(const NewSize: Int64); override; + public + constructor Create(AStream: TStream; ANotification: TStreamNotifyEvent = nil; + AOwnsStream: Boolean = False); + function Read(var Buffer; Count: Longint): Longint; override; + function Write(const Buffer; Count: Longint): Longint; override; + function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override; + property OnNotification: TStreamNotifyEvent read FNotification write FNotification; + end; + + TJclEasyStream = class(TJclStreamDecorator) + public + function IsEqual(Stream: TStream): Boolean; + function ReadBoolean: Boolean; + function ReadChar: Char; + function ReadAnsiChar: AnsiChar; + function ReadWideChar: WideChar; + function ReadByte: Byte; + function ReadCurrency: Currency; + function ReadDateTime: TDateTime; + function ReadExtended: Extended; + function ReadDouble: Double; + function ReadInt64: Int64; + function ReadInteger: Integer; + function ReadCString: string; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function ReadCAnsiString: AnsiString; + function ReadCWideString: WideString; + function ReadShortString: string; + function ReadSingle: Single; + function ReadSizedString: string; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function ReadSizedAnsiString: AnsiString; + function ReadSizedWideString: WideString; + procedure WriteBoolean(Value: Boolean); + procedure WriteChar(Value: Char); + procedure WriteAnsiChar(Value: AnsiChar); + procedure WriteWideChar(Value: WideChar); + procedure WriteByte(Value: Byte); + procedure WriteCurrency(const Value: Currency); + procedure WriteDateTime(const Value: TDateTime); + procedure WriteExtended(const Value: Extended); + procedure WriteDouble(const Value: Double); + procedure WriteInt64(Value: Int64); overload; + procedure WriteInteger(Value: Integer); overload; + procedure WriteCString(const Value: string); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + procedure WriteCAnsiString(const Value: AnsiString); + procedure WriteCWideString(const Value: WideString); + // use WriteCString + procedure WriteShortString(const Value: ShortString); + procedure WriteSingle(const Value: Single); + procedure WriteSizedString(const Value: string); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + procedure WriteSizedAnsiString(const Value: AnsiString); + procedure WriteSizedWideString(const Value: WideString); + end; + + TJclScopedStream = class(TJclStream) + private + FParentStream: TStream; + FStartPos: Int64; + FCurrentPos: Int64; + FMaxSize: Int64; + protected + procedure SetSize(const NewSize: Int64); override; + public + // scopedstream starting at the current position of the ParentStream + // if MaxSize is positive or null, read and write operations cannot overrun this size or the ParentStream limitation + // if MaxSize is negative, read and write operations are unlimited (up to the ParentStream limitation) + constructor Create(AParentStream: TStream; const AMaxSize: Int64 = -1); overload; + constructor Create(AParentStream: TStream; const AStartPos, AMaxSize: Int64); overload; + function Read(var Buffer; Count: Longint): Longint; override; + function Write(const Buffer; Count: Longint): Longint; override; + function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override; + + property ParentStream: TStream read FParentStream; + property StartPos: Int64 read FStartPos; + property MaxSize: Int64 read FMaxSize write FMaxSize; + end; + + TJclStreamSeekEvent = function(Sender: TObject; const Offset: Int64; + Origin: TSeekOrigin): Int64 of object; + TJclStreamReadEvent = function(Sender: TObject; var Buffer; Count: Longint): Longint of object; + TJclStreamWriteEvent = function(Sender: TObject; const Buffer;Count: Longint): Longint of object; + TJclStreamSizeEvent = procedure(Sender: TObject; const NewSize: Int64) of object; + + TJclDelegatedStream = class(TJclStream) + private + FOnSeek: TJclStreamSeekEvent; + FOnRead: TJclStreamReadEvent; + FOnWrite: TJclStreamWriteEvent; + FOnSize: TJclStreamSizeEvent; + protected + procedure SetSize(const NewSize: Int64); override; + public + function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override; + function Read(var Buffer; Count: Longint): Longint; override; + function Write(const Buffer; Count: Longint): Longint; override; + property OnSeek: TJclStreamSeekEvent read FOnSeek write FOnSeek; + property OnRead: TJclStreamReadEvent read FOnRead write FOnRead; + property OnWrite: TJclStreamWriteEvent read FOnWrite write FOnWrite; + property OnSize: TJclStreamSizeEvent read FOnSize write FOnSize; + end; + + // ancestor classes for streams with checksums and encrypted streams + // data are stored in sectors: each BufferSize-d buffer is followed by FSectorOverHead bytes + // containing the checksum. In case of an encrypted stream, there is no byte + // but sector is encrypted + + // reusing some code from TJclBufferedStream + TJclSectoredStream = class(TJclBufferedStream) + protected + FSectorOverHead: Longint; + function FlatToSectored(const Position: Int64): Int64; + function SectoredToFlat(const Position: Int64): Int64; + function GetCalcedSize: Int64; override; + function LoadBuffer: Boolean; override; + procedure DoAfterStreamChange; override; + procedure AfterBlockRead; virtual; // override to check protection + procedure BeforeBlockWrite; virtual; // override to compute protection + procedure SetSize(const NewSize: Int64); override; + public + constructor Create(AStorageStream: TStream; AOwnsStream: Boolean = False; + ASectorOverHead: Longint = 0); + + procedure Flush; override; + end; + +{$IFNDEF WINSCP} + TJclCRC16Stream = class(TJclSectoredStream) + protected + procedure AfterBlockRead; override; + procedure BeforeBlockWrite; override; + public + constructor Create(AStorageStream: TStream; AOwnsStream: Boolean = False); + end; + + TJclCRC32Stream = class(TJclSectoredStream) + protected + procedure AfterBlockRead; override; + procedure BeforeBlockWrite; override; + public + constructor Create(AStorageStream: TStream; AOwnsStream: Boolean = False); + end; +{$ENDIF ~WINSCP} + + {$IFDEF COMPILER7_UP} + {$DEFINE SIZE64} + {$ENDIF ~COMPILER7_UP} + {$IFDEF FPC} + {$DEFINE SIZE64} + {$ENDIF FPC} + TJclSplitStream = class(TJclStream) + private + FVolume: TStream; + FVolumeIndex: Integer; + FVolumeMaxSize: Int64; + FPosition: Int64; + FVolumePosition: Int64; + FForcePosition: Boolean; + protected + function GetVolume(Index: Integer): TStream; virtual; abstract; + function GetVolumeMaxSize(Index: Integer): Int64; virtual; abstract; + function GetSize: Int64; {$IFDEF SIZE64}override;{$ENDIF SIZE64} + procedure SetSize(const NewSize: Int64); override; + function InternalLoadVolume(Index: Integer): Boolean; + public + constructor Create(AForcePosition: Boolean = False); + + function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override; + function Read(var Buffer; Count: Longint): Longint; override; + function Write(const Buffer; Count: Longint): Longint; override; + + property ForcePosition: Boolean read FForcePosition write FForcePosition; + end; + + TJclVolumeEvent = function(Index: Integer): TStream of object; + TJclVolumeMaxSizeEvent = function(Index: Integer): Int64 of object; + + TJclDynamicSplitStream = class(TJclSplitStream) + private + FOnVolume: TJclVolumeEvent; + FOnVolumeMaxSize: TJclVolumeMaxSizeEvent; + protected + function GetVolume(Index: Integer): TStream; override; + function GetVolumeMaxSize(Index: Integer): Int64; override; + public + property OnVolume: TJclVolumeEvent read FOnVolume write FOnVolume; + property OnVolumeMaxSize: TJclVolumeMaxSizeEvent read FOnVolumeMaxSize + write FOnVolumeMaxSize; + end; + + TJclSplitVolume = class + public + MaxSize: Int64; + Stream: TStream; + OwnStream: Boolean; + end; + + TJclStaticSplitStream = class(TJclSplitStream) + private + FVolumes: TObjectList; + function GetVolumeCount: Integer; + protected + function GetVolume(Index: Integer): TStream; override; + function GetVolumeMaxSize(Index: Integer): Int64; override; + public + constructor Create(AForcePosition: Boolean = False); + destructor Destroy; override; + + function AddVolume(AStream: TStream; AMaxSize: Int64 = 0; + AOwnStream: Boolean = False): Integer; + + property VolumeCount: Integer read GetVolumeCount; + property Volumes[Index: Integer]: TStream read GetVolume; + property VolumeMaxSizes[Index: Integer]: Int64 read GetVolumeMaxSize; + end; + +{$IFNDEF WINSCP} + + TJclStringStream = class + protected + FStream: TStream; + FOwnStream: Boolean; + FBOM: array of Byte; + FBufferSize: SizeInt; + FStrPosition: Int64; // current position in characters + FStrBuffer: TUCS4Array; // buffer for read/write operations + FStrBufferPosition: Int64; // position of the first character of the read/write buffer + FStrBufferCurrentSize: Int64; // numbers of characters available in str buffer + FStrBufferModifiedSize: Int64; // numbers of characters modified in str buffer + FStrBufferStart: Int64; // position of the first byte of the read/write buffer in stream + FStrBufferNext: Int64; // position of the next character following the read/write buffer in stream + FStrPeekPosition: Int64; // current peek position in characters + FStrPeekBuffer: TUCS4Array; // buffer for peek operations + FStrPeekBufferPosition: Int64; // index of the first character of the peek buffer + FStrPeekBufferCurrentSize: SizeInt; // numbers of characters available in peek buffer + FStrPeekBufferStart: Int64; // position of the first byte of the peek buffer in stream + FStrPeekBufferNext: Int64; // position of the next character following the peek buffer in stream + function LoadBuffer: Boolean; + function LoadPeekBuffer: Boolean; + function InternalGetNextChar(S: TStream; out Ch: UCS4): Boolean; virtual; abstract; + function InternalGetNextBuffer(S: TStream; var Buffer: TUCS4Array; Start, Count: SizeInt): Longint; virtual; + function InternalSetNextChar(S: TStream; Ch: UCS4): Boolean; virtual; abstract; + function InternalSetNextBuffer(S: TStream; const Buffer: TUCS4Array; Start, Count: SizeInt): Longint; virtual; + procedure InvalidateBuffers; + public + constructor Create(AStream: TStream; AOwnsStream: Boolean = False); virtual; + destructor Destroy; override; + procedure Flush; virtual; + function ReadString(var Buffer: string; Start, Count: Longint): Longint; overload; + function ReadString(BufferSize: Longint = StreamDefaultBufferSize): string; overload; + function ReadAnsiString(var Buffer: AnsiString; Start, Count: Longint): Longint; overload; + function ReadAnsiString(BufferSize: Longint = StreamDefaultBufferSize): AnsiString; overload; + function ReadWideString(var Buffer: WideString; Start, Count: Longint): Longint; overload; + function ReadWideString(BufferSize: Longint = StreamDefaultBufferSize): WideString; overload; + function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; virtual; + function WriteString(const Buffer: string; Start, Count: Longint): Longint; + function WriteAnsiString(const Buffer: AnsiString; Start, Count: Longint): Longint; + function WriteWideString(const Buffer: WideString; Start, Count: Longint): Longint; + function PeekChar(out Buffer: Char): Boolean; + function PeekAnsiChar(out Buffer: AnsiChar): Boolean; + function PeekUCS4(out Buffer: UCS4): Boolean; + function PeekWideChar(out Buffer: WideChar): Boolean; + function ReadChar(out Buffer: Char): Boolean; + function ReadAnsiChar(out Buffer: AnsiChar): Boolean; + function ReadUCS4(out Buffer: UCS4): Boolean; + function ReadWideChar(out Buffer: WideChar): Boolean; + function WriteChar(Value: Char): Boolean; + function WriteAnsiChar(Value: AnsiChar): Boolean; + function WriteUCS4(Value: UCS4): Boolean; + function WriteWideChar(Value: WideChar): Boolean; + function SkipBOM: LongInt; virtual; + function WriteBOM: Longint; virtual; + property BufferSize: SizeInt read FBufferSize write FBufferSize; + property PeekPosition: Int64 read FStrPeekPosition; + property Position: Int64 read FStrPosition; + property Stream: TStream read FStream; + property OwnStream: Boolean read FOwnStream; + end; + + TJclStringStreamClass = class of TJclStringStream; + + TJclAnsiStream = class(TJclStringStream) + private + FCodePage: Word; + protected + function InternalGetNextChar(S: TStream; out Ch: UCS4): Boolean; override; + function InternalGetNextBuffer(S: TStream; var Buffer: TUCS4Array; Start, Count: SizeInt): Longint; override; + function InternalSetNextChar(S: TStream; Ch: UCS4): Boolean; override; + function InternalSetNextBuffer(S: TStream; const Buffer: TUCS4Array; Start, Count: SizeInt): Longint; override; + public + constructor Create(AStream: TStream; AOwnsStream: Boolean = False); override; + property CodePage: Word read FCodePage write FCodePage; + end; + + TJclUTF8Stream = class(TJclStringStream) + protected + function InternalGetNextChar(S: TStream; out Ch: UCS4): Boolean; override; + function InternalGetNextBuffer(S: TStream; var Buffer: TUCS4Array; Start, Count: SizeInt): Longint; override; + function InternalSetNextChar(S: TStream; Ch: UCS4): Boolean; override; + function InternalSetNextBuffer(S: TStream; const Buffer: TUCS4Array; Start, Count: SizeInt): Longint; override; + public + constructor Create(AStream: TStream; AOwnsStream: Boolean = False); override; + end; + + TJclUTF16Stream = class(TJclStringStream) + protected + function InternalGetNextChar(S: TStream; out Ch: UCS4): Boolean; override; + function InternalGetNextBuffer(S: TStream; var Buffer: TUCS4Array; Start, Count: SizeInt): Longint; override; + function InternalSetNextChar(S: TStream; Ch: UCS4): Boolean; override; + function InternalSetNextBuffer(S: TStream; const Buffer: TUCS4Array; Start, Count: SizeInt): Longint; override; + public + constructor Create(AStream: TStream; AOwnsStream: Boolean = False); override; + end; + + TJclStringEncoding = (seAnsi, seUTF8, seUTF16, seAuto); + + TJclAutoStream = class(TJclStringStream) + private + FCodePage: Word; + FEncoding: TJclStringEncoding; + procedure SetCodePage(Value: Word); + protected + function InternalGetNextChar(S: TStream; out Ch: UCS4): Boolean; override; + function InternalGetNextBuffer(S: TStream; var Buffer: TUCS4Array; Start, Count: SizeInt): Longint; override; + function InternalSetNextChar(S: TStream; Ch: UCS4): Boolean; override; + function InternalSetNextBuffer(S: TStream; const Buffer: TUCS4Array; Start, Count: SizeInt): Longint; override; + public + constructor Create(AStream: TStream; AOwnsStream: Boolean = False); override; + function SkipBOM: LongInt; override; + property CodePage: Word read FCodePage write SetCodePage; + property Encoding: TJclStringEncoding read FEncoding; + end; + +{$ENDIF ~WINSCP} + +// buffered copy of all available bytes from Source to Dest +// returns the number of bytes that were copied +function StreamCopy(Source: TStream; Dest: TStream; BufferSize: Longint = StreamDefaultBufferSize): Int64; + +{$IFNDEF WINSCP} +// buffered copy of all available characters from Source to Dest +// retuns the number of characters (in specified encoding) that were copied +function StringStreamCopy(Source, Dest: TJclStringStream; BufferLength: Longint = StreamDefaultBufferSize): Int64; +function AnsiStringStreamCopy(Source, Dest: TJclStringStream; BufferLength: Longint = StreamDefaultBufferSize): Int64; +function WideStringStreamCopy(Source, Dest: TJclStringStream; BufferLength: Longint = StreamDefaultBufferSize): Int64; +{$ENDIF ~WINSCP} + +// compares 2 streams for differencies +function CompareStreams(A, B : TStream; BufferSize: Longint = StreamDefaultBufferSize): Boolean; +// compares 2 files for differencies (calling CompareStreams) +function CompareFiles(const FileA, FileB: TFileName; BufferSize: Longint = StreamDefaultBufferSize): Boolean; + +{$IFDEF UNITVERSIONING} +const + UnitVersioning: TUnitVersionInfo = ( + RCSfile: '$URL$'; + Revision: '$Revision$'; + Date: '$Date$'; + LogPath: 'JCL\source\common'; + Extra: ''; + Data: nil + ); +{$ENDIF UNITVERSIONING} + +implementation + +uses + {$IFDEF HAS_UNITSCOPE} + System.Types, + {$ENDIF HAS_UNITSCOPE} + JclResources{$IFNDEF WINSCP}, + JclCharsets{$ENDIF ~WINSCP}{, + JclMath, + JclSysUtils}; + +function StreamCopy(Source: TStream; Dest: TStream; BufferSize: Longint): Int64; +var + Buffer: array of Byte; + ByteCount: Longint; +begin + Result := 0; + SetLength(Buffer, BufferSize); + repeat + ByteCount := Source.Read(Buffer[0], BufferSize); + Result := Result + ByteCount; + Dest.WriteBuffer(Buffer[0], ByteCount); + until ByteCount < BufferSize; +end; + +{$IFNDEF WINSCP} +function StringStreamCopy(Source, Dest: TJclStringStream; BufferLength: Longint): Int64; +var + Buffer: string; + CharCount: Longint; +begin + Result := 0; + SetLength(Buffer, BufferLength); + repeat + CharCount := Source.ReadString(Buffer, 1, BufferLength); + Result := Result + CharCount; + CharCount := Dest.WriteString(Buffer, 1, CharCount); + until CharCount = 0; +end; + +function AnsiStringStreamCopy(Source, Dest: TJclStringStream; BufferLength: Longint): Int64; +var + Buffer: AnsiString; + CharCount: Longint; +begin + Result := 0; + SetLength(Buffer, BufferLength); + repeat + CharCount := Source.ReadAnsiString(Buffer, 1, BufferLength); + Result := Result + CharCount; + CharCount := Dest.WriteAnsiString(Buffer, 1, CharCount); + until CharCount = 0; +end; + +function WideStringStreamCopy(Source, Dest: TJclStringStream; BufferLength: Longint): Int64; +var + Buffer: WideString; + CharCount: Longint; +begin + Result := 0; + SetLength(Buffer, BufferLength); + repeat + CharCount := Source.ReadWideString(Buffer, 1, BufferLength); + Result := Result + CharCount; + CharCount := Dest.WriteWideString(Buffer, 1, CharCount); + until CharCount = 0; +end; +{$ENDIF ~WINSCP} + +function CompareStreams(A, B : TStream; BufferSize: Longint): Boolean; +var + BufferA, BufferB: array of Byte; + ByteCountA, ByteCountB: Longint; +begin + SetLength(BufferA, BufferSize); + try + SetLength(BufferB, BufferSize); + try + repeat + ByteCountA := A.Read(BufferA[0], BufferSize); + ByteCountB := B.Read(BufferB[0], BufferSize); + + Result := (ByteCountA = ByteCountB); + Result := Result and CompareMem(BufferA, BufferB, ByteCountA); + until (ByteCountA <> BufferSize) or (ByteCountB <> BufferSize) or not Result; + finally + SetLength(BufferB, 0); + end; + finally + SetLength(BufferA, 0); + end; +end; + +function CompareFiles(const FileA, FileB: TFileName; BufferSize: Longint): Boolean; +var + A, B: TStream; +begin + A := TFileStream.Create(FileA, fmOpenRead or fmShareDenyWrite); + try + B := TFileStream.Create(FileB, fmOpenRead or fmShareDenyWrite); + try + Result := CompareStreams(A, B, BufferSize); + finally + B.Free; + end; + finally + A.Free; + end; +end; + +//=== { TJclStream } ========================================================= + +function TJclStream.Seek(Offset: Longint; Origin: Word): Longint; +var + Result64: Int64; +begin + case Origin of + soFromBeginning: + Result64 := Seek(Int64(Offset), soBeginning); + soFromCurrent: + Result64 := Seek(Int64(Offset), soCurrent); + soFromEnd: + Result64 := Seek(Int64(Offset), soEnd); + else + Result64 := -1; + end; + if (Result64 < 0) or (Result64 > High(Longint)) then + Result64 := -1; + Result := Result64; +end; + +procedure TJclStream.LoadFromFile(const FileName: TFileName; + BufferSize: Integer); +var + FS: TStream; +begin + FS := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite); + try + LoadFromStream(FS, BufferSize); + finally + FS.Free; + end; +end; + +procedure TJclStream.LoadFromStream(Source: TStream; BufferSize: Integer); +begin + StreamCopy(Source, Self, BufferSize); +end; + +procedure TJclStream.SaveToFile(const FileName: TFileName; BufferSize: Integer); +var + FS: TStream; +begin + FS := TFileStream.Create(FileName, fmCreate); + try + SaveToStream(FS, BufferSize); + finally + FS.Free; + end; +end; + +procedure TJclStream.SaveToStream(Dest: TStream; BufferSize: Integer); +begin + StreamCopy(Self, Dest, BufferSize); +end; + +function TJclStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; +begin + // override to customize + Result := -1; +end; + +procedure TJclStream.SetSize(NewSize: Longint); +begin + SetSize(Int64(NewSize)); +end; + +procedure TJclStream.SetSize(const NewSize: Int64); +begin + // override to customize +end; + +//=== { TJclHandleStream } =================================================== + +constructor TJclHandleStream.Create(AHandle: THandle); +begin + inherited Create; + FHandle := AHandle; +end; + +function TJclHandleStream.Read(var Buffer; Count: Longint): Longint; +begin + Result := 0; + {$IFDEF MSWINDOWS} + if (Count <= 0) or not ReadFile(Handle, Buffer, DWORD(Count), DWORD(Result), nil) then + Result := 0; + {$ENDIF MSWINDOWS} + {$IFDEF LINUX} + Result := __read(Handle, Buffer, Count); + {$ENDIF LINUX} +end; + +function TJclHandleStream.Write(const Buffer; Count: Longint): Longint; +begin + Result := 0; + {$IFDEF MSWINDOWS} + if (Count <= 0) or not WriteFile(Handle, Buffer, DWORD(Count), DWORD(Result), nil) then + Result := 0; + {$ENDIF MSWINDOWS} + {$IFDEF LINUX} + Result := __write(Handle, Buffer, Count); + {$ENDIF LINUX} +end; + +{$IFDEF MSWINDOWS} +function TJclHandleStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; +const + INVALID_SET_FILE_POINTER = -1; +type + TLarge = record + case Boolean of + False: + (OffsetLo: Longint; + OffsetHi: Longint); + True: + (Offset64: Int64); + end; +var + Offs: TLarge; +begin + Offs.Offset64 := Offset; + Offs.OffsetLo := SetFilePointer(Handle, Offs.OffsetLo, @Offs.OffsetHi, Ord(Origin)); + if (Offs.OffsetLo = INVALID_SET_FILE_POINTER) and (GetLastError <> NO_ERROR) then + Result := -1 + else + Result := Offs.Offset64; +end; +{$ENDIF MSWINDOWS} +{$IFDEF LINUX} +function TJclHandleStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; +const + SeekOrigins: array [TSeekOrigin] of Cardinal = ( SEEK_SET {soBeginning}, SEEK_CUR {soCurrent}, SEEK_END {soEnd} ); +begin + Result := lseek(Handle, Offset, SeekOrigins[Origin]); +end; +{$ENDIF LINUX} + +procedure TJclHandleStream.SetSize(const NewSize: Int64); +begin + Seek(NewSize, soBeginning); + {$IFDEF MSWINDOWS} + if not SetEndOfFile(Handle) then + RaiseLastOSError; + {$ENDIF MSWINDOWS} + {$IFDEF LINUX} + if ftruncate(Handle, Position) = -1 then + raise EJclStreamError.CreateRes(@RsStreamsSetSizeError); + {$ENDIF LINUX} +end; + +//=== { TJclFileStream } ===================================================== + +constructor TJclFileStream.Create(const FileName: TFileName; Mode: Word; Rights: Cardinal); +var + H: THandle; +{$IFDEF LINUX} +const + INVALID_HANDLE_VALUE = -1; +{$ENDIF LINUX} +begin + if Mode = fmCreate then + begin + {$IFDEF LINUX} + H := open(PChar(FileName), O_CREAT or O_RDWR, Rights); + {$ENDIF LINUX} + {$IFDEF MSWINDOWS} + H := CreateFile(PChar(FileName), GENERIC_READ or GENERIC_WRITE, + 0, nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); + {$ENDIF MSWINDOWS} + inherited Create(H); + if Handle = INVALID_HANDLE_VALUE then + raise EJclStreamError.CreateResFmt(@RsStreamsCreateError, [FileName]); + end + else + begin + H := THandle(FileOpen(FileName, Mode)); + inherited Create(H); + if Handle = INVALID_HANDLE_VALUE then + raise EJclStreamError.CreateResFmt(@RsStreamsOpenError, [FileName]); + end; +end; + +destructor TJclFileStream.Destroy; +begin + {$IFDEF MSWINDOWS} + if Handle <> INVALID_HANDLE_VALUE then + CloseHandle(Handle); + {$ENDIF MSWINDOWS} + {$IFDEF LINUX} + __close(Handle); + {$ENDIF LINUX} + inherited Destroy; +end; + +//=== { TJclEmptyStream } ==================================================== + +// a stream which stays empty no matter what you do +// so it is a Unix /dev/null equivalent + +procedure TJclEmptyStream.SetSize(const NewSize: Int64); +begin + // nothing +end; + +function TJclEmptyStream.Read(var Buffer; Count: Longint): Longint; +begin + // you cannot read anything + Result := 0; +end; + +function TJclEmptyStream.Write(const Buffer; Count: Longint): Longint; +begin + // you cannot write anything + Result := 0; +end; + +function TJclEmptyStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; +begin + if Offset <> 0 then + // seeking to anywhere except the position 0 is an error + Result := -1 + else + Result := 0; +end; + +{$IFNDEF WINSCP} + +//=== { TJclNullStream } ===================================================== + +// a stream which only keeps position and size, but no data +// so it is a Unix /dev/zero equivalent (?) + +procedure TJclNullStream.SetSize(const NewSize: Int64); +begin + if NewSize > 0 then + FSize := NewSize + else + FSize := 0; + if FPosition > FSize then + FPosition := FSize; +end; + +function TJclNullStream.Read(var Buffer; Count: Longint): Longint; +begin + if Count < 0 then + Count := 0; + // FPosition > FSize is possible! + if FSize - FPosition < Count then + Count := FSize - FPosition; + // does not read if beyond EOF + if Count > 0 then + begin + ResetMemory(Buffer, Count); + FPosition := FPosition + Count; + end; + Result := Count; +end; + +function TJclNullStream.Write(const Buffer; Count: Longint): Longint; +begin + if Count < 0 then + Count := 0; + FPosition := FPosition + Count; + // writing when FPosition > FSize is possible! + if FPosition > FSize then + FSize := FPosition; + Result := Count; +end; + +function TJclNullStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; +var + Rel: Int64; +begin + case Origin of + soBeginning: + Rel := 0; + soCurrent: + Rel := FPosition; + soEnd: + Rel := FSize; + else + // force Rel + Offset = -1 (code is never reached) + Rel := Offset - 1; + end; + if Rel + Offset >= 0 then + begin + // all non-negative destination positions including beyond EOF are valid + FPosition := Rel + Offset; + Result := FPosition; + end + else + Result := -1; +end; + +//=== { TJclRandomStream } =================================================== + +// A TJclNullStream decendant which returns random data when read +// so it is a Unix /dev/random equivalent + +function TJclRandomStream.GetRandSeed: Longint; +begin + Result := System.RandSeed; +end; + +procedure TJclRandomStream.SetRandSeed(Seed: Longint); +begin + System.RandSeed := Seed; +end; + +function TJclRandomStream.RandomData: Byte; +begin + Result := System.Random(256); +end; + +procedure TJclRandomStream.Randomize; +begin + System.Randomize; +end; + +function TJclRandomStream.Read(var Buffer; Count: Longint): Longint; +var + I: Longint; + BufferPtr: PByte; +begin + // this handles all necessary checks + Count := inherited Read(Buffer, Count); + BufferPtr := @Buffer; + for I := 0 to Count - 1 do + begin + BufferPtr^ := RandomData; + Inc(BufferPtr); + end; + Result := Count; +end; + +{$ENDIF ~WINSCP} + +//=== { TJclMultiplexStream } ================================================ + +constructor TJclMultiplexStream.Create; +begin + inherited Create; + FStreams := TList.Create; + FReadStreamIndex := -1; +end; + +destructor TJclMultiplexStream.Destroy; +begin + FStreams.Free; + inherited Destroy; +end; + +function TJclMultiplexStream.Add(NewStream: TStream): Integer; +begin + Result := FStreams.Add(Pointer(NewStream)); +end; + +procedure TJclMultiplexStream.Clear; +begin + FStreams.Clear; + FReadStreamIndex := -1; +end; + +procedure TJclMultiplexStream.Delete(const Index: Integer); +begin + FStreams.Delete(Index); + if ReadStreamIndex = Index then + FReadStreamIndex := -1 + else + if ReadStreamIndex > Index then + Dec(FReadStreamIndex); +end; + +function TJclMultiplexStream.GetReadStream: TStream; +begin + if FReadStreamIndex >= 0 then + Result := TStream(FStreams.Items[FReadStreamIndex]) + else + Result := nil; +end; + +function TJclMultiplexStream.GetStream(Index: Integer): TStream; +begin + Result := TStream(FStreams.Items[Index]); +end; + +function TJclMultiplexStream.GetCount: Integer; +begin + Result := FStreams.Count; +end; + +function TJclMultiplexStream.Read(var Buffer; Count: Longint): Longint; +var + Stream: TStream; +begin + Stream := ReadStream; + if Assigned(Stream) then + Result := Stream.Read(Buffer, Count) + else + Result := 0; +end; + +function TJclMultiplexStream.Remove(AStream: TStream): Integer; +begin + Result := FStreams.Remove(Pointer(AStream)); + if FReadStreamIndex = Result then + FReadStreamIndex := -1 + else + if FReadStreamIndex > Result then + Dec(FReadStreamIndex); +end; + +function TJclMultiplexStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; +begin + // what should this function do? + Result := -1; +end; + +procedure TJclMultiplexStream.SetReadStream(const Value: TStream); +begin + FReadStreamIndex := FStreams.IndexOf(Pointer(Value)); +end; + +procedure TJclMultiplexStream.SetReadStreamIndex(const Value: Integer); +begin + FReadStreamIndex := Value; +end; + +procedure TJclMultiplexStream.SetSize(const NewSize: Int64); +begin + // what should this function do? +end; + +procedure TJclMultiplexStream.SetStream(Index: Integer; const Value: TStream); +begin + FStreams.Items[Index] := Pointer(Value); +end; + +function TJclMultiplexStream.Write(const Buffer; Count: Longint): Longint; +var + Index: Integer; + ByteWritten, MinByteWritten: Longint; +begin + MinByteWritten := Count; + for Index := 0 to Self.Count - 1 do + begin + ByteWritten := TStream(FStreams.Items[Index]).Write(Buffer, Count); + if ByteWritten < MinByteWritten then + MinByteWritten := ByteWritten; + end; + Result := MinByteWritten; +end; + +//=== { TJclStreamDecorator } ================================================ + +constructor TJclStreamDecorator.Create(AStream: TStream; AOwnsStream: Boolean = False); +begin + inherited Create; + FStream := AStream; + FOwnsStream := AOwnsStream; +end; + +destructor TJclStreamDecorator.Destroy; +begin + if OwnsStream then + FStream.Free; + inherited Destroy; +end; + +procedure TJclStreamDecorator.DoAfterStreamChange; +begin + if Assigned(FAfterStreamChange) then + FAfterStreamChange(Self); +end; + +procedure TJclStreamDecorator.DoBeforeStreamChange; +begin + if Assigned(FBeforeStreamChange) then + FBeforeStreamChange(Self); +end; + +function TJclStreamDecorator.Read(var Buffer; Count: Longint): Longint; +begin + if Assigned(FStream) then + Result := Stream.Read(Buffer, Count) + else + Result := 0; +end; + +function TJclStreamDecorator.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; +begin + Result := Stream.Seek(Offset, Origin); +end; + +procedure TJclStreamDecorator.SetSize(const NewSize: Int64); +begin + if Assigned(FStream) then + Stream.Size := NewSize; +end; + +procedure TJclStreamDecorator.SetStream(Value: TStream); +begin + if Value <> FStream then + try + DoBeforeStreamChange; + finally + if OwnsStream then + FStream.Free; + FStream := Value; + DoAfterStreamChange; + end; +end; + +function TJclStreamDecorator.Write(const Buffer; Count: Longint): Longint; +begin + if Assigned(FStream) then + Result := Stream.Write(Buffer, Count) + else + Result := 0; +end; + +//=== { TJclBufferedStream } ================================================= + +constructor TJclBufferedStream.Create(AStream: TStream; AOwnsStream: Boolean = False); +begin + inherited Create(AStream, AOwnsStream); + if Stream <> nil then + FPosition := Stream.Position; + BufferSize := StreamDefaultBufferSize; + LoadBuffer; +end; + +destructor TJclBufferedStream.Destroy; +begin + Flush; + inherited Destroy; +end; + +function TJclBufferedStream.BufferHit: Boolean; +begin + Result := (FBufferStart <= FPosition) and (FPosition < (FBufferStart + FBufferCurrentSize)); +end; + +procedure TJclBufferedStream.DoAfterStreamChange; +begin + inherited DoAfterStreamChange; + FBufferCurrentSize := 0; // invalidate buffer after stream is changed + FBufferStart := 0; + if Stream <> nil then + FPosition := Stream.Position; +end; + +procedure TJclBufferedStream.DoBeforeStreamChange; +begin + inherited DoBeforeStreamChange; + Flush; +end; + +procedure TJclBufferedStream.Flush; +begin + if (Stream <> nil) and (FBufferMaxModifiedPos > 0) then + begin + Stream.Position := FBufferStart; + Stream.WriteBuffer(FBuffer[0], FBufferMaxModifiedPos); + FBufferMaxModifiedPos := 0; + end; +end; + +function TJclBufferedStream.GetCalcedSize: Int64; +begin + if Assigned(Stream) then + Result := Stream.Size + else + Result := 0; + if Result < FBufferMaxModifiedPos + FBufferStart then + Result := FBufferMaxModifiedPos + FBufferStart; +end; + +function TJclBufferedStream.LoadBuffer: Boolean; +begin + Flush; + if Length(FBuffer) <> FBufferSize then + SetLength(FBuffer, FBufferSize); + if Stream <> nil then + begin + Stream.Position := FPosition; + FBufferCurrentSize := Stream.Read(FBuffer[0], FBufferSize); + end + else + FBufferCurrentSize := 0; + FBufferStart := FPosition; + Result := (FBufferCurrentSize > 0); +end; + +function TJclBufferedStream.Read(var Buffer; Count: Longint): Longint; +const + Offset = 0; +begin + Result := Count + Offset; + while Count > 0 do + begin + if not BufferHit then + if not LoadBuffer then + Break; + Dec(Count, ReadFromBuffer(Buffer, Count, Result - Count)); + end; + Result := Result - Count - Offset; +end; + +function TJclBufferedStream.ReadFromBuffer(var Buffer; Count, Start: Longint): Longint; +var + BufPos: Longint; + P: PAnsiChar; +begin + Result := Count; + BufPos := FPosition - FBufferStart; + if Result > FBufferCurrentSize - BufPos then + Result := FBufferCurrentSize - BufPos; + P := @Buffer; + Move(FBuffer[BufPos], P[Start], Result); + Inc(FPosition, Result); +end; + +function TJclBufferedStream.Seek(const Offset: Int64; + Origin: TSeekOrigin): Int64; +var + NewPos: Int64; +begin + NewPos := FPosition; + case Origin of + soBeginning: + NewPos := Offset; + soCurrent: + Inc(NewPos, Offset); + soEnd: + NewPos := GetCalcedSize + Offset; + else + NewPos := -1; + end; + if NewPos < 0 then + NewPos := -1 + else + FPosition := NewPos; + Result := NewPos; +end; + +procedure TJclBufferedStream.SetSize(const NewSize: Int64); +begin + inherited SetSize(NewSize); + if NewSize < (FBufferStart + FBufferMaxModifiedPos) then + begin + FBufferMaxModifiedPos := NewSize - FBufferStart; + if FBufferMaxModifiedPos < 0 then + FBufferMaxModifiedPos := 0; + end; + if NewSize < (FBufferStart + FBufferCurrentSize) then + begin + FBufferCurrentSize := NewSize - FBufferStart; + if FBufferCurrentSize < 0 then + FBufferCurrentSize := 0; + end; + // fix from Marcelo Rocha + if Stream <> nil then + FPosition := Stream.Position; +end; + +function TJclBufferedStream.Write(const Buffer; Count: Longint): Longint; +const + Offset = 0; +begin + Result := Count + Offset; + while Count > 0 do + begin + if (FBufferStart > FPosition) or (FPosition >= (FBufferStart + FBufferSize)) then + LoadBuffer; + Dec(Count, WriteToBuffer(Buffer, Count, Result - Count)); + end; + Result := Result - Count - Offset; +end; + +function TJclBufferedStream.WriteToBuffer(const Buffer; Count, Start: Longint): Longint; +var + BufPos: Longint; + P: PAnsiChar; +begin + Result := Count; + BufPos := FPosition - FBufferStart; + if Result > Length(FBuffer) - BufPos then + Result := Length(FBuffer) - BufPos; + if FBufferCurrentSize < BufPos + Result then + FBufferCurrentSize := BufPos + Result; + P := @Buffer; + Move(P[Start], FBuffer[BufPos], Result); + if FBufferMaxModifiedPos < BufPos + Result then + FBufferMaxModifiedPos := BufPos + Result; + Inc(FPosition, Result); +end; + +//=== { TJclEventStream } ==================================================== + +constructor TJclEventStream.Create(AStream: TStream; ANotification: + TStreamNotifyEvent = nil; AOwnsStream: Boolean = False); +begin + inherited Create(AStream, AOwnsStream); + FNotification := ANotification; +end; + +procedure TJclEventStream.DoAfterStreamChange; +begin + inherited DoAfterStreamChange; + if Stream <> nil then + DoNotification; +end; + +procedure TJclEventStream.DoBeforeStreamChange; +begin + inherited DoBeforeStreamChange; + if Stream <> nil then + DoNotification; +end; + +procedure TJclEventStream.DoNotification; +begin + if Assigned(FNotification) then + FNotification(Self, Stream.Position, Stream.Size); +end; + +function TJclEventStream.Read(var Buffer; Count: Longint): Longint; +begin + Result := inherited Read(Buffer, Count); + DoNotification; +end; + +function TJclEventStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; +begin + Result := inherited Seek(Offset, Origin); + DoNotification; +end; + +procedure TJclEventStream.SetSize(const NewSize: Int64); +begin + inherited SetSize(NewSize); + DoNotification; +end; + +function TJclEventStream.Write(const Buffer; Count: Longint): Longint; +begin + Result := inherited Write(Buffer, Count); + DoNotification; +end; + +//=== { TJclEasyStream } ===================================================== + +function TJclEasyStream.IsEqual(Stream: TStream): Boolean; +var + SavePos, StreamSavePos: Int64; +begin + SavePos := Position; + StreamSavePos := Stream.Position; + try + Position := 0; + Stream.Position := 0; + Result := CompareStreams(Self, Stream); + finally + Position := SavePos; + Stream.Position := StreamSavePos; + end; +end; + +function TJclEasyStream.ReadBoolean: Boolean; +begin + Result := False; + ReadBuffer(Result, SizeOf(Result)); +end; + +function TJclEasyStream.ReadChar: Char; +begin + Result := #0; + ReadBuffer(Result, SizeOf(Result)); +end; + +function TJclEasyStream.ReadAnsiChar: AnsiChar; +begin + Result := #0; + ReadBuffer(Result, SizeOf(Result)); +end; + +function TJclEasyStream.ReadWideChar: WideChar; +begin + Result := #0; + ReadBuffer(Result, SizeOf(Result)); +end; + +function TJclEasyStream.ReadByte: Byte; +begin + Result := 0; + ReadBuffer(Result, SizeOf(Result)); +end; + +function TJclEasyStream.ReadCurrency: Currency; +begin + Result := 0; + ReadBuffer(Result, SizeOf(Result)); +end; + +function TJclEasyStream.ReadDateTime: TDateTime; +begin + Result := 0; + ReadBuffer(Result, SizeOf(Result)); +end; + +function TJclEasyStream.ReadDouble: Double; +begin + Result := 0; + ReadBuffer(Result, SizeOf(Result)); +end; + +function TJclEasyStream.ReadExtended: Extended; +begin + Result := 0; + ReadBuffer(Result, SizeOf(Result)); +end; + +function TJclEasyStream.ReadInt64: Int64; +begin + Result := 0; + ReadBuffer(Result, SizeOf(Result)); +end; + +function TJclEasyStream.ReadInteger: Integer; +begin + Result := 0; + ReadBuffer(Result, SizeOf(Result)); +end; + +function TJclEasyStream.ReadCString: string; +begin + {$IFDEF SUPPORTS_UNICODE} + Result := ReadCWideString; + {$ELSE ~SUPPORTS_UNICODE} + Result := ReadCAnsiString; + {$ENDIF ~SUPPORTS_UNICODE} +end; + +function TJclEasyStream.ReadCAnsiString: AnsiString; +var + CurrPos: Longint; + StrSize: Integer; +begin + CurrPos := Position; + repeat + until ReadAnsiChar = #0; + StrSize := Position - CurrPos; // Get number of bytes + SetLength(Result, StrSize div SizeOf(AnsiChar) - 1); // Set number of chars without #0 + Position := CurrPos; // Seek to start read + ReadBuffer(Result[1], StrSize); // Read ansi data and #0 +end; + +function TJclEasyStream.ReadCWideString: WideString; +var + CurrPos: Integer; + StrSize: Integer; +begin + CurrPos := Position; + repeat + until ReadWideChar = #0; + StrSize := Position - CurrPos; // Get number of bytes + SetLength(Result, StrSize div SizeOf(WideChar) - 1); // Set number of chars without #0 + Position := CurrPos; // Seek to start read + ReadBuffer(Result[1], StrSize); // Read wide data and #0 +end; + +function TJclEasyStream.ReadShortString: string; +var + StrSize: Integer; +begin + StrSize := Ord(ReadChar); + SetString(Result, PChar(nil), StrSize); + ReadBuffer(Pointer(Result)^, StrSize); +end; + +function TJclEasyStream.ReadSingle: Single; +begin + Result := 0; + ReadBuffer(Result, SizeOf(Result)); +end; + +function TJclEasyStream.ReadSizedString: string; +begin + {$IFDEF SUPPORTS_UNICODE} + Result := ReadSizedWideString; + {$ELSE ~SUPPORTS_UNICODE} + Result := ReadSizedAnsiString; + {$ENDIF ~SUPPORTS_UNICODE} +end; + +function TJclEasyStream.ReadSizedAnsiString: AnsiString; +var + StrSize: Integer; +begin + StrSize := ReadInteger; + SetLength(Result, StrSize); + ReadBuffer(Result[1], StrSize * SizeOf(Result[1])); +end; + +function TJclEasyStream.ReadSizedWideString: WideString; +var + StrSize: Integer; +begin + StrSize := ReadInteger; + SetLength(Result, StrSize); + ReadBuffer(Result[1], StrSize * SizeOf(Result[1])); +end; + +procedure TJclEasyStream.WriteBoolean(Value: Boolean); +begin + WriteBuffer(Value, SizeOf(Value)); +end; + +procedure TJclEasyStream.WriteChar(Value: Char); +begin + WriteBuffer(Value, SizeOf(Value)); +end; + +procedure TJclEasyStream.WriteAnsiChar(Value: AnsiChar); +begin + WriteBuffer(Value, SizeOf(Value)); +end; + +procedure TJclEasyStream.WriteWideChar(Value: WideChar); +begin + WriteBuffer(Value, SizeOf(Value)); +end; + +procedure TJclEasyStream.WriteByte(Value: Byte); +begin + WriteBuffer(Value, SizeOf(Value)); +end; + +procedure TJclEasyStream.WriteCurrency(const Value: Currency); +begin + WriteBuffer(Value, SizeOf(Value)); +end; + +procedure TJclEasyStream.WriteDateTime(const Value: TDateTime); +begin + WriteBuffer(Value, SizeOf(Value)); +end; + +procedure TJclEasyStream.WriteDouble(const Value: Double); +begin + WriteBuffer(Value, SizeOf(Value)); +end; + +procedure TJclEasyStream.WriteExtended(const Value: Extended); +begin + WriteBuffer(Value, SizeOf(Value)); +end; + +procedure TJclEasyStream.WriteInt64(Value: Int64); +begin + WriteBuffer(Value, SizeOf(Value)); +end; + +procedure TJclEasyStream.WriteInteger(Value: Integer); +begin + WriteBuffer(Value, SizeOf(Value)); +end; + +procedure TJclEasyStream.WriteCString(const Value: string); +begin + {$IFDEF SUPPORTS_UNICODE} + WriteCWideString(Value); + {$ELSE ~SUPPORTS_UNICODE} + WriteCAnsiString(Value); + {$ENDIF ~SUPPORTS_UNICODE} +end; + +procedure TJclEasyStream.WriteCAnsiString(const Value: AnsiString); +var + StrSize: Integer; +begin + StrSize := Length(Value); + WriteBuffer(Value[1], (StrSize + 1) * SizeOf(Value[1])); +end; + +procedure TJclEasyStream.WriteCWideString(const Value: WideString); +var + StrSize: Integer; +begin + StrSize := Length(Value); + WriteBuffer(Value[1], (StrSize + 1) * SizeOf(Value[1])); +end; + +procedure TJclEasyStream.WriteShortString(const Value: ShortString); +begin + WriteBuffer(Value[0], Length(Value) + 1); +end; + +procedure TJclEasyStream.WriteSingle(const Value: Single); +begin + WriteBuffer(Value, SizeOf(Value)); +end; + +procedure TJclEasyStream.WriteSizedString(const Value: string); +begin + {$IFDEF SUPPORTS_UNICODE} + WriteSizedWideString(Value); + {$ELSE ~SUPPORTS_UNICODE} + WriteSizedAnsiString(Value); + {$ENDIF ~SUPPORTS_UNICODE} +end; + +procedure TJclEasyStream.WriteSizedAnsiString(const Value: AnsiString); +var + StrSize: Integer; +begin + StrSize := Length(Value); + WriteInteger(StrSize); + WriteBuffer(Value[1], StrSize * SizeOf(Value[1])); +end; + +procedure TJclEasyStream.WriteSizedWideString(const Value: WideString); +var + StrSize: Integer; +begin + StrSize := Length(Value); + WriteInteger(StrSize); + WriteBuffer(Value[1], StrSize * SizeOf(Value[1])); +end; + +//=== { TJclScopedStream } =================================================== + +constructor TJclScopedStream.Create(AParentStream: TStream; const AMaxSize: Int64); +begin + inherited Create; + + FParentStream := AParentStream; + FStartPos := ParentStream.Position; + FCurrentPos := 0; + FMaxSize := AMaxSize; +end; + +constructor TJclScopedStream.Create(AParentStream: TStream; const AStartPos, AMaxSize: Int64); +begin + inherited Create; + + FParentStream := AParentStream; + FStartPos := AStartPos; + FCurrentPos := 0; + FMaxSize := AMaxSize; +end; + +function TJclScopedStream.Read(var Buffer; Count: Longint): Longint; +begin + if (MaxSize >= 0) and ((FCurrentPos + Count) > MaxSize) then + Count := MaxSize - FCurrentPos; + + if (Count > 0) and Assigned(ParentStream) then + begin + Result := ParentStream.Read(Buffer, Count); + Inc(FCurrentPos, Result); + end + else + Result := 0; +end; + +function TJclScopedStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; +begin + case Origin of + soBeginning: + begin + if (Offset < 0) or ((MaxSize >= 0) and (Offset > MaxSize)) then + Result := -1 // low and high bound check + else + Result := ParentStream.Seek(StartPos + Offset, soBeginning) - StartPos; + end; + soCurrent: + begin + if Offset = 0 then + Result := FCurrentPos // speeding the Position property up + else if ((FCurrentPos + Offset) < 0) or ((MaxSize >= 0) + and ((FCurrentPos + Offset) > MaxSize)) then + Result := -1 // low and high bound check + else + Result := ParentStream.Seek(Offset, soCurrent) - StartPos; + end; + soEnd: + begin + if (MaxSize >= 0) then + begin + if (Offset > 0) or (MaxSize < -Offset) then // low and high bound check + Result := -1 + else + Result := ParentStream.Seek(StartPos + MaxSize + Offset, soBeginning) - StartPos; + end + else + begin + Result := ParentStream.Seek(Offset, soEnd); + if (Result <> -1) and (Result < StartPos) then // low bound check + begin + Result := -1; + ParentStream.Seek(StartPos + FCurrentPos, soBeginning); + end; + end; + end; + else + Result := -1; + end; + if Result <> -1 then + FCurrentPos := Result; +end; + +procedure TJclScopedStream.SetSize(const NewSize: Int64); +var + ScopedNewSize: Int64; +begin + if (FMaxSize >= 0) and (NewSize >= (FStartPos + FMaxSize)) then + ScopedNewSize := FMaxSize + FStartPos + else + ScopedNewSize := NewSize; + inherited SetSize(ScopedNewSize); +end; + +function TJclScopedStream.Write(const Buffer; Count: Longint): Longint; +begin + if (MaxSize >= 0) and ((FCurrentPos + Count) > MaxSize) then + Count := MaxSize - FCurrentPos; + + if (Count > 0) and Assigned(ParentStream) then + begin + Result := ParentStream.Write(Buffer, Count); + Inc(FCurrentPos, Result); + end + else + Result := 0; +end; + +//=== { TJclDelegateStream } ================================================= + +procedure TJclDelegatedStream.SetSize(const NewSize: Int64); +begin + if Assigned(FOnSize) then + FOnSize(Self, NewSize); +end; + +function TJclDelegatedStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; +begin + if Assigned(FOnSeek) then + Result := FOnSeek(Self, Offset, Origin) + else + Result := -1; +end; + +function TJclDelegatedStream.Read(var Buffer; Count: Longint): Longint; +begin + if Assigned(FOnRead) then + Result := FOnRead(Self, Buffer, Count) + else + Result := -1; +end; + +function TJclDelegatedStream.Write(const Buffer; Count: Longint): Longint; +begin + if Assigned(FOnWrite) then + Result := FOnWrite(Self, Buffer, Count) + else + Result := -1; +end; + +//=== { TJclSectoredStream } ================================================= + +procedure TJclSectoredStream.AfterBlockRead; +begin + // override to customize (checks of protection) +end; + +procedure TJclSectoredStream.BeforeBlockWrite; +begin + // override to customize (computation of protection) +end; + +constructor TJclSectoredStream.Create(AStorageStream: TStream; + AOwnsStream: Boolean; ASectorOverHead: Integer); +begin + inherited Create(AStorageStream, AOwnsStream); + FSectorOverHead := ASectorOverHead; + if Stream <> nil then + FPosition := SectoredToFlat(Stream.Position); +end; + +procedure TJclSectoredStream.DoAfterStreamChange; +begin + inherited DoAfterStreamChange; + if Stream <> nil then + FPosition := SectoredToFlat(Stream.Position); +end; + +function TJclSectoredStream.FlatToSectored(const Position: Int64): Int64; +begin + Result := (Position div BufferSize) * (Int64(BufferSize) + FSectorOverHead) // add overheads of previous buffers + + (Position mod BufferSize); // offset in sector +end; + +procedure TJclSectoredStream.Flush; +begin + if (Stream <> nil) and (FBufferMaxModifiedPos > 0) then + begin + BeforeBlockWrite; + + Stream.Position := FlatToSectored(FBufferStart); + Stream.WriteBuffer(FBuffer[0], FBufferCurrentSize + FSectorOverHead); + FBufferMaxModifiedPos := 0; + end; +end; + +function TJclSectoredStream.GetCalcedSize: Int64; +var + VirtualSize: Int64; +begin + if Assigned(Stream) then + Result := SectoredToFlat(Stream.Size) + else + Result := 0; + VirtualSize := FBufferMaxModifiedPos + FBufferStart; + if Result < VirtualSize then + Result := VirtualSize; +end; + +function TJclSectoredStream.LoadBuffer: Boolean; +var + TotalSectorSize: Longint; +begin + Flush; + TotalSectorSize := FBufferSize + FSectorOverHead; + if Length(FBuffer) <> TotalSectorSize then + SetLength(FBuffer, TotalSectorSize); + FBufferStart := (FPosition div BufferSize) * BufferSize; + if Stream <> nil then + begin + Stream.Position := FlatToSectored(FBufferStart); + FBufferCurrentSize := Stream.Read(FBuffer[0], TotalSectorSize); + if FBufferCurrentSize > 0 then + begin + Dec(FBufferCurrentSize, FSectorOverHead); + AfterBlockRead; + end; + end + else + FBufferCurrentSize := 0; + Result := (FBufferCurrentSize > 0); +end; + +function TJclSectoredStream.SectoredToFlat(const Position: Int64): Int64; +var + TotalSectorSize: Int64; +begin + TotalSectorSize := Int64(BufferSize) + FSectorOverHead; + Result := (Position div TotalSectorSize) * BufferSize // remove previous overheads + + Position mod TotalSectorSize; // offset in sector +end; + +procedure TJclSectoredStream.SetSize(const NewSize: Int64); +begin + inherited SetSize(FlatToSectored(NewSize)); +end; + +{$IFNDEF WINSCP} + +//=== { TJclCRC16Stream } ==================================================== + +procedure TJclCRC16Stream.AfterBlockRead; +var + CRC: Word; +begin + CRC := Word(FBuffer[FBufferCurrentSize]) or (Word(FBuffer[FBufferCurrentSize + 1]) shl 8); + if CheckCrc16(FBuffer, FBufferCurrentSize, CRC) < 0 then + raise EJclStreamError.CreateRes(@RsStreamsCRCError); +end; + +procedure TJclCRC16Stream.BeforeBlockWrite; +var + CRC: Word; +begin + CRC := Crc16(FBuffer, FBufferCurrentSize); + FBuffer[FBufferCurrentSize] := CRC and $FF; + FBuffer[FBufferCurrentSize + 1] := CRC shr 8; +end; + +constructor TJclCRC16Stream.Create(AStorageStream: TStream; AOwnsStream: Boolean); +begin + inherited Create(AStorageStream, AOwnsStream, 2); +end; + +//=== { TJclCRC32Stream } ==================================================== + +procedure TJclCRC32Stream.AfterBlockRead; +var + CRC: Cardinal; +begin + CRC := Cardinal(FBuffer[FBufferCurrentSize]) or (Cardinal(FBuffer[FBufferCurrentSize + 1]) shl 8) + or (Cardinal(FBuffer[FBufferCurrentSize + 2]) shl 16) or (Cardinal(FBuffer[FBufferCurrentSize + 3]) shl 24); + if CheckCrc32(FBuffer, FBufferCurrentSize, CRC) < 0 then + raise EJclStreamError.CreateRes(@RsStreamsCRCError); +end; + +procedure TJclCRC32Stream.BeforeBlockWrite; +var + CRC: Cardinal; +begin + CRC := Crc32(FBuffer, FBufferCurrentSize); + FBuffer[FBufferCurrentSize] := CRC and $FF; + FBuffer[FBufferCurrentSize + 1] := (CRC shr 8) and $FF; + FBuffer[FBufferCurrentSize + 2] := (CRC shr 16) and $FF; + FBuffer[FBufferCurrentSize + 3] := (CRC shr 24) and $FF; +end; + +constructor TJclCRC32Stream.Create(AStorageStream: TStream; + AOwnsStream: Boolean); +begin + inherited Create(AStorageStream, AOwnsStream, 4); +end; + +{$ENDIF ~WINSCP} + +//=== { TJclSplitStream } ==================================================== + +constructor TJclSplitStream.Create(AForcePosition: Boolean); +begin + inherited Create; + FVolume := nil; + FVolumeIndex := -1; + FVolumeMaxSize := 0; + FPosition := 0; + FVolumePosition := 0; + FForcePosition := AForcePosition; +end; + +function TJclSplitStream.GetSize: Int64; +var + OldVolumeIndex: Integer; + OldVolumePosition, OldPosition: Int64; +begin + OldVolumeIndex := FVolumeIndex; + OldVolumePosition := FVolumePosition; + OldPosition := FPosition; + + Result := 0; + try + FVolumeIndex := -1; + repeat + if not InternalLoadVolume(FVolumeIndex + 1) then + Break; + Result := Result + FVolume.Size; + until FVolume.Size = 0; + finally + InternalLoadVolume(OldVolumeIndex); + FPosition := OldPosition; + if Assigned(FVolume) then + FVolumePosition := FVolume.Seek(OldVolumePosition, soBeginning); + end; +end; + +function TJclSplitStream.InternalLoadVolume(Index: Integer): Boolean; +var + OldVolumeIndex: Integer; + OldVolumeMaxSize: Int64; + OldVolumePosition: Int64; + OldVolume: TStream; +begin + if Index = -1 then + Index := 0; + if Index <> FVolumeIndex then + begin + // save current pointers + OldVolumeIndex := FVolumeIndex; + OldVolumeMaxSize := FVolumeMaxSize; + OldVolumePosition := FVolumePosition; + OldVolume := FVolume; + + FVolumeIndex := Index; + FVolumePosition := 0; + FVolume := GetVolume(Index); + FVolumeMaxSize := GetVolumeMaxSize(Index); + Result := Assigned(FVolume); + if Result then + FVolume.Seek(0, soBeginning) + else + begin + // restore old pointers if volume load failed + FVolumeIndex := OldVolumeIndex; + FVolumeMaxSize := OldVolumeMaxSize; + FVolumePosition := OldVolumePosition; + FVolume := OldVolume; + end; + end + else + Result := Assigned(FVolume); +end; + +function TJclSplitStream.Read(var Buffer; Count: Longint): Longint; +var + Data: PByte; + Total, LoopRead: Longint; +begin + Result := 0; + + if not InternalLoadVolume(FVolumeIndex) then + Exit; + + Data := PByte(@Buffer); + Total := Count; + + repeat + // force position + if ForcePosition then + FVolume.Seek(FVolumePosition, soBeginning); + + // try to read (Count) bytes from current stream + LoopRead := FVolume.Read(Data^, Count); + FVolumePosition := FVolumePosition + LoopRead; + FPosition := FPosition + LoopRead; + Inc(Result, LoopRead); + if Result = Total then + Break; + + // with next volume + Dec(Count, Result); + Inc(Data, Result); + if not InternalLoadVolume(FVolumeIndex + 1) then + Break; + until False; +end; + +function TJclSplitStream.Seek(const Offset: Int64; + Origin: TSeekOrigin): Int64; +var + ExpectedPosition, RemainingOffset: Int64; +begin + case TSeekOrigin(Origin) of + soBeginning: + ExpectedPosition := Offset; + soCurrent: + ExpectedPosition := FPosition + Offset; + soEnd: + ExpectedPosition := Size + Offset; + else + raise EJclStreamError.CreateRes(@RsStreamsSeekError); + end; + RemainingOffset := ExpectedPosition - FPosition; + Result := FPosition; + repeat + if not InternalLoadVolume(FVolumeIndex) then + Break; + + if RemainingOffset < 0 then + begin + // FPosition > ExpectedPosition, seek backward + if FVolumePosition >= -RemainingOffset then + begin + // seek in current volume + FVolumePosition := FVolume.Seek(FVolumePosition + RemainingOffset, soBeginning); + Result := Result + RemainingOffset; + FPosition := Result; + RemainingOffset := 0; + end + else + begin + // seek to previous volume + if FVolumeIndex = 0 then + Exit; + // seek to the beginning of current volume + RemainingOffset := RemainingOffset + FVolumePosition; + Result := Result - FVolumePosition; + FPosition := Result; + FVolumePosition := FVolume.Seek(0, soBeginning); + // load previous volume + if not InternalLoadVolume(FVolumeIndex - 1) then + Break; + Result := Result - FVolume.Size; + FPosition := Result; + RemainingOffset := RemainingOffset + FVolume.Size; + end; + end + else if RemainingOffset > 0 then + begin + // FPosition < ExpectedPosition, seek forward + if (FVolumeMaxSize = 0) or ((FVolumePosition + RemainingOffset) < FVolumeMaxSize) then + begin + // can seek in current volume + FVolumePosition := FVolume.Seek(FVolumePosition + RemainingOffset, soBeginning); + Result := Result + RemainingOffset; + FPosition := Result; + RemainingOffset := 0; + end + else + begin + // seek to next volume + RemainingOffset := RemainingOffset - FVolumeMaxSize + FVolumePosition; + Result := Result + FVolumeMaxSize - FVolumePosition; + FPosition := Result; + if not InternalLoadVolume(FVolumeIndex + 1) then + Break; + end; + end; + until RemainingOffset = 0; +end; + +procedure TJclSplitStream.SetSize(const NewSize: Int64); +var + OldVolumeIndex: Integer; + OldVolumePosition, OldPosition, RemainingSize, VolumeSize: Int64; +begin + OldVolumeIndex := FVolumeIndex; + OldVolumePosition := FVolumePosition; + OldPosition := FPosition; + + RemainingSize := NewSize; + try + FVolumeIndex := 0; + repeat + if not InternalLoadVolume(FVolumeIndex) then + Break; + if (FVolumeMaxSize > 0) and (RemainingSize > FVolumeMaxSize) then + VolumeSize := FVolumeMaxSize + else + VolumeSize := RemainingSize; + FVolume.Size := VolumeSize; + RemainingSize := RemainingSize - VolumeSize; + + Inc(FVolumeIndex); + until RemainingSize = 0; + finally + InternalLoadVolume(OldVolumeIndex); + FPosition := OldPosition; + if Assigned(FVolume) then + FVolumePosition := FVolume.Seek(OldVolumePosition, soBeginning); + end; +end; + +function TJclSplitStream.Write(const Buffer; Count: Longint): Longint; +var + Data: PByte; + Total, LoopWritten: Longint; +begin + Result := 0; + + if not InternalLoadVolume(FVolumeIndex) then + Exit; + + Data := PByte(@Buffer); + Total := Count; + + repeat + // force position + if ForcePosition then + FVolume.Seek(FVolumePosition, soBeginning); + + // do not write more than (VolumeMaxSize) bytes in current stream + if (FVolumeMaxSize > 0) and ((Count + FVolumePosition) > FVolumeMaxSize) then + LoopWritten := FVolumeMaxSize - FVolumePosition + else + LoopWritten := Count; + // try to write (Count) bytes from current stream + LoopWritten := FVolume.Write(Data^, LoopWritten); + FVolumePosition := FVolumePosition + LoopWritten; + FPosition := FPosition + LoopWritten; + Inc(Result, LoopWritten); + if Result = Total then + Break; + + // with next volume + Dec(Count, LoopWritten); + Inc(Data, LoopWritten); + if not InternalLoadVolume(FVolumeIndex + 1) then + Break; + until False; +end; + +//=== { TJclDynamicSplitStream } ============================================= + +function TJclDynamicSplitStream.GetVolume(Index: Integer): TStream; +begin + if Assigned(FOnVolume) then + Result := FOnVolume(Index) + else + Result := nil; +end; + +function TJclDynamicSplitStream.GetVolumeMaxSize(Index: Integer): Int64; +begin + if Assigned(FOnVolumeMaxSize) then + Result := FOnVolumeMaxSize(Index) + else + Result := 0; +end; + +//=== { TJclStaticSplitStream } =========================================== + +constructor TJclStaticSplitStream.Create(AForcePosition: Boolean); +begin + inherited Create(AForcePosition); + FVolumes := TObjectList.Create(True); +end; + +destructor TJclStaticSplitStream.Destroy; +var + Index: Integer; + AVolumeRec: TJclSplitVolume; +begin + if Assigned(FVolumes) then + begin + for Index := 0 to FVolumes.Count - 1 do + begin + AVolumeRec := TJclSplitVolume(FVolumes.Items[Index]); + if AVolumeRec.OwnStream then + AVolumeRec.Stream.Free; + end; + FVolumes.Free; + end; + inherited Destroy; +end; + +function TJclStaticSplitStream.AddVolume(AStream: TStream; AMaxSize: Int64; + AOwnStream: Boolean): Integer; +var + AVolumeRec: TJclSplitVolume; +begin + AVolumeRec := TJclSplitVolume.Create; + AVolumeRec.MaxSize := AMaxSize; + AVolumeRec.Stream := AStream; + AVolumeRec.OwnStream := AOwnStream; + Result := FVolumes.Add(AVolumeRec); +end; + +function TJclStaticSplitStream.GetVolume(Index: Integer): TStream; +begin + Result := TJclSplitVolume(FVolumes.Items[Index]).Stream; +end; + +function TJclStaticSplitStream.GetVolumeCount: Integer; +begin + Result := FVolumes.Count; +end; + +function TJclStaticSplitStream.GetVolumeMaxSize(Index: Integer): Int64; +begin + Result := TJclSplitVolume(FVolumes.Items[Index]).MaxSize; +end; + +{$IFNDEF WINSCP} + +//=== { TJclStringStream } ==================================================== + +constructor TJclStringStream.Create(AStream: TStream; AOwnsStream: Boolean); +begin + inherited Create; + FStream := AStream; + FOwnStream := AOwnsStream; + FBufferSize := StreamDefaultBufferSize; +end; + +destructor TJclStringStream.Destroy; +begin + Flush; + if FOwnStream then + FStream.Free; + inherited; +end; + +procedure TJclStringStream.Flush; +begin + if FStrBufferModifiedSize > 0 then + begin + FStream.Position := FStrBufferStart; + InternalSetNextBuffer(FStream, FStrBuffer, 0, FStrBufferModifiedSize); + FStrBufferNext := FStream.Seek(0, soCurrent); + FStrBufferModifiedSize := 0; + end; +end; + +function TJclStringStream.InternalGetNextBuffer(S: TStream; + var Buffer: TUCS4Array; Start, Count: SizeInt): Longint; +var + Ch: UCS4; +begin + // override to optimize + Result := 0; + while Count > 0 do + begin + if InternalGetNextChar(S, Ch) then + begin + Buffer[Start] := Ch; + Inc(Start); + Inc(Result); + end + else + Break; + Dec(Count); + end; +end; + +function TJclStringStream.InternalSetNextBuffer(S: TStream; + const Buffer: TUCS4Array; Start, Count: SizeInt): Longint; +begin + // override to optimize + Result := 0; + while Count > 0 do + begin + if InternalSetNextChar(S, Buffer[Start]) then + begin + Inc(Start); + Inc(Result); + end + else + Break; + Dec(Count); + end; +end; + +procedure TJclStringStream.InvalidateBuffers; +begin + FStrBufferStart := FStream.Seek(0, soCurrent); + FStrBufferNext := FStrBufferStart; + FStrBufferPosition := 0; + FStrBufferCurrentSize := 0; + FStrBufferModifiedSize := 0; + FStrPeekBufferStart := FStrBufferStart; + FStrPeekBufferNext := FStrBufferNext; + FStrPeekPosition := 0; + FStrPeekBufferCurrentSize := 0; +end; + +function TJclStringStream.LoadBuffer: Boolean; +begin + Flush; + // first test if the peek buffer contains the value + if (FStrBufferNext >= FStrPeekBufferStart) and (FStrBufferNext < FStrPeekBufferNext) then + begin + // the requested buffer is already loaded in the peek buffer + FStrBufferStart := FStrPeekBufferStart; + FStrBufferNext := FStrPeekBufferNext; + if Length(FStrBuffer) <> Length(FStrPeekBuffer) then + SetLength(FStrBuffer, Length(FStrPeekBuffer)); + FStrBufferPosition := FStrPeekBufferPosition; + FStrBufferCurrentSize := FStrPeekBufferCurrentSize; + Move(FStrPeekBuffer[0], FStrBuffer[0], FStrBufferCurrentSize * SizeOf(FStrBuffer[0])); + end + else + begin + // load a new buffer + if Length(FStrBuffer) <> FBufferSize then + SetLength(FStrBuffer, FBufferSize); + Inc(FStrBufferPosition, FStrBufferCurrentSize); + FStrBufferStart := FStrBufferNext; + FStream.Seek(FStrBufferStart, soBeginning); + FStrBufferCurrentSize := InternalGetNextBuffer(FStream, FStrBuffer, 0, FBufferSize); + FStrBufferNext := FStream.Seek(0, soCurrent); + // reset the peek buffer + FStrPeekBufferPosition := FStrBufferPosition + FStrBufferCurrentSize; + FStrPeekBufferCurrentSize := 0; + FStrPeekBufferNext := FStrBufferNext; + FStrPeekBufferStart := FStrBufferNext; + end; + Result := (FStrPosition >= FStrBufferPosition) and (FStrPosition < (FStrBufferPosition + FStrBufferCurrentSize)); +end; + +function TJclStringStream.LoadPeekBuffer: Boolean; +begin + if Length(FStrPeekBuffer) <> FBufferSize then + SetLength(FStrPeekBuffer, FBufferSize); + if FStrPeekBufferPosition > FStrPeekPosition then + begin + // the peek position is rolling back, load the buffer after the read buffer + FStrPeekBufferPosition := FStrBufferPosition; + FStrPeekBufferCurrentSize := FStrBufferCurrentSize; + FStrPeekBufferStart := FStrBufferStart; + FStrPeekBufferNext := FStrBufferNext; + end; + FStrPeekBufferStart := FStrPeekBufferNext; + Inc(FStrPeekBufferPosition, FStrPeekBufferCurrentSize); + FStream.Seek(FStrPeekBufferStart, soBeginning); + FStrPeekBufferCurrentSize := InternalGetNextBuffer(FStream, FStrPeekBuffer, 0, FBufferSize); + FStrPeekBufferNext := FStream.Seek(0, soCurrent); + Result := (FStrPeekPosition >= FStrPeekBufferPosition) and (FStrPeekPosition < (FStrPeekBufferPosition + FStrPeekBufferCurrentSize)); +end; + +function TJclStringStream.PeekAnsiChar(out Buffer: AnsiChar): Boolean; +var + Ch: UCS4; +begin + Result := PeekUCS4(Ch); + if Result then + Buffer := UCS4ToAnsiChar(Ch); +end; + +function TJclStringStream.PeekChar(out Buffer: Char): Boolean; +var + Ch: UCS4; +begin + Result := PeekUCS4(Ch); + if Result then + Buffer := UCS4ToChar(Ch); +end; + +function TJclStringStream.PeekUCS4(out Buffer: UCS4): Boolean; +begin + if (FStrPeekPosition >= FStrPeekBufferPosition) and (FStrPeekPosition < (FStrPeekBufferPosition + FStrPeekBufferCurrentSize)) then + begin + // read from the peek buffer + Result := True; + Buffer := FStrPeekBuffer[FStrPeekPosition - FStrPeekBufferPosition]; + Inc(FStrPeekPosition); + end + else + if (FStrPeekPosition >= FStrBufferPosition) and (FStrPeekPosition < (FStrBufferPosition + FStrBufferCurrentSize)) then + begin + // read from the read/write buffer + Result := True; + Buffer := FStrBuffer[FStrPeekPosition - FStrBufferPosition]; + Inc(FStrPeekPosition); + end + else + begin + // load a new peek buffer + Result := LoadPeekBuffer; + if Result then + begin + Buffer := FStrPeekBuffer[FStrPeekPosition - FStrPeekBufferPosition]; + Inc(FStrPeekPosition); + end; + end; +end; + +function TJclStringStream.PeekWideChar(out Buffer: WideChar): Boolean; +var + Ch: UCS4; +begin + Result := PeekUCS4(Ch); + if Result then + Buffer := UCS4ToWideChar(Ch); +end; + +function TJclStringStream.ReadString(var Buffer: string; Start, Count: Longint): Longint; +var + Index: Integer; + StrPos: SizeInt; + Ch: UCS4; +begin + Index := Start; + while Index < Start + Count - 1 do // avoid overflow on surrogate pairs for WideString + begin + if ReadUCS4(Ch) then + begin + StrPos := Index; + if StringSetNextChar(Buffer, StrPos, Ch) and (StrPos > 0) then + Index := StrPos + else + Break; // end of string (write) + end + else + Break; // end of stream (read) + end; + Result := Index - Start; +end; + +function TJclStringStream.ReadString(BufferSize: Longint): string; +var + Buffer: string; + ProcessedLength: Longint; +begin + Result := ''; + SetLength(Buffer, BufferSize); + repeat + ProcessedLength := ReadString(Buffer, 1, BufferSize); + if ProcessedLength > 0 then + Result := Result + Copy(Buffer, 1, ProcessedLength); + until ProcessedLength = 0; +end; + +function TJclStringStream.ReadAnsiChar(out Buffer: AnsiChar): Boolean; +var + Ch: UCS4; +begin + Result := ReadUCS4(Ch); + if Result then + Buffer := UCS4ToAnsiChar(Ch); +end; + +function TJclStringStream.ReadAnsiString(var Buffer: AnsiString; Start, Count: Longint): Longint; +var + Index: Integer; + StrPos: SizeInt; + Ch: UCS4; +begin + Index := Start; + while Index < Start + Count do + begin + if ReadUCS4(Ch) then + begin + StrPos := Index; + if AnsiSetNextChar(Buffer, StrPos, Ch) and (StrPos > 0) then + Index := StrPos + else + Break; // end of string (write) + end + else + Break; // end of stream (read) + end; + Result := Index - Start; +end; + +function TJclStringStream.ReadAnsiString(BufferSize: Longint): AnsiString; +var + Buffer: AnsiString; + ProcessedLength: Longint; +begin + Result := ''; + SetLength(Buffer, BufferSize); + repeat + ProcessedLength := ReadAnsiString(Buffer, 1, BufferSize); + if ProcessedLength > 0 then + Result := Result + Copy(Buffer, 1, ProcessedLength); + until ProcessedLength = 0; +end; + +function TJclStringStream.ReadChar(out Buffer: Char): Boolean; +var + Ch: UCS4; +begin + Result := ReadUCS4(Ch); + if Result then + Buffer := UCS4ToChar(Ch); +end; + +function TJclStringStream.ReadUCS4(out Buffer: UCS4): Boolean; +begin + if (FStrPosition >= FStrBufferPosition) and (FStrPosition < (FStrBufferPosition + FStrBufferCurrentSize)) then + begin + // load from buffer + Result := True; + Buffer := FStrBuffer[FStrPosition - FStrBufferPosition]; + Inc(FStrPosition); + end + else + begin + // load a new buffer + Result := LoadBuffer; + if Result then + begin + Buffer := FStrBuffer[FStrPosition - FStrBufferPosition]; + Inc(FStrPosition); + end; + end; + FStrPeekPosition := FStrPosition; +end; + +function TJclStringStream.ReadWideChar(out Buffer: WideChar): Boolean; +var + Ch: UCS4; +begin + Result := ReadUCS4(Ch); + if Result then + Buffer := UCS4ToWideChar(Ch); +end; + +function TJclStringStream.ReadWideString(var Buffer: WideString; Start, Count: Longint): Longint; +var + Index: Integer; + StrPos: SizeInt; + Ch: UCS4; +begin + Index := Start; + while Index < Start + Count - 1 do // avoid overflow on surrogate pairs + begin + if ReadUCS4(Ch) then + begin + StrPos := Index; + if UTF16SetNextChar(Buffer, StrPos, Ch) and (StrPos > 0) then + Index := StrPos + else + Break; // end of string (write) + end + else + Break; // end of stream (read) + end; + Result := Index - Start; +end; + +function TJclStringStream.ReadWideString(BufferSize: Longint): WideString; +var + Buffer: WideString; + ProcessedLength: Longint; +begin + Result := ''; + SetLength(Buffer, BufferSize); + repeat + ProcessedLength := ReadWideString(Buffer, 1, BufferSize); + if ProcessedLength > 0 then + Result := Result + Copy(Buffer, 1, ProcessedLength); + until ProcessedLength = 0; +end; + +function TJclStringStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; +begin + case Origin of + soBeginning: + if Offset = 0 then + begin + Flush; + FStrPosition := 0; + FStrBufferPosition := 0; + FStrBufferCurrentSize := 0; + FStrBufferStart := 0; + FStrBufferNext := 0; + FStrPeekBufferPosition := 0; + FStrPeekBufferCurrentSize := 0; + FStrPeekBufferStart := 0; + FStrPeekBufferNext := 0; + end + else + raise EJclStreamError.CreateRes(@RsStreamsSeekError); + soCurrent: + if Offset <> 0 then + raise EJclStreamError.CreateRes(@RsStreamsSeekError); + soEnd: + raise EJclStreamError.CreateRes(@RsStreamsSeekError); + end; + Result := FStrPosition; + FStrPeekPosition := FStrPosition; +end; + +function TJclStringStream.SkipBOM: Longint; +var + Pos: Int64; + I: Integer; + BOM: array of Byte; +begin + if Length(FBOM) > 0 then + begin + Pos := FStream.Seek(0, soCurrent); + SetLength(BOM, Length(FBOM)); + Result := FStream.Read(BOM[0], Length(BOM) * SizeOf(BOM[0])); + if Result = Length(FBOM) * SizeOf(FBOM[0]) then + for I := Low(FBOM) to High(FBOM) do + if BOM[I - Low(FBOM)] <> FBOM[I] then + Result := 0; + if Result <> Length(FBOM) * SizeOf(FBOM[0]) then + FStream.Seek(Pos, soBeginning); + end + else + Result := 0; + InvalidateBuffers; +end; + +function TJclStringStream.WriteBOM: Longint; +begin + if Length(FBOM) > 0 then + Result := FStream.Write(FBOM[0], Length(FBOM) * SizeOf(FBOM[0])) + else + Result := 0; + InvalidateBuffers; +end; + +function TJclStringStream.WriteChar(Value: Char): Boolean; +begin + Result := WriteUCS4(CharToUCS4(Value)); +end; + +function TJclStringStream.WriteString(const Buffer: string; Start, Count: Longint): Longint; +var + Index: Integer; + StrPos: SizeInt; + Ch: UCS4; +begin + Index := Start; + while Index < Start + Count do + begin + StrPos := Index; + Ch := StringGetNextChar(Buffer, StrPos); + if (StrPos > 0) and WriteUCS4(Ch) then + Index := StrPos + else + Break; // end of string (read) or end of stream (write) + end; + Result := Index - Start; +end; + +function TJclStringStream.WriteAnsiChar(Value: AnsiChar): Boolean; +begin + Result := WriteUCS4(AnsiCharToUCS4(Value)); +end; + +function TJclStringStream.WriteAnsiString(const Buffer: AnsiString; Start, Count: Longint): Longint; +var + Index: Integer; + StrPos: SizeInt; + Ch: UCS4; +begin + Index := Start; + while Index < Start + Count do + begin + StrPos := Index; + Ch := AnsiGetNextChar(Buffer, StrPos); + if (StrPos > 0) and WriteUCS4(Ch) then + Index := StrPos + else + Break; // end of string (read) or end of stream (write) + end; + Result := Index - Start; +end; + +function TJclStringStream.WriteUCS4(Value: UCS4): Boolean; +var + BufferPos: Int64; +begin + if FStrPosition >= (FStrBufferPosition + FBufferSize) then + // load the next buffer first + LoadBuffer; + // write to current buffer + BufferPos := FStrPosition - FStrBufferPosition; + Result := True; + if Length(FStrBuffer) <> FBufferSize then + SetLength(FStrBuffer, FBufferSize); + FStrBuffer[BufferPos] := Value; + Inc(FStrPosition); + Inc(BufferPos); + if FStrBufferModifiedSize < BufferPos then + FStrBufferModifiedSize := BufferPos; + if FStrBufferCurrentSize < BufferPos then + FStrBufferCurrentSize := BufferPos; + FStrPeekPosition := FStrPosition; +end; + +function TJclStringStream.WriteWideChar(Value: WideChar): Boolean; +begin + Result := WriteUCS4(WideCharToUCS4(Value)); +end; + +function TJclStringStream.WriteWideString(const Buffer: WideString; Start, Count: Longint): Longint; +var + Index: Integer; + StrPos: SizeInt; + Ch: UCS4; +begin + Index := Start; + while Index < Start + Count do + begin + StrPos := Index; + Ch := UTF16GetNextChar(Buffer, StrPos); + if (StrPos > 0) and WriteUCS4(Ch) then + Index := StrPos + else + Break; // end of string (read) or end of stream (write) + end; + Result := Index - Start; +end; + +//=== { TJclAnsiStream } ====================================================== + +constructor TJclAnsiStream.Create(AStream: TStream; AOwnsStream: Boolean); +begin + inherited Create(AStream, AOwnsStream); + SetLength(FBOM, 0); + FCodePage := CP_ACP; +end; + +function TJclAnsiStream.InternalGetNextBuffer(S: TStream; + var Buffer: TUCS4Array; Start, Count: SizeInt): Longint; +begin + if FCodePage = CP_ACP then + Result := AnsiGetNextBufferFromStream(S, Buffer, Start, Count) + else + Result := AnsiGetNextBufferFromStream(S, FCodePage, Buffer, Start, Count); +end; + +function TJclAnsiStream.InternalGetNextChar(S: TStream; out Ch: UCS4): Boolean; +begin + if FCodePage = CP_ACP then + Result := AnsiGetNextCharFromStream(S, Ch) + else + Result := AnsiGetNextCharFromStream(S, FCodePage, Ch); +end; + +function TJclAnsiStream.InternalSetNextBuffer(S: TStream; + const Buffer: TUCS4Array; Start, Count: SizeInt): Longint; +begin + if FCodePage = CP_ACP then + Result := AnsiSetNextBufferToStream(S, Buffer, Start, Count) + else + Result := AnsiSetNextBufferToStream(S, FCodePage, Buffer, Start, Count); +end; + +function TJclAnsiStream.InternalSetNextChar(S: TStream; Ch: UCS4): Boolean; +begin + if FCodePage = CP_ACP then + Result := AnsiSetNextCharToStream(S, Ch) + else + Result := AnsiSetNextCharToStream(S, FCodePage, Ch); +end; + +//=== { TJclUTF8Stream } ====================================================== + +constructor TJclUTF8Stream.Create(AStream: TStream; AOwnsStream: Boolean); +var + I: Integer; +begin + inherited Create(AStream, AOwnsStream); + SetLength(FBOM, Length(BOM_UTF8)); + for I := Low(BOM_UTF8) to High(BOM_UTF8) do + FBOM[I - Low(BOM_UTF8)] := BOM_UTF8[I]; +end; + +function TJclUTF8Stream.InternalGetNextBuffer(S: TStream; + var Buffer: TUCS4Array; Start, Count: SizeInt): Longint; +begin + Result := UTF8GetNextBufferFromStream(S, Buffer, Start, Count); +end; + +function TJclUTF8Stream.InternalGetNextChar(S: TStream; out Ch: UCS4): Boolean; +begin + Result := UTF8GetNextCharFromStream(S, Ch); +end; + +function TJclUTF8Stream.InternalSetNextBuffer(S: TStream; + const Buffer: TUCS4Array; Start, Count: SizeInt): Longint; +begin + Result := UTF8SetNextBufferToStream(S, Buffer, Start, Count); +end; + +function TJclUTF8Stream.InternalSetNextChar(S: TStream; Ch: UCS4): Boolean; +begin + Result := UTF8SetNextCharToStream(S, Ch); +end; + +//=== { TJclUTF16Stream } ===================================================== + +constructor TJclUTF16Stream.Create(AStream: TStream; AOwnsStream: Boolean); +var + I: Integer; +begin + inherited Create(AStream, AOwnsStream); + SetLength(FBOM, Length(BOM_UTF16_LSB)); + for I := Low(BOM_UTF16_LSB) to High(BOM_UTF16_LSB) do + FBOM[I - Low(BOM_UTF16_LSB)] := BOM_UTF16_LSB[I]; +end; + +function TJclUTF16Stream.InternalGetNextBuffer(S: TStream; + var Buffer: TUCS4Array; Start, Count: SizeInt): Longint; +begin + Result := UTF16GetNextBufferFromStream(S, Buffer, Start, Count); +end; + +function TJclUTF16Stream.InternalGetNextChar(S: TStream; out Ch: UCS4): Boolean; +begin + Result := UTF16GetNextCharFromStream(S, Ch); +end; + +function TJclUTF16Stream.InternalSetNextBuffer(S: TStream; + const Buffer: TUCS4Array; Start, Count: SizeInt): Longint; +begin + Result := UTF16SetNextBufferToStream(S, Buffer, Start, Count); +end; + +function TJclUTF16Stream.InternalSetNextChar(S: TStream; Ch: UCS4): Boolean; +begin + Result := UTF16SetNextCharToStream(S, Ch); +end; + +//=== { TJclAutoStream } ====================================================== + +constructor TJclAutoStream.Create(AStream: TStream; AOwnsStream: Boolean); +var + I, MaxLength, ReadLength: Integer; + BOM: array of Byte; +begin + inherited Create(AStream, AOwnsStream); + MaxLength := Length(BOM_UTF8); + if MaxLength < Length(BOM_UTF16_LSB) then + MaxLength := Length(BOM_UTF16_LSB); + + SetLength(BOM, MaxLength); + ReadLength := FStream.Read(BOM[0], Length(BOM) * SizeOf(BOM[0])) div SizeOf(BOM[0]); + + FEncoding := seAuto; + + // try UTF8 BOM + if (FEncoding = seAuto) and (ReadLength >= Length(BOM_UTF8) * SizeOf(BOM_UTF8[0])) then + begin + FCodePage := CP_UTF8; + FEncoding := seUTF8; + for I := Low(BOM_UTF8) to High(BOM_UTF8) do + if BOM[I - Low(BOM_UTF8)] <> BOM_UTF8[I] then + begin + FEncoding := seAuto; + Break; + end; + end; + + // try UTF16 BOM + if (FEncoding = seAuto) and (ReadLength >= Length(BOM_UTF16_LSB) * SizeOf(BOM_UTF16_LSB[0])) then + begin + FCodePage := CP_UTF16LE; + FEncoding := seUTF16; + for I := Low(BOM_UTF16_LSB) to High(BOM_UTF16_LSB) do + if BOM[I - Low(BOM_UTF8)] <> BOM_UTF16_LSB[I] then + begin + FEncoding := seAuto; + Break; + end; + end; + + case FEncoding of + seUTF8: + begin + FCodePage := CP_UTF8; + SetLength(FBOM, Length(BOM_UTF8)); + for I := Low(BOM_UTF8) to High(BOM_UTF8) do + FBOM[I - Low(BOM_UTF8)] := BOM_UTF8[I]; + end; + seUTF16: + begin + FCodePage := CP_UTF16LE; + SetLength(FBOM, Length(BOM_UTF16_LSB)); + for I := Low(BOM_UTF16_LSB) to High(BOM_UTF16_LSB) do + FBOM[I - Low(BOM_UTF16_LSB)] := BOM_UTF16_LSB[I]; + end; + seAuto, + seAnsi: + begin + // defaults to Ansi + FCodePage := CP_ACP; + FEncoding := seAnsi; + SetLength(FBOM, 0); + end; + end; + FStream.Seek(Length(FBOM) - ReadLength, soCurrent); + InvalidateBuffers; +end; + +function TJclAutoStream.InternalGetNextBuffer(S: TStream; + var Buffer: TUCS4Array; Start, Count: SizeInt): Longint; +begin + case FCodePage of + CP_UTF8: + Result := UTF8GetNextBufferFromStream(S, Buffer, Start, Count); + CP_UTF16LE: + Result := UTF16GetNextBufferFromStream(S, Buffer, Start, Count); + CP_ACP: + Result := AnsiGetNextBufferFromStream(S, Buffer, Start, Count); + else + Result := AnsiGetNextBufferFromStream(S, CodePage, Buffer, Start, Count); + end; +end; + +function TJclAutoStream.InternalGetNextChar(S: TStream; out Ch: UCS4): Boolean; +begin + case FCodePage of + CP_UTF8: + Result := UTF8GetNextCharFromStream(S, Ch); + CP_UTF16LE: + Result := UTF16GetNextCharFromStream(S, Ch); + CP_ACP: + Result := AnsiGetNextCharFromStream(S, Ch); + else + Result := AnsiGetNextCharFromStream(S, CodePage, Ch); + end; +end; + +function TJclAutoStream.InternalSetNextBuffer(S: TStream; + const Buffer: TUCS4Array; Start, Count: SizeInt): Longint; +begin + case FCodePage of + CP_UTF8: + Result := UTF8SetNextBufferToStream(S, Buffer, Start, Count); + CP_UTF16LE: + Result := UTF16SetNextBufferToStream(S, Buffer, Start, Count); + CP_ACP: + Result := AnsiSetNextBufferToStream(S, Buffer, Start, Count); + else + Result := AnsiSetNextBufferToStream(S, CodePage, Buffer, Start, Count); + end; +end; + +function TJclAutoStream.InternalSetNextChar(S: TStream; Ch: UCS4): Boolean; +begin + case FCodePage of + CP_UTF8: + Result := UTF8SetNextCharToStream(S, Ch); + CP_UTF16LE: + Result := UTF16SetNextCharToStream(S, Ch); + CP_ACP: + Result := AnsiSetNextCharToStream(S, Ch); + else + Result := AnsiSetNextCharToStream(S, CodePage, Ch); + end; +end; + +procedure TJclAutoStream.SetCodePage(Value: Word); +begin + if Value = CP_UTF8 then + FEncoding := seUTF8 + else + if Value = CP_UTF16LE then + FEncoding := seUTF16 + else + if Value = CP_ACP then + FEncoding := seAnsi + else + FEncoding := seAuto; + FCodePage := Value; +end; + +function TJclAutoStream.SkipBOM: LongInt; +begin + // already skipped to determine encoding + Result := 0; + InvalidateBuffers; +end; + +{$ENDIF ~WINSCP} + +{$IFDEF UNITVERSIONING} +initialization + RegisterUnitVersion(HInstance, UnitVersioning); + +finalization + UnregisterUnitVersion(HInstance); +{$ENDIF UNITVERSIONING} + +end. diff --git a/source/packages/jcl/JclStrings.pas b/source/packages/jcl/JclStrings.pas new file mode 100644 index 00000000..b1515b77 --- /dev/null +++ b/source/packages/jcl/JclStrings.pas @@ -0,0 +1,5444 @@ +{**************************************************************************************************} +{ } +{ Project JEDI Code Library (JCL) } +{ } +{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); } +{ you may not use this file except in compliance with the License. You may obtain a copy of the } +{ License at http://www.mozilla.org/MPL/ } +{ } +{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF } +{ ANY KIND, either express or implied. See the License for the specific language governing rights } +{ and limitations under the License. } +{ } +{ The Original Code is JclStrings.pas. } +{ } +{ The Initial Developer of the Original Code is Marcel van Brakel. } +{ Portions created by Marcel van Brakel are Copyright (C) Marcel van Brakel. All rights reserved. } +{ } +{ Contributor(s): } +{ Alexander Radchenko } +{ Andreas Hausladen (ahuser) } +{ Anthony Steele } +{ Azret Botash } +{ Barry Kelly } +{ Huanlin Tsai } +{ Jack N.A. Bakker } +{ Jean-Fabien Connault (cycocrew) } +{ John C Molyneux } +{ Kiriakos Vlahos } +{ Leonard Wennekers } +{ Marcel Bestebroer } +{ Martin Kimmings } +{ Martin Kubecka } +{ Massimo Maria Ghisalberti } +{ Matthias Thoma (mthoma) } +{ Michael Winter } +{ Nick Hodges } +{ Olivier Sannier (obones) } +{ Pelle F. S. Liljendal } +{ Petr Vones (pvones) } +{ Rik Barker (rikbarker) } +{ Robert Lee } +{ Robert Marquardt (marquardt) } +{ Robert Rossmair (rrossmair) } +{ Andreas Schmidt } +{ Sean Farrow (sfarrow) } +{ } +{**************************************************************************************************} +{ } +{ Various character and string routines (searching, testing and transforming) } +{ } +{**************************************************************************************************} +{ } +{ Last modified: $Date:: $ } +{ Revision: $Rev:: $ } +{ Author: $Author:: $ } +{ } +{**************************************************************************************************} + +unit JclStrings; + +{$I jcl.inc} + +interface + +uses + {$IFDEF UNITVERSIONING} + JclUnitVersioning, + {$ENDIF UNITVERSIONING} + {$IFDEF HAS_UNITSCOPE} + {$IFDEF MSWINDOWS} + Winapi.Windows, + {$ENDIF MSWINDOWS} + {$IFDEF UNICODE_RTL_DATABASE} + System.Character, + {$ENDIF UNICODE_RTL_DATABASE} + System.Classes, System.SysUtils, + {$ELSE ~HAS_UNITSCOPE} + {$IFDEF MSWINDOWS} + Windows, + {$ENDIF MSWINDOWS} + {$IFDEF UNICODE_RTL_DATABASE} + Character, + {$ENDIF UNICODE_RTL_DATABASE} + Classes, SysUtils, + {$ENDIF ~HAS_UNITSCOPE} +{$IFNDEF WINSCP} + JclAnsiStrings, + JclWideStrings, +{$ENDIF ~WINSCP} + JclBase; + +// Exceptions +type + EJclStringError = class(EJclError); + +// Character constants and sets + +const + // Misc. often used character definitions + NativeNull = Char(#0); + NativeSoh = Char(#1); + NativeStx = Char(#2); + NativeEtx = Char(#3); + NativeEot = Char(#4); + NativeEnq = Char(#5); + NativeAck = Char(#6); + NativeBell = Char(#7); + NativeBackspace = Char(#8); + NativeTab = Char(#9); + NativeLineFeed = JclBase.NativeLineFeed; + NativeVerticalTab = Char(#11); + NativeFormFeed = Char(#12); + NativeCarriageReturn = JclBase.NativeCarriageReturn; + NativeCrLf = JclBase.NativeCrLf; + NativeSo = Char(#14); + NativeSi = Char(#15); + NativeDle = Char(#16); + NativeDc1 = Char(#17); + NativeDc2 = Char(#18); + NativeDc3 = Char(#19); + NativeDc4 = Char(#20); + NativeNak = Char(#21); + NativeSyn = Char(#22); + NativeEtb = Char(#23); + NativeCan = Char(#24); + NativeEm = Char(#25); + NativeEndOfFile = Char(#26); + NativeEscape = Char(#27); + NativeFs = Char(#28); + NativeGs = Char(#29); + NativeRs = Char(#30); + NativeUs = Char(#31); + NativeSpace = Char(' '); + NativeComma = Char(','); + NativeBackslash = Char('\'); + NativeForwardSlash = Char('/'); + + NativeDoubleQuote = Char('"'); + NativeSingleQuote = Char(''''); + + NativeLineBreak = JclBase.NativeLineBreak; + +const + // CharType return values + C1_UPPER = $0001; // Uppercase + C1_LOWER = $0002; // Lowercase + C1_DIGIT = $0004; // Decimal digits + C1_SPACE = $0008; // Space characters + C1_PUNCT = $0010; // Punctuation + C1_CNTRL = $0020; // Control characters + C1_BLANK = $0040; // Blank characters + C1_XDIGIT = $0080; // Hexadecimal digits + C1_ALPHA = $0100; // Any linguistic character: alphabetic, syllabary, or ideographic + + {$IFDEF MSWINDOWS} + {$IFDEF SUPPORTS_EXTSYM} + {$EXTERNALSYM C1_UPPER} + {$EXTERNALSYM C1_LOWER} + {$EXTERNALSYM C1_DIGIT} + {$EXTERNALSYM C1_SPACE} + {$EXTERNALSYM C1_PUNCT} + {$EXTERNALSYM C1_CNTRL} + {$EXTERNALSYM C1_BLANK} + {$EXTERNALSYM C1_XDIGIT} + {$EXTERNALSYM C1_ALPHA} + {$ENDIF SUPPORTS_EXTSYM} + {$ENDIF MSWINDOWS} + +type + TCharValidator = function(const C: Char): Boolean; + +function ArrayContainsChar(const Chars: array of Char; const C: Char): Boolean; overload; +function ArrayContainsChar(const Chars: array of Char; const C: Char; out Index: SizeInt): Boolean; overload; + +// String Test Routines +function StrIsAlpha(const S: string): Boolean; +function StrIsAlphaNum(const S: string): Boolean; +function StrIsAlphaNumUnderscore(const S: string): Boolean; +function StrContainsChars(const S: string; const Chars: TCharValidator; CheckAll: Boolean): Boolean; overload; +function StrContainsChars(const S: string; const Chars: array of Char; CheckAll: Boolean): Boolean; overload; +{$IFNDEF WINSCP} +function StrConsistsOfNumberChars(const S: string): Boolean; +{$ENDIF ~WINSCP} +function StrIsDigit(const S: string): Boolean; +function StrIsSubset(const S: string; const ValidChars: TCharValidator): Boolean; overload; +function StrIsSubset(const S: string; const ValidChars: array of Char): Boolean; overload; +function StrSame(const S1, S2: string; CaseSensitive: Boolean = False): Boolean; + +// String Transformation Routines +function StrCenter(const S: string; L: SizeInt; C: Char = ' '): string; +function StrCharPosLower(const S: string; CharPos: SizeInt): string; +function StrCharPosUpper(const S: string; CharPos: SizeInt): string; +function StrDoubleQuote(const S: string): string; +function StrEnsureNoPrefix(const Prefix, Text: string): string; +function StrEnsureNoSuffix(const Suffix, Text: string): string; +function StrEnsurePrefix(const Prefix, Text: string): string; +function StrEnsureSuffix(const Suffix, Text: string): string; +function StrEscapedToString(const S: string): string; +function StrLower(const S: string): string; +procedure StrLowerInPlace(var S: string); +procedure StrLowerBuff(S: PChar); +procedure StrMove(var Dest: string; const Source: string; const ToIndex, + FromIndex, Count: SizeInt); +function StrPadLeft(const S: string; Len: SizeInt; C: Char = NativeSpace): string; +function StrPadRight(const S: string; Len: SizeInt; C: Char = NativeSpace): string; +function StrProper(const S: string): string; +procedure StrProperBuff(S: PChar); +function StrQuote(const S: string; C: Char): string; +function StrRemoveChars(const S: string; const Chars: TCharValidator): string; overload; +function StrRemoveChars(const S: string; const Chars: array of Char): string; overload; +function StrRemoveLeadingChars(const S: string; const Chars: TCharValidator): string; overload; +function StrRemoveLeadingChars(const S: string; const Chars: array of Char): string; overload; +function StrRemoveEndChars(const S: string; const Chars: TCharValidator): string; overload; +function StrRemoveEndChars(const S: string; const Chars: array of Char): string; overload; +function StrKeepChars(const S: string; const Chars: TCharValidator): string; overload; +function StrKeepChars(const S: string; const Chars: array of Char): string; overload; +procedure StrReplace(var S: string; const Search, Replace: string; Flags: TReplaceFlags = []); +function StrReplaceChar(const S: string; const Source, Replace: Char): string; +function StrReplaceChars(const S: string; const Chars: TCharValidator; Replace: Char): string; overload; +function StrReplaceChars(const S: string; const Chars: array of Char; Replace: Char): string; overload; +function StrReplaceButChars(const S: string; const Chars: TCharValidator; Replace: Char): string; overload; +function StrReplaceButChars(const S: string; const Chars: array of Char; Replace: Char): string; overload; +function StrRepeat(const S: string; Count: SizeInt): string; +function StrRepeatLength(const S: string; L: SizeInt): string; +function StrReverse(const S: string): string; +procedure StrReverseInPlace(var S: string); +function StrSingleQuote(const S: string): string; +procedure StrSkipChars(var S: PChar; const Chars: TCharValidator); overload; +procedure StrSkipChars(var S: PChar; const Chars: array of Char); overload; +procedure StrSkipChars(const S: string; var Index: SizeInt; const Chars: TCharValidator); overload; +procedure StrSkipChars(const S: string; var Index: SizeInt; const Chars: array of Char); overload; +function StrSmartCase(const S: string; const Delimiters: TCharValidator): string; overload; +function StrSmartCase(const S: string; const Delimiters: array of Char): string; overload; +function StrStringToEscaped(const S: string): string; +{$IFNDEF WINSCP} +function StrStripNonNumberChars(const S: string): string; +{$ENDIF ~WINSCP} +function StrToHex(const Source: string): string; +function StrTrimCharLeft(const S: string; C: Char): string; +function StrTrimCharsLeft(const S: string; const Chars: TCharValidator): string; overload; +function StrTrimCharsLeft(const S: string; const Chars: array of Char): string; overload; +function StrTrimCharRight(const S: string; C: Char): string; +function StrTrimCharsRight(const S: string; const Chars: TCharValidator): string; overload; +function StrTrimCharsRight(const S: string; const Chars: array of Char): string; overload; +function StrTrimQuotes(const S: string): string; +function StrUpper(const S: string): string; +procedure StrUpperInPlace(var S: string); +procedure StrUpperBuff(S: PChar); + +// String Management +procedure StrAddRef(var S: string); +procedure StrDecRef(var S: string); +function StrLength(const S: string): SizeInt; +function StrRefCount(const S: string): SizeInt; + +// String Search and Replace Routines +function StrCharCount(const S: string; C: Char): SizeInt; overload; +function StrCharsCount(const S: string; const Chars: TCharValidator): SizeInt; overload; +function StrCharsCount(const S: string; const Chars: array of Char): SizeInt; overload; +function StrStrCount(const S, SubS: string): SizeInt; +function StrCompare(const S1, S2: string; CaseSensitive: Boolean = False): SizeInt; +function StrCompareRange(const S1, S2: string; Index, Count: SizeInt; CaseSensitive: Boolean = True): SizeInt; +function StrCompareRangeEx(const S1, S2: string; Index, Count: SizeInt; CaseSensitive: Boolean): SizeInt; +procedure StrFillChar(var S; Count: SizeInt; C: Char); +function StrRepeatChar(C: Char; Count: SizeInt): string; +function StrFind(const Substr, S: string; const Index: SizeInt = 1): SizeInt; +function StrHasPrefix(const S: string; const Prefixes: array of string): Boolean; +function StrHasSuffix(const S: string; const Suffixes: array of string): Boolean; +function StrIndex(const S: string; const List: array of string; CaseSensitive: Boolean = False): SizeInt; +function StrIHasPrefix(const S: string; const Prefixes: array of string): Boolean; +function StrIHasSuffix(const S: string; const Suffixes: array of string): Boolean; +function StrILastPos(const SubStr, S: string): SizeInt; +function StrIPos(const SubStr, S: string): SizeInt; +function StrIPrefixIndex(const S: string; const Prefixes: array of string): SizeInt; +function StrIsOneOf(const S: string; const List: array of string): Boolean; +function StrISuffixIndex(const S: string; const Suffixes: array of string): SizeInt; +function StrLastPos(const SubStr, S: string): SizeInt; +function StrMatch(const Substr, S: string; Index: SizeInt = 1): SizeInt; +function StrMatches(const Substr, S: string; const Index: SizeInt = 1): Boolean; +function StrNIPos(const S, SubStr: string; N: SizeInt): SizeInt; +function StrNPos(const S, SubStr: string; N: SizeInt): SizeInt; +function StrPrefixIndex(const S: string; const Prefixes: array of string): SizeInt; +function StrSearch(const Substr, S: string; const Index: SizeInt = 1): SizeInt; +function StrSuffixIndex(const S: string; const Suffixes: array of string): SizeInt; + +// String Extraction +/// Returns the string after SubStr +function StrAfter(const SubStr, S: string): string; +/// Returns the String before SubStr +function StrBefore(const SubStr, S: string): string; +/// Splits a string at SubStr, returns true when SubStr is found, Left contains the +/// string before the SubStr and Right the string behind SubStr +function StrSplit(const SubStr, S: string;var Left, Right : string): boolean; +/// Returns the string between Start and Stop +function StrBetween(const S: string; const Start, Stop: Char): string; +/// Returns all but rightmost N characters of the string +function StrChopRight(const S: string; N: SizeInt): string;{$IFDEF SUPPORTS_INLINE} {$IFDEF COMPILER16_UP} inline; {$ENDIF} {$ENDIF} +/// Returns the left Count characters of the string +function StrLeft(const S: string; Count: SizeInt): string; {$IFDEF SUPPORTS_INLINE} {$IFDEF COMPILER16_UP} inline; {$ENDIF} {$ENDIF} +/// Returns the string starting from position Start for the Count Characters +function StrMid(const S: string; Start, Count: SizeInt): string; {$IFDEF SUPPORTS_INLINE} {$IFDEF COMPILER16_UP} inline; {$ENDIF} {$ENDIF} +/// Returns the string starting from position N to the end +function StrRestOf(const S: string; N: SizeInt): string;{$IFDEF SUPPORTS_INLINE} {$IFDEF COMPILER16_UP} inline; {$ENDIF} {$ENDIF} +/// Returns the right Count characters of the string +function StrRight(const S: string; Count: SizeInt): string;{$IFDEF SUPPORTS_INLINE} {$IFDEF COMPILER16_UP} inline; {$ENDIF} {$ENDIF} + +// Character Test Routines +function CharEqualNoCase(const C1, C2: Char): Boolean; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function CharIsAlpha(const C: Char): Boolean; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function CharIsAlphaNum(const C: Char): Boolean; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function CharIsBlank(const C: Char): Boolean; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function CharIsControl(const C: Char): Boolean; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function CharIsDelete(const C: Char): Boolean; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function CharIsDigit(const C: Char): Boolean; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function CharIsFracDigit(const C: Char): Boolean; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function CharIsHexDigit(const C: Char): Boolean; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function CharIsLower(const C: Char): Boolean; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +{$IFNDEF WINSCP} +function CharIsNumberChar(const C: Char): Boolean; {$IFDEF SUPPORTS_INLINE} {$IFDEF COMPILER16_UP} inline; {$ENDIF} {$ENDIF} +function CharIsNumber(const C: Char): Boolean; {$IFDEF SUPPORTS_INLINE} {$IFDEF COMPILER16_UP} inline; {$ENDIF} {$ENDIF} +{$ENDIF ~WINSCP} +function CharIsPrintable(const C: Char): Boolean; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function CharIsPunctuation(const C: Char): Boolean; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function CharIsReturn(const C: Char): Boolean; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function CharIsSpace(const C: Char): Boolean; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function CharIsUpper(const C: Char): Boolean; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function CharIsValidIdentifierLetter(const C: Char): Boolean; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function CharIsWhiteSpace(const C: Char): Boolean; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function CharIsWildcard(const C: Char): Boolean; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function CharType(const C: Char): Word; + +// Character Transformation Routines +function CharHex(const C: Char): Byte; +function CharLower(const C: Char): Char; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function CharUpper(const C: Char): Char; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function CharToggleCase(const C: Char): Char; + +// Character Search and Replace +function CharPos(const S: string; const C: Char; const Index: SizeInt = 1): SizeInt; +function CharLastPos(const S: string; const C: Char; const Index: SizeInt = 1): SizeInt; +function CharIPos(const S: string; C: Char; const Index: SizeInt = 1): SizeInt; +function CharReplace(var S: string; const Search, Replace: Char): SizeInt; + +// PCharVector +type + PCharVector = ^PChar; + +function StringsToPCharVector(var Dest: PCharVector; const Source: TStrings): PCharVector; +function PCharVectorCount(Source: PCharVector): SizeInt; +procedure PCharVectorToStrings(const Dest: TStrings; Source: PCharVector); +procedure FreePCharVector(var Dest: PCharVector); + +{$IFNDEF WINSCP} +// MultiSz Routines +type + PMultiSz = PChar; + PAnsiMultiSz = JclAnsiStrings.PAnsiMultiSz; + PWideMultiSz = JclWideStrings.PWideMultiSz; + + TAnsiStrings = JclAnsiStrings.TJclAnsiStrings; + TWideStrings = JclWideStrings.TJclWideStrings; + TAnsiStringList = JclAnsiStrings.TJclAnsiStringList; + TWideStringList = JclWideStrings.TJclWideStringList; + +function StringsToMultiSz(var Dest: PMultiSz; const Source: TStrings): PMultiSz; +procedure MultiSzToStrings(const Dest: TStrings; const Source: PMultiSz); +function MultiSzLength(const Source: PMultiSz): SizeInt; +procedure AllocateMultiSz(var Dest: PMultiSz; Len: SizeInt); +procedure FreeMultiSz(var Dest: PMultiSz); +function MultiSzDup(const Source: PMultiSz): PMultiSz; + +function AnsiStringsToAnsiMultiSz(var Dest: PAnsiMultiSz; const Source: TAnsiStrings): PAnsiMultiSz; + {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +procedure AnsiMultiSzToAnsiStrings(const Dest: TAnsiStrings; const Source: PAnsiMultiSz); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function AnsiMultiSzLength(const Source: PAnsiMultiSz): SizeInt; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +procedure AllocateAnsiMultiSz(var Dest: PAnsiMultiSz; Len: SizeInt); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +procedure FreeAnsiMultiSz(var Dest: PAnsiMultiSz); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function AnsiMultiSzDup(const Source: PAnsiMultiSz): PAnsiMultiSz; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + +function WideStringsToWideMultiSz(var Dest: PWideMultiSz; const Source: TWideStrings): PWideMultiSz; + {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +procedure WideMultiSzToWideStrings(const Dest: TWideStrings; const Source: PWideMultiSz); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function WideMultiSzLength(const Source: PWideMultiSz): SizeInt; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +procedure AllocateWideMultiSz(var Dest: PWideMultiSz; Len: SizeInt); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +procedure FreeWideMultiSz(var Dest: PWideMultiSz); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function WideMultiSzDup(const Source: PWideMultiSz): PWideMultiSz; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +{$ENDIF ~WINSCP} + +// TStrings Manipulation +procedure StrIToStrings(S, Sep: string; const List: TStrings; const AllowEmptyString: Boolean = True); +procedure StrToStrings(S, Sep: string; const List: TStrings; const AllowEmptyString: Boolean = True); +function StringsToStr(const List: TStrings; const Sep: string; const AllowEmptyString: Boolean = True): string; overload; +function StringsToStr(const List: TStrings; const Sep: string; const NumberOfItems: SizeInt; const AllowEmptyString: + Boolean = True): string; overload; +procedure TrimStrings(const List: TStrings; DeleteIfEmpty: Boolean = True); +procedure TrimStringsRight(const List: TStrings; DeleteIfEmpty: Boolean = True); +procedure TrimStringsLeft(const List: TStrings; DeleteIfEmpty: Boolean = True); +function AddStringToStrings(const S: string; Strings: TStrings; const Unique: Boolean): Boolean; + +// Miscellaneous +// (OF) moved to JclSysUtils +// function BooleanToStr(B: Boolean): string; + // AnsiString here because it is binary data +function FileToString(const FileName: string): {$IFDEF COMPILER12_UP}RawByteString{$ELSE}AnsiString{$ENDIF}; +procedure StringToFile(const FileName: string; const Contents: {$IFDEF COMPILER12_UP}RawByteString{$ELSE}AnsiString{$ENDIF}; + Append: Boolean = False); + +function StrToken(var S: string; Separator: Char): string; +procedure StrTokens(const S: string; const List: TStrings); +procedure StrTokenToStrings(S: string; Separator: Char; const List: TStrings); +function StrWord(const S: string; var Index: SizeInt; out Word: string): Boolean; overload; +function StrWord(var S: PChar; out Word: string): Boolean; overload; +function StrIdent(const S: string; var Index: SizeInt; out Ident: string): Boolean; overload; +function StrIdent(var S: PChar; out Ident: string): Boolean; overload; +{$IFNDEF WINSCP} +function StrToFloatSafe(const S: string): Float; +function StrToIntSafe(const S: string): Integer; +{$ENDIF ~WINSCP} +procedure StrNormIndex(const StrLen: SizeInt; var Index: SizeInt; var Count: SizeInt); overload; + +function ArrayOf(List: TStrings): TDynStringArray; overload; + +type + FormatException = class(EJclError); + ArgumentException = class(EJclError); + ArgumentNullException = class(EJclError); + ArgumentOutOfRangeException = class(EJclError); + + IToString = interface + ['{C4ABABB4-1029-46E7-B5FA-99800F130C05}'] + function ToString: string; + end; + + TCharDynArray = array of Char; + + // The TStringBuilder class is a Delphi implementation of the .NET + // System.Text.StringBuilder. + // It is zero based and the method that allow an TObject (Append, Insert, + // AppendFormat) are limited to IToString implementors or Delphi 2009+ RTL. + // This class is not threadsafe. Any instance of TStringBuilder should not + // be used in different threads at the same time. + TJclStringBuilder = class(TInterfacedObject, IToString) + private + FChars: TCharDynArray; + FLength: SizeInt; + FMaxCapacity: SizeInt; + + function GetCapacity: SizeInt; + procedure SetCapacity(const Value: SizeInt); + function GetChars(Index: SizeInt): Char; + procedure SetChars(Index: SizeInt; const Value: Char); + procedure Set_Length(const Value: SizeInt); + protected + function AppendPChar(Value: PChar; Count: SizeInt; RepeatCount: SizeInt = 1): TJclStringBuilder; + function InsertPChar(Index: SizeInt; Value: PChar; Count: SizeInt; RepeatCount: SizeInt = 1): TJclStringBuilder; + public + constructor Create(const Value: string; Capacity: SizeInt = 16); overload; + constructor Create(Capacity: SizeInt = 16; MaxCapacity: SizeInt = MaxInt); overload; + constructor Create(const Value: string; StartIndex, Length, Capacity: SizeInt); overload; + + function Append(const Value: string): TJclStringBuilder; overload; + function Append(const Value: string; StartIndex, Length: SizeInt): TJclStringBuilder; overload; + function Append(Value: Boolean): TJclStringBuilder; overload; + function Append(Value: Char; RepeatCount: SizeInt = 1): TJclStringBuilder; overload; + function Append(const Value: array of Char): TJclStringBuilder; overload; + function Append(const Value: array of Char; StartIndex, Length: SizeInt): TJclStringBuilder; overload; + function Append(Value: Cardinal): TJclStringBuilder; overload; + function Append(Value: Integer): TJclStringBuilder; overload; + function Append(Value: Double): TJclStringBuilder; overload; + function Append(Value: Int64): TJclStringBuilder; overload; + function Append(Obj: TObject): TJclStringBuilder; overload; + function AppendFormat(const Fmt: string; const Args: array of const): TJclStringBuilder; overload; + function AppendFormat(const Fmt: string; Arg0: Variant): TJclStringBuilder; overload; + function AppendFormat(const Fmt: string; Arg0, Arg1: Variant): TJclStringBuilder; overload; + function AppendFormat(const Fmt: string; Arg0, Arg1, Arg2: Variant): TJclStringBuilder; overload; + + function Insert(Index: SizeInt; const Value: string; Count: SizeInt = 1): TJclStringBuilder; overload; + function Insert(Index: SizeInt; Value: Boolean): TJclStringBuilder; overload; + function Insert(Index: SizeInt; const Value: array of Char): TJclStringBuilder; overload; + function Insert(Index: SizeInt; const Value: array of Char; StartIndex, Length: SizeInt): TJclStringBuilder; + overload; + function Insert(Index: SizeInt; Value: Cardinal): TJclStringBuilder; overload; + function Insert(Index: SizeInt; Value: Integer): TJclStringBuilder; overload; + function Insert(Index: SizeInt; Value: Double): TJclStringBuilder; overload; + function Insert(Index: SizeInt; Value: Int64): TJclStringBuilder; overload; + function Insert(Index: SizeInt; Obj: TObject): TJclStringBuilder; overload; + + function Replace(OldChar, NewChar: Char; StartIndex: SizeInt = 0; Count: SizeInt = -1): TJclStringBuilder; + overload; + function Replace(OldValue, NewValue: string; StartIndex: SizeInt = 0; Count: SizeInt = -1): TJclStringBuilder; + overload; + + function Remove(StartIndex, Length: SizeInt): TJclStringBuilder; + function EnsureCapacity(Capacity: SizeInt): SizeInt; + procedure Clear; + + { IToString } + function ToString: string; {$IFDEF RTL200_UP} override; {$ENDIF RTL200_UP} + + property __Chars__[Index: SizeInt]: Char read GetChars write SetChars; default; + property Chars: TCharDynArray read FChars; + property Length: SizeInt read FLength write Set_Length; + property Capacity: SizeInt read GetCapacity write SetCapacity; + property MaxCapacity: SizeInt read FMaxCapacity; + end; + + {$IFDEF RTL200_UP} + TStringBuilder = {$IFDEF HAS_UNITSCOPE}System.{$ENDIF}SysUtils.TStringBuilder; + {$ELSE ~RTL200_UP} + TStringBuilder = TJclStringBuilder; + {$ENDIF ~RTL200_UP} + +// DotNetFormat() uses the .NET format style: "{argX}" +function DotNetFormat(const Fmt: string; const Args: array of const): string; overload; +function DotNetFormat(const Fmt: string; const Arg0: Variant): string; overload; +function DotNetFormat(const Fmt: string; const Arg0, Arg1: Variant): string; overload; +function DotNetFormat(const Fmt: string; const Arg0, Arg1, Arg2: Variant): string; overload; + +// TJclTabSet +type + TJclTabSet = class (TInterfacedObject, IToString) + private + FData: TObject; + function GetCount: SizeInt; + function GetStops(Index: SizeInt): SizeInt; + function GetTabWidth: SizeInt; + function GetZeroBased: Boolean; + procedure SetStops(Index, Value: SizeInt); + procedure SetTabWidth(Value: SizeInt); + procedure SetZeroBased(Value: Boolean); + protected + function FindStop(Column: SizeInt): SizeInt; + function InternalTabStops: TDynSizeIntArray; + function InternalTabWidth: SizeInt; + procedure RemoveAt(Index: SizeInt); + public + constructor Create; overload; + constructor Create(Data: TObject); overload; + constructor Create(TabWidth: SizeInt); overload; + constructor Create(const Tabstops: array of SizeInt; ZeroBased: Boolean); overload; + constructor Create(const Tabstops: array of SizeInt; ZeroBased: Boolean; TabWidth: SizeInt); overload; + destructor Destroy; override; + + // cloning and referencing + function Clone: TJclTabSet; + function NewReference: TJclTabSet; + + // Tab stops manipulation + function Add(Column: SizeInt): SizeInt; + function Delete(Column: SizeInt): SizeInt; + + // Usage + function Expand(const S: string): string; overload; + function Expand(const S: string; Column: SizeInt): string; overload; + procedure OptimalFillInfo(StartColumn, TargetColumn: SizeInt; out TabsNeeded, SpacesNeeded: SizeInt); + function Optimize(const S: string): string; overload; + function Optimize(const S: string; Column: SizeInt): string; overload; + function StartColumn: SizeInt; + function TabFrom(Column: SizeInt): SizeInt; + function UpdatePosition(const S: string): SizeInt; overload; + function UpdatePosition(const S: string; Column: SizeInt): SizeInt; overload; + function UpdatePosition(const S: string; var Column, Line: SizeInt): SizeInt; overload; + + { IToString } + function ToString: string; overload; {$IFDEF RTL200_UP} override; {$ENDIF RTL200_UP} + // Conversions + function ToString(FormattingOptions: SizeInt): string; {$IFDEF RTL200_UP} reintroduce; {$ENDIF RTL200_UP} overload; + class function FromString(const S: string): TJclTabSet; {$IFDEF SUPPORTS_STATIC} static; {$ENDIF SUPPORTS_STATIC} + + // Properties + property ActualTabWidth: SizeInt read InternalTabWidth; + property Count: SizeInt read GetCount; + property TabStops[Index: SizeInt]: SizeInt read GetStops write SetStops; default; + property TabWidth: SizeInt read GetTabWidth write SetTabWidth; + property ZeroBased: Boolean read GetZeroBased write SetZeroBased; + end; + +// Formatting constants +const + TabSetFormatting_SurroundStopsWithBrackets = 1; + TabSetFormatting_EmptyBracketsIfNoStops = 2; + TabSetFormatting_NoTabStops = 4; + TabSetFormatting_NoTabWidth = 8; + TabSetFormatting_AutoTabWidth = 16; + // common combinations + TabSetFormatting_Default = 0; + TabSetFormatting_AlwaysUseBrackets = TabSetFormatting_SurroundStopsWithBrackets or + TabSetFormatting_EmptyBracketsIfNoStops; + TabSetFormatting_Full = TabSetFormatting_AlwaysUseBrackets or TabSetFormatting_AutoTabWidth; + // aliases + TabSetFormatting_StopsOnly = TabSetFormatting_NoTabWidth; + TabSetFormatting_TabWidthOnly = TabSetFormatting_NoTabStops; + TabSetFormatting_StopsWithoutBracketsAndTabWidth = TabSetFormatting_Default; + +// Tab expansion routines +function StrExpandTabs(S: string): string; {$IFDEF SUPPORTS_INLINE}inline; {$ENDIF} overload; +function StrExpandTabs(S: string; TabWidth: SizeInt): string; {$IFDEF SUPPORTS_INLINE}inline; {$ENDIF} overload; +function StrExpandTabs(S: string; TabSet: TJclTabSet): string; {$IFDEF SUPPORTS_INLINE}inline; {$ENDIF} overload; +// Tab optimization routines +function StrOptimizeTabs(S: string): string; {$IFDEF SUPPORTS_INLINE}inline; {$ENDIF} overload; +function StrOptimizeTabs(S: string; TabWidth: SizeInt): string; {$IFDEF SUPPORTS_INLINE}inline; {$ENDIF} overload; +function StrOptimizeTabs(S: string; TabSet: TJclTabSet): string; {$IFDEF SUPPORTS_INLINE}inline; {$ENDIF} overload; + +// move to JclBase? +type + NullReferenceException = class(EJclError) + public + constructor Create; overload; + end; + +procedure StrResetLength(var S: WideString); overload; +procedure StrResetLength(var S: AnsiString); overload; +procedure StrResetLength(S: TJclStringBuilder); overload; +{$IFDEF SUPPORTS_UNICODE_STRING} +procedure StrResetLength(var S: UnicodeString); overload; +{$ENDIF SUPPORTS_UNICODE_STRING} + +// natural comparison functions +{$IFNDEF WINSCP} +function CompareNaturalStr(const S1, S2: string): SizeInt; +function CompareNaturalText(const S1, S2: string): SizeInt; +{$ENDIF ~WINSCP} + +{$IFNDEF UNICODE_RTL_DATABASE} +// internal structures published to make function inlining working +const + MaxStrCharCount = Ord(High(Char)) + 1; // # of chars in one set + StrLoOffset = MaxStrCharCount * 0; // offset to lower case chars + StrUpOffset = MaxStrCharCount * 1; // offset to upper case chars + StrReOffset = MaxStrCharCount * 2; // offset to reverse case chars + StrCaseMapSize = MaxStrCharCount * 3; // # of chars is a table + +var + StrCaseMap: array [0..StrCaseMapSize - 1] of Char; // case mappings + StrCaseMapReady: Boolean = False; // true if case map exists + StrCharTypes: array [Char] of Word; +{$ENDIF ~UNICODE_RTL_DATABASE} + +{$IFDEF UNITVERSIONING} +const + UnitVersioning: TUnitVersionInfo = ( + RCSfile: '$URL$'; + Revision: '$Revision$'; + Date: '$Date$'; + LogPath: 'JCL\source\common'; + Extra: ''; + Data: nil + ); +{$ENDIF UNITVERSIONING} + +implementation + +uses + {$IFDEF HAS_UNIT_LIBC} + Libc, + {$ENDIF HAS_UNIT_LIBC} + {$IFDEF SUPPORTS_UNICODE} + {$IFDEF HAS_UNITSCOPE} + System.StrUtils, + {$ELSE ~HAS_UNITSCOPE} + StrUtils, + {$ENDIF ~HAS_UNITSCOPE} + {$ENDIF SUPPORTS_UNICODE} + {$IFNDEF WINSCP}JclLogic,{$ELSE}Math,{$ENDIF ~WINSCP} JclResources, JclStreams, JclSynch{$IFNDEF WINSCP}, JclSysUtils{$ENDIF ~WINSCP}; + +//=== Internal =============================================================== + +type + TStrRec = packed record + RefCount: Longint; + Length: Longint; + end; + PStrRec = ^TStrRec; + +{$IFNDEF UNICODE_RTL_DATABASE} +procedure LoadCharTypes; +var + CurrChar: Char; + CurrType: Word; +begin + for CurrChar := Low(CurrChar) to High(CurrChar) do + begin + {$IFDEF MSWINDOWS} + CurrType := 0; + GetStringTypeEx(LOCALE_USER_DEFAULT, CT_CTYPE1, @CurrChar, 1, CurrType); + {$DEFINE CHAR_TYPES_INITIALIZED} + {$ENDIF MSWINDOWS} + {$IFDEF LINUX} + CurrType := 0; + if isupper(Byte(CurrChar)) <> 0 then + CurrType := CurrType or C1_UPPER; + if islower(Byte(CurrChar)) <> 0 then + CurrType := CurrType or C1_LOWER; + if isdigit(Byte(CurrChar)) <> 0 then + CurrType := CurrType or C1_DIGIT; + if isspace(Byte(CurrChar)) <> 0 then + CurrType := CurrType or C1_SPACE; + if ispunct(Byte(CurrChar)) <> 0 then + CurrType := CurrType or C1_PUNCT; + if iscntrl(Byte(CurrChar)) <> 0 then + CurrType := CurrType or C1_CNTRL; + if isblank(Byte(CurrChar)) <> 0 then + CurrType := CurrType or C1_BLANK; + if isxdigit(Byte(CurrChar)) <> 0 then + CurrType := CurrType or C1_XDIGIT; + if isalpha(Byte(CurrChar)) <> 0 then + CurrType := CurrType or C1_ALPHA; + {$DEFINE CHAR_TYPES_INITIALIZED} + {$ENDIF LINUX} + StrCharTypes[CurrChar] := CurrType; + {$IFNDEF CHAR_TYPES_INITIALIZED} + Implement case map initialization here + {$ENDIF ~CHAR_TYPES_INITIALIZED} + end; +end; + +procedure LoadCaseMap; +var + CurrChar, UpCaseChar, LoCaseChar, ReCaseChar: Char; +begin + if not StrCaseMapReady then + begin + for CurrChar := Low(Char) to High(Char) do + begin + {$IFDEF MSWINDOWS} + LoCaseChar := CurrChar; + UpCaseChar := CurrChar; + {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.CharLowerBuff(@LoCaseChar, 1); + {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.CharUpperBuff(@UpCaseChar, 1); + {$DEFINE CASE_MAP_INITIALIZED} + {$ENDIF MSWINDOWS} + {$IFDEF LINUX} + LoCaseChar := Char(tolower(Byte(CurrChar))); + UpCaseChar := Char(toupper(Byte(CurrChar))); + {$DEFINE CASE_MAP_INITIALIZED} + {$ENDIF LINUX} + {$IFNDEF CASE_MAP_INITIALIZED} + Implement case map initialization here + {$ENDIF ~CASE_MAP_INITIALIZED} + if CharIsUpper(CurrChar) then + ReCaseChar := LoCaseChar + else + if CharIsLower(CurrChar) then + ReCaseChar := UpCaseChar + else + ReCaseChar := CurrChar; + StrCaseMap[Ord(CurrChar) + StrLoOffset] := LoCaseChar; + StrCaseMap[Ord(CurrChar) + StrUpOffset] := UpCaseChar; + StrCaseMap[Ord(CurrChar) + StrReOffset] := ReCaseChar; + end; + StrCaseMapReady := True; + end; +end; + +// Uppercases or Lowercases a give string depending on the +// passed offset. (UpOffset or LoOffset) + +procedure StrCase(var Str: string; const Offset: SizeInt); +var + P: PChar; + I, L: SizeInt; +begin + L := Length(Str); + if L > 0 then + begin + UniqueString(Str); + P := PChar(Str); + for I := 1 to L do + begin + P^ := StrCaseMap[Offset + Ord(P^)]; + Inc(P); + end; + end; +end; + +// Internal utility function +// Uppercases or Lowercases a give null terminated string depending on the +// passed offset. (UpOffset or LoOffset) + +procedure StrCaseBuff(S: PChar; const Offset: SizeInt); +var + C: Char; +begin + if S <> nil then + begin + repeat + C := S^; + S^ := StrCaseMap[Offset + Ord(C)]; + Inc(S); + until C = #0; + end; +end; +{$ENDIF ~UNICODE_RTL_DATABASE} + +function StrEndW(Str: PWideChar): PWideChar; +begin + Result := Str; + while Result^ <> #0 do + Inc(Result); +end; + +function ArrayContainsChar(const Chars: array of Char; const C: Char): Boolean; +var + idx: SizeInt; +begin + Result := ArrayContainsChar(Chars, C, idx); +end; + +function ArrayContainsChar(const Chars: array of Char; const C: Char; out Index: SizeInt): Boolean; +{ optimized version for sorted arrays +var + I, L, H: SizeInt; +begin + L := Low(Chars); + H := High(Chars); + while L <= H do + begin + I := (L + H) div 2; + if C = Chars[I] then + begin + Result := True; + Exit; + end + else + if C < Chars[I] then + H := I - 1 + else + // C > Chars[I] + L := I + 1; + end; + Result := False; +end;} +begin + Index := High(Chars); + while (Index >= Low(Chars)) and (Chars[Index] <> C) do + Dec(Index); + Result := Index >= Low(Chars); +end; + +// String Test Routines +function StrIsAlpha(const S: string): Boolean; +var + I: SizeInt; +begin + Result := S <> ''; + for I := 1 to Length(S) do + begin + if not CharIsAlpha(S[I]) then + begin + Result := False; + Exit; + end; + end; +end; + +function StrIsAlphaNum(const S: string): Boolean; +var + I: SizeInt; +begin + Result := S <> ''; + for I := 1 to Length(S) do + begin + if not CharIsAlphaNum(S[I]) then + begin + Result := False; + Exit; + end; + end; +end; + +{$IFNDEF WINSCP} +function StrConsistsofNumberChars(const S: string): Boolean; +var + I: SizeInt; +begin + Result := S <> ''; + for I := 1 to Length(S) do + begin + if not CharIsNumberChar(S[I]) then + begin + Result := False; + Exit; + end; + end; +end; +{$ENDIF ~WINSCP} + +function StrContainsChars(const S: string; const Chars: TCharValidator; CheckAll: Boolean): Boolean; +var + I: SizeInt; +begin + Result := False; + if CheckAll then + begin + // this will not work with the current definition of the validator. The validator would need to check each character + // it requires against the string (which is currently not provided to the Validator). The current implementation of + // CheckAll will check if all characters in S will be accepted by the provided Validator, which is wrong and incon- + // sistent with the documentation and the array-based overload. + for I := 1 to Length(S) do + begin + Result := Chars(S[I]); + if not Result then + Break; + end; + end + else + begin + for I := 1 to Length(S) do + begin + Result := Chars(S[I]); + if Result then + Break; + end; + end; +end; + +function StrContainsChars(const S: string; const Chars: array of Char; CheckAll: Boolean): Boolean; +var + I: SizeInt; +begin + if CheckAll then + begin + Result := True; + I := High(Chars); + while (I >= 0) and Result do + begin + Result := CharPos(S, Chars[I]) > 0; + Dec(I); + end; + end + else + begin + Result := False; + for I := 1 to Length(S) do + begin + Result := ArrayContainsChar(Chars, S[I]); + if Result then + Break; + end; + end; +end; + +function StrIsAlphaNumUnderscore(const S: string): Boolean; +var + I: SizeInt; + C: Char; +begin + for I := 1 to Length(S) do + begin + C := S[I]; + + if not (CharIsAlphaNum(C) or (C = '_')) then + begin + Result := False; + Exit; + end; + end; + + Result := Length(S) > 0; +end; + +function StrIsDigit(const S: string): Boolean; +var + I: SizeInt; +begin + Result := S <> ''; + for I := 1 to Length(S) do + begin + if not CharIsDigit(S[I]) then + begin + Result := False; + Exit; + end; + end; +end; + +function StrIsSubset(const S: string; const ValidChars: TCharValidator): Boolean; +var + I: SizeInt; +begin + for I := 1 to Length(S) do + begin + Result := ValidChars(S[I]); + if not Result then + Exit; + end; + + Result := Length(S) > 0; +end; + +function StrIsSubset(const S: string; const ValidChars: array of Char): Boolean; +var + I: SizeInt; +begin + for I := 1 to Length(S) do + begin + Result := ArrayContainsChar(ValidChars, S[I]); + if not Result then + Exit; + end; + + Result := Length(S) > 0; +end; + +function StrSame(const S1, S2: string; CaseSensitive: Boolean): Boolean; +begin + Result := StrCompare(S1, S2, CaseSensitive) = 0; +end; + +//=== String Transformation Routines ========================================= + +function StrCenter(const S: string; L: SizeInt; C: Char = ' '): string; +begin + if Length(S) < L then + begin + Result := StringOfChar(C, (L - Length(S)) div 2) + S; + Result := Result + StringOfChar(C, L - Length(Result)); + end + else + Result := S; +end; + +function StrCharPosLower(const S: string; CharPos: SizeInt): string; +begin + Result := S; + if (CharPos > 0) and (CharPos <= Length(S)) then + Result[CharPos] := CharLower(Result[CharPos]); +end; + +function StrCharPosUpper(const S: string; CharPos: SizeInt): string; +begin + Result := S; + if (CharPos > 0) and (CharPos <= Length(S)) then + Result[CharPos] := CharUpper(Result[CharPos]); +end; + +function StrDoubleQuote(const S: string): string; +begin + Result := NativeDoubleQuote + S + NativeDoubleQuote; +end; + +function StrEnsureNoPrefix(const Prefix, Text: string): string; +var + PrefixLen: SizeInt; +begin + PrefixLen := Length(Prefix); + if Copy(Text, 1, PrefixLen) = Prefix then + Result := Copy(Text, PrefixLen + 1, Length(Text)) + else + Result := Text; +end; + +function StrEnsureNoSuffix(const Suffix, Text: string): string; +var + SuffixLen: SizeInt; + StrLength: SizeInt; +begin + SuffixLen := Length(Suffix); + StrLength := Length(Text); + if Copy(Text, StrLength - SuffixLen + 1, SuffixLen) = Suffix then + Result := Copy(Text, 1, StrLength - SuffixLen) + else + Result := Text; +end; + +function StrEnsurePrefix(const Prefix, Text: string): string; +var + PrefixLen: SizeInt; +begin + PrefixLen := Length(Prefix); + if Copy(Text, 1, PrefixLen) = Prefix then + Result := Text + else + Result := Prefix + Text; +end; + +function StrEnsureSuffix(const Suffix, Text: string): string; +var + SuffixLen: SizeInt; +begin + SuffixLen := Length(Suffix); + if Copy(Text, Length(Text) - SuffixLen + 1, SuffixLen) = Suffix then + Result := Text + else + Result := Text + Suffix; +end; + +function StrEscapedToString(const S: string): string; + procedure HandleHexEscapeSeq(const S: string; var I: SizeInt; Len: SizeInt; var Dest: string); + const + HexDigits = string('0123456789abcdefABCDEF'); + var + StartI, Val, N: SizeInt; + begin + StartI := I; + N := Pos(S[I + 1], HexDigits) - 1; + if N < 0 then + // '\x' without hex digit following is not escape sequence + Dest := Dest + '\x' + else + begin + Inc(I); // Jump over x + if N >= 16 then + N := N - 6; + Val := N; + // Same for second digit + if I < Len then + begin + N := Pos(S[I + 1], HexDigits) - 1; + if N >= 0 then + begin + Inc(I); // Jump over first digit + if N >= 16 then + N := N - 6; + Val := Val * 16 + N; + end; + end; + + if Val > Ord(High(Char)) then + raise EJclStringError.CreateResFmt(@RsNumericConstantTooLarge, [Val, StartI]); + + Dest := Dest + Char(Val); + end; + end; + + procedure HandleOctEscapeSeq(const S: string; var I: SizeInt; Len: SizeInt; var Dest: string); + const + OctDigits = string('01234567'); + var + StartI, Val, N: SizeInt; + begin + StartI := I; + // first digit + Val := Pos(S[I], OctDigits) - 1; + if I < Len then + begin + N := Pos(S[I + 1], OctDigits) - 1; + if N >= 0 then + begin + Inc(I); + Val := Val * 8 + N; + end; + if I < Len then + begin + N := Pos(S[I + 1], OctDigits) - 1; + if N >= 0 then + begin + Inc(I); + Val := Val * 8 + N; + end; + end; + end; + + if Val > Ord(High(Char)) then + raise EJclStringError.CreateResFmt(@RsNumericConstantTooLarge, [Val, StartI]); + + Dest := Dest + Char(Val); + end; + +var + I, Len: SizeInt; +begin + Result := ''; + I := 1; + Len := Length(S); + while I <= Len do + begin + if not ((S[I] = '\') and (I < Len)) then + Result := Result + S[I] + else + begin + Inc(I); // Jump over escape character + case S[I] of + 'a': + Result := Result + NativeBell; + 'b': + Result := Result + NativeBackspace; + 'f': + Result := Result + NativeFormFeed; + 'n': + Result := Result + NativeLineFeed; + 'r': + Result := Result + NativeCarriageReturn; + 't': + Result := Result + NativeTab; + 'v': + Result := Result + NativeVerticalTab; + '\': + Result := Result + '\'; + '"': + Result := Result + '"'; + '''': + Result := Result + ''''; // Optionally escaped + '?': + Result := Result + '?'; // Optionally escaped + 'x': + if I < Len then + // Start of hex escape sequence + HandleHexEscapeSeq(S, I, Len, Result) + else + // '\x' at end of string is not escape sequence + Result := Result + '\x'; + '0'..'7': + // start of octal escape sequence + HandleOctEscapeSeq(S, I, Len, Result); + else + // no escape sequence + Result := Result + '\' + S[I]; + end; + end; + Inc(I); + end; +end; + +function StrLower(const S: string): string; +begin + Result := S; + StrLowerInPlace(Result); +end; + +procedure StrLowerInPlace(var S: string); +{$IFDEF UNICODE_RTL_DATABASE} +var + P: PChar; + I, L: SizeInt; +begin + L := Length(S); + if L > 0 then + begin + UniqueString(S); + P := PChar(S); + for I := 1 to L do + begin + P^ := TCharacter.ToLower(P^); + Inc(P); + end; + end; +end; +{$ELSE ~UNICODE_RTL_DATABASE} +begin + StrCase(S, StrLoOffset); +end; +{$ENDIF ~UNICODE_RTL_DATABASE} + +procedure StrLowerBuff(S: PChar); +begin + {$IFDEF UNICODE_RTL_DATABASE} + if S <> nil then + begin + repeat + S^ := TCharacter.ToLower(S^); + Inc(S); + until S^ = #0; + end; + {$ELSE ~UNICODE_RTL_DATABASE} + StrCaseBuff(S, StrLoOffset); + {$ENDIF ~UNICODE_RTL_DATABASE} +end; + +procedure StrMove(var Dest: string; const Source: string; + const ToIndex, FromIndex, Count: SizeInt); +begin + // Check strings + if (Source = '') or (Length(Dest) = 0) then + Exit; + + // Check FromIndex + if (FromIndex <= 0) or (FromIndex > Length(Source)) or + (ToIndex <= 0) or (ToIndex > Length(Dest)) or + ((FromIndex + Count - 1) > Length(Source)) or ((ToIndex + Count - 1) > Length(Dest)) then + { TODO : Is failure without notice the proper thing to do here? } + Exit; + + // Move + Move(Source[FromIndex], Dest[ToIndex], Count * SizeOf(Char)); +end; + +function StrPadLeft(const S: string; Len: SizeInt; C: Char): string; +var + L: SizeInt; +begin + L := Length(S); + if L < Len then + Result := StringOfChar(C, Len - L) + S + else + Result := S; +end; + +function StrPadRight(const S: string; Len: SizeInt; C: Char): string; +var + L: SizeInt; +begin + L := Length(S); + if L < Len then + Result := S + StringOfChar(C, Len - L) + else + Result := S; +end; + +function StrProper(const S: string): string; +begin + Result := StrLower(S); + if Result <> '' then + Result[1] := UpCase(Result[1]); +end; + +procedure StrProperBuff(S: PChar); +begin + if (S <> nil) and (S^ <> #0) then + begin + StrLowerBuff(S); + S^ := CharUpper(S^); + end; +end; + +function StrQuote(const S: string; C: Char): string; +var + L: SizeInt; +begin + L := Length(S); + Result := S; + if L > 0 then + begin + if Result[1] <> C then + begin + Result := C + Result; + Inc(L); + end; + if Result[L] <> C then + Result := Result + C; + end; +end; + +function StrRemoveChars(const S: string; const Chars: TCharValidator): string; +var + Source, Dest: PChar; + Len, Index: SizeInt; +begin + Len := Length(S); + SetLength(Result, Len); + UniqueString(Result); + Source := PChar(S); + Dest := PChar(Result); + for Index := 0 to Len - 1 do + begin + if not Chars(Source^) then + begin + Dest^ := Source^; + Inc(Dest); + end; + Inc(Source); + end; + SetLength(Result, Dest - PChar(Result)); +end; + +function StrRemoveChars(const S: string; const Chars: array of Char): string; +var + Source, Dest: PChar; + Len, Index: SizeInt; +begin + Len := Length(S); + SetLength(Result, Len); + UniqueString(Result); + Source := PChar(S); + Dest := PChar(Result); + for Index := 0 to Len - 1 do + begin + if not ArrayContainsChar(Chars, Source^) then + begin + Dest^ := Source^; + Inc(Dest); + end; + Inc(Source); + end; + SetLength(Result, Dest - PChar(Result)); +end; + +function StrRemoveLeadingChars(const S: string; const Chars: TCharValidator): string; +var + Len : SizeInt; + I: SizeInt; +begin + Len := Length(S); + I := 1; + while (I <= Len) and Chars(s[I]) do + Inc(I); + Result := Copy (s, I, Len-I+1); +end; + +function StrRemoveLeadingChars(const S: string; const Chars: array of Char): string; +var + Len : SizeInt; + I: SizeInt; +begin + Len := Length(S); + I := 1; + while (I <= Len) and ArrayContainsChar(Chars, s[I]) do + Inc(I); + Result := Copy (s, I, Len-I+1); +end; + +function StrRemoveEndChars(const S: string; const Chars: TCharValidator): string; +var + Len : SizeInt; +begin + Len := Length(S); + while (Len > 0) and Chars(s[Len]) do + Dec(Len); + Result := Copy (s, 1, Len); +end; + +function StrRemoveEndChars(const S: string; const Chars: array of Char): string; +var + Len : SizeInt; +begin + Len := Length(S); + while (Len > 0) and ArrayContainsChar(Chars, s[Len]) do + Dec(Len); + Result := Copy (s, 1, Len); +end; + +function StrKeepChars(const S: string; const Chars: TCharValidator): string; +var + Source, Dest: PChar; + Len, Index: SizeInt; +begin + Len := Length(S); + SetLength(Result, Len); + UniqueString(Result); + Source := PChar(S); + Dest := PChar(Result); + for Index := 0 to Len - 1 do + begin + if Chars(Source^) then + begin + Dest^ := Source^; + Inc(Dest); + end; + Inc(Source); + end; + SetLength(Result, Dest - PChar(Result)); +end; + +function StrKeepChars(const S: string; const Chars: array of Char): string; +var + Source, Dest: PChar; + Len, Index: SizeInt; +begin + Len := Length(S); + SetLength(Result, Len); + UniqueString(Result); + Source := PChar(S); + Dest := PChar(Result); + for Index := 0 to Len - 1 do + begin + if ArrayContainsChar(Chars, Source^) then + begin + Dest^ := Source^; + Inc(Dest); + end; + Inc(Source); + end; + SetLength(Result, Dest - PChar(Result)); +end; + +function StrRepeat(const S: string; Count: SizeInt): string; +var + Len, Index: SizeInt; + Dest, Source: PChar; +begin + Len := Length(S); + SetLength(Result, Count * Len); + Dest := PChar(Result); + Source := PChar(S); + if Dest <> nil then + for Index := 0 to Count - 1 do + begin + Move(Source^, Dest^, Len * SizeOf(Char)); + Inc(Dest, Len); + end; +end; + +function StrRepeatLength(const S: string; L: SizeInt): string; +var + Len: SizeInt; + Dest: PChar; +begin + Result := ''; + Len := Length(S); + + if (Len > 0) and (S <> '') then + begin + SetLength(Result, L); + Dest := PChar(Result); + while (L > 0) do + begin + Move(S[1], Dest^, Min(L, Len) * SizeOf(Char)); + Inc(Dest, Len); + Dec(L, Len); + end; + end; +end; + +procedure StrReplace(var S: string; const Search, Replace: string; Flags: TReplaceFlags); +var + SearchStr: string; + ResultStr: string; { result string } + SourcePtr: PChar; { pointer into S of character under examination } + SourceMatchPtr: PChar; { pointers into S and Search when first character has } + SearchMatchPtr: PChar; { been matched and we're probing for a complete match } + ResultPtr: PChar; { pointer into Result of character being written } + ResultIndex, + SearchLength, { length of search string } + ReplaceLength, { length of replace string } + BufferLength, { length of temporary result buffer } + ResultLength: SizeInt; { length of result string } + C: Char; { first character of search string } + IgnoreCase: Boolean; +begin + if Search = '' then + begin + if S = '' then + begin + S := Replace; + Exit; + end + else + raise EJclStringError.CreateRes(@RsBlankSearchString); + end; + + if S <> '' then + begin + IgnoreCase := rfIgnoreCase in Flags; + if IgnoreCase then + SearchStr := StrUpper(Search) + else + SearchStr := Search; + { avoid having to call Length() within the loop } + SearchLength := Length(Search); + ReplaceLength := Length(Replace); + ResultLength := Length(S); + BufferLength := ResultLength; + SetLength(ResultStr, BufferLength); + { get pointers to begin of source and result } + ResultPtr := PChar(ResultStr); + SourcePtr := PChar(S); + C := SearchStr[1]; + { while we haven't reached the end of the string } + while True do + begin + { copy characters until we find the first character of the search string } + if IgnoreCase then + while (CharUpper(SourcePtr^) <> C) and (SourcePtr^ <> #0) do + begin + ResultPtr^ := SourcePtr^; + Inc(ResultPtr); + Inc(SourcePtr); + end + else + while (SourcePtr^ <> C) and (SourcePtr^ <> #0) do + begin + ResultPtr^ := SourcePtr^; + Inc(ResultPtr); + Inc(SourcePtr); + end; + { did we find that first character or did we hit the end of the string? } + if SourcePtr^ = #0 then + Break + else + begin + { continue comparing, +1 because first character was matched already } + SourceMatchPtr := SourcePtr + 1; + SearchMatchPtr := PChar(SearchStr) + 1; + if IgnoreCase then + while (CharUpper(SourceMatchPtr^) = SearchMatchPtr^) and (SearchMatchPtr^ <> #0) do + begin + Inc(SourceMatchPtr); + Inc(SearchMatchPtr); + end + else + while (SourceMatchPtr^ = SearchMatchPtr^) and (SearchMatchPtr^ <> #0) do + begin + Inc(SourceMatchPtr); + Inc(SearchMatchPtr); + end; + { did we find a complete match? } + if SearchMatchPtr^ = #0 then + begin + // keep track of result length + Inc(ResultLength, ReplaceLength - SearchLength); + if ReplaceLength > 0 then + begin + // increase buffer size if required + if ResultLength > BufferLength then + begin + BufferLength := ResultLength * 2; + ResultIndex := ResultPtr - PChar(ResultStr) + 1; + SetLength(ResultStr, BufferLength); + ResultPtr := @ResultStr[ResultIndex]; + end; + { append replace to result and move past the search string in source } + Move((@Replace[1])^, ResultPtr^, ReplaceLength * SizeOf(Char)); + end; + Inc(SourcePtr, SearchLength); + Inc(ResultPtr, ReplaceLength); + { replace all instances or just one? } + if not (rfReplaceAll in Flags) then + begin + { just one, copy until end of source and break out of loop } + while SourcePtr^ <> #0 do + begin + ResultPtr^ := SourcePtr^; + Inc(ResultPtr); + Inc(SourcePtr); + end; + Break; + end; + end + else + begin + { copy current character and start over with the next } + ResultPtr^ := SourcePtr^; + Inc(ResultPtr); + Inc(SourcePtr); + end; + end; + end; + { set result length and copy result into S } + SetLength(ResultStr, ResultLength); + S := ResultStr; + end; +end; + +function StrReplaceChar(const S: string; const Source, Replace: Char): string; +var + I: SizeInt; +begin + Result := S; + for I := 1 to Length(S) do + if Result[I] = Source then + Result[I] := Replace; +end; + +function StrReplaceChars(const S: string; const Chars: TCharValidator; Replace: Char): string; +var + I: SizeInt; +begin + Result := S; + for I := 1 to Length(S) do + if Chars(Result[I]) then + Result[I] := Replace; +end; + +function StrReplaceChars(const S: string; const Chars: array of Char; Replace: Char): string; +var + I: SizeInt; +begin + Result := S; + for I := 1 to Length(S) do + if ArrayContainsChar(Chars, Result[I]) then + Result[I] := Replace; +end; + +function StrReplaceButChars(const S: string; const Chars: TCharValidator; + Replace: Char): string; +var + I: SizeInt; +begin + Result := S; + for I := 1 to Length(S) do + if not Chars(Result[I]) then + Result[I] := Replace; +end; + +function StrReplaceButChars(const S: string; const Chars: array of Char; Replace: Char): string; +var + I: SizeInt; +begin + Result := S; + for I := 1 to Length(S) do + if not ArrayContainsChar(Chars, Result[I]) then + Result[I] := Replace; +end; + +function StrReverse(const S: string): string; +begin + Result := S; + StrReverseInplace(Result); +end; + +procedure StrReverseInPlace(var S: string); +{ TODO -oahuser : Warning: This is dangerous for unicode surrogates } +var + P1, P2: PChar; + C: Char; +begin + UniqueString(S); + P1 := PChar(S); + P2 := P1 + (Length(S) - 1); + while P1 < P2 do + begin + C := P1^; + P1^ := P2^; + P2^ := C; + Inc(P1); + Dec(P2); + end; +end; + +function StrSingleQuote(const S: string): string; +begin + Result := NativeSingleQuote + S + NativeSingleQuote; +end; + +procedure StrSkipChars(var S: PChar; const Chars: TCharValidator); +begin + while Chars(S^) do + Inc(S); +end; + +procedure StrSkipChars(var S: PChar; const Chars: array of Char); +begin + while ArrayContainsChar(Chars, S^) do + Inc(S); +end; + +procedure StrSkipChars(const S: string; var Index: SizeInt; const Chars: TCharValidator); +begin + while Chars(S[Index]) do + Inc(Index); +end; + +procedure StrSkipChars(const S: string; var Index: SizeInt; const Chars: array of Char); +begin + while ArrayContainsChar(Chars, S[Index]) do + Inc(Index); +end; + +function StrSmartCase(const S: string; const Delimiters: TCharValidator): string; +var + Source, Dest: PChar; + Index, Len: SizeInt; + InternalDelimiters: TCharValidator; +begin + Result := ''; + if Assigned(Delimiters) then + InternalDelimiters := Delimiters + else + InternalDelimiters := CharIsSpace; + + if S <> '' then + begin + Result := S; + UniqueString(Result); + + Len := Length(S); + Source := PChar(S); + Dest := PChar(Result); + Inc(Dest); + + for Index := 2 to Len do + begin + if InternalDelimiters(Source^) and not InternalDelimiters(Dest^) then + Dest^ := CharUpper(Dest^); + Inc(Dest); + Inc(Source); + end; + Result[1] := CharUpper(Result[1]); + end; +end; + +function StrSmartCase(const S: string; const Delimiters: array of Char): string; +var + Source, Dest: PChar; + Index, Len: SizeInt; +begin + Result := ''; + + if S <> '' then + begin + Result := S; + UniqueString(Result); + + Len := Length(S); + Source := PChar(S); + Dest := PChar(Result); + Inc(Dest); + + for Index := 2 to Len do + begin + if ArrayContainsChar(Delimiters, Source^) and not ArrayContainsChar(Delimiters, Dest^) then + Dest^ := CharUpper(Dest^); + Inc(Dest); + Inc(Source); + end; + Result[1] := CharUpper(Result[1]); + end; +end; + +function StrStringToEscaped(const S: string): string; +var + I: SizeInt; +begin + Result := ''; + for I := 1 to Length(S) do + begin + case S[I] of + NativeBackspace: + Result := Result + '\b'; + NativeBell: + Result := Result + '\a'; + NativeCarriageReturn: + Result := Result + '\r'; + NAtiveFormFeed: + Result := Result + '\f'; + NativeLineFeed: + Result := Result + '\n'; + NativeTab: + Result := Result + '\t'; + NativeVerticalTab: + Result := Result + '\v'; + NativeBackSlash: + Result := Result + '\\'; + NativeDoubleQuote: + Result := Result + '\"'; + else + // Characters < ' ' are escaped with hex sequence + if S[I] < #32 then + Result := Result + Format('\x%.2x', [SizeInt(S[I])]) + else + Result := Result + S[I]; + end; + end; +end; + +{$IFNDEF WINSCP} +function StrStripNonNumberChars(const S: string): string; +var + I: SizeInt; + C: Char; +begin + Result := ''; + for I := 1 to Length(S) do + begin + C := S[I]; + if CharIsNumberChar(C) then + Result := Result + C; + end; +end; +{$ENDIF ~WINSCP} + +function StrToHex(const Source: string): string; +var + Index: SizeInt; + C, L, N: SizeInt; + BL, BH: Byte; + S: string; +begin + Result := ''; + if Source <> '' then + begin + S := Source; + L := Length(S); + if Odd(L) then + begin + S := '0' + S; + Inc(L); + end; + Index := 1; + SetLength(Result, L div 2); + C := 1; + N := 1; + while C <= L do + begin + BH := CharHex(S[Index]); + Inc(Index); + BL := CharHex(S[Index]); + Inc(Index); + Inc(C, 2); + if (BH = $FF) or (BL = $FF) then + begin + Result := ''; + Exit; + end; + Result[N] := Char((BH shl 4) or BL); + Inc(N); + end; + end; +end; + +function StrTrimCharLeft(const S: string; C: Char): string; +var + I, L: SizeInt; +begin + I := 1; + L := Length(S); + while (I <= L) and (S[I] = C) do + Inc(I); + Result := Copy(S, I, L - I + 1); +end; + +function StrTrimCharsLeft(const S: string; const Chars: TCharValidator): string; +var + I, L: SizeInt; +begin + I := 1; + L := Length(S); + while (I <= L) and Chars(S[I]) do + Inc(I); + Result := Copy(S, I, L - I + 1); +end; + +function StrTrimCharsLeft(const S: string; const Chars: array of Char): string; +var + I, L: SizeInt; +begin + I := 1; + L := Length(S); + while (I <= L) and ArrayContainsChar(Chars, S[I]) do + Inc(I); + Result := Copy(S, I, L - I + 1); +end; + +function StrTrimCharRight(const S: string; C: Char): string; +var + I: SizeInt; +begin + I := Length(S); + while (I >= 1) and (S[I] = C) do + Dec(I); + Result := Copy(S, 1, I); +end; + +function StrTrimCharsRight(const S: string; const Chars: TCharValidator): string; +var + I: SizeInt; +begin + I := Length(S); + while (I >= 1) and Chars(S[I]) do + Dec(I); + Result := Copy(S, 1, I); +end; + +function StrTrimCharsRight(const S: string; const Chars: array of Char): string; +var + I: SizeInt; +begin + I := Length(S); + while (I >= 1) and ArrayContainsChar(Chars, S[I]) do + Dec(I); + Result := Copy(S, 1, I); +end; + +function StrTrimQuotes(const S: string): string; +var + First, Last: Char; + L: SizeInt; +begin + L := Length(S); + if L > 1 then + begin + First := S[1]; + Last := S[L]; + if (First = Last) and ((First = NativeSingleQuote) or (First = NativeDoubleQuote)) then + Result := Copy(S, 2, L - 2) + else + Result := S; + end + else + Result := S; +end; + +function StrUpper(const S: string): string; +begin + Result := S; + StrUpperInPlace(Result); +end; + +procedure StrUpperInPlace(var S: string); +{$IFDEF UNICODE_RTL_DATABASE} +var + P: PChar; + I, L: SizeInt; +begin + L := Length(S); + if L > 0 then + begin + UniqueString(S); + P := PChar(S); + for I := 1 to L do + begin + P^ := TCharacter.ToUpper(P^); + Inc(P); + end; + end; +end; +{$ELSE ~UNICODE_RTL_DATABASE} +begin + StrCase(S, StrUpOffset); +end; +{$ENDIF ~UNICODE_RTL_DATABASE} + +procedure StrUpperBuff(S: PChar); +begin + {$IFDEF UNICODE_RTL_DATABASE} + if S <> nil then + begin + repeat + S^ := TCharacter.ToUpper(S^); + Inc(S); + until S^ = #0; + end; + {$ELSE ~UNICODE_RTL_DATABASE} + StrCaseBuff(S, StrUpOffset); + {$ENDIF ~UNICODE_RTL_DATABASE} +end; + +//=== String Management ====================================================== + +procedure StrAddRef(var S: string); +var + P: PStrRec; +begin + P := Pointer(S); + if P <> nil then + begin + Dec(P); + if P^.RefCount = -1 then + UniqueString(S) + else + LockedInc(P^.RefCount); + end; +end; + +procedure StrDecRef(var S: string); +var + P: PStrRec; +begin + P := Pointer(S); + if P <> nil then + begin + Dec(P); + case P^.RefCount of + -1, 0: { nothing } ; + 1: + begin + Finalize(S); + Pointer(S) := nil; + end; + else + LockedDec(P^.RefCount); + end; + end; +end; + +function StrLength(const S: string): SizeInt; +var + P: PStrRec; +begin + Result := 0; + P := Pointer(S); + if P <> nil then + begin + Dec(P); + Result := P^.Length and (not $80000000 shr 1); + end; +end; + +function StrRefCount(const S: string): SizeInt; +var + P: PStrRec; +begin + Result := 0; + P := Pointer(S); + if P <> nil then + begin + Dec(P); + Result := P^.RefCount; + end; +end; + +procedure StrResetLength(var S: WideString); +var + I: SizeInt; +begin + for I := 0 to Length(S) - 1 do + if S[I + 1] = #0 then + begin + SetLength(S, I); + Exit; + end; +end; + +procedure StrResetLength(var S: AnsiString); +var + I: SizeInt; +begin + for I := 0 to Length(S) - 1 do + if S[I + 1] = #0 then + begin + SetLength(S, I); + Exit; + end; +end; + +procedure StrResetLength(S: TJclStringBuilder); +var + I: SizeInt; +begin + if S <> nil then + for I := 0 to S.Length - 1 do + if S[I] = #0 then + begin + S.Length := I; + Exit; + end; +end; + +{$IFDEF SUPPORTS_UNICODE_STRING} +procedure StrResetLength(var S: UnicodeString); +var + I: SizeInt; +begin + for I := 0 to Length(S) - 1 do + if S[I + 1] = #0 then + begin + SetLength(S, I); + Exit; + end; +end; +{$ENDIF SUPPORTS_UNICODE_STRING} + +//=== String Search and Replace Routines ===================================== + +function StrCharCount(const S: string; C: Char): SizeInt; +var + I: SizeInt; +begin + Result := 0; + for I := 1 to Length(S) do + if S[I] = C then + Inc(Result); +end; + +function StrCharsCount(const S: string; const Chars: TCharValidator): SizeInt; +var + I: SizeInt; +begin + Result := 0; + for I := 1 to Length(S) do + if Chars(S[I]) then + Inc(Result); +end; + +function StrCharsCount(const S: string; const Chars: array of Char): SizeInt; +var + I: SizeInt; +begin + Result := 0; + for I := 1 to Length(S) do + if ArrayContainsChar(Chars, S[I]) then + Inc(Result); +end; + +function StrStrCount(const S, SubS: string): SizeInt; +var + I: SizeInt; +begin + Result := 0; + if (Length(SubS) > Length(S)) or (Length(SubS) = 0) or (Length(S) = 0) then + Exit; + if Length(SubS) = 1 then + begin + Result := StrCharCount(S, SubS[1]); + Exit; + end; + I := StrSearch(SubS, S, 1); + + if I > 0 then + Inc(Result); + + while (I > 0) and (Length(S) > I + Length(SubS)) do + begin + I := StrSearch(SubS, S, I + 1); + + if I > 0 then + Inc(Result); + end; +end; + +(* +{ 1} Test(StrCompareRange('', '', 1, 5), 0); +{ 2} Test(StrCompareRange('A', '', 1, 5), -1); +{ 3} Test(StrCompareRange('AB', '', 1, 5), -1); +{ 4} Test(StrCompareRange('ABC', '', 1, 5), -1); +{ 5} Test(StrCompareRange('', 'A', 1, 5), -1); +{ 6} Test(StrCompareRange('', 'AB', 1, 5), -1); +{ 7} Test(StrCompareRange('', 'ABC', 1, 5), -1); +{ 8} Test(StrCompareRange('A', 'a', 1, 5), -2); +{ 9} Test(StrCompareRange('A', 'a', 1, 1), -32); +{10} Test(StrCompareRange('aA', 'aB', 1, 1), 0); +{11} Test(StrCompareRange('aA', 'aB', 1, 2), -1); +{12} Test(StrCompareRange('aB', 'aA', 1, 2), 1); +{13} Test(StrCompareRange('aA', 'aa', 1, 2), -32); +{14} Test(StrCompareRange('aa', 'aA', 1, 2), 32); +{15} Test(StrCompareRange('', '', 1, 0), 0); +{16} Test(StrCompareRange('A', 'A', 1, 0), -2); +{17} Test(StrCompareRange('Aa', 'A', 1, 0), -2); +{18} Test(StrCompareRange('Aa', 'Aa', 1, 2), 0); +{19} Test(StrCompareRange('Aa', 'A', 1, 2), 0); +{20} Test(StrCompareRange('Ba', 'A', 1, 2), 1); +*) +function StrCompareRangeEx(const S1, S2: string; Index, Count: SizeInt; CaseSensitive: Boolean): SizeInt; +var + Len1, Len2: SizeInt; + I: SizeInt; + C1, C2: Char; +begin + if Pointer(S1) = Pointer(S2) then + begin + if (Count <= 0) and (S1 <> '') then + Result := -2 // no work + else + Result := 0; + end + else + if (S1 = '') or (S2 = '') then + Result := -1 // null string + else + if Count <= 0 then + Result := -2 // no work + else + begin + Len1 := Length(S1); + Len2 := Length(S2); + + if (Index - 1) + Count > Len1 then + Result := -2 + else + begin + if (Index - 1) + Count > Len2 then // strange behaviour, but the assembler code does it + Count := Len2 - (Index - 1); + + if CaseSensitive then + begin + for I := 0 to Count - 1 do + begin + C1 := S1[Index + I]; + C2 := S2[Index + I]; + if C1 <> C2 then + begin + Result := Ord(C1) - Ord(C2); + Exit; + end; + end; + end + else + begin + for I := 0 to Count - 1 do + begin + C1 := S1[Index + I]; + C2 := S2[Index + I]; + if C1 <> C2 then + begin + C1 := CharLower(C1); + C2 := CharLower(C2); + if C1 <> C2 then + begin + Result := Ord(C1) - Ord(C2); + Exit; + end; + end; + end; + end; + Result := 0; + end; + end; +end; + +function StrCompare(const S1, S2: string; CaseSensitive: Boolean): SizeInt; +var + Len1, Len2: SizeInt; +begin + if Pointer(S1) = Pointer(S2) then + Result := 0 + else + begin + Len1 := Length(S1); + Len2 := Length(S2); + Result := Len1 - Len2; + if Result = 0 then + Result := StrCompareRangeEx(S1, S2, 1, Len1, CaseSensitive); + end; +end; + +function StrCompareRange(const S1, S2: string; Index, Count: SizeInt; CaseSensitive: Boolean): SizeInt; +begin + Result := StrCompareRangeEx(S1, S2, Index, Count, CaseSensitive); +end; + +procedure StrFillChar(var S; Count: SizeInt; C: Char); +{$IFDEF SUPPORTS_UNICODE} +asm + // 32 --> EAX S + // EDX Count + // ECX C + // 64 --> RCX S + // RDX Count + // R8W C + {$IFDEF CPU32} + DEC EDX + JS @@Leave +@@Loop: + MOV [EAX], CX + ADD EAX, 2 + DEC EDX + JNS @@Loop + {$ENDIF CPU32} + {$IFDEF CPU64} + DEC RDX + JS @@Leave +@@Loop: + MOV WORD PTR [RCX], R8W + ADD RCX, 2 + DEC RDX + JNS @@Loop + {$ENDIF CPU64} +@@Leave: +end; +{$ELSE ~SUPPORTS_UNICODE} +begin + if Count > 0 then + FillChar(S, Count, C); +end; +{$ENDIF ~SUPPORTS_UNICODE} + +function StrRepeatChar(C: Char; Count: SizeInt): string; +begin + SetLength(Result, Count); + if Count > 0 then + StrFillChar(Result[1], Count, C); +end; + +function StrFind(const Substr, S: string; const Index: SizeInt): SizeInt; +var + pos: SizeInt; +begin + if (SubStr <> '') and (S <> '') then + begin + pos := StrIPos(Substr, Copy(S, Index, Length(S) - Index + 1)); + if pos = 0 then + Result := 0 + else + Result := Index + Pos - 1; + end + else + Result := 0; +end; + +function StrHasPrefix(const S: string; const Prefixes: array of string): Boolean; +begin + Result := StrPrefixIndex(S, Prefixes) > -1; +end; + +function StrHasSuffix(const S: string; const Suffixes: array of string): Boolean; +begin + Result := StrSuffixIndex(S, Suffixes) > -1; +end; + +function StrIndex(const S: string; const List: array of string; CaseSensitive: Boolean): SizeInt; +var + I: SizeInt; +begin + Result := -1; + for I := Low(List) to High(List) do + begin + if StrCompare(S, List[I], CaseSensitive) = 0 then + begin + Result := I; + Break; + end; + end; +end; + +function StrIHasPrefix(const S: string; const Prefixes: array of string): Boolean; +begin + Result := StrIPrefixIndex(S, Prefixes) > -1; +end; + +function StrIHasSuffix(const S: string; const Suffixes: array of string): Boolean; +begin + Result := StrISuffixIndex(S, Suffixes) > -1; +end; + +function StrILastPos(const SubStr, S: string): SizeInt; +begin + Result := StrLastPos(StrUpper(SubStr), StrUpper(S)); +end; + +function StrIPos(const SubStr, S: string): SizeInt; +begin + Result := Pos(StrUpper(SubStr), StrUpper(S)); +end; + +function StrIPrefixIndex(const S: string; const Prefixes: array of string): SizeInt; +var + I: SizeInt; + Test: string; +begin + Result := -1; + for I := Low(Prefixes) to High(Prefixes) do + begin + Test := StrLeft(S, Length(Prefixes[I])); + if CompareText(Test, Prefixes[I]) = 0 then + begin + Result := I; + Break; + end; + end; +end; + +function StrIsOneOf(const S: string; const List: array of string): Boolean; +begin + Result := StrIndex(S, List) > -1; +end; + +function StrISuffixIndex(const S: string; const Suffixes: array of string): SizeInt; +var + I: SizeInt; + Test: string; +begin + Result := -1; + for I := Low(Suffixes) to High(Suffixes) do + begin + Test := StrRight(S, Length(Suffixes[I])); + if CompareText(Test, Suffixes[I]) = 0 then + begin + Result := I; + Break; + end; + end; +end; + +function StrLastPos(const SubStr, S: string): SizeInt; +var + Last, Current: PChar; +begin + Result := 0; + Last := nil; + Current := PChar(S); + + while (Current <> nil) and (Current^ <> #0) do + begin + Current := StrPos(PChar(Current), PChar(SubStr)); + if Current <> nil then + begin + Last := Current; + Inc(Current); + end; + end; + if Last <> nil then + Result := Abs(PChar(S) - Last) + 1; +end; + +// IMPORTANT NOTE: The StrMatch function does currently not work with the Asterix (*) +// (*) acts like (?) + +function StrMatch(const Substr, S: string; Index: SizeInt): SizeInt; +var + SI, SubI, SLen, SubLen: SizeInt; + SubC: Char; +begin + SLen := Length(S); + SubLen := Length(Substr); + Result := 0; + if (Index > SLen) or (SubLen = 0) then + Exit; + while Index <= SLen do + begin + SubI := 1; + SI := Index; + while (SI <= SLen) and (SubI <= SubLen) do + begin + SubC := Substr[SubI]; + if (SubC = '*') or (SubC = '?') or (SubC = S[SI]) then + begin + Inc(SI); + Inc(SubI); + end + else + Break; + end; + if SubI > SubLen then + begin + Result := Index; + Break; + end; + Inc(Index); + end; +end; + +// Derived from "Like" by Michael Winter +function StrMatches(const Substr, S: string; const Index: SizeInt): Boolean; +var + StringPtr: PChar; + PatternPtr: PChar; + StringRes: PChar; + PatternRes: PChar; +begin + if SubStr = '' then + raise EJclStringError.CreateRes(@RsBlankSearchString); + + Result := SubStr = '*'; + + if Result or (S = '') then + Exit; + + if (Index <= 0) or (Index > Length(S)) then + raise EJclStringError.CreateRes(@RsArgumentOutOfRange); + + StringPtr := PChar(@S[Index]); + PatternPtr := PChar(SubStr); + StringRes := nil; + PatternRes := nil; + + repeat + repeat + case PatternPtr^ of + #0: + begin + Result := StringPtr^ = #0; + if Result or (StringRes = nil) or (PatternRes = nil) then + Exit; + + StringPtr := StringRes; + PatternPtr := PatternRes; + Break; + end; + '*': + begin + Inc(PatternPtr); + PatternRes := PatternPtr; + Break; + end; + '?': + begin + if StringPtr^ = #0 then + Exit; + Inc(StringPtr); + Inc(PatternPtr); + end; + else + begin + if StringPtr^ = #0 then + Exit; + if StringPtr^ <> PatternPtr^ then + begin + if (StringRes = nil) or (PatternRes = nil) then + Exit; + StringPtr := StringRes; + PatternPtr := PatternRes; + Break; + end + else + begin + Inc(StringPtr); + Inc(PatternPtr); + end; + end; + end; + until False; + + repeat + case PatternPtr^ of + #0: + begin + Result := True; + Exit; + end; + '*': + begin + Inc(PatternPtr); + PatternRes := PatternPtr; + end; + '?': + begin + if StringPtr^ = #0 then + Exit; + Inc(StringPtr); + Inc(PatternPtr); + end; + else + begin + repeat + if StringPtr^ = #0 then + Exit; + if StringPtr^ = PatternPtr^ then + Break; + Inc(StringPtr); + until False; + Inc(StringPtr); + StringRes := StringPtr; + Inc(PatternPtr); + Break; + end; + end; + until False; + until False; +end; + +function StrNPos(const S, SubStr: string; N: SizeInt): SizeInt; +var + I, P: SizeInt; +begin + if N < 1 then + begin + Result := 0; + Exit; + end; + + Result := StrSearch(SubStr, S, 1); + I := 1; + while I < N do + begin + P := StrSearch(SubStr, S, Result + 1); + if P = 0 then + begin + Result := 0; + Break; + end + else + begin + Result := P; + Inc(I); + end; + end; +end; + +function StrNIPos(const S, SubStr: string; N: SizeInt): SizeInt; +var + I, P: SizeInt; +begin + if N < 1 then + begin + Result := 0; + Exit; + end; + + Result := StrFind(SubStr, S, 1); + I := 1; + while I < N do + begin + P := StrFind(SubStr, S, Result + 1); + if P = 0 then + begin + Result := 0; + Break; + end + else + begin + Result := P; + Inc(I); + end; + end; +end; + +function StrPrefixIndex(const S: string; const Prefixes: array of string): SizeInt; +var + I: SizeInt; + Test: string; +begin + Result := -1; + for I := Low(Prefixes) to High(Prefixes) do + begin + Test := StrLeft(S, Length(Prefixes[I])); + if CompareStr(Test, Prefixes[I]) = 0 then + begin + Result := I; + Break; + end; + end; +end; + +function StrSearch(const Substr, S: string; const Index: SizeInt): SizeInt; +var + SP, SPI, SubP: PChar; + SLen: SizeInt; +begin + SLen := Length(S); + if Index <= SLen then + begin + SP := PChar(S); + SubP := PChar(Substr); + SPI := SP; + Inc(SPI, Index); + Dec(SPI); + SPI := StrPos(SPI, SubP); + if SPI <> nil then + Result := SPI - SP + 1 + else + Result := 0; + end + else + Result := 0; +end; + +function StrSuffixIndex(const S: string; const Suffixes: array of string): SizeInt; +var + I: SizeInt; + Test: string; +begin + Result := -1; + for I := Low(Suffixes) to High(Suffixes) do + begin + Test := StrRight(S, Length(Suffixes[I])); + if CompareStr(Test, Suffixes[I]) = 0 then + begin + Result := I; + Break; + end; + end; +end; + +//=== String Extraction ====================================================== + +function StrAfter(const SubStr, S: string): string; +var + P: SizeInt; +begin + P := StrFind(SubStr, S, 1); // StrFind is case-insensitive pos + if P <= 0 then + Result := '' // substr not found -> nothing after it + else + Result := StrRestOf(S, P + Length(SubStr)); +end; + +function StrBefore(const SubStr, S: string): string; +var + P: SizeInt; +begin + P := StrFind(SubStr, S, 1); + if P <= 0 then + Result := S + else + Result := StrLeft(S, P - 1); +end; + +function StrSplit(const SubStr, S: string;var Left, Right : string): boolean; +var + P: SizeInt; +begin + P := StrFind(SubStr, S, 1); + Result:= p > 0; + if Result then + begin + Left := StrLeft(S, P - 1); + Right := StrRestOf(S, P + Length(SubStr)); + end + else + begin + Left := ''; + Right := ''; + end; +end; + +function StrBetween(const S: string; const Start, Stop: Char): string; +var + PosStart, PosEnd: SizeInt; + L: SizeInt; +begin + PosStart := Pos(Start, S); + PosEnd := StrSearch(Stop, S, PosStart + 1); // PosEnd has to be after PosStart. + + if (PosStart > 0) and (PosEnd > PosStart) then + begin + L := PosEnd - PosStart; + Result := Copy(S, PosStart + 1, L - 1); + end + else + Result := ''; +end; + +function StrChopRight(const S: string; N: SizeInt): string; +begin + Result := Copy(S, 1, Length(S) - N); +end; + +function StrLeft(const S: string; Count: SizeInt): string; +begin + Result := Copy(S, 1, Count); +end; + +function StrMid(const S: string; Start, Count: SizeInt): string; +begin + Result := Copy(S, Start, Count); +end; + +function StrRestOf(const S: string; N: SizeInt): string; +begin + Result := Copy(S, N, (Length(S) - N + 1)); +end; + +function StrRight(const S: string; Count: SizeInt): string; +begin + Result := Copy(S, Length(S) - Count + 1, Count); +end; + +//=== Character (do we have it ;) ============================================ + +function CharEqualNoCase(const C1, C2: Char): Boolean; +begin + //if they are not equal chars, may be same letter different case + Result := (C1 = C2) or + (CharIsAlpha(C1) and CharIsAlpha(C2) and (CharLower(C1) = CharLower(C2))); +end; + + +function CharIsAlpha(const C: Char): Boolean; +begin + {$IFDEF UNICODE_RTL_DATABASE} + Result := TCharacter.IsLetter(C); + {$ELSE ~UNICODE_RTL_DATABASE} + Result := (StrCharTypes[C] and C1_ALPHA) <> 0; + {$ENDIF ~UNICODE_RTL_DATABASE} +end; + +function CharIsAlphaNum(const C: Char): Boolean; +begin + {$IFDEF UNICODE_RTL_DATABASE} + Result := TCharacter.IsLetterOrDigit(C); + {$ELSE ~UNICODE_RTL_DATABASE} + Result := ((StrCharTypes[C] and C1_ALPHA) <> 0) or ((StrCharTypes[C] and C1_DIGIT) <> 0); + {$ENDIF ~UNICODE_RTL_DATABASE} +end; + +function CharIsBlank(const C: Char): Boolean; +begin + {$IFDEF UNICODE_RTL_DATABASE} + //http://blogs.msdn.com/b/michkap/archive/2007/06/11/3230072.aspx + Result := (C = ' ') or (C = #$0009) or (C = #$00A0) or (C = #$3000); + {$ELSE ~UNICODE_RTL_DATABASE} + Result := ((StrCharTypes[C] and C1_BLANK) <> 0); + {$ENDIF ~UNICODE_RTL_DATABASE} +end; + +function CharIsControl(const C: Char): Boolean; +begin + {$IFDEF UNICODE_RTL_DATABASE} + Result := TCharacter.IsControl(C); + {$ELSE ~UNICODE_RTL_DATABASE} + Result := (StrCharTypes[C] and C1_CNTRL) <> 0; + {$ENDIF ~UNICODE_RTL_DATABASE} +end; + +function CharIsDelete(const C: Char): Boolean; +begin + Result := (C = #8); +end; + +function CharIsDigit(const C: Char): Boolean; +begin + {$IFDEF UNICODE_RTL_DATABASE} + Result := TCharacter.IsDigit(C); + {$ELSE ~UNICODE_RTL_DATABASE} + Result := (StrCharTypes[C] and C1_DIGIT) <> 0; + {$ENDIF ~UNICODE_RTL_DATABASE} +end; + +function CharIsFracDigit(const C: Char): Boolean; +begin + Result := (C = '.') or CharIsDigit(C); +end; + +function CharIsHexDigit(const C: Char): Boolean; +begin + case C of + 'A'..'F', + 'a'..'f': + Result := True; + else + Result := CharIsDigit(C); + end; +end; + +function CharIsLower(const C: Char): Boolean; +begin + {$IFDEF UNICODE_RTL_DATABASE} + Result := TCharacter.IsLower(C); + {$ELSE ~UNICODE_RTL_DATABASE} + Result := (StrCharTypes[C] and C1_LOWER) <> 0; + {$ENDIF ~UNICODE_RTL_DATABASE} +end; + +{$IFNDEF WINSCP} +function CharIsNumberChar(const C: Char): Boolean; +begin + Result := CharIsDigit(C) or (C = '+') or (C = '-') or (C = JclFormatSettings.DecimalSeparator); +end; + +function CharIsNumber(const C: Char): Boolean; +begin + Result := CharIsDigit(C) or (C = JclFormatSettings.DecimalSeparator); +end; +{$ENDIF ~WINSCP} + +function CharIsPrintable(const C: Char): Boolean; +begin + Result := not CharIsControl(C); +end; + +function CharIsPunctuation(const C: Char): Boolean; +begin + {$IFDEF UNICODE_RTL_DATABASE} + Result := TCharacter.IsPunctuation(C); + {$ELSE ~UNICODE_RTL_DATABASE} + Result := ((StrCharTypes[C] and C1_PUNCT) <> 0); + {$ENDIF ~UNICODE_RTL_DATABASE} +end; + +function CharIsReturn(const C: Char): Boolean; +begin + Result := (C = NativeLineFeed) or (C = NativeCarriageReturn); +end; + +function CharIsSpace(const C: Char): Boolean; +begin + {$IFDEF UNICODE_RTL_DATABASE} + Result := TCharacter.IsWhiteSpace(C); + {$ELSE ~UNICODE_RTL_DATABASE} + Result := (StrCharTypes[C] and C1_SPACE) <> 0; + {$ENDIF ~UNICODE_RTL_DATABASE} +end; + +function CharIsUpper(const C: Char): Boolean; +begin + {$IFDEF UNICODE_RTL_DATABASE} + Result := TCharacter.IsUpper(C); + {$ELSE ~UNICODE_RTL_DATABASE} + Result := (StrCharTypes[C] and C1_UPPER) <> 0; + {$ENDIF ~UNICODE_RTL_DATABASE} +end; + +function CharIsValidIdentifierLetter(const C: Char): Boolean; +begin + case C of + {$IFDEF SUPPORTS_UNICODE} + // from XML specifications + #$00C0..#$00D6, #$00D8..#$00F6, #$00F8..#$02FF, #$0370..#$037D, + #$037F..#$1FFF, #$200C..#$200D, #$2070..#$218F, #$2C00..#$2FEF, + #$3001..#$D7FF, #$F900..#$FDCF, #$FDF0..#$FFFD, // #$10000..#$EFFFF, howto match surrogate pairs? + #$00B7, #$0300..#$036F, #$203F..#$2040, + {$ENDIF SUPPORTS_UNICODE} + '0'..'9', 'A'..'Z', 'a'..'z', '_': + Result := True; + else + Result := False; + end; +end; + +function CharIsWhiteSpace(const C: Char): Boolean; +begin + case C of + NativeTab, + NativeLineFeed, + NativeVerticalTab, + NativeFormFeed, + NativeCarriageReturn, + NativeSpace: + Result := True; + else + Result := False; + end; +end; + +function CharIsWildcard(const C: Char): Boolean; +begin + case C of + '*', '?': + Result := True; + else + Result := False; + end; +end; + +function CharType(const C: Char): Word; +begin + {$IFDEF UNICODE_RTL_DATABASE} + GetStringTypeEx(LOCALE_USER_DEFAULT, CT_CTYPE1, @C, 1, Result); + {$ELSE ~UNICODE_RTL_DATABASE} + Result := StrCharTypes[C]; + {$ENDIF ~UNICODE_RTL_DATABASE} +end; + +//=== PCharVector ============================================================ + +function StringsToPCharVector(var Dest: PCharVector; const Source: TStrings): PCharVector; +var + I: SizeInt; + S: string; + List: array of PChar; +begin + Assert(Source <> nil); + Dest := AllocMem((Source.Count + SizeOf(Char)) * SizeOf(PChar)); + SetLength(List, Source.Count + SizeOf(Char)); + for I := 0 to Source.Count - 1 do + begin + S := Source[I]; + List[I] := StrAlloc(Length(S) + SizeOf(Char)); + StrPCopy(List[I], S); + end; + List[Source.Count] := nil; + Move(List[0], Dest^, (Source.Count + 1) * SizeOf(PChar)); + Result := Dest; +end; + +function PCharVectorCount(Source: PCharVector): SizeInt; +begin + Result := 0; + if Source <> nil then + begin + while Source^ <> nil do + begin + Inc(Source); + Inc(Result); + end; + end; +end; + +procedure PCharVectorToStrings(const Dest: TStrings; Source: PCharVector); +var + I, Count: SizeInt; + List: array of PChar; +begin + Assert(Dest <> nil); + if Source <> nil then + begin + Count := PCharVectorCount(Source); + SetLength(List, Count); + Move(Source^, List[0], Count * SizeOf(PChar)); + Dest.BeginUpdate; + try + Dest.Clear; + for I := 0 to Count - 1 do + Dest.Add(List[I]); + finally + Dest.EndUpdate; + end; + end; +end; + +procedure FreePCharVector(var Dest: PCharVector); +var + I, Count: SizeInt; + List: array of PChar; +begin + if Dest <> nil then + begin + Count := PCharVectorCount(Dest); + SetLength(List, Count); + Move(Dest^, List[0], Count * SizeOf(PChar)); + for I := 0 to Count - 1 do + StrDispose(List[I]); + FreeMem(Dest, (Count + 1) * SizeOf(PChar)); + Dest := nil; + end; +end; + +//=== Character Transformation Routines ====================================== + +function CharHex(const C: Char): Byte; +begin + case C of + '0'..'9': + Result := Ord(C) - Ord('0'); + 'a'..'f': + Result := Ord(C) - Ord('a') + 10; + 'A'..'F': + Result := Ord(C) - Ord('A') + 10; + else + Result := $FF; + end; +end; + +function CharLower(const C: Char): Char; +begin + {$IFDEF UNICODE_RTL_DATABASE} + Result := TCharacter.ToLower(C); + {$ELSE ~UNICODE_RTL_DATABASE} + Result := StrCaseMap[Ord(C) + StrLoOffset]; + {$ENDIF ~UNICODE_RTL_DATABASE} +end; + +function CharToggleCase(const C: Char): Char; +begin + {$IFDEF UNICODE_RTL_DATABASE} + if CharIsLower(C) then + Result := CharUpper(C) + else if CharIsUpper(C) then + Result := CharLower(C) + else + Result := C; + {$ELSE ~UNICODE_RTL_DATABASE} + Result := StrCaseMap[Ord(C) + StrReOffset]; + {$ENDIF ~UNICODE_RTL_DATABASE} +end; + +function CharUpper(const C: Char): Char; +begin + {$IFDEF UNICODE_RTL_DATABASE} + Result := TCharacter.ToUpper(C); + {$ELSE ~UNICODE_RTL_DATABASE} + Result := StrCaseMap[Ord(C) + StrUpOffset]; + {$ENDIF ~UNICODE_RTL_DATABASE} +end; + +//=== Character Search and Replace =========================================== + +function CharLastPos(const S: string; const C: Char; const Index: SizeInt): SizeInt; +begin + if (Index > 0) and (Index <= Length(S)) then + begin + for Result := Length(S) downto Index do + if S[Result] = C then + Exit; + end; + Result := 0; +end; + +function CharPos(const S: string; const C: Char; const Index: SizeInt): SizeInt; +begin + if (Index > 0) and (Index <= Length(S)) then + begin + for Result := Index to Length(S) do + if S[Result] = C then + Exit; + end; + Result := 0; +end; + +function CharIPos(const S: string; C: Char; const Index: SizeInt): SizeInt; +begin + if (Index > 0) and (Index <= Length(S)) then + begin + C := CharUpper(C); + for Result := Index to Length(S) do + if CharUpper(S[Result]) = C then + Exit; + end; + Result := 0; +end; + +function CharReplace(var S: string; const Search, Replace: Char): SizeInt; +var + P: PChar; + Index, Len: SizeInt; +begin + Result := 0; + if Search <> Replace then + begin + UniqueString(S); + P := PChar(S); + Len := Length(S); + for Index := 0 to Len - 1 do + begin + if P^ = Search then + begin + P^ := Replace; + Inc(Result); + end; + Inc(P); + end; + end; +end; + +{$IFNDEF WINSCP} +//=== MultiSz ================================================================ + +function StringsToMultiSz(var Dest: PMultiSz; const Source: TStrings): PMultiSz; +var + I, TotalLength: SizeInt; + P: PMultiSz; +begin + Assert(Source <> nil); + TotalLength := 1; + for I := 0 to Source.Count - 1 do + if Source[I] = '' then + raise EJclStringError.CreateRes(@RsInvalidEmptyStringItem) + else + Inc(TotalLength, StrLen(PChar(Source[I])) + 1); + AllocateMultiSz(Dest, TotalLength); + P := Dest; + for I := 0 to Source.Count - 1 do + begin + P := StrECopy(P, PChar(Source[I])); + Inc(P); + end; + P^ := #0; + Result := Dest; +end; + +procedure MultiSzToStrings(const Dest: TStrings; const Source: PMultiSz); +var + P: PMultiSz; +begin + Assert(Dest <> nil); + Dest.BeginUpdate; + try + Dest.Clear; + if Source <> nil then + begin + P := Source; + while P^ <> #0 do + begin + Dest.Add(P); + P := StrEnd(P); + Inc(P); + end; + end; + finally + Dest.EndUpdate; + end; +end; + +function MultiSzLength(const Source: PMultiSz): SizeInt; +var + P: PMultiSz; +begin + Result := 0; + if Source <> nil then + begin + P := Source; + repeat + Inc(Result, StrLen(P) + 1); + P := StrEnd(P); + Inc(P); + until P^ = #0; + Inc(Result); + end; +end; + +procedure AllocateMultiSz(var Dest: PMultiSz; Len: SizeInt); +begin + if Len > 0 then + GetMem(Dest, Len * SizeOf(Char)) + else + Dest := nil; +end; + +procedure FreeMultiSz(var Dest: PMultiSz); +begin + if Dest <> nil then + FreeMem(Dest); + Dest := nil; +end; + +function MultiSzDup(const Source: PMultiSz): PMultiSz; +var + Len: SizeInt; +begin + if Source <> nil then + begin + Len := MultiSzLength(Source); + Result := nil; + AllocateMultiSz(Result, Len); + Move(Source^, Result^, Len * SizeOf(Char)); + end + else + Result := nil; +end; + +function AnsiStringsToAnsiMultiSz(var Dest: PAnsiMultiSz; const Source: TAnsiStrings): PAnsiMultiSz; +begin + Result := JclAnsiStrings.StringsToMultiSz(Dest, Source); +end; + +procedure AnsiMultiSzToAnsiStrings(const Dest: TAnsiStrings; const Source: PAnsiMultiSz); +begin + JclAnsiStrings.MultiSzToStrings(Dest, Source); +end; + +function AnsiMultiSzLength(const Source: PAnsiMultiSz): SizeInt; +begin + Result := JclAnsiStrings.MultiSzLength(Source); +end; + +procedure AllocateAnsiMultiSz(var Dest: PAnsiMultiSz; Len: SizeInt); +begin + JclAnsiStrings.AllocateMultiSz(Dest, Len); +end; + +procedure FreeAnsiMultiSz(var Dest: PAnsiMultiSz); +begin + JclAnsiStrings.FreeMultiSz(Dest); +end; + +function AnsiMultiSzDup(const Source: PAnsiMultiSz): PAnsiMultiSz; +begin + Result := JclAnsiStrings.MultiSzDup(Source); +end; + +function WideStringsToWideMultiSz(var Dest: PWideMultiSz; const Source: TWideStrings): PWideMultiSz; +begin + Result := JclWideStrings.StringsToMultiSz(Dest, Source); +end; + +procedure WideMultiSzToWideStrings(const Dest: TWideStrings; const Source: PWideMultiSz); +begin + JclWideStrings.MultiSzToStrings(Dest, Source); +end; + +function WideMultiSzLength(const Source: PWideMultiSz): SizeInt; +begin + Result := JclWideStrings.MultiSzLength(Source); +end; + +procedure AllocateWideMultiSz(var Dest: PWideMultiSz; Len: SizeInt); +begin + JclWideStrings.AllocateMultiSz(Dest, Len); +end; + +procedure FreeWideMultiSz(var Dest: PWideMultiSz); +begin + JclWideStrings.FreeMultiSz(Dest); +end; + +function WideMultiSzDup(const Source: PWideMultiSz): PWideMultiSz; +begin + Result := JclWideStrings.MultiSzDup(Source); +end; + +{$ENDIF ~WINSCP} + +//=== TStrings Manipulation ================================================== + +procedure StrToStrings(S, Sep: string; const List: TStrings; const AllowEmptyString: Boolean = True); +var + I, L: SizeInt; + Left: string; +begin + Assert(List <> nil); + List.BeginUpdate; + try + List.Clear; + L := Length(Sep); + I := Pos(Sep, S); + while I > 0 do + begin + Left := StrLeft(S, I - 1); + if (Left <> '') or AllowEmptyString then + List.Add(Left); + Delete(S, 1, I + L - 1); + I := Pos(Sep, S); + end; + if (S <> '') or AllowEmptyString then + List.Add(S); // Ignore empty strings at the end (only if AllowEmptyString = False). + finally + List.EndUpdate; + end; +end; + +procedure StrIToStrings(S, Sep: string; const List: TStrings; const AllowEmptyString: Boolean = True); +var + I, L: SizeInt; + LowerCaseStr: string; + Left: string; +begin + Assert(List <> nil); + LowerCaseStr := StrLower(S); + Sep := StrLower(Sep); + L := Length(Sep); + I := Pos(Sep, LowerCaseStr); + List.BeginUpdate; + try + List.Clear; + while I > 0 do + begin + Left := StrLeft(S, I - 1); + if (Left <> '') or AllowEmptyString then + List.Add(Left); + Delete(S, 1, I + L - 1); + Delete(LowerCaseStr, 1, I + L - 1); + I := Pos(Sep, LowerCaseStr); + end; + if (S <> '') or AllowEmptyString then + List.Add(S); // Ignore empty strings at the end (only if AllowEmptyString = False). + finally + List.EndUpdate; + end; +end; + +function StringsToStr(const List: TStrings; const Sep: string; const AllowEmptyString: Boolean = True): string; +var + I, L: SizeInt; +begin + Result := ''; + for I := 0 to List.Count - 1 do + begin + if (List[I] <> '') or AllowEmptyString then + begin + // don't combine these into one addition, somehow it hurts performance + Result := Result + List[I]; + Result := Result + Sep; + end; + end; + // remove terminating separator + if List.Count > 0 then + begin + L := Length(Sep); + Delete(Result, Length(Result) - L + 1, L); + end; +end; + +function StringsToStr(const List: TStrings; const Sep: string; const NumberOfItems: SizeInt; const AllowEmptyString: + Boolean = True): string; +var + I, L, N: SizeInt; +begin + Result := ''; + if List.Count > NumberOfItems then + N := NumberOfItems + else + N := List.Count; + for I := 0 to N - 1 do + begin + if (List[I] <> '') or AllowEmptyString then + begin + // don't combine these into one addition, somehow it hurts performance + Result := Result + List[I]; + Result := Result + Sep; + end; + end; + // remove terminating separator + if N > 0 then + begin + L := Length(Sep); + Delete(Result, Length(Result) - L + 1, L); + end; +end; + +procedure TrimStrings(const List: TStrings; DeleteIfEmpty: Boolean); +var + I: SizeInt; +begin + Assert(List <> nil); + List.BeginUpdate; + try + for I := List.Count - 1 downto 0 do + begin + List[I] := Trim(List[I]); + if (List[I] = '') and DeleteIfEmpty then + List.Delete(I); + end; + finally + List.EndUpdate; + end; +end; + +procedure TrimStringsRight(const List: TStrings; DeleteIfEmpty: Boolean); +var + I: SizeInt; +begin + Assert(List <> nil); + List.BeginUpdate; + try + for I := List.Count - 1 downto 0 do + begin + List[I] := TrimRight(List[I]); + if (List[I] = '') and DeleteIfEmpty then + List.Delete(I); + end; + finally + List.EndUpdate; + end; +end; + +procedure TrimStringsLeft(const List: TStrings; DeleteIfEmpty: Boolean); +var + I: SizeInt; +begin + Assert(List <> nil); + List.BeginUpdate; + try + for I := List.Count - 1 downto 0 do + begin + List[I] := TrimLeft(List[I]); + if (List[I] = '') and DeleteIfEmpty then + List.Delete(I); + end; + finally + List.EndUpdate; + end; +end; + +function AddStringToStrings(const S: string; Strings: TStrings; const Unique: Boolean): Boolean; +begin + Assert(Strings <> nil); + Result := Unique and (Strings.IndexOf(S) <> -1); + if not Result then + Result := Strings.Add(S) > -1; +end; + +//=== Miscellaneous ========================================================== + +function FileToString(const FileName: string): {$IFDEF COMPILER12_UP}RawByteString{$ELSE}AnsiString{$ENDIF}; +var + fs: TFileStream; + Len: SizeInt; +begin + fs := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite); + try + Len := fs.Size; + SetLength(Result, Len); + if Len > 0 then + fs.ReadBuffer(Result[1], Len); + finally + fs.Free; + end; +end; + +procedure StringToFile(const FileName: string; const Contents: {$IFDEF COMPILER12_UP}RawByteString{$ELSE}AnsiString{$ENDIF}; + Append: Boolean); +var + FS: TFileStream; + Len: SizeInt; +begin + if Append and FileExists(filename) then + FS := TFileStream.Create(FileName, fmOpenReadWrite or fmShareDenyWrite) + else + FS := TFileStream.Create(FileName, fmCreate); + try + if Append then + FS.Seek(0, soEnd); // faster than .Position := .Size + Len := Length(Contents); + if Len > 0 then + FS.WriteBuffer(Contents[1], Len); + finally + FS.Free; + end; +end; + +function StrToken(var S: string; Separator: Char): string; +var + I: SizeInt; +begin + I := Pos(Separator, S); + if I <> 0 then + begin + Result := Copy(S, 1, I - 1); + Delete(S, 1, I); + end + else + begin + Result := S; + S := ''; + end; +end; + +procedure StrTokens(const S: string; const List: TStrings); +var + Start: PChar; + Token: string; + Done: Boolean; +begin + Assert(List <> nil); + if List = nil then + Exit; + + List.BeginUpdate; + try + List.Clear; + Start := Pointer(S); + repeat + Done := JclStrings.StrWord(Start, Token); + if Token <> '' then + List.Add(Token); + until Done; + finally + List.EndUpdate; + end; +end; + +function StrWord(const S: string; var Index: SizeInt; out Word: string): Boolean; +var + Start: SizeInt; + C: Char; +begin + Word := ''; + if (S = '') then + begin + Result := True; + Exit; + end; + Start := Index; + Result := False; + while True do + begin + C := S[Index]; + case C of + #0: + begin + if Start <> 0 then + Word := Copy(S, Start, Index - Start); + Result := True; + Exit; + end; + NativeSpace, NativeLineFeed, NativeCarriageReturn: + begin + if Start <> 0 then + begin + Word := Copy(S, Start, Index - Start); + Exit; + end + else + begin + while CharIsWhiteSpace(C) do + begin + Inc(Index); + C := S[Index]; + end; + end; + end; + else + if Start = 0 then + Start := Index; + Inc(Index); + end; + end; +end; + +function StrWord(var S: PChar; out Word: string): Boolean; +var + Start: PChar; +begin + Word := ''; + if S = nil then + begin + Result := True; + Exit; + end; + Start := nil; + Result := False; + while True do + begin + case S^ of + #0: + begin + if Start <> nil then + SetString(Word, Start, S - Start); + Result := True; + Exit; + end; + NativeSpace, NativeLineFeed, NativeCarriageReturn: + begin + if Start <> nil then + begin + SetString(Word, Start, S - Start); + Exit; + end + else + while CharIsWhiteSpace(S^) do + Inc(S); + end; + else + if Start = nil then + Start := S; + Inc(S); + end; + end; +end; + +function StrIdent(const S: string; var Index: SizeInt; out Ident: string): Boolean; +var + Start: SizeInt; + C: Char; +begin + Ident := ''; + if (S = '') then + begin + Result := True; + Exit; + end; + Start := Index; + Result := False; + while True do + begin + C := S[Index]; + if CharIsValidIdentifierLetter(C) then + begin + if Start = 0 then + Start := Index; + end + else + if C = #0 then + begin + if Start <> 0 then + Ident := Copy(S, Start, Index - Start); + Result := True; + Exit; + end + else + begin + if Start <> 0 then + begin + Ident := Copy(S, Start, Index - Start); + Exit; + end; + end; + Inc(Index); + end; +end; + +function StrIdent(var S: PChar; out Ident: string): Boolean; +var + Start: PChar; + C: Char; +begin + Ident := ''; + if S = nil then + begin + Result := True; + Exit; + end; + Start := nil; + Result := False; + while True do + begin + C := S^; + if CharIsValidIdentifierLetter(C) then + begin + if Start = nil then + Start := S; + end + else + if C = #0 then + begin + if Start <> nil then + SetString(Ident, Start, S - Start); + Result := True; + Exit; + end + else + begin + if Start <> nil then + begin + SetString(Ident, Start, S - Start); + Exit; + end + end; + Inc(S); + end; +end; + +procedure StrTokenToStrings(S: string; Separator: Char; const List: TStrings); +var + Token: string; +begin + Assert(List <> nil); + + if List = nil then + Exit; + + List.BeginUpdate; + try + List.Clear; + while S <> '' do + begin + Token := StrToken(S, Separator); + List.Add(Token); + end; + finally + List.EndUpdate; + end; +end; + +{$IFNDEF WINSCP} +function StrToFloatSafe(const S: string): Float; +var + Temp: string; + I, J, K: SizeInt; + SwapSeparators, IsNegative: Boolean; + DecSep, ThouSep, C: Char; +begin + DecSep := {$IFDEF RTL220_UP}FormatSettings.{$ENDIF}DecimalSeparator; + ThouSep := {$IFDEF RTL220_UP}FormatSettings.{$ENDIF}ThousandSeparator; + Temp := S; + SwapSeparators := False; + + IsNegative := False; + J := 0; + for I := 1 to Length(Temp) do + begin + C := Temp[I]; + if C = '-' then + IsNegative := not IsNegative + else + if (C <> ' ') and (C <> '(') and (C <> '+') then + begin + // if it appears prior to any digit, it has to be a decimal separator + SwapSeparators := Temp[I] = ThouSep; + J := I; + Break; + end; + end; + + if not SwapSeparators then + begin + K := CharPos(Temp, DecSep); + SwapSeparators := + // if it appears prior to any digit, it has to be a decimal separator + (K > J) and + // if it appears multiple times, it has to be a thousand separator + ((StrCharCount(Temp, DecSep) > 1) or + // we assume (consistent with Windows Platform SDK documentation), + // that thousand separators appear only to the left of the decimal + (K < CharPos(Temp, ThouSep))); + end; + + if SwapSeparators then + begin + // assume a numerical string from a different locale, + // where DecimalSeparator and ThousandSeparator are exchanged + for I := 1 to Length(Temp) do + if Temp[I] = DecSep then + Temp[I] := ThouSep + else + if Temp[I] = ThouSep then + Temp[I] := DecSep; + end; + + Temp := StrKeepChars(Temp, CharIsNumber); + + if Length(Temp) > 0 then + begin + if Temp[1] = DecSep then + Temp := '0' + Temp; + if Temp[Length(Temp)] = DecSep then + Temp := Temp + '0'; + Result := StrToFloat(Temp); + if IsNegative then + Result := -Result; + end + else + Result := 0.0; +end; + +function StrToIntSafe(const S: string): Integer; +begin + Result := Trunc(StrToFloatSafe(S)); +end; +{$ENDIF ~WINSCP} + +procedure StrNormIndex(const StrLen: SizeInt; var Index: SizeInt; var Count: SizeInt); overload; +begin + Index := Max(1, Min(Index, StrLen + 1)); + Count := Max(0, Min(Count, StrLen + 1 - Index)); +end; + +function ArrayOf(List: TStrings): TDynStringArray; +var + I: SizeInt; +begin + if List <> nil then + begin + SetLength(Result, List.Count); + for I := 0 to List.Count - 1 do + Result[I] := List[I]; + end + else + Result := nil; +end; + +const + BoolToStr: array [Boolean] of string = ('false', 'true'); + +type + TInterfacedObjectAccess = class(TInterfacedObject); + +procedure MoveChar(const Source; var Dest; Count: SizeInt); +begin + if Count > 0 then + Move(Source, Dest, Count * SizeOf(Char)); +end; + +function DotNetFormat(const Fmt: string; const Arg0: Variant): string; +begin + Result := DotNetFormat(Fmt, [Arg0]); +end; + +function DotNetFormat(const Fmt: string; const Arg0, Arg1: Variant): string; +begin + Result := DotNetFormat(Fmt, [Arg0, Arg1]); +end; + +function DotNetFormat(const Fmt: string; const Arg0, Arg1, Arg2: Variant): string; +begin + Result := DotNetFormat(Fmt, [Arg0, Arg1, Arg2]); +end; + +function DotNetFormat(const Fmt: string; const Args: array of const): string; +var + F, P: PChar; + Len, Capacity, Count: SizeInt; + Index: SizeInt; + ErrorCode: Integer; + S: string; + + procedure Grow(Count: SizeInt); + begin + if Len + Count > Capacity then + begin + Capacity := Capacity * 5 div 3 + Count; + SetLength(Result, Capacity); + end; + end; + + function InheritsFrom(AClass: TClass; const ClassName: string): Boolean; + begin + Result := True; + while AClass <> nil do + begin + if CompareText(AClass.ClassName, ClassName) = 0 then + Exit; + AClass := AClass.ClassParent; + end; + Result := False; + end; + + function GetStringOf(const V: TVarData; Index: SizeInt): string; overload; + begin + case V.VType of + varEmpty, varNull: + raise ArgumentNullException.CreateRes(@RsArgumentIsNull); + varSmallInt: + Result := IntToStr(V.VSmallInt); + varInteger: + Result := IntToStr(V.VInteger); + varSingle: + Result := FloatToStr(V.VSingle); + varDouble: + Result := FloatToStr(V.VDouble); + varCurrency: + Result := CurrToStr(V.VCurrency); + varDate: + Result := DateTimeToStr(V.VDate); + varOleStr: + Result := V.VOleStr; + varBoolean: + Result := BoolToStr[V.VBoolean <> False]; + varByte: + Result := IntToStr(V.VByte); + varWord: + Result := IntToStr(V.VWord); + varShortInt: + Result := IntToStr(V.VShortInt); + varLongWord: + Result := IntToStr(V.VLongWord); + varInt64: + Result := IntToStr(V.VInt64); + varString: + Result := string(V.VString); + {$IFDEF SUPPORTS_UNICODE_STRING} + varUString: + Result := string(V.VUString); + {$ENDIF SUPPORTS_UNICODE_STRING} + {varArray, + varDispatch, + varError, + varUnknown, + varAny, + varByRef:} + else + raise ArgumentNullException.CreateResFmt(@RsDotNetFormatArgumentNotSupported, [Index]); + end; + end; + + function GetStringOf(Index: SizeInt): string; overload; + var + V: TVarRec; + Intf: IToString; + begin + V := Args[Index]; + if (V.VInteger = 0) and + (V.VType in [vtExtended, vtString, vtObject, vtClass, vtCurrency, + vtInterface, vtInt64]) then + raise ArgumentNullException.CreateResFmt(@RsArgumentIsNull, [Index]); + + case V.VType of + vtInteger: + Result := IntToStr(V.VInteger); + vtBoolean: + Result := BoolToStr[V.VBoolean]; + vtChar: + Result := string(AnsiString(V.VChar)); + vtExtended: + Result := FloatToStr(V.VExtended^); + vtString: + Result := string(V.VString^); + vtPointer: + Result := IntToHex(TJclAddr(V.VPointer), 8); + vtPChar: + Result := string(AnsiString(V.VPChar)); + vtObject: + if (V.VObject is TInterfacedObject) and V.VObject.GetInterface(IToString, Intf) then + begin + Result := Intf.ToString; + Pointer(Intf) := nil; // do not release the object + // undo the RefCount change + Dec(TInterfacedObjectAccess(V.VObject).FRefCount); + end + else + if ((V.VObject is TComponent) or (V.VObject is TInterfacedPersistent)) and V.VObject.GetInterface(IToString, Intf) then + Result := Intf.ToString + {$IFDEF RTL200_UP} + else + Result := V.VObject.ToString; + {$ELSE} + else + raise ArgumentNullException.CreateResFmt(@RsDotNetFormatObjectArgumentNotSupported, [V.VObject.ClassName, Index]); + {$ENDIF RTL200_UP} + vtClass: + Result := V.VClass.ClassName; + vtWideChar: + Result := V.VWideChar; + vtPWideChar: + Result := V.VPWideChar; + vtAnsiString: + Result := string(V.VAnsiString); + vtCurrency: + Result := CurrToStr(V.VCurrency^); + vtVariant: + Result := GetStringOf(TVarData(V.VVariant^), Index); + vtInterface: + if IInterface(V.VInterface).QueryInterface(IToString, Intf) = 0 then + Result := IToString(Intf).ToString + else + raise ArgumentNullException.CreateResFmt(@RsDotNetFormatArgumentNotSupported, [Index]); + vtWideString: + Result := WideString(V.VWideString); + vtInt64: + Result := IntToStr(V.VInt64^); + {$IFDEF SUPPORTS_UNICODE_STRING} + vtUnicodeString: + Result := UnicodeString(V.VUnicodeString); + {$ENDIF SUPPORTS_UNICODE_STRING} + else + raise ArgumentNullException.CreateResFmt(@RsDotNetFormatArgumentNotSupported, [Index]); + end; + end; + +begin + if Length(Args) = 0 then + begin + Result := Fmt; + Exit; + end; + Len := 0; + Capacity := Length(Fmt); + SetLength(Result, Capacity); + if Capacity = 0 then + raise ArgumentNullException.CreateRes(@RsDotNetFormatNullFormat); + + P := Pointer(Fmt); + F := P; + while True do + begin + if (P[0] = #0) or (P[0] = '{') then + begin + Count := P - F; + Inc(P); + if (P[-1] <> #0) and (P[0] = '{') then + Inc(Count); // include '{' + + if Count > 0 then + begin + Grow(Count); + MoveChar(F[0], Result[Len + 1], Count); + Inc(Len, Count); + end; + + if P[-1] = #0 then + Break; + + if P[0] <> '{' then + begin + F := P; + Inc(P); + while (P[0] <> #0) and (P[0] <> '}') do + Inc(P); + SetString(S, F, P - F); + Val(S, Index, ErrorCode); + if ErrorCode <> 0 then + raise FormatException.CreateRes(@RsFormatException); + if (Index < 0) or (Index > High(Args)) then + raise FormatException.CreateRes(@RsFormatException); + S := GetStringOf(Index); + if S <> '' then + begin + Grow(Length(S)); + MoveChar(S[1], Result[Len + 1], Length(S)); + Inc(Len, Length(S)); + end; + + if P[0] = #0 then + Break; + end; + F := P + 1; + end + else + if (P[0] = '}') and (P[1] = '}') then + begin + Count := P - F + 1; + Inc(P); // skip next '}' + + Grow(Count); + MoveChar(F[0], Result[Len + 1], Count); + Inc(Len, Count); + F := P + 1; + end; + + Inc(P); + end; + + SetLength(Result, Len); +end; + +//=== { TJclStringBuilder } ===================================================== + +constructor TJclStringBuilder.Create(Capacity: SizeInt; MaxCapacity: SizeInt); +begin + inherited Create; + SetLength(FChars, Capacity); + FMaxCapacity := MaxCapacity; +end; + +constructor TJclStringBuilder.Create(const Value: string; Capacity: SizeInt); +begin + Create(Capacity); + Append(Value); +end; + +constructor TJclStringBuilder.Create(const Value: string; StartIndex, Length, Capacity: SizeInt); +begin + Create(Capacity); + Append(Value, StartIndex + 1, Length); +end; + +function TJclStringBuilder.ToString: string; +begin + if FLength > 0 then + SetString(Result, PChar(@FChars[0]), FLength) + else + Result := ''; +end; + +function TJclStringBuilder.EnsureCapacity(Capacity: SizeInt): SizeInt; +begin + if System.Length(FChars) < Capacity then + SetCapacity(Capacity); + Result := System.Length(FChars); +end; + +procedure TJclStringBuilder.Clear; +begin + Length := 0; +end; + +procedure TJclStringBuilder.SetCapacity(const Value: SizeInt); +begin + if Value <> System.Length(FChars) then + begin + SetLength(FChars, Value); + if Value < FLength then + FLength := Value; + end; +end; + +function TJclStringBuilder.GetChars(Index: SizeInt): Char; +begin + Result := FChars[Index]; +end; + +procedure TJclStringBuilder.SetChars(Index: SizeInt; const Value: Char); +begin + FChars[Index] := Value; +end; + +procedure TJclStringBuilder.Set_Length(const Value: SizeInt); +begin + FLength := Value; +end; + +function TJclStringBuilder.GetCapacity: SizeInt; +begin + Result := System.Length(FChars); +end; + +function TJclStringBuilder.AppendPChar(Value: PChar; Count: SizeInt; RepeatCount: SizeInt): TJclStringBuilder; +var + Capacity: SizeInt; +begin + if (Count > 0) and (RepeatCount > 0) then + begin + repeat + Capacity := System.Length(FChars); + if Capacity + Count > MaxCapacity then + raise ArgumentOutOfRangeException.CreateRes(@RsArgumentOutOfRange); + if Capacity < FLength + Count then + SetLength(FChars, Capacity * 5 div 3 + Count); + if Count = 1 then + FChars[FLength] := Value[0] + else + MoveChar(Value[0], FChars[FLength], Count); + Inc(FLength, Count); + Dec(RepeatCount); + until RepeatCount <= 0; + end; + Result := Self; +end; + +function TJclStringBuilder.InsertPChar(Index: SizeInt; Value: PChar; Count, + RepeatCount: SizeInt): TJclStringBuilder; +var + Capacity: SizeInt; +begin + if (Index < 0) or (Index > FLength) then + raise ArgumentOutOfRangeException.CreateRes(@RsArgumentOutOfRange); + + if Index = FLength then + AppendPChar(Value, Count, RepeatCount) + else + if (Count > 0) and (RepeatCount > 0) then + begin + repeat + Capacity := System.Length(FChars); + if Capacity + Count > MaxCapacity then + raise ArgumentOutOfRangeException.CreateRes(@RsArgumentOutOfRange); + if Capacity < FLength + Count then + SetLength(FChars, Capacity * 5 div 3 + Count); + MoveChar(FChars[Index], FChars[Index + Count], FLength - Index); + if Count = 1 then + FChars[Index] := Value[0] + else + MoveChar(Value[0], FChars[Index], Count); + Inc(FLength, Count); + + Dec(RepeatCount); + + Inc(Index, Count); // little optimization + until RepeatCount <= 0; + end; + Result := Self; +end; + +function TJclStringBuilder.Append(const Value: array of Char): TJclStringBuilder; +var + Len: SizeInt; +begin + Len := System.Length(Value); + if Len > 0 then + AppendPChar(@Value[0], Len); + Result := Self; +end; + +function TJclStringBuilder.Append(const Value: array of Char; StartIndex, Length: SizeInt): TJclStringBuilder; +var + Len: SizeInt; +begin + Len := System.Length(Value); + if (Length > 0) and (StartIndex < Len) then + begin + if StartIndex + Length > Len then + Length := Len - StartIndex; + AppendPChar(PChar(@Value[0]) + StartIndex, Length); + end; + Result := Self; +end; + +function TJclStringBuilder.Append(Value: Char; RepeatCount: SizeInt = 1): TJclStringBuilder; +begin + Result := AppendPChar(@Value, 1, RepeatCount); +end; + +function TJclStringBuilder.Append(const Value: string): TJclStringBuilder; +var + Len: SizeInt; +begin + Len := System.Length(Value); + if Len > 0 then + AppendPChar(Pointer(Value), Len); + Result := Self; +end; + +function TJclStringBuilder.Append(const Value: string; StartIndex, Length: SizeInt): TJclStringBuilder; +var + Len: SizeInt; +begin + Len := System.Length(Value); + if (Length > 0) and (StartIndex < Len) then + begin + if StartIndex + Length > Len then + Length := Len - StartIndex; + AppendPChar(PChar(Pointer(Value)) + StartIndex, Length); + end; + Result := Self; +end; + +function TJclStringBuilder.Append(Value: Boolean): TJclStringBuilder; +begin + Result := Append(BoolToStr[Value]); +end; + +function TJclStringBuilder.Append(Value: Cardinal): TJclStringBuilder; +begin + Result := Append(IntToStr(Value)); +end; + +function TJclStringBuilder.Append(Value: Integer): TJclStringBuilder; +begin + Result := Append(IntToStr(Value)); +end; + +function TJclStringBuilder.Append(Value: Double): TJclStringBuilder; +begin + Result := Append(FloatToStr(Value)); +end; + +function TJclStringBuilder.Append(Value: Int64): TJclStringBuilder; +begin + Result := Append(IntToStr(Value)); +end; + +function TJclStringBuilder.Append(Obj: TObject): TJclStringBuilder; +begin + Result := Append(DotNetFormat('{0}', [Obj])); +end; + +function TJclStringBuilder.AppendFormat(const Fmt: string; Arg0: Variant): TJclStringBuilder; +begin + Result := Append(DotNetFormat(Fmt, [Arg0])); +end; + +function TJclStringBuilder.AppendFormat(const Fmt: string; Arg0, Arg1: Variant): TJclStringBuilder; +begin + Result := Append(DotNetFormat(Fmt, [Arg0, Arg1])); +end; + +function TJclStringBuilder.AppendFormat(const Fmt: string; Arg0, Arg1, Arg2: Variant): TJclStringBuilder; +begin + Result := Append(DotNetFormat(Fmt, [Arg0, Arg1, Arg2])); +end; + +function TJclStringBuilder.AppendFormat(const Fmt: string; const Args: array of const): TJclStringBuilder; +begin + Result := Append(DotNetFormat(Fmt, Args)); +end; + +function TJclStringBuilder.Insert(Index: SizeInt; const Value: array of Char): TJclStringBuilder; +var + Len: SizeInt; +begin + Len := System.Length(Value); + if Len > 0 then + InsertPChar(Index, @Value[0], Len); + Result := Self; +end; + +function TJclStringBuilder.Insert(Index: SizeInt; const Value: string; Count: SizeInt): TJclStringBuilder; +var + Len: SizeInt; +begin + Len := System.Length(Value); + if Len > 0 then + InsertPChar(Index, Pointer(Value), Len, Count); + Result := Self; +end; + +function TJclStringBuilder.Insert(Index: SizeInt; Value: Boolean): TJclStringBuilder; +begin + Result := Insert(Index, BoolToStr[Value]); +end; + +function TJclStringBuilder.Insert(Index: SizeInt; const Value: array of Char; + StartIndex, Length: SizeInt): TJclStringBuilder; +var + Len: SizeInt; +begin + Len := System.Length(Value); + if (Length > 0) and (StartIndex < Len) then + begin + if StartIndex + Length > Len then + Length := Len - StartIndex; + InsertPChar(Index, PChar(@Value[0]) + StartIndex, Length); + end; + Result := Self; +end; + +function TJclStringBuilder.Insert(Index: SizeInt; Value: Double): TJclStringBuilder; +begin + Result := Insert(Index, FloatToStr(Value)); +end; + +function TJclStringBuilder.Insert(Index: SizeInt; Value: Int64): TJclStringBuilder; +begin + Result := Insert(Index, IntToStr(Value)); +end; + +function TJclStringBuilder.Insert(Index: SizeInt; Value: Cardinal): TJclStringBuilder; +begin + Result := Insert(Index, IntToStr(Value)); +end; + +function TJclStringBuilder.Insert(Index: SizeInt; Value: Integer): TJclStringBuilder; +begin + Result := Insert(Index, IntToStr(Value)); +end; + +function TJclStringBuilder.Insert(Index: SizeInt; Obj: TObject): TJclStringBuilder; +begin + Result := Insert(Index, DotNetFormat('{0}', [Obj])); +end; + +function TJclStringBuilder.Remove(StartIndex, Length: SizeInt): TJclStringBuilder; +begin + if (StartIndex < 0) or (Length < 0) or (StartIndex + Length >= FLength) then + raise ArgumentOutOfRangeException.CreateRes(@RsArgumentOutOfRange); + if Length > 0 then + begin + MoveChar(FChars[StartIndex + Length], FChars[StartIndex], FLength - (StartIndex + Length)); + Dec(FLength, Length); + end; + Result := Self; +end; + +function TJclStringBuilder.Replace(OldChar, NewChar: Char; StartIndex, + Count: SizeInt): TJclStringBuilder; +var + I: SizeInt; +begin + if Count = -1 then + Count := FLength; + if (StartIndex < 0) or (Count < 0) or (StartIndex + Count > FLength) then + raise ArgumentOutOfRangeException.CreateRes(@RsArgumentOutOfRange); + if (Count > 0) and (OldChar <> NewChar) then + begin + for I := StartIndex to StartIndex + Length - 1 do + if FChars[I] = OldChar then + FChars[I] := NewChar; + end; + Result := Self; +end; + +function TJclStringBuilder.Replace(OldValue, NewValue: string; StartIndex, Count: SizeInt): TJclStringBuilder; +var + I: SizeInt; + Offset: SizeInt; + NewLen, OldLen, Capacity: SizeInt; +begin + if Count = -1 then + Count := FLength; + if (StartIndex < 0) or (Count < 0) or (StartIndex + Count > FLength) then + raise ArgumentOutOfRangeException.CreateRes(@RsArgumentOutOfRange); + if OldValue = '' then + raise ArgumentException.CreateResFmt(@RsArgumentIsNull, [0]); + + if (Count > 0) and (OldValue <> NewValue) then + begin + OldLen := System.Length(OldValue); + NewLen := System.Length(NewValue); + Offset := NewLen - OldLen; + Capacity := System.Length(FChars); + for I := StartIndex to StartIndex + Length - 1 do + if FChars[I] = OldValue[1] then + begin + if OldLen > 1 then + if StrLComp(@FChars[I + 1], PChar(OldValue) + 1, OldLen - 1) <> 0 then + Continue; + if Offset <> 0 then + begin + if FLength - OldLen + NewLen > MaxCurrency then + raise ArgumentOutOfRangeException.CreateRes(@RsArgumentOutOfRange); + if Capacity < FLength + Offset then + begin + Capacity := Capacity * 5 div 3 + Offset; + SetLength(FChars, Capacity); + end; + if Offset < 0 then + MoveChar(FChars[I - Offset], FChars[I], FLength - I) + else + MoveChar(FChars[I + OldLen], FChars[I + OldLen + Offset], FLength - OldLen - I); + Inc(FLength, Offset); + end; + if NewLen > 0 then + begin + if (OldLen = 1) and (NewLen = 1) then + FChars[I] := NewValue[1] + else + MoveChar(NewValue[1], FChars[I], NewLen); + end; + end; + end; + Result := Self; +end; + +function StrExpandTabs(S: string): string; +begin + // use an empty tab set, which will default to a tab width of 2 + Result := TJclTabSet(nil).Expand(s); +end; + +function StrExpandTabs(S: string; TabWidth: SizeInt): string; +var + TabSet: TJclTabSet; +begin + // create a tab set with no tab stops and the given tab width + TabSet := TJclTabSet.Create(TabWidth); + try + Result := TabSet.Expand(S); + finally + TabSet.Free; + end; +end; + +function StrExpandTabs(S: string; TabSet: TJclTabSet): string; +begin + // use the provided tab set to perform the expansion + Result := TabSet.Expand(S); +end; + +function StrOptimizeTabs(S: string): string; +begin + // use an empty tab set, which will default to a tab width of 2 + Result := TJclTabSet(nil).Optimize(s); +end; + +function StrOptimizeTabs(S: string; TabWidth: SizeInt): string; +var + TabSet: TJclTabSet; +begin + // create a tab set with no tab stops and the given tab width + TabSet := TJclTabSet.Create(TabWidth); + try + Result := TabSet.Optimize(S); + finally + TabSet.Free; + end; +end; + +function StrOptimizeTabs(S: string; TabSet: TJclTabSet): string; +begin + // use the provided tab set to perform the optimization + Result := TabSet.Optimize(S); +end; + +// === { TTabSetData } =================================================== + +type + TTabSetData = class + public + FStops: TDynSizeIntArray; + FRealWidth: SizeInt; + FRefCount: SizeInt; + FWidth: SizeInt; + FZeroBased: Boolean; + constructor Create(TabStops: array of SizeInt; ZeroBased: Boolean; TabWidth: SizeInt); + + function Add(Column: SizeInt): SizeInt; + function AddRef: SizeInt; + procedure CalcRealWidth; + function FindStop(Column: SizeInt): SizeInt; + function ReleaseRef: SizeInt; + procedure RemoveAt(Index: SizeInt); + procedure SetStops(Index, Value: SizeInt); + end; + +constructor TTabSetData.Create(TabStops: array of SizeInt; ZeroBased: Boolean; TabWidth: SizeInt); +var + idx: SizeInt; +begin + inherited Create; + FRefCount := 1; + for idx := 0 to High(Tabstops) do + Add(Tabstops[idx]); + FWidth := TabWidth; + FZeroBased := ZeroBased; + CalcRealWidth; +end; + +function TTabSetData.Add(Column: SizeInt): SizeInt; +var + I: SizeInt; +begin + if Column < Ord(FZeroBased) then + raise ArgumentOutOfRangeException.Create('Column'); + Result := FindStop(Column); + if Result < 0 then + begin + // the column doesn't exist; invert the result of FindStop to get the correct index position + Result := not Result; + // increase the tab stop array + SetLength(FStops, Length(FStops) + 1); + // shift rooms after the insert position + for I := High(FStops) - 1 downto Result do + FStops[I + 1] := FStops[I]; + // add the tab stop at the correct location + FStops[Result] := Column; + CalcRealWidth; + end + else + begin + raise EJclStringError.CreateRes(@RsTabs_DuplicatesNotAllowed); + end; +end; + +function TTabSetData.AddRef: SizeInt; +begin + Result := LockedInc(FRefCount); +end; + +procedure TTabSetData.CalcRealWidth; +begin + if FWidth < 1 then + begin + if Length(FStops) > 1 then + FRealWidth := FStops[High(FStops)] - FStops[Pred(High(FStops))] + else + if Length(FStops) = 1 then + FRealWidth := FStops[0] + else + FRealWidth := 2; + end + else + FRealWidth := FWidth; +end; + +function TTabSetData.FindStop(Column: SizeInt): SizeInt; +begin + Result := High(FStops); + while (Result >= 0) and (FStops[Result] > Column) do + Dec(Result); + if (Result >= 0) and (FStops[Result] <> Column) then + Result := not Succ(Result); +end; + +function TTabSetData.ReleaseRef: SizeInt; +begin + Result := LockedDec(FRefCount); + if Result <= 0 then + Destroy; +end; + +procedure TTabSetData.RemoveAt(Index: SizeInt); +var + I: SizeInt; +begin + for I := Index to High(FStops) - 1 do + FStops[I] := FStops[I + 1]; + SetLength(FStops, High(FStops)); + CalcRealWidth; +end; + +procedure TTabSetData.SetStops(Index, Value: SizeInt); +var + temp: SizeInt; +begin + if (Index < 0) or (Index >= Length(FStops)) then + begin + raise ArgumentOutOfRangeException.CreateRes(@RsArgumentOutOfRange); + end + else + begin + temp := FindStop(Value); + if temp < 0 then + begin + // remove existing tab stop... + RemoveAt(Index); + // now add the new tab stop + Add(Value); + end + else + if temp <> Index then + begin + // new tab stop already present at another index + raise EJclStringError.CreateRes(@RsTabs_DuplicatesNotAllowed); + end; + end; +end; + +//=== { TJclTabSet } ===================================================== + +constructor TJclTabSet.Create; +begin + // no tab stops, tab width set to auto + Create([], True, 0); +end; + +constructor TJclTabSet.Create(TabWidth: SizeInt); +begin + // no tab stops, specified tab width + Create([], True, TabWidth); +end; + +constructor TJclTabSet.Create(const Tabstops: array of SizeInt; ZeroBased: Boolean); +begin + // specified tab stops, tab width equal to distance between last two tab stops + Create(Tabstops, ZeroBased, 0); +end; + +constructor TJclTabSet.Create(const Tabstops: array of SizeInt; ZeroBased: Boolean; TabWidth: SizeInt); +begin + inherited Create; + FData := TTabSetData.Create(Tabstops, ZeroBased, TabWidth); +end; + +constructor TJclTabSet.Create(Data: TObject); +begin + inherited Create; + // add a reference to the data + TTabSetData(Data).AddRef; + // assign the data to this instance + FData := TTabSetData(Data); +end; + +destructor TJclTabSet.Destroy; +begin + // release the reference to the tab set data + TTabSetData(FData).ReleaseRef; + // make sure we won't accidentally refer to it later, just in case something goes wrong during destruction + FData := nil; + // really destroy the instance + inherited Destroy; +end; + +function TJclTabSet.Add(Column: SizeInt): SizeInt; +begin + if Self = nil then + raise NullReferenceException.Create; + Result := TTabSetData(FData).Add(Column); +end; + +function TJclTabSet.Clone: TJclTabSet; +begin + if Self <> nil then + Result := TJclTabSet.Create(TTabSetData(FData).FStops, TTabSetData(FData).FZeroBased, TTabSetData(FData).FWidth) + else + Result := nil; +end; + +function TJclTabSet.Delete(Column: SizeInt): SizeInt; +begin + Result := TTabSetData(FData).FindStop(Column); + if Result >= 0 then + TTabSetData(FData).RemoveAt(Result); +end; + +function TJclTabSet.Expand(const S: string): string; +begin + Result := Expand(s, StartColumn); +end; + +function TJclTabSet.Expand(const S: string; Column: SizeInt): string; +var + sb: TJclStringBuilder; + head: PChar; + cur: PChar; +begin + if Column < StartColumn then + raise ArgumentOutOfRangeException.Create('Column'); + sb := TJclStringBuilder.Create(Length(S)); + try + cur := PChar(S); + while cur^ <> #0 do + begin + head := cur; + while (cur^ <> #0) and (cur^ <> #9) do + begin + if CharIsReturn(cur^) then + Column := StartColumn + else + Inc(Column); + Inc(cur); + end; + if cur > head then + sb.Append(head, 0, cur - head); + if cur^ = #9 then + begin + sb.Append(' ', TabFrom(Column) - Column); + Column := TabFrom(Column); + Inc(cur); + end; + end; + Result := sb.ToString; + finally + sb.Free; + end; +end; + +function TJclTabSet.FindStop(Column: SizeInt): SizeInt; +begin + if Self <> nil then + Result := TTabSetData(FData).FindStop(Column) + else + Result := -1; +end; + +class function TJclTabSet.FromString(const S: string): TJclTabSet; +var + cur: PChar; + + function ParseNumber: Integer; + var + head: PChar; + begin + StrSkipChars(cur, CharIsWhiteSpace); + head := cur; + while CharIsDigit(cur^) do + Inc(cur); + Result := -1; + if (cur <= head) or not TryStrToInt(Copy(head, 1, cur - head), Result) then + Result := -1; + end; + + procedure ParseStops; + var + openBracket, hadComma: Boolean; + num: SizeInt; + begin + StrSkipChars(cur, CharIsWhiteSpace); + openBracket := cur^ = '['; + hadComma := False; + if openBracket then + Inc(cur); + repeat + num := ParseNumber; + if (num < 0) and hadComma then + raise EJclStringError.CreateRes(@RsTabs_StopExpected) + else + if num >= 0 then + Result.Add(num); + StrSkipChars(cur, CharIsWhiteSpace); + hadComma := cur^ = ','; + if hadComma then + Inc(cur); + until (cur^ = #0) or (cur^ = '+') or (cur^ = ']'); + if hadComma then + raise EJclStringError.CreateRes(@RsTabs_StopExpected) + else + if openBracket and (cur^ <> ']') then + raise EJclStringError.CreateRes(@RsTabs_CloseBracketExpected); + end; + + procedure ParseTabWidth; + var + num: SizeInt; + begin + StrSkipChars(cur, CharIsWhiteSpace); + if cur^ = '+' then + begin + Inc(cur); + StrSkipChars(cur, CharIsWhiteSpace); + num := ParseNumber; + if (num < 0) then + raise EJclStringError.CreateRes(@RsTabs_TabWidthExpected) + else + Result.TabWidth := num; + end; + end; + + procedure ParseZeroBasedFlag; + begin + StrSkipChars(cur, CharIsWhiteSpace); + if cur^ = '0' then + begin + Inc(cur); + if CharIsWhiteSpace(cur^) or (cur^ = #0) or (cur^ = '[') then + begin + Result.ZeroBased := True; + StrSkipChars(cur, CharIsWhiteSpace); + end + else + Dec(cur); + end; + end; + +begin + Result := TJclTabSet.Create; + try + Result.ZeroBased := False; + cur := PChar(S); + ParseZeroBasedFlag; + ParseStops; + ParseTabWidth; + except + // clean up the partially complete instance (to avoid memory leaks)... + Result.Free; + // ... and re-raise the exception + raise; + end; +end; + +function TJclTabSet.GetCount: SizeInt; +begin + if Self <> nil then + Result := Length(TTabSetData(FData).FStops) + else + Result := 0; +end; + +function TJclTabSet.GetStops(Index: SizeInt): SizeInt; +begin + if Self <> nil then + begin + if (Index < 0) or (Index >= Length(TTabSetData(FData).FStops)) then + begin + raise EJclStringError.CreateRes(@RsArgumentOutOfRange); + end + else + Result := TTabSetData(FData).FStops[Index]; + end + else + begin + raise EJclStringError.CreateRes(@RsArgumentOutOfRange); + end; +end; + +function TJclTabSet.GetTabWidth: SizeInt; +begin + if Self <> nil then + Result := TTabSetData(FData).FWidth + else + Result := 0; +end; + +function TJclTabSet.GetZeroBased: Boolean; +begin + Result := (Self = nil) or TTabSetData(FData).FZeroBased; +end; + +procedure TJclTabSet.OptimalFillInfo(StartColumn, TargetColumn: SizeInt; out TabsNeeded, SpacesNeeded: SizeInt); +var + nextTab: SizeInt; +begin + if StartColumn < Self.StartColumn then // starting column less than 1 or 0 (depending on ZeroBased state) + raise ArgumentOutOfRangeException.Create('StartColumn'); + if (TargetColumn < StartColumn) then // target lies before the starting column + raise ArgumentOutOfRangeException.Create('TargetColumn'); + TabsNeeded := 0; + repeat + nextTab := TabFrom(StartColumn); + if nextTab <= TargetColumn then + begin + Inc(TabsNeeded); + StartColumn := nextTab; + end; + until nextTab > TargetColumn; + SpacesNeeded := TargetColumn - StartColumn; +end; + +function TJclTabSet.Optimize(const S: string): string; +begin + Result := Optimize(S, StartColumn); +end; + +function TJclTabSet.Optimize(const S: string; Column: SizeInt): string; +var + sb: TJclStringBuilder; + head: PChar; + cur: PChar; + tgt: SizeInt; + + procedure AppendOptimalWhiteSpace(Target: SizeInt); + var + tabCount: SizeInt; + spaceCount: SizeInt; + begin + if cur > head then + begin + OptimalFillInfo(Column, Target, tabCount, spaceCount); + if tabCount > 0 then + sb.Append(#9, tabCount); + if spaceCount > 0 then + sb.Append(' ', spaceCount); + end; + end; + +begin + if Column < StartColumn then + raise ArgumentOutOfRangeException.Create('Column'); + sb := TJclStringBuilder.Create(Length(S)); + try + cur := PChar(s); + while cur^ <> #0 do + begin + // locate first whitespace character + head := cur; + while (cur^ <> #0) and not CharIsWhiteSpace(cur^) do + Inc(cur); + // output non whitespace characters + if cur > head then + sb.Append(head, 0, cur - head); + // advance column + Inc(Column, cur - head); + // initialize target column indexer + tgt := Column; + // locate end of whitespace sequence + while CharIsWhiteSpace(cur^) do + begin + if CharIsReturn(cur^) then + begin + // append optimized whitespace sequence... + AppendOptimalWhiteSpace(tgt); + // ...set the column back to the start of the line... + Column := StartColumn; + // ...reset target column indexer... + tgt := Column; + // ...add the line break character... + sb.Append(cur^); + end + else + if cur^ = #9 then + tgt := TabFrom(tgt) // expand the tab + else + Inc(tgt); // a normal whitespace; taking up 1 column + Inc(cur); + end; + AppendOptimalWhiteSpace(tgt); // append optimized whitespace sequence... + Column := tgt; // ...and memorize the column for the next iteration + end; + Result := sb.ToString; // convert result to a string + finally + sb.Free; + end; +end; + +procedure TJclTabSet.RemoveAt(Index: SizeInt); +begin + if Self <> nil then + TTabSetData(FData).RemoveAt(Index) + else + raise NullReferenceException.Create; +end; + +procedure TJclTabSet.SetStops(Index, Value: SizeInt); +begin + if Self <> nil then + TTabSetData(FData).SetStops(Index, Value) + else + raise NullReferenceException.Create; +end; + +procedure TJclTabSet.SetTabWidth(Value: SizeInt); +begin + if Self <> nil then + begin + TTabSetData(FData).FWidth := Value; + TTabSetData(FData).CalcRealWidth; + end + else + raise NullReferenceException.Create; +end; + +procedure TJclTabSet.SetZeroBased(Value: Boolean); +var + shift: SizeInt; + idx: SizeInt; +begin + if Self <> nil then + begin + if Value <> TTabSetData(FData).FZeroBased then + begin + TTabSetData(FData).FZeroBased := Value; + if Value then + shift := -1 + else + shift := 1; + for idx := 0 to High(TTabSetData(FData).FStops) do + TTabSetData(FData).FStops[idx] := TTabSetData(FData).FStops[idx] + shift; + end; + end + else + raise NullReferenceException.Create; +end; + +function TJclTabSet.InternalTabStops: TDynSizeIntArray; +begin + if Self <> nil then + Result := TTabSetData(FData).FStops + else + Result := nil; +end; + +function TJclTabSet.InternalTabWidth: SizeInt; +begin + if Self <> nil then + Result := TTabSetData(FData).FRealWidth + else + Result := 2; +end; + +function TJclTabSet.NewReference: TJclTabSet; +begin + if Self <> nil then + Result := TJclTabSet.Create(FData) + else + Result := nil; +end; + +function TJclTabSet.StartColumn: SizeInt; +begin + if GetZeroBased then + Result := 0 + else + Result := 1; +end; + +function TJclTabSet.TabFrom(Column: SizeInt): SizeInt; +begin + if Column < StartColumn then + raise ArgumentOutOfRangeException.Create('Column'); + Result := FindStop(Column); + if Result < 0 then + Result := not Result + else + Inc(Result); + if Result >= GetCount then + begin + if GetCount > 0 then + Result := TTabSetData(FData).FStops[High(TTabSetData(FData).FStops)] + else + Result := StartColumn; + while Result <= Column do + Inc(Result, ActualTabWidth); + end + else + Result := TTabSetData(FData).FStops[Result]; +end; + +function TJclTabSet.ToString: string; +begin + Result := ToString(TabSetFormatting_Full); +end; + +function TJclTabSet.ToString(FormattingOptions: SizeInt): string; +var + sb: TJclStringBuilder; + idx: SizeInt; + + function WantBrackets: Boolean; + begin + Result := (TabSetFormatting_SurroundStopsWithBrackets and FormattingOptions) <> 0; + end; + + function EmptyBrackets: Boolean; + begin + Result := (TabSetFormatting_EmptyBracketsIfNoStops and FormattingOptions) <> 0; + end; + + function IncludeAutoWidth: Boolean; + begin + Result := (TabSetFormatting_AutoTabWidth and FormattingOptions) <> 0; + end; + + function IncludeTabWidth: Boolean; + begin + Result := (TabSetFormatting_NoTabWidth and FormattingOptions) = 0; + end; + + function IncludeStops: Boolean; + begin + Result := (TabSetFormatting_NoTabStops and FormattingOptions) = 0; + end; + +begin + sb := TJclStringBuilder.Create; + try + // output the fixed tabulation positions if requested... + if IncludeStops then + begin + // output each individual tabulation position + for idx := 0 to GetCount - 1 do + begin + sb.Append(TabStops[idx]); + sb.Append(','); + end; + // remove the final comma if any tabulation positions where outputted + if sb.Length <> 0 then + sb.Remove(sb.Length - 1, 1); + // bracket the tabulation positions if requested + if WantBrackets and (EmptyBrackets or (sb.Length > 0)) then + begin + sb.Insert(0, '['); + sb.Append(']'); + end; + end; + // output the tab width if requested.... + if IncludeTabWidth and (IncludeAutoWidth or (TabWidth > 0)) then + begin + // separate the tab width from any outputted tabulation positions with a whitespace + if sb.Length > 0 then + sb.Append(' '); + // flag tab width + sb.Append('+'); + // finally, output the tab width + sb.Append(ActualTabWidth); + end; + // flag zero-based tabset by outputting a 0 (zero) as the first character. + if ZeroBased then + sb.Insert(0, string('0 ')); + Result := StrTrimCharRight(sb.ToString, ' '); + finally + sb.Free; + end; +end; + +function TJclTabSet.UpdatePosition(const S: string): SizeInt; +var + Line: SizeInt; +begin + Result := StartColumn; + Line := -1; + UpdatePosition(S, Result, Line); +end; + +function TJclTabSet.UpdatePosition(const S: string; Column: SizeInt): SizeInt; +var + Line: SizeInt; +begin + if Column < StartColumn then + raise ArgumentOutOfRangeException.Create('Column'); + Result := Column; + Line := -1; + UpdatePosition(S, Result, Line); +end; + +function TJclTabSet.UpdatePosition(const S: string; var Column, Line: SizeInt): SizeInt; +var + prevChar: Char; + cur: PChar; +begin + if Column < StartColumn then + raise ArgumentOutOfRangeException.Create('Column'); + // initialize loop + cur := PChar(S); + // iterate until end of string (the Null-character) + while cur^ <> #0 do + begin + // check for line-breaking characters + if CharIsReturn(cur^) then + begin + // Column moves back all the way to the left + Column := StartColumn; + // If this is the first line-break character or the same line-break character, increment the Line parameter + Inc(Line); + // check if it's the first of a two-character line-break + prevChar := cur^; + Inc(cur); + // if it isn't a two-character line-break, undo the previous advancement + if (cur^ = prevChar) or not CharIsReturn(cur^) then + Dec(cur); + end + else // check for tab character and expand it + if cur^ = #9 then + Column := TabFrom(Column) + else // a normal character; increment column + Inc(Column); + // advance pointer + Inc(cur); + end; + // set the result to the newly calculated column + Result := Column; +end; + +//=== { NullReferenceException } ============================================= + +constructor NullReferenceException.Create; +begin + CreateRes(@RsArg_NullReferenceException); +end; + +{$IFNDEF WINSCP} +function CompareNatural(const S1, S2: string; CaseInsensitive: Boolean): SizeInt; +var + Cur1, Len1, + Cur2, Len2: SizeInt; + + function IsRealNumberChar(ch: Char): Boolean; + begin + Result := ((ch >= '0') and (ch <= '9')) or (ch = '-') or (ch = '+'); + end; + + procedure NumberCompare; + var + IsReallyNumber: Boolean; + FirstDiffBreaks: Boolean; + Val1, Val2: SizeInt; + begin + Result := 0; + IsReallyNumber := False; + // count leading spaces in S1 + while (Cur1 <= Len1) and CharIsWhiteSpace(S1[Cur1]) do + begin + Dec(Result); + Inc(Cur1); + end; + // count leading spaces in S2 (canceling them out against the ones in S1) + while (Cur2 <= Len2) and CharIsWhiteSpace(S2[Cur2]) do + begin + Inc(Result); + Inc(Cur2); + end; + + // if spaces match, or both strings are actually followed by a numeric character, continue the checks + if (Result = 0) or ((Cur1 <= Len1) and CharIsNumberChar(S1[Cur1]) and (Cur2 <= Len2) and CharIsNumberChar(S2[Cur2])) then + begin + // Check signed number + if (Cur1 <= Len1) and (S1[Cur1] = '-') and ((Cur2 > Len2) or (S2[Cur2] <> '-')) then + Result := 1 + else + if (Cur2 <= Len2) and (S2[Cur2] = '-') and ((Cur1 > Len1) or (S1[Cur1] <> '-')) then + Result := -1 + else + Result := 0; + + if (Cur1 <= Len1) and ((S1[Cur1] = '-') or (S1[Cur1] = '+')) then + Inc(Cur1); + if (Cur2 <= Len2) and ((S2[Cur2] = '-') or (S2[Cur2] = '+')) then + Inc(Cur2); + + FirstDiffBreaks := (Cur1 <= Len1) and (S1[Cur1] = '0') or (Cur2 <= Len2) and (S2[Cur2] = '0'); + while (Cur1 <= Len1) and CharIsDigit(S1[Cur1]) and (Cur2 <= Len2) and CharIsDigit(S2[Cur2]) do + begin + IsReallyNumber := True; + Val1 := StrToInt(S1[Cur1]); + Val2 := StrToInt(S2[Cur2]); + + if (Result = 0) and (Val1 < Val2) then + Result := -1 + else + if (Result = 0) and (Val1 > Val2) then + Result := 1; + if FirstDiffBreaks and (Result <> 0) then + Break; + Inc(Cur1); + Inc(Cur2); + end; + + if IsReallyNumber then + begin + if not FirstDiffBreaks then + begin + if (Cur1 <= Len1) and CharIsDigit(S1[Cur1]) then + Result := 1 + else + if (Cur2 <= Len2) and CharIsDigit(S2[Cur2]) then + Result := -1; + end; + end; + end; + end; + + procedure SetByCompareLength; + var + Remain1: SizeInt; + Remain2: SizeInt; + begin + // base result on relative compare length (spaces could be ignored, so even if S1 is longer than S2, they could be + // completely equal, or S2 could be longer) + Remain1 := Len1 - Cur1 + 1; + Remain2 := Len2 - Cur2 + 1; + if Remain1 < 0 then + Remain1 := 0; + if Remain2 < 0 then + Remain2 := 0; + + if Remain1 < Remain2 then + Result := -1 + else + if Remain1 > Remain2 then + Result := 1; + end; + +begin + Cur1 := 1; + Len1 := Length(S1); + Cur2 := 1; + Len2 := Length(S2); + Result := 0; + + while (Result = 0) do + begin + if (Cur1 > Len1) or (Cur2 > Len2) then + begin + SetByCompareLength; + Break; + end + else + if (Cur1 <= Len1) and (Cur2 > Len2) then + Result := 1 + else + if (S1[Cur1] = '-') and IsRealNumberChar(S2[Cur2]) and (S2[Cur2] <> '-') then + Result := -1 + else + if (S2[Cur2] = '-') and IsRealNumberChar(S1[Cur1]) and (S1[Cur1] <> '-') then + Result := 1 + else + if (IsRealNumberChar(S1[Cur1]) or CharIsWhiteSpace(S1[Cur1])) and (IsRealNumberChar(S2[Cur2]) or CharIsWhiteSpace(S2[Cur2])) then + NumberCompare + else + begin + if CaseInsensitive then + Result := StrLIComp(PChar(@S1[Cur1]), PChar(@S2[Cur2]), 1) + else + Result := StrLComp(PChar(@S1[Cur1]), PChar(@S2[Cur2]), 1); + Inc(Cur1); + Inc(Cur2); + end; + end; +end; + +function CompareNaturalStr(const S1, S2: string): SizeInt; overload; +begin + Result := CompareNatural(S1, S2, False); +end; + +function CompareNaturalText(const S1, S2: string): SizeInt; overload; +begin + Result := CompareNatural(S1, S2, True); +end; +{$ENDIF ~WINSCP} + +initialization + {$IFNDEF UNICODE_RTL_DATABASE} + LoadCharTypes; // this table first + LoadCaseMap; // or this function does not work + {$ENDIF ~UNICODE_RTL_DATABASE} + {$IFDEF UNITVERSIONING} + RegisterUnitVersion(HInstance, UnitVersioning); + {$ENDIF UNITVERSIONING} + +{$IFDEF UNITVERSIONING} +finalization + UnregisterUnitVersion(HInstance); +{$ENDIF UNITVERSIONING} + +end. diff --git a/source/packages/jcl/JclSynch.pas b/source/packages/jcl/JclSynch.pas new file mode 100644 index 00000000..e65575d8 --- /dev/null +++ b/source/packages/jcl/JclSynch.pas @@ -0,0 +1,1788 @@ +{**************************************************************************************************} +{ } +{ Project JEDI Code Library (JCL) } +{ } +{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); } +{ you may not use this file except in compliance with the License. You may obtain a copy of the } +{ License at http://www.mozilla.org/MPL/ } +{ } +{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF } +{ ANY KIND, either express or implied. See the License for the specific language governing rights } +{ and limitations under the License. } +{ } +{ The Original Code is JclSynch.pas. } +{ } +{ The Initial Developers of the Original Code are Marcel van Brakel and Azret Botash. } +{ Portions created by these individuals are Copyright (C) of these individuals. } +{ All Rights Reserved. } +{ } +{ Contributor(s): } +{ Marcel van Brakel } +{ Olivier Sannier (obones) } +{ Matthias Thoma (mthoma) } +{ } +{**************************************************************************************************} +{ } +{ This unit contains various classes and support routines for implementing synchronisation in } +{ multithreaded applications. This ranges from interlocked access to simple typed variables to } +{ wrapper classes for synchronisation primitives provided by the operating system } +{ (critical section, semaphore, mutex etc). It also includes three user defined classes to } +{ complement these. } +{ } +{**************************************************************************************************} +{ } +{ Last modified: $Date:: $ } +{ Revision: $Rev:: $ } +{ Author: $Author:: $ } +{ } +{**************************************************************************************************} + +unit JclSynch; + +{$I jcl.inc} + +interface + +uses + {$IFDEF UNITVERSIONING} + JclUnitVersioning, + {$ENDIF UNITVERSIONING} + {$IFDEF HAS_UNITSCOPE} + {$IFDEF MSWINDOWS} + Winapi.Windows, JclWin32, + {$ENDIF MSWINDOWS} + {$ELSE ~HAS_UNITSCOPE} + {$IFDEF MSWINDOWS} + Windows, JclWin32, + {$ENDIF MSWINDOWS} + {$ENDIF ~HAS_UNITSCOPE} + JclBase; + +// Locked Integer manipulation +// +// Routines to manipulate simple typed variables in a thread safe manner +function LockedAdd(var Target: Integer; Value: Integer): Integer; overload; +function LockedCompareExchange(var Target: Integer; Exch, Comp: Integer): Integer; overload; +function LockedCompareExchange(var Target: TObject; Exch, Comp: TObject): TObject; overload; +function LockedCompareExchange(var Target: Pointer; Exch, Comp: Pointer): Pointer; overload; +function LockedDec(var Target: Integer): Integer; overload; +function LockedExchange(var Target: Integer; Value: Integer): Integer; overload; +function LockedExchangeAdd(var Target: Integer; Value: Integer): Integer; overload; +function LockedExchangeDec(var Target: Integer): Integer; overload; +function LockedExchangeInc(var Target: Integer): Integer; overload; +function LockedExchangeSub(var Target: Integer; Value: Integer): Integer; overload; +function LockedInc(var Target: Integer): Integer; overload; +function LockedSub(var Target: Integer; Value: Integer): Integer; overload; + +{$IFDEF CPU64} +function LockedAdd(var Target: Int64; Value: Int64): Int64; overload; +function LockedCompareExchange(var Target: Int64; Exch, Comp: Int64): Int64; overload; +function LockedDec(var Target: Int64): Int64; overload; +function LockedExchange(var Target: Int64; Value: Int64): Int64; overload; +function LockedExchangeAdd(var Target: Int64; Value: Int64): Int64; overload; +function LockedExchangeDec(var Target: Int64): Int64; overload; +function LockedExchangeInc(var Target: Int64): Int64; overload; +function LockedExchangeSub(var Target: Int64; Value: Int64): Int64; overload; +function LockedInc(var Target: Int64): Int64; overload; +function LockedSub(var Target: Int64; Value: Int64): Int64; overload; + +{$IFDEF BORLAND} +function LockedDec(var Target: NativeInt): NativeInt; overload; +function LockedInc(var Target: NativeInt): NativeInt; overload; +{$ENDIF BORLAND} +{$ENDIF CPU64} + +// TJclDispatcherObject +// +// Base class for operating system provided synchronisation primitives +type + TJclWaitResult = (wrAbandoned, wrError, wrIoCompletion, wrSignaled, wrTimeout); + + TJclWaitHandle = THandle; + + TJclDispatcherObject = class(TObject) + private + FExisted: Boolean; + FHandle: TJclWaitHandle; + FName: string; + public + constructor Attach(AHandle: TJclWaitHandle); + destructor Destroy; override; + //function MsgWaitFor(const TimeOut: Cardinal): TJclWaitResult; Mask: DWORD): TJclWaitResult; + //function MsgWaitForEx(const TimeOut: Cardinal): TJclWaitResult; Mask: DWORD): TJclWaitResult; + function SignalAndWait(const Obj: TJclDispatcherObject; TimeOut: Cardinal; + Alertable: Boolean): TJclWaitResult; + function WaitAlertable(const TimeOut: Cardinal): TJclWaitResult; + function WaitFor(const TimeOut: Cardinal): TJclWaitResult; + function WaitForever: TJclWaitResult; + property Existed: Boolean read FExisted; + property Handle: TJclWaitHandle read FHandle; + property Name: string read FName; + end; + +// Wait functions +// +// Object enabled Wait functions (takes TJclDispatcher objects as parameter as +// opposed to handles) mostly for convenience +function WaitForMultipleObjects(const Objects: array of TJclDispatcherObject; + WaitAll: Boolean; TimeOut: Cardinal): Cardinal; +function WaitAlertableForMultipleObjects(const Objects: array of TJclDispatcherObject; + WaitAll: Boolean; TimeOut: Cardinal): Cardinal; + +type + TJclCriticalSection = class(TObject) + private + FCriticalSection: TRTLCriticalSection; + public + constructor Create; virtual; + destructor Destroy; override; + class procedure CreateAndEnter(var CS: TJclCriticalSection); + procedure Enter; + procedure Leave; + end; + + TJclCriticalSectionEx = class(TJclCriticalSection) + private + FSpinCount: Cardinal; + {$IFNDEF WINSCP} + function GetSpinCount: Cardinal; + procedure SetSpinCount(const Value: Cardinal); + {$ENDIF ~WINSCP} + public + constructor Create; override; + constructor CreateEx(SpinCount: Cardinal; NoFailEnter: Boolean); virtual; + {$IFNDEF WINSCP} + class function GetSpinTimeOut: Cardinal; + class procedure SetSpinTimeOut(const Value: Cardinal); + {$ENDIF ~WINSCP} + function TryEnter: Boolean; + {$IFNDEF WINSCP} + property SpinCount: Cardinal read GetSpinCount write SetSpinCount; + {$ENDIF ~WINSCP} + end; + + TJclEvent = class(TJclDispatcherObject) + public + constructor Create(SecAttr: PSecurityAttributes; Manual, Signaled: Boolean; const Name: string); + constructor Open(Access: Cardinal; Inheritable: Boolean; const Name: string); + function Pulse: Boolean; + function ResetEvent: Boolean; + function SetEvent: Boolean; + end; + + TJclWaitableTimer = class(TJclDispatcherObject) + private + FResume: Boolean; + public + constructor Create(SecAttr: PSecurityAttributes; Manual: Boolean; const Name: string); + constructor Open(Access: Cardinal; Inheritable: Boolean; const Name: string); + function Cancel: Boolean; + function SetTimer(const DueTime: Int64; Period: Longint; Resume: Boolean): Boolean; + function SetTimerApc(const DueTime: Int64; Period: Longint; Resume: Boolean; Apc: TFNTimerAPCRoutine; Arg: Pointer): Boolean; + end; + + TJclSemaphore = class(TJclDispatcherObject) + public + constructor Create(SecAttr: PSecurityAttributes; Initial, Maximum: Longint; const Name: string); + constructor Open(Access: Cardinal; Inheritable: Boolean; const Name: string); + function Release(ReleaseCount: Longint): Boolean; + function ReleasePrev(ReleaseCount: Longint; var PrevCount: Longint): Boolean; + end; + + TJclMutex = class(TJclDispatcherObject) + public + constructor Create(SecAttr: PSecurityAttributes; InitialOwner: Boolean; + const Name: string); + constructor Open(Access: Cardinal; Inheritable: Boolean; const Name: string); + function Acquire(const TimeOut: Cardinal = INFINITE): Boolean; + function Release: Boolean; + end; + + POptexSharedInfo = ^TOptexSharedInfo; + TOptexSharedInfo = record + SpinCount: Integer; // number of times to try and enter the optex before + // waiting on kernel event, 0 on single processor + LockCount: Integer; // count of enter attempts + ThreadId: Longword; // id of thread that owns the optex, 0 if free + RecursionCount: Integer; // number of times the optex is owned, 0 if free + end; + +{$IFNDEF WINSCP} + + TJclOptex = class(TObject) + private + FEvent: TJclEvent; + FExisted: Boolean; + FFileMapping: THandle; + FName: string; + FSharedInfo: POptexSharedInfo; + function GetUniProcess: Boolean; + function GetSpinCount: Integer; + procedure SetSpinCount(Value: Integer); + public + constructor Create(const Name: string = ''; SpinCount: Integer = 4000); + destructor Destroy; override; + procedure Enter; + procedure Leave; + function TryEnter: Boolean; + property Existed: Boolean read FExisted; + property Name: string read FName; + property SpinCount: Integer read GetSpinCount write SetSpinCount; + property UniProcess: Boolean read GetUniProcess; + end; + +{$ENDIF ~WINSCP} + + TMrewPreferred = (mpReaders, mpWriters, mpEqual); + + TMrewThreadInfo = record + ThreadId: Longword; // client-id of thread + RecursionCount: Integer; // number of times a thread accessed the mrew + Reader: Boolean; // true if reader, false if writer + end; + TMrewThreadInfoArray = array of TMrewThreadInfo; + + TJclMultiReadExclusiveWrite = class(TObject) + private + FLock: TJclCriticalSection; + FPreferred: TMrewPreferred; + FSemReaders: TJclSemaphore; + FSemWriters: TJclSemaphore; + FState: Integer; + FThreads: TMrewThreadInfoArray; + FWaitingReaders: Integer; + FWaitingWriters: Integer; + procedure AddToThreadList(ThreadId: Longword; Reader: Boolean); + procedure RemoveFromThreadList(Index: Integer); + function FindThread(ThreadId: Longword): Integer; + procedure ReleaseWaiters(WasReading: Boolean); + protected + procedure Release; + public + constructor Create(Preferred: TMrewPreferred); + + destructor Destroy; override; + procedure BeginRead; + procedure BeginWrite; + procedure EndRead; + procedure EndWrite; + end; + + PMetSectSharedInfo = ^TMetSectSharedInfo; + TMetSectSharedInfo = record + Initialized: LongBool; // Is the metered section initialized? + SpinLock: Longint; // Used to gain access to this structure + ThreadsWaiting: Longint; // Count of threads waiting + AvailableCount: Longint; // Available resource count + MaximumCount: Longint; // Maximum resource count + end; + + PMeteredSection = ^TMeteredSection; + TMeteredSection = record + Event: THandle; // Handle to a kernel event object + FileMap: THandle; // Handle to memory mapped file + SharedInfo: PMetSectSharedInfo; + end; + + TJclMeteredSection = class(TObject) + private + FMetSect: PMeteredSection; + procedure CloseMeteredSection; + function InitMeteredSection(InitialCount, MaxCount: Longint; const Name: string; OpenOnly: Boolean): Boolean; + function CreateMetSectEvent(const Name: string; OpenOnly: Boolean): Boolean; + function CreateMetSectFileView(InitialCount, MaxCount: Longint; const Name: string; OpenOnly: Boolean): Boolean; + protected + procedure AcquireLock; + procedure ReleaseLock; + public + constructor Create(InitialCount, MaxCount: Longint; const Name: string); + constructor Open(const Name: string); + destructor Destroy; override; + function Enter(TimeOut: Longword): TJclWaitResult; + function Leave(ReleaseCount: Longint): Boolean; overload; + function Leave(ReleaseCount: Longint; out PrevCount: Longint): Boolean; overload; + end; + +// Debugging +// +// Note that the following function and structure declarations are all offically +// undocumented and, except for QueryCriticalSection, require Windows NT since +// it is all part of the Windows NT Native API. +{ TODO -cTest : Test this structures } +type + TEventInfo = record + EventType: Longint; // 0 = manual, otherwise auto + Signaled: LongBool; // true is signaled + end; + + TMutexInfo = record + SignalState: Longint; // >0 = signaled, <0 = |SignalState| recurs. acquired + Owned: ByteBool; // owned by thread + Abandoned: ByteBool; // is abandoned? + end; + + TSemaphoreCounts = record + CurrentCount: Longint; // current semaphore count + MaximumCount: Longint; // maximum semaphore count + end; + + TTimerInfo = record + Remaining: TLargeInteger; // 100ns intervals until signaled + Signaled: ByteBool; // is signaled? + end; + +function QueryCriticalSection(CS: TJclCriticalSection; var Info: TRTLCriticalSection): Boolean; +{ TODO -cTest : Test these 4 functions } +function QueryEvent(Handle: THandle; var Info: TEventInfo): Boolean; +function QueryMutex(Handle: THandle; var Info: TMutexInfo): Boolean; +function QuerySemaphore(Handle: THandle; var Info: TSemaphoreCounts): Boolean; +function QueryTimer(Handle: THandle; var Info: TTimerInfo): Boolean; + +type + // Exceptions + EJclWin32HandleObjectError = class(EJclWin32Error); + EJclDispatcherObjectError = class(EJclWin32Error); + EJclCriticalSectionError = class(EJclWin32Error); + EJclEventError = class(EJclWin32Error); + EJclWaitableTimerError = class(EJclWin32Error); + EJclSemaphoreError = class(EJclWin32Error); + EJclMutexError = class(EJclWin32Error); + EJclMeteredSectionError = class(EJclError); + +function ValidateMutexName(const aName: string): string; + + +{$IFDEF UNITVERSIONING} +const + UnitVersioning: TUnitVersionInfo = ( + RCSfile: '$URL$'; + Revision: '$Revision$'; + Date: '$Date$'; + LogPath: 'JCL\source\common'; + Extra: ''; + Data: nil + ); +{$ENDIF UNITVERSIONING} + +implementation + +uses + {$IFDEF HAS_UNITSCOPE} + System.SysUtils, + {$ELSE ~HAS_UNITSCOPE} + SysUtils, + {$ENDIF ~HAS_UNITSCOPE} + {$IFNDEF WINSCP}JclLogic, JclRegistry,{$ELSE}Math,{$ENDIF ~WINSCP} JclResources, + {$IFNDEF WINSCP}JclSysInfo,{$ENDIF ~WINSCP} JclStrings; + +const + RegSessionManager = {HKLM\} 'SYSTEM\CurrentControlSet\Control\Session Manager'; + RegCritSecTimeout = {RegSessionManager\} 'CriticalSectionTimeout'; + +// Locked Integer manipulation +function LockedAdd(var Target: Integer; Value: Integer): Integer; +asm + {$IFDEF CPU32} + // --> EAX Target + // EDX Value + // <-- EAX Result + MOV ECX, EAX + MOV EAX, EDX + LOCK XADD [ECX], EAX + ADD EAX, EDX + {$ENDIF CPU32} + {$IFDEF CPU64} + // --> RCX Target + // EDX Value + // <-- EAX Result + MOV EAX, EDX + LOCK XADD [RCX], EAX + ADD EAX, EDX + {$ENDIF CPU64} +end; + +function LockedCompareExchange(var Target: Integer; Exch, Comp: Integer): Integer; +asm + {$IFDEF CPU32} + // --> EAX Target + // EDX Exch + // ECX Comp + // <-- EAX Result + XCHG EAX, ECX + // EAX Comp + // EDX Exch + // ECX Target + LOCK CMPXCHG [ECX], EDX + {$ENDIF CPU32} + {$IFDEF CPU64} + // --> RCX Target + // EDX Exch + // R8 Comp + // <-- EAX Result + MOV RAX, R8 + // RCX Target + // EDX Exch + // RAX Comp + LOCK CMPXCHG [RCX], EDX + {$ENDIF CPU64} +end; + +function LockedCompareExchange(var Target: Pointer; Exch, Comp: Pointer): Pointer; +asm + {$IFDEF CPU32} + // --> EAX Target + // EDX Exch + // ECX Comp + // <-- EAX Result + XCHG EAX, ECX + // EAX Comp + // EDX Exch + // ECX Target + LOCK CMPXCHG [ECX], EDX + {$ENDIF CPU32} + {$IFDEF CPU64} + // --> RCX Target + // RDX Exch + // R8 Comp + // <-- RAX Result + MOV RAX, R8 + // RCX Target + // RDX Exch + // RAX Comp + LOCK CMPXCHG [RCX], RDX + {$ENDIF CPU64} +end; + +function LockedCompareExchange(var Target: TObject; Exch, Comp: TObject): TObject; +asm + {$IFDEF CPU32} + // --> EAX Target + // EDX Exch + // ECX Comp + // <-- EAX Result + XCHG EAX, ECX + // EAX Comp + // EDX Exch + // ECX Target + LOCK CMPXCHG [ECX], EDX + {$ENDIF CPU32} + {$IFDEF CPU64} + // --> RCX Target + // RDX Exch + // R8 Comp + // <-- RAX Result + MOV RAX, R8 + // --> RCX Target + // RDX Exch + // RAX Comp + LOCK CMPXCHG [RCX], RDX + {$ENDIF CPU64} +end; + +function LockedDec(var Target: Integer): Integer; +asm + {$IFDEF CPU32} + // --> EAX Target + // <-- EAX Result + MOV ECX, EAX + MOV EAX, -1 + LOCK XADD [ECX], EAX + DEC EAX + {$ENDIF CPU32} + {$IFDEF CPU64} + // --> RCX Target + // <-- EAX Result + MOV EAX, -1 + LOCK XADD [RCX], EAX + DEC EAX + {$ENDIF CPU64} +end; + +function LockedExchange(var Target: Integer; Value: Integer): Integer; +asm + {$IFDEF CPU32} + // --> EAX Target + // EDX Value + // <-- EAX Result + MOV ECX, EAX + MOV EAX, EDX + // ECX Target + // EAX Value + LOCK XCHG [ECX], EAX + {$ENDIF CPU32} + {$IFDEF CPU64} + // --> RCX Target + // EDX Value + // <-- EAX Result + MOV EAX, EDX + // RCX Target + // EAX Value + LOCK XCHG [RCX], EAX + {$ENDIF CPU64} +end; + +function LockedExchangeAdd(var Target: Integer; Value: Integer): Integer; +asm + {$IFDEF CPU32} + // --> EAX Target + // EDX Value + // <-- EAX Result + MOV ECX, EAX + MOV EAX, EDX + // ECX Target + // EAX Value + LOCK XADD [ECX], EAX + {$ENDIF CPU32} + {$IFDEF CPU64} + // --> RCX Target + // EDX Value + // <-- EAX Result + MOV EAX, EDX + // RCX Target + // EAX Value + LOCK XADD [RCX], EAX + {$ENDIF CPU64} +end; + +function LockedExchangeDec(var Target: Integer): Integer; +asm + {$IFDEF CPU32} + // --> EAX Target + // <-- EAX Result + MOV ECX, EAX + MOV EAX, -1 + LOCK XADD [ECX], EAX + {$ENDIF CPU32} + {$IFDEF CPU64} + // --> RCX Target + // <-- EAX Result + MOV EAX, -1 + LOCK XADD [RCX], EAX + {$ENDIF CPU64} +end; + +function LockedExchangeInc(var Target: Integer): Integer; +asm + {$IFDEF CPU32} + // --> EAX Target + // <-- EAX Result + MOV ECX, EAX + MOV EAX, 1 + LOCK XADD [ECX], EAX + {$ENDIF CPU32} + {$IFDEF CPU64} + // --> RCX Target + // <-- EAX Result + MOV EAX, 1 + LOCK XADD [RCX], EAX + {$ENDIF CPU64} +end; + +function LockedExchangeSub(var Target: Integer; Value: Integer): Integer; +asm + {$IFDEF CPU32} + // --> EAX Target + // EDX Value + // <-- EAX Result + MOV ECX, EAX + NEG EDX + MOV EAX, EDX + // ECX Target + // EAX -Value + LOCK XADD [ECX], EAX + {$ENDIF CPU32} + {$IFDEF CPU64} + // --> RCX Target + // EDX Value + // <-- EAX Result + NEG EDX + MOV EAX, EDX + // RCX Target + // EAX -Value + LOCK XADD [RCX], EAX + {$ENDIF CPU64} +end; + +function LockedInc(var Target: Integer): Integer; +asm + {$IFDEF CPU32} + // --> EAX Target + // <-- EAX Result + MOV ECX, EAX + MOV EAX, 1 + LOCK XADD [ECX], EAX + INC EAX + {$ENDIF CPU32} + {$IFDEF CPU64} + // --> RCX Target + // <-- EAX Result + MOV EAX, 1 + LOCK XADD [RCX], EAX + INC EAX + {$ENDIF CPU64} +end; + +function LockedSub(var Target: Integer; Value: Integer): Integer; +asm + {$IFDEF CPU32} + // --> EAX Target + // EDX Value + // <-- EAX Result + MOV ECX, EAX + NEG EDX + MOV EAX, EDX + LOCK XADD [ECX], EAX + ADD EAX, EDX + {$ENDIF CPU32} + {$IFDEF CPU64} + // --> RCX Target + // EDX Value + // <-- EAX Result + NEG EDX + MOV EAX, EDX + LOCK XADD [RCX], EAX + ADD EAX, EDX + {$ENDIF CPU64} +end; + +{$IFDEF CPU64} + +// Locked Int64 manipulation +function LockedAdd(var Target: Int64; Value: Int64): Int64; +asm + // --> RCX Target + // RDX Value + // <-- RAX Result + MOV RAX, RDX + LOCK XADD [RCX], RAX + ADD RAX, RDX +end; + +function LockedCompareExchange(var Target: Int64; Exch, Comp: Int64): Int64; +asm + // --> RCX Target + // RDX Exch + // R8 Comp + // <-- RAX Result + MOV RAX, R8 + LOCK CMPXCHG [RCX], RDX +end; + +function LockedDec(var Target: Int64): Int64; +asm + // --> RCX Target + // <-- RAX Result + MOV RAX, -1 + LOCK XADD [RCX], RAX + DEC RAX +end; + +function LockedExchange(var Target: Int64; Value: Int64): Int64; +asm + // --> RCX Target + // RDX Value + // <-- RAX Result + MOV RAX, RDX + LOCK XCHG [RCX], RAX +end; + +function LockedExchangeAdd(var Target: Int64; Value: Int64): Int64; +asm + // --> RCX Target + // RDX Value + // <-- RAX Result + MOV RAX, RDX + LOCK XADD [RCX], RAX +end; + +function LockedExchangeDec(var Target: Int64): Int64; +asm + // --> RCX Target + // <-- RAX Result + MOV RAX, -1 + LOCK XADD [RCX], RAX +end; + +function LockedExchangeInc(var Target: Int64): Int64; +asm + // --> RCX Target + // <-- RAX Result + MOV RAX, 1 + LOCK XADD [RCX], RAX +end; + +function LockedExchangeSub(var Target: Int64; Value: Int64): Int64; +asm + // --> RCX Target + // RDX Value + // <-- RAX Result + NEG RDX + MOV RAX, RDX + LOCK XADD [RCX], RAX +end; + +function LockedInc(var Target: Int64): Int64; +asm + // --> RCX Target + // <-- RAX Result + MOV RAX, 1 + LOCK XADD [RCX], RAX + INC RAX +end; + +function LockedSub(var Target: Int64; Value: Int64): Int64; +asm + // --> RCX Target + // RDX Value + // <-- RAX Result + NEG RDX + MOV RAX, RDX + LOCK XADD [RCX], RAX + ADD RAX, RDX +end; + +{$IFDEF BORLAND} + +function LockedDec(var Target: NativeInt): NativeInt; +asm + // --> RCX Target + // <-- RAX Result + MOV RAX, -1 + LOCK XADD [RCX], RAX + DEC RAX +end; + +function LockedInc(var Target: NativeInt): NativeInt; +asm + // --> RCX Target + // <-- RAX Result + MOV RAX, 1 + LOCK XADD [RCX], RAX + INC RAX +end; + +{$ENDIF BORLAND} + +{$ENDIF CPU64} + +//=== { TJclDispatcherObject } =============================================== + +function MapSignalResult(const Ret: DWORD): TJclWaitResult; +begin + case Ret of + WAIT_ABANDONED: + Result := wrAbandoned; + WAIT_OBJECT_0: + Result := wrSignaled; + WAIT_TIMEOUT: + Result := wrTimeout; + WAIT_IO_COMPLETION: + Result := wrIoCompletion; + WAIT_FAILED: + Result := wrError; + else + Result := wrError; + end; +end; + +constructor TJclDispatcherObject.Attach(AHandle: TJclWaitHandle); +begin + inherited Create; + FExisted := True; + FHandle := AHandle; + FName := ''; +end; + +destructor TJclDispatcherObject.Destroy; +begin + CloseHandle(FHandle); + inherited Destroy; +end; + +{ TODO: Use RTDL Version of SignalObjectAndWait } + +function TJclDispatcherObject.SignalAndWait(const Obj: TJclDispatcherObject; + TimeOut: Cardinal; Alertable: Boolean): TJclWaitResult; +begin + // Note: Do not make this method virtual! It's only available on NT 4 up... + Result := MapSignalResult(Cardinal({$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.SignalObjectAndWait(Obj.Handle, Handle, TimeOut, Alertable))); +end; + +function TJclDispatcherObject.WaitAlertable(const TimeOut: Cardinal): TJclWaitResult; +begin + Result := MapSignalResult({$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.WaitForSingleObjectEx(FHandle, TimeOut, True)); +end; + +function TJclDispatcherObject.WaitFor(const TimeOut: Cardinal): TJclWaitResult; +begin + Result := MapSignalResult({$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.WaitForSingleObject(FHandle, TimeOut)); +end; + +function TJclDispatcherObject.WaitForever: TJclWaitResult; +begin + Result := WaitFor(INFINITE); +end; + +// Wait functions +function WaitForMultipleObjects(const Objects: array of TJclDispatcherObject; + WaitAll: Boolean; TimeOut: Cardinal): Cardinal; +var + Handles: array of TJclWaitHandle; + I, Count: Integer; +begin + Count := High(Objects) + 1; + SetLength(Handles, Count); + for I := 0 to Count - 1 do + Handles[I] := Objects[I].Handle; + Result := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.WaitForMultipleObjects(Count, @Handles[0], WaitAll, TimeOut); +end; + +function WaitAlertableForMultipleObjects(const Objects: array of TJclDispatcherObject; + WaitAll: Boolean; TimeOut: Cardinal): Cardinal; +var + Handles: array of TJclWaitHandle; + I, Count: Integer; +begin + Count := High(Objects) + 1; + SetLength(Handles, Count); + for I := 0 to Count - 1 do + Handles[I] := Objects[I].Handle; + Result := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.WaitForMultipleObjectsEx(Count, @Handles[0], WaitAll, TimeOut, True); +end; + +//=== { TJclCriticalSection } ================================================ + +constructor TJclCriticalSection.Create; +begin + inherited Create; + {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.InitializeCriticalSection(FCriticalSection); +end; + +destructor TJclCriticalSection.Destroy; +begin + {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.DeleteCriticalSection(FCriticalSection); + inherited Destroy; +end; + +class procedure TJclCriticalSection.CreateAndEnter(var CS: TJclCriticalSection); +var + NewCritSect: TJclCriticalSection; +begin + NewCritSect := TJclCriticalSection.Create; + if LockedCompareExchange(Pointer(CS), Pointer(NewCritSect), nil) <> nil then + begin + // LoadInProgress was <> nil -> no exchange took place, free the CS + NewCritSect.Free; + end; + CS.Enter; +end; + +procedure TJclCriticalSection.Enter; +begin + {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.EnterCriticalSection(FCriticalSection); +end; + +procedure TJclCriticalSection.Leave; +begin + {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.LeaveCriticalSection(FCriticalSection); +end; + +//== { TJclCriticalSectionEx } =============================================== + +const + DefaultCritSectSpinCount = 4000; + +constructor TJclCriticalSectionEx.Create; +begin + CreateEx(DefaultCritSectSpinCount, False); +end; + +{ TODO: Use RTDL Version of InitializeCriticalSectionAndSpinCount } + +constructor TJclCriticalSectionEx.CreateEx(SpinCount: Cardinal; + NoFailEnter: Boolean); +begin + FSpinCount := SpinCount; + if NoFailEnter then + SpinCount := SpinCount or Cardinal($80000000); + + if not InitializeCriticalSectionAndSpinCount(FCriticalSection, SpinCount) then + raise EJclCriticalSectionError.CreateRes(@RsSynchInitCriticalSection); +end; + +{$IFNDEF WINSCP} +function TJclCriticalSectionEx.GetSpinCount: Cardinal; +begin + // Spinning only makes sense on multiprocessor systems. On a single processor + // system the thread would simply waste cycles while the owning thread is + // suspended and thus cannot release the critical section. + if ProcessorCount = 1 then + Result := 0 + else + Result := FSpinCount; +end; + +class function TJclCriticalSectionEx.GetSpinTimeOut: Cardinal; +begin + Result := Cardinal(RegReadInteger(HKEY_LOCAL_MACHINE, RegSessionManager, + RegCritSecTimeout)); +end; + +{ TODO: Use RTLD version of SetCriticalSectionSpinCount } +procedure TJclCriticalSectionEx.SetSpinCount(const Value: Cardinal); +begin + FSpinCount := SetCriticalSectionSpinCount(FCriticalSection, Value); +end; + +class procedure TJclCriticalSectionEx.SetSpinTimeOut(const Value: Cardinal); +begin + RegWriteInteger(HKEY_LOCAL_MACHINE, RegSessionManager, RegCritSecTimeout, + Integer(Value)); +end; +{$ENDIF ~WINSCP} + +{ TODO: Use RTLD version of TryEnterCriticalSection } +function TJclCriticalSectionEx.TryEnter: Boolean; +begin + Result := TryEnterCriticalSection(FCriticalSection); +end; + +//== { TJclEvent } =========================================================== + +constructor TJclEvent.Create(SecAttr: PSecurityAttributes; Manual, Signaled: Boolean; const Name: string); +begin + inherited Create; + FName := Name; + FHandle := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.CreateEvent(SecAttr, Manual, Signaled, PChar(FName)); + if FHandle = 0 then + raise EJclEventError.CreateRes(@RsSynchCreateEvent); + FExisted := GetLastError = ERROR_ALREADY_EXISTS; +end; + +constructor TJclEvent.Open(Access: Cardinal; Inheritable: Boolean; + const Name: string); +begin + FName := Name; + FExisted := True; + FHandle := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.OpenEvent(Access, Inheritable, PChar(Name)); + if FHandle = 0 then + raise EJclEventError.CreateRes(@RsSynchOpenEvent); +end; + +function TJclEvent.Pulse: Boolean; +begin + Result := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.PulseEvent(FHandle); +end; + +function TJclEvent.ResetEvent: Boolean; +begin + Result := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.ResetEvent(FHandle); +end; + +function TJclEvent.SetEvent: Boolean; +begin + Result := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.SetEvent(FHandle); +end; + +//=== { TJclWaitableTimer } ================================================== + +{ TODO: Use RTLD version of CreateWaitableTimer } +constructor TJclWaitableTimer.Create(SecAttr: PSecurityAttributes; + Manual: Boolean; const Name: string); +begin + FName := Name; + FResume := False; + FHandle := CreateWaitableTimer(SecAttr, Manual, PChar(Name)); + if FHandle = 0 then + raise EJclWaitableTimerError.CreateRes(@RsSynchCreateWaitableTimer); + FExisted := GetLastError = ERROR_ALREADY_EXISTS; +end; + +{ TODO: Use RTLD version of CancelWaitableTimer } +function TJclWaitableTimer.Cancel: Boolean; +begin + Result := CancelWaitableTimer(FHandle); +end; + +{ TODO: Use RTLD version of OpenWaitableTimer } + +constructor TJclWaitableTimer.Open(Access: Cardinal; Inheritable: Boolean; + const Name: string); +begin + FExisted := True; + FName := Name; + FResume := False; + FHandle := OpenWaitableTimer(Access, Inheritable, PChar(Name)); + if FHandle = 0 then + raise EJclWaitableTimerError.CreateRes(@RsSynchOpenWaitableTimer); +end; + +{ TODO: Use RTLD version of SetWaitableTimer } +function TJclWaitableTimer.SetTimer(const DueTime: Int64; Period: Longint; + Resume: Boolean): Boolean; +var + DT: Int64; +begin + DT := DueTime; + FResume := Resume; + Result := SetWaitableTimer(FHandle, DT, Period, nil, nil, FResume); +end; + +{ TODO -cHelp : OS restrictions } +function TJclWaitableTimer.SetTimerApc(const DueTime: Int64; Period: Longint; + Resume: Boolean; Apc: TFNTimerAPCRoutine; Arg: Pointer): Boolean; +var + DT: Int64; +begin + DT := DueTime; + FResume := Resume; + Result := RtdlSetWaitableTimer(FHandle, DT, Period, Apc, Arg, FResume); + { TODO : Exception for Win9x, older WinNT? } + // if not Result and (GetLastError = ERROR_CALL_NOT_IMPLEMENTED) then + // RaiseLastOSError; +end; + +//== { TJclSemaphore } ======================================================= + +constructor TJclSemaphore.Create(SecAttr: PSecurityAttributes; + Initial, Maximum: Integer; const Name: string); +begin + Assert((Initial >= 0) and (Maximum > 0)); + FName := Name; + FHandle := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.CreateSemaphore(SecAttr, Initial, Maximum, PChar(Name)); + if FHandle = 0 then + raise EJclSemaphoreError.CreateRes(@RsSynchCreateSemaphore); + FExisted := GetLastError = ERROR_ALREADY_EXISTS; +end; + +constructor TJclSemaphore.Open(Access: Cardinal; Inheritable: Boolean; + const Name: string); +begin + FName := Name; + FExisted := True; + FHandle := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.OpenSemaphore(Access, Inheritable, PChar(Name)); + if FHandle = 0 then + raise EJclSemaphoreError.CreateRes(@RsSynchOpenSemaphore); +end; + +function TJclSemaphore.ReleasePrev(ReleaseCount: Longint; + var PrevCount: Longint): Boolean; +begin + Result := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.ReleaseSemaphore(FHandle, ReleaseCount, @PrevCount); +end; + +function TJclSemaphore.Release(ReleaseCount: Integer): Boolean; +begin + Result := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.ReleaseSemaphore(FHandle, ReleaseCount, nil); +end; + +//=== { TJclMutex } ========================================================== + +function TJclMutex.Acquire(const TimeOut: Cardinal): Boolean; +begin + Result := WaitFor(TimeOut) = wrSignaled; +end; + +constructor TJclMutex.Create(SecAttr: PSecurityAttributes; InitialOwner: Boolean; const Name: string); +begin + inherited Create; + FName := Name; + FHandle := JclWin32.CreateMutex(SecAttr, Ord(InitialOwner), PChar(Name)); + if FHandle = 0 then + raise EJclMutexError.CreateRes(@RsSynchCreateMutex); + FExisted := GetLastError = ERROR_ALREADY_EXISTS; +end; + +constructor TJclMutex.Open(Access: Cardinal; Inheritable: Boolean; const Name: string); +begin + inherited Create; + FName := Name; + FExisted := True; + FHandle := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.OpenMutex(Access, Inheritable, PChar(Name)); + if FHandle = 0 then + raise EJclMutexError.CreateRes(@RsSynchOpenMutex); +end; + +function TJclMutex.Release: Boolean; +begin + Result := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.ReleaseMutex(FHandle); +end; + +{$IFNDEF WINSCP} + +//=== { TJclOptex } ========================================================== + +constructor TJclOptex.Create(const Name: string; SpinCount: Integer); +begin + FExisted := False; + FName := Name; + if Name = '' then + begin + // None shared optex, don't need filemapping, sharedinfo is local + FFileMapping := 0; + FEvent := TJclEvent.Create(nil, False, False, ''); + FSharedInfo := AllocMem(SizeOf(TOptexSharedInfo)); + end + else + begin + // Shared optex, event protects access to sharedinfo. Creation of filemapping + // doesn't need protection as it will automatically "open" instead of "create" + // if another process already created it. + FEvent := TJclEvent.Create(nil, False, False, 'Optex_Event_' + Name); + FExisted := FEvent.Existed; + FFileMapping := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.CreateFileMapping(INVALID_HANDLE_VALUE, nil, PAGE_READWRITE, + 0, SizeOf(TOptexSharedInfo), PChar('Optex_MMF_' + Name)); + Assert(FFileMapping <> 0); + FSharedInfo := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.MapViewOfFile(FFileMapping, FILE_MAP_WRITE, 0, 0, 0); + Assert(FSharedInfo <> nil); + end; + SetSpinCount(SpinCount); +end; + +destructor TJclOptex.Destroy; +begin + FreeAndNil(FEvent); + if UniProcess then + FreeMem(FSharedInfo) + else + begin + {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.UnmapViewOfFile(FSharedInfo); + {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.CloseHandle(FFileMapping); + end; + inherited Destroy; +end; + +procedure TJclOptex.Enter; +var + ThreadId: Longword; +begin + if TryEnter then + Exit; + ThreadId := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.GetCurrentThreadId; + if {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.InterlockedIncrement(FSharedInfo^.LockCount) = 1 then + begin + // Optex was unowned + FSharedInfo^.ThreadId := ThreadId; + FSharedInfo^.RecursionCount := 1; + end + else + begin + if FSharedInfo^.ThreadId = ThreadId then + begin + // We already owned it, increase ownership count + Inc(FSharedInfo^.RecursionCount) + end + else + begin + // Optex is owner by someone else, wait for it to be released and then + // immediately take ownership + FEvent.WaitForever; + FSharedInfo^.ThreadId := ThreadId; + FSharedInfo^.RecursionCount := 1; + end; + end; +end; + +function TJclOptex.GetSpinCount: Integer; +begin + Result := FSharedInfo^.SpinCount; +end; + +function TJclOptex.GetUniProcess: Boolean; +begin + Result := FFileMapping = 0; +end; + +procedure TJclOptex.Leave; +begin + Dec(FSharedInfo^.RecursionCount); + if FSharedInfo^.RecursionCount > 0 then + {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.InterlockedDecrement(FSharedInfo^.LockCount) + else + begin + FSharedInfo^.ThreadId := 0; + if {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.InterlockedDecrement(FSharedInfo^.LockCount) > 0 then + FEvent.SetEvent; + end; +end; + +procedure TJclOptex.SetSpinCount(Value: Integer); +begin + if Value < 0 then + Value := DefaultCritSectSpinCount; + // Spinning only makes sense on multiprocessor systems + if ProcessorCount > 1 then + {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.InterlockedExchange(Integer(FSharedInfo^.SpinCount), Value); +end; + +function TJclOptex.TryEnter: Boolean; +var + ThreadId: Longword; + ThreadOwnsOptex: Boolean; + SpinCount: Integer; +begin + ThreadId := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.GetCurrentThreadId; + SpinCount := FSharedInfo^.SpinCount; + repeat + //ThreadOwnsOptex := InterlockedCompareExchange(Pointer(FSharedInfo^.LockCount), + // Pointer(1), Pointer(0)) = Pointer(0); // not available on win95 + ThreadOwnsOptex := LockedCompareExchange(FSharedInfo^.LockCount, 1, 0) = 0; + if ThreadOwnsOptex then + begin + // Optex was unowned + FSharedInfo^.ThreadId := ThreadId; + FSharedInfo^.RecursionCount := 1; + end + else + begin + if FSharedInfo^.ThreadId = ThreadId then + begin + // We already owned the Optex + {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.InterlockedIncrement(FSharedInfo^.LockCount); + Inc(FSharedInfo^.RecursionCount); + ThreadOwnsOptex := True; + end; + end; + Dec(SpinCount); + until ThreadOwnsOptex or (SpinCount <= 0); + Result := ThreadOwnsOptex; +end; + +{$ENDIF ~WINSCP} + +//=== { TJclMultiReadExclusiveWrite } ======================================== + +constructor TJclMultiReadExclusiveWrite.Create(Preferred: TMrewPreferred); +begin + inherited Create; + FLock := TJclCriticalSection.Create; + FPreferred := Preferred; + FSemReaders := TJclSemaphore.Create(nil, 0, MaxInt, ''); + FSemWriters := TJclSemaphore.Create(nil, 0, MaxInt, ''); + SetLength(FThreads, 0); + FState := 0; + FWaitingReaders := 0; + FWaitingWriters := 0; +end; + +destructor TJclMultiReadExclusiveWrite.Destroy; +begin + FreeAndNil(FSemReaders); + FreeAndNil(FSemWriters); + FreeAndNil(FLock); + inherited Destroy; +end; + +procedure TJclMultiReadExclusiveWrite.AddToThreadList(ThreadId: Longword; + Reader: Boolean); +var + L: Integer; +begin + // Caller must own lock + L := Length(FThreads); + SetLength(FThreads, L + 1); + FThreads[L].ThreadId := ThreadId; + FThreads[L].RecursionCount := 1; + FThreads[L].Reader := Reader; +end; + +procedure TJclMultiReadExclusiveWrite.BeginRead; +var + ThreadId: Longword; + Index: Integer; + MustWait: Boolean; +begin + MustWait := False; + ThreadId := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.GetCurrentThreadId; + FLock.Enter; + try + Index := FindThread(ThreadId); + if Index >= 0 then + begin + // Thread is on threadslist so it is already reading + Inc(FThreads[Index].RecursionCount); + end + else + begin + // Request to read (first time) + AddToThreadList(ThreadId, True); + if FState >= 0 then + begin + // MREW is unowned or only readers. If there are no waiting writers or + // readers are preferred then allow thread to continue, otherwise it must + // wait it's turn + if (FPreferred = mpReaders) or (FWaitingWriters = 0) then + Inc(FState) + else + begin + Inc(FWaitingReaders); + MustWait := True; + end; + end + else + begin + // MREW is owner by a writer, must wait + Inc(FWaitingReaders); + MustWait := True; + end; + end; + finally + FLock.Leave; + end; + if MustWait then + FSemReaders.WaitForever; +end; + +procedure TJclMultiReadExclusiveWrite.BeginWrite; +var + ThreadId: Longword; + Index: Integer; + MustWait: Boolean; +begin + MustWait := False; + FLock.Enter; + try + ThreadId := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.GetCurrentThreadId; + Index := FindThread(ThreadId); + if Index < 0 then + begin + // Request to write (first time) + AddToThreadList(ThreadId, False); + if FState = 0 then + begin + // MREW is unowned so start writing + FState := -1; + end + else + begin + // MREW is owner, must wait + Inc(FWaitingWriters); + MustWait := True; + end; + end + else + begin + if FThreads[Index].Reader then + begin + // Request to write while reading + Inc(FThreads[Index].RecursionCount); + FThreads[Index].Reader := False; + Dec(FState); + if FState = 0 then + begin + // MREW is unowned so start writing + FState := -1; + end + else + begin + // MREW is owned, must wait + MustWait := True; + Inc(FWaitingWriters); + end; + end + else + // Requesting to write while already writing + Inc(FThreads[Index].RecursionCount); + end; + finally + FLock.Leave; + end; + if MustWait then + FSemWriters.WaitFor(INFINITE); +end; + +procedure TJclMultiReadExclusiveWrite.EndRead; +begin + Release; +end; + +procedure TJclMultiReadExclusiveWrite.EndWrite; +begin + Release; +end; + +function TJclMultiReadExclusiveWrite.FindThread(ThreadId: Longword): Integer; +var + I: Integer; +begin + // Caller must lock + Result := -1; + for I := 0 to Length(FThreads) - 1 do + if FThreads[I].ThreadId = ThreadId then + begin + Result := I; + Exit; + end; +end; + +procedure TJclMultiReadExclusiveWrite.Release; +var + ThreadId: Longword; + Index: Integer; + WasReading: Boolean; +begin + ThreadId := GetCurrentThreadId; + FLock.Enter; + try + Index := FindThread(ThreadId); + if Index >= 0 then + begin + Dec(FThreads[Index].RecursionCount); + if FThreads[Index].RecursionCount = 0 then + begin + WasReading := FThreads[Index].Reader; + if WasReading then + Dec(FState) + else + FState := 0; + RemoveFromThreadList(Index); + if FState = 0 then + ReleaseWaiters(WasReading); + end; + end; + finally + FLock.Leave; + end; +end; + +procedure TJclMultiReadExclusiveWrite.ReleaseWaiters(WasReading: Boolean); +var + ToRelease: TMrewPreferred; +begin + // Caller must Lock + ToRelease := mpEqual; + case FPreferred of + mpReaders: + if FWaitingReaders > 0 then + ToRelease := mpReaders + else + if FWaitingWriters > 0 then + ToRelease := mpWriters; + mpWriters: + if FWaitingWriters > 0 then + ToRelease := mpWriters + else + if FWaitingReaders > 0 then + ToRelease := mpReaders; + mpEqual: + if WasReading then + begin + if FWaitingWriters > 0 then + ToRelease := mpWriters + else + if FWaitingReaders > 0 then + ToRelease := mpReaders; + end + else + begin + if FWaitingReaders > 0 then + ToRelease := mpReaders + else + if FWaitingWriters > 0 then + ToRelease := mpWriters; + end; + end; + case ToRelease of + mpReaders: + begin + FState := FWaitingReaders; + FWaitingReaders := 0; + FSemReaders.Release(FState); + end; + mpWriters: + begin + FState := -1; + Dec(FWaitingWriters); + FSemWriters.Release(1); + end; + mpEqual: + // no waiters + end; +end; + +procedure TJclMultiReadExclusiveWrite.RemoveFromThreadList(Index: Integer); +var + L: Integer; +begin + // Caller must Lock + L := Length(FThreads); + if Index < (L - 1) then + Move(FThreads[Index + 1], FThreads[Index], SizeOf(TMrewThreadInfo) * (L - Index - 1)); + SetLength(FThreads, L - 1); +end; + +//=== { TJclMeteredSection } ================================================= + +const + MAX_METSECT_NAMELEN = 128; + +constructor TJclMeteredSection.Create(InitialCount, MaxCount: Integer; const Name: string); +begin + if (MaxCount < 1) or (InitialCount > MaxCount) or (InitialCount < 0) or + (Length(Name) > MAX_METSECT_NAMELEN) then + raise EJclMeteredSectionError.CreateRes(@RsMetSectInvalidParameter); + FMetSect := PMeteredSection(AllocMem(SizeOf(TMeteredSection))); + if FMetSect <> nil then + begin + if not InitMeteredSection(InitialCount, MaxCount, Name, False) then + begin + CloseMeteredSection; + FMetSect := nil; + raise EJclMeteredSectionError.CreateRes(@RsMetSectInitialize); + end; + end; +end; + +constructor TJclMeteredSection.Open(const Name: string); +begin + FMetSect := nil; + if Name = '' then + raise EJclMeteredSectionError.CreateRes(@RsMetSectNameEmpty); + FMetSect := PMeteredSection(AllocMem(SizeOf(TMeteredSection))); + Assert(FMetSect <> nil); + if not InitMeteredSection(0, 0, Name, True) then + begin + CloseMeteredSection; + FMetSect := nil; + raise EJclMeteredSectionError.CreateRes(@RsMetSectInitialize); + end; +end; + +destructor TJclMeteredSection.Destroy; +begin + CloseMeteredSection; + inherited Destroy; +end; + +procedure TJclMeteredSection.AcquireLock; +begin + while {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.InterlockedExchange(FMetSect^.SharedInfo^.SpinLock, 1) <> 0 do + {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.Sleep(0); +end; + +procedure TJclMeteredSection.CloseMeteredSection; +begin + if FMetSect <> nil then + begin + if FMetSect^.SharedInfo <> nil then + {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.UnmapViewOfFile(FMetSect^.SharedInfo); + if FMetSect^.FileMap <> 0 then + {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.CloseHandle(FMetSect^.FileMap); + if FMetSect^.Event <> 0 then + {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.CloseHandle(FMetSect^.Event); + FreeMem(FMetSect); + end; +end; + +function TJclMeteredSection.CreateMetSectEvent(const Name: string; OpenOnly: Boolean): Boolean; +var + FullName: string; +begin + if Name = '' then + FMetSect^.Event := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.CreateEvent(nil, False, False, nil) + else + begin + FullName := 'JCL_MSECT_EVT_' + Name; + if OpenOnly then + FMetSect^.Event := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.OpenEvent(0, False, PChar(FullName)) + else + FMetSect^.Event := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.CreateEvent(nil, False, False, PChar(FullName)); + end; + Result := FMetSect^.Event <> 0; +end; + +function TJclMeteredSection.CreateMetSectFileView(InitialCount, MaxCount: Longint; + const Name: string; OpenOnly: Boolean): Boolean; +var + FullName: string; + LastError: DWORD; +begin + Result := False; + if Name = '' then + FMetSect^.FileMap := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.CreateFileMapping(INVALID_HANDLE_VALUE, nil, PAGE_READWRITE, 0, SizeOf(TMetSectSharedInfo), nil) + else + begin + FullName := 'JCL_MSECT_MMF_' + Name; + if OpenOnly then + FMetSect^.FileMap := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.OpenFileMapping(0, False, PChar(FullName)) + else + FMetSect^.FileMap := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.CreateFileMapping(INVALID_HANDLE_VALUE, nil, PAGE_READWRITE, 0, SizeOf(TMetSectSharedInfo), PChar(FullName)); + end; + if FMetSect^.FileMap <> 0 then + begin + LastError := GetLastError; + FMetSect^.SharedInfo := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.MapViewOfFile(FMetSect^.FileMap, FILE_MAP_WRITE, 0, 0, 0); + if FMetSect^.SharedInfo <> nil then + begin + if LastError = ERROR_ALREADY_EXISTS then + while not FMetSect^.SharedInfo^.Initialized do Sleep(0) + else + begin + FMetSect^.SharedInfo^.SpinLock := 0; + FMetSect^.SharedInfo^.ThreadsWaiting := 0; + FMetSect^.SharedInfo^.AvailableCount := InitialCount; + FMetSect^.SharedInfo^.MaximumCount := MaxCount; + {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.InterlockedExchange(Integer(FMetSect^.SharedInfo^.Initialized), 1); + end; + Result := True; + end; + end; +end; + +function TJclMeteredSection.Enter(TimeOut: Longword): TJclWaitResult; +begin + Result := wrSignaled; + while Result = wrSignaled do + begin + AcquireLock; + try + if FMetSect^.SharedInfo^.AvailableCount >= 1 then + begin + Dec(FMetSect^.SharedInfo^.AvailableCount); + Result := MapSignalResult(WAIT_OBJECT_0); + Exit; + end; + Inc(FMetSect^.SharedInfo^.ThreadsWaiting); + {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.ResetEvent(FMetSect^.Event); + finally + ReleaseLock; + end; + Result := MapSignalResult({$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.WaitForSingleObject(FMetSect^.Event, TimeOut)); + end; +end; + +function TJclMeteredSection.InitMeteredSection(InitialCount, MaxCount: Longint; + const Name: string; OpenOnly: Boolean): Boolean; +begin + Result := False; + if CreateMetSectEvent(Name, OpenOnly) then + Result := CreateMetSectFileView(InitialCount, MaxCount, Name, OpenOnly); +end; + +function TJclMeteredSection.Leave(ReleaseCount: Integer; out PrevCount: Integer): Boolean; +var + Count: Integer; +begin + Result := False; + AcquireLock; + try + PrevCount := FMetSect^.SharedInfo^.AvailableCount; + if (ReleaseCount < 0) or + (FMetSect^.SharedInfo^.AvailableCount + ReleaseCount > FMetSect^.SharedInfo^.MaximumCount) then + begin + {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.SetLastError(ERROR_INVALID_PARAMETER); + Exit; + end; + Inc(FMetSect^.SharedInfo^.AvailableCount, ReleaseCount); + ReleaseCount := Min(ReleaseCount, FMetSect^.SharedInfo^.ThreadsWaiting); + if FMetSect^.SharedInfo^.ThreadsWaiting > 0 then + begin + for Count := 0 to ReleaseCount - 1 do + begin + Dec(FMetSect^.SharedInfo^.ThreadsWaiting); + {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.SetEvent(FMetSect^.Event); + end; + end; + finally + ReleaseLock; + end; + Result := True; +end; + +function TJclMeteredSection.Leave(ReleaseCount: Integer): Boolean; +var + Previous: Longint; +begin + Result := Leave(ReleaseCount, Previous); +end; + +procedure TJclMeteredSection.ReleaseLock; +begin + {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.InterlockedExchange(FMetSect^.SharedInfo^.SpinLock, 0); +end; + +//=== Debugging ============================================================== + +function QueryCriticalSection(CS: TJclCriticalSection; var Info: TRTLCriticalSection): Boolean; +begin + Result := CS <> nil; + if Result then + Info := CS.FCriticalSection; +end; + +// Native API functions +// http://undocumented.ntinternals.net/ + +{ TODO: RTLD version } + +type + TNtQueryProc = function (Handle: THandle; InfoClass: Byte; Info: Pointer; + Len: Longint; ResLen: PLongint): Longint; stdcall; + +var + _QueryEvent: TNtQueryProc = nil; + _QueryMutex: TNtQueryProc = nil; + _QuerySemaphore: TNtQueryProc = nil; + _QueryTimer: TNtQueryProc = nil; + +function CallQueryProc(var P: TNtQueryProc; const Name: string; Handle: THandle; + Info: Pointer; InfoSize: Longint): Boolean; +var + NtDll: THandle; + Status: Longint; +begin + Result := False; + if @P = nil then + begin + NtDll := GetModuleHandle(PChar('ntdll.dll')); + if NtDll <> 0 then + @P := GetProcAddress(NtDll, PChar(Name)); + end; + if @P <> nil then + begin + Status := P(Handle, 0, Info, InfoSize, nil); + Result := (Status and $80000000) = 0; + end; +end; + +function QueryEvent(Handle: THandle; var Info: TEventInfo): Boolean; +begin + Result := CallQueryProc(_QueryEvent, 'NtQueryEvent', Handle, @Info, SizeOf(Info)); +end; + +function QueryMutex(Handle: THandle; var Info: TMutexInfo): Boolean; +begin + Result := CallQueryProc(_QueryMutex, 'NtQueryMutex', Handle, @Info, SizeOf(Info)); +end; + +function QuerySemaphore(Handle: THandle; var Info: TSemaphoreCounts): Boolean; +begin + Result := CallQueryProc(_QuerySemaphore, 'NtQuerySemaphore', Handle, @Info, SizeOf(Info)); +end; + +function QueryTimer(Handle: THandle; var Info: TTimerInfo): Boolean; +begin + Result := CallQueryProc(_QueryTimer, 'NtQueryTimer', Handle, @Info, SizeOf(Info)); +end; + +function ValidateMutexName(const aName: string): string; +const cMutexMaxName = 200; +begin + if Length(aName) > cMutexMaxName then + Result := Copy (aName, Length(aName)-cMutexMaxName, cMutexMaxName) + else + Result := aName; + Result := StrReplaceChar(Result, '\', '_'); +end; + + + +{$IFDEF UNITVERSIONING} +initialization + RegisterUnitVersion(HInstance, UnitVersioning); + +finalization + UnregisterUnitVersion(HInstance); +{$ENDIF UNITVERSIONING} + +end. diff --git a/source/packages/jcl/JclSysInfo.pas b/source/packages/jcl/JclSysInfo.pas new file mode 100644 index 00000000..667a7bdf --- /dev/null +++ b/source/packages/jcl/JclSysInfo.pas @@ -0,0 +1,6026 @@ +{**************************************************************************************************} +{ } +{ Project JEDI Code Library (JCL) } +{ } +{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); } +{ you may not use this file except in compliance with the License. You may obtain a copy of the } +{ License at http://www.mozilla.org/MPL/ } +{ } +{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF } +{ ANY KIND, either express or implied. See the License for the specific language governing rights } +{ and limitations under the License. } +{ } +{ The Original Code is JclSysInfo.pas. } +{ } +{ The Initial Developer of the Original Code is Marcel van Brakel. } +{ Portions created by Marcel van Brakel are Copyright (C) Marcel van Brakel. All rights reserved. } +{ } +{ Contributors: } +{ Alexander Radchenko } +{ Andre Snepvangers (asnepvangers) } +{ Azret Botash } +{ Bryan Coutch } +{ Carl Clark } +{ Eric S. Fisher } +{ Florent Ouchet (outchy) } +{ Heiko Adams } +{ James Azarja } +{ Jean-Fabien Connault (cycocrew) } +{ John C Molyneux } +{ Marcel van Brakel } +{ Matthias Thoma (mthoma) } +{ Mike Lischke } +{ Nick Hodges } +{ Olivier Sannier (obones) } +{ Peter Friese } +{ Peter Thornquist (peter3) } +{ Petr Vones (pvones) } +{ Rik Barker } +{ Robert Marquardt (marquardt) } +{ Robert Rossmair (rrossmair) } +{ Scott Price } +{ Tom Hahn (tomhahn) } +{ Wim de Cleen } +{ } +{**************************************************************************************************} +{ } +{ This unit contains routines and classes to retrieve various pieces of system information. } +{ Examples are the location of standard folders, settings of environment variables, processor } +{ details and the Windows version. } +{ } +{**************************************************************************************************} +{ } +{ Last modified: $Date:: $ } +{ Revision: $Rev:: $ } +{ Author: $Author:: $ } +{ } +{**************************************************************************************************} + +// Windows NT 4 and earlier do not support GetSystemPowerStatus (while introduced +// in NT4 - it is a stub there - implemented in Windows 2000 and later. + + +unit JclSysInfo; + +{$I jcl.inc} + +interface + +uses + {$IFDEF UNITVERSIONING} + JclUnitVersioning, + {$ENDIF UNITVERSIONING} + {$IFDEF HAS_UNIT_LIBC} + Libc, + {$ENDIF HAS_UNIT_LIBC} + {$IFDEF HAS_UNITSCOPE} + {$IFDEF MSWINDOWS} + Winapi.Windows, WinApi.ActiveX, Winapi.ShlObj, + {$ENDIF MSWINDOWS} + System.Classes, + {$ELSE ~HAS_UNITSCOPE} + {$IFDEF MSWINDOWS} + Windows, ActiveX, ShlObj, + {$ENDIF MSWINDOWS} + Classes, + {$ENDIF ~HAS_UNITSCOPE} + JclBase, JclResources; + +// Environment Variables +{$IFDEF MSWINDOWS} +type + TEnvironmentOption = (eoLocalMachine, eoCurrentUser, eoAdditional); + TEnvironmentOptions = set of TEnvironmentOption; +{$ENDIF MSWINDOWS} + +function DelEnvironmentVar(const Name: string): Boolean; +function ExpandEnvironmentVar(var Value: string): Boolean; +function ExpandEnvironmentVarCustom(var Value: string; Vars: TStrings): Boolean; +function GetEnvironmentVar(const Name: string; out Value: string): Boolean; overload; +function GetEnvironmentVar(const Name: string; out Value: string; Expand: Boolean): Boolean; overload; +{$IFNDEF WINSCP} +function GetEnvironmentVars(const Vars: TStrings): Boolean; overload; +function GetEnvironmentVars(const Vars: TStrings; Expand: Boolean): Boolean; overload; +{$ENDIF ~WINSCP} +function SetEnvironmentVar(const Name, Value: string): Boolean; +{$IFDEF MSWINDOWS} +{$IFNDEF WINSCP} +function CreateEnvironmentBlock(const Options: TEnvironmentOptions; const AdditionalVars: TStrings): PChar; +procedure DestroyEnvironmentBlock(var Env: PChar); +procedure SetGlobalEnvironmentVariable(VariableName, VariableContent: string); +{$ENDIF ~WINSCP} +{$ENDIF MSWINDOWS} + +// Common Folder Locations +{$IFDEF MSWINDOWS} +function GetCommonFilesFolder: string; +{$ENDIF MSWINDOWS} +function GetCurrentFolder: string; +{$IFDEF MSWINDOWS} +function GetProgramFilesFolder: string; +function GetWindowsFolder: string; +function GetWindowsSystemFolder: string; +function GetWindowsTempFolder: string; + +function GetDesktopFolder: string; +function GetProgramsFolder: string; +{$ENDIF MSWINDOWS} +{$IFNDEF WINSCP} +function GetPersonalFolder: string; +{$ENDIF ~WINSCP} +{$IFDEF MSWINDOWS} +{$IFNDEF WINSCP} +function GetFavoritesFolder: string; +function GetStartupFolder: string; +function GetRecentFolder: string; +function GetSendToFolder: string; +function GetStartmenuFolder: string; +function GetDesktopDirectoryFolder: string; +function GetCommonDocumentsFolder: string; +function GetNethoodFolder: string; +function GetFontsFolder: string; +function GetCommonStartmenuFolder: string; +function GetCommonStartupFolder: string; +function GetPrinthoodFolder: string; +function GetProfileFolder: string; +function GetCommonProgramsFolder: string; +function GetCommonDesktopdirectoryFolder: string; +function GetCommonAppdataFolder: string; +function GetAppdataFolder: string; +function GetLocalAppData: string; +function GetCommonFavoritesFolder: string; +function GetTemplatesFolder: string; +function GetInternetCacheFolder: string; +function GetCookiesFolder: string; +function GetHistoryFolder: string; +{$ENDIF ~WINSCP} + +// Advanced Power Management (APM) +type + TAPMLineStatus = (alsOffline, alsOnline, alsUnknown); + TAPMBatteryFlag = (abfHigh, abfLow, abfCritical, abfCharging, abfNoBattery, abfUnknown); + TAPMBatteryFlags = set of TAPMBatteryFlag; + +function GetAPMLineStatus: TAPMLineStatus; +function GetAPMBatteryFlag: TAPMBatteryFlag; +function GetAPMBatteryFlags: TAPMBatteryFlags; +function GetAPMBatteryLifePercent: Integer; +function GetAPMBatteryLifeTime: DWORD; +function GetAPMBatteryFullLifeTime: DWORD; + +// Identification +type + TFileSystemFlag = + ( + fsCaseSensitive, // The file system supports case-sensitive file names. + fsCasePreservedNames, // The file system preserves the case of file names when it places a name on disk. + fsSupportsUnicodeOnDisk, // The file system supports Unicode in file names as they appear on disk. + fsPersistentACLs, // The file system preserves and enforces ACLs. For example, NTFS preserves and enforces ACLs, and FAT does not. + fsSupportsFileCompression, // The file system supports file-based compression. + fsSupportsVolumeQuotas, // The file system supports disk quotas. + fsSupportsSparseFiles, // The file system supports sparse files. + fsSupportsReparsePoints, // The file system supports reparse points. + fsSupportsRemoteStorage, // ? + fsVolumeIsCompressed, // The specified volume is a compressed volume; for example, a DoubleSpace volume. + fsSupportsObjectIds, // The file system supports object identifiers. + fsSupportsEncryption, // The file system supports the Encrypted File System (EFS). + fsSupportsNamedStreams, // The file system supports named streams. + fsVolumeIsReadOnly // The specified volume is read-only. + // Windows 2000/NT and Windows Me/98/95: This value is not supported. + ); + + TFileSystemFlags = set of TFileSystemFlag; + +{$IFNDEF WINSCP} +function GetVolumeName(const Drive: string): string; +function GetVolumeSerialNumber(const Drive: string): string; +function GetVolumeFileSystem(const Drive: string): string; +function GetVolumeFileSystemFlags(const Volume: string): TFileSystemFlags; +{$ENDIF ~WINSCP} +{$ENDIF MSWINDOWS} +function GetIPAddress(const HostName: string): string; +{$IFDEF MSWINDOWS} +procedure GetIpAddresses(Results: TStrings; const HostName: AnsiString); overload; +{$ENDIF MSWINDOWS} +procedure GetIpAddresses(Results: TStrings); overload; +function GetLocalComputerName: string; +function GetLocalUserName: string; +{$IFDEF MSWINDOWS} +function GetUserDomainName(const CurUser: string): string; +function GetWorkGroupName: WideString; +{$ENDIF MSWINDOWS} +function GetDomainName: string; +{$IFDEF MSWINDOWS} +function GetRegisteredCompany: string; +function GetRegisteredOwner: string; +function GetBIOSName: string; +function GetBIOSCopyright: string; +function GetBIOSExtendedInfo: string; +{$IFNDEF WINSCP} +function GetBIOSDate: TDateTime; +{$ENDIF ~WINSCP} +{$ENDIF MSWINDOWS} + +// Processes, Tasks and Modules +type + TJclTerminateAppResult = (taError, taClean, taKill); + +function RunningProcessesList(const List: TStrings; FullPath: Boolean = True): Boolean; + +{$IFDEF MSWINDOWS} +function LoadedModulesList(const List: TStrings; ProcessID: DWORD; HandlesOnly: Boolean = False): Boolean; +function GetTasksList(const List: TStrings): Boolean; + +function ModuleFromAddr(const Addr: Pointer): HMODULE; +function IsSystemModule(const Module: HMODULE): Boolean; + +function IsMainAppWindow(Wnd: THandle): Boolean; +function IsWindowResponding(Wnd: THandle; Timeout: Integer): Boolean; + +function GetWindowIcon(Wnd: THandle; LargeIcon: Boolean): HICON; +function GetWindowCaption(Wnd: THandle): string; +function TerminateTask(Wnd: THandle; Timeout: Integer): TJclTerminateAppResult; +function TerminateApp(ProcessID: DWORD; Timeout: Integer): TJclTerminateAppResult; +{$ENDIF MSWINDOWS} + +{$IFDEF MSWINDOWS} +{.$IFNDEF FPC} +function GetPidFromProcessName(const ProcessName: string): THandle; +function GetProcessNameFromWnd(Wnd: THandle): string; +function GetProcessNameFromPid(PID: DWORD): string; +function GetMainAppWndFromPid(PID: DWORD): THandle; +function GetWndFromPid(PID: DWORD; const WindowClassName: string): HWND; +{.$ENDIF ~FPC} + +function GetShellProcessName: string; +{.$IFNDEF FPC} +function GetShellProcessHandle: THandle; +{.$ENDIF ~FPC} + +// Version Information +type + TWindowsVersion = + (wvUnknown, wvWin95, wvWin95OSR2, wvWin98, wvWin98SE, wvWinME, + wvWinNT31, wvWinNT35, wvWinNT351, wvWinNT4, wvWin2000, wvWinXP, + wvWin2003, wvWinXP64, wvWin2003R2, wvWinVista, wvWinServer2008, + wvWin7, wvWinServer2008R2, wvWin8, wvWin8RT, wvWinServer2012, wvWin81, wvWin81RT, wvWinServer2012R2); + TWindowsEdition = + (weUnknown, weWinXPHome, weWinXPPro, weWinXPHomeN, weWinXPProN, weWinXPHomeK, + weWinXPProK, weWinXPHomeKN, weWinXPProKN, weWinXPStarter, weWinXPMediaCenter, + weWinXPTablet, weWinVistaStarter, weWinVistaHomeBasic, weWinVistaHomeBasicN, + weWinVistaHomePremium, weWinVistaBusiness, weWinVistaBusinessN, + weWinVistaEnterprise, weWinVistaUltimate, weWin7Starter, weWin7HomeBasic, + weWin7HomePremium, weWin7Professional, weWin7Enterprise, weWin7Ultimate, + weWin8, weWin8Pro, weWin8Enterprise, weWin8RT, weWin81, weWin81Pro, weWin81Enterprise, weWin81RT); + TNtProductType = + (ptUnknown, ptWorkStation, ptServer, ptAdvancedServer, + ptPersonal, ptProfessional, ptDatacenterServer, ptEnterprise, ptWebEdition); + TProcessorArchitecture = + (paUnknown, // unknown processor + pax8632, // x86 32 bit processors (some P4, Celeron, Athlon and older) + pax8664, // x86 64 bit processors (latest P4, Celeron and Athlon64) + paIA64); // Itanium processors + +var + { in case of additions, don't forget to update initialization section! } + IsWin95: Boolean = False; + IsWin95OSR2: Boolean = False; + IsWin98: Boolean = False; + IsWin98SE: Boolean = False; + IsWinME: Boolean = False; + IsWinNT: Boolean = False; + IsWinNT3: Boolean = False; + IsWinNT31: Boolean = False; + IsWinNT35: Boolean = False; + IsWinNT351: Boolean = False; + IsWinNT4: Boolean = False; + IsWin2K: Boolean = False; + IsWinXP: Boolean = False; + IsWin2003: Boolean = False; + IsWinXP64: Boolean = False; + IsWin2003R2: Boolean = False; + IsWinVista: Boolean = False; + IsWinServer2008: Boolean = False; + IsWin7: Boolean = False; + IsWinServer2008R2: Boolean = False; + IsWin8: Boolean = False; + IsWin8RT: Boolean = False; + IsWinServer2012: Boolean = False; + IsWin81: Boolean = False; + IsWin81RT: Boolean = False; + IsWinServer2012R2: Boolean = False; + +const + PROCESSOR_ARCHITECTURE_INTEL = 0; + {$EXTERNALSYM PROCESSOR_ARCHITECTURE_INTEL} + PROCESSOR_ARCHITECTURE_AMD64 = 9; + {$EXTERNALSYM PROCESSOR_ARCHITECTURE_AMD64} + PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 = 10; + {$EXTERNALSYM PROCESSOR_ARCHITECTURE_IA32_ON_WIN64} + PROCESSOR_ARCHITECTURE_IA64 = 6; + {$EXTERNALSYM PROCESSOR_ARCHITECTURE_IA64} + +function GetWindowsVersion: TWindowsVersion; +function GetWindowsEdition: TWindowsEdition; +function NtProductType: TNtProductType; +function GetWindowsVersionString: string; +function GetWindowsEditionString: string; +function GetWindowsProductString: string; +function NtProductTypeString: string; +function GetWindowsBuildNumber: Integer; +function GetWindowsServicePackVersion: Integer; +function GetWindowsServicePackVersionString: string; +{$IFNDEF WINSCP} +function GetOpenGLVersion(const Win: THandle; out Version, Vendor: AnsiString): Boolean; +{$ENDIF ~WINSCP} +function GetNativeSystemInfo(var SystemInfo: TSystemInfo): Boolean; +function GetProcessorArchitecture: TProcessorArchitecture; +function IsWindows64: Boolean; +function JclCheckWinVersion(Major, Minor: Integer): Boolean; +{$ENDIF MSWINDOWS} + +function GetOSVersionString: string; + +// Hardware +{$IFDEF MSWINDOWS} +{$IFNDEF WINSCP} +function GetMacAddresses(const Machine: string; const Addresses: TStrings): Integer; +{$ENDIF ~WINSCP} +{$ENDIF MSWINDOWS} +function ReadTimeStampCounter: Int64; + +type + TTLBInformation = (tiEntries, tiAssociativity); + TCacheInformation = (ciLineSize {in Bytes}, ciLinesPerTag, ciAssociativity, ciSize); + + TIntelSpecific = record + L2Cache: Cardinal; + CacheDescriptors: array [0..15] of Byte; + BrandID: Byte; + FlushLineSize: Byte; + APICID: Byte; + ExFeatures: Cardinal; + Ex64Features: Cardinal; + Ex64Features2: Cardinal; + PowerManagementFeatures: Cardinal; + PhysicalAddressBits: Byte; + VirtualAddressBits: Byte; + end; + + TCyrixSpecific = record + L1CacheInfo: array [0..3] of Byte; + TLBInfo: array [0..3] of Byte; + end; + + TAMDSpecific = packed record + ExFeatures: Cardinal; + ExFeatures2: Cardinal; + Features2: Cardinal; + BrandID: Byte; + FlushLineSize: Byte; + APICID: Byte; + ExBrandID: Word; + // do not split L1 MByte TLB + L1MByteInstructionTLB: array [TTLBInformation] of Byte; + L1MByteDataTLB: array [TTLBInformation] of Byte; + // do not split L1 KByte TLB + L1KByteInstructionTLB: array [TTLBInformation] of Byte; + L1KByteDataTLB: array [TTLBInformation] of Byte; + L1DataCache: array [TCacheInformation] of Byte; + L1InstructionCache: array [TCacheInformation] of Byte; + // do not split L2 MByte TLB + L2MByteInstructionTLB: array [TTLBInformation] of Byte; // L2 TLB for 2-MByte and 4-MByte pages + L2MByteDataTLB: array [TTLBInformation] of Byte; // L2 TLB for 2-MByte and 4-MByte pages + // do not split L2 KByte TLB + L2KByteDataTLB: array [TTLBInformation] of Byte; // L2 TLB for 4-KByte pages + L2KByteInstructionTLB: array [TTLBInformation] of Byte; // L2 TLB for 4-KByte pages + L2Cache: Cardinal; + L3Cache: Cardinal; + AdvancedPowerManagement: Cardinal; + PhysicalAddressSize: Byte; + VirtualAddressSize: Byte; + end; + + TVIASpecific = record + ExFeatures: Cardinal; + DataTLB: array [TTLBInformation] of Byte; + InstructionTLB: array [TTLBInformation] of Byte; + L1DataCache: array [TCacheInformation] of Byte; + L1InstructionCache: array [TCacheInformation] of Byte; + L2DataCache: Cardinal; + end; + + TTransmetaSpecific = record + ExFeatures: Cardinal; + DataTLB: array [TTLBInformation] of Byte; + CodeTLB: array [TTLBInformation] of Byte; + L1DataCache: array [TCacheInformation] of Byte; + L1CodeCache: array [TCacheInformation] of Byte; + L2Cache: Cardinal; + RevisionABCD: Cardinal; + RevisionXXXX: Cardinal; + Frequency: Cardinal; + CodeMorphingABCD: Cardinal; + CodeMorphingXXXX: Cardinal; + TransmetaFeatures: Cardinal; + TransmetaInformations: array [0..64] of Char; + CurrentVoltage: Cardinal; + CurrentFrequency: Cardinal; + CurrentPerformance: Cardinal; + end; + + TCacheFamily = ( + cfInstructionTLB, cfDataTLB, + cfL1InstructionCache, cfL1DataCache, + cfL2Cache, cfL2TLB, cfL3Cache, cfTrace, cfOther); + + TCacheInfo = record + D: Byte; + Family: TCacheFamily; + Size: Cardinal; + WaysOfAssoc: Byte; + LineSize: Byte; // for Normal Cache + LinePerSector: Byte; // for L3 Normal Cache + Entries: Cardinal; // for TLB + I: PResStringRec; + end; + + TFreqInfo = record + RawFreq: Int64; + NormFreq: Int64; + InCycles: Int64; + ExTicks: Int64; + end; + +const + CPU_TYPE_INTEL = 1; + CPU_TYPE_CYRIX = 2; + CPU_TYPE_AMD = 3; + CPU_TYPE_TRANSMETA = 4; + CPU_TYPE_VIA = 5; + +type + TSSESupport = (sse, sse2, sse3, ssse3, sse41, sse42, sse4A, sse5, avx); + TSSESupports = set of TSSESupport; + + TCpuInfo = record + HasInstruction: Boolean; + AES: Boolean; + MMX: Boolean; + ExMMX: Boolean; + _3DNow: Boolean; + Ex3DNow: Boolean; + SSE: TSSESupports; + IsFDIVOK: Boolean; + Is64Bits: Boolean; + DEPCapable: Boolean; + HasCacheInfo: Boolean; + HasExtendedInfo: Boolean; + PType: Byte; + Family: Byte; + ExtendedFamily: Byte; + Model: Byte; + ExtendedModel: Byte; + Stepping: Byte; + Features: Cardinal; + FrequencyInfo: TFreqInfo; + VendorIDString: array [0..11] of AnsiChar; + Manufacturer: array [0..9] of AnsiChar; + CpuName: array [0..47] of AnsiChar; + L1DataCacheSize: Cardinal; // in kByte + L1DataCacheLineSize: Byte; // in Byte + L1DataCacheAssociativity: Byte; + L1InstructionCacheSize: Cardinal; // in kByte + L1InstructionCacheLineSize: Byte; // in Byte + L1InstructionCacheAssociativity: Byte; + L2CacheSize: Cardinal; // in kByte + L2CacheLineSize: Byte; // in Byte + L2CacheAssociativity: Byte; + L3CacheSize: Cardinal; // in kByte + L3CacheLineSize: Byte; // in Byte + L3CacheAssociativity: Byte; + L3LinesPerSector: Byte; + LogicalCore: Byte; + PhysicalCore: Byte; + HyperThreadingTechnology: Boolean; + HardwareHyperThreadingTechnology: Boolean; + // todo: TLB + case CpuType: Byte of + CPU_TYPE_INTEL: (IntelSpecific: TIntelSpecific;); + CPU_TYPE_CYRIX: (CyrixSpecific: TCyrixSpecific;); + CPU_TYPE_AMD: (AMDSpecific: TAMDSpecific;); + CPU_TYPE_TRANSMETA: (TransmetaSpecific: TTransmetaSpecific;); + CPU_TYPE_VIA: (ViaSpecific: TViaSpecific;); + end; + +const + VendorIDIntel: array [0..11] of AnsiChar = 'GenuineIntel'; + VendorIDCyrix: array [0..11] of AnsiChar = 'CyrixInstead'; + VendorIDAMD: array [0..11] of AnsiChar = 'AuthenticAMD'; + VendorIDTransmeta: array [0..11] of AnsiChar = 'GenuineTMx86'; + VendorIDVIA: array [0..11] of AnsiChar = 'CentaurHauls'; + +// Constants to be used with Feature Flag set of a CPU +// eg. IF (Features and FPU_FLAG = FPU_FLAG) THEN CPU has Floating-Point unit on +// chip. However, Intel claims that in future models, a zero in the feature +// flags will mean that the chip has that feature, however, the following flags +// will work for any production 80x86 chip or clone. +// eg. IF (Features and FPU_FLAG = 0) then CPU has Floating-Point unit on chip. + +const + { 32 bits in a DWord Value } + BIT_0 = $00000001; + BIT_1 = $00000002; + BIT_2 = $00000004; + BIT_3 = $00000008; + BIT_4 = $00000010; + BIT_5 = $00000020; + BIT_6 = $00000040; + BIT_7 = $00000080; + BIT_8 = $00000100; + BIT_9 = $00000200; + BIT_10 = $00000400; + BIT_11 = $00000800; + BIT_12 = $00001000; + BIT_13 = $00002000; + BIT_14 = $00004000; + BIT_15 = $00008000; + BIT_16 = $00010000; + BIT_17 = $00020000; + BIT_18 = $00040000; + BIT_19 = $00080000; + BIT_20 = $00100000; + BIT_21 = $00200000; + BIT_22 = $00400000; + BIT_23 = $00800000; + BIT_24 = $01000000; + BIT_25 = $02000000; + BIT_26 = $04000000; + BIT_27 = $08000000; + BIT_28 = $10000000; + BIT_29 = $20000000; + BIT_30 = $40000000; + BIT_31 = DWORD($80000000); + + { Standard Feature Flags } + FPU_FLAG = BIT_0; // Floating-Point unit on chip + VME_FLAG = BIT_1; // Virtual Mode Extention + DE_FLAG = BIT_2; // Debugging Extention + PSE_FLAG = BIT_3; // Page Size Extention + TSC_FLAG = BIT_4; // Time Stamp Counter + MSR_FLAG = BIT_5; // Model Specific Registers + PAE_FLAG = BIT_6; // Physical Address Extention + MCE_FLAG = BIT_7; // Machine Check Exception + CX8_FLAG = BIT_8; // CMPXCHG8 Instruction + APIC_FLAG = BIT_9; // Software-accessible local APIC on Chip + BIT_10_FLAG = BIT_10; // Reserved, do not count on value + SEP_FLAG = BIT_11; // Fast System Call + MTRR_FLAG = BIT_12; // Memory Type Range Registers + PGE_FLAG = BIT_13; // Page Global Enable + MCA_FLAG = BIT_14; // Machine Check Architecture + CMOV_FLAG = BIT_15; // Conditional Move Instruction + PAT_FLAG = BIT_16; // Page Attribute Table + PSE36_FLAG = BIT_17; // 36-bit Page Size Extention + PSN_FLAG = BIT_18; // Processor serial number is present and enabled + CLFLSH_FLAG = BIT_19; // CLFLUSH intruction + BIT_20_FLAG = BIT_20; // Reserved, do not count on value + DS_FLAG = BIT_21; // Debug store + ACPI_FLAG = BIT_22; // Thermal monitor and clock control + MMX_FLAG = BIT_23; // MMX technology + FXSR_FLAG = BIT_24; // Fast Floating Point Save and Restore + SSE_FLAG = BIT_25; // Streaming SIMD Extensions + SSE2_FLAG = BIT_26; // Streaming SIMD Extensions 2 + SS_FLAG = BIT_27; // Self snoop + HTT_FLAG = BIT_28; // Hyper-threading technology + TM_FLAG = BIT_29; // Thermal monitor + BIT_30_FLAG = BIT_30; // Reserved, do not count on value + PBE_FLAG = BIT_31; // Pending Break Enable + + { Standard Intel Feature Flags } + INTEL_FPU = BIT_0; // Floating-Point unit on chip + INTEL_VME = BIT_1; // Virtual Mode Extention + INTEL_DE = BIT_2; // Debugging Extention + INTEL_PSE = BIT_3; // Page Size Extention + INTEL_TSC = BIT_4; // Time Stamp Counter + INTEL_MSR = BIT_5; // Model Specific Registers + INTEL_PAE = BIT_6; // Physical Address Extention + INTEL_MCE = BIT_7; // Machine Check Exception + INTEL_CX8 = BIT_8; // CMPXCHG8 Instruction + INTEL_APIC = BIT_9; // Software-accessible local APIC on Chip + INTEL_BIT_10 = BIT_10; // Reserved, do not count on value + INTEL_SEP = BIT_11; // Fast System Call + INTEL_MTRR = BIT_12; // Memory Type Range Registers + INTEL_PGE = BIT_13; // Page Global Enable + INTEL_MCA = BIT_14; // Machine Check Architecture + INTEL_CMOV = BIT_15; // Conditional Move Instruction + INTEL_PAT = BIT_16; // Page Attribute Table + INTEL_PSE36 = BIT_17; // 36-bit Page Size Extention + INTEL_PSN = BIT_18; // Processor serial number is present and enabled + INTEL_CLFLSH = BIT_19; // CLFLUSH intruction + INTEL_BIT_20 = BIT_20; // Reserved, do not count on value + INTEL_DS = BIT_21; // Debug store + INTEL_ACPI = BIT_22; // Thermal monitor and clock control + INTEL_MMX = BIT_23; // MMX technology + INTEL_FXSR = BIT_24; // Fast Floating Point Save and Restore + INTEL_SSE = BIT_25; // Streaming SIMD Extensions + INTEL_SSE2 = BIT_26; // Streaming SIMD Extensions 2 + INTEL_SS = BIT_27; // Self snoop + INTEL_HTT = BIT_28; // Hyper-threading technology + INTEL_TM = BIT_29; // Thermal monitor + INTEL_IA64 = BIT_30; // IA32 emulation mode on Itanium processors (IA64) + INTEL_PBE = BIT_31; // Pending Break Enable + + { Extended Intel Feature Flags } + EINTEL_SSE3 = BIT_0; // Streaming SIMD Extensions 3 + EINTEL_PCLMULQDQ = BIT_1; // the processor supports the PCLMULQDQ instruction + EINTEL_DTES64 = BIT_2; // the processor supports DS area using 64-bit layout + EINTEL_MONITOR = BIT_3; // Monitor/MWAIT + EINTEL_DSCPL = BIT_4; // CPL Qualified debug Store + EINTEL_VMX = BIT_5; // Virtual Machine Technology + EINTEL_SMX = BIT_6; // Safer Mode Extensions + EINTEL_EST = BIT_7; // Enhanced Intel Speedstep technology + EINTEL_TM2 = BIT_8; // Thermal monitor 2 + EINTEL_SSSE3 = BIT_9; // SSSE 3 extensions + EINTEL_CNXTID = BIT_10; // L1 Context ID + EINTEL_BIT_11 = BIT_11; // Reserved, do not count on value + EINTEL_FMA = BIT_12; // Fused Multiply Add + EINTEL_CX16 = BIT_13; // CMPXCHG16B instruction + EINTEL_XTPR = BIT_14; // Send Task Priority messages + EINTEL_PDCM = BIT_15; // Perf/Debug Capability MSR + EINTEL_BIT_16 = BIT_16; // Reserved, do not count on value + EINTEL_PCID = BIT_17; // Process-context Identifiers + EINTEL_DCA = BIT_18; // Direct Cache Access + EINTEL_SSE4_1 = BIT_19; // Streaming SIMD Extensions 4.1 + EINTEL_SSE4_2 = BIT_20; // Streaming SIMD Extensions 4.2 + EINTEL_X2APIC = BIT_21; // x2APIC feature + EINTEL_MOVBE = BIT_22; // MOVBE instruction + EINTEL_POPCNT = BIT_23; // A value of 1 indicates the processor supports the POPCNT instruction. + EINTEL_TSC_DL = BIT_24; // TSC-Deadline + EINTEL_AES = BIT_25; // the processor supports the AES instruction extensions + EINTEL_XSAVE = BIT_26; // XSAVE/XRSTOR processor extended states feature, XSETBV/XGETBV instructions and XFEATURE_ENABLED_MASK (XCR0) register + EINTEL_OSXSAVE = BIT_27; // OS has enabled features present in EINTEL_XSAVE + EINTEL_AVX = BIT_28; // Advanced Vector Extensions + EINTEL_BIT_29 = BIT_29; // Reserved, do not count on value + EINTEL_RDRAND = BIT_30; // the processor supports the RDRAND instruction. + EINTEL_BIT_31 = BIT_31; // Always return 0 + + { Extended Intel 64 Bits Feature Flags } + EINTEL64_BIT_0 = BIT_0; // Reserved, do not count on value + EINTEL64_BIT_1 = BIT_1; // Reserved, do not count on value + EINTEL64_BIT_2 = BIT_2; // Reserved, do not count on value + EINTEL64_BIT_3 = BIT_3; // Reserved, do not count on value + EINTEL64_BIT_4 = BIT_4; // Reserved, do not count on value + EINTEL64_BIT_5 = BIT_5; // Reserved, do not count on value + EINTEL64_BIT_6 = BIT_6; // Reserved, do not count on value + EINTEL64_BIT_7 = BIT_7; // Reserved, do not count on value + EINTEL64_BIT_8 = BIT_8; // Reserved, do not count on value + EINTEL64_BIT_9 = BIT_9; // Reserved, do not count on value + EINTEL64_BIT_10 = BIT_10; // Reserved, do not count on value + EINTEL64_SYS = BIT_11; // 64 Bit - SYSCALL SYSRET + EINTEL64_BIT_12 = BIT_12; // Reserved, do not count on value + EINTEL64_BIT_13 = BIT_13; // Reserved, do not count on value + EINTEL64_BIT_14 = BIT_14; // Reserved, do not count on value + EINTEL64_BIT_15 = BIT_15; // Reserved, do not count on value + EINTEL64_BIT_16 = BIT_16; // Reserved, do not count on value + EINTEL64_BIT_17 = BIT_17; // Reserved, do not count on value + EINTEL64_BIT_18 = BIT_18; // Reserved, do not count on value + EINTEL64_BIT_19 = BIT_19; // Reserved, do not count on value + EINTEL64_XD = BIT_20; // Execution Disable Bit + EINTEL64_BIT_21 = BIT_21; // Reserved, do not count on value + EINTEL64_BIT_22 = BIT_22; // Reserved, do not count on value + EINTEL64_BIT_23 = BIT_23; // Reserved, do not count on value + EINTEL64_BIT_24 = BIT_24; // Reserved, do not count on value + EINTEL64_BIT_25 = BIT_25; // Reserved, do not count on value + EINTEL64_1GBYTE = BIT_26; // 1G-Byte pages are available + EINTEL64_RDTSCP = BIT_27; // RDTSCP and IA32_TSC_AUX are available + EINTEL64_BIT_28 = BIT_28; // Reserved, do not count on value + EINTEL64_EM64T = BIT_29; // Intel Extended Memory 64 Technology + EINTEL64_BIT_30 = BIT_30; // Reserved, do not count on value + EINTEL64_BIT_31 = BIT_31; // Reserved, do not count on value + + { Extended Intel 64 Bits Feature Flags continued } + EINTEL64_2_LAHF = BIT_0; // LAHF/SAHF available in 64 bit mode + EINTEL64_2_BIT_1 = BIT_1; // Reserved, do not count on value + EINTEL64_2_BIT_2 = BIT_2; // Reserved, do not count on value + EINTEL64_2_BIT_3 = BIT_3; // Reserved, do not count on value + EINTEL64_2_BIT_4 = BIT_4; // Reserved, do not count on value + EINTEL64_2_BIT_5 = BIT_5; // Reserved, do not count on value + EINTEL64_2_BIT_6 = BIT_6; // Reserved, do not count on value + EINTEL64_2_BIT_7 = BIT_7; // Reserved, do not count on value + EINTEL64_2_BIT_8 = BIT_8; // Reserved, do not count on value + EINTEL64_2_BIT_9 = BIT_9; // Reserved, do not count on value + EINTEL64_2_BIT_10 = BIT_10; // Reserved, do not count on value + EINTEL64_2_BIT_11 = BIT_11; // Reserved, do not count on value + EINTEL64_2_BIT_12 = BIT_12; // Reserved, do not count on value + EINTEL64_2_BIT_13 = BIT_13; // Reserved, do not count on value + EINTEL64_2_BIT_14 = BIT_14; // Reserved, do not count on value + EINTEL64_2_BIT_15 = BIT_15; // Reserved, do not count on value + EINTEL64_2_BIT_16 = BIT_16; // Reserved, do not count on value + EINTEL64_2_BIT_17 = BIT_17; // Reserved, do not count on value + EINTEL64_2_BIT_18 = BIT_18; // Reserved, do not count on value + EINTEL64_2_BIT_19 = BIT_19; // Reserved, do not count on value + EINTEL64_2_BIT_20 = BIT_20; // Reserved, do not count on value + EINTEL64_2_BIT_21 = BIT_21; // Reserved, do not count on value + EINTEL64_2_BIT_22 = BIT_22; // Reserved, do not count on value + EINTEL64_2_BIT_23 = BIT_23; // Reserved, do not count on value + EINTEL64_2_BIT_24 = BIT_24; // Reserved, do not count on value + EINTEL64_2_BIT_25 = BIT_25; // Reserved, do not count on value + EINTEL64_2_BIT_26 = BIT_26; // Reserved, do not count on value + EINTEL64_2_BIT_27 = BIT_27; // Reserved, do not count on value + EINTEL64_2_BIT_28 = BIT_28; // Reserved, do not count on value + EINTEL64_2_BIT_29 = BIT_29; // Reserved, do not count on value + EINTEL64_2_BIT_30 = BIT_30; // Reserved, do not count on value + EINTEL64_2_BIT_31 = BIT_31; // Reserved, do not count on value + + { INTEL Power Management Flags } + PINTEL_TEMPSENSOR = BIT_0; // Digital temperature sensor + PINTEL_TURBOBOOST = BIT_1; // Intel Turbo Boost Technology Available + PINTEL_ARAT = BIT_2; // APIC-Timer-always-running feature + PINTEL_BIT_3 = BIT_3; // Reverved, do not count on value + PINTEL_PLN = BIT_4; // Power Limit Notification constrols + PINTEL_ECMD = BIT_5; // Clock Modulation duty cycle extension + PINTEL_PTM = BIT_6; // Package Thermal Management + PINTEL_BIT_7 = BIT_7; // Reserved, do not count on value + PINTEL_BIT_8 = BIT_8; // Reserved, do not count on value + PINTEL_BIT_9 = BIT_9; // Reserved, do not count on value + PINTEL_BIT_10 = BIT_10; // Reserved, do not count on value + PINTEL_BIT_11 = BIT_11; // Reserved, do not count on value + PINTEL_BIT_12 = BIT_12; // Reserved, do not count on value + PINTEL_BIT_13 = BIT_13; // Reserved, do not count on value + PINTEL_BIT_14 = BIT_14; // Reserved, do not count on value + PINTEL_BIT_15 = BIT_15; // Reserved, do not count on value + PINTEL_BIT_16 = BIT_16; // Reserved, do not count on value + PINTEL_BIT_17 = BIT_17; // Reserved, do not count on value + PINTEL_BIT_18 = BIT_18; // Reserved, do not count on value + PINTEL_BIT_19 = BIT_19; // Reserved, do not count on value + PINTEL_BIT_20 = BIT_20; // Reserved, do not count on value + PINTEL_BIT_21 = BIT_21; // Reserved, do not count on value + PINTEL_BIT_22 = BIT_22; // Reserved, do not count on value + PINTEL_BIT_23 = BIT_23; // Reserved, do not count on value + PINTEL_BIT_24 = BIT_24; // Reserved, do not count on value + PINTEL_BIT_25 = BIT_25; // Reserved, do not count on value + PINTEL_BIT_26 = BIT_26; // Reserved, do not count on value + PINTEL_BIT_27 = BIT_27; // Reserved, do not count on value + PINTEL_BIT_28 = BIT_28; // Reserved, do not count on value + PINTEL_BIT_29 = BIT_29; // Reserved, do not count on value + PINTEL_BIT_30 = BIT_30; // Reserved, do not count on value + PINTEL_BIT_31 = BIT_31; // Reserved, do not count on value + + { AMD Standard Feature Flags } + AMD_FPU = BIT_0; // Floating-Point unit on chip + AMD_VME = BIT_1; // Virtual Mode Extention + AMD_DE = BIT_2; // Debugging Extention + AMD_PSE = BIT_3; // Page Size Extention + AMD_TSC = BIT_4; // Time Stamp Counter + AMD_MSR = BIT_5; // Model Specific Registers + AMD_PAE = BIT_6; // Physical address Extensions + AMD_MCE = BIT_7; // Machine Check Exception + AMD_CX8 = BIT_8; // CMPXCHG8 Instruction + AMD_APIC = BIT_9; // Software-accessible local APIC on Chip + AMD_BIT_10 = BIT_10; // Reserved, do not count on value + AMD_SEP_BIT = BIT_11; // SYSENTER and SYSEXIT instructions + AMD_MTRR = BIT_12; // Memory Type Range Registers + AMD_PGE = BIT_13; // Page Global Enable + AMD_MCA = BIT_14; // Machine Check Architecture + AMD_CMOV = BIT_15; // Conditional Move Instruction + AMD_PAT = BIT_16; // Page Attribute Table + AMD_PSE36 = BIT_17; // Page Size Extensions + AMD_BIT_18 = BIT_18; // Reserved, do not count on value + AMD_CLFLSH = BIT_19; // CLFLUSH instruction + AMD_BIT_20 = BIT_20; // Reserved, do not count on value + AMD_BIT_21 = BIT_21; // Reserved, do not count on value + AMD_BIT_22 = BIT_22; // Reserved, do not count on value + AMD_MMX = BIT_23; // MMX technology + AMD_FXSR = BIT_24; // FXSAVE and FXSTORE instructions + AMD_SSE = BIT_25; // SSE Extensions + AMD_SSE2 = BIT_26; // SSE2 Extensions + AMD_BIT_27 = BIT_27; // Reserved, do not count on value + AMD_HTT = BIT_28; // Hyper-Threading Technology + AMD_BIT_29 = BIT_29; // Reserved, do not count on value + AMD_BIT_30 = BIT_30; // Reserved, do not count on value + AMD_BIT_31 = BIT_31; // Reserved, do not count on value + + { AMD Standard Feature Flags continued } + AMD2_SSE3 = BIT_0; // SSE3 extensions + AMD2_PCLMULQDQ = BIT_1; // PCLMULQDQ instruction support + AMD2_BIT_2 = BIT_2; // Reserved, do not count on value + AMD2_MONITOR = BIT_3; // MONITOR/MWAIT instructions. See "MONITOR" and "MWAIT" in APM3. + AMD2_BIT_4 = BIT_4; // Reserved, do not count on value + AMD2_BIT_5 = BIT_5; // Reserved, do not count on value + AMD2_BIT_6 = BIT_6; // Reserved, do not count on value + AMD2_BIT_7 = BIT_7; // Reserved, do not count on value + AMD2_BIT_8 = BIT_8; // Reserved, do not count on value + AMD2_SSSE3 = BIT_9; // supplemental SSE3 extensions + AMD2_BIT_10 = BIT_10; // Reserved, do not count on value + AMD2_BIT_11 = BIT_11; // Reserved, do not count on value + AMD2_FMA = BIT_12; // FMA instruction support + AMD2_CMPXCHG16B = BIT_13; // CMPXCHG16B available + AMD2_BIT_14 = BIT_14; // Reserved, do not count on value + AMD2_BIT_15 = BIT_15; // Reserved, do not count on value + AMD2_BIT_16 = BIT_16; // Reserved, do not count on value + AMD2_BIT_17 = BIT_17; // Reserved, do not count on value + AMD2_BIT_18 = BIT_18; // Reserved, do not count on value + AMD2_SSE41 = BIT_19; // SSE4.1 instruction support + AMD2_SSE42 = BIT_20; // SSE4.2 instruction support + AMD2_BIT_21 = BIT_21; // Reserved, do not count on value + AMD2_BIT_22 = BIT_22; // Reserved, do not count on value + AMD2_POPCNT = BIT_23; // POPCNT instruction. See "POPCNT" in APM3. + AMD2_BIT_24 = BIT_24; // Reserved, do not count on value + AMD2_AES = BIT_25; // AES instruction support + AMD2_XSAVE = BIT_26; // XSAVE (and related) instructions are supported by hardware + AMD2_OSXSAVE = BIT_27; // XSAVE (and related) instructions are enabled + AMD2_AVX = BIT_28; // AVX instruction support + AMD2_F16C = BIT_29; // half-precision convert instruction support + AMD2_BIT_30 = BIT_30; // Reserved, do not count on value + AMD2_RAZ = BIT_31; // Reserved for use by hypervisor to indicate guest status + + { AMD Enhanced Feature Flags } + EAMD_FPU = BIT_0; // Floating-Point unit on chip + EAMD_VME = BIT_1; // Virtual Mode Extention + EAMD_DE = BIT_2; // Debugging Extention + EAMD_PSE = BIT_3; // Page Size Extention + EAMD_TSC = BIT_4; // Time Stamp Counter + EAMD_MSR = BIT_5; // Model Specific Registers + EAMD_PAE = BIT_6; // Physical-address extensions + EAMD_MCE = BIT_7; // Machine Check Exception + EAMD_CX8 = BIT_8; // CMPXCHG8 Instruction + EAMD_APIC = BIT_9; // Advanced Programmable Interrupt Controler + EAMD_BIT_10 = BIT_10; // Reserved, do not count on value + EAMD_SEP = BIT_11; // Fast System Call + EAMD_MTRR = BIT_12; // Memory-Type Range Registers + EAMD_PGE = BIT_13; // Page Global Enable + EAMD_MCA = BIT_14; // Machine Check Architecture + EAMD_CMOV = BIT_15; // Conditional Move Intructions + EAMD_PAT = BIT_16; // Page Attributes Table + EAMD_PSE2 = BIT_17; // Page Size Extensions + EAMD_BIT_18 = BIT_18; // Reserved, do not count on value + EAMD_BIT_19 = BIT_19; // Reserved, do not count on value + EAMD_NX = BIT_20; // No-Execute Page Protection + EAMD_BIT_21 = BIT_21; // Reserved, do not count on value + EAMD_EXMMX = BIT_22; // AMD Extensions to MMX technology + EAMD_MMX = BIT_23; // MMX technology + EAMD_FX = BIT_24; // FXSAVE and FXSTORE instructions + EAMD_FFX = BIT_25; // Fast FXSAVE and FXSTORE instructions + EAMD_1GBPAGE = BIT_26; // 1-GB large page support. + EAMD_RDTSCP = BIT_27; // RDTSCP instruction. + EAMD_BIT_28 = BIT_28; // Reserved, do not count on value + EAMD_LONG = BIT_29; // Long Mode (64-bit Core) + EAMD_EX3DNOW = BIT_30; // AMD Extensions to 3DNow! intructions + EAMD_3DNOW = BIT_31; // AMD 3DNOW! Technology + + { AMD Extended Feature Flags continued } + EAMD2_LAHF = BIT_0; // LAHF/SAHF available in 64-bit mode + EAMD2_CMPLEGACY = BIT_1; // core multi-processing legacy mode + EAMD2_SVM = BIT_2; // Secure Virtual Machine + EAMD2_EXTAPICSPACE = BIT_3; // This bit indicates the presence of extended APIC register space starting at offset 400h from the “APIC Base Address Register,” as specified in the BKDG. + EAMD2_ALTMOVCR8 = BIT_4; // LOCK MOV CR0 means MOV CR8 + EAMD2_ABM = BIT_5; // ABM: Advanced bit manipulation. LZCNT instruction support. + EAMD2_SSE4A = BIT_6; // EXTRQ, INSERTQ, MOVNTSS, and MOVNTSD instruction support. + EAMD2_MISALIGNSSE = BIT_7; // Misaligned SSE mode. + EAMD2_3DNOWPREFETCH = BIT_8; // PREFETCH and PREFETCHW instruction support. + EAMD2_OSVW = BIT_9; // OS visible workaround. + EAMD2_IBS = BIT_10; // Instruction based sampling + EAMD2_XOP = BIT_11; // extended operation support + EAMD2_SKINIT = BIT_12; // SKINIT, STGI, and DEV support. + EAMD2_WDT = BIT_13; // Watchdog timer support. + EAMD2_BIT_14 = BIT_14; // Reserved, do not count on value + EAMD2_LWP = BIT_15; // lightweight profiling support + EAMD2_FMA4 = BIT_16; // 4-operand FMA instruction support. + EAMD2_BIT_17 = BIT_17; // Reserved, do not count on value + EAMD2_BIT_18 = BIT_18; // Reserved, do not count on value + EAMD2_NODEID = BIT_19; // Support for MSRC001_100C[NodeId, NodesPerProcessor] + EAMD2_BIT_20 = BIT_20; // Reserved, do not count on value + EAMD2_TBM = BIT_21; // trailing bit manipulation instruction support + EAMD2_TOPOLOGYEXT = BIT_22; // topology extensions support + EAMD2_BIT_23 = BIT_23; // Reserved, do not count on value + EAMD2_BIT_24 = BIT_24; // Reserved, do not count on value + EAMD2_BIT_25 = BIT_25; // Reserved, do not count on value + EAMD2_BIT_26 = BIT_26; // Reserved, do not count on value + EAMD2_BIT_27 = BIT_27; // Reserved, do not count on value + EAMD2_BIT_28 = BIT_28; // Reserved, do not count on value + EAMD2_BIT_29 = BIT_29; // Reserved, do not count on value + EAMD2_BIT_30 = BIT_30; // Reserved, do not count on value + EAMD2_BIT_31 = BIT_31; // Reserved, do not count on value + + { AMD Power Management Features Flags } + PAMD_TEMPSENSOR = BIT_0; // Temperature Sensor + PAMD_FREQUENCYID = BIT_1; // Frequency ID Control + PAMD_VOLTAGEID = BIT_2; // Voltage ID Control + PAMD_THERMALTRIP = BIT_3; // Thermal Trip + PAMD_THERMALMONITOR = BIT_4; // Thermal Monitoring + PAMD_BIT_5 = BIT_5; // Reserved, do not count on value + PAMD_100MHZSTEP = BIT_6; // 100 Mhz multiplier control. + PAMD_HWPSTATE = BIT_7; // Hardware P-State control. + PAMD_TSC_INVARIANT = BIT_8; // TSC rate is invariant + PAMD_CPB = BIT_9; // core performance boost + PAMD_EFFFREQRO = BIT_10; // read-only effective frequency interface + PAMD_BIT_11 = BIT_11; // Reserved, do not count on value + PAMD_BIT_12 = BIT_12; // Reserved, do not count on value + PAMD_BIT_13 = BIT_13; // Reserved, do not count on value + PAMD_BIT_14 = BIT_14; // Reserved, do not count on value + PAMD_BIT_15 = BIT_15; // Reserved, do not count on value + PAMD_BIT_16 = BIT_16; // Reserved, do not count on value + PAMD_BIT_17 = BIT_17; // Reserved, do not count on value + PAMD_BIT_18 = BIT_18; // Reserved, do not count on value + PAMD_BIT_19 = BIT_19; // Reserved, do not count on value + PAMD_BIT_20 = BIT_20; // Reserved, do not count on value + PAMD_BIT_21 = BIT_21; // Reserved, do not count on value + PAMD_BIT_22 = BIT_22; // Reserved, do not count on value + PAMD_BIT_23 = BIT_23; // Reserved, do not count on value + PAMD_BIT_24 = BIT_24; // Reserved, do not count on value + PAMD_BIT_25 = BIT_25; // Reserved, do not count on value + PAMD_BIT_26 = BIT_26; // Reserved, do not count on value + PAMD_BIT_27 = BIT_27; // Reserved, do not count on value + PAMD_BIT_28 = BIT_28; // Reserved, do not count on value + PAMD_BIT_29 = BIT_29; // Reserved, do not count on value + PAMD_BIT_30 = BIT_30; // Reserved, do not count on value + PAMD_BIT_31 = BIT_31; // Reserved, do not count on value + + { AMD TLB and L1 Associativity constants } + AMD_ASSOC_RESERVED = 0; + AMD_ASSOC_DIRECT = 1; + // 2 to 254 = direct value to the associativity + AMD_ASSOC_FULLY = 255; + + { AMD L2 Cache Associativity constants } + AMD_L2_ASSOC_DISABLED = 0; + AMD_L2_ASSOC_DIRECT = 1; + AMD_L2_ASSOC_2WAY = 2; + AMD_L2_ASSOC_4WAY = 4; + AMD_L2_ASSOC_8WAY = 6; + AMD_L2_ASSOC_16WAY = 8; + AMD_L2_ASSOC_32WAY = 10; + AMD_L2_ASSOC_48WAY = 11; + AMD_L2_ASSOC_64WAY = 12; + AMD_L2_ASSOC_96WAY = 13; + AMD_L2_ASSOC_128WAY = 14; + AMD_L2_ASSOC_FULLY = 15; + + // TODO AMD SVM and LWP bits + + { VIA Standard Feature Flags } + VIA_FPU = BIT_0; // FPU present + VIA_VME = BIT_1; // Virtual Mode Extension + VIA_DE = BIT_2; // Debugging extensions + VIA_PSE = BIT_3; // Page Size Extensions (4MB) + VIA_TSC = BIT_4; // Time Stamp Counter + VIA_MSR = BIT_5; // Model Specific Registers + VIA_PAE = BIT_6; // Physical Address Extension + VIA_MCE = BIT_7; // Machine Check Exception + VIA_CX8 = BIT_8; // CMPXCHG8B instruction + VIA_APIC = BIT_9; // APIC supported + VIA_BIT_10 = BIT_10; // Reserved, do not count on value + VIA_SEP = BIT_11; // Fast System Call + VIA_MTRR = BIT_12; // Memory Range Registers + VIA_PTE = BIT_13; // PTE Global Bit + VIA_MCA = BIT_14; // Machine Check Architecture + VIA_CMOVE = BIT_15; // Conditional Move + VIA_PAT = BIT_16; // Page Attribute Table + VIA_PSE2 = BIT_17; // 36-bit Page Size Extension + VIA_SNUM = BIT_18; // Processor serial number + VIA_BIT_19 = BIT_19; // Reserved, do not count on value + VIA_BIT_20 = BIT_20; // Reserved, do not count on value + VIA_BIT_21 = BIT_21; // Reserved, do not count on value + VIA_BIT_22 = BIT_22; // Reserved, do not count on value + VIA_MMX = BIT_23; // MMX + VIA_FX = BIT_24; // FXSAVE and FXSTORE instructions + VIA_SSE = BIT_25; // Streaming SIMD Extension + VIA_BIT_26 = BIT_26; // Reserved, do not count on value + VIA_BIT_27 = BIT_27; // Reserved, do not count on value + VIA_BIT_28 = BIT_28; // Reserved, do not count on value + VIA_BIT_29 = BIT_29; // Reserved, do not count on value + VIA_BIT_30 = BIT_30; // Reserved, do not count on value + VIA_3DNOW = BIT_31; // 3DNow! Technology + + { VIA Extended Feature Flags } + EVIA_AIS = BIT_0; // Alternate Instruction Set + EVIA_AISE = BIT_1; // Alternate Instruction Set Enabled + EVIA_NO_RNG = BIT_2; // NO Random Number Generator + EVIA_RNGE = BIT_3; // Random Number Generator Enabled + EVIA_MSR = BIT_4; // Longhaul MSR 0x110A available + EVIA_FEMMS = BIT_5; // FEMMS instruction Present + EVIA_NO_ACE = BIT_6; // Advanced Cryptography Engine NOT Present + EVIA_ACEE = BIT_7; // ACE Enabled + EVIA_BIT_8 = BIT_8; // Reserved, do not count on value + EVIA_BIT_9 = BIT_9; // Reserved, do not count on value + EVIA_BIT_10 = BIT_10; // Reserved, do not count on value + EVIA_BIT_11 = BIT_11; // Reserved, do not count on value + EVIA_BIT_12 = BIT_12; // Reserved, do not count on value + EVIA_BIT_13 = BIT_13; // Reserved, do not count on value + EVIA_BIT_14 = BIT_14; // Reserved, do not count on value + EVIA_BIT_15 = BIT_15; // Reserved, do not count on value + EVIA_BIT_16 = BIT_16; // Reserved, do not count on value + EVIA_BIT_17 = BIT_17; // Reserved, do not count on value + EVIA_BIT_18 = BIT_18; // Reserved, do not count on value + EVIA_BIT_19 = BIT_19; // Reserved, do not count on value + EVIA_BIT_20 = BIT_20; // Reserved, do not count on value + EVIA_BIT_21 = BIT_21; // Reserved, do not count on value + EVIA_BIT_22 = BIT_22; // Reserved, do not count on value + EVIA_BIT_23 = BIT_23; // Reserved, do not count on value + EVIA_BIT_24 = BIT_24; // Reserved, do not count on value + EVIA_BIT_25 = BIT_25; // Reserved, do not count on value + EVIA_BIT_26 = BIT_26; // Reserved, do not count on value + EVIA_BIT_27 = BIT_27; // Reserved, do not count on value + EVIA_BIT_28 = BIT_28; // Reserved, do not count on value + EVIA_BIT_29 = BIT_29; // Reserved, do not count on value + EVIA_BIT_30 = BIT_30; // Reserved, do not count on value + EVIA_BIT_31 = BIT_31; // Reserved, do not count on value + + { Cyrix Standard Feature Flags } + CYRIX_FPU = BIT_0; // Floating-Point unit on chip + CYRIX_VME = BIT_1; // Virtual Mode Extention + CYRIX_DE = BIT_2; // Debugging Extention + CYRIX_PSE = BIT_3; // Page Size Extention + CYRIX_TSC = BIT_4; // Time Stamp Counter + CYRIX_MSR = BIT_5; // Model Specific Registers + CYRIX_PAE = BIT_6; // Physical Address Extention + CYRIX_MCE = BIT_7; // Machine Check Exception + CYRIX_CX8 = BIT_8; // CMPXCHG8 Instruction + CYRIX_APIC = BIT_9; // Software-accessible local APIC on Chip + CYRIX_BIT_10 = BIT_10; // Reserved, do not count on value + CYRIX_BIT_11 = BIT_11; // Reserved, do not count on value + CYRIX_MTRR = BIT_12; // Memory Type Range Registers + CYRIX_PGE = BIT_13; // Page Global Enable + CYRIX_MCA = BIT_14; // Machine Check Architecture + CYRIX_CMOV = BIT_15; // Conditional Move Instruction + CYRIX_BIT_16 = BIT_16; // Reserved, do not count on value + CYRIX_BIT_17 = BIT_17; // Reserved, do not count on value + CYRIX_BIT_18 = BIT_18; // Reserved, do not count on value + CYRIX_BIT_19 = BIT_19; // Reserved, do not count on value + CYRIX_BIT_20 = BIT_20; // Reserved, do not count on value + CYRIX_BIT_21 = BIT_21; // Reserved, do not count on value + CYRIX_BIT_22 = BIT_22; // Reserved, do not count on value + CYRIX_MMX = BIT_23; // MMX technology + CYRIX_BIT_24 = BIT_24; // Reserved, do not count on value + CYRIX_BIT_25 = BIT_25; // Reserved, do not count on value + CYRIX_BIT_26 = BIT_26; // Reserved, do not count on value + CYRIX_BIT_27 = BIT_27; // Reserved, do not count on value + CYRIX_BIT_28 = BIT_28; // Reserved, do not count on value + CYRIX_BIT_29 = BIT_29; // Reserved, do not count on value + CYRIX_BIT_30 = BIT_30; // Reserved, do not count on value + CYRIX_BIT_31 = BIT_31; // Reserved, do not count on value + + { Cyrix Enhanced Feature Flags } + ECYRIX_FPU = BIT_0; // Floating-Point unit on chip + ECYRIX_VME = BIT_1; // Virtual Mode Extention + ECYRIX_DE = BIT_2; // Debugging Extention + ECYRIX_PSE = BIT_3; // Page Size Extention + ECYRIX_TSC = BIT_4; // Time Stamp Counter + ECYRIX_MSR = BIT_5; // Model Specific Registers + ECYRIX_PAE = BIT_6; // Physical Address Extention + ECYRIX_MCE = BIT_7; // Machine Check Exception + ECYRIX_CX8 = BIT_8; // CMPXCHG8 Instruction + ECYRIX_APIC = BIT_9; // Software-accessible local APIC on Chip + ECYRIX_SEP = BIT_10; // Fast System Call + ECYRIX_BIT_11 = BIT_11; // Reserved, do not count on value + ECYRIX_MTRR = BIT_12; // Memory Type Range Registers + ECYRIX_PGE = BIT_13; // Page Global Enable + ECYRIX_MCA = BIT_14; // Machine Check Architecture + ECYRIX_ICMOV = BIT_15; // Integer Conditional Move Instruction + ECYRIX_FCMOV = BIT_16; // Floating Point Conditional Move Instruction + ECYRIX_BIT_17 = BIT_17; // Reserved, do not count on value + ECYRIX_BIT_18 = BIT_18; // Reserved, do not count on value + ECYRIX_BIT_19 = BIT_19; // Reserved, do not count on value + ECYRIX_BIT_20 = BIT_20; // Reserved, do not count on value + ECYRIX_BIT_21 = BIT_21; // Reserved, do not count on value + ECYRIX_BIT_22 = BIT_22; // Reserved, do not count on value + ECYRIX_MMX = BIT_23; // MMX technology + ECYRIX_EMMX = BIT_24; // Extended MMX Technology + ECYRIX_BIT_25 = BIT_25; // Reserved, do not count on value + ECYRIX_BIT_26 = BIT_26; // Reserved, do not count on value + ECYRIX_BIT_27 = BIT_27; // Reserved, do not count on value + ECYRIX_BIT_28 = BIT_28; // Reserved, do not count on value + ECYRIX_BIT_29 = BIT_29; // Reserved, do not count on value + ECYRIX_BIT_30 = BIT_30; // Reserved, do not count on value + ECYRIX_BIT_31 = BIT_31; // Reserved, do not count on value + + { Transmeta Features } + TRANSMETA_FPU = BIT_0; // Floating-Point unit on chip + TRANSMETA_VME = BIT_1; // Virtual Mode Extention + TRANSMETA_DE = BIT_2; // Debugging Extention + TRANSMETA_PSE = BIT_3; // Page Size Extention + TRANSMETA_TSC = BIT_4; // Time Stamp Counter + TRANSMETA_MSR = BIT_5; // Model Specific Registers + TRANSMETA_BIT_6 = BIT_6; // Reserved, do not count on value + TRANSMETA_BIT_7 = BIT_7; // Reserved, do not count on value + TRANSMETA_CX8 = BIT_8; // CMPXCHG8 Instruction + TRANSMETA_BIT_9 = BIT_9; // Reserved, do not count on value + TRANSMETA_BIT_10 = BIT_10; // Reserved, do not count on value + TRANSMETA_SEP = BIT_11; // Fast system Call Extensions + TRANSMETA_BIT_12 = BIT_12; // Reserved, do not count on value + TRANSMETA_BIT_13 = BIT_13; // Reserved, do not count on value + TRANSMETA_BIT_14 = BIT_14; // Reserved, do not count on value + TRANSMETA_CMOV = BIT_15; // Conditional Move Instruction + TRANSMETA_BIT_16 = BIT_16; // Reserved, do not count on value + TRANSMETA_BIT_17 = BIT_17; // Reserved, do not count on value + TRANSMETA_PSN = BIT_18; // Processor Serial Number + TRANSMETA_BIT_19 = BIT_19; // Reserved, do not count on value + TRANSMETA_BIT_20 = BIT_20; // Reserved, do not count on value + TRANSMETA_BIT_21 = BIT_21; // Reserved, do not count on value + TRANSMETA_BIT_22 = BIT_22; // Reserved, do not count on value + TRANSMETA_MMX = BIT_23; // MMX technology + TRANSMETA_BIT_24 = BIT_24; // Reserved, do not count on value + TRANSMETA_BIT_25 = BIT_25; // Reserved, do not count on value + TRANSMETA_BIT_26 = BIT_26; // Reserved, do not count on value + TRANSMETA_BIT_27 = BIT_27; // Reserved, do not count on value + TRANSMETA_BIT_28 = BIT_28; // Reserved, do not count on value + TRANSMETA_BIT_29 = BIT_29; // Reserved, do not count on value + TRANSMETA_BIT_30 = BIT_30; // Reserved, do not count on value + TRANSMETA_BIT_31 = BIT_31; // Reserved, do not count on value + + { Extended Transmeta Features } + ETRANSMETA_FPU = BIT_0; // Floating-Point unit on chip + ETRANSMETA_VME = BIT_1; // Virtual Mode Extention + ETRANSMETA_DE = BIT_2; // Debugging Extention + ETRANSMETA_PSE = BIT_3; // Page Size Extention + ETRANSMETA_TSC = BIT_4; // Time Stamp Counter + ETRANSMETA_MSR = BIT_5; // Model Specific Registers + ETRANSMETA_BIT_6 = BIT_6; // Reserved, do not count on value + ETRANSMETA_BIT_7 = BIT_7; // Reserved, do not count on value + ETRANSMETA_CX8 = BIT_8; // CMPXCHG8 Instruction + ETRANSMETA_BIT_9 = BIT_9; // Reserved, do not count on value + ETRANSMETA_BIT_10 = BIT_10; // Reserved, do not count on value + ETRANSMETA_BIT_11 = BIT_11; // Reserved, do not count on value + ETRANSMETA_BIT_12 = BIT_12; // Reserved, do not count on value + ETRANSMETA_BIT_13 = BIT_13; // Reserved, do not count on value + ETRANSMETA_BIT_14 = BIT_14; // Reserved, do not count on value + ETRANSMETA_CMOV = BIT_15; // Conditional Move Instruction + ETRANSMETA_FCMOV = BIT_16; // Float Conditional Move Instruction + ETRANSMETA_BIT_17 = BIT_17; // Reserved, do not count on value + ETRANSMETA_BIT_18 = BIT_18; // Reserved, do not count on value + ETRANSMETA_BIT_19 = BIT_19; // Reserved, do not count on value + ETRANSMETA_BIT_20 = BIT_20; // Reserved, do not count on value + ETRANSMETA_BIT_21 = BIT_21; // Reserved, do not count on value + ETRANSMETA_BIT_22 = BIT_22; // Reserved, do not count on value + ETRANSMETA_MMX = BIT_23; // MMX technology + ETRANSMETA_BIT_24 = BIT_24; // Reserved, do not count on value + ETRANSMETA_BIT_25 = BIT_25; // Reserved, do not count on value + ETRANSMETA_BIT_26 = BIT_26; // Reserved, do not count on value + ETRANSMETA_BIT_27 = BIT_27; // Reserved, do not count on value + ETRANSMETA_BIT_28 = BIT_28; // Reserved, do not count on value + ETRANSMETA_BIT_29 = BIT_29; // Reserved, do not count on value + ETRANSMETA_BIT_30 = BIT_30; // Reserved, do not count on value + ETRANSMETA_BIT_31 = BIT_31; // Reserved, do not count on value + + { Transmeta Specific Features } + STRANSMETA_RECOVERY = BIT_0; // Recovery Mode + STRANSMETA_LONGRUN = BIT_1; // Long Run + STRANSMETA_BIT_2 = BIT_2; // Debugging Extention + STRANSMETA_LRTI = BIT_3; // Long Run Table Interface + STRANSMETA_BIT_4 = BIT_4; // Reserved, do not count on value + STRANSMETA_BIT_5 = BIT_5; // Reserved, do not count on value + STRANSMETA_BIT_6 = BIT_6; // Reserved, do not count on value + STRANSMETA_PTTI1 = BIT_7; // Persistent Translation Technology 1.x + STRANSMETA_PTTI2 = BIT_8; // Persistent Translation Technology 2.0 + STRANSMETA_BIT_9 = BIT_9; // Reserved, do not count on value + STRANSMETA_BIT_10 = BIT_10; // Reserved, do not count on value + STRANSMETA_BIT_11 = BIT_11; // Reserved, do not count on value + STRANSMETA_BIT_12 = BIT_12; // Reserved, do not count on value + STRANSMETA_BIT_13 = BIT_13; // Reserved, do not count on value + STRANSMETA_BIT_14 = BIT_14; // Reserved, do not count on value + STRANSMETA_BIT_15 = BIT_15; // Reserved, do not count on value + STRANSMETA_BIT_16 = BIT_16; // Reserved, do not count on value + STRANSMETA_BIT_17 = BIT_17; // Reserved, do not count on value + STRANSMETA_BIT_18 = BIT_18; // Reserved, do not count on value + STRANSMETA_BIT_19 = BIT_19; // Reserved, do not count on value + STRANSMETA_BIT_20 = BIT_20; // Reserved, do not count on value + STRANSMETA_BIT_21 = BIT_21; // Reserved, do not count on value + STRANSMETA_BIT_22 = BIT_22; // Reserved, do not count on value + STRANSMETA_BIT_23 = BIT_23; // Reserved, do not count on value + STRANSMETA_BIT_24 = BIT_24; // Reserved, do not count on value + STRANSMETA_BIT_25 = BIT_25; // Reserved, do not count on value + STRANSMETA_BIT_26 = BIT_26; // Reserved, do not count on value + STRANSMETA_BIT_27 = BIT_27; // Reserved, do not count on value + STRANSMETA_BIT_28 = BIT_28; // Reserved, do not count on value + STRANSMETA_BIT_29 = BIT_29; // Reserved, do not count on value + STRANSMETA_BIT_30 = BIT_30; // Reserved, do not count on value + STRANSMETA_BIT_31 = BIT_31; // Reserved, do not count on value + + { Constants of bits of the MXCSR register - Intel and AMD processors that support SSE instructions} + MXCSR_IE = BIT_0; // Invalid Operation flag + MXCSR_DE = BIT_1; // Denormal flag + MXCSR_ZE = BIT_2; // Divide by Zero flag + MXCSR_OE = BIT_3; // Overflow flag + MXCSR_UE = BIT_4; // Underflow flag + MXCSR_PE = BIT_5; // Precision flag + MXCSR_DAZ = BIT_6; // Denormal are Zero flag + MXCSR_IM = BIT_7; // Invalid Operation mask + MXCSR_DM = BIT_8; // Denormal mask + MXCSR_ZM = BIT_9; // Divide by Zero mask + MXCSR_OM = BIT_10; // Overflow mask + MXCSR_UM = BIT_11; // Underflow mask + MXCSR_PM = BIT_12; // Precision mask + MXCSR_RC1 = BIT_13; // Rounding control, bit 1 + MXCSR_RC2 = BIT_14; // Rounding control, bit 2 + MXCSR_RC = MXCSR_RC1 or MXCSR_RC2; // Rounding control + MXCSR_FZ = BIT_15; // Flush to Zero + +const + IntelCacheDescription: array [0..102] of TCacheInfo = ( + (D: $00; Family: cfOther; Size: 0; WaysOfAssoc: 0; LineSize: 0; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr00), + (D: $01; Family: cfInstructionTLB; Size: 4; WaysOfAssoc: 4; LineSize: 0; LinePerSector: 0; Entries: 32; I: @RsIntelCacheDescr01), + (D: $02; Family: cfInstructionTLB; Size: 4096; WaysOfAssoc: 4; LineSize: 0; LinePerSector: 0; Entries: 2; I: @RsIntelCacheDescr02), + (D: $03; Family: cfDataTLB; Size: 4; WaysOfAssoc: 4; LineSize: 0; LinePerSector: 0; Entries: 64; I: @RsIntelCacheDescr03), + (D: $04; Family: cfDataTLB; Size: 4096; WaysOfAssoc: 4; LineSize: 0; LinePerSector: 0; Entries: 8; I: @RsIntelCacheDescr04), + (D: $05; Family: cfDataTLB; Size: 4096; WaysOfAssoc: 4; LineSize: 0; LinePerSector: 0; Entries: 32; I: @RsIntelCacheDescr05), + (D: $06; Family: cfL1InstructionCache; Size: 8; WaysOfAssoc: 4; LineSize: 32; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr06), + (D: $08; Family: cfL1InstructionCache; Size: 16; WaysOfAssoc: 4; LineSize: 32; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr08), + (D: $09; Family: cfL1InstructionCache; Size: 32; WaysOfAssoc: 4; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr09), + (D: $0A; Family: cfL1DataCache; Size: 8; WaysOfAssoc: 2; LineSize: 32; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr0A), + (D: $0B; Family: cfInstructionTLB; Size: 4; WaysOfAssoc: 4; LineSize: 0; LinePerSector: 0; Entries: 4; I: @RsIntelCacheDescr0B), + (D: $0C; Family: cfL1DataCache; Size: 16; WaysOfAssoc: 4; LineSize: 32; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr0C), + (D: $0D; Family: cfL1DataCache; Size: 16; WaysOfAssoc: 4; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr0D), + (D: $0E; Family: cfL1DataCache; Size: 24; WaysOfAssoc: 4; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr0E), + (D: $21; Family: cfL2Cache; Size: 256; WaysOfAssoc: 4; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr21), + (D: $22; Family: cfL3Cache; Size: 512; WaysOfAssoc: 4; LineSize: 64; LinePerSector: 2; Entries: 0; I: @RsIntelCacheDescr22), + (D: $23; Family: cfL3Cache; Size: 1024; WaysOfAssoc: 8; LineSize: 64; LinePerSector: 2; Entries: 0; I: @RsIntelCacheDescr23), + (D: $25; Family: cfL3Cache; Size: 2048; WaysOfAssoc: 8; LineSize: 64; LinePerSector: 2; Entries: 0; I: @RsIntelCacheDescr25), + (D: $29; Family: cfL3Cache; Size: 4096; WaysOfAssoc: 8; LineSize: 64; LinePerSector: 2; Entries: 0; I: @RsIntelCacheDescr29), + (D: $2C; Family: cfL1DataCache; Size: 32; WaysOfAssoc: 8; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr2C), + (D: $30; Family: cfL1InstructionCache; Size: 32; WaysOfAssoc: 8; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr30), + (D: $39; Family: cfL2Cache; Size: 128; WaysOfAssoc: 4; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr39), + (D: $3A; Family: cfL2Cache; Size: 192; WaysOfAssoc: 6; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr3A), + (D: $3B; Family: cfL2Cache; Size: 128; WaysOfAssoc: 2; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr3B), + (D: $3C; Family: cfL2Cache; Size: 256; WaysOfAssoc: 4; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr3C), + (D: $3D; Family: cfL2Cache; Size: 384; WaysOfAssoc: 6; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr3D), + (D: $3E; Family: cfL2Cache; Size: 512; WaysOfAssoc: 4; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr3E), + (D: $40; Family: cfOther; Size: 0; WaysOfAssoc: 0; LineSize: 0; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr40), + (D: $41; Family: cfL2Cache; Size: 128; WaysOfAssoc: 4; LineSize: 32; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr41), + (D: $42; Family: cfL2Cache; Size: 256; WaysOfAssoc: 4; LineSize: 32; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr42), + (D: $43; Family: cfL2Cache; Size: 512; WaysOfAssoc: 4; LineSize: 32; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr43), + (D: $44; Family: cfL2Cache; Size: 1024; WaysOfAssoc: 4; LineSize: 32; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr44), + (D: $45; Family: cfL2Cache; Size: 2048; WaysOfAssoc: 4; LineSize: 32; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr45), + (D: $46; Family: cfL3Cache; Size: 4096; WaysOfAssoc: 4; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr46), + (D: $47; Family: cfL3Cache; Size: 8192; WaysOfAssoc: 8; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr47), + (D: $48; Family: cfL2Cache; Size: 3072; WaysOfAssoc: 12; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr48), + (D: $49; Family: cfL2Cache; Size: 4096; WaysOfAssoc: 16; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr49), + (D: $4A; Family: cfL3Cache; Size: 6144; WaysOfAssoc: 12; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr4A), + (D: $4B; Family: cfL3Cache; Size: 8192; WaysOfAssoc: 16; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr4B), + (D: $4C; Family: cfL3Cache; Size: 12288; WaysOfAssoc: 12; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr4C), + (D: $4D; Family: cfL3Cache; Size: 16384; WaysOfAssoc: 16; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr4D), + (D: $4E; Family: cfL3Cache; Size: 6144; WaysOfAssoc: 24; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr4E), + (D: $4F; Family: cfInstructionTLB; Size: 4; WaysOfAssoc: 0; LineSize: 0; LinePerSector: 0; Entries: 32; I: @RsIntelCacheDescr4F), + (D: $50; Family: cfInstructionTLB; Size: 4; WaysOfAssoc: 0; LineSize: 0; LinePerSector: 0; Entries: 64; I: @RsIntelCacheDescr50), + (D: $51; Family: cfInstructionTLB; Size: 4; WaysOfAssoc: 0; LineSize: 0; LinePerSector: 0; Entries: 128; I: @RsIntelCacheDescr51), + (D: $52; Family: cfInstructionTLB; Size: 4; WaysOfAssoc: 0; LineSize: 0; LinePerSector: 0; Entries: 256; I: @RsIntelCacheDescr52), + (D: $55; Family: cfInstructionTLB; Size: 2048; WaysOfAssoc: 0; LineSize: 0; LinePerSector: 0; Entries: 7; I: @RsIntelCacheDescr55), + (D: $56; Family: cfDataTLB; Size: 4096; WaysOfAssoc: 4; LineSize: 0; LinePerSector: 0; Entries: 16; I: @RsIntelCacheDescr56), + (D: $57; Family: cfDataTLB; Size: 4; WaysOfAssoc: 4; LineSize: 0; LinePerSector: 0; Entries: 16; I: @RsIntelCacheDescr57), + (D: $59; Family: cfDataTLB; Size: 4; WaysOfAssoc: 0; LineSize: 0; LinePerSector: 0; Entries: 16; I: @RsIntelCacheDescr59), + (D: $5A; Family: cfDataTLB; Size: 4096; WaysOfAssoc: 4; LineSize: 0; LinePerSector: 0; Entries: 32; I: @RsIntelCacheDescr5A), + (D: $5B; Family: cfDataTLB; Size: 4096; WaysOfAssoc: 0; LineSize: 0; LinePerSector: 0; Entries: 64; I: @RsIntelCacheDescr5B), + (D: $5C; Family: cfDataTLB; Size: 4096; WaysOfAssoc: 0; LineSize: 0; LinePerSector: 0; Entries: 128; I: @RsIntelCacheDescr5C), + (D: $5D; Family: cfDataTLB; Size: 4096; WaysOfAssoc: 0; LineSize: 0; LinePerSector: 0; Entries: 256; I: @RsIntelCacheDescr5D), + (D: $60; Family: cfL1DataCache; Size: 16; WaysOfAssoc: 8; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr60), + (D: $66; Family: cfL1DataCache; Size: 8; WaysOfAssoc: 4; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr66), + (D: $67; Family: cfL1DataCache; Size: 16; WaysOfAssoc: 4; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr67), + (D: $68; Family: cfL1DataCache; Size: 32; WaysOfAssoc: 4; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr68), + (D: $70; Family: cfTrace; Size: 12; WaysOfAssoc: 8; LineSize: 0; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr70), + (D: $71; Family: cfTrace; Size: 16; WaysOfAssoc: 8; LineSize: 0; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr71), + (D: $72; Family: cfTrace; Size: 32; WaysOfAssoc: 8; LineSize: 0; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr72), + (D: $73; Family: cfTrace; Size: 64; WaysOfAssoc: 8; LineSize: 0; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr73), + (D: $76; Family: cfInstructionTLB; Size: 2048; WaysOfAssoc: 0; LineSize: 0; LinePerSector: 0; Entries: 8; I: @RsIntelCacheDescr76), + (D: $78; Family: cfL2Cache; Size: 1024; WaysOfAssoc: 4; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr78), + (D: $79; Family: cfL2Cache; Size: 128; WaysOfAssoc: 8; LineSize: 64; LinePerSector: 2; Entries: 0; I: @RsIntelCacheDescr79), + (D: $7A; Family: cfL2Cache; Size: 256; WaysOfAssoc: 8; LineSize: 64; LinePerSector: 2; Entries: 0; I: @RsIntelCacheDescr7A), + (D: $7B; Family: cfL2Cache; Size: 512; WaysOfAssoc: 8; LineSize: 64; LinePerSector: 2; Entries: 0; I: @RsIntelCacheDescr7B), + (D: $7C; Family: cfL2Cache; Size: 1024; WaysOfAssoc: 8; LineSize: 64; LinePerSector: 2; Entries: 0; I: @RsIntelCacheDescr7C), + (D: $7D; Family: cfL2Cache; Size: 2048; WaysOfAssoc: 8; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr7D), + (D: $7F; Family: cfL2Cache; Size: 512; WaysOfAssoc: 2; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr7F), + (D: $80; Family: cfL2Cache; Size: 512; WaysOfAssoc: 8; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr80), + (D: $82; Family: cfL2Cache; Size: 256; WaysOfAssoc: 8; LineSize: 32; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr82), + (D: $83; Family: cfL2Cache; Size: 512; WaysOfAssoc: 8; LineSize: 32; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr83), + (D: $84; Family: cfL2Cache; Size: 1024; WaysOfAssoc: 8; LineSize: 32; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr84), + (D: $85; Family: cfL2Cache; Size: 2048; WaysOfAssoc: 8; LineSize: 32; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr85), + (D: $86; Family: cfL2Cache; Size: 512; WaysOfAssoc: 4; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr86), + (D: $87; Family: cfL2Cache; Size: 1024; WaysOfAssoc: 8; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescr87), + (D: $B0; Family: cfInstructionTLB; Size: 4; WaysOfAssoc: 4; LineSize: 0; LinePerSector: 0; Entries: 128; I: @RsIntelCacheDescrB0), + (D: $B1; Family: cfInstructionTLB; Size: 2048; WaysOfAssoc: 4; LineSize: 0; LinePerSector: 0; Entries: 8; I: @RsIntelCacheDescrB1), + (D: $B2; Family: cfInstructionTLB; Size: 4; WaysOfAssoc: 4; LineSize: 0; LinePerSector: 0; Entries: 64; I: @RsIntelCacheDescrB2), + (D: $B3; Family: cfDataTLB; Size: 4; WaysOfAssoc: 4; LineSize: 0; LinePerSector: 0; Entries: 128; I: @RsIntelCacheDescrB3), + (D: $B4; Family: cfDataTLB; Size: 4; WaysOfAssoc: 4; LineSize: 0; LinePerSector: 0; Entries: 256; I: @RsIntelCacheDescrB4), + (D: $BA; Family: cfDataTLB; Size: 4; WaysOfAssoc: 4; LineSize: 0; LinePerSector: 0; Entries: 64; I: @RsIntelCacheDescrBA), + (D: $C0; Family: cfDataTLB; Size: 4; WaysOfAssoc: 4; LineSize: 0; LinePerSector: 0; Entries: 8; I: @RsIntelCacheDescrC0), + (D: $CA; Family: cfL2TLB; Size: 4; WaysOfAssoc: 4; LineSize: 0; LinePerSector: 0; Entries: 512; I: @RsIntelCacheDescrCA), + (D: $D0; Family: cfL3Cache; Size: 512; WaysOfAssoc: 4; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescrD0), + (D: $D1; Family: cfL3Cache; Size: 1024; WaysOfAssoc: 4; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescrD1), + (D: $D2; Family: cfL3Cache; Size: 2048; WaysOfAssoc: 4; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescrD2), + (D: $D6; Family: cfL3Cache; Size: 1024; WaysOfAssoc: 8; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescrD6), + (D: $D7; Family: cfL3Cache; Size: 2048; WaysOfAssoc: 8; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescrD7), + (D: $D8; Family: cfL3Cache; Size: 4096; WaysOfAssoc: 8; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescrD8), + (D: $DC; Family: cfL3Cache; Size: 1536; WaysOfAssoc: 12; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescrDC), + (D: $DD; Family: cfL3Cache; Size: 3072; WaysOfAssoc: 12; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescrDD), + (D: $DE; Family: cfL3Cache; Size: 6144; WaysOfAssoc: 12; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescrDE), + (D: $E2; Family: cfL3Cache; Size: 2048; WaysOfAssoc: 16; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescrE2), + (D: $E3; Family: cfL3Cache; Size: 4096; WaysOfAssoc: 16; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescrE3), + (D: $E4; Family: cfL3Cache; Size: 8192; WaysOfAssoc: 16; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescrE4), + (D: $EA; Family: cfL3Cache; Size: 12288; WaysOfAssoc: 24; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescrEA), + (D: $EB; Family: cfL3Cache; Size: 18432; WaysOfAssoc: 24; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescrEB), + (D: $EC; Family: cfL3Cache; Size: 24576; WaysOfAssoc: 24; LineSize: 64; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescrEC), + (D: $F0; Family: cfOther; Size: 0; WaysOfAssoc: 0; LineSize: 0; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescrF0), + (D: $F1; Family: cfOther; Size: 0; WaysOfAssoc: 0; LineSize: 0; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescrF1), + (D: $FF; Family: cfOther; Size: 0; WaysOfAssoc: 0; LineSize: 0; LinePerSector: 0; Entries: 0; I: @RsIntelCacheDescrFF) + ); + +{$IFNDEF WINSCP} +procedure GetCpuInfo(var CpuInfo: TCpuInfo); +{$ENDIF ~WINSCP} + +function GetIntelCacheDescription(const D: Byte): string; +function RoundFrequency(const Frequency: Integer): Integer; +{$IFDEF MSWINDOWS} +function GetCPUSpeed(var CpuSpeed: TFreqInfo): Boolean; + +type + TOSEnabledFeature = (oefFPU, oefSSE, oefAVX); + TOSEnabledFeatures = set of TOSEnabledFeature; + +function GetOSEnabledFeatures: TOSEnabledFeatures; +{$ENDIF MSWINDOWS} +{$IFNDEF WINSCP} +function CPUID: TCpuInfo; +{$ENDIF ~WINSCP} +function TestFDIVInstruction: Boolean; + +// Memory Information +{$IFDEF MSWINDOWS} +function GetMaxAppAddress: TJclAddr; +function GetMinAppAddress: TJclAddr; +{$ENDIF MSWINDOWS} +function GetMemoryLoad: Byte; +function GetSwapFileSize: Int64; +function GetSwapFileUsage: Byte; +function GetTotalPhysicalMemory: Int64; +function GetFreePhysicalMemory: Int64; +{$IFDEF MSWINDOWS} +function GetTotalPageFileMemory: Int64; +function GetFreePageFileMemory: Int64; +function GetTotalVirtualMemory: Int64; +function GetFreeVirtualMemory: Int64; +{$ENDIF MSWINDOWS} + +// Alloc granularity +procedure RoundToAllocGranularity64(var Value: Int64; Up: Boolean); +procedure RoundToAllocGranularityPtr(var Value: Pointer; Up: Boolean); + +{$IFDEF MSWINDOWS} +// Keyboard Information +function GetKeyState(const VirtualKey: Cardinal): Boolean; +function GetNumLockKeyState: Boolean; +function GetScrollLockKeyState: Boolean; +function GetCapsLockKeyState: Boolean; + +// Windows 95/98/Me system resources information +type + TFreeSysResKind = (rtSystem, rtGdi, rtUser); + TFreeSystemResources = record + SystemRes: Integer; + GdiRes: Integer; + UserRes: Integer; + end; + +function IsSystemResourcesMeterPresent: Boolean; + +function GetFreeSystemResources(const ResourceType: TFreeSysResKind): Integer; overload; +function GetFreeSystemResources: TFreeSystemResources; overload; +function GetBPP: Cardinal; + +// Installed programs information +function ProgIDExists(const ProgID: string): Boolean; +function IsWordInstalled: Boolean; +function IsExcelInstalled: Boolean; +function IsAccessInstalled: Boolean; +function IsPowerPointInstalled: Boolean; +function IsFrontPageInstalled: Boolean; +function IsOutlookInstalled: Boolean; +function IsInternetExplorerInstalled: Boolean; +function IsMSProjectInstalled: Boolean; +function IsOpenOfficeInstalled: Boolean; +function IsLibreOfficeInstalled: Boolean; + +{$ENDIF MSWINDOWS} + +// Public global variables +var + ProcessorCount: Cardinal = 0; + AllocGranularity: Cardinal = 0; + PageSize: Cardinal = 0; + +{$IFDEF UNITVERSIONING} +const + UnitVersioning: TUnitVersionInfo = ( + RCSfile: '$URL$'; + Revision: '$Revision$'; + Date: '$Date$'; + LogPath: 'JCL\source\common'; + Extra: ''; + Data: nil + ); +{$ENDIF UNITVERSIONING} + +implementation + +uses + {$IFDEF WINSCP} + Registry, + {$ENDIF ~WINSCP} + {$IFDEF HAS_UNITSCOPE} + System.SysUtils, System.Math, + {$IFDEF MSWINDOWS} + Winapi.Messages, Winapi.Winsock, {$IFNDEF WINSCP}Snmp,{$ENDIF ~WINSCP} + {$IFDEF FPC} + JwaTlHelp32, JwaPsApi, + {$ELSE ~FPC} + Winapi.TLHelp32, Winapi.PsApi, + {$IFNDEF WINSCP} + JclShell, + {$ENDIF ~WINSCP} + {$ENDIF ~FPC} + {$IFNDEF WINSCP}JclRegistry,{$ENDIF ~WINSCP} JclWin32, + {$ENDIF MSWINDOWS} + {$ELSE ~HAS_UNITSCOPE} + SysUtils, + Math, + {$IFDEF MSWINDOWS} + Messages, Winsock, Snmp, + {$IFDEF FPC} + JwaTlHelp32, JwaPsApi, + {$ELSE ~FPC} + TLHelp32, PsApi, + JclShell, + {$ENDIF ~FPC} + JclRegistry, JclWin32, + {$ENDIF MSWINDOWS} + {$ENDIF ~HAS_UNITSCOPE} + {$IFNDEF WINSCP}Jcl8087, JclIniFiles,{$ENDIF ~WINSCP} + JclSysUtils, JclFileUtils, {$IFNDEF WINSCP}JclAnsiStrings,{$ENDIF ~WINSCP} JclStrings; + +{$IFDEF WINSCP} + +type + DelphiHKEY = {$IFDEF CPUX64}type Winapi.Windows.HKEY{$ELSE}Longword{$ENDIF CPUX64}; + +function RegReadStringDef(const RootKey: DelphiHKEY; const Key, Name: string; Def: string): string; +var + Registry: TRegistry; +begin + Result := Def; + try + Registry := TRegistry.Create; + try + Registry.Access := KEY_READ; + Registry.RootKey := RootKey; + if Registry.OpenKey(Key, False) and + Registry.ValueExists(Name) then + begin + Result := Registry.ReadString(Name); + end; + finally + Registry.Free; + end; + except + end; +end; + +{$ENDIF ~WINSCP} + +{.$IFDEF FPC} +{$IFDEF MSWINDOWS} + +function PidlToPath(IdList: PItemIdList): string; +begin + SetLength(Result, MAX_PATH); + if SHGetPathFromIdList(IdList, PChar(Result)) then + StrResetLength(Result) + else + Result := ''; +end; + +//---------------------------------------------------------------------------- + +function GetSpecialFolderLocation(const Folder: Integer): string; +var + FolderPidl: PItemIdList; +begin + FolderPidl := nil; + if Succeeded(SHGetSpecialFolderLocation(0, Folder, FolderPidl)) then + begin + try + Result := PidlToPath(FolderPidl); + finally + CoTaskMemFree(FolderPidl); + end; + end + else + Result := ''; +end; + +//---------------------------------------------------------------------------- + +{$ENDIF MSWINDOWS} +{.$ENDIF FPC} + +//=== Environment ============================================================ + +function DelEnvironmentVar(const Name: string): Boolean; +begin + {$IFDEF UNIX} + UnSetEnv(PChar(Name)); + Result := True; + {$ENDIF UNIX} + {$IFDEF MSWINDOWS} + Result := SetEnvironmentVariable(PChar(Name), nil); + {$ENDIF MSWINDOWS} +end; + +function ExpandEnvironmentVar(var Value: string): Boolean; +{$IFDEF UNIX} +begin + Result := True; +end; +{$ENDIF UNIX} +{$IFDEF MSWINDOWS} +var + R: Integer; + Expanded: string; +begin + SetLength(Expanded, 1); + R := ExpandEnvironmentStrings(PChar(Value), PChar(Expanded), 0); + SetLength(Expanded, R); + Result := ExpandEnvironmentStrings(PChar(Value), PChar(Expanded), R) <> 0; + if Result then + begin + StrResetLength(Expanded); + Value := Expanded; + end; +end; +{$ENDIF MSWINDOWS} + +function ExpandEnvironmentVarCustom(var Value: string; Vars: TStrings): Boolean; + + function FindClosingBrace(const R: string; var Position: Integer): Boolean; + var + Index, Len, BraceCount: Integer; + Quotes: string; + begin + Len := Length(R); + BraceCount := 0; + Quotes := ''; + while (Position <= Len) do + begin + // handle quotes first + if (R[Position] = NativeSingleQuote) then + begin + Index := JclStrings.CharPos(Quotes, NativeSingleQuote); + if Index >= 0 then + SetLength(Quotes, Index - 1) + else + Quotes := Quotes + NativeSingleQuote; + end; + + if (R[Position] = NativeDoubleQuote) then + begin + Index := JclStrings.CharPos(Quotes, NativeDoubleQuote); + if Index >= 0 then + SetLength(Quotes, Index - 1) + else + Quotes := Quotes + NativeDoubleQuote; + end; + + if (R[Position] = '`') then + begin + Index := JclStrings.CharPos(Quotes, '`'); + if Index >= 0 then + SetLength(Quotes, Index - 1) + else + Quotes := Quotes + '`'; + end; + + if Quotes = '' then + begin + if R[Position] = ')' then + begin + Dec(BraceCount); + if BraceCount = 0 then + Break; + end + else + if R[Position] = '(' then + Inc(BraceCount); + end; + Inc(Position); + end; + Result := Position <= Len; + +// Delphi XE's CodeGear.Delphi.Targets has a bug where the closing paran is missing +// "'$(DelphiWin32DebugDCUPath'!=''". But it is still a valid string and not worth +// an exception. +// +// if Position > Len then +// raise EJclMsBuildError.CreateResFmt(@RsEEndOfString, [S]); + end; + +var + Start, Position: Integer; + PropertyName, PropertyValue: string; +begin + Result := True; + repeat + // start with the last match in order to convert $(some$(other)) + // evaluate properties + Start := StrLastPos('$(', Value); + if Start > 0 then + begin + Position := Start; + if not FindClosingBrace(Value, Position) then + Break; + PropertyName := Copy(Value, Start + 2, Position - Start - 2); + + PropertyValue := Vars.Values[PropertyName]; + + if PropertyValue <> '' then + StrReplace(Value, + Copy(Value, Start, Position - Start + 1), // $(PropertyName) + PropertyValue, + [rfReplaceAll, rfIgnoreCase]) + else + begin + Result := False; + Start := 0; + end; + end; + until Start = 0; +end; + +{$IFDEF UNIX} + +function GetEnvironmentVar(const Name: string; var Value: string): Boolean; +begin + Value := getenv(PChar(Name)); + Result := Value <> ''; +end; + +function GetEnvironmentVar(const Name: string; var Value: string; Expand: Boolean): Boolean; +begin + Result := GetEnvironmentVar(Name, Value); // Expand is there just for x-platform compatibility +end; + +{$ENDIF UNIX} + +{$IFDEF MSWINDOWS} + +function GetEnvironmentVar(const Name: string; out Value: string): Boolean; +begin + Result := GetEnvironmentVar(Name, Value, True); +end; + +function GetEnvironmentVar(const Name: string; out Value: string; Expand: Boolean): Boolean; +var + R: DWORD; +begin + R := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.GetEnvironmentVariable(PChar(Name), nil, 0); + SetLength(Value, R); + R := {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.GetEnvironmentVariable(PChar(Name), PChar(Value), R); + Result := R <> 0; + if not Result then + Value := '' + else + begin + SetLength(Value, R); + if Expand then + ExpandEnvironmentVar(Value); + end; +end; + +{$ENDIF MSWINDOWS} + +{$IFDEF LINUX} +function GetEnvironmentVars(const Vars: TStrings): Boolean; +var + P: PPChar; +begin + Vars.BeginUpdate; + try + Vars.Clear; + P := System.envp; + Result := P <> nil; + while (P <> nil) and (P^ <> nil) do + begin + Vars.Add(P^); + Inc(P); + end; + finally + Vars.EndUpdate; + end; +end; + +function GetEnvironmentVars(const Vars: TStrings; Expand: Boolean): Boolean; +begin + Result := GetEnvironmentVars(Vars); // Expand is there just for x-platform compatibility +end; +{$ENDIF LINUX} + +{$IFDEF MSWINDOWS} +{$IFNDEF WINSCP} +function GetEnvironmentVars(const Vars: TStrings): Boolean; +begin + Result := GetEnvironmentVars(Vars, True); +end; + +function GetEnvironmentVars(const Vars: TStrings; Expand: Boolean): Boolean; +var + Raw: PChar; + Expanded: string; + I: Integer; +begin + Vars.BeginUpdate; + try + Vars.Clear; + Raw := GetEnvironmentStrings; + try + MultiSzToStrings(Vars, Raw); + Result := True; + finally + FreeEnvironmentStrings(Raw); + end; + if Expand then + begin + for I := 0 to Vars.Count - 1 do + begin + Expanded := Vars[I]; + if ExpandEnvironmentVar(Expanded) then + Vars[I] := Expanded; + end; + end; + finally + Vars.EndUpdate; + end; +end; +{$ENDIF ~WINSCP} + +{$ENDIF MSWINDOWS} + +function SetEnvironmentVar(const Name, Value: string): Boolean; +begin + {$IFDEF UNIX} + SetEnv(PChar(Name), PChar(Value), 1); + Result := True; + {$ENDIF UNIX} + {$IFDEF MSWINDOWS} + Result := SetEnvironmentVariable(PChar(Name), PChar(Value)); + {$ENDIF MSWINDOWS} +end; + +{$IFDEF MSWINDOWS} + +{$IFNDEF WINSCP} +function CreateEnvironmentBlock(const Options: TEnvironmentOptions; const AdditionalVars: TStrings): PChar; +const + RegLocalEnvironment = 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'; + RegUserEnvironment = '\Environment\'; +var + KeyNames, TempList: TStrings; + Temp, Name, Value: string; + I: Integer; +begin + TempList := TStringList.Create; + try + // add additional environment variables + if eoAdditional in Options then + for I := 0 to AdditionalVars.Count - 1 do + begin + Temp := AdditionalVars[I]; + ExpandEnvironmentVar(Temp); + TempList.Add(Temp); + end; + // get environment strings from local machine + if eoLocalMachine in Options then + begin + KeyNames := TStringList.Create; + try + if RegGetValueNames(HKEY_LOCAL_MACHINE, RegLocalEnvironment, KeyNames) then + begin + for I := 0 to KeyNames.Count - 1 do + begin + Name := KeyNames[I]; + Value := RegReadString(HKEY_LOCAL_MACHINE, RegLocalEnvironment, Name); + ExpandEnvironmentVar(Value); + TempList.Add(Name + '=' + Value); + end; + end; + finally + FreeAndNil(KeyNames); + end; + end; + // get environment strings from current user + if eoCurrentUser in Options then + begin + KeyNames := TStringLIst.Create; + try + if RegGetValueNames(HKEY_CURRENT_USER, RegUserEnvironment, KeyNames) then + begin + for I := 0 to KeyNames.Count - 1 do + begin + Name := KeyNames[I]; + Value := RegReadString(HKEY_CURRENT_USER, RegUserEnvironment, Name); + ExpandEnvironmentVar(Value); + TempList.Add(Name + '=' + Value); + end; + end; + finally + KeyNames.Free; + end; + end; + // transform stringlist into multi-PChar + Result := nil; + StringsToMultiSz(Result, TempList); + finally + FreeAndNil(TempList); + end; +end; +{$ENDIF ~WINSCP} + +// frees an environment block allocated by CreateEnvironmentBlock and +// sets Env to nil + +{$IFNDEF WINSCP} +procedure DestroyEnvironmentBlock(var Env: PChar); +begin + FreeMultiSz(Env); +end; + +procedure SetGlobalEnvironmentVariable(VariableName, VariableContent: string); +const + cEnvironment = 'Environment'; +begin + if VariableName = '' then + Exit; + if VariableContent = '' then + begin + RegDeleteEntry(HKEY_CURRENT_USER, cEnvironment, VariableName); + SetEnvironmentVariable(PChar(VariableName), nil); + end + else + begin + RegWriteString(HKEY_CURRENT_USER, cEnvironment, VariableName, VariableContent); + SetEnvironmentVariable(PChar(VariableName), PChar(VariableContent)); + end; + SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, LPARAM(PChar(cEnvironment))); +end; +{$ENDIF ~WINSCP} + +//=== Common Folders ========================================================= + +// Utility function which returns the Windows independent CurrentVersion key +// inside HKEY_LOCAL_MACHINE + +const + HKLM_CURRENT_VERSION_WINDOWS = 'SOFTWARE\Microsoft\Windows\CurrentVersion'; + HKLM_CURRENT_VERSION_NT = 'SOFTWARE\Microsoft\Windows NT\CurrentVersion'; + +function REG_CURRENT_VERSION: string; +begin + if IsWinNT then + Result := HKLM_CURRENT_VERSION_NT + else + Result := HKLM_CURRENT_VERSION_WINDOWS; +end; + +{ TODO : Check for documented solution } +function GetCommonFilesFolder: string; +begin + Result := RegReadStringDef(HKEY_LOCAL_MACHINE, HKLM_CURRENT_VERSION_WINDOWS, + 'CommonFilesDir', ''); +end; + +{$ENDIF MSWINDOWS} + +function GetCurrentFolder: string; +{$IFDEF UNIX} +const + InitialSize = 64; +var + Size: Integer; +begin + Size := InitialSize; + while True do + begin + SetLength(Result, Size); + if getcwd(PChar(Result), Size) <> nil then + begin + StrResetLength(Result); + Exit; + end; + {$IFDEF FPC} + if GetLastOSError <> ERANGE then + {$ELSE ~FPC} + if GetLastError <> ERANGE then + {$ENDIF ~FPC} + RaiseLastOSError; + Size := Size * 2; + end; +end; +{$ENDIF UNIX} +{$IFDEF MSWINDOWS} +var + Required: Cardinal; +begin + Result := ''; + Required := GetCurrentDirectory(0, nil); + if Required <> 0 then + begin + SetLength(Result, Required); + GetCurrentDirectory(Required, PChar(Result)); + StrResetLength(Result); + end; +end; +{$ENDIF MSWINDOWS} + +{$IFDEF MSWINDOWS} +{ TODO : Check for documented solution } +function GetProgramFilesFolder: string; +begin + Result := RegReadStringDef(HKEY_LOCAL_MACHINE, HKLM_CURRENT_VERSION_WINDOWS, 'ProgramFilesDir', ''); +end; + +{ TODO : Check for documented solution } +function GetWindowsFolder: string; +var + Required: Cardinal; +begin + Result := ''; + Required := GetWindowsDirectory(nil, 0); + if Required <> 0 then + begin + SetLength(Result, Required); + GetWindowsDirectory(PChar(Result), Required); + StrResetLength(Result); + end; +end; + +{ TODO : Check for documented solution } +function GetWindowsSystemFolder: string; +var + Required: Cardinal; +begin + Result := ''; + Required := GetSystemDirectory(nil, 0); + if Required <> 0 then + begin + SetLength(Result, Required); + GetSystemDirectory(PChar(Result), Required); + StrResetLength(Result); + end; +end; + +function GetWindowsTempFolder: string; +begin + Result := PathRemoveSeparator(PathGetTempPath); +end; + +function GetDesktopFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_DESKTOP); +end; + +{ TODO : Check GetProgramsFolder = GetProgramFilesFolder } +function GetProgramsFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_PROGRAMS); +end; + +{$ENDIF MSWINDOWS} +{$IFNDEF WINSCP} +function GetPersonalFolder: string; +begin + {$IFDEF UNIX} + Result := GetEnvironmentVariable('HOME'); + {$ENDIF UNIX} + {$IFDEF MSWINDOWS} + Result := GetSpecialFolderLocation(CSIDL_PERSONAL); + {$ENDIF MSWINDOWS} +end; + +{$IFDEF MSWINDOWS} +function GetFavoritesFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_FAVORITES); +end; + +function GetStartupFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_STARTUP); +end; + +function GetRecentFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_RECENT); +end; + +function GetSendToFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_SENDTO); +end; + +function GetStartmenuFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_STARTMENU); +end; + +function GetDesktopDirectoryFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_DESKTOPDIRECTORY); +end; + +function GetCommonDocumentsFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_COMMON_DOCUMENTS); +end; + +function GetNethoodFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_NETHOOD); +end; + +function GetFontsFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_FONTS); +end; + +function GetCommonStartmenuFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_COMMON_STARTMENU); +end; + +function GetCommonProgramsFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_COMMON_PROGRAMS); +end; + +function GetCommonStartupFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_COMMON_STARTUP); +end; + +function GetCommonDesktopdirectoryFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_COMMON_DESKTOPDIRECTORY); +end; + +function GetCommonAppdataFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_COMMON_APPDATA); +end; + +function GetAppdataFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_APPDATA); +end; + +function GetLocalAppData: string; +begin + Result := GetSpecialFolderLocation(CSIDL_LOCAL_APPDATA); +end; + +function GetPrinthoodFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_PRINTHOOD); +end; + +function GetCommonFavoritesFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_COMMON_FAVORITES); +end; + +function GetTemplatesFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_TEMPLATES); +end; + +function GetInternetCacheFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_INTERNET_CACHE); +end; + +function GetCookiesFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_COOKIES); +end; + +function GetHistoryFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_HISTORY); +end; + +function GetProfileFolder: string; +begin + Result := GetSpecialFolderLocation(CSIDL_PROFILE); +end; +{$ENDIF ~WINSCP} + +// the following special folders are pure virtual and cannot be +// mapped to a directory path: +// CSIDL_INTERNET +// CSIDL_CONTROLS +// CSIDL_PRINTERS +// CSIDL_BITBUCKET +// CSIDL_DRIVES +// CSIDL_NETWORK +// CSIDL_ALTSTARTUP +// CSIDL_COMMON_ALTSTARTUP + +// Identification +type + TVolumeInfoKind = (vikName, vikSerial, vikFileSystem); + +function GetVolumeInfoHelper(const Drive: string; InfoKind: TVolumeInfoKind): string; +var + VolumeSerialNumber: DWORD; + MaximumComponentLength: DWORD; + Flags: DWORD; + Name: array [0..MAX_PATH] of Char; + FileSystem: array [0..15] of Char; + ErrorMode: Cardinal; + DriveStr: string; +begin + { TODO : Change to RootPath } + { TODO : Perform better checking of Drive param or document that no checking + is performed. RM Suggested: + DriveStr := Drive; + if (Length(Drive) < 2) or (Drive[2] <> ':') then + DriveStr := GetCurrentFolder; + DriveStr := DriveStr[1] + ':\'; } + Result := ''; + DriveStr := Drive + ':\'; + ErrorMode := SetErrorMode(SEM_FAILCRITICALERRORS); + try + Flags := 0; + MaximumComponentLength := 0; + if GetVolumeInformation(PChar(DriveStr), Name, SizeOf(Name), @VolumeSerialNumber, + MaximumComponentLength, Flags, FileSystem, SizeOf(FileSystem)) then + case InfoKind of + vikName: + Result := StrPas(Name); + vikSerial: + begin + Result := IntToHex(HiWord(VolumeSerialNumber), 4) + '-' + + IntToHex(LoWord(VolumeSerialNumber), 4); + end; + vikFileSystem: + Result := StrPas(FileSystem); + end; + finally + SetErrorMode(ErrorMode); + end; +end; + +function GetVolumeName(const Drive: string): string; +begin + Result := GetVolumeInfoHelper(Drive, vikName); +end; + +function GetVolumeSerialNumber(const Drive: string): string; +begin + Result := GetVolumeInfoHelper(Drive, vikSerial); +end; + +function GetVolumeFileSystem(const Drive: string): string; +begin + Result := GetVolumeInfoHelper(Drive, vikFileSystem); +end; + +{ TODO -cHelp : Donator (incl. TFileSystemFlag[s]): Robert Rossmair } + +function GetVolumeFileSystemFlags(const Volume: string): TFileSystemFlags; +const + FileSystemFlags: array [TFileSystemFlag] of DWORD = + ( FILE_CASE_SENSITIVE_SEARCH, // fsCaseSensitive + FILE_CASE_PRESERVED_NAMES, // fsCasePreservedNames + FILE_UNICODE_ON_DISK, // fsSupportsUnicodeOnDisk + FILE_PERSISTENT_ACLS, // fsPersistentACLs + FILE_FILE_COMPRESSION, // fsSupportsFileCompression + FILE_VOLUME_QUOTAS, // fsSupportsVolumeQuotas + FILE_SUPPORTS_SPARSE_FILES, // fsSupportsSparseFiles + FILE_SUPPORTS_REPARSE_POINTS, // fsSupportsReparsePoints + FILE_SUPPORTS_REMOTE_STORAGE, // fsSupportsRemoteStorage + FILE_VOLUME_IS_COMPRESSED, // fsVolumeIsCompressed + FILE_SUPPORTS_OBJECT_IDS, // fsSupportsObjectIds + FILE_SUPPORTS_ENCRYPTION, // fsSupportsEncryption + FILE_NAMED_STREAMS, // fsSupportsNamedStreams + FILE_READ_ONLY_VOLUME // fsVolumeIsReadOnly + ); +var + MaximumComponentLength, Flags: Cardinal; + Flag: TFileSystemFlag; +begin + Flags := 0; + MaximumComponentLength := 0; + if not GetVolumeInformation(PChar(PathAddSeparator(Volume)), nil, 0, nil, + MaximumComponentLength, Flags, nil, 0) then + RaiseLastOSError; + Result := []; + for Flag := Low(TFileSystemFlag) to High(TFileSystemFlag) do + if (Flags and FileSystemFlags[Flag]) <> 0 then + Include(Result, Flag); +end; + +{$ENDIF MSWINDOWS} + +{ TODO -cDoc: Contributor: twm } + +function GetIPAddress(const HostName: string): string; +var + {$IFDEF MSWINDOWS} + R: Integer; + WSAData: TWSAData; + {$ENDIF MSWINDOWS} + HostEnt: PHostEnt; + Host: AnsiString; + SockAddr: TSockAddrIn; +begin + Result := ''; + {$IFDEF MSWINDOWS} + WSAData.wVersion := 0; + R := WSAStartup(MakeWord(1, 1), WSAData); + if R = 0 then + try + {$ENDIF MSWINDOWS} + Host := AnsiString(HostName); + if Host = '' then + begin + SetLength(Host, MAX_PATH); + GetHostName(PAnsiChar(Host), MAX_PATH); + end; + HostEnt := GetHostByName(PAnsiChar(Host)); + if HostEnt <> nil then + begin + SockAddr.sin_addr.S_addr := Longint(PLongint(HostEnt^.h_addr_list^)^); + Result := string(AnsiString(inet_ntoa(SockAddr.sin_addr))); + end; + {$IFDEF MSWINDOWS} + finally + WSACleanup; + end; + {$ENDIF MSWINDOWS} +end; + +{ TODO -cDoc: Donator: twm } + +{$IFDEF MSWINDOWS} +procedure GetIpAddresses(Results: TStrings); +begin + GetIpAddresses(Results, ''); +end; + +procedure GetIpAddresses(Results: TStrings; const HostName: AnsiString); +type + TaPInAddr = array[0..10] of PInAddr; + PaPInAddr = ^TaPInAddr; +var + R: Integer; + HostEnt: PHostEnt; + pptr: PaPInAddr; + Host: AnsiString; + i: Integer; + WSAData: TWSAData; +begin + //need a socket for ioctl() + WSAData.wVersion := 0; + R := WSAStartup(MakeWord(1, 1), WSAData); + if R = 0 then begin + try + if HostName = '' then + begin + SetLength(Host, MAX_PATH); + GetHostName(PAnsiChar(Host), MAX_PATH); + end + else + Host := HostName; + + HostEnt := GetHostByName(PAnsiChar(Host)); + if HostEnt <> nil then + begin + pPtr := PaPInAddr(HostEnt^.h_addr_list); + i := 0; + while pPtr^[I] <> nil do begin + Results.Add(string(AnsiString(inet_ntoa(pptr^[i]^)))); // OF AnsiString to TStrings + Inc(i); + end; + end; + finally + WSACleanup; + end; + end; +end; +{$ENDIF MSWINDOWS} + +{$IFDEF UNIX} + +{ TODO -cDoc: Donator: twm, Contributor rrossmair } + +// Returns all IP addresses of the local machine in the form +// = (which allows for access to the interface names +// by means of Results.Names and the addresses through Results.Values) +// +// Example: +// +// lo=127.0.0.1 +// eth0=10.10.10.1 +// ppp0=217.82.187.130 +// +// note that this will append to Results! +// + +procedure GetIpAddresses(Results: TStrings); +var + Sock: Integer; + IfReq: TIfReq; + SockAddrPtr: PSockAddrIn; + ListSave, IfList: PIfNameIndex; +begin + //need a socket for ioctl() + Sock := socket(AF_INET, SOCK_STREAM, 0); + if Sock < 0 then + RaiseLastOSError; + + try + //returns pointer to dynamically allocated list of structs + ListSave := if_nameindex(); + try + IfList := ListSave; + //walk thru the array returned and query for each + //interface's address + while IfList^.if_index <> 0 do + begin + //copy in the interface name to look up address of + {$IFDEF FPC} + strncpy(IfReq.ifr_ifrn.ifrn_name, IfList^.if_name, IFNAMSIZ); + {$ELSE ~FPC} + strncpy(IfReq.ifrn_name, IfList^.if_name, IFNAMSIZ); + {$ENDIF ~FPC} + //get the address for this interface + if ioctl(Sock, SIOCGIFADDR, @IfReq) <> 0 then + RaiseLastOSError; + //print out the address + {$IFDEF FPC} + SockAddrPtr := PSockAddrIn(@IfReq.ifr_ifru.ifru_addr); + Results.Add(Format('%s=%s', [IfReq.ifr_ifrn.ifrn_name, inet_ntoa(SockAddrPtr^.sin_addr)])); + {$ELSE ~FPC} + SockAddrPtr := PSockAddrIn(@IfReq.ifru_addr); + Results.Add(Format('%s=%s', [IfReq.ifrn_name, inet_ntoa(SockAddrPtr^.sin_addr)])); + {$ENDIF ~FPC} + Inc(IfList); + end; + finally + //free the dynamic memory kernel allocated for us + if_freenameindex(ListSave); + end; + finally + Libc.__close(Sock) + end; +end; + +{$ENDIF UNIX} + +function GetLocalComputerName: string; +// (rom) UNIX or LINUX? +{$IFDEF LINUX} +var + MachineInfo: utsname; +begin + uname(MachineInfo); + Result := MachineInfo.nodename; +end; +{$ENDIF LINUX} +{$IFDEF MSWINDOWS} +var + Count: DWORD; +begin + Count := MAX_COMPUTERNAME_LENGTH + 1; + // set buffer size to MAX_COMPUTERNAME_LENGTH + 2 characters for safety + { TODO : Win2k solution } + SetLength(Result, Count); + if GetComputerName(PChar(Result), Count) then + StrResetLength(Result) + else + Result := ''; +end; +{$ENDIF MSWINDOWS} + +function GetLocalUserName: string; +{$IFDEF UNIX} +begin + Result := GetEnv('USER'); +end; +{$ENDIF UNIX} +{$IFDEF MSWINDOWS} +var + Count: DWORD; +begin + Count := 256 + 1; // UNLEN + 1 + // set buffer size to 256 + 2 characters + { TODO : Win2k solution } + SetLength(Result, Count); + if GetUserName(PChar(Result), Count) then + StrResetLength(Result) + else + Result := ''; +end; +{$ENDIF MSWINDOWS} + +{$IFDEF MSWINDOWS} +function GetRegisteredCompany: string; +begin + { TODO : check for MSDN documentation } + Result := RegReadStringDef(HKEY_LOCAL_MACHINE, REG_CURRENT_VERSION, 'RegisteredOrganization', ''); +end; + +function GetRegisteredOwner: string; +begin + { TODO : check for MSDN documentation } + Result := RegReadStringDef(HKEY_LOCAL_MACHINE, REG_CURRENT_VERSION, 'RegisteredOwner', ''); +end; + +{ TODO: Check supported platforms, maybe complete rewrite } + +function GetUserDomainName(const CurUser: string): string; +var + Count1, Count2: DWORD; + Sd: PSID; // PSecurityDescriptor; // FPC requires PSID + Snu: SID_Name_Use; +begin + Count1 := 0; + Count2 := 0; + Sd := nil; + Snu := SIDTypeUser; + Result := ''; + LookUpAccountName(nil, PChar(CurUser), Sd, Count1, PChar(Result), Count2, Snu); + // set buffer size to Count2 + 2 characters for safety + SetLength(Result, Count2 + 1); + Sd := AllocMem(Count1); + try + if LookUpAccountName(nil, PChar(CurUser), Sd, Count1, PChar(Result), Count2, Snu) then + StrResetLength(Result) + else + Result := EmptyStr; + finally + FreeMem(Sd); + end; +end; + +function GetWorkGroupName: WideString; +var + WkstaInfo: PByte; + WkstaInfo100: PWKSTA_INFO_100; +begin + if NetWkstaGetInfo(nil, 100, WkstaInfo) <> NERR_Success then + raise EJclWin32Error.CreateRes(@RsENetWkstaGetInfo); + WkstaInfo100 := PWKSTA_INFO_100(WkstaInfo); + Result := WideString(PWideChar(WkstaInfo100^.wki100_langroup)); + NetApiBufferFree(Pointer(WkstaInfo)); +end; + +{$ENDIF MSWINDOWS} +function GetDomainName: string; +{$IFDEF UNIX} +var + MachineInfo: utsname; +begin + uname(MachineInfo); + Result := MachineInfo.domainname; +end; +{$ENDIF UNIX} +{$IFDEF MSWINDOWS} +//091123 HA Use LookupAccountSid to fetch the current users domain ... +//begin +// Result := GetUserDomainName(GetLocalUserName); +//end; +var + hProcess, hAccessToken: THandle; + InfoBuffer: PChar; + AccountName: array [0..UNLEN] of Char; + DomainName: array [0..UNLEN] of Char; + + InfoBufferSize: Cardinal; + AccountSize: Cardinal; + DomainSize: Cardinal; + snu: SID_NAME_USE; +begin + InfoBufferSize := 1000; + AccountSize := SizeOf(AccountName); + DomainSize := SizeOf(DomainName); + + hProcess := GetCurrentProcess; + if OpenProcessToken(hProcess, TOKEN_READ, hAccessToken) then + try + GetMem(InfoBuffer, InfoBufferSize); + try + if GetTokenInformation(hAccessToken, TokenUser, InfoBuffer, InfoBufferSize, InfoBufferSize) then + LookupAccountSid(nil, PSIDAndAttributes(InfoBuffer)^.sid, AccountName, AccountSize, + DomainName, DomainSize, snu) + else + RaiseLastOSError; + finally + FreeMem(InfoBuffer) + end; + Result := DomainName; + finally + CloseHandle(hAccessToken); + end +end; +{$ENDIF MSWINDOWS} + +{$IFDEF MSWINDOWS} +// Reference: How to Obtain BIOS Information from the Registry +// http://support.microsoft.com/default.aspx?scid=kb;en-us;q195268 + +function GetBIOSName: string; +const + Win9xBIOSInfoKey = 'Enum\Root\*PNP0C01\0000'; +begin + if IsWinNT then + Result := '' + else + Result := RegReadStringDef(HKEY_LOCAL_MACHINE, Win9xBIOSInfoKey, 'BIOSName', ''); +end; + +function GetBIOSCopyright: string; +const + ADR_BIOSCOPYRIGHT = $FE091; +begin + Result := ''; + if not IsWinNT and not IsBadReadPtr(Pointer(ADR_BIOSCOPYRIGHT), 2) then + try + Result := string(AnsiString(PAnsiChar(ADR_BIOSCOPYRIGHT))); + except + Result := ''; + end; +end; + +function GetBIOSExtendedInfo: string; +const + ADR_BIOSEXTENDEDINFO = $FEC71; +begin + Result := ''; + if not IsWinNT and not IsBadReadPtr(Pointer(ADR_BIOSEXTENDEDINFO), 2) then + try + Result := string(AnsiString(PAnsiChar(ADR_BIOSEXTENDEDINFO))); + except + Result := ''; + end; +end; + +// Reference: How to Obtain BIOS Information from the Registry +// http://support.microsoft.com/default.aspx?scid=kb;en-us;q195268 + +{ TODO : the date string can be e.g. 00/00/00 } +{$IFNDEF WINSCP} +function GetBIOSDate: TDateTime; +const + WinNT_REG_PATH = 'HARDWARE\DESCRIPTION\System'; + WinNT_REG_KEY = 'SystemBiosDate'; + Win9x_REG_PATH = 'Enum\Root\*PNP0C01\0000'; + Win9x_REG_KEY = 'BiosDate'; +var + RegStr: string; + {$IFDEF RTL150_UP} + FormatSettings: TFormatSettings; + {$ELSE ~RTL150_UP} + RegFormat: string; + RegSeparator: Char; + {$ENDIF ~RTL150_UP} +begin + if IsWinNT then + RegStr := RegReadString(HKEY_LOCAL_MACHINE, WinNT_REG_PATH, WinNT_REG_KEY) + else + RegStr := RegReadString(HKEY_LOCAL_MACHINE, Win9x_REG_PATH, Win9x_REG_KEY); + {$IFDEF RTL150_UP} + FillChar(FormatSettings, SizeOf(FormatSettings), 0); + FormatSettings.DateSeparator := '/'; + FormatSettings.ShortDateFormat := 'm/d/y'; + if not TryStrToDate(RegStr, Result, FormatSettings) then + begin + FormatSettings.ShortDateFormat := 'y/m/d'; + if not TryStrToDate(RegStr, Result, FormatSettings) then + Result := 0; + end; + {$ELSE ~RTL150_UP} + Result := 0; + { TODO : change to a threadsafe solution } + RegFormat := ShortDateFormat; + RegSeparator := DateSeparator; + try + DateSeparator := '/'; + try + ShortDateFormat := 'm/d/y'; + Result := StrToDate(RegStr); + except + try + ShortDateFormat := 'y/m/d'; + Result := StrToDate(RegStr); + except + end; + end; + finally + ShortDateFormat := RegFormat; + DateSeparator := RegSeparator; + end; + {$ENDIF ~RTL150_UP} +end; +{$ENDIF ~WINSCP} + +{$ENDIF MSWINDOWS} + +//=== Processes, Tasks and Modules =========================================== + +{$IFDEF UNIX} +const + CommLen = 16; // synchronize with size of comm in struct task_struct in + // /usr/include/linux/sched.h + SProcDirectory = '/proc'; + +function RunningProcessesList(const List: TStrings; FullPath: Boolean): Boolean; +var + ProcDir: PDirectoryStream; + PtrDirEnt: PDirEnt; + Scratch: TDirEnt; + ProcID: __pid_t; + E: Integer; + FileName: string; + F: PIOFile; +begin + Result := False; + ProcDir := opendir(SProcDirectory); + if ProcDir <> nil then + begin + PtrDirEnt := nil; + {$IFDEF FPC} + if readdir_r(ProcDir, @Scratch, @PtrDirEnt) <> 0 then + Exit; + {$ELSE ~FPC} + if readdir_r(ProcDir, @Scratch, PtrDirEnt) <> 0 then + Exit; + {$ENDIF ~FPC} + List.BeginUpdate; + try + while PtrDirEnt <> nil do + begin + Val(PtrDirEnt^.d_name, ProcID, E); + if E = 0 then // name was process id + begin + FileName := ''; + + if FullPath then + FileName := SymbolicLinkTarget(Format('/proc/%s/exe', [PtrDirEnt^.d_name])); + + if FileName = '' then // usually due to insufficient access rights + begin + // read stat + FileName := Format('/proc/%s/stat', [PtrDirEnt^.d_name]); + F := fopen(PChar(FileName), 'r'); + if F = nil then + raise EJclError.CreateResFmt(@RsInvalidProcessID, [ProcID]); + try + SetLength(FileName, CommLen); + if fscanf(F, PChar(Format('%%*d (%%%d[^)])', [CommLen])), PChar(FileName)) <> 1 then + RaiseLastOSError; + StrResetLength(FileName); + finally + fclose(F); + end; + end; + + List.AddObject(FileName, Pointer(ProcID)); + end; + {$IFDEF FPC} + if readdir_r(ProcDir, @Scratch, @PtrDirEnt) <> 0 then + Break; + {$ELSE ~FPC} + if readdir_r(ProcDir, @Scratch, PtrDirEnt) <> 0 then + Break; + {$ENDIF ~FPC} + end; + finally + List.EndUpdate; + end; + end; +end; + +{$ENDIF UNIX} + +{$IFDEF MSWINDOWS} + +function RunningProcessesList(const List: TStrings; FullPath: Boolean): Boolean; + + // This function always returns an empty string on Win9x + function ProcessFileName(PID: DWORD): string; + var + Handle: THandle; + begin + Result := ''; + Handle := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, False, PID); + if Handle <> 0 then + try + SetLength(Result, MAX_PATH); + if FullPath then + begin + if GetModuleFileNameEx(Handle, 0, PChar(Result), MAX_PATH) > 0 then + StrResetLength(Result) + else + Result := ''; + end + else + begin + if GetModuleBaseName(Handle, 0, PChar(Result), MAX_PATH) > 0 then + StrResetLength(Result) + else + Result := ''; + end; + finally + CloseHandle(Handle); + end; + end; + + { TODO: Check return value of CreateToolhelp32Snapshot on Windows NT (0?) } + function BuildListTH: Boolean; + var + SnapProcHandle: THandle; + ProcEntry: TProcessEntry32; + NextProc: Boolean; + FileName: string; + Win2kOrNewer: Boolean; + begin + SnapProcHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); + Result := (SnapProcHandle <> INVALID_HANDLE_VALUE); + if Result then + try + Win2kOrNewer := JclCheckWinVersion(5, 0); // Win2k or newer + ProcEntry.dwSize := SizeOf(ProcEntry); + NextProc := Process32First(SnapProcHandle, ProcEntry); + while NextProc do + begin + if ProcEntry.th32ProcessID = 0 then + begin + // PID 0 is always the "System Idle Process" but this name cannot be + // retrieved from the system and has to be fabricated. + FileName := LoadResString(@RsSystemIdleProcess); + end + else + begin + if Win2kOrNewer then + begin + FileName := ProcessFileName(ProcEntry.th32ProcessID); + if FileName = '' then + FileName := ProcEntry.szExeFile; + end + else + begin + FileName := ProcEntry.szExeFile; + if not FullPath then + FileName := ExtractFileName(FileName); + end; + end; + List.AddObject(FileName, Pointer(ProcEntry.th32ProcessID)); + NextProc := Process32Next(SnapProcHandle, ProcEntry); + end; + finally + CloseHandle(SnapProcHandle); + end; + end; + + function BuildListPS: Boolean; + var + PIDs: array [0..1024] of DWORD; + Needed: DWORD; + I: Integer; + FileName: string; + begin + Needed := 0; + Result := EnumProcesses(@PIDs, SizeOf(PIDs), Needed); + if Result then + begin + for I := 0 to (Needed div SizeOf(DWORD)) - 1 do + begin + case PIDs[I] of + 0: + // PID 0 is always the "System Idle Process" but this name cannot be + // retrieved from the system and has to be fabricated. + FileName := LoadResString(@RsSystemIdleProcess); + 2: + // On NT 4 PID 2 is the "System Process" but this name cannot be + // retrieved from the system and has to be fabricated. + if IsWinNT4 then + FileName := LoadResString(@RsSystemProcess) + else + FileName := ProcessFileName(PIDs[I]); + 8: + // On Win2K PID 8 is the "System Process" but this name cannot be + // retrieved from the system and has to be fabricated. + if IsWin2k or IsWinXP then + FileName := LoadResString(@RsSystemProcess) + else + FileName := ProcessFileName(PIDs[I]); + else + FileName := ProcessFileName(PIDs[I]); + end; + if FileName <> '' then + List.AddObject(FileName, Pointer(PIDs[I])); + end; + end; + end; + +begin + { TODO : safer solution? } + List.BeginUpdate; + try + if GetWindowsVersion in [wvWinNT31, wvWinNT35, wvWinNT351, wvWinNT4] then + Result := BuildListPS + else + Result := BuildListTH; + finally + List.EndUpdate; + end; +end; + +{ TODO Windows 9x ? } + +function LoadedModulesList(const List: TStrings; ProcessID: DWORD; HandlesOnly: Boolean): Boolean; + + procedure AddToList(ProcessHandle: THandle; Module: HMODULE); + var + FileName: array [0..MAX_PATH] of Char; + ModuleInfo: TModuleInfo; + begin + ModuleInfo.EntryPoint := nil; + {$IFDEF FPC} + if GetModuleInformation(ProcessHandle, Module, ModuleInfo, SizeOf(ModuleInfo)) then + {$ELSE ~FPC} + if GetModuleInformation(ProcessHandle, Module, @ModuleInfo, SizeOf(ModuleInfo)) then + {$ENDIF ~FPC} + begin + if HandlesOnly then + List.AddObject('', Pointer(ModuleInfo.lpBaseOfDll)) + else + if GetModuleFileNameEx(ProcessHandle, Module, Filename, SizeOf(Filename)) > 0 then + List.AddObject(FileName, Pointer(ModuleInfo.lpBaseOfDll)); + end; + end; + + function EnumModulesVQ(ProcessHandle: THandle): Boolean; + var + MemInfo: TMemoryBasicInformation; + Base: PChar; + LastAllocBase: Pointer; + Res: DWORD; + begin + Base := nil; + LastAllocBase := nil; + ResetMemory(MemInfo, SizeOf(MemInfo)); + Res := VirtualQueryEx(ProcessHandle, Base, MemInfo, SizeOf(MemInfo)); + Result := (Res = SizeOf(MemInfo)); + while Res = SizeOf(MemInfo) do + begin + if MemInfo.AllocationBase <> LastAllocBase then + begin + {$IFDEF FPC} + if MemInfo._Type = MEM_IMAGE then + {$ELSE ~FPC} + if MemInfo.Type_9 = MEM_IMAGE then + {$ENDIF ~FPC} + AddToList(ProcessHandle, HMODULE(MemInfo.AllocationBase)); + LastAllocBase := MemInfo.AllocationBase; + end; + Inc(Base, MemInfo.RegionSize); + Res := VirtualQueryEx(ProcessHandle, Base, MemInfo, SizeOf(MemInfo)); + end; + end; + + function EnumModulesPS: Boolean; + var + ProcessHandle: THandle; + Needed: DWORD; + Modules: array of THandle; + I, Cnt: Integer; + begin + Result := False; + ProcessHandle := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, False, ProcessID); + if ProcessHandle <> 0 then + try + Needed := 0; + Result := EnumProcessModules(ProcessHandle, nil, 0, Needed); + if Result then + begin + Cnt := Needed div SizeOf(HMODULE); + SetLength(Modules, Cnt); + if EnumProcessModules(ProcessHandle, @Modules[0], Needed, Needed) then + for I := 0 to Cnt - 1 do + AddToList(ProcessHandle, Modules[I]); + end + else + Result := EnumModulesVQ(ProcessHandle); + finally + CloseHandle(ProcessHandle); + end; + end; + + { TODO: Check return value of CreateToolhelp32Snapshot on Windows NT (0?) } + + function EnumModulesTH: Boolean; + var + SnapProcHandle: THandle; + Module: TModuleEntry32; + Next: Boolean; + begin + SnapProcHandle := CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, ProcessID); + Result := (SnapProcHandle <> INVALID_HANDLE_VALUE); + if Result then + try + ResetMemory(Module, SizeOf(Module)); + Module.dwSize := SizeOf(Module); + Next := Module32First(SnapProcHandle, Module); + while Next do + begin + if HandlesOnly then + List.AddObject('', Pointer(Module.hModule)) + else + List.AddObject(Module.szExePath, Pointer(Module.hModule)); + Next := Module32Next(SnapProcHandle, Module); + end; + finally + CloseHandle(SnapProcHandle); + end; + end; + +begin + List.BeginUpdate; + try + if IsWinNT then + Result := EnumModulesPS + else + Result := EnumModulesTH; + finally + List.EndUpdate; + end; +end; + +function EnumTaskWindowsProc(Wnd: THandle; List: TStrings): Boolean; stdcall; +var + Caption: array [0..1024] of Char; +begin + if IsMainAppWindow(Wnd) and (GetWindowText(Wnd, Caption, SizeOf(Caption)) > 0) then + List.AddObject(Caption, Pointer(Wnd)); + Result := True; +end; + +function GetTasksList(const List: TStrings): Boolean; +begin + List.BeginUpdate; + try + Result := EnumWindows(@EnumTaskWindowsProc, LPARAM(List)); + finally + List.EndUpdate; + end; +end; + +function ModuleFromAddr(const Addr: Pointer): HMODULE; +var + MI: TMemoryBasicInformation; +begin + MI.AllocationBase := nil; + VirtualQuery(Addr, MI, SizeOf(MI)); + if MI.State <> MEM_COMMIT then + Result := 0 + else + Result := HMODULE(MI.AllocationBase); +end; + +function IsSystemModule(const Module: HMODULE): Boolean; +var + CurModule: PLibModule; +begin + Result := False; + if Module <> 0 then + begin + CurModule := LibModuleList; + while CurModule <> nil do + begin + if CurModule.Instance = Module then + begin + Result := True; + Break; + end; + CurModule := CurModule.Next; + end; + end; +end; + +// Reference: http://msdn.microsoft.com/library/periodic/period97/win321197.htm +{ TODO : wrong link } + +function IsMainAppWindow(Wnd: THandle): Boolean; +var + ParentWnd: THandle; + ExStyle: DWORD; +begin + if IsWindowVisible(Wnd) then + begin + ParentWnd := THandle(GetWindowLongPtr(Wnd, GWLP_HWNDPARENT)); + ExStyle := GetWindowLongPtr(Wnd, GWL_EXSTYLE); + Result := ((ParentWnd = 0) or (ParentWnd = GetDesktopWindow)) and + ((ExStyle and WS_EX_TOOLWINDOW = 0) or (ExStyle and WS_EX_APPWINDOW <> 0)); + end + else + Result := False; +end; + +function IsWindowResponding(Wnd: THandle; Timeout: Integer): Boolean; +var + Res: DWORD; +begin + Res := 0; + Result := SendMessageTimeout(Wnd, WM_NULL, 0, 0, SMTO_ABORTIFHUNG, Timeout, {$IFDEF RTL230_UP}@{$ENDIF}Res) <> 0; +end; + +function GetWindowIcon(Wnd: THandle; LargeIcon: Boolean): HICON; +var + Width, Height: Integer; + TempIcon: HICON; + IconType: DWORD; +begin + if LargeIcon then + begin + Width := GetSystemMetrics(SM_CXICON); + Height := GetSystemMetrics(SM_CYICON); + IconType := ICON_BIG; + TempIcon := GetClassLong(Wnd, GCL_HICON); + end + else + begin + Width := GetSystemMetrics(SM_CXSMICON); + Height := GetSystemMetrics(SM_CYSMICON); + IconType := ICON_SMALL; + TempIcon := GetClassLong(Wnd, GCL_HICONSM); + end; + if TempIcon = 0 then + TempIcon := SendMessage(Wnd, WM_GETICON, IconType, 0); + if (TempIcon = 0) and not LargeIcon then + TempIcon := SendMessage(Wnd, WM_GETICON, ICON_BIG, 0); + Result := CopyImage(TempIcon, IMAGE_ICON, Width, Height, 0); +end; + +function GetWindowCaption(Wnd: THandle): string; +var + Buffer: string; + Size: Integer; +begin + Size := GetWindowTextLength(Wnd); + if Size = 0 then + Size := 1; // always allocate at least one byte, otherwise PChar(Buffer) returns nil + SetLength(Buffer, Size); + // strings always have an additional null character + Size := GetWindowText(Wnd, PChar(Buffer), Size + 1); + Result := Copy(Buffer, 1, Size); +end; + +// Q178893 +// http://support.microsoft.com/default.aspx?scid=kb;en-us;178893 + +function EnumTerminateAppWindowsProc(Wnd: THandle; ProcessID: DWORD): Boolean; stdcall; +var + PID: DWORD; +begin + GetWindowThreadProcessId(Wnd, @PID); + if ProcessID = PID then + PostMessage(Wnd, WM_CLOSE, 0, 0); + Result := True; +end; + +function TerminateApp(ProcessID: DWORD; Timeout: Integer): TJclTerminateAppResult; +var + ProcessHandle: THandle; +begin + Result := taError; + if ProcessID <> GetCurrentProcessId then + begin + ProcessHandle := OpenProcess(SYNCHRONIZE or PROCESS_TERMINATE, False, ProcessID); + if ProcessHandle <> 0 then + try + EnumWindows(@EnumTerminateAppWindowsProc, LPARAM(ProcessID)); + if WaitForSingleObject(ProcessHandle, Timeout) = WAIT_OBJECT_0 then + Result := taClean + else + if TerminateProcess(ProcessHandle, 0) then + Result := taKill; + finally + CloseHandle(ProcessHandle); + end; + end; +end; + +function TerminateTask(Wnd: THandle; Timeout: Integer): TJclTerminateAppResult; +var + PID: DWORD; +begin + if GetWindowThreadProcessId(Wnd, @PID) <> 0 then + Result := TerminateApp(PID, Timeout) + else + Result := taError; +end; + +function GetProcessNameFromWnd(Wnd: THandle): string; +var + List: TStringList; + PID: THandle; + I: Integer; +begin + Result := ''; + if IsWindow(Wnd) then + begin + PID := INVALID_HANDLE_VALUE; + GetWindowThreadProcessId(Wnd, @PID); + List := TStringList.Create; + try + if RunningProcessesList(List, True) then + begin + I := List.IndexOfObject(Pointer(PID)); + if I > -1 then + Result := List[I]; + end; + finally + List.Free; + end; + end; +end; + +function GetPidFromProcessName(const ProcessName: string): THandle; +var + List: TStringList; + I: Integer; + HasFullPath: Boolean; +begin + Result := INVALID_HANDLE_VALUE; + List := TStringList.Create; + try + HasFullPath := ExtractFilePath(ProcessName) <> ''; + if RunningProcessesList(List, HasFullPath) then + begin + I := List.IndexOf(ProcessName); + if I > -1 then + Result := DWORD(List.Objects[I]); + end; + finally + List.Free; + end; +end; + +function GetProcessNameFromPid(PID: DWORD): string; +var + List: TStringList; + I: Integer; +begin + // Note: there are other ways to retrieve the name of the process given it's + // PID but this implementation seems to work best without making assumptions + // although it may not be the most efficient implementation. + Result := ''; + List := TStringList.Create; + try + if RunningProcessesList(List, True) then + begin + I := List.IndexOfObject(Pointer(PID)); + if I > -1 then + Result := List[I]; + end; + finally + List.Free; + end; +end; + +type + PSearch = ^TSearch; + TSearch = record + PID: DWORD; + Wnd: THandle; + end; + +function EnumMainAppWindowsProc(Wnd: THandle; Res: PSearch): Boolean; stdcall; +var + WindowPid: DWORD; +begin + WindowPid := 0; + GetWindowThreadProcessId(Wnd, @WindowPid); + if (WindowPid = Res^.PID) and IsMainAppWindow(Wnd) then + begin + Res^.Wnd := Wnd; + Result := False; + end + else + Result := True; +end; + +function GetMainAppWndFromPid(PID: DWORD): THandle; +var + SearchRec: TSearch; +begin + SearchRec.PID := PID; + SearchRec.Wnd := 0; + EnumWindows(@EnumMainAppWindowsProc, LPARAM(@SearchRec)); + Result := SearchRec.Wnd; +end; + +type + PEnumWndStruct = ^TEnumWndStruct; + TEnumWndStruct = record + PID: DWORD; + WndClassName: string; + ResultWnd: HWND; + end; + +function EnumPidWinProc(Wnd: HWND; Enum: PEnumWndStruct): BOOL; stdcall; +var + PID: DWORD; + C: PChar; + CLen: Integer; +begin + Result := True; + GetWindowThreadProcessId(Wnd, @PID); + if (PID = Enum.PID) then + begin + CLen := Length(Enum.WndClassName)+1; + C := StrAlloc(CLen); + if (GetClassName(Wnd, C, CLen) > 0) then + if (C = Enum.WndClassName) then + begin + Result := False; + Enum.ResultWnd := Wnd; + end; + StrDispose(C); + end; +end; + +function GetWndFromPid(PID: DWORD; const WindowClassName: string): HWND; +var + EnumWndStruct: TEnumWndStruct; +begin + EnumWndStruct.PID := PID; + EnumWndStruct.WndClassName := WindowClassName; + EnumWndStruct.ResultWnd := 0; + EnumWindows(@EnumPidWinProc, LPARAM(@EnumWndStruct)); + Result := EnumWndStruct.ResultWnd; +end; + +function GetShellProcessName: string; +const + cShellKey = 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon'; + cShellValue = 'Shell'; + cShellDefault = 'explorer.exe'; + cShellSystemIniFileName = 'system.ini'; + cShellBootSection = 'boot'; +begin + if IsWinNT then + Result := RegReadStringDef(HKEY_LOCAL_MACHINE, cShellKey, cShellValue, '') +{$IFNDEF WINSCP} + else + Result := IniReadString(PathAddSeparator(GetWindowsFolder) + cShellSystemIniFileName, cShellBootSection, cShellValue){$ENDIF ~WINSCP}; + if Result = '' then + Result := cShellDefault; +end; + +function GetShellProcessHandle: THandle; +var + Pid: Longword; +begin + Pid := GetPidFromProcessName(GetShellProcessName); + Result := OpenProcess(PROCESS_ALL_ACCESS, False, Pid); + if Result = 0 then + RaiseLastOSError; +end; + +//=== Version Information ==================================================== + +{ Q159/238 + + Windows 95 retail, OEM 4.00.950 7/11/95 + Windows 95 retail SP1 4.00.950A 7/11/95-12/31/95 + OEM Service Release 2 4.00.1111* (4.00.950B) 8/24/96 + OEM Service Release 2.1 4.03.1212-1214* (4.00.950B) 8/24/96-8/27/97 + OEM Service Release 2.5 4.03.1214* (4.00.950C) 8/24/96-11/18/97 + Windows 98 retail, OEM 4.10.1998 5/11/98 + Windows 98 Second Edition 4.10.2222A 4/23/99 + Windows Millennium 4.90.3000 +} +{ TODO : Distinquish between all these different releases? } + +var + KernelVersionHi: DWORD; + +function GetWindowsVersion: TWindowsVersion; +var + TrimmedWin32CSDVersion: string; + SystemInfo: TSystemInfo; + OSVersionInfoEx: TOSVersionInfoEx; + Win32MinorVersionEx: integer; + ProductName: string; +const + SM_SERVERR2 = 89; +begin + Result := wvUnknown; + TrimmedWin32CSDVersion := Trim(Win32CSDVersion); + case Win32Platform of + VER_PLATFORM_WIN32_WINDOWS: + case Win32MinorVersion of + 0..9: + if (TrimmedWin32CSDVersion = 'B') or (TrimmedWin32CSDVersion = 'C') then + Result := wvWin95OSR2 + else + Result := wvWin95; + 10..89: + // On Windows ME Win32MinorVersion can be 10 (indicating Windows 98 + // under certain circumstances (image name is setup.exe). Checking + // the kernel version is one way of working around that. + if KernelVersionHi = $0004005A then // 4.90.x.x + Result := wvWinME + else + if (TrimmedWin32CSDVersion = 'A') or (TrimmedWin32CSDVersion = 'B') then + Result := wvWin98SE + else + Result := wvWin98; + 90: + Result := wvWinME; + end; + VER_PLATFORM_WIN32_NT: + case Win32MajorVersion of + 3: + case Win32MinorVersion of + 1: + Result := wvWinNT31; + 5: + Result := wvWinNT35; + 51: + Result := wvWinNT351; + end; + 4: + Result := wvWinNT4; + 5: + case Win32MinorVersion of + 0: + Result := wvWin2000; + 1: + Result := wvWinXP; + 2: + begin + OSVersionInfoEx.dwOSVersionInfoSize := SizeOf(OSVersionInfoEx); + SystemInfo.dwOemId := 0; + GetNativeSystemInfo(SystemInfo); + if GetSystemMetrics(SM_SERVERR2) <> 0 then + Result := wvWin2003R2 + else + if (SystemInfo.wProcessorArchitecture <> PROCESSOR_ARCHITECTURE_INTEL) and + GetVersionEx(OSVersionInfoEx) and (OSVersionInfoEx.wProductType = VER_NT_WORKSTATION) then + Result := wvWinXP64 + else + Result := wvWin2003; + end; + end; + 6: + begin + Win32MinorVersionEx := Win32MinorVersion; + + // Workaround to differentiate Windows 8.1 and Windows Server 2012 R2 from Windows 8 and Windows Server 2012 + if Win32MinorVersionEx = 2 then + begin + ProductName := RegReadStringDef(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'ProductName', ''); + if (pos(RsOSVersionWin81, ProductName) = 1) or (pos(RsOSVersionWinServer2012R2, ProductName) = 1) then + Win32MinorVersionEx := 3; + end; + + case Win32MinorVersionEx of + 0: + begin + // Windows Vista and Windows Server 2008 + OSVersionInfoEx.dwOSVersionInfoSize := SizeOf(OSVersionInfoEx); + if GetVersionEx(OSVersionInfoEx) and (OSVersionInfoEx.wProductType = VER_NT_WORKSTATION) then + Result := wvWinVista + else + Result := wvWinServer2008; + end; + 1: + begin + // Windows 7 and Windows Server 2008 R2 + OSVersionInfoEx.dwOSVersionInfoSize := SizeOf(OSVersionInfoEx); + if GetVersionEx(OSVersionInfoEx) and (OSVersionInfoEx.wProductType = VER_NT_WORKSTATION) then + Result := wvWin7 + else + Result := wvWinServer2008R2; + end; + 2: + begin + // Windows 8 and Windows Server 2012 + OSVersionInfoEx.dwOSVersionInfoSize := SizeOf(OSVersionInfoEx); + if GetVersionEx(OSVersionInfoEx) and (OSVersionInfoEx.wProductType = VER_NT_WORKSTATION) then + Result := wvWin8 + else + Result := wvWinServer2012; + end; + 3: + begin + // Windows 8.1 and Windows Server 2012 R2 + OSVersionInfoEx.dwOSVersionInfoSize := SizeOf(OSVersionInfoEx); + if GetVersionEx(OSVersionInfoEx) and (OSVersionInfoEx.wProductType = VER_NT_WORKSTATION) then + Result := wvWin81 + else + Result := wvWinServer2012R2; + end; + end; + end; + end; + end; +end; + +function GetWindowsEdition: TWindowsEdition; +const + ProductName = 'SOFTWARE\Microsoft\Windows NT\CurrentVersion'; +var + Edition: string; +begin + Result := weUnknown; + Edition := RegReadStringDef(HKEY_LOCAL_MACHINE, ProductName, 'ProductName', ''); + + // Remove (tm) in 'Windows (TM) Vista Ultimate' + Edition := StringReplace(Edition, '(TM) ', '', [rfReplaceAll, rfIgnoreCase]); + + if Pos('Windows XP', Edition) = 1 then + begin + // Windows XP Editions + if Pos('Home Edition N', Edition) > 0 then + Result := weWinXPHomeN + else + if Pos('Professional N', Edition) > 0 then + Result := weWinXPProN + else + if Pos('Home Edition K', Edition) > 0 then + Result := weWinXPHomeK + else + if Pos('Professional K', Edition) > 0 then + Result := weWinXPProK + else + if Pos('Home Edition KN', Edition) > 0 then + Result := weWinXPHomeKN + else + if Pos('Professional KN', Edition) > 0 then + Result := weWinXPProKN + else + if Pos('Home', Edition) > 0 then + Result := weWinXPHome + else + if Pos('Professional', Edition) > 0 then + Result := weWinXPPro + else + if Pos('Starter', Edition) > 0 then + Result := weWinXPStarter + else + if Pos('Media Center', Edition) > 0 then + Result := weWinXPMediaCenter + else + if Pos('Tablet', Edition) > 0 then + Result := weWinXPTablet; + end + else + if (Pos('Windows Vista', Edition) = 1) then + begin + // Windows Vista Editions + if Pos('Starter', Edition) > 0 then + Result := weWinVistaStarter + else + if Pos('Home Basic N', Edition) > 0 then + Result := weWinVistaHomeBasicN + else + if Pos('Home Basic', Edition) > 0 then + Result := weWinVistaHomeBasic + else + if Pos('Home Premium', Edition) > 0 then + Result := weWinVistaHomePremium + else + if Pos('Business N', Edition) > 0 then + Result := weWinVistaBusinessN + else + if Pos('Business', Edition) > 0 then + Result := weWinVistaBusiness + else + if Pos('Enterprise', Edition) > 0 then + Result := weWinVistaEnterprise + else + if Pos('Ultimate', Edition) > 0 then + Result := weWinVistaUltimate; + end + else + if Pos('Windows 7', Edition) = 1 then + begin + // Windows 7 Editions + if Pos('Starter', Edition) > 0 then + Result := weWin7Starter + else + if Pos('Home Basic', Edition) > 0 then + Result := weWin7HomeBasic + else + if Pos('Home Premium', Edition) > 0 then + Result := weWin7HomePremium + else + if Pos('Professional', Edition) > 0 then + Result := weWin7Professional + else + if Pos('Enterprise', Edition) > 0 then + Result := weWin7Enterprise + else + if Pos('Ultimate', Edition) > 0 then + Result := weWin7Ultimate; + end + else + if Pos('Windows 8.1', Edition) = 1 then + begin + // Windows 8.1 Editions + if pos('Pro', Edition) > 0 then + Result := weWin81Pro + else + if Pos('Enterprise', Edition) > 0 then + Result := weWin81Enterprise + else + Result := weWin81; + end + else + if Pos('Windows 8', Edition) = 1 then + begin + // Windows 8 Editions + if Pos('Pro', Edition) > 0 then + Result := weWin8Pro + else + if Pos('Enterprise', Edition) > 0 then + Result := weWin8Enterprise + else + Result := weWin8; + end + else + if Pos('Windows RT 8.1', Edition) = 1 then + Result := weWin81RT + else + if Pos('Windows RT', Edition) = 1 then + Result := weWin8RT; +end; + +function NtProductType: TNtProductType; +const + ProductType = 'SYSTEM\CurrentControlSet\Control\ProductOptions'; +var + Product: string; + OSVersionInfo: TOSVersionInfoEx; + SystemInfo: TSystemInfo; +begin + Result := ptUnknown; + ResetMemory(OSVersionInfo, SizeOf(OSVersionInfo)); + ResetMemory(SystemInfo, SizeOf(SystemInfo)); + OSVersionInfo.dwOSVersionInfoSize := SizeOf(OSVersionInfo); + GetNativeSystemInfo(SystemInfo); + + // Favor documented API over registry + if IsWinNT4 and (GetWindowsServicePackVersion >= 6) then + begin + if GetVersionEx(OSVersionInfo) then + begin + if (OSVersionInfo.wProductType = VER_NT_WORKSTATION) then + Result := ptWorkstation + else + if (OSVersionInfo.wSuiteMask and VER_SUITE_ENTERPRISE) = VER_SUITE_ENTERPRISE then + Result := ptEnterprise + else + Result := ptServer; + end; + end + else + if IsWin2K then + begin + if GetVersionEx(OSVersionInfo) then + begin + if OSVersionInfo.wProductType in [VER_NT_SERVER, VER_NT_DOMAIN_CONTROLLER] then + begin + if (OSVersionInfo.wSuiteMask and VER_SUITE_DATACENTER) <> 0 then + Result := ptDatacenterServer + else + if (OSVersionInfo.wSuiteMask and VER_SUITE_ENTERPRISE) <> 0 then + Result := ptAdvancedServer + else + Result := ptServer; + end + else + Result := ptProfessional; + end; + end + else + if IsWinXP64 or IsWin2003 or IsWin2003R2 then // all (5.2) + begin + if GetVersionEx(OSVersionInfo) then + begin + if OSVersionInfo.wProductType in [VER_NT_SERVER, VER_NT_DOMAIN_CONTROLLER] then + begin + if (OSVersionInfo.wSuiteMask and VER_SUITE_DATACENTER) = VER_SUITE_DATACENTER then + Result := ptDatacenterServer + else + if (OSVersionInfo.wSuiteMask and VER_SUITE_ENTERPRISE) = VER_SUITE_ENTERPRISE then + Result := ptEnterprise + else + if (OSVersionInfo.wSuiteMask = VER_SUITE_BLADE) then + Result := ptWebEdition + else + Result := ptServer; + end + else + if (OSVersionInfo.wProductType = VER_NT_WORKSTATION) then + Result := ptProfessional; + end; + end + else + if JclCheckWinVersion(5, 1) then // WinXP or newer + begin + if GetVersionEx(OSVersionInfo) then + begin + //if IsWinXP or IsWinVista or IsWin7 or IsWin8 or IsWin81 then + if OSVersionInfo.wProductType = VER_NT_WORKSTATION then // workstation + begin + if (OSVersionInfo.wSuiteMask and VER_SUITE_PERSONAL) = VER_SUITE_PERSONAL then + Result := ptPersonal + else + Result := ptProfessional; + end + else + //if IsWinServer2008 or IsWinServer2008R2 or IsWinServer2012 or IsWinServer2012R2 then + if OSVersionInfo.wProductType in [VER_NT_SERVER, VER_NT_DOMAIN_CONTROLLER] then // server + begin + if (OSVersionInfo.wSuiteMask and VER_SUITE_DATACENTER) = VER_SUITE_DATACENTER then + Result := ptDatacenterServer + else + if (OSVersionInfo.wSuiteMask and VER_SUITE_ENTERPRISE) = VER_SUITE_ENTERPRISE then + Result := ptEnterprise + else + Result := ptServer; + end; + end; + end; + + if Result = ptUnknown then + begin + // Non Windows 2000/XP system or the above method failed, try registry + Product := RegReadStringDef(HKEY_LOCAL_MACHINE, ProductType, 'ProductType', ''); + if CompareText(Product, 'WINNT') = 0 then + Result := ptWorkStation + else + if CompareText(Product, 'SERVERNT') = 0 then + Result := {ptServer} ptAdvancedServer + else + if CompareText(Product, 'LANMANNT') = 0 then + Result := {ptAdvancedServer} ptServer + else + Result := ptUnknown; + end; +end; + +function GetWindowsVersionString: string; +begin + case GetWindowsVersion of + wvWin95: + Result := LoadResString(@RsOSVersionWin95); + wvWin95OSR2: + Result := LoadResString(@RsOSVersionWin95OSR2); + wvWin98: + Result := LoadResString(@RsOSVersionWin98); + wvWin98SE: + Result := LoadResString(@RsOSVersionWin98SE); + wvWinME: + Result := LoadResString(@RsOSVersionWinME); + wvWinNT31, wvWinNT35, wvWinNT351: + Result := Format(LoadResString(@RsOSVersionWinNT3), [Win32MinorVersion]); + wvWinNT4: + Result := Format(LoadResString(@RsOSVersionWinNT4), [Win32MinorVersion]); + wvWin2000: + Result := LoadResString(@RsOSVersionWin2000); + wvWinXP: + Result := LoadResString(@RsOSVersionWinXP); + wvWin2003: + Result := LoadResString(@RsOSVersionWin2003); + wvWin2003R2: + Result := LoadResString(@RsOSVersionWin2003R2); + wvWinXP64: + Result := LoadResString(@RsOSVersionWinXP64); + wvWinVista: + Result := LoadResString(@RsOSVersionWinVista); + wvWinServer2008: + Result := LoadResString(@RsOSVersionWinServer2008); + wvWin7: + Result := LoadResString(@RsOSVersionWin7); + wvWinServer2008R2: + Result := LoadResString(@RsOSVersionWinServer2008R2); + wvWin8: + Result := LoadResString(@RsOSVersionWin8); + wvWin8RT: + Result := LoadResString(@RsOSVersionWin8RT); + wvWinServer2012: + Result := LoadResString(@RsOSVersionWinServer2012); + wvWin81: + Result := LoadResString(@RsOSVersionWin81); + wvWin81RT: + Result := LoadResString(@RsOSVersionWin81RT); + wvWinServer2012R2: + Result := LoadResString(@RsOSVersionWinServer2012R2); + else + Result := ''; + end; +end; + +function GetWindowsEditionString: string; +begin + case GetWindowsEdition of + weWinXPHome: + Result := LoadResString(@RsEditionWinXPHome); + weWinXPPro: + Result := LoadResString(@RsEditionWinXPPro); + weWinXPHomeN: + Result := LoadResString(@RsEditionWinXPHomeN); + weWinXPProN: + Result := LoadResString(@RsEditionWinXPProN); + weWinXPHomeK: + Result := LoadResString(@RsEditionWinXPHomeK); + weWinXPProK: + Result := LoadResString(@RsEditionWinXPProK); + weWinXPHomeKN: + Result := LoadResString(@RsEditionWinXPHomeKN); + weWinXPProKN: + Result := LoadResString(@RsEditionWinXPProKN); + weWinXPStarter: + Result := LoadResString(@RsEditionWinXPStarter); + weWinXPMediaCenter: + Result := LoadResString(@RsEditionWinXPMediaCenter); + weWinXPTablet: + Result := LoadResString(@RsEditionWinXPTablet); + weWinVistaStarter: + Result := LoadResString(@RsEditionWinVistaStarter); + weWinVistaHomeBasic: + Result := LoadResString(@RsEditionWinVistaHomeBasic); + weWinVistaHomeBasicN: + Result := LoadResString(@RsEditionWinVistaHomeBasicN); + weWinVistaHomePremium: + Result := LoadResString(@RsEditionWinVistaHomePremium); + weWinVistaBusiness: + Result := LoadResString(@RsEditionWinVistaBusiness); + weWinVistaBusinessN: + Result := LoadResString(@RsEditionWinVistaBusinessN); + weWinVistaEnterprise: + Result := LoadResString(@RsEditionWinVistaEnterprise); + weWinVistaUltimate: + Result := LoadResString(@RsEditionWinVistaUltimate); + weWin7Starter: + Result := LoadResString(@RsEditionWin7Starter); + weWin7HomeBasic: + Result := LoadResString(@RsEditionWin7HomeBasic); + weWin7HomePremium: + Result := LoadResString(@RsEditionWin7HomePremium); + weWin7Professional: + Result := LoadResString(@RsEditionWin7Professional); + weWin7Enterprise: + Result := LoadResString(@RsEditionWin7Enterprise); + weWin7Ultimate: + Result := LoadResString(@RsEditionWin7Ultimate); + weWin8Pro: + Result := LoadResString(@RsEditionWin8Pro); + weWin8Enterprise: + Result := LoadResString(@RsEditionWin8Enterprise); + weWin8RT: + Result := LoadResString(@RsEditionWin8RT); + weWin81Pro: + Result := LoadResString(@RsEditionWin81Pro); + weWin81Enterprise: + Result := LoadResString(@RsEditionWin81Enterprise); + weWin81RT: + Result := LoadResString(@RsEditionWin81RT); + else + Result := ''; + end; +end; + +function GetWindowsProductString: string; +begin + Result := GetWindowsVersionString; + if GetWindowsEditionString <> '' then + Result := Result + ' ' + GetWindowsEditionString; +end; + +function NtProductTypeString: string; +begin + case NtProductType of + ptWorkStation: + Result := LoadResString(@RsProductTypeWorkStation); + ptServer: + Result := LoadResString(@RsProductTypeServer); + ptAdvancedServer: + Result := LoadResString(@RsProductTypeAdvancedServer); + ptPersonal: + Result := LoadResString(@RsProductTypePersonal); + ptProfessional: + Result := LoadResString(@RsProductTypeProfessional); + ptDatacenterServer: + Result := LoadResString(@RsProductTypeDatacenterServer); + ptEnterprise: + Result := LoadResString(@RsProductTypeEnterprise); + ptWebEdition: + Result := LoadResString(@RsProductTypeWebEdition); + else + Result := ''; + end; +end; + +function GetWindowsBuildNumber: Integer; +begin + // Workaround to differentiate Windows 8.1 and Windows Server 2012 R2 from Windows 8 and Windows Server 2012 + if (Win32MajorVersion = 6) and (Win32MinorVersion = 2) then + Result := strToInt(RegReadStringDef(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'CurrentBuildNumber', intToStr(Win32BuildNumber))) + else + Result := Win32BuildNumber; +end; + +function GetWindowsServicePackVersion: Integer; +const + RegWindowsControl = 'SYSTEM\CurrentControlSet\Control\Windows'; +var +{$IFNDEF WINSCP} + SP: Integer; +{$ENDIF ~WINSCP} + VersionInfo: TOSVersionInfoEx; +begin + Result := 0; + if (Win32Platform = VER_PLATFORM_WIN32_NT) and (Win32MajorVersion >= 5) then + begin + ResetMemory(VersionInfo, SizeOf(VersionInfo)); + VersionInfo.dwOSVersionInfoSize := SizeOf(VersionInfo); + if GetVersionEx(VersionInfo) then + Result := VersionInfo.wServicePackMajor; + end +{$IFNDEF WINSCP} + // WINSCP: We support Windows XP (5.1) and newer only + else + begin + SP := RegReadIntegerDef(HKEY_LOCAL_MACHINE, RegWindowsControl, 'CSDVersion', 0); + Result := StrToInt(IntToHex(SP, 4)) div 100; + end{$ENDIF ~WINSCP}; +end; + +function GetWindowsServicePackVersionString: string; +var + SP: Integer; +begin + SP := GetWindowsServicePackVersion; + if SP > 0 then + Result := Format(LoadResString(@RsSPInfo), [SP]) + else + Result := ''; +end; + +{$IFNDEF WINSCP} + +// Imports copied from OpenGL unit. Direct using of OpenGL unit might cause unexpected problems due +// setting 8087CW in the intialization section +{ +function glGetString(name: Cardinal): PChar; stdcall; external opengl32; +function glGetError: Cardinal; stdcall; external opengl32; +function gluErrorString(errCode: Cardinal): PChar; stdcall; external 'glu32.dll'; +} + +type + TglGetStringFunc = function(name: Cardinal): PAnsiChar; stdcall; + TglGetErrorFunc = function: Cardinal; stdcall; + TgluErrorStringFunc = function(errCode: Cardinal): PAnsiChar; stdcall; + + TwglCreateContextFunc = function(DC: HDC): HGLRC; stdcall; + TwglDeleteContextFunc = function(p1: HGLRC): BOOL; stdcall; + TwglMakeCurrentFunc = function(DC: HDC; p2: HGLRC): BOOL; stdcall; + +const + glu32 = 'glu32.dll'; // do not localize + glGetStringName = 'glGetString'; // do not localize + glGetErrorName = 'glGetError'; // do not localize + gluErrorStringName = 'gluErrorString'; // do not localize + wglCreateContextName = 'wglCreateContext'; // do not localize + wglDeleteContextName = 'wglDeleteContext'; // do not localize + wglMakeCurrentName = 'wglMakeCurrent'; // do not localize + ChoosePixelFormatName = 'ChoosePixelFormat'; // do not localize + SetPixelFormatName = 'SetPixelFormat'; // do not localize + +function GetOpenGLVersion(const Win: THandle; out Version, Vendor: AnsiString): Boolean; +const + GL_NO_ERROR = 0; + GL_VENDOR = $1F00; + GL_VERSION = $1F02; +var + OpenGlLib, Glu32Lib: HModule; + + glGetStringFunc: TglGetStringFunc; + glGetErrorFunc: TglGetErrorFunc; + gluErrorStringFunc: TgluErrorStringFunc; + + wglCreateContextFunc: TwglCreateContextFunc; + wglDeleteContextFunc: TwglDeleteContextFunc; + wglMakeCurrentFunc: TwglMakeCurrentFunc; + + pfd: TPixelFormatDescriptor; + iFormatIndex: Integer; + hGLContext: HGLRC; + hGLDC: HDC; + pcTemp: PAnsiChar; + glErr: Cardinal; + bError: Boolean; + sOpenGLVersion, sOpenGLVendor: AnsiString; + Save8087CW: Word; + + procedure FunctionFailedError(Name: string); + begin + raise EJclError.CreateResFmt(@RsEOpenGLInfo, [Name]); + end; + +begin + @glGetStringFunc := nil; + @glGetErrorFunc := nil; + @gluErrorStringFunc := nil; + + @wglCreateContextFunc := nil; + @wglDeleteContextFunc := nil; + @wglMakeCurrentFunc := nil; + + Glu32Lib := 0; + OpenGlLib := SafeLoadLibrary(opengl32); + try + if OpenGlLib <> 0 then + begin + Glu32Lib := SafeLoadLibrary(glu32); // do not localize + if (OpenGlLib <> 0) and (Glu32Lib <> 0) then + begin + glGetStringFunc := GetProcAddress(OpenGlLib, glGetStringName); + glGetErrorFunc := GetProcAddress(OpenGlLib, glGetErrorName); + gluErrorStringFunc := GetProcAddress(Glu32Lib, gluErrorStringName); + + wglCreateContextFunc := GetProcAddress(OpenGlLib, wglCreateContextName); + wglDeleteContextFunc := GetProcAddress(OpenGlLib, wglDeleteContextName); + wglMakeCurrentFunc := GetProcAddress(OpenGlLib, wglMakeCurrentName); + end; + end; + + if not (Assigned(glGetStringFunc) and Assigned(glGetErrorFunc) and Assigned(gluErrorStringFunc) and + Assigned(wglCreateContextFunc) and Assigned(wglDeleteContextFunc) and Assigned(wglMakeCurrentFunc)) then + begin + @glGetStringFunc := nil; + Result := False; + Vendor := AnsiString(LoadResString(@RsOpenGLInfoError)); + Version := AnsiString(LoadResString(@RsOpenGLInfoError)); + Exit; + end; + + { To call for the version information string we must first have an active + context established for use. We can, of course, close this after use } + Save8087CW := Get8087ControlWord; + try + Set8087CW($133F); + hGLContext := 0; + Result := False; + bError := False; + + if Win = 0 then + begin + Result := False; + Vendor := AnsiString(LoadResString(@RsOpenGLInfoError)); + Version := AnsiString(LoadResString(@RsOpenGLInfoError)); + Exit; + end; + + ResetMemory(pfd, SizeOf(pfd)); + with pfd do + begin + nSize := SizeOf(pfd); + nVersion := 1; { The Current Version of the descriptor is 1 } + dwFlags := PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL; + iPixelType := PFD_TYPE_RGBA; + cColorBits := 24; { support 24-bit colour } + cDepthBits := 32; { Depth of the z-buffer } + iLayerType := PFD_MAIN_PLANE; + end; + + hGLDC := GetDC(Win); + try + iFormatIndex := ChoosePixelFormat(hGLDC, @pfd); + if iFormatIndex = 0 then + FunctionFailedError(ChoosePixelFormatName); + + if not SetPixelFormat(hGLDC, iFormatIndex, @pfd) then + FunctionFailedError(SetPixelFormatName); + + hGLContext := wglCreateContextFunc(hGLDC); + if hGLContext = 0 then + FunctionFailedError(wglCreateContextName); + + if not wglMakeCurrentFunc(hGLDC, hGLContext) then + FunctionFailedError(wglMakeCurrentName); + + { TODO : Review the following. Not sure I am 100% happy with this code + in its current structure. } + pcTemp := glGetStringFunc(GL_VERSION); + if pcTemp <> nil then + begin + { TODO : Store this information in a Global Variable, and return that?? + This would save this work being performed again with later calls } + sOpenGLVersion := StrPasA(pcTemp); + end + else + begin + bError := True; + glErr := glGetErrorFunc; + if glErr <> GL_NO_ERROR then + begin + sOpenGLVersion := gluErrorStringFunc(glErr); + sOpenGLVendor := ''; + end; + end; + + pcTemp := glGetStringFunc(GL_VENDOR); + if pcTemp <> nil then + begin + { TODO : Store this information in a Global Variable, and return that?? + This would save this work being performed again with later calls } + sOpenGLVendor := StrPasA(pcTemp); + end + else + begin + bError := True; + glErr := glGetErrorFunc; + if glErr <> GL_NO_ERROR then + begin + sOpenGLVendor := gluErrorStringFunc(glErr); + Exit; + end; + end; + + Result := (not bError); + Version := sOpenGLVersion; + Vendor := sOpenGLVendor; + finally + { Close all resources } + wglMakeCurrentFunc(hGLDC, 0); + if hGLContext <> 0 then + wglDeleteContextFunc(hGLContext); + end; + finally + Set8087CW(Save8087CW); + end; + finally + if (OpenGlLib <> 0) then + FreeLibrary(OpenGlLib); + if (Glu32Lib <> 0) then + FreeLibrary(Glu32Lib); + end; +end; + +{$ENDIF ~WINSCP} + +function GetNativeSystemInfo(var SystemInfo: TSystemInfo): Boolean; +type + TGetNativeSystemInfo = procedure (var SystemInfo: TSystemInfo); stdcall; +var + LibraryHandle: HMODULE; + _GetNativeSystemInfo: TGetNativeSystemInfo; +begin + Result := False; + LibraryHandle := GetModuleHandle(kernel32); + + if LibraryHandle <> 0 then + begin + _GetNativeSystemInfo := GetProcAddress(LibraryHandle,'GetNativeSystemInfo'); + if Assigned(_GetNativeSystemInfo) then + begin + _GetNativeSystemInfo(SystemInfo); + Result := True; + end + else + GetSystemInfo(SystemInfo); + end + else + GetSystemInfo(SystemInfo); +end; + +function GetProcessorArchitecture: TProcessorArchitecture; +var + ASystemInfo: TSystemInfo; +begin + ASystemInfo.dwOemId := 0; + GetNativeSystemInfo(ASystemInfo); + case ASystemInfo.wProcessorArchitecture of + PROCESSOR_ARCHITECTURE_INTEL: + Result := pax8632; + PROCESSOR_ARCHITECTURE_IA64: + Result := paIA64; + PROCESSOR_ARCHITECTURE_AMD64: + Result := pax8664; + else + Result := paUnknown; + end; +end; + +function IsWindows64: Boolean; +var + ASystemInfo: TSystemInfo; +begin + ASystemInfo.dwOemId := 0; + GetNativeSystemInfo(ASystemInfo); + Result := ASystemInfo.wProcessorArchitecture in [PROCESSOR_ARCHITECTURE_IA64,PROCESSOR_ARCHITECTURE_AMD64]; +end; + +function JclCheckWinVersion(Major, Minor: Integer): Boolean; +begin + {$IFDEF RTL150_UP} + Result := CheckWin32Version(Major, Minor); + {$ELSE} + // Delphi 6 and older have a wrong implementation + Result := (Win32MajorVersion > Major) or + ((Win32MajorVersion = Major) and (Win32MinorVersion >= Minor)); + {$ENDIF RTL150_UP} +end; + +{$ENDIF MSWINDOWS} + +function GetOSVersionString: string; +{$IFDEF UNIX} +var + MachineInfo: utsname; +begin + uname(MachineInfo); + Result := Format('%s %s', [MachineInfo.sysname, MachineInfo.release]); +end; +{$ENDIF UNIX} +{$IFDEF MSWINDOWS} +begin + Result := Format('%s %s', [GetWindowsVersionString, GetWindowsServicePackVersionString]); +end; +{$ENDIF MSWINDOWS} + +//=== Hardware =============================================================== + +// Helper function for GetMacAddress() +// Converts the adapter_address array to a string + +function AdapterToString(Adapter: PJclByteArray): string; +begin + Result := Format('%2.2x-%2.2x-%2.2x-%2.2x-%2.2x-%2.2x', + [Integer(Adapter[0]), Integer(Adapter[1]), + Integer(Adapter[2]), Integer(Adapter[3]), + Integer(Adapter[4]), Integer(Adapter[5])]); +end; + +{$IFNDEF WINSCP} + +{ TODO: RTLD version of NetBios } +{$IFDEF MSWINDOWS} +type + TNetBios = function(P: PNCB): Byte; stdcall; + +var + NetBiosLib: HINST = 0; + _NetBios: TNetBios; + {$IFDEF FPC} + NullAdapterAddress: array [0..5] of Byte = ($00, $00, $00, $00, $00, $00); + OID_ipMACEntAddr: array [0..9] of UINT = (1, 3, 6, 1, 2, 1, 2, 2, 1, 6); + OID_ifEntryType: array [0..9] of UINT = (1, 3, 6, 1, 2, 1, 2, 2, 1, 3); + OID_ifEntryNum: array [0..7] of UINT = (1, 3, 6, 1, 2, 1, 2, 1); + {$ENDIF FPC} + +function GetMacAddresses(const Machine: string; const Addresses: TStrings): Integer; + + procedure ExitNetbios; + begin + if NetBiosLib <> 0 then + begin + FreeLibrary(NetBiosLib); + NetBiosLib := 0; + end; + end; + + function InitNetbios: Boolean; + begin + Result := True; + if NetBiosLib = 0 then + begin + NetBiosLib := SafeLoadLibrary('netapi32.dll'); + Result := NetBiosLib <> 0; + if Result then + begin + @_NetBios := GetProcAddress(NetBiosLib, PChar('Netbios')); + Result := @_NetBios <> nil; + if not Result then + ExitNetbios; + end; + end; + end; + + function NetBios(P: PNCB): Byte; + begin + if InitNetbios then + Result := _NetBios(P) + else + Result := 1; // anything other than NRC_GOODRET will do + end; + + procedure GetMacAddressesNetBios; + // Platform SDK + // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netbios/netbios_1l82.asp + + // Microsoft Knowledge Base Article - 118623 + // HOWTO: Get the MAC Address for an Ethernet Adapter + // http://support.microsoft.com/default.aspx?scid=kb;en-us;118623 + type + AStat = packed record + adapt: TAdapterStatus; + NameBuff: array [0..29] of TNameBuffer; + end; + var + NCB: TNCB; + Enum: TLanaEnum; + I, L, NameLen: Integer; + Adapter: AStat; + MachineName: AnsiString; + begin + MachineName := AnsiString(UpperCase(Machine)); + if MachineName = '' then + MachineName := '*'; + NameLen := Length(MachineName); + L := NCBNAMSZ - NameLen; + if L > 0 then + begin + SetLength(MachineName, NCBNAMSZ); + FillChar(MachineName[NameLen + 1], L, ' '); + end; + // From Junior/RO in NG: Microsoft's implementation limits NETBIOS names to 15 characters + MachineName[NCBNAMSZ] := #0; + ResetMemory(NCB, SizeOf(NCB)); + NCB.ncb_command := NCBENUM; + NCB.ncb_buffer := Pointer(@Enum); + NCB.ncb_length := SizeOf(Enum); + if NetBios(@NCB) = NRC_GOODRET then + begin + Result := Enum.Length; + for I := 0 to Ord(Enum.Length) - 1 do + begin + ResetMemory(NCB, SizeOf(NCB)); + NCB.ncb_command := NCBRESET; + NCB.ncb_lana_num := Enum.lana[I]; + if NetBios(@NCB) = NRC_GOODRET then + begin + ResetMemory(NCB, SizeOf(NCB)); + NCB.ncb_command := NCBASTAT; + NCB.ncb_lana_num := Enum.lana[I]; + Move(MachineName[1], NCB.ncb_callname, SizeOf(NCB.ncb_callname)); + NCB.ncb_buffer := PUCHAR(@Adapter); + NCB.ncb_length := SizeOf(Adapter); + if NetBios(@NCB) = NRC_GOODRET then + Addresses.Add(AdapterToString(@Adapter.adapt)); + end; + end; + end; + end; + + procedure GetMacAddressesSnmp; + const + InetMib1 = 'inetmib1.dll'; + {$IFNDEF FPC // can't resolve address of const } + NullAdapterAddress: array [0..5] of Byte = ($00, $00, $00, $00, $00, $00); + OID_ipMACEntAddr: array [0..9] of UINT = (1, 3, 6, 1, 2, 1, 2, 2, 1, 6); + OID_ifEntryType: array [0..9] of UINT = (1, 3, 6, 1, 2, 1, 2, 2, 1, 3); + OID_ifEntryNum: array [0..7] of UINT = (1, 3, 6, 1, 2, 1, 2, 1); + {$ENDIF ~FPC} + var + PollForTrapEvent: THandle; + SupportedView: PAsnObjectIdentifier; + MIB_ifMACEntAddr: TAsnObjectIdentifier; + MIB_ifEntryType: TAsnObjectIdentifier; + MIB_ifEntryNum: TAsnObjectIdentifier; + VarBindList: TSnmpVarBindList; + VarBind: array [0..1] of TSnmpVarBind; + ErrorStatus, ErrorIndex: TAsnInteger32; + DTmp: Integer; + Ret: Boolean; + MAC: PJclByteArray; + begin + if LoadSnmp then + try + if LoadSnmpExtension(InetMib1) then + try + MIB_ifMACEntAddr.idLength := Length(OID_ipMACEntAddr); + MIB_ifMACEntAddr.ids := @OID_ipMACEntAddr; + MIB_ifEntryType.idLength := Length(OID_ifEntryType); + MIB_ifEntryType.ids := @OID_ifEntryType; + MIB_ifEntryNum.idLength := Length(OID_ifEntryNum); + MIB_ifEntryNum.ids := @OID_ifEntryNum; + PollForTrapEvent := 0; + SupportedView := nil; + if SnmpExtensionInit(GetTickCount, PollForTrapEvent, SupportedView) then + begin + VarBindList.list := @VarBind[0]; + VarBind[0].name := DEFINE_NULLOID; + VarBind[1].name := DEFINE_NULLOID; + VarBindList.len := 1; + SnmpUtilOidCpy(@VarBind[0].name, @MIB_ifEntryNum); + ErrorIndex := 0; + ErrorStatus := 0; + Ret := SnmpExtensionQuery(SNMP_PDU_GETNEXT, VarBindList, ErrorStatus, ErrorIndex); + if Ret then + begin + Result := VarBind[0].value.number; + VarBindList.len := 2; + SnmpUtilOidCpy(@VarBind[0].name, @MIB_ifEntryType); + SnmpUtilOidCpy(@VarBind[1].name, @MIB_ifMACEntAddr); + while Ret do + begin + Ret := SnmpExtensionQuery(SNMP_PDU_GETNEXT, VarBindList, ErrorStatus, ErrorIndex); + if Ret then + begin + Ret := SnmpUtilOidNCmp(@VarBind[0].name, @MIB_ifEntryType, MIB_ifEntryType.idLength) = SNMP_ERRORSTATUS_NOERROR; + if Ret then + begin + DTmp := VarBind[0].value.number; + if DTmp = 6 then + begin + Ret := SnmpUtilOidNCmp(@VarBind[1].name, @MIB_ifMACEntAddr, MIB_ifMACEntAddr.idLength) = SNMP_ERRORSTATUS_NOERROR; + if Ret and (VarBind[1].value.address.stream <> nil) then + begin + MAC := PJclByteArray(VarBind[1].value.address.stream); + if not CompareMem(MAC, @NullAdapterAddress, SizeOf(NullAdapterAddress)) then + Addresses.Add(AdapterToString(MAC)); + end; + end; + end; + end; + end; + end; + SnmpUtilVarBindFree(@VarBind[0]); + SnmpUtilVarBindFree(@VarBind[1]); + end; + finally + UnloadSnmpExtension; + end; + finally + UnloadSnmp; + end; + end; + +begin + Result := -1; + Addresses.BeginUpdate; + try + Addresses.Clear; + GetMacAddressesNetBios; + if (Result <= 0) and (Machine = '') then + GetMacAddressesSnmp; + finally + Addresses.EndUpdate; + end; +end; +{$ENDIF ~WINSCP} +{$ENDIF MSWINDOWS} +function ReadTimeStampCounter: Int64; assembler; +asm + DW $310F + // TSC in EDX:EAX + {$IFDEF CPU64} + SHL RDX, 32 + OR RAX, RDX + // Result in RAX + {$ENDIF CPU64} +end; + +function GetIntelCacheDescription(const D: Byte): string; +var + I: Integer; +begin + Result := ''; + if D <> 0 then + for I := Low(IntelCacheDescription) to High(IntelCacheDescription) do + if IntelCacheDescription[I].D = D then + begin + Result := LoadResString(IntelCacheDescription[I].I); + Break; + end; + // (outchy) added a return value for unknow D value + if Result = '' then + Result := Format(LoadResString(@RsIntelUnknownCache),[D]); +end; + +{$IFNDEF WINSCP} + +procedure GetCpuInfo(var CpuInfo: TCpuInfo); +begin + CpuInfo := CPUID; + CpuInfo.IsFDIVOK := TestFDIVInstruction; + if CpuInfo.HasInstruction then + begin + {$IFDEF MSWINDOWS} + if (CpuInfo.Features and TSC_FLAG) = TSC_FLAG then + GetCpuSpeed(CpuInfo.FrequencyInfo); + {$ENDIF MSWINDOWS} + end; +end; + +{$ENDIF ~WINSCP} + +function RoundFrequency(const Frequency: Integer): Integer; +const + NF: array [0..8] of Integer = (0, 20, 33, 50, 60, 66, 80, 90, 100); +var + Freq, RF: Integer; + I: Byte; + Hi, Lo: Byte; +begin + RF := 0; + Freq := Frequency mod 100; + for I := 0 to 8 do + begin + if Freq < NF[I] then + begin + Hi := I; + Lo := I - 1; + if (NF[Hi] - Freq) > (Freq - NF[Lo]) then + RF := NF[Lo] - Freq + else + RF := NF[Hi] - Freq; + Break; + end; + end; + Result := Frequency + RF; +end; + +function GetCPUSpeed(var CpuSpeed: TFreqInfo): Boolean; +{$IFDEF UNIX} +begin + { TODO : GetCPUSpeed: Solution for Linux } + Result := False; +end; +{$ENDIF UNIX} +{$IFDEF MSWINDOWS} + +var + T0, T1: Int64; + CountFreq: Int64; + Freq, Freq2, Freq3, Total: Int64; + TotalCycles, Cycles: Int64; + Stamp0, Stamp1: Int64; + TotalTicks, Ticks: Double; + Tries, Priority: Integer; + Thread: THandle; +begin + Stamp0 := 0; + Stamp1 := 0; + Freq := 0; + Freq2 := 0; + Freq3 := 0; + Tries := 0; + TotalCycles := 0; + TotalTicks := 0; + Total := 0; + + Thread := GetCurrentThread(); + CountFreq := 0; + Result := QueryPerformanceFrequency(CountFreq); + if Result then + begin + while ((Tries < 3) or ((Tries < 20) and ((Abs(3 * Freq - Total) > 3) or + (Abs(3 * Freq2 - Total) > 3) or (Abs(3 * Freq3 - Total) > 3)))) do + begin + Inc(Tries); + Freq3 := Freq2; + Freq2 := Freq; + T0 := 0; + QueryPerformanceCounter(T0); + T1 := T0; + + Priority := GetThreadPriority(Thread); + if Priority <> THREAD_PRIORITY_ERROR_RETURN then + SetThreadPriority(Thread, THREAD_PRIORITY_TIME_CRITICAL); + try + while T1 - T0 < 50 do + begin + QueryPerformanceCounter(T1); + Stamp0 := ReadTimeStampCounter; + end; + T0 := T1; + + while T1 - T0 < 1000 do + begin + QueryPerformanceCounter(T1); + Stamp1 := ReadTimeStampCounter; + end; + finally + if Priority <> THREAD_PRIORITY_ERROR_RETURN then + SetThreadPriority(Thread, Priority); + end; + + Cycles := Stamp1 - Stamp0; + Ticks := T1 - T0; + Ticks := Ticks * 100000; + + // avoid division by zero + if CountFreq = 0 then + Ticks := High(Int64) + else + Ticks := Ticks / (CountFreq / 10); + + TotalTicks := TotalTicks + Ticks; + TotalCycles := TotalCycles + Cycles; + + // avoid division by zero + if IsZero(Ticks) then + Freq := High(Freq) + else + Freq := Round(Cycles / Ticks); + + Total := Freq + Freq2 + Freq3; + end; + + // avoid division by zero + if IsZero(TotalTicks) then + begin + Freq3 := High(Freq3); + Freq2 := High(Freq2); + CpuSpeed.RawFreq := High(CpuSpeed.RawFreq); + end + else + begin + Freq3 := Round((TotalCycles * 10) / TotalTicks); // freq. in multiples of 10^5 Hz + Freq2 := Round((TotalCycles * 100) / TotalTicks); // freq. in multiples of 10^4 Hz + CpuSpeed.RawFreq := Round(TotalCycles / TotalTicks); + end; + + CpuSpeed.NormFreq := CpuSpeed.RawFreq; + + if Freq2 - (Freq3 * 10) >= 6 then + Inc(Freq3); + + + Freq := CpuSpeed.RawFreq * 10; + if (Freq3 - Freq) >= 6 then + Inc(CpuSpeed.NormFreq); + + CpuSpeed.ExTicks := Round(TotalTicks); + CpuSpeed.InCycles := TotalCycles; + + CpuSpeed.NormFreq := RoundFrequency(CpuSpeed.NormFreq); + Result := True; + end; +end; + +function GetOSEnabledFeatures: TOSEnabledFeatures; +var + EnabledFeatures: Int64; +begin + if IsWin7 or IsWinServer2008 or IsWinServer2008R2 or IsWin8 or IsWinServer2012 or IsWin81 or IsWinServer2012R2 then + begin + EnabledFeatures := $FFFFFFFF; + EnabledFeatures := EnabledFeatures shl 32; + EnabledFeatures := EnabledFeatures or $FFFFFFFF; + EnabledFeatures := GetEnabledExtendedFeatures(EnabledFeatures); + Result := []; + if (EnabledFeatures and XSTATE_MASK_LEGACY_FLOATING_POINT) <> 0 then + Include(Result, oefFPU); + if (EnabledFeatures and XSTATE_MASK_LEGACY_SSE) <> 0 then + Include(Result, oefSSE); + if (EnabledFeatures and XSTATE_MASK_GSSE) <> 0 then + Include(Result, oefAVX); + end + else + Result := []; +end; +{$ENDIF MSWINDOWS} + +{$IFNDEF WINSCP} + +function CPUID: TCpuInfo; + function HasCPUIDInstruction: Boolean; + const + ID_FLAG = $200000; + {$IFNDEF DELPHI64_TEMPORARY} + begin + {$ENDIF ~DELPHI64_TEMPORARY} + asm + {$IFDEF CPU32} + PUSHFD + POP EAX + MOV ECX, EAX + XOR EAX, ID_FLAG + AND ECX, ID_FLAG + PUSH EAX + POPFD + PUSHFD + POP EAX + AND EAX, ID_FLAG + XOR EAX, ECX + SETNZ Result + {$ENDIF CPU32} + {$IFDEF CPU64} + {$IFDEF FPC} + {$DEFINE DELPHI64_TEMPORARY} + {$ENDIF FPC} + {$IFDEF DELPHI64_TEMPORARY} + PUSHFQ + {$ELSE ~DELPHI64_TEMPORARY} + PUSHFD + {$ENDIF ~DELPHI64_TEMPORARY} + POP RAX + MOV RCX, RAX + XOR RAX, ID_FLAG + AND RCX, ID_FLAG + PUSH RAX + {$IFDEF DELPHI64_TEMPORARY} + POPFQ + {$ELSE ~DELPHI64_TEMPORARY} + POPFD + {$ENDIF ~DELPHI64_TEMPORARY} + {$IFDEF DELPHI64_TEMPORARY} + PUSHFQ + {$ELSE ~DELPHI64_TEMPORARY} + PUSHFD + {$ENDIF ~DELPHI64_TEMPORARY} + POP RAX + AND RAX, ID_FLAG + XOR RAX, RCX + SETNZ Result + {$IFDEF FPC} + {$UNDEF DELPHI64_TEMPORARY} + {$ENDIF FPC} + {$ENDIF CPU64} + end; + {$IFNDEF DELPHI64_TEMPORARY} + end; + {$ENDIF ~DELPHI64_TEMPORARY} + + procedure CallCPUID(ValueEAX, ValueECX: Cardinal; out ReturnedEAX, ReturnedEBX, ReturnedECX, ReturnedEDX); + {$IFNDEF DELPHI64_TEMPORARY} + begin + {$ENDIF ~DELPHI64_TEMPORARY} + asm + {$IFDEF CPU32} + // save context + PUSH EDI + PUSH EBX + // init parameters + MOV EAX, ValueEAX + MOV ECX, ValueECX + // CPUID + DB 0FH + DB 0A2H + // store results + MOV EDI, ReturnedEAX + MOV Cardinal PTR [EDI], EAX + MOV EAX, ReturnedEBX + MOV EDI, ReturnedECX + MOV Cardinal PTR [EAX], EBX + MOV Cardinal PTR [EDI], ECX + MOV EAX, ReturnedEDX + MOV Cardinal PTR [EAX], EDX + // restore context + POP EBX + POP EDI + {$ENDIF CPU32} + {$IFDEF CPU64} + // save context + PUSH RBX + // init parameters + MOV EAX, ValueEAX + MOV ECX, ValueECX + // CPUID + CPUID + // store results + MOV R8, ReturnedEAX + MOV R9, ReturnedEBX + MOV R10, ReturnedECX + MOV R11, ReturnedEDX + MOV Cardinal PTR [R8], EAX + MOV Cardinal PTR [R9], EBX + MOV Cardinal PTR [R10], ECX + MOV Cardinal PTR [R11], EDX + // restore context + POP RBX + {$ENDIF CPU64} + end; + {$IFNDEF DELPHI64_TEMPORARY} + end; + {$ENDIF ~DELPHI64_TEMPORARY} + + procedure ProcessStandard(var CPUInfo: TCpuInfo; HiVal: Cardinal); + var + VersionInfo, AdditionalInfo, ExFeatures: Cardinal; + begin + if HiVal >= 1 then + begin + CallCPUID(1, 0, VersionInfo, AdditionalInfo, ExFeatures, CPUInfo.Features); + + CPUInfo.PType := (VersionInfo and $00003000) shr 12; + CPUInfo.Family := (VersionInfo and $00000F00) shr 8; + CPUInfo.Model := (VersionInfo and $000000F0) shr 4; + CPUInfo.Stepping := (VersionInfo and $0000000F); + CPUInfo.ExtendedModel := (VersionInfo and $000F0000) shr 16; + CPUInfo.ExtendedFamily := (VersionInfo and $0FF00000) shr 20; + + if CPUInfo.CpuType = CPU_TYPE_INTEL then + begin + CPUInfo.IntelSpecific.ExFeatures := ExFeatures; + CPUInfo.IntelSpecific.BrandID := AdditionalInfo and $000000FF; + CPUInfo.IntelSpecific.FlushLineSize := (AdditionalInfo and $0000FF00) shr 8; + CPUInfo.IntelSpecific.APICID := (AdditionalInfo and $FF000000) shr 24; + CPUInfo.HyperThreadingTechnology := (CPUInfo.Features and INTEL_HTT) <> 0; + if CPUInfo.HyperThreadingTechnology then + begin + CPUInfo.LogicalCore := (AdditionalInfo and $00FF0000) shr 16; + if CPUInfo.LogicalCore = 0 then + CPUInfo.LogicalCore := 1; + end; + + if HiVal >= 2 then + begin + CPUInfo.HasCacheInfo := True; + // TODO: multiple loops + CallCPUID(2, 0, CPUInfo.IntelSpecific.CacheDescriptors[0], CPUInfo.IntelSpecific.CacheDescriptors[4], + CPUInfo.IntelSpecific.CacheDescriptors[8], CPUInfo.IntelSpecific.CacheDescriptors[12]); + end; + end; + end; + end; + + procedure ProcessIntel(var CPUInfo: TCpuInfo; HiVal: Cardinal); + var + ExHiVal, Unused, AddressSize, CoreInfo: Cardinal; + I, J: Integer; + begin + CPUInfo.CpuType := CPU_TYPE_INTEL; + CPUInfo.Manufacturer := 'Intel'; + + ProcessStandard(CPUInfo, HiVal); + + if HiVal >= 4 then + begin + CallCPUID(4, 0, CoreInfo, Unused, Unused, Unused); + CPUInfo.PhysicalCore := ((CoreInfo and $FC000000) shr 26) + 1; + end; + + if HiVal >= 6 then + CallCPUID(6, 0, CPUInfo.IntelSpecific.PowerManagementFeatures, Unused, Unused, Unused); + + // check Intel extended + CallCPUID($80000000, 0, ExHiVal, Unused, Unused, Unused); + if ExHiVal >= $80000001 then + begin + CPUInfo.HasExtendedInfo := True; + CallCPUID($80000001, 0, Unused, Unused, CPUInfo.IntelSpecific.Ex64Features2, + CPUInfo.IntelSpecific.Ex64Features); + end; + if ExHiVal >= $80000002 then + CallCPUID($80000002, 0, CPUInfo.CpuName[0], CPUInfo.CpuName[4], CPUInfo.CpuName[8], CPUInfo.CpuName[12]); + if ExHiVal >= $80000003 then + CallCPUID($80000003, 0, CPUInfo.CpuName[16], CPUInfo.CpuName[20], CPUInfo.CpuName[24], CPUInfo.CpuName[28]); + if ExHiVal >= $80000004 then + CallCPUID($80000004, 0, CPUInfo.CpuName[32], CPUInfo.CpuName[36], CPUInfo.CpuName[40], CPUInfo.CpuName[44]); + if ExHiVal >= $80000006 then + CallCPUID($80000006, 0, Unused, Unused, CPUInfo.IntelSpecific.L2Cache, Unused); + if ExHiVal >= $80000008 then + begin + CallCPUID($80000008, 0, AddressSize, Unused, Unused, Unused); + CPUInfo.IntelSpecific.PhysicalAddressBits := AddressSize and $000000FF; + CPUInfo.IntelSpecific.VirtualAddressBits := (AddressSize and $0000FF00) shr 8; + end; + + if CPUInfo.HasCacheInfo then + begin + if (CPUInfo.IntelSpecific.L2Cache <> 0) then + begin + CPUInfo.L2CacheSize := CPUInfo.IntelSpecific.L2Cache shr 16; + CPUInfo.L2CacheLineSize := CPUInfo.IntelSpecific.L2Cache and $FF; + CPUInfo.L2CacheAssociativity := (CPUInfo.IntelSpecific.L2Cache shr 12) and $F; + end; + for I := Low(CPUInfo.IntelSpecific.CacheDescriptors) to High(CPUInfo.IntelSpecific.CacheDescriptors) do + if CPUInfo.IntelSpecific.CacheDescriptors[I]<>0 then + for J := Low(IntelCacheDescription) to High(IntelCacheDescription) do + if IntelCacheDescription[J].D = CPUInfo.IntelSpecific.CacheDescriptors[I] then + with IntelCacheDescription[J] do + case Family of + //cfInstructionTLB: + //cfDataTLB: + cfL1InstructionCache: + begin + Inc(CPUInfo.L1InstructionCacheSize,Size); + CPUInfo.L1InstructionCacheLineSize := LineSize; + CPUInfo.L1InstructionCacheAssociativity := WaysOfAssoc; + end; + cfL1DataCache: + begin + Inc(CPUInfo.L1DataCacheSize,Size); + CPUInfo.L1DataCacheLineSize := LineSize; + CPUInfo.L1DataCacheAssociativity := WaysOfAssoc; + end; + cfL2Cache: + if (CPUInfo.IntelSpecific.L2Cache = 0) then + begin + Inc(CPUInfo.L2CacheSize,Size); + CPUInfo.L2CacheLineSize := LineSize; + CPUInfo.L2CacheAssociativity := WaysOfAssoc; + end; + cfL3Cache: + begin + Inc(CPUInfo.L3CacheSize,Size); + CPUInfo.L3CacheLineSize := LineSize; + CPUInfo.L3CacheAssociativity := WaysOfAssoc; + CPUInfo.L3LinesPerSector := LinePerSector; + end; + //cfTrace: // no numeric informations + //cfOther: + end; + end; + if not CPUInfo.HasExtendedInfo then + begin + case CPUInfo.Family of + 4: + case CPUInfo.Model of + 1: + CPUInfo.CpuName := 'Intel 486DX Processor'; + 2: + CPUInfo.CpuName := 'Intel 486SX Processor'; + 3: + CPUInfo.CpuName := 'Intel DX2 Processor'; + 4: + CPUInfo.CpuName := 'Intel 486 Processor'; + 5: + CPUInfo.CpuName := 'Intel SX2 Processor'; + 7: + CPUInfo.CpuName := 'Write-Back Enhanced Intel DX2 Processor'; + 8: + CPUInfo.CpuName := 'Intel DX4 Processor'; + else + CPUInfo.CpuName := 'Intel 486 Processor'; + end; + 5: + CPUInfo.CpuName := 'Pentium'; + 6: + case CPUInfo.Model of + 1: + CPUInfo.CpuName := 'Pentium Pro'; + 3: + CPUInfo.CpuName := 'Pentium II'; + 5: + case CPUInfo.L2CacheSize of + 0: + CPUInfo.CpuName := 'Celeron'; + 1024: + CPUInfo.CpuName := 'Pentium II Xeon'; + 2048: + CPUInfo.CpuName := 'Pentium II Xeon'; + else + CPUInfo.CpuName := 'Pentium II'; + end; + 6: + case CPUInfo.L2CacheSize of + 0: + CPUInfo.CpuName := 'Celeron'; + 128: + CPUInfo.CpuName := 'Celeron'; + else + CPUInfo.CpuName := 'Pentium II'; + end; + 7: + case CPUInfo.L2CacheSize of + 1024: + CPUInfo.CpuName := 'Pentium III Xeon'; + 2048: + CPUInfo.CpuName := 'Pentium III Xeon'; + else + CPUInfo.CpuName := 'Pentium III'; + end; + 8: + case CPUInfo.IntelSpecific.BrandID of + 1: + CPUInfo.CpuName := 'Celeron'; + 2: + CPUInfo.CpuName := 'Pentium III'; + 3: + CPUInfo.CpuName := 'Pentium III Xeon'; + 4: + CPUInfo.CpuName := 'Pentium III'; + else + CPUInfo.CpuName := 'Pentium III'; + end; + 10: + CPUInfo.CpuName := 'Pentium III Xeon'; + 11: + CPUInfo.CpuName := 'Pentium III'; + else + StrPCopyA(CPUInfo.CpuName, AnsiString(Format('P6 (Model %d)', [CPUInfo.Model]))); + end; + 15: + case CPUInfo.IntelSpecific.BrandID of + 1: + CPUInfo.CpuName := 'Celeron'; + 8: + CPUInfo.CpuName := 'Pentium 4'; + 14: + CPUInfo.CpuName := 'Xeon'; + else + CPUInfo.CpuName := 'Pentium 4'; + end; + else + StrPCopyA(CPUInfo.CpuName, AnsiString(Format('P%d', [CPUInfo.Family]))); + end; + end; + + CPUInfo.HardwareHyperThreadingTechnology := CPUInfo.LogicalCore <> CPUInfo.PhysicalCore; + CPUInfo.AES := (CPUInfo.IntelSpecific.ExFeatures and EINTEL_AES) <> 0; + CPUInfo.MMX := (CPUInfo.Features and MMX_FLAG) <> 0; + CPUInfo.SSE := []; + if (CPUInfo.Features and SSE_FLAG) <> 0 then + Include(CPUInfo.SSE, sse); + if (CPUInfo.Features and SSE2_FLAG) <> 0 then + Include(CPUInfo.SSE, sse2); + if (CPUInfo.IntelSpecific.ExFeatures and EINTEL_SSE3) <> 0 then + Include(CPUInfo.SSE, sse3); + if (CPUInfo.IntelSpecific.ExFeatures and EINTEL_SSSE3) <> 0 then + Include(CPUInfo.SSE, ssse3); + if (CPUInfo.IntelSpecific.ExFeatures and EINTEL_SSE4_1) <> 0 then + Include(CPUInfo.SSE, sse41); + if (CPUInfo.IntelSpecific.ExFeatures and EINTEL_SSE4_2) <> 0 then + Include(CPUInfo.SSE, sse42); + if (CPUInfo.IntelSpecific.ExFeatures and EINTEL_AVX) <> 0 then + Include(CPUInfo.SSE, avx); + CPUInfo.Is64Bits := CPUInfo.HasExtendedInfo and ((CPUInfo.IntelSpecific.Ex64Features and EINTEL64_EM64T)<>0); + CPUInfo.DepCapable := CPUInfo.HasExtendedInfo and ((CPUInfo.IntelSpecific.Ex64Features and EINTEL64_XD) <> 0); + end; + + procedure ProcessAMD(var CPUInfo: TCpuInfo; HiVal: Cardinal); + var + ExHiVal, Unused, VersionInfo, AdditionalInfo: Cardinal; + begin + CPUInfo.CpuType := CPU_TYPE_AMD; + CPUInfo.Manufacturer := 'AMD'; + + // check AMD extended + if HiVal >= 1 then + begin + CallCPUID(1, 0, VersionInfo, AdditionalInfo, CPUInfo.AMDSpecific.Features2, CPUInfo.Features); + + CPUInfo.AMDSpecific.BrandID := AdditionalInfo and $000000FF; + CPUInfo.AMDSpecific.FlushLineSize := (AdditionalInfo and $0000FF00) shr 8; + CPUInfo.AMDSpecific.APICID := (AdditionalInfo and $FF000000) shr 24; + CPUInfo.HyperThreadingTechnology := (CPUInfo.Features and AMD_HTT) <> 0; + if CPUInfo.HyperThreadingTechnology then + begin + CPUInfo.LogicalCore := (AdditionalInfo and $00FF0000) shr 16; + if CPUInfo.LogicalCore = 0 then + CPUInfo.LogicalCore := 1; + end; + end; + + CallCPUID($80000000, 0, ExHiVal, Unused, Unused, Unused); + if ExHiVal <> 0 then + begin + // AMD only + CPUInfo.HasExtendedInfo := True; + + if ExHiVal >= $80000001 then + begin + CallCPUID($80000001, 0, VersionInfo, AdditionalInfo, CPUInfo.AMDSpecific.ExFeatures2, CPUInfo.AMDSpecific.ExFeatures); + CPUInfo.Family := (VersionInfo and $00000F00) shr 8; + CPUInfo.Model := (VersionInfo and $000000F0) shr 4; + CPUInfo.Stepping := (VersionInfo and $0000000F); + CPUInfo.ExtendedModel := (VersionInfo and $000F0000) shr 16; + CPUInfo.ExtendedFamily := (VersionInfo and $0FF00000) shr 20; + CPUInfo.AMDSpecific.ExBrandID := AdditionalInfo and $0000FFFF; + end; + if ExHiVal >= $80000002 then + CallCPUID($80000002, 0, CPUInfo.CpuName[0], CPUInfo.CpuName[4], CPUInfo.CpuName[8], CPUInfo.CpuName[12]); + if ExHiVal >= $80000003 then + CallCPUID($80000003, 0, CPUInfo.CpuName[16], CPUInfo.CpuName[20], CPUInfo.CpuName[24], CPUInfo.CpuName[28]); + if ExHiVal >= $80000004 then + CallCPUID($80000004, 0, CPUInfo.CpuName[32], CPUInfo.CpuName[36], CPUInfo.CpuName[40], CPUInfo.CpuName[44]); + if ExHiVal >= $80000005 then + begin + CPUInfo.HasCacheInfo := True; + CallCPUID($80000005, 0, CPUInfo.AMDSpecific.L1MByteInstructionTLB, CPUInfo.AMDSpecific.L1KByteInstructionTLB, + CPUInfo.AMDSpecific.L1DataCache, CPUInfo.AMDSpecific.L1InstructionCache); + end; + if ExHiVal >= $80000006 then + CallCPUID($80000006, 0, CPUInfo.AMDSpecific.L2MByteInstructionTLB, CPUInfo.AMDSpecific.L2KByteInstructionTLB, + CPUInfo.AMDSpecific.L2Cache, CPUInfo.AMDSpecific.L3Cache); + if CPUInfo.HasCacheInfo then + begin + CPUInfo.L1DataCacheSize := CPUInfo.AMDSpecific.L1DataCache[ciSize]; + CPUInfo.L1DataCacheLineSize := CPUInfo.AMDSpecific.L1DataCache[ciLineSize]; + CPUInfo.L1DataCacheAssociativity := CPUInfo.AMDSpecific.L1DataCache[ciAssociativity]; + CPUInfo.L1InstructionCacheSize := CPUInfo.AMDSpecific.L1InstructionCache[ciSize]; + CPUInfo.L1InstructionCacheLineSize := CPUInfo.AMDSpecific.L1InstructionCache[ciLineSize]; + CPUInfo.L1InstructionCacheAssociativity := CPUInfo.AMDSpecific.L1InstructionCache[ciAssociativity]; + CPUInfo.L2CacheLineSize := CPUInfo.AMDSpecific.L2Cache and $FF; + CPUInfo.L2CacheAssociativity := (CPUInfo.AMDSpecific.L2Cache shr 12) and $F; + CPUInfo.L2CacheSize := CPUInfo.AMDSpecific.L2Cache shr 16; + CPUInfo.L3CacheLineSize := CPUInfo.AMDSpecific.L3Cache and $FF; + CPUInfo.L3CacheAssociativity := (CPUInfo.AMDSpecific.L3Cache shr 12) and $F; + CPUInfo.L3CacheSize := CPUInfo.AMDSpecific.L3Cache shr 19 {MB}; //(CPUInfo.AMDSpecific.L3Cache shr 18) * 512 {kB}; + end; + if ExHiVal >= $80000007 then + CallCPUID($80000007, 0, Unused, Unused, Unused, CPUInfo.AMDSpecific.AdvancedPowerManagement); + if ExHiVal >= $80000008 then + begin + CallCPUID($80000008, 0, Unused, VersionInfo, AdditionalInfo, Unused); + CPUInfo.AMDSpecific.PhysicalAddressSize := VersionInfo and $000000FF; + CPUInfo.AMDSpecific.VirtualAddressSize := (VersionInfo and $0000FF00) shr 8; + CPUInfo.PhysicalCore := (AdditionalInfo and $000000FF) + 1; + end; + end + else + begin + ProcessStandard(CPUInfo, HiVal); + case CPUInfo.Family of + 4: + CPUInfo.CpuName := 'Am486(R) or Am5x86'; + 5: + case CPUInfo.Model of + 0: + CPUInfo.CpuName := 'AMD-K5 (Model 0)'; + 1: + CPUInfo.CpuName := 'AMD-K5 (Model 1)'; + 2: + CPUInfo.CpuName := 'AMD-K5 (Model 2)'; + 3: + CPUInfo.CpuName := 'AMD-K5 (Model 3)'; + 6: + CPUInfo.CpuName := 'AMD-K6® (Model 6)'; + 7: + CPUInfo.CpuName := 'AMD-K6® (Model 7)'; + 8: + CPUInfo.CpuName := 'AMD-K6®-2 (Model 8)'; + 9: + CPUInfo.CpuName := 'AMD-K6®-III (Model 9)'; + else + StrFmtA(CPUInfo.CpuName, PAnsiChar(AnsiString(LoadResString(@RsUnknownAMDModel))), [CPUInfo.Model]); + end; + 6: + case CPUInfo.Model of + 1: + CPUInfo.CpuName := 'AMD Athlon™ (Model 1)'; + 2: + CPUInfo.CpuName := 'AMD Athlon™ (Model 2)'; + 3: + CPUInfo.CpuName := 'AMD Duron™ (Model 3)'; + 4: + CPUInfo.CpuName := 'AMD Athlon™ (Model 4)'; + 6: + CPUInfo.CpuName := 'AMD Athlon™ XP (Model 6)'; + 7: + CPUInfo.CpuName := 'AMD Duron™ (Model 7)'; + 8: + CPUInfo.CpuName := 'AMD Athlon™ XP (Model 8)'; + 10: + CPUInfo.CpuName := 'AMD Athlon™ XP (Model 10)'; + else + StrFmtA(CPUInfo.CpuName, PAnsiChar(AnsiString(LoadResString(@RsUnknownAMDModel))), [CPUInfo.Model]); + end; + 8: + + else + CPUInfo.CpuName := 'Unknown AMD Chip'; + end; + end; + + CPUInfo.HardwareHyperThreadingTechnology := CPUInfo.LogicalCore <> CPUInfo.PhysicalCore; + CPUInfo.AES := (CPUInfo.AMDSpecific.Features2 and AMD2_AES) <> 0; + CPUInfo.MMX := (CPUInfo.Features and AMD_MMX) <> 0; + CPUInfo.ExMMX := CPUInfo.HasExtendedInfo and ((CPUInfo.AMDSpecific.ExFeatures and EAMD_EXMMX) <> 0); + CPUInfo._3DNow := CPUInfo.HasExtendedInfo and ((CPUInfo.AMDSpecific.ExFeatures and EAMD_3DNOW) <> 0); + CPUInfo.Ex3DNow := CPUInfo.HasExtendedInfo and ((CPUInfo.AMDSpecific.ExFeatures and EAMD_EX3DNOW) <> 0); + CPUInfo.SSE := []; + if (CPUInfo.Features and AMD_SSE) <> 0 then + Include(CPUInfo.SSE, sse); + if (CPUInfo.Features and AMD_SSE2) <> 0 then + Include(CPUInfo.SSE, sse2); + if (CPUInfo.AMDSpecific.Features2 and AMD2_SSE3) <> 0 then + Include(CPUInfo.SSE, sse3); + if CPUInfo.HasExtendedInfo then + begin + if (CPUInfo.AMDSpecific.ExFeatures2 and EAMD2_SSE4A) <> 0 then + Include(CPUInfo.SSE, sse4A); + if (CPUInfo.AMDSpecific.Features2 and AMD2_SSE41) <> 0 then + Include(CPUInfo.SSE, sse41); + if (CPUInfo.AMDSpecific.Features2 and AMD2_SSE42) <> 0 then + Include(CPUInfo.SSE, sse42); + end; + CPUInfo.Is64Bits := CPUInfo.HasExtendedInfo and ((CPUInfo.AMDSpecific.ExFeatures and EAMD_LONG) <> 0); + CPUInfo.DEPCapable := CPUInfo.HasExtendedInfo and ((CPUInfo.AMDSpecific.ExFeatures and EAMD_NX) <> 0); + end; + + procedure ProcessCyrix(var CPUInfo: TCpuInfo; HiVal: Cardinal); + var + ExHiVal, Unused, VersionInfo, AdditionalInfo: Cardinal; + begin + CPUInfo.CpuType := CPU_TYPE_CYRIX; + CPUInfo.Manufacturer := 'Cyrix'; + + // check Cyrix extended + CallCPUID($80000000, 0, ExHiVal, Unused, Unused, Unused); + if ExHiVal <> 0 then + begin + // Cyrix only + CPUInfo.HasExtendedInfo := True; + if ExHiVal >= $80000001 then + begin + CallCPUID($80000001, 0, VersionInfo, AdditionalInfo, Unused, CPUInfo.Features); + CPUInfo.PType := (VersionInfo and $0000F000) shr 12; + CPUInfo.Family := (VersionInfo and $00000F00) shr 8; + CPUInfo.Model := (VersionInfo and $000000F0) shr 4; + CPUInfo.Stepping := (VersionInfo and $0000000F); + end; + if ExHiVal >= $80000002 then + CallCPUID($80000002, 0, CPUInfo.CpuName[0], CPUInfo.CpuName[4], CPUInfo.CpuName[8], CPUInfo.CpuName[12]); + if ExHiVal >= $80000003 then + CallCPUID($80000003, 0, CPUInfo.CpuName[16], CPUInfo.CpuName[20], CPUInfo.CpuName[24], CPUInfo.CpuName[28]); + if ExHiVal >= $80000004 then + CallCPUID($80000004, 0, CPUInfo.CpuName[32], CPUInfo.CpuName[36], CPUInfo.CpuName[40], CPUInfo.CpuName[44]); + if ExHiVal >= $80000005 then + begin + CPUInfo.HasCacheInfo := True; + CallCPUID($80000005, 0, Unused, CPUInfo.CyrixSpecific.TLBInfo, CPUInfo.CyrixSpecific.L1CacheInfo, Unused); + end; + end + else + begin + ProcessStandard(CPUInfo, HiVal); + case CPUInfo.Family of + 4: + CPUInfo.CpuName := 'Cyrix MediaGX'; + 5: + case CPUInfo.Model of + 2: + CPUInfo.CpuName := 'Cyrix 6x86'; + 4: + CPUInfo.CpuName := 'Cyrix GXm'; + end; + 6: + CPUInfo.CpuName := '6x86MX'; + else + StrPCopyA(CPUInfo.CpuName, AnsiString(Format('%dx86', [CPUInfo.Family]))); + end; + end; + end; + + procedure ProcessVIA(var CPUInfo: TCpuInfo; HiVal: Cardinal); + var + ExHiVal, Unused, VersionInfo: Cardinal; + begin + CPUInfo.CpuType := CPU_TYPE_VIA; + CPUInfo.Manufacturer := 'Via'; + + // check VIA extended + CallCPUID($80000000, 0, ExHiVal, Unused, Unused, Unused); + if ExHiVal <> 0 then + begin + if ExHiVal >= $80000001 then + begin + CPUInfo.HasExtendedInfo := True; + CallCPUID($80000001, 0, VersionInfo, Unused, Unused, CPUInfo.ViaSpecific.ExFeatures); + CPUInfo.PType := (VersionInfo and $00003000) shr 12; + CPUInfo.Family := (VersionInfo and $00000F00) shr 8; + CPUInfo.Model := (VersionInfo and $000000F0) shr 4; + CPUInfo.Stepping := (VersionInfo and $0000000F); + end; + if ExHiVal >= $80000002 then + CallCPUID($80000002, 0, CPUInfo.CpuName[0], CPUInfo.CpuName[4], CPUInfo.CpuName[8], CPUInfo.CpuName[12]); + if ExHiVal >= $80000003 then + CallCPUID($80000003, 0, CPUInfo.CpuName[16], CPUInfo.CpuName[20], CPUInfo.CpuName[24], CPUInfo.CpuName[28]); + if ExHiVal >= $80000004 then + CallCPUID($80000004, 0, CPUInfo.CpuName[32], CPUInfo.CpuName[36], CPUInfo.CpuName[40], CPUInfo.CpuName[44]); + if ExHiVal >= $80000005 then + begin + CPUInfo.HasCacheInfo := True; + CallCPUID($80000005, 0, Unused, CPUInfo.ViaSpecific.InstructionTLB, CPUInfo.ViaSpecific.L1DataCache, + CPUInfo.ViaSpecific.L1InstructionCache); + end; + if ExHiVal >= $80000006 then + CallCPUID($80000006, 0, Unused, Unused, CPUInfo.ViaSpecific.L2DataCache, Unused); + + if CPUInfo.HasCacheInfo then + begin + CPUInfo.L1DataCacheSize := CPUInfo.VIASpecific.L1DataCache[ciSize]; + CPUInfo.L1DataCacheLineSize := CPUInfo.VIASpecific.L1DataCache[ciLineSize]; + CPUInfo.L1DataCacheAssociativity := CPUInfo.VIASpecific.L1DataCache[ciAssociativity]; + CPUInfo.L1InstructionCacheSize := CPUInfo.VIASpecific.L1InstructionCache[ciSize]; + CPUInfo.L1InstructionCacheLineSize := CPUInfo.VIASpecific.L1InstructionCache[ciLineSize]; + CPUInfo.L1InstructionCacheAssociativity := CPUInfo.VIASpecific.L1InstructionCache[ciAssociativity]; + CPUInfo.L2CacheLineSize := CPUInfo.VIASpecific.L2DataCache and $FF; + CPUInfo.L2CacheAssociativity := (CPUInfo.VIASpecific.L2DataCache shr 12) and $F; + CPUInfo.L2CacheSize := CPUInfo.VIASpecific.L2DataCache shr 16; + end; + + CallCPUID($C0000000, 0, ExHiVal, Unused, Unused, Unused); + if ExHiVal >= $C0000001 then + CallCPUID($C0000001, 0, Unused, Unused, Unused, CPUInfo.ViaSpecific.ExFeatures); + end + else + ProcessStandard(CPUInfo, HiVal); + + if not CPUInfo.HasExtendedInfo then + CPUInfo.CpuName := 'C3'; + CPUInfo.MMX := (CPUInfo.Features and VIA_MMX) <> 0; + CPUInfo.SSE := []; + if (CPUInfo.Features and VIA_SSE) <> 0 then + Include(CPUInfo.SSE, sse); + CPUInfo._3DNow := (CPUInfo.Features and VIA_3DNOW) <> 0; + end; + + procedure ProcessTransmeta(var CPUInfo: TCpuInfo; HiVal: Cardinal); + var + ExHiVal, Unused, VersionInfo: Cardinal; + begin + CPUInfo.CpuType := CPU_TYPE_TRANSMETA; + CPUInfo.Manufacturer := 'Transmeta'; + + if (HiVal >= 1) then + begin + CallCPUID(1, 0, VersionInfo, Unused, Unused, CPUInfo.Features); + CPUInfo.PType := (VersionInfo and $00003000) shr 12; + CPUInfo.Family := (VersionInfo and $00000F00) shr 8; + CPUInfo.Model := (VersionInfo and $000000F0) shr 4; + CPUInfo.Stepping := (VersionInfo and $0000000F); + end; + // no information when eax is 2 + // eax is 3 means Serial Number, not detected there + + // small CPU description, overriden if ExHiVal >= 80000002 + CallCPUID($80000000, 0, ExHiVal, CPUInfo.CpuName[0], CPUInfo.CpuName[8], CPUInfo.CpuName[4]); + if ExHiVal <> 0 then + begin + CPUInfo.HasExtendedInfo := True; + + if ExHiVal >= $80000001 then + CallCPUID($80000001, 0, Unused, Unused, Unused, CPUInfo.TransmetaSpecific.ExFeatures); + if ExHiVal >= $80000002 then + CallCPUID($80000002, 0, CPUInfo.CpuName[0], CPUInfo.CpuName[4], CPUInfo.CpuName[8], CPUInfo.CpuName[12]); + if ExHiVal >= $80000003 then + CallCPUID($80000003, 0, CPUInfo.CpuName[16], CPUInfo.CpuName[20], CPUInfo.CpuName[24], CPUInfo.CpuName[28]); + if ExHiVal >= $80000004 then + CallCPUID($80000004, 0, CPUInfo.CpuName[32], CPUInfo.CpuName[36], CPUInfo.CpuName[40], CPUInfo.CpuName[44]); + if ExHiVal >= $80000005 then + begin + CPUInfo.HasCacheInfo := True; + CallCPUID($80000005, 0, Unused, CPUInfo.TransmetaSpecific.CodeTLB, CPUInfo.TransmetaSpecific.L1DataCache, + CPUInfo.TransmetaSpecific.L1CodeCache); + end; + if CPUInfo.HasCacheInfo then + begin + CPUInfo.L1DataCacheSize := CPUInfo.TransmetaSpecific.L1DataCache[ciSize]; + CPUInfo.L1DataCacheLineSize := CPUInfo.TransmetaSpecific.L1DataCache[ciLineSize]; + CPUInfo.L1DataCacheAssociativity := CPUInfo.TransmetaSpecific.L1DataCache[ciAssociativity]; + CPUInfo.L1InstructionCacheSize := CPUInfo.TransmetaSpecific.L1CodeCache[ciSize]; + CPUInfo.L1InstructionCacheLineSize := CPUInfo.TransmetaSpecific.L1CodeCache[ciLineSize]; + CPUInfo.L1InstructionCacheAssociativity := CPUInfo.TransmetaSpecific.L1CodeCache[ciAssociativity]; + CPUInfo.L2CacheLineSize := CPUInfo.TransmetaSpecific.L2Cache and $FF; + CPUInfo.L2CacheAssociativity := (CPUInfo.TransmetaSpecific.L2Cache shr 12) and $F; + CPUInfo.L2CacheSize := CPUInfo.TransmetaSpecific.L2Cache shr 16; + end; + if ExHiVal >= $80000006 then + CallCPUID($80000006, 0, Unused, Unused, CPUInfo.TransmetaSpecific.L2Cache, Unused); + end + else + CPUInfo.CpuName := 'Crusoe'; + + CallCPUID($80860000, 0, ExHiVal, Unused, Unused, Unused); + if ExHiVal <> 0 then + begin + if ExHiVal >= $80860001 then + CallCPUID($80860001, 0, Unused, CPUInfo.TransmetaSpecific.RevisionABCD, CPUInfo.TransmetaSpecific.RevisionXXXX, + CPUInfo.TransmetaSpecific.TransmetaFeatures); + if ExHiVal >= $80860002 then + CallCPUID($80860002, 0, Unused, CPUInfo.TransmetaSpecific.CodeMorphingABCD, CPUInfo.TransmetaSpecific.CodeMorphingXXXX, Unused); + if ExHiVal >= $80860003 then + CallCPUID($80860003, 0, CPUInfo.TransmetaSpecific.TransmetaInformations[0], CPUInfo.TransmetaSpecific.TransmetaInformations[4], + CPUInfo.TransmetaSpecific.TransmetaInformations[8], CPUInfo.TransmetaSpecific.TransmetaInformations[12]); + if ExHiVal >= $80860004 then + CallCPUID($80860004, 0, CPUInfo.TransmetaSpecific.TransmetaInformations[16], CPUInfo.TransmetaSpecific.TransmetaInformations[20], + CPUInfo.TransmetaSpecific.TransmetaInformations[24], CPUInfo.TransmetaSpecific.TransmetaInformations[28]); + if ExHiVal >= $80860005 then + CallCPUID($80860005, 0, CPUInfo.TransmetaSpecific.TransmetaInformations[32], CPUInfo.TransmetaSpecific.TransmetaInformations[36], + CPUInfo.TransmetaSpecific.TransmetaInformations[40], CPUInfo.TransmetaSpecific.TransmetaInformations[44]); + if ExHiVal >= $80860006 then + CallCPUID($80860006, 0, CPUInfo.TransmetaSpecific.TransmetaInformations[48], CPUInfo.TransmetaSpecific.TransmetaInformations[52], + CPUInfo.TransmetaSpecific.TransmetaInformations[56], CPUInfo.TransmetaSpecific.TransmetaInformations[60]); + if (ExHiVal >= $80860007) and ((CPUInfo.TransmetaSpecific.TransmetaFeatures and STRANSMETA_LONGRUN) <> 0) then + CallCPUID($80860007, 0, CPUInfo.TransmetaSpecific.CurrentFrequency, CPUInfo.TransmetaSpecific.CurrentVoltage, + CPUInfo.TransmetaSpecific.CurrentPerformance, Unused); + end; + CPUInfo.MMX := (CPUInfo.Features and TRANSMETA_MMX) <> 0; + end; + +var + HiVal: Cardinal; +begin + ResetMemory(Result, sizeof(Result)); + Result.LogicalCore := 1; + Result.PhysicalCore := 1; + + if HasCPUIDInstruction then + begin + Result.HasInstruction := True; + CallCPUID(0, 0, HiVal, Result.VendorIDString[0], Result.VendorIDString[8], + Result.VendorIDString[4]); + if Result.VendorIDString = VendorIDIntel then + ProcessIntel(Result, HiVal) + else if Result.VendorIDString = VendorIDAMD then + ProcessAMD(Result, HiVal) + else if Result.VendorIDString = VendorIDCyrix then + ProcessCyrix(Result, HiVal) + else if Result.VendorIDString = VendorIDVIA then + ProcessVIA(Result, HiVal) + else if Result.VendorIDString = VendorIDTransmeta then + ProcessTransmeta(Result, HiVal) + else + ProcessStandard(Result, HiVal); + end + else + Result.Family := 4; + + if Result.CpuType = 0 then + begin + Result.Manufacturer := 'Unknown'; + Result.CpuName := 'Unknown'; + end; +end; + +{$ENDIF ~WINSCP} + +function TestFDIVInstruction: Boolean; +{$IFDEF CPU32} +var + TopNum: Double; + BottomNum: Double; + One: Double; + ISOK: Boolean; +begin + // The following code was found in Borlands fdiv.asm file in the + // Delphi 3\Source\RTL\SYS directory, (I made some minor modifications) + // therefore I cannot take credit for it. + TopNum := 2658955; + BottomNum := PI; + One := 1; + asm + PUSH EAX + FLD [TopNum] + FDIV [BottomNum] + FMUL [BottomNum] + FSUBR [TopNum] + FCOMP [One] + FSTSW AX + SHR EAX, 8 + AND EAX, 01H + MOV ISOK, AL + POP EAX + end; + Result := ISOK; +end; +{$ENDIF CPU32} +{$IFDEF CPU64} +begin + Result := True; +end; +{$ENDIF CPU64} + +//=== Alloc granularity ====================================================== + +procedure RoundToAllocGranularity64(var Value: Int64; Up: Boolean); +begin + if (Value mod AllocGranularity) <> 0 then + if Up then + Value := ((Value div AllocGranularity) + 1) * AllocGranularity + else + Value := (Value div AllocGranularity) * AllocGranularity; +end; + +procedure RoundToAllocGranularityPtr(var Value: Pointer; Up: Boolean); +var + Addr: TJclAddr; +begin + Addr := TJclAddr(Value); + if (Addr mod AllocGranularity) <> 0 then + begin + if Up then + Addr := ((Addr div AllocGranularity) + 1) * AllocGranularity + else + Addr := (Addr div AllocGranularity) * AllocGranularity; + Value := Pointer(Addr); + end; +end; + +//=== Advanced Power Management (APM) ======================================== + +{$IFDEF MSWINDOWS} +function GetAPMLineStatus: TAPMLineStatus; +var + SystemPowerStatus: TSystemPowerStatus; +begin + Result := alsUnknown; + + if (Win32Platform = VER_PLATFORM_WIN32_NT) and (Win32MajorVersion < 5) then // Windows NT doesn't support GetSystemPowerStatus + Exit; // so we return alsUnknown + + SystemPowerStatus.ACLineStatus := 0; + if not GetSystemPowerStatus(SystemPowerStatus) then + RaiseLastOSError + else + begin + case SystemPowerStatus.ACLineStatus of + 0: + Result := alsOffline; + 1: + Result := alsOnline; + 255: + Result := alsUnknown; + end; + end; +end; + +function GetAPMBatteryFlag: TAPMBatteryFlag; +var + SystemPowerStatus: TSystemPowerStatus; +begin + Result := abfUnknown; + + if (Win32Platform = VER_PLATFORM_WIN32_NT) and (Win32MajorVersion < 5) then // Windows NT doesn't support GetSystemPowerStatus + Exit; // so we return abfUnknown + + SystemPowerStatus.ACLineStatus := 0; + if not GetSystemPowerStatus(SystemPowerStatus) then + RaiseLastOSError + else + begin + case SystemPowerStatus.BatteryFlag of + 1: + Result := abfHigh; + 2: + Result := abfLow; + 4: + Result := abfCritical; + 8: + Result := abfCharging; + 128: + Result := abfNoBattery; + 255: + Result := abfUnknown; + end; + end; +end; + + +function GetAPMBatteryFlags: TAPMBatteryFlags; +var + SystemPowerStatus: TSystemPowerStatus; +begin + Result := []; + + if (Win32Platform = VER_PLATFORM_WIN32_NT) and (Win32MajorVersion < 5) then // Windows NT doesn't support GetSystemPowerStatus + begin + Result := [abfUnknown]; + Exit; // so we return [abfUnknown] + end; + + SystemPowerStatus.ACLineStatus := 0; + if not GetSystemPowerStatus(SystemPowerStatus) then + RaiseLastOSError + else + begin + if (SystemPowerStatus.BatteryFlag and 1) <> 0 then + Result := Result + [abfHigh]; + if (SystemPowerStatus.BatteryFlag and 2) <> 0 then + Result := Result + [abfLow]; + if (SystemPowerStatus.BatteryFlag and 4) <> 0 then + Result := Result + [abfCritical]; + if (SystemPowerStatus.BatteryFlag and 8) <> 0 then + Result := Result + [abfCharging]; + if (SystemPowerStatus.BatteryFlag and 128) <> 0 then + Result := Result + [abfNoBattery]; + if SystemPowerStatus.BatteryFlag = 255 then + Result := Result + [abfUnknown]; + end; +end; + +function GetAPMBatteryLifePercent: Integer; +var + SystemPowerStatus: TSystemPowerStatus; +begin + Result := 0; + + if (Win32Platform = VER_PLATFORM_WIN32_NT) and (Win32MajorVersion < 5) then // Windows NT doesn't support GetSystemPowerStatus + Exit; + + SystemPowerStatus.ACLineStatus := 0; + if not GetSystemPowerStatus(SystemPowerStatus) then + RaiseLastOSError + else + Result := SystemPowerStatus.BatteryLifePercent; +end; + +function GetAPMBatteryLifeTime: DWORD; +var + SystemPowerStatus: TSystemPowerStatus; +begin + Result := 0; + + if (Win32Platform = VER_PLATFORM_WIN32_NT) and (Win32MajorVersion < 5) then // Windows NT doesn't support GetSystemPowerStatus + Exit; + + SystemPowerStatus.ACLineStatus := 0; + if not GetSystemPowerStatus(SystemPowerStatus) then + RaiseLastOSError + else + Result := SystemPowerStatus.BatteryLifeTime; +end; + +function GetAPMBatteryFullLifeTime: DWORD; +var + SystemPowerStatus: TSystemPowerStatus; +begin + Result := 0; + + if (Win32Platform = VER_PLATFORM_WIN32_NT) and (Win32MajorVersion < 5) then // Windows NT doesn't support GetSystemPowerStatus + Exit; + + SystemPowerStatus.ACLineStatus := 0; + if not GetSystemPowerStatus(SystemPowerStatus) then + RaiseLastOSError + else + Result := SystemPowerStatus.BatteryFullLifeTime; +end; + +//=== Memory Information ===================================================== + +function GetMaxAppAddress: TJclAddr; +var + SystemInfo: TSystemInfo; +begin + ResetMemory(SystemInfo, SizeOf(SystemInfo)); + GetSystemInfo(SystemInfo); + Result := TJclAddr(SystemInfo.lpMaximumApplicationAddress); +end; + +function GetMinAppAddress: TJclAddr; +var + SystemInfo: TSystemInfo; +begin + ResetMemory(SystemInfo, SizeOf(SystemInfo)); + GetSystemInfo(SystemInfo); + Result := TJclAddr(SystemInfo.lpMinimumApplicationAddress); +end; +{$ENDIF MSWINDOWS} + +function GetMemoryLoad: Byte; +{$IFDEF UNIX} +var + SystemInf: TSysInfo; +begin + {$IFDEF FPC} + SysInfo(@SystemInf); + {$ELSE ~FPC} + SysInfo(SystemInf); + {$ENDIF ~FPC} + with SystemInf do + Result := 100 - Round(100 * freeram / totalram); +end; +{$ENDIF UNIX} +{$IFDEF MSWINDOWS} +var + MemoryStatusEx: TMemoryStatusEx; +begin + ResetMemory(MemoryStatusEx, SizeOf(MemoryStatusEx)); + MemoryStatusEx.dwLength := SizeOf(MemoryStatusEx); + if not GlobalMemoryStatusEx(MemoryStatusEx) then + RaiseLastOSError; + Result := MemoryStatusEx.dwMemoryLoad; +end; +{$ENDIF MSWINDOWS} + +function GetSwapFileSize: Int64; +{$IFDEF UNIX} +var + SystemInf: TSysInfo; +begin + {$IFDEF FPC} + SysInfo(@SystemInf); + {$ELSE ~FPC} + SysInfo(SystemInf); + {$ENDIF ~FPC} + Result := SystemInf.totalswap; +end; +{$ENDIF UNIX} +{$IFDEF MSWINDOWS} +var + MemoryStatusEx: TMemoryStatusEx; +begin + ResetMemory(MemoryStatusEx, SizeOf(MemoryStatusEx)); + MemoryStatusEx.dwLength := SizeOf(MemoryStatusEx); + if not GlobalMemoryStatusEx(MemoryStatusEx) then + RaiseLastOSError; + Result := MemoryStatusEx.ullTotalPageFile - MemoryStatusEx.ullAvailPageFile; +end; +{$ENDIF MSWINDOWS} + +function GetSwapFileUsage: Byte; +{$IFDEF UNIX} +var + SystemInf: TSysInfo; +begin + {$IFDEF FPC} + SysInfo(@SystemInf); + {$ELSE ~FPC} + SysInfo(SystemInf); + {$ENDIF ~FPC} + with SystemInf do + Result := 100 - Trunc(100 * FreeSwap / TotalSwap); +end; +{$ENDIF UNIX} +{$IFDEF MSWINDOWS} +var + MemoryStatusEx: TMemoryStatusEx; +begin + ResetMemory(MemoryStatusEx, SizeOf(MemoryStatusEx)); + MemoryStatusEx.dwLength := SizeOf(MemoryStatusEx); + if not GlobalMemoryStatusEx(MemoryStatusEx) then + RaiseLastOSError; + if MemoryStatusEx.ullTotalPageFile > 0 then + Result := 100 - Trunc(MemoryStatusEx.ullAvailPageFile / MemoryStatusEx.ullTotalPageFile * 100) + else + Result := 0; +end; +{$ENDIF MSWINDOWS} + +function GetTotalPhysicalMemory: Int64; +{$IFDEF UNIX} +var + SystemInf: TSysInfo; +begin + {$IFDEF FPC} + SysInfo(@SystemInf); + {$ELSE ~FPC} + SysInfo(SystemInf); + {$ENDIF ~FPC} + Result := SystemInf.totalram; +end; +{$ENDIF UNIX} +{$IFDEF MSWINDOWS} +var + MemoryStatusEx: TMemoryStatusEx; +begin + ResetMemory(MemoryStatusEx, SizeOf(MemoryStatusEx)); + MemoryStatusEx.dwLength := SizeOf(MemoryStatusEx); + if not GlobalMemoryStatusEx(MemoryStatusEx) then + RaiseLastOSError; + Result := MemoryStatusEx.ullTotalPhys; +end; +{$ENDIF MSWINDOWS} + +function GetFreePhysicalMemory: Int64; +{$IFDEF UNIX} +var + SystemInf: TSysInfo; +begin + {$IFDEF FPC} + SysInfo(@SystemInf); + {$ELSE ~FPC} + SysInfo(SystemInf); + {$ENDIF ~FPC} + Result := SystemInf.freeram; +end; +{$ENDIF UNIX} +{$IFDEF MSWINDOWS} +var + MemoryStatusEx: TMemoryStatusEx; +begin + ResetMemory(MemoryStatusEx, SizeOf(MemoryStatusEx)); + MemoryStatusEx.dwLength := SizeOf(MemoryStatusEx); + if not GlobalMemoryStatusEx(MemoryStatusEx) then + RaiseLastOSError; + Result := MemoryStatusEx.ullAvailPhys; +end; + +function GetTotalPageFileMemory: Int64; +var + MemoryStatusEx: TMemoryStatusEx; +begin + ResetMemory(MemoryStatusEx, SizeOf(MemoryStatusEx)); + MemoryStatusEx.dwLength := SizeOf(MemoryStatusEx); + if not GlobalMemoryStatusEx(MemoryStatusEx) then + RaiseLastOSError; + Result := MemoryStatusEx.ullTotalPageFile; +end; + +function GetFreePageFileMemory: Int64; +var + MemoryStatusEx: TMemoryStatusEx; +begin + ResetMemory(MemoryStatusEx, SizeOf(MemoryStatusEx)); + MemoryStatusEx.dwLength := SizeOf(MemoryStatusEx); + if not GlobalMemoryStatusEx(MemoryStatusEx) then + RaiseLastOSError; + Result := MemoryStatusEx.ullAvailPageFile; +end; + +function GetTotalVirtualMemory: Int64; +var + MemoryStatusEx: TMemoryStatusEx; +begin + ResetMemory(MemoryStatusEx, SizeOf(MemoryStatusEx)); + MemoryStatusEx.dwLength := SizeOf(MemoryStatusEx); + if not GlobalMemoryStatusEx(MemoryStatusEx) then + RaiseLastOSError; + Result := MemoryStatusEx.ullTotalVirtual; +end; + +function GetFreeVirtualMemory: Int64; +var + MemoryStatusEx: TMemoryStatusEx; +begin + ResetMemory(MemoryStatusEx, SizeOf(MemoryStatusEx)); + MemoryStatusEx.dwLength := SizeOf(MemoryStatusEx); + if not GlobalMemoryStatusEx(MemoryStatusEx) then + RaiseLastOSError; + Result := MemoryStatusEx.ullAvailVirtual; +end; + +//=== Keyboard Information =================================================== + +function GetKeybStateHelper(VirtualKey: Cardinal; Mask: Byte): Boolean; +var + Keys: TKeyboardState; +begin + Keys[0] := 0; + Result := GetKeyBoardState(Keys) and (Keys[VirtualKey] and Mask <> 0); +end; + +function GetKeyState(const VirtualKey: Cardinal): Boolean; +begin + Result := GetKeybStateHelper(VirtualKey, $80); +end; + +function GetNumLockKeyState: Boolean; +begin + Result := GetKeybStateHelper(VK_NUMLOCK, $01); +end; + +function GetScrollLockKeyState: Boolean; +begin + Result := GetKeybStateHelper(VK_SCROLL, $01); +end; + +function GetCapsLockKeyState: Boolean; +begin + Result := GetKeybStateHelper(VK_CAPITAL, $01); +end; + +//=== Windows 95/98/ME system resources information ========================== + +{ TODO -oPJH : compare to Win9xFreeSysResources } +var + ResmeterLibHandle: THandle; + MyGetFreeSystemResources: function(ResType: UINT): UINT; stdcall; + +procedure UnloadSystemResourcesMeterLib; +begin + if ResmeterLibHandle <> 0 then + begin + FreeLibrary(ResmeterLibHandle); + ResmeterLibHandle := 0; + @MyGetFreeSystemResources := nil; + end; +end; + +function IsSystemResourcesMeterPresent: Boolean; + + procedure LoadResmeter; + begin + ResmeterLibHandle := SafeLoadLibrary('rsrc32.dll', SEM_FAILCRITICALERRORS); + if ResmeterLibHandle <> 0 then + begin + @MyGetFreeSystemResources := GetProcAddress(ResmeterLibHandle, '_MyGetFreeSystemResources32@4'); + if not Assigned(MyGetFreeSystemResources) then + UnloadSystemResourcesMeterLib; + end; + end; + +begin + if not IsWinNT and (ResmeterLibHandle = 0) then + LoadResmeter; + Result := (ResmeterLibHandle <> 0); +end; + +function GetFreeSystemResources(const ResourceType: TFreeSysResKind): Integer; +const + ParamValues: array [TFreeSysResKind] of UINT = (0, 1, 2); +begin + if IsSystemResourcesMeterPresent then + Result := MyGetFreeSystemResources(ParamValues[ResourceType]) + else + Result := -1; +end; + +function GetFreeSystemResources: TFreeSystemResources; +begin + with Result do + begin + SystemRes := GetFreeSystemResources(rtSystem); + GdiRes := GetFreeSystemResources(rtGdi); + UserRes := GetFreeSystemResources(rtUser); + end; +end; + +function GetBPP: Cardinal; +var + DC: HDC; +begin + DC := GetDC(HWND_DESKTOP); + if DC <> 0 then + begin + Result := GetDeviceCaps(DC, BITSPIXEL) * GetDeviceCaps(DC, PLANES); + ReleaseDC(HWND_DESKTOP, DC); + end + else + Result := 0; +end; + +//=== Installed programs ===================================================== + +function ProgIDExists(const ProgID: string): Boolean; +var + Tmp: TGUID; + WideProgID: WideString; +begin + WideProgID := ProgID; + Result := Succeeded(CLSIDFromProgID(PWideChar(WideProgID), Tmp)); +end; + +function IsWordInstalled: Boolean; +begin + Result := ProgIDExists('Word.Application'); +end; + +function IsExcelInstalled: Boolean; +begin + Result := ProgIDExists('Excel.Application'); +end; + +function IsAccessInstalled: Boolean; +begin + Result := ProgIDExists('Access.Application'); +end; + +function IsPowerPointInstalled: Boolean; +begin + Result := ProgIDExists('PowerPoint.Application'); +end; + +function IsFrontPageInstalled: Boolean; +begin + Result := ProgIDExists('FrontPage.Application'); +end; + +function IsOutlookInstalled: Boolean; +begin + Result := ProgIDExists('Outlook.Application'); +end; + +function IsInternetExplorerInstalled: Boolean; +begin + Result := ProgIDExists('InternetExplorer.Application'); +end; + +function IsMSProjectInstalled: Boolean; +begin + Result := ProgIDExists('MSProject.Application'); +end; + +function IsOpenOfficeInstalled: Boolean; +begin + Result := ProgIDExists('com.sun.star.ServiceManager'); +end; + +function IsLibreOfficeInstalled: Boolean; +begin + Result := ProgIDExists('com.sun.star.ServiceManager.1'); +end; + +//=== Initialization/Finalization ============================================ + +procedure InitSysInfo; +var + SystemInfo: TSystemInfo; + Kernel32FileName: string; + VerFixedFileInfo: TVSFixedFileInfo; +begin + { processor information related initialization } + + ResetMemory(SystemInfo, SizeOf(SystemInfo)); + GetSystemInfo(SystemInfo); + ProcessorCount := SystemInfo.dwNumberOfProcessors; + AllocGranularity := SystemInfo.dwAllocationGranularity; + PageSize := SystemInfo.dwPageSize; + + { Windows version information } + + IsWinNT := Win32Platform = VER_PLATFORM_WIN32_NT; + + Kernel32FileName := GetModulePath(GetModuleHandle(kernel32)); + VerFixedFileInfo.dwFileDateLS := 0; + if (not IsWinNT) and VersionFixedFileInfo(Kernel32FileName, VerFixedFileInfo) then + KernelVersionHi := VerFixedFileInfo.dwProductVersionMS + else + KernelVersionHi := 0; + + case GetWindowsVersion of + wvUnknown: + ; + wvWin95: + IsWin95 := True; + wvWin95OSR2: + IsWin95OSR2 := True; + wvWin98: + IsWin98 := True; + wvWin98SE: + IsWin98SE := True; + wvWinME: + IsWinME := True; + wvWinNT31: + begin + IsWinNT3 := True; + IsWinNT31 := True; + end; + wvWinNT35: + begin + IsWinNT3 := True; + IsWinNT35 := True; + end; + wvWinNT351: + begin + IsWinNT3 := True; + IsWinNT35 := True; + IsWinNT351 := True; + end; + wvWinNT4: + IsWinNT4 := True; + wvWin2000: + IsWin2K := True; + wvWinXP: + IsWinXP := True; + wvWin2003: + IsWin2003 := True; + wvWinXP64: + IsWinXP64 := True; + wvWin2003R2: + IsWin2003R2 := True; + wvWinVista: + IsWinVista := True; + wvWinServer2008: + IsWinServer2008 := True; + wvWin7: + IsWin7 := True; + wvWinServer2008R2: + IsWinServer2008R2 := True; + wvWin8: + IsWin8 := True; + wvWin8RT: + IsWin8RT := True; + wvWinServer2012: + IsWinServer2012 := True; + wvWin81: + IsWin81 := True; + wvWin81RT: + IsWin81RT := True; + wvWinServer2012R2: + IsWinServer2012R2 := True; + end; +end; + +procedure FinalizeSysInfo; +begin + UnloadSystemResourcesMeterLib; +end; + +initialization + InitSysInfo; + {$IFDEF UNITVERSIONING} + RegisterUnitVersion(HInstance, UnitVersioning); + {$ENDIF UNITVERSIONING} + +finalization + {$IFDEF UNITVERSIONING} + UnregisterUnitVersion(HInstance); + {$ENDIF UNITVERSIONING} + FinalizeSysInfo; + +{$ENDIF MSWINDOWS} + +end. diff --git a/source/packages/jcl/JclSysUtils.pas b/source/packages/jcl/JclSysUtils.pas new file mode 100644 index 00000000..b9d438f5 --- /dev/null +++ b/source/packages/jcl/JclSysUtils.pas @@ -0,0 +1,4381 @@ +{**************************************************************************************************} +{ } +{ Project JEDI Code Library (JCL) } +{ } +{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); } +{ you may not use this file except in compliance with the License. You may obtain a copy of the } +{ License at http://www.mozilla.org/MPL/ } +{ } +{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF } +{ ANY KIND, either express or implied. See the License for the specific language governing rights } +{ and limitations under the License. } +{ } +{ The Original Code is JclSysUtils.pas. } +{ } +{ The Initial Developer of the Original Code is Marcel van Brakel. } +{ Portions created by Marcel van Brakel are Copyright (C) Marcel van Brakel. All rights reserved. } +{ } +{ Contributors: } +{ Alexander Radchenko, } +{ Andreas Hausladen (ahuser) } +{ Anthony Steele } +{ Bernhard Berger } +{ Heri Bender } +{ Jean-Fabien Connault (cycocrew) } +{ Jens Fudickar } +{ Jeroen Speldekamp } +{ Marcel van Brakel } +{ Peter Friese } +{ Petr Vones (pvones) } +{ Python } +{ Robert Marquardt (marquardt) } +{ Robert R. Marsh } +{ Robert Rossmair (rrossmair) } +{ Rudy Velthuis } +{ Uwe Schuster (uschuster) } +{ Wayne Sherman } +{ } +{**************************************************************************************************} +{ } +{ Description: Various pointer and class related routines. } +{ } +{**************************************************************************************************} +{ } +{ Last modified: $Date:: $ } +{ Revision: $Rev:: $ } +{ Author: $Author:: $ } +{ } +{**************************************************************************************************} + +unit JclSysUtils; + +{$I jcl.inc} + +interface + +uses + {$IFDEF UNITVERSIONING} + JclUnitVersioning, + {$ENDIF UNITVERSIONING} + {$IFDEF HAS_UNITSCOPE} + {$IFDEF MSWINDOWS} + Winapi.Windows, + {$ENDIF MSWINDOWS} + System.SysUtils, System.Classes, System.TypInfo, System.SyncObjs, + {$ELSE ~HAS_UNITSCOPE} + {$IFDEF MSWINDOWS} + Windows, + {$ENDIF MSWINDOWS} + SysUtils, Classes, TypInfo, SyncObjs, + {$ENDIF ~HAS_UNITSCOPE} + JclBase, JclSynch; + +// memory initialization +// first parameter is "out" to make FPC happy with uninitialized values +procedure ResetMemory(out P; Size: Longint); + +// Pointer manipulation +procedure GetAndFillMem(var P: Pointer; const Size: Integer; const Value: Byte); +procedure FreeMemAndNil(var P: Pointer); +function PCharOrNil(const S: string): PChar; +function PAnsiCharOrNil(const S: AnsiString): PAnsiChar; +{$IFDEF SUPPORTS_WIDESTRING} +function PWideCharOrNil(const W: WideString): PWideChar; +{$ENDIF SUPPORTS_WIDESTRING} + +function SizeOfMem(const APointer: Pointer): Integer; + +function WriteProtectedMemory(BaseAddress, Buffer: Pointer; Size: Cardinal; + out WrittenBytes: Cardinal): Boolean; + +// Guards +type + ISafeGuard = interface + function ReleaseItem: Pointer; + function GetItem: Pointer; + procedure FreeItem; + property Item: Pointer read GetItem; + end; + + IMultiSafeGuard = interface (IInterface) + function AddItem(Item: Pointer): Pointer; + procedure FreeItem(Index: Integer); + function GetCount: Integer; + function GetItem(Index: Integer): Pointer; + function ReleaseItem(Index: Integer): Pointer; + property Count: Integer read GetCount; + property Items[Index: Integer]: Pointer read GetItem; + end; + + TJclSafeGuard = class(TInterfacedObject, ISafeGuard) + private + FItem: Pointer; + public + constructor Create(Mem: Pointer); + destructor Destroy; override; + { ISafeGuard } + function ReleaseItem: Pointer; + function GetItem: Pointer; + procedure FreeItem; virtual; + property Item: Pointer read GetItem; + end; + + TJclObjSafeGuard = class(TJclSafeGuard, ISafeGuard) + public + constructor Create(Obj: TObject); + { ISafeGuard } + procedure FreeItem; override; + end; + + TJclMultiSafeGuard = class(TInterfacedObject, IMultiSafeGuard) + private + FItems: TList; + public + constructor Create; + destructor Destroy; override; + { IMultiSafeGuard } + function AddItem(Item: Pointer): Pointer; + procedure FreeItem(Index: Integer); virtual; + function GetCount: Integer; + function GetItem(Index: Integer): Pointer; + function ReleaseItem(Index: Integer): Pointer; + property Count: Integer read GetCount; + property Items[Index: Integer]: Pointer read GetItem; + end; + + TJclObjMultiSafeGuard = class(TJclMultiSafeGuard, IMultiSafeGuard) + public + { IMultiSafeGuard } + procedure FreeItem(Index: Integer); override; + end; + +function Guard(Mem: Pointer; out SafeGuard: ISafeGuard): Pointer; overload; +function Guard(Obj: TObject; out SafeGuard: ISafeGuard): TObject; overload; + +function Guard(Mem: Pointer; var SafeGuard: IMultiSafeGuard): Pointer; overload; +function Guard(Obj: TObject; var SafeGuard: IMultiSafeGuard): TObject; overload; + +function GuardGetMem(Size: Cardinal; out SafeGuard: ISafeGuard): Pointer; +function GuardAllocMem(Size: Cardinal; out SafeGuard: ISafeGuard): Pointer; + +(* +{$IFDEF SUPPORTS_GENERICS} +type + ISafeGuard = interface + function ReleaseItem: T; + function GetItem: T; + procedure FreeItem; + property Item: T read GetItem; + end; + + TSafeGuard = class(TObject, ISafeGuard) + private + FItem: T; + function ReleaseItem: T; + function GetItem: T; + procedure FreeItem; + + constructor Create(Instance: T); + destructor Destroy; override; + public + class function New(Instance: T): ISafeGuard; static; + end; +{$ENDIF SUPPORTS_GENERICS} +*) + +{ Shared memory between processes functions } + +// Functions for the shared memory owner +type + ESharedMemError = class(EJclError); + +{$IFDEF MSWINDOWS} + +{ SharedGetMem return ERROR_ALREADY_EXISTS if the shared memory is already + allocated, otherwise it returns 0. + Throws ESharedMemError if the Name is invalid. } +function SharedGetMem(var P{: Pointer}; const Name: string; Size: Cardinal; + DesiredAccess: Cardinal = FILE_MAP_ALL_ACCESS): Integer; + +{ SharedAllocMem calls SharedGetMem and then fills the memory with zero if + it was not already allocated. + Throws ESharedMemError if the Name is invalid. } +function SharedAllocMem(const Name: string; Size: Cardinal; + DesiredAccess: Cardinal = FILE_MAP_ALL_ACCESS): Pointer; + +{ SharedFreeMem releases the shared memory if it was the last reference. } +function SharedFreeMem(var P{: Pointer}): Boolean; + +// Functions for the shared memory user + +{ SharedOpenMem returns True if the shared memory was already allocated by + SharedGetMem or SharedAllocMem. Otherwise it returns False. + Throws ESharedMemError if the Name is invalid. } + +function SharedOpenMem(var P{: Pointer}; const Name: string; + DesiredAccess: Cardinal = FILE_MAP_ALL_ACCESS): Boolean; overload; + +{ SharedOpenMem return nil if the shared memory was not already allocated + by SharedGetMem or SharedAllocMem. + Throws ESharedMemError if the Name is invalid. } +function SharedOpenMem(const Name: string; + DesiredAccess: Cardinal = FILE_MAP_ALL_ACCESS): Pointer; overload; + +{ SharedCloseMem releases the shared memory if it was the last reference. } +function SharedCloseMem(var P{: Pointer}): Boolean; + +{$ENDIF MSWINDOWS} + +// Binary search +function SearchSortedList(List: TList; SortFunc: TListSortCompare; Item: Pointer; + Nearest: Boolean = False): Integer; + +type + TUntypedSearchCompare = function(Param: Pointer; ItemIndex: Integer; const Value): Integer; + +function SearchSortedUntyped(Param: Pointer; ItemCount: Integer; SearchFunc: TUntypedSearchCompare; + const Value; Nearest: Boolean = False): Integer; + +// Dynamic array sort and search routines +type + TDynArraySortCompare = function (Item1, Item2: Pointer): Integer; + +procedure SortDynArray(const ArrayPtr: Pointer; ElementSize: Cardinal; SortFunc: TDynArraySortCompare); +// Usage: SortDynArray(Array, SizeOf(Array[0]), SortFunction); +function SearchDynArray(const ArrayPtr: Pointer; ElementSize: Cardinal; SortFunc: TDynArraySortCompare; + ValuePtr: Pointer; Nearest: Boolean = False): SizeInt; +// Usage: SearchDynArray(Array, SizeOf(Array[0]), SortFunction, @SearchedValue); + +{ Various compare functions for basic types } + +function DynArrayCompareByte(Item1, Item2: Pointer): Integer; +function DynArrayCompareShortInt(Item1, Item2: Pointer): Integer; +function DynArrayCompareWord(Item1, Item2: Pointer): Integer; +function DynArrayCompareSmallInt(Item1, Item2: Pointer): Integer; +function DynArrayCompareInteger(Item1, Item2: Pointer): Integer; +function DynArrayCompareCardinal(Item1, Item2: Pointer): Integer; +function DynArrayCompareInt64(Item1, Item2: Pointer): Integer; + +function DynArrayCompareSingle(Item1, Item2: Pointer): Integer; +function DynArrayCompareDouble(Item1, Item2: Pointer): Integer; +function DynArrayCompareExtended(Item1, Item2: Pointer): Integer; +function DynArrayCompareFloat(Item1, Item2: Pointer): Integer; + +function DynArrayCompareAnsiString(Item1, Item2: Pointer): Integer; +function DynArrayCompareAnsiText(Item1, Item2: Pointer): Integer; +function DynArrayCompareWideString(Item1, Item2: Pointer): Integer; +function DynArrayCompareWideText(Item1, Item2: Pointer): Integer; +function DynArrayCompareString(Item1, Item2: Pointer): Integer; +function DynArrayCompareText(Item1, Item2: Pointer): Integer; + +// Object lists +procedure ClearObjectList(List: TList); +procedure FreeObjectList(var List: TList); + +// Reference memory stream +type + TJclReferenceMemoryStream = class(TCustomMemoryStream) + public + constructor Create(const Ptr: Pointer; Size: Longint); + function Write(const Buffer; Count: Longint): Longint; override; + end; + +// AutoPtr +type + IAutoPtr = interface + { Returns the object as pointer, so it is easier to assign it to a variable } + function AsPointer: Pointer; + { Returns the AutoPtr handled object } + function AsObject: TObject; + { Releases the object from the AutoPtr. The AutoPtr looses the control over + the object. } + function ReleaseObject: TObject; + end; + + TJclAutoPtr = class(TInterfacedObject, IAutoPtr) + private + FValue: TObject; + public + constructor Create(AValue: TObject); + destructor Destroy; override; + { IAutoPtr } + function AsPointer: Pointer; + function AsObject: TObject; + function ReleaseObject: TObject; + end; + +function CreateAutoPtr(Value: TObject): IAutoPtr; + +// Replacement for the C ternary conditional operator ? : +function Iff(const Condition: Boolean; const TruePart, FalsePart: string): string; overload; +function Iff(const Condition: Boolean; const TruePart, FalsePart: Char): Char; overload; +function Iff(const Condition: Boolean; const TruePart, FalsePart: Byte): Byte; overload; +function Iff(const Condition: Boolean; const TruePart, FalsePart: Integer): Integer; overload; +function Iff(const Condition: Boolean; const TruePart, FalsePart: Cardinal): Cardinal; overload; +function Iff(const Condition: Boolean; const TruePart, FalsePart: Float): Float; overload; +function Iff(const Condition: Boolean; const TruePart, FalsePart: Boolean): Boolean; overload; +function Iff(const Condition: Boolean; const TruePart, FalsePart: Pointer): Pointer; overload; +function Iff(const Condition: Boolean; const TruePart, FalsePart: Int64): Int64; overload; +{$IFDEF SUPPORTS_VARIANT} +function Iff(const Condition: Boolean; const TruePart, FalsePart: Variant): Variant; overload; +{$ENDIF SUPPORTS_VARIANT} + +// Classes information and manipulation +type + EJclVMTError = class(EJclError); + +// Virtual Methods +{$IFNDEF FPC} +function GetVirtualMethodCount(AClass: TClass): Integer; +{$ENDIF ~FPC} +function GetVirtualMethod(AClass: TClass; const Index: Integer): Pointer; +procedure SetVirtualMethod(AClass: TClass; const Index: Integer; const Method: Pointer); + +// Dynamic Methods +type + TDynamicIndexList = array [0..MaxInt div 16] of Word; + PDynamicIndexList = ^TDynamicIndexList; + TDynamicAddressList = array [0..MaxInt div 16] of Pointer; + PDynamicAddressList = ^TDynamicAddressList; + +function GetDynamicMethodCount(AClass: TClass): Integer; +function GetDynamicIndexList(AClass: TClass): PDynamicIndexList; +function GetDynamicAddressList(AClass: TClass): PDynamicAddressList; +function HasDynamicMethod(AClass: TClass; Index: Integer): Boolean; +{$IFNDEF FPC} +function GetDynamicMethod(AClass: TClass; Index: Integer): Pointer; +{$ENDIF ~FPC} + +{ init table methods } + +function GetInitTable(AClass: TClass): PTypeInfo; + +{ field table methods } + +type + PFieldEntry = ^TFieldEntry; + TFieldEntry = packed record + OffSet: Integer; + IDX: Word; + Name: ShortString; + end; + + PFieldClassTable = ^TFieldClassTable; + TFieldClassTable = packed record + Count: Smallint; + Classes: array [0..8191] of ^TPersistentClass; + end; + + PFieldTable = ^TFieldTable; + TFieldTable = packed record + EntryCount: Word; + FieldClassTable: PFieldClassTable; + FirstEntry: TFieldEntry; + {Entries: array [1..65534] of TFieldEntry;} + end; + +function GetFieldTable(AClass: TClass): PFieldTable; + +{ method table } + +type + PMethodEntry = ^TMethodEntry; + TMethodEntry = packed record + EntrySize: Word; + Address: Pointer; + Name: ShortString; + end; + + PMethodTable = ^TMethodTable; + TMethodTable = packed record + Count: Word; + FirstEntry: TMethodEntry; + {Entries: array [1..65534] of TMethodEntry;} + end; + +function GetMethodTable(AClass: TClass): PMethodTable; +function GetMethodEntry(MethodTable: PMethodTable; Index: Integer): PMethodEntry; + +// Class Parent +procedure SetClassParent(AClass: TClass; NewClassParent: TClass); +function GetClassParent(AClass: TClass): TClass; + +{$IFNDEF FPC} +function IsClass(Address: Pointer): Boolean; +function IsObject(Address: Pointer): Boolean; +{$ENDIF ~FPC} + +function InheritsFromByName(AClass: TClass; const AClassName: string): Boolean; + +// Interface information +function GetImplementorOfInterface(const I: IInterface): TObject; + +// interfaced persistent +type + TJclInterfacedPersistent = class(TInterfacedPersistent, IInterface) + protected + FOwnerInterface: IInterface; + FRefCount: Integer; + public + procedure AfterConstruction; override; + { IInterface } + // function QueryInterface(const IID: TGUID; out Obj): HRESULT; virtual; stdcall; + function _AddRef: Integer; stdcall; + function _Release: Integer; stdcall; + end; + +// Numeric formatting routines +type + TDigitCount = 0..255; + TDigitValue = -1..35; // invalid, '0'..'9', 'A'..'Z' + TNumericSystemBase = 2..Succ(High(TDigitValue)); + +{$IFNDEF WINSCP} + + TJclNumericFormat = class(TObject) + private + FWantedPrecision: TDigitCount; + FPrecision: TDigitCount; + FNumberOfFractionalDigits: TDigitCount; + FExpDivision: Integer; + FDigitBlockSize: TDigitCount; + FWidth: TDigitCount; + FSignChars: array [Boolean] of Char; + FBase: TNumericSystemBase; + FFractionalPartSeparator: Char; + FDigitBlockSeparator: Char; + FShowPositiveSign: Boolean; + FPaddingChar: Char; + FMultiplier: string; + function GetDigitValue(Digit: Char): Integer; + function GetNegativeSign: Char; + function GetPositiveSign: Char; + procedure InvalidDigit(Digit: Char); + procedure SetPrecision(const Value: TDigitCount); + procedure SetBase(const Value: TNumericSystemBase); + procedure SetNegativeSign(const Value: Char); + procedure SetPositiveSign(const Value: Char); + procedure SetExpDivision(const Value: Integer); + protected + function IntToStr(const Value: Int64; out FirstDigitPos: Integer): string; overload; + function ShowSign(const Value: Float): Boolean; overload; + function ShowSign(const Value: Int64): Boolean; overload; + function SignChar(const Value: Float): Char; overload; + function SignChar(const Value: Int64): Char; overload; + property WantedPrecision: TDigitCount read FWantedPrecision; + public + constructor Create; + function Digit(DigitValue: TDigitValue): Char; + function DigitValue(Digit: Char): TDigitValue; + function IsDigit(Value: Char): Boolean; + function Sign(Value: Char): Integer; + procedure GetMantissaExp(const Value: Float; out Mantissa: string; out Exponent: Integer); + function FloatToHTML(const Value: Float): string; + function IntToStr(const Value: Int64): string; overload; + function FloatToStr(const Value: Float): string; overload; + function StrToInt(const Value: string): Int64; + property Base: TNumericSystemBase read FBase write SetBase; + property Precision: TDigitCount read FPrecision write SetPrecision; + property NumberOfFractionalDigits: TDigitCount read FNumberOfFractionalDigits write FNumberOfFractionalDigits; + property ExponentDivision: Integer read FExpDivision write SetExpDivision; + property DigitBlockSize: TDigitCount read FDigitBlockSize write FDigitBlockSize; + property DigitBlockSeparator: Char read FDigitBlockSeparator write FDigitBlockSeparator; + property FractionalPartSeparator: Char read FFractionalPartSeparator write FFractionalPartSeparator; + property Multiplier: string read FMultiplier write FMultiplier; + property PaddingChar: Char read FPaddingChar write FPaddingChar; + property ShowPositiveSign: Boolean read FShowPositiveSign write FShowPositiveSign; + property Width: TDigitCount read FWidth write FWidth; + property NegativeSign: Char read GetNegativeSign write SetNegativeSign; + property PositiveSign: Char read GetPositiveSign write SetPositiveSign; + end; + +{$ENDIF ~WINSCP} + +function IntToStrZeroPad(Value, Count: Integer): string; + +// Child processes +type + // e.g. TStrings.Append + TTextHandler = procedure(const Text: string) of object; + TJclProcessPriority = (ppIdle, ppNormal, ppHigh, ppRealTime, ppBelowNormal, ppAboveNormal); + +const + ABORT_EXIT_CODE = {$IFDEF MSWINDOWS} ERROR_CANCELLED {$ELSE} 1223 {$ENDIF}; + +function Execute(const CommandLine: string; OutputLineCallback: TTextHandler; RawOutput: Boolean = False; + AbortPtr: PBoolean = nil; ProcessPriority: TJclProcessPriority = ppNormal): Cardinal; overload; +function Execute(const CommandLine: string; AbortEvent: TJclEvent; + OutputLineCallback: TTextHandler; RawOutput: Boolean = False; ProcessPriority: TJclProcessPriority = ppNormal): Cardinal; overload; +function Execute(const CommandLine: string; var Output: string; RawOutput: Boolean = False; + AbortPtr: PBoolean = nil; ProcessPriority: TJclProcessPriority = ppNormal): Cardinal; overload; +function Execute(const CommandLine: string; AbortEvent: TJclEvent; + var Output: string; RawOutput: Boolean = False; ProcessPriority: TJclProcessPriority = ppNormal): Cardinal; overload; + +function Execute(const CommandLine: string; OutputLineCallback, ErrorLineCallback: TTextHandler; + RawOutput: Boolean = False; RawError: Boolean = False; AbortPtr: PBoolean = nil; ProcessPriority: TJclProcessPriority = ppNormal): Cardinal; overload; +function Execute(const CommandLine: string; AbortEvent: TJclEvent; + OutputLineCallback, ErrorLineCallback: TTextHandler; RawOutput: Boolean = False; RawError: Boolean = False; ProcessPriority: TJclProcessPriority = ppNormal): Cardinal; overload; +function Execute(const CommandLine: string; var Output, Error: string; + RawOutput: Boolean = False; RawError: Boolean = False; AbortPtr: PBoolean = nil; ProcessPriority: TJclProcessPriority = ppNormal): Cardinal; overload; +function Execute(const CommandLine: string; AbortEvent: TJclEvent; + var Output, Error: string; RawOutput: Boolean = False; RawError: Boolean = False; ProcessPriority: TJclProcessPriority = ppNormal): Cardinal; overload; + +type +{$HPPEMIT 'namespace Jclsysutils'} +{$HPPEMIT '{'} +{$HPPEMIT ' // For some reason, the generator puts this interface after its first'} +{$HPPEMIT ' // usage, resulting in an unusable header file. We fix this by forward'} +{$HPPEMIT ' // declaring the interface.'} +{$HPPEMIT ' __interface IJclCommandLineTool;'} +(*$HPPEMIT '}'*) + + IJclCommandLineTool = interface + ['{A0034B09-A074-D811-847D-0030849E4592}'] + function GetExeName: string; + function GetOptions: TStrings; + function GetOutput: string; + function GetOutputCallback: TTextHandler; + procedure AddPathOption(const Option, Path: string); + function Execute(const CommandLine: string): Boolean; + procedure SetOutputCallback(const CallbackMethod: TTextHandler); + property ExeName: string read GetExeName; + property Options: TStrings read GetOptions; + property OutputCallback: TTextHandler read GetOutputCallback write SetOutputCallback; + property Output: string read GetOutput; + end; + + EJclCommandLineToolError = class(EJclError); + + TJclCommandLineTool = class(TInterfacedObject, IJclCommandLineTool) + private + FExeName: string; + FOptions: TStringList; + FOutput: string; + FOutputCallback: TTextHandler; + public + constructor Create(const AExeName: string); + destructor Destroy; override; + { IJclCommandLineTool } + function GetExeName: string; + function GetOptions: TStrings; + function GetOutput: string; + function GetOutputCallback: TTextHandler; + procedure AddPathOption(const Option, Path: string); + function Execute(const CommandLine: string): Boolean; + procedure SetOutputCallback(const CallbackMethod: TTextHandler); + property ExeName: string read GetExeName; + property Options: TStrings read GetOptions; + property OutputCallback: TTextHandler read GetOutputCallback write SetOutputCallback; + property Output: string read GetOutput; + end; + +{$IFNDEF WINSCP} +// Console Utilities +function ReadKey: Char; +{$ENDIF ~WINSCP} + +// Loading of modules (DLLs) +type +{$IFDEF MSWINDOWS} + TModuleHandle = HINST; +{$ENDIF MSWINDOWS} +{$IFDEF LINUX} + TModuleHandle = Pointer; +{$ENDIF LINUX} + +const + INVALID_MODULEHANDLE_VALUE = TModuleHandle(0); + +function LoadModule(var Module: TModuleHandle; FileName: string): Boolean; +function LoadModuleEx(var Module: TModuleHandle; FileName: string; Flags: Cardinal): Boolean; +procedure UnloadModule(var Module: TModuleHandle); +function GetModuleSymbol(Module: TModuleHandle; SymbolName: string): Pointer; +function GetModuleSymbolEx(Module: TModuleHandle; SymbolName: string; var Accu: Boolean): Pointer; +function ReadModuleData(Module: TModuleHandle; SymbolName: string; var Buffer; Size: Cardinal): Boolean; +function WriteModuleData(Module: TModuleHandle; SymbolName: string; var Buffer; Size: Cardinal): Boolean; + +// Conversion Utilities +type + EJclConversionError = class(EJclError); + +function StrToBoolean(const S: string): Boolean; +function BooleanToStr(B: Boolean): string; +function IntToBool(I: Integer): Boolean; +function BoolToInt(B: Boolean): Integer; + +function TryStrToUInt(const Value: string; out Res: Cardinal): Boolean; +function StrToUIntDef(const Value: string; const Default: Cardinal): Cardinal; +function StrToUInt(const Value: string): Cardinal; + +{$IFNDEF WINSCP} +const + {$IFDEF MSWINDOWS} + ListSeparator = ';'; + {$ENDIF MSWINDOWS} + {$IFDEF LINUX} + ListSeparator = ':'; + {$ENDIF LINUX} +{$ENDIF} + +// functions to handle items in a separated list of items +// add items at the end +procedure ListAddItems(var List: string; const Separator, Items: string); +// add items at the end if they are not present +procedure ListIncludeItems(var List: string; const Separator, Items: string); +// delete multiple items +procedure ListRemoveItems(var List: string; const Separator, Items: string); +// delete one item +procedure ListDelItem(var List: string; const Separator: string; + const Index: Integer); +// return the number of item +function ListItemCount(const List, Separator: string): Integer; +// return the Nth item +function ListGetItem(const List, Separator: string; + const Index: Integer): string; +// set the Nth item +procedure ListSetItem(var List: string; const Separator: string; + const Index: Integer; const Value: string); +// return the index of an item +function ListItemIndex(const List, Separator, Item: string): Integer; + +// RTL package information +function SystemTObjectInstance: TJclAddr; +function IsCompiledWithPackages: Boolean; + +// GUID +function JclGUIDToString(const GUID: TGUID): string; +function JclStringToGUID(const S: string): TGUID; +function GUIDEquals(const GUID1, GUID2: TGUID): Boolean; + +// thread safe support + +type + TJclIntfCriticalSection = class(TInterfacedObject, IInterface) + private + FCriticalSection: TCriticalSection; + public + constructor Create; + destructor Destroy; override; + { IInterface } + // function QueryInterface(const IID: TGUID; out Obj): HRESULT; stdcall; + function _AddRef: Integer; stdcall; + function _Release: Integer; stdcall; + end; + +type + {$IFDEF BORLAND} + {$IFDEF COMPILER16_UP} + TFileHandle = THandle; + {$ELSE ~COMPILER16_UP} + TFileHandle = Integer; + {$ENDIF ~COMPILER16_UP} + {$ELSE ~BORLAND} + TFileHandle = THandle; + {$ENDIF ~BORLAND} + +{$IFNDEF WINSCP} + TJclSimpleLog = class (TObject) + private + FDateTimeFormatStr: String; + FLogFileHandle: TFileHandle; + FLogFileName: string; + FLoggingActive: Boolean; + FLogWasEmpty: Boolean; + function GetLogOpen: Boolean; + protected + function CreateDefaultFileName: string; + public + constructor Create(const ALogFileName: string = ''); + destructor Destroy; override; + procedure ClearLog; + procedure CloseLog; + procedure OpenLog; + procedure Write(const Text: string; Indent: Integer = 0; KeepOpen: Boolean = true); overload; + procedure Write(Strings: TStrings; Indent: Integer = 0; KeepOpen: Boolean = true); overload; + //Writes a line to the log file. The current timestamp is written before the line. + procedure TimeWrite(const Text: string; Indent: Integer = 0; KeepOpen: Boolean = true); overload; + procedure TimeWrite(Strings: TStrings; Indent: Integer = 0; KeepOpen: Boolean = true); overload; + procedure WriteStamp(SeparatorLen: Integer = 0; KeepOpen: Boolean = true); + // DateTimeFormatStr property assumes the values described in "FormatDateTime Function" in Delphi Help + property DateTimeFormatStr: String read FDateTimeFormatStr write FDateTimeFormatStr; + property LogFileName: string read FLogFileName; + //1 Property to activate / deactivate the logging + property LoggingActive: Boolean read FLoggingActive write FLoggingActive default True; + property LogOpen: Boolean read GetLogOpen; + end; +{$ENDIF ~WINSCP} + +type + TJclFormatSettings = class + private + function GetCurrencyDecimals: Byte; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function GetCurrencyFormat: Byte; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function GetCurrencyString: string; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function GetDateSeparator: Char; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function GetDayNamesHighIndex: Integer; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function GetDayNamesLowIndex: Integer; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function GetDecimalSeparator: Char; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function GetListSeparator: Char; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function GetLongDateFormat: string; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function GetLongDayNames(AIndex: Integer): string; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function GetLongMonthNames(AIndex: Integer): string; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function GetLongTimeFormat: string; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function GetMonthNamesHighIndex: Integer; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function GetMonthNamesLowIndex: Integer; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function GetNegCurrFormat: Byte; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function GetShortDateFormat: string; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function GetShortDayNames(AIndex: Integer): string; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function GetShortMonthNames(AIndex: Integer): string; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function GetShortTimeFormat: string; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function GetThousandSeparator: Char; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function GetTimeAMString: string; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function GetTimePMString: string; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function GetTimeSeparator: Char; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + function GetTwoDigitYearCenturyWindow: Word; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + procedure SetCurrencyDecimals(AValue: Byte); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + procedure SetCurrencyFormat(const AValue: Byte); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + procedure SetCurrencyString(AValue: string); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + procedure SetDateSeparator(const AValue: Char); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + procedure SetDecimalSeparator(AValue: Char); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + procedure SetListSeparator(const AValue: Char); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + procedure SetLongDateFormat(const AValue: string); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + procedure SetLongTimeFormat(const AValue: string); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + procedure SetNegCurrFormat(const AValue: Byte); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + procedure SetShortDateFormat(AValue: string); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + procedure SetShortTimeFormat(const AValue: string); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + procedure SetThousandSeparator(AValue: Char); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + procedure SetTimeAMString(const AValue: string); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + procedure SetTimePMString(const AValue: string); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + procedure SetTimeSeparator(const AValue: Char); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + procedure SetTwoDigitYearCenturyWindow(const AValue: Word); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} + public + property CurrencyDecimals: Byte read GetCurrencyDecimals write SetCurrencyDecimals; + property CurrencyFormat: Byte read GetCurrencyFormat write SetCurrencyFormat; + property CurrencyString: string read GetCurrencyString write SetCurrencyString; + property DateSeparator: Char read GetDateSeparator write SetDateSeparator; + property DayNamesHighIndex: Integer read GetDayNamesHighIndex; + property DayNamesLowIndex: Integer read GetDayNamesLowIndex; + property DecimalSeparator: Char read GetDecimalSeparator write SetDecimalSeparator; + property ListSeparator: Char read GetListSeparator write SetListSeparator; + property LongDateFormat: string read GetLongDateFormat write SetLongDateFormat; + property LongDayNames[AIndex: Integer]: string read GetLongDayNames; + property LongMonthNames[AIndex: Integer]: string read GetLongMonthNames; + property LongTimeFormat: string read GetLongTimeFormat write SetLongTimeFormat; + property MonthNamesHighIndex: Integer read GetMonthNamesHighIndex; + property MonthNamesLowIndex: Integer read GetMonthNamesLowIndex; + property NegCurrFormat: Byte read GetNegCurrFormat write SetNegCurrFormat; + property ShortDateFormat: string read GetShortDateFormat write SetShortDateFormat; + property ShortDayNames[AIndex: Integer]: string read GetShortDayNames; + property ShortMonthNames[AIndex: Integer]: string read GetShortMonthNames; + property ShortTimeFormat: string read GetShortTimeFormat write SetShortTimeFormat; + property ThousandSeparator: Char read GetThousandSeparator write SetThousandSeparator; + property TimeAMString: string read GetTimeAMString write SetTimeAMString; + property TimePMString: string read GetTimePMString write SetTimePMString; + property TimeSeparator: Char read GetTimeSeparator write SetTimeSeparator; + property TwoDigitYearCenturyWindow: Word read GetTwoDigitYearCenturyWindow write SetTwoDigitYearCenturyWindow; + end; + +var + JclFormatSettings: TJclFormatSettings; + +{$IFNDEF WINSCP} +// Procedure to initialize the SimpleLog Variable +procedure InitSimpleLog(const ALogFileName: string = ''; AOpenLog: Boolean = true); + +// Global Variable to make it easier for an application wide log handling. +// Must be initialized with InitSimpleLog before using +var + SimpleLog : TJclSimpleLog; +{$ENDIF ~WINSCP} + + +// Validates if then variant value is null or is empty +function VarIsNullEmpty(const V: Variant): Boolean; +// Validates if then variant value is null or is empty or VarToStr is a blank string +function VarIsNullEmptyBlank(const V: Variant): Boolean; + + +{$IFDEF UNITVERSIONING} +const + UnitVersioning: TUnitVersionInfo = ( + RCSfile: '$URL$'; + Revision: '$Revision$'; + Date: '$Date$'; + LogPath: 'JCL\source\common'; + Extra: ''; + Data: nil + ); +{$ENDIF UNITVERSIONING} + +implementation + +uses + {$IFDEF HAS_UNIT_LIBC} + Libc, + {$ENDIF HAS_UNIT_LIBC} + {$IFDEF MSWINDOWS} + {$IFNDEF WINSCP} + JclConsole, + {$ENDIF ~WINSCP} + {$ENDIF MSWINDOWS} + {$IFDEF HAS_UNITSCOPE} + System.Variants, System.Types, System.Contnrs, + {$IFDEF HAS_UNIT_ANSISTRINGS} + System.AnsiStrings, + {$ENDIF HAS_UNIT_ANSISTRINGS} + {$ELSE ~HAS_UNITSCOPE} + Variants, Types, Contnrs, + {$IFDEF HAS_UNIT_ANSISTRINGS} + AnsiStrings, + {$ENDIF HAS_UNIT_ANSISTRINGS} + {$ENDIF ~HAS_UNITSCOPE} + JclFileUtils, {$IFNDEF WINSCP}JclMath,{$ENDIF ~WINSCP} JclResources, JclStrings, + {$IFNDEF WINSCP}JclStringConversions,{$ENDIF ~WINSCP} JclSysInfo, JclWin32; + +// memory initialization +procedure ResetMemory(out P; Size: Longint); +begin + if Size > 0 then + begin + Byte(P) := 0; + FillChar(P, Size, 0); + end; +end; + +// Pointer manipulation +procedure GetAndFillMem(var P: Pointer; const Size: Integer; const Value: Byte); +begin + GetMem(P, Size); + FillChar(P^, Size, Value); +end; + +procedure FreeMemAndNil(var P: Pointer); +var + Q: Pointer; +begin + Q := P; + P := nil; + FreeMem(Q); +end; + +function PCharOrNil(const S: string): PChar; +begin + Result := Pointer(S); +end; + +function PAnsiCharOrNil(const S: AnsiString): PAnsiChar; +begin + Result := Pointer(S); +end; + +{$IFDEF SUPPORTS_WIDESTRING} + +function PWideCharOrNil(const W: WideString): PWideChar; +begin + Result := Pointer(W); +end; + +{$ENDIF SUPPORTS_WIDESTRING} + +{$IFDEF MSWINDOWS} +type + PUsed = ^TUsed; + TUsed = record + SizeFlags: Integer; + end; + +const + cThisUsedFlag = 2; + cPrevFreeFlag = 1; + cFillerFlag = Integer($80000000); + cFlags = cThisUsedFlag or cPrevFreeFlag or cFillerFlag; + +function SizeOfMem(const APointer: Pointer): Integer; +var + U: PUsed; +begin + if IsMemoryManagerSet then + Result:= -1 + else + begin + Result := 0; + if APointer <> nil then + begin + U := APointer; + U := PUsed(TJclAddr(U) - SizeOf(TUsed)); + if (U.SizeFlags and cThisUsedFlag) <> 0 then + Result := (U.SizeFlags) and (not cFlags - SizeOf(TUsed)); + end; + end; +end; +{$ENDIF MSWINDOWS} + +{$IFDEF LINUX} +function SizeOfMem(const APointer: Pointer): Integer; +begin + if IsMemoryManagerSet then + Result:= -1 + else + begin + if APointer <> nil then + Result := malloc_usable_size(APointer) + else + Result := 0; + end; +end; +{$ENDIF LINUX} + +function WriteProtectedMemory(BaseAddress, Buffer: Pointer; + Size: Cardinal; out WrittenBytes: Cardinal): Boolean; +{$IFDEF MSWINDOWS} +var + OldProtect, Dummy: Cardinal; +begin + WrittenBytes := 0; + if Size > 0 then + begin + // (outchy) VirtualProtect for DEP issues + OldProtect := 0; + Result := VirtualProtect(BaseAddress, Size, PAGE_EXECUTE_READWRITE, OldProtect); + if Result then + try + Move(Buffer^, BaseAddress^, Size); + WrittenBytes := Size; + if OldProtect in [PAGE_EXECUTE, PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE, PAGE_EXECUTE_WRITECOPY] then + FlushInstructionCache(GetCurrentProcess, BaseAddress, Size); + finally + Dummy := 0; + VirtualProtect(BaseAddress, Size, OldProtect, Dummy); + end; + end; + Result := WrittenBytes = Size; +end; +{$ENDIF MSWINDOWS} +{$IFDEF LINUX} +{ TODO -cHelp : Author: Andreas Hausladen } +{ TODO : Works so far, but causes app to hang on termination } +var + AlignedAddress: Cardinal; + PageSize, ProtectSize: Cardinal; +begin + Result := False; + WrittenBytes := 0; + + PageSize := Cardinal(getpagesize); + AlignedAddress := Cardinal(BaseAddress) and not (PageSize - 1); // start memory page + // get the number of needed memory pages + ProtectSize := PageSize; + while Cardinal(BaseAddress) + Size > AlignedAddress + ProtectSize do + Inc(ProtectSize, PageSize); + + if mprotect(Pointer(AlignedAddress), ProtectSize, + PROT_READ or PROT_WRITE or PROT_EXEC) = 0 then // obtain write access + begin + try + Move(Buffer^, BaseAddress^, Size); // replace code + Result := True; + WrittenBytes := Size; + finally + // Is there any function that returns the current page protection? +// mprotect(p, ProtectSize, PROT_READ or PROT_EXEC); // lock memory page + end; + end; +end; + +procedure FlushInstructionCache; +{ TODO -cHelp : Author: Andreas Hausladen } +begin + // do nothing +end; + +{$ENDIF LINUX} + +// Guards + +//=== { TJclSafeGuard } ====================================================== + +constructor TJclSafeGuard.Create(Mem: Pointer); +begin + inherited Create; + FItem := Mem; +end; + +destructor TJclSafeGuard.Destroy; +begin + FreeItem; + inherited Destroy; +end; + +function TJclSafeGuard.ReleaseItem: Pointer; +begin + Result := FItem; + FItem := nil; +end; + +function TJclSafeGuard.GetItem: Pointer; +begin + Result := FItem; +end; + +procedure TJclSafeGuard.FreeItem; +begin + if FItem <> nil then + FreeMem(FItem); + FItem := nil; +end; + +//=== { TJclObjSafeGuard } =================================================== + +constructor TJclObjSafeGuard.Create(Obj: TObject); +begin + inherited Create(Pointer(Obj)); +end; + +procedure TJclObjSafeGuard.FreeItem; +begin + if FItem <> nil then + begin + TObject(FItem).Free; + FItem := nil; + end; +end; + +//=== { TJclMultiSafeGuard } ================================================= + +constructor TJclMultiSafeGuard.Create; +begin + inherited Create; + FItems := TList.Create; +end; + +destructor TJclMultiSafeGuard.Destroy; +var + I: Integer; +begin + for I := FItems.Count - 1 downto 0 do + FreeItem(I); + FItems.Free; + inherited Destroy; +end; + +function TJclMultiSafeGuard.AddItem(Item: Pointer): Pointer; +begin + Result := Item; + FItems.Add(Item); +end; + +procedure TJclMultiSafeGuard.FreeItem(Index: Integer); +begin + FreeMem(FItems[Index]); + FItems.Delete(Index); +end; + +function TJclMultiSafeGuard.GetCount: Integer; +begin + Result := FItems.Count; +end; + +function TJclMultiSafeGuard.GetItem(Index: Integer): Pointer; +begin + Result := FItems[Index]; +end; + +function TJclMultiSafeGuard.ReleaseItem(Index: Integer): Pointer; +begin + Result := FItems[Index]; + FItems.Delete(Index); +end; + +function Guard(Mem: Pointer; var SafeGuard: IMultiSafeGuard): Pointer; overload; +begin + if SafeGuard = nil then + SafeGuard := TJclMultiSafeGuard.Create; + Result := SafeGuard.AddItem(Mem); +end; + +//=== { TJclObjMultiSafeGuard } ============================================== + +procedure TJclObjMultiSafeGuard.FreeItem(Index: Integer); +begin + TObject(FItems[Index]).Free; + FItems.Delete(Index); +end; + +function Guard(Obj: TObject; var SafeGuard: IMultiSafeGuard): TObject; overload; +begin + if SafeGuard = nil then + SafeGuard := TJclObjMultiSafeGuard.Create; + Result := SafeGuard.AddItem(Obj); +end; + +function Guard(Mem: Pointer; out SafeGuard: ISafeGuard): Pointer; overload; +begin + Result := Mem; + SafeGuard := TJclSafeGuard.Create(Mem); +end; + +function Guard(Obj: TObject; out SafeGuard: ISafeGuard): TObject; overload; +begin + Result := Obj; + SafeGuard := TJclObjSafeGuard.Create(Obj); +end; + +function GuardGetMem(Size: Cardinal; out SafeGuard: ISafeGuard): Pointer; +begin + GetMem(Result, Size); + Guard(Result, SafeGuard); +end; + +function GuardAllocMem(Size: Cardinal; out SafeGuard: ISafeGuard): Pointer; +begin + Result := AllocMem(Size); + Guard(Result, SafeGuard); +end; + +{$IFDEF SUPPORTS_GENERICS_} +//=== { TSafeGuard } ====================================================== + +constructor TSafeGuard.Create(Instance: T); +begin + inherited Create; + FItem := Instance; +end; + +destructor TSafeGuard.Destroy; +begin + FreeItem; + inherited Destroy; +end; + +function TSafeGuard.ReleaseItem: T; +begin + Result := FItem; + FItem := nil; +end; + +function TSafeGuard.GetItem: T; +begin + Result := FItem; +end; + +procedure TSafeGuard.FreeItem; +begin + if FItem <> nil then + FItem.Free; + FItem := nil; +end; +{$ENDIF SUPPORTS_GENERICS_} + +//=== Shared memory functions ================================================ + +type + PMMFHandleListItem = ^TMMFHandleListItem; + TMMFHandleListItem = record + Next: PMMFHandleListItem; + Memory: Pointer; + Handle: THandle; + Name: string; + References: Integer; + end; + + PMMFHandleList = PMMFHandleListItem; + +var + MMFHandleList: PMMFHandleList = nil; + {$IFDEF THREADSAFE} + MMFFinalized: Boolean = False; + GlobalMMFHandleListCS: TJclIntfCriticalSection = nil; + {$ENDIF THREADSAFE} + +{$IFDEF THREADSAFE} +function GetAccessToHandleList: IInterface; +var + OldValue: Pointer; + CS: TJclIntfCriticalSection; +begin + if not Assigned(GlobalMMFHandleListCS) and not MMFFinalized then + begin + CS := TJclIntfCriticalSection.Create; + {$IFDEF RTL200_UP} // Delphi 2009+ + OldValue := InterlockedCompareExchangePointer(Pointer(GlobalMMFHandleListCS), Pointer(CS), nil); + {$ELSE} + {$IFDEF RTL160_UP} // Delphi 7-2007 + OldValue := Pointer(InterlockedCompareExchange(Longint(GlobalMMFHandleListCS), Longint(CS), 0)); + {$ELSE} // Delphi 5, 6 + OldValue := InterlockedCompareExchange(Pointer(GlobalMMFHandleListCS), Pointer(CS), nil); + {$ENDIF RTL180_UP} + {$ENDIF RTL185_UP} + if OldValue <> nil then + CS.Free; + end; + Result := GlobalMMFHandleListCS; +end; +{$ENDIF THREADSAFE} + +{$IFDEF MSWINDOWS} + +function SharedGetMem(var P{: Pointer}; const Name: string; Size: Cardinal; + DesiredAccess: Cardinal = FILE_MAP_ALL_ACCESS): Integer; +var + FileMappingHandle: THandle; + Iterate, NewListItem: PMMFHandleListItem; + Protect: Cardinal; + {$IFDEF THREADSAFE} + HandleListAccess: IInterface; + {$ENDIF THREADSAFE} +begin + Result := 0; + Pointer(P) := nil; + + if not JclCheckWinVersion(5, 0) and ((Name = '') or (Pos('\', Name) > 0)) then + raise ESharedMemError.CreateResFmt(@RsInvalidMMFName, [Name]); + + {$IFDEF THREADSAFE} + HandleListAccess := GetAccessToHandleList; + {$ENDIF THREADSAFE} + + // search for same name + Iterate := MMFHandleList; + while Iterate <> nil do + begin + if CompareText(Iterate^.Name, Name) = 0 then + begin + Inc(Iterate^.References); + Pointer(P) := Iterate^.Memory; + Result := ERROR_ALREADY_EXISTS; + Exit; + end; + Iterate := Iterate^.Next; + end; + + // open file mapping + FileMappingHandle := OpenFileMapping(DesiredAccess, False, PChar(Name)); + if FileMappingHandle = 0 then + begin + if Size = 0 then + raise ESharedMemError.CreateResFmt(@RsInvalidMMFEmpty, [Name]); + + Protect := PAGE_READWRITE; + if (Win32Platform = VER_PLATFORM_WIN32_WINDOWS) and (DesiredAccess = FILE_MAP_COPY) then + Protect := PAGE_WRITECOPY; + + FileMappingHandle := CreateFileMapping(INVALID_HANDLE_VALUE, nil, Protect, + 0, Size, PChar(Name)); + end + else + Result := ERROR_ALREADY_EXISTS; + + if GetLastError = ERROR_ALREADY_EXISTS then + Result := ERROR_ALREADY_EXISTS + else + begin + if FileMappingHandle = 0 then + RaiseLastOSError; + end; + + // map view + Pointer(P) := MapViewOfFile(FileMappingHandle, DesiredAccess, 0, 0, Size); + if Pointer(P) = nil then + begin + try + RaiseLastOSError; + except + CloseHandle(FileMappingHandle); + raise; + end; + end; + + // add list item to MMFHandleList + New(NewListItem); + NewListItem^.Name := Name; + NewListItem^.Handle := FileMappingHandle; + NewListItem^.Memory := Pointer(P); + NewListItem^.References := 1; + + NewListItem^.Next := MMFHandleList; + MMFHandleList := NewListItem; +end; + +function SharedAllocMem(const Name: string; Size: Cardinal; + DesiredAccess: Cardinal = FILE_MAP_ALL_ACCESS): Pointer; +begin + Result := nil; + if (SharedGetMem(Result, Name, Size, DesiredAccess) <> ERROR_ALREADY_EXISTS) and + ((DesiredAccess and (FILE_MAP_WRITE or FILE_MAP_COPY)) <> 0) and + (Size > 0) and (Result <> nil) then + ResetMemory(Pointer(Result)^, Size); +end; + +function SharedFreeMem(var P{: Pointer}): Boolean; +var + N, Iterate: PMMFHandleListItem; + {$IFDEF THREADSAFE} + HandleListAccess: IInterface; + {$ENDIF THREADSAFE} +begin + if Pointer(P) <> nil then + begin + Result := False; + {$IFDEF THREADSAFE} + HandleListAccess := GetAccessToHandleList; + {$ENDIF THREADSAFE} + Iterate := MMFHandleList; + N := nil; + while Iterate <> nil do + begin + if Iterate^.Memory = Pointer(P) then + begin + if Iterate^.References > 1 then + begin + Dec(Iterate^.References); + Pointer(P) := nil; + Result := True; + Exit; + end; + + UnmapViewOfFile(Iterate^.Memory); + CloseHandle(Iterate^.Handle); + + if N = nil then + MMFHandleList := Iterate^.Next + else + N^.Next := Iterate^.Next; + + Dispose(Iterate); + Pointer(P) := nil; + Result := True; + Break; + end; + N := Iterate; + Iterate := Iterate^.Next; + end; + end + else + Result := True; +end; + +function SharedOpenMem(var P{: Pointer}; const Name: string; + DesiredAccess: Cardinal = FILE_MAP_ALL_ACCESS): Boolean; +begin + Result := SharedGetMem(P, Name, 0, DesiredAccess) = ERROR_ALREADY_EXISTS; +end; + +function SharedOpenMem(const Name: string; + DesiredAccess: Cardinal = FILE_MAP_ALL_ACCESS): Pointer; +begin + Result := nil; + SharedGetMem(Result, Name, 0, DesiredAccess); +end; + +function SharedCloseMem(var P{: Pointer}): Boolean; +begin + Result := SharedFreeMem(P); +end; + +{$ENDIF MSWINDOWS} + +//=== Binary search ========================================================== + +function SearchSortedList(List: TList; SortFunc: TListSortCompare; Item: Pointer; Nearest: Boolean): Integer; +var + L, H, I, C: Integer; + B: Boolean; +begin + Result := -1; + if List <> nil then + begin + L := 0; + H := List.Count - 1; + B := False; + while L <= H do + begin + I := (L + H) shr 1; + C := SortFunc(List.List{$IFNDEF RTL230_UP}^{$ENDIF !RTL230_UP}[I], Item); + if C < 0 then + L := I + 1 + else + begin + H := I - 1; + if C = 0 then + begin + B := True; + L := I; + end; + end; + end; + if B then + Result := L + else + if Nearest and (H >= 0) then + Result := H; + end; +end; + +function SearchSortedUntyped(Param: Pointer; ItemCount: Integer; SearchFunc: TUntypedSearchCompare; + const Value; Nearest: Boolean): Integer; +var + L, H, I, C: Integer; + B: Boolean; +begin + Result := -1; + if ItemCount > 0 then + begin + L := 0; + H := ItemCount - 1; + B := False; + while L <= H do + begin + I := (L + H) shr 1; + C := SearchFunc(Param, I, Value); + if C < 0 then + L := I + 1 + else + begin + H := I - 1; + if C = 0 then + begin + B := True; + L := I; + end; + end; + end; + if B then + Result := L + else + if Nearest and (H >= 0) then + Result := H; + end; +end; + +//=== Dynamic array sort and search routines ================================= + +procedure SortDynArray(const ArrayPtr: Pointer; ElementSize: Cardinal; SortFunc: TDynArraySortCompare); +var + TempBuf: TDynByteArray; + + function ArrayItemPointer(Item: SizeInt): Pointer; + begin + Assert(Item >= 0); + Result := Pointer(TJclAddr(ArrayPtr) + TJclAddr(Item * SizeInt(ElementSize))); + end; + + procedure QuickSort(L, R: SizeInt); + var + I, J, T: SizeInt; + P, IPtr, JPtr: Pointer; + ElSize: Integer; + begin + ElSize := ElementSize; + repeat + I := L; + J := R; + P := ArrayItemPointer((L + R) shr 1); + repeat + IPtr := ArrayItemPointer(I); + JPtr := ArrayItemPointer(J); + while SortFunc(IPtr, P) < 0 do + begin + Inc(I); + Inc(PByte(IPtr), ElSize); + end; + while SortFunc(JPtr, P) > 0 do + begin + Dec(J); + Dec(PByte(JPtr), ElSize); + end; + if I <= J then + begin + if I <> J then + begin + case ElementSize of + SizeOf(Byte): + begin + T := PByte(IPtr)^; + PByte(IPtr)^ := PByte(JPtr)^; + PByte(JPtr)^ := T; + end; + SizeOf(Word): + begin + T := PWord(IPtr)^; + PWord(IPtr)^ := PWord(JPtr)^; + PWord(JPtr)^ := T; + end; + SizeOf(Integer): + begin + T := PInteger(IPtr)^; + PInteger(IPtr)^ := PInteger(JPtr)^; + PInteger(JPtr)^ := T; + end; + else + Move(IPtr^, TempBuf[0], ElementSize); + Move(JPtr^, IPtr^, ElementSize); + Move(TempBuf[0], JPtr^, ElementSize); + end; + end; + if P = IPtr then + P := JPtr + else + if P = JPtr then + P := IPtr; + Inc(I); + Dec(J); + end; + until I > J; + if L < J then + QuickSort(L, J); + L := I; + until I >= R; + end; + +begin + if ArrayPtr <> nil then + begin + SetLength(TempBuf, ElementSize); + QuickSort(0, PSizeInt(TJclAddr(ArrayPtr) - SizeOf(SizeInt))^ - 1); + end; +end; + +function SearchDynArray(const ArrayPtr: Pointer; ElementSize: Cardinal; SortFunc: TDynArraySortCompare; + ValuePtr: Pointer; Nearest: Boolean): SizeInt; +var + L, H, I, C: SizeInt; + B: Boolean; +begin + Result := -1; + if ArrayPtr <> nil then + begin + L := 0; + H := PSizeInt(TJclAddr(ArrayPtr) - SizeOf(SizeInt))^ - 1; + B := False; + while L <= H do + begin + I := (L + H) shr 1; + C := SortFunc(Pointer(TJclAddr(ArrayPtr) + TJclAddr(I * SizeInt(ElementSize))), ValuePtr); + if C < 0 then + L := I + 1 + else + begin + H := I - 1; + if C = 0 then + begin + B := True; + L := I; + end; + end; + end; + if B then + Result := L + else + if Nearest and (H >= 0) then + Result := H; + end; +end; + +{ Various compare functions for basic types } + +function DynArrayCompareByte(Item1, Item2: Pointer): Integer; +begin + Result := PByte(Item1)^ - PByte(Item2)^; +end; + +function DynArrayCompareShortInt(Item1, Item2: Pointer): Integer; +begin + Result := PShortInt(Item1)^ - PShortInt(Item2)^; +end; + +function DynArrayCompareWord(Item1, Item2: Pointer): Integer; +begin + Result := PWord(Item1)^ - PWord(Item2)^; +end; + +function DynArrayCompareSmallInt(Item1, Item2: Pointer): Integer; +begin + Result := PSmallInt(Item1)^ - PSmallInt(Item2)^; +end; + +function DynArrayCompareInteger(Item1, Item2: Pointer): Integer; +begin + if PInteger(Item1)^ < PInteger(Item2)^ then + Result := -1 + else + if PInteger(Item1)^ > PInteger(Item2)^ then + Result := 1 + else + Result := 0; +end; + +function DynArrayCompareCardinal(Item1, Item2: Pointer): Integer; +begin + if PCardinal(Item1)^ < PCardinal(Item2)^ then + Result := -1 + else + if PCardinal(Item1)^ > PCardinal(Item2)^ then + Result := 1 + else + Result := 0; +end; + +function DynArrayCompareInt64(Item1, Item2: Pointer): Integer; +begin + if PInt64(Item1)^ < PInt64(Item2)^ then + Result := -1 + else + if PInt64(Item1)^ > PInt64(Item2)^ then + Result := 1 + else + Result := 0; +end; + +function DynArrayCompareSingle(Item1, Item2: Pointer): Integer; +begin + if PSingle(Item1)^ < PSingle(Item2)^ then + Result := -1 + else + if PSingle(Item1)^ > PSingle(Item2)^ then + Result := 1 + else + Result := 0; +end; + +function DynArrayCompareDouble(Item1, Item2: Pointer): Integer; +begin + if PDouble(Item1)^ < PDouble(Item2)^ then + Result := -1 + else + if PDouble(Item1)^ > PDouble(Item2)^ then + Result := 1 + else + Result := 0; +end; + +function DynArrayCompareExtended(Item1, Item2: Pointer): Integer; +begin + if PExtended(Item1)^ < PExtended(Item2)^ then + Result := -1 + else + if PExtended(Item1)^ > PExtended(Item2)^ then + Result := 1 + else + Result := 0; +end; + +function DynArrayCompareFloat(Item1, Item2: Pointer): Integer; +begin + if PFloat(Item1)^ < PFloat(Item2)^ then + Result := -1 + else + if PFloat(Item1)^ > PFloat(Item2)^ then + Result := 1 + else + Result := 0; +end; + +function DynArrayCompareAnsiString(Item1, Item2: Pointer): Integer; +begin + Result := AnsiCompareStr(PAnsiString(Item1)^, PAnsiString(Item2)^); +end; + +function DynArrayCompareAnsiText(Item1, Item2: Pointer): Integer; +begin + Result := AnsiCompareText(PAnsiString(Item1)^, PAnsiString(Item2)^); +end; + +function DynArrayCompareWideString(Item1, Item2: Pointer): Integer; +begin + Result := WideCompareStr(PWideString(Item1)^, PWideString(Item2)^); +end; + +function DynArrayCompareWideText(Item1, Item2: Pointer): Integer; +begin + Result := WideCompareText(PWideString(Item1)^, PWideString(Item2)^); +end; + +function DynArrayCompareString(Item1, Item2: Pointer): Integer; +begin + Result := CompareStr(PString(Item1)^, PString(Item2)^); +end; + +function DynArrayCompareText(Item1, Item2: Pointer): Integer; +begin + Result := CompareText(PString(Item1)^, PString(Item2)^); +end; + +//=== Object lists =========================================================== + +procedure ClearObjectList(List: TList); +var + I: Integer; +begin + if List <> nil then + begin + for I := List.Count - 1 downto 0 do + begin + if List[I] <> nil then + begin + if TObject(List[I]) is TList then + begin + // recursively delete TList sublists + ClearObjectList(TList(List[I])); + end; + TObject(List[I]).Free; + if (not (List is TComponentList)) + and ((not(List is TObjectList)) or not TObjectList(List).OwnsObjects) then + List[I] := nil; + end; + end; + List.Clear; + end; +end; + +procedure FreeObjectList(var List: TList); +begin + if List <> nil then + begin + ClearObjectList(List); + FreeAndNil(List); + end; +end; + +//=== { TJclReferenceMemoryStream } ========================================== + +constructor TJclReferenceMemoryStream.Create(const Ptr: Pointer; Size: Longint); +begin + {$IFDEF MSWINDOWS} + Assert(not IsBadReadPtr(Ptr, Size)); + {$ENDIF MSWINDOWS} + inherited Create; + SetPointer(Ptr, Size); +end; + +function TJclReferenceMemoryStream.Write(const Buffer; Count: Longint): Longint; +begin + raise EJclError.CreateRes(@RsCannotWriteRefStream); +end; + +//=== { TJclAutoPtr } ======================================================== + +constructor TJclAutoPtr.Create(AValue: TObject); +begin + inherited Create; + FValue := AValue; +end; + +destructor TJclAutoPtr.Destroy; +begin + FValue.Free; + inherited Destroy; +end; + +function TJclAutoPtr.AsObject: TObject; +begin + Result := FValue; +end; + +function TJclAutoPtr.AsPointer: Pointer; +begin + Result := FValue; +end; + +function TJclAutoPtr.ReleaseObject: TObject; +begin + Result := FValue; + FValue := nil; +end; + +function CreateAutoPtr(Value: TObject): IAutoPtr; +begin + Result := TJclAutoPtr.Create(Value); +end; + +//=== replacement for the C distfix operator ? : ============================= + +function Iff(const Condition: Boolean; const TruePart, FalsePart: string): string; +begin + if Condition then + Result := TruePart + else + Result := FalsePart; +end; + +function Iff(const Condition: Boolean; const TruePart, FalsePart: Char): Char; +begin + if Condition then + Result := TruePart + else + Result := FalsePart; +end; + +function Iff(const Condition: Boolean; const TruePart, FalsePart: Byte): Byte; +begin + if Condition then + Result := TruePart + else + Result := FalsePart; +end; + +function Iff(const Condition: Boolean; const TruePart, FalsePart: Integer): Integer; +begin + if Condition then + Result := TruePart + else + Result := FalsePart; +end; + +function Iff(const Condition: Boolean; const TruePart, FalsePart: Cardinal): Cardinal; +begin + if Condition then + Result := TruePart + else + Result := FalsePart; +end; + +function Iff(const Condition: Boolean; const TruePart, FalsePart: Float): Float; +begin + if Condition then + Result := TruePart + else + Result := FalsePart; +end; + +function Iff(const Condition: Boolean; const TruePart, FalsePart: Boolean): Boolean; +begin + if Condition then + Result := TruePart + else + Result := FalsePart; +end; + +function Iff(const Condition: Boolean; const TruePart, FalsePart: Pointer): Pointer; +begin + if Condition then + Result := TruePart + else + Result := FalsePart; +end; + +function Iff(const Condition: Boolean; const TruePart, FalsePart: Int64): Int64; +begin + if Condition then + Result := TruePart + else + Result := FalsePart; +end; + +{$IFDEF SUPPORTS_VARIANT} +function Iff(const Condition: Boolean; const TruePart, FalsePart: Variant): Variant; overload; +begin + if Condition then + Result := TruePart + else + Result := FalsePart; +end; +{$ENDIF SUPPORTS_VARIANT} + +//=== Classes information and manipulation =================================== +// Virtual Methods +// Helper method + +procedure SetVMTPointer(AClass: TClass; Offset: Integer; Value: Pointer); +var + WrittenBytes: DWORD; + PatchAddress: PPointer; +begin + {$OVERFLOWCHECKS OFF} + PatchAddress := Pointer(TJclAddr(AClass) + TJclAddr(Offset)); + {$IFDEF OVERFLOWCHECKS_ON} + {$OVERFLOWCHECKS ON} + {$ENDIF OVERFLOWCHECKS_ON} + if not WriteProtectedMemory(PatchAddress, @Value, SizeOf(Value), WrittenBytes) then + raise EJclVMTError.CreateResFmt(@RsVMTMemoryWriteError, + [SysErrorMessage({$IFDEF FPC}GetLastOSError{$ELSE}GetLastError{$ENDIF})]); + + if WrittenBytes <> SizeOf(Pointer) then + raise EJclVMTError.CreateResFmt(@RsVMTMemoryWriteError, [IntToStr(WrittenBytes)]); + + // make sure that everything keeps working in a dual processor setting + // (outchy) done by WriteProtectedMemory + // FlushInstructionCache{$IFDEF MSWINDOWS}(GetCurrentProcess, PatchAddress, SizeOf(Pointer)){$ENDIF}; +end; + +{$IFNDEF FPC} +function GetVirtualMethodCount(AClass: TClass): Integer; +type + PINT_PTR = ^INT_PTR; +var + BeginVMT: INT_PTR; + EndVMT: INT_PTR; + TablePointer: INT_PTR; + I: Integer; +begin + BeginVMT := INT_PTR(AClass); + + // Scan the offset entries in the class table for the various fields, + // namely vmtIntfTable, vmtAutoTable, ..., vmtDynamicTable + // The last entry is always the vmtClassName, so stop once we got there + // After the last virtual method there is one of these entries. + + EndVMT := PINT_PTR(INT_PTR(AClass) + vmtClassName)^; + // Set iterator to first item behind VMT table pointer + I := vmtSelfPtr + SizeOf(Pointer); + repeat + TablePointer := PINT_PTR(INT_PTR(AClass) + I)^; + if (TablePointer <> 0) and (TablePointer >= BeginVMT) and + (TablePointer < EndVMT) then + EndVMT := INT_PTR(TablePointer); + Inc(I, SizeOf(Pointer)); + until I >= vmtClassName; + + Result := (EndVMT - BeginVMT) div SizeOf(Pointer); +end; +{$ENDIF ~FPC} + +function GetVirtualMethod(AClass: TClass; const Index: Integer): Pointer; +begin + {$OVERFLOWCHECKS OFF} + Result := PPointer(TJclAddr(AClass) + TJclAddr(Index * SizeOf(Pointer)))^; + {$IFDEF OVERFLOWCHECKS_ON} + {$OVERFLOWCHECKS ON} + {$ENDIF OVERFLOWCHECKS_ON} +end; + +procedure SetVirtualMethod(AClass: TClass; const Index: Integer; const Method: Pointer); +begin + SetVMTPointer(AClass, Index * SizeOf(Pointer), Method); +end; + +function GetDynamicMethodCount(AClass: TClass): Integer; assembler; +asm + {$IFDEF CPU32} + // --> RAX AClass + // <-- EAX Result + MOV EAX, [EAX].vmtDynamicTable + TEST EAX, EAX + JE @@Exit + MOVZX EAX, WORD PTR [EAX] + {$ENDIF CPU32} + {$IFDEF CPU64} + // --> RCX AClass + // <-- EAX Result + MOV RAX, [RCX].vmtDynamicTable + TEST RAX, RAX + JE @@Exit + MOVZX RAX, WORD PTR [RAX] + {$ENDIF CPU64} +@@Exit: +end; + +function GetDynamicIndexList(AClass: TClass): PDynamicIndexList; assembler; +asm + {$IFDEF CPU32} + // --> EAX AClass + // <-- EAX Result + MOV EAX, [EAX].vmtDynamicTable + ADD EAX, 2 + {$ENDIF CPU32} + {$IFDEF CPU64} + // --> RCX AClass + // <-- RAX Result + MOV RAX, [RCX].vmtDynamicTable + ADD RAX, 2 + {$ENDIF CPU64} +end; + +function GetDynamicAddressList(AClass: TClass): PDynamicAddressList; assembler; +asm + {$IFDEF CPU32} + // --> EAX AClass + // <-- EAX Result + MOV EAX, [EAX].vmtDynamicTable + MOVZX EDX, Word ptr [EAX] + ADD EAX, EDX + ADD EAX, EDX + ADD EAX, 2 + {$ENDIF CPU32} + {$IFDEF CPU64} + // --> RCX AClass + // <-- RAX Result + MOV RAX, [RCX].vmtDynamicTable + MOVZX RDX, Word ptr [RAX] + ADD RAX, RDX + ADD RAX, RDX + ADD RAX, 2 + {$ENDIF CPU64} +end; + +function HasDynamicMethod(AClass: TClass; Index: Integer): Boolean; assembler; +// Mainly copied from System.GetDynaMethod +asm + {$IFDEF CPU32} + // --> EAX AClass + // EDX Index + // <-- AL Result + PUSH EDI + XCHG EAX, EDX + JMP @@HaveVMT +@@OuterLoop: + MOV EDX, [EDX] +@@HaveVMT: + MOV EDI, [EDX].vmtDynamicTable + TEST EDI, EDI + JE @@Parent + MOVZX ECX, WORD PTR [EDI] + PUSH ECX + ADD EDI,2 + REPNE SCASW + JE @@Found + POP ECX +@@Parent: + MOV EDX,[EDX].vmtParent + TEST EDX,EDX + JNE @@OuterLoop + MOV EAX, 0 + JMP @@Exit +@@Found: + POP EAX + MOV EAX, 1 +@@Exit: + POP EDI + {$ENDIF CPU32} + {$IFDEF CPU64} + // --> RCX AClass + // EDX Index + // <-- AL Result + MOV EAX, EDX + MOV RDX, RCX + JMP @@HaveVMT +@@OuterLoop: + MOV RDX, [RDX] +@@HaveVMT: + MOV RDI, [RDX].vmtDynamicTable + TEST RDI, RDI + JE @@Parent + MOVZX RCX, WORD PTR [RDI] + PUSH RCX + ADD RDI,2 + REPNE SCASW + JE @@Found + POP RCX +@@Parent: + MOV RDX,[RDX].vmtParent + TEST RDX,RDX + JNE @@OuterLoop + MOV RAX, 0 + JMP @@Exit +@@Found: + POP RAX + MOV RAX, 1 +@@Exit: + {$ENDIF CPU64} +end; + +{$IFNDEF FPC} +function GetDynamicMethod(AClass: TClass; Index: Integer): Pointer; assembler; +asm + CALL System.@FindDynaClass +end; +{$ENDIF ~FPC} + +//=== Interface Table ======================================================== + +function GetInitTable(AClass: TClass): PTypeInfo; assembler; +asm + {$IFDEF CPU32} + // --> EAX AClass + // <-- EAX Result + MOV EAX, [EAX].vmtInitTable + {$ENDIF CPU32} + {$IFDEF CPU64} + // --> RCX AClass + // <-- RAX Result + MOV RAX, [RCX].vmtInitTable + {$ENDIF CPU64} +end; + +function GetFieldTable(AClass: TClass): PFieldTable; assembler; +asm + {$IFDEF CPU32} + // --> EAX AClass + // <-- EAX Result + MOV EAX, [EAX].vmtFieldTable + {$ENDIF CPU32} + {$IFDEF CPU64} + // --> RCX AClass + // <-- RAX Result + MOV RAX, [RCX].vmtFieldTable + {$ENDIF CPU64} +end; + +function GetMethodTable(AClass: TClass): PMethodTable; assembler; +asm + {$IFDEF CPU32} + // --> EAX AClass + // <-- EAX Result + MOV EAX, [EAX].vmtMethodTable + {$ENDIF CPU32} + {$IFDEF CPU64} + // --> RCX AClass + // <-- RAX Result + MOV RAX, [RCX].vmtMethodTable + {$ENDIF CPU64} +end; + +function GetMethodEntry(MethodTable: PMethodTable; Index: Integer): PMethodEntry; +begin + Result := Pointer(TJclAddr(MethodTable) + 2); + for Index := Index downto 1 do + Inc(TJclAddr(Result), Result^.EntrySize); +end; + +//=== Class Parent methods =================================================== + +procedure SetClassParent(AClass: TClass; NewClassParent: TClass); +var + WrittenBytes: DWORD; + PatchAddress: Pointer; +begin + {$OVERFLOWCHECKS OFF} + PatchAddress := PPointer(TJclAddr(AClass) + TJclAddr(vmtParent))^; + {$IFDEF OVERFLOWCHECKS_ON} + {$OVERFLOWCHECKS ON} + {$ENDIF OVERFLOWCHECKS_ON} + if not WriteProtectedMemory(PatchAddress, @NewClassParent, SizeOf(Pointer), WrittenBytes) then + raise EJclVMTError.CreateResFmt(@RsVMTMemoryWriteError, + [SysErrorMessage({$IFDEF FPC}GetLastOSError{$ELSE}GetLastError{$ENDIF})]); + if WrittenBytes <> SizeOf(Pointer) then + raise EJclVMTError.CreateResFmt(@RsVMTMemoryWriteError, [IntToStr(WrittenBytes)]); + // make sure that everything keeps working in a dual processor setting + // (outchy) done by WriteProtectedMemory + // FlushInstructionCache{$IFDEF MSWINDOWS}(GetCurrentProcess, PatchAddress, SizeOf(Pointer)){$ENDIF}; +end; + +function GetClassParent(AClass: TClass): TClass; assembler; +asm + {$IFDEF CPU32} + // --> EAX AClass + // <-- EAX Result + MOV EAX, [EAX].vmtParent + TEST EAX, EAX + JE @@Exit + MOV EAX, [EAX] + {$ENDIF CPU32} + {$IFDEF CPU64} + // --> RCX AClass + // <-- RAX Result + MOV RAX, [RCX].vmtParent + TEST RAX, RAX + JE @@Exit + MOV RAX, [RAX] + {$ENDIF CPU64} +@@Exit: +end; + +{$IFDEF BORLAND} +function IsClass(Address: Pointer): Boolean; assembler; +asm + CMP Address, Address.vmtSelfPtr + JNZ @False + MOV Result, True + JMP @Exit +@False: + MOV Result, False +@Exit: +end; +{$ENDIF BORLAND} + +{$IFDEF BORLAND} +function IsObject(Address: Pointer): Boolean; assembler; +asm +// or IsClass(Pointer(Address^)); + MOV EAX, [Address] + CMP EAX, EAX.vmtSelfPtr + JNZ @False + MOV Result, True + JMP @Exit +@False: + MOV Result, False +@Exit: +end; +{$ENDIF BORLAND} + +function InheritsFromByName(AClass: TClass; const AClassName: string): Boolean; +begin + while (AClass <> nil) and not AClass.ClassNameIs(AClassName) do + AClass := AClass.ClassParent; + Result := AClass <> nil; +end; + +//=== Interface information ================================================== + +function GetImplementorOfInterface(const I: IInterface): TObject; +{ TODO -cDOC : Original code by Hallvard Vassbotn } +{ TODO -cTesting : Check the implemetation for any further version of compiler } +const + AddByte = $04244483; // opcode for ADD DWORD PTR [ESP+4], Shortint + AddLong = $04244481; // opcode for ADD DWORD PTR [ESP+4], Longint +type + PAdjustSelfThunk = ^TAdjustSelfThunk; + TAdjustSelfThunk = packed record + case AddInstruction: Longint of + AddByte: (AdjustmentByte: ShortInt); + AddLong: (AdjustmentLong: Longint); + end; + PInterfaceMT = ^TInterfaceMT; + TInterfaceMT = packed record + QueryInterfaceThunk: PAdjustSelfThunk; + end; + TInterfaceRef = ^PInterfaceMT; +var + QueryInterfaceThunk: PAdjustSelfThunk; +begin + try + Result := Pointer(I); + if Assigned(Result) then + begin + QueryInterfaceThunk := TInterfaceRef(I)^.QueryInterfaceThunk; + case QueryInterfaceThunk.AddInstruction of + AddByte: + Inc(PByte(Result), QueryInterfaceThunk.AdjustmentByte); + AddLong: + Inc(PByte(Result), QueryInterfaceThunk.AdjustmentLong); + else + Result := nil; + end; + end; + except + Result := nil; + end; +end; + +//=== { TJclInterfacedPersistent } =========================================== + +procedure TJclInterfacedPersistent.AfterConstruction; +begin + inherited AfterConstruction; + if GetOwner <> nil then + GetOwner.GetInterface(IInterface, FOwnerInterface); +end; + +function TJclInterfacedPersistent._AddRef: Integer; +begin + if FOwnerInterface <> nil then + Result := FOwnerInterface._AddRef + else + Result := InterlockedIncrement(FRefCount); +end; + +function TJclInterfacedPersistent._Release: Integer; +begin + if FOwnerInterface <> nil then + Result := FOwnerInterface._Release + else + begin + Result := InterlockedDecrement(FRefCount); + if Result = 0 then + Destroy; + end; +end; + +//=== Numeric formatting routines ============================================ + +function IntToStrZeroPad(Value, Count: Integer): string; +begin + Result := IntToStr(Value); + if Length(Result) < Count then + Result := StrRepeatChar('0', Count - Length(Result)) + Result; +end; + +//=== { TJclNumericFormat } ================================================== + +{ TODO -cHelp : Author: Robert Rossmair } +{ Digit: converts a digit value (number) to a digit (char) + DigitValue: converts a digit (char) into a number (digit value) + IntToStr, + FloatToStr, + FloatToHTML: converts a numeric value to a base numeric representation with formating options + StrToIn: converts a base numeric representation into an integer, if possible + GetMantisseExponent: similar to AsString, but returns the Exponent separately as an integer +} +const + {$IFDEF MATH_EXTENDED_PRECISION} + BinaryPrecision = 64; + {$ENDIF MATH_EXTENDED_PRECISION} + {$IFDEF MATH_DOUBLE_PRECISION} + BinaryPrecision = 53; + {$ENDIF MATH_DOUBLE_PRECISION} + {$IFDEF MATH_SINGLE_PRECISION} + BinaryPrecision = 24; + {$ENDIF MATH_SINGLE_PRECISION} + +{$IFNDEF WINSCP} + +constructor TJclNumericFormat.Create; +begin + inherited Create; + { TODO : Initialize, when possible, from locale info } + FBase := 10; + FExpDivision := 1; + SetPrecision(6); + FNumberOfFractionalDigits := BinaryPrecision; + FSignChars[False] := '-'; + FSignChars[True] := '+'; + FPaddingChar := ' '; + FMultiplier := '×'; + FFractionalPartSeparator := JclFormatSettings.DecimalSeparator; + FDigitBlockSeparator := JclFormatSettings.ThousandSeparator; +end; + +procedure TJclNumericFormat.InvalidDigit(Digit: Char); +begin + raise EConvertError.CreateResFmt(@RsInvalidDigit, [Base, Digit]); +end; + +function TJclNumericFormat.Digit(DigitValue: TDigitValue): Char; +begin + Assert(DigitValue < Base, Format(LoadResString(@RsInvalidDigitValue), [Base, DigitValue])); + if DigitValue > 9 then + Result := Chr(Ord('A') + DigitValue - 10) + else + Result := Chr(Ord('0') + DigitValue); +end; + +function TJclNumericFormat.GetDigitValue(Digit: Char): Integer; +begin + Result := CharHex(Digit); + if (Result = $FF) or (Result >= Base) then + Result := -1; +end; + +function TJclNumericFormat.DigitValue(Digit: Char): TDigitValue; +begin + Result := GetDigitValue(Digit); + if Result = -1 then + InvalidDigit(Digit); +end; + +function TJclNumericFormat.IsDigit(Value: Char): Boolean; +begin + Result := GetDigitValue(Value) <> -1; +end; + +function TJclNumericFormat.FloatToHTML(const Value: Float): string; +var + Mantissa: string; + Exponent: Integer; +begin + GetMantissaExp(Value, Mantissa, Exponent); + Result := Format('%s %s %d%d', [Mantissa, Multiplier, Base, Exponent]); +end; + +procedure TJclNumericFormat.GetMantissaExp(const Value: Float; + out Mantissa: string; out Exponent: Integer); +const + {$IFDEF FPC} + InfMantissa: array [Boolean] of string[4] = ('inf', '-inf'); + {$ElSE ~FPC} + InfMantissa: array [Boolean] of string = ('inf', '-inf'); + {$ENDIF ~FPC} +var + BlockDigits: TDigitCount; + IntDigits, FracDigits: Integer; + FirstDigitPos, Prec: Integer; + I, J, N: Integer; + K: Int64; + X: Extended; + HighDigit: Char; + + function GetDigit(X: Extended): Char; + var + N: Integer; + begin + N := Trunc(X); + if N > 9 then + Result := Chr(Ord('A') + N - 10) + else + Result := Chr(Ord('0') + N); + end; + +begin + X := Abs(Value); + + if X > MaxFloatingPoint then + begin + Mantissa := InfMantissa[Value < 0]; + Exponent := 1; + Exit; + end + else + if X < MinFloatingPoint then + begin + Mantissa := Format('%.*f', [Precision, 0.0]); + Exponent := 1; + Exit; + end; + + IntDigits := 1; + Prec := Precision; + + Exponent := Trunc(LogBaseN(Base, X)); + if FExpDivision > 1 then + begin + N := Exponent mod FExpDivision; + Dec(Exponent, N); + Inc(IntDigits, N); + end; + X := X / Power(Base, Exponent); + + if X < 1.0 then + begin + Dec(Exponent, FExpDivision); + X := X * PowerInt(Base, FExpDivision); + Inc(IntDigits, FExpDivision - 1); + end; + +{ TODO : Here's a problem if X > High(Int64). +It *seems* to surface only if ExponentDivision > 12, but it +has not been investigated if ExponentDivision <= 12 is safe. } + K := Trunc(X); + if Value < 0 then + K := -K; + + Mantissa := IntToStr(K, FirstDigitPos); + + FracDigits := Prec - IntDigits; + if FracDigits > NumberOfFractionalDigits then + FracDigits := NumberOfFractionalDigits; + + if FracDigits > 0 then + begin + J := Length(Mantissa) + 1; + // allocate sufficient space for point + digits + digit block separators + SetLength(Mantissa, FracDigits * 2 + J); + Mantissa[J] := FractionalPartSeparator; + I := J + 1; + BlockDigits := 0; + while FracDigits > 0 do + begin + if (BlockDigits > 0) and (BlockDigits = DigitBlockSize) then + begin + Mantissa[I] := DigitBlockSeparator; + Inc(I); + BlockDigits := 0; + end; + X := Frac(X) * Base; + Mantissa[I] := GetDigit(X); + Inc(I); + Inc(BlockDigits); + Dec(FracDigits); + end; + Mantissa[I] := #0; + StrResetLength(Mantissa); + end; + + if Frac(X) >= 0.5 then + // round up + begin + HighDigit := Digit(Base - 1); + for I := Length(Mantissa) downto 1 do + begin + if Mantissa[I] = HighDigit then + if (I = FirstDigitPos) then + begin + Mantissa[I] := '1'; + Inc(Exponent); + Break; + end + else + Mantissa[I] := '0' + else + if (Mantissa[I] = DigitBlockSeparator) or (Mantissa[I] = FractionalPartSeparator) then + Continue + else + begin + if Mantissa[I] = '9' then + Mantissa[I] := 'A' + else + Mantissa[I] := Succ(Mantissa[I]); + Break; + end; + end; + end; +end; + +function TJclNumericFormat.FloatToStr(const Value: Float): string; +var + Mantissa: string; + Exponent: Integer; +begin + GetMantissaExp(Value, Mantissa, Exponent); + Result := Format('%s %s %d^%d', [Mantissa, Multiplier, Base, Exponent]); +end; + +function TJclNumericFormat.IntToStr(const Value: Int64): string; +var + FirstDigitPos: Integer; +begin + Result := IntToStr(Value, FirstDigitPos); +end; + +function TJclNumericFormat.IntToStr(const Value: Int64; out FirstDigitPos: Integer): string; +const + MaxResultLen = 64 + 63 + 1; // max. digits + max. group separators + sign +var + Remainder: Int64; + I, N: Integer; + Chars, Digits: Cardinal; + LoopFinished, HasSign, SpacePadding: Boolean; +begin + SpacePadding := PaddingChar = ' '; + HasSign := ShowSign(Value); + Chars := MaxResultLen; + if Width > Chars then + Chars := Width; + Result := StrRepeatChar(' ', Chars); + + Remainder := Abs(Value); + Digits := 0; + + Chars := 0; + if HasSign then + Chars := 1; + + I := MaxResultLen; + + while True do + begin + N := Remainder mod Base; + Remainder := Remainder div Base; + if N > 9 then + Result[I] := Chr(Ord('A') + N - 10) + else + Result[I] := Chr(Ord('0') + N); + Dec(I); + Inc(Digits); + Inc(Chars); + if (Remainder = 0) and (SpacePadding or (Chars >= Width)) then + Break; + if (Digits = DigitBlockSize) then + begin + Inc(Chars); + LoopFinished := (Remainder = 0) and (Chars = Width); + if LoopFinished then + Result[I] := ' ' + else + Result[I] := DigitBlockSeparator; + Dec(I); + if LoopFinished then + Break; + Digits := 0; + end; + end; + + FirstDigitPos := I + 1; + + if HasSign then + Result[I] := SignChar(Value) + else + Inc(I); + N := MaxResultLen - Width + 1; + if N < I then + I := N; + Result := Copy(Result, I, MaxResultLen); + Dec(FirstDigitPos, I - 1); +end; + +procedure TJclNumericFormat.SetBase(const Value: TNumericSystemBase); +begin + FBase := Value; + SetPrecision(FWantedPrecision); +end; + +procedure TJclNumericFormat.SetExpDivision(const Value: Integer); +begin + if Value <= 1 then + FExpDivision := 1 + else + // see TODO in GetMantissaExp + if Value > 12 then + FExpDivision := 12 + else + FExpDivision := Value; +end; + +procedure TJclNumericFormat.SetPrecision(const Value: TDigitCount); +begin + FWantedPrecision := Value; + // Do not display more digits than Float precision justifies + if Base = 2 then + FPrecision := BinaryPrecision + else + FPrecision := Trunc(BinaryPrecision / LogBase2(Base)); + if Value < FPrecision then + FPrecision := Value; +end; + +function TJclNumericFormat.Sign(Value: Char): Integer; +begin + Result := 0; + if Value = FSignChars[False] then + Result := -1; + if Value = FSignChars[True] then + Result := +1; +end; + +function TJclNumericFormat.StrToInt(const Value: string): Int64; +var + I, N: Integer; + C: Char; +begin + Result := 0; + I := 1; + if (Length(Value) >= I) + and ((Value[I] = '+') or (Value[I] = '-')) then + Inc(I); + for I := I to Length(Value) do + begin + C := Value[I]; + if C = DigitBlockSeparator then + Continue + else + begin + N := CharHex(C); + if (N = $FF) or (N >= Base) then + InvalidDigit(C); + Result := Result * Base + N; + end; + end; + if Value[1] = '-' then + Result := -Result; +end; + +function TJclNumericFormat.ShowSign(const Value: Float): Boolean; +begin + Result := FShowPositiveSign or (Value < 0); +end; + +function TJclNumericFormat.ShowSign(const Value: Int64): Boolean; +begin + Result := FShowPositiveSign or (Value < 0); +end; + +function TJclNumericFormat.SignChar(const Value: Float): Char; +begin + Result := FSignChars[Value >= 0]; +end; + +function TJclNumericFormat.SignChar(const Value: Int64): Char; +begin + Result := FSignChars[Value >= 0]; +end; + +function TJclNumericFormat.GetNegativeSign: Char; +begin + Result := FSignChars[False]; +end; + +function TJclNumericFormat.GetPositiveSign: Char; +begin + Result := FSignChars[True]; +end; + +procedure TJclNumericFormat.SetNegativeSign(const Value: Char); +begin + FSignChars[False] := Value; +end; + +procedure TJclNumericFormat.SetPositiveSign(const Value: Char); +begin + FSignChars[True] := Value; +end; + +{$ENDIF ~WINSCP} + +//=== Child processes ======================================================== + +const + BufferSize = 255; +type + TBuffer = array [0..BufferSize] of AnsiChar; + + TPipeInfo = record + PipeRead, PipeWrite: THandle; + Buffer: TBuffer; + Line: string; + TextHandler: TTextHandler; + RawOutput: Boolean; + Event: TJclEvent; + end; + PPipeInfo = ^TPipeInfo; + +// MuteCRTerminatedLines was "outsourced" from Win32ExecAndRedirectOutput + +function InternalExecuteMuteCRTerminatedLines(const RawOutput: string): string; +const + Delta = 1024; +var + BufPos, OutPos, LfPos, EndPos: Integer; + C: Char; +begin + SetLength(Result, Length(RawOutput)); + OutPos := 1; + LfPos := OutPos; + EndPos := OutPos; + for BufPos := 1 to Length(RawOutput) do + begin + if OutPos >= Length(Result)-2 then + SetLength(Result, Length(Result) + Delta); + C := RawOutput[BufPos]; + case C of + NativeCarriageReturn: + OutPos := LfPos; + NativeLineFeed: + begin + OutPos := EndPos; + Result[OutPos] := NativeCarriageReturn; + Inc(OutPos); + Result[OutPos] := C; + Inc(OutPos); + EndPos := OutPos; + LfPos := OutPos; + end; + else + Result[OutPos] := C; + Inc(OutPos); + EndPos := OutPos; + end; + end; + SetLength(Result, OutPos - 1); +end; + +procedure InternalExecuteProcessLine(const PipeInfo: TPipeInfo; LineEnd: Integer); +begin + if PipeInfo.RawOutput or (PipeInfo.Line[LineEnd] <> NativeCarriageReturn) then + begin + while (LineEnd > 0) and CharIsReturn(PipeInfo.Line[LineEnd]) do + Dec(LineEnd); + PipeInfo.TextHandler(Copy(PipeInfo.Line, 1, LineEnd)); + end; +end; + +procedure InternalExecuteProcessBuffer(var PipeInfo: TPipeInfo; PipeBytesRead: Cardinal); +var + CR, LF: Integer; +begin + PipeInfo.Buffer[PipeBytesRead] := #0; + PipeInfo.Line := PipeInfo.Line + string(PipeInfo.Buffer); + if Assigned(PipeInfo.TextHandler) then + repeat + CR := Pos(NativeCarriageReturn, PipeInfo.Line); + if CR = Length(PipeInfo.Line) then + CR := 0; // line feed at CR + 1 might be missing + LF := Pos(NativeLineFeed, PipeInfo.Line); + if (CR > 0) and ((LF > CR + 1) or (LF = 0)) then + LF := CR; // accept CR as line end + if LF > 0 then + begin + InternalExecuteProcessLine(PipeInfo, LF); + Delete(PipeInfo.Line, 1, LF); + end; + until LF = 0; +end; + +procedure InternalExecuteReadPipe(var PipeInfo: TPipeInfo; var Overlapped: TOverlapped); +var + NullDWORD: ^DWORD; // XE4 broke PDWORD + Res: DWORD; +begin + NullDWORD := nil; + if not ReadFile(PipeInfo.PipeRead, PipeInfo.Buffer[0], BufferSize, NullDWORD^, @Overlapped) then + begin + Res := GetLastError; + case Res of + ERROR_BROKEN_PIPE: + begin + CloseHandle(PipeInfo.PipeRead); + PipeInfo.PipeRead := 0; + end; + ERROR_IO_PENDING: + ; + else + {$IFDEF DELPHI11_UP} + RaiseLastOSError(Res); + {$ELSE} + RaiseLastOSError; + {$ENDIF DELPHI11_UP} + end; + end; +end; + +procedure InternalExecuteHandlePipeEvent(var PipeInfo: TPipeInfo; var Overlapped: TOverlapped); +var + PipeBytesRead: DWORD; +begin + if GetOverlappedResult(PipeInfo.PipeRead, Overlapped, PipeBytesRead, False) then + begin + InternalExecuteProcessBuffer(PipeInfo, PipeBytesRead); + // automatically launch the next read + InternalExecuteReadPipe(PipeInfo, Overlapped); + end + else + if GetLastError = ERROR_BROKEN_PIPE then + begin + CloseHandle(PipeInfo.PipeRead); + PipeInfo.PipeRead := 0; + end + else + RaiseLastOSError; +end; + +procedure InternalExecuteFlushPipe(var PipeInfo: TPipeInfo; var Overlapped: TOverlapped); +var + PipeBytesRead: DWORD; +begin + CancelIo(PipeInfo.PipeRead); + GetOverlappedResult(PipeInfo.PipeRead, Overlapped, PipeBytesRead, True); + if PipeBytesRead > 0 then + InternalExecuteProcessBuffer(PipeInfo, PipeBytesRead); + while PeekNamedPipe(PipeInfo.PipeRead, nil, 0, nil, @PipeBytesRead, nil) and (PipeBytesRead > 0) do + begin + if PipeBytesRead > BufferSize then + PipeBytesRead := BufferSize; + if not ReadFile(PipeInfo.PipeRead, PipeInfo.Buffer[0], PipeBytesRead, PipeBytesRead, nil) then + RaiseLastOSError; + InternalExecuteProcessBuffer(PipeInfo, PipeBytesRead); + end; +end; + +var + AsyncPipeCounter: Integer; + +// CreateAsyncPipe creates a pipe that uses overlapped reading. +function CreateAsyncPipe(var hReadPipe, hWritePipe: THandle; + lpPipeAttributes: PSecurityAttributes; nSize: DWORD): BOOL; +var + PipeName: string; + Error: DWORD; + PipeReadHandle, PipeWriteHandle: THandle; +begin + Result := False; + + if (@hReadPipe = nil) or (@hWritePipe = nil) then + begin + SetLastError(ERROR_INVALID_PARAMETER); + Exit; + end; + + if nSize = 0 then + nSize := 4096; + + InterlockedIncrement(AsyncPipeCounter); + // In some (not so) rare instances there is a race condition + // where the counter is the same for two threads at the same + // time. This makes the CreateNamedPipe call below fail + // because of the limit set to 1 in the call. + // So, to be sure this call succeeds, we put both the process + // and thread id in the name of the pipe. + // This was found to happen while simply starting 7 instances + // of the same exe file in parallel. + PipeName := Format('\\.\Pipe\AsyncAnonPipe.%.8x.%.8x.%.8x', [GetCurrentProcessId, GetCurrentThreadId, AsyncPipeCounter]); + + PipeReadHandle := CreateNamedPipe(PChar(PipeName), PIPE_ACCESS_INBOUND or FILE_FLAG_OVERLAPPED, + PIPE_TYPE_BYTE or PIPE_WAIT, 1, nSize, nSize, 120 * 1000, lpPipeAttributes); + if PipeReadHandle = INVALID_HANDLE_VALUE then + Exit; + + PipeWriteHandle := CreateFile(PChar(PipeName), GENERIC_WRITE, 0, lpPipeAttributes, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL {or FILE_FLAG_OVERLAPPED}, 0); + if PipeWriteHandle = INVALID_HANDLE_VALUE then + begin + Error := GetLastError; + CloseHandle(PipeReadHandle); + SetLastError(Error); + Exit; + end; + + hReadPipe := PipeReadHandle; + hWritePipe := PipeWriteHandle; + + Result := True; +end; + +const + BELOW_NORMAL_PRIORITY_CLASS = $00004000; + ABOVE_NORMAL_PRIORITY_CLASS = $00008000; + + ProcessPriorities: array [TJclProcessPriority] of DWORD = + (IDLE_PRIORITY_CLASS, NORMAL_PRIORITY_CLASS, HIGH_PRIORITY_CLASS, REALTIME_PRIORITY_CLASS, + BELOW_NORMAL_PRIORITY_CLASS, ABOVE_NORMAL_PRIORITY_CLASS); + +function InternalExecute(CommandLine: string; AbortPtr: PBoolean; AbortEvent: TJclEvent; + var Output: string; OutputLineCallback: TTextHandler; RawOutput: Boolean; + MergeError: Boolean; var Error: string; ErrorLineCallback: TTextHandler; RawError: Boolean; + ProcessPriority: TJclProcessPriority): Cardinal; +var + OutPipeInfo, ErrorPipeInfo: TPipeInfo; + Index: Cardinal; +{$IFDEF MSWINDOWS} +var + StartupInfo: TStartupInfo; + ProcessInfo: TProcessInformation; + SecurityAttr: TSecurityAttributes; + OutOverlapped, ErrorOverlapped: TOverlapped; + ProcessEvent: TJclDispatcherObject; + WaitEvents: array of TJclDispatcherObject; + InternalAbort: Boolean; + LastError: DWORD; +begin + // hack to pass a null reference to the parameter lpNumberOfBytesRead of ReadFile + Result := $FFFFFFFF; + SecurityAttr.nLength := SizeOf(SecurityAttr); + SecurityAttr.lpSecurityDescriptor := nil; + SecurityAttr.bInheritHandle := True; + + ResetMemory(OutPipeInfo, SizeOf(OutPipeInfo)); + OutPipeInfo.TextHandler := OutputLineCallback; + OutPipeInfo.RawOutput := RawOutput; + if not CreateAsyncPipe(OutPipeInfo.PipeRead, OutPipeInfo.PipeWrite, @SecurityAttr, 0) then + begin + Result := GetLastError; + Exit; + end; + OutPipeInfo.Event := TJclEvent.Create(@SecurityAttr, False {automatic reset}, False {not flagged}, '' {anonymous}); + ResetMemory(ErrorPipeInfo, SizeOf(ErrorPipeInfo)); + if not MergeError then + begin + ErrorPipeInfo.TextHandler := ErrorLineCallback; + ErrorPipeInfo.RawOutput := RawError; + if not CreateAsyncPipe(ErrorPipeInfo.PipeRead, ErrorPipeInfo.PipeWrite, @SecurityAttr, 0) then + begin + Result := GetLastError; + CloseHandle(OutPipeInfo.PipeWrite); + CloseHandle(OutPipeInfo.PipeRead); + OutPipeInfo.Event.Free; + Exit; + end; + ErrorPipeInfo.Event := TJclEvent.Create(@SecurityAttr, False {automatic reset}, False {not flagged}, '' {anonymous}); + end; + + ResetMemory(StartupInfo, SizeOf(TStartupInfo)); + StartupInfo.cb := SizeOf(TStartupInfo); + StartupInfo.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES; + StartupInfo.wShowWindow := SW_HIDE; + StartupInfo.hStdInput := GetStdHandle(STD_INPUT_HANDLE); + StartupInfo.hStdOutput := OutPipeInfo.PipeWrite; + if MergeError then + StartupInfo.hStdError := OutPipeInfo.PipeWrite + else + StartupInfo.hStdError := ErrorPipeInfo.PipeWrite; + UniqueString(CommandLine); // CommandLine must be in a writable memory block + ProcessInfo.dwProcessId := 0; + ProcessEvent := nil; + try + if CreateProcess(nil, PChar(CommandLine), nil, nil, True, ProcessPriorities[ProcessPriority], + nil, nil, StartupInfo, ProcessInfo) then + begin + try + // init out and error events + CloseHandle(OutPipeInfo.PipeWrite); + OutPipeInfo.PipeWrite := 0; + if not MergeError then + begin + CloseHandle(ErrorPipeInfo.PipeWrite); + ErrorPipeInfo.PipeWrite := 0; + end; + InternalAbort := False; + if AbortPtr <> nil then + AbortPtr^ := {$IFDEF FPC}Byte({$ENDIF}False{$IFDEF FPC}){$ENDIF} + else + AbortPtr := @InternalAbort; + // init the array of events to wait for + ProcessEvent := TJclDispatcherObject.Attach(ProcessInfo.hProcess); + SetLength(WaitEvents, 2); + // add the process first + WaitEvents[0] := ProcessEvent; + // add the output event + WaitEvents[1] := OutPipeInfo.Event; + // add the error event + if not MergeError then + begin + SetLength(WaitEvents, 3); + WaitEvents[2] := ErrorPipeInfo.Event; + end; + // add the abort event if any + if AbortEvent <> nil then + begin + AbortEvent.ResetEvent; + Index := Length(WaitEvents); + SetLength(WaitEvents, Index + 1); + WaitEvents[Index] := AbortEvent; + end; + // init the asynchronous reads + ResetMemory(OutOverlapped, SizeOf(OutOverlapped)); + OutOverlapped.hEvent := OutPipeInfo.Event.Handle; + InternalExecuteReadPipe(OutPipeInfo, OutOverlapped); + if not MergeError then + begin + ResetMemory(ErrorOverlapped, SizeOf(ErrorOverlapped)); + ErrorOverlapped.hEvent := ErrorPipeInfo.Event.Handle; + InternalExecuteReadPipe(ErrorPipeInfo, ErrorOverlapped); + end; + // event based loop + while not {$IFDEF FPC}Boolean({$ENDIF}AbortPtr^{$IFDEF FPC}){$ENDIF} do + begin + Index := WaitAlertableForMultipleObjects(WaitEvents, False, INFINITE); + if Index = WAIT_OBJECT_0 then + // the subprocess has ended + Break + else + if Index = (WAIT_OBJECT_0 + 1) then + begin + // event on output + InternalExecuteHandlePipeEvent(OutPipeInfo, OutOverlapped); + end + else + if (Index = (WAIT_OBJECT_0 + 2)) and not MergeError then + begin + // event on error + InternalExecuteHandlePipeEvent(ErrorPipeInfo, ErrorOverlapped); + end + else + if ((Index = (WAIT_OBJECT_0 + 2)) and MergeError) or + ((Index = (WAIT_OBJECT_0 + 3)) and not MergeError) then + // event on abort + AbortPtr^ := {$IFDEF FPC}Byte({$ENDIF}True{$IFDEF FPC}){$ENDIF} + else + {$IFDEF DELPHI11_UP} + RaiseLastOSError(Index); + {$ELSE} + RaiseLastOSError; + {$ENDIF DELPHI11_UP} + end; + if {$IFDEF FPC}Boolean({$ENDIF}AbortPtr^{$IFDEF FPC}){$ENDIF} then + TerminateProcess(ProcessEvent.Handle, Cardinal(ABORT_EXIT_CODE)); + if (ProcessEvent.WaitForever = wrSignaled) and not GetExitCodeProcess(ProcessEvent.Handle, Result) then + Result := $FFFFFFFF; + CloseHandle(ProcessInfo.hThread); + ProcessInfo.hThread := 0; + if OutPipeInfo.PipeRead <> 0 then + // read data remaining in output pipe + InternalExecuteFlushPipe(OutPipeinfo, OutOverlapped); + if not MergeError and (ErrorPipeInfo.PipeRead <> 0) then + // read data remaining in error pipe + InternalExecuteFlushPipe(ErrorPipeInfo, ErrorOverlapped); + except + // always terminate process in case of an exception. + // This is especially useful when an exception occured in one of + // the texthandler but only do it if the process actually started, + // this prevents eating up the last error value by calling those + // three functions with an invalid handle + // Note that we don't do it in the finally block because these + // calls would also then eat up the last error value which we tried + // to avoid in the first place + if ProcessInfo.hProcess <> 0 then + begin + TerminateProcess(ProcessInfo.hProcess, Cardinal(ABORT_EXIT_CODE)); + WaitForSingleObject(ProcessInfo.hProcess, INFINITE); + GetExitCodeProcess(ProcessInfo.hProcess, Result); + end; + + raise; + end; + end; + finally + LastError := GetLastError; + try + if OutPipeInfo.PipeRead <> 0 then + CloseHandle(OutPipeInfo.PipeRead); + if OutPipeInfo.PipeWrite <> 0 then + CloseHandle(OutPipeInfo.PipeWrite); + if ErrorPipeInfo.PipeRead <> 0 then + CloseHandle(ErrorPipeInfo.PipeRead); + if ErrorPipeInfo.PipeWrite <> 0 then + CloseHandle(ErrorPipeInfo.PipeWrite); + if ProcessInfo.hThread <> 0 then + CloseHandle(ProcessInfo.hThread); + + if Assigned(ProcessEvent) then + ProcessEvent.Free // this calls CloseHandle(ProcessInfo.hProcess) + else if ProcessInfo.hProcess <> 0 then + CloseHandle(ProcessInfo.hProcess); + OutPipeInfo.Event.Free; + ErrorPipeInfo.Event.Free; + finally + SetLastError(LastError); + end; + end; +{$ENDIF MSWINDOWS} +{$IFDEF UNIX} +var + PipeBytesRead: Cardinal; + Pipe: PIOFile; + Cmd: string; +begin + Cmd := Format('%s 2>&1', [CommandLine]); + Pipe := nil; + try + Pipe := Libc.popen(PChar(Cmd), 'r'); + { TODO : handle Abort } + repeat + PipeBytesRead := fread_unlocked(@OutBuffer, 1, BufferSize, Pipe); + if PipeBytesRead > 0 then + ProcessBuffer(OutBuffer, OutLine, PipeBytesRead); + until PipeBytesRead = 0; + Result := pclose(Pipe); + Pipe := nil; + wait(nil); + finally + if Pipe <> nil then + pclose(Pipe); + wait(nil); + end; +{$ENDIF UNIX} + if OutPipeInfo.Line <> '' then + if Assigned(OutPipeInfo.TextHandler) then + // output wasn't terminated by a line feed... + // (shouldn't happen, but you never know) + InternalExecuteProcessLine(OutPipeInfo, Length(OutPipeInfo.Line)) + else + if RawOutput then + Output := Output + OutPipeInfo.Line + else + Output := Output + InternalExecuteMuteCRTerminatedLines(OutPipeInfo.Line); + if ErrorPipeInfo.Line <> '' then + if Assigned(ErrorPipeInfo.TextHandler) then + // error wasn't terminated by a line feed... + // (shouldn't happen, but you never know) + InternalExecuteProcessLine(ErrorPipeInfo, Length(ErrorPipeInfo.Line)) + else + if RawError then + Error := Error + ErrorPipeInfo.Line + else + Error := Error + InternalExecuteMuteCRTerminatedLines(ErrorPipeInfo.Line); +end; + +{ TODO -cHelp : +RawOutput: Do not process isolated carriage returns (#13). +That is, for RawOutput = False, lines not terminated by a line feed (#10) are deleted from Output. } + +function Execute(const CommandLine: string; var Output: string; RawOutput: Boolean; + AbortPtr: PBoolean; ProcessPriority: TJclProcessPriority): Cardinal; +var + Error: string; +begin + Error := ''; + Result := InternalExecute(CommandLine, AbortPtr, nil, Output, nil, RawOutput, True, Error, nil, False, ProcessPriority); +end; + +function Execute(const CommandLine: string; AbortEvent: TJclEvent; var Output: string; RawOutput: Boolean; ProcessPriority: TJclProcessPriority): Cardinal; +var + Error: string; +begin + Error := ''; + Result := InternalExecute(CommandLine, nil, AbortEvent, Output, nil, RawOutput, True, Error, nil, False, ProcessPriority); +end; + +{ TODO -cHelp : +Author: Robert Rossmair +OutputLineCallback called once per line of output. } + +function Execute(const CommandLine: string; OutputLineCallback: TTextHandler; RawOutput: Boolean; + AbortPtr: PBoolean; ProcessPriority: TJclProcessPriority): Cardinal; +var + Output, Error: string; +begin + Output := ''; + Error := ''; + Result := InternalExecute(CommandLine, AbortPtr, nil, Output, OutputLineCallback, RawOutput, True, Error, nil, False, ProcessPriority); +end; + +function Execute(const CommandLine: string; AbortEvent: TJclEvent; OutputLineCallback: TTextHandler; RawOutput: Boolean; ProcessPriority: TJclProcessPriority): Cardinal; +var + Output, Error: string; +begin + Output := ''; + Error := ''; + Result := InternalExecute(CommandLine, nil, AbortEvent, Output, OutputLineCallback, RawOutput, True, Error, nil, False, ProcessPriority); +end; + +{ TODO -cHelp : +RawOutput: Do not process isolated carriage returns (#13). +That is, for RawOutput = False, lines not terminated by a line feed (#10) are deleted from Output. } + +function Execute(const CommandLine: string; var Output, Error: string; RawOutput, RawError: Boolean; + AbortPtr: PBoolean; ProcessPriority: TJclProcessPriority): Cardinal; +begin + Result := InternalExecute(CommandLine, AbortPtr, nil, Output, nil, RawOutput, False, Error, nil, RawError, ProcessPriority); +end; + +function Execute(const CommandLine: string; AbortEvent: TJclEvent; var Output, Error: string; + RawOutput, RawError: Boolean; ProcessPriority: TJclProcessPriority): Cardinal; +begin + Result := InternalExecute(CommandLine, nil, AbortEvent, Output, nil, RawOutput, False, Error, nil, RawError, ProcessPriority); +end; + +{ TODO -cHelp : +Author: Robert Rossmair +OutputLineCallback called once per line of output. } + +function Execute(const CommandLine: string; OutputLineCallback, ErrorLineCallback: TTextHandler; + RawOutput, RawError: Boolean; AbortPtr: PBoolean; ProcessPriority: TJclProcessPriority): Cardinal; +var + Output, Error: string; +begin + Output := ''; + Error := ''; + Result := InternalExecute(CommandLine, AbortPtr, nil, Output, OutputLineCallback, RawOutput, False, Error, ErrorLineCallback, RawError, ProcessPriority); +end; + +function Execute(const CommandLine: string; AbortEvent: TJclEvent; OutputLineCallback, ErrorLineCallback: TTextHandler; + RawOutput, RawError: Boolean; ProcessPriority: TJclProcessPriority): Cardinal; +var + Output, Error: string; +begin + Output := ''; + Error := ''; + Result := InternalExecute(CommandLine, nil, AbortEvent, Output, OutputLineCallback, RawOutput, False, Error, ErrorLineCallback, RawError, ProcessPriority); +end; + +//=== { TJclCommandLineTool } ================================================ + +constructor TJclCommandLineTool.Create(const AExeName: string); +begin + inherited Create; + FOptions := TStringList.Create; + FExeName := AExeName; +end; + +destructor TJclCommandLineTool.Destroy; +begin + FreeAndNil(FOptions); + inherited Destroy; +end; + +procedure TJclCommandLineTool.AddPathOption(const Option, Path: string); +var + S: string; +begin + S := PathRemoveSeparator(Path); + {$IFDEF MSWINDOWS} + S := LowerCase(S); // file names are case insensitive + {$ENDIF MSWINDOWS} + S := Format('-%s%s', [Option, S]); + // avoid duplicate entries (note that search is case sensitive) + if GetOptions.IndexOf(S) = -1 then + GetOptions.Add(S); +end; + +function TJclCommandLineTool.Execute(const CommandLine: string): Boolean; +begin + if Assigned(FOutputCallback) then + Result := JclSysUtils.Execute(Format('"%s" %s', [ExeName, CommandLine]), FOutputCallback) = 0 + else + Result := JclSysUtils.Execute(Format('"%s" %s', [ExeName, CommandLine]), FOutput) = 0; +end; + +function TJclCommandLineTool.GetExeName: string; +begin + Result := FExeName; +end; + +function TJclCommandLineTool.GetOptions: TStrings; +begin + Result := FOptions; +end; + +function TJclCommandLineTool.GetOutput: string; +begin + Result := FOutput; +end; + +function TJclCommandLineTool.GetOutputCallback: TTextHandler; +begin + Result := FOutputCallback; +end; + +procedure TJclCommandLineTool.SetOutputCallback(const CallbackMethod: TTextHandler); +begin + FOutputCallback := CallbackMethod; +end; + +//=== Console Utilities ====================================================== + +{$IFNDEF WINSCP} +function ReadKey: Char; +{$IFDEF MSWINDOWS} +{ TODO -cHelp : Contributor: Robert Rossmair } +var + Console: TJclConsole; + InputMode: TJclConsoleInputModes; +begin + Console := TJclConsole.Default; + InputMode := Console.Input.Mode; + Console.Input.Mode := [imProcessed]; + Console.Input.Clear; + Result := Char(Console.Input.GetEvent.Event.KeyEvent.AsciiChar); + Console.Input.Mode := InputMode; +end; +{$ENDIF MSWINDOWS} +{$IFDEF UNIX} +{ TODO -cHelp : Donator: Wayne Sherman } +var + ReadFileDescriptor: TFDSet; + TimeVal: TTimeVal; + SaveTerminalSettings: TTermIos; + RawTerminalSettings: TTermIos; +begin + Result := #0; + + //Save Original Terminal Settings + tcgetattr(stdin, SaveTerminalSettings); + tcgetattr(stdin, RawTerminalSettings); + + //Put Terminal in RAW mode + cfmakeraw(RawTerminalSettings); + tcsetattr(stdin, TCSANOW, RawTerminalSettings); + try + //Setup file I/O descriptor for STDIN + FD_ZERO(ReadFileDescriptor); + FD_SET(stdin, ReadFileDescriptor); + TimeVal.tv_sec := High(LongInt); //wait forever + TimeVal.tv_usec := 0; + + //clear keyboard buffer first + TCFlush(stdin, TCIFLUSH); + + //wait for a key to be pressed + if select(1, @ReadFileDescriptor, nil, nil, @TimeVal) > 0 then + begin + //Now read the character + Result := Char(getchar); + end + else + raise EJclError.CreateRes(@RsReadKeyError); + finally + //Restore Original Terminal Settings + tcsetattr(stdin, TCSANOW, SaveTerminalSettings); + end; +end; +{$ENDIF UNIX} +{$ENDIF ~WINSCP} + +//=== Loading of modules (DLLs) ============================================== + +function LoadModule(var Module: TModuleHandle; FileName: string): Boolean; +{$IFDEF MSWINDOWS} +begin + if Module = INVALID_MODULEHANDLE_VALUE then + Module := SafeLoadLibrary(FileName); + Result := Module <> INVALID_MODULEHANDLE_VALUE; +end; +{$ENDIF MSWINDOWS} +{$IFDEF UNIX} +begin + if Module = INVALID_MODULEHANDLE_VALUE then + Module := dlopen(PChar(FileName), RTLD_NOW); + Result := Module <> INVALID_MODULEHANDLE_VALUE; +end; +{$ENDIF UNIX} + +function LoadModuleEx(var Module: TModuleHandle; FileName: string; Flags: Cardinal): Boolean; +{$IFDEF MSWINDOWS} +begin + if Module = INVALID_MODULEHANDLE_VALUE then + Module := LoadLibraryEx(PChar(FileName), 0, Flags); // SafeLoadLibrary? + Result := Module <> INVALID_MODULEHANDLE_VALUE; +end; +{$ENDIF MSWINDOWS} +{$IFDEF UNIX} +begin + if Module = INVALID_MODULEHANDLE_VALUE then + Module := dlopen(PChar(FileName), Flags); + Result := Module <> INVALID_MODULEHANDLE_VALUE; +end; +{$ENDIF UNIX} + +procedure UnloadModule(var Module: TModuleHandle); +{$IFDEF MSWINDOWS} +begin + if Module <> INVALID_MODULEHANDLE_VALUE then + FreeLibrary(Module); + Module := INVALID_MODULEHANDLE_VALUE; +end; +{$ENDIF MSWINDOWS} +{$IFDEF UNIX} +begin + if Module <> INVALID_MODULEHANDLE_VALUE then + dlclose(Pointer(Module)); + Module := INVALID_MODULEHANDLE_VALUE; +end; +{$ENDIF UNIX} + +function GetModuleSymbol(Module: TModuleHandle; SymbolName: string): Pointer; +{$IFDEF MSWINDOWS} +begin + Result := nil; + if Module <> INVALID_MODULEHANDLE_VALUE then + Result := GetProcAddress(Module, PChar(SymbolName)); +end; +{$ENDIF MSWINDOWS} +{$IFDEF UNIX} +begin + Result := nil; + if Module <> INVALID_MODULEHANDLE_VALUE then + Result := dlsym(Module, PChar(SymbolName)); +end; +{$ENDIF UNIX} + +function GetModuleSymbolEx(Module: TModuleHandle; SymbolName: string; var Accu: Boolean): Pointer; +{$IFDEF MSWINDOWS} +begin + Result := nil; + if Module <> INVALID_MODULEHANDLE_VALUE then + Result := GetProcAddress(Module, PChar(SymbolName)); + Accu := Accu and (Result <> nil); +end; +{$ENDIF MSWINDOWS} +{$IFDEF UNIX} +begin + Result := nil; + if Module <> INVALID_MODULEHANDLE_VALUE then + Result := dlsym(Module, PChar(SymbolName)); + Accu := Accu and (Result <> nil); +end; +{$ENDIF UNIX} + +function ReadModuleData(Module: TModuleHandle; SymbolName: string; var Buffer; Size: Cardinal): Boolean; +var + Sym: Pointer; +begin + Result := True; + Sym := GetModuleSymbolEx(Module, SymbolName, Result); + if Result then + Move(Sym^, Buffer, Size); +end; + +function WriteModuleData(Module: TModuleHandle; SymbolName: string; var Buffer; Size: Cardinal): Boolean; +var + Sym: Pointer; +begin + Result := True; + Sym := GetModuleSymbolEx(Module, SymbolName, Result); + if Result then + Move(Buffer, Sym^, Size); +end; + +//=== Conversion Utilities =================================================== + +const + DefaultTrueBoolStr = 'True'; // DO NOT LOCALIZE + DefaultFalseBoolStr = 'False'; // DO NOT LOCALIZE + + DefaultYesBoolStr = 'Yes'; // DO NOT LOCALIZE + DefaultNoBoolStr = 'No'; // DO NOT LOCALIZE + +function StrToBoolean(const S: string): Boolean; +var + LowerCasedText: string; +begin + { TODO : Possibility to add localized strings, like in Delphi 7 } + { TODO : Lower case constants } + LowerCasedText := LowerCase(S); + Result := ((S = '1') or + (LowerCasedText = LowerCase(DefaultTrueBoolStr)) or (LowerCasedText = LowerCase(DefaultYesBoolStr))) or + (LowerCasedText = LowerCase(DefaultTrueBoolStr[1])) or (LowerCasedText = LowerCase(DefaultYesBoolStr[1])); + if not Result then + begin + Result := not ((S = '0') or + (LowerCasedText = LowerCase(DefaultFalseBoolStr)) or (LowerCasedText = LowerCase(DefaultNoBoolStr)) or + (LowerCasedText = LowerCase(DefaultFalseBoolStr[1])) or (LowerCasedText = LowerCase(DefaultNoBoolStr[1]))); + if Result then + raise EJclConversionError.CreateResFmt(@RsStringToBoolean, [S]); + end; +end; + +function BooleanToStr(B: Boolean): string; +begin + if B then + Result := DefaultTrueBoolStr + else + Result := DefaultFalseBoolStr; +end; + +function IntToBool(I: Integer): Boolean; +begin + Result := I <> 0; +end; + +function BoolToInt(B: Boolean): Integer; +begin + Result := Ord(B); +end; + +function TryStrToUInt(const Value: string; out Res: Cardinal): Boolean; +var i6: Int64; +begin + Result := false; + if not TryStrToInt64(Value, i6) then exit; + if ( i6 < Low(Res)) or ( i6 > High(Res)) then exit; + + Result := true; + Res := i6; +end; + +function StrToUIntDef(const Value: string; const Default: Cardinal): Cardinal; +begin + if not TryStrToUInt(Value, Result) + then Result := Default; +end; + +function StrToUInt(const Value: string): Cardinal; +begin + if not TryStrToUInt(Value, Result) + then raise EConvertError.Create('"'+Value+'" is not within range of Cardinal data type'); +end; + +//=== RTL package information ================================================ + +function SystemTObjectInstance: TJclAddr; +begin + Result := ModuleFromAddr(Pointer(System.TObject)); +end; + +function IsCompiledWithPackages: Boolean; +begin + Result := SystemTObjectInstance <> HInstance; +end; + +//=== GUID =================================================================== + +function JclGUIDToString(const GUID: TGUID): string; +begin + Result := Format('{%.8x-%.4x-%.4x-%.2x%.2x-%.2x%.2x%.2x%.2x%.2x%.2x}', + [GUID.D1, GUID.D2, GUID.D3, GUID.D4[0], GUID.D4[1], GUID.D4[2], + GUID.D4[3], GUID.D4[4], GUID.D4[5], GUID.D4[6], GUID.D4[7]]); +end; + +function JclStringToGUID(const S: string): TGUID; +begin + if (Length(S) <> 38) or (S[1] <> '{') or (S[10] <> '-') or (S[15] <> '-') or + (S[20] <> '-') or (S[25] <> '-') or (S[38] <> '}') then + raise EJclConversionError.CreateResFmt(@RsInvalidGUIDString, [S]); + + Result.D1 := StrToInt('$' + Copy(S, 2, 8)); + Result.D2 := StrToInt('$' + Copy(S, 11, 4)); + Result.D3 := StrToInt('$' + Copy(S, 16, 4)); + Result.D4[0] := StrToInt('$' + Copy(S, 21, 2)); + Result.D4[1] := StrToInt('$' + Copy(S, 23, 2)); + Result.D4[2] := StrToInt('$' + Copy(S, 26, 2)); + Result.D4[3] := StrToInt('$' + Copy(S, 28, 2)); + Result.D4[4] := StrToInt('$' + Copy(S, 30, 2)); + Result.D4[5] := StrToInt('$' + Copy(S, 32, 2)); + Result.D4[6] := StrToInt('$' + Copy(S, 34, 2)); + Result.D4[7] := StrToInt('$' + Copy(S, 36, 2)); +end; + +function GUIDEquals(const GUID1, GUID2: TGUID): Boolean; +begin + Result := (GUID1.D1 = GUID2.D1) and (GUID1.D2 = GUID2.D2) and (GUID1.D3 = GUID2.D3) and + (GUID1.D4[0] = GUID2.D4[0]) and (GUID1.D4[1] = GUID2.D4[1]) and + (GUID1.D4[2] = GUID2.D4[2]) and (GUID1.D4[3] = GUID2.D4[3]) and + (GUID1.D4[4] = GUID2.D4[4]) and (GUID1.D4[5] = GUID2.D4[5]) and + (GUID1.D4[6] = GUID2.D4[6]) and (GUID1.D4[7] = GUID2.D4[7]); +end; + +// add items at the end +procedure ListAddItems(var List: string; const Separator, Items: string); +var + StrList, NewItems: TStringList; + Index: Integer; +begin + StrList := TStringList.Create; + try + StrToStrings(List, Separator, StrList, False); + + NewItems := TStringList.Create; + try + StrToStrings(Items, Separator, NewItems); + + for Index := 0 to NewItems.Count - 1 do + StrList.Add(NewItems.Strings[Index]); + + List := StringsToStr(StrList, Separator); + finally + NewItems.Free; + end; + finally + StrList.Free; + end; +end; + +// add items at the end if they are not present +procedure ListIncludeItems(var List: string; const Separator, Items: string); +var + StrList, NewItems: TStringList; + Index: Integer; + Item: string; +begin + StrList := TStringList.Create; + try + StrToStrings(List, Separator, StrList, False); + + NewItems := TStringList.Create; + try + StrToStrings(Items, Separator, NewItems); + + for Index := 0 to NewItems.Count - 1 do + begin + Item := NewItems.Strings[Index]; + if StrList.IndexOf(Item) = -1 then + StrList.Add(Item); + end; + + List := StringsToStr(StrList, Separator); + finally + NewItems.Free; + end; + finally + StrList.Free; + end; +end; + +// delete multiple items +procedure ListRemoveItems(var List: string; const Separator, Items: string); +var + StrList, RemItems: TStringList; + Index, Position: Integer; + Item: string; +begin + StrList := TStringList.Create; + try + StrToStrings(List, Separator, StrList, False); + + RemItems := TStringList.Create; + try + StrToStrings(Items, Separator, RemItems, False); + + for Index := 0 to RemItems.Count - 1 do + begin + Item := RemItems.Strings[Index]; + repeat + Position := StrList.IndexOf(Item); + if Position >= 0 then + StrList.Delete(Position); + until Position < 0; + end; + + List := StringsToStr(StrList, Separator); + finally + RemItems.Free; + end; + finally + StrList.Free; + end; +end; + +// delete one item +procedure ListDelItem(var List: string; const Separator: string; const Index: Integer); +var + StrList: TStringList; +begin + StrList := TStringList.Create; + try + StrToStrings(List, Separator, StrList, False); + + StrList.Delete(Index); + + List := StringsToStr(StrList, Separator); + finally + StrList.Free; + end; +end; + +// return the number of item +function ListItemCount(const List, Separator: string): Integer; +var + StrList: TStringList; +begin + StrList := TStringList.Create; + try + StrToStrings(List, Separator, StrList, False); + + Result := StrList.Count; + finally + StrList.Free; + end; +end; + +// return the Nth item +function ListGetItem(const List, Separator: string; const Index: Integer): string; +var + StrList: TStringList; +begin + StrList := TStringList.Create; + try + StrToStrings(List, Separator, StrList, False); + + Result := StrList.Strings[Index]; + finally + StrList.Free; + end; +end; + +// set the Nth item +procedure ListSetItem(var List: string; const Separator: string; + const Index: Integer; const Value: string); +var + StrList: TStringList; +begin + StrList := TStringList.Create; + try + StrToStrings(List, Separator, StrList, False); + + StrList.Strings[Index] := Value; + + List := StringsToStr(StrList, Separator); + finally + StrList.Free; + end; +end; + +// return the index of an item +function ListItemIndex(const List, Separator, Item: string): Integer; +var + StrList: TStringList; +begin + StrList := TStringList.Create; + try + StrToStrings(List, Separator, StrList, False); + + Result := StrList.IndexOf(Item); + finally + StrList.Free; + end; +end; + +//=== { TJclIntfCriticalSection } ============================================ + +constructor TJclIntfCriticalSection.Create; +begin + inherited Create; + FCriticalSection := TCriticalSection.Create; +end; + +destructor TJclIntfCriticalSection.Destroy; +begin + FCriticalSection.Free; + inherited Destroy; +end; + +function TJclIntfCriticalSection._AddRef: Integer; +begin + FCriticalSection.Acquire; + Result := -1; +end; + +function TJclIntfCriticalSection._Release: Integer; +begin + FCriticalSection.Release; + Result := -1; +end; + +{$IFNDEF WINSCP} + +//=== { TJclSimpleLog } ====================================================== + +{$IFDEF LINUX} +const + INVALID_HANDLE_VALUE = 0; +{$ENDIF LINUX} + +constructor TJclSimpleLog.Create(const ALogFileName: string = ''); +begin + if ALogFileName = '' then + FLogFileName := CreateDefaultFileName + else + FLogFileName := ALogFileName; + FLogFileHandle := TFileHandle(INVALID_HANDLE_VALUE); + FLoggingActive := True; +end; + +function TJclSimpleLog.CreateDefaultFileName: string; +begin + Result := PathExtractFileDirFixed(ParamStr(0)) + + PathExtractFileNameNoExt(ParamStr(0)) + '_Err.log'; +end; + +destructor TJclSimpleLog.Destroy; +begin + CloseLog; + inherited Destroy; +end; + +procedure TJclSimpleLog.ClearLog; +var + WasOpen: Boolean; +begin + WasOpen := LogOpen; + if WasOpen then + CloseLog; + if not FileExists(FlogFileName) then + Exit; + FLogFileHandle := FileCreate(FLogFileName); + FLogWasEmpty := True; + if Not WasOpen then + CloseLog; +end; + +procedure TJclSimpleLog.CloseLog; +begin + if LogOpen then + begin + FileClose(FLogFileHandle); + FLogFileHandle := TFileHandle(INVALID_HANDLE_VALUE); + FLogWasEmpty := False; + end; +end; + +function TJclSimpleLog.GetLogOpen: Boolean; +begin + Result := DWORD_PTR(FLogFileHandle) <> INVALID_HANDLE_VALUE; +end; + +procedure TJclSimpleLog.OpenLog; +begin + if not LogOpen then + begin + FLogFileHandle := FileOpen(FLogFileName, fmOpenWrite or fmShareDenyWrite); + if LogOpen then + FLogWasEmpty := FileSeek(FLogFileHandle, 0, soFromEnd) = 0 + else + begin + FLogFileHandle := FileCreate(FLogFileName); + FLogWasEmpty := True; + if LogOpen then + FileWrite(FLogFileHandle, BOM_UTF8[0], Length(BOM_UTF8)); + end; + end + else + FLogWasEmpty := False; +end; + +procedure TJclSimpleLog.Write(const Text: string; Indent: Integer = 0; KeepOpen: Boolean = true); +var + S: string; + UTF8S: TUTF8String; + SL: TStringList; + I: Integer; + WasOpen: Boolean; +begin + if LoggingActive then + begin + WasOpen := LogOpen; + if not WasOpen then + OpenLog; + if LogOpen then + begin + SL := TStringList.Create; + try + SL.Text := Text; + for I := 0 to SL.Count - 1 do + begin + S := StringOfChar(' ', Indent) + StrEnsureSuffix(NativeLineBreak, TrimRight(SL[I])); + UTF8S := StringToUTF8(S); + FileWrite(FLogFileHandle, UTF8S[1], Length(UTF8S)); + end; + finally + SL.Free; + end; + // Keep the logfile Open when it was opened before and the KeepOpen is active + if Not (WasOpen and KeepOpen) then + CloseLog; + end; + end; +end; + +procedure TJclSimpleLog.Write(Strings: TStrings; Indent: Integer = 0; KeepOpen: Boolean = true); +begin + if Assigned(Strings) then + Write(Strings.Text, Indent, KeepOpen); +end; + +procedure TJclSimpleLog.TimeWrite(const Text: string; Indent: Integer = 0; KeepOpen: Boolean = true); +var + S: string; + UTF8S: TUTF8String; + SL: TStringList; + I: Integer; + WasOpen: Boolean; +begin + if LoggingActive then + begin + WasOpen := LogOpen; + if not LogOpen then + OpenLog; + if LogOpen then + begin + SL := TStringList.Create; + try + SL.Text := Text; + for I := 0 to SL.Count - 1 do + begin + if DateTimeFormatStr = '' then + S := DateTimeToStr(Now)+' : '+StringOfChar(' ', Indent) + StrEnsureSuffix(NativeLineBreak, TrimRight(SL[I])) + else + S := FormatDateTime( DateTimeFormatStr, Now)+' : '+StringOfChar(' ', Indent) + StrEnsureSuffix(NativeLineBreak, TrimRight(SL[I])); + UTF8S := StringToUTF8(S); + FileWrite(FLogFileHandle, UTF8S[1], Length(UTF8S)); + end; + finally + SL.Free; + end; + if Not WasOpen and Not KeepOpen then + CloseLog; + end; + end; +end; + +procedure TJclSimpleLog.TimeWrite(Strings: TStrings; Indent: Integer = 0; KeepOpen: Boolean = true); +begin + if Assigned(Strings) then + TimeWrite(Strings.Text, Indent, KeepOpen); +end; + +procedure TJclSimpleLog.WriteStamp(SeparatorLen: Integer = 0; KeepOpen: Boolean = true); +var + WasOpen: Boolean; +begin + if SeparatorLen <= 0 then + SeparatorLen := 40; + if LoggingActive then + begin + WasOpen := LogOpen; + if not LogOpen then + begin + OpenLog; + if LogOpen and not FLogWasEmpty then + Write(NativeLineBreak); + end; + if LogOpen then + begin + Write(StrRepeat('=', SeparatorLen), 0, True); + if DateTimeFormatStr = '' then + Write(Format('= %-*s =', [SeparatorLen - 4, DateTimeToStr(Now)]), 0, True) + else + Write(Format('= %-*s =', [SeparatorLen - 4, FormatDateTime( DateTimeFormatStr, Now)]), 0, True); + Write(StrRepeat('=', SeparatorLen), 0, True); + if Not WasOpen and Not KeepOpen then + CloseLog; + end; + end; +end; + +procedure InitSimpleLog(const ALogFileName: string = ''; AOpenLog: Boolean = true); +begin + if Assigned(SimpleLog) then + FreeAndNil(SimpleLog); + SimpleLog := TJclSimpleLog.Create(ALogFileName); + if AOpenLog then + SimpleLog.OpenLog; +end; + +{$ENDIF ~WINSCP} + +function TJclFormatSettings.GetCurrencyDecimals: Byte; +begin +{$IFDEF RTL220_UP} + Result := FormatSettings.CurrencyDecimals; +{$ELSE} + Result := SysUtils.CurrencyDecimals; +{$ENDIF} +end; + +function TJclFormatSettings.GetCurrencyFormat: Byte; +begin +{$IFDEF RTL220_UP} + Result := FormatSettings.CurrencyFormat; +{$ELSE} + Result := SysUtils.CurrencyFormat; +{$ENDIF} +end; + +function TJclFormatSettings.GetCurrencyString: string; +begin +{$IFDEF RTL220_UP} + Result := FormatSettings.CurrencyString; +{$ELSE} + Result := SysUtils.CurrencyString; +{$ENDIF} +end; + +function TJclFormatSettings.GetDateSeparator: Char; +begin +{$IFDEF RTL220_UP} + Result := FormatSettings.DateSeparator; +{$ELSE} + Result := SysUtils.DateSeparator; +{$ENDIF} +end; + +function TJclFormatSettings.GetDayNamesHighIndex: Integer; +begin +{$IFDEF RTL220_UP} + Result := High(FormatSettings.LongDayNames); +{$ELSE} + Result := High(SysUtils.LongDayNames); +{$ENDIF} +end; + +function TJclFormatSettings.GetDayNamesLowIndex: Integer; +begin +{$IFDEF RTL220_UP} + Result := Low(FormatSettings.LongDayNames); +{$ELSE} + Result := Low(SysUtils.LongDayNames); +{$ENDIF} +end; + +function TJclFormatSettings.GetDecimalSeparator: Char; +begin +{$IFDEF RTL220_UP} + Result := FormatSettings.DecimalSeparator; +{$ELSE} + Result := SysUtils.DecimalSeparator; +{$ENDIF} +end; + +function TJclFormatSettings.GetListSeparator: Char; +begin +{$IFDEF RTL220_UP} + Result := FormatSettings.ListSeparator; +{$ELSE} + Result := SysUtils.ListSeparator; +{$ENDIF} +end; + +function TJclFormatSettings.GetLongDateFormat: string; +begin +{$IFDEF RTL220_UP} + Result := FormatSettings.LongDateFormat; +{$ELSE} + Result := SysUtils.LongDateFormat; +{$ENDIF} +end; + +{ TJclFormatSettings } + +function TJclFormatSettings.GetLongDayNames(AIndex: Integer): string; +begin +{$IFDEF RTL220_UP} + Result := FormatSettings.LongDayNames[AIndex]; +{$ELSE} + Result := SysUtils.LongDayNames[AIndex]; +{$ENDIF} +end; + +function TJclFormatSettings.GetLongMonthNames(AIndex: Integer): string; +begin +{$IFDEF RTL220_UP} + Result := FormatSettings.LongMonthNames[AIndex]; +{$ELSE} + Result := SysUtils.LongMonthNames[AIndex]; +{$ENDIF} +end; + +function TJclFormatSettings.GetLongTimeFormat: string; +begin +{$IFDEF RTL220_UP} + Result := FormatSettings.LongTimeFormat; +{$ELSE} + Result := SysUtils.LongTimeFormat; +{$ENDIF} +end; + +function TJclFormatSettings.GetMonthNamesHighIndex: Integer; +begin +{$IFDEF RTL220_UP} + Result := High(FormatSettings.LongMonthNames); +{$ELSE} + Result := High(SysUtils.LongMonthNames); +{$ENDIF} +end; + +function TJclFormatSettings.GetMonthNamesLowIndex: Integer; +begin +{$IFDEF RTL220_UP} + Result := Low(FormatSettings.LongMonthNames); +{$ELSE} + Result := Low(SysUtils.LongMonthNames); +{$ENDIF} +end; + +function TJclFormatSettings.GetNegCurrFormat: Byte; +begin +{$IFDEF RTL220_UP} + Result := FormatSettings.NegCurrFormat; +{$ELSE} + Result := SysUtils.NegCurrFormat; +{$ENDIF} +end; + +function TJclFormatSettings.GetShortDateFormat: string; +begin +{$IFDEF RTL220_UP} + Result := FormatSettings.ShortDateFormat; +{$ELSE} + Result := SysUtils.ShortDateFormat; +{$ENDIF} +end; + +function TJclFormatSettings.GetShortDayNames(AIndex: Integer): string; +begin +{$IFDEF RTL220_UP} + Result := FormatSettings.ShortDayNames[AIndex]; +{$ELSE} + Result := SysUtils.ShortDayNames[AIndex]; +{$ENDIF} +end; + +function TJclFormatSettings.GetShortMonthNames(AIndex: Integer): string; +begin +{$IFDEF RTL220_UP} + Result := FormatSettings.ShortMonthNames[AIndex]; +{$ELSE} + Result := SysUtils.ShortMonthNames[AIndex]; +{$ENDIF} +end; + +function TJclFormatSettings.GetShortTimeFormat: string; +begin +{$IFDEF RTL220_UP} + Result := FormatSettings.ShortTimeFormat; +{$ELSE} + Result := SysUtils.ShortTimeFormat; +{$ENDIF} +end; + +function TJclFormatSettings.GetThousandSeparator: Char; +begin +{$IFDEF RTL220_UP} + Result := FormatSettings.ThousandSeparator; +{$ELSE} + Result := SysUtils.ThousandSeparator; +{$ENDIF} +end; + +function TJclFormatSettings.GetTimeAMString: string; +begin +{$IFDEF RTL220_UP} + Result := FormatSettings.TimeAMString; +{$ELSE} + Result := SysUtils.TimeAMString; +{$ENDIF} +end; + +function TJclFormatSettings.GetTimePMString: string; +begin +{$IFDEF RTL220_UP} + Result := FormatSettings.TimePMString; +{$ELSE} + Result := SysUtils.TimePMString; +{$ENDIF} +end; + +function TJclFormatSettings.GetTimeSeparator: Char; +begin +{$IFDEF RTL220_UP} + Result := FormatSettings.TimeSeparator; +{$ELSE} + Result := SysUtils.TimeSeparator; +{$ENDIF} +end; + +function TJclFormatSettings.GetTwoDigitYearCenturyWindow: Word; +begin +{$IFDEF RTL220_UP} + Result := FormatSettings.TwoDigitYearCenturyWindow; +{$ELSE} + Result := SysUtils.TwoDigitYearCenturyWindow; +{$ENDIF} +end; + +procedure TJclFormatSettings.SetCurrencyDecimals(AValue: Byte); +begin +{$IFDEF RTL220_UP} + FormatSettings.CurrencyDecimals := AValue; +{$ELSE} + SysUtils.CurrencyDecimals := AValue; +{$ENDIF} +end; + +procedure TJclFormatSettings.SetCurrencyFormat(const AValue: Byte); +begin +{$IFDEF RTL220_UP} + FormatSettings.CurrencyFormat := AValue; +{$ELSE} + SysUtils.CurrencyFormat := AValue; +{$ENDIF} +end; + +procedure TJclFormatSettings.SetCurrencyString(AValue: string); +begin +{$IFDEF RTL220_UP} + FormatSettings.CurrencyString := AValue; +{$ELSE} + SysUtils.CurrencyString := AValue; +{$ENDIF} +end; + +procedure TJclFormatSettings.SetDateSeparator(const AValue: Char); +begin +{$IFDEF RTL220_UP} + FormatSettings.DateSeparator := AValue; +{$ELSE} + SysUtils.DateSeparator := AValue; +{$ENDIF} +end; + +procedure TJclFormatSettings.SetDecimalSeparator(AValue: Char); +begin +{$IFDEF RTL220_UP} + FormatSettings.DecimalSeparator := AValue; +{$ELSE} + SysUtils.DecimalSeparator := AValue; +{$ENDIF} +end; + +procedure TJclFormatSettings.SetListSeparator(const AValue: Char); +begin +{$IFDEF RTL220_UP} + FormatSettings.ListSeparator := AValue; +{$ELSE} + SysUtils.ListSeparator := AValue; +{$ENDIF} +end; + +procedure TJclFormatSettings.SetLongDateFormat(const AValue: string); +begin +{$IFDEF RTL220_UP} + FormatSettings.LongDateFormat := AValue; +{$ELSE} + SysUtils.LongDateFormat := AValue; +{$ENDIF} +end; + +procedure TJclFormatSettings.SetLongTimeFormat(const AValue: string); +begin +{$IFDEF RTL220_UP} + FormatSettings.LongTimeFormat := AValue; +{$ELSE} + SysUtils.LongTimeFormat := AValue; +{$ENDIF} +end; + +procedure TJclFormatSettings.SetNegCurrFormat(const AValue: Byte); +begin +{$IFDEF RTL220_UP} + FormatSettings.NegCurrFormat := AValue; +{$ELSE} + SysUtils.NegCurrFormat := AValue; +{$ENDIF} +end; + +procedure TJclFormatSettings.SetShortDateFormat(AValue: string); +begin +{$IFDEF RTL220_UP} + FormatSettings.ShortDateFormat := AValue; +{$ELSE} + SysUtils.ShortDateFormat := AValue; +{$ENDIF} +end; + +procedure TJclFormatSettings.SetShortTimeFormat(const AValue: string); +begin +{$IFDEF RTL220_UP} + FormatSettings.ShortTimeFormat := AValue; +{$ELSE} + SysUtils.ShortTimeFormat := AValue; +{$ENDIF} +end; + +procedure TJclFormatSettings.SetThousandSeparator(AValue: Char); +begin +{$IFDEF RTL220_UP} + FormatSettings.TimeSeparator := AValue; +{$ELSE} + SysUtils.TimeSeparator := AValue; +{$ENDIF} +end; + +procedure TJclFormatSettings.SetTimeAMString(const AValue: string); +begin +{$IFDEF RTL220_UP} + FormatSettings.TimeAMString := AValue; +{$ELSE} + SysUtils.TimeAMString := AValue; +{$ENDIF} +end; + +procedure TJclFormatSettings.SetTimePMString(const AValue: string); +begin +{$IFDEF RTL220_UP} + FormatSettings.TimePMString := AValue; +{$ELSE} + SysUtils.TimePMString := AValue; +{$ENDIF} +end; + +procedure TJclFormatSettings.SetTimeSeparator(const AValue: Char); +begin +{$IFDEF RTL220_UP} + FormatSettings.TimeSeparator := AValue; +{$ELSE} + SysUtils.TimeSeparator := AValue; +{$ENDIF} +end; + +procedure TJclFormatSettings.SetTwoDigitYearCenturyWindow(const AValue: Word); +begin +{$IFDEF RTL220_UP} + FormatSettings.TwoDigitYearCenturyWindow:= AValue; +{$ELSE} + SysUtils.TwoDigitYearCenturyWindow:= AValue; +{$ENDIF} +end; + +function VarIsNullEmpty(const V: Variant): Boolean; +begin + Result := VarIsNull(V) or VarIsEmpty(V); +end; + +function VarIsNullEmptyBlank(const V: Variant): Boolean; +begin + Result := VarIsNull(V) or VarIsEmpty(V) or (VarToStr(V) = ''); +end; + + + +initialization + {$IFNDEF WINSCP} + SimpleLog := nil; + {$ENDIF ~WINSCP} + {$IFDEF UNITVERSIONING} + RegisterUnitVersion(HInstance, UnitVersioning); + {$ENDIF UNITVERSIONING} + +finalization + {$IFDEF UNITVERSIONING} + UnregisterUnitVersion(HInstance); + {$ENDIF UNITVERSIONING} + {$IFDEF MSWINDOWS} + {$IFDEF THREADSAFE} + // The user must release shared memory blocks himself. We don't clean up his + // memory leaks and make it impossible to release the shared memory in other + // unit's finalization blocks. + MMFFinalized := True; + FreeAndNil(GlobalMMFHandleListCS); + {$ENDIF THREADSAFE} + {$ENDIF MSWINDOWS} + {$IFNDEF WINSCP} + if Assigned(SimpleLog) then + FreeAndNil(SimpleLog); + {$ENDIF ~WINSCP} +end. diff --git a/source/packages/jcl/JclWin32.pas b/source/packages/jcl/JclWin32.pas new file mode 100644 index 00000000..23448d58 --- /dev/null +++ b/source/packages/jcl/JclWin32.pas @@ -0,0 +1,9301 @@ +{**************************************************************************************************} +{ WARNING: JEDI preprocessor generated unit. Do not edit. } +{**************************************************************************************************} + +{**************************************************************************************************} +{ } +{ Project JEDI Code Library (JCL) } +{ } +{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); } +{ you may not use this file except in compliance with the License. You may obtain a copy of the } +{ License at http://www.mozilla.org/MPL/ } +{ } +{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF } +{ ANY KIND, either express or implied. See the License for the specific language governing rights } +{ and limitations under the License. } +{ } +{ Portions of this code are translated from DelayImp.h. } +{ The Initial Developer of DelayImp.h is Inprise Corporation. Portions created by Inprise } +{ Corporation are Copyright (C) 1999, 2000 by Inprise Corporation. All Rights Reserved. } +{ } +{ The Original Code is JclWin32.pas. } +{ } +{ The Initial Developer of the Original Code is Marcel van Brakel. Portions created by Marcel van } +{ Brakel are Copyright (C) Marcel van Brakel. All Rights Reserved. } +{ } +{ Contributors: } +{ Marcel van Brakel } +{ Peter Friese } +{ Andreas Hausladen (ahuser) } +{ Flier Lu (flier) } +{ Robert Marquardt (marquardt) } +{ Robert Rossmair (rrossmair) } +{ Olivier Sannier (obones) } +{ Matthias Thoma (mthoma) } +{ Petr Vones (pvones) } +{ Florent Ouchet (outchy) } +{ } +{**************************************************************************************************} +{ } +{ This unit defines various Win32 API declarations which are either missing or incorrect in one or } +{ more of the supported Delphi versions. This unit is not intended for regular code, only API } +{ declarations. } +{ } +{**************************************************************************************************} +{ } +{ Last modified: $Date:: $ } +{ Revision: $Rev:: $ } +{ Author: $Author:: $ } +{ } +{**************************************************************************************************} + +unit JclWin32; + +{$I jcl.inc} +{$I windowsonly.inc} + +{$MINENUMSIZE 4} +{$ALIGN ON} + +interface + +uses + {$IFDEF UNITVERSIONING} + JclUnitVersioning, + {$ENDIF UNITVERSIONING} + {$IFDEF HAS_UNITSCOPE} + Winapi.Windows, System.SysUtils, + {$IFNDEF FPC} + Winapi.AccCtrl, Winapi.ActiveX, + {$ENDIF ~FPC} + {$ELSE ~HAS_UNITSCOPE} + Windows, SysUtils, + {$IFNDEF FPC} + AccCtrl, + {$ENDIF ~FPC} + ActiveX, + {$ENDIF ~HAS_UNITSCOPE} + JclBase; + +{$HPPEMIT '#include '} +{$HPPEMIT '#include '} +{$HPPEMIT '#include '} +{$HPPEMIT '#include '} +{$HPPEMIT '#include '} +{$HPPEMIT '#include '} +{$HPPEMIT '#include '} +{$HPPEMIT '#include '} +{$HPPEMIT '#include '} +{$HPPEMIT '#include '} +{$HPPEMIT '#include '} +{$HPPEMIT '#include '} +{$HPPEMIT '#include '} +//{$HPPEMIT '#include '} +{$HPPEMIT '#include '} +{$HPPEMIT '#include '} +{$HPPEMIT '#include '} +{$HPPEMIT '#include '} +{$IFNDEF COMPILER14_UP} +{$HPPEMIT '#include '} +{$ENDIF ~COMPILER14_UP} +{$HPPEMIT '#include '} +{$HPPEMIT '#include '} +{$HPPEMIT ''} +{$IFDEF RTL230_UP} +{$HPPEMIT '// To avoid ambiguity between IMAGE_LOAD_CONFIG_DIRECTORY32 and Winapi::Windows::IMAGE_LOAD_CONFIG_DIRECTORY32'} +{$HPPEMIT '#define IMAGE_LOAD_CONFIG_DIRECTORY32 ::IMAGE_LOAD_CONFIG_DIRECTORY32'} +{$HPPEMIT ''} +{$HPPEMIT '// To avoid ambiguity between IMAGE_LOAD_CONFIG_DIRECTORY64 and Winapi::Windows::IMAGE_LOAD_CONFIG_DIRECTORY64'} +{$HPPEMIT '#define IMAGE_LOAD_CONFIG_DIRECTORY64 ::IMAGE_LOAD_CONFIG_DIRECTORY64'} +{$HPPEMIT ''} +{$ENDIF RTL230_UP} + +// EJclWin32Error +type + EJclWin32Error = class(EJclError) + private + FLastError: DWORD; + FLastErrorMsg: string; + public + constructor Create(const Msg: string); + constructor CreateFmt(const Msg: string; const Args: array of const); + constructor CreateRes(Ident: Integer); overload; + constructor CreateRes(ResStringRec: PResStringRec); overload; + property LastError: DWORD read FLastError; + property LastErrorMsg: string read FLastErrorMsg; + end; + +//DOM-IGNORE-BEGIN + +{$IFNDEF FPC} + +// +// Unsigned Basics +// + +type + USHORT = Word; + {$EXTERNALSYM USHORT} + +{$ENDIF ~FPC} +//================================================================================================== +// presumable from any older WinNT.h or from WinIfs.h +//================================================================================================== + +//-------------------------------------------------------------------------------------------------- +// NTFS Reparse Points +//-------------------------------------------------------------------------------------------------- + +// The reparse structure is used by layered drivers to store data in a +// reparse point. The constraints on reparse tags are defined below. +// This version of the reparse data buffer is only for Microsoft tags. + +(*$HPPEMIT 'typedef struct _REPARSE_DATA_BUFFER {'*) +(*$HPPEMIT ''*) +(*$HPPEMIT ' DWORD ReparseTag;'*) +(*$HPPEMIT ' WORD ReparseDataLength;'*) +(*$HPPEMIT ' WORD Reserved;'*) +(*$HPPEMIT ''*) +(*$HPPEMIT ' union {'*) +(*$HPPEMIT ''*) +(*$HPPEMIT ' struct {'*) +(*$HPPEMIT ' WORD SubstituteNameOffset;'*) +(*$HPPEMIT ' WORD SubstituteNameLength;'*) +(*$HPPEMIT ' WORD PrintNameOffset;'*) +(*$HPPEMIT ' WORD PrintNameLength;'*) +(*$HPPEMIT ' WCHAR PathBuffer[1];'*) +(*$HPPEMIT ' } SymbolicLinkReparseBuffer;'*) +(*$HPPEMIT ''*) +(*$HPPEMIT ' struct {'*) +(*$HPPEMIT ' WORD SubstituteNameOffset;'*) +(*$HPPEMIT ' WORD SubstituteNameLength;'*) +(*$HPPEMIT ' WORD PrintNameOffset;'*) +(*$HPPEMIT ' WORD PrintNameLength;'*) +(*$HPPEMIT ' WCHAR PathBuffer[1];'*) +(*$HPPEMIT ' } MountPointReparseBuffer;'*) +(*$HPPEMIT ''*) +(*$HPPEMIT ' struct {'*) +(*$HPPEMIT ' UCHAR DataBuffer[1];'*) +(*$HPPEMIT ' } GenericReparseBuffer;'*) +(*$HPPEMIT ' };'*) +(*$HPPEMIT ''*) +(*$HPPEMIT '} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;'*) +(*$HPPEMIT ''*) +(*$HPPEMIT '#ifndef REPARSE_DATA_BUFFER_HEADER_SIZE'*) +(*$HPPEMIT '#define REPARSE_DATA_BUFFER_HEADER_SIZE 8'*) +(*$HPPEMIT '#endif'*) +(*$HPPEMIT ''*) +(*$HPPEMIT 'typedef struct _REPARSE_POINT_INFORMATION {'*) +(*$HPPEMIT ' WORD ReparseDataLength;'*) +(*$HPPEMIT ' WORD UnparsedNameLength;'*) +(*$HPPEMIT '} REPARSE_POINT_INFORMATION, *PREPARSE_POINT_INFORMATION;'*) +(*$HPPEMIT ''*) +(*$HPPEMIT '#ifndef IO_REPARSE_TAG_VALID_VALUES'*) +(*$HPPEMIT '#define IO_REPARSE_TAG_VALID_VALUES 0x0E000FFFF'*) +(*$HPPEMIT '#endif'*) +(*$HPPEMIT ''*) + +type + {$EXTERNALSYM _REPARSE_DATA_BUFFER} + _REPARSE_DATA_BUFFER = record + ReparseTag: DWORD; + ReparseDataLength: Word; + Reserved: Word; + case Integer of + 0: ( // SymbolicLinkReparseBuffer and MountPointReparseBuffer + SubstituteNameOffset: Word; + SubstituteNameLength: Word; + PrintNameOffset: Word; + PrintNameLength: Word; + PathBuffer: array [0..0] of WCHAR); + 1: ( // GenericReparseBuffer + DataBuffer: array [0..0] of Byte); + end; + {$EXTERNALSYM REPARSE_DATA_BUFFER} + REPARSE_DATA_BUFFER = _REPARSE_DATA_BUFFER; + {$EXTERNALSYM PREPARSE_DATA_BUFFER} + PREPARSE_DATA_BUFFER = ^_REPARSE_DATA_BUFFER; + TReparseDataBuffer = _REPARSE_DATA_BUFFER; + PReparseDataBuffer = PREPARSE_DATA_BUFFER; + +const + {$EXTERNALSYM REPARSE_DATA_BUFFER_HEADER_SIZE} + REPARSE_DATA_BUFFER_HEADER_SIZE = 8; + +type + {$EXTERNALSYM _REPARSE_POINT_INFORMATION} + _REPARSE_POINT_INFORMATION = record + ReparseDataLength: Word; + UnparsedNameLength: Word; + end; + {$EXTERNALSYM REPARSE_POINT_INFORMATION} + REPARSE_POINT_INFORMATION = _REPARSE_POINT_INFORMATION; + {$EXTERNALSYM PREPARSE_POINT_INFORMATION} + PREPARSE_POINT_INFORMATION = ^_REPARSE_POINT_INFORMATION; + TReparsePointInformation = _REPARSE_POINT_INFORMATION; + PReparsePointInformation = PREPARSE_POINT_INFORMATION; + +const + {$EXTERNALSYM IO_REPARSE_TAG_VALID_VALUES} + IO_REPARSE_TAG_VALID_VALUES = DWORD($E000FFFF); + +//================================================================================================== + +// from JwaWinNT.pas (few declarations from JwaWinType) + +const + MAXLONGLONG = $7fffffffffffffff; + {$EXTERNALSYM MAXLONGLONG} + +{$IFNDEF FPC} +type + ULONGLONG = Int64; + {$EXTERNALSYM ULONGLONG} + PLONGLONG = ^LONGLONG; + {$EXTERNALSYM PLONGLONG} + PULONGLONG = ^ULONGLONG; + {$EXTERNALSYM PULONGLONG} +{$ENDIF ~FPC} + +const + ANYSIZE_ARRAY = 1; + {$EXTERNALSYM ANYSIZE_ARRAY} + + MAX_NATURAL_ALIGNMENT = SizeOf(ULONG); + {$EXTERNALSYM MAX_NATURAL_ALIGNMENT} + +// line 72 + +const + VER_SERVER_NT = DWORD($80000000); + {$EXTERNALSYM VER_SERVER_NT} + VER_WORKSTATION_NT = $40000000; + {$EXTERNALSYM VER_WORKSTATION_NT} + VER_SUITE_SMALLBUSINESS = $00000001; + {$EXTERNALSYM VER_SUITE_SMALLBUSINESS} + VER_SUITE_ENTERPRISE = $00000002; + {$EXTERNALSYM VER_SUITE_ENTERPRISE} + VER_SUITE_BACKOFFICE = $00000004; + {$EXTERNALSYM VER_SUITE_BACKOFFICE} + VER_SUITE_COMMUNICATIONS = $00000008; + {$EXTERNALSYM VER_SUITE_COMMUNICATIONS} + VER_SUITE_TERMINAL = $00000010; + {$EXTERNALSYM VER_SUITE_TERMINAL} + VER_SUITE_SMALLBUSINESS_RESTRICTED = $00000020; + {$EXTERNALSYM VER_SUITE_SMALLBUSINESS_RESTRICTED} + VER_SUITE_EMBEDDEDNT = $00000040; + {$EXTERNALSYM VER_SUITE_EMBEDDEDNT} + VER_SUITE_DATACENTER = $00000080; + {$EXTERNALSYM VER_SUITE_DATACENTER} + VER_SUITE_SINGLEUSERTS = $00000100; + {$EXTERNALSYM VER_SUITE_SINGLEUSERTS} + VER_SUITE_PERSONAL = $00000200; + {$EXTERNALSYM VER_SUITE_PERSONAL} + VER_SUITE_BLADE = $00000400; + {$EXTERNALSYM VER_SUITE_BLADE} + VER_SUITE_EMBEDDED_RESTRICTED = $00000800; + {$EXTERNALSYM VER_SUITE_EMBEDDED_RESTRICTED} + VER_SUITE_SECURITY_APPLIANCE = $00001000; + {$EXTERNALSYM VER_SUITE_SECURITY_APPLIANCE} + VER_SUITE_STORAGE_SERVER = $00002000; + {$EXTERNALSYM VER_SUITE_STORAGE_SERVER} + VER_SUITE_COMPUTE_SERVER = $00004000; + {$EXTERNALSYM VER_SUITE_COMPUTE_SERVER} + +// line 515 + +// +// A language ID is a 16 bit value which is the combination of a +// primary language ID and a secondary language ID. The bits are +// allocated as follows: +// +// +-----------------------+-------------------------+ +// | Sublanguage ID | Primary Language ID | +// +-----------------------+-------------------------+ +// 15 10 9 0 bit +// +// +// Language ID creation/extraction macros: +// +// MAKELANGID - construct language id from a primary language id and +// a sublanguage id. +// PRIMARYLANGID - extract primary language id from a language id. +// SUBLANGID - extract sublanguage id from a language id. +// + +function MAKELANGID(PrimaryLang, SubLang: USHORT): WORD; +{$EXTERNALSYM MAKELANGID} +function PRIMARYLANGID(LangId: WORD): WORD; +{$EXTERNALSYM PRIMARYLANGID} +function SUBLANGID(LangId: WORD): WORD; +{$EXTERNALSYM SUBLANGID} + +// +// A locale ID is a 32 bit value which is the combination of a +// language ID, a sort ID, and a reserved area. The bits are +// allocated as follows: +// +// +-------------+---------+-------------------------+ +// | Reserved | Sort ID | Language ID | +// +-------------+---------+-------------------------+ +// 31 20 19 16 15 0 bit +// +// +// Locale ID creation/extraction macros: +// +// MAKELCID - construct the locale id from a language id and a sort id. +// MAKESORTLCID - construct the locale id from a language id, sort id, and sort version. +// LANGIDFROMLCID - extract the language id from a locale id. +// SORTIDFROMLCID - extract the sort id from a locale id. +// SORTVERSIONFROMLCID - extract the sort version from a locale id. +// + +const + NLS_VALID_LOCALE_MASK = $000fffff; + {$EXTERNALSYM NLS_VALID_LOCALE_MASK} + +function MAKELCID(LangId, SortId: WORD): DWORD; +{$EXTERNALSYM MAKELCID} +function MAKESORTLCID(LangId, SortId, SortVersion: WORD): DWORD; +{$EXTERNALSYM MAKESORTLCID} +function LANGIDFROMLCID(LocaleId: LCID): WORD; +{$EXTERNALSYM LANGIDFROMLCID} +function SORTIDFROMLCID(LocaleId: LCID): WORD; +{$EXTERNALSYM SORTIDFROMLCID} +function SORTVERSIONFROMLCID(LocaleId: LCID): WORD; +{$EXTERNALSYM SORTVERSIONFROMLCID} + +// line 1154 + +//////////////////////////////////////////////////////////////////////// +// // +// Security Id (SID) // +// // +//////////////////////////////////////////////////////////////////////// +// +// +// Pictorially the structure of an SID is as follows: +// +// 1 1 1 1 1 1 +// 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// +---------------------------------------------------------------+ +// | SubAuthorityCount |Reserved1 (SBZ)| Revision | +// +---------------------------------------------------------------+ +// | IdentifierAuthority[0] | +// +---------------------------------------------------------------+ +// | IdentifierAuthority[1] | +// +---------------------------------------------------------------+ +// | IdentifierAuthority[2] | +// +---------------------------------------------------------------+ +// | | +// +- - - - - - - - SubAuthority[] - - - - - - - - -+ +// | | +// +---------------------------------------------------------------+ +// +// + +{$IFNDEF FPC} +type + _SID_IDENTIFIER_AUTHORITY = record + Value: array [0..5] of Byte; + end; + {$EXTERNALSYM _SID_IDENTIFIER_AUTHORITY} + SID_IDENTIFIER_AUTHORITY = _SID_IDENTIFIER_AUTHORITY; + {$EXTERNALSYM SID_IDENTIFIER_AUTHORITY} + PSID_IDENTIFIER_AUTHORITY = ^_SID_IDENTIFIER_AUTHORITY; + {$EXTERNALSYM PSID_IDENTIFIER_AUTHORITY} + + // PSid = ^SID; + _SID = record + Revision: Byte; + SubAuthorityCount: Byte; + IdentifierAuthority: SID_IDENTIFIER_AUTHORITY; + SubAuthority: array [0..ANYSIZE_ARRAY - 1] of DWORD; + end; + {$EXTERNALSYM _SID} + SID = _SID; + {$EXTERNALSYM SID} + PPSID = ^PSID; + {$NODEFINE PPSID} + TSid = SID; +{$ENDIF ~FPC} + +const + SID_REVISION = (1); // Current revision level + {$EXTERNALSYM SID_REVISION} + SID_MAX_SUB_AUTHORITIES = (15); + {$EXTERNALSYM SID_MAX_SUB_AUTHORITIES} + SID_RECOMMENDED_SUB_AUTHORITIES = (1); // Will change to around 6 in a future release. + {$EXTERNALSYM SID_RECOMMENDED_SUB_AUTHORITIES} + + SECURITY_MAX_SID_SIZE = SizeOf(SID) - SizeOf(DWORD) + (SID_MAX_SUB_AUTHORITIES * SizeOf(DWORD)); + {$EXTERNALSYM SECURITY_MAX_SID_SIZE} + +{$IFNDEF FPC} + SidTypeUser = 1; + {$EXTERNALSYM SidTypeUser} + SidTypeGroup = 2; + {$EXTERNALSYM SidTypeGroup} + SidTypeDomain = 3; + {$EXTERNALSYM SidTypeDomain} + SidTypeAlias = 4; + {$EXTERNALSYM SidTypeAlias} + SidTypeWellKnownGroup = 5; + {$EXTERNALSYM SidTypeWellKnownGroup} + SidTypeDeletedAccount = 6; + {$EXTERNALSYM SidTypeDeletedAccount} + SidTypeInvalid = 7; + {$EXTERNALSYM SidTypeInvalid} + SidTypeUnknown = 8; + {$EXTERNALSYM SidTypeUnknown} + SidTypeComputer = 9; + {$EXTERNALSYM SidTypeComputer} + +type + _SID_NAME_USE = DWORD; + {$EXTERNALSYM _SID_NAME_USE} +// SID_NAME_USE = _SID_NAME_USE; +// {$EXTERNALSYM SID_NAME_USE} + PSID_NAME_USE = ^SID_NAME_USE; + {$EXTERNALSYM PSID_NAME_USE} + TSidNameUse = SID_NAME_USE; + PSidNameUSe = PSID_NAME_USE; + + PSID_AND_ATTRIBUTES = ^SID_AND_ATTRIBUTES; + {$EXTERNALSYM PSID_AND_ATTRIBUTES} + _SID_AND_ATTRIBUTES = record + Sid: PSID; + Attributes: DWORD; + end; + {$EXTERNALSYM _SID_AND_ATTRIBUTES} + SID_AND_ATTRIBUTES = _SID_AND_ATTRIBUTES; + {$EXTERNALSYM SID_AND_ATTRIBUTES} + TSidAndAttributes = SID_AND_ATTRIBUTES; + PSidAndAttributes = PSID_AND_ATTRIBUTES; + + SID_AND_ATTRIBUTES_ARRAY = array [0..ANYSIZE_ARRAY - 1] of SID_AND_ATTRIBUTES; + {$EXTERNALSYM SID_AND_ATTRIBUTES_ARRAY} + PSID_AND_ATTRIBUTES_ARRAY = ^SID_AND_ATTRIBUTES_ARRAY; + {$EXTERNALSYM PSID_AND_ATTRIBUTES_ARRAY} + PSidAndAttributesArray = ^TSidAndAttributesArray; + TSidAndAttributesArray = SID_AND_ATTRIBUTES_ARRAY; +{$ENDIF ~FPC} + +///////////////////////////////////////////////////////////////////////////// +// // +// Universal well-known SIDs // +// // +// Null SID S-1-0-0 // +// World S-1-1-0 // +// Local S-1-2-0 // +// Creator Owner ID S-1-3-0 // +// Creator Group ID S-1-3-1 // +// Creator Owner Server ID S-1-3-2 // +// Creator Group Server ID S-1-3-3 // +// // +// (Non-unique IDs) S-1-4 // +// // +///////////////////////////////////////////////////////////////////////////// + +const + SECURITY_NULL_SID_AUTHORITY: TSidIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 0)); + {$EXTERNALSYM SECURITY_NULL_SID_AUTHORITY} + SECURITY_WORLD_SID_AUTHORITY: TSidIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 1)); + {$EXTERNALSYM SECURITY_WORLD_SID_AUTHORITY} + SECURITY_LOCAL_SID_AUTHORITY: TSidIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 2)); + {$EXTERNALSYM SECURITY_LOCAL_SID_AUTHORITY} + SECURITY_CREATOR_SID_AUTHORITY: TSidIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 3)); + {$EXTERNALSYM SECURITY_CREATOR_SID_AUTHORITY} + SECURITY_NON_UNIQUE_AUTHORITY: TSidIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 4)); + {$EXTERNALSYM SECURITY_NON_UNIQUE_AUTHORITY} + SECURITY_RESOURCE_MANAGER_AUTHORITY: TSidIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 9)); + {$EXTERNALSYM SECURITY_RESOURCE_MANAGER_AUTHORITY} + + SECURITY_NULL_RID = ($00000000); + {$EXTERNALSYM SECURITY_NULL_RID} + SECURITY_WORLD_RID = ($00000000); + {$EXTERNALSYM SECURITY_WORLD_RID} + SECURITY_LOCAL_RID = ($00000000); + {$EXTERNALSYM SECURITY_LOCAL_RID} + + SECURITY_CREATOR_OWNER_RID = ($00000000); + {$EXTERNALSYM SECURITY_CREATOR_OWNER_RID} + SECURITY_CREATOR_GROUP_RID = ($00000001); + {$EXTERNALSYM SECURITY_CREATOR_GROUP_RID} + + SECURITY_CREATOR_OWNER_SERVER_RID = ($00000002); + {$EXTERNALSYM SECURITY_CREATOR_OWNER_SERVER_RID} + SECURITY_CREATOR_GROUP_SERVER_RID = ($00000003); + {$EXTERNALSYM SECURITY_CREATOR_GROUP_SERVER_RID} + +///////////////////////////////////////////////////////////////////////////// +// // +// NT well-known SIDs // +// // +// NT Authority S-1-5 // +// Dialup S-1-5-1 // +// // +// Network S-1-5-2 // +// Batch S-1-5-3 // +// Interactive S-1-5-4 // +// (Logon IDs) S-1-5-5-X-Y // +// Service S-1-5-6 // +// AnonymousLogon S-1-5-7 (aka null logon session) // +// Proxy S-1-5-8 // +// Enterprise DC (EDC) S-1-5-9 (aka domain controller account) // +// Self S-1-5-10 (self RID) // +// Authenticated User S-1-5-11 (Authenticated user somewhere) // +// Restricted Code S-1-5-12 (Running restricted code) // +// Terminal Server S-1-5-13 (Running on Terminal Server) // +// Remote Logon S-1-5-14 (Remote Interactive Logon) // +// This Organization S-1-5-15 // +// // +// Local System S-1-5-18 // +// Local Service S-1-5-19 // +// Network Service S-1-5-20 // +// // +// (NT non-unique IDs) S-1-5-0x15-... (NT Domain Sids) // +// // +// (Built-in domain) S-1-5-0x20 // +// // +// (Security Package IDs) S-1-5-0x40 // +// NTLM Authentication S-1-5-0x40-10 // +// SChannel Authentication S-1-5-0x40-14 // +// Digest Authentication S-1-5-0x40-21 // +// // +// Other Organization S-1-5-1000 (>=1000 can not be filtered) // +// // +// // +// NOTE: the relative identifier values (RIDs) determine which security // +// boundaries the SID is allowed to cross. Before adding new RIDs, // +// a determination needs to be made regarding which range they should // +// be added to in order to ensure proper "SID filtering" // +// // +///////////////////////////////////////////////////////////////////////////// + +const + SECURITY_NT_AUTHORITY: TSidIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 5)); + {$EXTERNALSYM SECURITY_NT_AUTHORITY} + + SECURITY_DIALUP_RID = ($00000001); + {$EXTERNALSYM SECURITY_DIALUP_RID} + SECURITY_NETWORK_RID = ($00000002); + {$EXTERNALSYM SECURITY_NETWORK_RID} + SECURITY_BATCH_RID = ($00000003); + {$EXTERNALSYM SECURITY_BATCH_RID} + SECURITY_INTERACTIVE_RID = ($00000004); + {$EXTERNALSYM SECURITY_INTERACTIVE_RID} + SECURITY_LOGON_IDS_RID = ($00000005); + {$EXTERNALSYM SECURITY_LOGON_IDS_RID} + SECURITY_LOGON_IDS_RID_COUNT = (3); + {$EXTERNALSYM SECURITY_LOGON_IDS_RID_COUNT} + SECURITY_SERVICE_RID = ($00000006); + {$EXTERNALSYM SECURITY_SERVICE_RID} + SECURITY_ANONYMOUS_LOGON_RID = ($00000007); + {$EXTERNALSYM SECURITY_ANONYMOUS_LOGON_RID} + SECURITY_PROXY_RID = ($00000008); + {$EXTERNALSYM SECURITY_PROXY_RID} + SECURITY_ENTERPRISE_CONTROLLERS_RID = ($00000009); + {$EXTERNALSYM SECURITY_ENTERPRISE_CONTROLLERS_RID} + SECURITY_SERVER_LOGON_RID = SECURITY_ENTERPRISE_CONTROLLERS_RID; + {$EXTERNALSYM SECURITY_SERVER_LOGON_RID} + SECURITY_PRINCIPAL_SELF_RID = ($0000000A); + {$EXTERNALSYM SECURITY_PRINCIPAL_SELF_RID} + SECURITY_AUTHENTICATED_USER_RID = ($0000000B); + {$EXTERNALSYM SECURITY_AUTHENTICATED_USER_RID} + SECURITY_RESTRICTED_CODE_RID = ($0000000C); + {$EXTERNALSYM SECURITY_RESTRICTED_CODE_RID} + SECURITY_TERMINAL_SERVER_RID = ($0000000D); + {$EXTERNALSYM SECURITY_TERMINAL_SERVER_RID} + SECURITY_REMOTE_LOGON_RID = ($0000000E); + {$EXTERNALSYM SECURITY_REMOTE_LOGON_RID} + SECURITY_THIS_ORGANIZATION_RID = ($0000000F); + {$EXTERNALSYM SECURITY_THIS_ORGANIZATION_RID} + + SECURITY_LOCAL_SYSTEM_RID = ($00000012); + {$EXTERNALSYM SECURITY_LOCAL_SYSTEM_RID} + SECURITY_LOCAL_SERVICE_RID = ($00000013); + {$EXTERNALSYM SECURITY_LOCAL_SERVICE_RID} + SECURITY_NETWORK_SERVICE_RID = ($00000014); + {$EXTERNALSYM SECURITY_NETWORK_SERVICE_RID} + + SECURITY_NT_NON_UNIQUE = ($00000015); + {$EXTERNALSYM SECURITY_NT_NON_UNIQUE} + SECURITY_NT_NON_UNIQUE_SUB_AUTH_COUNT = (3); + {$EXTERNALSYM SECURITY_NT_NON_UNIQUE_SUB_AUTH_COUNT} + + SECURITY_BUILTIN_DOMAIN_RID = ($00000020); + {$EXTERNALSYM SECURITY_BUILTIN_DOMAIN_RID} + + SECURITY_PACKAGE_BASE_RID = ($00000040); + {$EXTERNALSYM SECURITY_PACKAGE_BASE_RID} + SECURITY_PACKAGE_RID_COUNT = (2); + {$EXTERNALSYM SECURITY_PACKAGE_RID_COUNT} + SECURITY_PACKAGE_NTLM_RID = ($0000000A); + {$EXTERNALSYM SECURITY_PACKAGE_NTLM_RID} + SECURITY_PACKAGE_SCHANNEL_RID = ($0000000E); + {$EXTERNALSYM SECURITY_PACKAGE_SCHANNEL_RID} + SECURITY_PACKAGE_DIGEST_RID = ($00000015); + {$EXTERNALSYM SECURITY_PACKAGE_DIGEST_RID} + + SECURITY_MAX_ALWAYS_FILTERED = ($000003E7); + {$EXTERNALSYM SECURITY_MAX_ALWAYS_FILTERED} + SECURITY_MIN_NEVER_FILTERED = ($000003E8); + {$EXTERNALSYM SECURITY_MIN_NEVER_FILTERED} + + SECURITY_OTHER_ORGANIZATION_RID = ($000003E8); + {$EXTERNALSYM SECURITY_OTHER_ORGANIZATION_RID} + +///////////////////////////////////////////////////////////////////////////// +// // +// well-known domain relative sub-authority values (RIDs)... // +// // +///////////////////////////////////////////////////////////////////////////// + +// Well-known users ... + + FOREST_USER_RID_MAX = ($000001F3); + {$EXTERNALSYM FOREST_USER_RID_MAX} + + DOMAIN_USER_RID_ADMIN = ($000001F4); + {$EXTERNALSYM DOMAIN_USER_RID_ADMIN} + DOMAIN_USER_RID_GUEST = ($000001F5); + {$EXTERNALSYM DOMAIN_USER_RID_GUEST} + DOMAIN_USER_RID_KRBTGT = ($000001F6); + {$EXTERNALSYM DOMAIN_USER_RID_KRBTGT} + + DOMAIN_USER_RID_MAX = ($000003E7); + {$EXTERNALSYM DOMAIN_USER_RID_MAX} + +// well-known groups ... + + DOMAIN_GROUP_RID_ADMINS = ($00000200); + {$EXTERNALSYM DOMAIN_GROUP_RID_ADMINS} + DOMAIN_GROUP_RID_USERS = ($00000201); + {$EXTERNALSYM DOMAIN_GROUP_RID_USERS} + DOMAIN_GROUP_RID_GUESTS = ($00000202); + {$EXTERNALSYM DOMAIN_GROUP_RID_GUESTS} + DOMAIN_GROUP_RID_COMPUTERS = ($00000203); + {$EXTERNALSYM DOMAIN_GROUP_RID_COMPUTERS} + DOMAIN_GROUP_RID_CONTROLLERS = ($00000204); + {$EXTERNALSYM DOMAIN_GROUP_RID_CONTROLLERS} + DOMAIN_GROUP_RID_CERT_ADMINS = ($00000205); + {$EXTERNALSYM DOMAIN_GROUP_RID_CERT_ADMINS} + DOMAIN_GROUP_RID_SCHEMA_ADMINS = ($00000206); + {$EXTERNALSYM DOMAIN_GROUP_RID_SCHEMA_ADMINS} + DOMAIN_GROUP_RID_ENTERPRISE_ADMINS = ($00000207); + {$EXTERNALSYM DOMAIN_GROUP_RID_ENTERPRISE_ADMINS} + DOMAIN_GROUP_RID_POLICY_ADMINS = ($00000208); + {$EXTERNALSYM DOMAIN_GROUP_RID_POLICY_ADMINS} + +// well-known aliases ... + + DOMAIN_ALIAS_RID_ADMINS = ($00000220); + {$EXTERNALSYM DOMAIN_ALIAS_RID_ADMINS} + DOMAIN_ALIAS_RID_USERS = ($00000221); + {$EXTERNALSYM DOMAIN_ALIAS_RID_USERS} + DOMAIN_ALIAS_RID_GUESTS = ($00000222); + {$EXTERNALSYM DOMAIN_ALIAS_RID_GUESTS} + DOMAIN_ALIAS_RID_POWER_USERS = ($00000223); + {$EXTERNALSYM DOMAIN_ALIAS_RID_POWER_USERS} + + DOMAIN_ALIAS_RID_ACCOUNT_OPS = ($00000224); + {$EXTERNALSYM DOMAIN_ALIAS_RID_ACCOUNT_OPS} + DOMAIN_ALIAS_RID_SYSTEM_OPS = ($00000225); + {$EXTERNALSYM DOMAIN_ALIAS_RID_SYSTEM_OPS} + DOMAIN_ALIAS_RID_PRINT_OPS = ($00000226); + {$EXTERNALSYM DOMAIN_ALIAS_RID_PRINT_OPS} + DOMAIN_ALIAS_RID_BACKUP_OPS = ($00000227); + {$EXTERNALSYM DOMAIN_ALIAS_RID_BACKUP_OPS} + + DOMAIN_ALIAS_RID_REPLICATOR = ($00000228); + {$EXTERNALSYM DOMAIN_ALIAS_RID_REPLICATOR} + DOMAIN_ALIAS_RID_RAS_SERVERS = ($00000229); + {$EXTERNALSYM DOMAIN_ALIAS_RID_RAS_SERVERS} + DOMAIN_ALIAS_RID_PREW2KCOMPACCESS = ($0000022A); + {$EXTERNALSYM DOMAIN_ALIAS_RID_PREW2KCOMPACCESS} + DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS = ($0000022B); + {$EXTERNALSYM DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS} + DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS = ($0000022C); + {$EXTERNALSYM DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS} + DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS = ($0000022D); + {$EXTERNALSYM DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS} + + DOMAIN_ALIAS_RID_MONITORING_USERS = ($0000022E); + {$EXTERNALSYM DOMAIN_ALIAS_RID_MONITORING_USERS} + DOMAIN_ALIAS_RID_LOGGING_USERS = ($0000022F); + {$EXTERNALSYM DOMAIN_ALIAS_RID_LOGGING_USERS} + DOMAIN_ALIAS_RID_AUTHORIZATIONACCESS = ($00000230); + {$EXTERNALSYM DOMAIN_ALIAS_RID_AUTHORIZATIONACCESS} + DOMAIN_ALIAS_RID_TS_LICENSE_SERVERS = ($00000231); + {$EXTERNALSYM DOMAIN_ALIAS_RID_TS_LICENSE_SERVERS} + +// line 2495 + +//////////////////////////////////////////////////////////////////////// +// // +// NT Defined Privileges // +// // +//////////////////////////////////////////////////////////////////////// + +const + SE_CREATE_TOKEN_NAME = 'SeCreateTokenPrivilege'; + {$EXTERNALSYM SE_CREATE_TOKEN_NAME} + SE_ASSIGNPRIMARYTOKEN_NAME = 'SeAssignPrimaryTokenPrivilege'; + {$EXTERNALSYM SE_ASSIGNPRIMARYTOKEN_NAME} + SE_LOCK_MEMORY_NAME = 'SeLockMemoryPrivilege'; + {$EXTERNALSYM SE_LOCK_MEMORY_NAME} + SE_INCREASE_QUOTA_NAME = 'SeIncreaseQuotaPrivilege'; + {$EXTERNALSYM SE_INCREASE_QUOTA_NAME} + SE_UNSOLICITED_INPUT_NAME = 'SeUnsolicitedInputPrivilege'; + {$EXTERNALSYM SE_UNSOLICITED_INPUT_NAME} + SE_MACHINE_ACCOUNT_NAME = 'SeMachineAccountPrivilege'; + {$EXTERNALSYM SE_MACHINE_ACCOUNT_NAME} + SE_TCB_NAME = 'SeTcbPrivilege'; + {$EXTERNALSYM SE_TCB_NAME} + SE_SECURITY_NAME = 'SeSecurityPrivilege'; + {$EXTERNALSYM SE_SECURITY_NAME} + SE_TAKE_OWNERSHIP_NAME = 'SeTakeOwnershipPrivilege'; + {$EXTERNALSYM SE_TAKE_OWNERSHIP_NAME} + SE_LOAD_DRIVER_NAME = 'SeLoadDriverPrivilege'; + {$EXTERNALSYM SE_LOAD_DRIVER_NAME} + SE_SYSTEM_PROFILE_NAME = 'SeSystemProfilePrivilege'; + {$EXTERNALSYM SE_SYSTEM_PROFILE_NAME} + SE_SYSTEMTIME_NAME = 'SeSystemtimePrivilege'; + {$EXTERNALSYM SE_SYSTEMTIME_NAME} + SE_PROF_SINGLE_PROCESS_NAME = 'SeProfileSingleProcessPrivilege'; + {$EXTERNALSYM SE_PROF_SINGLE_PROCESS_NAME} + SE_INC_BASE_PRIORITY_NAME = 'SeIncreaseBasePriorityPrivilege'; + {$EXTERNALSYM SE_INC_BASE_PRIORITY_NAME} + SE_CREATE_PAGEFILE_NAME = 'SeCreatePagefilePrivilege'; + {$EXTERNALSYM SE_CREATE_PAGEFILE_NAME} + SE_CREATE_PERMANENT_NAME = 'SeCreatePermanentPrivilege'; + {$EXTERNALSYM SE_CREATE_PERMANENT_NAME} + SE_BACKUP_NAME = 'SeBackupPrivilege'; + {$EXTERNALSYM SE_BACKUP_NAME} + SE_RESTORE_NAME = 'SeRestorePrivilege'; + {$EXTERNALSYM SE_RESTORE_NAME} + SE_SHUTDOWN_NAME = 'SeShutdownPrivilege'; + {$EXTERNALSYM SE_SHUTDOWN_NAME} + SE_DEBUG_NAME = 'SeDebugPrivilege'; + {$EXTERNALSYM SE_DEBUG_NAME} + SE_AUDIT_NAME = 'SeAuditPrivilege'; + {$EXTERNALSYM SE_AUDIT_NAME} + SE_SYSTEM_ENVIRONMENT_NAME = 'SeSystemEnvironmentPrivilege'; + {$EXTERNALSYM SE_SYSTEM_ENVIRONMENT_NAME} + SE_CHANGE_NOTIFY_NAME = 'SeChangeNotifyPrivilege'; + {$EXTERNALSYM SE_CHANGE_NOTIFY_NAME} + SE_REMOTE_SHUTDOWN_NAME = 'SeRemoteShutdownPrivilege'; + {$EXTERNALSYM SE_REMOTE_SHUTDOWN_NAME} + SE_UNDOCK_NAME = 'SeUndockPrivilege'; + {$EXTERNALSYM SE_UNDOCK_NAME} + SE_SYNC_AGENT_NAME = 'SeSyncAgentPrivilege'; + {$EXTERNALSYM SE_SYNC_AGENT_NAME} + SE_ENABLE_DELEGATION_NAME = 'SeEnableDelegationPrivilege'; + {$EXTERNALSYM SE_ENABLE_DELEGATION_NAME} + SE_MANAGE_VOLUME_NAME = 'SeManageVolumePrivilege'; + {$EXTERNALSYM SE_MANAGE_VOLUME_NAME} + SE_IMPERSONATE_NAME = 'SeImpersonatePrivilege'; + {$EXTERNALSYM SE_IMPERSONATE_NAME} + SE_CREATE_GLOBAL_NAME = 'SeCreateGlobalPrivilege'; + {$EXTERNALSYM SE_CREATE_GLOBAL_NAME} + +// +// Thread Information Block (TIB) +// + +type + NT_TIB32 = packed record + ExceptionList: DWORD; + StackBase: DWORD; + StackLimit: DWORD; + SubSystemTib: DWORD; + case Integer of + 0 : ( + FiberData: DWORD; + ArbitraryUserPointer: DWORD; + Self: DWORD; + ); + 1 : ( + Version: DWORD; + ); + end; + {$EXTERNALSYM NT_TIB32} + PNT_TIB32 = ^NT_TIB32; + {$EXTERNALSYM PNT_TIB32} + + NT_TIB64 = packed record + ExceptionList: TJclAddr64; + StackBase: TJclAddr64; + StackLimit: TJclAddr64; + SubSystemTib: TJclAddr64; + case Integer of + 0 : ( + FiberData: TJclAddr64; + ArbitraryUserPointer: TJclAddr64; + Self: TJclAddr64; + ); + 1 : ( + Version: DWORD; + ); + end; + {$EXTERNALSYM NT_TIB64} + PNT_TIB64 = ^NT_TIB64; + {$EXTERNALSYM PNT_TIB64} + +// line 2686 + +// +// Token information class structures +// + +{$IFNDEF FPC} +type + PTOKEN_USER = ^TOKEN_USER; + {$EXTERNALSYM PTOKEN_USER} + _TOKEN_USER = record + User: SID_AND_ATTRIBUTES; + end; + {$EXTERNALSYM _TOKEN_USER} + TOKEN_USER = _TOKEN_USER; + {$EXTERNALSYM TOKEN_USER} + TTokenUser = TOKEN_USER; + PTokenUser = PTOKEN_USER; +{$ENDIF ~FPC} + +function CaptureStackBackTrace(FramesToSkip, FramesToCapture: DWORD; + BackTrace: Pointer; out BackTraceHash: DWORD): Word; stdcall; +{$EXTERNALSYM CaptureStackBackTrace} + +// line 3858 + +// +// Define access rights to files and directories +// + +// +// The FILE_READ_DATA and FILE_WRITE_DATA constants are also defined in +// devioctl.h as FILE_READ_ACCESS and FILE_WRITE_ACCESS. The values for these +// constants *MUST* always be in sync. +// The values are redefined in devioctl.h because they must be available to +// both DOS and NT. +// + +const + FILE_READ_DATA = ($0001); // file & pipe + {$EXTERNALSYM FILE_READ_DATA} + FILE_LIST_DIRECTORY = ($0001); // directory + {$EXTERNALSYM FILE_LIST_DIRECTORY} + + FILE_WRITE_DATA = ($0002); // file & pipe + {$EXTERNALSYM FILE_WRITE_DATA} + FILE_ADD_FILE = ($0002); // directory + {$EXTERNALSYM FILE_ADD_FILE} + + FILE_APPEND_DATA = ($0004); // file + {$EXTERNALSYM FILE_APPEND_DATA} + FILE_ADD_SUBDIRECTORY = ($0004); // directory + {$EXTERNALSYM FILE_ADD_SUBDIRECTORY} + FILE_CREATE_PIPE_INSTANCE = ($0004); // named pipe + {$EXTERNALSYM FILE_CREATE_PIPE_INSTANCE} + + FILE_READ_EA = ($0008); // file & directory + {$EXTERNALSYM FILE_READ_EA} + + FILE_WRITE_EA = ($0010); // file & directory + {$EXTERNALSYM FILE_WRITE_EA} + + FILE_EXECUTE = ($0020); // file + {$EXTERNALSYM FILE_EXECUTE} + FILE_TRAVERSE = ($0020); // directory + {$EXTERNALSYM FILE_TRAVERSE} + + FILE_DELETE_CHILD = ($0040); // directory + {$EXTERNALSYM FILE_DELETE_CHILD} + + FILE_READ_ATTRIBUTES = ($0080); // all + {$EXTERNALSYM FILE_READ_ATTRIBUTES} + + FILE_WRITE_ATTRIBUTES = ($0100); // all + {$EXTERNALSYM FILE_WRITE_ATTRIBUTES} + + FILE_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED or SYNCHRONIZE or $1FF); + {$EXTERNALSYM FILE_ALL_ACCESS} + + FILE_GENERIC_READ = (STANDARD_RIGHTS_READ or FILE_READ_DATA or + FILE_READ_ATTRIBUTES or FILE_READ_EA or SYNCHRONIZE); + {$EXTERNALSYM FILE_GENERIC_READ} + + FILE_GENERIC_WRITE = (STANDARD_RIGHTS_WRITE or FILE_WRITE_DATA or + FILE_WRITE_ATTRIBUTES or FILE_WRITE_EA or FILE_APPEND_DATA or SYNCHRONIZE); + {$EXTERNALSYM FILE_GENERIC_WRITE} + + FILE_GENERIC_EXECUTE = (STANDARD_RIGHTS_EXECUTE or FILE_READ_ATTRIBUTES or + FILE_EXECUTE or SYNCHRONIZE); + {$EXTERNALSYM FILE_GENERIC_EXECUTE} + + FILE_SHARE_READ = $00000001; + {$EXTERNALSYM FILE_SHARE_READ} + FILE_SHARE_WRITE = $00000002; + {$EXTERNALSYM FILE_SHARE_WRITE} + FILE_SHARE_DELETE = $00000004; + {$EXTERNALSYM FILE_SHARE_DELETE} + FILE_ATTRIBUTE_READONLY = $00000001; + {$EXTERNALSYM FILE_ATTRIBUTE_READONLY} + FILE_ATTRIBUTE_HIDDEN = $00000002; + {$EXTERNALSYM FILE_ATTRIBUTE_HIDDEN} + FILE_ATTRIBUTE_SYSTEM = $00000004; + {$EXTERNALSYM FILE_ATTRIBUTE_SYSTEM} + FILE_ATTRIBUTE_DIRECTORY = $00000010; + {$EXTERNALSYM FILE_ATTRIBUTE_DIRECTORY} + FILE_ATTRIBUTE_ARCHIVE = $00000020; + {$EXTERNALSYM FILE_ATTRIBUTE_ARCHIVE} + FILE_ATTRIBUTE_DEVICE = $00000040; + {$EXTERNALSYM FILE_ATTRIBUTE_DEVICE} + FILE_ATTRIBUTE_NORMAL = $00000080; + {$EXTERNALSYM FILE_ATTRIBUTE_NORMAL} + FILE_ATTRIBUTE_TEMPORARY = $00000100; + {$EXTERNALSYM FILE_ATTRIBUTE_TEMPORARY} + FILE_ATTRIBUTE_SPARSE_FILE = $00000200; + {$EXTERNALSYM FILE_ATTRIBUTE_SPARSE_FILE} + FILE_ATTRIBUTE_REPARSE_POINT = $00000400; + {$EXTERNALSYM FILE_ATTRIBUTE_REPARSE_POINT} + FILE_ATTRIBUTE_COMPRESSED = $00000800; + {$EXTERNALSYM FILE_ATTRIBUTE_COMPRESSED} + FILE_ATTRIBUTE_OFFLINE = $00001000; + {$EXTERNALSYM FILE_ATTRIBUTE_OFFLINE} + FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = $00002000; + {$EXTERNALSYM FILE_ATTRIBUTE_NOT_CONTENT_INDEXED} + FILE_ATTRIBUTE_ENCRYPTED = $00004000; + {$EXTERNALSYM FILE_ATTRIBUTE_ENCRYPTED} + FILE_NOTIFY_CHANGE_FILE_NAME = $00000001; + {$EXTERNALSYM FILE_NOTIFY_CHANGE_FILE_NAME} + FILE_NOTIFY_CHANGE_DIR_NAME = $00000002; + {$EXTERNALSYM FILE_NOTIFY_CHANGE_DIR_NAME} + FILE_NOTIFY_CHANGE_ATTRIBUTES = $00000004; + {$EXTERNALSYM FILE_NOTIFY_CHANGE_ATTRIBUTES} + FILE_NOTIFY_CHANGE_SIZE = $00000008; + {$EXTERNALSYM FILE_NOTIFY_CHANGE_SIZE} + FILE_NOTIFY_CHANGE_LAST_WRITE = $00000010; + {$EXTERNALSYM FILE_NOTIFY_CHANGE_LAST_WRITE} + FILE_NOTIFY_CHANGE_LAST_ACCESS = $00000020; + {$EXTERNALSYM FILE_NOTIFY_CHANGE_LAST_ACCESS} + FILE_NOTIFY_CHANGE_CREATION = $00000040; + {$EXTERNALSYM FILE_NOTIFY_CHANGE_CREATION} + FILE_NOTIFY_CHANGE_SECURITY = $00000100; + {$EXTERNALSYM FILE_NOTIFY_CHANGE_SECURITY} + FILE_ACTION_ADDED = $00000001; + {$EXTERNALSYM FILE_ACTION_ADDED} + FILE_ACTION_REMOVED = $00000002; + {$EXTERNALSYM FILE_ACTION_REMOVED} + FILE_ACTION_MODIFIED = $00000003; + {$EXTERNALSYM FILE_ACTION_MODIFIED} + FILE_ACTION_RENAMED_OLD_NAME = $00000004; + {$EXTERNALSYM FILE_ACTION_RENAMED_OLD_NAME} + FILE_ACTION_RENAMED_NEW_NAME = $00000005; + {$EXTERNALSYM FILE_ACTION_RENAMED_NEW_NAME} + MAILSLOT_NO_MESSAGE = DWORD(-1); + {$EXTERNALSYM MAILSLOT_NO_MESSAGE} + MAILSLOT_WAIT_FOREVER = DWORD(-1); + {$EXTERNALSYM MAILSLOT_WAIT_FOREVER} + FILE_CASE_SENSITIVE_SEARCH = $00000001; + {$EXTERNALSYM FILE_CASE_SENSITIVE_SEARCH} + FILE_CASE_PRESERVED_NAMES = $00000002; + {$EXTERNALSYM FILE_CASE_PRESERVED_NAMES} + FILE_UNICODE_ON_DISK = $00000004; + {$EXTERNALSYM FILE_UNICODE_ON_DISK} + FILE_PERSISTENT_ACLS = $00000008; + {$EXTERNALSYM FILE_PERSISTENT_ACLS} + FILE_FILE_COMPRESSION = $00000010; + {$EXTERNALSYM FILE_FILE_COMPRESSION} + FILE_VOLUME_QUOTAS = $00000020; + {$EXTERNALSYM FILE_VOLUME_QUOTAS} + FILE_SUPPORTS_SPARSE_FILES = $00000040; + {$EXTERNALSYM FILE_SUPPORTS_SPARSE_FILES} + FILE_SUPPORTS_REPARSE_POINTS = $00000080; + {$EXTERNALSYM FILE_SUPPORTS_REPARSE_POINTS} + FILE_SUPPORTS_REMOTE_STORAGE = $00000100; + {$EXTERNALSYM FILE_SUPPORTS_REMOTE_STORAGE} + FILE_VOLUME_IS_COMPRESSED = $00008000; + {$EXTERNALSYM FILE_VOLUME_IS_COMPRESSED} + FILE_SUPPORTS_OBJECT_IDS = $00010000; + {$EXTERNALSYM FILE_SUPPORTS_OBJECT_IDS} + FILE_SUPPORTS_ENCRYPTION = $00020000; + {$EXTERNALSYM FILE_SUPPORTS_ENCRYPTION} + FILE_NAMED_STREAMS = $00040000; + {$EXTERNALSYM FILE_NAMED_STREAMS} + FILE_READ_ONLY_VOLUME = $00080000; + {$EXTERNALSYM FILE_READ_ONLY_VOLUME} + +// line 4052 + +// +// The reparse GUID structure is used by all 3rd party layered drivers to +// store data in a reparse point. For non-Microsoft tags, The GUID field +// cannot be GUID_NULL. +// The constraints on reparse tags are defined below. +// Microsoft tags can also be used with this format of the reparse point buffer. +// + +type + TGenericReparseBuffer = record + DataBuffer: array [0..0] of BYTE; + end; + + PREPARSE_GUID_DATA_BUFFER = ^REPARSE_GUID_DATA_BUFFER; + {$EXTERNALSYM PREPARSE_GUID_DATA_BUFFER} + _REPARSE_GUID_DATA_BUFFER = record + ReparseTag: DWORD; + ReparseDataLength: WORD; + Reserved: WORD; + ReparseGuid: TGUID; + GenericReparseBuffer: TGenericReparseBuffer; + end; + {$EXTERNALSYM _REPARSE_GUID_DATA_BUFFER} + REPARSE_GUID_DATA_BUFFER = _REPARSE_GUID_DATA_BUFFER; + {$EXTERNALSYM REPARSE_GUID_DATA_BUFFER} + TReparseGuidDataBuffer = REPARSE_GUID_DATA_BUFFER; + PReparseGuidDataBuffer = PREPARSE_GUID_DATA_BUFFER; + +const + REPARSE_GUID_DATA_BUFFER_HEADER_SIZE = 24; + {$EXTERNALSYM REPARSE_GUID_DATA_BUFFER_HEADER_SIZE} +// +// Maximum allowed size of the reparse data. +// + +const + MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16 * 1024; + {$EXTERNALSYM MAXIMUM_REPARSE_DATA_BUFFER_SIZE} + +// +// Predefined reparse tags. +// These tags need to avoid conflicting with IO_REMOUNT defined in ntos\inc\io.h +// + + IO_REPARSE_TAG_RESERVED_ZERO = (0); + {$EXTERNALSYM IO_REPARSE_TAG_RESERVED_ZERO} + IO_REPARSE_TAG_RESERVED_ONE = (1); + {$EXTERNALSYM IO_REPARSE_TAG_RESERVED_ONE} + +// +// The value of the following constant needs to satisfy the following conditions: +// (1) Be at least as large as the largest of the reserved tags. +// (2) Be strictly smaller than all the tags in use. +// + + IO_REPARSE_TAG_RESERVED_RANGE = IO_REPARSE_TAG_RESERVED_ONE; + {$EXTERNALSYM IO_REPARSE_TAG_RESERVED_RANGE} + +// +// The reparse tags are a DWORD. The 32 bits are laid out as follows: +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// +-+-+-+-+-----------------------+-------------------------------+ +// |M|R|N|R| Reserved bits | Reparse Tag Value | +// +-+-+-+-+-----------------------+-------------------------------+ +// +// M is the Microsoft bit. When set to 1, it denotes a tag owned by Microsoft. +// All ISVs must use a tag with a 0 in this position. +// Note: If a Microsoft tag is used by non-Microsoft software, the +// behavior is not defined. +// +// R is reserved. Must be zero for non-Microsoft tags. +// +// N is name surrogate. When set to 1, the file represents another named +// entity in the system. +// +// The M and N bits are OR-able. +// The following macros check for the M and N bit values: +// + +// +// Macro to determine whether a reparse point tag corresponds to a tag +// owned by Microsoft. +// + +function IsReparseTagMicrosoft(Tag: ULONG): Boolean; +{$EXTERNALSYM IsReparseTagMicrosoft} + +// +// Macro to determine whether a reparse point tag corresponds to a file +// that is to be displayed with the slow icon overlay. +// + +function IsReparseTagHighLatency(Tag: ULONG): Boolean; +{$EXTERNALSYM IsReparseTagHighLatency} + +// +// Macro to determine whether a reparse point tag is a name surrogate +// + +function IsReparseTagNameSurrogate(Tag: ULONG): Boolean; +{$EXTERNALSYM IsReparseTagNameSurrogate} + +const + IO_REPARSE_TAG_MOUNT_POINT = DWORD($A0000003); + {$EXTERNALSYM IO_REPARSE_TAG_MOUNT_POINT} + IO_REPARSE_TAG_HSM = DWORD($C0000004); + {$EXTERNALSYM IO_REPARSE_TAG_HSM} + IO_REPARSE_TAG_SIS = DWORD($80000007); + {$EXTERNALSYM IO_REPARSE_TAG_SIS} + IO_REPARSE_TAG_DFS = DWORD($8000000A); + {$EXTERNALSYM IO_REPARSE_TAG_DFS} + IO_REPARSE_TAG_FILTER_MANAGER = DWORD($8000000B); + {$EXTERNALSYM IO_REPARSE_TAG_FILTER_MANAGER} + IO_COMPLETION_MODIFY_STATE = $0002; + {$EXTERNALSYM IO_COMPLETION_MODIFY_STATE} + IO_COMPLETION_ALL_ACCESS = DWORD(STANDARD_RIGHTS_REQUIRED or SYNCHRONIZE or $3); + {$EXTERNALSYM IO_COMPLETION_ALL_ACCESS} + DUPLICATE_CLOSE_SOURCE = $00000001; + {$EXTERNALSYM DUPLICATE_CLOSE_SOURCE} + DUPLICATE_SAME_ACCESS = $00000002; + {$EXTERNALSYM DUPLICATE_SAME_ACCESS} + +// line 4763 + +// +// File header format. +// + +{$IFNDEF FPC} +type + PIMAGE_FILE_HEADER = ^IMAGE_FILE_HEADER; + {$EXTERNALSYM PIMAGE_FILE_HEADER} + _IMAGE_FILE_HEADER = record + Machine: WORD; + NumberOfSections: WORD; + TimeDateStamp: DWORD; + PointerToSymbolTable: DWORD; + NumberOfSymbols: DWORD; + SizeOfOptionalHeader: WORD; + Characteristics: WORD; + end; + {$EXTERNALSYM _IMAGE_FILE_HEADER} + IMAGE_FILE_HEADER = _IMAGE_FILE_HEADER; + {$EXTERNALSYM IMAGE_FILE_HEADER} + TImageFileHeader = IMAGE_FILE_HEADER; + PImageFileHeader = PIMAGE_FILE_HEADER; +{$ENDIF ~FPC} + +const + IMAGE_SIZEOF_FILE_HEADER = 20; + {$EXTERNALSYM IMAGE_SIZEOF_FILE_HEADER} + + IMAGE_FILE_RELOCS_STRIPPED = $0001; // Relocation info stripped from file. + {$EXTERNALSYM IMAGE_FILE_RELOCS_STRIPPED} + IMAGE_FILE_EXECUTABLE_IMAGE = $0002; // File is executable (i.e. no unresolved externel references). + {$EXTERNALSYM IMAGE_FILE_EXECUTABLE_IMAGE} + IMAGE_FILE_LINE_NUMS_STRIPPED = $0004; // Line nunbers stripped from file. + {$EXTERNALSYM IMAGE_FILE_LINE_NUMS_STRIPPED} + IMAGE_FILE_LOCAL_SYMS_STRIPPED = $0008; // Local symbols stripped from file. + {$EXTERNALSYM IMAGE_FILE_LOCAL_SYMS_STRIPPED} + IMAGE_FILE_AGGRESIVE_WS_TRIM = $0010; // Agressively trim working set + {$EXTERNALSYM IMAGE_FILE_AGGRESIVE_WS_TRIM} + IMAGE_FILE_LARGE_ADDRESS_AWARE = $0020; // App can handle >2gb addresses + {$EXTERNALSYM IMAGE_FILE_LARGE_ADDRESS_AWARE} + IMAGE_FILE_BYTES_REVERSED_LO = $0080; // Bytes of machine word are reversed. + {$EXTERNALSYM IMAGE_FILE_BYTES_REVERSED_LO} + IMAGE_FILE_32BIT_MACHINE = $0100; // 32 bit word machine. + {$EXTERNALSYM IMAGE_FILE_32BIT_MACHINE} + IMAGE_FILE_DEBUG_STRIPPED = $0200; // Debugging info stripped from file in .DBG file + {$EXTERNALSYM IMAGE_FILE_DEBUG_STRIPPED} + IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP = $0400; // If Image is on removable media, copy and run from the swap file. + {$EXTERNALSYM IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP} + IMAGE_FILE_NET_RUN_FROM_SWAP = $0800; // If Image is on Net, copy and run from the swap file. + {$EXTERNALSYM IMAGE_FILE_NET_RUN_FROM_SWAP} + IMAGE_FILE_SYSTEM = $1000; // System File. + {$EXTERNALSYM IMAGE_FILE_SYSTEM} + IMAGE_FILE_DLL = $2000; // File is a DLL. + {$EXTERNALSYM IMAGE_FILE_DLL} + IMAGE_FILE_UP_SYSTEM_ONLY = $4000; // File should only be run on a UP machine + {$EXTERNALSYM IMAGE_FILE_UP_SYSTEM_ONLY} + IMAGE_FILE_BYTES_REVERSED_HI = $8000; // Bytes of machine word are reversed. + {$EXTERNALSYM IMAGE_FILE_BYTES_REVERSED_HI} + + IMAGE_FILE_MACHINE_UNKNOWN = 0; + {$EXTERNALSYM IMAGE_FILE_MACHINE_UNKNOWN} + IMAGE_FILE_MACHINE_I386 = $014c; // Intel 386. + {$EXTERNALSYM IMAGE_FILE_MACHINE_I386} + IMAGE_FILE_MACHINE_R3000 = $0162; // MIPS little-endian, 0x160 big-endian + {$EXTERNALSYM IMAGE_FILE_MACHINE_R3000} + IMAGE_FILE_MACHINE_R4000 = $0166; // MIPS little-endian + {$EXTERNALSYM IMAGE_FILE_MACHINE_R4000} + IMAGE_FILE_MACHINE_R10000 = $0168; // MIPS little-endian + {$EXTERNALSYM IMAGE_FILE_MACHINE_R10000} + IMAGE_FILE_MACHINE_WCEMIPSV2 = $0169; // MIPS little-endian WCE v2 + {$EXTERNALSYM IMAGE_FILE_MACHINE_WCEMIPSV2} + IMAGE_FILE_MACHINE_ALPHA = $0184; // Alpha_AXP + {$EXTERNALSYM IMAGE_FILE_MACHINE_ALPHA} + IMAGE_FILE_MACHINE_SH3 = $01a2; // SH3 little-endian + {$EXTERNALSYM IMAGE_FILE_MACHINE_SH3} + IMAGE_FILE_MACHINE_SH3DSP = $01a3; + {$EXTERNALSYM IMAGE_FILE_MACHINE_SH3DSP} + IMAGE_FILE_MACHINE_SH3E = $01a4; // SH3E little-endian + {$EXTERNALSYM IMAGE_FILE_MACHINE_SH3E} + IMAGE_FILE_MACHINE_SH4 = $01a6; // SH4 little-endian + {$EXTERNALSYM IMAGE_FILE_MACHINE_SH4} + IMAGE_FILE_MACHINE_SH5 = $01a8; // SH5 + {$EXTERNALSYM IMAGE_FILE_MACHINE_SH5} + IMAGE_FILE_MACHINE_ARM = $01c0; // ARM Little-Endian + {$EXTERNALSYM IMAGE_FILE_MACHINE_ARM} + IMAGE_FILE_MACHINE_THUMB = $01c2; + {$EXTERNALSYM IMAGE_FILE_MACHINE_THUMB} + IMAGE_FILE_MACHINE_AM33 = $01d3; + {$EXTERNALSYM IMAGE_FILE_MACHINE_AM33} + IMAGE_FILE_MACHINE_POWERPC = $01F0; // IBM PowerPC Little-Endian + {$EXTERNALSYM IMAGE_FILE_MACHINE_POWERPC} + IMAGE_FILE_MACHINE_POWERPCFP = $01f1; + {$EXTERNALSYM IMAGE_FILE_MACHINE_POWERPCFP} + IMAGE_FILE_MACHINE_IA64 = $0200; // Intel 64 + {$EXTERNALSYM IMAGE_FILE_MACHINE_IA64} + IMAGE_FILE_MACHINE_MIPS16 = $0266; // MIPS + {$EXTERNALSYM IMAGE_FILE_MACHINE_MIPS16} + IMAGE_FILE_MACHINE_ALPHA64 = $0284; // ALPHA64 + {$EXTERNALSYM IMAGE_FILE_MACHINE_ALPHA64} + IMAGE_FILE_MACHINE_MIPSFPU = $0366; // MIPS + {$EXTERNALSYM IMAGE_FILE_MACHINE_MIPSFPU} + IMAGE_FILE_MACHINE_MIPSFPU16 = $0466; // MIPS + {$EXTERNALSYM IMAGE_FILE_MACHINE_MIPSFPU16} + IMAGE_FILE_MACHINE_AXP64 = IMAGE_FILE_MACHINE_ALPHA64; + {$EXTERNALSYM IMAGE_FILE_MACHINE_AXP64} + IMAGE_FILE_MACHINE_TRICORE = $0520; // Infineon + {$EXTERNALSYM IMAGE_FILE_MACHINE_TRICORE} + IMAGE_FILE_MACHINE_CEF = $0CEF; + {$EXTERNALSYM IMAGE_FILE_MACHINE_CEF} + IMAGE_FILE_MACHINE_EBC = $0EBC; // EFI Byte Code + {$EXTERNALSYM IMAGE_FILE_MACHINE_EBC} + IMAGE_FILE_MACHINE_AMD64 = $8664; // AMD64 (K8) + {$EXTERNALSYM IMAGE_FILE_MACHINE_AMD64} + IMAGE_FILE_MACHINE_M32R = $9041; // M32R little-endian + {$EXTERNALSYM IMAGE_FILE_MACHINE_M32R} + IMAGE_FILE_MACHINE_CEE = $C0EE; + {$EXTERNALSYM IMAGE_FILE_MACHINE_CEE} + +// +// Directory format. +// + +const + IMAGE_NUMBEROF_DIRECTORY_ENTRIES = 16; + {$EXTERNALSYM IMAGE_NUMBEROF_DIRECTORY_ENTRIES} + +// +// Optional header format. +// + +{$IFNDEF FPC} +type + PIMAGE_OPTIONAL_HEADER32 = ^IMAGE_OPTIONAL_HEADER32; + {$EXTERNALSYM PIMAGE_OPTIONAL_HEADER32} + + IMAGE_OPTIONAL_HEADER32 = _IMAGE_OPTIONAL_HEADER; + {$EXTERNALSYM IMAGE_OPTIONAL_HEADER32} + TImageOptionalHeader32 = IMAGE_OPTIONAL_HEADER32; + PImageOptionalHeader32 = PIMAGE_OPTIONAL_HEADER32; + + PIMAGE_ROM_OPTIONAL_HEADER = ^IMAGE_ROM_OPTIONAL_HEADER; + {$EXTERNALSYM PIMAGE_ROM_OPTIONAL_HEADER} + _IMAGE_ROM_OPTIONAL_HEADER = record + Magic: Word; + MajorLinkerVersion: Byte; + MinorLinkerVersion: Byte; + SizeOfCode: DWORD; + SizeOfInitializedData: DWORD; + SizeOfUninitializedData: DWORD; + AddressOfEntryPoint: DWORD; + BaseOfCode: DWORD; + BaseOfData: DWORD; + BaseOfBss: DWORD; + GprMask: DWORD; + CprMask: array [0..3] of DWORD; + GpValue: DWORD; + end; + {$EXTERNALSYM _IMAGE_ROM_OPTIONAL_HEADER} + IMAGE_ROM_OPTIONAL_HEADER = _IMAGE_ROM_OPTIONAL_HEADER; + {$EXTERNALSYM IMAGE_ROM_OPTIONAL_HEADER} + TImageRomOptionalHeader = IMAGE_ROM_OPTIONAL_HEADER; + PImageRomOptionalHeader = PIMAGE_ROM_OPTIONAL_HEADER; + + PIMAGE_OPTIONAL_HEADER64 = ^IMAGE_OPTIONAL_HEADER64; + {$EXTERNALSYM PIMAGE_OPTIONAL_HEADER64} + _IMAGE_OPTIONAL_HEADER64 = record + Magic: Word; + MajorLinkerVersion: Byte; + MinorLinkerVersion: Byte; + SizeOfCode: DWORD; + SizeOfInitializedData: DWORD; + SizeOfUninitializedData: DWORD; + AddressOfEntryPoint: DWORD; + BaseOfCode: DWORD; + ImageBase: Int64; + SectionAlignment: DWORD; + FileAlignment: DWORD; + MajorOperatingSystemVersion: Word; + MinorOperatingSystemVersion: Word; + MajorImageVersion: Word; + MinorImageVersion: Word; + MajorSubsystemVersion: Word; + MinorSubsystemVersion: Word; + Win32VersionValue: DWORD; + SizeOfImage: DWORD; + SizeOfHeaders: DWORD; + CheckSum: DWORD; + Subsystem: Word; + DllCharacteristics: Word; + SizeOfStackReserve: Int64; + SizeOfStackCommit: Int64; + SizeOfHeapReserve: Int64; + SizeOfHeapCommit: Int64; + LoaderFlags: DWORD; + NumberOfRvaAndSizes: DWORD; + DataDirectory: array [0..IMAGE_NUMBEROF_DIRECTORY_ENTRIES - 1] of IMAGE_DATA_DIRECTORY; + end; + {$EXTERNALSYM _IMAGE_OPTIONAL_HEADER64} + IMAGE_OPTIONAL_HEADER64 = _IMAGE_OPTIONAL_HEADER64; + {$EXTERNALSYM IMAGE_OPTIONAL_HEADER64} + TImageOptionalHeader64 = IMAGE_OPTIONAL_HEADER64; + PImageOptionalHeader64 = PIMAGE_OPTIONAL_HEADER64; +{$ENDIF ~FPC} + +const + IMAGE_SIZEOF_ROM_OPTIONAL_HEADER = 56; + {$EXTERNALSYM IMAGE_SIZEOF_ROM_OPTIONAL_HEADER} + IMAGE_SIZEOF_STD_OPTIONAL_HEADER = 28; + {$EXTERNALSYM IMAGE_SIZEOF_STD_OPTIONAL_HEADER} + IMAGE_SIZEOF_NT_OPTIONAL32_HEADER = 224; + {$EXTERNALSYM IMAGE_SIZEOF_NT_OPTIONAL32_HEADER} + IMAGE_SIZEOF_NT_OPTIONAL64_HEADER = 240; + {$EXTERNALSYM IMAGE_SIZEOF_NT_OPTIONAL64_HEADER} + + IMAGE_NT_OPTIONAL_HDR32_MAGIC = $10b; + {$EXTERNALSYM IMAGE_NT_OPTIONAL_HDR32_MAGIC} + IMAGE_NT_OPTIONAL_HDR64_MAGIC = $20b; + {$EXTERNALSYM IMAGE_NT_OPTIONAL_HDR64_MAGIC} + IMAGE_ROM_OPTIONAL_HDR_MAGIC = $107; + {$EXTERNALSYM IMAGE_ROM_OPTIONAL_HDR_MAGIC} + +(* +type + IMAGE_OPTIONAL_HEADER = IMAGE_OPTIONAL_HEADER32; + {$EXTERNALSYM IMAGE_OPTIONAL_HEADER} + PIMAGE_OPTIONAL_HEADER = PIMAGE_OPTIONAL_HEADER32; + {$EXTERNALSYM PIMAGE_OPTIONAL_HEADER} +*) + +const + IMAGE_SIZEOF_NT_OPTIONAL_HEADER = IMAGE_SIZEOF_NT_OPTIONAL32_HEADER; + {$EXTERNALSYM IMAGE_SIZEOF_NT_OPTIONAL_HEADER} + IMAGE_NT_OPTIONAL_HDR_MAGIC = IMAGE_NT_OPTIONAL_HDR32_MAGIC; + {$EXTERNALSYM IMAGE_NT_OPTIONAL_HDR_MAGIC} + +{$IFNDEF FPC} +type + PIMAGE_NT_HEADERS64 = ^IMAGE_NT_HEADERS64; + {$EXTERNALSYM PIMAGE_NT_HEADERS64} + _IMAGE_NT_HEADERS64 = record + Signature: DWORD; + FileHeader: IMAGE_FILE_HEADER; + OptionalHeader: IMAGE_OPTIONAL_HEADER64; + end; + {$EXTERNALSYM _IMAGE_NT_HEADERS64} + IMAGE_NT_HEADERS64 = _IMAGE_NT_HEADERS64; + {$EXTERNALSYM IMAGE_NT_HEADERS64} + TImageNtHeaders64 = IMAGE_NT_HEADERS64; + PImageNtHeaders64 = PIMAGE_NT_HEADERS64; + + PIMAGE_NT_HEADERS32 = ^IMAGE_NT_HEADERS32; + {$EXTERNALSYM PIMAGE_NT_HEADERS32} + _IMAGE_NT_HEADERS = record + Signature: DWORD; + FileHeader: IMAGE_FILE_HEADER; + OptionalHeader: IMAGE_OPTIONAL_HEADER32; + end; + {$EXTERNALSYM _IMAGE_NT_HEADERS} + IMAGE_NT_HEADERS32 = _IMAGE_NT_HEADERS; + {$EXTERNALSYM IMAGE_NT_HEADERS32} + TImageNtHeaders32 = IMAGE_NT_HEADERS32; + PImageNtHeaders32 = PIMAGE_NT_HEADERS32; +{$ENDIF ~FPC} + +// Subsystem Values + +const + IMAGE_SUBSYSTEM_UNKNOWN = 0; // Unknown subsystem. + {$EXTERNALSYM IMAGE_SUBSYSTEM_UNKNOWN} + IMAGE_SUBSYSTEM_NATIVE = 1; // Image doesn't require a subsystem. + {$EXTERNALSYM IMAGE_SUBSYSTEM_NATIVE} + IMAGE_SUBSYSTEM_WINDOWS_GUI = 2; // Image runs in the Windows GUI subsystem. + {$EXTERNALSYM IMAGE_SUBSYSTEM_WINDOWS_GUI} + IMAGE_SUBSYSTEM_WINDOWS_CUI = 3; // Image runs in the Windows character subsystem. + {$EXTERNALSYM IMAGE_SUBSYSTEM_WINDOWS_CUI} + IMAGE_SUBSYSTEM_OS2_CUI = 5; // image runs in the OS/2 character subsystem. + {$EXTERNALSYM IMAGE_SUBSYSTEM_OS2_CUI} + IMAGE_SUBSYSTEM_POSIX_CUI = 7; // image runs in the Posix character subsystem. + {$EXTERNALSYM IMAGE_SUBSYSTEM_POSIX_CUI} + IMAGE_SUBSYSTEM_NATIVE_WINDOWS = 8; // image is a native Win9x driver. + {$EXTERNALSYM IMAGE_SUBSYSTEM_NATIVE_WINDOWS} + IMAGE_SUBSYSTEM_WINDOWS_CE_GUI = 9; // Image runs in the Windows CE subsystem. + {$EXTERNALSYM IMAGE_SUBSYSTEM_WINDOWS_CE_GUI} + IMAGE_SUBSYSTEM_EFI_APPLICATION = 10; + {$EXTERNALSYM IMAGE_SUBSYSTEM_EFI_APPLICATION} + IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER = 11; + {$EXTERNALSYM IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER} + IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER = 12; + {$EXTERNALSYM IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER} + IMAGE_SUBSYSTEM_EFI_ROM = 13; + {$EXTERNALSYM IMAGE_SUBSYSTEM_EFI_ROM} + IMAGE_SUBSYSTEM_XBOX = 14; + {$EXTERNALSYM IMAGE_SUBSYSTEM_XBOX} + +// DllCharacteristics Entries + +// IMAGE_LIBRARY_PROCESS_INIT 0x0001 // Reserved. +// IMAGE_LIBRARY_PROCESS_TERM 0x0002 // Reserved. +// IMAGE_LIBRARY_THREAD_INIT 0x0004 // Reserved. +// IMAGE_LIBRARY_THREAD_TERM 0x0008 // Reserved. + IMAGE_DLLCHARACTERISTICS_NO_ISOLATION = $0200; // Image understands isolation and doesn't want it + {$EXTERNALSYM IMAGE_DLLCHARACTERISTICS_NO_ISOLATION} + IMAGE_DLLCHARACTERISTICS_NO_SEH = $0400; // Image does not use SEH. No SE handler may reside in this image + {$EXTERNALSYM IMAGE_DLLCHARACTERISTICS_NO_SEH} + IMAGE_DLLCHARACTERISTICS_NO_BIND = $0800; // Do not bind this image. + {$EXTERNALSYM IMAGE_DLLCHARACTERISTICS_NO_BIND} + +// 0x1000 // Reserved. + + IMAGE_DLLCHARACTERISTICS_WDM_DRIVER = $2000; // Driver uses WDM model + {$EXTERNALSYM IMAGE_DLLCHARACTERISTICS_WDM_DRIVER} + +// 0x4000 // Reserved. + + IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE = $8000; + {$EXTERNALSYM IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE} + +// Directory Entries + + IMAGE_DIRECTORY_ENTRY_EXPORT = 0; // Export Directory + {$EXTERNALSYM IMAGE_DIRECTORY_ENTRY_EXPORT} + IMAGE_DIRECTORY_ENTRY_IMPORT = 1; // Import Directory + {$EXTERNALSYM IMAGE_DIRECTORY_ENTRY_IMPORT} + IMAGE_DIRECTORY_ENTRY_RESOURCE = 2; // Resource Directory + {$EXTERNALSYM IMAGE_DIRECTORY_ENTRY_RESOURCE} + IMAGE_DIRECTORY_ENTRY_EXCEPTION = 3; // Exception Directory + {$EXTERNALSYM IMAGE_DIRECTORY_ENTRY_EXCEPTION} + IMAGE_DIRECTORY_ENTRY_SECURITY = 4; // Security Directory + {$EXTERNALSYM IMAGE_DIRECTORY_ENTRY_SECURITY} + IMAGE_DIRECTORY_ENTRY_BASERELOC = 5; // Base Relocation Table + {$EXTERNALSYM IMAGE_DIRECTORY_ENTRY_BASERELOC} + IMAGE_DIRECTORY_ENTRY_DEBUG = 6; // Debug Directory + {$EXTERNALSYM IMAGE_DIRECTORY_ENTRY_DEBUG} + +// IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7 // (X86 usage) + + IMAGE_DIRECTORY_ENTRY_ARCHITECTURE = 7; // Architecture Specific Data + {$EXTERNALSYM IMAGE_DIRECTORY_ENTRY_ARCHITECTURE} + IMAGE_DIRECTORY_ENTRY_GLOBALPTR = 8; // RVA of GP + {$EXTERNALSYM IMAGE_DIRECTORY_ENTRY_GLOBALPTR} + IMAGE_DIRECTORY_ENTRY_TLS = 9; // TLS Directory + {$EXTERNALSYM IMAGE_DIRECTORY_ENTRY_TLS} + IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG = 10; // Load Configuration Directory + {$EXTERNALSYM IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG} + IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT = 11; // Bound Import Directory in headers + {$EXTERNALSYM IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT} + IMAGE_DIRECTORY_ENTRY_IAT = 12; // Import Address Table + {$EXTERNALSYM IMAGE_DIRECTORY_ENTRY_IAT} + IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT = 13; // Delay Load Import Descriptors + {$EXTERNALSYM IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT} + IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR = 14; // COM Runtime descriptor + {$EXTERNALSYM IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR} + +// +// Non-COFF Object file header +// + +type + PAnonObjectHeader = ^ANON_OBJECT_HEADER; + ANON_OBJECT_HEADER = record + Sig1: Word; // Must be IMAGE_FILE_MACHINE_UNKNOWN + Sig2: Word; // Must be 0xffff + Version: Word; // >= 1 (implies the CLSID field is present) + Machine: Word; + TimeDateStamp: DWORD; + ClassID: TCLSID; // Used to invoke CoCreateInstance + SizeOfData: DWORD; // Size of data that follows the header + end; + {$EXTERNALSYM ANON_OBJECT_HEADER} + TAnonObjectHeader = ANON_OBJECT_HEADER; + +// +// Section header format. +// + +const + IMAGE_SIZEOF_SHORT_NAME = 8; + {$EXTERNALSYM IMAGE_SIZEOF_SHORT_NAME} + +type + PPImageSectionHeader = ^PImageSectionHeader; + +// IMAGE_FIRST_SECTION doesn't need 32/64 versions since the file header is the same either way. + +function IMAGE_FIRST_SECTION(NtHeader: PImageNtHeaders): PImageSectionHeader; +{$EXTERNALSYM IMAGE_FIRST_SECTION} + +const + IMAGE_SIZEOF_SECTION_HEADER = 40; + {$EXTERNALSYM IMAGE_SIZEOF_SECTION_HEADER} + +// +// Section characteristics. +// +// IMAGE_SCN_TYPE_REG 0x00000000 // Reserved. +// IMAGE_SCN_TYPE_DSECT 0x00000001 // Reserved. +// IMAGE_SCN_TYPE_NOLOAD 0x00000002 // Reserved. +// IMAGE_SCN_TYPE_GROUP 0x00000004 // Reserved. + + IMAGE_SCN_TYPE_NO_PAD = $00000008; // Reserved. + {$EXTERNALSYM IMAGE_SCN_TYPE_NO_PAD} + +// IMAGE_SCN_TYPE_COPY 0x00000010 // Reserved. + + IMAGE_SCN_CNT_CODE = $00000020; // Section contains code. + {$EXTERNALSYM IMAGE_SCN_CNT_CODE} + IMAGE_SCN_CNT_INITIALIZED_DATA = $00000040; // Section contains initialized data. + {$EXTERNALSYM IMAGE_SCN_CNT_INITIALIZED_DATA} + IMAGE_SCN_CNT_UNINITIALIZED_DATA = $00000080; // Section contains uninitialized data. + {$EXTERNALSYM IMAGE_SCN_CNT_UNINITIALIZED_DATA} + + IMAGE_SCN_LNK_OTHER = $00000100; // Reserved. + {$EXTERNALSYM IMAGE_SCN_LNK_OTHER} + IMAGE_SCN_LNK_INFO = $00000200; // Section contains comments or some other type of information. + {$EXTERNALSYM IMAGE_SCN_LNK_INFO} + +// IMAGE_SCN_TYPE_OVER 0x00000400 // Reserved. + + IMAGE_SCN_LNK_REMOVE = $00000800; // Section contents will not become part of image. + {$EXTERNALSYM IMAGE_SCN_LNK_REMOVE} + IMAGE_SCN_LNK_COMDAT = $00001000; // Section contents comdat. + {$EXTERNALSYM IMAGE_SCN_LNK_COMDAT} + +// 0x00002000 // Reserved. +// IMAGE_SCN_MEM_PROTECTED - Obsolete 0x00004000 + + IMAGE_SCN_NO_DEFER_SPEC_EXC = $00004000; // Reset speculative exceptions handling bits in the TLB entries for this section. + {$EXTERNALSYM IMAGE_SCN_NO_DEFER_SPEC_EXC} + IMAGE_SCN_GPREL = $00008000; // Section content can be accessed relative to GP + {$EXTERNALSYM IMAGE_SCN_GPREL} + IMAGE_SCN_MEM_FARDATA = $00008000; + {$EXTERNALSYM IMAGE_SCN_MEM_FARDATA} + +// IMAGE_SCN_MEM_SYSHEAP - Obsolete 0x00010000 + + IMAGE_SCN_MEM_PURGEABLE = $00020000; + {$EXTERNALSYM IMAGE_SCN_MEM_PURGEABLE} + IMAGE_SCN_MEM_16BIT = $00020000; + {$EXTERNALSYM IMAGE_SCN_MEM_16BIT} + IMAGE_SCN_MEM_LOCKED = $00040000; + {$EXTERNALSYM IMAGE_SCN_MEM_LOCKED} + IMAGE_SCN_MEM_PRELOAD = $00080000; + {$EXTERNALSYM IMAGE_SCN_MEM_PRELOAD} + + IMAGE_SCN_ALIGN_1BYTES = $00100000; + {$EXTERNALSYM IMAGE_SCN_ALIGN_1BYTES} + IMAGE_SCN_ALIGN_2BYTES = $00200000; + {$EXTERNALSYM IMAGE_SCN_ALIGN_2BYTES} + IMAGE_SCN_ALIGN_4BYTES = $00300000; + {$EXTERNALSYM IMAGE_SCN_ALIGN_4BYTES} + IMAGE_SCN_ALIGN_8BYTES = $00400000; + {$EXTERNALSYM IMAGE_SCN_ALIGN_8BYTES} + IMAGE_SCN_ALIGN_16BYTES = $00500000; // Default alignment if no others are specified. + {$EXTERNALSYM IMAGE_SCN_ALIGN_16BYTES} + IMAGE_SCN_ALIGN_32BYTES = $00600000; + {$EXTERNALSYM IMAGE_SCN_ALIGN_32BYTES} + IMAGE_SCN_ALIGN_64BYTES = $00700000; + {$EXTERNALSYM IMAGE_SCN_ALIGN_64BYTES} + IMAGE_SCN_ALIGN_128BYTES = $00800000; + {$EXTERNALSYM IMAGE_SCN_ALIGN_128BYTES} + IMAGE_SCN_ALIGN_256BYTES = $00900000; + {$EXTERNALSYM IMAGE_SCN_ALIGN_256BYTES} + IMAGE_SCN_ALIGN_512BYTES = $00A00000; + {$EXTERNALSYM IMAGE_SCN_ALIGN_512BYTES} + IMAGE_SCN_ALIGN_1024BYTES = $00B00000; + {$EXTERNALSYM IMAGE_SCN_ALIGN_1024BYTES} + IMAGE_SCN_ALIGN_2048BYTES = $00C00000; + {$EXTERNALSYM IMAGE_SCN_ALIGN_2048BYTES} + IMAGE_SCN_ALIGN_4096BYTES = $00D00000; + {$EXTERNALSYM IMAGE_SCN_ALIGN_4096BYTES} + IMAGE_SCN_ALIGN_8192BYTES = $00E00000; + {$EXTERNALSYM IMAGE_SCN_ALIGN_8192BYTES} + +// Unused 0x00F00000 + + IMAGE_SCN_ALIGN_MASK = $00F00000; + {$EXTERNALSYM IMAGE_SCN_ALIGN_MASK} + + IMAGE_SCN_LNK_NRELOC_OVFL = $01000000; // Section contains extended relocations. + {$EXTERNALSYM IMAGE_SCN_LNK_NRELOC_OVFL} + IMAGE_SCN_MEM_DISCARDABLE = $02000000; // Section can be discarded. + {$EXTERNALSYM IMAGE_SCN_MEM_DISCARDABLE} + IMAGE_SCN_MEM_NOT_CACHED = $04000000; // Section is not cachable. + {$EXTERNALSYM IMAGE_SCN_MEM_NOT_CACHED} + IMAGE_SCN_MEM_NOT_PAGED = $08000000; // Section is not pageable. + {$EXTERNALSYM IMAGE_SCN_MEM_NOT_PAGED} + IMAGE_SCN_MEM_SHARED = $10000000; // Section is shareable. + {$EXTERNALSYM IMAGE_SCN_MEM_SHARED} + IMAGE_SCN_MEM_EXECUTE = $20000000; // Section is executable. + {$EXTERNALSYM IMAGE_SCN_MEM_EXECUTE} + IMAGE_SCN_MEM_READ = $40000000; // Section is readable. + {$EXTERNALSYM IMAGE_SCN_MEM_READ} + IMAGE_SCN_MEM_WRITE = DWORD($80000000); // Section is writeable. + {$EXTERNALSYM IMAGE_SCN_MEM_WRITE} + +// line 6232 + +// +// Line number format. +// + +type + TImgLineNoType = record + case Integer of + 0: (SymbolTableIndex: DWORD); // Symbol table index of function name if Linenumber is 0. + 1: (VirtualAddress: DWORD); // Virtual address of line number. + end; + + PIMAGE_LINENUMBER = ^IMAGE_LINENUMBER; + {$EXTERNALSYM PIMAGE_LINENUMBER} + _IMAGE_LINENUMBER = record + Type_: TImgLineNoType; + Linenumber: WORD; // Line number. + end; + {$EXTERNALSYM _IMAGE_LINENUMBER} + IMAGE_LINENUMBER = _IMAGE_LINENUMBER; + {$EXTERNALSYM IMAGE_LINENUMBER} + TImageLineNumber = IMAGE_LINENUMBER; + PImageLineNumber = PIMAGE_LINENUMBER; + +const + IMAGE_SIZEOF_LINENUMBER = 6; + {$EXTERNALSYM IMAGE_SIZEOF_LINENUMBER} + +// #include "poppack.h" // Back to 4 byte packing + +// +// Based relocation format. +// + +type + PIMAGE_BASE_RELOCATION = ^IMAGE_BASE_RELOCATION; + {$EXTERNALSYM PIMAGE_BASE_RELOCATION} + _IMAGE_BASE_RELOCATION = record + VirtualAddress: DWORD; + SizeOfBlock: DWORD; + // WORD TypeOffset[1]; + end; + {$EXTERNALSYM _IMAGE_BASE_RELOCATION} + IMAGE_BASE_RELOCATION = _IMAGE_BASE_RELOCATION; + {$EXTERNALSYM IMAGE_BASE_RELOCATION} + TImageBaseRelocation = IMAGE_BASE_RELOCATION; + PImageBaseRelocation = PIMAGE_BASE_RELOCATION; + +const + IMAGE_SIZEOF_BASE_RELOCATION = 8; + {$EXTERNALSYM IMAGE_SIZEOF_BASE_RELOCATION} + +// +// Based relocation types. +// + + IMAGE_REL_BASED_ABSOLUTE = 0; + {$EXTERNALSYM IMAGE_REL_BASED_ABSOLUTE} + IMAGE_REL_BASED_HIGH = 1; + {$EXTERNALSYM IMAGE_REL_BASED_HIGH} + IMAGE_REL_BASED_LOW = 2; + {$EXTERNALSYM IMAGE_REL_BASED_LOW} + IMAGE_REL_BASED_HIGHLOW = 3; + {$EXTERNALSYM IMAGE_REL_BASED_HIGHLOW} + IMAGE_REL_BASED_HIGHADJ = 4; + {$EXTERNALSYM IMAGE_REL_BASED_HIGHADJ} + IMAGE_REL_BASED_MIPS_JMPADDR = 5; + {$EXTERNALSYM IMAGE_REL_BASED_MIPS_JMPADDR} + + IMAGE_REL_BASED_MIPS_JMPADDR16 = 9; + {$EXTERNALSYM IMAGE_REL_BASED_MIPS_JMPADDR16} + IMAGE_REL_BASED_IA64_IMM64 = 9; + {$EXTERNALSYM IMAGE_REL_BASED_IA64_IMM64} + IMAGE_REL_BASED_DIR64 = 10; + {$EXTERNALSYM IMAGE_REL_BASED_DIR64} + +// +// Archive format. +// + + IMAGE_ARCHIVE_START_SIZE = 8; + {$EXTERNALSYM IMAGE_ARCHIVE_START_SIZE} + IMAGE_ARCHIVE_START = '!'#10; + {$EXTERNALSYM IMAGE_ARCHIVE_START} + IMAGE_ARCHIVE_END = '`'#10; + {$EXTERNALSYM IMAGE_ARCHIVE_END} + IMAGE_ARCHIVE_PAD = #10; + {$EXTERNALSYM IMAGE_ARCHIVE_PAD} + IMAGE_ARCHIVE_LINKER_MEMBER = '/ '; + {$EXTERNALSYM IMAGE_ARCHIVE_LINKER_MEMBER} + IMAGE_ARCHIVE_LONGNAMES_MEMBER = '// '; + {$EXTERNALSYM IMAGE_ARCHIVE_LONGNAMES_MEMBER} + +type + PIMAGE_ARCHIVE_MEMBER_HEADER = ^IMAGE_ARCHIVE_MEMBER_HEADER; + {$EXTERNALSYM PIMAGE_ARCHIVE_MEMBER_HEADER} + _IMAGE_ARCHIVE_MEMBER_HEADER = record + Name: array [0..15] of Byte; // File member name - `/' terminated. + Date: array [0..11] of Byte; // File member date - decimal. + UserID: array [0..5] of Byte; // File member user id - decimal. + GroupID: array [0..5] of Byte; // File member group id - decimal. + Mode: array [0..7] of Byte; // File member mode - octal. + Size: array [0..9] of Byte; // File member size - decimal. + EndHeader: array [0..1] of Byte; // String to end header. + end; + {$EXTERNALSYM _IMAGE_ARCHIVE_MEMBER_HEADER} + IMAGE_ARCHIVE_MEMBER_HEADER = _IMAGE_ARCHIVE_MEMBER_HEADER; + {$EXTERNALSYM IMAGE_ARCHIVE_MEMBER_HEADER} + TImageArchiveMemberHeader = IMAGE_ARCHIVE_MEMBER_HEADER; + PImageArchiveMemberHeader = PIMAGE_ARCHIVE_MEMBER_HEADER; + +const + IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR = 60; + {$EXTERNALSYM IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR} + +// line 6346 + +// +// DLL support. +// + +// +// Export Format +// + +type + PIMAGE_EXPORT_DIRECTORY = ^IMAGE_EXPORT_DIRECTORY; + {$EXTERNALSYM PIMAGE_EXPORT_DIRECTORY} + _IMAGE_EXPORT_DIRECTORY = record + Characteristics: DWORD; + TimeDateStamp: DWORD; + MajorVersion: Word; + MinorVersion: Word; + Name: DWORD; + Base: DWORD; + NumberOfFunctions: DWORD; + NumberOfNames: DWORD; + AddressOfFunctions: DWORD; // RVA from base of image + AddressOfNames: DWORD; // RVA from base of image + AddressOfNameOrdinals: DWORD; // RVA from base of image + end; + {$EXTERNALSYM _IMAGE_EXPORT_DIRECTORY} + IMAGE_EXPORT_DIRECTORY = _IMAGE_EXPORT_DIRECTORY; + {$EXTERNALSYM IMAGE_EXPORT_DIRECTORY} + TImageExportDirectory = IMAGE_EXPORT_DIRECTORY; + PImageExportDirectory = PIMAGE_EXPORT_DIRECTORY; + +// +// Import Format +// + + PIMAGE_IMPORT_BY_NAME = ^IMAGE_IMPORT_BY_NAME; + {$EXTERNALSYM PIMAGE_IMPORT_BY_NAME} + _IMAGE_IMPORT_BY_NAME = record + Hint: Word; + Name: array [0..0] of AnsiChar; + end; + {$EXTERNALSYM _IMAGE_IMPORT_BY_NAME} + IMAGE_IMPORT_BY_NAME = _IMAGE_IMPORT_BY_NAME; + {$EXTERNALSYM IMAGE_IMPORT_BY_NAME} + TImageImportByName = IMAGE_IMPORT_BY_NAME; + PImageImportByName = PIMAGE_IMPORT_BY_NAME; + +// #include "pshpack8.h" // Use align 8 for the 64-bit IAT. + + PIMAGE_THUNK_DATA64 = ^IMAGE_THUNK_DATA64; + {$EXTERNALSYM PIMAGE_THUNK_DATA64} + _IMAGE_THUNK_DATA64 = record + case Integer of + 0: (ForwarderString: ULONGLONG); // PBYTE + 1: (Function_: ULONGLONG); // PDWORD + 2: (Ordinal: ULONGLONG); + 3: (AddressOfData: ULONGLONG); // PIMAGE_IMPORT_BY_NAME + end; + {$EXTERNALSYM _IMAGE_THUNK_DATA64} + IMAGE_THUNK_DATA64 = _IMAGE_THUNK_DATA64; + {$EXTERNALSYM IMAGE_THUNK_DATA64} + TImageThunkData64 = IMAGE_THUNK_DATA64; + PImageThunkData64 = PIMAGE_THUNK_DATA64; + +// #include "poppack.h" // Back to 4 byte packing + + PIMAGE_THUNK_DATA32 = ^IMAGE_THUNK_DATA32; + {$EXTERNALSYM PIMAGE_THUNK_DATA32} + _IMAGE_THUNK_DATA32 = record + case Integer of + 0: (ForwarderString: DWORD); // PBYTE + 1: (Function_: DWORD); // PDWORD + 2: (Ordinal: DWORD); + 3: (AddressOfData: DWORD); // PIMAGE_IMPORT_BY_NAME + end; + {$EXTERNALSYM _IMAGE_THUNK_DATA32} + IMAGE_THUNK_DATA32 = _IMAGE_THUNK_DATA32; + {$EXTERNALSYM IMAGE_THUNK_DATA32} + TImageThunkData32 = IMAGE_THUNK_DATA32; + PImageThunkData32 = PIMAGE_THUNK_DATA32; + +const + IMAGE_ORDINAL_FLAG64 = ULONGLONG($8000000000000000); + {$EXTERNALSYM IMAGE_ORDINAL_FLAG64} + IMAGE_ORDINAL_FLAG32 = DWORD($80000000); + {$EXTERNALSYM IMAGE_ORDINAL_FLAG32} + +function IMAGE_ORDINAL64(Ordinal: ULONGLONG): ULONGLONG; +{$EXTERNALSYM IMAGE_ORDINAL64} +function IMAGE_ORDINAL32(Ordinal: DWORD): DWORD; +{$EXTERNALSYM IMAGE_ORDINAL32} +function IMAGE_SNAP_BY_ORDINAL64(Ordinal: ULONGLONG): Boolean; +{$EXTERNALSYM IMAGE_SNAP_BY_ORDINAL64} +function IMAGE_SNAP_BY_ORDINAL32(Ordinal: DWORD): Boolean; +{$EXTERNALSYM IMAGE_SNAP_BY_ORDINAL32} + +// +// Thread Local Storage +// + +type + PIMAGE_TLS_CALLBACK = procedure (DllHandle: Pointer; Reason: DWORD; Reserved: Pointer); stdcall; + {$EXTERNALSYM PIMAGE_TLS_CALLBACK} + TImageTlsCallback = PIMAGE_TLS_CALLBACK; + + PIMAGE_TLS_DIRECTORY64 = ^IMAGE_TLS_DIRECTORY64; + {$EXTERNALSYM PIMAGE_TLS_DIRECTORY64} + _IMAGE_TLS_DIRECTORY64 = record + StartAddressOfRawData: ULONGLONG; + EndAddressOfRawData: ULONGLONG; + AddressOfIndex: ULONGLONG; // PDWORD + AddressOfCallBacks: ULONGLONG; // PIMAGE_TLS_CALLBACK *; + SizeOfZeroFill: DWORD; + Characteristics: DWORD; + end; + {$EXTERNALSYM _IMAGE_TLS_DIRECTORY64} + IMAGE_TLS_DIRECTORY64 = _IMAGE_TLS_DIRECTORY64; + {$EXTERNALSYM IMAGE_TLS_DIRECTORY64} + TImageTlsDirectory64 = IMAGE_TLS_DIRECTORY64; + {$EXTERNALSYM TImageTlsDirectory64} + PImageTlsDirectory64 = PIMAGE_TLS_DIRECTORY64; + {$EXTERNALSYM PImageTlsDirectory64} + + PIMAGE_TLS_DIRECTORY32 = ^IMAGE_TLS_DIRECTORY32; + {$EXTERNALSYM PIMAGE_TLS_DIRECTORY32} + _IMAGE_TLS_DIRECTORY32 = record + StartAddressOfRawData: DWORD; + EndAddressOfRawData: DWORD; + AddressOfIndex: DWORD; // PDWORD + AddressOfCallBacks: DWORD; // PIMAGE_TLS_CALLBACK * + SizeOfZeroFill: DWORD; + Characteristics: DWORD; + end; + {$EXTERNALSYM _IMAGE_TLS_DIRECTORY32} + IMAGE_TLS_DIRECTORY32 = _IMAGE_TLS_DIRECTORY32; + {$EXTERNALSYM IMAGE_TLS_DIRECTORY32} + TImageTlsDirectory32 = IMAGE_TLS_DIRECTORY32; + {$EXTERNALSYM TImageTlsDirectory32} + PImageTlsDirectory32 = PIMAGE_TLS_DIRECTORY32; + {$EXTERNALSYM PImageTlsDirectory32} + +const + IMAGE_ORDINAL_FLAG = IMAGE_ORDINAL_FLAG32; + {$EXTERNALSYM IMAGE_ORDINAL_FLAG} + +function IMAGE_ORDINAL(Ordinal: DWORD): DWORD; +{$EXTERNALSYM IMAGE_ORDINAL} + +type + IMAGE_THUNK_DATA = IMAGE_THUNK_DATA32; + {$EXTERNALSYM IMAGE_THUNK_DATA} + PIMAGE_THUNK_DATA = PIMAGE_THUNK_DATA32; + {$EXTERNALSYM PIMAGE_THUNK_DATA} + TImageThunkData = TImageThunkData32; + PImageThunkData = PImageThunkData32; + +function IMAGE_SNAP_BY_ORDINAL(Ordinal: DWORD): Boolean; +{$EXTERNALSYM IMAGE_SNAP_BY_ORDINAL} + +type + IMAGE_TLS_DIRECTORY = IMAGE_TLS_DIRECTORY32; + {$EXTERNALSYM IMAGE_TLS_DIRECTORY} + PIMAGE_TLS_DIRECTORY = PIMAGE_TLS_DIRECTORY32; + {$EXTERNALSYM PIMAGE_TLS_DIRECTORY} + TImageTlsDirectory = TImageTlsDirectory32; + {$EXTERNALSYM TImageTlsDirectory} + PImageTlsDirectory = PImageTlsDirectory32; + {$EXTERNALSYM PImageTlsDirectory} + + TIIDUnion = record + case Integer of + 0: (Characteristics: DWORD); // 0 for terminating null import descriptor + 1: (OriginalFirstThunk: DWORD); // RVA to original unbound IAT (PIMAGE_THUNK_DATA) + end; + + PIMAGE_IMPORT_DESCRIPTOR = ^IMAGE_IMPORT_DESCRIPTOR; + {$EXTERNALSYM PIMAGE_IMPORT_DESCRIPTOR} + _IMAGE_IMPORT_DESCRIPTOR = record + Union: TIIDUnion; + TimeDateStamp: DWORD; // 0 if not bound, + // -1 if bound, and real date\time stamp + // in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT (new BIND) + // O.W. date/time stamp of DLL bound to (Old BIND) + + ForwarderChain: DWORD; // -1 if no forwarders + Name: DWORD; + FirstThunk: DWORD; // RVA to IAT (if bound this IAT has actual addresses) + end; + {$EXTERNALSYM _IMAGE_IMPORT_DESCRIPTOR} + IMAGE_IMPORT_DESCRIPTOR = _IMAGE_IMPORT_DESCRIPTOR; + {$EXTERNALSYM IMAGE_IMPORT_DESCRIPTOR} + TImageImportDescriptor = IMAGE_IMPORT_DESCRIPTOR; + PImageImportDescriptor = PIMAGE_IMPORT_DESCRIPTOR; + +// +// New format import descriptors pointed to by DataDirectory[ IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT ] +// + +type + PIMAGE_BOUND_IMPORT_DESCRIPTOR = ^IMAGE_BOUND_IMPORT_DESCRIPTOR; + {$EXTERNALSYM PIMAGE_BOUND_IMPORT_DESCRIPTOR} + _IMAGE_BOUND_IMPORT_DESCRIPTOR = record + TimeDateStamp: DWORD; + OffsetModuleName: Word; + NumberOfModuleForwarderRefs: Word; + // Array of zero or more IMAGE_BOUND_FORWARDER_REF follows + end; + {$EXTERNALSYM _IMAGE_BOUND_IMPORT_DESCRIPTOR} + IMAGE_BOUND_IMPORT_DESCRIPTOR = _IMAGE_BOUND_IMPORT_DESCRIPTOR; + {$EXTERNALSYM IMAGE_BOUND_IMPORT_DESCRIPTOR} + TImageBoundImportDescriptor = IMAGE_BOUND_IMPORT_DESCRIPTOR; + PImageBoundImportDescriptor = PIMAGE_BOUND_IMPORT_DESCRIPTOR; + + PIMAGE_BOUND_FORWARDER_REF = ^IMAGE_BOUND_FORWARDER_REF; + {$EXTERNALSYM PIMAGE_BOUND_FORWARDER_REF} + _IMAGE_BOUND_FORWARDER_REF = record + TimeDateStamp: DWORD; + OffsetModuleName: Word; + Reserved: Word; + end; + {$EXTERNALSYM _IMAGE_BOUND_FORWARDER_REF} + IMAGE_BOUND_FORWARDER_REF = _IMAGE_BOUND_FORWARDER_REF; + {$EXTERNALSYM IMAGE_BOUND_FORWARDER_REF} + TImageBoundForwarderRef = IMAGE_BOUND_FORWARDER_REF; + PImageBoundForwarderRef = PIMAGE_BOUND_FORWARDER_REF; + +// +// Resource Format. +// + +// +// Resource directory consists of two counts, following by a variable length +// array of directory entries. The first count is the number of entries at +// beginning of the array that have actual names associated with each entry. +// The entries are in ascending order, case insensitive strings. The second +// count is the number of entries that immediately follow the named entries. +// This second count identifies the number of entries that have 16-bit integer +// Ids as their name. These entries are also sorted in ascending order. +// +// This structure allows fast lookup by either name or number, but for any +// given resource entry only one form of lookup is supported, not both. +// This is consistant with the syntax of the .RC file and the .RES file. +// + + PIMAGE_RESOURCE_DIRECTORY = ^IMAGE_RESOURCE_DIRECTORY; + {$EXTERNALSYM PIMAGE_RESOURCE_DIRECTORY} + _IMAGE_RESOURCE_DIRECTORY = record + Characteristics: DWORD; + TimeDateStamp: DWORD; + MajorVersion: Word; + MinorVersion: Word; + NumberOfNamedEntries: Word; + NumberOfIdEntries: Word; + // IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; + end; + {$EXTERNALSYM _IMAGE_RESOURCE_DIRECTORY} + IMAGE_RESOURCE_DIRECTORY = _IMAGE_RESOURCE_DIRECTORY; + {$EXTERNALSYM IMAGE_RESOURCE_DIRECTORY} + TImageResourceDirectory = IMAGE_RESOURCE_DIRECTORY; + PImageResourceDirectory = PIMAGE_RESOURCE_DIRECTORY; + +const + IMAGE_RESOURCE_NAME_IS_STRING = DWORD($80000000); + {$EXTERNALSYM IMAGE_RESOURCE_NAME_IS_STRING} + IMAGE_RESOURCE_DATA_IS_DIRECTORY = DWORD($80000000); + {$EXTERNALSYM IMAGE_RESOURCE_DATA_IS_DIRECTORY} + +// +// Each directory contains the 32-bit Name of the entry and an offset, +// relative to the beginning of the resource directory of the data associated +// with this directory entry. If the name of the entry is an actual text +// string instead of an integer Id, then the high order bit of the name field +// is set to one and the low order 31-bits are an offset, relative to the +// beginning of the resource directory of the string, which is of type +// IMAGE_RESOURCE_DIRECTORY_STRING. Otherwise the high bit is clear and the +// low-order 16-bits are the integer Id that identify this resource directory +// entry. If the directory entry is yet another resource directory (i.e. a +// subdirectory), then the high order bit of the offset field will be +// set to indicate this. Otherwise the high bit is clear and the offset +// field points to a resource data entry. +// + +type + PIMAGE_RESOURCE_DIRECTORY_ENTRY = ^IMAGE_RESOURCE_DIRECTORY_ENTRY; + {$EXTERNALSYM PIMAGE_RESOURCE_DIRECTORY_ENTRY} + _IMAGE_RESOURCE_DIRECTORY_ENTRY = record + case Integer of + 0: ( + // DWORD NameOffset:31; + // DWORD NameIsString:1; + NameOffset: DWORD; + OffsetToData: DWORD + ); + 1: ( + Name: DWORD; + // DWORD OffsetToDirectory:31; + // DWORD DataIsDirectory:1; + OffsetToDirectory: DWORD; + ); + 2: ( + Id: WORD; + ); + end; + {$EXTERNALSYM _IMAGE_RESOURCE_DIRECTORY_ENTRY} + IMAGE_RESOURCE_DIRECTORY_ENTRY = _IMAGE_RESOURCE_DIRECTORY_ENTRY; + {$EXTERNALSYM IMAGE_RESOURCE_DIRECTORY_ENTRY} + TImageResourceDirectoryEntry = IMAGE_RESOURCE_DIRECTORY_ENTRY; + PImageResourceDirectoryEntry = PIMAGE_RESOURCE_DIRECTORY_ENTRY; + +// +// For resource directory entries that have actual string names, the Name +// field of the directory entry points to an object of the following type. +// All of these string objects are stored together after the last resource +// directory entry and before the first resource data object. This minimizes +// the impact of these variable length objects on the alignment of the fixed +// size directory entry objects. +// + +type + PIMAGE_RESOURCE_DIRECTORY_STRING = ^IMAGE_RESOURCE_DIRECTORY_STRING; + {$EXTERNALSYM PIMAGE_RESOURCE_DIRECTORY_STRING} + _IMAGE_RESOURCE_DIRECTORY_STRING = record + Length: Word; + NameString: array [0..0] of AnsiCHAR; + end; + {$EXTERNALSYM _IMAGE_RESOURCE_DIRECTORY_STRING} + IMAGE_RESOURCE_DIRECTORY_STRING = _IMAGE_RESOURCE_DIRECTORY_STRING; + {$EXTERNALSYM IMAGE_RESOURCE_DIRECTORY_STRING} + TImageResourceDirectoryString = IMAGE_RESOURCE_DIRECTORY_STRING; + PImageResourceDirectoryString = PIMAGE_RESOURCE_DIRECTORY_STRING; + + PIMAGE_RESOURCE_DIR_STRING_U = ^IMAGE_RESOURCE_DIR_STRING_U; + {$EXTERNALSYM PIMAGE_RESOURCE_DIR_STRING_U} + _IMAGE_RESOURCE_DIR_STRING_U = record + Length: Word; + NameString: array [0..0] of WCHAR; + end; + {$EXTERNALSYM _IMAGE_RESOURCE_DIR_STRING_U} + IMAGE_RESOURCE_DIR_STRING_U = _IMAGE_RESOURCE_DIR_STRING_U; + {$EXTERNALSYM IMAGE_RESOURCE_DIR_STRING_U} + TImageResourceDirStringU = IMAGE_RESOURCE_DIR_STRING_U; + PImageResourceDirStringU = PIMAGE_RESOURCE_DIR_STRING_U; + +// +// Each resource data entry describes a leaf node in the resource directory +// tree. It contains an offset, relative to the beginning of the resource +// directory of the data for the resource, a size field that gives the number +// of bytes of data at that offset, a CodePage that should be used when +// decoding code point values within the resource data. Typically for new +// applications the code page would be the unicode code page. +// + + PIMAGE_RESOURCE_DATA_ENTRY = ^IMAGE_RESOURCE_DATA_ENTRY; + {$EXTERNALSYM PIMAGE_RESOURCE_DATA_ENTRY} + _IMAGE_RESOURCE_DATA_ENTRY = record + OffsetToData: DWORD; + Size: DWORD; + CodePage: DWORD; + Reserved: DWORD; + end; + {$EXTERNALSYM _IMAGE_RESOURCE_DATA_ENTRY} + IMAGE_RESOURCE_DATA_ENTRY = _IMAGE_RESOURCE_DATA_ENTRY; + {$EXTERNALSYM IMAGE_RESOURCE_DATA_ENTRY} + TImageResourceDataEntry = IMAGE_RESOURCE_DATA_ENTRY; + PImageResourceDataEntry = PIMAGE_RESOURCE_DATA_ENTRY; + +// +// Load Configuration Directory Entry +// + +{$IFNDEF FPC} +type + PIMAGE_LOAD_CONFIG_DIRECTORY32 = ^IMAGE_LOAD_CONFIG_DIRECTORY32; + {$EXTERNALSYM PIMAGE_LOAD_CONFIG_DIRECTORY32} + IMAGE_LOAD_CONFIG_DIRECTORY32 = record + Size: DWORD; + TimeDateStamp: DWORD; + MajorVersion: WORD; + MinorVersion: WORD; + GlobalFlagsClear: DWORD; + GlobalFlagsSet: DWORD; + CriticalSectionDefaultTimeout: DWORD; + DeCommitFreeBlockThreshold: DWORD; + DeCommitTotalFreeThreshold: DWORD; + LockPrefixTable: DWORD; // VA + MaximumAllocationSize: DWORD; + VirtualMemoryThreshold: DWORD; + ProcessHeapFlags: DWORD; + ProcessAffinityMask: DWORD; + CSDVersion: WORD; + Reserved1: WORD; + EditList: DWORD; // VA + SecurityCookie: DWORD; // VA + SEHandlerTable: DWORD; // VA + SEHandlerCount: DWORD; + end; + {$EXTERNALSYM IMAGE_LOAD_CONFIG_DIRECTORY32} + TImageLoadConfigDirectory32 = IMAGE_LOAD_CONFIG_DIRECTORY32; + PImageLoadConfigDirectory32 = PIMAGE_LOAD_CONFIG_DIRECTORY32; + + PIMAGE_LOAD_CONFIG_DIRECTORY64 = ^IMAGE_LOAD_CONFIG_DIRECTORY64; + {$EXTERNALSYM PIMAGE_LOAD_CONFIG_DIRECTORY64} + IMAGE_LOAD_CONFIG_DIRECTORY64 = record + Size: DWORD; + TimeDateStamp: DWORD; + MajorVersion: WORD; + MinorVersion: WORD; + GlobalFlagsClear: DWORD; + GlobalFlagsSet: DWORD; + CriticalSectionDefaultTimeout: DWORD; + DeCommitFreeBlockThreshold: ULONGLONG; + DeCommitTotalFreeThreshold: ULONGLONG; + LockPrefixTable: ULONGLONG; // VA + MaximumAllocationSize: ULONGLONG; + VirtualMemoryThreshold: ULONGLONG; + ProcessAffinityMask: ULONGLONG; + ProcessHeapFlags: DWORD; + CSDVersion: WORD; + Reserved1: WORD; + EditList: ULONGLONG; // VA + SecurityCookie: ULONGLONG; // VA + SEHandlerTable: ULONGLONG; // VA + SEHandlerCount: ULONGLONG; + end; + {$EXTERNALSYM IMAGE_LOAD_CONFIG_DIRECTORY64} + TImageLoadConfigDirectory64 = IMAGE_LOAD_CONFIG_DIRECTORY64; + PImageLoadConfigDirectory64 = PIMAGE_LOAD_CONFIG_DIRECTORY64; + + IMAGE_LOAD_CONFIG_DIRECTORY = IMAGE_LOAD_CONFIG_DIRECTORY32; + {$EXTERNALSYM IMAGE_LOAD_CONFIG_DIRECTORY} + PIMAGE_LOAD_CONFIG_DIRECTORY = PIMAGE_LOAD_CONFIG_DIRECTORY32; + {$EXTERNALSYM PIMAGE_LOAD_CONFIG_DIRECTORY} + TImageLoadConfigDirectory = TImageLoadConfigDirectory32; + PImageLoadConfigDirectory = PImageLoadConfigDirectory32; +{$ENDIF ~FPC} + +// line 6802 + +// +// Debug Format +// +(* +type + PIMAGE_DEBUG_DIRECTORY = ^IMAGE_DEBUG_DIRECTORY; + {$EXTERNALSYM PIMAGE_DEBUG_DIRECTORY} + _IMAGE_DEBUG_DIRECTORY = record + Characteristics: DWORD; + TimeDateStamp: DWORD; + MajorVersion: Word; + MinorVersion: Word; + Type_: DWORD; + SizeOfData: DWORD; + AddressOfRawData: DWORD; + PointerToRawData: DWORD; + end; + {$EXTERNALSYM _IMAGE_DEBUG_DIRECTORY} + IMAGE_DEBUG_DIRECTORY = _IMAGE_DEBUG_DIRECTORY; + {$EXTERNALSYM IMAGE_DEBUG_DIRECTORY} + TImageDebugDirectory = IMAGE_DEBUG_DIRECTORY; + PImageDebugDirectory = PIMAGE_DEBUG_DIRECTORY; + +const + IMAGE_DEBUG_TYPE_UNKNOWN = 0; + {$EXTERNALSYM IMAGE_DEBUG_TYPE_UNKNOWN} + IMAGE_DEBUG_TYPE_COFF = 1; + {$EXTERNALSYM IMAGE_DEBUG_TYPE_COFF} + IMAGE_DEBUG_TYPE_CODEVIEW = 2; + {$EXTERNALSYM IMAGE_DEBUG_TYPE_CODEVIEW} + IMAGE_DEBUG_TYPE_FPO = 3; + {$EXTERNALSYM IMAGE_DEBUG_TYPE_FPO} + IMAGE_DEBUG_TYPE_MISC = 4; + {$EXTERNALSYM IMAGE_DEBUG_TYPE_MISC} + IMAGE_DEBUG_TYPE_EXCEPTION = 5; + {$EXTERNALSYM IMAGE_DEBUG_TYPE_EXCEPTION} + IMAGE_DEBUG_TYPE_FIXUP = 6; + {$EXTERNALSYM IMAGE_DEBUG_TYPE_FIXUP} + IMAGE_DEBUG_TYPE_OMAP_TO_SRC = 7; + {$EXTERNALSYM IMAGE_DEBUG_TYPE_OMAP_TO_SRC} + IMAGE_DEBUG_TYPE_OMAP_FROM_SRC = 8; + {$EXTERNALSYM IMAGE_DEBUG_TYPE_OMAP_FROM_SRC} + IMAGE_DEBUG_TYPE_BORLAND = 9; + {$EXTERNALSYM IMAGE_DEBUG_TYPE_BORLAND} + IMAGE_DEBUG_TYPE_RESERVED10 = 10; + {$EXTERNALSYM IMAGE_DEBUG_TYPE_RESERVED10} + IMAGE_DEBUG_TYPE_CLSID = 11; + {$EXTERNALSYM IMAGE_DEBUG_TYPE_CLSID} +*) + +{$IFNDEF FPC} +type + PIMAGE_COFF_SYMBOLS_HEADER = ^IMAGE_COFF_SYMBOLS_HEADER; + {$EXTERNALSYM PIMAGE_COFF_SYMBOLS_HEADER} + _IMAGE_COFF_SYMBOLS_HEADER = record + NumberOfSymbols: DWORD; + LvaToFirstSymbol: DWORD; + NumberOfLinenumbers: DWORD; + LvaToFirstLinenumber: DWORD; + RvaToFirstByteOfCode: DWORD; + RvaToLastByteOfCode: DWORD; + RvaToFirstByteOfData: DWORD; + RvaToLastByteOfData: DWORD; + end; + {$EXTERNALSYM _IMAGE_COFF_SYMBOLS_HEADER} + IMAGE_COFF_SYMBOLS_HEADER = _IMAGE_COFF_SYMBOLS_HEADER; + {$EXTERNALSYM IMAGE_COFF_SYMBOLS_HEADER} + TImageCoffSymbolsHeader = IMAGE_COFF_SYMBOLS_HEADER; + PImageCoffSymbolsHeader = PIMAGE_COFF_SYMBOLS_HEADER; +{$ENDIF ~FPC} + +const + FRAME_FPO = 0; + {$EXTERNALSYM FRAME_FPO} + FRAME_TRAP = 1; + {$EXTERNALSYM FRAME_TRAP} + FRAME_TSS = 2; + {$EXTERNALSYM FRAME_TSS} + FRAME_NONFPO = 3; + {$EXTERNALSYM FRAME_NONFPO} + + FPOFLAGS_PROLOG = $00FF; // # bytes in prolog + FPOFLAGS_REGS = $0700; // # regs saved + FPOFLAGS_HAS_SEH = $0800; // TRUE if SEH in func + FPOFLAGS_USE_BP = $1000; // TRUE if EBP has been allocated + FPOFLAGS_RESERVED = $2000; // reserved for future use + FPOFLAGS_FRAME = $C000; // frame type + +{$IFNDEF FPC} +type + PFPO_DATA = ^FPO_DATA; + {$EXTERNALSYM PFPO_DATA} + _FPO_DATA = record + ulOffStart: DWORD; // offset 1st byte of function code + cbProcSize: DWORD; // # bytes in function + cdwLocals: DWORD; // # bytes in locals/4 + cdwParams: WORD; // # bytes in params/4 + Flags: WORD; + end; + {$EXTERNALSYM _FPO_DATA} + FPO_DATA = _FPO_DATA; + {$EXTERNALSYM FPO_DATA} + TFpoData = FPO_DATA; + PFpoData = PFPO_DATA; +{$ENDIF ~FPC} + +const + SIZEOF_RFPO_DATA = 16; + {$EXTERNALSYM SIZEOF_RFPO_DATA} + + IMAGE_DEBUG_MISC_EXENAME = 1; + {$EXTERNALSYM IMAGE_DEBUG_MISC_EXENAME} + +type + PIMAGE_DEBUG_MISC = ^IMAGE_DEBUG_MISC; + {$EXTERNALSYM PIMAGE_DEBUG_MISC} + _IMAGE_DEBUG_MISC = record + DataType: DWORD; // type of misc data, see defines + Length: DWORD; // total length of record, rounded to four byte multiple. + Unicode: ByteBool; // TRUE if data is unicode string + Reserved: array [0..2] of Byte; + Data: array [0..0] of Byte; // Actual data + end; + {$EXTERNALSYM _IMAGE_DEBUG_MISC} + IMAGE_DEBUG_MISC = _IMAGE_DEBUG_MISC; + {$EXTERNALSYM IMAGE_DEBUG_MISC} + TImageDebugMisc = IMAGE_DEBUG_MISC; + PImageDebugMisc = PIMAGE_DEBUG_MISC; + +// +// Function table extracted from MIPS/ALPHA/IA64 images. Does not contain +// information needed only for runtime support. Just those fields for +// each entry needed by a debugger. +// + +{$IFNDEF FPC} + PIMAGE_FUNCTION_ENTRY = ^IMAGE_FUNCTION_ENTRY; + {$EXTERNALSYM PIMAGE_FUNCTION_ENTRY} + _IMAGE_FUNCTION_ENTRY = record + StartingAddress: DWORD; + EndingAddress: DWORD; + EndOfPrologue: DWORD; + end; + {$EXTERNALSYM _IMAGE_FUNCTION_ENTRY} + IMAGE_FUNCTION_ENTRY = _IMAGE_FUNCTION_ENTRY; + {$EXTERNALSYM IMAGE_FUNCTION_ENTRY} + TImageFunctionEntry = IMAGE_FUNCTION_ENTRY; + PImageFunctionEntry = PIMAGE_FUNCTION_ENTRY; + + PIMAGE_FUNCTION_ENTRY64 = ^IMAGE_FUNCTION_ENTRY64; + {$EXTERNALSYM PIMAGE_FUNCTION_ENTRY64} + _IMAGE_FUNCTION_ENTRY64 = record + StartingAddress: ULONGLONG; + EndingAddress: ULONGLONG; + case Integer of + 0: (EndOfPrologue: ULONGLONG); + 1: (UnwindInfoAddress: ULONGLONG); + end; + {$EXTERNALSYM _IMAGE_FUNCTION_ENTRY64} + IMAGE_FUNCTION_ENTRY64 = _IMAGE_FUNCTION_ENTRY64; + {$EXTERNALSYM IMAGE_FUNCTION_ENTRY64} + TImageFunctionEntry64 = IMAGE_FUNCTION_ENTRY64; + PImageFunctionEntry64 = PIMAGE_FUNCTION_ENTRY64; + +{$ENDIF ~FPC} + +// +// Debugging information can be stripped from an image file and placed +// in a separate .DBG file, whose file name part is the same as the +// image file name part (e.g. symbols for CMD.EXE could be stripped +// and placed in CMD.DBG). This is indicated by the IMAGE_FILE_DEBUG_STRIPPED +// flag in the Characteristics field of the file header. The beginning of +// the .DBG file contains the following structure which captures certain +// information from the image file. This allows a debug to proceed even if +// the original image file is not accessable. This header is followed by +// zero of more IMAGE_SECTION_HEADER structures, followed by zero or more +// IMAGE_DEBUG_DIRECTORY structures. The latter structures and those in +// the image file contain file offsets relative to the beginning of the +// .DBG file. +// +// If symbols have been stripped from an image, the IMAGE_DEBUG_MISC structure +// is left in the image file, but not mapped. This allows a debugger to +// compute the name of the .DBG file, from the name of the image in the +// IMAGE_DEBUG_MISC structure. +// + + PIMAGE_SEPARATE_DEBUG_HEADER = ^IMAGE_SEPARATE_DEBUG_HEADER; + {$EXTERNALSYM PIMAGE_SEPARATE_DEBUG_HEADER} + _IMAGE_SEPARATE_DEBUG_HEADER = record + Signature: Word; + Flags: Word; + Machine: Word; + Characteristics: Word; + TimeDateStamp: DWORD; + CheckSum: DWORD; + ImageBase: DWORD; + SizeOfImage: DWORD; + NumberOfSections: DWORD; + ExportedNamesSize: DWORD; + DebugDirectorySize: DWORD; + SectionAlignment: DWORD; + Reserved: array [0..1] of DWORD; + end; + {$EXTERNALSYM _IMAGE_SEPARATE_DEBUG_HEADER} + IMAGE_SEPARATE_DEBUG_HEADER = _IMAGE_SEPARATE_DEBUG_HEADER; + {$EXTERNALSYM IMAGE_SEPARATE_DEBUG_HEADER} + TImageSeparateDebugHeader = IMAGE_SEPARATE_DEBUG_HEADER; + PImageSeparateDebugHeader = PIMAGE_SEPARATE_DEBUG_HEADER; + + _NON_PAGED_DEBUG_INFO = record + Signature: WORD; + Flags: WORD; + Size: DWORD; + Machine: WORD; + Characteristics: WORD; + TimeDateStamp: DWORD; + CheckSum: DWORD; + SizeOfImage: DWORD; + ImageBase: ULONGLONG; + //DebugDirectorySize + //IMAGE_DEBUG_DIRECTORY + end; + {$EXTERNALSYM _NON_PAGED_DEBUG_INFO} + NON_PAGED_DEBUG_INFO = _NON_PAGED_DEBUG_INFO; + {$EXTERNALSYM NON_PAGED_DEBUG_INFO} + PNON_PAGED_DEBUG_INFO = ^NON_PAGED_DEBUG_INFO; + {$EXTERNALSYM PNON_PAGED_DEBUG_INFO} + +const + IMAGE_SEPARATE_DEBUG_SIGNATURE = $4944; + {$EXTERNALSYM IMAGE_SEPARATE_DEBUG_SIGNATURE} + NON_PAGED_DEBUG_SIGNATURE = $494E; + {$EXTERNALSYM NON_PAGED_DEBUG_SIGNATURE} + + IMAGE_SEPARATE_DEBUG_FLAGS_MASK = $8000; + {$EXTERNALSYM IMAGE_SEPARATE_DEBUG_FLAGS_MASK} + IMAGE_SEPARATE_DEBUG_MISMATCH = $8000; // when DBG was updated, the old checksum didn't match. + {$EXTERNALSYM IMAGE_SEPARATE_DEBUG_MISMATCH} + +// +// The .arch section is made up of headers, each describing an amask position/value +// pointing to an array of IMAGE_ARCHITECTURE_ENTRY's. Each "array" (both the header +// and entry arrays) are terminiated by a quadword of 0xffffffffL. +// +// NOTE: There may be quadwords of 0 sprinkled around and must be skipped. +// + +const + IAHMASK_VALUE = $00000001; // 1 -> code section depends on mask bit + // 0 -> new instruction depends on mask bit + IAHMASK_MBZ7 = $000000FE; // MBZ + IAHMASK_SHIFT = $0000FF00; // Amask bit in question for this fixup + IAHMASK_MBZ16 = DWORD($FFFF0000); // MBZ + +type + PIMAGE_ARCHITECTURE_HEADER = ^IMAGE_ARCHITECTURE_HEADER; + {$EXTERNALSYM PIMAGE_ARCHITECTURE_HEADER} + _ImageArchitectureHeader = record + Mask: DWORD; + FirstEntryRVA: DWORD; // RVA into .arch section to array of ARCHITECTURE_ENTRY's + end; + {$EXTERNALSYM _ImageArchitectureHeader} + IMAGE_ARCHITECTURE_HEADER = _ImageArchitectureHeader; + {$EXTERNALSYM IMAGE_ARCHITECTURE_HEADER} + TImageArchitectureHeader = IMAGE_ARCHITECTURE_HEADER; + PImageArchitectureHeader = PIMAGE_ARCHITECTURE_HEADER; + + PIMAGE_ARCHITECTURE_ENTRY = ^IMAGE_ARCHITECTURE_ENTRY; + {$EXTERNALSYM PIMAGE_ARCHITECTURE_ENTRY} + _ImageArchitectureEntry = record + FixupInstRVA: DWORD; // RVA of instruction to fixup + NewInst: DWORD; // fixup instruction (see alphaops.h) + end; + {$EXTERNALSYM _ImageArchitectureEntry} + IMAGE_ARCHITECTURE_ENTRY = _ImageArchitectureEntry; + {$EXTERNALSYM IMAGE_ARCHITECTURE_ENTRY} + TImageArchitectureEntry = IMAGE_ARCHITECTURE_ENTRY; + PImageArchitectureEntry = PIMAGE_ARCHITECTURE_ENTRY; + +// #include "poppack.h" // Back to the initial value + +// The following structure defines the new import object. Note the values of the first two fields, +// which must be set as stated in order to differentiate old and new import members. +// Following this structure, the linker emits two null-terminated strings used to recreate the +// import at the time of use. The first string is the import's name, the second is the dll's name. + +const + IMPORT_OBJECT_HDR_SIG2 = $ffff; + {$EXTERNALSYM IMPORT_OBJECT_HDR_SIG2} + +const + IOHFLAGS_TYPE = $0003; // IMPORT_TYPE + IAHFLAGS_NAMETYPE = $001C; // IMPORT_NAME_TYPE + IAHFLAGS_RESERVED = $FFE0; // Reserved. Must be zero. + +type + PImportObjectHeader = ^IMPORT_OBJECT_HEADER; + IMPORT_OBJECT_HEADER = record + Sig1: WORD; // Must be IMAGE_FILE_MACHINE_UNKNOWN + Sig2: WORD; // Must be IMPORT_OBJECT_HDR_SIG2. + Version: WORD; + Machine: WORD; + TimeDateStamp: DWORD; // Time/date stamp + SizeOfData: DWORD; // particularly useful for incremental links + OrdinalOrHint: record + case Integer of + 0: (Ordinal: WORD); // if grf & IMPORT_OBJECT_ORDINAL + 1: (Flags: DWORD); + end; + Flags: WORD; + //WORD Type : 2; // IMPORT_TYPE + //WORD NameType : 3; // IMPORT_NAME_TYPE + //WORD Reserved : 11; // Reserved. Must be zero. + end; + {$EXTERNALSYM IMPORT_OBJECT_HEADER} + TImportObjectHeader = IMPORT_OBJECT_HEADER; + + IMPORT_OBJECT_TYPE = (IMPORT_OBJECT_CODE, IMPORT_OBJECT_DATA, IMPORT_OBJECT_CONST); + {$EXTERNALSYM IMPORT_OBJECT_TYPE} + TImportObjectType = IMPORT_OBJECT_TYPE; + + IMPORT_OBJECT_NAME_TYPE = ( + IMPORT_OBJECT_ORDINAL, // Import by ordinal + IMPORT_OBJECT_NAME, // Import name == public symbol name. + IMPORT_OBJECT_NAME_NO_PREFIX, // Import name == public symbol name skipping leading ?, @, or optionally _. + IMPORT_OBJECT_NAME_UNDECORATE); // Import name == public symbol name skipping leading ?, @, or optionally _ + // and truncating at first @ + {$EXTERNALSYM IMPORT_OBJECT_NAME_TYPE} + TImportObjectNameType = IMPORT_OBJECT_NAME_TYPE; + + ReplacesCorHdrNumericDefines = DWORD; + {$EXTERNALSYM ReplacesCorHdrNumericDefines} + +const + +// COM+ Header entry point flags. + + COMIMAGE_FLAGS_ILONLY = $00000001; + {$EXTERNALSYM COMIMAGE_FLAGS_ILONLY} + COMIMAGE_FLAGS_32BITREQUIRED = $00000002; + {$EXTERNALSYM COMIMAGE_FLAGS_32BITREQUIRED} + COMIMAGE_FLAGS_IL_LIBRARY = $00000004; + {$EXTERNALSYM COMIMAGE_FLAGS_IL_LIBRARY} + COMIMAGE_FLAGS_STRONGNAMESIGNED = $00000008; + {$EXTERNALSYM COMIMAGE_FLAGS_STRONGNAMESIGNED} + COMIMAGE_FLAGS_TRACKDEBUGDATA = $00010000; + {$EXTERNALSYM COMIMAGE_FLAGS_TRACKDEBUGDATA} + +// Version flags for image. + + COR_VERSION_MAJOR_V2 = 2; + {$EXTERNALSYM COR_VERSION_MAJOR_V2} + COR_VERSION_MAJOR = COR_VERSION_MAJOR_V2; + {$EXTERNALSYM COR_VERSION_MAJOR} + COR_VERSION_MINOR = 0; + {$EXTERNALSYM COR_VERSION_MINOR} + COR_DELETED_NAME_LENGTH = 8; + {$EXTERNALSYM COR_DELETED_NAME_LENGTH} + COR_VTABLEGAP_NAME_LENGTH = 8; + {$EXTERNALSYM COR_VTABLEGAP_NAME_LENGTH} + +// Maximum size of a NativeType descriptor. + + NATIVE_TYPE_MAX_CB = 1; + {$EXTERNALSYM NATIVE_TYPE_MAX_CB} + COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE= $FF; + {$EXTERNALSYM COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE} + +// #defines for the MIH FLAGS + + IMAGE_COR_MIH_METHODRVA = $01; + {$EXTERNALSYM IMAGE_COR_MIH_METHODRVA} + IMAGE_COR_MIH_EHRVA = $02; + {$EXTERNALSYM IMAGE_COR_MIH_EHRVA} + IMAGE_COR_MIH_BASICBLOCK = $08; + {$EXTERNALSYM IMAGE_COR_MIH_BASICBLOCK} + +// V-table constants + + COR_VTABLE_32BIT = $01; // V-table slots are 32-bits in size. + {$EXTERNALSYM COR_VTABLE_32BIT} + COR_VTABLE_64BIT = $02; // V-table slots are 64-bits in size. + {$EXTERNALSYM COR_VTABLE_64BIT} + COR_VTABLE_FROM_UNMANAGED = $04; // If set, transition from unmanaged. + {$EXTERNALSYM COR_VTABLE_FROM_UNMANAGED} + COR_VTABLE_CALL_MOST_DERIVED = $10; // Call most derived method described by + {$EXTERNALSYM COR_VTABLE_CALL_MOST_DERIVED} + +// EATJ constants + + IMAGE_COR_EATJ_THUNK_SIZE = 32; // Size of a jump thunk reserved range. + {$EXTERNALSYM IMAGE_COR_EATJ_THUNK_SIZE} + +// Max name lengths +// Change to unlimited name lengths. + + MAX_CLASS_NAME = 1024; + {$EXTERNALSYM MAX_CLASS_NAME} + MAX_PACKAGE_NAME = 1024; + {$EXTERNALSYM MAX_PACKAGE_NAME} + +// COM+ 2.0 header structure. + +type + IMAGE_COR20_HEADER = record + + // Header versioning + + cb: DWORD; + MajorRuntimeVersion: WORD; + MinorRuntimeVersion: WORD; + + // Symbol table and startup information + + MetaData: IMAGE_DATA_DIRECTORY; + Flags: DWORD; + EntryPointToken: DWORD; + + // Binding information + + Resources: IMAGE_DATA_DIRECTORY; + StrongNameSignature: IMAGE_DATA_DIRECTORY; + + // Regular fixup and binding information + + CodeManagerTable: IMAGE_DATA_DIRECTORY; + VTableFixups: IMAGE_DATA_DIRECTORY; + ExportAddressTableJumps: IMAGE_DATA_DIRECTORY; + + // Precompiled image info (internal use only - set to zero) + + ManagedNativeHeader: IMAGE_DATA_DIRECTORY; + end; + PIMAGE_COR20_HEADER = ^IMAGE_COR20_HEADER; + TImageCor20Header = IMAGE_COR20_HEADER; + PImageCor20Header = PIMAGE_COR20_HEADER; + +// line 7351 + +const + COMPRESSION_FORMAT_NONE = ($0000); + {$EXTERNALSYM COMPRESSION_FORMAT_NONE} + COMPRESSION_FORMAT_DEFAULT = ($0001); + {$EXTERNALSYM COMPRESSION_FORMAT_DEFAULT} + COMPRESSION_FORMAT_LZNT1 = ($0002); + {$EXTERNALSYM COMPRESSION_FORMAT_LZNT1} + COMPRESSION_ENGINE_STANDARD = ($0000); + {$EXTERNALSYM COMPRESSION_ENGINE_STANDARD} + COMPRESSION_ENGINE_MAXIMUM = ($0100); + {$EXTERNALSYM COMPRESSION_ENGINE_MAXIMUM} + COMPRESSION_ENGINE_HIBER = ($0200); + {$EXTERNALSYM COMPRESSION_ENGINE_HIBER} + +// line 7462 + +type + POSVERSIONINFOEXA = ^OSVERSIONINFOEXA; + {$EXTERNALSYM POSVERSIONINFOEXA} + _OSVERSIONINFOEXA = record + dwOSVersionInfoSize: DWORD; + dwMajorVersion: DWORD; + dwMinorVersion: DWORD; + dwBuildNumber: DWORD; + dwPlatformId: DWORD; + szCSDVersion: array [0..127] of ANSICHAR; // Maintenance string for PSS usage + wServicePackMajor: WORD; + wServicePackMinor: WORD; + wSuiteMask: WORD; + wProductType: BYTE; + wReserved: BYTE; + end; + {$EXTERNALSYM _OSVERSIONINFOEXA} + OSVERSIONINFOEXA = _OSVERSIONINFOEXA; + {$EXTERNALSYM OSVERSIONINFOEXA} + LPOSVERSIONINFOEXA = ^OSVERSIONINFOEXA; + {$EXTERNALSYM LPOSVERSIONINFOEXA} + TOSVersionInfoExA = _OSVERSIONINFOEXA; + + POSVERSIONINFOEXW = ^OSVERSIONINFOEXW; + {$EXTERNALSYM POSVERSIONINFOEXW} + _OSVERSIONINFOEXW = record + dwOSVersionInfoSize: DWORD; + dwMajorVersion: DWORD; + dwMinorVersion: DWORD; + dwBuildNumber: DWORD; + dwPlatformId: DWORD; + szCSDVersion: array [0..127] of WCHAR; // Maintenance string for PSS usage + wServicePackMajor: WORD; + wServicePackMinor: WORD; + wSuiteMask: WORD; + wProductType: BYTE; + wReserved: BYTE; + end; + {$EXTERNALSYM _OSVERSIONINFOEXW} + OSVERSIONINFOEXW = _OSVERSIONINFOEXW; + {$EXTERNALSYM OSVERSIONINFOEXW} + LPOSVERSIONINFOEXW = ^OSVERSIONINFOEXW; + {$EXTERNALSYM LPOSVERSIONINFOEXW} + RTL_OSVERSIONINFOEXW = _OSVERSIONINFOEXW; + {$EXTERNALSYM RTL_OSVERSIONINFOEXW} + PRTL_OSVERSIONINFOEXW = ^RTL_OSVERSIONINFOEXW; + {$EXTERNALSYM PRTL_OSVERSIONINFOEXW} + TOSVersionInfoExW = _OSVERSIONINFOEXW; + +{$IFDEF SUPPORTS_UNICODE} + + OSVERSIONINFOEX = OSVERSIONINFOEXW; + {$EXTERNALSYM OSVERSIONINFOEX} + POSVERSIONINFOEX = POSVERSIONINFOEXW; + {$EXTERNALSYM POSVERSIONINFOEX} + LPOSVERSIONINFOEX = LPOSVERSIONINFOEXW; + {$EXTERNALSYM LPOSVERSIONINFOEX} + TOSVersionInfoEx = TOSVersionInfoExW; + +{$ELSE ~SUPPORTS_UNICODE} + + OSVERSIONINFOEX = OSVERSIONINFOEXA; + {$EXTERNALSYM OSVERSIONINFOEX} + POSVERSIONINFOEX = POSVERSIONINFOEXA; + {$EXTERNALSYM POSVERSIONINFOEX} + LPOSVERSIONINFOEX = LPOSVERSIONINFOEXA; + {$EXTERNALSYM LPOSVERSIONINFOEX} + TOSVersionInfoEx = TOSVersionInfoExA; + +{$ENDIF ~SUPPORTS_UNICODE} + +// +// RtlVerifyVersionInfo() conditions +// + +const + VER_EQUAL = 1; + {$EXTERNALSYM VER_EQUAL} + VER_GREATER = 2; + {$EXTERNALSYM VER_GREATER} + VER_GREATER_EQUAL = 3; + {$EXTERNALSYM VER_GREATER_EQUAL} + VER_LESS = 4; + {$EXTERNALSYM VER_LESS} + VER_LESS_EQUAL = 5; + {$EXTERNALSYM VER_LESS_EQUAL} + VER_AND = 6; + {$EXTERNALSYM VER_AND} + VER_OR = 7; + {$EXTERNALSYM VER_OR} + + VER_CONDITION_MASK = 7; + {$EXTERNALSYM VER_CONDITION_MASK} + VER_NUM_BITS_PER_CONDITION_MASK = 3; + {$EXTERNALSYM VER_NUM_BITS_PER_CONDITION_MASK} + +// +// RtlVerifyVersionInfo() type mask bits +// + + VER_MINORVERSION = $0000001; + {$EXTERNALSYM VER_MINORVERSION} + VER_MAJORVERSION = $0000002; + {$EXTERNALSYM VER_MAJORVERSION} + VER_BUILDNUMBER = $0000004; + {$EXTERNALSYM VER_BUILDNUMBER} + VER_PLATFORMID = $0000008; + {$EXTERNALSYM VER_PLATFORMID} + VER_SERVICEPACKMINOR = $0000010; + {$EXTERNALSYM VER_SERVICEPACKMINOR} + VER_SERVICEPACKMAJOR = $0000020; + {$EXTERNALSYM VER_SERVICEPACKMAJOR} + VER_SUITENAME = $0000040; + {$EXTERNALSYM VER_SUITENAME} + VER_PRODUCT_TYPE = $0000080; + {$EXTERNALSYM VER_PRODUCT_TYPE} + +// +// RtlVerifyVersionInfo() os product type values +// + + VER_NT_WORKSTATION = $0000001; + {$EXTERNALSYM VER_NT_WORKSTATION} + VER_NT_DOMAIN_CONTROLLER = $0000002; + {$EXTERNALSYM VER_NT_DOMAIN_CONTROLLER} + VER_NT_SERVER = $0000003; + {$EXTERNALSYM VER_NT_SERVER} + +// +// dwPlatformId defines: +// + + VER_PLATFORM_WIN32s = 0; + {$EXTERNALSYM VER_PLATFORM_WIN32s} + VER_PLATFORM_WIN32_WINDOWS = 1; + {$EXTERNALSYM VER_PLATFORM_WIN32_WINDOWS} + VER_PLATFORM_WIN32_NT = 2; + {$EXTERNALSYM VER_PLATFORM_WIN32_NT} + +const +// +// +// Predefined Value Types. +// + + REG_NONE = ( 0 ); // No value type + {$EXTERNALSYM REG_NONE} + REG_SZ = ( 1 ); // Unicode nul terminated string + {$EXTERNALSYM REG_SZ} + REG_EXPAND_SZ = ( 2 ); // Unicode nul terminated string + {$EXTERNALSYM REG_EXPAND_SZ} + // (with environment variable references) + REG_BINARY = ( 3 ); // Free form binary + {$EXTERNALSYM REG_BINARY} + REG_DWORD = ( 4 ); // 32-bit number + {$EXTERNALSYM REG_DWORD} + REG_DWORD_LITTLE_ENDIAN = ( 4 ); // 32-bit number (same as REG_DWORD) + {$EXTERNALSYM REG_DWORD_LITTLE_ENDIAN} + REG_DWORD_BIG_ENDIAN = ( 5 ); // 32-bit number + {$EXTERNALSYM REG_DWORD_BIG_ENDIAN} + REG_LINK = ( 6 ); // Symbolic Link (unicode) + {$EXTERNALSYM REG_LINK} + REG_MULTI_SZ = ( 7 ); // Multiple Unicode strings + {$EXTERNALSYM REG_MULTI_SZ} + REG_RESOURCE_LIST = ( 8 ); // Resource list in the resource map + {$EXTERNALSYM REG_RESOURCE_LIST} + REG_FULL_RESOURCE_DESCRIPTOR = ( 9 ); // Resource list in the hardware description + {$EXTERNALSYM REG_FULL_RESOURCE_DESCRIPTOR} + REG_RESOURCE_REQUIREMENTS_LIST = ( 10 ); + {$EXTERNALSYM REG_RESOURCE_REQUIREMENTS_LIST} + REG_QWORD = ( 11 ); // 64-bit number + {$EXTERNALSYM REG_QWORD} + REG_QWORD_LITTLE_ENDIAN = ( 11 ); // 64-bit number (same as REG_QWORD) + {$EXTERNALSYM REG_QWORD_LITTLE_ENDIAN} + + // Windows 7 debugging types + +type + _CONTEXT_CHUNK = packed record + Offset: Integer; + Length: DWORD; + end; + {$EXTERNALSYM _CONTEXT_CHUNK} + CONTEXT_CHUNK = _CONTEXT_CHUNK; + {$EXTERNALSYM CONTEXT_CHUNK} + PCONTEXT_CHUNK = ^_CONTEXT_CHUNK; + {$EXTERNALSYM PCONTEXT_CHUNK} + +type + _CONTEXT_EX = packed record + // + // The total length of the structure starting from the chunk with + // the smallest offset. N.B. that the offset may be negative. + // + All: CONTEXT_CHUNK; + + // + // Wrapper for the traditional CONTEXT structure. N.B. the size of + // the chunk may be less than sizeof(CONTEXT) is some cases (when + // CONTEXT_EXTENDED_REGISTERS is not set on x86 for instance). + // + + Legacy: CONTEXT_CHUNK; + + // + // CONTEXT_XSTATE: Extended processor state chunk. The state is + // stored in the same format XSAVE operation strores it with + // exception of the first 512 bytes, i.e. staring from + // XSAVE_AREA_HEADER. The lower two bits corresponding FP and + // SSE state must be zero. + // + + XState: CONTEXT_CHUNK; + end; + {$EXTERNALSYM _CONTEXT_EX} + CONTEXT_EX = _CONTEXT_EX; + {$EXTERNALSYM CONTEXT_EX} + PCONTEXT_EX = ^_CONTEXT_EX; + {$EXTERNALSYM PCONTEXT_EX} + +// +// Known extended CPU state feature IDs +// + +const + XSTATE_LEGACY_FLOATING_POINT = 0; + {$EXTERNALSYM XSTATE_LEGACY_FLOATING_POINT} + XSTATE_LEGACY_SSE = 1; + {$EXTERNALSYM XSTATE_LEGACY_SSE} + XSTATE_GSSE = 2; + {$EXTERNALSYM XSTATE_GSSE} + + XSTATE_MASK_LEGACY_FLOATING_POINT = Int64(1) shl XSTATE_LEGACY_FLOATING_POINT; + {$EXTERNALSYM XSTATE_MASK_LEGACY_FLOATING_POINT} + XSTATE_MASK_LEGACY_SSE = Int64(1) shl XSTATE_LEGACY_SSE; + {$EXTERNALSYM XSTATE_MASK_LEGACY_SSE} + XSTATE_MASK_LEGACY = XSTATE_MASK_LEGACY_FLOATING_POINT or XSTATE_MASK_LEGACY_SSE; + {$EXTERNALSYM XSTATE_MASK_LEGACY} + XSTATE_MASK_GSSE = Int64(1) shl XSTATE_GSSE; + {$EXTERNALSYM XSTATE_MASK_GSSE} + + MAXIMUM_XSTATE_FEATURES = 64; + {$EXTERNALSYM MAXIMUM_XSTATE_FEATURES} + +// +// The following flags control the contents of the CONTEXT structure. +// +const + CONTEXT_i386 = $00010000; // this assumes that i386 and + {$EXTERNALSYM CONTEXT_i386} + CONTEXT_i486 = $00010000; // i486 have identical context records + {$EXTERNALSYM CONTEXT_i486} + + CONTEXT_CONTROL = CONTEXT_i386 or $00000001; // SS:SP, CS:IP, FLAGS, BP + {$EXTERNALSYM CONTEXT_CONTROL} + CONTEXT_INTEGER = CONTEXT_i386 or $00000002; // AX, BX, CX, DX, SI, DI + {$EXTERNALSYM CONTEXT_INTEGER} + CONTEXT_SEGMENTS = CONTEXT_i386 or $00000004; // DS, ES, FS, GS + {$EXTERNALSYM CONTEXT_SEGMENTS} + CONTEXT_FLOATING_POINT = CONTEXT_i386 or $00000008; // 387 state + {$EXTERNALSYM CONTEXT_FLOATING_POINT} + CONTEXT_DEBUG_REGISTERS = CONTEXT_i386 or $00000010; // DB 0-3,6,7 + {$EXTERNALSYM CONTEXT_DEBUG_REGISTERS} + CONTEXT_EXTENDED_REGISTERS = CONTEXT_i386 or $00000020; // cpu specific extensions + {$EXTERNALSYM CONTEXT_EXTENDED_REGISTERS} + + CONTEXT_FULL = CONTEXT_CONTROL or CONTEXT_INTEGER or CONTEXT_SEGMENTS; + {$EXTERNALSYM CONTEXT_FULL} + + CONTEXT_ALL = CONTEXT_CONTROL or CONTEXT_INTEGER or CONTEXT_SEGMENTS or CONTEXT_FLOATING_POINT or + CONTEXT_DEBUG_REGISTERS or CONTEXT_EXTENDED_REGISTERS; + {$EXTERNALSYM CONTEXT_ALL} + + CONTEXT_XSTATE = CONTEXT_i386 or $00000040; + {$EXTERNALSYM CONTEXT_XSTATE} + +// line 160 + +// +// File creation flags must start at the high end since they +// are combined with the attributes +// + +const + FILE_FLAG_WRITE_THROUGH = DWORD($80000000); + {$EXTERNALSYM FILE_FLAG_WRITE_THROUGH} + FILE_FLAG_OVERLAPPED = $40000000; + {$EXTERNALSYM FILE_FLAG_OVERLAPPED} + FILE_FLAG_NO_BUFFERING = $20000000; + {$EXTERNALSYM FILE_FLAG_NO_BUFFERING} + FILE_FLAG_RANDOM_ACCESS = $10000000; + {$EXTERNALSYM FILE_FLAG_RANDOM_ACCESS} + FILE_FLAG_SEQUENTIAL_SCAN = $08000000; + {$EXTERNALSYM FILE_FLAG_SEQUENTIAL_SCAN} + FILE_FLAG_DELETE_ON_CLOSE = $04000000; + {$EXTERNALSYM FILE_FLAG_DELETE_ON_CLOSE} + FILE_FLAG_BACKUP_SEMANTICS = $02000000; + {$EXTERNALSYM FILE_FLAG_BACKUP_SEMANTICS} + FILE_FLAG_POSIX_SEMANTICS = $01000000; + {$EXTERNALSYM FILE_FLAG_POSIX_SEMANTICS} + FILE_FLAG_OPEN_REPARSE_POINT = $00200000; + {$EXTERNALSYM FILE_FLAG_OPEN_REPARSE_POINT} + FILE_FLAG_OPEN_NO_RECALL = $00100000; + {$EXTERNALSYM FILE_FLAG_OPEN_NO_RECALL} + FILE_FLAG_FIRST_PIPE_INSTANCE = $00080000; + {$EXTERNALSYM FILE_FLAG_FIRST_PIPE_INSTANCE} + +// line 2727 +type + _MEMORYSTATUSEX = packed record + dwLength: DWORD; + dwMemoryLoad: DWORD; + ullTotalPhys: Int64; + ullAvailPhys: Int64; + ullTotalPageFile: Int64; + ullAvailPageFile: Int64; + ullTotalVirtual: Int64; + ullAvailVirtual: Int64; + ullAvailExtendedVirtual: Int64; + end; + {$EXTERNALSYM _MEMORYSTATUSEX} + + MEMORYSTATUSEX = _MEMORYSTATUSEX; + {$EXTERNALSYM MEMORYSTATUSEX} + LPMEMORYSTATUSEX = ^_MEMORYSTATUSEX; + {$EXTERNALSYM LPMEMORYSTATUSEX} + + TMemoryStatusEx = _MEMORYSTATUSEX; + +function GlobalMemoryStatusEx(out lpBuffer: TMemoryStatusEx): BOOL; stdcall; + +// line 3189 + + +function BackupSeek(hFile: THandle; dwLowBytesToSeek, dwHighBytesToSeek: DWORD; + out lpdwLowByteSeeked, lpdwHighByteSeeked: DWORD; + var lpContext: Pointer): BOOL; stdcall; +{$EXTERNALSYM BackupSeek} + +// line 5454 + +function AdjustTokenPrivileges(TokenHandle: THandle; DisableAllPrivileges: BOOL; + const NewState: TTokenPrivileges; BufferLength: DWORD; + PreviousState: PTokenPrivileges; + ReturnLength: PDWORD + ): BOOL; stdcall; +{$EXTERNALSYM AdjustTokenPrivileges} + +{ +From: Ray Lischner +Subject: CreateMutex bug +Date: 1999/12/10 +Message-ID: #1/1 +Content-Transfer-Encoding: 7bit +Organization: Tempest Software, Inc., Corvallis, Oregon +Content-Type: text/plain; charset=us-ascii +Mime-Version: 1.0 +Newsgroups: borland.public.delphi.winapi + + +Windows NT 4 has a bug in CreateMutex. The second argument is documented +to be a BOOL, but in truth, the CreateMutex interprets 1 as True and all +other values as False. (Do I detect an "if (bInitialOwner == TRUE)" in +the implementation of CreateMutex?) + +The problem is that Delphi declares CreateMutex according to the +documentation, so bInitialOwner is declared as LongBool. Delphi maps +True values to $FFFFFFFF, which should work, but doesn't in this case. + +My workaround is to declare CreateMutex with a LongInt as the second +argument, and pass the value 1 for True. + +I have not had this problem on Windows 98. +-- +Ray Lischner, author of Delphi in a Nutshell (coming later this year) +http://www.bardware.com and http://www.tempest-sw.com +} +function CreateMutex(lpMutexAttributes: PSecurityAttributes; bInitialOwner: DWORD; lpName: PChar): THandle; stdcall; +{$EXTERNALSYM CreateMutex} + +// alternative conversion for WinNT 4.0 SP6 and later (OSVersionInfoEx instead of OSVersionInfo) +{$EXTERNALSYM GetVersionEx} +function GetVersionEx(var lpVersionInformation: TOSVersionInfoEx): BOOL; stdcall; overload; +{$EXTERNALSYM GetVersionEx} +function GetVersionEx(lpVersionInformation: POSVERSIONINFOEX): BOOL; stdcall; overload; + {$IFDEF SUPPORTS_DEPRECATED} deprecated; {$ENDIF} + +// line 3585 + +function SetWaitableTimer(hTimer: THandle; var lpDueTime: TLargeInteger; + lPeriod: Longint; pfnCompletionRoutine: TFNTimerAPCRoutine; + lpArgToCompletionRoutine: Pointer; fResume: BOOL): BOOL; stdcall; + {$EXTERNALSYM SetWaitableTimer} + +// WinBase.h line 8839 + +function SetFileSecurityA(lpFileName: LPCSTR; SecurityInformation: SECURITY_INFORMATION; + pSecurityDescriptor: PSECURITY_DESCRIPTOR): BOOL; stdcall; +{$EXTERNALSYM SetFileSecurityA} +function SetFileSecurityW(lpFileName: LPCWSTR; SecurityInformation: SECURITY_INFORMATION; + pSecurityDescriptor: PSECURITY_DESCRIPTOR): BOOL; stdcall; +{$EXTERNALSYM SetFileSecurityW} +function SetFileSecurity(lpFileName: LPCTSTR; SecurityInformation: SECURITY_INFORMATION; + pSecurityDescriptor: PSECURITY_DESCRIPTOR): BOOL; stdcall; +{$EXTERNALSYM SetFileSecurity} + +function GetFileSecurityA(lpFileName: LPCSTR; RequestedInformation: SECURITY_INFORMATION; + pSecurityDescriptor: PSECURITY_DESCRIPTOR; nLength: DWORD; + var lpnLengthNeeded: DWORD): BOOL; stdcall; +{$EXTERNALSYM GetFileSecurityA} +function GetFileSecurityW(lpFileName: LPCWSTR; RequestedInformation: SECURITY_INFORMATION; + pSecurityDescriptor: PSECURITY_DESCRIPTOR; nLength: DWORD; + var lpnLengthNeeded: DWORD): BOOL; stdcall; +{$EXTERNALSYM GetFileSecurityW} +function GetFileSecurity(lpFileName: LPCTSTR; RequestedInformation: SECURITY_INFORMATION; + pSecurityDescriptor: PSECURITY_DESCRIPTOR; nLength: DWORD; + var lpnLengthNeeded: DWORD): BOOL; stdcall; +{$EXTERNALSYM GetFileSecurity} + +// WinBase.h line 10251 + +function SetVolumeMountPointW(lpszVolumeMountPoint, lpszVolumeName: LPCWSTR): BOOL; stdcall; +{$EXTERNALSYM SetVolumeMountPointW} + +function DeleteVolumeMountPointW(lpszVolumeMountPoint: LPCWSTR): BOOL; stdcall; +{$EXTERNALSYM DeleteVolumeMountPointW} + +function GetVolumeNameForVolumeMountPointW(lpszVolumeMountPoint: LPCWSTR; + lpszVolumeName: LPWSTR; cchBufferLength: DWORD): BOOL; stdcall; +{$EXTERNALSYM GetVolumeNameForVolumeMountPointW} + +// new Windows 7 debugging API +function CopyExtendedContext(Destination: PCONTEXT_EX; ContextFlags: DWORD; Source: PCONTEXT_EX): BOOL; stdcall; +{$EXTERNALSYM CopyExtendedContext} + +function InitializeExtendedContext(Context: Pointer; ContextFlags: DWORD; out ContextEx: PCONTEXT_EX): BOOL; stdcall; +{$EXTERNALSYM InitializeExtendedContext} + +function GetEnabledExtendedFeatures(const FeatureMask: Int64): Int64; stdcall; +{$EXTERNALSYM GetEnabledExtendedFeatures} + +function GetExtendedContextLength(ContextFlags: DWORD; ContextLength: PDWORD): BOOL; stdcall; +{$EXTERNALSYM GetExtendedContextLength} + +function GetExtendedFeaturesMask(ContextEx: PCONTEXT_EX): Int64; stdcall; +{$EXTERNALSYM GetExtendedFeaturesMask} + +function LocateExtendedFeature(ContextEx: PCONTEXT_EX; FeatureId: DWORD; Length: PDWORD): Pointer; stdcall; +{$EXTERNALSYM LocateExtendedFeature} + +function LocateLegacyContext(ContextEx: PCONTEXT_EX; Length: PDWORD): PCONTEXT; stdcall; +{$EXTERNALSYM LocateLegacyContext} + +procedure SetExtendedFeaturesMask(ContextEx: PCONTEXT_EX; const FeatureMask: Int64); stdcall; +{$EXTERNALSYM SetExtendedFeaturesMask} + +function ProcessIdToSessionId(dwProcessId: DWORD; out dwSessionId: DWORD): BOOL; stdcall; +{$EXTERNALSYM ProcessIdToSessionId} + + +// From JwaAclApi + +// line 185 + +function SetNamedSecurityInfoW(pObjectName: LPWSTR; ObjectType: SE_OBJECT_TYPE; + SecurityInfo: SECURITY_INFORMATION; psidOwner, psidGroup: PSID; + pDacl, pSacl: PACL): DWORD; stdcall; +{$EXTERNALSYM SetNamedSecurityInfoW} +const + IMAGE_SEPARATION = (64*1024); + {$EXTERNALSYM IMAGE_SEPARATION} + +type + PLOADED_IMAGE = ^LOADED_IMAGE; + {$EXTERNALSYM PLOADED_IMAGE} + _LOADED_IMAGE = record + ModuleName: PAnsiChar; + hFile: THandle; + MappedAddress: PUCHAR; + FileHeader: PImageNtHeaders; + LastRvaSection: PImageSectionHeader; + NumberOfSections: ULONG; + Sections: PImageSectionHeader; + Characteristics: ULONG; + fSystemImage: ByteBool; + fDOSImage: ByteBool; + Links: LIST_ENTRY; + SizeOfImage: ULONG; + end; + {$EXTERNALSYM _LOADED_IMAGE} + LOADED_IMAGE = _LOADED_IMAGE; + {$EXTERNALSYM LOADED_IMAGE} + TLoadedImage = LOADED_IMAGE; + PLoadedImage = PLOADED_IMAGE; + + PIMAGE_SYMBOL = ^IMAGE_SYMBOL; + {$EXTERNALSYM PIMAGE_SYMBOL} + _IMAGE_SYMBOL = packed record // MUST pack to obtain the right size + Name: array [0..7] of AnsiChar; + Value: ULONG; + SectionNumber: USHORT; + _Type: USHORT; + StorageClass: BYTE; + NumberOfAuxSymbols: BYTE; + end; + {$EXTERNALSYM _IMAGE_SYMBOL} + IMAGE_SYMBOL = _IMAGE_SYMBOL; + {$EXTERNALSYM IMAGE_SYMBOL} + TImageSymbol = IMAGE_SYMBOL; + PImageSymbol = PIMAGE_SYMBOL; + +// line 152 + + +function ReBaseImage(CurrentImageName: PAnsiChar; SymbolPath: PAnsiChar; fReBase: BOOL; + fRebaseSysfileOk: BOOL; fGoingDown: BOOL; CheckImageSize: ULONG; + var OldImageSize: TJclAddr32; var OldImageBase: TJclAddr; + var NewImageSize: TJclAddr32; var NewImageBase: TJclAddr; TimeStamp: ULONG): BOOL; stdcall; +{$EXTERNALSYM ReBaseImage} + +function ReBaseImage64(CurrentImageName: PAnsiChar; SymbolPath: PAnsiChar; fReBase: BOOL; + fRebaseSysfileOk: BOOL; fGoingDown: BOOL; CheckImageSize: ULONG; + var OldImageSize: TJclAddr32; var OldImageBase: TJclAddr64; + var NewImageSize: TJclAddr32; var NewImageBase: TJclAddr64; TimeStamp: ULONG): BOOL; stdcall; +{$EXTERNALSYM ReBaseImage64} + +// line 199 + +// +// Define checksum function prototypes. +// + +function CheckSumMappedFile(BaseAddress: Pointer; FileLength: DWORD; + out HeaderSum, CheckSum: DWORD): PImageNtHeaders; stdcall; +{$EXTERNALSYM CheckSumMappedFile} + +// line 227 + +function GetImageUnusedHeaderBytes(const LoadedImage: LOADED_IMAGE; + var SizeUnusedHeaderBytes: DWORD): DWORD; stdcall; +{$EXTERNALSYM GetImageUnusedHeaderBytes} + +// line 285 + +function MapAndLoad(ImageName, DllPath: PAnsiChar; var LoadedImage: LOADED_IMAGE; + DotDll: BOOL; ReadOnly: BOOL): BOOL; stdcall; +{$EXTERNALSYM MapAndLoad} + +function UnMapAndLoad(const LoadedImage: LOADED_IMAGE): BOOL; stdcall; +{$EXTERNALSYM UnMapAndLoad} + +function TouchFileTimes(const FileHandle: THandle; const pSystemTime: TSystemTime): BOOL; stdcall; +{$EXTERNALSYM TouchFileTimes} + +// line 347 + +function ImageDirectoryEntryToData(Base: Pointer; MappedAsImage: ByteBool; + DirectoryEntry: USHORT; var Size: ULONG): Pointer; stdcall; +{$EXTERNALSYM ImageDirectoryEntryToData} + +function ImageRvaToSection(NtHeaders: PImageNtHeaders; Base: Pointer; Rva: ULONG): PImageSectionHeader; stdcall; +{$EXTERNALSYM ImageRvaToSection} + +function ImageRvaToVa(NtHeaders: PImageNtHeaders; Base: Pointer; Rva: ULONG; + LastRvaSection: PPImageSectionHeader): Pointer; stdcall; +{$EXTERNALSYM ImageRvaToVa} + + +// line 461 + +// +// UnDecorateSymbolName Flags +// + +const + UNDNAME_COMPLETE = ($0000); // Enable full undecoration + {$EXTERNALSYM UNDNAME_COMPLETE} + UNDNAME_NO_LEADING_UNDERSCORES = ($0001); // Remove leading underscores from MS extended keywords + {$EXTERNALSYM UNDNAME_NO_LEADING_UNDERSCORES} + UNDNAME_NO_MS_KEYWORDS = ($0002); // Disable expansion of MS extended keywords + {$EXTERNALSYM UNDNAME_NO_MS_KEYWORDS} + UNDNAME_NO_FUNCTION_RETURNS = ($0004); // Disable expansion of return type for primary declaration + {$EXTERNALSYM UNDNAME_NO_FUNCTION_RETURNS} + UNDNAME_NO_ALLOCATION_MODEL = ($0008); // Disable expansion of the declaration model + {$EXTERNALSYM UNDNAME_NO_ALLOCATION_MODEL} + UNDNAME_NO_ALLOCATION_LANGUAGE = ($0010); // Disable expansion of the declaration language specifier + {$EXTERNALSYM UNDNAME_NO_ALLOCATION_LANGUAGE} + UNDNAME_NO_MS_THISTYPE = ($0020); // NYI Disable expansion of MS keywords on the 'this' type for primary declaration + {$EXTERNALSYM UNDNAME_NO_MS_THISTYPE} + UNDNAME_NO_CV_THISTYPE = ($0040); // NYI Disable expansion of CV modifiers on the 'this' type for primary declaration + {$EXTERNALSYM UNDNAME_NO_CV_THISTYPE} + UNDNAME_NO_THISTYPE = ($0060); // Disable all modifiers on the 'this' type + {$EXTERNALSYM UNDNAME_NO_THISTYPE} + UNDNAME_NO_ACCESS_SPECIFIERS = ($0080); // Disable expansion of access specifiers for members + {$EXTERNALSYM UNDNAME_NO_ACCESS_SPECIFIERS} + UNDNAME_NO_THROW_SIGNATURES = ($0100); // Disable expansion of 'throw-signatures' for functions and pointers to functions + {$EXTERNALSYM UNDNAME_NO_THROW_SIGNATURES} + UNDNAME_NO_MEMBER_TYPE = ($0200); // Disable expansion of 'static' or 'virtual'ness of members + {$EXTERNALSYM UNDNAME_NO_MEMBER_TYPE} + UNDNAME_NO_RETURN_UDT_MODEL = ($0400); // Disable expansion of MS model for UDT returns + {$EXTERNALSYM UNDNAME_NO_RETURN_UDT_MODEL} + UNDNAME_32_BIT_DECODE = ($0800); // Undecorate 32-bit decorated names + {$EXTERNALSYM UNDNAME_32_BIT_DECODE} + UNDNAME_NAME_ONLY = ($1000); // Crack only the name for primary declaration; + {$EXTERNALSYM UNDNAME_NAME_ONLY} + // return just [scope::]name. Does expand template params + UNDNAME_NO_ARGUMENTS = ($2000); // Don't undecorate arguments to function + {$EXTERNALSYM UNDNAME_NO_ARGUMENTS} + UNDNAME_NO_SPECIAL_SYMS = ($4000); // Don't undecorate special names (v-table, vcall, vector xxx, metatype, etc) + {$EXTERNALSYM UNDNAME_NO_SPECIAL_SYMS} + +// line 1342 + +type + {$EXTERNALSYM SYM_TYPE} + SYM_TYPE = ( + SymNone, + SymCoff, + SymCv, + SymPdb, + SymExport, + SymDeferred, + SymSym { .sym file } + ); + TSymType = SYM_TYPE; + + { symbol data structure } + {$EXTERNALSYM PImagehlpSymbolA} + PImagehlpSymbolA = ^TImagehlpSymbolA; + {$EXTERNALSYM _IMAGEHLP_SYMBOLA} + _IMAGEHLP_SYMBOLA = packed record + SizeOfStruct: DWORD; { set to sizeof(IMAGEHLP_SYMBOL) } + Address: DWORD; { virtual address including dll base address } + Size: DWORD; { estimated size of symbol, can be zero } + Flags: DWORD; { info about the symbols, see the SYMF defines } + MaxNameLength: DWORD; { maximum size of symbol name in 'Name' } + Name: packed array[0..0] of AnsiChar; { symbol name (null terminated string) } + end; + {$EXTERNALSYM IMAGEHLP_SYMBOLA} + IMAGEHLP_SYMBOLA = _IMAGEHLP_SYMBOLA; + {$EXTERNALSYM TImagehlpSymbolA} + TImagehlpSymbolA = _IMAGEHLP_SYMBOLA; + + { symbol data structure } + {$EXTERNALSYM PImagehlpSymbolA64} + PImagehlpSymbolA64 = ^TImagehlpSymbolA64; + {$EXTERNALSYM _IMAGEHLP_SYMBOLA64} + _IMAGEHLP_SYMBOLA64 = packed record + SizeOfStruct: DWORD; { set to sizeof(IMAGEHLP_SYMBOL) } + Address: TJclAddr64; { virtual address including dll base address } + Size: DWORD; { estimated size of symbol, can be zero } + Flags: DWORD; { info about the symbols, see the SYMF defines } + MaxNameLength: DWORD; { maximum size of symbol name in 'Name' } + Name: packed array[0..0] of AnsiChar; { symbol name (null terminated string) } + end; + {$EXTERNALSYM IMAGEHLP_SYMBOLA64} + IMAGEHLP_SYMBOLA64 = _IMAGEHLP_SYMBOLA64; + {$EXTERNALSYM TImagehlpSymbolA64} + TImagehlpSymbolA64 = _IMAGEHLP_SYMBOLA64; + + { symbol data structure } + {$EXTERNALSYM PImagehlpSymbolW} + PImagehlpSymbolW = ^TImagehlpSymbolW; + {$EXTERNALSYM _IMAGEHLP_SYMBOLW} + _IMAGEHLP_SYMBOLW = packed record + SizeOfStruct: DWORD; { set to sizeof(IMAGEHLP_SYMBOL) } + Address: DWORD; { virtual address including dll base address } + Size: DWORD; { estimated size of symbol, can be zero } + Flags: DWORD; { info about the symbols, see the SYMF defines } + MaxNameLength: DWORD; { maximum size of symbol name in 'Name' } + Name: packed array[0..0] of WideChar; { symbol name (null terminated string) } + end; + {$EXTERNALSYM IMAGEHLP_SYMBOLW} + IMAGEHLP_SYMBOLW = _IMAGEHLP_SYMBOLW; + {$EXTERNALSYM TImagehlpSymbolW} + TImagehlpSymbolW = _IMAGEHLP_SYMBOLW; + + { symbol data structure } + {$EXTERNALSYM PImagehlpSymbolW64} + PImagehlpSymbolW64 = ^TImagehlpSymbolW64; + {$EXTERNALSYM _IMAGEHLP_SYMBOLW64} + _IMAGEHLP_SYMBOLW64 = packed record + SizeOfStruct: DWORD; { set to sizeof(IMAGEHLP_SYMBOL) } + Address: TJclAddr64; { virtual address including dll base address } + Size: DWORD; { estimated size of symbol, can be zero } + Flags: DWORD; { info about the symbols, see the SYMF defines } + MaxNameLength: DWORD; { maximum size of symbol name in 'Name' } + Name: packed array[0..0] of WideChar; { symbol name (null terminated string) } + end; + {$EXTERNALSYM IMAGEHLP_SYMBOLW64} + IMAGEHLP_SYMBOLW64 = _IMAGEHLP_SYMBOLW64; + {$EXTERNALSYM TImagehlpSymbolW64} + TImagehlpSymbolW64 = _IMAGEHLP_SYMBOLW64; + + { module data structure } + {$EXTERNALSYM PImagehlpModuleA} + PImagehlpModuleA = ^TImagehlpModuleA; + {$EXTERNALSYM _IMAGEHLP_MODULEA} + _IMAGEHLP_MODULEA = record + SizeOfStruct: DWORD; { set to sizeof(IMAGEHLP_MODULE) } + BaseOfImage: DWORD; { base load address of module } + ImageSize: DWORD; { virtual size of the loaded module } + TimeDateStamp: DWORD; { date/time stamp from pe header } + CheckSum: DWORD; { checksum from the pe header } + NumSyms: DWORD; { number of symbols in the symbol table } + SymType: TSymType; { type of symbols loaded } + ModuleName: packed array[0..31] of AnsiChar; { module name } + ImageName: packed array[0..255] of AnsiChar; { image name } + LoadedImageName: packed array[0..255] of AnsiChar; { symbol file name } + end; + {$EXTERNALSYM IMAGEHLP_MODULEA} + IMAGEHLP_MODULEA = _IMAGEHLP_MODULEA; + {$EXTERNALSYM TImagehlpModuleA} + TImagehlpModuleA = _IMAGEHLP_MODULEA; + + { module data structure } + {$EXTERNALSYM PImagehlpModuleA64} + PImagehlpModuleA64 = ^TImagehlpModuleA64; + {$EXTERNALSYM _IMAGEHLP_MODULEA64} + _IMAGEHLP_MODULEA64 = record + SizeOfStruct: DWORD; { set to sizeof(IMAGEHLP_MODULE) } + BaseOfImage: TJclAddr64; { base load address of module } + ImageSize: DWORD; { virtual size of the loaded module } + TimeDateStamp: DWORD; { date/time stamp from pe header } + CheckSum: DWORD; { checksum from the pe header } + NumSyms: DWORD; { number of symbols in the symbol table } + SymType: TSymType; { type of symbols loaded } + ModuleName: packed array[0..31] of AnsiChar; { module name } + ImageName: packed array[0..255] of AnsiChar; { image name } + LoadedImageName: packed array[0..255] of AnsiChar; { symbol file name } + end; + {$EXTERNALSYM IMAGEHLP_MODULEA64} + IMAGEHLP_MODULEA64 = _IMAGEHLP_MODULEA64; + {$EXTERNALSYM TImagehlpModuleA64} + TImagehlpModuleA64 = _IMAGEHLP_MODULEA64; + + { module data structure } + {$EXTERNALSYM PImagehlpModuleW} + PImagehlpModuleW = ^TImagehlpModuleW; + {$EXTERNALSYM _IMAGEHLP_MODULEW} + _IMAGEHLP_MODULEW = record + SizeOfStruct: DWORD; { set to sizeof(IMAGEHLP_MODULE) } + BaseOfImage: DWORD; { base load address of module } + ImageSize: DWORD; { virtual size of the loaded module } + TimeDateStamp: DWORD; { date/time stamp from pe header } + CheckSum: DWORD; { checksum from the pe header } + NumSyms: DWORD; { number of symbols in the symbol table } + SymType: TSymType; { type of symbols loaded } + ModuleName: packed array[0..31] of WideChar; { module name } + ImageName: packed array[0..255] of WideChar; { image name } + LoadedImageName: packed array[0..255] of WideChar; { symbol file name } + end; + {$EXTERNALSYM IMAGEHLP_MODULEW} + IMAGEHLP_MODULEW = _IMAGEHLP_MODULEW; + {$EXTERNALSYM TImagehlpModuleW} + TImagehlpModuleW = _IMAGEHLP_MODULEW; + + { module data structure } + {$EXTERNALSYM PImagehlpModuleW64} + PImagehlpModuleW64 = ^TImagehlpModuleW64; + {$EXTERNALSYM _IMAGEHLP_MODULEW64} + _IMAGEHLP_MODULEW64 = record + SizeOfStruct: DWORD; { set to sizeof(IMAGEHLP_MODULE) } + BaseOfImage: TJclAddr64; { base load address of module } + ImageSize: DWORD; { virtual size of the loaded module } + TimeDateStamp: DWORD; { date/time stamp from pe header } + CheckSum: DWORD; { checksum from the pe header } + NumSyms: DWORD; { number of symbols in the symbol table } + SymType: TSymType; { type of symbols loaded } + ModuleName: packed array[0..31] of WideChar; { module name } + ImageName: packed array[0..255] of WideChar; { image name } + LoadedImageName: packed array[0..255] of WideChar; { symbol file name } + end; + {$EXTERNALSYM IMAGEHLP_MODULEW64} + IMAGEHLP_MODULEW64 = _IMAGEHLP_MODULEW64; + {$EXTERNALSYM TImagehlpModuleW64} + TImagehlpModuleW64 = _IMAGEHLP_MODULEW64; + + _IMAGEHLP_LINEA = packed record + SizeOfStruct: DWORD; // set to sizeof(IMAGEHLP_LINE) + Key: Pointer; // internal + LineNumber: DWORD; // line number in file + FileName: PAnsiChar; // full filename + Address: DWORD; // first instruction of line + end; + IMAGEHLP_LINEA = _IMAGEHLP_LINEA; + PIMAGEHLP_LINEA = ^_IMAGEHLP_LINEA; + TImageHlpLineA = _IMAGEHLP_LINEA; + PImageHlpLineA = PIMAGEHLP_LINEA; + + _IMAGEHLP_LINEA64 = packed record + SizeOfStruct: DWORD; // set to sizeof(IMAGEHLP_LINE) + Key: Pointer; // internal + LineNumber: DWORD; // line number in file + FileName: PAnsiChar; // full filename + Address: TJclAddr64; // first instruction of line + end; + IMAGEHLP_LINEA64 = _IMAGEHLP_LINEA64; + PIMAGEHLP_LINEA64 = ^_IMAGEHLP_LINEA64; + TImageHlpLineA64 = _IMAGEHLP_LINEA64; + PImageHlpLineA64 = PIMAGEHLP_LINEA64; + + _IMAGEHLP_LINEW = packed record + SizeOfStruct: DWORD; // set to sizeof(IMAGEHLP_LINE) + Key: Pointer; // internal + LineNumber: DWORD; // line number in file + FileName: PWideChar; // full filename + Address: DWORD; // first instruction of line + end; + IMAGEHLP_LINEW = _IMAGEHLP_LINEW; + PIMAGEHLP_LINEW = ^_IMAGEHLP_LINEW; + TImageHlpLineW = _IMAGEHLP_LINEW; + PImageHlpLineW = PIMAGEHLP_LINEW; + + _IMAGEHLP_LINEW64 = packed record + SizeOfStruct: DWORD; // set to sizeof(IMAGEHLP_LINE) + Key: Pointer; // internal + LineNumber: DWORD; // line number in file + FileName: PWideChar; // full filename + Address: TJclAddr64; // first instruction of line + end; + IMAGEHLP_LINEW64 = _IMAGEHLP_LINEW64; + PIMAGEHLP_LINEW64 = ^_IMAGEHLP_LINEW64; + TImageHlpLineW64 = _IMAGEHLP_LINEW64; + PImageHlpLineW64 = PIMAGEHLP_LINEW64; + +// line 1475 + +// +// options that are set/returned by SymSetOptions() & SymGetOptions() +// these are used as a mask +// + +const + SYMOPT_CASE_INSENSITIVE = $00000001; + {$EXTERNALSYM SYMOPT_CASE_INSENSITIVE} + SYMOPT_UNDNAME = $00000002; + {$EXTERNALSYM SYMOPT_UNDNAME} + SYMOPT_DEFERRED_LOADS = $00000004; + {$EXTERNALSYM SYMOPT_DEFERRED_LOADS} + SYMOPT_NO_CPP = $00000008; + {$EXTERNALSYM SYMOPT_NO_CPP} + SYMOPT_LOAD_LINES = $00000010; + {$EXTERNALSYM SYMOPT_LOAD_LINES} + SYMOPT_OMAP_FIND_NEAREST = $00000020; + {$EXTERNALSYM SYMOPT_OMAP_FIND_NEAREST} + SYMOPT_LOAD_ANYTHING = $00000040; + {$EXTERNALSYM SYMOPT_LOAD_ANYTHING} + SYMOPT_IGNORE_CVREC = $00000080; + {$EXTERNALSYM SYMOPT_IGNORE_CVREC} + SYMOPT_NO_UNQUALIFIED_LOADS = $00000100; + {$EXTERNALSYM SYMOPT_NO_UNQUALIFIED_LOADS} + SYMOPT_FAIL_CRITICAL_ERRORS = $00000200; + {$EXTERNALSYM SYMOPT_FAIL_CRITICAL_ERRORS} + SYMOPT_EXACT_SYMBOLS = $00000400; + {$EXTERNALSYM SYMOPT_EXACT_SYMBOLS} + SYMOPT_ALLOW_ABSOLUTE_SYMBOLS = $00000800; + {$EXTERNALSYM SYMOPT_ALLOW_ABSOLUTE_SYMBOLS} + SYMOPT_IGNORE_NT_SYMPATH = $00001000; + {$EXTERNALSYM SYMOPT_IGNORE_NT_SYMPATH} + SYMOPT_INCLUDE_32BIT_MODULES = $00002000; + {$EXTERNALSYM SYMOPT_INCLUDE_32BIT_MODULES} + SYMOPT_PUBLICS_ONLY = $00004000; + {$EXTERNALSYM SYMOPT_PUBLICS_ONLY} + SYMOPT_NO_PUBLICS = $00008000; + {$EXTERNALSYM SYMOPT_NO_PUBLICS} + SYMOPT_AUTO_PUBLICS = $00010000; + {$EXTERNALSYM SYMOPT_AUTO_PUBLICS} + SYMOPT_NO_IMAGE_SEARCH = $00020000; + {$EXTERNALSYM SYMOPT_NO_IMAGE_SEARCH} + SYMOPT_SECURE = $00040000; + {$EXTERNALSYM SYMOPT_SECURE} + SYMOPT_NO_PROMPTS = $00080000; + {$EXTERNALSYM SYMOPT_NO_PROMPTS} + + SYMOPT_DEBUG = $80000000; + {$EXTERNALSYM SYMOPT_DEBUG} + +// IoAPI.h + + +function CancelIo(hFile: THandle): BOOL; stdcall; +{$EXTERNALSYM CancelIo} + + +const + NERR_Success = 0; // Success + {$EXTERNALSYM NERR_Success} + +// ERROR_ equates can be intermixed with NERR_ equates. + +// NERR_BASE is the base of error codes from network utilities, +// chosen to avoid conflict with system and redirector error codes. +// 2100 is a value that has been assigned to us by system. + + NERR_BASE = 2100; + {$EXTERNALSYM NERR_BASE} + + +//*INTERNAL_ONLY* + +{**********WARNING ***************** + *See the comment in lmcons.h for * + *info on the allocation of errors * + ***********************************} + +{**********WARNING ***************** + *The range 2750-2799 has been * + *allocated to the IBM LAN Server * + ***********************************} + +{**********WARNING ***************** + *The range 2900-2999 has been * + *reserved for Microsoft OEMs * + ***********************************} + +// UNUSED BASE+0 +// UNUSED BASE+1 + NERR_NetNotStarted = (NERR_BASE+2); // The workstation driver is not installed. + {$EXTERNALSYM NERR_NetNotStarted} + NERR_UnknownServer = (NERR_BASE+3); // The server could not be located. + {$EXTERNALSYM NERR_UnknownServer} + NERR_ShareMem = (NERR_BASE+4); // An internal error occurred. The network cannot access a shared memory segment. + {$EXTERNALSYM NERR_ShareMem} + + NERR_NoNetworkResource = (NERR_BASE+5); // A network resource shortage occurred . + {$EXTERNALSYM NERR_NoNetworkResource} + NERR_RemoteOnly = (NERR_BASE+6); // This operation is not supported on workstations. + {$EXTERNALSYM NERR_RemoteOnly} + NERR_DevNotRedirected = (NERR_BASE+7); // The device is not connected. + {$EXTERNALSYM NERR_DevNotRedirected} +// NERR_BASE+8 is used for ERROR_CONNECTED_OTHER_PASSWORD +// NERR_BASE+9 is used for ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT +// UNUSED BASE+10 +// UNUSED BASE+11 +// UNUSED BASE+12 +// UNUSED BASE+13 + NERR_ServerNotStarted = (NERR_BASE+14); // The Server service is not started. + {$EXTERNALSYM NERR_ServerNotStarted} + NERR_ItemNotFound = (NERR_BASE+15); // The queue is empty. + {$EXTERNALSYM NERR_ItemNotFound} + NERR_UnknownDevDir = (NERR_BASE+16); // The device or directory does not exist. + {$EXTERNALSYM NERR_UnknownDevDir} + NERR_RedirectedPath = (NERR_BASE+17); // The operation is invalid on a redirected resource. + {$EXTERNALSYM NERR_RedirectedPath} + NERR_DuplicateShare = (NERR_BASE+18); // The name has already been shared. + {$EXTERNALSYM NERR_DuplicateShare} + NERR_NoRoom = (NERR_BASE+19); // The server is currently out of the requested resource. + {$EXTERNALSYM NERR_NoRoom} +// UNUSED BASE+20 + NERR_TooManyItems = (NERR_BASE+21); // Requested addition of items exceeds the maximum allowed. + {$EXTERNALSYM NERR_TooManyItems} + NERR_InvalidMaxUsers = (NERR_BASE+22); // The Peer service supports only two simultaneous users. + {$EXTERNALSYM NERR_InvalidMaxUsers} + NERR_BufTooSmall = (NERR_BASE+23); // The API return buffer is too small. + {$EXTERNALSYM NERR_BufTooSmall} +// UNUSED BASE+24 +// UNUSED BASE+25 +// UNUSED BASE+26 + NERR_RemoteErr = (NERR_BASE+27); // A remote API error occurred. + {$EXTERNALSYM NERR_RemoteErr} +// UNUSED BASE+28 +// UNUSED BASE+29 +// UNUSED BASE+30 + NERR_LanmanIniError = (NERR_BASE+31); // An error occurred when opening or reading the configuration file. + {$EXTERNALSYM NERR_LanmanIniError} +// UNUSED BASE+32 +// UNUSED BASE+33 +// UNUSED BASE+34 +// UNUSED BASE+35 + NERR_NetworkError = (NERR_BASE+36); // A general network error occurred. + {$EXTERNALSYM NERR_NetworkError} + NERR_WkstaInconsistentState = (NERR_BASE+37); + {$EXTERNALSYM NERR_WkstaInconsistentState} + // The Workstation service is in an inconsistent state. Restart the computer before restarting the Workstation service. + NERR_WkstaNotStarted = (NERR_BASE+38); // The Workstation service has not been started. + {$EXTERNALSYM NERR_WkstaNotStarted} + NERR_BrowserNotStarted = (NERR_BASE+39); // The requested information is not available. + {$EXTERNALSYM NERR_BrowserNotStarted} + NERR_InternalError = (NERR_BASE+40); // An internal Windows 2000 error occurred. + {$EXTERNALSYM NERR_InternalError} + NERR_BadTransactConfig = (NERR_BASE+41); // The server is not configured for transactions. + {$EXTERNALSYM NERR_BadTransactConfig} + NERR_InvalidAPI = (NERR_BASE+42); // The requested API is not supported on the remote server. + {$EXTERNALSYM NERR_InvalidAPI} + NERR_BadEventName = (NERR_BASE+43); // The event name is invalid. + {$EXTERNALSYM NERR_BadEventName} + NERR_DupNameReboot = (NERR_BASE+44); // The computer name already exists on the network. Change it and restart the computer. + {$EXTERNALSYM NERR_DupNameReboot} + +// +// Config API related +// Error codes from BASE+45 to BASE+49 + + +// UNUSED BASE+45 + NERR_CfgCompNotFound = (NERR_BASE+46); // The specified component could not be found in the configuration information. + {$EXTERNALSYM NERR_CfgCompNotFound} + NERR_CfgParamNotFound = (NERR_BASE+47); // The specified parameter could not be found in the configuration information. + {$EXTERNALSYM NERR_CfgParamNotFound} + NERR_LineTooLong = (NERR_BASE+49); // A line in the configuration file is too long. + {$EXTERNALSYM NERR_LineTooLong} + +// +// Spooler API related +// Error codes from BASE+50 to BASE+79 + + + NERR_QNotFound = (NERR_BASE+50); // The printer does not exist. + {$EXTERNALSYM NERR_QNotFound} + NERR_JobNotFound = (NERR_BASE+51); // The print job does not exist. + {$EXTERNALSYM NERR_JobNotFound} + NERR_DestNotFound = (NERR_BASE+52); // The printer destination cannot be found. + {$EXTERNALSYM NERR_DestNotFound} + NERR_DestExists = (NERR_BASE+53); // The printer destination already exists. + {$EXTERNALSYM NERR_DestExists} + NERR_QExists = (NERR_BASE+54); // The printer queue already exists. + {$EXTERNALSYM NERR_QExists} + NERR_QNoRoom = (NERR_BASE+55); // No more printers can be added. + {$EXTERNALSYM NERR_QNoRoom} + NERR_JobNoRoom = (NERR_BASE+56); // No more print jobs can be added. + {$EXTERNALSYM NERR_JobNoRoom} + NERR_DestNoRoom = (NERR_BASE+57); // No more printer destinations can be added. + {$EXTERNALSYM NERR_DestNoRoom} + NERR_DestIdle = (NERR_BASE+58); // This printer destination is idle and cannot accept control operations. + {$EXTERNALSYM NERR_DestIdle} + NERR_DestInvalidOp = (NERR_BASE+59); // This printer destination request contains an invalid control function. + {$EXTERNALSYM NERR_DestInvalidOp} + NERR_ProcNoRespond = (NERR_BASE+60); // The print processor is not responding. + {$EXTERNALSYM NERR_ProcNoRespond} + NERR_SpoolerNotLoaded = (NERR_BASE+61); // The spooler is not running. + {$EXTERNALSYM NERR_SpoolerNotLoaded} + NERR_DestInvalidState = (NERR_BASE+62); // This operation cannot be performed on the print destination in its current state. + {$EXTERNALSYM NERR_DestInvalidState} + NERR_QInvalidState = (NERR_BASE+63); // This operation cannot be performed on the printer queue in its current state. + {$EXTERNALSYM NERR_QInvalidState} + NERR_JobInvalidState = (NERR_BASE+64); // This operation cannot be performed on the print job in its current state. + {$EXTERNALSYM NERR_JobInvalidState} + NERR_SpoolNoMemory = (NERR_BASE+65); // A spooler memory allocation failure occurred. + {$EXTERNALSYM NERR_SpoolNoMemory} + NERR_DriverNotFound = (NERR_BASE+66); // The device driver does not exist. + {$EXTERNALSYM NERR_DriverNotFound} + NERR_DataTypeInvalid = (NERR_BASE+67); // The data type is not supported by the print processor. + {$EXTERNALSYM NERR_DataTypeInvalid} + NERR_ProcNotFound = (NERR_BASE+68); // The print processor is not installed. + {$EXTERNALSYM NERR_ProcNotFound} + +// +// Service API related +// Error codes from BASE+80 to BASE+99 + + + NERR_ServiceTableLocked = (NERR_BASE+80); // The service database is locked. + {$EXTERNALSYM NERR_ServiceTableLocked} + NERR_ServiceTableFull = (NERR_BASE+81); // The service table is full. + {$EXTERNALSYM NERR_ServiceTableFull} + NERR_ServiceInstalled = (NERR_BASE+82); // The requested service has already been started. + {$EXTERNALSYM NERR_ServiceInstalled} + NERR_ServiceEntryLocked = (NERR_BASE+83); // The service does not respond to control actions. + {$EXTERNALSYM NERR_ServiceEntryLocked} + NERR_ServiceNotInstalled = (NERR_BASE+84); // The service has not been started. + {$EXTERNALSYM NERR_ServiceNotInstalled} + NERR_BadServiceName = (NERR_BASE+85); // The service name is invalid. + {$EXTERNALSYM NERR_BadServiceName} + NERR_ServiceCtlTimeout = (NERR_BASE+86); // The service is not responding to the control function. + {$EXTERNALSYM NERR_ServiceCtlTimeout} + NERR_ServiceCtlBusy = (NERR_BASE+87); // The service control is busy. + {$EXTERNALSYM NERR_ServiceCtlBusy} + NERR_BadServiceProgName = (NERR_BASE+88); // The configuration file contains an invalid service program name. + {$EXTERNALSYM NERR_BadServiceProgName} + NERR_ServiceNotCtrl = (NERR_BASE+89); // The service could not be controlled in its present state. + {$EXTERNALSYM NERR_ServiceNotCtrl} + NERR_ServiceKillProc = (NERR_BASE+90); // The service ended abnormally. + {$EXTERNALSYM NERR_ServiceKillProc} + NERR_ServiceCtlNotValid = (NERR_BASE+91); // The requested pause,continue, or stop is not valid for this service. + {$EXTERNALSYM NERR_ServiceCtlNotValid} + NERR_NotInDispatchTbl = (NERR_BASE+92); // The service control dispatcher could not find the service name in the dispatch table. + {$EXTERNALSYM NERR_NotInDispatchTbl} + NERR_BadControlRecv = (NERR_BASE+93); // The service control dispatcher pipe read failed. + {$EXTERNALSYM NERR_BadControlRecv} + NERR_ServiceNotStarting = (NERR_BASE+94); // A thread for the new service could not be created. + {$EXTERNALSYM NERR_ServiceNotStarting} + +// +// Wksta and Logon API related +// Error codes from BASE+100 to BASE+118 + + + NERR_AlreadyLoggedOn = (NERR_BASE+100); // This workstation is already logged on to the local-area network. + {$EXTERNALSYM NERR_AlreadyLoggedOn} + NERR_NotLoggedOn = (NERR_BASE+101); // The workstation is not logged on to the local-area network. + {$EXTERNALSYM NERR_NotLoggedOn} + NERR_BadUsername = (NERR_BASE+102); // The user name or group name parameter is invalid. + {$EXTERNALSYM NERR_BadUsername} + NERR_BadPassword = (NERR_BASE+103); // The password parameter is invalid. + {$EXTERNALSYM NERR_BadPassword} + NERR_UnableToAddName_W = (NERR_BASE+104); // @W The logon processor did not add the message alias. + {$EXTERNALSYM NERR_UnableToAddName_W} + NERR_UnableToAddName_F = (NERR_BASE+105); // The logon processor did not add the message alias. + {$EXTERNALSYM NERR_UnableToAddName_F} + NERR_UnableToDelName_W = (NERR_BASE+106); // @W The logoff processor did not delete the message alias. + {$EXTERNALSYM NERR_UnableToDelName_W} + NERR_UnableToDelName_F = (NERR_BASE+107); // The logoff processor did not delete the message alias. + {$EXTERNALSYM NERR_UnableToDelName_F} +// UNUSED BASE+108 + NERR_LogonsPaused = (NERR_BASE+109); // Network logons are paused. + {$EXTERNALSYM NERR_LogonsPaused} + NERR_LogonServerConflict = (NERR_BASE+110); // A centralized logon-server conflict occurred. + {$EXTERNALSYM NERR_LogonServerConflict} + NERR_LogonNoUserPath = (NERR_BASE+111); // The server is configured without a valid user path. + {$EXTERNALSYM NERR_LogonNoUserPath} + NERR_LogonScriptError = (NERR_BASE+112); // An error occurred while loading or running the logon script. + {$EXTERNALSYM NERR_LogonScriptError} +// UNUSED BASE+113 + NERR_StandaloneLogon = (NERR_BASE+114); // The logon server was not specified. Your computer will be logged on as STANDALONE. + {$EXTERNALSYM NERR_StandaloneLogon} + NERR_LogonServerNotFound = (NERR_BASE+115); // The logon server could not be found. + {$EXTERNALSYM NERR_LogonServerNotFound} + NERR_LogonDomainExists = (NERR_BASE+116); // There is already a logon domain for this computer. + {$EXTERNALSYM NERR_LogonDomainExists} + NERR_NonValidatedLogon = (NERR_BASE+117); // The logon server could not validate the logon. + {$EXTERNALSYM NERR_NonValidatedLogon} + +// +// ACF API related (access, user, group) +// Error codes from BASE+119 to BASE+149 + + + NERR_ACFNotFound = (NERR_BASE+119); // The security database could not be found. + {$EXTERNALSYM NERR_ACFNotFound} + NERR_GroupNotFound = (NERR_BASE+120); // The group name could not be found. + {$EXTERNALSYM NERR_GroupNotFound} + NERR_UserNotFound = (NERR_BASE+121); // The user name could not be found. + {$EXTERNALSYM NERR_UserNotFound} + NERR_ResourceNotFound = (NERR_BASE+122); // The resource name could not be found. + {$EXTERNALSYM NERR_ResourceNotFound} + NERR_GroupExists = (NERR_BASE+123); // The group already exists. + {$EXTERNALSYM NERR_GroupExists} + NERR_UserExists = (NERR_BASE+124); // The account already exists. + {$EXTERNALSYM NERR_UserExists} + NERR_ResourceExists = (NERR_BASE+125); // The resource permission list already exists. + {$EXTERNALSYM NERR_ResourceExists} + NERR_NotPrimary = (NERR_BASE+126); // This operation is only allowed on the primary domain controller of the domain. + {$EXTERNALSYM NERR_NotPrimary} + NERR_ACFNotLoaded = (NERR_BASE+127); // The security database has not been started. + {$EXTERNALSYM NERR_ACFNotLoaded} + NERR_ACFNoRoom = (NERR_BASE+128); // There are too many names in the user accounts database. + {$EXTERNALSYM NERR_ACFNoRoom} + NERR_ACFFileIOFail = (NERR_BASE+129); // A disk I/O failure occurred. + {$EXTERNALSYM NERR_ACFFileIOFail} + NERR_ACFTooManyLists = (NERR_BASE+130); // The limit of 64 entries per resource was exceeded. + {$EXTERNALSYM NERR_ACFTooManyLists} + NERR_UserLogon = (NERR_BASE+131); // Deleting a user with a session is not allowed. + {$EXTERNALSYM NERR_UserLogon} + NERR_ACFNoParent = (NERR_BASE+132); // The parent directory could not be located. + {$EXTERNALSYM NERR_ACFNoParent} + NERR_CanNotGrowSegment = (NERR_BASE+133); // Unable to add to the security database session cache segment. + {$EXTERNALSYM NERR_CanNotGrowSegment} + NERR_SpeGroupOp = (NERR_BASE+134); // This operation is not allowed on this special group. + {$EXTERNALSYM NERR_SpeGroupOp} + NERR_NotInCache = (NERR_BASE+135); // This user is not cached in user accounts database session cache. + {$EXTERNALSYM NERR_NotInCache} + NERR_UserInGroup = (NERR_BASE+136); // The user already belongs to this group. + {$EXTERNALSYM NERR_UserInGroup} + NERR_UserNotInGroup = (NERR_BASE+137); // The user does not belong to this group. + {$EXTERNALSYM NERR_UserNotInGroup} + NERR_AccountUndefined = (NERR_BASE+138); // This user account is undefined. + {$EXTERNALSYM NERR_AccountUndefined} + NERR_AccountExpired = (NERR_BASE+139); // This user account has expired. + {$EXTERNALSYM NERR_AccountExpired} + NERR_InvalidWorkstation = (NERR_BASE+140); // The user is not allowed to log on from this workstation. + {$EXTERNALSYM NERR_InvalidWorkstation} + NERR_InvalidLogonHours = (NERR_BASE+141); // The user is not allowed to log on at this time. + {$EXTERNALSYM NERR_InvalidLogonHours} + NERR_PasswordExpired = (NERR_BASE+142); // The password of this user has expired. + {$EXTERNALSYM NERR_PasswordExpired} + NERR_PasswordCantChange = (NERR_BASE+143); // The password of this user cannot change. + {$EXTERNALSYM NERR_PasswordCantChange} + NERR_PasswordHistConflict = (NERR_BASE+144); // This password cannot be used now. + {$EXTERNALSYM NERR_PasswordHistConflict} + NERR_PasswordTooShort = (NERR_BASE+145); // The password does not meet the password policy requirements. Check the minimum password length, password complexity and password history requirements. + {$EXTERNALSYM NERR_PasswordTooShort} + NERR_PasswordTooRecent = (NERR_BASE+146); // The password of this user is too recent to change. + {$EXTERNALSYM NERR_PasswordTooRecent} + NERR_InvalidDatabase = (NERR_BASE+147); // The security database is corrupted. + {$EXTERNALSYM NERR_InvalidDatabase} + NERR_DatabaseUpToDate = (NERR_BASE+148); // No updates are necessary to this replicant network/local security database. + {$EXTERNALSYM NERR_DatabaseUpToDate} + NERR_SyncRequired = (NERR_BASE+149); // This replicant database is outdated; synchronization is required. + {$EXTERNALSYM NERR_SyncRequired} + +// +// Use API related +// Error codes from BASE+150 to BASE+169 + + + NERR_UseNotFound = (NERR_BASE+150); // The network connection could not be found. + {$EXTERNALSYM NERR_UseNotFound} + NERR_BadAsgType = (NERR_BASE+151); // This asg_type is invalid. + {$EXTERNALSYM NERR_BadAsgType} + NERR_DeviceIsShared = (NERR_BASE+152); // This device is currently being shared. + {$EXTERNALSYM NERR_DeviceIsShared} + +// +// Message Server related +// Error codes BASE+170 to BASE+209 + + + NERR_NoComputerName = (NERR_BASE+170); // The computer name could not be added as a message alias. The name may already exist on the network. + {$EXTERNALSYM NERR_NoComputerName} + NERR_MsgAlreadyStarted = (NERR_BASE+171); // The Messenger service is already started. + {$EXTERNALSYM NERR_MsgAlreadyStarted} + NERR_MsgInitFailed = (NERR_BASE+172); // The Messenger service failed to start. + {$EXTERNALSYM NERR_MsgInitFailed} + NERR_NameNotFound = (NERR_BASE+173); // The message alias could not be found on the network. + {$EXTERNALSYM NERR_NameNotFound} + NERR_AlreadyForwarded = (NERR_BASE+174); // This message alias has already been forwarded. + {$EXTERNALSYM NERR_AlreadyForwarded} + NERR_AddForwarded = (NERR_BASE+175); // This message alias has been added but is still forwarded. + {$EXTERNALSYM NERR_AddForwarded} + NERR_AlreadyExists = (NERR_BASE+176); // This message alias already exists locally. + {$EXTERNALSYM NERR_AlreadyExists} + NERR_TooManyNames = (NERR_BASE+177); // The maximum number of added message aliases has been exceeded. + {$EXTERNALSYM NERR_TooManyNames} + NERR_DelComputerName = (NERR_BASE+178); // The computer name could not be deleted. + {$EXTERNALSYM NERR_DelComputerName} + NERR_LocalForward = (NERR_BASE+179); // Messages cannot be forwarded back to the same workstation. + {$EXTERNALSYM NERR_LocalForward} + NERR_GrpMsgProcessor = (NERR_BASE+180); // An error occurred in the domain message processor. + {$EXTERNALSYM NERR_GrpMsgProcessor} + NERR_PausedRemote = (NERR_BASE+181); // The message was sent, but the recipient has paused the Messenger service. + {$EXTERNALSYM NERR_PausedRemote} + NERR_BadReceive = (NERR_BASE+182); // The message was sent but not received. + {$EXTERNALSYM NERR_BadReceive} + NERR_NameInUse = (NERR_BASE+183); // The message alias is currently in use. Try again later. + {$EXTERNALSYM NERR_NameInUse} + NERR_MsgNotStarted = (NERR_BASE+184); // The Messenger service has not been started. + {$EXTERNALSYM NERR_MsgNotStarted} + NERR_NotLocalName = (NERR_BASE+185); // The name is not on the local computer. + {$EXTERNALSYM NERR_NotLocalName} + NERR_NoForwardName = (NERR_BASE+186); // The forwarded message alias could not be found on the network. + {$EXTERNALSYM NERR_NoForwardName} + NERR_RemoteFull = (NERR_BASE+187); // The message alias table on the remote station is full. + {$EXTERNALSYM NERR_RemoteFull} + NERR_NameNotForwarded = (NERR_BASE+188); // Messages for this alias are not currently being forwarded. + {$EXTERNALSYM NERR_NameNotForwarded} + NERR_TruncatedBroadcast = (NERR_BASE+189); // The broadcast message was truncated. + {$EXTERNALSYM NERR_TruncatedBroadcast} + NERR_InvalidDevice = (NERR_BASE+194); // This is an invalid device name. + {$EXTERNALSYM NERR_InvalidDevice} + NERR_WriteFault = (NERR_BASE+195); // A write fault occurred. + {$EXTERNALSYM NERR_WriteFault} +// UNUSED BASE+196 + NERR_DuplicateName = (NERR_BASE+197); // A duplicate message alias exists on the network. + {$EXTERNALSYM NERR_DuplicateName} + NERR_DeleteLater = (NERR_BASE+198); // @W This message alias will be deleted later. + {$EXTERNALSYM NERR_DeleteLater} + NERR_IncompleteDel = (NERR_BASE+199); // The message alias was not successfully deleted from all networks. + {$EXTERNALSYM NERR_IncompleteDel} + NERR_MultipleNets = (NERR_BASE+200); // This operation is not supported on computers with multiple networks. + {$EXTERNALSYM NERR_MultipleNets} + +// +// Server API related +// Error codes BASE+210 to BASE+229 + + + NERR_NetNameNotFound = (NERR_BASE+210); // This shared resource does not exist. + {$EXTERNALSYM NERR_NetNameNotFound} + NERR_DeviceNotShared = (NERR_BASE+211); // This device is not shared. + {$EXTERNALSYM NERR_DeviceNotShared} + NERR_ClientNameNotFound = (NERR_BASE+212); // A session does not exist with that computer name. + {$EXTERNALSYM NERR_ClientNameNotFound} + NERR_FileIdNotFound = (NERR_BASE+214); // There is not an open file with that identification number. + {$EXTERNALSYM NERR_FileIdNotFound} + NERR_ExecFailure = (NERR_BASE+215); // A failure occurred when executing a remote administration command. + {$EXTERNALSYM NERR_ExecFailure} + NERR_TmpFile = (NERR_BASE+216); // A failure occurred when opening a remote temporary file. + {$EXTERNALSYM NERR_TmpFile} + NERR_TooMuchData = (NERR_BASE+217); // The data returned from a remote administration command has been truncated to 64K. + {$EXTERNALSYM NERR_TooMuchData} + NERR_DeviceShareConflict = (NERR_BASE+218); // This device cannot be shared as both a spooled and a non-spooled resource. + {$EXTERNALSYM NERR_DeviceShareConflict} + NERR_BrowserTableIncomplete = (NERR_BASE+219); // The information in the list of servers may be incorrect. + {$EXTERNALSYM NERR_BrowserTableIncomplete} + NERR_NotLocalDomain = (NERR_BASE+220); // The computer is not active in this domain. + {$EXTERNALSYM NERR_NotLocalDomain} + NERR_IsDfsShare = (NERR_BASE+221); // The share must be removed from the Distributed File System before it can be deleted. + {$EXTERNALSYM NERR_IsDfsShare} + +// +// CharDev API related +// Error codes BASE+230 to BASE+249 + + +// UNUSED BASE+230 + NERR_DevInvalidOpCode = (NERR_BASE+231); // The operation is invalid for this device. + {$EXTERNALSYM NERR_DevInvalidOpCode} + NERR_DevNotFound = (NERR_BASE+232); // This device cannot be shared. + {$EXTERNALSYM NERR_DevNotFound} + NERR_DevNotOpen = (NERR_BASE+233); // This device was not open. + {$EXTERNALSYM NERR_DevNotOpen} + NERR_BadQueueDevString = (NERR_BASE+234); // This device name list is invalid. + {$EXTERNALSYM NERR_BadQueueDevString} + NERR_BadQueuePriority = (NERR_BASE+235); // The queue priority is invalid. + {$EXTERNALSYM NERR_BadQueuePriority} + NERR_NoCommDevs = (NERR_BASE+237); // There are no shared communication devices. + {$EXTERNALSYM NERR_NoCommDevs} + NERR_QueueNotFound = (NERR_BASE+238); // The queue you specified does not exist. + {$EXTERNALSYM NERR_QueueNotFound} + NERR_BadDevString = (NERR_BASE+240); // This list of devices is invalid. + {$EXTERNALSYM NERR_BadDevString} + NERR_BadDev = (NERR_BASE+241); // The requested device is invalid. + {$EXTERNALSYM NERR_BadDev} + NERR_InUseBySpooler = (NERR_BASE+242); // This device is already in use by the spooler. + {$EXTERNALSYM NERR_InUseBySpooler} + NERR_CommDevInUse = (NERR_BASE+243); // This device is already in use as a communication device. + {$EXTERNALSYM NERR_CommDevInUse} + +// +// NetICanonicalize and NetIType and NetIMakeLMFileName +// NetIListCanon and NetINameCheck +// Error codes BASE+250 to BASE+269 + + + NERR_InvalidComputer = (NERR_BASE+251); // This computer name is invalid. + {$EXTERNALSYM NERR_InvalidComputer} +// UNUSED BASE+252 +// UNUSED BASE+253 + NERR_MaxLenExceeded = (NERR_BASE+254); // The string and prefix specified are too long. + {$EXTERNALSYM NERR_MaxLenExceeded} +// UNUSED BASE+255 + NERR_BadComponent = (NERR_BASE+256); // This path component is invalid. + {$EXTERNALSYM NERR_BadComponent} + NERR_CantType = (NERR_BASE+257); // Could not determine the type of input. + {$EXTERNALSYM NERR_CantType} +// UNUSED BASE+258 +// UNUSED BASE+259 + NERR_TooManyEntries = (NERR_BASE+262); // The buffer for types is not big enough. + {$EXTERNALSYM NERR_TooManyEntries} + +// +// NetProfile +// Error codes BASE+270 to BASE+276 + + + NERR_ProfileFileTooBig = (NERR_BASE+270); // Profile files cannot exceed 64K. + {$EXTERNALSYM NERR_ProfileFileTooBig} + NERR_ProfileOffset = (NERR_BASE+271); // The start offset is out of range. + {$EXTERNALSYM NERR_ProfileOffset} + NERR_ProfileCleanup = (NERR_BASE+272); // The system cannot delete current connections to network resources. + {$EXTERNALSYM NERR_ProfileCleanup} + NERR_ProfileUnknownCmd = (NERR_BASE+273); // The system was unable to parse the command line in this file. + {$EXTERNALSYM NERR_ProfileUnknownCmd} + NERR_ProfileLoadErr = (NERR_BASE+274); // An error occurred while loading the profile file. + {$EXTERNALSYM NERR_ProfileLoadErr} + NERR_ProfileSaveErr = (NERR_BASE+275); // @W Errors occurred while saving the profile file. The profile was partially saved. + {$EXTERNALSYM NERR_ProfileSaveErr} + + +// +// NetAudit and NetErrorLog +// Error codes BASE+277 to BASE+279 + + + NERR_LogOverflow = (NERR_BASE+277); // Log file %1 is full. + {$EXTERNALSYM NERR_LogOverflow} + NERR_LogFileChanged = (NERR_BASE+278); // This log file has changed between reads. + {$EXTERNALSYM NERR_LogFileChanged} + NERR_LogFileCorrupt = (NERR_BASE+279); // Log file %1 is corrupt. + {$EXTERNALSYM NERR_LogFileCorrupt} + + +// +// NetRemote +// Error codes BASE+280 to BASE+299 + + NERR_SourceIsDir = (NERR_BASE+280); // The source path cannot be a directory. + {$EXTERNALSYM NERR_SourceIsDir} + NERR_BadSource = (NERR_BASE+281); // The source path is illegal. + {$EXTERNALSYM NERR_BadSource} + NERR_BadDest = (NERR_BASE+282); // The destination path is illegal. + {$EXTERNALSYM NERR_BadDest} + NERR_DifferentServers = (NERR_BASE+283); // The source and destination paths are on different servers. + {$EXTERNALSYM NERR_DifferentServers} +// UNUSED BASE+284 + NERR_RunSrvPaused = (NERR_BASE+285); // The Run server you requested is paused. + {$EXTERNALSYM NERR_RunSrvPaused} +// UNUSED BASE+286 +// UNUSED BASE+287 +// UNUSED BASE+288 + NERR_ErrCommRunSrv = (NERR_BASE+289); // An error occurred when communicating with a Run server. + {$EXTERNALSYM NERR_ErrCommRunSrv} +// UNUSED BASE+290 + NERR_ErrorExecingGhost = (NERR_BASE+291); // An error occurred when starting a background process. + {$EXTERNALSYM NERR_ErrorExecingGhost} + NERR_ShareNotFound = (NERR_BASE+292); // The shared resource you are connected to could not be found. + {$EXTERNALSYM NERR_ShareNotFound} +// UNUSED BASE+293 +// UNUSED BASE+294 + + +// +// NetWksta.sys (redir) returned error codes. +// +// NERR_BASE + (300-329) + + + NERR_InvalidLana = (NERR_BASE+300); // The LAN adapter number is invalid. + {$EXTERNALSYM NERR_InvalidLana} + NERR_OpenFiles = (NERR_BASE+301); // There are open files on the connection. + {$EXTERNALSYM NERR_OpenFiles} + NERR_ActiveConns = (NERR_BASE+302); // Active connections still exist. + {$EXTERNALSYM NERR_ActiveConns} + NERR_BadPasswordCore = (NERR_BASE+303); // This share name or password is invalid. + {$EXTERNALSYM NERR_BadPasswordCore} + NERR_DevInUse = (NERR_BASE+304); // The device is being accessed by an active process. + {$EXTERNALSYM NERR_DevInUse} + NERR_LocalDrive = (NERR_BASE+305); // The drive letter is in use locally. + {$EXTERNALSYM NERR_LocalDrive} + +// +// Alert error codes. +// +// NERR_BASE + (330-339) + + NERR_AlertExists = (NERR_BASE+330); // The specified client is already registered for the specified event. + {$EXTERNALSYM NERR_AlertExists} + NERR_TooManyAlerts = (NERR_BASE+331); // The alert table is full. + {$EXTERNALSYM NERR_TooManyAlerts} + NERR_NoSuchAlert = (NERR_BASE+332); // An invalid or nonexistent alert name was raised. + {$EXTERNALSYM NERR_NoSuchAlert} + NERR_BadRecipient = (NERR_BASE+333); // The alert recipient is invalid. + {$EXTERNALSYM NERR_BadRecipient} + NERR_AcctLimitExceeded = (NERR_BASE+334); // A user's session with this server has been deleted + {$EXTERNALSYM NERR_AcctLimitExceeded} + // because the user's logon hours are no longer valid. + +// +// Additional Error and Audit log codes. +// +// NERR_BASE +(340-343) + + NERR_InvalidLogSeek = (NERR_BASE+340); // The log file does not contain the requested record number. + {$EXTERNALSYM NERR_InvalidLogSeek} +// UNUSED BASE+341 +// UNUSED BASE+342 +// UNUSED BASE+343 + +// +// Additional UAS and NETLOGON codes +// +// NERR_BASE +(350-359) + + NERR_BadUasConfig = (NERR_BASE+350); // The user accounts database is not configured correctly. + {$EXTERNALSYM NERR_BadUasConfig} + NERR_InvalidUASOp = (NERR_BASE+351); // This operation is not permitted when the Netlogon service is running. + {$EXTERNALSYM NERR_InvalidUASOp} + NERR_LastAdmin = (NERR_BASE+352); // This operation is not allowed on the last administrative account. + {$EXTERNALSYM NERR_LastAdmin} + NERR_DCNotFound = (NERR_BASE+353); // Could not find domain controller for this domain. + {$EXTERNALSYM NERR_DCNotFound} + NERR_LogonTrackingError = (NERR_BASE+354); // Could not set logon information for this user. + {$EXTERNALSYM NERR_LogonTrackingError} + NERR_NetlogonNotStarted = (NERR_BASE+355); // The Netlogon service has not been started. + {$EXTERNALSYM NERR_NetlogonNotStarted} + NERR_CanNotGrowUASFile = (NERR_BASE+356); // Unable to add to the user accounts database. + {$EXTERNALSYM NERR_CanNotGrowUASFile} + NERR_TimeDiffAtDC = (NERR_BASE+357); // This server's clock is not synchronized with the primary domain controller's clock. + {$EXTERNALSYM NERR_TimeDiffAtDC} + NERR_PasswordMismatch = (NERR_BASE+358); // A password mismatch has been detected. + {$EXTERNALSYM NERR_PasswordMismatch} + + +// +// Server Integration error codes. +// +// NERR_BASE +(360-369) + + NERR_NoSuchServer = (NERR_BASE+360); // The server identification does not specify a valid server. + {$EXTERNALSYM NERR_NoSuchServer} + NERR_NoSuchSession = (NERR_BASE+361); // The session identification does not specify a valid session. + {$EXTERNALSYM NERR_NoSuchSession} + NERR_NoSuchConnection = (NERR_BASE+362); // The connection identification does not specify a valid connection. + {$EXTERNALSYM NERR_NoSuchConnection} + NERR_TooManyServers = (NERR_BASE+363); // There is no space for another entry in the table of available servers. + {$EXTERNALSYM NERR_TooManyServers} + NERR_TooManySessions = (NERR_BASE+364); // The server has reached the maximum number of sessions it supports. + {$EXTERNALSYM NERR_TooManySessions} + NERR_TooManyConnections = (NERR_BASE+365); // The server has reached the maximum number of connections it supports. + {$EXTERNALSYM NERR_TooManyConnections} + NERR_TooManyFiles = (NERR_BASE+366); // The server cannot open more files because it has reached its maximum number. + {$EXTERNALSYM NERR_TooManyFiles} + NERR_NoAlternateServers = (NERR_BASE+367); // There are no alternate servers registered on this server. + {$EXTERNALSYM NERR_NoAlternateServers} +// UNUSED BASE+368 +// UNUSED BASE+369 + + NERR_TryDownLevel = (NERR_BASE+370); // Try down-level (remote admin protocol) version of API instead. + {$EXTERNALSYM NERR_TryDownLevel} + +// +// UPS error codes. +// +// NERR_BASE + (380-384) + + NERR_UPSDriverNotStarted = (NERR_BASE+380); // The UPS driver could not be accessed by the UPS service. + {$EXTERNALSYM NERR_UPSDriverNotStarted} + NERR_UPSInvalidConfig = (NERR_BASE+381); // The UPS service is not configured correctly. + {$EXTERNALSYM NERR_UPSInvalidConfig} + NERR_UPSInvalidCommPort = (NERR_BASE+382); // The UPS service could not access the specified Comm Port. + {$EXTERNALSYM NERR_UPSInvalidCommPort} + NERR_UPSSignalAsserted = (NERR_BASE+383); // The UPS indicated a line fail or low battery situation. Service not started. + {$EXTERNALSYM NERR_UPSSignalAsserted} + NERR_UPSShutdownFailed = (NERR_BASE+384); // The UPS service failed to perform a system shut down. + {$EXTERNALSYM NERR_UPSShutdownFailed} + +// +// Remoteboot error codes. +// +// NERR_BASE + (400-419) +// Error codes 400 - 405 are used by RPLBOOT.SYS. +// Error codes 403, 407 - 416 are used by RPLLOADR.COM, +// Error code 417 is the alerter message of REMOTEBOOT (RPLSERVR.EXE). +// Error code 418 is for when REMOTEBOOT can't start +// Error code 419 is for a disallowed 2nd rpl connection +// + + NERR_BadDosRetCode = (NERR_BASE+400); // The program below returned an MS-DOS error code: + {$EXTERNALSYM NERR_BadDosRetCode} + NERR_ProgNeedsExtraMem = (NERR_BASE+401); // The program below needs more memory: + {$EXTERNALSYM NERR_ProgNeedsExtraMem} + NERR_BadDosFunction = (NERR_BASE+402); // The program below called an unsupported MS-DOS function: + {$EXTERNALSYM NERR_BadDosFunction} + NERR_RemoteBootFailed = (NERR_BASE+403); // The workstation failed to boot. + {$EXTERNALSYM NERR_RemoteBootFailed} + NERR_BadFileCheckSum = (NERR_BASE+404); // The file below is corrupt. + {$EXTERNALSYM NERR_BadFileCheckSum} + NERR_NoRplBootSystem = (NERR_BASE+405); // No loader is specified in the boot-block definition file. + {$EXTERNALSYM NERR_NoRplBootSystem} + NERR_RplLoadrNetBiosErr = (NERR_BASE+406); // NetBIOS returned an error: The NCB and SMB are dumped above. + {$EXTERNALSYM NERR_RplLoadrNetBiosErr} + NERR_RplLoadrDiskErr = (NERR_BASE+407); // A disk I/O error occurred. + {$EXTERNALSYM NERR_RplLoadrDiskErr} + NERR_ImageParamErr = (NERR_BASE+408); // Image parameter substitution failed. + {$EXTERNALSYM NERR_ImageParamErr} + NERR_TooManyImageParams = (NERR_BASE+409); // Too many image parameters cross disk sector boundaries. + {$EXTERNALSYM NERR_TooManyImageParams} + NERR_NonDosFloppyUsed = (NERR_BASE+410); // The image was not generated from an MS-DOS diskette formatted with /S. + {$EXTERNALSYM NERR_NonDosFloppyUsed} + NERR_RplBootRestart = (NERR_BASE+411); // Remote boot will be restarted later. + {$EXTERNALSYM NERR_RplBootRestart} + NERR_RplSrvrCallFailed = (NERR_BASE+412); // The call to the Remoteboot server failed. + {$EXTERNALSYM NERR_RplSrvrCallFailed} + NERR_CantConnectRplSrvr = (NERR_BASE+413); // Cannot connect to the Remoteboot server. + {$EXTERNALSYM NERR_CantConnectRplSrvr} + NERR_CantOpenImageFile = (NERR_BASE+414); // Cannot open image file on the Remoteboot server. + {$EXTERNALSYM NERR_CantOpenImageFile} + NERR_CallingRplSrvr = (NERR_BASE+415); // Connecting to the Remoteboot server... + {$EXTERNALSYM NERR_CallingRplSrvr} + NERR_StartingRplBoot = (NERR_BASE+416); // Connecting to the Remoteboot server... + {$EXTERNALSYM NERR_StartingRplBoot} + NERR_RplBootServiceTerm = (NERR_BASE+417); // Remote boot service was stopped; check the error log for the cause of the problem. + {$EXTERNALSYM NERR_RplBootServiceTerm} + NERR_RplBootStartFailed = (NERR_BASE+418); // Remote boot startup failed; check the error log for the cause of the problem. + {$EXTERNALSYM NERR_RplBootStartFailed} + NERR_RPL_CONNECTED = (NERR_BASE+419); // A second connection to a Remoteboot resource is not allowed. + {$EXTERNALSYM NERR_RPL_CONNECTED} + +// +// FTADMIN API error codes +// +// NERR_BASE + (425-434) +// +// (Currently not used in NT) +// + + +// +// Browser service API error codes +// +// NERR_BASE + (450-475) +// + + NERR_BrowserConfiguredToNotRun = (NERR_BASE+450); // The browser service was configured with MaintainServerList=No. + {$EXTERNALSYM NERR_BrowserConfiguredToNotRun} + +// +// Additional Remoteboot error codes. +// +// NERR_BASE + (510-550) + + NERR_RplNoAdaptersStarted = (NERR_BASE+510); // Service failed to start since none of the network adapters started with this service. + {$EXTERNALSYM NERR_RplNoAdaptersStarted} + NERR_RplBadRegistry = (NERR_BASE+511); // Service failed to start due to bad startup information in the registry. + {$EXTERNALSYM NERR_RplBadRegistry} + NERR_RplBadDatabase = (NERR_BASE+512); // Service failed to start because its database is absent or corrupt. + {$EXTERNALSYM NERR_RplBadDatabase} + NERR_RplRplfilesShare = (NERR_BASE+513); // Service failed to start because RPLFILES share is absent. + {$EXTERNALSYM NERR_RplRplfilesShare} + NERR_RplNotRplServer = (NERR_BASE+514); // Service failed to start because RPLUSER group is absent. + {$EXTERNALSYM NERR_RplNotRplServer} + NERR_RplCannotEnum = (NERR_BASE+515); // Cannot enumerate service records. + {$EXTERNALSYM NERR_RplCannotEnum} + NERR_RplWkstaInfoCorrupted = (NERR_BASE+516); // Workstation record information has been corrupted. + {$EXTERNALSYM NERR_RplWkstaInfoCorrupted} + NERR_RplWkstaNotFound = (NERR_BASE+517); // Workstation record was not found. + {$EXTERNALSYM NERR_RplWkstaNotFound} + NERR_RplWkstaNameUnavailable = (NERR_BASE+518); // Workstation name is in use by some other workstation. + {$EXTERNALSYM NERR_RplWkstaNameUnavailable} + NERR_RplProfileInfoCorrupted = (NERR_BASE+519); // Profile record information has been corrupted. + {$EXTERNALSYM NERR_RplProfileInfoCorrupted} + NERR_RplProfileNotFound = (NERR_BASE+520); // Profile record was not found. + {$EXTERNALSYM NERR_RplProfileNotFound} + NERR_RplProfileNameUnavailable = (NERR_BASE+521); // Profile name is in use by some other profile. + {$EXTERNALSYM NERR_RplProfileNameUnavailable} + NERR_RplProfileNotEmpty = (NERR_BASE+522); // There are workstations using this profile. + {$EXTERNALSYM NERR_RplProfileNotEmpty} + NERR_RplConfigInfoCorrupted = (NERR_BASE+523); // Configuration record information has been corrupted. + {$EXTERNALSYM NERR_RplConfigInfoCorrupted} + NERR_RplConfigNotFound = (NERR_BASE+524); // Configuration record was not found. + {$EXTERNALSYM NERR_RplConfigNotFound} + NERR_RplAdapterInfoCorrupted = (NERR_BASE+525); // Adapter id record information has been corrupted. + {$EXTERNALSYM NERR_RplAdapterInfoCorrupted} + NERR_RplInternal = (NERR_BASE+526); // An internal service error has occurred. + {$EXTERNALSYM NERR_RplInternal} + NERR_RplVendorInfoCorrupted = (NERR_BASE+527); // Vendor id record information has been corrupted. + {$EXTERNALSYM NERR_RplVendorInfoCorrupted} + NERR_RplBootInfoCorrupted = (NERR_BASE+528); // Boot block record information has been corrupted. + {$EXTERNALSYM NERR_RplBootInfoCorrupted} + NERR_RplWkstaNeedsUserAcct = (NERR_BASE+529); // The user account for this workstation record is missing. + {$EXTERNALSYM NERR_RplWkstaNeedsUserAcct} + NERR_RplNeedsRPLUSERAcct = (NERR_BASE+530); // The RPLUSER local group could not be found. + {$EXTERNALSYM NERR_RplNeedsRPLUSERAcct} + NERR_RplBootNotFound = (NERR_BASE+531); // Boot block record was not found. + {$EXTERNALSYM NERR_RplBootNotFound} + NERR_RplIncompatibleProfile = (NERR_BASE+532); // Chosen profile is incompatible with this workstation. + {$EXTERNALSYM NERR_RplIncompatibleProfile} + NERR_RplAdapterNameUnavailable = (NERR_BASE+533); // Chosen network adapter id is in use by some other workstation. + {$EXTERNALSYM NERR_RplAdapterNameUnavailable} + NERR_RplConfigNotEmpty = (NERR_BASE+534); // There are profiles using this configuration. + {$EXTERNALSYM NERR_RplConfigNotEmpty} + NERR_RplBootInUse = (NERR_BASE+535); // There are workstations, profiles or configurations using this boot block. + {$EXTERNALSYM NERR_RplBootInUse} + NERR_RplBackupDatabase = (NERR_BASE+536); // Service failed to backup Remoteboot database. + {$EXTERNALSYM NERR_RplBackupDatabase} + NERR_RplAdapterNotFound = (NERR_BASE+537); // Adapter record was not found. + {$EXTERNALSYM NERR_RplAdapterNotFound} + NERR_RplVendorNotFound = (NERR_BASE+538); // Vendor record was not found. + {$EXTERNALSYM NERR_RplVendorNotFound} + NERR_RplVendorNameUnavailable = (NERR_BASE+539); // Vendor name is in use by some other vendor record. + {$EXTERNALSYM NERR_RplVendorNameUnavailable} + NERR_RplBootNameUnavailable = (NERR_BASE+540); // (boot name, vendor id) is in use by some other boot block record. + {$EXTERNALSYM NERR_RplBootNameUnavailable} + NERR_RplConfigNameUnavailable = (NERR_BASE+541); // Configuration name is in use by some other configuration. + {$EXTERNALSYM NERR_RplConfigNameUnavailable} + +//*INTERNAL_ONLY* + +// +// Dfs API error codes. +// +// NERR_BASE + (560-590) + + + NERR_DfsInternalCorruption = (NERR_BASE+560); // The internal database maintained by the DFS service is corrupt + {$EXTERNALSYM NERR_DfsInternalCorruption} + NERR_DfsVolumeDataCorrupt = (NERR_BASE+561); // One of the records in the internal DFS database is corrupt + {$EXTERNALSYM NERR_DfsVolumeDataCorrupt} + NERR_DfsNoSuchVolume = (NERR_BASE+562); // There is no DFS name whose entry path matches the input Entry Path + {$EXTERNALSYM NERR_DfsNoSuchVolume} + NERR_DfsVolumeAlreadyExists = (NERR_BASE+563); // A root or link with the given name already exists + {$EXTERNALSYM NERR_DfsVolumeAlreadyExists} + NERR_DfsAlreadyShared = (NERR_BASE+564); // The server share specified is already shared in the DFS + {$EXTERNALSYM NERR_DfsAlreadyShared} + NERR_DfsNoSuchShare = (NERR_BASE+565); // The indicated server share does not support the indicated DFS namespace + {$EXTERNALSYM NERR_DfsNoSuchShare} + NERR_DfsNotALeafVolume = (NERR_BASE+566); // The operation is not valid on this portion of the namespace + {$EXTERNALSYM NERR_DfsNotALeafVolume} + NERR_DfsLeafVolume = (NERR_BASE+567); // The operation is not valid on this portion of the namespace + {$EXTERNALSYM NERR_DfsLeafVolume} + NERR_DfsVolumeHasMultipleServers = (NERR_BASE+568); // The operation is ambiguous because the link has multiple servers + {$EXTERNALSYM NERR_DfsVolumeHasMultipleServers} + NERR_DfsCantCreateJunctionPoint = (NERR_BASE+569); // Unable to create a link + {$EXTERNALSYM NERR_DfsCantCreateJunctionPoint} + NERR_DfsServerNotDfsAware = (NERR_BASE+570); // The server is not DFS Aware + {$EXTERNALSYM NERR_DfsServerNotDfsAware} + NERR_DfsBadRenamePath = (NERR_BASE+571); // The specified rename target path is invalid + {$EXTERNALSYM NERR_DfsBadRenamePath} + NERR_DfsVolumeIsOffline = (NERR_BASE+572); // The specified DFS link is offline + {$EXTERNALSYM NERR_DfsVolumeIsOffline} + NERR_DfsNoSuchServer = (NERR_BASE+573); // The specified server is not a server for this link + {$EXTERNALSYM NERR_DfsNoSuchServer} + NERR_DfsCyclicalName = (NERR_BASE+574); // A cycle in the DFS name was detected + {$EXTERNALSYM NERR_DfsCyclicalName} + NERR_DfsNotSupportedInServerDfs = (NERR_BASE+575); // The operation is not supported on a server-based DFS + {$EXTERNALSYM NERR_DfsNotSupportedInServerDfs} + NERR_DfsDuplicateService = (NERR_BASE+576); // This link is already supported by the specified server-share + {$EXTERNALSYM NERR_DfsDuplicateService} + NERR_DfsCantRemoveLastServerShare = (NERR_BASE+577); // Can't remove the last server-share supporting this root or link + {$EXTERNALSYM NERR_DfsCantRemoveLastServerShare} + NERR_DfsVolumeIsInterDfs = (NERR_BASE+578); // The operation is not supported for an Inter-DFS link + {$EXTERNALSYM NERR_DfsVolumeIsInterDfs} + NERR_DfsInconsistent = (NERR_BASE+579); // The internal state of the DFS Service has become inconsistent + {$EXTERNALSYM NERR_DfsInconsistent} + NERR_DfsServerUpgraded = (NERR_BASE+580); // The DFS Service has been installed on the specified server + {$EXTERNALSYM NERR_DfsServerUpgraded} + NERR_DfsDataIsIdentical = (NERR_BASE+581); // The DFS data being reconciled is identical + {$EXTERNALSYM NERR_DfsDataIsIdentical} + NERR_DfsCantRemoveDfsRoot = (NERR_BASE+582); // The DFS root cannot be deleted - Uninstall DFS if required + {$EXTERNALSYM NERR_DfsCantRemoveDfsRoot} + NERR_DfsChildOrParentInDfs = (NERR_BASE+583); // A child or parent directory of the share is already in a DFS + {$EXTERNALSYM NERR_DfsChildOrParentInDfs} + NERR_DfsInternalError = (NERR_BASE+590); // DFS internal error + {$EXTERNALSYM NERR_DfsInternalError} + +// +// Net setup error codes. +// +// NERR_BASE + (591-600) + + NERR_SetupAlreadyJoined = (NERR_BASE+591); // This machine is already joined to a domain. + {$EXTERNALSYM NERR_SetupAlreadyJoined} + NERR_SetupNotJoined = (NERR_BASE+592); // This machine is not currently joined to a domain. + {$EXTERNALSYM NERR_SetupNotJoined} + NERR_SetupDomainController = (NERR_BASE+593); // This machine is a domain controller and cannot be unjoined from a domain. + {$EXTERNALSYM NERR_SetupDomainController} + NERR_DefaultJoinRequired = (NERR_BASE+594); // The destination domain controller does not support creating machine accounts in OUs. + {$EXTERNALSYM NERR_DefaultJoinRequired} + NERR_InvalidWorkgroupName = (NERR_BASE+595); // The specified workgroup name is invalid. + {$EXTERNALSYM NERR_InvalidWorkgroupName} + NERR_NameUsesIncompatibleCodePage = (NERR_BASE+596); // The specified computer name is incompatible with the default language used on the domain controller. + {$EXTERNALSYM NERR_NameUsesIncompatibleCodePage} + NERR_ComputerAccountNotFound = (NERR_BASE+597); // The specified computer account could not be found. + {$EXTERNALSYM NERR_ComputerAccountNotFound} + NERR_PersonalSku = (NERR_BASE+598); // This version of Windows cannot be joined to a domain. + {$EXTERNALSYM NERR_PersonalSku} + +// +// Some Password and account error results +// +// NERR_BASE + (601 - 608) +// + + NERR_PasswordMustChange = (NERR_BASE + 601); // Password must change at next logon + {$EXTERNALSYM NERR_PasswordMustChange} + NERR_AccountLockedOut = (NERR_BASE + 602); // Account is locked out + {$EXTERNALSYM NERR_AccountLockedOut} + NERR_PasswordTooLong = (NERR_BASE + 603); // Password is too long + {$EXTERNALSYM NERR_PasswordTooLong} + NERR_PasswordNotComplexEnough = (NERR_BASE + 604); // Password doesn't meet the complexity policy + {$EXTERNALSYM NERR_PasswordNotComplexEnough} + NERR_PasswordFilterError = (NERR_BASE + 605); // Password doesn't meet the requirements of the filter dll's + {$EXTERNALSYM NERR_PasswordFilterError} + +//**********WARNING **************** +//The range 2750-2799 has been * +//allocated to the IBM LAN Server * +//********************************* + +//**********WARNING **************** +//The range 2900-2999 has been * +//reserved for Microsoft OEMs * +//********************************* + +//*END_INTERNAL* + + MAX_NERR = (NERR_BASE+899); // This is the last error in NERR range. + {$EXTERNALSYM MAX_NERR} + +// +// end of list +// +// WARNING: Do not exceed MAX_NERR; values above this are used by +// other error code ranges (errlog.h, service.h, apperr.h). + +// JwaLmCons, complete +// LAN Manager common definitions + +const + NetApi32 = 'netapi32.dll'; + +// +// NOTE: Lengths of strings are given as the maximum lengths of the +// string in characters (not bytes). This does not include space for the +// terminating 0-characters. When allocating space for such an item, +// use the form: +// +// TCHAR username[UNLEN+1]; +// +// Definitions of the form LN20_* define those values in effect for +// LanMan 2.0. +// + +// +// String Lengths for various LanMan names +// + +const + CNLEN = 15; // Computer name length + {$EXTERNALSYM CNLEN} + LM20_CNLEN = 15; // LM 2.0 Computer name length + {$EXTERNALSYM LM20_CNLEN} + DNLEN = CNLEN; // Maximum domain name length + {$EXTERNALSYM DNLEN} + LM20_DNLEN = LM20_CNLEN; // LM 2.0 Maximum domain name length + {$EXTERNALSYM LM20_DNLEN} + +//#if (CNLEN != DNLEN) +//#error CNLEN and DNLEN are not equal +//#endif + + UNCLEN = (CNLEN+2); // UNC computer name length + {$EXTERNALSYM UNCLEN} + LM20_UNCLEN = (LM20_CNLEN+2); // LM 2.0 UNC computer name length + {$EXTERNALSYM LM20_UNCLEN} + + NNLEN = 80; // Net name length (share name) + {$EXTERNALSYM NNLEN} + LM20_NNLEN = 12; // LM 2.0 Net name length + {$EXTERNALSYM LM20_NNLEN} + + RMLEN = (UNCLEN+1+NNLEN); // Max remote name length + {$EXTERNALSYM RMLEN} + LM20_RMLEN = (LM20_UNCLEN+1+LM20_NNLEN); // LM 2.0 Max remote name length + {$EXTERNALSYM LM20_RMLEN} + + SNLEN = 80; // Service name length + {$EXTERNALSYM SNLEN} + LM20_SNLEN = 15; // LM 2.0 Service name length + {$EXTERNALSYM LM20_SNLEN} + STXTLEN = 256; // Service text length + {$EXTERNALSYM STXTLEN} + LM20_STXTLEN = 63; // LM 2.0 Service text length + {$EXTERNALSYM LM20_STXTLEN} + + PATHLEN = 256; // Max. path (not including drive name) + {$EXTERNALSYM PATHLEN} + LM20_PATHLEN = 256; // LM 2.0 Max. path + {$EXTERNALSYM LM20_PATHLEN} + + DEVLEN = 80; // Device name length + {$EXTERNALSYM DEVLEN} + LM20_DEVLEN = 8; // LM 2.0 Device name length + {$EXTERNALSYM LM20_DEVLEN} + + EVLEN = 16; // Event name length + {$EXTERNALSYM EVLEN} + +// +// User, Group and Password lengths +// + + UNLEN = 256; // Maximum user name length + {$EXTERNALSYM UNLEN} + LM20_UNLEN = 20; // LM 2.0 Maximum user name length + {$EXTERNALSYM LM20_UNLEN} + + GNLEN = UNLEN; // Group name + {$EXTERNALSYM GNLEN} + LM20_GNLEN = LM20_UNLEN; // LM 2.0 Group name + {$EXTERNALSYM LM20_GNLEN} + + PWLEN = 256; // Maximum password length + {$EXTERNALSYM PWLEN} + LM20_PWLEN = 14; // LM 2.0 Maximum password length + {$EXTERNALSYM LM20_PWLEN} + + SHPWLEN = 8; // Share password length (bytes) + {$EXTERNALSYM SHPWLEN} + + CLTYPE_LEN = 12; // Length of client type string + {$EXTERNALSYM CLTYPE_LEN} + + MAXCOMMENTSZ = 256; // Multipurpose comment length + {$EXTERNALSYM MAXCOMMENTSZ} + LM20_MAXCOMMENTSZ = 48; // LM 2.0 Multipurpose comment length + {$EXTERNALSYM LM20_MAXCOMMENTSZ} + + QNLEN = NNLEN; // Queue name maximum length + {$EXTERNALSYM QNLEN} + LM20_QNLEN = LM20_NNLEN; // LM 2.0 Queue name maximum length + {$EXTERNALSYM LM20_QNLEN} + +//#if (QNLEN != NNLEN) +//# error QNLEN and NNLEN are not equal +//#endif + +// +// The ALERTSZ and MAXDEVENTRIES defines have not yet been NT'ized. +// Whoever ports these components should change these values appropriately. +// + + ALERTSZ = 128; // size of alert string in server + {$EXTERNALSYM ALERTSZ} + MAXDEVENTRIES = (SizeOf(Integer)*8); // Max number of device entries + {$EXTERNALSYM MAXDEVENTRIES} + + // + // We use int bitmap to represent + // + + NETBIOS_NAME_LEN = 16; // NetBIOS net name (bytes) + {$EXTERNALSYM NETBIOS_NAME_LEN} + +// +// Value to be used with APIs which have a "preferred maximum length" +// parameter. This value indicates that the API should just allocate +// "as much as it takes." +// + + MAX_PREFERRED_LENGTH = DWORD(-1); + {$EXTERNALSYM MAX_PREFERRED_LENGTH} + +// +// Constants used with encryption +// + + CRYPT_KEY_LEN = 7; + {$EXTERNALSYM CRYPT_KEY_LEN} + CRYPT_TXT_LEN = 8; + {$EXTERNALSYM CRYPT_TXT_LEN} + ENCRYPTED_PWLEN = 16; + {$EXTERNALSYM ENCRYPTED_PWLEN} + SESSION_PWLEN = 24; + {$EXTERNALSYM SESSION_PWLEN} + SESSION_CRYPT_KLEN = 21; + {$EXTERNALSYM SESSION_CRYPT_KLEN} + +// +// Value to be used with SetInfo calls to allow setting of all +// settable parameters (parmnum zero option) +// + + PARMNUM_ALL = 0; + {$EXTERNALSYM PARMNUM_ALL} + + PARM_ERROR_UNKNOWN = DWORD(-1); + {$EXTERNALSYM PARM_ERROR_UNKNOWN} + PARM_ERROR_NONE = 0; + {$EXTERNALSYM PARM_ERROR_NONE} + PARMNUM_BASE_INFOLEVEL = 1000; + {$EXTERNALSYM PARMNUM_BASE_INFOLEVEL} + +// +// Only the UNICODE version of the LM APIs are available on NT. +// Non-UNICODE version on other platforms +// + +//#if defined( _WIN32_WINNT ) || defined( WINNT ) || defined( FORCE_UNICODE ) + +{$IFDEF _WIN32_WINNT} +{$DEFINE LM_USE_UNICODE} +{$ENDIF} + +{$IFDEF FORCE_UNICODE} +{$DEFINE LM_USE_UNICODE} +{$ENDIF} + +{$IFDEF LM_USE_UNICODE} + +type + LMSTR = LPWSTR; + {$EXTERNALSYM LMSTR} + LMCSTR = LPCWSTR; + {$EXTERNALSYM LMCSTR} + PLMSTR = ^LMSTR; + {$NODEFINE PLMSTR} + +{$ELSE ~LM_USE_UNICODE} + +type + LMSTR = LPSTR; + {$EXTERNALSYM LMSTR} + LMCSTR = LPCSTR; + {$EXTERNALSYM LMCSTR} + +{$ENDIF ~LM_USE_UNICODE} + +// +// Message File Names +// + +const + MESSAGE_FILENAME = 'NETMSG'; + {$EXTERNALSYM MESSAGE_FILENAME} + OS2MSG_FILENAME = 'BASE'; + {$EXTERNALSYM OS2MSG_FILENAME} + HELP_MSG_FILENAME = 'NETH'; + {$EXTERNALSYM HELP_MSG_FILENAME} + +// ** INTERNAL_ONLY ** + +// The backup message file named here is a duplicate of net.msg. It +// is not shipped with the product, but is used at buildtime to +// msgbind certain messages to netapi.dll and some of the services. +// This allows for OEMs to modify the message text in net.msg and +// have those changes show up. Only in case there is an error in +// retrieving the messages from net.msg do we then get the bound +// messages out of bak.msg (really out of the message segment). + + BACKUP_MSG_FILENAME = 'BAK.MSG'; + {$EXTERNALSYM BACKUP_MSG_FILENAME} + +// ** END_INTERNAL ** + +// +// Keywords used in Function Prototypes +// + +type + NET_API_STATUS = DWORD; + {$EXTERNALSYM NET_API_STATUS} + TNetApiStatus = NET_API_STATUS; + +// +// The platform ID indicates the levels to use for platform-specific +// information. +// + +const + PLATFORM_ID_DOS = 300; + {$EXTERNALSYM PLATFORM_ID_DOS} + PLATFORM_ID_OS2 = 400; + {$EXTERNALSYM PLATFORM_ID_OS2} + PLATFORM_ID_NT = 500; + {$EXTERNALSYM PLATFORM_ID_NT} + PLATFORM_ID_OSF = 600; + {$EXTERNALSYM PLATFORM_ID_OSF} + PLATFORM_ID_VMS = 700; + {$EXTERNALSYM PLATFORM_ID_VMS} + +// +// There message numbers assigned to different LANMAN components +// are as defined below. +// +// lmerr.h: 2100 - 2999 NERR_BASE +// alertmsg.h: 3000 - 3049 ALERT_BASE +// lmsvc.h: 3050 - 3099 SERVICE_BASE +// lmerrlog.h: 3100 - 3299 ERRLOG_BASE +// msgtext.h: 3300 - 3499 MTXT_BASE +// apperr.h: 3500 - 3999 APPERR_BASE +// apperrfs.h: 4000 - 4299 APPERRFS_BASE +// apperr2.h: 4300 - 5299 APPERR2_BASE +// ncberr.h: 5300 - 5499 NRCERR_BASE +// alertmsg.h: 5500 - 5599 ALERT2_BASE +// lmsvc.h: 5600 - 5699 SERVICE2_BASE +// lmerrlog.h 5700 - 5899 ERRLOG2_BASE +// + + MIN_LANMAN_MESSAGE_ID = NERR_BASE; + {$EXTERNALSYM MIN_LANMAN_MESSAGE_ID} + MAX_LANMAN_MESSAGE_ID = 5899; + {$EXTERNALSYM MAX_LANMAN_MESSAGE_ID} + +// line 59 + +// +// Function Prototypes - User +// + + +function NetUserAdd(servername: LPCWSTR; level: DWORD; buf: PByte; parm_err: LPDWORD): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetUserAdd} + +function NetUserEnum(servername: LPCWSTR; level, filter: DWORD; var bufptr: PByte; prefmaxlen: DWORD; entriesread, totalentries, resume_handle: LPDWORD): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetUserEnum} + +function NetUserGetInfo(servername, username: LPCWSTR; level: DWORD; var bufptr: PByte): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetUserGetInfo} + +function NetUserSetInfo(servername, username: LPCWSTR; level: DWORD; buf: PByte; parm_err: LPDWORD): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetUserSetInfo} + +function NetUserDel(servername: LPCWSTR; username: LPCWSTR): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetUserDel} + +function NetUserGetGroups(servername, username: LPCWSTR; level: DWORD; var bufptr: PByte; prefmaxlen: DWORD; entriesread, totalentries: LPDWORD): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetUserGetGroups} + +function NetUserSetGroups(servername, username: LPCWSTR; level: DWORD; buf: PByte; num_entries: DWORD): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetUserSetGroups} + +function NetUserGetLocalGroups(servername, username: LPCWSTR; level, flags: DWORD; var bufptr: PByte; prefmaxlen: DWORD; entriesread, totalentries: LPDWORD): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetUserGetLocalGroups} + +function NetUserModalsGet(servername: LPCWSTR; level: DWORD; var bufptr: PByte): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetUserModalsGet} + +function NetUserModalsSet(servername: LPCWSTR; level: DWORD; buf: PByte; parm_err: LPDWORD): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetUserModalsSet} + +function NetUserChangePassword(domainname, username, oldpassword, newpassword: LPCWSTR): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetUserChangePassword} + + +// +// Data Structures - User +// + +type + {$IFNDEF FPC} + LPUSER_INFO_0 = ^USER_INFO_0; + {$EXTERNALSYM LPUSER_INFO_0} + PUSER_INFO_0 = ^USER_INFO_0; + {$EXTERNALSYM PUSER_INFO_0} + _USER_INFO_0 = record + usri0_name: LPWSTR; + end; + {$EXTERNALSYM _USER_INFO_0} + USER_INFO_0 = _USER_INFO_0; + {$EXTERNALSYM USER_INFO_0} + TUserInfo0 = USER_INFO_0; + PUserInfo0 = PUSER_INFO_0; + {$ENDIF ~FPC} + + LPUSER_INFO_1 = ^USER_INFO_1; + {$EXTERNALSYM LPUSER_INFO_1} + PUSER_INFO_1 = ^USER_INFO_1; + {$EXTERNALSYM PUSER_INFO_1} + _USER_INFO_1 = record + usri1_name: LPWSTR; + usri1_password: LPWSTR; + usri1_password_age: DWORD; + usri1_priv: DWORD; + usri1_home_dir: LPWSTR; + usri1_comment: LPWSTR; + usri1_flags: DWORD; + usri1_script_path: LPWSTR; + end; + {$EXTERNALSYM _USER_INFO_1} + USER_INFO_1 = _USER_INFO_1; + {$EXTERNALSYM USER_INFO_1} + TUserInfo1 = USER_INFO_1; + PUserInfo1 = PUSER_INFO_1; + + {$IFNDEF FPC} + LPUSER_INFO_2 = ^USER_INFO_2; + {$EXTERNALSYM LPUSER_INFO_2} + PUSER_INFO_2 = ^USER_INFO_2; + {$EXTERNALSYM PUSER_INFO_2} + _USER_INFO_2 = record + usri2_name: LPWSTR; + usri2_password: LPWSTR; + usri2_password_age: DWORD; + usri2_priv: DWORD; + usri2_home_dir: LPWSTR; + usri2_comment: LPWSTR; + usri2_flags: DWORD; + usri2_script_path: LPWSTR; + usri2_auth_flags: DWORD; + usri2_full_name: LPWSTR; + usri2_usr_comment: LPWSTR; + usri2_parms: LPWSTR; + usri2_workstations: LPWSTR; + usri2_last_logon: DWORD; + usri2_last_logoff: DWORD; + usri2_acct_expires: DWORD; + usri2_max_storage: DWORD; + usri2_units_per_week: DWORD; + usri2_logon_hours: PBYTE; + usri2_bad_pw_count: DWORD; + usri2_num_logons: DWORD; + usri2_logon_server: LPWSTR; + usri2_country_code: DWORD; + usri2_code_page: DWORD; + end; + {$EXTERNALSYM _USER_INFO_2} + USER_INFO_2 = _USER_INFO_2; + {$EXTERNALSYM USER_INFO_2} + TUserInfo2 = USER_INFO_2; + PUserInfo2 = puser_info_2; + {$ENDIF ~FPC} + +// line 799 + +// +// Special Values and Constants - User +// + +// +// Bit masks for field usriX_flags of USER_INFO_X (X = 0/1). +// + +const + UF_SCRIPT = $0001; + {$EXTERNALSYM UF_SCRIPT} + UF_ACCOUNTDISABLE = $0002; + {$EXTERNALSYM UF_ACCOUNTDISABLE} + UF_HOMEDIR_REQUIRED = $0008; + {$EXTERNALSYM UF_HOMEDIR_REQUIRED} + UF_LOCKOUT = $0010; + {$EXTERNALSYM UF_LOCKOUT} + UF_PASSWD_NOTREQD = $0020; + {$EXTERNALSYM UF_PASSWD_NOTREQD} + UF_PASSWD_CANT_CHANGE = $0040; + {$EXTERNALSYM UF_PASSWD_CANT_CHANGE} + UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED = $0080; + {$EXTERNALSYM UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED} + +// +// Account type bits as part of usri_flags. +// + + UF_TEMP_DUPLICATE_ACCOUNT = $0100; + {$EXTERNALSYM UF_TEMP_DUPLICATE_ACCOUNT} + UF_NORMAL_ACCOUNT = $0200; + {$EXTERNALSYM UF_NORMAL_ACCOUNT} + UF_INTERDOMAIN_TRUST_ACCOUNT = $0800; + {$EXTERNALSYM UF_INTERDOMAIN_TRUST_ACCOUNT} + UF_WORKSTATION_TRUST_ACCOUNT = $1000; + {$EXTERNALSYM UF_WORKSTATION_TRUST_ACCOUNT} + UF_SERVER_TRUST_ACCOUNT = $2000; + {$EXTERNALSYM UF_SERVER_TRUST_ACCOUNT} + + UF_MACHINE_ACCOUNT_MASK = UF_INTERDOMAIN_TRUST_ACCOUNT or UF_WORKSTATION_TRUST_ACCOUNT or UF_SERVER_TRUST_ACCOUNT; + {$EXTERNALSYM UF_MACHINE_ACCOUNT_MASK} + + UF_ACCOUNT_TYPE_MASK = UF_TEMP_DUPLICATE_ACCOUNT or UF_NORMAL_ACCOUNT or + UF_INTERDOMAIN_TRUST_ACCOUNT or UF_WORKSTATION_TRUST_ACCOUNT or UF_SERVER_TRUST_ACCOUNT; + {$EXTERNALSYM UF_ACCOUNT_TYPE_MASK} + + UF_DONT_EXPIRE_PASSWD = $10000; + {$EXTERNALSYM UF_DONT_EXPIRE_PASSWD} + UF_MNS_LOGON_ACCOUNT = $20000; + {$EXTERNALSYM UF_MNS_LOGON_ACCOUNT} + UF_SMARTCARD_REQUIRED = $40000; + {$EXTERNALSYM UF_SMARTCARD_REQUIRED} + UF_TRUSTED_FOR_DELEGATION = $80000; + {$EXTERNALSYM UF_TRUSTED_FOR_DELEGATION} + UF_NOT_DELEGATED = $100000; + {$EXTERNALSYM UF_NOT_DELEGATED} + UF_USE_DES_KEY_ONLY = $200000; + {$EXTERNALSYM UF_USE_DES_KEY_ONLY} + UF_DONT_REQUIRE_PREAUTH = $400000; + {$EXTERNALSYM UF_DONT_REQUIRE_PREAUTH} + UF_PASSWORD_EXPIRED = DWORD($800000); + {$EXTERNALSYM UF_PASSWORD_EXPIRED} + UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION = $1000000; + {$EXTERNALSYM UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION} + + + UF_SETTABLE_BITS = + UF_SCRIPT or + UF_ACCOUNTDISABLE or + UF_LOCKOUT or + UF_HOMEDIR_REQUIRED or + UF_PASSWD_NOTREQD or + UF_PASSWD_CANT_CHANGE or + UF_ACCOUNT_TYPE_MASK or + UF_DONT_EXPIRE_PASSWD or + UF_MNS_LOGON_ACCOUNT or + UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED or + UF_SMARTCARD_REQUIRED or + UF_TRUSTED_FOR_DELEGATION or + UF_NOT_DELEGATED or + UF_USE_DES_KEY_ONLY or + UF_DONT_REQUIRE_PREAUTH or + UF_PASSWORD_EXPIRED or + UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION; + {$EXTERNALSYM UF_SETTABLE_BITS} + +// line 1056 + +// +// For SetInfo call (parmnum 0) when password change not required +// + + NULL_USERSETINFO_PASSWD = ' '; + {$EXTERNALSYM NULL_USERSETINFO_PASSWD} + + TIMEQ_FOREVER = ULONG(-1); + {$EXTERNALSYM TIMEQ_FOREVER} + USER_MAXSTORAGE_UNLIMITED = ULONG(-1); + {$EXTERNALSYM USER_MAXSTORAGE_UNLIMITED} + USER_NO_LOGOFF = ULONG(-1); + {$EXTERNALSYM USER_NO_LOGOFF} + UNITS_PER_DAY = 24; + {$EXTERNALSYM UNITS_PER_DAY} + UNITS_PER_WEEK = UNITS_PER_DAY * 7; + {$EXTERNALSYM UNITS_PER_WEEK} + +// +// Privilege levels (USER_INFO_X field usriX_priv (X = 0/1)). +// + + USER_PRIV_MASK = $3; + {$EXTERNALSYM USER_PRIV_MASK} + USER_PRIV_GUEST = 0; + {$EXTERNALSYM USER_PRIV_GUEST} + USER_PRIV_USER = 1; + {$EXTERNALSYM USER_PRIV_USER} + USER_PRIV_ADMIN = 2; + {$EXTERNALSYM USER_PRIV_ADMIN} + +// line 1177 + +// +// Group Class +// + +// +// Function Prototypes +// + + +function NetGroupAdd(servername: LPCWSTR; level: DWORD; buf: PByte; parm_err: LPDWORD): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetGroupAdd} + +function NetGroupAddUser(servername, GroupName, username: LPCWSTR): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetGroupAddUser} + +function NetGroupEnum(servername: LPCWSTR; level: DWORD; out bufptr: PByte; + prefmaxlen: DWORD; out entriesread, totalentries: DWORD; resume_handle: PDWORD_PTR): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetGroupEnum} + +function NetGroupGetInfo(servername, groupname: LPCWSTR; level: DWORD; bufptr: PByte): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetGroupGetInfo} + +function NetGroupSetInfo(servername, groupname: LPCWSTR; level: DWORD; buf: PByte; parm_err: LPDWORD): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetGroupSetInfo} + +function NetGroupDel(servername: LPCWSTR; groupname: LPCWSTR): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetGroupDel} + +function NetGroupDelUser(servername: LPCWSTR; GroupName: LPCWSTR; Username: LPCWSTR): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetGroupDelUser} + +function NetGroupGetUsers(servername, groupname: LPCWSTR; level: DWORD; var bufptr: PByte; prefmaxlen: DWORD; entriesread, totalentries: LPDWORD; ResumeHandle: PDWORD_PTR): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetGroupGetUsers} + +function NetGroupSetUsers(servername, groupname: LPCWSTR; level: DWORD; buf: PByte; totalentries: DWORD): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetGroupSetUsers} + + +// +// Data Structures - Group +// + +type + LPGROUP_INFO_0 = ^GROUP_INFO_0; + {$EXTERNALSYM LPGROUP_INFO_0} + PGROUP_INFO_0 = ^GROUP_INFO_0; + {$EXTERNALSYM PGROUP_INFO_0} + _GROUP_INFO_0 = record + grpi0_name: LPWSTR; + end; + {$EXTERNALSYM _GROUP_INFO_0} + GROUP_INFO_0 = _GROUP_INFO_0; + {$EXTERNALSYM GROUP_INFO_0} + TGroupInfo0 = GROUP_INFO_0; + PGroupInfo0 = PGROUP_INFO_0; + + LPGROUP_INFO_1 = ^GROUP_INFO_1; + {$EXTERNALSYM LPGROUP_INFO_1} + PGROUP_INFO_1 = ^GROUP_INFO_1; + {$EXTERNALSYM PGROUP_INFO_1} + _GROUP_INFO_1 = record + grpi1_name: LPWSTR; + grpi1_comment: LPWSTR; + end; + {$EXTERNALSYM _GROUP_INFO_1} + GROUP_INFO_1 = _GROUP_INFO_1; + {$EXTERNALSYM GROUP_INFO_1} + TGroupInfo1 = GROUP_INFO_1; + PGroupInfo1 = PGROUP_INFO_1; + +// line 1380 + +// +// LocalGroup Class +// + +// +// Function Prototypes +// + + +function NetLocalGroupAdd(servername: LPCWSTR; level: DWORD; buf: PByte; parm_err: LPDWORD): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetLocalGroupAdd} + +function NetLocalGroupAddMember(servername, groupname: LPCWSTR; membersid: PSID): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetLocalGroupAddMember} + +function NetLocalGroupEnum(servername: LPCWSTR; level: DWORD; out bufptr: PByte; + prefmaxlen: DWORD; out entriesread, totalentries: DWORD; resumehandle: PDWORD_PTR): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetLocalGroupEnum} + +function NetLocalGroupGetInfo(servername, groupname: LPCWSTR; level: DWORD; var bufptr: PByte): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetLocalGroupGetInfo} + +function NetLocalGroupSetInfo(servername, groupname: LPCWSTR; level: DWORD; buf: PByte; parm_err: LPDWORD): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetLocalGroupSetInfo} + +function NetLocalGroupDel(servername: LPCWSTR; groupname: LPCWSTR): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetLocalGroupDel} + +function NetLocalGroupDelMember(servername: LPCWSTR; groupname: LPCWSTR; membersid: PSID): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetLocalGroupDelMember} + +function NetLocalGroupGetMembers(servername, localgroupname: LPCWSTR; level: DWORD; var bufptr: PByte; prefmaxlen: DWORD; entriesread, totalentries: LPDWORD; resumehandle: PDWORD_PTR): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetLocalGroupGetMembers} + +function NetLocalGroupSetMembers(servername, groupname: LPCWSTR; level: DWORD; buf: PByte; totalentries: DWORD): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetLocalGroupSetMembers} + +function NetLocalGroupAddMembers(servername, groupname: LPCWSTR; level: DWORD; buf: PByte; totalentries: DWORD): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetLocalGroupAddMembers} + +function NetLocalGroupDelMembers(servername, groupname: LPCWSTR; level: DWORD; buf: PByte; totalentries: DWORD): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetLocalGroupDelMembers} + + +// +// Data Structures - LocalGroup +// + +type + {$IFNDEF FPC} + LPLOCALGROUP_INFO_0 = ^LOCALGROUP_INFO_0; + {$EXTERNALSYM LPLOCALGROUP_INFO_0} + PLOCALGROUP_INFO_0 = ^LOCALGROUP_INFO_0; + {$EXTERNALSYM PLOCALGROUP_INFO_0} + _LOCALGROUP_INFO_0 = record + lgrpi0_name: LPWSTR; + end; + {$EXTERNALSYM _LOCALGROUP_INFO_0} + LOCALGROUP_INFO_0 = _LOCALGROUP_INFO_0; + {$EXTERNALSYM LOCALGROUP_INFO_0} + TLocalGroupInfo0 = LOCALGROUP_INFO_0; + PLocalGroupInfo0 = PLOCALGROUP_INFO_0; + {$ENDIF ~FPC} + + LPLOCALGROUP_INFO_1 = ^LOCALGROUP_INFO_1; + {$EXTERNALSYM LPLOCALGROUP_INFO_1} + PLOCALGROUP_INFO_1 = ^LOCALGROUP_INFO_1; + {$EXTERNALSYM PLOCALGROUP_INFO_1} + _LOCALGROUP_INFO_1 = record + lgrpi1_name: LPWSTR; + lgrpi1_comment: LPWSTR; + end; + {$EXTERNALSYM _LOCALGROUP_INFO_1} + LOCALGROUP_INFO_1 = _LOCALGROUP_INFO_1; + {$EXTERNALSYM LOCALGROUP_INFO_1} + TLocalGroupInfo1 = LOCALGROUP_INFO_1; + PLocalGroupInfo1 = PLOCALGROUP_INFO_1; + + LPLOCALGROUP_INFO_1002 = ^LOCALGROUP_INFO_1002; + {$EXTERNALSYM LPLOCALGROUP_INFO_1002} + PLOCALGROUP_INFO_1002 = ^LOCALGROUP_INFO_1002; + {$EXTERNALSYM PLOCALGROUP_INFO_1002} + _LOCALGROUP_INFO_1002 = record + lgrpi1002_comment: LPWSTR; + end; + {$EXTERNALSYM _LOCALGROUP_INFO_1002} + LOCALGROUP_INFO_1002 = _LOCALGROUP_INFO_1002; + {$EXTERNALSYM LOCALGROUP_INFO_1002} + TLocalGroupInfo1002 = LOCALGROUP_INFO_1002; + PLocalGroupInfo1002 = PLOCALGROUP_INFO_1002; + + {$IFNDEF FPC} + LPLOCALGROUP_MEMBERS_INFO_0 = ^LOCALGROUP_MEMBERS_INFO_0; + {$EXTERNALSYM LPLOCALGROUP_MEMBERS_INFO_0} + PLOCALGROUP_MEMBERS_INFO_0 = ^LOCALGROUP_MEMBERS_INFO_0; + {$EXTERNALSYM PLOCALGROUP_MEMBERS_INFO_0} + _LOCALGROUP_MEMBERS_INFO_0 = record + lgrmi0_sid: PSID; + end; + {$EXTERNALSYM _LOCALGROUP_MEMBERS_INFO_0} + LOCALGROUP_MEMBERS_INFO_0 = _LOCALGROUP_MEMBERS_INFO_0; + {$EXTERNALSYM LOCALGROUP_MEMBERS_INFO_0} + TLocalGroupMembersInfo0 = LOCALGROUP_MEMBERS_INFO_0; + PLocalGroupMembersInfo0 = PLOCALGROUP_MEMBERS_INFO_0; + {$ENDIF ~FPC} + + LPLOCALGROUP_MEMBERS_INFO_1 = ^LOCALGROUP_MEMBERS_INFO_1; + {$EXTERNALSYM LPLOCALGROUP_MEMBERS_INFO_1} + PLOCALGROUP_MEMBERS_INFO_1 = ^LOCALGROUP_MEMBERS_INFO_1; + {$EXTERNALSYM PLOCALGROUP_MEMBERS_INFO_1} + _LOCALGROUP_MEMBERS_INFO_1 = record + lgrmi1_sid: PSID; + lgrmi1_sidusage: SID_NAME_USE; + lgrmi1_name: LPWSTR; + end; + {$EXTERNALSYM _LOCALGROUP_MEMBERS_INFO_1} + LOCALGROUP_MEMBERS_INFO_1 = _LOCALGROUP_MEMBERS_INFO_1; + {$EXTERNALSYM LOCALGROUP_MEMBERS_INFO_1} + TLocalGroupMembersInfo1 = LOCALGROUP_MEMBERS_INFO_1; + PLocalGroupMembersInfo1 = PLOCALGROUP_MEMBERS_INFO_1; + + LPLOCALGROUP_MEMBERS_INFO_2 = ^LOCALGROUP_MEMBERS_INFO_2; + {$EXTERNALSYM LPLOCALGROUP_MEMBERS_INFO_2} + PLOCALGROUP_MEMBERS_INFO_2 = ^LOCALGROUP_MEMBERS_INFO_2; + {$EXTERNALSYM PLOCALGROUP_MEMBERS_INFO_2} + _LOCALGROUP_MEMBERS_INFO_2 = record + lgrmi2_sid: PSID; + lgrmi2_sidusage: SID_NAME_USE; + lgrmi2_domainandname: LPWSTR; + end; + {$EXTERNALSYM _LOCALGROUP_MEMBERS_INFO_2} + LOCALGROUP_MEMBERS_INFO_2 = _LOCALGROUP_MEMBERS_INFO_2; + {$EXTERNALSYM LOCALGROUP_MEMBERS_INFO_2} + TLocalGroupMembersInfo2 = LOCALGROUP_MEMBERS_INFO_2; + PLocalGroupMembersInfo2 = PLOCALGROUP_MEMBERS_INFO_2; + + {$IFNDEF FPC} + LPLOCALGROUP_MEMBERS_INFO_3 = ^LOCALGROUP_MEMBERS_INFO_3; + {$EXTERNALSYM LPLOCALGROUP_MEMBERS_INFO_3} + PLOCALGROUP_MEMBERS_INFO_3 = ^LOCALGROUP_MEMBERS_INFO_3; + {$EXTERNALSYM PLOCALGROUP_MEMBERS_INFO_3} + _LOCALGROUP_MEMBERS_INFO_3 = record + lgrmi3_domainandname: LPWSTR; + end; + {$EXTERNALSYM _LOCALGROUP_MEMBERS_INFO_3} + LOCALGROUP_MEMBERS_INFO_3 = _LOCALGROUP_MEMBERS_INFO_3; + {$EXTERNALSYM LOCALGROUP_MEMBERS_INFO_3} + TLocalGroupMembersInfo3 = LOCALGROUP_MEMBERS_INFO_3; + PLocalGroupMembersInfo3 = PLOCALGROUP_MEMBERS_INFO_3; + {$ENDIF ~FPC} + +function NetApiBufferFree(Buffer: Pointer): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetApiBufferFree} + +type + _WKSTA_INFO_100 = record + wki100_platform_id: DWORD; + wki100_computername: LMSTR; + wki100_langroup: LMSTR; + wki100_ver_major: DWORD; + wki100_ver_minor: DWORD; + end; + {$EXTERNALSYM _WKSTA_INFO_100} + WKSTA_INFO_100 = _WKSTA_INFO_100; + {$EXTERNALSYM WKSTA_INFO_100} + PWKSTA_INFO_100 = ^_WKSTA_INFO_100; + {$EXTERNALSYM PWKSTA_INFO_100} + LPWKSTA_INFO_100 = ^_WKSTA_INFO_100; + {$EXTERNALSYM LPWKSTA_INFO_100} + +function NetWkstaGetInfo(servername: PWideChar; level: DWORD; out bufptr: PByte): NET_API_STATUS; stdcall; +{$EXTERNALSYM NetWkstaGetInfo} + +(**************************************************************** + * * + * Data structure templates * + * * + ****************************************************************) + +const + NCBNAMSZ = 16; // absolute length of a net name + {$EXTERNALSYM NCBNAMSZ} + MAX_LANA = 254; // lana's in range 0 to MAX_LANA inclusive + {$EXTERNALSYM MAX_LANA} + +// +// Network Control Block +// + +type + {$IFNDEF FPC} + PNCB = ^NCB; + {$ENDIF ~FPC} + + TNcbPost = procedure (P: PNCB); stdcall; + + {$IFNDEF FPC} + _NCB = record + ncb_command: UCHAR; // command code + ncb_retcode: UCHAR; // return code + ncb_lsn: UCHAR; // local session number + ncb_num: UCHAR; // number of our network name + ncb_buffer: PUCHAR; // address of message buffer + ncb_length: Word; // size of message buffer + ncb_callname: array [0..NCBNAMSZ - 1] of UCHAR; // blank-padded name of remote + ncb_name: array [0..NCBNAMSZ - 1] of UCHAR; // our blank-padded netname + ncb_rto: UCHAR; // rcv timeout/retry count + ncb_sto: UCHAR; // send timeout/sys timeout + ncb_post: TNcbPost; // POST routine address + ncb_lana_num: UCHAR; // lana (adapter) number + ncb_cmd_cplt: UCHAR; // 0xff => commmand pending + {$IFDEF _WIN64} + ncb_reserve: array [0..17] of UCHAR; // reserved, used by BIOS + {$ELSE ~_WIN64} + ncb_reserve: array [0..9] of UCHAR; // reserved, used by BIOS + {$ENDIF ~_WIN64} + ncb_event: THandle; // HANDLE to Win32 event which + // will be set to the signalled + // state when an ASYNCH command + // completes + end; + {$EXTERNALSYM _NCB} + NCB = _NCB; + {$EXTERNALSYM NCB} + TNcb = NCB; + {$ENDIF ~FPC} + +// +// Structure returned to the NCB command NCBASTAT is ADAPTER_STATUS followed +// by an array of NAME_BUFFER structures. +// +{$IFNDEF FPC} +type + _ADAPTER_STATUS = record + adapter_address: array [0..5] of UCHAR; + rev_major: UCHAR; + reserved0: UCHAR; + adapter_type: UCHAR; + rev_minor: UCHAR; + duration: WORD; + frmr_recv: WORD; + frmr_xmit: WORD; + iframe_recv_err: WORD; + xmit_aborts: WORD; + xmit_success: DWORD; + recv_success: DWORD; + iframe_xmit_err: WORD; + recv_buff_unavail: WORD; + t1_timeouts: WORD; + ti_timeouts: WORD; + reserved1: DWORD; + free_ncbs: WORD; + max_cfg_ncbs: WORD; + max_ncbs: WORD; + xmit_buf_unavail: WORD; + max_dgram_size: WORD; + pending_sess: WORD; + max_cfg_sess: WORD; + max_sess: WORD; + max_sess_pkt_size: WORD; + name_count: WORD; + end; + {$EXTERNALSYM _ADAPTER_STATUS} + ADAPTER_STATUS = _ADAPTER_STATUS; + {$EXTERNALSYM ADAPTER_STATUS} + PADAPTER_STATUS = ^ADAPTER_STATUS; + {$EXTERNALSYM PADAPTER_STATUS} + TAdapterStatus = ADAPTER_STATUS; + PAdapterStatus = PADAPTER_STATUS; + + _NAME_BUFFER = record + name: array [0..NCBNAMSZ - 1] of UCHAR; + name_num: UCHAR; + name_flags: UCHAR; + end; + {$EXTERNALSYM _NAME_BUFFER} + NAME_BUFFER = _NAME_BUFFER; + {$EXTERNALSYM NAME_BUFFER} + PNAME_BUFFER = ^NAME_BUFFER; + {$EXTERNALSYM PNAME_BUFFER} + TNameBuffer = NAME_BUFFER; + PNameBuffer = PNAME_BUFFER; +{$ENDIF ~FPC} + +// values for name_flags bits. + +const + NAME_FLAGS_MASK = $87; + {$EXTERNALSYM NAME_FLAGS_MASK} + + GROUP_NAME = $80; + {$EXTERNALSYM GROUP_NAME} + UNIQUE_NAME = $00; + {$EXTERNALSYM UNIQUE_NAME} + + REGISTERING = $00; + {$EXTERNALSYM REGISTERING} + REGISTERED = $04; + {$EXTERNALSYM REGISTERED} + DEREGISTERED = $05; + {$EXTERNALSYM DEREGISTERED} + DUPLICATE = $06; + {$EXTERNALSYM DUPLICATE} + DUPLICATE_DEREG = $07; + {$EXTERNALSYM DUPLICATE_DEREG} + +// +// Structure returned to the NCB command NCBSSTAT is SESSION_HEADER followed +// by an array of SESSION_BUFFER structures. If the NCB_NAME starts with an +// asterisk then an array of these structures is returned containing the +// status for all names. +// + +{$IFNDEF FPC} +type + _SESSION_HEADER = record + sess_name: UCHAR; + num_sess: UCHAR; + rcv_dg_outstanding: UCHAR; + rcv_any_outstanding: UCHAR; + end; + {$EXTERNALSYM _SESSION_HEADER} + SESSION_HEADER = _SESSION_HEADER; + {$EXTERNALSYM SESSION_HEADER} + PSESSION_HEADER = ^SESSION_HEADER; + {$EXTERNALSYM PSESSION_HEADER} + TSessionHeader = SESSION_HEADER; + PSessionHeader = PSESSION_HEADER; + + _SESSION_BUFFER = record + lsn: UCHAR; + state: UCHAR; + local_name: array [0..NCBNAMSZ - 1] of UCHAR; + remote_name: array [0..NCBNAMSZ - 1] of UCHAR; + rcvs_outstanding: UCHAR; + sends_outstanding: UCHAR; + end; + {$EXTERNALSYM _SESSION_BUFFER} + SESSION_BUFFER = _SESSION_BUFFER; + {$EXTERNALSYM SESSION_BUFFER} + PSESSION_BUFFER = ^SESSION_BUFFER; + {$EXTERNALSYM PSESSION_BUFFER} + TSessionBuffer = SESSION_BUFFER; + PSessionBuffer = PSESSION_BUFFER; +{$ENDIF ~FPC} + +// Values for state + +const + LISTEN_OUTSTANDING = $01; + {$EXTERNALSYM LISTEN_OUTSTANDING} + CALL_PENDING = $02; + {$EXTERNALSYM CALL_PENDING} + SESSION_ESTABLISHED = $03; + {$EXTERNALSYM SESSION_ESTABLISHED} + HANGUP_PENDING = $04; + {$EXTERNALSYM HANGUP_PENDING} + HANGUP_COMPLETE = $05; + {$EXTERNALSYM HANGUP_COMPLETE} + SESSION_ABORTED = $06; + {$EXTERNALSYM SESSION_ABORTED} + +// +// Structure returned to the NCB command NCBENUM. +// +// On a system containing lana's 0, 2 and 3, a structure with +// length =3, lana[0]=0, lana[1]=2 and lana[2]=3 will be returned. +// + +{$IFNDEF FPC} +type + _LANA_ENUM = record + length: UCHAR; // Number of valid entries in lana[] + lana: array [0..MAX_LANA] of UCHAR; + end; + {$EXTERNALSYM _LANA_ENUM} + LANA_ENUM = _LANA_ENUM; + {$EXTERNALSYM LANA_ENUM} + PLANA_ENUM = ^LANA_ENUM; + {$EXTERNALSYM PLANA_ENUM} + TLanaEnum = LANA_ENUM; + PLanaEnum = PLANA_ENUM; +{$ENDIF ~FPC} + +// +// Structure returned to the NCB command NCBFINDNAME is FIND_NAME_HEADER followed +// by an array of FIND_NAME_BUFFER structures. +// + +{$IFNDEF FPC} +type + _FIND_NAME_HEADER = record + node_count: WORD; + reserved: UCHAR; + unique_group: UCHAR; + end; + {$EXTERNALSYM _FIND_NAME_HEADER} + FIND_NAME_HEADER = _FIND_NAME_HEADER; + {$EXTERNALSYM FIND_NAME_HEADER} + PFIND_NAME_HEADER = ^FIND_NAME_HEADER; + {$EXTERNALSYM PFIND_NAME_HEADER} + TFindNameHeader = FIND_NAME_HEADER; + PFindNameHeader = PFIND_NAME_HEADER; + + _FIND_NAME_BUFFER = record + length: UCHAR; + access_control: UCHAR; + frame_control: UCHAR; + destination_addr: array [0..5] of UCHAR; + source_addr: array [0..5] of UCHAR; + routing_info: array [0..17] of UCHAR; + end; + {$EXTERNALSYM _FIND_NAME_BUFFER} + FIND_NAME_BUFFER = _FIND_NAME_BUFFER; + {$EXTERNALSYM FIND_NAME_BUFFER} + PFIND_NAME_BUFFER = ^FIND_NAME_BUFFER; + {$EXTERNALSYM PFIND_NAME_BUFFER} + TFindNameBuffer = FIND_NAME_BUFFER; + PFindNameBuffer = PFIND_NAME_BUFFER; + +// +// Structure provided with NCBACTION. The purpose of NCBACTION is to provide +// transport specific extensions to netbios. +// + + _ACTION_HEADER = record + transport_id: ULONG; + action_code: USHORT; + reserved: USHORT; + end; + {$EXTERNALSYM _ACTION_HEADER} + ACTION_HEADER = _ACTION_HEADER; + {$EXTERNALSYM ACTION_HEADER} + PACTION_HEADER = ^ACTION_HEADER; + {$EXTERNALSYM PACTION_HEADER} + TActionHeader = ACTION_HEADER; + PActionHeader = PACTION_HEADER; +{$ENDIF ~FPC} + +// Values for transport_id + +const + ALL_TRANSPORTS = 'M'#0#0#0; + {$EXTERNALSYM ALL_TRANSPORTS} + MS_NBF = 'MNBF'; + {$EXTERNALSYM MS_NBF} + +(**************************************************************** + * * + * Special values and constants * + * * + ****************************************************************) + +// +// NCB Command codes +// + +const + NCBCALL = $10; // NCB CALL + {$EXTERNALSYM NCBCALL} + NCBLISTEN = $11; // NCB LISTEN + {$EXTERNALSYM NCBLISTEN} + NCBHANGUP = $12; // NCB HANG UP + {$EXTERNALSYM NCBHANGUP} + NCBSEND = $14; // NCB SEND + {$EXTERNALSYM NCBSEND} + NCBRECV = $15; // NCB RECEIVE + {$EXTERNALSYM NCBRECV} + NCBRECVANY = $16; // NCB RECEIVE ANY + {$EXTERNALSYM NCBRECVANY} + NCBCHAINSEND = $17; // NCB CHAIN SEND + {$EXTERNALSYM NCBCHAINSEND} + NCBDGSEND = $20; // NCB SEND DATAGRAM + {$EXTERNALSYM NCBDGSEND} + NCBDGRECV = $21; // NCB RECEIVE DATAGRAM + {$EXTERNALSYM NCBDGRECV} + NCBDGSENDBC = $22; // NCB SEND BROADCAST DATAGRAM + {$EXTERNALSYM NCBDGSENDBC} + NCBDGRECVBC = $23; // NCB RECEIVE BROADCAST DATAGRAM + {$EXTERNALSYM NCBDGRECVBC} + NCBADDNAME = $30; // NCB ADD NAME + {$EXTERNALSYM NCBADDNAME} + NCBDELNAME = $31; // NCB DELETE NAME + {$EXTERNALSYM NCBDELNAME} + NCBRESET = $32; // NCB RESET + {$EXTERNALSYM NCBRESET} + NCBASTAT = $33; // NCB ADAPTER STATUS + {$EXTERNALSYM NCBASTAT} + NCBSSTAT = $34; // NCB SESSION STATUS + {$EXTERNALSYM NCBSSTAT} + NCBCANCEL = $35; // NCB CANCEL + {$EXTERNALSYM NCBCANCEL} + NCBADDGRNAME = $36; // NCB ADD GROUP NAME + {$EXTERNALSYM NCBADDGRNAME} + NCBENUM = $37; // NCB ENUMERATE LANA NUMBERS + {$EXTERNALSYM NCBENUM} + NCBUNLINK = $70; // NCB UNLINK + {$EXTERNALSYM NCBUNLINK} + NCBSENDNA = $71; // NCB SEND NO ACK + {$EXTERNALSYM NCBSENDNA} + NCBCHAINSENDNA = $72; // NCB CHAIN SEND NO ACK + {$EXTERNALSYM NCBCHAINSENDNA} + NCBLANSTALERT = $73; // NCB LAN STATUS ALERT + {$EXTERNALSYM NCBLANSTALERT} + NCBACTION = $77; // NCB ACTION + {$EXTERNALSYM NCBACTION} + NCBFINDNAME = $78; // NCB FIND NAME + {$EXTERNALSYM NCBFINDNAME} + NCBTRACE = $79; // NCB TRACE + {$EXTERNALSYM NCBTRACE} + + ASYNCH = $80; // high bit set == asynchronous + {$EXTERNALSYM ASYNCH} + +// +// NCB Return codes +// + + NRC_GOODRET = $00; // good return also returned when ASYNCH request accepted + {$EXTERNALSYM NRC_GOODRET} + NRC_BUFLEN = $01; // illegal buffer length + {$EXTERNALSYM NRC_BUFLEN} + NRC_ILLCMD = $03; // illegal command + {$EXTERNALSYM NRC_ILLCMD} + NRC_CMDTMO = $05; // command timed out + {$EXTERNALSYM NRC_CMDTMO} + NRC_INCOMP = $06; // message incomplete, issue another command + {$EXTERNALSYM NRC_INCOMP} + NRC_BADDR = $07; // illegal buffer address + {$EXTERNALSYM NRC_BADDR} + NRC_SNUMOUT = $08; // session number out of range + {$EXTERNALSYM NRC_SNUMOUT} + NRC_NORES = $09; // no resource available + {$EXTERNALSYM NRC_NORES} + NRC_SCLOSED = $0a; // session closed + {$EXTERNALSYM NRC_SCLOSED} + NRC_CMDCAN = $0b; // command cancelled + {$EXTERNALSYM NRC_CMDCAN} + NRC_DUPNAME = $0d; // duplicate name + {$EXTERNALSYM NRC_DUPNAME} + NRC_NAMTFUL = $0e; // name table full + {$EXTERNALSYM NRC_NAMTFUL} + NRC_ACTSES = $0f; // no deletions, name has active sessions + {$EXTERNALSYM NRC_ACTSES} + NRC_LOCTFUL = $11; // local session table full + {$EXTERNALSYM NRC_LOCTFUL} + NRC_REMTFUL = $12; // remote session table full + {$EXTERNALSYM NRC_REMTFUL} + NRC_ILLNN = $13; // illegal name number + {$EXTERNALSYM NRC_ILLNN} + NRC_NOCALL = $14; // no callname + {$EXTERNALSYM NRC_NOCALL} + NRC_NOWILD = $15; // cannot put * in NCB_NAME + {$EXTERNALSYM NRC_NOWILD} + NRC_INUSE = $16; // name in use on remote adapter + {$EXTERNALSYM NRC_INUSE} + NRC_NAMERR = $17; // name deleted + {$EXTERNALSYM NRC_NAMERR} + NRC_SABORT = $18; // session ended abnormally + {$EXTERNALSYM NRC_SABORT} + NRC_NAMCONF = $19; // name conflict detected + {$EXTERNALSYM NRC_NAMCONF} + NRC_IFBUSY = $21; // interface busy, IRET before retrying + {$EXTERNALSYM NRC_IFBUSY} + NRC_TOOMANY = $22; // too many commands outstanding, retry later + {$EXTERNALSYM NRC_TOOMANY} + NRC_BRIDGE = $23; // ncb_lana_num field invalid + {$EXTERNALSYM NRC_BRIDGE} + NRC_CANOCCR = $24; // command completed while cancel occurring + {$EXTERNALSYM NRC_CANOCCR} + NRC_CANCEL = $26; // command not valid to cancel + {$EXTERNALSYM NRC_CANCEL} + NRC_DUPENV = $30; // name defined by anther local process + {$EXTERNALSYM NRC_DUPENV} + NRC_ENVNOTDEF = $34; // environment undefined. RESET required + {$EXTERNALSYM NRC_ENVNOTDEF} + NRC_OSRESNOTAV = $35; // required OS resources exhausted + {$EXTERNALSYM NRC_OSRESNOTAV} + NRC_MAXAPPS = $36; // max number of applications exceeded + {$EXTERNALSYM NRC_MAXAPPS} + NRC_NOSAPS = $37; // no saps available for netbios + {$EXTERNALSYM NRC_NOSAPS} + NRC_NORESOURCES = $38; // requested resources are not available + {$EXTERNALSYM NRC_NORESOURCES} + NRC_INVADDRESS = $39; // invalid ncb address or length > segment + {$EXTERNALSYM NRC_INVADDRESS} + NRC_INVDDID = $3B; // invalid NCB DDID + {$EXTERNALSYM NRC_INVDDID} + NRC_LOCKFAIL = $3C; // lock of user area failed + {$EXTERNALSYM NRC_LOCKFAIL} + NRC_OPENERR = $3f; // NETBIOS not loaded + {$EXTERNALSYM NRC_OPENERR} + NRC_SYSTEM = $40; // system error + {$EXTERNALSYM NRC_SYSTEM} + + NRC_PENDING = $ff; // asynchronous command is not yet finished + {$EXTERNALSYM NRC_PENDING} + +(**************************************************************** + * * + * main user entry point for NetBIOS 3.0 * + * * + * Usage: result = Netbios( pncb ); * + ****************************************************************) + +function Netbios(pncb: PNCB): UCHAR; stdcall; +{$EXTERNALSYM Netbios} + +type + PRasDialDlg = ^TRasDialDlg; + tagRASDIALDLG = packed record + dwSize: DWORD; + hwndOwner: HWND; + dwFlags: DWORD; + xDlg: Longint; + yDlg: Longint; + dwSubEntry: DWORD; + dwError: DWORD; + reserved: Longword; + reserved2: Longword; + end; + {$EXTERNALSYM tagRASDIALDLG} + RASDIALDLG = tagRASDIALDLG; + {$EXTERNALSYM RASDIALDLG} + TRasDialDlg = tagRASDIALDLG; + + +// Reason flags + +// Flags used by the various UIs. + +const + SHTDN_REASON_FLAG_COMMENT_REQUIRED = $01000000; + {$EXTERNALSYM SHTDN_REASON_FLAG_COMMENT_REQUIRED} + SHTDN_REASON_FLAG_DIRTY_PROBLEM_ID_REQUIRED = $02000000; + {$EXTERNALSYM SHTDN_REASON_FLAG_DIRTY_PROBLEM_ID_REQUIRED} + SHTDN_REASON_FLAG_CLEAN_UI = $04000000; + {$EXTERNALSYM SHTDN_REASON_FLAG_CLEAN_UI} + SHTDN_REASON_FLAG_DIRTY_UI = $08000000; + {$EXTERNALSYM SHTDN_REASON_FLAG_DIRTY_UI} + +// Flags that end up in the event log code. + + SHTDN_REASON_FLAG_USER_DEFINED = $40000000; + {$EXTERNALSYM SHTDN_REASON_FLAG_USER_DEFINED} + SHTDN_REASON_FLAG_PLANNED = DWORD($80000000); + {$EXTERNALSYM SHTDN_REASON_FLAG_PLANNED} + +// Microsoft major reasons. + + SHTDN_REASON_MAJOR_OTHER = $00000000; + {$EXTERNALSYM SHTDN_REASON_MAJOR_OTHER} + SHTDN_REASON_MAJOR_NONE = $00000000; + {$EXTERNALSYM SHTDN_REASON_MAJOR_NONE} + SHTDN_REASON_MAJOR_HARDWARE = $00010000; + {$EXTERNALSYM SHTDN_REASON_MAJOR_HARDWARE} + SHTDN_REASON_MAJOR_OPERATINGSYSTEM = $00020000; + {$EXTERNALSYM SHTDN_REASON_MAJOR_OPERATINGSYSTEM} + SHTDN_REASON_MAJOR_SOFTWARE = $00030000; + {$EXTERNALSYM SHTDN_REASON_MAJOR_SOFTWARE} + SHTDN_REASON_MAJOR_APPLICATION = $00040000; + {$EXTERNALSYM SHTDN_REASON_MAJOR_APPLICATION} + SHTDN_REASON_MAJOR_SYSTEM = $00050000; + {$EXTERNALSYM SHTDN_REASON_MAJOR_SYSTEM} + SHTDN_REASON_MAJOR_POWER = $00060000; + {$EXTERNALSYM SHTDN_REASON_MAJOR_POWER} + SHTDN_REASON_MAJOR_LEGACY_API = $00070000; + {$EXTERNALSYM SHTDN_REASON_MAJOR_LEGACY_API} + +// Microsoft minor reasons. + + SHTDN_REASON_MINOR_OTHER = $00000000; + {$EXTERNALSYM SHTDN_REASON_MINOR_OTHER} + SHTDN_REASON_MINOR_NONE = $000000ff; + {$EXTERNALSYM SHTDN_REASON_MINOR_NONE} + SHTDN_REASON_MINOR_MAINTENANCE = $00000001; + {$EXTERNALSYM SHTDN_REASON_MINOR_MAINTENANCE} + SHTDN_REASON_MINOR_INSTALLATION = $00000002; + {$EXTERNALSYM SHTDN_REASON_MINOR_INSTALLATION} + SHTDN_REASON_MINOR_UPGRADE = $00000003; + {$EXTERNALSYM SHTDN_REASON_MINOR_UPGRADE} + SHTDN_REASON_MINOR_RECONFIG = $00000004; + {$EXTERNALSYM SHTDN_REASON_MINOR_RECONFIG} + SHTDN_REASON_MINOR_HUNG = $00000005; + {$EXTERNALSYM SHTDN_REASON_MINOR_HUNG} + SHTDN_REASON_MINOR_UNSTABLE = $00000006; + {$EXTERNALSYM SHTDN_REASON_MINOR_UNSTABLE} + SHTDN_REASON_MINOR_DISK = $00000007; + {$EXTERNALSYM SHTDN_REASON_MINOR_DISK} + SHTDN_REASON_MINOR_PROCESSOR = $00000008; + {$EXTERNALSYM SHTDN_REASON_MINOR_PROCESSOR} + SHTDN_REASON_MINOR_NETWORKCARD = $00000009; + {$EXTERNALSYM SHTDN_REASON_MINOR_NETWORKCARD} + SHTDN_REASON_MINOR_POWER_SUPPLY = $0000000a; + {$EXTERNALSYM SHTDN_REASON_MINOR_POWER_SUPPLY} + SHTDN_REASON_MINOR_CORDUNPLUGGED = $0000000b; + {$EXTERNALSYM SHTDN_REASON_MINOR_CORDUNPLUGGED} + SHTDN_REASON_MINOR_ENVIRONMENT = $0000000c; + {$EXTERNALSYM SHTDN_REASON_MINOR_ENVIRONMENT} + SHTDN_REASON_MINOR_HARDWARE_DRIVER = $0000000d; + {$EXTERNALSYM SHTDN_REASON_MINOR_HARDWARE_DRIVER} + SHTDN_REASON_MINOR_OTHERDRIVER = $0000000e; + {$EXTERNALSYM SHTDN_REASON_MINOR_OTHERDRIVER} + SHTDN_REASON_MINOR_BLUESCREEN = $0000000F; + {$EXTERNALSYM SHTDN_REASON_MINOR_BLUESCREEN} + SHTDN_REASON_MINOR_SERVICEPACK = $00000010; + {$EXTERNALSYM SHTDN_REASON_MINOR_SERVICEPACK} + SHTDN_REASON_MINOR_HOTFIX = $00000011; + {$EXTERNALSYM SHTDN_REASON_MINOR_HOTFIX} + SHTDN_REASON_MINOR_SECURITYFIX = $00000012; + {$EXTERNALSYM SHTDN_REASON_MINOR_SECURITYFIX} + SHTDN_REASON_MINOR_SECURITY = $00000013; + {$EXTERNALSYM SHTDN_REASON_MINOR_SECURITY} + SHTDN_REASON_MINOR_NETWORK_CONNECTIVITY = $00000014; + {$EXTERNALSYM SHTDN_REASON_MINOR_NETWORK_CONNECTIVITY} + SHTDN_REASON_MINOR_WMI = $00000015; + {$EXTERNALSYM SHTDN_REASON_MINOR_WMI} + SHTDN_REASON_MINOR_SERVICEPACK_UNINSTALL = $00000016; + {$EXTERNALSYM SHTDN_REASON_MINOR_SERVICEPACK_UNINSTALL} + SHTDN_REASON_MINOR_HOTFIX_UNINSTALL = $00000017; + {$EXTERNALSYM SHTDN_REASON_MINOR_HOTFIX_UNINSTALL} + SHTDN_REASON_MINOR_SECURITYFIX_UNINSTALL = $00000018; + {$EXTERNALSYM SHTDN_REASON_MINOR_SECURITYFIX_UNINSTALL} + SHTDN_REASON_MINOR_MMC = $00000019; + {$EXTERNALSYM SHTDN_REASON_MINOR_MMC} + SHTDN_REASON_MINOR_TERMSRV = $00000020; + {$EXTERNALSYM SHTDN_REASON_MINOR_TERMSRV} + SHTDN_REASON_MINOR_DC_PROMOTION = $00000021; + {$EXTERNALSYM SHTDN_REASON_MINOR_DC_PROMOTION} + SHTDN_REASON_MINOR_DC_DEMOTION = $00000022; + {$EXTERNALSYM SHTDN_REASON_MINOR_DC_DEMOTION} + + SHTDN_REASON_UNKNOWN = SHTDN_REASON_MINOR_NONE; + {$EXTERNALSYM SHTDN_REASON_UNKNOWN} + SHTDN_REASON_LEGACY_API = (SHTDN_REASON_MAJOR_LEGACY_API or SHTDN_REASON_FLAG_PLANNED); + {$EXTERNALSYM SHTDN_REASON_LEGACY_API} + +// This mask cuts out UI flags. + + SHTDN_REASON_VALID_BIT_MASK = DWORD($c0ffffff); + {$EXTERNALSYM SHTDN_REASON_VALID_BIT_MASK} + +// Convenience flags. + + PCLEANUI = (SHTDN_REASON_FLAG_PLANNED or SHTDN_REASON_FLAG_CLEAN_UI); + {$EXTERNALSYM PCLEANUI} + UCLEANUI = (SHTDN_REASON_FLAG_CLEAN_UI); + {$EXTERNALSYM UCLEANUI} + PDIRTYUI = (SHTDN_REASON_FLAG_PLANNED or SHTDN_REASON_FLAG_DIRTY_UI); + {$EXTERNALSYM PDIRTYUI} + UDIRTYUI = (SHTDN_REASON_FLAG_DIRTY_UI); + {$EXTERNALSYM UDIRTYUI} + +const + CSIDL_LOCAL_APPDATA = $001C; { \Local Settings\Application Data (non roaming) } + CSIDL_COMMON_APPDATA = $0023; { All Users\Application Data } + CSIDL_WINDOWS = $0024; { GetWindowsDirectory() } + CSIDL_SYSTEM = $0025; { GetSystemDirectory() } + CSIDL_PROGRAM_FILES = $0026; { C:\Program Files } + CSIDL_MYPICTURES = $0027; { C:\Program Files\My Pictures } + CSIDL_PROFILE = $0028; { USERPROFILE } + CSIDL_PROGRAM_FILESX86 = $002A; { C:\Program Files (x86)\My Pictures } + CSIDL_PROGRAM_FILES_COMMON = $002B; { C:\Program Files\Common } + CSIDL_COMMON_TEMPLATES = $002D; { All Users\Templates } + CSIDL_COMMON_DOCUMENTS = $002E; { All Users\Documents } + CSIDL_COMMON_ADMINTOOLS = $002F; { All Users\Start Menu\Programs\Administrative Tools } + CSIDL_ADMINTOOLS = $0030; { \Start Menu\Programs\Administrative Tools } + CSIDL_CONNECTIONS = $0031; { Network and Dial-up Connections } + CSIDL_COMMON_MUSIC = $0035; { All Users\My Music } + CSIDL_COMMON_PICTURES = $0036; { All Users\My Pictures } + CSIDL_COMMON_VIDEO = $0037; { All Users\My Video } + CSIDL_RESOURCES = $0038; { Resource Direcotry } + CSIDL_RESOURCES_LOCALIZED = $0039; { Localized Resource Direcotry } + CSIDL_COMMON_OEM_LINKS = $003A; { Links to All Users OEM specific apps } + CSIDL_CDBURN_AREA = $003B; { USERPROFILE\Local Settings\Application Data\Microsoft\CD Burning } + CSIDL_COMPUTERSNEARME = $003D; { Computers Near Me (computered from Workgroup membership) } + + {$EXTERNALSYM CSIDL_LOCAL_APPDATA} + {$EXTERNALSYM CSIDL_COMMON_APPDATA} + {$EXTERNALSYM CSIDL_WINDOWS} + {$EXTERNALSYM CSIDL_SYSTEM} + {$EXTERNALSYM CSIDL_PROGRAM_FILES} + {$EXTERNALSYM CSIDL_MYPICTURES} + {$EXTERNALSYM CSIDL_PROFILE} + {$EXTERNALSYM CSIDL_PROGRAM_FILESX86} + {$EXTERNALSYM CSIDL_PROGRAM_FILES_COMMON} + {$EXTERNALSYM CSIDL_COMMON_TEMPLATES} + {$EXTERNALSYM CSIDL_COMMON_DOCUMENTS} + {$EXTERNALSYM CSIDL_COMMON_ADMINTOOLS} + {$EXTERNALSYM CSIDL_ADMINTOOLS} + {$EXTERNALSYM CSIDL_CONNECTIONS} + {$EXTERNALSYM CSIDL_COMMON_MUSIC} + {$EXTERNALSYM CSIDL_COMMON_PICTURES} + {$EXTERNALSYM CSIDL_COMMON_VIDEO} + {$EXTERNALSYM CSIDL_RESOURCES} + {$EXTERNALSYM CSIDL_RESOURCES_LOCALIZED} + {$EXTERNALSYM CSIDL_COMMON_OEM_LINKS} + {$EXTERNALSYM CSIDL_CDBURN_AREA} + {$EXTERNALSYM CSIDL_COMPUTERSNEARME} + +type + ITaskbarList = interface(IUnknown) + ['{56FDF342-FD6D-11D0-958A-006097C9A090}'] + function HrInit: HRESULT; stdcall; + function AddTab(hwnd: HWND): HRESULT; stdcall; + function DeleteTab(hwnd: HWND): HRESULT; stdcall; + function ActivateTab(hwnd: HWND): HRESULT; stdcall; + function SetActiveAlt(hwnd: HWND): HRESULT; stdcall; + end; + {$EXTERNALSYM ITaskbarList} + + ITaskbarList2 = interface(ITaskbarList) + ['{602D4995-B13A-429B-A66E-1935E44F4317}'] + function MarkFullscreenWindow(hwnd: HWND; fFullscreen: BOOL): HRESULT; stdcall; + end; + {$EXTERNALSYM ITaskbarList2} + +type + THUMBBUTTON = record + dwMask: DWORD; + iId: UINT; + iBitmap: UINT; + hIcon: HICON; + szTip: packed array[0..259] of WCHAR; + dwFlags: DWORD; + end; + {$EXTERNALSYM THUMBBUTTON} + tagTHUMBBUTTON = THUMBBUTTON; + {$EXTERNALSYM tagTHUMBBUTTON} + TThumbButton = THUMBBUTTON; + {$EXTERNALSYM TThumbButton} + PThumbButton = ^TThumbButton; + {$EXTERNALSYM PThumbButton} + +// for ThumbButtons.dwFlags +const + THBF_ENABLED = $0000; + {$EXTERNALSYM THBF_ENABLED} + THBF_DISABLED = $0001; + {$EXTERNALSYM THBF_DISABLED} + THBF_DISMISSONCLICK = $0002; + {$EXTERNALSYM THBF_DISMISSONCLICK} + THBF_NOBACKGROUND = $0004; + {$EXTERNALSYM THBF_NOBACKGROUND} + THBF_HIDDEN = $0008; + {$EXTERNALSYM THBF_HIDDEN} + THBF_NONINTERACTIVE = $0010; + {$EXTERNALSYM THBF_NONINTERACTIVE} + +// for ThumbButton.dwMask +const + THB_BITMAP = $0001; + {$EXTERNALSYM THB_BITMAP} + THB_ICON = $0002; + {$EXTERNALSYM THB_ICON} + THB_TOOLTIP = $0004; + {$EXTERNALSYM THB_TOOLTIP} + THB_FLAGS = $0008; + {$EXTERNALSYM THB_FLAGS} + +// wParam for WM_COMMAND message (lParam = Button ID) +const + THBN_CLICKED = $1800; + {$EXTERNALSYM THBN_CLICKED} + +// for ITaskBarList3.SetProgressState +const + TBPF_NOPROGRESS = 0; + {$EXTERNALSYM TBPF_NOPROGRESS} + TBPF_INDETERMINATE = $1; + {$EXTERNALSYM TBPF_INDETERMINATE} + TBPF_NORMAL = $2; + {$EXTERNALSYM TBPF_NORMAL} + TBPF_ERROR = $4; + {$EXTERNALSYM TBPF_ERROR} + TBPF_PAUSED = $8; + {$EXTERNALSYM TBPF_PAUSED} + +type + ITaskbarList3 = interface(ITaskbarList2) + ['{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}'] + function SetProgressValue(hwnd: HWND; ullCompleted: ULONGLONG; + ullTotal: ULONGLONG): HRESULT; stdcall; + function SetProgressState(hwnd: HWND; tbpFlags: Integer): HRESULT; stdcall; + function RegisterTab(hwndTab: HWND; hwndMDI: HWND): HRESULT; stdcall; + function UnregisterTab(hwndTab: HWND): HRESULT; stdcall; + function SetTabOrder(hwndTab: HWND; hwndInsertBefore: HWND): HRESULT; stdcall; + function SetTabActive(hwndTab: HWND; hwndMDI: HWND; + tbatFlags: Integer): HRESULT; stdcall; + function ThumbBarAddButtons(hwnd: HWND; cButtons: UINT; + pButton: PThumbButton): HRESULT; stdcall; + function ThumbBarUpdateButtons(hwnd: HWND; cButtons: UINT; + pButton: PThumbButton): HRESULT; stdcall; + function ThumbBarSetImageList(hwnd: HWND; himl: THandle): HRESULT; stdcall; + function SetOverlayIcon(hwnd: HWND; hIcon: HICON; + pszDescription: LPCWSTR): HRESULT; stdcall; + function SetThumbnailTooltip(hwnd: HWND; pszTip: LPCWSTR): HRESULT; stdcall; + function SetThumbnailClip(hwnd: HWND; var prcClip: TRect): HRESULT; stdcall; + end; + {$EXTERNALSYM ITaskbarList3} + +type + STPFLAG = Integer; + {$EXTERNALSYM STPFLAG} +const + STPF_NONE = 0; + {$EXTERNALSYM STPF_NONE} + STPF_USEAPPTHUMBNAILALWAYS = $1; + {$EXTERNALSYM STPF_USEAPPTHUMBNAILALWAYS} + STPF_USEAPPTHUMBNAILWHENACTIVE = $2; + {$EXTERNALSYM STPF_USEAPPTHUMBNAILWHENACTIVE} + STPF_USEAPPPEEKALWAYS = $4; + {$EXTERNALSYM STPF_USEAPPPEEKALWAYS} + STPF_USEAPPPEEKWHENACTIVE = $8; + {$EXTERNALSYM STPF_USEAPPPEEKWHENACTIVE} + +type + ITaskbarList4 = interface(ITaskbarList3) + ['{C43DC798-95D1-4BEA-9030-BB99E2983A1A}'] + function SetTabProperties(hwndTab: HWND; stpFlags: STPFLAG): HRESULT; stdcall; + end; + {$EXTERNALSYM ITaskbarList4} + +const + CLSID_TaskbarList: TGUID = '{56FDF344-FD6D-11d0-958A-006097C9A090}'; + {$EXTERNALSYM CLSID_TaskbarList} + + +{ TODO BCB-compatibility} + +const + DLLVER_PLATFORM_WINDOWS = $00000001; + {$EXTERNALSYM DLLVER_PLATFORM_WINDOWS} + DLLVER_PLATFORM_NT = $00000002; + {$EXTERNALSYM DLLVER_PLATFORM_NT} + +type + PDllVersionInfo = ^TDllVersionInfo; + _DLLVERSIONINFO = packed record + cbSize: DWORD; + dwMajorVersion: DWORD; + dwMinorVersion: DWORD; + dwBuildNumber: DWORD; + dwPlatformId: DWORD; + end; + {$EXTERNALSYM _DLLVERSIONINFO} + TDllVersionInfo = _DLLVERSIONINFO; + DLLVERSIONINFO = _DLLVERSIONINFO; + {$EXTERNALSYM DLLVERSIONINFO} + + +// JwaWinError +// line 22146 + +const + +// +// Task Scheduler errors +// +// +// MessageId: SCHED_S_TASK_READY +// +// MessageText: +// +// The task is ready to run at its next scheduled time. +// + SCHED_S_TASK_READY = HRESULT($00041300); + {$EXTERNALSYM SCHED_S_TASK_READY} + +// +// MessageId: SCHED_S_TASK_RUNNING +// +// MessageText: +// +// The task is currently running. +// + SCHED_S_TASK_RUNNING = HRESULT($00041301); + {$EXTERNALSYM SCHED_S_TASK_RUNNING} + +// +// MessageId: SCHED_S_TASK_DISABLED +// +// MessageText: +// +// The task will not run at the scheduled times because it has been disabled. +// + SCHED_S_TASK_DISABLED = HRESULT($00041302); + {$EXTERNALSYM SCHED_S_TASK_DISABLED} + +// +// MessageId: SCHED_S_TASK_HAS_NOT_RUN +// +// MessageText: +// +// The task has not yet run. +// + SCHED_S_TASK_HAS_NOT_RUN = HRESULT($00041303); + {$EXTERNALSYM SCHED_S_TASK_HAS_NOT_RUN} + +// +// MessageId: SCHED_S_TASK_NO_MORE_RUNS +// +// MessageText: +// +// There are no more runs scheduled for this task. +// + SCHED_S_TASK_NO_MORE_RUNS = HRESULT($00041304); + {$EXTERNALSYM SCHED_S_TASK_NO_MORE_RUNS} + +// +// MessageId: SCHED_S_TASK_NOT_SCHEDULED +// +// MessageText: +// +// One or more of the properties that are needed to run this task on a schedule have not been set. +// + SCHED_S_TASK_NOT_SCHEDULED = HRESULT($00041305); + {$EXTERNALSYM SCHED_S_TASK_NOT_SCHEDULED} + +// +// MessageId: SCHED_S_TASK_TERMINATED +// +// MessageText: +// +// The last run of the task was terminated by the user. +// + SCHED_S_TASK_TERMINATED = HRESULT($00041306); + {$EXTERNALSYM SCHED_S_TASK_TERMINATED} + +// +// MessageId: SCHED_S_TASK_NO_VALID_TRIGGERS +// +// MessageText: +// +// Either the task has no triggers or the existing triggers are disabled or not set. +// + SCHED_S_TASK_NO_VALID_TRIGGERS = HRESULT($00041307); + {$EXTERNALSYM SCHED_S_TASK_NO_VALID_TRIGGERS} + +// +// MessageId: SCHED_S_EVENT_TRIGGER +// +// MessageText: +// +// Event triggers don't have set run times. +// + SCHED_S_EVENT_TRIGGER = HRESULT($00041308); + {$EXTERNALSYM SCHED_S_EVENT_TRIGGER} + +// +// MessageId: SCHED_E_TRIGGER_NOT_FOUND +// +// MessageText: +// +// Trigger not found. +// + SCHED_E_TRIGGER_NOT_FOUND = HRESULT($80041309); + {$EXTERNALSYM SCHED_E_TRIGGER_NOT_FOUND} + +// +// MessageId: SCHED_E_TASK_NOT_READY +// +// MessageText: +// +// One or more of the properties that are needed to run this task have not been set. +// + SCHED_E_TASK_NOT_READY = HRESULT($8004130A); + {$EXTERNALSYM SCHED_E_TASK_NOT_READY} + +// +// MessageId: SCHED_E_TASK_NOT_RUNNING +// +// MessageText: +// +// There is no running instance of the task to terminate. +// + SCHED_E_TASK_NOT_RUNNING = HRESULT($8004130B); + {$EXTERNALSYM SCHED_E_TASK_NOT_RUNNING} + +// +// MessageId: SCHED_E_SERVICE_NOT_INSTALLED +// +// MessageText: +// +// The Task Scheduler Service is not installed on this computer. +// + SCHED_E_SERVICE_NOT_INSTALLED = HRESULT($8004130C); + {$EXTERNALSYM SCHED_E_SERVICE_NOT_INSTALLED} + +// +// MessageId: SCHED_E_CANNOT_OPEN_TASK +// +// MessageText: +// +// The task object could not be opened. +// + SCHED_E_CANNOT_OPEN_TASK = HRESULT($8004130D); + {$EXTERNALSYM SCHED_E_CANNOT_OPEN_TASK} + +// +// MessageId: SCHED_E_INVALID_TASK +// +// MessageText: +// +// The object is either an invalid task object or is not a task object. +// + SCHED_E_INVALID_TASK = HRESULT($8004130E); + {$EXTERNALSYM SCHED_E_INVALID_TASK} + +// +// MessageId: SCHED_E_ACCOUNT_INFORMATION_NOT_SET +// +// MessageText: +// +// No account information could be found in the Task Scheduler security database for the task indicated. +// + SCHED_E_ACCOUNT_INFORMATION_NOT_SET = HRESULT($8004130F); + {$EXTERNALSYM SCHED_E_ACCOUNT_INFORMATION_NOT_SET} + +// +// MessageId: SCHED_E_ACCOUNT_NAME_NOT_FOUND +// +// MessageText: +// +// Unable to establish existence of the account specified. +// + SCHED_E_ACCOUNT_NAME_NOT_FOUND = HRESULT($80041310); + {$EXTERNALSYM SCHED_E_ACCOUNT_NAME_NOT_FOUND} + +// +// MessageId: SCHED_E_ACCOUNT_DBASE_CORRUPT +// +// MessageText: +// +// Corruption was detected in the Task Scheduler security database; the database has been reset. +// + SCHED_E_ACCOUNT_DBASE_CORRUPT = HRESULT($80041311); + {$EXTERNALSYM SCHED_E_ACCOUNT_DBASE_CORRUPT} + +// +// MessageId: SCHED_E_NO_SECURITY_SERVICES +// +// MessageText: +// +// Task Scheduler security services are available only on Windows NT. +// + SCHED_E_NO_SECURITY_SERVICES = HRESULT($80041312); + {$EXTERNALSYM SCHED_E_NO_SECURITY_SERVICES} + +// +// MessageId: SCHED_E_UNKNOWN_OBJECT_VERSION +// +// MessageText: +// +// The task object version is either unsupported or invalid. +// + SCHED_E_UNKNOWN_OBJECT_VERSION = HRESULT($80041313); + {$EXTERNALSYM SCHED_E_UNKNOWN_OBJECT_VERSION} + +// +// MessageId: SCHED_E_UNSUPPORTED_ACCOUNT_OPTION +// +// MessageText: +// +// The task has been configured with an unsupported combination of account settings and run time options. +// + SCHED_E_UNSUPPORTED_ACCOUNT_OPTION = HRESULT($80041314); + {$EXTERNALSYM SCHED_E_UNSUPPORTED_ACCOUNT_OPTION} + +// +// MessageId: SCHED_E_SERVICE_NOT_RUNNING +// +// MessageText: +// +// The Task Scheduler Service is not running. +// + SCHED_E_SERVICE_NOT_RUNNING = HRESULT($80041315); + {$EXTERNALSYM SCHED_E_SERVICE_NOT_RUNNING} + + +// line 151 + +// +// Define the various device type values. Note that values used by Microsoft +// Corporation are in the range 0-32767, and 32768-65535 are reserved for use +// by customers. +// + +type + DEVICE_TYPE = DWORD; + {$EXTERNALSYM DEVICE_TYPE} + +const + FILE_DEVICE_BEEP = $00000001; + {$EXTERNALSYM FILE_DEVICE_BEEP} + FILE_DEVICE_CD_ROM = $00000002; + {$EXTERNALSYM FILE_DEVICE_CD_ROM} + FILE_DEVICE_CD_ROM_FILE_SYSTEM = $00000003; + {$EXTERNALSYM FILE_DEVICE_CD_ROM_FILE_SYSTEM} + FILE_DEVICE_CONTROLLER = $00000004; + {$EXTERNALSYM FILE_DEVICE_CONTROLLER} + FILE_DEVICE_DATALINK = $00000005; + {$EXTERNALSYM FILE_DEVICE_DATALINK} + FILE_DEVICE_DFS = $00000006; + {$EXTERNALSYM FILE_DEVICE_DFS} + FILE_DEVICE_DISK = $00000007; + {$EXTERNALSYM FILE_DEVICE_DISK} + FILE_DEVICE_DISK_FILE_SYSTEM = $00000008; + {$EXTERNALSYM FILE_DEVICE_DISK_FILE_SYSTEM} + FILE_DEVICE_FILE_SYSTEM = $00000009; + {$EXTERNALSYM FILE_DEVICE_FILE_SYSTEM} + FILE_DEVICE_INPORT_PORT = $0000000a; + {$EXTERNALSYM FILE_DEVICE_INPORT_PORT} + FILE_DEVICE_KEYBOARD = $0000000b; + {$EXTERNALSYM FILE_DEVICE_KEYBOARD} + FILE_DEVICE_MAILSLOT = $0000000c; + {$EXTERNALSYM FILE_DEVICE_MAILSLOT} + FILE_DEVICE_MIDI_IN = $0000000d; + {$EXTERNALSYM FILE_DEVICE_MIDI_IN} + FILE_DEVICE_MIDI_OUT = $0000000e; + {$EXTERNALSYM FILE_DEVICE_MIDI_OUT} + FILE_DEVICE_MOUSE = $0000000f; + {$EXTERNALSYM FILE_DEVICE_MOUSE} + FILE_DEVICE_MULTI_UNC_PROVIDER = $00000010; + {$EXTERNALSYM FILE_DEVICE_MULTI_UNC_PROVIDER} + FILE_DEVICE_NAMED_PIPE = $00000011; + {$EXTERNALSYM FILE_DEVICE_NAMED_PIPE} + FILE_DEVICE_NETWORK = $00000012; + {$EXTERNALSYM FILE_DEVICE_NETWORK} + FILE_DEVICE_NETWORK_BROWSER = $00000013; + {$EXTERNALSYM FILE_DEVICE_NETWORK_BROWSER} + FILE_DEVICE_NETWORK_FILE_SYSTEM = $00000014; + {$EXTERNALSYM FILE_DEVICE_NETWORK_FILE_SYSTEM} + FILE_DEVICE_NULL = $00000015; + {$EXTERNALSYM FILE_DEVICE_NULL} + FILE_DEVICE_PARALLEL_PORT = $00000016; + {$EXTERNALSYM FILE_DEVICE_PARALLEL_PORT} + FILE_DEVICE_PHYSICAL_NETCARD = $00000017; + {$EXTERNALSYM FILE_DEVICE_PHYSICAL_NETCARD} + FILE_DEVICE_PRINTER = $00000018; + {$EXTERNALSYM FILE_DEVICE_PRINTER} + FILE_DEVICE_SCANNER = $00000019; + {$EXTERNALSYM FILE_DEVICE_SCANNER} + FILE_DEVICE_SERIAL_MOUSE_PORT = $0000001a; + {$EXTERNALSYM FILE_DEVICE_SERIAL_MOUSE_PORT} + FILE_DEVICE_SERIAL_PORT = $0000001b; + {$EXTERNALSYM FILE_DEVICE_SERIAL_PORT} + FILE_DEVICE_SCREEN = $0000001c; + {$EXTERNALSYM FILE_DEVICE_SCREEN} + FILE_DEVICE_SOUND = $0000001d; + {$EXTERNALSYM FILE_DEVICE_SOUND} + FILE_DEVICE_STREAMS = $0000001e; + {$EXTERNALSYM FILE_DEVICE_STREAMS} + FILE_DEVICE_TAPE = $0000001f; + {$EXTERNALSYM FILE_DEVICE_TAPE} + FILE_DEVICE_TAPE_FILE_SYSTEM = $00000020; + {$EXTERNALSYM FILE_DEVICE_TAPE_FILE_SYSTEM} + FILE_DEVICE_TRANSPORT = $00000021; + {$EXTERNALSYM FILE_DEVICE_TRANSPORT} + FILE_DEVICE_UNKNOWN = $00000022; + {$EXTERNALSYM FILE_DEVICE_UNKNOWN} + FILE_DEVICE_VIDEO = $00000023; + {$EXTERNALSYM FILE_DEVICE_VIDEO} + FILE_DEVICE_VIRTUAL_DISK = $00000024; + {$EXTERNALSYM FILE_DEVICE_VIRTUAL_DISK} + FILE_DEVICE_WAVE_IN = $00000025; + {$EXTERNALSYM FILE_DEVICE_WAVE_IN} + FILE_DEVICE_WAVE_OUT = $00000026; + {$EXTERNALSYM FILE_DEVICE_WAVE_OUT} + FILE_DEVICE_8042_PORT = $00000027; + {$EXTERNALSYM FILE_DEVICE_8042_PORT} + FILE_DEVICE_NETWORK_REDIRECTOR = $00000028; + {$EXTERNALSYM FILE_DEVICE_NETWORK_REDIRECTOR} + FILE_DEVICE_BATTERY = $00000029; + {$EXTERNALSYM FILE_DEVICE_BATTERY} + FILE_DEVICE_BUS_EXTENDER = $0000002a; + {$EXTERNALSYM FILE_DEVICE_BUS_EXTENDER} + FILE_DEVICE_MODEM = $0000002b; + {$EXTERNALSYM FILE_DEVICE_MODEM} + FILE_DEVICE_VDM = $0000002c; + {$EXTERNALSYM FILE_DEVICE_VDM} + FILE_DEVICE_MASS_STORAGE = $0000002d; + {$EXTERNALSYM FILE_DEVICE_MASS_STORAGE} + FILE_DEVICE_SMB = $0000002e; + {$EXTERNALSYM FILE_DEVICE_SMB} + FILE_DEVICE_KS = $0000002f; + {$EXTERNALSYM FILE_DEVICE_KS} + FILE_DEVICE_CHANGER = $00000030; + {$EXTERNALSYM FILE_DEVICE_CHANGER} + FILE_DEVICE_SMARTCARD = $00000031; + {$EXTERNALSYM FILE_DEVICE_SMARTCARD} + FILE_DEVICE_ACPI = $00000032; + {$EXTERNALSYM FILE_DEVICE_ACPI} + FILE_DEVICE_DVD = $00000033; + {$EXTERNALSYM FILE_DEVICE_DVD} + FILE_DEVICE_FULLSCREEN_VIDEO = $00000034; + {$EXTERNALSYM FILE_DEVICE_FULLSCREEN_VIDEO} + FILE_DEVICE_DFS_FILE_SYSTEM = $00000035; + {$EXTERNALSYM FILE_DEVICE_DFS_FILE_SYSTEM} + FILE_DEVICE_DFS_VOLUME = $00000036; + {$EXTERNALSYM FILE_DEVICE_DFS_VOLUME} + FILE_DEVICE_SERENUM = $00000037; + {$EXTERNALSYM FILE_DEVICE_SERENUM} + FILE_DEVICE_TERMSRV = $00000038; + {$EXTERNALSYM FILE_DEVICE_TERMSRV} + FILE_DEVICE_KSEC = $00000039; + {$EXTERNALSYM FILE_DEVICE_KSEC} + FILE_DEVICE_FIPS = $0000003A; + {$EXTERNALSYM FILE_DEVICE_FIPS} + FILE_DEVICE_INFINIBAND = $0000003B; + {$EXTERNALSYM FILE_DEVICE_INFINIBAND} + +// line 297 + +// +// Define the method codes for how buffers are passed for I/O and FS controls +// + +const + METHOD_BUFFERED = 0; + {$EXTERNALSYM METHOD_BUFFERED} + METHOD_IN_DIRECT = 1; + {$EXTERNALSYM METHOD_IN_DIRECT} + METHOD_OUT_DIRECT = 2; + {$EXTERNALSYM METHOD_OUT_DIRECT} + METHOD_NEITHER = 3; + {$EXTERNALSYM METHOD_NEITHER} + +// +// Define some easier to comprehend aliases: +// METHOD_DIRECT_TO_HARDWARE (writes, aka METHOD_IN_DIRECT) +// METHOD_DIRECT_FROM_HARDWARE (reads, aka METHOD_OUT_DIRECT) +// + + METHOD_DIRECT_TO_HARDWARE = METHOD_IN_DIRECT; + {$EXTERNALSYM METHOD_DIRECT_TO_HARDWARE} + METHOD_DIRECT_FROM_HARDWARE = METHOD_OUT_DIRECT; + {$EXTERNALSYM METHOD_DIRECT_FROM_HARDWARE} + +// +// Define the access check value for any access +// +// +// The FILE_READ_ACCESS and FILE_WRITE_ACCESS constants are also defined in +// ntioapi.h as FILE_READ_DATA and FILE_WRITE_DATA. The values for these +// constants *MUST* always be in sync. +// +// +// FILE_SPECIAL_ACCESS is checked by the NT I/O system the same as FILE_ANY_ACCESS. +// The file systems, however, may add additional access checks for I/O and FS controls +// that use this value. +// + +const + FILE_ANY_ACCESS = 0; + {$EXTERNALSYM FILE_ANY_ACCESS} + FILE_SPECIAL_ACCESS = FILE_ANY_ACCESS; + {$EXTERNALSYM FILE_SPECIAL_ACCESS} + FILE_READ_ACCESS = $0001; // file & pipe + {$EXTERNALSYM FILE_READ_ACCESS} + FILE_WRITE_ACCESS = $0002; // file & pipe + {$EXTERNALSYM FILE_WRITE_ACCESS} + +// line 3425 + +// +// The following is a list of the native file system fsctls followed by +// additional network file system fsctls. Some values have been +// decommissioned. +// + +const + + FSCTL_REQUEST_OPLOCK_LEVEL_1 = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (0 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_REQUEST_OPLOCK_LEVEL_1} + + FSCTL_REQUEST_OPLOCK_LEVEL_2 = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (1 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_REQUEST_OPLOCK_LEVEL_2} + + FSCTL_REQUEST_BATCH_OPLOCK = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (2 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_REQUEST_BATCH_OPLOCK} + + FSCTL_OPLOCK_BREAK_ACKNOWLEDGE = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (3 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_OPLOCK_BREAK_ACKNOWLEDGE} + + FSCTL_OPBATCH_ACK_CLOSE_PENDING = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (4 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_OPBATCH_ACK_CLOSE_PENDING} + + FSCTL_OPLOCK_BREAK_NOTIFY = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (5 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_OPLOCK_BREAK_NOTIFY} + + FSCTL_LOCK_VOLUME = ((FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or (6 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_LOCK_VOLUME} + + FSCTL_UNLOCK_VOLUME = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (7 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_UNLOCK_VOLUME} + + FSCTL_DISMOUNT_VOLUME = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (8 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_DISMOUNT_VOLUME} + +// decommissioned fsctl value 9 + + FSCTL_IS_VOLUME_MOUNTED = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (10 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_IS_VOLUME_MOUNTED} + + FSCTL_IS_PATHNAME_VALID = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (11 shl 2) or METHOD_BUFFERED); // PATHNAME_BUFFER, + {$EXTERNALSYM FSCTL_IS_PATHNAME_VALID} + + FSCTL_MARK_VOLUME_DIRTY = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (12 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_MARK_VOLUME_DIRTY} + +// decommissioned fsctl value 13 + + FSCTL_QUERY_RETRIEVAL_POINTERS = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (14 shl 2) or METHOD_NEITHER); + {$EXTERNALSYM FSCTL_QUERY_RETRIEVAL_POINTERS} + + FSCTL_GET_COMPRESSION = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (15 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_GET_COMPRESSION} + + FSCTL_SET_COMPRESSION = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or ((FILE_READ_DATA or FILE_WRITE_DATA) shl 14) or + (16 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_SET_COMPRESSION} + +// decommissioned fsctl value 17 +// decommissioned fsctl value 18 + + FSCTL_MARK_AS_SYSTEM_HIVE = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (19 shl 2) or METHOD_NEITHER); + {$EXTERNALSYM FSCTL_MARK_AS_SYSTEM_HIVE} + + FSCTL_OPLOCK_BREAK_ACK_NO_2 = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (20 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_OPLOCK_BREAK_ACK_NO_2} + + FSCTL_INVALIDATE_VOLUMES = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (21 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_INVALIDATE_VOLUMES} + + FSCTL_QUERY_FAT_BPB = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (22 shl 2) or METHOD_BUFFERED); // FSCTL_QUERY_FAT_BPB_BUFFER + {$EXTERNALSYM FSCTL_QUERY_FAT_BPB} + + FSCTL_REQUEST_FILTER_OPLOCK = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (23 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_REQUEST_FILTER_OPLOCK} + + FSCTL_FILESYSTEM_GET_STATISTICS = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (24 shl 2) or METHOD_BUFFERED); // FILESYSTEM_STATISTICS + {$EXTERNALSYM FSCTL_FILESYSTEM_GET_STATISTICS} + + FSCTL_GET_NTFS_VOLUME_DATA = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (25 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_GET_NTFS_VOLUME_DATA} + + FSCTL_GET_NTFS_FILE_RECORD = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (26 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_GET_NTFS_FILE_RECORD} + + FSCTL_GET_VOLUME_BITMAP = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (27 shl 2) or METHOD_NEITHER); + {$EXTERNALSYM FSCTL_GET_VOLUME_BITMAP} + + FSCTL_GET_RETRIEVAL_POINTERS = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (28 shl 2) or METHOD_NEITHER); + {$EXTERNALSYM FSCTL_GET_RETRIEVAL_POINTERS} + + FSCTL_MOVE_FILE = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_SPECIAL_ACCESS shl 14) or + (29 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_MOVE_FILE} + + FSCTL_IS_VOLUME_DIRTY = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (30 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_IS_VOLUME_DIRTY} + +// decomissioned fsctl value 31 +(* FSCTL_GET_HFS_INFORMATION = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (31 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_GET_HFS_INFORMATION} +*) + + FSCTL_ALLOW_EXTENDED_DASD_IO = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (32 shl 2) or METHOD_NEITHER); + {$EXTERNALSYM FSCTL_ALLOW_EXTENDED_DASD_IO} + +// decommissioned fsctl value 33 +// decommissioned fsctl value 34 + +(* + FSCTL_READ_PROPERTY_DATA = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (33 shl 2) or METHOD_NEITHER); + {$EXTERNALSYM FSCTL_READ_PROPERTY_DATA} + + FSCTL_WRITE_PROPERTY_DATA = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (34 shl 2) or METHOD_NEITHER); + {$EXTERNALSYM FSCTL_WRITE_PROPERTY_DATA} +*) + + FSCTL_FIND_FILES_BY_SID = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (35 shl 2) or METHOD_NEITHER); + {$EXTERNALSYM FSCTL_FIND_FILES_BY_SID} + +// decommissioned fsctl value 36 +// decommissioned fsctl value 37 + +(* FSCTL_DUMP_PROPERTY_DATA = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (37 shl 2) or METHOD_NEITHER); + {$EXTERNALSYM FSCTL_DUMP_PROPERTY_DATA} +*) + + FSCTL_SET_OBJECT_ID = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_SPECIAL_ACCESS shl 14) or + (38 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_SET_OBJECT_ID} + + FSCTL_GET_OBJECT_ID = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (39 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_GET_OBJECT_ID} + + FSCTL_DELETE_OBJECT_ID = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_SPECIAL_ACCESS shl 14) or + (40 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_DELETE_OBJECT_ID} + + FSCTL_SET_REPARSE_POINT = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_SPECIAL_ACCESS shl 14) or + (41 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_SET_REPARSE_POINT} + + FSCTL_GET_REPARSE_POINT = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (42 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_GET_REPARSE_POINT} + + FSCTL_DELETE_REPARSE_POINT = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_SPECIAL_ACCESS shl 14) or + (43 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_DELETE_REPARSE_POINT} + + FSCTL_ENUM_USN_DATA = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (44 shl 2) or METHOD_NEITHER); + {$EXTERNALSYM FSCTL_ENUM_USN_DATA} + + FSCTL_SECURITY_ID_CHECK = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_READ_DATA shl 14) or + (45 shl 2) or METHOD_NEITHER); + {$EXTERNALSYM FSCTL_SECURITY_ID_CHECK} + + FSCTL_READ_USN_JOURNAL = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (46 shl 2) or METHOD_NEITHER); + {$EXTERNALSYM FSCTL_READ_USN_JOURNAL} + + FSCTL_SET_OBJECT_ID_EXTENDED = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_SPECIAL_ACCESS shl 14) or + (47 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_SET_OBJECT_ID_EXTENDED} + + FSCTL_CREATE_OR_GET_OBJECT_ID = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (48 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_CREATE_OR_GET_OBJECT_ID} + + FSCTL_SET_SPARSE = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_SPECIAL_ACCESS shl 14) or + (49 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_SET_SPARSE} + + FSCTL_SET_ZERO_DATA = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_WRITE_DATA shl 14) or + (50 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_SET_ZERO_DATA} + + FSCTL_QUERY_ALLOCATED_RANGES = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_READ_DATA shl 14) or + (51 shl 2) or METHOD_NEITHER); + {$EXTERNALSYM FSCTL_QUERY_ALLOCATED_RANGES} + +// decommissioned fsctl value 52 +(* + FSCTL_ENABLE_UPGRADE = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_WRITE_DATA shl 14) or + (52 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_ENABLE_UPGRADE} +*) + + FSCTL_SET_ENCRYPTION = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (53 shl 2) or METHOD_NEITHER); + {$EXTERNALSYM FSCTL_SET_ENCRYPTION} + + FSCTL_ENCRYPTION_FSCTL_IO = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (54 shl 2) or METHOD_NEITHER); + {$EXTERNALSYM FSCTL_ENCRYPTION_FSCTL_IO} + + FSCTL_WRITE_RAW_ENCRYPTED = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_SPECIAL_ACCESS shl 14) or + (55 shl 2) or METHOD_NEITHER); + {$EXTERNALSYM FSCTL_WRITE_RAW_ENCRYPTED} + + FSCTL_READ_RAW_ENCRYPTED = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_SPECIAL_ACCESS shl 14) or + (56 shl 2) or METHOD_NEITHER); + {$EXTERNALSYM FSCTL_READ_RAW_ENCRYPTED} + + FSCTL_CREATE_USN_JOURNAL = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (57 shl 2) or METHOD_NEITHER); + {$EXTERNALSYM FSCTL_CREATE_USN_JOURNAL} + + FSCTL_READ_FILE_USN_DATA = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (58 shl 2) or METHOD_NEITHER); + {$EXTERNALSYM FSCTL_READ_FILE_USN_DATA} + + FSCTL_WRITE_USN_CLOSE_RECORD = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (59 shl 2) or METHOD_NEITHER); + {$EXTERNALSYM FSCTL_WRITE_USN_CLOSE_RECORD} + + FSCTL_EXTEND_VOLUME = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (60 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_EXTEND_VOLUME} + + FSCTL_QUERY_USN_JOURNAL = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (61 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_QUERY_USN_JOURNAL} + + FSCTL_DELETE_USN_JOURNAL = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (62 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_DELETE_USN_JOURNAL} + + FSCTL_MARK_HANDLE = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (63 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_MARK_HANDLE} + + FSCTL_SIS_COPYFILE = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (64 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_SIS_COPYFILE} + + FSCTL_SIS_LINK_FILES = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or ((FILE_READ_DATA or FILE_WRITE_DATA) shl 14) or + (65 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_SIS_LINK_FILES} + + FSCTL_HSM_MSG = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or ((FILE_READ_DATA or FILE_WRITE_DATA) shl 14) or + (66 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_HSM_MSG} + +// decommissioned fsctl value 67 +(* + FSCTL_NSS_CONTROL = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_WRITE_DATA shl 14) or + (67 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_NSS_CONTROL} +*) + + FSCTL_HSM_DATA = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or ((FILE_READ_DATA or FILE_WRITE_DATA) shl 14) or + (68 shl 2) or METHOD_NEITHER); + {$EXTERNALSYM FSCTL_HSM_DATA} + + FSCTL_RECALL_FILE = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or + (69 shl 2) or METHOD_NEITHER); + {$EXTERNALSYM FSCTL_RECALL_FILE} + +// decommissioned fsctl value 70 +(* + FSCTL_NSS_RCONTROL = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_READ_DATA shl 14) or + (70 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_NSS_RCONTROL} +*) + + FSCTL_READ_FROM_PLEX = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_READ_DATA shl 14) or + (71 shl 2) or METHOD_OUT_DIRECT); + {$EXTERNALSYM FSCTL_READ_FROM_PLEX} + + FSCTL_FILE_PREFETCH = ( + (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_SPECIAL_ACCESS shl 14) or + (72 shl 2) or METHOD_BUFFERED); + {$EXTERNALSYM FSCTL_FILE_PREFETCH} + +// line 4553 + +// +// Structure for FSCTL_SET_ZERO_DATA +// + +type + + PFILE_ZERO_DATA_INFORMATION = ^FILE_ZERO_DATA_INFORMATION; + {$EXTERNALSYM PFILE_ZERO_DATA_INFORMATION} + _FILE_ZERO_DATA_INFORMATION = record + FileOffset: LARGE_INTEGER; + BeyondFinalZero: LARGE_INTEGER; + end; + {$EXTERNALSYM _FILE_ZERO_DATA_INFORMATION} + FILE_ZERO_DATA_INFORMATION = _FILE_ZERO_DATA_INFORMATION; + {$EXTERNALSYM FILE_ZERO_DATA_INFORMATION} + TFileZeroDataInformation = FILE_ZERO_DATA_INFORMATION; + PFileZeroDataInformation = PFILE_ZERO_DATA_INFORMATION; + +// +// Structure for FSCTL_QUERY_ALLOCATED_RANGES +// + +// +// Querying the allocated ranges requires an output buffer to store the +// allocated ranges and an input buffer to specify the range to query. +// The input buffer contains a single entry, the output buffer is an +// array of the following structure. +// + + PFILE_ALLOCATED_RANGE_BUFFER = ^FILE_ALLOCATED_RANGE_BUFFER; + {$EXTERNALSYM PFILE_ALLOCATED_RANGE_BUFFER} + _FILE_ALLOCATED_RANGE_BUFFER = record + FileOffset: LARGE_INTEGER; + Length: LARGE_INTEGER; + end; + {$EXTERNALSYM _FILE_ALLOCATED_RANGE_BUFFER} + FILE_ALLOCATED_RANGE_BUFFER = _FILE_ALLOCATED_RANGE_BUFFER; + {$EXTERNALSYM FILE_ALLOCATED_RANGE_BUFFER} + TFileAllocatedRangeBuffer = FILE_ALLOCATED_RANGE_BUFFER; + PFileAllocatedRangeBuffer = PFILE_ALLOCATED_RANGE_BUFFER; + + +// line 340 + +// +// Code Page Default Values. +// + +const + CP_ACP = 0; // default to ANSI code page + {$EXTERNALSYM CP_ACP} + CP_OEMCP = 1; // default to OEM code page + {$EXTERNALSYM CP_OEMCP} + CP_MACCP = 2; // default to MAC code page + {$EXTERNALSYM CP_MACCP} + CP_THREAD_ACP = 3; // current thread's ANSI code page + {$EXTERNALSYM CP_THREAD_ACP} + CP_SYMBOL = 42; // SYMBOL translations + {$EXTERNALSYM CP_SYMBOL} + + CP_UTF7 = 65000; // UTF-7 translation + {$EXTERNALSYM CP_UTF7} + CP_UTF8 = 65001; // UTF-8 translation + {$EXTERNALSYM CP_UTF8} + +// line 597 + +const + +// +// The following LCTypes may be used in combination with any other LCTypes. +// +// LOCALE_NOUSEROVERRIDE is also used in GetTimeFormat and +// GetDateFormat. +// +// LOCALE_USE_CP_ACP is used in many of the A (Ansi) apis that need +// to do string translation. +// +// LOCALE_RETURN_NUMBER will return the result from GetLocaleInfo as a +// number instead of a string. This flag is only valid for the LCTypes +// beginning with LOCALE_I. +// + + LOCALE_NOUSEROVERRIDE = DWORD($80000000); // do not use user overrides + {$EXTERNALSYM LOCALE_NOUSEROVERRIDE} + LOCALE_USE_CP_ACP = $40000000; // use the system ACP + {$EXTERNALSYM LOCALE_USE_CP_ACP} + + LOCALE_RETURN_NUMBER = $20000000; // return number instead of string + {$EXTERNALSYM LOCALE_RETURN_NUMBER} + +// line 841 + +const + LOCALE_IDEFAULTEBCDICCODEPAGE = $00001012; // default ebcdic code page + {$EXTERNALSYM LOCALE_IDEFAULTEBCDICCODEPAGE} + LOCALE_IPAPERSIZE = $0000100A; // 1 = letter, 5 = legal, 8 = a3, 9 = a4 + {$EXTERNALSYM LOCALE_IPAPERSIZE} + LOCALE_SENGCURRNAME = $00001007; // english name of currency + {$EXTERNALSYM LOCALE_SENGCURRNAME} + LOCALE_SNATIVECURRNAME = $00001008; // native name of currency + {$EXTERNALSYM LOCALE_SNATIVECURRNAME} + LOCALE_SYEARMONTH = $00001006; // year month format string + {$EXTERNALSYM LOCALE_SYEARMONTH} + LOCALE_SSORTNAME = $00001013; // sort name + {$EXTERNALSYM LOCALE_SSORTNAME} + LOCALE_IDIGITSUBSTITUTION = $00001014; // 0 = context, 1 = none, 2 = national + {$EXTERNALSYM LOCALE_IDIGITSUBSTITUTION} + +// line 880 + + DATE_YEARMONTH = $00000008; // use year month picture + {$EXTERNALSYM DATE_YEARMONTH} + DATE_LTRREADING = $00000010; // add marks for left to right reading order layout + {$EXTERNALSYM DATE_LTRREADING} + DATE_RTLREADING = $00000020; // add marks for right to left reading order layout + {$EXTERNALSYM DATE_RTLREADING} + +// +// Calendar Types. +// +// These types are used for the EnumCalendarInfo and GetCalendarInfo +// NLS API routines. +// Some of these types are also used for the SetCalendarInfo NLS API +// routine. +// + +// +// The following CalTypes may be used in combination with any other CalTypes. +// +// CAL_NOUSEROVERRIDE +// +// CAL_USE_CP_ACP is used in the A (Ansi) apis that need to do string +// translation. +// +// CAL_RETURN_NUMBER will return the result from GetCalendarInfo as a +// number instead of a string. This flag is only valid for the CalTypes +// beginning with CAL_I. +// + + CAL_NOUSEROVERRIDE = LOCALE_NOUSEROVERRIDE; // do not use user overrides + {$EXTERNALSYM CAL_NOUSEROVERRIDE} + CAL_USE_CP_ACP = LOCALE_USE_CP_ACP; // use the system ACP + {$EXTERNALSYM CAL_USE_CP_ACP} + CAL_RETURN_NUMBER = LOCALE_RETURN_NUMBER; // return number instead of string + {$EXTERNALSYM CAL_RETURN_NUMBER} + +// line 1014 + + CAL_SYEARMONTH = $0000002f; // year month format string + {$EXTERNALSYM CAL_SYEARMONTH} + CAL_ITWODIGITYEARMAX = $00000030; // two digit year max + {$EXTERNALSYM CAL_ITWODIGITYEARMAX} + +// line 1424 + +type + CALINFO_ENUMPROCEXW = function (lpCalendarInfoString: LPWSTR; Calendar: CALID): BOOL; stdcall; + {$EXTERNALSYM CALINFO_ENUMPROCEXW} + TCalInfoEnumProcExW = CALINFO_ENUMPROCEXW; + +// line 1635 + + +function GetCalendarInfoA(Locale: LCID; Calendar: CALID; CalType: CALTYPE; + lpCalData: LPSTR; cchData: Integer; lpValue: LPDWORD): Integer; stdcall; +{$EXTERNALSYM GetCalendarInfoA} +function GetCalendarInfoW(Locale: LCID; Calendar: CALID; CalType: CALTYPE; + lpCalData: LPWSTR; cchData: Integer; lpValue: LPDWORD): Integer; stdcall; +{$EXTERNALSYM GetCalendarInfoW} + +// line 1754 + +function EnumCalendarInfoExW(lpCalInfoEnumProcEx: CALINFO_ENUMPROCEXW; + Locale: LCID; Calendar: CALID; CalType: CALTYPE): BOOL; stdcall; +{$EXTERNALSYM EnumCalendarInfoExW} + + +{$IFNDEF FPC} +type + MAKEINTRESOURCEA = LPSTR; + {$EXTERNALSYM MAKEINTRESOURCEA} + MAKEINTRESOURCEW = LPWSTR; + {$EXTERNALSYM MAKEINTRESOURCEW} +{$IFDEF SUPPORTS_UNICODE} + MAKEINTRESOURCE = MAKEINTRESOURCEW; + {$EXTERNALSYM MAKEINTRESOURCE} +{$ELSE ~SUPPORTS_UNICODE} + MAKEINTRESOURCE = MAKEINTRESOURCEA; + {$EXTERNALSYM MAKEINTRESOURCE} +{$ENDIF ~SUPPORTS_UNICODE} +{$ENDIF ~FPC} + +// +// Predefined Resource Types +// + +const + RT_CURSOR = MAKEINTRESOURCE(1); + {$EXTERNALSYM RT_CURSOR} + RT_BITMAP = MAKEINTRESOURCE(2); + {$EXTERNALSYM RT_BITMAP} + RT_ICON = MAKEINTRESOURCE(3); + {$EXTERNALSYM RT_ICON} + RT_MENU = MAKEINTRESOURCE(4); + {$EXTERNALSYM RT_MENU} + RT_DIALOG = MAKEINTRESOURCE(5); + {$EXTERNALSYM RT_DIALOG} + RT_STRING = MAKEINTRESOURCE(6); + {$EXTERNALSYM RT_STRING} + RT_FONTDIR = MAKEINTRESOURCE(7); + {$EXTERNALSYM RT_FONTDIR} + RT_FONT = MAKEINTRESOURCE(8); + {$EXTERNALSYM RT_FONT} + RT_ACCELERATOR = MAKEINTRESOURCE(9); + {$EXTERNALSYM RT_ACCELERATOR} + RT_RCDATA = MAKEINTRESOURCE(10); + {$EXTERNALSYM RT_RCDATA} + RT_MESSAGETABLE = MAKEINTRESOURCE(11); + {$EXTERNALSYM RT_MESSAGETABLE} + + DIFFERENCE = 11; + {$EXTERNALSYM DIFFERENCE} + + RT_GROUP_CURSOR = MAKEINTRESOURCE(ULONG_PTR(RT_CURSOR) + DIFFERENCE); + {$EXTERNALSYM RT_GROUP_CURSOR} + RT_GROUP_ICON = MAKEINTRESOURCE(ULONG_PTR(RT_ICON) + DIFFERENCE); + {$EXTERNALSYM RT_GROUP_ICON} + RT_VERSION = MAKEINTRESOURCE(16); + {$EXTERNALSYM RT_VERSION} + RT_DLGINCLUDE = MAKEINTRESOURCE(17); + {$EXTERNALSYM RT_DLGINCLUDE} + RT_PLUGPLAY = MAKEINTRESOURCE(19); + {$EXTERNALSYM RT_PLUGPLAY} + RT_VXD = MAKEINTRESOURCE(20); + {$EXTERNALSYM RT_VXD} + RT_ANICURSOR = MAKEINTRESOURCE(21); + {$EXTERNALSYM RT_ANICURSOR} + RT_ANIICON = MAKEINTRESOURCE(22); + {$EXTERNALSYM RT_ANIICON} + RT_HTML = MAKEINTRESOURCE(23); + {$EXTERNALSYM RT_HTML} + RT_MANIFEST = MAKEINTRESOURCE(24); + CREATEPROCESS_MANIFEST_RESOURCE_ID = MAKEINTRESOURCE(1); + {$EXTERNALSYM CREATEPROCESS_MANIFEST_RESOURCE_ID} + ISOLATIONAWARE_MANIFEST_RESOURCE_ID = MAKEINTRESOURCE(2); + {$EXTERNALSYM ISOLATIONAWARE_MANIFEST_RESOURCE_ID} + ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID = MAKEINTRESOURCE(3); + {$EXTERNALSYM ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID} + MINIMUM_RESERVED_MANIFEST_RESOURCE_ID = MAKEINTRESOURCE(1{inclusive}); + {$EXTERNALSYM MINIMUM_RESERVED_MANIFEST_RESOURCE_ID} + MAXIMUM_RESERVED_MANIFEST_RESOURCE_ID = MAKEINTRESOURCE(16{inclusive}); + {$EXTERNALSYM MAXIMUM_RESERVED_MANIFEST_RESOURCE_ID} + +// line 1451 + + KLF_SETFORPROCESS = $00000100; + {$EXTERNALSYM KLF_SETFORPROCESS} + KLF_SHIFTLOCK = $00010000; + {$EXTERNALSYM KLF_SHIFTLOCK} + KLF_RESET = $40000000; + {$EXTERNALSYM KLF_RESET} + +// 64 compatible version of GetWindowLong and SetWindowLong + +const + GWLP_WNDPROC = -4; + {$EXTERNALSYM GWLP_WNDPROC} + GWLP_HINSTANCE = -6; + {$EXTERNALSYM GWLP_HINSTANCE} + GWLP_HWNDPARENT = -8; + {$EXTERNALSYM GWLP_HWNDPARENT} + GWLP_USERDATA = -21; + {$EXTERNALSYM GWLP_USERDATA} + GWLP_ID = -12; + {$EXTERNALSYM GWLP_ID} + +{$EXTERNALSYM GetWindowLongPtr} +function GetWindowLongPtr(hWnd: HWND; nIndex: Integer): TJclAddr; stdcall; +{$EXTERNALSYM SetWindowLongPtr} +function SetWindowLongPtr(hWnd: HWND; nIndex: Integer; dwNewLong: TJclAddr): Longint; stdcall; + +function IsPwrSuspendAllowed: BOOL; stdcall; +function IsPwrHibernateAllowed: BOOL; stdcall; +function IsPwrShutdownAllowed: BOOL; stdcall; +function SetSuspendState(Hibernate, ForceCritical, DisableWakeEvent: BOOL): BOOL; stdcall; + +type + // Microsoft version (64 bit SDK) + {$EXTERNALSYM RVA} + RVA = DWORD; + + // 64-bit PE + {$EXTERNALSYM ImgDelayDescrV2} + ImgDelayDescrV2 = packed record + grAttrs: DWORD; // attributes + rvaDLLName: RVA; // RVA to dll name + rvaHmod: RVA; // RVA of module handle + rvaIAT: RVA; // RVA of the IAT + rvaINT: RVA; // RVA of the INT + rvaBoundIAT: RVA; // RVA of the optional bound IAT + rvaUnloadIAT: RVA; // RVA of optional copy of original IAT + dwTimeStamp: DWORD; // 0 if not bound, + // O.W. date/time stamp of DLL bound to (Old BIND) + end; + {$EXTERNALSYM TImgDelayDescrV2} + TImgDelayDescrV2 = ImgDelayDescrV2; + {$EXTERNALSYM PImgDelayDescrV2} + PImgDelayDescrV2 = ^ImgDelayDescrV2; + + {$EXTERNALSYM PHMODULE} + PHMODULE = ^HMODULE; + + // 32-bit PE + {$EXTERNALSYM ImgDelayDescrV1} + ImgDelayDescrV1 = packed record + grAttrs: DWORD; // attributes + szName: LPCSTR; // pointer to dll name + phmod: PHMODULE; // address of module handle + pIAT: PImageThunkData32; // address of the IAT + pINT: PImageThunkData32; // address of the INT + pBoundIAT: PImageThunkData32; // address of the optional bound IAT + pUnloadIAT: PImageThunkData32; // address of optional copy of original IAT + dwTimeStamp: DWORD; // 0 if not bound, + // O.W. date/time stamp of DLL bound to (Old BIND) + end; + {$EXTERNALSYM TImgDelayDescrV1} + TImgDelayDescrV1 = ImgDelayDescrV1; + {$EXTERNALSYM PImgDelayDescrV1} + PImgDelayDescrV1 = ^ImgDelayDescrV1; + + //{$EXTERNALSYM PImgDelayDescr} + //PImgDelayDescr = ImgDelayDescr; + //TImgDelayDescr = ImgDelayDescr; + +// msidefs.h line 349 + +// PIDs given specific meanings for Installer + +const + PID_MSIVERSION = $0000000E; // integer, Installer version number (major*100+minor) + {$EXTERNALSYM PID_MSIVERSION} + PID_MSISOURCE = $0000000F; // integer, type of file image, short/long, media/tree + {$EXTERNALSYM PID_MSISOURCE} + PID_MSIRESTRICT = $00000010; // integer, transform restrictions + {$EXTERNALSYM PID_MSIRESTRICT} + + +// shlguid.h line 404 + +const + FMTID_ShellDetails: TGUID = '{28636aa6-953d-11d2-b5d6-00c04fd918d0}'; + {$EXTERNALSYM FMTID_ShellDetails} + + PID_FINDDATA = 0; + {$EXTERNALSYM PID_FINDDATA} + PID_NETRESOURCE = 1; + {$EXTERNALSYM PID_NETRESOURCE} + PID_DESCRIPTIONID = 2; + {$EXTERNALSYM PID_DESCRIPTIONID} + PID_WHICHFOLDER = 3; + {$EXTERNALSYM PID_WHICHFOLDER} + PID_NETWORKLOCATION = 4; + {$EXTERNALSYM PID_NETWORKLOCATION} + PID_COMPUTERNAME = 5; + {$EXTERNALSYM PID_COMPUTERNAME} + +// PSGUID_STORAGE comes from ntquery.h +const + FMTID_Storage: TGUID = '{b725f130-47ef-101a-a5f1-02608c9eebac}'; + {$EXTERNALSYM FMTID_Storage} + +// Image properties +const + FMTID_ImageProperties: TGUID = '{14b81da1-0135-4d31-96d9-6cbfc9671a99}'; + {$EXTERNALSYM FMTID_ImageProperties} + +// The GUIDs used to identify shell item attributes (columns). See IShellFolder2::GetDetailsEx implementations... + +const + FMTID_Displaced: TGUID = '{9B174B33-40FF-11d2-A27E-00C04FC30871}'; + {$EXTERNALSYM FMTID_Displaced} + PID_DISPLACED_FROM = 2; + {$EXTERNALSYM PID_DISPLACED_FROM} + PID_DISPLACED_DATE = 3; + {$EXTERNALSYM PID_DISPLACED_DATE} + +const + FMTID_Briefcase: TGUID = '{328D8B21-7729-4bfc-954C-902B329D56B0}'; + {$EXTERNALSYM FMTID_Briefcase} + PID_SYNC_COPY_IN = 2; + {$EXTERNALSYM PID_SYNC_COPY_IN} + +const + FMTID_Misc: TGUID = '{9B174B34-40FF-11d2-A27E-00C04FC30871}'; + {$EXTERNALSYM FMTID_Misc} + PID_MISC_STATUS = 2; + {$EXTERNALSYM PID_MISC_STATUS} + PID_MISC_ACCESSCOUNT = 3; + {$EXTERNALSYM PID_MISC_ACCESSCOUNT} + PID_MISC_OWNER = 4; + {$EXTERNALSYM PID_MISC_OWNER} + PID_HTMLINFOTIPFILE = 5; + {$EXTERNALSYM PID_HTMLINFOTIPFILE} + PID_MISC_PICS = 6; + {$EXTERNALSYM PID_MISC_PICS} + +const + FMTID_WebView: TGUID = '{F2275480-F782-4291-BD94-F13693513AEC}'; + {$EXTERNALSYM FMTID_WebView} + PID_DISPLAY_PROPERTIES = 0; + {$EXTERNALSYM PID_DISPLAY_PROPERTIES} + PID_INTROTEXT = 1; + {$EXTERNALSYM PID_INTROTEXT} + +const + FMTID_MUSIC: TGUID = '{56A3372E-CE9C-11d2-9F0E-006097C686F6}'; + {$EXTERNALSYM FMTID_MUSIC} + PIDSI_ARTIST = 2; + {$EXTERNALSYM PIDSI_ARTIST} + PIDSI_SONGTITLE = 3; + {$EXTERNALSYM PIDSI_SONGTITLE} + PIDSI_ALBUM = 4; + {$EXTERNALSYM PIDSI_ALBUM} + PIDSI_YEAR = 5; + {$EXTERNALSYM PIDSI_YEAR} + PIDSI_COMMENT = 6; + {$EXTERNALSYM PIDSI_COMMENT} + PIDSI_TRACK = 7; + {$EXTERNALSYM PIDSI_TRACK} + PIDSI_GENRE = 11; + {$EXTERNALSYM PIDSI_GENRE} + PIDSI_LYRICS = 12; + {$EXTERNALSYM PIDSI_LYRICS} + +const + FMTID_DRM: TGUID = '{AEAC19E4-89AE-4508-B9B7-BB867ABEE2ED}'; + {$EXTERNALSYM FMTID_DRM} + PIDDRSI_PROTECTED = 2; + {$EXTERNALSYM PIDDRSI_PROTECTED} + PIDDRSI_DESCRIPTION = 3; + {$EXTERNALSYM PIDDRSI_DESCRIPTION} + PIDDRSI_PLAYCOUNT = 4; + {$EXTERNALSYM PIDDRSI_PLAYCOUNT} + PIDDRSI_PLAYSTARTS = 5; + {$EXTERNALSYM PIDDRSI_PLAYSTARTS} + PIDDRSI_PLAYEXPIRES = 6; + {$EXTERNALSYM PIDDRSI_PLAYEXPIRES} + +// FMTID_VideoSummaryInformation property identifiers +const + FMTID_Video: TGUID = '{64440491-4c8b-11d1-8b70-080036b11a03}'; + {$EXTERNALSYM FMTID_Video} + PIDVSI_STREAM_NAME = $00000002; // "StreamName", VT_LPWSTR + {$EXTERNALSYM PIDVSI_STREAM_NAME} + PIDVSI_FRAME_WIDTH = $00000003; // "FrameWidth", VT_UI4 + {$EXTERNALSYM PIDVSI_FRAME_WIDTH} + PIDVSI_FRAME_HEIGHT = $00000004; // "FrameHeight", VT_UI4 + {$EXTERNALSYM PIDVSI_FRAME_HEIGHT} + PIDVSI_TIMELENGTH = $00000007; // "TimeLength", VT_UI4, milliseconds + {$EXTERNALSYM PIDVSI_TIMELENGTH} + PIDVSI_FRAME_COUNT = $00000005; // "FrameCount". VT_UI4 + {$EXTERNALSYM PIDVSI_FRAME_COUNT} + PIDVSI_FRAME_RATE = $00000006; // "FrameRate", VT_UI4, frames/millisecond + {$EXTERNALSYM PIDVSI_FRAME_RATE} + PIDVSI_DATA_RATE = $00000008; // "DataRate", VT_UI4, bytes/second + {$EXTERNALSYM PIDVSI_DATA_RATE} + PIDVSI_SAMPLE_SIZE = $00000009; // "SampleSize", VT_UI4 + {$EXTERNALSYM PIDVSI_SAMPLE_SIZE} + PIDVSI_COMPRESSION = $0000000A; // "Compression", VT_LPWSTR + {$EXTERNALSYM PIDVSI_COMPRESSION} + PIDVSI_STREAM_NUMBER = $0000000B; // "StreamNumber", VT_UI2 + {$EXTERNALSYM PIDVSI_STREAM_NUMBER} + +// FMTID_AudioSummaryInformation property identifiers +const + FMTID_Audio: TGUID = '{64440490-4c8b-11d1-8b70-080036b11a03}'; + {$EXTERNALSYM FMTID_Audio} + PIDASI_FORMAT = $00000002; // VT_BSTR + {$EXTERNALSYM PIDASI_FORMAT} + PIDASI_TIMELENGTH = $00000003; // VT_UI4, milliseconds + {$EXTERNALSYM PIDASI_TIMELENGTH} + PIDASI_AVG_DATA_RATE = $00000004; // VT_UI4, Hz + {$EXTERNALSYM PIDASI_AVG_DATA_RATE} + PIDASI_SAMPLE_RATE = $00000005; // VT_UI4, bits + {$EXTERNALSYM PIDASI_SAMPLE_RATE} + PIDASI_SAMPLE_SIZE = $00000006; // VT_UI4, bits + {$EXTERNALSYM PIDASI_SAMPLE_SIZE} + PIDASI_CHANNEL_COUNT = $00000007; // VT_UI4 + {$EXTERNALSYM PIDASI_CHANNEL_COUNT} + PIDASI_STREAM_NUMBER = $00000008; // VT_UI2 + {$EXTERNALSYM PIDASI_STREAM_NUMBER} + PIDASI_STREAM_NAME = $00000009; // VT_LPWSTR + {$EXTERNALSYM PIDASI_STREAM_NAME} + PIDASI_COMPRESSION = $0000000A; // VT_LPWSTR + {$EXTERNALSYM PIDASI_COMPRESSION} + +const + FMTID_ControlPanel: TGUID = '{305CA226-D286-468e-B848-2B2E8E697B74}'; + {$EXTERNALSYM FMTID_ControlPanel} + PID_CONTROLPANEL_CATEGORY = 2; + {$EXTERNALSYM PID_CONTROLPANEL_CATEGORY} + +const + FMTID_Volume: TGUID = '{9B174B35-40FF-11d2-A27E-00C04FC30871}'; + {$EXTERNALSYM FMTID_Volume} + PID_VOLUME_FREE = 2; + {$EXTERNALSYM PID_VOLUME_FREE} + PID_VOLUME_CAPACITY = 3; + {$EXTERNALSYM PID_VOLUME_CAPACITY} + PID_VOLUME_FILESYSTEM = 4; + {$EXTERNALSYM PID_VOLUME_FILESYSTEM} + +const + FMTID_Share: TGUID = '{D8C3986F-813B-449c-845D-87B95D674ADE}'; + {$EXTERNALSYM FMTID_Share} + PID_SHARE_CSC_STATUS = 2; + {$EXTERNALSYM PID_SHARE_CSC_STATUS} + +const + FMTID_Link: TGUID = '{B9B4B3FC-2B51-4a42-B5D8-324146AFCF25}'; + {$EXTERNALSYM FMTID_Link} + PID_LINK_TARGET = 2; + {$EXTERNALSYM PID_LINK_TARGET} + +const + FMTID_Query: TGUID = '{49691c90-7e17-101a-a91c-08002b2ecda9}'; + {$EXTERNALSYM FMTID_Query} + PID_QUERY_RANK = 2; + {$EXTERNALSYM PID_QUERY_RANK} + +const + FMTID_SummaryInformation: TGUID = '{f29f85e0-4ff9-1068-ab91-08002b27b3d9}'; + {$EXTERNALSYM FMTID_SummaryInformation} + FMTID_DocumentSummaryInformation: TGUID = '{d5cdd502-2e9c-101b-9397-08002b2cf9ae}'; + {$EXTERNALSYM FMTID_DocumentSummaryInformation} + FMTID_MediaFileSummaryInformation: TGUID = '{64440492-4c8b-11d1-8b70-080036b11a03}'; + {$EXTERNALSYM FMTID_MediaFileSummaryInformation} + FMTID_ImageSummaryInformation: TGUID = '{6444048f-4c8b-11d1-8b70-080036b11a03}'; + {$EXTERNALSYM FMTID_ImageSummaryInformation} + +// imgguids.h line 75 + +// Property sets +const + FMTID_ImageInformation: TGUID = '{e5836cbe-5eef-4f1d-acde-ae4c43b608ce}'; + {$EXTERNALSYM FMTID_ImageInformation} + FMTID_JpegAppHeaders: TGUID = '{1c4afdcd-6177-43cf-abc7-5f51af39ee85}'; + {$EXTERNALSYM FMTID_JpegAppHeaders} + + + +// objbase.h line 390 +const + STGFMT_STORAGE = 0; + {$EXTERNALSYM STGFMT_STORAGE} + STGFMT_NATIVE = 1; + {$EXTERNALSYM STGFMT_NATIVE} + STGFMT_FILE = 3; + {$EXTERNALSYM STGFMT_FILE} + STGFMT_ANY = 4; + {$EXTERNALSYM STGFMT_ANY} + STGFMT_DOCFILE = 5; + {$EXTERNALSYM STGFMT_DOCFILE} +// This is a legacy define to allow old component to builds + STGFMT_DOCUMENT = 0; + {$EXTERNALSYM STGFMT_DOCUMENT} + +// objbase.h line 913 + +type + tagSTGOPTIONS = record + usVersion: Word; // Versions 1 and 2 supported + reserved: Word; // must be 0 for padding + ulSectorSize: Cardinal; // docfile header sector size (512) + pwcsTemplateFile: PWideChar; // version 2 or above + end; + {$EXTERNALSYM tagSTGOPTIONS} + STGOPTIONS = tagSTGOPTIONS; + {$EXTERNALSYM STGOPTIONS} + PSTGOPTIONS = ^STGOPTIONS; + {$EXTERNALSYM PSTGOPTIONS} + +function StgCreateStorageEx(const pwcsName: PWideChar; grfMode: DWORD; + stgfmt: DWORD; grfAttrs: DWORD; pStgOptions: PSTGOPTIONS; reserved2: Pointer; + riid: PGUID; out stgOpen: IInterface): HResult; stdcall; +{$EXTERNALSYM StgCreateStorageEx} + +function StgOpenStorageEx(const pwcsName: PWideChar; grfMode: DWORD; + stgfmt: DWORD; grfAttrs: DWORD; pStgOptions: PSTGOPTIONS; reserved2: Pointer; + riid: PGUID; out stgOpen: IInterface): HResult; stdcall; +{$EXTERNALSYM StgOpenStorageEx} + + +// propidl.h line 386 + +// Reserved global Property IDs +const + PID_DICTIONARY = $00000000; // integer count + array of entries + {$EXTERNALSYM PID_DICTIONARY} + PID_CODEPAGE = $00000001; // short integer + {$EXTERNALSYM PID_CODEPAGE} + PID_FIRST_USABLE = $00000002; + {$EXTERNALSYM PID_FIRST_USABLE} + PID_FIRST_NAME_DEFAULT = $00000FFF; + {$EXTERNALSYM PID_FIRST_NAME_DEFAULT} + PID_LOCALE = $80000000; + {$EXTERNALSYM PID_LOCALE} + PID_MODIFY_TIME = $80000001; + {$EXTERNALSYM PID_MODIFY_TIME} + PID_SECURITY = $80000002; + {$EXTERNALSYM PID_SECURITY} + PID_BEHAVIOR = $80000003; + {$EXTERNALSYM PID_BEHAVIOR} + PID_ILLEGAL = $FFFFFFFF; + {$EXTERNALSYM PID_ILLEGAL} + +// Range which is read-only to downlevel implementations + +const + PID_MIN_READONLY = $80000000; + {$EXTERNALSYM PID_MIN_READONLY} + PID_MAX_READONLY = $BFFFFFFF; + {$EXTERNALSYM PID_MAX_READONLY} + +// Property IDs for the DiscardableInformation Property Set + +const + PIDDI_THUMBNAIL = $00000002; // VT_BLOB + {$EXTERNALSYM PIDDI_THUMBNAIL} + +// Property IDs for the SummaryInformation Property Set + +const + PIDSI_TITLE = $00000002; // VT_LPSTR + {$EXTERNALSYM PIDSI_TITLE} + PIDSI_SUBJECT = $00000003; // VT_LPSTR + {$EXTERNALSYM PIDSI_SUBJECT} + PIDSI_AUTHOR = $00000004; // VT_LPSTR + {$EXTERNALSYM PIDSI_AUTHOR} + PIDSI_KEYWORDS = $00000005; // VT_LPSTR + {$EXTERNALSYM PIDSI_KEYWORDS} + PIDSI_COMMENTS = $00000006; // VT_LPSTR + {$EXTERNALSYM PIDSI_COMMENTS} + PIDSI_TEMPLATE = $00000007; // VT_LPSTR + {$EXTERNALSYM PIDSI_TEMPLATE} + PIDSI_LASTAUTHOR = $00000008; // VT_LPSTR + {$EXTERNALSYM PIDSI_LASTAUTHOR} + PIDSI_REVNUMBER = $00000009; // VT_LPSTR + {$EXTERNALSYM PIDSI_REVNUMBER} + PIDSI_EDITTIME = $0000000A; // VT_FILETIME (UTC) + {$EXTERNALSYM PIDSI_EDITTIME} + PIDSI_LASTPRINTED = $0000000B; // VT_FILETIME (UTC) + {$EXTERNALSYM PIDSI_LASTPRINTED} + PIDSI_CREATE_DTM = $0000000C; // VT_FILETIME (UTC) + {$EXTERNALSYM PIDSI_CREATE_DTM} + PIDSI_LASTSAVE_DTM = $0000000D; // VT_FILETIME (UTC) + {$EXTERNALSYM PIDSI_LASTSAVE_DTM} + PIDSI_PAGECOUNT = $0000000E; // VT_I4 + {$EXTERNALSYM PIDSI_PAGECOUNT} + PIDSI_WORDCOUNT = $0000000F; // VT_I4 + {$EXTERNALSYM PIDSI_WORDCOUNT} + PIDSI_CHARCOUNT = $00000010; // VT_I4 + {$EXTERNALSYM PIDSI_CHARCOUNT} + PIDSI_THUMBNAIL = $00000011; // VT_CF + {$EXTERNALSYM PIDSI_THUMBNAIL} + PIDSI_APPNAME = $00000012; // VT_LPSTR + {$EXTERNALSYM PIDSI_APPNAME} + PIDSI_DOC_SECURITY = $00000013; // VT_I4 + {$EXTERNALSYM PIDSI_DOC_SECURITY} + +// Property IDs for the DocSummaryInformation Property Set + +const + PIDDSI_CATEGORY = $00000002; // VT_LPSTR + {$EXTERNALSYM PIDDSI_CATEGORY} + PIDDSI_PRESFORMAT = $00000003; // VT_LPSTR + {$EXTERNALSYM PIDDSI_PRESFORMAT} + PIDDSI_BYTECOUNT = $00000004; // VT_I4 + {$EXTERNALSYM PIDDSI_BYTECOUNT} + PIDDSI_LINECOUNT = $00000005; // VT_I4 + {$EXTERNALSYM PIDDSI_LINECOUNT} + PIDDSI_PARCOUNT = $00000006; // VT_I4 + {$EXTERNALSYM PIDDSI_PARCOUNT} + PIDDSI_SLIDECOUNT = $00000007; // VT_I4 + {$EXTERNALSYM PIDDSI_SLIDECOUNT} + PIDDSI_NOTECOUNT = $00000008; // VT_I4 + {$EXTERNALSYM PIDDSI_NOTECOUNT} + PIDDSI_HIDDENCOUNT = $00000009; // VT_I4 + {$EXTERNALSYM PIDDSI_HIDDENCOUNT} + PIDDSI_MMCLIPCOUNT = $0000000A; // VT_I4 + {$EXTERNALSYM PIDDSI_MMCLIPCOUNT} + PIDDSI_SCALE = $0000000B; // VT_BOOL + {$EXTERNALSYM PIDDSI_SCALE} + PIDDSI_HEADINGPAIR = $0000000C; // VT_VARIANT | VT_VECTOR + {$EXTERNALSYM PIDDSI_HEADINGPAIR} + PIDDSI_DOCPARTS = $0000000D; // VT_LPSTR | VT_VECTOR + {$EXTERNALSYM PIDDSI_DOCPARTS} + PIDDSI_MANAGER = $0000000E; // VT_LPSTR + {$EXTERNALSYM PIDDSI_MANAGER} + PIDDSI_COMPANY = $0000000F; // VT_LPSTR + {$EXTERNALSYM PIDDSI_COMPANY} + PIDDSI_LINKSDIRTY = $00000010; // VT_BOOL + {$EXTERNALSYM PIDDSI_LINKSDIRTY} + +// FMTID_MediaFileSummaryInfo - Property IDs + +const + PIDMSI_EDITOR = $00000002; // VT_LPWSTR + {$EXTERNALSYM PIDMSI_EDITOR} + PIDMSI_SUPPLIER = $00000003; // VT_LPWSTR + {$EXTERNALSYM PIDMSI_SUPPLIER} + PIDMSI_SOURCE = $00000004; // VT_LPWSTR + {$EXTERNALSYM PIDMSI_SOURCE} + PIDMSI_SEQUENCE_NO = $00000005; // VT_LPWSTR + {$EXTERNALSYM PIDMSI_SEQUENCE_NO} + PIDMSI_PROJECT = $00000006; // VT_LPWSTR + {$EXTERNALSYM PIDMSI_PROJECT} + PIDMSI_STATUS = $00000007; // VT_UI4 + {$EXTERNALSYM PIDMSI_STATUS} + PIDMSI_OWNER = $00000008; // VT_LPWSTR + {$EXTERNALSYM PIDMSI_OWNER} + PIDMSI_RATING = $00000009; // VT_LPWSTR + {$EXTERNALSYM PIDMSI_RATING} + PIDMSI_PRODUCTION = $0000000A; // VT_FILETIME (UTC) + {$EXTERNALSYM PIDMSI_PRODUCTION} + PIDMSI_COPYRIGHT = $0000000B; // VT_LPWSTR + {$EXTERNALSYM PIDMSI_COPYRIGHT} + +function PropVariantClear(var Prop: TPropVariant): HResult; stdcall; +{$EXTERNALSYM PropVariantClear} + + +// NtSecApi.h line 566 +type + PLSA_UNICODE_STRING = ^LSA_UNICODE_STRING; + _LSA_UNICODE_STRING = record + Length: USHORT; + MaximumLength: USHORT; + Buffer: {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.LPWSTR; + end; + LSA_UNICODE_STRING = _LSA_UNICODE_STRING; + TLsaUnicodeString = LSA_UNICODE_STRING; + PLsaUnicodeString = PLSA_UNICODE_STRING; + + PLSA_STRING = ^LSA_STRING; + _LSA_STRING = record + Length: USHORT; + MaximumLength: USHORT; + Buffer: PANSICHAR; + end; + LSA_STRING = _LSA_STRING; + TLsaString = LSA_STRING; + PLsaString = PLSA_STRING; + + PLSA_OBJECT_ATTRIBUTES = ^LSA_OBJECT_ATTRIBUTES; + _LSA_OBJECT_ATTRIBUTES = record + Length: ULONG; + RootDirectory: {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.THandle; + ObjectName: PLSA_UNICODE_STRING; + Attributes: ULONG; + SecurityDescriptor: Pointer; // Points to type SECURITY_DESCRIPTOR + SecurityQualityOfService: Pointer; // Points to type SECURITY_QUALITY_OF_SERVICE + end; + LSA_OBJECT_ATTRIBUTES = _LSA_OBJECT_ATTRIBUTES; + TLsaObjectAttributes = _LSA_OBJECT_ATTRIBUTES; + PLsaObjectAttributes = PLSA_OBJECT_ATTRIBUTES; + +// NtSecApi.h line 680 + +//////////////////////////////////////////////////////////////////////////// +// // +// Local Security Policy Administration API datatypes and defines // +// // +//////////////////////////////////////////////////////////////////////////// + +// +// Access types for the Policy object +// + +const + POLICY_VIEW_LOCAL_INFORMATION = $00000001; + {$EXTERNALSYM POLICY_VIEW_LOCAL_INFORMATION} + POLICY_VIEW_AUDIT_INFORMATION = $00000002; + {$EXTERNALSYM POLICY_VIEW_AUDIT_INFORMATION} + POLICY_GET_PRIVATE_INFORMATION = $00000004; + {$EXTERNALSYM POLICY_GET_PRIVATE_INFORMATION} + POLICY_TRUST_ADMIN = $00000008; + {$EXTERNALSYM POLICY_TRUST_ADMIN} + POLICY_CREATE_ACCOUNT = $00000010; + {$EXTERNALSYM POLICY_CREATE_ACCOUNT} + POLICY_CREATE_SECRET = $00000020; + {$EXTERNALSYM POLICY_CREATE_SECRET} + POLICY_CREATE_PRIVILEGE = $00000040; + {$EXTERNALSYM POLICY_CREATE_PRIVILEGE} + POLICY_SET_DEFAULT_QUOTA_LIMITS = $00000080; + {$EXTERNALSYM POLICY_SET_DEFAULT_QUOTA_LIMITS} + POLICY_SET_AUDIT_REQUIREMENTS = $00000100; + {$EXTERNALSYM POLICY_SET_AUDIT_REQUIREMENTS} + POLICY_AUDIT_LOG_ADMIN = $00000200; + {$EXTERNALSYM POLICY_AUDIT_LOG_ADMIN} + POLICY_SERVER_ADMIN = $00000400; + {$EXTERNALSYM POLICY_SERVER_ADMIN} + POLICY_LOOKUP_NAMES = $00000800; + {$EXTERNALSYM POLICY_LOOKUP_NAMES} + POLICY_NOTIFICATION = $00001000; + {$EXTERNALSYM POLICY_NOTIFICATION} + + POLICY_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED or + POLICY_VIEW_LOCAL_INFORMATION or + POLICY_VIEW_AUDIT_INFORMATION or + POLICY_GET_PRIVATE_INFORMATION or + POLICY_TRUST_ADMIN or + POLICY_CREATE_ACCOUNT or + POLICY_CREATE_SECRET or + POLICY_CREATE_PRIVILEGE or + POLICY_SET_DEFAULT_QUOTA_LIMITS or + POLICY_SET_AUDIT_REQUIREMENTS or + POLICY_AUDIT_LOG_ADMIN or + POLICY_SERVER_ADMIN or + POLICY_LOOKUP_NAMES); + {$EXTERNALSYM POLICY_ALL_ACCESS} + + POLICY_READ = (STANDARD_RIGHTS_READ or + POLICY_VIEW_AUDIT_INFORMATION or + POLICY_GET_PRIVATE_INFORMATION); + {$EXTERNALSYM POLICY_READ} + + POLICY_WRITE = (STANDARD_RIGHTS_WRITE or + POLICY_TRUST_ADMIN or + POLICY_CREATE_ACCOUNT or + POLICY_CREATE_SECRET or + POLICY_CREATE_PRIVILEGE or + POLICY_SET_DEFAULT_QUOTA_LIMITS or + POLICY_SET_AUDIT_REQUIREMENTS or + POLICY_AUDIT_LOG_ADMIN or + POLICY_SERVER_ADMIN); + {$EXTERNALSYM POLICY_WRITE} + + POLICY_EXECUTE = (STANDARD_RIGHTS_EXECUTE or + POLICY_VIEW_LOCAL_INFORMATION or + POLICY_LOOKUP_NAMES); + {$EXTERNALSYM POLICY_EXECUTE} + +// NtSecApi.h line 914 +type + _POLICY_INFORMATION_CLASS = ( + picFill0, + PolicyAuditLogInformation, + PolicyAuditEventsInformation, + PolicyPrimaryDomainInformation, + PolicyPdAccountInformation, + PolicyAccountDomainInformation, + PolicyLsaServerRoleInformation, + PolicyReplicaSourceInformation, + PolicyDefaultQuotaInformation, + PolicyModificationInformation, + PolicyAuditFullSetInformation, + PolicyAuditFullQueryInformation, + PolicyDnsDomainInformation, + PolicyDnsDomainInformationInt); + {$EXTERNALSYM _POLICY_INFORMATION_CLASS} + POLICY_INFORMATION_CLASS = _POLICY_INFORMATION_CLASS; + {$EXTERNALSYM POLICY_INFORMATION_CLASS} + PPOLICY_INFORMATION_CLASS = ^POLICY_INFORMATION_CLASS; + {$EXTERNALSYM PPOLICY_INFORMATION_CLASS} + TPolicyInformationClass = POLICY_INFORMATION_CLASS; + {$EXTERNALSYM TPolicyInformationClass} + PPolicyInformationClass = PPOLICY_INFORMATION_CLASS; + {$EXTERNALSYM PPolicyInformationClass} + +// NtSecApi.h line 1031 +// +// The following structure corresponds to the PolicyAccountDomainInformation +// information class. +// +type + PPOLICY_ACCOUNT_DOMAIN_INFO = ^POLICY_ACCOUNT_DOMAIN_INFO; + _POLICY_ACCOUNT_DOMAIN_INFO = record + DomainName: LSA_UNICODE_STRING; + DomainSid: {$IFDEF HAS_UNITSCOPE}Winapi.{$ENDIF}Windows.PSID; + end; + POLICY_ACCOUNT_DOMAIN_INFO = _POLICY_ACCOUNT_DOMAIN_INFO; + TPolicyAccountDomainInfo = POLICY_ACCOUNT_DOMAIN_INFO; + PPolicyAccountDomainInfo = PPOLICY_ACCOUNT_DOMAIN_INFO; + +// NtSecApi.h line 1298 +type + LSA_HANDLE = Pointer; + PLSA_HANDLE = ^LSA_HANDLE; + TLsaHandle = LSA_HANDLE; + +// NtSecApi.h line 1714 +type + NTSTATUS = DWORD; + +function LsaOpenPolicy(SystemName: PLSA_UNICODE_STRING; + var ObjectAttributes: LSA_OBJECT_ATTRIBUTES; DesiredAccess: ACCESS_MASK; + var PolicyHandle: LSA_HANDLE): NTSTATUS; stdcall; +function LsaQueryInformationPolicy(PolicyHandle: LSA_HANDLE; + InformationClass: POLICY_INFORMATION_CLASS; var Buffer: Pointer): NTSTATUS; stdcall; +function LsaFreeMemory(Buffer: Pointer): NTSTATUS; stdcall; +function LsaFreeReturnBuffer(Buffer: Pointer): NTSTATUS; stdcall; +function LsaClose(ObjectHandle: LSA_HANDLE): NTSTATUS; stdcall; +function LsaNtStatusToWinError(Status: NTSTATUS): ULONG; stdcall; + + +// Snapshot function + +function CreateToolhelp32Snapshot(dwFlags, th32ProcessID: DWORD): THandle; stdcall; +{$EXTERNALSYM CreateToolhelp32Snapshot} + +// +// The th32ProcessID argument is only used if TH32CS_SNAPHEAPLIST or +// TH32CS_SNAPMODULE is specified. th32ProcessID == 0 means the current +// process. +// +// NOTE that all of the snapshots are global except for the heap and module +// lists which are process specific. To enumerate the heap or module +// state for all WIN32 processes call with TH32CS_SNAPALL and the +// current process. Then for each process in the TH32CS_SNAPPROCESS +// list that isn't the current process, do a call with just +// TH32CS_SNAPHEAPLIST and/or TH32CS_SNAPMODULE. +// +// dwFlags +// + +const + TH32CS_SNAPHEAPLIST = $00000001; + {$EXTERNALSYM TH32CS_SNAPHEAPLIST} + TH32CS_SNAPPROCESS = $00000002; + {$EXTERNALSYM TH32CS_SNAPPROCESS} + TH32CS_SNAPTHREAD = $00000004; + {$EXTERNALSYM TH32CS_SNAPTHREAD} + TH32CS_SNAPMODULE = $00000008; + {$EXTERNALSYM TH32CS_SNAPMODULE} + TH32CS_SNAPMODULE32 = $00000010; + {$EXTERNALSYM TH32CS_SNAPMODULE32} + TH32CS_SNAPALL = TH32CS_SNAPHEAPLIST or TH32CS_SNAPPROCESS or + TH32CS_SNAPTHREAD or TH32CS_SNAPMODULE; + {$EXTERNALSYM TH32CS_SNAPALL} + TH32CS_INHERIT = $80000000; + {$EXTERNALSYM TH32CS_INHERIT} + +// +// Use CloseHandle to destroy the snapshot +// + +// Thread walking + +type + PTHREADENTRY32 = ^THREADENTRY32; + {$EXTERNALSYM PTHREADENTRY32} + tagTHREADENTRY32 = record + dwSize: DWORD; + cntUsage: DWORD; + th32ThreadID: DWORD; // this thread + th32OwnerProcessID: DWORD; // Process this thread is associated with + tpBasePri: Longint; + tpDeltaPri: Longint; + dwFlags: DWORD; + end; + {$EXTERNALSYM tagTHREADENTRY32} + THREADENTRY32 = tagTHREADENTRY32; + {$EXTERNALSYM THREADENTRY32} + LPTHREADENTRY32 = ^THREADENTRY32; + {$EXTERNALSYM LPTHREADENTRY32} + TThreadEntry32 = THREADENTRY32; + {$EXTERNALSYM TThreadEntry32} + +function Thread32First(hSnapshot: THandle; var lpte: THREADENTRY32): BOOL; stdcall; +{$EXTERNALSYM Thread32First} +function Thread32Next(hSnapshot: THandle; var lpte: THREADENTRY32): BOOL; stdcall; +{$EXTERNALSYM Thread32Next} + + + +type + _THREAD_INFORMATION_CLASS = type Cardinal; + {$EXTERNALSYM _THREAD_INFORMATION_CLASS} + THREAD_INFORMATION_CLASS = _THREAD_INFORMATION_CLASS; + {$EXTERNALSYM THREAD_INFORMATION_CLASS} + PTHREAD_INFORMATION_CLASS = ^_THREAD_INFORMATION_CLASS; + {$EXTERNALSYM PTHREAD_INFORMATION_CLASS} + +const + ThreadBasicInformation = 0; + {$EXTERNALSYM ThreadBasicInformation} + ThreadTimes = 1; + {$EXTERNALSYM ThreadTimes} + ThreadPriority = 2; + {$EXTERNALSYM ThreadPriority} + ThreadBasePriority = 3; + {$EXTERNALSYM ThreadBasePriority} + ThreadAffinityMask = 4; + {$EXTERNALSYM ThreadAffinityMask} + ThreadImpersonationToken = 5; + {$EXTERNALSYM ThreadImpersonationToken} + ThreadDescriptorTableEntry = 6; + {$EXTERNALSYM ThreadDescriptorTableEntry} + ThreadEnableAlignmentFaultFixup = 7; + {$EXTERNALSYM ThreadEnableAlignmentFaultFixup} + ThreadEventPair = 8; + {$EXTERNALSYM ThreadEventPair} + ThreadQuerySetWin32StartAddress = 9; + {$EXTERNALSYM ThreadQuerySetWin32StartAddress} + ThreadZeroTlsCell = 10; + {$EXTERNALSYM ThreadZeroTlsCell} + ThreadPerformanceCount = 11; + {$EXTERNALSYM ThreadPerformanceCount} + ThreadAmILastThread = 12; + {$EXTERNALSYM ThreadAmILastThread} + ThreadIdealProcessor = 13; + {$EXTERNALSYM ThreadIdealProcessor} + ThreadPriorityBoost = 14; + {$EXTERNALSYM ThreadPriorityBoost} + ThreadSetTlsArrayAddress = 15; + {$EXTERNALSYM ThreadSetTlsArrayAddress} + ThreadIsIoPending = 16; + {$EXTERNALSYM ThreadIsIoPending} + ThreadHideFromDebugger = 17; + {$EXTERNALSYM ThreadHideFromDebugger} + +type + _CLIENT_ID = record + UniqueProcess: THandle; + UniqueThread: THandle; + end; + {$EXTERNALSYM _CLIENT_ID} + CLIENT_ID = _CLIENT_ID; + {$EXTERNALSYM CLIENT_ID} + PCLIENT_ID = ^CLIENT_ID; + {$EXTERNALSYM PCLIENT_ID} + + KAFFINITY = ULONG; + {$EXTERNALSYM KAFFINITY} + + KPRIORITY = LongInt; + {$EXTERNALSYM KPRIORITY} + + _THREAD_BASIC_INFORMATION = record + ExitStatus: NTSTATUS; + TebBaseAddress: Pointer; + ClientId: CLIENT_ID; + AffinityMask: KAFFINITY; + Priority: KPRIORITY; + BasePriority: KPRIORITY; + end; + {$EXTERNALSYM _THREAD_BASIC_INFORMATION} + THREAD_BASIC_INFORMATION = _THREAD_BASIC_INFORMATION; + {$EXTERNALSYM THREAD_BASIC_INFORMATION} + PTHREAD_BASIC_INFORMATION = ^_THREAD_BASIC_INFORMATION; + {$EXTERNALSYM PTHREAD_BASIC_INFORMATION} + +function NtQueryInformationThread(ThreadHandle: THandle; ThreadInformationClass: THREAD_INFORMATION_CLASS; + ThreadInformation: Pointer; ThreadInformationLength: ULONG; ReturnLength: PULONG): NTSTATUS; stdcall; +{$EXTERNALSYM NtQueryInformationThread} + + + +//DOM-IGNORE-END + + +const + RtdlSetNamedSecurityInfoW: function(pObjectName: LPWSTR; ObjectType: SE_OBJECT_TYPE; + SecurityInfo: SECURITY_INFORMATION; psidOwner, psidGroup: PSID; + pDacl, pSacl: PACL): DWORD stdcall = SetNamedSecurityInfoW; + + RtdlSetWaitableTimer: function(hTimer: THandle; var lpDueTime: TLargeInteger; + lPeriod: Longint; pfnCompletionRoutine: TFNTimerAPCRoutine; + lpArgToCompletionRoutine: Pointer; fResume: BOOL): BOOL stdcall = SetWaitableTimer; + + RtdlNetUserAdd: function(servername: LPCWSTR; level: DWORD; + buf: PByte; parm_err: PDWord): NET_API_STATUS stdcall = NetUserAdd; + + RtdlNetUserDel: function(servername: LPCWSTR; + username: LPCWSTR): NET_API_STATUS stdcall = NetUserDel; + + RtdlNetGroupAdd: function(servername: LPCWSTR; level: DWORD; buf: PByte; + parm_err: PDWord): NET_API_STATUS stdcall = NetGroupAdd; + + RtdlNetGroupEnum: function(servername: LPCWSTR; level: DWORD; + out bufptr: PByte; prefmaxlen: DWORD; out entriesread, totalentries: DWORD; + resume_handle: PDWORD_PTR): NET_API_STATUS stdcall = NetGroupEnum; + + RtdlNetGroupDel: function(servername: LPCWSTR; + groupname: LPCWSTR): NET_API_STATUS stdcall = NetGroupDel; + + RtdlNetLocalGroupAdd: function(servername: LPCWSTR; level: DWORD; + buf: PByte; parm_err: PDWord): NET_API_STATUS stdcall = NetLocalGroupAdd; + + RtdlNetLocalGroupEnum: function(servername: LPCWSTR; level: DWORD; + out bufptr: PByte; prefmaxlen: DWORD; out entriesread, totalentries: DWORD; + resumehandle: PDWORD_PTR): NET_API_STATUS stdcall = NetLocalGroupEnum; + + RtdlNetLocalGroupDel: function(servername: LPCWSTR; + groupname: LPCWSTR): NET_API_STATUS stdcall = NetLocalGroupDel; + + RtdlNetLocalGroupAddMembers: function(servername: LPCWSTR; groupname: LPCWSTR; + level: DWORD; buf: PByte; + totalentries: DWORD): NET_API_STATUS stdcall = NetLocalGroupAddMembers; + + RtdlNetApiBufferFree: function(Buffer: Pointer): NET_API_STATUS stdcall = NetApiBufferFree; + + RtdlGetCalendarInfoA: function(Locale: LCID; Calendar: CALID; CalType: CALTYPE; + lpCalData: PAnsiChar; cchData: Integer; + lpValue: PDWORD): Integer stdcall = GetCalendarInfoA; + + RtdlGetCalendarInfoW: function(Locale: LCID; Calendar: CALID; CalType: CALTYPE; + lpCalData: PWideChar; cchData: Integer; + lpValue: PDWORD): Integer stdcall = GetCalendarInfoW; + + RtdlEnumCalendarInfoExW: function(lpCalInfoEnumProc: TCalInfoEnumProcExW; + Locale: LCID; Calendar: CALID; CalType: CALTYPE): BOOL stdcall = EnumCalendarInfoExW; + + RtdlGetVolumeNameForVolumeMountPointW: function(lpszVolumeMountPoint: LPCWSTR; + lpszVolumeName: LPWSTR; cchBufferLength: DWORD): BOOL stdcall = GetVolumeNameForVolumeMountPointW; + + RtdlSetVolumeMountPointW: function(lpszVolumeMountPoint: LPCWSTR; + lpszVolumeName: LPCWSTR): BOOL stdcall = SetVolumeMountPointW; + + RtdlDeleteVolumeMountPointW: function(lpszVolumeMountPoint: LPCWSTR): BOOL + stdcall = DeleteVolumeMountPointW; + + RtdlNetBios: function(P: PNCB): UCHAR stdcall = NetBios; + + +{$IFDEF UNITVERSIONING} +const + UnitVersioning: TUnitVersionInfo = ( + RCSfile: '$URL$'; + Revision: '$Revision$'; + Date: '$Date$'; + LogPath: 'JCL\source\windows' + ); +{$ENDIF UNITVERSIONING} + +implementation + +uses + JclResources; + +procedure GetProcedureAddress(var P: Pointer; const ModuleName, ProcName: string); +var + ModuleHandle: HMODULE; +begin + if not Assigned(P) then + begin + ModuleHandle := GetModuleHandle(PChar(ModuleName)); + if ModuleHandle = 0 then + begin + ModuleHandle := SafeLoadLibrary(PChar(ModuleName)); + if ModuleHandle = 0 then + raise EJclError.CreateResFmt(@RsELibraryNotFound, [ModuleName]); + end; + P := GetProcAddress(ModuleHandle, PChar(ProcName)); + if not Assigned(P) then + raise EJclError.CreateResFmt(@RsEFunctionNotFound, [ModuleName, ProcName]); + end; +end; + +//== { EJclWin32Error } ====================================================== + + +constructor EJclWin32Error.Create(const Msg: string); +begin + FLastError := GetLastError; + FLastErrorMsg := SysErrorMessage(FLastError); + inherited CreateResFmt(@RsWin32Error, [FLastErrorMsg, FLastError, NativeLineBreak, Msg]); +end; + +constructor EJclWin32Error.CreateFmt(const Msg: string; const Args: array of const); +begin + FLastError := GetLastError; + FLastErrorMsg := SysErrorMessage(FLastError); + inherited CreateResFmt(@RsWin32Error, [FLastErrorMsg, FLastError, NativeLineBreak, Format(Msg, Args)]); +end; + +constructor EJclWin32Error.CreateRes(Ident: Integer); +begin + FLastError := GetLastError; + FLastErrorMsg := SysErrorMessage(FLastError); + inherited CreateResFmt(@RsWin32Error, [FLastErrorMsg, FLastError, NativeLineBreak, LoadStr(Ident)]); +end; + +constructor EJclWin32Error.CreateRes(ResStringRec: PResStringRec); +begin + FLastError := GetLastError; + FLastErrorMsg := SysErrorMessage(FLastError); + inherited CreateResFmt(@RsWin32Error, [FLastErrorMsg, FLastError, NativeLineBreak, LoadResString(ResStringRec)]); +end; + + + +const + aclapilib = 'advapi32.dll'; + +type + TSetNamedSecurityInfoW = function (pObjectName: LPWSTR; ObjectType: SE_OBJECT_TYPE; + SecurityInfo: SECURITY_INFORMATION; psidOwner, psidGroup: PSID; + pDacl, pSacl: PACL): DWORD; stdcall; + +var + _SetNamedSecurityInfoW: TSetNamedSecurityInfoW = nil; + +function SetNamedSecurityInfoW(pObjectName: LPWSTR; ObjectType: SE_OBJECT_TYPE; + SecurityInfo: SECURITY_INFORMATION; psidOwner, psidGroup: PSID; + pDacl, pSacl: PACL): DWORD; +begin + GetProcedureAddress(Pointer(@_SetNamedSecurityInfoW), aclapilib, 'SetNamedSecurityInfoW'); + Result := _SetNamedSecurityInfoW(pObjectName, ObjectType, SecurityInfo, psidOwner, psidGroup, pDacl, pSacl); +end; + + + +const + ImageHlpLib = 'imagehlp.dll'; + +type + TReBaseImage = function (CurrentImageName: PAnsiChar; SymbolPath: PAnsiChar; fReBase: BOOL; + fRebaseSysfileOk: BOOL; fGoingDown: BOOL; CheckImageSize: ULONG; + var OldImageSize: TJclAddr32; var OldImageBase: TJclAddr; + var NewImageSize: TJclAddr32; var NewImageBase: TJclAddr; TimeStamp: ULONG): BOOL; stdcall; + +var + _ReBaseImage: TReBaseImage = nil; + +function ReBaseImage(CurrentImageName: PAnsiChar; SymbolPath: PAnsiChar; fReBase: BOOL; + fRebaseSysfileOk: BOOL; fGoingDown: BOOL; CheckImageSize: ULONG; + var OldImageSize: TJclAddr32; var OldImageBase: TJclAddr; + var NewImageSize: TJclAddr32; var NewImageBase: TJclAddr; TimeStamp: ULONG): BOOL; +begin + GetProcedureAddress(Pointer(@_ReBaseImage), ImageHlpLib, 'ReBaseImage'); + Result := _ReBaseImage(CurrentImageName, SymbolPath, fReBase, fRebaseSysfileOk, fGoingDown, CheckImageSize, OldImageSize, OldImageBase, NewImageSize, NewImageBase, TimeStamp); +end; + +type + TReBaseImage64 = function (CurrentImageName: PAnsiChar; SymbolPath: PAnsiChar; fReBase: BOOL; + fRebaseSysfileOk: BOOL; fGoingDown: BOOL; CheckImageSize: ULONG; + var OldImageSize: TJclAddr32; var OldImageBase: TJclAddr64; + var NewImageSize: TJclAddr32; var NewImageBase: TJclAddr64; TimeStamp: ULONG): BOOL; stdcall; + +var + _ReBaseImage64: TReBaseImage64 = nil; + +function ReBaseImage64(CurrentImageName: PAnsiChar; SymbolPath: PAnsiChar; fReBase: BOOL; + fRebaseSysfileOk: BOOL; fGoingDown: BOOL; CheckImageSize: ULONG; + var OldImageSize: TJclAddr32; var OldImageBase: TJclAddr64; + var NewImageSize: TJclAddr32; var NewImageBase: TJclAddr64; TimeStamp: ULONG): BOOL; +begin + GetProcedureAddress(Pointer(@_ReBaseImage64), ImageHlpLib, 'ReBaseImage64'); + Result := _ReBaseImage64(CurrentImageName, SymbolPath, fReBase, fRebaseSysfileOk, fGoingDown, CheckImageSize, OldImageSize, OldImageBase, NewImageSize, NewImageBase, TimeStamp); +end; + +type + TCheckSumMappedFile = function (BaseAddress: Pointer; FileLength: DWORD; + out HeaderSum, CheckSum: DWORD): PImageNtHeaders; stdcall; + +var + _CheckSumMappedFile: TCheckSumMappedFile = nil; + +function CheckSumMappedFile(BaseAddress: Pointer; FileLength: DWORD; + out HeaderSum, CheckSum: DWORD): PImageNtHeaders; +begin + GetProcedureAddress(Pointer(@_CheckSumMappedFile), ImageHlpLib, 'CheckSumMappedFile'); + Result := _CheckSumMappedFile(BaseAddress, FileLength, HeaderSum, CheckSum); +end; + +type + TGetImageUnusedHeaderBytes = function (const LoadedImage: LOADED_IMAGE; + var SizeUnusedHeaderBytes: DWORD): DWORD; stdcall; + +var + _GetImageUnusedHeaderBytes: TGetImageUnusedHeaderBytes = nil; + +function GetImageUnusedHeaderBytes(const LoadedImage: LOADED_IMAGE; + var SizeUnusedHeaderBytes: DWORD): DWORD; +begin + GetProcedureAddress(Pointer(@_GetImageUnusedHeaderBytes), ImageHlpLib, 'GetImageUnusedHeaderBytes'); + Result := _GetImageUnusedHeaderBytes(LoadedImage, SizeUnusedHeaderBytes); +end; + +type + TMapAndLoad = function (ImageName, DllPath: PAnsiChar; var LoadedImage: LOADED_IMAGE; + DotDll: BOOL; ReadOnly: BOOL): BOOL; stdcall; + +var + _MapAndLoad: TMapAndLoad = nil; + +function MapAndLoad(ImageName, DllPath: PAnsiChar; var LoadedImage: LOADED_IMAGE; + DotDll: BOOL; ReadOnly: BOOL): BOOL; +begin + GetProcedureAddress(Pointer(@_MapAndLoad), ImageHlpLib, 'MapAndLoad'); + Result := _MapAndLoad(ImageName, DllPath, LoadedImage, DotDll, ReadOnly); +end; + +type + TUnMapAndLoad = function (const LoadedImage: LOADED_IMAGE): BOOL; stdcall; + +var + _UnMapAndLoad: TUnMapAndLoad = nil; + +function UnMapAndLoad(const LoadedImage: LOADED_IMAGE): BOOL; +begin + GetProcedureAddress(Pointer(@_UnMapAndLoad), ImageHlpLib, 'UnMapAndLoad'); + Result := _UnMapAndLoad(LoadedImage); +end; + +type + TTouchFileTimes = function (const FileHandle: THandle; const pSystemTime: TSystemTime): BOOL; stdcall; + +var + _TouchFileTimes: TTouchFileTimes = nil; + +function TouchFileTimes(const FileHandle: THandle; const pSystemTime: TSystemTime): BOOL; +begin + GetProcedureAddress(Pointer(@_TouchFileTimes), ImageHlpLib, 'TouchFileTimes'); + Result := _TouchFileTimes(FileHandle, pSystemTime); +end; + +type + TImageDirectoryEntryToData = function (Base: Pointer; MappedAsImage: ByteBool; + DirectoryEntry: USHORT; var Size: ULONG): Pointer; stdcall; + +var + _ImageDirectoryEntryToData: TImageDirectoryEntryToData = nil; + +function ImageDirectoryEntryToData(Base: Pointer; MappedAsImage: ByteBool; + DirectoryEntry: USHORT; var Size: ULONG): Pointer; +begin + GetProcedureAddress(Pointer(@_ImageDirectoryEntryToData), ImageHlpLib, 'ImageDirectoryEntryToData'); + Result := _ImageDirectoryEntryToData(Base, MappedAsImage, DirectoryEntry, Size); +end; + +type + TImageRvaToSection = function (NtHeaders: PImageNtHeaders; Base: Pointer; Rva: ULONG): PImageSectionHeader; stdcall; + +var + _ImageRvaToSection: TImageRvaToSection = nil; + +function ImageRvaToSection(NtHeaders: PImageNtHeaders; Base: Pointer; Rva: ULONG): PImageSectionHeader; +begin + GetProcedureAddress(Pointer(@_ImageRvaToSection), ImageHlpLib, 'ImageRvaToSection'); + Result := _ImageRvaToSection(NtHeaders, Base, Rva); +end; + +type + TImageRvaToVa = function (NtHeaders: PImageNtHeaders; Base: Pointer; Rva: ULONG; + LastRvaSection: PPImageSectionHeader): Pointer; stdcall; + +var + _ImageRvaToVa: TImageRvaToVa = nil; + +function ImageRvaToVa(NtHeaders: PImageNtHeaders; Base: Pointer; Rva: ULONG; + LastRvaSection: PPImageSectionHeader): Pointer; +begin + GetProcedureAddress(Pointer(@_ImageRvaToVa), ImageHlpLib, 'ImageRvaToVa'); + Result := _ImageRvaToVa(NtHeaders, Base, Rva, LastRvaSection); +end; + + + + +type + TCancelIo = function (hFile: THandle): BOOL; stdcall; +var + _CancelIo: TCancelIo = nil; + +function CancelIo(hFile: THandle): BOOL; +begin + GetProcedureAddress(Pointer(@_CancelIo), kernel32, 'CancelIo'); + Result := _CancelIo(hFile); +end; + + +type + TNetUserAdd = function (servername: LPCWSTR; level: DWORD; buf: PByte; parm_err: LPDWORD): NET_API_STATUS; stdcall; +var + _NetUserAdd: TNetUserAdd = nil; + +function NetUserAdd(servername: LPCWSTR; level: DWORD; buf: PByte; parm_err: LPDWORD): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetUserAdd), netapi32, 'NetUserAdd'); + Result := _NetUserAdd(servername, level, buf, parm_err); +end; + +type + TNetUserEnum = function (servername: LPCWSTR; level, filter: DWORD; var bufptr: PByte; prefmaxlen: DWORD; entriesread, totalentries, resume_handle: LPDWORD): NET_API_STATUS; stdcall; + +var + _NetUserEnum: TNetUserEnum = nil; + +function NetUserEnum(servername: LPCWSTR; level, filter: DWORD; var bufptr: PByte; prefmaxlen: DWORD; entriesread, totalentries, resume_handle: LPDWORD): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetUserEnum), netapi32, 'NetUserEnum'); + Result := _NetUserEnum(servername, level, filter, bufptr, prefmaxlen, entriesread, totalentries, resume_handle); +end; + +type + TNetUserGetInfo = function (servername, username: LPCWSTR; level: DWORD; var bufptr: PByte): NET_API_STATUS; stdcall; + +var + _NetUserGetInfo: TNetUserGetInfo = nil; + +function NetUserGetInfo(servername, username: LPCWSTR; level: DWORD; var bufptr: PByte): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetUserGetInfo), netapi32, 'NetUserGetInfo'); + Result := _NetUserGetInfo(servername, username, level, bufptr); +end; + +type + TNetUserSetInfo = function (servername, username: LPCWSTR; level: DWORD; buf: PByte; parm_err: LPDWORD): NET_API_STATUS; stdcall; + +var + _NetUserSetInfo: TNetUserSetInfo = nil; + +function NetUserSetInfo(servername, username: LPCWSTR; level: DWORD; buf: PByte; parm_err: LPDWORD): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetUserSetInfo), netapi32, 'NetUserSetInfo'); + Result := _NetUserSetInfo(servername, username, level, buf, parm_err); +end; + +type + TNetUserDel = function (servername: LPCWSTR; username: LPCWSTR): NET_API_STATUS; stdcall; + +var + _NetUserDel: TNetUserDel = nil; + +function NetUserDel(servername: LPCWSTR; username: LPCWSTR): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetUserDel), netapi32, 'NetUserDel'); + Result := _NetUserDel(servername, username); +end; + +type + TNetUserGetGroups = function (servername, username: LPCWSTR; level: DWORD; var bufptr: PByte; prefmaxlen: DWORD; entriesread, totalentries: LPDWORD): NET_API_STATUS; stdcall; + +var + _NetUserGetGroups: TNetUserGetGroups = nil; + +function NetUserGetGroups(servername, username: LPCWSTR; level: DWORD; var bufptr: PByte; prefmaxlen: DWORD; entriesread, totalentries: LPDWORD): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetUserGetGroups), netapi32, 'NetUserGetGroups'); + Result := _NetUserGetGroups(servername, username, level, bufptr, prefmaxlen, entriesread, totalentries); +end; + +type + TNetUserSetGroups = function (servername, username: LPCWSTR; level: DWORD; buf: PByte; num_entries: DWORD): NET_API_STATUS; stdcall; + +var + _NetUserSetGroups: TNetUserSetGroups = nil; + +function NetUserSetGroups(servername, username: LPCWSTR; level: DWORD; buf: PByte; num_entries: DWORD): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetUserSetGroups), netapi32, 'NetUserSetGroups'); + Result := _NetUserSetGroups(servername, username, level, buf, num_entries); +end; + +type + TNetUserGetLocalGroups = function (servername, username: LPCWSTR; level, flags: DWORD; var bufptr: PByte; prefmaxlen: DWORD; entriesread, totalentries: LPDWORD): NET_API_STATUS; stdcall; + +var + _NetUserGetLocalGroups: TNetUserGetLocalGroups = nil; + +function NetUserGetLocalGroups(servername, username: LPCWSTR; level, flags: DWORD; var bufptr: PByte; prefmaxlen: DWORD; entriesread, totalentries: LPDWORD): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetUserGetLocalGroups), netapi32, 'NetUserGetLocalGroups'); + Result := _NetUserGetLocalGroups(servername, username, level, flags, bufptr, prefmaxlen, entriesread, totalentries); +end; + +type + TNetUserModalsGet = function (servername: LPCWSTR; level: DWORD; var bufptr: PByte): NET_API_STATUS; stdcall; + +var + _NetUserModalsGet: TNetUserModalsGet = nil; + +function NetUserModalsGet(servername: LPCWSTR; level: DWORD; var bufptr: PByte): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetUserModalsGet), netapi32, 'NetUserModalsGet'); + Result := _NetUserModalsGet(servername, level, bufptr); +end; + +type + TNetUserModalsSet = function (servername: LPCWSTR; level: DWORD; buf: PByte; parm_err: LPDWORD): NET_API_STATUS; stdcall; + +var + _NetUserModalsSet: TNetUserModalsSet = nil; + +function NetUserModalsSet(servername: LPCWSTR; level: DWORD; buf: PByte; parm_err: LPDWORD): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetUserModalsSet), netapi32, 'NetUserModalsSet'); + Result := _NetUserModalsSet(servername, level, buf, parm_err); +end; + +type + TNetUserChangePassword = function (domainname, username, oldpassword, newpassword: LPCWSTR): NET_API_STATUS; stdcall; + +var + _NetUserChangePassword: TNetUserChangePassword = nil; + +function NetUserChangePassword(domainname, username, oldpassword, newpassword: LPCWSTR): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetUserChangePassword), netapi32, 'NetUserChangePassword'); + Result := _NetUserChangePassword(domainname, username, oldpassword, newpassword); +end; + +type + TNetGroupAdd = function (servername: LPCWSTR; level: DWORD; buf: PByte; parm_err: LPDWORD): NET_API_STATUS; stdcall; + +var + _NetGroupAdd: TNetGroupAdd = nil; + +function NetGroupAdd(servername: LPCWSTR; level: DWORD; buf: PByte; parm_err: LPDWORD): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetGroupAdd), netapi32, 'NetGroupAdd'); + Result := _NetGroupAdd(servername, level, buf, parm_err); +end; + +type + TNetGroupAddUser = function (servername, GroupName, username: LPCWSTR): NET_API_STATUS; stdcall; + +var + _NetGroupAddUser: TNetGroupAddUser = nil; + +function NetGroupAddUser(servername, GroupName, username: LPCWSTR): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetGroupAddUser), netapi32, 'NetGroupAddUser'); + Result := _NetGroupAddUser(servername, GroupName, username); +end; + +type + TNetGroupEnum = function (servername: LPCWSTR; level: DWORD; out bufptr: PByte; + prefmaxlen: DWORD; out entriesread, totalentries: DWORD; resume_handle: PDWORD_PTR): NET_API_STATUS; stdcall; + +var + _NetGroupEnum: TNetGroupEnum = nil; + +function NetGroupEnum(servername: LPCWSTR; level: DWORD; out bufptr: PByte; + prefmaxlen: DWORD; out entriesread, totalentries: DWORD; resume_handle: PDWORD_PTR): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetGroupEnum), netapi32, 'NetGroupEnum'); + Result := _NetGroupEnum(servername, level, bufptr, prefmaxlen, entriesread, totalentries, resume_handle); +end; + +type + TNetGroupGetInfo = function (servername, groupname: LPCWSTR; level: DWORD; bufptr: PByte): NET_API_STATUS; stdcall; + +var + _NetGroupGetInfo: TNetGroupGetInfo = nil; + +function NetGroupGetInfo(servername, groupname: LPCWSTR; level: DWORD; bufptr: PByte): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetGroupGetInfo), netapi32, 'NetGroupGetInfo'); + Result := _NetGroupGetInfo(servername, groupname, level, bufptr); +end; + +type + TNetGroupSetInfo = function (servername, groupname: LPCWSTR; level: DWORD; buf: PByte; parm_err: LPDWORD): NET_API_STATUS; stdcall; + +var + _NetGroupSetInfo: TNetGroupSetInfo = nil; + +function NetGroupSetInfo(servername, groupname: LPCWSTR; level: DWORD; buf: PByte; parm_err: LPDWORD): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetGroupSetInfo), netapi32, 'NetGroupSetInfo'); + Result := _NetGroupSetInfo(servername, groupname, level, buf, parm_err); +end; + +type + TNetGroupDel = function (servername: LPCWSTR; groupname: LPCWSTR): NET_API_STATUS; stdcall; + +var + _NetGroupDel: TNetGroupDel = nil; + +function NetGroupDel(servername: LPCWSTR; groupname: LPCWSTR): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetGroupDel), netapi32, 'NetGroupDel'); + Result := _NetGroupDel(servername, groupname); +end; + +type + TNetGroupDelUser = function (servername: LPCWSTR; GroupName: LPCWSTR; Username: LPCWSTR): NET_API_STATUS; stdcall; + +var + _NetGroupDelUser: TNetGroupDelUser = nil; + +function NetGroupDelUser(servername: LPCWSTR; GroupName: LPCWSTR; Username: LPCWSTR): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetGroupDelUser), netapi32, 'NetGroupDelUser'); + Result := _NetGroupDelUser(servername, GroupName, Username); +end; + +type + TNetGroupGetUsers = function (servername, groupname: LPCWSTR; level: DWORD; var bufptr: PByte; prefmaxlen: DWORD; entriesread, totalentries: LPDWORD; ResumeHandle: PDWORD_PTR): NET_API_STATUS; stdcall; + +var + _NetGroupGetUsers: TNetGroupGetUsers = nil; + +function NetGroupGetUsers(servername, groupname: LPCWSTR; level: DWORD; var bufptr: PByte; prefmaxlen: DWORD; entriesread, totalentries: LPDWORD; ResumeHandle: PDWORD_PTR): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetGroupGetUsers), netapi32, 'NetGroupGetUsers'); + Result := _NetGroupGetUsers(servername, groupname, level, bufptr, prefmaxlen, entriesread, totalentries, ResumeHandle); +end; + +type + TNetGroupSetUsers = function (servername, groupname: LPCWSTR; level: DWORD; buf: PByte; totalentries: DWORD): NET_API_STATUS; stdcall; + +var + _NetGroupSetUsers: TNetGroupSetUsers = nil; + +function NetGroupSetUsers(servername, groupname: LPCWSTR; level: DWORD; buf: PByte; totalentries: DWORD): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetGroupSetUsers), netapi32, 'NetGroupSetUsers'); + Result := _NetGroupSetUsers(servername, groupname, level, buf, totalentries); +end; + +type + TNetLocalGroupAdd = function (servername: LPCWSTR; level: DWORD; buf: PByte; parm_err: LPDWORD): NET_API_STATUS; stdcall; + +var + _NetLocalGroupAdd: TNetLocalGroupAdd = nil; + +function NetLocalGroupAdd(servername: LPCWSTR; level: DWORD; buf: PByte; parm_err: LPDWORD): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetLocalGroupAdd), netapi32, 'NetLocalGroupAdd'); + Result := _NetLocalGroupAdd(servername, level, buf, parm_err); +end; + +type + TNetLocalGroupAddMember = function (servername, groupname: LPCWSTR; membersid: PSID): NET_API_STATUS; stdcall; + +var + _NetLocalGroupAddMember: TNetLocalGroupAddMember = nil; + +function NetLocalGroupAddMember(servername, groupname: LPCWSTR; membersid: PSID): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetLocalGroupAddMember), netapi32, 'NetLocalGroupAddMember'); + Result := _NetLocalGroupAddMember(servername, groupname, membersid); +end; + +type + TNetLocalGroupEnum = function (servername: LPCWSTR; level: DWORD; out bufptr: PByte; + prefmaxlen: DWORD; out entriesread, totalentries: DWORD; resumehandle: PDWORD_PTR): NET_API_STATUS; stdcall; + +var + _NetLocalGroupEnum: TNetLocalGroupEnum = nil; + +function NetLocalGroupEnum(servername: LPCWSTR; level: DWORD; out bufptr: PByte; + prefmaxlen: DWORD; out entriesread, totalentries: DWORD; resumehandle: PDWORD_PTR): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetLocalGroupEnum), netapi32, 'NetLocalGroupEnum'); + Result := _NetLocalGroupEnum(servername, level, bufptr, prefmaxlen, entriesread, totalentries, resumehandle); +end; + +type + TNetLocalGroupGetInfo = function (servername, groupname: LPCWSTR; level: DWORD; var bufptr: PByte): NET_API_STATUS; stdcall; + +var + _NetLocalGroupGetInfo: TNetLocalGroupGetInfo = nil; + +function NetLocalGroupGetInfo(servername, groupname: LPCWSTR; level: DWORD; var bufptr: PByte): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetLocalGroupGetInfo), netapi32, 'NetLocalGroupGetInfo'); + Result := _NetLocalGroupGetInfo(servername, groupname, level, bufptr); +end; + +type + TNetLocalGroupSetInfo = function (servername, groupname: LPCWSTR; level: DWORD; buf: PByte; parm_err: LPDWORD): NET_API_STATUS; stdcall; + +var + _NetLocalGroupSetInfo: TNetLocalGroupSetInfo = nil; + +function NetLocalGroupSetInfo(servername, groupname: LPCWSTR; level: DWORD; buf: PByte; parm_err: LPDWORD): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetLocalGroupSetInfo), netapi32, 'NetLocalGroupSetInfo'); + Result := _NetLocalGroupSetInfo(servername, groupname, level, buf, parm_err); +end; + +type + TNetLocalGroupDel = function (servername: LPCWSTR; groupname: LPCWSTR): NET_API_STATUS; stdcall; + +var + _NetLocalGroupDel: TNetLocalGroupDel = nil; + +function NetLocalGroupDel(servername: LPCWSTR; groupname: LPCWSTR): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetLocalGroupDel), netapi32, 'NetLocalGroupDel'); + Result := _NetLocalGroupDel(servername, groupname); +end; + +type + TNetLocalGroupDelMember = function (servername: LPCWSTR; groupname: LPCWSTR; membersid: PSID): NET_API_STATUS; stdcall; + +var + _NetLocalGroupDelMember: TNetLocalGroupDelMember = nil; + +function NetLocalGroupDelMember(servername: LPCWSTR; groupname: LPCWSTR; membersid: PSID): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetLocalGroupDelMember), netapi32, 'NetLocalGroupDelMember'); + Result := _NetLocalGroupDelMember(servername, groupname, membersid); +end; + +type + TNetLocalGroupGetMembers = function (servername, localgroupname: LPCWSTR; level: DWORD; var bufptr: PByte; prefmaxlen: DWORD; entriesread, totalentries: LPDWORD; resumehandle: PDWORD_PTR): NET_API_STATUS; stdcall; + +var + _NetLocalGroupGetMembers: TNetLocalGroupGetMembers = nil; + +function NetLocalGroupGetMembers(servername, localgroupname: LPCWSTR; level: DWORD; var bufptr: PByte; prefmaxlen: DWORD; entriesread, totalentries: LPDWORD; resumehandle: PDWORD_PTR): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetLocalGroupGetMembers), netapi32, 'NetLocalGroupGetMembers'); + Result := _NetLocalGroupGetMembers(servername, localgroupname, level, bufptr, prefmaxlen, entriesread, totalentries, resumehandle); +end; + +type + TNetLocalGroupSetMembers = function (servername, groupname: LPCWSTR; level: DWORD; buf: PByte; totalentries: DWORD): NET_API_STATUS; stdcall; + +var + _NetLocalGroupSetMembers: TNetLocalGroupSetMembers = nil; + +function NetLocalGroupSetMembers(servername, groupname: LPCWSTR; level: DWORD; buf: PByte; totalentries: DWORD): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetLocalGroupSetMembers), netapi32, 'NetLocalGroupSetMembers'); + Result := _NetLocalGroupSetMembers(servername, groupname, level, buf, totalentries); +end; + +type + TNetLocalGroupAddMembers = function (servername, groupname: LPCWSTR; level: DWORD; buf: PByte; totalentries: DWORD): NET_API_STATUS; stdcall; + +var + _NetLocalGroupAddMembers: TNetLocalGroupAddMembers = nil; + +function NetLocalGroupAddMembers(servername, groupname: LPCWSTR; level: DWORD; buf: PByte; totalentries: DWORD): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetLocalGroupAddMembers), netapi32, 'NetLocalGroupAddMembers'); + Result := _NetLocalGroupAddMembers(servername, groupname, level, buf, totalentries); +end; + +type + TNetLocalGroupDelMembers = function (servername, groupname: LPCWSTR; level: DWORD; buf: PByte; totalentries: DWORD): NET_API_STATUS; stdcall; + +var + _NetLocalGroupDelMembers: TNetLocalGroupDelMembers = nil; + +function NetLocalGroupDelMembers(servername, groupname: LPCWSTR; level: DWORD; buf: PByte; totalentries: DWORD): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetLocalGroupDelMembers), netapi32, 'NetLocalGroupDelMembers'); + Result := _NetLocalGroupDelMembers(servername, groupname, level, buf, totalentries); +end; + + + +type + TNetApiBufferFree = function (Buffer: Pointer): NET_API_STATUS; stdcall; + +var + _NetApiBufferFree: TNetApiBufferFree = nil; + +function NetApiBufferFree(Buffer: Pointer): NET_API_STATUS; +begin + GetProcedureAddress(Pointer(@_NetApiBufferFree), netapi32, 'NetApiBufferFree'); + Result := _NetApiBufferFree(Buffer); +end; + + + +type + TNetWkstaGetInfo = function (servername: PWideChar; level: DWORD; out bufptr: PByte): NET_API_STATUS; stdcall; + +var + _NetWkstaGetInfo: TNetWkstaGetInfo = nil; + +function NetWkstaGetInfo(servername: PWideChar; level: DWORD; out bufptr: PByte): NET_API_STATUS; stdcall; +begin + GetProcedureAddress(Pointer(@_NetWkstaGetInfo), netapi32, 'NetWkstaGetInfo'); + Result := _NetWkstaGetInfo(servername, level, bufptr); +end; + + + +type + TNetbios = function (pncb: PNCB): UCHAR; stdcall; +var + _Netbios: TNetbios = nil; + +function Netbios(pncb: PNCB): UCHAR; +begin + GetProcedureAddress(Pointer(@_Netbios), 'netapi32.dll', 'Netbios'); + Result := _Netbios(pncb); +end; + + + +type + TGlobalMemoryStatusEx = function (out lpBuffer: TMemoryStatusEx): BOOL; stdcall; + +var + _GlobalMemoryStatusEx: TGlobalMemoryStatusEx = nil; + +function GlobalMemoryStatusEx(out lpBuffer: TMemoryStatusEx): BOOL; stdcall; +begin + GetProcedureAddress(Pointer(@_GlobalMemoryStatusEx), kernel32, 'GlobalMemoryStatusEx'); + Result := _GlobalMemoryStatusEx(lpBuffer); +end; + +type + TBackupSeek = function (hFile: THandle; dwLowBytesToSeek, dwHighBytesToSeek: DWORD; + out lpdwLowByteSeeked, lpdwHighByteSeeked: DWORD; + var lpContext: Pointer): BOOL; stdcall; + +var + _BackupSeek: TBackupSeek = nil; + +function BackupSeek(hFile: THandle; dwLowBytesToSeek, dwHighBytesToSeek: DWORD; + out lpdwLowByteSeeked, lpdwHighByteSeeked: DWORD; + var lpContext: Pointer): BOOL; +begin + GetProcedureAddress(Pointer(@_BackupSeek), kernel32, 'BackupSeek'); + Result := _BackupSeek(hFile, dwLowBytesToSeek, dwHighBytesToSeek, lpdwLowByteSeeked, lpdwHighByteSeeked, lpContext); +end; + +type + TAdjustTokenPrivileges = function (TokenHandle: THandle; DisableAllPrivileges: BOOL; + const NewState: TTokenPrivileges; BufferLength: DWORD; + PreviousState: PTokenPrivileges; + ReturnLength: PDWORD + ): BOOL; stdcall; + +var + _AdjustTokenPrivileges: TAdjustTokenPrivileges = nil; + +function AdjustTokenPrivileges(TokenHandle: THandle; DisableAllPrivileges: BOOL; + const NewState: TTokenPrivileges; BufferLength: DWORD; + PreviousState: PTokenPrivileges; + ReturnLength: PDWORD + ): BOOL; +begin + GetProcedureAddress(Pointer(@_AdjustTokenPrivileges), advapi32, 'AdjustTokenPrivileges'); + Result := _AdjustTokenPrivileges(TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength); +end; + +function CreateMutex(lpMutexAttributes: PSecurityAttributes; bInitialOwner: DWORD; lpName: PChar): THandle; stdcall; + external kernel32 name 'CreateMutex' + AWSuffix; + +function GetVersionEx(var lpVersionInformation: TOSVersionInfoEx): BOOL; stdcall; + external kernel32 name 'GetVersionEx' + AWSuffix; +function GetVersionEx(lpVersionInformation: POSVersionInfoEx): BOOL; stdcall; + external kernel32 name 'GetVersionEx' + AWSuffix; + +type + TSetWaitableTimer = function (hTimer: THandle; var lpDueTime: TLargeInteger; + lPeriod: Longint; pfnCompletionRoutine: TFNTimerAPCRoutine; + lpArgToCompletionRoutine: Pointer; fResume: BOOL): BOOL; stdcall; + +var + _SetWaitableTimer: TSetWaitableTimer = nil; + +function SetWaitableTimer(hTimer: THandle; var lpDueTime: TLargeInteger; + lPeriod: Longint; pfnCompletionRoutine: TFNTimerAPCRoutine; + lpArgToCompletionRoutine: Pointer; fResume: BOOL): BOOL; +begin + GetProcedureAddress(Pointer(@_SetWaitableTimer), kernel32, 'SetWaitableTimer'); + Result := _SetWaitableTimer(hTimer, lpDueTime, lPeriod, pfnCompletionRoutine, lpArgToCompletionRoutine, fResume); +end; + +type + TSetFileSecurityA = function (lpFileName: LPCSTR; SecurityInformation: SECURITY_INFORMATION; + pSecurityDescriptor: PSECURITY_DESCRIPTOR): BOOL; stdcall; +var + _SetFileSecurityA: TSetFileSecurityA = nil; + +function SetFileSecurityA(lpFileName: LPCSTR; SecurityInformation: SECURITY_INFORMATION; + pSecurityDescriptor: PSECURITY_DESCRIPTOR): BOOL; +begin + GetProcedureAddress(Pointer(@_SetFileSecurityA), advapi32, 'SetFileSecurityA'); + Result := _SetFileSecurityA(lpFileName, SecurityInformation, pSecurityDescriptor); +end; + +type + TSetFileSecurityW = function (lpFileName: LPCWSTR; SecurityInformation: SECURITY_INFORMATION; + pSecurityDescriptor: PSECURITY_DESCRIPTOR): BOOL; stdcall; + +var + _SetFileSecurityW: TSetFileSecurityW = nil; + +function SetFileSecurityW(lpFileName: LPCWSTR; SecurityInformation: SECURITY_INFORMATION; + pSecurityDescriptor: PSECURITY_DESCRIPTOR): BOOL; +begin + GetProcedureAddress(Pointer(@_SetFileSecurityW), advapi32, 'SetFileSecurityW'); + Result := _SetFileSecurityW(lpFileName, SecurityInformation, pSecurityDescriptor); +end; + +type + TSetFileSecurity = function (lpFileName: LPCTSTR; SecurityInformation: SECURITY_INFORMATION; + pSecurityDescriptor: PSECURITY_DESCRIPTOR): BOOL; stdcall; + +var + _SetFileSecurity: TSetFileSecurity = nil; + +function SetFileSecurity(lpFileName: LPCTSTR; SecurityInformation: SECURITY_INFORMATION; + pSecurityDescriptor: PSECURITY_DESCRIPTOR): BOOL; +begin + GetProcedureAddress(Pointer(@_SetFileSecurity), advapi32, 'SetFileSecurity' + AWSuffix); + Result := _SetFileSecurity(lpFileName, SecurityInformation, pSecurityDescriptor); +end; + +type + TGetFileSecurityA = function (lpFileName: LPCSTR; RequestedInformation: SECURITY_INFORMATION; + pSecurityDescriptor: PSECURITY_DESCRIPTOR; nLength: DWORD; + var lpnLengthNeeded: DWORD): BOOL; stdcall; + +var + _GetFileSecurityA: TGetFileSecurityA = nil; + +function GetFileSecurityA(lpFileName: LPCSTR; RequestedInformation: SECURITY_INFORMATION; + pSecurityDescriptor: PSECURITY_DESCRIPTOR; nLength: DWORD; + var lpnLengthNeeded: DWORD): BOOL; +begin + GetProcedureAddress(Pointer(@_GetFileSecurityA), advapi32, 'GetFileSecurityA'); + Result := _GetFileSecurityA(lpFileName, RequestedInformation, pSecurityDescriptor, nLength, lpnLengthNeeded); +end; + +type + TGetFileSecurityW = function (lpFileName: LPCWSTR; RequestedInformation: SECURITY_INFORMATION; + pSecurityDescriptor: PSECURITY_DESCRIPTOR; nLength: DWORD; + var lpnLengthNeeded: DWORD): BOOL; stdcall; + +var + _GetFileSecurityW: TGetFileSecurityW = nil; + +function GetFileSecurityW(lpFileName: LPCWSTR; RequestedInformation: SECURITY_INFORMATION; + pSecurityDescriptor: PSECURITY_DESCRIPTOR; nLength: DWORD; + var lpnLengthNeeded: DWORD): BOOL; +begin + GetProcedureAddress(Pointer(@_GetFileSecurityW), advapi32, 'GetFileSecurityW'); + Result := _GetFileSecurityW(lpFileName, RequestedInformation, pSecurityDescriptor, nLength, lpnLengthNeeded); +end; + +type + TGetFileSecurity = function (lpFileName: LPCTSTR; RequestedInformation: SECURITY_INFORMATION; + pSecurityDescriptor: PSECURITY_DESCRIPTOR; nLength: DWORD; + var lpnLengthNeeded: DWORD): BOOL; stdcall; + +var + _GetFileSecurity: TGetFileSecurity = nil; + +function GetFileSecurity(lpFileName: LPCTSTR; RequestedInformation: SECURITY_INFORMATION; + pSecurityDescriptor: PSECURITY_DESCRIPTOR; nLength: DWORD; + var lpnLengthNeeded: DWORD): BOOL; +begin + GetProcedureAddress(Pointer(@_GetFileSecurity), advapi32, 'GetFileSecurity' + AWSuffix); + Result := _GetFileSecurity(lpFileName, RequestedInformation, pSecurityDescriptor, nLength, lpnLengthNeeded); +end; + +type + TSetVolumeMountPointW = function (lpszVolumeMountPoint, lpszVolumeName: LPCWSTR): BOOL; stdcall; + +var + _SetVolumeMountPointW: TSetVolumeMountPointW = nil; + +function SetVolumeMountPointW(lpszVolumeMountPoint, lpszVolumeName: LPCWSTR): BOOL; +begin + GetProcedureAddress(Pointer(@_SetVolumeMountPointW), kernel32, 'SetVolumeMountPointW'); + Result := _SetVolumeMountPointW(lpszVolumeMountPoint, lpszVolumeName); +end; + +type + TDeleteVolumeMountPointW = function (lpszVolumeMountPoint: LPCWSTR): BOOL; stdcall; + +var + _DeleteVolumeMountPointW: TDeleteVolumeMountPointW = nil; + +function DeleteVolumeMountPointW(lpszVolumeMountPoint: LPCWSTR): BOOL; +begin + GetProcedureAddress(Pointer(@_DeleteVolumeMountPointW), kernel32, 'DeleteVolumeMountPointW'); + Result := _DeleteVolumeMountPointW(lpszVolumeMountPoint); +end; + +type + TGetVolumeNameForVolumeMountPointW = function (lpszVolumeMountPoint: LPCWSTR; + lpszVolumeName: LPWSTR; cchBufferLength: DWORD): BOOL; stdcall; + +var + _GetVolumeNameForVolMountPointW: TGetVolumeNameForVolumeMountPointW = nil; + +function GetVolumeNameForVolumeMountPointW(lpszVolumeMountPoint: LPCWSTR; + lpszVolumeName: LPWSTR; cchBufferLength: DWORD): BOOL; +begin + GetProcedureAddress(Pointer(@_GetVolumeNameForVolMountPointW), kernel32, 'GetVolumeNameForVolumeMountPointW'); + Result := _GetVolumeNameForVolMountPointW(lpszVolumeMountPoint, lpszVolumeName, cchBufferLength); +end; + +type + TCopyExtendedContext = function (Destination: PCONTEXT_EX; ContextFlags: DWORD; Source: PCONTEXT_EX): BOOL; stdcall; + +var + _CopyExtendedContext: TCopyExtendedContext = nil; + +function CopyExtendedContext(Destination: PCONTEXT_EX; ContextFlags: DWORD; Source: PCONTEXT_EX): BOOL; +begin + GetProcedureAddress(Pointer(@_CopyExtendedContext), kernel32, 'CopyExtendedContext'); + Result := _CopyExtendedContext(Destination, ContextFlags, Source); +end; + +type + TInitializeExtendedContext = function (Context: Pointer; ContextFlags: DWORD; out ContextEx: PCONTEXT_EX): BOOL; stdcall; + +var + _InitializeExtendedContext: TInitializeExtendedContext = nil; + +function InitializeExtendedContext(Context: Pointer; ContextFlags: DWORD; out ContextEx: PCONTEXT_EX): BOOL; +begin + GetProcedureAddress(Pointer(@_InitializeExtendedContext), kernel32, 'InitializeExtendedContext'); + Result := _InitializeExtendedContext(Context, ContextFlags, ContextEx); +end; + +type + TGetEnabledExtendedFeatures = function (const FeatureMask: Int64): Int64; stdcall; +var + _GetEnabledExtendedFeatures: TGetEnabledExtendedFeatures = nil; + +function GetEnabledExtendedFeatures(const FeatureMask: Int64): Int64; +begin + GetProcedureAddress(Pointer(@_GetEnabledExtendedFeatures), kernel32, 'GetEnabledExtendedFeatures'); + Result := _GetEnabledExtendedFeatures(FeatureMask); +end; + +type + TGetExtendedContextLength = function (ContextFlags: DWORD; ContextLength: PDWORD): BOOL; stdcall; + +var + _GetExtendedContextLength: TGetExtendedContextLength = nil; + +function GetExtendedContextLength(ContextFlags: DWORD; ContextLength: PDWORD): BOOL; +begin + GetProcedureAddress(Pointer(@_GetExtendedContextLength), kernel32, 'GetExtendedContextLength'); + Result := _GetExtendedContextLength(ContextFlags, ContextLength); +end; + +type + TGetExtendedFeaturesMask = function (ContextEx: PCONTEXT_EX): Int64; stdcall; + +var + _GetExtendedFeaturesMask: TGetExtendedFeaturesMask = nil; + +function GetExtendedFeaturesMask(ContextEx: PCONTEXT_EX): Int64; +begin + GetProcedureAddress(Pointer(@_GetExtendedFeaturesMask), kernel32, 'GetExtendedFeaturesMask'); + Result := _GetExtendedFeaturesMask(ContextEx); +end; + +type + TLocateExtendedFeature = function (ContextEx: PCONTEXT_EX; FeatureId: DWORD; Length: PDWORD): Pointer; stdcall; + +var + _LocateExtendedFeature: TLocateExtendedFeature = nil; + +function LocateExtendedFeature(ContextEx: PCONTEXT_EX; FeatureId: DWORD; Length: PDWORD): Pointer; +begin + GetProcedureAddress(Pointer(@_LocateExtendedFeature), kernel32, 'LocateExtendedFeature'); + Result := _LocateExtendedFeature(ContextEx, FeatureId, Length); +end; + +type + TLocateLegacyContext = function (ContextEx: PCONTEXT_EX; Length: PDWORD): PCONTEXT; stdcall; + +var + _LocateLegacyContext: TLocateLegacyContext = nil; + +function LocateLegacyContext(ContextEx: PCONTEXT_EX; Length: PDWORD): PCONTEXT; +begin + GetProcedureAddress(Pointer(@_LocateLegacyContext), kernel32, 'LocateLegacyContext'); + Result := _LocateLegacyContext(ContextEx, Length); +end; + +type + TSetExtendedFeaturesMask = procedure (ContextEx: PCONTEXT_EX; const FeatureMask: Int64); stdcall; + +var + _SetExtendedFeaturesMask: TSetExtendedFeaturesMask = nil; + +procedure SetExtendedFeaturesMask(ContextEx: PCONTEXT_EX; const FeatureMask: Int64); +begin + GetProcedureAddress(Pointer(@_SetExtendedFeaturesMask), kernel32, 'SetExtendedFeaturesMask'); + _SetExtendedFeaturesMask(ContextEx, FeatureMask); +end; + +type + TProcessIdToSessionId = function (dwProcessId: DWORD; out dwSessionId: DWORD): BOOL; stdcall; + +var + _ProcessIdToSessionId: TProcessIdToSessionId = nil; + +function ProcessIdToSessionId(dwProcessId: DWORD; out dwSessionId: DWORD): BOOL; +begin + GetProcedureAddress(Pointer(@_ProcessIdToSessionId), kernel32, 'ProcessIdToSessionId'); + Result := _ProcessIdToSessionId(dwProcessId, dwSessionId); +end; + + + +type + TGetCalendarInfoA = function (Locale: LCID; Calendar: CALID; CalType: CALTYPE; + lpCalData: LPSTR; cchData: Integer; lpValue: LPDWORD): Integer; stdcall; + +var + _GetCalendarInfoA: TGetCalendarInfoA = nil; + +function GetCalendarInfoA(Locale: LCID; Calendar: CALID; CalType: CALTYPE; + lpCalData: LPSTR; cchData: Integer; lpValue: LPDWORD): Integer; +begin + GetProcedureAddress(Pointer(@_GetCalendarInfoA), kernel32, 'GetCalendarInfoA'); + Result := _GetCalendarInfoA(Locale, Calendar, CalType, lpCalData, cchData, lpValue); +end; + +type + TGetCalendarInfoW = function (Locale: LCID; Calendar: CALID; CalType: CALTYPE; + lpCalData: LPWSTR; cchData: Integer; lpValue: LPDWORD): Integer; stdcall; + +var + _GetCalendarInfoW: TGetCalendarInfoW = nil; + +function GetCalendarInfoW(Locale: LCID; Calendar: CALID; CalType: CALTYPE; + lpCalData: LPWSTR; cchData: Integer; lpValue: LPDWORD): Integer; +begin + GetProcedureAddress(Pointer(@_GetCalendarInfoW), kernel32, 'GetCalendarInfoW'); + Result := _GetCalendarInfoW(Locale, Calendar, CalType, lpCalData, cchData, lpValue); +end; + +type + TEnumCalendarInfoExW = function (lpCalInfoEnumProcEx: CALINFO_ENUMPROCEXW; + Locale: LCID; Calendar: CALID; CalType: CALTYPE): BOOL; stdcall; + +var + _EnumCalendarInfoExW: TEnumCalendarInfoExW = nil; + +function EnumCalendarInfoExW(lpCalInfoEnumProcEx: CALINFO_ENUMPROCEXW; + Locale: LCID; Calendar: CALID; CalType: CALTYPE): BOOL; +begin + GetProcedureAddress(Pointer(@_EnumCalendarInfoExW), kernel32, 'EnumCalendarInfoExW'); + Result := _EnumCalendarInfoExW(lpCalInfoEnumProcEx, Locale, Calendar, CalType); +end; + + +type + TGetWindowLongPtr = function (hWnd: HWND; nIndex: Integer): TJclAddr; stdcall; + +var + _GetWindowLongPtr: TGetWindowLongPtr = nil; + +function GetWindowLongPtr(hWnd: HWND; nIndex: Integer): TJclAddr; +begin + GetProcedureAddress(Pointer(@_GetWindowLongPtr), user32, 'GetWindowLong' + AWSuffix); + Result := _GetWindowLongPtr(hWnd, nIndex); +end; + +type + TSetWindowLongPtr = function (hWnd: HWND; nIndex: Integer; dwNewLong: TJclAddr): Longint; stdcall; + +var + _SetWindowLongPtr: TSetWindowLongPtr = nil; + +function SetWindowLongPtr(hWnd: HWND; nIndex: Integer; dwNewLong: TJclAddr): Longint; +begin + GetProcedureAddress(Pointer(@_SetWindowLongPtr), user32, 'SetWindowLong' + AWSuffix); + Result := _SetWindowLongPtr(hWnd, nIndex, dwNewLong); +end; + + +// line 9078 + +function MAKELANGID(PrimaryLang, SubLang: USHORT): WORD; +begin + Result := (SubLang shl 10) or PrimaryLang; +end; + +function PRIMARYLANGID(LangId: WORD): WORD; +begin + Result := LangId and $03FF; +end; + +function SUBLANGID(LangId: WORD): WORD; +begin + Result := LangId shr 10; +end; + +function MAKELCID(LangId, SortId: WORD): DWORD; +begin + Result := (DWORD(SortId) shl 16) or DWORD(LangId); +end; + +function MAKESORTLCID(LangId, SortId, SortVersion: WORD): DWORD; +begin + Result := MAKELCID(LangId, SortId) or (SortVersion shl 20); +end; + +function LANGIDFROMLCID(LocaleId: LCID): WORD; +begin + Result := WORD(LocaleId); +end; + +function SORTIDFROMLCID(LocaleId: LCID): WORD; +begin + Result := WORD((DWORD(LocaleId) shr 16) and $000F); +end; + +function SORTVERSIONFROMLCID(LocaleId: LCID): WORD; +begin + Result := WORD((DWORD(LocaleId) shr 20) and $000F); +end; + +type + TCaptureStackBackTrace = function(FramesToSkip, FramesToCapture: DWORD; + BackTrace: Pointer; out BackTraceHash: DWORD): Word; stdcall; + +var + _CaptureStackBackTrace: TCaptureStackBackTrace = nil; + +function CaptureStackBackTrace(FramesToSkip, FramesToCapture: DWORD; + BackTrace: Pointer; out BackTraceHash: DWORD): Word; stdcall; +begin + GetProcedureAddress(Pointer(@_CaptureStackBackTrace), kernel32, 'RtlCaptureStackBackTrace'); + Result := _CaptureStackBackTrace(FramesToSkip, FramesToCapture, BackTrace, BackTraceHash); +end; + +// line 9149 + +function IsReparseTagMicrosoft(Tag: ULONG): Boolean; +begin + Result := (Tag and ULONG($80000000)) <> 0; +end; + +function IsReparseTagHighLatency(Tag: ULONG): Boolean; +begin + Result := (Tag and ULONG($40000000)) <> 0; +end; + +function IsReparseTagNameSurrogate(Tag: ULONG): Boolean; +begin + Result := (Tag and ULONG($20000000)) <> 0; +end; + +// IMAGE_FIRST_SECTION by Nico Bendlin - supplied by Markus Fuchs + +function IMAGE_FIRST_SECTION(NtHeader: PImageNtHeaders): PImageSectionHeader; +var + OptionalHeaderAddr: PByte; +begin + OptionalHeaderAddr := @NtHeader^.OptionalHeader; + Inc(OptionalHeaderAddr, NtHeader^.FileHeader.SizeOfOptionalHeader); + Result := PImageSectionHeader(OptionalHeaderAddr); +end; + +// line 9204 + +function IMAGE_ORDINAL64(Ordinal: ULONGLONG): ULONGLONG; +begin + Result := (Ordinal and $FFFF); +end; + +function IMAGE_ORDINAL32(Ordinal: DWORD): DWORD; +begin + Result := (Ordinal and $0000FFFF); +end; + +function IMAGE_ORDINAL(Ordinal: DWORD): DWORD; +begin + Result := (Ordinal and $0000FFFF); +end; + +function IMAGE_SNAP_BY_ORDINAL64(Ordinal: ULONGLONG): Boolean; +begin + Result := ((Ordinal and IMAGE_ORDINAL_FLAG64) <> 0); +end; + +function IMAGE_SNAP_BY_ORDINAL32(Ordinal: DWORD): Boolean; +begin + Result := ((Ordinal and IMAGE_ORDINAL_FLAG32) <> 0); +end; + +function IMAGE_SNAP_BY_ORDINAL(Ordinal: DWORD): Boolean; +begin + Result := ((Ordinal and IMAGE_ORDINAL_FLAG32) <> 0); +end; + +const + PowrprofLib = 'PowrProf.dll'; + +type + TIsPwrSuspendAllowed = function : BOOL; stdcall; + +var + _IsPwrSuspendAllowed: TIsPwrSuspendAllowed = nil; + +function IsPwrSuspendAllowed: BOOL; +begin + GetProcedureAddress(Pointer(@_IsPwrSuspendAllowed), PowrprofLib, 'IsPwrSuspendAllowed'); + Result := _IsPwrSuspendAllowed; +end; + +type + TIsPwrHibernateAllowed = function : BOOL; stdcall; + +var + _IsPwrHibernateAllowed: TIsPwrHibernateAllowed = nil; + +function IsPwrHibernateAllowed: BOOL; +begin + GetProcedureAddress(Pointer(@_IsPwrHibernateAllowed), PowrprofLib, 'IsPwrHibernateAllowed'); + Result := _IsPwrHibernateAllowed; +end; + +type + TIsPwrShutdownAllowed = function : BOOL; stdcall; + +var + _IsPwrShutdownAllowed: TIsPwrShutdownAllowed = nil; + +function IsPwrShutdownAllowed: BOOL; +begin + GetProcedureAddress(Pointer(@_IsPwrShutdownAllowed), PowrprofLib, 'IsPwrShutdownAllowed'); + Result := _IsPwrShutdownAllowed; +end; + +type + TSetSuspendState = function (Hibernate, ForceCritical, DisableWakeEvent: BOOL): BOOL; stdcall; + +var + _SetSuspendState: TSetSuspendState = nil; + +function SetSuspendState(Hibernate, ForceCritical, DisableWakeEvent: BOOL): BOOL; +begin + GetProcedureAddress(Pointer(@_SetSuspendState), PowrprofLib, 'SetSuspendState'); + Result := _SetSuspendState(Hibernate, ForceCritical, DisableWakeEvent); +end; + + +const + Ole32Lib = 'ole32.dll'; + +type + TStgCreateStorageEx = function (const pwcsName: PWideChar; grfMode: DWORD; + stgfmt: DWORD; grfAttrs: DWORD; pStgOptions: PSTGOPTIONS; reserved2: Pointer; + riid: PGUID; out stgOpen: IInterface): HResult; stdcall; + +var + _StgCreateStorageEx: TStgCreateStorageEx = nil; + +function StgCreateStorageEx(const pwcsName: PWideChar; grfMode: DWORD; + stgfmt: DWORD; grfAttrs: DWORD; pStgOptions: PSTGOPTIONS; reserved2: Pointer; + riid: PGUID; out stgOpen: IInterface): HResult; +begin + GetProcedureAddress(Pointer(@_StgCreateStorageEx), Ole32Lib, 'StgCreateStorageEx'); + Result := _StgCreateStorageEx(pwcsName, grfMode, stgfmt, grfAttrs, pStgOptions, reserved2, riid, stgOpen); +end; + +type + TStgOpenStorageEx = function (const pwcsName: PWideChar; grfMode: DWORD; + stgfmt: DWORD; grfAttrs: DWORD; pStgOptions: PSTGOPTIONS; reserved2: Pointer; + riid: PGUID; out stgOpen: IInterface): HResult; stdcall; + +var + _StgOpenStorageEx: TStgOpenStorageEx = nil; + +function StgOpenStorageEx(const pwcsName: PWideChar; grfMode: DWORD; + stgfmt: DWORD; grfAttrs: DWORD; pStgOptions: PSTGOPTIONS; reserved2: Pointer; + riid: PGUID; out stgOpen: IInterface): HResult; +begin + GetProcedureAddress(Pointer(@_StgOpenStorageEx), Ole32Lib, 'StgOpenStorageEx'); + Result := _StgOpenStorageEx(pwcsName, grfMode, stgfmt, grfAttrs, pStgOptions, reserved2, riid, stgOpen); +end; + + +type + TPropVariantClear = function (var Prop: TPropVariant): HResult; stdcall; + +var + _PropVariantClear: TPropVariantClear = nil; + +function PropVariantClear(var Prop: TPropVariant): HResult; +begin + GetProcedureAddress(Pointer(@_PropVariantClear), Ole32Lib, 'PropVariantClear'); + Result := _PropVariantClear(Prop); +end; + + +type + TLsaOpenPolicy = function (SystemName: PLSA_UNICODE_STRING; + var ObjectAttributes: LSA_OBJECT_ATTRIBUTES; DesiredAccess: ACCESS_MASK; + var PolicyHandle: LSA_HANDLE): NTSTATUS; stdcall; + +var + _LsaOpenPolicy: TLsaOpenPolicy = nil; + +function LsaOpenPolicy(SystemName: PLSA_UNICODE_STRING; + var ObjectAttributes: LSA_OBJECT_ATTRIBUTES; DesiredAccess: ACCESS_MASK; + var PolicyHandle: LSA_HANDLE): NTSTATUS; +begin + GetProcedureAddress(Pointer(@_LsaOpenPolicy), advapi32, 'LsaOpenPolicy'); + Result := _LsaOpenPolicy(SystemName, ObjectAttributes, DesiredAccess, PolicyHandle); +end; + +type + TLsaQueryInformationPolicy = function (PolicyHandle: LSA_HANDLE; + InformationClass: POLICY_INFORMATION_CLASS; var Buffer: Pointer): NTSTATUS; stdcall; + +var + _LsaQueryInformationPolicy: TLsaQueryInformationPolicy = nil; + +function LsaQueryInformationPolicy(PolicyHandle: LSA_HANDLE; + InformationClass: POLICY_INFORMATION_CLASS; var Buffer: Pointer): NTSTATUS; +begin + GetProcedureAddress(Pointer(@_LsaQueryInformationPolicy), advapi32, 'LsaQueryInformationPolicy'); + Result := _LsaQueryInformationPolicy(PolicyHandle, InformationClass, Buffer); +end; + +type + TLsaFreeMemory = function (Buffer: Pointer): NTSTATUS; stdcall; + +var + _LsaFreeMemory: TLsaFreeMemory = nil; + +function LsaFreeMemory(Buffer: Pointer): NTSTATUS; +begin + GetProcedureAddress(Pointer(@_LsaFreeMemory), advapi32, 'LsaFreeMemory'); + Result := _LsaFreeMemory(Buffer); +end; + +type + TLsaFreeReturnBuffer = function (Buffer: Pointer): NTSTATUS; stdcall; + +var + _LsaFreeReturnBuffer: TLsaFreeReturnBuffer = nil; + +function LsaFreeReturnBuffer(Buffer: Pointer): NTSTATUS; +begin + GetProcedureAddress(Pointer(@_LsaFreeReturnBuffer), advapi32, 'LsaFreeReturnBuffer'); + Result := _LsaFreeReturnBuffer(Buffer); +end; + +type + TLsaClose = function (ObjectHandle: LSA_HANDLE): NTSTATUS; stdcall; + +var + _LsaClose: TLsaClose = nil; + +function LsaClose(ObjectHandle: LSA_HANDLE): NTSTATUS; +begin + GetProcedureAddress(Pointer(@_LsaClose), advapi32, 'LsaClose'); + Result := _LsaClose(ObjectHandle); +end; + +type + TLsaNtStatusToWinError = function (Status: NTSTATUS): ULONG; stdcall; + +var + _LsaNtStatusToWinError: TLsaNtStatusToWinError = nil; + +function LsaNtStatusToWinError(Status: NTSTATUS): ULONG; +begin + GetProcedureAddress(Pointer(@_LsaNtStatusToWinError), advapi32, 'LsaNtStatusToWinError'); + Result := _LsaNtStatusToWinError(Status); +end; + + +type + TCreateToolhelp32Snapshot = function (dwFlags, th32ProcessID: DWORD): THandle; stdcall; + +var + _CreateToolhelp32Snapshot: TCreateToolhelp32Snapshot = nil; + +function CreateToolhelp32Snapshot(dwFlags, th32ProcessID: DWORD): THandle; +begin + GetProcedureAddress(Pointer(@_CreateToolhelp32Snapshot), kernel32, 'CreateToolhelp32Snapshot'); + Result := _CreateToolhelp32Snapshot(dwFlags, th32ProcessID); +end; + +type + TThread32First = function (hSnapshot: THandle; var lpte: THREADENTRY32): BOOL; stdcall; + +var + _Thread32First: TThread32First = nil; + +function Thread32First(hSnapshot: THandle; var lpte: THREADENTRY32): BOOL; +begin + GetProcedureAddress(Pointer(@_Thread32First), kernel32, 'Thread32First'); + Result := _Thread32First(hSnapshot, lpte); +end; + +type + TThread32Next = function (hSnapshot: THandle; var lpte: THREADENTRY32): BOOL; stdcall; + +var + _Thread32Next: TThread32Next = nil; + +function Thread32Next(hSnapshot: THandle; var lpte: THREADENTRY32): BOOL; +begin + GetProcedureAddress(Pointer(@_Thread32Next), kernel32, 'Thread32Next'); + Result := _Thread32Next(hSnapshot, lpte); +end; + + +const + ntdll = 'ntdll.dll'; + +type + TNtQueryInformationThread = function (ThreadHandle: THandle; ThreadInformationClass: THREAD_INFORMATION_CLASS; + ThreadInformation: Pointer; ThreadInformationLength: ULONG; ReturnLength: PULONG): NTSTATUS; stdcall; + +var + _NtQueryInformationThread: TNtQueryInformationThread = nil; + +function NtQueryInformationThread(ThreadHandle: THandle; ThreadInformationClass: THREAD_INFORMATION_CLASS; + ThreadInformation: Pointer; ThreadInformationLength: ULONG; ReturnLength: PULONG): NTSTATUS; +begin + GetProcedureAddress(Pointer(@_NtQueryInformationThread), ntdll, 'NtQueryInformationThread'); + Result := _NtQueryInformationThread(ThreadHandle, ThreadInformationClass, ThreadInformation, ThreadInformationLength, ReturnLength); +end; + + + +{$IFDEF UNITVERSIONING} +initialization + RegisterUnitVersion(HInstance, UnitVersioning); + +finalization + UnregisterUnitVersion(HInstance); +{$ENDIF UNITVERSIONING} + +end. diff --git a/source/packages/jcl/LICENSE.txt b/source/packages/jcl/LICENSE.txt new file mode 100644 index 00000000..7714141d --- /dev/null +++ b/source/packages/jcl/LICENSE.txt @@ -0,0 +1,470 @@ + MOZILLA PUBLIC LICENSE + Version 1.1 + + --------------- + +1. Definitions. + + 1.0.1. "Commercial Use" means distribution or otherwise making the + Covered Code available to a third party. + + 1.1. "Contributor" means each entity that creates or contributes to + the creation of Modifications. + + 1.2. "Contributor Version" means the combination of the Original + Code, prior Modifications used by a Contributor, and the Modifications + made by that particular Contributor. + + 1.3. "Covered Code" means the Original Code or Modifications or the + combination of the Original Code and Modifications, in each case + including portions thereof. + + 1.4. "Electronic Distribution Mechanism" means a mechanism generally + accepted in the software development community for the electronic + transfer of data. + + 1.5. "Executable" means Covered Code in any form other than Source + Code. + + 1.6. "Initial Developer" means the individual or entity identified + as the Initial Developer in the Source Code notice required by Exhibit + A. + + 1.7. "Larger Work" means a work which combines Covered Code or + portions thereof with code not governed by the terms of this License. + + 1.8. "License" means this document. + + 1.8.1. "Licensable" means having the right to grant, to the maximum + extent possible, whether at the time of the initial grant or + subsequently acquired, any and all of the rights conveyed herein. + + 1.9. "Modifications" means any addition to or deletion from the + substance or structure of either the Original Code or any previous + Modifications. When Covered Code is released as a series of files, a + Modification is: + A. Any addition to or deletion from the contents of a file + containing Original Code or previous Modifications. + + B. Any new file that contains any part of the Original Code or + previous Modifications. + + 1.10. "Original Code" means Source Code of computer software code + which is described in the Source Code notice required by Exhibit A as + Original Code, and which, at the time of its release under this + License is not already Covered Code governed by this License. + + 1.10.1. "Patent Claims" means any patent claim(s), now owned or + hereafter acquired, including without limitation, method, process, + and apparatus claims, in any patent Licensable by grantor. + + 1.11. "Source Code" means the preferred form of the Covered Code for + making modifications to it, including all modules it contains, plus + any associated interface definition files, scripts used to control + compilation and installation of an Executable, or source code + differential comparisons against either the Original Code or another + well known, available Covered Code of the Contributor's choice. The + Source Code can be in a compressed or archival form, provided the + appropriate decompression or de-archiving software is widely available + for no charge. + + 1.12. "You" (or "Your") means an individual or a legal entity + exercising rights under, and complying with all of the terms of, this + License or a future version of this License issued under Section 6.1. + For legal entities, "You" includes any entity which controls, is + controlled by, or is under common control with You. For purposes of + this definition, "control" means (a) the power, direct or indirect, + to cause the direction or management of such entity, whether by + contract or otherwise, or (b) ownership of more than fifty percent + (50%) of the outstanding shares or beneficial ownership of such + entity. + +2. Source Code License. + + 2.1. The Initial Developer Grant. + The Initial Developer hereby grants You a world-wide, royalty-free, + non-exclusive license, subject to third party intellectual property + claims: + (a) under intellectual property rights (other than patent or + trademark) Licensable by Initial Developer to use, reproduce, + modify, display, perform, sublicense and distribute the Original + Code (or portions thereof) with or without Modifications, and/or + as part of a Larger Work; and + + (b) under Patents Claims infringed by the making, using or + selling of Original Code, to make, have made, use, practice, + sell, and offer for sale, and/or otherwise dispose of the + Original Code (or portions thereof). + + (c) the licenses granted in this Section 2.1(a) and (b) are + effective on the date Initial Developer first distributes + Original Code under the terms of this License. + + (d) Notwithstanding Section 2.1(b) above, no patent license is + granted: 1) for code that You delete from the Original Code; 2) + separate from the Original Code; or 3) for infringements caused + by: i) the modification of the Original Code or ii) the + combination of the Original Code with other software or devices. + + 2.2. Contributor Grant. + Subject to third party intellectual property claims, each Contributor + hereby grants You a world-wide, royalty-free, non-exclusive license + + (a) under intellectual property rights (other than patent or + trademark) Licensable by Contributor, to use, reproduce, modify, + display, perform, sublicense and distribute the Modifications + created by such Contributor (or portions thereof) either on an + unmodified basis, with other Modifications, as Covered Code + and/or as part of a Larger Work; and + + (b) under Patent Claims infringed by the making, using, or + selling of Modifications made by that Contributor either alone + and/or in combination with its Contributor Version (or portions + of such combination), to make, use, sell, offer for sale, have + made, and/or otherwise dispose of: 1) Modifications made by that + Contributor (or portions thereof); and 2) the combination of + Modifications made by that Contributor with its Contributor + Version (or portions of such combination). + + (c) the licenses granted in Sections 2.2(a) and 2.2(b) are + effective on the date Contributor first makes Commercial Use of + the Covered Code. + + (d) Notwithstanding Section 2.2(b) above, no patent license is + granted: 1) for any code that Contributor has deleted from the + Contributor Version; 2) separate from the Contributor Version; + 3) for infringements caused by: i) third party modifications of + Contributor Version or ii) the combination of Modifications made + by that Contributor with other software (except as part of the + Contributor Version) or other devices; or 4) under Patent Claims + infringed by Covered Code in the absence of Modifications made by + that Contributor. + +3. Distribution Obligations. + + 3.1. Application of License. + The Modifications which You create or to which You contribute are + governed by the terms of this License, including without limitation + Section 2.2. The Source Code version of Covered Code may be + distributed only under the terms of this License or a future version + of this License released under Section 6.1, and You must include a + copy of this License with every copy of the Source Code You + distribute. You may not offer or impose any terms on any Source Code + version that alters or restricts the applicable version of this + License or the recipients' rights hereunder. However, You may include + an additional document offering the additional rights described in + Section 3.5. + + 3.2. Availability of Source Code. + Any Modification which You create or to which You contribute must be + made available in Source Code form under the terms of this License + either on the same media as an Executable version or via an accepted + Electronic Distribution Mechanism to anyone to whom you made an + Executable version available; and if made available via Electronic + Distribution Mechanism, must remain available for at least twelve (12) + months after the date it initially became available, or at least six + (6) months after a subsequent version of that particular Modification + has been made available to such recipients. You are responsible for + ensuring that the Source Code version remains available even if the + Electronic Distribution Mechanism is maintained by a third party. + + 3.3. Description of Modifications. + You must cause all Covered Code to which You contribute to contain a + file documenting the changes You made to create that Covered Code and + the date of any change. You must include a prominent statement that + the Modification is derived, directly or indirectly, from Original + Code provided by the Initial Developer and including the name of the + Initial Developer in (a) the Source Code, and (b) in any notice in an + Executable version or related documentation in which You describe the + origin or ownership of the Covered Code. + + 3.4. Intellectual Property Matters + (a) Third Party Claims. + If Contributor has knowledge that a license under a third party's + intellectual property rights is required to exercise the rights + granted by such Contributor under Sections 2.1 or 2.2, + Contributor must include a text file with the Source Code + distribution titled "LEGAL" which describes the claim and the + party making the claim in sufficient detail that a recipient will + know whom to contact. If Contributor obtains such knowledge after + the Modification is made available as described in Section 3.2, + Contributor shall promptly modify the LEGAL file in all copies + Contributor makes available thereafter and shall take other steps + (such as notifying appropriate mailing lists or newsgroups) + reasonably calculated to inform those who received the Covered + Code that new knowledge has been obtained. + + (b) Contributor APIs. + If Contributor's Modifications include an application programming + interface and Contributor has knowledge of patent licenses which + are reasonably necessary to implement that API, Contributor must + also include this information in the LEGAL file. + + (c) Representations. + Contributor represents that, except as disclosed pursuant to + Section 3.4(a) above, Contributor believes that Contributor's + Modifications are Contributor's original creation(s) and/or + Contributor has sufficient rights to grant the rights conveyed by + this License. + + 3.5. Required Notices. + You must duplicate the notice in Exhibit A in each file of the Source + Code. If it is not possible to put such notice in a particular Source + Code file due to its structure, then You must include such notice in a + location (such as a relevant directory) where a user would be likely + to look for such a notice. If You created one or more Modification(s) + You may add your name as a Contributor to the notice described in + Exhibit A. You must also duplicate this License in any documentation + for the Source Code where You describe recipients' rights or ownership + rights relating to Covered Code. You may choose to offer, and to + charge a fee for, warranty, support, indemnity or liability + obligations to one or more recipients of Covered Code. However, You + may do so only on Your own behalf, and not on behalf of the Initial + Developer or any Contributor. You must make it absolutely clear than + any such warranty, support, indemnity or liability obligation is + offered by You alone, and You hereby agree to indemnify the Initial + Developer and every Contributor for any liability incurred by the + Initial Developer or such Contributor as a result of warranty, + support, indemnity or liability terms You offer. + + 3.6. Distribution of Executable Versions. + You may distribute Covered Code in Executable form only if the + requirements of Section 3.1-3.5 have been met for that Covered Code, + and if You include a notice stating that the Source Code version of + the Covered Code is available under the terms of this License, + including a description of how and where You have fulfilled the + obligations of Section 3.2. The notice must be conspicuously included + in any notice in an Executable version, related documentation or + collateral in which You describe recipients' rights relating to the + Covered Code. You may distribute the Executable version of Covered + Code or ownership rights under a license of Your choice, which may + contain terms different from this License, provided that You are in + compliance with the terms of this License and that the license for the + Executable version does not attempt to limit or alter the recipient's + rights in the Source Code version from the rights set forth in this + License. If You distribute the Executable version under a different + license You must make it absolutely clear that any terms which differ + from this License are offered by You alone, not by the Initial + Developer or any Contributor. You hereby agree to indemnify the + Initial Developer and every Contributor for any liability incurred by + the Initial Developer or such Contributor as a result of any such + terms You offer. + + 3.7. Larger Works. + You may create a Larger Work by combining Covered Code with other code + not governed by the terms of this License and distribute the Larger + Work as a single product. In such a case, You must make sure the + requirements of this License are fulfilled for the Covered Code. + +4. Inability to Comply Due to Statute or Regulation. + + If it is impossible for You to comply with any of the terms of this + License with respect to some or all of the Covered Code due to + statute, judicial order, or regulation then You must: (a) comply with + the terms of this License to the maximum extent possible; and (b) + describe the limitations and the code they affect. Such description + must be included in the LEGAL file described in Section 3.4 and must + be included with all distributions of the Source Code. Except to the + extent prohibited by statute or regulation, such description must be + sufficiently detailed for a recipient of ordinary skill to be able to + understand it. + +5. Application of this License. + + This License applies to code to which the Initial Developer has + attached the notice in Exhibit A and to related Covered Code. + +6. Versions of the License. + + 6.1. New Versions. + Netscape Communications Corporation ("Netscape") may publish revised + and/or new versions of the License from time to time. Each version + will be given a distinguishing version number. + + 6.2. Effect of New Versions. + Once Covered Code has been published under a particular version of the + License, You may always continue to use it under the terms of that + version. You may also choose to use such Covered Code under the terms + of any subsequent version of the License published by Netscape. No one + other than Netscape has the right to modify the terms applicable to + Covered Code created under this License. + + 6.3. Derivative Works. + If You create or use a modified version of this License (which you may + only do in order to apply it to code which is not already Covered Code + governed by this License), You must (a) rename Your license so that + the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape", + "MPL", "NPL" or any confusingly similar phrase do not appear in your + license (except to note that your license differs from this License) + and (b) otherwise make it clear that Your version of the license + contains terms which differ from the Mozilla Public License and + Netscape Public License. (Filling in the name of the Initial + Developer, Original Code or Contributor in the notice described in + Exhibit A shall not of themselves be deemed to be modifications of + this License.) + +7. DISCLAIMER OF WARRANTY. + + COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF + DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. + THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE + IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, + YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE + COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER + OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF + ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. + +8. TERMINATION. + + 8.1. This License and the rights granted hereunder will terminate + automatically if You fail to comply with terms herein and fail to cure + such breach within 30 days of becoming aware of the breach. All + sublicenses to the Covered Code which are properly granted shall + survive any termination of this License. Provisions which, by their + nature, must remain in effect beyond the termination of this License + shall survive. + + 8.2. If You initiate litigation by asserting a patent infringement + claim (excluding declatory judgment actions) against Initial Developer + or a Contributor (the Initial Developer or Contributor against whom + You file such action is referred to as "Participant") alleging that: + + (a) such Participant's Contributor Version directly or indirectly + infringes any patent, then any and all rights granted by such + Participant to You under Sections 2.1 and/or 2.2 of this License + shall, upon 60 days notice from Participant terminate prospectively, + unless if within 60 days after receipt of notice You either: (i) + agree in writing to pay Participant a mutually agreeable reasonable + royalty for Your past and future use of Modifications made by such + Participant, or (ii) withdraw Your litigation claim with respect to + the Contributor Version against such Participant. If within 60 days + of notice, a reasonable royalty and payment arrangement are not + mutually agreed upon in writing by the parties or the litigation claim + is not withdrawn, the rights granted by Participant to You under + Sections 2.1 and/or 2.2 automatically terminate at the expiration of + the 60 day notice period specified above. + + (b) any software, hardware, or device, other than such Participant's + Contributor Version, directly or indirectly infringes any patent, then + any rights granted to You by such Participant under Sections 2.1(b) + and 2.2(b) are revoked effective as of the date You first made, used, + sold, distributed, or had made, Modifications made by that + Participant. + + 8.3. If You assert a patent infringement claim against Participant + alleging that such Participant's Contributor Version directly or + indirectly infringes any patent where such claim is resolved (such as + by license or settlement) prior to the initiation of patent + infringement litigation, then the reasonable value of the licenses + granted by such Participant under Sections 2.1 or 2.2 shall be taken + into account in determining the amount or value of any payment or + license. + + 8.4. In the event of termination under Sections 8.1 or 8.2 above, + all end user license agreements (excluding distributors and resellers) + which have been validly granted by You or any distributor hereunder + prior to termination shall survive termination. + +9. LIMITATION OF LIABILITY. + + UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT + (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL + DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, + OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR + ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY + CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, + WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER + COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN + INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF + LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY + RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW + PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE + EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO + THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. + +10. U.S. GOVERNMENT END USERS. + + The Covered Code is a "commercial item," as that term is defined in + 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer + software" and "commercial computer software documentation," as such + terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 + C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), + all U.S. Government End Users acquire Covered Code with only those + rights set forth herein. + +11. MISCELLANEOUS. + + This License represents the complete agreement concerning subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the extent + necessary to make it enforceable. This License shall be governed by + California law provisions (except to the extent applicable law, if + any, provides otherwise), excluding its conflict-of-law provisions. + With respect to disputes in which at least one party is a citizen of, + or an entity chartered or registered to do business in the United + States of America, any litigation relating to this License shall be + subject to the jurisdiction of the Federal Courts of the Northern + District of California, with venue lying in Santa Clara County, + California, with the losing party responsible for costs, including + without limitation, court costs and reasonable attorneys' fees and + expenses. The application of the United Nations Convention on + Contracts for the International Sale of Goods is expressly excluded. + Any law or regulation which provides that the language of a contract + shall be construed against the drafter shall not apply to this + License. + +12. RESPONSIBILITY FOR CLAIMS. + + As between Initial Developer and the Contributors, each party is + responsible for claims and damages arising, directly or indirectly, + out of its utilization of rights under this License and You agree to + work with Initial Developer and Contributors to distribute such + responsibility on an equitable basis. Nothing herein is intended or + shall be deemed to constitute any admission of liability. + +13. MULTIPLE-LICENSED CODE. + + Initial Developer may designate portions of the Covered Code as + "Multiple-Licensed". "Multiple-Licensed" means that the Initial + Developer permits you to utilize portions of the Covered Code under + Your choice of the NPL or the alternative licenses, if any, specified + by the Initial Developer in the file described in Exhibit A. + +EXHIBIT A -Mozilla Public License. + + ``The contents of this file are subject to the Mozilla Public License + Version 1.1 (the "License"); you may not use this file except in + compliance with the License. You may obtain a copy of the License at + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" + basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the + License for the specific language governing rights and limitations + under the License. + + The Original Code is ______________________________________. + + The Initial Developer of the Original Code is ________________________. + Portions created by ______________________ are Copyright (C) ______ + _______________________. All Rights Reserved. + + Contributor(s): ______________________________________. + + Alternatively, the contents of this file may be used under the terms + of the _____ license (the "[___] License"), in which case the + provisions of [______] License are applicable instead of those + above. If you wish to allow use of your version of this file only + under the terms of the [____] License and not to allow others to use + your version of this file under the MPL, indicate your decision by + deleting the provisions above and replace them with the notice and + other provisions required by the [___] License. If you do not delete + the provisions above, a recipient may use your version of this file + under either the MPL or the [___] License." + + [NOTE: The text of this Exhibit A may differ slightly from the text of + the notices in the Source Code files of the Original Code. You should + use the text of this Exhibit A rather than the text found in the + Original Code Source Code for Your Modifications.] + diff --git a/source/packages/jcl/crossplatform.inc b/source/packages/jcl/crossplatform.inc new file mode 100644 index 00000000..c47d1def --- /dev/null +++ b/source/packages/jcl/crossplatform.inc @@ -0,0 +1,35 @@ +{**************************************************************************************************} +{ } +{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License");} +{ you may not use this file except in compliance with the License. You may obtain a copy of the } +{ License at http://www.mozilla.org/MPL/ } +{ } +{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF } +{ ANY KIND, either express or implied. See the License for the specific language governing rights } +{ and limitations under the License. } +{ } +{ The Original Code is: crossplatform.inc, released on 2004-05-16. } +{ } +{ You may retrieve the latest version of this file at the JCL home page, } +{ located at http://jcl.sourceforge.net/ } +{ } +{**************************************************************************************************} +{ } +{ Last modified: $Date:: $ } +{ Revision: $Rev:: $ } +{ Author: $Author:: $ } +{ } +{**************************************************************************************************} + +// This inc file depends on jedi.inc which has to +// be included first (usually indirectly through +// the inclusion of jcl.inc). + +// Suppress platform warnings which are irrelevant +// because the including unit inherently has to handle +// platform specifics already. + +{$IFDEF SUPPORTS_PLATFORM_WARNINGS} + {$WARN UNIT_PLATFORM OFF} + {$WARN SYMBOL_PLATFORM OFF} +{$ENDIF SUPPORTS_PLATFORM_WARNINGS} \ No newline at end of file diff --git a/source/packages/jcl/jcl.inc b/source/packages/jcl/jcl.inc new file mode 100644 index 00000000..a1bdf08b --- /dev/null +++ b/source/packages/jcl/jcl.inc @@ -0,0 +1,574 @@ +{**************************************************************************************************} +{ } +{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License");} +{ you may not use this file except in compliance with the License. You may obtain a copy of the } +{ License at http://www.mozilla.org/MPL/ } +{ } +{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF } +{ ANY KIND, either express or implied. See the License for the specific language governing rights } +{ and limitations under the License. } +{ } +{ The Original Code is jcl.inc } +{ } +{ The Initial Developer of the Original Code is Marcel van Brakel. } +{ Portions created by Marcel van Brakel are Copyright (C) Marcel van Brakel. } +{ } +{ Contributors: } +{ Marcel van Brakel } +{ Matthias Thoma (mthoma) } +{ Petr Vones } +{ Robert Marquardt (marquardt) } +{ Robert Rossmair (rrossmair) } +{ } +{**************************************************************************************************} +{ } +{ This include file defines various JCL specific defines. The more generic defines are defined in } +{ the jedi.inc file which is shared with the JEDI VCL. } +{ } +{**************************************************************************************************} +{ } +{ Last modified: $Date:: $ } +{ Revision: $Rev:: $ } +{ Author: $Author:: $ } +{ } +{**************************************************************************************************} + +{$BOOLEVAL OFF} // Boolean shortcut evaluation +{$LONGSTRINGS ON} // Long strings +{$WRITEABLECONST OFF} // Read-only typed constants +{$TYPEDADDRESS OFF} // Type checked pointers off +{$LOCALSYMBOLS ON} // Local symbol information +{$DEFINITIONINFO ON} // Symbol definition information +{$REFERENCEINFO ON} // Symbol reference information + +{$IFDEF WINSCP} +{$I jedi.inc} // Pull in the JCL/J-VCL shared directives +{$ELSE} +{$I jedi\jedi.inc} // Pull in the JCL/J-VCL shared directives +{$ENDIF} + +{$IFNDEF JEDI_INC} +ALERT_jedi_inc_incompatible +// secure against old versions of jedi.inc. +{$ENDIF ~JEDI_INC} + +{$IFNDEF JCLINSTALL} + {$IFDEF CLR} + {----------------------------} + { BDS } + {----------------------------} + {$IFDEF BDS3} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jcld9.net.inc} + {$DEFINE JCL_CONFIGURED} + {$ENDIF BDS3} + {----------------------------} + {$IFDEF BDS4} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jcld10.net.inc} + {$DEFINE JCL_CONFIGURED} + {$ENDIF BDS4} + {----------------------------} + {$IFDEF BDS5} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jcld11.net.inc} + {$DEFINE JCL_CONFIGURED} + {$ENDIF BDS5} + {----------------------------} + {$ELSE ~CLR} + {----------------------------} + { C++Builder } + {----------------------------} + {$IFDEF BCB5} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jclc5.inc} + {$DEFINE JCL_CONFIGURED} + {$ENDIF BCB5} + {----------------------------} + {$IFDEF BCB6} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jclc6.inc} + {$DEFINE JCL_CONFIGURED} + {$ENDIF BCB6} + {----------------------------} + { Delphi } + {----------------------------} + {$IFDEF DELPHI5} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jcld5.inc} + {$DEFINE JCL_CONFIGURED} + {$ENDIF DELPIH5} + {----------------------------} + {$IFDEF DELPHI6} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jcld6.inc} + {$DEFINE JCL_CONFIGURED} + {$ENDIF DELPIH6} + {----------------------------} + {$IFDEF DELPHI7} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jcld7.inc} + {$DEFINE JCL_CONFIGURED} + {$ENDIF DELPIH7} + {----------------------------} + { BDS } + {----------------------------} + // BDS 1 and BDS 2 have the same version numbers for their native compilers + // no compiler defines are used for BDS 1 and BDS 2 + {$IFDEF BDS1} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + //{$I jclcs1.inc} + {$DEFINE JCL_CONFIGURED} + {$ENDIF BDS1} + {----------------------------} + {$IFDEF BDS2} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + //{$I jcld8.inc} + {$DEFINE JCL_CONFIGURED} + {$ENDIF BDS2} + {----------------------------} + {$IFDEF BDS3} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jcld9.inc} + {$DEFINE JCL_CONFIGURED} + {$ENDIF BDS3} + {----------------------------} + {$IFDEF BDS4} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jcld10.inc} + {$DEFINE JCL_CONFIGURED} + {$ENDIF BDS4} + {----------------------------} + {$IFDEF BDS5} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jcld11.inc} + {$DEFINE JCL_CONFIGURED} + {$ENDIF BDS5} + {----------------------------} + {$IFDEF BDS6} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jcld12.inc} + {$DEFINE JCL_CONFIGURED} + {$ENDIF BDS6} + {----------------------------} + {$IFDEF BDS7} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jcld14.inc} + {$DEFINE JCL_CONFIGURED} + {$ENDIF BDS7} + {----------------------------} + {$IFDEF BDS8} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jcld15.inc} + {$DEFINE JCL_CONFIGURED} + {$ENDIF BDS8} + {----------------------------} + {$IFDEF BDS9} + {$IFDEF MSWINDOWS} + {$IFDEF CPUX86} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jcld16win32.inc} + {$ENDIF CPUX86} + {$IFDEF CPUX64} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jcld16win64.inc} + {$ENDIF CPUX64} + {$DEFINE JCL_CONFIGURED} + {$ENDIF MSWINDOWS} + {$ENDIF BDS9} + {----------------------------} + {$IFDEF BDS10} + {$IFDEF MSWINDOWS} + {$IFDEF CPUX86} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jcld17win32.inc} + {$ENDIF CPUX86} + {$IFDEF CPUX64} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jcld17win64.inc} + {$ENDIF CPUX64} + {$DEFINE JCL_CONFIGURED} + {$ENDIF MSWINDOWS} + {$ENDIF BDS10} + {----------------------------} + {$IFDEF BDS11} + {$IFDEF MSWINDOWS} + {$IFDEF CPUX86} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jcld18win32.inc} + {$ENDIF CPUX86} + {$IFDEF CPUX64} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jcld18win64.inc} + {$ENDIF CPUX64} + {$DEFINE JCL_CONFIGURED} + {$ENDIF MSWINDOWS} + {$ENDIF BDS11} + {----------------------------} + {$IFDEF BDS12} + {$IFDEF MSWINDOWS} + {$IFDEF CPUX86} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jcld19win32.inc} + {$ENDIF CPUX86} + {$IFDEF CPUX64} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jcld19win64.inc} + {$ENDIF CPUX64} + {$DEFINE JCL_CONFIGURED} + {$ENDIF MSWINDOWS} + {$ENDIF BDS12} + {----------------------------} + {$IFDEF BDS14} + {$IFDEF MSWINDOWS} + {$IFDEF CPUX86} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jcld20win32.inc} + {$ENDIF CPUX86} + {$IFDEF CPUX64} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jcld20win64.inc} + {$ENDIF CPUX64} + {$DEFINE JCL_CONFIGURED} + {$ENDIF MSWINDOWS} + {$ENDIF BDS14} + {----------------------------} + {$IFDEF FPC} + // This file should be located in directory jcl/source/include + // It is automatically created by the JCL installer + // For manual installations, copy and adjust jcl/source/include/jcl.template.inc + {$I jclfpc.inc} + {$DEFINE JCL_CONFIGURED} + {$ENDIF FPC} + {----------------------------} + {$ENDIF ~CLR} + + // check configuration + {$IFNDEF JCL_CONFIGURED} + {$IFDEF SUPPORTS_COMPILETIME_MESSAGES} + {$MESSAGE FATAL 'Your Delphi/BCB version is not supported by this JCL version!'} + {$ELSE ~SUPPORTS_COMPILETIME_MESSAGES} + 'Your Delphi/BCB version is not supported by this JCL version!' + {$ENDIF ~SUPPORTS_COMPILETIME_MESSAGES} + {$ENDIF !JCL_CONFIGURED} + +{$ENDIF ~JCLINSTALL} + +// Math precision selection, mutually exclusive +{$IFDEF MATH_EXTENDED_PRECISION} + {$UNDEF MATH_SINGLE_PRECISION} + {$UNDEF MATH_DOUBLE_PRECISION} +{$ENDIF} +{$IFDEF MATH_DOUBLE_PRECISION} + {$UNDEF MATH_SINGLE_PRECISION} + {$UNDEF MATH_EXTENDED_PRECISION} +{$ENDIF} +{$IFDEF MATH_SINGLE_PRECISION} + {$UNDEF MATH_DOUBLE_PRECISION} + {$UNDEF MATH_EXTENDED_PRECISION} +{$ENDIF} + +{$IFNDEF MATH_EXTENDED_PRECISION} + {$IFNDEF MATH_DOUBLE_PRECISION} + {$IFNDEF MATH_SINGLE_PRECISION} + {$IFDEF FPC} + {$IFDEF CPU64} + {$DEFINE MATH_DOUBLE_PRECISION} + {$ELSE ~CPU64} + {$DEFINE MATH_EXTENDED_PRECISION} + {$ENDIF ~CPU64} + {$ELSE ~FPC} + {$DEFINE MATH_EXTENDED_PRECISION} + {$ENDIF ~FPC} + {$ENDIF} + {$ENDIF} +{$ENDIF} + +{$IFDEF MATH_EXTENDED_PRECISION} + {$IFDEF CPU64} + {$IFDEF FPC} + {$MESSAGE FATAL 'FPC does not support extended floating points on x86_64!'} + {$ENDIF FPC} + {$ENDIF CPU64} +{$ENDIF MATH_EXTENDED_PRECISION} + +// PCRE options, mutually exclusive +{$IFDEF PCRE_STATICLINK} + {$UNDEF PCRE_LINKDLL} + {$UNDEF PCRE_LINKONREQUEST} + {$UNDEF PCRE_RTL} +{$ENDIF PCRE_STATICLINK} +{$IFDEF PCRE_LINKDLL} + {$UNDEF PCRE_LINKONREQUEST} + {$UNDEF PCRE_RTL} +{$ENDIF PCRE_LINKDLL} +{$IFDEF PCRE_LINKONREQUEST} + {$UNDEF PCRE_RTL} +{$ENDIF PCRE_LINKONREQUEST} + +{$IFNDEF PCRE_STATICLINK} + {$IFNDEF PCRE_LINKDLL} + {$IFNDEF PCRE_LINKONREQUEST} + {$IFNDEF PCRE_RTL} + {$DEFINE PCRE_LINKONREQUEST} + {$ENDIF ~PCRE_RTL} + {$ENDIF ~PCRE_LINKONREQUEST} + {$ENDIF ~PCRE_LINKDLL} +{$ENDIF ~PCRE_STATICLINK} + +{$IFNDEF PCRE_STATICLINK} + {$IFNDEF PCRE_RTL} + {$DEFINE PCRE_EXPORT_CDECL} + {$ENDIF ~PCRE_RTL} +{$ENDIF ~PCRE_STATICLINK} + +{$IFNDEF PCRE_STATICLINK} + {$UNDEF PCRE_16} +{$ENDIF ~PCRE_STATICLINK} + +{$IFNDEF PCRE_8} + {$IFNDEF PCRE_16} + {$DEFINE PCRE_RTL} + {$UNDEF PCRE_STATICLINK} + {$UNDEF PCRE_LINKDLL} + {$UNDEF PCRE_LINKONREQUEST} + {$ENDIF ~PCRE_16} +{$ENDIF ~PCRE_8} + +{$IFDEF PCRE_8} + {$IFDEF PCRE_16} + {$IFDEF PCRE_PREFER_16} + {$DEFINE JCL_PCRE_16} + {$ELSE ~PCRE_PREFER_16} + {$DEFINE JCL_PCRE_8} + {$ENDIF ~PCRE_PREFER_16} + {$ELSE ~PCRE_16} + {$DEFINE JCL_PCRE_8} + {$ENDIF ~PCRE_16} +{$ELSE ~PCRE_8} + {$IFDEF PCRE_16} + {$DEFINE JCL_PCRE_16} + {$ENDIF PCRE_16} +{$ENDIF ~PCRE_8} + +{$IFDEF JCL_PCRE_8} + {$DEFINE JCL_PCRE} +{$ENDIF JCL_PCRE_8} + +{$IFDEF JCL_PCRE_16} + {$DEFINE JCL_PCRE} +{$ENDIF JCL_PCRE_16} + +// BZip2 options +{$IFDEF BZIP2_STATICLINK} + {$UNDEF BZIP2_LINKDLL} + {$UNDEF BZIP2_LINKONREQUEST} +{$ENDIF BZIP2_STATICLINK} +{$IFDEF BZIP2_LINKDLL} + {$UNDEF BZIP2_LINKONREQUEST} +{$ENDIF BZIP2_LINKDLL} + +{$IFNDEF BZIP2_STATICLINK} + {$IFNDEF BZIP2_LINKDLL} + {$IFNDEF BZIP2_LINKONREQUEST} + {$DEFINE BZIP2_STATICLINK} + {$ENDIF ~BZIP2_LINKONREQUEST} + {$ENDIF ~BZIP2_LINKDLL} +{$ENDIF ~BZIP2_STATICLINK} + +{$IFDEF BZIP2_STATICLINK} + {$DEFINE BZIP2_EXPORT_STDCALL} +{$ENDIF BZIP2_STATICLINK} + +{$IFDEF BZIP2_LINKDLL} + {$DEFINE BZIP2_EXPORT_CDECL} +{$ENDIF BZIP2_LINKDLL} + +{$IFDEF BZIP2_LINKONREQUEST} + {$DEFINE BZIP2_EXPORT_CDECL} +{$ENDIF BZIP2_LINKONREQUEST} + + +// ZLib options +{$IFDEF ZLIB_STATICLINK} + {$UNDEF ZLIB_LINKDLL} + {$UNDEF ZLIB_LINKONREQUEST} + {$UNDEF ZLIB_RTL} +{$ENDIF ZLIB_STATICLINK} +{$IFDEF ZLIB_LINKDLL} + {$UNDEF ZLIB_LINKONREQUEST} + {$UNDEF ZLIB_RTL} +{$ENDIF ZLIB_LINKDLL} +{$IFDEF ZLIB_LINKONREQUEST} + {$UNDEF ZLIB_RTL} +{$ENDIF ZLIB_LINKONREQUEST} + +{$IFNDEF ZLIB_STATICLINK} + {$IFNDEF ZLIB_LINKDLL} + {$IFNDEF ZLIB_LINKONREQUEST} + {$IFNDEF ZLIB_RTL} + {$DEFINE ZLIB_STATICLINK} + {$ENDIF ~ZLIB_RTL} + {$ENDIF ~ZLIB_LINKONREQUEST} + {$ENDIF ~ZLIB_LINKDLL} +{$ENDIF ~ZLIB_STATICLINK} + +{$IFDEF ZLIB_LINKDLL} + {$DEFINE ZLIB_EXPORT_CDECL} +{$ENDIF ZLIB_LINKDLL} +{$IFDEF ZLIB_LINKONREQUEST} + {$DEFINE ZLIB_EXPORT_CDECL} +{$ENDIF ZLIB_LINKONREQUEST} +// calling convention for static link is fastcall + +{$IFNDEF HAS_UNIT_CHARACTER} + {$UNDEF UNICODE_RTL_DATABASE} +{$ENDIF ~HAS_UNIT_CHARACTER} + +{$IFDEF UNICODE_RAW_DATA} + {$UNDEF UNICODE_ZLIB_DATA} + {$UNDEF UNICODE_BZIP2_DATA} +{$ENDIF UNICODE_RAW_DATA} + +{$IFDEF UNICODE_ZLIB_DATA} + {$UNDEF UNICODE_RAW_DATA} + {$UNDEF UNICODE_BZIP2_DATA} +{$ENDIF UNICODE_ZLIB_DATA} + +{$IFNDEF UNICODE_ZLIB_DATA} + {$IFNDEF UNICODE_BZIP2_DATA} + {$DEFINE UNICODE_RAW_DATA} + {$ENDIF ~UNICODE_BZIP2_DATA} +{$ENDIF ~UNICODE_ZLIB_DATA} + +{$IFDEF CONTAINER_ANSISTR} + {$UNDEF CONTAINER_WIDESTR} + {$UNDEF CONTAINER_UNICODESTR} + {$UNDEF CONTAINER_NOSTR} +{$ENDIF CONTAINER_ANSISTR} + +{$IFDEF CONTAINER_WIDESTR} + {$UNDEF CONTAINER_UNICODESTR} + {$UNDEF CONTAINER_NOSTR} +{$ENDIF CONTAINER_WIDESTR} + +{$IFDEF CONTAINER_UNICODESTR} + {$UNDEF CONTAINER_NOSTR} +{$ENDIF CONTAINER_UNICODESTR} + +{$IFNDEF CONTAINER_ANSISTR} + {$IFNDEF CONTAINER_WIDESTR} + {$IFNDEF CONTAINER_UNICODESTR} + {$IFNDEF CONTAINER_NOSTR} + {$IFDEF SUPPORTS_UNICODE_STRING} + {$DEFINE CONTAINER_UNICODESTR} + {$ELSE ~SUPPORTS_UNICODE_STRING} + {$DEFINE CONTAINER_ANSISTR} + {$ENDIF ~SUPPORTS_UNICODE_STRING} + {$ENDIF ~CONTAINER_NOSTR} + {$ENDIF ~CONTAINER_UNICODESTR} + {$ENDIF ~CONTAINER_WIDESTR} +{$ENDIF ~CONTAINER_ANSISTR} + +// 7zip options +{$IFDEF 7ZIP_STATICLINK} + {$UNDEF 7ZIP_LINKDLL} + {$UNDEF 7ZIP_LINKONREQUEST} +{$ENDIF 7ZIP_STATICLINK} + +{$IFDEF 7ZIP_LINKDLL} + {$UNDEF 7ZIP_LINKONREQUEST} +{$ENDIF 7ZIP_LINKDLL} + +{$IFNDEF 7ZIP_STATICLINK} + {$IFNDEF 7ZIP_LINKDLL} + {$IFNDEF 7ZIP_LINKONREQUEST} + {$DEFINE 7ZIP_LINKONREQUEST} + {$ENDIF ~7ZIP_LINKONREQUEST} + {$ENDIF ~7ZIP_LINKDLL} +{$ENDIF ~7ZIP_STATICLINK} + +{$IFDEF SUPPORTS_UNSAFE_WARNINGS} + {$WARN UNSAFE_TYPE OFF} + {$WARN UNSAFE_CODE OFF} + {$WARN UNSAFE_CAST OFF} +{$ENDIF} + +{$IFNDEF DROP_OBSOLETE_CODE} + {$IFNDEF JCLINSTALL} + {$DEFINE KEEP_DEPRECATED} + {$ENDIF} +{$ENDIF} + +{$IFDEF CLR} + {$WARN UNSAFE_TYPE ON} + {$WARN UNSAFE_CODE ON} + {$WARN UNSAFE_CAST ON} + {$WARN UNIT_PLATFORM OFF} + + {$DEFINE MSWINDOWS} + {$DEFINE PIC} + {$DEFINE PUREPASCAL} +{$ENDIF CLR} + +// Delphi 2005 has a compiler internal failure when compiling the JCL with UNITVERSIONING enabled +{$IFDEF DELPHI2005} + {$UNDEF UNITVERSIONING} +{$ENDIF DELPHI2005} + +{$IFDEF FPC} + {$DEFINE DEBUG_NO_TD32} +{$ENDIF FPC} + diff --git a/source/packages/jcl/jcld20win32.inc b/source/packages/jcl/jcld20win32.inc new file mode 100644 index 00000000..053ad96c --- /dev/null +++ b/source/packages/jcl/jcld20win32.inc @@ -0,0 +1,141 @@ +{**************************************************************************************************} +{ } +{ Project JEDI Code Library (JCL) } +{ } +{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); } +{ you may not use this file except in compliance with the License. You may obtain a copy of the } +{ License at http://www.mozilla.org/MPL/ } +{ } +{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF } +{ ANY KIND, either express or implied. See the License for the specific language governing rights } +{ and limitations under the License. } +{ } +{ The Original Code is jcl.inc } +{ } +{ The Initial Developer of the Original Code is Marcel van Brakel. } +{ Portions created by Marcel van Brakel are Copyright (C) Marcel van Brakel. } +{ } +{ Contributors: } +{ Marcel van Brakel } +{ Matthias Thoma (mthoma) } +{ Petr Vones } +{ Robert Marquardt (marquardt) } +{ Robert Rossmair (rrossmair) } +{ Florent Ouchet (outchy) } +{ } +{**************************************************************************************************} +{ } +{ This include file defines various JCL specific defines. } +{ The more generic JCL defines are defined in jcl.inc and the generic defines in the jedi.inc file } +{ which is shared with the JEDI VCL. } +{ } +{**************************************************************************************************} +{ } +{ This file is filled by the JCL installer, all the changes made in its content will be lost the } +{ next time the JCL is installed. } +{ } +{**************************************************************************************************} + +// $Id$ + +// Math precision selection, mutually exclusive +// FPC does not support EXTENDED when targetting x86_64, MATH_DOUBLE_PRECISION is the default in this situation +{.$DEFINE MATH_EXTENDED_PRECISION} // default +{.$DEFINE MATH_DOUBLE_PRECISION} +{.$DEFINE MATH_SINGLE_PRECISION} + + +// Math functions takes care of infinites and NaN +{.$DEFINE MATH_EXT_EXTREMEVALUES} + + +// JclHookExcept support for hooking exceptions from DLLs +{.$DEFINE HOOK_DLL_EXCEPTIONS} + + +//Threadsafe directive +{.$DEFINE THREADSAFE} + + +// To exclude obsolete code from compilation, remove the point from the line below +{.$DEFINE DROP_OBSOLETE_CODE} + + +//Support for JclUnitVersioning.pas, not supported by Delphi 2005 (automatically disabled afterward) +{.$DEFINE UNITVERSIONING} + + +// debug sources +// defining these symbols will the debug source to be automatically registered +{.$DEFINE DEBUG_NO_BINARY} +{.$DEFINE DEBUG_NO_TD32} // automatically defined for FPC +{.$DEFINE DEBUG_NO_MAP} +{.$DEFINE DEBUG_NO_EXPORTS} +{.$DEFINE DEBUG_NO_SYMBOLS} + + +// PCRE options, mutually exclusive +// IMPORTANT: The static link works only for Delphi 2005 and newer +// (an internal error is raised on other compilers) +// Only one of the following defines can be defined at a time +// static link: PCRE_STATICLINK +// static dll import: PCRE_LINKDLL +// dynamic dll import: PCRE_LINKONREQUEST +// RTL's RegularExpressionsAPI: PCRE_RTL + +{.$DEFINE PCRE_STATICLINK} +{.$DEFINE PCRE_LINKDLL} +{.$DEFINE PCRE_LINKONREQUEST} // default +{.$DEFINE PCRE_RTL} // DXE and newer + +// ANSI/UTF8 PCRE +{$DEFINE PCRE_8} +// UCS2/UTF16 enabled PCRE +{$DEFINE PCRE_16} // only valid when PCRE_STATICLINK is enabled, the RTL does not support it and the DLL found over the internet are completly outdated. + +// use PCRE16 when available rather than good old PCRE8 +{$DEFINE PCRE_PREFER_16} + +// BZIP2 options, mutually exclusive + +{.$DEFINE BZIP2_STATICLINK} // default +{.$DEFINE BZIP2_LINKDLL} +{.$DEFINE BZIP2_LINKONREQUEST} + + +// ZLIB options, mutually exclusive + +{.$DEFINE ZLIB_STATICLINK} // default +{.$DEFINE ZLIB_LINKDLL} +{.$DEFINE ZLIB_LINKONREQUEST} +{.$DEFINE ZLIB_RTL} // DXE2 and newer only + + +// Unicode options +// use RTL Character Database rather than JCL one, less accurate but reduce executable size +{.$DEFINE UNICODE_RTL_DATABASE} + +// insert a replacement character if sequence is corrupted rather than raising an exception +{.$DEFINE UNICODE_SILENT_FAILURE} + +// defines resource compression (uncompressed, compressed with ZLib, compressed with BZip2), mutually exclusive +{.$DEFINE UNICODE_RAW_DATA} // default +{.$DEFINE UNICODE_ZLIB_DATA} +{.$DEFINE UNICODE_BZIP2_DATA} + + +// container options +// define mapping of TJclStr* containers to TJclAnsiStr* or TJclWideStr* (mutually exclusive) +{.$DEFINE CONTAINER_ANSISTR} // default for D2007 and older +{.$DEFINE CONTAINER_WIDESTR} +{.$DEFINE CONTAINER_UNICODESTR} // default for D2009 and newer, not supported for Delphi 2007 and older +{.$DEFINE CONTAINER_NOSTR} + + +// 7Zip options, mutually exclusive +// IMPORTANT: The static link is not supported yet + +{.$DEFINE 7ZIP_STATICLINK} // not supported yet +{.$DEFINE 7ZIP_LINKDLL} +{.$DEFINE 7ZIP_LINKONREQUEST} // default + diff --git a/source/packages/jcl/jedi.inc b/source/packages/jcl/jedi.inc new file mode 100644 index 00000000..b6d36b6a --- /dev/null +++ b/source/packages/jcl/jedi.inc @@ -0,0 +1,1566 @@ +{$IFNDEF JEDI_INC} +{$DEFINE JEDI_INC} + +{**************************************************************************************************} +{ } +{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License");} +{ you may not use this file except in compliance with the License. You may obtain a copy of the } +{ License at http://www.mozilla.org/MPL/ } +{ } +{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF } +{ ANY KIND, either express or implied. See the License for the specific language governing rights } +{ and limitations under the License. } +{ } +{ The Original Code is: jedi.inc. } +{ The Initial Developer of the Original Code is Project JEDI http://www.delphi-jedi.org } +{ } +{ Alternatively, the contents of this file may be used under the terms of the GNU Lesser General } +{ Public License (the "LGPL License"), in which case the provisions of the LGPL License are } +{ applicable instead of those above. If you wish to allow use of your version of this file only } +{ under the terms of the LGPL License and not to allow others to use your version of this file } +{ under the MPL, indicate your decision by deleting the provisions above and replace them with } +{ the notice and other provisions required by the LGPL License. If you do not delete the } +{ provisions above, a recipient may use your version of this file under either the MPL or the } +{ LGPL License. } +{ } +{ For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html } +{ } +{**************************************************************************************************} +{ } +{ This file defines various generic compiler directives used in different libraries, e.g. in the } +{ JEDI Code Library (JCL) and JEDI Visual Component Library Library (JVCL). The directives in } +{ this file are of generic nature and consist mostly of mappings from the VERXXX directives } +{ defined by Delphi, C++Builder and FPC to friendly names such as DELPHI5 and } +{ SUPPORTS_WIDESTRING. These friendly names are subsequently used in the libraries to test for } +{ compiler versions and/or whether the compiler supports certain features (such as widestrings or } +{ 64 bit integers. The libraries provide an additional, library specific, include file. For the } +{ JCL e.g. this is jcl.inc. These files should be included in source files instead of this file } +{ (which is pulled in automatically). } +{ } +{**************************************************************************************************} +{ } +{ Last modified: $Date:: $ } +{ Revision: $Rev:: $ } +{ Author: $Author:: $ } +{ } +{**************************************************************************************************} + +(* + +- Development environment directives + + This file defines two directives to indicate which development environment the + library is being compiled with. Currently this can either be Delphi, Kylix, + C++Builder or FPC. + + Directive Description + ------------------------------------------------------------------------------ + DELPHI Defined if compiled with Delphi + KYLIX Defined if compiled with Kylix + DELPHICOMPILER Defined if compiled with Delphi or Kylix/Delphi + BCB Defined if compiled with C++Builder + CPPBUILDER Defined if compiled with C++Builder (alias for BCB) + BCBCOMPILER Defined if compiled with C++Builder or Kylix/C++ + DELPHILANGUAGE Defined if compiled with Delphi, Kylix or C++Builder + BORLAND Defined if compiled with Delphi, Kylix or C++Builder + FPC Defined if compiled with FPC + +- Platform Directives + + Platform directives are not all explicitly defined in this file, some are + defined by the compiler itself. They are listed here only for completeness. + + Directive Description + ------------------------------------------------------------------------------ + WIN32 Defined when target platform is 32 bit Windows + WIN64 Defined when target platform is 64 bit Windows + MSWINDOWS Defined when target platform is 32 bit Windows + LINUX Defined when target platform is Linux + UNIX Defined when target platform is Unix-like (including Linux) + CLR Defined when target platform is .NET + +- Architecture directives. These are auto-defined by FPC + CPU32 and CPU64 are mostly for generic pointer size dependant differences rather + than for a specific architecture. + + CPU386 Defined when target platform is native x86 (win32) + CPUx86_64 Defined when target platform is native x86_64 (win64) + CPU32 Defined when target is 32-bit + CPU64 Defined when target is 64-bit + CPUASM Defined when target assembler is available + +- Visual library Directives + + The following directives indicate for a visual library. In a Delphi/BCB + (Win32) application you need to define the VisualCLX symbol in the project + options, if you want to use the VisualCLX library. Alternatively you can use + the IDE expert, which is distributed with the JCL to do this automatically. + + Directive Description + ------------------------------------------------------------------------------ + VCL Defined for Delphi/BCB (Win32) exactly if VisualCLX is not defined + VisualCLX Defined for Kylix; needs to be defined for Delphi/BCB to + use JCL with VisualCLX applications. + + +- Other cross-platform related defines + + These symbols are intended to help in writing portable code. + + Directive Description + ------------------------------------------------------------------------------ + PUREPASCAL Code is machine-independent (as opposed to assembler code) + Win32API Code is specific for the Win32 API; + use instead of "{$IFNDEF CLR} {$IFDEF MSWINDOWS}" constructs + + +- Delphi Versions + + The following directives are direct mappings from the VERXXX directives to a + friendly name of the associated compiler. These directives are only defined if + the compiler is Delphi (ie DELPHI is defined). + + Directive Description + ------------------------------------------------------------------------------ + DELPHI1 Defined when compiling with Delphi 1 (Codename WASABI/MANGO) + DELPHI2 Defined when compiling with Delphi 2 (Codename POLARIS) + DELPHI3 Defined when compiling with Delphi 3 (Codename IVORY) + DELPHI4 Defined when compiling with Delphi 4 (Codename ALLEGRO) + DELPHI5 Defined when compiling with Delphi 5 (Codename ARGUS) + DELPHI6 Defined when compiling with Delphi 6 (Codename ILLIAD) + DELPHI7 Defined when compiling with Delphi 7 (Codename AURORA) + DELPHI8 Defined when compiling with Delphi 8 (Codename OCTANE) + DELPHI2005 Defined when compiling with Delphi 2005 (Codename DIAMONDBACK) + DELPHI9 Alias for DELPHI2005 + DELPHI10 Defined when compiling with Delphi 2006 (Codename DEXTER) + DELPHI2006 Alias for DELPHI10 + DELPHI11 Defined when compiling with Delphi 2007 for Win32 (Codename SPACELY) + DELPHI2007 Alias for DELPHI11 + DELPHI12 Defined when compiling with Delphi 2009 for Win32 (Codename TIBURON) + DELPHI2009 Alias for DELPHI12 + DELPHI14 Defined when compiling with Delphi 2010 for Win32 (Codename WEAVER) + DELPHI2010 Alias for DELPHI14 + DELPHI15 Defined when compiling with Delphi XE for Win32 (Codename FULCRUM) + DELPHIXE Alias for DELPHI15 + DELPHI16 Defined when compiling with Delphi XE2 for Win32 (Codename PULSAR) + DELPHIXE2 Alias for DELPHI16 + DELPHI17 Defined when compiling with Delphi XE3 for Win32 (Codename WATERDRAGON) + DELPHIXE3 Alias for DELPHI17 + DELPHI18 Defined when compiling with Delphi XE4 for Win32 (Codename QUINTESSENCE) + DELPHIXE4 Alias for DELPHI18 + DELPHI19 Defined when compiling with Delphi XE5 for Win32 (Codename ZEPHYR) + DELPHIXE5 Alias for DELPHI19 + DELPHI20 Defined when compiling with Delphi XE6 for Win32 (Codename PROTEUS) + DELPHIXE6 Alias for DELPHI20 + DELPHI1_UP Defined when compiling with Delphi 1 or higher + DELPHI2_UP Defined when compiling with Delphi 2 or higher + DELPHI3_UP Defined when compiling with Delphi 3 or higher + DELPHI4_UP Defined when compiling with Delphi 4 or higher + DELPHI5_UP Defined when compiling with Delphi 5 or higher + DELPHI6_UP Defined when compiling with Delphi 6 or higher + DELPHI7_UP Defined when compiling with Delphi 7 or higher + DELPHI8_UP Defined when compiling with Delphi 8 or higher + DELPHI2005_UP Defined when compiling with Delphi 2005 or higher + DELPHI9_UP Alias for DELPHI2005_UP + DELPHI10_UP Defined when compiling with Delphi 2006 or higher + DELPHI2006_UP Alias for DELPHI10_UP + DELPHI11_UP Defined when compiling with Delphi 2007 for Win32 or higher + DELPHI2007_UP Alias for DELPHI11_UP + DELPHI12_UP Defined when compiling with Delphi 2009 for Win32 or higher + DELPHI2009_UP Alias for DELPHI12_UP + DELPHI14_UP Defined when compiling with Delphi 2010 for Win32 or higher + DELPHI2010_UP Alias for DELPHI14_UP + DELPHI15_UP Defined when compiling with Delphi XE for Win32 or higher + DELPHIXE_UP Alias for DELPHI15_UP + DELPHI16_UP Defined when compiling with Delphi XE2 for Win32 or higher + DELPHIXE2_UP Alias for DELPHI16_UP + DELPHI17_UP Defined when compiling with Delphi XE3 for Win32 or higher + DELPHIXE3_UP Alias for DELPHI17_UP + DELPHI18_UP Defined when compiling with Delphi XE4 for Win32 or higher + DELPHIXE4_UP Alias for DELPHI18_UP + DELPHI19_UP Defined when compiling with Delphi XE5 for Win32 or higher + DELPHIXE5_UP Alias for DELPHI19_UP + DELPHI20_UP Defined when compiling with Delphi XE6 for Win32 or higher + DELPHIXE6_UP Alias for DELPHI20_UP + + +- Kylix Versions + + The following directives are direct mappings from the VERXXX directives to a + friendly name of the associated compiler. These directives are only defined if + the compiler is Kylix (ie KYLIX is defined). + + Directive Description + ------------------------------------------------------------------------------ + KYLIX1 Defined when compiling with Kylix 1 + KYLIX2 Defined when compiling with Kylix 2 + KYLIX3 Defined when compiling with Kylix 3 (Codename CORTEZ) + KYLIX1_UP Defined when compiling with Kylix 1 or higher + KYLIX2_UP Defined when compiling with Kylix 2 or higher + KYLIX3_UP Defined when compiling with Kylix 3 or higher + + +- Delphi Compiler Versions (Delphi / Kylix, not in BCB mode) + + Directive Description + ------------------------------------------------------------------------------ + DELPHICOMPILER1 Defined when compiling with Delphi 1 + DELPHICOMPILER2 Defined when compiling with Delphi 2 + DELPHICOMPILER3 Defined when compiling with Delphi 3 + DELPHICOMPILER4 Defined when compiling with Delphi 4 + DELPHICOMPILER5 Defined when compiling with Delphi 5 + DELPHICOMPILER6 Defined when compiling with Delphi 6 or Kylix 1, 2 or 3 + DELPHICOMPILER7 Defined when compiling with Delphi 7 + DELPHICOMPILER8 Defined when compiling with Delphi 8 + DELPHICOMPILER9 Defined when compiling with Delphi 2005 + DELPHICOMPILER10 Defined when compiling with Delphi Personality of BDS 4.0 + DELPHICOMPILER11 Defined when compiling with Delphi 2007 for Win32 + DELPHICOMPILER12 Defined when compiling with Delphi Personality of BDS 6.0 + DELPHICOMPILER14 Defined when compiling with Delphi Personality of BDS 7.0 + DELPHICOMPILER15 Defined when compiling with Delphi Personality of BDS 8.0 + DELPHICOMPILER16 Defined when compiling with Delphi Personality of BDS 9.0 + DELPHICOMPILER17 Defined when compiling with Delphi Personality of BDS 10.0 + DELPHICOMPILER18 Defined when compiling with Delphi Personality of BDS 11.0 + DELPHICOMPILER19 Defined when compiling with Delphi Personality of BDS 12.0 + DELPHICOMPILER1_UP Defined when compiling with Delphi 1 or higher + DELPHICOMPILER2_UP Defined when compiling with Delphi 2 or higher + DELPHICOMPILER3_UP Defined when compiling with Delphi 3 or higher + DELPHICOMPILER4_UP Defined when compiling with Delphi 4 or higher + DELPHICOMPILER5_UP Defined when compiling with Delphi 5 or higher + DELPHICOMPILER6_UP Defined when compiling with Delphi 6 or Kylix 1, 2 or 3 or higher + DELPHICOMPILER7_UP Defined when compiling with Delphi 7 or higher + DELPHICOMPILER8_UP Defined when compiling with Delphi 8 or higher + DELPHICOMPILER9_UP Defined when compiling with Delphi 2005 + DELPHICOMPILER10_UP Defined when compiling with Delphi 2006 or higher + DELPHICOMPILER11_UP Defined when compiling with Delphi 2007 for Win32 or higher + DELPHICOMPILER12_UP Defined when compiling with Delphi 2009 for Win32 or higher + DELPHICOMPILER14_UP Defined when compiling with Delphi 2010 for Win32 or higher + DELPHICOMPILER15_UP Defined when compiling with Delphi XE for Win32 or higher + DELPHICOMPILER16_UP Defined when compiling with Delphi XE2 for Win32 or higher + DELPHICOMPILER17_UP Defined when compiling with Delphi XE3 for Win32 or higher + DELPHICOMPILER18_UP Defined when compiling with Delphi XE4 for Win32 or higher + DELPHICOMPILER19_UP Defined when compiling with Delphi XE5 for Win32 or higher + + +- C++Builder Versions + + The following directives are direct mappings from the VERXXX directives to a + friendly name of the associated compiler. These directives are only defined if + the compiler is C++Builder (ie BCB is defined). + + Directive Description + ------------------------------------------------------------------------------ + BCB1 Defined when compiling with C++Builder 1 + BCB3 Defined when compiling with C++Builder 3 + BCB4 Defined when compiling with C++Builder 4 + BCB5 Defined when compiling with C++Builder 5 (Codename RAMPAGE) + BCB6 Defined when compiling with C++Builder 6 (Codename RIPTIDE) + BCB10 Defined when compiling with C++Builder Personality of BDS 4.0 (also known as C++Builder 2006) (Codename DEXTER) + BCB11 Defined when compiling with C++Builder Personality of RAD Studio 2007 (also known as C++Builder 2007) (Codename COGSWELL) + BCB12 Defined when compiling with C++Builder Personality of RAD Studio 2009 (also known as C++Builder 2009) (Codename TIBURON) + BCB14 Defined when compiling with C++Builder Personality of RAD Studio 2010 (also known as C++Builder 2010) (Codename WEAVER) + BCB15 Defined when compiling with C++Builder Personality of RAD Studio XE (also known as C++Builder XE) (Codename FULCRUM) + BCB16 Defined when compiling with C++Builder Personality of RAD Studio XE2 (also known as C++Builder XE2) (Codename PULSAR) + BCB17 Defined when compiling with C++Builder Personality of RAD Studio XE3 (also known as C++Builder XE3) (Codename WATERDRAGON) + BCB18 Defined when compiling with C++Builder Personality of RAD Studio XE4 (also known as C++Builder XE4) (Codename QUINTESSENCE) + BCB19 Defined when compiling with C++Builder Personality of RAD Studio XE5 (also known as C++Builder XE5) (Codename ZEPHYR) + BCB1_UP Defined when compiling with C++Builder 1 or higher + BCB3_UP Defined when compiling with C++Builder 3 or higher + BCB4_UP Defined when compiling with C++Builder 4 or higher + BCB5_UP Defined when compiling with C++Builder 5 or higher + BCB6_UP Defined when compiling with C++Builder 6 or higher + BCB10_UP Defined when compiling with C++Builder Personality of BDS 4.0 or higher + BCB11_UP Defined when compiling with C++Builder Personality of RAD Studio 2007 or higher + BCB12_UP Defined when compiling with C++Builder Personality of RAD Studio 2009 or higher + BCB14_UP Defined when compiling with C++Builder Personality of RAD Studio 2010 or higher + BCB15_UP Defined when compiling with C++Builder Personality of RAD Studio XE or higher + BCB16_UP Defined when compiling with C++Builder Personality of RAD Studio XE2 or higher + BCB17_UP Defined when compiling with C++Builder Personality of RAD Studio XE3 or higher + BCB18_UP Defined when compiling with C++Builder Personality of RAD Studio XE4 or higher + BCB19_UP Defined when compiling with C++Builder Personality of RAD Studio XE5 or higher + BCB20_UP Defined when compiling with C++Builder Personality of RAD Studio XE6 or higher + + +- RAD Studio / Borland Developer Studio Versions + + The following directives are direct mappings from the VERXXX directives to a + friendly name of the associated IDE. These directives are only defined if + the IDE is Borland Developer Studio Version 2 or above. + + Note: Borland Developer Studio 2006 is marketed as Delphi 2006 or C++Builder 2006, + but those provide only different labels for identical content. + + Directive Description + ------------------------------------------------------------------------------ + BDS Defined when compiling with BDS version of dcc32.exe (Codename SIDEWINDER) + BDS2 Defined when compiling with BDS 2.0 (Delphi 8) (Codename OCTANE) + BDS3 Defined when compiling with BDS 3.0 (Delphi 2005) (Codename DIAMONDBACK) + BDS4 Defined when compiling with BDS 4.0 (Borland Developer Studio 2006) (Codename DEXTER) + BDS5 Defined when compiling with BDS 5.0 (CodeGear RAD Studio 2007) (Codename HIGHLANDER) + BDS6 Defined when compiling with BDS 6.0 (CodeGear RAD Studio 2009) (Codename TIBURON) + BDS7 Defined when compiling with BDS 7.0 (Embarcadero RAD Studio 2010) (Codename WEAVER) + BDS8 Defined when compiling with BDS 8.0 (Embarcadero RAD Studio XE) (Codename FULCRUM) + BDS9 Defined when compiling with BDS 9.0 (Embarcadero RAD Studio XE2) (Codename PULSAR) + BDS10 Defined when compiling with BDS 10.0 (Embarcadero RAD Studio XE3) (Codename WATERDRAGON) + BDS11 Defined when compiling with BDS 11.0 (Embarcadero RAD Studio XE4) (Codename QUINTESSENCE) + BDS12 Defined when compiling with BDS 12.0 (Embarcadero RAD Studio XE5) (Codename ZEPHYR) + BDS2_UP Defined when compiling with BDS 2.0 or higher + BDS3_UP Defined when compiling with BDS 3.0 or higher + BDS4_UP Defined when compiling with BDS 4.0 or higher + BDS5_UP Defined when compiling with BDS 5.0 or higher + BDS6_UP Defined when compiling with BDS 6.0 or higher + BDS7_UP Defined when compiling with BDS 7.0 or higher + BDS8_UP Defined when compiling with BDS 8.0 or higher + BDS9_UP Defined when compiling with BDS 9.0 or higher + BDS10_UP Defined when compiling with BDS 10.0 or higher + BDS11_UP Defined when compiling with BDS 11.0 or higher + BDS12_UP Defined when compiling with BDS 12.0 or higher + BDS14_UP Defined when compiling with BDS 14.0 or higher + +- Compiler Versions + + The following directives are direct mappings from the VERXXX directives to a + friendly name of the associated compiler. Unlike the DELPHI_X and BCB_X + directives, these directives are indepedent of the development environment. + That is, they are defined regardless of whether compilation takes place using + Delphi or C++Builder. + + Directive Description + ------------------------------------------------------------------------------ + COMPILER1 Defined when compiling with Delphi 1 + COMPILER2 Defined when compiling with Delphi 2 or C++Builder 1 + COMPILER3 Defined when compiling with Delphi 3 + COMPILER35 Defined when compiling with C++Builder 3 + COMPILER4 Defined when compiling with Delphi 4 or C++Builder 4 + COMPILER5 Defined when compiling with Delphi 5 or C++Builder 5 + COMPILER6 Defined when compiling with Delphi 6 or C++Builder 6 + COMPILER7 Defined when compiling with Delphi 7 + COMPILER8 Defined when compiling with Delphi 8 + COMPILER9 Defined when compiling with Delphi 9 + COMPILER10 Defined when compiling with Delphi or C++Builder Personalities of BDS 4.0 + COMPILER11 Defined when compiling with Delphi or C++Builder Personalities of BDS 5.0 + COMPILER12 Defined when compiling with Delphi or C++Builder Personalities of BDS 6.0 + COMPILER14 Defined when compiling with Delphi or C++Builder Personalities of BDS 7.0 + COMPILER15 Defined when compiling with Delphi or C++Builder Personalities of BDS 8.0 + COMPILER16 Defined when compiling with Delphi or C++Builder Personalities of BDS 9.0 + COMPILER17 Defined when compiling with Delphi or C++Builder Personalities of BDS 10.0 + COMPILER18 Defined when compiling with Delphi or C++Builder Personalities of BDS 11.0 + COMPILER19 Defined when compiling with Delphi or C++Builder Personalities of BDS 12.0 + COMPILER1_UP Defined when compiling with Delphi 1 or higher + COMPILER2_UP Defined when compiling with Delphi 2 or C++Builder 1 or higher + COMPILER3_UP Defined when compiling with Delphi 3 or higher + COMPILER35_UP Defined when compiling with C++Builder 3 or higher + COMPILER4_UP Defined when compiling with Delphi 4 or C++Builder 4 or higher + COMPILER5_UP Defined when compiling with Delphi 5 or C++Builder 5 or higher + COMPILER6_UP Defined when compiling with Delphi 6 or C++Builder 6 or higher + COMPILER7_UP Defined when compiling with Delphi 7 + COMPILER8_UP Defined when compiling with Delphi 8 + COMPILER9_UP Defined when compiling with Delphi Personalities of BDS 3.0 + COMPILER10_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 4.0 or higher + COMPILER11_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 5.0 or higher + COMPILER12_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 6.0 or higher + COMPILER14_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 7.0 or higher + COMPILER15_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 8.0 or higher + COMPILER16_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 9.0 or higher + COMPILER17_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 10.0 or higher + COMPILER18_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 11.0 or higher + COMPILER19_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 12.0 or higher + COMPILER20_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 14.0 or higher + + +- RTL Versions + + Use e.g. following to determine the exact RTL version since version 14.0: + {$IFDEF CONDITIONALEXPRESSIONS} + {$IF Declared(RTLVersion) and (RTLVersion >= 14.2)} + // code for Delphi 6.02 or higher, Kylix 2 or higher, C++Builder 6 or higher + ... + {$IFEND} + {$ENDIF} + + Directive Description + ------------------------------------------------------------------------------ + RTL80_UP Defined when compiling with Delphi 1 or higher + RTL90_UP Defined when compiling with Delphi 2 or higher + RTL93_UP Defined when compiling with C++Builder 1 or higher + RTL100_UP Defined when compiling with Delphi 3 or higher + RTL110_UP Defined when compiling with C++Builder 3 or higher + RTL120_UP Defined when compiling with Delphi 4 or higher + RTL125_UP Defined when compiling with C++Builder 4 or higher + RTL130_UP Defined when compiling with Delphi 5 or C++Builder 5 or higher + RTL140_UP Defined when compiling with Delphi 6, Kylix 1, 2 or 3 or C++Builder 6 or higher + RTL150_UP Defined when compiling with Delphi 7 or higher + RTL160_UP Defined when compiling with Delphi 8 or higher + RTL170_UP Defined when compiling with Delphi Personalities of BDS 3.0 or higher + RTL180_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 4.0 or higher + RTL185_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 5.0 or higher + RTL190_UP Defined when compiling with Delphi.NET of BDS 5.0 or higher + RTL200_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 6.0 or higher + RTL210_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 7.0 or higher + RTL220_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 8.0 or higher + RTL230_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 9.0 or higher + RTL240_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 10.0 or higher + RTL250_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 11.0 or higher + RTL260_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 12.0 or higher + RTL270_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 14.0 or higher + + +- CLR Versions + + Directive Description + ------------------------------------------------------------------------------ + CLR Defined when compiling for .NET + CLR10 Defined when compiling for .NET 1.0 (may be overriden by FORCE_CLR10) + CLR10_UP Defined when compiling for .NET 1.0 or higher + CLR11 Defined when compiling for .NET 1.1 (may be overriden by FORCE_CLR11) + CLR11_UP Defined when compiling for .NET 1.1 or higher + CLR20 Defined when compiling for .NET 2.0 (may be overriden by FORCE_CLR20) + CLR20_UP Defined when compiling for .NET 2.0 or higher + + +- Feature Directives + + The features directives are used to test if the compiler supports specific + features, such as method overloading, and adjust the sources accordingly. Use + of these directives is preferred over the use of the DELPHI and COMPILER + directives. + + Directive Description + ------------------------------------------------------------------------------ + SUPPORTS_CONSTPARAMS Compiler supports const parameters (D1+) + SUPPORTS_SINGLE Compiler supports the Single type (D1+) + SUPPORTS_DOUBLE Compiler supports the Double type (D1+) + SUPPORTS_EXTENDED Compiler supports the Extended type (D1+) + SUPPORTS_CURRENCY Compiler supports the Currency type (D2+) + SUPPORTS_THREADVAR Compiler supports threadvar declarations (D2+) + SUPPORTS_OUTPARAMS Compiler supports out parameters (D3+) + SUPPORTS_VARIANT Compiler supports variant (D2+) + SUPPORTS_WIDECHAR Compiler supports the WideChar type (D2+) + SUPPORTS_WIDESTRING Compiler supports the WideString type (D3+/BCB3+) + SUPPORTS_INTERFACE Compiler supports interfaces (D3+/BCB3+) + SUPPORTS_DISPINTERFACE Compiler supports dispatch interfaces (D3+/BCB3+) + SUPPORTS_DISPID Compiler supports dispatch ids (D3+/BCB3+/FPC) + SUPPORTS_EXTSYM Compiler supports the $EXTERNALSYM directive (D4+/BCB3+) + SUPPORTS_NODEFINE Compiler supports the $NODEFINE directive (D4+/BCB3+) + SUPPORTS_LONGWORD Compiler supports the LongWord type (unsigned 32 bit) (D4+/BCB4+) + SUPPORTS_INT64 Compiler supports the Int64 type (D4+/BCB4+) + SUPPORTS_UINT64 Compiler supports the UInt64 type (D XE+ ?) + SUPPORTS_DYNAMICARRAYS Compiler supports dynamic arrays (D4+/BCB4+) + SUPPORTS_DEFAULTPARAMS Compiler supports default parameters (D4+/BCB4+) + SUPPORTS_OVERLOAD Compiler supports overloading (D4+/BCB4+) + SUPPORTS_IMPLEMENTS Compiler supports implements (D4+/BCB4+) + SUPPORTS_DEPRECATED Compiler supports the deprecated directive (D6+/BCB6+) + SUPPORTS_PLATFORM Compiler supports the platform directive (D6+/BCB6+) + SUPPORTS_LIBRARY Compiler supports the library directive (D6+/BCB6+/FPC) + SUPPORTS_LOCAL Compiler supports the local directive (D6+/BCB6+) + SUPPORTS_SETPEFLAGS Compiler supports the SetPEFlags directive (D6+/BCB6+) + SUPPORTS_EXPERIMENTAL_WARNINGS Compiler supports the WARN SYMBOL_EXPERIMENTAL and WARN UNIT_EXPERIMENTAL directives (D6+/BCB6+) + SUPPORTS_INLINE Compiler supports the inline directive (D9+/FPC) + SUPPORTS_FOR_IN Compiler supports for in loops (D9+) + SUPPORTS_NESTED_CONSTANTS Compiler supports nested constants (D9+) + SUPPORTS_NESTED_TYPES Compiler supports nested types (D9+) + SUPPORTS_REGION Compiler supports the REGION and ENDREGION directives (D9+) + SUPPORTS_ENHANCED_RECORDS Compiler supports class [operator|function|procedure] for record types (D9.NET, D10+) + SUPPORTS_CLASS_FIELDS Compiler supports class fields (D9.NET, D10+) + SUPPORTS_CLASS_HELPERS Compiler supports class helpers (D9.NET, D10+) + SUPPORTS_CLASS_OPERATORS Compiler supports class operators (D9.NET, D10+) + SUPPORTS_CLASS_CTORDTORS Compiler supports class contructors/destructors (D14+) + SUPPORTS_STRICT Compiler supports strict keyword (D9.NET, D10+) + SUPPORTS_STATIC Compiler supports static keyword (D9.NET, D10+) + SUPPORTS_FINAL Compiler supports final keyword (D9.NET, D10+) + SUPPORTS_METHODINFO Compiler supports the METHODINFO directives (D10+) + SUPPORTS_GENERICS Compiler supports generic implementations (D11.NET, D12+) + SUPPORTS_DEPRECATED_DETAILS Compiler supports additional text for the deprecated directive (D11.NET, D12+) + ACCEPT_DEPRECATED Compiler supports or ignores the deprecated directive (D6+/BCB6+/FPC) + ACCEPT_PLATFORM Compiler supports or ignores the platform directive (D6+/BCB6+/FPC) + ACCEPT_LIBRARY Compiler supports or ignores the library directive (D6+/BCB6+) + SUPPORTS_CUSTOMVARIANTS Compiler supports custom variants (D6+/BCB6+) + SUPPORTS_VARARGS Compiler supports varargs (D6+/BCB6+) + SUPPORTS_ENUMVALUE Compiler supports assigning ordinalities to values of enums (D6+/BCB6+) + SUPPORTS_DEPRECATED_WARNINGS Compiler supports deprecated warnings (D6+/BCB6+) + SUPPORTS_LIBRARY_WARNINGS Compiler supports library warnings (D6+/BCB6+) + SUPPORTS_PLATFORM_WARNINGS Compiler supports platform warnings (D6+/BCB6+) + SUPPORTS_UNSAFE_WARNINGS Compiler supports unsafe warnings (D7) + SUPPORTS_WEAKPACKAGEUNIT Compiler supports the WEAKPACKAGEUNIT directive + SUPPORTS_COMPILETIME_MESSAGES Compiler supports the MESSAGE directive + SUPPORTS_PACKAGES Compiler supports Packages + HAS_UNIT_LIBC Unit Libc exists (Kylix, FPC on Linux/x86) + HAS_UNIT_RTLCONSTS Unit RTLConsts exists (D6+/BCB6+/FPC) + HAS_UNIT_TYPES Unit Types exists (D6+/BCB6+/FPC) + HAS_UNIT_VARIANTS Unit Variants exists (D6+/BCB6+/FPC) + HAS_UNIT_STRUTILS Unit StrUtils exists (D6+/BCB6+/FPC) + HAS_UNIT_DATEUTILS Unit DateUtils exists (D6+/BCB6+/FPC) + HAS_UNIT_CONTNRS Unit contnrs exists (D6+/BCB6+/FPC) + HAS_UNIT_HTTPPROD Unit HTTPProd exists (D9+) + HAS_UNIT_GIFIMG Unit GifImg exists (D11+) + HAS_UNIT_ANSISTRINGS Unit AnsiStrings exists (D12+) + HAS_UNIT_PNGIMAGE Unit PngImage exists (D12+) + HAS_UNIT_CHARACTER Unit Character exists (D12+) + XPLATFORM_RTL The RTL supports crossplatform function names (e.g. RaiseLastOSError) (D6+/BCB6+/FPC) + SUPPORTS_UNICODE string type is aliased to an unicode string (WideString or UnicodeString) (DX.NET, D12+) + SUPPORTS_UNICODE_STRING Compiler supports UnicodeString (D12+) + SUPPORTS_INT_ALIASES Types Int8, Int16, Int32, UInt8, UInt16 and UInt32 are defined in the unit System (D12+) + HAS_UNIT_RTTI Unit RTTI is available (D14+) + SUPPORTS_CAST_INTERFACE_TO_OBJ The compiler supports casts from interfaces to objects (D14+) + SUPPORTS_DELAYED_LOADING The compiler generates stubs for delaying imported function loads (D14+) + HAS_UNIT_REGULAREXPRESSIONSAPI Unit RegularExpressionsAPI is available (D15+) + HAS_UNIT_SYSTEM_UITYPES Unit System.UITypes is available (D16+) + HAS_UNIT_SYSTEM_ACTIONS Unit System.Actions is available (D17+) + DEPRECATED_SYSUTILS_ANSISTRINGS AnsiString functions from SysUtils are deprecated and moved to System.AnsiStrings (D18+) + HAS_PROPERTY_STYLEELEMENTS TControl has a StyleElements property (D17+) + HAS_AUTOMATIC_DB_FIELDS Database fields are automatically created/refreshed (D20+) + + +- Compiler Settings + + The compiler settings directives indicate whether a specific compiler setting + is in effect. This facilitates changing compiler settings locally in a more + compact and readible manner. + + Directive Description + ------------------------------------------------------------------------------ + ALIGN_ON Compiling in the A+ state (no alignment) + BOOLEVAL_ON Compiling in the B+ state (complete boolean evaluation) + ASSERTIONS_ON Compiling in the C+ state (assertions on) + DEBUGINFO_ON Compiling in the D+ state (debug info generation on) + IMPORTEDDATA_ON Compiling in the G+ state (creation of imported data references) + LONGSTRINGS_ON Compiling in the H+ state (string defined as AnsiString) + IOCHECKS_ON Compiling in the I+ state (I/O checking enabled) + WRITEABLECONST_ON Compiling in the J+ state (typed constants can be modified) + LOCALSYMBOLS Compiling in the L+ state (local symbol generation) + LOCALSYMBOLS_ON Alias of LOCALSYMBOLS + TYPEINFO_ON Compiling in the M+ state (RTTI generation on) + OPTIMIZATION_ON Compiling in the O+ state (code optimization on) + OPENSTRINGS_ON Compiling in the P+ state (variable string parameters are openstrings) + OVERFLOWCHECKS_ON Compiling in the Q+ state (overflow checing on) + RANGECHECKS_ON Compiling in the R+ state (range checking on) + TYPEDADDRESS_ON Compiling in the T+ state (pointers obtained using the @ operator are typed) + SAFEDIVIDE_ON Compiling in the U+ state (save FDIV instruction through RTL emulation) + VARSTRINGCHECKS_ON Compiling in the V+ state (type checking of shortstrings) + STACKFRAMES_ON Compiling in the W+ state (generation of stack frames) + EXTENDEDSYNTAX_ON Compiling in the X+ state (Delphi extended syntax enabled) +*) + +{$DEFINE BORLAND} + +{ Set FreePascal to Delphi mode } +{$IFDEF FPC} + {$MODE DELPHI} + {$ASMMODE Intel} + {$UNDEF BORLAND} + {$DEFINE CPUASM} + // FPC defines CPU32, CPU64 and Unix automatically +{$ENDIF} + +{$IFDEF BORLAND} + {$IFDEF LINUX} + {$DEFINE KYLIX} + {$ENDIF LINUX} + {$IFNDEF CLR} + {$IFNDEF CPUX86} + {$IFNDEF CPUX64} + {$DEFINE CPU386} // For Borland compilers select the x86 compat assembler by default + {$DEFINE CPU32} // Assume Borland compilers are 32-bit (rather than 64-bit) + {$DEFINE CPUASM} + {$ELSE ~CPUX64} + {$DEFINE CPU64} + {$DEFINE CPUASM} + {$DEFINE DELPHI64_TEMPORARY} + {$ENDIF ~CPUX64} + {$ELSE ~CPUX86} + {$DEFINE CPU386} + {$DEFINE CPU32} + {$DEFINE CPUASM} + {$ENDIF ~CPUX86} + {$ENDIF ~CLR} +{$ENDIF BORLAND} + +{------------------------------------------------------------------------------} +{ VERXXX to COMPILERX, DELPHIX and BCBX mappings } +{------------------------------------------------------------------------------} + +{$IFDEF BORLAND} + {$IFDEF KYLIX} + {$I kylix.inc} // FPC incompatible stuff + {$ELSE ~KYLIX} + + {$DEFINE UNKNOWN_COMPILER_VERSION} + + {$IFDEF VER80} + {$DEFINE COMPILER1} + {$DEFINE DELPHI1} + {$DEFINE DELPHICOMPILER1} + {$DEFINE RTL80_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER90} + {$DEFINE COMPILER2} + {$DEFINE DELPHI2} + {$DEFINE DELPHICOMPILER2} + {$DEFINE RTL90_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER93} + {$DEFINE COMPILER2} + {$DEFINE BCB1} + {$DEFINE BCB} + {$DEFINE RTL93_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER100} + {$DEFINE COMPILER3} + {$DEFINE DELPHI3} + {$DEFINE DELPHICOMPILER3} + {$DEFINE RTL100_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER110} + {$DEFINE COMPILER35} + {$DEFINE BCB3} + {$DEFINE BCB} + {$DEFINE RTL110_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER120} + {$DEFINE COMPILER4} + {$DEFINE DELPHI4} + {$DEFINE DELPHICOMPILER4} + {$DEFINE RTL120_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER125} + {$DEFINE COMPILER4} + {$DEFINE BCB4} + {$DEFINE BCB} + {$DEFINE RTL125_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER130} + {$DEFINE COMPILER5} + {$IFDEF BCB} + {$DEFINE BCB5} + {$ELSE} + {$DEFINE DELPHI5} + {$DEFINE DELPHICOMPILER5} + {$ENDIF} + {$DEFINE RTL130_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER140} + {$DEFINE COMPILER6} + {$IFDEF BCB} + {$DEFINE BCB6} + {$ELSE} + {$DEFINE DELPHI6} + {$DEFINE DELPHICOMPILER6} + {$ENDIF} + {$DEFINE RTL140_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER150} + {$DEFINE COMPILER7} + {$DEFINE DELPHI7} + {$DEFINE DELPHICOMPILER7} + {$DEFINE RTL150_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER160} + {$DEFINE BDS2} + {$DEFINE BDS} + {$IFDEF CLR} + {$DEFINE CLR10} + {$ENDIF CLR} + {$DEFINE COMPILER8} + {$DEFINE DELPHI8} + {$DEFINE DELPHICOMPILER8} + {$DEFINE RTL160_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER170} + {$DEFINE BDS3} + {$DEFINE BDS} + {$IFDEF CLR} + {$DEFINE CLR11} + {$ENDIF CLR} + {$DEFINE COMPILER9} + {$DEFINE DELPHI9} + {$DEFINE DELPHI2005} // synonym to DELPHI9 + {$DEFINE DELPHICOMPILER9} + {$DEFINE RTL170_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER180} + {$DEFINE BDS} + {$IFDEF CLR} + {$DEFINE CLR11} + {$ENDIF CLR} + {$IFDEF VER185} + {$DEFINE BDS5} + {$DEFINE COMPILER11} + {$IFDEF BCB} + {$DEFINE BCB11} + {$ELSE} + {$DEFINE DELPHI11} + {$DEFINE DELPHI2007} // synonym to DELPHI11 + {$DEFINE DELPHICOMPILER11} + {$ENDIF} + {$DEFINE RTL185_UP} + {$ELSE ~~VER185} + {$DEFINE BDS4} + {$DEFINE COMPILER10} + {$IFDEF BCB} + {$DEFINE BCB10} + {$ELSE} + {$DEFINE DELPHI10} + {$DEFINE DELPHI2006} // synonym to DELPHI10 + {$DEFINE DELPHICOMPILER10} + {$ENDIF} + {$DEFINE RTL180_UP} + {$ENDIF ~VER185} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER190} // Delphi 2007 for .NET + {$DEFINE BDS} + {$DEFINE BDS5} + {$IFDEF CLR} + {$DEFINE CLR20} + {$ENDIF CLR} + {$DEFINE COMPILER11} + {$DEFINE DELPHI11} + {$DEFINE DELPHI2007} // synonym to DELPHI11 + {$DEFINE DELPHICOMPILER11} + {$DEFINE RTL190_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF VER190} + + {$IFDEF VER200} // RAD Studio 2009 + {$DEFINE BDS} + {$DEFINE BDS6} + {$IFDEF CLR} + {$DEFINE CLR20} + {$ENDIF CLR} + {$DEFINE COMPILER12} + {$IFDEF BCB} + {$DEFINE BCB12} + {$ELSE} + {$DEFINE DELPHI12} + {$DEFINE DELPHI2009} // synonym to DELPHI12 + {$DEFINE DELPHICOMPILER12} + {$ENDIF BCB} + {$IFDEF CLR} + {$DEFINE RTL190_UP} + {$ELSE} + {$DEFINE RTL200_UP} + {$ENDIF} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF VER200} + + {$IFDEF VER210} // RAD Studio 2010 + {$DEFINE BDS} + {$DEFINE BDS7} + {$DEFINE COMPILER14} + {$IFDEF BCB} + {$DEFINE BCB14} + {$ELSE} + {$DEFINE DELPHI14} + {$DEFINE DELPHI2010} // synonym to DELPHI14 + {$DEFINE DELPHICOMPILER14} + {$ENDIF BCB} + {$DEFINE RTL210_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF VER210} + + {$IFDEF VER220} // RAD Studio XE + {$DEFINE BDS} + {$DEFINE BDS8} + {$DEFINE COMPILER15} + {$IFDEF BCB} + {$DEFINE BCB15} + {$ELSE} + {$DEFINE DELPHI15} + {$DEFINE DELPHIXE} // synonym to DELPHI15 + {$DEFINE DELPHICOMPILER15} + {$ENDIF BCB} + {$DEFINE RTL220_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF VER220} + + {$IFDEF VER230} // RAD Studio XE2 + {$DEFINE BDS} + {$DEFINE BDS9} + {$DEFINE COMPILER16} + {$IFDEF BCB} + {$DEFINE BCB16} + {$ELSE} + {$DEFINE DELPHI16} + {$DEFINE DELPHIXE2} // synonym to DELPHI16 + {$DEFINE DELPHICOMPILER16} + {$ENDIF BCB} + {$DEFINE RTL230_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF VER230} + + {$IFDEF VER240} // RAD Studio XE3 + {$DEFINE BDS} + {$DEFINE BDS10} + {$DEFINE COMPILER17} + {$IFDEF BCB} + {$DEFINE BCB17} + {$ELSE} + {$DEFINE DELPHI17} + {$DEFINE DELPHIXE3} // synonym to DELPHI17 + {$DEFINE DELPHICOMPILER17} + {$ENDIF BCB} + {$DEFINE RTL240_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF VER240} + + {$IFDEF VER250} // RAD Studio XE4 + {$DEFINE BDS} + {$DEFINE BDS11} + {$DEFINE COMPILER18} + {$IFDEF BCB} + {$DEFINE BCB18} + {$ELSE} + {$DEFINE DELPHI18} + {$DEFINE DELPHIXE4} // synonym to DELPHI18 + {$DEFINE DELPHICOMPILER18} + {$ENDIF BCB} + {$DEFINE RTL250_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF VER250} + + {$IFDEF VER260} // RAD Studio XE5 + {$DEFINE BDS} + {$DEFINE BDS12} + {$DEFINE COMPILER19} + {$IFDEF BCB} + {$DEFINE BCB19} + {$ELSE} + {$DEFINE DELPHI19} + {$DEFINE DELPHIXE5} // synonym to DELPHI19 + {$DEFINE DELPHICOMPILER19} + {$ENDIF BCB} + {$DEFINE RTL260_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF VER260} + + {$IFDEF VER270} // RAD Studio XE6 + {$DEFINE BDS} + {$DEFINE BDS14} + {$DEFINE COMPILER20} + {$IFDEF BCB} + {$DEFINE BCB20} + {$ELSE} + {$DEFINE DELPHI20} + {$DEFINE DELPHIXE6} // synonym to DELPHI20 + {$DEFINE DELPHICOMPILER20} + {$ENDIF BCB} + {$DEFINE RTL270_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF VER260} + + {$IFDEF UNKNOWN_COMPILER_VERSION} // adjust for newer version (always use latest version) + {$DEFINE BDS} + {$DEFINE BDS14} + {$DEFINE COMPILER20} + {$IFDEF BCB} + {$DEFINE BCB20} + {$ELSE} + {$DEFINE DELPHI20} + {$DEFINE DELPHIXE6} // synonym to DELPHI20 + {$DEFINE DELPHICOMPILER20} + {$ENDIF BCB} + {$DEFINE RTL270_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$ENDIF ~KYLIX} + + {$IFDEF BCB} + {$DEFINE CPPBUILDER} + {$DEFINE BCBCOMPILER} + {$ELSE ~BCB} + {$DEFINE DELPHI} + {$DEFINE DELPHICOMPILER} + {$ENDIF ~BCB} + +{$ENDIF BORLAND} + +{------------------------------------------------------------------------------} +{ DELPHIX_UP from DELPHIX mappings } +{------------------------------------------------------------------------------} + +{$IFDEF DELPHI20} {$DEFINE DELPHI20_UP} {$ENDIF} +{$IFDEF DELPHI19} {$DEFINE DELPHI19_UP} {$ENDIF} +{$IFDEF DELPHI18} {$DEFINE DELPHI18_UP} {$ENDIF} +{$IFDEF DELPHI17} {$DEFINE DELPHI17_UP} {$ENDIF} +{$IFDEF DELPHI16} {$DEFINE DELPHI16_UP} {$ENDIF} +{$IFDEF DELPHI15} {$DEFINE DELPHI15_UP} {$ENDIF} +{$IFDEF DELPHI14} {$DEFINE DELPHI14_UP} {$ENDIF} +{$IFDEF DELPHI12} {$DEFINE DELPHI12_UP} {$ENDIF} +{$IFDEF DELPHI11} {$DEFINE DELPHI11_UP} {$ENDIF} +{$IFDEF DELPHI10} {$DEFINE DELPHI10_UP} {$ENDIF} +{$IFDEF DELPHI9} {$DEFINE DELPHI9_UP} {$ENDIF} +{$IFDEF DELPHI8} {$DEFINE DELPHI8_UP} {$ENDIF} +{$IFDEF DELPHI7} {$DEFINE DELPHI7_UP} {$ENDIF} +{$IFDEF DELPHI6} {$DEFINE DELPHI6_UP} {$ENDIF} +{$IFDEF DELPHI5} {$DEFINE DELPHI5_UP} {$ENDIF} +{$IFDEF DELPHI4} {$DEFINE DELPHI4_UP} {$ENDIF} +{$IFDEF DELPHI3} {$DEFINE DELPHI3_UP} {$ENDIF} +{$IFDEF DELPHI2} {$DEFINE DELPHI2_UP} {$ENDIF} +{$IFDEF DELPHI1} {$DEFINE DELPHI1_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ DELPHIX_UP from DELPHIX_UP mappings } +{------------------------------------------------------------------------------} + +{$IFDEF DELPHI20_UP} + {$DEFINE DELPHIXE6_UP} // synonym to DELPHI20_UP + {$DEFINE DELPHI19_UP} +{$ENDIF} + +{$IFDEF DELPHI19_UP} + {$DEFINE DELPHIXE5_UP} // synonym to DELPHI19_UP + {$DEFINE DELPHI18_UP} +{$ENDIF} + +{$IFDEF DELPHI18_UP} + {$DEFINE DELPHIXE4_UP} // synonym to DELPHI18_UP + {$DEFINE DELPHI17_UP} +{$ENDIF} + +{$IFDEF DELPHI17_UP} + {$DEFINE DELPHIXE3_UP} // synonym to DELPHI17_UP + {$DEFINE DELPHI16_UP} +{$ENDIF} + +{$IFDEF DELPHI16_UP} + {$DEFINE DELPHIXE2_UP} // synonym to DELPHI16_UP + {$DEFINE DELPHI15_UP} +{$ENDIF} + +{$IFDEF DELPHI15_UP} + {$DEFINE DELPHIXE_UP} // synonym to DELPHI15_UP + {$DEFINE DELPHI14_UP} +{$ENDIF} + +{$IFDEF DELPHI14_UP} + {$DEFINE DELPHI2010_UP} // synonym to DELPHI14_UP + {$DEFINE DELPHI12_UP} +{$ENDIF} + +{$IFDEF DELPHI12_UP} + {$DEFINE DELPHI2009_UP} // synonym to DELPHI12_UP + {$DEFINE DELPHI11_UP} +{$ENDIF} + +{$IFDEF DELPHI11_UP} + {$DEFINE DELPHI2007_UP} // synonym to DELPHI11_UP + {$DEFINE DELPHI10_UP} +{$ENDIF} + +{$IFDEF DELPHI10_UP} + {$DEFINE DELPHI2006_UP} // synonym to DELPHI10_UP + {$DEFINE DELPHI9_UP} +{$ENDIF} + +{$IFDEF DELPHI9_UP} + {$DEFINE DELPHI2005_UP} // synonym to DELPHI9_UP + {$DEFINE DELPHI8_UP} +{$ENDIF} + +{$IFDEF DELPHI8_UP} {$DEFINE DELPHI7_UP} {$ENDIF} +{$IFDEF DELPHI7_UP} {$DEFINE DELPHI6_UP} {$ENDIF} +{$IFDEF DELPHI6_UP} {$DEFINE DELPHI5_UP} {$ENDIF} +{$IFDEF DELPHI5_UP} {$DEFINE DELPHI4_UP} {$ENDIF} +{$IFDEF DELPHI4_UP} {$DEFINE DELPHI3_UP} {$ENDIF} +{$IFDEF DELPHI3_UP} {$DEFINE DELPHI2_UP} {$ENDIF} +{$IFDEF DELPHI2_UP} {$DEFINE DELPHI1_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ BCBX_UP from BCBX mappings } +{------------------------------------------------------------------------------} + +{$IFDEF BCB20} {$DEFINE BCB20_UP} {$ENDIF} +{$IFDEF BCB19} {$DEFINE BCB19_UP} {$ENDIF} +{$IFDEF BCB18} {$DEFINE BCB18_UP} {$ENDIF} +{$IFDEF BCB17} {$DEFINE BCB17_UP} {$ENDIF} +{$IFDEF BCB16} {$DEFINE BCB16_UP} {$ENDIF} +{$IFDEF BCB15} {$DEFINE BCB15_UP} {$ENDIF} +{$IFDEF BCB14} {$DEFINE BCB14_UP} {$ENDIF} +{$IFDEF BCB12} {$DEFINE BCB12_UP} {$ENDIF} +{$IFDEF BCB11} {$DEFINE BCB11_UP} {$ENDIF} +{$IFDEF BCB10} {$DEFINE BCB10_UP} {$ENDIF} +{$IFDEF BCB6} {$DEFINE BCB6_UP} {$ENDIF} +{$IFDEF BCB5} {$DEFINE BCB5_UP} {$ENDIF} +{$IFDEF BCB4} {$DEFINE BCB4_UP} {$ENDIF} +{$IFDEF BCB3} {$DEFINE BCB3_UP} {$ENDIF} +{$IFDEF BCB1} {$DEFINE BCB1_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ BCBX_UP from BCBX_UP mappings } +{------------------------------------------------------------------------------} + +{$IFDEF BCB20_UP} {$DEFINE BCB19_UP} {$ENDIF} +{$IFDEF BCB19_UP} {$DEFINE BCB18_UP} {$ENDIF} +{$IFDEF BCB18_UP} {$DEFINE BCB17_UP} {$ENDIF} +{$IFDEF BCB17_UP} {$DEFINE BCB16_UP} {$ENDIF} +{$IFDEF BCB16_UP} {$DEFINE BCB15_UP} {$ENDIF} +{$IFDEF BCB15_UP} {$DEFINE BCB14_UP} {$ENDIF} +{$IFDEF BCB14_UP} {$DEFINE BCB12_UP} {$ENDIF} +{$IFDEF BCB12_UP} {$DEFINE BCB11_UP} {$ENDIF} +{$IFDEF BCB11_UP} {$DEFINE BCB10_UP} {$ENDIF} +{$IFDEF BCB10_UP} {$DEFINE BCB6_UP} {$ENDIF} +{$IFDEF BCB6_UP} {$DEFINE BCB5_UP} {$ENDIF} +{$IFDEF BCB5_UP} {$DEFINE BCB4_UP} {$ENDIF} +{$IFDEF BCB4_UP} {$DEFINE BCB3_UP} {$ENDIF} +{$IFDEF BCB3_UP} {$DEFINE BCB1_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ BDSX_UP from BDSX mappings } +{------------------------------------------------------------------------------} + +{$IFDEF BDS14} {$DEFINE BDS14_UP} {$ENDIF} +{$IFDEF BDS12} {$DEFINE BDS12_UP} {$ENDIF} +{$IFDEF BDS11} {$DEFINE BDS11_UP} {$ENDIF} +{$IFDEF BDS10} {$DEFINE BDS10_UP} {$ENDIF} +{$IFDEF BDS9} {$DEFINE BDS9_UP} {$ENDIF} +{$IFDEF BDS8} {$DEFINE BDS8_UP} {$ENDIF} +{$IFDEF BDS7} {$DEFINE BDS7_UP} {$ENDIF} +{$IFDEF BDS6} {$DEFINE BDS6_UP} {$ENDIF} +{$IFDEF BDS5} {$DEFINE BDS5_UP} {$ENDIF} +{$IFDEF BDS4} {$DEFINE BDS4_UP} {$ENDIF} +{$IFDEF BDS3} {$DEFINE BDS3_UP} {$ENDIF} +{$IFDEF BDS2} {$DEFINE BDS2_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ BDSX_UP from BDSX_UP mappings } +{------------------------------------------------------------------------------} + +{$IFDEF BDS14_UP} {$DEFINE BDS12_UP} {$ENDIF} +{$IFDEF BDS12_UP} {$DEFINE BDS11_UP} {$ENDIF} +{$IFDEF BDS11_UP} {$DEFINE BDS10_UP} {$ENDIF} +{$IFDEF BDS10_UP} {$DEFINE BDS9_UP} {$ENDIF} +{$IFDEF BDS9_UP} {$DEFINE BDS8_UP} {$ENDIF} +{$IFDEF BDS8_UP} {$DEFINE BDS7_UP} {$ENDIF} +{$IFDEF BDS7_UP} {$DEFINE BDS6_UP} {$ENDIF} +{$IFDEF BDS6_UP} {$DEFINE BDS5_UP} {$ENDIF} +{$IFDEF BDS5_UP} {$DEFINE BDS4_UP} {$ENDIF} +{$IFDEF BDS4_UP} {$DEFINE BDS3_UP} {$ENDIF} +{$IFDEF BDS3_UP} {$DEFINE BDS2_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ DELPHICOMPILERX_UP from DELPHICOMPILERX mappings } +{------------------------------------------------------------------------------} + +{$IFDEF DELPHICOMPILER20} {$DEFINE DELPHICOMPILER20_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER19} {$DEFINE DELPHICOMPILER19_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER18} {$DEFINE DELPHICOMPILER18_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER17} {$DEFINE DELPHICOMPILER17_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER16} {$DEFINE DELPHICOMPILER16_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER15} {$DEFINE DELPHICOMPILER15_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER14} {$DEFINE DELPHICOMPILER14_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER12} {$DEFINE DELPHICOMPILER12_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER11} {$DEFINE DELPHICOMPILER11_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER10} {$DEFINE DELPHICOMPILER10_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER9} {$DEFINE DELPHICOMPILER9_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER8} {$DEFINE DELPHICOMPILER8_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER7} {$DEFINE DELPHICOMPILER7_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER6} {$DEFINE DELPHICOMPILER6_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER5} {$DEFINE DELPHICOMPILER5_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER4} {$DEFINE DELPHICOMPILER4_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER3} {$DEFINE DELPHICOMPILER3_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER2} {$DEFINE DELPHICOMPILER2_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER1} {$DEFINE DELPHICOMPILER1_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ DELPHICOMPILERX_UP from DELPHICOMPILERX_UP mappings } +{------------------------------------------------------------------------------} + +{$IFDEF DELPHICOMPILER20_UP} {$DEFINE DELPHICOMPILER19_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER19_UP} {$DEFINE DELPHICOMPILER18_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER18_UP} {$DEFINE DELPHICOMPILER17_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER17_UP} {$DEFINE DELPHICOMPILER16_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER16_UP} {$DEFINE DELPHICOMPILER15_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER15_UP} {$DEFINE DELPHICOMPILER14_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER14_UP} {$DEFINE DELPHICOMPILER12_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER12_UP} {$DEFINE DELPHICOMPILER11_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER11_UP} {$DEFINE DELPHICOMPILER10_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER10_UP} {$DEFINE DELPHICOMPILER9_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER9_UP} {$DEFINE DELPHICOMPILER8_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER8_UP} {$DEFINE DELPHICOMPILER7_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER8_UP} {$DEFINE DELPHICOMPILER7_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER7_UP} {$DEFINE DELPHICOMPILER6_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER6_UP} {$DEFINE DELPHICOMPILER5_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER5_UP} {$DEFINE DELPHICOMPILER4_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER4_UP} {$DEFINE DELPHICOMPILER3_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER3_UP} {$DEFINE DELPHICOMPILER2_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER2_UP} {$DEFINE DELPHICOMPILER1_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ COMPILERX_UP from COMPILERX mappings } +{------------------------------------------------------------------------------} + +{$IFDEF COMPILER20} {$DEFINE COMPILER20_UP} {$ENDIF} +{$IFDEF COMPILER19} {$DEFINE COMPILER19_UP} {$ENDIF} +{$IFDEF COMPILER18} {$DEFINE COMPILER18_UP} {$ENDIF} +{$IFDEF COMPILER17} {$DEFINE COMPILER17_UP} {$ENDIF} +{$IFDEF COMPILER16} {$DEFINE COMPILER16_UP} {$ENDIF} +{$IFDEF COMPILER15} {$DEFINE COMPILER15_UP} {$ENDIF} +{$IFDEF COMPILER14} {$DEFINE COMPILER14_UP} {$ENDIF} +{$IFDEF COMPILER12} {$DEFINE COMPILER12_UP} {$ENDIF} +{$IFDEF COMPILER11} {$DEFINE COMPILER11_UP} {$ENDIF} +{$IFDEF COMPILER10} {$DEFINE COMPILER10_UP} {$ENDIF} +{$IFDEF COMPILER9} {$DEFINE COMPILER9_UP} {$ENDIF} +{$IFDEF COMPILER8} {$DEFINE COMPILER8_UP} {$ENDIF} +{$IFDEF COMPILER7} {$DEFINE COMPILER7_UP} {$ENDIF} +{$IFDEF COMPILER6} {$DEFINE COMPILER6_UP} {$ENDIF} +{$IFDEF COMPILER5} {$DEFINE COMPILER5_UP} {$ENDIF} +{$IFDEF COMPILER4} {$DEFINE COMPILER4_UP} {$ENDIF} +{$IFDEF COMPILER35} {$DEFINE COMPILER35_UP} {$ENDIF} +{$IFDEF COMPILER3} {$DEFINE COMPILER3_UP} {$ENDIF} +{$IFDEF COMPILER2} {$DEFINE COMPILER2_UP} {$ENDIF} +{$IFDEF COMPILER1} {$DEFINE COMPILER1_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ COMPILERX_UP from COMPILERX_UP mappings } +{------------------------------------------------------------------------------} + +{$IFDEF COMPILER20_UP} {$DEFINE COMPILER19_UP} {$ENDIF} +{$IFDEF COMPILER19_UP} {$DEFINE COMPILER18_UP} {$ENDIF} +{$IFDEF COMPILER18_UP} {$DEFINE COMPILER17_UP} {$ENDIF} +{$IFDEF COMPILER17_UP} {$DEFINE COMPILER16_UP} {$ENDIF} +{$IFDEF COMPILER16_UP} {$DEFINE COMPILER15_UP} {$ENDIF} +{$IFDEF COMPILER15_UP} {$DEFINE COMPILER14_UP} {$ENDIF} +{$IFDEF COMPILER14_UP} {$DEFINE COMPILER12_UP} {$ENDIF} +{$IFDEF COMPILER12_UP} {$DEFINE COMPILER11_UP} {$ENDIF} +{$IFDEF COMPILER11_UP} {$DEFINE COMPILER10_UP} {$ENDIF} +{$IFDEF COMPILER10_UP} {$DEFINE COMPILER9_UP} {$ENDIF} +{$IFDEF COMPILER9_UP} {$DEFINE COMPILER8_UP} {$ENDIF} +{$IFDEF COMPILER8_UP} {$DEFINE COMPILER7_UP} {$ENDIF} +{$IFDEF COMPILER7_UP} {$DEFINE COMPILER6_UP} {$ENDIF} +{$IFDEF COMPILER6_UP} {$DEFINE COMPILER5_UP} {$ENDIF} +{$IFDEF COMPILER5_UP} {$DEFINE COMPILER4_UP} {$ENDIF} +{$IFDEF COMPILER4_UP} {$DEFINE COMPILER35_UP} {$ENDIF} +{$IFDEF COMPILER35_UP} {$DEFINE COMPILER3_UP} {$ENDIF} +{$IFDEF COMPILER3_UP} {$DEFINE COMPILER2_UP} {$ENDIF} +{$IFDEF COMPILER2_UP} {$DEFINE COMPILER1_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ RTLX_UP from RTLX_UP mappings } +{------------------------------------------------------------------------------} + +{$IFDEF RTL270_UP} {$DEFINE RTL260_UP} {$ENDIF} +{$IFDEF RTL260_UP} {$DEFINE RTL250_UP} {$ENDIF} +{$IFDEF RTL250_UP} {$DEFINE RTL240_UP} {$ENDIF} +{$IFDEF RTL240_UP} {$DEFINE RTL230_UP} {$ENDIF} +{$IFDEF RTL230_UP} {$DEFINE RTL220_UP} {$ENDIF} +{$IFDEF RTL220_UP} {$DEFINE RTL210_UP} {$ENDIF} +{$IFDEF RTL210_UP} {$DEFINE RTL200_UP} {$ENDIF} +{$IFDEF RTL200_UP} {$DEFINE RTL190_UP} {$ENDIF} +{$IFDEF RTL190_UP} {$DEFINE RTL185_UP} {$ENDIF} +{$IFDEF RTL185_UP} {$DEFINE RTL180_UP} {$ENDIF} +{$IFDEF RTL180_UP} {$DEFINE RTL170_UP} {$ENDIF} +{$IFDEF RTL170_UP} {$DEFINE RTL160_UP} {$ENDIF} +{$IFDEF RTL160_UP} {$DEFINE RTL150_UP} {$ENDIF} +{$IFDEF RTL150_UP} {$DEFINE RTL145_UP} {$ENDIF} +{$IFDEF RTL145_UP} {$DEFINE RTL142_UP} {$ENDIF} +{$IFDEF RTL142_UP} {$DEFINE RTL140_UP} {$ENDIF} +{$IFDEF RTL140_UP} {$DEFINE RTL130_UP} {$ENDIF} +{$IFDEF RTL130_UP} {$DEFINE RTL125_UP} {$ENDIF} +{$IFDEF RTL125_UP} {$DEFINE RTL120_UP} {$ENDIF} +{$IFDEF RTL120_UP} {$DEFINE RTL110_UP} {$ENDIF} +{$IFDEF RTL110_UP} {$DEFINE RTL100_UP} {$ENDIF} +{$IFDEF RTL100_UP} {$DEFINE RTL93_UP} {$ENDIF} +{$IFDEF RTL93_UP} {$DEFINE RTL90_UP} {$ENDIF} +{$IFDEF RTL90_UP} {$DEFINE RTL80_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ Check for CLR overrides of default detection } +{------------------------------------------------------------------------------} + +{$IFDEF CLR} + {$IFDEF FORCE_CLR10} + {$DEFINE CLR10} + {$UNDEF CLR11} + {$UNDEF CLR20} + {$ENDIF FORCE_CLR10} + + {$IFDEF FORCE_CLR11} + {$UNDEF CLR10} + {$DEFINE CLR11} + {$UNDEF CLR20} + {$ENDIF FORCE_CLR11} + + {$IFDEF FORCE_CLR20} + {$UNDEF CLR10} + {$UNDEF CLR11} + {$DEFINE CLR20} + {$ENDIF FORCE_CLR20} +{$ENDIF CLR} + +{------------------------------------------------------------------------------} +{ CLRX from CLRX_UP mappings } +{------------------------------------------------------------------------------} + +{$IFDEF CLR10} {$DEFINE CLR10_UP} {$ENDIF} +{$IFDEF CLR11} {$DEFINE CLR11_UP} {$ENDIF} +{$IFDEF CLR20} {$DEFINE CLR20_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ CLRX_UP from CLRX_UP mappings } +{------------------------------------------------------------------------------} + +{$IFDEF CLR20_UP} {$DEFINE CLR11_UP} {$ENDIF} +{$IFDEF CLR11_UP} {$DEFINE CLR10_UP} {$ENDIF} + +{------------------------------------------------------------------------------} + +{$IFDEF DELPHICOMPILER} + {$DEFINE DELPHILANGUAGE} +{$ENDIF} + +{$IFDEF BCBCOMPILER} + {$DEFINE DELPHILANGUAGE} +{$ENDIF} + +{------------------------------------------------------------------------------} +{ KYLIXX_UP from KYLIXX mappings } +{------------------------------------------------------------------------------} + +{$IFDEF KYLIX3} {$DEFINE KYLIX3_UP} {$ENDIF} +{$IFDEF KYLIX2} {$DEFINE KYLIX2_UP} {$ENDIF} +{$IFDEF KYLIX1} {$DEFINE KYLIX1_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ KYLIXX_UP from KYLIXX_UP mappings } +{------------------------------------------------------------------------------} + +{$IFDEF KYLIX3_UP} {$DEFINE KYLIX2_UP} {$ENDIF} +{$IFDEF KYLIX2_UP} {$DEFINE KYLIX1_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ Map COMPILERX_UP to friendly feature names } +{------------------------------------------------------------------------------} + +{$IFDEF FPC} + {$IFDEF VER1_0} + Please use FPC 2.0 or higher to compile this. + {$ELSE} + {$DEFINE SUPPORTS_OUTPARAMS} + {$DEFINE SUPPORTS_WIDECHAR} + {$DEFINE SUPPORTS_WIDESTRING} + {$IFDEF HASINTF} + {$DEFINE SUPPORTS_INTERFACE} + {$ENDIF} + {$IFDEF HASVARIANT} + {$DEFINE SUPPORTS_VARIANT} + {$ENDIF} + {$IFDEF FPC_HAS_TYPE_SINGLE} + {$DEFINE SUPPORTS_SINGLE} + {$ENDIF} + {$IFDEF FPC_HAS_TYPE_DOUBLE} + {$DEFINE SUPPORTS_DOUBLE} + {$ENDIF} + {$IFDEF FPC_HAS_TYPE_EXTENDED} + {$DEFINE SUPPORTS_EXTENDED} + {$ENDIF} + {$IFDEF HASCURRENCY} + {$DEFINE SUPPORTS_CURRENCY} + {$ENDIF} + {$DEFINE SUPPORTS_THREADVAR} + {$DEFINE SUPPORTS_CONSTPARAMS} + {$DEFINE SUPPORTS_LONGWORD} + {$DEFINE SUPPORTS_INT64} + {$DEFINE SUPPORTS_DYNAMICARRAYS} + {$DEFINE SUPPORTS_DEFAULTPARAMS} + {$DEFINE SUPPORTS_OVERLOAD} + {$DEFINE ACCEPT_DEPRECATED} // 2.2 also gives warnings + {$DEFINE ACCEPT_PLATFORM} // 2.2 also gives warnings + {$DEFINE ACCEPT_LIBRARY} + {$DEFINE SUPPORTS_EXTSYM} + {$DEFINE SUPPORTS_NODEFINE} + + {$DEFINE SUPPORTS_CUSTOMVARIANTS} + {$DEFINE SUPPORTS_VARARGS} + {$DEFINE SUPPORTS_ENUMVALUE} + {$IFDEF LINUX} + {$DEFINE HAS_UNIT_LIBC} + {$ENDIF LINUX} + {$DEFINE HAS_UNIT_CONTNRS} + {$DEFINE HAS_UNIT_TYPES} + {$DEFINE HAS_UNIT_VARIANTS} + {$DEFINE HAS_UNIT_STRUTILS} + {$DEFINE HAS_UNIT_DATEUTILS} + {$DEFINE HAS_UNIT_RTLCONSTS} + + {$DEFINE XPLATFORM_RTL} + + {$IFDEF VER2_2} + {$DEFINE SUPPORTS_DISPINTERFACE} + {$DEFINE SUPPORTS_IMPLEMENTS} + {$DEFINE SUPPORTS_DISPID} + {$ELSE} + {$UNDEF SUPPORTS_DISPINTERFACE} + {$UNDEF SUPPORTS_IMPLEMENTS} + {$endif} + {$UNDEF SUPPORTS_UNSAFE_WARNINGS} + {$ENDIF} +{$ENDIF FPC} + +{$IFDEF CLR} + {$DEFINE SUPPORTS_UNICODE} +{$ENDIF CLR} + +{$IFDEF COMPILER1_UP} + {$DEFINE SUPPORTS_CONSTPARAMS} + {$DEFINE SUPPORTS_SINGLE} + {$DEFINE SUPPORTS_DOUBLE} + {$DEFINE SUPPORTS_EXTENDED} + {$DEFINE SUPPORTS_PACKAGES} +{$ENDIF COMPILER1_UP} + +{$IFDEF COMPILER2_UP} + {$DEFINE SUPPORTS_CURRENCY} + {$DEFINE SUPPORTS_THREADVAR} + {$DEFINE SUPPORTS_VARIANT} + {$DEFINE SUPPORTS_WIDECHAR} +{$ENDIF COMPILER2_UP} + +{$IFDEF COMPILER3_UP} + {$DEFINE SUPPORTS_OUTPARAMS} + {$DEFINE SUPPORTS_WIDESTRING} + {$DEFINE SUPPORTS_INTERFACE} + {$DEFINE SUPPORTS_DISPINTERFACE} + {$DEFINE SUPPORTS_DISPID} + {$DEFINE SUPPORTS_WEAKPACKAGEUNIT} +{$ENDIF COMPILER3_UP} + +{$IFDEF COMPILER35_UP} + {$DEFINE SUPPORTS_EXTSYM} + {$DEFINE SUPPORTS_NODEFINE} +{$ENDIF COMPILER35_UP} + +{$IFDEF COMPILER4_UP} + {$DEFINE SUPPORTS_LONGWORD} + {$DEFINE SUPPORTS_INT64} + {$DEFINE SUPPORTS_DYNAMICARRAYS} + {$DEFINE SUPPORTS_DEFAULTPARAMS} + {$DEFINE SUPPORTS_OVERLOAD} + {$DEFINE SUPPORTS_IMPLEMENTS} +{$ENDIF COMPILER4_UP} + +{$IFDEF COMPILER6_UP} + {$DEFINE SUPPORTS_DEPRECATED} + {$DEFINE SUPPORTS_LIBRARY} + {$DEFINE SUPPORTS_PLATFORM} + {$DEFINE SUPPORTS_LOCAL} + {$DEFINE SUPPORTS_SETPEFLAGS} + {$DEFINE SUPPORTS_EXPERIMENTAL_WARNINGS} + {$DEFINE ACCEPT_DEPRECATED} + {$DEFINE ACCEPT_PLATFORM} + {$DEFINE ACCEPT_LIBRARY} + {$DEFINE SUPPORTS_DEPRECATED_WARNINGS} + {$DEFINE SUPPORTS_LIBRARY_WARNINGS} + {$DEFINE SUPPORTS_PLATFORM_WARNINGS} + {$DEFINE SUPPORTS_CUSTOMVARIANTS} + {$DEFINE SUPPORTS_VARARGS} + {$DEFINE SUPPORTS_ENUMVALUE} + {$DEFINE SUPPORTS_COMPILETIME_MESSAGES} +{$ENDIF COMPILER6_UP} + +{$IFDEF COMPILER7_UP} + {$DEFINE SUPPORTS_UNSAFE_WARNINGS} +{$ENDIF COMPILER7_UP} + +{$IFDEF COMPILER9_UP} + {$DEFINE SUPPORTS_FOR_IN} + {$DEFINE SUPPORTS_INLINE} + {$DEFINE SUPPORTS_NESTED_CONSTANTS} + {$DEFINE SUPPORTS_NESTED_TYPES} + {$DEFINE SUPPORTS_REGION} + {$IFDEF CLR} + {$DEFINE SUPPORTS_ENHANCED_RECORDS} + {$DEFINE SUPPORTS_CLASS_FIELDS} + {$DEFINE SUPPORTS_CLASS_HELPERS} + {$DEFINE SUPPORTS_CLASS_OPERATORS} + {$DEFINE SUPPORTS_STRICT} + {$DEFINE SUPPORTS_STATIC} + {$DEFINE SUPPORTS_FINAL} + {$ENDIF CLR} +{$ENDIF COMPILER9_UP} + +{$IFDEF COMPILER10_UP} + {$DEFINE SUPPORTS_ENHANCED_RECORDS} + {$DEFINE SUPPORTS_CLASS_FIELDS} + {$DEFINE SUPPORTS_CLASS_HELPERS} + {$DEFINE SUPPORTS_CLASS_OPERATORS} + {$DEFINE SUPPORTS_STRICT} + {$DEFINE SUPPORTS_STATIC} + {$DEFINE SUPPORTS_FINAL} + {$DEFINE SUPPORTS_METHODINFO} +{$ENDIF COMPILER10_UP} + +{$IFDEF COMPILER11_UP} + {$IFDEF CLR} + {$DEFINE SUPPORTS_GENERICS} + {$DEFINE SUPPORTS_DEPRECATED_DETAILS} + {$ENDIF CLR} +{$ENDIF COMPILER11_UP} + +{$IFDEF COMPILER12_UP} + {$DEFINE SUPPORTS_GENERICS} + {$DEFINE SUPPORTS_DEPRECATED_DETAILS} + {$DEFINE SUPPORTS_INT_ALIASES} + {$IFNDEF CLR} + {$DEFINE SUPPORTS_UNICODE} + {$DEFINE SUPPORTS_UNICODE_STRING} + {$ENDIF CLR} +{$ENDIF COMPILER12_UP} + +{$IFDEF COMPILER14_UP} + {$DEFINE SUPPORTS_CLASS_CTORDTORS} + {$DEFINE HAS_UNIT_RTTI} + {$DEFINE SUPPORTS_CAST_INTERFACE_TO_OBJ} + {$DEFINE SUPPORTS_DELAYED_LOADING} +{$ENDIF COMPILER14_UP} + +{$IFDEF COMPILER16_UP} + {$DEFINE USE_64BIT_TYPES} +{$ENDIF COMPILER16_UP} + +{$IFDEF RTL130_UP} + {$DEFINE HAS_UNIT_CONTNRS} +{$ENDIF RTL130_UP} + +{$IFDEF RTL140_UP} + {$IFDEF LINUX} + {$DEFINE HAS_UNIT_LIBC} + {$ENDIF LINUX} + {$DEFINE HAS_UNIT_RTLCONSTS} + {$DEFINE HAS_UNIT_TYPES} + {$DEFINE HAS_UNIT_VARIANTS} + {$DEFINE HAS_UNIT_STRUTILS} + {$DEFINE HAS_UNIT_DATEUTILS} + {$DEFINE XPLATFORM_RTL} +{$ENDIF RTL140_UP} + +{$IFDEF RTL170_UP} + {$DEFINE HAS_UNIT_HTTPPROD} +{$ENDIF RTL170_UP} + +{$IFDEF RTL185_UP} + {$DEFINE HAS_UNIT_GIFIMG} +{$ENDIF RTL185_UP} + +{$IFDEF RTL200_UP} + {$DEFINE HAS_UNIT_ANSISTRINGS} + {$DEFINE HAS_UNIT_PNGIMAGE} + {$DEFINE HAS_UNIT_CHARACTER} +{$ENDIF RTL200_UP} + +{$IFDEF RTL220_UP} + {$DEFINE SUPPORTS_UINT64} + {$DEFINE HAS_UNIT_REGULAREXPRESSIONSAPI} +{$ENDIF RTL220_UP} + +{$IFDEF RTL230_UP} + {$DEFINE HAS_UNITSCOPE} + {$DEFINE HAS_UNIT_SYSTEM_UITYPES} +{$ENDIF RTL230_UP} + +{$IFDEF RTL240_UP} + {$DEFINE HAS_UNIT_SYSTEM_ACTIONS} + {$DEFINE HAS_PROPERTY_STYLEELEMENTS} +{$ENDIF RTL240_UP} + +{$IFDEF RTL250_UP} + {$DEFINE DEPRECATED_SYSUTILS_ANSISTRINGS} +{$ENDIF RTL250_UP} + +{$IFDEF RTL270_UP} + {$DEFINE HAS_AUTOMATIC_DB_FIELDS} +{$ENDIF RTL270_UP} + +{------------------------------------------------------------------------------} +{ Cross-platform related defines } +{------------------------------------------------------------------------------} + +{$IFNDEF CPUASM} + {$DEFINE PUREPASCAL} +{$ENDIF ~CPUASM} + +{$IFDEF WIN32} + {$DEFINE MSWINDOWS} // predefined for D6+/BCB6+ + {$DEFINE Win32API} +{$ENDIF} + +{$IFDEF DELPHILANGUAGE} + {$IFDEF LINUX} + {$DEFINE UNIX} + {$ENDIF} + + {$IFNDEF CONSOLE} + {$IFDEF LINUX} + {$DEFINE VisualCLX} + {$ENDIF} + {$IFNDEF VisualCLX} + {$DEFINE VCL} + {$ENDIF} + {$ENDIF ~CONSOLE} +{$ENDIF DELPHILANGUAGE} + +{------------------------------------------------------------------------------} +{ Compiler settings } +{------------------------------------------------------------------------------} + +{$IFOPT A+} {$DEFINE ALIGN_ON} {$ENDIF} +{$IFOPT B+} {$DEFINE BOOLEVAL_ON} {$ENDIF} +{$IFDEF COMPILER2_UP} + {$IFOPT C+} {$DEFINE ASSERTIONS_ON} {$ENDIF} +{$ENDIF} +{$IFOPT D+} {$DEFINE DEBUGINFO_ON} {$ENDIF} +{$IFOPT G+} {$DEFINE IMPORTEDDATA_ON} {$ENDIF} +{$IFDEF COMPILER2_UP} + {$IFOPT H+} {$DEFINE LONGSTRINGS_ON} {$ENDIF} +{$ENDIF} + +// Hints +{$IFOPT I+} {$DEFINE IOCHECKS_ON} {$ENDIF} +{$IFDEF COMPILER2_UP} + {$IFOPT J+} {$DEFINE WRITEABLECONST_ON} {$ENDIF} +{$ENDIF} +{$IFOPT L+} {$DEFINE LOCALSYMBOLS} {$DEFINE LOCALSYMBOLS_ON} {$ENDIF} +{$IFOPT M+} {$DEFINE TYPEINFO_ON} {$ENDIF} +{$IFOPT O+} {$DEFINE OPTIMIZATION_ON} {$ENDIF} +{$IFOPT P+} {$DEFINE OPENSTRINGS_ON} {$ENDIF} +{$IFOPT Q+} {$DEFINE OVERFLOWCHECKS_ON} {$ENDIF} +{$IFOPT R+} {$DEFINE RANGECHECKS_ON} {$ENDIF} + +// Real compatibility +{$IFOPT T+} {$DEFINE TYPEDADDRESS_ON} {$ENDIF} +{$IFOPT U+} {$DEFINE SAFEDIVIDE_ON} {$ENDIF} +{$IFOPT V+} {$DEFINE VARSTRINGCHECKS_ON} {$ENDIF} +{$IFOPT W+} {$DEFINE STACKFRAMES_ON} {$ENDIF} + +// Warnings +{$IFOPT X+} {$DEFINE EXTENDEDSYNTAX_ON} {$ENDIF} + +// for Delphi/BCB trial versions remove the point from the line below +{.$UNDEF SUPPORTS_WEAKPACKAGEUNIT} + +{$ENDIF ~JEDI_INC} diff --git a/source/packages/jcl/windowsonly.inc b/source/packages/jcl/windowsonly.inc new file mode 100644 index 00000000..d77d9bba --- /dev/null +++ b/source/packages/jcl/windowsonly.inc @@ -0,0 +1,54 @@ +{$IFNDEF WINDOWSONLY_INC} +{$DEFINE WINDOWSONLY_INC} + +{**************************************************************************************************} +{ } +{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License");} +{ you may not use this file except in compliance with the License. You may obtain a copy of the } +{ License at http://www.mozilla.org/MPL/ } +{ } +{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF } +{ ANY KIND, either express or implied. See the License for the specific language governing rights } +{ and limitations under the License. } +{ } +{ The Original Code is: windowsonly.inc, released on 2002-07-04. } +{ } +{ You may retrieve the latest version of this file at the JCL home page, } +{ located at http://jcl.sourceforge.net/ } +{ } +{**************************************************************************************************} +{ } +{ Last modified: $Date:: $ } +{ Revision: $Rev:: $ } +{ Author: $Author:: $ } +{ } +{**************************************************************************************************} + +{$IFNDEF JEDI_INC} +ALERT_jedi_inc_missing +// This inc file depends on jedi.inc which has to +// be included first (usually indirectly through +// the inclusion of jcl.inc). +{$ENDIF ~JEDI_INC} + +// Suppress platform warnings which are irrelevant +// because the including unit can only be compiled +// for the Windows platform anyway. + +{$IFDEF SUPPORTS_PLATFORM_WARNINGS} + {$WARN UNIT_PLATFORM OFF} + {$WARN SYMBOL_PLATFORM OFF} +{$ENDIF SUPPORTS_PLATFORM_WARNINGS} + +// Cause a compilation error for any platform except Windows. + +{$IFNDEF MSWINDOWS} + {$IFDEF SUPPORTS_COMPILETIME_MESSAGES} + {$MESSAGE FATAL 'This unit is only supported on Windows!'} + {$ELSE} + 'This unit is only supported on Windows!' + {$ENDIF SUPPORTS_COMPILETIME_MESSAGES} +{$ENDIF ~MSWINDOWS} + +{$ENDIF ~WINDOWSONLY_INC} + diff --git a/source/packages/my/ComboEdit.pas b/source/packages/my/ComboEdit.pas index 622d5682..574271a2 100644 --- a/source/packages/my/ComboEdit.pas +++ b/source/packages/my/ComboEdit.pas @@ -383,7 +383,7 @@ procedure Register; implementation uses - ShellAPI, Consts, ExtDlgs, Variants; + ShellAPI, Consts, ExtDlgs, Variants, PasTools, UITypes; procedure Register; begin @@ -429,7 +429,7 @@ function DirExists(Name: string): Boolean; var Code: Integer; begin - Code := GetFileAttributes(PChar(Name)); + Code := GetFileAttributes(PChar(ApiPath(Name))); Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0); end; @@ -996,7 +996,7 @@ function ClipFilename(const FileName: string): string; var Params: string; begin - if FileExists(FileName) then Result := FileName + if FileExists(ApiPath(FileName)) then Result := FileName else SplitCommandLine(FileName, Result, Params); end; @@ -1291,7 +1291,7 @@ procedure TDirectoryEdit.ReceptFileDir(const AFileName: string); var Temp: string; begin - if FileExists(AFileName) then Temp := ExtractFilePath(AFileName) + if FileExists(ApiPath(AFileName)) then Temp := ExtractFilePath(AFileName) else Temp := AFileName; if (Text = '') or not MultipleDirs then Text := Temp else Text := Text + ';' + Temp; diff --git a/source/packages/my/DiscMon.pas b/source/packages/my/DiscMon.pas index 2f329399..c154820a 100644 --- a/source/packages/my/DiscMon.pas +++ b/source/packages/my/DiscMon.pas @@ -204,6 +204,9 @@ procedure Register; implementation +uses + PasTools; + {$WARN SYMBOL_PLATFORM OFF} {$IFDEF BUGFIX} @@ -227,7 +230,7 @@ procedure AddDirectory(Dirs: TStrings; Directory: string; begin FindAttrs := faReadOnly or faHidden or faSysFile or faDirectory or faArchive; Directory := IncludeTrailingBackslash(Directory); - Found := (FindFirst(Directory + '*.*', FindAttrs, SearchRec) = 0); + Found := (FindFirst(ApiPath(Directory + '*.*'), FindAttrs, SearchRec) = 0); if Found then begin @@ -288,8 +291,6 @@ constructor TDiscMonitorThread.Create; begin inherited Create(True); FDirectories := TStringList.Create; - (FDirectories as TStringList).CaseSensitive := False; - (FDirectories as TStringList).Sorted := True; FDestroyEvent := CreateEvent(nil, True, False, nil); FChangeEvent := CreateEvent(nil, False, False, nil); FOnFilter := nil; @@ -340,7 +341,12 @@ procedure TDiscMonitorThread.SaveOSError; procedure TDiscMonitorThread.SetDirectories(const Value: TStrings); begin - if Value <> nil then FDirectories.Assign(Value) + if Value <> nil then + begin + FDirectories.Assign(Value); + (FDirectories as TStringList).CaseSensitive := False; + (FDirectories as TStringList).Sorted := True; + end else FDirectories.Clear; Update; end; diff --git a/source/packages/my/IEListView.pas b/source/packages/my/IEListView.pas index 2d27d6cd..f04536b3 100644 --- a/source/packages/my/IEListView.pas +++ b/source/packages/my/IEListView.pas @@ -313,7 +313,7 @@ procedure Register; implementation uses - PasTools; + PasTools, Types; const HDF_SORTUP = $400; const HDF_SORTDOWN = $200; diff --git a/source/packages/my/NortonLikeListView.pas b/source/packages/my/NortonLikeListView.pas index d3e612dd..6f0c5a6b 100644 --- a/source/packages/my/NortonLikeListView.pas +++ b/source/packages/my/NortonLikeListView.pas @@ -185,7 +185,7 @@ procedure Register; implementation uses - PasTools; + PasTools, Types; procedure Register; begin diff --git a/source/packages/my/PasTools.pas b/source/packages/my/PasTools.pas index 22f3618d..d309546e 100644 --- a/source/packages/my/PasTools.pas +++ b/source/packages/my/PasTools.pas @@ -39,6 +39,16 @@ function IsAppIconic: Boolean; procedure SetAppIconic(Value: Boolean); procedure SetAppMainForm(Value: TForm); +procedure ForceColorChange(Control: TWinControl); + +type + TApiPathEvent = function(Path: string): string; + +var + OnApiPath: TApiPathEvent = nil; + +function ApiPath(Path: string): string; + type TControlScrollBeforeUpdate = procedure(ObjectToValidate: TObject) of object; TControlScrollAfterUpdate = procedure of object; @@ -90,7 +100,7 @@ TListBoxScrollOnDragOver = class(TCustomControlScrollOnDragOver) implementation uses - SysUtils, Messages, StdCtrls; + SysUtils, Messages, StdCtrls, Graphics; const DDExpandDelay = 15000000; @@ -341,6 +351,25 @@ procedure SetAppMainForm(Value: TForm); Application.SetMainForm(Value); end; +function ApiPath(Path: string): string; +begin + Result := Path; + if Assigned(OnApiPath) then + begin + Result := OnApiPath(Result); + end; +end; + +procedure ForceColorChange(Control: TWinControl); +begin + // particularly when changing color back to default (clWindow), + // non-client area (border line) is not redrawn, + // keeping previous color. force redraw here + if Control.HandleAllocated then + begin + RedrawWindow(Control.Handle, nil, 0, RDW_INVALIDATE or RDW_FRAME); + end; +end; { TCustomControlScrollOnDragOver } diff --git a/source/packages/my/TcpIp.pas b/source/packages/my/TcpIp.pas index e8ba034b..265e97c5 100644 --- a/source/packages/my/TcpIp.pas +++ b/source/packages/my/TcpIp.pas @@ -23,8 +23,8 @@ interface ETcpIpError = class(Exception); ESocketError = class(ETcpIpError) - ErrorNumber: Cardinal; - constructor Create(Number: Cardinal); + ErrorNumber: Integer; + constructor Create(Number: Integer); end; EProtocolError = class(ETcpIpError) @@ -238,7 +238,7 @@ constructor EProtocolError.Create(const Proto, Msg: string; Number: Word); ErrorNumber := Number; end; -constructor ESocketError.Create(Number: Cardinal); +constructor ESocketError.Create(Number: Integer); const UnknownSuccessError = $1BD0000; var diff --git a/source/packages/png/PngImageList.pas b/source/packages/png/PngImageList.pas index 44ab3a1b..9a750797 100644 --- a/source/packages/png/PngImageList.pas +++ b/source/packages/png/PngImageList.pas @@ -160,7 +160,9 @@ function FindMethodPatch(const Name: string): TMethodPatch; end; end; +{$IF RTLVersion > 18.0 } {$POINTERMATH ON} +{$IFEND} function PatchPtr(OldPtr, NewPtr: Pointer; const Name: string; Patch: TMethodPatch): Boolean; var Access: Cardinal; @@ -180,7 +182,11 @@ function PatchPtr(OldPtr, NewPtr: Pointer; const Name: string; Patch: TMethodPat Move(opCode^, Patch.OldBody[0], memSize); if VirtualProtect(OldPtr, 16, PAGE_EXECUTE_READWRITE, @Access) then begin opCode^ := $E9; // Near jump + {$IF RTLVersion > 18.0 } operand^ := PByte(NewPtr) - PByte(OldPtr) - 5; + {$ELSE} + operand^ := PChar(NewPtr) - PChar(OldPtr) - 5; + {$IFEND} VirtualProtect(OldPtr, 16, Access, @Access); // {$IF not (defined(CPU386) or defined(CPUX86) or defined(CPUX64)) } // FlushInstructionCache(GetCurrentProcess, OldPtr, memSize); @@ -191,7 +197,9 @@ function PatchPtr(OldPtr, NewPtr: Pointer; const Name: string; Patch: TMethodPat if not Result then Patch.OldPointer := nil; end; +{$IF RTLVersion > 18.0 } {$POINTERMATH OFF} +{$IFEND} procedure ApplyMethodPatches; type diff --git a/source/packages/tb2k/TB2Acc.pas b/source/packages/tb2k/TB2Acc.pas index 860b6115..b1d510cd 100644 --- a/source/packages/tb2k/TB2Acc.pas +++ b/source/packages/tb2k/TB2Acc.pas @@ -151,7 +151,7 @@ TTBItemViewerAccObject = class(TTBCustomAccObject, IUnknown, IDispatch, ITBAcc implementation uses - {$IFDEF JR_D6} Variants, {$ENDIF} ActiveX, Menus, TB2Common, Winapi.oleacc; + {$IFDEF JR_D6} Variants, {$ENDIF} ActiveX, Menus, TB2Common, Winapi.oleacc, Types; const { Constants from OleAcc.h } diff --git a/source/packages/tb2k/TB2Common.pas b/source/packages/tb2k/TB2Common.pas index c5d1bc83..07eb1abf 100644 --- a/source/packages/tb2k/TB2Common.pas +++ b/source/packages/tb2k/TB2Common.pas @@ -80,7 +80,7 @@ procedure ProcessPaintMessages; procedure RemoveMessages(const AMin, AMax: Integer); procedure RemoveFromList(var List: TList; Item: Pointer); procedure SelectNCUpdateRgn(Wnd: HWND; DC: HDC; Rgn: HRGN); -function StripAccelChars(const S: String): String; +function StripAccelChars(const S: String; IncludingStandaloneKey: Boolean = False {MP}): String; function StripTrailingPunctuation(const S: String): String; function UsingMultipleMonitors: Boolean; @@ -94,7 +94,7 @@ function UsingMultipleMonitors: Boolean; implementation uses - TB2Version; + TB2Version, Types, System.Character {MP}; function ApplicationIsActive: Boolean; { Returns True if the application is in the foreground } @@ -308,7 +308,7 @@ function GetTextHeight(const DC: HDC): Integer; Result := TextMetric.tmHeight; end; -function StripAccelChars(const S: String): String; +function StripAccelChars(const S: String; IncludingStandaloneKey: Boolean {MP}): String; var I: Integer; begin @@ -317,7 +317,23 @@ function StripAccelChars(const S: String): String; while I <= Length(Result) do begin if not CharInSet(Result[I], LeadBytes) then begin if Result[I] = '&' then - System.Delete(Result, I, 1); + begin + {MP} + // Trim trailing artificial accelerators typical for asian translation + // e.g. "ローカル(&L)" + if IncludingStandaloneKey and + (I = Length(Result) - 2) and + (Result[I - 1] = '(') and + Result[I + 1].IsLetter() and + (Result[I + 2] = ')') then + begin + System.Delete(Result, I - 1, 4); + end + else + begin + System.Delete(Result, I, 1); + end; + end; Inc(I); end else diff --git a/source/packages/tb2k/TB2Dock.pas b/source/packages/tb2k/TB2Dock.pas index 8eead249..ec29e3a3 100644 --- a/source/packages/tb2k/TB2Dock.pas +++ b/source/packages/tb2k/TB2Dock.pas @@ -577,7 +577,7 @@ implementation uses Registry, IniFiles, Consts, Menus, - TB2Common, TB2Hook, TB2Consts; + TB2Common, TB2Hook, TB2Consts, Types; type TControlAccess = class(TControl); diff --git a/source/packages/tb2k/TB2ExtItems.pas b/source/packages/tb2k/TB2ExtItems.pas index 43b74577..9e89f7e7 100644 --- a/source/packages/tb2k/TB2ExtItems.pas +++ b/source/packages/tb2k/TB2ExtItems.pas @@ -255,9 +255,9 @@ procedure TTBEditAction.SetEditCaption(Value: String); I: Integer; begin if FEditCaption <> Value then begin - for I := 0 to FClients.Count - 1 do - if TBasicActionLink(FClients[I]) is TTBEditItemActionLink then - TTBEditItemActionLink(FClients[I]).SetEditCaption(Value); + for I := 0 to ClientCount - 1 do + if TBasicActionLink(Clients[I]) is TTBEditItemActionLink then + TTBEditItemActionLink(Clients[I]).SetEditCaption(Value); FEditCaption := Value; Change; end; @@ -268,9 +268,9 @@ procedure TTBEditAction.SetEditOptions(Value: TTBEditItemOptions); I: Integer; begin if FEditOptions <> Value then begin - for I := 0 to FClients.Count - 1 do - if TBasicActionLink(FClients[I]) is TTBEditItemActionLink then - TTBEditItemActionLink(FClients[I]).SetEditOptions(Value); + for I := 0 to ClientCount - 1 do + if TBasicActionLink(Clients[I]) is TTBEditItemActionLink then + TTBEditItemActionLink(Clients[I]).SetEditOptions(Value); FEditOptions := Value; Change; end; @@ -281,9 +281,9 @@ procedure TTBEditAction.SetEditWidth(Value: Integer); I: Integer; begin if FEditWidth <> Value then begin - for I := 0 to FClients.Count - 1 do - if TBasicActionLink(FClients[I]) is TTBEditItemActionLink then - TTBEditItemActionLink(FClients[I]).SetEditWidth(Value); + for I := 0 to ClientCount - 1 do + if TBasicActionLink(Clients[I]) is TTBEditItemActionLink then + TTBEditItemActionLink(Clients[I]).SetEditWidth(Value); FEditWidth := Value; Change; end; @@ -294,9 +294,9 @@ procedure TTBEditAction.SetOnAcceptText(Value: TTBAcceptTextEvent); I: Integer; begin if not MethodsEqual(TMethod(FOnAcceptText), TMethod(Value)) then begin - for I := 0 to FClients.Count - 1 do - if TBasicActionLink(FClients[I]) is TTBEditItemActionLink then - TTBEditItemActionLink(FClients[I]).SetOnAcceptText(Value); + for I := 0 to ClientCount - 1 do + if TBasicActionLink(Clients[I]) is TTBEditItemActionLink then + TTBEditItemActionLink(Clients[I]).SetOnAcceptText(Value); FOnAcceptText := Value; Change; end; @@ -307,9 +307,9 @@ procedure TTBEditAction.SetText(Value: String); I: Integer; begin if FText <> Value then begin - for I := 0 to FClients.Count - 1 do - if TBasicActionLink(FClients[I]) is TTBEditItemActionLink then - TTBEditItemActionLink(FClients[I]).SetText(Value); + for I := 0 to ClientCount - 1 do + if TBasicActionLink(Clients[I]) is TTBEditItemActionLink then + TTBEditItemActionLink(Clients[I]).SetText(Value); FText := Value; Change; end; diff --git a/source/packages/tb2k/TB2Item.pas b/source/packages/tb2k/TB2Item.pas index 0e7d6e9c..ee7e3aa2 100644 --- a/source/packages/tb2k/TB2Item.pas +++ b/source/packages/tb2k/TB2Item.pas @@ -40,7 +40,7 @@ interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, - StdCtrls, CommCtrl, Menus, ActnList, ImgList, TB2Anim; + StdCtrls, CommCtrl, Menus, ActnList, ImgList, TB2Anim, UITypes; const WM_TB2K_POPUPSHOWING = WM_USER + 554; @@ -887,7 +887,7 @@ function ProcessDoneAction(const DoneActionData: TTBDoneActionData; implementation uses - MMSYSTEM, TB2Consts, TB2Common, IMM, TB2Acc, Winapi.oleacc; + MMSYSTEM, TB2Consts, TB2Common, IMM, TB2Acc, Winapi.oleacc, Types; var LastPos: TPoint; @@ -2739,7 +2739,7 @@ function TTBItemViewer.GetCaptionText: String; SetLength(Result, P-1); { MP } if IsToolbarStyle and not (vsMenuBar in View.Style) then - Result := StripAccelChars(StripTrailingPunctuation(Result)); + Result := StripAccelChars(StripTrailingPunctuation(Result), True); end; function TTBItemViewer.GetHintText: String; @@ -6979,7 +6979,9 @@ procedure TBInitToolbarSystemFont; begin NonClientMetrics.cbSize := SizeOf(NonClientMetrics); if SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, @NonClientMetrics, 0) then + begin ToolbarFont.Handle := CreateFontIndirect(NonClientMetrics.lfMenuFont); + end; end; initialization diff --git a/source/packages/tb2k/TB2Reg.pas b/source/packages/tb2k/TB2Reg.pas index 2095341c..9c938749 100644 --- a/source/packages/tb2k/TB2Reg.pas +++ b/source/packages/tb2k/TB2Reg.pas @@ -75,7 +75,7 @@ procedure Register; implementation uses - ImgEdit; + ImgEdit, Actions, UITypes; {$IFDEF JR_D5} diff --git a/source/packages/tbx/TBX.pas b/source/packages/tbx/TBX.pas index 5d7c4198..5bd563c5 100644 --- a/source/packages/tbx/TBX.pas +++ b/source/packages/tbx/TBX.pas @@ -639,7 +639,7 @@ implementation uses TBXExtItems, TBXLists, TB2Common, UxTheme, MultiMon, TBXDefaultTheme, {ComCtrls, Menus;} {vb-} - ComCtrls, Menus, MMSystem; {vb+} + ComCtrls, Menus, MMSystem, Types, UITypes; {vb+} type TTBItemAccess = class(TTBCustomItem); diff --git a/source/packages/tbx/TBXDefaultTheme.pas b/source/packages/tbx/TBXDefaultTheme.pas index 9f104afd..41433049 100644 --- a/source/packages/tbx/TBXDefaultTheme.pas +++ b/source/packages/tbx/TBXDefaultTheme.pas @@ -70,7 +70,8 @@ TTBXDefaultTheme = class(TTBXTheme) implementation uses - Classes, Controls, CommCtrl, TBXUtils, UxTheme, TB2Common, TB2Item, TBX, Forms; + Classes, Controls, CommCtrl, TBXUtils, UxTheme, TB2Common, TB2Item, TBX, Forms, + Types, UITypes; var SmCaptionFont: TFont; diff --git a/source/packages/tbx/TBXLists.pas b/source/packages/tbx/TBXLists.pas index 54711c5d..d29179e3 100644 --- a/source/packages/tbx/TBXLists.pas +++ b/source/packages/tbx/TBXLists.pas @@ -247,6 +247,8 @@ TTBXUndoListViewer = class(TTBXCustomListViewer) implementation +uses Types; + type TTBViewAccess = class(TTBView); const diff --git a/source/packages/tbx/TBXOffice2003Theme.pas b/source/packages/tbx/TBXOffice2003Theme.pas index 6af7da75..72ed7d2c 100644 --- a/source/packages/tbx/TBXOffice2003Theme.pas +++ b/source/packages/tbx/TBXOffice2003Theme.pas @@ -128,7 +128,9 @@ function GetMDIWorkspaceColor: TColor; implementation -uses TBXUtils, TB2Common, TB2Item, Controls, CommCtrl, Forms, SysUtils; +uses + TBXUtils, TB2Common, TB2Item, Controls, CommCtrl, Forms, SysUtils, + Types, UITypes; function GetOffice2003Scheme: TOffice2003Scheme; const diff --git a/source/packages/tbx/TBXOfficeXPTheme.pas b/source/packages/tbx/TBXOfficeXPTheme.pas index 913fb746..3dcd353a 100644 --- a/source/packages/tbx/TBXOfficeXPTheme.pas +++ b/source/packages/tbx/TBXOfficeXPTheme.pas @@ -96,7 +96,9 @@ TTBXOfficeXPTheme = class(TTBXTheme) implementation -uses TBXUtils, TB2Common, TB2Item, Classes, Controls, Commctrl, Forms, SysUtils; +uses + TBXUtils, TB2Common, TB2Item, Classes, Controls, Commctrl, Forms, SysUtils, + Types, UITypes; var StockImgList: TImageList; diff --git a/source/packages/tbx/TBXStatusBars.pas b/source/packages/tbx/TBXStatusBars.pas index bf84ebc3..033c8055 100644 --- a/source/packages/tbx/TBXStatusBars.pas +++ b/source/packages/tbx/TBXStatusBars.pas @@ -13,7 +13,7 @@ interface uses Windows, Messages, Classes, SysUtils, Controls, Forms, Graphics, TBX, - TBXThemes, TB2ITem, ImgList; + TBXThemes, TB2ITem, ImgList, UITypes; type TTBXCustomStatusBar = class; @@ -223,7 +223,7 @@ TTBXStatusBar = class(TTBXCustomStatusBar) implementation -uses TBXUtils; +uses TBXUtils, Types; type TFontSettingsAccess = class(TFontSettings); @@ -972,8 +972,9 @@ procedure TTBXCustomStatusBar.UpdateCache; if (Panel.MaxSize > Panel.CachedSize) and (NewSize > Panel.MaxSize) then begin NewSize := Panel.MaxSize; - Dec(Delta, NewSize - Panel.CachedSize); end; + // MP fix (this was inside branch above, but it has to be done always) + Dec(Delta, NewSize - Panel.CachedSize); Panel.CachedSize := NewSize; SortList.Count := SortList.Count - 1; end; diff --git a/source/packages/tbx/TBXThemes.pas b/source/packages/tbx/TBXThemes.pas index ff13769d..0af2ea50 100644 --- a/source/packages/tbx/TBXThemes.pas +++ b/source/packages/tbx/TBXThemes.pas @@ -438,7 +438,7 @@ function GetTBXDragHandleSize(const ToolbarInfo: TTBXToolbarInfo): Integer; implementation uses - SysUtils, TBXUtils, UxTheme; + SysUtils, TBXUtils, UxTheme, Types; const SPI_GETFLATMENU = $1022; diff --git a/source/packages/tbx/TBXToolPals.pas b/source/packages/tbx/TBXToolPals.pas index a7b6cc20..614a64b8 100644 --- a/source/packages/tbx/TBXToolPals.pas +++ b/source/packages/tbx/TBXToolPals.pas @@ -198,7 +198,7 @@ TTBXColorPalette = class(TTBXCustomToolPalette) implementation -uses ImgList, UxTheme; +uses ImgList, UxTheme, Types; var DefaultColorSet: TTBXCustomColorSet; diff --git a/source/packages/tbx/TBXUtils.pas b/source/packages/tbx/TBXUtils.pas index 93561105..c6172939 100644 --- a/source/packages/tbx/TBXUtils.pas +++ b/source/packages/tbx/TBXUtils.pas @@ -179,7 +179,7 @@ implementation {$R-}{$Q-} -uses TB2Common, Math; +uses TB2Common, Math, Types; {$IFDEF TBX_UNICODE} diff --git a/source/resource/HelpCore.h b/source/resource/HelpCore.h index a7cd5f08..7118f0d2 100644 --- a/source/resource/HelpCore.h +++ b/source/resource/HelpCore.h @@ -30,5 +30,6 @@ #define HELP_RENAME_AFTER_RESUME_ERROR "message_transfer_finished_could_not_rename" #define HELP_INTERNAL_ERROR "internal_error" #define HELP_PRESERVE_TIME_PERM_ERROR "message_preserve_time_perm" +#define HELP_FTP_SUGGESTION "message_server_rejected_sftp_listens_for_ftp" #endif // HelpCoreH diff --git a/source/resource/LicenseExpat.txt b/source/resource/LicenseExpat.txt new file mode 100644 index 00000000..9b45aa0e --- /dev/null +++ b/source/resource/LicenseExpat.txt @@ -0,0 +1,9 @@ +Expat +Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd and Clark Cooper +Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/source/resource/Propagation.rc b/source/resource/Propagation.rc new file mode 100644 index 00000000..4dbd0142 --- /dev/null +++ b/source/resource/Propagation.rc @@ -0,0 +1,24 @@ +STRINGTABLE +BEGIN + SHORT_DESCRIPTION, "Free SFTP, FTP and SCP client for Windows" + LONG_DESCRIPTION, "WinSCP is an open source free SFTP client and FTP client for Windows. Its main function is secure file transfer between a local and a remote computer. Beyond this, WinSCP offers basic file manager and file synchronization functionality." + + FUNCTIONS_PROTOCOLS, "Support for SFTP and SCP protocols over SSH and FTP protocol" + FUNCTIONS_FILE_OPERATION, "All common operations with files" + FUNCTIONS_INTEGRATION, "Integration with Windows (drag&drop, URL, shortcut icons)" + FUNCTIONS_TRANSLATIONS, "Translated into many languages" + FUNCTIONS_AUTOMATION, "Batch file scripting, command-line interface, .NET assembly" + FUNCTIONS_SYNCHRONIZATION, "Directory synchronization in several semi or fully automatic ways" + FUNCTIONS_EDITOR, "Integrated text editor and support for external text editors" + FUNCTIONS_INTERFACES, "Choice of Windows Explorer-like or Norton Commander-like interfaces" + FUNCTIONS_PORTABLE, "Optionally supports portable operation using a configuration file instead of registry entries, suitable for operation from removable media" + + KEYWORD_SFTP_CLIENT, "sftp client" + KEYWORD_FTP_CLIENT, "ftp client" + KEYWORD_FTP, "ftp" + KEYWORD_SCP_CLIENT, "scp client" + KEYWORD_SECURE_TRANSFER, "secure file transfer" + KEYWORD_FREEWARE, "freeware" + + LICENSE, "WinSCP is free software: you can use it, redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version." +END diff --git a/source/resource/TextsCore.h b/source/resource/TextsCore.h index 629420e2..dafb1a65 100644 --- a/source/resource/TextsCore.h +++ b/source/resource/TextsCore.h @@ -7,7 +7,7 @@ #define SCRIPT_HELP_HELP 4 #define SCRIPT_EXIT_HELP 5 -#define SCRIPT_OPEN_HELP5 6 +#define SCRIPT_OPEN_HELP6 6 #define SCRIPT_CLOSE_HELP 7 #define SCRIPT_SESSION_HELP 8 #define SCRIPT_PWD_HELP 9 @@ -22,9 +22,9 @@ #define SCRIPT_CHMOD_HELP 18 #define SCRIPT_LN_HELP 19 #define SCRIPT_MKDIR_HELP 20 -#define SCRIPT_GET_HELP6 21 -#define SCRIPT_PUT_HELP6 22 -#define SCRIPT_OPTION_HELP6 23 +#define SCRIPT_GET_HELP7 21 +#define SCRIPT_PUT_HELP7 22 +#define SCRIPT_OPTION_HELP7 23 #define SCRIPT_SYNCHRONIZE_HELP7 24 #define SCRIPT_KEEPUPTODATE_HELP4 25 #define SCRIPT_CALL_HELP2 26 @@ -224,6 +224,15 @@ #define TLS_CERT_DECODE_ERROR 299 #define FIND_FILE_ERROR 700 #define CERT_NAME_MISMATCH 701 +#define SCRIPT_MATCH_NO_MATCH 702 +#define CERT_ERR_BAD_CHAIN 703 +#define CERT_OK 704 +#define REQUEST_REDIRECTED 705 +#define TOO_MANY_REDIRECTS 706 +#define REDIRECT_LOOP 707 +#define INVALID_URL 708 +#define PROXY_AUTHENTICATION_FAILED 709 +#define CONFIGURED_KEY_NOT_MATCH 710 #define CORE_CONFIRMATION_STRINGS 300 #define CONFIRM_PROLONG_TIMEOUT3 301 @@ -276,7 +285,7 @@ #define YES_STR 401 #define NO_STR 402 #define SESSION_INFO_TIP2 403 -#define VERSION 404 +#define VERSION2 404 #define CLOSED_ON_COMPLETION 405 #define SFTP_PROTOCOL_NAME2 406 #define FS_RENAME_NOT_SUPPORTED 407 @@ -366,7 +375,7 @@ #define RESUME_BUTTON 499 #define FTP_NO_FEATURE_INFO 500 #define FTP_FEATURE_INFO 501 -#define COPY_INFO_CPS_LIMIT 502 +#define COPY_INFO_CPS_LIMIT2 502 #define COPY_KEY_BUTTON 503 #define UPDATE_KEY_BUTTON 504 #define ADD_KEY_BUTTON 505 @@ -396,6 +405,14 @@ #define SCRIPT_SYNCHRONIZE_CHECKLIST 529 #define COPY_INFO_REMOVE_CTRLZ 530 #define COPY_INFO_REMOVE_BOM 531 +#define SCRIPT_NON_DEFAULT_COPY_PARAM 532 +#define SCRIPT_NON_DEFAULT_SYNC_PARAM 533 +#define KEY_TYPE_CONVERT 534 +#define VERSION_BUILD 535 +#define VERSION_DEV_BUILD 536 +#define VERSION_DEBUG_BUILD 537 +#define VERSION_DONT_DISTRIBUTE 538 +#define WEBDAV_EXTENSION_INFO 539 #define CORE_VARIABLE_STRINGS 600 #define PUTTY_BASED_ON 601 @@ -406,9 +423,14 @@ #define FILEZILLA_COPYRIGHT2 607 #define FILEZILLA_URL 608 #define OPENSSL_BASED_ON 609 -#define OPENSSL_COPYRIGHT 610 -#define OPENSSL_VERSION 611 +#define OPENSSL_COPYRIGHT2 610 #define OPENSSL_URL 612 +#define NEON_BASED_ON 613 +#define NEON_COPYRIGHT 614 +#define NEON_URL 615 +#define EXPAT_BASED_ON 616 +#define EXPAT_COPYRIGHT 617 +#define EXPAT_URL 618 #define PUTTY_LICENSE_URL 625 #define MAIN_MSG_TAG 631 diff --git a/source/resource/TextsCore1.rc b/source/resource/TextsCore1.rc index 717740ba..4e566acb 100644 --- a/source/resource/TextsCore1.rc +++ b/source/resource/TextsCore1.rc @@ -38,7 +38,7 @@ BEGIN NOT_DIRECTORY_ERROR, "'%s' is not folder!" CREATE_DIR_ERROR, "Error creating folder '%s'." CREATE_FILE_ERROR, "Can't create file '%s'." - WRITE_ERROR, "Error writting to file '%s'" + WRITE_ERROR, "Error writing to file '%s'" CANT_SET_ATTRS, "Can't set attributes of file '%s'." REMOTE_ERROR, "Received error message from remote side: '%s'" DELETE_FILE_ERROR, "Error deleting file '%s'." @@ -138,7 +138,7 @@ BEGIN SFTP_STATUS_DELETE_PENDING, "An operation was attempted on a file for which a delete operation is pending." SFTP_STATUS_FILE_CORRUPT, "The file is corrupt; an filesystem integrity check should be run." KEY_TYPE_UNKNOWN, "File '%s' does not exist or it does not contain private key in known format." - KEY_TYPE_UNSUPPORTED, "Private key file '%s' contains key in %s format. WinSCP supports only PuTTY format.\n \nYou can use PuTTYgen tool to convert your private key file." + KEY_TYPE_UNSUPPORTED, "**Private key file '%s' contains key in %s format. WinSCP supports only PuTTY format.**\n \nYou can use PuTTYgen tool to convert your private key file." KEY_TYPE_DIFFERENT_SSH, "Private key file '%s' contains key in %s format. It does not follow your preferred SSH protocol version." SFTP_OVERWRITE_FILE_ERROR, "Cannot overwrite remote file '%s'.\n \nPress 'Delete' to delete the file and create new one instead of overwriting it." SFTP_OVERWRITE_DELETE_BUTTON, "&Delete" @@ -189,12 +189,21 @@ BEGIN TLS_CERT_DECODE_ERROR, "Error decoding TLS/SSL certificate (%s)." FIND_FILE_ERROR, "Error retrieving file list for \"%s\"." CERT_NAME_MISMATCH, "Certificate was not issued for this server. You might be connecting to a server that is pretending to be \"%s\"." + SCRIPT_MATCH_NO_MATCH, "No file matching '%s' found." + CERT_ERR_BAD_CHAIN, "Some certificates in certificate chain are invalid." + CERT_OK, "Certificate is valid." CERT_ERR_CERT_CHAIN_TOO_LONG, "Certificate chain too long." CERT_ERR_CERT_HAS_EXPIRED, "Certificate has expired." CERT_ERR_CERT_NOT_YET_VALID, "Certificate is not yet valid." CERT_ERR_CERT_REJECTED, "Certificate rejected." CERT_ERR_CERT_SIGNATURE_FAILURE, "Certificate signature failure." CERT_ERR_CERT_UNTRUSTED, "Certificate not trusted." + REQUEST_REDIRECTED, "WebDAV resource moved to '%s'." + TOO_MANY_REDIRECTS, "Too many redirects." + REDIRECT_LOOP, "Redirect loop detected." + INVALID_URL, "Invalid URL \"%s\"." + PROXY_AUTHENTICATION_FAILED, "Proxy authentication failed." + CONFIGURED_KEY_NOT_MATCH, "Host key does not match configured key \"%s\"!" CORE_CONFIRMATION_STRINGS, "CORE_CONFIRMATION" CONFIRM_PROLONG_TIMEOUT3, "Host is not communicating for %d seconds.\n\nWait for another %0:d seconds?" @@ -239,6 +248,7 @@ BEGIN VERIFY_CERT_CONTACT, "- Organization: %s\n|- Location: %s\n|- Other: %s\n" VERIFY_CERT_CONTACT_LIST, "%s, %s" CERT_TEXT, "Issuer:\n%s\nSubject:\n%s\nValid: %s - %s\n\nFingerprint (SHA1): %s\n\nSummary: %s" + KEY_TYPE_CONVERT, "**Do you want to load this %s private key to PuTTYgen to convert it to PuTTY format?**\n\nPrivate key file '%s' contains key in %s format. WinSCP supports only PuTTY format.\n \nYou can use PuTTYgen tool to convert your private key file." CERT_FILENAME_PROMPT_TITLE, "Certificate file name" CERT_FILENAME_PROMPT, "Enter certificate file name:" @@ -247,7 +257,7 @@ BEGIN YES_STR, "Yes" NO_STR, "No" SESSION_INFO_TIP2, "Host: %s\nUser name: %s\nPrivate key file: %s\nTransfer protocol: %s" - VERSION, "Version %d.%d.%d (Build %d)" + VERSION2, "Version %s (%s)" CLOSED_ON_COMPLETION, "Operation was successfully completed. Connection was closed." SFTP_PROTOCOL_NAME2, "SFTP-%d" FS_RENAME_NOT_SUPPORTED, "The version of SFTP protocol does not allow file renaming." @@ -337,7 +347,7 @@ BEGIN RESUME_BUTTON, "&Resume" FTP_NO_FEATURE_INFO, "The server does not support any additional FTP feature." FTP_FEATURE_INFO, "The server supports these FTP additional features:" - COPY_INFO_CPS_LIMIT, "Transfer speed limit: %u KiB/s" + COPY_INFO_CPS_LIMIT2, "Transfer speed limit: %u KB/s" COPY_KEY_BUTTON, "&Copy Key" UPDATE_KEY_BUTTON, "&Update" ADD_KEY_BUTTON, "&Add" @@ -356,7 +366,7 @@ BEGIN COPY_PARAM_NEWER_ONLY, "&New and updated files only" FTP_SUGGESTION, "The server rejected SFTP connection, but it listens for FTP connections.\n\nDid you want to use FTP protocol instead of SFTP? Prefer using encryption." SCRIPT_CMDLINE_SESSION, "Opening session using command-line parameter in scripting is deprecated. Use 'open' command instead." - ANY_HOSTKEY, "WARNING! Giving up security and accepting any key as configured!" + ANY_HOSTKEY, "WARNING! Giving up security and accepting any host key as configured!" ANY_CERTIFICATE, "WARNING! Giving up security and accepting any certificate as configured!" SCRIPT_SYNC_UPLOAD_NEW, "New local file %s" SCRIPT_SYNC_DOWNLOAD_NEW, "New remote file %s" @@ -367,6 +377,13 @@ BEGIN SCRIPT_SYNCHRONIZE_CHECKLIST, "Differences found:" COPY_INFO_REMOVE_CTRLZ, "Remove EOF mark" COPY_INFO_REMOVE_BOM, "Remove BOM" + SCRIPT_NON_DEFAULT_COPY_PARAM, "Using configured transfer settings different from factory defaults." + SCRIPT_NON_DEFAULT_SYNC_PARAM, "Using configured synchronization options different from factory defaults." + VERSION_BUILD, "Build" + VERSION_DEV_BUILD, "Dev Build" + VERSION_DEBUG_BUILD, "Debug Build" + VERSION_DONT_DISTRIBUTE, "- Do NOT distribute" + WEBDAV_EXTENSION_INFO, "The server supports these WebDAV extensions:" CORE_VARIABLE_STRINGS, "CORE_VARIABLE" PUTTY_BASED_ON, "SSH and SCP code based on PuTTY %s" @@ -377,9 +394,14 @@ BEGIN FILEZILLA_COPYRIGHT2, "Copyright © Tim Kosse" FILEZILLA_URL, "http://filezilla-project.org/" OPENSSL_BASED_ON, "This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit %s." - OPENSSL_COPYRIGHT, "Copyright © 1998-2014 The OpenSSL Project" - OPENSSL_VERSION, "1.0.1h" + OPENSSL_COPYRIGHT2, "Copyright © 1998-%s The OpenSSL Project" OPENSSL_URL, "http://www.openssl.org/" + NEON_BASED_ON, "WebDAV code based on neon library %s" + NEON_COPYRIGHT, "Copyright © 1999-2013 Joe Orton" + NEON_URL, "http://www.webdav.org/neon/" + EXPAT_BASED_ON, "eXpat library %s" + EXPAT_COPYRIGHT, "Copyright © 1998-2012 Expat maintainers" + EXPAT_URL, "http://www.libexpat.org/" PUTTY_LICENSE_URL, "http://www.chiark.greenend.org.uk/~sgtatham/putty/licence.html" MAIN_MSG_TAG, "**" END diff --git a/source/resource/TextsCore2.rc b/source/resource/TextsCore2.rc index f8185914..e1e3c9aa 100644 --- a/source/resource/TextsCore2.rc +++ b/source/resource/TextsCore2.rc @@ -59,16 +59,18 @@ BEGIN " Closes all sessions and terminates the program.\n" "alias:\n" " bye\n" - SCRIPT_OPEN_HELP5, + SCRIPT_OPEN_HELP6, "open \n" - "open [ sftp|scp|ftp:// ][ [ :password ] @ ] [ : ]\n" + "open sftp|scp|ftp|http[s] :// [ [ :password ] @ ] [ : ]\n" " Establishes connection to given host. Use either name of the site or\n" " specify host, username, port and protocol directly.\n" "switches:\n" " -privatekey= Private key file\n" + " -passphrase= Private key passphrase\n" " -timeout= Server response timeout\n" " -hostkey= Fingerprint of server host key (SFTP and SCP only).\n" - " -certificate= Fingerprint of TLS/SSL certificate (FTPS only)\n" + " -certificate= Fingerprint of TLS/SSL certificate\n" + " (FTPS and WebDAVS only)\n" " -passive=on|off Passive mode (FTP protocol only)\n" " -implicit Implicit TLS/SSL (FTPS protocol only)\n" " -explicittls Explicit TLS (FTPS protocol only)\n" @@ -185,7 +187,7 @@ BEGIN " Creates remote directory.\n" "example:\n" " mkdir public_html\n" - SCRIPT_GET_HELP6, + SCRIPT_GET_HELP7, "get [ [ ... ] \\[ ] ]\n" " Downloads one or more files from remote directory to local directory.\n" " If only one parameter is specified downloads the file to local working\n" @@ -204,11 +206,12 @@ BEGIN " -append Append file to end of target file (SFTP protocol only)\n" " -preservetime Preserve timestamp\n" " -nopreservetime Do not preserve timestamp\n" - " -speed= Limit transfer speed\n" + " -speed= Limit transfer speed\n" " -transfer= Transfer mode: binary, ascii, automatic\n" " -filemask= Sets file mask.\n" " -resumesupport= Configures resume support.\n" " Possible values are 'on', 'off' or threshold\n" + " -neweronly Transfer new and updated files only\n" "effective options:\n" " confirm, reconnecttime\n" "examples:\n" @@ -217,7 +220,7 @@ BEGIN " get index.html about.html d:\\www\\\n" " get public_html/index.html d:\\www\\about.*\n" " get *.html *.png d:\\www\\*.bak\n" - SCRIPT_PUT_HELP6, + SCRIPT_PUT_HELP7, "put [ [ ... ] /[ ] ]\n" " Uploads one or more files from local directory to remote directory.\n" " If only one parameter is specified uploads the file to remote working\n" @@ -238,11 +241,12 @@ BEGIN " -nopreservetime Do not preserve timestamp\n" " -permissions= Set permissions\n" " -nopermissions Keep default permissions\n" - " -speed= Limit transfer speed\n" + " -speed= Limit transfer speed\n" " -transfer= Transfer mode: binary, ascii, automatic\n" " -filemask= Sets file mask.\n" " -resumesupport= Configures resume support.\n" " Possible values are 'on', 'off' or threshold\n" + " -neweronly Transfer new and updated files only\n" "effective options:\n" " confirm, reconnecttime\n" "examples:\n" @@ -251,7 +255,7 @@ BEGIN " put -permissions=644 index.html about.html /home/martin/public_html/\n" " put d:\\www\\index.html about.*\n" " put *.html *.png /home/martin/backup/*.bak\n" - SCRIPT_OPTION_HELP6, + SCRIPT_OPTION_HELP7, "option [